diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientCoverTilt.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientCoverTilt.lean new file mode 100644 index 0000000000000000000000000000000000000000..83e3b86a5a59197fab1fda58e56c8993ea28acb4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientCoverTilt.lean @@ -0,0 +1,602 @@ +import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap +import OAI.Combinatorics.Progressions.Fourier.AnchoredCoefficientFourierNormalization +import OAI.Combinatorics.Progressions.Fourier.SiteFourierHaarMean +import OAI.Combinatorics.Progressions.Lattices.SmoothResidueWindowMass +import OAI.Combinatorics.Progressions.Probability.DensityIntegralBound +import OAI.Combinatorics.Progressions.Probability.ProbabilityIntegralApproximation + +namespace OAI + +section + +namespace Erdos3 + +open Polynomial + +theorem exists_integer_cover_threshold (A₀ : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ P : ℝ, 0 ≤ P → + Real.exp ((P + A₀) ^ A₀) ≤ Real.exp ((P + A) ^ A) ∧ + Real.exp P * Real.exp ((P + A₀) ^ A₀) ≤ Real.exp ((P + A) ^ A) := by + obtain ⟨A, hA, hpoly⟩ := exists_natPolynomial_eval_budget (X + (X + C A₀) ^ A₀ + 1) + refine ⟨A, hA, ?_⟩ + intro P hP + have he : P + (P + A₀) ^ A₀ + 1 ≤ (P + A) ^ A := by + simpa [Polynomial.eval₂_pow] using hpoly P hP + constructor + · apply Real.exp_le_exp.mpr + linarith + · rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + linarith + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem affineSampleCoefficientArray_smul {I K : Type*} [Fintype K] {m : ℕ} + {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j) + (r : ℝ) (b : Option K → I → ℝ) : + affineSampleCoefficientArray U (fun j => r • p j) + (fun j => coefficients_smul_mem (U j) (p j) (hm j) r) b = + r • affineSampleCoefficientArray U p hm b := by + funext s + apply Subtype.ext + change (affineSampleCoefficientArray U (fun j => r • p j) _ b s).val = + r • (affineSampleCoefficientArray U p hm b s).val + rw [affineSampleCoefficientArray_val, affineSampleCoefficientArray_val] + simp only [map_smul, Finsupp.smul_apply] + +noncomputable def affineCoefficientCoverSample {I K : Type*} [Fintype K] {m : ℕ} + {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j) + (q : ℕ) (b : Option K → I → ℝ) : CoefficientTorus (K := K) U := + QuotientAddGroup.mk' (coefficientIntegerLattice U) ((q : ℝ)⁻¹ • affineSampleCoefficientArray U p hm b) + +theorem affineCoefficientCoverSample_eq_scaled {I K : Type*} [Fintype K] {m : ℕ} + {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j) + (q : ℕ) (b : Option K → I → ℝ) : + affineCoefficientCoverSample U p hm q b = + affineSampleCoefficientTorus U (fun j => (q : ℝ)⁻¹ • p j) + (fun j => coefficients_smul_mem (U j) (p j) (hm j) (q : ℝ)⁻¹) b := by + rw [affineSampleCoefficientTorus, affineSampleCoefficientArray_smul] + rfl + +theorem affineCoefficientCoverSample_projection {I K : Type*} [Fintype K] {m : ℕ} + {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j) + (q : ℕ) (hq : 0 < q) (b : Option K → I → ℝ) : + quotientIntegerCover (coefficientIntegerLattice U) q (affineCoefficientCoverSample U p hm q b) = + affineSampleCoefficientTorus U p hm b := by + have hq0 : (q : ℝ) ≠ 0 := by exact_mod_cast hq.ne' + rw [affineCoefficientCoverSample, quotientIntegerCover_mk, + smul_smul, mul_inv_cancel₀ hq0, one_smul] + rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_coefficient_haar_comparison (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + coefficientTorusFourierSum U frequency c + (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - + (∫ x, coefficientTorusFourierSum U frequency c x ∂μ)‖ ≤ ε := by + obtain ⟨A, hA, hnormalization⟩ := exists_affine_coefficient_fourier_normalization m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients + p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + obtain ⟨hZ, hnorm⟩ := hnormalization hP hn hd U hC hCP frequency hbound c hB hBP hcoefficients + p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + refine ⟨hZ, ?_⟩ + rw [coefficientTorusFourierSum_integral] + simpa only [coefficientTorusFourierSum, coefficientTorusCharacter_sample U _ p hp hm] using hnorm + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_coefficient_haar_approximation (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (f : CoefficientTorus (K := K) U → ℂ) (_hf : Integrable f μ) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖f x - coefficientTorusFourierSum U frequency c x‖ ≤ η), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + f (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - + (∫ x, f x ∂μ)‖ ≤ 2 * η + ε := by + obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_haar_comparison m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients + p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth f hf η hη happrox + obtain ⟨hZ, hcomp⟩ := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients + p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + refine ⟨hZ, ?_⟩ + let g := coefficientTorusFourierSum U frequency c + let sample (z : Option K × I → ℤ) := affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)) + let E (a : CoefficientTorus (K := K) U → ℂ) := + ∑' z, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * a (sample z) + have hfirst := selectedResidueSmoothPMF_approximation stride G V hV hZ + (fun _ => 1) (fun z => f (sample z)) (fun z => g (sample z)) hη + (fun _ _ => by simp) (fun z _ => happrox (sample z)) + simp only [one_mul] at hfirst + have hlast := probability_integral_approximation μ g f + (coefficientTorusFourierSum_integrable U frequency c μ) hf + (fun x => by simpa only [norm_sub_rev] using happrox x) + have htri := norm_sub_le_norm_sub_add_norm_sub (E f) (E g) (∫ x, f x ∂μ) + have htri' := norm_sub_le_norm_sub_add_norm_sub (E g) (∫ x, g x ∂μ) (∫ x, f x ∂μ) + change ‖E f - E g‖ ≤ η at hfirst + change ‖E g - ∫ x, g x ∂μ‖ ≤ ε at hcomp + change ‖E f - ∫ x, f x ∂μ‖ ≤ 2 * η + ε + linarith + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_coefficient_cover_haar_approximation (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (q : ℕ) (_hq : 0 < q) (_hqP : (q : ℝ) ≤ Real.exp P) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (f : CoefficientTorus (K := K) U → ℂ) (_hf : Integrable f μ) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖f x - coefficientTorusFourierSum U frequency c x‖ ≤ η), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + f (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) - + (∫ x, f x ∂μ)‖ ≤ 2 * η + ε := by + obtain ⟨A₀, _, hcomparison⟩ := exists_affine_coefficient_haar_approximation m + obtain ⟨A, hA, hbudget⟩ := exists_integer_cover_threshold A₀ + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients + p hp hm q hq hqP stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth f hf η hη happrox + have hb := hbudget P hP + have hR0 : 0 ≤ R := (Real.exp_pos _).le.trans hR + have hq0 : (0 : ℝ) < q := by exact_mod_cast hq + have hscaledR : Real.exp ((P + A₀) ^ A₀) ≤ R / q := by + apply (le_div_iff₀ hq0).mpr + calc + _ ≤ Real.exp P * Real.exp ((P + A₀) ^ A₀) := by + simpa only [mul_comm] using mul_le_mul_of_nonneg_right hqP (Real.exp_pos ((P + A₀) ^ A₀)).le + _ ≤ Real.exp ((P + A) ^ A) := hb.2 + _ ≤ R := hR + obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients + (fun j => (q : ℝ)⁻¹ • p j) (fun j => (hp j).smul (q : ℝ)⁻¹) + (fun j => coefficients_smul_mem (U j) (p j) (hm j) (q : ℝ)⁻¹) + stride hs hS hSP hρ hε hρP hεP hstride H (fun k => hb.1.trans (hsize k)) + (fun j => (hrank j).div_nat hR0 q hq) hscaledR G hG V hV hwidth f hf hη happrox + refine ⟨hZ, ?_⟩ + simpa only [affineCoefficientCoverSample_eq_scaled] using he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_coefficient_density_mass (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (_hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ) + (_hDmass : (∫ x, D x ∂μ) = 1) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖(D x : ℂ) - coefficientTorusFourierSum U frequency c x‖ ≤ η), + ∃ _hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + |selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - 1| ≤ + 2 * η + ε := by + obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_haar_approximation m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients + p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth D hD hDmass η hη happrox + obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients + p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + (fun x => (D x : ℂ)) hD.ofReal hη happrox + refine ⟨hZ, ?_⟩ + rw [integral_complex_ofReal, hDmass, Complex.ofReal_one] at he + rw [← selectedResidueDensityMass_complex stride G V hV hZ + (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))), + ← Complex.ofReal_one, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] at he + exact he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_coefficient_cover_tilted_family_comparison (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (F : Bool → Type*) [∀ b, Fintype (F b)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : ∀ b, F b → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C) + (c : ∀ b, F b → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (cover : ℕ) (_hcover : 0 < cover) (_hcoverP : (cover : ℝ) ≤ Real.exp P) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ) + (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x) + (f : CoefficientTorus (K := K) U → ℂ) (_hf : AEStronglyMeasurable f μ) + (_hfbound : ∀ x, ‖f x‖ ≤ 1) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ b x, + ‖(D x : ℂ) * (if b then f x else 1) - coefficientTorusFourierSum U (frequency b) (c b) x‖ ≤ η) + (_hsmall : 2 * η + ε ≤ 1 / 2), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ∃ hDpos : 0 < selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))), + |selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧ + (1 / 2 ≤ selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ))))) ∧ + (selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧ + ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ + (fun z => D (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))) + (fun _z => _hD0 _) hDpos z).toReal : ℂ) * + f (affineCoefficientCoverSample U p _hm cover (fun k j => (z (k, j) : ℝ)))) - + (∫ x, (D x : ℂ) * f x ∂μ)‖ ≤ 4 * (2 * η + ε) := by + obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_cover_haar_approximation m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients + p hp hm cover hcover hcoverP stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + D hD hDmass hD0 f hf hfbound η hη happrox hsmall + let sample (z : Option K × I → ℤ) := affineCoefficientCoverSample U p hm cover (fun k j => (z (k, j) : ℝ)) + obtain ⟨hZ, he0⟩ := hcomparison hP hn hd U μ hC hCP (frequency false) (hbound false) + (c false) hB hBP (hcoefficients false) p hp hm cover hcover hcoverP stride hs hS hSP hρ hε hρP hεP hstride + H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ)) hD.ofReal hη + (fun x => by simpa using happrox false x) + have hmass : |selectedResidueDensityMass stride G V (fun z => D (sample z)) - 1| ≤ 2 * η + ε := by + rw [integral_complex_ofReal, hDmass, Complex.ofReal_one] at he0 + rw [← selectedResidueDensityMass_complex stride G V hV hZ (fun z => D (sample z)), + ← Complex.ofReal_one, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] at he0 + exact he0 + have hlower : 1 / 2 ≤ selectedResidueDensityMass stride G V (fun z => D (sample z)) := by + have := (abs_le.mp hmass).1 + linarith + have hupper : selectedResidueDensityMass stride G V (fun z => D (sample z)) ≤ 3 / 2 := by + have := (abs_le.mp hmass).2 + linarith + have hDpos : 0 < selectedResidueDensityMass stride G V (fun z => D (sample z)) := by linarith + refine ⟨hZ, hDpos, hmass, hlower, hupper, ?_⟩ + obtain ⟨hZ', he1⟩ := hcomparison hP hn hd U μ hC hCP (frequency true) (hbound true) + (c true) hB hBP (hcoefficients true) p hp hm cover hcover hcoverP stride hs hS hSP hρ hε hρP hεP hstride + H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ) * f x) + (density_mul_integrable μ D hD f hf hfbound) hη + (fun x => by simpa using happrox true x) + have he := selectedResidueDensityPMF_error stride G V hV hZ + (fun z => D (sample z)) (fun z => hD0 _) hDpos (fun z => f (sample z)) + hlower he1 hmass (norm_density_integral_le_one μ D hD hD0 hDmass f hfbound) + convert he using 1; ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_coefficient_tilted_comparison (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : Bool → F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C) + (c : Bool → F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ) + (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x) + (f : CoefficientTorus (K := K) U → ℂ) (_hf : AEStronglyMeasurable f μ) + (_hfbound : ∀ x, ‖f x‖ ≤ 1) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ b x, + ‖(D x : ℂ) * (if b then f x else 1) - coefficientTorusFourierSum U (frequency b) (c b) x‖ ≤ η) + (_hsmall : 2 * η + ε ≤ 1 / 2), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ∃ hDpos : 0 < selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))), + |selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧ + (1 / 2 ≤ selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))) ∧ + (selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧ + ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) + (fun _z => _hD0 _) hDpos z).toReal : ℂ) * + f (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - + (∫ x, (D x : ℂ) * f x ∂μ)‖ ≤ 4 * (2 * η + ε) := by + obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_haar_approximation m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients + p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + D hD hDmass hD0 f hf hfbound η hη happrox hsmall + let sample (z : Option K × I → ℤ) := affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)) + obtain ⟨hZ, he0⟩ := hcomparison hP hn hd U μ hC hCP (frequency false) (hbound false) + (c false) hB hBP (hcoefficients false) p hp hm stride hs hS hSP hρ hε hρP hεP hstride + H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ)) hD.ofReal hη + (fun x => by simpa using happrox false x) + have hmass : |selectedResidueDensityMass stride G V (fun z => D (sample z)) - 1| ≤ 2 * η + ε := by + rw [integral_complex_ofReal, hDmass, Complex.ofReal_one] at he0 + rw [← selectedResidueDensityMass_complex stride G V hV hZ (fun z => D (sample z)), + ← Complex.ofReal_one, ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] at he0 + exact he0 + have hlower : 1 / 2 ≤ selectedResidueDensityMass stride G V (fun z => D (sample z)) := by + have := (abs_le.mp hmass).1 + linarith + have hupper : selectedResidueDensityMass stride G V (fun z => D (sample z)) ≤ 3 / 2 := by + have := (abs_le.mp hmass).2 + linarith + have hDpos : 0 < selectedResidueDensityMass stride G V (fun z => D (sample z)) := by linarith + refine ⟨hZ, hDpos, hmass, hlower, hupper, ?_⟩ + obtain ⟨hZ', he1⟩ := hcomparison hP hn hd U μ hC hCP (frequency true) (hbound true) + (c true) hB hBP (hcoefficients true) p hp hm stride hs hS hSP hρ hε hρP hεP hstride + H hsize hrank hR G hG V hV hwidth (fun x => (D x : ℂ) * f x) + (density_mul_integrable μ D hD f hf hfbound) hη + (fun x => by simpa using happrox true x) + have he := selectedResidueDensityPMF_error stride G V hV hZ + (fun z => D (sample z)) (fun z => hD0 _) hDpos (fun z => f (sample z)) + hlower he1 hmass (norm_density_integral_le_one μ D hD hD0 hDmass f hfbound) + convert he using 1; ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_coefficient_cover_tilted_comparison (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : Bool → F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C) + (c : Bool → F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (q : ℕ) (_hq : 0 < q) (_hqP : (q : ℝ) ≤ Real.exp P) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ) + (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x) + (f : CoefficientTorus (K := K) U → ℂ) (_hf : AEStronglyMeasurable f μ) + (_hfbound : ∀ x, ‖f x‖ ≤ 1) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ b x, + ‖(D x : ℂ) * (if b then f x else 1) - coefficientTorusFourierSum U (frequency b) (c b) x‖ ≤ η) + (_hsmall : 2 * η + ε ≤ 1 / 2), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ∃ hDpos : 0 < selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))), + |selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧ + (1 / 2 ≤ selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ))))) ∧ + (selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧ + ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ + (fun z => D (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) + (fun _z => _hD0 _) hDpos z).toReal : ℂ) * + f (affineCoefficientCoverSample U p _hm q (fun k j => (z (k, j) : ℝ)))) - + (∫ x, (D x : ℂ) * f x ∂μ)‖ ≤ 4 * (2 * η + ε) := by + obtain ⟨A₀, _, hcomparison⟩ := exists_affine_coefficient_tilted_comparison m + obtain ⟨A, hA, hbudget⟩ := exists_integer_cover_threshold A₀ + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ C hC hCP frequency hbound c B hB hBP hcoefficients + p hp hm q hq hqP stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + D hD hDmass hD0 f hf hfbound η hη happrox hsmall + have hb := hbudget P hP + have hR0 : 0 ≤ R := (Real.exp_pos _).le.trans hR + have hq0 : (0 : ℝ) < q := by exact_mod_cast hq + have hscaledR : Real.exp ((P + A₀) ^ A₀) ≤ R / q := by + apply (le_div_iff₀ hq0).mpr + calc + _ ≤ Real.exp P * Real.exp ((P + A₀) ^ A₀) := by + simpa only [mul_comm] using mul_le_mul_of_nonneg_right hqP (Real.exp_pos ((P + A₀) ^ A₀)).le + _ ≤ Real.exp ((P + A) ^ A) := hb.2 + _ ≤ R := hR + have he := hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients + (fun j => (q : ℝ)⁻¹ • p j) (fun j => (hp j).smul (q : ℝ)⁻¹) + (fun j => coefficients_smul_mem (U j) (p j) (hm j) (q : ℝ)⁻¹) + stride hs hS hSP hρ hε hρP hεP hstride H (fun k => hb.1.trans (hsize k)) + (fun j => (hrank j).div_nat hR0 q hq) hscaledR G hG V hV hwidth + D hD hDmass hD0 f hf hfbound hη happrox hsmall + simpa only [affineCoefficientCoverSample_eq_scaled] using he + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..bab12ca2374f3aa582453e4162262beeda16465f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientLaw.lean @@ -0,0 +1,313 @@ +import Mathlib.MeasureTheory.Group.Integral +import Mathlib.MeasureTheory.Measure.Haar.NormedSpace +import OAI.Combinatorics.Progressions.Probability.SelectedDensityNormalization + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff + +noncomputable def affineProbabilityProfile (c w x : ℝ) : ℝ := + w⁻¹ * smoothProbabilityProfile ((x - c) / w) + +theorem affineProbabilityProfile_nonneg (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ) : + 0 ≤ affineProbabilityProfile c w x := + mul_nonneg (inv_nonneg.mpr hw.le) (smoothProbabilityProfile_range _).1 + +theorem affineProbabilityProfile_le (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ) : + affineProbabilityProfile c w x ≤ w⁻¹ := by + exact (mul_le_mul_of_nonneg_left (smoothProbabilityProfile_range _).2 + (inv_nonneg.mpr hw.le)).trans_eq (mul_one _) + +theorem affineProbabilityProfile_contDiff (c w : ℝ) : + ContDiff ℝ ∞ (affineProbabilityProfile c w) := by + change ContDiff ℝ ∞ (fun x => w⁻¹ * smoothProbabilityProfile ((x-c)/w)) + exact contDiff_const.mul + (smoothProbabilityProfile_contDiff.comp ((contDiff_id.sub contDiff_const).div_const w)) + +theorem affineProbabilityProfile_zero (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ) + (hx : w < |x - c|) : affineProbabilityProfile c w x = 0 := by + have hnorm : 1 < |(x-c)/w| := by + rw [abs_div, abs_of_pos hw] + exact (one_lt_div hw).mpr hx + rw [affineProbabilityProfile, smoothProbabilityProfile_zero_outside _ hnorm, mul_zero] + +theorem affineProbabilityProfile_zero_outside (c : ℝ) {w : ℝ} (hw : 0 < w) (x : ℝ) + (hx : |c| + w < |x|) : affineProbabilityProfile c w x = 0 := by + apply affineProbabilityProfile_zero c hw x + have ht : |x| ≤ |x-c| + |c| := by + simpa only [sub_add_cancel] using abs_add_le (x-c) c + linarith + +theorem affineProbabilityProfile_compact (c : ℝ) {w : ℝ} (hw : 0 < w) : + HasCompactSupport (affineProbabilityProfile c w) := by + apply HasCompactSupport.of_support_subset_isCompact (isCompact_closedBall (0 : ℝ) (|c|+w)) + intro x hx + rw [Metric.mem_closedBall, dist_zero_right, Real.norm_eq_abs] + exact le_of_not_gt (fun h => hx (affineProbabilityProfile_zero_outside c hw x h)) + +theorem affineProbabilityProfile_integrable (c : ℝ) {w : ℝ} (hw : 0 < w) : + Integrable (affineProbabilityProfile c w) := + (affineProbabilityProfile_contDiff c w).continuous.integrable_of_hasCompactSupport + (affineProbabilityProfile_compact c hw) + +theorem affineProbabilityProfile_integral (c : ℝ) {w : ℝ} (hw : 0 < w) : + (∫ x, affineProbabilityProfile c w x) = 1 := by + change (∫ x, w⁻¹ * smoothProbabilityProfile ((x-c)/w)) = 1 + rw [integral_const_mul, + integral_sub_right_eq_self (fun x => smoothProbabilityProfile (x/w)) c, + Measure.integral_comp_div, smoothProbabilityProfile_integral, smul_eq_mul, + mul_one, abs_of_pos hw, inv_mul_cancel₀ hw.ne'] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators ContDiff + +noncomputable def affineProductProfile {I : Type*} [Fintype I] (c w x : I → ℝ) : ℝ := + ∏ i, affineProbabilityProfile (c i) (w i) (x i) + +noncomputable def profileWidthFactor {I : Type*} [Fintype I] (w : I → ℝ) : ℝ := + ∏ i, (w i)⁻¹ + +theorem affineProductProfile_eq {I : Type*} [Fintype I] (c w x : I → ℝ) : + affineProductProfile c w x = profileWidthFactor w * + smoothProductProfile I (fun i => (x i - c i) / w i) := by + simp only [affineProductProfile, affineProbabilityProfile, Finset.prod_mul_distrib, + profileWidthFactor, smoothProductProfile] + +theorem profileWidthFactor_pos {I : Type*} [Fintype I] (w : I → ℝ) (hw : ∀ i, 0 < w i) : + 0 < profileWidthFactor w := Finset.prod_pos (fun i _ => inv_pos.mpr (hw i)) + +theorem affineProductProfile_nonneg {I : Type*} [Fintype I] (c w : I → ℝ) + (hw : ∀ i, 0 < w i) (x : I → ℝ) : 0 ≤ affineProductProfile c w x := + Finset.prod_nonneg (fun i _ => affineProbabilityProfile_nonneg (c i) (hw i) (x i)) + +theorem affineProductProfile_norm_le {I : Type*} [Fintype I] (c w : I → ℝ) + (hw : ∀ i, 0 < w i) (x : I → ℝ) : ‖affineProductProfile c w x‖ ≤ profileWidthFactor w := by + rw [Real.norm_eq_abs, abs_of_nonneg (affineProductProfile_nonneg c w hw x)] + exact Finset.prod_le_prod₀ (fun i _ => affineProbabilityProfile_nonneg (c i) (hw i) (x i)) + (fun i _ => affineProbabilityProfile_le (c i) (hw i) (x i)) + +theorem affineProductProfile_contDiff {I : Type*} [Fintype I] (c w : I → ℝ) : + ContDiff ℝ ∞ (affineProductProfile c w) := by + unfold affineProductProfile + apply contDiff_prod + intro i _ + exact (affineProbabilityProfile_contDiff (c i) (w i)).comp + (ContinuousLinearMap.proj i : (I → ℝ) →L[ℝ] ℝ).contDiff + +theorem affineProductProfile_compact {I : Type*} [Fintype I] (c w : I → ℝ) + (hw : ∀ i, 0 < w i) : HasCompactSupport (affineProductProfile c w) := + tensorCutoffWeight_compact (fun i => affineProbabilityProfile (c i) (w i)) + (fun i => affineProbabilityProfile_compact (c i) (hw i)) + +theorem affineProductProfile_integrable {I : Type*} [Fintype I] (c w : I → ℝ) + (hw : ∀ i, 0 < w i) : Integrable (affineProductProfile c w) := + (affineProductProfile_contDiff c w).continuous.integrable_of_hasCompactSupport + (affineProductProfile_compact c w hw) + +theorem affineProductProfile_integral {I : Type*} [Fintype I] (c w : I → ℝ) + (hw : ∀ i, 0 < w i) : (∫ x, affineProductProfile c w x) = 1 := by + change (∫ x, tensorCutoffWeight (fun i => affineProbabilityProfile (c i) (w i)) x) = 1 + rw [tensorCutoffWeight_integral] + simp only [affineProbabilityProfile_integral _ (hw _), Finset.prod_const_one] + +theorem affineProductProfile_zero_outside {I : Type*} [Fintype I] (c w : I → ℝ) + (hw : ∀ i, 0 < w i) {R : ℝ} (hR : 0 ≤ R) (hcw : ∀ i, |c i| + w i ≤ R) : + ∀ x, R < ‖x‖ → affineProductProfile c w x = 0 := by + classical + intro x hx + by_contra hne + apply (not_le_of_gt hx) + apply (pi_norm_le_iff_of_nonneg hR).mpr + intro i + rw [Real.norm_eq_abs] + by_contra! hi + exact hne (Finset.prod_eq_zero (Finset.mem_univ i) + (affineProbabilityProfile_zero_outside (c i) (hw i) (x i) ((hcw i).trans_lt hi))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +theorem affineProbabilityProfile_integral_test (c : ℝ) {w : ℝ} (hw : 0 < w) (φ : ℝ → ℝ) : + (∫ x, affineProbabilityProfile c w x * φ x) = + ∫ y, smoothProbabilityProfile y * φ (c + w*y) := by + let g := fun y => smoothProbabilityProfile y * φ (c+w*y) + have he (x : ℝ) : affineProbabilityProfile c w x * φ x = w⁻¹ * g ((x-c)/w) := by + have hx : c + w*((x-c)/w) = x := by field_simp [hw.ne']; ring + simp only [affineProbabilityProfile, g, hx] + ring + simp_rw [he] + rw [integral_const_mul, integral_sub_right_eq_self (fun x => g (x/w)) c, + Measure.integral_comp_div, smul_eq_mul, abs_of_pos hw, ← mul_assoc, + inv_mul_cancel₀ hw.ne', one_mul] + +theorem affineProbabilityProfile_law (c : ℝ) {w : ℝ} (hw : 0 < w) : + (realDensityMeasure volume smoothProbabilityProfile).map (fun y => c + w*y) = + realDensityMeasure volume (affineProbabilityProfile c w) := by + have hψ : Integrable smoothProbabilityProfile := + smoothProbabilityProfile_contDiff.continuous.integrable_of_hasCompactSupport smoothProbabilityProfile_compact + let : IsFiniteMeasure (realDensityMeasure volume smoothProbabilityProfile) := + realDensityMeasure_finite _ _ hψ (fun y => (smoothProbabilityProfile_range y).1) + let : IsFiniteMeasure (realDensityMeasure volume (affineProbabilityProfile c w)) := + realDensityMeasure_finite _ _ (affineProbabilityProfile_integrable c hw) (affineProbabilityProfile_nonneg c hw) + have hmap : Measurable (fun y : ℝ => c+w*y) := by fun_prop + apply finiteMeasure_eq_of_integrals + intro φ hφ + rw [integral_map hmap.aemeasurable hφ.aestronglyMeasurable, + realDensityMeasure_integral volume smoothProbabilityProfile + smoothProbabilityProfile_contDiff.continuous.measurable (fun y => (smoothProbabilityProfile_range y).1), + realDensityMeasure_integral volume (affineProbabilityProfile c w) + (affineProbabilityProfile_contDiff c w).continuous.measurable (affineProbabilityProfile_nonneg c hw)] + exact (affineProbabilityProfile_integral_test c hw φ).symm + +theorem affineProductProfile_law {I : Type*} [Fintype I] + (c w : I → ℝ) (hw : ∀ i, 0 < w i) : + (realDensityMeasure volume (smoothProductProfile I)).map (fun y i => c i + w i * y i) = + realDensityMeasure volume (affineProductProfile c w) := by + have hψ : Integrable smoothProbabilityProfile := + smoothProbabilityProfile_contDiff.continuous.integrable_of_hasCompactSupport smoothProbabilityProfile_compact + let : IsFiniteMeasure (realDensityMeasure volume smoothProbabilityProfile) := + realDensityMeasure_finite _ _ hψ (fun y => (smoothProbabilityProfile_range y).1) + have hsrc := realDensityMeasure_pi (fun _ : I => (volume : Measure ℝ)) + (fun _ => smoothProbabilityProfile) (fun _ => hψ) (fun _ y => (smoothProbabilityProfile_range y).1) + have hdst := realDensityMeasure_pi (fun _ : I => (volume : Measure ℝ)) + (fun i => affineProbabilityProfile (c i) (w i)) + (fun i => affineProbabilityProfile_integrable (c i) (hw i)) + (fun i => affineProbabilityProfile_nonneg (c i) (hw i)) + change (Measure.pi (fun _ : I => realDensityMeasure volume smoothProbabilityProfile)) = + realDensityMeasure volume (smoothProductProfile I) at hsrc + change (Measure.pi (fun i : I => realDensityMeasure volume (affineProbabilityProfile (c i) (w i)))) = + realDensityMeasure volume (affineProductProfile c w) at hdst + rw [← hsrc, Measure.pi_map_pi (fun i => + (show Measurable (fun y : ℝ => c i + w i * y) by fun_prop).aemeasurable)] + simp_rw [affineProbabilityProfile_law _ (hw _)] + exact hdst + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +theorem affineProbabilityProfile_support (c : ℝ) {w : ℝ} (hw : 0 < w) {x : ℝ} + (hx : affineProbabilityProfile c w x ≠ 0) : |x - c| < 3 * w / 4 := by + by_contra! h + have hz : smoothProbabilityProfile ((x-c)/w) = 0 := by + apply smoothProbabilityProfile_zero + rw [abs_div, abs_of_pos hw] + apply (le_div_iff₀ hw).mpr + linarith + exact hx (by simp only [affineProbabilityProfile, hz, mul_zero]) + +theorem realDensityMeasure_ae_of_support {X : Type*} [MeasurableSpace X] + (μ : Measure X) (f : X → ℝ) (hf : Measurable f) (P : X → Prop) + (hP : ∀ x, f x ≠ 0 → P x) : ∀ᵐ x ∂realDensityMeasure μ f, P x := by + apply (ae_withDensity_iff hf.ennreal_ofReal).mpr + exact Filter.Eventually.of_forall (fun x hx => hP x (fun hz => hx (by simp [hz]))) + +noncomputable def affineCoefficientMeasure (c w : ℝ) : Measure ℝ := + realDensityMeasure volume (affineProbabilityProfile c w) + +theorem affineCoefficientMeasure_probability (c : ℝ) {w : ℝ} (hw : 0 < w) : + IsProbabilityMeasure (affineCoefficientMeasure c w) := + realDensityMeasure_probability volume _ (affineProbabilityProfile_integrable c hw) + (affineProbabilityProfile_nonneg c hw) (affineProbabilityProfile_integral c hw) + +theorem affineCoefficientMeasure_support (c : ℝ) {w : ℝ} (hw : 0 < w) : + ∀ᵐ x ∂affineCoefficientMeasure c w, |x - c| < 3 * w / 4 := + realDensityMeasure_ae_of_support volume _ (affineProbabilityProfile_contDiff c w).continuous.measurable + _ (fun _ hx => affineProbabilityProfile_support c hw hx) + +theorem affineCoefficientMeasure_law (c : ℝ) {w : ℝ} (hw : 0 < w) : + (realDensityMeasure volume smoothProbabilityProfile).map (fun y => c + w*y) = + affineCoefficientMeasure c w := + affineProbabilityProfile_law c hw + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped Matrix + +theorem affineProductProfile_integral_test {J : Type*} [Fintype J] + (c w : J → ℝ) (hw : ∀ j, 0 < w j) (φ : (J → ℝ) → ℝ) (hφ : Measurable φ) : + (∫ x, affineProductProfile c w x * φ x) = + ∫ r, smoothProductProfile J r * φ (fun j => c j + w j * r j) := by + have hmap : Measurable (fun r : J → ℝ => fun j => c j + w j * r j) := by fun_prop + rw [← realDensityMeasure_integral volume (affineProductProfile c w) + (affineProductProfile_contDiff c w).continuous.measurable (affineProductProfile_nonneg c w hw), + ← affineProductProfile_law c w hw, integral_map hmap.aemeasurable hφ.aestronglyMeasurable, + realDensityMeasure_integral volume (smoothProductProfile J) + (smoothProductProfile_contDiff J).continuous.measurable (fun r => (smoothProductProfile_range J r).1)] + +theorem affineProductProfile_retained_integral {Ω J : Type*} [MeasurableSpace Ω] [Fintype J] + (μ : Measure Ω) (c w : Ω → J → ℝ) (hw : ∀ ω j, 0 < w ω j) + (φ : Ω → (J → ℝ) → ℝ) (hφ : ∀ ω, Measurable (φ ω)) : + (∫ ω, (∫ x, affineProductProfile (c ω) (w ω) x * φ ω x) ∂μ) = + ∫ ω, (∫ r, smoothProductProfile J r * φ ω (fun j => c ω j + w ω j * r j)) ∂μ := by + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun ω => affineProductProfile_integral_test (c ω) (w ω) (hw ω) (φ ω) (hφ ω)) + +theorem affineCoefficientDensity_unit_source {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) + (S : J → ℝ) (P : I → ℝ) (hS : ∀ j, 0 < S j) (hP : ∀ i, 0 < P i) + (c w : J → ℝ) (hw : ∀ j, 0 < w j) : + (realDensityMeasure volume (smoothProductProfile J)).map + (fun r => normalizedIntegerColumns A S P *ᵥ (fun j => c j + w j * r j)) = + realDensityMeasure volume + (selectedCoefficientDensity A s hA S P hS hP (affineProductProfile c w)) := by + have hF : Measurable (fun x => normalizedIntegerColumns A S P *ᵥ x) := + (matrixSupCLM (normalizedIntegerColumns A S P)).continuous.measurable + have hmap : Measurable (fun r : J → ℝ => fun j => c j + w j * r j) := by fun_prop + change ((realDensityMeasure volume (smoothProductProfile J)).map + ((fun x => normalizedIntegerColumns A S P *ᵥ x) ∘ + (fun r j => c j + w j * r j))) = _ + rw [← Measure.map_map hF hmap, affineProductProfile_law c w hw] + exact selectedCoefficientDensity_law A s hA S P hS hP _ + (affineProductProfile_integrable c w hw) (affineProductProfile_nonneg c w hw) + +theorem affineProductProfile_measurable_comp {Ω J : Type*} [MeasurableSpace Ω] [Fintype J] + (c w x : Ω → J → ℝ) (hc : Measurable c) (hw : Measurable w) (hx : Measurable x) : + Measurable (fun ω => affineProductProfile (c ω) (w ω) (x ω)) := by + unfold affineProductProfile affineProbabilityProfile + apply Finset.measurable_prod + intro j _ + exact ((measurable_pi_apply j).comp hw).inv.mul + (smoothProbabilityProfile_contDiff.continuous.measurable.comp + ((((measurable_pi_apply j).comp hx).sub ((measurable_pi_apply j).comp hc)).div + ((measurable_pi_apply j).comp hw))) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientReindex.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fd852f2d41d3b96b4a357a8b894a0b4b74d2f4a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientReindex.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.Progressions.Probability.CoefficientJetDensityFactors + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +variable {I J O : Type*} [Fintype I] [Fintype J] + +theorem affineProductProfile_reindex (e : I ≃ J) (c w x : J → ℝ) : + affineProductProfile (c ∘ e) (w ∘ e) (x ∘ e) = affineProductProfile c w x := + Equiv.prod_comp e (fun j => affineProbabilityProfile (c j) (w j) (x j)) + +theorem affineCoefficientWeight_reindex (e : I ≃ J) (c w S : J → ℝ) (z : J → ℤ) : + coefficientWeight (affineProductProfile (c ∘ e) (w ∘ e)) (S ∘ e) (z ∘ e) = + coefficientWeight (affineProductProfile c w) S z := + affineProductProfile_reindex e c w (fun j => (z j : ℝ)/S j) + +theorem affineCoefficientWeightSum_reindex (e : I ≃ J) (c w S : J → ℝ) : + coefficientWeightSum (affineProductProfile (c ∘ e) (w ∘ e)) (S ∘ e) = + coefficientWeightSum (affineProductProfile c w) S := by + let E : (J → ℤ) ≃ (I → ℤ) := Equiv.arrowCongr e.symm (Equiv.refl ℤ) + calc + _ = ∑' z : J → ℤ, + coefficientWeight (affineProductProfile (c ∘ e) (w ∘ e)) (S ∘ e) (z ∘ e) := + (E.tsum_eq _).symm + _ = _ := tsum_congr (fun z => affineCoefficientWeight_reindex e c w S z) + +theorem coefficientPMF_affine_reindex (e : I ≃ J) (c w S : J → ℝ) + (hw : ∀ j, 0 < w j) (hS : ∀ j, 0 < S j) {R : ℝ} (hR : 0 ≤ R) + (hcw : ∀ j, |c j|+w j ≤ R) (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) : + (coefficientPMF (affineProductProfile (c ∘ e) (w ∘ e)) + (affineProductProfile_nonneg _ _ (fun i => hw (e i))) (S ∘ e) (fun i => hS (e i)) + (affineProductProfile_zero_outside _ _ (fun i => hw (e i)) hR (fun i => hcw (e i))) + (by rw [affineCoefficientWeightSum_reindex]; exact hZ)).map (fun z => z ∘ e.symm) = + coefficientPMF (affineProductProfile c w) (affineProductProfile_nonneg c w hw) S hS + (affineProductProfile_zero_outside c w hw hR hcw) hZ := by + let E : (I → ℤ) ≃ (J → ℤ) := Equiv.arrowCongr e (Equiv.refl ℤ) + change (coefficientPMF _ _ _ _ _ _).map E = _ + ext z + rw [pmf_map_equiv_apply] + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + change ((coefficientPMF _ _ _ _ _ _) (z ∘ e)).toReal = _ + rw [coefficientPMF_apply, coefficientPMF_apply, + affineCoefficientWeight_reindex, affineCoefficientWeightSum_reindex] + +theorem coefficientImagePMF_affine_reindex (A : Matrix O J ℤ) (e : I ≃ J) (c w S : J → ℝ) + (hw : ∀ j, 0 < w j) (hS : ∀ j, 0 < S j) {R : ℝ} (hR : 0 ≤ R) + (hcw : ∀ j, |c j|+w j ≤ R) (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) : + coefficientImagePMF (A.submatrix id e) (affineProductProfile (c ∘ e) (w ∘ e)) + (affineProductProfile_nonneg _ _ (fun i => hw (e i))) (S ∘ e) (fun i => hS (e i)) + (affineProductProfile_zero_outside _ _ (fun i => hw (e i)) hR (fun i => hcw (e i))) + (by rw [affineCoefficientWeightSum_reindex]; exact hZ) = + coefficientImagePMF A (affineProductProfile c w) (affineProductProfile_nonneg c w hw) S hS + (affineProductProfile_zero_outside c w hw hR hcw) hZ := by + unfold coefficientImagePMF + rw [← coefficientPMF_affine_reindex e c w S hw hS hR hcw hZ, PMF.map_comp] + congr 1 + funext z + exact Matrix.submatrix_mulVec_equiv A z id e + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientResidueWidths.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientResidueWidths.lean new file mode 100644 index 0000000000000000000000000000000000000000..99c4d4a85ffb2028e5748ec47e546adfb66b7635 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientResidueWidths.lean @@ -0,0 +1,553 @@ +import OAI.Combinatorics.Progressions.Dynamics.LayerRemovalBudgets +import OAI.Combinatorics.Progressions.Estimates.ModeShiftLengths +import OAI.Combinatorics.Progressions.Fourier.AffineFrequencyLift +import OAI.Combinatorics.Progressions.Fourier.LayeredFourierCharacter +import OAI.Combinatorics.Progressions.Polynomial.MonomialCoordinateRows + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +theorem integerContractedRow_monomial {K J : Type*} + (frequency : (K →₀ ℕ) → J → ℤ) (d : K →₀ ℕ) (j : J) : + integerContractedRow frequency (MvPolynomial.monomial d 1) j = frequency d j := by + simp [integerContractedRow] + +theorem exists_unit_integer_mode_rows {K J : Type*} [Fintype K] [Fintype J] + (W : Submodule ℝ (J → ℝ)) (frequency : (K →₀ ℕ) → J → ℤ) {h : ℕ} {C : ℝ} + (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C) + (hnonzero : ∃ p, Homogeneous h p ∧ + coefficientFunctional (fun d j => (frequency d j : ℝ)) (map W.subtype p) ≠ 0) : + ∃ rows : Fin h → K → ℤ, + (∀ i k, |(rows i k : ℝ)| ≤ 1) ∧ + (∀ j, |(integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤ C) ∧ + ∃ w : W, (∑ j, (integerContractedRow frequency + (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0 := by + obtain ⟨d, hd, w, hw⟩ := exists_restricted_coefficient_nonzero W frequency hnonzero + obtain ⟨rows, hrows, hprod⟩ := exists_monomial_coordinate_rows d hd + refine ⟨rows, hrows, ?_, ?_⟩ + · simpa only [hprod, integerContractedRow_monomial] using hbound d hd + · exact ⟨w, by simpa only [hprod, integerContractedRow_monomial] using hw⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +theorem layeredModeTestedPhase_empty_zero {I K : Type*} [Fintype K] {m : ℕ} + {W : Fin m → Type*} [∀ j, AddCommGroup (W j)] [∀ j, Module ℝ (W j)] + (L : ∀ j, VectorPolynomial K ℝ (W j) →ₗ[ℝ] ℝ) + (p : ∀ j, VectorPolynomial I ℝ (W j)) (b : K → I → ℝ) : + layeredModeTestedPhase L p 0 (Empty.elim : Empty → K → ℤ) Empty.elim b = + layeredCoefficientCharacter L p b := by + simp [layeredModeTestedPhase, layeredCoefficientCharacter] + +theorem exists_affine_coefficient_local_removal {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ} + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + {β : ℝ} (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ∃ i : Fin m, ∃ rows : Fin (i.val + 1) → Option K → ℤ, + (∀ a k, |(rows a k : ℝ)| ≤ 1) ∧ + ∀ base : Option K → I → ℝ, + ‖𝔼 x : Fin (i.val + 1) → ∀ j, Fin (N j), + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (rowShiftedTuple base rows + (fun (y : ∀ j, Fin (N j)) j => (stride j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ β := by + classical + let L := fun j => coefficientFunctional (fun d a => (frequency j d a : ℝ)) + let site : Empty → K → ℝ := Empty.elim + have hf (i : Fin m) := homogeneous_empty_factorization_iff + ((affineModeLift (L i)).comp (map (U i).subtype)) (i.val + 1) + (fun s (k : Option K) => k.elim 1 (site s)) + have hbad' : ∃ i, ¬∃ M : (Empty → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → affineModeLift (L i) (map (U i).subtype P) = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) P) := by + obtain ⟨i, P, hP, hn⟩ := hbad + exact ⟨i, fun h => hn ((hf i).mp h P hP)⟩ + obtain ⟨i, hi, hfactor⟩ := exists_highest_affine_subspace_nonfactor U site L hbad' + have hn := mt (hf i).mpr hi + simp only [not_forall, LinearMap.comp_apply] at hn + obtain ⟨P, hP, hnP⟩ := hn + obtain ⟨rows, hrows, hcontract, hnonzero⟩ := exists_unit_integer_mode_rows (U i) + (affineLiftFrequency (frequency i)) (affineLiftFrequency_bound _ (hbound i)) + (by exact ⟨P, hP, by simpa only [L, affineModeLift_integerFrequency] using hnP⟩) + have hsite : (fun (s : Empty) (k : Option K) => (((Empty.elim s : Option K → ℤ) k : ℤ) : ℝ)) = + (fun s (k : Option K) => k.elim 1 (site s)) := Subsingleton.elim _ _ + obtain ⟨Q', hQ', test', ht, he⟩ := exists_subspace_layered_mode_reduction i U + (fun j => affineModeLift (L j)) p hm hp (Empty.elim : Empty → Option K → ℤ) + (by rw [hsite]; exact hfactor) 0 (by simp) Empty.elim (fun s => s.elim) + have he' (b : Option K → I → ℝ) : + layeredCoefficientCharacter (fun j => affineModeLift (L j)) p b = + coefficientModeTestedPhase + (coefficientFunctional (fun d a => ((affineLiftFrequency (frequency i) d a : ℤ) : ℝ))) + (p i) Q' Empty.elim test' b := by + simpa only [layeredModeTestedPhase_empty_zero, L, affineModeLift_integerFrequency] using he b + refine ⟨i, rows, hrows, ?_⟩ + intro base + change ‖𝔼 x : Fin (i.val + 1) → ∀ j, Fin (N j), + layeredCoefficientCharacter (fun j => affineModeLift (L j)) p + (rowShiftedTuple base rows + (fun (y : ∀ j, Fin (N j)) j => (stride j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ β + simp_rw [he'] + exact inhomogeneous_coefficient_mode_local_removal (affineLiftFrequency (frequency i)) rows + (p i) (hp i) (U i) N stride hs hζ (hN i) H hH hA hscale (hrank i) + hcontract (hrowBudget i) hnonzero (hdenom i) (hcoeff i) + Empty.elim (fun s => s.elim) Q' hQ' test' ht hβ (hpower i) base + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal + +theorem affine_coefficient_mode_residue_removal_lipschitz_amplitude {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ} + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {r β : ℝ} (hr : 0 ≤ r) + (hmove : ∀ i : Fin m, ∀ z, + ((i.val + 1 : ℕ) : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) + (F : (Option K × I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) + {Lip : ℝ≥0} (hLip : LipschitzWith Lip F) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + (F (fun t => (residueLatticeArray residue stride z t : ℝ) / V t) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ)))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + (Lip : ℝ) * r + β := by + obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_coefficient_local_removal + U frequency hbound hbad p hp hm N stride hs hζ hN + H hH hA hscale hrank hrowBudget hdenom hcoeff hβ hpower + have hNp k : 0 < N k := by + exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k) + exact residue_smooth_row_shift_transfer_lipschitz_amplitude N stride hNp hs rows residue V hV hZ hV1 + hδ hδ1 hmesh hsmall zero_le_one hrows hr (by simpa only [mul_one] using hmove i) + _ (fun b => (layeredCoefficientCharacter_norm _ p b).le) hlocal F hF hLip + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +theorem affine_coefficient_mode_residue_removal {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ} + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {r β : ℝ} (hr : 0 ≤ r) + (hmove : ∀ i : Fin m, ∀ z, + ((i.val + 1 : ℕ) : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_coefficient_local_removal + U frequency hbound hbad p hp hm N stride hs hζ hN + H hH hA hscale hrank hrowBudget hdenom hcoeff hβ hpower + have hNp k : 0 < N k := by + exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k) + exact residue_smooth_row_shift_transfer N stride hNp hs rows residue V hV hZ hV1 + hδ hδ1 hmesh hsmall zero_le_one hrows hr (by simpa only [mul_one] using hmove i) + _ (fun b => (layeredCoefficientCharacter_norm _ p b).le) hlocal + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +theorem anchored_affine_coefficient_mode_residue_removal {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + (origin : Option K → I → ℝ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) {C : ℝ} + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, ((i.val + 1).factorial : ℝ) * C ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {r β : ℝ} (hr : 0 ≤ r) + (hmove : ∀ i : Fin m, ∀ z, + ((i.val + 1 : ℕ) : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (origin + fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_coefficient_local_removal + U frequency hbound hbad p hp hm N stride hs hζ hN + H hH hA hscale hrank hrowBudget hdenom hcoeff hβ hpower + have hNp k : 0 < N k := by + exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k) + exact anchored_residue_smooth_row_shift_transfer origin N stride hNp hs rows residue V hV hZ hV1 + hδ hδ1 hmesh hsmall zero_le_one hrows hr (by simpa only [mul_one] using hmove i) + _ (fun b => (layeredCoefficientCharacter_norm _ p b).le) hlocal + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +def affineCoefficientModeTrivial {K : Type*} {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : Prop := + ∀ j, ∀ P, Homogeneous (j.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))) + (map (U j).subtype P) = 0 + +theorem not_affineCoefficientModeTrivial_iff {K : Type*} {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : + ¬affineCoefficientModeTrivial U frequency ↔ + ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0 := by + simp only [affineCoefficientModeTrivial, not_forall, exists_prop] + +theorem affineModeLift_zero_of_homogeneous {K W : Type*} + [AddCommGroup W] [Module ℝ W] + (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) {h : ℕ} + (hz : ∀ P, Homogeneous h P → affineModeLift L P = 0) + (P : VectorPolynomial (Option K) ℝ W) (hP : DegreeLE (1 : Option K → ℕ) h P) : + affineModeLift L P = 0 := by + have hf := (affineModeLift_factorization_iff h (Empty.elim : Empty → K → ℝ) + L (0 : (Empty → W) →ₗ[ℝ] ℝ)).mp (by simpa only [LinearMap.zero_apply] using hz) + exact hf P hP + +theorem layeredCoefficientCharacter_eq_one_of_trivial {I K : Type*} [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hz : affineCoefficientModeTrivial U frequency) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (b : Option K → I → ℝ) : + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) p b = 1 := by + have hzero (j : Fin m) : + affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))) + (substitute (fun u => rowPolynomial (fun k => b k u)) (p j)) = 0 := by + let p' := restrictCoefficients (U j) (p j) (hm j) + have hp' := degreeLE_restrictCoefficients (U j) (p j) (hm j) (hp j) + have he := affineModeLift_zero_of_homogeneous + ((coefficientFunctional (fun d a => (frequency j d a : ℝ))).comp (map (U j).subtype)) + (by simpa only [affineModeLift_comp_map, LinearMap.comp_apply] using hz j) + (substitute (fun u => rowPolynomial (fun k => b k u)) p') + (degreeLE_substitute_affine _ (fun u => (rowPolynomial_homogeneous (fun k => b k u)).totalDegree_le) p' hp') + simpa only [affineModeLift_comp_map, LinearMap.comp_apply, map_substitute, + p', map_restrictCoefficients] using he + simp only [layeredCoefficientCharacter, hzero, Finset.sum_const_zero, + AddCircle.coe_zero, CircleFourier.character_zero] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal + +theorem affine_coefficient_residue_removal_of_widths_lipschitz_amplitude {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + {C : ℝ} (hC : 0 ≤ C) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (hH : ∀ k, 0 < H k) + (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : layerRemovalRankBudget m (Fintype.card I) C 1 + (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) + (hmove : (m : ℝ) * 1 ≤ r * ρ * T) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) + (F : (Option K × I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) + {Lip : ℝ≥0} (hLip : LipschitzWith Lip F) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + (F (fun t => (residueLatticeArray residue stride z t : ℝ) / V t) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ)))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + (Lip : ℝ) * r + β := by + classical + let B := finiteLayerBiasBudget m ζ + let D : ℝ := 1 + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ + have hD : 0 ≤ D := zero_le_one + have hA : 0 ≤ 2 * T := by positivity + have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B := + multiaffineBiasBudget_le_finite i hζ + obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth + have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD + (zero_le_one.trans hB) hA hS + apply affine_coefficient_mode_residue_removal_lipschitz_amplitude U frequency hbound hbad + p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank + (fun i => by simpa only [D, one_pow, mul_one] using (hbud i).1.trans hR) _ _ residue V hV hZ hV1 hδ hδ1 hmesh hsmall hr _ hβ hpower F hF hLip + · intro i + have hi := tensorDenominatorBound_le (H := Fin (i.val + 1)) + (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ)) + (fun k => Nat.cast_nonneg _) hstride + have hi' : (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ + (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by + simpa only [Fintype.card_fin] using hi + apply hi'.trans + apply le_trans _ ((hbud i).2.1.trans hR) + exact pow_le_pow_left₀ + (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _)) + (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _ + · intro i + apply le_trans _ ((hbud i).2.2.trans hR) + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _)) + (pow_nonneg (Nat.cast_nonneg _) _) + · intro i z + have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt + have hs' : (m : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z := by + simpa only [mul_one] using hshift z + exact (mul_le_mul_of_nonneg_right hi + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))).trans hs' + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal + +theorem affine_coefficient_residue_removal_of_widths {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + {C : ℝ} (hC : 0 ≤ C) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (hH : ∀ k, 0 < H k) + (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : layerRemovalRankBudget m (Fintype.card I) C 1 + (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) + (hmove : (m : ℝ) * 1 ≤ r * ρ * T) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + let B := finiteLayerBiasBudget m ζ + let D : ℝ := 1 + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ + have hD : 0 ≤ D := zero_le_one + have hA : 0 ≤ 2 * T := by positivity + have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B := + multiaffineBiasBudget_le_finite i hζ + obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth + have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD + (zero_le_one.trans hB) hA hS + apply affine_coefficient_mode_residue_removal U frequency hbound hbad + p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank + (fun i => by simpa only [D, one_pow, mul_one] using (hbud i).1.trans hR) _ _ residue V hV hZ hV1 hδ hδ1 hmesh hsmall hr _ hβ hpower + · intro i + have hi := tensorDenominatorBound_le (H := Fin (i.val + 1)) + (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ)) + (fun k => Nat.cast_nonneg _) hstride + have hi' : (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ + (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by + simpa only [Fintype.card_fin] using hi + apply hi'.trans + apply le_trans _ ((hbud i).2.1.trans hR) + exact pow_le_pow_left₀ + (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _)) + (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _ + · intro i + apply le_trans _ ((hbud i).2.2.trans hR) + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _)) + (pow_nonneg (Nat.cast_nonneg _) _) + · intro i z + have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt + have hs' : (m : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z := by + simpa only [mul_one] using hshift z + exact (mul_le_mul_of_nonneg_right hi + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))).trans hs' + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientSubspace.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientSubspace.lean new file mode 100644 index 0000000000000000000000000000000000000000..56c98b7d32130c9dc6cb89b72594faa78d06ed66 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoefficientSubspace.lean @@ -0,0 +1,584 @@ +import OAI.Combinatorics.Progressions.Estimates.BoundedAmbientModeWitness +import OAI.Combinatorics.Progressions.Estimates.OrderedLayerSplit +import OAI.Combinatorics.Progressions.Polynomial.PolynomialSiteAbsorption + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators TensorProduct Classical + +noncomputable def integerContractedRow {σ J : Type*} + (frequency : (σ →₀ ℕ) → J → ℤ) (P : MvPolynomial σ ℤ) : J → ℤ := + fun j => ∑ d ∈ P.support, P.coeff d * frequency d j + +theorem integerContractedRow_cast {σ J : Type*} + (Λ : VectorPolynomial σ ℝ (J → ℝ) →ₗ[ℝ] ℝ) + (frequency : (σ →₀ ℕ) → J → ℤ) {h : ℕ} + (hfrequency : ∀ d : σ →₀ ℕ, d.degree = h → ∀ j, + Λ (MvPolynomial.monomial d 1 ⊗ₜ[ℝ] Pi.single j 1) = (frequency d j : ℝ)) + {P : MvPolynomial σ ℤ} (hP : P.IsHomogeneous h) (j : J) : + (integerContractedRow frequency P j : ℝ) = contractedRow Λ (MvPolynomial.map (Int.castRingHom ℝ) P) j := by + change _ = ((TensorProduct.curry Λ).flip (Pi.single j 1)) (MvPolynomial.map (Int.castRingHom ℝ) P) + rw [polynomialFunctional_map_expansion] + simp only [integerContractedRow, Int.cast_sum, Int.cast_mul, Int.coe_castRingHom] + apply Finset.sum_congr rfl + intro d hd + have hdeg : d.degree = h := by + simpa only [Finsupp.degree_eq_weight_one, Pi.one_def] using hP (MvPolynomial.mem_support_iff.mp hd) + change _ = ((P.coeff d : ℤ) : ℝ) * Λ (MvPolynomial.monomial d 1 ⊗ₜ[ℝ] Pi.single j 1) + rw [hfrequency d hdeg j] + +theorem integerContractedRow_coefficientFunctional {σ J : Type*} [Fintype J] + (frequency : (σ →₀ ℕ) → J → ℤ) {P : MvPolynomial σ ℤ} {h : ℕ} + (hP : P.IsHomogeneous h) (j : J) : + (integerContractedRow frequency P j : ℝ) = contractedRow + (coefficientFunctional (fun d j => (frequency d j : ℝ))) + (MvPolynomial.map (Int.castRingHom ℝ) P) j := + integerContractedRow_cast _ frequency (fun d _ j => coefficientFunctional_unit _ d j) hP j + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Classical + +theorem integer_cube_root_bound {K : Type*} {q : ℕ} + (root : K → ℤ) (difference : Fin q → K → ℤ) {L : ℝ} + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) : + ∀ k, |(root k : ℝ)| ≤ L := by + intro k + simpa only [affineSite, Finset.sum_empty, add_zero] using hsite ∅ k + +theorem integer_cube_difference_bound {K : Type*} {q : ℕ} + (root : K → ℤ) (difference : Fin q → K → ℤ) {L : ℝ} + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) : + ∀ i k, |(difference i k : ℝ)| ≤ 2 * L := by + intro i k + have he : (difference i k : ℝ) = + ((affineSite root difference {i} (some k) : ℤ) : ℝ) - (root k : ℝ) := by + simp [affineSite] + rw [he] + have ht := hsite {i} k + have hr := integer_cube_root_bound root difference hsite k + exact (abs_sub _ _).trans (by linarith) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +theorem integerCubeWitnessBound_le_polynomial (q : ℕ) {H D : ℝ} + (hH : 0 ≤ H) (hD : 0 ≤ D) : + integerCubeWitnessBound q H D ≤ + (q.factorial : ℝ) * (2 + (q : ℝ) * (q + 1)) * (1 + H + D) ^ (q + 2) := by + let M := 1 + H + D + have hM : 1 ≤ M := by dsimp [M]; linarith + have hDq : D ^ q ≤ M ^ q := pow_le_pow_left₀ hD (by dsimp [M]; linarith) q + have hDm : D ^ (q - 1) ≤ M ^ q := + (pow_le_pow_left₀ hD (by dsimp [M]; linarith) (q - 1)).trans + (pow_le_pow_right₀ hM (Nat.sub_le _ _)) + have hHM : 1 + H ≤ M := by dsimp [M]; linarith + have hA : (q.factorial : ℝ) * D ^ q ≤ (q.factorial : ℝ) * M ^ q := + mul_le_mul_of_nonneg_left hDq (Nat.cast_nonneg _) + have hB : (q : ℝ) * ((q.factorial : ℝ) * D ^ (q - 1) * (1 + H)) ≤ + (q : ℝ) * (q.factorial : ℝ) * M ^ (q + 1) := by + calc + _ ≤ (q : ℝ) * ((q.factorial : ℝ) * M ^ q * M) := by gcongr + _ = _ := by rw [pow_succ]; ring + have hfactor : (q : ℝ) * D + 1 ≤ ((q : ℝ) + 1) * M := by + have hd : D ≤ M := by dsimp [M]; linarith + nlinarith [show (0 : ℝ) ≤ (q : ℝ) from Nat.cast_nonneg q] + have hbase : 2 + H ≤ 2 * M := by dsimp [M]; linarith + have hpow : M ^ (q + 1) ≤ M ^ (q + 2) := pow_le_pow_right₀ hM (by omega) + unfold integerCubeWitnessBound integerFormMassBound + calc + _ ≤ (q.factorial : ℝ) * M ^ q * (2 * M) + + (((q : ℝ) + 1) * M) * ((q : ℝ) * (q.factorial : ℝ) * M ^ (q + 1)) := by + exact add_le_add (mul_le_mul hA hbase (by positivity) (by positivity)) + (mul_le_mul hfactor hB (by positivity) (by positivity)) + _ = 2 * (q.factorial : ℝ) * M ^ (q + 1) + + ((q : ℝ) * (q + 1) * (q.factorial : ℝ)) * M ^ (q + 2) := by + simp only [pow_succ] + ring + _ ≤ 2 * (q.factorial : ℝ) * M ^ (q + 2) + + ((q : ℝ) * (q + 1) * (q.factorial : ℝ)) * M ^ (q + 2) := by gcongr + _ = _ := by dsimp [M]; ring + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators TensorProduct Classical + +theorem exists_bounded_integer_mode_witness {K J : Type*} [Fintype K] [Fintype J] {q : ℕ} + (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {H D C : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hC : 0 ≤ C) + (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D) + (frequency : ((Option K) →₀ ℕ) → J → ℤ) (h : ℕ) + (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C) + (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ, + ∀ p, VectorPolynomial.Homogeneous h p → + VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ)) + (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) : + ∃ P : Fin h → MvPolynomial (Option K) ℤ, + (∀ i, (P i).IsHomogeneous 1 ∧ + realPolynomialMass (map (Int.castRingHom ℝ) (P i)) ≤ integerCubeWitnessBound q H D) ∧ + (∀ s : Finset (Fin q), ∃ i, eval (affineSite root difference s) (P i) = 0) ∧ + (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, P i) j : ℝ)| ≤ + C * integerCubeWitnessBound q H D ^ h) ∧ + ∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency (∏ i, P i) j : ℝ) * w.val j) ≠ 0 := by + obtain ⟨P, hP, hz, hb, w, hw⟩ := exists_bounded_ambient_mode_witness W root difference hlin + hH hD hC hroot hdiff (VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ))) + h (VectorPolynomial.coefficientFunctional_rowBound _ hbound) hnonfactor + have hp : (∏ i, P i).IsHomogeneous h := by + simpa using IsHomogeneous.prod Finset.univ P (fun _ => 1) (fun i _ => (hP i).1) + have hcast (j : J) := VectorPolynomial.integerContractedRow_coefficientFunctional frequency hp j + refine ⟨P, hP, hz, ?_, w, ?_⟩ + · intro j + rw [hcast j] + exact hb j + · simp_rw [hcast] + exact hw + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators TensorProduct Classical + +theorem rowPolynomial_homogeneous {σ R : Type*} [Fintype σ] [CommRing R] (a : σ → R) : + (rowPolynomial a).IsHomogeneous 1 := + IsHomogeneous.sum Finset.univ _ 1 (fun i _ => isHomogeneous_C_mul_X (a i) i) + +theorem VectorPolynomial.integerContractedRow_apply {σ J : Type*} [Fintype J] + (frequency : (σ →₀ ℕ) → J → ℤ) {P : MvPolynomial σ ℤ} {h : ℕ} + (hP : P.IsHomogeneous h) (w : J → ℝ) : + (∑ j, (integerContractedRow frequency P j : ℝ) * w j) = + coefficientFunctional (fun d j => (frequency d j : ℝ)) + ((MvPolynomial.map (Int.castRingHom ℝ) P) ⊗ₜ[ℝ] w) := by + simp_rw [integerContractedRow_coefficientFunctional frequency hP] + exact contractedRow_apply _ _ w + +namespace BooleanCubeKernel + +theorem exists_bounded_integer_mode_rows {K J : Type*} [Fintype K] [Fintype J] {q : ℕ} + (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {H D C : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hC : 0 ≤ C) + (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D) + (frequency : ((Option K) →₀ ℕ) → J → ℤ) (h : ℕ) + (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C) + (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ, + ∀ p, VectorPolynomial.Homogeneous h p → + VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ)) + (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) : + ∃ rows : Fin h → Option K → ℤ, + (∀ i k, |(rows i k : ℝ)| ≤ integerCubeWitnessBound q H D) ∧ + (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧ + (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤ + C * integerCubeWitnessBound q H D ^ h) ∧ + ∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency + (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0 := by + obtain ⟨P, hP, hz, hb, hw⟩ := exists_bounded_integer_mode_witness W root difference hlin + hH hD hC hroot hdiff frequency h hbound hnonfactor + let rows := fun i => polynomialLinearRow (P i) + have hp (i : Fin h) : rowPolynomial (rows i) = P i := + (homogeneous_eq_rowPolynomial _ (hP i).1).symm + have hprod : (∏ i, rowPolynomial (rows i)) = ∏ i, P i := by simp_rw [hp] + refine ⟨rows, ?_, ?_, ?_, ?_⟩ + · intro i k + exact (integer_coefficient_le_mass (P i) (Finsupp.single k 1)).trans (hP i).2 + · intro s + obtain ⟨i, hi⟩ := hz s + refine ⟨i, ?_⟩ + change (∑ k, polynomialLinearRow (P i) k * affineSite root difference s k) = 0 + rw [← homogeneous_eval_eq_row _ (hP i).1] + exact hi + · rw [hprod] + exact hb + · rw [hprod] + exact hw + +end BooleanCubeKernel +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +noncomputable def affineParameterSubstitution {I K : Type*} [Fintype K] + (b : Option K → I → ℝ) (j : I) : MvPolynomial K ℝ := + MvPolynomial.C (b none j) + rowPolynomial (fun k => b (some k) j) + +theorem dehomogenize_rowPolynomial {K : Type*} [Fintype K] (a : Option K → ℝ) : + MvPolynomial.aeval dehomogenizingSubstitution (rowPolynomial a) = + MvPolynomial.C (a none) + rowPolynomial (fun k => a (some k)) := by + simp [rowPolynomial, dehomogenizingSubstitution, Fintype.sum_option] + +theorem affineParameterSubstitution_degree {I K : Type*} [Fintype K] + (b : Option K → I → ℝ) (j : I) : (affineParameterSubstitution b j).totalDegree ≤ 1 := by + apply (MvPolynomial.totalDegree_add _ _).trans + exact max_le (by simp) (rowPolynomial_homogeneous (fun k => b (some k) j)).totalDegree_le + +theorem affineParameterSubstitution_eval {I K : Type*} [Fintype K] + (b : Option K → I → ℝ) (t : K → ℝ) (j : I) : + MvPolynomial.aeval t (affineParameterSubstitution b j) = + b none j + ∑ k, b (some k) j * t k := by + change MvPolynomial.eval t (affineParameterSubstitution b j) = _ + rw [affineParameterSubstitution, map_add, MvPolynomial.eval_C, rowPolynomial_eval] + +noncomputable def affineModeLift {K W : Type*} [AddCommGroup W] [Module ℝ W] + (Λ : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) : VectorPolynomial (Option K) ℝ W →ₗ[ℝ] ℝ := + Λ.comp (substitute dehomogenizingSubstitution) + +theorem affineModeLift_substitute {I K W : Type*} [Fintype K] + [AddCommGroup W] [Module ℝ W] + (Λ : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) (p : VectorPolynomial I ℝ W) + (b : Option K → I → ℝ) : + affineModeLift Λ (substitute (fun j => rowPolynomial (fun k => b k j)) p) = + Λ (substitute (affineParameterSubstitution b) p) := by + rw [affineModeLift, LinearMap.comp_apply, substitute_comp] + simp only [dehomogenize_rowPolynomial] + rfl + +theorem coefficientModePolynomial_affine_eval {I K W : Type*} [Fintype K] + [AddCommGroup W] [Module ℝ W] + (Λ : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) (p : VectorPolynomial I ℝ W) + (b : Option K → I → ℝ) : + MvPolynomial.eval (fun z => b z.1 z.2) (coefficientModePolynomial (affineModeLift Λ) p) = + Λ (substitute (affineParameterSubstitution b) p) := by + rw [coefficientModePolynomial_eval, affineModeLift_substitute] + +theorem coefficientModePolynomial_degreeLE {I K W : Type*} [Fintype K] + [AddCommGroup W] [Module ℝ W] + (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) (p : VectorPolynomial I ℝ W) + {h : ℕ} (hp : DegreeLE (1 : I → ℕ) h p) : + (coefficientModePolynomial L p).totalDegree ≤ h := by + unfold coefficientModePolynomial + apply MvPolynomial.totalDegree_finsetSum_le + intro d hd + apply (mapPolynomialCoefficients_degree _ _).trans + apply parameterPolynomialPullback_degree + have hb : d.sum (fun _ n => n) ≤ h := by + simpa only [Finsupp.weight_apply, Pi.one_def, smul_eq_mul, mul_one] using + (degreeLE_iff (1 : I → ℕ) h p).mp hp d hd + exact (MvPolynomial.totalDegree_monomial_le d 1).trans hb + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open CircleFourier +open scoped BigOperators + +theorem rowPolynomial_integer_site {I K : Type*} [Fintype K] + (site : K → ℤ) (b : K → I → ℝ) : + (fun i => MvPolynomial.aeval (fun k => (site k : ℝ)) (rowPolynomial (fun k => b k i))) = + integerSiteValue site b := by + funext i + change MvPolynomial.eval (fun k => (site k : ℝ)) (rowPolynomial (fun k => b k i)) = _ + rw [rowPolynomial_eval] + change (∑ k, b k i * (site k : ℝ)) = (∑ k, site k • b k) i + rw [Finset.sum_apply] + apply Finset.sum_congr rfl + intro k _ + change b k i * (site k : ℝ) = site k • b k i + rw [zsmul_eq_mul, mul_comm] + +theorem exists_absorbed_integer_site_tests {A I K S : Type*} {W : A → Type*} + [Fintype A] [Fintype K] [Fintype S] [DecidableEq S] + [∀ a, AddCommGroup (W a)] [∀ a, Module ℝ (W a)] + (h : A → ℕ) (site : S → K → ℤ) + (L : ∀ a, VectorPolynomial K ℝ (W a) →ₗ[ℝ] ℝ) + (hfactor : ∀ a, ∃ M : (S → W a) →ₗ[ℝ] ℝ, + ∀ q, DegreeLE (1 : K → ℕ) (h a) q → + L a q = M (siteEvaluation (fun s k => (site s k : ℝ)) q)) + (p : ∀ a, VectorPolynomial I ℝ (W a)) (hp : ∀ a, DegreeLE (1 : I → ℕ) (h a) (p a)) + (low : (K → I → ℝ) → ℝ) + (test : S → (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) : + ∃ test' : S → (I → ℝ) → ℂ, (∀ s x, ‖test' s x‖ ≤ 1) ∧ ∀ b, + character ((low b + ∑ a, L a (substitute (fun i => rowPolynomial (fun k => b k i)) (p a)) : ℝ) : + CircleFourier.Circle) * (∏ s, test s (integerSiteValue (site s) b)) = + character (low b : CircleFourier.Circle) * (∏ s, test' s (integerSiteValue (site s) b)) := by + have hf (a : A) : ∃ M : (S → W a) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (h a) q → L a (substitute dehomogenizingSubstitution q) = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) q) := by + obtain ⟨M, hM⟩ := hfactor a + exact ⟨M, (homogeneous_site_factorization_iff (h a) + (fun s k => (site s k : ℝ)) (L a) M).mpr hM⟩ + obtain ⟨test', ht, he⟩ := exists_absorbed_polynomial_site_tests h + (fun s k => (site s k : ℝ)) L hf p hp + (fun (b : K → I → ℝ) i => rowPolynomial (fun k => b k i)) + (fun b i => (rowPolynomial_homogeneous (fun k => b k i)).totalDegree_le) low test htest + refine ⟨test', ht, ?_⟩ + intro b + simpa only [rowPolynomial_integer_site] using he b + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators TensorProduct Classical + +def cubeModePolynomialBudget (q : ℕ) (L : ℝ) : ℝ := + (q.factorial : ℝ) * (2 + (q : ℝ) * (q + 1)) * (1 + 3 * L) ^ (q + 2) + +theorem integerCubeWitnessBound_le_vertex_budget (q : ℕ) {L : ℝ} (hL : 0 ≤ L) : + integerCubeWitnessBound q L (2 * L) ≤ cubeModePolynomialBudget q L := by + have he : 1 + L + 2 * L = 1 + 3 * L := by ring + simpa only [cubeModePolynomialBudget, he] using + integerCubeWitnessBound_le_polynomial q hL (show 0 ≤ 2 * L by positivity) + +theorem exists_vertex_bounded_integer_mode {K J : Type*} [Fintype K] [Fintype J] {q : ℕ} + (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ((Option K) →₀ ℕ) → J → ℤ) (h : ℕ) + (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C) + (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ, + ∀ p, VectorPolynomial.Homogeneous h p → + VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ)) + (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) : + ∃ rows : Fin h → Option K → ℤ, + (∀ i k, |(rows i k : ℝ)| ≤ cubeModePolynomialBudget q L) ∧ + (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧ + (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤ + C * cubeModePolynomialBudget q L ^ h) ∧ + ∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency + (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0 := by + obtain ⟨rows, hr, hz, hb, hw⟩ := exists_bounded_integer_mode_rows W root difference hlin + hL (show 0 ≤ 2 * L by positivity) hC + (integer_cube_root_bound root difference hsite) + (integer_cube_difference_bound root difference hsite) frequency h hbound hnonfactor + have hbudget := integerCubeWitnessBound_le_vertex_budget q hL + refine ⟨rows, (fun i k => (hr i k).trans hbudget), hz, ?_, hw⟩ + intro j + exact (hb j).trans (mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (integerCubeWitnessBound_nonneg q hL (by positivity)) hbudget h) hC) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem degreeLE_dehomogenize {K W : Type*} [AddCommGroup W] [Module ℝ W] + {h : ℕ} {p : VectorPolynomial (Option K) ℝ W} + (hp : DegreeLE (1 : Option K → ℕ) h p) : + DegreeLE (1 : K → ℕ) h (substitute dehomogenizingSubstitution p) := by + apply degreeLE_substitute_affine _ _ p hp + intro k + cases k <;> simp [dehomogenizingSubstitution] + +theorem affineModeLift_factorization_iff {K S W : Type*} [AddCommGroup W] [Module ℝ W] + (h : ℕ) (site : S → K → ℝ) (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) + (M : (S → W) →ₗ[ℝ] ℝ) : + (∀ q, Homogeneous h q → affineModeLift L q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ↔ + (∀ q, DegreeLE (1 : Option K → ℕ) h q → affineModeLift L q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) := by + constructor + · intro hf q hq + have ho := (homogeneous_site_factorization_iff h site L M).mp hf + change L (substitute dehomogenizingSubstitution q) = _ + rw [← siteEvaluation_dehomogenize] + exact ho _ (degreeLE_dehomogenize hq) + · intro hf q hq + exact hf q (homogeneous_degreeLE hq) + +theorem affineModeLift_exists_factorization_iff {K S W : Type*} + [AddCommGroup W] [Module ℝ W] + (h : ℕ) (site : S → K → ℝ) (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) : + (∃ M : (S → W) →ₗ[ℝ] ℝ, ∀ q, Homogeneous h q → affineModeLift L q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ↔ + (∃ M : (S → W) →ₗ[ℝ] ℝ, ∀ q, DegreeLE (1 : Option K → ℕ) h q → affineModeLift L q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) := + exists_congr (fun M => affineModeLift_factorization_iff h site L M) + +theorem exists_highest_affine_nonfactor {K S : Type*} {m : ℕ} {W : Fin m → Type*} + [∀ j, AddCommGroup (W j)] [∀ j, Module ℝ (W j)] + (site : S → K → ℝ) (L : ∀ j, VectorPolynomial K ℝ (W j) →ₗ[ℝ] ℝ) + (hbad : ∃ i, ¬∃ M : (S → W i) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) : + ∃ i, (¬∃ M : (S → W i) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ∧ + ∀ j, i < j → ∃ M : (S → W j) →ₗ[ℝ] ℝ, + ∀ q, DegreeLE (1 : Option K → ℕ) (j.val + 1) q → affineModeLift (L j) q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q) := by + obtain ⟨i, hi, hh⟩ := exists_highest_exceptional_layer _ hbad + refine ⟨i, hi, ?_⟩ + intro j hj + exact (affineModeLift_exists_factorization_iff (j.val + 1) site (L j)).mp (hh j hj) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open CircleFourier +open scoped BigOperators + +theorem exists_absorbed_affine_site_tests {A I K S : Type*} {W : A → Type*} + [Fintype A] [Fintype K] [Fintype S] [DecidableEq S] + [∀ a, AddCommGroup (W a)] [∀ a, Module ℝ (W a)] + (h : A → ℕ) (site : S → K → ℝ) + (Λ : ∀ a, VectorPolynomial K ℝ (W a) →ₗ[ℝ] ℝ) + (hfactor : ∀ a, ∃ M : (S → W a) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (h a) q → affineModeLift (Λ a) q = + M (siteEvaluation (fun s (i : Option K) => i.elim 1 (site s)) q)) + (p : ∀ a, VectorPolynomial I ℝ (W a)) (hp : ∀ a, DegreeLE (1 : I → ℕ) (h a) (p a)) + (low : (Option K → I → ℝ) → ℝ) + (test : S → (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) : + ∃ test' : S → (I → ℝ) → ℂ, (∀ s x, ‖test' s x‖ ≤ 1) ∧ ∀ b, + character ((low b + ∑ a, MvPolynomial.eval (fun z => b z.1 z.2) + (coefficientModePolynomial (affineModeLift (Λ a)) (p a)) : ℝ) : CircleFourier.Circle) * + (∏ s, test s (fun i => b none i + ∑ k, b (some k) i * site s k)) = + character (low b : CircleFourier.Circle) * + (∏ s, test' s (fun i => b none i + ∑ k, b (some k) i * site s k)) := by + obtain ⟨test', htest', he⟩ := exists_absorbed_polynomial_site_tests h site Λ hfactor p hp + affineParameterSubstitution affineParameterSubstitution_degree low test htest + refine ⟨test', htest', ?_⟩ + intro b + simpa only [coefficientModePolynomial_affine_eval, affineParameterSubstitution_eval] using he b + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open CircleFourier MvPolynomial +open scoped BigOperators Classical + +def FiniteSitePhaseRemoval {h : ℕ} {S K X V : Type*} + [Fintype S] [Fintype K] [Fintype X] [AddCommGroup V] + (site : S → K → ℤ) (rows : Fin h → K → ℤ) : Prop := + ∀ (base : K → V) (shift : X → V) (phase : (K → V) → ℝ) (test : S → V → ℂ), + (∀ s v, ‖test s v‖ ≤ 1) → + ‖𝔼 x, character (phase (rowShiftedTuple base rows shift x) : CircleFourier.Circle) * + ∏ s, test s (integerSiteValue (site s) (rowShiftedTuple base rows shift x))‖ ^ (2 ^ h) ≤ + ‖𝔼 u, 𝔼 v, character ((additiveBoxDifference h + (fun x (_ : Unit) => phase (rowShiftedTuple base rows shift x)) u v () : ℝ) : CircleFourier.Circle)‖ + +theorem finiteSitePhaseRemoval_of_annihilates {h : ℕ} {S K X V : Type*} + [Fintype S] [Fintype K] [Fintype X] [Nonempty X] [AddCommGroup V] + (hh : 0 < h) (site : S → K → ℤ) (rows : Fin h → K → ℤ) + (hzero : ∀ s, ∃ i, (∑ k, rows i k * site s k) = 0) : + FiniteSitePhaseRemoval (X := X) (V := V) site rows := by + intro base shift phase test htest + exact row_shifted_site_phase_cauchySchwarz hh site base rows shift hzero phase test htest + +namespace BooleanCubeKernel + +theorem exists_vertex_mode_with_phase_removal {K J X V : Type*} + [Fintype K] [Fintype J] [Fintype X] [Nonempty X] [AddCommGroup V] {q h : ℕ} + (hh : 0 < h) (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ((Option K) →₀ ℕ) → J → ℤ) + (hbound : ∀ d, d.degree = h → ∀ j, |(frequency d j : ℝ)| ≤ C) + (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ, + ∀ p, VectorPolynomial.Homogeneous h p → + VectorPolynomial.coefficientFunctional (fun d j => (frequency d j : ℝ)) + (VectorPolynomial.map W.subtype p) = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) : + ∃ rows : Fin h → Option K → ℤ, + (∀ i k, |(rows i k : ℝ)| ≤ cubeModePolynomialBudget q L) ∧ + (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧ + (∀ j, |(VectorPolynomial.integerContractedRow frequency (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤ + C * cubeModePolynomialBudget q L ^ h) ∧ + (∃ w : W, (∑ j, (VectorPolynomial.integerContractedRow frequency + (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0) ∧ + FiniteSitePhaseRemoval (X := X) (V := V) (fun s => affineSite root difference s) rows := by + obtain ⟨rows, hr, hz, hb, hw⟩ := exists_vertex_bounded_integer_mode W root difference hlin + hL hC hsite frequency h hbound hnonfactor + exact ⟨rows, hr, hz, hb, hw, finiteSitePhaseRemoval_of_annihilates hh _ rows hz⟩ + +end BooleanCubeKernel +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem affineModeLift_comp_map {K V W : Type*} + [AddCommGroup V] [Module ℝ V] [AddCommGroup W] [Module ℝ W] + (f : V →ₗ[ℝ] W) (L : VectorPolynomial K ℝ W →ₗ[ℝ] ℝ) : + affineModeLift (L.comp (map f)) = (affineModeLift L).comp (map f) := by + apply LinearMap.ext + intro q + simp only [affineModeLift, LinearMap.comp_apply, map_substitute] + +theorem exists_highest_affine_subspace_nonfactor {K S : Type*} {m : ℕ} + {V : Fin m → Type*} [∀ j, AddCommGroup (V j)] [∀ j, Module ℝ (V j)] + (U : ∀ j, Submodule ℝ (V j)) (site : S → K → ℝ) + (L : ∀ j, VectorPolynomial K ℝ (V j) →ₗ[ℝ] ℝ) + (hbad : ∃ i, ¬∃ M : (S → U i) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) (map (U i).subtype q) = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) : + ∃ i, (¬∃ M : (S → U i) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) (map (U i).subtype q) = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q)) ∧ + ∀ j, i < j → ∃ M : (S → U j) →ₗ[ℝ] ℝ, + ∀ q, DegreeLE (1 : Option K → ℕ) (j.val + 1) q → + affineModeLift (L j) (map (U j).subtype q) = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (site s)) q) := by + have hh := exists_highest_affine_nonfactor site (fun j => (L j).comp (map (U j).subtype)) + (by simpa only [affineModeLift_comp_map, LinearMap.comp_apply] using hbad) + simpa only [affineModeLift_comp_map, LinearMap.comp_apply] using hh + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCommonReferenceBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCommonReferenceBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5018ccc39137c7203539215ebebbfcc207295af --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCommonReferenceBudget.lean @@ -0,0 +1,120 @@ +import OAI.Combinatorics.Progressions.Polynomial.AffineSidePolynomialBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem affineAdaptiveDegreeBudget_le_power {P : ℝ} (hP : 0 ≤ P) : + affineAdaptiveDegreeBudget P ≤ 1024 * (P + 3) ^ 3 := by + apply le_of_sub_nonneg + simp only [affineAdaptiveDegreeBudget, affineLocalDegreeBudget, affineOuterDegreeInputBudget, + affineLocalDegreeInputBudget, affineShellLogBudget, affineCountLogBudget, affinePrimitiveLogBudget] + ring_nf + positivity + +theorem affineSidePolynomialBudget_le_power {P : ℝ} (hP : 0 ≤ P) : + affineSidePolynomialBudget P ≤ 65536 * (P + 3) ^ 4 := by + apply le_of_sub_nonneg + simp only [affineSidePolynomialBudget, affineOrderPolynomialBudget, affineAccuracyPolynomialBudget, + affineAdaptiveDegreeBudget, affineLocalDegreeBudget, affineOuterDegreeInputBudget, + affineLocalDegreeInputBudget, affineShellLogBudget, affineCountLogBudget, affinePrimitiveLogBudget] + ring_nf + positivity + +theorem adaptiveAffineCutoff_le_power (A sourceDim siteDim : ℕ) + {epsilon L T C totalShell modLog P : ℝ} + (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog) + (hLP : L ≤ P) (hTP : T ≤ P) (hCP : C ≤ P) (hmod : modLog ≤ P) + (hA : (A : ℝ) ≤ P) (hsource : (sourceDim : ℝ) ≤ P) (hsite : (siteDim : ℝ) ≤ P) + (hinverse : epsilon⁻¹ ≤ Real.exp P) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp P) : + (adaptiveAffineCutoff A sourceDim siteDim epsilon L T C totalShell modLog : ℝ) ≤ + 1024 * (P + 3) ^ 3 := + (adaptiveAffineCutoff_le_polynomialBudget A sourceDim siteDim hepsilon hepsilon1 hP hL hT hC hmod0 + hLP hTP hCP hmod hA hsource hsite hinverse htotal htotalInv).trans (affineAdaptiveDegreeBudget_le_power hP) + +theorem adaptiveAffineSideLog_le_power (A sourceDim siteDim : ℕ) + {epsilon L T C totalShell modLog dimLog P : ℝ} + (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog) + (hLP : L ≤ P) (hTP : T ≤ P) (hCP : C ≤ P) (hmod : modLog ≤ P) (hdim : dimLog ≤ P) + (hA : (A : ℝ) ≤ P) (hsource : (sourceDim : ℝ) ≤ P) (hsite : (siteDim : ℝ) ≤ P) + (hinverse : epsilon⁻¹ ≤ Real.exp P) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp P) : + adaptiveAffineSideLog A sourceDim siteDim epsilon L T C totalShell modLog dimLog ≤ + 65536 * (P + 3) ^ 4 := + (adaptiveAffineSideLog_le_polynomialBudget A sourceDim siteDim hepsilon hepsilon1 hP hL hT hC hmod0 + hLP hTP hCP hmod hdim hA hsource hsite hinverse htotal htotalInv).trans (affineSidePolynomialBudget_le_power hP) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def affineCommonReferenceBudget (E : ℕ) (epsilon U : ℝ) : ℝ := + 2 * (affineReferenceInput epsilon U + 2) ^ E + +theorem affineCommonReferenceBudget_bounds {E : ℕ} (hE : 2 ≤ E) (epsilon : ℝ) {U : ℝ} (hU : 0 ≤ U) : + 0 ≤ affineCommonReferenceBudget E epsilon U ∧ + U ≤ affineCommonReferenceBudget E epsilon U ∧ + (⌈(affineReferenceInput epsilon U + 2) ^ E⌉₊ : ℝ) ≤ affineCommonReferenceBudget E epsilon U := by + have hb := affineReferenceInput_bounds epsilon hU + have hbase : 0 ≤ affineReferenceInput epsilon U + 2 := by linarith [hb.1] + have hpow : affineReferenceInput epsilon U + 2 ≤ (affineReferenceInput epsilon U + 2) ^ E := by + simpa only [pow_one] using pow_le_pow_right₀ (by linarith : 1 ≤ affineReferenceInput epsilon U + 2) + (show 1 ≤ E by omega) + have hc := Nat.ceil_lt_add_one (by positivity : 0 ≤ (affineReferenceInput epsilon U + 2) ^ E) + unfold affineCommonReferenceBudget + exact ⟨by positivity, by linarith [hb.2.1], by linarith [hb.1]⟩ + +theorem adaptiveAffineCutoff_reference_bounds {E sourceDim siteDim : ℕ} + {epsilon L T C totalShell modLog U : ℝ} + (hE : 2 ≤ E) (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hU : 0 ≤ U) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog) + (hLU : L ≤ U) (hTU : T ≤ U) (hCU : C ≤ U) (hmod : modLog ≤ U) + (hsource : (sourceDim : ℝ) ≤ U) (hsite : (siteDim : ℝ) ≤ U) + (hinverse : epsilon⁻¹ ≤ Real.exp U) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp U) : + let A := ⌈(affineReferenceInput epsilon U + 2) ^ E⌉₊ + let b := adaptiveAffineCutoff A sourceDim siteDim epsilon L T C totalShell modLog + 2 * U ≤ (b : ℝ) ∧ (b : ℝ) ≤ 1024 * (affineCommonReferenceBudget E epsilon U + 3) ^ 3 := by + intro A b + have hp := affineReferenceInput_bounds epsilon hU + have hc := affineCommonReferenceBudget_bounds hE epsilon hU + have he : Real.exp U ≤ Real.exp (affineCommonReferenceBudget E epsilon U) := Real.exp_le_exp.mpr hc.2.1 + constructor + · have hA : A ≤ b := by + have h := (adaptiveAffineCutoff_bounds A sourceDim siteDim epsilon L T C totalShell modLog).1 + dsimp only [b] + omega + have hAr : (A : ℝ) ≤ b := by exact_mod_cast hA + have hbase := ceil_power_dominates_twice hp.1 hE + change 2 * affineReferenceInput epsilon U ≤ (A : ℝ) at hbase + linarith [hp.2.1] + · exact adaptiveAffineCutoff_le_power A sourceDim siteDim hepsilon hepsilon1 hc.1 hL hT hC hmod0 + (hLU.trans hc.2.1) (hTU.trans hc.2.1) (hCU.trans hc.2.1) (hmod.trans hc.2.1) + hc.2.2 (hsource.trans hc.2.1) (hsite.trans hc.2.1) (hinverse.trans he) htotal (htotalInv.trans he) + +theorem adaptiveAffineSideLog_reference_bound {E sourceDim siteDim : ℕ} + {epsilon L T C totalShell modLog dimLog U : ℝ} + (hE : 2 ≤ E) (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hU : 0 ≤ U) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmod0 : 0 ≤ modLog) + (hLU : L ≤ U) (hTU : T ≤ U) (hCU : C ≤ U) (hmod : modLog ≤ U) (hdim : dimLog ≤ U) + (hsource : (sourceDim : ℝ) ≤ U) (hsite : (siteDim : ℝ) ≤ U) + (hinverse : epsilon⁻¹ ≤ Real.exp U) (htotal : 0 < totalShell) (htotalInv : totalShell⁻¹ ≤ Real.exp U) : + adaptiveAffineSideLog ⌈(affineReferenceInput epsilon U + 2) ^ E⌉₊ sourceDim siteDim + epsilon L T C totalShell modLog dimLog ≤ 65536 * (affineCommonReferenceBudget E epsilon U + 3) ^ 4 := by + have hc := affineCommonReferenceBudget_bounds hE epsilon hU + have he : Real.exp U ≤ Real.exp (affineCommonReferenceBudget E epsilon U) := Real.exp_le_exp.mpr hc.2.1 + exact adaptiveAffineSideLog_le_power _ sourceDim siteDim hepsilon hepsilon1 hc.1 hL hT hC hmod0 + (hLU.trans hc.2.1) (hTU.trans hc.2.1) (hCU.trans hc.2.1) (hmod.trans hc.2.1) (hdim.trans hc.2.1) + hc.2.2 (hsource.trans hc.2.1) (hsite.trans hc.2.1) (hinverse.trans he) htotal (htotalInv.trans he) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredJetDensity.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredJetDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1ce39815d82de7900fb4718f9fa2fec95ff5248 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredJetDensity.lean @@ -0,0 +1,213 @@ +import OAI.Combinatorics.Progressions.Probability.CanonicalCoverLaw +import OAI.Combinatorics.Progressions.Probability.EuclideanJetDensity +import OAI.Combinatorics.Progressions.Probability.LowJetDensity + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators Classical + +theorem exists_affine_covered_density (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K] + (root : K → ℤ) (difference : Fin q → K → ℤ) {P : ℝ}, 0 ≤ P → + (Fintype.card K : ℝ) ≤ P → + (∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ Real.exp P) → + ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + [CompactSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ), Continuous D → + ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 → + let E := coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k)) + let π := Set.rangeFactorization E + let C := quotientIntegerCover (coefficientIntegerLattice U) d + ∃ g : Set.range E → ℝ, Continuous g ∧ (∀ y, g y ∈ Set.Icc (0 : ℝ) B) ∧ + Integrable g (μ.map π) ∧ (∫ y, g y ∂μ.map π) = 1 ∧ + (realDensityMeasure μ (fun x => D (C x))).map π = realDensityMeasure (μ.map π) g ∧ + ∀ {I F : Type*} [Fintype F] + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) {η : ℝ}, + (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) → + ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ), + ‖affineCubeFourierProjection U root difference frequency p c b - + (g (π (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by + obtain ⟨A, hA, hbudget⟩ := exists_geometric_positive_cover_budget m q + refine ⟨A, hA, ?_⟩ + intro K _ root difference P hP hK hsite + let site := fun s k => affineSite root difference s (some k) + obtain ⟨d, T, hd, hT, hbound⟩ := exists_common_integer_site_residual + (fun j : Fin m => boundedSiteMatrix (j.val + 1) site) (fun _ => exponentialSiteHeight m P) + (fun _ => exponentialSiteHeight_pos m P) + (fun j => boundedSiteMatrix_height_of_exp m (Nat.succ_le_of_lt j.isLt) site hsite) + have hperiod := hbound (geometricSiteBudget_nonneg m q hP) + (fun j => boundedCoefficientExponent_card_le_geometricSiteBudget m q + (Nat.succ_le_of_lt j.isLt) hP hK) + (cubeSites_card_le_geometricSiteBudget m q hP) + (fun _ => (exponentialSiteHeight_le m hP).trans + (Real.exp_le_exp.mpr (degree_mul_le_geometricSiteBudget m q hP))) + refine ⟨d, hd, ?_, ?_⟩ + · exact hperiod.trans (Real.exp_le_exp.mpr (by simpa only [Fintype.card_fin] using hbudget P hP)) + intro J _ U _ _ _ _ _ μ _ _ D hD B hcap hmass E π C + let R := coefficientSiteResidual U site (fun _ => d) T + let hR := coefficientSiteResidual_preserves_lattice U site (fun _ => d) T + obtain ⟨g, hgc, hgb, hgi, hgmass, hg, hlaw⟩ := + exists_covered_coefficient_density U site d hd T (fun j x => hT j x) μ D hD hcap hmass + refine ⟨g, hgc, hgb, hgi, hgmass, hlaw, ?_⟩ + intro I F _ frequency c η happrox p hp hm b + have hfactor (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : + (coefficientArrayFunctional U frequency).comp R = 0 ↔ + affineCubeModeFactors U root difference frequency := by + change (coefficientArrayFunctional U frequency).comp + (coefficientSiteResidual U site (fun _ => d) T) = 0 ↔ _ + rw [coefficientSiteResidual_zero_iff U site (fun _ => d) T (fun _ => hd) (fun j x => hT j x), + affineCubeModeFactors_iff_bounded] + have hb (x) : ‖D x‖ ≤ B := by rw [Real.norm_of_nonneg (hcap x).1]; exact (hcap x).2 + have he := coefficientTorusFourierProjection_approx_residualAverage U R hR root difference hfactor + frequency c μ D happrox (affineSampleCoefficientTorus U p hm b) + (coefficientResidual_section_integrable U R hR μ D hD hb _) + have hvalue := hg (affineCoefficientCoverSample U p hm d b) + rw [affineCoefficientCoverSample_projection U p hm d hd b] at hvalue + rw [hvalue] + simpa only [coefficientTorusCharacter_sample U _ p hp hm b, affineCubeFourierProjection] using he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped Classical + +theorem exists_affine_covered_euclidean_density (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K] + (root : K → ℤ) (difference : Fin q → K → ℤ) {P : ℝ}, 0 ≤ P → + (Fintype.card K : ℝ) ≤ P → + (∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ Real.exp P) → + ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ (a : ℤ), a ≠ 0 → + integerScalarLattice (Fin q) a ≤ (Matrix.of difference).mulVecLin.range → + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + [CompactSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (D : CoefficientTorus (K := K) U → ℝ), Continuous D → + ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 → + let F := euclideanCoefficientJetMap U root (Matrix.of difference) + (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q))) + let C := quotientIntegerCover (coefficientIntegerLattice U) d + let ξ := Measure.pi (fun j => Measure.pi (fun _ : BoundedBooleanJet (Fin q) (j.val + 1) => ν j)) + ∃ f : EuclideanJetLayers U (fun j => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ, + Continuous f ∧ (∀ z, f z ∈ Set.Icc (0 : ℝ) B) ∧ Integrable f ξ ∧ + (∫ z, f z ∂ξ) = 1 ∧ + (realDensityMeasure μ (fun x => D (C x))).map F = realDensityMeasure ξ f ∧ + ∀ {I G : Type*} [Fintype G] + (frequency : G → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : G → ℂ) {η : ℝ}, + (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) → + ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ), + ‖affineCubeFourierProjection U root difference frequency p c b - + (f (F (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by + obtain ⟨A, hA, hcover⟩ := exists_affine_covered_density m q + refine ⟨A, hA, ?_⟩ + intro K _ root difference P hP hK hsite + obtain ⟨d, hd, hdb, hcover⟩ := hcover root difference hP hK hsite + refine ⟨d, hd, hdb, ?_⟩ + intro a ha hperiod J _ U _ _ _ _ _ μ _ _ ν _ _ D hD B hcap hmass F C ξ + obtain ⟨g, hgc, hgb, _, hgmass, hglaw, hgapprox⟩ := hcover U μ D hD hcap hmass + obtain ⟨hfc, hfb, hfi, hfmass, hvalue, hflaw⟩ := siteImage_density_euclideanJet U root + (Matrix.of difference) a ha hperiod μ ν (realDensityMeasure μ (fun x => D (C x))) + g hgc hgb hgmass hglaw + refine ⟨_, hfc, hfb, hfi, hfmass, hflaw, ?_⟩ + intro I G _ frequency c η happrox p hp hm b + have he := hvalue (Set.rangeFactorization + (coefficientSiteTorusMap U (integerAffineCube root (Matrix.of difference))) + (affineCoefficientCoverSample U p hm d b)) + change (g ((euclideanSiteImageHomeomorph U root (Matrix.of difference) a ha hperiod).symm + (F (affineCoefficientCoverSample U p hm d b)))) = _ at he + rw [he] + exact hgapprox frequency c happrox p hp hm b + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped Classical + +theorem exists_affine_covered_jet_density (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K] + (root : K → ℤ) (difference : Fin q → K → ℤ) {P : ℝ}, 0 ≤ P → + (Fintype.card K : ℝ) ≤ P → + (∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ Real.exp P) → + ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ (a : ℤ), a ≠ 0 → + integerScalarLattice (Fin q) a ≤ (Matrix.of difference).mulVecLin.range → + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + [CompactSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)] + [∀ j, MeasurableSpace (SubspaceArrayTorus (BoundedBooleanJet (Fin q) (j.val + 1)) (U j))] + [∀ j, BorelSpace (SubspaceArrayTorus (BoundedBooleanJet (Fin q) (j.val + 1)) (U j))] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (SubspaceArrayTorus (BoundedBooleanJet (Fin q) (j.val + 1)) (U j))) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (D : CoefficientTorus (K := K) U → ℝ), Continuous D → + ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 → + let F := coefficientBooleanJetTorusMap U root (Matrix.of difference) + (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q))) + let C := quotientIntegerCover (coefficientIntegerLattice U) d + ∃ f : LowBooleanJetTorus (Fin q) U → ℝ, Continuous f ∧ + (∀ z, f z ∈ Set.Icc (0 : ℝ) B) ∧ Integrable f (Measure.pi ν) ∧ + (∫ z, f z ∂Measure.pi ν) = 1 ∧ + (realDensityMeasure μ (fun x => D (C x))).map F = realDensityMeasure (Measure.pi ν) f ∧ + ∀ {I G : Type*} [Fintype G] + (frequency : G → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : G → ℂ) {η : ℝ}, + (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) → + ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ), + ‖affineCubeFourierProjection U root difference frequency p c b - + (f (F (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by + obtain ⟨A, hA, hcover⟩ := exists_affine_covered_density m q + refine ⟨A, hA, ?_⟩ + intro K _ root difference P hP hK hsite + obtain ⟨d, hd, hdb, hcover⟩ := hcover root difference hP hK hsite + refine ⟨d, hd, hdb, ?_⟩ + intro a ha hperiod J _ U _ _ _ _ _ _ _ μ _ _ ν _ _ D hD B hcap hmass F C + obtain ⟨g, hgc, hgb, _, hgmass, hglaw, hgapprox⟩ := hcover U μ D hD hcap hmass + obtain ⟨f, hfc, hfb, hfi, hfmass, hvalue, hflaw⟩ := siteImage_density_lowJet U root + (Matrix.of difference) a ha hperiod μ ν (realDensityMeasure μ (fun x => D (C x))) + g hgc hgb hgmass hglaw + refine ⟨f, hfc, hfb, hfi, hfmass, hflaw, ?_⟩ + intro I G _ frequency c η happrox p hp hm b + have he := hvalue (Set.rangeFactorization + (coefficientSiteTorusMap U (integerAffineCube root (Matrix.of difference))) + (affineCoefficientCoverSample U p hm d b)) + change f (F (affineCoefficientCoverSample U p hm d b)) = _ at he + rw [he] + exact hgapprox frequency c happrox p hp hm b + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredSiteValues.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredSiteValues.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b229a74d49da7d79623f0daacc58ee54af2621e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCoveredSiteValues.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.Progressions.Geometry.GeometricRetainedCommonCover + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +noncomputable def affineCoveredSiteSample {I K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (difference : Fin q → K → ℤ) (D : ℕ) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (x : Option K → I → ℝ) : + ∀ j, SubspaceArrayTorus (Finset (Fin q)) (U j) := fun j => + QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j)) + ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) + (substitute (affineParameterSubstitution x) (restrictCoefficients (U j) (p j) (hm j)))) + +theorem layeredCoefficientCharacter_of_site_factorization + {I K : Type*} [Fintype K] {m q : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (D : ℕ) (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (b : ∀ j, Matrix (Finset (Fin q)) (J j) ℤ) + (hchar : ∀ (j : Fin m) (v : VectorPolynomial K ℝ (U j)), + DegreeLE (1 : K → ℕ) (j.val + 1) v → + CircleFourier.character + (coefficientFunctional (fun d a => (frequency j d a : ℝ)) + (map (U j).subtype v) : CircleFourier.Circle) = + subspaceArrayCharacter (U j) (b j) + (QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j)) + ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) v))) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (x : Option K → I → ℝ) : + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) p x = + ∏ j, subspaceArrayCharacter (U j) (b j) + (affineCoveredSiteSample U root difference D p hm x j) := by + unfold layeredCoefficientCharacter + rw [character_real_sum] + apply Finset.prod_congr rfl + intro j _ + rw [affineModeLift_substitute] + have he := hchar j + (substitute (affineParameterSubstitution x) (restrictCoefficients (U j) (p j) (hm j))) + (degreeLE_substitute_affine _ (affineParameterSubstitution_degree x) _ + (degreeLE_restrictCoefficients (U j) (p j) (hm j) (hp j))) + simpa only [map_substitute, map_restrictCoefficients, affineCoveredSiteSample] using he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem affine_site_substitution_eval {I K W : Type*} [Fintype K] + [AddCommGroup W] [Module ℝ W] {q : ℕ} + (root : K → ℤ) (difference : Fin q → K → ℤ) + (p : VectorPolynomial I ℝ W) (x : Option K → I → ℝ) : + VectorPolynomial.siteEvaluation + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) + (substitute (affineParameterSubstitution x) p) = + fun s => eval (integerSiteValue (affineSite root difference s) x) p := by + funext s + change eval _ (substitute _ p) = _ + rw [eval_substitute] + apply congrArg (fun t : I → ℝ => eval t p) + funext i + rw [affineParameterSubstitution_eval] + simp [integerSiteValue, Fintype.sum_option, affineSite, Finset.sum_apply, + zsmul_eq_mul, mul_comm] + +theorem affineCoveredSiteSample_eq_values {I K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (difference : Fin q → K → ℤ) (D : ℕ) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (x : Option K → I → ℝ) (j : Fin m) : + affineCoveredSiteSample U root difference D p hm x j = + QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j)) + ((D : ℝ)⁻¹ • fun s => eval (integerSiteValue (affineSite root difference s) x) + (restrictCoefficients (U j) (p j) (hm j))) := by + unfold affineCoveredSiteSample + rw [affine_site_substitution_eval] + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c2147d121d62903be5c54e8a7790830f22da027 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoordinates.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.Progressions.Estimates.CoefficientSliceEmbedding + +namespace OAI + +section + +namespace Erdos3 + +def affineCubeCoordinates {I : Type*} (u : Option I → ℝ) (v : Option I → ℕ) + (x : Option I → ℝ) : Option I → ℝ := fun i => u i + (v i : ℝ) * x i + +def affineIntegerCubeCoordinates {I : Type*} (u : Option I → ℤ) (v : Option I → ℕ) + (x : Option I → ℤ) : Option I → ℤ := fun i => u i + (v i : ℤ) * x i + +theorem affineIntegerCubeCoordinates_cast {I : Type*} (u : Option I → ℤ) (v : Option I → ℕ) + (x : Option I → ℤ) : + (fun i => (affineIntegerCubeCoordinates u v x i : ℝ)) = + affineCubeCoordinates (fun i => (u i : ℝ)) v (fun i => (x i : ℝ)) := by + funext i + simp only [affineIntegerCubeCoordinates, affineCubeCoordinates, Int.cast_add, Int.cast_mul, Int.cast_natCast] + +theorem ScalarCubeLocalizationData.affine_point_scale {I : Type*} [Fintype I] [DecidableEq I] + (d : ScalarCubeLocalizationData I) (u : Option I → ℝ) (v : Option I → ℕ) + (z : IntegerScalarCubeBox I d.length) : + affineCubeCoordinates u v (fun i => (d.length : ℝ) * d.point z i) = + affineCubeCoordinates u v (fun i => (z i : ℝ)) := by + congr 1 + funext i + exact d.point_scale z i + +theorem ScalarCubeLocalizationData.affine_cell_scale {I : Type*} [Fintype I] [DecidableEq I] + (d : ScalarCubeLocalizationData I) (u : Option I → ℝ) (v : Option I → ℕ) + (k : Option I → Fin d.cellCount) (t : Option I → Fin d.cellLength) : + affineCubeCoordinates u v (fun i => (d.length : ℝ) * d.cell k t i) = + fun i => (u i + (v i : ℝ) * d.integerOffset k i) + + ((v i * d.modulus i : ℕ) : ℝ) * (t i).val := by + rw [d.cell_scale] + funext i + simp only [affineCubeCoordinates, Nat.cast_mul] + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoveredProjection.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoveredProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f2166ef0048c442d8aaa77fc623d7f7baeff762 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeCoveredProjection.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Fourier.SectionRetainedFourier + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial Polynomial +open scoped BigOperators + +theorem exists_affine_cube_covered_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hK : (Fintype.card K : ℝ) ≤ P) (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∃ b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ a j s t, |(b a j s t : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + affineCubeFourierSum frequency p c (fun k j => (z (k, j) : ℝ)))) - + (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + retainedSiteFourierSum U root difference frequency b c + (affineCoveredSiteSample U root difference D p hm (fun k j => (z (k, j) : ℝ)))))‖ ≤ ε := by + obtain ⟨A₀, _, hprojection⟩ := exists_affine_cube_fourier_projection m q + obtain ⟨A₁, _, hcover⟩ := exists_geometric_site_fourier_projection m q + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A₀) ^ A₀ + (X + Polynomial.C A₁) ^ A₁) + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hK hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound c B hB hBP hcoefficients p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth + have hsum : (P + A₀) ^ A₀ + (P + A₁) ^ A₁ ≤ (P + A) ^ A := by + simpa [Polynomial.eval₂_pow] using hbudget P hP + have hb₀ : (P + A₀) ^ A₀ ≤ (P + A) ^ A := by + linarith [pow_nonneg (add_nonneg hP (Nat.cast_nonneg A₁)) A₁] + have hb₁ : (P + A₁) ^ A₁ ≤ (P + A) ^ A := by + linarith [pow_nonneg (add_nonneg hP (Nat.cast_nonneg A₀)) A₀] + obtain ⟨D, hD, hDP, hrows⟩ := hcover root difference hP hK (fun s k => (hsite s k).trans hLP) + obtain ⟨b, hb, heq⟩ := hrows U frequency (fun a j d hd t => (hbound a j d hd t).trans hCP) + obtain ⟨hZ, hproj⟩ := hprojection hP hn hd U root difference hlin hL hC hLP hCP hsite + frequency hbound c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP + hstride H (fun k => (Real.exp_le_exp.mpr hb₀).trans (hsize k)) hrank + ((Real.exp_le_exp.mpr hb₀).trans hR) Q hQ test htest G hG V hV hwidth + refine ⟨D, hD, hDP.trans (Real.exp_le_exp.mpr hb₁), b, + fun a j s t => (hb a j s t).trans (Real.exp_le_exp.mpr hb₁), hZ, ?_⟩ + have hfun : affineCubeFourierProjection U root difference frequency p c = + fun x => retainedSiteFourierSum U root difference frequency b c + (affineCoveredSiteSample U root difference D p hm x) := + funext (fun x => heq p hp hm c x) + rw [hfun] at hproj + exact hproj + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeMinorGoodMass.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeMinorGoodMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1cbd84fc671705ed00bed6e2dbfe3bc7091860b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeMinorGoodMass.lean @@ -0,0 +1,622 @@ +import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar +import OAI.Combinatorics.Progressions.Estimates.CanonicalCubeMinorThreshold +import OAI.Combinatorics.Progressions.Probability.JointBooleanCutoffLaw + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory + +variable {I : Type*} [Fintype I] + +theorem affine_preimage_volume_real (L : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (b : I → ℝ) (s : Set (I → ℝ)) : + volume.real ((fun x => b + L x) ⁻¹' s) = inverseJacobian L * volume.real s := by + change (volume (L ⁻¹' ((fun x => b + x) ⁻¹' s))).toReal = _ + rw [Measure.addHaar_preimage_continuousLinearEquiv volume L, measure_preimage_add, + ENNReal.toReal_mul, ENNReal.toReal_ofReal (abs_nonneg _)] + rfl + +theorem affine_sublevel_volume_real (L : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (b : I → ℝ) (Ω : Set (I → ℝ)) (g : (I → ℝ) → ℝ) (u : ℝ) : + volume.real (Ω ∩ {x | |g (b + L x)| ≤ u}) = inverseJacobian L * + volume.real (((fun x => b + L x) '' Ω) ∩ {x | |g x| ≤ u}) := by + have he : Ω ∩ {x | |g (b + L x)| ≤ u} = + (fun x => b + L x) ⁻¹' (((fun x => b + L x) '' Ω) ∩ {x | |g x| ≤ u}) := by + ext x + constructor + · rintro ⟨hx, hg⟩ + exact ⟨⟨x, hx, rfl⟩, hg⟩ + · rintro ⟨⟨y, hy, he⟩, hg⟩ + have hyx : y = x := L.injective (add_left_cancel he) + exact ⟨hyx ▸ hy, hg⟩ + rw [he, affine_preimage_volume_real] + +theorem exists_affine_boolean_minor_sublevel_bound {O α : Type*} + [Fintype O] [Fintype α] [DecidableEq O] [DecidableEq α] + (c : O → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets) + (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h) + {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N) + {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ o, c₀ ≤ |c o|) : + ∃ r : O → Option α, ∀ (d : ℕ), 0 < d → Fintype.card O * (h - 1) ≤ d → + ∀ (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ) + (Ω : Set (Fin N → ℝ)) (R u : ℝ), 1 ≤ R → + (∀ x ∈ Ω, ∀ j, |(b + L x) j| ≤ R) → 0 < u → + volume.real (Ω ∩ {x | |((booleanSelectedMinor c sets id (⟨0, hh⟩ : Fin h) r).map + (MvPolynomial.eval ((b + L x) ∘ e))).det| ≤ u}) ≤ + inverseJacobian L * (R ^ N * multivariateSublevelConstant N d * + (u * (d + 1 : ℝ) ^ N / c₀ ^ Fintype.card O) ^ (((N * d : ℕ) : ℝ)⁻¹)) := by + obtain ⟨r, hr⟩ := exists_boolean_minor_sublevel_bound c sets hsets h hh hcard e hN hc₀ hc + refine ⟨r, ?_⟩ + intro d hd hdeg L b Ω R u hR hΩ hu + rw [affine_sublevel_volume_real L b Ω + (fun x => ((booleanSelectedMinor c sets id (⟨0, hh⟩ : Fin h) r).map + (MvPolynomial.eval (x ∘ e))).det) u] + apply mul_le_mul_of_nonneg_left _ (inverseJacobian_pos L).le + apply hr d hd hdeg _ R u hR _ hu + rintro y ⟨x, hx, rfl⟩ j + exact hΩ x hx j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +noncomputable def reindexedAffineSource {I : Type*} {N : ℕ} (e : I ≃ Fin N) + (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ) (a : I → ℝ) : I → ℝ := + (b + L (a ∘ e.symm)) ∘ e + +theorem reindexedAffineSource_continuous {I : Type*} [Fintype I] {N : ℕ} + (e : I ≃ Fin N) (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ) : + Continuous (reindexedAffineSource e L b) := by + unfold reindexedAffineSource + fun_prop + +theorem reindexedAffineSource_apply {I : Type*} {N : ℕ} (e : I ≃ Fin N) + (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b x : Fin N → ℝ) : + reindexedAffineSource e L b (x ∘ e) = (b + L x) ∘ e := by + have he : (x ∘ e) ∘ e.symm = x := by funext j; simp + simp only [reindexedAffineSource, he] + +theorem exists_affine_cube_minor_probability_bound {O α : Type*} + [Fintype O] [Fintype α] [DecidableEq O] [DecidableEq α] + (c : O → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets) + (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h) + {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N) + {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ o, c₀ ≤ |c o|) : + ∃ r : O → Option α, ∀ d : ℕ, 0 < d → Fintype.card O * (h - 1) ≤ d → + ∀ (L : (Fin N → ℝ) ≃L[ℝ] (Fin N → ℝ)) (b : Fin N → ℝ) (R u : ℝ), + 1 ≤ R → (∀ x ∈ reindexedBlockCubeDomain e, ∀ j, |(b + L x) j| ≤ R) → 0 < u → + (blockCubeMeasure O (Fin h) α).real + {a | |booleanMinorDeterminant c sets id (⟨0, hh⟩ : Fin h) r + (reindexedAffineSource e L b a)| ≤ u} ≤ + scalarCubeDomainDensity α ^ Fintype.card (O × Fin h) * inverseJacobian L * + (R ^ N * multivariateSublevelConstant N d * + (u * (d + 1 : ℝ) ^ N / c₀ ^ Fintype.card O) ^ (((N * d : ℕ) : ℝ)⁻¹)) := by + obtain ⟨r, hr⟩ := exists_affine_boolean_minor_sublevel_bound c sets hsets h hh hcard e hN hc₀ hc + refine ⟨r, ?_⟩ + intro d hd hdeg L b R u hR hbox hu + have hsm : MeasurableSet {a | |booleanMinorDeterminant c sets id (⟨0, hh⟩ : Fin h) r + (reindexedAffineSource e L b a)| ≤ u} := + measurableSet_le (((booleanMinorDeterminant_contDiff c sets id (⟨0, hh⟩ : Fin h) r).continuous.comp + (reindexedAffineSource_continuous e L b)).measurable.abs) measurable_const + rw [blockCubeMeasure_real_reindex e _ hsm] + simp only [Set.mem_ofPred_eq, reindexedAffineSource_apply] + have hvol := hr d hd hdeg L b (reindexedBlockCubeDomain e) R u hR hbox hu + exact (mul_le_mul_of_nonneg_left hvol + (pow_nonneg (scalarCubeDomainDensity_pos α).le (Fintype.card (O × Fin h)))).trans_eq + (mul_assoc _ _ _).symm + +theorem booleanMinorDeterminant_affine_sublevel_marginal {B O F α : Type*} + [Fintype B] [Fintype O] [Fintype F] [Fintype α] + [DecidableEq B] [DecidableEq O] [DecidableEq F] [DecidableEq α] + (c : B → ℝ) (sets : O → Finset α) (block : O → B) (hblock : Function.Injective block) + (v : F) (r : O → Option α) + (T : (BlockParameter B F α → ℝ) → (BlockParameter B F α → ℝ)) + (T₀ : (BlockParameter O F α → ℝ) → (BlockParameter O F α → ℝ)) + (hT₀ : Measurable T₀) + (hrestrict : ∀ a, restrictBlockParameters block (T a) = T₀ (restrictBlockParameters block a)) (u : ℝ) : + (blockCubeMeasure B F α).real {a | |booleanMinorDeterminant c sets block v r (T a)| ≤ u} = + (blockCubeMeasure O F α).real {a | |booleanMinorDeterminant (c ∘ block) sets id v r (T₀ a)| ≤ u} := by + have hs : MeasurableSet {a | |booleanMinorDeterminant (c ∘ block) sets id v r (T₀ a)| ≤ u} := + measurableSet_le (((booleanMinorDeterminant_contDiff (c ∘ block) sets id v r).continuous.measurable.comp + hT₀).abs) measurable_const + have hm := (restrictBlockParameters_cube_measurePreserving (F := F) (α := α) block hblock).measureReal_preimage + hs.nullMeasurableSet + have he : {a | |booleanMinorDeterminant c sets block v r (T a)| ≤ u} = + restrictBlockParameters block ⁻¹' + {a | |booleanMinorDeterminant (c ∘ block) sets id v r (T₀ a)| ≤ u} := by + ext a + change |booleanMinorDeterminant c sets block v r (T a)| ≤ u ↔ _ + rw [booleanMinorDeterminant_restrict c sets block v r (T a), hrestrict] + rfl + rw [he] + exact hm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +theorem inverseJacobian_coordinateScale_le {I : Type*} [Fintype I] + (a : I → ℝ) (ha : ∀ i, a i ≠ 0) {δ : ℝ} (hδ : 0 < δ) + (hwidth : ∀ i, δ ≤ |a i|) : + inverseJacobian (coordinateScaleEquiv a ha).toContinuousLinearEquiv ≤ δ⁻¹ ^ Fintype.card I := by + rw [inverseJacobian_eq] + change |LinearMap.det (coordinateScaleEquiv a ha).toLinearMap|⁻¹ ≤ _ + rw [diagonalDensityTransport_det, Finset.abs_prod, ← Finset.prod_inv_distrib] + calc + _ ≤ ∏ _i : I, δ⁻¹ := by + apply Finset.prod_le_prod₀ + · intro i _ + exact inv_nonneg.mpr (abs_nonneg _) + · intro i _ + simpa only [one_div] using one_div_le_one_div_of_le hδ (hwidth i) + _ = _ := by simp + +theorem exists_allocated_affine_cube_minor_probability_bound {B O α : Type*} + [Fintype B] [Fintype O] [Fintype α] + [DecidableEq B] [DecidableEq O] [DecidableEq α] + (c : B → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets) + (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h) + (block : O → B) (hblock : Function.Injective block) + {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N) + {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ o, c₀ ≤ |c (block o)|) : + ∃ r : O → Option α, ∀ d : ℕ, 0 < d → Fintype.card O * (h - 1) ≤ d → + ∀ (center width : BlockParameter B (Fin h) α → ℝ) (δ u : ℝ), 0 < δ → + (∀ z : BlockParameter O (Fin h) α, δ ≤ |restrictBlockParameters block width z|) → + (∀ z : BlockParameter O (Fin h) α, + |restrictBlockParameters block center z| + |restrictBlockParameters block width z| ≤ 1) → + 0 < u → + (blockCubeMeasure B (Fin h) α).real + {a | |booleanMinorDeterminant c sets block (⟨0, hh⟩ : Fin h) r + (fun z => center z + width z * a z)| ≤ u} ≤ + scalarCubeDomainDensity α ^ Fintype.card (O × Fin h) * δ⁻¹ ^ N * + (multivariateSublevelConstant N d * + (u * (d + 1 : ℝ) ^ N / c₀ ^ Fintype.card O) ^ (((N * d : ℕ) : ℝ)⁻¹)) := by + obtain ⟨r, hr⟩ := exists_affine_cube_minor_probability_bound + (c ∘ block) sets hsets h hh hcard e hN hc₀ hc + refine ⟨r, ?_⟩ + intro d hd hdeg center width δ u hδ hwidth hbox hu + let w : Fin N → ℝ := restrictBlockParameters block width ∘ e.symm + let b : Fin N → ℝ := restrictBlockParameters block center ∘ e.symm + have hw (i) : δ ≤ |w i| := hwidth (e.symm i) + have hwne (i) : w i ≠ 0 := abs_pos.mp (hδ.trans_le (hw i)) + let L := (coordinateScaleEquiv w hwne).toContinuousLinearEquiv + let T := fun a : BlockParameter B (Fin h) α → ℝ => fun z => center z + width z * a z + let T₀ := reindexedAffineSource e L b + have hrestrict (a) : restrictBlockParameters block (T a) = T₀ (restrictBlockParameters block a) := by + funext z + change center (block z.1, z.2) + width (block z.1, z.2) * a (block z.1, z.2) = + b (e z) + w (e z) * restrictBlockParameters block a (e.symm (e z)) + simp only [w, b, Function.comp_apply, e.symm_apply_apply, restrictBlockParameters] + rw [booleanMinorDeterminant_affine_sublevel_marginal c sets block hblock (⟨0, hh⟩ : Fin h) r + T T₀ (reindexedAffineSource_continuous e L b).measurable hrestrict u] + have hbox' (x) (hx : x ∈ reindexedBlockCubeDomain e) (i) : |(b + L x) i| ≤ (1 : ℝ) := by + change |b i + w i * x i| ≤ 1 + calc + _ ≤ |b i| + |w i * x i| := abs_add_le _ _ + _ = |b i| + |w i| * |x i| := by rw [abs_mul] + _ ≤ |b i| + |w i| := add_le_add le_rfl + (mul_le_of_le_one_right (abs_nonneg _) (reindexedBlockCubeDomain_box e hx i)) + _ ≤ 1 := hbox (e.symm i) + have hp := hr d hd hdeg L b 1 u le_rfl hbox' hu + simp only [one_pow, one_mul] at hp + apply hp.trans + have hJ : inverseJacobian L ≤ δ⁻¹ ^ N := by + simpa only [Fintype.card_fin] using inverseJacobian_coordinateScale_le w hwne hδ hw + have hconst : 0 ≤ multivariateSublevelConstant N d := (multivariateSublevelConstant_pos hN d).le + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hJ (pow_nonneg (scalarCubeDomainDensity_pos α).le _)) + (mul_nonneg hconst (Real.rpow_nonneg (by positivity) _)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +noncomputable def affineCubeMinorThreshold (J O α : Type*) [Fintype J] [Fintype O] [Fintype α] + [DecidableEq α] (h N d : ℕ) (c₀ δ η : ℝ) : ℝ := + polynomialSublevelThreshold (N * d) (Fintype.card J) + (cubeMinorProbabilityConstant O α h N d * δ⁻¹ ^ N) + (cubeMinorProbabilityScale O N d c₀) η + +theorem affineCubeMinorThreshold_pos (J O α : Type*) [Fintype J] [Fintype O] [Fintype α] + [DecidableEq α] (h : ℕ) {N : ℕ} (hN : 0 < N) (d : ℕ) + {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hη : 0 < η) : + 0 < affineCubeMinorThreshold J O α h N d c₀ δ η := + polynomialSublevelThreshold_pos _ _ + (mul_nonneg (cubeMinorProbabilityConstant_pos O α h hN d).le (pow_nonneg (inv_nonneg.mpr hδ.le) _)) + (cubeMinorProbabilityScale_pos O N d hc₀).le hη + +theorem affineCubeMinorThreshold_log_inv (J O α : Type*) [Fintype J] [Fintype O] [Fintype α] + [DecidableEq α] (h : ℕ) {N : ℕ} (hN : 0 < N) (d : ℕ) + {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hη : 0 < η) : + Real.log (affineCubeMinorThreshold J O α h N d c₀ δ η)⁻¹ = + Real.log 2 + Real.log (1 + cubeMinorProbabilityScale O N d c₀) + + (N * d : ℕ) * Real.log (1 + 2 * (cubeMinorProbabilityConstant O α h N d * δ⁻¹ ^ N) * + (Fintype.card J + 1 : ℝ) / η) := + polynomialSublevelThreshold_log_inv _ _ + (mul_nonneg (cubeMinorProbabilityConstant_pos O α h hN d).le (pow_nonneg (inv_nonneg.mpr hδ.le) _)) + (cubeMinorProbabilityScale_pos O N d hc₀).le hη + +theorem exists_affine_cube_minor_thresholds {B O J α : Type*} + [Fintype B] [Fintype O] [Fintype J] [Fintype α] + [DecidableEq B] [DecidableEq O] [DecidableEq α] + (c : J → B → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets) + (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h) + (block : J → O → B) (hblock : ∀ j, Function.Injective (block j)) + {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N) + (d : ℕ) (hd : 0 < d) (hdeg : Fintype.card O * (h - 1) ≤ d) + {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ j o, c₀ ≤ |c j (block j o)|) : + ∃ sel : J → O → Option α, ∀ δ η : ℝ, 0 < δ → 0 < η → + ∀ center width : BlockParameter B (Fin h) α → ℝ, + (∀ j z, δ ≤ |restrictBlockParameters (block j) width z|) → + (∀ j z, |restrictBlockParameters (block j) center z| + + |restrictBlockParameters (block j) width z| ≤ 1) → + (∑ j, (blockCubeMeasure B (Fin h) α).real + {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| < + 2 * affineCubeMinorThreshold J O α h N d c₀ δ η}) ≤ η / 2 := by + choose sel hsel using (fun j => exists_allocated_affine_cube_minor_probability_bound + (c j) sets hsets h hh hcard (block j) (hblock j) e hN hc₀ (hc j)) + refine ⟨sel, ?_⟩ + intro δ η hδ hη center width hwidth hbox + let K := cubeMinorProbabilityConstant O α h N d * δ⁻¹ ^ N + let scale := cubeMinorProbabilityScale O N d c₀ + let κ := affineCubeMinorThreshold J O α h N d c₀ δ η + have hK : 0 < K := mul_pos (cubeMinorProbabilityConstant_pos O α h hN d) (pow_pos (inv_pos.mpr hδ) _) + have hscale : 0 < scale := cubeMinorProbabilityScale_pos O N d hc₀ + have hκ : 0 < κ := affineCubeMinorThreshold_pos J O α h hN d hc₀ hδ hη + have hp (j : J) : (blockCubeMeasure B (Fin h) α).real + {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| < 2 * κ} ≤ + K * (2 * κ * scale) ^ (((N * d : ℕ) : ℝ)⁻¹) := by + have hm : (blockCubeMeasure B (Fin h) α).real + {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| < 2 * κ} ≤ + (blockCubeMeasure B (Fin h) α).real + {a | |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| ≤ 2 * κ} := by + apply measureReal_mono + · intro a ha + change |booleanMinorDeterminant (c j) sets (block j) (⟨0, hh⟩ : Fin h) (sel j) (fun z => center z + width z * a z)| ≤ 2 * κ + exact le_of_lt ha + · exact measure_ne_top _ _ + apply hm.trans + have hb := hsel j d hd hdeg center width δ (2 * κ) hδ (hwidth j) (hbox j) (by positivity) + simpa only [K, scale, cubeMinorProbabilityConstant, cubeMinorProbabilityScale, + div_eq_mul_inv, mul_assoc, mul_left_comm, mul_comm] using hb + calc + _ ≤ ∑ _j : J, K * (2 * κ * scale) ^ (((N * d : ℕ) : ℝ)⁻¹) := + Finset.sum_le_sum (fun j _ => hp j) + _ = (Fintype.card J : ℝ) * K * (2 * κ * scale) ^ (((N * d : ℕ) : ℝ)⁻¹) := by + rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + ring + _ ≤ η / 2 := polynomialSublevelThreshold_total_bound (Nat.mul_pos hN hd) hK.le hscale.le hη + +end Erdos3 + +end + +section + +namespace Erdos3 + +lemma log_one_add_inverse_width_pow {A δ : ℝ} (hA : 0 ≤ A) (hδ : 0 < δ) (hδone : δ ≤ 1) + (N : ℕ) : + Real.log (1 + A * δ⁻¹ ^ N) ≤ Real.log (1 + A) + (N : ℝ) * Real.log δ⁻¹ := by + have hi : 1 ≤ δ⁻¹ := (one_le_inv₀ hδ).mpr hδone + have hp : 1 ≤ δ⁻¹ ^ N := one_le_pow₀ hi + have hmul : 1 + A * δ⁻¹ ^ N ≤ (1 + A) * δ⁻¹ ^ N := by nlinarith + have hlog := Real.log_le_log (show 0 < 1 + A * δ⁻¹ ^ N by positivity) hmul + rw [Real.log_mul (by positivity : (1 + A : ℝ) ≠ 0) (by positivity : δ⁻¹ ^ N ≠ 0), + Real.log_pow] at hlog + exact hlog + +theorem affineCubeMinorThreshold_log_inv_slice_bound (J O α : Type*) [Fintype J] [Fintype O] + [Fintype α] [DecidableEq α] (h : ℕ) {N : ℕ} (hN : 0 < N) (d : ℕ) + {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + Real.log (affineCubeMinorThreshold J O α h N d c₀ δ η)⁻¹ ≤ + Real.log 2 + Real.log (1 + cubeMinorProbabilityScale O N d c₀) + + (N * d : ℕ) * (Real.log (1 + 2 * cubeMinorProbabilityConstant O α h N d * + (Fintype.card J + 1 : ℝ) / η) + (N : ℝ) * Real.log δ⁻¹) := by + rw [affineCubeMinorThreshold_log_inv J O α h hN d hc₀ hδ hη] + apply add_le_add le_rfl + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg (N * d)) + have hA : 0 ≤ 2 * cubeMinorProbabilityConstant O α h N d * (Fintype.card J + 1 : ℝ) / η := + div_nonneg (mul_nonneg (mul_nonneg (by norm_num) (cubeMinorProbabilityConstant_pos O α h hN d).le) + (by positivity)) hη.le + have hb := log_one_add_inverse_width_pow hA hδ hδone N + convert hb using 1 + congr 1 + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff BigOperators + +variable {B O J α : Type*} [Fintype B] [Fintype O] [Fintype J] [Fintype α] + [DecidableEq B] [DecidableEq O] [DecidableEq α] {h : ℕ} + +noncomputable def affineBooleanCubeDeterminant + (c : B → ℝ) (sets : O → Finset α) (block : O → B) + (v : Fin h) (sel : O → Option α) + (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ)) + (b : BlockParameter B (Fin h) α → ℝ) (x : (B × Fin h) → Option α → ℝ) : ℝ := + booleanMinorDeterminant c sets block v sel (b + L (blockCubeFlatten B (Fin h) α x)) + +theorem affineBooleanCubeDeterminant_contDiff + (c : B → ℝ) (sets : O → Finset α) (block : O → B) + (v : Fin h) (sel : O → Option α) + (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ)) + (b : BlockParameter B (Fin h) α → ℝ) : + ContDiff ℝ ∞ (affineBooleanCubeDeterminant c sets block v sel L b) := + (booleanMinorDeterminant_contDiff c sets block v sel).comp + (contDiff_const.add (L.contDiff.comp (blockCubeFlatten B (Fin h) α).contDiff)) + +noncomputable def affineBooleanCubeGoodWeight + (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B) + (v : Fin h) (sel : J → O → Option α) + (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ)) + (b : BlockParameter B (Fin h) α → ℝ) + (ψ : ℝ → ℝ) (r : B × Fin h → ℝ) (κ : J → ℝ) : + (BlockParameter B (Fin h) α → ℝ) → ℝ := + blockCubeWeight (scalarCubeGoodWeight α ψ r κ + (fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b)) + +noncomputable def affineBooleanCubeCutoff + (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B) + (v : Fin h) (sel : J → O → Option α) + (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ)) + (b : BlockParameter B (Fin h) α → ℝ) + (ψ : ℝ → ℝ) (r : B × Fin h → ℝ) (κ : J → ℝ) + (a : BlockParameter B (Fin h) α → ℝ) : ℝ := + goodDomainCutoff ψ κ + (fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b) + (scalarCubeProductCutoff α r) ((blockCubeFlatten B (Fin h) α).symm a) + +variable (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B) + (v : Fin h) (sel : J → O → Option α) + (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ)) + (b : BlockParameter B (Fin h) α → ℝ) + (ψ : ℝ → ℝ) (r : B × Fin h → ℝ) (κ : J → ℝ) + +theorem affineBooleanCubeCutoff_contDiff (hψ : ContDiff ℝ ∞ ψ) : + ContDiff ℝ ∞ (affineBooleanCubeCutoff c sets block v sel L b ψ r κ) := + (goodDomainCutoff_smooth ψ hψ κ _ + (fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b) _ + (scalarCubeProductCutoff_smooth r)).comp (blockCubeFlatten B (Fin h) α).symm.contDiff + +theorem affineBooleanCubeCutoff_range (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (x : BlockParameter B (Fin h) α → ℝ) : + affineBooleanCubeCutoff c sets block v sel L b ψ r κ x ∈ Set.Icc (0 : ℝ) 1 := + goodDomainCutoff_range ψ hrange κ _ _ (scalarCubeProductCutoff_range r) _ + +theorem affineBooleanCubeGoodWeight_spec + (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hr : ∀ i, 0 < r i) (hκ : ∀ j, 0 < κ j) : + let w := affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ + ContDiff ℝ 1 w ∧ HasCompactSupport w ∧ (∀ a, 0 ≤ w a) ∧ (∫ a, |w a|) ≤ 1 ∧ + ∀ a ∈ tsupport w, (∀ z, |a z| ≤ 1) ∧ + ∀ j, κ j ≤ |booleanMinorDeterminant (c j) sets (block j) v (sel j) (b + L a)| := by + let d := fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b + have hs := scalarCubeGoodWeight_spec ψ hψ hrange hzero r hr κ hκ d + (fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b) + refine ⟨blockCubeWeight_contDiff _ hs.1, blockCubeWeight_compact _ hs.2.1, + fun a => hs.2.2.2.1 _, ?_, ?_⟩ + · change (∫ a, |blockCubeWeight (scalarCubeGoodWeight α ψ r κ d) a|) ≤ 1 + rw [blockCubeWeight_abs_integral] + exact hs.2.2.2.2 + · intro a ha + refine ⟨blockCubeWeight_box _ (fun x hx => (hs.2.2.1 hx).1) ha, ?_⟩ + change a ∈ tsupport (blockCubeWeight (scalarCubeGoodWeight α ψ r κ d)) at ha + rw [blockCubeWeight_tsupport] at ha + intro j + simpa only [d, affineBooleanCubeDeterminant, ContinuousLinearEquiv.apply_symm_apply] using + (hs.2.2.1 ha).2 j + +theorem affineBooleanCubeGoodWeight_integral_test (hr : ∀ i, 0 < r i) + (f : (BlockParameter B (Fin h) α → ℝ) → ℝ) : + (∫ a, affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ a * f a) = + ∫ a, affineBooleanCubeCutoff c sets block v sel L b ψ r κ a * f a + ∂blockCubeMeasure B (Fin h) α := by + unfold affineBooleanCubeGoodWeight + rw [blockCubeWeight_integral_test, blockCubeMeasure_integral] + simp only [affineBooleanCubeCutoff, ContinuousLinearEquiv.symm_apply_apply] + exact scalarCubeGoodWeight_integral_test ψ r hr κ _ _ + +theorem affineBooleanCubeGoodWeight_measure + (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hr : ∀ i, 0 < r i) (hκ : ∀ j, 0 < κ j) : + realDensityMeasure volume (affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ) = + realDensityMeasure (blockCubeMeasure B (Fin h) α) + (affineBooleanCubeCutoff c sets block v sel L b ψ r κ) := by + let w := affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ + let χ := affineBooleanCubeCutoff c sets block v sel L b ψ r κ + have hw := affineBooleanCubeGoodWeight_spec c sets block v sel L b ψ r κ hψ hrange hzero hr hκ + have hm : Measurable χ := + (affineBooleanCubeCutoff_contDiff c sets block v sel L b ψ r κ hψ).continuous.measurable + have h01 := affineBooleanCubeCutoff_range c sets block v sel L b ψ r κ hrange + let : IsFiniteMeasure (realDensityMeasure volume w) := + realDensityMeasure_finite volume w (hw.1.continuous.integrable_of_hasCompactSupport hw.2.1) hw.2.2.1 + let : IsFiniteMeasure (realDensityMeasure (blockCubeMeasure B (Fin h) α) χ) := + realDensityMeasure_finite _ χ (cutoff_integrable _ χ hm h01) (fun a => (h01 a).1) + apply finiteMeasure_eq_of_integrals + intro f _ + rw [realDensityMeasure_integral volume w hw.1.continuous.measurable hw.2.2.1, + realDensityMeasure_integral _ χ hm (fun a => (h01 a).1)] + exact affineBooleanCubeGoodWeight_integral_test c sets block v sel L b ψ r κ hr f + +theorem affineBooleanCubeGoodWeight_mass_lower + (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hone : ∀ t, 2 ≤ |t| → ψ t = 1) (hr : ∀ i, 0 < r i) (hκ : ∀ j, 0 < κ j) : + 1 - scalarCubeBoundaryConstant α * ∑ i, r i - + ∑ j, (blockCubeMeasure B (Fin h) α).real + {a | |booleanMinorDeterminant (c j) sets (block j) v (sel j) (b + L a)| < 2 * κ j} ≤ + ∫ a, affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ a := by + unfold affineBooleanCubeGoodWeight + rw [blockCubeWeight_integral] + have hs := scalarCubeGoodWeight_mass_lower ψ hψ hrange hone r hr κ hκ + (fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b) + (fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b) + have he (j : J) : + (scalarCubeProductMeasure (B × Fin h) α).real + {x | |affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b x| < 2 * κ j} = + (blockCubeMeasure B (Fin h) α).real + {a | |booleanMinorDeterminant (c j) sets (block j) v (sel j) (b + L a)| < 2 * κ j} := by + symm + exact blockCubeMeasure_real_apply _ (measurableSet_lt + (((booleanMinorDeterminant_contDiff (c j) sets (block j) v (sel j)).comp + (contDiff_const.add L.contDiff)).continuous.measurable.abs) measurable_const) + simp_rw [he] at hs + exact hs + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff BigOperators NNReal + +variable {B O J α : Type*} [Fintype B] [Fintype O] [Fintype J] [Fintype α] + [DecidableEq B] [DecidableEq O] [DecidableEq α] {h : ℕ} + +theorem affineBooleanCubeDeterminant_fderiv_norm_le + (c : B → ℝ) (sets : O → Finset α) (block : O → B) + (v : Fin h) (sel : O → Option α) (hcard : ∀ o, (sets o).card ≤ h) + (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ)) + (b : BlockParameter B (Fin h) α → ℝ) (hL : ‖L‖ ≤ 1) + {C : ℝ} (hC : 0 ≤ C) (hc : ∀ o, |c (block o)| ≤ C) + (x : (B × Fin h) → Option α → ℝ) + (hx : ∀ z, |(b + L (blockCubeFlatten B (Fin h) α x)) z| ≤ 1) : + ‖fderiv ℝ (affineBooleanCubeDeterminant c sets block v sel L b) x‖ ≤ + productMinorDeterminantDerivativeBound (Fintype.card (BlockParameter B (Fin h) α)) + (Fintype.card O) (Fintype.card α) h C 1 := by + let e := (blockCubeFlatten B (Fin h) α).toContinuousLinearMap + have hLe : ‖L.comp e‖ ≤ 1 := by + apply (ContinuousLinearMap.opNorm_comp_le L e).trans + exact (mul_le_mul hL (blockCubeFlatten_norm_le_one B (Fin h) α) + (norm_nonneg _) zero_le_one).trans_eq (one_mul 1) + have hF := (booleanMinorDeterminant_contDiff c sets block v sel).differentiable (by norm_num) + have hd := affineSlice_fderiv (booleanMinorDeterminant c sets block v sel) b (L.comp e) x + (hF (b + (L.comp e) x)) + change fderiv ℝ (affineBooleanCubeDeterminant c sets block v sel L b) x = _ at hd + rw [hd] + exact ((ContinuousLinearMap.opNorm_comp_le _ _).trans + (mul_le_of_le_one_right (norm_nonneg _) hLe)).trans + (booleanMinorDeterminant_fderiv_norm_le c sets block v sel hcard _ hC le_rfl hc hx) + +theorem affineBooleanCubeGoodWeight_derivative_budget + (c : J → B → ℝ) (sets : O → Finset α) (block : J → O → B) + (v : Fin h) (sel : J → O → Option α) (hcard : ∀ o, (sets o).card ≤ h) + (L : (BlockParameter B (Fin h) α → ℝ) →L[ℝ] (BlockParameter B (Fin h) α → ℝ)) + (b : BlockParameter B (Fin h) α → ℝ) (hL : ‖L‖ ≤ 1) + (hbox : ∀ x ∈ scalarCubeProductDomain (B × Fin h) α, + ∀ z, |(b + L (blockCubeFlatten B (Fin h) α x)) z| ≤ 1) + (C : J → ℝ) (hC : ∀ j, 0 ≤ C j) (hc : ∀ j o, |c j (block j o)| ≤ C j) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (r : B × Fin h → ℝ) (hr : ∀ i, 0 < r i) (κ : J → ℝ) (hκ : ∀ j, 0 < κ j) : + (∑ z : BlockParameter B (Fin h) α, ∫ a, + |fderiv ℝ (affineBooleanCubeGoodWeight c sets block v sel L b ψ r κ) a (Pi.single z 1)|) ≤ + (∑ i, ((2 * 2 ^ Fintype.card α : ℕ) : ℝ) * ((Fintype.card α : ℝ) + 1) ^ 2 * T / r i) + + (Fintype.card (B × Fin h) : ℝ) * ((Fintype.card α : ℝ) + 1) * + (∑ j, (A : ℝ) / κ j * productMinorDeterminantDerivativeBound + (Fintype.card (BlockParameter B (Fin h) α)) (Fintype.card O) (Fintype.card α) h (C j) 1) := by + let d := fun j => affineBooleanCubeDeterminant (c j) sets (block j) v (sel j) L b + have hd := fun j => affineBooleanCubeDeterminant_contDiff (c j) sets (block j) v (sel j) L b + have hw : ContDiff ℝ 1 (scalarCubeGoodWeight α ψ r κ d) := + (scalarCubeProductWeight_spec (α := α) r hr).1.mul + ((sublevelCutoffProduct_smooth ψ hψ κ d hd).of_le (by norm_num)) + unfold affineBooleanCubeGoodWeight + rw [blockCubeWeight_derivative_sum _ hw] + let D : J → ℝ≥0 := fun j => ⟨productMinorDeterminantDerivativeBound + (Fintype.card (BlockParameter B (Fin h) α)) (Fintype.card O) (Fintype.card α) h (C j) 1, + productMinorDeterminantDerivativeBound_nonneg _ _ _ _ (hC j) zero_le_one⟩ + exact scalarCubeGoodWeight_derivative_budget ψ hψ hrange A T hLip hTransition r hr κ hκ d hd D + (fun j x hx => affineBooleanCubeDeterminant_fderiv_norm_le (c j) sets (block j) v (sel j) + hcard L b hL (hC j) (hc j) x (hbox x hx)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators ContDiff + +theorem exists_affine_cube_good_mass {B O J α : Type*} + [Fintype B] [Fintype O] [Fintype J] [Fintype α] + [DecidableEq B] [DecidableEq O] [DecidableEq α] + (c : J → B → ℝ) (sets : O → Finset α) (hsets : Function.Injective sets) + (h : ℕ) (hh : 0 < h) (hcard : ∀ o, (sets o).card ≤ h) + (block : J → O → B) (hblock : ∀ j, Function.Injective (block j)) + {N : ℕ} (e : BlockParameter O (Fin h) α ≃ Fin N) (hN : 0 < N) + (d : ℕ) (hd : 0 < d) (hdeg : Fintype.card O * (h - 1) ≤ d) + {c₀ : ℝ} (hc₀ : 0 < c₀) (hc : ∀ j o, c₀ ≤ |c j (block j o)|) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hone : ∀ t, 2 ≤ |t| → ψ t = 1) : + ∃ sel : J → O → Option α, ∀ δ η : ℝ, 0 < δ → 0 < η → + ∀ (center width : BlockParameter B (Fin h) α → ℝ) (hw : ∀ z, width z ≠ 0), + (∀ j z, δ ≤ |restrictBlockParameters (block j) width z|) → + (∀ j z, |restrictBlockParameters (block j) center z| + + |restrictBlockParameters (block j) width z| ≤ 1) → + 1 - η ≤ ∫ a, affineBooleanCubeGoodWeight c sets block (⟨0, hh⟩ : Fin h) sel + (coordinateScaleEquiv width hw).toContinuousLinearEquiv.toContinuousLinearMap center ψ + (fun _ => scalarCubeProductBoundaryRadius (B × Fin h) α (η / 2)) + (fun _ => affineCubeMinorThreshold J O α h N d c₀ δ η) a := by + obtain ⟨sel, hs⟩ := exists_affine_cube_minor_thresholds c sets hsets h hh hcard + block hblock e hN d hd hdeg hc₀ hc + refine ⟨sel, ?_⟩ + intro δ η hδ hη center width hw hwidth hbox + let κ := affineCubeMinorThreshold J O α h N d c₀ δ η + have hκ : 0 < κ := affineCubeMinorThreshold_pos J O α h hN d hc₀ hδ hη + have hr := scalarCubeProductBoundaryRadius_pos (B × Fin h) α (half_pos hη) + have hm := affineBooleanCubeGoodWeight_mass_lower c sets block (⟨0, hh⟩ : Fin h) sel + (coordinateScaleEquiv width hw).toContinuousLinearEquiv.toContinuousLinearMap center ψ + (fun _ => scalarCubeProductBoundaryRadius (B × Fin h) α (η / 2)) (fun _ => κ) + hψ hrange hone (fun _ => hr) (fun _ => hκ) + have hp := hs δ η hδ hη center width hwidth hbox + have he (a : BlockParameter B (Fin h) α → ℝ) : + center + (coordinateScaleEquiv width hw).toContinuousLinearEquiv.toContinuousLinearMap a = + fun z => center z + width z * a z := rfl + simp only [he] at hm + have hb := scalarCubeProductBoundaryRadius_loss (B × Fin h) α (half_pos hη) + linarith only [hm, hp, hb] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePlateauSite.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePlateauSite.lean new file mode 100644 index 0000000000000000000000000000000000000000..31423695b27341d06fc82c0b06ac6d25e995a02f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePlateauSite.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Progressions.Estimates.WeightedPlateauSiteApproximation + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {B α T : Type*} [Fintype B] [DecidableEq B] [Fintype α] [DecidableEq α] +variable {n K M : ℕ} [NeZero M] +variable (s : B → Fin (n + 1) → NormalizedScalarCubeSource α) +variable (u : B → Fin (n + 1) → Option α → ℤ) (v : B → Fin (n + 1) → Option α → ℕ) + +noncomputable def affineCubePlateauCoefficient (K M : ℕ) (rows : Finset (Finset α)) + (k : rows → Fin M) : ℂ := + ((K : ℂ) / M) ^ rows.card * ∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k + +omit [NeZero M] [DecidableEq B] in +theorem affineCubePlateauCoefficient_sum_le (rows : Finset (Finset α)) + (F : Finset (rows → Fin M)) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ} + (hcap : (∑ k, ‖∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k‖) ≤ C) : + (∑ k : F, ‖affineCubePlateauCoefficient s u v K M rows k‖) ≤ C := by + rw [← Finset.sum_subtype F (fun _ => Iff.rfl) + (fun k => ‖affineCubePlateauCoefficient s u v K M rows k‖)] + simp only [affineCubePlateauCoefficient, norm_mul, norm_pow, norm_div, + Complex.norm_natCast, ← Finset.mul_sum] + have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap + apply (mul_le_mul_of_nonneg_left + ((Finset.sum_le_univ_sum_of_nonneg (fun _ => norm_nonneg _)).trans hcap) (by positivity)).trans + exact mul_le_of_le_one_left hC hscale + +variable [Countable T] [MeasurableSpace T] [MeasurableSingletonClass T] + +theorem affineCubePlateauMixture_model + (p : PMF T) (hK : 0 < K) (H : ℝ) (rows : Finset (Finset α)) + (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) + (shift : T → rows → ℤ) (z : rows → ℤ) : + (∫ zeta, affineCubePlateauApproximation s u v K H rows (shift zeta) z F ∂p.toMeasure) = + finiteResidueModeModel (fun k : F => D k) (fun k => a k) + (fun k => affineCubePlateauCoefficient s u v K M rows k) + (fun k => plateauModeMixture p H (D k) K (a k) (ω k) shift) + (fun k => integerGridResidue (D k) z) (fun t => (z t : ℝ) / K) := by + rw [affineCubePlateauMixture_expansion s u v p hK H rows shift z F D a ω hfreq] + let term (k : rows → Fin M) := affineCubePlateauCoefficient s u v K M rows k * + (star (rationalGridPhase (D k) (a k) (integerGridResidue (D k) z)) * + plateauModeMixture p H (D k) K (a k) (ω k) shift (fun t => (z t : ℝ) / K)) + calc + _ = ∑ k ∈ F, term k := by + simp only [term, affineCubePlateauCoefficient, Finset.mul_sum, mul_assoc] + _ = ∑ k : F, term k := Finset.sum_subtype F (fun _ => Iff.rfl) term + _ = _ := rfl + +theorem exists_affineCube_plateau_site_approximation + (p : PMF T) (hK : 0 < K) (H : ℝ) (rows : Finset (Finset α)) + (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) + (shift : T → rows → ℤ) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ} + (hcap : (∑ k, ‖∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k‖) ≤ C) + (W : ℝ≥0) (hW : ∀ k ∈ F, ∀ t, |ω k t| ≤ W) + {R δ P : ℝ} (hR : 0 < R) (hδ : 0 < δ) (hP : 0 ≤ P) + (hRP : R ≤ Real.exp P) (hδP : (δ / (C + 1))⁻¹ ≤ Real.exp P) + (hLP : ((CircleFourier.characterLipConstant * (rows.card * W) + 4) * + (2 : ℝ≥0) ^ Fintype.card α : ℝ≥0) ≤ Real.exp P) : + ∃ N : F → ℕ, (∀ k, (N k : ℝ) ≤ Real.exp (4 * P + 8)) ∧ + (Fintype.card (PlateauSiteIndex α F N) : ℝ) ≤ + F.card * Real.exp (Fintype.card (Finset α) * (4 * P + 8)) ∧ + ∃ (β : PlateauSiteIndex α F N → ℂ) + (f : (k : PlateauSiteIndex α F N) → Finset α → ZMod (D k.1) → ℝ → ℂ), + (∑ k, ‖β k‖) ≤ C * Real.exp (Fintype.card (Finset α) * (4 * P + 8) + P) ∧ + (∀ k u r x, ‖f k u r x‖ ≤ 1) ∧ + (∀ k u r, LipschitzWith ⟨Real.exp (1 + 6 * P + 12), Real.exp_nonneg _⟩ (f k u r)) ∧ + ∀ y : Finset α → ℤ, (∀ u, |(y u : ℝ) / K| ≤ R) → + ‖(∫ zeta, affineCubePlateauApproximation s u v K H rows (shift zeta) + (fun t => booleanCoefficient y t) F ∂p.toMeasure) - + ∑ k, β k * ∏ u, f k u (y u : ZMod (D k.1)) ((y u : ℝ) / K)‖ ≤ δ := by + have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap + have htol : 0 < δ / (C + 1) := div_pos hδ (by positivity) + obtain ⟨N, hN, hcard, β, f, hβ, hf, hLf, he⟩ := + exists_integer_plateau_sum_site_approximation p H K rows (fun k : F => D k) + (fun k => a k) (fun k => ω k) shift + (fun k => affineCubePlateauCoefficient s u v K M rows k) + (affineCubePlateauCoefficient_sum_le s u v rows F hscale hcap) + W (fun k => hW k k.property) hR htol hP hRP hδP hLP + refine ⟨N, hN, ?_, β, f, hβ, hf, hLf, ?_⟩ + · simpa only [Fintype.card_coe] using hcard + · intro y hy + rw [affineCubePlateauMixture_model s u v p hK H rows F D a ω hfreq shift] + apply (he y hy).trans + rw [← mul_div_assoc] + apply (div_le_iff₀ (by positivity : 0 < C + 1)).mpr + nlinarith only [hC, hδ] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePositiveComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePositiveComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c915e76a6935420fd6fa4842f5b74803532779d2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubePositiveComparison.lean @@ -0,0 +1,361 @@ +import OAI.Combinatorics.Progressions.Fourier.SectionRetainedFourier +import OAI.Combinatorics.Progressions.Fourier.SiteFourierHaarMean + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_affine_cube_approximated_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (f g : (Option K × I → ℤ) → ℂ) {η : ℝ} (_hη : 0 ≤ η) + (_hf : ∀ z ∈ rectangularWeightIndices 0 V 1, + ‖f z - affineCubeFourierSum frequency p c (fun k j => (z (k, j) : ℝ))‖ ≤ η) + (_hg : ∀ z ∈ rectangularWeightIndices 0 V 1, + ‖affineCubeFourierProjection U root difference frequency p c (fun k j => (z (k, j) : ℝ)) - g z‖ ≤ η), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * f z)) - + (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * g z))‖ ≤ 2 * η + ε := by + obtain ⟨A, hA, hprojection⟩ := exists_affine_cube_fourier_projection m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound c B hB hBP hcoefficients p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth f g η hη hf hg + obtain ⟨hZ, hproj⟩ := hprojection hP hn hd U root difference hlin hL hC hLP hCP hsite + frequency hbound c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth + refine ⟨hZ, ?_⟩ + exact selectedResidueSmoothPMF_projection_approximation stride G V hV hZ + (fun z => layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))) + f (fun z => affineCubeFourierSum frequency p c (fun k j => (z (k, j) : ℝ))) + (fun z => affineCubeFourierProjection U root difference frequency p c (fun k j => (z (k, j) : ℝ))) + g hη (fun z _ => layeredSiteWeight_norm_le Q _ test htest _) hf hg hproj + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped Classical + +theorem affineCubeModeFactors_iff_bounded {K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : + affineCubeModeFactors U root difference frequency ↔ + ∀ j, ∃ M : (Finset (Fin q) → U j) →ₗ[ℝ] ℝ, + ∀ p : VectorPolynomial K ℝ (U j), DegreeLE (1 : K → ℕ) (j.val + 1) p → + coefficientFunctional (fun d a => (frequency j d a : ℝ)) (map (U j).subtype p) = + M (VectorPolynomial.siteEvaluation (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p) := by + constructor + · exact affineCubeModeFactors_bounded U root difference frequency + · intro h j + obtain ⟨M, hM⟩ := h j + refine ⟨M, ?_⟩ + let L := (coefficientFunctional (fun d a => (frequency j d a : ℝ))).comp (map (U j).subtype) + have hh := (homogeneous_site_factorization_iff (j.val + 1) + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) L M).mpr hM + change ∀ p, Homogeneous (j.val + 1) p → affineModeLift L p = _ at hh + have he : (fun s (k : Option K) => k.elim (1 : ℝ) + (fun k => ((affineSite root difference s (some k) : ℤ) : ℝ))) = + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) := by + funext s k + cases k <;> simp [affineSite, Int.cast_sum] + simpa only [L, affineModeLift_comp_map, LinearMap.comp_apply, he] using hh + +theorem exists_affine_cube_residual {K : Type*} [Fintype K] (m q : ℕ) + (root : K → ℤ) (difference : Fin q → K → ℤ) {H : ℕ} (hH : 1 ≤ H) + (hsite : ∀ (s : Finset (Fin q)) k, (affineSite root difference s (some k)).natAbs ≤ H) : + ∃ (d : Fin m → ℕ) + (T : ∀ j : Fin m, Matrix (BoundedCoefficientExponent K (j.val + 1)) (Finset (Fin q)) ℤ), + (∀ j, 0 < d j) ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)), + let R := coefficientSiteResidual U (fun s k => affineSite root difference s (some k)) d T + (∀ x ∈ coefficientIntegerLattice U, R x ∈ coefficientIntegerLattice U) ∧ + ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ, + (coefficientArrayFunctional U frequency).comp R = 0 ↔ + affineCubeModeFactors U root difference frequency := by + let site := fun s k => affineSite root difference s (some k) + have hex (j : Fin m) := exists_integer_site_residual (boundedSiteMatrix (j.val + 1) site) + (Nat.one_le_pow _ _ hH) (boundedSiteMatrix_height (j.val + 1) site hH hsite) + choose d T hd hT _hbound using hex + refine ⟨d, T, hd, ?_⟩ + intro J _ U + refine ⟨coefficientSiteResidual_preserves_lattice U site d T, ?_⟩ + intro frequency + rw [coefficientSiteResidual_zero_iff U site d T hd (fun j x => hT j x), + affineCubeModeFactors_iff_bounded] + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators Classical + +variable {K : Type*} [Fintype K] {m q : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (R : CoefficientArray (K := K) U →ₗ[ℝ] CoefficientArray (K := K) U) + (hR : ∀ x ∈ coefficientIntegerLattice U, R x ∈ coefficientIntegerLattice U) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + +theorem coefficientResidual_section_integrable + {W : Type*} [NormedAddCommGroup W] [NormedSpace ℝ W] + (μ : Measure (CoefficientTorus (K := K) U)) [IsFiniteMeasure μ] + (f : CoefficientTorus (K := K) U → W) (hf : Continuous f) + {B : ℝ} (hB : ∀ x, ‖f x‖ ≤ B) (x : CoefficientTorus (K := K) U) : + Integrable (fun y => f (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y)) μ := by + have hc := linearQuotientEndomorphism_continuous (coefficientIntegerLattice U) R hR + R.continuous_of_finiteDimensional + exact Integrable.of_bound (hf.comp (continuous_const.add hc)).aestronglyMeasurable B + (ae_of_all μ (fun _ => hB _)) + +theorem coefficientResidualAverage_continuous + {W : Type*} [NormedAddCommGroup W] [NormedSpace ℝ W] + (μ : Measure (CoefficientTorus (K := K) U)) [IsFiniteMeasure μ] + (f : CoefficientTorus (K := K) U → W) (hf : Continuous f) + {B : ℝ} (hB : ∀ x, ‖f x‖ ≤ B) : + Continuous (linearQuotientAverage (coefficientIntegerLattice U) R hR μ f) := by + apply continuous_of_dominated + (fun x => (coefficientResidual_section_integrable U R hR μ f hf hB x).aestronglyMeasurable) + (fun _ => ae_of_all μ (fun _ => hB _)) (integrable_const B) + exact ae_of_all μ (fun _ => hf.comp (continuous_id.add continuous_const)) + +theorem coefficientTorusFourierSum_residualAverage {F : Type*} [Fintype F] + (root : K → ℤ) (difference : Fin q → K → ℤ) + (hfactor : ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ, + (coefficientArrayFunctional U frequency).comp R = 0 ↔ affineCubeModeFactors U root difference frequency) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (x : CoefficientTorus (K := K) U) : + linearQuotientAverage (coefficientIntegerLattice U) R hR μ (coefficientTorusFourierSum U frequency c) x = + ∑ a, if affineCubeModeFactors U root difference (frequency a) then + c a * coefficientTorusCharacter U (frequency a) x else 0 := by + have hi (a : F) := coefficientResidual_section_integrable U R hR μ + (coefficientTorusCharacter U (frequency a)) + (quotientLinearCharacter_continuous _ _ _ (coefficientArrayFunctional U (frequency a)).continuous_of_finiteDimensional) + (fun x => (quotientLinearCharacter_norm _ _ _ x).le) x + change (∫ y, ∑ a, c a * coefficientTorusCharacter U (frequency a) + (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y) ∂μ) = _ + rw [integral_finsetSum _ (fun a _ => (hi a).const_mul (c a))] + simp only [integral_const_mul] + change (∑ a, c a * linearQuotientAverage (coefficientIntegerLattice U) R hR μ + (quotientLinearCharacter (coefficientIntegerLattice U) (coefficientArrayFunctional U (frequency a)) + (coefficientArrayFunctional_integral U (frequency a))) x) = _ + simp only [linearQuotientAverage_character, hfactor, mul_ite, mul_zero] + rfl + +theorem affineCubeFourierProjection_eq_residualAverage {I F : Type*} [Fintype F] + (root : K → ℤ) (difference : Fin q → K → ℤ) + (hfactor : ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ, + (coefficientArrayFunctional U frequency).comp R = 0 ↔ affineCubeModeFactors U root difference frequency) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (b : Option K → I → ℝ) : + affineCubeFourierProjection U root difference frequency p c b = + linearQuotientAverage (coefficientIntegerLattice U) R hR μ (coefficientTorusFourierSum U frequency c) + (affineSampleCoefficientTorus U p hm b) := by + rw [coefficientTorusFourierSum_residualAverage U R hR root difference hfactor] + simp only [coefficientTorusCharacter_sample U _ p hp hm b, affineCubeFourierProjection] + +theorem coefficientTorusFourierProjection_approx_residualAverage {F : Type*} [Fintype F] + (root : K → ℤ) (difference : Fin q → K → ℤ) + (hfactor : ∀ frequency : ∀ j, (K →₀ ℕ) → J j → ℤ, + (coefficientArrayFunctional U frequency).comp R = 0 ↔ affineCubeModeFactors U root difference frequency) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ) {η : ℝ} + (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) + (x : CoefficientTorus (K := K) U) + (hD : Integrable (fun y => D (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y)) μ) : + ‖(∑ a, if affineCubeModeFactors U root difference (frequency a) then + c a * coefficientTorusCharacter U (frequency a) x else 0) - + ((linearQuotientAverage (coefficientIntegerLattice U) R hR μ D x : ℝ) : ℂ)‖ ≤ η := by + rw [← coefficientTorusFourierSum_residualAverage U R hR root difference hfactor frequency c μ x] + have hi : Integrable (fun y => coefficientTorusFourierSum U frequency c + (x + linearQuotientEndomorphism (coefficientIntegerLattice U) R hR y)) μ := by + apply integrable_finsetSum + intro a _ + apply Integrable.const_mul + exact coefficientResidual_section_integrable U R hR μ (coefficientTorusCharacter U (frequency a)) + (quotientLinearCharacter_continuous _ _ _ (coefficientArrayFunctional U (frequency a)).continuous_of_finiteDimensional) + (fun x => (quotientLinearCharacter_norm _ _ _ x).le) x + have he := linearQuotientAverage_approx (coefficientIntegerLattice U) R hR μ + (coefficientTorusFourierSum U frequency c) (fun x => (D x : ℂ)) happrox x hi hD.ofReal + simpa only [linearQuotientAverage, integral_complex_ofReal] using he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators Classical + +theorem exists_affine_cube_positive_density {K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (difference : Fin q → K → ℤ) {H : ℕ} (hH : 1 ≤ H) + (hsite : ∀ (s : Finset (Fin q)) k, (affineSite root difference s (some k)).natAbs ≤ H) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ) (hD : Continuous D) {B : ℝ} + (hcap : ∀ x, D x ∈ Set.Icc (0 : ℝ) B) (hmass : (∫ x, D x ∂μ) = 1) : + ∃ g : CoefficientTorus (K := K) U → ℝ, + Continuous g ∧ (∀ x, g x ∈ Set.Icc (0 : ℝ) B) ∧ Integrable g μ ∧ (∫ x, g x ∂μ) = 1 ∧ + ∀ {F : Type*} [Fintype F] (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + {η : ℝ}, (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) → + ∀ x, ‖(∑ a, if affineCubeModeFactors U root difference (frequency a) then + c a * coefficientTorusCharacter U (frequency a) x else 0) - (g x : ℂ)‖ ≤ η := by + obtain ⟨d, T, _, hR⟩ := exists_affine_cube_residual m q root difference hH hsite + obtain ⟨hlattice, hfactor⟩ := hR U + let R := coefficientSiteResidual U (fun s k => affineSite root difference s (some k)) d T + let g := linearQuotientAverage (coefficientIntegerLattice U) R hlattice μ D + have hRm := (linearQuotientEndomorphism_continuous (coefficientIntegerLattice U) R hlattice + R.continuous_of_finiteDimensional).measurable + have hb (x) : ‖D x‖ ≤ B := by rw [Real.norm_of_nonneg (hcap x).1]; exact (hcap x).2 + have hi : Integrable D μ := Integrable.of_bound hD.aestronglyMeasurable B (ae_of_all μ hb) + have hp := linearQuotientAverage_probability (coefficientIntegerLattice U) R hlattice μ hRm D + hD.measurable hi (fun x => (hcap x).1) hmass + refine ⟨g, ?_, ?_, hp.2.1, hp.2.2, ?_⟩ + · exact coefficientResidualAverage_continuous U R hlattice μ D hD hb + · intro x + refine ⟨hp.1 x, ?_⟩ + have h := linearQuotientAverage_bound (coefficientIntegerLattice U) R hlattice μ D hb x + rwa [Real.norm_of_nonneg (hp.1 x)] at h + · intro F _ frequency c η happrox x + exact coefficientTorusFourierProjection_approx_residualAverage U R hlattice root difference hfactor + frequency c μ D happrox x (coefficientResidual_section_integrable U R hlattice μ D hD hb x) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators Classical + +theorem exists_affine_cube_positive_comparison (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ) (_hD : Continuous D) {B₀ η : ℝ} + (_hcap : ∀ x, D x ∈ Set.Icc (0 : ℝ) B₀) (_hmass : (∫ x, D x ∂μ) = 1) (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η), + ∃ g : CoefficientTorus (K := K) U → ℝ, + Continuous g ∧ (∀ x, g x ∈ Set.Icc (0 : ℝ) B₀) ∧ Integrable g μ ∧ (∫ x, g x ∂μ) = 1 ∧ + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + (D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ))) - + (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + (g (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ)))‖ ≤ 2 * η + ε := by + obtain ⟨A, hA, hprojection⟩ := exists_affine_cube_approximated_projection m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U root difference hlin L C hL hC hLP hCP hsite + frequency hbound c B hB hBP hcoefficients p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth _ _ μ _ _ D hD B₀ η hcap hmass hη happrox + let H₀ := max 1 (Finset.univ.sup (fun sk : Finset (Fin q) × K => + (affineSite root difference sk.1 (some sk.2)).natAbs)) + have hH₀ : 1 ≤ H₀ := le_max_left _ _ + have hsite₀ (s : Finset (Fin q)) (k : K) : (affineSite root difference s (some k)).natAbs ≤ H₀ := + (Finset.le_sup (f := fun sk : Finset (Fin q) × K => + (affineSite root difference sk.1 (some sk.2)).natAbs) (Finset.mem_univ (s, k))).trans (le_max_right _ _) + obtain ⟨g, hgm, hgc, hgi, hgmass, hg⟩ := + exists_affine_cube_positive_density U root difference hH₀ hsite₀ μ D hD hcap hmass + refine ⟨g, hgm, hgc, hgi, hgmass, ?_⟩ + apply hprojection hP hn hd U root difference hlin hL hC hLP hCP hsite frequency hbound c + hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR + Q hQ test htest G hG V hV hwidth + (fun z => (D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ)) + (fun z => (g (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) : ℂ)) hη + · intro z _ + have h := happrox (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) + simpa only [coefficientTorusFourierSum, coefficientTorusCharacter_sample U _ p hp hm, + affineCubeFourierSum, norm_sub_rev] using h + · intro z _ + have h := hg frequency c happrox (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))) + simpa only [coefficientTorusCharacter_sample U _ p hp hm, affineCubeFourierProjection] using h + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeUniformRemoval.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeUniformRemoval.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f69d27e3a70d057864679ee8b329a597f3d2d5b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineCubeUniformRemoval.lean @@ -0,0 +1,222 @@ +import OAI.Combinatorics.Progressions.Dynamics.CubeModeUniformBudget + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators NNReal + +theorem affine_cube_removal_of_widths {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (hH : ∀ k, 0 < H k) + (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : layerRemovalRankBudget m (Fintype.card I) C (cubeModePolynomialBudget q L) + (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (hV1 : ∀ z, 1 ≤ V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) + (hmove : (m : ℝ) * cubeModePolynomialBudget q L ≤ r * ρ * T) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((smoothProductPMF V hV z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + let B := finiteLayerBiasBudget m ζ + let D := cubeModePolynomialBudget q L + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ + have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le + have hA : 0 ≤ 2 * T := by positivity + have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B := + multiaffineBiasBudget_le_finite i hζ + obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth + have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD + (zero_le_one.trans hB) hA hS + apply affine_cube_mode_smooth_removal U root difference hlin hL hC hsite frequency hbound hbad + p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank + (fun i => (hbud i).1.trans hR) _ _ Q hQ test htest V hV hV1 hδ hδ1 hmesh hsmall hr _ hβ hpower + · intro i + have hi := tensorDenominatorBound_le (H := Fin (i.val + 1)) + (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ)) + (fun k => Nat.cast_nonneg _) hstride + have hi' : (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ + (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by + simpa only [Fintype.card_fin] using hi + apply hi'.trans + apply le_trans _ ((hbud i).2.1.trans hR) + exact pow_le_pow_left₀ + (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _)) + (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _ + · intro i + apply le_trans _ ((hbud i).2.2.trans hR) + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _)) + (pow_nonneg (Nat.cast_nonneg _) _) + · intro i z + have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt + apply le_trans _ (hshift z) + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hi hD) + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem affine_cube_removal_at_error {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (hsize : ∀ k, modeRemovalSideThreshold m (Fintype.card (Option K × I)) + (cubeModePolynomialBudget q L) S ρ ε ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : modeRemovalRankThreshold m (Fintype.card I) (Fintype.card (Option K × I)) + C (cubeModePolynomialBudget q L) S ρ ε ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) : + ‖∑' z : Option K × I → ℤ, ((smoothProductPMF V hV z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ ε := by + classical + let d := Fintype.card (Option K × I) + let D := cubeModePolynomialBudget q L + let T := modeRemovalShrink m d D ρ ε + let B := finiteLayerBiasBudget m (modeRemovalBias m ε) + have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le + have hT : 0 < T := lt_of_lt_of_le zero_lt_one (modeRemovalShrink_one_le m d hD hρ hε) + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m (modeRemovalBias_pos m hε) + have hside := modeRemovalSideThreshold_bounds m d hD hS hρ hε + have hH k : 0 < H k := hside.1.trans_le (hsize k) + have hsize' k : (stride k : ℝ) * T * (B + 1) ≤ H k := by + calc + _ ≤ S * T * (B + 1) := by gcongr; exact hstride k + _ ≤ H k := hside.2.1.trans (hsize k) + have hv z : 1 ≤ V z ∧ 1 / V z ≤ modeRemovalMesh d := by + apply modeRemovalMesh_of_width d (hV z) + exact (hside.2.2.trans (mul_le_mul_of_nonneg_left (hsize z.2) hρ.le)).trans (hwidth z) + have hout := affine_cube_removal_of_widths U root difference hlin hL hC hsite frequency hbound hbad + p hp hm stride hs (modeRemovalBias_pos m hε) hT hS hstride H hH hsize' hrank hR + Q hQ test htest V hV (fun z => (hv z).1) (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) + (fun z => (hv z).2) (modeRemovalMesh_small d) hρ (modeRemovalRadius_pos d hε).le hwidth + (modeRemovalShrink_move m d hρ hε) (modeRemovalBeta_pos hε).le (fun i => modeRemovalBias_le i hε) + exact hout.trans (modeRemovalError_bound d hε) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_affine_cube_uniform_removal (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ‖∑' z : Option K × I → ℤ, ((smoothProductPMF V hV z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hbudget⟩ := exists_cube_mode_threshold_exp_budget m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ P hP hn hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest V hV hwidth + obtain ⟨hside, hrankBudget⟩ := hbudget (Fintype.card I) (Fintype.card (Option K × I)) + P C L S ρ ε hP hn hd hC hCP hL hLP hS hSP hρ hρP hε hεP + exact affine_cube_removal_at_error U root difference hlin hL hC hsite frequency hbound hbad + p hp hm stride hs hS hρ hε hstride H (fun k => hside.trans (hsize k)) hrank + (hrankBudget.trans hR) Q hQ test htest V hV hwidth + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineIntervalNormalizedBounds.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineIntervalNormalizedBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e4600f98a447b65ca69a9f558ee0c465ecc3e42 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineIntervalNormalizedBounds.lean @@ -0,0 +1,42 @@ +import Mathlib.Algebra.Order.Field.Basic +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +theorem affineInterval_normalized_bounds + {L H step : ℕ} {start : ℤ} + (hL : 0 < L) (hH : 2 ≤ H) (hstep : 0 < step) + (hinside : ∀ t : Fin H, 0 ≤ start + step * (t.val : ℤ) ∧ + start + step * (t.val : ℤ) < L) : + 0 ≤ (start : ℝ) / L ∧ + 0 < (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L ∧ + (start : ℝ) / L + (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L < 1 ∧ + (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L ≤ 1 := by + have hHpos : 0 < H := by omega + have hlast : H - 1 < H := Nat.sub_lt hHpos (by norm_num) + have hstartZ : 0 ≤ start := by + simpa only [Nat.cast_zero, mul_zero, add_zero] using (hinside ⟨0, hHpos⟩).1 + have hendZ := (hinside ⟨H - 1, hlast⟩).2 + have hstart : (0 : ℝ) ≤ start := by exact_mod_cast hstartZ + have hend : (start : ℝ) + (step : ℝ) * ((H - 1 : ℕ) : ℝ) < L := by + exact_mod_cast hendZ + have hLreal : (0 : ℝ) < L := by exact_mod_cast hL + have hstepreal : (0 : ℝ) < step := by exact_mod_cast hstep + have hHreal : (0 : ℝ) < ((H - 1 : ℕ) : ℝ) := by + exact_mod_cast (show 0 < H - 1 by omega) + have hlower := div_nonneg hstart hLreal.le + have hwidth := div_pos (mul_pos hstepreal hHreal) hLreal + have hsum : (start : ℝ) / L + (step : ℝ) * ((H - 1 : ℕ) : ℝ) / L < 1 := by + rw [← add_div] + exact (div_lt_one hLreal).mpr hend + exact ⟨hlower, hwidth, hsum, by linarith⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelEndpointGeometry.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelEndpointGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..8dfc9fba814643facf00881b1d9ded3fbd1f07d2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelEndpointGeometry.lean @@ -0,0 +1,151 @@ +import OAI.Combinatorics.Progressions.Estimates.DenseProgressionInnerFamily +import OAI.Combinatorics.Progressions.Estimates.JointCoefficientRetainedTest + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +variable {J I : Type*} [Fintype J] [Fintype I] + +def affineCubeTuple (lower width : J → ℝ) (x : J → Option I → ℝ) : J → Option I → ℝ := + fun j i => (if i = none then lower j else 0) + width j * x j i + +theorem affineCubeTuple_lipschitz (lower width : J → ℝ) (K : ℝ≥0) + (hw : ∀ j, |width j| ≤ K) : LipschitzWith K (affineCubeTuple (I := I) lower width) := by + apply LipschitzWith.of_dist_le_mul + intro x y + apply (dist_pi_le_iff (mul_nonneg K.coe_nonneg dist_nonneg)).mpr + intro j + apply (dist_pi_le_iff (mul_nonneg K.coe_nonneg dist_nonneg)).mpr + intro i + simp only [affineCubeTuple, dist_add_left, Real.dist_eq, ← mul_sub, abs_mul] + simpa only [Real.dist_eq] using mul_le_mul (hw j) + ((dist_le_pi_dist (x j) (y j) i).trans (dist_le_pi_dist x y j)) + dist_nonneg K.coe_nonneg + +theorem affineCubeTuple_width_dist (lower w v : J → ℝ) {ε : ℝ} (hε : 0 ≤ ε) + (hw : ∀ j, |w j - v j| ≤ ε) (x : J → Option I → ℝ) (hx : ‖x‖ ≤ 1) : + dist (affineCubeTuple lower w x) (affineCubeTuple lower v x) ≤ ε := by + apply (dist_pi_le_iff hε).mpr + intro j + apply (dist_pi_le_iff hε).mpr + intro i + have hxj : |x j i| ≤ 1 := by + exact (norm_le_pi_norm (x j) i).trans ((norm_le_pi_norm x j).trans hx) + simp only [affineCubeTuple, dist_add_left, Real.dist_eq, ← sub_mul, abs_mul] + exact (mul_le_mul (hw j) hxj (abs_nonneg _) hε).trans_eq (mul_one _) + +theorem affineCubeTuple_integral_width_error [DecidableEq I] + (lower w v : J → ℝ) {ε : ℝ} (hε : 0 ≤ ε) (hw : ∀ j, |w j - v j| ≤ ε) + (φ : (J → Option I → ℝ) → ℝ) {K : ℝ≥0} {A : ℝ} + (hφ : LipschitzWith K φ) (_hA : 0 ≤ A) (hb : ∀ x, ‖φ x‖ ≤ A) : + |(∫ x, φ (affineCubeTuple lower w x) ∂scalarCubeProductMeasure J I) - + ∫ x, φ (affineCubeTuple lower v x) ∂scalarCubeProductMeasure J I| ≤ K * ε := by + have hm (v : J → ℝ) : Measurable (affineCubeTuple (I := I) lower v) := by + unfold affineCubeTuple + fun_prop + have hi (v : J → ℝ) : Integrable (fun x => φ (affineCubeTuple lower v x)) (scalarCubeProductMeasure J I) := + Integrable.mono' (integrable_const A) (hφ.continuous.measurable.comp (hm v)).aestronglyMeasurable + (Filter.Eventually.of_forall (fun x => hb _)) + rw [← integral_sub (hi w) (hi v)] + have he : ∀ᵐ x ∂scalarCubeProductMeasure J I, + ‖φ (affineCubeTuple lower w x) - φ (affineCubeTuple lower v x)‖ ≤ K * ε := by + filter_upwards [scalarCubeProductMeasure_ae_closedBall J I] with x hx + rw [Metric.mem_closedBall, dist_zero_right] at hx + rw [← dist_eq_norm] + exact (hφ.dist_le_mul _ _).trans + (mul_le_mul_of_nonneg_left (affineCubeTuple_width_dist lower w v hε hw x hx) K.coe_nonneg) + have ht := norm_integral_le_of_norm_le (integrable_const ((K : ℝ) * ε) (μ := scalarCubeProductMeasure J I)) he + simpa only [Real.norm_eq_abs, integral_const, probReal_univ, one_smul] using ht + +theorem affineCubeTuple_residue_riemann [DecidableEq J] [DecidableEq I] + (H M : J → ℕ) (hH : ∀ j, 0 < H j) (modulus : J → Option I → ℕ) + (residue : ∀ j i, ZMod (modulus j i)) + (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j) + (hsize : ∀ j, (Fintype.card I + 1) * M j ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant I * ((M j : ℝ) / H j) < volume.real (scalarCubeDomain I)) + (lower w v : J → ℝ) (W : ℝ≥0) (hw : ∀ j, |w j| ≤ W) + {ε : ℝ} (hε : 0 ≤ ε) (hwidth : ∀ j, |w j - v j| ≤ ε) + (φ : (J → Option I → ℝ) → ℝ) {K : ℝ≥0} {A : ℝ} + (hφ : LipschitzWith K φ) (hA : 0 ≤ A) (hb : ∀ x, ‖φ x‖ ≤ A) : + |(FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights I (H j) (M j) (hH j) + (modulus j) (residue j) (hm j) (hmM j) (hsize j))).mean + (fun z => φ (affineCubeTuple lower w (fun j i => (z j i : ℝ) / H j))) - + ∫ x, φ (affineCubeTuple lower v x) ∂scalarCubeProductMeasure J I| ≤ + (2 * A * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + K * W) * + ∑ j, (M j : ℝ) / H j + K * ε := by + have htest := hφ.comp (affineCubeTuple_lipschitz lower w W hw) + have he := scalarCubeResidueWeights_pi_riemann H M hH modulus residue hm hmM hsize hsmall + (φ ∘ affineCubeTuple lower w) htest hA (fun x => hb _) + have hi := affineCubeTuple_integral_width_error lower w v hε hwidth φ hφ hA hb + exact (abs_sub_le _ _ _).trans (add_le_add he hi) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators NNReal Classical +variable {G : Type*} [Fintype G] + +noncomputable def affineKernelContinuousPoint (lower : G → ℝ) (step S : ℝ) (H : G → ℕ) + (x : G → Option Empty → ℝ) : G → ℝ := + fun g => (lower g + step * ((H g - 1 : ℕ) : ℝ) * x g none) / S + +noncomputable def affineKernelDiscretePoint (lower : G → ℝ) (step S : ℝ) {H : G → ℕ} + (z : ∀ g, IntegerScalarCubeBox Empty (H g)) : G → ℝ := + fun g => (lower g + step * (z g none : ℝ)) / S + +theorem affineKernelContinuousPoint_lipschitz (lower : G → ℝ) (step S : ℝ) (H : G → ℕ) + (hS : 0 < S) (hstep : 0 ≤ step) + (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S) : + LipschitzWith 1 (affineKernelContinuousPoint lower step S H) := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro g + have hw0 : 0 ≤ step * ((H g - 1 : ℕ) : ℝ) := mul_nonneg hstep (Nat.cast_nonneg _) + have hw : step * ((H g - 1 : ℕ) : ℝ) / S ≤ 1 := (div_le_one hS).mpr (hspan g) + have hx : |x g none - y g none| ≤ dist x y := + (dist_le_pi_dist (x g) (y g) none).trans (dist_le_pi_dist x y g) + change |(lower g + step * ((H g - 1 : ℕ) : ℝ) * x g none) / S - + (lower g + step * ((H g - 1 : ℕ) : ℝ) * y g none) / S| ≤ _ + rw [← sub_div, add_sub_add_left_eq_sub, ← mul_sub, abs_div, abs_mul, + abs_of_nonneg hw0, abs_of_pos hS] + calc + _ = (step * ((H g - 1 : ℕ) : ℝ) / S) * |x g none - y g none| := by ring + _ ≤ 1 * dist x y := mul_le_mul hw hx (abs_nonneg _) zero_le_one + _ = _ := one_mul _ + +theorem affineKernelEndpoint_dist_le (lower : G → ℝ) (step S : ℝ) (H : G → ℕ) + (hH : ∀ g, 0 < H g) (hS : 0 < S) (hstep : 0 ≤ step) + (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S) + (z : ∀ g, IntegerScalarCubeBox Empty (H g)) + (hz : (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight z ≠ 0) : + dist (affineKernelDiscretePoint lower step S z) + (affineKernelContinuousPoint lower step S H (fun g i => (z g i : ℝ) / H g)) ≤ + ∑ g, (1 : ℝ) / H g := by + have hsum : 0 ≤ ∑ g, (1 : ℝ) / H g := Finset.sum_nonneg (fun g _ => by positivity) + apply (dist_pi_le_iff hsum).mpr + intro g + have hz' := integerScalarCubePi_root_real_bounds H hH z hz g + have he := affineKernelEndpoint_error_nat (lower g) (hH g) hS hz'.1 hz'.2 hstep (hspan g) + change |(lower g + step * (z g none : ℝ)) / S - + (lower g + step * ((H g - 1 : ℕ) : ℝ) * ((z g none : ℝ) / H g)) / S| ≤ _ + exact he.trans (Finset.single_le_sum (f := fun j => (1 : ℝ) / H j) + (fun j _ => by positivity) (Finset.mem_univ g)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelResidueRetained.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelResidueRetained.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cf8680ade42a4a22242dc5fefd19cb79c8a27dd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineKernelResidueRetained.lean @@ -0,0 +1,324 @@ +import Mathlib.MeasureTheory.Integral.Prod +import OAI.Combinatorics.Progressions.Lattices.OriginalKernelResidueRetained + +namespace OAI + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators Classical NNReal + +theorem originalKernel_residue_slow_quadrature_varying + {G : Type*} [Fintype G] [DecidableEq G] + (L : G → ℕ) (q : ℕ) [NeZero q] + (hL : ∀ g, 0 < L g) (hq : 0 < q) (hqL : ∀ g, q ≤ L g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / L g) < + volume.real (scalarCubeDomain Empty)) + (F : (G → ZMod q) → (G → Option Empty → ℝ) → ℂ) + {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r)) + (hbound : ∀ r x, ‖F r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun z => F (fun g => ((z g none : ℤ) : ZMod q)) + (fun g i => (z g i : ℝ) / L g)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K)) * + (∑ g, (q : ℝ) / L g) := by + let test := fun (r : G → ZMod q) (z : ∀ g, IntegerScalarCubeBox Empty (L g)) => + F r (fun g i => (z g i : ℝ) / L g) + let law := fun (r : G → ZMod q) => FiniteProbabilityWeights.pi + (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) (by simpa using hqL g)) + let e : ℝ := 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K) * (∑ g, (q : ℝ) / L g) + have hcond (r : G → ZMod q) : + ‖(law r).complexMean (test r) - ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by + simpa only [law, test, e, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] using + scalarCubeResidueWeights_pi_complex_riemann L (fun _ => q) hL + (fun (_ : G) (_ : Option Empty) => q) (fun g _ => r g) (fun _ _ => hq) + (fun _ _ => le_rfl) (fun g => by simpa using hqL g) + hsmall (F r) (hF r) zero_le_one (hbound r) + have hmix := integerScalarCubeWeights_empty_pi_uniform_residue_error_varying L q hL hq hqL + test (fun r z => hbound r _) + have havg : ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by + rw [← Finset.expect_sub_distrib] + apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun r _ => hcond r)).trans_eq (by simp) + calc + _ ≤ ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun z => test (fun g => ((z g none : ℤ) : ZMod q)) z) - + 𝔼 r : G → ZMod q, (law r).complexMean (test r)‖ + + ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ := + norm_sub_le_norm_sub_add_norm_sub _ _ _ + _ ≤ (∑ g, (q : ℝ) / L g) + e := add_le_add hmix havg + _ = _ := by dsimp only [e]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {G R : Type*} [Fintype G] [DecidableEq G] + +theorem affineKernel_residue_slow_quadrature + (H : G → ℕ) (q : ℕ) [NeZero q] (hH : ∀ g, 0 < H g) + (hq : 0 < q) (hqH : ∀ g, q ≤ H g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H g) < + volume.real (scalarCubeDomain Empty)) + (lower : G → ℝ) (step S : ℝ) (hS : 0 < S) (hstep : 0 ≤ step) + (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S) + (residueMap : (G → ZMod q) → R) (F : R → (G → ℝ) → ℂ) + {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r)) + (hbound : ∀ r x, ‖F r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun g => integerScalarCubeWeights Empty (H g) (hH g))).complexMean + (fun z => F (residueMap (fun g => ((z g none : ℤ) : ZMod q))) + (fun g => (lower g + step * (z g none : ℝ)) / S)) - + 𝔼 r : G → ZMod q, ∫ x, + F (residueMap r) (affineKernelContinuousPoint lower step S H x) + ∂scalarCubeProductMeasure G Empty‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K) + K) * ∑ g, (q : ℝ) / H g := by + let p := FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g)) + let test := fun r x => F (residueMap r) (affineKernelContinuousPoint lower step S H x) + have htest (r : G → ZMod q) : LipschitzWith K (test r) := by + simpa only [test, Function.comp_def, mul_one] using (hF (residueMap r)).comp + (affineKernelContinuousPoint_lipschitz lower step S H hS hstep hspan) + have hquad := originalKernel_residue_slow_quadrature_varying H q hH hq hqH + hsmall test htest (fun r x => hbound _ _) + have hsum : (∑ g, (1 : ℝ) / H g) ≤ ∑ g, (q : ℝ) / H g := by + apply Finset.sum_le_sum + intro g _ + exact div_le_div_of_nonneg_right (by exact_mod_cast hq) (by positivity) + have hpoint : + ‖p.complexMean (fun z => F (residueMap (fun g => ((z g none : ℤ) : ZMod q))) + (fun g => (lower g + step * (z g none : ℝ)) / S)) - + p.complexMean (fun z => test (fun g => ((z g none : ℤ) : ZMod q)) + (fun g i => (z g i : ℝ) / H g))‖ ≤ (K : ℝ) * ∑ g, (q : ℝ) / H g := by + apply (p.norm_complexMean_sub_le _ _ (fun _ => (K : ℝ) * ∑ g, (q : ℝ) / H g) ?_).trans_eq + (p.mean_const _) + intro z hz + rw [← dist_eq_norm] + exact ((hF _).dist_le_mul _ _).trans (mul_le_mul_of_nonneg_left + ((affineKernelEndpoint_dist_le lower step S H hH hS hstep hspan z hz).trans hsum) + K.coe_nonneg) + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans + ((add_le_add hpoint hquad).trans_eq (by ring)) + +theorem affineKernel_integer_residue_slow_quadrature + (H : G → ℕ) (q : ℕ) [NeZero q] (hH : ∀ g, 0 < H g) + (hq : 0 < q) (hqH : ∀ g, q ≤ H g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H g) < + volume.real (scalarCubeDomain Empty)) + (start : G → ℤ) (step : ℤ) (S : ℝ) (hS : 0 < S) (hstep : 0 ≤ step) + (hspan : ∀ g, (step : ℝ) * ((H g - 1 : ℕ) : ℝ) ≤ S) + (F : (G → ZMod q) → (G → ℝ) → ℂ) + {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r)) + (hbound : ∀ r x, ‖F r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun g => integerScalarCubeWeights Empty (H g) (hH g))).complexMean + (fun z => F (fun g => ((start g + step * (z g none : ℤ) : ℤ) : ZMod q)) + (fun g => ((start g + step * (z g none : ℤ) : ℤ) : ℝ) / S)) - + 𝔼 r : G → ZMod q, ∫ x, + F (fun g => (start g : ZMod q) + (step : ZMod q) * r g) + (fun g => ((start g : ℝ) + (step : ℝ) * ((H g - 1 : ℕ) : ℝ) * x g none) / S) + ∂scalarCubeProductMeasure G Empty‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K) + K) * ∑ g, (q : ℝ) / H g := by + have h := affineKernel_residue_slow_quadrature H q hH hq hqH hsmall + (fun g => (start g : ℝ)) (step : ℝ) S hS (by exact_mod_cast hstep) hspan + (fun r g => (start g : ZMod q) + (step : ZMod q) * r g) F hF hbound + simp only [Int.cast_add, Int.cast_mul] at ⊢ + convert h using 1 + rfl + +omit [Fintype G] [DecidableEq G] in + +theorem affineKernel_span_of_contained + (H : G → ℕ) (hH : ∀ g, 0 < H g) (start : G → ℤ) + (step S : ℕ) (hstep : 0 < step) + (hcontained : ∀ g, integerProgressionSupport (start g) (step : ℤ) (H g) ⊆ + Finset.Ico (0 : ℤ) (S : ℤ)) : + ∀ g, (step : ℝ) * ((H g - 1 : ℕ) : ℝ) ≤ S := by + intro g + have hfirst := hcontained g + (integerProgressionSupport_point (start g) step (H g) hstep 0 (hH g)) + have hlast := hcontained g + (integerProgressionSupport_point (start g) step (H g) hstep (H g - 1) (by + have := hH g + omega)) + have hc : (0 : ℤ) ≤ start g := by simpa using (Finset.mem_Ico.mp hfirst).1 + have he : start g + (step : ℤ) * ((H g - 1 : ℕ) : ℤ) < S := + (Finset.mem_Ico.mp hlast).2 + have hs : (step : ℤ) * ((H g - 1 : ℕ) : ℤ) ≤ S := by omega + exact_mod_cast hs + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +theorem originalKernel_residue_slow_retained_quadrature_varying + {G Z : Type*} [Fintype G] [DecidableEq G] [MeasurableSpace Z] + (μ : Measure Z) [IsProbabilityMeasure μ] + (L : G → ℕ) (q : ℕ) [NeZero q] (hL : ∀ g, 0 < L g) (hq : 0 < q) + (hqL : ∀ g, q ≤ L g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / L g) < + volume.real (scalarCubeDomain Empty)) + (F : Z → (G → ZMod q) → (G → Option Empty → ℝ) → ℂ) + (hMeas : ∀ r, Measurable (fun zx : Z × (G → Option Empty → ℝ) => F zx.1 r zx.2)) + {K : ℝ≥0} (hLip : ∀ z r, LipschitzWith K (F z r)) + (hbound : ∀ z r x, ‖F z r x‖ ≤ 1) : + ‖(∫ z, (FiniteProbabilityWeights.pi + (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun y => F z (fun g => ((y g none : ℤ) : ZMod q)) + (fun g i => (y g i : ℝ) / L g)) ∂μ) - + ∫ z, 𝔼 r : G → ZMod q, + ∫ x, F z r x ∂scalarCubeProductMeasure G Empty ∂μ‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K)) * + (∑ g, (q : ℝ) / L g) := by + let p := FiniteProbabilityWeights.pi + (fun g : G => integerScalarCubeWeights Empty (L g) (hL g)) + let a (z : Z) := p.complexMean + (fun y => F z (fun g => ((y g none : ℤ) : ZMod q)) + (fun g i => (y g i : ℝ) / L g)) + let b (z : Z) := 𝔼 r : G → ZMod q, + ∫ x, F z r x ∂scalarCubeProductMeasure G Empty + have haMeas : Measurable a := by + unfold a FiniteProbabilityWeights.complexMean + apply Finset.measurable_sum + intro y _ + exact measurable_const.mul ((hMeas _).comp (measurable_id.prodMk measurable_const)) + have haBound (z : Z) : ‖a z‖ ≤ 1 := by + apply (p.norm_complexMean_le_mean_norm _).trans + exact (p.mean_mono (fun y => hbound z _ _)).trans_eq (p.mean_const 1) + have haInt : Integrable a μ := + (integrable_const (1 : ℝ)).mono' haMeas.aestronglyMeasurable (ae_of_all μ haBound) + have hiMeas (r : G → ZMod q) : + StronglyMeasurable (fun z => ∫ x, F z r x ∂scalarCubeProductMeasure G Empty) := + (hMeas r).stronglyMeasurable.integral_prod_right' + have hiBound (z : Z) (r : G → ZMod q) : + ‖∫ x, F z r x ∂scalarCubeProductMeasure G Empty‖ ≤ 1 := by + simpa only [probReal_univ, mul_one] using + norm_integral_le_of_norm_le_const + (ae_of_all (scalarCubeProductMeasure G Empty) (hbound z r)) + have hbMeas : Measurable b := by + unfold b + simp only [Fintype.expect_eq_sum_div_card] + apply Measurable.div_const + exact Finset.measurable_sum _ (fun r _ => (hiMeas r).measurable) + have hbBound (z : Z) : ‖b z‖ ≤ 1 := by + apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun r _ => hiBound z r)).trans_eq (by simp) + have hbInt : Integrable b μ := + (integrable_const (1 : ℝ)).mono' hbMeas.aestronglyMeasurable (ae_of_all μ hbBound) + change ‖(∫ z, a z ∂μ) - ∫ z, b z ∂μ‖ ≤ _ + rw [← integral_sub haInt hbInt] + have he := ae_of_all μ (fun z => + originalKernel_residue_slow_quadrature_varying L q hL hq hqL hsmall + (F z) (hLip z) (hbound z)) + simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const he + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +theorem affineKernel_residue_slow_retained_quadrature + {G R Z : Type*} [Fintype G] [DecidableEq G] [MeasurableSpace Z] + (μ : Measure Z) [IsProbabilityMeasure μ] + (H : G → ℕ) (q : ℕ) [NeZero q] (hH : ∀ g, 0 < H g) + (hq : 0 < q) (hqH : ∀ g, q ≤ H g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H g) < + volume.real (scalarCubeDomain Empty)) + (lower : G → ℝ) (step S : ℝ) (hS : 0 < S) (hstep : 0 ≤ step) + (hspan : ∀ g, step * ((H g - 1 : ℕ) : ℝ) ≤ S) + (residueMap : (G → ZMod q) → R) (F : Z → R → (G → ℝ) → ℂ) + (hMeas : ∀ r, Measurable (fun zx : Z × (G → ℝ) => F zx.1 r zx.2)) + {K : ℝ≥0} (hLip : ∀ z r, LipschitzWith K (F z r)) + (hbound : ∀ z r x, ‖F z r x‖ ≤ 1) : + ‖(∫ z, (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).complexMean + (fun y => F z (residueMap (fun g => ((y g none : ℤ) : ZMod q))) + (fun g => (lower g + step * (y g none : ℝ)) / S)) ∂μ) - + ∫ z, 𝔼 r : G → ZMod q, ∫ x, + F z (residueMap r) (affineKernelContinuousPoint lower step S H x) + ∂scalarCubeProductMeasure G Empty ∂μ‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K) + K) * ∑ g, (q : ℝ) / H g := by + let p := FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g)) + let a (z : Z) := p.complexMean + (fun y => F z (residueMap (fun g => ((y g none : ℤ) : ZMod q))) + (fun g => (lower g + step * (y g none : ℝ)) / S)) + let b (z : Z) := 𝔼 r : G → ZMod q, + ∫ x, F z (residueMap r) (affineKernelContinuousPoint lower step S H x) + ∂scalarCubeProductMeasure G Empty + have haMeas : Measurable a := by + unfold a FiniteProbabilityWeights.complexMean + apply Finset.measurable_sum + intro y _ + exact measurable_const.mul ((hMeas _).comp (measurable_id.prodMk measurable_const)) + have haBound (z : Z) : ‖a z‖ ≤ 1 := by + apply (p.norm_complexMean_le_mean_norm _).trans + exact (p.mean_mono (fun y => hbound z _ _)).trans_eq (p.mean_const 1) + have haInt : Integrable a μ := + (integrable_const (1 : ℝ)).mono' haMeas.aestronglyMeasurable (ae_of_all μ haBound) + have hAffine : Measurable (affineKernelContinuousPoint lower step S H) := + (affineKernelContinuousPoint_lipschitz lower step S H hS hstep hspan).continuous.measurable + have hiMeas (r : G → ZMod q) : + StronglyMeasurable (fun z => ∫ x, + F z (residueMap r) (affineKernelContinuousPoint lower step S H x) + ∂scalarCubeProductMeasure G Empty) := by + have hm : Measurable (fun zx : Z × (G → Option Empty → ℝ) => + F zx.1 (residueMap r) (affineKernelContinuousPoint lower step S H zx.2)) := + (hMeas _).comp (measurable_fst.prodMk (hAffine.comp measurable_snd)) + exact hm.stronglyMeasurable.integral_prod_right' + have hiBound (z : Z) (r : G → ZMod q) : + ‖∫ x, F z (residueMap r) (affineKernelContinuousPoint lower step S H x) + ∂scalarCubeProductMeasure G Empty‖ ≤ 1 := by + simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const + (ae_of_all (scalarCubeProductMeasure G Empty) (fun x => hbound z _ _)) + have hbMeas : Measurable b := by + unfold b + simp only [Fintype.expect_eq_sum_div_card] + apply Measurable.div_const + exact Finset.measurable_sum _ (fun r _ => (hiMeas r).measurable) + have hbBound (z : Z) : ‖b z‖ ≤ 1 := by + apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun r _ => hiBound z r)).trans_eq (by simp) + have hbInt : Integrable b μ := + (integrable_const (1 : ℝ)).mono' hbMeas.aestronglyMeasurable (ae_of_all μ hbBound) + change ‖(∫ z, a z ∂μ) - ∫ z, b z ∂μ‖ ≤ _ + rw [← integral_sub haInt hbInt] + have he := ae_of_all μ (fun z => + affineKernel_residue_slow_quadrature H q hH hq hqH hsmall lower step S hS hstep hspan + residueMap (F z) (hLip z) (hbound z)) + simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const he + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineLayeredModeReduction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineLayeredModeReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bdca68e68c6a62c073b225bdbb5b39ba84f6972 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineLayeredModeReduction.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.Progressions.Estimates.SubspaceLayeredModeSmoothRemoval + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +noncomputable def liftedIntegerSite {K : Type*} (site : K → ℤ) : Option K → ℤ := + fun k => k.elim 1 site + +theorem liftedIntegerSite_cast {K : Type*} (site : K → ℤ) : + (fun k => (liftedIntegerSite site k : ℝ)) = + (fun k : Option K => k.elim 1 (fun k => (site k : ℝ))) := by + funext k + cases k <;> simp [liftedIntegerSite] + +theorem exists_affine_layered_mode_reduction {I K S : Type*} + [Fintype K] [Fintype S] [DecidableEq S] {m : ℕ} + {W : Fin m → Type*} [∀ j, AddCommGroup (W j)] [∀ j, Module ℝ (W j)] + (site : S → K → ℤ) (L : ∀ j, VectorPolynomial K ℝ (W j) →ₗ[ℝ] ℝ) + (p : ∀ j, VectorPolynomial I ℝ (W j)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hbad : ∃ i, ¬∃ M : (S → W i) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) q)) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : S → (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) : + ∃ i, (¬∃ M : (S → W i) →ₗ[ℝ] ℝ, + ∀ q, Homogeneous (i.val + 1) q → affineModeLift (L i) q = + M (siteEvaluation (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) q)) ∧ + ∃ Q' : MvPolynomial (Option K × I) ℝ, Q'.totalDegree < i.val + 1 ∧ + ∃ test' : S → (I → ℝ) → ℂ, (∀ s x, ‖test' s x‖ ≤ 1) ∧ ∀ b, + layeredModeTestedPhase (fun j => affineModeLift (L j)) p Q + (fun s => liftedIntegerSite (site s)) test b = + coefficientModeTestedPhase (affineModeLift (L i)) (p i) Q' + (fun s => liftedIntegerSite (site s)) test' b := by + obtain ⟨i, hi, hh⟩ := exists_highest_affine_nonfactor (fun s k => (site s k : ℝ)) L hbad + refine ⟨i, hi, ?_⟩ + apply exists_layered_mode_reduction i (fun j => affineModeLift (L j)) p hp + (fun s => liftedIntegerSite (site s)) _ Q (hQ.trans_lt (Nat.zero_lt_succ _)) test htest + have hs : (fun s k => (liftedIntegerSite (site s) k : ℝ)) = + (fun s (k : Option K) => k.elim 1 (fun k => (site s k : ℝ))) := by + funext s k + exact congrFun (liftedIntegerSite_cast (site s)) k + rw [hs] + exact hh + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineLiftInsertion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineLiftInsertion.lean new file mode 100644 index 0000000000000000000000000000000000000000..727db69d8a17f12aa2329592447a55737d547094 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineLiftInsertion.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialPatchComposition + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +variable {σ ρ : Type*} {D E s : ℕ} + +noncomputable def affineLiftSubstitution (c : ρ → ℝ) (M : ρ → Fin D → ℝ) : + σ ⊕ ρ → MvPolynomial (σ ⊕ Fin D) ℝ := + Sum.elim (fun a => X (Sum.inl a)) + (fun a => C (c a) + ∑ j, M a j • X (Sum.inr j)) + +theorem affineLiftSubstitution_degree {p : ρ → ℕ} {w : Fin D → ℕ} + (c : ρ → ℝ) (M : ρ → Fin D → ℝ) + (hM : ∀ a j, M a j ≠ 0 → w j ≤ p a) (a : σ ⊕ ρ) : + affineLiftSubstitution c M a ∈ weightedSupportLE (Sum.elim (fun _ : σ => 1) w) + (Sum.elim (fun _ : σ => 1) p a) := by + classical + cases a with + | inl a => exact weightedSupportLE_X _ (Sum.inl a) + | inr a => + apply (weightedSupportLE _ _).add_mem (weightedSupportLE_C _ _ _) + apply (weightedSupportLE _ _).sum_mem + intro j _ + by_cases hj : M a j = 0 + · simp only [hj, zero_smul] + exact (weightedSupportLE _ _).zero_mem + · exact weightedSupportLE_mono (hM a j hj) + ((weightedSupportLE _ _).smul_mem (M a j) + (weightedSupportLE_X (Sum.elim (fun _ : σ => 1) w) (Sum.inr j))) + +theorem affineLiftSubstitution_eval (c : ρ → ℝ) (M : ρ → Fin D → ℝ) + (t : σ → ℝ) (x : Fin D → ℝ) (a : σ ⊕ ρ) : + aeval (Sum.elim t x) (affineLiftSubstitution c M a) = + Sum.elim t (fun a => c a + ∑ j, M a j * x j) a := by + cases a <;> simp [affineLiftSubstitution] + +namespace PolynomialPatch + +noncomputable def insertAffineLifts {p : ρ → ℕ} (A : PolynomialPatch σ s D) + (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E) + (c : ρ → ℝ) (M : ρ → Fin D → ℝ) + (hM : ∀ a j, M a j ≠ 0 → A.weight j ≤ p a) : PolynomialPatch σ s (D + E) := + A.insertLifts (B.reparam (affineLiftSubstitution c M) (affineLiftSubstitution_degree c M hM)) + +@[simp] theorem insertAffineLifts_lip {p : ρ → ℕ} (A : PolynomialPatch σ s D) + (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E) + (c : ρ → ℝ) (M : ρ → Fin D → ℝ) + (hM : ∀ a j, M a j ≠ 0 → A.weight j ≤ p a) : + (A.insertAffineLifts B c M hM).kernel.lip = A.kernel.lip + B.kernel.lip := rfl + +theorem insertAffineLifts_value_at_lift {p : ρ → ℕ} (A : PolynomialPatch σ s D) + (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E) + (c : ρ → ℝ) (M : ρ → Fin D → ℝ) + (hM : ∀ a j, M a j ≠ 0 → A.weight j ≤ p a) + (t : σ → ℝ) (b : Fin D → ℤ) + (hb : ∀ i, |(A.form.slots t).residual b i| ≤ 1 / 3) : + (A.insertAffineLifts B c M hM).value t = + A.kernel.value ((A.form.slots t).residual b) * + B.value (Sum.elim t (fun a => c a + ∑ j, M a j * (b j : ℝ))) := by + unfold insertAffineLifts + rw [insertLifts_value_at_lift _ _ t b hb, WeightedParameterPatch.reparam_value] + simp only [affineLiftSubstitution_eval] + +theorem exists_affine_lift_insertion {p : ρ → ℕ} (w : Fin D → ℕ) + (hw : ∀ i, 1 ≤ w i) (hws : ∀ i, w i ≤ s) (hmono : Monotone w) + (P : Fin D → MvPolynomial σ ℝ) + (hP : ∀ i, P i ∈ weightedSupportLE (fun _ : σ => 1) (w i)) (Φ : PatchKernel D) + (B : WeightedParameterPatch (σ ⊕ ρ) (Sum.elim (fun _ => 1) p) s E) + (c : ρ → ℝ) (M : ρ → Fin D → ℝ) (hM : ∀ a j, M a j ≠ 0 → w j ≤ p a) : + ∃ Q : PolynomialPatch σ s (D + E), Q.kernel.lip = Φ.lip + B.kernel.lip ∧ + ∀ (t : σ → ℝ) (b : Fin D → ℤ), + (∀ i, |(b i : ℝ) - aeval t (P i)| ≤ 1 / 3) → + Q.value t = Φ.value (fun i => (b i : ℝ) - aeval t (P i)) * + B.value (Sum.elim t (fun a => c a + ∑ j, M a j * (b j : ℝ))) := by + let A := ofCoordinates w hw hws hmono P hP Φ + refine ⟨A.insertAffineLifts B c M hM, rfl, ?_⟩ + intro t b hb + have hres : (A.form.slots t).residual b = fun i => (b i : ℝ) - aeval t (P i) := + ofCoordinates_residual w hw hws hmono P hP Φ t b + rw [insertAffineLifts_value_at_lift A B c M hM t b (by simpa only [hres] using hb), hres] + rfl + +end PolynomialPatch +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineLowestLayer.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineLowestLayer.lean new file mode 100644 index 0000000000000000000000000000000000000000..701a0111181ff7d6bfa707efb9ff34725323d7d5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineLowestLayer.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Estimates.DependentPatchValue + +namespace OAI + +section + +namespace Erdos3 + +namespace TriangularSlots + +variable {D : ℕ} + +noncomputable def affineBlock (M : Matrix (Fin D) (Fin D) ℝ) + (hM : ∀ i j, i ≤ j → M i j = 0) (P : Fin D → ℝ) : TriangularSlots D where + center x := P + M.mulVec (x - P) + lower i x y hxy := by + simp only [Pi.add_apply, Matrix.mulVec, dotProduct] + congr 1 + apply Finset.sum_congr rfl + intro j _ + by_cases hji : j < i + · simp only [Pi.sub_apply, hxy j hji] + · simp [hM i j (le_of_not_gt hji)] + +theorem affineBlock_residual (M : Matrix (Fin D) (Fin D) ℝ) + (hM : ∀ i j, i ≤ j → M i j = 0) (P : Fin D → ℝ) (b : Fin D → ℤ) : + (affineBlock M hM P).residual b = (1 - M).mulVec ((fun i => (b i : ℝ)) - P) := by + rw [Matrix.sub_mulVec, Matrix.one_mulVec] + ext i + simp only [residual, affineBlock, Pi.sub_apply, Pi.add_apply] + ring + +end TriangularSlots + +def shiftedIntegerBlock {T : Type*} {D : ℕ} (I : T → Fin D → ℤ) + (t₀ : T) (b₀ : Fin D → ℤ) (t : T) : Fin D → ℤ := b₀ + I t - I t₀ + +@[simp] theorem shiftedIntegerBlock_at_base {T : Type*} {D : ℕ} + (I : T → Fin D → ℤ) (t₀ : T) (b₀ : Fin D → ℤ) : + shiftedIntegerBlock I t₀ b₀ t₀ = b₀ := by simp [shiftedIntegerBlock] + +theorem affine_residual_shift_identity {T : Type*} {D : ℕ} + (M : Matrix (Fin D) (Fin D) ℝ) (hM : ∀ i j, i ≤ j → M i j = 0) + (P : T → Fin D → ℝ) (I : T → Fin D → ℤ) (t₀ t : T) (b₀ : Fin D → ℤ) : + (TriangularSlots.affineBlock M hM (P t)).residual (shiftedIntegerBlock I t₀ b₀ t) - + (TriangularSlots.affineBlock M hM (P t₀)).residual b₀ = + -(1 - M).mulVec ((P t - fun i => (I t i : ℝ)) - (P t₀ - fun i => (I t₀ i : ℝ))) := by + rw [TriangularSlots.affineBlock_residual, TriangularSlots.affineBlock_residual, + ← Matrix.mulVec_sub, ← Matrix.mulVec_neg] + congr 1 + ext i + simp only [shiftedIntegerBlock, Pi.add_apply, Pi.sub_apply, Pi.neg_apply, Int.cast_sub, Int.cast_add] + ring + +theorem affine_residual_shift_dist {T : Type*} {D : ℕ} + (M : Matrix (Fin D) (Fin D) ℝ) (hM : ∀ i j, i ≤ j → M i j = 0) + (P : T → Fin D → ℝ) (I : T → Fin D → ℤ) (t₀ t : T) (b₀ : Fin D → ℤ) : + dist ((TriangularSlots.affineBlock M hM (P t)).residual (shiftedIntegerBlock I t₀ b₀ t)) + ((TriangularSlots.affineBlock M hM (P t₀)).residual b₀) = + ‖(1 - M).mulVec ((P t - fun i => (I t i : ℝ)) - (P t₀ - fun i => (I t₀ i : ℝ)))‖ := by + rw [dist_eq_norm, affine_residual_shift_identity, norm_neg] + +theorem freeze_affine_lowest_layer {T : Type*} {D E : ℕ} + (M : Matrix (Fin D) (Fin D) ℝ) (hM : ∀ i j, i ≤ j → M i j = 0) + (P : T → Fin D → ℝ) (I : T → Fin D → ℤ) + (B : T → (Fin D → ℝ) → TriangularSlots E) (Φ : PatchKernel (D + E)) + (t₀ : T) (b₀ : Fin D → ℤ) {ε : ℝ} + (hbase : ∀ i, |(TriangularSlots.affineBlock M hM (P t₀)).residual b₀ i| ≤ 1 / 4) + (hε : ε < 1 / 12) + (hosc : ∀ t, ‖(1 - M).mulVec + ((P t - fun i => (I t i : ℝ)) - (P t₀ - fun i => (I t₀ i : ℝ)))‖ ≤ ε) : + ∀ t, dist (((TriangularSlots.affineBlock M hM (P t)).append (B t)).patchValue Φ) + ((B t (fun i => (shiftedIntegerBlock I t₀ b₀ t i : ℝ))).patchValue + (Φ.freeze ((TriangularSlots.affineBlock M hM (P t₀)).residual b₀))) ≤ Φ.lip * ε := by + intro t + apply TriangularSlots.patchValue_freeze_prefix _ _ Φ _ _ hbase hε + rw [affine_residual_shift_dist] + exact hosc t + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineMaskedInitialShell.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineMaskedInitialShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..87c2109c3b0d6a84d512af2745c40f4d0bf39101 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineMaskedInitialShell.lean @@ -0,0 +1,548 @@ +import OAI.Combinatorics.Progressions.Dynamics.InitialConditioningBudget +import OAI.Combinatorics.Progressions.Geometry.OutsideProductTransport +import OAI.Combinatorics.Progressions.Lattices.ResidueCellNormLengths +import OAI.Combinatorics.Progressions.Lattices.RetainedPhysicalCRT + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι σ : Type*} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] + (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + +include hpair u + +theorem residuePrimeCoordinateDensity_fixed (f : (σ → ℤ) → ℝ) + (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) : + residuePrimeCoordinateDensity lo N M a hne q f x = + residuePrimeCoordinateMassRatio lo N M a q K base * + residueCellOutsideDensity lo N M a q K base u f (fun i => x i.val) := by + have hcover : K ∪ (Finset.univ : Finset {i // i ∉ K}).image Subtype.val = Finset.univ := by + ext i + by_cases hi : i ∈ K + · simp [hi] + · simp only [Finset.mem_union, hi, false_or, Finset.mem_image, Finset.mem_univ, iff_true] + exact ⟨⟨i, hi⟩, trivial, rfl⟩ + have h := residuePrimeCoordinateDensity_conditional_outside lo N M a hne q hpair K base u f + (Finset.univ : Finset {i // i ∉ K}) x hx + rw [hcover, productConditionalMean_univ, productConditionalMean_univ] at h + rw [residueCellOutsideDensity_lcm lo N M a q hpair K base u f] + exact h + +theorem residuePrimeCoordinateDensity_section (f : (σ → ℤ) → ℝ) (x : ∀ i, σ → ZMod (q i)) : + productSectionAverage (primeCoordinateReference (σ := σ) q) K K base + (residuePrimeCoordinateDensity lo N M a hne q f) x = + residuePrimeCoordinateMassRatio lo N M a q K base * + residueCellOutsideDensity lo N M a q K base u f (fun i => x i.val) := by + have hx : ∀ i ∈ K, productCoordinateMix K base x i = base i := by + intro i hi + simp only [productCoordinateMix, hi, ite_true] + have hout : (fun i : {i // i ∉ K} => productCoordinateMix K base x i.val) = (fun i : {i // i ∉ K} => x i.val) := by + funext i + simp only [productCoordinateMix, i.property, ite_false] + rw [productSectionAverage_eq_conditionalMean _ K K (Finset.Subset.refl K)] + simp only [Finset.union_compl, productConditionalMean_univ] + rw [residuePrimeCoordinateDensity_fixed lo N M a hne q hpair K base u f _ hx, hout] + +omit hne hpair in +theorem residuePrimeCoordinateMassRatio_pos : 0 < residuePrimeCoordinateMassRatio lo N M a q K base := by + let : Nonempty (ResiduePrimeCoordinateCell lo N M a q K base) := ⟨u⟩ + let : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) := ⟨u.val⟩ + have hp : 0 < ∏ i ∈ K, q i := Finset.prod_pos (fun i _ => Nat.pos_of_ne_zero (NeZero.ne (q i))) + rw [residuePrimeCoordinateMassRatio_eq_count] + positivity + +theorem residuePrimeCoordinateDensity_normalized_section (f : (σ → ℤ) → ℝ) + (x : ∀ i, σ → ZMod (q i)) : + (residuePrimeCoordinateMassRatio lo N M a q K base)⁻¹ * + productSectionAverage (primeCoordinateReference (σ := σ) q) K K base + (residuePrimeCoordinateDensity lo N M a hne q f) x = + residueCellOutsideDensity lo N M a q K base u f (fun i => x i.val) := by + rw [residuePrimeCoordinateDensity_section lo N M a hne q hpair K base u f x, + ← mul_assoc, inv_mul_cancel₀ (residuePrimeCoordinateMassRatio_pos lo N M a q K base u).ne', one_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residuePrimeCoordinateMassRatio_le_prime_product {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) : + residuePrimeCoordinateMassRatio lo N M a q K base ≤ ((∏ i ∈ K, q i : ℕ) : ℝ) ^ Fintype.card σ := by + let : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) := ⟨u.val⟩ + have hB : (0 : ℝ) < Fintype.card (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) := by + exact_mod_cast Fintype.card_pos + have hcard : (Fintype.card (ResiduePrimeCoordinateCell lo N M a q K base) : ℝ) ≤ + Fintype.card (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) := + Nat.cast_le.mpr (Fintype.card_subtype_le _) + have hratio : (Fintype.card (ResiduePrimeCoordinateCell lo N M a q K base) : ℝ) / + Fintype.card (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) ≤ 1 := by + apply (div_le_iff₀ hB).mpr + simpa only [one_mul] using hcard + rw [residuePrimeCoordinateMassRatio_eq_count, mul_div_assoc] + exact mul_le_of_le_one_right (by positivity) hratio + +theorem residuePrimeCoordinateMassRatio_le_exp {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) (modLog : ℝ) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) : + residuePrimeCoordinateMassRatio lo N M a q K base ≤ + Real.exp ((K.card : ℝ) * Fintype.card σ * modLog) := by + have hprod := primeCoordinateProduct_le_exp q K modLog hmoduli + calc + _ ≤ ((∏ i ∈ K, q i : ℕ) : ℝ) ^ Fintype.card σ := + residuePrimeCoordinateMassRatio_le_prime_product lo N M a q K base u + _ ≤ (Real.exp (modLog * K.card)) ^ Fintype.card σ := + pow_le_pow_left₀ (Nat.cast_nonneg _) hprod _ + _ = _ := by + rw [← Real.exp_nat_mul] + congr 1 + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residuePrimeCoordinateDensity_section_norm {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) (f : (σ → ℤ) → ℝ) (B : ℕ) : + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) q) (lowDegreeCoordinateSets ι B) + (productSectionAverage (primeCoordinateReference (σ := σ) q) K K base + (residuePrimeCoordinateDensity lo N M a hne q f))) = + residuePrimeCoordinateMassRatio lo N M a q K base * + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (lowDegreeCoordinateSets {i // i ∉ K} B) (residueCellOutsideDensity lo N M a q K base u f)) := by + have hs := funext (residuePrimeCoordinateDensity_section lo N M a hne q hpair K base u f) + rw [hs, sqrt_productANOVAEnergy_smul, + productANOVAEnergy_outside (primeCoordinateReference (σ := σ) q) K base B, + abs_of_nonneg (residuePrimeCoordinateMassRatio_pos lo N M a q K base u).le] + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residueSectionPairing_core {ι σ τ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] + (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ) + (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX)) + (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ) + (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i)) + (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX) + (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY) + (c : ∀ i, FiniteProbabilityCoupling (primeCoordinateReference (σ := σ) q i) (primeCoordinateReference (σ := τ) q i)) + (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ) : + productTruncatedPairing c (conditioningCoreSupports K B) + (productSectionAverage (primeCoordinateReference (σ := σ) q) K K baseX (residuePrimeCoordinateDensity loX NX MX aX hneX q w)) + (productSectionAverage (primeCoordinateReference (σ := τ) q) K K baseY (residuePrimeCoordinateDensity loY NY MY aY hneY q f)) = + residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * + productTruncatedPairing (fun i : {i // i ∉ K} => c i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) + (residueCellOutsideDensity loX NX MX aX q K baseX uX w) + (residueCellOutsideDensity loY NY MY aY q K baseY uY f) := by + have hx := funext (residuePrimeCoordinateDensity_section loX NX MX aX hneX q hpair K baseX uX w) + have hy := funext (residuePrimeCoordinateDensity_section loY NY MY aY hneY q hpair K baseY uY f) + rw [hx, hy, productTruncatedPairing_smul, productTruncatedPairing_outside_core c K baseX baseY B] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residue_initial_conditioning_shell {ι σ τ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] + (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ) + (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX)) + (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ) + (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i)) + (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX) + (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY) + (kernel : ∀ i, (σ → ZMod (q i)) → FiniteProbabilityWeights (τ → ZMod (q i))) + (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : (τ → ZMod (q i)) → ℝ), (primeCoordinateReference (σ := τ) q i).mean f = 0 → + (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f ^ 2) ≤ + C i * (primeCoordinateReference (σ := τ) q i).mean (fun y => f y ^ 2)) + (hmean : ∀ i (f : (τ → ZMod (q i)) → ℝ), + (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f) = + (primeCoordinateReference (σ := τ) q i).mean f) + (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ) (hKB : K.card ≤ B) + {κ sourceNorm siteNorm : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∉ K, C i ≤ κ ^ 2) + (hsourceNorm : Real.sqrt (productANOVAEnergy + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (lowDegreeCoordinateSets {i // i ∉ K} B) (residueCellOutsideDensity loX NX MX aX q K baseX uX w)) ≤ sourceNorm) + (hsiteNorm : Real.sqrt (productANOVAEnergy + (primeCoordinateReference (σ := τ) (fun i : {i // i ∉ K} => q i.val)) + (lowDegreeCoordinateSets {i // i ∉ K} B) (residueCellOutsideDensity loY NY MY aY q K baseY uY f)) ≤ siteNorm) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (primeCoordinateReference (σ := σ) q i) + (primeCoordinateReference (σ := τ) q i) (kernel i) (hmean i) + |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) - + productCouplingAtomMass c K baseX baseY * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * + productTruncatedPairing (fun i : {i // i ∉ K} => c i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) + (residueCellOutsideDensity loX NX MX aX q K baseX uX w) + (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ + (2 : ℝ) ^ K.card * (κ ^ (B - K.card) * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * sourceNorm) * + (residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * siteNorm)) := by + let μ := primeCoordinateReference (σ := σ) q + let ν := primeCoordinateReference (σ := τ) q + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (kernel i) (hmean i) + have hx : Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι B) + (productSectionAverage μ K K baseX (residuePrimeCoordinateDensity loX NX MX aX hneX q w))) ≤ + residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * sourceNorm := by + rw [residuePrimeCoordinateDensity_section_norm loX NX MX aX hneX q hpair K baseX uX w B] + exact mul_le_mul_of_nonneg_left hsourceNorm (residuePrimeCoordinateMassRatio_pos loX NX MX aX q K baseX uX).le + have hy : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι B) + (productSectionAverage ν K K baseY (residuePrimeCoordinateDensity loY NY MY aY hneY q f))) ≤ + residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * siteNorm := by + rw [residuePrimeCoordinateDensity_section_norm loY NY MY aY hneY q hpair K baseY uY f B] + exact mul_le_mul_of_nonneg_left hsiteNorm (residuePrimeCoordinateMassRatio_pos loY NY MY aY q K baseY uY).le + have hshell := productKernel_conditioning_shell_of_truncated μ ν kernel C hC hbound hmean K B hKB + hκ0 hκ1 hcap baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) hx hy + change |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) - + productCouplingAtomMass c K baseX baseY * productTruncatedPairing c (conditioningCoreSupports K B) + (productSectionAverage μ K K baseX (residuePrimeCoordinateDensity loX NX MX aX hneX q w)) + (productSectionAverage ν K K baseY (residuePrimeCoordinateDensity loY NY MY aY hneY q f))| ≤ _ at hshell + rw [residueSectionPairing_core loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY c w f B] at hshell + exact hshell + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residue_initial_conditioning_shell_of_lengths {ι σ τ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] + (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ) + (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX)) + (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ) + (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i)) + (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX) + (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY) + (kernel : ∀ i, (σ → ZMod (q i)) → FiniteProbabilityWeights (τ → ZMod (q i))) + (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : (τ → ZMod (q i)) → ℝ), (primeCoordinateReference (σ := τ) q i).mean f = 0 → + (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f ^ 2) ≤ + C i * (primeCoordinateReference (σ := τ) q i).mean (fun y => f y ^ 2)) + (hmean : ∀ i (f : (τ → ZMod (q i)) → ℝ), + (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f) = + (primeCoordinateReference (σ := τ) q i).mean f) + (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ) (hKB : K.card ≤ B) + {κ : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∉ K, C i ≤ κ ^ 2) + (hMX : 0 < MX) (hMY : 0 < MY) + (hcopX : ∀ i ∉ K, MX.Coprime (q i)) (hcopY : ∀ i ∉ K, MY.Coprime (q i)) + (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX, + 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1) + (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY, + 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1) + (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + (hdimX : (Fintype.card σ : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card τ : ℝ) ≤ Real.exp dimY) + (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤ + (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ)) + (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤ + (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ)) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (primeCoordinateReference (σ := σ) q i) + (primeCoordinateReference (σ := τ) q i) (kernel i) (hmean i) + |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) - + productCouplingAtomMass c K baseX baseY * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * + productTruncatedPairing (fun i : {i // i ∉ K} => c i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) + (residueCellOutsideDensity loX NX MX aX q K baseX uX w) + (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ + (2 : ℝ) ^ K.card * (κ ^ (B - K.card) * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * 3) * + (residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * 3)) := by + have hx := residueCellOutsideDensity_norm_of_lengths (ι := ι) (σ := σ) + loX NX MX aX q hMX hpair K baseX hcopX uX w hw B P modLog dimX hP hmodLog hcount hmoduli hdimX hlengthX + have hy := residueCellOutsideDensity_norm_of_lengths (ι := ι) (σ := τ) + loY NY MY aY q hMY hpair K baseY hcopY uY f hf B P modLog dimY hP hmodLog hcount hmoduli hdimY hlengthY + exact residue_initial_conditioning_shell loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY + kernel C hC hbound hmean w f B hKB hκ0 hκ1 hcap hx hy + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residue_initial_conditioning_shell_small {ι σ τ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] + (loX : σ → ℤ) (NX : σ → ℕ) (MX : ℕ) (aX : σ → ℤ) + (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX)) + (loY : τ → ℤ) (NY : τ → ℕ) (MY : ℕ) (aY : τ → ℤ) + (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (baseX : ∀ i, σ → ZMod (q i)) (baseY : ∀ i, τ → ZMod (q i)) + (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX) + (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY) + (kernel : ∀ i, (σ → ZMod (q i)) → FiniteProbabilityWeights (τ → ZMod (q i))) + (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : (τ → ZMod (q i)) → ℝ), (primeCoordinateReference (σ := τ) q i).mean f = 0 → + (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f ^ 2) ≤ + C i * (primeCoordinateReference (σ := τ) q i).mean (fun y => f y ^ 2)) + (hmean : ∀ i (f : (τ → ZMod (q i)) → ℝ), + (primeCoordinateReference (σ := σ) q i).mean (fun x => (kernel i x).mean f) = + (primeCoordinateReference (σ := τ) q i).mean f) + (w : (σ → ℤ) → ℝ) (f : (τ → ℤ) → ℝ) (B : ℕ) + {κ : ℝ} (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hcap : ∀ i ∉ K, C i ≤ κ ^ 2) + (hMX : 0 < MX) (hMY : 0 < MY) + (hcopX : ∀ i ∉ K, MX.Coprime (q i)) (hcopY : ∀ i ∉ K, MY.Coprime (q i)) + (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX, + 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1) + (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY, + 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1) + (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (hdimX : (Fintype.card σ : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card τ : ℝ) ≤ Real.exp dimY) + (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤ + (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ)) + (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤ + (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ)) + (shell : ℝ) (hshell : 0 < shell) + (hB : K.card + CyclicCrootSisask.spectralIterations shell + ((K.card : ℝ) * ((Fintype.card σ : ℝ) * modLog + (Fintype.card τ : ℝ) * modLog + 1) + 4) ≤ B) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (primeCoordinateReference (σ := σ) q i) + (primeCoordinateReference (σ := τ) q i) (kernel i) (hmean i) + |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) - + productCouplingAtomMass c K baseX baseY * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * + productTruncatedPairing (fun i : {i // i ∉ K} => c i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) + (residueCellOutsideDensity loX NX MX aX q K baseX uX w) + (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 := by + have hsmallX : residuePrimeCoordinateMassRatio loX NX MX aX q K baseX ≤ + Real.exp ((K.card : ℝ) * ((Fintype.card σ : ℝ) * modLog)) := by + simpa only [mul_assoc] using residuePrimeCoordinateMassRatio_le_exp loX NX MX aX q K baseX uX modLog hmoduli + have hsmallY : residuePrimeCoordinateMassRatio loY NY MY aY q K baseY ≤ + Real.exp ((K.card : ℝ) * ((Fintype.card τ : ℝ) * modLog)) := by + simpa only [mul_assoc] using residuePrimeCoordinateMassRatio_le_exp loY NY MY aY q K baseY uY modLog hmoduli + have hbudget := initial_conditioning_error_small K.card B + (residuePrimeCoordinateMassRatio_pos loX NX MX aX q K baseX uX).le + (residuePrimeCoordinateMassRatio_pos loY NY MY aY q K baseY uY).le + hsmallX hsmallY hκ0 hκhalf hshell hB + have hresult := residue_initial_conditioning_shell_of_lengths + loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY kernel C hC hbound hmean + w f B (by omega) hκ0 (by linarith) hcap hMX hMY hcopX hcopY hw hf P modLog dimX dimY hP hmodLog + hcount (fun i _ => hmoduli i) hdimX hdimY hlengthX hlengthY + exact hresult.trans hbudget + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affine_period_initial_conditioning_shell_small {ι J σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype σ] + (loX : (Option J × σ) → ℤ) (NX : (Option J × σ) → ℕ) (MX : ℕ) (aX : (Option J × σ) → ℤ) + (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX)) + (loY : σ → ℤ) (NY : σ → ℕ) (MY : ℕ) (aY : σ → ℤ) + (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (baseX : ∀ i, (Option J × σ) → ZMod (q i)) (baseY : ∀ i, σ → ZMod (q i)) + (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX) + (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY) + (D : ℕ) (a : J → ℤ) (hDcop : ∀ i ∉ K, D.Coprime (q i)) + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) + (hpower : ∀ i, q i = prime i ^ power i) (hJ : 2 ≤ Fintype.card J) + (w : ((Option J × σ) → ℤ) → ℝ) (f : (σ → ℤ) → ℝ) (B : ℕ) + {κ : ℝ} (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hlarge : ∀ i ∉ K, (prime i : ℝ)⁻¹ ≤ κ) + (hMX : 0 < MX) (hMY : 0 < MY) + (hcopX : ∀ i ∉ K, MX.Coprime (q i)) (hcopY : ∀ i ∉ K, MY.Coprime (q i)) + (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX, + 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1) + (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY, + 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1) + (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (hdimX : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card σ : ℝ) ≤ Real.exp dimY) + (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤ + (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ)) + (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤ + (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ)) + (shell : ℝ) (hshell : 0 < shell) + (hB : K.card + CyclicCrootSisask.spectralIterations shell + ((K.card : ℝ) * ((Fintype.card (Option J × σ) : ℝ) * modLog + (Fintype.card σ : ℝ) * modLog + 1) + 4) ≤ B) : + let c := affinePeriodProductCoupling (σ := σ) q D a + |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) - + productCouplingAtomMass c K baseX baseY * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) + (residueCellOutsideDensity loX NX MX aX q K baseX uX w) + (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 := by + let kernel := fun i => affineSampleParameterKernel (I := σ) (affinePeriodParameterLaw (q := q i) D a) + let C := fun i => if i ∈ K then (1 : ℝ) else κ ^ 2 + have hC (i : ι) : 0 ≤ C i := by + dsimp only [C] + split_ifs <;> positivity + have hbound := affinePeriodParameterKernel_centered_sq (σ := σ) q D a K prime power + hprime hpower hDcop hκ0 hJ hlarge + have hmean := fun i => affineSampleParameterKernel_preserves_mean (I := σ) + (affinePeriodParameterLaw (q := q i) D a) + have hcap (i : ι) (hi : i ∉ K) : C i ≤ κ ^ 2 := by simp only [C, ite_eq_right hi, le_refl] + have hresult := residue_initial_conditioning_shell_small + loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY + kernel C hC hbound hmean w f B hκ0 hκhalf hcap hMX hMY hcopX hcopY hw hf + P modLog dimX dimY hP hmodLog hcount hmoduli hdimX hdimY hlengthX hlengthY shell hshell hB + change + |productAtomTruncatedPairing (affinePeriodProductCoupling (σ := σ) q D a) (lowDegreeCoordinateSets ι B) K baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) - + productCouplingAtomMass (affinePeriodProductCoupling (σ := σ) q D a) K baseX baseY * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * + productTruncatedPairing (fun i : {i // i ∉ K} => affinePeriodProductCoupling (σ := σ) q D a i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) + (residueCellOutsideDensity loX NX MX aX q K baseX uX w) + (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 at hresult + rw [affinePeriodProductCoupling_outside q D a K hDcop] at hresult + exact hresult + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affine_masked_initial_conditioning_shell_small {ι J σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype σ] + (loX : (Option J × σ) → ℤ) (NX : (Option J × σ) → ℕ) (MX : ℕ) (aX : (Option J × σ) → ℤ) + (hneX : Nonempty (IntegerResidueBox loX (fun k => loX k + NX k) (fun _ => (MX : ℤ)) aX)) + (loY : σ → ℤ) (NY : σ → ℕ) (MY : ℕ) (aY : σ → ℤ) + (hneY : Nonempty (IntegerResidueBox loY (fun k => loY k + NY k) (fun _ => (MY : ℤ)) aY)) + (q : ι → ℕ) [∀ i, NeZero (q i)] + (K : Finset ι) (baseX : ∀ i, (Option J × σ) → ZMod (q i)) (baseY : ∀ i, σ → ZMod (q i)) + (uX : ResiduePrimeCoordinateCell loX NX MX aX q K baseX) + (uY : ResiduePrimeCoordinateCell loY NY MY aY q K baseY) + (D : ℕ) (a : J → ℤ) + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) + (hpower : ∀ i, q i = prime i ^ power i) (hinj : Function.Injective prime) (hJ : 2 ≤ Fintype.card J) + (w : ((Option J × σ) → ℤ) → ℝ) (f : (σ → ℤ) → ℝ) (B : ℕ) + (hMX : 0 < MX) (hMY : 0 < MY) + (hw : ∀ z : ResiduePrimeCoordinateCell loX NX MX aX q K baseX, + 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1) + (hf : ∀ z : ResiduePrimeCoordinateCell loY NY MY aY q K baseY, + 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1) + (P modLog dimX dimY : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog) + (ξ : ℝ) (hξ : 0 < ξ) (hmask : affineSamplerPrimeMask prime ξ P MX MY D ⊆ K) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (hdimX : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp dimX) (hdimY : (Fintype.card σ : ℝ) ≤ Real.exp dimY) + (hlengthX : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimX + 1) ≤ + (residueIndexLength (loX k) (loX k + NX k) (MX.lcm (∏ i ∈ K, q i)) ((uX.val k).val) : ℝ)) + (hlengthY : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimY + 1) ≤ + (residueIndexLength (loY k) (loY k + NY k) (MY.lcm (∏ i ∈ K, q i)) ((uY.val k).val) : ℝ)) + (shell : ℝ) (hshell : 0 < shell) + (hB : K.card + CyclicCrootSisask.spectralIterations shell + ((K.card : ℝ) * ((Fintype.card (Option J × σ) : ℝ) * modLog + (Fintype.card σ : ℝ) * modLog + 1) + 4) ≤ B) : + let c := affinePeriodProductCoupling (σ := σ) q D a + |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) K baseX baseY + (residuePrimeCoordinateDensity loX NX MX aX hneX q w) (residuePrimeCoordinateDensity loY NY MY aY hneY q f) - + productCouplingAtomMass c K baseX baseY * + (residuePrimeCoordinateMassRatio loX NX MX aX q K baseX * residuePrimeCoordinateMassRatio loY NY MY aY q K baseY * + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) + (residueCellOutsideDensity loX NX MX aX q K baseX uX w) + (residueCellOutsideDensity loY NY MY aY q K baseY uY f))| ≤ shell / 16 := by + have hpair : Pairwise (fun i k => (q i).Coprime (q k)) := by + intro i k hik + rw [hpower i, hpower k] + exact selectedPrimePowers_pairwise_coprime prime power hprime hinj hik + have houtside := affineSamplerPrimeMask_outside prime power hprime hP K hmask + have hcopX (i : ι) (hi : i ∉ K) : MX.Coprime (q i) := by + rw [hpower i] + exact (houtside i hi).1 + have hcopY (i : ι) (hi : i ∉ K) : MY.Coprime (q i) := by + rw [hpower i] + exact (houtside i hi).2.1 + have hDcop (i : ι) (hi : i ∉ K) : D.Coprime (q i) := by + rw [hpower i] + exact (houtside i hi).2.2.1 + have hlarge (i : ι) (hi : i ∉ K) : (prime i : ℝ)⁻¹ ≤ affineComparisonContraction ξ P := + (houtside i hi).2.2.2 + have hκ := affineComparisonContraction_bounds hξ hP + exact affine_period_initial_conditioning_shell_small + loX NX MX aX hneX loY NY MY aY hneY q hpair K baseX baseY uX uY + D a hDcop prime power hprime hpower hJ w f B hκ.1.le hκ.2.1 hlarge + hMX hMY hcopX hcopY hw hf P modLog dimX dimY hP hmodLog hcount hmoduli + hdimX hdimY hlengthX hlengthY shell hshell hB + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshRetention.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..90e02bcf900d4837a43aac589d3e3ff181404569 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshRetention.lean @@ -0,0 +1,646 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalBoundaryLabels +import OAI.Combinatorics.Progressions.Estimates.RealFiniteZeroExtension +import OAI.Combinatorics.Progressions.Estimates.WeightedSmoothSampledError +import OAI.Combinatorics.Progressions.Probability.LargeDivisorPairProbability +import OAI.Combinatorics.Progressions.Probability.RelativeFullSliceLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem interval_event_probability (a b : ℤ) (hab : a < b) (E : ℤ → Prop) + [DecidablePred E] : + (intervalUniformWeights a b hab).eventProbability (fun x => E (x : ℤ)) = + ((Finset.filter E (Finset.Ico a b)).card : ℝ) / ((b - a : ℤ) : ℝ) := by + unfold FiniteProbabilityWeights.eventProbability + rw [intervalUniformWeights_mean] + convert integerInterval_indicator_expect a b hab.le E using 1 + congr 1 + funext x + split_ifs <;> rfl + +theorem interval_near_probability (a b v : ℤ) (hab : a < b) (r : ℕ) : + (intervalUniformWeights a b hab).eventProbability (fun x => |(x : ℤ) - v| ≤ (r : ℤ)) ≤ + (2 * (r : ℝ) + 1) / ((b - a : ℤ) : ℝ) := by + rw [interval_event_probability a b hab (fun x => |x - v| ≤ (r : ℤ))] + have hsub : (Finset.filter (fun x => |x - v| ≤ (r : ℤ)) (Finset.Ico a b)) ⊆ + Finset.Icc (v - (r : ℤ)) (v + (r : ℤ)) := by + intro x hx + have h := abs_le.mp (Finset.mem_filter.mp hx).2 + exact Finset.mem_Icc.mpr ⟨by omega, by omega⟩ + have he : (Finset.Icc (v - (r : ℤ)) (v + (r : ℤ))).card = 2 * r + 1 := by + rw [Int.card_Icc] + omega + have hc : ((Finset.filter (fun x => |x - v| ≤ (r : ℤ)) (Finset.Ico a b)).card : ℝ) ≤ + 2 * (r : ℝ) + 1 := by + have h := Finset.card_le_card hsub + rw [he] at h + exact_mod_cast h + exact div_le_div_of_nonneg_right hc (by exact_mod_cast (sub_pos.mpr hab).le) + +theorem integer_box_near_probability {J : Type*} [Fintype J] [DecidableEq J] + (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) (v : J → ℤ) (r : ℕ) : + (integerBoxUniformWeights lo hi hlen).eventProbability + (fun y => ∀ j, |(y j : ℤ) - v j| ≤ (r : ℤ)) ≤ + ∏ j, (2 * (r : ℝ) + 1) / ((hi j - lo j : ℤ) : ℝ) := by + rw [integerBoxUniformWeights, FiniteProbabilityWeights.eventProbability_pi + (fun j => intervalUniformWeights (lo j) (hi j) (hlen j)) + (fun j (y : Finset.Ico (lo j) (hi j)) => |(y : ℤ) - v j| ≤ (r : ℤ))] + apply Finset.prod_le_prod₀ + · intro j _ + exact FiniteProbabilityWeights.eventProbability_nonneg _ _ + · intro j _ + exact interval_near_probability (lo j) (hi j) (v j) (hlen j) r + +theorem integer_box_pair_near_probability {J : Type*} [Fintype J] [DecidableEq J] + (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) (r : ℕ) : + ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability + (fun xy => ∀ j, |(xy.2 j : ℤ) - (xy.1 j : ℤ)| ≤ (r : ℤ)) ≤ + ∏ j, (2 * (r : ℝ) + 1) / ((hi j - lo j : ℤ) : ℝ) := by + unfold FiniteProbabilityWeights.eventProbability + rw [FiniteProbabilityWeights.mean_prod] + apply (FiniteProbabilityWeights.mean_mono _ ?_).trans_eq (FiniteProbabilityWeights.mean_const _ _) + intro x + exact integer_box_near_probability lo hi hlen (fun j => (x j : ℤ)) r + +theorem integer_box_pair_near_probability_of_lengths {J : Type*} + [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (r : ℕ) {L : ℝ} (hL : 0 < L) (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ)) : + ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability + (fun xy => ∀ j, |(xy.2 j : ℤ) - (xy.1 j : ℤ)| ≤ (r : ℤ)) ≤ + ((2 * (r : ℝ) + 1) / L) ^ Fintype.card J := by + apply (integer_box_pair_near_probability lo hi hlen r).trans + calc + _ ≤ ∏ _j : J, (2 * (r : ℝ) + 1) / L := by + apply Finset.prod_le_prod₀ + · intro j _ + have hj : (0 : ℝ) < ((hi j - lo j : ℤ) : ℝ) := hL.trans_le (hside j) + positivity + · intro j _ + exact div_le_div_of_nonneg_left (by positivity) hL (hside j) + _ = _ := by simp [div_pow] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integer_vector_content_natAbs_scale {J : Type*} [Fintype J] + (D : ℕ) (z : J → ℤ) : + (BohrLattice.Primitive.content (fun j => (D : ℤ) * z j)).natAbs = + D * (BohrLattice.Primitive.content z).natAbs := by + simp only [BohrLattice.Primitive.content, Finset.gcd_mul_left, Int.normalize_coe_nat, + Int.natAbs_mul, Int.natAbs_natCast] + +theorem affine_parameter_difference_gcd {J : Type*} [Fintype J] + (D : ℕ) (a x y : J → ℤ) : + (BohrLattice.Primitive.content (fun j => (a j + (D : ℤ) * y j) - + (a j + (D : ℤ) * x j))).natAbs = + D * (BohrLattice.Primitive.content (fun j => y j - x j)).natAbs := by + have he : (fun j => (a j + (D : ℤ) * y j) - (a j + (D : ℤ) * x j)) = + (fun j => (D : ℤ) * (y j - x j)) := by funext j; ring + rw [he, integer_vector_content_natAbs_scale] + +theorem integer_box_pair_gcd_probability {J : Type*} + [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (B R : ℕ) (hB : 0 < B) (hdim : 2 ≤ Fintype.card J) + {L : ℝ} (hL : 0 < L) (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ)) + (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ)) : + ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability + (fun xy => B < (BohrLattice.Primitive.content + (fun j => (xy.2 j : ℤ) - (xy.1 j : ℤ))).natAbs) ≤ + 2 ^ (Fintype.card J - 1) * + (1 / (B : ℝ) ^ (Fintype.card J - 1) + (R : ℝ) / L ^ Fintype.card J) := by + apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans + (integer_box_pair_nonzero_large_divisor_probability lo hi hlen B R hB hdim hL hside hwidth) + intro xy h + refine ⟨?_, (BohrLattice.Primitive.content (fun j => (xy.2 j : ℤ) - (xy.1 j : ℤ))).natAbs, h, ?_⟩ + · intro he + have hz : Finset.univ.gcd (fun _ : J => (0 : ℤ)) = 0 := + Finset.gcd_eq_zero_iff.mpr (fun _ _ => rfl) + simp [he, BohrLattice.Primitive.content, hz] at h + · intro j + exact Int.natAbs_dvd.mpr (BohrLattice.Primitive.content_dvd _ j) + +theorem affine_parameter_pair_gcd_probability {J : Type*} + [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (D Q B R : ℕ) (a : J → ℤ) (hBQ : D * B ≤ Q) (hB : 0 < B) + (hdim : 2 ≤ Fintype.card J) {L : ℝ} (hL : 0 < L) + (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ)) + (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ)) : + ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability + (fun xy => Q < (BohrLattice.Primitive.content + (fun j => (a j + (D : ℤ) * (xy.2 j : ℤ)) - + (a j + (D : ℤ) * (xy.1 j : ℤ)))).natAbs) ≤ + 2 ^ (Fintype.card J - 1) * + (1 / (B : ℝ) ^ (Fintype.card J - 1) + (R : ℝ) / L ^ Fintype.card J) := by + apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans + (integer_box_pair_gcd_probability lo hi hlen B R hB hdim hL hside hwidth) + intro xy h + rw [affine_parameter_difference_gcd] at h + exact Nat.lt_of_mul_lt_mul_left (hBQ.trans_lt h) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerBoxUniformWeights_mean {J : Type*} [Fintype J] [DecidableEq J] + (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (f : (∀ j, Finset.Ico (lo j) (hi j)) → ℝ) : + (integerBoxUniformWeights lo hi hlen).mean f = 𝔼 x, f x := by + let : ∀ j, Nonempty (Finset.Ico (lo j) (hi j)) := + fun j => ⟨⟨lo j, Finset.mem_Ico.mpr ⟨le_rfl, hlen j⟩⟩⟩ + have he : integerBoxUniformWeights lo hi hlen = + FiniteProbabilityWeights.uniform (∀ j, Finset.Ico (lo j) (hi j)) := by + apply FiniteProbabilityWeights.eq_of_weight_eq + intro x + change (∏ j, (Fintype.card (Finset.Ico (lo j) (hi j)) : ℝ)⁻¹) = + (Fintype.card (∀ j, Finset.Ico (lo j) (hi j)) : ℝ)⁻¹ + rw [Fintype.card_pi, Nat.cast_prod, Finset.prod_inv_distrib] + rw [he, FiniteProbabilityWeights.uniform_mean] + +theorem finite_event_probability_or_le {X : Type*} [Fintype X] + (p : FiniteProbabilityWeights X) (A B : X → Prop) : + p.eventProbability (fun x => A x ∨ B x) ≤ p.eventProbability A + p.eventProbability B := by + have hpoint (x : X) : (@ite ℝ (A x ∨ B x) (Classical.propDecidable _) 1 0) ≤ + (@ite ℝ (A x) (Classical.propDecidable _) 1 0) + + (@ite ℝ (B x) (Classical.propDecidable _) 1 0) := by + by_cases ha : A x <;> by_cases hb : B x <;> simp [ha, hb] + exact (p.mean_mono hpoint).trans_eq (p.mean_add _ _) + +def affineParameterBadPair {J : Type*} [Fintype J] + (D Q r : ℕ) (a x y : J → ℤ) : Prop := + Q < (BohrLattice.Primitive.content + (fun j => (a j + (D : ℤ) * y j) - (a j + (D : ℤ) * x j))).natAbs ∨ + ∀ j, |y j - x j| ≤ (r : ℤ) + +noncomputable def integerBoxBadPairBudget (d B R r : ℕ) (L : ℝ) : ℝ := + 2 ^ (d - 1) * (1 / (B : ℝ) ^ (d - 1) + (R : ℝ) / L ^ d) + + ((2 * (r : ℝ) + 1) / L) ^ d + +theorem affine_parameter_bad_pair_probability {J : Type*} + [Fintype J] [DecidableEq J] (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (D Q B R r : ℕ) (a : J → ℤ) (hBQ : D * B ≤ Q) (hB : 0 < B) + (hdim : 2 ≤ Fintype.card J) {L : ℝ} (hL : 0 < L) + (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ)) + (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ)) : + ((integerBoxUniformWeights lo hi hlen).prod (integerBoxUniformWeights lo hi hlen)).eventProbability + (fun xy => affineParameterBadPair D Q r a + (fun j => (xy.1 j : ℤ)) (fun j => (xy.2 j : ℤ))) ≤ + integerBoxBadPairBudget (Fintype.card J) B R r L := by + unfold affineParameterBadPair integerBoxBadPairBudget + apply (finite_event_probability_or_le _ _ _).trans + exact add_le_add + (affine_parameter_pair_gcd_probability lo hi hlen D Q B R a hBQ hB hdim hL hside hwidth) + (integer_box_pair_near_probability_of_lengths lo hi hlen r hL hside) + +theorem sampled_affine_integer_box_error {Ω J : Type*} + [Fintype Ω] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights Ω) (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (D Q B R r : ℕ) (a : J → ℤ) (hBQ : D * B ≤ Q) (hB : 0 < B) + (hdim : 2 ≤ Fintype.card J) {L : ℝ} (hL : 0 < L) + (hside : ∀ j, L ≤ ((hi j - lo j : ℤ) : ℝ)) + (hwidth : ∀ j, hi j - lo j ≤ (R : ℤ)) + (e : Ω → (∀ j, Finset.Ico (lo j) (hi j)) → ℝ) + {C epsilon : ℝ} (hC : 0 ≤ C) (hepsilon : 0 ≤ epsilon) + (henergy : ∀ t, p.mean (fun x => e x t ^ 2) ≤ C) + (hgood : ∀ (t u : ∀ j, Finset.Ico (lo j) (hi j)), ¬ affineParameterBadPair D Q r a (fun j => (t j : ℤ)) (fun j => (u j : ℤ)) → + |p.mean (fun x => e x t * e x u)| ≤ epsilon) + (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ 1) : + |p.mean (fun x => w x * (𝔼 t, e x t))| ≤ + Real.sqrt (C * integerBoxBadPairBudget (Fintype.card J) B R r L + epsilon) := by + have h := sampled_weighted_error_of_energy p (integerBoxUniformWeights lo hi hlen) e + (fun tu => affineParameterBadPair D Q r a (fun j => (tu.1 j : ℤ)) (fun j => (tu.2 j : ℤ))) + hC hepsilon henergy + (affine_parameter_bad_pair_probability lo hi hlen D Q B R r a hBQ hB hdim hL hside hwidth) + (fun tu htu => hgood tu.1 tu.2 htu) w hw + simpa only [integerBoxUniformWeights_mean] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem expect_le_of_dependent_coordinate_slices {I : Type*} [Fintype I] [DecidableEq I] + {X : I → Type*} [∀ i, Fintype (X i)] [∀ i, Nonempty (X i)] + (i : I) (f : (∀ j, X j) → ℝ) (C : ℝ) + (hslice : ∀ x : ∀ j, X j, (𝔼 a : X i, f (Function.update x i a)) ≤ C) : + (𝔼 x : ∀ j, X j, f x) ≤ C := by + let e := Equiv.piSplitAt i X + have he := Fintype.expect_equiv e f (fun p => f (e.symm p)) (fun x => by simp) + rw [he, ← Finset.univ_product_univ, Finset.expect_product, Finset.expect_comm] + apply Finset.expect_le Finset.univ_nonempty + intro r _ + let x : ∀ j, X j := e.symm (Classical.choice inferInstance, r) + have hupdate (a : X i) : e.symm (a, r) = Function.update x i a := by + funext j + by_cases hj : j = i + · subst j + simp [e, Equiv.piSplitAt] + · simp [e, x, Equiv.piSplitAt, hj] + simpa only [hupdate] using hslice x + +theorem integer_box_affine_near_probability {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (lo hi : Option J × I → ℤ) (hlen : ∀ j, lo j < hi j) + (t : J → ℤ) (i : I) (b : ℤ) (r : ℕ) : + (integerBoxUniformWeights lo hi hlen).eventProbability + (fun z => |smoothAffineSample t (fun j => (z j : ℤ)) i - b| ≤ (r : ℤ)) ≤ + (2 * (r : ℝ) + 1) / ((hi (none, i) - lo (none, i) : ℤ) : ℝ) := by + let : ∀ j, Nonempty (Finset.Ico (lo j) (hi j)) := + fun j => ⟨⟨lo j, Finset.mem_Ico.mpr ⟨le_rfl, hlen j⟩⟩⟩ + unfold FiniteProbabilityWeights.eventProbability + rw [integerBoxUniformWeights_mean] + apply expect_le_of_dependent_coordinate_slices (none, i) + intro z + have h := interval_near_probability (lo (none, i)) (hi (none, i)) + (b - ∑ j, t j * (z (some j, i) : ℤ)) (hlen (none, i)) r + unfold FiniteProbabilityWeights.eventProbability at h + rw [intervalUniformWeights_mean] at h + convert h using 1 + apply Finset.expect_congr rfl + intro a _ + have he : smoothAffineSample t (fun j => ((Function.update z (none, i) a) j : ℤ)) i - b = + (a : ℤ) - (b - ∑ j, t j * (z (some j, i) : ℤ)) := by + simp [smoothAffineSample, Function.update] + ring + dsimp only + simp only [he] + split_ifs <;> rfl + +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators Classical + +variable {X : Type*} [Fintype X] [DecidableEq X] {N : X → ℕ} {q : ℕ} + +theorem fullSliceLaw_mean_eq_rectangle (S : ResidueBoxSlice N q) + (hlen : ∀ i, 0 < S.length i) (f : (X → ℤ) → ℝ) : + (S.fullSliceLaw hlen).mean (fun x => f x.val) = + (integerBoxUniformWeights (fun _ : X => 0) (fun i => (S.length i : ℤ)) + (fun i => by exact_mod_cast hlen i)).mean + (fun t => f (fun i => (S.start i : ℤ) + (q : ℤ) * (t i).val)) := by + rw [fullSliceLaw_mean, integerBoxUniformWeights_mean] + let forward (u : ∀ i, Fin (S.length i)) : + ∀ i, Finset.Ico (0 : ℤ) (S.length i : ℤ) := fun i => + ⟨((u i).val : ℤ), Finset.mem_Ico.mpr ⟨Int.natCast_nonneg _, by exact_mod_cast (u i).isLt⟩⟩ + apply Finset.expect_bij (fun u _ => forward u) + · intro u _ + exact Finset.mem_univ _ + · intro u _ + simp only [forward, fullSlicePointInIntegerBox, point, Nat.cast_add, Nat.cast_mul] + · intro u _ v _ he + funext i + apply Fin.ext + have hi := congrArg (fun t => (t i).val) he + dsimp only [forward] at hi + exact_mod_cast hi + · intro t _ + let u : ∀ i, Fin (S.length i) := fun i => + ⟨(t i).val.toNat, by have := Finset.mem_Ico.mp (t i).property; omega⟩ + refine ⟨u, Finset.mem_univ _, ?_⟩ + funext i + apply Subtype.ext + change (((t i).val.toNat : ℕ) : ℤ) = (t i).val + exact Int.toNat_of_nonneg (Finset.mem_Ico.mp (t i).property).1 + +omit [Fintype X] [DecidableEq X] in +theorem fullSliceRectangle_endpoint_bounds (S : ResidueBoxSlice N q) + (hlen : ∀ i, 0 < S.length i) {L C : ℝ} (hL : 0 < L) + (hN : ∀ i, (N i : ℝ) ≤ C * L) (i : X) : + |(S.start i : ℝ) / L| ≤ C ∧ + |((S.start i : ℝ) + (q : ℝ) * S.length i) / L| ≤ C + q / L := by + have hstart : S.start i < N i := by simpa using S.inside i 0 (hlen i) + have hlast := S.inside i (S.length i - 1) (by have := hlen i; omega) + have hend : S.start i + q * S.length i < N i + q := by + have he : S.start i + q * S.length i = + (S.start i + q * (S.length i - 1)) + q := by + have hl : S.length i = (S.length i - 1) + 1 := by have := hlen i; omega + conv_lhs => rw [hl] + ring + rw [he] + omega + have hstartR : (S.start i : ℝ) < N i := by exact_mod_cast hstart + have hendR : (S.start i : ℝ) + (q : ℝ) * S.length i < (N i : ℝ) + q := by + exact_mod_cast hend + constructor + · rw [abs_of_nonneg (div_nonneg (Nat.cast_nonneg _) hL.le)] + exact (div_le_iff₀ hL).mpr (hstartR.le.trans (hN i)) + · rw [abs_of_nonneg (by positivity)] + apply (div_le_iff₀ hL).mpr + rw [add_mul, div_mul_cancel₀ _ hL.ne'] + linarith [hN i] + +omit [Fintype X] [DecidableEq X] in +theorem fullSliceRectangle_endpoint_bounds_two (S : ResidueBoxSlice N q) + (hlen : ∀ i, 2 ≤ S.length i) {L C : ℝ} (hL : 0 < L) + (hN : ∀ i, (N i : ℝ) ≤ C * L) (i : X) : + |(S.start i : ℝ) / L| ≤ C ∧ + |((S.start i : ℝ) + (q : ℝ) * S.length i) / L| ≤ 2 * C := by + have hbase := fullSliceRectangle_endpoint_bounds S (fun i => by have := hlen i; omega) hL hN i + have hqN : q < N i := by + have h := S.inside i 1 (by have := hlen i; omega) + omega + have hqR : (q : ℝ) ≤ C * L := + (show (q : ℝ) ≤ (N i : ℝ) by exact_mod_cast hqN.le).trans (hN i) + have hqL : (q : ℝ) / L ≤ C := (div_le_iff₀ hL).mpr hqR + exact ⟨hbase.1, hbase.2.trans (by linarith)⟩ + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3 + +theorem integerBoxBadPairBudget_nonneg (d B R r : ℕ) {M : ℝ} (hM : 0 ≤ M) : + 0 ≤ integerBoxBadPairBudget d B R r M := by + unfold integerBoxBadPairBudget + positivity + +theorem integerBoxBadPairBudget_le_separated (d B R r : ℕ) {M C nu : ℝ} + (hd : 2 ≤ d) (hB : 0 < B) (hBM : (B : ℝ) ≤ M) (hC : 0 ≤ C) + (hR : (R : ℝ) ≤ C * M) (hr : (r : ℝ) ≤ nu * M) + (hinv : 1 / M ≤ nu) : + integerBoxBadPairBudget d B R r M ≤ + 2 ^ (d - 1) * (1 + C) / (B : ℝ) ^ (d - 1) + (3 * nu) ^ d := by + have hBp : (0 : ℝ) < B := by exact_mod_cast hB + have hM : 0 < M := hBp.trans_le hBM + have hpow : (B : ℝ) ^ (d - 1) ≤ M ^ (d - 1) := + pow_le_pow_left₀ hBp.le hBM _ + have hR' : (R : ℝ) / M ^ d ≤ C / (B : ℝ) ^ (d - 1) := by + calc + _ ≤ (C * M) / M ^ d := div_le_div_of_nonneg_right hR (by positivity) + _ = C / M ^ (d - 1) := by + conv_lhs => rw [show d = (d - 1) + 1 by omega, pow_succ] + field_simp + _ ≤ C / (B : ℝ) ^ (d - 1) := div_le_div_of_nonneg_left hC (by positivity) hpow + have hnear : (2 * (r : ℝ) + 1) / M ≤ 3 * nu := by + have hrr : (r : ℝ) / M ≤ nu := (div_le_iff₀ hM).mpr hr + calc + _ = 2 * ((r : ℝ) / M) + 1 / M := by ring + _ ≤ 3 * nu := by linarith + unfold integerBoxBadPairBudget + calc + _ ≤ 2 ^ (d - 1) * (1 / (B : ℝ) ^ (d - 1) + C / (B : ℝ) ^ (d - 1)) + + (3 * nu) ^ d := add_le_add + (mul_le_mul_of_nonneg_left (add_le_add le_rfl hR') (by positivity)) + (pow_le_pow_left₀ (by positivity) hnear d) + _ = _ := by ring + +theorem integerBoxBadPairBudget_le_linear (d B R r : ℕ) {M C nu : ℝ} + (hd : 2 ≤ d) (hB : 0 < B) (hBM : (B : ℝ) ≤ M) (hC : 0 ≤ C) + (hR : (R : ℝ) ≤ C * M) (hr : (r : ℝ) ≤ nu * M) + (hinv : 1 / M ≤ nu) (hnu : nu ≤ 1) : + integerBoxBadPairBudget d B R r M ≤ + 2 ^ (d - 1) * (1 + C) / (B : ℝ) + 3 ^ d * nu := by + have hB1 : (1 : ℝ) ≤ B := by exact_mod_cast hB + have hBp : (0 : ℝ) < B := by exact_mod_cast hB + have hM : 0 < M := hBp.trans_le hBM + have hnu0 : 0 ≤ nu := (by positivity : 0 ≤ 1 / M).trans hinv + have hpow : (B : ℝ) ≤ (B : ℝ) ^ (d - 1) := by + simpa only [pow_one] using pow_le_pow_right₀ hB1 (show 1 ≤ d - 1 by omega) + have hnpow : nu ^ d ≤ nu := by + obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (show d ≠ 0 by omega) + rw [pow_succ] + exact (mul_le_mul_of_nonneg_right (pow_le_one₀ hnu0 hnu) hnu0).trans_eq (one_mul nu) + apply (integerBoxBadPairBudget_le_separated d B R r hd hB hBM hC hR hr hinv).trans + apply add_le_add + · exact div_le_div_of_nonneg_left (by positivity) hBp hpow + · rw [mul_pow] + exact mul_le_mul_of_nonneg_left hnpow (by positivity) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerBox_weighted_joint_mean + {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (lo hi : I → ℤ) (hsource : ∀ i, lo i < hi i) + (parLo parHi : J → ℤ) (hparam : ∀ j, parLo j < parHi j) + (w : (I → ℤ) → ℝ) (f : (I → ℤ) → (∀ j, Finset.Ico (parLo j) (parHi j)) → ℝ) : + ((integerBoxUniformWeights parLo parHi hparam).prod + (integerBoxUniformWeights lo hi hsource)).mean + (fun tx => w (fun i => (tx.2 i).val) * f (fun i => (tx.2 i).val) tx.1) = + 𝔼 z ∈ Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)), w z * (𝔼 t, f z t) := by + rw [FiniteProbabilityWeights.mean_prod, FiniteProbabilityWeights.mean_comm] + simp only [FiniteProbabilityWeights.mean_const_mul, integerBoxUniformWeights_mean] + rw [← finiteBoxPoints_expect (fun i => Finset.Ico (lo i) (hi i)) (fun z => w z * (𝔼 t, f z t))] + simp only [Finset.expect_eq_sum_div_card, Finset.card_univ, Fintype.card_coe] + congr 1 + simpa only [Finset.expect_eq_sum_div_card, Finset.card_univ] using + Finset.sum_coe_sort (Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i))) + (fun z => w z * (𝔼 t, f z t)) + +theorem integerBox_joint_error_of_window_tests + {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (lo hi : I → ℤ) (hsource : ∀ i, lo i < hi i) + (parLo parHi : J → ℤ) (hparam : ∀ j, parLo j < parHi j) + (f : (I → ℤ) → (∀ j, Finset.Ico (parLo j) (parHi j)) → ℝ) (accuracy : ℝ) + (htest : ∀ v : (I → ℤ) → ℝ, (∀ z, 0 ≤ v z ∧ v z ≤ 1) → + |𝔼 z ∈ Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)), v z * (𝔼 t, f z t)| ≤ accuracy) + (w : (I → ℤ) → ℝ) + (hw : ∀ z : (∀ i, Finset.Ico (lo i) (hi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) : + |((integerBoxUniformWeights parLo parHi hparam).prod + (integerBoxUniformWeights lo hi hsource)).mean + (fun tx => w (fun i => (tx.2 i).val) * f (fun i => (tx.2 i).val) tx.1)| ≤ accuracy := by + let W := Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)) + have hwW (z) (hz : z ∈ W) : 0 ≤ w z ∧ w z ≤ 1 := by + exact hw (fun i => ⟨z i, Fintype.mem_piFinset.mp hz i⟩) + have h := htest (realZeroExtendFinset W w) (realZeroExtendFinset_unit W w hwW) + rw [integerBox_weighted_joint_mean lo hi hsource parLo parHi hparam w f] + convert h using 2 + apply Finset.expect_congr rfl + intro z hz + rw [realZeroExtendFinset_on W w hz] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def physicalBoundaryBudget {I : Type*} [Fintype I] + (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) (r : I → ℕ) (width : I → ℝ) : ℝ := + ∑ i, 2 * (Fintype.card (P i).Label : ℝ) * (2 * (r i : ℝ) + 1) / width i + +theorem integer_box_physical_boundary_probability {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ j, sourceLo j < sourceHi j) + (t : J → ℤ) (lo : I → ℤ) (N : I → ℕ) + (P : ∀ i, FiniteProgressionPartition (N i)) (r : I → ℕ) : + (integerBoxUniformWeights sourceLo sourceHi hsource).eventProbability + (fun z => physicalBoundaryNear lo N P r (smoothAffineSample t (fun j => (z j : ℤ)))) ≤ + physicalBoundaryBudget N P r (fun i => ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) := by + let p := integerBoxUniformWeights sourceLo sourceHi hsource + let E := fun (e : Σ i, (P i).Label) (z : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) => + |smoothAffineSample t (fun j => (z j : ℤ)) e.1 - intervalCellLower (lo e.1) (P e.1) e.2| ≤ (r e.1 : ℤ) ∨ + |smoothAffineSample t (fun j => (z j : ℤ)) e.1 - intervalCellUpper (lo e.1) (P e.1) e.2| ≤ (r e.1 : ℤ) + have hE (e : Σ i, (P i).Label) : p.eventProbability (E e) ≤ + 2 * ((2 * (r e.1 : ℝ) + 1) / ((sourceHi (none, e.1) - sourceLo (none, e.1) : ℤ) : ℝ)) := by + apply (p.eventProbability_or_le _ _).trans + have hleft := integer_box_affine_near_probability sourceLo sourceHi hsource t e.1 + (intervalCellLower (lo e.1) (P e.1) e.2) (r e.1) + have hright := integer_box_affine_near_probability sourceLo sourceHi hsource t e.1 + (intervalCellUpper (lo e.1) (P e.1) e.2) (r e.1) + linarith + have hcover (z : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) + (h : physicalBoundaryNear lo N P r (smoothAffineSample t (fun j => (z j : ℤ)))) : ∃ e, E e z := by + obtain ⟨i, c, hc⟩ := h + exact ⟨⟨i, c⟩, hc⟩ + apply (p.eventProbability_union_bound _ E hcover).trans + calc + _ ≤ ∑ e : Σ i, (P i).Label, + 2 * ((2 * (r e.1 : ℝ) + 1) / ((sourceHi (none, e.1) - sourceLo (none, e.1) : ℤ) : ℝ)) := + Finset.sum_le_sum (fun e _ => hE e) + _ = _ := by + rw [Fintype.sum_sigma] + unfold physicalBoundaryBudget + apply Finset.sum_congr rfl + intro i _ + dsimp only + rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + ring + +theorem sampled_physical_boundary_probability {J I T : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] [Fintype T] + (parameterLaw : FiniteProbabilityWeights T) (parameter : T → J → ℤ) + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ j, sourceLo j < sourceHi j) + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) (r : I → ℕ) : + (parameterLaw.prod (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (fun tz => physicalBoundaryNear lo N P r (smoothAffineSample (parameter tz.1) (fun j => (tz.2 j : ℤ)))) ≤ + physicalBoundaryBudget N P r (fun i => ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) := by + unfold FiniteProbabilityWeights.eventProbability + rw [FiniteProbabilityWeights.mean_prod] + apply (parameterLaw.mean_mono (fun t => + integer_box_physical_boundary_probability sourceLo sourceHi hsource (parameter t) lo N P r)).trans_eq + exact parameterLaw.mean_const _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def physicalMeshCrossing {I X M : Type*} [Fintype I] [DecidableEq I] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (mesh : X → M) (location : X → I → ℤ) (x : X) : Prop := + ∃ y, mesh y = mesh x ∧ physicalBoxClassify lo N P (location x) ≠ physicalBoxClassify lo N P (location y) + +theorem retained_mesh_cell_constant {I X M : Type*} [Fintype I] [DecidableEq I] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (mesh : X → M) (location : X → I → ℤ) (x : X) + (hx : ¬ physicalMeshCrossing lo N P mesh location x) : + ∀ y, mesh y = mesh x → physicalBoxClassify lo N P (location y) = physicalBoxClassify lo N P (location x) := by + intro y hy + by_contra h + exact hx ⟨y, hy, Ne.symm h⟩ + +theorem physicalMeshCrossing_congr {I X M : Type*} [Fintype I] [DecidableEq I] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (mesh : X → M) (location : X → I → ℤ) {x y : X} (hxy : mesh x = mesh y) : + physicalMeshCrossing lo N P mesh location x ↔ physicalMeshCrossing lo N P mesh location y := by + have transfer (u v : X) (huv : mesh u = mesh v) + (hu : physicalMeshCrossing lo N P mesh location u) : physicalMeshCrossing lo N P mesh location v := by + obtain ⟨z, hz, huz⟩ := hu + by_cases hvz : physicalBoxClassify lo N P (location v) = physicalBoxClassify lo N P (location z) + · exact ⟨u, huv, fun hvu => huz (hvu.symm.trans hvz)⟩ + · exact ⟨z, hz.trans huv, hvz⟩ + exact ⟨transfer x y hxy, transfer y x hxy.symm⟩ + +theorem physicalMeshCrossing_subset_boundary {I X M : Type*} [Fintype I] [DecidableEq I] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (mesh : X → M) (location : X → I → ℤ) (r : I → ℕ) + (hmove : ∀ x y, mesh y = mesh x → ∀ i, |location x i - location y i| ≤ (r i : ℤ)) + (x : X) (hx : physicalMeshCrossing lo N P mesh location x) : + physicalBoundaryNear lo N P r (location x) := by + by_contra hn + obtain ⟨y, hy, hxy⟩ := hx + exact hxy (physicalBoxClassify_stable lo N P hstep hpos r (location x) (location y) (hmove x y hy) hn) + +theorem affine_mesh_crossing_probability {J I T SCell TCell : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] [Fintype T] + (parameterLaw : FiniteProbabilityWeights T) (parameter : T → J → ℤ) + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ j, sourceLo j < sourceHi j) + (sourceCell : (∀ j, Finset.Ico (sourceLo j) (sourceHi j)) → SCell) (parameterCell : T → TCell) + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (r : I → ℕ) (r0 rV V : I → ℝ) (Tcap rt : ℝ) (hT : 0 ≤ Tcap) (hV : ∀ i, 0 ≤ V i) + (ht : ∀ t j, |(parameter t j : ℝ)| ≤ Tcap) + (hv : ∀ (z : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) j i, |((z (some j, i) : ℤ) : ℝ)| ≤ V i) + (hbase : ∀ z w, sourceCell w = sourceCell z → ∀ i, + |((z (none, i) : ℤ) : ℝ) - ((w (none, i) : ℤ) : ℝ)| ≤ r0 i) + (hdir : ∀ z w, sourceCell w = sourceCell z → ∀ j i, + |((z (some j, i) : ℤ) : ℝ) - ((w (some j, i) : ℤ) : ℝ)| ≤ rV i) + (hparam : ∀ t u, parameterCell u = parameterCell t → ∀ j, + |(parameter t j : ℝ) - parameter u j| ≤ rt) + (hbudget : ∀ i, r0 i + (Fintype.card J : ℝ) * (Tcap * rV i + V i * rt) ≤ (r i : ℝ)) : + (parameterLaw.prod (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (physicalMeshCrossing lo N P + (fun tz => (sourceCell tz.2, parameterCell tz.1)) + (fun tz => smoothAffineSample (parameter tz.1) (fun j => (tz.2 j : ℤ)))) ≤ + physicalBoundaryBudget N P r (fun i => ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) := by + let mesh := fun tz : T × (∀ j, Finset.Ico (sourceLo j) (sourceHi j)) => + (sourceCell tz.2, parameterCell tz.1) + let location := fun tz : T × (∀ j, Finset.Ico (sourceLo j) (sourceHi j)) => + smoothAffineSample (parameter tz.1) (fun j => (tz.2 j : ℤ)) + have hmove (x y : T × (∀ j, Finset.Ico (sourceLo j) (sourceHi j))) (he : mesh y = mesh x) (i : I) : + |location x i - location y i| ≤ (r i : ℤ) := by + have hs : sourceCell y.2 = sourceCell x.2 := congrArg Prod.fst he + have hp : parameterCell y.1 = parameterCell x.1 := congrArg Prod.snd he + have h := (smoothAffineSample_variation (parameter x.1) (parameter y.1) + (fun j => (x.2 j : ℤ)) (fun j => (y.2 j : ℤ)) i hT (hV i) (ht x.1) (fun j => hv y.2 j i) + (hbase x.2 y.2 hs i) (fun j => hdir x.2 y.2 hs j i) (hparam x.1 y.1 hp)).trans (hbudget i) + exact_mod_cast h + apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ + (physicalMeshCrossing_subset_boundary lo N P hstep hpos mesh location r hmove)).trans + exact sampled_physical_boundary_probability parameterLaw parameter sourceLo sourceHi hsource lo N P r + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshScalarTail.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshScalarTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..44361d73d0e62a897c60bb0e24b0e11bfeed80e2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineMeshScalarTail.lean @@ -0,0 +1,336 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteRetainedCellMean +import OAI.Combinatorics.Progressions.Estimates.PhysicalZeroExtension +import OAI.Combinatorics.Progressions.Estimates.RetainedPhysicalDifference +import OAI.Combinatorics.Progressions.Lattices.ConcreteAffineMeshBoundary + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affine_mesh_truncation_bound + {ι I J : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] [Fintype J] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hPstep : ∀ i c, (P i).step c = 1) (hPpos : ∀ i c, 0 < (P i).length c) + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ i, sourceLo i < sourceHi i) + (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat) + (hSstep : ∀ i c, (S i).step c = 1) (hSpos : ∀ i c, 0 < (S i).length c) + (paramLo paramHi : J → ℤ) (hparam : ∀ j, paramLo j < paramHi j) + (T : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat) + (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c) + (D : ℕ) (a : J → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ) + (w : (Option J × I → ℤ) → ℝ) (h g : (I → ℤ) → ℝ) + (hw : ∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) + (hh : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ h x ∧ h x ≤ 1) + (hg : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ g x ∧ g x ≤ 1) + {etaParam etaSite r R beta : ℝ} (hetaParam : 0 ≤ etaParam) (hetaSite : 0 ≤ etaSite) + (hr : 0 ≤ r) (hR : 0 ≤ R) + (hcloseParam : ∀ ct : (∀ j, (T j).Label), + ProductMarginalsClose (primeCoordinateReference (σ := J) q) + (residuePrimeCoordinateDensity (fun j => intervalCellLower (paramLo j) (T j) (ct j)) + (fun j => (T j).length (ct j)) 1 (fun _ => 0) + (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct) + q (fun _ => 1)) etaParam b) + (hcloseSite : ∀ c : (∀ i, (P i).Label), + ProductMarginalsClose (primeCoordinateReference (σ := I) q) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) + q (fun _ => 1)) etaSite b) + (hreference : ∀ cs : (∀ i, (S i).Label), ∀ c : (∀ i, (P i).Label), + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) + (fun i => (S i).length (cs i)) 1 (fun _ => 0) + (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) q w) + (fun x => residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q h x - + r * residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q g x) ≤ R) + (hbad : ((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (physicalMeshCrossing lo N P + (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1)) + (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))) ≤ beta) : + ((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * + (physicalBoxTruncation lo N P hPpos q b h + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)) - + r * physicalBoxTruncation lo N P hPpos q b g + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))) ≤ + R + (1 + r) * (etaParam + beta) * residueTruncationCap ι b etaSite := by + let : Nonempty (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) := + ⟨fun i => ⟨sourceLo i, Finset.mem_Ico.mpr ⟨le_rfl, hsource i⟩⟩⟩ + let : Nonempty (∀ j, Finset.Ico (paramLo j) (paramHi j)) := + ⟨fun j => ⟨paramLo j, Finset.mem_Ico.mpr ⟨le_rfl, hparam j⟩⟩⟩ + let ps := FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) + let pt := FiniteProbabilityWeights.uniform (∀ j, Finset.Ico (paramLo j) (paramHi j)) + let p := pt.prod ps + let ms := integerBoxMesh sourceLo sourceHi S + let mt := integerBoxMesh paramLo paramHi T + let mesh := fun tz : (∀ j, Finset.Ico (paramLo j) (paramHi j)) × + (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) => (ms tz.2, mt tz.1) + let location := fun tz : (∀ j, Finset.Ico (paramLo j) (paramHi j)) × + (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) => + smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val) + let bad := physicalMeshCrossing lo N P mesh location + let value := fun (z : Option J × I → ℤ) (t : J → ℤ) => w z * + (physicalBoxTruncation lo N P hPpos q b h (smoothAffineSample (fun j => a j + (D : ℤ) * t j) z) - + r * physicalBoxTruncation lo N P hPpos q b g (smoothAffineSample (fun j => a j + (D : ℤ) * t j) z)) + let F := fun tz : (∀ j, Finset.Ico (paramLo j) (paramHi j)) × + (∀ i, Finset.Ico (sourceLo i) (sourceHi i)) => value (fun i => (tz.2 i).val) (fun j => (tz.1 j).val) + let cap := residueTruncationCap ι b etaSite + let K := R + (1 + r) * etaParam * cap + have hcap0 : 0 ≤ cap := residueTruncationCap_nonneg ι b hetaSite + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hsLaw : integerBoxUniformWeights sourceLo sourceHi hsource = ps := + integerBoxUniformWeights_eq_uniform sourceLo sourceHi hsource + have htLaw : integerBoxUniformWeights paramLo paramHi hparam = pt := + integerBoxUniformWeights_eq_uniform paramLo paramHi hparam + rw [hsLaw, htLaw] at hbad ⊢ + change p.eventProbability bad ≤ beta at hbad + change p.mean F ≤ R + (1 + r) * (etaParam + beta) * cap + have hlocal (x) (hx : ¬ bad x) : finiteCellMean p mesh F (mesh x) ≤ K * (finiteCellWeights p mesh).weight (mesh x) := by + let cs := ms x.2 + let ct := mt x.1 + have hclass := retained_integer_mesh_boxes_classify lo N P sourceLo sourceHi S hSstep hSpos + paramLo paramHi T hTstep hTpos D a x hx + have hwcell (z) (hz : z ∈ translatedIntegerBox + (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) (fun i => (S i).length (cs i))) : + 0 ≤ w z ∧ w z ≤ 1 := by + obtain ⟨y, _, hy⟩ := integerBoxMesh_cell_realize sourceLo sourceHi S hSstep hSpos cs z hz + simpa only [hy] using hw y + have havg : (𝔼 z : IntegerResidueBox (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) + (fun i => intervalCellLower (sourceLo i) (S i) (cs i) + (S i).length (cs i)) (fun _ => 1) (fun _ => 0), + 𝔼 t : IntegerResidueBox (fun j => intervalCellLower (paramLo j) (T j) (ct j)) + (fun j => intervalCellLower (paramLo j) (T j) (ct j) + (T j).length (ct j)) (fun _ => 1) (fun _ => 0), + value (fun i => (z i).val) (fun j => (t j).val)) ≤ K := by + cases hc : physicalBoxClassify lo N P (location x) with + | some c => + have ht := retained_physical_truncation_difference_le lo N P hPstep hPpos c q + (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) (fun i => (S i).length (cs i)) + (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) + (fun j => intervalCellLower (paramLo j) (T j) (ct j)) (fun j => (T j).length (ct j)) + (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct) + D a b w h g hwcell hh hg + (fun z hz t ht => (hclass z hz t ht).trans hc) hetaParam hetaSite hr + (hcloseParam ct) (hcloseSite c) (hreference cs c) + simpa only [value, K, cap, ← Finset.mul_expect] using ht + | none => + have he (z : IntegerResidueBox (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) + (fun i => intervalCellLower (sourceLo i) (S i) (cs i) + (S i).length (cs i)) (fun _ => 1) (fun _ => 0)) + (t : IntegerResidueBox (fun j => intervalCellLower (paramLo j) (T j) (ct j)) + (fun j => intervalCellLower (paramLo j) (T j) (ct j) + (T j).length (ct j)) (fun _ => 1) (fun _ => 0)) : + value (fun i => (z i).val) (fun j => (t j).val) = 0 := by + have hnone := (hclass (fun i => (z i).val) + ((mem_translatedIntegerBox _ _ _).mpr (fun i => Finset.mem_Ico.mp (Finset.mem_filter.mp (z i).property).1)) + (fun j => (t j).val) + ((mem_translatedIntegerBox _ _ _).mpr (fun j => Finset.mem_Ico.mp (Finset.mem_filter.mp (t j).property).1))).trans hc + dsimp only [value] + rw [physicalBoxTruncation_of_classify_none lo N P hPpos q b h _ hnone, + physicalBoxTruncation_of_classify_none lo N P hPpos q b g _ hnone] + ring + simpa only [he, Finset.expect_const_zero] using hK + have hm := integerBoxMesh_pair_cell_mean sourceLo sourceHi S hSstep hSpos + paramLo paramHi T hTstep hTpos cs ct value + have hwgt := finiteCellWeights_product ps pt ms mt cs ct + change finiteCellMean p mesh F (cs,ct) ≤ K * (finiteCellWeights p mesh).weight (cs,ct) + rw [hm, hwgt] + exact (mul_le_mul_of_nonneg_left havg + (mul_nonneg ((finiteCellWeights ps ms).nonneg cs) ((finiteCellWeights pt mt).nonneg ct))).trans_eq (mul_comm _ _) + have hbound (x) (_ : bad x) : |F x| ≤ (1 + r) * cap := by + have hhc := physicalBoxTruncation_cap lo N P hPstep hPpos q b h hh hetaSite hcloseSite (location x) + have hgc := physicalBoxTruncation_cap lo N P hPstep hPpos q b g hg hetaSite hcloseSite (location x) + have hd : |physicalBoxTruncation lo N P hPpos q b h (location x) - + r * physicalBoxTruncation lo N P hPpos q b g (location x)| ≤ (1 + r) * cap := by + apply (abs_sub _ _).trans + rw [abs_mul, abs_of_nonneg hr] + exact (add_le_add hhc (mul_le_mul_of_nonneg_left hgc hr)).trans_eq (by dsimp only [cap]; ring) + change |w (fun i => (x.2 i).val) * + (physicalBoxTruncation lo N P hPpos q b h (location x) - + r * physicalBoxTruncation lo N P hPpos q b g (location x))| ≤ _ + rw [abs_mul, abs_of_nonneg (hw x.2).1] + exact (mul_le_mul (hw x.2).2 hd (abs_nonneg _) zero_le_one).trans_eq (one_mul _) + have hall := finite_mean_le_of_retained_cells p mesh bad F + (fun x y hxy => physicalMeshCrossing_congr lo N P mesh location hxy) + hK (by positivity : 0 ≤ (1 + r) * cap) hbad hbound hlocal + exact hall.trans_eq (by dsimp only [K]; ring) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affine_mesh_zero_extension_bound + {ι I J : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] [Fintype J] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hPstep : ∀ i c, (P i).step c = 1) (hPpos : ∀ i c, 0 < (P i).length c) + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ i, sourceLo i < sourceHi i) + (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat) + (hSstep : ∀ i c, (S i).step c = 1) (hSpos : ∀ i c, 0 < (S i).length c) + (paramLo paramHi : J → ℤ) (hparam : ∀ j, paramLo j < paramHi j) + (T : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat) + (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c) + (D : ℕ) (a : J → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ) + (w : (Option J × I → ℤ) → ℝ) (h g : (I → ℤ) → ℝ) + (hw : ∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) + (hh : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ h x ∧ h x ≤ 1) + (hg : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ g x ∧ g x ≤ 1) + {etaParam etaSite r R beta accuracy : ℝ} (hetaParam : 0 ≤ etaParam) (hetaSite : 0 ≤ etaSite) + (hr : 0 ≤ r) (hR : 0 ≤ R) + (hcloseParam : ∀ ct : (∀ j, (T j).Label), + ProductMarginalsClose (primeCoordinateReference (σ := J) q) + (residuePrimeCoordinateDensity (fun j => intervalCellLower (paramLo j) (T j) (ct j)) + (fun j => (T j).length (ct j)) 1 (fun _ => 0) + (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct) + q (fun _ => 1)) etaParam b) + (hcloseSite : ∀ c : (∀ i, (P i).Label), + ProductMarginalsClose (primeCoordinateReference (σ := I) q) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) + q (fun _ => 1)) etaSite b) + (hreference : ∀ cs : (∀ i, (S i).Label), ∀ c : (∀ i, (P i).Label), + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) + (fun i => (S i).length (cs i)) 1 (fun _ => 0) + (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) q w) + (fun x => residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q h x - + r * residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q g x) ≤ R) + (hbad : ((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (physicalMeshCrossing lo N P + (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1)) + (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))) ≤ beta) + (heh : |((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b h + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy) + (heg : |((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b g + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy) : + ((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * + (realZeroExtendFinset (translatedIntegerBox lo N) h + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)) - + r * realZeroExtendFinset (translatedIntegerBox lo N) g + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))) ≤ + R + (1 + r) * ((etaParam + beta) * residueTruncationCap ι b etaSite + accuracy) := by + have hlow := affine_mesh_truncation_bound lo N P hPstep hPpos + sourceLo sourceHi hsource S hSstep hSpos paramLo paramHi hparam T hTstep hTpos + D a q b w h g hw hh hg hetaParam hetaSite hr hR hcloseParam hcloseSite hreference hbad + have hrestore := physical_zero_extension_restore_difference + ((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)) + (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)) + (fun tz => w (fun i => (tz.2 i).val)) lo N P hPstep hPpos q b h g hr heh heg hlow + exact hrestore.trans_eq (by ring) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affine_mesh_scalar_tail + {ι I J : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] [Fintype J] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hPstep : ∀ i c, (P i).step c = 1) (hPpos : ∀ i c, 0 < (P i).length c) + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ i, sourceLo i < sourceHi i) + (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat) + (hSstep : ∀ i c, (S i).step c = 1) (hSpos : ∀ i c, 0 < (S i).length c) + (paramLo paramHi : J → ℤ) (hparam : ∀ j, paramLo j < paramHi j) + (T : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat) + (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c) + (D : ℕ) (a : J → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ) + (h g : (I → ℤ) → ℝ) + (hh : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ h x ∧ h x ≤ 1) + (hg : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ g x ∧ g x ≤ 1) + {etaParam etaSite r R beta accuracy : ℝ} (hetaParam : 0 ≤ etaParam) (hetaSite : 0 ≤ etaSite) + (hr : 0 ≤ r) (hR : 0 ≤ R) + (hcloseParam : ∀ ct : (∀ j, (T j).Label), + ProductMarginalsClose (primeCoordinateReference (σ := J) q) + (residuePrimeCoordinateDensity (fun j => intervalCellLower (paramLo j) (T j) (ct j)) + (fun j => (T j).length (ct j)) 1 (fun _ => 0) + (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) T hTpos ct) + q (fun _ => 1)) etaParam b) + (hcloseSite : ∀ c : (∀ i, (P i).Label), + ProductMarginalsClose (primeCoordinateReference (σ := I) q) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) + q (fun _ => 1)) etaSite b) + (hreference : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) → + ∀ cs : (∀ i, (S i).Label), ∀ c : (∀ i, (P i).Label), + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) + (fun i => (S i).length (cs i)) 1 (fun _ => 0) + (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) q w) + (fun x => residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q h x - + r * residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) q g x) ≤ R) + (hbad : ((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (physicalMeshCrossing lo N P + (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1)) + (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))) ≤ beta) + (heh : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) → + |((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b h + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy) + (heg : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) → + |((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos q b g + (smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy) + (p dominationLog : ℝ) + (outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i))) + (hdom : ∀ z, outer.weight z ≤ Real.exp dominationLog * + (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) + (herror : R + (1 + r) * ((etaParam + beta) * residueTruncationCap ι b etaSite + accuracy) ≤ + Real.exp (-(2 * p + dominationLog)) / 2) : + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights paramLo paramHi hparam).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) h + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + r * realZeroExtendFinset (translatedIntegerBox lo N) g + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ + Real.exp (-p) := by + apply fixedParameter_observed_tail_dominated + (integerBoxUniformWeights sourceLo sourceHi hsource) outer + (integerBoxUniformWeights paramLo paramHi hparam) (fun z i => (z i).val) + (fun t z => realZeroExtendFinset (translatedIntegerBox lo N) h + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) z) - + r * realZeroExtendFinset (translatedIntegerBox lo N) g + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) z)) p dominationLog hdom + intro w hw + exact (affine_mesh_zero_extension_bound lo N P hPstep hPpos sourceLo sourceHi hsource + S hSstep hSpos paramLo paramHi hparam T hTstep hTpos D a q b w h g hw hh hg + hetaParam hetaSite hr hR hcloseParam hcloseSite (hreference w hw) hbad + (heh w hw) (heg w hw)).trans herror + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineModerateGeometricApproximation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineModerateGeometricApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..660d4e2348b099730908ca914278612998686a09 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineModerateGeometricApproximation.lean @@ -0,0 +1,243 @@ +import OAI.Combinatorics.Progressions.Fourier.AffineTorusGeometry +import OAI.Combinatorics.Progressions.Lattices.WeightedSliceIntegerImage + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def affinePrimitiveEnvelope (I : Type*) [Fintype I] + (A B T : ℝ≥0) (M V : ℕ) : ℝ := + max 1 (max (scalarCubePrimitiveEnvelope I A B T M) + (max (scalarCubePrimitiveEnvelope Empty A B T M) ((V * M : ℕ) : ℝ))) + +theorem affinePrimitiveEnvelope_one_le (I : Type*) [Fintype I] (A B T : ℝ≥0) (M V : ℕ) : + 1 ≤ affinePrimitiveEnvelope I A B T M V := le_max_left _ _ + +theorem affinePrimitiveEnvelope_vector (I : Type*) [Fintype I] [DecidableEq I] + (s : NormalizedScalarCubeSource I) (A B T : ℝ≥0) (M V : ℕ) + (hM : s.modulusBound ≤ M) (hB : s.weightBound ≤ B) (hT : s.weightLipschitz ≤ T) : + ScalarCubePrimitiveBudget s A (affinePrimitiveEnvelope I A B T M V) := + (scalarCubePrimitiveBudget_of_raw_bounds s A B T M hM hB hT).mono + ((le_max_left _ _).trans (le_max_right _ _)) + +theorem affinePrimitiveEnvelope_coefficient (I : Type*) [Fintype I] + (s : NormalizedScalarCubeSource Empty) (A B T : ℝ≥0) (M V : ℕ) + (hM : s.modulusBound ≤ M) (hB : s.weightBound ≤ B) (hT : s.weightLipschitz ≤ T) : + ScalarCubePrimitiveBudget s A (affinePrimitiveEnvelope I A B T M V) := + (scalarCubePrimitiveBudget_of_raw_bounds s A B T M hM hB hT).mono + ((le_max_left _ _).trans ((le_max_right _ _).trans (le_max_right _ _))) + +theorem affinePrimitiveEnvelope_stride (I : Type*) [Fintype I] (A B T : ℝ≥0) (M V : ℕ) + {v m : ℕ} (hv : v ≤ V) (hm : m ≤ M) : + ((v * m : ℕ) : ℝ) ≤ affinePrimitiveEnvelope I A B T M V := by + have hvm : ((v * m : ℕ) : ℝ) ≤ ((V * M : ℕ) : ℝ) := by exact_mod_cast Nat.mul_le_mul hv hm + exact hvm.trans ((le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +theorem affineCube_geometric_approximation {B I : Type*} + [Fintype B] [Nonempty B] [DecidableEq B] [Fintype I] [DecidableEq I] + {n K : ℕ} [NeZero K] (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ) + (A W T : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (M V : ℕ) + (hM : ∀ b j, (s b j).modulusBound ≤ M) (hW : ∀ b j, (s b j).weightBound ≤ W) + (hT : ∀ b j, (s b j).weightLipschitz ≤ T) (hv : ∀ b j i, 0 < v b j i) + (hvV : ∀ b j i, v b j i ≤ V) {C F D E ε : ℝ} + (hC : 0 ≤ C) (hD : 0 ≤ D) (hE : 0 ≤ E) (hε : 0 < ε) (hε1 : ε ≤ 1) + (hcoord : ∀ b j i, |(u b j i : ℝ)| + (v b j i : ℝ) * (s b j).length ≤ C * (s b j).length) + (hupper : ∀ b, (∏ j, ((s b j).length : ℝ)) ≤ F * K) + (hlower : ∀ b, (K : ℝ) ≤ D * ∏ j, ((s b j).length : ℝ)) + (p : ℕ) (hpower : ∀ b j, (K : ℝ) ≤ E * ((s b j).length : ℝ) ^ p) + (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n + 1) + (hB : uniformSpectrumBlockCount n J.card (p * J.card) ≤ Fintype.card B) : + let U := affinePrimitiveEnvelope I A W T M V + let Q := affineTorusRadius (Fintype.card I) (n + 1) (Fintype.card B) C F + let R := affineTorusFactor (Fintype.card I) (n + 1) (Fintype.card B) C F + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + ∃ S : Finset (J → Fin (R * K)), + (S.card : ℝ) ≤ uniformSpectrumSizeConstant n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) / + ε ^ max (majorArcSpectrumExponent n J.card) (majorArcLengthExponent n * (p * J.card)) ∧ + (∑ k, ‖∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) (R * K) J k‖) ≤ + uniformSpectrumAbsoluteCap n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ∧ + (∀ k ∈ S, ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ uniformCharacterDenominatorBound n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ζ ∧ + ∃ (a : J → ℤ) (ξ : J → ℝ), + (∀ Z, |ξ Z| ≤ 2 * majorArcCoverConstant n J.card U ((R : ℝ) * D) / ζ ^ majorArcCoverExponent n J.card) ∧ + ∀ Z, ((k Z).val : ℝ) / (R * K) = (a Z : ℝ) / d + ξ Z / K) ∧ + ∀ center z : J → ℤ, centeredFundamentalBox Q K center z → + ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedCubeIntegerSource s) + (affineWeightedCubeIntegerSum s u v J center) z : ℝ) : ℂ) - + integerGridApproximation (weightedCubeIntegerSource s) + (affineWeightedCubeIntegerSum s u v J center) K (R * K) S z‖ ≤ ε := by + let U := affinePrimitiveEnvelope I A W T M V + let Q := affineTorusRadius (Fintype.card I) (n + 1) (Fintype.card B) C F + let R := affineTorusFactor (Fintype.card I) (n + 1) (Fintype.card B) C F + have hU : 1 ≤ U := affinePrimitiveEnvelope_one_le I A W T M V + have h (b) (j) : ScalarCubePrimitiveBudget (s b j) A U := + affinePrimitiveEnvelope_vector I (s b j) A W T M V (hM b j) (hW b j) (hT b j) + have hstride (b) (j) (i) : ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U := + affinePrimitiveEnvelope_stride I A W T M V (hvV b j i) ((s b j).modulus_le i |>.trans (hM b j)) + have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K) + have hR : 0 < R := affineTorusFactor_pos _ _ _ _ _ + obtain ⟨m, hm, hmin, hsize⟩ := exists_scaled_grid_minimum + (fun x : B × Fin (n + 1) => (s x.1 x.2).length) + (fun x => (s x.1 x.2).length_pos) (R := R) p J.card (fun x => hpower x.1 x.2) + have hVD : 0 ≤ (R : ℝ) * D := by positivity + have hWE : 0 ≤ ((R : ℝ) * E) ^ J.card := by positivity + have hscale (b : B) : ((R * K : ℕ) : ℝ) / ∏ j, ((s b j).length : ℝ) ≤ (R : ℝ) * D := by + have hp : 0 < ∏ j, ((s b j).length : ℝ) := + Finset.prod_pos (fun j _ => by exact_mod_cast (s b j).length_pos) + simpa only [Nat.cast_mul] using scaled_grid_volume_bound (Nat.cast_nonneg R) hp (hlower b) + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + let S := uniformBlockSpectrumCover J (R * K) n U ((R : ℝ) * D) (m : ℝ) ζ + refine ⟨S, ?_, ?_, ?_, ?_⟩ + · simpa only [S, ζ, Fintype.card_coe] using uniformBlockSpectrumCover_polynomial_card + J (R * K) n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hε hε1 + (by simpa only [Fintype.card_coe] using hsize) + · exact (affine_weightedCube_uniform_spectrum s (fun b j i => (u b j i : ℝ)) v A hA hU hVD hWE + (Nat.cast_nonneg m) hε h (fun b j => by exact_mod_cast hmin (b, j)) hv hstride + (R * K) (p * J.card) (Nat.mul_pos hR hK) J hJ hB hsize hscale).2 + · intro k hk + obtain ⟨hζ, hζ1, _⟩ := uniformBlockRetainedBias_spec n J.card (p * J.card) hU hWE hε + obtain ⟨d, hd, hdb, a, ξ, hξ, he⟩ := uniformBlockSpectrumCover_character (Nat.mul_pos hR hK) + n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hζ hζ1 + (by simpa only [Fintype.card_coe] using hsize) k hk + obtain ⟨ρ, hρ, hρe⟩ := grid_character_rescale hR k a ξ hξ (by simpa only [Nat.cast_mul] using he) + refine ⟨d, hd, ?_, a, ρ, ?_, hρe⟩ + · simpa only [Fintype.card_coe] using hdb + · simpa only [Fintype.card_coe] using hρ + · exact affine_weightedCube_fundamental_approximation s u v A hA hU hVD hWE (Nat.cast_nonneg m) hε + h (fun b j => by exact_mod_cast hmin (b, j)) hv hstride (p * J.card) J hJ + (fun Z => affineWeightedCube_bound_le_torus s u v hC hcoord hupper Z (hJ Z Z.property)) + hB hsize hscale + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +theorem affineModerate_geometric_approximation {B I : Type*} + [Fintype B] [Nonempty B] [DecidableEq B] [Fintype I] [DecidableEq I] + {n K : ℕ} [NeZero K] (c : B → NormalizedScalarCubeSource Empty) + (s : B → Fin n → NormalizedScalarCubeSource I) (offset : B → ℤ) (stride : B → ℕ) + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (A W T : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (M V : ℕ) + (hcM : ∀ b, (c b).modulusBound ≤ M) (hcW : ∀ b, (c b).weightBound ≤ W) + (hcT : ∀ b, (c b).weightLipschitz ≤ T) + (hM : ∀ b j, (s b j).modulusBound ≤ M) (hW : ∀ b j, (s b j).weightBound ≤ W) + (hT : ∀ b j, (s b j).weightLipschitz ≤ T) (hv : ∀ b j i, 0 < v b j i) + (hvV : ∀ b j i, v b j i ≤ V) (ht : ∀ b, 0 < stride b) (htV : ∀ b, stride b ≤ V) + {C F D E ε : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D) (hE : 0 ≤ E) (hε : 0 < ε) (hε1 : ε ≤ 1) + (hcoord : ∀ b j i, |(u b j i : ℝ)| + (v b j i : ℝ) * (s b j).length ≤ C * (s b j).length) + (hupper : ∀ b, (|(offset b : ℝ)| + (stride b : ℝ) * (c b).length) * + (∏ j, ((s b j).length : ℝ)) ≤ F * K) + (hlower : ∀ b, (K : ℝ) ≤ D * ((c b).length * ∏ j, ((s b j).length : ℝ))) + (p : ℕ) (hpower : ∀ b j, (K : ℝ) ≤ E * ((s b j).length : ℝ) ^ p) + (hcpower : ∀ b, (K : ℝ) ≤ E * ((c b).length : ℝ) ^ p) + (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n) + (hB : uniformSpectrumBlockCount n J.card (p * J.card) ≤ Fintype.card B) : + let U := affinePrimitiveEnvelope I A W T M V + let Q := affineTorusRadius (Fintype.card I) n (Fintype.card B) C F + let R := affineTorusFactor (Fintype.card I) n (Fintype.card B) C F + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + ∃ S : Finset (J → Fin (R * K)), + (S.card : ℝ) ≤ uniformSpectrumSizeConstant n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) / + ε ^ max (majorArcSpectrumExponent n J.card) (majorArcLengthExponent n * (p * J.card)) ∧ + (∑ k, ‖∏ b, affineWeightedModerateGridCoefficient (c b) (s b) (offset b : ℝ) (stride b) + (fun j i => (u b j i : ℝ)) (v b) (R * K) J k‖) ≤ + uniformSpectrumAbsoluteCap n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ∧ + (∀ k ∈ S, ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ uniformCharacterDenominatorBound n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ζ ∧ + ∃ (a : J → ℤ) (ξ : J → ℝ), + (∀ Z, |ξ Z| ≤ 2 * majorArcCoverConstant n J.card U ((R : ℝ) * D) / ζ ^ majorArcCoverExponent n J.card) ∧ + ∀ Z, ((k Z).val : ℝ) / (R * K) = (a Z : ℝ) / d + ξ Z / K) ∧ + ∀ center z : J → ℤ, centeredFundamentalBox Q K center z → + ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J center) z : ℝ) : ℂ) - + integerGridApproximation (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J center) K (R * K) S z‖ ≤ ε := by + let U := affinePrimitiveEnvelope I A W T M V + let R := affineTorusFactor (Fintype.card I) n (Fintype.card B) C F + have hU : 1 ≤ U := affinePrimitiveEnvelope_one_le I A W T M V + have hc (b) : ScalarCubePrimitiveBudget (c b) A U := + affinePrimitiveEnvelope_coefficient I (c b) A W T M V (hcM b) (hcW b) (hcT b) + have h (b) (j) : ScalarCubePrimitiveBudget (s b j) A U := + affinePrimitiveEnvelope_vector I (s b j) A W T M V (hM b j) (hW b j) (hT b j) + have hstride (b) (j) (i) : ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U := + affinePrimitiveEnvelope_stride I A W T M V (hvV b j i) ((s b j).modulus_le i |>.trans (hM b j)) + have hcoeff (b) : ((stride b * (c b).modulus none : ℕ) : ℝ) ≤ U := + affinePrimitiveEnvelope_stride I A W T M V (htV b) ((c b).modulus_le none |>.trans (hcM b)) + have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K) + have hR : 0 < R := affineTorusFactor_pos _ _ _ _ _ + let length (x : B × Option (Fin n)) : ℕ := x.2.elim (c x.1).length (fun j => (s x.1 j).length) + have hpos (x : B × Option (Fin n)) : 0 < length x := by + rcases x with ⟨b, _ | j⟩ + · exact (c b).length_pos + · exact (s b j).length_pos + have hpow (x : B × Option (Fin n)) : (K : ℝ) ≤ E * (length x : ℝ) ^ p := by + rcases x with ⟨b, _ | j⟩ + · exact hcpower b + · exact hpower b j + obtain ⟨m, hm, hmin, hsize⟩ := exists_scaled_grid_minimum length hpos (R := R) p J.card hpow + have hVD : 0 ≤ (R : ℝ) * D := by positivity + have hWE : 0 ≤ ((R : ℝ) * E) ^ J.card := by positivity + have hscale (b : B) : ((R * K : ℕ) : ℝ) / + ((((stride b * (c b).modulus none : ℕ) : ℝ) * (c b).length) * ∏ j, ((s b j).length : ℝ)) ≤ + (R : ℝ) * D := by + have hp : 0 < (((stride b * (c b).modulus none : ℕ) : ℝ) * (c b).length) * + ∏ j, ((s b j).length : ℝ) := by + apply mul_pos + · exact mul_pos (by exact_mod_cast Nat.mul_pos (ht b) ((c b).modulus_pos none)) + (by exact_mod_cast (c b).length_pos) + · exact Finset.prod_pos (fun j _ => by exact_mod_cast (s b j).length_pos) + simpa only [Nat.cast_mul] using scaled_grid_volume_bound (Nat.cast_nonneg R) hp + (affineModerate_physical_volume_lower (c b) (s b) (ht b) hD (hlower b)) + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + let S := uniformBlockSpectrumCover J (R * K) n U ((R : ℝ) * D) (m : ℝ) ζ + refine ⟨S, ?_, ?_, ?_, ?_⟩ + · simpa only [S, ζ, Fintype.card_coe] using uniformBlockSpectrumCover_polynomial_card + J (R * K) n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hε hε1 + (by simpa only [Fintype.card_coe] using hsize) + · exact (affine_weightedModerate_uniform_spectrum c s (fun b => (offset b : ℝ)) stride + (fun b j i => (u b j i : ℝ)) v A hA hU hVD hWE (Nat.cast_nonneg m) hε hc h + (fun b => by exact_mod_cast hmin (b, none)) (fun b j => by exact_mod_cast hmin (b, some j)) + ht hv hstride hcoeff (R * K) (p * J.card) (Nat.mul_pos hR hK) J hJ hB hsize hscale).2 + · intro k hk + obtain ⟨hζ, hζ1, _⟩ := uniformBlockRetainedBias_spec n J.card (p * J.card) hU hWE hε + obtain ⟨d, hd, hdb, a, ξ, hξ, he⟩ := uniformBlockSpectrumCover_character (Nat.mul_pos hR hK) + n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hζ hζ1 + (by simpa only [Fintype.card_coe] using hsize) k hk + obtain ⟨ρ, hρ, hρe⟩ := grid_character_rescale hR k a ξ hξ (by simpa only [Nat.cast_mul] using he) + refine ⟨d, hd, ?_, a, ρ, ?_, hρe⟩ + · simpa only [Fintype.card_coe] using hdb + · simpa only [Fintype.card_coe] using hρ + · exact affine_weightedModerate_fundamental_approximation c s offset stride u v A hA hU hVD hWE + (Nat.cast_nonneg m) hε hc h (fun b => by exact_mod_cast hmin (b, none)) + (fun b j => by exact_mod_cast hmin (b, some j)) ht hv hstride hcoeff (p * J.card) J hJ + (fun Z => affineWeightedModerate_bound_le_torus c s offset stride u v hC hcoord hupper Z (hJ Z Z.property)) + hB hsize hscale + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauModel.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..287d2461d1855be688ce19fd6181ad2c5b5ffed1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauModel.lean @@ -0,0 +1,492 @@ +import OAI.Combinatorics.Progressions.Fourier.FixedPrincipalCoefficientSpectrum +import OAI.Combinatorics.Progressions.Probability.AllocatedActiveAxisSourceLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +variable {A J : Type*} [Fintype A] [Fintype J] +variable (D : A → ℕ) [∀ a, NeZero (D a)] (frequency : A → J → ℤ) +variable (coefficient : A → ℂ) (mode : A → (J → ℝ) → ℂ) + +noncomputable def finiteResidueModeModel (residue : ∀ a, J → ZMod (D a)) (x : J → ℝ) : ℂ := + ∑ a, coefficient a * (star (rationalGridPhase (D a) (frequency a) (residue a)) * mode a x) + +theorem finiteResidueModeModel_norm {C : ℝ} + (hcap : (∑ a, ‖coefficient a‖) ≤ C) (hmode : ∀ a x, ‖mode a x‖ ≤ 1) + (residue : ∀ a, J → ZMod (D a)) (x : J → ℝ) : + ‖finiteResidueModeModel D frequency coefficient mode residue x‖ ≤ C := by + apply (norm_sum_le _ _).trans + apply (Finset.sum_le_sum (fun a _ => ?_)).trans hcap + rw [norm_mul, norm_mul, norm_star, rationalGridPhase_norm, one_mul] + exact mul_le_of_le_one_right (norm_nonneg _) (hmode a x) + +theorem finiteResidueModeModel_lipschitz (C L : ℝ≥0) + (hcap : (∑ a, ‖coefficient a‖) ≤ C) (hmode : ∀ a, LipschitzWith L (mode a)) + (residue : ∀ a, J → ZMod (D a)) : + LipschitzWith (C * L) (finiteResidueModeModel D frequency coefficient mode residue) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [dist_eq_norm] + unfold finiteResidueModeModel + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ a, ‖coefficient a * (star (rationalGridPhase (D a) (frequency a) (residue a)) * mode a x) - + coefficient a * (star (rationalGridPhase (D a) (frequency a) (residue a)) * mode a y)‖ := + norm_sum_le _ _ + _ ≤ ∑ a, ‖coefficient a‖ * ((L : ℝ) * dist x y) := by + apply Finset.sum_le_sum + intro a _ + rw [← mul_sub, ← mul_sub, norm_mul, norm_mul, norm_star, rationalGridPhase_norm, one_mul] + exact mul_le_mul_of_nonneg_left + (by simpa only [dist_eq_norm] using (hmode a).dist_le_mul x y) (norm_nonneg _) + _ = (∑ a, ‖coefficient a‖) * ((L : ℝ) * dist x y) := (Finset.sum_mul _ _ _).symm + _ ≤ (C : ℝ) * ((L : ℝ) * dist x y) := + mul_le_mul_of_nonneg_right hcap (mul_nonneg L.coe_nonneg dist_nonneg) + _ = _ := by rw [NNReal.coe_mul, mul_assoc] + +theorem finiteResidueModeModel_residue_card [DecidableEq A] [DecidableEq J] + (Q : ℕ) (hQ : ∀ a, D a ≤ Q) : + Fintype.card (∀ a, J → ZMod (D a)) ≤ Q ^ (Fintype.card A * Fintype.card J) := by + classical + rw [Fintype.card_pi] + simp only [Fintype.card_fun, ZMod.card] + calc + ∏ a, D a ^ Fintype.card J ≤ ∏ _a : A, Q ^ Fintype.card J := + Finset.prod_le_prod (fun a _ => Nat.pow_le_pow_left (hQ a) _) + _ = Q ^ (Fintype.card A * Fintype.card J) := by + simp only [Finset.prod_const, Finset.card_univ, ← pow_mul, Nat.mul_comm] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical +open CircleFourier + +noncomputable def weightedAffineModerateIntegerBlock {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I) + (u : Fin n → Option I → ℤ) (v : Fin n → Option I → ℕ) + (J : Finset (Finset I)) (offset : ℤ) + (x : IntegerScalarCubeBox Empty c.length × (∀ j, IntegerScalarCubeBox I (s j).length)) : J → ℤ := + fun S => (offset + (x.1 none : ℤ)) * integerBooleanBlockJet (fun j => affineIntegerCubeCoordinates (u j) (v j) (fun r => (x.2 j r : ℤ))) S + +theorem weightedAffineModerateGridCoefficient_eq_image {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I) + (u : Fin n → Option I → ℤ) (v : Fin n → Option I → ℕ) + (M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : ℤ) (k : J → Fin M) : + integerGridCoefficient (weightedModerateIntegerSource c s) (weightedAffineModerateIntegerBlock c s u v J offset) M k = + weightedAffineModerateGridCoefficient c s (fun j i => (u j i : ℝ)) v (offset : ℝ) M J k := by + unfold integerGridCoefficient weightedModerateIntegerSource + rw [FiniteProbabilityWeights.complexMean_prod] + change c.source.complexMean _ = c.source.complexMean _ + congr 1 + funext z + congr 1 + funext x + rw [rectangularGridCharacter_eq] + simp only [weightedAffineModerateIntegerBlock, integerBooleanBlockJet_scaled_pairing] + simp only [affineIntegerCubeCoordinates, Int.cast_add, Int.cast_mul, Int.cast_natCast] + rfl + +noncomputable def weightedAffineModerateIntegerJetSum {B : Type*} [Fintype B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) + (x : ∀ b, IntegerScalarCubeBox Empty (c b).length × (∀ j, IntegerScalarCubeBox I (s b j).length)) : J → ℤ := + shift + ∑ b, weightedAffineModerateIntegerBlock (c b) (s b) (u b) (v b) J (offset b) (x b) + +theorem weightedAffineModerateIntegerJetSum_coefficient {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) (k : J → Fin M) : + integerGridCoefficient (weightedModerateIntegerProductSource c s) + (weightedAffineModerateIntegerJetSum c s u v J offset shift) M k = + rectangularGridCharacter M k shift * ∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M J k := by + have h := independent_integerGridCoefficient (fun b => weightedModerateIntegerSource (c b) (s b)) + (fun b => weightedAffineModerateIntegerBlock (c b) (s b) (u b) (v b) J (offset b)) shift M k + unfold weightedModerateIntegerProductSource weightedAffineModerateIntegerJetSum + simpa only [weightedAffineModerateGridCoefficient_eq_image] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem containedProgressionCoordinate_mem {L H step : ℕ} (c z : ℤ) + (hsubset : integerProgressionSupport c (step : ℤ) H ⊆ Finset.Ico (0 : ℤ) (L : ℤ)) + (hz : z ∈ Finset.Ico (0 : ℤ) (H : ℤ)) : + c + (step : ℤ) * z ∈ Finset.Ico (0 : ℤ) (L : ℤ) := by + apply hsubset + rw [integerProgressionSupport, mem_translateSupport] + exact Finset.mem_image.mpr ⟨z, hz, by change (step : ℤ) * z = _; ring⟩ + +theorem NormalizedScalarCubeSource.source_cube {I : Type*} [Fintype I] [DecidableEq I] + (s : NormalizedScalarCubeSource I) (x : IntegerScalarCubeBox I s.length) + (hx : s.source.weight x ≠ 0) : IntegerScalarCube s.length (fun i => (x i : ℤ)) := by + have hb : s.baseLaw.weight x ≠ 0 := (mul_ne_zero_iff.mp hx).1 + have hp := lt_of_le_of_ne (s.baseLaw.nonneg x) hb.symm + rw [NormalizedScalarCubeSource.baseLaw, scalarCubeResidueWeights, + FiniteProbabilityWeights.condition_weight_pos_iff] at hp + have h1 := hp.2 + rw [integerScalarCubeWeights, FiniteProbabilityWeights.condition_weight_pos_iff] at h1 + exact (mem_integerScalarCubeSet s.length x).mp h1.1 + +theorem containedProgressionCoordinate_bound {I : Type*} [Fintype I] [DecidableEq I] + {L H step : ℕ} (c : ℤ) + (hsubset : integerProgressionSupport c (step : ℤ) H ⊆ Finset.Ico (0 : ℤ) (L : ℤ)) + (x : IntegerScalarCubeBox I H) (hx : IntegerScalarCube H (fun i => (x i : ℤ))) (i : Option I) : + |(if i = none then c else 0) + (step : ℤ) * (x i : ℤ)| ≤ L := by + have hb := integerScalarCube_coordinates (integerScalarCube_progression c hsubset _ hx) i + exact abs_le.mpr ⟨hb.1.le, hb.2.le⟩ + +theorem weightedAffineModerateIntegerJetSum_box_bound + {B I : Type*} [Fintype B] [Fintype I] [DecidableEq I] {n : ℕ} + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (T : ℕ) (rows : Finset (Finset I)) (hrows : ∀ t ∈ rows, t.card ≤ n) + {A K : ℝ} (hA : 0 ≤ A) (hK : 0 ≤ K) + (hvol : ∀ b, ((c b).length : ℝ) * (T : ℝ) ^ n ≤ A * K) + (shift : rows → ℤ) + (x : ∀ b, IntegerScalarCubeBox Empty (c b).length × (∀ j, IntegerScalarCubeBox I (s b j).length)) + (hcoord : ∀ b j i, + |affineIntegerCubeCoordinates (u b j) (v b j) (fun i => ((x b).2 j i : ℤ)) i| ≤ T) + (t : rows) : + |(weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t : ℝ) - shift t| ≤ + blockJetScaleBound (Fintype.card I) n (Fintype.card B) A * K := by + have hb (b : B) : |weightedAffineModerateIntegerBlock (c b) (s b) (u b) (v b) rows 0 (x b) t| ≤ + ((c b).length : ℤ) * ((2 : ℤ) ^ t.val.card * + ∏ _j : Fin n, ((Fintype.card I + 1 : ℕ) : ℤ) * T) := by + unfold weightedAffineModerateIntegerBlock + rw [zero_add, abs_mul] + exact mul_le_mul (integerScalarCubeBox_coordinate_abs (x b).1 none) + (integerBooleanBlockJet_bound _ (fun _ => T) (fun j i => hcoord b j i) t) + (abs_nonneg _) (Nat.cast_nonneg _) + have hs : |weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t - shift t| ≤ + ∑ b, ((c b).length : ℤ) * ((2 : ℤ) ^ t.val.card * + ∏ _j : Fin n, ((Fintype.card I + 1 : ℕ) : ℤ) * T) := by + simp only [weightedAffineModerateIntegerJetSum, Pi.add_apply, Finset.sum_apply, add_sub_cancel_left] + exact (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum (fun b _ => hb b)) + have hs' : |(weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t : ℝ) - shift t| ≤ + ∑ b, ((c b).length : ℝ) * ((2 : ℝ) ^ t.val.card * + (((Fintype.card I + 1 : ℕ) : ℝ) ^ n * (T : ℝ) ^ n)) := by + have hh : |(weightedAffineModerateIntegerJetSum c s u v rows (fun _ => 0) shift x t : ℝ) - shift t| ≤ + ∑ b, ((c b).length : ℝ) * ((2 : ℝ) ^ t.val.card * + ∏ _j : Fin n, ((Fintype.card I + 1 : ℕ) : ℝ) * T) := by + exact_mod_cast hs + simpa only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, Fintype.card_fin] using hh + apply hs'.trans + calc + _ = ∑ b, (2 : ℝ) ^ t.val.card * ((Fintype.card I + 1 : ℕ) : ℝ) ^ n * + (((c b).length : ℝ) * (T : ℝ) ^ n) := by + apply Finset.sum_congr rfl + intro b _ + ring + _ ≤ ∑ _b : B, (2 : ℝ) ^ n * ((Fintype.card I + 1 : ℕ) : ℝ) ^ n * (A * K) := by + apply Finset.sum_le_sum + intro b _ + apply (mul_le_mul_of_nonneg_left (hvol b) (by positivity)).trans + have hp := pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) (hrows t t.property) + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right hp (by positivity)) (mul_nonneg hA hK) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, blockJetScaleBound] + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {B : Type*} [Fintype B] [DecidableEq B] +variable {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] +variable (c : B → NormalizedScalarCubeSource Empty) +variable (s : B → Fin n → NormalizedScalarCubeSource I) + +theorem weightedAffineModerateProductSource_jet_sum_law + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) : + ((weightedModerateIntegerProductSource c s).toPMF).map + (weightedAffineModerateIntegerJetSum c s u v J offset shift) = + (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind + (fun a => (dependentProductPMF (fun b => + (dependentProductPMF (fun j => (s b j).source.toPMF)).map + (fun y j q => (y j q : ℤ)))).map + (fun y => shift + ∑ b, fun r : J => (offset b + a b) * integerBooleanBlockJet (fun j => affineIntegerCubeCoordinates (u b j) (v b j) (y b j)) r)) := by + have hp := congrArg (fun p : PMF (B → ℤ × (Fin n → Option I → ℤ)) => + p.map (fun z => shift + ∑ b, fun r : J => + (offset b + (z b).1) * integerBooleanBlockJet (fun j => affineIntegerCubeCoordinates (u b j) (v b j) ((z b).2 j)) r)) + (weightedModerateProductSource_pair_law c s) + rw [PMF.map_comp, PMF.map_bind] at hp + change ((weightedModerateIntegerProductSource c s).toPMF).map + (fun x => shift + ∑ b, fun r : J => (offset b + ((x b).1 none : ℤ)) * + integerBooleanBlockJet (fun j => affineIntegerCubeCoordinates (u b j) (v b j) (fun q => ((x b).2 j q : ℤ))) r) = _ + simpa only [PMF.map_comp, Function.comp_def] using hp + +theorem weightedAffineModerateProductSource_affine_law + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) : + (weightedModerateIntegerProductSource c s).toPMF.map + (weightedAffineModerateIntegerJetSum c s u v J offset shift) = + (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind + (fun a => (dependentProductPMF (fun b => + (dependentProductPMF (fun j => (s b j).source.toPMF)).map + (fun y j => affineIntegerCubeCoordinates (u b j) (v b j) (fun i => (y j i : ℤ))))).map + (fun y => shift + ∑ b, fun r : J => (offset b + a b) * integerBooleanBlockJet (y b) r)) := by + have hm := dependentProductPMF_map + (fun b => (dependentProductPMF (fun j => (s b j).source.toPMF)).map + (fun y j i => (y j i : ℤ))) + (fun b y j => affineIntegerCubeCoordinates (u b j) (v b j) (y j)) + simp only [PMF.map_comp, Function.comp_def] at hm + have ht := congrArg (fun p : PMF (B → Fin n → Option I → ℤ) => + (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind + (fun a => p.map (fun y => shift + ∑ b, fun r : J => + (offset b + a b) * integerBooleanBlockJet (y b) r))) hm + refine (weightedAffineModerateProductSource_jet_sum_law c s u v J offset shift).trans ?_ + simpa only [PMF.map_comp, Function.comp_def] using ht + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affineWeightedCubeIntegerSum_box_bound + {B I : Type*} [Fintype B] [Fintype I] [DecidableEq I] {n : ℕ} + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ) + (T : ℕ) (rows : Finset (Finset I)) (hrows : ∀ t ∈ rows, t.card ≤ n + 1) + {A K : ℝ} (hA : 0 ≤ A) (hK : 0 ≤ K) + (hvol : (T : ℝ) ^ (n + 1) ≤ A * K) + (shift : rows → ℤ) (x : ∀ b j, IntegerScalarCubeBox I (s b j).length) + (hcoord : ∀ b j i, + |affineIntegerCubeCoordinates (u b j) (v b j) (fun i => (x b j i : ℤ)) i| ≤ T) + (t : rows) : + |(affineWeightedCubeIntegerSum s u v rows shift x t : ℝ) - shift t| ≤ + blockJetScaleBound (Fintype.card I) (n + 1) (Fintype.card B) A * K := by + have hs : |affineWeightedCubeIntegerSum s u v rows shift x t - shift t| ≤ + ∑ _b : B, (2 : ℤ) ^ t.val.card * + ∏ _j : Fin (n + 1), ((Fintype.card I + 1 : ℕ) : ℤ) * T := by + simp only [affineWeightedCubeIntegerSum, Pi.add_apply, Finset.sum_apply, add_sub_cancel_left] + apply (Finset.abs_sum_le_sum_abs _ _).trans + exact Finset.sum_le_sum (fun b _ => + integerBooleanBlockJet_bound _ (fun _ => T) (fun j i => hcoord b j i) t) + have hs' : |(affineWeightedCubeIntegerSum s u v rows shift x t : ℝ) - shift t| ≤ + ∑ _b : B, (2 : ℝ) ^ t.val.card * + (((Fintype.card I + 1 : ℕ) : ℝ) ^ (n + 1) * (T : ℝ) ^ (n + 1)) := by + have hh : |(affineWeightedCubeIntegerSum s u v rows shift x t : ℝ) - shift t| ≤ + ∑ _b : B, (2 : ℝ) ^ t.val.card * + ∏ _j : Fin (n + 1), ((Fintype.card I + 1 : ℕ) : ℝ) * T := by exact_mod_cast hs + simpa only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, Fintype.card_fin] using hh + apply hs'.trans + calc + _ ≤ ∑ _b : B, (2 : ℝ) ^ (n + 1) * ((Fintype.card I + 1 : ℕ) : ℝ) ^ (n + 1) * (A * K) := by + apply Finset.sum_le_sum + intro b _ + rw [← mul_assoc] + apply (mul_le_mul_of_nonneg_left hvol (by positivity)).trans + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right + (pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) (hrows t t.property)) (by positivity)) + (mul_nonneg hA hK) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, blockJetScaleBound] + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +noncomputable def weightedAffineModerateGridApproximation {B : Type*} [Fintype B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (K M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (shift z : J → ℤ) + (S : Finset (J → Fin M)) : ℂ := + ((K : ℂ) / M) ^ J.card * ∑ k ∈ S, + (∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M J k) * + (rectangularGridCharacter M k shift * star (rectangularGridCharacter M k z)) + +theorem weightedAffineModerateGridDensity_fourier {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (K M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (shift z : J → ℤ) : + (integerGridDensity (weightedModerateIntegerProductSource c s) + (weightedAffineModerateIntegerJetSum c s u v J offset shift) K M z : ℂ) = + weightedAffineModerateGridApproximation c s u v K M J offset shift z Finset.univ := by + rw [integerGridDensity_fourier] + simp only [weightedAffineModerateGridApproximation, Fintype.card_coe] + congr 1 + apply Finset.sum_congr rfl + intro k _ + rw [weightedAffineModerateIntegerJetSum_coefficient] + ring + +theorem weightedAffineModerateGridDensity_error_of_tail {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (K M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (S : Finset (J → Fin M)) + {ε : ℝ} (htail : spectrumTail S (fun k => + ‖∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M J k‖) ≤ ε) + (shift z : J → ℤ) : + ‖(integerGridDensity (weightedModerateIntegerProductSource c s) + (weightedAffineModerateIntegerJetSum c s u v J offset shift) K M z : ℂ) - + weightedAffineModerateGridApproximation c s u v K M J offset shift z S‖ ≤ ((K : ℝ) / M) ^ J.card * ε := by + let ψ k := rectangularGridCharacter M k shift * star (rectangularGridCharacter M k z) + have hψ k : ‖ψ k‖ ≤ 1 := by + simp only [ψ, norm_mul, norm_star, rectangularGridCharacter_norm, one_mul, le_refl] + have hb := (finite_series_truncation_le S + (fun k => ∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M J k) ψ hψ).trans htail + rw [weightedAffineModerateGridDensity_fourier] + unfold weightedAffineModerateGridApproximation + rw [← mul_sub, norm_mul, norm_pow, norm_div, Complex.norm_natCast, Complex.norm_natCast] + exact mul_le_mul_of_nonneg_left hb (by positivity) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {B I T : Type*} [Fintype B] [Fintype I] [DecidableEq I] +variable [Countable T] [MeasurableSpace T] [MeasurableSingletonClass T] +variable {n K M : ℕ} [NeZero M] +variable (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) +variable (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) +variable (offset : B → ℤ) + +noncomputable def weightedAffineModeratePlateauApproximation (K : ℕ) (H : ℝ) + (rows : Finset (Finset I)) (shift z : rows → ℤ) (F : Finset (rows → Fin M)) : ℂ := + (normalizedSupportPlateau H (fun t => ((z t : ℝ) - shift t) / K) : ℂ) * + weightedAffineModerateGridApproximation c s u v K M rows offset shift z F + +theorem weightedAffineModeratePlateauApproximation_split_periods + (hK : 0 < K) (H : ℝ) (rows : Finset (Finset I)) (shift z : rows → ℤ) + (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) : + weightedAffineModeratePlateauApproximation c s u v offset K H rows shift z F = + ((K : ℂ) / M) ^ rows.card * ∑ k ∈ F, + (∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k) * + (rationalGridPhase (D k) (a k) (integerGridResidue (D k) (shift - z)) * + plateauFourierMode H (fun t => -ω k t) (fun t => ((z t : ℝ) - shift t) / K)) := by + unfold weightedAffineModeratePlateauApproximation weightedAffineModerateGridApproximation + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro k hk + rw [← plateau_grid_character_split H hK k (a k) (ω k) (hfreq k hk) shift z] + ring + +theorem weightedAffineModeratePlateauMixture_expansion + (p : PMF T) (hK : 0 < K) (H : ℝ) (rows : Finset (Finset I)) + (shift : T → rows → ℤ) (z : rows → ℤ) + (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) : + (∫ zeta, weightedAffineModeratePlateauApproximation c s u v offset K H rows (shift zeta) z F ∂p.toMeasure) = + ((K : ℂ) / M) ^ rows.card * ∑ k ∈ F, + (∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k) * + (star (rationalGridPhase (D k) (a k) (integerGridResidue (D k) z)) * + plateauModeMixture p H (D k) K (a k) (ω k) shift (fun t => (z t : ℝ) / K)) := by + simp_rw [weightedAffineModeratePlateauApproximation_split_periods c s u v offset hK H rows _ z F D a ω hfreq] + rw [integral_const_mul, integral_finsetSum] + · congr 1 + apply Finset.sum_congr rfl + intro k _ + rw [integral_const_mul, plateauModeMixture_grid_factor] + · intro k _ + apply Integrable.const_mul + apply pmf_integrable_of_norm_le p _ (B := 1) + intro zeta + rw [norm_mul, rationalGridPhase_norm, one_mul] + exact plateauFourierMode_norm _ _ _ + +noncomputable def weightedAffinePlateauModeCoefficient (K M : ℕ) (rows : Finset (Finset I)) + (k : rows → Fin M) : ℂ := + ((K : ℂ) / M) ^ rows.card * + ∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k + +omit [NeZero M] in +theorem weightedAffinePlateauModeCoefficient_sum_le (rows : Finset (Finset I)) + (F : Finset (rows → Fin M)) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ} + (hcap : (∑ k, ‖∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k‖) ≤ C) : + (∑ k : F, ‖weightedAffinePlateauModeCoefficient c s u v offset K M rows k‖) ≤ C := by + rw [← Finset.sum_subtype F (fun _ => Iff.rfl) + (fun k => ‖weightedAffinePlateauModeCoefficient c s u v offset K M rows k‖)] + simp only [weightedAffinePlateauModeCoefficient, norm_mul, norm_pow, norm_div, + Complex.norm_natCast, ← Finset.mul_sum] + have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap + apply (mul_le_mul_of_nonneg_left + ((Finset.sum_le_univ_sum_of_nonneg (fun _ => norm_nonneg _)).trans hcap) (by positivity)).trans + exact mul_le_of_le_one_left hC hscale + +noncomputable def weightedAffinePlateauModeModel (p : PMF T) (H : ℝ) (K : ℕ) + (rows : Finset (Finset I)) (F : Finset (rows → Fin M)) + (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (shift : T → rows → ℤ) (residue : ∀ k : F, rows → ZMod (D k)) (x : rows → ℝ) : ℂ := + finiteResidueModeModel (fun k : F => D k) (fun k => a k) + (fun k => weightedAffinePlateauModeCoefficient c s u v offset K M rows k) + (fun k => plateauModeMixture p H (D k) K (a k) (ω k) shift) residue x + +theorem weightedAffinePlateauModeModel_grid_value (p : PMF T) (hK : 0 < K) (H : ℝ) + (rows : Finset (Finset I)) (F : Finset (rows → Fin M)) + (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) + (shift : T → rows → ℤ) (z : rows → ℤ) : + (∫ zeta, weightedAffineModeratePlateauApproximation c s u v offset K H rows (shift zeta) z F ∂p.toMeasure) = + weightedAffinePlateauModeModel c s u v offset p H K rows F D a ω shift + (fun k => integerGridResidue (D k) z) (fun t => (z t : ℝ) / K) := by + rw [weightedAffineModeratePlateauMixture_expansion c s u v offset p hK H rows shift z F D a ω hfreq] + let term (k : rows → Fin M) := weightedAffinePlateauModeCoefficient c s u v offset K M rows k * + (star (rationalGridPhase (D k) (a k) (integerGridResidue (D k) z)) * + plateauModeMixture p H (D k) K (a k) (ω k) shift (fun t => (z t : ℝ) / K)) + calc + _ = ∑ k ∈ F, term k := by + simp only [term, weightedAffinePlateauModeCoefficient, Finset.mul_sum, mul_assoc] + _ = ∑ k : F, term k := Finset.sum_subtype F (fun _ => Iff.rfl) term + _ = _ := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauSite.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauSite.lean new file mode 100644 index 0000000000000000000000000000000000000000..295ff0eec565b936ec29efeba39edf9457f14785 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineModeratePlateauSite.lean @@ -0,0 +1,64 @@ +import OAI.Combinatorics.Progressions.Estimates.WeightedPlateauSiteApproximation + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {B α T : Type*} [Fintype B] [Fintype α] [DecidableEq α] +variable [Countable T] [MeasurableSpace T] [MeasurableSingletonClass T] +variable {b K M : ℕ} [NeZero M] + +theorem exists_weighted_affine_plateau_site_approximation + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin b → NormalizedScalarCubeSource α) + (u : B → Fin b → Option α → ℤ) (v : B → Fin b → Option α → ℕ) + (offset : B → ℤ) (p : PMF T) (hK : 0 < K) (H : ℝ) + (rows : Finset (Finset α)) (F : Finset (rows → Fin M)) + (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) + (shift : T → rows → ℤ) (hscale : ((K : ℝ) / M) ^ rows.card ≤ 1) {C : ℝ} + (hcap : (∑ k, ‖∏ b, weightedAffineModerateGridCoefficient (c b) (s b) (fun j i => (u b j i : ℝ)) (v b) (offset b : ℝ) M rows k‖) ≤ C) + (W : ℝ≥0) (hW : ∀ k ∈ F, ∀ t, |ω k t| ≤ W) + {R δ P : ℝ} (hR : 0 < R) (hδ : 0 < δ) (hP : 0 ≤ P) + (hRP : R ≤ Real.exp P) (hδP : (δ / (C + 1))⁻¹ ≤ Real.exp P) + (hLP : ((CircleFourier.characterLipConstant * (rows.card * W) + 4) * + (2 : ℝ≥0) ^ Fintype.card α : ℝ≥0) ≤ Real.exp P) : + ∃ n : F → ℕ, (∀ k, (n k : ℝ) ≤ Real.exp (4 * P + 8)) ∧ + (Fintype.card (PlateauSiteIndex α F n) : ℝ) ≤ + F.card * Real.exp (Fintype.card (Finset α) * (4 * P + 8)) ∧ + ∃ (β : PlateauSiteIndex α F n → ℂ) + (f : (k : PlateauSiteIndex α F n) → Finset α → ZMod (D k.1) → ℝ → ℂ), + (∑ k, ‖β k‖) ≤ C * Real.exp (Fintype.card (Finset α) * (4 * P + 8) + P) ∧ + (∀ k u r x, ‖f k u r x‖ ≤ 1) ∧ + (∀ k u r, LipschitzWith ⟨Real.exp (1 + 6 * P + 12), Real.exp_nonneg _⟩ (f k u r)) ∧ + ∀ y : Finset α → ℤ, (∀ u, |(y u : ℝ) / K| ≤ R) → + ‖(∫ zeta, weightedAffineModeratePlateauApproximation c s u v offset K H rows (shift zeta) + (fun t => booleanCoefficient y t) F ∂p.toMeasure) - + ∑ k, β k * ∏ u, f k u (y u : ZMod (D k.1)) ((y u : ℝ) / K)‖ ≤ δ := by + have hC : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hcap + have htol : 0 < δ / (C + 1) := div_pos hδ (by positivity) + obtain ⟨n, hn, hcard, β, f, hβ, hf, hLf, he⟩ := + exists_integer_plateau_sum_site_approximation p H K rows (fun k : F => D k) + (fun k => a k) (fun k => ω k) shift + (fun k => weightedAffinePlateauModeCoefficient c s u v offset K M rows k) + (weightedAffinePlateauModeCoefficient_sum_le c s u v offset rows F hscale hcap) + W (fun k => hW k k.property) hR htol hP hRP hδP hLP + refine ⟨n, hn, ?_, β, f, hβ, hf, hLf, ?_⟩ + · simpa only [Fintype.card_coe] using hcard + · intro y hy + rw [weightedAffinePlateauModeModel_grid_value c s u v offset p hK H rows F D a ω hfreq shift] + apply (he y hy).trans + rw [← mul_div_assoc] + apply (div_le_iff₀ (by positivity : 0 < C + 1)).mpr + nlinarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineNormalizedScales.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineNormalizedScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3e25a6ce190d9fa6169beef1f28586d009a012f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineNormalizedScales.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedMeshLengths + +namespace OAI + +section + +namespace Erdos3 + +theorem affinePhysicalScales_lower {H L Q : ℝ} {exponent : ℕ} + (hL : 1 ≤ L) (hQ : 0 ≤ Q) (hexponent : 1 ≤ exponent) + (hH : Q * L ^ exponent ≤ H) : Q ≤ H ∧ Q ≤ H / L := by + have hpower : L ≤ L ^ exponent := by + simpa only [pow_one] using pow_le_pow_right₀ hL hexponent + have hQL : Q * L ≤ H := (mul_le_mul_of_nonneg_left hpower hQ).trans hH + have hLpos : 0 < L := lt_of_lt_of_le zero_lt_one hL + refine ⟨?_, (le_div_iff₀ hLpos).mpr hQL⟩ + exact (by nlinarith : Q ≤ Q * L).trans hQL + +theorem affineParameterScale_lower {L Q P : ℝ} {D : ℕ} + (hD : 0 < D) (hQ : 0 ≤ Q) (hDlog : (D : ℝ) ≤ Real.exp P) + (hL : Q * Real.exp P ≤ L) : Q ≤ L / (D : ℝ) := by + apply (le_div_iff₀ (by exact_mod_cast hD : (0 : ℝ) < D)).mpr + exact (mul_le_mul_of_nonneg_left hDlog hQ).trans hL + +theorem affineNormalizedScales_lower {I J : Type*} (H : I → ℝ) + {L inverseLog lengthLog parameterLog : ℝ} {D exponent : ℕ} + (hL : 1 ≤ L) (hD : 0 < D) (hexponent : 1 ≤ exponent) + (hDlog : (D : ℝ) ≤ Real.exp parameterLog) + (hparam : 4 * Real.exp (inverseLog + lengthLog + parameterLog) ≤ L) + (hsite : ∀ i, 4 * Real.exp (inverseLog + lengthLog) * L ^ exponent ≤ H i) : + (∀ i, 4 * Real.exp (inverseLog + lengthLog) ≤ H i) ∧ + (∀ z : Option J × I, 4 * Real.exp (inverseLog + lengthLog) ≤ + smoothPairCoefficientScale (H z.2) L z.1) ∧ + 4 * Real.exp (inverseLog + lengthLog) ≤ L / (D : ℝ) := by + have hQ : 0 ≤ 4 * Real.exp (inverseLog + lengthLog) := by positivity + have hs (i) := affinePhysicalScales_lower hL hQ hexponent (hsite i) + refine ⟨fun i => (hs i).1, ?_, ?_⟩ + · rintro ⟨j,i⟩ + cases j with + | none => exact (hs i).1 + | some j => exact (hs i).2 + · apply affineParameterScale_lower hD hQ hDlog + simpa only [Real.exp_add, mul_assoc] using hparam + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineObservedTransport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineObservedTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a6511c5a9a67ebf57f02d1a31b53d4f45c8de80 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineObservedTransport.lean @@ -0,0 +1,80 @@ +import OAI.Combinatorics.Progressions.Lattices.AffineSampleAlphabet + +namespace OAI + +section + +namespace Erdos3 + +open scoped Classical + +variable {ι J I Ω : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype I] [Fintype Ω] + (q : ι → ℕ) [∀ i, NeZero (q i)] (p : FiniteProbabilityWeights Ω) + (F : Ω → Option J × I → ℤ) (w : Ω → ℝ) + +noncomputable def affinePrimeObservedDensity : (∀ i, (J → I → ZMod (q i)) × (I → ZMod (q i))) → ℝ := + observedProductDensity (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) + p (fun z => affinePrimeCoordinateObservation q (F z)) w + +theorem affinePrimeObservedDensity_pullback (x : ∀ i, Option J × I → ZMod (q i)) : + affinePrimeObservedDensity q p F w (fun i => affineSampleAlphabetEquiv (x i)) = + observedProductDensity (primeCoordinateReference (σ := Option J × I) q) + p (fun z => primeCoordinateObservation q (F z)) w x := + observedProductDensity_coordinate_equiv _ _ (fun _ => affineSampleAlphabetEquiv) + (fun _ => affineSampleAlphabet_weight) p (fun z => primeCoordinateObservation q (F z)) w x + +theorem affinePrimeObservedDensity_energy (D : Finset (Finset ι)) : + productANOVAEnergy (primeCoordinateReference (σ := Option J × I) q) D + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) + p (fun z => primeCoordinateObservation q (F z)) w) = + productANOVAEnergy (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) D + (affinePrimeObservedDensity q p F w) := + observedProductDensity_coordinate_energy _ _ (fun _ => affineSampleAlphabetEquiv) + (fun _ => affineSampleAlphabet_weight) p (fun z => primeCoordinateObservation q (F z)) w D + +theorem affinePrimeObservedDensity_marginals_iff (η : ℝ) (r : ℕ) : + ProductMarginalsClose (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) + (affinePrimeObservedDensity q p F w) η r ↔ + ProductMarginalsClose (primeCoordinateReference (σ := Option J × I) q) + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) + p (fun z => primeCoordinateObservation q (F z)) w) η r := by + rw [productMarginalsClose_coordinate_equiv_iff + (primeCoordinateReference (σ := Option J × I) q) + (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) + (fun _ => affineSampleAlphabetEquiv) (fun _ => affineSampleAlphabet_weight)] + simp only [affinePrimeObservedDensity_pullback] + +theorem affinePrimeObservedDensity_section (T A : Finset ι) + (z x : ∀ i, Option J × I → ZMod (q i)) : + productSectionAverage (primeCoordinateReference (σ := Option J × I) q) T A z + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) + p (fun v => primeCoordinateObservation q (F v)) w) x = + productSectionAverage (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) T A + (fun i => affineSampleAlphabetEquiv (z i)) (affinePrimeObservedDensity q p F w) + (fun i => affineSampleAlphabetEquiv (x i)) := by + have he := funext (affinePrimeObservedDensity_pullback q p F w) + rw [← he] + exact productSectionAverage_coordinate_transport _ _ (fun _ => affineSampleAlphabetEquiv) + (fun _ => affineSampleAlphabet_mean) T A z _ x + +theorem affinePrimeObservedDensity_section_energy (T A : Finset ι) + (z : ∀ i, Option J × I → ZMod (q i)) (D : Finset (Finset ι)) : + productANOVAEnergy (primeCoordinateReference (σ := Option J × I) q) D + (productSectionAverage (primeCoordinateReference (σ := Option J × I) q) T A z + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) + p (fun v => primeCoordinateObservation q (F v)) w)) = + productANOVAEnergy (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) D + (productSectionAverage (fun i => residueAffineSource (J := J) (G := I → ZMod (q i))) T A + (fun i => affineSampleAlphabetEquiv (z i)) (affinePrimeObservedDensity q p F w)) := by + rw [show productSectionAverage (primeCoordinateReference (σ := Option J × I) q) T A z + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) + p (fun v => primeCoordinateObservation q (F v)) w) = _ from + funext (affinePrimeObservedDensity_section q p F w T A z)] + exact productANOVAEnergy_coordinate_transport _ _ (fun _ => affineSampleAlphabetEquiv) + (fun _ => affineSampleAlphabet_mean) D _ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineOneSiteNormalizedLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineOneSiteNormalizedLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..40e937123045f80dd736b7e92ea06fa5c6b7df14 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineOneSiteNormalizedLaw.lean @@ -0,0 +1,521 @@ +import OAI.Combinatorics.Progressions.Estimates.OneSiteWeightIdentity +import OAI.Combinatorics.Progressions.Fourier.CoefficientFourierTranslation +import OAI.Combinatorics.Progressions.Linear.ProductOneSiteProjectionCap + +namespace OAI + +section + +namespace Erdos3 + +theorem selectedResidueDensityPMF_test_le {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D g φ : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + {C ε a : ℝ} (ha : 0 < a) (hlower : a ≤ selectedResidueDensityMass modulus G V D) + (hg : ∀ x, g x ≤ C) (hφ : ∀ x, 0 ≤ φ x) + (he : |(∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (D x * φ x)) - + ∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (g x * φ x)| ≤ ε) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * φ x) ≤ + (C * (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * φ x) + ε) / a := by + let prob := selectedResidueFiniteLaw modulus G V hV hZ + have hmean (f : (K × I → ℤ) → ℝ) : prob.mean (fun x => f x.val) = + ∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * f x := + selectedResidueFiniteLaw_mean modulus G V hV hZ f + have hm : prob.mean (fun x => D x.val) = selectedResidueDensityMass modulus G V D := + selectedResidueFiniteLaw_densityMass modulus G V hV hZ D + have hb := prob.mean_mul_le_of_capped_comparison (ε := ε) (fun x => D x.val) (fun x => g x.val) + (fun x => φ x.val) (fun x => hφ x.val) (fun x => hg x.val) + (by + rw [hmean (fun x => D x * φ x), hmean (fun x => g x * φ x)] + exact he) + have hn := prob.reweightPositive_test_le (fun x => D x.val) (fun x => hD0 x.val) + (hm.symm ▸ hD) (fun x => φ x.val) (fun x => hφ x.val) ha (hm.symm ▸ hlower) hb + rw [FiniteProbabilityWeights.reweightPositive_mean, hm, + hmean (fun x => D x * φ x), hmean φ] at hn + rw [selectedResidueDensityPMF_mean] + exact hn + +theorem selectedResidueDensityPMF_test_le_of_complex {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D g φ : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + {C ε a : ℝ} (ha : 0 < a) (hlower : a ≤ selectedResidueDensityMass modulus G V D) + (hg : ∀ x, g x ≤ C) (hφ : ∀ x, 0 ≤ φ x) + (he : ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * ((φ x : ℂ) * (D x : ℂ))) - + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * ((φ x : ℂ) * (g x : ℂ))‖ ≤ ε) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * φ x) ≤ + (C * (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * φ x) + ε) / a := by + apply selectedResidueDensityPMF_test_le modulus G V hV hZ D g φ hD0 hD ha hlower hg hφ + simp only [← Complex.ofReal_mul, ← Complex.ofReal_tsum, ← Complex.ofReal_sub, + Complex.norm_real, Real.norm_eq_abs] at he + simpa only [mul_comm, mul_left_comm, mul_assoc] using he + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem selectedResidueSmoothPMF_test_le_of_complex {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D g φ : (K × I → ℤ) → ℝ) {C ε : ℝ} + (hg : ∀ x, g x ≤ C) (hφ : ∀ x, 0 ≤ φ x) + (he : ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * + ((φ x : ℂ) * (D x : ℂ))) - + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * + ((φ x : ℂ) * (g x : ℂ))‖ ≤ ε) : + (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (φ x * D x)) ≤ + C * (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * φ x) + ε := by + let prob := selectedResidueFiniteLaw modulus G V hV hZ + have hmean (f : (K × I → ℤ) → ℝ) : prob.mean (fun x => f x.val) = + ∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * f x := + selectedResidueFiniteLaw_mean modulus G V hV hZ f + simp only [← Complex.ofReal_mul, ← Complex.ofReal_tsum, ← Complex.ofReal_sub, + Complex.norm_real, Real.norm_eq_abs] at he + have h := prob.mean_mul_le_of_capped_comparison (ε := ε) (fun x => D x.val) + (fun x => g x.val) (fun x => φ x.val) (fun x => hφ x.val) (fun x => hg x.val) (by + rw [hmean (fun x => D x * φ x), hmean (fun x => g x * φ x)] + simpa only [mul_comm, mul_left_comm, mul_assoc] using he) + rw [hmean (fun x => D x * φ x), hmean φ] at h + simpa only [mul_comm, mul_left_comm, mul_assoc] using h + +end Erdos3 + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +noncomputable def physicalAffineSite {I K : Type*} [Fintype K] + (root : K → ℤ) (z : Option K × I → ℤ) : I → ℝ := + integerSiteValue (fun k => match k with | none => 1 | some k => root k) + (fun k j => (z (k,j) : ℝ)) + +theorem integerSiteValue_oneSite {I K : Type*} [Fintype K] + (root : K → ℤ) (difference : Fin 0 → K → ℤ) (z : Option K × I → ℤ) : + integerSiteValue (affineSite root difference ∅) (fun k j => (z (k,j) : ℝ)) = + physicalAffineSite root z := by + have hs : affineSite root difference ∅ = (fun k => match k with | none => 1 | some k => root k) := by + funext k + cases k <;> simp [affineSite] + rw [hs] + rfl + +theorem layeredSiteWeight_physical {I K : Type*} [Fintype K] + (root : K → ℤ) (difference : Fin 0 → K → ℤ) (φ : (I → ℝ) → ℂ) + (z : Option K × I → ℤ) : + layeredSiteWeight 0 (fun s => affineSite root difference s) (fun _ => φ) + (fun k j => (z (k,j) : ℝ)) = φ (physicalAffineSite root z) := by + rw [layeredSiteWeight_oneSite, integerSiteValue_oneSite] + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial + +theorem selectedResidue_oneSite_density_error {I K F : Type*} [Fintype I] [Fintype K] [Fintype F] + {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (t : K → ℤ) (difference : Fin 0 → K → ℤ) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ) {η ε : ℝ} (hη : 0 ≤ η) + (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) + (hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U t y x)) μ) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (G : Finset (ColumnResiduePattern (Option K) I stride)) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x) + (w : (Option K × I → ℤ) → ℂ) (hw : ∀ x, ‖w x‖ ≤ 1) + (hprojection : ‖(∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * affineCubeFourierSum frequency p c (fun k j => (x (k, j) : ℝ)))) - + ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * affineCubeFourierProjection U t difference frequency p c (fun k j => (x (k, j) : ℝ)))‖ ≤ ε) : + ‖(∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * (D (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ))) : ℂ))) - + ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * ((coefficientFiberAverage U μ t D (coefficientEvaluationTorus U t + (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ)))) : ℝ) : ℂ))‖ ≤ 2 * η + ε := by + let prob := selectedResidueFiniteLaw stride G V hV hZ + have hmean (f : (Option K × I → ℤ) → ℂ) : prob.complexMean (fun x => f x.val) = + ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * f x := + selectedResidueFiniteLaw_complexMean stride G V hV hZ f + have hw' : prob.mean (fun x => ‖w x.val‖) ≤ 1 := + (prob.mean_mono (fun x => hw x.val)).trans_eq (prob.mean_const 1) + have he := oneSiteDensity_projection_error (ε := ε) U t difference frequency c μ D hη happrox p hp hm + prob (fun x k j => (x.val (k, j) : ℝ)) (fun x => w x.val) (fun _ _ => hD _) hw' + (by + rw [hmean (fun x => w x * affineCubeFourierSum frequency p c (fun k j => (x (k, j) : ℝ))), + hmean (fun x => w x * affineCubeFourierProjection U t difference frequency p c (fun k j => (x (k, j) : ℝ)))] + exact hprojection) + rw [hmean (fun x => w x * (D (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ))) : ℂ)), + hmean (fun x => w x * ((coefficientFiberAverage U μ t D (coefficientEvaluationTorus U t + (affineSampleCoefficientTorus U p hm (fun k j => (x (k, j) : ℝ)))) : ℝ) : ℂ))] at he + simpa only [mul_one] using he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators + +theorem exists_affine_oneSite_density_comparison (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (root : K → ℤ) (difference : Fin 0 → K → ℤ) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin 0)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin 0) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) + (_hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U root y x)) μ) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + (D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))) : ℂ))) - + (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + ((coefficientFiberAverage U μ root D (coefficientEvaluationTorus U root + (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) : ℝ) : ℂ)))‖ ≤ 2 * η + ε := by + obtain ⟨A, hA, hprojection⟩ := exists_affine_cube_fourier_projection m 0 + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root difference + L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm + stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR Q hQ test htest + G hG V hV hwidth D hD η hη happrox + obtain ⟨hZ, he⟩ := hprojection hP hn hd U root difference linearIndependent_empty_type + hL hC hLP hCP hsite frequency hbound c hB hBP hcoefficients p hp hm stride hs + hS hSP hρ hε hρP hεP hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth + refine ⟨hZ, ?_⟩ + exact selectedResidue_oneSite_density_error U root difference frequency c μ D hη happrox hD p hp hm + stride G V hV hZ + (fun z => layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))) + (fun z => layeredSiteWeight_norm_le Q _ test htest _) he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators + +theorem exists_affine_oneSite_test_domination (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (root : K → ℤ) (difference : Fin 0 → K → ℤ) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin 0)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) + (_hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U root y x)) μ) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) + (_hD0 : ∀ x, 0 ≤ D x) {M a : ℝ} (_ha : 0 < a) + (_hlower : a ≤ selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))) + (_hcap : ∀ y, coefficientFiberAverage U μ root D y ≤ M) + (φ : (I → ℝ) → ℝ) (_hφ : ∀ v, φ v ∈ Set.Icc (0 : ℝ) 1), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ∃ hDpos : 0 < selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))), + (∑' z, (selectedResidueDensityPMF stride G V hV hZ + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) + (fun _ => _hD0 _) hDpos z).toReal * + φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) ≤ + (M * (∑' z, (selectedResidueSmoothPMF stride G V hV hZ z).toReal * + φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) + + (2 * η + ε)) / a := by + obtain ⟨A, hA, hcomparison⟩ := exists_affine_oneSite_density_comparison m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root difference + L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm + stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR + G hG V hV hwidth D hD η hη happrox hD0 M a ha hlower hcap φ hφ + have hφn (v : I → ℝ) : ‖(φ v : ℂ)‖ ≤ 1 := by + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hφ v).1] + exact (hφ v).2 + obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ root difference hL hC hLP hCP hsite frequency hbound + c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR + 0 (by simp) (fun _ v => (φ v : ℂ)) (fun _ v => hφn v) G hG V hV hwidth D hD hη happrox + have hDpos : 0 < selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))) := ha.trans_le hlower + refine ⟨hZ, hDpos, ?_⟩ + simp only [layeredSiteWeight_oneSite] at he + exact selectedResidueDensityPMF_test_le_of_complex (C := M) (ε := 2 * η + ε) (a := a) stride G V hV hZ + (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))) + (fun z => coefficientFiberAverage U μ root D (coefficientEvaluationTorus U root + (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ))))) + (fun z => φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) + (fun _ => hD0 _) hDpos ha hlower + (fun _ => hcap _) (fun _ => (hφ _).1) he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators + +theorem exists_affine_translated_oneSite_density_comparison (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (root : K → ℤ) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ k, |(root k : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) (_hD : Measurable D) + {M : ℝ} (_hDbound : ∀ x, ‖D x‖ ≤ M) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖(D x : ℂ) - coefficientTorusFourierSum U frequency c x‖ ≤ η) + (center : CoefficientTorus (K := K) U) + (φphysical : (I → ℝ) → ℂ) (_hφ : ∀ v, ‖φphysical v‖ ≤ 1), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (φphysical (physicalAffineSite root z) * + (D (center + affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))) : ℂ))) - + (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (φphysical (physicalAffineSite root z) * + (((coefficientFiberAverage U μ root (fun x => D (center + x)) + (coefficientEvaluationTorus U root + (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ))))) : ℝ) : ℂ)))‖ ≤ + 2 * η + ε := by + obtain ⟨A, hA, hcomparison⟩ := exists_affine_oneSite_density_comparison m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root + L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm + stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR + G hG V hV hwidth D hD M hDbound η hη happrox center φphysical hφ + let difference : Fin 0 → K → ℤ := fun i => Fin.elim0 i + have hsite' (s : Finset (Fin 0)) (k : K) : + |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L := by + have hs : s = ∅ := Subsingleton.elim _ _ + simpa [hs, affineSite] using hsite k + have hcoefficients' : + (∑ a, ‖c a * coefficientTorusCharacter U (frequency a) center‖) ≤ B := by + rw [coefficientFourier_translate_norm] + exact hcoefficients + have happrox' (x) : + ‖coefficientTorusFourierSum U frequency + (fun a => c a * coefficientTorusCharacter U (frequency a) center) x - + (D (center + x) : ℂ)‖ ≤ η := by + rw [norm_sub_rev] + exact coefficientFourier_translate_approx U D frequency c happrox center x + have hintegrable (y) : + Integrable (fun x => D (center + coefficientFiberMap U root y x)) μ := + bounded_coefficient_translate_fiber_integrable U μ D hD hDbound center root y + obtain ⟨hZ, he⟩ := hcomparison hP hn hd U μ root difference hL hC hLP hCP hsite' + frequency hbound (fun a => c a * coefficientTorusCharacter U (frequency a) center) + hB hBP hcoefficients' p hp hm stride hs hS hSP hρ hε hρP hεP hstride + H hsize hrank hR 0 (by simp) (fun _ => φphysical) (fun _ => hφ) + G hG V hV hwidth (fun x => D (center + x)) hintegrable hη happrox' + refine ⟨hZ, ?_⟩ + simpa only [layeredSiteWeight_physical] using he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators + +theorem exists_affine_oneSite_normalized_domination (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (root : K → ℤ) (difference : Fin 0 → K → ℤ) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin 0)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C) + (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) + (_hDglobal : Integrable D μ) (_hDmass : (∫ x, D x ∂μ) = 1) + (_hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U root y x)) μ) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) + (_hsmall : 2 * η + ε ≤ 1 / 2) + (_hD0 : ∀ x, 0 ≤ D x) {M : ℝ} + (_hcap : ∀ y, coefficientFiberAverage U μ root D y ≤ M) + (φ : (I → ℝ) → ℝ) (_hφ : ∀ v, φ v ∈ Set.Icc (0 : ℝ) 1), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ∃ hDpos : 0 < selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))), + |selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧ + 1 / 2 ≤ selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) ∧ + (∑' z, (selectedResidueDensityPMF stride G V hV hZ + (fun z => D (affineSampleCoefficientTorus U p _hm (fun k j => (z (k, j) : ℝ)))) + (fun _ => _hD0 _) hDpos z).toReal * + φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) ≤ + (M * (∑' z, (selectedResidueSmoothPMF stride G V hV hZ z).toReal * + φ (integerSiteValue (affineSite root difference ∅) (fun k j => (z (k, j) : ℝ)))) + + (2 * η + ε)) / (1 / 2 : ℝ) := by + obtain ⟨A₀, hA₀, hmass⟩ := exists_affine_coefficient_density_mass m + obtain ⟨A₁, _hA₁, hdom⟩ := exists_affine_oneSite_test_domination m + let A := max A₀ A₁ + have hA : 2 ≤ A := hA₀.trans (le_max_left _ _) + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U _ _ μ _ _ root difference + L C hL hC hLP hCP hsite frequency hbound c B hB hBP hcoefficients p hp hm + stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR + G hG V hV hwidth D hDglobal hDmass hD η hη happrox hsmall hD0 M hcap φ hφ + have hthreshold (a : ℕ) (ha : a ≤ A) : Real.exp ((P + a) ^ a) ≤ Real.exp ((P + A) ^ A) := by + apply Real.exp_le_exp.mpr + have haa : (a : ℝ) ≤ A := by exact_mod_cast ha + have hbase : P + (a : ℝ) ≤ P + A := by linarith + have hAreal : (2 : ℝ) ≤ A := by exact_mod_cast hA + exact (pow_le_pow_left₀ (by positivity) hbase a).trans + (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ P + A) ha) + have h₀ := hthreshold A₀ (le_max_left _ _) + have h₁ := hthreshold A₁ (le_max_right _ _) + obtain ⟨_hZ₀, he⟩ := hmass hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients p hp hm + stride hs hS hSP hρ hε hρP hεP hstride H (fun k => h₀.trans (hsize k)) hrank (h₀.trans hR) + G hG V hV hwidth D hDglobal hDmass hη (fun x => by rw [norm_sub_rev]; exact happrox x) + have hlower : 1 / 2 ≤ selectedResidueDensityMass stride G V + (fun z => D (affineSampleCoefficientTorus U p hm (fun k j => (z (k, j) : ℝ)))) := by + have hh := (abs_le.mp he).1 + linarith + obtain ⟨hZ, hDpos, hb⟩ := hdom hP hn hd U μ root difference hL hC hLP hCP hsite frequency hbound + c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP hstride + H (fun k => h₁.trans (hsize k)) hrank (h₁.trans hR) G hG V hV hwidth D hD hη happrox + hD0 (by norm_num : (0 : ℝ) < 1 / 2) hlower hcap φ hφ + exact ⟨hZ, hDpos, he, hlower, hb⟩ + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffinePrecisionBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffinePrecisionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddd821190b86f730fdce566da9034793fd0408b4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffinePrecisionBudget.lean @@ -0,0 +1,289 @@ +import OAI.Combinatorics.Progressions.Estimates.AdaptiveRatioNormalization +import OAI.Combinatorics.Progressions.Estimates.GlobalCutoffAtomComparison + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem normalized_adaptive_affine_comparison + {ι σ J : Type*} [Fintype J] [Fintype ι] [LinearOrder ι] [Fintype σ] + {q : ι → ℕ} [∀ i, NeZero (q i)] + (lo a : σ → ℤ) (N : σ → ℕ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (1 : ℤ)) a)) + (sourceLo sourceA : Option J × σ → ℤ) (sourceN : Option J × σ → ℕ) + (hneSource : Nonempty (IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k) + (fun _ => (1 : ℤ)) sourceA)) + (h g : (σ → ℤ) → ℂ) (w : (Option J × σ → ℤ) → ℝ) + (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + (hw : ∀ z ∈ translatedIntegerBox sourceLo sourceN, 0 ≤ w z ∧ w z ≤ 1) + {ε L T C shell totalShell modLog level dimLog sourceDimLog : ℝ} + (hε : 0 < ε) (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) + (hshell : 0 < shell) (hlower : Real.exp (-L) ≤ level) (hlevel2 : level ≤ 2) + (hmodLog : 0 ≤ modLog) (hdimLog : 0 ≤ dimLog) (hsourceDimLog : 0 ≤ sourceDimLog) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) + (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) + (hsourceDim : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp sourceDimLog) + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) + (hpower : ∀ i, q i = prime i ^ power i) (hinj : Function.Injective prime) + (hJ : 2 ≤ Fintype.card J) (D : ℕ) (parameterA : J → ℤ) + (tree : CoordinateDecisionTree ι (fun i => σ → ZMod (q i))) + (baseX : ∀ i, Option J × σ → ZMod (q i)) (baseY : ∀ i, σ → ZMod (q i)) + {d A B : ℕ} + (htree : CoordinateDecisionTree.Valid (fun K base => + affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D ⊆ K ∧ + ResiduePrimeCoordinateStable g lo N 1 a q (affineRemovalDepth T + affineComparisonTail ε L T) + (affineStabilityTolerance T) K base ∧ + PrimeRefinementUpperBound h g lo N 1 a q (affineRemovalDepth T + affineComparisonTail ε L T) + level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base) + ∅ baseY tree d) + (hA : d ≤ A) + (hB : A + affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) + ε L T C shell modLog ≤ B) + (hBinitial : A + CyclicCrootSisask.spectralIterations shell + ((A : ℝ) * ((Fintype.card (Option J × σ) : ℝ) * modLog + + (Fintype.card σ : ℝ) * modLog + 1) + 4) ≤ B) + (hside : ∀ k, Real.exp (modLog * A + affineComparisonLengthLog B ε L T C modLog dimLog + 2) ≤ (N k : ℝ)) + (hsourceSide : ∀ k, Real.exp (modLog * A + affineComparisonLengthLog B ε L T C modLog sourceDimLog + 2) ≤ (sourceN k : ℝ)) + (hallocation : Real.exp ((A : ℝ) * (affineComparisonScale ε L T C + + (Fintype.card (Option J × σ) : ℝ) * modLog + (Fintype.card σ : ℝ) * modLog + 1)) * shell ≤ totalShell) : + productTruncatedPairing (affinePeriodProductCoupling (σ := σ) q D parameterA) + (lowDegreeCoordinateSets ι B) + (residuePrimeCoordinateDensity sourceLo sourceN 1 sourceA hneSource q w) + (fun z => residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (h x).re) z - + (1 + ε) * level * residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (g x).re) z) ≤ + (1 + affineComparisonAccuracy B (affineComparisonScale ε L T C) L T) * + (1 + affineComparisonAccuracy B (affineComparisonScale ε L T C) L T) * + (level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 + + Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3)) + + (1 + (1 + ε) * level) * (totalShell / 16) := by + have hpair : Pairwise (fun i k => (q i).Coprime (q k)) := by + intro i k hik + rw [hpower i, hpower k] + exact selectedPrimePowers_pairwise_coprime prime power hprime hinj hik + have hAB : A ≤ B := (Nat.le_add_right _ _).trans hB + have hsite := unconditioned_affine_cell_bounds lo N a hne q hpair hAB hL hT hC + hmodLog hdimLog hmoduli hdim hside + have hsource := unconditioned_affine_cell_bounds sourceLo sourceN sourceA hneSource q hpair hAB + hL hT hC hmodLog hsourceDimLog hmoduli hsourceDim hsourceSide + let c := affinePeriodProductCoupling (σ := σ) q D parameterA + let source := residuePrimeCoordinateDensity sourceLo sourceN 1 sourceA hneSource q w + let target := fun z => residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (h x).re) z - + (1 + ε) * level * residuePrimeCoordinateDensity lo N 1 a hne q (fun x => (g x).re) z + let eta := affineComparisonAccuracy B (affineComparisonScale ε L T C) L T + let R := level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 + + Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3) + let coeff := 1 + (1 + ε) * level + let pairs := CoordinateDecisionTree.leafSourceAssignments (fun i => Option J × σ → ZMod (q i)) tree ∅ baseY + let ratioX := fun z : Σ leaf : ProductCylinder (fun i => σ → ZMod (q i)), + ∀ i : leaf.1, Option J × σ → ZMod (q i.val) => + residuePrimeCoordinateMassRatio sourceLo sourceN 1 sourceA q z.1.1 (productSubtypePoint z.1.1 z.2 baseX) + let ratioY := fun z : Σ leaf : ProductCylinder (fun i => σ → ZMod (q i)), + ∀ i : leaf.1, Option J × σ → ZMod (q i.val) => + residuePrimeCoordinateMassRatio lo N 1 a q z.1.1 (z.1.assignment baseY) + have hA' : (∅ : Finset ι).card + d ≤ A := by simpa using hA + have hleaf (z) (hz : z ∈ pairs) : z.1 ∈ CoordinateDecisionTree.leafCylinders tree ∅ baseY := + (CoordinateDecisionTree.mem_leafSourceAssignments (fun i => Option J × σ → ZMod (q i)) tree ∅ baseY z).mp hz + have hsize (z) (hz : z ∈ pairs) : z.1.1.card ≤ A := + (htree.leaf_card_le z.1 (hleaf z hz)).trans hA' + have hratioX (z) (hz : z ∈ pairs) : |ratioX z - 1| ≤ eta := + residuePrimeCoordinateMassRatio_close_of_marginals sourceLo sourceN 1 sourceA hneSource q + hsource.1 z.1.1 (hsize z hz) (productSubtypePoint z.1.1 z.2 baseX) + have hratioY (z) (hz : z ∈ pairs) : |ratioY z - 1| ≤ eta := + residuePrimeCoordinateMassRatio_close_of_marginals lo N 1 a hne q + hsite.1 z.1.1 (hsize z hz) (z.1.assignment baseY) + have hbound (z) (hz : z ∈ pairs) : + productAtomTruncatedPairing c (lowDegreeCoordinateSets ι B) z.1.1 + (productSubtypePoint z.1.1 z.2 baseX) (z.1.assignment baseY) source target ≤ + adaptiveLeafPairMass c baseX baseY z * (ratioX z * ratioY z) * R + coeff * (shell / 16) := by + have hcert := htree.leaf_good z.1 (hleaf z hz) + let u := (hsite.2.1 z.1.1 (hsize z hz) (z.1.assignment baseY)).some + let uX := (hsource.2.1 z.1.1 (hsize z hz) (productSubtypePoint z.1.1 z.2 baseX)).some + have hwX (v : ResiduePrimeCoordinateCell sourceLo sourceN 1 sourceA q z.1.1 + (productSubtypePoint z.1.1 z.2 baseX)) : + 0 ≤ w (fun k => (v.val k).val) ∧ w (fun k => (v.val k).val) ≤ 1 := by + apply hw + apply (mem_translatedIntegerBox sourceLo sourceN _).mpr + intro k + exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (v.val k).property).1) + have ha := global_cutoff_initial_atom_comparison + (hKcard := hsize z hz) (hB := hB) (hstable := hcert.2.1) (hupper := hcert.2.2) + (hM := by decide) (u := u) (hg := hg) (hh := hh) (hL := hL) (hT := hT) + (hlower := hlower) (prime := prime) (power := power) (hprime := hprime) (hpower := hpower) + (hJ := hJ) (hshell := hshell) (hlevel2 := hlevel2) (hmodLog := hmodLog) (hmoduli := hmoduli) + (hε := hε) (hC := hC) (hcount := hcount) (dimLog := dimLog) (hdim := hdim) + (hlength := hsite.2.2 z.1.1 (hsize z hz) (z.1.assignment baseY) u) + (sourceLo := sourceLo) (sourceA := sourceA) (sourceN := sourceN) (sourceM := 1) + (sourceBase := productSubtypePoint z.1.1 z.2 baseX) (sourceCell := uX) (w := w) (hw := hwX) + (hsourceM := by decide) (sourceDimLog := sourceDimLog) (hsourceDim := hsourceDim) + (hsourceLength := hsource.2.2 z.1.1 (hsize z hz) (productSubtypePoint z.1.1 z.2 baseX) uX) + (hinj := hinj) (D := D) (parameterA := parameterA) (hmask := hcert.1) (hBinitial := hBinitial) + exact ha + have hlevel : 0 ≤ level := (Real.exp_pos (-L)).le.trans hlower + have hcoeff : 0 ≤ coeff := by dsimp only [coeff]; positivity + have hR : 0 ≤ R := by dsimp only [R]; positivity + have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1 + have hcountP := affineComparisonScale_count (ι := ι) (ε := ε) hL hT hC hcount + have hcard := affine_leaf_source_assignments_card_le_exp (J := J) q htree hA' hP hmodLog hcountP hmoduli + have herror : (∑ _z ∈ pairs, coeff * (shell / 16)) ≤ coeff * (totalShell / 16) := by + have hpay := (mul_le_mul_of_nonneg_right hcard hshell.le).trans hallocation + have hscale := mul_le_mul_of_nonneg_left hpay (div_nonneg hcoeff (by norm_num : (0 : ℝ) ≤ 16)) + calc + _ = ((pairs.card : ℝ) * shell) * (coeff / 16) := by simp only [Finset.sum_const, nsmul_eq_mul]; ring + _ ≤ totalShell * (coeff / 16) := by nlinarith only [hscale] + _ = _ := by ring + exact productTruncatedPairing_leaf_normalized_bound c tree (lowDegreeCoordinateSets ι B) + baseX baseY source target ratioX ratioY (fun _ => coeff * (shell / 16)) hR hratioX hratioY hbound herror + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem normalized_affine_error_le {ε T level eta shell totalShell : ℝ} + (hε : 0 ≤ ε) (hT : 0 ≤ T) (hlevel : 0 ≤ level) (hlevel2 : level ≤ 2) + (heta0 : 0 ≤ eta) (heta1 : eta ≤ 1) (hshell : 0 ≤ shell) (htotal : shell ≤ totalShell) : + (1 + eta) * (1 + eta) * + (level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 + + Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3)) + + (1 + (1 + ε) * level) * (totalShell / 16) ≤ + 100 * (1 + ε) * Real.exp (-T / 2) + (1 + ε) * totalShell := by + have he : 0 < Real.exp (-T / 2) := Real.exp_pos _ + have he0 : 0 < Real.exp (-T) := Real.exp_pos _ + have htotal0 : 0 ≤ totalShell := hshell.trans htotal + have hdecay : Real.exp (-T) ≤ Real.exp (-T / 2) := Real.exp_le_exp.mpr (by linarith) + have hsquare : (Real.exp (-T / 2)) ^ 2 = Real.exp (-T) := by + rw [pow_two, ← Real.exp_add] + congr 1 + ring + have hsqrt : Real.sqrt (3 * Real.exp (-T)) ≤ 2 * Real.exp (-T / 2) := by + apply (Real.sqrt_le_left (by positivity : 0 ≤ 2 * Real.exp (-T / 2))).mpr + nlinarith only [hsquare, he0] + have hfirstCoeff : level * (1 + 2 * ε) ≤ 4 * (1 + ε) := by nlinarith + have hfirst := mul_le_mul hfirstCoeff hdecay he0.le (by positivity : 0 ≤ 4 * (1 + ε)) + have htailCoeff : 3 + (1 + ε) * level * 3 ≤ 9 * (1 + ε) := by nlinarith + have htail := mul_le_mul hsqrt htailCoeff + (by positivity : 0 ≤ 3 + (1 + ε) * level * 3) + (by positivity : 0 ≤ 2 * Real.exp (-T / 2)) + have hmain : level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 + + Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3) ≤ + 22 * (1 + ε) * Real.exp (-T / 2) + shell / 16 := by nlinarith only [hfirst, htail] + have hmain0 : 0 ≤ level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 + + Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3) := by positivity + have hfactor : (1 + eta) * (1 + eta) ≤ 4 := by nlinarith + have hcoeff : 1 + (1 + ε) * level ≤ 3 * (1 + ε) := by nlinarith + have herr := mul_le_mul_of_nonneg_right hcoeff (div_nonneg htotal0 (by norm_num : (0 : ℝ) ≤ 16)) + have hrest : shell / 4 + 3 * (1 + ε) * (totalShell / 16) ≤ (1 + ε) * totalShell := by + nlinarith only [htotal, htotal0, mul_nonneg hε htotal0] + calc + _ ≤ 4 * (level * (1 + 2 * ε) * Real.exp (-T) + shell / 16 + + Real.sqrt (3 * Real.exp (-T)) * (3 + (1 + ε) * level * 3)) + + 3 * (1 + ε) * (totalShell / 16) := + add_le_add (mul_le_mul_of_nonneg_right hfactor hmain0) herr + _ ≤ 4 * (22 * (1 + ε) * Real.exp (-T / 2) + shell / 16) + + 3 * (1 + ε) * (totalShell / 16) := by + linarith only [hmain] + _ ≤ _ := by nlinarith only [hrest, mul_nonneg (by linarith : 0 ≤ 1 + ε) he.le] + +theorem affine_error_envelope_at_precision {ε Q : ℝ} (hε : 0 ≤ ε) : + 100 * (1 + ε) * Real.exp (-(2 * (Q + Real.log (400 * (1 + ε)))) / 2) + + (1 + ε) * (Real.exp (-Q) / (4 * (1 + ε))) = Real.exp (-Q) / 2 := by + have ha : 0 < 1 + ε := by linarith + have hc : 0 < 400 * (1 + ε) := by positivity + have harg : -(2 * (Q + Real.log (400 * (1 + ε)))) / 2 = + -Q - Real.log (400 * (1 + ε)) := by ring + rw [harg, Real.exp_sub, Real.exp_log hc] + field_simp + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def affineStabilityInputBudget (p ε L T C modLog parameterLog : ℝ) : ℝ := + max p (max (T + 4) (max modLog + (max (affineComparisonPrimeThreshold (ε / (2 + ε)) (affineComparisonScale ε L T C) + 2 + 2 * parameterLog) + ((affineRemovalDepth T + affineComparisonTail ε L T : ℕ) : ℝ)))) + +theorem affineStabilityInputBudget_bounds (p ε L T C modLog parameterLog : ℝ) : + p ≤ affineStabilityInputBudget p ε L T C modLog parameterLog ∧ + T + 4 ≤ affineStabilityInputBudget p ε L T C modLog parameterLog ∧ + modLog ≤ affineStabilityInputBudget p ε L T C modLog parameterLog ∧ + affineComparisonPrimeThreshold (ε / (2 + ε)) (affineComparisonScale ε L T C) + 2 + 2 * parameterLog ≤ + affineStabilityInputBudget p ε L T C modLog parameterLog ∧ + ((affineRemovalDepth T + affineComparisonTail ε L T : ℕ) : ℝ) ≤ + affineStabilityInputBudget p ε L T C modLog parameterLog := by + unfold affineStabilityInputBudget + refine ⟨le_max_left _ _, ?_, ?_, ?_, ?_⟩ + · exact (le_max_left _ _).trans (le_max_right _ _) + · exact (le_max_left _ _).trans ((le_max_right _ _).trans (le_max_right _ _)) + · exact (le_max_left _ _).trans ((le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _))) + · exact (le_max_right _ _).trans ((le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _))) + +theorem affineStabilityInputBudget_mask {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + (p ε modLog : ℝ) {L T C parameterLog : ℝ} {D : ℕ} + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hD : 0 < D) + (hparameter : (D : ℝ) ≤ Real.exp parameterLog) : + ((affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D).card : ℝ) ≤ + affineStabilityInputBudget p ε L T C modLog parameterLog := by + have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1 + have hm := affineSamplerPrimeMask_card_le (ξ := ε / (2 + ε)) prime hprime hinj hP + (sourceM := 1) (siteM := 1) (sourceLog := 0) (siteLog := 0) + (by decide) (by decide) hD (by simp) (by simp) hparameter + have hm' : ((affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D).card : ℝ) ≤ + affineComparisonPrimeThreshold (ε / (2 + ε)) (affineComparisonScale ε L T C) + 2 + 2 * parameterLog := by + simpa only [mul_zero, add_zero] using hm + exact hm'.trans (affineStabilityInputBudget_bounds p ε L T C modLog parameterLog).2.2.2.1 + +noncomputable def affineReferenceTargetTime (ε Q : ℝ) : ℝ := + 2 * (Q + Real.log (400 * (1 + ε))) + +noncomputable def affineReferenceTargetShell (ε Q : ℝ) : ℝ := + Real.exp (-Q) / (4 * (1 + ε)) + +theorem affineReferenceTargetTime_nonneg {ε Q : ℝ} (hε : 0 ≤ ε) (hQ : 0 ≤ Q) : + 0 ≤ affineReferenceTargetTime ε Q := by + have hlog : 0 ≤ Real.log (400 * (1 + ε)) := Real.log_nonneg (by linarith) + unfold affineReferenceTargetTime + positivity + +theorem affineReferenceTargetShell_pos {ε : ℝ} (Q : ℝ) (hε : 0 ≤ ε) : + 0 < affineReferenceTargetShell ε Q := by + unfold affineReferenceTargetShell + positivity + +theorem affine_error_envelope_le_precision {ε Q T totalShell : ℝ} (hε : 0 ≤ ε) + (hT : affineReferenceTargetTime ε Q ≤ T) + (hshell : totalShell ≤ affineReferenceTargetShell ε Q) : + 100 * (1 + ε) * Real.exp (-T / 2) + (1 + ε) * totalShell ≤ Real.exp (-Q) / 2 := by + have ht : Real.exp (-T / 2) ≤ Real.exp (-affineReferenceTargetTime ε Q / 2) := + Real.exp_le_exp.mpr (by linarith) + have hfirst := mul_le_mul_of_nonneg_left ht (by positivity : 0 ≤ 100 * (1 + ε)) + have hsecond := mul_le_mul_of_nonneg_left hshell (by linarith : 0 ≤ 1 + ε) + exact (add_le_add hfirst hsecond).trans_eq (affine_error_envelope_at_precision hε) + +theorem affine_error_envelope_lt_target {ε Q T totalShell : ℝ} (hε : 0 ≤ ε) + (hT : affineReferenceTargetTime ε Q ≤ T) + (hshell : totalShell ≤ affineReferenceTargetShell ε Q) : + 100 * (1 + ε) * Real.exp (-T / 2) + (1 + ε) * totalShell < Real.exp (-Q) := by + have h := affine_error_envelope_le_precision hε hT hshell + linarith [Real.exp_pos (-Q)] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffinePrimitiveLogBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffinePrimitiveLogBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..b927857fd1b4eed3d2e3d2dc247a82586044a2cf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffinePrimitiveLogBudget.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.Progressions.Polynomial.AffineDegreeChoice + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def affineComparisonTail (ε L T : ℝ) : ℕ := + CyclicCrootSisask.spectralIterations (ε / (2 + ε)) (L + 2 * T + 4) + +noncomputable def affineComparisonScale (ε L T C : ℝ) : ℝ := + L + T + 2 + (affineRemovalDepth T + affineComparisonTail ε L T : ℕ) + C + +noncomputable def affineComparisonMoment (P : ℝ) : ℕ := + 2 * (Nat.floor (P / 2) + 1) + +theorem affineComparisonScale_bounds {ε L T C : ℝ} + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) : + 0 ≤ affineComparisonScale ε L T C ∧ + L + T + 2 ≤ affineComparisonScale ε L T C ∧ + ((affineRemovalDepth T + affineComparisonTail ε L T : ℕ) : ℝ) ≤ affineComparisonScale ε L T C ∧ + C ≤ affineComparisonScale ε L T C := by + have hn : (0 : ℝ) ≤ (affineRemovalDepth T + affineComparisonTail ε L T : ℕ) := Nat.cast_nonneg _ + unfold affineComparisonScale + constructor + · positivity + constructor + · linarith + constructor <;> linarith + +theorem affineComparisonScale_count {ι : Type*} [Fintype ι] {ε L T C : ℝ} + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) : + (Fintype.card ι : ℝ) ≤ Real.exp (affineComparisonScale ε L T C) := + hcount.trans (Real.exp_le_exp.mpr (affineComparisonScale_bounds (ε := ε) hL hT hC).2.2.2) + +theorem affineComparisonMoment_bounds {P : ℝ} (hP : 0 ≤ P) : + 2 ≤ affineComparisonMoment P ∧ Even (affineComparisonMoment P) ∧ + P ≤ (affineComparisonMoment P : ℝ) ∧ (affineComparisonMoment P : ℝ) ≤ P + 2 := by + unfold affineComparisonMoment + refine ⟨by omega, even_two_mul _, ?_, ?_⟩ + · have h := Nat.lt_floor_add_one (P / 2) + push_cast + linarith + · have h := Nat.floor_le (by positivity : 0 ≤ P / 2) + push_cast + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def affinePrimitiveLogBudget (P : ℝ) : ℝ := 16 * (P + 3) + +theorem affinePrimitiveLogBudget_nonneg {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ affinePrimitiveLogBudget P := by unfold affinePrimitiveLogBudget; positivity + +theorem affineRemovalDepth_le_logBudget {T P : ℝ} (hT : 0 ≤ T) (hTP : T ≤ P) : + (affineRemovalDepth T : ℝ) ≤ 2 * P + 10 := by + have h := CyclicCrootSisask.spectralIterations_le_logBudget (epsilon := 1) (A := 0) + (by norm_num) hT le_rfl (by simp) + change (affineRemovalDepth T : ℝ) ≤ _ at h + linarith + +theorem affineComparisonTail_le_logBudget {epsilon L T P : ℝ} + (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hLP : L ≤ P) (hTP : T ≤ P) + (hinverse : epsilon⁻¹ ≤ Real.exp P) : + (affineComparisonTail epsilon L T : ℝ) ≤ 8 * P + 22 := by + have h := CyclicCrootSisask.spectralIterations_le_logBudget + (epsilon := epsilon / (2 + epsilon)) (p := L + 2 * T + 4) (A := P + 2) + (by positivity) (by positivity) (by positivity) + (affineAllowance_inverse_le_exp hepsilon hepsilon1 hinverse) + change (affineComparisonTail epsilon L T : ℝ) ≤ _ at h + linarith + +theorem affineComparisonPrimitive_bounds {epsilon L T C P : ℝ} + (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hP : 0 ≤ P) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) + (hLP : L ≤ P) (hTP : T ≤ P) (hCP : C ≤ P) + (hinverse : epsilon⁻¹ ≤ Real.exp P) : + ((affineRemovalDepth T + affineComparisonTail epsilon L T : ℕ) : ℝ) ≤ affinePrimitiveLogBudget P ∧ + affineComparisonScale epsilon L T C ≤ affinePrimitiveLogBudget P ∧ + (affineComparisonMoment (affineComparisonScale epsilon L T C) : ℝ) ≤ affinePrimitiveLogBudget P + 2 := by + have hj := affineRemovalDepth_le_logBudget hT hTP + have ht := affineComparisonTail_le_logBudget hepsilon hepsilon1 hP hL hT hLP hTP hinverse + have hsum : ((affineRemovalDepth T + affineComparisonTail epsilon L T : ℕ) : ℝ) ≤ + 10 * P + 32 := by push_cast; linarith + have hs : affineComparisonScale epsilon L T C ≤ affinePrimitiveLogBudget P := by + unfold affineComparisonScale affinePrimitiveLogBudget + linarith + refine ⟨?_, hs, ?_⟩ + · unfold affinePrimitiveLogBudget + linarith + · have hm := (affineComparisonMoment_bounds (affineComparisonScale_bounds (ε := epsilon) hL hT hC).1).2.2.2 + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineProfileTranslationL1.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineProfileTranslationL1.lean new file mode 100644 index 0000000000000000000000000000000000000000..b441e6ba48f408d80f34f55a8bb4b0a1af4d9864 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineProfileTranslationL1.lean @@ -0,0 +1,45 @@ +import OAI.Combinatorics.Progressions.Geometry.ScalarSupportTranslationL1 + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +theorem affineProductProfile_translation_l1 {I : Type*} [Fintype I] + (c w : I → ℝ) {δ : ℝ} (hδ : 0 < δ) (hw : ∀ i, δ ≤ w i) (a b : I → ℝ) : + (∫ x, |affineProductProfile c w (x + a) - affineProductProfile c w (x + b)|) ≤ + (Fintype.card I * (4 * (probabilityProfileLipschitz : ℝ) / δ)) * dist a b := by + classical + have hwp (i) : 0 < w i := hδ.trans_le (hw i) + have hi (z : I → ℝ) (i) : Integrable (fun x => affineProbabilityProfile (c i) (w i) (x + z i)) := + (affineProbabilityProfile_integrable (c i) (hwp i)).comp_add_right (z i) + have hm (z : I → ℝ) (i) : (∫ x, affineProbabilityProfile (c i) (w i) (x + z i)) = 1 := by + rw [integral_add_right_eq_self, affineProbabilityProfile_integral (c i) (hwp i)] + have h := product_density_l1_le_sum + (fun i x => affineProbabilityProfile (c i) (w i) (x + a i)) + (fun i x => affineProbabilityProfile (c i) (w i) (x + b i)) + (hi a) (hi b) (fun i _ => affineProbabilityProfile_nonneg (c i) (hwp i) _) + (fun i _ => affineProbabilityProfile_nonneg (c i) (hwp i) _) (hm a) (hm b) + change (∫ x, |affineProductProfile c w (x + a) - affineProductProfile c w (x + b)|) ≤ _ at h + refine h.trans ?_ + calc + _ ≤ ∑ _i : I, (4 * (probabilityProfileLipschitz : ℝ) / δ) * dist a b := by + apply Finset.sum_le_sum + intro i _ + apply (affineProbabilityProfile_translation_l1 (c i) (a i) (b i) (hwp i)).trans + apply mul_le_mul + · exact div_le_div_of_nonneg_left (by positivity) hδ (hw i) + · simpa only [Real.dist_eq] using dist_le_pi_dist a b i + · exact abs_nonneg _ + · positivity + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineRefinedCoefficients.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineRefinedCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fcd14db2284dc4a0033a8f72414ed2bf3a4c4c3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineRefinedCoefficients.lean @@ -0,0 +1,33 @@ +import OAI.Combinatorics.Progressions.Linear.SharedFreeCommonProjection + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped TensorProduct BigOperators + +theorem affine_refined_coefficient_mem {L ι : Type*} [AddCommGroup L] [Module ℚ L] + [Fintype ι] {s : ℕ} (C D : Fin s → Submodule ℚ L) + (K : Fin s → Submodule ℚ (Fin 4 → L)) + (G : VectorPolynomial Unit ℚ (ℝ ⊗[ℚ] L)) + (α : Fin s → ℝ ⊗[ℚ] L) (β : ι → Fin s → ℝ ⊗[ℚ] L) (x : ι → ℝ) + (hG : ∀ d : Fin s, coefficients G (Finsupp.single () (d.val + 1)) ∈ + ((fourRefinedRelation (C d) (D d) (K d)).map (LinearMap.proj 0)).baseChange ℝ) + (hα : ∀ d, α d ∈ (D d).baseChange ℝ) + (hβ : ∀ j d, β j d ∈ (D d).baseChange ℝ) (d : Fin s) : + coefficients (G + positiveUnivariate (fun d => α d + ∑ j, x j • β j d)) + (Finsupp.single () (d.val + 1)) ∈ + ((fourRefinedRelation (C d) (D d) (K d)).map (LinearMap.proj 0)).baseChange ℝ := by + rw [map_add, Finsupp.add_apply, positiveUnivariate_coefficient] + apply Submodule.add_mem _ (hG d) + apply Submodule.baseChange_mono ℝ (dependent_le_refined_firstProjection (C d) (D d) (K d)) + exact Submodule.add_mem _ (hα d) + (Submodule.sum_mem _ (fun j _ => Submodule.smul_mem _ _ (hβ j d))) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidualRecovery.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidualRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..8759a73bf72ba71a1dc7c4868ac008f0e9662514 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidualRecovery.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.Progressions.Linear.WeightedPatchKernel + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +def recoveredIntegerLift {d m : ℕ} (M : Fin m → Fin d → ℤ) (c : Fin m → ℤ) + (k : Fin d → ℤ) : Fin m → ℤ := fun i => c i + ∑ j, M i j * k j + +noncomputable def realIntegerMatrix {d m : ℕ} (M : Fin m → Fin d → ℤ) + (x : Fin d → ℝ) : Fin m → ℝ := fun i => ∑ j, (M i j : ℝ) * x j + +noncomputable def recoveredSmallLift {d m : ℕ} (M : Fin m → Fin d → ℤ) + (a : Fin d → ℝ) (c : Fin m → ℤ) (e : Fin d → ℝ) : Fin m → ℝ := + fun i => (∑ j, (M i j : ℝ) * (a j - e j)) - c i + +theorem recoveredSmallLift_at_integer {d m : ℕ} (M : Fin m → Fin d → ℤ) + (a x : Fin d → ℝ) (c : Fin m → ℤ) (k : Fin d → ℤ) : + recoveredSmallLift M a c (fun j => (k j : ℝ) - (x - a) j) = + fun i => realIntegerMatrix M x i - (recoveredIntegerLift M c k i : ℝ) := by + funext i + simp only [recoveredSmallLift, realIntegerMatrix, recoveredIntegerLift, Pi.sub_apply] + push_cast + simp only [mul_sub, Finset.sum_sub_distrib] + ring + +theorem recoveredSmallLift_lipschitz {d m : ℕ} (M : Fin m → Fin d → ℤ) + (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0) + (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) : LipschitzWith K (recoveredSmallLift M a c) := by + apply LipschitzWith.of_dist_le_mul + intro x y + apply (dist_pi_le_iff (mul_nonneg K.coe_nonneg dist_nonneg)).mpr + intro i + simp only [recoveredSmallLift, Real.dist_eq] + rw [sub_sub_sub_cancel_right, ← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j, |(M i j : ℝ) * (a j - x j) - (M i j : ℝ) * (a j - y j)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ j, |(M i j : ℝ)| * dist x y := by + apply Finset.sum_le_sum + intro j _ + rw [← mul_sub, abs_mul] + apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) + simpa only [sub_sub_sub_cancel_left, abs_sub_comm, Real.dist_eq] using dist_le_pi_dist x y j + _ = (∑ j, |(M i j : ℝ)|) * dist x y := (Finset.sum_mul _ _ _).symm + _ ≤ K * dist x y := mul_le_mul_of_nonneg_right (hM i) dist_nonneg + +noncomputable def recoveredCellKernel {d m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m) + (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0) + (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) : PatchKernel d := + Φ.weightAlong Ψ (recoveredSmallLift M a c) K (recoveredSmallLift_lipschitz M a c K hM) + +@[simp] theorem recoveredCellKernel_lip {d m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m) + (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0) + (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) : + (recoveredCellKernel Φ Ψ M a c K hM).lip = Φ.lip + Ψ.lip * K := rfl + +@[simp] theorem recoveredCellKernel_value {d m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m) + (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) (c : Fin m → ℤ) (K : ℝ≥0) + (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) (e : Fin d → ℝ) : + (recoveredCellKernel Φ Ψ M a c K hM).value e = Φ.value e * Ψ.value (recoveredSmallLift M a c e) := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueAccuracy.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fb5cc596b781b0333ffddf05956882e228a93e9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueAccuracy.lean @@ -0,0 +1,79 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalPairAccuracyLogBounds + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def affineComparisonAccuracyLog (b : ℕ) (P L T : ℝ) : ℝ := + (P + 3) ^ 3 + 2 * (b : ℝ) * (P + 2) + L + T + 4 + +noncomputable def affineComparisonAccuracy (b : ℕ) (P L T : ℝ) : ℝ := + Real.exp (-affineComparisonAccuracyLog b P L T) + +theorem affineComparisonAccuracy_bounds {P L T level : ℝ} (b : ℕ) + (hP : 0 ≤ P) (hL : 0 ≤ L) (hT : 0 ≤ T) (hlevel : Real.exp (-L) ≤ level) : + 0 < affineComparisonAccuracy b P L T ∧ affineComparisonAccuracy b P L T < 1 ∧ + affineComparisonAccuracy b P L T ≤ Real.exp (-T) / 8 ∧ + affineComparisonAccuracy b P L T ≤ level * Real.exp (-T) / 8 ∧ + affineComparisonAccuracy b P L T ≤ (1 / 2) * Real.exp (-((P + 3) ^ 3)) := by + have hp : 0 ≤ (P + 3) ^ 3 := by positivity + have hb : 0 ≤ 2 * (b : ℝ) * (P + 2) := by positivity + have hpos : 0 < affineComparisonAccuracyLog b P L T := by + unfold affineComparisonAccuracyLog + linarith + refine ⟨Real.exp_pos _, ?_, ?_, ?_, ?_⟩ + · exact Real.exp_lt_one_iff.mpr (by linarith) + · exact exp_neg_le_exp_neg_div_eight (by unfold affineComparisonAccuracyLog; linarith) + · calc + _ ≤ Real.exp (-(L + T)) / 8 := + exp_neg_le_exp_neg_div_eight (by unfold affineComparisonAccuracyLog; linarith) + _ ≤ level * Real.exp (-T) / 8 := by + rw [neg_add, Real.exp_add] + exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right hlevel (Real.exp_pos _).le) (by norm_num) + · exact exp_neg_le_half_exp_neg (by unfold affineComparisonAccuracyLog; linarith) + +theorem affineComparisonAccuracy_gram {ι : Type*} [Fintype ι] [DecidableEq ι] + {P L T : ℝ} (b : ℕ) (hP : 0 ≤ P) (hL : 0 ≤ L) (hT : 0 ≤ T) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) : + 2 * affineComparisonAccuracy b P L T * ((lowDegreeCoordinateSets ι b).card : ℝ) ^ 2 * + (4 : ℝ) ^ b * (1 + affineComparisonAccuracy b P L T) ^ 2 ≤ Real.exp (-T) := by + let η := affineComparisonAccuracy b P L T + have he := affineComparisonAccuracy_bounds (level := Real.exp (-L)) b hP hL hT le_rfl + have hη0 : 0 < η := he.1 + have hη1 : η < 1 := he.2.1 + have hc := lowDegreeCoordinateSets_card_le_exp hP hcount b + have hc2 : ((lowDegreeCoordinateSets ι b).card : ℝ) ^ 2 ≤ + Real.exp (2 * (b : ℝ) * (P + 1)) := by + calc + _ ≤ (Real.exp ((b : ℝ) * (P + 1))) ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg _) hc 2 + _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hfour : (4 : ℝ) ≤ Real.exp 2 := by + calc + 4 = (2 : ℝ) ^ 2 := by norm_num + _ ≤ (Real.exp 1) ^ 2 := pow_le_pow_left₀ (by norm_num) htwo 2 + _ = _ := by rw [← Real.exp_nat_mul]; norm_num + have hp4 : (4 : ℝ) ^ b ≤ Real.exp (2 * (b : ℝ)) := by + exact (pow_le_pow_left₀ (by norm_num) hfour b).trans_eq (by rw [← Real.exp_nat_mul]; congr 1; ring) + have hsq : (1 + η) ^ 2 ≤ 4 := by nlinarith + have hsmall : η ≤ Real.exp (-(2 * (b : ℝ) * (P + 2) + T)) / 8 := by + apply exp_neg_le_exp_neg_div_eight + unfold affineComparisonAccuracyLog + have hp : 0 ≤ (P + 3) ^ 3 := by positivity + linarith + change 2 * η * _ ^ 2 * _ ^ b * (1 + η) ^ 2 ≤ _ + calc + _ ≤ 2 * η * Real.exp (2 * (b : ℝ) * (P + 1)) * Real.exp (2 * (b : ℝ)) * 4 := by gcongr + _ = 8 * η * (Real.exp (2 * (b : ℝ) * (P + 1)) * Real.exp (2 * (b : ℝ))) := by ring + _ = 8 * η * Real.exp (2 * (b : ℝ) * (P + 2)) := by rw [← Real.exp_add]; congr 2; ring + _ ≤ 8 * (Real.exp (-(2 * (b : ℝ) * (P + 2) + T)) / 8) * Real.exp (2 * (b : ℝ) * (P + 2)) := by gcongr + _ = Real.exp (-(2 * (b : ℝ) * (P + 2) + T)) * Real.exp (2 * (b : ℝ) * (P + 2)) := by ring + _ = Real.exp (-T) := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueCoordinateEquiv.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueCoordinateEquiv.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2d9a74beed7c0f2893b74f3df28549d965cdcd3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineResidueCoordinateEquiv.lean @@ -0,0 +1,31 @@ +import Mathlib.Algebra.Group.Equiv.Basic +import Mathlib.Algebra.Group.Units.Equiv +import Mathlib.Data.ZMod.Basic + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def affineResidueCoordinateEquiv {σ : Type*} (M q : ℕ) (a : σ → ℤ) + (hcop : M.Coprime q) : (σ → ZMod q) ≃ (σ → ZMod q) := + Equiv.piCongrRight fun j => + (ZMod.unitOfCoprime M hcop).mulLeft.trans (Equiv.addLeft (a j : ZMod q)) + +theorem affineResidueCoordinateEquiv_apply {σ : Type*} (M q : ℕ) (a : σ → ℤ) + (hcop : M.Coprime q) (x : σ → ZMod q) (j : σ) : + affineResidueCoordinateEquiv M q a hcop x j = (a j : ZMod q) + (M : ZMod q) * x j := rfl + +theorem affineResidueCoordinateEquiv_intCast {σ : Type*} (M q : ℕ) (a : σ → ℤ) + (hcop : M.Coprime q) (z : σ → ℤ) : + affineResidueCoordinateEquiv M q a hcop (fun j => (z j : ZMod q)) = + (fun j => ((a j + (M : ℤ) * z j : ℤ) : ZMod q)) := by + funext j + simp only [affineResidueCoordinateEquiv_apply, Int.cast_add, Int.cast_mul, Int.cast_natCast] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineSampleAlphabet.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSampleAlphabet.lean new file mode 100644 index 0000000000000000000000000000000000000000..1bf5ba013d48ae6eae134955355d593f2c6d0d7e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSampleAlphabet.lean @@ -0,0 +1,635 @@ +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Lattices.PrimeCoordinateCells +import OAI.Combinatorics.Progressions.Linear.KernelCoreComparison + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {q : ℕ} [NeZero q] {J G : Type*} [Fintype J] + [AddCommGroup G] [Module (ZMod q) G] + +noncomputable def residueColumnMap (V : J → G) : (J → ZMod q) →+ G where + toFun t := ∑ j, t j • V j + map_zero' := by simp + map_add' t u := by simp [add_smul, Finset.sum_add_distrib] + +omit [NeZero q] in +theorem residueColumnMap_single (V : J → G) (j : J) : + residueColumnMap (q := q) V (Pi.single j (1 : ZMod q)) = V j := by + simp [residueColumnMap, Pi.single_apply, ite_smul] + +theorem additiveCharacter_zmod_smul (χ : AddChar G ℂ) (t : ZMod q) (x : G) : + χ (t • x) = χ x ^ t.val := by + conv_lhs => rw [← ZMod.natCast_zmod_val t, Nat.cast_smul_eq_nsmul] + exact χ.map_nsmul_eq_pow t.val x + +theorem residueColumn_character_zero_iff (V : J → G) (χ : AddChar G ℂ) : + χ.compAddMonoidHom (residueColumnMap (q := q) V) = 0 ↔ ∀ j, χ (V j) = 1 := by + constructor + · intro h j + have hh := DFunLike.congr_fun h (Pi.single j (1 : ZMod q)) + simpa only [AddChar.compAddMonoidHom_apply, residueColumnMap_single, AddChar.zero_apply] using hh + · intro h + ext t + change χ (∑ j, t j • V j) = 1 + exact (additiveCharacterKernel χ).sum_mem (fun j _ => by + change χ (t j • V j) = 1 + rw [additiveCharacter_zmod_smul, h, one_pow]) + +theorem residueColumn_character_mean (V : J → G) (χ : AddChar G ℂ) : + (𝔼 t : J → ZMod q, χ (residueColumnMap (q := q) V t)) = + if ∀ j, χ (V j) = 1 then 1 else 0 := by + have h := AddChar.expect_eq_ite (χ.compAddMonoidHom (residueColumnMap (q := q) V)) + simpa only [AddChar.compAddMonoidHom_apply, residueColumn_character_zero_iff] using h + +noncomputable def residueColumnAverage (V : J → G) (f : G → ℂ) (x : G) : ℂ := + 𝔼 t : J → ZMod q, f (x + residueColumnMap (q := q) V t) + +variable [Fintype G] + +theorem finiteFourierCoeff_residueColumnAverage (V : J → G) (f : G → ℂ) (χ : AddChar G ℂ) : + finiteFourierCoeff (residueColumnAverage (q := q) V f) χ = + (if ∀ j, χ (V j) = 1 then 1 else 0) * finiteFourierCoeff f χ := by + have htranslate (a : G) : finiteFourierCoeff (fun x => f (x + a)) χ = + χ a * finiteFourierCoeff f χ := by + have h := finiteFourierCoeff_translate f (-a) χ + rw [AddChar.map_neg_eq_conj] at h + simpa only [sub_neg_eq_add, Complex.star_def, starRingEnd_self_apply] using h + unfold finiteFourierCoeff residueColumnAverage + simp_rw [Finset.expect_mul] + rw [Finset.expect_comm] + change (𝔼 t : J → ZMod q, finiteFourierCoeff (fun x => f (x + residueColumnMap (q := q) V t)) χ) = _ + simp_rw [htranslate] + rw [← Finset.expect_mul, residueColumn_character_mean] + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {J G : Type*} [Fintype J] [AddCommGroup G] [Fintype G] + +theorem residueColumn_survival_probability (χ : AddChar G ℂ) : + (𝔼 V : J → G, if ∀ j, χ (V j) = 1 then (1 : ℝ) else 0) = + (𝔼 x : G, if χ x = 1 then (1 : ℝ) else 0) ^ Fintype.card J := by + have hpoint (V : J → G) : + (if ∀ j, χ (V j) = 1 then (1 : ℝ) else 0) = + ∏ j, if χ (V j) = 1 then (1 : ℝ) else 0 := by + by_cases h : ∀ j, χ (V j) = 1 + · simp [h] + · rw [ite_eq_right h] + push Not at h + obtain ⟨j, hj⟩ := h + exact (Finset.prod_eq_zero (Finset.mem_univ j) (by simp [hj])).symm + calc + _ = 𝔼 V : J → G, ∏ j, if χ (V j) = 1 then (1 : ℝ) else 0 := + Finset.expect_congr rfl (fun V _ => hpoint V) + _ = (∑ x : G, if χ x = 1 then (1 : ℝ) else 0) ^ Fintype.card J / + (Fintype.card G : ℝ) ^ Fintype.card J := by + rw [Fintype.expect_eq_sum_div_card, Fintype.card_fun, Nat.cast_pow] + congr 1 + simpa using (Fintype.prod_sum + (fun _j : J => fun x : G => if χ x = 1 then (1 : ℝ) else 0)).symm + _ = _ := by rw [Fintype.expect_eq_sum_div_card, div_pow] + +variable {q : ℕ} [NeZero q] [Module (ZMod q) G] + +theorem residueColumnAverage_energy (V : J → G) (f : G → ℂ) : + (𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) = + ∑ χ : AddChar G ℂ, + (if ∀ j, χ (V j) = 1 then (1 : ℝ) else 0) * ‖finiteFourierCoeff f χ‖ ^ 2 := by + rw [← finiteFourier_parseval] + apply Finset.sum_congr rfl + intro χ _ + rw [finiteFourierCoeff_residueColumnAverage] + split_ifs <;> simp + +theorem residueColumnAverage_mean_energy (f : G → ℂ) : + (𝔼 V : J → G, 𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) = + ∑ χ : AddChar G ℂ, + (𝔼 x : G, if χ x = 1 then (1 : ℝ) else 0) ^ Fintype.card J * + ‖finiteFourierCoeff f χ‖ ^ 2 := by + simp_rw [residueColumnAverage_energy] + rw [Finset.expect_sum_comm] + apply Finset.sum_congr rfl + intro χ _ + rw [← Finset.expect_mul, residueColumn_survival_probability] + +theorem primeAffine_contraction_sq {p a : ℕ} (hp : p.Prime) + (hG : Fintype.card G = p ^ a) (f : G → ℂ) (hf : (𝔼 x, f x) = 0) : + (𝔼 V : J → G, 𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) ≤ + (p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 x : G, ‖f x‖ ^ 2) := by + rw [residueColumnAverage_mean_energy] + calc + _ ≤ ∑ χ : AddChar G ℂ, (p : ℝ)⁻¹ ^ Fintype.card J * + ‖finiteFourierCoeff f χ‖ ^ 2 := by + apply Finset.sum_le_sum + intro χ _ + by_cases hχ : χ = 0 + · subst χ + have hz : finiteFourierCoeff f 0 = 0 := by + simpa [finiteFourierCoeff] using hf + simp [hz] + · apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + exact pow_le_pow_left₀ + (Finset.expect_nonneg (fun x _ => by split_ifs <;> norm_num)) + (primePowerCharacter_kernel_probability hp hG hχ) _ + _ = _ := by rw [← Finset.mul_sum, finiteFourier_parseval] + +theorem primeAffine_contraction {p a : ℕ} (hp : p.Prime) + (hG : Fintype.card G = p ^ a) (f : G → ℂ) (hf : (𝔼 x, f x) = 0) : + Real.sqrt (𝔼 V : J → G, 𝔼 x : G, ‖residueColumnAverage (q := q) V f x‖ ^ 2) ≤ + (p : ℝ) ^ (-(Fintype.card J : ℝ) / 2) * Real.sqrt (𝔼 x : G, ‖f x‖ ^ 2) := by + have hs : Real.sqrt ((p : ℝ)⁻¹ ^ Fintype.card J) = + (p : ℝ) ^ (-(Fintype.card J : ℝ) / 2) := by + rw [Real.sqrt_eq_rpow] + calc + _ = ((p : ℝ) ^ (-(Fintype.card J : ℝ))) ^ (1 / (2 : ℝ)) := by + rw [Real.rpow_neg (Nat.cast_nonneg p), Real.rpow_natCast, inv_pow] + _ = (p : ℝ) ^ (-(Fintype.card J : ℝ) * (1 / 2)) := + (Real.rpow_mul (Nat.cast_nonneg p) _ _).symm + _ = _ := by congr 1; ring + calc + _ ≤ Real.sqrt ((p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 x : G, ‖f x‖ ^ 2)) := + Real.sqrt_le_sqrt (primeAffine_contraction_sq (q := q) hp hG f hf) + _ = _ := by rw [Real.sqrt_mul (by positivity), hs] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {I J : Type*} [Fintype I] [Fintype J] + {p a : ℕ} [NeZero (p ^ a)] + +theorem primePowerResidue_contraction_sq (hp : p.Prime) + (f : (I → ZMod (p ^ a)) → ℂ) (hf : (𝔼 x, f x) = 0) : + (𝔼 V : J → I → ZMod (p ^ a), 𝔼 X : I → ZMod (p ^ a), + ‖𝔼 t : J → ZMod (p ^ a), f (X + ∑ j, t j • V j)‖ ^ 2) ≤ + (p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 X, ‖f X‖ ^ 2) := by + have hG : Fintype.card (I → ZMod (p ^ a)) = p ^ (a * Fintype.card I) := by + simp [pow_mul] + simpa only [residueColumnAverage, residueColumnMap, AddMonoidHom.coe_mk, + ZeroHom.coe_mk] using primeAffine_contraction_sq (J := J) (q := p ^ a) hp hG f hf + +theorem primePowerResidue_contraction (hp : p.Prime) + (f : (I → ZMod (p ^ a)) → ℂ) (hf : (𝔼 x, f x) = 0) : + Real.sqrt (𝔼 V : J → I → ZMod (p ^ a), 𝔼 X : I → ZMod (p ^ a), + ‖𝔼 t : J → ZMod (p ^ a), f (X + ∑ j, t j • V j)‖ ^ 2) ≤ + (p : ℝ) ^ (-(Fintype.card J : ℝ) / 2) * Real.sqrt (𝔼 X, ‖f X‖ ^ 2) := by + have hG : Fintype.card (I → ZMod (p ^ a)) = p ^ (a * Fintype.card I) := by + simp [pow_mul] + simpa only [residueColumnAverage, residueColumnMap, AddMonoidHom.coe_mk, + ZeroHom.coe_mk] using primeAffine_contraction (J := J) (q := p ^ a) hp hG f hf + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {q : ℕ} [NeZero q] {J G : Type*} [Fintype J] + [AddCommGroup G] [Module (ZMod q) G] + +noncomputable def residueColumnRealAverage (V : J → G) (f : G → ℝ) (x : G) : ℝ := + 𝔼 t : J → ZMod q, f (x + residueColumnMap (q := q) V t) + +theorem residueColumnAverage_ofReal (V : J → G) (f : G → ℝ) (x : G) : + residueColumnAverage (q := q) V (fun y => (f y : ℂ)) x = + (residueColumnRealAverage (q := q) V f x : ℂ) := by + simp only [residueColumnAverage, residueColumnRealAverage, Fintype.expect_eq_sum_div_card, + Complex.ofReal_div, Complex.ofReal_sum, Complex.ofReal_natCast] + +variable [Fintype G] + +theorem residueColumnRealAverage_mean (V : J → G) (f : G → ℝ) : + (𝔼 x : G, residueColumnRealAverage (q := q) V f x) = 𝔼 x : G, f x := by + unfold residueColumnRealAverage + rw [Finset.expect_comm] + have hshift (t : J → ZMod q) : (𝔼 x : G, f (x + residueColumnMap (q := q) V t)) = 𝔼 x : G, f x := + Fintype.expect_equiv (Equiv.addRight (residueColumnMap (q := q) V t)) _ _ (fun _ => rfl) + simp only [hshift, Fintype.expect_const] + +theorem primeAffine_real_contraction_sq {p a : ℕ} (hp : p.Prime) + (hG : Fintype.card G = p ^ a) (f : G → ℝ) (hf : (𝔼 x, f x) = 0) : + (𝔼 V : J → G, 𝔼 x : G, residueColumnRealAverage (q := q) V f x ^ 2) ≤ + (p : ℝ)⁻¹ ^ Fintype.card J * (𝔼 x : G, f x ^ 2) := by + have hfc : (𝔼 x : G, (f x : ℂ)) = 0 := by + have hc := congrArg (fun y : ℝ => (y : ℂ)) hf + simpa only [Fintype.expect_eq_sum_div_card, Complex.ofReal_div, Complex.ofReal_sum, + Complex.ofReal_natCast, Complex.ofReal_zero] using hc + have h := primeAffine_contraction_sq (q := q) (J := J) hp hG (fun x => (f x : ℂ)) hfc + simpa only [residueColumnAverage_ofReal, Complex.norm_real, Real.norm_eq_abs, sq_abs] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {q : ℕ} [NeZero q] {J G : Type*} [Fintype J] + [AddCommGroup G] [Module (ZMod q) G] [Fintype G] + +noncomputable def residueAffineSource : FiniteProbabilityWeights ((J → G) × G) := + (FiniteProbabilityWeights.uniform (J → G)).prod (FiniteProbabilityWeights.uniform G) + +noncomputable def residueAffineKernel (z : (J → G) × G) : FiniteProbabilityWeights G := + (FiniteProbabilityWeights.uniform (J → ZMod q)).fiberLaw + (fun t => z.2 + residueColumnMap (q := q) z.1 t) + +theorem residueAffineKernel_mean (z : (J → G) × G) (f : G → ℝ) : + (residueAffineKernel (q := q) z).mean f = residueColumnRealAverage (q := q) z.1 f z.2 := by + rw [residueAffineKernel, FiniteProbabilityWeights.fiberLaw_mean, FiniteProbabilityWeights.uniform_mean] + rfl + +theorem residueAffineKernel_preserves_mean (f : G → ℝ) : + (residueAffineSource (J := J) (G := G)).mean (fun z => (residueAffineKernel (q := q) z).mean f) = + (FiniteProbabilityWeights.uniform G).mean f := by + simp only [residueAffineSource, FiniteProbabilityWeights.mean_prod, residueAffineKernel_mean, + FiniteProbabilityWeights.uniform_mean, residueColumnRealAverage_mean, Fintype.expect_const] + +noncomputable def residueAffineCoupling : + FiniteProbabilityCoupling (residueAffineSource (J := J) (G := G)) (FiniteProbabilityWeights.uniform G) := + FiniteProbabilityCoupling.ofKernel _ _ (residueAffineKernel (q := q)) + (residueAffineKernel_preserves_mean (q := q)) + +theorem residueAffineKernel_centered_sq {p a : ℕ} (hp : p.Prime) + (hG : Fintype.card G = p ^ a) (f : G → ℝ) + (hf : (FiniteProbabilityWeights.uniform G).mean f = 0) : + (residueAffineSource (J := J) (G := G)).mean (fun z => (residueAffineKernel (q := q) z).mean f ^ 2) ≤ + (p : ℝ)⁻¹ ^ Fintype.card J * (FiniteProbabilityWeights.uniform G).mean (fun x => f x ^ 2) := by + simp only [residueAffineSource, FiniteProbabilityWeights.mean_prod, residueAffineKernel_mean, + FiniteProbabilityWeights.uniform_mean] + exact primeAffine_real_contraction_sq hp hG f (by simpa only [FiniteProbabilityWeights.uniform_mean] using hf) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] + (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*} + [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)] + (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i) + +include hp hcard + +theorem affineCoupling_level_abs_le {κ : ℝ} (hκ : 0 ≤ κ) + (hcap : ∀ i, (p i : ℝ)⁻¹ ^ Fintype.card J ≤ κ ^ 2) + (k : ℕ) (w : (∀ i, (J → G i) × G i) → ℝ) (f : (∀ i, G i) → ℝ) : + let μ := fun i => residueAffineSource (J := J) (G := G i) + let ν := fun i => FiniteProbabilityWeights.uniform (G i) + |productCouplingPairing (fun i => residueAffineCoupling (q := q i) (J := J) (G := G i)) + (productANOVATruncation μ (Finset.univ.powersetCard k) w) + (productANOVATruncation ν (Finset.univ.powersetCard k) f)| ≤ + κ ^ k * Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) * + Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) := by + exact productCouplingPairing_level_abs_le _ _ (fun i => residueAffineKernel (q := q i)) + (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity) + (fun i => residueAffineKernel_centered_sq (hp i) (hcard i)) + (fun i => residueAffineKernel_preserves_mean (q := q i)) hκ hcap k w f + +theorem affineCoupling_tail_abs_le {κ : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) + (hcap : ∀ i, (p i : ℝ)⁻¹ ^ Fintype.card J ≤ κ ^ 2) + (r : ℕ) (D : Finset (Finset ι)) (hmin : ∀ S ∈ D, r ≤ S.card) + (w : (∀ i, (J → G i) × G i) → ℝ) (f : (∀ i, G i) → ℝ) : + let μ := fun i => residueAffineSource (J := J) (G := G i) + let ν := fun i => FiniteProbabilityWeights.uniform (G i) + |productCouplingPairing (fun i => residueAffineCoupling (q := q i) (J := J) (G := G i)) + (productANOVATruncation μ D w) (productANOVATruncation ν D f)| ≤ + κ ^ r * Real.sqrt (productANOVAEnergy μ D w) * Real.sqrt (productANOVAEnergy ν D f) := by + exact productCouplingPairing_tail_abs_le _ _ (fun i => residueAffineKernel (q := q i)) + (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity) + (fun i => residueAffineKernel_centered_sq (hp i) (hcard i)) + (fun i => residueAffineKernel_preserves_mean (q := q i)) hκ0 hκ1 hcap r D hmin w f + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem productAffine_centered_contraction_sq {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] + (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*} + [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)] + (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i) + (f : (∀ i, G i) → ℝ) : + (FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean + (fun x => productMatrixApply (fun i => centeredKernelMatrix (FiniteProbabilityWeights.uniform (G i)) + (residueAffineKernel (q := q i) (J := J))) f x ^ 2) ≤ + (∏ i, (p i : ℝ)⁻¹ ^ Fintype.card J) * + (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (G i))).mean + (fun y => f y ^ 2) := by + apply productMatrixApply_sq_le _ _ _ (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity) + intro i g + apply centeredKernelMatrix_sq_le _ _ _ (by positivity) + intro h hh + exact residueAffineKernel_centered_sq (hp i) (hcard i) h hh + +theorem productAffine_centered_pairing_sq {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] + (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*} + [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)] + (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i) + (w : (∀ i, (J → G i) × G i) → ℝ) (f : (∀ i, G i) → ℝ) : + ((FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean + (fun x => w x * productMatrixApply (fun i => centeredKernelMatrix (FiniteProbabilityWeights.uniform (G i)) + (residueAffineKernel (q := q i) (J := J))) f x)) ^ 2 ≤ + (∏ i, (p i : ℝ)⁻¹ ^ Fintype.card J) * + (FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean + (fun x => w x ^ 2) * + (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (G i))).mean + (fun y => f y ^ 2) := by + apply productMatrixApply_pairing_sq_le _ _ _ (fun i => (p i : ℝ)⁻¹ ^ Fintype.card J) (fun _ => by positivity) + intro i g + apply centeredKernelMatrix_sq_le _ _ _ (by positivity) + intro h hh + exact residueAffineKernel_centered_sq (hp i) (hcard i) h hh + +theorem productAffine_uniform_centered_sq {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] + (p q a : ι → ℕ) [∀ i, NeZero (q i)] {G : ι → Type*} + [∀ i, AddCommGroup (G i)] [∀ i, Module (ZMod (q i)) (G i)] [∀ i, Fintype (G i)] + (hp : ∀ i, (p i).Prime) (hcard : ∀ i, Fintype.card (G i) = p i ^ a i) + {P : ℝ} (hP : 0 < P) (hmin : ∀ i, P ≤ (p i : ℝ)) (f : (∀ i, G i) → ℝ) : + (FiniteProbabilityWeights.pi (fun i => residueAffineSource (J := J) (G := G i))).mean + (fun x => productMatrixApply (fun i => centeredKernelMatrix (FiniteProbabilityWeights.uniform (G i)) + (residueAffineKernel (q := q i) (J := J))) f x ^ 2) ≤ + (P⁻¹ ^ Fintype.card J) ^ Fintype.card ι * + (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (G i))).mean + (fun y => f y ^ 2) := by + apply (productAffine_centered_contraction_sq p q a hp hcard f).trans + apply mul_le_mul_of_nonneg_right _ (FiniteProbabilityWeights.mean_nonneg _ (fun y => sq_nonneg (f y))) + have hi (i : ι) : (p i : ℝ)⁻¹ ≤ P⁻¹ := by + simpa only [one_div] using one_div_le_one_div_of_le hP (hmin i) + have hh := Finset.prod_le_prod₀ (s := (Finset.univ : Finset ι)) + (fun i _ => pow_nonneg (inv_nonneg.mpr (Nat.cast_nonneg (p i))) (Fintype.card J)) + (fun i _ => pow_le_pow_left₀ (inv_nonneg.mpr (Nat.cast_nonneg (p i))) (hi i) (Fintype.card J)) + simpa only [Finset.prod_const, Finset.card_univ] using hh + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem primeCoordinateCell_mono {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) {I J : Finset ι} + {x y : ∀ i, σ → ZMod (q i)} (hIJ : I ⊆ J) (hxy : ∀ i ∈ I, y i = x i) : + primeCoordinateCell lo N q J y ⊆ primeCoordinateCell lo N q I x := by + intro z hz + obtain ⟨hz, heq⟩ := (mem_primeCoordinateCell lo N q J y z).mp hz + exact (mem_primeCoordinateCell lo N q I x z).mpr ⟨hz, fun i hi => (heq i (hIJ hi)).trans (hxy i hi)⟩ + +noncomputable def primeCoordinateMean {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : ℂ := + 𝔼 z : primeCoordinateCell lo N q I x, f z.val + +theorem primeCoordinateMean_eq_physical {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (u : σ → ℤ) (hu : u ∈ primeCoordinateCell lo N q I x) : + primeCoordinateMean f lo N q I x = physicalResidueMean f lo N (∏ i ∈ I, q i) u := by + unfold primeCoordinateMean + rw [primeCoordinateCell_anchor lo N q I x u hu] + exact primeCoordinateCell_mean lo N q hcop I u f + +noncomputable def PrimeCoordinateStable {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (r : ℕ) (δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : Prop := + ∀ J : Finset ι, Disjoint I J → J.card ≤ r → ∀ y : ∀ i, σ → ZMod (q i), + (∀ i ∈ I, y i = x i) → (primeCoordinateCell lo N q (I ∪ J) y).Nonempty → + ‖primeCoordinateMean f lo N q I x - primeCoordinateMean f lo N q (I ∪ J) y‖ ≤ δ + +theorem primeCoordinateStable_of_empty {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (r : ℕ) (δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (hempty : ¬ (primeCoordinateCell lo N q I x).Nonempty) : PrimeCoordinateStable f lo N q r δ I x := by + intro J hIJ hJ y hxy hnonempty + obtain ⟨z, hz⟩ := hnonempty + exact False.elim (hempty ⟨z, primeCoordinateCell_mono lo N q Finset.subset_union_left hxy hz⟩) + +universe u v + +theorem exists_prime_cell_physical_comparison + {ι : Type*} [DecidableEq ι] {σ : Type u} [Fintype σ] [DecidableEq σ] + {s bound : ℕ} {gap : ℝ} (base : PhysicalEpochSource.{u, v} σ s bound) + (T : base.model.Niltest (fun _ : σ => 1)) (horbit : T.orbit = base.fixedMap.orbit) + (hpositive : T.UnitIntervalValued) (hcomplexity : T.ComplexityLE base.incomingBudget) + (q : ι → ℕ) (hq : ∀ i, 0 < q i) (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (I J : Finset ι) (hIJ : Disjoint I J) (x y : ∀ i, σ → ZMod (q i)) + (hxy : ∀ i ∈ I, y i = x i) (u v : σ → ℤ) + (hu : u ∈ primeCoordinateCell base.lower base.sides q I x) + (hv : v ∈ primeCoordinateCell base.lower base.sides q (I ∪ J) y) + (hgap : 0 < gap) (hgap1 : gap ≤ 1) (hinverse : gap⁻¹ ≤ Real.exp base.incomingBudget) + (hrecord : 2 ≤ base.recordBudget) + (hdiscrepancy : gap ≤ ‖primeCoordinateMean T.eval base.lower base.sides q I x - + primeCoordinateMean T.eval base.lower base.sides q (I ∪ J) y‖) : + ∃ c : PhysicalEpochComparison base (∏ i ∈ I, q i) 1 (∏ i ∈ J, q i) gap, + c.Controlled ∧ c.anchor = u ∧ c.refined = v := by + have hvmem := primeCoordinateCell_mono base.lower base.sides q Finset.subset_union_left hxy hv + have hanchorCell := primeCoordinateCell_anchor base.lower base.sides q I x u hu + have hcompat : ∀ i, v i ≡ u i [ZMOD ((∏ j ∈ I, q j : ℕ) : ℤ)] := by + rw [hanchorCell] at hvmem + exact ((mem_primeCoordinateCell_anchor base.lower base.sides q hcop I u v).mp hvmem).2 + have huinside := (mem_translatedIntegerBox base.lower base.sides u).mp + ((mem_primeCoordinateCell base.lower base.sides q I x u).mp hu).1 + have hvinside := (mem_translatedIntegerBox base.lower base.sides v).mp + ((mem_primeCoordinateCell base.lower base.sides q (I ∪ J) y v).mp hv).1 + have hm : 0 < ∏ i ∈ I, q i := Finset.prod_pos (fun i _ => hq i) + have hJ : 0 < ∏ i ∈ J, q i := Finset.prod_pos (fun i _ => hq i) + have hphysical : gap ≤ ‖physicalResidueMean T.eval base.lower base.sides (∏ i ∈ I, q i) u - + physicalResidueMean T.eval base.lower base.sides ((∏ i ∈ I, q i) * ∏ i ∈ J, q i) v‖ := by + rw [primeCoordinateMean_eq_physical T.eval base.lower base.sides q hcop I x u hu, + primeCoordinateMean_eq_physical T.eval base.lower base.sides q hcop (I ∪ J) y v hv, + Finset.prod_union hIJ] at hdiscrepancy + exact hdiscrepancy + obtain ⟨c, hc, hcu, hcv, _, _⟩ := exists_initial_physical_comparison base T horbit hpositive hcomplexity + hm hJ u v huinside hvinside hcompat hgap hgap1 hinverse hrecord hphysical + exact ⟨c, hc, hcu, hcv⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def primeCoordinateObservation {ι σ : Type*} (q : ι → ℕ) (z : σ → ℤ) : ∀ i, σ → ZMod (q i) := + fun i j => (z j : ZMod (q i)) + +noncomputable def primeCoordinateReference {ι σ : Type*} [Fintype σ] [DecidableEq σ] + (q : ι → ℕ) [∀ i, NeZero (q i)] : ∀ i, FiniteProbabilityWeights (σ → ZMod (q i)) := + fun i => FiniteProbabilityWeights.uniform (σ → ZMod (q i)) + +theorem primeCoordinateReference_weight_pos {ι σ : Type*} [Fintype σ] [DecidableEq σ] + (q : ι → ℕ) [∀ i, NeZero (q i)] (i : ι) (x : σ → ZMod (q i)) : + 0 < (primeCoordinateReference (σ := σ) q i).weight x := by + dsimp only [primeCoordinateReference, FiniteProbabilityWeights.uniform] + positivity + +noncomputable def primeCoordinateLaw {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] : + FiniteProbabilityWeights (∀ i, σ → ZMod (q i)) := + (FiniteProbabilityWeights.uniformFinset (translatedIntegerBox lo N) hbox).fiberLaw + (fun z => primeCoordinateObservation q z.val) + +noncomputable def primeCoordinateDensity {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (f : (σ → ℤ) → ℝ) : (∀ i, σ → ZMod (q i)) → ℝ := + observedProductDensity (primeCoordinateReference (σ := σ) q) + (FiniteProbabilityWeights.uniformFinset (translatedIntegerBox lo N) hbox) + (fun z => primeCoordinateObservation q z.val) (fun z => f z.val) + +theorem primeCoordinateDensity_nonneg {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (f : (σ → ℤ) → ℝ) (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z) + (x : ∀ i, σ → ZMod (q i)) : 0 ≤ primeCoordinateDensity lo N hbox q f x := by + unfold primeCoordinateDensity observedProductDensity + apply finiteWeightDensity_nonneg + intro y + apply FiniteProbabilityWeights.fiberMean_nonneg + intro z + exact hf z.val z.property + +theorem primeCoordinateDensity_one {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (x : ∀ i, σ → ZMod (q i)) : + primeCoordinateDensity lo N hbox q (fun _ => 1) x = + (primeCoordinateLaw lo N hbox q).weight x / + (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).weight x := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +abbrev ResiduePrimeCoordinateCell {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) := + {z : IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a // + ∀ i ∈ I, (fun j => ((z j).val : ZMod (q i))) = x i} + +noncomputable def residuePrimeCoordinateMean {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : ℂ := by + classical + exact 𝔼 z : ResiduePrimeCoordinateCell lo N M a q I x, f (fun j => (z.val j).val) + +noncomputable def ResiduePrimeCoordinateStable {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (r : ℕ) (δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : Prop := + ∀ J : Finset ι, Disjoint I J → J.card ≤ r → ∀ y : ∀ i, σ → ZMod (q i), + (∀ i ∈ I, y i = x i) → Nonempty (ResiduePrimeCoordinateCell lo N M a q (I ∪ J) y) → + ‖residuePrimeCoordinateMean f lo N M a q I x - + residuePrimeCoordinateMean f lo N M a q (I ∪ J) y‖ ≤ δ + +noncomputable def primeCoordinateCell_subtypeEquiv {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + primeCoordinateCell lo N q I x ≃ + {z : translatedIntegerBox lo N // ∀ i ∈ I, (fun j => (z.val j : ZMod (q i))) = x i} where + toFun z := ⟨⟨z.val, ((mem_primeCoordinateCell lo N q I x z.val).mp z.property).1⟩, + ((mem_primeCoordinateCell lo N q I x z.val).mp z.property).2⟩ + invFun z := ⟨z.val.val, (mem_primeCoordinateCell lo N q I x z.val.val).mpr ⟨z.val.property, z.property⟩⟩ + left_inv _ := rfl + right_inv _ := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +def affineSampleAlphabetEquiv {J I R : Type*} : + (Option J × I → R) ≃ (J → I → R) × (I → R) where + toFun z := (fun j i => z (some j, i), fun i => z (none, i)) + invFun z := baseArrayJoin (fun k => z.1 k.1 k.2) z.2 + left_inv z := baseArrayJoin_eta z + right_inv _ := rfl + +theorem affineSampleAlphabet_weight {J I R : Type*} [Fintype J] [Fintype I] + [Fintype R] [AddCommGroup R] (z : Option J × I → R) : + (residueAffineSource (J := J) (G := I → R)).weight (affineSampleAlphabetEquiv z) = + (FiniteProbabilityWeights.uniform (Option J × I → R)).weight z := by + change (Fintype.card (J → I → R) : ℝ)⁻¹ * (Fintype.card (I → R) : ℝ)⁻¹ = + (Fintype.card (Option J × I → R) : ℝ)⁻¹ + rw [Fintype.card_congr (affineSampleAlphabetEquiv (J := J) (I := I) (R := R))] + simp only [Fintype.card_prod, Nat.cast_mul, mul_inv_rev] + ring + +theorem affineSampleAlphabet_mean {J I R : Type*} [Fintype J] [Fintype I] + [Fintype R] [AddCommGroup R] (f : ((J → I → R) × (I → R)) → ℝ) : + (FiniteProbabilityWeights.uniform (Option J × I → R)).mean + (fun z => f (affineSampleAlphabetEquiv z)) = + (residueAffineSource (J := J) (G := I → R)).mean f := + FiniteProbabilityWeights.mean_equiv _ _ affineSampleAlphabetEquiv affineSampleAlphabet_weight f + +def affinePrimeCoordinateObservation {ι J I : Type*} (q : ι → ℕ) + (z : Option J × I → ℤ) : ∀ i, (J → I → ZMod (q i)) × (I → ZMod (q i)) := + fun i => affineSampleAlphabetEquiv (primeCoordinateObservation q z i) + +theorem affinePrimeCoordinateObservation_apply {ι J I : Type*} (q : ι → ℕ) + (z : Option J × I → ℤ) (i : ι) : + affinePrimeCoordinateObservation q z i = + (fun j k => (z (some j, k) : ZMod (q i)), fun k => (z (none, k) : ZMod (q i))) := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineSiteCoverTilt.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSiteCoverTilt.lean new file mode 100644 index 0000000000000000000000000000000000000000..3990a3548c13b4c17ac76d28fb182ca5996183ed --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSiteCoverTilt.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalSingleSiteCommonCover + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial MeasureTheory +open scoped BigOperators Classical + +theorem exists_affine_site_cover_tilted_comparison (m r : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (difference : Fin r → K → ℤ) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (SiteTorus (Finset (Fin r)) U)] [BorelSpace (SiteTorus (Finset (Fin r)) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : Bool → F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ b a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency b a j d t : ℝ)| ≤ C) + (c : Bool → F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : ∀ b, (∑ a, ‖c b a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (q : ℕ) (_hq : 0 < q) (_hqP : (q : ℝ) ≤ Real.exp P) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (D : CoefficientTorus (K := K) U → ℝ) (_hD : Integrable D μ) + (_hDmass : (∫ x, D x ∂μ) = 1) (_hD0 : ∀ x, 0 ≤ D x) + (f : SiteTorus (Finset (Fin r)) U → ℂ) (_hf : Measurable f) + (_hfbound : ∀ x, ‖f x‖ ≤ 1) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ b x, + ‖(D x : ℂ) * (if b then f (coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k)) x) else 1) - coefficientTorusFourierSum U (frequency b) (c b) x‖ ≤ η) + (_hsmall : 2 * η + ε ≤ 1 / 2), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ∃ hDpos : 0 < selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ)))), + |selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ)))) - 1| ≤ 2 * η + ε ∧ + (1 / 2 ≤ selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ))))) ∧ + (selectedResidueDensityMass stride G V + (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ)))) ≤ 3 / 2) ∧ + ‖(∑' z, ((selectedResidueDensityPMF stride G V hV hZ + (fun z => D (affineCoefficientCoverSample U p hm q (fun k j => (z (k, j) : ℝ)))) + (fun _z => _hD0 _) hDpos z).toReal : ℂ) * + f (affineCoveredSiteSample U root difference q p hm (fun k j => (z (k, j) : ℝ)))) - + (∫ x, (D x : ℂ) * f (coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k)) x) ∂μ)‖ ≤ 4 * (2 * η + ε) := by + obtain ⟨A, hA, hcomparison⟩ := exists_affine_coefficient_cover_tilted_comparison m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ F _ P hP hn hd U root difference _ _ _ _ μ _ _ + C hC hCP frequency hbound c B hB hBP hcoefficients p hp hm q hq hqP + stride hs R S ρ ε hS hSP hρ hε hρP hεP hstride H hsize hrank hR G hG V hV hwidth + D hD hDmass hD0 f hf hfbound η hη happrox hsmall + let g : CoefficientTorus (K := K) U → ℂ := fun x => + f (coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k)) x) + have hg : AEStronglyMeasurable g μ := + (hf.comp (coefficientSiteTorusMap_continuous U _).measurable).aestronglyMeasurable + obtain ⟨hZ, hDpos, hmass, hlower, hupper, he⟩ := + hcomparison hP hn hd U μ hC hCP frequency hbound c hB hBP hcoefficients + p hp hm q hq hqP stride hs hS hSP hρ hε hρP hεP hstride H hsize hrank hR + G hG V hV hwidth D hD hDmass hD0 g hg (fun _ => hfbound _) hη happrox hsmall + refine ⟨hZ, hDpos, hmass, hlower, hupper, ?_⟩ + simpa only [g, coefficientSiteTorusMap_coverSample U root difference q p hp hm] using he + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineSliceC2Difference.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSliceC2Difference.lean new file mode 100644 index 0000000000000000000000000000000000000000..e257157cf5d6fa0b07fced9d832dbf36d9ebf788 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSliceC2Difference.lean @@ -0,0 +1,132 @@ +import Mathlib.Analysis.Calculus.ContDiff.Operations +import Mathlib.Analysis.Calculus.FDeriv.CompCLM +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +variable {E X Y : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup X] [NormedSpace ℝ X] [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +noncomputable def operatorPrecompose (J : E →L[ℝ] X) : + (X →L[ℝ] Y) →L[ℝ] (E →L[ℝ] Y) := + (ContinuousLinearMap.compL ℝ E X Y).flip J + +theorem operatorPrecompose_apply (J : E →L[ℝ] X) (A : X →L[ℝ] Y) : + operatorPrecompose J A = A.comp J := rfl + +theorem operatorPrecompose_norm_le (J : E →L[ℝ] X) : + ‖operatorPrecompose (Y := Y) J‖ ≤ ‖J‖ := by + apply ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg J) + intro A + exact (A.opNorm_comp_le J).trans_eq (mul_comm _ _) + +theorem affineSlice_fderiv (F : X → Y) (c : X) (J : E →L[ℝ] X) (x : E) + (hF : DifferentiableAt ℝ F (c + J x)) : + fderiv ℝ (fun y => F (c + J y)) x = (fderiv ℝ F (c + J x)).comp J := by + exact (hF.hasFDerivAt.comp x (J.hasFDerivAt.const_add c)).fderiv + +theorem affineSlice_fderiv_norm_le (F : X → Y) (c : X) (J : E →L[ℝ] X) (x : E) + (hF : DifferentiableAt ℝ F (c + J x)) (hJ : ‖J‖ ≤ 1) {H : ℝ} + (hH : ‖fderiv ℝ F (c + J x)‖ ≤ H) : + ‖fderiv ℝ (fun y => F (c + J y)) x‖ ≤ H := by + rw [affineSlice_fderiv F c J x hF] + calc + _ ≤ ‖fderiv ℝ F (c + J x)‖ * ‖J‖ := ContinuousLinearMap.opNorm_comp_le _ _ + _ ≤ H * 1 := mul_le_mul hH hJ (norm_nonneg J) ((norm_nonneg _).trans hH) + _ = H := mul_one H + +theorem affineSlice_second_fderiv_norm_le (F : X → Y) (hF : ContDiff ℝ 2 F) + (c : X) (J : E →L[ℝ] X) (x : E) (hJ : ‖J‖ ≤ 1) {H : ℝ} + (hH : ‖fderiv ℝ (fderiv ℝ F) (c + J x)‖ ≤ H) : + ‖fderiv ℝ (fderiv ℝ (fun y => F (c + J y))) x‖ ≤ H := by + let L : (X →L[ℝ] Y) →L[ℝ] (E →L[ℝ] Y) := operatorPrecompose J + let g : E → (X →L[ℝ] Y) := fun y => fderiv ℝ F (c + J y) + have hD : ContDiff ℝ 1 (fderiv ℝ F) := hF.fderiv_right (by norm_num) + have hg := ((hD.differentiable one_ne_zero (c + J x)).hasFDerivAt.comp x + (J.hasFDerivAt.const_add c)) + have hg' : HasFDerivAt g ((fderiv ℝ (fderiv ℝ F) (c + J x)).comp J) x := hg + have he : fderiv ℝ (fun y => F (c + J y)) = L ∘ g := by + funext y + exact affineSlice_fderiv F c J y (hF.differentiable (by norm_num) _) + rw [he, fderiv_comp x L.differentiableAt hg'.differentiableAt, L.fderiv, hg'.fderiv] + have hL : ‖L‖ ≤ 1 := (operatorPrecompose_norm_le J).trans hJ + have hinner : ‖(fderiv ℝ (fderiv ℝ F) (c + J x)).comp J‖ ≤ H := by + calc + _ ≤ ‖fderiv ℝ (fderiv ℝ F) (c + J x)‖ * ‖J‖ := ContinuousLinearMap.opNorm_comp_le _ _ + _ ≤ H * 1 := mul_le_mul hH hJ (norm_nonneg J) + ((norm_nonneg (fderiv ℝ (fderiv ℝ F) (c + J x))).trans hH) + _ = H := mul_one H + calc + _ ≤ ‖L‖ * ‖(fderiv ℝ (fderiv ℝ F) (c + J x)).comp J‖ := ContinuousLinearMap.opNorm_comp_le _ _ + _ ≤ 1 * H := mul_le_mul hL hinner + (norm_nonneg ((fderiv ℝ (fderiv ℝ F) (c + J x)).comp J)) zero_le_one + _ = H := one_mul H + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E X Y : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup X] [NormedSpace ℝ X] [NormedAddCommGroup Y] [NormedSpace ℝ Y] + +theorem second_fderiv_sub (F G : X → Y) (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (x : X) : + fderiv ℝ (fderiv ℝ (fun y => F y - G y)) x = + fderiv ℝ (fderiv ℝ F) x - fderiv ℝ (fderiv ℝ G) x := by + have he : fderiv ℝ (fun y => F y - G y) = fun y => fderiv ℝ F y - fderiv ℝ G y := by + funext y + exact fderiv_sub (hF.differentiable (by norm_num) y) (hG.differentiable (by norm_num) y) + rw [he] + exact fderiv_sub ((hF.fderiv_right (by norm_num : 1 + 1 ≤ (2 : WithTop ℕ∞))).differentiable one_ne_zero x) + ((hG.fderiv_right (by norm_num : 1 + 1 ≤ (2 : WithTop ℕ∞))).differentiable one_ne_zero x) + +theorem affineSlice_first_difference_bound (F G : X → Y) + (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (b : X) + (J : E →L[ℝ] X) (hJ : ‖J‖ ≤ 1) (x : E) {ε : ℝ} + (herr : ‖fderiv ℝ F (b + J x) - fderiv ℝ G (b + J x)‖ ≤ ε) : + ‖fderiv ℝ (fun y => F (b + J y)) x - fderiv ℝ (fun y => G (b + J y)) x‖ ≤ ε := by + rw [affineSlice_fderiv F b J x (hF.differentiable (by norm_num) _), + affineSlice_fderiv G b J x (hG.differentiable (by norm_num) _), ← ContinuousLinearMap.sub_comp] + exact ((ContinuousLinearMap.opNorm_comp_le _ _).trans + (mul_le_of_le_one_right (norm_nonneg _) hJ)).trans herr + +theorem affineSlice_second_difference_bound (F G : X → Y) + (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (b : X) + (J : E →L[ℝ] X) (hJ : ‖J‖ ≤ 1) (x : E) {ε : ℝ} + (herr : ‖fderiv ℝ (fderiv ℝ F) (b + J x) - fderiv ℝ (fderiv ℝ G) (b + J x)‖ ≤ ε) : + ‖fderiv ℝ (fderiv ℝ (fun y => F (b + J y))) x - + fderiv ℝ (fderiv ℝ (fun y => G (b + J y))) x‖ ≤ ε := by + have hs : ‖fderiv ℝ (fderiv ℝ (fun y => F y - G y)) (b + J x)‖ ≤ ε := by + rw [second_fderiv_sub F G hF hG] + exact herr + have ht := affineSlice_second_fderiv_norm_le (fun y => F y - G y) (hF.sub hG) b J x hJ hs + have hFs : ContDiff ℝ 2 (fun y => F (b + J y)) := hF.comp (contDiff_const.add J.contDiff) + have hGs : ContDiff ℝ 2 (fun y => G (b + J y)) := hG.comp (contDiff_const.add J.contDiff) + rw [second_fderiv_sub (fun y => F (b + J y)) (fun y => G (b + J y)) hFs hGs] at ht + exact ht + +theorem affineSlice_c2_difference_bound (F G : X → Y) + (hF : ContDiff ℝ 2 F) (hG : ContDiff ℝ 2 G) (b : X) + (J : E →L[ℝ] X) (hJ : ‖J‖ ≤ 1) (x : E) {ε : ℝ} + (herr : ‖F (b + J x) - G (b + J x)‖ ≤ ε ∧ + ‖fderiv ℝ F (b + J x) - fderiv ℝ G (b + J x)‖ ≤ ε ∧ + ‖fderiv ℝ (fderiv ℝ F) (b + J x) - fderiv ℝ (fderiv ℝ G) (b + J x)‖ ≤ ε) : + ‖F (b + J x) - G (b + J x)‖ ≤ ε ∧ + ‖fderiv ℝ (fun y => F (b + J y)) x - fderiv ℝ (fun y => G (b + J y)) x‖ ≤ ε ∧ + ‖fderiv ℝ (fderiv ℝ (fun y => F (b + J y))) x - + fderiv ℝ (fderiv ℝ (fun y => G (b + J y))) x‖ ≤ ε := + ⟨herr.1, affineSlice_first_difference_bound F G hF hG b J hJ x herr.2.1, + affineSlice_second_difference_bound F G hF hG b J hJ x herr.2.2⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineSourceAccuracy.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSourceAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..352b508dc7bef3b253ee9a677b16cf95130b5d64 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSourceAccuracy.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.SlicedSourceAccuracy + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators NNReal + +theorem affineSourceAccuracy_budget + {ι κ : Type*} [Fintype ι] [Fintype κ] + {Dout Dgrid Prho Pbox Op E F C : ℝ} + (hDout : 0 ≤ Dout) (hDgrid : 0 ≤ Dgrid) (hPrho : 0 ≤ Prho) + (hPbox : 0 ≤ Pbox) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hout : (Fintype.card κ : ℝ) ≤ Dout) (hgrid : (Fintype.card ι : ℝ) ≤ Dgrid) + (ρ : ℝ≥0) (hρ : (ρ : ℝ)⁻¹ ≤ Real.exp Prho) + (hC0 : 0 ≤ C) (hC : C ≤ Real.exp F) : + let G := Dgrid * max Op 0 + let εgrid := Real.exp (-(Dout * Prho + (E + F) + 1)) + let εlong := Real.exp (-(G + (E + F) + 1)) + let Plong := Pbox + Prho + G + (E + F) + 2 + 0 < εgrid ∧ εgrid ≤ 1 ∧ εgrid⁻¹ = Real.exp (Dout * Prho + (E + F) + 1) ∧ + 0 < εlong ∧ εlong ≤ 1 ∧ εlong⁻¹ ≤ Real.exp Plong ∧ + 0 ≤ Plong ∧ Pbox ≤ Plong ∧ (ρ : ℝ)⁻¹ ≤ Real.exp Plong ∧ + C * ((ρ⁻¹ ^ Fintype.card κ : ℝ≥0) * εgrid + + εlong * ∏ _i : ι, Real.exp Op) ≤ Real.exp (-E) := by + intro G εgrid εlong Plong + have hG : 0 ≤ G := mul_nonneg hDgrid (le_max_right _ _) + obtain ⟨hg0, hg1, hgi, hl0, hl1, hli, herr⟩ := + slicedSourceAccuracy_bounds (mul_nonneg hDout hPrho) hG (add_nonneg hE hF) + have hPlong : G + (E + F) + 1 ≤ Plong := by dsimp [Plong]; linarith + have hb : Pbox ≤ Plong := by dsimp [Plong]; linarith + have hr : Prho ≤ Plong := by dsimp [Plong]; linarith + have hcap : (ρ⁻¹ ^ Fintype.card κ : ℝ≥0) ≤ Real.exp (Dout * Prho) := by + rw [NNReal.coe_pow, NNReal.coe_inv] + calc + _ ≤ (Real.exp Prho) ^ Fintype.card κ := pow_le_pow_left₀ (inv_nonneg.mpr ρ.coe_nonneg) hρ _ + _ = Real.exp (Fintype.card κ * Prho) := (Real.exp_nat_mul _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hout hPrho) + have hprod : (∏ _i : ι, Real.exp Op) ≤ Real.exp G := by + simp only [Finset.prod_const, Finset.card_univ, ← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + exact (mul_le_mul_of_nonneg_left (le_max_left _ _) (Nat.cast_nonneg _)).trans + (mul_le_mul_of_nonneg_right hgrid (le_max_right _ _)) + refine ⟨hg0, hg1, hgi, hl0, hl1, hli.trans_le (Real.exp_le_exp.mpr hPlong), + hPbox.trans hb, hb, hρ.trans (Real.exp_le_exp.mpr hr), ?_⟩ + calc + _ ≤ C * (Real.exp (Dout * Prho) * εgrid + εlong * ∏ _i : ι, Real.exp Op) := by + apply mul_le_mul_of_nonneg_left _ hC0 + exact add_le_add (mul_le_mul_of_nonneg_right hcap hg0.le) le_rfl + _ ≤ C * Real.exp (-(E + F)) := mul_le_mul_of_nonneg_left (herr _ hprod) hC0 + _ ≤ Real.exp F * Real.exp (-(E + F)) := mul_le_mul_of_nonneg_right hC (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineSquareErrorAccuracy.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSquareErrorAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..045892b1d96fa4a6c9059b735372e90ad739091c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineSquareErrorAccuracy.lean @@ -0,0 +1,42 @@ +import OAI.Combinatorics.Progressions.Sampling.SquareSamplingAccuracy + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def affineSquareErrorAccuracy (target capLog : ℝ) : ℝ := + Real.exp (-(target + capLog + 24)) + +theorem affineSquareErrorAccuracy_pos (target capLog : ℝ) : + 0 < affineSquareErrorAccuracy target capLog := Real.exp_pos _ + +theorem affineSquareErrorAccuracy_inv (target capLog : ℝ) : + (affineSquareErrorAccuracy target capLog)⁻¹ = Real.exp (target + capLog + 24) := by + rw [affineSquareErrorAccuracy, ← Real.exp_neg, neg_neg] + +theorem affineSquareErrorAccuracy_bound {target capLog cap e₁ e₂ e₃ : ℝ} + (hcap0 : 0 ≤ cap) (hcap : cap ≤ Real.exp capLog) + (h₁ : e₁ ≤ affineSquareErrorAccuracy target capLog) + (h₂ : e₂ ≤ affineSquareErrorAccuracy target capLog) + (h₃ : e₃ ≤ affineSquareErrorAccuracy target capLog) : + cap * (e₁ + e₂ + e₃) ≤ Real.exp (-(target + 20)) := by + have hb := (affineSquareErrorAccuracy_pos target capLog).le + have he : e₁ + e₂ + e₃ ≤ 3 * affineSquareErrorAccuracy target capLog := by + linarith only [h₁, h₂, h₃] + have h3 : (3 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + calc + _ ≤ cap * (3 * affineSquareErrorAccuracy target capLog) := mul_le_mul_of_nonneg_left he hcap0 + _ ≤ Real.exp capLog * (Real.exp 4 * affineSquareErrorAccuracy target capLog) := by gcongr + _ = _ := by + unfold affineSquareErrorAccuracy + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineTopCoefficient.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineTopCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..714786a717e6136da339ebe5e5353308ebf6c91b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineTopCoefficient.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.Progressions.Geometry.TopSupportSubstitution +import OAI.Combinatorics.Progressions.Polynomial.AffineShiftPolynomial + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators Classical + +theorem affineShiftPullback_translate {I : Type*} {n : ℕ} + (base : I → ℝ) (direction : Fin n → I → ℝ) (P : MvPolynomial I ℝ) : + affineShiftPullback (fun _ => 0) direction (polynomialTranslate base P) = + affineShiftPullback base direction P := by + have he : (affineShiftPullback (fun _ => 0) direction).comp (polynomialTranslate base) = + affineShiftPullback base direction := by + apply algHom_ext + intro i + simp [AlgHom.comp_apply, polynomialTranslate_X, affineShiftPullback, + affineShiftCoordinate, add_comm] + exact AlgHom.congr_fun he P + +theorem affineShift_full_coefficient_base {I : Type*} {n : ℕ} + (base : I → ℝ) (direction : Fin n → I → ℝ) + (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ n) : + (affineShiftPullback base direction P).coeff (fullShiftExponent n) = + (affineShiftPullback (fun _ => 0) direction P).coeff (fullShiftExponent n) := by + have hc (i : I) : affineShiftCoordinate (fun _ => 0) direction i ∈ + weightedSupportLE (1 : Fin n → ℕ) ((1 : I → ℕ) i) := + (mem_weightedSupportLE_one_iff _ 1).mpr (affineShiftCoordinate_degree _ _ _) + have hp := (mem_weightedSupportLE_one_iff P n).mpr hP + have ht := polynomialTranslate_sub_mem_weightedSupportLT base (1 : I → ℕ) + (fun _ => by simp) hp + have hl := weightedSupportLT_aeval (1 : I → ℕ) (1 : Fin n → ℕ) + (affineShiftCoordinate (fun _ => 0) direction) hc ht + have hz := full_coefficient_zero_of_lower_support hl + change (affineShiftPullback (fun _ => 0) direction (polynomialTranslate base P - P)).coeff + (fullShiftExponent n) = 0 at hz + rw [map_sub, coeff_sub, affineShiftPullback_translate] at hz + exact sub_eq_zero.mp hz + +theorem sub_topComponent_mem_lowerSupport {I R : Type*} [CommRing R] {n : ℕ} + (P : MvPolynomial I R) (hP : P.totalDegree ≤ n) : + P - homogeneousComponent n P ∈ weightedSupportLT (1 : I → ℕ) n := by + intro a ha + change Finsupp.weight (1 : I → ℕ) a < n + have hne : (P - homogeneousComponent n P).coeff a ≠ 0 := mem_support_iff.mp ha + simp only [coeff_sub, coeff_homogeneousComponent] at hne + by_cases hd : a.degree = n + · simp only [hd, ite_true, sub_self, ne_eq, not_true_eq_false] at hne + · have haP : P.coeff a ≠ 0 := by + intro hz + simp only [hz, hd, ite_false, sub_self, ne_eq, not_true_eq_false] at hne + have hle : Finsupp.weight (1 : I → ℕ) a ≤ n := + (mem_weightedSupportLE_one_iff P n).mpr hP (mem_support_iff.mpr haP) + have hn : Finsupp.weight (1 : I → ℕ) a ≠ n := by + simpa only [Finsupp.degree_eq_weight_one, Pi.one_def] using hd + omega + +theorem affineShift_full_coefficient_top {I : Type*} {n : ℕ} + (base : I → ℝ) (direction : Fin n → I → ℝ) + (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ n) : + (affineShiftPullback base direction P).coeff (fullShiftExponent n) = + (affineShiftPullback base direction (homogeneousComponent n P)).coeff (fullShiftExponent n) := by + have hc (i : I) : affineShiftCoordinate base direction i ∈ + weightedSupportLE (1 : Fin n → ℕ) ((1 : I → ℕ) i) := + (mem_weightedSupportLE_one_iff _ 1).mpr (affineShiftCoordinate_degree _ _ _) + have hl := weightedSupportLT_aeval (1 : I → ℕ) (1 : Fin n → ℕ) + (affineShiftCoordinate base direction) hc (sub_topComponent_mem_lowerSupport P hP) + have hz := full_coefficient_zero_of_lower_support hl + change (affineShiftPullback base direction (P - homogeneousComponent n P)).coeff + (fullShiftExponent n) = 0 at hz + rw [map_sub, coeff_sub] at hz + exact sub_eq_zero.mp hz + +noncomputable def polynomialTopSymbol {I : Type*} (n : ℕ) (P : MvPolynomial I ℝ) + (direction : Fin n → I → ℝ) : ℝ := + (affineShiftPullback (fun _ => 0) direction (homogeneousComponent n P)).coeff (fullShiftExponent n) + +theorem affineShift_difference_eq_topSymbol {I : Type*} {n : ℕ} + (base : I → ℝ) (direction : Fin n → I → ℝ) + (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ n) (u v : Fin n → ℝ) : + additiveBoxDifference n + (fun t (_ : Unit) => eval (fun i => base i + ∑ j, direction j i * t j) P) u v () = + polynomialTopSymbol n P direction * ∏ i, (u i - v i) := by + rw [affineShift_full_difference base direction P hP, + affineShift_full_coefficient_base base direction P hP, + affineShift_full_coefficient_top (fun _ => 0) direction P hP] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AffineWindowGoodKernelBound.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AffineWindowGoodKernelBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..551520e61edbe0aaafc1b22a1c75c4090d5e4168 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AffineWindowGoodKernelBound.lean @@ -0,0 +1,316 @@ +import OAI.Combinatorics.Progressions.Estimates.CubeTranslation +import OAI.Combinatorics.Progressions.Estimates.ScalarCubeRootTranslation +import OAI.Combinatorics.Progressions.Linear.WindowGoodKernelBound + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def integerStrideHom (m : ℤ) : ℤ →+ ℤ where + toFun x := m * x + map_zero' := mul_zero m + map_add' := mul_add m + +theorem integerStride_reflectsPairSums (m : ℤ) (hm : m ≠ 0) (Q : Set ℤ) : + ReflectsPairSums (integerStrideHom m) Q := by + intro a _ b _ c _ d _ h + apply mul_left_cancel₀ hm + simpa only [integerStrideHom, AddMonoidHom.coe_mk, ZeroHom.coe_mk, mul_add] using h + +noncomputable def integerProgressionSupport (c m : ℤ) (L : ℕ) : Finset ℤ := + translateSupport c ((Finset.Ico (0 : ℤ) (L : ℤ)).image (integerStrideHom m)) + +noncomputable def supportedIntervalProgressionEquiv (q L : ℕ) (c m : ℤ) (hm : m ≠ 0) : + SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ)) ≃ + SupportedCube q (integerProgressionSupport c m L : Set ℤ) := by + let e := supportedCubeEquiv (integerStride_reflectsPairSums m hm (Set.Ico 0 (L : ℤ))) q + let e' : SupportedCube q (integerStrideHom m '' Set.Ico (0 : ℤ) (L : ℤ)) ≃ + SupportedCube q (((Finset.Ico (0 : ℤ) (L : ℤ)).image (integerStrideHom m)) : Set ℤ) := + Equiv.subtypeEquivRight (fun p => by simp only [Finset.coe_image, Finset.coe_Ico]) + exact (e.trans e').trans (supportedCubeTranslateEquiv q _ c) + +theorem supportedIntervalProgressionEquiv_value (q L : ℕ) (c m : ℤ) (hm : m ≠ 0) + (p : SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ))) : + (supportedIntervalProgressionEquiv q L c m hm p).val = + (fun i => m * p.val.1 i, c + m * p.val.2) := rfl + +theorem integerScalarCubeWeights_progression_mean (q L : ℕ) (hL : 0 < L) + (c m : ℤ) (hm : m ≠ 0) (f : ((Fin q → ℤ) × ℤ) → ℝ) : + (integerScalarCubeWeights (Fin q) L hL).mean + (fun x => f (fun i => m * (x (some i) : ℤ), c + m * (x none : ℤ))) = + 𝔼 p : SupportedCube q (integerProgressionSupport c m L : Set ℤ), f p.val := by + calc + _ = 𝔼 p : SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ)), + f (fun i => m * p.val.1 i, c + m * p.val.2) := + integerScalarCubeWeights_supported_mean q L hL + (fun p => f (fun i => m * p.1 i, c + m * p.2)) + _ = _ := Fintype.expect_equiv (supportedIntervalProgressionEquiv q L c m hm) _ _ + (fun _ => rfl) + +end Erdos3 + +end + +section + +namespace Erdos3 + +abbrev TranslatedResidueSupportedCube (q K : ℕ) (c : ℤ) (m : Option (Fin q) → ℕ) + (r : ∀ i, ZMod (m i)) := + {p : SupportedCube q (Set.Ico c (c + K)) // + ∀ i, ((supportedCubeCoordinates p.val i : ℤ) : ZMod (m i)) = r i} + +noncomputable def shiftedScalarCubeResidueEquiv (q K : ℕ) (c : ℤ) + (m : Option (Fin q) → ℕ) (r : ∀ i, ZMod (m i)) : + ↥((integerScalarCubeSet (Fin q) K) ∩ + scalarCubeResidueSet (Fin q) K m (shiftScalarCubeResidues c m r)) ≃ + TranslatedResidueSupportedCube q K c m r := by + let e := shiftedScalarCubeEquiv q K c + refine { + toFun := fun x => ⟨e ⟨x.val, (Finset.mem_inter.mp x.property).1⟩, ?_⟩ + invFun := fun y => ⟨(e.symm y.val).val, ?_⟩ + left_inv := ?_ + right_inv := ?_ } + · change ∀ i, ((supportedCubeCoordinates (shiftedScalarCubeEquiv q K c + ⟨x.val, (Finset.mem_inter.mp x.property).1⟩).val i : ℤ) : ZMod (m i)) = r i + rw [shiftedScalarCubeEquiv_coordinates] + exact (shiftScalarCube_residues_iff c m r _).mpr + ((mem_scalarCubeResidueSet K m (shiftScalarCubeResidues c m r) x.val).mp + (Finset.mem_inter.mp x.property).2) + · refine Finset.mem_inter.mpr ⟨(e.symm y.val).property, ?_⟩ + apply (mem_scalarCubeResidueSet K m (shiftScalarCubeResidues c m r) _).mpr + apply (shiftScalarCube_residues_iff c m r _).mp + rw [← shiftedScalarCubeEquiv_coordinates] + simpa only [e, Equiv.apply_symm_apply] using y.property + · intro x + apply Subtype.ext + change (e.symm (e ⟨x.val, (Finset.mem_inter.mp x.property).1⟩)).val = x.val + rw [e.symm_apply_apply] + · intro y + apply Subtype.ext + change e (e.symm y.val) = y.val + exact e.apply_symm_apply y.val + +theorem shiftedScalarCubeResidueEquiv_coordinates (q K : ℕ) (c : ℤ) + (m : Option (Fin q) → ℕ) (r : ∀ i, ZMod (m i)) + (x : ↥((integerScalarCubeSet (Fin q) K) ∩ + scalarCubeResidueSet (Fin q) K m (shiftScalarCubeResidues c m r))) : + supportedCubeCoordinates (shiftedScalarCubeResidueEquiv q K c m r x).val.val = + shiftScalarCube c (fun i => (x.val i : ℤ)) := by + funext i + cases i <;> rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem mem_integerProgressionSupport_iff (c : ℤ) (m H : ℕ) (hm : 0 < m) (x : ℤ) : + x ∈ integerProgressionSupport c (m : ℤ) H ↔ + c ≤ x ∧ x < c + (m * H : ℕ) ∧ (x : ZMod m) = (c : ZMod m) := by + have hm' : (0 : ℤ) < m := by exact_mod_cast hm + rw [integerProgressionSupport, mem_translateSupport, Finset.mem_image] + constructor + · rintro ⟨y, hy, he⟩ + have hy' := Finset.mem_Ico.mp hy + change (m : ℤ) * y = x - c at he + have hx : x = c + (m : ℤ) * y := by omega + constructor + · nlinarith + constructor + · push_cast + nlinarith + · rw [hx] + simp + · rintro ⟨hlo, hhi, hr⟩ + have hz : ((x - c : ℤ) : ZMod m) = 0 := by simp [hr] + obtain ⟨y, hy⟩ := (ZMod.intCast_zmod_eq_zero_iff_dvd (x - c) m).mp hz + have hy0 : 0 ≤ y := by nlinarith + have hyH : y < H := by push_cast at hhi; nlinarith + exact ⟨y, Finset.mem_Ico.mpr ⟨hy0, hyH⟩, hy.symm⟩ + +def progressionCubeResidues (q m : ℕ) (c : ℤ) : Option (Fin q) → ZMod m + | none => (c : ZMod m) + | some _ => 0 + +noncomputable def progressionResidueSupportedCubeEquiv (q m H : ℕ) (c : ℤ) (hm : 0 < m) : + SupportedCube q (integerProgressionSupport c (m : ℤ) H : Set ℤ) ≃ + TranslatedResidueSupportedCube q (m * H) c (fun _ => m) (progressionCubeResidues q m c) where + toFun p := by + let p' : SupportedCube q (Set.Ico c (c + (m * H : ℕ))) := ⟨p.val, fun ω => by + have h := (mem_integerProgressionSupport_iff c m H hm _).mp (p.property ω) + exact ⟨h.1, h.2.1⟩⟩ + refine ⟨p', ?_⟩ + intro i + cases i with + | none => exact ((mem_integerProgressionSupport_iff c m H hm _).mp p.base_mem).2.2 + | some i => + have h0 := ((mem_integerProgressionSupport_iff c m H hm _).mp p.base_mem).2.2 + have hi := ((mem_integerProgressionSupport_iff c m H hm _).mp (p.axis_mem i)).2.2 + change (p.val.1 i : ZMod m) = 0 + push_cast at hi + rw [h0] at hi + exact add_left_cancel (hi.trans (add_zero _).symm) + invFun p := by + refine ⟨p.val.val, fun ω => ?_⟩ + apply (mem_integerProgressionSupport_iff c m H hm _).mpr + have h := p.val.property ω + refine ⟨h.1, h.2, ?_⟩ + have h0 : (p.val.val.2 : ZMod m) = (c : ZMod m) := p.property none + have hi (i : Fin q) : (p.val.val.1 i : ZMod m) = 0 := p.property (some i) + simp only [Int.cast_add, h0, cubeShift, Int.cast_sum, apply_ite, hi, Int.cast_zero, ite_self, + Finset.sum_const_zero, add_zero] + left_inv p := by apply Subtype.ext; rfl + right_inv p := by apply Subtype.ext; apply Subtype.ext; rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def affineScalarCubeWindowWeights (I : Type*) [Fintype I] [DecidableEq I] + (L K M D : ℕ) (c : ℤ) (hL : 0 < L) (hKL : K ≤ L) (hDK : L ≤ D * K) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ K) : + FiniteProbabilityWeights (IntegerScalarCubeBox I L) := + scalarCubeWindowWeights I L K M D hL hKL hDK m (shiftScalarCubeResidues c m r) hm hmM hsize + +theorem affineScalarCubeWindowWeights_supported_mean (q L K M D : ℕ) (c : ℤ) + (hL : 0 < L) (hKL : K ≤ L) (hDK : L ≤ D * K) + (m : Option (Fin q) → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card (Fin q) + 1) * M ≤ K) (f : (Option (Fin q) → ℤ) → ℝ) : + (affineScalarCubeWindowWeights (Fin q) L K M D c hL hKL hDK m r hm hmM hsize).mean + (fun x => f (shiftScalarCube c (fun i => (x i : ℤ)))) = + 𝔼 p : TranslatedResidueSupportedCube q K c m r, f (supportedCubeCoordinates p.val.val) := by + classical + have hM : 0 < M := (hm none).trans_le (hmM none) + have hK : 0 < K := (Nat.mul_pos (Nat.succ_pos _) hM).trans_le hsize + unfold affineScalarCubeWindowWeights + rw [scalarCubeWindowWeights_small_mean (Fin q) L K M D hL hK hKL hDK, + scalarCubeResidueWeights_mean] + apply Fintype.expect_equiv (shiftedScalarCubeResidueEquiv q K c m r) + intro x + rw [shiftedScalarCubeResidueEquiv_coordinates] + rfl + +theorem affineScalarCubeWindowWeights_weight_le (I : Type*) [Fintype I] [DecidableEq I] + (L K M D : ℕ) (c : ℤ) (hL : 0 < L) (hKL : K ≤ L) (hDK : L ≤ D * K) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ K) (x : IntegerScalarCubeBox I L) : + (affineScalarCubeWindowWeights I L K M D c hL hKL hDK m r hm hmM hsize).weight x ≤ + scalarCubeResidueDensityCap I (M * D) * (integerScalarCubeWeights I L hL).weight x := + scalarCubeWindowWeights_weight_le I L K M D hL hKL hDK m (shiftScalarCubeResidues c m r) hm hmM hsize x + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem affineScalarCubeWindowWeights_progression_mean (q L m H M D : ℕ) (c : ℤ) + (hL : 0 < L) (hm : 0 < m) (hmM : m ≤ M) (hKL : m * H ≤ L) (hDK : L ≤ D * (m * H)) + (hsize : (Fintype.card (Fin q) + 1) * M ≤ m * H) (f : (Option (Fin q) → ℤ) → ℝ) : + (affineScalarCubeWindowWeights (Fin q) L (m * H) M D c hL hKL hDK + (fun _ => m) (progressionCubeResidues q m c) (fun _ => hm) (fun _ => hmM) hsize).mean + (fun x => f (shiftScalarCube c (fun i => (x i : ℤ)))) = + 𝔼 p : SupportedCube q (integerProgressionSupport c (m : ℤ) H : Set ℤ), + f (supportedCubeCoordinates p.val) := by + rw [affineScalarCubeWindowWeights_supported_mean] + exact (Fintype.expect_equiv (progressionResidueSupportedCubeEquiv q m H c hm) _ _ + (fun _ => rfl)).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem scalarKernelCutoff_window_size (I J : Type*) [Fintype I] [Fintype J] + {M D L K : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) + (hlarge : scalarKernelCutoff I J M D η ≤ L) (hDK : L ≤ D * K) : + (Fintype.card I + 1) * M ≤ K := + scalarCubeWindow_size hD ((scalarKernelCutoff_bounds I J hM hD hη).2.2.1.trans hlarge) hDK + +theorem affineKernel_explicit_probability_le (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) (s : I ↪ J) + {M D L : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) (hL : 0 < L) + (hlarge : scalarKernelCutoff I J M D η ≤ L) (K : J → ℕ) + (hKL : ∀ j, K j ≤ L) (hDK : ∀ j, L ≤ D * K j) (c : J → ℤ) + (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i)) + (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M) : + (FiniteProbabilityWeights.pi (fun j => + affineScalarCubeWindowWeights I L (K j) M D (c j) hL (hKL j) (hDK j) + (m j) (r j) (hm j) (hmM j) (scalarKernelCutoff_window_size I J hM hD hη hlarge (hDK j)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ)) + (scalarKernelCutoff I J M D η) x) ≤ η := by + let C := scalarKernelConditioningConstant I J M D + have hC : 0 < C := scalarKernelConditioningConstant_pos I J hM hD + have h := scalarCubeWindow_pi_eventProbability_le I J L M D K hL hKL hDK m + (fun j => shiftScalarCubeResidues (c j) (m j) (r j)) hm hmM + (fun j => scalarKernelCutoff_window_size I J hM hD hη hlarge (hDK j)) + (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ)) + (scalarKernelCutoff I J M D η) x) + apply h.trans + calc + _ ≤ C * scalarKernelAdjustedAccuracy I J M D η := mul_le_mul_of_nonneg_left + (scalarKernel_explicit_probability_le I J hJ s hM hD hη hL hlarge) hC.le + _ = η := by + change C * (η / C) = η + field_simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_affine_window_good_scalar_kernel_bound (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) : + ∃ s : I ↪ J, ∀ (M D : ℕ), 0 < M → ∀ hD : 0 < D, ∀ η : ℝ, 0 < η → ∃ B L₀ : ℕ, + 0 < B ∧ ∃ hsize : D * ((Fintype.card I + 1) * M) ≤ L₀, + ∀ (L : ℕ) (hL : 0 < L) (hlarge : L₀ ≤ L) (K : J → ℕ) + (hKL : ∀ j, K j ≤ L) (hDK : ∀ j, L ≤ D * K j) (c : J → ℤ) + (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i)) + (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M), + (FiniteProbabilityWeights.pi (fun j => + affineScalarCubeWindowWeights I L (K j) M D (c j) hL (hKL j) (hDK j) + (m j) (r j) (hm j) (hmM j) + (scalarCubeWindow_size hD (hsize.trans hlarge) (hDK j)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (B : ℝ)) B x) ≤ η := by + obtain ⟨s, hs⟩ := exists_window_good_scalar_kernel_bound I J hJ + refine ⟨s, fun M D hM hD η hη => ?_⟩ + obtain ⟨B, L₀, hB, hsize, hprob⟩ := hs M D hM hD η hη + refine ⟨B, L₀, hB, hsize, ?_⟩ + intro L hL hlarge K hKL hDK c m r hm hmM + exact hprob L hL hlarge K hKL hDK m (fun j => shiftScalarCubeResidues (c j) (m j) (r j)) hm hmM + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorIntegerRestoration.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorIntegerRestoration.lean new file mode 100644 index 0000000000000000000000000000000000000000..26053a566cb775f929cfd6aaabc6fa772b3da054 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorIntegerRestoration.lean @@ -0,0 +1,167 @@ +import OAI.Combinatorics.Progressions.Polynomial.IntegerPolynomialDenominatorGrid +import OAI.Combinatorics.Progressions.Polynomial.TranslationPhaseQuotient + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +variable {σ τ : Type*} + +theorem weightedHomogeneousComponent_fractional_restoration + (F : MvPolynomial σ ℝ) (w : σ → ℕ) (d : ℕ) : + weightedHomogeneousComponent w d F = + weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F) + + MvPolynomial.map (Int.castRingHom ℝ) + (weightedHomogeneousComponent w d (floorIntegerPolynomial F)) := by + classical + conv_lhs => rw [← floorIntegerPolynomial_add_fractionalCoefficientPolynomial F] + rw [map_add, add_comm] + congr 1 + ext a + simp only [coeff_weightedHomogeneousComponent, coeff_map] + split_ifs <;> simp + +noncomputable def restoredMajorRemainder (F : MvPolynomial σ ℝ) + (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) : MvPolynomial σ ℚ := + R + MvPolynomial.map (Int.castRingHom ℚ) + (weightedHomogeneousComponent w d (floorIntegerPolynomial F)) + +theorem restoredMajorRemainder_coefficientGrid (F : MvPolynomial σ ℝ) + (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) (q : ℕ) + (hR : (fun a => R.coeff a) ∈ denominatorGrid q) : + (fun a => (restoredMajorRemainder F w d R).coeff a) ∈ denominatorGrid q := + add_integerPolynomial_coefficientGrid R + (weightedHomogeneousComponent w d (floorIntegerPolynomial F)) q hR + +theorem integerPolynomial_map_rat_real (I : MvPolynomial σ ℤ) : + MvPolynomial.map (algebraMap ℚ ℝ) (MvPolynomial.map (Int.castRingHom ℚ) I) = + MvPolynomial.map (Int.castRingHom ℝ) I := by + ext a + simp only [coeff_map] + simp + +theorem restoredMajorRemainder_eval (F : MvPolynomial σ ℝ) + (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) (z : σ → ℝ) : + eval₂ (algebraMap ℚ ℝ) z (restoredMajorRemainder F w d R) = + eval₂ (algebraMap ℚ ℝ) z R + + eval z (MvPolynomial.map (Int.castRingHom ℝ) + (weightedHomogeneousComponent w d (floorIntegerPolynomial F))) := by + rw [restoredMajorRemainder, eval₂_add] + congr 1 + rw [← eval_map, integerPolynomial_map_rat_real] + +theorem restoredMajorRemainder_isWeightedHomogeneous (F : MvPolynomial σ ℝ) + (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) + (hR : R.IsWeightedHomogeneous w d) : + (restoredMajorRemainder F w d R).IsWeightedHomogeneous w d := by + apply hR.add + intro a ha + apply weightedHomogeneousComponent_isWeightedHomogeneous + (w := w) d (floorIntegerPolynomial F) + intro hz + apply ha + simp only [coeff_map, hz, map_zero] + +theorem restoredMajorRemainder_degree (F : MvPolynomial σ ℝ) + (w : σ → ℕ) (d : ℕ) (R : MvPolynomial σ ℚ) + (hR : R ∈ weightedSupportLE w d) : + restoredMajorRemainder F w d R ∈ weightedSupportLE w d := by + apply (weightedSupportLE w d).add_mem hR + intro a ha + have hi : (MvPolynomial.map (Int.castRingHom ℚ) + (weightedHomogeneousComponent w d (floorIntegerPolynomial F))).IsWeightedHomogeneous w d := by + intro a ha + apply weightedHomogeneousComponent_isWeightedHomogeneous + (w := w) d (floorIntegerPolynomial F) + intro hz + apply ha + simp only [coeff_map, hz, map_zero] + exact (hi (mem_support_iff.mp ha)).le + +theorem restoredMajorRemainder_totalDegree_le (F : MvPolynomial σ ℝ) + (w : σ → ℕ) (hw : ∀ i, 0 < w i) (d : ℕ) (R : MvPolynomial σ ℚ) + {r : ℕ} (hR : R.totalDegree ≤ r) (hdr : d ≤ r) : + (restoredMajorRemainder F w d R).totalDegree ≤ r := by + have hI : MvPolynomial.map (Int.castRingHom ℚ) + (weightedHomogeneousComponent w d (floorIntegerPolynomial F)) ∈ + weightedSupportLE w d := by + simpa only [restoredMajorRemainder, zero_add] using + restoredMajorRemainder_degree F w d 0 (Submodule.zero_mem _) + have hdeg : (MvPolynomial.map (Int.castRingHom ℚ) + (weightedHomogeneousComponent w d (floorIntegerPolynomial F))).totalDegree ≤ d := by + unfold totalDegree + apply Finset.sup_le + intro a ha + exact (exponentSum_le_positive_weight w hw a).trans (hI ha) + exact (totalDegree_add _ _).trans (max_le hR (hdeg.trans hdr)) + +theorem algebraic_major_integer_restoration_identity + (F : MvPolynomial σ ℝ) (w : σ → ℕ) (d : ℕ) + (S : MvPolynomial τ ℝ) (R : MvPolynomial σ ℚ) + (chart : (σ → ℝ) → (τ → ℝ)) (Ω : Set (σ → ℝ)) + (hidentity : ∀ z ∈ Ω, + eval z (weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F)) = + eval (chart z) S + eval₂ (algebraMap ℚ ℝ) z R) + (z : σ → ℝ) (hz : z ∈ Ω) : + eval z (weightedHomogeneousComponent w d F) = + eval (chart z) S + eval₂ (algebraMap ℚ ℝ) z (restoredMajorRemainder F w d R) := by + rw [weightedHomogeneousComponent_fractional_restoration, map_add, hidentity z hz, + restoredMajorRemainder_eval, add_assoc] + +theorem algebraic_major_restore_integer_coefficients + {U B : Type*} (F : MvPolynomial (U ⊕ B) ℝ) + (w : U ⊕ B → ℕ) (d : ℕ) (K : Submodule ℝ (B → ℝ)) + (A : B → MvPolynomial U ℝ) (H : U → ℝ) + (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ) + (hgrid : (fun a => R.coeff a) ∈ denominatorGrid q) + (hdegree : R ∈ weightedSupportLE w d) + (hidentity : ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) + (weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F)) = + eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R) : + let R' := restoredMajorRemainder F w d R + (fun a => R'.coeff a) ∈ denominatorGrid q ∧ R' ∈ weightedSupportLE w d ∧ + ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) (weightedHomogeneousComponent w d F) = + eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R' := by + refine ⟨restoredMajorRemainder_coefficientGrid F w d R q hgrid, + restoredMajorRemainder_degree F w d R hdegree, ?_⟩ + intro u b hb + rw [weightedHomogeneousComponent_fractional_restoration, map_add, hidentity u b hb, + restoredMajorRemainder_eval, add_assoc] + +theorem algebraic_major_restore_integer_coefficients_totalDegree + {U B : Type*} (F : MvPolynomial (U ⊕ B) ℝ) + (w : U ⊕ B → ℕ) (hw : ∀ i, 0 < w i) (d : ℕ) + (K : Submodule ℝ (B → ℝ)) (A : B → MvPolynomial U ℝ) (H : U → ℝ) + (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ) (q r : ℕ) + (hgrid : (fun a => R.coeff a) ∈ denominatorGrid q) + (hdegree : R.totalDegree ≤ r) (hdr : d ≤ r) + (hidentity : ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) + (weightedHomogeneousComponent w d (fractionalCoefficientPolynomial F)) = + eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R) : + let R' := restoredMajorRemainder F w d R + (fun a => R'.coeff a) ∈ denominatorGrid q ∧ R'.totalDegree ≤ r ∧ + ∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) (weightedHomogeneousComponent w d F) = + eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R' := by + refine ⟨restoredMajorRemainder_coefficientGrid F w d R q hgrid, + restoredMajorRemainder_totalDegree_le F w hw d R hdegree hdr, ?_⟩ + intro u b hb + rw [weightedHomogeneousComponent_fractional_restoration, map_add, hidentity u b hb, + restoredMajorRemainder_eval, add_assoc] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorWeightedAffineTopPullback.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorWeightedAffineTopPullback.lean new file mode 100644 index 0000000000000000000000000000000000000000..692660cf05a1c7b2d2f782654a23aec1219f37aa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AlgebraicMajorWeightedAffineTopPullback.lean @@ -0,0 +1,528 @@ +import OAI.Combinatorics.Progressions.Polynomial.MajorTranslationPolynomialSymbolDegree +import OAI.Combinatorics.Progressions.Polynomial.TranslationPhaseQuotient +import OAI.Combinatorics.Progressions.Polynomial.TranslationTopDegree + +namespace OAI + +section + +namespace Erdos3 +open MvPolynomial + +variable {U B : Type*} + +noncomputable def majorSlowDilationPullback (q : ℕ) (H T : U → ℝ) + (S : MvPolynomial (U ⊕ B) ℝ) : MvPolynomial (U ⊕ B) ℝ := + scaleMvPolynomialAxes + (Sum.elim (fun i => H i / ((q : ℝ) * T i)) (fun _ : B => 1)) S + + theorem majorSlowDilationPullback_eval (q : ℕ) (hq : 0 < q) (H T : U → ℝ) + (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i) + (S : MvPolynomial (U ⊕ B) ℝ) (u : U → ℝ) (z : B → ℝ) : + eval (Sum.elim (fun i => u i / H i) z) (majorSlowDilationPullback q H T S) = + eval (Sum.elim (fun i => (u i / (q : ℝ)) / T i) z) S := by + rw [majorSlowDilationPullback, scaleMvPolynomialAxes_eval] + apply congrArg (fun x : U ⊕ B → ℝ => eval x S) + funext j + cases j with + | inl i => + dsimp only [Sum.elim_inl] + field_simp [(hH i).ne', (hT i).ne', (Nat.cast_pos.mpr hq : (0 : ℝ) < q).ne'] + | inr j => simp only [Sum.elim_inr, one_mul] + + theorem majorSlowDilationPullback_totalDegree_le (q : ℕ) (H T : U → ℝ) + (S : MvPolynomial (U ⊕ B) ℝ) : + (majorSlowDilationPullback q H T S).totalDegree ≤ S.totalDegree := + scaleMvPolynomialAxes_totalDegree_le _ _ + +theorem algebraic_major_dilation_pullback_identity + (K : Submodule ℝ (B → ℝ)) (D : MvPolynomial (U ⊕ B) ℝ) + (A : B → MvPolynomial U ℝ) (S : MvPolynomial (U ⊕ B) ℝ) + (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ) (hq : 0 < q) + (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i) + (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim (fun i => (q : ℝ) * v i) b) D = + eval (Sum.elim (fun i => v i / T i) + (fun j => b j - eval (fun i => (q : ℝ) * v i) (A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R) + (u : U → ℝ) (b : B → ℝ) (hb : b ∈ K) : + eval (Sum.elim u b) D = + eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) + (majorSlowDilationPullback q H T S) + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) (jointRationalPolynomialDilation q R) := by + rw [majorSlowDilationPullback_eval q hq H T hH hT, + jointRationalPolynomialDilation_eval₂] + have hcancel : (fun i => (q : ℝ) * (u i / (q : ℝ))) = u := by + funext i + exact mul_div_cancel₀ (u i) (Nat.cast_ne_zero.mpr hq.ne') + simpa only [hcancel] using hsource (fun i => u i / (q : ℝ)) b hb + + theorem majorSlowDilationPullback_mass_le (q : ℕ) (hq : 0 < q) (H T : U → ℝ) + (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i) + (S : MvPolynomial (U ⊕ B) ℝ) {c : ℝ} (hc : 1 ≤ c) + (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i) {d : ℕ} (hS : S.totalDegree ≤ d) : + realPolynomialMass (majorSlowDilationPullback q H T S) ≤ c^d * realPolynomialMass S := by + apply jointPolynomialDilation_mass_le _ S hc _ hS + intro i + have hqT : 0 < (q : ℝ) * T i := mul_pos (Nat.cast_pos.mpr hq) (hT i) + rw [abs_of_nonneg (div_nonneg (hH i).le hqT.le)] + apply (div_le_iff₀ hqT).mpr + simpa only [mul_assoc] using hHT i + +theorem algebraic_major_dilation_pullback_decomposition + (K : Submodule ℝ (B → ℝ)) (D : MvPolynomial (U ⊕ B) ℝ) + (A : B → MvPolynomial U ℝ) (S : MvPolynomial (U ⊕ B) ℝ) + (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ) (hq : 0 < q) + (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i) + (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim (fun i => (q : ℝ) * v i) b) D = + eval (Sum.elim (fun i => v i / T i) + (fun j => b j - eval (fun i => (q : ℝ) * v i) (A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R) + (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i) + (d l : ℕ) (hS : S.totalDegree ≤ d) (hR : R.totalDegree ≤ d) + (hSmass : realPolynomialMass S ≤ C) + (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) : + ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ), + (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) D = + eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S' + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧ + realPolynomialMass S' ≤ c^d * C ∧ S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧ + (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) := by + refine ⟨majorSlowDilationPullback q H T S, jointRationalPolynomialDilation q R, + algebraic_major_dilation_pullback_identity K D A S R q hq H T hH hT hsource, ?_, + (majorSlowDilationPullback_totalDegree_le q H T S).trans hS, + (jointRationalPolynomialDilation_totalDegree_le q R).trans hR, ?_⟩ + · exact (majorSlowDilationPullback_mass_le q hq H T hH hT S hc hHT hS).trans + (mul_le_mul_of_nonneg_left hSmass (pow_nonneg (le_trans zero_le_one hc) d)) + · exact jointRationalPolynomialDilation_denominatorGrid R q l d hq hR hRgrid + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial + +variable {U B : Type*} + +theorem majorSlowDilationPullback_mem_weightedSupportLE + (q : ℕ) (H T : U → ℝ) (S : MvPolynomial (U ⊕ B) ℝ) + (w : U ⊕ B → ℕ) (d : ℕ) (hS : S ∈ weightedSupportLE w d) : + majorSlowDilationPullback q H T S ∈ weightedSupportLE w d := + scaleMvPolynomialAxes_mem_weightedSupportLE _ w d hS + +theorem algebraic_major_weighted_dilation_pullback_decomposition + (w : B → ℕ) (hw : ∀ i, 0 < w i) + (K : Submodule ℝ (B → ℝ)) (D : MvPolynomial (U ⊕ B) ℝ) + (A : B → MvPolynomial U ℝ) (S : MvPolynomial (U ⊕ B) ℝ) + (R : MvPolynomial (U ⊕ B) ℚ) (q : ℕ) (hq : 0 < q) + (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i) + (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim (fun i => (q : ℝ) * v i) b) D = + eval (Sum.elim (fun i => v i / T i) + (fun j => b j - eval (fun i => (q : ℝ) * v i) (A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R) + (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i) + (d l : ℕ) + (hS : S ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (hR : R ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (hSmass : realPolynomialMass S ≤ C) + (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) : + ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ), + S' = majorSlowDilationPullback q H T S ∧ + R' = jointRationalPolynomialDilation q R ∧ + (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) D = + eval (Sum.elim (fun i => u i / H i) (fun j => b j - eval u (A j))) S' + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧ + realPolynomialMass S' ≤ c^d * C ∧ + S' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧ + R' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧ + S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧ + (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) := by + have hpos : ∀ i : U ⊕ B, 0 < Sum.elim (fun _ : U => 1) w i := + Sum.rec (fun _ => Nat.zero_lt_one) hw + have hSdeg := weightedSupportLE_totalDegree_le_of_pos hpos hS + have hRdeg := weightedSupportLE_totalDegree_le_of_pos hpos hR + have hS' := majorSlowDilationPullback_mem_weightedSupportLE q H T S _ d hS + have hR' := jointRationalPolynomialDilation_mem_weightedSupportLE q R _ d hR + refine ⟨majorSlowDilationPullback q H T S, jointRationalPolynomialDilation q R, + rfl, rfl, + algebraic_major_dilation_pullback_identity K D A S R q hq H T hH hT hsource, + ?_, hS', hR', weightedSupportLE_totalDegree_le_of_pos hpos hS', + weightedSupportLE_totalDegree_le_of_pos hpos hR', ?_⟩ + · exact (majorSlowDilationPullback_mass_le q hq H T hH hT S hc hHT hSdeg).trans + (mul_le_mul_of_nonneg_left hSmass (pow_nonneg (le_trans zero_le_one hc) d)) + · exact jointRationalPolynomialDilation_denominatorGrid R q l d hq hRdeg hRgrid + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators TensorProduct + +variable {U R : Type*} [CommRing R] + +theorem homogeneousComponent_polynomialTranslate (h : ℕ) (r : U → R) + (P : MvPolynomial U R) (hP : P.totalDegree ≤ h) : + homogeneousComponent h (polynomialTranslate r P) = homogeneousComponent h P := by + have hp : VectorPolynomial.DegreeLE (1 : U → ℕ) h (P ⊗ₜ[R] (1 : R)) := by + intro α hα + have hz : P.coeff α = 0 := coeff_eq_zero_of_totalDegree_lt (hP.trans_lt (by + simpa only [Finsupp.weight_apply, Finsupp.sum, Pi.one_apply, + smul_eq_mul, mul_one] using hα)) + simp only [VectorPolynomial.coefficients_tmul, hz, zero_smul] + have ht := VectorPolynomial.homogeneousPart_translate r (P ⊗ₜ[R] (1 : R)) hp + ext α + have hc := congrArg (fun p => VectorPolynomial.coefficients p α) ht + simpa only [VectorPolynomial.translate_tmul, VectorPolynomial.homogeneousPart_tmul, + VectorPolynomial.coefficients_tmul, smul_eq_mul, mul_one] using hc + +theorem polynomial_dilation_monomial (a c : R) (α : U →₀ ℕ) : + aeval (fun i => C a * X i) (monomial α c) = monomial α (a ^ α.degree * c) := by + classical + rw [aeval_monomial] + simp only [algebraMap_eq, Finsupp.prod, mul_pow, Finset.prod_mul_distrib, + ← map_pow, ← map_prod, Finset.prod_pow_eq_pow_sum, prod_X_pow_eq_monomial] + rw [monomial_eq, monomial_eq] + simp only [map_one, one_mul, map_mul] + have hd : (∑ i ∈ α.support, α i) = α.degree := rfl + rw [hd] + ring + +theorem coeff_polynomial_dilation (a : R) (P : MvPolynomial U R) (α : U →₀ ℕ) : + (aeval (fun i => C a * X i) P).coeff α = a ^ α.degree * P.coeff α := by + classical + conv_lhs => rw [P.as_sum] + simp only [map_sum, polynomial_dilation_monomial, coeff_sum, coeff_monomial] + by_cases hα : α ∈ P.support + · rw [Finset.sum_eq_single α] + · simp + · intro β hβ hβα + simp [hβα] + · exact fun h => (h hα).elim + · rw [Finset.sum_eq_zero] + · have hz : P.coeff α = 0 := not_ne_iff.mp (fun h => hα (mem_support_iff.mpr h)) + simp only [hz, mul_zero] + · intro β hβ + have hβα : β ≠ α := by rintro rfl; exact hα hβ + simp [hβα] + +theorem homogeneousComponent_polynomial_dilation (h : ℕ) (a : R) + (P : MvPolynomial U R) : + homogeneousComponent h (aeval (fun i => C a * X i) P) = + C (a ^ h) * homogeneousComponent h P := by + classical + ext α + rw [coeff_homogeneousComponent, coeff_polynomial_dilation, coeff_C_mul, + coeff_homogeneousComponent] + by_cases hα : α.degree = h + · simp only [hα, ite_true] + · simp only [hα, ite_false, mul_zero] + +theorem residueAffinePolynomial_eq_dilation_translate (q : ℕ) (r : U → ℤ) + (P : MvPolynomial U ℝ) : + residueAffinePolynomial q r P = + aeval (fun i => C (q : ℝ) * X i) (polynomialTranslate (fun i => (r i : ℝ)) P) := by + induction P using MvPolynomial.induction_on with + | C c => simp [residueAffinePolynomial] + | add P Q hP hQ => + simpa only [residueAffinePolynomial, map_add] using congrArg₂ (· + ·) hP hQ + | mul_X P i hP => + simp only [residueAffinePolynomial, map_mul, eval₂Hom_X', polynomialTranslate_X, + map_add, aeval_X, aeval_C, algebraMap_eq] at * + rw [hP, add_comm (C (r i : ℝ))] + +theorem residueAffinePolynomial_homogeneousComponent (q h : ℕ) (r : U → ℤ) + (P : MvPolynomial U ℝ) (hP : P.totalDegree ≤ h) : + homogeneousComponent h (residueAffinePolynomial q r P) = + C ((q : ℝ) ^ h) * homogeneousComponent h P := by + rw [residueAffinePolynomial_eq_dilation_translate, + homogeneousComponent_polynomial_dilation, homogeneousComponent_polynomialTranslate h _ P hP] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial + +variable {U : Type*} + +theorem residueAffinePolynomial_homogeneousComponent_eval + (q h : ℕ) (r : U → ℤ) (P : MvPolynomial U ℝ) + (hP : P.totalDegree ≤ h) (v : U → ℝ) : + eval v (homogeneousComponent h (residueAffinePolynomial q r P)) = + eval (fun i => (q : ℝ) * v i) (homogeneousComponent h P) := by + have hdil : C ((q : ℝ) ^ h) * homogeneousComponent h P = + aeval (fun i => C (q : ℝ) * X i) (homogeneousComponent h P) := by + classical + ext α + rw [coeff_C_mul, coeff_polynomial_dilation, coeff_homogeneousComponent] + by_cases hα : α.degree = h + · simp only [hα, ite_true] + · simp only [hα, ite_false, mul_zero] + rw [residueAffinePolynomial_homogeneousComponent q h r P hP, hdil] + change (aeval v) (aeval (fun i => C (q : ℝ) * X i) + (homogeneousComponent h P)) = _ + rw [comp_aeval_apply] + simp only [map_mul, aeval_C, aeval_X, Algebra.algebraMap_self, RingHom.id_apply, + aeval_eq_eval] + +theorem residueAffinePolynomial_weightedHomogeneousComponent_eval + (q h : ℕ) (r : U → ℤ) (P : MvPolynomial U ℝ) + (hP : P.totalDegree ≤ h) (v : U → ℝ) : + eval v (weightedHomogeneousComponent (fun _ : U => 1) h + (residueAffinePolynomial q r P)) = + eval (fun i => (q : ℝ) * v i) + (weightedHomogeneousComponent (fun _ : U => 1) h P) := + residueAffinePolynomial_homogeneousComponent_eval q h r P hP v + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial + +variable {U B : Type*} + +noncomputable def jointResidueAffinePolynomial (q : ℕ) (r : U → ℤ) + (D : MvPolynomial (U ⊕ B) ℝ) : MvPolynomial (U ⊕ B) ℝ := + aeval (Sum.elim (fun i => C (r i : ℝ) + C (q : ℝ) * X (Sum.inl i)) + (fun j => X (Sum.inr j))) D + +theorem jointResidueAffinePolynomial_eval (q : ℕ) (r : U → ℤ) + (D : MvPolynomial (U ⊕ B) ℝ) (u : U → ℝ) (b : B → ℝ) : + eval (Sum.elim u b) (jointResidueAffinePolynomial q r D) = + eval (Sum.elim (fun i => (r i : ℝ) + (q : ℝ) * u i) b) D := by + induction D using MvPolynomial.induction_on with + | C c => simp [jointResidueAffinePolynomial] + | add D E hD hE => simpa only [jointResidueAffinePolynomial, map_add] using congrArg₂ (· + ·) hD hE + | mul_X D i hD => + cases i <;> simp [jointResidueAffinePolynomial, map_mul] at hD ⊢ <;> rw [hD] <;> simp + +private theorem jointResidueAffine_variables_degree (w : B → ℕ) (q : ℕ) (r : U → ℤ) + (i : U ⊕ B) : + Sum.elim (fun j => C (r j : ℝ) + C (q : ℝ) * X (Sum.inl j)) + (fun j => X (Sum.inr j)) i ∈ + weightedSupportLE (Sum.elim (fun _ : U => 1) w) (Sum.elim (fun _ : U => 1) w i) := by + cases i with + | inl i => + apply (weightedSupportLE _ _).add_mem (weightedSupportLE_C _ _ _) + simpa only [zero_add] using weightedSupportLE_mul + (weightedSupportLE_C (Sum.elim (fun _ : U => 1) w) 0 (q : ℝ)) + (weightedSupportLE_X (Sum.elim (fun _ : U => 1) w) (Sum.inl i)) + | inr j => exact weightedSupportLE_X (Sum.elim (fun _ : U => 1) w) (Sum.inr j) + +theorem jointResidueAffinePolynomial_degree (w : B → ℕ) (q : ℕ) (r : U → ℤ) + {d : ℕ} {D : MvPolynomial (U ⊕ B) ℝ} + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) : + jointResidueAffinePolynomial q r D ∈ + weightedSupportLE (Sum.elim (fun _ : U => 1) w) d := + weightedSupportLE_aeval _ _ _ (jointResidueAffine_variables_degree w q r) hD + +theorem jointResidueAffinePolynomial_sub_axes_lower (w : B → ℕ) (q : ℕ) (r : U → ℤ) + {d : ℕ} {D : MvPolynomial (U ⊕ B) ℝ} + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) : + jointResidueAffinePolynomial q r D - + scaleMvPolynomialAxes (Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1)) D ∈ + weightedSupportLT (Sum.elim (fun _ : U => 1) w) d := by + let v := Sum.elim (fun _ : U => 1) w + let F : MvPolynomial (U ⊕ B) ℝ →ₐ[ℝ] MvPolynomial (U ⊕ B) ℝ := aeval (R := ℝ) (Sum.elim + (fun i => C (r i : ℝ) + C (q : ℝ) * X (Sum.inl i)) (fun j => X (Sum.inr j))) + let T := Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1) + let G := aeval (R := ℝ) (fun i : U ⊕ B => C (T i) * X i) + have hF : ∀ i, F (X i) ∈ weightedSupportLE v (v i) := by + intro i + simpa only [F, aeval_X] using jointResidueAffine_variables_degree w q r i + have hG : ∀ i, G (X i) ∈ weightedSupportLE v (v i) := by + intro i + simpa only [G, aeval_X, zero_add] using + weightedSupportLE_mul (weightedSupportLE_C v 0 (T i)) (weightedSupportLE_X v i) + have hdiff : ∀ i, F (X i) - G (X i) ∈ weightedSupportLT v (v i) := by + intro i + cases i with + | inl i => + simp only [F, G, T, aeval_X, Sum.elim_inl, add_sub_cancel_right] + exact weightedSupportLE_lt_succ (weightedSupportLE_C v 0 (r i : ℝ)) + | inr j => + simp only [F, G, T, aeval_X, Sum.elim_inr, map_one, one_mul, sub_self] + exact Submodule.zero_mem _ + rw [scaleMvPolynomialAxes_eq_aeval] + exact weightedComparison_difference v v F G hF hG hdiff hD + +theorem jointResidueAffinePolynomial_weightedHomogeneousComponent (w : B → ℕ) + (q d : ℕ) (r : U → ℤ) (D : MvPolynomial (U ⊕ B) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) : + weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d + (jointResidueAffinePolynomial q r D) = + scaleMvPolynomialAxes (Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1)) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d D) := by + have hlower := jointResidueAffinePolynomial_sub_axes_lower w q r hD + have hzero : weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d + (jointResidueAffinePolynomial q r D - + scaleMvPolynomialAxes (Sum.elim (fun _ : U => (q : ℝ)) (fun _ : B => 1)) D) = 0 := + weightedHomogeneousComponent_eq_zero' d _ (fun α hα => (hlower hα).ne) + rw [map_sub, sub_eq_zero] at hzero + rw [hzero, scaleMvPolynomialAxes_weightedHomogeneousComponent] + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial + +variable {U B : Type*} + + theorem jointResidueAffinePolynomial_weightedHomogeneousComponent_eval + (w : B → ℕ) (q d : ℕ) (r : U → ℤ) (D : MvPolynomial (U ⊕ B) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (v : U → ℝ) (b : B → ℝ) : + eval (Sum.elim v b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d + (jointResidueAffinePolynomial q r D)) = + eval (Sum.elim (fun i => (q : ℝ) * v i) b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) d D) := by + rw [jointResidueAffinePolynomial_weightedHomogeneousComponent w q d r D hD, + scaleMvPolynomialAxes_eval] + apply congrArg (fun x : U ⊕ B → ℝ => eval x _) + funext i + cases i <;> simp only [Sum.elim_inl, Sum.elim_inr, one_mul] + +theorem algebraic_major_affine_top_dilation_identity + (K : Submodule ℝ (B → ℝ)) (w : B → ℕ) (n : ℕ) + (D : MvPolynomial (U ⊕ B) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) n) + (A : B → MvPolynomial U ℝ) (hA : ∀ j, (A j).totalDegree ≤ w j) + (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ) + (q : ℕ) (r : U → ℤ) (T : U → ℝ) + (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim v b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n + (jointResidueAffinePolynomial q r D)) = + eval (Sum.elim (fun i => v i / T i) + (fun j => b j - eval v + (majorTranslationTopCoordinates w (fun j => residueAffinePolynomial q r (A j)) j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R) + (v : U → ℝ) (b : B → ℝ) (hb : b ∈ K) : + eval (Sum.elim (fun i => (q : ℝ) * v i) b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n D) = + eval (Sum.elim (fun i => v i / T i) + (fun j => b j - eval (fun i => (q : ℝ) * v i) (majorTranslationTopCoordinates w A j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R := by + have h := hsource v b hb + rw [jointResidueAffinePolynomial_weightedHomogeneousComponent_eval w q n r D hD] at h + simp only [majorTranslationTopCoordinates, + residueAffinePolynomial_weightedHomogeneousComponent_eval q _ r _ (hA _)] at h + exact h + +theorem algebraic_major_affine_top_pullback_decomposition + (K : Submodule ℝ (B → ℝ)) (w : B → ℕ) (n : ℕ) + (D : MvPolynomial (U ⊕ B) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) n) + (A : B → MvPolynomial U ℝ) (hA : ∀ j, (A j).totalDegree ≤ w j) + (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ) + (q : ℕ) (hq : 0 < q) (r : U → ℤ) + (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i) + (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim v b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n + (jointResidueAffinePolynomial q r D)) = + eval (Sum.elim (fun i => v i / T i) + (fun j => b j - eval v + (majorTranslationTopCoordinates w (fun j => residueAffinePolynomial q r (A j)) j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R) + (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i) + (d l : ℕ) (hS : S.totalDegree ≤ d) (hR : R.totalDegree ≤ d) + (hSmass : realPolynomialMass S ≤ C) + (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) : + ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ), + (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n D) = + eval (Sum.elim (fun i => u i / H i) + (fun j => b j - eval u (majorTranslationTopCoordinates w A j))) S' + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧ + realPolynomialMass S' ≤ c^d * C ∧ S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧ + (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) := + algebraic_major_dilation_pullback_decomposition K _ _ S R q hq H T hH hT + (algebraic_major_affine_top_dilation_identity K w n D hD A hA S R q r T hsource) + c C hc hHT d l hS hR hSmass hRgrid + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial + +variable {U B : Type*} + +theorem algebraic_major_weighted_affine_top_pullback_decomposition + (K : Submodule ℝ (B → ℝ)) (w : B → ℕ) (hw : ∀ i, 0 < w i) (n : ℕ) + (D : MvPolynomial (U ⊕ B) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) n) + (A : B → MvPolynomial U ℝ) (hA : ∀ j, (A j).totalDegree ≤ w j) + (S : MvPolynomial (U ⊕ B) ℝ) (R : MvPolynomial (U ⊕ B) ℚ) + (q : ℕ) (hq : 0 < q) (r : U → ℤ) + (H T : U → ℝ) (hH : ∀ i, 0 < H i) (hT : ∀ i, 0 < T i) + (hsource : ∀ (v : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim v b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n + (jointResidueAffinePolynomial q r D)) = + eval (Sum.elim (fun i => v i / T i) + (fun j => b j - eval v + (majorTranslationTopCoordinates w (fun j => residueAffinePolynomial q r (A j)) j))) S + + eval₂ (algebraMap ℚ ℝ) (Sum.elim v b) R) + (c C : ℝ) (hc : 1 ≤ c) (hHT : ∀ i, H i ≤ c * (q : ℝ) * T i) + (d l : ℕ) + (hS : S ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (hR : R ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (hSmass : realPolynomialMass S ≤ C) + (hRgrid : (fun α => R.coeff α) ∈ denominatorGrid l) : + ∃ (S' : MvPolynomial (U ⊕ B) ℝ) (R' : MvPolynomial (U ⊕ B) ℚ), + S' = majorSlowDilationPullback q H T S ∧ + R' = jointRationalPolynomialDilation q R ∧ + (∀ (u : U → ℝ) (b : B → ℝ), b ∈ K → + eval (Sum.elim u b) + (weightedHomogeneousComponent (Sum.elim (fun _ : U => 1) w) n D) = + eval (Sum.elim (fun i => u i / H i) + (fun j => b j - eval u (majorTranslationTopCoordinates w A j))) S' + + eval₂ (algebraMap ℚ ℝ) (Sum.elim u b) R') ∧ + realPolynomialMass S' ≤ c^d * C ∧ + S' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧ + R' ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d ∧ + S'.totalDegree ≤ d ∧ R'.totalDegree ≤ d ∧ + (fun α => R'.coeff α) ∈ denominatorGrid (q^d*l) := + algebraic_major_weighted_dilation_pullback_decomposition w hw K _ _ S R q hq H T hH hT + (algebraic_major_affine_top_dilation_identity K w n D hD A hA S R q r T hsource) + c C hc hHT d l hS hR hSmass hRgrid + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResidueComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResidueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9cf5dc2a23411630fd37ac43937cd433d735721 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResidueComparison.lean @@ -0,0 +1,436 @@ +import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialInputStepLaw +import OAI.Combinatorics.Progressions.Sampling.AllocatedPeriodicGridQuadrature + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem integerBox_residue_fiberLaw_l1 + {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q] + (hsmall : (∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)) ≤ 1 / 2) : + (∑ r : I → ZMod q, + |((integerBoxUniformWeights lo hi hlen).fiberLaw + (fun x => integerVectorResidue q (fun i => (x i).val))).weight r - + (FiniteProbabilityWeights.uniform (I → ZMod q)).weight r|) ≤ + 2 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := by + let E := 2 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) + let μ := (integerBoxUniformWeights lo hi hlen).fiberLaw + (fun x => integerVectorResidue q (fun i => (x i).val)) + let u := FiniteProbabilityWeights.uniform (I → ZMod q) + have hc : (0 : ℝ) < (q : ℝ) ^ Fintype.card I := pow_pos (by exact_mod_cast NeZero.pos q) _ + have hw (r : I → ZMod q) : |μ.weight r - u.weight r| ≤ E * u.weight r := by + have h := integerBox_residue_fiberLaw_relative_error lo hi hlen q r hsmall + change |(q : ℝ) ^ Fintype.card I * μ.weight r - 1| ≤ E at h + have hu : u.weight r = ((q : ℝ) ^ Fintype.card I)⁻¹ := by + simp only [u, FiniteProbabilityWeights.uniform, Fintype.card_fun, ZMod.card, Nat.cast_pow] + rw [hu] + have heq : μ.weight r - ((q : ℝ) ^ Fintype.card I)⁻¹ = + ((q : ℝ) ^ Fintype.card I * μ.weight r - 1) * ((q : ℝ) ^ Fintype.card I)⁻¹ := by + field_simp + rw [heq, abs_mul, abs_of_pos (inv_pos.mpr hc)] + exact mul_le_mul_of_nonneg_right h (inv_nonneg.mpr hc.le) + calc + _ ≤ ∑ r, E * u.weight r := Finset.sum_le_sum (fun r _ => hw r) + _ = E := by rw [← Finset.mul_sum, u.total, mul_one] + +theorem integerBox_affine_residue_complexMean_error + {I Y : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q] + (origin stride : I → ℤ) (F : (I → ZMod q) → Y) (f : Y → ℂ) + (hf : ∀ y, ‖f y‖ ≤ 1) + (hsmall : (∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)) ≤ 1 / 2) : + ‖(integerBoxUniformWeights lo hi hlen).complexMean + (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q)))) - + (FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean + (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤ + 2 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := by + let μ := (integerBoxUniformWeights lo hi hlen).fiberLaw + (fun x => integerVectorResidue q (fun i => (x i).val)) + let g := fun r : I → ZMod q => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)) + have h := (FiniteProbabilityWeights.norm_complexMean_sub_le_weight_l1 μ + (FiniteProbabilityWeights.uniform (I → ZMod q)) g (fun r => hf _)).trans + (integerBox_residue_fiberLaw_l1 lo hi hlen q hsmall) + dsimp only [μ] at h + rw [FiniteProbabilityWeights.fiberLaw_complexMean] at h + simpa only [g, integerVectorResidue, Int.cast_add, Int.cast_mul] using h + +theorem integerBox_affine_residue_complexMean_error_unconditional + {I Y : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q] + (origin stride : I → ℤ) (F : (I → ZMod q) → Y) (f : Y → ℂ) + (hf : ∀ y, ‖f y‖ ≤ 1) : + ‖(integerBoxUniformWeights lo hi hlen).complexMean + (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q)))) - + (FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean + (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤ + 4 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := by + by_cases hsmall : (∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)) ≤ 1 / 2 + · apply (integerBox_affine_residue_complexMean_error lo hi hlen q origin stride F f hf hsmall).trans + have hn : 0 ≤ ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := + Finset.sum_nonneg (fun i _ => div_nonneg (Nat.cast_nonneg _) + (by exact_mod_cast (sub_pos.mpr (hlen i)).le)) + linarith + · have h1 := (integerBoxUniformWeights lo hi hlen).norm_complexMean_le_mean_norm + (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q)))) + have h2 := (FiniteProbabilityWeights.uniform (I → ZMod q)).norm_complexMean_le_mean_norm + (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i))) + have hb1 := (integerBoxUniformWeights lo hi hlen).mean_mono (fun x => hf + (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q)))) + have hb2 := (FiniteProbabilityWeights.uniform (I → ZMod q)).mean_mono (fun r => hf + (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i))) + rw [FiniteProbabilityWeights.mean_const] at hb1 hb2 + have ht := norm_sub_le + ((integerBoxUniformWeights lo hi hlen).complexMean + (fun x => f (F (fun i => ((origin i + stride i * (x i).val : ℤ) : ZMod q))))) + ((FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean + (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))) + linarith + +theorem originalActiveCube_affine_residue_complexMean_error + {I Y : Type*} [Fintype I] [DecidableEq I] + (L : I → ℕ) (hL : ∀ i, 0 < L i) (q : ℕ) [NeZero q] + (origin stride : I → ℤ) (F : (I → ZMod q) → Y) (f : Y → ℂ) + (hf : ∀ y, ‖f y‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun i => integerScalarCubeWeights Empty (L i) (hL i))).complexMean + (fun x => f (F (fun i => ((origin i + stride i * (x i none : ℤ) : ℤ) : ZMod q)))) - + (FiniteProbabilityWeights.uniform (I → ZMod q)).complexMean + (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤ + 4 * ∑ i, (q : ℝ) / L i := by + have he := FiniteProbabilityWeights.complexMean_pi_transport_fintype + (fun i => integerScalarCubeWeights Empty (L i) (hL i)) + (fun i => intervalUniformWeights 0 (L i : ℤ) (by exact_mod_cast hL i)) + (fun _ x => (x none : ℤ)) (fun _ x => (x : ℤ)) + (fun i g => integerScalarCubeWeights_zero_complexMean Empty (L i) (hL i) g) + (fun z : I → ℤ => f (F (fun i => ((origin i + stride i * z i : ℤ) : ZMod q)))) + rw [he] + simpa only [integerBoxUniformWeights, sub_zero, Int.cast_natCast] using + integerBox_affine_residue_complexMean_error_unconditional (fun _ => 0) + (fun i => (L i : ℤ)) (fun i => by exact_mod_cast hL i) q origin stride F f hf + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +variable {L V : Type*} [Fintype L] [Fintype V] +local instance activeCRTModulusNeZero (p A : L → ℕ) [∀ l, NeZero (p l)] : + NeZero (∏ l, p l ^ A l) := + ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (p l)))⟩ + +theorem originalActiveCube_crt_input_comparison + (length : V → ℕ) (hlength : ∀ v, 0 < length v) + (p A e : L → ℕ) [∀ l, NeZero (p l)] + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k))) + (origin : ∀ l, V → ZMod (p l ^ A l)) + {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ A l) + (f : (V → ZMod q) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) : + let c : V → ℤ := fun v => (crtInput (fun l => p l ^ A l) hq origin v).val + let step : ℤ := (∏ l, p l ^ e l : ℕ) + ‖(FiniteProbabilityWeights.pi (fun v => integerScalarCubeWeights Empty (length v) (hlength v))).complexMean + (fun x => f (fun v => ((c v + step * (x v none : ℤ) : ℤ) : ZMod q))) - + (crtPolynomialInputLaw p A e hq origin).complexMean + (fun x => f (tupleResidueReduction hdiv x))‖ ≤ + 4 * ∑ v, (q : ℝ) / length v := by + intro c step + rw [crtPolynomialInputLaw_divisor_integerOrigin_complexMean p A e hp hinj hq origin hdiv f] + simpa only [c, step, Int.cast_natCast, id_eq] using + originalActiveCube_affine_residue_complexMean_error length hlength q c (fun _ => step) id f hf + +theorem crtPolynomialInputLaw_unrestricted_divisor_complexMean + (p A : L → ℕ) [∀ l, NeZero (p l)] + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k))) + (origin : ∀ l, V → ZMod (p l ^ A l)) + {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ A l) + (f : (V → ZMod q) → ℂ) : + (crtPolynomialInputLaw p A (fun _ => 0) hq origin).complexMean + (fun x => f (tupleResidueReduction hdiv x)) = + (FiniteProbabilityWeights.uniform (V → ZMod q)).complexMean f := by + rw [crtPolynomialInputLaw_divisor_complexMean p A (fun _ => 0) hp hinj hq origin hdiv f] + simp only [pow_zero, Finset.prod_const_one, Nat.cast_one, one_mul] + rw [FiniteProbabilityWeights.uniform_complexMean, FiniteProbabilityWeights.uniform_complexMean] + exact Fintype.expect_equiv + (Equiv.addLeft (tupleResidueReduction hdiv (crtInput (fun l => p l ^ A l) hq origin))) + _ _ (fun _ => rfl) + +theorem originalActiveCube_crt_unrestricted_input_comparison + (length : V → ℕ) (hlength : ∀ v, 0 < length v) + (p A : L → ℕ) [∀ l, NeZero (p l)] + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k))) + (origin : ∀ l, V → ZMod (p l ^ A l)) + {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ A l) + (f : (V → ZMod q) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun v => integerScalarCubeWeights Empty (length v) (hlength v))).complexMean + (fun x => f (fun v => ((x v none : ℤ) : ZMod q))) - + (crtPolynomialInputLaw p A (fun _ => 0) hq origin).complexMean + (fun x => f (tupleResidueReduction hdiv x))‖ ≤ + 4 * ∑ v, (q : ℝ) / length v := by + rw [crtPolynomialInputLaw_unrestricted_divisor_complexMean p A hp hinj hq origin hdiv f] + simpa only [zero_add, one_mul, Int.cast_one, Int.cast_zero, id_eq] using + originalActiveCube_affine_residue_complexMean_error length hlength q (fun _ => 0) + (fun _ => 1) id f hf + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {L A I J : Type*} [Fintype L] [Fintype A] [Fintype J] [DecidableEq J] + +local instance unrestrictedForecastModulusNeZero (p e : L → ℕ) [∀ l, NeZero (p l)] : + NeZero (∏ l, p l ^ e l) := + ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (p l)))⟩ + +theorem rationalPolynomialForecast_unrestrictedCRT_marginal + (p e : L → ℕ) [∀ l, NeZero (p l)] + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hcoprime : Pairwise (fun l k => (p l ^ e l).Coprime (p k ^ e k))) + (origin : ∀ l, A → ZMod (p l ^ e l)) + (poly : J → MvPolynomial (A ⊕ I) ℤ) (inactive : I → ℤ) + {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ e l) + (test : (J → ZMod q) → ℂ) : + (𝔼 b : J → ZMod (∏ l, p l ^ e l), + (rationalOutputDensity (crtPolynomialInputLaw p e (fun _ => 0) hcoprime origin) + (integerLongPolynomialOutput poly inactive (∏ l, p l ^ e l)) + (∏ l, p l ^ e l) b : ℂ) * + test (fun j => ZMod.castHom hdiv (ZMod q) (b j))) = + 𝔼 t : A → ZMod q, test (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim t (fun i => (inactive i : ZMod q))) (poly j)) := by + rw [rationalOutputDensity_divisor_test _ _ hdiv] + simp_rw [integerLongPolynomialOutput_reduce poly inactive hdiv] + exact (crtPolynomialInputLaw_unrestricted_divisor_complexMean p e hp hinj hcoprime origin hdiv + (fun t => test (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim t (fun i => (inactive i : ZMod q))) (poly j)))).trans + (FiniteProbabilityWeights.uniform_complexMean _) + +theorem rationalInactivePolynomialForecast_conditionalUnrestrictedCRT_tsum_marginal + {Ω Z : Type*} [Fintype Ω] + (inactive : FiniteProbabilityWeights Ω) (gridPoint : Ω → Z) + (p e : L → ℕ) [∀ l, NeZero (p l)] + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hcoprime : Pairwise (fun l k => (p l ^ e l).Coprime (p k ^ e k))) + (origin : Ω → ∀ l, A → ZMod (p l ^ e l)) + (poly : J → MvPolynomial (A ⊕ I) ℤ) (inactiveCoord : Ω → I → ℤ) + {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ e l) + {gridVolume : ℝ} (hV : gridVolume ≠ 0) (test : Z → (J → ZMod q) → ℂ) : + (∑' z, 𝔼 b : J → ZMod (∏ l, p l ^ e l), + ((rationalInactiveForecast inactive + (fun i => crtPolynomialInputLaw p e (fun _ => 0) hcoprime (origin i)) gridPoint + (fun i => integerLongPolynomialOutput poly (inactiveCoord i) (∏ l, p l ^ e l)) + (∏ l, p l ^ e l) gridVolume z b / gridVolume : ℝ) : ℂ) * + test z (fun j => ZMod.castHom hdiv (ZMod q) (b j))) = + inactive.complexMean (fun i => 𝔼 t : A → ZMod q, + test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim t (fun a => (inactiveCoord i a : ZMod q))) (poly j))) := by + rw [rationalInactiveForecast_divisor_tsum_test _ _ _ _ hdiv hV] + congr 1 + funext i + simp_rw [integerLongPolynomialOutput_reduce poly (inactiveCoord i) hdiv] + exact (crtPolynomialInputLaw_unrestricted_divisor_complexMean p e hp hinj hcoprime (origin i) hdiv + (fun t => test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim t (fun a => (inactiveCoord i a : ZMod q))) (poly j)))).trans + (FiniteProbabilityWeights.uniform_complexMean _) + +theorem rationalInactivePolynomialForecast_unrestrictedCRT_tsum_marginal + {Ω Z : Type*} [Fintype Ω] + (inactive : FiniteProbabilityWeights Ω) (gridPoint : Ω → Z) + (p e : L → ℕ) [∀ l, NeZero (p l)] + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hcoprime : Pairwise (fun l k => (p l ^ e l).Coprime (p k ^ e k))) + (origin : ∀ l, A → ZMod (p l ^ e l)) + (poly : J → MvPolynomial (A ⊕ I) ℤ) (inactiveCoord : Ω → I → ℤ) + {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ e l) + {gridVolume : ℝ} (hV : gridVolume ≠ 0) (test : Z → (J → ZMod q) → ℂ) : + (∑' z, 𝔼 b : J → ZMod (∏ l, p l ^ e l), + ((rationalInactiveForecast inactive + (fun _ => crtPolynomialInputLaw p e (fun _ => 0) hcoprime origin) gridPoint + (fun i => integerLongPolynomialOutput poly (inactiveCoord i) (∏ l, p l ^ e l)) + (∏ l, p l ^ e l) gridVolume z b / gridVolume : ℝ) : ℂ) * + test z (fun j => ZMod.castHom hdiv (ZMod q) (b j))) = + inactive.complexMean (fun i => 𝔼 t : A → ZMod q, + test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim t (fun a => (inactiveCoord i a : ZMod q))) (poly j))) := + rationalInactivePolynomialForecast_conditionalUnrestrictedCRT_tsum_marginal + inactive gridPoint p e hp hinj hcoprime (fun _ => origin) poly inactiveCoord hdiv hV test + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "degree" => layerSamplerDegree I n +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "hSides" => allocatedPrincipalSides_pos B U basis S +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "activeB" => (fun a : Active => B (Subtype.val a)) +local notation "activeDegree" => (fun a : Active => degree (Subtype.val a)) +local notation "ActiveInput" => PrincipalTupleIndex activeB activeDegree +local notation "activeLength" => principalAxisLength (fun a => ¬short a) sides +local notation "activePos" => (fun j : ActiveInput => hSides (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) +local notation "Original" => PrincipalIntegerTuples B degree Empty sides + +variable (q : ℕ) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := Empty) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +noncomputable def allocatedShortPrincipalResidueLaw := + principalSupportedAxisWeights B degree sides hSides q r hcell short + +noncomputable def allocatedActivePrincipalResidueLaw := + principalSupportedAxisWeights B degree sides hSides q r hcell (fun a => ¬short a) + +theorem allocatedPrincipalResidue_partition (f : Original → ℂ) : + ((principalTupleWeights (α := Empty) B degree sides hSides).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).complexMean f = + (allocatedShortPrincipalResidueLaw B U basis S q r hcell).complexMean (fun u => + (allocatedActivePrincipalResidueLaw B U basis S q r hcell).complexMean + (fun v => f (principalAxisJoin short u v))) := + principalSupportedResidueWeights_partition B degree sides hSides q r hcell short f + +theorem allocatedActivePrincipalResidue_length (j : ActiveInput) : activeLength j = S.value := + allocatedPrincipalSides_long_of_not_short B U basis S j.1.val j.1.property j.2.1 j.2.2 + +theorem allocatedActivePrincipalResidueLaw_eq (hq : 0 < q) (hsize : q ≤ S.value) : + allocatedActivePrincipalResidueLaw B U basis S q r hcell = + principalResidueWeights activeB activeDegree activeLength activePos q hq + (fun j => r ⟨j.1.val, j.2⟩) + (fun j => by simpa only [Fintype.card_empty, zero_add, one_mul, + allocatedActivePrincipalResidue_length B U basis S] using hsize) := by + exact principalSupportedAxisWeights_eq_residueWeights B degree sides hSides q r hcell + (fun a => ¬short a) hq _ + +theorem allocatedPrincipalResidue_partition_mul + (φ : PrincipalAxisTuples (α := Empty) short sides → ℂ) + (ψ : PrincipalAxisTuples (α := Empty) (fun a => ¬short a) sides → ℂ) : + ((principalTupleWeights (α := Empty) B degree sides hSides).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).complexMean + (fun y => φ (principalAxisRestrict short y) * + ψ (principalAxisRestrict (fun a => ¬short a) y)) = + (allocatedShortPrincipalResidueLaw B U basis S q r hcell).complexMean φ * + (allocatedActivePrincipalResidueLaw B U basis S q r hcell).complexMean ψ := + principalSupportedResidueWeights_partition_mul B degree sides hSides q r hcell short φ ψ + +private theorem scalarResidueIntegerMean_congr + (L₁ L₂ q : ℕ) (hL₁ : 0 < L₁) (hL₂ : 0 < L₂) (hq : 0 < q) + (r : Option Empty → ZMod q) (hsize₁ : (Fintype.card Empty + 1) * q ≤ L₁) + (hsize₂ : (Fintype.card Empty + 1) * q ≤ L₂) (he : L₁ = L₂) (f : ℤ → ℂ) : + (scalarCubeResidueWeights Empty L₁ q hL₁ (fun _ => q) r + (fun _ => hq) (fun _ => le_rfl) hsize₁).complexMean (fun z => f (z none : ℤ)) = + (scalarCubeResidueWeights Empty L₂ q hL₂ (fun _ => q) r + (fun _ => hq) (fun _ => le_rfl) hsize₂).complexMean (fun z => f (z none : ℤ)) := by + subst L₂ + rfl + +theorem allocatedActivePrincipalResidueLaw_integer_mean (hq : 0 < q) (hsize : q ≤ S.value) + (f : (ActiveInput → ℤ) → ℂ) : + (allocatedActivePrincipalResidueLaw B U basis S q r hcell).complexMean + (fun y => f (fun j => (y j none : ℤ))) = + (principalResidueWeights activeB activeDegree (fun _ => S.value) (fun _ => S.positive) + q hq (fun j => r ⟨j.1.val, j.2⟩) + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean + (fun y => f (fun j => (y j none : ℤ))) := by + rw [allocatedActivePrincipalResidueLaw_eq B U basis S q r hcell hq hsize] + exact FiniteProbabilityWeights.complexMean_pi_transport_fintype + (fun j => scalarCubeResidueWeights Empty (activeLength j) q (activePos j) + (fun _ => q) (r ⟨j.1.val, j.2⟩) (fun _ => hq) (fun _ => le_rfl) + (by simpa only [Fintype.card_empty, zero_add, one_mul, + allocatedActivePrincipalResidue_length B U basis S] using hsize)) + (fun j => scalarCubeResidueWeights Empty S.value q S.positive + (fun _ => q) (r ⟨j.1.val, j.2⟩) (fun _ => hq) (fun _ => le_rfl) + (by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)) + (fun _ z => (z none : ℤ)) (fun _ z => (z none : ℤ)) + (fun j g => scalarResidueIntegerMean_congr (activeLength j) S.value q (activePos j) + S.positive hq (r ⟨j.1.val, j.2⟩) _ _ + (allocatedActivePrincipalResidue_length B U basis S j) g) f + +theorem allocatedPrincipalResidue_integer_partition (hq : 0 < q) (hsize : q ≤ S.value) + (f : PrincipalAxisTuples (α := Empty) short sides → (ActiveInput → ℤ) → ℂ) : + ((principalTupleWeights (α := Empty) B degree sides hSides).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).complexMean + (fun y => f (principalAxisRestrict short y) + (fun j => ((principalAxisRestrict (fun a => ¬short a) y) j none : ℤ))) = + (allocatedShortPrincipalResidueLaw B U basis S q r hcell).complexMean (fun u => + (principalResidueWeights activeB activeDegree (fun _ => S.value) (fun _ => S.positive) + q hq (fun j => r ⟨j.1.val, j.2⟩) + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean + (fun v => f u (fun j => (v j none : ℤ)))) := by + rw [allocatedPrincipalResidue_partition B U basis S q r hcell] + simp only [principalAxisRestrict_join_left, principalAxisRestrict_join_right] + congr 1 + funext u + exact allocatedActivePrincipalResidueLaw_integer_mean B U basis S q r hcell hq hsize (f u) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "AB" => (fun a : Active => B (Subtype.val a)) +local notation "Ah" => (fun a : Active => layerSamplerDegree I n (Subtype.val a)) +local notation "AI" => PrincipalTupleIndex AB Ah +local notation "L" => principalAxisLength (fun a => ¬short a) (allocatedPrincipalSides B U basis S) +local notation "hL" => (fun j : AI => allocatedPrincipalSides_pos B U basis S (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +theorem allocatedActive_affine_residue_comparison + {Y : Type*} (q : ℕ) [NeZero q] (origin stride : AI → ℤ) + (F : (AI → ZMod q) → Y) (f : Y → ℂ) (hf : ∀ y, ‖f y‖ ≤ 1) : + ‖(principalTupleWeights (α := Empty) AB Ah L hL).complexMean + (fun x => f (F (fun i => ((origin i + stride i * (x i none : ℤ) : ℤ) : ZMod q)))) - + (FiniteProbabilityWeights.uniform (AI → ZMod q)).complexMean + (fun r => f (F (fun i => (origin i : ZMod q) + (stride i : ZMod q) * r i)))‖ ≤ + 4 * Fintype.card AI * ((q : ℝ) / S.value) := by + classical + have he := originalActiveCube_affine_residue_complexMean_error L hL q origin stride F f hf + have hs : (∑ i : AI, (q : ℝ) / L i) = Fintype.card AI * ((q : ℝ) / S.value) := by + simp only [allocatedActivePrincipalResidue_length B U basis S, Finset.sum_const, + Finset.card_univ, nsmul_eq_mul] + rw [hs] at he + exact he.trans_eq (by ring) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResiduePointMass.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResiduePointMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f592efca58d3d578ae16809b5af61b1d037803a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActiveResiduePointMass.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.Progressions.Fourier.AllocatedSupportedResidueSpectrum + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +variable (j : Fin m) (i : Fin (n j)) + +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +variable (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + +local notation "sources" => allocatedActiveResidueSources B U basis S j i hactive q hq r hsize +local notation "csource" => allocatedPrincipalNormalizedSource B U basis hR S j i hactive +local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i)) +local notation "torus" => blockTorusFactor (Fintype.card α) (j.val + 1) + (Fintype.card (B (Sigma.mk j (Sum.inr i)))) (4 * gamma) + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +noncomputable def allocatedActiveResiduePointApproximation + (M : ℕ) [NeZero M] (rows : Finset (Finset α)) (shift z : rows → ℤ) + (F : Finset (rows → Fin M)) : ℂ := + if ∀ t, |(z t : ℝ) - shift t| ≤ + blockJetScaleBound (Fintype.card α) (j.val + 1) (Fintype.card (B ⟨j, Sum.inr i⟩)) + (4 * gamma) * basisAxisScale (basis j) i then + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F + else 0 + +theorem allocatedActiveResiduePointMass_error_of_tail + {M : ℕ} [NeZero M] (hM : M = torus * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (shift z : rows → ℤ) + (F : Finset (rows → Fin M)) {ε : ℝ} (hε : 0 ≤ ε) + (htail : spectrumTail F (fun k => ‖∏ b : B ⟨j, Sum.inr i⟩, + weightedModerateGridCoefficient csource ((sources) b) 0 M rows k‖) ≤ ε) : + ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card * + (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift z).toReal : ℝ) : ℂ) - + allocatedActiveResiduePointApproximation B U basis hR S q r j i hactive hq hsize + M rows shift z F‖ ≤ ε := by + have hgamma : 0 < gamma := principalProfileSize_pos (hR j) _ + exact weightedModeratePointMass_error_cutoff (fun _ : B ⟨j, Sum.inr i⟩ => csource) + sources (fun _ => 0) (by positivity) (basisAxisScale_pos (basis j) i) + (allocatedActiveResidueSources_volume B U basis S j i hactive q hq r hsize hR) + hM rows hrows shift z + (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift) + (allocatedSupportedResidueJetPMF_source B U basis hR hσ S q r hcell j i hactive hq hsize rows shift) + F hε (by + simp only [Int.cast_zero] + exact htail) + +theorem allocatedActiveResiduePointMass_error_of_grid + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + {ζ ε : ℝ} {M : ℕ} [NeZero M] (hM : M = torus * basisAxisScale (basis j) i) + (hζ : 0 < ζ) (hζ1 : ζ ≤ 1) (hε : 0 ≤ ε) + (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (haccuracy : (2 * positiveModerateSpectrumConstant j.val rows.card P ((torus : ℝ) / (2 * gamma)) * + 2 ^ positiveModerateSpectrumExponent j.val rows.card + + (torus : ℝ) ^ rows.card * + (2 ^ positiveModerateLengthExponent j.val * positiveModerateLengthConstant j.val P) ^ + ((layerTailDegree m + 1) * rows.card)) * ζ ≤ ε) + (shift z : rows → ℤ) : + ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card * + (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift z).toReal : ℝ) : ℂ) - + allocatedActiveResiduePointApproximation B U basis hR S q r j i hactive hq hsize + M rows shift z + (positiveModerateSpectrumCover rows M j.val P ((torus : ℝ) / (2 * gamma)) S.value ζ)‖ ≤ ε := by + have hMK : (M : ℝ) ≤ (torus : ℝ) * basisAxisScale (basis j) i := by + simp only [hM, Nat.cast_mul, le_refl] + apply allocatedActiveResiduePointMass_error_of_tail B U basis hR hσ S q r hcell j i hactive hq hsize + hM rows hrows shift z _ hε + exact allocatedActiveResidueSpectrum_tail B U basis S j i hactive q hq r hsize hR + A hA P hcP hsP (Nat.cast_nonneg torus) (pow_nonneg (Nat.cast_nonneg torus) _) + hζ hζ1 hε (Nat.pos_of_ne_zero (NeZero.ne M)) hMK rows hrows hB + (allocatedGrid_modulus_cardinality B U basis S j i hgrid (Nat.cast_nonneg torus) hMK rows.card) + haccuracy + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActualCRTRationalMarginal.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActualCRTRationalMarginal.lean new file mode 100644 index 0000000000000000000000000000000000000000..501f07ca3bd69650e1bc145d73b56887b86045d0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedActualCRTRationalMarginal.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedActualRationalMarginal + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] +variable {I E : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "hSides" => allocatedPrincipalSides_pos B U basis S +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) short sides +local notation "Long" => LayerSamplerLongVariables short G B +local notation "Out" => Sigma (AllocatedCongruenceRankOutput X E short) +local notation "law" => principalTupleWeights (α := Empty) B degree sides hSides + +variable {PrimeIndex : Type*} [Fintype PrimeIndex] +variable (primes exponent : PrimeIndex → ℕ) [∀ l, NeZero (primes l)] +local notation "N" => (∏ l, primes l ^ exponent l) +local instance actualCRTModulusNeZero : NeZero N := + ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (primes l)))⟩ + +theorem allocatedActual_crtRationalForecast_tsum_marginal + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + {A : Type*} (selected : A → Σ j : Fin m, Fin (n j)) + (hsmall : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (c : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + ((selected a).1.val + 1) → ℤ) + (hc : ∀ a d, c a d ∈ (allocatedLayerIntegerPMFs B U basis hR hσ S + (selected a).1 (selected a).2 d).support) + (x : G → IntegerScalarCubeBox Empty S.value) + (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (deck : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis short j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (hp : ∀ l, (primes l).Prime) (hinj : Function.Injective primes) + (hcoprime : Pairwise (fun l k => (primes l ^ exponent l).Coprime (primes k ^ exponent k))) + (origin : ∀ l, Long → ZMod (primes l ^ exponent l)) + {q : ℕ} [NeZero q] (hq : q ∣ N) + {gridVolume : ℝ} (hV : gridVolume ≠ 0) + (test : (A → ((Finset.univ : Finset (Finset Empty)) : Type) → ℤ) → + (Out → ZMod q) → ℂ) : + let poly := allocatedForecastPolynomial short base noise deck projection + (∑' z, 𝔼 b : Out → ZMod N, + ((rationalInactiveForecast (law) + (fun _ => crtPolynomialInputLaw primes exponent (fun _ => 0) hcoprime origin) + (forecastInactiveFixedOutput B U basis S selected c x) + (fun v => integerLongPolynomialOutput poly (fun k => (v k.1 k.2 : ℤ)) N) + N gridVolume z b / gridVolume : ℝ) : ℂ) * + test z (fun j => ZMod.castHom hq (ZMod q) (b j))) = + (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean (fun u => + 𝔼 t : Long → ZMod q, + test (forecastInactiveShortGrid B U basis S selected c u) + (fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim t (fun k => (allocatedShortPrincipalRaw B U basis S u k : ZMod q))) + (poly o))) := by + intro poly + have hcrt := rationalInactivePolynomialForecast_unrestrictedCRT_tsum_marginal (law) + (forecastInactiveFixedOutput B U basis S selected c x) primes exponent hp hinj hcoprime origin + poly (fun v k => (v k.1 k.2 : ℤ)) hq hV test + have huniform := rationalInactivePolynomialForecast_tsum_marginal (law) + (forecastInactiveFixedOutput B U basis S selected c x) poly + (fun v k => (v k.1 k.2 : ℤ)) hq hV test + exact hcrt.trans (huniform.symm.trans + (allocatedActual_rationalForecast_tsum_marginal B U basis S hR hσ selected hsmall c hc x + base noise deck projection hq hV test)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineAnalyticBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineAnalyticBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ea51d9af07613d24b67165c0728a4e415d8834a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineAnalyticBudget.lean @@ -0,0 +1,325 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedFiniteIdealMaskBudget +import OAI.Combinatorics.Progressions.Sampling.AllocatedSlicedGridResourceBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped NNReal + +theorem allocatedAffineFactor_exp_bound {B Q Op Pper cutoff coord Qgrid Mp period r radius : ℝ} + (axes gridaxes : ℕ) (hB : 0 ≤ B) (hQ : 0 ≤ Q) (hOp : 0 ≤ Op) (hPper : 0 ≤ Pper) + (ha : (axes : ℝ) ≤ B) (hg : (gridaxes : ℝ) ≤ B) + (hc0 : 0 ≤ cutoff) (hcoord0 : 0 ≤ coord) (hgrid0 : 0 ≤ Qgrid) (hMp0 : 0 ≤ Mp) + (hper0 : 0 ≤ period) (hc : cutoff ≤ Real.exp B) (hcoord : coord ≤ Real.exp B) + (hQgrid : Qgrid ≤ Real.exp B) (hMp : Mp ≤ Real.exp Pper) (hper : period ≤ Real.exp Pper) + (hr : 1 ≤ r) (hradius : 1 ≤ radius) : + let Llong := (axes * cutoff / (2 * r)) * coord + + max ((Real.exp (axes + 6 * Q + 12) + axes * cutoff / (2 * radius)) * coord * Mp) (4 * Mp) + let Lgrid := max (gridaxes * Real.exp Op * Qgrid * coord * (Real.exp Op) ^ gridaxes) + (4 * (Real.exp Op) ^ gridaxes) + (Llong + Lgrid) * (period * (Real.exp Op) ^ gridaxes) ≤ + Real.exp (10 * B + 6 * Q + 2 * Pper + (2 * B + 1) * Op + 19) := by + intro Llong Lgrid + have hax : (axes : ℝ) ≤ Real.exp B := ha.trans (by linarith [Real.add_one_le_exp B]) + have hgx : (gridaxes : ℝ) ≤ Real.exp B := hg.trans (by linarith [Real.add_one_le_exp B]) + have hcut (z : ℝ) (hz : 1 ≤ z) : (axes : ℝ) * cutoff / (2 * z) ≤ Real.exp (2 * B) := by + calc + _ ≤ (axes : ℝ) * cutoff := div_le_self (mul_nonneg (Nat.cast_nonneg _) hc0) (by linarith) + _ ≤ Real.exp B * Real.exp B := mul_le_mul hax hc hc0 (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, ← two_mul] + have hfirst : (axes * cutoff / (2 * r)) * coord ≤ Real.exp (3 * B) := by + calc + _ ≤ Real.exp (2 * B) * Real.exp B := mul_le_mul (hcut r hr) hcoord hcoord0 (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hsum : Real.exp (axes + 6 * Q + 12) + axes * cutoff / (2 * radius) ≤ + Real.exp (3 * B + 6 * Q + 13) := by + have hs := add_le_exp_add_one (show 0 ≤ B + 6 * Q + 12 by positivity) + (show 0 ≤ 2 * B by positivity) + (Real.exp_le_exp.mpr (add_le_add (add_le_add ha le_rfl) le_rfl)) (hcut radius hradius) + exact hs.trans_eq (by congr 1; ring) + have hsecond : (Real.exp (axes + 6 * Q + 12) + axes * cutoff / (2 * radius)) * coord * Mp ≤ + Real.exp (4 * B + 6 * Q + Pper + 13) := by + calc + _ ≤ Real.exp (3 * B + 6 * Q + 13) * Real.exp B * Real.exp Pper := + mul_le_mul (mul_le_mul hsum hcoord hcoord0 (Real.exp_nonneg _)) hMp hMp0 (by positivity) + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hfour : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have hthird : 4 * Mp ≤ Real.exp (4 * B + 6 * Q + Pper + 13) := by + calc + _ ≤ Real.exp 4 * Real.exp Pper := mul_le_mul hfour hMp hMp0 (Real.exp_nonneg _) + _ = Real.exp (4 + Pper) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + have hlong : Llong ≤ Real.exp (7 * B + 6 * Q + Pper + 14) := by + have h := add_le_exp_add_one (show 0 ≤ 3 * B by positivity) + (show 0 ≤ 4 * B + 6 * Q + Pper + 13 by positivity) hfirst (max_le hsecond hthird) + exact h.trans_eq (by congr 1; ring) + have hpower : (Real.exp Op) ^ gridaxes ≤ Real.exp (B * Op) := by + rw [← Real.exp_nat_mul] + exact Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hg hOp) + have hgridFirst : gridaxes * Real.exp Op * Qgrid * coord * (Real.exp Op) ^ gridaxes ≤ + Real.exp (3 * B + (B + 1) * Op) := by + calc + _ ≤ Real.exp B * Real.exp Op * Real.exp B * Real.exp B * Real.exp (B * Op) := by gcongr + _ = _ := by simp only [← Real.exp_add]; congr 1; ring + have hgrid : Lgrid ≤ Real.exp (3 * B + (B + 1) * Op + 4) := by + apply max_le + · exact hgridFirst.trans (Real.exp_le_exp.mpr (by linarith)) + · calc + _ ≤ Real.exp 4 * Real.exp (B * Op) := mul_le_mul hfour hpower (by positivity) (Real.exp_nonneg _) + _ = Real.exp (4 + B * Op) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + have hboth := add_le_exp_add_one (show 0 ≤ 7 * B + 6 * Q + Pper + 14 by positivity) + (show 0 ≤ 3 * B + (B + 1) * Op + 4 by positivity) hlong hgrid + have hcover : period * (Real.exp Op) ^ gridaxes ≤ Real.exp (Pper + B * Op) := + (mul_le_mul hper hpower (by positivity) (Real.exp_nonneg _)).trans_eq (Real.exp_add _ _).symm + calc + _ ≤ Real.exp ((7 * B + 6 * Q + Pper + 14) + (3 * B + (B + 1) * Op + 4) + 1) * + Real.exp (Pper + B * Op) := mul_le_mul hboth hcover (by positivity) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem allocatedAffineCover_exp_bound {B Op Pper period : ℝ} + (gridaxes : ℕ) (hB : 0 ≤ B) (hOp : 0 ≤ Op) + (hg : (gridaxes : ℝ) ≤ B) (hperiod : period ≤ Real.exp Pper) : + period * (Real.exp Op) ^ gridaxes ≤ Real.exp (Pper + B * Op) := by + have hpower : (Real.exp Op) ^ gridaxes ≤ Real.exp (B * Op) := by + rw [← Real.exp_nat_mul] + exact Real.exp_le_exp.mpr (mul_le_mul hg le_rfl hOp hB) + exact (mul_le_mul hperiod hpower (by positivity) (Real.exp_nonneg _)).trans_eq + (Real.exp_add _ _).symm + +theorem allocatedAffineFactor_nnreal_exp_bound {B Q Op Pper : ℝ} + (cutoff coord Qgrid Mp period r radius : ℝ≥0) (axes gridaxes : ℕ) + (hB : 0 ≤ B) (hQ : 0 ≤ Q) (hOp : 0 ≤ Op) (hPper : 0 ≤ Pper) + (ha : (axes : ℝ) ≤ B) (hg : (gridaxes : ℝ) ≤ B) + (hc : (cutoff : ℝ) ≤ Real.exp B) (hcoord : (coord : ℝ) ≤ Real.exp B) + (hQgrid : (Qgrid : ℝ) ≤ Real.exp B) (hMp : (Mp : ℝ) ≤ Real.exp Pper) + (hper : (period : ℝ) ≤ Real.exp Pper) (hr : 1 ≤ r) (hradius : 1 ≤ radius) : + let Llong : ℝ≥0 := (axes * cutoff / (2 * r)) * coord + + max ((⟨Real.exp (axes + 6 * Q + 12), Real.exp_nonneg _⟩ + axes * cutoff / (2 * radius)) * coord * Mp) (4 * Mp) + let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg _⟩ + let Lgrid : ℝ≥0 := max (gridaxes * Lprimitive * Qgrid * coord * Lprimitive ^ gridaxes) + (4 * Lprimitive ^ gridaxes) + (((Llong + Lgrid) * (period * Lprimitive ^ gridaxes) : ℝ≥0) : ℝ) ≤ + Real.exp (10 * B + 6 * Q + 2 * Pper + (2 * B + 1) * Op + 19) := by + exact + allocatedAffineFactor_exp_bound axes gridaxes hB hQ hOp hPper ha hg + cutoff.coe_nonneg coord.coe_nonneg Qgrid.coe_nonneg Mp.coe_nonneg period.coe_nonneg + hc hcoord hQgrid hMp hper (show (1 : ℝ) ≤ r from hr) (show (1 : ℝ) ≤ radius from hradius) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators + +theorem exists_allocatedAffineModelMass_budget (m dim : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {D p v F Prho Pk target : ℝ}, + 0 ≤ D → 0 ≤ p → 0 ≤ v → 0 ≤ F → 0 ≤ Prho → 0 ≤ Pk → 0 ≤ target → + ∀ (outputs axes gridaxes ambient : ℕ), + (outputs : ℝ) ≤ D → (axes : ℝ) ≤ D → (gridaxes : ℝ) ≤ D → (ambient : ℝ) ≤ D → + (dim : ℝ) ≤ D → (probabilityProfileLipschitz : ℝ) ≤ D → + let Eg := outputs * Prho + (target + F) + 1 + let Op := allocatedSlicedGridResourceLog m dim D p v Eg + let Plong := ((m : ℝ) + 2) * dim + m + 4 + Prho + axes * max Op 0 + (target + F) + 2 + let Q := idealSiteLogBudget outputs dim Plong + 2 * (2 : ℝ) ^ dim + F + (2 : ℝ) ^ dim * (ambient * ((m + 1 : ℕ) * Pk)) + + ((2 : ℝ) ^ dim * axes * (4 * Q + 8) + Q) + gridaxes * Op ≤ + (D + p + v + F + Prho + Pk + target + A) ^ A := by + obtain ⟨b, hb, hgrid⟩ := exists_allocatedSlicedGridResource_budget m dim + let X : Polynomial ℕ := Polynomial.X + let O : Polynomial ℕ := (3 * X + (X ^ 2 + 2 * X + 1) + Polynomial.C b) ^ b + let Pbox : Polynomial ℕ := Polynomial.C ((m + 2) * dim + m + 4) + let Pl : Polynomial ℕ := Pbox + X + X * O + 2 * X + 2 + let Qp := allocatedFiniteIdealProfileLog X Pl + let poly : Polynomial ℕ := 2 * (2 : Polynomial ℕ) ^ dim + X + (2 : Polynomial ℕ) ^ dim * + (X * ((m + 1 : ℕ) * X)) + ((2 : Polynomial ℕ) ^ dim * X * (4 * Qp + 8) + Qp) + X * O + obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget poly + refine ⟨A, hA, ?_⟩ + intro D p v F Prho Pk target hD hp hv hF hPrho hPk htarget outputs axes gridaxes ambient + hout haxes hgridaxes hamb hdim hprofile Eg Op Plong Q + let R := D + p + v + F + Prho + Pk + target + have hR : 0 ≤ R := by dsimp [R]; positivity + have hDR : D ≤ R := by dsimp [R]; linarith + have hpR : p ≤ R := by dsimp [R]; linarith + have hvR : v ≤ R := by dsimp [R]; linarith + have hFR : F ≤ R := by dsimp [R]; linarith + have hPrhoR : Prho ≤ R := by dsimp [R]; linarith + have hPkR : Pk ≤ R := by dsimp [R]; linarith + have htR : target ≤ R := by dsimp [R]; linarith + have hEg : 0 ≤ Eg := by dsimp [Eg]; positivity + have hEgR : Eg ≤ R ^ 2 + 2 * R + 1 := by + have hprod := mul_le_mul (hout.trans hDR) hPrhoR hPrho hR + dsimp only [Eg] + nlinarith only [hprod, htR, hFR] + let Ob := (3 * R + (R ^ 2 + 2 * R + 1) + b) ^ b + have hOb : 0 ≤ Ob := by dsimp [Ob]; positivity + have hOp : 0 ≤ Op := allocatedSlicedGridResourceLog_nonneg m dim hD hp hv hEg + have hOpR : Op ≤ Ob := (hgrid hD hp hv hEg).trans + (pow_le_pow_left₀ (by positivity) (by linarith only [hDR, hpR, hvR, hEgR]) b) + let Plb := (((m + 2) * dim + m + 4 : ℕ) : ℝ) + R + R * Ob + 2 * R + 2 + have hPlb : 0 ≤ Plb := by dsimp [Plb]; positivity + have hPl : 0 ≤ Plong := by dsimp [Plong]; positivity + have hPlR : Plong ≤ Plb := by + have hm : (axes : ℝ) * max Op 0 ≤ R * Ob := by + rw [max_eq_left hOp] + exact mul_le_mul (haxes.trans hDR) hOpR hOp hR + dsimp only [Plong, Plb] + push_cast + linarith only [hPrhoR, htR, hFR, hm] + let Qb := allocatedFiniteIdealProfileLog R Plb + have hQb : 0 ≤ Qb := (allocatedFiniteIdeal_budget_nonneg m hR hPlb (le_refl (0 : ℝ))).1 + have hQ : 0 ≤ Q := (idealSiteLogBudget_bounds outputs dim hPl).1 + have hQR : Q ≤ Qb := by + apply (idealSiteLogBudget_le_finite_profile hPl hout hdim hprofile).trans + change allocatedFiniteIdealProfileLog D Plong ≤ allocatedFiniteIdealProfileLog R Plb + unfold allocatedFiniteIdealProfileLog + gcongr + have hmass : 2 * (2 : ℝ) ^ dim + F + (2 : ℝ) ^ dim * (ambient * ((m + 1 : ℕ) * Pk)) + + ((2 : ℝ) ^ dim * axes * (4 * Q + 8) + Q) + gridaxes * Op ≤ + 2 * (2 : ℝ) ^ dim + R + (2 : ℝ) ^ dim * (R * ((m + 1 : ℕ) * R)) + + ((2 : ℝ) ^ dim * R * (4 * Qb + 8) + Qb) + R * Ob := by + gcongr + · exact hamb.trans hDR + · exact haxes.trans hDR + · exact hgridaxes.trans hDR + apply hmass.trans + simpa [poly, X, O, Pbox, Pl, Qp, Ob, Plb, Qb, allocatedFiniteIdealProfileLog, + Polynomial.eval₂_pow] using hbound R hR + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators NNReal + +theorem exists_allocatedAffineAnalytic_budget (m dim : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {D p v F Prho Pk target B : ℝ}, + 0 ≤ D → 0 ≤ p → 0 ≤ v → 0 ≤ F → 0 ≤ Prho → 0 ≤ Pk → 0 ≤ target → 0 ≤ B → + ∀ (outputs axes : ℕ), (outputs : ℝ) ≤ D → (axes : ℝ) ≤ D → + (dim : ℝ) ≤ D → (probabilityProfileLipschitz : ℝ) ≤ D → + let Eg := outputs * Prho + (target + F) + 1 + let Op := allocatedSlicedGridResourceLog m dim D p v Eg + let Plong := ((m : ℝ) + 2) * dim + m + 4 + Prho + axes * max Op 0 + (target + F) + 2 + let Q := idealSiteLogBudget outputs dim Plong + 10 * B + 6 * Q + 2 * ((m + 1 : ℕ) * Pk) + (2 * B + 1) * Op + 19 ≤ + (D + p + v + F + Prho + Pk + target + B + A) ^ A := by + obtain ⟨b, hb, hgrid⟩ := exists_allocatedSlicedGridResource_budget m dim + let X : Polynomial ℕ := Polynomial.X + let O : Polynomial ℕ := (3 * X + (X ^ 2 + 2 * X + 1) + Polynomial.C b) ^ b + let Pbox : Polynomial ℕ := Polynomial.C ((m + 2) * dim + m + 4) + let Pl : Polynomial ℕ := Pbox + X + X * O + 2 * X + 2 + let Qp := allocatedFiniteIdealProfileLog X Pl + let poly : Polynomial ℕ := 10 * X + 6 * Qp + 2 * ((m + 1 : ℕ) * X) + (2 * X + 1) * O + 19 + obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget poly + refine ⟨A, hA, ?_⟩ + intro D p v F Prho Pk target B hD hp hv hF hPrho hPk htarget hB outputs axes + hout haxes hdim hprofile Eg Op Plong Q + let R := D + p + v + F + Prho + Pk + target + B + have hR : 0 ≤ R := by dsimp [R]; positivity + have hBR : B ≤ R := by dsimp [R]; linarith + have hDR : D ≤ R := by dsimp [R]; linarith + have hpR : p ≤ R := by dsimp [R]; linarith + have hvR : v ≤ R := by dsimp [R]; linarith + have hFR : F ≤ R := by dsimp [R]; linarith + have hPrhoR : Prho ≤ R := by dsimp [R]; linarith + have hPkR : Pk ≤ R := by dsimp [R]; linarith + have htR : target ≤ R := by dsimp [R]; linarith + have hEg : 0 ≤ Eg := by dsimp [Eg]; positivity + have hEgR : Eg ≤ R ^ 2 + 2 * R + 1 := by + have hprod := mul_le_mul (hout.trans hDR) hPrhoR hPrho hR + dsimp only [Eg] + nlinarith only [hprod, htR, hFR] + let Ob := (3 * R + (R ^ 2 + 2 * R + 1) + b) ^ b + have hOb : 0 ≤ Ob := by dsimp [Ob]; positivity + have hOp : 0 ≤ Op := allocatedSlicedGridResourceLog_nonneg m dim hD hp hv hEg + have hOpR : Op ≤ Ob := (hgrid hD hp hv hEg).trans + (pow_le_pow_left₀ (by positivity) (by linarith only [hDR, hpR, hvR, hEgR]) b) + let Plb := (((m + 2) * dim + m + 4 : ℕ) : ℝ) + R + R * Ob + 2 * R + 2 + have hPlb : 0 ≤ Plb := by dsimp [Plb]; positivity + have hPl : 0 ≤ Plong := by dsimp [Plong]; positivity + have hPlR : Plong ≤ Plb := by + have hm : (axes : ℝ) * max Op 0 ≤ R * Ob := by + rw [max_eq_left hOp] + exact mul_le_mul (haxes.trans hDR) hOpR hOp hR + dsimp only [Plong, Plb] + push_cast + linarith only [hPrhoR, htR, hFR, hm] + let Qb := allocatedFiniteIdealProfileLog R Plb + have hQb : 0 ≤ Qb := (allocatedFiniteIdeal_budget_nonneg m hR hPlb (le_refl (0 : ℝ))).1 + have hQ : 0 ≤ Q := (idealSiteLogBudget_bounds outputs dim hPl).1 + have hQR : Q ≤ Qb := by + apply (idealSiteLogBudget_le_finite_profile hPl hout hdim hprofile).trans + change allocatedFiniteIdealProfileLog D Plong ≤ allocatedFiniteIdealProfileLog R Plb + unfold allocatedFiniteIdealProfileLog + gcongr + have hcost : 10 * B + 6 * Q + 2 * ((m + 1 : ℕ) * Pk) + (2 * B + 1) * Op + 19 ≤ + 10 * R + 6 * Qb + 2 * ((m + 1 : ℕ) * R) + (2 * R + 1) * Ob + 19 := by + gcongr + apply hcost.trans + simpa [poly, X, O, Pbox, Pl, Qp, Ob, Plb, Qb, allocatedFiniteIdealProfileLog, + Polynomial.eval₂_pow] using hbound R hR + +theorem allocatedAffineAnalytic_bounds (m dim outputs axes gridaxes : ℕ) + {D p v F Prho Pk target B : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (hv : 0 ≤ v) (hF : 0 ≤ F) + (hPrho : 0 ≤ Prho) (hPk : 0 ≤ Pk) (htarget : 0 ≤ target) (hB : 0 ≤ B) + (hout : (outputs : ℝ) ≤ D) (haxes : (axes : ℝ) ≤ D) + (hdim : (dim : ℝ) ≤ D) (hprofile : (probabilityProfileLipschitz : ℝ) ≤ D) + (hDB : D ≤ B) (hgrid : (gridaxes : ℝ) ≤ B) + (cutoff coord Qgrid r radius : ℝ≥0) (hr : 1 ≤ r) (hradius : 1 ≤ radius) + (hc : (cutoff : ℝ) ≤ Real.exp B) (hcoord : (coord : ℝ) ≤ Real.exp B) + (hQgrid : (Qgrid : ℝ) ≤ Real.exp B) + (M period : ℕ) (hM : (M : ℝ) ≤ Real.exp Pk) (hperiod : period ≤ M ^ (m + 1)) : + let A := Classical.choose (exists_allocatedAffineAnalytic_budget m dim) + let Eg := outputs * Prho + (target + F) + 1 + let Op := allocatedSlicedGridResourceLog m dim D p v Eg + let Plong := ((m : ℝ) + 2) * Fintype.card (Fin dim) + m + 4 + Prho + axes * max Op 0 + (target + F) + 2 + let Q := idealSiteLogBudget outputs (Fintype.card (Fin dim)) Plong + let Llong : ℝ≥0 := (axes * cutoff / (2 * r)) * coord + + max ((⟨Real.exp (axes + 6 * Q + 12), Real.exp_nonneg _⟩ + axes * cutoff / (2 * radius)) * coord * (M ^ (m + 1))) (4 * (M ^ (m + 1))) + let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg _⟩ + let Lgrid : ℝ≥0 := max (gridaxes * Lprimitive * Qgrid * coord * Lprimitive ^ gridaxes) + (4 * Lprimitive ^ gridaxes) + (((Llong + Lgrid) * (period * Lprimitive ^ gridaxes) : ℝ≥0) : ℝ) ≤ + Real.exp ((D + p + v + F + Prho + Pk + target + B + A) ^ A) ∧ + (period : ℝ) * (Real.exp Op) ^ gridaxes ≤ + Real.exp ((D + p + v + F + Prho + Pk + target + B + A) ^ A) := by + intro A Eg Op Plong Q Llong Lprimitive Lgrid + have hEg : 0 ≤ Eg := by dsimp only [Eg]; positivity + have hOp := allocatedSlicedGridResourceLog_nonneg m dim hD hp hv hEg + have hPlong : 0 ≤ Plong := by dsimp only [Plong]; positivity + have hQ := (idealSiteLogBudget_bounds outputs (Fintype.card (Fin dim)) hPlong).1 + have hMp : ((M ^ (m + 1) : ℝ≥0) : ℝ) ≤ Real.exp (((m + 1 : ℕ) : ℝ) * Pk) := by + change (M : ℝ) ^ (m + 1) ≤ _ + calc + _ ≤ (Real.exp Pk) ^ (m + 1) := pow_le_pow_left₀ (Nat.cast_nonneg _) hM _ + _ = _ := (Real.exp_nat_mul _ _).symm + have hper : (period : ℝ) ≤ Real.exp (((m + 1 : ℕ) : ℝ) * Pk) := + (by exact_mod_cast hperiod : (period : ℝ) ≤ (M : ℝ) ^ (m + 1)).trans hMp + have hlog : 10 * B + 6 * Q + 2 * (((m + 1 : ℕ) : ℝ) * Pk) + (2 * B + 1) * Op + 19 ≤ + (D + p + v + F + Prho + Pk + target + B + A) ^ A := by + simpa only [Q, Plong, Fintype.card_fin] using + (Classical.choose_spec (exists_allocatedAffineAnalytic_budget m dim)).2 + hD hp hv hF hPrho hPk htarget hB outputs axes hout haxes hdim hprofile + exact ⟨(allocatedAffineFactor_nnreal_exp_bound cutoff coord Qgrid (M ^ (m + 1)) period r radius + axes gridaxes hB hQ hOp (by positivity) (haxes.trans hDB) hgrid hc hcoord hQgrid hMp hper + hr hradius).trans (Real.exp_le_exp.mpr hlog), + (allocatedAffineCover_exp_bound gridaxes hB hOp hgrid hper).trans + (Real.exp_le_exp.mpr (le_trans (by + have hper0 : 0 ≤ (((m + 1 : ℕ) : ℝ) * Pk) := mul_nonneg (Nat.cast_nonneg _) hPk + nlinarith only [hB, hQ, hOp, hper0, mul_nonneg hB hOp]) hlog))⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineCanonicalBackendBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineCanonicalBackendBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a46bdcba9f2c4e0ee3f0bf7b940abfb5e62da4e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineCanonicalBackendBudget.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateThresholdSuccessor +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffinePhysicalTerminalReset + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +def allocatedAffineResetHeightLog (p : ℝ) : ℝ := (p + 4) ^ 12 + +theorem allocatedAffineResetHeightLog_bounds {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ allocatedAffineResetHeightLog p ∧ + p ≤ allocatedAffineResetHeightLog p ∧ + (p + 4) ^ 11 ≤ allocatedAffineResetHeightLog p ∧ + (p + 3) ^ 7 ≤ allocatedAffineResetHeightLog p ∧ + (p + 2) ^ 4 ≤ allocatedAffineResetHeightLog p := by + have hbase : 1 ≤ p + 4 := by linarith + have hlinear : p + 4 ≤ (p + 4) ^ 12 := by + simpa only [pow_one] using pow_le_pow_right₀ hbase (by norm_num : 1 ≤ 12) + have h11 : (p + 4) ^ 11 ≤ (p + 4) ^ 12 := + pow_le_pow_right₀ hbase (by norm_num) + have h7 : (p + 3) ^ 7 ≤ (p + 4) ^ 12 := + (pow_le_pow_left₀ (by linarith : 0 ≤ p + 3) + (by linarith : p + 3 ≤ p + 4) 7).trans + (pow_le_pow_right₀ hbase (by norm_num)) + have h4 : (p + 2) ^ 4 ≤ (p + 4) ^ 12 := + (pow_le_pow_left₀ (by linarith : 0 ≤ p + 2) + (by linarith : p + 2 ≤ p + 4) 4).trans + (pow_le_pow_right₀ hbase (by norm_num)) + dsimp only [allocatedAffineResetHeightLog] + exact ⟨pow_nonneg (by linarith) _, (by linarith), h11, h7, h4⟩ + +theorem allocatedAffineResetHeightLog_exp_bounds {p : ℝ} (hp : 0 ≤ p) : + 1 ≤ Real.exp (allocatedAffineResetHeightLog p) ∧ + Real.exp p ≤ Real.exp (allocatedAffineResetHeightLog p) ∧ + Real.exp ((p + 4) ^ 11) ≤ Real.exp (allocatedAffineResetHeightLog p) ∧ + Real.exp ((p + 3) ^ 7) ≤ Real.exp (allocatedAffineResetHeightLog p) ∧ + Real.exp ((p + 2) ^ 4) ≤ Real.exp (allocatedAffineResetHeightLog p) := by + obtain ⟨h0, hp', h11, h7, h4⟩ := allocatedAffineResetHeightLog_bounds hp + exact ⟨Real.one_le_exp_iff.mpr h0, Real.exp_le_exp.mpr hp', + Real.exp_le_exp.mpr h11, Real.exp_le_exp.mpr h7, Real.exp_le_exp.mpr h4⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open NilpotentLieFiltration + +noncomputable def allocatedAffineResetRightLog (s : ℕ) (pFull : ℝ) : ℝ := + (pFull + allocatedEarlyAffineRightExponent (s + 1) 4) ^ + allocatedEarlyAffineRightExponent (s + 1) 4 + +noncomputable def allocatedAffineResetLeftLog (s : ℕ) (pFull : ℝ) : ℝ := + (pFull + allocatedEarlyAffineLeftExponent (s + 1) 4) ^ + allocatedEarlyAffineLeftExponent (s + 1) 4 + +noncomputable def allocatedAffineResetCompareLog (s : ℕ) (pNative : ℝ) : ℝ := + (pNative + allocatedAffineResetCompareExponent s) ^ allocatedAffineResetCompareExponent s + +noncomputable def allocatedAffineResetMapBudget (s : ℕ) (p0 pFull : ℝ) : ℝ := + ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 + allocatedAffineResetHeightLog p0 + 1 + p0 + + allocatedAffineResetRightLog s pFull + +noncomputable def allocatedAffineCanonicalNativeBudget (s : ℕ) (p0 pFull : ℝ) : ℝ := + allocatedAffineResetNativeBudget s pFull (allocatedAffineResetMapBudget s p0 pFull) p0 + +noncomputable def allocatedAffineCanonicalBudget (s : ℕ) (p0 pFull : ℝ) : ℝ := + p0 + pFull + allocatedAffineResetMapBudget s p0 pFull + + allocatedAffineCanonicalNativeBudget s p0 pFull + + allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s p0 pFull) + + allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull) + + allocatedAffineResetLeftLog s pFull + (s + 2 : ℕ) + +structure AllocatedAffineResetMapBudgetBounds (s : ℕ) (p0 pFull : ℝ) : Prop where + nonnegative : 0 ≤ allocatedAffineResetMapBudget s p0 pFull + input : p0 ≤ allocatedAffineResetMapBudget s p0 pFull + pointwise : ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 ≤ + allocatedAffineResetMapBudget s p0 pFull + height : allocatedAffineResetHeightLog p0 + 1 ≤ allocatedAffineResetMapBudget s p0 pFull + denominatorLog : p0 + allocatedAffineResetRightLog s pFull ≤ + allocatedAffineResetMapBudget s p0 pFull + +theorem allocatedAffineResetMapBudget_bounds (s : ℕ) {p0 pFull : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) : + AllocatedAffineResetMapBudgetBounds s p0 pFull := by + have hsection : 0 ≤ ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 := + hp0.trans (ordinaryImagePointwiseBudget_ge (s + 1) (s + 1) hp0) + have hheight : 0 ≤ allocatedAffineResetHeightLog p0 := by + unfold allocatedAffineResetHeightLog + positivity + have hright : 0 ≤ allocatedAffineResetRightLog s pFull := by + unfold allocatedAffineResetRightLog + positivity + constructor <;> dsimp only [allocatedAffineResetMapBudget] <;> linarith + +theorem allocatedAffineResetMapBudget_denominator (s : ℕ) {p0 pFull : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) {l n : ℕ} + (hl : (l : ℝ) ≤ Real.exp p0) + (hn : (n : ℝ) ≤ Real.exp (allocatedAffineResetRightLog s pFull)) : + ((l * n : ℕ) : ℝ) ≤ Real.exp (allocatedAffineResetMapBudget s p0 pFull) := by + rw [Nat.cast_mul] + calc + (l : ℝ) * n ≤ Real.exp p0 * Real.exp (allocatedAffineResetRightLog s pFull) := + mul_le_mul hl hn (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = Real.exp (p0 + allocatedAffineResetRightLog s pFull) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (allocatedAffineResetMapBudget_bounds s hp0 hFull).denominatorLog + +theorem allocatedAffineResetLogBudget_nonnegative (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ allocatedAffineResetLogBudget s p := by + unfold allocatedAffineResetLogBudget markedNativeLiftInput fullMarkedNativeInput + pointwiseFastSectionInput + positivity + +structure AllocatedAffineCanonicalBudgetBounds (s : ℕ) (p0 pFull : ℝ) : Prop where + nonnegative : 0 ≤ allocatedAffineCanonicalBudget s p0 pFull + map_nonnegative : 0 ≤ allocatedAffineResetMapBudget s p0 pFull + native_nonnegative : 0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull + input : p0 ≤ allocatedAffineCanonicalBudget s p0 pFull + full : pFull ≤ allocatedAffineCanonicalBudget s p0 pFull + map : allocatedAffineResetMapBudget s p0 pFull ≤ allocatedAffineCanonicalBudget s p0 pFull + native : allocatedAffineCanonicalNativeBudget s p0 pFull ≤ allocatedAffineCanonicalBudget s p0 pFull + native_input : p0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull + native_full : pFull ≤ allocatedAffineCanonicalNativeBudget s p0 pFull + native_map : allocatedAffineResetMapBudget s p0 pFull ≤ allocatedAffineCanonicalNativeBudget s p0 pFull + reset : allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤ + allocatedAffineCanonicalBudget s p0 pFull + compare : allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤ + allocatedAffineCanonicalBudget s p0 pFull + physical : allocatedAffineResetLeftLog s pFull ≤ allocatedAffineCanonicalBudget s p0 pFull + interpolation_log : p0 + (s + 2 : ℕ) ≤ allocatedAffineCanonicalBudget s p0 pFull + +theorem allocatedAffineCanonicalBudget_bounds (s : ℕ) {p0 pFull : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) : + AllocatedAffineCanonicalBudgetBounds s p0 pFull := by + have hm := allocatedAffineResetMapBudget_bounds s hp0 hFull + obtain ⟨hn, hnf, hnm, hnq, hnl, hn4, hn3⟩ := + affineResetNativeBudget_bounds (allocatedEarlyAffineLeftExponent (s + 1) 4) + hFull hm.nonnegative (q := p0) + change 0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull at hn + change pFull ≤ allocatedAffineCanonicalNativeBudget s p0 pFull at hnf + change allocatedAffineResetMapBudget s p0 pFull ≤ + allocatedAffineCanonicalNativeBudget s p0 pFull at hnm + change p0 ≤ allocatedAffineCanonicalNativeBudget s p0 pFull at hnq + have hreset := allocatedAffineResetLogBudget_nonnegative s hn + have hcompare : 0 ≤ allocatedAffineResetCompareLog s + (allocatedAffineCanonicalNativeBudget s p0 pFull) := by + unfold allocatedAffineResetCompareLog + positivity + have hleft : 0 ≤ allocatedAffineResetLeftLog s pFull := by + unfold allocatedAffineResetLeftLog + positivity + have hs : (0 : ℝ) ≤ (s + 2 : ℕ) := Nat.cast_nonneg _ + constructor + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + · exact hm.nonnegative + · exact hn + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + · dsimp only [allocatedAffineCanonicalBudget]; linarith + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + · exact hnq + · exact hnf + · exact hnm + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + · dsimp only [allocatedAffineCanonicalBudget]; linarith [hm.nonnegative] + +structure AllocatedAffineCanonicalExpBounds (s : ℕ) (p0 pFull : ℝ) : Prop where + map_absorption : Real.exp ((allocatedAffineResetMapBudget s p0 pFull + 2) ^ 4) ≤ + Real.exp (allocatedAffineCanonicalNativeBudget s p0 pFull) + physical_absorption : Real.exp (allocatedAffineResetLeftLog s pFull) ≤ + Real.exp ((allocatedAffineCanonicalNativeBudget s p0 pFull + 2) ^ (1 : ℕ)) + original_absorption : Real.exp p0 ≤ + Real.exp ((allocatedAffineCanonicalNativeBudget s p0 pFull + 2) ^ (1 : ℕ)) + mapped_absorption : Real.exp ((allocatedAffineResetMapBudget s p0 pFull + 2) ^ 3 + p0) ≤ + Real.exp ((allocatedAffineCanonicalNativeBudget s p0 pFull + 2) ^ (1 : ℕ)) + compare_cutoff : Real.exp + (allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull)) ≤ + Real.exp (candidatePrimitiveFreezingCutoff s 1 (allocatedAffineCanonicalBudget s p0 pFull)) + cost_cutoff : ∀ cost : ℝ, cost ≤ p0 → Real.exp cost ≤ + Real.exp (candidatePrimitiveFreezingCutoff s 1 (allocatedAffineCanonicalBudget s p0 pFull)) + interpolation : ∀ cost : ℝ, cost ≤ p0 → Real.exp cost * (s + 2 : ℕ) ≤ + Real.exp (candidatePrimitiveFreezingCutoff s 1 (allocatedAffineCanonicalBudget s p0 pFull)) + +theorem allocatedAffineCanonicalBudget_exp_bounds (s : ℕ) {p0 pFull : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) : + AllocatedAffineCanonicalExpBounds s p0 pFull := by + have hb := allocatedAffineCanonicalBudget_bounds s hp0 hFull + obtain ⟨_, _, _, hm, hf, hq, hmq⟩ := + allocatedAffineResetNativeBudget_exp_bounds s hFull hb.map_nonnegative (q := p0) + have hcut := candidatePrimitiveFreezingCutoff_ge_input s 1 hb.nonnegative + refine ⟨hm, hf, hq, hmq, Real.exp_le_exp.mpr (hb.compare.trans hcut), ?_, ?_⟩ + · intro cost hcost + exact Real.exp_le_exp.mpr ((hcost.trans hb.input).trans hcut) + · intro cost hcost + have hs : ((s + 2 : ℕ) : ℝ) ≤ Real.exp (s + 2 : ℕ) := by + linarith [Real.add_one_le_exp ((s + 2 : ℕ) : ℝ)] + calc + Real.exp cost * (s + 2 : ℕ) ≤ Real.exp cost * Real.exp (s + 2 : ℕ) := + mul_le_mul_of_nonneg_left hs (Real.exp_pos _).le + _ = Real.exp (cost + (s + 2 : ℕ)) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr + ((add_le_add hcost le_rfl).trans (hb.interpolation_log.trans hcut)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open NilpotentLieFiltration + +theorem allocatedAffineCanonicalBudget_le_diagonal (s : ℕ) {p0 pFull B : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) (hp0B : p0 ≤ B) (hFullB : pFull ≤ B) : + allocatedAffineCanonicalBudget s p0 pFull ≤ allocatedAffineCanonicalBudget s B B := by + have hB : 0 ≤ B := hp0.trans hp0B + have hmap0 := (allocatedAffineResetMapBudget_bounds s hp0 hFull).nonnegative + have hnative0 := (allocatedAffineCanonicalBudget_bounds s hp0 hFull).native_nonnegative + have hpoint : ordinaryImagePointwiseBudget (s + 1) (s + 1) p0 ≤ + ordinaryImagePointwiseBudget (s + 1) (s + 1) B := by + unfold ordinaryImagePointwiseBudget pointwiseFastSectionInput + gcongr + have hmap : allocatedAffineResetMapBudget s p0 pFull ≤ + allocatedAffineResetMapBudget s B B := by + unfold allocatedAffineResetMapBudget allocatedAffineResetHeightLog allocatedAffineResetRightLog + gcongr + have hnative : allocatedAffineCanonicalNativeBudget s p0 pFull ≤ + allocatedAffineCanonicalNativeBudget s B B := by + unfold allocatedAffineCanonicalNativeBudget allocatedAffineResetNativeBudget affineResetNativeBudget + gcongr + have hreset : allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤ + allocatedAffineResetLogBudget s (allocatedAffineCanonicalNativeBudget s B B) := by + unfold allocatedAffineResetLogBudget markedNativeLiftInput fullMarkedNativeInput + pointwiseFastSectionInput + gcongr + have hcompare : allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s p0 pFull) ≤ + allocatedAffineResetCompareLog s (allocatedAffineCanonicalNativeBudget s B B) := by + unfold allocatedAffineResetCompareLog + gcongr + have hleft : allocatedAffineResetLeftLog s pFull ≤ allocatedAffineResetLeftLog s B := by + unfold allocatedAffineResetLeftLog + gcongr + unfold allocatedAffineCanonicalBudget + linarith + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open NilpotentLieFiltration + +private noncomputable def canonicalSectionPolynomial (s : ℕ) (P : Polynomial ℕ) : Polynomial ℕ := + 2 * (P + Polynomial.C (s + 3)) ^ (s + 3) + + ((P + Polynomial.C (s + 3)) ^ (s + 3)) ^ 2 + P + +noncomputable def allocatedAffineCanonicalBudgetPolynomial (s : ℕ) : Polynomial ℕ := + let X := Polynomial.X + let sectionPoly := canonicalSectionPolynomial (s + 1) X + let right := (X + Polynomial.C (allocatedEarlyAffineRightExponent (s + 1) 4)) ^ + allocatedEarlyAffineRightExponent (s + 1) 4 + let left := (X + Polynomial.C (allocatedEarlyAffineLeftExponent (s + 1) 4)) ^ + allocatedEarlyAffineLeftExponent (s + 1) 4 + let map := sectionPoly + sectionPoly + (X + 2) ^ 5 + (X + 4) ^ 12 + 1 + X + right + let native := X + map + X + left + (map + 2) ^ 4 + let nativeSection := canonicalSectionPolynomial (s + 1) native + let full := (nativeSection + Polynomial.C (allocatedAffineResetFactorExponent s)) ^ + allocatedAffineResetFactorExponent s + (native + 2) ^ 1 + nativeSection + let reset := ((full + 2) ^ 11 + full + Polynomial.C (allocatedAffineResetLiftExponent s)) ^ + allocatedAffineResetLiftExponent s + X + X + map + native + reset + + (native + Polynomial.C (allocatedAffineResetCompareExponent s)) ^ + allocatedAffineResetCompareExponent s + left + Polynomial.C (s + 2) + +theorem allocatedAffineCanonicalBudgetPolynomial_eval (s : ℕ) {B : ℝ} (hB : 0 ≤ B) : + (allocatedAffineCanonicalBudgetPolynomial s).eval₂ (Nat.castRingHom ℝ) B = + allocatedAffineCanonicalBudget s B B := by + simp only [allocatedAffineCanonicalBudgetPolynomial, canonicalSectionPolynomial, + allocatedAffineCanonicalBudget, allocatedAffineResetMapBudget, + allocatedAffineCanonicalNativeBudget, allocatedAffineResetNativeBudget, + affineResetNativeBudget, allocatedAffineResetRightLog, allocatedAffineResetLeftLog, + allocatedAffineResetCompareLog, allocatedAffineResetLogBudget, + ordinaryImagePointwiseBudget, allocatedAffineResetHeightLog, + markedNativeLiftInput, fullMarkedNativeInput, pointwiseFastSectionInput, + max_eq_left hB, Polynomial.eval₂_add, Polynomial.eval₂_mul, + Polynomial.eval₂_pow, Polynomial.eval₂_X, Polynomial.eval₂_C, + Polynomial.eval₂_ofNat, Polynomial.eval₂_one, Nat.coe_castRingHom, + Nat.cast_add, Nat.cast_one, Nat.cast_ofNat] + +noncomputable def allocatedAffineCanonicalBackendPolynomial (s : ℕ) : Polynomial ℕ := + let P := allocatedAffineCanonicalBudgetPolynomial s + P + 12 * (P + Polynomial.C (candidatePrimitivePhysicalBudgetExponent s 1)) ^ + candidatePrimitivePhysicalBudgetExponent s 1 + 32 + +theorem allocatedAffineCanonicalBackendPolynomial_eval (s : ℕ) {B : ℝ} (hB : 0 ≤ B) : + (allocatedAffineCanonicalBackendPolynomial s).eval₂ (Nat.castRingHom ℝ) B = + allocatedAffineCanonicalBudget s B B + + finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s B B) := by + simp only [allocatedAffineCanonicalBackendPolynomial, Polynomial.eval₂_add, + Polynomial.eval₂_mul, Polynomial.eval₂_pow, Polynomial.eval₂_C, + Polynomial.eval₂_ofNat, Nat.coe_castRingHom, allocatedAffineCanonicalBudgetPolynomial_eval s hB, + finiteFreezingRecursiveParameter] + ring + +private theorem power_le_recursiveParameter (C : ℕ) {p : ℝ} (hp : 0 ≤ p) : + (p + C) ^ C ≤ finiteFreezingRecursiveParameter C p := by + have hpow : 0 ≤ (p + C) ^ C := pow_nonneg (by positivity) _ + unfold finiteFreezingRecursiveParameter + linarith only [hpow] + +theorem allocatedAffineCanonical_cutoffCost_le_recursive (s : ℕ) {p0 pFull : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) : + candidateSideCutoffCost + (Real.exp (candidatePrimitiveFreezingCutoff s 1 + (allocatedAffineCanonicalBudget s p0 pFull))) ≤ + finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s p0 pFull) := by + have hp := (allocatedAffineCanonicalBudget_bounds s hp0 hFull).nonnegative + exact ((candidatePrimitiveFreezingCutoff_integer_cost s 1 hp).trans + (candidatePrimitiveFreezingCutoff_add_two_le_budget s 1 hp)).trans + (power_le_recursiveParameter _ hp) + +structure AllocatedAffineCanonicalBackendBounds (s : ℕ) (p0 pFull upper : ℝ) : Prop where + canonical : allocatedAffineCanonicalBudget s p0 pFull ≤ upper + recursive : finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s p0 pFull) ≤ upper + cutoff : candidatePrimitiveFreezingCutoff s 1 + (allocatedAffineCanonicalBudget s p0 pFull) ≤ upper + cutoff_cost : candidateSideCutoffCost + (Real.exp (candidatePrimitiveFreezingCutoff s 1 + (allocatedAffineCanonicalBudget s p0 pFull))) ≤ upper + +theorem allocatedAffineCanonicalBackendPolynomial_bounds (s : ℕ) {p0 pFull B : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) (hp0B : p0 ≤ B) (hFullB : pFull ≤ B) : + AllocatedAffineCanonicalBackendBounds s p0 pFull + ((allocatedAffineCanonicalBackendPolynomial s).eval₂ (Nat.castRingHom ℝ) B) := by + have hB := hp0.trans hp0B + have hp := (allocatedAffineCanonicalBudget_bounds s hp0 hFull).nonnegative + have hd := (allocatedAffineCanonicalBudget_bounds s hB hB).nonnegative + have hdiag := allocatedAffineCanonicalBudget_le_diagonal s hp0 hFull hp0B hFullB + have hrec : + finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s p0 pFull) ≤ + finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s B B) := by + unfold finiteFreezingRecursiveParameter + gcongr + have hrec0 : 0 ≤ + finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s B B) := by + unfold finiteFreezingRecursiveParameter + positivity + have hrecUpper : + finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s p0 pFull) ≤ + (allocatedAffineCanonicalBackendPolynomial s).eval₂ (Nat.castRingHom ℝ) B := by + rw [allocatedAffineCanonicalBackendPolynomial_eval s hB] + linarith only [hrec, hd] + constructor + · rw [allocatedAffineCanonicalBackendPolynomial_eval s hB] + linarith only [hdiag, hrec0] + · exact hrecUpper + · exact ((candidatePrimitiveFreezingCutoff_le_budget s 1 hp).trans + (power_le_recursiveParameter _ hp)).trans hrecUpper + · exact (allocatedAffineCanonical_cutoffCost_le_recursive s hp0 hFull).trans hrecUpper + +theorem exists_allocatedAffineCanonicalBackend_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (B p0 pFull : ℝ), + 0 ≤ p0 → 0 ≤ pFull → p0 ≤ B → pFull ≤ B → + AllocatedAffineCanonicalBackendBounds s p0 pFull ((B + C) ^ C) := by + obtain ⟨C, hC, hbound⟩ := + exists_natPolynomial_eval_budget (allocatedAffineCanonicalBackendPolynomial s) + refine ⟨C, hC, ?_⟩ + intro B p0 pFull hp0 hFull hp0B hFullB + have hb := allocatedAffineCanonicalBackendPolynomial_bounds s hp0 hFull hp0B hFullB + have hpoly := hbound B (hp0.trans hp0B) + exact ⟨hb.canonical.trans hpoly, hb.recursive.trans hpoly, + hb.cutoff.trans hpoly, hb.cutoff_cost.trans hpoly⟩ + +noncomputable def allocatedAffineCanonicalBackendExponent (s : ℕ) : ℕ := + (exists_allocatedAffineCanonicalBackend_budget s).choose + +theorem allocatedAffineCanonicalBackendExponent_ge_two (s : ℕ) : + 2 ≤ allocatedAffineCanonicalBackendExponent s := + (exists_allocatedAffineCanonicalBackend_budget s).choose_spec.1 + +theorem allocatedAffineCanonicalBackend_bounds (s : ℕ) {B p0 pFull : ℝ} + (hp0 : 0 ≤ p0) (hFull : 0 ≤ pFull) (hp0B : p0 ≤ B) (hFullB : pFull ≤ B) : + AllocatedAffineCanonicalBackendBounds s p0 pFull + ((B + allocatedAffineCanonicalBackendExponent s) ^ + allocatedAffineCanonicalBackendExponent s) := + (exists_allocatedAffineCanonicalBackend_budget s).choose_spec.2 B p0 pFull + hp0 hFull hp0B hFullB + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineFiniteModelL2.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineFiniteModelL2.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ac2fe01d6d07bce7e3b6c2da97beb7d8c7a0853 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineFiniteModelL2.lean @@ -0,0 +1,832 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineWholeProfileComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +local notation "jets" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "input" => PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) +local notation "output" => (Σ a : {a // ¬grid a}, jets (Sigma.fst (Subtype.val a))) + +theorem allocatedRowSlicedIdeal_measurable (hR : ∀ j, 0 < R j) + (ρ : ℝ≥0) (hρ : 0 < ρ) (center width : input → ℝ) : + Measurable (allocatedRowSlicedIdeal B U b S rowSets ρ center width) := by + apply diagonalImageDensity_measurable (fun q : output => R q.1.val.1) + (fun q : output => (hR q.1.val.1).ne') + exact (activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => (Subtype.val : jets a.val.1 → Finset α)) + ρ hρ center width).2.1.continuous.measurable + +theorem allocatedRowSlicedIdeal_coordinate_support (hR : ∀ j, 0 < R j) + (ρ : ℝ≥0) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (center width : input → ℝ) (hw : ∀ i, |center i| + |width i| ≤ 1) + (v : output → ℝ) (hv : allocatedRowSlicedIdeal B U b S rowSets ρ center width v ≠ 0) + (a : {a // ¬grid a}) (t : jets a.val.1) : + |v ⟨a, t⟩| ≤ (partitionedIdealRadius α m + 1) * R a.val.1 := by + have hn : ‖fun q : output => v q / R q.1.val.1‖ ≤ partitionedIdealRadius α m + 1 := by + by_contra hh + apply hv + unfold allocatedRowSlicedIdeal diagonalImageDensity + rw [activeAveragedSlicedProfileIdeal_zero_outside (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => (Subtype.val : jets a.val.1 → Finset α)) + (fun a => Nat.succ_le_of_lt a.1.isLt) ρ hρ hρ1 center width hw _ (lt_of_not_ge hh), mul_zero] + have hc := (norm_le_pi_norm (fun q : output => v q / R q.1.val.1) ⟨a, t⟩).trans hn + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hR a.val.1)] at hc + exact (div_le_iff₀ (hR a.val.1)).mp hc + +theorem allocatedRowSlicedIdeal_normalized_cap (hR : ∀ j, 0 < R j) + (ρ : ℝ≥0) (hρ : 0 < ρ) (center width : input → ℝ) + (z : AllocatedLongJetRows B U b S jets) : + ‖((∏ q : output, R q.1.val.1 : ℝ) : ℂ) * + (allocatedRowSlicedIdeal B U b S rowSets ρ center width + (allocatedLongJetRealCoordinates B U b S z) : ℂ)‖ ≤ + (ρ⁻¹ ^ Fintype.card output : ℝ≥0) := by + rw [← Complex.ofReal_mul, allocatedRowSlicedIdealCoordinates_density B U b S rowSets hR ρ center width] + have hb := (activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => (Subtype.val : jets a.val.1 → Finset α)) ρ hρ center width).1 + (booleanSiteJets (fun a => (Subtype.val : jets a.val.1 → Finset α)) + (fun s a => allocatedRowIdealCoordinates B U b S rowSets z s a.val)) + simpa only [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hb.1] using hb.2 + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] (r : ℝ≥0) (hr : 0 < r) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) + +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) +variable (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) +variable (hradius : ∀ j, (rowSets j).card * T j ≤ (r : ℝ)) +variable (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)) ≤ 1 / 4) + +include hT hsource hradius hC hchart hbudget in + +theorem allocatedAffineRowIdeal_cutoff_fixes + (hσ1 : ∀ j, σ j ≤ 1) (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (ρ : ℝ≥0) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) → ℝ) + (hw : ∀ i, |center i| + |width i| ≤ 1) + (x : G → IntegerScalarCubeBox α S.value) + (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) + (q : ℕ) (y : EuclideanJetLayers U rowTypes) : + allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr y * + (allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d y₀ q + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y : ℂ) = + (allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d y₀ q + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y : ℂ) := by + apply allocatedProductSiteCutoff_fixes_source B U b S rowSets o hb bW d r hr hR hσ T hT hsource hradius C hC hchart hbudget hσ1 x y₀ q + intro v hv a₀ t + exact (allocatedRowSlicedIdeal_coordinate_support B U b S rowSets hR ρ hρ hρ1 center width hw v hv a₀ t).trans (mul_le_mul_of_nonneg_right (hTideal _) (hR _).le) + +include hT hsource hradius hC hchart hbudget in + +theorem allocatedAffineRowIdeal_cutoff_fixes_mean + (hσ1 : ∀ j, σ j ≤ 1) (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (ρ : ℝ≥0) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) → ℝ) + (hw : ∀ i, |center i| + |width i| ≤ 1) + (x : G → IntegerScalarCubeBox α S.value) + {Ω : Type*} [Fintype Ω] (weights : FiniteProbabilityWeights Ω) + (tuples : Ω → PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) + (q : ℕ) (y : EuclideanJetLayers U rowTypes) : + allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr y * + ((weights).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d (tuples u) q + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y) : ℂ) = + ((weights).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d (tuples u) q + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y) : ℂ) := by + simp only [← weights.complexMean_ofReal] + rw [← weights.complexMean_mul_left] + apply congrArg weights.complexMean + funext u + exact allocatedAffineRowIdeal_cutoff_fixes B U b S rowSets o hb bW d r hr hR hσ T hT hsource hradius C hC hchart hbudget + hσ1 hTideal ρ hρ hρ1 center width hw x (tuples u) q y + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "mask" => allocatedClippedPrefactorSiteMask B U b S rowSets x y₀ q d period +local notation "residue" => (fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hperiod : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable {M : ℝ} (hM : 1 ≤ M) +variable (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +include hperiod hM hm hR hC hchart hbudget in + +theorem allocatedAffineProductPrefactor_cap + (ρ : ℝ≥0) (hρ : 0 < ρ) + (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) → ℝ) + (y : EuclideanJetLayers U rowTypes) : + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y‖ ≤ + ‖inverseNormalizer‖ * (M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period) * + (ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0) := by + let aa : Empty → ℂ := fun i => i.elim + let ff : Empty → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ := fun i => i.elim + have herr (v : AllocatedLongJetRows B U b S rowTypes) : + ‖((∏ q : (Σ a : {a // ¬grid a}, rowTypes a.val.1), R q.1.val.1 : ℝ) : ℂ) * + (allocatedRowSlicedIdeal B U b S rowSets ρ center width + (allocatedLongJetRealCoordinates B U b S v) : ℂ) - + ∑ k, aa k * ∏ s, ff k s (allocatedRowIdealCoordinates B U b S rowSets v s)‖ ≤ + (ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0) := by + simp only [Finset.univ_eq_empty, Finset.sum_empty, sub_zero] + exact allocatedRowSlicedIdeal_normalized_cap B U b S rowSets hR ρ hρ center width _ + have he := allocatedProductChartDensityApproximation_error B U b S rowSets x y₀ q d period r hr hb o bW + hperiod hM hm hR C hC hchart hbudget aa ff + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) + (NNReal.coe_nonneg _) herr y + simpa only [allocatedProductChartIdealApproximation, Finset.univ_eq_empty, Finset.sum_empty, + Finset.sum_const_zero, sub_zero] using he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset α)) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset α)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset α) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (F : EuclideanJetLayers U (fun j => ↥(rowSets j)) → ℂ) + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) +local notation "actual" => allocatedProgressionCoveredExpectation B U basis hR hσ S rows x Q hb o bW d (fun p => F (Prod.snd p)) + H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineFiniteModel_comparison + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) (hH : ∀ j : Tuple, 2 ≤ H j) + (hδ : 0 < δ) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hsize : ∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j : Tuple, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α jetRows P e) ≤ S.value) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ (u : GridTuples) j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ∧ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ≤ Cmask) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (hF : Measurable F) (hFbound : ∀ p, ‖F p‖ ≤ 1) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let _outputResidue := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ (period : ℕ) [NeZero period] (r : ℝ≥0) (hr : 0 < r) + (u₀ : GridTuples) {Kmodel : Type*} [Fintype Kmodel] + (am : Kmodel → ℂ) (fm : Kmodel → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ) + {Lm : ℝ≥0} (_hLm : ∀ k t, LipschitzWith Lm (fm k t)) (_hfm : ∀ k t z, ‖fm k t z‖ ≤ 1) + (eg : {a // grid a} → ScalarSiteExpansion (Finset α)) + {Nt V Cc Hs : {a // grid a} → ℝ} {Lg : ℝ≥0} + (_heg : ∀ a, (eg a).Bounds (Nt a) (V a) (Cc a) Lg (Hs a)) {εmodel : ℝ}, + (∀ y : EuclideanJetLayers U selectedRows, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ) - + (allocatedProductChartIdealApproximation B U basis S rowSets x (principalAxisJoin grid u₀ v₀) + modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y)‖ ≤ εmodel) → + ‖actual - ∫ y, (allocatedProductChartIdealApproximation B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y) * F y + ∂Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j))‖ ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α selectedRows P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, selectedRows a.1) * + (Fintype.card {a // ¬grid a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α selectedRows P) + εcoef)^ + Fintype.card {a // ¬grid a}) + + allocatedAffineSourceReferenceError B U basis S α selectedRows (ρ grid) P η (fun _ => modulus) H ε mesh Cmask + εmodel + := by + intro center width ideal outputResidue period hperiodNZ r hr u₀ Kmodel hKmodel am fm Lm hLm hfm eg Nt V Cc Hs Lg heg εmodel happrox + have hc := allocatedAffineWholeProfile_comparison B U basis hR hσ S rows x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d F H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν + ρ t htone hs hρ hρ1 hσsmall hstep hH hδ hdense hm hsize hsmall hε hmesh + selection hgood hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh hCmask hmask + T hT hsource C hC hchart hbudget hF hFbound + have hs' := allocatedWholeMaskedCoveredProfile_mean_measurable B U basis hR hσ S x rows hb o bW d + gridLaw (fun u => principalAxisJoin grid u v₀) modulus ideal + (allocatedRowSlicedIdeal_measurable B U basis S rowSets hR (ρ grid) hρ center width) + have ht := allocatedFiniteSourceModel_test_error B U basis S rowSets x (principalAxisJoin grid u₀ v₀) + modulus d period r hr hb o bW (Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j))) + am fm hLm hfm eg heg _ hs' happrox F hF hFbound + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hc ht.2) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset α)) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset α)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset α) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +local notation "ξ" => Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j)) +local notation "density" => allocatedCoefficientDensity B U basis hb o hR hσ S +local notation "cover" => quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineFiniteModel_l1 + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) ξ) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure ξ (g y)) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) (hH : ∀ j : Tuple, 2 ≤ H j) + (hδ : 0 < δ) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hsize : ∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j : Tuple, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α jetRows P e) ≤ S.value) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ (u : GridTuples) j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ∧ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ≤ Cmask) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let _outputResidue := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ (period : ℕ) [NeZero period] (r : ℝ≥0) (hr : 0 < r) + (u₀ : GridTuples) {Kmodel : Type*} [Fintype Kmodel] + (am : Kmodel → ℂ) (fm : Kmodel → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ) + {Lm : ℝ≥0} (_hLm : ∀ k t, LipschitzWith Lm (fm k t)) (_hfm : ∀ k t z, ‖fm k t z‖ ≤ 1) + (eg : {a // grid a} → ScalarSiteExpansion (Finset α)) + {Nt V Cc Hs : {a // grid a} → ℝ} {Lg : ℝ≥0} + (_heg : ∀ a, (eg a).Bounds (Nt a) (V a) (Cc a) Lg (Hs a)) {εmodel : ℝ}, + (∀ y : EuclideanJetLayers U selectedRows, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ) - + (allocatedProductChartIdealApproximation B U basis S rowSets x (principalAxisJoin grid u₀ v₀) + modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y)‖ ≤ εmodel) → + (∫ y, ‖((wholeLaw).mean (fun v => g v y) : ℂ) - + (allocatedProductChartIdealApproximation B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y)‖ ∂ξ) ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α selectedRows P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, selectedRows a.1) * + (Fintype.card {a // ¬grid a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α selectedRows P) + εcoef)^ + Fintype.card {a // ¬grid a}) + + allocatedAffineSourceReferenceError B U basis S α selectedRows (ρ grid) P η (fun _ => modulus) H ε mesh Cmask + εmodel + := by + intro center width ideal outputResidue period hperiodNZ r hr u₀ Kmodel hKmodel am fm Lm hLm hfm eg Nt V Cc Hs Lg heg εmodel happrox + let model := fun y => allocatedProductChartIdealApproximation B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y + have hmodelm : Measurable model := + (allocatedProductChartIdealApproximation_measurable B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW am fm hLm hfm).mul + (allocatedFullGridChartModel_measurable B U basis S rowSets d hb o bW eg) + have hmodeli : Integrable model ξ := allocatedFiniteSourceModel_integrable B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW ξ am fm hLm hfm eg heg + have hmeanm : Measurable (fun y => ((wholeLaw).mean (fun v => g v y) : ℂ)) := + (Finset.measurable_sum Finset.univ (fun v _ => (hgm v).const_mul _)).complex_ofReal + have hmeani : Integrable (fun y => ((wholeLaw).mean (fun v => g v y) : ℂ)) ξ := + (integrable_finsetSum Finset.univ (fun v _ => (hgi v).const_mul _)).ofReal + apply complex_model_l1_le_of_bounded_tests ξ _ model hmeanm hmodelm hmeani hmodeli + intro F hF hFbound + have hc := allocatedAffineFiniteModel_comparison B U basis hR hσ S rowSets x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d F H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν + ρ t htone hs hρ hρ1 hσsmall hstep hH hδ hdense hm hsize hsmall hε hmesh + selection hgood hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh hCmask hmask + T hT hsource C hC hchart hbudget hF hFbound + period r hr u₀ am fm hLm hfm eg heg happrox + have hsmallDensity (j) : C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4 := by + have hT1 : 1 ≤ T j := (le_add_of_nonneg_left (partitionedIdealRadius_nonneg α m)).trans (hT j) + have hRle : R j ≤ T j * R j := by simpa only [one_mul] using mul_le_mul_of_nonneg_right hT1 (hR j).le + calc + _ = C j * (((Fintype.card (I j) : ℝ) + 1) * R j) := mul_assoc _ _ _ + _ ≤ C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hRle + (add_nonneg (Nat.cast_nonneg _) zero_le_one)) (hC j) + _ ≤ _ := hbudget j + have hdeck := allocatedCoefficientDeckSample_density_law B U basis hR hσ S Q hb o bW d μ ν + (fun j => (hσsmall j).trans htone) C hC hchart hsmallDensity + have hid := allocatedProgressionCoveredExpectation_density B U basis hR hσ S rows x Q hb o bW d + H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell μ ν hdeck g hgm hg0 hgi hglaw F hF hFbound + rw [hid] at hc + exact hc + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset α)) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset α)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset α) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +local notation "ξ" => Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j)) +local notation "density" => allocatedCoefficientDensity B U basis hb o hR hσ S +local notation "cover" => quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineFiniteModel_l2 + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) ξ) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure ξ (g y)) + (densityCap : ℝ≥0) (hgcap : ∀ y z, |g y z| ≤ densityCap) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) (hH : ∀ j : Tuple, 2 ≤ H j) + (hδ : 0 < δ) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hsize : ∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j : Tuple, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α jetRows P e) ≤ S.value) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ (u : GridTuples) j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ∧ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ≤ Cmask) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let _outputResidue := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ (period : ℕ) [NeZero period] (r : ℝ≥0) (hr : 0 < r) + (u₀ : GridTuples) {Kmodel : Type*} [Fintype Kmodel] + (am : Kmodel → ℂ) (fm : Kmodel → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ) + {Lm : ℝ≥0} (_hLm : ∀ k t, LipschitzWith Lm (fm k t)) (_hfm : ∀ k t z, ‖fm k t z‖ ≤ 1) + (eg : {a // grid a} → ScalarSiteExpansion (Finset α)) + {Nt V Cc Hs : {a // grid a} → ℝ} {Lg : ℝ≥0} + (_heg : ∀ a, (eg a).Bounds (Nt a) (V a) (Cc a) Lg (Hs a)) {εmodel : ℝ} + (profileCap : ℝ≥0) + (_hprofileCap : ∀ u y, |allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y| ≤ profileCap), + (∀ y : EuclideanJetLayers U selectedRows, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ) - + (allocatedProductChartIdealApproximation B U basis S rowSets x (principalAxisJoin grid u₀ v₀) + modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y)‖ ≤ εmodel) → εmodel ≤ 1 → + (∫ y, ‖((wholeLaw).mean (fun v => g v y) : ℂ) - + (allocatedProductChartIdealApproximation B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y)‖ ^ 2 ∂ξ) ≤ + ((densityCap + (profileCap + 1) : ℝ≥0) : ℝ) * + ((2 * Real.exp (allocatedJetSupportLog (G := G) B α selectedRows P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, selectedRows a.1) * + (Fintype.card {a // ¬grid a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α selectedRows P) + εcoef)^ + Fintype.card {a // ¬grid a}) + + allocatedAffineSourceReferenceError B U basis S α selectedRows (ρ grid) P η (fun _ => modulus) H ε mesh Cmask + εmodel) + := by + intro center width ideal outputResidue period hperiodNZ r hr u₀ Kmodel hKmodel am fm Lm hLm hfm eg Nt V Cc Hs Lg heg εmodel profileCap hprofileCap happrox hεmodel + let model := fun y => allocatedProductChartIdealApproximation B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW am fm y * + allocatedFullGridChartModel B U basis S rowSets d hb o bW eg y + have hmodelm : Measurable model := + (allocatedProductChartIdealApproximation_measurable B U basis S rowSets x + (principalAxisJoin grid u₀ v₀) modulus d period r hr hb o bW am fm hLm hfm).mul + (allocatedFullGridChartModel_measurable B U basis S rowSets d hb o bW eg) + have hmeanm : Measurable (fun y => ((wholeLaw).mean (fun v => g v y) : ℂ)) := + (Finset.measurable_sum Finset.univ (fun v _ => (hgm v).const_mul _)).complex_ofReal + have hmeanb (y) : ‖((wholeLaw).mean (fun v => g v y) : ℂ)‖ ≤ densityCap := by + rw [← FiniteProbabilityWeights.complexMean_ofReal] + have hb (v) : ‖(g v y : ℂ)‖ ≤ densityCap := by + simpa only [Complex.norm_real, Real.norm_eq_abs] using hgcap v y + exact ((wholeLaw).norm_complexMean_le_mean_norm _).trans + (((wholeLaw).mean_mono hb).trans_eq ((wholeLaw).mean_const _)) + have hmodelb (y) : ‖model y‖ ≤ (profileCap + 1 : ℝ≥0) := by + simpa only [NNReal.coe_add, NNReal.coe_one] using + finiteMeanModel_norm_le_of_uniform_approximation (gridLaw) + (fun u y => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) + model hprofileCap happrox hεmodel y + have hL1 := allocatedAffineFiniteModel_l1 B U basis hR hσ S rowSets x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν μ + g hgm hg0 hgi hglaw ρ t htone hs hρ hρ1 hσsmall hstep hH hδ hdense hm hsize hsmall hε hmesh + selection hgood hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh hCmask hmask + T hT hsource C hC hchart hbudget period r hr u₀ am fm hLm hfm eg heg happrox + exact complex_model_l2_le_of_l1 ξ _ model hmeanm hmodelm densityCap (profileCap + 1) + hmeanb hmodelb hL1 + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineFixedPathRationalReference.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineFixedPathRationalReference.lean new file mode 100644 index 0000000000000000000000000000000000000000..25ed647ea574651d344c177e91f011a913811c0e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineFixedPathRationalReference.lean @@ -0,0 +1,452 @@ +import OAI.Combinatorics.Progressions.Sampling.AllocatedForecastShortRawDependence +import OAI.Combinatorics.Progressions.Sampling.ForecastNativeJointTestBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {L V Short Out : Type*} [Fintype L] [Fintype V] + [Fintype Out] [DecidableEq Out] + +local instance arbitraryStepForecastModulusNeZero (p e : L → ℕ) [∀ l, NeZero (p l)] : + NeZero (∏ l, p l ^ e l) := + ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (p l)))⟩ + +theorem rationalInactivePolynomialForecast_arbitraryStepCRT_tsum_marginal + {I Z : Type*} [Fintype I] + (inactive : FiniteProbabilityWeights I) (gridPoint : I → Z) + (p e : L → ℕ) [∀ l, NeZero (p l)] (step : ℕ) + (hp : ∀ l, (p l).Prime) (hstep : step ≠ 0) + (hcoprime : Pairwise (fun l k => (p l ^ e l).Coprime (p k ^ e k))) + (cLong : V → ℤ) + (poly : Out → MvPolynomial (V ⊕ Short) ℤ) (inactiveCoord : I → Short → ℤ) + {q : ℕ} [NeZero q] (hdiv : q ∣ ∏ l, p l ^ e l) + {gridVolume : ℝ} (hV : gridVolume ≠ 0) (test : Z → (Out → ZMod q) → ℂ) : + (∑' z, 𝔼 b : Out → ZMod (∏ l, p l ^ e l), + ((rationalInactiveForecast inactive + (fun _ => crtPolynomialInputLaw p e (fun l => padicValNat (p l) step) hcoprime + (fun l v => (cLong v : ZMod (p l ^ e l)))) gridPoint + (fun i => integerLongPolynomialOutput poly (inactiveCoord i) (∏ l, p l ^ e l)) + (∏ l, p l ^ e l) gridVolume z b / gridVolume : ℝ) : ℂ) * + test z (fun j => ZMod.castHom hdiv (ZMod q) (b j))) = + inactive.complexMean (fun i => + (FiniteProbabilityWeights.uniform (V → ZMod q)).complexMean (fun r => + test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim (fun v => (cLong v : ZMod q) + (step : ZMod q) * r v) + (fun a => (inactiveCoord i a : ZMod q))) (poly j)))) := by + rw [rationalInactiveForecast_divisor_tsum_test _ _ _ _ hdiv hV] + apply congrArg inactive.complexMean + funext i + simp_rw [integerLongPolynomialOutput_reduce poly (inactiveCoord i) hdiv] + exact crtPolynomialInputLaw_arbitrary_step_divisor_complexMean p e step hp hstep + hcoprime cLong hdiv + (fun r => test (gridPoint i) (fun j => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim r (fun a => (inactiveCoord i a : ZMod q))) (poly j))) + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (start : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) +variable (hinside : ∀ j (t : Fin (H j)), + 0 ≤ start j + (step j : ℤ) * t.val ∧ start j + (step j : ℤ) * t.val < (allocatedPrincipalSides B U basis S) j) +variable (hH : ∀ j, 0 < H j) + +noncomputable def allocatedInactiveAffineIntervalLaw + (H step : (PrincipalTupleIndex B (layerSamplerDegree I n)) → ℕ) (start : (PrincipalTupleIndex B (layerSamplerDegree I n)) → ℤ) + (hinside : ∀ j (t : Fin (H j)), + 0 ≤ start j + (step j : ℤ) * t.val ∧ start j + (step j : ℤ) * t.val < (allocatedPrincipalSides B U basis S) j) + (hH : ∀ j, 0 < H j) : FiniteProbabilityWeights (PrincipalAxisTuples (α := Empty) (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) := + principalAffineIntervalAxisLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside hH (allocatedShortAxis (I := I) U basis S.value) + +include hinside hH in +theorem allocatedInactiveAffineIntervalLaw_complexMean (f : (PrincipalAxisTuples (α := Empty) (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) → ℂ) : + (allocatedInactiveAffineIntervalLaw B U basis S H step start hinside hH).complexMean f = + 𝔼 t : (∀ j, Fin (H j)), f (principalAxisRestrict (allocatedShortAxis (I := I) U basis S.value) + (principalAffineIntervalPoint B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside t)) := + principalAffineIntervalAxisLaw_complexMean B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside hH (allocatedShortAxis (I := I) U basis S.value) f + +include hinside hH in +theorem allocatedInactiveAffineIntervalLaw_total : + ∑ u, (allocatedInactiveAffineIntervalLaw B U basis S H step start hinside hH).weight u = 1 := + (allocatedInactiveAffineIntervalLaw B U basis S H step start hinside hH).total + +variable {A : Type*} (selected : A → Σ j : Fin m, Fin (n j)) +variable (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) +variable (x : G → IntegerScalarCubeBox Empty S.value) + +include hinside hH in + +theorem allocatedInactiveAffineIntervalLaw_fixed_grid_mean + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (hshort : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (f : (A → ((Finset.univ : Finset (Finset Empty)) : Type) → ℤ) → ℂ) : + (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside hH).complexMean (fun y => f (forecastInactiveFixedOutput B U basis S selected (allocatedOriginalSampleInactiveCoefficients B selected sample) x y)) = + (allocatedInactiveAffineIntervalLaw B U basis S H step start hinside hH).complexMean + (fun u => f (forecastInactiveShortGrid B U basis S selected (allocatedOriginalSampleInactiveCoefficients B selected sample) u)) := by + rw [allocatedInactiveAffineIntervalLaw, principalAffineIntervalAxisLaw, + FiniteProbabilityWeights.complexMean_finitePushforward] + apply congrArg (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside hH).complexMean + funext y + rw [forecastInactiveFixedOutput_eq_shortGrid B U basis S hR hσ selected hshort (allocatedOriginalSampleInactiveCoefficients B selected sample) + (allocatedOriginalSampleInactiveCoefficients_supported B selected U basis hR hσ S sample hs) x y] + +include hinside hH in + +theorem allocatedInactiveAffineIntervalLaw_fixed_grid_law + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (hshort : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) : + (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside hH).toPMF.map (forecastInactiveFixedOutput B U basis S selected (allocatedOriginalSampleInactiveCoefficients B selected sample) x) = + (allocatedInactiveAffineIntervalLaw B U basis S H step start hinside hH).toPMF.map + (forecastInactiveShortGrid B U basis S selected (allocatedOriginalSampleInactiveCoefficients B selected sample)) := by + ext z + apply ENNReal.ofReal_toReal (PMF.apply_ne_top _ _) |>.symm.trans + apply Eq.trans _ (ENNReal.ofReal_toReal (PMF.apply_ne_top _ _)) + congr 1 + rw [FiniteProbabilityWeights.toPMF_map_toReal, FiniteProbabilityWeights.toPMF_map_toReal] + have he := congrArg Complex.re + (allocatedInactiveAffineIntervalLaw_fixed_grid_mean B U basis S H step start hinside hH + selected sample x hR hσ hshort hs (fun w => if w = z then 1 else 0)) + simpa only [FiniteProbabilityWeights.complexMean_re, apply_ite, Complex.one_re, Complex.zero_re] using he + +variable {Ω Out : Type*} [Fintype Ω] [Fintype Out] [DecidableEq Out] +variable (active : (PrincipalIntegerTuples B (layerSamplerDegree I n) Empty (allocatedPrincipalSides B U basis S)) → FiniteProbabilityWeights Ω) (Y : (PrincipalIntegerTuples B (layerSamplerDegree I n) Empty (allocatedPrincipalSides B U basis S)) → Ω → Out → ℤ) + +noncomputable def allocatedAffineIntervalInactiveForecast + (H step : (PrincipalTupleIndex B (layerSamplerDegree I n)) → ℕ) (start : (PrincipalTupleIndex B (layerSamplerDegree I n)) → ℤ) + (hinside : ∀ j (t : Fin (H j)), + 0 ≤ start j + (step j : ℤ) * t.val ∧ start j + (step j : ℤ) * t.val < (allocatedPrincipalSides B U basis S) j) + (hH : ∀ j, 0 < H j) (N : ℕ) [NeZero N] (volume : ℝ) + (grid : (A → ((Finset.univ : Finset (Finset Empty)) : Type) → ℤ)) (out : Out → ZMod N) : ℝ := + rationalInactiveForecast (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside hH) active (forecastInactiveFixedOutput B U basis S selected (allocatedOriginalSampleInactiveCoefficients B selected sample) x) + Y N volume grid out + +include hinside hH in +theorem allocatedAffineIntervalInactiveForecast_mass_one + (N : ℕ) [NeZero N] {volume : ℝ} (hV : volume ≠ 0) : + (∑' grid, 𝔼 out : Out → ZMod N, + ((allocatedAffineIntervalInactiveForecast B U basis S selected sample x active Y + H step start hinside hH N volume grid out / volume : ℝ) : ℂ)) = 1 := + rationalInactiveForecast_complexTsumMass_one + (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H step start hinside hH) active + (forecastInactiveFixedOutput B U basis S selected (allocatedOriginalSampleInactiveCoefficients B selected sample) x) Y N hV + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] +variable {I E : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "FullInput" => PrincipalTupleIndex B degree +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "AI" => PrincipalTupleIndex (fun a : Active => B (Subtype.val a)) + (fun a : Active => degree (Subtype.val a)) +local notation "Long" => LayerSamplerLongVariables short G B +local notation "Out" => Sigma (AllocatedCongruenceRankOutput X E short) +local notation "sides" => allocatedPrincipalSides B U basis S + +variable (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) +variable (deck : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) +variable (projection : ∀ j, AllocatedDegreeActiveAxis short j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + +noncomputable def allocatedJointResidueOutput + (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (deck : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis short j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (q : ℕ) (rG : G → ZMod q) + (r : FullInput → Option Empty → ZMod q) : Out → ZMod q := + fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim (Sum.elim rG (fun j : AI => r ⟨j.1.val, j.2⟩ none)) + (fun k => r k.1 k.2)) (allocatedForecastPolynomial short base noise deck projection o) + +theorem allocatedJointResidueOutput_join + (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (deck : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis short j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (q : ℕ) (rG : G → ZMod q) + (u : PrincipalAxisTuples (α := Empty) short sides) (ar : AI → ZMod q) : + allocatedJointResidueOutput B U basis S base noise deck projection q rG + (allocatedPrincipalResidueJoin B U basis S q u ar) = + fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim (Sum.elim rG ar) + (fun k => (allocatedShortPrincipalRaw B U basis S u k : ZMod q))) + (allocatedForecastPolynomial short base noise deck projection o) := by + funext o + have hlong : (fun j : AI => allocatedPrincipalResidueJoin B U basis S q u ar + ⟨j.1.val, j.2⟩ none) = ar := by + funext j + simp only [allocatedPrincipalResidueJoin, principalAxisResidueJoin, j.1.property, dite_false] + unfold allocatedJointResidueOutput + rw [hlong] + apply allocatedForecastPolynomial_eval₂_raw_congr + intro j hj + simp only [allocatedPrincipalResidueJoin, principalAxisResidueJoin, + allocatedShortPrincipalRaw, hj, dite_true] + +theorem allocatedJointResidueOutput_actual + (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (deck : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis short j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (q : ℕ) + (x : G → IntegerScalarCubeBox Empty S.value) + (v : PrincipalIntegerTuples B degree Empty sides) : + allocatedJointResidueOutput B U basis S base noise deck projection q + (fun g => ((x g none : ℤ) : ZMod q)) (principalResidueLabel q v) = + fun o => ((MvPolynomial.eval (Sum.elim (fun g => (x g none : ℤ)) + (fun j => (v j none : ℤ))) + (allocatedUnconditionedCongruenceIntegerPolynomial short o.1 base noise deck + (projection o.1) o.2) : ℤ) : ZMod q) := by + funext o + rw [integerPolynomial_eval_residue] + unfold allocatedJointResidueOutput allocatedForecastPolynomial allocatedSeparatedCongruencePolynomial + rw [MvPolynomial.eval₂_rename] + congr 1 + funext k + cases k with + | inl g => rfl + | inr j => + by_cases hj : short j.1 + · simp only [Function.comp_apply, samplerSeparatedVariable_inactive short degree _ _ _ hj, + Sum.elim_inr, principalResidueLabel] + rfl + · simp only [Function.comp_apply, samplerSeparatedVariable_active short degree _ _ _ hj, + Sum.elim_inl, Sum.elim_inr, principalResidueLabel] + rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +private theorem affineReference_uniform_sum_flip + {G A R : Type*} [Fintype G] [Fintype A] [Fintype R] [Nonempty R] + [DecidableEq G] [DecidableEq A] [DecidableEq (G ⊕ A)] + (f : (G ⊕ A → R) → ℂ) : + (FiniteProbabilityWeights.uniform (A → R)).complexMean (fun a => + (FiniteProbabilityWeights.uniform (G → R)).complexMean (fun g => f (Sum.elim g a))) = + (FiniteProbabilityWeights.uniform (G ⊕ A → R)).complexMean f := by + simp only [FiniteProbabilityWeights.uniform_complexMean] + calc + _ = 𝔼 ga : (G → R) × (A → R), f (Sum.elim ga.1 ga.2) := by + rw [Finset.expect_comm] + simpa only [Finset.univ_product_univ] using + (Finset.expect_product' (Finset.univ : Finset (G → R)) + (Finset.univ : Finset (A → R)) (fun g a => f (Sum.elim g a))).symm + _ = _ := by + apply Fintype.expect_equiv (Equiv.sumPiEquivProdPi (fun _ : G ⊕ A => R)).symm + intro ga + rfl + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] +variable {I E : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] + [∀ j, Fintype (E j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "Input" => PrincipalTupleIndex B degree +local notation "Long" => LayerSamplerLongVariables short G B +local notation "Active" => PrincipalTupleIndex + (fun a : {a // ¬short a} => B (Subtype.val a)) + (fun a : {a // ¬short a} => degree (Subtype.val a)) +local notation "Out" => Sigma (AllocatedCongruenceRankOutput X E short) + +variable (H parameterStep : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (start : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) +variable (hinside : ∀ j (t : Fin (H j)), + 0 ≤ start j + (parameterStep j : ℤ) * t.val ∧ + start j + (parameterStep j : ℤ) * t.val < allocatedPrincipalSides B U basis S j) +variable (hH : ∀ j, 0 < H j) + +variable {PrimeIndex : Type*} [Fintype PrimeIndex] +variable (primes exponent : PrimeIndex → ℕ) [∀ l, NeZero (primes l)] +local notation "N" => (∏ l, primes l ^ exponent l) +local instance affineFixedPathCRTModulusNeZero : NeZero N := + ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (primes l)))⟩ + +theorem allocatedAffineFixedPath_crtRationalForecast_reference + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + {A : Type*} (selected : A → Σ j : Fin m, Fin (n j)) + (hsmall : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (xref : G → IntegerScalarCubeBox Empty S.value) + (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (deck : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis short j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (commonStep : ℕ) (hstep : commonStep ≠ 0) (cLong : Long → ℤ) + (hp : ∀ l, (primes l).Prime) + (hcoprime : Pairwise (fun l k => (primes l ^ exponent l).Coprime (primes k ^ exponent k))) + {q : ℕ} [NeZero q] (hq : q ∣ N) + {gridVolume : ℝ} (hV : gridVolume ≠ 0) + (test : (A → ((Finset.univ : Finset (Finset Empty)) : Type) → ℤ) → + (Out → ZMod q) → ℂ) : + let poly := allocatedForecastPolynomial short base noise deck projection + let c := allocatedOriginalSampleInactiveCoefficients B selected sample + (allocatedInactiveAffineIntervalLaw B U basis S H parameterStep start hinside hH).complexMean (fun u => + (FiniteProbabilityWeights.uniform (Long → ZMod q)).complexMean (fun r => + test (forecastInactiveShortGrid B U basis S selected c u) + (fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim (fun v => (cLong v : ZMod q) + (commonStep : ZMod q) * r v) + (fun k => (allocatedShortPrincipalRaw B U basis S u k : ZMod q))) (poly o)))) = + ∑' z, 𝔼 b : Out → ZMod N, + ((rationalInactiveForecast (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) + H parameterStep start hinside hH) + (fun _ => crtPolynomialInputLaw primes exponent + (fun l => padicValNat (primes l) commonStep) hcoprime + (fun l v => (cLong v : ZMod (primes l ^ exponent l)))) + (forecastInactiveFixedOutput B U basis S selected c xref) + (fun v => integerLongPolynomialOutput poly (fun k => (v k.1 k.2 : ℤ)) N) + N gridVolume z b / gridVolume : ℝ) : ℂ) * + test z (fun j => ZMod.castHom hq (ZMod q) (b j)) := by + intro poly c + symm + rw [rationalInactivePolynomialForecast_arbitraryStepCRT_tsum_marginal (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) + H parameterStep start hinside hH) + (forecastInactiveFixedOutput B U basis S selected c xref) + primes exponent commonStep hp hstep hcoprime cLong poly + (fun v k => (v k.1 k.2 : ℤ)) hq hV test] + change _ = ((principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) + H parameterStep start hinside hH).finitePushforward (principalAxisRestrict short)).complexMean _ + rw [FiniteProbabilityWeights.complexMean_finitePushforward] + apply congrArg (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) + H parameterStep start hinside hH).complexMean + funext v + rw [forecastInactiveFixedOutput_eq_shortGrid B U basis S hR hσ selected hsmall c + (allocatedOriginalSampleInactiveCoefficients_supported B selected U basis hR hσ S sample hs) + xref v] + apply congrArg (FiniteProbabilityWeights.uniform (Long → ZMod q)).complexMean + funext r + congr 1 + funext o + exact allocatedForecastPolynomial_short_raw B U basis S base noise deck projection q + (fun k => (cLong k : ZMod q) + (commonStep : ZMod q) * r k) v o + +theorem allocatedAffineFixedPath_joint_crtRationalForecast_reference + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + {A : Type*} (selected : A → Σ j : Fin m, Fin (n j)) + (hsmall : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (xref : G → IntegerScalarCubeBox Empty S.value) + (base : X → ℤ) (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (deck : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis short j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (commonStep : ℕ) (hstep : commonStep ≠ 0) (cLong : Long → ℤ) + (hp : ∀ l, (primes l).Prime) + (hcoprime : Pairwise (fun l k => (primes l ^ exponent l).Coprime (primes k ^ exponent k))) + {q : ℕ} [NeZero q] (hq : q ∣ N) + {gridVolume : ℝ} (hV : gridVolume ≠ 0) + (test : (A → ((Finset.univ : Finset (Finset Empty)) : Type) → ℤ) → + (Out → ZMod q) → ℂ) : + let poly := allocatedForecastPolynomial short base noise deck projection + let c := allocatedOriginalSampleInactiveCoefficients B selected sample + (allocatedInactiveAffineIntervalLaw B U basis S H parameterStep start hinside hH).complexMean (fun u => + (FiniteProbabilityWeights.uniform (Active → ZMod q)).complexMean (fun ar => + (FiniteProbabilityWeights.uniform (G → ZMod q)).complexMean (fun rG => + test (forecastInactiveShortGrid B U basis S selected c u) + (allocatedJointResidueOutput B U basis S base noise deck projection q + (fun g => (cLong (Sum.inl g) : ZMod q) + (commonStep : ZMod q) * rG g) + (allocatedPrincipalResidueJoin B U basis S q u + (fun a => (cLong (Sum.inr a) : ZMod q) + (commonStep : ZMod q) * ar a)))))) = + ∑' z, 𝔼 b : Out → ZMod N, + ((rationalInactiveForecast (principalAffineIntervalLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) + H parameterStep start hinside hH) + (fun _ => crtPolynomialInputLaw primes exponent + (fun l => padicValNat (primes l) commonStep) hcoprime + (fun l v => (cLong v : ZMod (primes l ^ exponent l)))) + (forecastInactiveFixedOutput B U basis S selected c xref) + (fun v => integerLongPolynomialOutput poly (fun k => (v k.1 k.2 : ℤ)) N) + N gridVolume z b / gridVolume : ℝ) : ℂ) * + test z (fun j => ZMod.castHom hq (ZMod q) (b j)) := by + intro poly c + rw [← allocatedAffineFixedPath_crtRationalForecast_reference B U basis S H parameterStep + start hinside hH primes exponent hR hσ selected hsmall sample hs xref + base noise deck projection commonStep hstep cLong hp hcoprime hq hV test] + apply congrArg (allocatedInactiveAffineIntervalLaw B U basis S H parameterStep start hinside hH).complexMean + funext u + simp_rw [allocatedJointResidueOutput_join] + have hlong (ar : Active → ZMod q) (rG : G → ZMod q) : + Sum.elim + (fun g => (cLong (Sum.inl g) : ZMod q) + (commonStep : ZMod q) * rG g) + (fun a => (cLong (Sum.inr a) : ZMod q) + (commonStep : ZMod q) * ar a) = + (fun v => (cLong v : ZMod q) + (commonStep : ZMod q) * Sum.elim rG ar v) := by + funext v + cases v <;> rfl + simp_rw [hlong] + exact affineReference_uniform_sum_flip + (fun r : Long → ZMod q => + test (forecastInactiveShortGrid B U basis S selected c u) + (fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (Sum.elim (fun v => (cLong v : ZMod q) + (commonStep : ZMod q) * r v) + (fun k => (allocatedShortPrincipalRaw B U basis S u k : ZMod q))) (poly o))) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineJointSamplingBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineJointSamplingBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..56460a925657955637c883378f02ffc516bede3b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineJointSamplingBudget.lean @@ -0,0 +1,108 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedFiniteIdealMaskBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedProjectedAmbientLogBounds + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +theorem exists_affineAmbientUniformSamplingThreshold_bound (K : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {base D p : ℝ} {outputs dim : ℕ}, + 0 ≤ base → 0 ≤ D → 0 ≤ p → + (outputs : ℝ) ≤ D → (dim : ℝ) ≤ D → (probabilityProfileLipschitz : ℝ) ≤ D → + (ambientL1SamplingBudget (affineAmbientPrimitiveBudget base (idealSiteLogBudget outputs dim p)) + K) ^ K ≤ + (base + D + p + A) ^ A := by + let poly : Polynomial ℕ := + (ambientL1SamplingBudget (affineAmbientPrimitiveBudget Polynomial.X + (allocatedFiniteIdealProfileLog Polynomial.X Polynomial.X)) + Polynomial.C K) ^ K + obtain ⟨A, hA, ha⟩ := exists_natPolynomial_eval_budget poly + refine ⟨A, hA, ?_⟩ + intro base D p outputs dim hbase hD hp hout hdim hprof + let R := base + D + p + have hR : 0 ≤ R := by dsimp [R]; positivity + have hbR : base ≤ R := by dsimp [R]; linarith + have hDR : D ≤ R := by dsimp [R]; linarith + have hpR : p ≤ R := by dsimp [R]; linarith + have hQ : 0 ≤ idealSiteLogBudget outputs dim p := (idealSiteLogBudget_bounds _ _ hp).1 + have hQR : idealSiteLogBudget outputs dim p ≤ allocatedFiniteIdealProfileLog R R := by + apply (idealSiteLogBudget_le_finite_profile hp hout hdim hprof).trans + unfold allocatedFiniteIdealProfileLog + gcongr + have hprofR : 0 ≤ allocatedFiniteIdealProfileLog R R := by + unfold allocatedFiniteIdealProfileLog + positivity + have hmono : + (ambientL1SamplingBudget (affineAmbientPrimitiveBudget base (idealSiteLogBudget outputs dim p)) + K) ^ K ≤ + (ambientL1SamplingBudget (affineAmbientPrimitiveBudget R (allocatedFiniteIdealProfileLog R R)) + K) ^ K := by + dsimp only [ambientL1SamplingBudget, ambientL1FourierInput, affineAmbientPrimitiveBudget, affineAmbientMassLog] + gcongr + apply hmono.trans + simpa [poly, ambientL1SamplingBudget, ambientL1FourierInput, affineAmbientPrimitiveBudget, + affineAmbientMassLog, allocatedFiniteIdealProfileLog, Polynomial.eval₂_pow] using ha R hR + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +noncomputable def affineJointSamplingInput {A : Type*} [Semiring A] (b : ℕ) + (actual base idealQ geometry : A) : A := + (actual + (b : A)) ^ b + affineAmbientPrimitiveBudget base idealQ + geometry + +theorem exists_allocatedAffineJointSamplingThreshold_bound (m dim Aproj K : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {actual base D p geometry : ℝ} {outputs : ℕ}, + 0 ≤ actual → 0 ≤ base → 0 ≤ D → 0 ≤ p → 0 ≤ geometry → + (outputs : ℝ) ≤ D → (dim : ℝ) ≤ D → (probabilityProfileLipschitz : ℝ) ≤ D → + (ambientL1SamplingBudget (allocatedProjectedAmbientLog m dim Aproj actual + + affineAmbientPrimitiveBudget base (idealSiteLogBudget outputs dim p) + geometry) + K) ^ K ≤ + (actual + base + D + p + geometry + A) ^ A := by + obtain ⟨b, hb, hactual⟩ := exists_allocatedProjectedAmbientLog_bound m dim Aproj + let X : Polynomial ℕ := Polynomial.X + let poly : Polynomial ℕ := + (ambientL1SamplingBudget (affineJointSamplingInput b X X + (allocatedFiniteIdealProfileLog X X) X) + Polynomial.C K) ^ K + obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget poly + refine ⟨A, hA, ?_⟩ + intro actual base D p geometry outputs ha hbase hD hp hg hout hdim hprofile + let R := actual + base + D + p + geometry + have hR : 0 ≤ R := by dsimp [R]; positivity + have haR : actual ≤ R := by dsimp [R]; linarith + have hbR : base ≤ R := by dsimp [R]; linarith + have hDR : D ≤ R := by dsimp [R]; linarith + have hpR : p ≤ R := by dsimp [R]; linarith + have hgR : geometry ≤ R := by dsimp [R]; linarith + have hQ : 0 ≤ idealSiteLogBudget outputs dim p := (idealSiteLogBudget_bounds _ _ hp).1 + have hprofR : 0 ≤ allocatedFiniteIdealProfileLog R R := by + unfold allocatedFiniteIdealProfileLog + positivity + have hQR : idealSiteLogBudget outputs dim p ≤ allocatedFiniteIdealProfileLog R R := by + apply (idealSiteLogBudget_le_finite_profile hp hout hdim hprofile).trans + unfold allocatedFiniteIdealProfileLog + gcongr + have hap : allocatedProjectedAmbientLog m dim Aproj actual ≤ (R + b) ^ b := + (hactual actual ha).trans (pow_le_pow_left₀ (by positivity) (by linarith) b) + have ha0 : 0 ≤ allocatedProjectedAmbientLog m dim Aproj actual := by + have h := allocatedAmbientLog_nonneg m ha + unfold allocatedProjectedAmbientLog + positivity + have hmono : + (ambientL1SamplingBudget (allocatedProjectedAmbientLog m dim Aproj actual + + affineAmbientPrimitiveBudget base (idealSiteLogBudget outputs dim p) + geometry) + K) ^ K ≤ + (ambientL1SamplingBudget (affineJointSamplingInput b R R (allocatedFiniteIdealProfileLog R R) R) + K) ^ K := by + dsimp only [affineJointSamplingInput, ambientL1SamplingBudget, ambientL1FourierInput, + affineAmbientPrimitiveBudget, affineAmbientMassLog] + gcongr + apply hmono.trans + simpa [poly, X, affineJointSamplingInput, ambientL1SamplingBudget, ambientL1FourierInput, + affineAmbientPrimitiveBudget, affineAmbientMassLog, allocatedFiniteIdealProfileLog, + Polynomial.eval₂_pow] using hbound R hR + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineLogEnvelope.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineLogEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..51ea98969fc33ef7d45afd45755ddbeb8e9601d4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineLogEnvelope.lean @@ -0,0 +1,92 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedProfileDimensions +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineRadiusLog + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {α : Type*} [Fintype α] {O : Fin m → Type*} [∀ j, Fintype (O j)] + + theorem allocatedBlock_card_le_tuples (a : LayerSamplerAxis I n) : + Fintype.card (B a) ≤ Fintype.card (PrincipalTupleIndex B (layerSamplerDegree I n)) := by + apply Fintype.card_le_of_injective + (fun b : B a => (⟨a, b, ⟨0, Nat.zero_lt_succ _⟩⟩ : PrincipalTupleIndex B (layerSamplerDegree I n))) + intro b c hbc + simpa using hbc + + theorem allocatedAffine_block_dimensions {D : ℝ} + (hd : AllocatedComparisonDimensions (G := G) B α O D) : + ∀ a, (Fintype.card (B a) : ℝ) ≤ D := + fun a => (Nat.cast_le.mpr (allocatedBlock_card_le_tuples B a)).trans hd.tuples + + theorem allocatedAffine_parameter_dimensions {D : ℝ} + (hd : AllocatedComparisonDimensions (G := G) B α O D) : + (Fintype.card (PolynomialParameter + ((G × Option α) ⊕ (Σ a, SamplerCoefficientSlot G B (layerSamplerDegree I n) a)) + (JointBlockParameter B (layerSamplerDegree I n) α)) : ℝ) ≤ + D * (D + 1) + D * D + D + 1 := by + have hslots : (∑ a : LayerSamplerAxis I n, + (Fintype.card (SamplerCoefficientSlot G B (layerSamplerDegree I n) a) : ℝ)) ≤ D * D := by + apply affineLog_sum_le _ hd.axes hd.nonneg + intro a + exact hd.coefficients a.1 + have hG := hd.kernel_variables + have hα := hd.cube + have hparam := hd.parameters + have hD := hd.nonneg + simp only [PolynomialParameter, Fintype.card_option, Fintype.card_sum, Fintype.card_sigma, + Fintype.card_prod, Nat.cast_add, Nat.cast_mul, Nat.cast_sum, Nat.cast_one] + simp only [JointBlockParameter, BlockParameter, Fintype.card_sigma, Fintype.card_prod, + Fintype.card_option, Nat.cast_sum, Nat.cast_mul, Nat.cast_add, Nat.cast_one] at hparam + gcongr + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {α : Type*} [Fintype α] [DecidableEq α] + {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] + +omit [DecidableEq α] [∀ j, Nonempty (O j)] in + theorem allocatedAffine_log_costs_le_envelope [DecidableEq α] [∀ j, Nonempty (O j)] + (A T : ℝ≥0) {D E F : ℝ} + (hd : AllocatedComparisonDimensions (G := G) B α O D) (hE : 0 ≤ E) (hF : 0 ≤ F) : + allocatedAffineRadiusLog (O := O) (α := α) B A T E F ≤ + 2 * affineProfileInputEnvelope D (A : ℝ) (T : ℝ) E F + 2 ∧ + allocatedAffineToleranceLog (G := G) (O := O) (α := α) B A T E F ≤ + affineProfileToleranceEnvelope m D (D * (D + 1) + D * D + D + 1) (A : ℝ) (T : ℝ) E F := by + have hB := allocatedAffine_block_dimensions B hd + have hh (a : LayerSamplerAxis I n) : (layerSamplerDegree I n a : ℝ) ≤ D := + hd.layer_degree B a.1 + have hO (a : LayerSamplerAxis I n) : (Fintype.card (O a.1) : ℝ) ≤ D := hd.rows a.1 + constructor + · apply (Finset.sup'_le_iff _ _).mpr + intro partition _ + exact add_le_add (mul_le_mul_of_nonneg_left + (partitionedAffineInputLog_le_envelope (B := B) (O := fun a : LayerSamplerAxis I n => O a.1) + (α := α) (layerSamplerDegree I n) partition A T hd.nonneg hd.axes hd.cube hB hO hh hE hF) + (by norm_num)) le_rfl + · apply (Finset.sup'_le_iff _ _).mpr + intro partition _ + exact partitionedAffineToleranceLog_le_envelope (G := G) (Z := G × Option α) + (B := B) (O := fun a : LayerSamplerAxis I n => O a.1) (α := α) + (layerSamplerDegree I n) partition A T m hd.nonneg hd.axes hd.cube hB hO hh hE hF + (allocatedAffine_parameter_dimensions B hd) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffinePhysicalBoundsSuccessor.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffinePhysicalBoundsSuccessor.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f9b9988da4ba22ac2028887f97de684b82805c4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffinePhysicalBoundsSuccessor.lean @@ -0,0 +1,1092 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateRoundedThresholdSuccessor +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineCanonicalBackendBudget +import OAI.Combinatorics.Progressions.Nilpotent.NativeResetBracketGeometry + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem.CertifiedThresholdAffineRefinement + +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p separation : ℝ} + +variable (selected : P.CertifiedThresholdAffineRefinement K p separation) + +@[simp] theorem problem_physicalIntegerPoint (x : X → ℤ) : + selected.problem.physicalIntegerPoint x = P.physicalIntegerPoint x := rfl + +@[simp] theorem withKeep_physicalIntegerPoint + (keep : LayerSamplerVariables G I n B → Prop) + (hkeep : ∀ z : selected.problem.productive, (selected.problem.chart z).keep = keep) + (x : X → ℤ) : + (selected.problem.withKeep keep hkeep).physicalIntegerPoint x = + P.physicalIntegerPoint x := rfl + +theorem withKeep_original_dense + (keep : LayerSamplerVariables G I n B → Prop) + (hkeep : ∀ z : selected.problem.productive, (selected.problem.chart z).keep = keep) + (z : (selected.problem.withKeep keep hkeep).productive) : + IsDenseCommonStrideBox + (fun i : ((selected.problem.withKeep keep hkeep).chart z).Variables => A.sides i.val) + cost ((selected.problem.withKeep keep hkeep).chart z).slice.integerPoints := by + suffices h : ∀ (keep' : LayerSamplerVariables G I n B → Prop) + (heq : (selected.problem.chart z).keep = keep'), + IsDenseCommonStrideBox + (fun i : ((selected.problem.chart z).withKeep keep' heq).Variables => A.sides i.val) + cost ((selected.problem.chart z).withKeep keep' heq).slice.integerPoints by + exact h keep (hkeep z) + intro keep' heq + cases heq + exact selected.original_dense z + +noncomputable def conclusion_normalized {outputCost : ℝ} + (hcutoff : candidateSideCutoffCost separation ≤ outputCost) + (out : selected.problem.Conclusion outputCost + (Real.exp (-outputCost)) (Real.exp (-outputCost))) : + P.Conclusion outputCost (Real.exp (-outputCost)) (Real.exp (-outputCost)) := by + simpa only [max_eq_left hcutoff] using selected.conclusion out + +noncomputable def conclusion_of_withKeep_normalized + (keep : LayerSamplerVariables G I n B → Prop) + (hkeep : ∀ z : selected.problem.productive, (selected.problem.chart z).keep = keep) + {outputCost : ℝ} (hcutoff : candidateSideCutoffCost separation ≤ outputCost) + (out : (selected.problem.withKeep keep hkeep).Conclusion outputCost + (Real.exp (-outputCost)) (Real.exp (-outputCost))) : + P.Conclusion outputCost (Real.exp (-outputCost)) (Real.exp (-outputCost)) := + selected.conclusion_normalized hcutoff + (selected.problem.conclusion_of_withKeep keep hkeep out) + +theorem canonical_cutoff_le_recursive (degree slowExponent : ℕ) {input : ℝ} + (hinput : 0 ≤ input) : + candidateSideCutoffCost (Real.exp + (candidatePrimitiveFreezingCutoff degree slowExponent input)) ≤ + finiteFreezingRecursiveParameter + (candidatePrimitivePhysicalBudgetExponent degree slowExponent) input := by + apply (candidatePrimitiveFreezingCutoff_integer_cost degree slowExponent hinput).trans + apply (candidatePrimitiveFreezingCutoff_add_two_le_budget degree slowExponent hinput).trans + unfold finiteFreezingRecursiveParameter + have hbudget : 0 ≤ (input + candidatePrimitivePhysicalBudgetExponent degree slowExponent) ^ + candidatePrimitivePhysicalBudgetExponent degree slowExponent := by positivity + linarith + +end AllocatedExternalCandidateProblem.CertifiedThresholdAffineRefinement +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realChartSubstitute realPolynomialGroupMap associatedGradedMap gradedRefiltrationMap + PolynomialRationalGrid PolynomialSlowBound + realSymbolHomogeneousPullbackHom CertifiedFullChartFiniteHistory.outer + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalCandidateProblem + +variable {L M : Type} {nMarkedBasis : ℕ} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (c : Basis (Fin nMarkedBasis) ℚ M) + (ν : Fin nMarkedBasis → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (c '' {i | j ≤ ν i})) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull separation : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration c ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom c ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation) + +theorem conclusion_of_affinePhysicalTerminal_nativeReset_degreeRule + {p logSlow massLog : ℝ} {denominator e : ℕ} + (reset : AllocatedExternalGlobalNativeResetFamily Fmark φ hφ + data.selected.problem (fun i => candidateSideCutoff separation ≤ A.sides i) + (data.selected.common_keep hcost) W data.factors (Real.exp logSlow) denominator) + (hp0 : 0 ≤ p) + (hseparation : separation = Real.exp (candidatePrimitiveFreezingCutoff s 1 p)) + (hDNative : D.GeometryComplexityLE p) + (hRetainedCount : (Fintype.card { i : LayerSamplerVariables G I n B // + candidateSideCutoff separation ≤ A.sides i } : ℝ) ≤ p) + (hMarkedDimension : (nMarkedBasis : ℝ) ≤ p) + (hSectionMapHeight : ∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p) + (hdenominatorPos : 0 < denominator) + (hdenominatorBound : (denominator : ℝ) ≤ Real.exp p) + (hdenominatorDvd : data.nFinal ∣ denominator) + (hlogSlow : logSlow ≤ p) + (hphysical : (pFull + allocatedEarlyAffineLeftExponent (s + 1) 4) ^ + allocatedEarlyAffineLeftExponent (s + 1) 4 ≤ p) + (hσ1 : ∀ j, σ j ≤ 1) (H : Fin m → ℝ) (hH : ∀ j, 0 ≤ H j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ H j * ‖v‖) + (hsmall : ∀ j, H j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp p) + (hscoreInput : Real.exp (-p) ≤ scoreThreshold) + (hcostInput : cost ≤ p) + (hmassLog : massLog ≤ p) + (hmassInput : Real.exp (-massLog) ≤ + Real.exp (-((2 * certifiedAffineCenterBudget pAffine + 3) ^ 3)) * massThreshold) + (dw : Fin d → ℕ) + (hdb : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ dw i})) + (hW : BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis dw hdb) dw W.toSubmodule) + (hsurj : ∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) + (hξ1 : ξ ≤ 1) + (ℓ : ℝ≥0) (hℓ : (ℓ : ℝ) ≤ Real.exp p) + (hOriginalLip : ∀ x, letI := D.metricSpace; LipschitzWith ℓ (observable x)) + (hpositive : ∀ x y, (observable x y).im = 0 ∧ + 0 ≤ (observable x y).re ∧ (observable x y).re ≤ 1) + (hFGeo : Fmark.GeometryComplexityLE p) + {Generator : Type} [Fintype Generator] + (generators : Generator → D.filtration.AssociatedGraded) + (hspan : span ℚ (Set.range generators) = W.toSubmodule) + (hgeneratorCount : (Fintype.card Generator : ℝ) ≤ p) + (hmarkedBasis : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p) + (hmarkHeight : ∀ i j, rationalLogHeight (Fmark.basis.repr (φ (D.basis i)) j) ≤ p) + (hgeneratorHeight : ∀ i j, + rationalLogHeight ((D.filtration.associatedGradedBasis D.basis dw hdb).repr (generators i) j) ≤ p) + (htopKernel : ∀ x : L, x ∈ D.filtration.gradedRefiltrationLayer W (s + 1) → φ x = 0 → x = 0) + (hOriginalNet : ∀ η : ℝ, 0 < η → η ≤ 1 → ∃ n : ℕ, + (n : ℝ) ≤ Real.exp ((p + Real.log (1 / η) + e) ^ e) ∧ + ∃ oc : Fin n → {x : X → ℤ // x ∈ integerBox N}, + ∀ x ∈ integerBox N, ∃ i, ∀ y, ‖observable x y - observable (oc i).val y‖ ≤ η) + (outputCost : ℝ) + (lowerIH : A.DegreeGlobalizationAt (E := E) weight s + (RationalFilteredNilmanifold.refilteredQuotientNetExponent.{0, 0, 0} s 1 e + 2) + (finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) p) outputCost) : + Nonempty (P.Conclusion (max outputCost (candidateSideCutoffCost separation)) + (Real.exp (-outputCost)) (Real.exp (-outputCost))) := by + classical + let keep : LayerSamplerVariables G I n B → Prop := + fun i => candidateSideCutoff separation ≤ A.sides i + let hkeep := data.selected.common_keep hcost + let reset' : AllocatedExternalGlobalNativeResetFamily Fmark φ hφ + data.selected.problem keep hkeep W data.factors (Real.exp p) denominator := + { reset with + slow_left := fun z => D.filtration.polynomialSlowBound_mono D.basis + (fun _ : {i // keep i} => 1) (fun i => (A.sides i.val : ℝ)) + (fun i => Nat.cast_pos.mpr (A.sides_pos i.val)) + (Real.exp_le_exp.mpr hlogSlow) _ (reset.slow_left z) } + have hslowMark : ∀ z, Fmark.filtration.PolynomialSlowBound c + (fun _ : {i // keep i} => 1) (fun i => (A.sides i.val : ℝ)) (Real.exp p) + (Fmark.filtration.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : {i // keep i} => 1) + (integerSampledRealChart ((data.selected.problem.withKeep keep hkeep).chart z).integerChart) + ((data.selected.problem.withKeep keep hkeep).chart z).integerChart_support data.factors.left) := by + intro z + suffices h : ∀ (keep' : LayerSamplerVariables G I n B → Prop) + (heq : (data.selected.problem.chart z).keep = keep'), + Fmark.filtration.PolynomialSlowBound c + (fun _ : ((data.selected.problem.chart z).withKeep keep' heq).Variables => 1) + (fun i => (A.sides i.val : ℝ)) (Real.exp p) + (Fmark.filtration.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : ((data.selected.problem.chart z).withKeep keep' heq).Variables => 1) + (integerSampledRealChart ((data.selected.problem.chart z).withKeep keep' heq).integerChart) + ((data.selected.problem.chart z).withKeep keep' heq).integerChart_support data.factors.left) by + exact h keep (hkeep z) + intro keep' heq + cases heq + exact Fmark.filtration.polynomialSlowBound_mono c + (fun _ : (data.selected.problem.chart z).Variables => 1) + (fun i => (A.sides i.val : ℝ)) + (fun i => Nat.cast_pos.mpr (A.sides_pos i.val)) + (Real.exp_le_exp.mpr hphysical) _ (data.local_left z) + have hgrid := Fmark.filtration.polynomialRationalGrid_of_dvd c + (fullTaggedVariableWeight J) data.nFinal_pos hdenominatorDvd data.factors.right data.right_grid + have hside (i : {i // keep i}) : + Real.exp (candidatePrimitiveFreezingCutoff s 1 p) ≤ (A.sides i.val : ℝ) := by + rw [← hseparation] + exact (lt_candidateSideCutoff separation).le.trans (Nat.cast_le.mpr i.property) + have hcostRounded : max cost (candidateSideCutoffCost separation) ≤ + candidatePrimitiveFreezingCutoff s 1 p + 2 := by + apply max_le + · have h := candidatePrimitiveFreezingCutoff_ge_input s 1 hp0 + linarith + · rw [hseparation] + exact candidatePrimitiveFreezingCutoff_integer_cost s 1 hp0 + have hmarkedPhysicalLeft : ∀ x ∈ integerBox N, ∀ i, + |(c.baseChange ℝ).repr + (Fmark.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + ((data.selected.problem.withKeep keep hkeep).physicalIntegerPoint x) reset'.leftMark).coord i| ≤ + Real.exp p := by + intro x hx i + rw [data.selected.withKeep_physicalIntegerPoint keep hkeep x] + exact (data.physical_left x hx i).trans (Real.exp_le_exp.mpr hphysical) + obtain ⟨out⟩ := data.selected.problem.conclusion_of_roundedThreshold_nativeReset_degreeRule + Fmark φ hφ keep hkeep W c ν hF data.factors reset' hσ1 H hH hchart hsmall hp + 1 hp0 hDNative (by simpa only [Fintype.card_eq_nat_card] using hRetainedCount) + hMarkedDimension hSectionMapHeight + hdenominatorPos hdenominatorBound (Real.exp_le_exp.mpr (by simp)) hslowMark hgrid + (data.selected.withKeep_original_dense keep hkeep) hside hweight hscoreInput + hcostRounded hcostInput hmassLog hmassInput dw hdb hW hsurj hξ1 ℓ hℓ + hmarkedPhysicalLeft hOriginalLip hpositive hFGeo generators hspan hgeneratorCount + hmarkedBasis hmarkHeight hgeneratorHeight htopKernel hOriginalNet outputCost lowerIH + exact ⟨data.selected.conclusion out⟩ + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realChartSubstitute realPolynomialGroupMap associatedGradedMap gradedRefiltrationMap + PolynomialRationalGrid PolynomialSlowBound + realSymbolHomogeneousPullbackHom CertifiedFullChartFiniteHistory.outer + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalCandidateProblem + +variable {L M : Type} {nMarkedBasis : ℕ} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (c : Basis (Fin nMarkedBasis) ℚ M) + (ν : Fin nMarkedBasis → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (c '' {i | j ≤ ν i})) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull separation : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration c ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom c ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation) + +variable {Fmark φ hφ P W c ν hF basis lift Bphase budget pAffine pFull separation history data hcost} + +structure AffinePhysicalTerminalData.SuccessorInputs + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (p : ℝ) (e : ℕ) (outputCost : ℝ) where + nonnegative : 0 ≤ p + separation_eq : separation = Real.exp (candidatePrimitiveFreezingCutoff s 1 p) + source_geometry : D.GeometryComplexityLE p + retained_count : (Fintype.card { i : LayerSamplerVariables G I n B // + candidateSideCutoff separation ≤ A.sides i } : ℝ) ≤ p + marked_dimension : (nMarkedBasis : ℝ) ≤ p + section_height : ∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p + physical_budget : (pFull + allocatedEarlyAffineLeftExponent (s + 1) 4) ^ + allocatedEarlyAffineLeftExponent (s + 1) 4 ≤ p + scale_le_one : ∀ j, σ j ≤ 1 + chart_bound : Fin m → ℝ + chart_nonnegative : ∀ j, 0 ≤ chart_bound j + chart_norm : ∀ j v, + ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ chart_bound j * ‖v‖ + chart_small : ∀ j, chart_bound j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8 + polynomial_degree : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j) + weight_bound : ∀ x, ‖weight x‖ ≤ Real.exp p + score_bound : Real.exp (-p) ≤ scoreThreshold + cost_bound : cost ≤ p + mass_log : ℝ + mass_log_bound : mass_log ≤ p + mass_bound : Real.exp (-mass_log) ≤ + Real.exp (-((2 * certifiedAffineCenterBudget pAffine + 3) ^ 3)) * massThreshold + weights : Fin d → ℕ + adapted : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ weights i}) + graded : BasisGradedSubmodule + (D.filtration.associatedGradedBasis D.basis weights adapted) weights W.toSubmodule + surjective : ∀ j, ∀ y ∈ Fmark.filtration.layer j, + ∃ x ∈ D.filtration.layer j, φ x = y + width_le_one : ξ ≤ 1 + lipschitz_constant : ℝ≥0 + lipschitz_bound : (lipschitz_constant : ℝ) ≤ Real.exp p + lipschitz : ∀ x, letI := D.metricSpace; LipschitzWith lipschitz_constant (observable x) + positive : ∀ x y, (observable x y).im = 0 ∧ + 0 ≤ (observable x y).re ∧ (observable x y).re ≤ 1 + marked_geometry : Fmark.GeometryComplexityLE p + Generator : Type + generator_fintype : Fintype Generator + generators : Generator → D.filtration.AssociatedGraded + generator_span : span ℚ (Set.range generators) = W.toSubmodule + generator_count : (@Fintype.card Generator generator_fintype : ℝ) ≤ p + marked_basis_height : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p + mark_height : ∀ i j, rationalLogHeight (Fmark.basis.repr (φ (D.basis i)) j) ≤ p + generator_height : ∀ i j, + rationalLogHeight + ((D.filtration.associatedGradedBasis D.basis weights adapted).repr (generators i) j) ≤ p + top_kernel : ∀ x : L, + x ∈ D.filtration.gradedRefiltrationLayer W (s + 1) → φ x = 0 → x = 0 + net : ∀ accuracy : ℝ, 0 < accuracy → accuracy ≤ 1 → ∃ count : ℕ, + (count : ℝ) ≤ Real.exp ((p + Real.log (1 / accuracy) + e) ^ e) ∧ + ∃ centers : Fin count → {x : X → ℤ // x ∈ integerBox N}, + ∀ x ∈ integerBox N, ∃ i, ∀ y, + ‖observable x y - observable (centers i).val y‖ ≤ accuracy + lower_degree : A.DegreeGlobalizationAt (E := E) weight s + (RationalFilteredNilmanifold.refilteredQuotientNetExponent.{0, 0, 0} s 1 e + 2) + (finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) p) outputCost + +theorem AffinePhysicalTerminalData.SuccessorInputs.conclusion_of_reset + {p logSlow outputCost : ℝ} {denominator e : ℕ} + (input : data.SuccessorInputs p e outputCost) + (reset : AllocatedExternalGlobalNativeResetFamily Fmark φ hφ + data.selected.problem (fun i => candidateSideCutoff separation ≤ A.sides i) + (data.selected.common_keep hcost) W data.factors (Real.exp logSlow) denominator) + (hlogSlow : logSlow ≤ p) + (hdenominatorPos : 0 < denominator) + (hdenominatorBound : (denominator : ℝ) ≤ Real.exp p) + (hdenominatorDvd : data.nFinal ∣ denominator) : + Nonempty (P.Conclusion (max outputCost (candidateSideCutoffCost separation)) + (Real.exp (-outputCost)) (Real.exp (-outputCost))) := by + let _ := input.generator_fintype + exact P.conclusion_of_affinePhysicalTerminal_nativeReset_degreeRule Fmark φ hφ W c ν hF + basis lift Bphase budget pAffine pFull separation history data hcost reset + input.nonnegative input.separation_eq input.source_geometry input.retained_count + input.marked_dimension input.section_height hdenominatorPos hdenominatorBound hdenominatorDvd + hlogSlow input.physical_budget input.scale_le_one input.chart_bound input.chart_nonnegative + input.chart_norm input.chart_small input.polynomial_degree input.weight_bound input.score_bound + input.cost_bound input.mass_log_bound input.mass_bound input.weights input.adapted input.graded + input.surjective input.width_le_one input.lipschitz_constant input.lipschitz_bound input.lipschitz + input.positive input.marked_geometry input.generators input.generator_span input.generator_count + input.marked_basis_height input.mark_height input.generator_height input.top_kernel input.net + outputCost input.lower_degree + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalCandidateProblem + +variable {L M : Type} {nMarkedBasis : ℕ} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (c : Basis (Fin nMarkedBasis) ℚ M) + (ν : Fin nMarkedBasis → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (c '' {i | j ≤ ν i})) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull separation : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration c ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom c ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation) + +variable {Fmark φ hφ P W c ν hF basis lift Bphase budget pAffine pFull separation history data hcost} + +noncomputable def AffinePhysicalTerminalData.successorInputsOfBounds + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (p0 : ℝ) (hp0 : 0 ≤ p0) (hpFull : 0 ≤ pFull) + (hseparation : separation = Real.exp (candidatePrimitiveFreezingCutoff s 1 + (allocatedAffineCanonicalBudget s p0 pFull))) + (hDgeo : D.GeometryComplexityLE p0) (hFgeo : Fmark.GeometryComplexityLE p0) + (hvariables : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p0) + (hmarkedDim : (nMarkedBasis : ℝ) ≤ p0) + (hsection : ∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p0) + (hσ1 : ∀ j, σ j ≤ 1) + (Hchart : Fin m → ℝ) (hHchart : ∀ j, 0 ≤ Hchart j) + (hchart : ∀ j v, + ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ Hchart j * ‖v‖) + (hsmall : ∀ j, Hchart j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp p0) + (hscore : Real.exp (-p0) ≤ scoreThreshold) + (hcost0 : cost ≤ p0) + (hmass : Real.exp (-p0) ≤ + Real.exp (-((2 * certifiedAffineCenterBudget pAffine + 3) ^ 3)) * massThreshold) + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (hW : BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule) + (hsurj : ∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) + (hξ1 : ξ ≤ 1) (ℓ : ℝ≥0) (hℓ : (ℓ : ℝ) ≤ Real.exp p0) + (hLip : ∀ x, letI := D.metricSpace; LipschitzWith ℓ (observable x)) + (hpositive : ∀ x y, (observable x y).im = 0 ∧ + 0 ≤ (observable x y).re ∧ (observable x y).re ≤ 1) + {Generator : Type} [Fintype Generator] + (v : Generator → D.filtration.AssociatedGraded) + (hspan : span ℚ (Set.range v) = W.toSubmodule) + (hcount : (Fintype.card Generator : ℝ) ≤ p0) + (hcForward : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p0) + (hmark : ∀ i j, rationalLogHeight (Fmark.basis.repr (φ (D.basis i)) j) ≤ p0) + (hv : ∀ i j, rationalLogHeight + ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v i) j) ≤ p0) + (htop : ∀ x : L, x ∈ D.filtration.gradedRefiltrationLayer W (s + 1) → φ x = 0 → x = 0) + {e : ℕ} + (hnet : ∀ accuracy : ℝ, 0 < accuracy → accuracy ≤ 1 → ∃ count : ℕ, + (count : ℝ) ≤ Real.exp ((p0 + Real.log (1 / accuracy) + e) ^ e) ∧ + ∃ centers : Fin count → integerBox N, + ∀ x ∈ integerBox N, ∃ i, ∀ y, + ‖observable x y - observable (centers i).val y‖ ≤ accuracy) + (outputCost : ℝ) + (lowerIH : A.DegreeGlobalizationAt (E := E) weight s + (RationalFilteredNilmanifold.refilteredQuotientNetExponent.{0, 0, 0} s 1 e + 2) + (finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s p0 pFull)) outputCost) : + data.SuccessorInputs (allocatedAffineCanonicalBudget s p0 pFull) e outputCost := by + have bounds := allocatedAffineCanonicalBudget_bounds s hp0 hpFull + refine { + nonnegative := bounds.nonnegative + separation_eq := hseparation + source_geometry := hDgeo.mono D bounds.input + retained_count := ?_ + marked_dimension := hmarkedDim.trans bounds.input + section_height := fun i j => (hsection i j).trans bounds.input + physical_budget := bounds.physical + scale_le_one := hσ1 + chart_bound := Hchart + chart_nonnegative := hHchart + chart_norm := hchart + chart_small := hsmall + polynomial_degree := hpoly + weight_bound := fun x => (hweight x).trans (Real.exp_le_exp.mpr bounds.input) + score_bound := (Real.exp_le_exp.mpr (neg_le_neg bounds.input)).trans hscore + cost_bound := hcost0.trans bounds.input + mass_log := p0 + mass_log_bound := bounds.input + mass_bound := hmass + weights := ω + adapted := hD + graded := hW + surjective := hsurj + width_le_one := hξ1 + lipschitz_constant := ℓ + lipschitz_bound := hℓ.trans (Real.exp_le_exp.mpr bounds.input) + lipschitz := hLip + positive := hpositive + marked_geometry := hFgeo.mono Fmark bounds.input + Generator := Generator + generator_fintype := inferInstance + generators := v + generator_span := hspan + generator_count := hcount.trans bounds.input + marked_basis_height := fun i j => (hcForward i j).trans bounds.input + mark_height := fun i j => (hmark i j).trans bounds.input + generator_height := fun i j => (hv i j).trans bounds.input + top_kernel := htop + net := ?_ + lower_degree := lowerIH } + · exact (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans + (hvariables.trans bounds.input) + · intro accuracy hacc hacc1 + obtain ⟨count, hcount, centers, hcenters⟩ := hnet accuracy hacc hacc1 + refine ⟨count, hcount.trans (Real.exp_le_exp.mpr ?_), centers, hcenters⟩ + have hlog : 0 ≤ Real.log (1 / accuracy) := + Real.log_nonneg ((one_le_div hacc).mpr hacc1) + exact pow_le_pow_left₀ (by positivity) (by linarith [bounds.input]) e + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates associatedGradedMap realPolynomialGroupMap + AllocatedExternalCandidateProblem.Refinement.problem + realSymbolHomogeneousPullbackHom CertifiedFullChartFiniteHistory.outer + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalCandidateProblem + +variable {L M : Type} {nMarkedBasis : ℕ} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (c : Basis (Fin nMarkedBasis) ℚ M) + (ν : Fin nMarkedBasis → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (c '' {i | j ≤ ν i})) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull separation : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration c ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom c ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation) + +local notation "kept" => (fun i : LayerSamplerVariables G I n B => + candidateSideCutoff separation ≤ A.sides i) + +theorem conclusion_of_affinePhysicalTerminal_zeroRestricted_degreeRule + {κK μ χ : Type} [Fintype κK] [Fintype μ] [Fintype χ] + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (hsurj : ∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) + (bk : Basis κK ℚ (LinearMap.ker φ.toLinearMap)) + (v : μ → D.filtration.AssociatedGraded) + (hW : BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule) + (hvspan : span ℚ (Set.range v) = W.toSubmodule) + (vg : χ → Fmark.filtration.PolynomialSymbol (fun _ : {i // kept i} => 1)) + (hvgspan : span ℚ (Set.range vg) = + (Fmark.filtration.symbolPointwiseSubalgebra c ν hF (fun _ : {i // kept i} => 1) + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))).toSubmodule) + [Fintype (SymbolBasisIndex (fun _ : {i // kept i} => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : {i // kept i} => 1) ν)] + (H l : ℕ) (pMap pNative : ℝ) + (hH : 1 ≤ H) (hl : 0 < l) (hpMap : 0 ≤ pMap) (hpNative : 0 ≤ pNative) + (hsrc : (Fintype.card (SymbolBasisIndex (fun _ : {i // kept i} => 1) ω) : ℝ) ≤ pMap) + (htgt : (Fintype.card (SymbolBasisIndex (fun _ : {i // kept i} => 1) ν) : ℝ) ≤ pMap) + (hHmap : (H : ℝ) ≤ Real.exp pMap) + (hlmap : ((l * data.nFinal : ℕ) : ℝ) ≤ Real.exp pMap) + (hmabsorb : Real.exp ((pMap + 2) ^ 4) ≤ Real.exp pNative) + (hd : (d : ℝ) ≤ pNative) (hc : (nMarkedBasis : ℝ) ≤ pNative) + (hk : (Fintype.card κK : ℝ) ≤ pNative) + (hμ : (Fintype.card μ : ℝ) ≤ pNative) + (hχ : (Fintype.card χ : ℝ) ≤ pNative) + (hvars : (Fintype.card {i // kept i} : ℝ) ≤ pNative) + (hHp : (H : ℝ) ≤ Real.exp pNative) + (hbracketD : ∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) H) + (hbracketF : ∀ i j k, RationalHeightLE (c.repr ⁅c i, c j⁆ k) H) + (hkernel : ∀ i j, RationalHeightLE (D.basis.repr (bk j : L) i) H) + (hentries : ∀ k i, RationalHeightLE (c.repr (φ (D.basis i)) k) H) + (hv : ∀ j i, RationalHeightLE + ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) H) + (hvg : ∀ i z, RationalHeightLE + ((Fmark.filtration.polynomialSymbolBasis c ν hF (fun _ : {i // kept i} => 1)).repr (vg i) z) H) + (hslow : Real.exp ((pFull + allocatedEarlyAffineLeftExponent (s + 1) 4) ^ + allocatedEarlyAffineLeftExponent (s + 1) 4) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ))) + (hsideBound : Real.exp ((pNative + allocatedAffineResetCompareExponent s) ^ + allocatedAffineResetCompareExponent s) ≤ separation) + (q : ℝ) + (hq : Real.exp q ≤ Real.exp ((pNative + 2) ^ (1 : ℕ))) + (hqmap : Real.exp ((pMap + 2) ^ 3 + q) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ))) + (hcutoff : Real.exp cost * ((s + 1 + 1 : ℕ) : ℝ) ≤ separation) + (initialLong : LayerSamplerVariables G I n B → Prop) + (hsub : ∀ i, kept i → initialLong i) + (hzero : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors D.basis ω hD + (fun i : {i // initialLong i} => (A.sides i.val : ℝ)) q l W + (D.filtration.weightedAdaptedRealChartHom (fun _ : (P.chart z).Variables => 1) + (fun _ : {i // initialLong i} => 1) ((P.chart z).axisPolynomial initialLong (fun _ => 0)) + ((P.chart z).axisPolynomial_support initialLong (fun _ => 0)) + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) (P.candidate z).orbit))) + {p outputCost : ℝ} {e : ℕ} + (input : data.SuccessorInputs p e outputCost) + (hresetBudget : allocatedAffineResetLogBudget s pNative ≤ p) : + Nonempty (P.Conclusion (max outputCost (candidateSideCutoffCost separation)) + (Real.exp (-outputCost)) (Real.exp (-outputCost))) := by + have hcost : Real.exp cost ≤ separation := by + rw [input.separation_eq] + exact Real.exp_le_exp.mpr + (input.cost_bound.trans (candidatePrimitiveFreezingCutoff_ge_input s 1 input.nonnegative)) + obtain ⟨denominator, hden, hdenBound, hdenDvd, ⟨reset⟩⟩ := + P.exists_affinePhysicalTerminal_nativeReset_of_zero_restriction Fmark φ hφ W c ν hF + basis lift Bphase budget pAffine pFull separation history data hcost + ω hD hsurj bk v hW hvspan vg hvgspan H l pMap pNative hH hl hpMap hpNative + hsrc htgt hHmap hlmap hmabsorb hd hc hk hμ hχ hvars hHp + hbracketD hbracketF hkernel hentries hv hvg hslow hsideBound q hq hqmap hcutoff + initialLong hsub hzero + exact input.conclusion_of_reset (hcost := hcost) reset hresetBudget hden + (hdenBound.trans (Real.exp_le_exp.mpr hresetBudget)) hdenDvd + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates associatedGradedMap realPolynomialGroupMap + AllocatedExternalCandidateProblem.Refinement.problem + realSymbolHomogeneousPullbackHom CertifiedFullChartFiniteHistory.outer + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalCandidateProblem + +variable {L M : Type} {nMarkedBasis : ℕ} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (c : Basis (Fin nMarkedBasis) ℚ M) + (ν : Fin nMarkedBasis → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (c '' {i | j ≤ ν i})) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull separation : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration c ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom c ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation) + +local notation "kept" => (fun i : LayerSamplerVariables G I n B => + candidateSideCutoff separation ≤ A.sides i) + +theorem conclusion_of_normalized_affinePhysicalTerminal_zeroRestricted_degreeRule + {γ : Type} [Fintype γ] + (p0 : ℝ) (hp0 : 0 ≤ p0) (hpFull : 0 ≤ pFull) + (hDgeo : D.GeometryComplexityLE p0) (hFgeo : Fmark.GeometryComplexityLE p0) + (hcForward : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p0) + (hMap : ∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p0) + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (v : γ → D.filtration.AssociatedGraded) + (hW : BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule) + (hvspan : span ℚ (Set.range v) = W.toSubmodule) + (hγ : (Fintype.card γ : ℝ) ≤ p0) + (hvHeight : ∀ j i, rationalLogHeight + ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) ≤ p0) + (hvariables : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p0) + (q : ℝ) (l : ℕ) (hq0 : q ≤ p0) (hl : 0 < l) (hlBound : (l : ℝ) ≤ Real.exp p0) + (hcost0 : cost ≤ p0) + (initialLong : LayerSamplerVariables G I n B → Prop) + (hshort : ∀ i, ¬initialLong i → (A.sides i : ℝ) ≤ Real.exp p0) + (hzero : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors D.basis ω hD + (fun i : {i // initialLong i} => (A.sides i.val : ℝ)) q l W + (D.filtration.weightedAdaptedRealChartHom (fun _ : (P.chart z).Variables => 1) + (fun _ : {i // initialLong i} => 1) ((P.chart z).axisPolynomial initialLong (fun _ => 0)) + ((P.chart z).axisPolynomial_support initialLong (fun _ => 0)) + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) (P.candidate z).orbit))) + {outputCost : ℝ} {e : ℕ} + (input : data.SuccessorInputs (allocatedAffineCanonicalBudget s p0 pFull) e outputCost) : + Nonempty (P.Conclusion (max outputCost (candidateSideCutoffCost separation)) + (Real.exp (-outputCost)) (Real.exp (-outputCost))) := by + classical + let Vars := {i : LayerSamplerVariables G I n B // kept i} + have hvars : (Fintype.card Vars : ℝ) ≤ p0 := + (Nat.cast_le.mpr (Fintype.card_subtype_le kept)).trans hvariables + obtain ⟨hHeight0, hHeightInput, hHeightBracket, hHeightKernel, hHeightPoint⟩ := + allocatedAffineResetHeightLog_bounds hp0 + let H := ⌈Real.exp (allocatedAffineResetHeightLog p0)⌉₊ + obtain ⟨hH, hHBound, hd, hc, hbracketD, hbracketF⟩ := + D.nativeResetBracketGeometry_of_logBudget Fmark c hp0 hDgeo hFgeo hcForward hHeightBracket + obtain ⟨r, hr, hrp, bk, hbk⟩ := exists_marked_kernel_basis_commonHeight_of_dim + D.basis c φ hp0 (by simpa using hd) hc hMap + let : Fintype (SymbolBasisIndex (fun _ : Vars => 1) ω) := + D.filtration.ordinarySymbolBasisFintype D.basis ω hD + let : Fintype (SymbolBasisIndex (fun _ : Vars => 1) ν) := + Fmark.filtration.ordinarySymbolBasisFintype c ν hF + let vg := D.filtration.gradedImagePointwiseSpanningFamily Fmark.filtration φ hφ + c ν hF (fun _ : Vars => 1) v + obtain ⟨hvgspan, _, hvgHeight, hsrcCount, htgtCount, hvgCount, _, _⟩ := + D.filtration.ordinaryGradedImagePointwiseSpanning_controlled Fmark.filtration φ hφ + D.basis ω hD c ν hF W v hW hvspan hp0 (by simpa using hd) hc hγ hvars hvHeight + (fun i j => hMap j i) + have mapBounds := allocatedAffineResetMapBudget_bounds s hp0 hpFull + have bounds := allocatedAffineCanonicalBudget_bounds s hp0 hpFull + have expBounds := allocatedAffineCanonicalBudget_exp_bounds s hp0 hpFull + have hsrc : (Fintype.card (SymbolBasisIndex (fun _ : Vars => 1) ω) : ℝ) ≤ + allocatedAffineResetMapBudget s p0 pFull := by + simpa only [Nat.card_eq_fintype_card] using hsrcCount.trans mapBounds.pointwise + have htgt : (Fintype.card (SymbolBasisIndex (fun _ : Vars => 1) ν) : ℝ) ≤ + allocatedAffineResetMapBudget s p0 pFull := by + simpa only [Nat.card_eq_fintype_card] using htgtCount.trans mapBounds.pointwise + have hχ : (Fintype.card (SymbolBasisIndex (fun _ : Vars => 1) ν × γ) : ℝ) ≤ + allocatedAffineCanonicalNativeBudget s p0 pFull := by + simpa only [Nat.card_eq_fintype_card] using + (hvgCount.trans mapBounds.pointwise).trans bounds.native_map + have hHmap : (H : ℝ) ≤ Real.exp (allocatedAffineResetMapBudget s p0 pFull) := + hHBound.trans (Real.exp_le_exp.mpr mapBounds.height) + have hlmap : ((l * data.nFinal : ℕ) : ℝ) ≤ + Real.exp (allocatedAffineResetMapBudget s p0 pFull) := + allocatedAffineResetMapBudget_denominator s hp0 hpFull hlBound data.nFinal_bound + have hkernel : ∀ i j, RationalHeightLE (D.basis.repr (bk j : L) i) H := by + intro i j + exact (hbk j i).mono (Nat.ceil_mono (Real.exp_le_exp.mpr hHeightKernel)) + have hentries : ∀ i j, RationalHeightLE (c.repr (φ (D.basis j)) i) H := + fun i j => rationalHeightLE_ceil_exp ((hMap i j).trans hHeightInput) + have hv : ∀ j i, RationalHeightLE + ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) H := + fun j i => rationalHeightLE_ceil_exp ((hvHeight j i).trans hHeightInput) + have hvg : ∀ i z, RationalHeightLE + ((Fmark.filtration.polynomialSymbolBasis c ν hF (fun _ : Vars => 1)).repr (vg i) z) H := by + intro i z + exact (hvgHeight i z).mono (Nat.ceil_mono (Real.exp_le_exp.mpr hHeightPoint)) + have hside : Real.exp ((allocatedAffineCanonicalNativeBudget s p0 pFull + + allocatedAffineResetCompareExponent s) ^ allocatedAffineResetCompareExponent s) ≤ separation := by + rw [input.separation_eq] + exact expBounds.compare_cutoff + have hcutoff : Real.exp cost * ((s + 1 + 1 : ℕ) : ℝ) ≤ separation := by + rw [input.separation_eq] + simpa only [Nat.add_assoc] using expBounds.interpolation cost hcost0 + have hsub : ∀ i, kept i → initialLong i := by + intro i hi + by_contra hn + have hside0 : Real.exp p0 ≤ separation := by + rw [input.separation_eq] + exact expBounds.cost_cutoff p0 le_rfl + have hlong : separation < (A.sides i : ℝ) := + (lt_candidateSideCutoff separation).trans_le (Nat.cast_le.mpr hi) + exact (not_lt_of_ge ((hshort i hn).trans hside0)) hlong + exact P.conclusion_of_affinePhysicalTerminal_zeroRestricted_degreeRule Fmark φ hφ W c ν hF + basis lift Bphase budget pAffine pFull separation history data + ω hD input.surjective bk v hW hvspan vg hvgspan H l + (allocatedAffineResetMapBudget s p0 pFull) (allocatedAffineCanonicalNativeBudget s p0 pFull) + hH hl bounds.map_nonnegative bounds.native_nonnegative hsrc htgt hHmap hlmap + expBounds.map_absorption (hd.trans bounds.native_input) + (by simpa only [Fintype.card_fin] using hc.trans bounds.native_input) + (by simpa only [Fintype.card_fin] using hrp.trans bounds.native_input) + (hγ.trans bounds.native_input) hχ (hvars.trans bounds.native_input) + (hHmap.trans (Real.exp_le_exp.mpr bounds.native_map)) hbracketD hbracketF + hkernel hentries hv hvg expBounds.physical_absorption hside q + ((Real.exp_le_exp.mpr hq0).trans expBounds.original_absorption) + ((Real.exp_le_exp.mpr (add_le_add le_rfl hq0)).trans expBounds.mapped_absorption) + hcutoff initialLong hsub hzero input bounds.reset + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates associatedGradedMap realPolynomialGroupMap + AllocatedExternalCandidateProblem.Refinement.problem + realSymbolHomogeneousPullbackHom CertifiedFullChartFiniteHistory.outer + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalCandidateProblem + +variable {L M : Type} {nMarkedBasis : ℕ} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (c : Basis (Fin nMarkedBasis) ℚ M) + (ν : Fin nMarkedBasis → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (c '' {i | j ≤ ν i})) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull separation : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration c ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom c ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation) + +local notation "kept" => (fun i : LayerSamplerVariables G I n B => + candidateSideCutoff separation ≤ A.sides i) + +include data in +theorem conclusion_of_affinePhysicalTerminal_bounds_degreeRule + {γ : Type} [Fintype γ] + (p0 : ℝ) (hp0 : 0 ≤ p0) (hpFull : 0 ≤ pFull) + (hDgeo : D.GeometryComplexityLE p0) (hFgeo : Fmark.GeometryComplexityLE p0) + (hcForward : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p0) + (hMap : ∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p0) + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (v : γ → D.filtration.AssociatedGraded) + (hW : BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule) + (hvspan : span ℚ (Set.range v) = W.toSubmodule) + (hγ : (Fintype.card γ : ℝ) ≤ p0) + (hvHeight : ∀ j i, rationalLogHeight + ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) ≤ p0) + (hvariables : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p0) + (q : ℝ) (l : ℕ) (hq0 : q ≤ p0) (hl : 0 < l) (hlBound : (l : ℝ) ≤ Real.exp p0) + (hcost0 : cost ≤ p0) + (initialLong : LayerSamplerVariables G I n B → Prop) + (hshort : ∀ i, ¬initialLong i → (A.sides i : ℝ) ≤ Real.exp p0) + (hzero : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors D.basis ω hD + (fun i : {i // initialLong i} => (A.sides i.val : ℝ)) q l W + (D.filtration.weightedAdaptedRealChartHom (fun _ : (P.chart z).Variables => 1) + (fun _ : {i // initialLong i} => 1) ((P.chart z).axisPolynomial initialLong (fun _ => 0)) + ((P.chart z).axisPolynomial_support initialLong (fun _ => 0)) + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) (P.candidate z).orbit))) + (hseparation : separation = Real.exp (candidatePrimitiveFreezingCutoff s 1 + (allocatedAffineCanonicalBudget s p0 pFull))) + (hσ1 : ∀ j, σ j ≤ 1) + (Hchart : Fin m → ℝ) (hHchart : ∀ j, 0 ≤ Hchart j) + (hchart : ∀ j v, + ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ Hchart j * ‖v‖) + (hsmall : ∀ j, Hchart j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp p0) + (hscore : Real.exp (-p0) ≤ scoreThreshold) + (hmass : Real.exp (-p0) ≤ + Real.exp (-((2 * certifiedAffineCenterBudget pAffine + 3) ^ 3)) * massThreshold) + (hsurj : ∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) + (hξ1 : ξ ≤ 1) (ℓ : ℝ≥0) (hℓ : (ℓ : ℝ) ≤ Real.exp p0) + (hLip : ∀ x, letI := D.metricSpace; LipschitzWith ℓ (observable x)) + (hpositive : ∀ x y, (observable x y).im = 0 ∧ + 0 ≤ (observable x y).re ∧ (observable x y).re ≤ 1) + (hmark : ∀ i j, rationalLogHeight (Fmark.basis.repr (φ (D.basis i)) j) ≤ p0) + (htop : ∀ x : L, x ∈ D.filtration.gradedRefiltrationLayer W (s + 1) → φ x = 0 → x = 0) + {e : ℕ} + (hnet : ∀ accuracy : ℝ, 0 < accuracy → accuracy ≤ 1 → ∃ count : ℕ, + (count : ℝ) ≤ Real.exp ((p0 + Real.log (1 / accuracy) + e) ^ e) ∧ + ∃ centers : Fin count → integerBox N, + ∀ x ∈ integerBox N, ∃ i, ∀ y, + ‖observable x y - observable (centers i).val y‖ ≤ accuracy) + (outputCost : ℝ) + (lowerIH : A.DegreeGlobalizationAt (E := E) weight s + (RationalFilteredNilmanifold.refilteredQuotientNetExponent.{0, 0, 0} s 1 e + 2) + (finiteFreezingRecursiveParameter (candidatePrimitivePhysicalBudgetExponent s 1) + (allocatedAffineCanonicalBudget s p0 pFull)) outputCost) : + Nonempty (P.Conclusion (max outputCost (candidateSideCutoffCost separation)) + (Real.exp (-outputCost)) (Real.exp (-outputCost))) := by + have hc := (D.nativeResetBracketGeometry Fmark c hp0 hDgeo hFgeo hcForward).2.1 + let input := data.successorInputsOfBounds p0 hp0 hpFull hseparation hDgeo hFgeo + hvariables (by simpa only [Fintype.card_fin] using hc) hMap hσ1 Hchart hHchart hchart + hsmall hpoly hweight hscore hcost0 hmass ω hD hW hsurj hξ1 ℓ hℓ hLip hpositive + v hvspan hγ hcForward hmark hvHeight htop hnet outputCost lowerIH + exact P.conclusion_of_normalized_affinePhysicalTerminal_zeroRestricted_degreeRule + Fmark φ hφ W c ν hF basis lift Bphase budget pAffine pFull separation history data + p0 hp0 hpFull hDgeo hFgeo hcForward hMap ω hD v hW hvspan hγ hvHeight hvariables + q l hq0 hl hlBound hcost0 initialLong hshort hzero input + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffinePhysicalTerminalReset.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffinePhysicalTerminalReset.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7c813b6cf41e097194634f5622041143788aa89 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffinePhysicalTerminalReset.lean @@ -0,0 +1,853 @@ +import OAI.Combinatorics.Progressions.Estimates.GlobalMarkedPhysicalValueBounds +import OAI.Combinatorics.Progressions.Lattices.CertifiedAffineNormalizedBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped TensorProduct BigOperators +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom realChartSubstitute PolynomialRationalGrid PolynomialSlowBound + CertifiedFullChartFiniteHistory.outer + +theorem exists_allocatedCertifiedAffineControlledGlobalTerminal (t a : ℕ) : + ∃ Ce Cr : ℕ, 2 ≤ Ce ∧ 2 ≤ Cr ∧ + ∀ {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ i, Fintype (B i)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {sampler : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) sampler D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + {ι η : Type} [Fintype ι] [Fintype η] + (bF : Basis ι ℚ M) (ω : ι → ℕ) + (hF : ∀ j, Fmark.layer j = span ℚ (bF '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ Fmark.AssociatedGraded) + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.AssociatedGraded ⧸ W.toSubmodule))) + (lift : (Fmark.AssociatedGraded ⧸ W.toSubmodule) →ₗ[ℚ] Fmark.AssociatedGraded) + (Z : Fmark.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (Bphase budget pAffine : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark bF ω hF J W.toSubmodule basis lift + Z Set.univ U poly N Bphase t) + (affine : P.CertifiedAffineRefinement history.K pAffine), + BasisGradedSubmodule (Fmark.associatedGradedBasis bF ω hF) ω W.toSubmodule → + FullChartControlledFactors Fmark bF ω hF J poly N history.outer.1 history.outer.2 budget → + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + Fmark.realPolynomialSymbolHom bF ω hF (fullTaggedVariableWeight (X := X) J) + (Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked) = Z → + τ ≤ 1 → ξ ≤ 1 → (∀ j, σ j ≤ 1) → + ∀ (Cgeo : Fin m → ℝ), (∀ j, 0 ≤ Cgeo j) → + (∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) → + (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1) → + ∀ (H : ℕ) (pFull : ℝ), 1 ≤ H → 0 ≤ pFull → + (Fintype.card ι : ℝ) ≤ pFull → + (Fintype.card (X ⊕ (Σ j, J j)) : ℝ) ≤ pFull → + (H : ℝ) ≤ Real.exp pFull → + Real.exp budget * (Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine)) ^ t ≤ + Real.exp pFull → + (∀ i j k, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ k) H) → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ pFull → + (((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ t * Real.exp budget * + (actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) pFull + (((pAffine + ((pAffine+2)^2+2)^63)+2)^8)) ^ t ≤ Real.exp ((pFull + 2) ^ a)) → + let wt := fullTaggedVariableWeight (X := X) J + let β := affine.globalChart + let δ := affine.slowChart + let pull := Fmark.realSymbolHomogeneousPullbackHom bF ω hF wt wt + (fun i => weightedHomogeneousComponent wt (wt i) (β i)) + (fun _ => weightedHomogeneousComponent_isWeightedHomogeneous _ _) + 0 < affine.commonDenominator ∧ + (affine.commonDenominator : ℝ) ≤ Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine) ∧ + ∃ q nFinal : ℕ, 0 < q ∧ (q : ℝ) ≤ Real.exp budget ∧ + 0 < nFinal ∧ (nFinal : ℝ) ≤ Real.exp ((pFull + Cr) ^ Cr) ∧ + q * affine.commonDenominator ^ t ∣ nFinal ∧ + ∃ factors : GlobalMarkedNativeFactors Fmark bF ω hF wt W + (Fmark.weightedAdaptedRealChartHom wt wt β affine.globalChart_support + (Fmark.realification.polynomialOrbitCoordinates wt marked)) + (pull history.outer.1) (pull history.outer.2), + Fmark.PolynomialRationalGrid bF wt nFinal factors.right ∧ + (∀ z : affine.refinement.problem.productive, + let C := affine.refinement.problem.chart z + Fmark.PolynomialSlowBound bF (fun _ : C.Variables => 1) + (fun i => (sampler.sides i.val : ℝ)) (Real.exp ((pFull + Ce) ^ Ce)) + (Fmark.weightedAdaptedRealChartHom wt (fun _ : C.Variables => 1) + (integerSampledRealChart C.integerChart) C.integerChart_support factors.left)) ∧ + ∀ {Υ : Type} [Fintype Υ] (v : Υ → ℕ), (∀ i, 0 < v i) → + (Fintype.card Υ : ℝ) ≤ pFull → + ∀ (γ : (X ⊕ (Σ j, J j)) → MvPolynomial Υ ℝ) + (hγ : ∀ i, γ i ∈ weightedSupportLE v (wt i)) + (T : Υ → ℝ), (∀ i, 0 < T i) → + ∀ mass : ℝ, 1 ≤ mass → + (∀ i, realPolynomialMass + (scaleMvPolynomialAxes T (MvPolynomial.aeval γ (δ i))) ≤ mass) → + (((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ t * + Real.exp budget * mass ^ t ≤ Real.exp ((pFull + 2) ^ a)) → + Fmark.PolynomialSlowBound bF v T (Real.exp ((pFull + Ce) ^ Ce)) + (Fmark.weightedAdaptedRealChartHom wt v γ hγ factors.left) := by + classical + obtain ⟨Ce, Cr, hCe, hCr, hterminal⟩ := exists_allocatedCertifiedAffineGlobalTerminal t a + refine ⟨Ce, Cr, hCe, hCr, ?_⟩ + intro m G X _ _ I E J _ _ n B _ U btag Rad σ S hb o hRad hσ N poly hm + τ ξ stride cells center _ sampler L M _ _ _ _ s d D Fmark φ marked observable weight + cost massThreshold scoreThreshold P ι η _ _ bF ω hF W basis lift Z Bphase budget pAffine + history affine hW hcontrol hpoly hZ hτ1 hξ1 hσ1 Cgeo hCgeo hchart hsmall + H pFull hH hpFull hι hvars hHp hden hbracket hsample hmass + obtain ⟨hDpos, hDbound, q, nFinal, hq, hqB, hn, hnB, hdiv, factors, hgrid, hslow⟩ := + hterminal P bF ω hF W basis lift Z Bphase budget pAffine history affine hW hcontrol + hpoly hZ H pFull hH hpFull hι hvars hHp hden hbracket + refine ⟨hDpos, hDbound, q, nFinal, hq, hqB, hn, hnB, hdiv, factors, + hgrid, ?_, hslow⟩ + intro z + let C := affine.refinement.problem.chart z + have hretained (x) (hx : ∀ j, (fun i => x (Sum.inr ⟨j,i⟩)) ∈ U j) : x ∈ history.K := + history.retained x (Set.mem_univ _) hx + have hdim (j : Fin m) : (Fintype.card (J j) : ℝ) ≤ pFull := by + exact (Nat.cast_le.mpr (Fintype.card_le_of_injective + (fun i : J j => (Sum.inr ⟨j,i⟩ : X ⊕ (Σ j,J j))) + (by intro i k h; simpa using h))).trans hvars + have hlocal : (Fintype.card C.Variables : ℝ) ≤ pFull := + (Nat.cast_le.mpr (Fintype.card_subtype_le C.keep)).trans hsample + have hside (i : C.Variables) : (0 : ℝ) < sampler.sides i.val := + Nat.cast_pos.mpr (sampler.sides_pos i.val) + apply hslow (fun _ : C.Variables => 1) (fun _ => Nat.zero_lt_one) hlocal + (integerSampledRealChart C.integerChart) C.integerChart_support + (fun i => (sampler.sides i.val : ℝ)) hside + (actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) pFull + (((pAffine + ((pAffine+2)^2+2)^63)+2)^8)) + (actualCandidateSlowProjectionMassBudget_one_le _ _ hpFull) ?_ hmass + intro i + exact affine.slowChart_mass_sides hretained hpFull hdim hτ1 hξ1 hpoly hσ1 + Cgeo hCgeo hchart hsmall z i + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped TensorProduct BigOperators Classical +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom realChartSubstitute PolynomialRationalGrid PolynomialSlowBound + CertifiedFullChartFiniteHistory.outer + +theorem exists_allocatedCertifiedAffineGlobalPhysicalTerminal (t a : ℕ) : + ∃ Ce Cr : ℕ, 2 ≤ Ce ∧ 2 ≤ Cr ∧ + ∀ {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ i, Fintype (B i)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {sampler : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) sampler D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + {ι η : Type} [Fintype ι] [Fintype η] + (bF : Basis ι ℚ M) (ω : ι → ℕ) + (hF : ∀ j, Fmark.layer j = span ℚ (bF '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ Fmark.AssociatedGraded) + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.AssociatedGraded ⧸ W.toSubmodule))) + (lift : (Fmark.AssociatedGraded ⧸ W.toSubmodule) →ₗ[ℚ] Fmark.AssociatedGraded) + (Z : Fmark.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (Bphase budget pAffine : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark bF ω hF J W.toSubmodule basis lift + Z Set.univ U poly N Bphase t) + (affine : P.CertifiedAffineRefinement history.K pAffine), + BasisGradedSubmodule (Fmark.associatedGradedBasis bF ω hF) ω W.toSubmodule → + FullChartControlledFactors Fmark bF ω hF J poly N history.outer.1 history.outer.2 budget → + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + Fmark.realPolynomialSymbolHom bF ω hF (fullTaggedVariableWeight (X := X) J) + (Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked) = Z → + τ ≤ 1 → ξ ≤ 1 → (∀ j, σ j ≤ 1) → + ∀ (Cgeo : Fin m → ℝ), (∀ j, 0 ≤ Cgeo j) → + (∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) → + (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1) → + ∀ (H : ℕ) (pFull : ℝ), 1 ≤ H → 0 ≤ pFull → + (Fintype.card ι : ℝ) ≤ pFull → + (Fintype.card (X ⊕ (Σ j, J j)) : ℝ) ≤ pFull → + (H : ℝ) ≤ Real.exp pFull → + Real.exp budget * (Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine)) ^ t ≤ + Real.exp pFull → + (∀ i j k, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ k) H) → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ pFull → + (((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ t * Real.exp budget * + (actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) pFull + (((pAffine + ((pAffine+2)^2+2)^63)+2)^8)) ^ t ≤ Real.exp ((pFull + 2) ^ a)) → + let wt := fullTaggedVariableWeight (X := X) J + let β := affine.globalChart + let δ := affine.slowChart + let pull := Fmark.realSymbolHomogeneousPullbackHom bF ω hF wt wt + (fun i => weightedHomogeneousComponent wt (wt i) (β i)) + (fun _ => weightedHomogeneousComponent_isWeightedHomogeneous _ _) + 0 < affine.commonDenominator ∧ + (affine.commonDenominator : ℝ) ≤ Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine) ∧ + ∃ q nFinal : ℕ, 0 < q ∧ (q : ℝ) ≤ Real.exp budget ∧ + 0 < nFinal ∧ (nFinal : ℝ) ≤ Real.exp ((pFull + Cr) ^ Cr) ∧ + q * affine.commonDenominator ^ t ∣ nFinal ∧ + ∃ factors : GlobalMarkedNativeFactors Fmark bF ω hF wt W + (Fmark.weightedAdaptedRealChartHom wt wt β affine.globalChart_support + (Fmark.realification.polynomialOrbitCoordinates wt marked)) + (pull history.outer.1) (pull history.outer.2), + Fmark.PolynomialRationalGrid bF wt nFinal factors.right ∧ + (∀ z : affine.refinement.problem.productive, + let C := affine.refinement.problem.chart z + Fmark.PolynomialSlowBound bF (fun _ : C.Variables => 1) + (fun i => (sampler.sides i.val : ℝ)) (Real.exp ((pFull + Ce) ^ Ce)) + (Fmark.weightedAdaptedRealChartHom wt (fun _ : C.Variables => 1) + (integerSampledRealChart C.integerChart) C.integerChart_support factors.left)) ∧ + (∀ x ∈ integerBox N, ∀ i, + |(bF.baseChange ℝ).repr + (Fmark.realification.polynomialOrbitEval wt (P.physicalIntegerPoint x) + ((Fmark.realification.polynomialOrbitCoordinates wt).symm factors.left)).coord i| ≤ + Real.exp ((pFull + Ce) ^ Ce)) ∧ + (∀ x : X → ℤ, (bF.baseChange ℝ).equivFun + (Fmark.realification.polynomialOrbitEval wt (P.physicalIntegerPoint x) + ((Fmark.realification.polynomialOrbitCoordinates wt).symm factors.right)).coord ∈ + realDenominatorGrid nFinal) ∧ + ∀ {Υ : Type} [Fintype Υ] (v : Υ → ℕ), (∀ i, 0 < v i) → + (Fintype.card Υ : ℝ) ≤ pFull → + ∀ (γ : (X ⊕ (Σ j, J j)) → MvPolynomial Υ ℝ) + (hγ : ∀ i, γ i ∈ weightedSupportLE v (wt i)) + (T : Υ → ℝ), (∀ i, 0 < T i) → + ∀ mass : ℝ, 1 ≤ mass → + (∀ i, realPolynomialMass + (scaleMvPolynomialAxes T (MvPolynomial.aeval γ (δ i))) ≤ mass) → + (((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ t * + Real.exp budget * mass ^ t ≤ Real.exp ((pFull + 2) ^ a)) → + Fmark.PolynomialSlowBound bF v T (Real.exp ((pFull + Ce) ^ Ce)) + (Fmark.weightedAdaptedRealChartHom wt v γ hγ factors.left) := by + classical + obtain ⟨Ce, Cr, hCe, hCr, hterminal⟩ := + exists_allocatedCertifiedAffineControlledGlobalTerminal t a + refine ⟨Ce, Cr, hCe, hCr, ?_⟩ + intro m G X _ _ I E J _ _ n B _ U btag Rad σ S hb o hRad hσ N poly hm + τ ξ stride cells center _ sampler L M _ _ _ _ s d D Fmark φ marked observable weight + cost massThreshold scoreThreshold P ι η _ _ bF ω hF W basis lift Z Bphase budget pAffine + history affine hW hcontrol hpoly hZ hτ1 hξ1 hσ1 Cgeo hCgeo hchart hsmall + H pFull hH hpFull hι hvars hHp hden hbracket hsample hmass + obtain ⟨hDpos, hDbound, q, nFinal, hq, hqB, hn, hnB, hdiv, factors, + hgrid, hlocal, hcharts⟩ := + hterminal P bF ω hF W basis lift Z Bphase budget pAffine history affine hW hcontrol + hpoly hZ hτ1 hξ1 hσ1 Cgeo hCgeo hchart hsmall H pFull hH hpFull hι hvars hHp + hden hbracket hsample hmass + refine ⟨hDpos, hDbound, q, nFinal, hq, hqB, hn, hnB, hdiv, factors, + hgrid, hlocal, ?_, ?_, hcharts⟩ + · intro x hx i + have hretained (y) (hy : ∀ j, (fun i => y (Sum.inr ⟨j,i⟩)) ∈ U j) : y ∈ history.K := + history.retained y (Set.mem_univ _) hy + have hdim (j : Fin m) : (Fintype.card (J j) : ℝ) ≤ pFull := by + exact (Nat.cast_le.mpr (Fintype.card_le_of_injective + (fun i : J j => (Sum.inr ⟨j,i⟩ : X ⊕ (Σ j,J j))) + (by intro i k h; simpa using h))).trans hvars + rw [← Fmark.realification.polynomialOrbitRealEval_integer, + Fmark.nativeFrozenMarkedOrbitCoordinates_symm_realEval] + apply Fmark.value_bound_of_terminal_chart_control bF (fullTaggedVariableWeight J) + affine.slowChart pFull budget a Ce hpFull factors.left hcharts _ + (actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) pFull + (((pAffine + ((pAffine+2)^2+2)^63)+2)^8)) + (actualCandidateSlowProjectionMassBudget_one_le _ _ hpFull) ?_ hmass i + intro z + exact (affine.slowChart_physical_abs_le hretained hdim x hx z).trans + (actualCandidateSlowProjectionMassBudget_max_le _ _ hpFull) + · intro x + rw [← Fmark.realification.polynomialOrbitRealEval_integer, + Fmark.nativeFrozenMarkedOrbitCoordinates_symm_realEval] + exact Fmark.polynomialRationalGrid_value bF (fullTaggedVariableWeight J) + nFinal factors.right hgrid (P.physicalIntegerPoint x) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped Classical TensorProduct BigOperators +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom realSymbolGradeEvaluation + CertifiedFullChartFiniteHistory.outer + +noncomputable def allocatedEarlyAffineLeftExponent (s a : ℕ) : ℕ := + Classical.choose (exists_allocatedCertifiedAffineGlobalPhysicalTerminal s a) + +noncomputable def allocatedEarlyAffineRightExponent (s a : ℕ) : ℕ := + Classical.choose (Classical.choose_spec (exists_allocatedCertifiedAffineGlobalPhysicalTerminal s a)) + +theorem allocatedEarlyAffine_exponent_bounds (s a : ℕ) : + 2 ≤ allocatedEarlyAffineLeftExponent s a ∧ 2 ≤ allocatedEarlyAffineRightExponent s a := by + have h := Classical.choose_spec + (Classical.choose_spec (exists_allocatedCertifiedAffineGlobalPhysicalTerminal s a)) + exact ⟨h.1, h.2.1⟩ + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I Deck J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M s} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem + +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := Deck) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + (keep : ℕ → LayerSamplerVariables G I n B → Prop) + {ι κ η : Type} {χ : ℕ → Type} [Fintype ι] [Fintype κ] [∀ r, Fintype (χ r)] [Fintype η] + (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (bD '' {i | j ≤ ω i})) + (bF : Basis κ ℚ M) (ν : κ → ℕ) + (hF : ∀ j, Fmark.layer j = span ℚ (bF '' {i | j ≤ ν i})) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.layer j) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + +local notation "fast" => W.map (D.filtration.associatedGradedMap Fmark φ hφ) +local notation "gmark" => Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked +local notation "Z" => Fmark.realPolynomialSymbolHom bF ν hF (fullTaggedVariableWeight J) gmark + +structure AffinePhysicalTerminalData + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.AssociatedGraded ⧸ (fast).toSubmodule))) + (lift : (Fmark.AssociatedGraded ⧸ (fast).toSubmodule) →ₗ[ℚ] Fmark.AssociatedGraded) + (Bphase budget pAffine pFull : ℝ) (a : ℕ) + (history : CertifiedFullChartFiniteHistory Fmark bF ν hF J (fast).toSubmodule + basis lift Z Set.univ U poly N Bphase s) + (separation : ℝ) where + selected : P.CertifiedThresholdAffineRefinement history.K pAffine separation + denominator_pos : 0 < selected.affine.commonDenominator + denominator_bound : (selected.affine.commonDenominator : ℝ) ≤ + Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine) + q : ℕ + nFinal : ℕ + q_pos : 0 < q + q_bound : (q : ℝ) ≤ Real.exp budget + nFinal_pos : 0 < nFinal + nFinal_bound : (nFinal : ℝ) ≤ + Real.exp ((pFull + allocatedEarlyAffineRightExponent s a) ^ allocatedEarlyAffineRightExponent s a) + denominator_dvd : q * selected.affine.commonDenominator ^ s ∣ nFinal + factors : + let wt := fullTaggedVariableWeight (X := X) J + let β := selected.affine.globalChart + let pull := Fmark.realSymbolHomogeneousPullbackHom bF ν hF wt wt + (fun i => weightedHomogeneousComponent wt (wt i) (β i)) + (fun _ => weightedHomogeneousComponent_isWeightedHomogeneous _ _) + GlobalMarkedNativeFactors Fmark bF ν hF wt fast + (Fmark.weightedAdaptedRealChartHom wt wt β selected.affine.globalChart_support + (Fmark.realification.polynomialOrbitCoordinates wt marked)) + (pull history.outer.1) (pull history.outer.2) + right_grid : Fmark.PolynomialRationalGrid bF (fullTaggedVariableWeight J) nFinal factors.right + local_left : ∀ z : selected.affine.refinement.problem.productive, + let C := selected.affine.refinement.problem.chart z + Fmark.PolynomialSlowBound bF (fun _ : C.Variables => 1) + (fun i => (A.sides i.val : ℝ)) + (Real.exp ((pFull + allocatedEarlyAffineLeftExponent s a) ^ allocatedEarlyAffineLeftExponent s a)) + (Fmark.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) (fun _ : C.Variables => 1) + (integerSampledRealChart C.integerChart) C.integerChart_support factors.left) + physical_left : ∀ x ∈ integerBox N, ∀ i, + |(bF.baseChange ℝ).repr + (Fmark.realification.polynomialOrbitEval (fullTaggedVariableWeight J) (P.physicalIntegerPoint x) + ((Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J)).symm factors.left)).coord i| ≤ + Real.exp ((pFull + allocatedEarlyAffineLeftExponent s a) ^ allocatedEarlyAffineLeftExponent s a) + physical_right : ∀ x : X → ℤ, (bF.baseChange ℝ).equivFun + (Fmark.realification.polynomialOrbitEval (fullTaggedVariableWeight J) (P.physicalIntegerPoint x) + ((Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J)).symm factors.right)).coord ∈ + realDenominatorGrid nFinal + +theorem exists_affinePhysicalTerminalData + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.AssociatedGraded ⧸ (fast).toSubmodule))) + (lift : (Fmark.AssociatedGraded ⧸ (fast).toSubmodule) →ₗ[ℚ] Fmark.AssociatedGraded) + (Bphase budget pAffine : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark bF ν hF J (fast).toSubmodule + basis lift Z Set.univ U poly N Bphase s) + (hfast : BasisGradedSubmodule (Fmark.associatedGradedBasis bF ν hF) ν (fast).toSubmodule) + (hcontrol : FullChartControlledFactors Fmark bF ν hF J poly N + history.outer.1 history.outer.2 budget) + {blocks : ℕ} + (hcertificate : RationalTaggedConstraintCertificate J Set.univ history.K pAffine blocks) + (hpAffine : 0 ≤ pAffine) (hdim : (Fintype.card (Σ j, J j) : ℝ) ≤ pAffine) + (hblocks : (blocks : ℝ) ≤ pAffine) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hτ : τ ≤ 1) (hξ : ξ ≤ 1) (hσone : ∀ j, σ j ≤ 1) + (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1) + (hmass : 0 < massThreshold) (H : ℕ) (a : ℕ) (pFull : ℝ) + (hH : 1 ≤ H) (hpFull : 0 ≤ pFull) + (hκ : (Fintype.card κ : ℝ) ≤ pFull) + (htags : (Fintype.card (X ⊕ (Σ j, J j)) : ℝ) ≤ pFull) + (hHExp : (H : ℝ) ≤ Real.exp pFull) + (hden : Real.exp budget * (Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine)) ^ s ≤ + Real.exp pFull) + (hbracket : ∀ i j k, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ k) H) + (hsampler : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ pFull) + (hmassFull : (((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ s * Real.exp budget * + (actualCandidateSlowProjectionMassBudget m (Fintype.card (LayerSamplerVariables G I n B)) pFull + (((pAffine + ((pAffine+2)^2+2)^63)+2)^8)) ^ s ≤ Real.exp ((pFull + 2) ^ a))) + (separation : ℝ) (hseparation : certifiedAffineLongSideBound pAffine ≤ separation) : + Nonempty (P.AffinePhysicalTerminalData bF ν hF hφ W basis lift + Bphase budget pAffine pFull a history separation) := by + classical + have hretained (point) (hpoint : ∀ j, (fun i => point (Sum.inr ⟨j,i⟩)) ∈ U j) : + point ∈ history.K := history.retained point (Set.mem_univ _) hpoint + have hcap (j : Fin m) : + Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ Real.exp pAffine := + (hsmall j).trans (Real.one_le_exp_iff.mpr hpAffine) + obtain ⟨selected⟩ := P.exists_certifiedThresholdAffineRefinement hσone history.K + (p := pAffine) (blocks := blocks) hcertificate hretained hpAffine hdim hblocks + Cgeo hCgeo hchart hpoly hcap separation hseparation hmass + obtain ⟨hDpos, hDbound, q, nFinal, hq, hqB, hn, hnB, hdiv, factors, + hgrid, hlocal, hphysicalLeft, hphysicalRight, _⟩ := + ((Classical.choose_spec + (Classical.choose_spec (exists_allocatedCertifiedAffineGlobalPhysicalTerminal s a))).2.2) + selected.freezing.problem bF ν hF fast basis lift Z Bphase budget pAffine + history selected.affine hfast hcontrol hpoly rfl hτ hξ hσone Cgeo hCgeo hchart hsmall + H pFull hH hpFull hκ htags hHExp hden hbracket hsampler hmassFull + exact ⟨{ + selected := selected + denominator_pos := hDpos + denominator_bound := hDbound + q := q + nFinal := nFinal + q_pos := hq + q_bound := hqB + nFinal_pos := hn + nFinal_bound := hnB + denominator_dvd := hdiv + factors := factors + right_grid := hgrid + local_left := hlocal + physical_left := hphysicalLeft + physical_right := hphysicalRight + }⟩ + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates associatedGradedMap realPolynomialGroupMap + AllocatedExternalCandidateProblem.Refinement.problem + realSymbolHomogeneousPullbackHom CertifiedFullChartFiniteHistory.outer + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalCandidateProblem + +variable {L M : Type} {nMarkedBasis : ℕ} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF : ℕ} + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (c : Basis (Fin nMarkedBasis) ℚ M) + (ν : Fin nMarkedBasis → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (c '' {i | j ≤ ν i})) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull separation : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration c ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom c ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData c ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation) + +local notation "kept" => (fun i : LayerSamplerVariables G I n B => + candidateSideCutoff separation ≤ A.sides i) + +theorem exists_affinePhysicalTerminal_nativeReset_of_zero_restriction + {κK μ χ : Type} [Fintype κK] [Fintype μ] [Fintype χ] + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (hsurj : ∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) + (bk : Basis κK ℚ (LinearMap.ker φ.toLinearMap)) + (v : μ → D.filtration.AssociatedGraded) + (hW : BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule) + (hvspan : span ℚ (Set.range v) = W.toSubmodule) + (vg : χ → Fmark.filtration.PolynomialSymbol (fun _ : {i // kept i} => 1)) + (hvgspan : span ℚ (Set.range vg) = + (Fmark.filtration.symbolPointwiseSubalgebra c ν hF (fun _ : {i // kept i} => 1) + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))).toSubmodule) + [Fintype (SymbolBasisIndex (fun _ : {i // kept i} => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : {i // kept i} => 1) ν)] + (H l : ℕ) (pMap pNative : ℝ) + (hH : 1 ≤ H) (hl : 0 < l) (hpMap : 0 ≤ pMap) (hpNative : 0 ≤ pNative) + (hsrc : (Fintype.card (SymbolBasisIndex (fun _ : {i // kept i} => 1) ω) : ℝ) ≤ pMap) + (htgt : (Fintype.card (SymbolBasisIndex (fun _ : {i // kept i} => 1) ν) : ℝ) ≤ pMap) + (hHmap : (H : ℝ) ≤ Real.exp pMap) + (hlmap : ((l * data.nFinal : ℕ) : ℝ) ≤ Real.exp pMap) + (hmabsorb : Real.exp ((pMap + 2) ^ 4) ≤ Real.exp pNative) + (hd : (d : ℝ) ≤ pNative) (hc : (nMarkedBasis : ℝ) ≤ pNative) + (hk : (Fintype.card κK : ℝ) ≤ pNative) + (hμ : (Fintype.card μ : ℝ) ≤ pNative) + (hχ : (Fintype.card χ : ℝ) ≤ pNative) + (hvars : (Fintype.card {i // kept i} : ℝ) ≤ pNative) + (hHp : (H : ℝ) ≤ Real.exp pNative) + (hbracketD : ∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) H) + (hbracketF : ∀ i j k, RationalHeightLE (c.repr ⁅c i, c j⁆ k) H) + (hkernel : ∀ i j, RationalHeightLE (D.basis.repr (bk j : L) i) H) + (hentries : ∀ k i, RationalHeightLE (c.repr (φ (D.basis i)) k) H) + (hv : ∀ j i, RationalHeightLE + ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) H) + (hvg : ∀ i z, RationalHeightLE + ((Fmark.filtration.polynomialSymbolBasis c ν hF (fun _ : {i // kept i} => 1)).repr (vg i) z) H) + (hslow : Real.exp ((pFull + allocatedEarlyAffineLeftExponent (s + 1) 4) ^ + allocatedEarlyAffineLeftExponent (s + 1) 4) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ))) + (hsideBound : Real.exp ((pNative + allocatedAffineResetCompareExponent s) ^ + allocatedAffineResetCompareExponent s) ≤ separation) + (q : ℝ) + (hq : Real.exp q ≤ Real.exp ((pNative + 2) ^ (1 : ℕ))) + (hqmap : Real.exp ((pMap + 2) ^ 3 + q) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ))) + (hcutoff : Real.exp cost * ((s + 1 + 1 : ℕ) : ℝ) ≤ separation) + (initialLong : LayerSamplerVariables G I n B → Prop) + (hsub : ∀ i, kept i → initialLong i) + (hzero : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors D.basis ω hD + (fun i : {i // initialLong i} => (A.sides i.val : ℝ)) q l W + (D.filtration.weightedAdaptedRealChartHom (fun _ : (P.chart z).Variables => 1) + (fun _ : {i // initialLong i} => 1) ((P.chart z).axisPolynomial initialLong (fun _ => 0)) + ((P.chart z).axisPolynomial_support initialLong (fun _ => 0)) + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) (P.candidate z).orbit))) : + ∃ denominator : ℕ, 0 < denominator ∧ + (denominator : ℝ) ≤ Real.exp (allocatedAffineResetLogBudget s pNative) ∧ + data.nFinal ∣ denominator ∧ + Nonempty (AllocatedExternalGlobalNativeResetFamily Fmark φ hφ + data.selected.problem kept (data.selected.common_keep hcost) W data.factors + (Real.exp (allocatedAffineResetLogBudget s pNative)) denominator) := by + classical + have hreset := Classical.choose_spec (Classical.choose_spec + (Classical.choose_spec (exists_allocatedCertifiedAffineFamilyReset s 1))) + obtain ⟨mMap, denominator, hmMap, hmMapBound, hdiv, hden, hdenBound, hmMapDen, hrun⟩ := + hreset.2.2.2 (sampler := A) (E := E) D Fmark φ hφ ω hD c ν hF hsurj kept + bk W v hW hvspan vg hvgspan H l data.nFinal pMap pNative hH hl data.nFinal_pos + hpMap hpNative hsrc htgt hHmap hlmap hmabsorb hd (by simpa using hc) hk hμ hχ + (by convert hvars using 1; simp only [Fintype.card_eq_nat_card]) hHp + hbracketD hbracketF hkernel hentries hv hvg + refine ⟨denominator, hden, hdenBound, (dvd_mul_left data.nFinal l).trans (hdiv.trans hmMapDen), ?_⟩ + have hside (i : {i // kept i}) : + Real.exp ((pNative + allocatedAffineResetCompareExponent s) ^ + allocatedAffineResetCompareExponent s) ≤ (A.sides i.val : ℝ) := + hsideBound.trans ((lt_candidateSideCutoff separation).le.trans (Nat.cast_le.mpr i.property)) + have hlong (i : LayerSamplerVariables G I n B) (hi : kept i) : + separation ≤ layerSamplerBox B U b S i := by + rw [allocatedParameterBox_side_eq B U b S i] + exact (lt_candidateSideCutoff separation).le.trans (Nat.cast_le.mpr hi) + apply hrun marked observable weight data.selected.freezing.problem data.selected.affine + (data.selected.common_keep hcost) _ _ data.factors data.right_grid + · intro z + exact Fmark.filtration.polynomialSlowBound_mono c + (fun _ : (data.selected.problem.chart z).Variables => 1) + (fun i => (A.sides i.val : ℝ)) (fun i => Nat.cast_pos.mpr (A.sides_pos i.val)) + hslow _ (data.local_left z) + · exact hside + · exact hq + · exact hqmap + · exact data.selected.original_dense + · exact hcutoff + · exact hlong + · exact data.selected.withKeep_nativeFactors_of_zero_restriction + kept (data.selected.common_keep hcost) initialLong + (fun z i hi => hsub i hi.2) D.basis ω hD q l W hzero + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +def affineResetNativeBudget (C : ℕ) (pFull pMap q : ℝ) : ℝ := + pFull + pMap + max q 0 + (pFull + C) ^ C + (pMap + 2) ^ 4 + +theorem affineResetNativeBudget_bounds (C : ℕ) {pFull pMap q : ℝ} + (hFull : 0 ≤ pFull) (hMap : 0 ≤ pMap) : + let pNative := affineResetNativeBudget C pFull pMap q + 0 ≤ pNative ∧ pFull ≤ pNative ∧ pMap ≤ pNative ∧ q ≤ pNative ∧ + (pFull + C) ^ C ≤ pNative ∧ (pMap + 2) ^ 4 ≤ pNative ∧ + (pMap + 2) ^ 3 + q ≤ pNative := by + have hq0 : 0 ≤ max q 0 := le_max_right _ _ + have hq : q ≤ max q 0 := le_max_left _ _ + have hslow : 0 ≤ (pFull + C) ^ C := pow_nonneg (by positivity) _ + have hmap4 : 0 ≤ (pMap + 2) ^ 4 := pow_nonneg (by linarith) _ + have h34 : (pMap + 2) ^ 3 ≤ (pMap + 2) ^ 4 := + pow_le_pow_right₀ (by linarith) (by omega) + dsimp only [affineResetNativeBudget] + constructor + · linarith + constructor + · linarith + constructor + · linarith + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +theorem affineResetNativeBudget_exp_bounds (C : ℕ) {pFull pMap q : ℝ} + (hFull : 0 ≤ pFull) (hMap : 0 ≤ pMap) : + let pNative := affineResetNativeBudget C pFull pMap q + 0 ≤ pNative ∧ pFull ≤ pNative ∧ pMap ≤ pNative ∧ + Real.exp ((pMap + 2) ^ 4) ≤ Real.exp pNative ∧ + Real.exp ((pFull + C) ^ C) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) ∧ + Real.exp q ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) ∧ + Real.exp ((pMap + 2) ^ 3 + q) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) := by + obtain ⟨hp, hfull, hmap, hq, hslow, hmap4, hmapq⟩ := + affineResetNativeBudget_bounds C hFull hMap (q := q) + refine ⟨hp, hfull, hmap, Real.exp_le_exp.mpr hmap4, ?_, ?_, ?_⟩ <;> + apply Real.exp_le_exp.mpr <;> simp only [pow_one] <;> linarith + +noncomputable def allocatedAffineResetNativeBudget (s : ℕ) (pFull pMap q : ℝ) : ℝ := + affineResetNativeBudget (allocatedEarlyAffineLeftExponent (s + 1) 4) pFull pMap q + +theorem allocatedAffineResetNativeBudget_exp_bounds (s : ℕ) {pFull pMap q : ℝ} + (hFull : 0 ≤ pFull) (hMap : 0 ≤ pMap) : + let pNative := allocatedAffineResetNativeBudget s pFull pMap q + let Ce := allocatedEarlyAffineLeftExponent (s + 1) 4 + 0 ≤ pNative ∧ pFull ≤ pNative ∧ pMap ≤ pNative ∧ + Real.exp ((pMap + 2) ^ 4) ≤ Real.exp pNative ∧ + Real.exp ((pFull + Ce) ^ Ce) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) ∧ + Real.exp q ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) ∧ + Real.exp ((pMap + 2) ^ 3 + q) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) := + affineResetNativeBudget_exp_bounds (allocatedEarlyAffineLeftExponent (s + 1) 4) hFull hMap + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical TensorProduct +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates associatedGradedMap realPolynomialGroupMap + AllocatedExternalCandidateProblem.Refinement.problem + realSymbolHomogeneousPullbackHom CertifiedFullChartFiniteHistory.outer + +theorem exists_allocatedAffinePhysicalTerminalReset (s : ℕ) : + ∃ Ccompare Cf Cnative : ℕ, 2 ≤ Ccompare ∧ 2 ≤ Cf ∧ 2 ≤ Cnative ∧ + ∀ {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ i, Fintype (B i)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ narrow : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {sampler : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ narrow stride cells center} + {L M κ ξ μ χ : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [Fintype κ] [Fintype ξ] [Fintype μ] [Fintype χ] + {d f : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (bF : Basis κ ℚ M) (ν : κ → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (bF '' {i | j ≤ ν i})), + (∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) → + ∀ (separation : ℝ), + let keep : LayerSamplerVariables G I n B → Prop := + fun i => candidateSideCutoff separation ≤ sampler.sides i; + ∀ (bk : Basis ξ ℚ (LinearMap.ker φ.toLinearMap)) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) (v : μ → D.filtration.AssociatedGraded), + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule → + Submodule.span ℚ (Set.range v) = W.toSubmodule → + ∀ (vg : χ → Fmark.filtration.PolynomialSymbol (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + Submodule.span ℚ (Set.range vg) = + (Fmark.filtration.symbolPointwiseSubalgebra bF ν hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))).toSubmodule → + ∀ [Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ν)] + (H l nFinal : ℕ) (pMap pNative : ℝ), + 1 ≤ H → 0 < l → 0 < nFinal → 0 ≤ pMap → 0 ≤ pNative → + (Fintype.card (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ω) : ℝ) ≤ pMap → + (Fintype.card (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ν) : ℝ) ≤ pMap → + (H : ℝ) ≤ Real.exp pMap → ((l * nFinal : ℕ) : ℝ) ≤ Real.exp pMap → + Real.exp ((pMap + 2) ^ 4) ≤ Real.exp pNative → + (d : ℝ) ≤ pNative → (Fintype.card κ : ℝ) ≤ pNative → + (Fintype.card ξ : ℝ) ≤ pNative → (Fintype.card μ : ℝ) ≤ pNative → + (Fintype.card χ : ℝ) ≤ pNative → (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ pNative → + (H : ℝ) ≤ Real.exp pNative → + (∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) H) → + (∀ i j k, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ k) H) → + (∀ i j, RationalHeightLE (D.basis.repr (bk j : L) i) H) → + (∀ k i, RationalHeightLE (bF.repr (φ (D.basis i)) k) H) → + (∀ j i, RationalHeightLE ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) H) → + (∀ i z, RationalHeightLE + ((Fmark.filtration.polynomialSymbolBasis bF ν hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)).repr (vg i) z) H) → + ∃ mMap mReset : ℕ, 0 < mMap ∧ (mMap : ℝ) ≤ Real.exp ((pMap + 2) ^ 4) ∧ + l * nFinal ∣ mMap ∧ 0 < mReset ∧ + (mReset : ℝ) ≤ Real.exp ((markedNativeLiftInput + (fullMarkedNativeInput (s + 1) 1 Cf pNative) + Cnative) ^ Cnative) ∧ mMap ∣ mReset ∧ + ∀ (marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)) + (observable : (X → ℤ) → D.Space → ℂ) (weight : (X → ℤ) → ℂ) + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) sampler D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + {η : Type} [Fintype η] + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule))) + (lift : (Fmark.filtration.AssociatedGraded ⧸ + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule) →ₗ[ℚ] + Fmark.filtration.AssociatedGraded) + (Bphase budget pAffine pFull : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark.filtration bF ν hF J + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)).toSubmodule + basis lift + (Fmark.filtration.realPolynomialSymbolHom bF ν hF (fullTaggedVariableWeight J) + (Fmark.filtration.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked)) + Set.univ U poly N Bphase (s + 1)) + (data : P.AffinePhysicalTerminalData bF ν hF hφ W basis lift + Bphase budget pAffine pFull 4 history separation) + (hcost : Real.exp cost ≤ separation), + data.nFinal = nFinal → + Real.exp ((pFull + allocatedEarlyAffineLeftExponent (s + 1) 4) ^ + allocatedEarlyAffineLeftExponent (s + 1) 4) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) → + Real.exp ((pNative + Ccompare) ^ Ccompare) ≤ separation → + ∀ (q : ℝ), + Real.exp q ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) → + Real.exp ((pMap + 2) ^ 3 + q) ≤ Real.exp ((pNative + 2) ^ (1 : ℕ)) → + Real.exp cost * ((s + 1 + 1 : ℕ) : ℝ) ≤ separation → + (∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors D.basis ω hD + (fun i : (P.chart z).Variables => (sampler.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates _ (P.candidate z).orbit)) → + Nonempty (AllocatedExternalGlobalNativeResetFamily Fmark φ hφ + data.selected.problem keep (data.selected.common_keep hcost) W data.factors + (Real.exp ((markedNativeLiftInput (fullMarkedNativeInput (s + 1) 1 Cf pNative) + + Cnative) ^ Cnative)) mReset) := by + classical + obtain ⟨Ccompare, Cf, Cnative, hCcompare, hCf, hCnative, hreset⟩ := + exists_allocatedThresholdAffineFamilyReset s 1 + refine ⟨Ccompare, Cf, Cnative, hCcompare, hCf, hCnative, ?_⟩ + intro m G X _ _ I E J _ _ n B _ U btag Rad σ S hb o hRad hσ N poly hm + τ narrow stride cells center _ sampler L M κ ξ μ χ _ _ _ _ _ _ _ _ d f + D Fmark φ hφ ω hD bF ν hF hsurj separation keep bk W v hW hvspan vg hvgspan _ _ + H l nFinal pMap pNative hH hl hnFinal hpMap hpNative hsrc htgt hHmap hlmap hmabsorb + hd hκ hξ hμ hχ hvars hHp hbracketD hbracketF hkernel hentries hv hvg + obtain ⟨mMap, mReset, hmMap, hmMapBound, hdiv, hmReset, hmResetBound, hmMapReset, hrun⟩ := + hreset (sampler := sampler) (E := E) D Fmark φ hφ ω hD bF ν hF hsurj separation + bk W v hW hvspan vg hvgspan H l nFinal pMap pNative hH hl hnFinal hpMap hpNative + hsrc htgt hHmap hlmap hmabsorb hd hκ hξ hμ hχ hvars hHp + hbracketD hbracketF hkernel hentries hv hvg + refine ⟨mMap, mReset, hmMap, hmMapBound, hdiv, hmReset, hmResetBound, hmMapReset, ?_⟩ + intro marked observable weight cost massThreshold scoreThreshold P η _ basis lift + Bphase budget pAffine pFull history data hcost hn hslow hside q hq hqmap hcutoff hOriginal + apply hrun marked observable weight P data.selected hcost _ _ data.factors + · simpa only [← hn] using data.right_grid + · intro z + exact Fmark.filtration.polynomialSlowBound_mono bF + (fun _ : (data.selected.problem.chart z).Variables => 1) + (fun i => (sampler.sides i.val : ℝ)) + (fun i => Nat.cast_pos.mpr (sampler.sides_pos i.val)) hslow _ (data.local_left z) + · exact hside + · exact hq + · exact hqmap + · exact hcutoff + · exact hOriginal + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineProfileMeanTransport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineProfileMeanTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..84231b2cc08297dd0e352d9407fb3e1c3ebf82ff --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineProfileMeanTransport.lean @@ -0,0 +1,319 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedSlicedRowIdealSupport + +namespace OAI + +section + +namespace Erdos3 +open scoped NNReal + +theorem activeScaledSlicedIdeal_coordinate_support + {D G Z α : Type*} [Fintype D] [Fintype G] [Fintype Z] [Fintype α] [DecidableEq α] + {B : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ) + (P : D → Prop) [DecidablePred P] + {O : {d // ¬P d} → Type*} [∀ d, Fintype (O d)] (sets : ∀ d, O d → Finset α) + (R : (Σ d, O d) → ℝ) (hR : ∀ q, 0 < R q) {degree : ℕ} (hd : ∀ d, h d ≤ degree) + (ρ : ℝ≥0) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (center width : PrincipalAxisParameter (B := B) (h := h) (α := α) (fun d => ¬P d) → ℝ) + (hw : ∀ i, |center i| + |width i| ≤ 1) + (v : (Σ d, O d) → ℝ) + (hv : diagonalImageDensity R (activeAveragedSlicedProfileIdeal (G := G) (B := B) + Z h P sets ρ center width) v ≠ 0) (q : Σ d, O d) : + |v q| ≤ (partitionedIdealRadius α degree + 1) * R q := by + have hn : ‖fun q => v q / R q‖ ≤ partitionedIdealRadius α degree + 1 := by + by_contra hh + apply hv + unfold diagonalImageDensity + rw [activeAveragedSlicedProfileIdeal_zero_outside (G := G) (B := B) Z h P sets + hd ρ hρ hρ1 center width hw _ (lt_of_not_ge hh), mul_zero] + have hc := (norm_le_pi_norm (fun q => v q / R q) q).trans hn + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hR q)] at hc + exact (div_le_iff₀ (hR q)).mp hc + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped BigOperators NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "input" => PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) +local notation "output" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) + +include hR in + theorem allocatedAffineIdeal_profile_integrable + {P : ℝ} (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (ρ : ℝ≥0) (hρ : 0 < ρ) (hρone : ρ ≤ 1) + (center width : input → ℝ) (hw : ∀ i, |center i| + |width i| ≤ 1) + (modulus : ℕ) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + {Cmask : ℝ} (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ≤ Cmask) : + Integrable (allocatedLongProfileDensity B U basis S x rows modulus residue + (diagonalImageDensity (fun o : output => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) ρ center width))) + (allocatedLongJetReference B U basis S O) := by + have hRI (o : output) : |(R o.1.val.1)⁻¹| ≤ Real.exp P := by + rw [abs_of_pos (inv_pos.mpr (hR o.1.val.1))] + exact hRi _ + have hb := activeScaledSlicedIdeal_bounds (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (fun o : output => R o.1.val.1) + (C := ⟨Real.exp P, Real.exp_nonneg _⟩) + hRI + ρ hρ center width + apply allocatedLongProfileDensity_integrable B U basis S x rows modulus residue + _ hb.2.continuous.measurable + (T := Real.exp P * (partitionedIdealRadius α m + 1)) + (mul_nonneg (Real.exp_nonneg _) (by have := partitionedIdealRadius_nonneg α m; linarith)) + ?_ hCmask (by positivity) hb.1 hmask + exact activeScaledSlicedIdeal_zero_outside (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (fun o : output => R o.1.val.1) + (fun o => (hR o.1.val.1).ne') (Real.exp_nonneg P) + (fun o => by simpa only [abs_of_pos (hR o.1.val.1)] using hRP o.1.val.1) + (fun a => Nat.succ_le_of_lt a.1.isLt) ρ hρ hρone center width hw + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule +open scoped Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Jet" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +variable (hR : ∀ j, 0 < R j) +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) + (allocatedPrincipalSides B U basis S)) +variable (Q : Fin m → Type*) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +local notation "jetRows" => O +local notation "ideal" => diagonalImageDensity (fun q : Jet => R (Sigma.fst (Subtype.val (Sigma.fst q)))) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows (Sigma.fst (Subtype.val a))) ρ center width) +local notation "reference" => allocatedLongJetReference B U basis S jetRows + +omit [∀ a, DecidableEq (B a)] in +theorem allocatedAffineCoveredProfile_test_integral + [∀ a, DecidableEq (B a)] + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {P : ℝ} + (hRbound : ∀ j, R j ≤ Real.exp P) (hInv : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (modulus : ℕ) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + {Cmask : ℝ} (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ≤ Cmask) + (hσ1 : ∀ j, σ j ≤ 1) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (F : EuclideanJetLayers U jetRows → ℂ) (hF : Measurable F) + {CF : ℝ} (hFb : ∀ z, ‖F z‖ ≤ CF) : + let f := allocatedLongProfileDensity B U basis S x rows modulus residue ideal + (∫ a₀, ∫ z, (f z : ℂ) * allocatedCoveredFixedTest B U basis S x u v₀ rows + Q hb o bW d (fun p => F p.2) a₀ z ∂reference ∂allocatedFrozenCoefficientSource B U basis hR hσ S) = + ∫ y, (allocatedCoveredProfileDensity B U basis hR hσ S x u v₀ rows hb o bW d + (fun j (_ : O j) => standardLatticeClosedQuarterBox (J j)) f y : ℂ) * F y + ∂Measure.pi (fun j => Measure.pi (fun _ : O j => ν j)) := by + intro f + have hIm : Measurable ideal := diagonalImageDensity_measurable + (fun q : Jet => R q.1.val.1) (fun q => (hR q.1.val.1).ne') + (activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) ρ hρ center width).2.1.continuous.measurable + have hfm : Measurable f := allocatedLongProfileDensity_measurable B U basis S x rows + modulus residue ideal hIm + have hfi : Integrable f reference := allocatedAffineIdeal_profile_integrable B U basis hR S x rows + hRbound hInv ρ hρ hρ1 center width hw modulus residue hCmask hmask + have hf0 : ∀ z, 0 ≤ f z := allocatedLongProfileDensity_nonneg B U basis S x rows + modulus residue ideal + (diagonalImageDensity_nonneg _ (fun v => (activeAveragedSlicedProfileIdeal_spec + (G := G) (B := B) (G × Option α) (layerSamplerDegree I n) grid + (fun a => rows a.val.1) ρ hρ center width).1 v |>.1)) + (fun j z => (hmask j z).1) + apply allocatedCoveredProfile_test_integral B U basis hR hσ S x u v₀ rows Q hb o bW d ν + (fun j (_ : O j) => standardLatticeClosedQuarterBox (J j)) + (fun j _ => (standardLatticeClosedQuarterBox_isCompact (J j)).measurableSet) + (fun j _ => standardLatticeClosedQuarterBox_subset_smallBox (J j)) f hfm hfi hf0 ?_ F hF hFb + intro z hz + by_contra hn + apply hz + apply allocatedGridlessWeightedKernel_quarter_support B U basis hR hσ S x u v₀ rows Q o d + hσ1 T (fun j => (by have := partitionedIdealRadius_nonneg α m; have := hT j; linarith : 0 ≤ T j)) hsource C hC hchart hbudget f ?_ z hn + intro w hwne a₀ t + have hi := allocatedLongProfileDensity_ne_zero B U basis S x rows modulus residue ideal w hwne + exact (activeScaledSlicedIdeal_coordinate_support (G := G) (Z := G × Option α) (B := B) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (fun q : Jet => R q.1.val.1) + (fun q => hR q.1.val.1) (fun a => Nat.succ_le_of_lt a.1.isLt) + ρ hρ hρ1 center width hw _ hi ⟨a₀, t⟩).trans + (mul_le_mul_of_nonneg_right (hT _) (hR _).le) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule +open scoped Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Jet" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +variable (hR : ∀ j, 0 < R j) +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) + (allocatedPrincipalSides B U basis S)) +variable (Q : Fin m → Type*) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +local notation "jetRows" => O +local notation "ideal" => diagonalImageDensity (fun q : Jet => R (Sigma.fst (Subtype.val (Sigma.fst q)))) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows (Sigma.fst (Subtype.val a))) ρ center width) +local notation "reference" => allocatedLongJetReference B U basis S jetRows + +theorem allocatedAffineCoveredProfile_mean_test_integral + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {P : ℝ} + (hRbound : ∀ j, R j ≤ Real.exp P) (hInv : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (modulus : ℕ) + (weights : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) + (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S))) + (residue : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S) → ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + {Cmask : ℝ} (hCmask : 1 ≤ Cmask) + (hmask : ∀ u j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue u j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue u j) z ≤ Cmask) + (hσ1 : ∀ j, σ j ≤ 1) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (F : EuclideanJetLayers U jetRows → ℂ) (hF : Measurable F) + {CF : ℝ} (hFb : ∀ z, ‖F z‖ ≤ CF) : + + let f := fun u => allocatedLongProfileDensity B U basis S x rows modulus (residue u) ideal + weights.complexMean (fun u => ∫ a₀, ∫ z, (f u z : ℂ) * + allocatedCoveredFixedTest B U basis S x u v₀ rows Q hb o bW d + (fun p => F p.2) a₀ z ∂reference ∂allocatedFrozenCoefficientSource B U basis hR hσ S) = + ∫ y, (weights.mean (fun u => allocatedCoveredProfileDensity B U basis hR hσ S x u v₀ rows + hb o bW d (fun j (_ : O j) => standardLatticeClosedQuarterBox (J j)) (f u) y) : ℂ) * F y + ∂Measure.pi (fun j => Measure.pi (fun _ : O j => ν j)) := by + intro f + let profile := fun u => allocatedCoveredProfileDensity B U basis hR hσ S x u v₀ rows + hb o bW d (fun j (_ : O j) => standardLatticeClosedQuarterBox (J j)) (f u) + have hi u : Integrable (fun y => (profile u y : ℂ) * F y) + (Measure.pi (fun j => Measure.pi (fun _ : O j => ν j))) := by + have hIm : Measurable ideal := diagonalImageDensity_measurable + (fun q : Jet => R q.1.val.1) (fun q => (hR q.1.val.1).ne') + (activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) ρ hρ center width).2.1.continuous.measurable + have hfm : Measurable (f u) := allocatedLongProfileDensity_measurable B U basis S x rows + modulus (residue u) ideal hIm + have hfi : Integrable (f u) reference := allocatedAffineIdeal_profile_integrable B U basis hR S x rows + hRbound hInv ρ hρ hρ1 center width hw modulus (residue u) hCmask (hmask u) + exact (allocatedCoveredProfileDensity_integrable B U basis hR hσ S x u v₀ rows hb o bW d + (fun j (_ : O j) => standardLatticeClosedQuarterBox (J j)) + (fun j _ => (standardLatticeClosedQuarterBox_isCompact (J j)).measurableSet) + (fun j _ => standardLatticeClosedQuarterBox_subset_smallBox (J j)) ν (f u) hfm hfi).ofReal.mul_bdd + hF.aestronglyMeasurable (Filter.Eventually.of_forall hFb) + calc + _ = weights.complexMean (fun u => ∫ y, (profile u y : ℂ) * F y + ∂Measure.pi (fun j => Measure.pi (fun _ : O j => ν j))) := by + apply congrArg weights.complexMean + funext u + exact allocatedAffineCoveredProfile_test_integral B U basis S rows x u hR ρ center width hσ v₀ Q hb o bW d ν + hρ hρ1 hw hRbound hInv modulus (residue u) hCmask (hmask u) + hσ1 T hT hsource C hC hchart hbudget F hF hFb + _ = ∫ y, weights.complexMean (fun u => (profile u y : ℂ) * F y) + ∂Measure.pi (fun j => Measure.pi (fun _ : O j => ν j)) := + (weights.integral_complexMean _ _ hi).symm + _ = _ := by + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun y => weights.complexMean_ofReal_mul _ _) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineRadiusLog.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineRadiusLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..cdbe5baf5b2750905d09fafb8fccbae504234274 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineRadiusLog.lean @@ -0,0 +1,633 @@ +import OAI.Combinatorics.Progressions.Estimates.ActiveTailSlicedProfileComparison +import OAI.Combinatorics.Progressions.Estimates.AllocatedContinuousProxyAveraging + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "activeInput" => PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) +local notation "activeCoefficient" => ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) grid +local notation "realOutput" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) + +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) + (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) → ℝ) + +noncomputable def allocatedAffineLongJetDensity (y : activeInput → ℝ) : (realOutput → ℝ) → ℝ := by + exact allocatedNormalizedLongJetDensity B U basis S x u rows s hA (fun i => center i + width i * y i) + +noncomputable def allocatedAffineLongJetProxy : (realOutput → ℝ) → ℝ := + densityMixture (jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val)) + (allocatedAffineLongJetDensity B U basis S x u rows s hA center width) + +include hR hσ in +theorem allocatedAffineLongJetDensity_measurable (hσ1 : ∀ j, σ j ≤ 1) : + Measurable (Function.uncurry (allocatedAffineLongJetDensity B U basis S x u rows s hA center width)) := by + have hin : Measurable (fun p : (activeInput → ℝ) × (realOutput → ℝ) => + ((fun i => center i + width i * p.1 i), p.2)) := by + apply Measurable.prodMk + · apply Measurable.of_eval + intro i + exact measurable_const.add (measurable_const.mul ((measurable_pi_apply i).comp measurable_fst)) + · exact measurable_snd + exact (allocatedNormalizedLongJetDensity_measurable B U basis hR hσ S x u rows s hA hσ1).comp + (f := fun p : (activeInput → ℝ) × (realOutput → ℝ) => ((fun i => center i + width i * p.1 i), p.2)) hin + +include hR hσ in +theorem allocatedAffineLongJetDensity_probability (hσ1 : ∀ j, σ j ≤ 1) (y : activeInput → ℝ) : + (∀ v, 0 ≤ allocatedAffineLongJetDensity B U basis S x u rows s hA center width y v) ∧ + Integrable (allocatedAffineLongJetDensity B U basis S x u rows s hA center width y) ∧ + (∫ v, allocatedAffineLongJetDensity B U basis S x u rows s hA center width y v) = 1 := + allocatedNormalizedLongJetDensity_probability B U basis hR hσ S x u rows s hA hσ1 _ + +omit [∀ j, DecidableEq (O j)] in +theorem allocatedAffineLongJetMap_measurable : + Measurable (fun p : (activeInput → ℝ) × (activeCoefficient → ℝ) => + allocatedNormalizedLongJetMap B U basis S x u rows (fun i => center i + width i * p.1 i) p.2) := by + have hin : Measurable (fun p : (activeInput → ℝ) × (activeCoefficient → ℝ) => + ((fun i => center i + width i * p.1 i), p.2)) := by + apply Measurable.prodMk + · apply Measurable.of_eval + intro i + exact measurable_const.add (measurable_const.mul ((measurable_pi_apply i).comp measurable_fst)) + · exact measurable_snd + exact (allocatedNormalizedLongJetMap_measurable B U basis S x u rows).comp + (f := fun p : (activeInput → ℝ) × (activeCoefficient → ℝ) => ((fun i => center i + width i * p.1 i), p.2)) hin + +include hR hσ in +theorem allocatedAffineLongJetProxy_image_law (hσ1 : ∀ j, σ j ≤ 1) : + ((jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val)).prod + (unitCoefficientSource activeCoefficient)).map + (fun p => allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.1 i) p.2) = + realDensityMeasure volume (allocatedAffineLongJetProxy B U basis S x u rows s hA center width) := by + exact densityMixture_image_law _ _ volume _ + (allocatedAffineLongJetMap_measurable B U basis S x u rows center width) _ + (allocatedAffineLongJetDensity_measurable B U basis hR hσ S x u rows s hA center width hσ1) + (allocatedAffineLongJetDensity_probability B U basis hR hσ S x u rows s hA center width hσ1) + (by + intro y + change (unitCoefficientSource activeCoefficient).map + (allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * y i)) = + realDensityMeasure volume (allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (fun i => center i + width i * y i)) + exact allocatedNormalizedLongJetDensity_unit_law B U basis hR hσ S x u rows s hA hσ1 _) + +include hR hσ in +theorem allocatedAffineLongJetProxy_probability (hσ1 : ∀ j, σ j ≤ 1) : + (∀ v, 0 ≤ allocatedAffineLongJetProxy B U basis S x u rows s hA center width v) ∧ + Integrable (allocatedAffineLongJetProxy B U basis S x u rows s hA center width) ∧ + (∫ v, allocatedAffineLongJetProxy B U basis S x u rows s hA center width v) = 1 := + densityMixture_probability_density _ _ _ + (allocatedAffineLongJetDensity_measurable B U basis hR hσ S x u rows s hA center width hσ1) + (Filter.Eventually.of_forall + (allocatedAffineLongJetDensity_probability B U basis hR hσ S x u rows s hA center width hσ1)) + +include hR hσ in +theorem allocatedAffineLongJetProxy_test_integral (hσ1 : ∀ j, σ j ≤ 1) + (f : (realOutput → ℝ) → ℝ) (hf : Measurable f) : + (∫ v, allocatedAffineLongJetProxy B U basis S x u rows s hA center width v * f v) = + ∫ p : (activeCoefficient → ℝ) × (activeInput → ℝ), + f (allocatedNormalizedLongJetMap B U basis S x u rows (fun i => center i + width i * p.2 i) p.1) + ∂(unitCoefficientSource activeCoefficient).prod + (jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val)) := by + have hm := allocatedAffineLongJetMap_measurable B U basis S x u rows center width + have hd : Measurable (allocatedAffineLongJetProxy B U basis S x u rows s hA center width) := + (allocatedAffineLongJetDensity_measurable B U basis hR hσ S x u rows s hA center width hσ1).stronglyMeasurable.integral_prod_left'.measurable + have hp := allocatedAffineLongJetProxy_probability B U basis hR hσ S x u rows s hA center width hσ1 + have ht := mappedTest_eq_density + ((jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val)).prod + (unitCoefficientSource activeCoefficient)) volume + (fun p => allocatedNormalizedLongJetMap B U basis S x u rows (fun i => center i + width i * p.1 i) p.2) hm + (allocatedAffineLongJetProxy B U basis S x u rows s hA center width) hd hp.1 + (allocatedAffineLongJetProxy_image_law B U basis hR hσ S x u rows s hA center width hσ1) f hf + change (∫ p, f (allocatedNormalizedLongJetMap B U basis S x u rows (fun i => center i + width i * p.1 i) p.2) + ∂(jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val)).prod + (unitCoefficientSource activeCoefficient)) = _ at ht + exact ht.symm.trans (integral_prod_swap + (fun p : (activeInput → ℝ) × (activeCoefficient → ℝ) => + f (allocatedNormalizedLongJetMap B U basis S x u rows (fun i => center i + width i * p.1 i) p.2))).symm + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] [∀ j, Nonempty (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "activeInput" => PrincipalAxisParameter (B := B) (h := degree) (α := α) (fun a => ¬grid a) +local notation "activeCoefficient" => ActiveProfileCoefficientIndex G B degree grid +local notation "realOutput" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +local notation "sets" => (fun a : {a // ¬grid a} => rows (Sigma.fst (Subtype.val a))) + +include hσ hrows hcard in +omit [∀ j, DecidableEq (O j)] in +theorem exists_allocated_affine_tail_test_comparison + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : {a // ¬grid a}, O a.val.1 → B a.val) + (hblock : ∀ a, Function.Injective (block a)) + {δ ε : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) : + ∃ ρ : ℝ≥0, 0 < ρ ∧ ρ ≤ 1 ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ((∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S)) + (center width : activeInput → ℝ), + (∀ i, δ ≤ |width i|) → (∀ i, |center i| + |width i| ≤ 1) → + ∀ f : (realOutput → ℝ) → ℝ, Measurable f → (∀ v, ‖f v‖ ≤ 1) → + |(∫ v, activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + degree grid sets ρ center width v * f (fun o => R o.1.val.1 * v o)) - + ∫ p, f (allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1) + ∂(unitCoefficientSource activeCoefficient).prod + (jointBooleanSource (B := fun a : {a // ¬grid a} => B a.val) (α := α) (fun a => degree a.val))| ≤ ε) := by + have hh (a : LayerSamplerAxis I n) : 0 < degree a := Nat.zero_lt_succ _ + have hdeg (a : LayerSamplerAxis I n) : degree a ≤ m := Nat.succ_le_of_lt a.1.isLt + obtain ⟨ρ, hρ, hρone, t, ht, htone, hcomp⟩ := exists_active_tail_sliced_profile_comparison + (W := Unit) (G := G) (Z := G × Option α) degree hh grid (fun g a => (g, a)) sets (fun a => hrows a.val.1) + (fun a => hcard a.val.1) block hblock ψ hψ hrange hzero hone A T hLip hTransition hdeg hδ hδone hε + refine ⟨ρ, hρ, hρone, t, ht, htone, ?_⟩ + intro hsmall x u center width hwidth hcenter f hf hfb + let τ : LayerSamplerAxis I n → ℝ := fun a => σ a.1 / t + have hτ (a : LayerSamplerAxis I n) : |τ a| ≤ 1 := by + dsimp only [τ] + rw [abs_div, abs_of_pos (hσ a.1), abs_of_pos ht] + exact (div_le_one ht).mpr (hsmall a.1) + let z := fun _ : Unit => allocatedProfileFrozenNoise B U basis S x u + have hbox : ∀ᵐ a ∂Measure.dirac (), ∀ j, |z a j| ≤ 1 := + Filter.Eventually.of_forall (fun _ => allocatedProfileFrozenNoise_abs_le B U basis S x u) + have herr := hcomp τ hτ z (fun _ => measurable_const) center width hwidth hcenter + (Measure.dirac ()) inferInstance hbox (fun a => R a.1) + (fun p => f p.2) (hf.comp measurable_snd) (fun p => hfb p.2) + have heq (p : (Unit × (activeCoefficient → ℝ)) × (activeInput → ℝ)) : + partitionedAllocatedProfileJet degree grid (fun g a => (g, a)) sets (fun a => R a.1) t + (profileNoiseWithActive degree grid (z p.1.1) (activeTailRescale degree grid τ p.1.2)) + (fun i => center i + width i * p.2 i) = + allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1.2 := + allocatedTailProfileJet_eq B U basis S x u rows ht.ne' p.1.2 _ + simp only [heq] at herr + have hD : Measurable (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + degree grid sets ρ center width) := + (activeAveragedSlicedProfileIdeal_spec (G × Option α) degree grid sets ρ hρ center width).2.1.continuous.measurable + have hscale : Measurable (fun v : realOutput → ℝ => fun o => R o.1.val.1 * v o) := + Measurable.of_eval (fun o => measurable_const.mul (measurable_pi_apply o)) + have hfirst := integral_dirac_first volume () + (fun p : Unit × (realOutput → ℝ) => + activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) degree grid sets ρ center width p.2 * + f (fun o => R o.1.val.1 * p.2 o)) + ((hD.comp measurable_snd).mul (hf.comp (hscale.comp measurable_snd))) + have hin : Measurable (fun p : (Unit × (activeCoefficient → ℝ)) × (activeInput → ℝ) => + ((fun i => center i + width i * p.2 i), p.1.2)) := by + apply Measurable.prodMk + · apply Measurable.of_eval + intro i + exact measurable_const.add (measurable_const.mul ((measurable_pi_apply i).comp measurable_snd)) + · exact measurable_snd.comp measurable_fst + have hmap : Measurable (fun p : (Unit × (activeCoefficient → ℝ)) × (activeInput → ℝ) => + allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1.2) := + (allocatedNormalizedLongJetMap_measurable B U basis S x u rows).comp + (f := fun p : (Unit × (activeCoefficient → ℝ)) × (activeInput → ℝ) => + ((fun i => center i + width i * p.2 i), p.1.2)) hin + have hsecond := integral_dirac_first_nested (unitCoefficientSource activeCoefficient) + (jointBooleanSource (B := fun a : {a // ¬grid a} => B a.val) (α := α) (fun a => degree a.val)) () + (fun p : (Unit × (activeCoefficient → ℝ)) × (activeInput → ℝ) => + f (allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1.2)) (hf.comp hmap) + rw [hfirst, hsecond] at herr + exact herr + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] [∀ j, Nonempty (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "activeInput" => PrincipalAxisParameter (B := B) (h := degree) (α := α) (fun a => ¬grid a) +local notation "activeCoefficient" => ActiveProfileCoefficientIndex G B degree grid +local notation "realOutput" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +local notation "sets" => (fun a : {a // ¬grid a} => rows (Sigma.fst (Subtype.val a))) + +include hR hσ hrows hcard in +theorem exists_allocated_affine_proxy_comparison + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : {a // ¬grid a}, O a.val.1 → B a.val) + (hblock : ∀ a, Function.Injective (block a)) + {δ ε : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) : + ∃ ρ : ℝ≥0, 0 < ρ ∧ ρ ≤ 1 ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ((∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S)) + (center width : activeInput → ℝ), + (∀ i, δ ≤ |width i|) → (∀ i, |center i| + |width i| ≤ 1) → + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ f : (realOutput → ℝ) → ℝ, Measurable f → (∀ v, ‖f v‖ ≤ 1) → + |(∫ v, activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + degree grid sets ρ center width v * f (fun o => R o.1.val.1 * v o)) - + ∫ v, allocatedAffineLongJetProxy B U basis S x u rows s hA center width v * f v| ≤ ε) := by + obtain ⟨ρ, hρ, hρone, t, ht, htone, hs⟩ := exists_allocated_affine_tail_test_comparison + B U basis hσ S rows hrows hcard ψ hψ hrange hzero hone A T hLip hTransition + block hblock hδ hδone hε + refine ⟨ρ, hρ, hρone, t, ht, htone, ?_⟩ + intro hsmall x u center width hwidth hcenter s hA f hf hfb + have he := hs hsmall x u center width hwidth hcenter f hf hfb + rw [← allocatedAffineLongJetProxy_test_integral B U basis hR hσ S x u rows s hA + center width (fun j => (hsmall j).trans htone) f hf] at he + exact he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +noncomputable def allocatedAffineSourceTolerance (A T : ℝ≥0) (δ ε : ℝ) : ℝ := + Finset.univ.inf' Finset.univ_nonempty (fun P : LayerSamplerAxis I n → Prop => + partitionedAffineSourceTolerance (G := G) (Z := G × Option α) (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T m δ ε) + +include hrows hcard in +theorem exists_early_allocated_affine_tail_test_comparison_with_scales + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ ε : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T δ ε) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T δ ε ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (_hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + (∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + (center width : (PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ), + (∀ i, δ ≤ |width i|) → (∀ i, |center i| + |width i| ≤ 1) → + ∀ f : ((Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O (Sigma.fst (Subtype.val a))) → ℝ) → ℝ, Measurable f → (∀ v, ‖f v‖ ≤ 1) → + |(∫ v, activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => rows (Sigma.fst (Subtype.val a))) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width v * f (fun o => R o.1.val.1 * v o)) - + ∫ p, f (allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1) + ∂(unitCoefficientSource (ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value))).prod + (jointBooleanSource (B := fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (α := α) (fun a => (layerSamplerDegree I n) a.val))| ≤ ε := by + have hh (a : LayerSamplerAxis I n) : 0 < (layerSamplerDegree I n) a := Nat.zero_lt_succ _ + have hdeg (a : LayerSamplerAxis I n) : (layerSamplerDegree I n) a ≤ m := Nat.succ_le_of_lt a.1.isLt + have hall (P : LayerSamplerAxis I n → Prop) := exists_active_tail_sliced_profile_comparison_with_scales + (W := Unit) (G := G) (Z := G × Option α) (layerSamplerDegree I n) hh P (fun g a => (g, a)) + (fun a : {a // ¬P a} => rows a.val.1) (fun a => hrows a.val.1) + (fun a => hcard a.val.1) (fun a => block a.val) (fun a => hblock a.val) + ψ hψ hrange hzero hone A T hLip hTransition hdeg hδ hδone hε + choose ρ hρ hρone hρeq tp htp htpone htpeq hcomp using hall + let t := Finset.univ.inf' Finset.univ_nonempty tp + have ht : 0 < t := (Finset.lt_inf'_iff _).mpr (fun P _ => htp P) + have htP (P) : t ≤ tp P := Finset.inf'_le _ (Finset.mem_univ P) + let ρmin := Finset.univ.inf' Finset.univ_nonempty ρ + have hρmin : 0 < ρmin := (Finset.lt_inf'_iff _).mpr (fun P _ => hρ P) + refine ⟨ρmin, hρmin, ρ, (fun P => ⟨Finset.inf'_le _ (Finset.mem_univ P), hρone P⟩), + hρeq, t, ht, (htP (fun _ => False)).trans (htpone _), ?_, ?_⟩ + · change Finset.univ.inf' Finset.univ_nonempty tp = _ + simp only [htpeq] + rfl + intro J _ U basis R σ hσ S hsmall x u center width hwidth hcenter f hf hfb + let τ : LayerSamplerAxis I n → ℝ := fun a => σ a.1 / tp (allocatedGridAxis (I := I) U basis S.value) + have hτ (a : LayerSamplerAxis I n) : |τ a| ≤ 1 := by + dsimp only [τ] + rw [abs_div, abs_of_pos (hσ a.1), abs_of_pos (htp (allocatedGridAxis (I := I) U basis S.value))] + exact (div_le_one (htp (allocatedGridAxis (I := I) U basis S.value))).mpr ((hsmall a.1).trans (htP (allocatedGridAxis (I := I) U basis S.value))) + let z := fun _ : Unit => allocatedProfileFrozenNoise B U basis S x u + have hbox : ∀ᵐ a ∂Measure.dirac (), ∀ j, |z a j| ≤ 1 := + Filter.Eventually.of_forall (fun _ => allocatedProfileFrozenNoise_abs_le B U basis S x u) + have herr := hcomp (allocatedGridAxis (I := I) U basis S.value) τ hτ z (fun _ => measurable_const) center width hwidth hcenter + (Measure.dirac ()) inferInstance hbox (fun a => R a.1) + (fun p => f p.2) (hf.comp measurable_snd) (fun p => hfb p.2) + have heq (p : (Unit × ((ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value)) → ℝ)) × ((PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ)) : + partitionedAllocatedProfileJet (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun g a => (g, a)) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => rows (Sigma.fst (Subtype.val a))) (fun a => R a.1) (tp (allocatedGridAxis (I := I) U basis S.value)) + (profileNoiseWithActive (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (z p.1.1) (activeTailRescale (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) τ p.1.2)) + (fun i => center i + width i * p.2 i) = + allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1.2 := + allocatedTailProfileJet_eq B U basis S x u rows (htp (allocatedGridAxis (I := I) U basis S.value)).ne' p.1.2 _ + simp only [heq] at herr + have hD : Measurable (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => rows (Sigma.fst (Subtype.val a))) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) := + (activeAveragedSlicedProfileIdeal_spec (G × Option α) (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => rows (Sigma.fst (Subtype.val a))) (ρ (allocatedGridAxis (I := I) U basis S.value)) (hρ (allocatedGridAxis (I := I) U basis S.value)) center width).2.1.continuous.measurable + have hscale : Measurable (fun v : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O (Sigma.fst (Subtype.val a))) → ℝ => fun o => R o.1.val.1 * v o) := + Measurable.of_eval (fun o => measurable_const.mul (measurable_pi_apply o)) + have hfirst := integral_dirac_first volume () + (fun p : Unit × ((Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O (Sigma.fst (Subtype.val a))) → ℝ) => + activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => rows (Sigma.fst (Subtype.val a))) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width p.2 * + f (fun o => R o.1.val.1 * p.2 o)) + ((hD.comp measurable_snd).mul (hf.comp (hscale.comp measurable_snd))) + have hin : Measurable (fun p : (Unit × ((ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value)) → ℝ)) × ((PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ) => + ((fun i => center i + width i * p.2 i), p.1.2)) := by + apply Measurable.prodMk + · apply Measurable.of_eval + intro i + exact measurable_const.add (measurable_const.mul ((measurable_pi_apply i).comp measurable_snd)) + · exact measurable_snd.comp measurable_fst + have hmap : Measurable (fun p : (Unit × ((ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value)) → ℝ)) × ((PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ) => + allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1.2) := + (allocatedNormalizedLongJetMap_measurable B U basis S x u rows).comp + (f := fun p : (Unit × ((ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value)) → ℝ)) × ((PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ) => + ((fun i => center i + width i * p.2 i), p.1.2)) hin + have hsecond := integral_dirac_first_nested (unitCoefficientSource (ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value))) + (jointBooleanSource (B := fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (α := α) (fun a => (layerSamplerDegree I n) a.val)) () + (fun p : (Unit × ((ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value)) → ℝ)) × ((PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ) => + f (allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1.2)) (hf.comp hmap) + rw [hfirst, hsecond] at herr + exact herr + +include hrows hcard in +theorem exists_early_allocated_affine_tail_test_comparison + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ ε : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (_hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + (∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + (center width : (PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ), + (∀ i, δ ≤ |width i|) → (∀ i, |center i| + |width i| ≤ 1) → + ∀ f : ((Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O (Sigma.fst (Subtype.val a))) → ℝ) → ℝ, Measurable f → (∀ v, ‖f v‖ ≤ 1) → + |(∫ v, activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => rows (Sigma.fst (Subtype.val a))) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width v * f (fun o => R o.1.val.1 * v o)) - + ∫ p, f (allocatedNormalizedLongJetMap B U basis S x u rows + (fun i => center i + width i * p.2 i) p.1) + ∂(unitCoefficientSource (ActiveProfileCoefficientIndex G B (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value))).prod + (jointBooleanSource (B := fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (α := α) (fun a => (layerSamplerDegree I n) a.val))| ≤ ε := by + obtain ⟨ρmin, hρmin, ρ, hρ, _, t, ht, htone, _, hs⟩ := + exists_early_allocated_affine_tail_test_comparison_with_scales (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hε + exact ⟨ρmin, hρmin, ρ, hρ, t, ht, htone, hs⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] [∀ j, Nonempty (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "activeInput" => PrincipalAxisParameter (B := B) (h := degree) (α := α) (fun a => ¬grid a) +local notation "activeCoefficient" => ActiveProfileCoefficientIndex G B degree grid +local notation "realOutput" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +local notation "sets" => (fun a : {a // ¬grid a} => rows (Sigma.fst (Subtype.val a))) + +include hR hσ hrows hcard in +theorem exists_allocated_affine_proxy_l1 + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : {a // ¬grid a}, O a.val.1 → B a.val) + (hblock : ∀ a, Function.Injective (block a)) + {δ ε : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) : + ∃ ρ : ℝ≥0, 0 < ρ ∧ ρ ≤ 1 ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ((∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S)) + (center width : activeInput → ℝ), + (∀ i, δ ≤ |width i|) → (∀ i, |center i| + |width i| ≤ 1) → + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + (∫ v, |diagonalImageDensity (fun o : realOutput => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + degree grid sets ρ center width) v - + allocatedAffineLongJetProxy B U basis S x u rows s hA center width v|) ≤ ε) := by + obtain ⟨ρ, hρ, hρone, t, ht, htone, hs⟩ := exists_allocated_affine_proxy_comparison + B U basis hR hσ S rows hrows hcard ψ hψ hrange hzero hone A T hLip hTransition + block hblock hδ hδone hε + refine ⟨ρ, hρ, hρone, t, ht, htone, ?_⟩ + intro hsmall x u center width hwidth hcenter s hA + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hsmall j).trans htone + have hi := activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) + (G × Option α) degree grid sets ρ hρ center width + have hp := allocatedAffineLongJetProxy_probability B U basis hR hσ S x u rows s hA + center width hσ1 + have hm : Measurable (allocatedAffineLongJetProxy B U basis S x u rows s hA center width) := + (allocatedAffineLongJetDensity_measurable B U basis hR hσ S x u rows s hA + center width hσ1).stronglyMeasurable.integral_prod_left'.measurable + exact diagonalImageDensity_l1_le_of_tests (fun o : realOutput => R o.1.val.1) + (fun o => (hR o.1.val.1).ne') _ _ hi.2.1.continuous.measurable hm hi.2.2.1 hp.2.1 + (hs hsmall x u center width hwidth hcenter s hA) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped NNReal BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {α : Type*} [Fintype α] [DecidableEq α] + {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] + +noncomputable def allocatedAffinePartitionLog (A T : ℝ≥0) (E F : ℝ) + (P : LayerSamplerAxis I n → Prop) : ℝ := + let Clog := unitProfileCoefficientLog (B := B) A T + let Elog := E + Fintype.card {a // ¬P a} + 4 + let Qlog := jointAffineSourceInputLog (B := fun a : {a // ¬P a} => B a.val) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) + (fun a => layerSamplerDegree I n a.val) Clog Elog F + Real.log 16 + 6 * Qlog + + booleanToleranceC2Log (B := fun a : {a // ¬P a} => B a.val) (α := α) + (PartitionedProfileNoiseIndex G (G × Option α) α B (layerSamplerDegree I n) P) + (fun a => layerSamplerDegree I n a.val) m Clog + 1 + +noncomputable def allocatedAffineToleranceLog (A T : ℝ≥0) (E F : ℝ) : ℝ := + Finset.univ.sup' Finset.univ_nonempty (allocatedAffinePartitionLog (G := G) (O := O) (α := α) B A T E F) + + theorem allocatedAffineSourceTolerance_log_bound (A T : ℝ≥0) {δ ε E F : ℝ} + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hεE : ε⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) : + Real.log (allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T δ ε)⁻¹ ≤ + allocatedAffineToleranceLog (G := G) (O := O) (α := α) B A T E F := by + let t := fun P : LayerSamplerAxis I n → Prop => + partitionedAffineSourceTolerance (G := G) (Z := G × Option α) (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T m δ ε + obtain ⟨P, hP, heq⟩ := Finset.exists_mem_eq_inf' (s := (Finset.univ : Finset (LayerSamplerAxis I n → Prop))) + Finset.univ_nonempty t + change Real.log (Finset.univ.inf' Finset.univ_nonempty t)⁻¹ ≤ _ + rw [heq] + have hb := (partitionedAffineSource_scales_log_bounds (G := G) (Z := G × Option α) + (B := B) (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P + (fun _ => Nat.zero_lt_succ _) A T m hδ hδone hε hE hF hεE hδF).2 + exact hb.trans (Finset.le_sup' (allocatedAffinePartitionLog (G := G) (O := O) (α := α) B A T E F) hP) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped NNReal BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {α : Type*} [Fintype α] [DecidableEq α] + {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] + +noncomputable def allocatedAffinePartitionRadiusLog (A T : ℝ≥0) (E F : ℝ) + (P : LayerSamplerAxis I n → Prop) : ℝ := + 2 * jointAffineSourceInputLog (B := fun a : {a // ¬P a} => B a.val) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) + (fun a => layerSamplerDegree I n a.val) (unitProfileCoefficientLog (B := B) A T) + (E + Fintype.card {a // ¬P a} + 4) F + 2 + +noncomputable def allocatedAffineRadiusLog (A T : ℝ≥0) (E F : ℝ) : ℝ := + Finset.univ.sup' Finset.univ_nonempty + (allocatedAffinePartitionRadiusLog (O := O) (α := α) B A T E F) + + theorem allocatedAffineSourceRadius_inverse_bound (A T : ℝ≥0) {δ ε E F : ℝ} + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hεE : ε⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) + (P : LayerSamplerAxis I n → Prop) : + (partitionedAffineSourceRadius (B := B) (O := fun a : {a // ¬P a} => O a.val.1) + (α := α) (layerSamplerDegree I n) P A T δ ε)⁻¹ ≤ + Real.exp (allocatedAffineRadiusLog (O := O) (α := α) B A T E F) := by + have h := (partitionedAffineSource_scales_log_bounds (G := Unit) (Z := Unit) + (B := B) (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P + (fun _ => Nat.zero_lt_succ _) A T m hδ hδone hε hE hF hεE hδF).1 + apply h.trans + apply Real.exp_le_exp.mpr + exact Finset.le_sup' (allocatedAffinePartitionRadiusLog (O := O) (α := α) B A T E F) + (Finset.mem_univ P) + + theorem allocatedAffineSourceRadius_uniform_floor (A T : ℝ≥0) {δ ε E F : ℝ} + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hεE : ε⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) + (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) + (hρ : ∀ P, 0 < ρ P) + (hρeq : ∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T δ ε) : + ∀ P, Real.exp (-allocatedAffineRadiusLog (O := O) (α := α) B A T E F) ≤ ρ P := by + intro P + have hi := allocatedAffineSourceRadius_inverse_bound (O := O) (α := α) + B A T hδ hδone hε hE hF hεE hδF P + rw [← hρeq P] at hi + rw [Real.exp_neg] + exact (inv_le_comm₀ (Real.exp_pos _) (show 0 < (ρ P : ℝ) from hρ P)).mpr hi + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineRecenteredSource.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineRecenteredSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..db781e47d1164c2b2c33cfa22b011292c13f14db --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineRecenteredSource.lean @@ -0,0 +1,1121 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRecenteredL1Source +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineFiniteModelL2 + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset α)) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset α)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset α) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +local notation "ξ" => Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j)) +local notation "density" => allocatedCoefficientDensity B U basis hb o hR hσ S +local notation "cover" => quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineIdeal_l1 + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) ξ) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure ξ (g y)) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) (hH : ∀ j : Tuple, 2 ≤ H j) + (hδ : 0 < δ) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hsize : ∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j : Tuple, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α jetRows P e) ≤ S.value) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ (u : GridTuples) j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ∧ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ≤ Cmask) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let _outputResidue := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + (∫ y, ‖((wholeLaw).mean (fun v => g v y) : ℂ) - + ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ)‖ ∂ξ) ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α selectedRows P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, selectedRows a.1) * + (Fintype.card {a // ¬grid a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α selectedRows P) + εcoef)^ + Fintype.card {a // ¬grid a}) + + allocatedAffineSourceReferenceError B U basis S α selectedRows (ρ grid) P η (fun _ => modulus) H ε mesh Cmask + := by + intro center width ideal outputResidue + have hw := principalProgressionSlice_parameters (α := α) activeB activeDegree + L H step c positiveLengths hstep hH hδ hsubset hdense + have hidealm : Measurable ideal := + allocatedRowSlicedIdeal_measurable B U basis S rowSets hR (ρ grid) hρ center width + let profile := fun u y => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y + have hprofilem (u) : Measurable (profile u) := + allocatedWholeMaskedCoveredProfile_measurable B U basis hR hσ S x rows hb o bW d + (principalAxisJoin grid u v₀) modulus ideal hidealm + have hprofilei (u) : Integrable (profile u) ξ := by + have hfm := allocatedLongProfileDensity_measurable B U basis S x rows + modulus (outputResidue u) ideal hidealm + have hfi := allocatedAffineIdeal_profile_integrable B U basis hR S x rows + hRP hRi (ρ grid) hρ hρ1 center width (fun i => (hw i).2.2) + modulus (outputResidue u) hCmask (hmask u) + have hi := allocatedCoveredProfileDensity_integrable B U basis hR hσ S x u v₀ rows + hb o bW d (fun j (_ : selectedRows j) => standardLatticeClosedQuarterBox (J j)) + (fun j _ => (standardLatticeClosedQuarterBox_isCompact (J j)).measurableSet) + (fun j _ => standardLatticeClosedQuarterBox_subset_smallBox (J j)) ν _ hfm hfi + simpa only [profile, allocatedWholeMaskedCoveredProfile_join] using hi + have hmeanm : Measurable (fun y => ((wholeLaw).mean (fun v => g v y) : ℂ)) := + (Finset.measurable_sum Finset.univ (fun v _ => (hgm v).const_mul _)).complex_ofReal + have hmeani : Integrable (fun y => ((wholeLaw).mean (fun v => g v y) : ℂ)) ξ := + (integrable_finsetSum Finset.univ (fun v _ => (hgi v).const_mul _)).ofReal + have hmodelm : Measurable (fun y => ((gridLaw).mean (fun u => profile u y) : ℂ)) := + ((gridLaw).mean_measurable _ hprofilem).complex_ofReal + have hmodeli : Integrable (fun y => ((gridLaw).mean (fun u => profile u y) : ℂ)) ξ := + (integrable_finsetSum Finset.univ (fun u _ => (hprofilei u).const_mul _)).ofReal + apply complex_model_l1_le_of_bounded_tests ξ _ _ hmeanm hmodelm hmeani hmodeli + intro F hF hFbound + have hc := allocatedAffineWholeProfile_comparison B U basis hR hσ S rows x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d F H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν + ρ t htone hs hρ hρ1 hσsmall hstep hH hδ hdense hm hsize hsmall hε hmesh + selection hgood hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh hCmask hmask + T hT hsource C hC hchart hbudget hF hFbound + have hsmallDensity (j) : C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4 := by + have hT1 : 1 ≤ T j := (le_add_of_nonneg_left (partitionedIdealRadius_nonneg α m)).trans (hT j) + have hRle : R j ≤ T j * R j := by simpa only [one_mul] using mul_le_mul_of_nonneg_right hT1 (hR j).le + calc + _ = C j * (((Fintype.card (I j) : ℝ) + 1) * R j) := mul_assoc _ _ _ + _ ≤ C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hRle + (add_nonneg (Nat.cast_nonneg _) zero_le_one)) (hC j) + _ ≤ _ := hbudget j + have hdeck := allocatedCoefficientDeckSample_density_law B U basis hR hσ S Q hb o bW d μ ν + (fun j => (hσsmall j).trans htone) C hC hchart hsmallDensity + have hid := allocatedProgressionCoveredExpectation_density B U basis hR hσ S rows x Q hb o bW d + H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell μ ν hdeck g hgm hg0 hgi hglaw F hF hFbound + rw [hid] at hc + exact hc + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineIdeal_l1_small + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) ξ) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure ξ (g y)) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) (hH : ∀ j : Tuple, 2 ≤ H j) + (hδ : 0 < δ) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hsize : ∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j : Tuple, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + (hrowDegree : ∀ j (a : rowSets j), a.val.card ≤ j.val + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α jetRows P e) ≤ S.value) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0) + {mesh : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + {D target Pk Prho : ℝ} + (hdimensions : AllocatedComparisonDimensions (G := G) B α selectedRows D) + (hPk : 0 ≤ Pk) (hMkPk : (Mk : ℝ) ≤ Real.exp Pk) + (hPrho : 0 ≤ Prho) (hρlog : (ρ grid : ℝ)⁻¹ ≤ Real.exp Prho) + (htarget : 0 ≤ target) + (hη0 : 0 ≤ η) + (hcoefsmall : εcoef ≤ Real.exp (-(target + 1 + coefficientReplacementErrorLog D (allocatedAffineL1Log m D P Prho Pk)))) + (hηsmall : η ≤ Real.exp (-(target + 1 + D * ((m * 2 ^ (m + 1) : ℕ) * Pk) + 4))) + (hratiosmall : (∑ j : Tuple, (modulus : ℝ) / H j) ≤ + Real.exp (-(target + 1 + affineReferenceCoefficientLog D (allocatedAffineL1Log m D P Prho Pk) + 4))) + (hεsmall : ε ≤ Real.exp (-(target + 1 + affineReferenceCoefficientLog D (allocatedAffineL1Log m D P Prho Pk) + 4))) + (hmeshsmall : mesh ≤ Real.exp (-(target + 1 + affineReferenceCoefficientLog D (allocatedAffineL1Log m D P Prho Pk) + 4))) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let _outputResidue := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + (∫ y, ‖((wholeLaw).mean (fun v => g v y) : ℂ) - + ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ)‖ ∂ξ) ≤ + Real.exp (-target) := by + intro center width ideal outputResidue + let Lb := allocatedAffineL1Log m D P Prho Pk + have hD := hdimensions.nonneg + have haxes := hdimensions.axes + have houtputs := hdimensions.outputs + have hlongoutputs := hdimensions.active_outputs B grid + have hsplit := selectedOutput_card_split (allocatedLongIntegerSelect B U basis S (O := selectedRows)) + have hunselected : (Fintype.card (UnselectedColumn + (allocatedLongIntegerSelect B U basis S (O := selectedRows))) : ℝ) ≤ D := by + apply (Nat.cast_le.mpr (Nat.le_add_right _ _)).trans + rw [hsplit] + exact hlongoutputs + have hinteger : (Fintype.card {o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) // + allocatedLongIntegerCoordinate B U basis S (O := selectedRows) o} : ℝ) ≤ D := + (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans hlongoutputs + obtain ⟨hLb, hPL, hdensity, hsupport, hamp, hideal, hKi, hindexL, hboundary⟩ := + allocatedAffineL1_primitive_bounds B hdimensions hP hPrho hPk hMkPk grid R + (fun j => (hR j).le) hRi (ρ grid) hρlog + have hboundary0 : 0 ≤ scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) := + div_nonneg (scalarCubeGridBoundaryConstant_pos α).le (scalarCubeDomain_volumeReal_pos α).le + let Cmask : ℝ := layerKernelIndexBound m Mk + have hCmask : 1 ≤ Cmask := by + dsimp only [Cmask, layerKernelIndexBound] + exact_mod_cast (Nat.one_le_pow _ _ hMk) + have hmask (u : GridTuples) (j : Fin m) (z : selectedRows j → ℤ) := + allocatedIntegerKernelMask_bound B U basis S x rows hMk selection hgood hq + (fun _ => Subtype.val_injective) hrowDegree j modulus (outputResidue u j) z + have hmaskL : Cmask ≤ Real.exp Lb := + (layerKernelIndexBound_le_exp m hMkPk).trans (Real.exp_le_exp.mpr hindexL) + have hearlyMask : Cmask ^ Fintype.card (LayerSamplerAxis I n) ≤ + Real.exp (D * ((m * 2 ^ (m + 1) : ℕ) * Pk)) := + pow_le_exp_mul_of_le_exp (Nat.cast_nonneg _) (layerKernelIndexBound_le_exp m hMkPk) + (mul_nonneg (Nat.cast_nonneg _) hPk) _ haxes + have hc := allocatedAffineIdeal_l1 B U basis hR hσ S rowSets x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν μ + g hgm hg0 hgi hglaw ρ t htone hs hρ hρ1 hσsmall hstep hH hδ hdense hm hsize hsmall + hε hmesh selection hgood hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh + hCmask hmask T hT hsource C hC hchart hbudget + have hactive : (Fintype.card {a // ¬grid a} : ℝ) ≤ D := + (Nat.cast_le.mpr (Fintype.card_subtype_le (fun a => ¬grid a))).trans haxes + have hreplace := coefficientReplacementError_small hD hLb (by linarith : 0 ≤ target + 1) + hsupport (mul_nonneg (Nat.cast_nonneg _) (Real.exp_nonneg _)) hamp + (Fintype.card (Σ a : LayerSamplerAxis I n, selectedRows a.1)) + (Fintype.card {a // ¬grid a}) houtputs hactive hεcoef.le hcoefsmall + have href := allocatedAffineSourceReferenceError_small_separated B U basis S α selectedRows (ρ grid) P + (fun _ => modulus) H hearlyMask hD hLb hPL hdensity hsupport hideal hKi (zero_le_one.trans hCmask) + hmaskL hboundary0 hboundary haxes hlongoutputs hunselected hinteger hη0 hε hmesh0 + hηsmall hratiosmall hεsmall hmeshsmall + calc + _ ≤ _ := hc + _ ≤ Real.exp (-(target + 1)) + Real.exp (-(target + 1)) := add_le_add hreplace href + _ ≤ Real.exp (-target) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ = 2 * Real.exp (-(target + 1)) := by ring + _ ≤ Real.exp 1 * Real.exp (-(target + 1)) := + mul_le_mul_of_nonneg_right htwo (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset α)) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset α)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset α) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +local notation "ξ" => Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j)) +local notation "density" => allocatedCoefficientDensity B U basis hb o hR hσ S +local notation "cover" => quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineIdeal_l1_of_length + {D target Pk Prho F Tmod : ℝ} + (hdimensions : AllocatedComparisonDimensions (G := G) B α selectedRows D) + (hPk : 0 ≤ Pk) (hMkPk : (Mk : ℝ) ≤ Real.exp Pk) + (hPrho : 0 ≤ Prho) (htarget : 0 ≤ target) (hF : 0 ≤ F) (hTmod : 0 ≤ Tmod) + (hlength : Real.exp (allocatedAffineLengthLog m D P Prho Pk target F Tmod) ≤ S.value) + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) ξ) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure ξ (g y)) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) + (hδ : 0 < δ) (hδF : δ⁻¹ ≤ Real.exp F) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hmodulus : (modulus : ℝ) ≤ Real.exp Tmod) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + (hrowDegree : ∀ j (a : rowSets j), a.val.card ≤ j.val + 1) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue (allocatedAffineLength_slice_ready B U basis hdimensions hP hPrho hPk htarget hF hTmod S hlength H₀ step₀ c₀ hsubset₀ hδ hδF modulus hm hmodulus hstep hdense).2.1).weight v₀ ≠ 0) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (hρlog : (ρ grid : ℝ)⁻¹ ≤ Real.exp Prho) + (hη0 : 0 ≤ η) + (hηsmall : η ≤ Real.exp (-(target + 1 + D * ((m * 2 ^ (m + 1) : ℕ) * Pk) + 4))) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let _outputResidue := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + (∫ y, ‖((wholeLaw).mean (fun v => g v y) : ℂ) - + ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ)‖ ∂ξ) ≤ + Real.exp (-target) := by + let e := allocatedAffineCoefficientAccuracyLog m D P Prho Pk target + let E := allocatedAffineReferenceAccuracyLog m D P Prho Pk target + obtain ⟨he, hE, _⟩ := allocatedAffineLengthLog_bounds m hdimensions.nonneg hP hPrho hPk htarget hF hTmod + obtain ⟨hH, hsize, hsmall, hratio, hmesh⟩ := allocatedAffineLength_slice_ready B U basis hdimensions hP hPrho hPk htarget hF hTmod S hlength H₀ step₀ c₀ hsubset₀ hδ hδF modulus hm hmodulus hstep hdense + obtain ⟨hlarge, hscaleMesh, _⟩ := + allocatedAffineLength_ready B U basis hdimensions hP hPrho hPk htarget hF hTmod S hlength + have hεe : (Real.exp (-e))⁻¹ ≤ Real.exp e := by rw [← Real.exp_neg, neg_neg] + exact allocatedAffineIdeal_l1_small B U basis hR hσ S rowSets x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν μ + g hgm hg0 hgi hglaw ρ t htone hs hρ hρ1 hσsmall hstep hH hδ hdense hm hsize hsmall + (Real.exp_nonneg (-E)) hmesh selection hgood hq hrowDegree he (Real.exp_pos (-e)) hεe hlarge + hperiod v₀ hv₀ (Real.exp_nonneg (-E)) (Real.exp_le_one_iff.mpr (neg_nonpos.mpr hE)) + hscaleMesh T hT hsource C hC hchart hbudget hdimensions hPk hMkPk hPrho hρlog htarget hη0 + le_rfl hηsmall hratio le_rfl le_rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset α)) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset α)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset α) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +local notation "ξ" => Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j)) +local notation "density" => allocatedCoefficientDensity B U basis hb o hR hσ S +local notation "cover" => quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem exists_allocatedAffineIdeal_l1_reference + {D target Pk Prho F Tmod : ℝ} + (hdimensions : AllocatedComparisonDimensions (G := G) B α selectedRows D) + (hPk : 0 ≤ Pk) (hMkPk : (Mk : ℝ) ≤ Real.exp Pk) + (hPrho : 0 ≤ Prho) (htarget : 0 ≤ target) (hF : 0 ≤ F) (hTmod : 0 ≤ Tmod) + (hlength : Real.exp (allocatedAffineLengthLog m D P Prho Pk target F Tmod) ≤ S.value) + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) ξ) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure ξ (g y)) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) + (hδ : 0 < δ) (hδF : δ⁻¹ ≤ Real.exp F) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hmodulus : (modulus : ℝ) ≤ Real.exp Tmod) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + (hrowDegree : ∀ j (a : rowSets j), a.val.card ≤ j.val + 1) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (hρlog : (ρ grid : ℝ)⁻¹ ≤ Real.exp Prho) + (hη0 : 0 ≤ η) + (hηsmall : η ≤ Real.exp (-(target + 1 + D * ((m * 2 ^ (m + 1) : ℕ) * Pk) + 4))) : + ∃ y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S), + 0 < (wholeLaw).weight y₀ ∧ + (∀ j, IntegerScalarCube (allocatedPrincipalSides B U basis S j) (fun a => (y₀ j a : ℤ))) ∧ + 0 < (gridLaw).weight (principalAxisRestrict grid y₀) ∧ + (∀ y, (wholeLaw).weight y ≠ 0 → principalResidueLabel modulus y = principalResidueLabel modulus y₀) ∧ + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + (∫ y, ‖((wholeLaw).mean (fun v => g v y) : ℂ) - + ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) modulus ideal y) : ℂ)‖ ∂ξ) ≤ + Real.exp (-target) := by + obtain ⟨y₀, hy₀, hcube, hmarg, hlabel⟩ := exists_containedSupportedProgressionReference + B (layerSamplerDegree I n) (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ + (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell + refine ⟨y₀, hy₀, hcube, hmarg grid, hlabel, ?_⟩ + have hsize := (allocatedAffineLength_slice_ready B U basis hdimensions hP hPrho hPk htarget hF hTmod + S hlength H₀ step₀ c₀ hsubset₀ hδ hδF modulus hm hmodulus hstep hdense).2.1 + have hv₀ := hmarg (fun a => ¬grid a) + have heq := containedSupportedProgressionAxisLaw_eq_of_size B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) + hH₀ hsubset₀ modulus hm r₀ hcell (fun a => ¬grid a) hsize + have hv₁ : 0 < (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight + (principalAxisRestrict (fun a => ¬grid a) y₀) := by + erw [← heq] + convert hv₀ using 1 + congr! (transparency := .reducible) + exact allocatedAffineIdeal_l1_of_length B U basis hR hσ S rowSets x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν μ + hdimensions hPk hMkPk hPrho htarget hF hTmod hlength + g hgm hg0 hgi hglaw ρ t htone hs hρ hρ1 hσsmall hstep hδ hδF hdense hm hmodulus + selection hgood hq hrowDegree hperiod (principalAxisRestrict (fun a => ¬grid a) y₀) hv₁.ne' + T hT hsource C hC hchart hbudget hρlog hη0 hηsmall + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ uX +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {dim : ℕ} +variable (rowSets : Fin m → Finset (Finset (Fin dim))) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset (Fin dim) // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset (Fin dim))).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset (Fin dim)) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := (Fin dim)) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := (Fin dim)) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +local notation "ξ" => Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j)) +local notation "density" => allocatedCoefficientDensity B U basis hb o hR hσ S +local notation "cover" => quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d + +variable {X : Type uX} [Fintype X] [DecidableEq X] +variable [CompactSpace (CoefficientTorus (K := Fin dim) U)] +variable [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] +variable [BorelSpace (CoefficientTorus (K := Fin dim) U)] +variable (μrows : Measure (CoefficientTorus (K := Fin dim) U)) +variable [μrows.IsAddLeftInvariant] [IsProbabilityMeasure μrows] + +include μrows hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineIdeal_sampled_l1_of_length + {D target Pk Prho F Tmod : ℝ} + (hdimensions : AllocatedComparisonDimensions (G := G) B (Fin dim) selectedRows D) + (hPk : 0 ≤ Pk) (hMkPk : (Mk : ℝ) ≤ Real.exp Pk) + (hPrho : 0 ≤ Prho) (htarget : 0 ≤ target) (hF : 0 ≤ F) (hTmod : 0 ≤ Tmod) + (hlength : Real.exp (allocatedAffineLengthLog m D P Prho Pk target F Tmod) ≤ S.value) + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) ξ) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure ξ (g y)) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) + (hδ : 0 < δ) (hδF : δ⁻¹ ≤ Real.exp F) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hmodulus : (modulus : ℝ) ≤ Real.exp Tmod) + (selection : (Fin dim) ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card (Fin dim) ≤ m + 1) + (hrowDegree : ∀ j (a : rowSets j), a.val.card ≤ j.val + 1) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := (Fin dim)) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue (allocatedAffineLength_slice_ready B U basis hdimensions hP hPrho hPk htarget hF hTmod S hlength H₀ step₀ c₀ hsubset₀ hδ hδF modulus hm hmodulus hstep hdense).2.1).weight v₀ ≠ 0) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius (Fin dim) m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card (Fin dim) * ((Fintype.card (Fin dim) : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (hρlog : (ρ grid : ℝ)⁻¹ ≤ Real.exp Prho) + (hη0 : 0 ≤ η) + (hηsmall : η ≤ Real.exp (-(target + 1 + D * ((m * 2 ^ (m + 1) : ℕ) * Pk) + 4))) : + let center := principalProgressionSliceCenter (α := (Fin dim)) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := (Fin dim)) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option (Fin dim)) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let profile := fun y => ((gridLaw).mean (fun u => + allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ) + let A := Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,0} m dim) + ∀ {Psample Rrank Sstride τ εsample ηsample δsur : ℝ}, + 0 ≤ Psample → (Fintype.card X : ℝ) ≤ Psample → + (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ Psample → + ∀ (base : X → ℤ) (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j ex, coefficients (poly j) ex ∈ U j), + (d : ℝ) ≤ Real.exp Psample → + ∀ (stride : X → ℕ), (∀ i, 0 < stride i) → + 0 ≤ Sstride → Sstride ≤ Real.exp Psample → 0 < τ → 0 < εsample → + 1 / τ ≤ Real.exp Psample → 1 / εsample ≤ Real.exp Psample → + (∀ i, (stride i : ℝ) ≤ Sstride) → + ∀ (N : X → ℝ), (∀ i, Real.exp ((Psample + A) ^ A) ≤ N i) → + (∀ j, HasLayerSamplingRank (j.val + 1) N Rrank (U j) (poly j)) → + Real.exp ((Psample + A) ^ A) ≤ Rrank → + ∀ (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)), cells.Nonempty → + ∀ (V : Option (Fin dim) × X → ℝ), (∀ z, 0 < V z) → (∀ z, τ * N z.2 ≤ V z) → + ∀ (actual surrogate : (JetAmbientIndex selectedRows J → UnitAddCircle) → ℂ) + (La Ls Ca Cs : ℝ≥0), + LipschitzWith La actual → LipschitzWith Ls surrogate → + (∀ z, ‖actual z‖ ≤ Ca) → (∀ z, ‖surrogate z‖ ≤ Cs) → + 0 < ηsample → (Fintype.card (CoefficientAmbientIndex (Fin dim) J) : ℝ) ≤ Psample → + (La : ℝ) ≤ Real.exp Psample → (Ls : ℝ) ≤ Real.exp Psample → + (Ca : ℝ) ≤ Real.exp Psample → (Cs : ℝ) ≤ Real.exp Psample → + ((∑ j : Fin m, (Fintype.card (BoundedCoefficientExponent (Fin dim) (j.val + 1)) : ℝ≥0) : ℝ≥0) : ℝ) ≤ Real.exp Psample → + ηsample⁻¹ ≤ Real.exp Psample → + (∀ y, ((wholeLaw).mean (fun v => g v y) : ℂ) = actual (coveredJetAmbientTorus U 1 y)) → + (∀ y, ‖profile y - surrogate (coveredJetAmbientTorus U 1 y)‖ ≤ δsur) → + ∃ _hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells V z, + selectedResidueDensityMass stride cells V (fun z => + let point := physicalCubeRowSample U d rows poly hmem + (translatePhysicalCube base (standardPhysicalCubeOutput z)) + ‖((wholeLaw).mean (fun v => g v point) : ℂ) - profile point‖) ≤ + Real.exp (-target) + 2 * δsur + (2 * ηsample + εsample) := by + intro center width ideal profile A Psample Rrank Sstride τ εsample ηsample δsur + hPs hX hframe base poly hp hmem hdP stride hstridepos hSstride hSstrideP hτ hεsample hτP hεsampleP + hstride N hsize hrank hRrank cells hcells V hV hwidth actual surrogate La Ls Ca Cs + hLa hLs hCa hCs hηsample hamb hLaP hLsP hCaP hCsP hjet hηsampleP hactual happrox + have hhaar := allocatedAffineIdeal_l1_of_length B U basis hR hσ S rowSets x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν μ + hdimensions hPk hMkPk hPrho htarget hF hTmod hlength + g hgm hg0 hgi hglaw ρ t htone hs hρ hρ1 hσsmall hstep hδ hδF hdense hm hmodulus + selection hgood hq hrowDegree hperiod v₀ hv₀ T hT hsource C hC hchart hbudget hρlog hη0 hηsmall + have hmass : (∫ y, ‖actual (coveredJetAmbientTorus U 1 y) - profile y‖ ∂ξ) ≤ Real.exp (-target) := by + simpa only [hactual] using hhaar + have hmeas : Measurable profile := + allocatedWholeMaskedCoveredProfile_mean_measurable B U basis hR hσ S x rows hb o bW d + (gridLaw) (fun u => principalAxisJoin grid u v₀) modulus ideal + (allocatedRowSlicedIdeal_measurable B U basis S rowSets hR (ρ grid) hρ center width) + have hsample := (Classical.choose_spec (exists_translated_physical_jet_l1_perturbation.{uX,uJ,0} m dim)).2 + (I := X) (J := J) (O := selectedRows) + obtain ⟨hZ, he⟩ := hsample rows (fun _ => Subtype.val_injective) hrowDegree hPs hX hframe U μrows ν + base poly hp hmem d (NeZero.pos d) hdP stride hstridepos hSstride hSstrideP hτ hεsample + hτP hεsampleP hstride N hsize hrank hRrank cells hcells V hV hwidth actual surrogate La Ls Ca Cs + hLa hLs hCa hCs hηsample hamb hLaP hLsP hCaP hCsP hjet hηsampleP profile hmeas happrox hmass + refine ⟨hZ, ?_⟩ + simpa only [hactual] using he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ uX +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {dim : ℕ} +variable (rowSets : Fin m → Finset (Finset (Fin dim))) +variable [∀ j, Nonempty (rowSets j)] +local notation "selectedRows" => (fun j : Fin m => {t : Finset (Fin dim) // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (s : ∀ j : Fin m, ↥(rowSets j) ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowSets j → Finset (Fin dim))).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := ↥(rowSets j)) + S.positive x (j.val + 1) (Subtype.val : rowSets j → Finset (Fin dim)) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => selectedRows +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := (Fin dim)) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := (Fin dim)) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +local notation "jetHaar" => Measure.pi (fun j => Measure.pi (fun _ : rowSets j => ν j)) +local notation "density" => allocatedCoefficientDensity B U basis hb o hR hσ S +local notation "cover" => quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d + +variable {X : Type uX} [Fintype X] [DecidableEq X] +variable [CompactSpace (CoefficientTorus (K := Fin dim) U)] +variable [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] +variable [BorelSpace (CoefficientTorus (K := Fin dim) U)] +variable (μrows : Measure (CoefficientTorus (K := Fin dim) U)) +variable [μrows.IsAddLeftInvariant] [IsProbabilityMeasure μrows] + +include μrows hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ j, Nonempty (rowSets j)] in +theorem allocatedAffineIdeal_recentered_source_of_length + {D target Pk Prho F Tmod : ℝ} + (hdimensions : AllocatedComparisonDimensions (G := G) B (Fin dim) selectedRows D) + (hPk : 0 ≤ Pk) (hMkPk : (Mk : ℝ) ≤ Real.exp Pk) + (hPrho : 0 ≤ Prho) (htarget : 0 ≤ target) (hF : 0 ≤ F) (hTmod : 0 ≤ Tmod) + (hlength : Real.exp (allocatedAffineLengthLog m D P Prho Pk target F Tmod) ≤ S.value) + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U selectedRows → ℝ) + (hgm : ∀ y, Measurable (g y)) (hg0 : ∀ y z, 0 ≤ g y z) + (hgi : ∀ y, Integrable (g y) jetHaar) + (hglaw : ∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows) = realDensityMeasure jetHaar (g y)) + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) + (hδ : 0 < δ) (hδF : δ⁻¹ ≤ Real.exp F) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hmodulus : (modulus : ℝ) ≤ Real.exp Tmod) + (selection : (Fin dim) ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card (Fin dim) ≤ m + 1) + (hrowDegree : ∀ j (a : rowSets j), a.val.card ≤ j.val + 1) + (hperiod : ∀ j : Fin m, integerScalarLattice (selectedRows j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := (Fin dim)) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue (allocatedAffineLength_slice_ready B U basis hdimensions hP hPrho hPk htarget hF hTmod S hlength H₀ step₀ c₀ hsubset₀ hδ hδF modulus hm hmodulus hstep hdense).2.1).weight v₀ ≠ 0) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius (Fin dim) m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card (Fin dim) * ((Fintype.card (Fin dim) : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (hρlog : (ρ grid : ℝ)⁻¹ ≤ Real.exp Prho) + (hη0 : 0 ≤ η) + (hηsmall : η ≤ Real.exp (-(target + 1 + D * ((m * 2 ^ (m + 1) : ℕ) * Pk) + 4))) : + let center := principalProgressionSliceCenter (α := (Fin dim)) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := (Fin dim)) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, selectedRows a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option (Fin dim)) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let profile := fun y => ((gridLaw).mean (fun u => + allocatedWholeMaskedCoveredProfile B U basis hR hσ S x rows + hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ) + ∀ (spatialModulus : ℕ) [NeZero spatialModulus] (stride N : X → ℕ), + let refined := residueRefinedPeriod spatialModulus stride + let labels := PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod refined + ∀ (wholeReference : labels → PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U basis S)) (r : labels), + (∀ y, (wholeLaw).weight y ≠ 0 → principalResidueLabel refined y = r) → + principalResidueLabel refined (wholeReference r) = r → + ∀ {W τ ξn mesh : ℝ} (hW : 0 ≤ W) (base : X → ℤ) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j ex, coefficients (poly j) ex ∈ U j) + (test : (X → (Unit ⊕ Fin dim) → ℤ) → ℂ), + let point := physicalCubeRowSample U d rows poly hmem + ∀ (model : EuclideanJetLayers U selectedRows → ℂ) + {κ loss εtrunc Psample Rrank Sstride εsample ηsample δsur : ℝ}, + (∀ i, 0 < stride i) → (∀ i, 0 < N i) → 0 < τ → 0 < mesh → + allocatedPhysicalRootBudget B U basis S (fun _ => 0) ≤ W → + integerScalarLattice (Unit ⊕ Fin dim) (spatialModulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection) → + (∀ v, ‖test v‖ ≤ 1) → + κ ≤ ((wholeLaw).complexMean (allocatedRecenteredProfileTerm (τ := τ) (ξ := ξn) + B U basis S X spatialModulus stride wholeReference x hMk selection hgood N hW mesh base cells point test + (fun y z => (g y z : ℂ)))).re → + 0 ≤ εtrunc → (∀ z, ‖profile z - model z‖ ≤ εtrunc) → + 0 ≤ Psample → (Fintype.card X : ℝ) ≤ Psample → + (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ Psample → + (d : ℝ) ≤ Real.exp Psample → + 0 ≤ Sstride → Sstride ≤ Real.exp Psample → 0 < εsample → + 1 / τ ≤ Real.exp Psample → 1 / εsample ≤ Real.exp Psample → + (∀ i, (stride i : ℝ) ≤ Sstride) → + let A := Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,0} m dim) + (∀ i, Real.exp ((Psample + A) ^ A) ≤ (N i : ℝ)) → + (∀ j, HasLayerSamplingRank (j.val + 1) (fun i => (N i : ℝ)) Rrank (U j) (poly j)) → + Real.exp ((Psample + A) ^ A) ≤ Rrank → + ∀ (actual surrogate : (JetAmbientIndex selectedRows J → UnitAddCircle) → ℂ) + (La Ls Ca Cs : ℝ≥0), + LipschitzWith La actual → LipschitzWith Ls surrogate → + (∀ z, ‖actual z‖ ≤ Ca) → (∀ z, ‖surrogate z‖ ≤ Cs) → + 0 < ηsample → (Fintype.card (CoefficientAmbientIndex (Fin dim) J) : ℝ) ≤ Psample → + (La : ℝ) ≤ Real.exp Psample → (Ls : ℝ) ≤ Real.exp Psample → + (Ca : ℝ) ≤ Real.exp Psample → (Cs : ℝ) ≤ Real.exp Psample → + ((∑ j : Fin m, (Fintype.card (BoundedCoefficientExponent (Fin dim) (j.val + 1)) : ℝ≥0) : ℝ≥0) : ℝ) ≤ Real.exp Psample → + ηsample⁻¹ ≤ Real.exp Psample → + (∀ y, ((wholeLaw).mean (fun v => g v y) : ℂ) = actual (coveredJetAmbientTorus U 1 y)) → + (∀ y, ‖profile y - surrogate (coveredJetAmbientTorus U 1 y)‖ ≤ δsur) → + let root := allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x (wholeReference r) + let dirs := allocatedPhysicalCubeDirections B U basis S x (wholeReference r) + let Hsp := trimmedSpatialRootScale τ N stride + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξn N + let Csp := ((spatialModulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (Mk : ℝ))) ^ Fintype.card X + let volumeFactor := (30 / smoothProbabilityProfile 0) ^ Fintype.card (Option (Fin dim) × X) * + (((1 + W) / S.value) ^ dim) ^ Fintype.card X + (∀ z, 0 < V z) → (0 < ∑' z, selectedResidueSmoothWeight stride cells V z) → + (∀ t i, (∑ k, |(physicalCubeCoefficient root dirs i k : ℝ)|) ≤ Hsp t) → + (∀ t, 8 * (probabilityProfileLipschitz : ℝ) ≤ 20 * Hsp t) → + (∀ t, 1 ≤ Hsp t) → + Csp * (volumeFactor * (Real.exp (-target) + 2 * δsur + (2 * ηsample + εsample)) + + ((9 : ℝ) ^ Fintype.card (X × (Unit ⊕ Fin dim)) * + (((1 + W) / S.value) ^ dim) ^ Fintype.card X) * εtrunc) ≤ loss → + κ - loss ≤ + (∑ t : cells × spatialWindow (α := Fin dim) Hsp 4, (selectedResidueCellWeight stride cells V t.1 : ℂ) * + allocatedRecenteredResidueWeight (τ := τ) B U basis S X spatialModulus stride wholeReference x hMk selection hgood + N hW mesh base cells test r t.1 t.2.val * + model (point (allocatedWholeResidueReconstruction B U basis S X spatialModulus stride wholeReference x base r + t.1.val t.2.val))).re := by + intro center width ideal profile spatialModulus _ stride N refined labels wholeReference r hlabel hwhole + W τ ξn mesh hW base cells poly hp hmem test point model κ loss εtrunc Psample Rrank Sstride εsample ηsample δsur + hstridepos hN hτ hmesh hrootbudget hspatialPeriod htest hpositive hεtrunc htrunc + hPs hX hframe hdP hSstride hSstrideP hεsample hτP hεsampleP hstride A hsize hrank hRrank + actual surrogate La Ls Ca Cs hLa hLs hCa hCs hηsample hamb hLaP hLsP hCaP hCsP hjet hηsampleP hactual happrox + root dirs Hsp V Csp volumeFactor hV hZ hrows hscale hH1 hcost + apply allocatedRecenteredSelectedMean_l1_source B U basis S X spatialModulus stride wholeReference + x hMk selection hgood N hW mesh base cells point test (wholeLaw) r hlabel hwhole + (fun y z => (g y z : ℂ)) profile model hstridepos hN hτ hrootbudget hmesh hspatialPeriod htest + hpositive hεtrunc htrunc hV hZ hrows hscale hH1 ?_ hcost + intro a + let targetCell := columnResiduePattern stride (standardPhysicalCubeFrame + (physicalCubeRootDifferences root dirs 0 (boundedColumnResidueRepresentative stride a.val))) + let V₁ := referenceJetEnvelopeWidths (q := dim) stride Hsp + have hwidth (z : Option (Fin dim) × X) : τ * (N z.2 : ℝ) ≤ V₁ z := by + change τ * (N z.2 : ℝ) ≤ referenceJetEnvelopeWidths stride (trimmedSpatialRootScale τ N stride) z + rw [referenceJetEnvelopeWidths_trimmed stride N hstridepos τ z] + nlinarith [mul_pos hτ (Nat.cast_pos.mpr (hN z.2))] + have hV₁ (z : Option (Fin dim) × X) : 0 < V₁ z := + (mul_pos hτ (Nat.cast_pos.mpr (hN z.2))).trans_le (hwidth z) + obtain ⟨hZa, he⟩ := allocatedAffineIdeal_sampled_l1_of_length B U basis hR hσ S rowSets x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ν μ μrows + hdimensions hPk hMkPk hPrho htarget hF hTmod hlength + g hgm hg0 hgi hglaw ρ t htone hs hρ hρ1 hσsmall hstep hδ hδF hdense hm hmodulus + selection hgood hq hrowDegree hperiod v₀ hv₀ T hT hsource C hC hchart hbudget hρlog hη0 hηsmall + hPs hX hframe base poly hp hmem hdP stride hstridepos hSstride hSstrideP hτ hεsample hτP hεsampleP + hstride (fun i => (N i : ℝ)) hsize hrank hRrank {targetCell} (Finset.singleton_nonempty _) + V₁ hV₁ hwidth actual surrogate La Ls Ca Cs hLa hLs hCa hCs hηsample hamb hLaP hLsP hCaP hCsP hjet hηsampleP + hactual happrox + exact ⟨hZa, by simpa only [FiniteProbabilityWeights.complexMean_ofReal] using he⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineScaleEnvelope.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineScaleEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..378ba3002228d21c1a55af007879429f0856d7bd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineScaleEnvelope.lean @@ -0,0 +1,570 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedReferenceIdealBudget + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def affineReferenceCoefficientLog {A : Type*} [Semiring A] (D L : A) : A := + 8 * (D + 1) * (L + 1) + +theorem affineReferenceCoefficient_bounds + {D L dlog slog P ideal Ki Cmask boundary : ℝ} + (hD : 0 ≤ D) (hL : 0 ≤ L) + (hdlog : dlog ≤ L) (hslog : slog ≤ L) (hP : P ≤ L) + (hideal : ideal ≤ Real.exp L) (hKi : Ki ≤ Real.exp L) + (hCmask0 : 0 ≤ Cmask) (hCmask : Cmask ≤ Real.exp L) + (hb0 : 0 ≤ boundary) (hb : boundary ≤ Real.exp L) + (axes output unselected integer : ℕ) + (ha : (axes : ℝ) ≤ D) (ho : (output : ℝ) ≤ D) + (hu : (unselected : ℝ) ≤ D) (hi : (integer : ℝ) ≤ D) : + let cap := (Real.exp dlog) ^ axes + let lip := (axes : ℝ) * Real.exp dlog * cap + let radius := max (Real.exp P * ideal) (Real.exp slog) + let mask := Cmask ^ axes + let support := (2 * Real.exp slog) ^ output + let Q := affineReferenceCoefficientLog D L + mask ≤ Real.exp Q ∧ + mask * (2 * cap * boundary + lip * 2) * support ≤ Real.exp Q ∧ + mask * lip * support ≤ Real.exp Q ∧ + mask * (2 * radius) ^ unselected * ((2 * radius + 2) ^ integer * (Ki + lip)) ≤ Real.exp Q := by + intro cap lip radius mask support Q + have hDL : 0 ≤ D * L := mul_nonneg hD hL + have hcap : cap ≤ Real.exp (D * L) := + pow_le_exp_mul_of_le_exp (Real.exp_pos _).le (Real.exp_le_exp.mpr hdlog) hL axes ha + have hm : mask ≤ Real.exp (D * L) := + pow_le_exp_mul_of_le_exp hCmask0 hCmask hL axes ha + have haxes : (axes : ℝ) ≤ Real.exp D := ha.trans (by linarith [Real.add_one_le_exp D]) + have hlip : lip ≤ Real.exp (D + L + D * L) := by + calc + _ ≤ Real.exp D * Real.exp L * Real.exp (D * L) := by dsimp [lip, cap]; gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add] + have h2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have h4 : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have hrad : radius ≤ Real.exp (2 * L) := by + apply max_le + · calc + _ ≤ Real.exp P * Real.exp L := mul_le_mul_of_nonneg_left hideal (Real.exp_pos _).le + _ ≤ Real.exp L * Real.exp L := by gcongr + _ = _ := by rw [← Real.exp_add]; congr 1; ring + · exact Real.exp_le_exp.mpr (by linarith) + have hrad0 : 0 ≤ radius := (Real.exp_pos slog).le.trans (le_max_right _ _) + have hsuppBase : 2 * Real.exp slog ≤ Real.exp (L + 2) := by + calc + _ ≤ Real.exp L * Real.exp 2 := by rw [mul_comm 2]; gcongr + _ = _ := (Real.exp_add _ _).symm + have hsupp : support ≤ Real.exp (D * (L + 2)) := + pow_le_exp_mul_of_le_exp (by positivity) hsuppBase (by positivity) output ho + have hradBase : 2 * radius ≤ Real.exp (2 * L + 2) := by + calc + _ ≤ Real.exp (2 * L) * Real.exp 2 := by rw [mul_comm 2]; gcongr + _ = _ := (Real.exp_add _ _).symm + have hradPlus : 2 * radius + 2 ≤ Real.exp (2 * L + 4) := by + have h1 : 1 ≤ Real.exp (2 * L) := Real.one_le_exp_iff.mpr (by positivity) + calc + _ ≤ 4 * Real.exp (2 * L) := by linarith only [hrad, h1] + _ ≤ Real.exp (2 * L) * Real.exp 4 := by nlinarith [Real.exp_pos (2 * L)] + _ = _ := (Real.exp_add _ _).symm + have hru := pow_le_exp_mul_of_le_exp (mul_nonneg (by norm_num) hrad0) hradBase + (by positivity : 0 ≤ 2 * L + 2) unselected hu + have hri := pow_le_exp_mul_of_le_exp (by positivity : 0 ≤ 2 * radius + 2) hradPlus + (by positivity : 0 ≤ 2 * L + 4) integer hi + have hbl : 2 * cap * boundary ≤ Real.exp (D * L + L + 2) := by + calc + _ ≤ Real.exp (D * L) * Real.exp L * Real.exp 2 := by + rw [show 2 * cap * boundary = cap * boundary * 2 by ring] + gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add] + have hll : lip * 2 ≤ Real.exp (D + L + D * L + 2) := by + calc + _ ≤ Real.exp (D + L + D * L) * Real.exp 2 := by gcongr + _ = _ := (Real.exp_add _ _).symm + have hboundary := add_le_exp_add_one (by positivity : 0 ≤ D * L + L + 2) + (by positivity : 0 ≤ D + L + D * L + 2) hbl hll + have hsum := add_le_exp_add_one hL (by positivity : 0 ≤ D + L + D * L) hKi hlip + have hlog₀ : D * L ≤ Q := by dsimp [Q, affineReferenceCoefficientLog]; nlinarith only [hDL, hD, hL] + have hlog₁ : D * L + ((D * L + L + 2) + (D + L + D * L + 2) + 1) + D * (L + 2) ≤ Q := by + dsimp [Q, affineReferenceCoefficientLog]; nlinarith only [hDL, hD, hL] + have hlog₂ : D * L + (D + L + D * L) + D * (L + 2) ≤ Q := by + dsimp [Q, affineReferenceCoefficientLog]; nlinarith only [hDL, hD, hL] + have hlog₃ : D * L + D * (2 * L + 2) + + (D * (2 * L + 4) + (L + (D + L + D * L) + 1)) ≤ Q := by + dsimp [Q, affineReferenceCoefficientLog]; nlinarith only [hDL, hD, hL] + refine ⟨hm.trans (Real.exp_le_exp.mpr hlog₀), ?_, ?_, ?_⟩ + · calc + _ ≤ Real.exp (D * L) * Real.exp ((D * L + L + 2) + (D + L + D * L + 2) + 1) * + Real.exp (D * (L + 2)) := by gcongr + _ ≤ _ := by rw [← Real.exp_add, ← Real.exp_add]; exact Real.exp_le_exp.mpr hlog₁ + · calc + _ ≤ Real.exp (D * L) * Real.exp (D + L + D * L) * Real.exp (D * (L + 2)) := by gcongr + _ ≤ _ := by rw [← Real.exp_add, ← Real.exp_add]; exact Real.exp_le_exp.mpr hlog₂ + · by_cases hneg : Ki + lip < 0 + · exact (mul_nonpos_of_nonneg_of_nonpos (by positivity) + (mul_nonpos_of_nonneg_of_nonpos (by positivity) hneg.le)).trans (Real.exp_pos Q).le + · have hsum0 := le_of_not_gt hneg + calc + _ ≤ Real.exp (D * L) * Real.exp (D * (2 * L + 2)) * + (Real.exp (D * (2 * L + 4)) * Real.exp (L + (D + L + D * L) + 1)) := by gcongr + _ ≤ _ := by simp only [← Real.exp_add]; exact Real.exp_le_exp.mpr hlog₃ + +theorem affineReferenceError_accuracy {target Q mask cap lip boundary support volume Ki η ratio ε mesh : ℝ} + (hη0 : 0 ≤ η) (hratio0 : 0 ≤ ratio) (hε0 : 0 ≤ ε) (hmesh0 : 0 ≤ mesh) + (hcoeff : mask ≤ Real.exp Q ∧ + mask * (2 * cap * boundary + lip * 2) * support ≤ Real.exp Q ∧ + mask * lip * support ≤ Real.exp Q ∧ mask * volume * (Ki + lip) ≤ Real.exp Q) + (hη : η ≤ Real.exp (-(target + Q + 4))) + (hratio : ratio ≤ Real.exp (-(target + Q + 4))) + (hε : ε ≤ Real.exp (-(target + Q + 4))) + (hmesh : mesh ≤ Real.exp (-(target + Q + 4))) : + mask * (η + ((2 * cap * boundary + lip * 2) * ratio + lip * ε) * support + + volume * (Ki + lip) * mesh) ≤ Real.exp (-target) := by + have hterm {c x : ℝ} (hc : c ≤ Real.exp Q) (hx0 : 0 ≤ x) + (hx : x ≤ Real.exp (-(target + Q + 4))) : c * x ≤ Real.exp (-(target + 4)) := by + calc + _ ≤ Real.exp Q * Real.exp (-(target + Q + 4)) := + (mul_le_mul_of_nonneg_right hc hx0).trans (mul_le_mul_of_nonneg_left hx (Real.exp_pos _).le) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have h₁ := hterm hcoeff.1 hη0 hη + have h₂ := hterm hcoeff.2.1 hratio0 hratio + have h₃ := hterm hcoeff.2.2.1 hε0 hε + have h₄ := hterm hcoeff.2.2.2 hmesh0 hmesh + have hsum : mask * (η + ((2 * cap * boundary + lip * 2) * ratio + lip * ε) * support + + volume * (Ki + lip) * mesh) ≤ 4 * Real.exp (-(target + 4)) := by + nlinarith only [h₁, h₂, h₃, h₄] + have h4 : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + calc + _ ≤ 4 * Real.exp (-(target + 4)) := hsum + _ ≤ Real.exp 4 * Real.exp (-(target + 4)) := mul_le_mul_of_nonneg_right h4 (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem affineReferenceError_accuracy_separated {target Q Qη mask cap lip boundary support volume Ki η ratio ε mesh : ℝ} + (hη0 : 0 ≤ η) (hratio0 : 0 ≤ ratio) (hε0 : 0 ≤ ε) (hmesh0 : 0 ≤ mesh) + (hcoeff : mask ≤ Real.exp Qη ∧ + mask * (2 * cap * boundary + lip * 2) * support ≤ Real.exp Q ∧ + mask * lip * support ≤ Real.exp Q ∧ mask * volume * (Ki + lip) ≤ Real.exp Q) + (hη : η ≤ Real.exp (-(target + Qη + 4))) + (hratio : ratio ≤ Real.exp (-(target + Q + 4))) + (hε : ε ≤ Real.exp (-(target + Q + 4))) + (hmesh : mesh ≤ Real.exp (-(target + Q + 4))) : + mask * (η + ((2 * cap * boundary + lip * 2) * ratio + lip * ε) * support + + volume * (Ki + lip) * mesh) ≤ Real.exp (-target) := by + have hterm {c x Q : ℝ} (hc : c ≤ Real.exp Q) (hx0 : 0 ≤ x) + (hx : x ≤ Real.exp (-(target + Q + 4))) : c * x ≤ Real.exp (-(target + 4)) := by + calc + _ ≤ Real.exp Q * Real.exp (-(target + Q + 4)) := + (mul_le_mul_of_nonneg_right hc hx0).trans (mul_le_mul_of_nonneg_left hx (Real.exp_pos _).le) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have h₁ := hterm hcoeff.1 hη0 hη + have h₂ := hterm hcoeff.2.1 hratio0 hratio + have h₃ := hterm hcoeff.2.2.1 hε0 hε + have h₄ := hterm hcoeff.2.2.2 hmesh0 hmesh + have hsum : mask * (η + ((2 * cap * boundary + lip * 2) * ratio + lip * ε) * support + + volume * (Ki + lip) * mesh) ≤ 4 * Real.exp (-(target + 4)) := by + nlinarith only [h₁, h₂, h₃, h₄] + have h4 : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + calc + _ ≤ 4 * Real.exp (-(target + 4)) := hsum + _ ≤ Real.exp 4 * Real.exp (-(target + 4)) := mul_le_mul_of_nonneg_right h4 (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped BigOperators Classical NNReal + +def allocatedAffineL1Log {A : Type*} [Semiring A] (m : ℕ) (D P Prho Pk : A) : A := + P + ((m * 2 ^ (m + 1) : ℕ) * Pk + allocatedDensityEnvelope m D P) + + allocatedSupportEnvelope m D P + allocatedIdealLipEnvelope D P Prho + + ((m + 1 : ℕ) * D + 2) + scalarCubeRiemannLog D + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] + +theorem allocatedAffineL1_primitive_bounds {D P Prho Pk : ℝ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) + (hP : 0 ≤ P) (hPrho : 0 ≤ Prho) (hPk : 0 ≤ Pk) + {Mk : ℕ} (hMk : (Mk : ℝ) ≤ Real.exp Pk) + (partition : LayerSamplerAxis I n → Prop) + (R : Fin m → ℝ) (hR : ∀ j, 0 ≤ R j) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (ρ : ℝ≥0) (hρ : (ρ : ℝ)⁻¹ ≤ Real.exp Prho) : + let L := allocatedAffineL1Log m D P Prho Pk + let Output := Σ a : {a // ¬partition a}, O a.val.1 + 0 ≤ L ∧ P ≤ L ∧ + allocatedDensityLog (G := G) B α O P ≤ L ∧ + allocatedJetSupportLog (G := G) B α O P ≤ L ∧ + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) ≤ Real.exp L ∧ + partitionedIdealRadius α m + 1 ≤ Real.exp L ∧ + ‖(∏ o : Output, |R o.1.val.1|)⁻¹‖ * + ((affineProductProfileLip Output ρ : ℝ) * Real.exp P) ≤ Real.exp L ∧ + ((m * 2 ^ (m + 1) : ℕ) : ℝ) * Pk ≤ L ∧ + scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) ≤ Real.exp L := by + intro L Output + have hD := hdim.nonneg + have hden := allocatedDensityEnvelope_nonneg m hD hP + have hsupp := allocatedSupportEnvelope_nonneg m hD hP + have hindex : 0 ≤ ((m * 2 ^ (m + 1) : ℕ) : ℝ) * Pk := mul_nonneg (Nat.cast_nonneg _) hPk + have hlip : 0 ≤ allocatedIdealLipEnvelope D P Prho := by + unfold allocatedIdealLipEnvelope + positivity + have hradius : 0 ≤ ((m + 1 : ℕ) : ℝ) * D + 2 := by positivity + have hboundary : 0 ≤ scalarCubeRiemannLog D := by unfold scalarCubeRiemannLog; positivity + have hpieces : 0 ≤ L ∧ P ≤ L ∧ + ((m * 2 ^ (m + 1) : ℕ) : ℝ) * Pk + allocatedDensityEnvelope m D P ≤ L ∧ + allocatedSupportEnvelope m D P ≤ L ∧ allocatedIdealLipEnvelope D P Prho ≤ L ∧ + ((m + 1 : ℕ) : ℝ) * D + 2 ≤ L ∧ scalarCubeRiemannLog D ≤ L := by + dsimp only [L, allocatedAffineL1Log] + exact ⟨by linarith, by linarith, by linarith, by linarith, by linarith, by linarith, by linarith⟩ + have hdenL : allocatedDensityEnvelope m D P ≤ L := by linarith only [hpieces.2.2.1, hindex] + refine ⟨hpieces.1, hpieces.2.1, (allocatedDensityLog_le_envelope B hdim hP).trans hdenL, + (allocatedJetSupportLog_le_envelope B hdim hP).trans hpieces.2.2.2.1, ?_, ?_, ?_, ?_, ?_⟩ + · calc + _ ≤ Real.exp (((m * 2 ^ (m + 1) : ℕ) : ℝ) * Pk) * Real.exp (allocatedDensityEnvelope m D P) := + mul_le_mul (layerKernelIndexBound_le_exp m hMk) + (Real.exp_le_exp.mpr (allocatedDensityLog_le_envelope B hdim hP)) (Real.exp_nonneg _) (Real.exp_nonneg _) + _ ≤ _ := by rw [← Real.exp_add]; exact Real.exp_le_exp.mpr hpieces.2.2.1 + · apply (partitionedIdealRadius_add_one_le_exp α m).trans + apply Real.exp_le_exp.mpr + have hdim' := mul_le_mul_of_nonneg_left hdim.cube (by positivity : 0 ≤ (m : ℝ) + 1) + have hb := hpieces.2.2.2.2.2.1 + push_cast at hb + linarith + · have hk := diagonalProfileLip_le_exp (fun o : Output => R o.1.val.1) + (fun o => hR o.1.val.1) hP hPrho (hdim.active_outputs B partition) hdim.profile + (fun o => hRi o.1.val.1) hρ + simp only [NNReal.coe_mul, NNReal.coe_mk, coe_nnnorm] at hk + simp_rw [abs_of_nonneg (hR _)] + exact hk.trans (Real.exp_le_exp.mpr hpieces.2.2.2.2.1) + · linarith only [hpieces.2.2.1, hden] + · exact (scalarCubeRiemannBoundary_le_exp α hD hdim.cube).trans + (Real.exp_le_exp.mpr hpieces.2.2.2.2.2.2) + +theorem exists_allocatedAffineL1Log_bound (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ D P Prho Pk : ℝ, + 0 ≤ D → 0 ≤ P → 0 ≤ Prho → 0 ≤ Pk → + allocatedAffineL1Log m D P Prho Pk ≤ (D + P + Prho + Pk + A) ^ A := by + let X : Polynomial ℕ := Polynomial.X + let poly := allocatedAffineL1Log m X X X X + obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget poly + refine ⟨A, hA, ?_⟩ + intro D P Prho Pk hD hP hPrho hPk + let Q := D + P + Prho + Pk + have hQ : 0 ≤ Q := by dsimp [Q]; linarith + have hDQ : D ≤ Q := by dsimp [Q]; linarith + have hPQ : P ≤ Q := by dsimp [Q]; linarith + have hrQ : Prho ≤ Q := by dsimp [Q]; linarith + have hkQ : Pk ≤ Q := by dsimp [Q]; linarith + have hkernel : kernelOutputEnvelope D (4 * (P + 8)) ≤ kernelOutputEnvelope Q (4 * (Q + 8)) := by + unfold kernelOutputEnvelope kernelGeometryEnvelope kernelInverseEnvelope + gcongr + have hden : allocatedDensityEnvelope m D P ≤ allocatedDensityEnvelope m Q Q := by + unfold allocatedDensityEnvelope + gcongr + have hsupp : allocatedSupportEnvelope m D P ≤ allocatedSupportEnvelope m Q Q := by + unfold allocatedSupportEnvelope + gcongr + have hmono : allocatedAffineL1Log m D P Prho Pk ≤ allocatedAffineL1Log m Q Q Q Q := by + unfold allocatedAffineL1Log allocatedIdealLipEnvelope scalarCubeRiemannLog + gcongr + apply hmono.trans + simpa [poly, X, allocatedAffineL1Log, allocatedDensityEnvelope, allocatedSupportEnvelope, + allocatedIdealLipEnvelope, scalarCubeRiemannLog, kernelOutputEnvelope, + kernelGeometryEnvelope, kernelInverseEnvelope, Polynomial.eval₂_pow, Nat.cast_add, Nat.cast_mul] + using hbound Q hQ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +noncomputable def allocatedAffineCoefficientAccuracyLog {A : Type*} [Semiring A] + (m : ℕ) (D P Prho Pk target : A) : A := + target + 1 + coefficientReplacementErrorLog D (allocatedAffineL1Log m D P Prho Pk) + +noncomputable def allocatedAffineReferenceAccuracyLog {A : Type*} [Semiring A] + (m : ℕ) (D P Prho Pk target : A) : A := + target + 1 + affineReferenceCoefficientLog D (allocatedAffineL1Log m D P Prho Pk) + 4 + +noncomputable def allocatedAffineLengthLog {A : Type*} [Semiring A] + (m : ℕ) (D P Prho Pk target F T : A) : A := + m * allocatedFrontEnvelope m D P (allocatedAffineCoefficientAccuracyLog m D P Prho Pk target) + + progressionSliceLengthLog D (allocatedAffineReferenceAccuracyLog m D P Prho Pk target) F T + + theorem allocatedAffineL1Log_nonneg (m : ℕ) {D P Prho Pk : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hr : 0 ≤ Prho) (hk : 0 ≤ Pk) : + 0 ≤ allocatedAffineL1Log m D P Prho Pk := by + have hd := allocatedDensityEnvelope_nonneg m hD hP + have hs := allocatedSupportEnvelope_nonneg m hD hP + dsimp only [allocatedAffineL1Log, allocatedIdealLipEnvelope, scalarCubeRiemannLog] + positivity + + theorem allocatedAffineLengthLog_bounds (m : ℕ) {D P Prho Pk target F T : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hr : 0 ≤ Prho) (hk : 0 ≤ Pk) + (ht : 0 ≤ target) (hF : 0 ≤ F) (hT : 0 ≤ T) : + let e := allocatedAffineCoefficientAccuracyLog m D P Prho Pk target + let E := allocatedAffineReferenceAccuracyLog m D P Prho Pk target + let L := allocatedAffineLengthLog m D P Prho Pk target F T + 0 ≤ e ∧ 0 ≤ E ∧ 0 ≤ L ∧ E ≤ L ∧ + (m : ℝ) * allocatedFrontEnvelope m D P e ≤ L ∧ + progressionSliceLengthLog D E F T ≤ L := by + intro e E L + have hb := allocatedAffineL1Log_nonneg m hD hP hr hk + have he : 0 ≤ e := by dsimp [e, allocatedAffineCoefficientAccuracyLog, coefficientReplacementErrorLog]; positivity + have hE : 0 ≤ E := by dsimp [E, allocatedAffineReferenceAccuracyLog, affineReferenceCoefficientLog]; positivity + have hki := kernelInverseEnvelope_nonneg hD hP + have hf : 0 ≤ (m : ℝ) * allocatedFrontEnvelope m D P e := by + dsimp [allocatedFrontEnvelope, allocatedKernelEnvelope]; positivity + have hs : 0 ≤ progressionSliceLengthLog D E F T := by + dsimp [progressionSliceLengthLog, scalarCubeRiemannLog]; positivity + have hEL : E ≤ progressionSliceLengthLog D E F T := by + have hB : 0 ≤ scalarCubeRiemannLog D := by unfold scalarCubeRiemannLog; positivity + dsimp only [progressionSliceLengthLog]; linarith + refine ⟨he, hE, add_nonneg hf hs, ?_, le_add_of_nonneg_right hs, le_add_of_nonneg_left hf⟩ + exact hEL.trans (le_add_of_nonneg_left hf) + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {α : Type*} [Fintype α] {O : Fin m → Type*} [∀ j, Fintype (O j)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +noncomputable def allocatedAffineScale (D P Prho Pk target F T : ℝ) : + LayerSamplerScale (G := G) B U basis R σ := + selectedLayerSamplerScale B U basis R σ hR hσ + ⌈Real.exp (allocatedAffineLengthLog m D P Prho Pk target F T)⌉₊ + + theorem allocatedAffineScale_lower (D P Prho Pk target F T : ℝ) : + Real.exp (allocatedAffineLengthLog m D P Prho Pk target F T) ≤ + ((allocatedAffineScale (G := G) B U basis hR hσ D P Prho Pk target F T).value : ℝ) := + (Nat.le_ceil _).trans (Nat.cast_le.mpr + (selectedLayerSamplerScale_bounds B U basis R σ hR hσ _).1) + + theorem allocatedAffineScale_upper {D P Prho Pk target F T : ℝ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) + (hP : 0 ≤ P) (hr : 0 ≤ Prho) (hk : 0 ≤ Pk) (ht : 0 ≤ target) + (hF : 0 ≤ F) (hT : 0 ≤ T) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) : + ((allocatedAffineScale (G := G) B U basis hR hσ D P Prho Pk target F T).value : ℝ) ≤ + Real.exp (allocatedScaleLog (D + P + allocatedAffineLengthLog m D P Prho Pk target F T + 1)) := by + let L := allocatedAffineLengthLog m D P Prho Pk target F T + let Q := D + P + L + 1 + have hD := hdim.nonneg + have hL := (allocatedAffineLengthLog_bounds m hD hP hr hk ht hF hT).2.2.1 + have hQ : 0 ≤ Q := by dsimp [Q]; linarith + have hDQ : D ≤ Q := by dsimp [Q]; linarith + have hPQ : P ≤ Q := by dsimp [Q]; linarith + have hLQ : L + 1 ≤ Q := by dsimp [Q]; linarith + apply selectedLayerSamplerScale_exp_bound B U basis R σ hR hσ _ hQ + (hdim.degree.trans hDQ) (fun j => (hdim.integer_axes B j).trans hDQ) + (fun j => (hRi j).trans (Real.exp_le_exp.mpr hPQ)) + (fun j => (hσi j).trans (Real.exp_le_exp.mpr hPQ)) + (fun j => (hdim.coefficients j).trans hDQ) + · exact (hdim.profile.trans hDQ).trans (by linarith [Real.add_one_le_exp Q]) + · exact (natCeil_le_exp_succ_of_le hL le_rfl).trans (Real.exp_le_exp.mpr hLQ) + + theorem allocatedAffineLength_ready {D P Prho Pk target F T : ℝ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) + (hP : 0 ≤ P) (hr : 0 ≤ Prho) (hk : 0 ≤ Pk) (ht : 0 ≤ target) + (hF : 0 ≤ F) (hT : 0 ≤ T) + (S : LayerSamplerScale (G := G) B U basis R σ) + (hS : Real.exp (allocatedAffineLengthLog m D P Prho Pk target F T) ≤ S.value) : + let e := allocatedAffineCoefficientAccuracyLog m D P Prho Pk target + let E := allocatedAffineReferenceAccuracyLog m D P Prho Pk target + Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value ∧ + 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ Real.exp (-E) ∧ + Real.exp (progressionSliceLengthLog D E F T) ≤ S.value := by + intro e E + obtain ⟨he, hE, _, hEL, hf, hs⟩ := + allocatedAffineLengthLog_bounds m hdim.nonneg hP hr hk ht hF hT + refine ⟨?_, ?_, (Real.exp_le_exp.mpr hs).trans hS⟩ + · exact (Real.exp_le_exp.mpr ((allocatedKernelReplacementLog_le_envelope B hdim hP).trans hf)).trans hS + · have hES : Real.exp E ≤ S.value := (Real.exp_le_exp.mpr hEL).trans hS + have hS1 : (1 : ℝ) ≤ S.value := (Real.one_le_exp_iff.mpr hE).trans hES + have hpow : (S.value : ℝ) ≤ (S.value : ℝ) ^ (layerTailDegree m + 1) := by + simpa only [pow_one] using pow_le_pow_right₀ hS1 (Nat.succ_le_succ (Nat.zero_le _)) + calc + _ ≤ 1 / Real.exp E := one_div_le_one_div_of_le (Real.exp_pos _) (hES.trans hpow) + _ = _ := by rw [Real.exp_neg, one_div] + + theorem AllocatedComparisonDimensions.active_tuples {D : ℝ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) + (partition : LayerSamplerAxis I n → Prop) : + (Fintype.card (PrincipalTupleIndex (fun a : {a // ¬partition a} => B a.val) + (fun a => layerSamplerDegree I n a.val)) : ℝ) ≤ D := + (Nat.cast_le.mpr (dependentAxis_card_restrict_le + (fun a => B a × Fin (layerSamplerDegree I n a)) (fun a => ¬partition a))).trans hdim.tuples + + theorem allocatedAffineLength_slice_ready [DecidableEq α] + {D P Prho Pk target F T δ : ℝ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) + (hP : 0 ≤ P) (hr : 0 ≤ Prho) (hk : 0 ≤ Pk) (ht : 0 ≤ target) + (hF : 0 ≤ F) (hT : 0 ≤ T) + (S : LayerSamplerScale (G := G) B U basis R σ) + (hS : Real.exp (allocatedAffineLengthLog m D P Prho Pk target F T) ≤ S.value) + (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) + (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S j : ℤ)) + (hδ : 0 < δ) (hδF : δ⁻¹ ≤ Real.exp F) + (modulus : ℕ) (hm : 0 < modulus) (hmT : (modulus : ℝ) ≤ Real.exp T) : + let grid := allocatedGridAxis (I := I) U basis S.value + let Tuple := PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) + let embed := fun j : Tuple => (⟨j.1.val, j.2⟩ : PrincipalTupleIndex B (layerSamplerDegree I n)) + let E := allocatedAffineReferenceAccuracyLog m D P Prho Pk target + (∀ j : Tuple, 0 < step (embed j)) → + (∀ j : Tuple, δ * allocatedPrincipalSides B U basis S (embed j) ≤ + ((integerProgressionSupport (c (embed j)) (step (embed j) : ℤ) (H (embed j))).card : ℝ)) → + (∀ j : Tuple, 2 ≤ H (embed j)) ∧ + (∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H (embed j)) ∧ + (∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H (embed j)) < + MeasureTheory.volume.real (scalarCubeDomain α)) ∧ + (∑ j : Tuple, (modulus : ℝ) / H (embed j)) ≤ Real.exp (-E) ∧ + (∀ j : Tuple, (step (embed j) : ℝ) / allocatedPrincipalSides B U basis S (embed j) ≤ + Real.exp (-E)) := by + intro grid Tuple embed E hstep hdense + have hlen (j : Tuple) : allocatedPrincipalSides B U basis S (embed j) = S.value := + allocatedPrincipalSides_long B U basis S j.1.val j.1.property j.2.1 j.2.2 + have hready := allocatedAffineLength_ready B U basis hdim hP hr hk ht hF hT S hS + have hE := (allocatedAffineLengthLog_bounds m hdim.nonneg hP hr hk ht hF hT).2.1 + have hslices := progressionSlice_scale_bounds (α := α) + (fun j : Tuple => H (embed j)) (fun j : Tuple => step (embed j)) (fun j : Tuple => c (embed j)) + hdim.nonneg hE hF hT (hdim.active_tuples B grid) hdim.cube hδ hδF hm hmT hready.2.2 hstep + (fun j => by simpa only [hlen j] using hsubset (embed j)) + (fun j => by simpa only [hlen j] using hdense j) + simpa only [hlen] using hslices + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem allocatedAffineLengthLog_kernel_bound {m : ℕ} (hm : 0 < m) + {D P Prho Pk target F T : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hr : 0 ≤ Prho) (hk : 0 ≤ Pk) + (ht : 0 ≤ target) (hF : 0 ≤ F) (hT : 0 ≤ T) : + Pk ≤ allocatedAffineLengthLog m D P Prho Pk target F T := by + let L := allocatedAffineL1Log m D P Prho Pk + have hL : 0 ≤ L := allocatedAffineL1Log_nonneg m hD hP hr hk + have hd := allocatedDensityEnvelope_nonneg m hD hP + have hs := allocatedSupportEnvelope_nonneg m hD hP + have hi : 0 ≤ allocatedIdealLipEnvelope D P Prho := by + unfold allocatedIdealLipEnvelope + positivity + have hb : 0 ≤ scalarCubeRiemannLog D := by unfold scalarCubeRiemannLog; positivity + have hc : (1 : ℝ) ≤ ((m * 2 ^ (m + 1) : ℕ) : ℝ) := by + exact_mod_cast (Nat.mul_pos hm (pow_pos (by decide : 0 < (2 : ℕ)) _)) + have hkL : Pk ≤ L := by + have hprod := mul_le_mul_of_nonneg_right hc hk + dsimp only [L, allocatedAffineL1Log] + have hrad : 0 ≤ ((m + 1 : ℕ) : ℝ) * D := mul_nonneg (Nat.cast_nonneg _) hD + nlinarith + have hLE : L ≤ allocatedAffineReferenceAccuracyLog m D P Prho Pk target := by + have hp := mul_nonneg hD (add_nonneg hL zero_le_one) + dsimp only [allocatedAffineReferenceAccuracyLog, affineReferenceCoefficientLog] + change L ≤ target + 1 + 8 * (D + 1) * (L + 1) + 4 + nlinarith + exact hkL.trans (hLE.trans (allocatedAffineLengthLog_bounds m hD hP hr hk ht hF hT).2.2.2.1) + +theorem allocatedAffineLength_kernel_ready {m : ℕ} (hm : 0 < m) + {D P Prho Pk target F T : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hr : 0 ≤ Prho) (hk : 0 ≤ Pk) + (ht : 0 ≤ target) (hF : 0 ≤ F) (hT : 0 ≤ T) + {Mk S : ℕ} (hMk : (Mk : ℝ) ≤ Real.exp Pk) + (hS : Real.exp (allocatedAffineLengthLog m D P Prho Pk target F T) ≤ (S : ℝ)) : Mk ≤ S := by + exact_mod_cast hMk.trans ((Real.exp_le_exp.mpr + (allocatedAffineLengthLog_kernel_bound hm hD hP hr hk ht hF hT)).trans hS) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +noncomputable def allocatedAffineScalePolynomial {A : Type*} [Semiring A] + (m : ℕ) (D P Lb target F T : A) : A := + let e := target + 1 + coefficientReplacementErrorLog D Lb + let E := target + 1 + affineReferenceCoefficientLog D Lb + 4 + let Q := D + P + (m * allocatedFrontEnvelope m D P e + progressionSliceLengthLog D E F T) + 1 + (1 + Q ^ 2) * (5 * Q + 49) + + theorem exists_allocatedAffineScaleLog_bound (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ D P Prho Pk target F T : ℝ, + 0 ≤ D → 0 ≤ P → 0 ≤ Prho → 0 ≤ Pk → 0 ≤ target → 0 ≤ F → 0 ≤ T → + allocatedScaleLog (D + P + allocatedAffineLengthLog m D P Prho Pk target F T + 1) ≤ + (D + P + Prho + Pk + target + F + T + A) ^ A := by + obtain ⟨b, hb, hLb⟩ := exists_allocatedAffineL1Log_bound m + let X : Polynomial ℕ := Polynomial.X + let poly := allocatedAffineScalePolynomial m X X ((X + Polynomial.C b) ^ b) X X X + obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget poly + refine ⟨A, hA, ?_⟩ + intro D P Prho Pk target F T hD hP hr hk ht hF hT + let Q := D + P + Prho + Pk + target + F + T + have hQ : 0 ≤ Q := by dsimp [Q]; positivity + have hDQ : D ≤ Q := by dsimp [Q]; linarith + have hPQ : P ≤ Q := by dsimp [Q]; linarith + have htQ : target ≤ Q := by dsimp [Q]; linarith + have hFQ : F ≤ Q := by dsimp [Q]; linarith + have hTQ : T ≤ Q := by dsimp [Q]; linarith + have hl0 := allocatedAffineL1Log_nonneg m hD hP hr hk + have hl : allocatedAffineL1Log m D P Prho Pk ≤ (Q + b) ^ b := by + apply (hLb D P Prho Pk hD hP hr hk).trans + apply pow_le_pow_left₀ (by positivity) + dsimp [Q]; linarith + have he : allocatedAffineCoefficientAccuracyLog m D P Prho Pk target ≤ + Q + 1 + coefficientReplacementErrorLog Q ((Q + b) ^ b) := by + dsimp only [allocatedAffineCoefficientAccuracyLog, coefficientReplacementErrorLog] + gcongr + have hE : allocatedAffineReferenceAccuracyLog m D P Prho Pk target ≤ + Q + 1 + affineReferenceCoefficientLog Q ((Q + b) ^ b) + 4 := by + dsimp only [allocatedAffineReferenceAccuracyLog, affineReferenceCoefficientLog] + gcongr + have hi : kernelInverseEnvelope D P ≤ kernelInverseEnvelope Q Q := by + unfold kernelInverseEnvelope + gcongr + have hfront : allocatedFrontEnvelope m D P (allocatedAffineCoefficientAccuracyLog m D P Prho Pk target) ≤ + allocatedFrontEnvelope m Q Q (Q + 1 + coefficientReplacementErrorLog Q ((Q + b) ^ b)) := by + have hki := kernelInverseEnvelope_nonneg hD hP + dsimp only [allocatedFrontEnvelope, allocatedKernelEnvelope] + gcongr + have hslice : progressionSliceLengthLog D (allocatedAffineReferenceAccuracyLog m D P Prho Pk target) F T ≤ + progressionSliceLengthLog Q (Q + 1 + affineReferenceCoefficientLog Q ((Q + b) ^ b) + 4) Q Q := by + dsimp only [progressionSliceLengthLog, scalarCubeRiemannLog] + gcongr + have hL0 := (allocatedAffineLengthLog_bounds m hD hP hr hk ht hF hT).2.2.1 + have hL : allocatedAffineLengthLog m D P Prho Pk target F T ≤ + (m : ℝ) * allocatedFrontEnvelope m Q Q (Q + 1 + coefficientReplacementErrorLog Q ((Q + b) ^ b)) + + progressionSliceLengthLog Q (Q + 1 + affineReferenceCoefficientLog Q ((Q + b) ^ b) + 4) Q Q := by + exact add_le_add (mul_le_mul_of_nonneg_left hfront (Nat.cast_nonneg _)) hslice + have hmono : allocatedScaleLog (D + P + allocatedAffineLengthLog m D P Prho Pk target F T + 1) ≤ + allocatedAffineScalePolynomial m Q Q ((Q + b) ^ b) Q Q Q := by + dsimp only [allocatedScaleLog, allocatedAffineScalePolynomial] + gcongr + apply hmono.trans + simpa [poly, X, allocatedAffineScalePolynomial, allocatedFrontEnvelope, allocatedKernelEnvelope, + kernelInverseEnvelope, kernelGeometryEnvelope, coefficientReplacementErrorLog, + affineReferenceCoefficientLog, progressionSliceLengthLog, scalarCubeRiemannLog, + Polynomial.eval₂_pow] using hbound Q hQ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSecondaryMesh.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSecondaryMesh.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1d8fd46d32c7c87729417a34cad38b4560fa093 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSecondaryMesh.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.Progressions.Dynamics.SecondaryMeshLogBudget +import OAI.Combinatorics.Progressions.Lattices.ConcreteAffineMeshBoundary + +namespace OAI + +section + +namespace Erdos3 + +open scoped Classical + +theorem exists_allocated_affine_secondary_mesh {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z) + (parLo parHi anchor : J → ℤ) (hpar : ∀ j, parLo j < parHi j) (D : ℕ) (hD : 0 < D) + (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ) {L C B A c rho sourceRatio parameterRatio U lengthLog beta : ℝ} + (hL : 0 < L) (hH : ∀ i, 0 < H i) (hC : 0 ≤ C) (hB : 0 ≤ B) (hA : 0 ≤ A) + (hc : 0 < c) (hrho : 0 < rho) (hsRatio : 0 ≤ sourceRatio) (hpRatio : 0 ≤ parameterRatio) + (hU : 0 ≤ U) (hlength : 0 ≤ lengthLog) (hbeta : 0 < beta) + (hsiteLarge : ∀ i, 4 ≤ rho * H i) (hsiteWhole : ∀ i, rho * H i ≤ 2 * (N i : ℝ)) + (hsiteRatio : ∀ i, (N i : ℝ) ≤ A * H i) + (hbaseWidth : ∀ i, c * H i ≤ ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) + (hparamLo : ∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) + (hparamHi : ∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) + (hsourceLo : ∀ j i, |(sourceLo (some j, i) : ℝ)| ≤ B * H i / L) + (hsourceHi : ∀ j i, |(sourceHi (some j, i) : ℝ)| ≤ B * H i / L) + (hboundaryU : 40 * (Fintype.card I : ℝ) * A / (rho * c) ≤ Real.exp U) + (hmovementU : 1 + (Fintype.card J : ℝ) * (C + B) ≤ Real.exp U) + (hsourceU : sourceRatio ≤ Real.exp U) (hparameterU : parameterRatio ≤ Real.exp U) + (hbetaU : beta⁻¹ ≤ Real.exp U) + (hsourceWidth : ∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + sourceRatio * ((sourceHi z - sourceLo z).toNat : ℝ)) + (hparameterWidth : ∀ j, L / (D : ℝ) ≤ parameterRatio * ((parHi j - parLo j).toNat : ℝ)) + (hsourceScale : ∀ z : Option J × I, 4 * Real.exp (4 * U + 18 + lengthLog) ≤ + smoothPairCoefficientScale (H z.2) L z.1) + (hparameterScale : 4 * Real.exp (4 * U + 18 + lengthLog) ≤ L / (D : ℝ)) : + let P := normalizedBoxPartitions N H rho hsiteLarge hsiteWhole + ∃ (S : ∀ z, FiniteProgressionPartition (sourceHi z - sourceLo z).toNat) + (T : ∀ j, FiniteProgressionPartition (parHi j - parLo j).toNat), + (∀ z cs, (S z).step cs = 1) ∧ (∀ z cs, 0 < (S z).length cs) ∧ + (∀ j ct, (T j).step ct = 1) ∧ (∀ j ct, 0 < (T j).length ct) ∧ + (∀ z cs, Real.exp lengthLog ≤ ((S z).length cs : ℝ)) ∧ + (∀ j ct, Real.exp lengthLog ≤ ((T j).length ct : ℝ)) ∧ + ((integerBoxUniformWeights parLo parHi hpar).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (physicalMeshCrossing lo N P + (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh parLo parHi T tz.1)) + (fun tz => smoothAffineSample (fun j => anchor j + (D : ℤ) * (tz.1 j).val) + (fun i => (tz.2 i).val))) ≤ beta := by + intro P + let boundary := 40 * (Fintype.card I : ℝ) * A / (rho * c) + let movement := 1 + (Fintype.card J : ℝ) * (C + B) + let M := secondaryMovementBudget movement sourceRatio parameterRatio + let margin := secondaryBoundaryMargin boundary beta + let delta := secondaryMeshDelta boundary M beta + have hb : 0 ≤ boundary := by dsimp only [boundary]; positivity + have hm : 0 ≤ movement := by dsimp only [movement]; positivity + obtain ⟨hmargin, _, hpay, hdelta, _, hmove, hsw, hpw⟩ := + secondaryMesh_geometry hb hm hsRatio hpRatio hbeta + have hinv := secondaryMesh_geometry_inverse hb hm hsRatio hpRatio hbeta hU + hboundaryU hmovementU hsourceU hparameterU hbetaU + change 0 < margin at hmargin + change 0 < delta at hdelta + change delta * movement ≤ margin at hmove + change delta * sourceRatio ≤ 1 at hsw + change delta * parameterRatio ≤ 1 at hpw + have hsLarge (z : Option J × I) : 4 ≤ delta * smoothPairCoefficientScale (H z.2) L z.1 := + normalizedMesh_scale_large hdelta hinv.2 hlength (hsourceScale z) + have hsWhole (z : Option J × I) : delta * smoothPairCoefficientScale (H z.2) L z.1 ≤ + 2 * ((sourceHi z - sourceLo z).toNat : ℝ) := + normalizedMesh_upper_of_ratio _ hdelta.le hsw (hsourceWidth z) + have htLarge (_j : J) : 4 ≤ delta * (L / (D : ℝ)) := + normalizedMesh_scale_large hdelta hinv.2 hlength hparameterScale + have htWhole (j : J) : delta * (L / (D : ℝ)) ≤ 2 * ((parHi j - parLo j).toNat : ℝ) := + normalizedMesh_upper_of_ratio _ hdelta.le hpw (hparameterWidth j) + let S := normalizedBoxPartitions (fun z => (sourceHi z - sourceLo z).toNat) + (fun z => smoothPairCoefficientScale (H z.2) L z.1) delta hsLarge hsWhole + let T := normalizedBoxPartitions (fun j => (parHi j - parLo j).toNat) + (fun _ => L / (D : ℝ)) delta htLarge htWhole + refine ⟨S, T, normalizedBoxPartitions_step _ _ _ _ _, normalizedBoxPartitions_positive _ _ _ _ _, + normalizedBoxPartitions_step _ _ _ _ _, normalizedBoxPartitions_positive _ _ _ _ _, ?_, ?_, ?_⟩ + · exact normalizedBoxPartitions_exp_lengths _ _ delta (4 * U + 18) lengthLog hdelta hinv.2 + hsourceScale hsLarge hsWhole + · exact normalizedBoxPartitions_exp_lengths _ _ delta (4 * U + 18) lengthLog hdelta hinv.2 + (fun _ => hparameterScale) htLarge htWhole + · have hround (i : I) : 1 ≤ margin * H i := + secondaryMesh_rounding_of_scale hmargin hinv.1 hU hlength (hsourceScale (none,i)) + have hbad := concrete_affine_mesh_boundary_probability sourceLo sourceHi hsource + parLo parHi anchor hpar D hD lo N H hL hH hC hB hA hc hrho hmargin + hsiteLarge hsiteWhole hsiteRatio hbaseWidth hround hparamLo hparamHi hsourceLo hsourceHi + hsLarge hsWhole htLarge htWhole hmove + apply hbad.trans + change 40 * (Fintype.card I : ℝ) * A * margin / (rho * c) ≤ beta + calc + _ = boundary * margin := by dsimp only [boundary]; ring + _ ≤ beta := hpay + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSmoothCoefficientLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSmoothCoefficientLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..a30161a13a16a2a15414de479ec3d178afe912d9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSmoothCoefficientLaw.lean @@ -0,0 +1,110 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedEnormousProfiles + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators + +variable {I : Type*} [Fintype I] + +theorem affineProductProfile_weight_eq_shiftedSmooth + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) (z : I → ℤ) : + coefficientWeight (affineProductProfile c w) S z = profileWidthFactor w * + rectangularWeight (smoothProductProfile I) (fun i => S i * c i) + (fun i => S i * w i) z := by + change coefficientWeight (affineProductProfile c w) S z = profileWidthFactor w * + smoothProductProfile I (fun i => ((z i : ℝ) - S i * c i) / (S i * w i)) + simpa only [mul_comm] using affineProductProfile_sample c w S hw hS z + +theorem affineProductProfile_mass_eq_shiftedSmooth + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) : + coefficientWeightSum (affineProductProfile c w) S = profileWidthFactor w * + shiftedSmoothProductMass (fun i => S i * c i) (fun i => S i * w i) := by + unfold coefficientWeightSum shiftedSmoothProductMass + simp_rw [affineProductProfile_weight_eq_shiftedSmooth c w S hw hS] + exact tsum_mul_left + +theorem affineProductProfile_shiftedSmooth_mass_pos + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) + (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) : + 0 < shiftedSmoothProductMass (fun i => S i * c i) (fun i => S i * w i) := by + rw [affineProductProfile_mass_eq_shiftedSmooth c w S hw hS] at hZ + exact (mul_pos_iff_of_pos_left (profileWidthFactor_pos w hw)).mp hZ + +theorem coefficientPMF_affineProductProfile_eq_shiftedSmooth + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) + {R : ℝ} (hsupport : ∀ x, R < ‖x‖ → affineProductProfile c w x = 0) + (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) : + coefficientPMF (affineProductProfile c w) (affineProductProfile_nonneg c w hw) + S hS hsupport hZ = + shiftedSmoothProductPMF (fun i => S i * c i) (fun i => S i * w i) + (fun i => mul_pos (hS i) (hw i)) + (affineProductProfile_shiftedSmooth_mass_pos c w S hw hS hZ) := by + ext z + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + rw [coefficientPMF_apply, shiftedSmoothProductPMF_toReal, + affineProductProfile_weight_eq_shiftedSmooth c w S hw hS, + affineProductProfile_mass_eq_shiftedSmooth c w S hw hS] + exact mul_div_mul_left _ _ (profileWidthFactor_pos w hw).ne' + +namespace VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + (j : Fin m) (i : Fin (n j)) (hσ1 : σ j ≤ 1) + (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) + +include hR hσ hσ1 henormous in + +theorem allocatedEnormous_shiftedSmooth_mass_pos : + 0 < shiftedSmoothProductMass + (fun d => allocatedIntegerProfileScales B U basis S j i d * + allocatedIntegerProfileCenters B R j i d) + (fun d => allocatedIntegerProfileScales B U basis S j i d * + allocatedIntegerProfileWidths B R σ j i d) := + affineProductProfile_shiftedSmooth_mass_pos _ _ _ + (allocatedIntegerProfileWidths_pos B hR hσ j i) + (allocatedIntegerProfileScales_pos B U basis S j i) + (allocatedEnormous_profile_sum_pos B U basis hR hσ S j i hσ1 henormous) + +theorem allocatedEnormousProfilePMF_eq_shiftedSmooth : + allocatedEnormousProfilePMF B U basis hR hσ S j i hσ1 henormous = + shiftedSmoothProductPMF + (fun d => allocatedIntegerProfileScales B U basis S j i d * + allocatedIntegerProfileCenters B R j i d) + (fun d => allocatedIntegerProfileScales B U basis S j i d * + allocatedIntegerProfileWidths B R σ j i d) + (fun d => mul_pos (allocatedIntegerProfileScales_pos B U basis S j i d) + (allocatedIntegerProfileWidths_pos B hR hσ j i d)) + (allocatedEnormous_shiftedSmooth_mass_pos B U basis hR hσ S j i hσ1 henormous) := + coefficientPMF_affineProductProfile_eq_shiftedSmooth _ _ _ + (allocatedIntegerProfileWidths_pos B hR hσ j i) + (allocatedIntegerProfileScales_pos B U basis S j i) + (allocatedIntegerProfile_support B hR hσ j i hσ1) + (allocatedEnormous_profile_sum_pos B U basis hR hσ S j i hσ1 henormous) + +theorem allocatedEnormous_coefficient_law_shiftedSmooth : + allocatedCoefficientAxisLaw B U basis hR hσ S ⟨j, Sum.inr i⟩ = + (shiftedSmoothProductPMF + (fun d => allocatedIntegerProfileScales B U basis S j i d * + allocatedIntegerProfileCenters B R j i d) + (fun d => allocatedIntegerProfileScales B U basis S j i d * + allocatedIntegerProfileWidths B R σ j i d) + (fun d => mul_pos (allocatedIntegerProfileScales_pos B U basis S j i d) + (allocatedIntegerProfileWidths_pos B hR hσ j i d)) + (allocatedEnormous_shiftedSmooth_mass_pos B U basis hR hσ S j i hσ1 henormous)).toMeasure := by + rw [allocatedEnormous_coefficient_law B U basis hR hσ S j i hσ1 henormous, + allocatedEnormousProfilePMF_eq_shiftedSmooth B U basis hR hσ S j i hσ1 henormous] + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSourceAccuracy.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSourceAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..bef304cc5728d970ad6d9804023b893be9d03f13 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineSourceAccuracy.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedCanonicalBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {α : Type*} [Fintype α] [DecidableEq α] + +omit [DecidableEq α] in +theorem allocatedRowSlicedSiteRadius_buffer_le_exp (rowSets : Fin m → Finset (Finset α)) : + 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ + Real.exp (((m : ℝ) + 2) * Fintype.card α + m + 4) := by + let A : ℝ := ((m : ℝ) + 2) * Fintype.card α + 3 + have hT : 0 ≤ partitionedIdealRadius α m + 1 := by + have := partitionedIdealRadius_nonneg α m + positivity + have hr : (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ 1 + m * idealSiteBoxRadius α m := by + change 1 + ∑ j : Fin m, (rowSets j).card * (partitionedIdealRadius α m + 1) ≤ _ + apply add_le_add_right + calc + _ ≤ ∑ _j : Fin m, idealSiteBoxRadius α m := by + apply Finset.sum_le_sum + intro j _ + apply mul_le_mul_of_nonneg_right _ hT + exact_mod_cast (Finset.card_le_univ (rowSets j)).trans_eq (Fintype.card_finset (α := α)) + _ = _ := by simp + have hA : 0 ≤ A := by dsimp [A]; positivity + have hone : 1 ≤ Real.exp A := Real.one_le_exp_iff.mpr hA + calc + _ ≤ 2 + m * (2 * idealSiteBoxRadius α m) := by nlinarith only [hr] + _ ≤ 2 + m * Real.exp A := by + gcongr + exact idealSiteBoxRadius_buffer_le_exp α m + _ ≤ ((m : ℝ) + 2) * Real.exp A := by nlinarith only [hone] + _ ≤ Real.exp ((m : ℝ) + 1) * Real.exp A := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + simpa only [add_assoc, one_add_one_eq_two] using Real.add_one_le_exp ((m : ℝ) + 1) + _ = _ := by rw [← Real.exp_add]; congr 1; dsimp [A]; ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory Module +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) +variable (E : Fin m → Type*) [∀ j, Fintype (E j)] +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hR : ∀ j, 0 < R j) {Pnum : ℝ} (hPnum : 0 ≤ Pnum) +variable (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ Pnum) (hn : ∀ j, (n j : ℝ) ≤ Pnum) +variable (hcoeff : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Pnum) +variable (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp Pnum) +variable (hV : ∀ j, mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ Real.exp Pnum) + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "outputs" => (Σ a : {a // ¬grid a}, rowTypes (Sigma.fst (Subtype.val a))) + +include hR hPnum hI hn hcoeff hRi hV in +omit [DecidableEq α] in +theorem allocatedAffineSourceEarly_error_budget + {Mk period : ℕ} {Pk Pper Prho target Op : ℝ} + (hPk : 0 ≤ Pk) (hPper : 0 ≤ Pper) (hPrho : 0 ≤ Prho) (htarget : 0 ≤ target) + (hMk : (Mk : ℝ) ≤ Real.exp Pk) (hperiod : (period : ℝ) ≤ Real.exp Pper) + (ρ : ℝ≥0) (hρ : (ρ : ℝ)⁻¹ ≤ Real.exp Prho) : + let F := (m * (2 : ℝ) ^ Fintype.card α) * (Pnum + 8) * (1 + 4 * Pnum) + + Fintype.card (LayerSamplerAxis I n) * ((m * 2 ^ (m + 1) : ℕ) * Pk) + + ∑ j, (Fintype.card (E j) : ℝ) * (Fintype.card (rowTypes j) * Pper) + let Dout := (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1) : ℝ) + let Dgrid := (Fintype.card (LayerSamplerAxis I n) : ℝ) + let Pbox := ((m : ℝ) + 2) * Fintype.card α + m + 4 + let εgrid := Real.exp (-(Dout * Prho + (target + F) + 1)) + let Gcost := Dgrid * max Op 0 + let εlong := Real.exp (-(Gcost + (target + F) + 1)) + let Plong := Pbox + Prho + Gcost + (target + F) + 2 + 0 < εgrid ∧ εgrid ≤ 1 ∧ εgrid⁻¹ = Real.exp (Dout * Prho + (target + F) + 1) ∧ + 0 < εlong ∧ εlong ≤ 1 ∧ εlong⁻¹ ≤ Real.exp Plong ∧ 0 ≤ Plong ∧ + 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp Plong ∧ + (ρ : ℝ)⁻¹ ≤ Real.exp Plong ∧ + ‖inverseNormalizer‖ * + ((layerKernelIndexBound m Mk : ℝ) ^ Fintype.card (LayerSamplerAxis I n) * + coefficientDeckPeriodCap rowTypes E period) * + ((ρ⁻¹ ^ Fintype.card outputs : ℝ≥0) * εgrid + + εlong * ∏ _a : {a // grid a}, Real.exp Op) ≤ Real.exp (-target) := by + intro F Dout Dgrid Pbox εgrid Gcost εlong Plong + have hF : 0 ≤ F := by dsimp only [F]; positivity + have hbox : 0 ≤ Pbox := by dsimp only [Pbox]; positivity + have hout : (Fintype.card outputs : ℝ) ≤ Dout := by + apply Nat.cast_le.mpr + apply Fintype.card_le_of_injective (fun a : outputs => + (⟨a.1.val, a.2⟩ : Σ a : LayerSamplerAxis I n, rowTypes a.1)) + rintro ⟨⟨a, ha⟩, x⟩ ⟨⟨b, hb⟩, y⟩ heq + cases heq + rfl + have hg : (Fintype.card {a // grid a} : ℝ) ≤ Dgrid := by + change (Fintype.card {a // grid a} : ℝ) ≤ (Fintype.card (LayerSamplerAxis I n) : ℝ) + exact_mod_cast Fintype.card_subtype_le grid + have hc0 : 0 ≤ ‖inverseNormalizer‖ * + ((layerKernelIndexBound m Mk : ℝ) ^ Fintype.card (LayerSamplerAxis I n) * + coefficientDeckPeriodCap rowTypes E period) := + mul_nonneg (norm_nonneg _) (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) + (coefficientDeckPeriodCap_nonneg rowTypes E period)) + obtain ⟨hg0, hg1, hgi, hl0, hl1, hli, hp, hbp, hrp, herr⟩ := + affineSourceAccuracy_budget (ι := {a // grid a}) (κ := outputs) + (Nat.cast_nonneg _) (Nat.cast_nonneg _) hPrho hbox htarget hF hout hg ρ hρ hc0 + (allocatedSlicedSourceEarlyPrefactor_le_exp B U b S rowSets E hR hPnum hI hn hcoeff hRi hV hMk hperiod) + exact ⟨hg0, hg1, hgi, hl0, hl1, hli, hp, + (allocatedRowSlicedSiteRadius_buffer_le_exp rowSets).trans (Real.exp_le_exp.mpr hbp), hrp, herr⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineWholeProfileComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineWholeProfileComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea316eb22a900606c39336220e79044749c2656f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedAffineWholeProfileComparison.lean @@ -0,0 +1,1243 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedSlicedFiniteModelComparison +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineLogEnvelope +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineProfileMeanTransport +import OAI.Combinatorics.Progressions.Lattices.EarlyAllocatedAffineResidueSource +import OAI.Combinatorics.Progressions.Probability.AllocatedProgressionDensityIdentity + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {M : ℕ} (hM : 0 < M) +variable (hi : ∀ j : Fin m, + fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMP : (M : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "bound" => NNReal.mk (Real.exp (allocatedDensityLog (G := G) B α O P)) + (le_of_lt (Real.exp_pos _)) +local notation "cap" => bound ^ Fintype.card (LayerSamplerAxis I n) +local notation "lip" => (Fintype.card (LayerSamplerAxis I n) : ℝ≥0) * bound * cap + +local notation "input" => PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) +local notation "output" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +local notation "proxyRadius" => Real.exp (allocatedJetSupportLog (G := G) B α O P) + +include hR hσ hM hi hP hMP hRP hRi hσi hcount in +theorem allocatedAffineIdeal_finite_reference_l1 (hσ1 : ∀ j, σ j ≤ 1) + {Ω : Type*} [Fintype Ω] (weights : FiniteProbabilityWeights Ω) (F : Ω → (input → ℝ)) + (hF : ∀ v, weights.weight v ≠ 0 → ‖F v‖ ≤ 1) + (ρ : ℝ≥0) (hρ : 0 < ρ) (hρone : ρ ≤ 1) + (center width : input → ℝ) (hw : ∀ i, |center i| + |width i| ≤ 1) + (modulus : ℕ) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ≤ Cmask) {E : ℝ} : + let ideal := diagonalImageDensity (fun o : output => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) ρ center width) + let discrete := fun z => weights.mean (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA (F v) z) + let radius := max (Real.exp P * (partitionedIdealRadius α m + 1)) proxyRadius + let Ki : ℝ≥0 := ‖(∏ o : output, |R o.1.val.1|)⁻¹‖₊ * + (affineProductProfileLip output ρ * ⟨Real.exp P, Real.exp_nonneg _⟩) + let select := allocatedLongIntegerSelect B U basis S (O := O) + (∫ z, |ideal z - discrete z|) ≤ E → + (∫ z, |allocatedLongProfileDensity B U basis S x rows modulus residue ideal z - + allocatedLongProfileDensity B U basis S x rows modulus residue discrete z| + ∂allocatedLongJetReference B U basis S O) ≤ + Cmask ^ Fintype.card (LayerSamplerAxis I n) * + (E + (2 * radius) ^ Fintype.card (UnselectedColumn select) * + ((2 * radius + 2) ^ Fintype.card {o : output // allocatedLongIntegerCoordinate B U basis S (O := O) o} * + ((Ki : ℝ) + lip) * mesh)) := by + intro ideal discrete radius Ki select he + have hreg := allocatedFiniteLongJetDensity_regularity B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount u hσ1 weights F hF + have hRI (o : output) : |(R o.1.val.1)⁻¹| ≤ Real.exp P := by + rw [abs_of_pos (inv_pos.mpr (hR o.1.val.1))] + exact hRi _ + have hIb := activeScaledSlicedIdeal_bounds (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (fun o : output => R o.1.val.1) + (C := ⟨Real.exp P, Real.exp_nonneg _⟩) hRI ρ hρ center width + have hispec := activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) ρ hρ center width + have hIi : Integrable ideal := diagonalImageDensity_integrable _ + (fun o : output => (hR o.1.val.1).ne') hispec.2.2.1 + have hIs (z : output → ℝ) (hz : radius < ‖z‖) : ideal z = 0 := + activeScaledSlicedIdeal_zero_outside (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (fun o : output => R o.1.val.1) + (fun o => (hR o.1.val.1).ne') (Real.exp_nonneg P) + (fun o => by simpa only [abs_of_pos (hR o.1.val.1)] using hRP o.1.val.1) + (fun a => Nat.succ_le_of_lt a.1.isLt) ρ hρ hρone center width hw z + ((le_max_left _ _).trans_lt hz) + have hDs (z : output → ℝ) (hz : radius < ‖z‖) : discrete z = 0 := + hreg.2.2.1 z ((le_max_right _ _).trans_lt hz) + exact allocatedLongReference_l1_comparison B U basis S x rows modulus residue + ideal discrete ⟨radius, (Real.exp_nonneg _).trans (le_max_right _ _)⟩ hIb.2 hreg.2.1 hIs hDs + (by positivity) (NNReal.coe_nonneg cap) hIb.1 hreg.1 + (hIi.sub hreg.2.2.2) he hmesh0 hmesh1 hscaleMesh hCmask hmask + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped BigOperators NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable (α : Type*) [Fintype α] [DecidableEq α] (O : Fin m → Type*) [∀ j, Fintype (O j)] + +noncomputable def allocatedAffineSourceReferenceError (ρ : ℝ≥0) (P η : ℝ) + (M H : PrincipalTupleIndex + (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) + (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) → ℕ) + (ε mesh Cmask : ℝ) : ℝ := + let bound : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), Real.exp_nonneg _⟩ + let cap := bound ^ Fintype.card (LayerSamplerAxis I n) + let lip := (Fintype.card (LayerSamplerAxis I n) : ℝ≥0) * bound * cap + let sourceError := η + + ((2 * (cap : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + + (lip : ℝ) * 2) * ∑ j, (M j : ℝ) / H j + (lip : ℝ) * ε) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) + let radius := max (Real.exp P * (partitionedIdealRadius α m + 1)) (Real.exp (allocatedJetSupportLog (G := G) B α O P)) + let Ki : ℝ≥0 := ‖(∏ o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1), |R o.1.val.1|)⁻¹‖₊ * + (affineProductProfileLip (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) ρ * ⟨Real.exp P, Real.exp_nonneg _⟩) + let select := allocatedLongIntegerSelect B U basis S (O := O) + Cmask ^ Fintype.card (LayerSamplerAxis I n) * + (sourceError + (2 * radius) ^ Fintype.card (UnselectedColumn select) * + ((2 * radius + 2) ^ Fintype.card {o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) // allocatedLongIntegerCoordinate B U basis S (O := O) o} * + ((Ki : ℝ) + lip) * mesh)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped BigOperators NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable (α : Type*) [Fintype α] [DecidableEq α] (O : Fin m → Type*) [∀ j, Fintype (O j)] + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "Outputs" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +local notation "select" => allocatedLongIntegerSelect B U basis S (O := O) + +theorem allocatedAffineSourceReferenceError_small + (ρ : ℝ≥0) (P : ℝ) + (M H : PrincipalTupleIndex + (fun a : {a // ¬grid a} => B a.val) + (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val) → ℕ) + {D L target η ε mesh Cmask : ℝ} + (hD : 0 ≤ D) (hL : 0 ≤ L) (hP : P ≤ L) + (hdensity : allocatedDensityLog (G := G) B α O P ≤ L) + (hsupport : allocatedJetSupportLog (G := G) B α O P ≤ L) + (hideal : partitionedIdealRadius α m + 1 ≤ Real.exp L) + (hKi : ‖(∏ o : Outputs, |R o.1.val.1|)⁻¹‖ * + ((affineProductProfileLip Outputs ρ : ℝ) * Real.exp P) ≤ Real.exp L) + (hCmask0 : 0 ≤ Cmask) (hCmask : Cmask ≤ Real.exp L) + (hb0 : 0 ≤ scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α)) + (hb : scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) ≤ Real.exp L) + (ha : (Fintype.card (LayerSamplerAxis I n) : ℝ) ≤ D) + (ho : (Fintype.card Outputs : ℝ) ≤ D) + (hu : (Fintype.card (UnselectedColumn select) : ℝ) ≤ D) + (hi : (Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o} : ℝ) ≤ D) + (hη0 : 0 ≤ η) (hε0 : 0 ≤ ε) (hmesh0 : 0 ≤ mesh) + (hη : η ≤ Real.exp (-(target + affineReferenceCoefficientLog D L + 4))) + (hratio : (∑ j, (M j : ℝ) / H j) ≤ Real.exp (-(target + affineReferenceCoefficientLog D L + 4))) + (hε : ε ≤ Real.exp (-(target + affineReferenceCoefficientLog D L + 4))) + (hmesh : mesh ≤ Real.exp (-(target + affineReferenceCoefficientLog D L + 4))) : + allocatedAffineSourceReferenceError B U basis S α O ρ P η M H ε mesh Cmask ≤ Real.exp (-target) := by + let cap := Real.exp (allocatedDensityLog (G := G) B α O P) ^ Fintype.card (LayerSamplerAxis I n) + let lip := (Fintype.card (LayerSamplerAxis I n) : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) * cap + let radius := max (Real.exp P * (partitionedIdealRadius α m + 1)) (Real.exp (allocatedJetSupportLog (G := G) B α O P)) + let Ki := ‖(∏ o : Outputs, |R o.1.val.1|)⁻¹‖ * ((affineProductProfileLip Outputs ρ : ℝ) * Real.exp P) + let vol := (2 * radius) ^ Fintype.card (UnselectedColumn select) * + (2 * radius + 2) ^ Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o} + have hc := affineReferenceCoefficient_bounds hD hL hdensity hsupport hP hideal hKi hCmask0 hCmask hb0 hb + (Fintype.card (LayerSamplerAxis I n)) (Fintype.card Outputs) + (Fintype.card (UnselectedColumn select)) + (Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o}) ha ho hu hi + have hc' : Cmask ^ Fintype.card (LayerSamplerAxis I n) ≤ Real.exp (affineReferenceCoefficientLog D L) ∧ + Cmask ^ Fintype.card (LayerSamplerAxis I n) * + (2 * cap * (scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α)) + lip * 2) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card Outputs ≤ Real.exp (affineReferenceCoefficientLog D L) ∧ + Cmask ^ Fintype.card (LayerSamplerAxis I n) * lip * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card Outputs ≤ Real.exp (affineReferenceCoefficientLog D L) ∧ + Cmask ^ Fintype.card (LayerSamplerAxis I n) * vol * (Ki + lip) ≤ Real.exp (affineReferenceCoefficientLog D L) := by + refine ⟨hc.1, hc.2.1, hc.2.2.1, ?_⟩ + convert hc.2.2.2 using 1 + dsimp only [vol, Ki, lip, cap, radius] + ring + have herr := affineReferenceError_accuracy hη0 (by positivity : 0 ≤ ∑ j, (M j : ℝ) / H j) + hε0 hmesh0 hc' hη hratio hε hmesh + let bound : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), Real.exp_nonneg _⟩ + let capNN : ℝ≥0 := bound ^ Fintype.card (LayerSamplerAxis I n) + let lipNN : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * bound * capNN + let KiNN : ℝ≥0 := ‖(∏ o : Outputs, |R o.1.val.1|)⁻¹‖₊ * + (affineProductProfileLip Outputs ρ * ⟨Real.exp P, Real.exp_nonneg _⟩) + have hcapNN : (capNN : ℝ) = cap := rfl + have hlipNN : (lipNN : ℝ) = lip := by + simp only [lipNN, NNReal.coe_mul, NNReal.coe_natCast, hcapNN] + rfl + have hKiNN : (KiNN : ℝ) = Ki := rfl + convert herr using 1 + change Cmask ^ Fintype.card (LayerSamplerAxis I n) * + (η + ((2 * (capNN : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + (lipNN : ℝ) * 2) * + (∑ j, (M j : ℝ) / H j) + (lipNN : ℝ) * ε) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card Outputs + + (2 * radius) ^ Fintype.card (UnselectedColumn select) * + ((2 * radius + 2) ^ Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o} * + ((KiNN : ℝ) + lipNN) * mesh)) = _ + rw [hcapNN, hlipNN, hKiNN] + dsimp only [vol] + ring + +theorem allocatedAffineSourceReferenceError_small_separated + (ρ : ℝ≥0) (P : ℝ) + (M H : PrincipalTupleIndex + (fun a : {a // ¬grid a} => B a.val) + (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val) → ℕ) + {D L target η ε mesh Cmask earlyMaskLog : ℝ} + (hearlyMask : Cmask ^ Fintype.card (LayerSamplerAxis I n) ≤ Real.exp earlyMaskLog) + (hD : 0 ≤ D) (hL : 0 ≤ L) (hP : P ≤ L) + (hdensity : allocatedDensityLog (G := G) B α O P ≤ L) + (hsupport : allocatedJetSupportLog (G := G) B α O P ≤ L) + (hideal : partitionedIdealRadius α m + 1 ≤ Real.exp L) + (hKi : ‖(∏ o : Outputs, |R o.1.val.1|)⁻¹‖ * + ((affineProductProfileLip Outputs ρ : ℝ) * Real.exp P) ≤ Real.exp L) + (hCmask0 : 0 ≤ Cmask) (hCmask : Cmask ≤ Real.exp L) + (hb0 : 0 ≤ scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α)) + (hb : scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) ≤ Real.exp L) + (ha : (Fintype.card (LayerSamplerAxis I n) : ℝ) ≤ D) + (ho : (Fintype.card Outputs : ℝ) ≤ D) + (hu : (Fintype.card (UnselectedColumn select) : ℝ) ≤ D) + (hi : (Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o} : ℝ) ≤ D) + (hη0 : 0 ≤ η) (hε0 : 0 ≤ ε) (hmesh0 : 0 ≤ mesh) + (hη : η ≤ Real.exp (-(target + earlyMaskLog + 4))) + (hratio : (∑ j, (M j : ℝ) / H j) ≤ Real.exp (-(target + affineReferenceCoefficientLog D L + 4))) + (hε : ε ≤ Real.exp (-(target + affineReferenceCoefficientLog D L + 4))) + (hmesh : mesh ≤ Real.exp (-(target + affineReferenceCoefficientLog D L + 4))) : + allocatedAffineSourceReferenceError B U basis S α O ρ P η M H ε mesh Cmask ≤ Real.exp (-target) := by + let cap := Real.exp (allocatedDensityLog (G := G) B α O P) ^ Fintype.card (LayerSamplerAxis I n) + let lip := (Fintype.card (LayerSamplerAxis I n) : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) * cap + let radius := max (Real.exp P * (partitionedIdealRadius α m + 1)) (Real.exp (allocatedJetSupportLog (G := G) B α O P)) + let Ki := ‖(∏ o : Outputs, |R o.1.val.1|)⁻¹‖ * ((affineProductProfileLip Outputs ρ : ℝ) * Real.exp P) + let vol := (2 * radius) ^ Fintype.card (UnselectedColumn select) * + (2 * radius + 2) ^ Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o} + have hc := affineReferenceCoefficient_bounds hD hL hdensity hsupport hP hideal hKi hCmask0 hCmask hb0 hb + (Fintype.card (LayerSamplerAxis I n)) (Fintype.card Outputs) + (Fintype.card (UnselectedColumn select)) + (Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o}) ha ho hu hi + have hc' : Cmask ^ Fintype.card (LayerSamplerAxis I n) ≤ Real.exp earlyMaskLog ∧ + Cmask ^ Fintype.card (LayerSamplerAxis I n) * + (2 * cap * (scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α)) + lip * 2) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card Outputs ≤ Real.exp (affineReferenceCoefficientLog D L) ∧ + Cmask ^ Fintype.card (LayerSamplerAxis I n) * lip * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card Outputs ≤ Real.exp (affineReferenceCoefficientLog D L) ∧ + Cmask ^ Fintype.card (LayerSamplerAxis I n) * vol * (Ki + lip) ≤ Real.exp (affineReferenceCoefficientLog D L) := by + refine ⟨hearlyMask, hc.2.1, hc.2.2.1, ?_⟩ + convert hc.2.2.2 using 1 + dsimp only [vol, Ki, lip, cap, radius] + ring + have herr := affineReferenceError_accuracy_separated hη0 (by positivity : 0 ≤ ∑ j, (M j : ℝ) / H j) + hε0 hmesh0 hc' hη hratio hε hmesh + let bound : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), Real.exp_nonneg _⟩ + let capNN : ℝ≥0 := bound ^ Fintype.card (LayerSamplerAxis I n) + let lipNN : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * bound * capNN + let KiNN : ℝ≥0 := ‖(∏ o : Outputs, |R o.1.val.1|)⁻¹‖₊ * + (affineProductProfileLip Outputs ρ * ⟨Real.exp P, Real.exp_nonneg _⟩) + have hcapNN : (capNN : ℝ) = cap := rfl + have hlipNN : (lipNN : ℝ) = lip := by + simp only [lipNN, NNReal.coe_mul, NNReal.coe_natCast, hcapNN] + rfl + have hKiNN : (KiNN : ℝ) = Ki := rfl + convert herr using 1 + change Cmask ^ Fintype.card (LayerSamplerAxis I n) * + (η + ((2 * (capNN : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + (lipNN : ℝ) * 2) * + (∑ j, (M j : ℝ) / H j) + (lipNN : ℝ) * ε) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card Outputs + + (2 * radius) ^ Fintype.card (UnselectedColumn select) * + ((2 * radius + 2) ^ Fintype.card {o : Outputs // allocatedLongIntegerCoordinate B U basis S (O := O) o} * + ((KiNN : ℝ) + lipNN) * mesh)) = _ + rw [hcapNN, hlipNN, hKiNN] + dsimp only [vol] + ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +def AllocatedAffineReferenceComparison + (δ η : ℝ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) : Prop := + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (_hR : ∀ j, 0 < R j) (_hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + (∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (hMk : 0 < Mk) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) + (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + ∀ (L step H M : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (hL : ∀ j, 0 < L j) (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ℕ) (residue : ∀ j i, ZMod (modulus j i)) + (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j) + (hsize : ∀ j, (Fintype.card α + 1) * M j ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((M j : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) + (outputModulus : ℕ) + (outputResidue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod outputModulus)) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j outputModulus (outputResidue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j outputModulus (outputResidue j) z ≤ Cmask), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let discrete := fun z : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) → ℝ => + (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) (hsize j))).mean + (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (principalTupleFlatten (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j)) z) + (∫ z, |allocatedLongProfileDensity B U basis S x rows outputModulus outputResidue ideal z - + allocatedLongProfileDensity B U basis S x rows outputModulus outputResidue discrete z| + ∂allocatedLongJetReference B U basis S O) ≤ + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η M H ε mesh Cmask + +include hrows hcard in +theorem exists_early_allocated_affine_reference_source + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ η : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T (δ / 2) η) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T (δ / 2) η ∧ + AllocatedAffineReferenceComparison.{uJ, _, _, _, _, _} (G := G) B rows δ η ρ t := by + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_residue_source_with_scales (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + refine ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, ?_⟩ + unfold AllocatedAffineReferenceComparison + intro J _ U basis R σ hR hσ S hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L step H M c hL hstep hH hsubset hdense modulus residue hm hmM hsize hsmall ε hε hmesh + outputModulus outputResidue mesh Cmask hmesh0 hmesh1 hscaleMesh hCmask hmask + center width ideal discrete + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have he := hs U basis hR hσ S hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + L step H M c hL hstep hH hsubset hdense modulus residue hm hmM hsize hsmall hε hmesh + let weights := FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) (hsize j)) + let V := fun (v : ∀ j, IntegerScalarCubeBox α (H j)) => principalTupleFlatten (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j) + have hV (v) (hv : weights.weight v ≠ 0) : ‖V v‖ ≤ 1 := by + apply (principalTupleFlatten_norm_apply_le _ _ _ _).trans + apply progressionTuple_norm_le L step H c hH + (fun j => (progression_slice_endpoint_geometry (c j) (hL j) (hstep j) (hH j) hδ + (hsubset j) (hdense j)).2.2.1) v + intro j + exact scalarCubeResidueWeights_cube_support α (H j) (M j) (by have := hH j; omega) + (modulus j) (residue j) (hm j) (hmM j) (hsize j) (v j) + (FiniteProbabilityWeights.pi_weight_pos_component _ v + (lt_of_le_of_ne (weights.nonneg v) (Ne.symm hv)) j) + have hwidth := principalProgressionSlice_parameters (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) + L H step c hL hstep hH hδ hsubset hdense + exact allocatedAffineIdeal_finite_reference_l1 B U basis hR hσ S x rows s hA + hMk hi hP hMkP hRP hRi hσi hcount u hσ1 weights V hV (ρ (allocatedGridAxis (I := I) U basis S.value)) + (hρmin.trans_le (hρ (allocatedGridAxis (I := I) U basis S.value)).1) (hρ (allocatedGridAxis (I := I) U basis S.value)).2 center width (fun i => (hwidth i).2.2) + outputModulus outputResidue hmesh0 hmesh1 hscaleMesh hCmask hmask he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +include hrows hcard in +omit [∀ index, Nonempty (O index)] in +theorem allocatedAffineCoefficient_from_reference_l1 + {δ η : ℝ} (hδ : 0 < δ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) + (hρpos : ∀ P, 0 < ρ P) (hρone : ∀ P, ρ P ≤ 1) (t : ℝ) (htone : t ≤ 1) : + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + ∀ (hσsmall : ∀ j, σ j ≤ t), + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (_ : 0 < Mk) + (_ : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (_ : 0 ≤ P) (_ : (Mk : ℝ) ≤ Real.exp P) + (_ : ∀ j, R j ≤ Real.exp P) (_ : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (_ : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_ : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + let L := principalAxisLength (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S) + let hL := fun j : PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)) + ∀ (H step : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (_ : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (_ : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : ℕ) (hm : 0 < modulus) + (residue : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ZMod modulus) + (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + (_ : ∀ j, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (_ : 0 ≤ ε) (_ : ∀ j, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) (_ : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (_ : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (_ : 0 ≤ e) (_ : 0 < εcoef) (_ : εcoef⁻¹ ≤ Real.exp e) + (_ : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) + (_ : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S)) + (_ : (containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0), + let outputResidue := fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ {mesh Cmask : ℝ} (_ : 0 ≤ mesh) (_ : mesh ≤ 1) + (_ : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (_ : 1 ≤ Cmask) + (_ : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ≤ Cmask), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let law := containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize + let proxy := fun z : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) → ℝ => + (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) modulus + (lt_of_lt_of_le (by decide : 0 < 2) (hH j)) (fun _ => modulus) (residue j) (fun _ => hm) (fun _ => le_rfl) (hsize j))).mean + (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (principalTupleFlatten (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j)) z) + (∫ z, |allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z - + allocatedLongProfileDensity B U basis S x rows modulus outputResidue proxy z| + ∂allocatedLongJetReference B U basis S O) ≤ + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask → + (∫ z, |law.mean (fun v => allocatedLongJetDensity B U basis hR hσ S x u v rows s hA + (fun j => (hσsmall j).trans htone) z) - + allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z| + ∂allocatedLongJetReference B U basis S O) ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}) + + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask + := by + intro J _ U basis R σ hR hσ S hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L hL H step c hstep hH hsubset hdense modulus hm residue hsize hsmall ε hε hmesh + selection hx hq e εcoef he hεcoef hεe hlarge hperiod v₀ hv₀ outputResidue + mesh Cmask hmesh0 hmesh1 hscaleMesh hCmask hmask + center width ideal law proxy href + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have hw := principalProgressionSlice_parameters (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) + L H step c hL hstep hH hδ hsubset hdense + have hg := allocatedAffineIdeal_profile_integrable B U basis hR S x rows hRP hRi + (ρ (allocatedGridAxis (I := I) U basis S.value)) (hρpos _) (hρone _) + center width (fun i => (hw i).2.2) modulus outputResidue hCmask hmask + have hlong := allocatedSlicedLongJet_ideal_transfer B U basis hR hσ S x rows + hMk selection hx hq hrows hcard hσ1 hP he hεcoef hMkP hRP hRi hσi hcount hεe hlarge + modulus hperiod s hA hi u H step c (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset hm residue hsize + v₀ hv₀ (allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal) + hg (Eref := allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask) href + exact hlong + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ +open scoped ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) + + theorem exists_quantitative_early_affine_reference_source + (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) (hblock : ∀ a, Function.Injective (block a)) + {δ η E F : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) + (hE : 0 ≤ E) (hF : 0 ≤ F) (hηE : η⁻¹ ≤ Real.exp E) (hδF : (δ / 2)⁻¹ ≤ Real.exp F) : + ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, 0 < ρ P ∧ ρ P ≤ 1 ∧ + (ρ P : ℝ)⁻¹ ≤ Real.exp (allocatedAffineRadiusLog (O := O) (α := α) B A T E F)) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + Real.log t⁻¹ ≤ allocatedAffineToleranceLog (G := G) (O := O) (α := α) B A T E F ∧ + AllocatedAffineReferenceComparison.{uJ, _, _, _, _, _} (G := G) B rows δ η ρ t := by + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_reference_source (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + have hδhalf : δ / 2 ≤ 1 := by linarith + refine ⟨ρ, ?_, t, ht, htone, ?_, hs⟩ + · intro P + refine ⟨hρmin.trans_le (hρ P).1, (hρ P).2, ?_⟩ + rw [hρeq P] + exact allocatedAffineSourceRadius_inverse_bound B A T (half_pos hδ) hδhalf hη hE hF hηE hδF P + · rw [hteq] + exact allocatedAffineSourceTolerance_log_bound B A T (half_pos hδ) hδhalf hη hE hF hηE hδF + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +def AllocatedAffineCoefficientComparison + (δ η : ℝ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) : Prop := + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + ∀ (hσsmall : ∀ j, σ j ≤ t), + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (hMk : 0 < Mk) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) + (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + let L := principalAxisLength (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S) + let hL := fun j : PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)) + ∀ (H step : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : ℕ) (hm : 0 < modulus) + (residue : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ZMod modulus) + (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0), + let outputResidue := fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ≤ Cmask), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let law := containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize + (∫ z, |law.mean (fun v => allocatedLongJetDensity B U basis hR hσ S x u v rows s hA + (fun j => (hσsmall j).trans htone) z) - + allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z| + ∂allocatedLongJetReference B U basis S O) ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}) + + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask + +include hrows hcard in +omit [∀ index, Nonempty (O index)] in +theorem allocatedAffineCoefficientComparison_of_reference + {δ η : ℝ} (hδ : 0 < δ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) + (hρpos : ∀ P, 0 < ρ P) (hρone : ∀ P, ρ P ≤ 1) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineReferenceComparison.{uJ, _, _, _, _, _} (G := G) B rows δ η ρ t) : + AllocatedAffineCoefficientComparison.{uJ, _, _, _, _, _} (G := G) B rows δ η ρ t htone := by + unfold AllocatedAffineCoefficientComparison + intro J _ U basis R σ hR hσ S hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L hL H step c hstep hH hsubset hdense modulus hm residue hsize hsmall ε hε hmesh + selection hx hq e εcoef he hεcoef hεe hlarge hperiod v₀ hv₀ outputResidue + mesh Cmask hmesh0 hmesh1 hscaleMesh hCmask hmask + center width ideal law + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have href := hs U basis hR hσ S hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + L step H (fun _ => modulus) c hL hstep hH hsubset hdense (fun _ _ => modulus) residue + (fun _ _ => hm) (fun _ _ => le_rfl) hsize hsmall hε hmesh + modulus outputResidue hmesh0 hmesh1 hscaleMesh hCmask hmask + with_reducible + refine allocatedAffineCoefficient_from_reference_l1 B rows hrows hcard hδ ρ hρpos hρone t htone + U basis hR hσ S hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + H step c hstep hH hsubset hdense modulus hm residue hsize hsmall hε hmesh + selection hx hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh hCmask hmask ?_ + exact href + +include hrows hcard in +theorem exists_early_allocated_affine_coefficient_source + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ η : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T (δ / 2) η) ∧ + ∃ t : ℝ, 0 < t ∧ ∃ htone : t ≤ 1, + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T (δ / 2) η ∧ + AllocatedAffineCoefficientComparison.{uJ, _, _, _, _, _} (G := G) B rows δ η ρ t htone := by + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_reference_source (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + refine ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, ?_⟩ + exact allocatedAffineCoefficientComparison_of_reference B rows hrows hcard hδ ρ + (fun P => hρmin.trans_le (hρ P).1) (fun P => (hρ P).2) t htone hs + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +def AllocatedAffineCoveredComparison + (δ η : ℝ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (_ : t ≤ 1) : Prop := + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + ∀ (hσsmall : ∀ j, σ j ≤ t), + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (hMk : 0 < Mk) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) + (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + let L := principalAxisLength (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S) + let hL := fun j : PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)) + ∀ (H step : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : ℕ) (hm : 0 < modulus) + (residue : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ZMod modulus) + (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0), + let outputResidue := fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ≤ Cmask), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let law := containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize + ∀ (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] + (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + (F : AllocatedFrozenCoefficients B U basis S × EuclideanJetLayers U O → ℂ) + (hF : Measurable F) (hFbound : ∀ p, ‖F p‖ ≤ 1), + ‖(∫ p, law.complexMean (fun v => F (((allocatedCoefficientSplit B U basis S) p.1).1, + euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x (principalAxisJoin (allocatedGridAxis (I := I) U basis S.value) u v)) + (allocatedPhysicalCubeDirections B U basis S x (principalAxisJoin (allocatedGridAxis (I := I) U basis S.value) u v)) rows + (canonicalCoefficientDeckSample U bW basis hb o d (Nat.pos_of_ne_zero (NeZero.ne d)) p.1 p.2))) + ∂(allocatedCoefficientSource B U basis hR hσ S).prod + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d)).toMeasure) - + ∫ a₀, ∫ z, (allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z : ℂ) * + allocatedCoveredFixedTest B U basis S x u v₀ rows Q hb o bW d F a₀ z + ∂allocatedLongJetReference B U basis S O ∂allocatedFrozenCoefficientSource B U basis hR hσ S‖ ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}) + + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask + +omit [∀ index, Nonempty (O index)] in +theorem allocatedAffineCoveredComparison_of_coefficient + {δ η : ℝ} (hδ : 0 < δ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) + (hρpos : ∀ P, 0 < ρ P) (hρone : ∀ P, ρ P ≤ 1) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoefficientComparison.{uJ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) : + AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone := by + unfold AllocatedAffineCoveredComparison + intro J _ U basis R σ hR hσ S hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L hL H step c hstep hH hsubset hdense modulus hm residue hsize hsmall ε hε hmesh + selection hx hq e εcoef he hεcoef hεe hlarge hperiod v₀ hv₀ outputResidue + mesh Cmask hmesh0 hmesh1 hscaleMesh hCmask hmask + center width ideal law Q _ hb o bW d _ F hF hFbound + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have hc := hs U basis hR hσ S hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + H step c hstep hH hsubset hdense modulus hm residue hsize hsmall hε hmesh + selection hx hq he hεcoef hεe hlarge hperiod v₀ hv₀ + hmesh0 hmesh1 hscaleMesh hCmask hmask + have hw := principalProgressionSlice_parameters (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) + L H step c hL hstep hH hδ hsubset hdense + have hg := allocatedAffineIdeal_profile_integrable B U basis hR S x rows hRP hRi + (ρ (allocatedGridAxis (I := I) U basis S.value)) (hρpos _) (hρone _) + center width (fun i => (hw i).2.2) modulus outputResidue hCmask hmask + exact allocatedSlicedPhysicalCovered_test_comparison_of_l1 B U basis hR hσ S x u v₀ rows + Q hb o bW d s hA hσ1 modulus hperiod F H step c (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) + hsubset hm residue hsize hv₀ _ hg hc hF hFbound + +include hrows hcard in +theorem exists_early_allocated_affine_covered_source + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ η : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T (δ / 2) η) ∧ + ∃ t : ℝ, 0 < t ∧ ∃ htone : t ≤ 1, + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T (δ / 2) η ∧ + AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone := by + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_coefficient_source (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + refine ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, ?_⟩ + exact allocatedAffineCoveredComparison_of_coefficient B rows hδ ρ + (fun P => hρmin.trans_le (hρ P).1) (fun P => (hρ P).2) t htone hs + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := O j) + S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => O +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (F : AllocatedFrozenCoefficients B U basis S × EuclideanJetLayers U O → ℂ) + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) +local notation "actual" => allocatedProgressionCoveredExpectation B U basis hR hσ S rows x Q hb o bW d F + H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ index, Nonempty (O index)] in +theorem allocatedAffineWholeCovered_comparison + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) (hH : ∀ j : Tuple, 2 ≤ H j) + (_ : 0 < δ) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hsize : ∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j : Tuple, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α jetRows P e) ≤ S.value) + (hperiod : ∀ j : Fin m, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ (u : GridTuples) j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ∧ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ≤ Cmask) + (hF : Measurable F) (hFbound : ∀ p, ‖F p‖ ≤ 1) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let outputResidue := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ‖actual - FiniteProbabilityWeights.complexMean gridLaw (fun u => ∫ a₀, ∫ z, + (allocatedLongProfileDensity B U basis S x rows modulus (outputResidue u) ideal z : ℂ) * + allocatedCoveredFixedTest B U basis S x u v₀ rows Q hb o bW d F a₀ z + ∂reference ∂frozenSource)‖ ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬grid a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬grid a}) + + allocatedAffineSourceReferenceError B U basis S α O (ρ grid) P η (fun _ => modulus) H ε mesh Cmask + := by + intro center width ideal outputResidue + let f := fun (p : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n × + CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S)) => + F (((allocatedCoefficientSplit B U basis S) p.1).1, + euclideanCoefficientJetMap U (wholeRoot y) (wholeDirs y) rows + (canonicalCoefficientDeckSample U bW basis hb o d (Nat.pos_of_ne_zero (NeZero.ne d)) p.1 p.2)) + have hf (y) : Integrable (fun p => f p y) ((source).prod (deck).toMeasure) := + allocatedProgressionCoveredIntegrand_integrable B U basis hR hσ S rows x Q hb o bW d F y hF hFbound + apply containedSupportedProgressionLaw_integral_comparison B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid + ((source).prod (deck).toMeasure) f hf + intro u hu + have heq := containedSupportedProgressionAxisLaw_eq_of_size B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus hm r₀ hcell + (fun a => ¬grid a) hsize + rw [heq] + exact hs U basis hR hσ S hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + H step c hstep hH hsubset hdense modulus hm residue hsize hsmall hε hmesh + selection hgood hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh hCmask (hmask u) + Q hb o bW d F hF hFbound + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j a, (rows j a).card ≤ j.val + 1) + +include hrows hcard in +theorem exists_early_allocated_affine_bounded_source + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ target maskLog F D : ℝ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) (hδ : 0 < δ) (hδone : δ ≤ 1) + (htarget : 0 ≤ target) (hmaskLog : 0 ≤ maskLog) (hF : 0 ≤ F) + (hδF : (δ / 2)⁻¹ ≤ Real.exp F) : + let E := target + maskLog + 5 + let η := Real.exp (-E) + let radiusLog := 2 * affineProfileInputEnvelope D (A : ℝ) (T : ℝ) E F + 2 + let toleranceLog := affineProfileToleranceEnvelope m D (D * (D + 1) + D * D + D + 1) (A : ℝ) (T : ℝ) E F + ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, 0 < ρ P ∧ ρ P ≤ 1 ∧ Real.exp (-radiusLog) ≤ ρ P) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) + (layerSamplerDegree I n) P A T (δ / 2) η) ∧ + ∃ t : ℝ, 0 < t ∧ ∃ htone : t ≤ 1, + t⁻¹ ≤ Real.exp toleranceLog ∧ + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T (δ / 2) η ∧ + AllocatedAffineCoveredComparison.{uJ,uQ,_,_,_,_,_} (G := G) B rows δ η ρ t htone := by + intro E η radiusLog toleranceLog + have hη : 0 < η := Real.exp_pos _ + have hE : 0 ≤ E := by dsimp [E]; linarith + have hηE : η⁻¹ ≤ Real.exp E := by + dsimp [η] + rw [← Real.exp_neg] + simp only [neg_neg, le_refl] + have hδhalf : δ / 2 ≤ 1 := by linarith + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_covered_source.{uJ,uQ} (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + have hρpos (P) : 0 < ρ P := hρmin.trans_le (hρ P).1 + have hfloor := allocatedAffineSourceRadius_uniform_floor (O := O) (α := α) + B A T (half_pos hδ) hδhalf hη hE hF hηE hδF ρ hρpos hρeq + have htlog := allocatedAffineSourceTolerance_log_bound (G := G) (O := O) (α := α) + B A T (half_pos hδ) hδhalf hη hE hF hηE hδF + rw [← hteq] at htlog + have hlogs := allocatedAffine_log_costs_le_envelope B A T hdim hE hF + refine ⟨ρ, fun P => ⟨hρpos P, (hρ P).2, + (Real.exp_le_exp.mpr (neg_le_neg hlogs.1)).trans (hfloor P)⟩, + hρeq, t, ht, htone, ?_, hteq, hs⟩ + exact (Real.log_le_iff_le_exp (inv_pos.mpr ht)).mp (htlog.trans hlogs.2) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (x : G → IntegerScalarCubeBox α S.value) +variable (s : ∀ j : Fin m, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := O j) + S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "jetRows" => O +local notation "activeB" => (fun a : {a // ¬grid a} => B (Subtype.val a)) +local notation "activeDegree" => (fun a : {a // ¬grid a} => degree (Subtype.val a)) +local notation "L" => principalAxisLength (fun a => ¬grid a) (allocatedPrincipalSides B U basis S) +local notation "positiveLengths" => (fun j : Tuple => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) + +variable (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (F : EuclideanJetLayers U O → ℂ) + +local notation "source" => allocatedCoefficientSource B U basis hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U basis hR hσ S +local notation "reference" => allocatedLongJetReference B U basis S jetRows +variable (H₀ step₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH₀ : ∀ t, 0 < H₀ t) +variable (hsubset₀ : ∀ t, integerProgressionSupport (c₀ t) (step₀ t : ℤ) (H₀ t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (modulus : ℕ) (r₀ : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod modulus) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H₀ hH₀).mass + (Finset.univ.filter (fun y => principalResidueLabel modulus y = r₀))) +local notation "embed" => (fun j : Tuple => (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j) : PrincipalTupleIndex B (layerSamplerDegree I n))) +local notation "H" => (fun j : Tuple => H₀ (embed j)) +local notation "step" => (fun j : Tuple => step₀ (embed j)) +local notation "c" => (fun j : Tuple => c₀ (embed j)) +local notation "hsubset" => (fun j : Tuple => hsubset₀ (embed j)) +local notation "residue" => (fun j : Tuple => r₀ (embed j)) +local notation "GridTuples" => PrincipalAxisTuples (α := α) grid (allocatedPrincipalSides B U basis S) +local notation "wholeLaw" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H₀ step₀ c₀ (allocatedPrincipalSides_pos B U basis S) hH₀ hsubset₀ modulus r₀ hcell grid +local notation "wholeRoot" y => allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y +local notation "wholeDirs" y => allocatedPhysicalCubeDirections B U basis S x y +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) +local notation "actual" => allocatedProgressionCoveredExpectation B U basis hR hσ S rows x Q hb o bW d (fun p => F (Prod.snd p)) + H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +omit [∀ index, Nonempty (O index)] in +theorem allocatedAffineWholeProfile_comparison + {δ η : ℝ} (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone) + (hρ : 0 < ρ grid) (hρ1 : ρ grid ≤ 1) + (hσsmall : ∀ j, σ j ≤ t) + (hstep : ∀ j : Tuple, 0 < step j) (hH : ∀ j : Tuple, 2 ≤ H j) + (hδ : 0 < δ) + (hdense : ∀ j : Tuple, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (hm : 0 < modulus) + (hsize : ∀ j : Tuple, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j : Tuple, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j : Tuple, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) + (hgood : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ m + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α jetRows P e) ≤ S.value) + (hperiod : ∀ j : Fin m, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw activeB activeDegree L H step c positiveLengths + (fun j : Tuple => hH₀ (embed j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0) + {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ (u : GridTuples) j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ∧ allocatedIntegerKernelMask B U basis S x rows j + modulus + (integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus) z ≤ Cmask) + (T : Fin m → ℝ) (hT : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (T j * R j)) ≤ 1 / 4) + (hF : Measurable F) (hFbound : ∀ p, ‖F p‖ ≤ 1) : + let center := principalProgressionSliceCenter (α := α) activeB activeDegree L c + let width := principalProgressionSliceWidth (α := α) activeB activeDegree L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬grid a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) grid (fun a => rows a.val.1) (ρ grid) center width) + let _ := fun (u : GridTuples) j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ‖actual - (∫ y, ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile + B U basis hR hσ S x rows hb o bW d (principalAxisJoin grid u v₀) modulus ideal y) : ℂ) * F y + ∂Measure.pi (fun j => Measure.pi (fun _ : O j => ν j)))‖ ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬grid a} * εcoef * + (1 + (layerKernelIndexBound m Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬grid a}) + + allocatedAffineSourceReferenceError B U basis S α O (ρ grid) P η (fun _ => modulus) H ε mesh Cmask + := by + intro center width ideal outputResidue + have hw := principalProgressionSlice_parameters (α := α) activeB activeDegree + L H step c positiveLengths hstep hH hδ hsubset hdense + have ht := allocatedAffineCoveredProfile_mean_test_integral B U basis S rows x hR (ρ grid) + center width hσ v₀ Q hb o bW d ν hρ hρ1 (fun i => (hw i).2.2) hRP hRi + modulus gridLaw outputResidue hCmask hmask (fun j => (hσsmall j).trans htone) + T hT hsource C hC hchart hbudget F hF hFbound + have hc := allocatedAffineWholeCovered_comparison B U basis hR hσ S rows x s hA hMk hi + hP hMkP hRP hRi hσi hcount Q hb o bW d (fun p => F (Prod.snd p)) + H₀ step₀ c₀ hH₀ hsubset₀ modulus r₀ hcell ρ t htone hs hσsmall hstep hH hδ hdense + hm hsize hsmall hε hmesh selection hgood hq he hεcoef hεe hlarge hperiod v₀ hv₀ + hmesh0 hmesh1 hscaleMesh hCmask hmask (hF.comp measurable_snd) (fun p => hFbound p.2) + change ‖actual - (gridLaw).complexMean (fun u => ∫ a₀, ∫ z, + (allocatedLongProfileDensity B U basis S x rows modulus (outputResidue u) ideal z : ℂ) * + allocatedCoveredFixedTest B U basis S x u v₀ rows Q hb o bW d (fun p => F (Prod.snd p)) a₀ z + ∂reference ∂frozenSource)‖ ≤ _ at hc + rw [ht] at hc + simpa only [allocatedWholeMaskedCoveredProfile_join] using hc + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCandidateEarlyAffinePhysicalTerminal.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCandidateEarlyAffinePhysicalTerminal.lean new file mode 100644 index 0000000000000000000000000000000000000000..85488d812d05b45fa4c7fbf80b09e569ae0ba533 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCandidateEarlyAffinePhysicalTerminal.lean @@ -0,0 +1,229 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffinePhysicalTerminalReset + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped Classical TensorProduct BigOperators + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom realSymbolGradeEvaluation + CertifiedFullChartFiniteHistory.outer CertifiedFullChartFiniteHistory.earlyForwardBranchTree + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] [DecidableEq X] + {I Deck J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M s} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem + +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := Deck) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + (keep : ℕ → LayerSamplerVariables G I n B → Prop) + {ι κ η : Type} {χ : ℕ → Type} [Fintype ι] [Fintype κ] [∀ r, Fintype (χ r)] [Fintype η] + (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (bD '' {i | j ≤ ω i})) + (bF : Basis κ ℚ M) (ν : κ → ℕ) + (hF : ∀ j, Fmark.layer j = span ℚ (bF '' {i | j ≤ ν i})) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.layer j) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + +local notation "fast" => W.map (D.filtration.associatedGradedMap Fmark φ hφ) +local notation "gmark" => Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked +local notation "Z" => Fmark.realPolynomialSymbolHom bF ν hF (fullTaggedVariableWeight J) gmark +local notation "countConstants" => (fun n => fullChartStageCountConstant (n + 1) 254) + +theorem exists_early_forward_affine_physical_terminal + [Fintype (SymbolBasisIndex (fun _ : LayerSamplerVariables G I n B => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : LayerSamplerVariables G I n B => 1) ν)] + [∀ r, Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep r i} => 1) ω)] + [∀ r, Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep r i} => 1) ν)] + [∀ r, TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [∀ r, IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [∀ r, ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [∀ r, T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + (eQ : Basis η ℚ (Fmark.AssociatedGraded ⧸ (fast).toSubmodule)) + (lift : (Fmark.AssociatedGraded ⧸ (fast).toSubmodule) →ₗ[ℚ] Fmark.AssociatedGraded) + (hfast : BasisGradedSubmodule (Fmark.associatedGradedBasis bF ν hF) ν (fast).toSubmodule) + (hsection : ∀ y, (fast).toSubmodule.mkQ (lift y) = y) + (Bbound Rrank : ℝ) (Hbr qS : ℕ) + (scheduleExponent : ℕ) (x gainLog stageLog : ℝ) + (hx : 0 ≤ x) (hgain : gainLog ∈ Set.Icc 0 x) (hstage : stageLog ∈ Set.Icc 0 x) + (Cprimitive Csource : ℕ) (sourceNative pTest α : ℕ → ℝ) + (hSourceNonneg : ∀ r < s, 0 ≤ sourceNative r) + (hSourceBound : ∀ r < s, sourceNative r ≤ + (preparedFiniteForwardSourcePrecision scheduleExponent countConstants r x gainLog stageLog + + preparedFiniteForwardWork scheduleExponent countConstants r x + Csource) ^ Csource) + (hBaseExponent : allocatedCandidateStageBaseExponent s m Cprimitive ≤ scheduleExponent) + (hphaseExponent : ∀ r < s, + allocatedCandidateCompositePhaseConstant s m 1 + (allocatedCandidatePromotedMajorConstant Csource) r ≤ scheduleExponent) + (hHbr : 1 ≤ Hbr) (hqS : 0 < qS) + (hκBase : (Fintype.card κ : ℝ) ≤ x) + (hTagsBase : (Fintype.card (X ⊕ (Σ j, J j)) : ℝ) ≤ x) + (hηBase : (Fintype.card η : ℝ) ≤ x) + (hmEarly : (m : ℝ) ≤ x) + (hblocksEarly : ((s * (Fintype.card η * m) : ℕ) : ℝ) ≤ x) + (hHbrBase : (Hbr : ℝ) ≤ Real.exp x) (hqSBase : (qS : ℝ) ≤ Real.exp x) + (hBboundBase : Bbound ≤ Real.exp x) + (hstructure : ∀ i j z, RationalHeightLE ((Fmark.associatedGradedBasis bF ν hF).repr + ⁅Fmark.associatedGradedBasis bF ν hF i, Fmark.associatedGradedBasis bF ν hF j⁆ z) Hbr) + (hentry : ∀ i j, |((Fmark.associatedGradedBasis bF ν hF).baseChange ℝ).repr + (lift.baseChange ℝ ((eQ.baseChange ℝ) j)) i| ≤ Bbound) + (hgrid : ∀ j, (fun i => ((Fmark.associatedGradedBasis bF ν hF).baseChange ℝ).repr + (lift.baseChange ℝ ((eQ.baseChange ℝ) j)) i) ∈ realDenominatorGrid qS) + (hcost : cost ≤ (x + Cprimitive) ^ Cprimitive) + (HMap l H Hθ : ℕ) (qNative : ℝ) + (hHMap : 1 ≤ HMap) (hl : 0 < l) (hH : 1 ≤ H) + (hHMapExp : (HMap : ℝ) ≤ Real.exp ((x + Cprimitive) ^ Cprimitive)) + (hlExp : (l : ℝ) ≤ Real.exp ((x + Cprimitive) ^ Cprimitive)) + (hHExp : (H : ℝ) ≤ Real.exp ((x + Cprimitive) ^ Cprimitive)) + (hHθExp : (Hθ : ℝ) ≤ Real.exp ((x + Cprimitive) ^ Cprimitive)) + (hqNative : qNative ≤ (x + Cprimitive) ^ Cprimitive) + (hentries : ∀ i j, RationalHeightLE (bF.repr (φ (bD j)) i) HMap) + (hsource : (Fintype.card (SymbolBasisIndex + (fun _ : LayerSamplerVariables G I n B => 1) ω) : ℝ) ≤ + (x + Cprimitive) ^ Cprimitive) + (htarget : (Fintype.card (SymbolBasisIndex + (fun _ : LayerSamplerVariables G I n B => 1) ν) : ℝ) ≤ + (x + Cprimitive) ^ Cprimitive) + (hκ : (Fintype.card κ : ℝ) ≤ (x + Cprimitive) ^ Cprimitive) + (hχ : ∀ r < s, (Fintype.card (χ r) : ℝ) ≤ (x + Cprimitive) ^ Cprimitive) + (htags : (Fintype.card (X ⊕ (Σ j, J j)) : ℝ) ≤ (x + Cprimitive) ^ Cprimitive) + (hsampler : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ (x + Cprimitive) ^ Cprimitive) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ (x + Cprimitive) ^ Cprimitive) + (hbracket : ∀ i j z, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ z) H) + (vg : ∀ r, χ r → Fmark.PolynomialSymbol + (fun _ : {i : LayerSamplerVariables G I n B // keep r i} => 1)) + (hspan : ∀ r < s, span ℚ (Set.range (vg r)) = + (Fmark.symbolPointwiseSubalgebra bF ν hF + (fun _ : {i : LayerSamplerVariables G I n B // keep r i} => 1) fast).toSubmodule) + (hvg : ∀ r < s, ∀ i z, RationalHeightLE + ((Fmark.polynomialSymbolBasis bF ν hF + (fun _ : {i : LayerSamplerVariables G I n B // keep r i} => 1)).repr (vg r i) z) H) + (hθ : ∀ j i, RationalHeightLE (((eQ.coord j).comp (fast).toSubmodule.mkQ) + (Fmark.associatedGradedBasis bF ν hF i)) Hθ) + (hOriginal : ∀ z : P.productive, D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : (P.chart z).Variables => (A.sides i.val : ℝ)) qNative l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) (P.candidate z).orbit)) + (hτ : τ ≤ 1) (hξ : ξ ≤ 1) (hσone : ∀ j, σ j ≤ 1) + (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1 / 8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hkept : ∀ r, ∀ i, keep r i → Real.exp (allocatedCandidateStageSlice s m Cprimitive + (preparedFiniteForwardParameter scheduleExponent countConstants r x)) ≤ (A.sides i : ℝ)) + (hfrozen : ∀ r, ∀ i, ¬keep r i → (A.sides i : ℝ) ≤ Real.exp (allocatedCandidateStageSlice s m Cprimitive + (preparedFiniteForwardParameter scheduleExponent countConstants r x))) + (hTest : ∀ r < s, OrdinaryPolynomialPhase.budget r ≤ pTest r) + (hα : ∀ r < s, α r ≤ (9 / 10 : ℝ) * massThreshold) + (hdirect : ∀ r < s, A.NativeDetection r (allocatedCandidateStageSlice s m Cprimitive + (preparedFiniteForwardParameter scheduleExponent countConstants r x)) (pTest r) (sourceNative r) (α r)) + (hN : ∀ i, Real.exp (preparedFiniteForwardCumulative scheduleExponent countConstants s x) ≤ (N i : ℝ)) + (hRrank : Real.exp (preparedFiniteForwardCumulative scheduleExponent countConstants s x) ≤ Rrank) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) + (fun i => (N i : ℝ)) Rrank (U j) (poly j)) + (hs : 0 < s) (hmass : 0 < massThreshold) + (separation : ℝ) + (hseparation : certifiedAffineLongSideBound + (preparedFiniteForwardCumulative scheduleExponent countConstants s x) ≤ separation) + (a : ℕ) (pFull : ℝ) + (hFullBase : (x + Cprimitive) ^ Cprimitive ≤ pFull) + (hdenFull : + Real.exp (preparedFiniteForwardWork scheduleExponent countConstants s x) * + (Real.exp ((m : ℝ) * certifiedAffineCenterBudget + (preparedFiniteForwardCumulative scheduleExponent countConstants s x))) ^ s ≤ + Real.exp pFull) + (hmassFull : + (((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ s * + Real.exp (preparedFiniteForwardWork scheduleExponent countConstants s x) * + (actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) pFull + (((preparedFiniteForwardCumulative scheduleExponent countConstants s x + + ((preparedFiniteForwardCumulative scheduleExponent countConstants s x + 2)^2+2)^63)+2)^8)) ^ s ≤ + Real.exp ((pFull + 2) ^ a))) : + let hXEarly : (Fintype.card X : ℝ) ≤ x := by + have hsum : (Fintype.card X : ℝ) + (Fintype.card (Σ j, J j) : ℝ) ≤ x := by + simpa only [Fintype.card_sum, Nat.cast_add] using hTagsBase + exact (le_add_of_nonneg_right (Nat.cast_nonneg _)).trans hsum + let hJEarly : (Fintype.card (Σ j, J j) : ℝ) ≤ x := by + have hsum : (Fintype.card X : ℝ) + (Fintype.card (Σ j, J j) : ℝ) ≤ x := by + simpa only [Fintype.card_sum, Nat.cast_add] using hTagsBase + exact (le_add_of_nonneg_left (Nat.cast_nonneg _)).trans hsum + let hNEarly : ∀ i, 1 ≤ N i := by + intro i + have hpos : 0 < N i := by + exact_mod_cast ((Real.exp_pos _).trans_le (hN i)) + exact Nat.succ_le_iff.mpr hpos + let T := CertifiedFullChartFiniteHistory.earlyForwardBranchTree + Fmark bF ν hF J (fast).toSubmodule (eQ.baseChange ℝ) lift Z U poly N + s scheduleExponent x hx hXEarly hmEarly hJEarly hηBase hblocksEarly + (fun j ex _ => hm j ex) hNEarly + let pAffine := preparedFiniteForwardCumulative scheduleExponent countConstants s x + let budget := preparedFiniteForwardWork scheduleExponent countConstants s x + ∃ history ∈ T.level s, + FullChartControlledFactors Fmark bF ν hF J poly N history.outer.1 history.outer.2 + budget ∧ + RationalTaggedConstraintCertificate J Set.univ history.K + pAffine + (s * (Fintype.card η * m)) ∧ + (∀ point ∈ history.K, + eval₂ point (Fmark.realGradedSymbolPolynomial bF ν hF (fullTaggedVariableWeight J) + (history.outer.1⁻¹ * Z * history.outer.2⁻¹).coord) ∈ + (fast).toSubmodule.baseChange ℝ) ∧ + Nonempty (P.AffinePhysicalTerminalData bF ν hF hφ W (eQ.baseChange ℝ) lift + pAffine budget pAffine pFull a history separation) := by + classical + intro hXEarly hJEarly hNEarly T pAffine budget + obtain ⟨history, hmem, hcontrol, hcertificate, hterminalFast⟩ := + P.exists_early_forward_terminal_of_frozen_candidates keep bD ω hD bF ν hF hφ W + eQ lift hfast hsection Bbound Rrank Hbr qS scheduleExponent x gainLog stageLog + hx hgain hstage Cprimitive Csource sourceNative pTest α hSourceNonneg hSourceBound + hBaseExponent hphaseExponent hHbr hqS hκBase hTagsBase hηBase hmEarly hblocksEarly + hHbrBase hqSBase hBboundBase hstructure hentry hgrid hcost HMap l H Hθ qNative + hHMap hl hH hHMapExp hlExp hHExp hHθExp hqNative hentries hsource htarget hκ hχ + htags hsampler hJ hbracket vg hspan hvg hθ hOriginal hτ hξ hσone Cgeo hCgeo + hchart hsmall hpoly hkept hfrozen hTest hα hdirect hN hRrank hrank + have hA : 1 ≤ scheduleExponent := + (by omega : 1 ≤ 2).trans + ((allocatedCandidateStageBaseExponent_bounds s m Cprimitive).1.trans hBaseExponent) + have hxcum := le_preparedFiniteForwardCumulative scheduleExponent countConstants s hx hA hs + have hcum : 0 ≤ preparedFiniteForwardCumulative scheduleExponent countConstants s x := + hx.trans hxcum + have hpFull : 0 ≤ pFull := + (show 0 ≤ (x + Cprimitive) ^ Cprimitive by positivity).trans hFullBase + refine ⟨history, hmem, hcontrol, hcertificate, hterminalFast, ?_⟩ + exact P.exists_affinePhysicalTerminalData bF ν hF hφ W (eQ.baseChange ℝ) lift + pAffine budget pAffine history hfast hcontrol hcertificate hcum + (hJEarly.trans hxcum) (hblocksEarly.trans hxcum) hpoly hτ hξ hσone + Cgeo hCgeo hchart (fun j => (hsmall j).trans (by norm_num)) hmass H a pFull + hH hpFull (hκ.trans hFullBase) (htags.trans hFullBase) + (hHExp.trans (Real.exp_le_exp.mpr hFullBase)) hdenFull hbracket + (hsampler.trans hFullBase) hmassFull separation hseparation + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCenteredBadPrimeSurrogate.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCenteredBadPrimeSurrogate.lean new file mode 100644 index 0000000000000000000000000000000000000000..7191a69d1db4b1c33086b6a3113025f4707a81fb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCenteredBadPrimeSurrogate.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedAnchoredRecoveredSource + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule MeasureTheory +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) +variable (inactive : LayerSamplerAxis I n → Prop) (rankC : ℝ) + +private theorem singleton_prime_neZero (p : ℕ) [NeZero p] (r : ({p} : Finset ℕ)) : NeZero r.val := by + have hr : r.val = p := Finset.mem_singleton.mp r.property + rw [hr] + infer_instance + +private theorem singleton_prime_power_dvd (p a : ℕ) (r : ({p} : Finset ℕ)) : r.val ^ a ∣ p ^ a := by + have hr : r.val = p := Finset.mem_singleton.mp r.property + simp only [hr, dvd_refl] + +def allocatedPhysicalPrimePowerEvent + (z : Option (LayerSamplerVariables G I n B) × X → ℤ) (p a : ℕ) [NeZero p] : Prop := + letI : ∀ r : ({p} : Finset ℕ), NeZero r.val := singleton_prime_neZero p + coefficientDeckChartEvent U bW b hb o (p ^ a) + (allocatedChartResiduePrimePowerWitness inactive rankC {p} (fun _ => a) (p ^ a) + (singleton_prime_power_dvd p a) (fun v => (z v : ZMod (p ^ a)))) + (affineCoefficientCoverSample U poly hm (p ^ a) (fun k x => (z (k,x) : ℝ))) + +variable {L : ℕ} (spatial : Fin L ↪ G) +variable (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) + +theorem AllocatedPhysicalRankReadCertificate.primePowerEvent_iff + {z : Option (LayerSamplerVariables G I n B) × X → ℤ} + {f : AllocatedActualCoefficientIndex G X I E n B → ℤ} + (hf : AllocatedPhysicalRankReadCertificate B U bW b hb o poly hm inactive spatial kernel block rankC z f) + (p a : ℕ) [NeZero p] : + allocatedPhysicalPrimePowerEvent B U bW b hb o poly hm inactive rankC z p a ↔ + allocatedActualModulusBad inactive spatial kernel block rankC (p ^ a) f := by + have hpa : 0 < p ^ a := pow_pos (NeZero.pos p) a + have he := hf {p} (singleton_prime_neZero p) (fun _ => a) (p ^ a) hpa + (singleton_prime_power_dvd p a) + refine he.trans ?_ + constructor + · intro h + exact h ⟨p, Finset.mem_singleton_self p⟩ + · intro h r + have hr : r.val = p := Finset.mem_singleton.mp r.property + rcases r with ⟨r, hrmem⟩ + have hrp : r = p := Finset.mem_singleton.mp hrmem + subst r + exact h + +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + +theorem allocatedPhysicalPrimePowerEvent_center_measurableSet + {T : Type*} [MeasurableSpace T] (c : T → ∀ j, U j) (hc : Measurable c) + (base : X → ℤ) (z : Option (LayerSamplerVariables G I n B) × X → ℤ) + (p a : ℕ) [NeZero p] : + MeasurableSet {center | allocatedPhysicalPrimePowerEvent B U bW b hb o + (fun j => translate (fun x => (base x : ℝ)) (subtractConstant (c center j).val (poly j))) + (fun j => coefficients_translate_mem (U j) (fun x => (base x : ℝ)) _ + (coefficients_subtractConstant_mem (U j) (c center j) (poly j) (hm j))) + inactive rankC z p a} := by + unfold allocatedPhysicalPrimePowerEvent + exact coefficientDeckChartEvent_center_measurableSet U bW b hb o poly hm c hc base z (p ^ a) _ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCertifiedAffinePhysicalSlowBound.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCertifiedAffinePhysicalSlowBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf61ab0cdb047dfbd72800778ee3024a6c3a2ac4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCertifiedAffinePhysicalSlowBound.lean @@ -0,0 +1,598 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedExternalCandidateResetSuccessor +import OAI.Combinatorics.Progressions.Dynamics.CommonRefilteredGlobalMarkedFamilyReset +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateKeptSymbolFactors +import OAI.Combinatorics.Progressions.Linear.ActualCandidateSlowProjectionMass +import OAI.Combinatorics.Progressions.Sampling.FullTaggedRationalChartGrid + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem.CertifiedAffineRefinement + +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {pAffine : ℝ} + (C : P.CertifiedAffineRefinement K pAffine) + +local notation "wt" => fullTaggedVariableWeight (X := X) J + +noncomputable def globalChart : + (X ⊕ (Σ j, J j)) → MvPolynomial (X ⊕ (Σ j, J j)) ℝ := + fullTaggedAffineMapChart J (fullTaggedRealMatrixProjection J C.projection) C.translate + +noncomputable def slowChart : + (X ⊕ (Σ j, J j)) → MvPolynomial (X ⊕ (Σ j, J j)) ℝ := + fullTaggedSlowProjectionChart J (fullTaggedRealMatrixProjection J C.projection) + (fun i => (N i : ℝ)) poly (fun j => (P.centerLift j).val) + +noncomputable def commonDenominator : ℕ := ∏ j, C.denominator j + +theorem globalChart_support (i : X ⊕ (Σ j, J j)) : + C.globalChart i ∈ weightedSupportLE wt (wt i) := + fullTaggedAffineMapChart_support J _ _ i + +theorem slowChart_support + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (i : X ⊕ (Σ j, J j)) : + C.slowChart i ∈ weightedSupportLE wt (wt i) := + fullTaggedSlowProjectionChart_support J _ _ poly hpoly _ i + +theorem globalChart_top (i : X ⊕ (Σ j, J j)) : + weightedHomogeneousComponent wt (wt i) (C.globalChart i) = + fullTaggedLinearMapChart J (fullTaggedRealMatrixProjection J C.projection) i := + fullTaggedAffineMapChart_top J _ _ i + +theorem slowChart_top (i : X ⊕ (Σ j, J j)) : + weightedHomogeneousComponent wt (wt i) (C.slowChart i) = + aeval (fun a => weightedHomogeneousComponent wt (wt a) (C.globalChart a)) + (normalizedRealPolynomialChart (fun x => (N x : ℝ)) + (fullTaggedMajorTopCoordinates J poly) i) := by + simp only [C.globalChart_top] + exact fullTaggedSlowProjectionChart_top J _ _ poly _ i + +theorem globalChart_top_mem (x : X ⊕ (Σ j, J j) → ℝ) : + (fun i => MvPolynomial.eval x + (weightedHomogeneousComponent wt (wt i) (C.globalChart i))) ∈ K := by + apply fullTaggedAffineMapChart_top_mem_set J _ _ + (fun j => realRationalCoordinateSpan (C.space j)) _ K _ x + · intro j y + rw [← C.range_eq j] + exact LinearMap.mem_range_self _ y + · intro y hy + rw [C.constraint] + exact hy + +theorem commonDenominator_pos : 0 < C.commonDenominator := + Finset.prod_pos (fun j _ => C.denominator_pos j) + +theorem commonDenominator_bound : + (C.commonDenominator : ℝ) ≤ + Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine) := by + rw [commonDenominator, Nat.cast_prod] + calc + _ ≤ ∏ _j : Fin m, Real.exp (certifiedAffineCenterBudget pAffine) := + Finset.prod_le_prod₀ (fun j _ => Nat.cast_nonneg _) (fun j _ => C.denominator_bound j) + _ = _ := by + simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin, Real.exp_nat_mul] + +theorem globalChart_top_grid (v : X ⊕ (Σ j, J j)) : + realPolynomialCoefficientGrid C.commonDenominator + (weightedHomogeneousComponent wt (wt v) (C.globalChart v)) := by + rw [C.globalChart_top] + apply fullTaggedLinearMapChart_coefficientGrid J + (fullTaggedRealMatrixProjection J C.projection) C.commonDenominator + intro j i a + obtain ⟨z, hz⟩ := C.projection_grid j i a + have hdiv : C.denominator j ∣ C.commonDenominator := + Finset.dvd_prod_of_mem C.denominator (Finset.mem_univ j) + obtain ⟨k, hk⟩ := hdiv + refine ⟨(k : ℤ) * z, ?_⟩ + have hentry : fullTaggedRealMatrixProjection J C.projection j (Pi.single a 1) i = + (C.projection j i a : ℝ) := by + change (Matrix.mulVecLin (fun (i a : J j) => (C.projection j i a : ℝ))) + (Pi.single a (1 : ℝ)) i = (C.projection j i a : ℝ) + exact congrFun (Matrix.mulVec_single_one + (fun (i a : J j) => (C.projection j i a : ℝ)) a) i + rw [hentry, hk, Nat.cast_mul, Int.cast_mul, Int.cast_natCast, ← hz] + ring + +end AllocatedExternalCandidateProblem.CertifiedAffineRefinement +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical TensorProduct +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + +theorem exists_allocatedCertifiedAffineFamilyReset (s a : ℕ) : + ∃ Ccompare Cf Cnative : ℕ, 2 ≤ Ccompare ∧ 2 ≤ Cf ∧ 2 ≤ Cnative ∧ + ∀ {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ i, Fintype (B i)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ narrow : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {sampler : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ narrow stride cells center} + {L M κ ξ μ χ : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [Fintype κ] [Fintype ξ] [Fintype μ] [Fintype χ] + {d f : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (bF : Basis κ ℚ M) (ν : κ → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (bF '' {i | j ≤ ν i})), + (∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) → + ∀ (keep : LayerSamplerVariables G I n B → Prop), + ∀ (bk : Basis ξ ℚ (LinearMap.ker φ.toLinearMap)) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) (v : μ → D.filtration.AssociatedGraded), + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule → + Submodule.span ℚ (Set.range v) = W.toSubmodule → + ∀ (vg : χ → Fmark.filtration.PolynomialSymbol (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + Submodule.span ℚ (Set.range vg) = + (Fmark.filtration.symbolPointwiseSubalgebra bF ν hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))).toSubmodule → + ∀ [Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ν)] + (H l nFinal : ℕ) (pMap pNative : ℝ), + 1 ≤ H → 0 < l → 0 < nFinal → 0 ≤ pMap → 0 ≤ pNative → + (Fintype.card (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ω) : ℝ) ≤ pMap → + (Fintype.card (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ν) : ℝ) ≤ pMap → + (H : ℝ) ≤ Real.exp pMap → ((l * nFinal : ℕ) : ℝ) ≤ Real.exp pMap → + Real.exp ((pMap + 2) ^ 4) ≤ Real.exp pNative → + (d : ℝ) ≤ pNative → (Fintype.card κ : ℝ) ≤ pNative → + (Fintype.card ξ : ℝ) ≤ pNative → (Fintype.card μ : ℝ) ≤ pNative → + (Fintype.card χ : ℝ) ≤ pNative → (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ pNative → + (H : ℝ) ≤ Real.exp pNative → + (∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) H) → + (∀ i j k, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ k) H) → + (∀ i j, RationalHeightLE (D.basis.repr (bk j : L) i) H) → + (∀ k i, RationalHeightLE (bF.repr (φ (D.basis i)) k) H) → + (∀ j i, RationalHeightLE ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) H) → + (∀ i z, RationalHeightLE + ((Fmark.filtration.polynomialSymbolBasis bF ν hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)).repr (vg i) z) H) → + ∃ mMap mReset : ℕ, 0 < mMap ∧ (mMap : ℝ) ≤ Real.exp ((pMap + 2) ^ 4) ∧ + l * nFinal ∣ mMap ∧ 0 < mReset ∧ + (mReset : ℝ) ≤ Real.exp ((markedNativeLiftInput + (fullMarkedNativeInput (s + 1) a Cf pNative) + Cnative) ^ Cnative) ∧ mMap ∣ mReset ∧ + ∀ (marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)) + (observable : (X → ℤ) → D.Space → ℂ) (weight : (X → ℤ) → ℂ) + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) sampler D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {pAffine : ℝ} + (affine : P.CertifiedAffineRefinement K pAffine) + (hkeep : ∀ z : affine.refinement.problem.productive, + (affine.refinement.problem.chart z).keep = keep) + (EF RF : Fmark.filtration.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (factors : GlobalMarkedNativeFactors Fmark.filtration bF ν hF + (fullTaggedVariableWeight J) + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)) + (Fmark.filtration.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fullTaggedVariableWeight J) affine.globalChart affine.globalChart_support + (Fmark.filtration.realification.polynomialOrbitCoordinates _ marked)) EF RF), + Fmark.filtration.PolynomialRationalGrid bF (fullTaggedVariableWeight J) nFinal factors.right → + (∀ z : affine.refinement.problem.productive, + let C := affine.refinement.problem.chart z + Fmark.filtration.PolynomialSlowBound bF (fun _ : C.Variables => 1) + (fun i => (sampler.sides i.val : ℝ)) (Real.exp ((pNative + 2) ^ a)) + (Fmark.filtration.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : C.Variables => 1) (integerSampledRealChart C.integerChart) + C.integerChart_support factors.left)) → + (∀ i : {i : LayerSamplerVariables G I n B // keep i}, + Real.exp ((pNative + Ccompare) ^ Ccompare) ≤ (sampler.sides i.val : ℝ)) → + ∀ (q densityCost cutoff : ℝ), + Real.exp q ≤ Real.exp ((pNative + 2) ^ a) → + Real.exp ((pMap + 2) ^ 3 + q) ≤ Real.exp ((pNative + 2) ^ a) → + (∀ z : affine.refinement.problem.productive, + let C := affine.refinement.problem.chart z + IsDenseCommonStrideBox (fun i : C.Variables => sampler.sides i.val) + densityCost C.slice.integerPoints) → + Real.exp densityCost * ((s + 1 + 1 : ℕ) : ℝ) ≤ cutoff → + (∀ i, keep i → cutoff ≤ layerSamplerBox B U btag S i) → + (∀ z : (affine.refinement.problem.withKeep keep hkeep).productive, + D.filtration.HasCommonRefilteredOrbitFactors D.basis ω hD + (fun i : {i : LayerSamplerVariables G I n B // keep i} => (sampler.sides i.val : ℝ)) + q l W (D.filtration.realification.polynomialOrbitCoordinates _ + ((affine.refinement.problem.withKeep keep hkeep).candidate z).orbit)) → + Nonempty (AllocatedExternalGlobalNativeResetFamily Fmark φ hφ + affine.refinement.problem keep hkeep W factors + (Real.exp ((markedNativeLiftInput (fullMarkedNativeInput (s + 1) a Cf pNative) + + Cnative) ^ Cnative)) mReset) := by + classical + obtain ⟨Ccompare, Cf, Cnative, hCcompare, hCf, hCnative, hreset⟩ := + exists_common_refiltered_globalMarked_family_reset (s + 1) a + refine ⟨Ccompare, Cf, Cnative, hCcompare, hCf, hCnative, ?_⟩ + intro m G X _ _ I E J _ _ n B _ U btag Rad σ S hb o hRad hσ N poly hm + τ narrow stride cells center _ sampler L M κ ξ μ χ _ _ _ _ _ _ _ _ d f + D Fmark φ hφ ω hD bF ν hF hsurj keep bk W v hW hvspan vg hvgspan _ _ + H l nFinal pMap pNative hH hl hnFinal hpMap hpNative hsrc htgt hHmap hlmap hmabsorb + hd hκ hξ hμ hχ hvars hHp hbracketD hbracketF hkernel hentries hv hvg + obtain ⟨mMap, mReset, hmMap, hmMapBound, hdiv, hmReset, hmResetBound, hmMapReset, hrun⟩ := + hreset D.filtration Fmark.filtration φ hφ D.basis ω hD bF ν hF hsurj + bk W v hW hvspan vg hvgspan H l nFinal pMap pNative hH hl hnFinal hpMap hpNative + hsrc htgt hHmap hlmap hmabsorb (by simpa using hd) hκ hξ hμ hχ hvars hHp + hbracketD hbracketF hkernel hentries hv hvg + refine ⟨mMap, mReset, hmMap, hmMapBound, hdiv, hmReset, hmResetBound, hmMapReset, ?_⟩ + intro marked observable weight cost massThreshold scoreThreshold P K pAffine affine hkeep + EF RF factors hgrid hslow hside q densityCost cutoff hq hqmap hdensity hcutoff hlong hcommon + let Q := affine.refinement.problem.withKeep keep hkeep + have hfixed (z : Q.productive) := + (affine.refinement.problem.chart z).withKeep_chart_fixed keep (hkeep z) + affine.globalChart (affine.chart_fixed z) + have hslow' (z : Q.productive) := + (affine.refinement.problem.chart z).withKeep_polynomialSlowBound keep (hkeep z) + Fmark.filtration bF factors.left (Real.exp ((pNative + 2) ^ a)) (hslow z) + have hmarked (z : Q.productive) := (Q.candidate z).formal_mark_group hφ (by + simp only [max_self] + apply (Q.chart z).slice_length_gt_of_dense_cutoff + ((affine.refinement.problem.chart z).withKeep_dense keep (hkeep z) densityCost (hdensity z)) + (s + 1) hcutoff + exact hlong) + obtain ⟨left, middle, right, native, hfactors⟩ := hrun + (fullTaggedVariableWeight J) affine.globalChart affine.globalChart_support + (Fmark.filtration.realification.polynomialOrbitCoordinates _ marked) EF RF factors hgrid + (fun _ : Q.productive => fun i : {i : LayerSamplerVariables G I n B // keep i} => (sampler.sides i.val : ℝ)) + (fun _ => q) (fun z => (Q.chart z).integerChart) (fun z => (Q.chart z).integerChart_support) + (fun _ => hside) (fun _ => hq) (fun _ => hqmap) hfixed hslow' + (fun z => D.filtration.realification.polynomialOrbitCoordinates _ (Q.candidate z).orbit) + hmarked hcommon + exact ⟨{ + localLeft := left + localMiddle := middle + localRight := right + native := native + source_factor := fun z => (hfactors z).1 + projection_left := fun z => (hfactors z).2.1 + projection_right := fun z => (hfactors z).2.2.1 + projection_middle := fun z => (hfactors z).2.2.2.1 + slow_left := fun z => (hfactors z).2.2.2.2.1 + grid_right := fun z => (hfactors z).2.2.2.2.2.1 + native_log := fun z => (hfactors z).2.2.2.2.2.2.1 }⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped TensorProduct BigOperators + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom realChartSubstitute PolynomialRationalGrid PolynomialSlowBound + CertifiedFullChartFiniteHistory.outer + +theorem exists_allocatedCertifiedAffineGlobalTerminal (t a : ℕ) : + ∃ Ce Cr : ℕ, 2 ≤ Ce ∧ 2 ≤ Cr ∧ + ∀ {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ i, Fintype (B i)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {sampler : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) sampler D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + {ι η : Type} [Fintype ι] [Fintype η] + (bF : Basis ι ℚ M) (ω : ι → ℕ) + (hF : ∀ j, Fmark.layer j = span ℚ (bF '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ Fmark.AssociatedGraded) + (basis : Basis η ℝ (ℝ ⊗[ℚ] (Fmark.AssociatedGraded ⧸ W.toSubmodule))) + (lift : (Fmark.AssociatedGraded ⧸ W.toSubmodule) →ₗ[ℚ] Fmark.AssociatedGraded) + (Z : Fmark.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (Bphase budget pAffine : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark bF ω hF J W.toSubmodule basis lift + Z Set.univ U poly N Bphase t) + (affine : P.CertifiedAffineRefinement history.K pAffine), + BasisGradedSubmodule (Fmark.associatedGradedBasis bF ω hF) ω W.toSubmodule → + FullChartControlledFactors Fmark bF ω hF J poly N history.outer.1 history.outer.2 budget → + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + Fmark.realPolynomialSymbolHom bF ω hF (fullTaggedVariableWeight (X := X) J) + (Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked) = Z → + ∀ (H : ℕ) (pFull : ℝ), 1 ≤ H → 0 ≤ pFull → + (Fintype.card ι : ℝ) ≤ pFull → + (Fintype.card (X ⊕ (Σ j, J j)) : ℝ) ≤ pFull → + (H : ℝ) ≤ Real.exp pFull → + Real.exp budget * (Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine)) ^ t ≤ + Real.exp pFull → + (∀ i j k, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ k) H) → + let wt := fullTaggedVariableWeight (X := X) J + let β := affine.globalChart + let δ := affine.slowChart + let pull := Fmark.realSymbolHomogeneousPullbackHom bF ω hF wt wt + (fun i => weightedHomogeneousComponent wt (wt i) (β i)) + (fun _ => weightedHomogeneousComponent_isWeightedHomogeneous _ _) + 0 < affine.commonDenominator ∧ + (affine.commonDenominator : ℝ) ≤ Real.exp ((m : ℝ) * certifiedAffineCenterBudget pAffine) ∧ + ∃ q nFinal : ℕ, 0 < q ∧ (q : ℝ) ≤ Real.exp budget ∧ + 0 < nFinal ∧ (nFinal : ℝ) ≤ Real.exp ((pFull + Cr) ^ Cr) ∧ + q * affine.commonDenominator ^ t ∣ nFinal ∧ + ∃ factors : GlobalMarkedNativeFactors Fmark bF ω hF wt W + (Fmark.weightedAdaptedRealChartHom wt wt β affine.globalChart_support + (Fmark.realification.polynomialOrbitCoordinates wt marked)) + (pull history.outer.1) (pull history.outer.2), + Fmark.PolynomialRationalGrid bF wt nFinal factors.right ∧ + ∀ {Υ : Type*} [Fintype Υ] (v : Υ → ℕ), (∀ i, 0 < v i) → + (Fintype.card Υ : ℝ) ≤ pFull → + ∀ (γ : (X ⊕ (Σ j, J j)) → MvPolynomial Υ ℝ) + (hγ : ∀ i, γ i ∈ weightedSupportLE v (wt i)) + (T : Υ → ℝ), (∀ i, 0 < T i) → + ∀ mass : ℝ, 1 ≤ mass → + (∀ i, realPolynomialMass + (scaleMvPolynomialAxes T (MvPolynomial.aeval γ (δ i))) ≤ mass) → + (((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ t * + Real.exp budget * mass ^ t ≤ Real.exp ((pFull + 2) ^ a)) → + Fmark.PolynomialSlowBound bF v T (Real.exp ((pFull + Ce) ^ Ce)) + (Fmark.weightedAdaptedRealChartHom wt v γ hγ factors.left) := by + obtain ⟨Ce, Cr, hCe, hCr, hterminal⟩ := + exists_controlled_terminal_globalMarkedNativeFactors t a + refine ⟨Ce, Cr, hCe, hCr, ?_⟩ + intro m G X _ _ I E J _ _ n B _ U btag Rad σ S hb o hRad hσ N poly hm + τ ξ stride cells center _ sampler L M _ _ _ _ s d D Fmark φ marked observable weight + cost massThreshold scoreThreshold P ι η _ _ bF ω hF W basis lift Z Bphase budget pAffine + history affine hW hcontrol hpoly hZ H pFull hH hpFull hι hvars hHp hden hbracket + let wt := fullTaggedVariableWeight (X := X) J + let β := affine.globalChart + let δ := affine.slowChart + have hden' : Real.exp budget * (affine.commonDenominator : ℝ) ^ t ≤ Real.exp pFull := + (mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (Nat.cast_nonneg _) affine.commonDenominator_bound t) + (Real.exp_nonneg _)).trans hden + obtain ⟨q, nFinal, hq, hqB, hn, hnB, hdiv, hproduce⟩ := hterminal + Fmark bF ω hF J W basis lift Z Set.univ U poly N Bphase budget history hW hcontrol + β δ affine.globalChart_support (affine.slowChart_support hpoly) + affine.slowChart_top affine.globalChart_top_mem + affine.commonDenominator H pFull affine.commonDenominator_pos hH hpFull hι hvars hHp + hden' hbracket affine.globalChart_top_grid + refine ⟨affine.commonDenominator_pos, affine.commonDenominator_bound, + q, nFinal, hq, hqB, hn, hnB, hdiv, ?_⟩ + exact hproduce (Fmark.realification.polynomialOrbitCoordinates wt marked) hZ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem.CertifiedAffineRefinement + +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {pAffine : ℝ} + (C : P.CertifiedAffineRefinement K pAffine) + +theorem projection_fixes_original + (hretained : ∀ x, (∀ j, (fun i => x (Sum.inr ⟨j, i⟩)) ∈ U j) → x ∈ K) + (j : Fin m) (x : J j → ℝ) (hx : x ∈ U j) : + fullTaggedRealMatrixProjection J C.projection j x = x := by + apply C.fixes_space j x + exact retained_tag_le_of_product_constraint K + (fun j => realRationalCoordinateSpan (C.space j)) C.constraint hretained j hx + +theorem slowChart_mass + (hretained : ∀ x, (∀ j, (fun i => x (Sum.inr ⟨j, i⟩)) ∈ U j) → x ∈ K) + {dTag : ℝ} (hdTag : 0 ≤ dTag) + (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ dTag) + (hτ1 : τ ≤ 1) (hξ1 : ξ ≤ 1) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hσ1 : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1) + (z : C.refinement.problem.productive) (i : X ⊕ (Σ j, J j)) : + realPolynomialMass (scaleMvPolynomialAxes + (fun a : (C.refinement.problem.chart z).Variables => layerSamplerBox B U b S a.val) + (aeval (integerSampledRealChart (C.refinement.problem.chart z).integerChart) + (C.slowChart i))) ≤ + actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) dTag + (((pAffine + ((pAffine + 2) ^ 2 + 2) ^ 63) + 2) ^ 8) := by + have h := (C.refinement.problem.chart z).slowProjection_mass C.projection + (C.projection_fixes_original hretained) hdTag C.projection_height hdim + hτ1 hξ1 hp hσ1 Cgeo hCgeo hchart hsmall i + rw [C.refinement.problem.chart_centerLift z] at h + exact h + +theorem slowChart_mass_sides + (hretained : ∀ x, (∀ j, (fun i => x (Sum.inr ⟨j, i⟩)) ∈ U j) → x ∈ K) + {dTag : ℝ} (hdTag : 0 ≤ dTag) + (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ dTag) + (hτ1 : τ ≤ 1) (hξ1 : ξ ≤ 1) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hσ1 : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1) + (z : C.refinement.problem.productive) (i : X ⊕ (Σ j, J j)) : + realPolynomialMass (scaleMvPolynomialAxes + (fun a : (C.refinement.problem.chart z).Variables => (A.sides a.val : ℝ)) + (aeval (integerSampledRealChart (C.refinement.problem.chart z).integerChart) + (C.slowChart i))) ≤ + actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) dTag + (((pAffine + ((pAffine + 2) ^ 2 + 2) ^ 63) + 2) ^ 8) := by + have h := (C.refinement.problem.chart z).slowProjection_mass_sides C.projection + (C.projection_fixes_original hretained) hdTag C.projection_height hdim + hτ1 hξ1 hp hσ1 Cgeo hCgeo hchart hsmall i + rw [C.refinement.problem.chart_centerLift z] at h + exact h + +end AllocatedExternalCandidateProblem.CertifiedAffineRefinement +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open NilpotentLieFiltration +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates associatedGradedMap realPolynomialGroupMap + AllocatedExternalCandidateProblem.Refinement.problem + +noncomputable def allocatedAffineResetCompareExponent (s : ℕ) : ℕ := + Classical.choose (exists_allocatedCertifiedAffineFamilyReset s 1) + +noncomputable def allocatedAffineResetFactorExponent (s : ℕ) : ℕ := + Classical.choose (Classical.choose_spec (exists_allocatedCertifiedAffineFamilyReset s 1)) + +noncomputable def allocatedAffineResetLiftExponent (s : ℕ) : ℕ := + Classical.choose (Classical.choose_spec + (Classical.choose_spec (exists_allocatedCertifiedAffineFamilyReset s 1))) + +theorem allocatedAffineReset_exponents_ge_two (s : ℕ) : + 2 ≤ allocatedAffineResetCompareExponent s ∧ + 2 ≤ allocatedAffineResetFactorExponent s ∧ + 2 ≤ allocatedAffineResetLiftExponent s := by + have h := Classical.choose_spec (Classical.choose_spec + (Classical.choose_spec (exists_allocatedCertifiedAffineFamilyReset s 1))) + exact ⟨h.1, h.2.1, h.2.2.1⟩ + +noncomputable def allocatedAffineResetLogBudget (s : ℕ) (pNative : ℝ) : ℝ := + (markedNativeLiftInput + (fullMarkedNativeInput (s + 1) 1 (allocatedAffineResetFactorExponent s) pNative) + + allocatedAffineResetLiftExponent s) ^ allocatedAffineResetLiftExponent s + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem.CertifiedAffineRefinement + +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {pAffine : ℝ} + (C : P.CertifiedAffineRefinement K pAffine) + +theorem slowChart_physical_abs_le + (hretained : ∀ x, (∀ j, (fun i => x (Sum.inr ⟨j, i⟩)) ∈ U j) → x ∈ K) + {dTag : ℝ} (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ dTag) + (x : X → ℤ) (hx : x ∈ integerBox N) (z : X ⊕ (Σ j, J j)) : + |MvPolynomial.eval (fun v => (P.physicalIntegerPoint x v : ℝ)) (C.slowChart z)| ≤ + max 1 (dTag * Real.exp (((pAffine + ((pAffine + 2) ^ 2 + 2) ^ 63) + 2) ^ 8)) := by + exact fullTaggedSlowProjectionChart_physical_abs_le_rational J U C.projection + (C.projection_fixes_original hretained) N poly hm P.centerLift x hx + C.projection_height hdim z + +end AllocatedExternalCandidateProblem.CertifiedAffineRefinement +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedChildActiveResidueComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedChildActiveResidueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..327e8122d047894486dfe220ed8302806564b9be --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedChildActiveResidueComparison.lean @@ -0,0 +1,214 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedOriginalSampleSlicedPerturbedRiemann + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "Input" => (Σ a : Active, B (Subtype.val a) × Fin (degree (Subtype.val a))) +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short + +variable (x : G → IntegerScalarCubeBox Empty S.value) +variable (u : PrincipalAxisTuples (α := Empty) + (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + +include hR hσ in +theorem allocatedOriginalSample_sliced_affine_residue_comparison (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + (step H : Input → ℕ) (c : Input → ℤ) + (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + {δ : ℝ} (hδ : 0 < δ) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (S.value : ℤ)) + (hdense : ∀ j, δ * S.value ≤ + ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (q : ℕ) [NeZero q] (hsize : ∀ j, q ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H j) < 1) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / S.value ≤ ε) + (hδone : δ ≤ 1) (b : ∀ a : Active, B a.val) + {η : ℝ} (hη : 0 < η) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + (htail : |t| * polynomialMassC2Budget (Fintype.card Input) m 1 ≤ + slicedPrincipalC2Tolerance (Fintype.card Input) (Fintype.card Active) m 1 + (unitProfilePrincipalLowerBound B) (δ / 2) A η) + (φ : (Input → ZMod q) → (Output → ℝ) → ℂ) {Kφ : ℝ≥0} + (hφ : ∀ r, LipschitzWith Kφ (φ r)) (hφone : ∀ r y, ‖φ r y‖ ≤ 1) : + let lower := fun (a : Active) (p : B a.val × Fin (degree a.val)) => (c ⟨a, p⟩ : ℝ) / S.value + let width := fun (a : Active) (p : B a.val × Fin (degree a.val)) => + (step ⟨a, p⟩ : ℝ) * ((H ⟨a, p⟩ : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + ‖(FiniteProbabilityWeights.pi (fun j : Input => integerScalarCubeWeights Empty (H j) + (by have := hH j; omega))).complexMean + (fun z => φ (fun j => ((c j + (step j : ℤ) * (z j none : ℤ) : ℤ) : ZMod q)) + (allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => ((c j : ℝ) + (step j : ℝ) * (z j none : ℝ)) / S.value))) - + 𝔼 r : Input → ZMod q, + ∫ y, φ (fun j => (c j : ZMod q) + (step j : ZMod q) * r j) + (allocatedOriginalSampleLiftMap B U basis S lower width sample y) + ∂unitBoxMeasure Input‖ ≤ + (∑ j, (q : ℝ) / H j) + + (2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ j, (q : ℝ) / H j + K * ε) + 2 * η) := by + classical + intro lower width K + let hHpos : ∀ j, 0 < H j := fun j => by have := hH j; omega + let law := FiniteProbabilityWeights.pi (fun j : Input => integerScalarCubeWeights Empty (H j) (hHpos j)) + let residues := FiniteProbabilityWeights.uniform (Input → ZMod q) + let conditioned := fun r : Input → ZMod q => FiniteProbabilityWeights.pi + (fun j : Input => scalarCubeResidueWeights Empty (H j) q (hHpos j) + (fun _ => q) (fun _ => r j) (fun _ => NeZero.pos q) (fun _ => le_rfl) + (by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize j)) + let F := allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) sample + let value := fun (r : Input → ZMod q) (z : ∀ j : Input, IntegerScalarCubeBox Empty (H j)) => + φ (fun j => (c j : ZMod q) + (step j : ZMod q) * r j) + (F (fun j => ((c j : ℝ) + (step j : ℝ) * (z j none : ℝ)) / S.value)) + let reference := fun r : Input → ZMod q => + ∫ y, φ (fun j => (c j : ZMod q) + (step j : ZMod q) * r j) + (allocatedOriginalSampleLiftMap B U basis S lower width sample y) ∂unitBoxMeasure Input + let error := 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ j, (q : ℝ) / H j + K * ε) + 2 * η + have hc (r : Input → ZMod q) : + ‖(conditioned r).complexMean (value r) - reference r‖ ≤ error := by + exact allocatedOriginalSample_sliced_residue_perturbed_riemann B U basis hR hσ S x u + sample hs ht hσbound step H (fun _ => q) c hstep hH hδ hsubset hdense + (fun _ _ => q) (fun j _ => r j) (fun _ _ => NeZero.pos q) (fun _ _ => le_rfl) + hsize hsmall hε hmesh hδone b hη A hA htail (φ _) (hφ _) (hφone _) + have hm := integerScalarCubeWeights_empty_pi_uniform_residue_error_varying + H q hHpos (NeZero.pos q) hsize value (fun r z => hφone _ _) + have hm' : ‖law.complexMean (fun z => value (fun j => ((z j none : ℤ) : ZMod q)) z) - + residues.complexMean (fun r => (conditioned r).complexMean (value r))‖ ≤ + ∑ j, (q : ℝ) / H j := by + simpa only [law, residues, conditioned, FiniteProbabilityWeights.uniform_complexMean] using hm + have ha : ‖residues.complexMean (fun r => (conditioned r).complexMean (value r)) - + residues.complexMean reference‖ ≤ error := + (residues.norm_complexMean_sub_le _ _ (fun _ => error) (fun r _ => hc r)).trans_eq + (residues.mean_const error) + have he := (norm_sub_le_norm_sub_add_norm_sub + (law.complexMean (fun z => value (fun j => ((z j none : ℤ) : ZMod q)) z)) + (residues.complexMean (fun r => (conditioned r).complexMean (value r))) + (residues.complexMean reference)).trans + (add_le_add hm' ha) + simpa only [law, residues, conditioned, value, reference, error, F, + FiniteProbabilityWeights.uniform_complexMean, Int.cast_add, Int.cast_mul, Int.cast_natCast] using he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "Input" => (Σ a : Active, B (Subtype.val a) × Fin (degree (Subtype.val a))) +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short + +variable (x : G → IntegerScalarCubeBox Empty S.value) +variable (u : PrincipalAxisTuples (α := Empty) + (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + +include hR hσ in +theorem allocatedOriginalSample_child_active_residue_comparison (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + {cutoff stride : ℕ} (hcutoff : cutoff ≤ S.value) + (slice : ResidueBoxSlice + (fun k : {k : LayerSamplerVariables G I n B // cutoff ≤ + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U basis S) k} => + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U basis S) k.val) stride) + (hstride : 0 < stride) {cost : ℝ} (hcost : 0 ≤ cost) + (hlarge : 2 * Real.exp cost ≤ (S.value : ℝ)) + (hfraction : ∀ k, Real.exp (-cost) * + ((Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U basis S) k.val : ℕ) : ℝ) ≤ + slice.length k) + (q : ℕ) [NeZero q] (hsize : ∀ j : Input, q ≤ slice.length (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2)) + (hsmall : ∀ j : Input, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / slice.length (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2)) < 1) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : (stride : ℝ) / S.value ≤ ε) + (b : ∀ a : Active, B a.val) + {η : ℝ} (hη : 0 < η) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + (htail : |t| * polynomialMassC2Budget (Fintype.card Input) m 1 ≤ + slicedPrincipalC2Tolerance (Fintype.card Input) (Fintype.card Active) m 1 + (unitProfilePrincipalLowerBound B) (Real.exp (-cost) / 2) A η) + (φ : (Input → ZMod q) → (Output → ℝ) → ℂ) {Kφ : ℝ≥0} + (hφ : ∀ r, LipschitzWith Kφ (φ r)) (hφone : ∀ r y, ‖φ r y‖ ≤ 1) : + let lower := fun (a : Active) (p : B a.val × Fin (degree a.val)) => ((slice.start (allocatedChildNonshortCoordinate B U basis S hcutoff a p.1 p.2) : ℤ) : ℝ) / S.value + let width := fun (a : Active) (p : B a.val × Fin (degree a.val)) => + (stride : ℝ) * ((slice.length (allocatedChildNonshortCoordinate B U basis S hcutoff a p.1 p.2) : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + ‖(FiniteProbabilityWeights.pi (fun j : Input => integerScalarCubeWeights Empty (slice.length (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2)) + (by + have := (allocatedChildSlice_nonshort_geometry B U basis S hcutoff slice hstride hlarge hfraction j.1 j.2.1 j.2.2).1 + omega))).complexMean + (fun z => φ (fun j => (((slice.start (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2) : ℤ) + (stride : ℤ) * (z j none : ℤ) : ℤ) : ZMod q)) + (allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (((slice.start (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2) : ℤ) : ℝ) + (stride : ℝ) * (z j none : ℝ)) / S.value))) - + 𝔼 r : Input → ZMod q, + ∫ y, φ (fun j => ((slice.start (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2) : ℤ) : ZMod q) + (stride : ZMod q) * r j) + (allocatedOriginalSampleLiftMap B U basis S lower width sample y) + ∂unitBoxMeasure Input‖ ≤ + (∑ j : Input, (q : ℝ) / slice.length (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2)) + + (2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ j : Input, (q : ℝ) / slice.length (allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2) + K * ε) + 2 * η) := by + classical + let coord := fun j : Input => allocatedChildNonshortCoordinate B U basis S hcutoff j.1 j.2.1 j.2.2 + let lengths := fun j : Input => slice.length (coord j) + let starts := fun j : Input => (slice.start (coord j) : ℤ) + have hg (j : Input) := allocatedChildSlice_nonshort_geometry B U basis S hcutoff + slice hstride hlarge hfraction j.1 j.2.1 j.2.2 + have hsubset (j : Input) : integerProgressionSupport (starts j) (stride : ℤ) (lengths j) ⊆ + Finset.Ico (0 : ℤ) (S.value : ℤ) := by + simpa only [coord, starts, lengths, allocatedChildNonshortCoordinate_side] using slice.coordinate_progression_subset (coord j) + have hdense (j : Input) : Real.exp (-cost) * (S.value : ℝ) ≤ + ((integerProgressionSupport (starts j) (stride : ℤ) (lengths j)).card : ℝ) := by + rw [card_integerProgressionSupport _ _ _ hstride] + simpa only [coord, starts, lengths, allocatedChildNonshortCoordinate_side] using hfraction (coord j) + exact allocatedOriginalSample_sliced_affine_residue_comparison B U basis hR hσ S x u + sample hs ht hσbound (fun _ => stride) lengths starts (fun _ => hstride) (fun j => (hg j).1) + (Real.exp_pos (-cost)) hsubset hdense q hsize hsmall hε (fun _ => hmesh) + (by exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr hcost)) b hη A hA htail φ hφ hφone + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCoefficientIntegerMarginal.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCoefficientIntegerMarginal.lean new file mode 100644 index 0000000000000000000000000000000000000000..8107bd15b443c0008ed01664595ae9627ae2a300 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCoefficientIntegerMarginal.lean @@ -0,0 +1,205 @@ +import Mathlib.Probability.ProbabilityMassFunction.Integrals +import OAI.Combinatorics.Progressions.Sampling.AllocatedCoefficientSampler + +namespace OAI + +section + +namespace Erdos3 +open MeasureTheory + +theorem mixedScalarArrayLaw_integer_marginal {I Z Q : Type*} + [Fintype I] [Fintype Z] [Fintype Q] + (c w : I → Q → ℝ) (hw : ∀ i q, 0 < w i q) (p : Z → Q → PMF ℤ) : + MeasurePreserving Prod.snd (mixedScalarArrayLaw c w p) + (Measure.pi (fun z => Measure.pi (fun q => (p z q).toMeasure))) := by + let : ∀ i q, IsProbabilityMeasure (affineCoefficientMeasure (c i q) (w i q)) := + fun i q => affineCoefficientMeasure_probability _ (hw i q) + exact measurePreserving_snd + +theorem pmf_bind_pair_toMeasure {X Y : Type*} [Countable X] [Countable Y] + [MeasurableSpace X] [MeasurableSpace Y] + [MeasurableSingletonClass X] [MeasurableSingletonClass Y] + (p : PMF X) (q : PMF Y) : + (p.bind (fun x => q.map (fun y => (x, y)))).toMeasure = p.toMeasure.prod q.toMeasure := by + apply Measure.ext_of_singleton + rintro ⟨x, y⟩ + rw [PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton _), pmf_bind_pair_apply, + ← Set.singleton_prod_singleton, Measure.prod_prod] + rw [PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton _), + PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton _)] + +namespace VectorPolynomial +open Module Submodule +open scoped BigOperators Classical + +abbrev CoefficientIntegerScalarIndex (K : Type*) {m : ℕ} (n : Fin m → ℕ) := + Σ j : Fin m, BoundedCoefficientExponent K (j.val + 1) × Fin (n j) + +def coefficientIntegerScalars {K : Type*} {m : ℕ} {I : Fin m → Type*} {n : Fin m → ℕ} + (a : CoefficientSamplerArrays (K := K) I n) (q : CoefficientIntegerScalarIndex K n) : ℤ := + (a q.1).2 q.2.2 q.2.1 + +theorem coefficientIntegerScalars_measurable {K : Type*} {m : ℕ} + {I : Fin m → Type*} {n : Fin m → ℕ} : + Measurable (coefficientIntegerScalars (K := K) (I := I) (n := n)) := by + apply Measurable.of_eval + intro q + exact (measurable_pi_apply q.2.1).comp + ((measurable_pi_apply q.2.2).comp (measurable_snd.comp (measurable_pi_apply q.1))) + +theorem coefficientIntegerScalars_measurePreserving {K : Type*} [Fintype K] {m : ℕ} + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (c w : ∀ j : Fin m, I j → BoundedCoefficientExponent K (j.val + 1) → ℝ) + (hw : ∀ j i q, 0 < w j i q) + (p : ∀ j : Fin m, Fin (n j) → BoundedCoefficientExponent K (j.val + 1) → PMF ℤ) : + MeasurePreserving coefficientIntegerScalars + (Measure.pi (fun j => mixedScalarArrayLaw (c j) (w j) (p j))) + (Measure.pi (fun q : CoefficientIntegerScalarIndex K n => (p q.1 q.2.2 q.2.1).toMeasure)) := by + let μ := fun q : CoefficientIntegerScalarIndex K n => (p q.1 q.2.2 q.2.1).toMeasure + have hrow (j : Fin m) : MeasurePreserving + (fun a : (I j → BoundedCoefficientExponent K (j.val + 1) → ℝ) × + (Fin (n j) → BoundedCoefficientExponent K (j.val + 1) → ℤ) => + fun q : BoundedCoefficientExponent K (j.val + 1) × Fin (n j) => a.2 q.2 q.1) + (mixedScalarArrayLaw (c j) (w j) (p j)) + (Measure.pi (fun q => μ ⟨j, q⟩)) := by + exact ((finiteArray_uncurry_measurePreserving (fun q i => (p j i q).toMeasure)).comp + (finiteArrayTranspose_measurePreserving (fun i q => (p j i q).toMeasure))).comp + (mixedScalarArrayLaw_integer_marginal (c j) (w j) (hw j) (p j)) + have houter := measurePreserving_pi + (fun j => mixedScalarArrayLaw (c j) (w j) (p j)) + (fun j => Measure.pi (fun q => μ ⟨j, q⟩)) hrow + have hflat : MeasurePreserving + (fun (x : ∀ j : Fin m, BoundedCoefficientExponent K (j.val + 1) × Fin (n j) → ℤ) + (q : CoefficientIntegerScalarIndex K n) => x q.1 q.2) + (Measure.pi (fun j => Measure.pi (fun q => μ ⟨j, q⟩))) (Measure.pi μ) := + ⟨Measurable.of_eval (fun q => (measurable_pi_apply q.2).comp (measurable_pi_apply q.1)), + sigmaProductMeasure_flatten μ⟩ + exact hflat.comp houter + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +noncomputable def allocatedCoefficientIntegerPMF : + PMF (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) := + independentProductPMF (fun q => allocatedLayerIntegerPMFs B U b hR hσ S q.1 q.2.2 q.2.1) + +theorem allocatedCoefficientSource_integer_measurePreserving : + MeasurePreserving coefficientIntegerScalars + (allocatedCoefficientSource B U b hR hσ S) + (allocatedCoefficientIntegerPMF B U b hR hσ S).toMeasure := by + simpa only [allocatedCoefficientSource, allocatedCoefficientIntegerPMF, + independentProductPMF, Measure.toPMF_toMeasure] using + coefficientIntegerScalars_measurePreserving + (allocatedLayerCenters B U b S) (allocatedLayerWidths B U b S) + (allocatedLayerWidths_pos B U b hR hσ S) (allocatedLayerIntegerPMFs B U b hR hσ S) + +theorem allocatedCoefficientSource_integer_map : + (allocatedCoefficientSource B U b hR hσ S).map coefficientIntegerScalars = + (allocatedCoefficientIntegerPMF B U b hR hσ S).toMeasure := + (allocatedCoefficientSource_integer_measurePreserving B U b hR hσ S).map_eq + +theorem allocatedCoefficientSource_integer_prod_measurePreserving + {Deck : Type*} [Countable Deck] [MeasurableSpace Deck] [MeasurableSingletonClass Deck] + (q : PMF Deck) : + MeasurePreserving (Prod.map coefficientIntegerScalars id) + ((allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) + ((allocatedCoefficientIntegerPMF B U b hR hσ S).bind + (fun a => q.map (fun deck => (a, deck)))).toMeasure := by + let : IsProbabilityMeasure (allocatedCoefficientSource B U b hR hσ S) := + allocatedCoefficientSource_probability B U b hR hσ S + rw [pmf_bind_pair_toMeasure] + exact (allocatedCoefficientSource_integer_measurePreserving B U b hR hσ S).prod + (MeasurePreserving.id q.toMeasure) + +theorem allocatedCoefficientSource_integer_prod_integral + {Deck : Type*} [Countable Deck] [MeasurableSpace Deck] [MeasurableSingletonClass Deck] + (q : PMF Deck) + (f : (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) → Deck → ℂ) : + (∫ a, f (coefficientIntegerScalars a.1) a.2 + ∂(allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) = + ∫ a, f a.1 a.2 ∂((allocatedCoefficientIntegerPMF B U b hR hσ S).bind + (fun a => q.map (fun deck => (a, deck)))).toMeasure := by + have hp := allocatedCoefficientSource_integer_prod_measurePreserving B U b hR hσ S q + rw [← hp.map_eq] + exact (integral_map_of_stronglyMeasurable hp.measurable + (measurable_of_countable (fun a => f a.1 a.2)).stronglyMeasurable).symm + +theorem allocatedCoefficientSource_integer_prod_complexMean + {Deck : Type*} [Countable Deck] [MeasurableSpace Deck] [MeasurableSingletonClass Deck] + (q : PMF Deck) + (f : (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) → Deck → ℂ) + {C : ℝ} (hf : ∀ a deck, ‖f a deck‖ ≤ C) : + (∫ a, f (coefficientIntegerScalars a.1) a.2 + ∂(allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) = + ∑' a : (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) × Deck, + (((allocatedCoefficientIntegerPMF B U b hR hσ S a.1).toReal * (q a.2).toReal : ℝ) : ℂ) * + f a.1 a.2 := by + rw [allocatedCoefficientSource_integer_prod_integral] + let p := (allocatedCoefficientIntegerPMF B U b hR hσ S).bind + (fun a => q.map (fun deck => (a, deck))) + have hi : Integrable (fun a => f a.1 a.2) p.toMeasure := + pmf_integrable_of_norm_le p (fun a => f a.1 a.2) (fun a => hf a.1 a.2) + simpa only [p, pmf_bind_pair_apply, ENNReal.toReal_mul, Complex.real_smul] using + PMF.integral_eq_tsum p (fun a => f a.1 a.2) hi + +theorem allocatedCoefficientSource_integer_prod_eventProbability + {Deck : Type*} [Countable Deck] [MeasurableSpace Deck] [MeasurableSingletonClass Deck] + (q : PMF Deck) + (E : (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) → Deck → Prop) : + (((allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) + {a | E (coefficientIntegerScalars a.1) a.2}).toReal = + (((allocatedCoefficientIntegerPMF B U b hR hσ S).bind + (fun a => q.map (fun deck => decide (E a deck)))) true).toReal := by + let p := (allocatedCoefficientIntegerPMF B U b hR hσ S).bind + (fun a => q.map (fun deck => (a, deck))) + let obs := fun a : (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) × Deck => + decide (E a.1 a.2) + have hp := allocatedCoefficientSource_integer_prod_measurePreserving B U b hR hσ S q + have hset : + ((allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) + {a | E (coefficientIntegerScalars a.1) a.2} = p.toMeasure {a | E a.1 a.2} := by + rw [← hp.map_eq, Measure.map_apply hp.measurable (Set.to_countable _).measurableSet] + rfl + have hobs : (p.map obs) true = p.toMeasure {a | E a.1 a.2} := by + rw [← PMF.toMeasure_apply_singleton _ true (measurableSet_singleton _), + ← PMF.toMeasure_map _ _ (measurable_of_countable _), + Measure.map_apply (measurable_of_countable _) (measurableSet_singleton _)] + congr 1 + ext a + simp [obs] + rw [hset, ← hobs] + congr 1 + simp only [p, PMF.map_bind, PMF.map_comp, obs, Function.comp_def] + +theorem allocatedCoefficientSource_integer_prod_indicator + {Deck : Type*} [Countable Deck] [MeasurableSpace Deck] [MeasurableSingletonClass Deck] + (q : PMF Deck) + (E : (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) → Deck → Prop) : + (∫ a, (if E (coefficientIntegerScalars a.1) a.2 then (1 : ℝ) else 0) + ∂(allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) = + (((allocatedCoefficientIntegerPMF B U b hR hσ S).bind + (fun a => q.map (fun deck => decide (E a deck)))) true).toReal := by + have hp := allocatedCoefficientSource_integer_prod_measurePreserving B U b hR hσ S q + have hs : MeasurableSet + {a : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n × Deck | + E (coefficientIntegerScalars a.1) a.2} := + (Set.to_countable {a : (CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) × Deck | + E a.1 a.2}).measurableSet.preimage hp.measurable + calc + _ = (((allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) + {a | E (coefficientIntegerScalars a.1) a.2}).toReal := by + simpa only [Set.indicator, Set.mem_ofPred_eq, Pi.one_apply, Measure.real] using + integral_indicator_one (μ := (allocatedCoefficientSource B U b hR hσ S).prod q.toMeasure) hs + _ = _ := allocatedCoefficientSource_integer_prod_eventProbability B U b hR hσ S q E + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCommonPrimitiveAffine.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCommonPrimitiveAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b217adee13ee7a3ab41928102ab8a8655df0d9e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCommonPrimitiveAffine.lean @@ -0,0 +1,1245 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedCommonKernelLaw +import OAI.Combinatorics.Progressions.Linear.AllocatedConstructedKernelMixture + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S + +def AllocatedAffineGenuineKernelData (Psp E e pNum Pbase Qraw p₁ : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (L : ℝ≥0) (Cc : activeAxes → ℝ) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m p₁ w v) + (allocatedOriginalGeometryLog m Psp p₁ w v (E + 1)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp) (hlarge : Mk ≤ S.value), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (Qsite : ℝ≥0) + (_hQsite : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Qsite) + (Kcap : ℝ≥0) (_hKcap : ∀ j, (R j)⁻¹ ≤ Kcap) (_hσ1 : ∀ j, σ j ≤ 1) + (_hcoverSmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets Cinv j), + ∃ g : (x : GoodKernel) → (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + (∀ a, ((witnesses q r).expansion a).Term) → + Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ x q r k s, LipschitzWith (max (((Fintype.card activeAxes * L) * Qsite) * + (Kcap * ∑ j, C j * Fintype.card (J j)) * commonSitePeriod (witnesses q r).expansion k) + (4 * commonSitePeriod (witnesses q r).expansion k)) (g x q r k s) ∧ + ∀ z, ‖g x q r k s z‖ ≤ 1) ∧ + (∀ (_x : GoodKernel) q r, (∑ k, ‖coverSiteCoefficient (witnesses q r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + (∀ (_x : GoodKernel) q, allocatedResidueCoverCoefficientMass B U b S (q.val : ℕ) (witnesses q) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + ∀ + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((E + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp p₁ w v (E + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + ∀ (_hZ : 1 / 2 ≤ Z), + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedSupportedIdealCoverValue B U b hR hσ S (refined x) (witnesses (index x)) + hb o bW (d x) (g x (index x)) δ x.val poly hmem input r + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +theorem allocatedAffineGenuineKernelData_of_mixture + {Psp E e pNum Pbase Qraw p₁ : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + {L : ℝ≥0} {Cc : activeAxes → ℝ} + (hmixture : AllocatedGenuineKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : + AllocatedAffineGenuineKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc M Dwin hM hDwin η hη := by + unfold AllocatedAffineGenuineKernelData + intro w v Pfinal Mk hMk selection hqDim hcard _ hMkPsp hlarge Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hmixture⟩ := + hmixture hMk selection hqDim hMkPsp + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp Cinv hCinv hchart hsmall + Qsite hQsite Kcap hKcap hσ1 hcoverSmall + obtain ⟨g, hg, hcoeff, hmassCover, hmixture⟩ := hmixture block hb o bW C V hC hV hCp hVp + Cinv hCinv hchart hsmall Qsite hQsite Kcap hKcap hσ1 hcoverSmall + refine ⟨g, hg, hcoeff, hmassCover, ?_⟩ + intro μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z hZ H law + coverValue wholeReference reconstruct weight cover + obtain ⟨hmass, hmixture⟩ := hmixture μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN hsizeN + poly hpoly hmem hrank hRank cells hcells test htest bases hbases hZ + refine ⟨hmass, ?_⟩ + intro window hwindow hDwindow shift moduli residues hmoduli hmoduliM kernelLaw + have hbad := affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hcard) selection hM hDwin hη S.positive hlarge + window hwindow hDwindow shift moduli residues hmoduli hmoduliM + exact hmixture kernelLaw hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S + +def AllocatedAccurateAffineData (Psp E e pNum Pbase Qraw p₁ : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (L : ℝ≥0) (Cc : activeAxes → ℝ) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp) + (hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value) : Prop := + let Epoint := E + 1 + let η := Real.exp (-(E + 1)) + let hη := Real.exp_pos (-(E + 1)) + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m p₁ w v) + (allocatedOriginalGeometryLog m Psp p₁ w v (Epoint + 1)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + , + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (Qsite : ℝ≥0) + (_hQsite : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Qsite) + (Kcap : ℝ≥0) (_hKcap : ∀ j, (R j)⁻¹ ≤ Kcap) (_hσ1 : ∀ j, σ j ≤ 1) + (_hcoverSmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets Cinv j), + ∃ g : (x : GoodKernel) → (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + (∀ a, ((witnesses q r).expansion a).Term) → + Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ x q r k s, LipschitzWith (max (((Fintype.card activeAxes * L) * Qsite) * + (Kcap * ∑ j, C j * Fintype.card (J j)) * commonSitePeriod (witnesses q r).expansion k) + (4 * commonSitePeriod (witnesses q r).expansion k)) (g x q r k s) ∧ + ∀ z, ‖g x q r k s z‖ ≤ 1) ∧ + (∀ (_x : GoodKernel) q r, (∑ k, ‖coverSiteCoefficient (witnesses q r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + (∀ (_x : GoodKernel) q, allocatedResidueCoverCoefficientMass B U b S (q.val : ℕ) (witnesses q) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + ∀ + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((Epoint + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((Epoint + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((Epoint + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp p₁ w v (Epoint + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + ∀ (_hZ : 1 / 2 ≤ Z), + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedSupportedIdealCoverValue B U b hR hσ S (refined x) (witnesses (index x)) + hb o bW (d x) (g x (index x)) δ x.val poly hmem input r + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + +theorem allocatedAccurateAffineData_of_mixture + {Psp E e pNum Pbase Qraw p₁ : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + {L : ℝ≥0} {Cc : activeAxes → ℝ} + (hmixture : AllocatedGenuineKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp (E + 1) e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp) + (hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value) : + AllocatedAccurateAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc M Dwin hM hDwin hMkPsp hlarge := by + have herror : Real.exp (-(E + 1)) + Real.exp (-(E + 1)) ≤ Real.exp (-E) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ = 2 * Real.exp (-(E + 1)) := by ring + _ ≤ Real.exp 1 * Real.exp (-(E + 1)) := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hAffine := allocatedAffineGenuineKernelData_of_mixture B U b hR hσ S hP witnesses hmixture + M Dwin hM hDwin (Real.exp (-(E + 1))) (Real.exp_pos _) + unfold AllocatedAccurateAffineData + intro Epoint η hη w v Pfinal Mk hMk selection hqDim hcard _ Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hAffine⟩ := + hAffine selection hqDim hcard hMkPsp hlarge + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp Cinv hCinv hchart hsmall + Qsite hQsite Kcap hKcap hσ1 hcoverSmall + obtain ⟨g, hg, hcoeff, hmassCover, hAffine⟩ := hAffine block hb o bW C V hC hV hCp hVp + Cinv hCinv hchart hsmall Qsite hQsite Kcap hKcap hσ1 hcoverSmall + refine ⟨g, hg, hcoeff, hmassCover, ?_⟩ + intro μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z hZ H law + coverValue wholeReference reconstruct weight cover + obtain ⟨hmass, hAffine⟩ := hAffine μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN hsizeN + poly hpoly hmem hrank hRank cells hcells test htest bases hbases hZ + refine ⟨hmass, ?_⟩ + intro window hwindow hDwindow shift moduli residues hmoduli hmoduliM kernelLaw + exact (hAffine window hwindow hDwindow shift moduli residues hmoduli hmoduliM).trans herror + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S + +def AllocatedNormalizedAffineData (Psp E e pNum Pbase Qraw p₁ : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (L : ℝ≥0) (Cc : activeAxes → ℝ) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp) + (hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value) : Prop := + let Epoint := E + 1 + let η := Real.exp (-(E + 1)) + let hη := Real.exp_pos (-(E + 1)) + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m p₁ w v) + (allocatedOriginalGeometryLog m Psp p₁ w v (Epoint + 1)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + , + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (Qsite : ℝ≥0) + (_hQsite : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Qsite) + (Kcap : ℝ≥0) (_hKcap : ∀ j, (R j)⁻¹ ≤ Kcap) (_hσ1 : ∀ j, σ j ≤ 1) + (_hcoverSmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets Cinv j), + ∃ g : (x : GoodKernel) → (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + (∀ a, ((witnesses q r).expansion a).Term) → + Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ x q r k s, LipschitzWith (max (((Fintype.card activeAxes * L) * Qsite) * + (Kcap * ∑ j, C j * Fintype.card (J j)) * commonSitePeriod (witnesses q r).expansion k) + (4 * commonSitePeriod (witnesses q r).expansion k)) (g x q r k s) ∧ + ∀ z, ‖g x q r k s z‖ ≤ 1) ∧ + (∀ (_x : GoodKernel) q r, (∑ k, ‖coverSiteCoefficient (witnesses q r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + (∀ (_x : GoodKernel) q, allocatedResidueCoverCoefficientMass B U b S (q.val : ℕ) (witnesses q) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + ∀ + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((Epoint + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((Epoint + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((Epoint + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp p₁ w v (Epoint + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedSupportedIdealCoverValue B U b hR hσ S (refined x) (witnesses (index x)) + hb o bW (d x) (g x (index x)) δ x.val poly hmem input r + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + +theorem allocatedAccurateAffineData_normalized + {Psp E e pNum Pbase p₁ l F : ℝ} (hP : 0 ≤ Psp) (hE : 0 ≤ E) + (hPbase : Psp ≤ Pbase) (hpNum : pNum ≤ Pbase) + (hm : ((m + 1 : ℕ) : ℝ) ≤ Psp) (hdim : ((dim + 1 : ℕ) : ℝ) ≤ Psp) + (hG : (Fintype.card G : ℝ) ≤ Psp) (hl : Pbase ≤ l) (hF : 0 ≤ F) + (hnum : ∀ (_o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C V : Fin m → ℝ≥0), (∀ j, (C j : ℝ) ≤ Real.exp pNum) → + (∀ j, (V j : ℝ) ≤ Real.exp pNum) → AllocatedSourceNumerics B U b S C V Pbase) + {δ : ℝ≥0} {A Kraw Ksite Knorm : ℕ} + (hKraw : 1 ≤ Kraw) (hKsite : 1 ≤ Ksite) (hKnorm : 1 ≤ Knorm) + (hnorm : AllocatedSourceNarrowNormalization.{uG,uI,uB,uJ,uX} m Knorm) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + {L : ℝ≥0} {Cc : activeAxes → ℝ} + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp) + (hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value) : + let Qraw := allocatedSourceSamplingBudget m dim A Pbase ((E + 1) + 1) l F + AllocatedAccurateAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc + M Dwin hM hDwin hMkPsp hlarge → + AllocatedNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw (max Ksite Knorm) witnesses L Cc + M Dwin hM hDwin hMkPsp hlarge := by + intro Qraw hAffine + have hPbase0 : 0 ≤ Pbase := hP.trans hPbase + have hEsource : 0 ≤ (E + 1) + 1 := by linarith + have hQraw1 : 1 ≤ Qraw := + (allocatedSourceSamplingBudget_bounds m dim A hPbase0 hEsource (hPbase0.trans hl) hF).1 + have hQraw0 : 0 ≤ Qraw := zero_le_one.trans hQraw1 + unfold AllocatedNormalizedAffineData + intro Epoint η hη w v Pfinal Mk hMk selection hqDim hcard _ Kernel Good GoodKernel + have hFinal := sourceCoverParameter_bounds dim Kraw (pNum := pNum) (Qraw := Qraw) + (F := allocatedSiteErrorFourierOutput m p₁ w v) + (G := allocatedOriginalGeometryLog m Psp p₁ w v (Epoint + 1)) hP + have hFinal0 : 0 ≤ Pfinal := zero_le_one.trans hFinal.1 + have hRawPower : Qraw ≤ (Qraw + Kraw) ^ Kraw := by + have h := shifted_power_self_mono hQraw0 (le_refl 1) hKraw + simp only [Nat.cast_one, pow_one] at h + linarith + have hRawFinal : Qraw ≤ Pfinal := hRawPower.trans hFinal.2.2.2.2.1 + have hOldCut : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ + Real.exp ((Pfinal + (max Ksite Knorm : ℕ)) ^ max Ksite Knorm) := + Real.exp_le_exp.mpr (shifted_power_self_mono hFinal0 hKsite (le_max_left _ _)) + have hNormCut : Real.exp ((Qraw + Knorm) ^ Knorm) ≤ + Real.exp ((Pfinal + (max Ksite Knorm : ℕ)) ^ max Ksite Knorm) := by + apply Real.exp_le_exp.mpr + exact (pow_le_pow_left₀ (add_nonneg hQraw0 (Nat.cast_nonneg _)) + (add_le_add hRawFinal le_rfl) Knorm).trans + (shifted_power_self_mono hFinal0 hKnorm (le_max_right _ _)) + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hAffine⟩ := + hAffine selection hqDim hcard + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp Cinv hCinv hchart hsmall + Qsite hQsite Kcap hKcap hσ1 hcoverSmall + obtain ⟨g, hg, hcoeff, hmassCover, hAffine⟩ := hAffine block hb o bW C V hC hV hCp hVp + Cinv hCinv hchart hsmall Qsite hQsite Kcap hKcap hσ1 hcoverSmall + refine ⟨g, hg, hcoeff, hmassCover, ?_⟩ + intro μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z H law + coverValue wholeReference reconstruct weight cover + obtain ⟨_, hnormal⟩ := hnorm B U b S hb o μ ν hR hσ hσ1 C V hC hV Cinv hCinv hchart + hsmall A (hnum o C V hCp hVp) hP hEsource hPbase hm hdim hG hl hF + hXPsp selection hMk hMkPsp q hq hqPsp hτ (hτP.trans (Real.exp_le_exp.mpr hpNum)) + N (fun t => hNormCut.trans (hsizeN t)) poly hpoly hmem hrank (hNormCut.trans hRank) cells hcells + have hZ := hnormal bases hbases + obtain ⟨hmass, hAffine⟩ := hAffine μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN + (fun t => hOldCut.trans (hsizeN t)) poly hpoly hmem hrank (hOldCut.trans hRank) + cells hcells test htest bases hbases hZ.2.1.1 + exact ⟨hmass, hZ, hAffine⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S + +def AllocatedPrimitiveAffineData (p c Psp E e pNum Pbase Qraw p₁ : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Ksize : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (L : ℝ≥0) (Cc : activeAxes → ℝ) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp) + (hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value) : Prop := + let Epoint := E + 1 + let η := Real.exp (-(E + 1)) + let hη := Real.exp_pos (-(E + 1)) + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let sizeLog := (p + c + Psp + E + Ksize) ^ Ksize + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + , + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hCinvP : ∀ j, Cinv j ≤ Real.exp p) + (Qsite : ℝ≥0) + (_hQsite : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Qsite) + (Kcap : ℝ≥0) (_hKcap : ∀ j, (R j)⁻¹ ≤ Kcap) (_hσ1 : ∀ j, σ j ≤ 1), + ∃ g : (x : GoodKernel) → (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + (∀ a, ((witnesses q r).expansion a).Term) → + Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ x q r k s, LipschitzWith (max (((Fintype.card activeAxes * L) * Qsite) * + (Kcap * ∑ j, C j * Fintype.card (J j)) * commonSitePeriod (witnesses q r).expansion k) + (4 * commonSitePeriod (witnesses q r).expansion k)) (g x q r k s) ∧ + ∀ z, ‖g x q r k s z‖ ≤ 1) ∧ + (∀ (_x : GoodKernel) q r, (∑ k, ‖coverSiteCoefficient (witnesses q r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + (∀ (_x : GoodKernel) q, allocatedResidueCoverCoefficientMass B U b S (q.val : ℕ) (witnesses q) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + ∀ + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((Epoint + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((Epoint + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((Epoint + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp p₁ w v (Epoint + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp sizeLog ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp sizeLog ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedSupportedIdealCoverValue B U b hR hσ S (refined x) (witnesses (index x)) + hb o bW (d x) (g x (index x)) δ x.val poly hmem input r + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + +theorem allocatedNormalizedAffineData_primitive + {p c Psp E e pNum Pbase Qraw p₁ : ℝ} (hp : 0 ≤ p) (hP : 0 ≤ Psp) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + (hRsmall : ∀ j, R j ≤ allocatedSourceCoverRadius m p p) + {δ : ℝ≥0} {A Kraw Ksite Ksize : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + {L : ℝ≥0} {Cc : activeAxes → ℝ} + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp) + (hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value) : + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m p₁ w v) + (allocatedOriginalGeometryLog m Psp p₁ w v ((E + 1) + 1)) + (Pfinal + Ksite) ^ Ksite ≤ (p + c + Psp + E + Ksize) ^ Ksize → + AllocatedNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc + M Dwin hM hDwin hMkPsp hlarge → + AllocatedPrimitiveAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S p c Psp E e pNum Pbase Qraw p₁ hP δ A Ksize witnesses L Cc + M Dwin hM hDwin hMkPsp hlarge := by + intro w v Pfinal hcut hSource + have hCut := Real.exp_le_exp.mpr hcut + unfold AllocatedPrimitiveAffineData + intro Epoint η hη w' v' sizeLog Mk hMk selection hqDim hcard _ Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hSource⟩ := + hSource selection hqDim hcard + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp Cinv hCinv hchart hCinvP + Qsite hQsite Kcap hKcap hσ1 + have hcharts := fun j => allocatedSourceCoverRadius_le_charts B rowSets hp hp + (by simpa only [Fintype.card_fin] using hqDim) hvars hI hn Cinv hCinv hCinvP j + have hsmall := fun j => (hRsmall j).trans (hcharts j).1 + have hcoverSmall := fun j => (hRsmall j).trans (hcharts j).2 + obtain ⟨g, hg, hcoeff, hmassCover, hSource⟩ := hSource block hb o bW C V hC hV hCp hVp + Cinv hCinv hchart hsmall Qsite hQsite Kcap hKcap hσ1 hcoverSmall + refine ⟨g, hg, hcoeff, hmassCover, ?_⟩ + intro μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z H law + coverValue wholeReference reconstruct weight cover + exact hSource μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN + (fun t => hCut.trans (hsizeN t)) poly hpoly hmem hrank (hCut.trans hRank) + cells hcells test htest bases hbases + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +universe uG uI uB uJ uQ uX + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped ContDiff BigOperators Classical NNReal + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) + +local notation "hLayer" => layerSamplerDegree I n + +def AllocatedCommonAccurateAffineAt (p Psp E e t : ℝ) (hP : 0 ≤ Psp) (δ : ℝ≥0) + (A T Kproj Kideal Ksite : ℕ) : Prop := + let Epoint := E + 1 + ∀ {c : ℝ}, 0 ≤ c → + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j), + (∀ j, σ j ≤ t) → (∀ j, R j ≤ 1) → + (∀ j, (R j)⁻¹ ≤ Real.exp c) → (∀ j, (σ j)⁻¹ ≤ Real.exp c) → + let Eraw := Epoint + 1 + 4 + let Esite := allocatedOriginalCoverAccuracy Psp (Epoint + 1) + let D := allocatedComparisonDimension m p + let pNum := allocatedCommonScaleNumeric m p c Psp Eraw + let S := allocatedCommonScale (G := G) B U b hR hσ p c Psp e Eraw + let p₁ := allocatedCommonRefinedSourceLog m p c Psp e Eraw Esite + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let error := allocatedReferenceIdealError m D Psp Eraw + let lengthLog := allocatedIdealScaleLog m D pNum e w error + let gainLog := allocatedProfileGainLog m D Psp w + let Pbase := allocatedIdealSourceBudget m D pNum e w error + let lateLog := allocatedSpatialLateLog (G := G) B Pbase Pbase + let F := allocatedProfileFourierOutput (allocatedActualProfileInput m D pNum e gainLog lengthLog) + let Λ := allocatedSiteSpectrumLog m p₁ w v Esite + let L : ℝ≥0 := NNReal.mk (Real.exp (1 + 6 * Λ + 12)) (Real.exp_nonneg _) + 4 + let Cc := fun a : {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} => + allocatedGridPointCap B (canonicalScalarSourceEnvelope m (allocatedRefinedPeriodCutoff m Psp)) + (allocatedGridIntegerAxis B U b S a.val) + (rowSets (allocatedGridIntegerAxis B U b S a.val).1) * + Real.exp (Fintype.card (Finset (Fin dim)) * (4 * Λ + 8) + Λ) + ∃ witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val, + AllocatedPointwiseResidueCoverFamily.{uG,uI,uB,uJ,uQ,uX,0} + B U b hR hσ S (fun q : AllocatedRefinedPeriodIndex m Psp => (q.val : ℕ)) witnesses L Cc ∧ + ∀ (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (Tker : ℝ) (_hTker : 0 ≤ Tker) + (_hbudget : allocatedKernelPrimitiveBudget p E Tker ≤ Psp) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (_hMT : (M : ℝ) ≤ Real.exp Tker) (_hDwinP : (Dwin : ℝ) ≤ Real.exp p), + ∃ hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp, + ∃ hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value, + AllocatedAccurateAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase (allocatedSourceSamplingBudget m dim A Pbase (Epoint + 1) lateLog F) + p₁ hP δ A (max T (max Kproj Kideal)) Ksite witnesses L Cc M Dwin hM hDwin hMkPsp hlarge + +theorem allocatedCommonGenuineKernelAt_accurate_affine + {p P E e t : ℝ} (hp : 0 ≤ p) (hP : 0 ≤ P) (hE : 0 ≤ E) (he : 0 ≤ e) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + {δ : ℝ≥0} {A T Kproj Kideal Ksite : ℕ} + (hkernel : AllocatedCommonGenuineKernelAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P (E + 1) e t hP δ A T Kproj Kideal Ksite) : + AllocatedCommonAccurateAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A T Kproj Kideal Ksite := by + unfold AllocatedCommonAccurateAffineAt + intro Epoint c hc J _ U b R σ hR hσ hσt hR1 hRi hσi + obtain ⟨witnesses, hFamily, hData⟩ := hkernel hc U b hR hσ hσt hR1 hRi hσi + refine ⟨witnesses, hFamily, ?_⟩ + intro hcard _ Tker hTker hbudget M Dwin hM hDwin hMT hDwinP + have hG : (Fintype.card G : ℝ) ≤ p := + (Nat.cast_le.mpr (allocatedKernelVariables_card_le_variables (G := G) B)).trans hvars + have hdimNat : dim ≤ Fintype.card G := + (show dim ≤ dim * (dim + 2) by nlinarith).trans hcard + have hdim : (dim : ℝ) ≤ p := (Nat.cast_le.mpr hdimNat).trans hG + have hcut := allocatedCommonScale_kernel_cutoff (dim := dim) B U b hR hσ + hp hc hP he (show 0 ≤ (E + 1) + 1 + 4 by linarith) hE hTker hdim hG hbudget + hM hDwin hMT hDwinP + refine ⟨hcut.2.1, hcut.2.2, ?_⟩ + exact allocatedAccurateAffineData_of_mixture B U b hR hσ _ hP witnesses hData + M Dwin hM hDwin hcut.2.1 hcut.2.2 + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +universe uG uI uB uJ uQ uX + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped ContDiff BigOperators Classical NNReal + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) + +local notation "hLayer" => layerSamplerDegree I n + +def AllocatedCommonNormalizedAffineAt (p Psp E e t : ℝ) (hP : 0 ≤ Psp) (δ : ℝ≥0) + (A T Kproj Kideal Ksite : ℕ) : Prop := + let Epoint := E + 1 + ∀ {c : ℝ}, 0 ≤ c → + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j), + (∀ j, σ j ≤ t) → (∀ j, R j ≤ 1) → + (∀ j, (R j)⁻¹ ≤ Real.exp c) → (∀ j, (σ j)⁻¹ ≤ Real.exp c) → + let Eraw := Epoint + 1 + 4 + let Esite := allocatedOriginalCoverAccuracy Psp (Epoint + 1) + let D := allocatedComparisonDimension m p + let pNum := allocatedCommonScaleNumeric m p c Psp Eraw + let S := allocatedCommonScale (G := G) B U b hR hσ p c Psp e Eraw + let p₁ := allocatedCommonRefinedSourceLog m p c Psp e Eraw Esite + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let error := allocatedReferenceIdealError m D Psp Eraw + let lengthLog := allocatedIdealScaleLog m D pNum e w error + let gainLog := allocatedProfileGainLog m D Psp w + let Pbase := allocatedIdealSourceBudget m D pNum e w error + let lateLog := allocatedSpatialLateLog (G := G) B Pbase Pbase + let F := allocatedProfileFourierOutput (allocatedActualProfileInput m D pNum e gainLog lengthLog) + let Λ := allocatedSiteSpectrumLog m p₁ w v Esite + let L : ℝ≥0 := NNReal.mk (Real.exp (1 + 6 * Λ + 12)) (Real.exp_nonneg _) + 4 + let Cc := fun a : {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} => + allocatedGridPointCap B (canonicalScalarSourceEnvelope m (allocatedRefinedPeriodCutoff m Psp)) + (allocatedGridIntegerAxis B U b S a.val) + (rowSets (allocatedGridIntegerAxis B U b S a.val).1) * + Real.exp (Fintype.card (Finset (Fin dim)) * (4 * Λ + 8) + Λ) + ∃ witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val, + AllocatedPointwiseResidueCoverFamily.{uG,uI,uB,uJ,uQ,uX,0} + B U b hR hσ S (fun q : AllocatedRefinedPeriodIndex m Psp => (q.val : ℕ)) witnesses L Cc ∧ + ∀ (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (Tker : ℝ) (_hTker : 0 ≤ Tker) + (_hbudget : allocatedKernelPrimitiveBudget p E Tker ≤ Psp) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (_hMT : (M : ℝ) ≤ Real.exp Tker) (_hDwinP : (Dwin : ℝ) ≤ Real.exp p), + ∃ hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp, + ∃ hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value, + AllocatedNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase (allocatedSourceSamplingBudget m dim A Pbase (Epoint + 1) lateLog F) + p₁ hP δ A (max T (max Kproj Kideal)) Ksite witnesses L Cc M Dwin hM hDwin hMkPsp hlarge + +theorem allocatedCommonAccurateAffineAt_normalized + {p P E e t : ℝ} (hp : 0 ≤ p) (hP : 0 ≤ P) (hE : 0 ≤ E) (he : 0 ≤ e) + (hdim : dim ≤ m + 1) (hmP : ((m + 2 : ℕ) : ℝ) ≤ P) (hpP : p ≤ P) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + {δ : ℝ≥0} {A T Kproj Kideal Ksite Knorm : ℕ} + (hT : 1 ≤ T) (hKsite : 1 ≤ Ksite) (hKnorm : 1 ≤ Knorm) + (hnorm : AllocatedSourceNarrowNormalization.{uG,uI,uB,uJ,uX} m Knorm) + (hcover : AllocatedCommonAccurateAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A T Kproj Kideal Ksite) : + AllocatedCommonNormalizedAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A T Kproj Kideal (max Ksite Knorm) := by + unfold AllocatedCommonNormalizedAffineAt + intro Epoint c hc J _ U b R σ hR hσ hσt hR1 hRi hσi + Eraw Esite D pNum S p₁ w v error lengthLog gainLog Pbase lateLog F Λ L Cc + have hdimensions : AllocatedComparisonDimensions (G := G) B (Fin dim) jets D := + allocatedComparisonDimensions_of_primitive B + (fun j => (Subtype.val : jets j → Finset (Fin dim))) + (by simpa only [Fintype.card_fin] using hdim) + (fun _ => Subtype.val_injective) hp hvars hI hn + have hEraw : 0 ≤ Eraw := by dsimp only [Eraw, Epoint]; linarith + obtain ⟨hNum, _, hcNum, hPNum, _⟩ := allocatedCommonScaleNumeric_bounds m hp hc hP hEraw + have hw : 0 ≤ w := allocatedSiteKernelMaskLog_nonneg m hP + have herror : 0 ≤ error := allocatedReferenceIdealError_nonneg m hdimensions.nonneg hP hEraw + have hgain : 0 ≤ gainLog := allocatedProfileGainLog_nonneg m hdimensions.nonneg hP hw + have hlength : 0 ≤ lengthLog := by + have h := allocatedIdealScaleInput_bounds m hdimensions.nonneg hNum he hw herror + exact h.2.1.trans h.2.2.2.2.2 + have hF : 0 ≤ F := allocatedActualProfileFourier_nonneg m hdimensions.nonneg hNum he hgain hlength + obtain ⟨hBase1, _, hNumBase, _, _⟩ := + allocatedIdealSourceBudget_bounds m hdimensions.nonneg hNum he hw herror + have hBase0 : 0 ≤ Pbase := zero_le_one.trans hBase1 + have hPBase : P ≤ Pbase := hPNum.trans hNumBase + have hlate : Pbase ≤ lateLog := by + have hcap : 0 ≤ (Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) : ℝ) * + allocatedAmbientLog m Pbase := mul_nonneg (Nat.cast_nonneg _) (allocatedAmbientLog_nonneg m hBase0) + dsimp only [lateLog, allocatedSpatialLateLog] + linarith + have hnum : ∀ (_o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C V : Fin m → ℝ≥0), (∀ j, (C j : ℝ) ≤ Real.exp pNum) → + (∀ j, (V j : ℝ) ≤ Real.exp pNum) → AllocatedSourceNumerics B U b S C V Pbase := by + intro o C V hCp hVp + exact allocatedIdealSource_numerics B U b o hdimensions hNum he hw herror hR hσ + (fun j => (hRi j).trans (Real.exp_le_exp.mpr hcNum)) + (fun j => (hσi j).trans (Real.exp_le_exp.mpr hcNum)) C V hCp hVp + have hmNorm : ((m + 1 : ℕ) : ℝ) ≤ P := + (Nat.cast_le.mpr (show m + 1 ≤ m + 2 by omega)).trans hmP + have hdimNorm : ((dim + 1 : ℕ) : ℝ) ≤ P := + (Nat.cast_le.mpr (show dim + 1 ≤ m + 2 by omega)).trans hmP + have hG : (Fintype.card G : ℝ) ≤ P := + (Nat.cast_le.mpr (allocatedKernelVariables_card_le_variables (G := G) B)).trans (hvars.trans hpP) + obtain ⟨witnesses, hFamily, hData⟩ := hcover hc U b hR hσ hσt hR1 hRi hσi + refine ⟨witnesses, hFamily, ?_⟩ + intro hcard _ Tker hTker hbudget M Dwin hM hDwin hMT hDwinP + obtain ⟨hMkP, hlarge, hAffine⟩ := hData hcard Tker hTker hbudget M Dwin hM hDwin hMT hDwinP + refine ⟨hMkP, hlarge, ?_⟩ + exact allocatedAccurateAffineData_normalized B U b hR hσ S hP hE hPBase hNumBase + hmNorm hdimNorm hG hlate hF hnum (hT.trans (le_max_left _ _)) hKsite hKnorm hnorm + witnesses M Dwin hM hDwin hMkP hlarge hAffine + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +universe uG uI uB uJ uQ uX + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped ContDiff BigOperators Classical NNReal + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) + +local notation "hLayer" => layerSamplerDegree I n + +def AllocatedCommonPrimitiveAffineAt (p Psp E e t : ℝ) (hP : 0 ≤ Psp) (δ : ℝ≥0) + (A Ksize : ℕ) : Prop := + let Epoint := E + 1 + ∀ {c : ℝ}, 0 ≤ c → + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j), + (∀ j, σ j ≤ t) → (∀ j, R j ≤ allocatedSourceCoverRadius m p p) → + (∀ j, (R j)⁻¹ ≤ Real.exp c) → (∀ j, (σ j)⁻¹ ≤ Real.exp c) → + let Eraw := Epoint + 1 + 4 + let Esite := allocatedOriginalCoverAccuracy Psp (Epoint + 1) + let D := allocatedComparisonDimension m p + let pNum := allocatedCommonScaleNumeric m p c Psp Eraw + let S := allocatedCommonScale (G := G) B U b hR hσ p c Psp e Eraw + let p₁ := allocatedCommonRefinedSourceLog m p c Psp e Eraw Esite + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let error := allocatedReferenceIdealError m D Psp Eraw + let lengthLog := allocatedIdealScaleLog m D pNum e w error + let gainLog := allocatedProfileGainLog m D Psp w + let Pbase := allocatedIdealSourceBudget m D pNum e w error + let lateLog := allocatedSpatialLateLog (G := G) B Pbase Pbase + let F := allocatedProfileFourierOutput (allocatedActualProfileInput m D pNum e gainLog lengthLog) + let Λ := allocatedSiteSpectrumLog m p₁ w v Esite + let L : ℝ≥0 := NNReal.mk (Real.exp (1 + 6 * Λ + 12)) (Real.exp_nonneg _) + 4 + let Cc := fun a : {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} => + allocatedGridPointCap B (canonicalScalarSourceEnvelope m (allocatedRefinedPeriodCutoff m Psp)) + (allocatedGridIntegerAxis B U b S a.val) + (rowSets (allocatedGridIntegerAxis B U b S a.val).1) * + Real.exp (Fintype.card (Finset (Fin dim)) * (4 * Λ + 8) + Λ) + ∃ witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val, + AllocatedPointwiseResidueCoverFamily.{uG,uI,uB,uJ,uQ,uX,0} + B U b hR hσ S (fun q : AllocatedRefinedPeriodIndex m Psp => (q.val : ℕ)) witnesses L Cc ∧ + ∀ (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (Tker : ℝ) (_hTker : 0 ≤ Tker) + (_hbudget : allocatedKernelPrimitiveBudget p E Tker ≤ Psp) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (_hMT : (M : ℝ) ≤ Real.exp Tker) (_hDwinP : (Dwin : ℝ) ≤ Real.exp p), + ∃ hMkPsp : (scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) : ℝ) ≤ Real.exp Psp, + ∃ hlarge : scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(E + 1))) ≤ S.value, + AllocatedPrimitiveAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S p c Psp E e pNum Pbase (allocatedSourceSamplingBudget m dim A Pbase (Epoint + 1) lateLog F) + p₁ hP δ A Ksize witnesses L Cc M Dwin hM hDwin hMkPsp hlarge + +theorem allocatedCommonNormalizedAffineAt_primitive + {p P E e t : ℝ} (hp : 0 ≤ p) (hP : 0 ≤ P) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + {δ : ℝ≥0} {A T Kproj Kideal Ksite Ksize : ℕ} + (hsize : ∀ {c : ℝ}, 0 ≤ c → + (allocatedCommonCoverParameter (G := G) B dim A (max T (max Kproj Kideal)) p c P e (E + 1) + + Ksite) ^ Ksite ≤ (p + c + P + E + Ksize) ^ Ksize) + (hsource : AllocatedCommonNormalizedAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A T Kproj Kideal Ksite) : + AllocatedCommonPrimitiveAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A Ksize := by + unfold AllocatedCommonPrimitiveAffineAt + intro Epoint c hc J _ U b R σ hR hσ hσt hRsmall hRi hσi + have hR1 := fun j => (hRsmall j).trans (allocatedSourceCoverRadius_bounds (m := m) hp hp).2.2.1 + obtain ⟨witnesses, hFamily, hData⟩ := hsource hc U b hR hσ hσt hR1 hRi hσi + refine ⟨witnesses, hFamily, ?_⟩ + intro hcard _ Tker hTker hbudget M Dwin hM hDwin hMT hDwinP + obtain ⟨hMkP, hlarge, hData⟩ := hData hcard Tker hTker hbudget M Dwin hM hDwin hMT hDwinP + refine ⟨hMkP, hlarge, ?_⟩ + exact allocatedNormalizedAffineData_primitive B U b hR hσ _ hp hP hvars hI hn hRsmall + witnesses M Dwin hM hDwin hMkP hlarge (hsize hc) hData + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCommonResidueMask.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCommonResidueMask.lean new file mode 100644 index 0000000000000000000000000000000000000000..db8c72060b93501cacb907c47108ba7b06d1bb6d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCommonResidueMask.lean @@ -0,0 +1,82 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedNormalizedSiteTwist + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {n : Fin m → ℕ} {E : Fin m → Type*} + +noncomputable def mixedSiteResidueReduction {period M : ℕ} (h : period ∣ M) + (w : (∀ j, Fin (n j) → ZMod M) × (∀ j, E j → ZMod M)) : + (∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period) := + (fun j i => ZMod.castHom h (ZMod period) (w.1 j i), + fun j i => ZMod.castHom h (ZMod period) (w.2 j i)) + +theorem mixedSiteResidueReduction_cast {I : Fin m → Type*} (d period M : ℕ) (h : period ∣ M) + (w : MixedCoveredJetSource I (fun _ => Unit) E n d) : + mixedSiteResidueReduction h (mixedCoveredSiteResidue d M w) = mixedCoveredSiteResidue d period w := by + simp only [mixedSiteResidueReduction, mixedCoveredSiteResidue, map_intCast, map_natCast] + +variable {A V : Type*} (e : A → ScalarSiteExpansion V) (k : ∀ a, (e a).Term) +variable (selected : A → Σ j : Fin m, Fin (n j)) + +noncomputable def mixedSiteGridResidue {M : ℕ} (h : ∀ a, (e a).period (k a) ∣ M) + (w : (∀ j, Fin (n j) → ZMod M) × (∀ j, E j → ZMod M)) : ∀ a, ZMod ((e a).period (k a)) := + fun a => ZMod.castHom (h a) (ZMod ((e a).period (k a))) (w.1 (selected a).1 (selected a).2) + +theorem mixedSiteGridResidue_cast {I : Fin m → Type*} (d M : ℕ) + (h : ∀ a, (e a).period (k a) ∣ M) + (w : MixedCoveredJetSource I (fun _ => Unit) E n d) : + mixedSiteGridResidue e k selected h (mixedCoveredSiteResidue d M w) = + fun a => ((w.1 (selected a).1).2 (selected a).2 () : ZMod ((e a).period (k a))) := by + funext a + change ZMod.castHom (h a) (ZMod ((e a).period (k a))) + (((w.1 (selected a).1).2 (selected a).2 () : ℤ) : ZMod M) = _ + exact map_intCast _ _ + +variable {K X α : Type*} [Fintype K] [Fintype X] [Fintype α] +variable (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) +variable (residue : Option K × X → ℤ) (q : X → ℕ) +variable (b : ℝ) (r : ℝ≥0) {spatialPeriod period M : ℕ} +variable (hs : ∀ x, q x * spatialPeriod ∣ M) +variable (hg : ∀ a, (e a).period (k a) ∣ M) (hi : period ∣ M) +variable (t : X → SpatialSiteLabel α spatialPeriod b r) (s : Finset α) +variable (label : (∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) +variable (gridLabel : ∀ a, ZMod ((e a).period (k a))) + +variable [DecidableEq (∀ a, ZMod ((e a).period (k a)))] + +noncomputable def allocatedCommonResidueMask (u : X → ZMod M) + (w : (∀ j, Fin (n j) → ZMod M) × (∀ j, E j → ZMod M)) : ℂ := + (physicalResidueSpatialMaskMod root D base residue q b r hs t s u * + (if mixedSiteResidueReduction hi w = label then (1 : ℂ) else 0)) * + (if mixedSiteGridResidue e k selected hg w = gridLabel then (1 : ℂ) else 0) + +theorem allocatedCommonResidueMask_eval {I : Fin m → Type*} (d : ℕ) + (u : X → ℤ) (w : MixedCoveredJetSource I (fun _ => Unit) E n d) : + allocatedCommonResidueMask e k selected root D base residue q b r hs hg hi t s label gridLabel + (fun x => (u x : ZMod M)) (mixedCoveredSiteResidue d M w) = + (physicalResidueSpatialMask root D base residue q b r t s u * + (if mixedCoveredSiteResidue d period w = label then (1 : ℂ) else 0)) * + (if (fun a => ((w.1 (selected a).1).2 (selected a).2 () : ZMod ((e a).period (k a)))) = gridLabel + then (1 : ℂ) else 0) := by + simp only [allocatedCommonResidueMask, physicalResidueSpatialMaskMod_eval, + mixedSiteResidueReduction_cast, mixedSiteGridResidue_cast] + +theorem allocatedCommonResidueMask_norm (u : X → ZMod M) + (w : (∀ j, Fin (n j) → ZMod M) × (∀ j, E j → ZMod M)) : + ‖allocatedCommonResidueMask e k selected root D base residue q b r hs hg hi t s label gridLabel u w‖ ≤ 1 := by + unfold allocatedCommonResidueMask + split_ifs <;> simp only [mul_one, mul_zero, norm_zero, zero_le_one] + exact physicalResidueSpatialMaskMod_norm root D base residue q b r hs t s u + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCoveredResidueComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCoveredResidueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..24dcaffcff4da8a9ab105a43cc558317d25ea929 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedCoveredResidueComparison.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedSlicedCoveredComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) + (allocatedPrincipalSides B U b S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (Q : Fin m → Type*) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable (hσ1 : ∀ j, σ j ≤ 1) +variable (period : ℕ) (hp : 0 < period) +variable (hperiod : ∀ j, integerScalarLattice (O j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) +variable (r : PrincipalTupleIndex + (fun a : {a // ¬allocatedGridAxis (I := I) U b S.value a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod period) +variable (hsize : ∀ j, (Fintype.card α + 1) * period ≤ + principalAxisLength (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S) j) +variable (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod period)) + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "weights" => allocatedLongResidueWeights B U b S period hp r hsize +local notation "source" => allocatedCoefficientSource B U b hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U b hR hσ S +local notation "reference" => allocatedLongJetReference B U b S O +local notation "density" => (fun v z => allocatedLongJetDensity B U b hR hσ S x u v rows s hA hσ1 z) +local notation "scale" => (∏ a, allocatedLongJetOutputScale B U b S (O := O) a) +local notation "proxy" => allocatedLongJetProxy B U b S x u rows s hA period residue +local notation "root" v => allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u v) +local notation "dirs" v => allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u v) +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +include hperiod + +theorem exists_allocatedPhysicalCovered_residue_comparison + {M : ℕ} (hM : 0 < M) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) + {P : ℝ} (hP : 0 ≤ P) (hMP : (M : ℝ) ≤ Real.exp P) + (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + + 1 ≤ Real.exp P) + {ε : ℝ} (hε : 0 ≤ ε) (he : ∀ z, |(weights).mean (fun v => scale * density v z) - proxy z| ≤ ε) : + ∃ v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides, + principalResidueLabel period v₀ = r ∧ + ∀ F : AllocatedFrozenCoefficients B U b S × EuclideanJetLayers U O → ℂ, + Measurable F → (∀ p, ‖F p‖ ≤ 1) → + ‖(∫ p, (weights).complexMean (fun v => F (((allocatedCoefficientSplit B U b S) p.1).1, + euclideanCoefficientJetMap U (root v) (dirs v) rows + (canonicalCoefficientDeckSample U bW b hb o d (Nat.pos_of_ne_zero (NeZero.ne d)) p.1 p.2))) + ∂(source).prod (deck).toMeasure) - + ∫ a₀, ∫ z, ((proxy z / scale : ℝ) : ℂ) * + allocatedCoveredFixedTest B U b S x u v₀ rows Q hb o bW d F a₀ z ∂reference ∂frozenSource‖ ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1) ^ + Fintype.card (Σ a : LayerSamplerAxis I n, O (Sigma.fst a)) * ε := by + obtain ⟨v₀, hv₀⟩ := exists_allocatedLongResidueReference (α := α) B U b S period hp r hsize + refine ⟨v₀, hv₀, ?_⟩ + intro F hF hbound + have hres : ∀ v, (weights).weight v ≠ 0 → principalResidueLabel period v = principalResidueLabel period v₀ := by + intro v hv + exact (allocatedLongResidueWeights_support_label B U b S period hp r hsize v hv).trans hv₀.symm + exact allocatedPhysicalCovered_test_comparison B U b hR hσ S x u v₀ rows Q hb o bW d + s hA hσ1 weights period hperiod hres F residue hM hi hP hMP hRP hRi hσi hcount hε he hF hbound + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedFixedPathSlicedKernelResidueRiemann.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedFixedPathSlicedKernelResidueRiemann.lean new file mode 100644 index 0000000000000000000000000000000000000000..9aa508532fa140a89cf4df7bd5f8c4e9a05d51ac --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedFixedPathSlicedKernelResidueRiemann.lean @@ -0,0 +1,685 @@ +import Mathlib.Analysis.Calculus.MeanValue +import OAI.Combinatorics.Progressions.Estimates.AllocatedOriginalSampleFullSliceLipschitz +import OAI.Combinatorics.Progressions.Lattices.AffineKernelResidueRetained +import OAI.Combinatorics.Progressions.Linear.ContainedKernelPhysicalDisplacement +import OAI.Combinatorics.Progressions.Sampling.AllocatedKernelForecastSourceDecoupling + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "Input" => (Σ a : Active, B (Subtype.val a) × Fin (degree (Subtype.val a))) +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short + +variable (x : G → IntegerScalarCubeBox Empty S.value) +variable (u : PrincipalAxisTuples (α := Empty) + (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + +include hR hσ in +theorem allocatedOriginalSampleFullSlice_residue_riemann (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + (step H M : Input → ℕ) (c : Input → ℤ) + (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + {δ : ℝ} (hδ : 0 < δ) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (S.value : ℤ)) + (hdense : ∀ j, δ * S.value ≤ + ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : Input → Option Empty → ℕ) (residue : ∀ j i, ZMod (modulus j i)) + (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j) + (hsize : ∀ j, M j ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant Empty * ((M j : ℝ) / H j) < 1) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / S.value ≤ ε) + (φ : (Output → ℝ) → ℝ) {Kφ : ℝ≥0} + (hφ : LipschitzWith Kφ φ) (hφone : ∀ y, ‖φ y‖ ≤ 1) : + let lower := fun (a : Active) (p : B a.val × Fin (degree a.val)) => (c ⟨a, p⟩ : ℝ) / S.value + let width := fun (a : Active) (p : B a.val × Fin (degree a.val)) => + (step ⟨a, p⟩ : ℝ) * ((H ⟨a, p⟩ : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + |(FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights Empty (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) + (by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize j))).mean + (fun z => φ (allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => ((c j : ℝ) + (step j : ℝ) * (z j none : ℝ)) / S.value))) - + ∫ y, φ (allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample y) + ∂unitBoxMeasure Input| ≤ + (2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ j, (M j : ℝ) / H j + K * ε := by + classical + intro lower width K + let F := allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) sample + let project := fun x : Input → Option Empty → ℝ => fun j => x j none + have hproj : LipschitzWith 1 project := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro j + exact (dist_le_pi_dist (x j) (y j) none).trans (dist_le_pi_dist x y j) + have hball : Set.MapsTo project (Metric.closedBall 0 1) (Metric.closedBall 0 1) := by + intro x hx + rw [Metric.mem_closedBall, dist_zero_right] at hx ⊢ + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro j + exact (norm_le_pi_norm (x j) none).trans ((norm_le_pi_norm x j).trans hx) + have hF := allocatedOriginalSampleFullSliceMap_supported_lipschitzOn B U basis hR hσ S x u sample hs + (fun _ _ => 0) (fun _ _ => 1) (by intro _ _; norm_num) ht hσbound + have htest : LipschitzOnWith K (fun x => φ (F (project x))) (Metric.closedBall 0 1) := by + apply LipschitzOnWith.of_dist_le_mul + intro x hx y hy + calc + _ ≤ Kφ * dist (F (project x)) (F (project y)) := hφ.dist_le_mul _ _ + _ ≤ Kφ * ((allocatedOriginalSampleFullSliceLip B U basis S t : ℝ) * + dist (project x) (project y)) := + mul_le_mul_of_nonneg_left (hF.dist_le_mul _ (hball hx) _ (hball hy)) Kφ.coe_nonneg + _ ≤ Kφ * ((allocatedOriginalSampleFullSliceLip B U basis S t : ℝ) * dist x y) := + mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (by simpa using hproj.dist_le_mul x y) + (allocatedOriginalSampleFullSliceLip B U basis S t).coe_nonneg) Kφ.coe_nonneg + _ = K * dist x y := by simp only [K, NNReal.coe_mul, mul_assoc] + have he := progressionTuple_residue_riemann_on_box (fun _ : Input => S.value) + step H M c (fun _ => S.positive) hstep hH hδ hsubset hdense modulus residue hm hmM + (fun j => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize j) + (fun j => by simpa only [Measure.real, scalarCubeDomain_empty_volume, ENNReal.toReal_one] + using hsmall j) hε hmesh (fun x => φ (F (project x))) htest zero_le_one + (fun x _ => hφone _) + have hid (z : Input → Option Empty → ℝ) : + F (project (affineCubeTuple (fun j => (c j : ℝ) / S.value) + (fun j => (step j : ℝ) * ((H j : ℝ) - 1) / S.value) z)) = + allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample (project z) := by + exact allocatedOriginalSampleFullSliceMap_affine B U basis S x u sample lower width (project z) + simp_rw [hid] at he + have hmeas : Measurable (fun y => + φ (allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample y)) := + hφ.continuous.measurable.comp + (allocatedOriginalSampleFullSliceMap_measurable B U basis S x u lower width sample) + rw [scalarCubeProductMeasure_empty_integral Input _ hmeas] at he + simpa only [F, project, ite_true, Measure.real, scalarCubeDomain_empty_volume, + ENNReal.toReal_one, mul_one, div_one] using he + +include hR hσ in +theorem allocatedOriginalSampleFullSlice_full_residue_real_riemann + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + (hS : 2 ≤ S.value) (q : ℕ) (hq : 0 < q) + (residue : Input → Option Empty → ZMod q) + (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (Output → ℝ) → ℝ) {Kφ : ℝ≥0} + (hφ : LipschitzWith Kφ φ) (hφone : ∀ y, ‖φ y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + |(principalResidueWeights (fun a : Active => B a.val) (fun a : Active => degree a.val) + (fun _ => S.value) (fun _ => S.positive) q hq residue + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).mean + (fun v => φ (allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (v j none : ℝ) / S.value))) - + ∫ y, φ (allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample y) + ∂unitBoxMeasure Input| ≤ + (2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value) := by + classical + intro lower width K + have he := allocatedOriginalSampleFullSlice_residue_riemann B U basis hR hσ S x u + sample hs ht hσbound (fun _ => 1) (fun _ => S.value) (fun _ => q) (fun _ => 0) + (fun _ => Nat.zero_lt_one) (fun _ => hS) (δ := 1) zero_lt_one + (fun _ => fullIntervalProgression_subset S.value) + (fun _ => by simp only [Nat.cast_one, fullIntervalProgression_card, one_mul, le_refl]) + (fun _ _ => q) residue (fun _ _ => hq) (fun _ _ => le_rfl) + (fun _ => hsize) (fun _ => hsmall) + (ε := 1 / S.value) (by positivity) (fun _ => by simp only [Nat.cast_one, le_refl]) + φ hφ hφone + simpa only [principalResidueWeights, Int.cast_zero, Nat.cast_one, zero_add, + one_mul, zero_div, lower, width, K] using he + +include hR hσ in +theorem allocatedOriginalSampleFullSlice_full_residue_complex_riemann + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + (hS : 2 ≤ S.value) (q : ℕ) (hq : 0 < q) + (residue : Input → Option Empty → ZMod q) + (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (Output → ℝ) → ℂ) {Kφ : ℝ≥0} + (hφ : LipschitzWith Kφ φ) (hφone : ∀ y, ‖φ y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + ‖(principalResidueWeights (fun a : Active => B a.val) (fun a : Active => degree a.val) + (fun _ => S.value) (fun _ => S.positive) q hq residue + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean + (fun v => φ (allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (v j none : ℝ) / S.value))) - + ∫ y, φ (allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample y) + ∂unitBoxMeasure Input‖ ≤ + 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) := by + classical + intro lower width K + let p := (principalResidueWeights (fun a : Active => B a.val) (fun a : Active => degree a.val) + (fun _ => S.value) (fun _ => S.positive) q hq residue + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)) + let F := allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) sample + let g := fun y => φ (allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample y) + have hig : Integrable g (unitBoxMeasure Input) := + ⟨(hφ.continuous.measurable.comp + (allocatedOriginalSampleFullSliceMap_measurable B U basis S x u lower width sample)).aestronglyMeasurable, + HasFiniteIntegral.of_bounded (Filter.Eventually.of_forall (fun y => hφone _))⟩ + have hφre : LipschitzWith Kφ (fun y => (φ y).re) := by + apply LipschitzWith.of_dist_le_mul + intro v w + rw [Real.dist_eq, ← Complex.sub_re] + exact (Complex.abs_re_le_norm _).trans (by simpa only [dist_eq_norm] using hφ.dist_le_mul v w) + have hφim : LipschitzWith Kφ (fun y => (φ y).im) := by + apply LipschitzWith.of_dist_le_mul + intro v w + rw [Real.dist_eq, ← Complex.sub_im] + exact (Complex.abs_im_le_norm _).trans (by simpa only [dist_eq_norm] using hφ.dist_le_mul v w) + have hre := allocatedOriginalSampleFullSlice_full_residue_real_riemann B U basis hR hσ S x u + sample hs ht hσbound hS q hq residue hsize hsmall (fun y => (φ y).re) hφre + (fun y => (Complex.abs_re_le_norm _).trans (hφone y)) + have him := allocatedOriginalSampleFullSlice_full_residue_real_riemann B U basis hR hσ S x u + sample hs ht hσbound hS q hq residue hsize hsmall (fun y => (φ y).im) hφim + (fun y => (Complex.abs_im_le_norm _).trans (hφone y)) + have hgre : (∫ y, g y ∂unitBoxMeasure Input).re = ∫ y, (g y).re ∂unitBoxMeasure Input := by + simpa only [RCLike.re_eq_complex_re] using (integral_re hig).symm + have hgim : (∫ y, g y ∂unitBoxMeasure Input).im = ∫ y, (g y).im ∂unitBoxMeasure Input := by + simpa only [RCLike.im_eq_complex_im] using (integral_im hig).symm + change ‖p.complexMean (fun v => φ (F (fun j => (v j none : ℝ) / S.value))) - + ∫ y, g y ∂unitBoxMeasure Input‖ ≤ _ + calc + _ ≤ |(p.complexMean (fun v => φ (F (fun j => (v j none : ℝ) / S.value))) - + ∫ y, g y ∂unitBoxMeasure Input).re| + + |(p.complexMean (fun v => φ (F (fun j => (v j none : ℝ) / S.value))) - + ∫ y, g y ∂unitBoxMeasure Input).im| := Complex.norm_le_abs_re_add_abs_im _ + _ ≤ ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) + ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) := by + apply add_le_add + · rw [Complex.sub_re, FiniteProbabilityWeights.complexMean_re, hgre] + exact hre + · rw [Complex.sub_im, FiniteProbabilityWeights.complexMean_im, hgim] + exact him + _ = _ := by ring + +include hR hσ in +theorem allocatedOriginalSample_full_residue_perturbed_riemann + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + (hS : 2 ≤ S.value) (q : ℕ) (hq : 0 < q) + (residue : Input → Option Empty → ZMod q) + (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (b : ∀ a : Active, B a.val) + {η : ℝ} (hη : 0 < η) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + (htail : |t| * polynomialMassC2Budget (Fintype.card Input) m 1 ≤ + slicedPrincipalC2Tolerance (Fintype.card Input) (Fintype.card Active) m 1 + (unitProfilePrincipalLowerBound B) (1 / 2) A η) + (φ : (Output → ℝ) → ℂ) {Kφ : ℝ≥0} + (hφ : LipschitzWith Kφ φ) (hφone : ∀ y, ‖φ y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + ‖(principalResidueWeights (fun a : Active => B a.val) (fun a : Active => degree a.val) + (fun _ => S.value) (fun _ => S.positive) q hq residue + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean + (fun v => φ (fun o => + MvPolynomial.eval (allocatedOriginalSampleSliceInput B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) (fun j => (v j none : ℝ) / S.value)) + (monomialArrayPolynomial Subtype.val + (allocatedSampleNormalizedCoefficients B U basis S sample o.1.val)) / R o.1.val.1)) - + ∫ y, φ (allocatedOriginalSampleLiftMap B U basis S lower width sample y) + ∂unitBoxMeasure Input‖ ≤ + 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) + 2 * η := by + classical + intro lower width K + have hSreal : (2 : ℝ) ≤ S.value := by exact_mod_cast hS + have hSpos : (0 : ℝ) < S.value := by exact_mod_cast S.positive + have hw0 : 0 ≤ ((S.value : ℝ) - 1) / S.value := + div_nonneg (by linarith) hSpos.le + have hw1 : ((S.value : ℝ) - 1) / S.value ≤ 1 := by + apply (div_le_one hSpos).mpr + linarith + have hw2 : (1 / 2 : ℝ) ≤ ((S.value : ℝ) - 1) / S.value := by + apply (le_div_iff₀ hSpos).mpr + linarith + have hwidth : ∀ a p, |lower a p| + |width a p| ≤ 1 := by + intro a p + simpa only [lower, width, abs_zero, zero_add, abs_of_nonneg hw0] using hw1 + have hp := allocatedOriginalSample_slice_complex_perturbation B U basis hR hσ S x u lower width + sample hs hwidth b (δ := 1 / 2) (by norm_num) (by norm_num) hη + (fun _ _ => hw2) (fun _ _ => le_rfl) A hA ht hσbound htail φ hφ.continuous.measurable hφone + have hq' := allocatedOriginalSampleFullSlice_full_residue_complex_riemann + B U basis hR hσ S x u sample hs ht hσbound hS q hq residue hsize hsmall φ hφ hφone + let p := (principalResidueWeights (fun a : Active => B a.val) (fun a : Active => degree a.val) + (fun _ => S.value) (fun _ => S.positive) q hq residue + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)) + let f := fun (v : Input → IntegerScalarCubeBox Empty S.value) => φ (allocatedOriginalSampleFullSliceMap B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) sample (fun j => (v j none : ℝ) / S.value)) + have he : ‖p.complexMean f - + ∫ y, φ (allocatedOriginalSampleLiftMap B U basis S lower width sample y) ∂unitBoxMeasure Input‖ ≤ + 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) + 2 * η := by + calc + _ ≤ ‖p.complexMean f - + ∫ y, φ (allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample y) ∂unitBoxMeasure Input‖ + + ‖(∫ y, φ (allocatedOriginalSampleFullSliceMap B U basis S x u lower width sample y) ∂unitBoxMeasure Input) - + ∫ y, φ (allocatedOriginalSampleLiftMap B U basis S lower width sample y) ∂unitBoxMeasure Input‖ := + norm_sub_le_norm_sub_add_norm_sub _ _ _ + _ ≤ _ := add_le_add hq' (by simpa only [norm_sub_rev] using hp) + have hmap : allocatedOriginalSampleFullSliceMap B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) sample = fun y o => + MvPolynomial.eval (allocatedOriginalSampleSliceInput B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) y) + (monomialArrayPolynomial Subtype.val + (allocatedSampleNormalizedCoefficients B U basis S sample o.1.val)) / R o.1.val.1 := by + funext y o + exact allocatedOriginalSampleFullSliceMap_eq_eval B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) sample y o + simpa only [p, f, hmap] using he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G X : Type*} [Fintype G] [DecidableEq G] [Fintype X] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "Input" => (Σ a : Active, B (Subtype.val a) × Fin (degree (Subtype.val a))) +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short + +local notation "Spatial" => ((Σ _ : X, Unit ⊕ Empty) → ℝ) +local notation "Domain" => (Spatial × (Output → ℝ)) +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) + (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S) + +omit hR hσ [DecidableEq G] in +theorem allocatedFixedSpatialKernelMap_lipschitz + (z : Option G × X → ℝ) (hz : ∀ g x, |z (some g, x)| ≤ 1) : + LipschitzWith 1 (fixedSpatialKernelMap budget (S.value : ℝ) z) := by + apply (fixedSpatialKernelMap_lipschitz budget (S.value : ℝ) z hz).weaken + change (Fintype.card G : ℝ) * ‖(S.value : ℝ) / (1 + budget)‖ ≤ 1 + simpa only [Real.norm_eq_abs] using allocatedKernelSlowBudget_abs_le_one B U basis S + +omit hR hσ in +theorem allocatedFixedPath_kernel_residue_riemann + (z : Option G × X → ℝ) (hz : ∀ g x, |z (some g, x)| ≤ 1) + (sample : Sample) + (lower width : ∀ a : Active, B a.val × Fin (degree a.val) → ℝ) + (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (G → ZMod q) → Domain → ℂ) {Kφ : ℝ≥0} + (hφ : ∀ r, LipschitzWith Kφ (φ r)) (hbound : ∀ r y, ‖φ r y‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun x => ∫ v, φ (fun g => ((x g none : ℤ) : ZMod q)) + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), + allocatedOriginalSampleLiftMap B U basis S lower width sample v) ∂unitBoxMeasure Input) - + (FiniteProbabilityWeights.uniform (G → ZMod q)).complexMean (fun r => + ∫ k, ∫ v, φ r (fixedSpatialKernelMap budget (S.value : ℝ) z k, + allocatedOriginalSampleLiftMap B U basis S lower width sample v) + ∂unitBoxMeasure Input ∂unitBoxMeasure G)‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + Kφ)) * + (Fintype.card G * ((q : ℝ) / S.value)) := by + classical + let F := fun (r : G → ZMod q) (k : G → ℝ) => + ∫ v, φ r (fixedSpatialKernelMap budget (S.value : ℝ) z k, + allocatedOriginalSampleLiftMap B U basis S lower width sample v) ∂unitBoxMeasure Input + have hF (r : G → ZMod q) : LipschitzWith Kφ (F r) := by + simpa only [mul_one, Function.comp_def, F] using + (allocatedOriginalSampleForecastPartial_lipschitz B U basis S lower width sample + (φ r) (hφ r) (hbound r)).comp + (allocatedFixedSpatialKernelMap_lipschitz B U basis S z hz) + have hFb (r : G → ZMod q) (k : G → ℝ) : ‖F r k‖ ≤ 1 := + allocatedOriginalSampleForecastPartial_norm_le B U basis S lower width sample + (φ r) (hbound r) _ + have hproject : LipschitzWith 1 (fun k : G → Option Empty → ℝ => fun g => k g none) := by + apply LipschitzWith.of_dist_le_mul + intro k l + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro g + exact (dist_le_pi_dist (k g) (l g) none).trans (dist_le_pi_dist k l g) + have he := originalKernel_residue_slow_quadrature S.value q S.positive (NeZero.pos q) hsize + (by simpa only [Measure.real, scalarCubeDomain_empty_volume, ENNReal.toReal_one] using hsmall) + (fun r k => F r (fun g => k g none)) + (fun r => by simpa only [mul_one, Function.comp_def] using (hF r).comp hproject) + (fun r k => hFb r _) + have hid (r : G → ZMod q) : + (∫ k, F r (fun g => k g none) ∂scalarCubeProductMeasure G Empty) = + ∫ k, F r k ∂unitBoxMeasure G := by + rw [← scalarCubeProductMeasure_empty_map G] + exact (integral_map (by fun_prop : Measurable (fun k : G → Option Empty → ℝ => fun g => k g none)).aemeasurable + (hF r).continuous.measurable.aestronglyMeasurable).symm + simpa only [F, hid, FiniteProbabilityWeights.uniform_complexMean, Measure.real, + scalarCubeDomain_empty_volume, ENNReal.toReal_one, div_one] using he + +include hR hσ in +theorem allocatedFixedPath_joint_residue_riemann + (z : Option G × X → ℝ) (hz : ∀ g x, |z (some g, x)| ≤ 1) + (u : PrincipalAxisTuples (α := Empty) + (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + (b : ∀ a : Active, B a.val) {η : ℝ} (hη : 0 < η) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + (htail : |t| * polynomialMassC2Budget (Fintype.card Input) m 1 ≤ + slicedPrincipalC2Tolerance (Fintype.card Input) (Fintype.card Active) m 1 + (unitProfilePrincipalLowerBound B) (1 / 2) A η) + (hS : 2 ≤ S.value) (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (G → ZMod q) → (Input → ZMod q) → Domain → ℂ) {Kφ : ℝ≥0} + (hφ : ∀ rG rA, LipschitzWith Kφ (φ rG rA)) + (hbound : ∀ rG rA y, ‖φ rG rA y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + let kernel := FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive) + let active := FiniteProbabilityWeights.pi (fun _ : Input => integerScalarCubeWeights Empty S.value S.positive) + ‖kernel.complexMean (fun x => active.complexMean (fun v => + φ (fun g => ((x g none : ℤ) : ZMod q)) (fun j => ((v j none : ℤ) : ZMod q)) + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), + allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (v j none : ℝ) / S.value)))) - + (FiniteProbabilityWeights.uniform (Input → ZMod q)).complexMean (fun rA => + (FiniteProbabilityWeights.uniform (G → ZMod q)).complexMean (fun rG => + ∫ k, ∫ v, φ rG rA (fixedSpatialKernelMap budget (S.value : ℝ) z k, + allocatedOriginalSampleLiftMap B U basis S lower width sample v) + ∂unitBoxMeasure Input ∂unitBoxMeasure G))‖ ≤ + ((Fintype.card Input : ℝ) * ((q : ℝ) / S.value) + + (2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) + 2 * η)) + + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + Kφ)) * + (Fintype.card G * ((q : ℝ) / S.value)) := by + classical + intro lower width K kernel active + let residues := FiniteProbabilityWeights.uniform (Input → ZMod q) + let E := 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) + 2 * η + let EA := (Fintype.card Input : ℝ) * ((q : ℝ) / S.value) + E + let EG := (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + Kφ)) * + (Fintype.card G * ((q : ℝ) / S.value)) + let value := fun (x : G → IntegerScalarCubeBox Empty S.value) (rA : Input → ZMod q) + (v : Input → IntegerScalarCubeBox Empty S.value) => + φ (fun g => ((x g none : ℤ) : ZMod q)) rA + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), + allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (v j none : ℝ) / S.value)) + let reference := fun (x : G → IntegerScalarCubeBox Empty S.value) (rA : Input → ZMod q) => + ∫ v, φ (fun g => ((x g none : ℤ) : ZMod q)) rA + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), + allocatedOriginalSampleLiftMap B U basis S lower width sample v) ∂unitBoxMeasure Input + let conditioned := fun rA : Input → ZMod q => + FiniteProbabilityWeights.pi (fun j : Input => scalarCubeResidueWeights Empty S.value q S.positive + (fun _ => q) (fun _ => rA j) (fun _ => NeZero.pos q) (fun _ => le_rfl) + (by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)) + have hcond (x : G → IntegerScalarCubeBox Empty S.value) (rA : Input → ZMod q) : + ‖(conditioned rA).complexMean (value x rA) - reference x rA‖ ≤ E := by + let test := fun w : Output → ℝ => φ (fun g => ((x g none : ℤ) : ZMod q)) rA + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), w) + have htest : LipschitzWith Kφ test := by + apply LipschitzWith.of_dist_le_mul + intro v w + simpa only [test, Prod.dist_eq, dist_self, max_eq_right dist_nonneg] using + (hφ (fun g => ((x g none : ℤ) : ZMod q)) rA).dist_le_mul + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), v) + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), w) + have he := allocatedOriginalSample_full_residue_perturbed_riemann B U basis hR hσ S x u + sample hs ht hσbound hS q (NeZero.pos q) (fun j _ => rA j) hsize hsmall b hη A hA htail + test htest (fun w => hbound _ _ _) + have hmap : allocatedOriginalSampleFullSliceMap B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) sample = fun y o => + MvPolynomial.eval (allocatedOriginalSampleSliceInput B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) y) + (monomialArrayPolynomial Subtype.val + (allocatedSampleNormalizedCoefficients B U basis S sample o.1.val)) / R o.1.val.1 := by + funext y o + exact allocatedOriginalSampleFullSliceMap_eq_eval B U basis S x u + (fun _ _ => 0) (fun _ _ => 1) sample y o + simpa only [conditioned, value, reference, E, K, lower, width, test, + principalResidueWeights, hmap] using he + have hprincipal (x : G → IntegerScalarCubeBox Empty S.value) : + ‖active.complexMean (fun v => value x (fun j => ((v j none : ℤ) : ZMod q)) v) - + residues.complexMean (reference x)‖ ≤ EA := by + have hmix := integerScalarCubeWeights_empty_pi_uniform_residue_error + S.value q S.positive (NeZero.pos q) hsize (value x) (fun rA v => hbound _ _ _) + have havg : ‖residues.complexMean (fun rA => (conditioned rA).complexMean (value x rA)) - + residues.complexMean (reference x)‖ ≤ E := + (residues.norm_complexMean_sub_le _ _ (fun _ => E) (fun rA _ => hcond x rA)).trans_eq + (residues.mean_const E) + have hmix' : ‖active.complexMean (fun v => value x (fun j => ((v j none : ℤ) : ZMod q)) v) - + residues.complexMean (fun rA => (conditioned rA).complexMean (value x rA))‖ ≤ + (Fintype.card Input : ℝ) * ((q : ℝ) / S.value) := by + simpa only [active, residues, conditioned, FiniteProbabilityWeights.uniform_complexMean] using hmix + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hmix' havg) + have hfirst := (kernel.norm_complexMean_sub_le _ _ (fun _ => EA) + (fun x _ => hprincipal x)).trans_eq (kernel.mean_const EA) + have hlast := (residues.norm_complexMean_sub_le _ _ (fun _ => EG) + (fun rA _ => allocatedFixedPath_kernel_residue_riemann B U basis S z hz sample lower width + q hsize hsmall (fun rG => φ rG rA) (fun rG => hφ rG rA) (fun rG => hbound rG rA))).trans_eq + (residues.mean_const EG) + rw [← FiniteProbabilityWeights.complexMean_commute kernel residues] at hlast + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hfirst hlast) + +include hR hσ in +theorem allocatedFixedPath_joint_residue_weighted_riemann + (z : Option G × X → ℝ) (hz : ∀ g x, |z (some g, x)| ≤ 1) + (u : PrincipalAxisTuples (α := Empty) + (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + {t : ℝ} (ht : 0 < t) (hσbound : ∀ j, |σ j| ≤ t) + (b : ∀ a : Active, B a.val) {η : ℝ} (hη : 0 < η) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + (htail : |t| * polynomialMassC2Budget (Fintype.card Input) m 1 ≤ + slicedPrincipalC2Tolerance (Fintype.card Input) (Fintype.card Active) m 1 + (unitProfilePrincipalLowerBound B) (1 / 2) A η) + (hS : 2 ≤ S.value) (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (coefficient : (G → ZMod q) → (Input → ZMod q) → ℂ) + (hcoefficient : ∀ rG rA, ‖coefficient rG rA‖ ≤ 1) + (φ : (G → ZMod q) → (Input → ZMod q) → Domain → ℂ) {Kφ : ℝ≥0} + (hφ : ∀ rG rA, LipschitzWith Kφ (φ rG rA)) + (hbound : ∀ rG rA y, ‖φ rG rA y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleFullSliceLip B U basis S t + let kernel := FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive) + let active := FiniteProbabilityWeights.pi (fun _ : Input => integerScalarCubeWeights Empty S.value S.positive) + ‖kernel.complexMean (fun x => active.complexMean (fun v => + coefficient (fun g => ((x g none : ℤ) : ZMod q)) (fun j => ((v j none : ℤ) : ZMod q)) * + φ (fun g => ((x g none : ℤ) : ZMod q)) (fun j => ((v j none : ℤ) : ZMod q)) + (fixedSpatialKernelMap budget (S.value : ℝ) z (fun g => (x g none : ℝ) / S.value), + allocatedOriginalSampleFullSliceMap B U basis S x u (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (v j none : ℝ) / S.value)))) - + (FiniteProbabilityWeights.uniform (Input → ZMod q)).complexMean (fun rA => + (FiniteProbabilityWeights.uniform (G → ZMod q)).complexMean (fun rG => + coefficient rG rA * ∫ k, ∫ v, φ rG rA (fixedSpatialKernelMap budget (S.value : ℝ) z k, + allocatedOriginalSampleLiftMap B U basis S lower width sample v) + ∂unitBoxMeasure Input ∂unitBoxMeasure G))‖ ≤ + ((Fintype.card Input : ℝ) * ((q : ℝ) / S.value) + + (2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) + 2 * η)) + + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + Kφ)) * + (Fintype.card G * ((q : ℝ) / S.value)) := by + have hmul (rG : G → ZMod q) (rA : Input → ZMod q) : + LipschitzWith Kφ (fun y => coefficient rG rA * φ rG rA y) := by + apply LipschitzWith.of_dist_le_mul + intro y w + rw [dist_eq_norm, ← mul_sub, norm_mul] + exact (mul_le_of_le_one_left (norm_nonneg _) (hcoefficient rG rA)).trans + (by simpa only [dist_eq_norm] using (hφ rG rA).dist_le_mul y w) + have hb (rG : G → ZMod q) (rA : Input → ZMod q) (y : Domain) : + ‖coefficient rG rA * φ rG rA y‖ ≤ 1 := by + rw [norm_mul] + exact (mul_le_of_le_one_left (norm_nonneg _) (hcoefficient rG rA)).trans + (hbound rG rA y) + simpa only [integral_const_mul] using + allocatedFixedPath_joint_residue_riemann B U basis hR hσ S z hz u sample hs + ht hσbound b hη A hA htail hS q hsize hsmall + (fun rG rA y => coefficient rG rA * φ rG rA y) hmul hb + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G X : Type*} [Fintype G] [DecidableEq G] [Fintype X] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "Input" => (Σ a : Active, B (Subtype.val a) × Fin (degree (Subtype.val a))) +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short + +local notation "Spatial" => ((Σ _ : X, Unit ⊕ Empty) → ℝ) +local notation "Domain" => (Spatial × (Output → ℝ)) +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) + (allocatedShortAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S) + +omit hR hσ in +theorem allocatedFixedPath_sliced_kernel_residue_riemann + (z : Option G × X → ℝ) (hz : ∀ g x, |z (some g, x)| ≤ 1) + (sample : Sample) + (lower width : ∀ a : Active, B a.val × Fin (degree a.val) → ℝ) + (H : G → ℕ) (hH : ∀ g, 0 < H g) (start : G → ℤ) + (step : ℕ) (hstep : 0 < step) + (hcontained : ∀ g, integerProgressionSupport (start g) (step : ℤ) (H g) ⊆ + Finset.Ico (0 : ℤ) (S.value : ℤ)) + (q : ℕ) [NeZero q] (hsize : ∀ g, q ≤ H g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / H g) < 1) + (φ : (G → ZMod q) → Domain → ℂ) {Kφ : ℝ≥0} + (hφ : ∀ r, LipschitzWith Kφ (φ r)) (hbound : ∀ r y, ‖φ r y‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun g => integerScalarCubeWeights Empty (H g) (hH g))).complexMean + (fun x => ∫ v, φ (fun g => ((start g + (step : ℤ) * (x g none : ℤ) : ℤ) : ZMod q)) + (fixedSpatialKernelMap budget (S.value : ℝ) z + (fun g => ((start g : ℝ) + (step : ℝ) * (x g none : ℝ)) / S.value), + allocatedOriginalSampleLiftMap B U basis S lower width sample v) ∂unitBoxMeasure Input) - + (FiniteProbabilityWeights.uniform (G → ZMod q)).complexMean (fun r => + ∫ k, ∫ v, φ (fun g => (start g : ZMod q) + (step : ZMod q) * r g) + (fixedSpatialKernelMap budget (S.value : ℝ) z + (fun g => ((start g : ℝ) + (step : ℝ) * ((H g - 1 : ℕ) : ℝ) * k g) / S.value), + allocatedOriginalSampleLiftMap B U basis S lower width sample v) + ∂unitBoxMeasure Input ∂unitBoxMeasure G)‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + Kφ) + Kφ) * + ∑ g, (q : ℝ) / H g := by + classical + let F := fun (r : G → ZMod q) (k : G → ℝ) => + ∫ v, φ r (fixedSpatialKernelMap budget (S.value : ℝ) z k, + allocatedOriginalSampleLiftMap B U basis S lower width sample v) ∂unitBoxMeasure Input + have hF (r : G → ZMod q) : LipschitzWith Kφ (F r) := by + simpa only [mul_one, Function.comp_def, F] using + (allocatedOriginalSampleForecastPartial_lipschitz B U basis S lower width sample + (φ r) (hφ r) (hbound r)).comp + (allocatedFixedSpatialKernelMap_lipschitz B U basis S z hz) + have hFb (r : G → ZMod q) (k : G → ℝ) : ‖F r k‖ ≤ 1 := + allocatedOriginalSampleForecastPartial_norm_le B U basis S lower width sample + (φ r) (hbound r) _ + have hspan := affineKernel_span_of_contained H hH start step S.value hstep hcontained + have he := affineKernel_residue_slow_quadrature H q hH (NeZero.pos q) hsize + (fun g => by simpa only [Measure.real, scalarCubeDomain_empty_volume, ENNReal.toReal_one] using hsmall g) + (fun g => (start g : ℝ)) (step : ℝ) (S.value : ℝ) (by exact_mod_cast S.positive) + (Nat.cast_nonneg _) hspan + (fun r g => (start g : ZMod q) + (step : ZMod q) * r g) F hF hFb + have hid (r : G → ZMod q) : + (∫ k, F (fun g => (start g : ZMod q) + (step : ZMod q) * r g) + (affineKernelContinuousPoint (fun g => (start g : ℝ)) (step : ℝ) (S.value : ℝ) H k) + ∂scalarCubeProductMeasure G Empty) = + ∫ k, F (fun g => (start g : ZMod q) + (step : ZMod q) * r g) + (fun g => ((start g : ℝ) + (step : ℝ) * ((H g - 1 : ℕ) : ℝ) * k g) / S.value) + ∂unitBoxMeasure G := by + rw [← scalarCubeProductMeasure_empty_map G] + exact (integral_map (by fun_prop : Measurable + (fun k : G → Option Empty → ℝ => fun g => k g none)).aemeasurable + (show AEStronglyMeasurable (fun k : G → ℝ => + F (fun g => (start g : ZMod q) + (step : ZMod q) * r g) + (fun g => ((start g : ℝ) + (step : ℝ) * ((H g - 1 : ℕ) : ℝ) * k g) / S.value)) + ((scalarCubeProductMeasure G Empty).map (fun k => fun g => k g none)) from + ((hF _).continuous.comp (by fun_prop)).measurable.aestronglyMeasurable)).symm + simpa only [hid, F, FiniteProbabilityWeights.uniform_complexMean, Measure.real, + scalarCubeDomain_empty_volume, ENNReal.toReal_one, div_one, + Int.cast_add, Int.cast_mul, Int.cast_natCast] using he + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedFullGridResidueWitness.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedFullGridResidueWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..b534687f009b505321ddfa86148fe010c42ff13e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedFullGridResidueWitness.lean @@ -0,0 +1,160 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedResidueSitePrimitiveAverage +import OAI.Combinatorics.Progressions.Sampling.AllocatedClippedFullGridGlobal + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +variable (q : ℕ) + +local notation "tupleType" => PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S) +local notation "tuples" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) +local notation "labelType" => PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q +local notation "gridAxes" => {a // allocatedGridAxis (I := I) U b S.value a} +local notation "ig" => allocatedGridIntegerAxis B U b S + +structure AllocatedFullGridResidueWitness (r : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q)) where + representative : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S) + label_eq : principalResidueLabel q representative = r + positive : 0 < (tuples).mass (Finset.univ.filter + (fun y => principalResidueLabel q y = principalResidueLabel q representative)) + expansion : gridAxes → ScalarSiteExpansion.{0,0} (Finset (Fin dim)) + +theorem exists_allocated_full_grid_residue_witnesses + {D P p v δ E : ℝ} + (hD : AllocatedComparisonDimensions (G := G) B (Fin dim) (fun j : Fin m => (rowSets j : Type)) D) + (hα : Fintype.card (Fin dim) ≤ m + 1) (hP : 1 ≤ P) (hp : 0 ≤ p) (hv : 0 ≤ v) + (hPp : P ≤ Real.exp p) (hq : 0 < q) (hqv : (q : ℝ) ≤ Real.exp v) + (hδ : 0 < δ) (hE : 0 ≤ E) (hδE : δ⁻¹ ≤ Real.exp E) + (hsize : (Fintype.card (Fin dim) + 1) * q ≤ S.value) + (hgamma : ∀ a : gridAxes, principalProfileSize (R (ig a).1) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (ig a).1 (ig a).2)) ≤ 1) + (hσ1 : ∀ a : gridAxes, σ (ig a).1 ≤ 1) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope (Fin dim) L 1 0 q ≤ P) + (hrows : ∀ j t, t ∈ rowSets j → t.card ≤ j.val + 1) + (hB : ∀ a : gridAxes, max + (positiveModerateSpectrumBlockCount (ig a).1.val (rowSets (ig a).1).card + ((layerTailDegree m + 2) * (rowSets (ig a).1).card)) + (uniformSpectrumBlockCount (ig a).1.val (rowSets (ig a).1).card + (((ig a).1.val + 1) * (rowSets (ig a).1).card)) ≤ + Fintype.card (B ⟨(ig a).1, Sum.inr (ig a).2⟩)) : + let O := allocatedMixedJointSiteLog m D p v (E + allocatedFullGridWindowLog D) + ∃ W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val, + ∀ r, (∀ a, ((W r).expansion a).Bounds (Real.exp O) (Real.exp O) (Real.exp O) + ⟨Real.exp O, Real.exp_nonneg _⟩ (Real.exp (allocatedInactiveSupportLog D))) ∧ + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (z : AllocatedFrozenJetRows B U b S (rowTypes)), + ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ) * + ((∏ a : gridAxes, (allocatedSupportedGridJetPMF B U b hR hσ S x (rows) q + (principalResidueLabel q (W r).representative) (W r).positive a (z a)).toReal : ℝ) : ℂ) - + allocatedFullGridSiteApproximation B U b S rowSets (W r).expansion z‖ ≤ + allocatedFullGridPointTolerance D δ := by + have hreps (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + (tuples).exists_mem_positive_fiber (principalResidueLabel q) r.val r.property + choose rep hrep using hreps + have hc (r : AllocatedPositiveResidue (dim := dim) B U b S q) : + 0 < (tuples).mass (Finset.univ.filter + (fun y => principalResidueLabel q y = principalResidueLabel q (rep r))) := by + simpa only [hrep r] using r.property + have hex (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_full_grid_site_approximation B U b hR hσ S rowSets q + (principalResidueLabel q (rep r)) (hc r) hD hα hP hp hv hPp hq hqv + (allocatedFullGridPointTolerance_pos (D := D) hδ) + (add_nonneg hE (allocatedFullGridWindowLog_nonneg hD.nonneg)) + (allocatedFullGridPointTolerance_inv hδE) hsize hgamma hσ1 L hL hcP hsP hrows hB + choose e hbounds herror using hex + let W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val := + fun r => ⟨rep r, hrep r, hc r, e r⟩ + exact ⟨W, fun r => ⟨hbounds r, herror r⟩⟩ + +variable {r : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q)} +variable (w : AllocatedFullGridResidueWitness (dim := dim) B U b S q r) +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) ((Sigma.fst (Subtype.val a)).val + 1)}) → ℝ) → ℝ) + +noncomputable def allocatedFullGridResidueWitnessProfile : EuclideanJetLayers U (rowTypes) → ℂ := + allocatedFullGridSiteProfile B U b hR hσ S rowSets x hb o bW d q + w.representative w.positive f w.expansion + +noncomputable def allocatedSupportedFullGridResidueProfile + (W : (r : (AllocatedPositiveResidue (dim := dim) B U b S q)) → AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) + (r : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q)) : EuclideanJetLayers U (rowTypes) → ℂ := + if hr : 0 < (tuples).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) then + allocatedFullGridResidueWitnessProfile B U b hR hσ S q (W ⟨r, hr⟩) x hb o bW d f + else fun _ => 0 + +theorem allocatedSupportedFullGridResidueProfile_positive + (W : (r : (AllocatedPositiveResidue (dim := dim) B U b S q)) → AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) + (r : (AllocatedPositiveResidue (dim := dim) B U b S q)) : + allocatedSupportedFullGridResidueProfile B U b hR hσ S q x hb o bW d f W r.val = + allocatedFullGridResidueWitnessProfile B U b hR hσ S q (W r) x hb o bW d f := by + unfold allocatedSupportedFullGridResidueProfile + rw [dite_eq_left r.property] + +theorem allocatedFullGridResidueWitnessProfile_error + (hr : 0 < (tuples).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))) : + (fun z => ((tuples).condition _ hr).complexMean (fun y => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y q f z : ℂ)) - + allocatedFullGridResidueWitnessProfile B U b hR hσ S q w x hb o bW d f z) = + allocatedSelectedConditionalError (O := rowTypes) B U b hR hσ S x (rows) hb o bW d q + w.representative w.positive (fun _ => True) f + (allocatedFullGridSelectedApproximation B U b S rowSets w.expansion) + (allocatedFullGridNaturalVolume B U b S rowSets) := by + rcases w with ⟨y₀, hy₀, hcell, e⟩ + subst r + simpa only [allocatedFullGridResidueWitnessProfile, FiniteProbabilityWeights.complexMean_ofReal] using + allocatedFullGridSiteProfile_error B U b hR hσ S rowSets x hb o bW d q y₀ hcell f e + +theorem allocatedSupportedFullGridResidueProfile_error + (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) + (r : AllocatedPositiveResidue (dim := dim) B U b S q) : + (fun z => ((tuples).condition _ r.property).complexMean (fun y => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y q f z : ℂ)) - + allocatedSupportedFullGridResidueProfile B U b hR hσ S q x hb o bW d f W r.val z) = + allocatedSelectedConditionalError (O := rowTypes) B U b hR hσ S x (rows) hb o bW d q + (W r).representative (W r).positive (fun _ => True) f + (allocatedFullGridSelectedApproximation B U b S rowSets (W r).expansion) + (allocatedFullGridNaturalVolume B U b S rowSets) := by + rw [allocatedSupportedFullGridResidueProfile_positive] + exact allocatedFullGridResidueWitnessProfile_error B U b hR hσ S q (W r) x hb o bW d f r.property + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedGridResidueRefinement.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedGridResidueRefinement.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a213e78734c3d17a27b20ddf0af95ad8fda11a5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedGridResidueRefinement.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.Progressions.Sampling.AllocatedBufferedGridIdeal + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +theorem residueSelectedSiteProduct {S R : Type*} [Fintype S] [Fintype R] [DecidableEq R] + (label : S → R) (f : R → S → ℂ) : + (∏ s, f (label s) s) = + ∑ r : S → R, ∏ s, (if label s = r s then (1 : ℂ) else 0) * f (r s) s := by + symm + rw [Finset.sum_eq_single label] + · simp + · intro r _ hr + have hne : ∃ s, label s ≠ r s := by + by_contra h + apply hr + funext s + exact (not_ne_iff.mp (not_exists.mp h s)).symm + obtain ⟨s, hs⟩ := hne + exact Finset.prod_eq_zero (Finset.mem_univ s) (by simp only [hs, ite_false, zero_mul]) + · simp + +variable {A V : Type*} [Fintype A] (e : A → ScalarSiteExpansion V) +variable (k : ∀ a, (e a).Term) [∀ a, NeZero ((e a).period (k a))] + +theorem gridResidueLabels_card : + Fintype.card (∀ a, ZMod ((e a).period (k a))) = commonSitePeriod e k := by + simp only [Fintype.card_pi, ZMod.card, commonSitePeriod] + +theorem gridResidueLabels_card_le_exp + {T C H K : A → ℝ} {L : ℝ≥0} (he : ∀ a, (e a).Bounds (T a) (C a) (H a) L (K a)) + {D E : ℝ} (hE : 0 ≤ E) (hA : (Fintype.card A : ℝ) ≤ D) + (hperiod : ∀ a, C a ≤ Real.exp E) : + (Fintype.card (∀ a, ZMod ((e a).period (k a))) : ℝ) ≤ Real.exp (D * E) := by + rw [gridResidueLabels_card] + apply (commonSitePeriod_le_pow e he hperiod k).trans + rw [← Real.exp_nat_mul] + exact Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hA hE) + +theorem gridSiteResidueLabels_card_le_exp [Fintype V] + {T C H K : A → ℝ} {L : ℝ≥0} (he : ∀ a, (e a).Bounds (T a) (C a) (H a) L (K a)) + {D DS E : ℝ} (hD : 0 ≤ D) (hE : 0 ≤ E) (hA : (Fintype.card A : ℝ) ≤ D) + (hS : (Fintype.card V : ℝ) ≤ DS) (hperiod : ∀ a, C a ≤ Real.exp E) : + (Fintype.card (V → ∀ a, ZMod ((e a).period (k a))) : ℝ) ≤ Real.exp (DS * D * E) := by + simp only [Fintype.card_fun, Nat.cast_pow] + exact (pow_le_exp_mul_of_le_exp (Nat.cast_nonneg _) + (gridResidueLabels_card_le_exp e k he hE hA hperiod) (mul_nonneg hD hE) _ hS).trans_eq + (congrArg Real.exp (by ring)) + +theorem gridResidueRefinement_coefficient_bound [Fintype V] + {T C H K : A → ℝ} {L : ℝ≥0} (he : ∀ a, (e a).Bounds (T a) (C a) (H a) L (K a)) + {D DS E Ec : ℝ} (hD : 0 ≤ D) (hE : 0 ≤ E) (hA : (Fintype.card A : ℝ) ≤ D) + (hS : (Fintype.card V : ℝ) ≤ DS) (hperiod : ∀ a, C a ≤ Real.exp E) + {J : Type*} [Fintype J] (c : J → ℂ) (hc : (∑ j, ‖c j‖) ≤ Real.exp Ec) : + (∑ _r : V → ∀ a, ZMod ((e a).period (k a)), ∑ j, ‖c j‖) ≤ Real.exp (DS * D * E + Ec) := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + exact (mul_le_mul (gridSiteResidueLabels_card_le_exp e k he hD hE hA hS hperiod) + hc (Finset.sum_nonneg (fun _ _ => norm_nonneg _)) (Real.exp_pos _).le).trans_eq + (Real.exp_add _ _).symm + +open Module Submodule + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (radius : ℝ≥0) (hradius : 0 < radius) + +include hradius in +theorem allocatedNormalizedGridIdealFactor_residue_product [Fintype V] + (label : V → ∀ a, ZMod ((e a).period (k a))) + (f : V → (LayerSamplerAxis I n → ℝ) → ℂ) (y : V → LayerSamplerAxis I n → ℝ) : + (∏ s, allocatedNormalizedGridIdealFactor B U b S e selected radius hradius k s (label s) (f s) (y s)) = + ∑ r : V → ∀ a, ZMod ((e a).period (k a)), ∏ s, + (if label s = r s then (1 : ℂ) else 0) * + allocatedNormalizedGridIdealFactor B U b S e selected radius hradius k s (r s) (f s) (y s) := by + exact residueSelectedSiteProduct label (fun r s => + allocatedNormalizedGridIdealFactor B U b S e selected radius hradius k s r (f s) (y s)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedGridlessMeasurableResidue.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedGridlessMeasurableResidue.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc94b8064baf9cc85fb41e3f9066b98407d005a6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedGridlessMeasurableResidue.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Sampling.AllocatedGridlessProfileBound + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped Classical + +theorem exists_measurable_fiber_family {A R Y : Type*} [MeasurableSpace Y] + (F : A → R) (f : A → Y → ℝ) (hf : ∀ a, Measurable (f a)) + (he : ∀ a b, F a = F b → f a = f b) : + ∃ P : R → Y → ℝ, (∀ r, Measurable (P r)) ∧ ∀ a, f a = P (F a) := by + let P (r : R) : Y → ℝ := if hr : ∃ a, F a = r then f hr.choose else fun _ => 0 + refine ⟨P, ?_, ?_⟩ + · intro r + dsimp only [P] + split_ifs with hr + · exact hf hr.choose + · exact measurable_const + · intro a + have ha : ∃ b, F b = F a := ⟨a, rfl⟩ + dsimp only [P] + rw [dite_eq_left ha] + exact he a ha.choose ha.choose_spec.symm + +end Erdos3 + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (y y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α + (allocatedPrincipalSides B U b S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "root" z => allocatedPhysicalCubeRoot B U b S (fun _ => 0) x z +local notation "dirs" z => allocatedPhysicalCubeDirections B U b S x z + +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {Q : Fin m → Type*} [∀ j, Fintype (Q j)] +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +theorem allocatedWholeMaskedGridlessProfile_measurable (M : ℕ) + (f : ((Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) → ℝ) → ℝ) + (hf : Measurable f) : + Measurable (allocatedWholeMaskedGridlessProfile B U b S x y rows hb o bW d M f) := by + unfold allocatedWholeMaskedGridlessProfile + apply allocatedGridlessCoveredProfile_measurable + exact allocatedLongProfileDensity_measurable B U b S x rows M _ f hf + +theorem exists_allocatedWholeMaskedGridlessProfile_measurable_by_residue (M : ℕ) + (hperiod : ∀ j, integerScalarLattice (O j) (M : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (f : ((Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) → ℝ) → ℝ) + (hf : Measurable f) : + ∃ P : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod M) → + EuclideanJetLayers U O → ℝ, + (∀ r, Measurable (P r)) ∧ + ∀ z : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S), + allocatedWholeMaskedGridlessProfile B U b S x z rows hb o bW d M f = + P (principalResidueLabel M z) := by + exact exists_measurable_fiber_family (principalResidueLabel M) + (fun z => allocatedWholeMaskedGridlessProfile B U b S x z rows hb o bW d M f) + (fun z => allocatedWholeMaskedGridlessProfile_measurable B U b S x z rows hb o bW d M f hf) + (fun z w h => allocatedWholeMaskedGridlessProfile_eq B U b S x z w rows hb o bW d M hperiod h f) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIdealResidueData.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIdealResidueData.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fe4c33e382f29a17275283b5ed0e24ec3dc2f9a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIdealResidueData.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedAveragedCoarseKernelComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +omit [DecidableEq G] in +theorem allocatedIdealScale_refined_window_size {dim : ℕ} {D p e w E P : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (he : 0 ≤ e) (hw : 0 ≤ w) (hE : 0 ≤ E) + (hP : 0 ≤ P) (hbudget : (m + 1 : ℕ) * P + P ^ 2 + (dim + 1 : ℕ) ≤ p) + {M modulus : ℕ} (hmodulus : modulus ≤ M ^ (m + 1)) (hM : (M : ℝ) ≤ Real.exp P) + {X : Type*} [Fintype X] (hX : (Fintype.card X : ℝ) ≤ P) + (q : X → ℕ) (hq : ∀ x, (q x : ℝ) ≤ Real.exp P) : + let S := allocatedIdealScale (G := G) B U b hR hσ D p e w E + ∀ a, (Fintype.card (Fin dim) + 1) * residueRefinedPeriod modulus q ≤ + principalAxisLength (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S) a := by + intro S a + have hmod : (modulus : ℝ) ≤ Real.exp ((m + 1 : ℕ) * P) := by + calc + _ ≤ (M : ℝ) ^ (m + 1) := by exact_mod_cast hmodulus + _ ≤ (Real.exp P) ^ (m + 1) := pow_le_pow_left₀ (Nat.cast_nonneg _) hM _ + _ = _ := (Real.exp_nat_mul P (m + 1)).symm + have hrefined := residueRefinedPeriod_exp_bound modulus q hmod hq + have hdim : ((dim + 1 : ℕ) : ℝ) ≤ Real.exp (dim + 1 : ℕ) := by + linarith [Real.add_one_le_exp ((dim + 1 : ℕ) : ℝ)] + have hcost : ((dim + 1 : ℕ) : ℝ) + ((m + 1 : ℕ) * P + Fintype.card X * P) ≤ p := by + nlinarith [mul_le_mul_of_nonneg_right hX hP] + have hsize : ((dim + 1 : ℕ) : ℝ) * residueRefinedPeriod modulus q ≤ (S.value : ℝ) := by + calc + _ ≤ Real.exp (dim + 1 : ℕ) * Real.exp ((m + 1 : ℕ) * P + Fintype.card X * P) := + mul_le_mul hdim hrefined (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = Real.exp (((dim + 1 : ℕ) : ℝ) + ((m + 1 : ℕ) * P + Fintype.card X * P)) := + (Real.exp_add _ _).symm + _ ≤ Real.exp p := Real.exp_le_exp.mpr hcost + _ ≤ _ := allocatedIdealScale_ge_exp B U b hR hσ hD hp he hw hE + rw [allocatedPrincipalSides_long_restricted] + simpa only [Fintype.card_fin] using (show (dim + 1) * residueRefinedPeriod modulus q ≤ S.value by + exact_mod_cast hsize) + +variable [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S + +omit [DecidableEq G] [∀ j, Fintype (O j)] in +theorem allocated_refined_residue_data {modulus refined : ℕ} + (hRefined : 0 < refined) (hdiv : modulus ∣ refined) + (hsize : ∀ a, (Fintype.card α + 1) * refined ≤ + principalAxisLength (fun a => ¬grid a) sides a) : + ∃ (reference : PrincipalAxisTuples (α := α) grid sides → + (PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod refined) → + PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + (residue : PrincipalAxisTuples (α := α) grid sides → + (PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod refined) → + ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + (∀ u r, principalResidueLabel refined (reference u r) = r) ∧ + (∀ u r v, (allocatedLongResidueWeights B U b S refined hRefined r hsize).weight v ≠ 0 → + ∀ j, integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) modulus = + residue u r j) := by + choose representative hrepresentative using + (fun r => exists_allocatedLongResidueReference (α := α) B U b S refined hRefined r hsize) + let residue := fun (u : PrincipalAxisTuples (α := α) grid sides) r j => integerResidueMatrix + (integerMappedJetMatrix (allocatedNonkernelExponent B j) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (rows j) (principalResidueLift refined r)) modulus + refine ⟨fun _ r => representative r, residue, fun _ r => hrepresentative r, ?_⟩ + intro u r v hv j + apply integerResidueMatrix_reduce _ _ hdiv + exact allocatedLongResidueWeights_matrix B U b S refined hRefined r hsize x u rows + (principalResidueLift refined r) (principalResidueLift_spec refined r) j v hv + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedInactiveResidueScale.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedInactiveResidueScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ab4b1982c7e49f5517cf4c2e34df2eaab4636ab --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedInactiveResidueScale.lean @@ -0,0 +1,164 @@ +import OAI.Combinatorics.Progressions.Probability.PrincipalSupportedUnitBlockLaw + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (j : Fin m) (i : Fin (n j)) (q : ℕ) (hq : 0 < q) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hsize : ∀ (a : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)), + (Fintype.card α + 1) * q ≤ allocatedPrincipalSides B U b S ⟨⟨j, Sum.inr i⟩, a, v⟩) + +noncomputable def allocatedLocalResidueSources + (a : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)) : NormalizedScalarCubeSource α := + principalSupportedAxisSources B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + q hq r ⟨j, Sum.inr i⟩ hsize a v + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedLocalResidueSources_length (a : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)) : + (allocatedLocalResidueSources B U b S j i q hq r hsize a v).length = + integerAxisSideLength (j.val + 1) (basisAxisScale (b j) i) S.value + (principalProfileSize (R j) (layerIntegerPrincipalSlots (G := G) B j i).card) := by + rw [layerIntegerPrincipalSlots_card] + rfl + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedLocalResidueSources_primitive + (a : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)) (A : ℝ≥0) : + ScalarCubePrimitiveBudget (allocatedLocalResidueSources B U b S j i q hq r hsize a v) + A (scalarCubePrimitiveEnvelope α A 1 0 q) := + principalSupportedAxisSources_primitive B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + q hq r ⟨j, Sum.inr i⟩ hsize a v A + +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedInactivePrincipalPMF + (hsmall : basisAxisScale (b j) i ≤ S.value ^ (j.val + 1)) (a : B ⟨j, Sum.inr i⟩) : + allocatedLayerIntegerPMFs B U b hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ a) = + PMF.pure (inactivePrincipalCoefficient (basisAxisScale (b j) i) + (inactiveDenominator (principalProfileSize (R j) (layerIntegerPrincipalSlots (G := G) B j i).card))) := by + have hmem : principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ a ∈ + layerIntegerPrincipalSlots (G := G) B j i := (mem_principalCoefficientSlots _ _ _).mpr ⟨a, rfl⟩ + have hne : principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ a ≠ + constantCoefficientSlot (LayerSamplerVariables G I n B) (j.val + 1) := by + intro he + exact (layerIntegerPrincipalSlots_not_constant B j i) (he ▸ hmem) + simp only [allocatedLayerIntegerPMFs, allocatedProjectionPMFs, + allocatedIntegerPolynomialCoordinatePMF, integerPolynomialCoordinatePMF] + split_ifs with hc hp + · exact False.elim (hne hc) + · exact integerAxisPrincipalPMF_inactive (Nat.zero_lt_succ _) + (basisAxisScale_pos (b j) i) S.positive (principalProfileSize_pos (hR j) _) (S.gap j i) hsmall + · exact False.elim (hp hmem) + +theorem allocatedInactiveResidueJetPMF_source + (hsmall : basisAxisScale (b j) i ≤ S.value ^ (j.val + 1)) + (hlarge : 2 * inactiveDenominator + (principalProfileSize (R j) (layerIntegerPrincipalSlots (G := G) B j i).card) ≤ basisAxisScale (b j) i) + (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + (rows : Finset (Finset α)) (shift : rows → ℤ) : + let s := allocatedLocalResidueSources B U b S j i q hq r hsize + (weightedCubeIntegerSource s).toPMF.map (weightedCubeIntegerJetSum s rows shift) = + allocatedSupportedResidueJetPMF B U b hR hσ S q r hcell j i rows shift := by + have hcoeff : (dependentProductPMF (fun a : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U b hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ a))) = + PMF.pure (fun _ : B ⟨j, Sum.inr i⟩ => (1 : ℤ)) := by + ext c + rw [dependentProductPMF_apply] + simp_rw [allocatedInactivePrincipalPMF B U b S j i hR hσ hsmall, inactivePrincipal_large hlarge] + by_cases hc : c = fun _ => (1 : ℤ) + · subst c + simp + · obtain ⟨a, ha⟩ : ∃ a, c a ≠ 1 := by + by_contra hn + apply hc + funext a + exact not_not.mp (fun h => hn ⟨a, h⟩) + rw [PMF.pure_apply_of_ne _ _ hc] + exact Finset.prod_eq_zero (Finset.mem_univ a) (PMF.pure_apply_of_ne _ _ ha) + unfold allocatedSupportedResidueJetPMF + rw [hcoeff, PMF.pure_bind] + simp only [one_mul] + exact principalSupportedResidue_unit_block_law B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + q hq r ⟨j, Sum.inr i⟩ hsize hcell rows shift + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (j : Fin m) (i : Fin (n j)) (q : ℕ) (hq : 0 < q) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hsize : ∀ (a : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)), + (Fintype.card α + 1) * q ≤ allocatedPrincipalSides B U b S ⟨⟨j, Sum.inr i⟩, a, v⟩) + +local notation "height" => basisAxisScale (b j) i +local notation "degree" => Fin.val j + 1 +local notation "denom" => inactiveDenominator + (principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i))) +local notation "source" => allocatedLocalResidueSources B U b S j i q hq r hsize + +theorem allocatedInactiveResidueSources_scale + (hsmall : height ≤ S.value ^ degree) (hlarge : 2 * denom ≤ height) : + (∀ a, (∏ v, ((source a v).length : ℝ)) ≤ height) ∧ + (∀ a, (height : ℝ) ≤ ((denom : ℝ) * 2 ^ degree) * ∏ v, ((source a v).length : ℝ)) ∧ + (∀ a v, (height : ℝ) ≤ ((denom : ℝ) * 2 ^ degree) * ((source a v).length : ℝ) ^ degree) := by + let T := inactiveSideLength degree height denom + have hlen (a : B ⟨j, Sum.inr i⟩) (v : Fin degree) : (source a v).length = T := by + rw [allocatedLocalResidueSources_length] + simp only [integerAxisSideLength, Nat.not_lt.mpr hsmall, ite_false, T] + have hprod (a : B ⟨j, Sum.inr i⟩) : (∏ v, ((source a v).length : ℝ)) = (T : ℝ) ^ degree := by + simp only [hlen, Finset.prod_const, Finset.card_univ, Fintype.card_fin] + have hu : T ^ degree ≤ height := + (inactiveSideLength_power (Nat.zero_lt_succ _) hlarge).trans (Nat.div_le_self _ _) + have hl : height ≤ denom * 2 ^ degree * T ^ degree := + (inactiveSideLength_lower_power (Nat.zero_lt_succ _) (inactiveDenominator_pos _) hlarge).le + refine ⟨?_, ?_, ?_⟩ + · intro a + rw [hprod] + exact_mod_cast hu + · intro a + rw [hprod] + exact_mod_cast hl + · intro a v + rw [hlen] + exact_mod_cast hl + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerJet.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerJet.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f8093f7f084b72e05c6312d22c7e1be4a396a3a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerJet.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedScalarLogBounds + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem allocatedIntegerJet_bound {J V α O : Type*} [Fintype J] [DecidableEq α] + (P : Finset J) (j₀ : J) (h K L s : ℕ) (hh : 0 < h) (hK : 0 < K) (hL : 0 < L) + (T : V → ℝ) (hT : ∀ v, 0 < T v) (hTL : ∀ v, T v ≤ L) + (e : J → V →₀ ℕ) (he : ∀ j, (e j).sum (fun _ n => n) ≤ s) + (R σ : ℝ) (hR : 0 < R) (hσ : 0 < σ) + (hgap : L^h < K → (principalSamplingGapRatio (principalProfileSize R P.card)*L)^h ≤ K) + (hεL : 8*(probabilityProfileLipschitz : ℝ) ≤ tailProfileSize R σ (Fintype.card J)*L) + (hj₀ : j₀ ∉ P) (he₀ : e j₀ = 0) (hσ1 : σ ≤ 1) + (hprincipal : ∀ j ∈ P, monomialScale T (e j) = + (integerAxisSideLength h K L (principalProfileSize R P.card) : ℝ)^h) + (a : J → ℤ) (ha : ∀ j, a j ∈ (allocatedIntegerPolynomialCoordinatePMF P j₀ h K L s + hh hK hL T hT hTL e he R σ hR hσ hgap hεL j).support) + (vertices : Finset α → V → ℤ) (rows : O → Finset α) (o : O) (q : ℕ) + (hrows : (rows o).card ≤ q) + (hx : ∀ t ∈ (rows o).powerset, ∀ v, |(vertices t v : ℝ)| ≤ T v) : + |((integerJetMatrix (fun j => MvPolynomial.monomial (e j) (1 : ℤ)) vertices rows *ᵥ a) o : ℝ)| ≤ + 2^q*(3*R/4)*(K : ℝ) := by + let f := fun t => MvPolynomial.eval (vertices t) (integerMonomialArrayPolynomial e a) + have hv (t) (ht : t ∈ (rows o).powerset) : |(f t : ℝ)/(K : ℝ)| ≤ 3*R/4 := + allocatedIntegerPolynomial_integer_box P j₀ h K L s hh hK hL T hT hTL e he + R σ hR hσ hgap hεL hj₀ he₀ hσ1 hprincipal a ha (vertices t) (hx t ht) + have hb := booleanCoefficient_abs_le (fun t => (f t : ℝ)/(K : ℝ)) (rows o) hv + rw [booleanCoefficient_div] at hb + have hc := booleanCoefficient_map (Int.castRingHom ℝ) f (rows o) + simp only [Int.coe_castRingHom] at hc + rw [← hc, abs_div, abs_of_pos (show (0 : ℝ) < K by exact_mod_cast hK)] at hb + have hj : (integerJetMatrix (fun j => MvPolynomial.monomial (e j) (1 : ℤ)) vertices rows *ᵥ a) o = + booleanCoefficient f (rows o) := by + simpa only [f, MvPolynomial.C_mul_monomial, mul_one, integerMonomialArrayPolynomial] using + integerJetMatrix_apply_coefficients (fun j => MvPolynomial.monomial (e j) (1 : ℤ)) vertices rows a o + rw [hj] + exact ((div_le_iff₀ (show (0 : ℝ) < K by exact_mod_cast hK)).mp hb).trans + (by gcongr; norm_num) + +noncomputable def allocatedIntegerJetRadius (q : ℕ) (R : ℝ) : ℕ := ⌈(2 : ℝ)^q*(3*R/4)⌉₊ + +theorem allocatedIntegerJetRadius_le_exp (q : ℕ) {R r : ℝ} + (hR : 0 ≤ R) (hr : 0 ≤ r) (hRr : R ≤ Real.exp r) : + (allocatedIntegerJetRadius q R : ℝ) ≤ Real.exp (q+r+1) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hraw : (2 : ℝ)^q*(3*R/4) ≤ Real.exp (q+r) := by + calc + _ ≤ (Real.exp 1)^q*Real.exp r := by + apply mul_le_mul (pow_le_pow_left₀ (by norm_num) htwo q) (by linarith) + (by positivity) (by positivity) + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add]; simp only [mul_one] + exact natCeil_le_exp_succ (by positivity) (by positivity) hraw + +namespace VectorPolynomial + +theorem allocatedLayerIntegerJet_bound {m : ℕ} {G : Type*} [Fintype G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) (hσ1 : ∀ j, σ j ≤ 1) + (j : Fin m) (i : Fin (n j)) + (a : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) → ℤ) + (ha : ∀ d, a d ∈ (allocatedLayerIntegerPMFs B U basis hR hσ S j i d).support) + {α O : Type*} [DecidableEq α] + (vertices : Finset α → LayerSamplerVariables G I n B → ℤ) (rows : O → Finset α) + (o : O) (q : ℕ) (hrows : (rows o).card ≤ q) + (hx : ∀ t ∈ (rows o).powerset, ∀ v, |(vertices t v : ℝ)| ≤ layerSamplerBox B U basis S v) : + |((integerJetMatrix (fun d => MvPolynomial.monomial d.val (1 : ℤ)) vertices rows *ᵥ a) o : ℝ)| ≤ + 2^q*(3*R j/4)*(basisAxisScale (basis j) i : ℝ) := by + exact allocatedIntegerJet_bound (layerIntegerPrincipalSlots (G := G) B j i) + (constantCoefficientSlot _ _) (j.val+1) (basisAxisScale (basis j) i) S.value (layerTailDegree m) + (Nat.zero_lt_succ _) (basisAxisScale_pos (basis j) i) S.positive + (layerSamplerBox B U basis S) + (fun v => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S v)) + (layerSamplerBox_le B U basis S) Subtype.val + (fun d => d.property.trans (layerDegree_le_tailDegree j)) + (R j) (σ j) (hR j) (hσ j) (S.gap j i) (S.width j) + (layerIntegerPrincipalSlots_not_constant B j i) rfl (hσ1 j) + (layerSamplerSides_integer_principal B U basis R S.value j i) a ha vertices rows o q hrows hx + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerKernelComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerKernelComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c241c35228242ecfe104ae0b58076141fed4b892 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerKernelComparison.lean @@ -0,0 +1,362 @@ +import OAI.Combinatorics.Progressions.Estimates.JointPrincipalCoefficientComparison +import OAI.Combinatorics.Progressions.Linear.AllocatedKernelScaleWithCutoff + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable (v : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) +local notation "fixedInteger" => Sum.elim + (fun ga : G × Option α => (x (Prod.fst ga) (Prod.snd ga) : ℤ)) (principalTupleIntegers u) + +noncomputable def allocatedPartitionedJetMatrix (j : Fin m) : + Matrix (O j) (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) ℤ := + integerMappedJetMatrix Subtype.val input fixedInteger (rows j) (principalTupleIntegers v) + +noncomputable def allocatedIntegerKernelPMF (j : Fin m) (i : Fin (n j)) (hσ1 : σ j ≤ 1) + (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) : PMF (O j → ℤ) := + (allocatedEnormousProfilePMF B U basis hR hσ S j i hσ1 henormous).map + (fun a => allocatedPartitionedJetMatrix B U basis S x u v rows j *ᵥ a) + +theorem allocatedIntegerKernelPMF_law [∀ j, Fintype (O j)] + (j : Fin m) (i : Fin (n j)) (hσ1 : σ j ≤ 1) + (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) : + (allocatedCoefficientAxisLaw B U basis hR hσ S ⟨j, Sum.inr i⟩).map + (fun a => allocatedPartitionedJetMatrix B U basis S x u v rows j *ᵥ a) = + (allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i hσ1 henormous).toMeasure := + allocatedEnormous_image_law B U basis hR hσ S j i hσ1 henormous + (allocatedPartitionedJetMatrix B U basis S x u v rows j) + +variable (j : Fin m) (i : Fin (n j)) (hσ1 : σ j ≤ 1) +variable (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) + +local notation "centers" => allocatedIntegerProfileCenters (G := G) B R j i +local notation "widths" => allocatedIntegerProfileWidths (G := G) B R σ j i +local notation "scales" => allocatedIntegerProfileScales B U basis S j i +local notation "reindex" => allocatedKernelCoefficientEquiv (G := G) B j + +theorem allocatedIntegerKernelPMF_reindexed : + allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i hσ1 henormous = + coefficientImagePMF + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) (rows j)) + (integerMappedJetMatrix (allocatedNonkernelExponent B j) input fixedInteger (rows j) + (principalTupleIntegers v))) + (affineProductProfile (centers ∘ reindex) (widths ∘ reindex)) + (affineProductProfile_nonneg _ _ (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d))) + (scales ∘ reindex) (fun d => allocatedIntegerProfileScales_pos B U basis S j i (reindex d)) + (affineProductProfile_zero_outside _ _ + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) (hR j).le + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d))) + (allocatedKernelProfile_sum_pos B U basis hR hσ S j i hσ1 henormous) := by + have he := coefficientImagePMF_affine_reindex (allocatedPartitionedJetMatrix B U basis S x u v rows j) + reindex centers widths scales (allocatedIntegerProfileWidths_pos B hR hσ j i) + (allocatedIntegerProfileScales_pos B U basis S j i) (hR j).le + (allocatedKernelProfile_bound B hR hσ j i hσ1) + (allocatedEnormous_profile_sum_pos B U basis hR hσ S j i hσ1 henormous) + change coefficientImagePMF ((integerMappedJetMatrix _ _ _ _ _).submatrix id reindex) _ _ _ _ _ _ = _ at he + rw [allocatedKernelJet_split B U basis S j x (principalTupleIntegers u) (principalTupleIntegers v) (rows j)] at he + exact he.symm + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable (j : Fin m) (i : Fin (n j)) + +local notation "unitWidth" => allocatedUnitProfileWidth (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) + +include hR in +theorem allocatedIntegerProfileWidths_floor (d) : + unitWidth ≤ allocatedIntegerProfileWidths (G := G) B R σ j i d := + allocatedUnitProfileWidth_le _ _ (hR j) d + +local notation "centers" => allocatedIntegerProfileCenters (G := G) B R j i +local notation "widths" => allocatedIntegerProfileWidths (G := G) B R σ j i +local notation "reindex" => allocatedKernelCoefficientEquiv (G := G) B j +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +variable {α O : Type*} [Fintype α] [DecidableEq α] [Fintype O] [DecidableEq O] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent G (j.val+1)) +variable (hA : ((scalarKernelIntegerJet x (j.val+1) rows).submatrix id s).det ≠ 0) + +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) +local notation "fixedReal" => Sum.elim + (fun ga : G × Option α => ((x (Prod.fst ga) (Prod.snd ga) : ℤ) : ℝ) / (S.value : ℝ)) + (principalTupleNormalized (principalAxisLength grid sides) u) +local notation "height" => (basisAxisScale (basis j) i : ℝ) +local notation "heightPos" => Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) +local notation "kernelScale" => kernelJetCoefficientScale G (j.val+1) (S.value : ℝ) height +local notation "pivot" => normalizedPivotEquiv (Matrix.submatrix (scalarKernelIntegerJet x (j.val+1) rows) id s) hA + (fun o => kernelScale (s o)) (fun _ => height) + (fun o => kernelJetCoefficientScale_pos G (j.val+1) + (Nat.cast_pos.mpr (LayerSamplerScale.positive S)) heightPos (s o)) + (fun _ => heightPos) +local notation "free" => matrixSupCLM (normalizedIntegerColumns + (remainingMatrixColumns (scalarKernelIntegerJet x (j.val+1) rows) s) + (fun d => kernelScale (Subtype.val d)) (fun _ => height)) +local notation "radius" => NNReal.mk (R j) (le_of_lt (hR j)) +local notation "delta" => NNReal.mk unitWidth (le_of_lt (allocatedUnitProfileWidth_pos (hR j) (hσ j) _)) + +noncomputable def allocatedIntegerKernelDensity + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) : + (O → ℝ) → ℝ := + affineSelectedJetDensity s pivot free (allocatedNonkernelExponent B j) input fixedReal rows + (centers ∘ reindex) (widths ∘ reindex) y + +include hR hσ in +theorem allocatedIntegerKernelDensity_measurable (hσ1 : σ j ≤ 1) : + Measurable (Function.uncurry (allocatedIntegerKernelDensity B U basis S j i x u rows s hA)) := by + have hw (d) := allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d) + have hb (d) := allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d) + exact normalizedJetDensity_measurable pivot free (allocatedNonkernelExponent B j) input fixedReal rows + ((affineProductProfile_contDiff _ _).continuous.comp (selectedCoefficientEquiv_lipschitz s).continuous) + (affineProductProfile_contDiff _ _).continuous + (selectedCoefficientProfile_zero_outside s + (affineProductProfile_zero_outside _ _ (fun d => hw (.inl d)) (hR j).le (fun d => hb (.inl d)))) + (affineProductProfile_zero_outside _ _ (fun d => hw (.inr d)) (hR j).le (fun d => hb (.inr d))) + +include hR hσ in +theorem allocatedIntegerKernelDensity_probability_data (hσ1 : σ j ≤ 1) + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) : + (∀ z, 0 ≤ allocatedIntegerKernelDensity B U basis S j i x u rows s hA y z) ∧ + Integrable (allocatedIntegerKernelDensity B U basis S j i x u rows s hA y) ∧ + (∫ z, allocatedIntegerKernelDensity B U basis S j i x u rows s hA y z) = 1 := + affineSelectedJetDensity_probability_data s pivot free (allocatedNonkernelExponent B j) input fixedReal rows + (centers ∘ reindex) (widths ∘ reindex) + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) radius + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d)) y + +include hR hσ in +theorem allocatedIntegerKernelDensity_bounds (hσ1 : σ j ≤ 1) (z : O → ℝ) : + (∀ y, |allocatedIntegerKernelDensity B U basis S j i x u rows s hA y z| ≤ + pivotKernelCap (UnselectedColumn s) pivot radius + (delta⁻¹^Fintype.card (BoundedIntegerExponent G (j.val+1)))) ∧ + LipschitzOnWith + (pivotKernelLip (UnselectedColumn s) pivot radius + (affineProductProfileLip (BoundedIntegerExponent G (j.val+1)) delta) * + (Fintype.card (AllocatedNonkernelCoefficient (G := G) B j) * + polynomialBoxLip + (Fintype.card (PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a))) (j.val+1) (normalizedJetMass α (j.val+1))) * radius) + (fun y => allocatedIntegerKernelDensity B U basis S j i x u rows s hA y z) + (Metric.closedBall 0 1) := by + have hδ : 0 < delta := allocatedUnitProfileWidth_pos (hR j) (hσ j) _ + have he := affineSelectedJetDensity_bounds s pivot free (allocatedNonkernelExponent B j) + input fixedReal (allocatedPartitionedInput_frozen_bound B U basis S x u) rows + (allocatedNonkernelExponent_degree B j) (centers ∘ reindex) (widths ∘ reindex) + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) hδ + (fun d => allocatedIntegerProfileWidths_floor B hR j i (reindex (.inl d))) radius + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d)) z + simpa only [allocatedIntegerKernelDensity, Real.norm_eq_abs] using he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +theorem coefficientImagePMF_congr_scale {I J : Type*} [Fintype J] + (A : Matrix I J ℤ) (f : (J → ℝ) → ℝ) (hf : ∀ x, 0 ≤ f x) + {S T : J → ℝ} (hST : S = T) (hS : ∀ j, 0 < S j) (hT : ∀ j, 0 < T j) + {R : ℝ} (hsupport : ∀ x, R < ‖x‖ → f x = 0) + (hZS : 0 < coefficientWeightSum f S) (hZT : 0 < coefficientWeightSum f T) : + coefficientImagePMF A f hf S hS hsupport hZS = coefficientImagePMF A f hf T hT hsupport hZT := by + subst T + rfl + +end Erdos3 + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) (j : Fin m) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) +local notation "fixedInteger" => Sum.elim + (fun ga : G × Option α => (x (Prod.fst ga) (Prod.snd ga) : ℤ)) (principalTupleIntegers u) +local notation "fixedReal" => Sum.elim + (fun ga : G × Option α => ((x (Prod.fst ga) (Prod.snd ga) : ℤ) : ℝ) / (S.value : ℝ)) + (principalTupleNormalized (principalAxisLength grid sides) u) + +noncomputable def allocatedNonkernelJetMatrix + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) : + Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) ℤ := + integerMappedJetMatrix (allocatedNonkernelExponent B j) input fixedInteger (rows j) + (principalTupleIntegers v) + +noncomputable def allocatedIntegerKernelMask (modulus : ℕ) + (residue : Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) : + (O j → ℤ) → ℝ := + coefficientResidueMultiplier (scalarKernelIntegerJet x (j.val+1) (rows j)) residue + +variable (i : Fin (n j)) (s : O j ↪ BoundedIntegerExponent G (j.val+1)) +variable (hA : ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id s).det ≠ 0) +variable (hσ1 : σ j ≤ 1) (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) + +local notation "height" => (basisAxisScale (basis j) i : ℝ) +local notation "heightPos" => Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) +local notation "kernelScale" => kernelJetCoefficientScale G (j.val+1) (S.value : ℝ) height +local notation "nonkernelScale" => fun d => height / monomialScale (layerSamplerBox B U basis S) + (allocatedNonkernelExponent B j d) +local notation "centers" => allocatedIntegerProfileCenters (G := G) B R j i +local notation "widths" => allocatedIntegerProfileWidths (G := G) B R σ j i +local notation "reindex" => allocatedKernelCoefficientEquiv (G := G) B j +local notation "unitWidth" => allocatedUnitProfileWidth (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) +local notation "radius" => NNReal.mk (R j) (le_of_lt (hR j)) +local notation "delta" => NNReal.mk unitWidth (le_of_lt (allocatedUnitProfileWidth_pos (hR j) (hσ j) _)) + +omit [Fintype α] [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] in +theorem allocatedIntegerKernelPMF_split_scale + (hZ : 0 < coefficientWeightSum (affineProductProfile (centers ∘ reindex) (widths ∘ reindex)) + (Sum.elim kernelScale nonkernelScale)) + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) : + allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i hσ1 henormous = + coefficientImagePMF + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) (rows j)) + (allocatedNonkernelJetMatrix B U basis S x u rows j v)) + (affineProductProfile (centers ∘ reindex) (widths ∘ reindex)) + (affineProductProfile_nonneg _ _ (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d))) + (Sum.elim kernelScale nonkernelScale) + (Sum.rec (kernelJetCoefficientScale_pos G (j.val+1) (Nat.cast_pos.mpr S.positive) heightPos) + (fun _d => div_pos heightPos (monomialScale_pos _ + (fun k => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S k)) _))) + (affineProductProfile_zero_outside _ _ + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) (hR j).le + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d))) hZ := by + apply (allocatedIntegerKernelPMF_reindexed B U basis hR hσ S x u v rows j i hσ1 henormous).trans + exact coefficientImagePMF_congr_scale _ _ _ (allocatedKernelCoefficientScales_split B U basis S j i) _ _ _ _ _ + +variable [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable [DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedIntegerKernelDensity_of_matrix + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) : + kernelCoefficientDensity (scalarKernelIntegerJet x (j.val+1) (rows j)) s hA + kernelScale (fun _ => height) + (kernelJetCoefficientScale_pos G (j.val+1) (Nat.cast_pos.mpr S.positive) heightPos) + (fun _ => heightPos) (allocatedNonkernelJetMatrix B U basis S x u rows j v) nonkernelScale + (centers ∘ reindex) (widths ∘ reindex) = + allocatedIntegerKernelDensity B U basis S j i x u (rows j) s hA + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) := by + have hn := integerMappedCubeTuple_normalized input fixedInteger (principalTupleIntegers v) fixedReal + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (layerSamplerBox B U basis S) (allocatedPartitionedInput_normalized B U basis S x u v) + have he := kernelCoefficientDensity_eq_jet (scalarKernelIntegerJet x (j.val+1) (rows j)) s hA + kernelScale (kernelJetCoefficientScale_pos G (j.val+1) (Nat.cast_pos.mpr S.positive) heightPos) + heightPos (allocatedNonkernelExponent B j) input fixedReal (rows j) + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (integerMappedCubeTuple input fixedInteger (principalTupleIntegers v)) (layerSamplerBox B U basis S) + hn (centers ∘ reindex) (widths ∘ reindex) + refine he.trans ?_ + unfold allocatedIntegerKernelDensity + congr 3 + exact Subsingleton.elim _ _ + +theorem allocatedIntegerKernel_residue_family + (p : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides)) + (modulus : ℕ) + (residue : Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + (hperiod : integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) + (hresidue : ∀ v, p.weight v ≠ 0 → + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue) + {C V M b t ε : ℝ} (hC0 : 0 ≤ C) (hV0 : 0 ≤ V) (hM0 : 0 ≤ M) + (ctrl : ∀ v, p.weight v ≠ 0 → CoefficientFiberControl + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) (rows j)) + (allocatedNonkernelJetMatrix B U basis S x u rows j v)) + (s.trans Function.Embedding.inl) (Sum.elim kernelScale nonkernelScale) + height S.value (j.val+1) C V M) + (hb : 0 ≤ b) (ht : 0 ≤ t) (hε : 0 < ε) + (hM : M ≤ Real.exp b) (hV : V ≤ Real.exp b) (hC : C ≤ Real.exp b) + (hRb : R j ≤ Real.exp b) (hwidth : unitWidth⁻¹ ≤ Real.exp t) + (hlarge : coefficientReplacementScale + (J := BoundedIntegerExponent G (j.val+1) ⊕ AllocatedNonkernelCoefficient (G := G) B j) + (s.trans Function.Embedding.inl) b t ε S.value (j.val+1) ≤ height) : + (∀ z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus residue z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus residue z ≤ M) ∧ + ∀ v, p.weight v ≠ 0 → ∀ z, + |height^Fintype.card (O j) * + (allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i hσ1 henormous z).toReal - + allocatedIntegerKernelMask B U basis S x rows j modulus residue z * + allocatedIntegerKernelDensity B U basis S j i x u (rows j) s hA + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (fun o => (z o : ℝ)/height)| ≤ ε := by + have hscale := kernelJetCoefficientScale_pos G (j.val+1) (Nat.cast_pos.mpr S.positive) heightPos + have hT d : 0 < nonkernelScale d := div_pos heightPos + (monomialScale_pos _ (fun k => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S k)) _) + obtain ⟨hZ, hm, he⟩ := affineCoefficientImage_residue_family p + (scalarKernelIntegerJet x (j.val+1) (rows j)) s hA + (allocatedNonkernelJetMatrix B U basis S x u rows j) kernelScale nonkernelScale hscale hT + (j.val+1) ctrl (Nat.cast_pos.mpr S.positive) heightPos hC0 hV0 hM0 + (centers ∘ reindex) (widths ∘ reindex) + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) + (show 0 < delta from allocatedUnitProfileWidth_pos (hR j) (hσ j) _) + (fun d => allocatedIntegerProfileWidths_floor B hR j i (reindex d)) radius + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d)) + hb ht hε hM hV hC hRb hwidth hlarge modulus residue hperiod hresidue + refine ⟨hm, ?_⟩ + intro v hv z + rw [allocatedIntegerKernelPMF_split_scale B U basis hR hσ S x u rows j i hσ1 henormous hZ v, + ← allocatedIntegerKernelDensity_of_matrix B U basis S x u rows j i s hA v] + exact he v hv z + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerSupport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b068459758941954043b611478b927cb6695d07 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerSupport.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedJetSupportBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped Matrix Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable (v : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) + +theorem allocatedIntegerKernelPMF_zero_off_box (j : Fin m) (i : Fin (n j)) + (hσ1 : σ j ≤ 1) (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) + {P : ℝ} (hP : 0 ≤ P) (hRP : R j ≤ Real.exp P) (z : O j → ℤ) + (hz : z ∉ rectangularWeightIndices (fun _ => 0) (fun _ => (basisAxisScale (basis j) i : ℝ)) + (Real.exp (allocatedJetSupportLog (G := G) B α O P))) : + allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i hσ1 henormous z = 0 := by + exact coefficientImagePMF_zero_off_box (allocatedPartitionedJetMatrix B U basis S x u v rows j) + (allocatedIntegerProfileScales B U basis S j i) (fun _ => (basisAxisScale (basis j) i : ℝ)) + (allocatedIntegerProfileScales_pos B U basis S j i) + (fun _ => Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i)) + (affineProductProfile (allocatedIntegerProfileCenters (G := G) B R j i) + (allocatedIntegerProfileWidths B R σ j i)) + (affineProductProfile_nonneg _ _ (allocatedIntegerProfileWidths_pos B hR hσ j i)) + (allocatedIntegerProfile_support B hR hσ j i hσ1) + (allocatedEnormous_profile_sum_pos B U basis hR hσ S j i hσ1 henormous) + (allocatedPartitionedJet_radius_bound B U basis S x u v rows j i hP (hR j).le hRP) z hz + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerTailZero.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerTailZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..e36c3e210e82c2d99ec9a6071b9d0b8c3f7865a0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedIntegerTailZero.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedScalarLogBounds + +namespace OAI + +section + +namespace Erdos3 + +section Coordinate + +variable {J V : Type*} [Fintype J] +variable (P : Finset J) (j₀ : J) (h K L s : ℕ) +variable (hh : 0 < h) (hK : 0 < K) (hL : 0 < L) +variable (T : V → ℝ) (hT : ∀ v, 0 < T v) (hTL : ∀ v, T v ≤ L) +variable (e : J → V →₀ ℕ) (he : ∀ j, (e j).sum (fun _ n => n) ≤ s) +variable (R σ : ℝ) (hR : 0 < R) (hσ : 0 < σ) +variable (hgap : L^h < K → (principalSamplingGapRatio (principalProfileSize R P.card)*L)^h ≤ K) +variable (hεL : 8*(probabilityProfileLipschitz : ℝ) ≤ tailProfileSize R σ (Fintype.card J)*L) + +local notation "laws" => allocatedIntegerPolynomialCoordinatePMF P j₀ h K L s hh hK hL T hT hTL + e he R σ hR hσ hgap hεL + +theorem allocatedIntegerCoordinate_tail_pure (hsmall : K ≤ L^(s+1)) + (j : J) (hj₀ : j ≠ j₀) (hjP : j ∉ P) : laws j = PMF.pure 0 := by + classical + unfold allocatedIntegerPolynomialCoordinatePMF integerPolynomialCoordinatePMF + simp only [hj₀, hjP, ↓reduceIte] + exact integerAxisTailPMF_small T hT hK hL hTL (tailProfileSize_pos hR hσ _) hεL (e j) (he j) hsmall + +theorem allocatedIntegerCoordinate_tail_zero (hsmall : K ≤ L^(s+1)) + (j : J) (hj₀ : j ≠ j₀) (hjP : j ∉ P) {k : ℤ} (hk : k ∈ (laws j).support) : k = 0 := by + rw [allocatedIntegerCoordinate_tail_pure P j₀ h K L s hh hK hL T hT hTL e he R σ hR hσ + hgap hεL hsmall j hj₀ hjP] at hk + simpa only [PMF.support_pure, Set.mem_singleton_iff] using hk + +theorem allocatedIntegerCoordinate_principal_inactive (hsmall : K ≤ L^h) + (j : J) (hj₀ : j ≠ j₀) (hjP : j ∈ P) {k : ℤ} (hk : k ∈ (laws j).support) : + k = inactivePrincipalCoefficient K (inactiveDenominator (principalProfileSize R P.card)) := by + classical + unfold allocatedIntegerPolynomialCoordinatePMF integerPolynomialCoordinatePMF at hk + simp only [hj₀, hjP, ↓reduceIte] at hk + rw [integerAxisPrincipalPMF_inactive hh hK hL (principalProfileSize_pos hR _) hgap hsmall] at hk + exact inactivePrincipalPMF_support hk + +end Coordinate + +namespace VectorPolynomial + +theorem allocatedLayerInteger_inactive_structure {m : ℕ} {G : Type*} [Fintype G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) (j : Fin m) (i : Fin (n j)) + (hsmall : basisAxisScale (basis j) i ≤ S.value^(j.val+1)) + (a : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) → ℤ) + (ha : ∀ d, a d ∈ (allocatedLayerIntegerPMFs B U basis hR hσ S j i d).support) : + (∀ d, d ≠ constantCoefficientSlot _ _ → d ∉ layerIntegerPrincipalSlots B j i → a d = 0) ∧ + ∀ d ∈ layerIntegerPrincipalSlots B j i, + a d = inactivePrincipalCoefficient (basisAxisScale (basis j) i) + (inactiveDenominator (principalProfileSize (R j) (layerIntegerPrincipalSlots (G := G) B j i).card)) := by + have hpow : basisAxisScale (basis j) i ≤ S.value^(layerTailDegree m+1) := + hsmall.trans (Nat.pow_le_pow_right S.positive + ((layerDegree_le_tailDegree j).trans (Nat.le_succ _))) + have hconst := layerIntegerPrincipalSlots_not_constant (G := G) B j i + constructor + · intro d hd₀ hdP + exact allocatedIntegerCoordinate_tail_zero (layerIntegerPrincipalSlots B j i) + (constantCoefficientSlot _ _) (j.val+1) (basisAxisScale (basis j) i) S.value (layerTailDegree m) + (Nat.zero_lt_succ _) (basisAxisScale_pos (basis j) i) S.positive + (layerSamplerBox B U basis S) + (fun v => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S v)) + (layerSamplerBox_le B U basis S) Subtype.val + (fun d => d.property.trans (layerDegree_le_tailDegree j)) + (R j) (σ j) (hR j) (hσ j) (S.gap j i) (S.width j) hpow d hd₀ hdP (ha d) + · intro d hd + have hd₀ : d ≠ constantCoefficientSlot _ _ := fun he => hconst (he ▸ hd) + exact allocatedIntegerCoordinate_principal_inactive (layerIntegerPrincipalSlots B j i) + (constantCoefficientSlot _ _) (j.val+1) (basisAxisScale (basis j) i) S.value (layerTailDegree m) + (Nat.zero_lt_succ _) (basisAxisScale_pos (basis j) i) S.positive + (layerSamplerBox B U basis S) + (fun v => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S v)) + (layerSamplerBox_le B U basis S) Subtype.val + (fun d => d.property.trans (layerDegree_le_tailDegree j)) + (R j) (σ j) (hR j) (hσ j) (S.gap j i) (S.width j) hsmall d hd₀ hd (ha d) + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointPlateauResidue.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointPlateauResidue.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e25a53bf9655095568ba4aa79332db4eefa64e9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointPlateauResidue.lean @@ -0,0 +1,144 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedJointWindowIntegral + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) [NeZero q] + +local notation "tuples" => principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) + +variable (rowFamily : (Σ j : Fin m, Fin (n j)) → Finset (Finset α)) +variable {A : Type*} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) (x : G → IntegerScalarCubeBox α S.value) +variable (P δ : ℝ) + +local notation "rows" => fun a : A => rowFamily (selected a) +local notation "axisK" => fun a : A => basisAxisScale (basis (Sigma.fst (selected a))) (Sigma.snd (selected a)) +local notation "axisN" => fun a : A => allocatedPrincipalGridScale (G := G) B U basis (R := R) + (Sigma.fst (selected a)) (Sigma.snd (selected a)) +local notation "axisGamma" => fun a : A => principalProfileSize (R (Sigma.fst (selected a))) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (Sigma.fst (selected a)) (Sigma.snd (selected a)))) +local notation "accuracy" => allocatedGridFamilyAccuracy B rowFamily P δ + +local notation "jointLaw" => fun y => dependentProductPMF (fun a : A => + integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) ((Fin.val (Sigma.fst (selected a))) + 1) + (fun t : (rows) a => (t : Finset α))) + (allocatedLayerIntegerPMFs B U basis hR hσ S (Sigma.fst (selected a)) (Sigma.snd (selected a)))) + +theorem allocatedJointPlateau_residue_weighted_error + (hP : 1 ≤ P) (hδ : 0 < δ) (hselected : Function.Injective selected) + (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value + ⟨(selected a).1, Sum.inr (selected a).2⟩) + (hactive : ∀ a, S.value ^ ((selected a).1.val + 1) < (axisK) a) + (hgamma : ∀ a, (axisGamma) a ≤ S.value) + (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α L 1 0 q ≤ P) + (M : A → ℕ) [∀ a, NeZero (M a)] + (hM : ∀ a, M a = allocatedGridTorusFactor B α (selected a) * (axisN) a) + (hrows : ∀ a t, t ∈ (rows) a → t.card ≤ (selected a).1.val + 1) + (hB : ∀ a, positiveModerateSpectrumBlockCount (selected a).1.val ((rows) a).card + ((layerTailDegree m + 2) * ((rows) a).card) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) + (test : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) → ℂ) + (z : ∀ a, (rows) a → ℤ) : + ‖(tuples).complexMean (fun y => test (principalResidueLabel q y) * + (((∏ a, ((axisN) a : ℝ) ^ ((rows) a).card) * ((jointLaw y) z).toReal : ℝ) : ℂ)) - + ((tuples).fiberLaw (principalResidueLabel q)).complexMean (fun r => test r * + ∏ a, allocatedBudgetedPlateauApproximation B U basis hR hσ S q r + (selected a).1 (selected a).2 (hactive a) hq hsize P accuracy (M a) ((rows) a) (z a))‖ ≤ + δ * ((tuples).fiberLaw (principalResidueLabel q)).mean (fun r => ‖test r‖) := by + apply (tuples).complexMean_supported_fiber_weighted_error (principalResidueLabel q) + intro r hr + have hc := ((tuples).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hr).toPMF_bind_scaled_complexMean + (jointLaw) (∏ a, ((axisN) a : ℝ) ^ ((rows) a).card) z + have he := allocatedJointPlateau_family_error B U basis hR hσ S q r hr rowFamily selected x P δ + hP hδ hselected hgrid hactive hgamma hq hsize L hL hcP hsP M hM hrows hB z + exact (congrArg (fun w : ℂ => ‖w - + ∏ a, allocatedBudgetedPlateauApproximation B U basis hR hσ S q r + (selected a).1 (selected a).2 (hactive a) hq hsize P accuracy (M a) ((rows) a) (z a)‖) hc).trans_le he + +theorem allocatedJointPlateau_residue_test_error + (hP : 1 ≤ P) (hδ : 0 < δ) (hselected : Function.Injective selected) + (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value + ⟨(selected a).1, Sum.inr (selected a).2⟩) + (hactive : ∀ a, S.value ^ ((selected a).1.val + 1) < (axisK) a) + (hgamma : ∀ a, (axisGamma) a ≤ S.value) + (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α L 1 0 q ≤ P) + (M : A → ℕ) [∀ a, NeZero (M a)] + (hM : ∀ a, M a = allocatedGridTorusFactor B α (selected a) * (axisN) a) + (hrows : ∀ a t, t ∈ (rows) a → t.card ≤ (selected a).1.val + 1) + (hB : ∀ a, positiveModerateSpectrumBlockCount (selected a).1.val ((rows) a).card + ((layerTailDegree m + 2) * ((rows) a).card) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) + (test : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) → ℂ) + (htest : ∀ r, ‖test r‖ ≤ 1) (z : ∀ a, (rows) a → ℤ) : + ‖(tuples).complexMean (fun y => test (principalResidueLabel q y) * + (((∏ a, ((axisN) a : ℝ) ^ ((rows) a).card) * ((jointLaw y) z).toReal : ℝ) : ℂ)) - + ((tuples).fiberLaw (principalResidueLabel q)).complexMean (fun r => test r * + ∏ a, allocatedBudgetedPlateauApproximation B U basis hR hσ S q r + (selected a).1 (selected a).2 (hactive a) hq hsize P accuracy (M a) ((rows) a) (z a))‖ ≤ δ := by + have he := allocatedJointPlateau_residue_weighted_error B U basis hR hσ S q rowFamily selected x P δ + hP hδ hselected hgrid hactive hgamma hq hsize L hL hcP hsP M hM hrows hB test z + have hm : ((tuples).fiberLaw (principalResidueLabel q)).mean (fun r => ‖test r‖) ≤ 1 := + (((tuples).fiberLaw (principalResidueLabel q)).mean_mono htest).trans_eq + (((tuples).fiberLaw (principalResidueLabel q)).mean_const 1) + exact he.trans (mul_le_of_le_one_right hδ.le hm) + +theorem allocatedJointPlateau_residue_mass_error + (hP : 1 ≤ P) (hδ : 0 < δ) (hselected : Function.Injective selected) + (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value + ⟨(selected a).1, Sum.inr (selected a).2⟩) + (hactive : ∀ a, S.value ^ ((selected a).1.val + 1) < (axisK) a) + (hgamma : ∀ a, (axisGamma) a ≤ S.value) + (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α L 1 0 q ≤ P) + (M : A → ℕ) [∀ a, NeZero (M a)] + (hM : ∀ a, M a = allocatedGridTorusFactor B α (selected a) * (axisN) a) + (hrows : ∀ a t, t ∈ (rows) a → t.card ≤ (selected a).1.val + 1) + (hB : ∀ a, positiveModerateSpectrumBlockCount (selected a).1.val ((rows) a).card + ((layerTailDegree m + 2) * ((rows) a).card) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) + (z : ∀ a, (rows) a → ℤ) : + ‖(((∏ a, ((axisN) a : ℝ) ^ ((rows) a).card) * + (((tuples).toPMF.bind (jointLaw)) z).toReal : ℝ) : ℂ) - + ((tuples).fiberLaw (principalResidueLabel q)).complexMean (fun r => + ∏ a, allocatedBudgetedPlateauApproximation B U basis hR hσ S q r + (selected a).1 (selected a).2 (hactive a) hq hsize P accuracy (M a) ((rows) a) (z a))‖ ≤ δ := by + have he := allocatedJointPlateau_residue_test_error B U basis hR hσ S q rowFamily selected x P δ + hP hδ hselected hgrid hactive hgamma hq hsize L hL hcP hsP M hM hrows hB + (fun _ => 1) (fun _ => by simp) z + simp only [one_mul] at he + rw [(tuples).toPMF_bind_scaled_complexMean] at he + exact he + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointResidueAverage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointResidueAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7d7066d9a0ec9e1f07126f01ea292c87d94970a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointResidueAverage.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedJointPointApproximation + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) [NeZero q] + +local notation "tuples" => principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) + +variable {A : Type*} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (rows : A → Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) + +variable (P : ℝ) + +local notation "axisK" => fun a : A => basisAxisScale (basis (Sigma.fst (selected a))) (Sigma.snd (selected a)) +local notation "axisGamma" => fun a : A => principalProfileSize (R (Sigma.fst (selected a))) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (Sigma.fst (selected a)) (Sigma.snd (selected a)))) +local notation "axisTorus" => fun a : A => blockTorusFactor (Fintype.card α) ((Fin.val (Sigma.fst (selected a))) + 1) + (Fintype.card (B (Sigma.mk (Sigma.fst (selected a)) (Sum.inr (Sigma.snd (selected a)))))) (4 * (axisGamma) a) +local notation "axisCap" => fun a : A => positiveModerateSpectrumCardBudget (Fin.val (Sigma.fst (selected a))) + (Finset.card (rows a)) ((layerTailDegree m + 1) * (Finset.card (rows a))) P + (((axisTorus) a : ℝ) / (2 * (axisGamma) a)) (((axisTorus) a : ℝ) ^ (Finset.card (rows a))) 1 + 1 + +local notation "jointLaw" => fun y => dependentProductPMF (fun a => + integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) ((Fin.val (Sigma.fst (selected a))) + 1) + (fun t : rows a => (t : Finset α))) + (allocatedLayerIntegerPMFs B U basis hR hσ S (Sigma.fst (selected a)) (Sigma.snd (selected a)))) + +theorem allocatedJointResiduePoint_test_error + (hselected : Function.Injective selected) + (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value + ⟨(selected a).1, Sum.inr (selected a).2⟩) + (hactive : ∀ a, S.value ^ ((selected a).1.val + 1) < (axisK) a) + (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α L 1 0 q ≤ P) + (M : A → ℕ) [∀ a, NeZero (M a)] (hM : ∀ a, M a = (axisTorus) a * (axisK) a) + (hrows : ∀ a t, t ∈ rows a → t.card ≤ (selected a).1.val + 1) + (hB : ∀ a, positiveModerateSpectrumBlockCount (selected a).1.val (rows a).card + ((layerTailDegree m + 1) * (rows a).card) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) + {ε : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) + (test : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) → ℂ) + (htest : ∀ r, ‖test r‖ ≤ 1) (z : ∀ a, rows a → ℤ) : + let C := ∑ a, (axisCap) a + ‖(tuples).complexMean (fun y => test (principalResidueLabel q y) * + (((∏ a, ((axisK) a : ℝ) ^ (rows a).card) * ((jointLaw y) z).toReal : ℝ) : ℂ)) - + ((tuples).fiberLaw (principalResidueLabel q)).complexMean (fun r => test r * + ∏ a, allocatedSupportedPhysicalPointApproximation B U basis hR hσ S q r + (selected a).1 (selected a).2 (hactive a) hq hsize P ε (M a) (rows a) (z a))‖ ≤ + Fintype.card A * ε * (1 + C + ε) ^ Fintype.card A := by + intro C + have hC0 : 0 ≤ C := by + apply Finset.sum_nonneg + intro a _ + have hc := allocatedSupportedPhysicalPointApproximation_norm_le B U basis hR hσ S q + (fun _ _ => 0) (selected a).1 (selected a).2 (hactive a) hq hsize (hgrid a) + L hL P hcP hsP (hM a) (rows a) (hrows a) (hB a) ε (z a) + exact (norm_nonneg _).trans hc + have hE : 0 ≤ (Fintype.card A : ℝ) * ε * (1 + C + ε) ^ Fintype.card A := by positivity + apply (tuples).complexMean_supported_fiber_mul_error (principalResidueLabel q) _ _ test hE htest + intro r hr + have hc := ((tuples).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hr).toPMF_bind_scaled_complexMean + (jointLaw) (∏ a, ((axisK) a : ℝ) ^ (rows a).card) z + have he := allocatedSupportedJointPoint_error B U basis hR hσ S q r hr selected rows x P + hselected hgrid hactive hq hsize L hL hcP hsP M hM hrows hB hε hε1 z + exact (congrArg (fun w : ℂ => ‖w - + ∏ a, allocatedSupportedPhysicalPointApproximation B U basis hR hσ S q r + (selected a).1 (selected a).2 (hactive a) hq hsize P ε (M a) (rows a) (z a)‖) hc).trans_le he + +theorem allocatedJointResiduePoint_mass_error + (hselected : Function.Injective selected) + (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value + ⟨(selected a).1, Sum.inr (selected a).2⟩) + (hactive : ∀ a, S.value ^ ((selected a).1.val + 1) < (axisK) a) + (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α L 1 0 q ≤ P) + (M : A → ℕ) [∀ a, NeZero (M a)] (hM : ∀ a, M a = (axisTorus) a * (axisK) a) + (hrows : ∀ a t, t ∈ rows a → t.card ≤ (selected a).1.val + 1) + (hB : ∀ a, positiveModerateSpectrumBlockCount (selected a).1.val (rows a).card + ((layerTailDegree m + 1) * (rows a).card) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) + {ε : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) + (z : ∀ a, rows a → ℤ) : + let C := ∑ a, (axisCap) a + ‖(((∏ a, ((axisK) a : ℝ) ^ (rows a).card) * + (((tuples).toPMF.bind (jointLaw)) z).toReal : ℝ) : ℂ) - + ((tuples).fiberLaw (principalResidueLabel q)).complexMean (fun r => + ∏ a, allocatedSupportedPhysicalPointApproximation B U basis hR hσ S q r + (selected a).1 (selected a).2 (hactive a) hq hsize P ε (M a) (rows a) (z a))‖ ≤ + Fintype.card A * ε * (1 + C + ε) ^ Fintype.card A := by + intro C + have h := allocatedJointResiduePoint_test_error B U basis hR hσ S q selected rows x P + hselected hgrid hactive hq hsize L hL hcP hsP M hM hrows hB hε hε1 + (fun _ => 1) (fun _ => by simp) z + simp only [one_mul] at h + rw [(tuples).toPMF_bind_scaled_complexMean] at h + exact h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointResidueLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointResidueLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..a03c795bf9fe46126535b5a8f1683258f6dec544 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedJointResidueLaw.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.Progressions.Linear.ContainedSupportedProgressionKernels + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +variable {A : Type*} [Fintype A] (j : A → Fin m) (i : ∀ a, Fin (n (j a))) +variable (hdistinct : Function.Injective + (fun a : A => (⟨j a, Sum.inr (i a)⟩ : LayerSamplerAxis I n))) +variable (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value ⟨j a, Sum.inr (i a)⟩) +variable {O : A → Type*} [∀ a, Fintype (O a)] (rows : ∀ a, O a → Finset α) +variable (x : G → IntegerScalarCubeBox α S.value) + +local notation "conditioned" => FiniteProbabilityWeights.condition + (principalTupleWeights B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)) + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell +local notation "physical" => fun y a => integerMatrixImagePMF + (boundedCoefficientJetMatrix (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (Fin.val (j a) + 1) (rows a)) + (allocatedLayerIntegerPMFs B U basis hR hσ S (j a) (i a)) + +include hdistinct hgrid in +theorem allocatedPhysicalGrid_joint_residue_law : + (conditioned).toPMF.bind (fun y => dependentProductPMF ((physical) y)) = + dependentProductPMF (fun a => (conditioned).toPMF.bind (fun y => (physical) y a)) := by + let F (a : A) + (v : ∀ b : B ⟨j a, Sum.inr (i a)⟩, ∀ t : Fin ((j a).val + 1), + IntegerScalarCubeBox α (allocatedPrincipalSides B U basis S ⟨⟨j a, Sum.inr (i a)⟩, b, t⟩)) : + PMF (O a → ℤ) := + (independentProductPMF (fun s : Option (B ⟨j a, Sum.inr (i a)⟩) => + allocatedLayerIntegerPMFs B U basis hR hσ S (j a) (i a) + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) ⟨j a, Sum.inr (i a)⟩ s))).map + (fun c o => booleanCoefficient (fun _ => c none) (rows a o) + + ∑ b, c (some b) * integerBooleanBlockJet (fun t k => (v b t k : ℤ)) (rows a o)) + have hpoint y a : (physical) y a = F a (fun b t => y ⟨⟨j a, Sum.inr (i a)⟩, b, t⟩) := + allocatedPhysicalGridJetPMF_principal B U basis hR hσ S (j a) (i a) (hgrid a) x y (rows a) + simp_rw [hpoint] + exact principalSupportedResidue_selected_kernels B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) + q r hcell (fun a => ⟨j a, Sum.inr (i a)⟩) hdistinct F + +include hdistinct hgrid in +theorem allocatedPhysicalGrid_joint_point_mass (K : A → ℝ) (z : ∀ a, O a → ℤ) : + (conditioned).mean (fun y => ∏ a, K a * ((physical) y a (z a)).toReal) = + ∏ a, K a * (((conditioned).toPMF.bind (fun y => (physical) y a)) (z a)).toReal := by + exact FiniteProbabilityWeights.mean_prod_point_mass (conditioned) (physical) + (allocatedPhysicalGrid_joint_residue_law B U basis hR hσ S q r hcell j i + hdistinct hgrid rows x) K z + +include hdistinct hgrid in +theorem allocatedPhysicalGrid_joint_point_error + (K : A → ℝ) (z : ∀ a, O a → ℤ) (g : A → ℂ) + {C ε : ℝ} (hC : 0 ≤ C) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (hg : ∀ a, ‖g a‖ ≤ C) + (herr : ∀ a, ‖((K a * (((conditioned).toPMF.bind + (fun y => (physical) y a)) (z a)).toReal : ℝ) : ℂ) - g a‖ ≤ ε) : + ‖((conditioned).mean (fun y => ∏ a, K a * ((physical) y a (z a)).toReal) : ℂ) - + ∏ a, g a‖ ≤ Fintype.card A * ε * (C + 1) ^ Fintype.card A := by + rw [allocatedPhysicalGrid_joint_point_mass B U basis hR hσ S q r hcell + j i hdistinct hgrid rows x K z, Complex.ofReal_prod] + have hcap a : ‖((K a * (((conditioned).toPMF.bind + (fun y => (physical) y a)) (z a)).toReal : ℝ) : ℂ)‖ ≤ C + 1 := by + calc + _ = ‖(((K a * (((conditioned).toPMF.bind + (fun y => (physical) y a)) (z a)).toReal : ℝ) : ℂ) - g a) + g a‖ := by + rw [sub_add_cancel] + _ ≤ ‖((K a * (((conditioned).toPMF.bind + (fun y => (physical) y a)) (z a)).toReal : ℝ) : ℂ) - g a‖ + ‖g a‖ := norm_add_le _ _ + _ ≤ C + 1 := by linarith [herr a, hg a] + simpa only [Finset.card_univ] using norm_finset_prod_sub_prod_le Finset.univ + (fun a => ((K a * (((conditioned).toPMF.bind + (fun y => (physical) y a)) (z a)).toReal : ℝ) : ℂ)) g + (by linarith : 1 ≤ C + 1) hε (fun a _ => hcap a) + (fun a _ => (hg a).trans (by linarith)) (fun a _ => herr a) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedKernelCanonicalResidueComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedKernelCanonicalResidueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..63814550afc49d08eaa29aa102115974c0a901f9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedKernelCanonicalResidueComparison.lean @@ -0,0 +1,166 @@ +import OAI.Combinatorics.Progressions.Lattices.OriginalKernelResidueRetained +import OAI.Combinatorics.Progressions.Linear.AllocatedKernelSlowBudget +import OAI.Combinatorics.Progressions.Linear.CanonicalKernelSlowParameter + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G X : Type*} [Fintype G] [DecidableEq G] [Fintype X] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) +local notation "slope" => (S.value : ℝ) / (1 + budget) +local notation "Spatial" => ((Σ _ : X, Unit ⊕ Empty) → ℝ) + +omit [DecidableEq G] in + +theorem allocatedKernelSlowExpectation_lipschitz + (φ : Spatial → ℂ) {K : ℝ≥0} (hφ : LipschitzWith K φ) (hbound : ∀ y, ‖φ y‖ ≤ 1) : + LipschitzWith K (canonicalKernelSlowExpectation (G := G) slope φ) := by + apply (canonicalKernelSlowExpectation_lipschitz slope φ hφ hbound).weaken + apply NNReal.coe_le_coe.mp + change (K : ℝ) * ((Fintype.card G : ℝ) * |slope|) ≤ (K : ℝ) + exact (mul_le_mul_of_nonneg_left (allocatedKernelSlowBudget_abs_le_one B U basis S) + K.coe_nonneg).trans_eq (mul_one (K : ℝ)) + +theorem allocatedKernel_canonical_residue_comparison + (s : Empty ↪ G) (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (G → ZMod q) → Spatial → ℂ) {K : ℝ≥0} + (hφ : ∀ r, LipschitzWith K (φ r)) (hbound : ∀ r y, ‖φ r y‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun x => ∫ y, φ (fun g => ((x g none : ℤ) : ZMod q)) y + ∂canonicalZeroSpatialLaw s (fun g => (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) budget (S.value : ℝ)) - + 𝔼 r : G → ZMod q, ∫ z, canonicalKernelSlowExpectation slope (φ r) + (fun g => z g none) ∂scalarCubeProductMeasure G Empty‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K)) * + (Fintype.card G * ((q : ℝ) / S.value)) := by + classical + let F := fun (r : G → ZMod q) (z : G → Option Empty → ℝ) => + canonicalKernelSlowExpectation slope (φ r) (fun g => z g none) + have hproject : LipschitzWith 1 (fun z : G → Option Empty → ℝ => fun g => z g none) := by + apply LipschitzWith.of_dist_le_mul + intro z w + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro g + exact (dist_le_pi_dist (z g) (w g) none).trans (dist_le_pi_dist z w g) + have hF (r : G → ZMod q) : LipschitzWith K (F r) := by + simpa only [mul_one, Function.comp_def, F] using + (allocatedKernelSlowExpectation_lipschitz B U basis S (φ r) (hφ r) (hbound r)).comp hproject + have he := originalKernel_residue_slow_quadrature S.value q S.positive (NeZero.pos q) + hsize (by simpa only [Measure.real, scalarCubeDomain_empty_volume, ENNReal.toReal_one] + using hsmall) F hF + (fun r z => canonicalKernelSlowExpectation_norm_le slope (φ r) (hbound r) _) + have hid (x : G → IntegerScalarCubeBox Empty S.value) : + F (fun g => ((x g none : ℤ) : ZMod q)) (fun g i => (x g i : ℝ) / S.value) = + ∫ y, φ (fun g => ((x g none : ℤ) : ZMod q)) y + ∂canonicalZeroSpatialLaw s (fun g => (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) budget (S.value : ℝ) := + canonicalKernelSlowExpectation_eq s (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) + budget S.value S.value (allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0)) + (by exact_mod_cast S.positive.ne') _ (hφ _).continuous.measurable + simp_rw [hid] at he + simpa only [F, Measure.real, scalarCubeDomain_empty_volume, ENNReal.toReal_one, div_one] using he + +theorem allocatedKernel_canonical_residue_unitBox_comparison + (s : Empty ↪ G) (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (G → ZMod q) → Spatial → ℂ) {K : ℝ≥0} + (hφ : ∀ r, LipschitzWith K (φ r)) (hbound : ∀ r y, ‖φ r y‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun x => ∫ y, φ (fun g => ((x g none : ℤ) : ZMod q)) y + ∂canonicalZeroSpatialLaw s (fun g => (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) budget (S.value : ℝ)) - + 𝔼 r : G → ZMod q, ∫ t, canonicalKernelSlowExpectation slope (φ r) t + ∂unitBoxMeasure G‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K)) * + (Fintype.card G * ((q : ℝ) / S.value)) := by + have hid (r : G → ZMod q) : + (∫ z, canonicalKernelSlowExpectation slope (φ r) (fun g => z g none) + ∂scalarCubeProductMeasure G Empty) = + ∫ t, canonicalKernelSlowExpectation slope (φ r) t ∂unitBoxMeasure G := by + rw [← scalarCubeProductMeasure_empty_map G] + exact (integral_map (by fun_prop : Measurable (fun z : G → Option Empty → ℝ => fun g => z g none)).aemeasurable + (allocatedKernelSlowExpectation_lipschitz B U basis S (φ r) (hφ r) (hbound r)).continuous.measurable.aestronglyMeasurable).symm + simpa only [hid] using + allocatedKernel_canonical_residue_comparison B U basis S s q hsize hsmall φ hφ hbound + +theorem allocatedKernel_canonical_mean_riemann + (s : Empty ↪ G) + (hsmall : scalarCubeGridBoundaryConstant Empty * (1 / (S.value : ℝ)) < 1) + (φ : Spatial → ℂ) {K : ℝ≥0} + (hφ : LipschitzWith K φ) (hbound : ∀ y, ‖φ y‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun x => ∫ y, φ y ∂canonicalZeroSpatialLaw s (fun g => (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) budget (S.value : ℝ)) - + ∫ t, canonicalKernelSlowExpectation slope φ t ∂unitBoxMeasure G‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K)) * + (Fintype.card G * (1 / (S.value : ℝ))) := by + simpa only [Nat.cast_one, Finset.expect_const, Finset.univ_nonempty, ite_true] using + allocatedKernel_canonical_residue_unitBox_comparison B U basis S s 1 S.positive + (by simpa only [Nat.cast_one] using hsmall) (fun _ => φ) (fun _ => hφ) (fun _ => hbound) + +theorem allocatedKernel_canonical_residue_decoupling + (s : Empty ↪ G) (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (G → ZMod q) → Spatial → ℂ) {K : ℝ≥0} + (hφ : ∀ r, LipschitzWith K (φ r)) (hbound : ∀ r y, ‖φ r y‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun x => ∫ y, φ (fun g => ((x g none : ℤ) : ZMod q)) y + ∂canonicalZeroSpatialLaw s (fun g => (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) budget (S.value : ℝ)) - + 𝔼 r : G → ZMod q, + (FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun x => ∫ y, φ r y ∂canonicalZeroSpatialLaw s (fun g => (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) budget (S.value : ℝ))‖ ≤ + 2 * ((1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K)) * + (Fintype.card G * ((q : ℝ) / S.value))) := by + classical + let law := FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive) + let C : ℝ := 1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K) + let E : ℝ := C * (Fintype.card G * ((q : ℝ) / S.value)) + let ref := fun r : G → ZMod q => + ∫ t, canonicalKernelSlowExpectation slope (φ r) t ∂unitBoxMeasure G + let original := fun r : G → ZMod q => law.complexMean + (fun x => ∫ y, φ r y ∂canonicalZeroSpatialLaw s (fun g => (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) budget (S.value : ℝ)) + have hratio : 1 / (S.value : ℝ) ≤ (q : ℝ) / S.value := + div_le_div_of_nonneg_right (by exact_mod_cast (show 1 ≤ q from NeZero.one_le)) (Nat.cast_nonneg _) + have hC : 0 ≤ C := by + have hc := (scalarCubeGridBoundaryConstant_pos Empty).le + dsimp only [C] + positivity + have hsmallOne : scalarCubeGridBoundaryConstant Empty * (1 / (S.value : ℝ)) < 1 := + (mul_le_mul_of_nonneg_left hratio (scalarCubeGridBoundaryConstant_pos Empty).le).trans_lt hsmall + have hsingle (r : G → ZMod q) : ‖ref r - original r‖ ≤ E := by + rw [norm_sub_rev] + exact (allocatedKernel_canonical_mean_riemann B U basis S s hsmallOne (φ r) (hφ r) + (hbound r)).trans (mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left hratio (Nat.cast_nonneg _)) hC) + have havg : ‖(𝔼 r : G → ZMod q, ref r) - 𝔼 r : G → ZMod q, original r‖ ≤ E := by + rw [← Finset.expect_sub_distrib] + apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun r _ => hsingle r)).trans_eq (by simp) + have hjoint := allocatedKernel_canonical_residue_unitBox_comparison + B U basis S s q hsize hsmall φ hφ hbound + exact ((norm_sub_le_norm_sub_add_norm_sub _ _ _).trans + (add_le_add hjoint havg)).trans_eq (by change E + E = 2 * E; ring) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLocalResidueReconstruction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLocalResidueReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..d510f285e1631739eedac288f85a4f2fc3083042 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLocalResidueReconstruction.lean @@ -0,0 +1,709 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRefinedWholeReference + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (X : Type*) [Fintype X] +variable {M : ℕ} (hM : 0 < M) (selection : Fin dim ↪ G) +variable (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) +variable (modulus : ℕ) [NeZero modulus] (H : X → ℝ) +variable {W : ℝ} (hW : 0 ≤ W) (mesh : ℝ) + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S +local notation "labels" => (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod modulus) + +noncomputable def allocatedResidueSpatialKernel + (r : labels) (v : X → (Unit ⊕ Fin dim) → ℤ) : ℂ := + let ker := fun g => (0 : ℤ) + (x g none : ℤ) + let hp := goodScalarKernelTuple_spatial_det_ne_zero selection x ker + (one_div_pos.mpr (Nat.cast_pos.mpr hM)) hx + let f := canonicalSpatialSiteDensity selection ker (scalarCubeDifferenceMatrix x) hp W S.value + hW (Nat.cast_pos.mpr S.positive) + ∏ t, spatialSiteApprox (selectedSpatialPivot ker (scalarCubeDifferenceMatrix x) selection) + (Matrix.fromCols (selectedSpatialFreeColumns ker (scalarCubeDifferenceMatrix x) selection) + (liftResidueMatrix (principalSpatialResidueColumns modulus (fun _ => (0 : ℤ)) id r))) + modulus f (H t) 4 mesh (v t) + +theorem allocatedResidueSpatialKernel_norm_le + (hH : ∀ t, 0 < H t) (hbudget : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W) + (hmesh : 0 < mesh) + (hperiod : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection)) + (r : labels) (v : X → (Unit ⊕ Fin dim) → ℤ) (hv : v ∈ spatialWindow H 4) : + ‖allocatedResidueSpatialKernel B U b S x X hM selection hx modulus H hW mesh r v‖ ≤ + ((modulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (M : ℝ))) ^ Fintype.card X := by + let ker := fun g => (0 : ℤ) + (x g none : ℤ) + let hp := goodScalarKernelTuple_spatial_det_ne_zero selection x ker + (one_div_pos.mpr (Nat.cast_pos.mpr hM)) hx + let f := canonicalSpatialSiteDensity selection ker (scalarCubeDifferenceMatrix x) hp W S.value + hW (Nat.cast_pos.mpr S.positive) + obtain ⟨y, _hy⟩ := (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + sides (allocatedPrincipalSides_pos B U b S)).exists_weight_pos + have hκ : 0 < 1 / (M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + have hC := anisotropicSpatialDensityCap_nonneg selection hκ.le + have hroot (g : G) : |(ker g : ℝ)| ≤ 1 + W := by + have h := (allocatedPhysicalCube_root_budget B U b S (fun _ => 0) x y (.inl g)).trans hbudget + change |(ker g : ℝ)| ≤ W at h + linarith + have hD (i : Fin dim) (g : G) : |(scalarCubeDifferenceMatrix x i g : ℝ)| ≤ S.value := + allocatedPhysicalCube_directions_bound B U b S x y i (.inl g) + have hminor : 1 / (M : ℝ) ≤ + |(Matrix.of (fun i j => (scalarCubeDifferenceMatrix x i (selection j) : ℝ) / (S.value : ℝ))).det| := by + change 1 / (M : ℝ) ≤ |(normalizedScalarCubePivot selection x).det| + rw [normalizedScalarCubePivot_det] + exact hx.1.le + have hf := (canonicalSpatialSiteDensity_bounds selection ker (scalarCubeDifferenceMatrix x) hp + hW (Nat.cast_pos.mpr S.positive) (by exact_mod_cast S.positive) hκ hroot hD hminor).1 + exact residueSpatialSite_norm_le _ _ modulus hperiod (fun _ : X => f) H (by norm_num) hmesh hC + (fun _ => hf) (fun _ => principalSpatialResidueColumns modulus (fun _ => (0 : ℤ)) id r) v + ((mem_spatialWindow_scaled_iff H hH 4 v).mp hv) + +noncomputable def allocatedResidueSpatialWindowWeight + (r : labels) (v : X → (Unit ⊕ Fin dim) → ℤ) : ℂ := + if v ∈ spatialWindow H 4 then + allocatedResidueSpatialKernel B U b S x X hM selection hx modulus H hW mesh r v + else 0 + +theorem allocatedResidueSpatialWindowWeight_norm_le + (hH : ∀ t, 0 < H t) (hbudget : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W) + (hmesh : 0 < mesh) + (hperiod : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection)) + (r : labels) (v : X → (Unit ⊕ Fin dim) → ℤ) : + ‖allocatedResidueSpatialWindowWeight B U b S x X hM selection hx modulus H hW mesh r v‖ ≤ + ((modulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (M : ℝ))) ^ Fintype.card X := by + unfold allocatedResidueSpatialWindowWeight + split_ifs with hv + · exact allocatedResidueSpatialKernel_norm_le B U b S x X hM selection hx modulus H hW mesh + hH hbudget hmesh hperiod r v hv + · rw [norm_zero] + exact pow_nonneg (mul_nonneg (pow_nonneg (Nat.cast_nonneg modulus) _) + (anisotropicSpatialDensityCap_nonneg selection (one_div_nonneg.mpr (Nat.cast_nonneg M)))) _ + +variable (q : X → ℕ) {τ : ℝ} +variable (reference : PrincipalAxisTuples (α := Fin dim) (allocatedGridAxis (I := I) U b S.value) + (allocatedPrincipalSides B U b S) → + (PrincipalTupleIndex (fun a : {a // ¬allocatedGridAxis (I := I) U b S.value a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + PrincipalAxisTuples (α := Fin dim) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S)) + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedRefinedSpatialKernel_residue + (N : X → ℕ) + (u : PrincipalAxisTuples (α := Fin dim) grid sides) + (r : PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) : + allocatedRefinedSpatialKernel (τ := τ) B U b S x X hM selection hx modulus q reference N hW mesh u r = + allocatedResidueSpatialKernel B U b S x X hM selection hx modulus (trimmedSpatialRootScale τ N q) hW mesh + (principalResidueLabel modulus (principalAxisJoin grid u (reference u r))) := by + funext v + simp only [allocatedRefinedSpatialKernel, allocatedResidueSpatialKernel, principalSpatialColumns_residue] + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedRefinedSpatialKernel_whole_residue + (N : X → ℕ) + (href : ∀ u r, principalResidueLabel (residueRefinedPeriod modulus q) (reference u r) = r) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) sides) : + allocatedRefinedSpatialKernel (τ := τ) B U b S x X hM selection hx modulus q reference N hW mesh + (principalAxisRestrict grid y) + (principalResidueLabel (residueRefinedPeriod modulus q) (principalAxisRestrict (fun a => ¬grid a) y)) = + allocatedResidueSpatialKernel B U b S x X hM selection hx modulus (trimmedSpatialRootScale τ N q) hW mesh + (principalResidueLabel modulus y) := by + rw [allocatedRefinedSpatialKernel_residue] + have hlabel := principalResidueLabel_eq_of_dvd + (reference (principalAxisRestrict grid y) + (principalResidueLabel (residueRefinedPeriod modulus q) (principalAxisRestrict (fun a => ¬grid a) y))) + (principalAxisRestrict (fun a => ¬grid a) y) ⟨∏ t, q t, rfl⟩ + (href (principalAxisRestrict grid y) + (principalResidueLabel (residueRefinedPeriod modulus q) (principalAxisRestrict (fun a => ¬grid a) y))) + rw [principalResidueLabel_join, hlabel, ← principalResidueLabel_join, principalAxisJoin_restrict] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Classical Matrix + +noncomputable def allocatedSpatialCoefficientCap {G : Type*} [Fintype G] {dim : ℕ} + (X : Type*) [Fintype X] (selection : Fin dim ↪ G) (M modulus : ℕ) (mesh : ℝ) : ℝ := + ((modulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + (intervalSiteCount 4 mesh : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + ((modulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (M : ℝ)))) ^ Fintype.card X + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (X : Type*) [Fintype X] +variable {M : ℕ} (hM : 0 < M) (selection : Fin dim ↪ G) +variable (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) +variable (modulus : ℕ) [NeZero modulus] {W : ℝ} (hW : 0 ≤ W) (mesh : ℝ) + +local notation "labels" => PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod modulus +local notation "terms" => X → SpatialSiteLabel (Fin dim) modulus 4 mesh + +noncomputable def allocatedSpatialExpansionCoefficient (r : labels) (t : terms) : ℂ := + let ker := fun g => (0 : ℤ) + (x g none : ℤ) + let hp := goodScalarKernelTuple_spatial_det_ne_zero selection x ker + (one_div_pos.mpr (Nat.cast_pos.mpr hM)) hx + let f := canonicalSpatialSiteDensity selection ker (scalarCubeDifferenceMatrix x) hp W S.value + hW (Nat.cast_pos.mpr S.positive) + ∏ z : X, spatialSiteCoefficient (selectedSpatialPivot ker (scalarCubeDifferenceMatrix x) selection) + (Matrix.fromCols (selectedSpatialFreeColumns ker (scalarCubeDifferenceMatrix x) selection) + (liftResidueMatrix (principalSpatialResidueColumns modulus (fun _ => (0 : ℤ)) id r))) + modulus f 4 mesh (t z) + +theorem allocatedResidueSpatialKernel_expansion (H : X → ℝ) (r : labels) + (v : X → (Unit ⊕ Fin dim) → ℤ) : + allocatedResidueSpatialKernel B U b S x X hM selection hx modulus H hW mesh r v = + ∑ t : terms, allocatedSpatialExpansionCoefficient B U b S x X hM selection hx modulus hW mesh r t * + ∏ i, vectorResidueSiteWeight 4 mesh H (fun z => (t z).1 i) (fun z => (t z).2 i) + (fun z => spatialStar (v z) i) := by + unfold allocatedResidueSpatialKernel allocatedSpatialExpansionCoefficient + exact vectorSpatialSiteExpansion _ _ modulus _ H 4 mesh v + +theorem allocatedSpatialExpansionCoefficient_sum_le + (hbudget : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W) + (hperiod : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection)) (r : labels) : + (∑ t : terms, ‖allocatedSpatialExpansionCoefficient B U b S x X hM selection hx modulus hW mesh r t‖) ≤ + allocatedSpatialCoefficientCap X selection M modulus mesh := by + let ker := fun g => (0 : ℤ) + (x g none : ℤ) + let hp := goodScalarKernelTuple_spatial_det_ne_zero selection x ker + (one_div_pos.mpr (Nat.cast_pos.mpr hM)) hx + let f := canonicalSpatialSiteDensity selection ker (scalarCubeDifferenceMatrix x) hp W S.value + hW (Nat.cast_pos.mpr S.positive) + obtain ⟨y, _hy⟩ := (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).exists_weight_pos + have hκ : 0 < 1 / (M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + have hroot (g : G) : |(ker g : ℝ)| ≤ 1 + W := by + have h := (allocatedPhysicalCube_root_budget B U b S (fun _ => 0) x y (.inl g)).trans hbudget + change |(ker g : ℝ)| ≤ W at h + linarith + have hD (i : Fin dim) (g : G) : |(scalarCubeDifferenceMatrix x i g : ℝ)| ≤ S.value := + allocatedPhysicalCube_directions_bound B U b S x y i (.inl g) + have hminor : 1 / (M : ℝ) ≤ + |(Matrix.of (fun i j => (scalarCubeDifferenceMatrix x i (selection j) : ℝ) / (S.value : ℝ))).det| := by + change 1 / (M : ℝ) ≤ |(normalizedScalarCubePivot selection x).det| + rw [normalizedScalarCubePivot_det] + exact hx.1.le + have hf := (canonicalSpatialSiteDensity_bounds selection ker (scalarCubeDifferenceMatrix x) hp + hW (Nat.cast_pos.mpr S.positive) (by exact_mod_cast S.positive) hκ hroot hD hminor).1 + let extra := Matrix.fromCols (selectedSpatialFreeColumns ker (scalarCubeDifferenceMatrix x) selection) + (liftResidueMatrix (principalSpatialResidueColumns modulus (fun _ => (0 : ℤ)) id r)) + have hfull : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot ker (scalarCubeDifferenceMatrix x) selection) extra := by + dsimp only [extra] + rw [pivotFullImage_split] + exact hperiod.trans le_sup_left + have hindex : ((pivotFullImage (selectedSpatialPivot ker (scalarCubeDifferenceMatrix x) selection) + extra).toAddSubgroup.index : ℝ) ≤ (modulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) := by + exact_mod_cast residueLatticeImage_index_le _ modulus hfull + exact vectorSpatialSiteCoefficient_sum_bound _ (fun _ : X => extra) modulus (fun _ => f) + 4 mesh (fun _ => hindex) (fun _ => hf) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Matrix NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (X : Type*) [Fintype X] +variable {M : ℕ} (hM : 0 < M) (selection : Fin dim ↪ G) +variable (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) +variable (modulus : ℕ) [NeZero modulus] (H : X → ℝ) + +variable {W : ℝ} (hW : 0 ≤ W) (mesh : ℝ) + +theorem allocatedResidueSpatialKernel_remesh (Q : ℝ≥0) (hQ : 1 ≤ Q) + (hratio : (1 + W) / (S.value : ℝ) ≤ Q) + (hroot : ∀ g, |((x g none : ℤ) : ℝ)| ≤ 1 + W) + (hperiod : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage + (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) (scalarCubeDifferenceMatrix x) selection)) + (hH : ∀ t, 0 < H t) (hmesh : 0 < mesh) (coarse : ℝ) (hcoarse : 0 < coarse) + (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod modulus) + (v : X → (Unit ⊕ Fin dim) → ℤ) (hv : v ∈ spatialWindow H 4) : + ‖allocatedResidueSpatialKernel B U b S x X hM selection hx modulus H hW mesh r v - + allocatedResidueSpatialKernel B U b S x X hM selection hx modulus H hW coarse r v‖ ≤ + Fintype.card X * + (4 * (modulus : ℝ)^Fintype.card (Unit ⊕ Fin dim) * + (anisotropicSpatialDensityLip selection (1 / (M : ℝ)) * Q) * (mesh + coarse)) * + (1 + (modulus : ℝ)^Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (M : ℝ)))^Fintype.card X := by + let root := fun g => (0 : ℤ) + (x g none : ℤ) + let A := selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection + let C := Matrix.fromCols (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection) + (liftResidueMatrix (principalSpatialResidueColumns modulus (fun _ => (0 : ℤ)) id r)) + have hκ : 0 < 1 / (M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + let hp := goodScalarKernelTuple_spatial_det_ne_zero selection x root hκ hx + let f := canonicalSpatialSiteDensity selection root (scalarCubeDifferenceMatrix x) hp W S.value + hW (Nat.cast_pos.mpr S.positive) + have hL1 : (1 : ℝ) ≤ S.value := by exact_mod_cast S.positive + have hroot' : ∀ g, |(root g : ℝ)| ≤ 1 + W := by + intro g + simpa only [root, zero_add] using hroot g + have hD : ∀ i g, |(scalarCubeDifferenceMatrix x i g : ℝ)| ≤ S.value := by + intro i g + have hg := Finset.mem_Ico.mp (x g (some i)).property + change |((x g (some i) : ℤ) : ℝ)| ≤ S.value + exact_mod_cast abs_le.mpr ⟨hg.1, hg.2.le⟩ + have hminor : 1 / (M : ℝ) ≤ + |(Matrix.of (fun i j => (scalarCubeDifferenceMatrix x i (selection j) : ℝ) / (S.value : ℝ))).det| := by + change 1 / (M : ℝ) ≤ |(normalizedScalarCubePivot selection x).det| + rw [normalizedScalarCubePivot_det] + exact hx.1.le + have hf := canonicalSpatialSiteDensity_lipschitz_ratio selection root (scalarCubeDifferenceMatrix x) + hp hW (Nat.cast_pos.mpr S.positive) hκ hroot' hD hminor hQ hratio + have hcap := (canonicalSpatialSiteDensity_bounds selection root (scalarCubeDifferenceMatrix x) + hp hW (Nat.cast_pos.mpr S.positive) hL1 hκ hroot' hD hminor).1 + have hfull : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ pivotFullImage A C := by + dsimp only [A, C] + rw [pivotFullImage_split] + exact hperiod.trans le_sup_left + have hi : ((pivotFullImage A C).toAddSubgroup.index : ℝ) ≤ + (modulus : ℝ)^Fintype.card (Unit ⊕ Fin dim) := by + exact_mod_cast residueLatticeImage_index_le _ modulus hfull + have hv' := (mem_spatialWindow_scaled_iff H hH 4 v).mp hv + have h := vectorSpatialSiteApprox_remesh A (fun _ : X => C) modulus (fun _ => hfull) + (fun _ => f) (fun _ => hf) H (by positivity) + (anisotropicSpatialDensityCap_nonneg selection hκ.le) (fun _ => hi) (fun _ => hcap) + (by norm_num : (0 : ℝ) < 4) hmesh hcoarse v hv' + simpa only [allocatedResidueSpatialKernel, f, A, C, root, hp, NNReal.coe_mul, + Real.coe_toNNReal _ (anisotropicSpatialDensityLip_nonneg selection hκ.le)] using h + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Matrix NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset (Fin dim)) + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides + +variable (X : Type*) [Fintype X] + +local notation "whole" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) sides (allocatedPrincipalSides_pos B U b S) +local notation "frozen" => allocatedFrozenTupleWeights (α := Fin dim) B U b S +local notation "long" => allocatedLongTupleWeights (α := Fin dim) B U b S + +variable {M : ℕ} (hM : 0 < M) (selection : Fin dim ↪ G) +variable (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) +variable (modulus : ℕ) [NeZero modulus] +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) +variable (q : X → ℕ) +variable [NeZero (residueRefinedPeriod modulus q)] +variable (reference : PrincipalAxisTuples (α := Fin dim) (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S) → + (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U b S.value) a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + PrincipalAxisTuples (α := Fin dim) (fun a => ¬(allocatedGridAxis (I := I) U b S.value) a) (allocatedPrincipalSides B U b S)) +variable (residue : PrincipalAxisTuples (α := Fin dim) (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S) → + (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U b S.value) a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {Kcov : Fin m → Type*} [∀ j, Fintype (Kcov j)] +variable (bW : ∀ j, Module.Basis (Kcov j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (g : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S) → EuclideanJetLayers U O → ℝ) +variable (N : X → ℕ) (hN : ∀ t, 0 < N t) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (C₀ ρ δ mesh : ℝ) (base : X → ℤ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (point : (X → (Unit ⊕ Fin dim) → ℤ) → EuclideanJetLayers U O) +variable (test : (X → (Unit ⊕ Fin dim) → ℤ) → ℂ) (Cg Z : ℝ) + +local notation "frozenTuple" => PrincipalAxisTuples (α := Fin dim) grid sides +local notation "label" => (PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) + (fun a => layerSamplerDegree I n (Subtype.val a)) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) +local notation "window" => spatialWindow (α := Fin dim) (trimmedSpatialRootScale τ N q) 4 + +local notation "fullTuple" => PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) sides +local notation "refined" => residueRefinedPeriod modulus q + +noncomputable def allocatedResidueWeightedProfileTerm + (profile : fullTuple → EuclideanJetLayers U O → ℂ) (y : fullTuple) : ℂ := + let u := principalAxisRestrict grid y + let r := principalResidueLabel refined (principalAxisRestrict (fun a => ¬grid a) y) + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + let A := ∏ t, ∏ i, physicalSpatialOutputScale (Fin dim) + (trimmedSpatialRootScale τ N q t) (trimmedSpatialSlopeScale W τ N q t) S.value i + let reconstruction := allocatedRefinedReferenceReconstruction B U b S x X modulus q reference base cells u r + ∑ t : cells × window, + (selectedResidueCellWeight q cells V t.1 : ℂ) * + (allocatedResidueSpatialKernel B U b S x X hM selection hx modulus + (trimmedSpatialRootScale τ N q) hW mesh (principalResidueLabel modulus y) t.2.val / (A : ℂ)) * + test (reconstruction t.1 t.2.val) * profile y (point (reconstruction t.1 t.2.val)) + +omit [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] + [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] + [NeZero (residueRefinedPeriod modulus q)] in +theorem allocatedWholeProfileReferenceTerm_residue_weighted + (href : ∀ u r, principalResidueLabel refined (reference u r) = r) + (profile : fullTuple → EuclideanJetLayers U O → ℂ) (y : fullTuple) : + allocatedWholeProfileReferenceTerm (τ := τ) (ξ := ξ) + B U b S x X hM selection hx modulus q reference N hW mesh base cells point test profile y = + allocatedResidueWeightedProfileTerm (τ := τ) (ξ := ξ) + B U b S x X hM selection hx modulus q reference N hW mesh base cells point test profile y := by + have hker := allocatedRefinedSpatialKernel_whole_residue (τ := τ) + B U b S x X hM selection hx modulus hW mesh q reference N href y + simp only [allocatedWholeProfileReferenceTerm, allocatedResidueWeightedProfileTerm, + allocatedRefinedProfileCoefficient, hker] + +noncomputable def allocatedWholeIdealReference (δ : ℝ≥0) : ℂ := + let f := physicalActiveProfileIdeal (G := G) (B := B) (G × Option (Fin dim)) (layerSamplerDegree I n) + grid (fun a => rows a.val.1) (fun a => R a.1) (fun a => hR a.1) δ + (whole).complexMean (allocatedResidueWeightedProfileTerm (τ := τ) (ξ := ξ) + B U b S x X hM selection hx modulus q reference N hW mesh base cells point test + (fun y z => (allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d y modulus f z : ℂ))) / + (Z : ℂ) + +omit [∀ j, DecidableEq (O j)] in +theorem allocatedRefinedIdealReference_residue_weighted (δ : ℝ≥0) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (hRefined : 0 < refined) + (hsize : ∀ a, (Fintype.card (Fin dim) + 1) * refined ≤ + principalAxisLength (fun a => ¬grid a) sides a) + (href : ∀ u r, principalResidueLabel refined (reference u r) = r) + (hresidue : ∀ u r v, + (allocatedLongResidueWeights B U b S refined hRefined r hsize).weight v ≠ 0 → + ∀ j, integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) modulus = residue u r j) : + allocatedRefinedIdealReference (τ := τ) (ξ := ξ) + B U b hR hσ S x rows X hM selection hx modulus q reference residue hb o bW d + N hW mesh base cells point test Z δ = + allocatedWholeIdealReference (τ := τ) (ξ := ξ) + B U b hR hσ S x rows X hM selection hx modulus q reference hb o bW d + N hW mesh base cells point test Z δ := by + let f := physicalActiveProfileIdeal (G := G) (B := B) (G × Option (Fin dim)) (layerSamplerDegree I n) + grid (fun a => rows a.val.1) (fun a => R a.1) (fun a => hR a.1) δ + have h := allocatedRefinedFamilyReference_whole (τ := τ) (ξ := ξ) + B U b hR hσ S x rows X hM selection hx modulus q reference residue hb o bW d + N hW mesh base cells point test Z hperiod hRefined hsize href hresidue + (fun r => allocatedLongProfileDensity B U b S x rows modulus r f) (fun _ => 1) + have hfirst : allocatedRefinedIdealReference (τ := τ) (ξ := ξ) + B U b hR hσ S x rows X hM selection hx modulus q reference residue hb o bW d + N hW mesh base cells point test Z δ = + (whole).complexMean (allocatedWholeProfileReferenceTerm (τ := τ) (ξ := ξ) + B U b S x X hM selection hx modulus q reference N hW mesh base cells point test + (fun y z => (allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d y modulus f z : ℂ))) / + (Z : ℂ) := by + rw [allocatedRefinedIdealReference_as_complex] + simpa only [mul_one, allocatedRefinedIdealProfile, allocatedWholeResidueProfile, + allocatedWholeMaskedCoveredProfile] using h + rw [hfirst] + unfold allocatedWholeIdealReference + apply congrArg (fun z : ℂ => z / (Z : ℂ)) + apply congrArg (whole).complexMean + funext y + exact allocatedWholeProfileReferenceTerm_residue_weighted (τ := τ) (ξ := ξ) + B U b S x X hM selection hx modulus q reference N hW mesh base cells point test href _ y + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S +local notation "fullTuple" => PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) sides + +theorem exists_allocatedWholeResidueReference (modulus : ℕ) (hmodulus : 0 < modulus) + (hsize : ∀ a, (Fintype.card (Fin dim) + 1) * modulus ≤ sides a) : + ∃ reference : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod modulus) → fullTuple, + ∀ r, principalResidueLabel modulus (reference r) = r ∧ + (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) sides + (allocatedPrincipalSides_pos B U b S)).weight (reference r) ≠ 0 := by + have h := fun r => principalResidue_positive_witness B (layerSamplerDegree I n) sides + (allocatedPrincipalSides_pos B U b S) modulus hmodulus hsize r + exact ⟨fun r => (h r).choose, fun r => (h r).choose_spec⟩ + +variable (X : Type*) [Fintype X] (modulus : ℕ) (q : X → ℕ) +variable (reference : PrincipalAxisTuples (α := Fin dim) (allocatedGridAxis (I := I) U b S.value) + (allocatedPrincipalSides B U b S) → + (PrincipalTupleIndex (fun a : {a // ¬allocatedGridAxis (I := I) U b S.value a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + PrincipalAxisTuples (α := Fin dim) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S)) +variable (wholeReference : + (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S)) + +local notation "refined" => residueRefinedPeriod modulus q +local notation "labels" => (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod refined) + +noncomputable def allocatedReferenceTupleOfWhole (y : fullTuple) : fullTuple := + principalAxisJoin grid (principalAxisRestrict grid y) + (reference (principalAxisRestrict grid y) + (principalResidueLabel refined (principalAxisRestrict (fun a => ¬grid a) y))) + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedReferenceTupleOfWhole_label + (href : ∀ u r, principalResidueLabel refined (reference u r) = r) (y : fullTuple) : + principalResidueLabel refined (allocatedReferenceTupleOfWhole B U b S X modulus q reference y) = + principalResidueLabel refined y := by + unfold allocatedReferenceTupleOfWhole + rw [principalResidueLabel_join, href, ← principalResidueLabel_join, principalAxisJoin_restrict] + +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) + +noncomputable def allocatedWholeResidueReconstruction (base : X → ℤ) + (r : labels) (a : ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q) := + physicalResidueReconstruction + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (wholeReference r)) + (allocatedPhysicalCubeDirections B U b S x (wholeReference r)) base + (boundedColumnResidueRepresentative q a) q + +noncomputable def allocatedResidueReferenceShift (y : fullTuple) + (a : ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q) := + let old := allocatedReferenceTupleOfWhole B U b S X modulus q reference y + let chosen := wholeReference (principalResidueLabel refined y) + physicalResidueOffsetShift + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x old) + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x chosen) + (allocatedPhysicalCubeDirections B U b S x old) + (allocatedPhysicalCubeDirections B U b S x chosen) + (boundedColumnResidueRepresentative q a) q + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedResidueReferenceShift_spec + (hq : ∀ t, 0 < q t) + (href : ∀ u r, principalResidueLabel refined (reference u r) = r) + (hwhole : ∀ r, principalResidueLabel refined (wholeReference r) = r) + (base : X → ℤ) (y : fullTuple) + (a : ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q) : + let shift := allocatedResidueReferenceShift B U b S X modulus q reference wholeReference x y a + (∀ t, shift t ∈ integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ)) ∧ + (∀ v, physicalResidueReconstruction + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y)) + (allocatedPhysicalCubeDirections B U b S x + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y)) base + (boundedColumnResidueRepresentative q a) q v = + allocatedWholeResidueReconstruction B U b S X modulus q wholeReference x base + (principalResidueLabel refined y) a (v + shift)) ∧ + (∀ t i, |(shift t i : ℝ)| ≤ Fintype.card (Option (LayerSamplerVariables G I n B)) * + (2 * allocatedPhysicalEntryBudget B U b S (fun _ => 0))) := by + have hlabel : principalResidueLabel refined + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y) = + principalResidueLabel refined (wholeReference (principalResidueLabel refined y)) := by + rw [allocatedReferenceTupleOfWhole_label B U b S X modulus q reference href, hwhole] + have hrep (k) (t) : |(boundedColumnResidueRepresentative q a (k,t) : ℝ)| ≤ q t := by + have h := boundedColumnResidueRepresentative_bounds q hq a (k,t) + rw [abs_of_nonneg (by exact_mod_cast h.1 : + (0 : ℝ) ≤ boundedColumnResidueRepresentative q a (k,t))] + exact_mod_cast h.2.le + exact allocatedPhysicalResidue_whole_offset_shift B U b S (fun _ => 0) x + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y) + (wholeReference (principalResidueLabel refined y)) base + (boundedColumnResidueRepresentative q a) q hq modulus refined + (stride_mul_dvd_residueRefinedPeriod modulus q) hlabel hrep + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedResidueReferenceShift_normalized + (hq : ∀ t, 0 < q t) + (href : ∀ u r, principalResidueLabel refined (reference u r) = r) + (hwhole : ∀ r, principalResidueLabel refined (wholeReference r) = r) + (H : X → ℝ) (hH : ∀ t, 0 < H t) {ε : ℝ} (hε : 0 ≤ ε) + (hsize : ∀ t, Fintype.card (Option (LayerSamplerVariables G I n B)) * + (2 * allocatedPhysicalEntryBudget B U b S (fun _ => 0)) ≤ ε * H t) + (y : fullTuple) (a : ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q) : + ∀ t, ‖fun i => ((allocatedResidueReferenceShift B U b S X modulus q reference wholeReference x y a t i : ℤ) : ℝ) / + H t‖ ≤ ε := by + have hbound := (allocatedResidueReferenceShift_spec B U b S X modulus q reference wholeReference x + hq href hwhole (fun _ => 0) y a).2.2 + intro t + apply (pi_norm_le_iff_of_nonneg hε).2 + intro i + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hH t)] + exact (div_le_iff₀ (hH t)).mpr ((hbound t i).trans (hsize t)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S +local notation "fullTuple" => PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) sides + +variable (X : Type*) [Fintype X] (modulus : ℕ) (q : X → ℕ) +variable (reference : PrincipalAxisTuples (α := Fin dim) (allocatedGridAxis (I := I) U b S.value) + (allocatedPrincipalSides B U b S) → + (PrincipalTupleIndex (fun a : {a // ¬allocatedGridAxis (I := I) U b S.value a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + PrincipalAxisTuples (α := Fin dim) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S)) +variable (wholeReference : + (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S)) + +local notation "refined" => residueRefinedPeriod modulus q +local notation "labels" => (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod refined) + +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedResidueReferenceShift_spec_at + (hq : ∀ t, 0 < q t) + (href : ∀ u r, principalResidueLabel refined (reference u r) = r) + (base : X → ℤ) (y : fullTuple) + (hwhole : principalResidueLabel refined (wholeReference (principalResidueLabel refined y)) = principalResidueLabel refined y) + (a : ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q) : + let shift := allocatedResidueReferenceShift B U b S X modulus q reference wholeReference x y a + (∀ t, shift t ∈ integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ)) ∧ + (∀ v, physicalResidueReconstruction + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y)) + (allocatedPhysicalCubeDirections B U b S x + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y)) base + (boundedColumnResidueRepresentative q a) q v = + allocatedWholeResidueReconstruction B U b S X modulus q wholeReference x base + (principalResidueLabel refined y) a (v + shift)) ∧ + (∀ t i, |(shift t i : ℝ)| ≤ Fintype.card (Option (LayerSamplerVariables G I n B)) * + (2 * allocatedPhysicalEntryBudget B U b S (fun _ => 0))) := by + have hlabel : principalResidueLabel refined + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y) = + principalResidueLabel refined (wholeReference (principalResidueLabel refined y)) := by + rw [allocatedReferenceTupleOfWhole_label B U b S X modulus q reference href, hwhole] + have hrep (k) (t) : |(boundedColumnResidueRepresentative q a (k,t) : ℝ)| ≤ q t := by + have h := boundedColumnResidueRepresentative_bounds q hq a (k,t) + rw [abs_of_nonneg (by exact_mod_cast h.1 : + (0 : ℝ) ≤ boundedColumnResidueRepresentative q a (k,t))] + exact_mod_cast h.2.le + exact allocatedPhysicalResidue_whole_offset_shift B U b S (fun _ => 0) x + (allocatedReferenceTupleOfWhole B U b S X modulus q reference y) + (wholeReference (principalResidueLabel refined y)) base + (boundedColumnResidueRepresentative q a) q hq modulus refined + (stride_mul_dvd_residueRefinedPeriod modulus q) hlabel hrep + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedResidueReferenceShift_normalized_at + (hq : ∀ t, 0 < q t) + (href : ∀ u r, principalResidueLabel refined (reference u r) = r) + (H : X → ℝ) (hH : ∀ t, 0 < H t) {ε : ℝ} (hε : 0 ≤ ε) + (hsize : ∀ t, Fintype.card (Option (LayerSamplerVariables G I n B)) * + (2 * allocatedPhysicalEntryBudget B U b S (fun _ => 0)) ≤ ε * H t) + (y : fullTuple) (hwhole : principalResidueLabel refined (wholeReference (principalResidueLabel refined y)) = principalResidueLabel refined y) + (a : ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q) : + ∀ t, ‖fun i => ((allocatedResidueReferenceShift B U b S X modulus q reference wholeReference x y a t i : ℤ) : ℝ) / + H t‖ ≤ ε := by + have hbound := (allocatedResidueReferenceShift_spec_at B U b S X modulus q reference wholeReference x + hq href (fun _ => 0) y hwhole a).2.2 + intro t + apply (pi_norm_le_iff_of_nonneg hε).2 + intro i + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hH t)] + exact (div_le_iff₀ (hH t)).mpr ((hbound t i).trans (hsize t)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLongLatticeScale.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLongLatticeScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..895d1247731232fba3cad5e512e995af62d9ba8a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLongLatticeScale.lean @@ -0,0 +1,81 @@ +import OAI.Combinatorics.Progressions.Sampling.AllocatedLongGridCoordinates + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped Classical BigOperators + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "output" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) + +local notation "integerOutput" => {q : output // allocatedLongIntegerCoordinate B U basis S q} + +omit [∀ j, Fintype (O j)] in +theorem allocatedLongLatticeScale_pos (q : integerOutput) : + 0 < allocatedLongLatticeScale B U basis S q := by + rcases q with ⟨⟨⟨⟨j, i | i⟩, ha⟩, o⟩, hq⟩ + · exact False.elim hq + · exact Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) + +theorem allocatedLongLatticeScale_product : + (∏ q : integerOutput, allocatedLongLatticeScale B U basis S q) = + ∏ a : {a // ¬grid a}, allocatedLongJetOutputScale B U basis S (O := O) a := by + have hs := Fintype.prod_subtype_mul_prod_subtype + (allocatedLongIntegerCoordinate B U basis S (O := O)) + (allocatedLongCoordinateScale B U basis S (O := O)) + have hz : (∏ q : {q : output // ¬allocatedLongIntegerCoordinate B U basis S q}, + allocatedLongCoordinateScale B U basis S q.val) = 1 := by + apply Finset.prod_eq_one + intro q _ + rcases q with ⟨⟨⟨⟨j, i | i⟩, ha⟩, o⟩, hq⟩ + · rfl + · exact False.elim (hq True.intro) + rw [hz, mul_one] at hs + change (∏ q : integerOutput, allocatedLongCoordinateScale B U basis S q.val) = _ + rw [hs, Fintype.prod_sigma] + apply Finset.prod_congr rfl + intro a _ + rcases a with ⟨⟨j, i | i⟩, ha⟩ <;> + simp [allocatedLongCoordinateScale, allocatedLongJetOutputScale] + +omit [∀ j, Fintype (O j)] in +theorem allocatedLongLatticeScale_mesh (q : integerOutput) : + 1 / allocatedLongLatticeScale B U basis S q ≤ + 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) := by + rcases q with ⟨⟨⟨⟨j, i | i⟩, ha⟩, o⟩, hq⟩ + · exact False.elim hq + · change 1 / (basisAxisScale (basis j) i : ℝ) ≤ _ + apply one_div_le_one_div_of_le (pow_pos (Nat.cast_pos.mpr S.positive) _) + exact_mod_cast Nat.le_of_lt (Nat.lt_of_not_ge ha) + +omit [∀ j, Fintype (O j)] in +theorem allocatedLongRowsFromGrid_measurable : + Measurable (fun p : + (UnselectedColumn (allocatedLongIntegerSelect B U basis S (O := O)) → ℝ) × + (integerOutput → ℤ) => allocatedLongRowsFromGrid B U basis S p.1 p.2) := by + apply Measurable.of_eval + intro a + rcases a with ⟨⟨j, i | i⟩, ha⟩ + · change Measurable (fun p : (UnselectedColumn (allocatedLongIntegerSelect B U basis S (O := O)) → ℝ) × (integerOutput → ℤ) => fun o : O j => p.1 (allocatedLongRealIndex B U basis S j i ha o)) + exact Measurable.of_eval (fun o => + (measurable_pi_apply (allocatedLongRealIndex B U basis S j i ha o)).comp measurable_fst) + · change Measurable (fun p : (UnselectedColumn (allocatedLongIntegerSelect B U basis S (O := O)) → ℝ) × (integerOutput → ℤ) => fun o : O j => p.2 (allocatedLongIntegerIndex B U basis S j i ha o)) + exact Measurable.of_eval (fun o => + (measurable_pi_apply (allocatedLongIntegerIndex B U basis S j i ha o)).comp measurable_snd) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLongResidueProfile.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLongResidueProfile.lean new file mode 100644 index 0000000000000000000000000000000000000000..b514341c9d661702ae17cf7891ad8f1459bfafca --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedLongResidueProfile.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedNormalizedConditionalHaar + +namespace OAI + +section + +namespace Erdos3 + +theorem principalResidueLabel_eq_of_dvd {D α : Type*} {B : D → Type*} {h : D → ℕ} + {L : PrincipalTupleIndex B h → ℕ} + (y y₀ : PrincipalIntegerTuples B h α L) {q refined : ℕ} + (hdiv : q ∣ refined) + (hlabel : principalResidueLabel refined y = principalResidueLabel refined y₀) : + principalResidueLabel q y = principalResidueLabel q y₀ := by + exact integerResidueMatrix_reduce (fun j i => (y j i : ℤ)) + (fun j i => (y₀ j i : ℤ)) hdiv hlabel + +namespace VectorPolynomial + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] (rows : ∀ j, O j → Finset α) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {Q : Fin m → Type*} [∀ j, Fintype (Q j)] +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S +local notation "quarter" => (fun j (_ : O j) => standardLatticeClosedQuarterBox (J j)) + +variable (u : PrincipalAxisTuples (B := B) (h := layerSamplerDegree I n) (α := α) + (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S)) +variable (v v₀ : PrincipalAxisTuples (B := B) (h := layerSamplerDegree I n) (α := α) + (fun a => ¬allocatedGridAxis (I := I) U b S.value a) (allocatedPrincipalSides B U b S)) + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedCoveredProfileDensity_long_residue_eq (q : ℕ) + (hperiod : ∀ j, integerScalarLattice (O j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (hlabel : principalResidueLabel q v = principalResidueLabel q v₀) + (f : AllocatedLongJetRows B U b S O → ℝ) : + allocatedCoveredProfileDensity B U b hR hσ S x u v rows hb o bW d quarter f = + allocatedCoveredProfileDensity B U b hR hσ S x u v₀ rows hb o bW d quarter f := by + have hwhole : principalResidueLabel q (principalAxisJoin grid u v) = + principalResidueLabel q (principalAxisJoin grid u v₀) := by + rw [principalResidueLabel_join, principalResidueLabel_join, hlabel] + have hgridless : allocatedGridlessCoveredProfile B U b S x u v rows hb o bW d f = + allocatedGridlessCoveredProfile B U b S x u v₀ rows hb o bW d f := by + have heq := allocatedWholeGridlessProfile_eq B U b S x + (principalAxisJoin grid u v) (principalAxisJoin grid u v₀) rows hb o bW d q hperiod hwhole f + simpa only [principalAxisRestrict_join_left, principalAxisRestrict_join_right] using heq + have hgrid : allocatedGridJetDensity B U b hR hσ S x u v rows = + allocatedGridJetDensity B U b hR hσ S x u v₀ rows := by + funext z + simp only [allocatedGridJetDensity_frozen_blocks B U b hR hσ S u rows] + rw [allocatedCoveredProfileDensity_grid_multiplier, + allocatedCoveredProfileDensity_grid_multiplier, hgrid, hgridless] + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedMaskedProfile_eq_whole_of_long_residue (q : ℕ) + (hperiod : ∀ j, integerScalarLattice (O j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (hlabel : principalResidueLabel q v₀ = principalResidueLabel q v) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod q)) + (hresidue : ∀ j, integerResidueMatrix + (allocatedNonkernelJetMatrix B U b S x u rows j v) q = residue j) + (f : ((Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) → ℝ) → ℝ) : + allocatedCoveredProfileDensity B U b hR hσ S x u v₀ rows hb o bW d quarter + (allocatedLongProfileDensity B U b S x rows q residue f) = + allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u v) q f := by + simp only [allocatedWholeMaskedCoveredProfile, + principalAxisRestrict_join_left, principalAxisRestrict_join_right] + rw [show (fun j => integerResidueMatrix + (allocatedNonkernelJetMatrix B U b S x u rows j v) q) = residue from funext hresidue] + exact allocatedCoveredProfileDensity_long_residue_eq B U b hR hσ S x rows hb o bW d + u v₀ v q hperiod hlabel _ + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankAffineFullWitness.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankAffineFullWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2a08be6992b46bb35bf19c2d6a57041de51e879 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankAffineFullWitness.lean @@ -0,0 +1,526 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedModularRankAffineProbability +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankActualRefreshBad +import OAI.Combinatorics.Progressions.Probability.MixedSelectedCoefficientProbability + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + +theorem allocatedCongruenceIntegerSelectedCoefficients_read + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block = + f ∘ allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block := by + funext s + rcases s with ⟨j, (x | i | a), l⟩ <;> rfl + +theorem allocatedCongruenceIntegerSelectedCoefficients_refresh + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (c : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) : + let refreshed := Function.extend + (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) c f + allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise refreshed) (allocatedReadDeck refreshed) + (fun j a => allocatedReadProjection refreshed ⟨j, a.val⟩) spatial kernel block = c := by + dsimp only + rw [allocatedCongruenceIntegerSelectedCoefficients_read] + funext s + exact (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block).injective.extend_apply + c f s + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +def allocatedResidueModulusBad + (inactive : LayerSamplerAxis I n → Prop) (C : ℝ) (M : ℕ) [NeZero M] + (f : AllocatedActualCoefficientIndex G X I E n B → ZMod M) : Prop := + ∃ v : LayerSamplerVariables G I n B → ZMod M, ∃ j : Fin m, + ∃ w : AllocatedCongruenceRankOutput X E inactive j → ZMod M, + (∃ o, IsUnit (w o)) ∧ (M : ℝ) ^ (-C) < + (𝔼 u : Fin j.val → LayerSamplerLongVariables inactive G B → ZMod M, + if polynomialLinearRow (polynomialIterDifference j.val + (∑ o, w o • allocatedOriginalTaggedTop inactive j + (allocatedReadNoise f) (allocatedReadDeck f) + (fun a => allocatedReadProjection f ⟨j,a.val⟩) v + (allocatedCongruenceOutputEmbedding inactive j o)) u) = 0 then 1 else 0) + +def allocatedActualModulusBad + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (M : ℕ) [NeZero M] + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : Prop := + allocatedCongruenceModulusBad inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j,a.val⟩) spatial kernel block C M + (fun z => (allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j,a.val⟩) spatial kernel block z : ZMod M)) + +theorem allocatedActualModulusBad_eq_residue + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (M : ℕ) [NeZero M] + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedActualModulusBad inactive spatial kernel block C M f = + allocatedResidueModulusBad inactive C M (fun i => (f i : ZMod M)) := by + unfold allocatedActualModulusBad allocatedCongruenceModulusBad + allocatedCongruenceRankFailureProbability allocatedResidueModulusBad + simp only [allocatedCongruenceIntegerSelectedCoefficients_reduce, + allocatedCongruenceRankPolynomial_original] + rfl + +theorem allocatedActualModulusBad_congr_residue + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (M : ℕ) [NeZero M] + (f g : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (hfg : ∀ i, (f i : ZMod M) = (g i : ZMod M)) : + allocatedActualModulusBad inactive spatial kernel block C M f ↔ + allocatedActualModulusBad inactive spatial kernel block C M g := by + rw [allocatedActualModulusBad_eq_residue, allocatedActualModulusBad_eq_residue] + exact (congrArg (allocatedResidueModulusBad inactive C M) (funext hfg)).to_iff + +def allocatedResiduePrimePowerWitness + (inactive : LayerSamplerAxis I n → Prop) (C : ℝ) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (fM : AllocatedActualCoefficientIndex G X I E n B → ZMod M) : Prop := + ∀ p : P, allocatedResidueModulusBad inactive C (p.val ^ A p.val) + (fun i => ZMod.castHom (hdiv p) (ZMod (p.val ^ A p.val)) (fM i)) + +theorem allocatedResiduePrimePowerWitness_iff_actual + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedResiduePrimePowerWitness inactive C P A M hdiv (fun i => (f i : ZMod M)) ↔ + ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) f := by + unfold allocatedResiduePrimePowerWitness + apply forall_congr' + intro p + rw [allocatedActualModulusBad_eq_residue] + have hcast : (fun i => ZMod.castHom (hdiv p) (ZMod (p.val ^ A p.val)) (f i : ZMod M)) = + (fun i => (f i : ZMod (p.val ^ A p.val))) := by + funext i + exact map_intCast _ _ + rw [hcast] + +omit [Fintype X] [∀ j, Fintype (E j)] in + +theorem allocatedOriginalCongruenceTop_congr_outputs + (inactive : LayerSamplerAxis I n → Prop) (M : ℕ) + (f g : AllocatedActualCoefficientIndex G X I E n B → ZMod M) + (hnoise : allocatedReadNoise f = allocatedReadNoise g) + (hdeck : allocatedReadDeck f = allocatedReadDeck g) + (hinteger : ∀ (j : Fin m) (i : Fin (n j)), + allocatedReadProjection f ⟨j,Sum.inr i⟩ = allocatedReadProjection g ⟨j,Sum.inr i⟩) + (j : Fin m) (v : LayerSamplerVariables G I n B → ZMod M) + (o : AllocatedCongruenceRankOutput X E inactive j) : + allocatedOriginalTaggedTop inactive j (allocatedReadNoise f) (allocatedReadDeck f) + (fun a => allocatedReadProjection f ⟨j,a.val⟩) v + (allocatedCongruenceOutputEmbedding inactive j o) = + allocatedOriginalTaggedTop inactive j (allocatedReadNoise g) (allocatedReadDeck g) + (fun a => allocatedReadProjection g ⟨j,a.val⟩) v + (allocatedCongruenceOutputEmbedding inactive j o) := by + rcases o with x | i | a + · simp only [allocatedCongruenceOutputEmbedding_spatial, allocatedOriginalTaggedTop, hnoise] + · simp only [allocatedCongruenceOutputEmbedding_deck, allocatedOriginalTaggedTop, hdeck] + · simp only [allocatedCongruenceOutputEmbedding_integer, allocatedOriginalTaggedTop, hinteger] + +theorem allocatedResidueModulusBad_congr_outputs + (inactive : LayerSamplerAxis I n → Prop) (C : ℝ) (M : ℕ) [NeZero M] + (f g : AllocatedActualCoefficientIndex G X I E n B → ZMod M) + (hnoise : allocatedReadNoise f = allocatedReadNoise g) + (hdeck : allocatedReadDeck f = allocatedReadDeck g) + (hinteger : ∀ (j : Fin m) (i : Fin (n j)), + allocatedReadProjection f ⟨j,Sum.inr i⟩ = allocatedReadProjection g ⟨j,Sum.inr i⟩) : + allocatedResidueModulusBad inactive C M f = allocatedResidueModulusBad inactive C M g := by + unfold allocatedResidueModulusBad + simp only [allocatedOriginalCongruenceTop_congr_outputs inactive M f g hnoise hdeck hinteger] + +theorem allocatedResiduePrimePowerWitness_congr_outputs + (inactive : LayerSamplerAxis I n → Prop) (C : ℝ) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (f g : AllocatedActualCoefficientIndex G X I E n B → ZMod M) + (hnoise : allocatedReadNoise f = allocatedReadNoise g) + (hdeck : allocatedReadDeck f = allocatedReadDeck g) + (hinteger : ∀ (j : Fin m) (i : Fin (n j)), + allocatedReadProjection f ⟨j,Sum.inr i⟩ = allocatedReadProjection g ⟨j,Sum.inr i⟩) : + allocatedResiduePrimePowerWitness inactive C P A M hdiv f = + allocatedResiduePrimePowerWitness inactive C P A M hdiv g := by + unfold allocatedResiduePrimePowerWitness + apply propext + apply forall_congr' + intro p + apply Eq.to_iff + apply allocatedResidueModulusBad_congr_outputs + · funext q + exact congrArg (ZMod.castHom (hdiv p) (ZMod (p.val ^ A p.val))) (congrFun hnoise q) + · funext j q i + exact congrArg (ZMod.castHom (hdiv p) (ZMod (p.val ^ A p.val))) + (congrFun (congrFun (congrFun hdeck j) q) i) + · intro j i + funext q + exact congrArg (ZMod.castHom (hdiv p) (ZMod (p.val ^ A p.val))) (congrFun (hinteger j i) q) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] +variable (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) + +def allocatedActualPrimeBad (p a : ℕ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : Prop := + ∃ hp : p ∈ P, letI : NeZero p := inferInstanceAs (NeZero (⟨p, hp⟩ : P).val) + allocatedActualModulusBad inactive spatial kernel block C (p ^ a) f + +theorem allocatedActualPrimeBad_iff_modulusBad (p : P) (a : ℕ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedActualPrimeBad inactive spatial kernel block P C p.val a f ↔ + allocatedActualModulusBad inactive spatial kernel block C (p.val ^ a) f := by + constructor + · rintro ⟨_, h⟩ + exact h + · intro h + exact ⟨p.property, h⟩ + +theorem allocatedActualPrimeBad_eq_rankBad (p a : ℕ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedActualPrimeBad inactive spatial kernel block P C p a f = + allocatedCongruenceRankBad inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block P C p a + (allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block) := rfl + +theorem allocatedActualPrimeBad_false_of_notMem {p : ℕ} (hp : p ∉ P) (a : ℕ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + ¬ allocatedActualPrimeBad inactive spatial kernel block P C p a f := by + rintro ⟨h, _⟩ + exact hp h + +theorem allocatedActualPrimeBad_depth (A : ℕ → ℕ) (p : ℕ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + largestTestedBadDepth A (allocatedActualPrimeBad inactive spatial kernel block P C) p f = + allocatedCongruenceBadDepth inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block P A C p := by + unfold allocatedCongruenceBadDepth largestTestedBadDepth + apply congrArg (fun t : Finset ℕ => t.sup id) + apply Finset.filter_congr + intro a _ + exact (allocatedActualPrimeBad_eq_rankBad inactive spatial kernel block P C p a f).to_iff + +theorem allocatedActualPrimeBad_prescribedDeep_eq (cutoff : ℕ → ℕ) (p a : ℕ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + prescribedDeepBad cutoff (allocatedActualPrimeBad inactive spatial kernel block P C) p a f = + prescribedDeepBad cutoff + (allocatedCongruenceRankBad inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block P C) p a + (allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block) := rfl + +theorem allocatedActualPrimeBad_deep_depth (A cutoff : ℕ → ℕ) (p : ℕ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + largestTestedBadDepth A + (prescribedDeepBad cutoff (allocatedActualPrimeBad inactive spatial kernel block P C)) p f = + largestTestedBadDepth A + (prescribedDeepBad cutoff + (allocatedCongruenceRankBad inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block P C)) p + (allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j, a.val⟩) spatial kernel block) := by + unfold largestTestedBadDepth + apply congrArg (fun t : Finset ℕ => t.sup id) + apply Finset.filter_congr + intro a _ + exact (allocatedActualPrimeBad_prescribedDeep_eq inactive spatial kernel block P C cutoff p a f).to_iff + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical +open FiniteProbabilityWeights + +private theorem affineWitness_uniform_le (Y : Type*) (f g : Fintype Y) + [Nonempty Y] (F : Y → Prop) (r : ℝ) + (h : @eventProbability Y f (@uniform Y f _) F ≤ r) : + @eventProbability Y g (@uniform Y g _) F ≤ r := by + cases Subsingleton.elim f g + exact h + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable local instance affineWitnessSmoothIndexFintype (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedSmoothRankCoefficientIndex X inactive L) := inferInstance +noncomputable local instance affineWitnessDeckIndexFintype : + Fintype (AllocatedDeckRankCoefficientIndex E L) := inferInstance +noncomputable local instance affineWitnessDeckIndexDecidableEq : + DecidableEq (AllocatedDeckRankCoefficientIndex E L) := Classical.decEq _ +noncomputable local instance affineWitnessCongruenceIndexFintype (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedCongruenceCoefficientIndex X E inactive L) := inferInstance +noncomputable local instance affineWitnessCongruenceIndexDecidableEq (inactive : LayerSamplerAxis I n → Prop) : + DecidableEq (AllocatedCongruenceCoefficientIndex X E inactive L) := Classical.decEq _ + +variable (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + +def allocatedAffineMixedModulusBad (stride : X → ℕ) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + (C : ℝ) (M : ℕ) [NeZero M] + (x : (AllocatedSmoothRankCoefficientIndex X inactive L ⊕ + AllocatedDeckRankCoefficientIndex E L) → ZMod M) : Prop := + allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C M + (allocatedCongruenceAffineCoefficients inactive (fun x => (stride x : ZMod M)) + (fun j => (offset j : ZMod M)) (allocatedMixedCoefficientEquiv inactive L (ZMod M) x)) + +theorem allocatedAffineMixedModulusBad_probability {p a D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (hdeep : ∀ x, 2 * (stride x).factorization p ≤ a) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + {C : ℝ} (hC : 0 ≤ C) + (hlarge : modularCoefficientPrimeThreshold m ≤ p ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (uniform ((AllocatedSmoothRankCoefficientIndex X inactive L ⊕ + AllocatedDeckRankCoefficientIndex E L) → ZMod (p ^ a))).eventProbability + (allocatedAffineMixedModulusBad inactive noise r projection spatial kernel block + stride offset C (p ^ a)) ≤ 1 / ((p ^ a : ℕ) : ℝ) ^ 10 := by + have he := allocatedMixedCoefficient_uniform_event (X := X) (E := E) inactive L (p ^ a) + (fun c => allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C (p ^ a) + (allocatedCongruenceAffineCoefficients inactive (fun x => (stride x : ZMod (p ^ a))) + (fun j => (offset j : ZMod (p ^ a))) c)) + have hs := allocatedCongruenceModulusBad_affine_probability inactive noise r projection + spatial kernel block hm hp ha hD stride hstride hdeep + (fun j => (offset j : ZMod (p ^ a))) hC hlarge hL + have hb := he.le.trans (affineWitness_uniform_le _ _ _ _ _ hs) + exact affineWitness_uniform_le _ _ _ _ _ hb + +theorem allocatedAffineMixed_primePower_event {N D : ℕ} [NeZero N] + (hm : 0 < m) (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hdeep : ∀ p ∈ P, ∀ x, 2 * (stride x).factorization p ≤ A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ width j) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => ∀ p : P, allocatedCongruenceModulusBad inactive noise r projection spatial kernel block + C (p.val ^ A p.val) (fun j => + (allocatedMixedAffineSelectedValues inactive (fun x => (stride x : ℤ)) offset + x.1.val x.2 j : ZMod (p.val ^ A p.val)))) ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) / width j := by + have h := mixedSmoothUniform_primePower_event (N := N) center width hwidth hZ P A + hprime hcover + (fun p => allocatedAffineMixedModulusBad inactive noise r projection spatial kernel block + stride offset C (p.val ^ A p.val)) + (fun p => by + have ht := allocatedAffineMixedModulusBad_probability inactive noise r projection spatial kernel block + hm (hprime p p.property) (hpositive p p.property) hD stride hstride (hdeep p p.property) + offset hC (hthreshold p p.property) hL + exact affineWitness_uniform_le _ _ _ _ _ ht) + hlarge + simpa only [allocatedAffineMixedModulusBad, allocatedMixedAffineSelectedValues_natCast] using h + +theorem allocatedAffineMixedActual_primePower_event + (fixed : AllocatedActualCoefficientIndex G X I E n B → ℤ) + {N D : ℕ} [NeZero N] + (hm : 0 < m) (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hdeep : ∀ p ∈ P, ∀ x, 2 * (stride x).factorization p ≤ A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ width j) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (Function.extend (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + (allocatedMixedAffineSelectedValues inactive (fun x => (stride x : ℤ)) offset x.1.val x.2) fixed)) ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) / width j := by + have h := allocatedAffineMixed_primePower_event inactive + (allocatedReadNoise fixed) (allocatedReadDeck fixed) + (fun j a => allocatedReadProjection fixed ⟨j,a.val⟩) spatial kernel block hm stride hstride offset + center width hwidth hZ P A hprime hcover hpositive hdeep hD hC hL hthreshold hlarge + simpa only [allocatedActualModulusBad, allocatedActualRefresh_modulusBad] using h + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical +open FiniteProbabilityWeights +attribute [local irreducible] allocatedActualModulusBad allocatedMixedFullArray independentProductPMF + +private theorem affine_decide_eq_classical (p : Prop) [d : Decidable p] : + @decide p d = @decide p (Classical.propDecidable p) := by + cases Subsingleton.elim d (Classical.propDecidable p) + rfl + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable local instance affineFullWitnessSmoothFintype : + Fintype (AllocatedFullSmoothCoefficientIndex G X I n B) := inferInstance +noncomputable local instance affineFullWitnessSmoothDecidableEq : + DecidableEq (AllocatedFullSmoothCoefficientIndex G X I n B) := Classical.decEq _ +noncomputable local instance affineFullWitnessSelectedSmoothDecidableEq (inactive : LayerSamplerAxis I n → Prop) : + DecidableEq (AllocatedSmoothRankCoefficientIndex X inactive L) := Classical.decEq _ +noncomputable local instance affineFullWitnessDeckFintype : + Fintype (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := inferInstance +noncomputable local instance affineFullWitnessDeckDecidableEq : + DecidableEq (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := Classical.decEq _ +noncomputable local instance affineFullWitnessSelectedSmoothFintype (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedSmoothRankCoefficientIndex X inactive L) := inferInstance +noncomputable local instance affineFullWitnessSelectedDeckFintype : + Fintype (AllocatedDeckRankCoefficientIndex E L) := inferInstance +noncomputable local instance affineFullWitnessSelectedDeckDecidableEq : + DecidableEq (AllocatedDeckRankCoefficientIndex E L) := Classical.decEq _ + +theorem allocatedAffineProductMixed_primePower_event + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (residue : Option (LayerSamplerVariables G I n B) × X → ℤ) + (laws : AllocatedFullSmoothCoefficientIndex G X I n B → PMF ℤ) + {N D : ℕ} [NeZero N] (hm : 0 < m) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (hcoordinate : ∀ i, laws (allocatedSmoothFullEmbedding inactive spatial block i) = + shiftedSmoothCoefficientPMF (center i) (width i) (hwidth i) + (shiftedSmoothProductMass_coordinate_pos center width hwidth hZ i)) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hdeep : ∀ p ∈ P, ∀ x, 2 * (stride x).factorization p ≤ A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ width j) : + (((independentProductPMF laws).bind + (fun x => (PMF.uniformOfFintype + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N)).map + (fun deck => decide (∀ p : P, + allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (allocatedFullSmoothAffine (fun x => (stride x : ℤ)) residue x) + (fun i => (deck i).val) continuous))))) true).toReal ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / width j := by + let e := allocatedSmoothFullEmbedding (X := X) inactive spatial block + let d := allocatedDeckFullEmbedding (E := E) (I := I) (n := n) (B := B) kernel + let bad : (AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) → + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) → Prop := + fun x deck => ∀ p : P, + allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (allocatedFullSmoothAffine (fun x => (stride x : ℤ)) residue x) + (fun i => (deck i).val) continuous) + let δ : ℝ := 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / width j + have hδ : 0 ≤ δ := add_nonneg (by positivity) + (Finset.sum_nonneg (fun j _ => div_nonneg (by positivity) (hwidth _).le)) + have hconditional : ∀ (fixed : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (fixedDeck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N), + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun z => bad (Function.extend e z.1.val fixed) (Function.extend d z.2 fixedDeck)) ≤ δ := by + intro fixed fixedDeck + have h := allocatedAffineMixedActual_primePower_event inactive spatial kernel block + (allocatedMixedFullArray + (allocatedFullSmoothAffine (fun x => (stride x : ℤ)) residue fixed) + (fun i => (fixedDeck i).val) continuous) hm stride hstride + (allocatedSelectedNoiseOffset inactive spatial residue) + center width hwidth hZ P A hprime hcover hpositive hdeep hD hC hL hthreshold hlarge + simpa only [e, d, bad, δ, allocatedMixedFullArray_affine_refresh_selected] using h + simpa only [bad, δ, affine_decide_eq_classical] using + independentProduct_uniform_smooth_selected_event_probability_le + e d laws center width hwidth hZ hcoordinate N bad hδ hconditional + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankAffineProbability.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankAffineProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..e932f34e077dda64e56eaceb30eabc85ce27be66 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankAffineProbability.lean @@ -0,0 +1,798 @@ +import OAI.Combinatorics.Progressions.Estimates.ModularHalfExponentExceptions +import OAI.Combinatorics.Progressions.Estimates.ModularUnitGCD +import OAI.Combinatorics.Progressions.Lattices.ModularAffineSpatialGCD +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankBadProduct +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankFullProductLaw + +namespace OAI + +section + +namespace Erdos3 + +theorem modularAffineSpatial_power_ratio_le {p : ℝ} (hp : 1 ≤ p) + {v a : ℕ} (hva : 2 * v ≤ a) : + p ^ v / p ^ a ≤ (p ^ a) ^ (-(1 : ℝ) / 2) := by + have hp0 : 0 < p := lt_of_lt_of_le zero_lt_one hp + have hexp : (v : ℝ) - a ≤ -(a : ℝ) / 2 := by + have h : (2 : ℝ) * v ≤ a := by exact_mod_cast hva + linarith + calc + p ^ v / p ^ a = p ^ ((v : ℝ) - (a : ℝ)) := by + rw [Real.rpow_sub hp0, Real.rpow_natCast, Real.rpow_natCast] + _ ≤ p ^ (-(a : ℝ) / 2) := Real.rpow_le_rpow_of_exponent_le hp hexp + _ = (p ^ a) ^ (-(1 : ℝ) / 2) := by + rw [← Real.rpow_natCast_mul hp0.le] + congr 1 + ring + +theorem modularRankSmallBallExponent_le_half {m : ℕ} (hm : 2 ≤ m) : + modularRankSmallBallExponent m ≤ (1 : ℝ) / 2 := by + have hmR : (2 : ℝ) ≤ m := by exact_mod_cast hm + calc + modularRankSmallBallExponent m ≤ (2 : ℝ) ^ (-(1 : ℝ)) := by + unfold modularRankSmallBallExponent + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + linarith + _ = (1 : ℝ) / 2 := by norm_num + +theorem modularAffineSpatial_sqrt_le_tag {q : ℝ} (hq : 1 ≤ q) + {m : ℕ} (hm : 2 ≤ m) : + q ^ (-(1 : ℝ) / 2) ≤ (m : ℝ) * q ^ (-modularRankSmallBallExponent m) := by + have hp : q ^ (-(1 : ℝ) / 2) ≤ q ^ (-modularRankSmallBallExponent m) := + Real.rpow_le_rpow_of_exponent_le hq (by + simpa only [neg_div] using neg_le_neg (modularRankSmallBallExponent_le_half hm)) + exact hp.trans (le_mul_of_one_le_left (Real.rpow_nonneg (by linarith) _) + (by exact_mod_cast (show 1 ≤ m by omega))) + +theorem modularAffineSpatial_gcd_cost_le_sqrt {stride p a : ℕ} + (hstride : 0 < stride) (hp : p.Prime) + (ha : 2 * stride.factorization p ≤ a) : + (Nat.gcd ((stride : ZMod (p ^ a)).val) (p ^ a) : ℝ) / + ((p ^ a : ℕ) : ℝ) ≤ ((p ^ a : ℕ) : ℝ) ^ (-(1 : ℝ) / 2) := by + rw [zmod_natCast_gcd_primePower_eq_pow_min_factorization hstride hp a, + min_eq_left (show stride.factorization p ≤ a by omega)] + push_cast + exact modularAffineSpatial_power_ratio_le (by exact_mod_cast hp.one_lt.le) ha + +theorem modularAffineSpatial_gcd_cost_le_tag {stride p a m : ℕ} + (hstride : 0 < stride) (hp : p.Prime) + (ha : 2 * stride.factorization p ≤ a) (hm : 2 ≤ m) : + (Nat.gcd ((stride : ZMod (p ^ a)).val) (p ^ a) : ℝ) / + ((p ^ a : ℕ) : ℝ) ≤ + (m : ℝ) * ((p ^ a : ℕ) : ℝ) ^ (-modularRankSmallBallExponent m) := by + apply (modularAffineSpatial_gcd_cost_le_sqrt hstride hp ha).trans + apply modularAffineSpatial_sqrt_le_tag _ hm + exact_mod_cast (Nat.one_le_pow a p hp.pos) + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +theorem designatedPolynomial_affine_linearRow_zero_probability_le {A I : Type*} + [Fintype A] [DecidableEq A] [Fintype I] [decI : DecidableEq I] + (N : ℕ) [NeZero N] (S : A → Finset I) (selected : A → I) + (hselected : ∀ i, selected i ∈ S i) (hcard : ∀ i, (S i).card = 1) + (hdisjoint : Pairwise (fun i j => Disjoint (S i) (S j))) + (Q : MvPolynomial I (ZMod N)) (offset multiplier : A → ZMod N) + (u : Fin 0 → I → ZMod N) : + (𝔼 c : A → ZMod N, + if polynomialLinearRow (polynomialIterDifference 0 + (Q + ∑ i, (offset i + multiplier i * c i) • ∏ j ∈ S i, X j) u) = 0 + then (1 : ℝ) else 0) ≤ + ∏ i, (Nat.gcd (multiplier i).val N : ℝ) / N := by + apply uniform_selected_row_zero_probability_le N _ selected + (fun i => (polynomialIterDifference 0 Q u).coeff + (Finsupp.single (selected i) 1) + offset i) multiplier + intro c i + have h := polynomialIterDifference_disjoint_designated_linearCoeff + Finset.univ S (fun i => offset i + multiplier i * c i) Q 0 i + (Finset.mem_univ _) (selected i) (hselected i) (hcard i) + (fun _ _ _ _ hij => hdisjoint hij) u + have he (d : DecidableEq I) : @Finset.erase I d (S i) (selected i) = ∅ := by + let := d + apply Finset.card_eq_zero.mp + rw [Finset.card_erase_of_mem (hselected i), hcard] + simpa only [polynomialLinearRow, squarefreePermanent, he, ite_true, mul_one, + add_assoc, mul_comm] using h + +theorem designatedPolynomial_expected_affine_linearRow_zero_le {A I : Type*} + [Fintype A] [DecidableEq A] [Fintype I] [DecidableEq I] + (N : ℕ) [NeZero N] (S : A → Finset I) + (hcard : ∀ i, (S i).card = 1) + (hdisjoint : Pairwise (fun i j => Disjoint (S i) (S j))) + (Q : MvPolynomial I (ZMod N)) (offset multiplier : A → ZMod N) : + (𝔼 c : A → ZMod N, 𝔼 u : Fin 0 → I → ZMod N, + if polynomialLinearRow (polynomialIterDifference 0 + (Q + ∑ i, (offset i + multiplier i * c i) • ∏ j ∈ S i, X j) u) = 0 + then (1 : ℝ) else 0) ≤ + ∏ i, (Nat.gcd (multiplier i).val N : ℝ) / N := by + have hnonempty (i : A) : (S i).Nonempty := + Finset.card_pos.mp (by rw [hcard]; omega) + choose selected hselected using hnonempty + rw [Finset.expect_comm] + calc + _ ≤ 𝔼 _u : Fin 0 → I → ZMod N, + ∏ i, (Nat.gcd (multiplier i).val N : ℝ) / N := by + apply Finset.expect_le_expect + intro u _ + exact designatedPolynomial_affine_linearRow_zero_probability_le N S selected + hselected hcard hdisjoint Q offset multiplier u + _ = _ := Fintype.expect_const _ + +theorem affineCoefficientArray_update {A B R : Type*} [DecidableEq B] [Semiring R] + (offset : B → A → R) (multiplier : B → R) (c : B → A → R) + (b₀ : B) (d : A → R) : + (fun b i => offset b i + multiplier b * Function.update c b₀ d b i) = + Function.update (fun b i => offset b i + multiplier b * c b i) b₀ + (fun i => offset b₀ i + multiplier b₀ * d i) := by + funext b i + by_cases hb : b = b₀ + · subst b + simp only [Function.update_self] + · simp only [Function.update_of_ne hb] + +theorem vectorDesignatedRankFailureProbability_affine_mean_le {A B I : Type*} + [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] (N : ℕ) [NeZero N] + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod N)) + (w : B → ZMod N) (b₀ : B) + (hcard : ∀ i, (S b₀ i).card = 1) + (hdisjoint : Pairwise (fun i j => Disjoint (S b₀ i) (S b₀ j))) + (offset : B → A → ZMod N) (multiplier : B → ZMod N) : + (FiniteProbabilityWeights.uniform (B → A → ZMod N)).mean + (fun c => vectorDesignatedRankFailureProbability N 0 S Q w + (fun b i => offset b i + multiplier b * c b i)) ≤ + ((Nat.gcd (w b₀ * multiplier b₀).val N : ℝ) / N) ^ Fintype.card A := by + have hconditional (c : B → A → ZMod N) : + (𝔼 d : A → ZMod N, vectorDesignatedRankFailureProbability N 0 S Q w + (fun b i => offset b i + multiplier b * Function.update c b₀ d b i)) ≤ + ((Nat.gcd (w b₀ * multiplier b₀).val N : ℝ) / N) ^ Fintype.card A := by + simp_rw [affineCoefficientArray_update] + unfold vectorDesignatedRankFailureProbability + simp_rw [designatedVectorComponent_update_row, mul_add, ← mul_assoc] + have h := designatedPolynomial_expected_affine_linearRow_zero_le N (S b₀) + hcard hdisjoint + ((∑ b ∈ Finset.univ.erase b₀, w b • designatedVectorComponent S Q + (fun b i => offset b i + multiplier b * c b i) b) + w b₀ • Q b₀) + (fun i => w b₀ * offset b₀ i) (fun _ => w b₀ * multiplier b₀) + simpa only [Finset.prod_const, Finset.card_univ] using h + rw [FiniteProbabilityWeights.uniform_mean, + ← expect_uniform_coordinate_refresh b₀ (fun c : B → A → ZMod N => + vectorDesignatedRankFailureProbability N 0 S Q w + (fun b i => offset b i + multiplier b * c b i))] + calc + _ ≤ 𝔼 _c : B → A → ZMod N, + ((Nat.gcd (w b₀ * multiplier b₀).val N : ℝ) / N) ^ Fintype.card A := + Finset.expect_le_expect (fun c _ => hconditional c) + _ = _ := Fintype.expect_const _ + +theorem vectorDesignatedRankFailureProbability_affine_mean_le_of_unit {A B I : Type*} + [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] (N : ℕ) [NeZero N] + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod N)) + (w : B → ZMod N) (b₀ : B) (hunit : IsUnit (w b₀)) + (hcard : ∀ i, (S b₀ i).card = 1) + (hdisjoint : Pairwise (fun i j => Disjoint (S b₀ i) (S b₀ j))) + (offset : B → A → ZMod N) (multiplier : B → ZMod N) : + (FiniteProbabilityWeights.uniform (B → A → ZMod N)).mean + (fun c => vectorDesignatedRankFailureProbability N 0 S Q w + (fun b i => offset b i + multiplier b * c b i)) ≤ + ((Nat.gcd (multiplier b₀).val N : ℝ) / N) ^ Fintype.card A := by + obtain ⟨unit, hunit⟩ := hunit + have h := vectorDesignatedRankFailureProbability_affine_mean_le N S Q w b₀ + hcard hdisjoint offset multiplier + rw [← hunit, zmod_gcd_unit_mul] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +noncomputable def affineSpatialCoefficients {A B R : Type*} [Semiring R] + (spatial : B → Prop) (stride : B → ℕ) (offset : B → A → R) + (c : B → A → R) : B → A → R := + fun b i => if spatial b then (stride b : R) * c b i + offset b i else c b i + +theorem vectorDesignatedRankFailureProbability_affineSpatial_zero_mean_le + {A B I : Type*} [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] {p a : ℕ} {stride : B → ℕ} [NeZero p] + (hp : p.Prime) (ha : 0 < a) (spatial : B → Prop) + (hstride : ∀ b, spatial b → 0 < stride b) + (hdeep : ∀ b, spatial b → 2 * (stride b).factorization p ≤ a) (offset : B → A → ZMod (p ^ a)) + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod (p ^ a))) + (hcard : ∀ b i, (S b i).card = 1) + (hdisjoint : ∀ b, Pairwise (fun i j => Disjoint (S b i) (S b j))) + (w : B → ZMod (p ^ a)) (hprimitive : ∃ b, IsUnit (w b)) : + (FiniteProbabilityWeights.uniform (B → A → ZMod (p ^ a))).mean + (fun c => vectorDesignatedRankFailureProbability (p ^ a) 0 S Q w + (affineSpatialCoefficients spatial stride offset c)) ≤ + (((p : ℝ) ^ a) ^ (-(1 : ℝ) / 2)) ^ Fintype.card A := by + obtain ⟨b₀, hb₀⟩ := hprimitive + let off : B → A → ZMod (p ^ a) := fun b i => if spatial b then offset b i else 0 + let mult : B → ZMod (p ^ a) := fun b => if spatial b then (stride b : ZMod (p ^ a)) else 1 + have he (c : B → A → ZMod (p ^ a)) : + affineSpatialCoefficients spatial stride offset c = + fun b i => off b i + mult b * c b i := by + funext b i + by_cases hb : spatial b <;> simp [affineSpatialCoefficients, off, mult, hb, add_comm] + simp_rw [he] + apply (vectorDesignatedRankFailureProbability_affine_mean_le_of_unit (p ^ a) + S Q w b₀ hb₀ (hcard b₀) (hdisjoint b₀) off mult).trans + apply pow_le_pow_left₀ (by positivity) + by_cases hb : spatial b₀ + · simpa only [mult, ite_eq_left hb, Nat.cast_pow] using + modularAffineSpatial_gcd_cost_le_sqrt (hstride b₀ hb) hp (hdeep b₀ hb) + · have h := modularAffineSpatial_gcd_cost_le_sqrt (stride := 1) + (by norm_num) hp (show 2 * Nat.factorization 1 p ≤ a from + calc + 2 * Nat.factorization 1 p = 0 := by simp + _ ≤ a := ha.le) + simpa only [mult, ite_eq_right hb, Nat.cast_one, Nat.cast_pow] using h + +theorem affineSpatialCoefficients_eq_self {A B R : Type*} [Semiring R] + (spatial : B → Prop) (stride : B → ℕ) (offset : B → A → R) + (c : B → A → R) (hspatial : ∀ b, ¬ spatial b) : + affineSpatialCoefficients spatial stride offset c = c := by + funext b i + simp only [affineSpatialCoefficients, ite_eq_right (hspatial b)] + +theorem vectorDesignatedRankFailureProbability_affineSpatial_mean_le + {A B I : Type*} [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] {p a n s : ℕ} {stride : B → ℕ} [NeZero p] + (hp : p.Prime) (ha : 0 < a) (hs : 2 ≤ s) (hns : n + 1 ≤ s) + (spatial : B → Prop) (hspatial : ∀ b, spatial b → n = 0) + (hstride : ∀ b, spatial b → 0 < stride b) + (hdeep : ∀ b, spatial b → 2 * (stride b).factorization p ≤ a) + (offset : B → A → ZMod (p ^ a)) + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod (p ^ a))) + (hcard : ∀ b i, (S b i).card = n + 1) + (hdisjoint : ∀ b, Pairwise (fun i j => Disjoint (S b i) (S b j))) + (w : B → ZMod (p ^ a)) (hprimitive : ∃ b, IsUnit (w b)) : + (FiniteProbabilityWeights.uniform (B → A → ZMod (p ^ a))).mean + (fun c => vectorDesignatedRankFailureProbability (p ^ a) n S Q w + (affineSpatialCoefficients spatial stride offset c)) ≤ + ((s : ℝ) * ((p : ℝ) ^ a) ^ (-modularRankSmallBallExponent s)) ^ Fintype.card A := by + by_cases hn : n = 0 + · subst n + apply (vectorDesignatedRankFailureProbability_affineSpatial_zero_mean_le + hp ha spatial hstride hdeep offset S Q hcard hdisjoint w hprimitive).trans + apply pow_le_pow_left₀ (by positivity) + exact modularAffineSpatial_sqrt_le_tag + (one_le_pow₀ (by exact_mod_cast hp.one_lt.le)) hs + · have hnone (b : B) : ¬ spatial b := fun hb => hn (hspatial b hb) + simp_rw [affineSpatialCoefficients_eq_self spatial stride offset _ hnone] + exact vectorDesignatedRankFailureProbability_mean_le hp ha hns S Q + hcard hdisjoint w hprimitive + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +theorem taggedVectorDesignatedRank_affineSpatial_exceptional_probability {T A I : Type*} + [Fintype T] [DecidableEq T] [Fintype A] [DecidableEq A] + [Fintype I] [DecidableEq I] {B : T → Type*} + [∀ t, Fintype (B t)] [∀ t, DecidableEq (B t)] + {p a s m : ℕ} [NeZero p] (hp : p.Prime) (ha : 0 < a) + (n : T → ℕ) (hns : ∀ t, n t + 1 ≤ s) (hTs : Fintype.card T ≤ s) + (hBm : ∀ t, Fintype.card (B t) ≤ m) + (spatial : ∀ t, B t → Prop) + (hspatial : ∀ t b, spatial t b → n t = 0) + (stride : ∀ t, B t → ℕ) + (hstride : ∀ t b, spatial t b → 0 < stride t b) + (hdeep : ∀ t b, spatial t b → 2 * (stride t b).factorization p ≤ a) + (offset : ∀ t, B t → A → ZMod (p ^ a)) + (S : ∀ t, B t → A → Finset I) + (Q : ∀ t, B t → MvPolynomial I (ZMod (p ^ a))) + (hcard : ∀ t b j, (S t b j).card = n t + 1) + (hdisjoint : ∀ t b, Pairwise (fun j k => Disjoint (S t b j) (S t b k))) + {C : ℝ} (hC : 0 ≤ C) + (hq : max 2 ((s : ℝ) ^ (4 / modularRankSmallBallExponent s)) ≤ (p : ℝ) ^ a) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ Fintype.card A) : + (FiniteProbabilityWeights.uniform (∀ t, B t → A → ZMod (p ^ a))).eventProbability + (fun c => ∃ t, ∃ w : B t → ZMod (p ^ a), (∃ b, IsUnit (w b)) ∧ + ((p : ℝ) ^ a) ^ (-C) < + vectorDesignatedRankFailureProbability (p ^ a) (n t) (S t) (Q t) w + (affineSpatialCoefficients (spatial t) (stride t) (offset t) (c t))) ≤ + ((p : ℝ) ^ a) ^ (-(10 : ℝ)) := by + let Rows (t : T) := {w : B t → ZMod (p ^ a) // ∃ b, IsUnit (w b)} + let Row := Σ t, Rows t + let ρ : Row → (∀ t, B t → A → ZMod (p ^ a)) → ℝ := fun w c => + vectorDesignatedRankFailureProbability (p ^ a) (n w.1) (S w.1) (Q w.1) w.2.val + (affineSpatialCoefficients (spatial w.1) (stride w.1) (offset w.1) (c w.1)) + have hρ (w : Row) (c) : 0 ≤ ρ w c := + vectorDesignatedRankFailureProbability_nonneg (p ^ a) (n w.1) (S w.1) (Q w.1) w.2.val + (affineSpatialCoefficients (spatial w.1) (stride w.1) (offset w.1) (c w.1)) + have hq1 : (1 : ℝ) ≤ (p : ℝ) ^ a := one_le_pow₀ (by exact_mod_cast hp.one_lt.le) + have hcount (t : T) : (Fintype.card (Rows t) : ℝ) ≤ ((p : ℝ) ^ a) ^ (m : ℝ) := by + calc + _ ≤ (Fintype.card (B t → ZMod (p ^ a)) : ℝ) := by + exact_mod_cast Fintype.card_subtype_le (fun w : B t → ZMod (p ^ a) => ∃ b, IsUnit (w b)) + _ = ((p : ℝ) ^ a) ^ (Fintype.card (B t) : ℝ) := by + simp [ZMod.card, Real.rpow_natCast] + _ ≤ _ := Real.rpow_le_rpow_of_exponent_le hq1 (by exact_mod_cast hBm t) + have hrows : (Fintype.card Row : ℝ) ≤ (s : ℝ) * ((p : ℝ) ^ a) ^ (m : ℝ) := by + change (Fintype.card (Σ t, Rows t) : ℝ) ≤ _ + rw [Fintype.card_sigma, Nat.cast_sum] + calc + _ ≤ ∑ _t : T, ((p : ℝ) ^ a) ^ (m : ℝ) := Finset.sum_le_sum (fun t _ => hcount t) + _ = (Fintype.card T : ℝ) * ((p : ℝ) ^ a) ^ (m : ℝ) := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hTs) (by positivity) + have h : + (FiniteProbabilityWeights.uniform (∀ t, B t → A → ZMod (p ^ a))).eventProbability + (fun c => ∃ w : Row, ((p : ℝ) ^ a) ^ (-C) < ρ w c) ≤ + ((p : ℝ) ^ a) ^ (-(10 : ℝ)) := by + by_cases hs : 2 ≤ s + · apply modularRank_exceptional_probability_of_parameters + (FiniteProbabilityWeights.uniform (∀ t, B t → A → ZMod (p ^ a))) ρ hρ + hC (Nat.cast_nonneg m) hq hJ hrows + intro w + rw [FiniteProbabilityWeights.uniform_mean] + change (𝔼 c : ∀ t, B t → A → ZMod (p ^ a), + vectorDesignatedRankFailureProbability (p ^ a) (n w.1) (S w.1) (Q w.1) w.2.val + (affineSpatialCoefficients (spatial w.1) (stride w.1) (offset w.1) (c w.1))) ≤ _ + rw [expect_uniform_coordinate (X := fun t => B t → A → ZMod (p ^ a)) w.1 + (fun d => vectorDesignatedRankFailureProbability (p ^ a) (n w.1) + (S w.1) (Q w.1) w.2.val + (affineSpatialCoefficients (spatial w.1) (stride w.1) (offset w.1) d))] + have hh := vectorDesignatedRankFailureProbability_affineSpatial_mean_le + hp ha hs (hns w.1) (spatial w.1) (hspatial w.1) (hstride w.1) (hdeep w.1) (offset w.1) + (S w.1) (Q w.1) (hcard w.1) (hdisjoint w.1) w.2.val w.2.property + simpa only [FiniteProbabilityWeights.uniform_mean] using hh + · by_cases hs0 : s = 0 + · apply modularRank_exceptional_probability_of_parameters + (FiniteProbabilityWeights.uniform (∀ t, B t → A → ZMod (p ^ a))) ρ hρ + hC (Nat.cast_nonneg m) hq hJ hrows + intro w + have hh := hns w.1 + omega + · have hs1 : s = 1 := by omega + have hJ1 : 2 * (C + m + 10) ≤ (Fintype.card A : ℝ) := by + have hh := Nat.le_of_ceil_le hJ + simpa [hs1, modularRankSmallBallExponent] using hh + have hrows1 : (Fintype.card Row : ℝ) ≤ ((p : ℝ) ^ a) ^ (m : ℝ) := by + simpa [hs1] using hrows + apply modularRank_half_exceptional_probability + (FiniteProbabilityWeights.uniform (∀ t, B t → A → ZMod (p ^ a))) ρ hρ + hq1 hJ1 hrows1 + intro w + have hn : n w.1 = 0 := by have hh := hns w.1; omega + rw [FiniteProbabilityWeights.uniform_mean] + change (𝔼 c : ∀ t, B t → A → ZMod (p ^ a), + vectorDesignatedRankFailureProbability (p ^ a) (n w.1) (S w.1) (Q w.1) w.2.val + (affineSpatialCoefficients (spatial w.1) (stride w.1) (offset w.1) (c w.1))) ≤ _ + rw [expect_uniform_coordinate (X := fun t => B t → A → ZMod (p ^ a)) w.1 + (fun d => vectorDesignatedRankFailureProbability (p ^ a) (n w.1) + (S w.1) (Q w.1) w.2.val + (affineSpatialCoefficients (spatial w.1) (stride w.1) (offset w.1) d))] + have hcard1 : ∀ b j, (S w.1 b j).card = 1 := by + simpa [hn] using hcard w.1 + have hh := vectorDesignatedRankFailureProbability_affineSpatial_zero_mean_le + hp ha (spatial w.1) (hstride w.1) (hdeep w.1) (offset w.1) (S w.1) (Q w.1) + hcard1 (hdisjoint w.1) w.2.val w.2.property + simpa only [FiniteProbabilityWeights.uniform_mean, hn] using hh + have hev (c : ∀ t, B t → A → ZMod (p ^ a)) : + (∃ w : Row, ((p : ℝ) ^ a) ^ (-C) < ρ w c) ↔ + (∃ t, ∃ w : B t → ZMod (p ^ a), (∃ b, IsUnit (w b)) ∧ + ((p : ℝ) ^ a) ^ (-C) < + vectorDesignatedRankFailureProbability (p ^ a) (n t) (S t) (Q t) w + (affineSpatialCoefficients (spatial t) (stride t) (offset t) (c t))) := by + constructor + · rintro ⟨⟨t, ⟨w, hw⟩⟩, hh⟩ + exact ⟨t, w, hw, hh⟩ + · rintro ⟨t, w, hw, hh⟩ + exact ⟨⟨t, ⟨w, hw⟩⟩, hh⟩ + simpa only [hev] using h + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +variable {T D I : Type*} [Fintype T] [DecidableEq T] + [Fintype D] [DecidableEq D] [Fintype I] [DecidableEq I] + {B : T → Type*} [∀ t, Fintype (B t)] [∀ t, DecidableEq (B t)] + +theorem scalarCoefficientBad_affineSpatial_probability_eq (n : T → ℕ) + (S : ∀ t, B t → D → Finset I) (Q : ∀ t, B t → MvPolynomial I ℤ) + (C : ℝ) (M : ℕ) [NeZero M] + (spatial : ∀ t, B t → Prop) (stride : ∀ t, B t → ℕ) + (offset : ∀ t, B t → D → ZMod M) : + (FiniteProbabilityWeights.uniform ((Σ t, B t × D) → ZMod M)).eventProbability + (fun x => scalarCoefficientBad n S Q C M + (fun j => affineSpatialCoefficients (spatial j.1) (stride j.1) (offset j.1) + (scalarCoefficientTupleEquiv x j.1) j.2.1 j.2.2)) = + (FiniteProbabilityWeights.uniform (∀ t, B t → D → ZMod M)).eventProbability + (fun c => ∃ t, ∃ w : B t → ZMod M, (∃ b, IsUnit (w b)) ∧ + (M : ℝ) ^ (-C) < vectorDesignatedRankFailureProbability M (n t) (S t) + (fun b => (Q t b).map (Int.castRingHom (ZMod M))) w + (affineSpatialCoefficients (spatial t) (stride t) (offset t) (c t))) := by + let e := scalarCoefficientTupleEquiv (T := T) (B := B) (D := D) (V := ZMod M) + have h := uniform_mean_surjective_hom e.toAddMonoidHom e.surjective + (fun c => @ite ℝ (∃ t, ∃ w : B t → ZMod M, (∃ b, IsUnit (w b)) ∧ + (M : ℝ) ^ (-C) < vectorDesignatedRankFailureProbability M (n t) (S t) + (fun b => (Q t b).map (Int.castRingHom (ZMod M))) w + (affineSpatialCoefficients (spatial t) (stride t) (offset t) (c t))) + (Classical.propDecidable _) 1 0) + exact h + +theorem scalarCoefficientBad_affineSpatial_probability {p a s m : ℕ} [NeZero p] + (hp : p.Prime) (ha : 0 < a) + (n : T → ℕ) (hns : ∀ t, n t + 1 ≤ s) (hTs : Fintype.card T ≤ s) + (hBm : ∀ t, Fintype.card (B t) ≤ m) + (spatial : ∀ t, B t → Prop) + (hspatial : ∀ t b, spatial t b → n t = 0) + (stride : ∀ t, B t → ℕ) + (hstride : ∀ t b, spatial t b → 0 < stride t b) + (hdeep : ∀ t b, spatial t b → 2 * (stride t b).factorization p ≤ a) + (offset : ∀ t, B t → D → ZMod (p ^ a)) + (S : ∀ t, B t → D → Finset I) (Q : ∀ t, B t → MvPolynomial I ℤ) + (hcard : ∀ t b j, (S t b j).card = n t + 1) + (hdisjoint : ∀ t b, Pairwise (fun j k => Disjoint (S t b j) (S t b k))) + {C : ℝ} (hC : 0 ≤ C) + (hlarge : modularCoefficientPrimeThreshold s ≤ p ^ a) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ Fintype.card D) : + (FiniteProbabilityWeights.uniform ((Σ t, B t × D) → ZMod (p ^ a))).eventProbability + (fun x => scalarCoefficientBad n S Q C (p ^ a) + (fun j => affineSpatialCoefficients (spatial j.1) (stride j.1) (offset j.1) + (scalarCoefficientTupleEquiv x j.1) j.2.1 j.2.2)) ≤ + 1 / ((p ^ a : ℕ) : ℝ) ^ 10 := by + rw [scalarCoefficientBad_affineSpatial_probability_eq] + have h := taggedVectorDesignatedRank_affineSpatial_exceptional_probability + hp ha n hns hTs hBm spatial hspatial stride hstride hdeep offset S + (fun t b => (Q t b).map (Int.castRingHom (ZMod (p ^ a)))) hcard hdisjoint hC + (modularCoefficientPrimeThreshold_le_primePower hlarge) hJ + simpa only [Nat.cast_pow, primePower_rpow_neg_ten] using h + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {L : ℕ} {R : Type*} + +def allocatedCongruenceIsSpatial (inactive : LayerSamplerAxis I n → Prop) + (j : Fin m) : AllocatedCongruenceRankOutput X E inactive j → Prop + | .inl _ => True + | .inr _ => False + +theorem allocatedCongruenceIsSpatial_degree + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (o : AllocatedCongruenceRankOutput X E inactive j) + (ho : allocatedCongruenceIsSpatial inactive j o) : j.val = 0 := by + cases o with + | inl x => exact x.property + | inr o => exact False.elim ho + +def allocatedCongruenceAffineCoefficients [Semiring R] + (inactive : LayerSamplerAxis I n → Prop) (stride : X → R) + (offset c : AllocatedCongruenceCoefficientIndex X E inactive L → R) : + AllocatedCongruenceCoefficientIndex X E inactive L → R + | ⟨j,.inl x,l⟩ => offset ⟨j,.inl x,l⟩ + stride x.val * c ⟨j,.inl x,l⟩ + | ⟨j,.inr o,l⟩ => c ⟨j,.inr o,l⟩ + +theorem allocatedCongruenceAffineCoefficients_spatial [Semiring R] + (inactive : LayerSamplerAxis I n → Prop) (stride : X → R) + (offset c : AllocatedCongruenceCoefficientIndex X E inactive L → R) + (j : Fin m) (x : SpatialDegreeOutput X j) (l : Fin L) : + allocatedCongruenceAffineCoefficients inactive stride offset c ⟨j,.inl x,l⟩ = + offset ⟨j,.inl x,l⟩ + stride x.val * c ⟨j,.inl x,l⟩ := rfl + +theorem allocatedCongruenceAffineCoefficients_nonspatial [Semiring R] + (inactive : LayerSamplerAxis I n → Prop) (stride : X → R) + (offset c : AllocatedCongruenceCoefficientIndex X E inactive L → R) + (j : Fin m) (o : E j ⊕ AllocatedCongruenceIntegerAxis inactive j) (l : Fin L) : + allocatedCongruenceAffineCoefficients inactive stride offset c ⟨j,.inr o,l⟩ = + c ⟨j,.inr o,l⟩ := rfl + +theorem allocatedCongruenceAffineCoefficients_intCast + (inactive : LayerSamplerAxis I n → Prop) (stride : X → ℤ) + (offset c : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) (N : ℕ) : + (fun j => ((allocatedCongruenceAffineCoefficients (R := ℤ) inactive stride offset c j : ℤ) : ZMod N)) = + allocatedCongruenceAffineCoefficients inactive (fun x => (stride x : ZMod N)) + (fun j => (offset j : ZMod N)) (fun j => (c j : ZMod N)) := by + funext j + rcases j with ⟨j,(x | o),l⟩ + · simp only [allocatedCongruenceAffineCoefficients, Int.cast_add, Int.cast_mul] + · rfl + +noncomputable def allocatedMixedAffineSelectedValues + (inactive : LayerSamplerAxis I n → Prop) (stride : X → ℤ) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + {N : ℕ} (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + AllocatedCongruenceCoefficientIndex X E inactive L → ℤ := + allocatedCongruenceAffineCoefficients inactive stride offset + (allocatedMixedSelectedValues inactive x deck) + +theorem allocatedMixedAffineSelectedValues_cast + (inactive : LayerSamplerAxis I n → Prop) (stride : X → ℤ) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + {N : ℕ} [NeZero N] (M : ℕ) + (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + allocatedCongruenceAffineCoefficients inactive (fun x => (stride x : ZMod M)) + (fun j => (offset j : ZMod M)) + (allocatedMixedCoefficientEquiv inactive L (ZMod M) + (Sum.elim (fun j => (x j : ZMod M)) (fun j => ZMod.cast (deck j)))) = + (fun j => (allocatedMixedAffineSelectedValues inactive stride offset x deck j : ZMod M)) := by + rw [allocatedMixedCoefficientEquiv_cast] + exact (allocatedCongruenceAffineCoefficients_intCast inactive stride offset _ M).symm + +theorem allocatedMixedAffineSelectedValues_natCast + (inactive : LayerSamplerAxis I n → Prop) (stride : X → ℕ) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + {N : ℕ} [NeZero N] (M : ℕ) + (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + allocatedCongruenceAffineCoefficients inactive (fun x => (stride x : ZMod M)) + (fun j => (offset j : ZMod M)) + (allocatedMixedCoefficientEquiv inactive L (ZMod M) + (Sum.elim (fun j => (x j : ZMod M)) (fun j => ZMod.cast (deck j)))) = + (fun j => (allocatedMixedAffineSelectedValues inactive (fun x => (stride x : ℤ)) + offset x deck j : ZMod M)) := by + simpa only [Int.cast_natCast] using + allocatedMixedAffineSelectedValues_cast inactive (fun x => (stride x : ℤ)) offset M x deck + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} {R : Type*} + +def allocatedFullSmoothAffine [Semiring R] (stride : X → R) + (residue : Option (LayerSamplerVariables G I n B) × X → R) + (z : AllocatedFullSmoothCoefficientIndex G X I n B → R) : + AllocatedFullSmoothCoefficientIndex G X I n B → R + | .inl t => residue t + stride t.2 * z (.inl t) + | .inr t => z (.inr t) + +def allocatedSelectedNoiseOffset [Semiring R] + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (residue : Option (LayerSamplerVariables G I n B) × X → R) : + AllocatedCongruenceCoefficientIndex X E inactive L → R + | ⟨_j,.inl x,l⟩ => residue (some (.inl (spatial l)),x.val) + | ⟨_j,.inr _,_l⟩ => 0 + +def allocatedSelectedSmoothAffine [Semiring R] + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (stride : X → R) (residue : Option (LayerSamplerVariables G I n B) × X → R) + (z : AllocatedSmoothRankCoefficientIndex X inactive L → R) : + AllocatedSmoothRankCoefficientIndex X inactive L → R + | ⟨j,.inl x,l⟩ => residue (some (.inl (spatial l)),x.val) + stride x.val * z ⟨j,.inl x,l⟩ + | ⟨j,.inr i,l⟩ => z ⟨j,.inr i,l⟩ + +theorem allocatedFullSmoothAffine_extend [Semiring R] + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) + (stride : X → R) (residue : Option (LayerSamplerVariables G I n B) × X → R) + (selected : AllocatedSmoothRankCoefficientIndex X inactive L → R) + (fixed : AllocatedFullSmoothCoefficientIndex G X I n B → R) : + allocatedFullSmoothAffine stride residue + (Function.extend (allocatedSmoothFullEmbedding inactive spatial block) selected fixed) = + Function.extend (allocatedSmoothFullEmbedding inactive spatial block) + (allocatedSelectedSmoothAffine inactive spatial stride residue selected) + (allocatedFullSmoothAffine stride residue fixed) := by + let F : AllocatedFullSmoothCoefficientIndex G X I n B → R → R := + fun t v => match t with + | .inl t => residue t + stride t.2 * v + | .inr _ => v + have hs : (fun a => F (allocatedSmoothFullEmbedding inactive spatial block a) (selected a)) = + allocatedSelectedSmoothAffine inactive spatial stride residue selected := by + funext a + rcases a with ⟨j,(x | i),l⟩ <;> rfl + have h := map_coordinate_extend (allocatedSmoothFullEmbedding inactive spatial block) F selected fixed + have hf (z : AllocatedFullSmoothCoefficientIndex G X I n B → R) : + (fun t => F t (z t)) = allocatedFullSmoothAffine stride residue z := by + funext t + rcases t with t | t <;> rfl + rw [hs, hf, hf] at h + exact h + +theorem allocatedMixedSelectedValues_affine {N : ℕ} + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (stride : X → ℤ) (residue : Option (LayerSamplerVariables G I n B) × X → ℤ) + (selected : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + allocatedMixedSelectedValues inactive + (allocatedSelectedSmoothAffine inactive spatial stride residue selected) deck = + allocatedMixedAffineSelectedValues inactive stride + (allocatedSelectedNoiseOffset inactive spatial residue) selected deck := by + funext a + rcases a with ⟨j,(x | e | i),l⟩ <;> rfl + +theorem allocatedMixedFullArray_affine_refresh_selected {N : ℕ} + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) + (stride : X → ℤ) (residue : Option (LayerSamplerVariables G I n B) × X → ℤ) + (selectedSmooth : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (selectedDeck : AllocatedDeckRankCoefficientIndex E L → ZMod N) + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) : + allocatedMixedFullArray + (allocatedFullSmoothAffine stride residue + (Function.extend (allocatedSmoothFullEmbedding inactive spatial block) selectedSmooth smooth)) + (fun k => ((Function.extend (allocatedDeckFullEmbedding kernel) selectedDeck deck k).val : ℤ)) continuous = + Function.extend (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + (allocatedMixedAffineSelectedValues inactive stride + (allocatedSelectedNoiseOffset inactive spatial residue) selectedSmooth selectedDeck) + (allocatedMixedFullArray (allocatedFullSmoothAffine stride residue smooth) + (fun k => (deck k).val) continuous) := by + rw [allocatedFullSmoothAffine_extend, allocatedMixedFullArray_refresh_selected, + allocatedMixedSelectedValues_affine] + +theorem allocatedFullSmoothAffine_intCast + (stride : X → ℤ) (residue : Option (LayerSamplerVariables G I n B) × X → ℤ) + (z : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) (N : ℕ) : + (fun t => ((allocatedFullSmoothAffine (R := ℤ) stride residue z t : ℤ) : ZMod N)) = + allocatedFullSmoothAffine (fun x => (stride x : ZMod N)) + (fun t => (residue t : ZMod N)) (fun t => (z t : ZMod N)) := by + funext t + rcases t with t | t + · simp only [allocatedFullSmoothAffine, Int.cast_add, Int.cast_mul] + · rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +private theorem affine_uniform_eventProbability_le_instances (Y : Type*) (f g : Fintype Y) + [Nonempty Y] (A : Y → Prop) (r : ℝ) + (h : @FiniteProbabilityWeights.eventProbability Y f + (@FiniteProbabilityWeights.uniform Y f _) A ≤ r) : + @FiniteProbabilityWeights.eventProbability Y g + (@FiniteProbabilityWeights.uniform Y g _) A ≤ r := by + cases Subsingleton.elim f g + exact h + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + +def allocatedCongruenceNaturalStride (inactive : LayerSamplerAxis I n → Prop) + (stride : X → ℕ) (j : Fin m) : AllocatedCongruenceRankOutput X E inactive j → ℕ + | .inl x => stride x.val + | .inr _ => 1 + +theorem allocatedCongruenceAffineCoefficients_eq_scalar {R : Type*} [CommRing R] + (inactive : LayerSamplerAxis I n → Prop) (stride : X → ℕ) + (offset c : AllocatedCongruenceCoefficientIndex X E inactive L → R) : + allocatedCongruenceAffineCoefficients inactive (fun x => (stride x : R)) offset c = + fun j => affineSpatialCoefficients (allocatedCongruenceIsSpatial inactive j.1) + (allocatedCongruenceNaturalStride inactive stride j.1) + (fun o l => offset ⟨j.1,o,l⟩) (scalarCoefficientTupleEquiv c j.1) j.2.1 j.2.2 := by + funext j + rcases j with ⟨j, (x | o), l⟩ + · simp [allocatedCongruenceAffineCoefficients, affineSpatialCoefficients, + allocatedCongruenceIsSpatial, allocatedCongruenceNaturalStride, + scalarCoefficientTupleEquiv, add_comm] + · simp [allocatedCongruenceAffineCoefficients, affineSpatialCoefficients, + allocatedCongruenceIsSpatial, scalarCoefficientTupleEquiv] + +variable [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable local instance affineCongruenceScalarFintype + (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedCongruenceScalarIndex X E inactive L) := inferInstance + +noncomputable local instance affineCongruenceScalarDecidableEq + (inactive : LayerSamplerAxis I n → Prop) : + DecidableEq (AllocatedCongruenceScalarIndex X E inactive L) := Classical.decEq _ + +variable (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + +local notation "rankS" => allocatedCongruenceRankBlockFamily (X := X) (E := E) inactive spatial kernel block +local notation "rankQ" => allocatedCongruenceRankIntegerResidualFamily inactive noise r projection spatial kernel block + +theorem allocatedCongruenceModulusBad_affine_probability {p a D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (hdeep : ∀ x, 2 * (stride x).factorization p ≤ a) + (offset : AllocatedCongruenceCoefficientIndex X E inactive L → ZMod (p ^ a)) + {C : ℝ} (hC : 0 ≤ C) + (hlarge : modularCoefficientPrimeThreshold m ≤ p ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (FiniteProbabilityWeights.uniform + (AllocatedCongruenceCoefficientIndex (I := I) (n := n) X E inactive L → ZMod (p ^ a))).eventProbability + (fun c => allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C (p ^ a) + (allocatedCongruenceAffineCoefficients inactive (fun x => (stride x : ZMod (p ^ a))) offset c)) ≤ + 1 / ((p ^ a : ℕ) : ℝ) ^ 10 := by + have hcount (j : Fin m) : Fintype.card (AllocatedCongruenceRankOutput X E inactive j) ≤ D := + (Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ j)).trans + ((allocatedCongruenceRankOutput_sum_card_le (X := X) (E := E) hm inactive).trans hD) + have hstride' (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) + (ho : allocatedCongruenceIsSpatial inactive j o) : + 0 < allocatedCongruenceNaturalStride inactive stride j o := by + cases o with + | inl x => exact hstride x.val + | inr o => exact False.elim ho + have hdeep' (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) + (ho : allocatedCongruenceIsSpatial inactive j o) : + 2 * (allocatedCongruenceNaturalStride inactive stride j o).factorization p ≤ a := by + cases o with + | inl x => exact hdeep x.val + | inr o => exact False.elim ho + have h := scalarCoefficientBad_affineSpatial_probability + (T := Fin m) (D := Fin L) (I := LayerSamplerLongVariables inactive G B) + (B := AllocatedCongruenceRankOutput X E inactive) (s := m) (m := D) hp ha + (fun j => j.val) (fun j => Nat.succ_le_of_lt j.isLt) + (by simp only [Fintype.card_fin, le_refl]) hcount + (allocatedCongruenceIsSpatial inactive) + (allocatedCongruenceIsSpatial_degree inactive) + (allocatedCongruenceNaturalStride inactive stride) hstride' hdeep' + (fun j o l => offset ⟨j,o,l⟩) rankS rankQ + (fun j o => allocatedTaggedRankBlock_card inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o)) + (fun j o => allocatedTaggedRankBlock_disjoint inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o)) + hC hlarge (by simpa only [Fintype.card_fin] using hL) + have heq : (fun c => allocatedCongruenceModulusBad inactive noise r projection + spatial kernel block C (p ^ a) + (allocatedCongruenceAffineCoefficients inactive + (fun x => (stride x : ZMod (p ^ a))) offset c)) = + fun c => scalarCoefficientBad (fun j : Fin m => j.val) rankS rankQ C (p ^ a) + (fun j => affineSpatialCoefficients (allocatedCongruenceIsSpatial inactive j.1) + (allocatedCongruenceNaturalStride inactive stride j.1) + (fun o l => offset ⟨j.1,o,l⟩) (scalarCoefficientTupleEquiv c j.1) j.2.1 j.2.2) := by + funext c + apply propext + rw [allocatedCongruenceModulusBad_iff_scalarCoefficientBad, + allocatedCongruenceAffineCoefficients_eq_scalar] + rw [heq] + exact affine_uniform_eventProbability_le_instances _ _ _ _ _ h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankIntegerDecay.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankIntegerDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..2cf8632cf3d604e8f947e4e256672aba1beaec24 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedModularRankIntegerDecay.lean @@ -0,0 +1,310 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankBadProduct +import OAI.Combinatorics.Progressions.Polynomial.ConditionPolynomialMapDegree + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + [Fintype G] [∀ j, Fintype (I j)] [∀ a, Fintype (B a)] + {N L : ℕ} + +noncomputable def allocatedCongruenceIntegerPolynomial + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (base : X → ℤ) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (v : LayerSamplerVariables G I n B → ℤ) : + AllocatedCongruenceRankOutput X E inactive j → + MvPolynomial (LayerSamplerLongVariables inactive G B) ℤ + | .inl x => conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (C (base x.val) + spatialRankPolynomial (fun d => noise (d, x.val))) + | .inr (.inl i) => conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) (fun q => r j q i)) + | .inr (.inr a) => conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) + (projection (allocatedCongruenceIntegerEmbedding inactive j a))) + +theorem allocatedCongruenceIntegerPolynomial_degree + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (base : X → ℤ) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (v : LayerSamplerVariables G I n B → ℤ) + (o : AllocatedCongruenceRankOutput X E inactive j) : + (allocatedCongruenceIntegerPolynomial inactive j base noise r projection v o).totalDegree ≤ + j.val + 1 := by + rcases o with x | i | a + · apply (conditionPolynomial_totalDegree_le _ _ _ _).trans + apply (totalDegree_add _ _).trans + apply max_le + · rw [totalDegree_C] + exact Nat.zero_le _ + · exact (spatialRankPolynomial_degree _).trans (by omega) + · exact (conditionPolynomial_totalDegree_le _ _ _ _).trans + (modularBoundedCoefficientPolynomial_degree _ _) + · exact (conditionPolynomial_totalDegree_le _ _ _ _).trans + (modularBoundedCoefficientPolynomial_degree _ _) + +theorem allocatedCongruenceIntegerPolynomial_top_reduce + (N : ℕ) (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (base : X → ℤ) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (v : LayerSamplerVariables G I n B → ℤ) + (o : AllocatedCongruenceRankOutput X E inactive j) : + (homogeneousComponent (j.val + 1) + (allocatedCongruenceIntegerPolynomial inactive j base noise r projection v o)).map + (Int.castRingHom (ZMod N)) = + allocatedOriginalTaggedTop inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun a q => (projection a q : ZMod N)) + (fun k => (v k : ZMod N)) (allocatedCongruenceOutputEmbedding inactive j o) := by + rw [← homogeneousComponent_map_ringHom] + rcases o with x | i | a + · have hx : j.val + 1 = 1 := by simp only [x.property, zero_add] + simp only [allocatedCongruenceIntegerPolynomial, conditionPolynomial_map, + allocatedCongruenceOutputEmbedding_spatial, allocatedOriginalTaggedTop, hx, + map_add, map_C, Int.coe_castRingHom] + have hs : (spatialRankPolynomial (fun d => noise (d, x.val))).map + (Int.castRingHom (ZMod N)) = + spatialRankPolynomial (fun d => (noise (d, x.val) : ZMod N)) := by + simp only [spatialRankPolynomial, map_sum, MvPolynomial.map_monomial, + Int.coe_castRingHom] + rw [hs] + simp only [conditionPolynomial, map_add, polynomialTranslate_C, killCompl_C] + have hc : homogeneousComponent 1 (C (base x.val : ZMod N) : + MvPolynomial (LayerSamplerLongVariables inactive G B) (ZMod N)) = 0 := + homogeneousComponent_eq_zero _ _ (by rw [totalDegree_C]; exact zero_lt_one) + rw [hc, zero_add] + · simp only [allocatedCongruenceIntegerPolynomial, conditionPolynomial_map, + allocatedCongruenceOutputEmbedding_deck, allocatedOriginalTaggedTop, + modularDeckPolynomial, ← modularBoundedCoefficientPolynomial_map, + Int.coe_castRingHom] + · simp only [allocatedCongruenceIntegerPolynomial, conditionPolynomial_map, + allocatedCongruenceOutputEmbedding_integer, allocatedOriginalTaggedTop, + ← modularBoundedCoefficientPolynomial_map, Int.coe_castRingHom, + allocatedCongruenceIntegerEmbedding] + rfl + +theorem allocatedCongruenceIntegerPolynomial_top_eq_actual_rank + (N : ℕ) (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (base : X → ℤ) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (v : LayerSamplerVariables G I n B → ℤ) + (o : AllocatedCongruenceRankOutput X E inactive j) : + (homogeneousComponent (j.val + 1) + (allocatedCongruenceIntegerPolynomial inactive j base noise r projection v o)).map + (Int.castRingHom (ZMod N)) = + allocatedCongruenceRankPolynomial inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun a q => (projection a q : ZMod N)) + spatial kernel block + (fun z => allocatedSelectedRankCoefficients inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun a q => (projection a q : ZMod N)) + spatial kernel block (allocatedCongruenceOutputEmbedding inactive j z)) + (fun k => (v k : ZMod N)) o := by + rw [allocatedCongruenceRankPolynomial_original] + exact allocatedCongruenceIntegerPolynomial_top_reduce N inactive j base noise r projection v o + +theorem allocatedCongruenceIntegerPolynomial_spatial_eval + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (base : X → ℤ) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (v : LayerSamplerVariables G I n B → ℤ) + (y : LayerSamplerLongVariables inactive G B → ℤ) (x : SpatialDegreeOutput X j) : + MvPolynomial.eval y + (allocatedCongruenceIntegerPolynomial inactive j base noise r projection v (.inl x)) = + BooleanCubeKernel.jointIntegerPhysicalSite + (Function.extend (allocatedLongEmbedding inactive) y v) (base, noise) x.val := by + rw [allocatedCongruenceIntegerPolynomial, eval_conditionPolynomial] + exact spatialRankPolynomial_actual_eval base noise x.val _ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +variable (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + +noncomputable def allocatedCongruenceIntegerSelectedCoefficients : + AllocatedCongruenceScalarIndex X E inactive L → ℤ + | ⟨_j, .inl x, l⟩ => noise (spatialKernelRankSlot spatial l, x.val) + | ⟨j, .inr (.inl i), l⟩ => r j (kernelRankCoefficientSlot (layerSamplerDegree I n) (kernel j) l) i + | ⟨j, .inr (.inr a), l⟩ => projection j (allocatedCongruenceIntegerEmbedding inactive j a) + (canonicalPrincipalSubblockSlot (layerSamplerDegree I n) + ⟨j, Sum.inr a.val⟩ (block j (allocatedCongruenceIntegerEmbedding inactive j a)) l) + +local notation "selected" => allocatedCongruenceIntegerSelectedCoefficients + inactive noise r projection spatial kernel block + +omit [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ a, Fintype (B a)] in + +theorem allocatedCongruenceIntegerSelectedCoefficients_reduce (N : ℕ) + (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) (l : Fin L) : + (selected ⟨j, (o,l)⟩ : ZMod N) = + allocatedSelectedRankCoefficients inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun a q => (projection j a q : ZMod N)) + spatial (kernel j) (block j) (allocatedCongruenceOutputEmbedding inactive j o) l := by + rcases o with x | i | a <;> rfl + +theorem allocatedCongruenceIntegerPolynomial_rank_probability + (p a : ℕ) [NeZero p] (base : X → ℤ) + (v : LayerSamplerVariables G I n B → ℤ) (j : Fin m) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod (p ^ a)) : + integerPolynomialRankProbability p a j.val + (allocatedCongruenceIntegerPolynomial inactive j base noise r (projection j) v) w = + allocatedCongruenceRankFailureProbability inactive j (fun q => (noise q : ZMod (p ^ a))) + (fun j q i => (r j q i : ZMod (p ^ a))) + (fun b q => (projection j b q : ZMod (p ^ a))) spatial (kernel j) (block j) + (fun o l => (selected ⟨j,(o,l)⟩ : ZMod (p ^ a))) (fun k => (v k : ZMod (p ^ a))) w := by + unfold integerPolynomialRankProbability allocatedCongruenceRankFailureProbability + simp only [allocatedCongruenceIntegerSelectedCoefficients_reduce, + allocatedCongruenceIntegerPolynomial_top_eq_actual_rank + (p ^ a) inactive j base noise r (projection j) spatial (kernel j) (block j)] + simp only [polynomialCharacterRow, smul_eq_C_mul] + +theorem allocatedCongruenceIntegerPolynomial_rank_of_good + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) (p : P) (a : ℕ) + (hgood : ¬ allocatedCongruenceRankBad inactive noise r projection spatial kernel block + P C p.val a selected) + (base : X → ℤ) (v : LayerSamplerVariables G I n B → ℤ) (j : Fin m) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod (p.val ^ a)) + (hw : ∃ o, IsUnit (w o)) : + integerPolynomialRankProbability p.val a j.val + (allocatedCongruenceIntegerPolynomial inactive j base noise r (projection j) v) w ≤ + (p.val : ℝ) ^ (-C * a) := by + rw [allocatedCongruenceIntegerPolynomial_rank_probability inactive noise r projection spatial kernel block] + have h := allocatedCongruenceRankBad_good inactive noise r projection spatial kernel block + P C p a selected hgood (fun k => (v k : ZMod (p.val ^ a))) j w hw + calc + _ ≤ ((p.val ^ a : ℕ) : ℝ) ^ (-C) := h + _ = (p.val : ℝ) ^ (-C * a) := by + rw [Nat.cast_pow, ← Real.rpow_natCast_mul (Nat.cast_nonneg p.val)] + congr 1 + ring + +theorem allocatedCongruence_crt_characteristic_decay + (hm : 0 < m) (P : Finset ℕ) [∀ p : P, NeZero p.val] + (A b e : ℕ → ℕ) (hp : ∀ p ∈ P, p.Prime) (C : ℝ) (hC : 0 ≤ C) + (hgood : ∀ (p : P) (a : ℕ), b p.val < a → a ≤ A p.val → + ¬ allocatedCongruenceRankBad inactive noise r projection spatial kernel block + P C p.val a selected) + (base : X → ℤ) (v : LayerSamplerVariables G I n B → ℤ) + (origin : ∀ p : P, LayerSamplerLongVariables inactive G B → ZMod (p.val ^ A p.val)) + (χ : AddChar (∀ j, AllocatedCongruenceRankOutput X E inactive j → + ZMod (∏ p : P, p.val ^ A p.val)) ℂ) : + letI : DecidableEq P := Classical.decEq _ + ‖finiteImageCharacteristic (crtPrimePowerPolynomialLaw (V := LayerSamplerLongVariables inactive G B) + (fun p : P => p.val) (fun p : P => A p.val)) + (crtPrimePowerPolynomialMap (fun p : P => p.val) (fun p : P => A p.val) + (fun p : P => e p.val) + (primePower_crt_coprime (fun p : P => p.val) (fun p : P => A p.val) + (fun p => hp p.val p.property) Subtype.val_injective) + (fun j => allocatedCongruenceIntegerPolynomial inactive j base noise r (projection j) v) + origin) χ‖ ≤ + crtPolynomialCharge (fun p : P => p.val) (fun p : P => b p.val) + (fun p : P => e p.val) m C * (orderOf χ : ℝ) ^ (-modularRankDecayExponent m C) := by + let : DecidableEq P := Classical.decEq _ + apply crt_integer_polynomial_characteristic_decay hm + (fun p : P => p.val) (fun p : P => A p.val) (fun p : P => b p.val) + (fun p : P => e p.val) (fun p => hp p.val p.property) Subtype.val_injective C hC + · exact fun j o => allocatedCongruenceIntegerPolynomial_degree inactive j base noise r (projection j) v o + · intro p a ha hA j w hw + exact allocatedCongruenceIntegerPolynomial_rank_of_good inactive noise r projection spatial kernel block + P C p a (hgood p a ha hA) base v j w hw + +theorem allocatedCongruence_largest_bad_depth_good + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) (C : ℝ) + (p : P) (a : ℕ) + (ha : largestTestedBadDepth A + (allocatedCongruenceRankBad inactive noise r projection spatial kernel block P C) + p.val selected < a) (hA : a ≤ A p.val) : + ¬ allocatedCongruenceRankBad inactive noise r projection spatial kernel block + P C p.val a selected := + largestTestedBadDepth_not_bad A _ p.val selected ha hA + +noncomputable def allocatedCongruenceBadDepth + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) (C : ℝ) : ℕ → ℕ := + fun p => largestTestedBadDepth A + (allocatedCongruenceRankBad inactive noise r projection spatial kernel block P C) p selected + +theorem allocatedCongruence_crt_decay_of_bad_product + (hm : 0 < m) (P : Finset ℕ) [∀ p : P, NeZero p.val] + (A e : ℕ → ℕ) (hp : ∀ p ∈ P, p.Prime) (C : ℝ) (hC : 0 ≤ C) (R : ℕ) + (hbad : (∏ p : P, p.val ^ allocatedCongruenceBadDepth + inactive noise r projection spatial kernel block P A C p.val) ≤ R) + (base : X → ℤ) (v : LayerSamplerVariables G I n B → ℤ) + (origin : ∀ p : P, LayerSamplerLongVariables inactive G B → ZMod (p.val ^ A p.val)) + (χ : AddChar (∀ j, AllocatedCongruenceRankOutput X E inactive j → + ZMod (∏ p : P, p.val ^ A p.val)) ℂ) : + letI : DecidableEq P := Classical.decEq _ + ‖finiteImageCharacteristic (crtPrimePowerPolynomialLaw (V := LayerSamplerLongVariables inactive G B) + (fun p : P => p.val) (fun p : P => A p.val)) + (crtPrimePowerPolynomialMap (fun p : P => p.val) (fun p : P => A p.val) + (fun p : P => e p.val) + (primePower_crt_coprime (fun p : P => p.val) (fun p : P => A p.val) + (fun p => hp p.val p.property) Subtype.val_injective) + (fun j => allocatedCongruenceIntegerPolynomial inactive j base noise r (projection j) v) + origin) χ‖ ≤ + ((R * ∏ p : P, p.val ^ e p.val : ℕ) : ℝ) ^ + (modularRankDecayExponent m C * modularRankChargeFactor m) * + (orderOf χ : ℝ) ^ (-modularRankDecayExponent m C) := by + let : DecidableEq P := Classical.decEq _ + let b := allocatedCongruenceBadDepth inactive noise r projection spatial kernel block P A C + have h := allocatedCongruence_crt_characteristic_decay inactive noise r projection spatial kernel block + hm P A b e hp C hC (fun p a ha hA => + allocatedCongruence_largest_bad_depth_good inactive noise r projection spatial kernel block + P A C p a ha hA) base v origin χ + exact h.trans (mul_le_mul_of_nonneg_right + (crtPolynomialCharge_le_of_bad_product (fun p : P => p.val) (fun p : P => b p.val) + (fun p : P => e p.val) m hC hbad) (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedNormalizedProductResidueCover.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedNormalizedProductResidueCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..12ad2f9384d06c59911fbf400a0774a34c8160d0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedNormalizedProductResidueCover.lean @@ -0,0 +1,554 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedProductRadiusBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedNormalizedIdealCover +import OAI.Combinatorics.Progressions.Estimates.AllocatedNormalizedProductCover +import OAI.Combinatorics.Progressions.Sampling.AllocatedFullGridSpatialWeighted + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullGridCoverAxisDecidableEq fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (q : ℕ) [NeZero q] +variable (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +local notation "gridAxes" => {a // allocatedGridAxis (I := I) U b S.value a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "law" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + +noncomputable def allocatedClippedFullGridCoverCoefficientMass : ℝ := + ((law).fiberLaw (principalResidueLabel q)).mean (fun r => + if hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) then + ∑ k, ‖coverSiteCoefficient (W ⟨r, hr⟩).expansion k‖ + else 0) + +theorem allocatedClippedFullGridCoverCoefficientMass_le (C : ℝ) + (h : ∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ C) : + allocatedClippedFullGridCoverCoefficientMass B U b S q W ≤ C := by + let weights := (law).fiberLaw (principalResidueLabel q) + apply (weights.mean_mono_on_support (g := fun _ => C) ?_).trans_eq (weights.mean_const C) + intro r hr + have hp : 0 < weights.weight r := lt_of_le_of_ne (weights.nonneg r) (Ne.symm hr) + change 0 < ((law).fiberLaw (principalResidueLabel q)).weight r at hp + rw [FiniteProbabilityWeights.fiberLaw_weight_eq_mass] at hp + simpa only [dite_eq_left hp] using h ⟨r, hp⟩ + +noncomputable def allocatedClippedFullGridCoverValue + (g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ)) + (δ : ℝ≥0) (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ) + (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) : ℂ := + if hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) then + let rr : AllocatedPositiveResidue (dim := dim) B U b S q := ⟨r, hr⟩ + allocatedClippedFullGridGlobalPrefactor B U b S rowSets d (allocatedIdealCoverSupport (G := G) B rowSets) + x hb o bW q (W rr).representative + (allocatedPhysicalLongIdeal B U b hR S rowSets δ) + (physicalCubeRowSample U d rows p hm v) * + ∑ k, coverSiteCoefficient (W rr).expansion k * ∏ s, + g rr k s (fun a => (((eval (fun z => (physicalCubeVertexValue v s z : ℝ)) + (p a.1) a.2) / commonSitePeriod (W rr).expansion k : ℝ) : UnitAddCircle)) + else 0 + +theorem exists_allocated_clipped_full_grid_residue_cover + {Nt V Cc Hs : gridAxes → ℝ} {L : ℝ≥0} + (he : ∀ r a, ((W r).expansion a).Bounds (Nt a) (V a) (Cc a) L (Hs a)) + (Q : ℝ≥0) (hQ : ∀ a : gridAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a).1 (ig a).2) : ℝ) + 1) ≤ Q) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets C j) : + ∃ g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ r k s, LipschitzWith (max (((Fintype.card gridAxes * L) * Q) * + (K * ∑ j, Cforward j * Fintype.card (J j)) * commonSitePeriod (W r).expansion k) + (4 * commonSitePeriod (W r).expansion k)) (g r k s) ∧ ∀ v, ‖g r k s v‖ ≤ 1) ∧ + (∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + allocatedClippedFullGridCoverCoefficientMass B U b S q W ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a ∧ + ∀ (δ : ℝ≥0), 0 < δ → δ ≤ 1 → + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ), + ∀ r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q, + allocatedClippedFullGridResidueProfile B U b hR hσ S q x hb o bW d + (allocatedPhysicalLongIdeal B U b hR S rowSets δ) W + (allocatedIdealCoverSupport (G := G) B rowSets) r + (physicalCubeRowSample U d rows p hm v) = + allocatedClippedFullGridCoverValue B U b hR S q W hb o bW d g δ x p hm v r := by + have hlocal (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_clipped_full_grid_ideal_cover B U b hR hσ S d q + (W r).representative (W r).positive hb o bW (W r).expansion (he r) + Q hQ Cforward hforward K hK C hC hchart hsmall + choose g hg hc hv using hlocal + refine ⟨g, hg, hc, allocatedClippedFullGridCoverCoefficientMass_le B U b S q W _ hc, ?_⟩ + intro δ hδ hδ1 x X p hp hm v r + by_cases hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) + · simp only [allocatedClippedFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedClippedFullGridCoverValue, dite_eq_left hr] + simpa only [allocatedClippedFullGridSiteProfile, allocatedFullGridResidueWitnessProfile] using + hv ⟨r, hr⟩ δ hδ hδ1 x p hp hm v + · simp only [allocatedClippedFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedClippedFullGridCoverValue, dite_eq_right hr, mul_zero] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullGridCoverAxisDecidableEq fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (q : ℕ) [NeZero q] +variable (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +local notation "gridAxes" => {a // allocatedGridAxis (I := I) U b S.value a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "law" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + +theorem exists_allocated_normalized_full_grid_residue_cover + {Nt V Cc Hs : gridAxes → ℝ} {L : ℝ≥0} + (he : ∀ r a, ((W r).expansion a).Bounds (Nt a) (V a) (Cc a) L (Hs a)) + (Q : ℝ≥0) (hQ : ∀ a : gridAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a).1 (ig a).2) : ℝ) + 1) ≤ Q) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets C j) : + ∃ g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ r k s, LipschitzWith (max (((Fintype.card gridAxes * L) * Q) * + (K * ∑ j, Cforward j * Fintype.card (J j)) * commonSitePeriod (W r).expansion k) + (4 * commonSitePeriod (W r).expansion k)) (g r k s) ∧ ∀ v, ‖g r k s v‖ ≤ 1) ∧ + (∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + allocatedClippedFullGridCoverCoefficientMass B U b S q W ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a ∧ + (∀ r k s (u : ∀ j, euclideanSubspace (U j)) (w : ∀ j, (I j → ℝ) × (Fin (n j) → ℤ)), + (∀ j, (QuotientAddGroup.mk (u j) : euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup) = + normalizedLatticeQuotient (euclideanSubspace (U j)) (b j) (hb j) (orthonormalMixedChart (o j) (w j))) → + (∀ j i, |normalizedLatticePoint (euclideanSubspace (U j)) (b j) (orthonormalMixedChart (o j) (w j)) i| ≤ 1 / 4) → + g r k s (fun a => ((((u a.1).val a.2) / commonSitePeriod (W r).expansion k : ℝ) : UnitAddCircle)) = + allocatedFullGridSiteFactor (G := G) B U b (R := R) (W r).expansion ig k s + (fun a => ((w (ig a).1).2 (ig a).2 : ZMod (((W r).expansion a).period (k a)))) + (allocatedFullMixedSiteValue (R := R) U b w) / 2) ∧ + ∀ (δ : ℝ≥0), 0 < δ → δ ≤ 1 → + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ), + ∀ r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q, + allocatedClippedFullGridResidueProfile B U b hR hσ S q x hb o bW d + (allocatedPhysicalLongIdeal B U b hR S rowSets δ) W + (allocatedIdealCoverSupport (G := G) B rowSets) r + (physicalCubeRowSample U d rows p hm v) = + allocatedClippedFullGridCoverValue B U b hR S q W hb o bW d g δ x p hm v r := by + have hlocal (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_normalized_full_grid_ideal_cover B U b hR hσ S d q + (W r).representative (W r).positive hb o bW (W r).expansion (he r) + Q hQ Cforward hforward K hK C hC hchart hsmall + choose g hg hc hsite hv using hlocal + refine ⟨g, hg, hc, allocatedClippedFullGridCoverCoefficientMass_le B U b S q W _ hc, hsite, ?_⟩ + intro δ hδ hδ1 x X p hp hm v r + by_cases hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) + · simp only [allocatedClippedFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedClippedFullGridCoverValue, dite_eq_left hr] + simpa only [allocatedClippedFullGridSiteProfile, allocatedFullGridResidueWitnessProfile] using + hv ⟨r, hr⟩ δ hδ hδ1 x p hp hm v + · simp only [allocatedClippedFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedClippedFullGridCoverValue, dite_eq_right hr, mul_zero] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uE uX + +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (q : ℕ) [NeZero q] +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {E : Fin m → Type uE} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) +variable (δ : ℝ≥0) + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +local notation "labelType" => PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q +local notation "law" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) +local notation "radius" => allocatedProductIdealSiteRadius (G := G) B rowSets +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d radius + (allocatedProductIdealSiteRadius_pos B rowSets) +local notation "ideal" => allocatedPhysicalLongIdeal B U b hR S rowSets δ +local notation "rawProfile" => allocatedSupportedFullGridResidueProfile B U b hR hσ S q x hb o bW d ideal W + +noncomputable def allocatedProductFullGridResidueProfile (r : labelType) + (y : EuclideanJetLayers U (rowTypes)) : ℂ := cutoff y * rawProfile r y + +noncomputable def allocatedProductFullGridWeightedError (weight : labelType → ℂ) + (y : EuclideanJetLayers U (rowTypes)) : ℂ := + (law).complexMean (fun y₀ => weight (principalResidueLabel q y₀) * + (allocatedWholeMaskedCoveredProfile B U b hR hσ S x (rows) hb o bW d y₀ q ideal y : ℂ)) - + ((law).fiberLaw (principalResidueLabel q)).complexMean (fun r => weight r * + allocatedProductFullGridResidueProfile B U b hR hσ S q x hb o bW d W δ r y) + +variable (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hsmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B + (fun k : Fin m => boundedBooleanJetRows (Fin dim) (k.val + 1)) C j) +variable (hδ : 0 < δ) (hδ1 : δ ≤ 1) + +include hσ1 hC hchart hsmall hδ hδ1 in +theorem allocatedProductFullGridWeightedError_eq (weight : labelType → ℂ) + (y : EuclideanJetLayers U (rowTypes)) : + allocatedProductFullGridWeightedError B U b hR hσ S q x hb o bW d W δ weight y = + cutoff y * allocatedFullGridWeightedProfileError B U b hR hσ S q x hb o bW d ideal W weight y := by + have hfix (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S)) : + cutoff y * (allocatedWholeMaskedCoveredProfile B U b hR hσ S x (rows) hb o bW d y₀ q ideal y : ℂ) = + (allocatedWholeMaskedCoveredProfile B U b hR hσ S x (rows) hb o bW d y₀ q ideal y : ℂ) := by + exact allocatedProductSiteCutoff_fixes_source B U b S rowSets o hb bW d radius + (allocatedProductIdealSiteRadius_pos B rowSets) hR hσ + (allocatedIdealCoverSupport (G := G) B rowSets) + (allocatedIdealCoverSupport_nonneg B rowSets) (allocatedIdealCoverSupport_inactive B rowSets) + (allocatedProductIdealSiteRadius_dominates B rowSets) C hC hchart + (allocatedProductGridRadius_source_budget B rowSets C hC (fun j => (hR j).le) hsmall) + hσ1 x y₀ q ideal (allocatedPhysicalLongIdeal_cover_support B U b hR S rowSets δ hδ hδ1) y + exact supportMask_weighted_complexMean_difference (law) ((law).fiberLaw (principalResidueLabel q)) + (principalResidueLabel q) weight + (fun y₀ => (allocatedWholeMaskedCoveredProfile B U b hR hσ S x (rows) hb o bW d y₀ q ideal y : ℂ)) + (fun r => rawProfile r y) (cutoff y) hfix + +include hσ1 hC hchart hsmall hδ hδ1 in +theorem allocatedProductFullGridWeightedError_norm (weight : labelType → ℂ) + (y : EuclideanJetLayers U (rowTypes)) : + ‖allocatedProductFullGridWeightedError B U b hR hσ S q x hb o bW d W δ weight y‖ ≤ + ‖allocatedFullGridWeightedProfileError B U b hR hσ S q x hb o bW d ideal W weight y‖ := by + rw [allocatedProductFullGridWeightedError_eq B U b hR hσ S q x hb o bW d W δ + hσ1 C hC hchart hsmall hδ hδ1, norm_mul] + exact (mul_le_mul_of_nonneg_right (allocatedProductSiteCutoff_norm B U b S rowSets o hb bW d radius + (allocatedProductIdealSiteRadius_pos B rowSets) y) (norm_nonneg _)).trans_eq (one_mul _) + +variable {X : Type uX} [Fintype X] [DecidableEq X] +variable (stride : X → ℕ) (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) +variable (widths : Option (Fin dim) × X → ℝ) (hwidths : ∀ z, 0 < widths z) +variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells widths z) +variable (sample : (Option (Fin dim) × X → ℤ) → EuclideanJetLayers U + (fun j : Fin m => (boundedBooleanJetRows (Fin dim) (j.val + 1) : Type))) +variable (weight : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) → + (Option (Fin dim) × X → ℤ) → ℂ) + +omit [DecidableEq X] in +include hσ1 hC hchart hsmall hδ hδ1 hwidths hZ in +theorem allocatedProductFullGridWeightedError_sampled {η : ℝ} + (hraw : selectedResidueDensityMass stride cells widths (fun z => + ‖allocatedFullGridWeightedProfileError B U b hR hσ S q x hb o bW d ideal W + (fun r => weight r z) (sample z)‖) ≤ η) : + selectedResidueDensityMass stride cells widths (fun z => + ‖allocatedProductFullGridWeightedError B U b hR hσ S q x hb o bW d W δ + (fun r => weight r z) (sample z)‖) ≤ η := by + exact (selectedResidueDensityMass_mono stride cells widths hwidths hZ (fun z => + allocatedProductFullGridWeightedError_norm B U b hR hσ S q x hb o bW d W δ hσ1 C hC hchart hsmall + hδ hδ1 (fun r => weight r z) (sample z))).trans hraw + +omit [DecidableEq X] in +include hσ1 hC hchart hsmall hδ hδ1 in +theorem allocatedProductFullGridWeightedError_test {η : ℝ} + (hraw : ∀ φ : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖φ z‖ ≤ 1) → + ‖∑' z, ((selectedResidueSmoothPMF stride cells widths hwidths hZ z).toReal : ℂ) * + (allocatedFullGridWeightedProfileError B U b hR hσ S q x hb o bW d ideal W + (fun r => weight r z) (sample z) * φ z)‖ ≤ η) + (φ : (Option (Fin dim) × X → ℤ) → ℂ) (hφ : ∀ z, ‖φ z‖ ≤ 1) : + ‖∑' z, ((selectedResidueSmoothPMF stride cells widths hwidths hZ z).toReal : ℂ) * + (allocatedProductFullGridWeightedError B U b hR hσ S q x hb o bW d W δ + (fun r => weight r z) (sample z) * φ z)‖ ≤ η := by + have hcut (z : Option (Fin dim) × X → ℤ) : ‖cutoff (sample z) * φ z‖ ≤ 1 := by + rw [norm_mul] + exact (mul_le_mul_of_nonneg_right (allocatedProductSiteCutoff_norm B U b S rowSets o hb bW d radius + (allocatedProductIdealSiteRadius_pos B rowSets) (sample z)) (norm_nonneg _)).trans + (by simpa using hφ z) + have h := hraw (fun z => cutoff (sample z) * φ z) hcut + convert h using 1 + congr 1 + apply tsum_congr + intro z + rw [allocatedProductFullGridWeightedError_eq B U b hR hσ S q x hb o bW d W δ + hσ1 C hC hchart hsmall hδ hδ1] + ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullGridCoverAxisDecidableEq fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (q : ℕ) [NeZero q] +variable (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +local notation "gridAxes" => {a // allocatedGridAxis (I := I) U b S.value a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "law" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + +local notation "radius" => allocatedProductIdealSiteRadius (G := G) B rowSets + +noncomputable def allocatedProductFullGridCoverValue + (g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ)) + (δ : ℝ≥0) (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ) + (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) : ℂ := + if hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) then + let rr : AllocatedPositiveResidue (dim := dim) B U b S q := ⟨r, hr⟩ + allocatedProductFullGridPrefactor B U b S rowSets d radius (allocatedProductIdealSiteRadius_pos B rowSets) + x hb o bW q (W rr).representative + (allocatedPhysicalLongIdeal B U b hR S rowSets δ) + (physicalCubeRowSample U d rows p hm v) * + ∑ k, coverSiteCoefficient (W rr).expansion k * ∏ s, + g rr k s (fun a => (((eval (fun z => (physicalCubeVertexValue v s z : ℝ)) + (p a.1) a.2) / commonSitePeriod (W rr).expansion k : ℝ) : UnitAddCircle)) + else 0 + +theorem exists_allocated_product_full_grid_residue_cover + {Nt V Cc Hs : gridAxes → ℝ} {L : ℝ≥0} + (he : ∀ r a, ((W r).expansion a).Bounds (Nt a) (V a) (Cc a) L (Hs a)) + (Q : ℝ≥0) (hQ : ∀ a : gridAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a).1 (ig a).2) : ℝ) + 1) ≤ Q) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets C j) : + ∃ g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ r k s, LipschitzWith (max (((Fintype.card gridAxes * L) * Q) * + (K * ∑ j, Cforward j * Fintype.card (J j)) * commonSitePeriod (W r).expansion k) + (4 * commonSitePeriod (W r).expansion k)) (g r k s) ∧ ∀ v, ‖g r k s v‖ ≤ 1) ∧ + (∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + allocatedClippedFullGridCoverCoefficientMass B U b S q W ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a ∧ + ∀ (δ : ℝ≥0) (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ), + ∀ r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q, + allocatedProductFullGridResidueProfile B U b hR hσ S q x hb o bW d W δ r + (physicalCubeRowSample U d rows p hm v) = + allocatedProductFullGridCoverValue B U b hR S q W hb o bW d g δ x p hm v r := by + have hlocal (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_product_full_grid_cover B U b hR hσ S d q + (W r).representative (W r).positive hb o bW (W r).expansion (he r) + Q hQ Cforward hforward K hK radius (allocatedProductIdealSiteRadius_pos B rowSets) C hC hchart + (allocatedProductGridRadius_recovery_budget B rowSets C hC (fun j => (hR j).le) hsmall) + choose g hg hc hv using hlocal + refine ⟨g, hg, hc, allocatedClippedFullGridCoverCoefficientMass_le B U b S q W _ hc, ?_⟩ + intro δ x X p hp hm v r + by_cases hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) + · simp only [allocatedProductFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedProductFullGridCoverValue, dite_eq_left hr] + simpa only [allocatedProductFullGridProfile, allocatedFullGridResidueWitnessProfile] using + hv ⟨r, hr⟩ x (allocatedPhysicalLongIdeal B U b hR S rowSets δ) p hp hm v + · simp only [allocatedProductFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedProductFullGridCoverValue, dite_eq_right hr, mul_zero] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullGridCoverAxisDecidableEq fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (q : ℕ) [NeZero q] +variable (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedFullGridResidueWitness (dim := dim) B U b S q r.val) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +local notation "gridAxes" => {a // allocatedGridAxis (I := I) U b S.value a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "law" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + +local notation "radius" => allocatedProductIdealSiteRadius (G := G) B rowSets + +theorem exists_allocated_normalized_product_full_grid_residue_cover + {Nt V Cc Hs : gridAxes → ℝ} {L : ℝ≥0} + (he : ∀ r a, ((W r).expansion a).Bounds (Nt a) (V a) (Cc a) L (Hs a)) + (Q : ℝ≥0) (hQ : ∀ a : gridAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a).1 (ig a).2) : ℝ) + 1) ≤ Q) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets C j) : + ∃ g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ r k s, LipschitzWith (max (((Fintype.card gridAxes * L) * Q) * + (K * ∑ j, Cforward j * Fintype.card (J j)) * commonSitePeriod (W r).expansion k) + (4 * commonSitePeriod (W r).expansion k)) (g r k s) ∧ ∀ v, ‖g r k s v‖ ≤ 1) ∧ + (∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + allocatedClippedFullGridCoverCoefficientMass B U b S q W ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a ∧ + (∀ r k s (u : ∀ j, euclideanSubspace (U j)) (w : ∀ j, (I j → ℝ) × (Fin (n j) → ℤ)), + (∀ j, (QuotientAddGroup.mk (u j) : euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup) = + normalizedLatticeQuotient (euclideanSubspace (U j)) (b j) (hb j) (orthonormalMixedChart (o j) (w j))) → + (∀ j i, |normalizedLatticePoint (euclideanSubspace (U j)) (b j) (orthonormalMixedChart (o j) (w j)) i| ≤ 1 / 4) → + g r k s (fun a => ((((u a.1).val a.2) / commonSitePeriod (W r).expansion k : ℝ) : UnitAddCircle)) = + allocatedFullGridSiteFactor (G := G) B U b (R := R) (W r).expansion ig k s + (fun a => ((w (ig a).1).2 (ig a).2 : ZMod (((W r).expansion a).period (k a)))) + (allocatedFullMixedSiteValue (R := R) U b w) / 2) ∧ + ∀ (δ : ℝ≥0) (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ), + ∀ r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q, + allocatedProductFullGridResidueProfile B U b hR hσ S q x hb o bW d W δ r + (physicalCubeRowSample U d rows p hm v) = + allocatedProductFullGridCoverValue B U b hR S q W hb o bW d g δ x p hm v r := by + have hlocal (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_normalized_product_full_grid_cover B U b hR hσ S d q + (W r).representative (W r).positive hb o bW (W r).expansion (he r) + Q hQ Cforward hforward K hK radius (allocatedProductIdealSiteRadius_pos B rowSets) C hC hchart + (allocatedProductGridRadius_recovery_budget B rowSets C hC (fun j => (hR j).le) hsmall) + choose g hg hc hsite hv using hlocal + refine ⟨g, hg, hc, allocatedClippedFullGridCoverCoefficientMass_le B U b S q W _ hc, hsite, ?_⟩ + intro δ x X p hp hm v r + by_cases hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) + · simp only [allocatedProductFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedProductFullGridCoverValue, dite_eq_left hr] + simpa only [allocatedProductFullGridProfile, allocatedFullGridResidueWitnessProfile] using + hv ⟨r, hr⟩ x (allocatedPhysicalLongIdeal B U b hR S rowSets δ) p hp hm v + · simp only [allocatedProductFullGridResidueProfile, allocatedSupportedFullGridResidueProfile, + allocatedProductFullGridCoverValue, dite_eq_right hr, mul_zero] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalGenuineAffine.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalGenuineAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b42bb642b51e40a7bd0dcbb0e57e198ba09acd4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalGenuineAffine.lean @@ -0,0 +1,724 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedProductBoxAffine +import OAI.Combinatorics.Progressions.Linear.AllocatedProductCoarseNormalizedKernel + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductCoarseNormalizedAffineData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 2)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp) (hlarge : Mk ≤ S.value), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 2) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 2) + 2) + let mesh := fun x : GoodKernel => + allocatedProductCoarseMesh m X selection Mk (modulus x) Psp pAccuracy w v (E + 2) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW (mesh x) base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +theorem allocatedProductCoarseNormalizedAffineData_of_kernel + {Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (hkernel : AllocatedProductCoarseNormalizedKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : + AllocatedProductCoarseNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses + M Dwin hM hDwin η hη := by + unfold AllocatedProductCoarseNormalizedAffineData + intro w v Pfinal Mk hMk selection hqDim hcard _ hMkPsp hlarge Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hkernel⟩ := + hkernel hMk selection hqDim hMkPsp + let _ : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let _ : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z H law + coverValue wholeReference reconstruct weight cover + obtain ⟨hmass, hZ, hcomparison⟩ := hkernel block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN hsizeN + poly hpoly hmem hrank hRank cells hcells test htest bases hbases + refine ⟨hmass, hZ, ?_⟩ + intro window hwindow hDwindow shift moduli residues hmoduli hmoduliM kernelLaw + have hbad := affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hcard) selection hM hDwin hη S.positive hlarge + window hwindow hDwindow shift moduli residues hmoduli hmoduliM + exact hcomparison kernelLaw hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductCoarseBoxAffineData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 2)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp) (hlarge : Mk ≤ S.value), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 2) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 2) + 2) + let mesh := fun x : GoodKernel => + allocatedProductCoarseMesh m X selection Mk (modulus x) Psp pAccuracy w v (E + 2) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (_hτ1 : τ ≤ 1 / 2) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (_hsizeBox : ∀ t, 4 ≤ τ * (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty) + (_hbaseBox : ∀ base ∈ bases, base ∈ trimmedIntegerBox N (spatialTrimMargin τ N)), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW (mesh x) base cells (physicalCubeSiteTest (fun site => integerBoxTestExtension N (test site))) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +theorem allocatedProductCoarseBoxAffineData_of_normalized + {Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) + (haffine : AllocatedProductCoarseNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses + M Dwin hM hDwin η hη) : + AllocatedProductCoarseBoxAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses + M Dwin hM hDwin η hη := by + unfold AllocatedProductCoarseBoxAffineData + intro w v Pfinal Mk hMk selection hqDim hcard _ hMkPsp hlarge Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, haffine⟩ := + haffine selection hqDim hcard hMkPsp hlarge + let _ : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let _ : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ mesh τ hτ hτP hτ1 N hN hsizeN hsizeBox poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases hbaseBox V₀ Z H law + coverValue wholeReference reconstruct weight cover + have htestExt : ∀ site z, ‖integerBoxTestExtension N (test site) z‖ ≤ 1 := + fun site z => integerBoxTestExtension_norm_le_one N (test site) (htest site) z + obtain ⟨hmass, hZ, hcomparison⟩ := haffine block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN hsizeN + poly hpoly hmem hrank hRank cells hcells (fun site => integerBoxTestExtension N (test site)) htestExt bases hbases + refine ⟨hmass, hZ, ?_⟩ + intro window hwindow hDwindow shift moduli residues hmoduli hmoduliM kernelLaw + have h := hcomparison window hwindow hDwindow shift moduli residues hmoduli hmoduliM + have hξ1 : ξ ≤ 1 := by + dsimp only [ξ, normalizedTupleNarrowWidth, twoTermErrorWidth] + exact min_le_left _ _ + have hext := allocatedOriginalTupleSource_affine_box_extension B U b hR hσ S X q hb o + N hN hW hτ hξ hξ1 hτ1 hsizeBox (le_refl W) cells hmass test Z poly hmem + M Dwin window shift hwindow hDwindow moduli residues hmoduli hmoduliM + (fun g => scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g)) bases hbaseBox + change ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest (fun site => integerBoxTestExtension N (test site))) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η at h + dsimp only at hext + rw [hext] at h + exact h + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq fullGridCoverAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedOriginalGenuineAffineData (Psp E e pNum Pbase Qraw pAccuracy pSampling Dgeom cgeom O : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite Kgen : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : Prop := + ∃ hgridPeriod : ∀ (q : AllocatedRefinedPeriodIndex m Psp) + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) + (a : {a // allocatedGridAxis (I := I) U b S.value a}) + (k : ((witnesses q r).expansion a).Term), + 0 < ((witnesses q r).expansion a).period k, + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 2)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp) (hlarge : Mk ≤ S.value) + (_hG : (Fintype.card G : ℝ) ≤ Psp) (_hdimP : ((dim + 1 : ℕ) : ℝ) ≤ Psp) + (_hDexp : Dgeom ≤ Real.exp Psp) (_hpAccuracy : 0 ≤ pAccuracy) (_he : 0 ≤ e) + (_hE : 0 ≤ E) (_hcgeom : 0 ≤ cgeom) (_hO : 0 ≤ O) + (_hδ : 0 < δ) (_hδ1 : δ ≤ 1) (_hδe : (δ : ℝ)⁻¹ ≤ Real.exp e) + (_hKgen : 2 ≤ Kgen) + (_hSampling : PhysicalAmbientRowsKernelSampling.{uX,uJ,0} m dim Kgen + (fun j => (rowSets j : Type)) fullRows), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hgeom : AllocatedComparisonDimensions (G := G) B (Fin dim) (fun j => (rowSets j : Type)) Dgeom) + (_hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ Dgeom) + (_hIgeom : ∀ j, (Fintype.card (I j) : ℝ) ≤ Dgeom) + (_hngeom : ∀ j, (n j : ℝ) ≤ Dgeom) + (_hKcov : ∀ j, (Fintype.card (Kcov j) : ℝ) ≤ Dgeom) + (_hCgeom : ∀ j, Cinv j ≤ Real.exp cgeom) + (_hsmall : ∀ j, R j ≤ allocatedProductChartRadius m Dgeom cgeom) + (_hσ1 : ∀ j, σ j ≤ 1) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 2) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 2) + 2) + let mesh := fun x : GoodKernel => + allocatedProductCoarseMesh m X selection Mk (modulus x) Psp pAccuracy w v (E + 2) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (_hτ1 : τ ≤ 1 / 2) + {Psrc Psamp : ℝ} (_hnum : AllocatedSourceNumerics B U b S C V Psrc) + (_hPsamp : Psp ≤ Psamp) (_hdimPsamp : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ Psamp) + (_hτPsamp : 1 / τ ≤ Real.exp Psamp) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (_hsizeBox : ∀ t, 4 ≤ τ * (N t : ℝ)) + (_hsizeG : ∀ t, Real.exp ((allocatedCutoffSamplingLog m dim Psrc + (normalizedSiteCutoffBound : ℝ) 0 Psamp + Kgen) ^ Kgen) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (_hRankG : Real.exp ((allocatedCutoffSamplingLog m dim Psrc + (normalizedSiteCutoffBound : ℝ) 0 Psamp + Kgen) ^ Kgen) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty) + (_hbaseBox : ∀ base ∈ bases, base ∈ trimmedIntegerBox N (spatialTrimMargin τ N)), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let idealLog := allocatedGenuineComparisonErrorLog m Psp Dgeom cgeom + (coarseSpatialPartitionLog (allocatedProductCoarseInput m dim Psp pAccuracy w v (E + 2))) O E + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∃ t : GoodKernel → (X → ℤ) → Fin Mk, + (∀ x base, kernelPeriodCandidate (m + 1) (t x base) ≤ Mk ^ (m + 1)) ∧ + ∃ F : GoodKernel → (X → ℤ) → + PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S) → + AllocatedFiniteIdealData (Fin dim) I n, + (∀ x base y₀, (F x base y₀).Bounds B U b S rowSets x.val y₀ (refined x) (d x) + (kernelPeriodCandidate (m + 1) (t x base)) hb o bW hR δ (Real.exp (-idealLog)) + (allocatedFiniteIdealInputLog m Dgeom e idealLog) (layerKernelIndexBound m Mk)) ∧ + ∀ (test : Finset (Fin dim) → (X → ℝ) → ℂ), (∀ site z, ‖test site z‖ ≤ 1) → + let genuine := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + if hr : 0 < law.mass (Finset.univ.filter (fun y => principalResidueLabel (refined x) y = r)) then + let rr : AllocatedPositiveResidue (dim := dim) B U b S (refined x) := ⟨r, hr⟩ + let _ : ∀ (a : {a // allocatedGridAxis (I := I) U b S.value a}) + (k : ((witnesses (index x) rr).expansion a).Term), + NeZero (((witnesses (index x) rr).expansion a).period k) := + fun a k => ⟨(hgridPeriod (index x) rr a k).ne'⟩ + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ((integerBoxCubeCount N dim : ℂ) * + 𝔼 cube : SupportedCube dim (integerBox N : Set (X → ℤ)), + allocatedAmbientNormalizedSpatialApproximation (τ := τ) B U b S X (modulus x) q + (wholeReference x) (witnesses (index x)) hb o bW (d x) x.val hMk selection x.property N hW + ⟨mesh x, (allocatedProductCoarseMesh_pos m X selection Mk (modulus x) + Psp pAccuracy w v (E + 2)).le⟩ base cells poly hmem rr a + (kernelPeriodCandidate (m + 1) (t x base)) + (F x base ((witnesses (index x) rr).representative)).coefficient + (F x base ((witnesses (index x) rr).representative)).factor test + ((physicalCubeParametersEquiv X dim).symm cube.val)) + else 0) / (Z : ℂ) + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => genuine ⟨x, hx⟩ base)‖ ≤ 2 * Real.exp (-E) + η + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq fullGridCoverAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +theorem allocatedOriginalGenuineAffineData_of_coarse + {Psp E e pNum Pbase Qraw pAccuracy pSampling Dgeom cgeom O : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite Kgen : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + {Nt Vg Hs : (q : AllocatedRefinedPeriodIndex m Psp) → + {a // allocatedGridAxis (I := I) U b S.value a} → ℝ} {L : ℝ≥0} + (hgrid : ∀ q r a, ((witnesses q r).expansion a).Bounds + (Nt q a) (Vg q a) (Real.exp O) L (Hs q a)) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) + (hcoarse : AllocatedProductCoarseBoxAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses + M Dwin hM hDwin η hη) : + AllocatedOriginalGenuineAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling Dgeom cgeom O hP δ + A Kraw Ksite Kgen witnesses M Dwin hM hDwin η hη := by + unfold AllocatedOriginalGenuineAffineData + refine ⟨fun q r a k => (hgrid q r a).period_pos k, ?_⟩ + intro w v Pfinal Mk hMk selection hqDim hcard _ hMkPsp hlarge hG hdimP hDexp + hpAccuracy he hE hcgeom hO hδ hδ1 hδe hKgen hSampling Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hcoarse⟩ := + hcoarse selection hqDim hcard hMkPsp hlarge + let _ : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let _ : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hgeom hvars hIgeom hngeom hKcov hCgeom hsmall hσ1 + μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ mesh τ hτ hτP hτ1 Psrc Psamp hnum hPsamp hdimPsamp hτPsamp + N hN hsizeN hsizeBox hsizeG poly hpoly hmem rank hrank hRank hRankG cells hcells + bases hbases hbaseBox V₀ Z law wholeReference idealLog + have hphysical (j : Fin m) : R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j := + (hsmall j).trans (allocatedProductChartRadius_le_charts B rowSets hgeom hcgeom + hIgeom hngeom Cinv hCinv hCgeom j).2.1 + have hproduct (j : Fin m) : R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j := + (hsmall j).trans (allocatedProductChartRadius_le_charts B rowSets hgeom hcgeom + hIgeom hngeom Cinv hCinv hCgeom j).1 + obtain ⟨hmass, hZ, _⟩ := hcoarse block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hphysical hσ1 hproduct μ ν μsmall hXPsp q hq hqPsp hτ hτP hτ1 + N hN hsizeN hsizeBox poly hpoly hmem hrank hRank cells hcells + (fun _ _ => 0) (by intros; simp) bases hbases hbaseBox + have hw : 0 ≤ w := allocatedSiteKernelMaskLog_nonneg m hP + have hv : 0 ≤ v := allocatedIdealProfileLog_nonneg m hpAccuracy he + have hPsamp0 : 0 ≤ Psamp := hP.trans hPsamp + have hone : (1 : ℝ) ≤ Real.exp Psamp := Real.one_le_exp_iff.mpr hPsamp0 + have hstride (z : X) : (q z : ℝ) ≤ Real.exp Psamp := + (hqPsp z).trans (Real.exp_le_exp.mpr hPsamp) + have hfamily (x : GoodKernel) (base : X → ℤ) := + exists_allocated_coarse_genuine_source_comparison + (B := B) (U := U) (b := b) (hR := hR) (hσ := hσ) (hσ1 := hσ1) (S := S) + (X := X) (modulus := modulus x) (q := q) (wholeReference := wholeReference x) + (coverWitness := witnesses (index x)) (hb := hb) (o := o) (bW := bW) (d := d x) + (δ := δ) (x := x.val) (hM := hMk) (selection := selection) (hx := x.property) + (pAccuracy := pAccuracy) (w := w) (v := v) (Ecoarse := E + 2) + (N := N) (base := base) (cells := cells) (p := poly) (hm := hmem) + (C := Cinv) (hC := hCinv) (hchart := hchart) (hgeom := hgeom) (hcgeom := hcgeom) + (hIgeom := hIgeom) (hngeom := hngeom) (hCgeom := hCgeom) (hsmall := hsmall) + (D := C) (hD := hC) (Vcov := V) (hnum := hnum) (hVcov := fun j => (hV j).2) + (Psp := Psp) (O := O) (E := E) (Z := Z) (P := Psamp) (Elog := 0) + (εs := 1) (η := 1) (S₀ := Real.exp Psamp) + hpAccuracy hw hv (by linarith) hG (hmodulusSize x) + hP hDexp hdimP hXPsp hvars hKcov hO hE hMkPsp hZ.2.2.1 hZ.2.2.2 + (hgrid (index x)) hKgen hSampling hPsamp0 (hXPsp.trans hPsamp) hdimPsamp μsmall ν + (Real.exp_pos _).le le_rfl (by norm_num) hτPsamp (by simpa using hone) hstride + hsizeG hrank hRankG (by norm_num) le_rfl le_rfl (by norm_num) (by norm_num) + hq hτ (hspatial x (fun g => (0 : ℤ) + (x.val g none : ℤ))) hpoly hqDim hδ hδ1 hξ he hδe hmass + choose t ht F hF happrox using hfamily + refine ⟨hmass, hZ, t, ht, F, hF, ?_⟩ + intro test htest genuine window hwindow hDwindow shift moduli residues hmoduli hmoduliM kernelLaw + obtain ⟨hmass', _, hsource⟩ := hcoarse block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hphysical hσ1 hproduct μ ν μsmall hXPsp q hq hqPsp hτ hτP hτ1 + N hN hsizeN hsizeBox poly hpoly hmem hrank hRank cells hcells test htest bases hbases hbaseBox + have hsourceLaw := hsource window hwindow hDwindow shift moduli residues hmoduli hmoduliM + let cover : GoodKernel → (X → ℤ) → ℂ := fun x base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow (trimmedSpatialRootScale τ N q) 4, + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) + x.val hMk selection x.property N hW (mesh x) base cells + (physicalCubeSiteTest (fun site => integerBoxTestExtension N (test site))) r a z * + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem + (allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) + x.val base r a.val z))) / (Z : ℂ) + have hpoint (x : Kernel) (hx : Good x) (base : X → ℤ) (_hb : base ∈ bases) : + ‖cover ⟨x, hx⟩ base - genuine ⟨x, hx⟩ base‖ ≤ Real.exp (-E) := + happrox ⟨x, hx⟩ base test htest + have htransfer := kernelLaw.complexMean_goodPart_base_transfer bases hbases Good + (fun x base => allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ + base cells hmass (physicalCubeSiteTest test) Z poly hmem) + (fun x hx base => cover ⟨x, hx⟩ base) (fun x hx base => genuine ⟨x, hx⟩ base) + (Real.exp_pos (-E)).le hsourceLaw hpoint + exact htransfer.trans_eq (by ring) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalSampleFullResidueRiemann.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalSampleFullResidueRiemann.lean new file mode 100644 index 0000000000000000000000000000000000000000..91661362220c006d391ffcbdb202c0fcfc401a30 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalSampleFullResidueRiemann.lean @@ -0,0 +1,120 @@ +import OAI.Combinatorics.Progressions.Polynomial.AllocatedOriginalSampleResiduePolynomialAlmostSure + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G X Zsp : Type*} [Fintype G] [Fintype X] [Fintype Zsp] [DecidableEq Zsp] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "activeB" => (fun a : Active => B (Subtype.val a)) +local notation "activeDegree" => (fun a : Active => degree (Subtype.val a)) +local notation "Input" => PrincipalTupleIndex activeB activeDegree +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short + +theorem allocatedOriginalSampleForecastDensity_full_residue_riemann + (s : Empty ↪ Zsp) (root : Zsp → ℤ) (D : Matrix Empty Zsp ℤ) + (hp : (selectedSpatialPivot root D s).det ≠ 0) + {W L : ℝ} (hW : 0 ≤ W) (hL : 0 < L) + (hB : ∀ a : Active, 4 ≤ Fintype.card (B a.val)) + (hroot : ∀ j, |(root j : ℝ)| ≤ 1 + W) + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (hS : 2 ≤ S.value) + (q : ℕ) (hq : 0 < q) (residue : Input → Option Empty → ZMod q) + (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + {Out : Type*} (poly : Out → MvPolynomial Input ℤ) + (φ : (Out → ZMod q) → (((Σ _ : X, Unit ⊕ Empty) → ℝ) × (Output → ℝ)) → ℂ) + {Kφ : ℝ≥0} (hφ : ∀ r, LipschitzWith Kφ (φ r)) + (hφone : ∀ r y, ‖φ r y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleLiftLip B U basis S + let outres := fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (fun j => residue j none) (poly o) + ‖(∫ z, (principalResidueWeights activeB activeDegree (fun _ => S.value) + (fun _ => S.positive) q hq residue + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean + (fun v => φ (fun o => ((MvPolynomial.eval (fun j => (v j none : ℤ)) (poly o) : ℤ) : ZMod q)) (z, allocatedOriginalSampleLiftMap B U basis S (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (v j none : ℝ) / S.value))) + ∂canonicalZeroSpatialLaw (X := X) s root D W L) - + ∫ y, φ outres y ∂realDensityMeasure volume (allocatedOriginalSampleForecastDensity (X := X) + B U basis S s root D hp hW hL hB lower width sample)‖ ≤ + 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) := by + classical + intro lower width K outres + have he := allocatedOriginalSampleForecastDensity_polynomial_residue_riemann + B U basis hR hσ S s root D hp hW hL hB hroot sample hs + (fun _ => 1) (fun _ => S.value) (fun _ => 0) + (fun _ => Nat.zero_lt_one) (fun _ => hS) (δ := 1) zero_lt_one + (fun _ => fullIntervalProgression_subset S.value) + (fun _ => by simp only [Nat.cast_one, fullIntervalProgression_card, one_mul, le_refl]) + q hq residue (fun _ => hsize) (fun _ => hsmall) + (ε := 1 / S.value) (by positivity) (fun _ => by simp only [Nat.cast_one, le_refl]) + poly φ hφ hφone + dsimp only at he + rw [containedProgressionResidueLaw_fullInterval] at he + simpa only [Int.cast_zero, Nat.cast_one, zero_add, one_mul, zero_div, + lower, width, K, outres] using he + +theorem allocatedOriginalSampleForecastDensity_full_residue_complex_riemann + (s : Empty ↪ Zsp) (root : Zsp → ℤ) (D : Matrix Empty Zsp ℤ) + (hp : (selectedSpatialPivot root D s).det ≠ 0) + {W L : ℝ} (hW : 0 ≤ W) (hL : 0 < L) + (hB : ∀ a : Active, 4 ≤ Fintype.card (B a.val)) + (hroot : ∀ j, |(root j : ℝ)| ≤ 1 + W) + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (hS : 2 ≤ S.value) + (q : ℕ) (hq : 0 < q) (residue : Input → Option Empty → ZMod q) + (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (((Σ _ : X, Unit ⊕ Empty) → ℝ) × (Output → ℝ)) → ℂ) + {Kφ : ℝ≥0} (hφ : LipschitzWith Kφ φ) + (hφone : ∀ y, ‖φ y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleLiftLip B U basis S + ‖(∫ z, (principalResidueWeights activeB activeDegree (fun _ => S.value) + (fun _ => S.positive) q hq residue + (fun _ => by simpa only [Fintype.card_empty, zero_add, one_mul] using hsize)).complexMean + (fun v => φ (z, allocatedOriginalSampleLiftMap B U basis S (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (v j none : ℝ) / S.value))) + ∂canonicalZeroSpatialLaw (X := X) s root D W L) - + ∫ y, φ y ∂realDensityMeasure volume (allocatedOriginalSampleForecastDensity (X := X) + B U basis S s root D hp hW hL hB lower width sample)‖ ≤ + 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) := by + exact allocatedOriginalSampleForecastDensity_full_residue_riemann + B U basis hR hσ S s root D hp hW hL hB hroot sample hs hS q hq residue hsize hsmall + (fun e : Empty => e.elim) (fun _ => φ) (fun _ => hφ) (fun _ => hφone) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalSampleResidueMixtureForecast.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalSampleResidueMixtureForecast.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a26532b5813a5af6abf21cccae1771fc88ad76e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedOriginalSampleResidueMixtureForecast.lean @@ -0,0 +1,734 @@ +import OAI.Combinatorics.Progressions.Sampling.AllocatedKernelForecastSourceDecoupling +import OAI.Combinatorics.Progressions.Sampling.AllocatedOriginalSampleConditionalForecastComparison +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveFiberLaw +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveSlicedFixedProduct + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem forecastInactive_kernel_disintegration + {Ω Z R : Type*} [Fintype Ω] [DecidableEq Ω] [Fintype R] [DecidableEq R] + (p : FiniteProbabilityWeights Ω) (residue : Ω → R) + (kernel : Ω → PMF Z) (z : Z) (coefficient : R → ℂ) : + p.complexMean (fun x => coefficient (residue x) * ((kernel x z).toReal : ℂ)) = + ∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + (p.mass (Finset.univ.filter (fun x => residue x = r.val)) : ℂ) * coefficient r.val * + ((((p.condition (Finset.univ.filter (fun x => residue x = r.val)) r.property).toPMF.bind + kernel) z).toReal : ℂ) := by + calc + _ = p.complexMean (fun x => ((kernel x z).toReal : ℂ) * coefficient (residue x)) := by + congr 1 + funext x + exact mul_comm _ _ + _ = ∑ r, (p.fiberMean residue r (fun x => (kernel x z).toReal) : ℂ) * coefficient r := + p.complexMean_fiber_factor residue (fun x => (kernel x z).toReal) coefficient + _ = _ := by + apply Finset.sum_congr_set + {r : R | 0 < p.mass (Finset.univ.filter (fun x => residue x = r))} + · intro r hr + rw [forecastInactive_fiber_kernel p residue r hr kernel z, Complex.ofReal_mul] + ring + · intro r hr + have hzero : p.mass (Finset.univ.filter (fun x => residue x = r)) = 0 := + le_antisymm (le_of_not_gt hr) (p.mass_nonneg _) + have hf : p.fiberMean residue r (fun x => (kernel x z).toReal) = 0 := by + simpa only [FiniteProbabilityWeights.fiberMean, Finset.mem_filter, + Finset.mem_univ, true_and] using p.mean_mask_zero + (Finset.univ.filter (fun x => residue x = r)) hzero + (fun x => (kernel x z).toReal) + rw [hf, Complex.ofReal_zero, zero_mul] + +theorem forecastInactive_indicator_disintegration + {Ω Z R : Type*} [Fintype Ω] [DecidableEq Ω] [Fintype R] [DecidableEq R] + [DecidableEq Z] (p : FiniteProbabilityWeights Ω) (residue : Ω → R) + (F : Ω → Z) (z : Z) (coefficient : R → ℂ) : + p.complexMean (fun y => coefficient (residue y) * (if F y = z then 1 else 0)) = + ∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun y => residue y = r))}, + (p.mass (Finset.univ.filter (fun y => residue y = r.val)) : ℂ) * coefficient r.val * + ((((p.condition (Finset.univ.filter (fun y => residue y = r.val)) r.property).toPMF.map + F) z).toReal : ℂ) := by + have hp (y : Ω) : ((PMF.pure (F y) z).toReal : ℂ) = if F y = z then 1 else 0 := by + by_cases hy : F y = z + · simp [PMF.pure_apply, hy] + · simp [PMF.pure_apply, hy, Ne.symm hy] + simpa only [PMF.bind_pure_comp, Function.comp_apply, hp] using + forecastInactive_kernel_disintegration p residue (PMF.pure ∘ F) z coefficient + +theorem forecastInactive_positiveResidue_mass_sum + {Ω R : Type*} [Fintype Ω] [DecidableEq Ω] [Fintype R] [DecidableEq R] + (p : FiniteProbabilityWeights Ω) (residue : Ω → R) : + (∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + p.mass (Finset.univ.filter (fun x => residue x = r.val))) = 1 := by + have hsum : (∑ r : R, p.mass (Finset.univ.filter (fun x => residue x = r))) = + ∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + p.mass (Finset.univ.filter (fun x => residue x = r.val)) := by + apply Finset.sum_congr_set + {r : R | 0 < p.mass (Finset.univ.filter (fun x => residue x = r))} + · intro r hr + rfl + · intro r hr + exact le_antisymm (le_of_not_gt hr) (p.mass_nonneg _) + rw [← hsum] + simpa only [FiniteProbabilityWeights.fiberLaw_weight_eq_mass] using + (p.fiberLaw residue).total + +namespace VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {A : Type*} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (rows : A → Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) + +noncomputable def forecastInactivePhysicalJointKernel + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) : + PMF (∀ a, rows a → ℤ) := + dependentProductPMF (fun a => integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) ((selected a).1.val + 1) + (fun t : rows a => (t : Finset α))) + (allocatedLayerIntegerPMFs B U b hR hσ S (selected a).1 (selected a).2)) + +theorem forecastInactive_physical_fiber_kernel + (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) + (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + (z : ∀ a, rows a → ℤ) : + (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).fiberMean + (principalResidueLabel q) r + (fun y => (forecastInactivePhysicalJointKernel B U b hR hσ S selected rows x y z).toReal) = + (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) * + (allocatedSupportedPhysicalJointPMF B U b hR hσ S q r hcell selected rows x z).toReal := by + exact forecastInactive_fiber_kernel _ (principalResidueLabel q) r hcell + (forecastInactivePhysicalJointKernel B U b hR hσ S selected rows x) z + +theorem forecastInactive_physical_kernel_disintegration + (q : ℕ) [NeZero q] + (coefficient : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) → ℂ) + (z : ∀ a, rows a → ℤ) : + let p := principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + p.complexMean (fun y => coefficient (principalResidueLabel q y) * + ((forecastInactivePhysicalJointKernel B U b hR hσ S selected rows x y z).toReal : ℂ)) = + ∑ r : {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q // + 0 < p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + (p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + coefficient r.val * + ((allocatedSupportedPhysicalJointPMF B U b hR hσ S q r.val r.property + selected rows x z).toReal : ℂ) := by + exact forecastInactive_kernel_disintegration _ (principalResidueLabel q) + (forecastInactivePhysicalJointKernel B U b hR hσ S selected rows x) z coefficient + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.FiniteProbabilityWeights + +open scoped BigOperators Classical + +variable {X R : Type*} [Fintype X] [DecidableEq X] [Fintype R] [DecidableEq R] + +omit [Fintype R] in +theorem condition_complexMean_fiber_apply (p : FiniteProbabilityWeights X) (residue : X → R) + (r : R) (hr : 0 < p.mass (Finset.univ.filter (fun x => residue x = r))) + (test : R → X → ℂ) : + (p.condition _ hr).complexMean (fun x => test (residue x) x) = + (p.condition _ hr).complexMean (test r) := by + apply (p.condition _ hr).complexMean_congr_support + intro x hx + have hxr : residue x = r := + (Finset.mem_filter.mp (condition_weight_support p _ hr x hx).1).2 + rw [hxr] + +theorem complexMean_positiveResidue_disintegration + (p : FiniteProbabilityWeights X) (residue : X → R) (test : R → X → ℂ) : + p.complexMean (fun x => test (residue x) x) = + ∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + (p.mass (Finset.univ.filter (fun x => residue x = r.val)) : ℂ) * + (p.condition (Finset.univ.filter (fun x => residue x = r.val)) r.property).complexMean + (test r.val) := by + calc + _ = ∑ r, p.fiberComplexMean residue r (fun x => test (residue x) x) := by + simpa only [Finset.mem_univ, ite_true] using + (p.sum_fiberComplexMean_on residue Finset.univ (fun x => test (residue x) x)).symm + _ = _ := by + apply Finset.sum_congr_set + {r : R | 0 < p.mass (Finset.univ.filter (fun x => residue x = r))} + · intro r hr + rw [p.fiberComplexMean_eq_condition residue r _ hr, + p.condition_complexMean_fiber_apply residue r hr test] + · intro r hr + apply p.fiberComplexMean_zero + rw [p.fiberLaw_weight_eq_mass] + exact le_antisymm (le_of_not_gt hr) (p.mass_nonneg _) + +theorem complexMean_positiveResidue_weighted_disintegration + (p : FiniteProbabilityWeights X) (residue : X → R) + (coefficient : R → ℂ) (test : R → X → ℂ) : + p.complexMean (fun x => coefficient (residue x) * test (residue x) x) = + ∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + (p.mass (Finset.univ.filter (fun x => residue x = r.val)) : ℂ) * coefficient r.val * + (p.condition (Finset.univ.filter (fun x => residue x = r.val)) r.property).complexMean + (test r.val) := by + rw [p.complexMean_positiveResidue_disintegration residue + (fun r x => coefficient r * test r x)] + apply Finset.sum_congr rfl + intro r _ + rw [complexMean_mul_left, mul_assoc] + +theorem complexMean_positiveResidue_weighted_error + (p : FiniteProbabilityWeights X) (residue : X → R) + (coefficient : R → ℂ) (test : R → X → ℂ) + (target : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))} → ℂ) + {ε : ℝ} (hε : 0 ≤ ε) + (hcoefficient : ∀ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + ‖coefficient r.val‖ ≤ 1) + (herror : ∀ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + ‖(p.condition (Finset.univ.filter (fun x => residue x = r.val)) r.property).complexMean + (test r.val) - target r‖ ≤ ε) : + ‖p.complexMean (fun x => coefficient (residue x) * test (residue x) x) - + ∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + (p.mass (Finset.univ.filter (fun x => residue x = r.val)) : ℂ) * coefficient r.val * + target r‖ ≤ ε := by + rw [p.complexMean_positiveResidue_weighted_disintegration residue, + ← Finset.sum_sub_distrib] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ r : {r : R // 0 < p.mass (Finset.univ.filter (fun x => residue x = r))}, + p.mass (Finset.univ.filter (fun x => residue x = r.val)) * ε := by + apply Finset.sum_le_sum + intro r _ + rw [← mul_sub, norm_mul, norm_mul, Complex.norm_real, + Real.norm_of_nonneg (p.mass_nonneg _), mul_assoc] + apply mul_le_mul_of_nonneg_left _ (p.mass_nonneg _) + exact (mul_le_mul_of_nonneg_left (herror r) (norm_nonneg _)).trans + ((mul_le_mul_of_nonneg_right (hcoefficient r) hε).trans_eq (one_mul ε)) + _ = ε := by + rw [← Finset.sum_mul, forecastInactive_positiveResidue_mass_sum p residue, one_mul] + +end Erdos3.FiniteProbabilityWeights + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "degree" => layerSamplerDegree I n +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "hSides" => allocatedPrincipalSides_pos B U basis S +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "Short" => {a : LayerSamplerAxis I n // short a} +local notation "activeB" => (fun a : Active => B (Subtype.val a)) +local notation "activeDegree" => (fun a : Active => degree (Subtype.val a)) +local notation "ActiveInput" => PrincipalTupleIndex activeB activeDegree +local notation "FullInput" => PrincipalTupleIndex B degree +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) short sides +local notation "ActiveTuple" => PrincipalAxisTuples (α := Empty) (fun a => ¬short a) sides +local notation "law" => principalTupleWeights (α := Empty) B degree sides hSides + +noncomputable def allocatedUnconditionalShortPrincipalLaw : + FiniteProbabilityWeights ShortTuple := + principalTupleWeights (fun a : Short => B a.val) (fun a => degree a.val) + (principalAxisLength short sides) (fun j => hSides ⟨j.1.val, j.2⟩) + +noncomputable def allocatedUnconditionalActivePrincipalLaw : + FiniteProbabilityWeights ActiveTuple := + principalTupleWeights activeB activeDegree (principalAxisLength (fun a => ¬short a) sides) + (fun j => hSides ⟨j.1.val, j.2⟩) + +noncomputable def allocatedPrincipalResidueJoin (q : ℕ) (u : ShortTuple) + (r : ActiveInput → ZMod q) : FullInput → Option Empty → ZMod q := + principalAxisResidueJoin short u q (fun j _ => r j) + +theorem allocatedPrincipalResidueJoin_label_join (q : ℕ) (u : ShortTuple) (v : ActiveTuple) : + principalResidueLabel q (principalAxisJoin short u v) = + allocatedPrincipalResidueJoin B U basis S q u (fun j => ((v j none : ℤ) : ZMod q)) := by + rw [principalResidueLabel_join] + unfold allocatedPrincipalResidueJoin + congr 1 + funext j c + cases c with + | none => rfl + | some e => exact e.elim + +theorem allocatedPrincipalResidue_short_marginal + (q : ℕ) (r : FullInput → Option Empty → ZMod q) + (hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + (f : ShortTuple → ℂ) : + ((law).condition (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hr).complexMean + (fun y => f (principalAxisRestrict short y)) = + (allocatedShortPrincipalResidueLaw B U basis S q r hr).complexMean f := by + rw [allocatedPrincipalResidue_partition B U basis S q r hr] + simp only [principalAxisRestrict_join_left, FiniteProbabilityWeights.complexMean_const] + +theorem allocatedPrincipalResidue_mixture_reconstruct + (q : ℕ) [NeZero q] (f : (FullInput → Option Empty → ZMod q) → ShortTuple → ℂ) : + (∑ r : {r : FullInput → Option Empty → ZMod q // + 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + ((law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + (allocatedShortPrincipalResidueLaw B U basis S q r.val r.property).complexMean (f r.val)) = + (law).complexMean (fun y => f (principalResidueLabel q y) (principalAxisRestrict short y)) := by + rw [(law).complexMean_positiveResidue_disintegration (principalResidueLabel q) + (fun r y => f r (principalAxisRestrict short y))] + apply Finset.sum_congr rfl + intro r _ + rw [allocatedPrincipalResidue_short_marginal B U basis S q r.val r.property] + +theorem allocatedPrincipalResidue_mixture_partition + (q : ℕ) [NeZero q] (f : (FullInput → Option Empty → ZMod q) → ShortTuple → ℂ) : + (∑ r : {r : FullInput → Option Empty → ZMod q // + 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + ((law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + (allocatedShortPrincipalResidueLaw B U basis S q r.val r.property).complexMean (f r.val)) = + (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean (fun u => + (allocatedUnconditionalActivePrincipalLaw B U basis S).complexMean (fun v => + f (allocatedPrincipalResidueJoin B U basis S q u + (fun j => ((v j none : ℤ) : ZMod q))) u)) := by + rw [allocatedPrincipalResidue_mixture_reconstruct B U basis S q f, + principalTupleWeights_partition short sides hSides] + simp only [principalAxisRestrict_join_left, + allocatedPrincipalResidueJoin_label_join B U basis S] + rfl + +theorem allocatedPrincipalResidue_mixture_active_residue + (q : ℕ) [NeZero q] (f : (FullInput → Option Empty → ZMod q) → ShortTuple → ℂ) : + (∑ r : {r : FullInput → Option Empty → ZMod q // + 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + ((law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + (allocatedShortPrincipalResidueLaw B U basis S q r.val r.property).complexMean (f r.val)) = + (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean (fun u => + ((allocatedUnconditionalActivePrincipalLaw B U basis S).fiberLaw + (fun v j => ((v j none : ℤ) : ZMod q))).complexMean + (fun r => f (allocatedPrincipalResidueJoin B U basis S q u r) u)) := by + simp only [FiniteProbabilityWeights.fiberLaw_complexMean] + exact allocatedPrincipalResidue_mixture_partition B U basis S q f + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "hSides" => allocatedPrincipalSides_pos B U basis S +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "AI" => PrincipalTupleIndex (fun a : Active => B (Subtype.val a)) (fun a : Active => degree (Subtype.val a)) +local notation "FullInput" => PrincipalTupleIndex B degree +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) short sides +local notation "law" => principalTupleWeights (α := Empty) B degree sides hSides + +theorem allocatedPrincipalResidue_mixture_active_uniform + (q : ℕ) [NeZero q] + (f : (FullInput → Option Empty → ZMod q) → ShortTuple → ℂ) + (hf : ∀ r u, ‖f r u‖ ≤ 1) : + ‖(∑ r : {r : FullInput → Option Empty → ZMod q // + 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + ((law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + (allocatedShortPrincipalResidueLaw B U basis S q r.val r.property).complexMean (f r.val)) - + (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean (fun u => + (FiniteProbabilityWeights.uniform (AI → ZMod q)).complexMean (fun r => + f (allocatedPrincipalResidueJoin B U basis S q u r) u))‖ ≤ + 4 * Fintype.card AI * ((q : ℝ) / S.value) := by + rw [allocatedPrincipalResidue_mixture_partition B U basis S q f] + apply ((allocatedUnconditionalShortPrincipalLaw B U basis S).norm_complexMean_sub_le + _ _ (fun _ => 4 * Fintype.card AI * ((q : ℝ) / S.value)) ?_).trans_eq + ((allocatedUnconditionalShortPrincipalLaw B U basis S).mean_const _) + intro u _ + have h := allocatedActive_affine_residue_comparison B U basis S q (fun _ => 0) + (fun _ => 1) (fun r => allocatedPrincipalResidueJoin B U basis S q u r) + (fun r => f r u) (fun r => hf r u) + simpa only [zero_add, one_mul, Int.cast_zero, Int.cast_one, + allocatedUnconditionalActivePrincipalLaw] using h + +variable {X Zsp : Type*} [Fintype X] [Fintype Zsp] [DecidableEq Zsp] +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "Domain" => (((Σ _ : X, Unit ⊕ Empty) → ℝ) × ((Σ _a : Active, Unit) → ℝ)) + +theorem allocatedOriginalSampleForecastSource_active_uniform + (s : Empty ↪ Zsp) (root : Zsp → ℤ) (D : Matrix Empty Zsp ℤ) + (hp : (selectedSpatialPivot root D s).det ≠ 0) + {W L : ℝ} (hW : 0 ≤ W) (hL : 0 < L) + (lower width : ∀ a : Active, B a.val × Fin (degree a.val) → ℝ) + (sample : Sample) (q : ℕ) [NeZero q] + (φ : (FullInput → Option Empty → ZMod q) → ShortTuple → Domain → ℂ) + (hφ : ∀ r u y, ‖φ r u y‖ ≤ 1) : + let μ := allocatedOriginalSampleForecastSource (X := X) (W := W) (L := L) + B U basis S s root D lower width sample + ‖(∑ r : {r : FullInput → Option Empty → ZMod q // + 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + ((law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + (allocatedShortPrincipalResidueLaw B U basis S q r.val r.property).complexMean + (fun u => ∫ y, φ r.val u y ∂μ)) - + (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean (fun u => + (FiniteProbabilityWeights.uniform (AI → ZMod q)).complexMean (fun r => + ∫ y, φ (allocatedPrincipalResidueJoin B U basis S q u r) u y ∂μ))‖ ≤ + 4 * Fintype.card AI * ((q : ℝ) / S.value) := by + intro μ + let : IsProbabilityMeasure μ := allocatedOriginalSampleForecastSource_probability + B U basis S lower width s root D hp hW hL sample + have hb (r : FullInput → Option Empty → ZMod q) (u : ShortTuple) : + ‖∫ y, φ r u y ∂μ‖ ≤ 1 := by + simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const + (μ := μ) (Filter.Eventually.of_forall (fun y => hφ r u y)) + exact allocatedPrincipalResidue_mixture_active_uniform B U basis S q + (fun r u => ∫ y, φ r u y ∂μ) hb + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "degree" => layerSamplerDegree I n +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "hSides" => allocatedPrincipalSides_pos B U basis S +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "activeB" => (fun a : Active => B (Subtype.val a)) +local notation "activeDegree" => (fun a : Active => degree (Subtype.val a)) +local notation "ActiveInput" => PrincipalTupleIndex activeB activeDegree +local notation "activeLength" => principalAxisLength (fun a => ¬short a) sides +local notation "activePos" => (fun j : ActiveInput => hSides (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j))) +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) short sides + +private theorem scalarIntegerMean_congr + (L₁ L₂ : ℕ) (hL₁ : 0 < L₁) (hL₂ : 0 < L₂) (he : L₁ = L₂) (f : ℤ → ℂ) : + (integerScalarCubeWeights Empty L₁ hL₁).complexMean (fun z => f (z none : ℤ)) = + (integerScalarCubeWeights Empty L₂ hL₂).complexMean (fun z => f (z none : ℤ)) := by + subst L₂ + rfl + +theorem allocatedUnconditionalActivePrincipalLaw_integer_mean + (f : (ActiveInput → ℤ) → ℂ) : + (allocatedUnconditionalActivePrincipalLaw B U basis S).complexMean + (fun y => f (fun j => (y j none : ℤ))) = + (FiniteProbabilityWeights.pi + (fun _ : ActiveInput => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun y => f (fun j => (y j none : ℤ))) := by + exact FiniteProbabilityWeights.complexMean_pi_transport_fintype + (fun j => integerScalarCubeWeights Empty (activeLength j) (activePos j)) + (fun _ : ActiveInput => integerScalarCubeWeights Empty S.value S.positive) + (fun _ z => (z none : ℤ)) (fun _ z => (z none : ℤ)) + (fun j g => scalarIntegerMean_congr (activeLength j) S.value (activePos j) + S.positive (allocatedActivePrincipalResidue_length B U basis S j) g) f + +theorem allocatedPrincipal_integer_partition + (f : ShortTuple → (ActiveInput → ℤ) → ℂ) : + (principalTupleWeights (α := Empty) B degree sides hSides).complexMean + (fun y => f (principalAxisRestrict short y) + (fun j => ((principalAxisRestrict (fun a => ¬short a) y) j none : ℤ))) = + (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean (fun u => + (FiniteProbabilityWeights.pi + (fun _ : ActiveInput => integerScalarCubeWeights Empty S.value S.positive)).complexMean + (fun v => f u (fun j => (v j none : ℤ)))) := by + rw [principalTupleWeights_partition short sides hSides] + simp only [principalAxisRestrict_join_left, principalAxisRestrict_join_right] + change (allocatedUnconditionalShortPrincipalLaw B U basis S).complexMean + (fun u => (allocatedUnconditionalActivePrincipalLaw B U basis S).complexMean + (fun v => f u (fun j => (v j none : ℤ)))) = _ + congr 1 + funext u + exact allocatedUnconditionalActivePrincipalLaw_integer_mean B U basis S (f u) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G X : Type*} [Fintype G] [DecidableEq G] [Fintype X] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "Input" => (Σ a : Active, B (Subtype.val a) × Fin (layerSamplerDegree I n (Subtype.val a))) +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "Spatial" => ((Σ _ : X, Unit ⊕ Empty) → ℝ) +local notation "Domain" => (Spatial × (Output → ℝ)) +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) short sides + +variable (lower width : ∀ a : {a : LayerSamplerAxis I n // + ¬allocatedShortAxis (I := I) U basis S.value a}, + B a.val × Fin (layerSamplerDegree I n a.val) → ℝ) + +theorem allocatedJointLongForecast_residue_decoupling + (s : Empty ↪ G) (sample : Sample) + (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (φ : (G → ZMod q) → (Input → ZMod q) → ShortTuple → Domain → ℂ) {K : ℝ≥0} + (hφ : ∀ rG rA u, LipschitzWith K (φ rG rA u)) + (hbound : ∀ rG rA u y, ‖φ rG rA u y‖ ≤ 1) : + let kernel := FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive) + let shortLaw := allocatedUnconditionalShortPrincipalLaw B U basis S + let activeResidues := FiniteProbabilityWeights.uniform (Input → ZMod q) + let kernelResidues := FiniteProbabilityWeights.uniform (G → ZMod q) + ‖kernel.complexMean (fun x => shortLaw.complexMean (fun u => activeResidues.complexMean (fun rA => + ∫ y, φ (fun g => ((x g none : ℤ) : ZMod q)) rA u y + ∂allocatedOriginalSampleForecastSource (X := X) (W := budget) (L := (S.value : ℝ)) + B U basis S s (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) + lower width sample))) - + shortLaw.complexMean (fun u => activeResidues.complexMean (fun rA => + kernelResidues.complexMean (fun rG => kernel.complexMean (fun x => + ∫ y, φ rG rA u y + ∂allocatedOriginalSampleForecastSource (X := X) (W := budget) (L := (S.value : ℝ)) + B U basis S s (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) + lower width sample))))‖ ≤ + 2 * ((1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K)) * + (Fintype.card G * ((q : ℝ) / S.value))) := by + classical + intro kernel shortLaw activeResidues kernelResidues + let E : ℝ := 2 * ((1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K)) * + (Fintype.card G * ((q : ℝ) / S.value))) + let value := fun (x : G → IntegerScalarCubeBox Empty S.value) rG rA (u : ShortTuple) => + ∫ y, φ rG rA u y + ∂allocatedOriginalSampleForecastSource (X := X) (W := budget) (L := (S.value : ℝ)) + B U basis S s (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) + lower width sample + have hpoint (u : ShortTuple) (rA : Input → ZMod q) : + ‖kernel.complexMean (fun x => value x (fun g => ((x g none : ℤ) : ZMod q)) rA u) - + kernelResidues.complexMean (fun rG => kernel.complexMean (fun x => value x rG rA u))‖ ≤ E := by + simpa only [kernelResidues, FiniteProbabilityWeights.uniform_complexMean] using + allocatedKernel_forecastSource_residue_decoupling B U basis S lower width s sample + q hsize hsmall (fun rG => φ rG rA u) (fun rG => hφ rG rA u) (fun rG => hbound rG rA u) + have hcomm : + kernel.complexMean (fun x => shortLaw.complexMean (fun u => activeResidues.complexMean + (fun rA => value x (fun g => ((x g none : ℤ) : ZMod q)) rA u))) = + shortLaw.complexMean (fun u => activeResidues.complexMean (fun rA => kernel.complexMean + (fun x => value x (fun g => ((x g none : ℤ) : ZMod q)) rA u))) := by + rw [FiniteProbabilityWeights.complexMean_commute kernel shortLaw] + congr 1 + funext u + exact FiniteProbabilityWeights.complexMean_commute kernel activeResidues _ + rw [hcomm] + apply (shortLaw.norm_complexMean_sub_le _ _ (fun _ => E) ?_).trans_eq (shortLaw.mean_const E) + intro u _ + exact (activeResidues.norm_complexMean_sub_le _ _ (fun _ => E) + (fun rA _ => hpoint u rA)).trans_eq (activeResidues.mean_const E) + +theorem allocatedJointLongForecast_weighted_residue_decoupling + (s : Empty ↪ G) (sample : Sample) + (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (coefficient : (G → ZMod q) → (Input → ZMod q) → ShortTuple → ℂ) + (hcoefficient : ∀ rG rA u, ‖coefficient rG rA u‖ ≤ 1) + (φ : (G → ZMod q) → (Input → ZMod q) → ShortTuple → Domain → ℂ) {K : ℝ≥0} + (hφ : ∀ rG rA u, LipschitzWith K (φ rG rA u)) + (hbound : ∀ rG rA u y, ‖φ rG rA u y‖ ≤ 1) : + let kernel := FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty S.value S.positive) + let shortLaw := allocatedUnconditionalShortPrincipalLaw B U basis S + let activeResidues := FiniteProbabilityWeights.uniform (Input → ZMod q) + let kernelResidues := FiniteProbabilityWeights.uniform (G → ZMod q) + ‖kernel.complexMean (fun x => shortLaw.complexMean (fun u => activeResidues.complexMean (fun rA => + coefficient (fun g => ((x g none : ℤ) : ZMod q)) rA u * + ∫ y, φ (fun g => ((x g none : ℤ) : ZMod q)) rA u y + ∂allocatedOriginalSampleForecastSource (X := X) (W := budget) (L := (S.value : ℝ)) + B U basis S s (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) + lower width sample))) - + shortLaw.complexMean (fun u => activeResidues.complexMean (fun rA => + kernelResidues.complexMean (fun rG => kernel.complexMean (fun x => + coefficient rG rA u * ∫ y, φ rG rA u y + ∂allocatedOriginalSampleForecastSource (X := X) (W := budget) (L := (S.value : ℝ)) + B U basis S s (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) + lower width sample))))‖ ≤ + 2 * ((1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + K)) * + (Fintype.card G * ((q : ℝ) / S.value))) := by + have hmul (rG : G → ZMod q) (rA : Input → ZMod q) (u : ShortTuple) : + LipschitzWith K (fun y => coefficient rG rA u * φ rG rA u y) := by + apply LipschitzWith.of_dist_le_mul + intro y z + rw [dist_eq_norm, ← mul_sub, norm_mul] + exact (mul_le_of_le_one_left (norm_nonneg _) (hcoefficient rG rA u)).trans + (by simpa only [dist_eq_norm] using (hφ rG rA u).dist_le_mul y z) + have hb (rG : G → ZMod q) (rA : Input → ZMod q) (u : ShortTuple) (y : Domain) : + ‖coefficient rG rA u * φ rG rA u y‖ ≤ 1 := by + rw [norm_mul] + exact (mul_le_of_le_one_left (norm_nonneg _) (hcoefficient rG rA u)).trans + (hbound rG rA u y) + simpa only [integral_const_mul] using + allocatedJointLongForecast_residue_decoupling B U basis S lower width s sample q hsize hsmall + (fun rG rA u y => coefficient rG rA u * φ rG rA u y) hmul hb + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G X Zsp : Type*} [Fintype G] [Fintype X] [Fintype Zsp] [DecidableEq Zsp] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "activeB" => (fun a : Active => B (Subtype.val a)) +local notation "activeDegree" => (fun a : Active => degree (Subtype.val a)) +local notation "Input" => PrincipalTupleIndex activeB activeDegree +local notation "Output" => (Σ _a : Active, Unit) +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short + +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "hSides" => allocatedPrincipalSides_pos B U basis S +local notation "ShortTuple" => PrincipalAxisTuples (α := Empty) short sides +local notation "FullInput" => PrincipalTupleIndex B degree +local notation "Original" => PrincipalIntegerTuples B degree Empty sides +local notation "Domain" => (((Σ _ : X, Unit ⊕ Empty) → ℝ) × (Output → ℝ)) + +theorem allocatedOriginalSample_residue_mixture_forecast_comparison + (s : Empty ↪ Zsp) (root : Zsp → ℤ) (D : Matrix Empty Zsp ℤ) + (hp : (selectedSpatialPivot root D s).det ≠ 0) + {W L : ℝ} (hW : 0 ≤ W) (hL : 0 < L) + (hB : ∀ a : Active, 4 ≤ Fintype.card (B a.val)) + (hroot : ∀ j, |(root j : ℝ)| ≤ 1 + W) + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (hS : 2 ≤ S.value) + (q : ℕ) [NeZero q] (hsize : q ≤ S.value) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / S.value) < 1) + (coefficient : (FullInput → Option Empty → ZMod q) → ℂ) + (hcoefficient : ∀ r, ‖coefficient r‖ ≤ 1) + (φ : (FullInput → Option Empty → ZMod q) → ShortTuple → Domain → ℂ) + {Kφ : ℝ≥0} (hφ : ∀ r u, LipschitzWith Kφ (φ r u)) + (hφone : ∀ r u y, ‖φ r u y‖ ≤ 1) : + let lower := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => (0 : ℝ) + let width := fun (_a : Active) (_p : B _a.val × Fin (degree _a.val)) => + ((S.value : ℝ) - 1) / S.value + let K := Kφ * allocatedOriginalSampleLiftLip B U basis S + let law := principalTupleWeights (α := Empty) B degree sides hSides + let Pos := {r : FullInput → Option Empty → ZMod q // + 0 < law.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))} + ‖(∫ z, law.complexMean (fun v => coefficient (principalResidueLabel q v) * + φ (principalResidueLabel q v) (principalAxisRestrict short v) + (z, allocatedOriginalSampleLiftMap B U basis S (fun _ _ => 0) (fun _ _ => 1) + sample (fun j => (((principalAxisRestrict (fun a => ¬short a) v) j none : ℤ) : ℝ) / S.value))) + ∂canonicalZeroSpatialLaw (X := X) s root D W L) - + ∑ r : Pos, (law.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + coefficient r.val * (allocatedShortPrincipalResidueLaw B U basis S q r.val r.property).complexMean + (fun u => ∫ y, φ r.val u y ∂realDensityMeasure volume (allocatedOriginalSampleForecastDensity (X := X) + B U basis S s root D hp hW hL hB lower width sample))‖ ≤ + 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) := by + classical + intro lower width K law Pos + let μ := canonicalZeroSpatialLaw (X := X) s root D W L + let := canonicalZeroSpatialLaw_probability (X := X) s root D hp hW hL + let F := allocatedOriginalSampleLiftMap B U basis S (fun _ _ => 0) (fun _ _ => 1) sample + let value := fun (z : (Σ _ : X, Unit ⊕ Empty) → ℝ) (r : FullInput → Option Empty → ZMod q) + (v : Original) => φ r (principalAxisRestrict short v) + (z, F (fun j => (((principalAxisRestrict (fun a => ¬short a) v) j none : ℤ) : ℝ) / S.value)) + have hint (r : FullInput → Option Empty → ZMod q) (v : Original) : + Integrable (fun z => value z r v) μ := by + have hm : Measurable (fun z => value z r v) := + (hφ r (principalAxisRestrict short v)).continuous.measurable.comp + (measurable_id.prodMk measurable_const) + exact ⟨hm.aestronglyMeasurable, + HasFiniteIntegral.of_bounded (Filter.Eventually.of_forall (fun z => hφone r _ _))⟩ + have hmean := law.integral_complexMean μ + (fun z v => coefficient (principalResidueLabel q v) * value z (principalResidueLabel q v) v) + (fun v => (hint (principalResidueLabel q v) v).const_mul _) + simp only [integral_const_mul] at hmean + rw [hmean] + have hnonneg : 0 ≤ 2 * ((2 * scalarCubeGridBoundaryConstant Empty + K * 2) * + ∑ _j : Input, (q : ℝ) / S.value + K * (1 / S.value)) := by + have hC := (scalarCubeGridBoundaryConstant_pos Empty).le + positivity + apply law.complexMean_positiveResidue_weighted_error (principalResidueLabel q) + coefficient (fun r v => ∫ z, value z r v ∂μ) _ hnonneg (fun r => hcoefficient r.val) + intro r + rw [← (law.condition (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) + r.property).integral_complexMean μ (fun z v => value z r.val v) (hint r.val)] + exact allocatedOriginalSample_conditional_forecast_comparison + B U basis hR hσ S s root D hp hW hL hB hroot sample hs hS q (NeZero.pos q) + r.val r.property hsize hsmall (φ r.val) (hφ r.val) (hφone r.val) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPhysicalIntegerRankLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPhysicalIntegerRankLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..889e19e68081816783940e4192da9afe3ad155db --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPhysicalIntegerRankLaw.lean @@ -0,0 +1,458 @@ +import Mathlib.MeasureTheory.Constructions.BorelSpace.Order +import Mathlib.MeasureTheory.Group.Arithmetic +import OAI.Combinatorics.Progressions.Linear.AllocatedShortRankWitnessWidth + +namespace OAI + +section + +namespace Erdos3 +open scoped Classical + +theorem selectedResidueDensityPMF_event_congr_of_density_ne_zero + {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (f g : (K × I → ℤ) → Prop) [DecidablePred f] [DecidablePred g] + (hfg : ∀ x, D x ≠ 0 → (f x ↔ g x)) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if f x then (1 : ℝ) else 0)) = + ∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if g x then (1 : ℝ) else 0) := by + apply tsum_congr + intro x + by_cases hx : D x = 0 + · rw [selectedResidueDensityPMF_zero_of_density_zero modulus G V hV hZ D hD0 hD x hx] + simp only [zero_mul] + · simp only [hfg x hx] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem largestTestedBadDepth_congr_on_tested {Ω : Type*} + (A : ℕ → ℕ) (bad other : ℕ → ℕ → Ω → Prop) (p : ℕ) (x : Ω) + (h : ∀ a, 0 < a → a ≤ A p → (bad p a x ↔ other p a x)) : + largestTestedBadDepth A bad p x = largestTestedBadDepth A other p x := by + unfold largestTestedBadDepth + congr 1 + apply Finset.filter_congr + intro a ha + exact h a (Finset.mem_Icc.mp ha).1 (Finset.mem_Icc.mp ha).2 + +theorem largestBadPrimeProduct_congr_on_tested {Ω : Type*} + (S : Finset ℕ) (A : ℕ → ℕ) (bad other : ℕ → ℕ → Ω → Prop) (x : Ω) + (h : ∀ p ∈ S, ∀ a, 0 < a → a ≤ A p → (bad p a x ↔ other p a x)) : + (∏ p ∈ S, p ^ largestTestedBadDepth A bad p x) = + ∏ p ∈ S, p ^ largestTestedBadDepth A other p x := by + apply Finset.prod_congr rfl + intro p hp + rw [largestTestedBadDepth_congr_on_tested A bad other p x (h p hp)] + +theorem selectedResidueDensityPMF_badProduct_event_congr + {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (S : Finset ℕ) (A : ℕ → ℕ) + (bad other : ℕ → ℕ → (K × I → ℤ) → Prop) (R : ℕ) + (heq : ∀ x, D x ≠ 0 → ∀ p ∈ S, ∀ a, 0 < a → a ≤ A p → + (bad p a x ↔ other p a x)) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if R < ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x then (1 : ℝ) else 0)) = + ∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if R < ∏ p ∈ S, p ^ largestTestedBadDepth A other p x then (1 : ℝ) else 0) := by + apply selectedResidueDensityPMF_event_congr_of_density_ne_zero + intro x hx + rw [largestBadPrimeProduct_congr_on_tested S A bad other x (heq x hx)] + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators Classical + +private theorem finite_nat_sup_measurable {Ω ι : Type*} [MeasurableSpace Ω] + (s : Finset ι) (f : ι → Ω → ℕ) (hf : ∀ i ∈ s, Measurable (f i)) : + Measurable (fun x => s.sup (fun i => f i x)) := by + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + simp only [Finset.sup_insert] + exact (hf i (Finset.mem_insert_self _ _)).sup + (ih (fun j hj => hf j (Finset.mem_insert_of_mem hj))) + +theorem largestTestedBadDepth_measurable {Ω : Type*} [MeasurableSpace Ω] + (A : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) (p : ℕ) + (hbad : ∀ a ∈ Finset.Icc 1 (A p), MeasurableSet {x | bad p a x}) : + Measurable (largestTestedBadDepth A bad p) := by + unfold largestTestedBadDepth + have h := finite_nat_sup_measurable (Finset.Icc 1 (A p)) + (fun a x => if bad p a x then a else 0) + (fun a ha => Measurable.ite (hbad a ha) measurable_const measurable_const) + convert h using 1 + funext x + rw [Finset.sup_ite] + simp only [show (0 : ℕ) = ⊥ from rfl, Finset.sup_bot, sup_bot_eq] + rfl + +theorem largestBadPrimeProduct_measurable {Ω : Type*} [MeasurableSpace Ω] + (P : Finset ℕ) (A : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) + (hbad : ∀ p ∈ P, ∀ a ∈ Finset.Icc 1 (A p), MeasurableSet {x | bad p a x}) : + Measurable (fun x => ∏ p ∈ P, p ^ largestTestedBadDepth A bad p x) := by + apply Finset.measurable_prod + intro p hp + exact (measurable_of_countable (fun a : ℕ => p ^ a)).comp + (largestTestedBadDepth_measurable A bad p (hbad p hp)) + +theorem largestBadPrimeProduct_tail_measurableSet {Ω : Type*} [MeasurableSpace Ω] + (P : Finset ℕ) (A : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) + (hbad : ∀ p ∈ P, ∀ a ∈ Finset.Icc 1 (A p), MeasurableSet {x | bad p a x}) + (cutoff : ℕ) : + MeasurableSet {x | cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A bad p x} := + measurableSet_lt measurable_const (largestBadPrimeProduct_measurable P A bad hbad) + +theorem density_mul_badPrimeProduct_indicator_measurable {Ω : Type*} [MeasurableSpace Ω] + (D : Ω → ℝ) (hD : Measurable D) + (P : Finset ℕ) (A : ℕ → ℕ) (bad test : ℕ → ℕ → Ω → Prop) + (htest : ∀ p ∈ P, ∀ a ∈ Finset.Icc 1 (A p), MeasurableSet {x | test p a x}) + (heq : ∀ x, D x ≠ 0 → ∀ p ∈ P, ∀ a, 0 < a → a ≤ A p → + (bad p a x ↔ test p a x)) (cutoff : ℕ) : + Measurable (fun x => D x * + (if cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A bad p x then (1 : ℝ) else 0)) := by + have he (x : Ω) : D x * + (if cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A bad p x then (1 : ℝ) else 0) = + D x * (if cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A test p x then (1 : ℝ) else 0) := by + by_cases hx : D x = 0 + · simp only [hx, zero_mul] + · rw [largestBadPrimeProduct_congr_on_tested P A bad test x (heq x hx)] + simp_rw [he] + exact hD.mul (Measurable.ite (largestBadPrimeProduct_tail_measurableSet P A test htest cutoff) + measurable_const measurable_const) + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped Classical + +variable {K : Type*} {m : ℕ} {J I E : Fin m → Type*} +variable [∀ j, Fintype (J j)] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] {n : Fin m → ℕ} +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + +theorem exists_coefficientDeck_integer_lift (c : CoefficientArray (K := K) U) + (x : CoefficientSamplerArrays (K := K) I n) + (hx : canonicalCoefficientSample U b hb o x = + QuotientAddGroup.mk' (coefficientIntegerLattice U) c) : + ∃ w : ∀ j : Fin m, BoundedCoefficientExponent K (j.val + 1) → E j → ℤ, + ∀ (q : ℕ) (hq : 0 < q), + canonicalCoefficientDeckSample U bW b hb o q hq x + (fun j e => integerResidueMap (E j) q (w j e)) = + QuotientAddGroup.mk' (coefficientIntegerLattice U) ((q : ℝ)⁻¹ • c) := by + have hp (j : Fin m) (e : BoundedCoefficientExponent K (j.val + 1)) : + QuotientAddGroup.mk' _ ((euclideanSubspaceArrayEquiv (U j)).symm (fun _ => c ⟨j, e⟩)) = + normalizedLatticeQuotient (euclideanSubspace (U j)) (b j) (hb j) + (orthonormalMixedChart (o j) (mixedArrayRegroup _ _ _ (x j) e)) := by + have h := congrArg (fun y => euclideanCoefficientEquiv U y j e) hx + simpa only [canonicalCoefficientSample, AddEquiv.apply_symm_apply, + euclideanCoefficientEquiv_mk, mixedArrayQuotient] using h.symm + choose w hw using fun (j : Fin m) (e : BoundedCoefficientExponent K (j.val + 1)) => + exists_normalized_representative_offset (euclideanSubspace (U j)) (bW j) (b j) (hb j) + ((euclideanSubspaceArrayEquiv (U j)).symm (fun _ => c ⟨j, e⟩)) + (orthonormalMixedChart (o j) (mixedArrayRegroup _ _ _ (x j) e)) (hp j e) + refine ⟨w, ?_⟩ + intro q hq + apply (euclideanCoefficientEquiv U).injective + funext j e + rw [canonicalCoefficientDeckSample_coordinate, normalizedCoverLift_add_deck, hw, + euclideanCoefficientEquiv_mk] + congr 1 + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule + +variable {K : Type*} {m : ℕ} {J I E : Fin m → Type*} +variable [∀ j, Fintype (J j)] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] {n : Fin m → ℕ} +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + +theorem exists_coefficientDeck_integer_event_read + (c : CoefficientArray (K := K) U) (x : CoefficientSamplerArrays (K := K) I n) + (hx : canonicalCoefficientSample U b hb o x = QuotientAddGroup.mk' (coefficientIntegerLattice U) c) + (hsmall : ∀ a, |coefficientSamplerAmbientPoint U b o x a| < 1/2) : + ∃ w : ∀ j, BoundedCoefficientExponent K (j.val + 1) → E j → ℤ, + ∀ (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ event : CoefficientChartResidues K n E q → Prop, + coefficientDeckChartEvent U bW b hb o q event + (QuotientAddGroup.mk' (coefficientIntegerLattice U) ((q : ℝ)⁻¹ • c)) ↔ + event (coefficientSamplerChartResidues q x + (fun j e => integerResidueMap (E j) q (w j e))) := by + obtain ⟨w, hw⟩ := exists_coefficientDeck_integer_lift U bW b hb o c x hx + refine ⟨w, ?_⟩ + intro q hq + let : NeZero q := ⟨hq.ne'⟩ + intro event + rw [← hw q (NeZero.pos q)] + exact coefficientDeckChartEvent_sample_iff U bW b hb o q event x hsmall _ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped Classical + +variable {m : ℕ} {G X : Type*} {J I E : Fin m → Type*} {n : Fin m → ℕ} +variable {B : LayerSamplerAxis I n → Type*} +variable [∀ j, Fintype (J j)] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + +theorem exists_allocatedCoefficient_integer_event_read + (c : CoefficientArray (K := LayerSamplerVariables G I n B) U) + (x : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (hx : canonicalCoefficientSample U b hb o x = QuotientAddGroup.mk' (coefficientIntegerLattice U) c) + (hsmall : ∀ a, |coefficientSamplerAmbientPoint U b o x a| < 1/2) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) : + ∃ f : AllocatedActualCoefficientIndex G X I E n B → ℤ, + allocatedReadNoise f = noise ∧ + (∀ (j : Fin m) (i : Fin (n j)) + (e : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)), + allocatedReadProjection f ⟨j, Sum.inr i⟩ e = (x j).2 i e) ∧ + ∀ (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ event : CoefficientChartResidues (LayerSamplerVariables G I n B) n E q → Prop, + coefficientDeckChartEvent U bW b hb o q event + (QuotientAddGroup.mk' (coefficientIntegerLattice U) ((q : ℝ)⁻¹ • c)) ↔ + event (allocatedReadCoefficientChartResidues (fun i => (f i : ZMod q))) := by + obtain ⟨w, hw⟩ := exists_coefficientDeck_integer_event_read U bW b hb o c x hx hsmall + let f : AllocatedActualCoefficientIndex G X I E n B → ℤ := + allocatedMixedFullArray (Sum.elim noise (fun ⟨j,e,i⟩ => (x j).2 i e)) + (fun ⟨j,e,i⟩ => w j e i) (fun _ => 0) + have hi (j : Fin m) (i : Fin (n j)) + (e : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : + allocatedReadProjection f ⟨j, Sum.inr i⟩ e = (x j).2 i e := rfl + refine ⟨f, rfl, hi, ?_⟩ + intro q hq + let : NeZero q := ⟨hq.ne'⟩ + intro event + rw [allocatedReadCoefficientChartResidues_sampler q f x hi] + exact hw q hq event + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +theorem exists_allocatedPhysical_integer_coefficient_read : + ∃ read : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + AllocatedActualCoefficientIndex G X I E n B → ℤ, + ∀ z, allocatedReadNoise (read z) = z ∧ + (allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k,x) : ℝ))) ≠ 0 → + ∀ (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ event : CoefficientChartResidues (LayerSamplerVariables G I n B) n E q → Prop, + coefficientDeckChartEvent U bW b hb o q event + (affineCoefficientCoverSample U poly hm q (fun k x => (z (k,x) : ℝ))) ↔ + event (allocatedReadCoefficientChartResidues (fun i => (read z i : ZMod q)))) := by + have hex (z : Option (LayerSamplerVariables G I n B) × X → ℤ) : + ∃ f : AllocatedActualCoefficientIndex G X I E n B → ℤ, + allocatedReadNoise f = z ∧ + (allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k,x) : ℝ))) ≠ 0 → + ∀ (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ event : CoefficientChartResidues (LayerSamplerVariables G I n B) n E q → Prop, + coefficientDeckChartEvent U bW b hb o q event + (affineCoefficientCoverSample U poly hm q (fun k x => (z (k,x) : ℝ))) ↔ + event (allocatedReadCoefficientChartResidues (fun i => (f i : ZMod q)))) := by + by_cases hz : allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k,x) : ℝ))) = 0 + · refine ⟨allocatedMixedFullArray (Sum.elim z (fun _ => 0)) (fun _ => 0) (fun _ => 0), rfl, ?_⟩ + intro h + exact (h hz).elim + · obtain ⟨x, hx, _⟩ := canonicalCoefficientDensity_recover_unique U b hb o + (allocatedLayerCenters B U b S) (allocatedLayerWidths B U b S) + (allocatedLayerIntegerPMFs B U b hR hσ S) hz + have hsmall : ∀ a, |coefficientSamplerAmbientPoint U b o x a| < 1/2 := by + intro a + exact (hx.2 a.1.1).1 a.1.2 a.2 + obtain ⟨f, hfnoise, _hfint, hfevent⟩ := exists_allocatedCoefficient_integer_event_read + U bW b hb o (affineSampleCoefficientArray U poly hm (fun k x => (z (k,x) : ℝ))) + x hx.1 hsmall z + refine ⟨f, hfnoise, ?_⟩ + intro _ q hq + exact hfevent q hq + choose read hread using hex + exact ⟨read, hread⟩ + +variable [Fintype X] + +theorem exists_allocatedPhysical_integer_rank_read + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) + (C : ℝ) : + ∃ read : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + AllocatedActualCoefficientIndex G X I E n B → ℤ, + ∀ z, allocatedReadNoise (read z) = z ∧ + (allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k,x) : ℝ))) ≠ 0 → + ∀ (P : Finset ℕ) (hP : ∀ p : P, NeZero p.val), letI := hP + ∀ (A : ℕ → ℕ) (M : ℕ) (hM : 0 < M), letI : NeZero M := ⟨hM.ne'⟩ + ∀ hdiv : ∀ p : P, p.val ^ A p.val ∣ M, + coefficientDeckChartEvent U bW b hb o M + (allocatedChartResiduePrimePowerWitness inactive C P A M hdiv + (fun v => (z v : ZMod M))) + (affineCoefficientCoverSample U poly hm M (fun k x => (z (k,x) : ℝ))) ↔ + ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C + (p.val ^ A p.val) (read z)) := by + obtain ⟨read, hread⟩ := exists_allocatedPhysical_integer_coefficient_read + B U bW b hb o S hR hσ poly hm + refine ⟨read, ?_⟩ + intro z + refine ⟨(hread z).1, ?_⟩ + intro hz P hP + let := hP + intro A M hM + let : NeZero M := ⟨hM.ne'⟩ + intro hdiv + have he := (hread z).2 hz M hM + (allocatedChartResiduePrimePowerWitness inactive C P A M hdiv + (fun v => (z v : ZMod M))) + apply he.trans + have hn : allocatedReadNoise (fun i => (read z i : ZMod M)) = + fun v => (z v : ZMod M) := by + funext v + change ((allocatedReadNoise (read z) v : ℤ) : ZMod M) = _ + rw [(hread z).1] + rw [← hn] + exact allocatedChartResiduePrimePowerWitness_iff_actual + inactive spatial kernel block C P A M hdiv (read z) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +local notation "Dphysical" => (fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => + allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k,x) : ℝ)))) + +theorem exists_allocatedPhysical_integer_rank_law + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) + (C : ℝ) (stride : X → ℕ) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (width : Option (LayerSamplerVariables G I n B) × X → ℝ) (hwidth : ∀ z, 0 < width z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells width z) + (hD0 : ∀ z, 0 ≤ Dphysical z) + (hDpos : 0 < selectedResidueDensityMass stride cells width Dphysical) : + ∃ read : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + AllocatedActualCoefficientIndex G X I E n B → ℤ, + (∀ z, allocatedReadNoise (read z) = z) ∧ + ∀ (P : Finset ℕ) (hP : ∀ p : P, NeZero p.val), letI := hP + ∀ (A : ℕ → ℕ) (M : ℕ) (hM : 0 < M), letI : NeZero M := ⟨hM.ne'⟩ + ∀ hdiv : ∀ p : P, p.val ^ A p.val ∣ M, + (∑' z, (selectedResidueDensityPMF stride cells width hwidth hZ Dphysical hD0 hDpos z).toReal * + (if coefficientDeckChartEvent U bW b hb o M + (allocatedChartResiduePrimePowerWitness inactive C P A M hdiv + (fun v => (z v : ZMod M))) + (affineCoefficientCoverSample U poly hm M (fun k x => (z (k,x) : ℝ))) then (1 : ℝ) else 0)) = + ∑' z, (selectedResidueDensityPMF stride cells width hwidth hZ Dphysical hD0 hDpos z).toReal * + (if ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C + (p.val ^ A p.val) (read z) then (1 : ℝ) else 0) := by + obtain ⟨read, hread⟩ := exists_allocatedPhysical_integer_rank_read + B U bW b hb o S hR hσ poly hm inactive spatial kernel block C + refine ⟨read, fun z => (hread z).1, ?_⟩ + intro P hP + let := hP + intro A M hM + let : NeZero M := ⟨hM.ne'⟩ + intro hdiv + apply selectedResidueDensityPMF_event_congr_of_density_ne_zero + intro z hz + exact (hread z).2 hz P hP A M hM hdiv + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPhysicalResidueAverage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPhysicalResidueAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..c862c87068e9aebfcd984079b280e537e8020e35 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPhysicalResidueAverage.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedPhysicalPointMixture +import OAI.Combinatorics.Progressions.Probability.WeightedSupportedComplexMixture + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] + +variable (q : ℕ) [NeZero q] (hq : 0 < q) +variable (hsize : (Fintype.card α + 1) * q ≤ S.value) +variable (j : Fin m) (i : Fin (n j)) +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +variable (rows : Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) + +local notation "tuples" => principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) +local notation "axisLaw" => fun y => integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i) +local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i)) +local notation "torus" => blockTorusFactor (Fintype.card α) (j.val + 1) + (Fintype.card (B (Sigma.mk j (Sum.inr i)))) (4 * gamma) + +theorem allocatedPhysicalResiduePoint_test_error + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + {ε : ℝ} {M : ℕ} [NeZero M] (hM : M = torus * basisAxisScale (basis j) i) + (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (hε : 0 < ε) (hε1 : ε ≤ 1) + (test : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) → ℂ) + (htest : ∀ r, ‖test r‖ ≤ 1) (z : rows → ℤ) : + ‖(tuples).complexMean (fun y => test (principalResidueLabel q y) * + (((basisAxisScale (basis j) i : ℝ) ^ rows.card * ((axisLaw y) z).toReal : ℝ) : ℂ)) - + ((tuples).fiberLaw (principalResidueLabel q)).complexMean (fun r => test r * + allocatedSupportedPhysicalPointApproximation B U basis hR hσ S q r j i hactive hq hsize + P ε M rows z)‖ ≤ ε := by + apply (tuples).complexMean_supported_fiber_mul_error (principalResidueLabel q) + _ _ test hε.le htest + intro r hr + have hc := ((tuples).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hr).toPMF_bind_scaled_complexMean + (axisLaw) ((basisAxisScale (basis j) i : ℝ) ^ rows.card) z + have he := allocatedSupportedPhysicalPointApproximation_error B U basis hR hσ S q r hr j i + hactive hq hsize hgrid A hA P hcP hsP hM rows hrows hB hε hε1 x z + exact (congrArg (fun w : ℂ => ‖w - + allocatedSupportedPhysicalPointApproximation B U basis hR hσ S q r j i hactive hq hsize + P ε M rows z‖) hc).trans_le he + +theorem allocatedPhysicalResiduePoint_mass_error + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + {ε : ℝ} {M : ℕ} [NeZero M] (hM : M = torus * basisAxisScale (basis j) i) + (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (hε : 0 < ε) (hε1 : ε ≤ 1) (z : rows → ℤ) : + ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((tuples).toPMF.bind (axisLaw)) z).toReal : ℝ) : ℂ) - + ((tuples).fiberLaw (principalResidueLabel q)).complexMean (fun r => + allocatedSupportedPhysicalPointApproximation B U basis hR hσ S q r j i hactive hq hsize + P ε M rows z)‖ ≤ ε := by + have h := allocatedPhysicalResiduePoint_test_error B U basis hR hσ S q hq hsize j i hactive rows x + hgrid A hA P hcP hsP hM hrows hB hε hε1 (fun _ => 1) (fun _ => by simp) z + simp only [one_mul] at h + rw [(tuples).toPMF_bind_scaled_complexMean] at h + exact h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPointwiseResidueCover.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPointwiseResidueCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb0813bf085789aae14c3de5bf13eef9dd8d474d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedPointwiseResidueCover.lean @@ -0,0 +1,210 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedIdealPhysicalCover +import OAI.Combinatorics.Progressions.Lattices.AllocatedResidueSitePrimitiveAverage + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] activeAmbientAxisDecidableEq fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (q : ℕ) [NeZero q] +variable (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "siteH" => (fun a : activeAxes => allocatedNaturalSiteRadius (G := G) B + (Sigma.fst (ig (Subtype.val a))) (Sigma.snd (ig (Subtype.val a))) + (rowSets (Sigma.fst (ig (Subtype.val a)))) + 1 / 4) +local notation "law" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + +noncomputable def allocatedResidueCoverCoefficientMass : ℝ := + ((law).fiberLaw (principalResidueLabel q)).mean (fun r => + if hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) then + ∑ k, ‖coverSiteCoefficient (W ⟨r, hr⟩).expansion k‖ + else 0) + +theorem allocatedResidueCoverCoefficientMass_le (C : ℝ) + (h : ∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ C) : + allocatedResidueCoverCoefficientMass B U b S q W ≤ C := by + let weights := (law).fiberLaw (principalResidueLabel q) + apply (weights.mean_mono_on_support (g := fun _ => C) ?_).trans_eq (weights.mean_const C) + intro r hr + have hp : 0 < weights.weight r := lt_of_le_of_ne (weights.nonneg r) (Ne.symm hr) + change 0 < ((law).fiberLaw (principalResidueLabel q)).weight r at hp + rw [FiniteProbabilityWeights.fiberLaw_weight_eq_mass] at hp + simpa only [dite_eq_left hp] using h ⟨r, hp⟩ + +noncomputable def allocatedSupportedIdealCoverValue + (g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ)) + (δ : ℝ≥0) (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ) + (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) : ℂ := + if hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) then + let rr : AllocatedPositiveResidue (dim := dim) B U b S q := ⟨r, hr⟩ + allocatedGlobalWindowPrefactor B U b hR hσ S rowSets d x q + (W rr).representative (W rr).positive hb o bW + (allocatedPhysicalLongIdeal B U b hR S rowSets δ) + (physicalCubeRowSample U d rows p hm v) * + ∑ k, coverSiteCoefficient (W rr).expansion k * ∏ s, + g rr k s (fun a => (((eval (fun z => (physicalCubeVertexValue v s z : ℝ)) + (p a.1) a.2) / commonSitePeriod (W rr).expansion k : ℝ) : UnitAddCircle)) + else 0 + +theorem exists_allocated_ideal_residue_cover + {Nt V Cc : activeAxes → ℝ} {L : ℝ≥0} + (he : ∀ r a, ((W r).expansion a).Bounds (Nt a) (V a) (Cc a) L ((siteH) a)) + (Q : ℝ≥0) (hQ : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Q) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) (hσ1 : ∀ j, σ j ≤ 1) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets C j) : + ∃ g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ r k s, LipschitzWith (max (((Fintype.card activeAxes * L) * Q) * + (K * ∑ j, Cforward j * Fintype.card (J j)) * commonSitePeriod (W r).expansion k) + (4 * commonSitePeriod (W r).expansion k)) (g r k s) ∧ ∀ v, ‖g r k s v‖ ≤ 1) ∧ + (∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + allocatedResidueCoverCoefficientMass B U b S q W ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a ∧ + ∀ (δ : ℝ≥0), 0 < δ → δ ≤ 1 → + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ), + ((law).fiberLaw (principalResidueLabel q)).complexMean (fun r => + allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d + (allocatedPhysicalLongIdeal B U b hR S rowSets δ) W r + (physicalCubeRowSample U d rows p hm v)) = + ((law).fiberLaw (principalResidueLabel q)).complexMean + (allocatedSupportedIdealCoverValue B U b hR hσ S q W hb o bW d g δ x p hm v) := by + have hlocal (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_ideal_physical_cover B U b hR hσ S d q + (W r).representative (W r).positive hb o bW (W r).expansion (he r) + Q hQ Cforward hforward K hK hσ1 C hC hchart hsmall + choose g hg hc hv using hlocal + refine ⟨g, hg, hc, allocatedResidueCoverCoefficientMass_le B U b S q W _ hc, ?_⟩ + intro δ hδ hδ1 x X p hp hm v + apply congrArg ((law).fiberLaw (principalResidueLabel q)).complexMean + funext r + by_cases hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) + · simp only [allocatedSupportedResidueSiteProfile, allocatedSupportedIdealCoverValue, dite_eq_left hr] + exact hv ⟨r, hr⟩ δ hδ hδ1 x p hp hm v + · simp only [allocatedSupportedResidueSiteProfile, allocatedSupportedIdealCoverValue, dite_eq_right hr] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] activeAmbientAxisDecidableEq fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (q : ℕ) [NeZero q] +variable (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "siteH" => (fun a : activeAxes => allocatedNaturalSiteRadius (G := G) B + (Sigma.fst (ig (Subtype.val a))) (Sigma.snd (ig (Subtype.val a))) + (rowSets (Sigma.fst (ig (Subtype.val a)))) + 1 / 4) +local notation "law" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + +theorem exists_allocated_ideal_residue_cover_pointwise + {Nt V Cc : activeAxes → ℝ} {L : ℝ≥0} + (he : ∀ r a, ((W r).expansion a).Bounds (Nt a) (V a) (Cc a) L ((siteH) a)) + (Q : ℝ≥0) (hQ : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Q) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) (hσ1 : ∀ j, σ j ≤ 1) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets C j) : + ∃ g : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + (∀ a, ((W r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ r k s, LipschitzWith (max (((Fintype.card activeAxes * L) * Q) * + (K * ∑ j, Cforward j * Fintype.card (J j)) * commonSitePeriod (W r).expansion k) + (4 * commonSitePeriod (W r).expansion k)) (g r k s) ∧ ∀ v, ‖g r k s v‖ ≤ 1) ∧ + (∀ r, (∑ k, ‖coverSiteCoefficient (W r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + allocatedResidueCoverCoefficientMass B U b S q W ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a ∧ + ∀ (δ : ℝ≥0), 0 < δ → δ ≤ 1 → + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j a, coefficients (p j) a ∈ U j) (v : X → (Unit ⊕ Fin dim) → ℤ) + (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q), + allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d + (allocatedPhysicalLongIdeal B U b hR S rowSets δ) W r + (physicalCubeRowSample U d rows p hm v) = + allocatedSupportedIdealCoverValue B U b hR hσ S q W hb o bW d g δ x p hm v r := by + have hlocal (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_ideal_physical_cover B U b hR hσ S d q + (W r).representative (W r).positive hb o bW (W r).expansion (he r) + Q hQ Cforward hforward K hK hσ1 C hC hchart hsmall + choose g hg hc hv using hlocal + refine ⟨g, hg, hc, allocatedResidueCoverCoefficientMass_le B U b S q W _ hc, ?_⟩ + intro δ hδ hδ1 x X p hp hm v r + by_cases hr : 0 < (law).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) + · simp only [allocatedSupportedResidueSiteProfile, allocatedSupportedIdealCoverValue, dite_eq_left hr] + exact hv ⟨r, hr⟩ δ hδ hδ1 x p hp hm v + · simp only [allocatedSupportedResidueSiteProfile, allocatedSupportedIdealCoverValue, dite_eq_right hr] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedProductBoxAffine.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedProductBoxAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ab4787f13506628e6390d6aa7cd12bf3a7419b5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedProductBoxAffine.lean @@ -0,0 +1,493 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedOriginalBoxInputs +import OAI.Combinatorics.Progressions.Linear.AllocatedProductNormalizedKernel + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affineScalarCubeWindowWeights_support {I : Type*} [Fintype I] [DecidableEq I] + (L K M D : ℕ) (c : ℤ) (hL : 0 < L) (hKL : K ≤ L) (hDK : L ≤ D * K) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ K) (x : IntegerScalarCubeBox I L) + (hx : (affineScalarCubeWindowWeights I L K M D c hL hKL hDK m r hm hmM hsize).weight x ≠ 0) : + (integerScalarCubeWeights I L hL).weight x ≠ 0 := by + intro hzero + have hbound := affineScalarCubeWindowWeights_weight_le I L K M D c hL hKL hDK m r hm hmM hsize x + rw [hzero, mul_zero] at hbound + exact hx (le_antisymm hbound + ((affineScalarCubeWindowWeights I L K M D c hL hKL hDK m r hm hmM hsize).nonneg x)) + +theorem affineScalarCubeWindowWeights_pi_support {G I : Type*} + [Fintype G] [DecidableEq G] [Fintype I] [DecidableEq I] + (L M D : ℕ) (hL : 0 < L) (window : G → ℕ) (shift : G → ℤ) + (hwindow : ∀ g, window g ≤ L) (hDwindow : ∀ g, L ≤ D * window g) + (moduli : G → Option I → ℕ) (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M) + (hsize : ∀ g, (Fintype.card I + 1) * M ≤ window g) + (x : G → IntegerScalarCubeBox I L) + (hx : (FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights I L (window g) M D (shift g) hL + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) (hsize g))).weight x ≠ 0) : + ∀ g, (integerScalarCubeWeights I L hL).weight (x g) ≠ 0 := by + intro g + apply affineScalarCubeWindowWeights_support L (window g) M D (shift g) hL + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) (hsize g) (x g) + change (∏ g, (affineScalarCubeWindowWeights I L (window g) M D (shift g) hL + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) (hsize g)).weight (x g)) ≠ 0 at hx + exact Finset.prod_ne_zero_iff.mp hx g (Finset.mem_univ g) + +namespace VectorPolynomial + +open Module Submodule BooleanCubeKernel + +variable {m dim : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable (X : Type*) [Fintype X] [DecidableEq X] (stride : X → ℕ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (N : X → ℕ) (hN : ∀ a, 0 < N a) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (hξ1 : ξ ≤ 1) (hτ1 : τ ≤ 1 / 2) (hsizeN : ∀ a, 4 ≤ τ * (N a : ℝ)) +variable (hbudget : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (test : Finset (Fin dim) → (X → ℝ) → ℂ) (Z : ℝ) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + +include hξ1 hτ1 hsizeN hbudget in +theorem allocatedOriginalTupleSource_affine_box_extension + (M Dwin : ℕ) (window : G → ℕ) (shift : G → ℤ) + (hwindow : ∀ g, window g ≤ S.value) (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (moduli : G → Option (Fin dim) → ℕ) (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M) + (hsize : ∀ g, (Fintype.card (Fin dim) + 1) * M ≤ window g) + (bases : Finset (X → ℤ)) + (hbases : ∀ base ∈ bases, base ∈ trimmedIntegerBox N (spatialTrimMargin τ N)) : + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) (hsize g)) + kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X stride hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest (fun s => integerBoxTestExtension N (test s))) Z poly hmem) = + kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X stride hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) := by + intro kernelLaw + exact allocatedOriginalTupleSource_box_extension_kernel_mean B U b hR hσ S X stride hb o + N hN hW hτ hξ hξ1 hτ1 hsizeN hbudget cells hmass test Z poly hmem kernelLaw + (fun x hx => affineScalarCubeWindowWeights_pi_support S.value M Dwin S.positive window shift + hwindow hDwindow moduli residues hmoduli hmoduliM hsize x hx) bases hbases + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductNormalizedAffineData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 1)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp) (hlarge : Mk ≤ S.value), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((E + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp pAccuracy w v (E + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +theorem allocatedProductNormalizedAffineData_of_kernel + {Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (hkernel : AllocatedProductNormalizedKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : + AllocatedProductNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses + M Dwin hM hDwin η hη := by + unfold AllocatedProductNormalizedAffineData + intro w v Pfinal Mk hMk selection hqDim hcard _ hMkPsp hlarge Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hkernel⟩ := + hkernel hMk selection hqDim hMkPsp + let _ : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let _ : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z H law + coverValue wholeReference reconstruct weight cover + obtain ⟨hmass, hZ, hcomparison⟩ := hkernel block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN hsizeN + poly hpoly hmem hrank hRank cells hcells test htest bases hbases + refine ⟨hmass, hZ, ?_⟩ + intro window hwindow hDwindow shift moduli residues hmoduli hmoduliM kernelLaw + have hbad := affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hcard) selection hM hDwin hη S.positive hlarge + window hwindow hDwindow shift moduli residues hmoduli hmoduliM + exact hcomparison kernelLaw hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductBoxAffineData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 1)) + let Mk := scalarKernelCutoff (Fin dim) G M Dwin η + let hMk := (scalarKernelCutoff_bounds (Fin dim) G hM hDwin hη).1 + ∀ (selection : Fin dim ↪ G) (_hqDim : dim ≤ m + 1) + (_hcard : dim * (dim + 2) ≤ Fintype.card G) [Nonempty (Fin dim)] + (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp) (hlarge : Mk ≤ S.value), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((E + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp pAccuracy w v (E + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (_hτ1 : τ ≤ 1 / 2) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (_hsizeBox : ∀ t, 4 ≤ τ * (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty) + (_hbaseBox : ∀ base ∈ bases, base ∈ trimmedIntegerBox N (spatialTrimMargin τ N)), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest (fun site => integerBoxTestExtension N (test site))) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) + (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g))) + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +theorem allocatedProductBoxAffineData_of_normalized + {Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) (η : ℝ) (hη : 0 < η) + (haffine : AllocatedProductNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses + M Dwin hM hDwin η hη) : + AllocatedProductBoxAffineData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses + M Dwin hM hDwin η hη := by + unfold AllocatedProductBoxAffineData + intro w v Pfinal Mk hMk selection hqDim hcard _ hMkPsp hlarge Kernel Good GoodKernel + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, haffine⟩ := + haffine selection hqDim hcard hMkPsp hlarge + let _ : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let _ : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP hτ1 N hN hsizeN hsizeBox poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases hbaseBox V₀ Z H law + coverValue wholeReference reconstruct weight cover + have htestExt : ∀ site z, ‖integerBoxTestExtension N (test site) z‖ ≤ 1 := + fun site z => integerBoxTestExtension_norm_le_one N (test site) (htest site) z + obtain ⟨hmass, hZ, hcomparison⟩ := haffine block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN hsizeN + poly hpoly hmem hrank hRank cells hcells (fun site => integerBoxTestExtension N (test site)) htestExt bases hbases + refine ⟨hmass, hZ, ?_⟩ + intro window hwindow hDwindow shift moduli residues hmoduli hmoduliM kernelLaw + have h := hcomparison window hwindow hDwindow shift moduli residues hmoduli hmoduliM + have hξ1 : ξ ≤ 1 := by + dsimp only [ξ, normalizedTupleNarrowWidth, twoTermErrorWidth] + exact min_le_left _ _ + have hext := allocatedOriginalTupleSource_affine_box_extension B U b hR hσ S X q hb o + N hN hW hτ hξ hξ1 hτ1 hsizeBox (le_refl W) cells hmass test Z poly hmem + M Dwin window shift hwindow hDwindow moduli residues hmoduli hmoduliM + (fun g => scalarKernelCutoff_window_size (Fin dim) G hM hDwin hη hlarge (hDwindow g)) bases hbaseBox + change ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest (fun site => integerBoxTestExtension N (test site))) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η at h + dsimp only at hext + rw [hext] at h + exact h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedProductGeometricAffine.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedProductGeometricAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..86cbdb5a54f0e54ee0211b2f0e02f3c684255bdd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedProductGeometricAffine.lean @@ -0,0 +1,477 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedActualCoarseBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedUniformCommonCover +import OAI.Combinatorics.Progressions.Lattices.AllocatedCommonPrimitiveAffine + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped ContDiff BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +section Data + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "hLayer" => layerSamplerDegree I n + +def AllocatedUniformAccurateAffineData (p P E : ℝ) (hP : 0 ≤ P) (A T : ℝ≥0) + (A₀ T₀ Kproj Kideal Ksite : ℕ) : Prop := + let D := allocatedComparisonDimension m p + let target := profileReferenceErrorLog P ((E + 1) + 1 + 4) + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * P + let gainLog := allocatedProfileGainLog m D P w + let ε := physicalIdealErrorShare target gainLog + let e := physicalIdealSmoothingLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) hLayer A T target gainLog + let eTail := physicalIdealTailLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) G (G × Option (Fin dim)) hLayer A T m target gainLog + let t := booleanMassPerturbationScale (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) + ((G × Option (Fin dim)) ⊕ (Σ a, SamplerCoefficientSlot G B hLayer a)) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T m 1 (ε / 2) + 0 ≤ e ∧ 0 ≤ eTail ∧ 0 < t ∧ t ≤ 1 ∧ t⁻¹ ≤ Real.exp eTail ∧ + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ) = booleanRegularizationRadius (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T (ε / 2) ∧ (δ : ℝ)⁻¹ ≤ Real.exp e ∧ + AllocatedCommonAccurateAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A₀ T₀ Kproj Kideal Ksite + +theorem allocatedUniformCommonCover_accurate_affine + {p P E : ℝ} (hp : 0 ≤ p) (hP : 0 ≤ P) (hE : 0 ≤ E) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + {A T : ℝ≥0} {A₀ T₀ Kproj Kideal Ksite : ℕ} + (hcover : AllocatedUniformCommonCoverData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P (E + 1) hP A T A₀ T₀ Kproj Kideal Ksite) : + AllocatedUniformAccurateAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T A₀ T₀ Kproj Kideal Ksite := by + unfold AllocatedUniformAccurateAffineData + intro D target w gainLog ε e eTail t + obtain ⟨he, heTail, ht, ht1, hti, δ, hδ, hδ1, hδeq, hδe, hraw, hgenuine⟩ := hcover + refine ⟨he, heTail, ht, ht1, hti, δ, hδ, hδ1, hδeq, hδe, ?_⟩ + exact allocatedCommonGenuineKernelAt_accurate_affine B hp hP hE he hvars + (allocatedCommonGenuineCoverAt_kernel B hP hgenuine) + +end Data + +theorem exists_uniform_accurate_affine : + ∃ A : ℝ≥0, 1 ≤ A ∧ ∀ m dim : ℕ, ∃ A₀ T₀ Kproj Kideal Ksite : ℕ, + 2 ≤ A₀ ∧ 2 ≤ T₀ ∧ 2 ≤ Kproj ∧ 2 ≤ Kideal ∧ 2 ≤ Ksite ∧ + ∀ {G : Type uG} [Fintype G] [DecidableEq G] + {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + {p P E : ℝ}, 0 ≤ p → ∀ hP : 0 ≤ P, 0 ≤ E → + dim ≤ m + 1 → ((m + 2 : ℕ) : ℝ) ≤ P → p ≤ P → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p → + (∀ j, (Fintype.card (I j) : ℝ) ≤ p) → (∀ j, (n j : ℝ) ≤ p) → + (∀ j i, siteSpectrumBlockCount m ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) → + AllocatedUniformAccurateAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A scalarSourceTransitionBound A₀ T₀ Kproj Kideal Ksite := by + obtain ⟨A, hA, hfixed⟩ := exists_uniform_common_cover.{uG,uI,uB,uJ,uQ,uX} + refine ⟨A, hA, ?_⟩ + intro m dim + obtain ⟨A₀, T₀, Kproj, Kideal, Ksite, hA₀, hT₀, hKproj, hKideal, hKsite, hfixed⟩ := hfixed m dim + refine ⟨A₀, T₀, Kproj, Kideal, Ksite, hA₀, hT₀, hKproj, hKideal, hKsite, ?_⟩ + intro G _ _ I _ n B _ p P E hp hP hE hdim hmP hpP hvars hI hn hBlocks + exact allocatedUniformCommonCover_accurate_affine B hp hP hE hvars + (hfixed B hp hP (show 0 ≤ E + 1 by linarith) hdim hmP hpP hvars hI hn hBlocks) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped ContDiff BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +section Data + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "hLayer" => layerSamplerDegree I n + +def AllocatedUniformNormalizedAffineData (p P E : ℝ) (hP : 0 ≤ P) (A T : ℝ≥0) + (A₀ T₀ Kproj Kideal Ksite : ℕ) : Prop := + let D := allocatedComparisonDimension m p + let target := profileReferenceErrorLog P ((E + 1) + 1 + 4) + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * P + let gainLog := allocatedProfileGainLog m D P w + let ε := physicalIdealErrorShare target gainLog + let e := physicalIdealSmoothingLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) hLayer A T target gainLog + let eTail := physicalIdealTailLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) G (G × Option (Fin dim)) hLayer A T m target gainLog + let t := booleanMassPerturbationScale (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) + ((G × Option (Fin dim)) ⊕ (Σ a, SamplerCoefficientSlot G B hLayer a)) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T m 1 (ε / 2) + 0 ≤ e ∧ 0 ≤ eTail ∧ 0 < t ∧ t ≤ 1 ∧ t⁻¹ ≤ Real.exp eTail ∧ + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ) = booleanRegularizationRadius (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T (ε / 2) ∧ (δ : ℝ)⁻¹ ≤ Real.exp e ∧ + AllocatedCommonNormalizedAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A₀ T₀ Kproj Kideal Ksite + +theorem allocatedUniformAccurateAffine_normalized + {p P E : ℝ} (hp : 0 ≤ p) (hP : 0 ≤ P) (hE : 0 ≤ E) + (hdim : dim ≤ m + 1) (hmP : ((m + 2 : ℕ) : ℝ) ≤ P) (hpP : p ≤ P) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + {A T : ℝ≥0} {A₀ T₀ Kproj Kideal Ksite Knorm : ℕ} + (hT : 1 ≤ T₀) (hKsite : 1 ≤ Ksite) (hKnorm : 1 ≤ Knorm) + (hnorm : AllocatedSourceNarrowNormalization.{uG,uI,uB,uJ,uX} m Knorm) + (hcover : AllocatedUniformAccurateAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T A₀ T₀ Kproj Kideal Ksite) : + AllocatedUniformNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T A₀ T₀ Kproj Kideal (max Ksite Knorm) := by + unfold AllocatedUniformNormalizedAffineData + intro D target w gainLog ε e eTail t + obtain ⟨he, heTail, ht, ht1, hti, δ, hδ, hδ1, hδeq, hδe, hcommon⟩ := hcover + refine ⟨he, heTail, ht, ht1, hti, δ, hδ, hδ1, hδeq, hδe, ?_⟩ + exact allocatedCommonAccurateAffineAt_normalized B hp hP hE he hdim hmP hpP hvars hI hn + hT hKsite hKnorm hnorm hcommon + +end Data + +theorem exists_uniform_normalized_affine : + ∃ A : ℝ≥0, 1 ≤ A ∧ ∀ m dim : ℕ, ∃ A₀ T₀ Kproj Kideal Ksite : ℕ, + 2 ≤ A₀ ∧ 2 ≤ T₀ ∧ 2 ≤ Kproj ∧ 2 ≤ Kideal ∧ 2 ≤ Ksite ∧ + ∀ {G : Type uG} [Fintype G] [DecidableEq G] + {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + {p P E : ℝ}, 0 ≤ p → ∀ hP : 0 ≤ P, 0 ≤ E → + dim ≤ m + 1 → ((m + 2 : ℕ) : ℝ) ≤ P → p ≤ P → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p → + (∀ j, (Fintype.card (I j) : ℝ) ≤ p) → (∀ j, (n j : ℝ) ≤ p) → + (∀ j i, siteSpectrumBlockCount m ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) → + AllocatedUniformNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A scalarSourceTransitionBound A₀ T₀ Kproj Kideal Ksite := by + obtain ⟨A, hA, hfixed⟩ := exists_uniform_accurate_affine.{uG,uI,uB,uJ,uQ,uX} + refine ⟨A, hA, ?_⟩ + intro m dim + obtain ⟨A₀, T₀, Kproj, Kideal, Ksite, hA₀, hT₀, hKproj, hKideal, hKsite, hfixed⟩ := hfixed m dim + obtain ⟨Knorm, hKnorm, hnorm⟩ := exists_allocatedSourceNarrowNormalization.{uG,uI,uB,uJ,uX} m + refine ⟨A₀, T₀, Kproj, Kideal, max Ksite Knorm, hA₀, hT₀, hKproj, hKideal, + hKsite.trans (le_max_left _ _), ?_⟩ + intro G _ _ I _ n B _ p P E hp hP hE hdim hmP hpP hvars hI hn hBlocks + exact allocatedUniformAccurateAffine_normalized B hp hP hE hdim hmP hpP hvars hI hn + (by omega) (by omega) (by omega) hnorm + (hfixed B hp hP hE hdim hmP hpP hvars hI hn hBlocks) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +section Data + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +theorem allocatedCommonNormalizedAffineAt_mono_width + {p P E e s t : ℝ} {hP : 0 ≤ P} {δ : ℝ≥0} {A T Kproj Kideal Ksite : ℕ} + (hst : s ≤ t) + (hsource : AllocatedCommonNormalizedAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A T Kproj Kideal Ksite) : + AllocatedCommonNormalizedAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e s hP δ A T Kproj Kideal Ksite := by + unfold AllocatedCommonNormalizedAffineAt + intro Epoint c hc J _ U b R σ hR hσ hσs hR1 hRi hσi + exact hsource hc U b hR hσ (fun j => (hσs j).trans hst) hR1 hRi hσi + +def AllocatedGeometricNormalizedAffineData (p g P E : ℝ) (hP : 0 ≤ P) (A T : ℝ≥0) + (A₀ T₀ Kproj Kideal Ksite : ℕ) : Prop := + let e := allocatedCommonSmoothingLog B dim A T p P E + let c := allocatedCommonGeometryLog (G := G) B dim A T p g P E + let r := allocatedCommonRadius m p g + let σ := allocatedCommonWidth (G := G) B dim A T p P E + 0 ≤ c ∧ g ≤ c ∧ 0 < r ∧ r ≤ 1 ∧ 0 < σ ∧ σ ≤ 1 ∧ + r⁻¹ ≤ Real.exp c ∧ σ⁻¹ ≤ Real.exp c ∧ + (∀ (C : Fin m → ℝ), (∀ j, 0 ≤ C j) → (∀ j, C j ≤ Real.exp g) → ∀ j, + r ≤ allocatedBufferedPhysicalChartRadius (G := G) B (Fin dim) C j ∧ + r ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) C 1 j ∧ + r ≤ allocatedIdealCoverRadius (G := G) B + (fun j => boundedBooleanJetRows (Fin dim) (j.val + 1)) C j) ∧ + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ (δ : ℝ)⁻¹ ≤ Real.exp e ∧ + AllocatedCommonNormalizedAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e σ hP δ A₀ T₀ Kproj Kideal Ksite + +theorem allocatedUniformNormalizedAffine_geometric + {p g P E : ℝ} (hp : 0 ≤ p) (hg : 0 ≤ g) (hP : 0 ≤ P) (hE : 0 ≤ E) + (hdim : dim ≤ m + 1) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + {A T : ℝ≥0} {A₀ T₀ Kproj Kideal Ksite : ℕ} + (hsource : AllocatedUniformNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T A₀ T₀ Kproj Kideal Ksite) : + AllocatedGeometricNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p g P E hP A T A₀ T₀ Kproj Kideal Ksite := by + obtain ⟨_, _, ht, _, hti, δ, hδ, hδ1, _, hδe, hcommon⟩ := hsource + have hwidth := allocatedCommonWidth_le (G := G) B dim A T ht hti + obtain ⟨hc, hgc, _, _, hri, hσi⟩ := allocatedCommonGeometryLog_bounds (G := G) B dim A T hp hg hP hE + obtain ⟨hr, hr1, _⟩ := allocatedCommonRadius_bounds m hp hg + obtain ⟨hσ, hσ1, _⟩ := allocatedCommonWidth_bounds (G := G) B dim A T hp hP hE + refine ⟨hc, hgc, hr, hr1, hσ, hσ1, hri, hσi, ?_, δ, hδ, hδ1, hδe, ?_⟩ + · intro C hC hCg j + exact allocatedCommonRadius_admissible B (fun j => boundedBooleanJetRows (Fin dim) (j.val + 1)) + hp hg (by simpa only [Fintype.card_fin] using hdim) hvars hI hn C hC hCg j + · exact allocatedCommonNormalizedAffineAt_mono_width B hwidth hcommon + +end Data + +theorem exists_uniform_geometric_normalized_affine : + ∃ A : ℝ≥0, 1 ≤ A ∧ ∀ m dim : ℕ, ∃ A₀ T₀ Kproj Kideal Ksite a : ℕ, + 2 ≤ A₀ ∧ 2 ≤ T₀ ∧ 2 ≤ Kproj ∧ 2 ≤ Kideal ∧ 2 ≤ Ksite ∧ 2 ≤ a ∧ + ∀ {G : Type uG} [Fintype G] [DecidableEq G] + {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type uB) [∀ i, Fintype (B i)] + {p g P E : ℝ}, 0 ≤ p → 0 ≤ g → ∀ hP : 0 ≤ P, 0 ≤ E → + dim ≤ m + 1 → ((m + 2 : ℕ) : ℝ) ≤ P → p ≤ P → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p → + (∀ j, (Fintype.card (I j) : ℝ) ≤ p) → (∀ j, (n j : ℝ) ≤ p) → + (∀ j i, siteSpectrumBlockCount m ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) → + AllocatedGeometricNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p g P E hP A scalarSourceTransitionBound A₀ T₀ Kproj Kideal Ksite ∧ + (allocatedCommonCoverParameter (G := G) B dim A₀ (max T₀ (max Kproj Kideal)) p + (allocatedCommonGeometryLog (G := G) B dim A scalarSourceTransitionBound p g P E) P + (allocatedCommonSmoothingLog B dim A scalarSourceTransitionBound p P E) (E + 1) + Ksite) ^ Ksite ≤ + (p + g + P + E + a) ^ a := by + obtain ⟨A, hA, hfixed⟩ := exists_uniform_normalized_affine.{uG,uI,uB,uJ,uQ,uX} + refine ⟨A, hA, ?_⟩ + intro m dim + obtain ⟨A₀, T₀, Kproj, Kideal, Ksite, hA₀, hT₀, hKproj, hKideal, hKsite, hfixed⟩ := hfixed m dim + obtain ⟨a, ha, hbound⟩ := exists_fixedGeometricCommonCoverThreshold_bound + m dim A₀ (max T₀ (max Kproj Kideal)) Ksite A scalarSourceTransitionBound + refine ⟨A₀, T₀, Kproj, Kideal, Ksite, a, hA₀, hT₀, hKproj, hKideal, hKsite, ha, ?_⟩ + intro G _ _ I _ n B _ p g P E hp hg hP hE hdim hmP hpP hvars hI hn hBlocks + exact ⟨allocatedUniformNormalizedAffine_geometric B hp hg hP hE hdim hvars hI hn + (hfixed B hp hP hE hdim hmP hpP hvars hI hn hBlocks), + hbound B hp hg hP hE hdim hvars hI hn⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped ContDiff BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +section Data + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "hLayer" => layerSamplerDegree I n + +def AllocatedUniformPrimitiveAffineData (p P E : ℝ) (hP : 0 ≤ P) (A T : ℝ≥0) + (A₀ Ksize : ℕ) : Prop := + let D := allocatedComparisonDimension m p + let target := profileReferenceErrorLog P ((E + 1) + 1 + 4) + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * P + let gainLog := allocatedProfileGainLog m D P w + let ε := physicalIdealErrorShare target gainLog + let e := physicalIdealSmoothingLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) hLayer A T target gainLog + let eTail := physicalIdealTailLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) G (G × Option (Fin dim)) hLayer A T m target gainLog + let t := booleanMassPerturbationScale (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) + ((G × Option (Fin dim)) ⊕ (Σ a, SamplerCoefficientSlot G B hLayer a)) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T m 1 (ε / 2) + 0 ≤ e ∧ 0 ≤ eTail ∧ 0 < t ∧ t ≤ 1 ∧ t⁻¹ ≤ Real.exp eTail ∧ + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ) = booleanRegularizationRadius (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T (ε / 2) ∧ (δ : ℝ)⁻¹ ≤ Real.exp e ∧ + AllocatedCommonPrimitiveAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A₀ Ksize + +theorem allocatedUniformNormalizedAffine_primitive + {p P E : ℝ} (hp : 0 ≤ p) (hP : 0 ≤ P) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + {A T : ℝ≥0} {A₀ T₀ Kproj Kideal Ksite Ksize : ℕ} + (hsize : ∀ {c : ℝ}, 0 ≤ c → + (allocatedCommonCoverParameter (G := G) B dim A₀ (max T₀ (max Kproj Kideal)) p c P + (allocatedCommonSmoothingLog B dim A T p P E) (E + 1) + Ksite) ^ Ksite ≤ + (p + c + P + E + Ksize) ^ Ksize) + (hsource : AllocatedUniformNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T A₀ T₀ Kproj Kideal Ksite) : + AllocatedUniformPrimitiveAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T A₀ Ksize := by + unfold AllocatedUniformPrimitiveAffineData + intro D target w gainLog ε e eTail t + obtain ⟨he, heTail, ht, ht1, hti, δ, hδ, hδ1, hδeq, hδe, hcommon⟩ := hsource + refine ⟨he, heTail, ht, ht1, hti, δ, hδ, hδ1, hδeq, hδe, ?_⟩ + exact allocatedCommonNormalizedAffineAt_primitive B hp hP hvars hI hn hsize hcommon + +end Data + +theorem exists_uniform_primitive_affine : + ∃ A : ℝ≥0, 1 ≤ A ∧ ∀ m dim : ℕ, ∃ A₀ Ksize : ℕ, 2 ≤ A₀ ∧ 2 ≤ Ksize ∧ + ∀ {G : Type uG} [Fintype G] [DecidableEq G] + {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + {p P E : ℝ}, 0 ≤ p → ∀ hP : 0 ≤ P, 0 ≤ E → + dim ≤ m + 1 → ((m + 2 : ℕ) : ℝ) ≤ P → p ≤ P → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p → + (∀ j, (Fintype.card (I j) : ℝ) ≤ p) → (∀ j, (n j : ℝ) ≤ p) → + (∀ j i, siteSpectrumBlockCount m ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) → + AllocatedUniformPrimitiveAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A scalarSourceTransitionBound A₀ Ksize := by + obtain ⟨A, hA, hfixed⟩ := exists_uniform_normalized_affine.{uG,uI,uB,uJ,uQ,uX} + refine ⟨A, hA, ?_⟩ + intro m dim + obtain ⟨A₀, T₀, Kproj, Kideal, Ksite, hA₀, _, _, _, _, hfixed⟩ := hfixed m dim + obtain ⟨Ksize, hKsize, hsize⟩ := exists_fixedRegularizedCommonCoverThreshold_bound + m dim A₀ (max T₀ (max Kproj Kideal)) Ksite A scalarSourceTransitionBound + refine ⟨A₀, Ksize, hA₀, hKsize, ?_⟩ + intro G _ _ I _ n B _ p P E hp hP hE hdim hmP hpP hvars hI hn hBlocks + apply allocatedUniformNormalizedAffine_primitive B hp hP hvars hI hn + (Ksite := Ksite) (Kideal := Kideal) (Kproj := Kproj) (T₀ := T₀) + · intro c hc + exact hsize B hp hc hP hE hdim hvars hI hn + · exact hfixed B hp hP hE hdim hmP hpP hvars hI hn hBlocks + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +section Data + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +def AllocatedProductGeometricNormalizedAffineData (p g P E : ℝ) (hP : 0 ≤ P) (A T : ℝ≥0) + (A₀ T₀ Kproj Kideal Ksite : ℕ) : Prop := + let e := allocatedCommonSmoothingLog B dim A T p P E + let c := allocatedProductGeometryLog (G := G) B dim A T p g P E + let r := allocatedCommonProductRadius m p g + let σ := allocatedCommonWidth (G := G) B dim A T p P E + 0 ≤ c ∧ g ≤ c ∧ 0 < r ∧ r ≤ 1 ∧ 0 < σ ∧ σ ≤ 1 ∧ + r⁻¹ ≤ Real.exp c ∧ σ⁻¹ ≤ Real.exp c ∧ + (∀ (C : Fin m → ℝ), (∀ j, 0 ≤ C j) → (∀ j, C j ≤ Real.exp g) → ∀ j, + r ≤ allocatedBufferedPhysicalChartRadius (G := G) B (Fin dim) C j ∧ + r ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) C 1 j ∧ + r ≤ allocatedIdealCoverRadius (G := G) B + (fun j => boundedBooleanJetRows (Fin dim) (j.val + 1)) C j ∧ + r ≤ allocatedProductGridRadius (G := G) B + (fun j => boundedBooleanJetRows (Fin dim) (j.val + 1)) C j) ∧ + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ (δ : ℝ)⁻¹ ≤ Real.exp e ∧ + AllocatedCommonNormalizedAffineAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e σ hP δ A₀ T₀ Kproj Kideal Ksite + +theorem allocatedUniformNormalizedAffine_product_geometric + {p g P E : ℝ} (hp : 0 ≤ p) (hg : 0 ≤ g) (hP : 0 ≤ P) (hE : 0 ≤ E) + (hdim : dim ≤ m + 1) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + {A T : ℝ≥0} {A₀ T₀ Kproj Kideal Ksite : ℕ} + (hsource : AllocatedUniformNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T A₀ T₀ Kproj Kideal Ksite) : + AllocatedProductGeometricNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p g P E hP A T A₀ T₀ Kproj Kideal Ksite := by + obtain ⟨_, _, ht, _, hti, δ, hδ, hδ1, _, hδe, hcommon⟩ := hsource + have hwidth := allocatedCommonWidth_le (G := G) B dim A T ht hti + obtain ⟨hc, hgc, _, _, hri, hσi⟩ := allocatedProductGeometryLog_bounds (G := G) B dim A T hp hg hP hE + obtain ⟨_, hr, hr1, _, _, _, _⟩ := allocatedCommonProductRadius_bounds m hp hg + obtain ⟨hσ, hσ1, _⟩ := allocatedCommonWidth_bounds (G := G) B dim A T hp hP hE + refine ⟨hc, hgc, hr, hr1, hσ, hσ1, hri, hσi, ?_, δ, hδ, hδ1, hδe, ?_⟩ + · intro C hC hCg j + exact allocatedCommonProductRadius_admissible B (fun j => boundedBooleanJetRows (Fin dim) (j.val + 1)) + hp hg (by simpa only [Fintype.card_fin] using hdim) hvars hI hn C hC hCg j + · exact allocatedCommonNormalizedAffineAt_mono_width B hwidth hcommon + +end Data + +theorem exists_uniform_product_geometric_normalized_affine : + ∃ A : ℝ≥0, 1 ≤ A ∧ ∀ m dim : ℕ, ∃ A₀ T₀ Kproj Kideal Ksite a : ℕ, + 2 ≤ A₀ ∧ 2 ≤ T₀ ∧ 2 ≤ Kproj ∧ 2 ≤ Kideal ∧ 2 ≤ Ksite ∧ 2 ≤ a ∧ + ∀ {G : Type uG} [Fintype G] [DecidableEq G] + {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type uB) [∀ i, Fintype (B i)] + {p g P E : ℝ}, 0 ≤ p → 0 ≤ g → ∀ hP : 0 ≤ P, 0 ≤ E → + dim ≤ m + 1 → ((m + 2 : ℕ) : ℝ) ≤ P → p ≤ P → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p → + (∀ j, (Fintype.card (I j) : ℝ) ≤ p) → (∀ j, (n j : ℝ) ≤ p) → + (∀ j i, siteSpectrumBlockCount m ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) → + AllocatedProductGeometricNormalizedAffineData.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p g P E hP A scalarSourceTransitionBound A₀ T₀ Kproj Kideal Ksite ∧ + (allocatedCommonCoverParameter (G := G) B dim A₀ (max T₀ (max Kproj Kideal)) p + (allocatedProductGeometryLog (G := G) B dim A scalarSourceTransitionBound p g P E) P + (allocatedCommonSmoothingLog B dim A scalarSourceTransitionBound p P E) (E + 1) + Ksite) ^ Ksite ≤ + (p + g + P + E + a) ^ a := by + obtain ⟨A, hA, hfixed⟩ := exists_uniform_normalized_affine.{uG,uI,uB,uJ,uQ,uX} + refine ⟨A, hA, ?_⟩ + intro m dim + obtain ⟨A₀, T₀, Kproj, Kideal, Ksite, hA₀, hT₀, hKproj, hKideal, hKsite, hfixed⟩ := hfixed m dim + obtain ⟨a, ha, hbound⟩ := exists_fixedProductGeometricCommonCoverThreshold_bound + m dim A₀ (max T₀ (max Kproj Kideal)) Ksite A scalarSourceTransitionBound + refine ⟨A₀, T₀, Kproj, Kideal, Ksite, a, hA₀, hT₀, hKproj, hKideal, hKsite, ha, ?_⟩ + intro G _ _ I _ n B _ p g P E hp hg hP hE hdim hmP hpP hvars hI hn hBlocks + exact ⟨allocatedUniformNormalizedAffine_product_geometric B hp hg hP hE hdim hvars hI hn + (hfixed B hp hP hE hdim hmP hpP hvars hI hn hBlocks), + hbound B hp hg hP hE hdim hvars hI hn⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedRecoveredIntegerFullChart.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedRecoveredIntegerFullChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..db5d8985889da2f5c61e4e77119e5dbf8e4fa331 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedRecoveredIntegerFullChart.lean @@ -0,0 +1,182 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRecoveredPreparedFreeze +import OAI.Combinatorics.Progressions.Polynomial.BufferedSampledCurrentGradePhase + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open BooleanCubeKernel _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators +variable {m : ℕ} {K X : Type*} [Fintype K] (J : Fin m → Type*) + (a : X → ℤ) (v : Option K × X → ℤ) + (tag : ∀ j, J j → MvPolynomial K ℤ) + +noncomputable def jointIntegerFullChart : X ⊕ (Σ j, J j) → MvPolynomial K ℤ := + Sum.elim (affineFramePolynomial (jointIntegerFrame (a, v))) (fun z => tag z.1 z.2) + +theorem jointIntegerFullChart_support + (htag : ∀ j b, (tag j b).totalDegree ≤ j.val + 1) : + ∀ i, integerSampledRealChart (jointIntegerFullChart J a v tag) i ∈ + weightedSupportLE (fun _ : K => 1) (fullTaggedVariableWeight J i) := by + intro i + apply (mem_weightedSupportLE_one_iff _ _).mpr + cases i with + | inl x => + change (MvPolynomial.map (Int.castRingHom ℝ) + (affineFramePolynomial (jointIntegerFrame (a, v)) x)).totalDegree ≤ 1 + exact (totalDegree_map_le _ _).trans (affineFramePolynomial_degree _ _) + | inr z => + change (MvPolynomial.map (Int.castRingHom ℝ) (tag z.1 z.2)).totalDegree ≤ z.1.val + 1 + exact (totalDegree_map_le _ _).trans (htag z.1 z.2) + +theorem jointIntegerFullChart_spatial (x : K → ℤ) : + integerSampledSpatial (jointIntegerFullChart J a v tag) x = + jointIntegerPhysicalSite x (a, v) := by + funext i + change MvPolynomial.aeval x (affineFramePolynomial (jointIntegerFrame (a, v)) i) = _ + rw [affineFramePolynomial_eval] + have h := congrFun (integerAffineMap_jointIntegerFrame (a, v) x) i + simpa only [integerAffineMap] using h + +theorem cast_jointIntegerPhysicalSite_eq_frame (x : K → ℤ) : + (fun i => (jointIntegerPhysicalSite x (a, v) i : ℝ)) = + (fun i => (jointIntegerFrame (a, v) none i : ℝ) + + ∑ k, (jointIntegerFrame (a, v) (some k) i : ℝ) * (x k : ℝ)) := by + rw [← integerAffineMap_jointIntegerFrame] + funext i + simp only [integerAffineMap, Int.cast_add, Int.cast_sum, Int.cast_mul] + +theorem eval_jointIntegerPhysicalSite_eq_frame + {V : Type*} [AddCommGroup V] [Module ℝ V] + (p : VectorPolynomial X ℝ V) (x : K → ℤ) : + eval (fun i => (jointIntegerPhysicalSite x (a, v) i : ℝ)) p = + eval (fun i => (jointIntegerFrame (a, v) none i : ℝ) + + ∑ k, (jointIntegerFrame (a, v) (some k) i : ℝ) * (x k : ℝ)) p := by + rw [cast_jointIntegerPhysicalSite_eq_frame] +end Erdos3.VectorPolynomial + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +noncomputable def allocatedRecoveredIntegerFullChart + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) : + X ⊕ (Σ j, J j) → MvPolynomial (LayerSamplerVariables G I n B) ℤ := + jointIntegerFullChart J a v + (coefficientIntegerFloorPolynomial U b o sample + (centeredAffineCoefficientArray U poly hm c + (fun k z => (jointIntegerFrame (a, v) k z : ℝ)))) + +theorem allocatedRecoveredIntegerFullChart_support + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) : + ∀ i, integerSampledRealChart (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) i ∈ + weightedSupportLE (fun _ : LayerSamplerVariables G I n B => 1) (fullTaggedVariableWeight J i) := by + apply jointIntegerFullChart_support + exact coefficientIntegerFloorPolynomial_degree U b o sample _ + +theorem allocatedRecoveredIntegerFullChart_spatial + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (x : LayerSamplerVariables G I n B → ℤ) : + integerSampledSpatial (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) x = + jointIntegerPhysicalSite x (a, v) := + jointIntegerFullChart_spatial J a v _ x + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_remainder + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (x : LayerSamplerVariables G I n B → ℝ) (j : Fin m) (i : J j) : + eval (fun z => (jointIntegerFrame (a, v) none z : ℝ) + + ∑ k, (jointIntegerFrame (a, v) (some k) z : ℝ) * x k) (poly j) i - (c j).val i = + mixedPolynomialPoint (euclideanSubspace (U j)) (b j) (o j) Subtype.val + (sample j).1 (sample j).2 x i + + MvPolynomial.eval x (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) (Sum.inr ⟨j, i⟩)) := by + let frame : Option (LayerSamplerVariables G I n B) → X → ℝ := + fun k z => (jointIntegerFrame (a, v) k z : ℝ) + have hc : canonicalCoefficientSample U b hb o sample = + QuotientAddGroup.mk' (coefficientIntegerLattice U) + (centeredAffineCoefficientArray U poly hm c frame) := + h.2.1.trans (affineSampleCoefficientTorus_subtractConstant U poly hm c frame) + have hβ := canonicalCoefficientSample_floor_polynomial_remainder U b hb o sample + (centeredAffineCoefficientArray U poly hm c frame) hc j i + change eval (fun z => frame none z + ∑ k, frame (some k) z * x k) (poly j) i - (c j).val i = + mixedPolynomialPoint (euclideanSubspace (U j)) (b j) (o j) Subtype.val + (sample j).1 (sample j).2 x i + + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) + (coefficientIntegerFloorPolynomial U b o sample + (centeredAffineCoefficientArray U poly hm c frame) j i)) + rw [← coefficientRowPolynomial_centered_affine_eval U poly hm hp c frame j i x, + hβ.1, map_add, mixedLiftPolynomial_eval] + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_residual + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (x : LayerSamplerVariables G I n B → ℤ) + (hx : ∀ k, |(x k : ℝ)| ≤ layerSamplerBox B U b S k) (j : Fin m) (i : J j) : + |eval (fun z => (jointIntegerPhysicalSite x (a, v) z : ℝ)) (poly j) i - (c j).val i - + (MvPolynomial.eval x (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample + (Sum.inr ⟨j, i⟩)) : ℝ)| ≤ C j * (((Fintype.card (I j) : ℝ) + 1) * R j) := by + rw [eval_jointIntegerPhysicalSite_eq_frame a v, + ← integerSampledRealChart_eval (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample), + h.integerFullChart_remainder B U b hb o S hR hσ poly hm hp c a v sample read, + add_sub_cancel_right] + exact allocatedLayerSupported_polynomial_bound B U b o hR hσ S hσ1 C hC hchart + j (sample j) (h.2.2.1 j).2 (fun k => (x k : ℝ)) hx i + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_low_residual + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (k : ℕ) (x : LayerSamplerVariables G I n B → ℤ) + (hx : ∀ z, |(x z : ℝ)| ≤ layerSamplerBox B U b S z) + (i : Fin (Fintype.card (LowTaggedIndex J k))) : + |MvPolynomial.eval + (fun z => (integerSampledSpatial (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) x z : ℝ)) + (lowTaggedPolynomial J k poly i) - (c (lowTaggedIndex J k i).1).val (lowTaggedIndex J k i).2 - + (integerSampledLowTags J k (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) x i : ℝ)| ≤ 1 / 8 := by + rw [allocatedRecoveredIntegerFullChart_spatial, lowTaggedPolynomial_eval] + exact (h.integerFullChart_residual B U b hb o S hR hσ poly hm hσ1 C hC hchart hp + c a v sample read x hx (lowTaggedIndex J k i).1 (lowTaggedIndex J k i).2).trans + (hsmall (lowTaggedIndex J k i).1) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueAmbientFactor.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueAmbientFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef56f40663a72428cca2370f75c8698c15a09cd0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueAmbientFactor.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedMaskedFactorBounds + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] (r : ℝ≥0) (hr : 0 < r) (period : ℕ) [NeZero period] + +local notation "single" => (fun _ : Fin m => Unit) +local notation "ambient" => JetAmbientIndex single J +local notation "RI" => MaskedSiteResidueIndex n E +local notation "chart" => mixedCoveredJetChart (O := single) U o b hb bW d +local notation "region" => mixedCoveredJetRegion (O := single) (E := E) U o b d + (fun j (_ : Unit) => standardLatticeClosedQuarterBox (J j)) + +theorem exists_allocated_residue_ambient_factor + (hR : ∀ j, 0 < R j) (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (label : (∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) + (f : (LayerSamplerAxis I n → ℝ) → ℂ) {L : ℝ≥0} + (hf : LipschitzWith L f) (hf1 : ∀ z, ‖f z‖ ≤ 1) : + let Lout := max (L * (K * ∑ j, Cforward j * Fintype.card (J j))) (2 * period) + ∃ g : (RI → UnitAddCircle) × (ambient → UnitAddCircle) → ℂ, + LipschitzWith Lout g ∧ (∀ z, ‖g z‖ ≤ 1) ∧ + ∀ w : MixedCoveredJetSource I single E n d, w ∈ region → + g ((fun i => (((mixedCoveredSiteResidueIntegers d w i : ℝ) / period : ℝ) : UnitAddCircle)), + coveredJetAmbientTorus U d (chart w)) = + ((if mixedCoveredSiteResidue d period w = label then (1 : ℂ) else 0) * + f (allocatedFullMixedSiteValue (R := R) U b + (fun j => mixedArrayRegroup _ _ _ ((Prod.fst w) j) ()))) / 4 := by + intro Lout + let F := f + let decode := fun a : RI → ZMod period => + ((fun j i => a (.inl ⟨j,i⟩)), (fun j i => a (.inr ⟨j,i⟩))) + let raw := fun a : RI → ZMod period => fun v : ambient → ℝ => + if decode a = label then F (allocatedFullAmbientSiteCoordinates (R := R) U b o v) else 0 + have hFl : LipschitzWith L F := hf + have hFb : ∀ z, ‖F z‖ ≤ 1 := hf1 + have hraw (a) : LipschitzWith (L * (K * ∑ j, Cforward j * Fintype.card (J j))) (raw a) := by + dsimp only [raw] + split_ifs + · exact hFl.comp (allocatedFullAmbientSiteCoordinates_lipschitz U b o hR Cforward hforward K hK) + · apply LipschitzWith.of_dist_le_mul + intro v w + simp only [dist_self] + positivity + have hrawb (a) (v) : ‖raw a v‖ ≤ 1 := by + dsimp only [raw] + split_ifs + · exact hFb _ + · simp only [norm_zero, zero_le_one] + obtain ⟨g₀, hg₀, hgb, hgv⟩ := exists_residue_quarter_extension (fun _ : RI => period) + (period : ℝ≥0) (L * (K * ∑ j, Cforward j * Fintype.card (J j))) (fun _ => le_rfl) raw hraw hrawb + refine ⟨fun z => g₀ z / 4, lipschitz_complex_div_four g₀ Lout hg₀, + fun z => complex_div_four_norm_le (hgb z), ?_⟩ + intro w hw + rw [coveredJetAmbientTorus_chart U b hb o bW d w] + have hsmall : ∀ i, |mixedJetAmbientPoint U b o w.1 i| ≤ 1 / 4 := by + rintro ⟨j, t, i⟩ + exact (hw j (mem_univ j) t (mem_univ t)).1 i + have hv := hgv (fun i => (mixedCoveredSiteResidueIntegers d w i : ZMod period)) + (mixedJetAmbientPoint U b o w.1) hsmall + have hc : (residueTuplePoint (fun _ : RI => period) + (fun i => (mixedCoveredSiteResidueIntegers d w i : ZMod period))) = + (fun i => (((mixedCoveredSiteResidueIntegers d w i : ℝ) / period : ℝ) : UnitAddCircle)) := by + funext i + exact ZMod.toAddCircle_intCast _ + rw [hc] at hv + dsimp only + rw [hv] + congr 1 + dsimp only [raw] + rw [allocatedFullAmbientSiteCoordinates_point] + have hdecode : decode (fun i => (mixedCoveredSiteResidueIntegers d w i : ZMod period)) = + mixedCoveredSiteResidue d period w := by + apply Prod.ext + · rfl + · funext j i + exact Int.cast_natCast _ + rw [hdecode] + change (if mixedCoveredSiteResidue d period w = label then F _ else 0) = + (if mixedCoveredSiteResidue d period w = label then (1 : ℂ) else 0) * F _ + split_ifs <;> simp only [one_mul, zero_mul] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueCoefficientL1.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueCoefficientL1.lean new file mode 100644 index 0000000000000000000000000000000000000000..70c9a268ac537524773db0419f3faeeb0844d69b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueCoefficientL1.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedFiniteCoefficientL1 + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable [DecidableEq G] [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +theorem allocatedLongJet_residue_coefficient_l1 {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) + (modulus : ℕ) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) + (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) + (u : PrincipalAxisTuples (α := α) grid sides) + (p : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides)) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + (hr : ∀ v, p.weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) + : + let C := Real.exp (allocatedDensityLog (G := G) B α O P) + let CM : ℝ := layerKernelIndexBound m M + let T := Real.exp (allocatedJetSupportLog (G := G) B α O P) + let normalized := fun v => principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v + let proxy := fun z => p.mean (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA (normalized v) z) + Integrable (allocatedLongProfileDensity B U basis S x rows modulus residue proxy) + (allocatedLongJetReference B U basis S O) ∧ + (∫ z, |p.mean (fun v => allocatedLongJetDensity B U basis hR hσ S x u v rows s hA hσ1 z) - + allocatedLongProfileDensity B U basis S x rows modulus residue proxy z| + ∂allocatedLongJetReference B U basis S O) ≤ + (2*T+1)^Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬grid a} * ε * (1 + CM * C + ε)^Fintype.card {a // ¬grid a}) := by + intro C CM T normalized proxy + have hid (v) (z : AllocatedLongJetRows B U basis S O) : + allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (normalized v) (allocatedLongJetRealCoordinates B U basis S z) = + ∏ a, allocatedLongJetTarget B U basis S x u rows s hA (normalized v) a (z a) := by + exact Finset.prod_congr rfl (fun a _ => + (allocatedLongJetTarget_normalized B U basis S x u rows s hA (normalized v) z a).symm) + have he (z) := allocatedLongJet_residue_coefficient_comparison B U basis hR hσ S x rows + hM selection hx hq hinj hrows hσ1 hP he hε hMP hRP hRi hσi hcount hεe hlarge + modulus hperiod s hA hi u p residue hr z + change ∀ z, |_ - _ * p.mean (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (normalized v) (allocatedLongJetRealCoordinates B U basis S z))| ≤ + Fintype.card {a // ¬grid a} * ε * (1 + CM * C + ε)^Fintype.card {a // ¬grid a} at he + simp_rw [hid] at he + have hε0 : 0 ≤ Fintype.card {a // ¬grid a} * ε * + (1 + CM * C + ε)^Fintype.card {a // ¬grid a} := by + dsimp [CM,C] + positivity + have hh := allocatedFiniteLongJet_l1_comparison B U basis hR hσ S x u rows s hA + hM hi hP hMP hRP hRi hσi hcount hσ1 p modulus residue hε0 he + have hprofile : allocatedLongProfileDensity B U basis S x rows modulus residue proxy = + fun z => (∏ a, allocatedLongJetMask B U basis S x rows modulus residue a (z a)) * + p.mean (fun v => ∏ a, allocatedLongJetTarget B U basis S x u rows s hA (normalized v) a (z a)) / + (∏ a, allocatedLongJetOutputScale B U basis S (O := O) a) := by + funext z + dsimp only [allocatedLongProfileDensity, proxy] + simp_rw [hid] + rw [hprofile] + exact hh + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueCoefficientL1WithCutoff.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueCoefficientL1WithCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d6e3b16c2e6d8fb62bdb7a7241a4e814da576c3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueCoefficientL1WithCutoff.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedFiniteCoefficientComparisonWithCutoff +import OAI.Combinatorics.Progressions.Estimates.AllocatedFiniteCoefficientL1 + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable [DecidableEq G] [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +theorem allocatedLongJet_residue_coefficient_l1_withCutoff (d : ℕ) + (hcutoff : AllocatedTailCutoffCompatible U basis S.value d) {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ d+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLogWithCutoff (G := G) B d α O P e) ≤ S.value) + (modulus : ℕ) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) + (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) + (u : PrincipalAxisTuples (α := α) grid sides) + (p : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides)) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + (hr : ∀ v, p.weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) + : + let C := Real.exp (allocatedDensityLog (G := G) B α O P) + let CM : ℝ := layerKernelIndexBound (max m d) M + let T := Real.exp (allocatedJetSupportLog (G := G) B α O P) + let normalized := fun v => principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v + let proxy := fun z => p.mean (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA (normalized v) z) + Integrable (allocatedLongProfileDensity B U basis S x rows modulus residue proxy) + (allocatedLongJetReference B U basis S O) ∧ + (∫ z, |p.mean (fun v => allocatedLongJetDensity B U basis hR hσ S x u v rows s hA hσ1 z) - + allocatedLongProfileDensity B U basis S x rows modulus residue proxy z| + ∂allocatedLongJetReference B U basis S O) ≤ + (2*T+1)^Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬grid a} * ε * (1 + CM * C + ε)^Fintype.card {a // ¬grid a}) := by + intro C CM T normalized proxy + have hid (v) (z : AllocatedLongJetRows B U basis S O) : + allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (normalized v) (allocatedLongJetRealCoordinates B U basis S z) = + ∏ a, allocatedLongJetTarget B U basis S x u rows s hA (normalized v) a (z a) := by + exact Finset.prod_congr rfl (fun a _ => + (allocatedLongJetTarget_normalized B U basis S x u rows s hA (normalized v) z a).symm) + have he (z) := allocatedLongJet_residue_coefficient_comparison_withCutoff B U basis hR hσ S x rows d hcutoff + hM selection hx hq hinj hrows hσ1 hP he hε hMP hRP hRi hσi hcount hεe hlarge + modulus hperiod s hA hi u p residue hr z + change ∀ z, |_ - _ * p.mean (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (normalized v) (allocatedLongJetRealCoordinates B U basis S z))| ≤ + Fintype.card {a // ¬grid a} * ε * (1 + CM * C + ε)^Fintype.card {a // ¬grid a} at he + simp_rw [hid] at he + have hε0 : 0 ≤ Fintype.card {a // ¬grid a} * ε * + (1 + CM * C + ε)^Fintype.card {a // ¬grid a} := by + dsimp [CM,C] + positivity + have hh := allocatedFiniteLongJet_l1_comparison B U basis hR hσ S x u rows s hA + hM hi hP hMP hRP hRi hσi hcount hσ1 p modulus residue hε0 he + have hprofile : allocatedLongProfileDensity B U basis S x rows modulus residue proxy = + fun z => (∏ a, allocatedLongJetMask B U basis S x rows modulus residue a (z a)) * + p.mean (fun v => ∏ a, allocatedLongJetTarget B U basis S x u rows s hA (normalized v) a (z a)) / + (∏ a, allocatedLongJetOutputScale B U basis S (O := O) a) := by + funext z + dsimp only [allocatedLongProfileDensity, proxy] + simp_rw [hid] + rw [hprofile] + exact hh + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueGridBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueGridBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..99729527783afc0bbabeca40048b134ebc64ebb9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueGridBudget.lean @@ -0,0 +1,204 @@ +import OAI.Combinatorics.Progressions.Fourier.AllocatedGridSpectrumSize +import OAI.Combinatorics.Progressions.Fourier.AllocatedResidueSpectrum + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (hq : 0 < q) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hsize : ∀ v, (Fintype.card α + 1) * q ≤ allocatedPrincipalSides B U basis S v) +variable (j : Fin m) (i : Fin (n j)) + +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "sidepos" => allocatedPrincipalSides_pos B U basis S +local notation "sources" => allocatedPrincipalResidueSources B U basis S q hq r hsize j i + +noncomputable def allocatedPrincipalResidueJetPMF (rows : Finset (Finset α)) (shift : rows → ℤ) : + PMF (rows → ℤ) := + (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b))).bind + (fun z => (principalResidueWeights B (layerSamplerDegree I n) sides sidepos q hq r hsize).toPMF.map + (fun y => shift + ∑ b : B ⟨j, Sum.inr i⟩, fun row : rows => + z b * integerBooleanBlockJet + (fun v : Fin (j.val + 1) => fun k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) row)) + +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +local notation "csource" => allocatedPrincipalNormalizedSource B U basis hR S j i hactive +local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i)) + +theorem allocatedPrincipalResidueJetPMF_eq_normalized + (rows : Finset (Finset α)) (shift : rows → ℤ) : + allocatedPrincipalResidueJetPMF B U basis hR hσ S q hq r hsize j i rows shift = + principalResidueAxisJetPMF B (layerSamplerDegree I n) sides sidepos q hq r hsize + ⟨j, Sum.inr i⟩ (fun _ => csource) rows (fun _ => 0) shift := by + have hc : + (dependentProductPMF (fun _ : B ⟨j, Sum.inr i⟩ => + (csource).source.toPMF.map (fun x => (x none : ℤ)))) = + dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b)) := + congrArg (fun p : B ⟨j, Sum.inr i⟩ → PMF ℤ => dependentProductPMF p) + (funext (fun b => allocatedPrincipalNormalizedSource_law B U basis hR hσ S j i hactive b)) + have he := congrArg (fun p : PMF (B ⟨j, Sum.inr i⟩ → ℤ) => p.bind (fun z => + (principalResidueWeights B (layerSamplerDegree I n) sides sidepos q hq r hsize).toPMF.map + (fun y => shift + ∑ b : B ⟨j, Sum.inr i⟩, fun row : rows => + z b * integerBooleanBlockJet + (fun v : Fin (j.val + 1) => fun k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) row))) hc.symm + unfold allocatedPrincipalResidueJetPMF principalResidueAxisJetPMF + simp only [zero_add] + exact he + +theorem allocatedPrincipalResidueGridDensity_eq_normalized + (rows : Finset (Finset α)) (shift : rows → ℤ) (M : ℕ) (z : rows → ℤ) : + (basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((allocatedPrincipalResidueJetPMF B U basis hR hσ S q hq r hsize j i rows shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal = + principalResidueAxisGridDensity B (layerSamplerDegree I n) sides sidepos q hq r hsize + ⟨j, Sum.inr i⟩ (fun _ => csource) rows (fun _ => 0) shift (basisAxisScale (basis j) i) M z := by + have he := congrArg (fun μ : PMF (rows → ℤ) => + (basisAxisScale (basis j) i : ℝ) ^ rows.card * + ((μ.map (integerGridResidue M)) (integerGridResidue M z)).toReal) + (allocatedPrincipalResidueJetPMF_eq_normalized B U basis hR hσ S q hq r hsize j i hactive rows shift) + simpa only [principalResidueAxisGridDensity] using he + +theorem allocatedPrincipalResidueGridDensity_error_of_tail + (rows : Finset (Finset α)) (shift : rows → ℤ) (M : ℕ) [NeZero M] + (F : Finset (rows → Fin M)) {ε : ℝ} + (htail : spectrumTail F (fun k => ‖∏ b : B ⟨j, Sum.inr i⟩, + weightedModerateGridCoefficient csource ((sources) b) 0 M rows k‖) ≤ ε) + (z : rows → ℤ) : + ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((allocatedPrincipalResidueJetPMF B U basis hR hσ S q hq r hsize j i rows shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal : ℝ) : ℂ) - + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + have hsources : sources = (fun (b : B ⟨j, Sum.inr i⟩) + (v : Fin (layerSamplerDegree I n ⟨j, Sum.inr i⟩)) => + principalResidueNormalizedSource B (layerSamplerDegree I n) sides sidepos q hq r hsize + ⟨⟨j, Sum.inr i⟩, b, v⟩) := rfl + simp only [hsources] at htail ⊢ + have he := principalResidueAxisGridDensity_error_of_tail B (layerSamplerDegree I n) + sides sidepos q hq r hsize ⟨j, Sum.inr i⟩ (fun _ => csource) rows (fun _ => 0) shift + (basisAxisScale (basis j) i) M F (by + simp only [Int.cast_zero] + exact htail) z + have hd := allocatedPrincipalResidueGridDensity_eq_normalized B U basis hR hσ S q hq r hsize + j i hactive rows shift M z + exact (congrArg (fun x : ℝ => ‖(x : ℂ) - + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) + (fun (b : B ⟨j, Sum.inr i⟩) (v : Fin (layerSamplerDegree I n ⟨j, Sum.inr i⟩)) => + principalResidueNormalizedSource B (layerSamplerDegree I n) sides sidepos q hq r hsize + ⟨⟨j, Sum.inr i⟩, b, v⟩) + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F‖) hd).trans_le he + +theorem allocatedPrincipalResidueGridDensity_error + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + {C W ζ ε : ℝ} {t M : ℕ} [NeZero M] (hC : 0 ≤ C) (hW : 0 ≤ W) + (hζ : 0 < ζ) (hζ1 : ζ ≤ 1) (hε : 0 ≤ ε) + (hMK : (M : ℝ) ≤ C * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ s ∈ rows, s.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card t ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (hcard : (M : ℝ) ^ rows.card ≤ W * (S.value : ℝ) ^ t) + (haccuracy : (2 * positiveModerateSpectrumConstant j.val rows.card P (C / (2 * gamma)) * + 2 ^ positiveModerateSpectrumExponent j.val rows.card + + W * (2 ^ positiveModerateLengthExponent j.val * positiveModerateLengthConstant j.val P) ^ t) * ζ ≤ ε) + (shift z : rows → ℤ) : + ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((allocatedPrincipalResidueJetPMF B U basis hR hσ S q hq r hsize j i rows shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal : ℝ) : ℂ) - + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z + (positiveModerateSpectrumCover rows M j.val P (C / (2 * gamma)) S.value ζ)‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + exact allocatedPrincipalResidueGridDensity_error_of_tail B U basis hR hσ S q hq r hsize + j i hactive rows shift M + (positiveModerateSpectrumCover rows M j.val P (C / (2 * gamma)) S.value ζ) + (allocatedPrincipalResidueSpectrum_tail B U basis S q hq r hsize j i hactive hR + A hA P hcP hsP hC hW hζ hζ1 hε (Nat.pos_of_ne_zero (NeZero.ne M)) hMK + rows hrows hB hcard haccuracy) z + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (hq : 0 < q) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hsize : ∀ v, (Fintype.card α + 1) * q ≤ allocatedPrincipalSides B U basis S v) +variable (j : Fin m) (i : Fin (n j)) + +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "sidepos" => allocatedPrincipalSides_pos B U basis S +local notation "sources" => allocatedPrincipalResidueSources B U basis S q hq r hsize j i + +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +local notation "csource" => allocatedPrincipalNormalizedSource B U basis hR S j i hactive +local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i)) + +theorem allocatedPrincipalResidueGridDensity_error_of_grid + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + {C ζ ε : ℝ} {M : ℕ} [NeZero M] (hC : 0 ≤ C) + (hζ : 0 < ζ) (hζ1 : ζ ≤ 1) (hε : 0 ≤ ε) + (hMK : (M : ℝ) ≤ C * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ s ∈ rows, s.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (haccuracy : (2 * positiveModerateSpectrumConstant j.val rows.card P (C / (2 * gamma)) * + 2 ^ positiveModerateSpectrumExponent j.val rows.card + + C ^ rows.card * (2 ^ positiveModerateLengthExponent j.val * positiveModerateLengthConstant j.val P) ^ + ((layerTailDegree m + 1) * rows.card)) * ζ ≤ ε) + (shift z : rows → ℤ) : + ‖(((basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((allocatedPrincipalResidueJetPMF B U basis hR hσ S q hq r hsize j i rows shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal : ℝ) : ℂ) - + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z + (positiveModerateSpectrumCover rows M j.val P (C / (2 * gamma)) S.value ζ)‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + exact allocatedPrincipalResidueGridDensity_error B U basis hR hσ S q hq r hsize j i hactive + A hA P hcP hsP hC (pow_nonneg hC _) hζ hζ1 hε hMK rows hrows hB + (allocatedGrid_modulus_cardinality B U basis S j i hgrid hC hMK rows.card) + haccuracy shift z + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueInterpolationMixture.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueInterpolationMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c823701a3a55a2b774e73a57736c90be2370ccb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueInterpolationMixture.lean @@ -0,0 +1,620 @@ +import OAI.Combinatorics.Progressions.Estimates.PositiveFiberMarginal +import OAI.Combinatorics.Progressions.Geometry.PrincipalCoordinatePartition +import OAI.Combinatorics.Progressions.Probability.AllocatedActiveAxisSourceLaw +import OAI.Combinatorics.Progressions.Sampling.AllocatedWeightedGridMixture + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ t, 0 < L t) +variable (q : ℕ) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B h L hL).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +noncomputable def principalSupportedCoordinateWeights (t : PrincipalTupleIndex B h) : + FiniteProbabilityWeights (IntegerScalarCubeBox α (L t)) := + (integerScalarCubeWeights α (L t) (hL t)).condition + (Finset.univ.filter (fun z => (fun i => ((z i : ℤ) : ZMod q)) = r t)) + (FiniteProbabilityWeights.coordinate_fiber_mass_pos + (fun t => integerScalarCubeWeights α (L t) (hL t)) + (fun t (z : IntegerScalarCubeBox α (L t)) i => ((z i : ℤ) : ZMod q)) r hcell t) + +local notation "coord" => principalSupportedCoordinateWeights B h L hL q r hcell +local notation "conditioned" => FiniteProbabilityWeights.condition + (principalTupleWeights B h L hL) + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell + +theorem principalSupportedResidueWeights_eq_pi : + (conditioned) = FiniteProbabilityWeights.pi (coord) := + FiniteProbabilityWeights.pi_condition_positive_fiber + (fun t => integerScalarCubeWeights α (L t) (hL t)) + (fun t (z : IntegerScalarCubeBox α (L t)) i => ((z i : ℤ) : ZMod q)) r hcell + +theorem principalSupportedResiduePMF_eq_product : + (conditioned).toPMF = dependentProductPMF (fun t => ((coord) t).toPMF) := by + exact (congrArg (fun p : FiniteProbabilityWeights (PrincipalIntegerTuples B h α L) => p.toPMF) + (principalSupportedResidueWeights_eq_pi B h L hL q r hcell)).trans + (FiniteProbabilityWeights.toPMF_pi (coord)) + +noncomputable def principalSupportedAxisTuplePMF (a : D) : + PMF (∀ b : B a, ∀ v : Fin (h a), IntegerScalarCubeBox α (L ⟨a, b, v⟩)) := + dependentProductPMF (fun b => dependentProductPMF (fun v => ((coord) ⟨a, b, v⟩).toPMF)) + +theorem principalSupportedResidue_full_axis_law : + (conditioned).toPMF.map (fun y (a : D) (b : B a) (v : Fin (h a)) => y ⟨a, b, v⟩) = + dependentProductPMF (principalSupportedAxisTuplePMF B h L hL q r hcell) := by + have hp := congrArg (fun p : PMF (PrincipalIntegerTuples B h α L) => + p.map (fun y (a : D) (b : B a) (v : Fin (h a)) => y ⟨a, b, v⟩)) + (principalSupportedResiduePMF_eq_product B h L hL q r hcell) + exact hp.trans (dependentProductPMF_sigma_curry + (fun a b v => ((coord) ⟨a, b, v⟩).toPMF)) + +theorem principalSupportedResidue_selected_axis_law {A : Type*} [Fintype A] + (e : A → D) (he : Function.Injective e) : + (conditioned).toPMF.map (fun y (a : A) (b : B (e a)) (v : Fin (h (e a))) => y ⟨e a, b, v⟩) = + dependentProductPMF (fun a => principalSupportedAxisTuplePMF B h L hL q r hcell (e a)) := by + have hp := congrArg (fun p : PMF (∀ a : D, ∀ b : B a, ∀ v : Fin (h a), + IntegerScalarCubeBox α (L ⟨a, b, v⟩)) => p.map (fun y a => y (e a))) + (principalSupportedResidue_full_axis_law B h L hL q r hcell) + rw [PMF.map_comp] at hp + exact hp.trans (dependentProductPMF_marginal + (principalSupportedAxisTuplePMF B h L hL q r hcell) e he) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +theorem scalarCubeResidue_fiber_eq {α : Type*} [Fintype α] [DecidableEq α] + (L q : ℕ) (r : Option α → ZMod q) : + Finset.univ.filter (fun x : IntegerScalarCubeBox α L => + (fun i => ((x i : ℤ) : ZMod q)) = r) = + scalarCubeResidueSet α L (fun _ => q) r := by + ext x + simp only [Finset.mem_filter, Finset.mem_univ, true_and, + mem_scalarCubeResidueSet, funext_iff] + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ t, 0 < L t) +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B h L hL).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +theorem principalSupportedResidue_marginal {V : Type*} [Fintype V] + (e : V → PrincipalTupleIndex B h) (he : Function.Injective e) + (hsize : ∀ v, (Fintype.card α + 1) * q ≤ L (e v)) : + ((principalTupleWeights (α := α) B h L hL).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).toPMF.map + (fun y v => y (e v)) = + dependentProductPMF (fun v => + (normalizedUniformCubeSource α (L (e v)) q (hL (e v)) (fun _ => q) (r (e v)) + (fun _ => hq) (fun _ => le_rfl) (hsize v)).source.toPMF) := by + have hpositive : 0 < (FiniteProbabilityWeights.pi + (fun t => integerScalarCubeWeights α (L t) (hL t))).mass + (Finset.univ.filter (fun y => (fun t i => ((y t i : ℤ) : ZMod q)) = r)) := hcell + have hp := FiniteProbabilityWeights.pi_condition_positive_fiber_marginal + (fun t => integerScalarCubeWeights α (L t) (hL t)) + (fun t (x : IntegerScalarCubeBox α (L t)) i => ((x i : ℤ) : ZMod q)) r hpositive e he + refine hp.trans ?_ + apply congrArg (fun p : ∀ v, PMF (IntegerScalarCubeBox α (L (e v))) => dependentProductPMF p) + funext v + rw [normalizedUniformCubeSource_toPMF] + simp only [scalarCubeResidueWeights] + congr 2 + exact scalarCubeResidue_fiber_eq (L (e v)) q (r (e v)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical NNReal + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ t, 0 < L t) +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (a : D) (hsize : ∀ b v, (Fintype.card α + 1) * q ≤ L ⟨a, b, v⟩) + +noncomputable def principalSupportedAxisSources (b : B a) (v : Fin (h a)) : + NormalizedScalarCubeSource α := + normalizedUniformCubeSource α (L ⟨a, b, v⟩) q (hL ⟨a, b, v⟩) (fun _ => q) (r ⟨a, b, v⟩) + (fun _ => hq) (fun _ => le_rfl) (hsize b v) + +local notation "sources" => principalSupportedAxisSources B h L hL q hq r a hsize + +omit [Fintype D] [DecidableEq D] [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] in +theorem principalSupportedAxisSources_primitive (b : B a) (v : Fin (h a)) (A : ℝ≥0) : + ScalarCubePrimitiveBudget ((sources) b v) A (scalarCubePrimitiveEnvelope α A 1 0 q) := + normalizedUniformCubeSource_primitive α (L ⟨a, b, v⟩) q (hL ⟨a, b, v⟩) (fun _ => q) + (r ⟨a, b, v⟩) (fun _ => hq) (fun _ => le_rfl) (hsize b v) A + +variable (hcell : 0 < (principalTupleWeights (α := α) B h L hL).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +theorem principalSupportedResidue_axis_marginal : + ((principalTupleWeights (α := α) B h L hL).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).toPMF.map + (fun y (b : B a) (v : Fin (h a)) => y ⟨a, b, v⟩) = + dependentProductPMF (fun b => dependentProductPMF (fun v => ((sources) b v).source.toPMF)) := by + have hp := principalSupportedResidue_marginal B h L hL q hq r hcell + (fun t : B a × Fin (h a) => ⟨a, t⟩) + (by intro x y hxy; simpa using hxy) (fun t => hsize t.1 t.2) + have ht := congrArg (fun p => p.map (fun x b v => x (b, v))) hp + rw [PMF.map_comp] at ht + exact ht.trans (dependentProductPMF_curry + (fun b v => ((sources) b v).source.toPMF)) + +theorem principalSupportedResidue_axis_integer_law : + ((principalTupleWeights (α := α) B h L hL).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).toPMF.map + (fun y (b : B a) (v : Fin (h a)) i => (y ⟨a, b, v⟩ i : ℤ)) = + dependentProductPMF (fun b => (dependentProductPMF + (fun v => ((sources) b v).source.toPMF)).map (fun y v i => (y v i : ℤ))) := by + have hp := congrArg (fun p => p.map (fun x b v i => (x b v i : ℤ))) + (principalSupportedResidue_axis_marginal B h L hL q hq r a hsize hcell) + rw [PMF.map_comp] at hp + exact hp.trans (dependentProductPMF_map + (fun b => dependentProductPMF (fun v => ((sources) b v).source.toPMF)) + (fun _ y v i => (y v i : ℤ))) + +theorem principalSupportedResidue_axis_jet_sum_law + (c : B a → NormalizedScalarCubeSource Empty) + (rows : Finset (Finset α)) (offset : B a → ℤ) (shift : rows → ℤ) : + (weightedModerateIntegerProductSource c (sources)).toPMF.map + (weightedModerateIntegerJetSum c (sources) rows offset shift) = + (dependentProductPMF (fun b => (c b).source.toPMF.map (fun z => (z none : ℤ)))).bind + (fun coeff => ((principalTupleWeights (α := α) B h L hL).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).toPMF.map + (fun y => shift + ∑ b, fun t : rows => (offset b + coeff b) * + integerBooleanBlockJet (fun v i => (y ⟨a, b, v⟩ i : ℤ)) t)) := by + refine (weightedModerateProductSource_jet_sum_law c (sources) rows offset shift).trans ?_ + have hp := congrArg (fun p : PMF (B a → Fin (h a) → Option α → ℤ) => + (dependentProductPMF (fun b => (c b).source.toPMF.map (fun z => (z none : ℤ)))).bind + (fun coeff => p.map (fun y => shift + ∑ b, fun t : rows => + (offset b + coeff b) * integerBooleanBlockJet (y b) t))) + (principalSupportedResidue_axis_integer_law B h L hL q hq r a hsize hcell).symm + simpa only [PMF.map_comp, Function.comp_def] using hp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) +variable (q : ℕ) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B h L hL).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +noncomputable def principalSupportedAxisWeights (P : D → Prop) [DecidablePred P] : + FiniteProbabilityWeights (PrincipalAxisTuples (α := α) P L) := + FiniteProbabilityWeights.pi + (fun j : PrincipalTupleIndex (fun d : {d // P d} => B d.val) (fun d => h d.val) => + principalSupportedCoordinateWeights B h L hL q r hcell ⟨j.1.val, j.2⟩) + +local notation "conditioned" => FiniteProbabilityWeights.condition (principalTupleWeights (α := α) B h L hL) + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell +local notation "axisWeights" => principalSupportedAxisWeights B h L hL q r hcell + +theorem principalSupportedResidueWeights_partition_weight + (P : D → Prop) [DecidablePred P] (y : PrincipalIntegerTuples B h α L) : + (conditioned).weight y = + (axisWeights P).weight (principalAxisRestrict P y) * + (axisWeights (fun d => ¬P d)).weight (principalAxisRestrict (fun d => ¬P d) y) := by + rw [principalSupportedResidueWeights_eq_pi B h L hL q r hcell] + exact principalCoordinateWeights_partition_weight P L + (principalSupportedCoordinateWeights B h L hL q r hcell) y + +theorem principalSupportedResidueWeights_partition + (P : D → Prop) [DecidablePred P] (f : PrincipalIntegerTuples B h α L → ℂ) : + (conditioned).complexMean f = + (axisWeights P).complexMean (fun u => + (axisWeights (fun d => ¬P d)).complexMean (fun v => f (principalAxisJoin P u v))) := by + rw [principalSupportedResidueWeights_eq_pi B h L hL q r hcell] + exact principalCoordinateWeights_partition P L + (principalSupportedCoordinateWeights B h L hL q r hcell) f + +theorem principalSupportedResidueWeights_partition_mul + (P : D → Prop) [DecidablePred P] + (φ : PrincipalAxisTuples (α := α) P L → ℂ) + (ψ : PrincipalAxisTuples (α := α) (fun d => ¬P d) L → ℂ) : + (conditioned).complexMean (fun y => + φ (principalAxisRestrict P y) * ψ (principalAxisRestrict (fun d => ¬P d) y)) = + (axisWeights P).complexMean φ * (axisWeights (fun d => ¬P d)).complexMean ψ := by + rw [principalSupportedResidueWeights_partition B h L hL q r hcell P] + simp only [principalAxisRestrict_join_left, principalAxisRestrict_join_right, + FiniteProbabilityWeights.complexMean_mul_left] + simp only [FiniteProbabilityWeights.complexMean, Finset.sum_mul, mul_assoc] + +theorem principalSupportedAxisWeights_eq_residueWeights + (P : D → Prop) [DecidablePred P] (hq : 0 < q) + (hsize : ∀ j : PrincipalTupleIndex (fun d : {d // P d} => B d.val) (fun d => h d.val), + (Fintype.card α + 1) * q ≤ principalAxisLength P L j) : + axisWeights P = + principalResidueWeights (fun d : {d // P d} => B d.val) (fun d => h d.val) + (principalAxisLength P L) (fun j => hL ⟨j.1.val, j.2⟩) q hq + (fun j => r ⟨j.1.val, j.2⟩) hsize := by + unfold principalSupportedAxisWeights principalResidueWeights + congr 1 + funext j + simp only [principalSupportedCoordinateWeights, scalarCubeResidueWeights, + principalAxisLength] + congr 1 + exact scalarCubeResidue_fiber_eq (L ⟨j.1.val, j.2⟩) q (r ⟨j.1.val, j.2⟩) + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (j : Fin m) (i : Fin (n j)) +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +variable (q : ℕ) (hq : 0 < q) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hsize : (Fintype.card α + 1) * q ≤ S.value) + +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "sides_pos" => allocatedPrincipalSides_pos B U basis S + +noncomputable def allocatedActiveResidueSources + (b : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)) : NormalizedScalarCubeSource α := + principalSupportedAxisSources B (layerSamplerDegree I n) (sides) (sides_pos) + q hq r ⟨j, Sum.inr i⟩ + (fun b v => by + simpa only [allocatedPrincipalSides_active B U basis S j i hactive b v] using hsize) b v + +local notation "sources" => allocatedActiveResidueSources B U basis S j i hactive q hq r hsize + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedActiveResidueSources_length (b : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)) : + ((sources) b v).length = S.value := + allocatedPrincipalSides_active B U basis S j i hactive b v + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedActiveResidueSources_primitive + (b : B ⟨j, Sum.inr i⟩) (v : Fin (j.val + 1)) (A : ℝ≥0) : + ScalarCubePrimitiveBudget ((sources) b v) A (scalarCubePrimitiveEnvelope α A 1 0 q) := + principalSupportedAxisSources_primitive B (layerSamplerDegree I n) (sides) (sides_pos) + q hq r ⟨j, Sum.inr i⟩ _ b v A + +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +theorem allocatedActiveResidueSources_jet_sum_law + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (rows : Finset (Finset α)) (shift : rows → ℤ) : + (weightedModerateIntegerProductSource + (fun _ : B ⟨j, Sum.inr i⟩ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive) + (sources)).toPMF.map + (weightedModerateIntegerJetSum + (fun _ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive) + (sources) rows (fun _ => 0) shift) = + (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b))).bind + (fun coeff => ((principalTupleWeights (α := α) B (layerSamplerDegree I n) + (sides) (sides_pos)).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).toPMF.map + (fun y => shift + ∑ b, fun t : rows => coeff b * + integerBooleanBlockJet (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t)) := by + have hp := principalSupportedResidue_axis_jet_sum_law B (layerSamplerDegree I n) + (sides) (sides_pos) q hq r ⟨j, Sum.inr i⟩ + (fun b v => by + simpa only [allocatedPrincipalSides_active B U basis S j i hactive b v] using hsize) + hcell (fun _ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive) + rows (fun _ => 0) shift + have hc : (dependentProductPMF (fun _ : B ⟨j, Sum.inr i⟩ => + (allocatedPrincipalNormalizedSource B U basis hR S j i hactive).source.toPMF.map + (fun z => (z none : ℤ)))) = + dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b)) := + congrArg (fun p : B ⟨j, Sum.inr i⟩ → PMF ℤ => dependentProductPMF p) + (funext (fun b => allocatedPrincipalNormalizedSource_law B U basis hR hσ S j i hactive b)) + rw [hc] at hp + simp only [zero_add] at hp + convert hp using 6 <;> rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (j : Fin m) (i : Fin (n j)) +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +variable (q : ℕ) (hq : 0 < q) +variable (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hsize : (Fintype.card α + 1) * q ≤ S.value) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +local notation "sources" => allocatedActiveResidueSources B U basis S j i hactive q hq r hsize + +theorem allocatedActiveResidueSources_coeff_jet_law + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (rows : Finset (Finset α)) (shift : rows → ℤ) : + (weightedModerateIntegerProductSource + (fun _ : B ⟨j, Sum.inr i⟩ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive) + sources).toPMF.map + (fun x => (fun b => ((x b).1 none : ℤ), + weightedModerateIntegerJetSum + (fun _ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive) + sources rows (fun _ => 0) shift x)) = + (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b))).bind + (fun coeff => ((principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell).toPMF.map + (fun y => (coeff, shift + ∑ b, fun t : rows => coeff b * + integerBooleanBlockJet (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t))) := by + let c := fun _ : B ⟨j, Sum.inr i⟩ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive + have hp := congrArg + (fun p : PMF (B ⟨j, Sum.inr i⟩ → ℤ × (Fin (j.val + 1) → Option α → ℤ)) => + p.map (fun z => (fun b => (z b).1, + shift + ∑ b, fun t : rows => (z b).1 * integerBooleanBlockJet (z b).2 t))) + (weightedModerateProductSource_pair_law c sources) + rw [PMF.map_comp, PMF.map_bind] at hp + have hc : (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + (c b).source.toPMF.map (fun z => (z none : ℤ)))) = + dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b)) := + congrArg (fun p : B ⟨j, Sum.inr i⟩ → PMF ℤ => dependentProductPMF p) + (funext (fun b => allocatedPrincipalNormalizedSource_law B U basis hR hσ S j i hactive b)) + rw [hc] at hp + have ht := principalSupportedResidue_axis_integer_law B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) + q hq r ⟨j, Sum.inr i⟩ + (fun b v => by simpa only [allocatedPrincipalSides_active B U basis S j i hactive b v] using hsize) + hcell + have htarget := congrArg + (fun p : PMF (B ⟨j, Sum.inr i⟩ → Fin (j.val + 1) → Option α → ℤ) => + (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b))).bind + (fun coeff => p.map (fun y => (coeff, + shift + ∑ b, fun t : rows => coeff b * integerBooleanBlockJet (y b) t)))) ht.symm + simp only [PMF.map_comp, Function.comp_def] at hp + dsimp only [layerSamplerDegree] at hp htarget ⊢ + have hfinal := hp.trans htarget + simp only [PMF.map_comp, Function.comp_def] at hfinal + convert hfinal using 2 + · funext x + congr 1 + funext t + simp only [weightedModerateIntegerJetSum, Pi.add_apply, Finset.sum_apply, + weightedModerateIntegerBlock, zero_add] + · rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +variable (j : Fin m) (i : Fin (n j)) + +local notation "conditioned" => FiniteProbabilityWeights.condition + (principalTupleWeights B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)) + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell + +noncomputable def allocatedSupportedResidueJetPMF + (rows : Finset (Finset α)) (shift : rows → ℤ) : PMF (rows → ℤ) := + (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b))).bind + (fun coeff => (conditioned).toPMF.map (fun y => + shift + ∑ b, fun t : rows => coeff b * + integerBooleanBlockJet (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t)) + +theorem allocatedSupportedResidueJetPMF_source + (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) + (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + (rows : Finset (Finset α)) (shift : rows → ℤ) : + (weightedModerateIntegerProductSource + (fun _ : B ⟨j, Sum.inr i⟩ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive) + (allocatedActiveResidueSources B U basis S j i hactive q hq r hsize)).toPMF.map + (weightedModerateIntegerJetSum + (fun _ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive) + (allocatedActiveResidueSources B U basis S j i hactive q hq r hsize) + rows (fun _ => 0) shift) = + allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift := + allocatedActiveResidueSources_jet_sum_law B U basis S j i hactive q hq r hsize hcell + hR hσ rows shift + +theorem allocatedSupportedResidueJetPMF_constant_mixture + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (rows : Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) : + (conditioned).toPMF.bind (fun y => + integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i)) = + (allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ none)).bind + (fun c => allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows + (fun t => booleanCoefficient (fun _ : Finset α => c) t)) := by + let p := (conditioned).toPMF + let a := dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b)) + let c := allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ none) + let f (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S)) + (z : ℤ) (coeff : B ⟨j, Sum.inr i⟩ → ℤ) : rows → ℤ := + (fun t : rows => booleanCoefficient (fun _ : Finset α => z) t) + + ∑ b, fun t : rows => coeff b * integerBooleanBlockJet + (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t + have hpoint y : integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i) = + c.bind (fun z => a.map (f y z)) := by + rw [allocatedPhysicalGridJetPMF_principal B U basis hR hσ S j i hgrid, + independentProductPMF_option, PMF.map_bind] + simp only [PMF.map_comp] + apply congrArg (fun k : ℤ → PMF (rows → ℤ) => c.bind k) + funext z + apply congrArg (fun g : (B ⟨j, Sum.inr i⟩ → ℤ) → rows → ℤ => a.map g) + funext coeff t + simp only [Function.comp_apply, f, Pi.add_apply, Finset.sum_apply, + Option.elim_none, Option.elim_some] + simp_rw [hpoint] + change p.bind (fun y => c.bind (fun z => a.map (f y z))) = + c.bind (fun z => a.bind (fun coeff => p.map (fun y => f y z coeff))) + refine (PMF.bind_comm p c (fun y z => a.map (f y z))).trans ?_ + apply congrArg (fun k : ℤ → PMF (rows → ℤ) => c.bind k) + funext z + exact PMF.bind_comm p a (fun y coeff => PMF.pure (f y z coeff)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +variable (j : Fin m) (i : Fin (n j)) + +local notation "conditioned" => FiniteProbabilityWeights.condition + (principalTupleWeights B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)) + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell + +local notation "constantLaw" => allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) (Sigma.mk j (Sum.inr i)) none) + +theorem allocatedResidueInterpolation_constant_mixture + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (rows : Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) (z : rows → ℝ) : + (conditioned).mean (fun y => integerRowMassInterpolation (basisAxisScale (basis j) i) + (integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i)) z) = + ∫ c, integerRowMassInterpolation (basisAxisScale (basis j) i) + (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows + (fun t => booleanCoefficient (fun _ : Finset α => c) t)) z ∂(constantLaw).toMeasure := by + have hm := allocatedSupportedResidueJetPMF_constant_mixture B U basis hR hσ S q r hcell + j i hgrid rows x + have he := congrArg (fun μ : PMF (rows → ℤ) => + integerRowMassInterpolation (basisAxisScale (basis j) i) μ z) hm + rw [integerRowMassInterpolation_finite_bind _ (Nat.cast_nonneg _), + integerRowMassInterpolation_bind _ (Nat.cast_nonneg _)] at he + exact he + +theorem allocatedNormalizedResidueInterpolation_constant_mixture + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (rows : Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) (z : rows → ℝ) : + (conditioned).mean (fun y => normalizedIntegerRowInterpolation (basisAxisScale (basis j) i) + (integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i)) z) = + ∫ c, normalizedIntegerRowInterpolation (basisAxisScale (basis j) i) + (allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows + (fun t => booleanCoefficient (fun _ : Finset α => c) t)) z ∂(constantLaw).toMeasure := by + have hm := allocatedSupportedResidueJetPMF_constant_mixture B U basis hR hσ S q r hcell + j i hgrid rows x + have he := congrArg (fun μ : PMF (rows → ℤ) => + normalizedIntegerRowInterpolation (basisAxisScale (basis j) i) μ z) hm + rw [normalizedIntegerRowInterpolation_finite_bind _ (Nat.cast_nonneg _), + normalizedIntegerRowInterpolation_bind _ (Nat.cast_nonneg _)] at he + exact he + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueLabelCount.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueLabelCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b50d44eb8620e57e38d4b4dea0046d807c650c5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueLabelCount.lean @@ -0,0 +1,89 @@ +import Mathlib.LinearAlgebra.Dimension.Constructions +import OAI.Combinatorics.Progressions.Fourier.LatticeCoordinateResidueFourier + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule +open scoped BigOperators Classical + +theorem standardLatticeCoordinates_card {D I J : Type*} + [Fintype D] [Fintype I] [Fintype J] + (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) : + Fintype.card (J ⊕ I) = Fintype.card D := by + simpa only [Module.finrank_fintype_fun_eq_card] using + (standardLatticeCoordinates W bW bP hP).finrank_eq.symm + +theorem latticeCoordinate_frequency_count {D I J : Type*} + [Fintype D] [Fintype I] [Fintype J] + (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) (M : ℕ) : + Fintype.card ((J ⊕ I) → Fin M) = M ^ Fintype.card D := by + rw [Fintype.card_fun, Fintype.card_fin, standardLatticeCoordinates_card W bW bP hP] + +theorem latticeCoordinate_congruence_fourier_ambient_bound {D I J : Type*} + [Fintype D] [DecidableEq D] [Fintype I] [Fintype J] + (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) + (M : ℕ) [NeZero M] (Good : (J ⊕ I → ZMod M) → Prop) [DecidablePred Good] : + ∃ (c : ((J ⊕ I) → Fin M) → ℂ) (ell : ((J ⊕ I) → Fin M) → D → Fin M), + (∑ k, ‖c k‖) ≤ (M : ℝ) ^ Fintype.card D ∧ + (∀ k j, 0 ≤ ((ell k j).val : ℝ) / M ∧ ((ell k j).val : ℝ) / M < 1) ∧ + ∀ β, (if Good (integerResidueMap (J ⊕ I) M (standardLatticeCoordinates W bW bP hP β)) + then (1 : ℂ) else 0) = + ∑ k, c k * CircleFourier.character + ((∑ j, (((ell k j).val : ℝ) / M) * (β j : ℝ) : ℝ) : CircleFourier.Circle) := by + simpa only [standardLatticeCoordinates_card W bW bP hP] using + latticeCoordinate_congruence_fourier_expansion W bW bP hP M Good + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped BigOperators Classical + +variable {m : ℕ} {n : Fin m → ℕ} +variable {J E : Fin m → Type*} [∀ j, Fintype (J j)] [∀ j, Fintype (E j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +include hb bW in +theorem allocatedResidueLabel_card (period : ℕ) [NeZero period] : + Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) = + period ^ (∑ j, Fintype.card (J j)) := by + have hc (j) : n j + Fintype.card (E j) = Fintype.card (J j) := by + simpa only [Fintype.card_sum, Fintype.card_fin] using + standardLatticeCoordinates_card (euclideanSubspace (U j)) (bW j) (b j) (hb j) + simp only [Fintype.card_prod, Fintype.card_pi, ZMod.card, + Finset.prod_const, Finset.card_univ, Fintype.card_fin] + rw [← Finset.prod_mul_distrib] + simp_rw [← pow_add, hc] + exact Finset.prod_pow_eq_pow_sum _ _ _ + +include hb bW in +theorem allocatedResidueLabels_le_exp {S : Type*} [Fintype S] + (period : ℕ) [NeZero period] {P : ℝ} (hperiod : (period : ℝ) ≤ Real.exp P) : + (Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card S ≤ + Real.exp (Fintype.card S * ((∑ j, Fintype.card (J j) : ℕ) * P)) := by + rw [allocatedResidueLabel_card U b hb bW, Nat.cast_pow, Real.exp_nat_mul, Real.exp_nat_mul] + exact pow_le_pow_left₀ (by positivity) + (pow_le_pow_left₀ (Nat.cast_nonneg _) hperiod _) _ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueSitePrimitiveAverage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueSitePrimitiveAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..82dd8c6c8ed975123ff36f18a9046e22b3972e05 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueSitePrimitiveAverage.lean @@ -0,0 +1,1189 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedWholeProfileEnvelope +import OAI.Combinatorics.Progressions.Geometry.SupportedFiberFiniteMeanError + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {X R K I : Type*} [Fintype X] [DecidableEq X] +variable [Fintype R] [DecidableEq R] [Fintype K] [Fintype I] +variable (p : FiniteProbabilityWeights X) (F : X → R) +variable (stride : I → ℕ) (cells : Finset (ColumnResiduePattern K I stride)) +variable (W : K × I → ℝ) (hW : ∀ z, 0 < W z) +variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z) +variable (f : X → (K × I → ℤ) → ℂ) (target : R → (K × I → ℤ) → ℂ) + +include hW hZ + +theorem selectedResidue_supported_fiber_error (ε : R → ℝ) + (he : ∀ r (hr : 0 < p.mass (Finset.univ.filter (fun x => F x = r))), + selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖) ≤ ε r) : + selectedResidueDensityMass stride cells W + (fun z => ‖p.complexMean (fun x => f x z) - + (p.fiberLaw F).complexMean (fun r => target r z)‖) ≤ (p.fiberLaw F).mean ε := by + have h := p.mean_norm_supported_fiber_error (selectedResidueFiniteLaw stride cells W hW hZ) + F (fun x z => f x z.val) (fun r z => target r z.val) ε (fun r hr => by + rw [selectedResidueFiniteLaw_densityMass stride cells W hW hZ + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖)] + exact he r hr) + rw [selectedResidueFiniteLaw_densityMass stride cells W hW hZ + (fun z => ‖p.complexMean (fun x => f x z) - (p.fiberLaw F).complexMean (fun r => target r z)‖)] at h + exact h + +theorem selectedResidue_supported_fiber_error_uniform {ε : ℝ} + (he : ∀ r (hr : 0 < p.mass (Finset.univ.filter (fun x => F x = r))), + selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖) ≤ ε) : + selectedResidueDensityMass stride cells W + (fun z => ‖p.complexMean (fun x => f x z) - + (p.fiberLaw F).complexMean (fun r => target r z)‖) ≤ ε := by + simpa only [FiniteProbabilityWeights.mean_const] using + selectedResidue_supported_fiber_error p F stride cells W hW hZ f target (fun _ => ε) he + +theorem selectedResidue_supported_fiber_test_error (ε : R → ℝ) + (he : ∀ r (hr : 0 < p.mass (Finset.univ.filter (fun x => F x = r))), + selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖) ≤ ε r) + (φ : (K × I → ℤ) → ℂ) (hφ : ∀ z, ‖φ z‖ ≤ 1) : + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + ((p.complexMean (fun x => f x z) - (p.fiberLaw F).complexMean (fun r => target r z)) * φ z)‖ ≤ + (p.fiberLaw F).mean ε := by + have h := p.complexMean_supported_fiber_test_error (selectedResidueFiniteLaw stride cells W hW hZ) + F (fun x z => f x z.val) (fun r z => target r z.val) ε (fun r hr => by + rw [selectedResidueFiniteLaw_densityMass stride cells W hW hZ + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖)] + exact he r hr) (fun z => φ z.val) (fun z => hφ z.val) + rw [selectedResidueFiniteLaw_complexMean stride cells W hW hZ + (fun z => (p.complexMean (fun x => f x z) - (p.fiberLaw F).complexMean (fun r => target r z)) * φ z)] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {X R K I : Type*} [Fintype X] [DecidableEq X] +variable [Fintype R] [DecidableEq R] [Fintype K] [Fintype I] +variable (p : FiniteProbabilityWeights X) (F : X → R) +variable (stride : I → ℕ) (cells : Finset (ColumnResiduePattern K I stride)) +variable (W : K × I → ℝ) (hW : ∀ z, 0 < W z) +variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z) +variable (f : X → (K × I → ℤ) → ℂ) (target : R → (K × I → ℤ) → ℂ) +variable (weight : R → (K × I → ℤ) → ℂ) {C : ℝ} (hC : 0 ≤ C) +variable (hweight : ∀ r z, ‖weight r z‖ ≤ C) + +include hW hZ hC hweight + +omit [Fintype R] in +theorem selectedResidue_weighted_condition_error (r : R) + (hr : 0 < p.mass (Finset.univ.filter (fun x => F x = r))) {ε : ℝ} + (he : selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖) ≤ ε) : + selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => weight (F x) z * f x z) - + weight r z * target r z‖) ≤ C * ε := by + let law := selectedResidueFiniteLaw stride cells W hW hZ + rw [← selectedResidueFiniteLaw_densityMass stride cells W hW hZ + (fun z => ‖(p.condition _ hr).complexMean (fun x => weight (F x) z * f x z) - + weight r z * target r z‖)] + have hid (z : K × I → ℤ) : + (p.condition _ hr).complexMean (fun x => weight (F x) z * f x z) - weight r z * target r z = + weight r z * ((p.condition _ hr).complexMean (fun x => f x z) - target r z) := by + rw [p.condition_complexMean_fiber_mul F r hr (fun x => f x z) (fun r => weight r z), mul_sub] + calc + _ ≤ law.mean (fun z => C * ‖(p.condition _ hr).complexMean (fun x => f x z.val) - target r z.val‖) := by + apply law.mean_mono + intro z + rw [hid, norm_mul] + exact mul_le_mul_of_nonneg_right (hweight r z.val) (norm_nonneg _) + _ = C * selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖) := by + rw [law.mean_const_mul] + exact congrArg (fun a : ℝ => C * a) + (selectedResidueFiniteLaw_densityMass stride cells W hW hZ + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖)) + _ ≤ C * ε := mul_le_mul_of_nonneg_left he hC + +theorem selectedResidue_supported_fiber_weighted_error (ε : R → ℝ) + (he : ∀ r (hr : 0 < p.mass (Finset.univ.filter (fun x => F x = r))), + selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖) ≤ ε r) : + selectedResidueDensityMass stride cells W + (fun z => ‖p.complexMean (fun x => weight (F x) z * f x z) - + (p.fiberLaw F).complexMean (fun r => weight r z * target r z)‖) ≤ + C * (p.fiberLaw F).mean ε := by + have h := selectedResidue_supported_fiber_error p F stride cells W hW hZ + (fun x z => weight (F x) z * f x z) (fun r z => weight r z * target r z) + (fun r => C * ε r) (fun r hr => selectedResidue_weighted_condition_error + p F stride cells W hW hZ f target weight hC hweight r hr (he r hr)) + simpa only [FiniteProbabilityWeights.mean_const_mul] using h + +theorem selectedResidue_supported_fiber_weighted_test_error (ε : R → ℝ) + (he : ∀ r (hr : 0 < p.mass (Finset.univ.filter (fun x => F x = r))), + selectedResidueDensityMass stride cells W + (fun z => ‖(p.condition _ hr).complexMean (fun x => f x z) - target r z‖) ≤ ε r) + (φ : (K × I → ℤ) → ℂ) (hφ : ∀ z, ‖φ z‖ ≤ 1) : + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + ((p.complexMean (fun x => weight (F x) z * f x z) - + (p.fiberLaw F).complexMean (fun r => weight r z * target r z)) * φ z)‖ ≤ + C * (p.fiberLaw F).mean ε := by + have h := selectedResidue_supported_fiber_test_error p F stride cells W hW hZ + (fun x z => weight (F x) z * f x z) (fun r z => weight r z * target r z) + (fun r => C * ε r) (fun r hr => selectedResidue_weighted_condition_error + p F stride cells W hW hZ f target weight hC hweight r hr (he r hr)) φ hφ + simpa only [FiniteProbabilityWeights.mean_const_mul] using h + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +variable (q : ℕ) + +local notation "tupleType" => PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S) +local notation "tuples" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) +local notation "labelType" => PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q +abbrev AllocatedPositiveResidue := + {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q // + 0 < (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))} + +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} + +structure AllocatedResidueSiteWitness (r : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q)) where + representative : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S) + label_eq : principalResidueLabel q representative = r + positive : 0 < (tuples).mass (Finset.univ.filter + (fun y => principalResidueLabel q y = principalResidueLabel q representative)) + expansion : activeAxes → ScalarSiteExpansion.{0,0} (Finset (Fin dim)) + +variable {r : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q)} +variable (w : AllocatedResidueSiteWitness (dim := dim) B U b S q r) +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) ((Sigma.fst (Subtype.val a)).val + 1)}) → ℝ) → ℝ) + +noncomputable def allocatedResidueWitnessProfile : EuclideanJetLayers U (rowTypes) → ℂ := + allocatedActiveSiteProfile B U b hR hσ S rowSets x hb o bW d q + w.representative w.positive f w.expansion + +noncomputable def allocatedSupportedResidueSiteProfile + (W : (r : (AllocatedPositiveResidue (dim := dim) B U b S q)) → AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) + (r : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q)) : EuclideanJetLayers U (rowTypes) → ℂ := + if hr : 0 < (tuples).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r)) then + allocatedResidueWitnessProfile B U b hR hσ S q (W ⟨r, hr⟩) x hb o bW d f + else fun _ => 0 + +theorem allocatedSupportedResidueSiteProfile_positive + (W : (r : (AllocatedPositiveResidue (dim := dim) B U b S q)) → AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) + (r : (AllocatedPositiveResidue (dim := dim) B U b S q)) : + allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d f W r.val = + allocatedResidueWitnessProfile B U b hR hσ S q (W r) x hb o bW d f := by + unfold allocatedSupportedResidueSiteProfile + rw [dite_eq_left r.property] + +theorem allocatedResidueWitnessProfile_error + (hr : 0 < (tuples).mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))) : + (fun z => ((tuples).condition _ hr).complexMean (fun y => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y q f z : ℂ)) - + allocatedResidueWitnessProfile B U b hR hσ S q w x hb o bW d f z) = + allocatedSelectedConditionalError (O := rowTypes) B U b hR hσ S x (rows) hb o bW d q + w.representative w.positive (allocatedActiveGrid B U b S) f + (allocatedActiveSiteApproximation B U b S rowSets w.expansion) + (allocatedActiveNaturalVolume B U b S rowSets) := by + rcases w with ⟨y₀, hy₀, hcell, e⟩ + subst r + simpa only [allocatedResidueWitnessProfile, FiniteProbabilityWeights.complexMean_ofReal] using + allocatedActiveSiteProfile_error B U b hR hσ S rowSets x hb o bW d q y₀ hcell f e + +theorem allocatedSupportedResidueSiteProfile_error + (W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) + (r : AllocatedPositiveResidue (dim := dim) B U b S q) : + (fun z => ((tuples).condition _ r.property).complexMean (fun y => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y q f z : ℂ)) - + allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d f W r.val z) = + allocatedSelectedConditionalError (O := rowTypes) B U b hR hσ S x (rows) hb o bW d q + (W r).representative (W r).positive (allocatedActiveGrid B U b S) f + (allocatedActiveSiteApproximation B U b S rowSets (W r).expansion) + (allocatedActiveNaturalVolume B U b S rowSets) := by + rw [allocatedSupportedResidueSiteProfile_positive] + exact allocatedResidueWitnessProfile_error B U b hR hσ S q (W r) x hb o bW d f r.property + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +variable (q : ℕ) [NeZero q] + +variable {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q} +variable (w : AllocatedResidueSiteWitness (dim := dim) B U b S q r) + +def AllocatedResidueSiteSampling (δ : ℝ) : Prop := + ∀ {K : ℕ}, AllocatedBooleanRowsSampling.{uX,uJ,uG,uI,uB,uQ} m dim K (rowTypes) (rows) → ∀ + (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + + (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ rowSets (Sigma.fst (Subtype.val a))}) → ℝ) → ℝ) + (CM Cf : ℝ≥0) (_hCM : 1 ≤ (CM : ℝ)) (_hfb : ∀ v, |f v| ≤ Cf) + (_hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) w.representative) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) w.representative)) q) z ∧ + allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) w.representative) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) w.representative)) q) z ≤ CM) + (_hperiod : ∀ j, integerScalarLattice (rowTypes j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j w, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) w‖ ≤ C j * ‖w‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + {X : Type uX} [Fintype X] [DecidableEq X] + {P₀ : ℝ} (_hP : 0 ≤ P₀) (_hn : (Fintype.card X : ℝ) ≤ P₀) + (_hdim : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P₀) + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hmp : ∀ j e, coefficients (p j) e ∈ U j) + (stride : X → ℕ) (_hs : ∀ x, 0 < stride x) + {R₁ S₀ ρ ε : ℝ} (_hS : 0 ≤ S₀) (_hSP : S₀ ≤ Real.exp P₀) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P₀) (_hεP : 1 / ε ≤ Real.exp P₀) + (_hstride : ∀ x, (stride x : ℝ) ≤ S₀) + (H : X → ℝ) (_hsize : ∀ x, Real.exp ((P₀ + K) ^ K) ≤ H x) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R₁ (U j) (p j)) + (_hR : Real.exp ((P₀ + K) ^ K) ≤ R₁) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) (_hcells : cells.Nonempty) + (W : Option (Fin dim) × X → ℝ) (_hW : ∀ z, 0 < W z) (_hwidth : ∀ z, ρ * H z.2 ≤ W z) + {δFourier LFourier : ℝ} (_hδFourier : 0 < δFourier) (_hLFourier : 0 ≤ LFourier) + (_hamb : (Fintype.card (JetAmbientIndex (rowTypes) J) : ℝ) ≤ LFourier) + (_hδL : δFourier⁻¹ ≤ Real.exp LFourier), + let A := Real.toNNReal (coefficientDeckPeriodCap (rowTypes) Q q) * + CM ^ Fintype.card (LayerSamplerAxis I n) * Cf + (allocatedErrorKernelLip B U b S (O := rowTypes) (Real.toNNReal δ) A C V : ℝ) ≤ Real.exp LFourier → + Real.exp ((2 * LFourier + 2) ^ 4) ≤ Real.exp P₀ → + Real.exp (2 * LFourier * (2 * LFourier + 2) ^ 4) * + allocatedErrorKernelCap B U b S (O := rowTypes) (Real.toNNReal δ) A V ≤ Real.exp P₀ → + let error := allocatedSelectedConditionalError (O := rowTypes) B U b hR hσ S x (rows) + hb o bW d q w.representative w.positive (allocatedActiveGrid B U b S) f + (allocatedActiveSiteApproximation B U b S rowSets w.expansion) + (allocatedActiveNaturalVolume B U b S rowSets) + let mass := δ * A * + (2 * (∑ j, (C j : ℝ) * ((Fintype.card (J j) : ℝ) + 1)) + 1) ^ + Fintype.card (Σ a : LayerSamplerAxis I n, (rowTypes) a.1) + ∃ _hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W + (fun z => ‖error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z))‖) + ≤ mass + 2 * δFourier + ε + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "active" => allocatedActiveGrid B U b S +local notation "activeAxes" => {a : {a // grid a} // active a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "axisN" => allocatedGridNaturalScale B U b S +local notation "volumeN" => allocatedActiveNaturalVolume B U b S rowSets +local notation "rowFamily" => (fun a : (Σ j : Fin m, Fin (n j)) => rowSets (Sigma.fst a)) + +variable (hq : 0 < q) (hsize : (Fintype.card (Fin dim) + 1) * q ≤ S.value) +variable (P δ Λ : ℝ) +variable (M : {a : {a // allocatedGridAxis (I := I) U b S.value a} // allocatedActiveGrid B U b S a} → ℕ) +variable [∀ a, NeZero (M a)] + +local notation "pointTolerance" => allocatedSitePointTolerance (G := G) B rowSets δ +local notation "trueCap" => allocatedGridFamilyCap B (rowFamily) P + 1 +local notation "halfAccuracy" => uniformProductAccuracy (Fintype.card (Σ j : Fin m, Fin (n j))) trueCap pointTolerance / 2 +local notation "torus" => (fun a : activeAxes => allocatedGridTorusFactor B (Fin dim) (ig (Subtype.val a))) +local notation "cap" => (fun a : activeAxes => allocatedGridPointCap B P (ig (Subtype.val a)) (rowSets (Sigma.fst (ig (Subtype.val a))))) +local notation "siteH" => (fun a : activeAxes => + allocatedNaturalSiteRadius (G := G) B (Sigma.fst (ig (Subtype.val a))) (Sigma.snd (ig (Subtype.val a))) (rowSets (Sigma.fst (ig (Subtype.val a)))) + 1 / 4) +local notation "bias" => (fun a : activeAxes => positiveModerateRetainedBias (Fin.val (Sigma.fst (ig (Subtype.val a)))) + (Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) ((layerTailDegree m + 2) * Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) + P ((torus) a : ℝ) ((2 * ((torus) a : ℝ)) ^ Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) halfAccuracy) +local notation "freq" => (fun a : activeAxes => Real.toNNReal (positiveRetainedFrequencyBound + (Fin.val (Sigma.fst (ig (Subtype.val a)))) (Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) P ((torus) a : ℝ) ((bias) a))) +include hq hsize in +theorem exists_allocated_residue_site_sampling + (hP : 1 ≤ P) (hδ : 0 < δ) (hΛ : 0 ≤ Λ) + (hgamma : ∀ a : activeAxes, principalProfileSize (R (ig a.val).1) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (ig a.val).1 (ig a.val).2)) ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope (Fin dim) L 1 0 q ≤ P) + (hM : ∀ a, M a = (torus) a * axisN a.val) + (hB : ∀ a : activeAxes, positiveModerateSpectrumBlockCount (ig a.val).1.val + (rowSets (ig a.val).1).card ((layerTailDegree m + 2) * (rowSets (ig a.val).1).card) ≤ + Fintype.card (B ⟨(ig a.val).1, Sum.inr (ig a.val).2⟩)) + (hHΛ : ∀ a, (siteH) a ≤ Real.exp Λ) + (hδΛ : ∀ a, (halfAccuracy / ((cap) a + 1))⁻¹ ≤ Real.exp Λ) + (hLΛ : ∀ a, ((CircleFourier.characterLipConstant * ((rowSets (ig a.val).1).card * (freq) a) + 4) * + (2 : ℝ≥0) ^ Fintype.card (Fin dim) : ℝ≥0) ≤ Real.exp Λ) : + ∃ W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → AllocatedResidueSiteWitness (dim := dim) B U b S q r.val, + (∀ r, allocatedActiveSiteBounds B U b S rowSets P pointTolerance Λ M (W r).expansion) ∧ + ∀ r, AllocatedResidueSiteSampling B U b hR hσ S q (W r) δ := by + have hreps (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).exists_mem_positive_fiber + (principalResidueLabel q) r.val r.property + choose rep hrep using hreps + have hc (r : AllocatedPositiveResidue (dim := dim) B U b S q) : + 0 < (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = principalResidueLabel q (rep r))) := by + simpa only [hrep r] using r.property + have hex (r : AllocatedPositiveResidue (dim := dim) B U b S q) := + exists_allocated_active_site_uniform_sampled_error + B U b hR hσ S q (rep r) (hc r) hq hsize P δ Λ M hP hδ hΛ hgamma L hL hcP hsP hM hB hHΛ hδΛ hLΛ + choose e hb he using hex + let W : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → AllocatedResidueSiteWitness (dim := dim) B U b S q r.val := + fun r => ⟨rep r, hrep r, hc r, e r⟩ + refine ⟨W, ?_, ?_⟩ + · intro r + exact hb r + · intro r + simpa only [AllocatedResidueSiteSampling, W] using @he r + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +variable (q : ℕ) [NeZero q] + +variable (δ : ℝ) +variable (witnesses : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) +variable (hWitness : ∀ r, AllocatedResidueSiteSampling.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S q (witnesses r) δ) + +include hWitness in +theorem allocated_residue_site_sampled_error : + ∀ {K : ℕ}, AllocatedBooleanRowsSampling.{uX,uJ,uG,uI,uB,uQ} m dim K (rowTypes) (rows) → ∀ + (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + + (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ rowSets (Sigma.fst (Subtype.val a))}) → ℝ) → ℝ) + (CM Cf : ℝ≥0) (_hCM : 1 ≤ (CM : ℝ)) (_hfb : ∀ v, |f v| ≤ Cf) + (_hmask : ∀ y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S), ∀ j z, 0 ≤ allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ CM) + (_hperiod : ∀ j, integerScalarLattice (rowTypes j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j w, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) w‖ ≤ C j * ‖w‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + {X : Type uX} [Fintype X] [DecidableEq X] + {P₀ : ℝ} (_hP : 0 ≤ P₀) (_hn : (Fintype.card X : ℝ) ≤ P₀) + (_hdim : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P₀) + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hmp : ∀ j e, coefficients (p j) e ∈ U j) + (stride : X → ℕ) (_hs : ∀ x, 0 < stride x) + {R₁ S₀ ρ ε : ℝ} (_hS : 0 ≤ S₀) (_hSP : S₀ ≤ Real.exp P₀) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P₀) (_hεP : 1 / ε ≤ Real.exp P₀) + (_hstride : ∀ x, (stride x : ℝ) ≤ S₀) + (H : X → ℝ) (_hsize : ∀ x, Real.exp ((P₀ + K) ^ K) ≤ H x) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R₁ (U j) (p j)) + (_hR : Real.exp ((P₀ + K) ^ K) ≤ R₁) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) (_hcells : cells.Nonempty) + (W : Option (Fin dim) × X → ℝ) (hW : ∀ z, 0 < W z) (_hwidth : ∀ z, ρ * H z.2 ≤ W z) + {δFourier LFourier : ℝ} (_hδFourier : 0 < δFourier) (_hLFourier : 0 ≤ LFourier) + (_hamb : (Fintype.card (JetAmbientIndex (rowTypes) J) : ℝ) ≤ LFourier) + (_hδL : δFourier⁻¹ ≤ Real.exp LFourier), + let A := Real.toNNReal (coefficientDeckPeriodCap (rowTypes) Q q) * + CM ^ Fintype.card (LayerSamplerAxis I n) * Cf + (allocatedErrorKernelLip B U b S (O := rowTypes) (Real.toNNReal δ) A C V : ℝ) ≤ Real.exp LFourier → + Real.exp ((2 * LFourier + 2) ^ 4) ≤ Real.exp P₀ → + Real.exp (2 * LFourier * (2 * LFourier + 2) ^ 4) * + allocatedErrorKernelCap B U b S (O := rowTypes) (Real.toNNReal δ) A V ≤ Real.exp P₀ → + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let target := allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d f witnesses + let error := fun y : EuclideanJetLayers U (rowTypes) => + law.complexMean (fun y₀ => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ q f y : ℂ)) - + (law.fiberLaw (principalResidueLabel q)).complexMean (fun r => target r y) + let mass := δ * A * + (2 * (∑ j, (C j : ℝ) * ((Fintype.card (J j) : ℝ) + 1)) + 1) ^ + Fintype.card (Σ a : LayerSamplerAxis I n, (rowTypes) a.1) + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W + (fun z => ‖error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z))‖) + ≤ mass + 2 * δFourier + ε ∧ + ∀ φ : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖φ z‖ ≤ 1) → + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + (error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z)) * φ z)‖ + ≤ mass + 2 * δFourier + ε := by + intro K hSampling x hb o Q _ bW d _ _ f CM Cf hCM hfb hmask hperiod C V hC hV + X _ _ P₀ hP₀ hn hdim _ _ _ μ _ _ ν _ _ p hp hmp stride hs R₁ S₀ ρ ε + hS hSP hρ hε hρP hεP hstride H hsize₁ hrank hR₁ cells hcells W hW hwidth + δFourier LFourier hδFourier hLFourier hamb hδL A hLip hfreqP hcoeffP law target error mass + let sample := fun z : Option (Fin dim) × X → ℤ => + physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z) + let source := fun (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S)) (z : Option (Fin dim) × X → ℤ) => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ q f (sample z) : ℂ) + let targetSample := fun r (z : Option (Fin dim) × X → ℤ) => target r (sample z) + have hlocal (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) + (hr : 0 < law.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))) : + ∃ _hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W + (fun z => ‖(law.condition _ hr).complexMean (fun y => source y z) - targetSample r z‖) + ≤ mass + 2 * δFourier + ε := by + let rr : AllocatedPositiveResidue (dim := dim) B U b S q := ⟨r, hr⟩ + have hc := @hWitness rr + dsimp only [AllocatedResidueSiteSampling] at hc + obtain ⟨hZ, hbound⟩ := @hc K hSampling x hb o Q _ bW d _ _ f CM Cf hCM hfb + (hmask (witnesses rr).representative) hperiod C V hC hV + X _ _ P₀ hP₀ hn hdim _ _ _ μ _ _ ν _ _ p hp hmp stride hs R₁ S₀ ρ ε + hS hSP hρ hε hρP hεP hstride H hsize₁ hrank hR₁ cells hcells W hW hwidth + δFourier LFourier hδFourier hLFourier hamb hδL hLip hfreqP hcoeffP + refine ⟨hZ, ?_⟩ + have hid := allocatedSupportedResidueSiteProfile_error B U b hR hσ S q x hb o bW d f witnesses rr + have hfun : + (fun z => ‖(law.condition _ hr).complexMean (fun y => source y z) - targetSample r z‖) = + (fun z => ‖allocatedSelectedConditionalError (O := rowTypes) B U b hR hσ S x (rows) + hb o bW d q (witnesses rr).representative (witnesses rr).positive + (allocatedActiveGrid B U b S) f + (allocatedActiveSiteApproximation B U b S rowSets (witnesses rr).expansion) + (allocatedActiveNaturalVolume B U b S rowSets) (sample z)‖) := by + funext z + exact congrArg norm (congrFun hid (sample z)) + rw [hfun] + exact hbound + obtain ⟨r₀, hr₀⟩ := (law.fiberLaw (principalResidueLabel q)).exists_weight_pos + rw [law.fiberLaw_weight_eq_mass] at hr₀ + obtain ⟨hZ, _⟩ := hlocal r₀ hr₀ + have heach r hr := (hlocal r hr).choose_spec + refine ⟨hZ, ?_, ?_⟩ + · exact selectedResidue_supported_fiber_error_uniform law (principalResidueLabel q) + stride cells W hW hZ source targetSample heach + · intro φ hφ + have h := selectedResidue_supported_fiber_test_error law (principalResidueLabel q) + stride cells W hW hZ source targetSample (fun _ => mass + 2 * δFourier + ε) heach φ hφ + simpa only [FiniteProbabilityWeights.mean_const] using h + +section Constructed + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "active" => allocatedActiveGrid B U b S +local notation "activeAxes" => {a : {a // grid a} // active a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "axisN" => allocatedGridNaturalScale B U b S +local notation "volumeN" => allocatedActiveNaturalVolume B U b S rowSets +local notation "rowFamily" => (fun a : (Σ j : Fin m, Fin (n j)) => rowSets (Sigma.fst a)) + +variable (hq : 0 < q) (hsize : (Fintype.card (Fin dim) + 1) * q ≤ S.value) +variable (P Λ : ℝ) +variable (M : {a : {a // allocatedGridAxis (I := I) U b S.value a} // allocatedActiveGrid B U b S a} → ℕ) +variable [∀ a, NeZero (M a)] + +local notation "pointTolerance" => allocatedSitePointTolerance (G := G) B rowSets δ +local notation "trueCap" => allocatedGridFamilyCap B (rowFamily) P + 1 +local notation "halfAccuracy" => uniformProductAccuracy (Fintype.card (Σ j : Fin m, Fin (n j))) trueCap pointTolerance / 2 +local notation "torus" => (fun a : activeAxes => allocatedGridTorusFactor B (Fin dim) (ig (Subtype.val a))) +local notation "cap" => (fun a : activeAxes => allocatedGridPointCap B P (ig (Subtype.val a)) (rowSets (Sigma.fst (ig (Subtype.val a))))) +local notation "siteH" => (fun a : activeAxes => + allocatedNaturalSiteRadius (G := G) B (Sigma.fst (ig (Subtype.val a))) (Sigma.snd (ig (Subtype.val a))) (rowSets (Sigma.fst (ig (Subtype.val a)))) + 1 / 4) +local notation "bias" => (fun a : activeAxes => positiveModerateRetainedBias (Fin.val (Sigma.fst (ig (Subtype.val a)))) + (Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) ((layerTailDegree m + 2) * Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) + P ((torus) a : ℝ) ((2 * ((torus) a : ℝ)) ^ Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) halfAccuracy) +local notation "freq" => (fun a : activeAxes => Real.toNNReal (positiveRetainedFrequencyBound + (Fin.val (Sigma.fst (ig (Subtype.val a)))) (Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) P ((torus) a : ℝ) ((bias) a))) +include hq hsize in +theorem exists_allocated_residue_site_sampled_error + (hP : 1 ≤ P) (hδ : 0 < δ) (hΛ : 0 ≤ Λ) + (hgamma : ∀ a : activeAxes, principalProfileSize (R (ig a.val).1) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (ig a.val).1 (ig a.val).2)) ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope (Fin dim) L 1 0 q ≤ P) + (hM : ∀ a, M a = (torus) a * axisN a.val) + (hB : ∀ a : activeAxes, positiveModerateSpectrumBlockCount (ig a.val).1.val + (rowSets (ig a.val).1).card ((layerTailDegree m + 2) * (rowSets (ig a.val).1).card) ≤ + Fintype.card (B ⟨(ig a.val).1, Sum.inr (ig a.val).2⟩)) + (hHΛ : ∀ a, (siteH) a ≤ Real.exp Λ) + (hδΛ : ∀ a, (halfAccuracy / ((cap) a + 1))⁻¹ ≤ Real.exp Λ) + (hLΛ : ∀ a, ((CircleFourier.characterLipConstant * ((rowSets (ig a.val).1).card * (freq) a) + 4) * + (2 : ℝ≥0) ^ Fintype.card (Fin dim) : ℝ≥0) ≤ Real.exp Λ) : + ∃ K : ℕ, 2 ≤ K ∧ + ∃ witnesses : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedResidueSiteWitness (dim := dim) B U b S q r.val, + (∀ r, allocatedActiveSiteBounds B U b S rowSets P pointTolerance Λ M (witnesses r).expansion) ∧ + ∀ + (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + + (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ rowSets (Sigma.fst (Subtype.val a))}) → ℝ) → ℝ) + (CM Cf : ℝ≥0) (_hCM : 1 ≤ (CM : ℝ)) (_hfb : ∀ v, |f v| ≤ Cf) + (_hmask : ∀ y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S), ∀ j z, 0 ≤ allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ CM) + (_hperiod : ∀ j, integerScalarLattice (rowTypes j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j w, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) w‖ ≤ C j * ‖w‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + {X : Type uX} [Fintype X] [DecidableEq X] + {P₀ : ℝ} (_hP : 0 ≤ P₀) (_hn : (Fintype.card X : ℝ) ≤ P₀) + (_hdim : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P₀) + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hmp : ∀ j e, coefficients (p j) e ∈ U j) + (stride : X → ℕ) (_hs : ∀ x, 0 < stride x) + {R₁ S₀ ρ ε : ℝ} (_hS : 0 ≤ S₀) (_hSP : S₀ ≤ Real.exp P₀) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P₀) (_hεP : 1 / ε ≤ Real.exp P₀) + (_hstride : ∀ x, (stride x : ℝ) ≤ S₀) + (H : X → ℝ) (_hsize : ∀ x, Real.exp ((P₀ + K) ^ K) ≤ H x) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R₁ (U j) (p j)) + (_hR : Real.exp ((P₀ + K) ^ K) ≤ R₁) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) (_hcells : cells.Nonempty) + (W : Option (Fin dim) × X → ℝ) (hW : ∀ z, 0 < W z) (_hwidth : ∀ z, ρ * H z.2 ≤ W z) + {δFourier LFourier : ℝ} (_hδFourier : 0 < δFourier) (_hLFourier : 0 ≤ LFourier) + (_hamb : (Fintype.card (JetAmbientIndex (rowTypes) J) : ℝ) ≤ LFourier) + (_hδL : δFourier⁻¹ ≤ Real.exp LFourier), + let A := Real.toNNReal (coefficientDeckPeriodCap (rowTypes) Q q) * + CM ^ Fintype.card (LayerSamplerAxis I n) * Cf + (allocatedErrorKernelLip B U b S (O := rowTypes) (Real.toNNReal δ) A C V : ℝ) ≤ Real.exp LFourier → + Real.exp ((2 * LFourier + 2) ^ 4) ≤ Real.exp P₀ → + Real.exp (2 * LFourier * (2 * LFourier + 2) ^ 4) * + allocatedErrorKernelCap B U b S (O := rowTypes) (Real.toNNReal δ) A V ≤ Real.exp P₀ → + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let target := allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d f witnesses + let error := fun y : EuclideanJetLayers U (rowTypes) => + law.complexMean (fun y₀ => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ q f y : ℂ)) - + (law.fiberLaw (principalResidueLabel q)).complexMean (fun r => target r y) + let mass := δ * A * + (2 * (∑ j, (C j : ℝ) * ((Fintype.card (J j) : ℝ) + 1)) + 1) ^ + Fintype.card (Σ a : LayerSamplerAxis I n, (rowTypes) a.1) + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W + (fun z => ‖error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z))‖) + ≤ mass + 2 * δFourier + ε ∧ + ∀ φ : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖φ z‖ ≤ 1) → + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + (error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z)) * φ z)‖ + ≤ mass + 2 * δFourier + ε := by + obtain ⟨K, hK, hSampling⟩ := + exists_allocated_boolean_rows_sampling.{uX,uJ,uG,uI,uB,uQ} m dim + obtain ⟨witnesses, hBounds, hWitnesses⟩ := exists_allocated_residue_site_sampling + B U b hR hσ S q hq hsize P δ Λ M hP hδ hΛ hgamma L hL hcP hsP hM hB hHΛ hδΛ hLΛ + refine ⟨K, hK, witnesses, hBounds, ?_⟩ + exact allocated_residue_site_sampled_error B U b hR hσ S q δ witnesses hWitnesses + (K := K) (@hSampling (fun j => Finset.Subtype.fintype (rowSets j))) + +end Constructed + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +variable (q : ℕ) [NeZero q] + +variable (δ : ℝ) +variable (witnesses : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) +variable (hWitness : ∀ r, AllocatedResidueSiteSampling.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S q (witnesses r) δ) + +include hWitness in +theorem allocated_residue_site_weighted_sampled_error : + ∀ {K : ℕ}, AllocatedBooleanRowsSampling.{uX,uJ,uG,uI,uB,uQ} m dim K (rowTypes) (rows) → ∀ + (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + + (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ rowSets (Sigma.fst (Subtype.val a))}) → ℝ) → ℝ) + (CM Cf : ℝ≥0) (_hCM : 1 ≤ (CM : ℝ)) (_hfb : ∀ v, |f v| ≤ Cf) + (_hmask : ∀ y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S), ∀ j z, 0 ≤ allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ CM) + (_hperiod : ∀ j, integerScalarLattice (rowTypes j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j w, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) w‖ ≤ C j * ‖w‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + {X : Type uX} [Fintype X] [DecidableEq X] + {P₀ : ℝ} (_hP : 0 ≤ P₀) (_hn : (Fintype.card X : ℝ) ≤ P₀) + (_hdim : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P₀) + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hmp : ∀ j e, coefficients (p j) e ∈ U j) + (stride : X → ℕ) (_hs : ∀ x, 0 < stride x) + {R₁ S₀ ρ ε : ℝ} (_hS : 0 ≤ S₀) (_hSP : S₀ ≤ Real.exp P₀) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P₀) (_hεP : 1 / ε ≤ Real.exp P₀) + (_hstride : ∀ x, (stride x : ℝ) ≤ S₀) + (H : X → ℝ) (_hsize : ∀ x, Real.exp ((P₀ + K) ^ K) ≤ H x) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R₁ (U j) (p j)) + (_hR : Real.exp ((P₀ + K) ^ K) ≤ R₁) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) (_hcells : cells.Nonempty) + (W : Option (Fin dim) × X → ℝ) (hW : ∀ z, 0 < W z) (_hwidth : ∀ z, ρ * H z.2 ≤ W z) + {δFourier LFourier : ℝ} (_hδFourier : 0 < δFourier) (_hLFourier : 0 ≤ LFourier) + (_hamb : (Fintype.card (JetAmbientIndex (rowTypes) J) : ℝ) ≤ LFourier) + (_hδL : δFourier⁻¹ ≤ Real.exp LFourier), + let A := Real.toNNReal (coefficientDeckPeriodCap (rowTypes) Q q) * + CM ^ Fintype.card (LayerSamplerAxis I n) * Cf + (allocatedErrorKernelLip B U b S (O := rowTypes) (Real.toNNReal δ) A C V : ℝ) ≤ Real.exp LFourier → + Real.exp ((2 * LFourier + 2) ^ 4) ≤ Real.exp P₀ → + Real.exp (2 * LFourier * (2 * LFourier + 2) ^ 4) * + allocatedErrorKernelCap B U b S (O := rowTypes) (Real.toNNReal δ) A V ≤ Real.exp P₀ → + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let target := allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d f witnesses + let mass := δ * A * + (2 * (∑ j, (C j : ℝ) * ((Fintype.card (J j) : ℝ) + 1)) + 1) ^ + Fintype.card (Σ a : LayerSamplerAxis I n, (rowTypes) a.1) + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + ∀ (Cweight : ℝ), 0 ≤ Cweight → + ∀ weight : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) → + (Option (Fin dim) × X → ℤ) → ℂ, + (∀ r z, ‖weight r z‖ ≤ Cweight) → + let sample := fun z : Option (Fin dim) × X → ℤ => + physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z) + let error := fun z : Option (Fin dim) × X → ℤ => + law.complexMean (fun y₀ => weight (principalResidueLabel q y₀) z * + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ q f (sample z) : ℂ)) - + (law.fiberLaw (principalResidueLabel q)).complexMean (fun r => weight r z * target r (sample z)) + selectedResidueDensityMass stride cells W (fun z => ‖error z‖) ≤ Cweight * (mass + 2 * δFourier + ε) ∧ + ∀ φ : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖φ z‖ ≤ 1) → + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + (error z * φ z)‖ ≤ Cweight * (mass + 2 * δFourier + ε) := by + intro K hSampling x hb o Q _ bW d _ _ f CM Cf hCM hfb hmask hperiod C V hC hV + X _ _ P₀ hP₀ hn hdim _ _ _ μ _ _ ν _ _ p hp hmp stride hs R₁ S₀ ρ ε + hS hSP hρ hε hρP hεP hstride H hsize₁ hrank hR₁ cells hcells W hW hwidth + δFourier LFourier hδFourier hLFourier hamb hδL A hLip hfreqP hcoeffP law target mass + let sample := fun z : Option (Fin dim) × X → ℤ => + physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z) + let source := fun (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S)) (z : Option (Fin dim) × X → ℤ) => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ q f (sample z) : ℂ) + let targetSample := fun r (z : Option (Fin dim) × X → ℤ) => target r (sample z) + have hlocal (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) + (hr : 0 < law.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))) : + ∃ _hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W + (fun z => ‖(law.condition _ hr).complexMean (fun y => source y z) - targetSample r z‖) + ≤ mass + 2 * δFourier + ε := by + let rr : AllocatedPositiveResidue (dim := dim) B U b S q := ⟨r, hr⟩ + have hc := @hWitness rr + dsimp only [AllocatedResidueSiteSampling] at hc + obtain ⟨hZ, hbound⟩ := @hc K hSampling x hb o Q _ bW d _ _ f CM Cf hCM hfb + (hmask (witnesses rr).representative) hperiod C V hC hV + X _ _ P₀ hP₀ hn hdim _ _ _ μ _ _ ν _ _ p hp hmp stride hs R₁ S₀ ρ ε + hS hSP hρ hε hρP hεP hstride H hsize₁ hrank hR₁ cells hcells W hW hwidth + δFourier LFourier hδFourier hLFourier hamb hδL hLip hfreqP hcoeffP + refine ⟨hZ, ?_⟩ + have hid := allocatedSupportedResidueSiteProfile_error B U b hR hσ S q x hb o bW d f witnesses rr + have hfun : + (fun z => ‖(law.condition _ hr).complexMean (fun y => source y z) - targetSample r z‖) = + (fun z => ‖allocatedSelectedConditionalError (O := rowTypes) B U b hR hσ S x (rows) + hb o bW d q (witnesses rr).representative (witnesses rr).positive + (allocatedActiveGrid B U b S) f + (allocatedActiveSiteApproximation B U b S rowSets (witnesses rr).expansion) + (allocatedActiveNaturalVolume B U b S rowSets) (sample z)‖) := by + funext z + exact congrArg norm (congrFun hid (sample z)) + rw [hfun] + exact hbound + obtain ⟨r₀, hr₀⟩ := (law.fiberLaw (principalResidueLabel q)).exists_weight_pos + rw [law.fiberLaw_weight_eq_mass] at hr₀ + obtain ⟨hZ, _⟩ := hlocal r₀ hr₀ + have heach r hr := (hlocal r hr).choose_spec + refine ⟨hZ, ?_⟩ + intro Cweight hCweight weight hweight sample' error + refine ⟨?_, ?_⟩ + · have h := selectedResidue_supported_fiber_weighted_error law (principalResidueLabel q) + stride cells W hW hZ source targetSample weight hCweight hweight + (fun _ => mass + 2 * δFourier + ε) heach + simpa only [FiniteProbabilityWeights.mean_const] using h + · intro φ hφ + have h := selectedResidue_supported_fiber_weighted_test_error law (principalResidueLabel q) + stride cells W hW hZ source targetSample weight hCweight hweight + (fun _ => mass + 2 * δFourier + ε) heach φ hφ + simpa only [FiniteProbabilityWeights.mean_const] using h + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +variable (q : ℕ) [NeZero q] + +variable (δ : ℝ) +variable (witnesses : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedResidueSiteWitness (dim := dim) B U b S q r.val) +variable (hWitness : ∀ r, AllocatedResidueSiteSampling.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S q (witnesses r) δ) + +include hWitness in +theorem allocated_residue_site_primitive_error + {p₁ w v E : ℝ} (hp₁ : 0 ≤ p₁) (hw : 0 ≤ w) (hv : 0 ≤ v) (hE : 0 ≤ E) + (hdimSmall : dim ≤ m + 1) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p₁) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p₁) (hn₁ : ∀ j, (n j : ℝ) ≤ p₁) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p₁) + (M₀ : ℕ) (hqM : q ≤ M₀ ^ (m + 1)) (hM₀ : (M₀ : ℝ) ≤ Real.exp p₁) + (hS₁ : (S.value : ℝ) ≤ Real.exp p₁) + (hδ : δ ≤ allocatedSitePrimitiveTolerance m p₁ w v E) (hEbudget : E + 4 ≤ p₁) : + ∀ {K : ℕ}, AllocatedBooleanRowsSampling.{uX,uJ,uG,uI,uB,uQ} m dim K (rowTypes) (rows) → ∀ + (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + + (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ rowSets (Sigma.fst (Subtype.val a))}) → ℝ) → ℝ) + (CM Cf : ℝ≥0) (_hCM : 1 ≤ (CM : ℝ)) (_hfb : ∀ v, |f v| ≤ Cf) + (_hCMexp : (CM : ℝ) ≤ Real.exp w) (_hCfexp : (Cf : ℝ) ≤ Real.exp v) + (_hmask : ∀ y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S), ∀ j z, 0 ≤ allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ CM) + (_hperiod : ∀ j, integerScalarLattice (rowTypes j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j w, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) w‖ ≤ C j * ‖w‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCexp : ∀ j, (C j : ℝ) ≤ Real.exp p₁) (_hVexp : ∀ j, (V j : ℝ) ≤ Real.exp p₁) + {X : Type uX} [Fintype X] [DecidableEq X] + {P₀ : ℝ} (_hP : 0 ≤ P₀) (_hn : (Fintype.card X : ℝ) ≤ P₀) + (_hdim : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P₀) + (_hbudget : allocatedSiteErrorFourierOutput m p₁ w v ≤ P₀) + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hmp : ∀ j e, coefficients (p j) e ∈ U j) + (stride : X → ℕ) (_hs : ∀ x, 0 < stride x) + {R₁ S₀ ρ : ℝ} (_hS : 0 ≤ S₀) (_hSP : S₀ ≤ Real.exp P₀) (_hρ : 0 < ρ) + (_hρP : 1 / ρ ≤ Real.exp P₀) + (_hstride : ∀ x, (stride x : ℝ) ≤ S₀) + (H : X → ℝ) (_hsize : ∀ x, Real.exp ((P₀ + K) ^ K) ≤ H x) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R₁ (U j) (p j)) + (_hR : Real.exp ((P₀ + K) ^ K) ≤ R₁) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) (_hcells : cells.Nonempty) + (W : Option (Fin dim) × X → ℝ) (hW : ∀ z, 0 < W z) (_hwidth : ∀ z, ρ * H z.2 ≤ W z), + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let target := allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d f witnesses + let error := fun y : EuclideanJetLayers U (rowTypes) => + law.complexMean (fun y₀ => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ q f y : ℂ)) - + (law.fiberLaw (principalResidueLabel q)).complexMean (fun r => target r y) + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W + (fun z => ‖error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z))‖) + ≤ Real.exp (-E) ∧ + ∀ φ : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖φ z‖ ≤ 1) → + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + (error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z)) * φ z)‖ + ≤ Real.exp (-E) := by + intro K hSampling x hb o Q _ bW d _ _ f CM Cf hCM hfb hCMexp hCfexp hmask hperiod C V hC hV + hCexp hVexp X _ _ P₀ hP₀ hn hdim hbudget _ _ _ μ _ _ ν _ _ p hp hmp stride hs R₁ S₀ ρ + hS hSP hρ hρP hstride H hsize₁ hrank hR₁ cells hcells W hW hwidth law target error + have hδnn : Real.toNNReal δ ≤ 1 := Real.toNNReal_le_one.mpr + (hδ.trans (allocatedSitePrimitiveTolerance_le_one m hp₁ hw hv hE)) + have hrowdim : Fintype.card (Fin dim) ≤ m + 1 := by + simpa only [Fintype.card_fin] using hdimSmall + have hshare : (physicalIdealErrorShare E 1)⁻¹ ≤ Real.exp p₁ := by + rw [physicalIdealErrorShare_inv] + exact Real.exp_le_exp.mpr (by linarith) + obtain ⟨hLF, hpP, hamb, hδL, hLip, hfreq, hcoeff⟩ := + allocatedSiteErrorPrimitive_fourier_budget B U b S (rows) hrowdim + (fun _ => Subtype.val_injective) hb bW M₀ q hqM (Real.toNNReal δ) CM Cf C V + hp₁ hw hv hvars hI hn₁ hJ hδnn hM₀ hS₁ hCexp hVexp hCMexp hCfexp hshare + have heP := Real.exp_le_exp.mpr hbudget + have hεP : 1 / physicalIdealErrorShare E 1 ≤ Real.exp P₀ := by + simpa only [one_div] using hshare.trans (Real.exp_le_exp.mpr (hpP.trans hbudget)) + have hprevious := allocated_residue_site_sampled_error B U b hR hσ S q δ witnesses hWitness + (K := K) hSampling + obtain ⟨hZ, hmean, htest⟩ := @hprevious x hb o Q _ bW d _ _ f CM Cf hCM hfb hmask hperiod C V hC hV + X _ _ P₀ hP₀ hn hdim _ _ _ μ _ _ ν _ _ p hp hmp stride hs R₁ S₀ ρ (physicalIdealErrorShare E 1) + hS hSP hρ (physicalIdealErrorShare_pos E 1) hρP hεP hstride H hsize₁ hrank hR₁ cells hcells W hW hwidth + (physicalIdealErrorShare E 1) (allocatedSiteErrorFourierInput m p₁ w v) + (physicalIdealErrorShare_pos E 1) hLF hamb hδL hLip (hfreq.trans heP) (hcoeff.trans heP) + have hmass := allocatedSiteSpatial_primitive_error_budget B U b (rows) hrowdim + (fun _ => Subtype.val_injective) hb bW M₀ q hqM CM Cf C hp₁ hw hvars hI hn₁ hJ + hM₀ hCexp hCMexp hCfexp hδ (le_refl (physicalIdealErrorShare E 1)) + (le_refl (physicalIdealErrorShare E 1)) + exact ⟨hZ, hmean.trans hmass, fun φ hφ => (htest φ hφ).trans hmass⟩ + +section Constructed + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "active" => allocatedActiveGrid B U b S +local notation "activeAxes" => {a : {a // grid a} // active a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "axisN" => allocatedGridNaturalScale B U b S +local notation "volumeN" => allocatedActiveNaturalVolume B U b S rowSets +local notation "rowFamily" => (fun a : (Σ j : Fin m, Fin (n j)) => rowSets (Sigma.fst a)) + +variable (hq : 0 < q) (hsize : (Fintype.card (Fin dim) + 1) * q ≤ S.value) +variable (P Λ : ℝ) +variable (M : {a : {a // allocatedGridAxis (I := I) U b S.value a} // allocatedActiveGrid B U b S a} → ℕ) +variable [∀ a, NeZero (M a)] + +local notation "pointTolerance" => allocatedSitePointTolerance (G := G) B rowSets δ +local notation "trueCap" => allocatedGridFamilyCap B (rowFamily) P + 1 +local notation "halfAccuracy" => uniformProductAccuracy (Fintype.card (Σ j : Fin m, Fin (n j))) trueCap pointTolerance / 2 +local notation "torus" => (fun a : activeAxes => allocatedGridTorusFactor B (Fin dim) (ig (Subtype.val a))) +local notation "cap" => (fun a : activeAxes => allocatedGridPointCap B P (ig (Subtype.val a)) (rowSets (Sigma.fst (ig (Subtype.val a))))) +local notation "siteH" => (fun a : activeAxes => + allocatedNaturalSiteRadius (G := G) B (Sigma.fst (ig (Subtype.val a))) (Sigma.snd (ig (Subtype.val a))) (rowSets (Sigma.fst (ig (Subtype.val a)))) + 1 / 4) +local notation "bias" => (fun a : activeAxes => positiveModerateRetainedBias (Fin.val (Sigma.fst (ig (Subtype.val a)))) + (Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) ((layerTailDegree m + 2) * Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) + P ((torus) a : ℝ) ((2 * ((torus) a : ℝ)) ^ Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) halfAccuracy) +local notation "freq" => (fun a : activeAxes => Real.toNNReal (positiveRetainedFrequencyBound + (Fin.val (Sigma.fst (ig (Subtype.val a)))) (Finset.card (rowSets (Sigma.fst (ig (Subtype.val a))))) P ((torus) a : ℝ) ((bias) a))) +include hq hsize in +theorem exists_allocated_residue_site_primitive_error + {p₁ w v E : ℝ} (hp₁ : 0 ≤ p₁) (hw : 0 ≤ w) (hv : 0 ≤ v) (hE : 0 ≤ E) + (hdimSmall : dim ≤ m + 1) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p₁) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p₁) (hn₁ : ∀ j, (n j : ℝ) ≤ p₁) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p₁) + (M₀ : ℕ) (hqM : q ≤ M₀ ^ (m + 1)) (hM₀ : (M₀ : ℝ) ≤ Real.exp p₁) + (hS₁ : (S.value : ℝ) ≤ Real.exp p₁) + (hδbudget : δ ≤ allocatedSitePrimitiveTolerance m p₁ w v E) (hEbudget : E + 4 ≤ p₁) + (hP : 1 ≤ P) (hδ : 0 < δ) (hΛ : 0 ≤ Λ) + (hgamma : ∀ a : activeAxes, principalProfileSize (R (ig a.val).1) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (ig a.val).1 (ig a.val).2)) ≤ S.value) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hcP : scalarCubePrimitiveEnvelope Empty L 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope (Fin dim) L 1 0 q ≤ P) + (hM : ∀ a, M a = (torus) a * axisN a.val) + (hB : ∀ a : activeAxes, positiveModerateSpectrumBlockCount (ig a.val).1.val + (rowSets (ig a.val).1).card ((layerTailDegree m + 2) * (rowSets (ig a.val).1).card) ≤ + Fintype.card (B ⟨(ig a.val).1, Sum.inr (ig a.val).2⟩)) + (hHΛ : ∀ a, (siteH) a ≤ Real.exp Λ) + (hδΛ : ∀ a, (halfAccuracy / ((cap) a + 1))⁻¹ ≤ Real.exp Λ) + (hLΛ : ∀ a, ((CircleFourier.characterLipConstant * ((rowSets (ig a.val).1).card * (freq) a) + 4) * + (2 : ℝ≥0) ^ Fintype.card (Fin dim) : ℝ≥0) ≤ Real.exp Λ) : + ∃ K : ℕ, 2 ≤ K ∧ + ∃ witnesses : (r : AllocatedPositiveResidue (dim := dim) B U b S q) → + AllocatedResidueSiteWitness (dim := dim) B U b S q r.val, + (∀ r, allocatedActiveSiteBounds B U b S rowSets P pointTolerance Λ M (witnesses r).expansion) ∧ + ∀ + (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + + (f : ((Σ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + {t : Finset (Fin dim) // t ∈ rowSets (Sigma.fst (Subtype.val a))}) → ℝ) → ℝ) + (CM Cf : ℝ≥0) (_hCM : 1 ≤ (CM : ℝ)) (_hfb : ∀ v, |f v| ≤ Cf) + (_hCMexp : (CM : ℝ) ≤ Real.exp w) (_hCfexp : (Cf : ℝ) ≤ Real.exp v) + (_hmask : ∀ y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) + (allocatedPrincipalSides B U b S), ∀ j z, 0 ≤ allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask (O := rowTypes) B U b S x + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix (O := rowTypes) B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ CM) + (_hperiod : ∀ j, integerScalarLattice (rowTypes j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j w, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) w‖ ≤ C j * ‖w‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCexp : ∀ j, (C j : ℝ) ≤ Real.exp p₁) (_hVexp : ∀ j, (V j : ℝ) ≤ Real.exp p₁) + {X : Type uX} [Fintype X] [DecidableEq X] + {P₀ : ℝ} (_hP : 0 ≤ P₀) (_hn : (Fintype.card X : ℝ) ≤ P₀) + (_hdim : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P₀) + (_hbudget : allocatedSiteErrorFourierOutput m p₁ w v ≤ P₀) + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hmp : ∀ j e, coefficients (p j) e ∈ U j) + (stride : X → ℕ) (_hs : ∀ x, 0 < stride x) + {R₁ S₀ ρ : ℝ} (_hS : 0 ≤ S₀) (_hSP : S₀ ≤ Real.exp P₀) (_hρ : 0 < ρ) + (_hρP : 1 / ρ ≤ Real.exp P₀) + (_hstride : ∀ x, (stride x : ℝ) ≤ S₀) + (H : X → ℝ) (_hsize : ∀ x, Real.exp ((P₀ + K) ^ K) ≤ H x) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R₁ (U j) (p j)) + (_hR : Real.exp ((P₀ + K) ^ K) ≤ R₁) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) (_hcells : cells.Nonempty) + (W : Option (Fin dim) × X → ℝ) (hW : ∀ z, 0 < W z) (_hwidth : ∀ z, ρ * H z.2 ≤ W z), + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let target := allocatedSupportedResidueSiteProfile B U b hR hσ S q x hb o bW d f witnesses + let error := fun y : EuclideanJetLayers U (rowTypes) => + law.complexMean (fun y₀ => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ q f y : ℂ)) - + (law.fiberLaw (principalResidueLabel q)).complexMean (fun r => target r y) + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W + (fun z => ‖error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z))‖) + ≤ Real.exp (-E) ∧ + ∀ φ : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖φ z‖ ≤ 1) → + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + (error (physicalCubeRowSample (O := rowTypes) U d (rows) p hmp (standardPhysicalCubeOutput z)) * φ z)‖ + ≤ Real.exp (-E) := by + obtain ⟨K, hK, hSampling⟩ := + exists_allocated_boolean_rows_sampling.{uX,uJ,uG,uI,uB,uQ} m dim + obtain ⟨witnesses, hBounds, hWitnesses⟩ := exists_allocated_residue_site_sampling + B U b hR hσ S q hq hsize P δ Λ M hP hδ hΛ hgamma L hL hcP hsP hM hB hHΛ hδΛ hLΛ + refine ⟨K, hK, witnesses, hBounds, ?_⟩ + exact allocated_residue_site_primitive_error B U b hR hσ S q δ witnesses hWitnesses + hp₁ hw hv hE hdimSmall hvars hI hn₁ hJ M₀ hqM hM₀ hS₁ hδbudget hEbudget + (K := K) (@hSampling (fun j => Finset.Subtype.fintype (rowSets j))) + +end Constructed + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueSpatialDensity.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueSpatialDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ef7de4a8b3db1d3fb35abba1ddc859923504339 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedResidueSpatialDensity.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedPrescribedRefinedDensity + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule +open scoped BigOperators Classical Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) + (allocatedPrincipalSides B U b S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "rootAt" => (fun w => allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u w)) +local notation "dirsAt" => (fun w => allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u w)) +local notation "axis" => coefficientJetAxisEquiv O I n +local notation "scale" => (∏ a, allocatedLongJetOutputScale B U b S (O := O) a) + +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B α C 1 j) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] +variable (g : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S) → EuclideanJetLayers U O → ℝ) +variable (hg : ∀ w, Continuous (g w)) (hg0 : ∀ w z, 0 ≤ g w z) +variable (hlaw : ∀ w, (realDensityMeasure μ (fun z => allocatedCoefficientDensity B U b hb o hR hσ S + (quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d z))).map + (euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin (allocatedGridAxis (I := I) U b S.value) u w)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin (allocatedGridAxis (I := I) U b S.value) u w)) rows) = + realDensityMeasure (Measure.pi (fun j => Measure.pi (fun _ : O j => ν j))) (g w)) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (O := O) (E := E) U o b d + (fun j _ => standardLatticeClosedQuarterBox (J j)) + +variable [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] + +include hσ1 hC hchart hsmall hg hg0 hlaw in +theorem allocatedResidue_spatial_density_comparison + (M : ℕ) (hM : 0 < M) + (label : PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod M) + (hsize : ∀ t, (Fintype.card α + 1) * M ≤ principalAxisLength (fun a => ¬grid a) sides t) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + (hv₀ : principalResidueLabel M v₀ = label) + (hperiod : ∀ j, integerScalarLattice (O j) (M : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod M)) + {ε : ℝ} (hpoint : ∀ z, |(allocatedLongResidueWeights B U b S M hM label hsize).mean + (fun w => scale * allocatedLongJetDensity B U b hR hσ S x u w rows s hA hσ1 z) - + allocatedLongJetProxy B U b S x u rows s hA M residue z| ≤ ε) + {V : Type*} [Fintype V] (point : V → EuclideanJetLayers U O) + (spatial : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides → V → ℂ) + (spatialProxy test : V → ℂ) (δ cap : V → ℝ) + (hδ : ∀ t, 0 ≤ δ t) (htest : ∀ t, ‖test t‖ ≤ 1) + (hspatial : ∀ w, (allocatedLongResidueWeights B U b S M hM label hsize).weight w ≠ 0 → + ∀ t, ‖spatial w t - spatialProxy t‖ ≤ δ t) + (hcap : ∀ w, (allocatedLongResidueWeights B U b S M hM label hsize).weight w ≠ 0 → + ∀ t, g w (point t) ≤ cap t) + {Z : ℝ} (hZ : 0 < Z) : + let proxy := restrictedChartDensity chart region 1 (fun z : MixedCoveredJetSource I O E n d => + allocatedCoveredFixedFactor B U b hR hσ S x u v₀ rows E d z.1 z.2 * + (allocatedLongJetProxy B U b S x u rows s hA M residue (fun a => axis z.1 a.val) / scale)) + let error := restrictedChartDensity chart region 1 (fun z : MixedCoveredJetSource I O E n d => + allocatedCoveredFixedFactor B U b hR hσ S x u v₀ rows E d z.1 z.2 * (ε / scale)) + ‖(allocatedLongResidueWeights B U b S M hM label hsize).complexMean + (fun w => ∑ t, test t * (spatial w t * (g w (point t) : ℂ))) / (Z : ℂ) - + (∑ t, test t * (spatialProxy t * (proxy (point t) : ℂ))) / (Z : ℂ)‖ ≤ + (∑ t, (δ t * cap t + ‖spatialProxy t‖ * error (point t))) / Z := by + intro proxy error + refine (allocatedLongResidueWeights B U b S M hM label hsize).norm_spatial_density_sum_error_normalized + spatial spatialProxy (fun w t => g w (point t)) (fun t => proxy (point t)) + test δ cap (fun t => error (point t)) hδ htest hspatial ?_ ?_ hZ + · intro w hw t + rw [abs_of_nonneg (hg0 w (point t))] + exact hcap w hw t + · intro t + exact allocatedPhysicalDensityFamily_residue_comparison B U b hR hσ S x u rows s hA + hb o hσ1 C hC hchart hsmall bW d μ ν g hg hg0 hlaw + M hM label hsize v₀ hv₀ hperiod residue hpoint (point t) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSlicedPhysicalResidueIdentity.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSlicedPhysicalResidueIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fbc61bbbeb993307ea946666193fbd73ff8c8d7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSlicedPhysicalResidueIdentity.lean @@ -0,0 +1,70 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedActiveContainedTupleMap +import OAI.Combinatorics.Progressions.Lattices.AllocatedOriginalSampleResidueMixtureForecast + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem containedProgressionCubePi_residue + {G : Type*} [Fintype G] (L : ℕ) (hL : 0 < L) + (H step : G → ℕ) (c : G → ℤ) (hH : ∀ g, 0 < H g) + (hsubset : ∀ g, integerProgressionSupport (c g) (step g : ℤ) (H g) ⊆ + Finset.Ico (0 : ℤ) (L : ℤ)) + (x : ∀ g, IntegerScalarCubeBox Empty (H g)) + (hx : (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight x ≠ 0) + (q : ℕ) : + (fun g => ((containedProgressionCubeMap Empty L (H g) (step g) (c g) + hL (hsubset g) (x g) none : ℤ) : ZMod q)) = + fun g => ((c g + (step g : ℤ) * (x g none : ℤ) : ℤ) : ZMod q) := by + funext g + have hb := integerScalarCubePi_root_bounds H hH x hx g + have hc : IntegerScalarCube (H g) (fun a => (x g a : ℤ)) := by + intro row + have he : row = ∅ := Subsingleton.elim _ _ + simp only [he, integerScalarCubeValue, Finset.sum_empty, add_zero] + exact ⟨hb.1, by have := hH g; omega⟩ + rw [containedProgressionCubeMap_value Empty L (H g) (step g) (c g) hL (hsubset g) (x g) hc] + rfl + +namespace VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "degree" => layerSamplerDegree I n +local notation "Input" => (Σ a : Active, B (Subtype.val a) × Fin (degree (Subtype.val a))) +local notation "sides" => allocatedPrincipalSides B U basis S + +theorem allocatedActiveContainedProgression_residue_join + (step H : Input → ℕ) (c : Input → ℤ) (hH : ∀ j, 0 < H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (S.value : ℤ)) + (v : ∀ j, IntegerScalarCubeBox Empty (H j)) + (hv : (FiniteProbabilityWeights.pi + (fun j => integerScalarCubeWeights Empty (H j) (hH j))).weight v ≠ 0) + (q : ℕ) (u : PrincipalAxisTuples (α := Empty) short sides) : + principalResidueLabel q (principalAxisJoin short u + (allocatedActiveContainedProgression B U basis S step H c hsubset v)) = + allocatedPrincipalResidueJoin B U basis S q u + (fun j => ((c j + (step j : ℤ) * (v j none : ℤ) : ℤ) : ZMod q)) := by + rw [allocatedPrincipalResidueJoin_label_join] + congr 1 + funext j + rw [allocatedActiveContainedProgression_value B U basis S step H c hH hsubset v hv j] + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSpatialResidueMaskedComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSpatialResidueMaskedComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..14ce82ee6c79d592c759096ef0825d31093c9151 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSpatialResidueMaskedComparison.lean @@ -0,0 +1,133 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedJointMaskedDensityComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type} [Fintype G] {I : Fin m → Type} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + +variable (C V : Fin m → ℝ≥0) +variable (hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) +variable (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + +include hC hV in + +theorem exists_allocated_spatial_residue_masked_comparison + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (hσ1 : ∀ j, σ j ≤ 1) + (Cinv : Fin m → ℝ) (hCinv : ∀ j, 0 ≤ Cinv j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ Cinv j * ‖v‖) + (hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1/4) + (q : ℕ) (hq : 0 < q) + {P δ : ℝ} (hP : 0 ≤ P) (hmP : (m : ℝ) ≤ P) + (hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ) ≤ P) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (hn : ∀ j, (n j : ℝ) ≤ P) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hLP : (S.value : ℝ) ≤ Real.exp P) + (hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (hqP : (q : ℝ) ≤ Real.exp P) (hδ : 0 < δ) (hδP : δ⁻¹ ≤ Real.exp P) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + {X : Type} [Fintype X] [DecidableEq X] + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j) + {Ps ε ρ Rs Smax : ℝ} (hPs : 0 ≤ Ps) (hX : (Fintype.card X : ℝ) ≤ Ps) + (hframe : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ Ps) + (hqPs : (q : ℝ) ≤ Real.exp Ps) + (hε : 0 < ε) (hρ : 0 < ρ) (hεPs : 1 / ε ≤ Real.exp Ps) (hρPs : 1 / ρ ≤ Real.exp Ps) + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (hSmax : 0 ≤ Smax) (hSmaxPs : Smax ≤ Real.exp Ps) (hstrideMax : ∀ x, ((stride x * q : ℕ) : ℝ) ≤ Smax) + (H : X → ℝ) + (hsize : ∀ x, Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ H x) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H Rs (U j) (poly j)) + (hRs : Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ Rs) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (hcells : cells.Nonempty) + (mask : ((Option (LayerSamplerVariables G I n B) × X) → ZMod q) → + (CoefficientAmbientIndex (LayerSamplerVariables G I n B) J → ZMod q) → ℝ) + (hmask : ∀ r z, mask r z ∈ Set.Icc (0 : ℝ) 1) + (width : Option (LayerSamplerVariables G I n B) × X → ℝ) (hwidth : ∀ z, 0 < width z) + (hwide : ∀ z, ρ * H z.2 ≤ width z) + (hfreqPs : (4 * allocatedFourierLogBudget m P + 2)^4 ≤ Ps) + (hmassPs : 4 * allocatedFourierLogBudget m P * (4 * allocatedFourierLogBudget m P + 2)^4 + + allocatedFourierLogBudget m P ≤ Ps) + (hsmallError : 2 * δ + ε ≤ 1 / 2) : + let D := allocatedCoefficientDensity B U b hb o hR hσ S + let Dc := fun x => D (quotientIntegerCover (coefficientIntegerLattice U) q x) + let A := fun r => allocatedMaskedCoefficientDensity B U b o S q (mask r) + let sample := fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => + affineCoefficientCoverSample U poly hm q (fun k x => (z (k, x) : ℝ)) + let Dphysical := fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => D (affineSampleCoefficientTorus U poly hm (fun k x => (z (k, x) : ℝ))) + ∃ hD0 : ∀ z, 0 ≤ Dphysical z, + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells width z, + ∃ hDpos : 0 < selectedResidueDensityMass stride cells width Dphysical, + |selectedResidueDensityMass stride cells width Dphysical - 1| ≤ 2 * δ + ε ∧ + 1 / 2 ≤ selectedResidueDensityMass stride cells width Dphysical ∧ + selectedResidueDensityMass stride cells width Dphysical ≤ 3 / 2 ∧ + ‖(∑' z, ((selectedResidueDensityPMF stride cells width hwidth hZ Dphysical hD0 hDpos z).toReal : ℂ) * + dominatedDensityRatio Dc (A (fun v => (z v : ZMod q))) (sample z)) - + ∑' z, ((selectedResidueSmoothPMF stride cells width hwidth hZ z).toReal : ℂ) * + ((∫ x, A (fun v => (z v : ZMod q)) x ∂μ) : ℂ)‖ ≤ 12 * (2 * δ + ε) := by + let (x : X) : NeZero (stride x) := ⟨(hstride x).ne'⟩ + let : NeZero q := ⟨hq.ne'⟩ + let refined := fun x => stride x * q + let hdiv := fun x => dvd_mul_right (stride x) q + let fine := selectedResidueRefinement stride refined hdiv cells + let fmask := fun r => mask (refinedColumnExtraResidue stride q r) + have hfine : fine.Nonempty := selectedResidueRefinement_nonempty stride refined hdiv cells hcells + have hresult := exists_allocated_joint_masked_density_comparison B U b hb o S C V hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall q hq hP hmP hK hRP hσP hcount hI hn hJ hAP hLP + hCP hVP hqP hδ hδP μ ν poly hp hm hPs hX hframe hqPs hε hρ hεPs hρPs + refined (fun x => Nat.mul_pos (hstride x) hq) hSmax hSmaxPs hstrideMax H hsize hrank hRs + fine hfine fmask (fun r => hmask _) width hwidth hwide hfreqPs hmassPs hsmallError + dsimp only at hresult ⊢ + obtain ⟨hD0, hZref, hDref, hmassref, hlower, hupper, herror⟩ := hresult + let Dphysical := fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => + allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k,x) : ℝ))) + have hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells width z := by + rwa [selectedResidueSmoothMass_refinement] at hZref + have hDpos : 0 < selectedResidueDensityMass stride cells width Dphysical := by + rwa [selectedResidueDensityMass_refinement] at hDref + have hpmf := selectedResidueSmoothPMF_refinement stride refined hdiv cells width hwidth hZ hZref + have htilt := selectedResidueDensityPMF_refinement stride refined hdiv cells width hwidth + hZ hZref Dphysical hD0 hDpos hDref + have hmaskpattern (z : Option (LayerSamplerVariables G I n B) × X → ℤ) : + fmask (columnResiduePattern refined z) = mask (fun v => (z v : ZMod q)) := by + simp only [fmask, refinedColumnExtraResidue, refined, columnResidueReduction_pattern] + rfl + dsimp only [fine] at hmassref hlower hupper herror + dsimp only [Dphysical] at htilt + refine ⟨hD0, hZ, hDpos, ?_, ?_, ?_, ?_⟩ + · simpa only [selectedResidueDensityMass_refinement] using hmassref + · simpa only [selectedResidueDensityMass_refinement] using hlower + · simpa only [selectedResidueDensityMass_refinement] using hupper + · simpa only [htilt, hpmf, hmaskpattern] using herror + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedAffineAccurateSource.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedAffineAccurateSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..708e2f351dc9d33bce8518fb8262d855edd44635 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedAffineAccurateSource.lean @@ -0,0 +1,1403 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRowSlicedIdealApproximation +import OAI.Combinatorics.Progressions.Geometry.AllocatedSupportedSlicedUniformPhysicalSource +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineFiniteModelL2 +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineSourceAccuracy + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "mask" => allocatedClippedPrefactorSiteMask B U b S rowSets x y₀ q d period +local notation "residue" => (fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hperiod : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable {M : ℝ} (hM : 1 ≤ M) +variable (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +include hperiod hM hm hR hC hchart hbudget in +theorem exists_allocated_global_masked_affine_ideal_approximation + (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) → ℝ) + (δ : ℝ≥0) (hδ : 0 < δ) (hδ1 : δ ≤ 1) + (hw : ∀ i, |center i| + |width i| ≤ 1) + {ε p : ℝ} (hε : 0 < ε) (hp : 0 ≤ p) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp p) + (hεp : ε⁻¹ ≤ Real.exp p) (hδp : (δ : ℝ)⁻¹ ≤ Real.exp p) : + let sourceRadius : ℝ≥0 := allocatedRowSlicedSiteRadius rowSets + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * sourceRadius) + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card α) p + let A := Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset α × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset α × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset α × LayerSamplerAxis I n → Fin k) → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, 2 * (sourceRadius : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset α → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset α) * maskCap * A) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + ∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets δ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε := by + intro sourceRadius cutoffLip Q A maskCap + obtain ⟨k, hk, hcard, a, f, ha, hf, hLf, hs, herr⟩ := + exists_allocated_row_sliced_ideal_site_approximation B U b S rowSets center width hR + δ hδ hδ1 hw hε hp hbox hεp hδp + refine ⟨k, hk, hcard, a, f, ha, hf, hLf, hs, ?_, ?_, ?_, ?_, ?_⟩ + · exact allocatedProductMaskedIdealCoefficient_bound B U b S rowSets x y₀ q d period hperiod hM hm a ha + · intro label i s y + exact allocatedMaskedSiteChartFactor_norm B U b S o hb bW d r hr period label (f i s) (hf i s) y + · intro label i s + exact allocatedMaskedSiteChartFactor_measurable B U b S o hb bW d r hr period label (f i s) (hLf i s) (hf i s) + · exact allocatedProductChartIdealApproximation_measurable B U b S rowSets x y₀ q d period r hr hb o bW a f hLf hf + · intro y + exact allocatedProductChartDensityApproximation_error B U b S rowSets x y₀ q d period r hr hb o bW + hperiod hM hm hR C hC hchart hbudget a f + (allocatedRowSlicedIdeal B U b S rowSets δ center width) hε.le (fun z => (herr z).1) y + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uα + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type uα} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "mask" => allocatedClippedPrefactorSiteMask B U b S rowSets x y₀ q d period +local notation "residue" => (fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hperiod : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable {M : ℝ} (hM : 1 ≤ M) +variable (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +variable (hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) +variable (hmodulus : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable (hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))) +local notation "gridAxes" => {a // grid a} +local notation "gridDensity" => allocatedSupportedSlicedFullGridDensity B U b hR hσ S rowSets H step c hH hsubset q label hcell x +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width +local notation "prefactor" => allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ ideal + +include hperiod hM hm hR hC hchart hbudget hu₀ hmodulus hy₀ in +theorem exists_allocated_supported_affine_ideal_model + (e : gridAxes → ScalarSiteExpansion.{uα,uα} (Finset α)) + {εgrid : ℝ} + (he : ∀ z : AllocatedFrozenJetRows B U b S rowTypes, + ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ) * (gridDensity z : ℂ) - + allocatedFullGridSiteApproximation B U b S rowSets e z‖ ≤ εgrid) + {Nt V Cc Hs : gridAxes → ℝ} {Lg : ℝ≥0} + (heb : ∀ a, (e a).Bounds (Nt a) (V a) (Cc a) Lg (Hs a)) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {ε p : ℝ} (hε : 0 < ε) (hp : 0 ≤ p) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp p) + (hεp : ε⁻¹ ≤ Real.exp p) (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp p) : + let sourceRadius : ℝ≥0 := allocatedRowSlicedSiteRadius rowSets + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * sourceRadius) + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card α) p + let A := Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset α × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset α × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset α × LayerSamplerAxis I n → Fin k) → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, 2 * (sourceRadius : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset α → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset α) * maskCap * A) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε) ∧ + ∀ y : EuclideanJetLayers U rowTypes, + ‖cutoff y * ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y‖ ≤ + ‖prefactor y‖ * εgrid + (‖inverseNormalizer‖ * maskCap * ε) * ∏ a, Cc a := by + intro sourceRadius cutoffLip Q A maskCap + obtain ⟨k, hk, hcard, a, f, ha', hf, hLf, hs, hc, hfn, hfm, hmeas, herr⟩ := + exists_allocated_global_masked_affine_ideal_approximation B U b S rowSets x y₀ q d period r hr hb o bW + hperiod hM hm hR C hC hchart hbudget center width ρ hρ hρ1 hw hε hp hbox hεp hρp + refine ⟨k, hk, hcard, a, f, ha', hf, hLf, hs, hc, hfn, hfm, hmeas, herr, ?_⟩ + have hfullcell := principalResidueCell_pos_of_cube B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) q y₀ hy₀ + have hjoin := principalAxisJoin_restrict grid y₀ + intro y + have hfullcell' : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = principalResidueLabel q + (principalAxisJoin grid (principalAxisRestrict grid y₀) (principalAxisRestrict (fun a => ¬grid a) y₀)))) := by + simpa only [hjoin] using hfullcell + have hlong : ∀ y, ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q + (principalAxisJoin grid (principalAxisRestrict grid y₀) (principalAxisRestrict (fun a => ¬grid a) y₀)) ideal y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε := by simpa only [hjoin] using herr + have hη : 0 ≤ ‖inverseNormalizer‖ * maskCap * ε := by + have hmask : 0 ≤ maskCap := mul_nonneg (pow_nonneg (zero_le_one.trans hM) _) (coefficientDeckPeriodCap_nonneg rowTypes E period) + exact mul_nonneg (mul_nonneg (norm_nonneg _) hmask) hε.le + have h := allocatedSupportedSlicedProductProfile_combined_error B U b hR hσ S rowSets H step c hH hsubset q label hcell + x (principalAxisRestrict grid y₀) hu₀ (principalAxisRestrict (fun a => ¬grid a) y₀) E d hmodulus hb o bW + ideal hfullcell' r hr e he heb + (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) hη hlong y + simpa only [hjoin] using h + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uα + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type uα} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "mask" => allocatedClippedPrefactorSiteMask B U b S rowSets x y₀ q d period +local notation "residue" => (fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hperiod : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable {M : ℝ} (hM : 1 ≤ M) +variable (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +variable (hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) +variable (hmodulus : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable (hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))) +local notation "gridAxes" => {a // grid a} +local notation "gridDensity" => allocatedSupportedSlicedFullGridDensity B U b hR hσ S rowSets H step c hH hsubset q label hcell x +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width +local notation "prefactor" => allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ ideal + +include hperiod hM hm hR hC hchart hbudget hu₀ hmodulus hy₀ in +theorem exists_allocated_supported_affine_source_model + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) + (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (rowSets j).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (e : gridAxes → ScalarSiteExpansion.{uα,uα} (Finset α)) + {εgrid : ℝ} (hεgrid : 0 ≤ εgrid) + (he : ∀ z : AllocatedFrozenJetRows B U b S rowTypes, + ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ) * (gridDensity z : ℂ) - + allocatedFullGridSiteApproximation B U b S rowSets e z‖ ≤ εgrid) + {Nt V Cc Hs : gridAxes → ℝ} {Lg : ℝ≥0} + (heb : ∀ a, (e a).Bounds (Nt a) (V a) (Cc a) Lg (Hs a)) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {ε p : ℝ} (hε : 0 < ε) (hp : 0 ≤ p) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp p) + (hεp : ε⁻¹ ≤ Real.exp p) (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp p) : + let sourceRadius : ℝ≥0 := allocatedRowSlicedSiteRadius rowSets + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * sourceRadius) + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card α) p + let A := Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset α × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset α × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset α × LayerSamplerAxis I n → Fin k) → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, 2 * (sourceRadius : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset α → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset α) * maskCap * A) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε) ∧ + ∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y‖ ≤ + ‖inverseNormalizer‖ * maskCap * + ((ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0) * εgrid + + ε * ∏ a, Cc a) := by + intro sourceRadius cutoffLip Q A maskCap + obtain ⟨k, hk, hcard, a, f, ha, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr⟩ := + exists_allocated_supported_affine_ideal_model B U b S rowSets x y₀ q d period r hr hb o bW + hperiod hM hm hR C hC hchart hbudget ρ center width hσ H step c hH hsubset label hcell + hu₀ hmodulus hy₀ e he heb hρ hρ1 hw hε hp hbox hεp hρp + refine ⟨k, hk, hcard, a, f, ha, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, ?_⟩ + have hb0 (j : Fin m) : C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)) ≤ 1 / 4 := by + have hp0 : 0 ≤ C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)) := + mul_nonneg (hC j) (mul_nonneg (by positivity) (mul_nonneg (by positivity) (hR j).le)) + have hcard : (1 : ℝ) ≤ Fintype.card (Finset α) := by + exact_mod_cast Fintype.card_pos_iff.mpr (inferInstance : Nonempty (Finset α)) + have hfac : (1 : ℝ) ≤ ((rowSets j).card + 1 : ℝ) * Fintype.card (Finset α) := + one_le_mul_of_one_le_of_one_le (by have := Nat.cast_nonneg (α := ℝ) (rowSets j).card; linarith) hcard + exact (le_mul_of_one_le_left hp0 hfac).trans (by simpa only [mul_assoc] using hbudget j) + intro y + have hfix := allocatedAffineRowIdeal_cutoff_fixes_mean B U b S rowSets o hb bW d r hr hR hσ + T hT hsource hradius C hC hchart hb0 hσ1 hTideal ρ hρ hρ1 center width hw x gridLaw + (fun u => principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q y + have hh := herr y + rw [hfix] at hh + have hcap := allocatedAffineProductPrefactor_cap B U b S rowSets x y₀ q d period r hr hb o bW + hperiod hM hm hR C hC hchart hbudget ρ hρ center width y + calc + _ ≤ ‖prefactor y‖ * εgrid + (‖inverseNormalizer‖ * maskCap * ε) * ∏ a, Cc a := hh + _ ≤ (‖inverseNormalizer‖ * maskCap * + (ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0)) * εgrid + + (‖inverseNormalizer‖ * maskCap * ε) * ∏ a, Cc a := + add_le_add (mul_le_mul_of_nonneg_right hcap hεgrid) le_rfl + _ = _ := by ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uα + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type uα} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +local notation "gridAxes" => {a // grid a} +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width + +include hR hC hchart hbudget in + +theorem exists_allocated_supported_affine_uniform_source_model + (hq : 0 < q) {δg : ℝ} (hδg : 0 < δg) + (hdenseg : ∀ tg, δg * allocatedPrincipalSides B U b S tg ≤ (H tg : ℝ)) + (Tg : ℕ) (hQTg : (((Fintype.card α + 1) * q : ℕ) : ℝ) / δg ≤ Tg) + (hstep : ∀ tg, 0 < step tg) + (Ag : ℝ≥0) (hAg : LipschitzWith Ag Real.smoothTransition) (Pg : ℝ) (hPg : 1 ≤ Pg) + (hcP : scalarCubePrimitiveEnvelope Empty Ag 16 (128 * probabilityProfileLipschitz) 1 ≤ Pg) + (hsP : scalarCubePrimitiveEnvelope α Ag 1 0 q ≤ Pg) + (hstride : ∀ tg, ((step tg * q : ℕ) : ℝ) ≤ Pg) + (hrowDegree : ∀ j tg, tg ∈ rowSets j → tg.card ≤ j.val + 1) + (hBa : ∀ j i, positiveModerateSpectrumBlockCount j.val (rowSets j).card + ((layerTailDegree m + 1) * (rowSets j).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + (hBi : ∀ j i, uniformSpectrumBlockCount j.val (rowSets j).card + ((j.val + 1) * (rowSets j).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + {Dg vg wg tg pg Eg εgrid : ℝ} + (hDg : 0 ≤ Dg) (hvg : 0 ≤ vg) (hwg : 0 ≤ wg) (htg : 0 ≤ tg) (hpg : 0 ≤ pg) (hEg : 0 ≤ Eg) + (hcube : (Fintype.card α : ℝ) ≤ Dg) (hdegree : ∀ j : Fin m, ((j.val + 1 : ℕ) : ℝ) ≤ Dg) + (hrowsD : ∀ j, ((rowSets j).card : ℝ) ≤ Dg) + (htail : ((layerTailDegree m + 1 : ℕ) : ℝ) ≤ Dg) + (hblocks : ∀ j i, (Fintype.card (B ⟨j, Sum.inr i⟩) : ℝ) ≤ Dg) + (hRv : ∀ j, R j ≤ Real.exp vg) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp vg) + (hδw : δg⁻¹ ≤ Real.exp wg) (hTg : (Tg : ℝ) ≤ Real.exp tg) + (hcoeff : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Real.exp vg) + (hPp₀ : Pg ≤ Real.exp pg) (haxes : (Fintype.card gridAxes : ℝ) ≤ Dg) + (hεgrid : 0 < εgrid) (hεgridEg : εgrid⁻¹ ≤ Real.exp Eg) (hσgrid : ∀ j, σ j ≤ 1) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (rowSets j).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {ε Plong : ℝ} (hε : 0 < ε) (hPlong : 0 ≤ Plong) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp Plong) + (hεp : ε⁻¹ ≤ Real.exp Plong) (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp Plong) : + let p := slicedGridGeometryLog Dg vg wg tg + pg + let L := fun j : Fin m => fun e : ℝ => slicedGridSiteLog j.val (rowSets j).card + ((layerTailDegree m + 1) * (rowSets j).card) ((j.val + 1) * (rowSets j).card) Dg p e + let Cp := ∑ j, (L j 0 + Dg * (vg + 1)) + let Eg' := uniformProductAccuracyLog Dg Cp Eg + Dg * (vg + 1) + 1 + let Op := ∑ j, (siteExponentialOutputLog (Fintype.card (Finset α)) (L j Eg') + (Dg + 1) * (vg + 1)) + ∃ e : gridAxes → ScalarSiteExpansion.{uα,uα} (Finset α), + (∀ a, (e a).Bounds (Real.exp Op) (Real.exp Op) (Real.exp Op) + ⟨Real.exp Op, Real.exp_nonneg _⟩ (Real.exp (slicedGridGeometryLog Dg vg wg tg + (Dg + vg + 8)))) ∧ + ∀ (x : G → IntegerScalarCubeBox α S.value) + (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) + (d period : ℕ) [NeZero d] [NeZero period] + (_hperiod : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) + {M : ℝ} (_hM : 1 ≤ M) + (_hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + + (_hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) + (_hmodulus : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) + (_hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))), + let sourceRadius : ℝ≥0 := allocatedRowSlicedSiteRadius rowSets + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * sourceRadius) + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card α) Plong + let A := Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset α × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset α × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset α × LayerSamplerAxis I n → Fin k) → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, 2 * (sourceRadius : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset α → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset α) * maskCap * A) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y‖ ≤ + ‖inverseNormalizer‖ * maskCap * + ((ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0) * εgrid + + ε * ∏ _a : gridAxes, Real.exp Op)) ∧ + ∀ (μ : Measure (EuclideanJetLayers U rowTypes)) [IsProbabilityMeasure μ] + (φ : EuclideanJetLayers U rowTypes → ℂ), Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + Integrable (fun y => ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile + B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y) : ℂ)) μ ∧ + ‖(∫ y, ((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile + B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y) : ℂ) * φ y ∂μ) - + ∫ y, (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y) * φ y ∂μ‖ ≤ + ‖inverseNormalizer‖ * maskCap * + ((ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0) * εgrid + + ε * ∏ _a : gridAxes, Real.exp Op) := by + intro p L Cp E' Op + obtain ⟨e, heb, he⟩ := exists_allocatedSupportedSliced_full_grid_site_expansion B U b hR hσ S + rowSets H step c hH hsubset q label hcell hq hδg hdenseg Tg hQTg hstep Ag hAg Pg hPg + hcP hsP hstride hrowDegree hBa hBi hDg hvg hwg htg hpg hEg hcube hdegree hrowsD htail hblocks + hRv hRi hδw hTg hcoeff hPp₀ haxes hεgrid hεgridEg hσgrid + refine ⟨e, heb, ?_⟩ + intro x y₀ d period hd hper hperiod M hM hm hu₀ hmodulus hy₀ + obtain ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr⟩ := + exists_allocated_supported_affine_source_model B U b S rowSets x y₀ q d period r hr hb o bW + hperiod hM hm hR C hC hchart hbudget ρ center width hσ H step c hH hsubset label hcell + hu₀ hmodulus hy₀ T hT hTideal hsource hradius hσ1 e hεgrid.le (he x) heb + hρ hρ1 hw hε hPlong hbox hεp hρp + + refine ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr, ?_⟩ + intro μ hμ φ hφ hφb + exact allocatedFiniteSourceModel_test_error B U b S rowSets x y₀ q d period r hr hb o bW μ + a₀ f hLf hf e heb _ + (allocatedWholeMaskedCoveredProfile_mean_measurable B U b hR hσ S x rows hb o bW d gridLaw + (fun u => principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q _ + (allocatedRowSlicedIdeal_measurable B U b S rowSets hR ρ hρ center width)) + herr φ hφ hφb + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (Fin.val j + 1)}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset (Fin dim))) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j : Fin m, ((boundedBooleanJetRows (Fin dim) (j.val + 1)).card + 1 : ℝ) * (Fintype.card (Finset (Fin dim)) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := (Fin dim)) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := (Fin dim)) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +local notation "gridAxes" => {a // grid a} +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width + +include hR hC hchart hbudget in + +theorem exists_allocated_supported_affine_uniform_physical_source + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (Qgrid : ℝ≥0) (hQgrid : ∀ a : {a // allocatedGridAxis (I := I) U b S.value a}, + 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (allocatedGridIntegerAxis B U b S a).1 (allocatedGridIntegerAxis B U b S a).2) : ℝ) + 1) ≤ Qgrid) + (hq : 0 < q) {δg : ℝ} (hδg : 0 < δg) + (hdenseg : ∀ tg, δg * allocatedPrincipalSides B U b S tg ≤ (H tg : ℝ)) + (Tg : ℕ) (hQTg : (((Fintype.card (Fin dim) + 1) * q : ℕ) : ℝ) / δg ≤ Tg) + (hstep : ∀ tg, 0 < step tg) + (Ag : ℝ≥0) (hAg : LipschitzWith Ag Real.smoothTransition) (Pg : ℝ) (hPg : 1 ≤ Pg) + (hcP : scalarCubePrimitiveEnvelope Empty Ag 16 (128 * probabilityProfileLipschitz) 1 ≤ Pg) + (hsP : scalarCubePrimitiveEnvelope (Fin dim) Ag 1 0 q ≤ Pg) + (hstride : ∀ tg, ((step tg * q : ℕ) : ℝ) ≤ Pg) + (hBa : ∀ j i, positiveModerateSpectrumBlockCount j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((layerTailDegree m + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + (hBi : ∀ j i, uniformSpectrumBlockCount j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((j.val + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + {Dg vg wg tg pg Eg εgrid : ℝ} + (hDg : 0 ≤ Dg) (hvg : 0 ≤ vg) (hwg : 0 ≤ wg) (htg : 0 ≤ tg) (hpg : 0 ≤ pg) (hEg : 0 ≤ Eg) + (hcube : (Fintype.card (Fin dim) : ℝ) ≤ Dg) (hdegree : ∀ j : Fin m, ((j.val + 1 : ℕ) : ℝ) ≤ Dg) + (hrowsD : ∀ j : Fin m, ((boundedBooleanJetRows (Fin dim) (j.val + 1)).card : ℝ) ≤ Dg) + (htail : ((layerTailDegree m + 1 : ℕ) : ℝ) ≤ Dg) + (hblocks : ∀ j i, (Fintype.card (B ⟨j, Sum.inr i⟩) : ℝ) ≤ Dg) + (hRv : ∀ j, R j ≤ Real.exp vg) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp vg) + (hδw : δg⁻¹ ≤ Real.exp wg) (hTg : (Tg : ℝ) ≤ Real.exp tg) + (hcoeff : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Real.exp vg) + (hPp₀ : Pg ≤ Real.exp pg) (haxes : (Fintype.card gridAxes : ℝ) ≤ Dg) + (hεgrid : 0 < εgrid) (hεgridEg : εgrid⁻¹ ≤ Real.exp Eg) (hσgrid : ∀ j, σ j ≤ 1) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) (hTideal : ∀ j, partitionedIdealRadius (Fin dim) m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card (Fin dim) * ((Fintype.card (Fin dim) : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (boundedBooleanJetRows (Fin dim) (j.val + 1)).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {ε Plong : ℝ} (hε : 0 < ε) (hPlong : 0 ≤ Plong) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp Plong) + (hεp : ε⁻¹ ≤ Real.exp Plong) (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp Plong) : + let p := slicedGridGeometryLog Dg vg wg tg + pg + let L := fun j : Fin m => fun e : ℝ => slicedGridSiteLog j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((layerTailDegree m + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ((j.val + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) Dg p e + let Cp := ∑ j, (L j 0 + Dg * (vg + 1)) + let Eg' := uniformProductAccuracyLog Dg Cp Eg + Dg * (vg + 1) + 1 + let Op := ∑ j, (siteExponentialOutputLog (Fintype.card (Finset (Fin dim))) (L j Eg') + (Dg + 1) * (vg + 1)) + ∃ e : gridAxes → ScalarSiteExpansion.{0,0} (Finset (Fin dim)), + (∀ a, (e a).Bounds (Real.exp Op) (Real.exp Op) (Real.exp Op) + ⟨Real.exp Op, Real.exp_nonneg _⟩ (Real.exp (slicedGridGeometryLog Dg vg wg tg + (Dg + vg + 8)))) ∧ + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S)) + (d period : ℕ) [NeZero d] [NeZero period] (_hdiv : period ∣ d) + (_hperiod : ∀ j : Fin m, integerScalarLattice {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} → Finset (Fin dim))).mulVecLin.range) + {M : ℝ} (_hM : 1 ≤ M) + (_hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} → Finset (Fin dim))) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} → Finset (Fin dim))) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + + (_hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) + (_hmodulus : ∀ j : Fin m, integerScalarLattice {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (j.val + 1)} → Finset (Fin dim))).mulVecLin.range) + (_hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))), + let sourceRadius : ℝ≥0 := allocatedRowSlicedSiteRadius rowSets + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * sourceRadius) + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card (Fin dim)) Plong + let A := Real.exp ((Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → Finset (Fin dim) → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, 2 * (sourceRadius : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset (Fin dim) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset (Fin dim)) * maskCap * A) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y‖ ≤ + ‖inverseNormalizer‖ * maskCap * + ((ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0) * εgrid + + ε * ∏ _a : gridAxes, Real.exp Op)) ∧ + ∀ {X : Type*} (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j), + let Lcoord : ℝ≥0 := K * ∑ j, Cforward j * Fintype.card (J j) + let Llong : ℝ≥0 := (Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * r)) * Lcoord + + max ((⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) * Lcoord * period) (4 * period) + let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg Op⟩ + let Lgrid : ℝ≥0 := max ((((Fintype.card gridAxes : ℝ≥0) * Lprimitive) * Qgrid) * + Lcoord * Lprimitive ^ Fintype.card gridAxes) (4 * Lprimitive ^ Fintype.card gridAxes) + ∃ g : (Finset (Fin dim) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period))) → + (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → (∀ a, (e a).Term) → Finset (Fin dim) → + (((JetAmbientIndex (fun _ : Fin m => Unit) J → UnitAddCircle) × ((Σ j, J j) → UnitAddCircle)) × + ((Σ j, J j) → UnitAddCircle)) → ℂ, + (∀ label i kg t, LipschitzWith (Llong + Lgrid) (g label i kg t)) ∧ + (∀ label i kg t z, ‖g label i kg t z‖ ≤ 1) ∧ + AllocatedModelPhysicalExpansionIdentity B U b S x y₀ q d period r hr hb o bW e a f poly hm g := by + intro p L Cp E' Op + have hrowDegree : ∀ (j : Fin m) (tg : Finset (Fin dim)), + tg ∈ boundedBooleanJetRows (Fin dim) (j.val + 1) → tg.card ≤ j.val + 1 := by + intro j tg htg + exact (mem_boundedBooleanJetRows (j.val + 1) tg).mp htg + obtain ⟨e, heb, he⟩ := exists_allocated_supported_affine_uniform_source_model + B U b S rowSets q r hr hb o bW hR C hC hchart hbudget ρ center width hσ + H step c hH hsubset label hcell hq hδg hdenseg Tg hQTg hstep Ag hAg Pg hPg hcP hsP + hstride hrowDegree hBa hBi hDg hvg hwg htg hpg hEg hcube hdegree hrowsD htail hblocks + hRv hRi hδw hTg hcoeff hPp₀ haxes hεgrid hεgridEg hσgrid + T hT hTideal hsource hradius hσ1 hρ hρ1 hw hε hPlong hbox hεp hρp + refine ⟨e, heb, ?_⟩ + intro x y₀ d period hd hper hdiv hperiod M hM hm hu₀ hmodulus hy₀ + obtain ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr, htest⟩ := + he x y₀ d period hperiod hM hm hu₀ hmodulus hy₀ + refine ⟨k, ?_, ?_, a₀, f, ?_⟩ + · simpa only [Fintype.card_eq_nat_card] using hk + · simpa only [Fintype.card_eq_nat_card] using hcard + refine ⟨?_, hf, ?_, ?_, ?_, hfn, hfm, hmeas, ?_, ?_, ?_⟩ + · simpa only [Fintype.card_eq_nat_card] using ha₀ + · simpa only [Fintype.card_eq_nat_card] using hLf + · exact hs + · simpa only [coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using hc + · simpa only [coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using hlong + · simpa only [Op, E', Cp, L, p, coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using herr + intro X poly hp hm + have hphysical := exists_allocated_finite_model_uniform_physical_expansion B U b S x y₀ q d period r hr hb o bW e + hdiv hR C hC hchart hbudget Cforward hforward K hK a₀ f hLf hf heb Qgrid hQgrid poly hp hm + (period : ℝ≥0) ⟨Real.exp Op, Real.exp_nonneg Op⟩ le_rfl (fun _ => le_rfl) + simpa only [Op, E', Cp, L, p, Fintype.card_eq_nat_card] using hphysical + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullBooleanRowSetFintype + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (Fin.val j + 1)}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset (Fin dim))) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j : Fin m, ((boundedBooleanJetRows (Fin dim) (j.val + 1)).card + 1 : ℝ) * (Fintype.card (Finset (Fin dim)) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := (Fin dim)) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := (Fin dim)) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +local notation "gridAxes" => {a // grid a} +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width + +include hR hC hchart hbudget in + +theorem exists_allocated_supported_affine_good_kernel_source + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (Qgrid : ℝ≥0) (hQgrid : ∀ a : {a // allocatedGridAxis (I := I) U b S.value a}, + 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (allocatedGridIntegerAxis B U b S a).1 (allocatedGridIntegerAxis B U b S a).2) : ℝ) + 1) ≤ Qgrid) + (hdim : dim ≤ m + 1) + (hq : 0 < q) {δg : ℝ} (hδg : 0 < δg) + (hdenseg : ∀ tg, δg * allocatedPrincipalSides B U b S tg ≤ (H tg : ℝ)) + (Tg : ℕ) (hQTg : (((Fintype.card (Fin dim) + 1) * q : ℕ) : ℝ) / δg ≤ Tg) + (hstep : ∀ tg, 0 < step tg) + (Ag : ℝ≥0) (hAg : LipschitzWith Ag Real.smoothTransition) (Pg : ℝ) (hPg : 1 ≤ Pg) + (hcP : scalarCubePrimitiveEnvelope Empty Ag 16 (128 * probabilityProfileLipschitz) 1 ≤ Pg) + (hsP : scalarCubePrimitiveEnvelope (Fin dim) Ag 1 0 q ≤ Pg) + (hstride : ∀ tg, ((step tg * q : ℕ) : ℝ) ≤ Pg) + (hBa : ∀ j i, positiveModerateSpectrumBlockCount j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((layerTailDegree m + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + (hBi : ∀ j i, uniformSpectrumBlockCount j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((j.val + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + {Dg vg wg tg pg Eg εgrid : ℝ} + (hDg : 0 ≤ Dg) (hvg : 0 ≤ vg) (hwg : 0 ≤ wg) (htg : 0 ≤ tg) (hpg : 0 ≤ pg) (hEg : 0 ≤ Eg) + (hcube : (Fintype.card (Fin dim) : ℝ) ≤ Dg) (hdegree : ∀ j : Fin m, ((j.val + 1 : ℕ) : ℝ) ≤ Dg) + (hrowsD : ∀ j : Fin m, ((boundedBooleanJetRows (Fin dim) (j.val + 1)).card : ℝ) ≤ Dg) + (htail : ((layerTailDegree m + 1 : ℕ) : ℝ) ≤ Dg) + (hblocks : ∀ j i, (Fintype.card (B ⟨j, Sum.inr i⟩) : ℝ) ≤ Dg) + (hRv : ∀ j, R j ≤ Real.exp vg) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp vg) + (hδw : δg⁻¹ ≤ Real.exp wg) (hTg : (Tg : ℝ) ≤ Real.exp tg) + (hcoeff : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Real.exp vg) + (hPp₀ : Pg ≤ Real.exp pg) (haxes : (Fintype.card gridAxes : ℝ) ≤ Dg) + (hεgrid : 0 < εgrid) (hεgridEg : εgrid⁻¹ ≤ Real.exp Eg) (hσgrid : ∀ j, σ j ≤ 1) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) (hTideal : ∀ j, partitionedIdealRadius (Fin dim) m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card (Fin dim) * ((Fintype.card (Fin dim) : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (boundedBooleanJetRows (Fin dim) (j.val + 1)).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {ε Plong : ℝ} (hε : 0 < ε) (hPlong : 0 ≤ Plong) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp Plong) + (hεp : ε⁻¹ ≤ Real.exp Plong) (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp Plong) : + let p := slicedGridGeometryLog Dg vg wg tg + pg + let L := fun j : Fin m => fun e : ℝ => slicedGridSiteLog j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((layerTailDegree m + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ((j.val + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) Dg p e + let Cp := ∑ j, (L j 0 + Dg * (vg + 1)) + let Eg' := uniformProductAccuracyLog Dg Cp Eg + Dg * (vg + 1) + 1 + let Op := ∑ j, (siteExponentialOutputLog (Fintype.card (Finset (Fin dim))) (L j Eg') + (Dg + 1) * (vg + 1)) + ∃ e : gridAxes → ScalarSiteExpansion.{0,0} (Finset (Fin dim)), + (∀ a, (e a).Bounds (Real.exp Op) (Real.exp Op) (Real.exp Op) + ⟨Real.exp Op, Real.exp_nonneg _⟩ (Real.exp (slicedGridGeometryLog Dg vg wg tg + (Dg + vg + 8)))) ∧ + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + {Mk : ℕ} (_hMk : 0 < Mk) (selection : Fin dim ↪ G) + (hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x), + ∃ candidate : Fin Mk, candidate = goodKernelUniformCandidate selection x hx m ∧ + let period := kernelPeriodCandidate (m + 1) candidate + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ Fin dim) (period : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + ∀ (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S)) + (d : ℕ) [NeZero d] (_hdiv : period ∣ d) (_hqperiod : period ∣ q) + (_hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) + (_hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))), + let sourceRadius : ℝ≥0 := allocatedRowSlicedSiteRadius rowSets + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * sourceRadius) + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card (Fin dim)) Plong + let A := Real.exp ((Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := (layerKernelIndexBound m Mk : ℝ) ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → Finset (Fin dim) → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, 2 * (sourceRadius : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset (Fin dim) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset (Fin dim)) * maskCap * A) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y‖ ≤ + ‖inverseNormalizer‖ * maskCap * + ((ρ⁻¹ ^ Fintype.card (Σ a : {a // ¬grid a}, rowTypes a.val.1) : ℝ≥0) * εgrid + + ε * ∏ _a : gridAxes, Real.exp Op)) ∧ + ∀ {X : Type*} (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j), + let Lcoord : ℝ≥0 := K * ∑ j, Cforward j * Fintype.card (J j) + let Llong : ℝ≥0 := (Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * r)) * Lcoord + + max ((⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) * Lcoord * (Mk ^ (m + 1) : ℝ≥0)) (4 * (Mk ^ (m + 1) : ℝ≥0)) + let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg Op⟩ + let Lgrid : ℝ≥0 := max ((((Fintype.card gridAxes : ℝ≥0) * Lprimitive) * Qgrid) * + Lcoord * Lprimitive ^ Fintype.card gridAxes) (4 * Lprimitive ^ Fintype.card gridAxes) + ∃ g : (Finset (Fin dim) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period))) → + (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → (∀ a, (e a).Term) → Finset (Fin dim) → + (((JetAmbientIndex (fun _ : Fin m => Unit) J → UnitAddCircle) × ((Σ j, J j) → UnitAddCircle)) × + ((Σ j, J j) → UnitAddCircle)) → ℂ, + (∀ label i kg t, LipschitzWith (Llong + Lgrid) (g label i kg t)) ∧ + (∀ label i kg t z, ‖g label i kg t z‖ ≤ 1) ∧ + AllocatedModelPhysicalExpansionIdentity B U b S x y₀ q d period r hr hb o bW e a f poly hm g := by + intro p L Cp E' Op + obtain ⟨e, heb, he⟩ := exists_allocated_supported_affine_uniform_physical_source + B U b S q r hr hb o bW hR C hC hchart hbudget ρ center width hσ H step c hH hsubset label hcell + Cforward hforward K hK Qgrid hQgrid hq hδg hdenseg Tg hQTg hstep Ag hAg Pg hPg hcP hsP + hstride hBa hBi hDg hvg hwg htg hpg hEg hcube hdegree hrowsD htail hblocks hRv hRi hδw hTg + hcoeff hPp₀ haxes hεgrid hεgridEg hσgrid T hT hTideal hsource hradius hσ1 + hρ hρ1 hw hε hPlong hbox hεp hρp + refine ⟨e, heb, ?_⟩ + intro x Mk hMk selection hx + let candidate := goodKernelUniformCandidate selection x hx m + obtain ⟨hspatial, hperiodAll⟩ := goodKernelUniformCandidate_spec selection x hx m + refine ⟨candidate, rfl, hspatial, ?_⟩ + intro y₀ d hd hdiv hqperiod hu₀ hy₀ + let period := kernelPeriodCandidate (m + 1) candidate + have hperiod (j : Fin m) : integerScalarLattice (rowTypes j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowTypes j → Finset (Fin dim))).mulVecLin.range := + @hperiodAll (rowTypes j) (Subtype.fintype _) (j.val + 1) (by omega) _ Subtype.val_injective + (fun t => (mem_boundedBooleanJetRows (j.val + 1) t.val).mp t.property) + have hM : (1 : ℝ) ≤ (layerKernelIndexBound m Mk : ℝ) := by + exact_mod_cast (Nat.one_le_pow _ _ (by omega : 1 ≤ Mk)) + have hmask := fun j z => allocatedIntegerKernelMask_bound B U b S x rows hMk selection hx + (by simpa only [Fintype.card_fin] using hdim) (fun _ => Subtype.val_injective) + (fun j t => (mem_boundedBooleanJetRows (j.val + 1) t.val).mp t.property) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) z + have hqimage := fun j => (@integerScalarLattice_le_of_nat_dvd (rowTypes j) (Subtype.fintype _) + period q hqperiod).trans (hperiod j) + obtain ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr, hphysical⟩ := + he x y₀ d period hdiv hperiod hM hmask hu₀ hqimage hy₀ + refine ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr, ?_⟩ + intro X poly hp hm Lcoord Llong Lprimitive Lgrid + obtain ⟨g, hg, hgb, hidentity⟩ := hphysical poly hp hm + refine ⟨g, ?_, hgb, hidentity⟩ + intro label i kg t + apply (hg label i kg t).weaken + have hper : (period : ℝ≥0) ≤ (Mk ^ (m + 1) : ℝ≥0) := by + exact_mod_cast kernelPeriodCandidate_le (m + 1) candidate + apply add_le_add _ le_rfl + exact add_le_add le_rfl (max_le_max (mul_le_mul_of_nonneg_left hper zero_le) + (mul_le_mul_of_nonneg_left hper zero_le)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal +attribute [local instance] ScalarSiteExpansion.termFinite +attribute [local instance 2000] fullBooleanRowSetFintype + +private noncomputable def affineSourceSum {ι : Type*} [Finite ι] (f : ι → ℝ) : ℝ := + @Finset.sum ι ℝ _ (@Finset.univ ι (Fintype.ofFinite ι)) f + +private theorem affineSource_sum_eq {ι : Type*} [Fintype ι] (f : ι → ℝ) : + (∑ i, f i) = affineSourceSum f := by + unfold affineSourceSum + apply Finset.sum_congr + · ext i + simp only [Finset.mem_univ] + · intro i hi + rfl + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset (Fin dim) // t ∈ boundedBooleanJetRows (Fin dim) (Fin.val j + 1)}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset (Fin dim))) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j : Fin m, ((boundedBooleanJetRows (Fin dim) (j.val + 1)).card + 1 : ℝ) * (Fintype.card (Finset (Fin dim)) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := (Fin dim)) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := (Fin dim)) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +local notation "gridAxes" => {a // grid a} +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +include hR hC hchart hbudget in + +theorem exists_allocated_supported_affine_accurate_source + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (Qgrid : ℝ≥0) (hQgrid : ∀ a : {a // allocatedGridAxis (I := I) U b S.value a}, + 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (allocatedGridIntegerAxis B U b S a).1 (allocatedGridIntegerAxis B U b S a).2) : ℝ) + 1) ≤ Qgrid) + (hdim : dim ≤ m + 1) + (hq : 0 < q) {δg : ℝ} (hδg : 0 < δg) + (hdenseg : ∀ tg, δg * allocatedPrincipalSides B U b S tg ≤ (H tg : ℝ)) + (Tg : ℕ) (hQTg : (((Fintype.card (Fin dim) + 1) * q : ℕ) : ℝ) / δg ≤ Tg) + (hstep : ∀ tg, 0 < step tg) + (Ag : ℝ≥0) (hAg : LipschitzWith Ag Real.smoothTransition) (Pg : ℝ) (hPg : 1 ≤ Pg) + (hcP : scalarCubePrimitiveEnvelope Empty Ag 16 (128 * probabilityProfileLipschitz) 1 ≤ Pg) + (hsP : scalarCubePrimitiveEnvelope (Fin dim) Ag 1 0 q ≤ Pg) + (hstride : ∀ tg, ((step tg * q : ℕ) : ℝ) ≤ Pg) + (hBa : ∀ j i, positiveModerateSpectrumBlockCount j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((layerTailDegree m + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + (hBi : ∀ j i, uniformSpectrumBlockCount j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((j.val + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + {Dg vg wg tg pg : ℝ} + (hDg : 0 ≤ Dg) (hvg : 0 ≤ vg) (hwg : 0 ≤ wg) (htg : 0 ≤ tg) (hpg : 0 ≤ pg) + (hcube : (Fintype.card (Fin dim) : ℝ) ≤ Dg) (hdegree : ∀ j : Fin m, ((j.val + 1 : ℕ) : ℝ) ≤ Dg) + (hrowsD : ∀ j : Fin m, ((boundedBooleanJetRows (Fin dim) (j.val + 1)).card : ℝ) ≤ Dg) + (htail : ((layerTailDegree m + 1 : ℕ) : ℝ) ≤ Dg) + (hblocks : ∀ j i, (Fintype.card (B ⟨j, Sum.inr i⟩) : ℝ) ≤ Dg) + (hRv : ∀ j, R j ≤ Real.exp vg) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp vg) + (hδw : δg⁻¹ ≤ Real.exp wg) (hTg : (Tg : ℝ) ≤ Real.exp tg) + (hcoeff : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Real.exp vg) + (hPp₀ : Pg ≤ Real.exp pg) (haxes : (Fintype.card gridAxes : ℝ) ≤ Dg) + (hσgrid : ∀ j, σ j ≤ 1) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) (hTideal : ∀ j, partitionedIdealRadius (Fin dim) m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card (Fin dim) * ((Fintype.card (Fin dim) : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (boundedBooleanJetRows (Fin dim) (j.val + 1)).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {Prho : ℝ} (hPrho : 0 ≤ Prho) (hρPrho : (ρ : ℝ)⁻¹ ≤ Real.exp Prho) + {Pnum Pk target : ℝ} (hPnum : 0 ≤ Pnum) (hPk : 0 ≤ Pk) (htarget : 0 ≤ target) + {Mk : ℕ} (hMk : 0 < Mk) (hMkPk : (Mk : ℝ) ≤ Real.exp Pk) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ Pnum) (hn : ∀ j, (n j : ℝ) ≤ Pnum) + (hcoeffEarly : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Pnum) + (hRiEarly : ∀ j, (R j)⁻¹ ≤ Real.exp Pnum) + (hVEarly : ∀ j, mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ Real.exp Pnum) : + let F := (m * (2 : ℝ) ^ Fintype.card (Fin dim)) * (Pnum + 8) * (1 + 4 * Pnum) + + Fintype.card (LayerSamplerAxis I n) * ((m * 2 ^ (m + 1) : ℕ) * Pk) + + ∑ j, (Fintype.card (E j) : ℝ) * (Fintype.card (rowTypes j) * ((m + 1 : ℕ) * Pk)) + let Dout := (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1) : ℝ) + let Dgrid := (Fintype.card (LayerSamplerAxis I n) : ℝ) + let Pbox := ((m : ℝ) + 2) * Fintype.card (Fin dim) + m + 4 + let Eg := Dout * Prho + (target + F) + 1 + let _εgrid := Real.exp (-Eg) + let p := slicedGridGeometryLog Dg vg wg tg + pg + let L := fun j : Fin m => fun e : ℝ => slicedGridSiteLog j.val (boundedBooleanJetRows (Fin dim) (j.val + 1)).card + ((layerTailDegree m + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) ((j.val + 1) * (boundedBooleanJetRows (Fin dim) (j.val + 1)).card) Dg p e + let Cp := ∑ j, (L j 0 + Dg * (vg + 1)) + let Eg' := uniformProductAccuracyLog Dg Cp Eg + Dg * (vg + 1) + 1 + let Op := ∑ j, (siteExponentialOutputLog (Fintype.card (Finset (Fin dim))) (L j Eg') + (Dg + 1) * (vg + 1)) + let Gcost := Dgrid * max Op 0 + let ε := Real.exp (-(Gcost + (target + F) + 1)) + let Plong := Pbox + Prho + Gcost + (target + F) + 2 + ∃ e : gridAxes → ScalarSiteExpansion.{0,0} (Finset (Fin dim)), + (∀ a, (e a).Bounds (Real.exp Op) (Real.exp Op) (Real.exp Op) + ⟨Real.exp Op, Real.exp_nonneg _⟩ (Real.exp (slicedGridGeometryLog Dg vg wg tg + (Dg + vg + 8)))) ∧ + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (selection : Fin dim ↪ G) + (hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x), + ∃ candidate : Fin Mk, candidate = goodKernelUniformCandidate selection x hx m ∧ + let period := kernelPeriodCandidate (m + 1) candidate + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ Fin dim) (period : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + ∀ (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S)) + (d : ℕ) [NeZero d] (_hdiv : period ∣ d) (_hqperiod : period ∣ q) + (_hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) + (_hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))), + let sourceRadius : ℝ≥0 := allocatedRowSlicedSiteRadius rowSets + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * sourceRadius) + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card (Fin dim)) Plong + let A := Real.exp ((Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := (layerKernelIndexBound m Mk : ℝ) ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → Finset (Fin dim) → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, 2 * (sourceRadius : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset (Fin dim) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset (Fin dim)) * maskCap * A) ∧ + (∑ label : Finset (Fin dim) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), + ∑ i, ∑ kg, ‖((2 : ℂ) ^ Fintype.card (Finset (Fin dim)) * + allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i) * + coverSiteCoefficient e kg‖) ≤ + Real.exp (2 * Fintype.card (Finset (Fin dim)) + F + + Fintype.card (Finset (Fin dim)) * ((∑ j, Fintype.card (J j) : ℕ) * ((m + 1 : ℕ) * Pk)) + + ((Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + + Fintype.card gridAxes * Op) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y‖ ≤ + Real.exp (-target)) ∧ + ∀ {X : Type*} (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j), + let Lcoord : ℝ≥0 := K * ∑ j, Cforward j * Fintype.card (J j) + let Llong : ℝ≥0 := (Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * r)) * Lcoord + + max ((⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) * Lcoord * (Mk ^ (m + 1) : ℝ≥0)) (4 * (Mk ^ (m + 1) : ℝ≥0)) + let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg Op⟩ + let Lgrid : ℝ≥0 := max ((((Fintype.card gridAxes : ℝ≥0) * Lprimitive) * Qgrid) * + Lcoord * Lprimitive ^ Fintype.card gridAxes) (4 * Lprimitive ^ Fintype.card gridAxes) + ∃ g : (Finset (Fin dim) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period))) → + (Finset (Fin dim) × LayerSamplerAxis I n → Fin k) → (∀ a, (e a).Term) → Finset (Fin dim) → + (((JetAmbientIndex (fun _ : Fin m => Unit) J → UnitAddCircle) × ((Σ j, J j) → UnitAddCircle)) × + ((Σ j, J j) → UnitAddCircle)) → ℂ, + (∀ label i kg t, LipschitzWith (Llong + Lgrid) (g label i kg t)) ∧ + (∀ label i kg t z, ‖g label i kg t z‖ ≤ 1) ∧ + AllocatedModelPhysicalExpansionIdentity B U b S x y₀ q d period r hr hb o bW e a f poly hm g := by + intro F Dout Dgrid Pbox Eg εgrid p L Cp E' Op Gcost ε Plong + have hF : 0 ≤ F := by + dsimp only [F] + exact add_nonneg + (add_nonneg + (mul_nonneg (mul_nonneg (mul_nonneg (Nat.cast_nonneg _) (pow_nonneg zero_le_two _)) + (add_nonneg hPnum (by norm_num))) + (add_nonneg zero_le_one (mul_nonneg (by norm_num) hPnum))) + (mul_nonneg (Nat.cast_nonneg _) (mul_nonneg (Nat.cast_nonneg _) hPk))) + (Finset.sum_nonneg (fun j _ => mul_nonneg (Nat.cast_nonneg _) + (mul_nonneg (Nat.cast_nonneg _) (mul_nonneg (Nat.cast_nonneg _) hPk)))) + have hEg : 0 ≤ Eg := add_nonneg + (add_nonneg (mul_nonneg (Nat.cast_nonneg _) hPrho) (add_nonneg htarget hF)) zero_le_one + have hPper : 0 ≤ (m + 1 : ℕ) * Pk := mul_nonneg (Nat.cast_nonneg _) hPk + have hPbox : 0 ≤ Pbox := add_nonneg + (add_nonneg (mul_nonneg (add_nonneg (Nat.cast_nonneg _) zero_le_two) (Nat.cast_nonneg _)) + (Nat.cast_nonneg _)) (by norm_num) + obtain ⟨hg0, hg1, hgi, hl0, hl1, hli, hp, hbp, hrp, _⟩ := + affineSourceAccuracy_budget (ι := Empty) (κ := Empty) + (Dout := Dout) (Dgrid := Dgrid) (Pbox := Pbox) (Op := Op) + (Nat.cast_nonneg _) (Nat.cast_nonneg _) hPrho hPbox htarget hF + (by simp only [Fintype.card_ofIsEmpty, Nat.cast_zero]; exact Nat.cast_nonneg _) + (by simp only [Fintype.card_ofIsEmpty, Nat.cast_zero]; exact Nat.cast_nonneg _) + ρ hρPrho (C := 0) le_rfl (Real.exp_nonneg _) + have hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp Plong := + (allocatedRowSlicedSiteRadius_buffer_le_exp rowSets).trans (Real.exp_le_exp.mpr hbp) + obtain ⟨e, heb, he⟩ := exists_allocated_supported_affine_good_kernel_source + B U b S q r hr hb o bW hR C hC hchart hbudget ρ center width hσ H step c hH hsubset label hcell + Cforward hforward K hK Qgrid hQgrid hdim hq hδg hdenseg Tg hQTg hstep Ag hAg Pg hPg hcP hsP + hstride hBa hBi hDg hvg hwg htg hpg hEg hcube hdegree hrowsD htail hblocks hRv hRi hδw hTg + hcoeff hPp₀ haxes hg0 hgi.le hσgrid T hT hTideal hsource hradius hσ1 + hρ hρ1 hw hl0 hp hbox hli hrp + refine ⟨e, ?_, ?_⟩ + · simpa only [Op, E', Cp, L, p, Fintype.card_eq_nat_card] using heb + intro x selection hx + obtain ⟨candidate, hcanonical, hspatial, hsourceModel⟩ := he x hMk selection hx + refine ⟨candidate, hcanonical, hspatial, ?_⟩ + intro y₀ d hd hdiv hqperiod hu₀ hy₀ + let period := kernelPeriodCandidate (m + 1) candidate + intro sourceRadius cutoffLip Q A maskCap + obtain ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr, hphysical⟩ := + hsourceModel y₀ d hdiv hqperiod hu₀ hy₀ + obtain ⟨_, _, _, _, _, _, _, _, _, herror⟩ := + allocatedAffineSourceEarly_error_budget B U b S rowSets E hR hPnum hI hn hcoeffEarly hRiEarly hVEarly + (Op := Op) hPk hPper hPrho htarget hMkPk + (kernelPeriodCandidate_le_exp hMkPk (m + 1) candidate) ρ hρPrho + have hpref := allocatedSlicedSourceEarlyPrefactor_le_exp B U b S rowSets E hR + hPnum hI hn hcoeffEarly hRiEarly hVEarly hMkPk + (kernelPeriodCandidate_le_exp hMkPk (m + 1) candidate) + have hmass := allocatedFiniteModelPhysicalCoefficientMass_le_exp B U b S x y₀ q d period + hb bW e a₀ (F := F) + (A := (Fintype.card (Finset (Fin dim)) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + (Op := Op) (Nat.cast_nonneg (layerKernelIndexBound m Mk)) + (by simpa only [F, period, coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using hpref) + (kernelPeriodCandidate_le_exp hMkPk (m + 1) candidate) + (by simpa only [Q, coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using hc) + (by simpa only [Op, E', Cp, L, p, Fintype.card_eq_nat_card] using heb) + refine ⟨k, ?_, ?_, a₀, f, ?_, hf, ?_, ?_, ?_, ?_, hfn, hfm, hmeas, ?_, ?_, ?_⟩ + · simpa only [Q, Fintype.card_eq_nat_card] using hk + · simpa only [Q, Fintype.card_eq_nat_card] using hcard + · simpa only [A, Q, Fintype.card_eq_nat_card] using ha₀ + · simpa only [cutoffLip, sourceRadius, Q, Fintype.card_eq_nat_card] using hLf + · simpa only [sourceRadius] using hs + · simpa only [maskCap, A, Q, coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using hc + · simpa only [affineSource_sum_eq, Fintype.card_eq_nat_card] using hmass + · simpa only [maskCap, coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using hlong + · intro y + apply (herr y).trans + simpa only [F, Dout, Dgrid, Pbox, Eg, εgrid, p, L, Cp, E', Op, Gcost, ε, Plong, + coefficientDeckPeriodCap, Fintype.card_eq_nat_card] using herror + · intro X poly hpoly hmem + simpa only [cutoffLip, sourceRadius, Q, Plong, Gcost, Op, E', Cp, L, p, + Fintype.card_eq_nat_card] using + hphysical poly hpoly hmem + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedAffineBoundedAmbient.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedAffineBoundedAmbient.lean new file mode 100644 index 0000000000000000000000000000000000000000..a37c574fd719ade7ab5545398a02d6f1394c7d15 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedAffineBoundedAmbient.lean @@ -0,0 +1,602 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedChartIdealAmbientLift +import OAI.Combinatorics.Progressions.Lattices.AllocatedSupportedAffineAccurateSource +import OAI.Combinatorics.Progressions.Sampling.AllocatedSupportedSlicedAmbientGrid + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +universe uα + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type uα} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "gridAxes" => {a // allocatedGridAxis (I := I) U b S.value a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "axisN" => allocatedGridNaturalScale B U b S +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset α)) + +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell grid +local notation "height" => (fun a : gridAxes => basisAxisScale (b (Sigma.fst (ig a))) (Sigma.snd (ig a))) + +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u₀ : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S)) +variable (hu₀ : ((containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell (allocatedGridAxis (I := I) U b S.value))).weight u₀ ≠ 0) +variable (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U b S.value) a) (allocatedPrincipalSides B U b S)) +variable (Q : Fin m → Type*) [∀ j, Fintype (Q j)] (d : ℕ) [NeZero d] +variable (hperiod : ∀ j, integerScalarLattice ((fun j : Fin m => {t : Finset α // t ∈ rowSets j}) j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) ((fun j => (Subtype.val : rowSets j → Finset α)) j)).mulVecLin.range) +local notation "root" u => allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u v₀) +local notation "dirs" u => allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u v₀) +local notation "residue" u:max => (fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v₀) q) + +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "quarter" => (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "region" => mixedCoveredJetRegion (E := Q) U o b d quarter +local notation "y₀" => principalAxisJoin grid u₀ v₀ +local notation "gridDensity" => allocatedSupportedSlicedFullGridDensity B U b hR hσ S rowSets H step c hH hsubset q r hcell x + +include hu₀ hperiod in +theorem exists_allocated_supported_affine_ambient_surrogate + (period : ℕ) [NeZero period] (hdiv : period ∣ d) + (rad : ℝ≥0) (hrad : 0 < rad) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (rad : ℝ) * R j)))) ≤ 1 / 4) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) + (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (rowSets j).card * T j ≤ (rad : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (ρ : ℝ≥0) (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) → ℝ) (hw : ∀ i, |center i| + |width i| ≤ 1) + {Kmodel : Type*} [Fintype Kmodel] (a : Kmodel → ℂ) + (f : Kmodel → Finset α → (LayerSamplerAxis I n → ℝ) → ℂ) {L : ℝ≥0} + (hf : ∀ k s, LipschitzWith L (f k s)) (hfb : ∀ k s z, ‖f k s z‖ ≤ 1) + {η : ℝ} (hη : 0 ≤ η) + (happrox : ∀ y, ‖allocatedProductFullGridPrefactor B U b S rowSets d rad hrad x hb o bW q y₀ + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period rad hrad hb o bW a f y‖ ≤ η) : + let Lcoord := K * ∑ j, Cforward j * Fintype.card (J j) + let Lcut := (Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * rad)) * Lcoord + let Lsite := Lcut * d + max (L * Lcoord * period) (4 * period) * (d / period : ℕ) + let Lrows := ∑ j : Fin m, ((rowSets j).card : ℝ≥0) + let mass := ∑ label : Finset α → ((∀ j, Fin (n j) → ZMod period) × (∀ j, Q j → ZMod period)), + ∑ k, ‖(2 : ℂ) ^ Fintype.card (Finset α) * + allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label k‖₊ + let Lgrid := (Fintype.card gridAxes * + (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1) * + (2 * ((S.value : ℝ≥0) ^ (layerTailDegree m + 1)) ^ 2))) * + (∑ j, Cforward j * Fintype.card (J j)) + let N := ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ)‖₊ + ∃ F : (JetAmbientIndex rowTypes J → UnitAddCircle) → ℂ, + LipschitzWith (N * (mass * (Lgrid * d) + + mass * (Fintype.card (Finset α) * (Lsite * Lrows)))) F ∧ + (∀ z, ‖F z‖ ≤ (N * mass : ℝ≥0)) ∧ + ∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u v₀) q (allocatedRowSlicedIdeal B U b S rowSets ρ center width) y) : ℂ) - + F (coveredJetAmbientTorus U 1 y)‖ ≤ + allocatedFullGridNaturalVolume B U b S rowSets * η := by + intro Lcoord Lcut Lsite Lrows mass Lgrid N + have hb0 (j : Fin m) : C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (rad : ℝ) * R j)) ≤ 1 / 4 := by + have hp0 : 0 ≤ C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (rad : ℝ) * R j)) := + mul_nonneg (hC j) (mul_nonneg (by positivity) (mul_nonneg (by positivity) (hR j).le)) + have hcard : (1 : ℝ) ≤ Fintype.card (Finset α) := by + exact_mod_cast Fintype.card_pos_iff.mpr (inferInstance : Nonempty (Finset α)) + have hfac : (1 : ℝ) ≤ ((rowSets j).card + 1 : ℝ) * Fintype.card (Finset α) := + one_le_mul_of_one_le_of_one_le (by have := Nat.cast_nonneg (α := ℝ) (rowSets j).card; linarith) hcard + exact (le_mul_of_one_le_left hp0 hfac).trans (by simpa only [mul_assoc] using hbudget j) + let model := allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period rad hrad hb o bW a f + obtain ⟨F, hF, hFb, hFv⟩ := exists_allocated_chart_ideal_ambient_lift B U b S rowSets x y₀ q d period + rad hrad hb o bW hdiv hR C hC hchart hb0 Cforward hforward K hK a f hf hfb + change ∀ y, model y = F (coveredJetAmbientTorus U 1 y) at hFv + obtain ⟨g, hg, hgb, hgv⟩ := exists_allocated_supported_sliced_ambient_grid B U b hR hσ S rowSets + H step c hH hsubset q r hcell x v₀ Q d hb o bW Cforward hforward + have hzero (y) (hy : y ∉ chart '' region) : model y = 0 := + allocatedProductChartIdealApproximation_zero_outside B U b S rowSets x y₀ q d period rad hrad hb o bW + hR C hC hchart hbudget a f y hy + obtain ⟨G₀, hG₀, hG₀b, hG₀v⟩ := exists_allocated_grid_times_ambient_lift B U b S o hb bW d + gridDensity g hg hgb hgv model F hF hFb hFv hzero + change LipschitzWith (mass * (Lgrid * d) + + mass * (Fintype.card (Finset α) * (Lsite * Lrows))) G₀ at hG₀ + let Fout := fun z => (allocatedFullGridNaturalVolume B U b S rowSets : ℂ) * G₀ z + have hFN : LipschitzWith (N * (mass * (Lgrid * d) + + mass * (Fintype.card (Finset α) * (Lsite * Lrows)))) Fout := by + apply LipschitzWith.of_dist_le_mul + intro z w + rw [dist_eq_norm] + change ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ) * G₀ z - + (allocatedFullGridNaturalVolume B U b S rowSets : ℂ) * G₀ w‖ ≤ _ + rw [← mul_sub, norm_mul] + have hh := mul_le_mul_of_nonneg_left (hG₀.dist_le_mul z w) + (norm_nonneg (allocatedFullGridNaturalVolume B U b S rowSets : ℂ)) + simpa only [N, dist_eq_norm, NNReal.coe_mul, coe_nnnorm, mul_assoc] using hh + refine ⟨Fout, hFN, ?_, ?_⟩ + · intro z + exact (norm_mul _ _).trans_le (mul_le_mul_of_nonneg_left (hG₀b z) (norm_nonneg _)) + · intro y + have hh := allocatedSupportedSlicedProfile_ambient_surrogate_error B U b hR hσ S rowSets + H step c hH hsubset q r hcell x u₀ hu₀ v₀ Q d hperiod hb o bW + (allocatedRowSlicedIdeal B U b S rowSets ρ center width) rad hrad g hgb hgv + model F hFv hzero hη happrox y + have hfix := allocatedAffineRowIdeal_cutoff_fixes_mean B U b S rowSets o hb bW d rad hrad hR hσ + T hT hsource hradius C hC hchart hb0 hσ1 hTideal ρ hρ hρ1 center width hw x gridLaw + (fun u => principalAxisJoin grid u v₀) q y + rw [hfix] at hh + have heq : G₀ (coveredJetAmbientTorus U 1 y) = + F (coveredJetAmbientTorus U 1 y) * (g (coveredJetAmbientTorus U d y) : ℂ) := by + rw [← hG₀v] + by_cases hy : y ∈ chart '' region + · obtain ⟨z, hz, rfl⟩ := hy + rw [allocatedChartGridMultiplier_apply B U b S rowTypes hb o bW d gridDensity z hz, hgv z hz, hFv] + · rw [← hFv, hzero y hy, zero_mul, zero_mul] + simpa only [Fout, heq, mul_assoc] using hh + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uα + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type uα} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "mask" => allocatedClippedPrefactorSiteMask B U b S rowSets x y₀ q d period +local notation "residue" => (fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hperiod : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable {M : ℝ} (hM : 1 ≤ M) +variable (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +variable (hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) +variable (hmodulus : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable (hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))) +local notation "gridAxes" => {a // grid a} +local notation "gridDensity" => allocatedSupportedSlicedFullGridDensity B U b hR hσ S rowSets H step c hH hsubset q label hcell x +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width +local notation "prefactor" => allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ ideal + +include hr hperiod hM hm hR hC hchart hbudget hu₀ hmodulus in + +theorem exists_allocated_supported_affine_ambient_approximation + (hdiv : period ∣ d) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) + (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (rowSets j).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {ε p : ℝ} (hε : 0 < ε) (hp : 0 ≤ p) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp p) + (hεp : ε⁻¹ ≤ Real.exp p) (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp p) : + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card α) p + let A := Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + let mass := Real.toNNReal ((2 : ℝ) ^ Fintype.card (Finset α) * ‖inverseNormalizer‖ * + ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ + Fintype.card (Finset α) * maskCap * A)) + let L : ℝ≥0 := ⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + + Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * allocatedRowSlicedSiteRadius rowSets) + let Lcoord := K * ∑ j, Cforward j * Fintype.card (J j) + let Lsite := (Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * r)) * Lcoord * d + + max (L * Lcoord * period) (4 * period) * (d / period : ℕ) + let Lrows := ∑ j : Fin m, ((rowSets j).card : ℝ≥0) + let Lgrid := (Fintype.card gridAxes * + (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1) * + (2 * ((S.value : ℝ≥0) ^ (layerTailDegree m + 1)) ^ 2))) * + (∑ j, Cforward j * Fintype.card (J j)) + let N := ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ)‖₊ + ∃ F : (JetAmbientIndex rowTypes J → UnitAddCircle) → ℂ, + LipschitzWith (N * (mass * (Lgrid * d) + + mass * (Fintype.card (Finset α) * (Lsite * Lrows)))) F ∧ + (∀ z, ‖F z‖ ≤ (N * mass : ℝ≥0)) ∧ + ∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + F (coveredJetAmbientTorus U 1 y)‖ ≤ + allocatedFullGridNaturalVolume B U b S rowSets * (‖inverseNormalizer‖ * maskCap * ε) := by + intro Q A maskCap mass L Lcoord Lsite Lrows Lgrid N + obtain ⟨k, hk, hcard, a, f, ha, hf, hLf, hs, hc, hfn, hfm, hmeas, herr⟩ := + exists_allocated_global_masked_affine_ideal_approximation B U b S rowSets x y₀ q d period r hr hb o bW + hperiod hM hm hR C hC hchart hbudget center width ρ hρ hρ1 hw hε hp hbox hεp hρp + let Mactual := ∑ label : Finset α → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), + ∑ i, ‖(2 : ℂ) ^ Fintype.card (Finset α) * + allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖₊ + have hmass : Mactual ≤ mass := by + apply NNReal.coe_le_coe.mp + apply le_trans _ (Real.le_coe_toNNReal _) + change (Mactual : ℝ) ≤ (2 : ℝ) ^ Fintype.card (Finset α) * ‖inverseNormalizer‖ * + ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ + Fintype.card (Finset α) * maskCap * A) + have h2 : ‖(2 : ℂ)‖ = 2 := by norm_num + have he : (Mactual : ℝ) = (2 : ℝ) ^ Fintype.card (Finset α) * + (∑ label : Finset α → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), + ∑ i, ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) := by + simp only [Mactual, NNReal.coe_sum, coe_nnnorm, norm_mul, norm_pow, h2, Finset.mul_sum] + rw [he] + exact (mul_le_mul_of_nonneg_left hc (by positivity)).trans_eq (by ring) + have hη : 0 ≤ ‖inverseNormalizer‖ * maskCap * ε := + mul_nonneg (mul_nonneg (norm_nonneg _) (mul_nonneg + (pow_nonneg (zero_le_one.trans hM) _) (coefficientDeckPeriodCap_nonneg rowTypes E period))) hε.le + have hjoin := principalAxisJoin_restrict grid y₀ + have herr' : ∀ y, ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q + (principalAxisJoin grid (principalAxisRestrict grid y₀) (principalAxisRestrict (fun a => ¬grid a) y₀)) + ideal y - allocatedProductChartIdealApproximation B U b S rowSets x + (principalAxisJoin grid (principalAxisRestrict grid y₀) (principalAxisRestrict (fun a => ¬grid a) y₀)) + q d period r hr hb o bW a f y‖ ≤ ‖inverseNormalizer‖ * maskCap * ε := by + simpa only [hjoin] using herr + obtain ⟨F, hF, hFb, hFe⟩ := exists_allocated_supported_affine_ambient_surrogate B U b hR hσ S rowSets + H step c hH hsubset q label hcell x (principalAxisRestrict grid y₀) hu₀ + (principalAxisRestrict (fun a => ¬grid a) y₀) E d hmodulus hb o bW + period hdiv r hr C hC hchart hbudget Cforward hforward K hK T hT hTideal hsource hradius hσ1 + ρ hρ hρ1 center width hw a f hLf hf hη herr' + simp only [hjoin] at hF hFb + change LipschitzWith (N * (Mactual * (Lgrid * d) + + Mactual * (Fintype.card (Finset α) * (Lsite * Lrows)))) F at hF + change ∀ z, ‖F z‖ ≤ (N * Mactual : ℝ≥0) at hFb + refine ⟨F, hF.weaken ?_, ?_, hFe⟩ + · gcongr + · intro z + exact (hFb z).trans (by exact_mod_cast mul_le_mul_of_nonneg_left hmass (show 0 ≤ N from zero_le)) + +include hr hperiod hM hm hR hC hchart hbudget hu₀ hmodulus in + +theorem exists_allocated_supported_affine_accurate_ambient + (hdiv : period ∣ d) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) + (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (rowSets j).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {Pbox Prho Vlog Nlog Mlog target : ℝ} + (hPbox : 0 ≤ Pbox) (hPrho : 0 ≤ Prho) (hVlog : 0 ≤ Vlog) + (hNlog : 0 ≤ Nlog) (hMlog : 0 ≤ Mlog) (htarget : 0 ≤ target) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp Pbox) + (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp Prho) + (hvolume : allocatedFullGridNaturalVolume B U b S rowSets ≤ Real.exp Vlog) + (hnormalizer : ‖inverseNormalizer‖ ≤ Real.exp Nlog) + (hmask : M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period ≤ Real.exp Mlog) : + let p := Pbox + Prho + Vlog + Nlog + Mlog + target + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card α) p + let A := Real.exp ((Fintype.card (Finset α) * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + let mass := Real.toNNReal ((2 : ℝ) ^ Fintype.card (Finset α) * ‖inverseNormalizer‖ * + ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ + Fintype.card (Finset α) * maskCap * A)) + let L : ℝ≥0 := ⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + + Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * allocatedRowSlicedSiteRadius rowSets) + let Lcoord := K * ∑ j, Cforward j * Fintype.card (J j) + let Lsite := (Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * r)) * Lcoord * d + + max (L * Lcoord * period) (4 * period) * (d / period : ℕ) + let Lrows := ∑ j : Fin m, ((rowSets j).card : ℝ≥0) + let Lgrid := (Fintype.card gridAxes * + (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1) * + (2 * ((S.value : ℝ≥0) ^ (layerTailDegree m + 1)) ^ 2))) * + (∑ j, Cforward j * Fintype.card (J j)) + let N := ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ)‖₊ + ∃ F : (JetAmbientIndex rowTypes J → UnitAddCircle) → ℂ, + LipschitzWith (N * (mass * (Lgrid * d) + + mass * (Fintype.card (Finset α) * (Lsite * Lrows)))) F ∧ + (∀ z, ‖F z‖ ≤ (N * mass : ℝ≥0)) ∧ + ∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + F (coveredJetAmbientTorus U 1 y)‖ ≤ + Real.exp (-target) := by + intro p Q A maskCap mass L Lcoord Lsite Lrows Lgrid N + let e := Vlog + Nlog + Mlog + target + let ε := Real.exp (-e) + have hp : 0 ≤ p := by dsimp [p]; positivity + have hep : e ≤ p := by dsimp [e, p]; linarith + have hεp : ε⁻¹ ≤ Real.exp p := by + rw [show ε = Real.exp (-e) from rfl, ← Real.exp_neg, neg_neg] + exact Real.exp_le_exp.mpr hep + have hbox' : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp p := + hbox.trans (Real.exp_le_exp.mpr (by dsimp [p]; linarith)) + have hρp' : (ρ : ℝ)⁻¹ ≤ Real.exp p := + hρp.trans (Real.exp_le_exp.mpr (by dsimp [p]; linarith)) + obtain ⟨F, hF, hFb, hFe⟩ := exists_allocated_supported_affine_ambient_approximation + B U b S rowSets x y₀ q d period r hr hb o bW hperiod hM hm hR C hC hchart hbudget + ρ center width hσ H step c hH hsubset label hcell hu₀ hmodulus hdiv + Cforward hforward K hK T hT hTideal hsource hradius hσ1 hρ hρ1 hw + (Real.exp_pos (-e)) hp hbox' hεp hρp' + refine ⟨F, hF, hFb, ?_⟩ + intro y + apply (hFe y).trans + have hmask0 : 0 ≤ maskCap := mul_nonneg (pow_nonneg (zero_le_one.trans hM) _) + (coefficientDeckPeriodCap_nonneg rowTypes E period) + calc + _ ≤ Real.exp Vlog * (Real.exp Nlog * Real.exp Mlog * ε) := + mul_le_mul hvolume (mul_le_mul_of_nonneg_right + (mul_le_mul hnormalizer hmask hmask0 (Real.exp_nonneg _)) (Real.exp_nonneg _)) + (by positivity) (Real.exp_nonneg _) + _ = _ := by + dsimp only [ε, e] + rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uα + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type uα} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U b S)) +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "mask" => allocatedClippedPrefactorSiteMask B U b S rowSets x y₀ q d period +local notation "residue" => (fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hperiod : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable {M : ℝ} (hM : 1 ≤ M) +variable (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ∧ + allocatedIntegerKernelMask B U b S x + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) + (fun j => (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)) j + (principalAxisRestrict (fun a => ¬allocatedGridAxis (I := I) U b S.value a) y₀)) q) z ≤ M) + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j, ((rowSets j).card + 1 : ℝ) * (Fintype.card (Finset α) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (ρ : ℝ≥0) +variable (center width : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +variable (hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) +variable (hmodulus : ∀ j, integerScalarLattice {t : Finset α // t ∈ rowSets j} (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : {t : Finset α // t ∈ rowSets j} → Finset α)).mulVecLin.range) +variable (hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))) +local notation "gridAxes" => {a // grid a} +local notation "gridDensity" => allocatedSupportedSlicedFullGridDensity B U b hR hσ S rowSets H step c hH hsubset q label hcell x +local notation "ideal" => allocatedRowSlicedIdeal B U b S rowSets ρ center width +local notation "prefactor" => allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ ideal + +omit [DecidableEq α] in +theorem allocatedRowSlicedSiteRadius_ge_one : 1 ≤ allocatedRowSlicedSiteRadius rowSets := by + apply NNReal.coe_le_coe.mp + change (1 : ℝ) ≤ 1 + ∑ j : Fin m, (rowSets j).card * (partitionedIdealRadius α m + 1) + exact le_add_of_nonneg_right (Finset.sum_nonneg (fun j _ => + mul_nonneg (Nat.cast_nonneg _) (add_nonneg (partitionedIdealRadius_nonneg α m) zero_le_one))) + +include hr hperiod hM hm hR hC hchart hbudget hu₀ hmodulus in +theorem exists_allocated_supported_affine_bounded_ambient + (hdiv : period ∣ d) + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) + (hTideal : ∀ j, partitionedIdealRadius α m + 1 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (rowSets j).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (hρ : 0 < ρ) (hρ1 : ρ ≤ 1) (hw : ∀ i, |center i| + |width i| ≤ 1) + {Pbox Prho Vlog Nlog Mlog target : ℝ} + (hPbox : 0 ≤ Pbox) (hPrho : 0 ≤ Prho) (hVlog : 0 ≤ Vlog) + (hNlog : 0 ≤ Nlog) (hMlog : 0 ≤ Mlog) (htarget : 0 ≤ target) + (hbox : 2 * (allocatedRowSlicedSiteRadius rowSets : ℝ) ≤ Real.exp Pbox) + (hρp : (ρ : ℝ)⁻¹ ≤ Real.exp Prho) + (hvolume : allocatedFullGridNaturalVolume B U b S rowSets ≤ Real.exp Vlog) + (hnormalizer : ‖inverseNormalizer‖ ≤ Real.exp Nlog) + (hmask : M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period ≤ Real.exp Mlog) + {base : ℝ} (hbase : 0 ≤ base) + (hvbase : Vlog ≤ base) (hnbase : Nlog ≤ base) (hmbase : Mlog ≤ base) + (hsites : (Fintype.card (Finset α) : ℝ) ≤ base) + (haxes : (Fintype.card (LayerSamplerAxis I n) : ℝ) ≤ base) + (hlabels : (Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ≤ Real.exp base) + (hKbase : (K : ℝ) ≤ Real.exp base) + (hcoords : ((∑ j, Cforward j * Fintype.card (J j) : ℝ≥0) : ℝ) ≤ Real.exp base) + (hcutoff : (normalizedSiteCutoffBound : ℝ) ≤ Real.exp base) + (hrone : 1 ≤ r) (hdbase : (d : ℝ) ≤ Real.exp base) (hpbase : (period : ℝ) ≤ Real.exp base) + (hrows : ((∑ j : Fin m, ((rowSets j).card : ℝ≥0) : ℝ≥0) : ℝ) ≤ Real.exp base) + (houtputs : (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1) : ℝ) ≤ base) + (hheight : (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ Real.exp base) : + let p := Pbox + Prho + Vlog + Nlog + Mlog + target + let Q := idealSiteLogBudget (Fintype.card (Σ a : LayerSamplerAxis I n, rowTypes a.1)) (Fintype.card α) p + let budget := affineAmbientPrimitiveBudget base Q + ∃ F : (JetAmbientIndex rowTypes J → UnitAddCircle) → ℂ, + LipschitzWith ⟨Real.exp budget, Real.exp_nonneg _⟩ F ∧ + (∀ z, ‖F z‖ ≤ Real.exp budget) ∧ + ∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + F (coveredJetAmbientTorus U 1 y)‖ ≤ Real.exp (-target) := by + intro p Q budget + obtain ⟨F, hF, hFb, hFe⟩ := exists_allocated_supported_affine_accurate_ambient + B U b S rowSets x y₀ q d period r hr hb o bW hperiod hM hm hR C hC hchart hbudget + ρ center width hσ H step c hH hsubset label hcell hu₀ hmodulus hdiv + Cforward hforward K hK T hT hTideal hsource hradius hσ1 hρ hρ1 hw + hPbox hPrho hVlog hNlog hMlog htarget hbox hρp hvolume hnormalizer hmask + have hp : 0 ≤ p := by dsimp [p]; positivity + have hQ : 0 ≤ Q := (idealSiteLogBudget_bounds _ _ hp).1 + have hN : (‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ)‖₊ : ℝ) ≤ Real.exp base := by + rw [coe_nnnorm, Complex.norm_real, Real.norm_of_nonneg (allocatedFullGridNaturalVolume_pos B U b hR S rowSets).le] + exact hvolume.trans (Real.exp_le_exp.mpr hvbase) + have hradone : 1 ≤ allocatedRowSlicedSiteRadius rowSets := + allocatedRowSlicedSiteRadius_ge_one rowSets + have hmask0 : 0 ≤ M ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period := + mul_nonneg (pow_nonneg (zero_le_one.trans hM) _) (coefficientDeckPeriodCap_nonneg rowTypes E period) + have hprim := affineAmbientPrimitive_bounds (d := d) (period := period) + (gridaxes := Fintype.card gridAxes) + (N := ‖(allocatedFullGridNaturalVolume B U b S rowSets : ℂ)‖₊) + (K := K) (coords := ∑ j, Cforward j * Fintype.card (J j)) + (cutoff := normalizedSiteCutoffBound) (r := r) (radius := allocatedRowSlicedSiteRadius rowSets) + (Lrows := ∑ j : Fin m, ((rowSets j).card : ℝ≥0)) + (height := (S.value : ℝ≥0) ^ (layerTailDegree m + 1)) + hbase hQ hsites haxes hlabels (norm_nonneg _) (hnormalizer.trans (Real.exp_le_exp.mpr hnbase)) + hmask0 (hmask.trans (Real.exp_le_exp.mpr hmbase)) hN hKbase hcoords hcutoff hrone hradone + hdbase hpbase hrows ((Nat.cast_le.mpr (Fintype.card_subtype_le (allocatedGridAxis (I := I) U b S.value))).trans haxes) + houtputs hheight + refine ⟨F, hF.weaken ?_, fun z => (hFb z).trans hprim.1, hFe⟩ + exact NNReal.coe_le_coe.mp hprim.2 + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedResidueGrid.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedResidueGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..344ef1fe4d3c2e790c6b74acab50654f013103db --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedResidueGrid.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.Progressions.Fourier.AllocatedSupportedResidueSpectrum + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S)).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +variable (j : Fin m) (i : Fin (n j)) + +noncomputable def allocatedSupportedGridDensity (M : ℕ) (rows : Finset (Finset α)) + (shift z : rows → ℤ) : ℝ := + (basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((allocatedSupportedResidueJetPMF B U basis hR hσ S q r hcell j i rows shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal + +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +variable (hq : 0 < q) (hsize : (Fintype.card α + 1) * q ≤ S.value) + +local notation "sources" => allocatedActiveResidueSources B U basis S j i hactive q hq r hsize +local notation "csource" => allocatedPrincipalNormalizedSource B U basis hR S j i hactive +local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i)) + +theorem allocatedSupportedGridDensity_eq_normalized (M : ℕ) (rows : Finset (Finset α)) + (shift z : rows → ℤ) : + allocatedSupportedGridDensity B U basis hR hσ S q r hcell j i M rows shift z = + integerGridDensity (weightedModerateIntegerProductSource + (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources) + (weightedModerateIntegerJetSum (fun _ => csource) sources rows (fun _ => 0) shift) + (basisAxisScale (basis j) i) M z := by + have h := integerGridDensity_eq_of_pmf_image + (weightedModerateIntegerProductSource (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources) + (weightedModerateIntegerJetSum (fun _ => csource) sources rows (fun _ => 0) shift) _ + (allocatedSupportedResidueJetPMF_source B U basis hR hσ S q r hcell j i + hactive hq hsize rows shift) (basisAxisScale (basis j) i) M z + simpa only [allocatedSupportedGridDensity, Fintype.card_coe] using h.symm + +noncomputable def allocatedSupportedGridApproximation (P C ε : ℝ) (M : ℕ) [NeZero M] + (rows : Finset (Finset α)) (shift z : rows → ℤ) : ℂ := + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z + (positiveModerateSpectrumCover rows M j.val P (C / (2 * gamma)) S.value + (positiveModerateRetainedBias j.val rows.card ((layerTailDegree m + 1) * rows.card) + P (C / (2 * gamma)) (C ^ rows.card) ε)) + +theorem allocatedSupportedGridDensity_error_of_tail + (M : ℕ) [NeZero M] (rows : Finset (Finset α)) (shift z : rows → ℤ) + (F : Finset (rows → Fin M)) {ε : ℝ} + (htail : spectrumTail F (fun k => ‖∏ b : B ⟨j, Sum.inr i⟩, + weightedModerateGridCoefficient csource ((sources) b) 0 M rows k‖) ≤ ε) : + ‖(allocatedSupportedGridDensity B U basis hR hσ S q r hcell j i M rows shift z : ℂ) - + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + have he := congrArg (fun x : ℝ => ‖(x : ℂ) - + weightedModerateGridApproximation (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F‖) + (allocatedSupportedGridDensity_eq_normalized B U basis hR hσ S q r hcell j i hactive hq hsize + M rows shift z) + exact he.trans_le (weightedModerateGridDensity_error_of_tail + (fun _ : B ⟨j, Sum.inr i⟩ => csource) sources (basisAxisScale (basis j) i) M rows (fun _ => 0) + F (by simpa only [Int.cast_zero] using htail) shift z) + +theorem allocatedSupportedGridDensity_error + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + {C ε : ℝ} {M : ℕ} [NeZero M] (hC : 0 ≤ C) + (hMK : (M : ℝ) ≤ C * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (hε : 0 < ε) (hε1 : ε ≤ 1) (shift z : rows → ℤ) : + ‖(allocatedSupportedGridDensity B U basis hR hσ S q r hcell j i M rows shift z : ℂ) - + allocatedSupportedGridApproximation B U basis hR S q r j i hactive hq hsize P C ε M rows shift z‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + exact allocatedSupportedGridDensity_error_of_tail B U basis hR hσ S q r hcell j i hactive hq hsize + M rows shift z _ (allocatedSupportedResidueSpectrum_tail B U basis hR S j i hactive q hq r hsize + hgrid A hA P hcP hsP hC (Nat.pos_of_ne_zero (NeZero.ne M)) hMK rows hrows hB hε hε1) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidue.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidue.lean new file mode 100644 index 0000000000000000000000000000000000000000..6bea2701430aef246c6aec9a486f3c5d43f050b0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidue.lean @@ -0,0 +1,726 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRefinedLongJetComparison +import OAI.Combinatorics.Progressions.Geometry.PrincipalCubeSupportedCell +import OAI.Combinatorics.Progressions.Lattices.RelativeSliceAffineThreeFactorLaw +import OAI.Combinatorics.Progressions.Probability.AllocatedWholeDeckLaw + +namespace OAI + +section + +namespace Erdos3 +open scoped Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] (h : D → ℕ) +variable (L H step : PrincipalTupleIndex B h → ℕ) (c : PrincipalTupleIndex B h → ℤ) +variable (hL : ∀ j, 0 < L j) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) +variable (q : ℕ) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +local notation "weights" => FiniteProbabilityWeights.condition (principalTupleWeights B h H hH) + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell +local notation "law" => containedSupportedProgressionLaw B h L H step c hL hH hsubset q r hcell + +theorem containedSupportedProgressionLaw_residue_support + (y : PrincipalIntegerTuples B h α L) (hy : (law).weight y ≠ 0) : + ∀ j a, ((y j a : ℤ) : ZMod q) = + (if a = none then (c j : ZMod q) else 0) + (step j : ZMod q) * r j a := by + apply (weights).fiberLaw_support (containedProgressionTupleMap B h L H step c hL hsubset) + (fun y => ∀ j a, ((y j a : ℤ) : ZMod q) = + (if a = none then (c j : ZMod q) else 0) + (step j : ZMod q) * r j a) _ y hy + intro z hz j a + have hpos := lt_of_le_of_ne ((weights).nonneg z) hz.symm + have hmem := ((FiniteProbabilityWeights.condition_weight_pos_iff _ _ _ z).mp hpos).1 + have hr : principalResidueLabel q z = r := (Finset.mem_filter.mp hmem).2 + have hza : ((z j a : ℤ) : ZMod q) = r j a := congrFun (congrFun hr j) a + have hcube := principalSupportedResidue_cube_support B h H hH q r hcell z hz j + change ((containedProgressionCubeMap α (L j) (H j) (step j) (c j) (hL j) (hsubset j) (z j) a : ℤ) : ZMod q) = _ + rw [containedProgressionCubeMap_value _ _ _ _ _ _ _ _ hcube] + simp only [Int.cast_add, Int.cast_mul, Int.cast_natCast, apply_ite, Int.cast_zero, hza] + +theorem containedSupportedProgressionLaw_residue_eq + (y z : PrincipalIntegerTuples B h α L) (hy : (law).weight y ≠ 0) (hz : (law).weight z ≠ 0) : + principalResidueLabel q y = principalResidueLabel q z := by + funext j a + exact (containedSupportedProgressionLaw_residue_support B h L H step c hL hH hsubset q r hcell y hy j a).trans + (containedSupportedProgressionLaw_residue_support B h L H step c hL hH hsubset q r hcell z hz j a).symm + +theorem containedSupportedProgressionAxisLaw_fiberLaw (P : D → Prop) [DecidablePred P] : + (law).fiberLaw (principalAxisRestrict P) = + containedSupportedProgressionAxisLaw B h L H step c hL hH hsubset q r hcell P := by + apply FiniteProbabilityWeights.toPMF_injective + exact (FiniteProbabilityWeights.toPMF_fiberLaw (law) (principalAxisRestrict P)).trans + (containedSupportedProgressionLaw_axis_marginal B h L H step c hL hH hsubset q r hcell P) + +theorem containedSupportedProgressionAxisLaw_residue_support (P : D → Prop) [DecidablePred P] + (u : PrincipalAxisTuples (α := α) P L) + (hu : (containedSupportedProgressionAxisLaw B h L H step c hL hH hsubset q r hcell P).weight u ≠ 0) : + ∀ j a, ((u j a : ℤ) : ZMod q) = + (if a = none then (c ⟨j.1.val, j.2⟩ : ZMod q) else 0) + + (step ⟨j.1.val, j.2⟩ : ZMod q) * r ⟨j.1.val, j.2⟩ a := by + rw [← containedSupportedProgressionAxisLaw_fiberLaw B h L H step c hL hH hsubset q r hcell P] at hu + apply (law).fiberLaw_support (principalAxisRestrict P) _ _ u hu + intro y hy j a + exact containedSupportedProgressionLaw_residue_support B h L H step c hL hH hsubset q r hcell y hy ⟨j.1.val, j.2⟩ a + +theorem containedSupportedProgressionAxisLaw_residue_eq (P : D → Prop) [DecidablePred P] + (u v : PrincipalAxisTuples (α := α) P L) + (hu : (containedSupportedProgressionAxisLaw B h L H step c hL hH hsubset q r hcell P).weight u ≠ 0) + (hv : (containedSupportedProgressionAxisLaw B h L H step c hL hH hsubset q r hcell P).weight v ≠ 0) : + principalResidueLabel q u = principalResidueLabel q v := by + funext j a + exact (containedSupportedProgressionAxisLaw_residue_support B h L H step c hL hH hsubset q r hcell P u hu j a).trans + (containedSupportedProgressionAxisLaw_residue_support B h L H step c hL hH hsubset q r hcell P v hv j a).symm + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem integerProgressionSupport_subset_iff_fin (L H step : ℕ) (start : ℤ) : + integerProgressionSupport start (step : ℤ) H ⊆ Finset.Ico (0 : ℤ) (L : ℤ) ↔ + ∀ t : Fin H, 0 ≤ start + (step : ℤ) * t.val ∧ + start + (step : ℤ) * t.val < L := by + constructor + · intro hs t + apply Finset.mem_Ico.mp + apply hs + rw [integerProgressionSupport, mem_translateSupport] + apply Finset.mem_image.mpr + refine ⟨(t.val : ℤ), Finset.mem_Ico.mpr ⟨Int.natCast_nonneg _, by exact_mod_cast t.isLt⟩, ?_⟩ + change (step : ℤ) * t.val = _ + ring + · intro hi z hz + rw [integerProgressionSupport, mem_translateSupport] at hz + obtain ⟨v, hv, he⟩ := Finset.mem_image.mp hz + have hv' := Finset.mem_Ico.mp hv + let t : Fin H := ⟨v.toNat, by omega⟩ + have ht : (t.val : ℤ) = v := Int.toNat_of_nonneg hv'.1 + have hi' := hi t + rw [ht] at hi' + change (step : ℤ) * v = _ at he + apply Finset.mem_Ico.mpr + constructor <;> omega + +theorem integerProgressionSupport_subset_of_fin (L H step : ℕ) (start : ℤ) + (hinside : ∀ t : Fin H, 0 ≤ start + (step : ℤ) * t.val ∧ + start + (step : ℤ) * t.val < L) : + integerProgressionSupport start (step : ℤ) H ⊆ Finset.Ico (0 : ℤ) (L : ℤ) := + (integerProgressionSupport_subset_iff_fin L H step start).mpr hinside + +private def finIntegerIntervalEquiv (L : ℕ) : + Fin L ≃ ↥(Finset.Ico (0 : ℤ) (L : ℤ)) where + toFun t := ⟨t.val, Finset.mem_Ico.mpr ⟨Int.natCast_nonneg _, by exact_mod_cast t.isLt⟩⟩ + invFun z := ⟨z.val.toNat, by have hz := Finset.mem_Ico.mp z.property; omega⟩ + left_inv t := by apply Fin.ext; simp + right_inv z := by + apply Subtype.ext + change (z.val.toNat : ℤ) = z.val + exact Int.toNat_of_nonneg (Finset.mem_Ico.mp z.property).1 + +def zeroScalarFinPoint (L : ℕ) (t : Fin L) : IntegerScalarCubeBox Empty L := + fun _ => ⟨t.val, Finset.mem_Ico.mpr ⟨by omega, by exact_mod_cast t.isLt⟩⟩ + +private theorem zeroScalar_fin_mean (L : ℕ) (hL : 0 < L) + (f : IntegerScalarCubeBox Empty L → ℝ) : + (integerScalarCubeWeights Empty L hL).mean f = 𝔼 t : Fin L, f (zeroScalarFinPoint L t) := by + rw [integerScalarCubeWeights_mean] + apply Fintype.expect_equiv + ((zeroScalarCubeIntervalEquiv Empty L).trans (finIntegerIntervalEquiv L).symm) + intro x + congr 1 + funext a + apply Subtype.ext + cases a with + | none => + have hx := ((mem_integerScalarCubeSet L x.val).mp x.property) ∅ + simp only [integerScalarCubeValue, Finset.sum_empty, add_zero] at hx + exact (Int.toNat_of_nonneg hx.1).symm + | some a => exact isEmptyElim a + +theorem zeroScalar_fin_complexMean (L : ℕ) (hL : 0 < L) + (f : IntegerScalarCubeBox Empty L → ℂ) : + (integerScalarCubeWeights Empty L hL).complexMean f = + 𝔼 t : Fin L, f (zeroScalarFinPoint L t) := by + let : Nonempty (Fin L) := ⟨⟨0, hL⟩⟩ + rw [← FiniteProbabilityWeights.uniform_complexMean] + apply Complex.ext + · simpa only [FiniteProbabilityWeights.complexMean_re, FiniteProbabilityWeights.uniform_mean] + using zeroScalar_fin_mean L hL (fun z => (f z).re) + · simpa only [FiniteProbabilityWeights.complexMean_im, FiniteProbabilityWeights.uniform_mean] + using zeroScalar_fin_mean L hL (fun z => (f z).im) + +theorem integerScalarCubeWeights_pi_fin_complexMean + {X : Type*} [Fintype X] [DecidableEq X] + (H : X → ℕ) (hH : ∀ i, 0 < H i) + (f : (∀ i, IntegerScalarCubeBox Empty (H i)) → ℂ) : + (FiniteProbabilityWeights.pi (fun i => integerScalarCubeWeights Empty (H i) (hH i))).complexMean f = + 𝔼 t : (∀ i, Fin (H i)), f (fun i => zeroScalarFinPoint (H i) (t i)) := by + let : ∀ i, Nonempty (Fin (H i)) := fun i => ⟨⟨0, hH i⟩⟩ + have htransport := FiniteProbabilityWeights.complexMean_pi_transport_fintype + (fun i => integerScalarCubeWeights Empty (H i) (hH i)) + (fun i => FiniteProbabilityWeights.uniform (Fin (H i))) + (fun _ x => x) (fun i => zeroScalarFinPoint (H i)) + (fun i g => (zeroScalar_fin_complexMean (H i) (hH i) g).trans + (FiniteProbabilityWeights.uniform_complexMean _).symm) f + exact htransport.trans (FiniteProbabilityWeights.pi_uniform_complexMean _) + +variable {D : Type*} [Fintype D] [DecidableEq D] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] (h : D → ℕ) +variable (H : PrincipalTupleIndex B h → ℕ) (hH : ∀ j, 0 < H j) + +def principalFinTuplePoint (t : ∀ j, Fin (H j)) : PrincipalIntegerTuples B h Empty H := + fun j => zeroScalarFinPoint (H j) (t j) + +theorem principalTupleWeights_fin_complexMean (f : PrincipalIntegerTuples B h Empty H → ℂ) : + (principalTupleWeights (α := Empty) B h H hH).complexMean f = + 𝔼 t : (∀ j, Fin (H j)), f (principalFinTuplePoint B h H t) := by + exact integerScalarCubeWeights_pi_fin_complexMean H hH f + +theorem principalTupleWeights_fin_mean (f : PrincipalIntegerTuples B h Empty H → ℝ) : + (principalTupleWeights (α := Empty) B h H hH).mean f = + 𝔼 t : (∀ j, Fin (H j)), f (principalFinTuplePoint B h H t) := by + let : ∀ j, Nonempty (Fin (H j)) := fun j => ⟨⟨0, hH j⟩⟩ + have he := congrArg Complex.re (principalTupleWeights_fin_complexMean B h H hH (fun z => (f z : ℂ))) + rw [← FiniteProbabilityWeights.uniform_complexMean] at he + simpa only [FiniteProbabilityWeights.complexMean_re, Complex.ofReal_re, + FiniteProbabilityWeights.uniform_mean] using he + +def principalFinResidueLabel (q : ℕ) (t : ∀ j, Fin (H j)) : + PrincipalTupleIndex B h → Option Empty → ZMod q := fun j _ => ((t j).val : ZMod q) + +noncomputable def principalFinResidueCell (q : ℕ) + (r : PrincipalTupleIndex B h → Option Empty → ZMod q) : Finset (∀ j, Fin (H j)) := + Finset.univ.filter (fun t => principalFinResidueLabel B h H q t = r) + +omit [Fintype D] [DecidableEq D] [∀ index, Fintype (B index)] + [∀ index, DecidableEq (B index)] in +theorem principalFinTuplePoint_residue [Fintype D] [DecidableEq D] + [∀ index, Fintype (B index)] [∀ index, DecidableEq (B index)] + (q : ℕ) (t : ∀ j, Fin (H j)) : + principalResidueLabel q (principalFinTuplePoint B h H t) = principalFinResidueLabel B h H q t := by + funext j a + simp only [principalResidueLabel, principalFinTuplePoint, zeroScalarFinPoint, + principalFinResidueLabel, Int.cast_natCast] + +theorem principalFinResidueCell_mass (q : ℕ) + (r : PrincipalTupleIndex B h → Option Empty → ZMod q) : + letI : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + (FiniteProbabilityWeights.uniform (∀ j, Fin (H j))).mass (principalFinResidueCell B h H q r) = + (principalTupleWeights (α := Empty) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) := by + let : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + rw [← FiniteProbabilityWeights.mean_indicator, ← FiniteProbabilityWeights.mean_indicator, + FiniteProbabilityWeights.uniform_mean, principalTupleWeights_fin_mean] + simp only [principalFinResidueCell, Finset.mem_filter, Finset.mem_univ, true_and, + principalFinTuplePoint_residue] + +variable (L step : PrincipalTupleIndex B h → ℕ) (start : PrincipalTupleIndex B h → ℤ) +variable (hL : ∀ j, 0 < L j) +variable (hinside : ∀ j (t : Fin (H j)), + 0 ≤ start j + (step j : ℤ) * t.val ∧ start j + (step j : ℤ) * t.val < L j) +variable (hsubset : ∀ j, integerProgressionSupport (start j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (L j : ℤ)) + +omit [Fintype D] [DecidableEq D] [∀ index, Fintype (B index)] + [∀ index, DecidableEq (B index)] in +theorem containedProgressionTupleMap_finPoint [Fintype D] [DecidableEq D] + [∀ index, Fintype (B index)] [∀ index, DecidableEq (B index)] + (t : ∀ j, Fin (H j)) : + containedProgressionTupleMap B h L H step start hL hsubset (principalFinTuplePoint B h H t) = + principalAffineIntervalPoint B h L H step start hinside t := by + funext j a + apply Subtype.ext + have hc : IntegerScalarCube (H j) (fun a => (principalFinTuplePoint B h H t j a : ℤ)) := by + intro row + have he : row = ∅ := Subsingleton.elim _ _ + simp only [he, integerScalarCubeValue, Finset.sum_empty, add_zero, + principalFinTuplePoint, zeroScalarFinPoint] + exact ⟨Int.natCast_nonneg _, by exact_mod_cast (t j).isLt⟩ + rw [containedProgressionTupleMap, + containedProgressionCubeMap_value Empty _ _ _ _ _ _ _ hc] + cases a with + | none => rfl + | some a => exact isEmptyElim a + +theorem principalAffineIntervalLaw_eq_contained : + principalAffineIntervalLaw B h L H step start hinside hH = + (principalTupleWeights (α := Empty) B h H hH).fiberLaw + (containedProgressionTupleMap B h L H step start hL hsubset) := by + have he (f : PrincipalIntegerTuples B h Empty L → ℝ) : + (principalAffineIntervalLaw B h L H step start hinside hH).mean f = + ((principalTupleWeights (α := Empty) B h H hH).fiberLaw + (containedProgressionTupleMap B h L H step start hL hsubset)).mean f := by + rw [principalAffineIntervalLaw_mean, FiniteProbabilityWeights.fiberLaw_mean, + principalTupleWeights_fin_mean] + apply Finset.expect_congr rfl + intro t _ + rw [containedProgressionTupleMap_finPoint B h H L step start hL hinside hsubset] + apply FiniteProbabilityWeights.toPMF_injective + ext z + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + rw [FiniteProbabilityWeights.toPMF_toReal, FiniteProbabilityWeights.toPMF_toReal] + simpa [FiniteProbabilityWeights.mean] using he (fun y => if y = z then 1 else 0) + +theorem containedSupportedProgressionLaw_fin_condition_mean + (q : ℕ) (r : PrincipalTupleIndex B h → Option Empty → ZMod q) + (hcell : 0 < (principalTupleWeights (α := Empty) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + (f : PrincipalIntegerTuples B h Empty L → ℝ) : + letI : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + (containedSupportedProgressionLaw B h L H step start hL hH hsubset q r hcell).mean f = + ((FiniteProbabilityWeights.uniform (∀ j, Fin (H j))).condition + (principalFinResidueCell B h H q r) + (by rw [principalFinResidueCell_mass B h H hH]; exact hcell)).mean + (fun t => f (principalAffineIntervalPoint B h L H step start hinside t)) := by + let : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + rw [containedSupportedProgressionLaw, FiniteProbabilityWeights.fiberLaw_mean, + FiniteProbabilityWeights.condition_mean, FiniteProbabilityWeights.condition_mean, + principalFinResidueCell_mass B h H hH, principalTupleWeights_fin_mean, + FiniteProbabilityWeights.uniform_mean] + congr 1 + apply Finset.expect_congr rfl + intro t _ + simp only [principalFinResidueCell, Finset.mem_filter, Finset.mem_univ, true_and, + principalFinTuplePoint_residue, + containedProgressionTupleMap_finPoint B h H L step start hL hinside hsubset] + +theorem containedSupportedProgressionLaw_fin_condition_complexMean + (q : ℕ) (r : PrincipalTupleIndex B h → Option Empty → ZMod q) + (hcell : 0 < (principalTupleWeights (α := Empty) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + (f : PrincipalIntegerTuples B h Empty L → ℂ) : + letI : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + (containedSupportedProgressionLaw B h L H step start hL hH hsubset q r hcell).complexMean f = + ((FiniteProbabilityWeights.uniform (∀ j, Fin (H j))).condition + (principalFinResidueCell B h H q r) + (by rw [principalFinResidueCell_mass B h H hH]; exact hcell)).complexMean + (fun t => f (principalAffineIntervalPoint B h L H step start hinside t)) := by + let : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + apply Complex.ext + · simpa only [FiniteProbabilityWeights.complexMean_re] using + containedSupportedProgressionLaw_fin_condition_mean B h H hH L step start hL hinside hsubset + q r hcell (fun z => (f z).re) + · simpa only [FiniteProbabilityWeights.complexMean_im] using + containedSupportedProgressionLaw_fin_condition_mean B h H hH L step start hL hinside hsubset + q r hcell (fun z => (f z).im) + +theorem containedSupportedProgressionLaw_eq_fin_condition + (q : ℕ) (r : PrincipalTupleIndex B h → Option Empty → ZMod q) + (hcell : 0 < (principalTupleWeights (α := Empty) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) : + letI : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + containedSupportedProgressionLaw B h L H step start hL hH hsubset q r hcell = + ((FiniteProbabilityWeights.uniform (∀ j, Fin (H j))).condition + (principalFinResidueCell B h H q r) + (by rw [principalFinResidueCell_mass B h H hH]; exact hcell)).finitePushforward + (principalAffineIntervalPoint B h L H step start hinside) := by + let : Nonempty (∀ j, Fin (H j)) := ⟨fun j => ⟨0, hH j⟩⟩ + apply FiniteProbabilityWeights.toPMF_injective + ext z + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + rw [FiniteProbabilityWeights.toPMF_toReal, FiniteProbabilityWeights.toPMF_toReal] + have hm := containedSupportedProgressionLaw_fin_condition_mean + B h H hH L step start hL hinside hsubset q r hcell (fun y => if y = z then 1 else 0) + simp only [FiniteProbabilityWeights.mean, mul_ite, mul_one, mul_zero, + Finset.sum_ite_eq', Finset.mem_univ, ite_true] at hm + rw [hm] + unfold FiniteProbabilityWeights.finitePushforward + apply Finset.sum_congr rfl + intro t _ + by_cases ht : principalAffineIntervalPoint B h L H step start hinside t = z <;> simp [ht] + +theorem principalAffineIntervalPoint_residue (q : ℕ) (t : ∀ j, Fin (H j)) + (r : PrincipalTupleIndex B h → Option Empty → ZMod q) + (ht : t ∈ principalFinResidueCell B h H q r) : + ∀ j a, ((principalAffineIntervalPoint B h L H step start hinside t j a : ℤ) : ZMod q) = + (start j : ZMod q) + (step j : ZMod q) * r j a := by + have hr := (Finset.mem_filter.mp ht).2 + intro j a + have hj := congrFun (congrFun hr j) a + simp only [principalFinResidueLabel] at hj + simp only [principalAffineIntervalPoint_value, Int.cast_add, Int.cast_mul, Int.cast_natCast, hj] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {D : Type*} [Fintype D] [DecidableEq D] +variable (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] (h : D → ℕ) +variable (L H step : PrincipalTupleIndex B h → ℕ) (start : PrincipalTupleIndex B h → ℤ) +variable (hinside : ∀ j (t : Fin (H j)), + 0 ≤ start j + (step j : ℤ) * t.val ∧ start j + (step j : ℤ) * t.val < L j) +variable (hH : ∀ j, 0 < H j) (P : D → Prop) + +theorem principalAffineIntervalLaw_partition_complexMean + (f : PrincipalIntegerTuples B h Empty L → ℂ) : + (principalAffineIntervalLaw B h L H step start hinside hH).complexMean f = + (principalAffineIntervalLaw (fun d : {d // P d} => B d.val) (fun d => h d.val) + (principalAxisLength P L) (principalAxisLength P H) (principalAxisLength P step) + (fun j => start ⟨j.1.val, j.2⟩) (fun j t => hinside ⟨j.1.val, j.2⟩ t) + (fun j => hH ⟨j.1.val, j.2⟩)).complexMean (fun u => + (principalAffineIntervalLaw (fun d : {d // ¬P d} => B d.val) (fun d => h d.val) + (principalAxisLength (fun d => ¬P d) L) (principalAxisLength (fun d => ¬P d) H) + (principalAxisLength (fun d => ¬P d) step) + (fun j => start ⟨j.1.val, j.2⟩) (fun j t => hinside ⟨j.1.val, j.2⟩ t) + (fun j => hH ⟨j.1.val, j.2⟩)).complexMean (fun v => f (principalAxisJoin P u v))) := by + have hL (j : PrincipalTupleIndex B h) : 0 < L j := by + have hi := hinside j ⟨0, hH j⟩ + omega + have hsubset (j : PrincipalTupleIndex B h) : + integerProgressionSupport (start j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (L j : ℤ) := + integerProgressionSupport_subset_of_fin _ _ _ _ (hinside j) + rw [principalAffineIntervalLaw_eq_contained B h H hH L step start hL hinside hsubset, + FiniteProbabilityWeights.fiberLaw_complexMean, + principalTupleWeights_partition P H hH] + rw [principalAffineIntervalLaw_eq_contained + (fun d : {d // P d} => B d.val) (fun d => h d.val) + (principalAxisLength P H) (fun j => hH ⟨j.1.val, j.2⟩) + (principalAxisLength P L) (principalAxisLength P step) (fun j => start ⟨j.1.val, j.2⟩) + (fun j => hL ⟨j.1.val, j.2⟩) (fun j t => hinside ⟨j.1.val, j.2⟩ t) + (fun j => hsubset ⟨j.1.val, j.2⟩), + FiniteProbabilityWeights.fiberLaw_complexMean] + apply congrArg _ + funext u + rw [principalAffineIntervalLaw_eq_contained + (fun d : {d // ¬P d} => B d.val) (fun d => h d.val) + (principalAxisLength (fun d => ¬P d) H) (fun j => hH ⟨j.1.val, j.2⟩) + (principalAxisLength (fun d => ¬P d) L) (principalAxisLength (fun d => ¬P d) step) + (fun j => start ⟨j.1.val, j.2⟩) + (fun j => hL ⟨j.1.val, j.2⟩) (fun j t => hinside ⟨j.1.val, j.2⟩ t) + (fun j => hsubset ⟨j.1.val, j.2⟩), + FiniteProbabilityWeights.fiberLaw_complexMean] + apply congrArg _ + funext v + rw [containedProgressionTupleMap_axisJoin] + +theorem principalAffineIntervalAxisLaw_complexMean_restricted + (f : PrincipalAxisTuples (α := Empty) P L → ℂ) : + (principalAffineIntervalAxisLaw B h L H step start hinside hH P).complexMean f = + (principalAffineIntervalLaw (fun d : {d // P d} => B d.val) (fun d => h d.val) + (principalAxisLength P L) (principalAxisLength P H) (principalAxisLength P step) + (fun j => start ⟨j.1.val, j.2⟩) (fun j t => hinside ⟨j.1.val, j.2⟩ t) + (fun j => hH ⟨j.1.val, j.2⟩)).complexMean f := by + rw [principalAffineIntervalAxisLaw, FiniteProbabilityWeights.complexMean_finitePushforward, + principalAffineIntervalLaw_partition_complexMean B h L H step start hinside hH P] + simp only [principalAxisRestrict_join_left, FiniteProbabilityWeights.complexMean_const] + +theorem principalAffineIntervalAxisLaw_eq_restricted : + principalAffineIntervalAxisLaw B h L H step start hinside hH P = + principalAffineIntervalLaw (fun d : {d // P d} => B d.val) (fun d => h d.val) + (principalAxisLength P L) (principalAxisLength P H) (principalAxisLength P step) + (fun j => start ⟨j.1.val, j.2⟩) (fun j t => hinside ⟨j.1.val, j.2⟩ t) + (fun j => hH ⟨j.1.val, j.2⟩) := by + apply FiniteProbabilityWeights.toPMF_injective + ext z + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + rw [FiniteProbabilityWeights.toPMF_toReal, FiniteProbabilityWeights.toPMF_toReal] + have he := congrArg Complex.re + (principalAffineIntervalAxisLaw_complexMean_restricted B h L H step start hinside hH P + (fun y => if y = z then 1 else 0)) + simpa [FiniteProbabilityWeights.complexMean] using he + +theorem principalAffineIntervalLaw_axis_complexMean + (f : PrincipalIntegerTuples B h Empty L → ℂ) : + (principalAffineIntervalLaw B h L H step start hinside hH).complexMean f = + (principalAffineIntervalAxisLaw B h L H step start hinside hH P).complexMean (fun u => + (principalAffineIntervalLaw (fun d : {d // ¬P d} => B d.val) (fun d => h d.val) + (principalAxisLength (fun d => ¬P d) L) (principalAxisLength (fun d => ¬P d) H) + (principalAxisLength (fun d => ¬P d) step) + (fun j => start ⟨j.1.val, j.2⟩) (fun j t => hinside ⟨j.1.val, j.2⟩ t) + (fun j => hH ⟨j.1.val, j.2⟩)).complexMean (fun v => f (principalAxisJoin P u v))) := by + rw [principalAffineIntervalAxisLaw_eq_restricted] + exact principalAffineIntervalLaw_partition_complexMean B h L H step start hinside hH P f + +theorem principalAffineIntervalLaw_axis_contained_complexMean + (hL : ∀ j : PrincipalTupleIndex (fun d : {d // ¬P d} => B d.val) (fun d => h d.val), + 0 < principalAxisLength (fun d => ¬P d) L j) + (hsubset : ∀ j : PrincipalTupleIndex (fun d : {d // ¬P d} => B d.val) (fun d => h d.val), + integerProgressionSupport (start ⟨j.1.val, j.2⟩) + (principalAxisLength (fun d => ¬P d) step j : ℤ) + (principalAxisLength (fun d => ¬P d) H j) ⊆ + Finset.Ico (0 : ℤ) (principalAxisLength (fun d => ¬P d) L j : ℤ)) + (f : PrincipalIntegerTuples B h Empty L → ℂ) : + (principalAffineIntervalLaw B h L H step start hinside hH).complexMean f = + (principalAffineIntervalAxisLaw B h L H step start hinside hH P).complexMean (fun u => + (principalTupleWeights (α := Empty) (fun d : {d // ¬P d} => B d.val) (fun d => h d.val) + (principalAxisLength (fun d => ¬P d) H) (fun j => hH ⟨j.1.val, j.2⟩)).complexMean + (fun v => f (principalAxisJoin P u + (containedProgressionTupleMap (fun d : {d // ¬P d} => B d.val) (fun d => h d.val) + (principalAxisLength (fun d => ¬P d) L) (principalAxisLength (fun d => ¬P d) H) + (principalAxisLength (fun d => ¬P d) step) (fun j => start ⟨j.1.val, j.2⟩) + hL hsubset v)))) := by + rw [principalAffineIntervalLaw_axis_complexMean B h L H step start hinside hH P] + apply congrArg _ + funext u + rw [principalAffineIntervalLaw_eq_contained + (fun d : {d // ¬P d} => B d.val) (fun d => h d.val) + (principalAxisLength (fun d => ¬P d) H) (fun j => hH ⟨j.1.val, j.2⟩) + (principalAxisLength (fun d => ¬P d) L) (principalAxisLength (fun d => ¬P d) step) + (fun j => start ⟨j.1.val, j.2⟩) hL (fun j t => hinside ⟨j.1.val, j.2⟩ t) hsubset, + FiniteProbabilityWeights.fiberLaw_complexMean] + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (M : ℕ) (hM : 0 < M) +variable (r : PrincipalTupleIndex + (fun a : {a // ¬allocatedGridAxis (I := I) U b S.value a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod M) +variable (hsize : ∀ d, (Fintype.card α + 1) * M ≤ + principalAxisLength (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S) d) + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides + +theorem allocatedLongResidueWeights_support_label + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + (hv : (allocatedLongResidueWeights B U b S M hM r hsize).weight v ≠ 0) : + principalResidueLabel M v = r := by + have h := principalResidueWeights_support (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) lengths + (fun j => allocatedPrincipalSides_pos B U b S ⟨j.1.val, j.2⟩) M hM r hsize v hv + funext j i + exact congrFun h ⟨j.1, j.2.1, j.2.2, i⟩ + +include hM hsize in +theorem exists_allocatedLongResidueReference : + ∃ v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides, principalResidueLabel M v = r := by + obtain ⟨v, hv, _⟩ := principalResidue_positive_witness (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) lengths + (fun j => allocatedPrincipalSides_pos B U b S ⟨j.1.val, j.2⟩) M hM hsize r + exact ⟨v, hv⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) + +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S)) + +omit [Fintype α] [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] + [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] in +theorem allocatedNonkernelJetMatrix_residue_of_label + (v w : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U b S.value) a) (allocatedPrincipalSides B U b S)) (M : ℕ) + (hlabel : principalResidueLabel M v = principalResidueLabel M w) (j : Fin m) : + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) M = + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j w) M := + integerMappedJetMatrix_residue (allocatedNonkernelExponent B j) + (partitionedPrincipalInput (allocatedGridAxis (I := I) U b S.value) (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (rows j) (principalTupleIntegers v) (principalTupleIntegers w) M + (congrArg principalTupleResidues hlabel) + +omit [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] in +theorem allocatedLongResidueWeights_reference_matrix + (M : ℕ) (hM : 0 < M) + (label : PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U b S.value) a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod M) + (hsize : ∀ t, (Fintype.card α+1)*M ≤ (principalAxisLength (fun a => ¬allocatedGridAxis (I := I) U b S.value a) (allocatedPrincipalSides B U b S)) t) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U b S.value) a) (allocatedPrincipalSides B U b S)) + (hv₀ : principalResidueLabel M v₀ = label) + (period : ℕ) (hdiv : period ∣ M) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod period)) + (hr : ∀ v, (allocatedLongResidueWeights B U b S M hM label hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) period = residue j) : + ∀ j, integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v₀) period = residue j := by + classical + let p := allocatedLongResidueWeights B U b S M hM label hsize + have hex : ∃ v, p.weight v ≠ 0 := by + by_contra! h + have ht := p.total + simp only [h, Finset.sum_const_zero] at ht + exact zero_ne_one ht + obtain ⟨v, hv⟩ := hex + have hl := (allocatedLongResidueWeights_support_label B U b S M hM label hsize v hv).trans hv₀.symm + intro j + have he := integerResidueMatrix_reduce _ _ hdiv + (allocatedNonkernelJetMatrix_residue_of_label B U b S x rows u v v₀ M hl j) + exact he.symm.trans (hr v hv j) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S +variable (u u₀ : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S)) +variable (v v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U b S.value) a) (allocatedPrincipalSides B U b S)) +variable {O : Fin m → Type*} (rows : ∀ j, O j → Finset α) (q : ℕ) +variable (hu : principalResidueLabel q u = principalResidueLabel q u₀) +variable (hv : principalResidueLabel q v = principalResidueLabel q v₀) + +include hu hv + +theorem allocatedNonkernelJetMatrix_residue_both (j : Fin m) : + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) q = + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u₀ rows j v₀) q := by + apply integerMappedJetMatrix_residue_both + · funext z + cases z with + | inl z => rfl + | inr z => exact congrFun (congrArg principalTupleResidues hu) z + · exact congrArg principalTupleResidues hv + +theorem allocatedPartitionedJetMatrix_residue_both (j : Fin m) : + integerResidueMatrix (allocatedPartitionedJetMatrix B U b S x u v rows j) q = + integerResidueMatrix (allocatedPartitionedJetMatrix B U b S x u₀ v₀ rows j) q := by + apply integerMappedJetMatrix_residue_both + · funext z + cases z with + | inl z => rfl + | inr z => exact congrFun (congrArg principalTupleResidues hu) z + · exact congrArg principalTupleResidues hv + +variable [∀ j, Fintype (O j)] + +theorem allocatedPartitionedJetMatrix_image_eq_of_residue_both + (hperiod : ∀ j, integerScalarLattice (O j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) (j : Fin m) : + (allocatedPartitionedJetMatrix B U b S x u v rows j).mulVecLin.range = + (allocatedPartitionedJetMatrix B U b S x u₀ v₀ rows j).mulVecLin.range := by + apply integerMatrixImage_eq_of_residueMatrix _ _ q + · exact (hperiod j).trans (allocatedPartitionedJetMatrix_kernel_range_le B U b S x u v rows j) + · exact (hperiod j).trans (allocatedPartitionedJetMatrix_kernel_range_le B U b S x u₀ v₀ rows j) + · exact allocatedPartitionedJetMatrix_residue_both B U b S x u u₀ v v₀ rows q hu hv j + +theorem allocatedPhysicalDeckJet_law_eq_of_residue_both + (Q : Fin m → Type*) [∀ j, Fintype (Q j)] + (hperiod : ∀ j, integerScalarLattice (O j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (d : ℕ) [NeZero d] : + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d)).map + (coefficientDeckJetMap (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u v)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u v)) rows d) = + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d)).map + (coefficientDeckJetMap (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u₀ v₀)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u₀ v₀)) rows d) := by + have hr (j : Fin m) : + (boundedCoefficientJetMatrix (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u v)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u v)) (j.val + 1) (rows j)).mulVecLin.range = + (boundedCoefficientJetMatrix (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u₀ v₀)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u₀ v₀)) (j.val + 1) (rows j)).mulVecLin.range := by + rw [← allocatedPartitionedJetMatrix_eq_physical B U b S x u v rows j, + ← allocatedPartitionedJetMatrix_eq_physical B U b S x u₀ v₀ rows j] + exact allocatedPartitionedJetMatrix_image_eq_of_residue_both B U b S x u u₀ v v₀ rows q hu hv hperiod j + exact uniformPMF_map_hom_eq_of_range_eq _ _ + (coefficientDeckJetMap_range_eq_of_integer_range_eq + (α := α) (K := LayerSamplerVariables G I n B) (O := O) (B := Q) _ _ rows _ _ hr d) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) ((allocatedPrincipalSides B U b S) j : ℤ)) +variable (q : ℕ) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) sides H step c + (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell grid +local notation "longLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) sides H step c + (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell (fun a => ¬grid a) +variable (u u₀ : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S)) +variable (hu : ((containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell (allocatedGridAxis (I := I) U b S.value))).weight u ≠ 0) (hu₀ : ((containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell (allocatedGridAxis (I := I) U b S.value))).weight u₀ ≠ 0) +variable (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U b S.value) a) (allocatedPrincipalSides B U b S)) +variable {O : Fin m → Type*} (rows : ∀ j, O j → Finset α) + +include hu hu₀ + +theorem allocatedSupportedSlicedNonkernel_residue_constant (j : Fin m) : + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v₀) q = + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u₀ rows j v₀) q := by + have hlabel := containedSupportedProgressionAxisLaw_residue_eq B (layerSamplerDegree I n) sides H step c + (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell grid u u₀ hu hu₀ + exact allocatedNonkernelJetMatrix_residue_both B U b S x u u₀ v₀ v₀ rows q hlabel rfl j + +variable [∀ j, Fintype (O j)] + +theorem allocatedSupportedSlicedDeck_law_constant + (Q : Fin m → Type*) [∀ j, Fintype (Q j)] + (hperiod : ∀ j, integerScalarLattice (O j) (q : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (d : ℕ) [NeZero d] : + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d)).map + (coefficientDeckJetMap (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u v₀)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u v₀)) rows d) = + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d)).map + (coefficientDeckJetMap (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u₀ v₀)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u₀ v₀)) rows d) := by + have hlabel := containedSupportedProgressionAxisLaw_residue_eq B (layerSamplerDegree I n) sides H step c + (allocatedPrincipalSides_pos B U b S) hH hsubset q r hcell grid u u₀ hu hu₀ + exact allocatedPhysicalDeckJet_law_eq_of_residue_both B U b S x u u₀ v₀ v₀ rows q hlabel rfl Q hperiod d + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidueGrid.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidueGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..85f2107c6271354e7720887f3209c126c7cef7fc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidueGrid.lean @@ -0,0 +1,522 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedSupportedSlicedResidueJet +import OAI.Combinatorics.Progressions.Probability.ContainedProgressionJetSourceLaw +import OAI.Combinatorics.Progressions.Sampling.DenseSliceGridScale + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical NNReal + +theorem positiveAffineModerate_grid_approximation_on_cover + {B I : Type*} [Fintype B] [DecidableEq B] [Fintype I] [DecidableEq I] {n : ℕ} + (c : B → NormalizedScalarCubeSource Empty) + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V W L ε : ℝ} + (hU : 1 ≤ U) (hc : ∀ b, ScalarCubePrimitiveBudget (c b) A U) + (hs : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) + (hv : ∀ b j i, 0 < v b j i) + (hstride : ∀ b j i, ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U) + (hpositive : ∀ b z, (c b).source.weight z ≠ 0 → ((c b).length : ℝ) / 4 ≤ (z none : ℝ)) + (hV : 0 ≤ V) (hW : 0 ≤ W) (hL : 0 ≤ L) (hε : 0 < ε) (hε1 : ε ≤ 1) + (hlen : ∀ b j, L ≤ (s b j).length) + (K M t : ℕ) [NeZero M] + (hscale : ∀ b, (M : ℝ) / (((c b).length : ℝ) * ∏ j, ((s b j).length : ℝ)) ≤ V) + (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n + 1) + (hB : positiveModerateSpectrumBlockCount n J.card t ≤ Fintype.card B) + (hsize : (M : ℝ) ^ J.card ≤ W * L ^ t) : + let F := positiveModerateSpectrumCover J M n U V L + (positiveModerateRetainedBias n J.card t U V W ε); + (F.card : ℝ) ≤ positiveModerateSpectrumCardBudget n J.card t U V W ε ∧ + ∀ shift z : J → ℤ, + ‖(integerGridDensity (weightedModerateIntegerProductSource c s) + (weightedAffineModerateIntegerJetSum c s u v J (fun _ => 0) shift) K M z : ℂ) - + weightedAffineModerateGridApproximation c s u v K M J (fun _ => 0) shift z F‖ ≤ + ((K : ℝ) / M) ^ J.card * ε := by + intro F + obtain ⟨hζ, hζ1, hacc⟩ := positiveModerateRetainedBias_spec n J.card t (V := V) hU hW hε hε1 + have htail := weightedPositiveAffineModerate_uniform_spectrum_tail c s A hA hU hc hs + (fun b j i => (u b j i : ℝ)) v hv hstride hpositive hV hW hL hζ hζ1 hε.le hlen + (Nat.pos_of_ne_zero (NeZero.ne M)) hscale J hJ hB hsize hacc + refine ⟨?_, fun shift z => ?_⟩ + · simpa only [Fintype.card_coe] using + positiveModerateSpectrumCover_card_budget J M n t hU hV hW hL hε hε1 + (by simpa only [Fintype.card_coe] using hsize) + · exact weightedAffineModerateGridDensity_error_of_tail c s u v K M J (fun _ => 0) F + (by simpa only [Int.cast_zero] using htail) shift z + +theorem positiveAffineModerate_grid_approximation + {B I : Type*} [Fintype B] [DecidableEq B] [Fintype I] [DecidableEq I] {n : ℕ} + (c : B → NormalizedScalarCubeSource Empty) + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V W L ε : ℝ} + (hU : 1 ≤ U) (hc : ∀ b, ScalarCubePrimitiveBudget (c b) A U) + (hs : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) + (hv : ∀ b j i, 0 < v b j i) + (hstride : ∀ b j i, ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U) + (hpositive : ∀ b z, (c b).source.weight z ≠ 0 → ((c b).length : ℝ) / 4 ≤ (z none : ℝ)) + (hV : 0 ≤ V) (hW : 0 ≤ W) (hL : 0 ≤ L) (hε : 0 < ε) (hε1 : ε ≤ 1) + (hlen : ∀ b j, L ≤ (s b j).length) + (K M t : ℕ) [NeZero M] + (hscale : ∀ b, (M : ℝ) / (((c b).length : ℝ) * ∏ j, ((s b j).length : ℝ)) ≤ V) + (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n + 1) + (hB : positiveModerateSpectrumBlockCount n J.card t ≤ Fintype.card B) + (hsize : (M : ℝ) ^ J.card ≤ W * L ^ t) : + ∃ F : Finset (J → Fin M), + (F.card : ℝ) ≤ positiveModerateSpectrumCardBudget n J.card t U V W ε ∧ + ∀ shift z : J → ℤ, + ‖(integerGridDensity (weightedModerateIntegerProductSource c s) + (weightedAffineModerateIntegerJetSum c s u v J (fun _ => 0) shift) K M z : ℂ) - + weightedAffineModerateGridApproximation c s u v K M J (fun _ => 0) shift z F‖ ≤ + ((K : ℝ) / M) ^ J.card * ε := by + let ζ := positiveModerateRetainedBias n J.card t U V W ε + let F := positiveModerateSpectrumCover J M n U V L ζ + obtain ⟨hζ, hζ1, hacc⟩ := positiveModerateRetainedBias_spec n J.card t (V := V) hU hW hε hε1 + have htail := weightedPositiveAffineModerate_uniform_spectrum_tail c s A hA hU hc hs + (fun b j i => (u b j i : ℝ)) v hv hstride hpositive hV hW hL hζ hζ1 hε.le hlen + (Nat.pos_of_ne_zero (NeZero.ne M)) hscale J hJ hB hsize hacc + refine ⟨F, ?_, fun shift z => ?_⟩ + · simpa only [Fintype.card_coe] using + positiveModerateSpectrumCover_card_budget J M n t hU hV hW hL hε hε1 + (by simpa only [Fintype.card_coe] using hsize) + · exact weightedAffineModerateGridDensity_error_of_tail c s u v K M J (fun _ => 0) F + (by simpa only [Int.cast_zero] using htail) shift z + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ t, 0 < H t) +variable (hsubset : ∀ t, integerProgressionSupport (c t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (hsize : ∀ t, (Fintype.card α + 1) * q ≤ H t) +variable (j : Fin m) (i : Fin (n j)) + +local notation "conditioned" => containedProgressionResidueLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H step c (allocatedPrincipalSides_pos B U basis S) hH hsubset q hq r hsize + +noncomputable def allocatedSlicedResidueJetPMF + (rows : Finset (Finset α)) (shift : rows → ℤ) : PMF (rows → ℤ) := + (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b))).bind + (fun coeff => (conditioned).toPMF.map (fun y => + shift + ∑ b, fun t : rows => coeff b * + integerBooleanBlockJet (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t)) + +theorem allocatedSlicedResidueJetPMF_source + (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (shift : rows → ℤ) : + let sources := principalSupportedAxisSources B (layerSamplerDegree I n) H hH q hq r + ⟨j, Sum.inr i⟩ (fun b v => hsize ⟨⟨j,Sum.inr i⟩,b,v⟩) + let coeff := fun _ : B ⟨j,Sum.inr i⟩ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive + let lower := fun (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) (a : Option α) => + if a = none then c ⟨⟨j,Sum.inr i⟩,b,v⟩ else 0 + let strides := fun (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) (_ : Option α) => + step ⟨⟨j,Sum.inr i⟩,b,v⟩ + (weightedModerateIntegerProductSource coeff sources).toPMF.map + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) = + allocatedSlicedResidueJetPMF B U basis hR hσ S q hq r H step c hH hsubset hsize j i rows shift := by + intro sources coeff lower strides + have hp := containedProgressionResidueLaw_jet_sum_law B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H step c (allocatedPrincipalSides_pos B U basis S) + hH hsubset q hq r hsize ⟨j,Sum.inr i⟩ coeff rows (fun _ => 0) shift + dsimp only at hp + have hc := congrArg (fun p : B ⟨j,Sum.inr i⟩ → PMF ℤ => dependentProductPMF p) + (funext (fun b => allocatedPrincipalNormalizedSource_law B U basis hR hσ S j i hactive b)) + rw [hc] at hp + simp only [zero_add] at hp + convert hp using 1 <;> rfl + +theorem allocatedSlicedResidueJetPMF_constant_mixture + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (rows : Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) : + (conditioned).toPMF.bind (fun y => + integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i)) = + (allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ none)).bind + (fun z => allocatedSlicedResidueJetPMF B U basis hR hσ S q hq r H step c hH hsubset hsize j i rows + (fun t => booleanCoefficient (fun _ : Finset α => z) t)) := by + let p := (conditioned).toPMF + let a := dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b)) + let constLaw := allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ none) + let f (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S)) + (z : ℤ) (coeff : B ⟨j, Sum.inr i⟩ → ℤ) : rows → ℤ := + (fun t : rows => booleanCoefficient (fun _ : Finset α => z) t) + + ∑ b, fun t : rows => coeff b * integerBooleanBlockJet + (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t + have hpoint y : integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i) = + constLaw.bind (fun z => a.map (f y z)) := by + rw [allocatedPhysicalGridJetPMF_principal B U basis hR hσ S j i hgrid, + independentProductPMF_option, PMF.map_bind] + simp only [PMF.map_comp] + apply congrArg (fun k : ℤ → PMF (rows → ℤ) => constLaw.bind k) + funext z + apply congrArg (fun g : (B ⟨j, Sum.inr i⟩ → ℤ) → rows → ℤ => a.map g) + funext coeff t + simp only [Function.comp_apply, f, Pi.add_apply, Finset.sum_apply, + Option.elim_none, Option.elim_some] + simp_rw [hpoint] + change p.bind (fun y => constLaw.bind (fun z => a.map (f y z))) = + constLaw.bind (fun z => a.bind (fun coeff => p.map (fun y => f y z coeff))) + refine (PMF.bind_comm p constLaw (fun y z => a.map (f y z))).trans ?_ + apply congrArg (fun k : ℤ → PMF (rows → ℤ) => constLaw.bind k) + funext z + exact PMF.bind_comm p a (fun y coeff => PMF.pure (f y z coeff)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ t, 0 < H t) +variable (hsubset : ∀ t, integerProgressionSupport (c t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (hsize : ∀ t, (Fintype.card α + 1) * q ≤ H t) +variable (j : Fin m) (i : Fin (n j)) + +noncomputable def allocatedSlicedGridDensity (M : ℕ) (rows : Finset (Finset α)) + (shift z : rows → ℤ) : ℝ := + (basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((allocatedSlicedResidueJetPMF B U basis hR hσ S q hq r H step c hH hsubset hsize j i rows shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal + +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) + +local notation "coeff" => (fun _ : B (Sigma.mk j (Sum.inr i)) => + allocatedPrincipalNormalizedSource B U basis hR S j i hactive) +local notation "sources" => principalSupportedAxisSources B (layerSamplerDegree I n) H hH q hq r + (Sigma.mk j (Sum.inr i)) (fun b v => hsize (Sigma.mk (Sigma.mk j (Sum.inr i)) (Prod.mk b v))) +local notation "lower" => (fun (b : B (Sigma.mk j (Sum.inr i))) (v : Fin (Fin.val j + 1)) (a : Option α) => + ite (a = none) (c (Sigma.mk (Sigma.mk j (Sum.inr i)) (Prod.mk b v))) 0) +local notation "strides" => (fun (b : B (Sigma.mk j (Sum.inr i))) (v : Fin (Fin.val j + 1)) (_ : Option α) => + step (Sigma.mk (Sigma.mk j (Sum.inr i)) (Prod.mk b v))) +local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i)) + +theorem allocatedSlicedGridDensity_approximation + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + {δ : ℝ} (hδ : 0 < δ) + (hlength : ∀ b v, δ * S.value ≤ (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) + (hstep : ∀ b v, 0 < step ⟨⟨j,Sum.inr i⟩,b,v⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + (hstride : ∀ b v, ((step ⟨⟨j,Sum.inr i⟩,b,v⟩ * q : ℕ) : ℝ) ≤ P) + {C ε : ℝ} {M : ℕ} [NeZero M] (hC : 0 ≤ C) + (hMK : (M : ℝ) ≤ C * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (hε : 0 < ε) (hε1 : ε ≤ 1) : + let V := (C / (2 * gamma)) / δ ^ (j.val + 1) + let t := (layerTailDegree m + 1) * rows.card + let W := C ^ rows.card / δ ^ t + ∃ F : Finset (rows → Fin M), + (F.card : ℝ) ≤ positiveModerateSpectrumCardBudget j.val rows.card t P V W ε ∧ + ∀ shift z : rows → ℤ, + ‖(allocatedSlicedGridDensity B U basis hR hσ S q hq r H step c hH hsubset hsize j i M rows shift z : ℂ) - + weightedAffineModerateGridApproximation coeff sources lower strides + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + intro V t W + have hc := (allocatedPrincipalNormalizedSource_primitive B U basis hR S j i hactive A).mono hcP + have hs (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) := + (principalSupportedAxisSources_primitive B (layerSamplerDegree I n) H hH q hq r + ⟨j,Sum.inr i⟩ (fun b v => hsize ⟨⟨j,Sum.inr i⟩,b,v⟩) b v A).mono hsP + have hgamma : 0 < gamma := principalProfileSize_pos (hR j) _ + have hV : 0 ≤ V := by dsimp [V]; positivity + have hW : 0 ≤ W := by dsimp [W]; positivity + have hscale (b : B ⟨j,Sum.inr i⟩) : + (M : ℝ) / (((coeff b).length : ℝ) * ∏ v, (((sources) b v).length : ℝ)) ≤ V := by + exact dense_slice_product_ratio (fun v => (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) hδ + (Nat.cast_pos.mpr S.positive) (Nat.cast_pos.mpr (coeff b).length_pos) (Nat.cast_nonneg M) + (hlength b) (allocatedPrincipalNormalizedSource_grid_ratio B U basis hR S j i hactive hC hMK) + have hcard : (M : ℝ) ^ rows.card ≤ W * (δ * S.value) ^ t := + dense_slice_grid_cardinality rows.card t hδ + (allocatedGrid_modulus_cardinality B U basis S j i hgrid hC hMK rows.card) + obtain ⟨F, hF, he⟩ := positiveAffineModerate_grid_approximation coeff sources lower strides A hA + hc.one_le (fun _ => hc) hs (fun b v _ => hstep b v) (fun b v _ => hstride b v) + (fun _ z hz => allocatedPrincipalNormalizedSource_positive_support B U basis hR S j i hactive z hz) + hV hW (mul_pos hδ (Nat.cast_pos.mpr S.positive)).le hε hε1 hlength + (basisAxisScale (basis j) i) M t hscale rows hrows hB hcard + refine ⟨F,hF,fun shift z => ?_⟩ + have hlaw := allocatedSlicedResidueJetPMF_source B U basis hR hσ S q hq r H step c hH hsubset hsize + j i hactive rows shift + have hd := integerGridDensity_eq_of_pmf_image (weightedModerateIntegerProductSource coeff sources) + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) + _ hlaw (basisAxisScale (basis j) i) M z + have hd' : integerGridDensity (weightedModerateIntegerProductSource coeff sources) + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) + (basisAxisScale (basis j) i) M z = + allocatedSlicedGridDensity B U basis hR hσ S q hq r H step c hH hsubset hsize j i M rows shift z := by + simpa only [allocatedSlicedGridDensity, Fintype.card_coe] using hd + rw [← hd'] + exact he shift z + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ t, 0 < H t) +variable (hsubset : ∀ t, integerProgressionSupport (c t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +variable (j : Fin m) (i : Fin (n j)) + +noncomputable def allocatedSupportedSlicedGridDensity (M : ℕ) (rows : Finset (Finset α)) + (shift z : rows → ℤ) : ℝ := + (basisAxisScale (basis j) i : ℝ) ^ rows.card * + (((allocatedSupportedSlicedResidueJetPMF B U basis hR hσ S q r H step c hH hsubset hcell j i rows shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal + +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +variable (hsize : ∀ b v, (Fintype.card α + 1) * q ≤ H ⟨⟨j,Sum.inr i⟩,b,v⟩) + +local notation "coeff" => (fun _ : B (Sigma.mk j (Sum.inr i)) => + allocatedPrincipalNormalizedSource B U basis hR S j i hactive) +local notation "sources" => principalSupportedAxisSources B (layerSamplerDegree I n) H hH q hq r + (Sigma.mk j (Sum.inr i)) hsize +local notation "lower" => (fun (b : B (Sigma.mk j (Sum.inr i))) (v : Fin (Fin.val j + 1)) (a : Option α) => + ite (a = none) (c (Sigma.mk (Sigma.mk j (Sum.inr i)) (Prod.mk b v))) 0) +local notation "strides" => (fun (b : B (Sigma.mk j (Sum.inr i))) (v : Fin (Fin.val j + 1)) (_ : Option α) => + step (Sigma.mk (Sigma.mk j (Sum.inr i)) (Prod.mk b v))) +local notation "gamma" => principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i)) + +theorem allocatedSupportedSlicedGridDensity_approximation_on_cover + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + {δ : ℝ} (hδ : 0 < δ) + (hlength : ∀ b v, δ * S.value ≤ (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) + (hstep : ∀ b v, 0 < step ⟨⟨j,Sum.inr i⟩,b,v⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + (hstride : ∀ b v, ((step ⟨⟨j,Sum.inr i⟩,b,v⟩ * q : ℕ) : ℝ) ≤ P) + {C ε : ℝ} {M : ℕ} [NeZero M] (hC : 0 ≤ C) + (hMK : (M : ℝ) ≤ C * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (hε : 0 < ε) (hε1 : ε ≤ 1) : + let V := (C / (2 * gamma)) / δ ^ (j.val + 1) + let t := (layerTailDegree m + 1) * rows.card + let W := C ^ rows.card / δ ^ t + let F := positiveModerateSpectrumCover rows M j.val P V (δ * S.value) + (positiveModerateRetainedBias j.val rows.card t P V W ε); + (F.card : ℝ) ≤ positiveModerateSpectrumCardBudget j.val rows.card t P V W ε ∧ + ∀ shift z : rows → ℤ, + ‖(allocatedSupportedSlicedGridDensity B U basis hR hσ S q r H step c hH hsubset hcell j i M rows shift z : ℂ) - + weightedAffineModerateGridApproximation coeff sources lower strides + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + intro V t W F + have hc := (allocatedPrincipalNormalizedSource_primitive B U basis hR S j i hactive A).mono hcP + have hs (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) := + (principalSupportedAxisSources_primitive B (layerSamplerDegree I n) H hH q hq r + ⟨j,Sum.inr i⟩ hsize b v A).mono hsP + have hgamma : 0 < gamma := principalProfileSize_pos (hR j) _ + have hV : 0 ≤ V := by dsimp [V]; positivity + have hW : 0 ≤ W := by dsimp [W]; positivity + have hscale (b : B ⟨j,Sum.inr i⟩) : + (M : ℝ) / (((coeff b).length : ℝ) * ∏ v, (((sources) b v).length : ℝ)) ≤ V := by + exact dense_slice_product_ratio (fun v => (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) hδ + (Nat.cast_pos.mpr S.positive) (Nat.cast_pos.mpr (coeff b).length_pos) (Nat.cast_nonneg M) + (hlength b) (allocatedPrincipalNormalizedSource_grid_ratio B U basis hR S j i hactive hC hMK) + have hcard : (M : ℝ) ^ rows.card ≤ W * (δ * S.value) ^ t := + dense_slice_grid_cardinality rows.card t hδ + (allocatedGrid_modulus_cardinality B U basis S j i hgrid hC hMK rows.card) + obtain ⟨hF, he⟩ := positiveAffineModerate_grid_approximation_on_cover coeff sources lower strides A hA + hc.one_le (fun _ => hc) hs (fun b v _ => hstep b v) (fun b v _ => hstride b v) + (fun _ z hz => allocatedPrincipalNormalizedSource_positive_support B U basis hR S j i hactive z hz) + hV hW (mul_pos hδ (Nat.cast_pos.mpr S.positive)).le hε hε1 hlength + (basisAxisScale (basis j) i) M t hscale rows hrows hB hcard + refine ⟨hF,fun shift z => ?_⟩ + have hlaw := allocatedSupportedSlicedResidueJetPMF_source B U basis hR hσ S q hq r H step c hH hsubset hcell + j i hactive hsize rows shift + have hd := integerGridDensity_eq_of_pmf_image (weightedModerateIntegerProductSource coeff sources) + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) + _ hlaw (basisAxisScale (basis j) i) M z + have hd' : integerGridDensity (weightedModerateIntegerProductSource coeff sources) + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) + (basisAxisScale (basis j) i) M z = + allocatedSupportedSlicedGridDensity B U basis hR hσ S q r H step c hH hsubset hcell j i M rows shift z := by + simpa only [allocatedSupportedSlicedGridDensity, Fintype.card_coe] using hd + rw [← hd'] + exact he shift z + +theorem allocatedSupportedSlicedGridDensity_approximation + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + {δ : ℝ} (hδ : 0 < δ) + (hlength : ∀ b v, δ * S.value ≤ (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) + (hstep : ∀ b v, 0 < step ⟨⟨j,Sum.inr i⟩,b,v⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + (hstride : ∀ b v, ((step ⟨⟨j,Sum.inr i⟩,b,v⟩ * q : ℕ) : ℝ) ≤ P) + {C ε : ℝ} {M : ℕ} [NeZero M] (hC : 0 ≤ C) + (hMK : (M : ℝ) ≤ C * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + (hε : 0 < ε) (hε1 : ε ≤ 1) : + let V := (C / (2 * gamma)) / δ ^ (j.val + 1) + let t := (layerTailDegree m + 1) * rows.card + let W := C ^ rows.card / δ ^ t + ∃ F : Finset (rows → Fin M), + (F.card : ℝ) ≤ positiveModerateSpectrumCardBudget j.val rows.card t P V W ε ∧ + ∀ shift z : rows → ℤ, + ‖(allocatedSupportedSlicedGridDensity B U basis hR hσ S q r H step c hH hsubset hcell j i M rows shift z : ℂ) - + weightedAffineModerateGridApproximation coeff sources lower strides + (basisAxisScale (basis j) i) M rows (fun _ => 0) shift z F‖ ≤ + ((basisAxisScale (basis j) i : ℝ) / M) ^ rows.card * ε := by + intro V t W + have hc := (allocatedPrincipalNormalizedSource_primitive B U basis hR S j i hactive A).mono hcP + have hs (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) := + (principalSupportedAxisSources_primitive B (layerSamplerDegree I n) H hH q hq r + ⟨j,Sum.inr i⟩ hsize b v A).mono hsP + have hgamma : 0 < gamma := principalProfileSize_pos (hR j) _ + have hV : 0 ≤ V := by dsimp [V]; positivity + have hW : 0 ≤ W := by dsimp [W]; positivity + have hscale (b : B ⟨j,Sum.inr i⟩) : + (M : ℝ) / (((coeff b).length : ℝ) * ∏ v, (((sources) b v).length : ℝ)) ≤ V := by + exact dense_slice_product_ratio (fun v => (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) hδ + (Nat.cast_pos.mpr S.positive) (Nat.cast_pos.mpr (coeff b).length_pos) (Nat.cast_nonneg M) + (hlength b) (allocatedPrincipalNormalizedSource_grid_ratio B U basis hR S j i hactive hC hMK) + have hcard : (M : ℝ) ^ rows.card ≤ W * (δ * S.value) ^ t := + dense_slice_grid_cardinality rows.card t hδ + (allocatedGrid_modulus_cardinality B U basis S j i hgrid hC hMK rows.card) + obtain ⟨F, hF, he⟩ := positiveAffineModerate_grid_approximation coeff sources lower strides A hA + hc.one_le (fun _ => hc) hs (fun b v _ => hstep b v) (fun b v _ => hstride b v) + (fun _ z hz => allocatedPrincipalNormalizedSource_positive_support B U basis hR S j i hactive z hz) + hV hW (mul_pos hδ (Nat.cast_pos.mpr S.positive)).le hε hε1 hlength + (basisAxisScale (basis j) i) M t hscale rows hrows hB hcard + refine ⟨F,hF,fun shift z => ?_⟩ + have hlaw := allocatedSupportedSlicedResidueJetPMF_source B U basis hR hσ S q hq r H step c hH hsubset hcell + j i hactive hsize rows shift + have hd := integerGridDensity_eq_of_pmf_image (weightedModerateIntegerProductSource coeff sources) + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) + _ hlaw (basisAxisScale (basis j) i) M z + have hd' : integerGridDensity (weightedModerateIntegerProductSource coeff sources) + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) + (basisAxisScale (basis j) i) M z = + allocatedSupportedSlicedGridDensity B U basis hR hσ S q r H step c hH hsubset hcell j i M rows shift z := by + simpa only [allocatedSupportedSlicedGridDensity, Fintype.card_coe] using hd + rw [← hd'] + exact he shift z + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedSupportedSlicedGridDensity_absolute_cap + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + {δ : ℝ} (hδ : 0 < δ) + (hlength : ∀ b v, δ * S.value ≤ (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) + (hstep : ∀ b v, 0 < step ⟨⟨j,Sum.inr i⟩,b,v⟩) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) (P : ℝ) + (hcP : scalarCubePrimitiveEnvelope Empty A 16 (128 * probabilityProfileLipschitz) 1 ≤ P) + (hsP : scalarCubePrimitiveEnvelope α A 1 0 q ≤ P) + (hstride : ∀ b v, ((step ⟨⟨j,Sum.inr i⟩,b,v⟩ * q : ℕ) : ℝ) ≤ P) + {C : ℝ} {M : ℕ} [NeZero M] (hC : 0 ≤ C) + (hMK : (M : ℝ) ≤ C * basisAxisScale (basis j) i) + (rows : Finset (Finset α)) (hrows : ∀ t ∈ rows, t.card ≤ j.val + 1) + (hB : positiveModerateSpectrumBlockCount j.val rows.card + ((layerTailDegree m + 1) * rows.card) ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) + : + let V := (C / (2 * gamma)) / δ ^ (j.val + 1) + let t := (layerTailDegree m + 1) * rows.card + let W := C ^ rows.card / δ ^ t + (∑ k, ‖∏ b, weightedAffineModerateGridCoefficient (coeff b) (sources b) + (fun v a => (lower b v a : ℝ)) (strides b) 0 M rows k‖) ≤ + positiveModerateSpectrumCardBudget j.val rows.card t P V W 1 + 1 := by + intro V t W + have hc := (allocatedPrincipalNormalizedSource_primitive B U basis hR S j i hactive A).mono hcP + have hs (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) := + (principalSupportedAxisSources_primitive B (layerSamplerDegree I n) H hH q hq r + ⟨j,Sum.inr i⟩ hsize b v A).mono hsP + have hgamma : 0 < gamma := principalProfileSize_pos (hR j) _ + have hV : 0 ≤ V := by dsimp [V]; positivity + have hW : 0 ≤ W := by dsimp [W]; positivity + have hscale (b : B ⟨j,Sum.inr i⟩) : + (M : ℝ) / (((coeff b).length : ℝ) * ∏ v, (((sources) b v).length : ℝ)) ≤ V := by + exact dense_slice_product_ratio (fun v => (H ⟨⟨j,Sum.inr i⟩,b,v⟩ : ℝ)) hδ + (Nat.cast_pos.mpr S.positive) (Nat.cast_pos.mpr (coeff b).length_pos) (Nat.cast_nonneg M) + (hlength b) (allocatedPrincipalNormalizedSource_grid_ratio B U basis hR S j i hactive hC hMK) + have hcard : (M : ℝ) ^ rows.card ≤ W * (δ * S.value) ^ t := + dense_slice_grid_cardinality rows.card t hδ + (allocatedGrid_modulus_cardinality B U basis S j i hgrid hC hMK rows.card) + exact weightedPositiveAffineModerateSpectrum_absolute_cap coeff sources A hA hc.one_le + (fun _ => hc) hs (fun b v a => (lower b v a : ℝ)) strides + (fun b v _ => hstep b v) (fun b v _ => hstride b v) + (fun _ z hz => allocatedPrincipalNormalizedSource_positive_support B U basis hR S j i hactive z hz) + hV hW (mul_pos hδ (Nat.cast_pos.mpr S.positive)).le hlength + (Nat.pos_of_ne_zero (NeZero.ne M)) hscale rows hrows hB hcard + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidueJet.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidueJet.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbe28b36deaf0d100a6b72c132d05faf9a3dd0e2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedSupportedSlicedResidueJet.lean @@ -0,0 +1,116 @@ +import OAI.Combinatorics.Progressions.Probability.ContainedSupportedProgressionJetLaw + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option α → ZMod q) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ t, 0 < H t) +variable (hsubset : ∀ t, integerProgressionSupport (c t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable (hcell : 0 < (principalTupleWeights (α := α) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) +variable (j : Fin m) (i : Fin (n j)) + +local notation "conditioned" => containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H step c (allocatedPrincipalSides_pos B U basis S) hH hsubset q r hcell + +noncomputable def allocatedSupportedSlicedResidueJetPMF + (rows : Finset (Finset α)) (shift : rows → ℤ) : PMF (rows → ℤ) := + (dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b))).bind + (fun coeff => (conditioned).toPMF.map (fun y => + shift + ∑ b, fun t : rows => coeff b * + integerBooleanBlockJet (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t)) + +theorem allocatedSupportedSlicedResidueJetPMF_source + (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) + (hsize : ∀ b v, (Fintype.card α + 1) * q ≤ H ⟨⟨j,Sum.inr i⟩,b,v⟩) + (rows : Finset (Finset α)) (shift : rows → ℤ) : + let sources := principalSupportedAxisSources B (layerSamplerDegree I n) H hH q hq r + ⟨j, Sum.inr i⟩ hsize + let coeff := fun _ : B ⟨j,Sum.inr i⟩ => allocatedPrincipalNormalizedSource B U basis hR S j i hactive + let lower := fun (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) (a : Option α) => + if a = none then c ⟨⟨j,Sum.inr i⟩,b,v⟩ else 0 + let strides := fun (b : B ⟨j,Sum.inr i⟩) (v : Fin (j.val + 1)) (_ : Option α) => + step ⟨⟨j,Sum.inr i⟩,b,v⟩ + (weightedModerateIntegerProductSource coeff sources).toPMF.map + (weightedAffineModerateIntegerJetSum coeff sources lower strides rows (fun _ => 0) shift) = + allocatedSupportedSlicedResidueJetPMF B U basis hR hσ S q r H step c hH hsubset hcell j i rows shift := by + intro sources coeff lower strides + have hp := containedSupportedProgressionLaw_jet_sum_law B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H step c (allocatedPrincipalSides_pos B U basis S) + hH hsubset q hq r hcell ⟨j,Sum.inr i⟩ hsize coeff rows (fun _ => 0) shift + dsimp only at hp + have hc := congrArg (fun p : B ⟨j,Sum.inr i⟩ → PMF ℤ => dependentProductPMF p) + (funext (fun b => allocatedPrincipalNormalizedSource_law B U basis hR hσ S j i hactive b)) + rw [hc] at hp + simp only [zero_add] at hp + convert hp using 1 <;> rfl + +theorem allocatedSupportedSlicedResidueJetPMF_constant_mixture + (hgrid : allocatedGridAxis (I := I) U basis S.value ⟨j, Sum.inr i⟩) + (rows : Finset (Finset α)) (x : G → IntegerScalarCubeBox α S.value) : + (conditioned).toPMF.bind (fun y => + integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i)) = + (allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ none)).bind + (fun z => allocatedSupportedSlicedResidueJetPMF B U basis hR hσ S q r H step c hH hsubset hcell j i rows + (fun t => booleanCoefficient (fun _ : Finset α => z) t)) := by + let p := (conditioned).toPMF + let a := dependentProductPMF (fun b : B ⟨j, Sum.inr i⟩ => + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b)) + let constLaw := allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ none) + let f (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S)) + (z : ℤ) (coeff : B ⟨j, Sum.inr i⟩ → ℤ) : rows → ℤ := + (fun t : rows => booleanCoefficient (fun _ : Finset α => z) t) + + ∑ b, fun t : rows => coeff b * integerBooleanBlockJet + (fun v k => (y ⟨⟨j, Sum.inr i⟩, b, v⟩ k : ℤ)) t + have hpoint y : integerMatrixImagePMF (boundedCoefficientJetMatrix + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) (j.val + 1) + (fun t : rows => (t : Finset α))) (allocatedLayerIntegerPMFs B U basis hR hσ S j i) = + constLaw.bind (fun z => a.map (f y z)) := by + rw [allocatedPhysicalGridJetPMF_principal B U basis hR hσ S j i hgrid, + independentProductPMF_option, PMF.map_bind] + simp only [PMF.map_comp] + apply congrArg (fun k : ℤ → PMF (rows → ℤ) => constLaw.bind k) + funext z + apply congrArg (fun g : (B ⟨j, Sum.inr i⟩ → ℤ) → rows → ℤ => a.map g) + funext coeff t + simp only [Function.comp_apply, f, Pi.add_apply, Finset.sum_apply, + Option.elim_none, Option.elim_some] + simp_rw [hpoint] + change p.bind (fun y => constLaw.bind (fun z => a.map (f y z))) = + constLaw.bind (fun z => a.bind (fun coeff => p.map (fun y => f y z coeff))) + refine (PMF.bind_comm p constLaw (fun y z => a.map (f y z))).trans ?_ + apply congrArg (fun k : ℤ → PMF (rows → ℤ) => constLaw.bind k) + funext z + exact PMF.bind_comm p a (fun y coeff => PMF.pure (f y z coeff)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedTrimmedResidueTest.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedTrimmedResidueTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f0aaa23de32460c495ac69420f9031cd7445da4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedTrimmedResidueTest.lean @@ -0,0 +1,327 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedTrimmedVectorSite + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +theorem selectedResidue_site_mass_bound {K X Y : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (T : Finset (ColumnResiduePattern K X q)) (V : K × X → ℝ) + (hV : ∀ z, 0 < V z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (S : Finset Y) (φ : T → Y → ℂ) {A E B C : ℝ} + (hA : 0 < A) (hE : 0 ≤ E) (hB : 0 ≤ B) + (hφ : ∀ a v, v ∈ S → ‖φ a v‖ ≤ B) (hcard : (S.card : ℝ) ≤ C * A) : + (∑ a : T, selectedResidueCellWeight q T V a * ((E / A) * ∑ v ∈ S, ‖φ a v‖)) ≤ + B * E * C := by + have hpart (a : T) : (E / A) * (∑ v ∈ S, ‖φ a v‖) ≤ B * E * C := by + have hs : (∑ v ∈ S, ‖φ a v‖) ≤ B * S.card := by + simpa only [Finset.sum_const, nsmul_eq_mul, mul_comm] using + Finset.sum_le_sum (fun v hv => hφ a v hv) + calc + _ ≤ (E / A) * (B * S.card) := mul_le_mul_of_nonneg_left hs (div_nonneg hE hA.le) + _ ≤ (E / A) * (B * (C * A)) := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left hcard hB) (div_nonneg hE hA.le) + _ = _ := by field_simp + calc + _ ≤ ∑ a : T, selectedResidueCellWeight q T V a * (B * E * C) := + Finset.sum_le_sum (fun a _ => mul_le_mul_of_nonneg_left (hpart a) + (selectedResidueCellWeight_nonneg q T V a)) + _ = (∑ a : T, selectedResidueCellWeight q T V a) * (B * E * C) := (Finset.sum_mul _ _ _).symm + _ = _ := by rw [selectedResidueCellWeight_sum q T V hV hmass, one_mul] + +theorem physicalCenteredResidueMixture_site_error {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (q : X → ℕ) (hq : ∀ d, 0 < q d) + (T : Finset (ColumnResiduePattern (Option K) X q)) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (ψ φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {A E Z : ℝ} (hA : 0 < A) (hZ : 0 < Z) + (he : ∀ v ∈ centeredPhysicalCubeWindow root D (residueProfileWidth q V), + ‖((A * (((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV)).map (centeredPhysicalCubeMap root D)) v).toReal : ℝ) : ℂ) - + ψ v‖ ≤ E) : + let Q := residueProfileWidth q V + let hQ := residueProfileWidth_pos q V hq hV + let window := centeredPhysicalCubeWindow root D Q + let F := fun r : T => physicalResidueReconstruction root D base + (boundedColumnResidueRepresentative q r.val) q + ‖(∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' z, ((smoothProductPMF Q hQ z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base (boundedColumnResidueRepresentative q r.val) q z)) / + (Z : ℂ) - + (∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑ v ∈ window, (ψ v / (A : ℂ)) * φ (F r v)) / (Z : ℂ)‖ ≤ + (∑ r : T, selectedResidueCellWeight q T V r * + ((E / A) * ∑ v ∈ window, ‖φ (F r v)‖)) / Z := by + classical + intro Q hQ window F + rw [← sub_div, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hZ] + apply div_le_div_of_nonneg_right _ hZ.le + rw [← Finset.sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro r _ + rw [← mul_sub, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (selectedResidueCellWeight_nonneg q T V r)] + exact mul_le_mul_of_nonneg_left + (smoothPhysicalResidue_site_error root D base (boundedColumnResidueRepresentative q r.val) + q Q hQ ψ φ hA he) (selectedResidueCellWeight_nonneg q T V r) + +theorem physicalSelectedResidue_site_error {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (q : X → ℕ) (hq : ∀ d, 0 < q d) + (T : Finset (ColumnResiduePattern (Option K) X q)) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hmass : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hlarge : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + (ψ φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {A E Z B : ℝ} + (hA : 0 < A) (hZ : 0 < Z) (hB : 0 ≤ B) (hφ : ∀ v, ‖φ v‖ ≤ B) + (he : ∀ v ∈ centeredPhysicalCubeWindow root D (residueProfileWidth q V), + ‖((A * (((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV)).map (centeredPhysicalCubeMap root D)) v).toReal : ℝ) : ℂ) - + ψ v‖ ≤ E) : + let window := centeredPhysicalCubeWindow root D (residueProfileWidth q V) + let F := fun r : T => physicalResidueReconstruction root D base + (boundedColumnResidueRepresentative q r.val) q + ‖(∑' z, ((selectedResidueSmoothPMF q T V hV hmass z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) / (Z : ℂ) - + (∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑ v ∈ window, (ψ v / (A : ℂ)) * φ (F r v)) / (Z : ℂ)‖ ≤ + (B * (24 * (probabilityProfileLipschitz : ℝ) * ∑ z : Option K × X, (q z.2 : ℝ) / V z)) / Z + + (∑ r : T, selectedResidueCellWeight q T V r * + ((E / A) * ∑ v ∈ window, ‖φ (F r v)‖)) / Z := by + intro window F + have hrec := physicalSelectedResidue_recenter_test root D base q hq T V hV hmass hlarge φ hB hφ hZ + have hsite := physicalCenteredResidueMixture_site_error root D base q hq T V hV ψ φ hA hZ he + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hrec hsite) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Classical + +theorem selectedResidue_coefficient_tail {K X Y : Type*} [Fintype K] [Fintype X] + (stride : X → ℕ) (cells : Finset (ColumnResiduePattern K X stride)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells V z) + (window : Finset Y) (ψ : Y → ℂ) (test : cells → Y → ℂ) + (error : cells → Y → ℝ) {A C E Cwin : ℝ} + (hA : 0 < A) (hC : 0 ≤ C) (hE : 0 ≤ E) + (hψ : ∀ v ∈ window, ‖ψ v‖ ≤ C) (htest : ∀ a v, ‖test a v‖ ≤ 1) + (herror : ∀ a v, error a v ≤ E) (hcard : (window.card : ℝ) ≤ Cwin * A) : + (∑ t : cells × window, + ‖(selectedResidueCellWeight stride cells V t.1 : ℂ) * (ψ t.2.val / (A : ℂ)) * + test t.1 t.2.val‖ * error t.1 t.2.val) ≤ C * E * Cwin := by + have hφ (a : cells) (v : Y) (hv : v ∈ window) : ‖ψ v * test a v‖ ≤ C := by + rw [norm_mul] + exact (mul_le_mul (hψ v hv) (htest a v) (norm_nonneg _) hC).trans_eq (mul_one _) + calc + _ ≤ ∑ t : cells × window, + ‖(selectedResidueCellWeight stride cells V t.1 : ℂ) * (ψ t.2.val / (A : ℂ)) * + test t.1 t.2.val‖ * E := + Finset.sum_le_sum (fun t _ => mul_le_mul_of_nonneg_left (herror t.1 t.2.val) (norm_nonneg _)) + _ = ∑ a : cells, selectedResidueCellWeight stride cells V a * + ((E / A) * ∑ v ∈ window, ‖ψ v * test a v‖) := by + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro a _ + rw [← Finset.sum_coe_sort window (fun v => ‖ψ v * test a v‖), + Finset.mul_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro v _ + simp only [norm_mul, norm_div, Complex.norm_real, + Real.norm_eq_abs, + abs_of_nonneg (selectedResidueCellWeight_nonneg stride cells V a), abs_of_pos hA] + ring + _ ≤ _ := selectedResidue_site_mass_bound stride cells V hV hmass window + (fun a v => ψ v * test a v) hA hE hC hφ hcard + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Classical + +theorem selectedResidue_coefficient_tail_of_window_mass {K X Y : Type*} [Fintype K] [Fintype X] + (stride : X → ℕ) (cells : Finset (ColumnResiduePattern K X stride)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells V z) + (window : Finset Y) (ψ : Y → ℂ) (test : cells → Y → ℂ) + (error : cells → Y → ℝ) {A C E : ℝ} (hA : 0 < A) (hC : 0 ≤ C) + (hψ : ∀ w ∈ window, ‖ψ w‖ ≤ C) (htest : ∀ a w, ‖test a w‖ ≤ 1) + (herror : ∀ a w, 0 ≤ error a w) + (hmass : ∀ a, (∑ w ∈ window, error a w) ≤ E * A) : + (∑ t : cells × window, + ‖(selectedResidueCellWeight stride cells V t.1 : ℂ) * (ψ t.2.val / (A : ℂ)) * + test t.1 t.2.val‖ * error t.1 t.2.val) ≤ C * E := by + have hcell (a : cells) : + (∑ w : window, ‖(selectedResidueCellWeight stride cells V a : ℂ) * + (ψ w.val / (A : ℂ)) * test a w.val‖ * error a w.val) ≤ + selectedResidueCellWeight stride cells V a * (C * E) := by + let w := selectedResidueCellWeight stride cells V a + have hw : 0 ≤ w := selectedResidueCellWeight_nonneg stride cells V a + have hn (v : window) : + ‖(w : ℂ) * (ψ v.val / (A : ℂ)) * test a v.val‖ ≤ w / A * C := by + have ht : ‖ψ v.val‖ * ‖test a v.val‖ ≤ C := + (mul_le_mul (hψ v.val v.property) (htest a v.val) (norm_nonneg _) hC).trans_eq (mul_one C) + calc + _ = w / A * (‖ψ v.val‖ * ‖test a v.val‖) := by + simp only [norm_mul, norm_div, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg hw, abs_of_pos hA] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left ht (div_nonneg hw hA.le) + calc + _ ≤ ∑ v : window, (w / A * C) * error a v.val := + Finset.sum_le_sum (fun v _ => mul_le_mul_of_nonneg_right (hn v) (herror a v.val)) + _ = (w / A * C) * ∑ v ∈ window, error a v := by + rw [← Finset.mul_sum, Finset.sum_coe_sort] + _ ≤ (w / A * C) * (E * A) := + mul_le_mul_of_nonneg_left (hmass a) (mul_nonneg (div_nonneg hw hA.le) hC) + _ = w * (C * E) := by field_simp [hA.ne'] + rw [Fintype.sum_prod_type] + calc + _ ≤ ∑ a : cells, selectedResidueCellWeight stride cells V a * (C * E) := + Finset.sum_le_sum (fun a _ => hcell a) + _ = _ := by rw [← Finset.sum_mul, selectedResidueCellWeight_sum stride cells V hV hZ, one_mul] + +theorem referenceErrorVolumeFactor_bound (q : ℕ) (X : Type*) [Fintype X] + {W L D : ℝ} (hW : 0 ≤ W) (hL : 1 ≤ L) (hWL : W ≤ D * L) : + (30 / smoothProbabilityProfile 0) ^ Fintype.card (Option (Fin q) × X) * + (((1 + W) / L) ^ q) ^ Fintype.card X ≤ + (30 / smoothProbabilityProfile 0) ^ Fintype.card (Option (Fin q) × X) * + ((1 + D) ^ q) ^ Fintype.card X := by + have hL0 : 0 < L := lt_of_lt_of_le zero_lt_one hL + have hratio : (1 + W) / L ≤ 1 + D := (div_le_iff₀ hL0).mpr (by nlinarith) + have hratio0 : 0 ≤ (1 + W) / L := div_nonneg (by linarith) hL0.le + have hprofile := smoothProbabilityProfile_pos_zero + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact pow_le_pow_left₀ (pow_nonneg hratio0 q) (pow_le_pow_left₀ hratio0 hratio q) _ + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox α S.value) +variable (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S)) + +local notation "vars" => LayerSamplerVariables G I n B +local notation "cols" => principalSpatialColumns (fun j => c (Sum.inr j)) id y +local notation "ker" => (fun g => c (Sum.inl g) + (x g none : ℤ)) +local notation "root" => allocatedPhysicalCubeRoot B U basis S c x y +local notation "dirs" => allocatedPhysicalCubeDirections B U basis S x y + +theorem allocatedTrimmedSpatial_selected_site_test (selection : α ↪ G) {M : ℕ} + {X : Type*} [Fintype X] (N q : X → ℕ) (hN : ∀ d, 0 < N d) (hq : ∀ d, 0 < q d) + {W τ κ C₀ ρ ξ r : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hκ : 0 < κ) (hρ : 0 < ρ) + (hx : GoodScalarKernelTuple selection κ M x) + (hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (hC₀ : 1 ≤ C₀) (hLC : (S.value : ℝ) ≤ C₀) (hWC : W ≤ C₀) + (hξ0 : 0 ≤ ξ) (hξ1 : ξ ≤ 1) + (hprincipalRoot : ∀ j, ((|c (.inr j)| : ℤ) + (allocatedPrincipalSides B U basis S j : ℤ) : ℝ) ≤ + ξ * (1 + W)) + (hprincipalDir : ∀ j, ((|c (.inr j)| : ℤ) + (allocatedPrincipalSides B U basis S j : ℤ) : ℝ) ≤ + ξ * S.value) + (hsize : ∀ d, 8 * (1 + W) * (q d : ℝ) * ρ ≤ τ * (N d : ℝ)) + (hmesh : anisotropicSpatialMeshThreshold selection (PrincipalTupleIndex B (layerSamplerDegree I n)) C₀ ≤ ρ) + (hρ8 : 8 * (probabilityProfileLipschitz : ℝ) ≤ ρ) + (modulus : ℕ) [NeZero modulus] + (hperiod : integerScalarLattice (Unit ⊕ α) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot ker (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns ker (scalarCubeDifferenceMatrix x) selection)) + (hr : 0 < r) (base : X → ℤ) + (cells : Finset (ColumnResiduePattern (Option vars) X q)) + (hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells (trimmedSpatialWidths W τ N) z) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {Cφ Z : ℝ} + (hCφ : 0 ≤ Cφ) (hφ : ∀ v, ‖φ v‖ ≤ Cφ) (hZ : 0 < Z) : + let H := fun d => trimmedSpatialRootScale τ N q d + let T := fun d => trimmedSpatialSlopeScale W τ N q d + let V := trimmedSpatialWidths (K := vars) W τ N + let hV := trimmedSpatialWidths_pos (K := vars) hW hτ N hN + let Q := residueProfileWidth q V + let hpivot := goodScalarKernelTuple_spatial_det_ne_zero selection x ker hκ hx + let f := canonicalSpatialSiteDensity selection ker (scalarCubeDifferenceMatrix x) hpivot W S.value + hW (Nat.cast_pos.mpr S.positive) + let ψ := fun v : X → (Unit ⊕ α) → ℤ => ∏ d, + spatialSiteApprox (selectedSpatialPivot ker (scalarCubeDifferenceMatrix x) selection) + (Matrix.fromCols (selectedSpatialFreeColumns ker (scalarCubeDifferenceMatrix x) selection) + (liftResidueMatrix (integerResidueMatrix cols modulus))) modulus f (H d) 3 r (v d) + let A := ∏ d, ∏ i, physicalSpatialOutputScale α (H d) (T d) S.value i + let E₀ := anisotropicSpatialError selection (PrincipalTupleIndex B (layerSamplerDegree I n)) M κ C₀ ρ ξ + let G₀ := (modulus : ℝ) ^ Fintype.card (Unit ⊕ α) + let E := Fintype.card X * (E₀ + 4 * G₀ * (anisotropicSpatialDensityLip selection κ * (1 + W)) * r) * + (1 + G₀ * anisotropicSpatialDensityCap selection κ + E₀) ^ Fintype.card X + let Cwin := 7 ^ Fintype.card (X × (Unit ⊕ α)) * + (((1 + W) / (S.value : ℝ)) ^ Fintype.card α) ^ Fintype.card X + let window := centeredPhysicalCubeWindow root dirs Q + let F := fun a : cells => physicalResidueReconstruction root dirs base + (boundedColumnResidueRepresentative q a.val) q + ‖(∑' z, ((selectedResidueSmoothPMF q cells V hV hmass z).toReal : ℂ) * + φ (physicalCubeRootDifferences root dirs base z)) / (Z : ℂ) - + (∑ a : cells, (selectedResidueCellWeight q cells V a : ℂ) * + ∑ v ∈ window, (ψ v / (A : ℂ)) * φ (F a v)) / (Z : ℂ)‖ ≤ + Cφ * (24 * (probabilityProfileLipschitz : ℝ) * Fintype.card (Option vars × X) / ρ + E * Cwin) / Z := by + classical + intro H T V hV Q hpivot f ψ A E₀ G₀ E Cwin window F + have hH (d) : 0 < H d := (trimmedSpatial_scales_pos hW hτ N q d (hN d) (hq d)).1 + have hT (d) : 0 < T d := (trimmedSpatial_scales_pos hW hτ N q d (hN d) (hq d)).2 + have hA : 0 < A := Finset.prod_pos (fun d _ => Finset.prod_pos (fun i _ => + physicalSpatialOutputScale_pos α (hH d) (hT d) (Nat.cast_pos.mpr S.positive) i)) + have hwindow (v) (hv : v ∈ window) := + allocatedTrimmedSpatial_window_bound B U basis S c x y N q hN hq hW hτ hbudget v hv + have he (v) (hv : v ∈ window) : + ‖((A * (((smoothProductPMF Q (residueProfileWidth_pos q V hq hV)).map + (centeredPhysicalCubeMap root dirs)) v).toReal : ℝ) : ℂ) - ψ v‖ ≤ E := + allocatedTrimmedSpatial_vector_site_error B U basis S c x y selection N q hN hq + hW hτ hκ hρ hx hbudget hC₀ hLC hWC hξ0 hξ1 hprincipalRoot hprincipalDir hsize hmesh + modulus hperiod (by norm_num : (0 : ℝ) < 3) hr v (hwindow v hv) + have hρ1 : 1 ≤ ρ := by linarith [probabilityProfileLipschitz_one_le] + have hcard : (window.card : ℝ) ≤ Cwin * A := + spatialStarWindow_card_anisotropic window H T + (fun d => hρ1.trans (trimmedSpatial_scale_lower hW hρ.le N q d (hq d) (hsize d)).1) + (Nat.cast_ne_zero.mpr S.positive.ne') (fun d => trimmedSpatial_scale_ratio hW N q d) hwindow + have hE₀ : 0 ≤ E₀ := anisotropicSpatialError_nonneg selection _ M hκ.le + (zero_le_one.trans hC₀) hρ.le hξ0 + have hcap := anisotropicSpatialDensityCap_nonneg selection hκ.le + have hlip := anisotropicSpatialDensityLip_nonneg selection hκ.le + have hE : 0 ≤ E := by dsimp only [E, G₀]; positivity + have hmassBound := selectedResidue_site_mass_bound q cells V hV hmass window + (fun a v => φ (F a v)) hA hE hCφ (fun _ _ _ => hφ _) hcard + have hrec := physicalSelectedResidue_trimmed_recenter root dirs base q N hq hN cells + hW hτ hρ8 hsize hmass φ hCφ hφ hZ + have hsite := physicalCenteredResidueMixture_site_error root dirs base q hq cells V hV ψ φ hA hZ he + have h := (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans + (add_le_add hrec (hsite.trans (div_le_div_of_nonneg_right hmassBound hZ.le))) + exact h.trans_eq (by ring) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedWholeResidueShift.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedWholeResidueShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5c4c85ffd1e56bfd5a51bb541f8d5f55b3d09e9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AllocatedWholeResidueShift.lean @@ -0,0 +1,222 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedTrimmedVectorSite + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox α S.value) + +local notation "vars" => LayerSamplerVariables G I n B +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "sides" => allocatedPrincipalSides B U basis S + +omit [Fintype α] [DecidableEq α] in +theorem allocatedPhysicalCube_coefficient_entry_bound + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) + (i : Unit ⊕ α) (k : Option vars) : + |(physicalCubeCoefficient (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) i k : ℝ)| ≤ + allocatedPhysicalEntryBudget B U basis S c := by + cases k with + | none => + cases i with + | inl i => + simpa only [physicalCubeCoefficient, Int.cast_one, abs_one] using + allocatedPhysicalEntryBudget_one_le B U basis S c + | inr i => + simpa only [physicalCubeCoefficient, Int.cast_zero, abs_zero] using + zero_le_one.trans (allocatedPhysicalEntryBudget_one_le B U basis S c) + | some k => + cases i with + | inl i => exact allocatedPhysicalCube_root_entry_bound B U basis S c x y k + | inr i => exact allocatedPhysicalCube_direction_entry_bound B U basis S c x y i k + +omit [Fintype α] [DecidableEq α] in +theorem allocatedPhysicalCube_residue_of_principal_label + (u : PrincipalAxisTuples (α := α) grid sides) + (w w₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + (modulus : ℕ) (hlabel : principalResidueLabel modulus w = principalResidueLabel modulus w₀) : + integerResidueMatrix (physicalCubeCoefficient + (allocatedPhysicalCubeRoot B U basis S c x (principalAxisJoin grid u w)) + (allocatedPhysicalCubeDirections B U basis S x (principalAxisJoin grid u w))) modulus = + integerResidueMatrix (physicalCubeCoefficient + (allocatedPhysicalCubeRoot B U basis S c x (principalAxisJoin grid u w₀)) + (allocatedPhysicalCubeDirections B U basis S x (principalAxisJoin grid u w₀))) modulus := by + have hc : integerResidueMatrix (principalSpatialColumns (fun j => c (Sum.inr j)) id + (principalAxisJoin grid u w)) modulus = + integerResidueMatrix (principalSpatialColumns (fun j => c (Sum.inr j)) id + (principalAxisJoin grid u w₀)) modulus := by + rw [principalSpatialColumns_join_residue, principalSpatialColumns_join_residue, hlabel] + ext i k + cases k with + | none => cases i <;> rfl + | some k => + cases k with + | inl g => cases i <;> rfl + | inr j => + cases i with + | inl i => exact congrFun (congrFun hc (.inl i)) j + | inr i => exact congrFun (congrFun hc (.inr i)) j + +omit [Fintype α] [DecidableEq α] in +theorem allocatedPhysicalResidue_shift_principal + (y y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) + {X : Type*} (r : Option vars × X → ℤ) (q : X → ℕ) : + physicalResidueOffsetShift (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeRoot B U basis S c x y₀) + (allocatedPhysicalCubeDirections B U basis S x y) + (allocatedPhysicalCubeDirections B U basis S x y₀) r q = + fun d => residueMatrixShift (principalSpatialColumns (fun j => c (Sum.inr j)) id y) + (principalSpatialColumns (fun j => c (Sum.inr j)) id y₀) (q d) + (fun j => r (some (Sum.inr j), d)) := by + funext d i + unfold physicalResidueOffsetShift residueMatrixShift + congr 1 + simp only [Matrix.mulVec, dotProduct, Matrix.sub_apply, Fintype.sum_option, + Fintype.sum_sum_type, allocatedPhysicalCube_principal_columns] + cases i <;> simp [physicalCubeCoefficient, allocatedPhysicalCubeRoot, allocatedPhysicalCubeDirections] + +omit [DecidableEq α] in +theorem allocatedPhysicalResidue_offset_shift + (u : PrincipalAxisTuples (α := α) grid sides) + (w w₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + {X : Type*} (base : X → ℤ) (r : Option vars × X → ℤ) + (q : X → ℕ) (hq : ∀ d, 0 < q d) (period modulus : ℕ) + (hdiv : ∀ d, q d * period ∣ modulus) + (hlabel : principalResidueLabel modulus w = principalResidueLabel modulus w₀) + (hr : ∀ k d, |(r (k, d) : ℝ)| ≤ q d) : + let root := allocatedPhysicalCubeRoot B U basis S c x (principalAxisJoin grid u w) + let root₀ := allocatedPhysicalCubeRoot B U basis S c x (principalAxisJoin grid u w₀) + let dirs := allocatedPhysicalCubeDirections B U basis S x (principalAxisJoin grid u w) + let dirs₀ := allocatedPhysicalCubeDirections B U basis S x (principalAxisJoin grid u w₀) + let shift := physicalResidueOffsetShift root root₀ dirs dirs₀ r q + (∀ d, shift d ∈ integerScalarLattice (Unit ⊕ α) (period : ℤ)) ∧ + (∀ v, physicalResidueReconstruction root dirs base r q v = + physicalResidueReconstruction root₀ dirs₀ base r q (v + shift)) ∧ + (∀ d i, |(shift d i : ℝ)| ≤ + Fintype.card (Option vars) * (2 * allocatedPhysicalEntryBudget B U basis S c)) := by + intro root root₀ dirs dirs₀ shift + have hres (d) : integerResidueMatrix (physicalCubeCoefficient root dirs) (q d * period) = + integerResidueMatrix (physicalCubeCoefficient root₀ dirs₀) (q d * period) := + integerResidueMatrix_reduce _ _ (hdiv d) + (allocatedPhysicalCube_residue_of_principal_label B U basis S c x u w w₀ modulus hlabel) + refine ⟨fun d => physicalResidueOffsetShift_mem root root₀ dirs dirs₀ r q hq period hres d, + fun v => physicalResidueReconstruction_offset_shift root root₀ dirs dirs₀ base r q hq period hres v, ?_⟩ + intro d i + apply (physicalResidueOffsetShift_bound root root₀ dirs dirs₀ r q hq period hres hr d i).trans + calc + _ ≤ ∑ _k : Option vars, 2 * allocatedPhysicalEntryBudget B U basis S c := by + apply Finset.sum_le_sum + intro k _ + rw [Int.cast_sub] + apply (abs_sub _ _).trans + have h₁ := allocatedPhysicalCube_coefficient_entry_bound B U basis S c x (principalAxisJoin grid u w) i k + have h₂ := allocatedPhysicalCube_coefficient_entry_bound B U basis S c x (principalAxisJoin grid u w₀) i k + linarith + _ = _ := by simp + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox α S.value) + +local notation "vars" => LayerSamplerVariables G I n B +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "sides" => allocatedPrincipalSides B U basis S + +omit [Fintype α] [DecidableEq α] in +theorem allocatedPhysicalCube_residue_of_whole_label + (y y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) + (modulus : ℕ) (hlabel : principalResidueLabel modulus y = principalResidueLabel modulus y₀) : + integerResidueMatrix (physicalCubeCoefficient + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y)) modulus = + integerResidueMatrix (physicalCubeCoefficient + (allocatedPhysicalCubeRoot B U basis S c x y₀) + (allocatedPhysicalCubeDirections B U basis S x y₀)) modulus := by + have hc : integerResidueMatrix (principalSpatialColumns (fun j => c (Sum.inr j)) id + y) modulus = + integerResidueMatrix (principalSpatialColumns (fun j => c (Sum.inr j)) id + y₀) modulus := by + rw [principalSpatialColumns_residue, principalSpatialColumns_residue, hlabel] + ext i k + cases k with + | none => cases i <;> rfl + | some k => + cases k with + | inl g => cases i <;> rfl + | inr j => + cases i with + | inl i => exact congrFun (congrFun hc (.inl i)) j + | inr i => exact congrFun (congrFun hc (.inr i)) j + +omit [DecidableEq α] in +theorem allocatedPhysicalResidue_whole_offset_shift + (y y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) + {X : Type*} (base : X → ℤ) (r : Option vars × X → ℤ) + (q : X → ℕ) (hq : ∀ d, 0 < q d) (period modulus : ℕ) + (hdiv : ∀ d, q d * period ∣ modulus) + (hlabel : principalResidueLabel modulus y = principalResidueLabel modulus y₀) + (hr : ∀ k d, |(r (k, d) : ℝ)| ≤ q d) : + let root := allocatedPhysicalCubeRoot B U basis S c x y + let root₀ := allocatedPhysicalCubeRoot B U basis S c x y₀ + let dirs := allocatedPhysicalCubeDirections B U basis S x y + let dirs₀ := allocatedPhysicalCubeDirections B U basis S x y₀ + let shift := physicalResidueOffsetShift root root₀ dirs dirs₀ r q + (∀ d, shift d ∈ integerScalarLattice (Unit ⊕ α) (period : ℤ)) ∧ + (∀ v, physicalResidueReconstruction root dirs base r q v = + physicalResidueReconstruction root₀ dirs₀ base r q (v + shift)) ∧ + (∀ d i, |(shift d i : ℝ)| ≤ + Fintype.card (Option vars) * (2 * allocatedPhysicalEntryBudget B U basis S c)) := by + intro root root₀ dirs dirs₀ shift + have hres (d) : integerResidueMatrix (physicalCubeCoefficient root dirs) (q d * period) = + integerResidueMatrix (physicalCubeCoefficient root₀ dirs₀) (q d * period) := + integerResidueMatrix_reduce _ _ (hdiv d) + (allocatedPhysicalCube_residue_of_whole_label B U basis S c x y y₀ modulus hlabel) + refine ⟨fun d => physicalResidueOffsetShift_mem root root₀ dirs dirs₀ r q hq period hres d, + fun v => physicalResidueReconstruction_offset_shift root root₀ dirs dirs₀ base r q hq period hres v, ?_⟩ + intro d i + apply (physicalResidueOffsetShift_bound root root₀ dirs dirs₀ r q hq period hres hr d i).trans + calc + _ ≤ ∑ _k : Option vars, 2 * allocatedPhysicalEntryBudget B U basis S c := by + apply Finset.sum_le_sum + intro k _ + rw [Int.cast_sub] + apply (abs_sub _ _).trans + have h₁ := allocatedPhysicalCube_coefficient_entry_bound B U basis S c x y i k + have h₂ := allocatedPhysicalCube_coefficient_entry_bound B U basis S c x y₀ i k + linarith + _ = _ := by simp + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCoefficientResidueAmbient.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCoefficientResidueAmbient.lean new file mode 100644 index 0000000000000000000000000000000000000000..19dc60ba9022f9ed555ad29ccc17bd12d6e151fa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCoefficientResidueAmbient.lean @@ -0,0 +1,277 @@ +import OAI.Combinatorics.Progressions.Lattices.RetainedAffineCommonCover + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal + +theorem anchored_affine_coefficient_residue_removal_of_widths {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + (origin : Option K → I → ℝ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + {C : ℝ} (hC : 0 ≤ C) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (hH : ∀ k, 0 < H k) + (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : layerRemovalRankBudget m (Fintype.card I) C 1 + (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) + (hmove : (m : ℝ) * 1 ≤ r * ρ * T) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (origin + fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + let B := finiteLayerBiasBudget m ζ + let D : ℝ := 1 + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ + have hD : 0 ≤ D := zero_le_one + have hA : 0 ≤ 2 * T := by positivity + have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B := + multiaffineBiasBudget_le_finite i hζ + obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth + have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD + (zero_le_one.trans hB) hA hS + apply anchored_affine_coefficient_mode_residue_removal origin U frequency hbound hbad + p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank + (fun i => by simpa only [D, one_pow, mul_one] using (hbud i).1.trans hR) _ _ residue V hV hZ hV1 hδ hδ1 hmesh hsmall hr _ hβ hpower + · intro i + have hi := tensorDenominatorBound_le (H := Fin (i.val + 1)) + (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ)) + (fun k => Nat.cast_nonneg _) hstride + have hi' : (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ + (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by + simpa only [Fintype.card_fin] using hi + apply hi'.trans + apply le_trans _ ((hbud i).2.1.trans hR) + exact pow_le_pow_left₀ + (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _)) + (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _ + · intro i + apply le_trans _ ((hbud i).2.2.trans hR) + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _)) + (pow_nonneg (Nat.cast_nonneg _) _) + · intro i z + have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt + have hs' : (m : ℝ) * ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z := by + simpa only [mul_one] using hshift z + exact (mul_le_mul_of_nonneg_right hi + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))).trans hs' + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +theorem anchored_affine_coefficient_residue_removal_at_error {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + (origin : Option K → I → ℝ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + {C : ℝ} (hC : 0 ≤ C) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (hsize : ∀ k, modeResidueSideThreshold m (Fintype.card (Option K × I)) + 1 S ρ ε ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : modeRemovalRankThreshold m (Fintype.card I) (Fintype.card (Option K × I)) + C 1 S ρ ε ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) : + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (origin + fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ ε := by + classical + let d := Fintype.card (Option K × I) + let D : ℝ := 1 + let T := modeRemovalShrink m d D ρ ε + let B := finiteLayerBiasBudget m (modeRemovalBias m ε) + have hD : 0 ≤ D := zero_le_one + have hT : 0 < T := lt_of_lt_of_le zero_lt_one (modeRemovalShrink_one_le m d hD hρ hε) + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m (modeRemovalBias_pos m hε) + have hside := modeRemovalSideThreshold_bounds m d hD hS hρ hε + have hsizeBase k : modeRemovalSideThreshold m d D S ρ ε ≤ H k := + (modeResidueSideThreshold_bounds m d hD hS hρ hε).1.trans (hsize k) + have hH k : 0 < H k := hside.1.trans_le (hsizeBase k) + have hsize' k : (stride k : ℝ) * T * (B + 1) ≤ H k := by + calc + _ ≤ S * T * (B + 1) := by gcongr; exact hstride k + _ ≤ H k := hside.2.1.trans (hsizeBase k) + have hv z : 1 ≤ residueProfileWidth stride V z ∧ + 1 / residueProfileWidth stride V z ≤ modeRemovalMesh d := + modeResidueWidth_mesh m d hD hS hρ hε (hs z.2) (hstride z.2) (hsize z.2) (hV z) (hwidth z) + have hmass := shiftedSmoothProductMass_lower (residueProfileCenter residue stride) + (residueProfileWidth stride V) (residueProfileWidth_pos stride V hs hV) + (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) (fun z => (hv z).2) (modeRemovalMesh_small d) + have hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V) := + (div_pos (Finset.prod_pos (fun z _ => residueProfileWidth_pos stride V hs hV z)) (by norm_num)).trans_le hmass + refine ⟨hZ, ?_⟩ + have hout := anchored_affine_coefficient_residue_removal_of_widths origin U hC frequency hbound hbad + p hp hm stride hs (modeRemovalBias_pos m hε) hT hS hstride H hH hsize' hrank hR + residue V hV hZ (fun z => (hv z).1) (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) + (fun z => (hv z).2) (modeRemovalMesh_small d) hρ (modeRemovalRadius_pos d hε).le hwidth + (modeRemovalShrink_move m d hρ hε) (modeRemovalBeta_pos hε).le (fun i => modeRemovalBias_le i hε) + exact hout.trans (modeRemovalError_bound d hε) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +theorem exists_anchored_affine_coefficient_residue_uniform_removal (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + (origin : Option K → I → ℝ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride _hs V hV hZ z).toReal : ℂ) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (origin + fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hbudget⟩ := exists_mode_residue_threshold_exp_budget m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ origin J _ P hP hn hd U C hC hCP frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR residue V hV hwidth + obtain ⟨hside, hrankBudget⟩ := hbudget (Fintype.card I) (Fintype.card (Option K × I)) + P C 1 S ρ ε hP hn hd hC hCP zero_le_one (Real.one_le_exp hP) hS hSP hρ hρP hε hεP + exact anchored_affine_coefficient_residue_removal_at_error origin U hC frequency hbound hbad + p hp hm stride hs hS hρ hε hstride H (fun k => hside.trans (hsize k)) hrank + (hrankBudget.trans hR) residue V hV hwidth + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +theorem exists_anchored_affine_coefficient_ambient_residue_removal (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + (origin : Option K → I → ℝ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothPMF residue stride _hs V hV hZ z).toReal : ℂ) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (origin + fun k j => (z (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hremove⟩ := exists_anchored_affine_coefficient_residue_uniform_removal m + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ origin J _ P hP hn hd U C hC hCP frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR residue V hV hwidth + obtain ⟨hZ, hrem⟩ := hremove origin hP hn hd U hC hCP frequency hbound hbad p hp hm stride hs hS hSP hρ hε hρP hεP + hstride H hsize hrank hR residue V hV hwidth + refine ⟨hZ, ?_⟩ + rw [residueSmoothPMF_expectation] + exact hrem + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCubeResidueAmbient.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCubeResidueAmbient.lean new file mode 100644 index 0000000000000000000000000000000000000000..a671debd9e1926efcd383a7442b21d7fa8195e84 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCubeResidueAmbient.lean @@ -0,0 +1,130 @@ +import OAI.Combinatorics.Progressions.Lattices.RetainedAffineCommonCover + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_anchored_affine_cube_residue_uniform_removal (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + (anchor : Option K × I → ℤ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride _hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => ((anchor + residueLatticeArray residue stride z) (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hbudget⟩ := exists_cube_residue_threshold_exp_budget m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ anchor J _ P hP hn hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest residue V hV hwidth + obtain ⟨hside, hrankBudget⟩ := hbudget (Fintype.card I) (Fintype.card (Option K × I)) + P C L S ρ ε hP hn hd hC hCP hL hLP hS hSP hρ hρP hε hεP + exact anchored_affine_cube_residue_removal_at_error anchor U root difference hlin hL hC hsite frequency hbound hbad + p hp hm stride hs hS hρ hε hstride H (fun k => hside.trans (hsize k)) hrank + (hrankBudget.trans hR) Q hQ test htest residue V hV hwidth + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_anchored_affine_cube_ambient_residue_removal (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + (anchor : Option K × I → ℤ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothPMF residue stride _hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => ((anchor + z) (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hremove⟩ := exists_anchored_affine_cube_residue_uniform_removal m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ anchor J _ P hP hn hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest residue V hV hwidth + obtain ⟨hZ, hrem⟩ := hremove anchor hP hn hd U root difference hlin hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest residue V hV hwidth + refine ⟨hZ, ?_⟩ + rw [residueSmoothPMF_expectation] + exact hrem + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCubeResidueWidths.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCubeResidueWidths.lean new file mode 100644 index 0000000000000000000000000000000000000000..66d549f38b89af88d883c5d6c9b0b65322c79710 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredCubeResidueWidths.lean @@ -0,0 +1,577 @@ +import OAI.Combinatorics.Progressions.Dynamics.LayerRemovalBudgets +import OAI.Combinatorics.Progressions.Estimates.ModeShiftLengths +import OAI.Combinatorics.Progressions.Estimates.SubspaceLayeredModeSmoothRemoval +import OAI.Combinatorics.Progressions.Fourier.AffineFrequencyLift + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators +open VectorPolynomial + +theorem cubeModePolynomialBudget_pos (q : ℕ) {L : ℝ} (hL : 0 ≤ L) : + 0 < cubeModePolynomialBudget q L := by + unfold cubeModePolynomialBudget + positivity + +theorem affineSite_intCast {K : Type*} {q : ℕ} + (root : K → ℤ) (difference : Fin q → K → ℤ) (s : Finset (Fin q)) : + (fun k => ((affineSite root difference s k : ℤ) : ℝ)) = + affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s := by + exact (affineSite_map (Int.castRingHom ℝ) root difference s).symm + +theorem exists_affine_bounded_integer_mode {K J : Type*} [Fintype K] [Fintype J] {q : ℕ} + (W : Submodule ℝ (J → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : (K →₀ ℕ) → J → ℤ) (h : ℕ) + (hbound : ∀ d, d.degree ≤ h → ∀ j, |(frequency d j : ℝ)| ≤ C) + (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ, + ∀ p, Homogeneous h p → + affineModeLift (coefficientFunctional (fun d j => (frequency d j : ℝ))) (map W.subtype p) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) : + ∃ rows : Fin h → Option K → ℤ, + (∀ i k, |(rows i k : ℝ)| ≤ cubeModePolynomialBudget q L) ∧ + (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧ + (∀ j, |(integerContractedRow (affineLiftFrequency frequency) (∏ i, rowPolynomial (rows i)) j : ℝ)| ≤ + C * cubeModePolynomialBudget q L ^ h) ∧ + ∃ w : W, (∑ j, (integerContractedRow (affineLiftFrequency frequency) + (∏ i, rowPolynomial (rows i)) j : ℝ) * w.val j) ≠ 0 := by + apply exists_vertex_bounded_integer_mode W root difference hlin hL hC hsite + (affineLiftFrequency frequency) h (affineLiftFrequency_bound frequency hbound) + simpa only [affineModeLift_integerFrequency] using hnonfactor + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_selected_affine_mode_rows {K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ p, Homogeneous (i.val + 1) p → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype p) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) p)) : + ∃ (i : Fin m) (rows : Fin (i.val + 1) → Option K → ℤ), + (∀ j, i < j → ∃ M : (Finset (Fin q) → U j) →ₗ[ℝ] ℝ, + ∀ p, DegreeLE (1 : Option K → ℕ) (j.val + 1) p → + affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))) (map (U j).subtype p) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) p)) ∧ + (∀ r k, |(rows r k : ℝ)| ≤ cubeModePolynomialBudget q L) ∧ + (∀ s : Finset (Fin q), ∃ r, (∑ k, rows r k * affineSite root difference s k) = 0) ∧ + (∀ a, |(integerContractedRow (affineLiftFrequency (frequency i)) + (∏ r, rowPolynomial (rows r)) a : ℝ)| ≤ C * cubeModePolynomialBudget q L ^ (i.val + 1)) ∧ + ∃ w : U i, (∑ a, (integerContractedRow (affineLiftFrequency (frequency i)) + (∏ r, rowPolynomial (rows r)) a : ℝ) * w.val a) ≠ 0 := by + let site : Finset (Fin q) → K → ℝ := + fun s k => (root k : ℝ) + ∑ r ∈ s, (difference r k : ℝ) + have he : (fun s (k : Option K) => k.elim 1 (site s)) = + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) := by + funext s k + cases k <;> rfl + obtain ⟨i, hi, hh⟩ := exists_highest_affine_subspace_nonfactor U site + (fun j => coefficientFunctional (fun d a => (frequency j d a : ℝ))) (by rwa [he]) + rw [he] at hi hh + obtain ⟨rows, hr, hz, hb, hw⟩ := exists_affine_bounded_integer_mode (U i) root difference hlin + hL hC hsite (frequency i) (i.val + 1) (hbound i) hi + exact ⟨i, rows, hh, hr, hz, hb, hw⟩ + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_affine_cube_local_removal {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, + ((i.val + 1).factorial : ℝ) * (C * cubeModePolynomialBudget q L ^ (i.val + 1)) ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + {β : ℝ} (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ∃ i : Fin m, ∃ rows : Fin (i.val + 1) → Option K → ℤ, + (∀ a k, |(rows a k : ℝ)| ≤ cubeModePolynomialBudget q L) ∧ + ∀ base : Option K → I → ℝ, + ‖𝔼 x : Fin (i.val + 1) → ∀ j, Fin (N j), + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test + (rowShiftedTuple base rows + (fun (y : ∀ j, Fin (N j)) j => (stride j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ β := by + classical + obtain ⟨i, rows, hfactor, hrows, hzero, hcontract, hnonzero⟩ := + exists_selected_affine_mode_rows U root difference hlin hL hC hsite frequency hbound hbad + have hcast : (fun s k => ((affineSite root difference s k : ℤ) : ℝ)) = + (fun s => affineSite (fun k => (root k : ℝ)) (fun a k => (difference a k : ℝ)) s) := by + funext s + exact affineSite_intCast root difference s + obtain ⟨Q', hQ', test', ht, he⟩ := exists_subspace_layered_mode_reduction i U + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p hm hp (fun s => affineSite root difference s) + (by rw [hcast]; exact hfactor) Q (hQ.trans_lt (Nat.zero_lt_succ _)) test htest + refine ⟨i, rows, hrows, ?_⟩ + intro base + simp_rw [he, affineModeLift_integerFrequency] + exact inhomogeneous_coefficient_mode_local_removal (affineLiftFrequency (frequency i)) rows + (p i) (hp i) (U i) N stride hs hζ (hN i) H hH hA hscale (hrank i) + hcontract (hrowBudget i) hnonzero (hdenom i) (hcoeff i) + (fun s => affineSite root difference s) hzero Q' hQ' test' ht hβ (hpower i) base + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem affine_cube_mode_residue_removal {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, + ((i.val + 1).factorial : ℝ) * (C * cubeModePolynomialBudget q L ^ (i.val + 1)) ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {r β : ℝ} (hr : 0 ≤ r) + (hmove : ∀ i : Fin m, ∀ z, + ((i.val + 1 : ℕ) : ℝ) * cubeModePolynomialBudget q L * + ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_cube_local_removal + U root difference hlin hL hC hsite frequency hbound hbad p hp hm N stride hs hζ hN + H hH hA hscale hrank hrowBudget hdenom hcoeff Q hQ test htest hβ hpower + have hNp k : 0 < N k := by + exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k) + exact residue_smooth_row_shift_transfer N stride hNp hs rows residue V hV hZ hV1 + hδ hδ1 hmesh hsmall (cubeModePolynomialBudget_pos q hL).le hrows hr (hmove i) + _ (layeredModeTestedPhase_norm_le _ p Q _ test htest) hlocal + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem anchored_affine_cube_mode_residue_removal {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + (anchor : Option K × I → ℤ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, + ((i.val + 1).factorial : ℝ) * (C * cubeModePolynomialBudget q L ^ (i.val + 1)) ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {r β : ℝ} (hr : 0 ≤ r) + (hmove : ∀ i : Fin m, ∀ z, + ((i.val + 1 : ℕ) : ℝ) * cubeModePolynomialBudget q L * + ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => ((anchor + residueLatticeArray residue stride z) (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + obtain ⟨i, rows, hrows, hlocal⟩ := exists_affine_cube_local_removal + U root difference hlin hL hC hsite frequency hbound hbad p hp hm N stride hs hζ hN + H hH hA hscale hrank hrowBudget hdenom hcoeff Q hQ test htest hβ hpower + have hNp k : 0 < N k := by + exact_mod_cast (multiaffineBiasBudget_pos i.val hζ).trans_le (hN i k) + have h := anchored_residue_smooth_row_shift_transfer (fun k i => (anchor (k,i) : ℝ)) N stride hNp hs rows residue V hV hZ hV1 + hδ hδ1 hmesh hsmall (cubeModePolynomialBudget_pos q hL).le hrows hr (hmove i) + _ (layeredModeTestedPhase_norm_le _ p Q _ test htest) hlocal + + simpa only [← integerArrayFrame_add] using h + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators NNReal + +theorem affine_cube_mode_smooth_removal {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (N stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R : ℝ} (hζ : 0 < ζ) (hN : ∀ i : Fin m, ∀ k, multiaffineBiasBudget i.val ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((stride k : ℝ) * (N k : ℝ))) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hrowBudget : ∀ i : Fin m, + ((i.val + 1).factorial : ℝ) * (C * cubeModePolynomialBudget q L ^ (i.val + 1)) ≤ R) + (hdenom : ∀ i : Fin m, (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ R) + (hcoeff : ∀ i : Fin m, (Fintype.card I : ℝ) ^ (i.val + 1) * + (A ^ (i.val + 1) * multiaffineBiasBudget i.val ζ) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (hV1 : ∀ z, 1 ≤ V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {r β : ℝ} (hr : 0 ≤ r) + (hmove : ∀ i : Fin m, ∀ z, + ((i.val + 1 : ℕ) : ℝ) * cubeModePolynomialBudget q L * + ((stride z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((smoothProductPMF V hV z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + obtain ⟨i, rows, hfactor, hrows, hzero, hcontract, hnonzero⟩ := + exists_selected_affine_mode_rows U root difference hlin hL hC hsite frequency hbound hbad + have hcast : (fun s k => ((affineSite root difference s k : ℤ) : ℝ)) = + (fun s => affineSite (fun k => (root k : ℝ)) (fun a k => (difference a k : ℝ)) s) := by + funext s + exact affineSite_intCast root difference s + apply subspace_layered_mode_smooth_removal i (affineLiftFrequency (frequency i)) rows + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + (affineModeLift_integerFrequency (frequency i)) p hp U hm N stride hs hζ (hN i) + H hH hA hscale (hrank i) hcontract (hrowBudget i) hnonzero (hdenom i) (hcoeff i) + (fun s => affineSite root difference s) _ hzero Q (hQ.trans_lt (Nat.zero_lt_succ _)) + test htest V hV hV1 hδ hδ1 hmesh hsmall (cubeModePolynomialBudget_pos q hL).le hrows + hr (hmove i) hβ (hpower i) + rw [hcast] + exact hfactor + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators NNReal + +theorem affine_cube_residue_removal_of_widths {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (hH : ∀ k, 0 < H k) + (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : layerRemovalRankBudget m (Fintype.card I) C (cubeModePolynomialBudget q L) + (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) + (hmove : (m : ℝ) * cubeModePolynomialBudget q L ≤ r * ρ * T) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + let B := finiteLayerBiasBudget m ζ + let D := cubeModePolynomialBudget q L + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ + have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le + have hA : 0 ≤ 2 * T := by positivity + have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B := + multiaffineBiasBudget_le_finite i hζ + obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth + have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD + (zero_le_one.trans hB) hA hS + apply affine_cube_mode_residue_removal U root difference hlin hL hC hsite frequency hbound hbad + p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank + (fun i => (hbud i).1.trans hR) _ _ Q hQ test htest residue V hV hZ hV1 hδ hδ1 hmesh hsmall hr _ hβ hpower + · intro i + have hi := tensorDenominatorBound_le (H := Fin (i.val + 1)) + (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ)) + (fun k => Nat.cast_nonneg _) hstride + have hi' : (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ + (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by + simpa only [Fintype.card_fin] using hi + apply hi'.trans + apply le_trans _ ((hbud i).2.1.trans hR) + exact pow_le_pow_left₀ + (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _)) + (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _ + · intro i + apply le_trans _ ((hbud i).2.2.trans hR) + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _)) + (pow_nonneg (Nat.cast_nonneg _) _) + · intro i z + have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt + apply le_trans _ (hshift z) + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hi hD) + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators NNReal + +theorem anchored_affine_cube_residue_removal_of_widths {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + (anchor : Option K × I → ℤ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {ζ R T S : ℝ} (hζ : 0 < ζ) (hT : 0 < T) (hS : 0 ≤ S) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (hH : ∀ k, 0 < H k) + (hsize : ∀ k, (stride k : ℝ) * T * (finiteLayerBiasBudget m ζ + 1) ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : layerRemovalRankBudget m (Fintype.card I) C (cubeModePolynomialBudget q L) + (finiteLayerBiasBudget m ζ) (2 * T) S ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth stride V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ z, 1 / residueProfileWidth stride V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {ρ r β : ℝ} (hρ : 0 < ρ) (hr : 0 ≤ r) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) + (hmove : (m : ℝ) * cubeModePolynomialBudget q L ≤ r * ρ * T) + (hβ : 0 ≤ β) (hpower : ∀ i : Fin m, ζ ≤ β ^ (2 ^ (i.val + 1))) : + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => ((anchor + residueLatticeArray residue stride z) (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (Option K × I) * + ((Fintype.card (Option K × I) : ℝ) * probabilityProfileLipschitz) * r + β := by + classical + let B := finiteLayerBiasBudget m ζ + let D := cubeModePolynomialBudget q L + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m hζ + have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le + have hA : 0 ≤ 2 * T := by positivity + have hb (i : Fin m) : multiaffineBiasBudget i.val ζ ≤ B := + multiaffineBiasBudget_le_finite i hζ + obtain ⟨N, hN, hscale, hshift⟩ := exists_mode_shift_lengths m hT hB hρ hr hmove H stride hs hsize V hwidth + have hbud (i : Fin m) := layerRemovalRankBudget_bounds i (Fintype.card I) hC hD + (zero_le_one.trans hB) hA hS + apply anchored_affine_cube_mode_residue_removal anchor U root difference hlin hL hC hsite frequency hbound hbad + p hp hm N stride hs hζ (fun i k => (hb i).trans (hN k)) H hH hA hscale hrank + (fun i => (hbud i).1.trans hR) _ _ Q hQ test htest residue V hV hZ hV1 hδ hδ1 hmesh hsmall hr _ hβ hpower + · intro i + have hi := tensorDenominatorBound_le (H := Fin (i.val + 1)) + (multiaffineBiasBudget_pos i.val hζ).le (fun k => (stride k : ℝ)) + (fun k => Nat.cast_nonneg _) hstride + have hi' : (∏ j : Fin (i.val + 1) → I, + (multiaffineBiasBudget i.val ζ * ∏ r, (stride (j r) : ℝ))) ≤ + (multiaffineBiasBudget i.val ζ * S ^ (i.val + 1)) ^ (Fintype.card I ^ (i.val + 1)) := by + simpa only [Fintype.card_fin] using hi + apply hi'.trans + apply le_trans _ ((hbud i).2.1.trans hR) + exact pow_le_pow_left₀ + (mul_nonneg (multiaffineBiasBudget_pos i.val hζ).le (pow_nonneg hS _)) + (mul_le_mul_of_nonneg_right (hb i) (pow_nonneg hS _)) _ + · intro i + apply le_trans _ ((hbud i).2.2.trans hR) + exact mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left (hb i) (pow_nonneg hA _)) + (pow_nonneg (Nat.cast_nonneg _) _) + · intro i z + have hi : ((i.val + 1 : ℕ) : ℝ) ≤ m := by exact_mod_cast Nat.succ_le_of_lt i.isLt + apply le_trans _ (hshift z) + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hi hD) + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredIntegerIntervalsPower.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredIntegerIntervalsPower.lean new file mode 100644 index 0000000000000000000000000000000000000000..74d0345583fa7755c2faf2d330dd156641953a14 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredIntegerIntervalsPower.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.Progressions.Dynamics.AnchorLossBudget +import OAI.Combinatorics.Progressions.Estimates.FixedTwoShiftBranches + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_anchored_integer_intervals {K : Type*} [Fintype K] {N : ℕ} [NeZero N] + (H : Finset (ZMod N)) (hH : H.Nonempty) + (U : ZMod N → K → ℤ → ℂ) (Q R : K → ℤ → ℂ) {delta : ℝ} (hdelta : 0 < delta) + (hU : ∀ h ∈ H, ∀ k n, ‖U h k n‖ ≤ 1) + (hQ : ∀ k n, ‖Q k n‖ ≤ 1) (hR : ∀ k n, ‖R k n‖ ≤ 1) + (hcorr : ∀ h ∈ H, ∀ k, delta ≤ ‖𝔼 x : ZMod N, + U h k x.val * Q k x.val * R k ((x + h).val : ℤ)‖) : + ∃ h0 ∈ H, ∃ (branches : K → Bool × Bool) (S : Finset (ZMod N)), + S ⊆ H ∧ S.Nonempty ∧ + Real.exp (-Real.log 4 * Fintype.card K) * (delta ^ (2 * Fintype.card K) / 2) * H.card ≤ + (S.card : ℝ) ∧ + ∀ h ∈ S, ∀ k, ∃ a len : ℕ, 0 < len ∧ a + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + delta ^ (2 * Fintype.card K) / 40 ≤ + ‖𝔼 n ∈ Finset.Ico (a : ℤ) (a + len), + partnerAnchorWeight (U h k) (U h0 k) (Q k) n * + R k (n + cyclicBranchOffset h (branches k).1) * + star (R k (n + cyclicBranchOffset h0 (branches k).2))‖ ∧ + delta ^ (2 * Fintype.card K) / 40 ≤ (len : ℝ) / N := by + obtain ⟨h0, hh0, H', hsub, hH'n, hsize, hanchor⟩ := exists_fixed_partner_anchor H hH + (fun h k x => U h k x.val) (fun k x => Q k x.val) (fun k x => R k x.val) hdelta + (fun h hh k x => hU h hh k x.val) (fun k x => hQ k x.val) (fun k x => hR k x.val) hcorr + let f : ZMod N → K → ℤ → ℂ := fun h k => partnerAnchorWeight (U h k) (U h0 k) (Q k) + have hf : ∀ h ∈ H', ∀ k n, ‖f h k n‖ ≤ 1 := by + intro h hh k n + exact partnerAnchorWeight_norm_le_one (U h k) (U h0 k) (Q k) + (hU h (hsub hh) k) (hU h0 hh0 k) (hQ k) n + have hcorr' : ∀ h ∈ H', ∀ k, delta ^ (2 * Fintype.card K) / 2 ≤ + ‖𝔼 x : ZMod N, f h k x.val * R k ((x + h).val : ℤ) * star (R k ((x + h0).val : ℤ))‖ := + hanchor + obtain ⟨branches, S, hSH', hSn, hcard, hinterval⟩ := exists_fixed_two_shift_branches + H' hH'n h0 f R (by positivity) hf hR hcorr' + refine ⟨h0, hh0, branches, S, fun h hh => hsub (hSH' hh), hSn, ?_, ?_⟩ + · calc + _ = Real.exp (-Real.log 4 * Fintype.card K) * + ((delta ^ (2 * Fintype.card K) / 2) * H.card) := mul_assoc _ _ _ + _ ≤ Real.exp (-Real.log 4 * Fintype.card K) * H'.card := + mul_le_mul_of_nonneg_left hsize (Real.exp_pos _).le + _ ≤ _ := hcard + · intro h hh k + obtain ⟨a, len, hlen, hbound, hshort, hbias, hvol⟩ := hinterval h hh k + refine ⟨a, len, hlen, hbound, hshort, ?_, ?_⟩ + · simpa only [div_div, show (2 : ℝ) * 20 = 40 by norm_num] using hbias + · simpa only [div_div, show (2 : ℝ) * 20 = 40 by norm_num] using hvol + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_anchored_integer_intervals_power {K : Type*} [Fintype K] {N : ℕ} [NeZero N] + (H : Finset (ZMod N)) (U : ZMod N → K → ℤ → ℂ) (Q R : K → ℤ → ℂ) + {p delta : ℝ} (hp : 2 ≤ p) (hm : (Fintype.card K : ℝ) ≤ p) + (hdelta : Real.exp (-p) ≤ delta) (hH : Real.exp (-p) * N ≤ (H.card : ℝ)) + (hU : ∀ h ∈ H, ∀ k n, ‖U h k n‖ ≤ 1) + (hQ : ∀ k n, ‖Q k n‖ ≤ 1) (hR : ∀ k n, ‖R k n‖ ≤ 1) + (hcorr : ∀ h ∈ H, ∀ k, delta ≤ ‖𝔼 x : ZMod N, + U h k x.val * Q k x.val * R k ((x + h).val : ℤ)‖) : + ∃ h0 ∈ H, ∃ (branches : K → Bool × Bool) (S : Finset (ZMod N)), + S ⊆ H ∧ S.Nonempty ∧ Real.exp (-((p + 2) ^ 3)) * N ≤ (S.card : ℝ) ∧ + ∀ h ∈ S, ∀ k, ∃ a len : ℕ, 0 < len ∧ a + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + Real.exp (-((p + 2) ^ 3)) ≤ + ‖𝔼 n ∈ Finset.Ico (a : ℤ) (a + len), + partnerAnchorWeight (U h k) (U h0 k) (Q k) n * + R k (n + cyclicBranchOffset h (branches k).1) * + star (R k (n + cyclicBranchOffset h0 (branches k).2))‖ ∧ + Real.exp (-((p + 2) ^ 3)) ≤ (len : ℝ) / N := by + have hdelta0 : 0 < delta := (Real.exp_pos _).trans_le hdelta + have hN : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + have hHpos : (0 : ℝ) < H.card := (mul_pos (Real.exp_pos _) hN).trans_le hH + have hHn : H.Nonempty := Finset.card_pos.mp (by exact_mod_cast hHpos) + obtain ⟨h0, hh0, branches, S, hsub, hSn, hsize, hinterval⟩ := + exists_anchored_integer_intervals H hHn U Q R hdelta0 hU hQ hR hcorr + have hB : 0 ≤ Real.exp (-Real.log 4 * Fintype.card K) * (delta ^ (2 * Fintype.card K) / 2) := + mul_nonneg (Real.exp_nonneg _) (by positivity) + refine ⟨h0, hh0, branches, S, hsub, hSn, ?_, ?_⟩ + · calc + _ ≤ (Real.exp (-Real.log 4 * Fintype.card K) * + (delta ^ (2 * Fintype.card K) / 2) * Real.exp (-p)) * N := + mul_le_mul_of_nonneg_right (anchored_density_budget hp hm hdelta le_rfl) hN.le + _ = (Real.exp (-Real.log 4 * Fintype.card K) * + (delta ^ (2 * Fintype.card K) / 2)) * (Real.exp (-p) * N) := by ring + _ ≤ (Real.exp (-Real.log 4 * Fintype.card K) * + (delta ^ (2 * Fintype.card K) / 2)) * H.card := mul_le_mul_of_nonneg_left hH hB + _ ≤ _ := hsize + · intro h hh k + obtain ⟨a, len, hlen, hbound, hshort, hbias, hvol⟩ := hinterval h hh k + exact ⟨a, len, hlen, hbound, hshort, (anchored_interval_budget hp hm hdelta).trans hbias, + (anchored_interval_budget hp hm hdelta).trans hvol⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredResidueProjectionTransfer.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredResidueProjectionTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c946cf5de8f8361d343f578c3be4ee8a76a6d20 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AnchoredResidueProjectionTransfer.lean @@ -0,0 +1,58 @@ +import OAI.Combinatorics.Progressions.Linear.ProductOneSiteProjectionCap + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial + +theorem anchored_selectedResidue_oneSite_density_error {I K F : Type*} [Fintype I] [Fintype K] [Fintype F] + (anchor : Option K × I → ℤ) + {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (t : K → ℤ) (difference : Fin 0 → K → ℤ) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ) {η ε : ℝ} (hη : 0 ≤ η) + (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) + (hD : ∀ y, Integrable (fun x => D (coefficientFiberMap U t y x)) μ) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (G : Finset (ColumnResiduePattern (Option K) I stride)) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x) + (w : (Option K × I → ℤ) → ℂ) (hw : ∀ x, ‖w x‖ ≤ 1) + (hprojection : ‖(∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * affineCubeFourierSum frequency p c (fun k j => ((anchor + x) (k, j) : ℝ)))) - + ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * affineCubeFourierProjection U t difference frequency p c (fun k j => ((anchor + x) (k, j) : ℝ)))‖ ≤ ε) : + ‖(∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * (D (affineSampleCoefficientTorus U p hm (fun k j => ((anchor + x) (k, j) : ℝ))) : ℂ))) - + ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * + (w x * ((coefficientFiberAverage U μ t D (coefficientEvaluationTorus U t + (affineSampleCoefficientTorus U p hm (fun k j => ((anchor + x) (k, j) : ℝ)))) : ℝ) : ℂ))‖ ≤ 2 * η + ε := by + let prob := selectedResidueFiniteLaw stride G V hV hZ + have hmean (f : (Option K × I → ℤ) → ℂ) : prob.complexMean (fun x => f x.val) = + ∑' x, ((selectedResidueSmoothPMF stride G V hV hZ x).toReal : ℂ) * f x := + selectedResidueFiniteLaw_complexMean stride G V hV hZ f + have hw' : prob.mean (fun x => ‖w x.val‖) ≤ 1 := + (prob.mean_mono (fun x => hw x.val)).trans_eq (prob.mean_const 1) + have he := oneSiteDensity_projection_error (ε := ε) U t difference frequency c μ D hη happrox p hp hm + prob (fun x k j => ((anchor + x.val) (k, j) : ℝ)) (fun x => w x.val) (fun _ _ => hD _) hw' + (by + rw [hmean (fun x => w x * affineCubeFourierSum frequency p c (fun k j => ((anchor + x) (k, j) : ℝ))), + hmean (fun x => w x * affineCubeFourierProjection U t difference frequency p c (fun k j => ((anchor + x) (k, j) : ℝ)))] + exact hprojection) + rw [hmean (fun x => w x * (D (affineSampleCoefficientTorus U p hm (fun k j => ((anchor + x) (k, j) : ℝ))) : ℂ)), + hmean (fun x => w x * ((coefficientFiberAverage U μ t D (coefficientEvaluationTorus U t + (affineSampleCoefficientTorus U p hm (fun k j => ((anchor + x) (k, j) : ℝ)))) : ℝ) : ℂ))] at he + simpa only [mul_one] using he + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AnnihilatingCoordinateResidue.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AnnihilatingCoordinateResidue.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fac5d7188ef43bba6c80b07a0eda8038e4903cc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AnnihilatingCoordinateResidue.lean @@ -0,0 +1,51 @@ +import Mathlib.Data.Int.ModEq +import OAI.Combinatorics.Progressions.Fourier.CharacterCoordinateScale + +namespace OAI + +section + +namespace Erdos3 + +theorem update_integerVector_sub {I : Type*} [DecidableEq I] + (v : I → ℤ) (i : I) (x y : ℤ) : + Function.update v i x - Function.update v i y = (x - y) • (Pi.single i 1 : I → ℤ) := by + ext j + by_cases hji : j = i + · subst j; simp + · simp [hji] + +theorem annihilating_coordinate_difference_dvd {I : Type*} [DecidableEq I] + (χ : AddChar (I → ℤ) ℂ) (v : I → ℤ) (i : I) {x y : ℤ} + (hxy : χ (Function.update v i x) = χ (Function.update v i y)) : + (orderOf (latticeCharacterCoordinates χ i) : ℤ) ∣ x - y := by + have hn : χ (Function.update v i y) ≠ 0 := (χ.val_isUnit _).ne_zero + have hd : χ (Function.update v i x - Function.update v i y) = 1 := by + rw [χ.map_sub_eq_div, hxy, div_self hn] + rw [update_integerVector_sub, χ.map_zsmul_eq_zpow] at hd + change latticeCharacterCoordinates χ i ^ (x - y) = 1 at hd + let u := (χ.val_isUnit (Pi.single i 1)).unit + have hu : (u : ℂ) = latticeCharacterCoordinates χ i := (χ.val_isUnit _).unit_spec + have hpow : u ^ (x - y) = 1 := by + apply Units.ext + simpa only [Units.val_zpow_eq_zpow_val, hu, Units.val_one] using hd + have hdiv := orderOf_dvd_iff_zpow_eq_one.mpr hpow + rwa [← orderOf_units, hu] at hdiv + +theorem annihilating_coordinate_residue {I : Type*} [DecidableEq I] + (χ : AddChar (I → ℤ) ℂ) (v : I → ℤ) (i : I) : + ∃ r : ℤ, ∀ x, χ (Function.update v i x) = 1 → + x ≡ r [ZMOD (orderOf (latticeCharacterCoordinates χ i) : ℤ)] := by + by_cases hex : ∃ r, χ (Function.update v i r) = 1 + · obtain ⟨r, hr⟩ := hex + refine ⟨r, fun x hx => ?_⟩ + have hdiv := annihilating_coordinate_difference_dvd χ v i (hx.trans hr.symm) + exact (show r ≡ x [ZMOD (orderOf (latticeCharacterCoordinates χ i) : ℤ)] from + Int.modEq_iff_dvd.mpr hdiv).symm + · exact ⟨0, fun x hx => False.elim (hex ⟨x, hx⟩)⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AuxiliaryResidueLocalization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AuxiliaryResidueLocalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..57e3b94706e6dc593eb18c3878cd8a09776800e1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AuxiliaryResidueLocalization.lean @@ -0,0 +1,105 @@ +import OAI.Combinatorics.Progressions.Geometry.PhysicalBoxPartition +import OAI.Combinatorics.Progressions.Probability.AuxiliaryBoxLaws + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_auxiliary_residue_piece {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (N H : I → ℕ) (hH : ∀ i, 0 < H i) (hHN : ∀ i, H i ≤ N i) + (M d J : I → ℕ) (hM : ∀ i, 0 < M i) (hd : ∀ i, 0 < d i) (hJ : ∀ i, 0 < J i) + (u w : I → ℤ) (hw : ∀ i, w i ≡ u i [ZMOD (M i : ℤ)]) + (hcop : ∀ i, (M i * d i).Coprime (J i)) {ε : ℝ} (hε : ε < 1 / 2) + (hsmall : (∑ i, (Nat.lcm (M i) (d i) * J i : ℕ) / (H i : ℝ)) ≤ ε) + (f : IntegerResidueBox a (fun i => a i + N i) (fun i => (M i : ℤ)) u → ℂ) + (g : IntegerResidueBox a (fun i => a i + N i) (fun i => (M i * J i : ℕ)) w → ℂ) + (hg : ∀ x, ‖g x‖ ≤ 1) : + let P := comparableBoxPartitions N H hH hHN + ∃ k : AuxiliaryBoxLabels P M d u, + 0 < (partitionCell (baseAuxiliaryBoxCell a N P M d hd u) k).card ∧ + 0 < (partitionCell (refinedAuxiliaryBoxCell a N P M d J hd u w hw) k).card ∧ + ‖(𝔼 x, f x) - (𝔼 x, g x)‖ - 8 * ε ≤ + ‖(𝔼 x ∈ partitionCell (baseAuxiliaryBoxCell a N P M d hd u) k, f x) - + (𝔼 x ∈ partitionCell (refinedAuxiliaryBoxCell a N P M d J hd u w hw) k, g x)‖ := by + intro P + let := auxiliaryBoxLabels_nonempty P (comparableBoxPartitions_nonempty N H hH hHN) M d hd u + have hstep : ∀ i k, (P i).step k = 1 := comparableBoxPartitions_step N H hH hHN + have hpos : ∀ i k, 0 < (P i).length k := fun i k => + (hH i).trans_le (comparableBoxPartitions_length N H hH hHN i k).1 + let lo : AuxiliaryBoxLabels P M d u → I → ℤ := + fun k i => intervalCellLower (a i) (P i) (k i).1 + let hi : AuxiliaryBoxLabels P M d u → I → ℤ := + fun k i => intervalCellUpper (a i) (P i) (k i).1 + let R : I → ℤ := fun i => Nat.lcm (M i) (d i) + let S : I → ℤ := fun i => (Nat.lcm (M i) (d i) * J i : ℕ) + let v : AuxiliaryBoxLabels P M d u → I → ℤ := fun k i => (k i).2.baseValue + let z : AuxiliaryBoxLabels P M d u → I → ℤ := fun k i => (k i).2.refinedValue (hcop i) (w i) + have hL : ∀ i, 0 < Nat.lcm (M i) (d i) := fun i => + Nat.pos_of_ne_zero (Nat.lcm_ne_zero (hM i).ne' (hd i).ne') + have hRpos : ∀ i, 0 < R i := by + intro i + dsimp only [R] + exact_mod_cast hL i + have hSpos : ∀ i, 0 < S i := by + intro i + dsimp only [S] + exact_mod_cast Nat.mul_pos (hL i) (hJ i) + have hsmallS : (∑ i, (S i : ℝ) / (H i : ℝ)) ≤ ε := by + simpa only [S, Int.cast_natCast] using hsmall + have hsmallR : (∑ i, (R i : ℝ) / (H i : ℝ)) ≤ ε := by + apply le_trans (Finset.sum_le_sum fun i _ => ?_) hsmallS + apply div_le_div_of_nonneg_right ?_ (Nat.cast_nonneg _) + have hle : Nat.lcm (M i) (d i) ≤ Nat.lcm (M i) (d i) * J i := by + nlinarith [hJ i] + dsimp only [R, S] + exact_mod_cast hle + have hbox : ∀ k i, lo k i < hi k i := by + intro k i + apply sub_pos.mp + change 0 < intervalCellUpper (a i) (P i) (k i).1 - intervalCellLower (a i) (P i) (k i).1 + rw [intervalCell_width] + exact_mod_cast hpos i (k i).1 + have hR : ∀ k, (∑ i, (R i : ℝ) / ((hi k i - lo k i : ℤ) : ℝ)) ≤ ε := + fun k => (comparableBoxPartitions_ratio_le a N H hH hHN R (fun i => (hRpos i).le) + (fun i => (k i).1)).trans hsmallR + have hS : ∀ k, (∑ i, (S i : ℝ) / ((hi k i - lo k i : ℤ) : ℝ)) ≤ ε := + fun k => (comparableBoxPartitions_ratio_le a N H hH hHN S (fun i => (hSpos i).le) + (fun i => (k i).1)).trans hsmallS + let F : AuxiliaryBoxLabels P M d u → ℂ := fun k => + 𝔼 x ∈ partitionCell (baseAuxiliaryBoxCell a N P M d hd u) k, f x + let G : AuxiliaryBoxLabels P M d u → ℂ := fun k => + 𝔼 x ∈ partitionCell (refinedAuxiliaryBoxCell a N P M d J hd u w hw) k, g x + have hG : ∀ k, ‖G k‖ ≤ 1 := by + intro k + let A := partitionCell (refinedAuxiliaryBoxCell a N P M d J hd u w hw) k + change ‖𝔼 x ∈ A, g x‖ ≤ 1 + by_cases hA : A.Nonempty + · apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun x _ => hg x)).trans_eq (Finset.expect_const hA 1) + · have he := Finset.not_nonempty_iff_eq_empty.mp hA + simp only [he, Finset.expect_empty, norm_zero, zero_le_one] + obtain ⟨k, hkr, hks, hgap⟩ := exists_rectangular_residue_piece_discrepancy + lo hi R S v z hbox hRpos hSpos hε hR hS F G hG + have hmR := boxAuxiliaryCell_mixture a N P hstep hpos M d hd u (fun i => (M i : ℤ)) u + (fun _ _ hx => hx) R v (fun k i => (k i).2.baseConstraint_iff) f + have hmS := boxAuxiliaryCell_mixture a N P hstep hpos M d hd u (fun i => (M i * J i : ℕ)) w + (fun i => refinedResidue_implies_base (M i) (J i) (u i) (w i) (hw i)) S z + (fun k i => (k i).2.refinedConstraint_iff (hcop i) (w i) (hw i)) g + simp only [div_mul_eq_mul_div, ← Finset.sum_div] at hmR hmS + dsimp only [F, G, lo, hi, baseAuxiliaryBoxCell, refinedAuxiliaryBoxCell] at hgap + rw [← hmR, ← hmS] at hgap + refine ⟨k, ?_, ?_, hgap⟩ + · rw [baseAuxiliaryBoxCell_card a N P hstep hpos M d hd u] + exact Nat.cast_pos.mp hkr + · rw [refinedAuxiliaryBoxCell_card a N P hstep hpos M d J hd u w hw hcop] + exact Nat.cast_pos.mp hks + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineGrid.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7029c20b9eb4ed6b1dad41b49cdebe3a09b67e0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineGrid.lean @@ -0,0 +1,807 @@ +import OAI.Combinatorics.Progressions.Estimates.CoefficientAverageL1 +import OAI.Combinatorics.Progressions.Estimates.RetainedJointUnitOrder +import OAI.Combinatorics.Progressions.Geometry.AveragedIdealSupport +import OAI.Combinatorics.Progressions.Probability.AveragedJointImageLaw +import OAI.Combinatorics.Progressions.Probability.RetainedGroupedDensity + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +section + +variable {W T Q Z X K α : Type*} [MeasurableSpace W] [MeasurableSpace T] [Fintype Q] + [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) + (ν : Measure T) (z : W → T → Z → ℝ) (x : W → T → X → ℝ) + +noncomputable def flatAffineMixtureDensity (a : W) (v : (Σ q, I q) → ℝ) : ℝ := + densityMixture ν (fun t => jointAffineJetDensity s A F e input (z a t) rows c w (x a t)) + (sigmaAxisCoordinates I v) + +noncomputable def flatAffineUnitSource + (p : (W × (∀ q, J q ⊕ N q → ℝ)) × T) : W × ((Σ q, I q) → ℝ) := + (p.1.1, (sigmaAxisCoordinates I).symm + (jointAffineJetUnitMap s A F e input (z p.1.1 p.2) rows c w (x p.1.1 p.2) p.1.2)) + +variable (hz : ∀ j, Measurable (fun p : W × T => z p.1 p.2 j)) + (hx : ∀ j, Measurable (fun p : W × T => x p.1 p.2 j)) + +include hz hx in +theorem flatAffineUnitSource_measurable : + Measurable (flatAffineUnitSource s A F e input rows c w z x) := by + have hm := jointAffineJetUnitMap_measurable_comp (Ω := (W × (∀ q, J q ⊕ N q → ℝ)) × T) + s A F e input rows (fun _ => c) (fun _ => w) (fun p => p.1.2) + (fun _ => measurable_const) (fun _ => measurable_const) + (fun q => (measurable_pi_apply q).comp (measurable_snd.comp measurable_fst)) + (fun p => z p.1.1 p.2) (fun j => (hz j).comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)) + (fun p => x p.1.1 p.2) (fun j => (hx j).comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)) + exact (measurable_fst.comp measurable_fst).prodMk ((sigmaAxisCoordinates I).symm.continuous.measurable.comp hm) + +variable (hw : ∀ q j, 0 < w q j) (R : Q → ℝ≥0) (hsupport : ∀ q j, |c q j|+w q j ≤ R q) + +include hw hsupport hz hx in +theorem flatAffineMixtureDensity_measurable [SFinite ν] : + Measurable (Function.uncurry (flatAffineMixtureDensity s A F e input rows c w ν z x)) := by + have hm := jointAffineJetDensity_measurable_comp (Ω := (W × ((Σ q, I q) → ℝ)) × T) + s A F e input rows c w hw R hsupport + (fun p => z p.1.1 p.2) (fun j => (hz j).comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)) + (fun p => x p.1.1 p.2) (fun j => (hx j).comp ((measurable_fst.comp measurable_fst).prodMk measurable_snd)) + (fun p => sigmaAxisCoordinates I p.1.2) + (fun q i => (measurable_pi_apply (⟨q, i⟩ : Σ q, I q)).comp (measurable_snd.comp measurable_fst)) + exact hm.stronglyMeasurable.integral_prod_right'.measurable + +include hw hsupport hz hx in +theorem flatAffineMixtureDensity_image_law (μ : Measure W) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] : + ((μ.prod (jointUnitCoefficientSource J N)).prod ν).map + (flatAffineUnitSource s A F e input rows c w z x) = + realDensityMeasure (μ.prod volume) (Function.uncurry (flatAffineMixtureDensity s A F e input rows c w ν z x)) := by + have hlaw := jointAffineJetDensity_retained_conditioned_law s A F e input rows c w hw R hsupport μ ν z hz x hx + let g := fun p : W × (∀ q, I q → ℝ) => (p.1, (sigmaAxisCoordinates I).symm p.2) + have hg : Measurable g := measurable_fst.prodMk ((sigmaAxisCoordinates I).symm.continuous.measurable.comp measurable_snd) + have hm := flatAffineUnitSource_measurable s A F e input rows c w z x hz hx + have hgroup : Measurable (fun p : (W × (∀ q, J q ⊕ N q → ℝ)) × T => + (p.1.1, jointAffineJetUnitMap s A F e input (z p.1.1 p.2) rows c w (x p.1.1 p.2) p.1.2)) := by + have hback : Measurable (fun p : W × ((Σ q, I q) → ℝ) => (p.1, sigmaAxisCoordinates I p.2)) := + measurable_fst.prodMk ((sigmaAxisCoordinates I).continuous.measurable.comp measurable_snd) + simpa only [Function.comp_def, flatAffineUnitSource, ContinuousLinearEquiv.apply_symm_apply] using hback.comp hm + have ht := congrArg (Measure.map g) hlaw + rw [Measure.map_map hg hgroup] at ht + exact ht.trans (retained_density_flatten I μ _) + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +section + +variable {W T Q Z X K α : Type*} [MeasurableSpace W] [MeasurableSpace T] [Fintype Q] + [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) + (ν : Measure T) [IsProbabilityMeasure ν] (z : W → T → Z → ℝ) (x : W → T → X → ℝ) + (hz : ∀ j, Measurable (fun p : W × T => z p.1 p.2 j)) + (hx : ∀ j, Measurable (fun p : W × T => x p.1 p.2 j)) + (hw : ∀ q j, 0 < w q j) (R : Q → ℝ≥0) (hsupport : ∀ q j, |c q j|+w q j ≤ R q) + +include hz hx hw hsupport in +theorem flatAffineMixtureDensity_probability (a : W) : + (∀ v, 0 ≤ flatAffineMixtureDensity s A F e input rows c w ν z x a v) ∧ + Integrable (flatAffineMixtureDensity s A F e input rows c w ν z x a) ∧ + (∫ v, flatAffineMixtureDensity s A F e input rows c w ν z x a v) = 1 := by + let D := fun t => jointAffineJetDensity s A F e input (z a t) rows c w (x a t) + have hm : Measurable (Function.uncurry D) := + jointAffineJetDensity_measurable_comp (Ω := T × (∀ q, I q → ℝ)) s A F e input rows c w hw R hsupport + (fun p => z a p.1) (fun j => (hz j).comp (measurable_const.prodMk measurable_fst)) + (fun p => x a p.1) (fun j => (hx j).comp (measurable_const.prodMk measurable_fst)) + (fun p => p.2) (fun q i => (measurable_pi_apply i).comp ((measurable_pi_apply q).comp measurable_snd)) + have hp := densityMixture_probability_density ν volume D hm (Filter.Eventually.of_forall (fun t => by + have ht := jointAffineJetDensity_probability_data s A F e input (z a t) rows c w hw R hsupport (x a t) + exact ⟨ht.2.1, ht.1, ht.2.2⟩)) + refine ⟨fun v => hp.1 _, (sigmaAxisCoordinates_measurePreserving I).integrable_comp_of_integrable hp.2.1, ?_⟩ + exact ((sigmaAxisCoordinates_measurePreserving I).integral_comp + (sigmaAxisCoordinates I).toHomeomorph.toMeasurableEquiv.measurableEmbedding _).trans hp.2.2 + +include hz hx hw hsupport in +theorem flatAffineMixtureDensity_bounds (a : W) + (δ : Q → ℝ≥0) (hδ : ∀ q, 0 < δ q) (hwidth : ∀ q j, (δ q : ℝ) ≤ w q (.inl j)) + (Cap Lip : ℝ≥0) (hCap : 1 ≤ Cap) + (hcap : ∀ q, pivotKernelCap (UnselectedColumn (s q)) (A q) (R q) ((δ q)⁻¹^Fintype.card (J q)) ≤ Cap) + (hlip : ∀ q, pivotKernelLip (UnselectedColumn (s q)) (A q) (R q) (affineProductProfileLip (J q) (δ q)) ≤ Lip) : + (∀ v, flatAffineMixtureDensity s A F e input rows c w ν z x a v ∈ Set.Icc (0 : ℝ) ((Cap : ℝ)^Fintype.card Q)) ∧ + LipschitzWith (Fintype.card Q*Lip*Cap^Fintype.card Q) + (flatAffineMixtureDensity s A F e input rows c w ν z x a) := by + have ht := jointAffineJetDensity_mixture_spec s A F e input rows c w hw R hsupport ν + (z a) (fun j => (hz j).comp (measurable_const.prodMk measurable_id)) + (x a) (fun j => (hx j).comp (measurable_const.prodMk measurable_id)) δ hδ hwidth Cap Lip hCap hcap hlip + refine ⟨fun v => ht.1 _, ?_⟩ + change LipschitzWith (Fintype.card Q*Lip*Cap^Fintype.card Q) + ((densityMixture ν (fun t => jointAffineJetDensity s A F e input (z a t) rows c w (x a t))) ∘ sigmaAxisCoordinates I) + simpa only [mul_one] using ht.2.1.comp (sigmaAxisCoordinates_lipschitz I) + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem canonicalAffineRawArray_retained_test {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] + [Fintype α] [DecidableEq α] {B O J N : D → Type*} + [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (sets : ∀ d, O d → Finset α) + (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) (T : SamplerTupleIndex G B h → ℝ) (hT : ∀ k, 0 < T k) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (extra : G → Option α → Z) (z : W → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (hkernel : ∀ a x d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) (z a) x) (sets d)) + (c w : ∀ d, J d ⊕ N d → ℝ) (hw : ∀ d j, 0 < w d j) + (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (μ : Measure W) [IsProbabilityMeasure μ] + (φ : W × ((Σ d, O d) → ℝ) → ℝ) (hφ : Measurable φ) : + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + (∫ p, φ (p.1.1, canonicalAffineRawArray h (fun d => Sum.elim (eK d) (eN d)) Q T c w p.1.2 sets + (rawCanonicalCubeTuple extra T (z p.1.1) p.2)) + ∂(μ.prod (jointUnitCoefficientSource J N)).prod (scaledJointCubeSource h (fun i => T (.inr i)))) = + ∫ p, flatAffineMixtureDensity s E F eN (canonicalTupleInput extra) sets c w (jointBooleanSource h) + (fun a _ => z a) (fun _ x => x) p.1 p.2*φ p ∂μ.prod volume := by + dsimp only + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + have hz' (j) : Measurable (fun p : W × (JointBlockParameter B h α → ℝ) => z p.1 j) := + (hz j).comp measurable_fst + have hx' (j) : Measurable (fun p : W × (JointBlockParameter B h α → ℝ) => p.2 j) := + (measurable_pi_apply j).comp measurable_snd + rw [scaledJointCubeSource_prod_integral h _ (fun i => hT (.inr i))] + have heval (p : (W × (∀ d, J d ⊕ N d → ℝ)) × (JointBlockParameter B h α → ℝ)) := + canonicalAffineRawArray_eq_jointUnitMap h hh sets M s hM S hS Q hQ T (fun k => (hT k).ne') eK eN + extra (z p.1.1) p.2 (hkernel p.1.1 p.2) c w p.1.2 + simp_rw [heval] + have hp (a) := flatAffineMixtureDensity_probability s E F eN (canonicalTupleInput extra) sets c w + (jointBooleanSource h) (fun a _ => z a) (fun _ x => x) hz' hx' hw R hsupport a + exact mappedTest_eq_density ((μ.prod (jointUnitCoefficientSource J N)).prod (jointBooleanSource h)) + (μ.prod volume) (flatAffineUnitSource s E F eN (canonicalTupleInput extra) sets c w (fun a _ => z a) (fun _ x => x)) + (flatAffineUnitSource_measurable s E F eN (canonicalTupleInput extra) sets c w (fun a _ => z a) (fun _ x => x) hz' hx') _ + (flatAffineMixtureDensity_measurable s E F eN (canonicalTupleInput extra) sets c w + (jointBooleanSource h) (fun a _ => z a) (fun _ x => x) hz' hx' hw R hsupport) + (fun p => (hp p.1).1 p.2) + (flatAffineMixtureDensity_image_law s E F eN (canonicalTupleInput extra) sets c w + (jointBooleanSource h) (fun a _ => z a) (fun _ x => x) hz' hx' hw R hsupport μ) φ hφ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +section + +variable {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (t : ℝ) (z : W → Z → ℝ) + +noncomputable def smallAffineMixtureDensity (a : W) (v : (Σ d, O d) → ℝ) : ℝ := + flatAffineMixtureDensity s A F eN (canonicalTupleInput extra) sets + (fun d j => nonprincipalDilation (Sum.elim (eK d) (eN d)) (canonicalPrincipalExponent h d) t j*c d j) + (fun d j => nonprincipalDilation (Sum.elim (eK d) (eN d)) (canonicalPrincipalExponent h d) t j*w d j) + (jointBooleanSource h) (fun a _ => z a) (fun _ x => x) a v + +variable (hz : ∀ j, Measurable (fun a => z a j)) (ht : 0 < t) (ht1 : t ≤ 1) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + +include hz ht ht1 hw hsupport in +theorem smallAffineMixtureDensity_measurable : + Measurable (Function.uncurry (smallAffineMixtureDensity h eK eN s A F sets extra c w t z)) := by + apply flatAffineMixtureDensity_measurable s A F eN (canonicalTupleInput extra) sets _ _ + (jointBooleanSource h) (fun a _ => z a) (fun _ x => x) + (fun j => (hz j).comp measurable_fst) (fun j => (measurable_pi_apply j).comp measurable_snd) + _ R _ + · exact fun d j => nonprincipalDilation_width_pos _ _ ht (w d) (hw d) j + · exact fun d j => nonprincipalDilation_profile_support _ _ ht ht1 (c d) (w d) + (fun j => (hw d j).le) (hsupport d) j + +include hz ht ht1 hw hsupport in +theorem smallAffineMixtureDensity_probability (a : W) : + (∀ v, 0 ≤ smallAffineMixtureDensity h eK eN s A F sets extra c w t z a v) ∧ + Integrable (smallAffineMixtureDensity h eK eN s A F sets extra c w t z a) ∧ + (∫ v, smallAffineMixtureDensity h eK eN s A F sets extra c w t z a v) = 1 := by + apply flatAffineMixtureDensity_probability s A F eN (canonicalTupleInput extra) sets _ _ + (jointBooleanSource h) (fun a _ => z a) (fun _ x => x) + (fun j => (hz j).comp measurable_fst) (fun j => (measurable_pi_apply j).comp measurable_snd) + _ R _ a + · exact fun d j => nonprincipalDilation_width_pos _ _ ht (w d) (hw d) j + · exact fun d j => nonprincipalDilation_profile_support _ _ ht ht1 (c d) (w d) + (fun j => (hw d j).le) (hsupport d) j + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +section + +variable {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (z : W → Z → ℝ) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + +include hw hsupport in +theorem smallAffineMixtureDensity_bounds + (hz : ∀ j, Measurable (fun a => z a j)) + (t : ℝ≥0) (ht : 0 < t) (ht1 : t ≤ 1) (a : W) + (δ : D → ℝ≥0) (hδ : ∀ d, 0 < δ d) (hwidth : ∀ d j, (δ d : ℝ) ≤ w d j) + (Cap Lip : ℝ≥0) (hCap : 1 ≤ Cap) + (hcap : ∀ d, pivotKernelCap (UnselectedColumn (s d)) (A d) (R d) + ((t*δ d)⁻¹^Fintype.card (J d)) ≤ Cap) + (hlip : ∀ d, pivotKernelLip (UnselectedColumn (s d)) (A d) (R d) + (affineProductProfileLip (J d) (t*δ d)) ≤ Lip) : + (∀ v, smallAffineMixtureDensity h eK eN s A F sets extra c w t z a v ∈ + Set.Icc (0 : ℝ) ((Cap : ℝ)^Fintype.card D)) ∧ + LipschitzWith (Fintype.card D*Lip*Cap^Fintype.card D) + (smallAffineMixtureDensity h eK eN s A F sets extra c w t z a) := by + apply flatAffineMixtureDensity_bounds s A F eN (canonicalTupleInput extra) sets _ _ + (jointBooleanSource h) (fun a _ => z a) (fun _ x => x) + (fun j => (hz j).comp measurable_fst) (fun j => (measurable_pi_apply j).comp measurable_snd) + _ R _ a (fun d => t*δ d) (fun d => mul_pos ht (hδ d)) _ Cap Lip hCap hcap hlip + · exact fun d j => nonprincipalDilation_width_pos _ _ ht (w d) (hw d) j + · exact fun d j => nonprincipalDilation_profile_support _ _ ht ht1 (c d) (w d) + (fun j => (hw d j).le) (hsupport d) j + · exact fun d j => nonprincipalDilation_width_lower _ _ ht.le ht1 (w d) + (fun j => (hw d j).le) (hwidth d) (.inl j) + +omit [MeasurableSpace W] in +include hw hsupport in +theorem smallAffineMixtureDensity_support + (t : ℝ) (ht : 0 < t) (ht1 : t ≤ 1) (a : W) (hz : ∀ j, |z a j| ≤ 1) + (degree : D → ℕ) (hd : ∀ d n, (eN d n).sum (fun _ k => k) ≤ degree d) + (Ro : ℝ≥0) (hRo : ∀ d, normalizedJetOutputRadius α (N d) (A d) (F d) + (degree d) (R d) (R d) ≤ Ro) : + ∀ v, (Ro : ℝ) < ‖v‖ → smallAffineMixtureDensity h eK eN s A F sets extra c w t z a v = 0 := by + intro v hv + apply jointAffineJetDensity_mixture_support s A F eN (canonicalTupleInput extra) sets _ _ + (fun d j => nonprincipalDilation_width_pos _ _ ht (w d) (hw d) j) R + (fun d j => nonprincipalDilation_profile_support _ _ ht ht1 (c d) (w d) + (fun j => (hw d j).le) (hsupport d) j) + (jointBooleanSource h) (fun _ => z a) (fun x => x) _ degree hd Ro hRo (sigmaAxisCoordinates O v) _ + · filter_upwards [jointBooleanSource_ae_closedBall B h] with x hx + exact ⟨hz, by simpa only [Metric.mem_closedBall, dist_zero_right] using hx⟩ + · simpa only [sigmaAxisCoordinates_norm] using hv + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem smallAffineMixtureDensity_test {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] + [Fintype α] [DecidableEq α] {B O J N : D → Type*} + [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (sets : ∀ d, O d → Finset α) + (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) (T : SamplerTupleIndex G B h → ℝ) (hT : ∀ k, 0 < T k) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (extra : G → Option α → Z) (z : W → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (hkernel : ∀ a x d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) (z a) x) (sets d)) + (c w : ∀ d, J d ⊕ N d → ℝ) (hw : ∀ d j, 0 < w d j) + (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (t : ℝ) (ht : 0 < t) (ht1 : t ≤ 1) (μ : Measure W) [IsProbabilityMeasure μ] + (φ : W × ((Σ d, O d) → ℝ) → ℝ) (hφ : Measurable φ) : + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + (∫ p, φ (p.1.1, smallAffineSourceOutput h (fun d => Sum.elim (eK d) (eN d)) c w sets extra + (fun _ => Q) T t (fun a => z a.1) (fun a => a.2) p) + ∂(μ.prod (jointUnitCoefficientSource J N)).prod (scaledJointCubeSource h (fun i => T (.inr i)))) = + ∫ p, smallAffineMixtureDensity h eK eN s E F sets extra c w t z p.1 p.2*φ p ∂μ.prod volume := by + dsimp only + exact canonicalAffineRawArray_retained_test h hh sets M s hM S hS Q hQ T hT eK eN extra z hz hkernel + (fun d j => nonprincipalDilation (Sum.elim (eK d) (eN d)) (canonicalPrincipalExponent h d) t j*c d j) + (fun d j => nonprincipalDilation (Sum.elim (eK d) (eN d)) (canonicalPrincipalExponent h d) t j*w d j) + (fun d j => nonprincipalDilation_width_pos _ _ ht (w d) (hw d) j) R + (fun d j => nonprincipalDilation_profile_support _ _ ht ht1 (c d) (w d) (fun j => (hw d j).le) (hsupport d) j) + μ φ hφ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem smallAffineMixtureDensity_log_bounds + {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (z : W → Z → ℝ) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (hz : ∀ j, Measurable (fun a => z a j)) (t : ℝ≥0) (ht : 0 < t) (ht1 : t ≤ 1) + (δ : D → ℝ≥0) (hδ : ∀ d, 0 < δ d) (hwidth : ∀ d j, (δ d : ℝ) ≤ w d j) + {P T : ℝ} (hP : 0 ≤ P) (hT : 0 ≤ T) + (hA : ∀ d, ‖(A d).symm.toContinuousLinearMap‖ ≤ Real.exp P) + (hR : ∀ d, (R d : ℝ) ≤ Real.exp P) + (htT : (t : ℝ)⁻¹ ≤ Real.exp T) (hδP : ∀ d, (δ d : ℝ)⁻¹ ≤ Real.exp P) (a : W) : + let b := jointPivotProfileLog s P T + (∀ v, smallAffineMixtureDensity h eK eN s A F sets extra c w t z a v ∈ + Set.Icc (0 : ℝ) (Real.exp (Fintype.card D*b))) ∧ + LipschitzWith ⟨Real.exp (Fintype.card D+(Fintype.card D+1)*b), Real.exp_nonneg _⟩ + (smallAffineMixtureDensity h eK eN s A F sets extra c w t z a) := by + let b := jointPivotProfileLog s P T + let C : ℝ≥0 := ⟨Real.exp b, Real.exp_nonneg _⟩ + obtain ⟨hC, hbounds⟩ := jointPivotProfile_regularity s A R δ t ht hδ hP hT hA hR htT hδP + have hs := smallAffineMixtureDensity_bounds h eK eN s A F sets extra c w z hw R hsupport + hz t ht ht1 a δ hδ hwidth C C hC (fun d => (hbounds d).1) (fun d => (hbounds d).2) + dsimp only + constructor + · intro v + refine ⟨(hs.1 v).1, (hs.1 v).2.trans_eq ?_⟩ + exact (Real.exp_nat_mul b (Fintype.card D)).symm + · apply hs.2.weaken + change (Fintype.card D : ℝ)*Real.exp b*(Real.exp b)^Fintype.card D ≤ _ + exact jointDensityLip_le_exp _ b + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff NNReal BigOperators + +theorem exists_averaged_regularized_affine_l1_with_parameters + {W D G Z α : Type*} [MeasurableSpace W] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (Sum.elim (eK d) (eN d))) + (index : ∀ d, B d → J d ⊕ N d) + (hindex : ∀ d b, Sum.elim (eK d) (eN d) (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d ⊕ N d → ℝ) (hw : ∀ d j, 0 < w d j) + (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (z : W → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A L : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith L Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (Sum.elim (eK d) (eN d) j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) : + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ) = booleanRegularizationRadius (B := B) (O := O) (α := α) h c₀ C A L (ε/2) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = booleanPerturbationScale (B := B) (O := O) (α := α) (AffineAuxiliaryIndex Z (fun d => J d ⊕ N d)) h c₀ C A L degree Csum Wsum (ε/2) ∧ + ∀ (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) + (T : SamplerTupleIndex G B h → ℝ), (∀ k, 0 < T k) → + (∀ a x d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) (z a) x) (sets d)) → + ∀ μ : Measure W, IsProbabilityMeasure μ → (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + (∫ p : W × ((Σ d, O d) → ℝ), + |averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets δ p.2 - + smallAffineMixtureDensity h eK eN s E F sets extra c w t z p.1 p.2| ∂μ.prod volume) ≤ ε := by + let e := fun d => Sum.elim (eK d) (eN d) + have hr : ∀ d j, Measurable (fun p : W × (∀ d, J d ⊕ N d → ℝ) => p.2 d j) := + fun d j => (measurable_pi_apply j).comp ((measurable_pi_apply d).comp measurable_snd) + obtain ⟨δ, hδ, hδ1, hδeq, t, ht, ht1, hteq, hcomp⟩ := exists_regularized_affine_comparison_with_parameters + (Ω := W × (∀ d, J d ⊕ N d → ℝ)) (Y := W × ((Σ d, O d) → ℝ)) + h hh e he index hindex c w (fun p => p.2) hr + (fun p => z p.1) (fun j => (hz j).comp measurable_fst) sets hsets hcard block hblock + c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A L hLip hTransition extra + hdegree htaildegree hCsum hWsum hcsum hwsum hε + refine ⟨δ, hδ, hδ1, hδeq, t, ht, ht1, hteq, ?_⟩ + intro M s hM S hS Q hQ T hT hkernel μ hμ hzb + let : IsProbabilityMeasure μ := hμ + dsimp only + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + let g := smallAffineMixtureDensity h eK eN s E F sets extra c w t z + have hgm : Measurable (Function.uncurry g) := + smallAffineMixtureDensity_measurable h eK eN s E F sets extra c w t z hz ht ht1 hw R hsupport + have hgp := smallAffineMixtureDensity_probability h eK eN s E F sets extra c w t z hz ht ht1 hw R hsupport + have hgi : Integrable (Function.uncurry g) (μ.prod volume) := + densityMixture_joint_integrable μ volume g hgm (Filter.Eventually.of_forall hgp) + apply coefficientAverage_density_l1 μ (jointUnitCoefficientSource J N) + (scaledJointCubeSource h (fun i => T (.inr i))) volume + (regularizedAffineIdealDensity h e index c w sets δ) + (regularizedAffineIdealDensity_joint_measurable h e index c w sets δ) + (regularizedAffineIdealDensity_probability h e index c w sets δ hδ) + (Function.uncurry g) hgm hgi + (fun p => (p.1.1, smallAffineSourceOutput h e c w sets extra (fun _ => Q) T t + (fun a => z a.1) (fun a => a.2) p)) + · intro φ hφ _ + exact smallAffineMixtureDensity_test h hh sets M s hM S hS Q hQ T hT eK eN extra z hz hkernel + c w hw R hsupport t ht ht1 μ φ hφ + · intro φ hφ hbound + exact hcomp (fun _ => Q) T (fun _ d => (hQ d).ne') hT (μ.prod (jointUnitCoefficientSource J N)) + inferInstance (Measure.quasiMeasurePreserving_fst.ae hzb) + (Measure.quasiMeasurePreserving_snd.ae (jointUnitCoefficientSource_abs_le J N)) + (fun p => (p.1.1, p.2)) (measurable_fst.fst.prodMk measurable_snd) φ hφ hbound + +theorem exists_averaged_regularized_affine_l1 + {W D G Z α : Type*} [MeasurableSpace W] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (Sum.elim (eK d) (eN d))) + (index : ∀ d, B d → J d ⊕ N d) + (hindex : ∀ d b, Sum.elim (eK d) (eN d) (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d ⊕ N d → ℝ) (hw : ∀ d j, 0 < w d j) + (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (z : W → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A L : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith L Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (Sum.elim (eK d) (eN d) j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) : + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ∀ (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) + (T : SamplerTupleIndex G B h → ℝ), (∀ k, 0 < T k) → + (∀ a x d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) (z a) x) (sets d)) → + ∀ μ : Measure W, IsProbabilityMeasure μ → (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + (∫ p : W × ((Σ d, O d) → ℝ), + |averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets δ p.2 - + smallAffineMixtureDensity h eK eN s E F sets extra c w t z p.1 p.2| ∂μ.prod volume) ≤ ε := by + obtain ⟨δ, hδ, hδ1, _, t, ht, ht1, _, herr⟩ := exists_averaged_regularized_affine_l1_with_parameters h hh eK eN he index hindex c w hw R hsupport z hz sets hsets hcard block hblock + c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A L hLip hTransition extra + hdegree htaildegree hCsum hWsum hcsum hwsum hε + exact ⟨δ, hδ, hδ1, t, ht, ht1, herr⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem averagedAffine_density_data + {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → J d ⊕ N d) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (z : W → Z → ℝ) + (hz : ∀ j, Measurable (fun a => z a j)) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (t : ℝ≥0) (ht : 0 < t) (ht1 : t ≤ 1) + (δ : D → ℝ≥0) (hδ : ∀ d, 0 < δ d) (hwidth : ∀ d j, (δ d : ℝ) ≤ w d j) + (Cap Lip : ℝ≥0) (hCap : 1 ≤ Cap) + (hcap : ∀ d, pivotKernelCap (UnselectedColumn (s d)) (A d) (R d) + ((t*δ d)⁻¹^Fintype.card (J d)) ≤ Cap) + (hlip : ∀ d, pivotKernelLip (UnselectedColumn (s d)) (A d) (R d) + (affineProductProfileLip (J d) (t*δ d)) ≤ Lip) + (degree : D → ℕ) (hd : ∀ d n, (eN d n).sum (fun _ k => k) ≤ degree d) + (Ro : ℝ≥0) (hRo : ∀ d, normalizedJetOutputRadius α (N d) (A d) (F d) + (degree d) (R d) (R d) ≤ Ro) + (η : ℝ≥0) (hη : 0 < η) {Csum Wsum Ri : ℝ} (hRi : 0 ≤ Ri) (hRiRo : Ri+η ≤ Ro) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, (|c d j|+|w d j|)) ≤ Wsum) + (hideal : ∀ d o, Wsum+(2 : ℝ)^(sets d o).card*(Csum*((Fintype.card α : ℝ)+1)^h d) ≤ Ri) + (μ : Measure W) [IsProbabilityMeasure μ] (hzbox : ∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) : + let f := averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η + let g := smallAffineMixtureDensity h eK eN s A F sets extra c w t z + Integrable (fun p : W × ((Σ d, O d) → ℝ) => f p.2-g p.1 p.2) (μ.prod volume) ∧ + (∀ᵐ a ∂μ, LipschitzWith (affineProductProfileLip (Σ d, O d) η) f ∧ + LipschitzWith (Fintype.card D*Lip*Cap^Fintype.card D) (g a) ∧ + (∀ v, (Ro : ℝ) < ‖v‖ → f v = 0) ∧ (∀ v, (Ro : ℝ) < ‖v‖ → g a v = 0)) := by + dsimp only + let f := averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η + let g := smallAffineMixtureDensity h eK eN s A F sets extra c w t z + have hf := averagedRegularizedIdeal_spec h (fun d => Sum.elim (eK d) (eN d)) index c w sets η hη + have hg := smallAffineMixtureDensity_bounds h eK eN s A F sets extra c w z hw R hsupport + hz t ht ht1 + have hfi : Integrable (fun p : W × ((Σ d, O d) → ℝ) => f p.2) (μ.prod volume) := hf.2.2.1.comp_snd μ + have hgi : Integrable (Function.uncurry g) (μ.prod volume) := + densityMixture_joint_integrable μ volume g + (smallAffineMixtureDensity_measurable h eK eN s A F sets extra c w t z hz ht ht1 hw R hsupport) + (Filter.Eventually.of_forall + (smallAffineMixtureDensity_probability h eK eN s A F sets extra c w t z hz ht ht1 hw R hsupport)) + have hfs : ∀ w v, (Ro : ℝ) < ‖v‖ → (fun _ : W => f) w v = 0 := by + intro _ v hv + exact averagedRegularizedIdeal_support h (fun d => Sum.elim (eK d) (eN d)) index c w sets η hη + hRi hcsum hwsum hideal v (lt_of_le_of_lt hRiRo hv) + have hgood : ∀ᵐ a ∂μ, LipschitzWith (affineProductProfileLip (Σ d, O d) η) f ∧ + LipschitzWith (Fintype.card D*Lip*Cap^Fintype.card D) (g a) ∧ + (∀ v, (Ro : ℝ) < ‖v‖ → f v = 0) ∧ (∀ v, (Ro : ℝ) < ‖v‖ → g a v = 0) := by + filter_upwards [hzbox] with a ha + exact ⟨hf.2.1, (hg a δ hδ hwidth Cap Lip hCap hcap hlip).2, hfs a, + smallAffineMixtureDensity_support h eK eN s A F sets extra c w z hw R hsupport + t ht ht1 a ha degree hd Ro hRo⟩ + exact ⟨hfi.sub hgi, hgood⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal ContDiff BigOperators + +theorem exists_averaged_affine_l1_with_parameter_bounds + {W D G Z α : Type*} [MeasurableSpace W] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (Sum.elim (eK d) (eN d))) + (index : ∀ d, B d → J d ⊕ N d) + (hindex : ∀ d b, Sum.elim (eK d) (eN d) (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d ⊕ N d → ℝ) (hw : ∀ d j, 0 < w d j) + (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (z : W → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A L : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith L Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (Sum.elim (eK d) (eN d) j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) {P : ℝ} (hP : 0 ≤ P) + (hNoise : (jointBooleanRegularizationBudget (B := B) (O := O) (α := α) h c₀ C A L + (fun _ => (ε/2)/(4*((Fintype.card D : ℝ)+1))) : ℝ) ≤ Real.exp P) + (hm : (Fintype.card (Σ d, O d) : ℝ) ≤ Real.exp P) + (hK : (jointBooleanInverseBudget (O := O) (α := α) h C + (booleanToleranceMinor (O := O) (α := α) h c₀ (ε/2)) : ℝ) ≤ Real.exp P) + (hM : booleanToleranceC2 (B := B) (α := α) (AffineAuxiliaryIndex Z (fun d => J d ⊕ N d)) + h degree Csum Wsum ≤ Real.exp P) + (hQbudget : booleanToleranceDivergence (B := B) (O := O) (α := α) h c₀ C A L (ε/2) ≤ Real.exp P) + (hAccuracy : (ε/4)⁻¹ ≤ Real.exp P) : + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ)⁻¹ ≤ Real.exp (2*P+2) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t⁻¹ ≤ Real.exp (6*P+8) ∧ + ∀ (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) + (T : SamplerTupleIndex G B h → ℝ), (∀ k, 0 < T k) → + (∀ a x d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) (z a) x) (sets d)) → + ∀ μ : Measure W, IsProbabilityMeasure μ → (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + (∫ p : W × ((Σ d, O d) → ℝ), + |averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets δ p.2 - + smallAffineMixtureDensity h eK eN s E F sets extra c w t z p.1 p.2| ∂μ.prod volume) ≤ ε := by + obtain ⟨δ, hδ, hδ1, hδeq, t, ht, ht1, hteq, herr⟩ := + exists_averaged_regularized_affine_l1_with_parameters + h hh eK eN he index hindex c w hw R hsupport z hz sets hsets hcard block hblock + c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A L hLip hTransition extra + hdegree htaildegree hCsum hWsum hcsum hwsum hε + have hhalf : (ε/2)⁻¹ ≤ Real.exp P := by + apply le_trans _ hAccuracy + simpa only [one_div] using + one_div_le_one_div_of_le (show 0 < ε/4 by positivity) (show ε/4 ≤ ε/2 by linarith) + have hquarter : ((ε/2)/2)⁻¹ ≤ Real.exp P := by + have heq : (ε/2)/2 = ε/4 := by ring + simpa only [heq] using hAccuracy + refine ⟨δ, hδ, hδ1, ?_, t, ht, ht1, ?_, herr⟩ + · rw [hδeq] + exact booleanRegularizationRadius_inverse_le_exp h c₀ C A L (half_pos hε) hP hNoise hhalf + · rw [hteq] + exact booleanPerturbationScale_inverse_le_exp (AffineAuxiliaryIndex Z (fun d => J d ⊕ N d)) + h hh c₀ C hc₀ hC A L degree hCsum hWsum (half_pos hε) hP hm hK hM hQbudget hquarter + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem averagedAffine_grid_error + {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → J d ⊕ N d) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (z : W → Z → ℝ) + (hz : ∀ j, Measurable (fun a => z a j)) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (t : ℝ≥0) (ht : 0 < t) (ht1 : t ≤ 1) + (δ : D → ℝ≥0) (hδ : ∀ d, 0 < δ d) (hwidth : ∀ d j, (δ d : ℝ) ≤ w d j) + (Cap Lip : ℝ≥0) (hCap : 1 ≤ Cap) + (hcap : ∀ d, pivotKernelCap (UnselectedColumn (s d)) (A d) (R d) + ((t*δ d)⁻¹^Fintype.card (J d)) ≤ Cap) + (hlip : ∀ d, pivotKernelLip (UnselectedColumn (s d)) (A d) (R d) + (affineProductProfileLip (J d) (t*δ d)) ≤ Lip) + (degree : D → ℕ) (hd : ∀ d n, (eN d n).sum (fun _ k => k) ≤ degree d) + (Ro : ℝ≥0) (hRo : ∀ d, normalizedJetOutputRadius α (N d) (A d) (F d) + (degree d) (R d) (R d) ≤ Ro) + (η : ℝ≥0) (hη : 0 < η) {Csum Wsum Ri : ℝ} (hRi : 0 ≤ Ri) (hRiRo : Ri+η ≤ Ro) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, (|c d j|+|w d j|)) ≤ Wsum) + (hideal : ∀ d o, Wsum+(2 : ℝ)^(sets d o).card*(Csum*((Fintype.card α : ℝ)+1)^h d) ≤ Ri) + (μ : Measure W) [IsProbabilityMeasure μ] (hzbox : ∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) {ε : ℝ} + (he : (∫ p : W × ((Σ d, O d) → ℝ), + |averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η p.2 - + smallAffineMixtureDensity h eK eN s A F sets extra c w t z p.1 p.2| ∂μ.prod volume) ≤ ε) + (a S : (Σ d, O d) → ℝ) (hS : ∀ j, 0 < S j) {mesh M : ℝ} + (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) (hmesh : ∀ j, 1/S j ≤ mesh) + (grid : Finset ((Σ d, O d) → ℤ)) (mask : W → ((Σ d, O d) → ℤ) → ℝ) + (φ : W → ((Σ d, O d) → ℤ) → ℂ) + (hM : 0 ≤ M) (hmask : ∀ w k, k ∈ grid → |mask w k| ≤ M) + (hφ : ∀ w k, k ∈ grid → ‖φ w k‖ ≤ 1) : + let f := averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η + let g := smallAffineMixtureDensity h eK eN s A F sets extra c w t z + ‖∫ w, gridDensityTest f a S grid (mask w) (φ w)-gridDensityTest (g w) a S grid (mask w) (φ w) ∂μ‖ ≤ + M*(ε+(2*(Ro : ℝ)+2)^Fintype.card (Σ d, O d)* + ((affineProductProfileLip (Σ d, O d) η : ℝ)+(Fintype.card D*Lip*Cap^Fintype.card D : ℝ≥0))*mesh) := by + dsimp only + obtain ⟨hi, hgood⟩ := averagedAffine_density_data h eK eN index s A F sets extra c w z hz hw R hsupport + t ht ht1 δ hδ hwidth Cap Lip hCap hcap hlip degree hd Ro hRo η hη hRi hRiRo + hcsum hwsum hideal μ hzbox + simpa only [probReal_univ, one_mul] using + partial_gridDensityTest_error_ae μ + (fun _ => averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η) + (smallAffineMixtureDensity h eK eN s A F sets extra c w t z) + a S hS Ro.coe_nonneg hmesh0 hmesh1 hmesh hgood grid mask φ hM hmask hφ hi he + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineLogMixedGrid.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineLogMixedGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5b1621c7d195e65914f651b3fac30bebcb21090 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineLogMixedGrid.lean @@ -0,0 +1,339 @@ +import OAI.Combinatorics.Progressions.Lattices.AveragedAffineGrid +import OAI.Combinatorics.Progressions.Sampling.MixedGridBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +def idealOutputLog (q degree : ℕ) (P : ℝ) : ℝ := 2*P+q+(degree : ℝ)*q+1 + +theorem idealOutputLog_nonneg (q degree : ℕ) {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ idealOutputLog q degree P := by unfold idealOutputLog; positivity + +theorem idealOutputBound_le_exp {α : Type*} [Fintype α] (a : Finset α) + {h degree : ℕ} (hh : h ≤ degree) {C W P : ℝ} + (hC : 0 ≤ C) (hP : 0 ≤ P) (hCP : C ≤ Real.exp P) (hWP : W ≤ Real.exp P) : + W+(2 : ℝ)^a.card*(C*((Fintype.card α : ℝ)+1)^h) ≤ + Real.exp (idealOutputLog (Fintype.card α) degree P) := by + have hc : a.card ≤ Fintype.card α := Finset.card_le_univ a + have hb : (2 : ℝ)^a.card*(C*((Fintype.card α : ℝ)+1)^h) ≤ + booleanJetMassBudget (Fintype.card α) degree C := by + unfold booleanJetMassBudget + gcongr + · norm_num + · linarith [Nat.cast_nonneg (α := ℝ) (Fintype.card α)] + have hm := booleanJetMassBudget_le_exp (Fintype.card α) degree hC hCP + have hs := add_le_exp_add_one hP + (show 0 ≤ booleanJetMassLog (Fintype.card α) degree P by unfold booleanJetMassLog; positivity) + hWP (hb.trans hm) + apply hs.trans_eq + congr 1 + unfold idealOutputLog booleanJetMassLog + ring + +noncomputable def commonAffineOutputLog {D α : Type*} [Fintype D] [Fintype α] + (N : D → Type*) [∀ d, Fintype (N d)] (degree : ℕ) (P : ℝ) : ℝ := + (∑ d, jetOutputRadiusLog (Fintype.card α) (Fintype.card (N d)) degree P)+ + idealOutputLog (Fintype.card α) degree P+1 + +theorem commonAffineOutputLog_nonneg {D α : Type*} [Fintype D] [Fintype α] + (N : D → Type*) [∀ d, Fintype (N d)] (degree : ℕ) {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ commonAffineOutputLog (α := α) N degree P := by + have hs : 0 ≤ ∑ d, jetOutputRadiusLog (Fintype.card α) (Fintype.card (N d)) degree P := + Finset.sum_nonneg (fun d _ => jetOutputRadiusLog_nonneg _ _ _ hP) + have hi := idealOutputLog_nonneg (Fintype.card α) degree hP + unfold commonAffineOutputLog + linarith + +theorem commonAffineOutputLog_radius {D α : Type*} [Fintype D] [Fintype α] + (N : D → Type*) [∀ d, Fintype (N d)] {I J : Type*} [Fintype I] [Fintype J] + (d : D) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (F : (J → ℝ) →L[ℝ] (I → ℝ)) + (degree : ℕ) (R S : ℝ≥0) {P : ℝ} (hP : 0 ≤ P) + (hA : ‖A.toContinuousLinearMap‖ ≤ Real.exp P) (hF : ‖F‖ ≤ Real.exp P) + (hR : (R : ℝ) ≤ Real.exp P) (hS : (S : ℝ) ≤ Real.exp P) : + (normalizedJetOutputRadius α (N d) A F degree R S : ℝ) ≤ + Real.exp (commonAffineOutputLog (α := α) N degree P) := by + apply (normalizedJetOutputRadius_le_exp α (N d) A F degree R S hP hA hF hR hS).trans + apply Real.exp_le_exp.mpr + have hs := Finset.single_le_sum (s := Finset.univ) + (f := fun d => jetOutputRadiusLog (Fintype.card α) (Fintype.card (N d)) degree P) + (fun d _ => jetOutputRadiusLog_nonneg _ _ _ hP) (Finset.mem_univ d) + have hi := idealOutputLog_nonneg (Fintype.card α) degree hP + unfold commonAffineOutputLog + linarith + +theorem commonAffineOutputLog_ideal {D α : Type*} [Fintype D] [Fintype α] + (N : D → Type*) [∀ d, Fintype (N d)] (degree : ℕ) {P η : ℝ} + (hP : 0 ≤ P) (hη : η ≤ 1) : + Real.exp (idealOutputLog (Fintype.card α) degree P)+η ≤ + Real.exp (commonAffineOutputLog (α := α) N degree P) := by + have hs : 0 ≤ ∑ d, jetOutputRadiusLog (Fintype.card α) (Fintype.card (N d)) degree P := + Finset.sum_nonneg (fun d _ => jetOutputRadiusLog_nonneg _ _ _ hP) + calc + _ ≤ 1+Real.exp (idealOutputLog (Fintype.card α) degree P) := by linarith + _ ≤ Real.exp (idealOutputLog (Fintype.card α) degree P+1) := + one_add_le_exp_succ (idealOutputLog_nonneg _ _ hP) le_rfl + _ ≤ _ := by apply Real.exp_le_exp.mpr; unfold commonAffineOutputLog; linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem averagedAffine_log_density_data + {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → J d ⊕ N d) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (z : W → Z → ℝ) + (hz : ∀ j, Measurable (fun a => z a j)) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (t : ℝ≥0) (ht : 0 < t) (ht1 : t ≤ 1) + (δ : D → ℝ≥0) (hδ : ∀ d, 0 < δ d) (hwidth : ∀ d j, (δ d : ℝ) ≤ w d j) + (degree : ℕ) (hdegree : ∀ d, h d ≤ degree) + (hd : ∀ d n, (eN d n).sum (fun _ k => k) ≤ degree) + (η : ℝ≥0) (hη : 0 < η) (hη1 : η ≤ 1) {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, (|c d j|+|w d j|)) ≤ Wsum) + {P T E : ℝ} (hP : 0 ≤ P) (hT : 0 ≤ T) + (hA : ∀ d, ‖(A d).toContinuousLinearMap‖ ≤ Real.exp P) + (hF : ∀ d, ‖F d‖ ≤ Real.exp P) + (hInv : ∀ d, ‖(A d).symm.toContinuousLinearMap‖ ≤ Real.exp P) + (hR : ∀ d, (R d : ℝ) ≤ Real.exp P) + (htT : (t : ℝ)⁻¹ ≤ Real.exp T) (hδP : ∀ d, (δ d : ℝ)⁻¹ ≤ Real.exp P) + (hηE : (η : ℝ)⁻¹ ≤ Real.exp E) + (hCsumP : Csum ≤ Real.exp P) (hWsumP : Wsum ≤ Real.exp P) + (μ : Measure W) [IsProbabilityMeasure μ] (hzbox : ∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) : + let Ro := Real.exp (commonAffineOutputLog (α := α) N degree P) + let b := jointPivotProfileLog s P T + let f := averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η + let g := smallAffineMixtureDensity h eK eN s A F sets extra c w t z + Integrable (fun p : W × ((Σ d, O d) → ℝ) => f p.2-g p.1 p.2) (μ.prod volume) ∧ + (∀ᵐ a ∂μ, LipschitzWith ⟨Real.exp (affineProfileLogBound (Fintype.card (Σ d, O d)) E), Real.exp_nonneg _⟩ f ∧ + LipschitzWith ⟨Real.exp (Fintype.card D+(Fintype.card D+1)*b), Real.exp_nonneg _⟩ (g a) ∧ + (∀ v, (Ro : ℝ) < ‖v‖ → f v = 0) ∧ (∀ v, (Ro : ℝ) < ‖v‖ → g a v = 0)) := by + let b := jointPivotProfileLog s P T + let C : ℝ≥0 := ⟨Real.exp b, Real.exp_nonneg _⟩ + let Ro : ℝ≥0 := ⟨Real.exp (commonAffineOutputLog (α := α) N degree P), Real.exp_nonneg _⟩ + let Ri := Real.exp (idealOutputLog (Fintype.card α) degree P) + obtain ⟨hC, hbounds⟩ := jointPivotProfile_regularity s A R δ t ht hδ hP hT hInv hR htT hδP + have hRo : ∀ d, normalizedJetOutputRadius α (N d) (A d) (F d) degree (R d) (R d) ≤ Ro := by + intro d + exact_mod_cast commonAffineOutputLog_radius N d (A d) (F d) degree (R d) (R d) hP + (hA d) (hF d) (hR d) (hR d) + have hideal : ∀ d o, Wsum+(2 : ℝ)^(sets d o).card*(Csum*((Fintype.card α : ℝ)+1)^h d) ≤ Ri := + fun d o => idealOutputBound_le_exp (sets d o) (hdegree d) hCsum hP hCsumP hWsumP + have hRiRo : Ri+(η : ℝ) ≤ Ro := + commonAffineOutputLog_ideal N degree hP (by exact_mod_cast hη1) + have hs := averagedAffine_density_data h eK eN index s A F sets extra c w z hz hw R hsupport + t ht ht1 δ hδ hwidth C C hC (fun d => (hbounds d).1) (fun d => (hbounds d).2) + (fun _ => degree) hd Ro hRo η hη (Real.exp_nonneg _) hRiRo hcsum hwsum hideal μ hzbox + dsimp only + refine ⟨hs.1, ?_⟩ + filter_upwards [hs.2] with a ha + refine ⟨ha.1.weaken ?_, ha.2.1.weaken ?_, ha.2.2.1, ha.2.2.2⟩ + · exact_mod_cast affineProductProfileLip_le_exp (Σ d, O d) hηE + · change (Fintype.card D : ℝ)*Real.exp b*(Real.exp b)^Fintype.card D ≤ _ + exact jointDensityLip_le_exp _ b + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +variable {D α : Type*} [Fintype D] [Fintype α] + {O J : D → Type*} [∀ d, Fintype (O d)] [∀ d, Fintype (J d)] + +noncomputable def affineGridCommonLog (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) (P T E : ℝ) : ℝ := + commonAffineOutputLog (α := α) N degree P+ + affineProfileLogBound (Fintype.card (Σ d, O d)) E+ + (Fintype.card D+(Fintype.card D+1)*jointPivotProfileLog s P T)+1 + +noncomputable def affineMixedGridLog (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) (P T E : ℝ) : ℝ := + Fintype.card (Σ d, O d)*(affineGridCommonLog (α := α) N s degree P T E+4)+ + affineGridCommonLog (α := α) N s degree P T E + +theorem affineGridCommonLog_nonneg (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) {P T E : ℝ} + (hP : 0 ≤ P) (hT : 0 ≤ T) (hE : 0 ≤ E) : + 0 ≤ affineGridCommonLog (α := α) N s degree P T E := by + have := commonAffineOutputLog_nonneg (α := α) N degree hP + have := affineProfileLogBound_nonneg (Fintype.card (Σ d, O d)) hE + have := jointPivotProfileLog_nonneg s hP hT + unfold affineGridCommonLog + positivity + +theorem affineMixedGridLog_nonneg (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) {P T E : ℝ} + (hP : 0 ≤ P) (hT : 0 ≤ T) (hE : 0 ≤ E) : + 0 ≤ affineMixedGridLog (α := α) N s degree P T E := by + have := affineGridCommonLog_nonneg (α := α) N s degree hP hT hE + unfold affineMixedGridLog + positivity + +theorem affineMixedGridAllowance_le_exp (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) {P T E : ℝ} + (hP : 0 ≤ P) (hT : 0 ≤ T) (hE : 0 ≤ E) + {V : Type*} [Fintype V] (select : V ↪ (Σ d, O d)) : + mixedOutputGridAllowance select + (Real.exp (commonAffineOutputLog (α := α) N degree P)) + (Real.exp (affineProfileLogBound (Fintype.card (Σ d, O d)) E)+ + Real.exp (Fintype.card D+(Fintype.card D+1)*jointPivotProfileLog s P T)) ≤ + Real.exp (affineMixedGridLog (α := α) N s degree P T E) := by + have hr := commonAffineOutputLog_nonneg (α := α) N degree hP + have ha := affineProfileLogBound_nonneg (Fintype.card (Σ d, O d)) hE + have hb : 0 ≤ (Fintype.card D : ℝ)+(Fintype.card D+1)*jointPivotProfileLog s P T := by + have := jointPivotProfileLog_nonneg s hP hT + positivity + apply mixedOutputGridAllowance_le_exp select (Real.exp_nonneg _) + (add_nonneg (Real.exp_nonneg _) (Real.exp_nonneg _)) + (affineGridCommonLog_nonneg (α := α) N s degree hP hT hE) + · apply Real.exp_le_exp.mpr + unfold affineGridCommonLog + linarith + · apply (add_le_exp_add_one ha hb le_rfl le_rfl).trans + apply Real.exp_le_exp.mpr + unfold affineGridCommonLog + linarith + +noncomputable def affineMixedGridAccuracy (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) (P T E M τ : ℝ) : ℝ := + min 1 (outputGridAccuracy M (Real.exp (affineMixedGridLog (α := α) N s degree P T E)) τ) + +theorem affineMixedGridAccuracy_spec (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) (P T E : ℝ) {M τ ε : ℝ} + (hM : 0 ≤ M) (hτ : 0 < τ) (hε : ε ≤ mixedCoefficientAccuracy M τ) : + 0 < affineMixedGridAccuracy (α := α) N s degree P T E M τ ∧ + affineMixedGridAccuracy (α := α) N s degree P T E M τ ≤ 1 ∧ + M*(ε+Real.exp (affineMixedGridLog (α := α) N s degree P T E)* + affineMixedGridAccuracy (α := α) N s degree P T E M τ) ≤ τ := by + refine ⟨lt_min zero_lt_one (outputGridAccuracy_pos hM (Real.exp_nonneg _) hτ), min_le_left _ _, ?_⟩ + exact outputGridError_le hM (Real.exp_nonneg _) hτ.le hε (min_le_right _ _) + +theorem affineMixedGridAccuracy_inverse_le_exp (N : D → Type*) [∀ d, Fintype (N d)] + (s : ∀ d, O d ↪ J d) (degree : ℕ) {P T E M τ W : ℝ} + (hP : 0 ≤ P) (hT : 0 ≤ T) (hE : 0 ≤ E) (hM : 0 ≤ M) (hτ : 0 < τ) (hW : 0 ≤ W) + (hMW : M ≤ Real.exp W) (hτW : τ⁻¹ ≤ Real.exp W) : + (affineMixedGridAccuracy (α := α) N s degree P T E M τ)⁻¹ ≤ + Real.exp (3*(affineMixedGridLog (α := α) N s degree P T E+W)+8) := by + have hQ := affineMixedGridLog_nonneg (α := α) N s degree hP hT hE + have hWQ : W ≤ affineMixedGridLog (α := α) N s degree P T E+W := le_add_of_nonneg_left hQ + have hQW : affineMixedGridLog (α := α) N s degree P T E ≤ + affineMixedGridLog (α := α) N s degree P T E+W := le_add_of_nonneg_right hW + apply inv_min_le_of_inv_le + · simpa only [inv_one] using (Real.one_le_exp_iff.mpr (by positivity : + 0 ≤ 3*(affineMixedGridLog (α := α) N s degree P T E+W)+8)) + · exact outputGridAccuracy_inverse_le_exp hM (Real.exp_nonneg _) hτ (add_nonneg hQ hW) + (hMW.trans (Real.exp_le_exp.mpr hWQ)) (Real.exp_le_exp.mpr hQW) + (hτW.trans (Real.exp_le_exp.mpr hWQ)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem averagedAffine_log_mixed_grid_error + {V : Type*} [Fintype V] + {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → J d ⊕ N d) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (z : W → Z → ℝ) + (hz : ∀ j, Measurable (fun a => z a j)) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (t : ℝ≥0) (ht : 0 < t) (ht1 : t ≤ 1) + (δ : D → ℝ≥0) (hδ : ∀ d, 0 < δ d) (hwidth : ∀ d j, (δ d : ℝ) ≤ w d j) + (degree : ℕ) (hdegree : ∀ d, h d ≤ degree) + (hd : ∀ d n, (eN d n).sum (fun _ k => k) ≤ degree) + (η : ℝ≥0) (hη : 0 < η) (hη1 : η ≤ 1) {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, (|c d j|+|w d j|)) ≤ Wsum) + {P T E : ℝ} (hP : 0 ≤ P) (hT : 0 ≤ T) (hE : 0 ≤ E) + (hA : ∀ d, ‖(A d).toContinuousLinearMap‖ ≤ Real.exp P) + (hF : ∀ d, ‖F d‖ ≤ Real.exp P) + (hInv : ∀ d, ‖(A d).symm.toContinuousLinearMap‖ ≤ Real.exp P) + (hR : ∀ d, (R d : ℝ) ≤ Real.exp P) + (htT : (t : ℝ)⁻¹ ≤ Real.exp T) (hδP : ∀ d, (δ d : ℝ)⁻¹ ≤ Real.exp P) + (hηE : (η : ℝ)⁻¹ ≤ Real.exp E) + (hCsumP : Csum ≤ Real.exp P) (hWsumP : Wsum ≤ Real.exp P) + (μ : Measure W) [IsProbabilityMeasure μ] (hzbox : ∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) {ε : ℝ} + (he : (∫ p : W × ((Σ d, O d) → ℝ), + |averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η p.2 - + smallAffineMixtureDensity h eK eN s A F sets extra c w t z p.1 p.2| ∂μ.prod volume) ≤ ε) + (select : V ↪ (Σ d, O d)) + (a S : W × (UnselectedColumn select → ℝ) → V → ℝ) + (hS : ∀ p j, 0 < S p j) {mesh M : ℝ} + (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) (hmesh : ∀ p j, 1/S p j ≤ mesh) + (grid : W × (UnselectedColumn select → ℝ) → Finset (V → ℤ)) (mask : W × (UnselectedColumn select → ℝ) → (V → ℤ) → ℝ) + (φ : W × (UnselectedColumn select → ℝ) → (V → ℤ) → ℂ) + (hM : 0 ≤ M) (hmask : ∀ p k, k ∈ grid p → |mask p k| ≤ M) + (hφ : ∀ p k, k ∈ grid p → ‖φ p k‖ ≤ 1) : + let f := averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η + let g := smallAffineMixtureDensity h eK eN s A F sets extra c w t z + ‖∫ p : W × (UnselectedColumn select → ℝ), + gridDensityTest (selectedOutputSlice select f p.2) (a p) (S p) (grid p) (mask p) (φ p)- + gridDensityTest (selectedOutputSlice select (g p.1) p.2) (a p) (S p) (grid p) (mask p) (φ p) ∂μ.prod volume‖ ≤ + M*(ε+Real.exp (affineMixedGridLog (α := α) N s degree P T E)*mesh) := by + dsimp only + obtain ⟨hi, hgood⟩ := averagedAffine_log_density_data h eK eN index s A F sets extra c w z hz + hw R hsupport t ht ht1 δ hδ hwidth degree hdegree hd η hη hη1 hCsum hcsum hwsum + hP hT hA hF hInv hR htT hδP hηE hCsumP hWsumP μ hzbox + let Ro : ℝ≥0 := ⟨Real.exp (commonAffineOutputLog (α := α) N degree P), Real.exp_nonneg _⟩ + have herr := mixed_output_grid_error select μ + (fun _ => averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η) + (smallAffineMixtureDensity h eK eN s A F sets extra c w t z) + Ro hgood hi he a S hS hmesh0 hmesh1 hmesh grid mask φ hM hmask hφ + have hcost := affineMixedGridAllowance_le_exp (α := α) N s degree hP hT hE select + apply herr.trans + calc + _ = M*(ε+mixedOutputGridAllowance select + (Real.exp (commonAffineOutputLog (α := α) N degree P)) + (Real.exp (affineProfileLogBound (Fintype.card (Σ d, O d)) E)+ + Real.exp (Fintype.card D+(Fintype.card D+1)*jointPivotProfileLog s P T))*mesh) := by + change M*(ε+(2*Real.exp (commonAffineOutputLog (α := α) N degree P))^ + Fintype.card (UnselectedColumn select)* + ((2*Real.exp (commonAffineOutputLog (α := α) N degree P)+2)^Fintype.card V* + (Real.exp (affineProfileLogBound (Fintype.card (Σ d, O d)) E)+ + Real.exp (Fintype.card D+(Fintype.card D+1)*jointPivotProfileLog s P T))*mesh)) = _ + unfold mixedOutputGridAllowance + ring + _ ≤ _ := by gcongr + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineMixedGrid.lean b/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineMixedGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..94b734675f34e55e5b74ce349974d749ca957fa6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/AveragedAffineMixedGrid.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.Progressions.Lattices.AveragedAffineGrid + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem averagedAffine_mixed_grid_error + {P : Type*} [Fintype P] + {W D G Z α : Type*} [MeasurableSpace W] [Fintype D] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, Fintype (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → J d ⊕ N d) + (s : ∀ d, O d ↪ J d) (A : ∀ d, (O d → ℝ) ≃L[ℝ] (O d → ℝ)) + (F : ∀ d, (UnselectedColumn (s d) → ℝ) →L[ℝ] (O d → ℝ)) + (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (c w : ∀ d, J d ⊕ N d → ℝ) (z : W → Z → ℝ) + (hz : ∀ j, Measurable (fun a => z a j)) + (hw : ∀ d j, 0 < w d j) (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (t : ℝ≥0) (ht : 0 < t) (ht1 : t ≤ 1) + (δ : D → ℝ≥0) (hδ : ∀ d, 0 < δ d) (hwidth : ∀ d j, (δ d : ℝ) ≤ w d j) + (Cap Lip : ℝ≥0) (hCap : 1 ≤ Cap) + (hcap : ∀ d, pivotKernelCap (UnselectedColumn (s d)) (A d) (R d) + ((t*δ d)⁻¹^Fintype.card (J d)) ≤ Cap) + (hlip : ∀ d, pivotKernelLip (UnselectedColumn (s d)) (A d) (R d) + (affineProductProfileLip (J d) (t*δ d)) ≤ Lip) + (degree : D → ℕ) (hd : ∀ d n, (eN d n).sum (fun _ k => k) ≤ degree d) + (Ro : ℝ≥0) (hRo : ∀ d, normalizedJetOutputRadius α (N d) (A d) (F d) + (degree d) (R d) (R d) ≤ Ro) + (η : ℝ≥0) (hη : 0 < η) {Csum Wsum Ri : ℝ} (hRi : 0 ≤ Ri) (hRiRo : Ri+η ≤ Ro) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, (|c d j|+|w d j|)) ≤ Wsum) + (hideal : ∀ d o, Wsum+(2 : ℝ)^(sets d o).card*(Csum*((Fintype.card α : ℝ)+1)^h d) ≤ Ri) + (μ : Measure W) [IsProbabilityMeasure μ] (hzbox : ∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) {ε : ℝ} + (he : (∫ p : W × ((Σ d, O d) → ℝ), + |averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η p.2 - + smallAffineMixtureDensity h eK eN s A F sets extra c w t z p.1 p.2| ∂μ.prod volume) ≤ ε) + (select : P ↪ (Σ d, O d)) + (a S : W × (UnselectedColumn select → ℝ) → P → ℝ) + (hS : ∀ p j, 0 < S p j) {mesh M : ℝ} + (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) (hmesh : ∀ p j, 1/S p j ≤ mesh) + (grid : W × (UnselectedColumn select → ℝ) → Finset (P → ℤ)) (mask : W × (UnselectedColumn select → ℝ) → (P → ℤ) → ℝ) + (φ : W × (UnselectedColumn select → ℝ) → (P → ℤ) → ℂ) + (hM : 0 ≤ M) (hmask : ∀ p k, k ∈ grid p → |mask p k| ≤ M) + (hφ : ∀ p k, k ∈ grid p → ‖φ p k‖ ≤ 1) : + let f := averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η + let g := smallAffineMixtureDensity h eK eN s A F sets extra c w t z + ‖∫ p : W × (UnselectedColumn select → ℝ), + gridDensityTest (selectedOutputSlice select f p.2) (a p) (S p) (grid p) (mask p) (φ p)- + gridDensityTest (selectedOutputSlice select (g p.1) p.2) (a p) (S p) (grid p) (mask p) (φ p) ∂μ.prod volume‖ ≤ + M*(ε+(2*(Ro : ℝ))^Fintype.card (UnselectedColumn select)* + ((2*(Ro : ℝ)+2)^Fintype.card P* + ((affineProductProfileLip (Σ d, O d) η : ℝ)+(Fintype.card D*Lip*Cap^Fintype.card D : ℝ≥0))*mesh)) := by + dsimp only + obtain ⟨hi, hgood⟩ := averagedAffine_density_data h eK eN index s A F sets extra c w z hz hw R hsupport + t ht ht1 δ hδ hwidth Cap Lip hCap hcap hlip degree hd Ro hRo η hη hRi hRiRo + hcsum hwsum hideal μ hzbox + exact mixed_output_grid_error select μ + (fun _ => averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets η) + (smallAffineMixtureDensity h eK eN s A F sets extra c w t z) Ro hgood hi he + a S hS hmesh0 hmesh1 hmesh grid mask φ hM hmask hφ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/BooleanAffineInput.lean b/lean/OAI/Combinatorics/Progressions/Lattices/BooleanAffineInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..04a2c4757eada9809532e6b3684d0e9dfa73099f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/BooleanAffineInput.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Polynomial.BooleanPolynomialBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def booleanAffineInput {I α : Type*} [Fintype α] [DecidableEq α] + (a : Option α → MvPolynomial I ℝ) (t : Finset α) : MvPolynomial I ℝ := + ∑ r, MvPolynomial.C (booleanFeature r t : ℝ) * a r + +theorem booleanAffineInput_eval {I α : Type*} [Fintype α] [DecidableEq α] + (a : Option α → MvPolynomial I ℝ) (t : Finset α) (x : I → ℝ) : + MvPolynomial.eval x (booleanAffineInput a t) = + ∑ r, (booleanFeature r t : ℝ) * MvPolynomial.eval x (a r) := by + simp only [booleanAffineInput, map_sum, map_mul, MvPolynomial.eval_C] + +theorem booleanAffineInput_mass_le {I α : Type*} [Fintype α] [DecidableEq α] + (a : Option α → MvPolynomial I ℝ) (t : Finset α) {A : ℝ} + (ha : ∀ r, realPolynomialMass (a r) ≤ A) : + realPolynomialMass (booleanAffineInput a t) ≤ ((Fintype.card α : ℝ) + 1) * A := by + classical + apply (realPolynomialMass_sum_le _ _).trans + calc + _ ≤ ∑ _r : Option α, A := by + apply Finset.sum_le_sum + intro r _ + apply (realPolynomialMass_C_mul_le _ _).trans + simpa only [one_mul] using mul_le_mul (booleanFeature_abs_le_one r t) + (ha r) (realPolynomialMass_nonneg _) zero_le_one + _ = _ := by simp + +theorem booleanAffineInput_totalDegree_le {I α : Type*} [Fintype α] [DecidableEq α] + (a : Option α → MvPolynomial I ℝ) (t : Finset α) {e : ℕ} + (ha : ∀ r, (a r).totalDegree ≤ e) : (booleanAffineInput a t).totalDegree ≤ e := by + classical + apply MvPolynomial.totalDegree_finsetSum_le + intro r _ + exact (MvPolynomial.totalDegree_mul _ _).trans (by + simpa only [MvPolynomial.totalDegree_C, zero_add] using ha r) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/BooleanJetResidueMask.lean b/lean/OAI/Combinatorics/Progressions/Lattices/BooleanJetResidueMask.lean new file mode 100644 index 0000000000000000000000000000000000000000..dac929881a09cd30e7b27091c373253ee9e72578 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/BooleanJetResidueMask.lean @@ -0,0 +1,44 @@ +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Estimates.ActiveAveragedProfileComparison + +namespace OAI + +section + +namespace Erdos3 + +open scoped Classical + +noncomputable def booleanJetResidueMask {D α : Type*} [DecidableEq α] + {O : D → Type*} (sets : ∀ d, O d → Finset α) (m : ℕ) + (mask : ((Σ d, O d) → ZMod m) → ℂ) (r : Finset α → D → ZMod m) : ℂ := + mask (fun o => booleanCoefficient (fun s => r s o.1) (sets o.1 o.2)) + +theorem booleanJetResidueMask_cast {D α : Type*} [DecidableEq α] + {O : D → Type*} (sets : ∀ d, O d → Finset α) (m : ℕ) + (mask : ((Σ d, O d) → ZMod m) → ℂ) (z : Finset α → D → ℤ) : + booleanJetResidueMask sets m mask (fun s d => (z s d : ZMod m)) = + mask (fun o => (booleanCoefficient (fun s => z s o.1) (sets o.1 o.2) : ℤ)) := by + unfold booleanJetResidueMask + congr 1 + funext o + exact (booleanCoefficient_map (Int.castRingHom (ZMod m)) (fun s => z s o.1) (sets o.1 o.2)).symm + +theorem booleanJetResidueMask_bound {D α : Type*} [DecidableEq α] + {O : D → Type*} (sets : ∀ d, O d → Finset α) (m : ℕ) + (mask : ((Σ d, O d) → ZMod m) → ℂ) {G : ℝ} (hm : ∀ r, ‖mask r‖ ≤ G) + (r : Finset α → D → ZMod m) : ‖booleanJetResidueMask sets m mask r‖ ≤ G := hm _ + +theorem siteResidueVector_card_le_exp (D : Type*) [Fintype D] (m : ℕ) [NeZero m] + {P : ℝ} (hm : (m : ℝ) ≤ Real.exp P) : + (Fintype.card (D → ZMod m) : ℝ) ≤ Real.exp (Fintype.card D*P) := by + simp only [Fintype.card_fun, ZMod.card, Nat.cast_pow] + calc + _ ≤ (Real.exp P)^Fintype.card D := by gcongr + _ = _ := (Real.exp_nat_mul _ _).symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeDepthBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeDepthBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..22df50f7b7b785e40a3b871f0aecfddad2c09f30 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeDepthBudget.lean @@ -0,0 +1,164 @@ +import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Data.Nat.Factorization.Basic +import Mathlib.Data.Nat.Log + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def boundedPrimes (Q : ℕ) : Finset ℕ := (Finset.range (Q + 1)).filter Nat.Prime + +abbrev BoundedPrime (Q : ℕ) := {p // p ∈ boundedPrimes Q} + +def boundedPrime (Q : ℕ) (p : BoundedPrime Q) : ℕ := p.val + +def boundedPrimeExponent (Q : ℕ) (p : BoundedPrime Q) : ℕ := Nat.log p.val Q + +def boundedPrimePower (Q : ℕ) (p : BoundedPrime Q) : ℕ := p.val ^ boundedPrimeExponent Q p + +theorem mem_boundedPrimes (Q p : ℕ) : p ∈ boundedPrimes Q ↔ p.Prime ∧ p ≤ Q := by + simp only [boundedPrimes, Finset.mem_filter, Finset.mem_range, Nat.lt_succ_iff, and_comm] + +theorem boundedPrime_prime (Q : ℕ) (p : BoundedPrime Q) : (boundedPrime Q p).Prime := + ((mem_boundedPrimes Q p.val).mp p.property).1 + +theorem boundedPrime_le (Q : ℕ) (p : BoundedPrime Q) : boundedPrime Q p ≤ Q := + ((mem_boundedPrimes Q p.val).mp p.property).2 + +theorem boundedPrime_injective (Q : ℕ) : Function.Injective (boundedPrime Q) := Subtype.val_injective + +theorem boundedPrimeExponent_pos (Q : ℕ) (p : BoundedPrime Q) : 0 < boundedPrimeExponent Q p := + Nat.log_pos (boundedPrime_prime Q p).one_lt (boundedPrime_le Q p) + +theorem boundedPrimePower_pos (Q : ℕ) (p : BoundedPrime Q) : 0 < boundedPrimePower Q p := + pow_pos (boundedPrime_prime Q p).pos _ + +instance boundedPrimePower_neZero (Q : ℕ) (p : BoundedPrime Q) : NeZero (boundedPrimePower Q p) := + ⟨(boundedPrimePower_pos Q p).ne'⟩ + +theorem boundedPrimePower_le (Q : ℕ) (p : BoundedPrime Q) : boundedPrimePower Q p ≤ Q := by + have hQ : 0 < Q := (boundedPrime_prime Q p).pos.trans_le (boundedPrime_le Q p) + exact Nat.pow_log_le_self p.val hQ.ne' + +theorem boundedPrimePower_maximal (Q : ℕ) (p : BoundedPrime Q) : + Q < p.val ^ (boundedPrimeExponent Q p + 1) := + Nat.lt_pow_succ_log_self (boundedPrime_prime Q p).one_lt Q + +theorem boundedPrime_card_le (Q : ℕ) : Fintype.card (BoundedPrime Q) ≤ Q := by + have hsub : boundedPrimes Q ⊆ (Finset.range (Q + 1)).erase 0 := by + intro p hp + have h := (mem_boundedPrimes Q p).mp hp + exact Finset.mem_erase.mpr ⟨h.1.ne_zero, Finset.mem_range.mpr (by omega)⟩ + calc + _ = (boundedPrimes Q).card := Fintype.card_coe _ + _ ≤ ((Finset.range (Q + 1)).erase 0).card := Finset.card_le_card hsub + _ = Q := by simp + +theorem boundedPrimePower_pairwise (Q : ℕ) : + Pairwise (fun p r : BoundedPrime Q => (boundedPrimePower Q p).Coprime (boundedPrimePower Q r)) := by + intro p r hpr + apply Nat.Coprime.pow + exact (Nat.coprime_primes (boundedPrime_prime Q p) (boundedPrime_prime Q r)).mpr + (fun h => hpr (Subtype.ext h)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def boundedPrimeProduct (Q : ℕ) : ℕ := ∏ p : BoundedPrime Q, boundedPrimePower Q p + +theorem boundedPrimeProduct_pos (Q : ℕ) : 0 < boundedPrimeProduct Q := + Finset.prod_pos (fun p _ => boundedPrimePower_pos Q p) + +theorem boundedPrimeProduct_captures {Q m : ℕ} (hm : 0 < m) (hmQ : m ≤ Q) : + m ∣ boundedPrimeProduct Q := by + have hQ : Q ≠ 0 := (hm.trans_le hmQ).ne' + have hsub : m.primeFactors ⊆ boundedPrimes Q := by + intro p hp + have h := Nat.mem_primeFactors.mp hp + exact (mem_boundedPrimes Q p).mpr ⟨h.1, (Nat.le_of_dvd hm h.2.1).trans hmQ⟩ + have hpow (p : ℕ) (hp : p ∈ m.primeFactors) : + p ^ m.factorization p ∣ p ^ Nat.log p Q := by + have hprime := (Nat.mem_primeFactors.mp hp).1 + apply Nat.pow_dvd_pow + apply (Nat.le_log_iff_pow_le hprime.one_lt hQ).mpr + exact (Nat.le_of_dvd hm (Nat.ordProj_dvd m p)).trans hmQ + have hsmall : m ∣ ∏ p ∈ m.primeFactors, p ^ Nat.log p Q := by + nth_rw 1 [Nat.prod_primeFactors_pow_factorization hm.ne'] + exact Finset.prod_dvd_prod_of_dvd _ _ hpow + have hlarge := Finset.prod_dvd_prod_of_subset m.primeFactors (boundedPrimes Q) + (fun p => p ^ Nat.log p Q) hsub + have h := hsmall.trans hlarge + have he : boundedPrimeProduct Q = ∏ p ∈ boundedPrimes Q, p ^ Nat.log p Q := + Finset.prod_coe_sort (boundedPrimes Q) (fun p => p ^ Nat.log p Q) + rwa [he] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem natLog_ceil_exp_le_linear {p : ℕ} (hp : 2 ≤ p) + {B : ℝ} (hB : 0 ≤ B) : + (Nat.log p ⌈Real.exp B⌉₊ : ℝ) ≤ 2 * B + 2 := by + let Q : ℕ := ⌈Real.exp B⌉₊ + let n : ℕ := Nat.log p Q + have hQ : 0 < Q := Nat.ceil_pos.mpr (Real.exp_pos B) + have hpowNat : 2 ^ n ≤ Q := + (Nat.pow_le_pow_left hp n).trans (Nat.pow_log_le_self p hQ.ne') + have hpow : (2 : ℝ) ^ n ≤ Q := by exact_mod_cast hpowNat + have hceil : (Q : ℝ) ≤ 2 * Real.exp B := by + have hc := Nat.ceil_lt_add_one (Real.exp_pos B).le + have he : 1 ≤ Real.exp B := Real.one_le_exp_iff.mpr hB + dsimp [Q] + linarith + have hlog := Real.log_le_log (by positivity : (0 : ℝ) < 2 ^ n) + (hpow.trans hceil) + rw [Real.log_pow, Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) + (Real.exp_ne_zero B), Real.log_exp] at hlog + have hhalf : (1 : ℝ) / 2 ≤ Real.log 2 := by + have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at h ⊢ + exact h + have hone : Real.log 2 ≤ 1 := by + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at h + exact h + have hn : (0 : ℝ) ≤ n := Nat.cast_nonneg n + dsimp [n, Q] at hlog hn ⊢ + nlinarith + +theorem prime_natLog_tested_depth_le {p : ℕ} (hp : p.Prime) + {Ptest : ℝ} (hPtest : 0 ≤ Ptest) : + (Nat.log p ⌈Real.exp (2 * Ptest)⌉₊ : ℝ) ≤ 4 * Ptest + 2 := by + have h := natLog_ceil_exp_le_linear hp.two_le + (B := 2 * Ptest) (mul_nonneg (by norm_num) hPtest) + nlinarith + +theorem exists_testedPrimeDepth {Ptest : ℝ} (hPtest : 0 ≤ Ptest) : + ∃ depth : ℕ, (depth : ℝ) ≤ 4 * Ptest + 2 ∧ + ∀ p : ℕ, p.Prime → Nat.log p ⌈Real.exp (2 * Ptest)⌉₊ ≤ depth := by + have hnonneg : 0 ≤ 4 * Ptest + 2 := by positivity + refine ⟨⌊4 * Ptest + 2⌋₊, Nat.floor_le hnonneg, ?_⟩ + intro p hp + exact Nat.le_floor (prime_natLog_tested_depth_le hp hPtest) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeGridCorrelation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeGridCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6a53b6ccf49195f3b850fe4cadbcdfcf6bad381 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeGridCorrelation.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Sampling.PhysicalGridCorrelation + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem boundedPrime_small_support (Q degree m : ℕ) (hm : 0 < m) (hmQ : m ≤ Q) (hQdegree : Q ≤ 2 ^ degree) : + ∃ S : Finset (BoundedPrime Q), S.card ≤ degree ∧ m ∣ ∏ j ∈ S, boundedPrimePower Q j := by + refine ⟨periodPrimeCoordinates (boundedPrime Q) m, ?_, ?_⟩ + · exact periodPrimeCoordinates_card_le_of_le_pow (boundedPrime Q) (boundedPrime_prime Q) + (boundedPrime_injective Q) hm (hmQ.trans hQdegree) + · exact periodPrimeCoordinates_modulus_dvd_product (boundedPrime Q) (boundedPrimeExponent Q) + (boundedPrime_prime Q) m (boundedPrimeProduct_captures hm hmQ) + +theorem bounded_prime_physical_residual_correlation {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) + (H : I → ℝ) {L C κ δ : ℝ} (Q : ℕ) (hH : ∀ i, 0 < H i) + (hL : 1 ≤ L) (hC : 1 ≤ C) (hκ : 0 < κ) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (ht : ∀ j, |(t j : ℝ) / L| ≤ C) (hu : ∀ j, |(u j : ℝ) / L| ≤ C) + (hgap : κ ≤ |((u k - t k : ℤ) : ℝ) / L|) (hQ : affinePairModulus t u ≤ Q) + (hmesh : ∀ i, ((u k - t k).natAbs : ℝ) * L / H i ≤ δ) + (hsmall : (4 : ℝ) ^ (2 + Fintype.card {j : J // j ≠ k}) * smoothPairRowLipschitz k * δ ≤ 1 / 2) + (origin : Option J × I → ℤ) + (hZ : 0 < shiftedSmoothProductMass (fun z => (origin z : ℝ)) + (fun z : Option J × I => smoothPairCoefficientScale (H z.2) L z.1)) + (lo : I → ℤ) (N : I → ℕ) (hside : ∀ i, (Q : ℝ) ≤ (N i : ℝ)) + (degree : ℕ) (f g : (I → ℤ) → ℝ) + (hf : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ f x ∧ f x ≤ 1) + (hg : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ g x ∧ g x ≤ 1) + (eta ρ modLog dimLog accLog : ℝ) (hρ : 0 ≤ ρ) (heta : eta ≤ 1) + (hmodLog : 0 ≤ modLog) (hacc : Real.exp (-accLog) ≤ eta) + (hQlog : (Q : ℝ) ≤ Real.exp modLog) + (hdim : (Fintype.card I : ℝ) ≤ Real.exp dimLog) + (hlarge : ∀ i, 4 ≤ ρ * H i) (hwhole : ∀ i, ρ * H i ≤ 2 * (N i : ℝ)) + (hlength : ∀ i, Real.exp (modLog * (2 * degree : ℕ) + accLog + dimLog + 1) ≤ ρ * H i / 4) + (hQdegree : Q ≤ 2 ^ degree) : + let P := normalizedBoxPartitions N H ρ hlarge hwhole + let hpos := normalizedBoxPartitions_positive N H ρ hlarge hwhole + |(smoothSourceFiniteWeights (fun z => (origin z : ℝ)) + (fun z : Option J × I => smoothPairCoefficientScale (H z.2) L z.1) + (fun z => smoothPairCoefficientScale_pos (hH z.2) (zero_lt_one.trans_le hL) z.1) hZ).mean + (fun z => physicalBoxResidual lo N P hpos (boundedPrimePower Q) degree f (smoothAffineSample t z.val) * + physicalBoxResidual lo N P hpos (boundedPrimePower Q) degree g (smoothAffineSample u z.val))| ≤ + ((translatedIntegerBox lo N).card : ℝ) ^ 2 / (∏ i, H i ^ 2) * + ((smoothPairKernelCap (Fintype.card I) k C κ : ℝ) * (eta * residueTruncationCap (BoundedPrime Q) degree eta) ^ 2 + + (fullSmoothPairError (Fintype.card I) k Q C κ δ + + (smoothPairKernelLip (Fintype.card I) k C κ : ℝ) * ρ) * + (2 : ℝ) ^ Fintype.card I * (1 + eta * residueTruncationCap (BoundedPrime Q) degree eta ^ 2)) := by + obtain ⟨S, hS, hm⟩ := boundedPrime_small_support Q degree (affinePairModulus t u) + (affinePairModulus_pos t u k hne) hQ hQdegree + exact normalized_physical_residual_correlation t u k hne H Q hH hL hC hκ hδ hδ1 ht hu hgap hQ + hmesh hsmall origin hZ lo N hside (boundedPrimePower Q) (boundedPrimePower_pairwise Q) degree f g hf hg + eta ρ modLog dimLog accLog hρ heta hmodLog hacc + (fun j => (Nat.cast_le.mpr (boundedPrimePower_le Q j)).trans hQlog) hdim hlarge hwhole hlength S hS hm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeResidual.lean b/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d8d02c128c5e68067c9dbfb870e875021f3570d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/BoundedPrimeResidual.lean @@ -0,0 +1,350 @@ +import Mathlib.Data.ZMod.QuotientRing +import OAI.Combinatorics.Progressions.Lattices.BoundedPrimeDepthBudget +import OAI.Combinatorics.Progressions.Lattices.ResidueSliceUpperFailure + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι σ : Type*} (q : ι → ℕ) (I : Finset ι) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + +noncomputable def selectedPrimeCRT : + ZMod (∏ i : I, q i.val) ≃+* (∀ i : I, ZMod (q i.val)) := + ZMod.prodEquivPi (fun i : I => q i.val) + (fun i j hij => hpair (by intro h; exact hij (Subtype.ext h))) + +noncomputable def primeCoordinatesMod (m : ℕ) (hd : m ∣ ∏ i : I, q i.val) : + (∀ i, σ → ZMod (q i)) →+ (σ → ZMod m) where + toFun x k := (ZMod.castHom hd (ZMod m)) + ((selectedPrimeCRT q I hpair).symm (fun i : I => x i.val k)) + map_zero' := by + ext k + change (ZMod.castHom hd (ZMod m)) ((selectedPrimeCRT q I hpair).symm 0) = 0 + rw [map_zero, map_zero] + map_add' := by + intro x y + ext k + change (ZMod.castHom hd (ZMod m)) ((selectedPrimeCRT q I hpair).symm + ((fun i : I => x i.val k) + (fun i : I => y i.val k))) = _ + rw [map_add, map_add] + rfl + +theorem primeCoordinatesMod_agree (m : ℕ) (hd : m ∣ ∏ i : I, q i.val) + (x y : ∀ i, σ → ZMod (q i)) (hxy : ∀ i ∈ I, x i = y i) : + primeCoordinatesMod q I hpair m hd x = primeCoordinatesMod q I hpair m hd y := by + ext k + change (ZMod.castHom hd (ZMod m)) ((selectedPrimeCRT q I hpair).symm (fun i : I => x i.val k)) = + (ZMod.castHom hd (ZMod m)) ((selectedPrimeCRT q I hpair).symm (fun i : I => y i.val k)) + congr 2 + funext i + exact congrFun (hxy i.val i.property) k + +theorem primeCoordinatesMod_integer (m : ℕ) (hd : m ∣ ∏ i : I, q i.val) (u : σ → ℤ) : + primeCoordinatesMod q I hpair m hd (primeCoordinateObservation q u) = (fun k => (u k : ZMod m)) := by + ext k + change (ZMod.castHom hd (ZMod m)) + ((selectedPrimeCRT q I hpair).symm (u k : ∀ i : I, ZMod (q i.val))) = _ + rw [map_intCast, map_intCast] + +theorem primeCoordinatesMod_surjective (m : ℕ) [NeZero m] (hd : m ∣ ∏ i : I, q i.val) : + Function.Surjective (primeCoordinatesMod (σ := σ) q I hpair m hd) := by + intro y + refine ⟨primeCoordinateObservation q (fun k => ((y k).val : ℤ)), ?_⟩ + rw [primeCoordinatesMod_integer] + funext k + simp only [Int.cast_natCast, ZMod.natCast_zmod_val] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def coarseResidueIndicator {ι σ : Type*} + (q : ι → ℕ) (I : Finset ι) (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (m : ℕ) (hd : m ∣ ∏ i : I, q i.val) (r : σ → ZMod m) (x : ∀ i, σ → ZMod (q i)) : ℝ := + if primeCoordinatesMod q I hpair m hd x = r then 1 else 0 + +section + +variable {ι σ : Type*} (q : ι → ℕ) (I : Finset ι) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (m : ℕ) (hd : m ∣ ∏ i : I, q i.val) (r : σ → ZMod m) + +theorem coarseResidueIndicator_depends : + ProductDependsOn I (coarseResidueIndicator q I hpair m hd r) := by + intro x y hxy + unfold coarseResidueIndicator + rw [primeCoordinatesMod_agree q I hpair m hd x y hxy] + +theorem coarseResidueIndicator_abs (x : ∀ i, σ → ZMod (q i)) : + |coarseResidueIndicator q I hpair m hd r x| = coarseResidueIndicator q I hpair m hd r x := by + unfold coarseResidueIndicator + split_ifs <;> norm_num + +theorem coarseResidueIndicator_integer (u : σ → ℤ) : + coarseResidueIndicator q I hpair m hd r (primeCoordinateObservation q u) = + if (fun k => (u k : ZMod m)) = r then (1 : ℝ) else 0 := by + simp only [coarseResidueIndicator, primeCoordinatesMod_integer] + +end + +theorem primeCoordinateReference_uniform {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (q : ι → ℕ) [∀ i, NeZero (q i)] : + FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q) = + FiniteProbabilityWeights.uniform (∀ i, σ → ZMod (q i)) := by + apply FiniteProbabilityWeights.eq_of_weight_eq + intro x + change (∏ i, (Fintype.card (σ → ZMod (q i)) : ℝ)⁻¹) = + (Fintype.card (∀ i, σ → ZMod (q i)) : ℝ)⁻¹ + rw [Fintype.card_pi, Nat.cast_prod, Finset.prod_inv_distrib] + +theorem coarseResidueIndicator_mean {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (q : ι → ℕ) [∀ i, NeZero (q i)] (I : Finset ι) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (m : ℕ) [NeZero m] (hd : m ∣ ∏ i : I, q i.val) (r : σ → ZMod m) : + (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).mean + (coarseResidueIndicator q I hpair m hd r) = ((m : ℝ) ^ Fintype.card σ)⁻¹ := by + rw [primeCoordinateReference_uniform] + have h := uniform_mean_surjective_hom_fiber (primeCoordinatesMod (σ := σ) q I hpair m hd) + (primeCoordinatesMod_surjective q I hpair m hd) r + convert h using 1 + · congr 1 + · simp only [Fintype.card_fun, ZMod.card, Nat.cast_pow] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def residueTruncationCap (ι : Type*) [Fintype ι] [DecidableEq ι] + (b : ℕ) (eta : ℝ) : ℝ := + ((lowDegreeCoordinateSets ι b).card : ℝ) * (2 : ℝ) ^ b * (1 + eta) + +variable {ι σ : Type*} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] + +noncomputable def residuePhysicalTruncation (b : ℕ) (f : (σ → ℤ) → ℝ) (u : σ → ℤ) : ℝ := + productANOVATruncation (primeCoordinateReference (σ := σ) q) (lowDegreeCoordinateSets ι b) + (residuePrimeCoordinateDensity lo N M a hne q f) (primeCoordinateObservation q u) + +def ResiduePhysicalTruncationControl (b : ℕ) (f : (σ → ℤ) → ℝ) (eta : ℝ) : Prop := + let low := residuePhysicalTruncation lo N M a hne q b f + let cap := residueTruncationCap ι b eta + (𝔼 z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a, + low (fun k => (z k).val) ^ 2) ≤ 2 + 3 * eta * cap ^ 2 ∧ + (𝔼 z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a, + (f (fun k => (z k).val) - low (fun k => (z k).val)) ^ 2) ≤ 1 + eta * cap ^ 2 ∧ + ∀ (I : Finset ι), I.card ≤ b → ∀ test : (∀ i, σ → ZMod (q i)) → ℝ, ProductDependsOn I test → + |𝔼 z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a, + (f (fun k => (z k).val) - low (fun k => (z k).val)) * + test (primeCoordinateObservation q (fun k => (z k).val))| ≤ + eta * cap * (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).mean + (fun x => |test x|) + +theorem residuePhysicalTruncation_control (b : ℕ) (f : (σ → ℤ) → ℝ) + (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z ∧ f z ≤ 1) {eta : ℝ} (heta : 0 ≤ eta) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1)) eta (2 * b)) : + ResiduePhysicalTruncationControl lo N M a hne q b f eta := by + let := hne + let p := FiniteProbabilityWeights.uniform + (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) + let F := fun z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a => + primeCoordinateObservation q (fun k => (z k).val) + let w := fun z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a => + f (fun k => (z k).val) + have hw (z) : 0 ≤ w z ∧ w z ≤ 1 := by + apply hf + apply (mem_translatedIntegerBox lo N _).mpr + intro k + exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (z k).property).1) + have h := observed_unit_truncation_control (primeCoordinateReference (σ := σ) q) p F + (primeCoordinateReference_weight_pos q) (fun _ _ => 0) w hw (lowDegreeCoordinateSets ι b) + heta (fun S hS => (mem_lowDegreeCoordinateSets ι b S).mp hS) hclose + dsimp only [ResiduePhysicalTruncationControl] + refine ⟨?_, ?_, ?_⟩ + · simpa only [residuePhysicalTruncation, residueTruncationCap, residuePrimeCoordinateDensity, + p, F, w, FiniteProbabilityWeights.uniform_mean] using h.1 + · simpa only [residuePhysicalTruncation, residueTruncationCap, residuePrimeCoordinateDensity, + p, F, w, FiniteProbabilityWeights.uniform_mean] using h.2.1 + · intro I hI test htest + have ht := h.2.2 I hI + (fun S hS => (mem_lowDegreeCoordinateSets ι b S).mpr ((Finset.card_le_card hS).trans hI)) test htest + simpa only [residuePhysicalTruncation, residueTruncationCap, residuePrimeCoordinateDensity, + p, F, w, FiniteProbabilityWeights.uniform_mean] using ht + +theorem residuePhysicalTruncation_control_of_lengths (b : ℕ) (f : (σ → ℤ) → ℝ) + (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z ∧ f z ≤ 1) + (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (modLog dimLog accLog eta : ℝ) (hmodLog : 0 ≤ modLog) (heta : eta ≤ 1) + (hacc : Real.exp (-accLog) ≤ eta) (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) + (hlength : ∀ k, Real.exp (modLog * (2 * b : ℕ) + accLog + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) M (a k) : ℝ)) : + ResiduePhysicalTruncationControl lo N M a hne q b f eta := by + have hclose := residuePrimeDensity_close_of_lengths lo N M a hne q hM hcop hpair + (2 * b) modLog dimLog accLog eta hmodLog heta hacc hmoduli hdim hlength + exact residuePhysicalTruncation_control lo N M a hne q b f hf ((Real.exp_pos _).le.trans hacc) hclose + +theorem residuePhysicalTruncation_atom_error {b : ℕ} {f : (σ → ℤ) → ℝ} {eta : ℝ} + (h : ResiduePhysicalTruncationControl lo N M a hne q b f eta) + (I : Finset ι) (hI : I.card ≤ b) (base : ∀ i, σ → ZMod (q i)) : + |𝔼 z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a, + (f (fun k => (z k).val) - residuePhysicalTruncation lo N M a hne q b f (fun k => (z k).val)) * + productFiberIndicator I base (primeCoordinateObservation q (fun k => (z k).val))| ≤ + eta * residueTruncationCap ι b eta * (((∏ i ∈ I, q i : ℕ) : ℝ) ^ Fintype.card σ)⁻¹ := by + have ht := h.2.2 I hI (productFiberIndicator I base) (productFiberIndicator_depends I base) + have hind : (fun x => |productFiberIndicator I base x|) = productFiberIndicator I base := by + funext x + unfold productFiberIndicator + split_ifs <;> norm_num + rw [hind] at ht + change _ ≤ eta * residueTruncationCap ι b eta * + productFiberMass (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).weight I base at ht + rw [primeCoordinateReference_fiber] at ht + exact ht + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residuePhysicalTruncation_modulus_error {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + {b : ℕ} {f : (σ → ℤ) → ℝ} {eta : ℝ} + (h : ResiduePhysicalTruncationControl lo N M a hne q b f eta) + (I : Finset ι) (hI : I.card ≤ b) (m : ℕ) [NeZero m] + (hd : m ∣ ∏ i ∈ I, q i) (r : σ → ZMod m) : + |𝔼 z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a, + (f (fun k => (z k).val) - residuePhysicalTruncation lo N M a hne q b f (fun k => (z k).val)) * + (if (fun k => ((z k).val : ZMod m)) = r then (1 : ℝ) else 0)| ≤ + eta * residueTruncationCap ι b eta * ((m : ℝ) ^ Fintype.card σ)⁻¹ := by + have hd' : m ∣ ∏ i : I, q i.val := by simpa only [Finset.prod_coe_sort] using hd + have ht := h.2.2 I hI (coarseResidueIndicator q I hpair m hd' r) + (coarseResidueIndicator_depends q I hpair m hd' r) + simp_rw [coarseResidueIndicator_integer, coarseResidueIndicator_abs] at ht + rw [coarseResidueIndicator_mean] at ht + convert ht using 1 + congr 3 + funext z + split_ifs <;> rfl + +theorem residuePhysicalTruncation_small_modulus_error {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (prime power : ι → ℕ) [∀ i, NeZero (prime i ^ power i)] + (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + {b : ℕ} {f : (σ → ℤ) → ℝ} {eta : ℝ} + (h : ResiduePhysicalTruncationControl lo N M a hne (fun i => prime i ^ power i) b f eta) + (m : ℕ) [NeZero m] (hm : m ∣ ∏ i, prime i ^ power i) (hmb : m ≤ 2 ^ b) + (r : σ → ZMod m) : + |𝔼 z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a, + (f (fun k => (z k).val) - residuePhysicalTruncation lo N M a hne + (fun i => prime i ^ power i) b f (fun k => (z k).val)) * + (if (fun k => ((z k).val : ZMod m)) = r then (1 : ℝ) else 0)| ≤ + eta * residueTruncationCap ι b eta * ((m : ℝ) ^ Fintype.card σ)⁻¹ := by + exact residuePhysicalTruncation_modulus_error lo N M a hne (fun i => prime i ^ power i) + (selectedPrimePowers_pairwise_coprime prime power hprime hinj) h (periodPrimeCoordinates prime m) + (periodPrimeCoordinates_card_le_of_le_pow prime hprime hinj (Nat.pos_of_ne_zero (NeZero.ne m)) hmb) + m (periodPrimeCoordinates_modulus_dvd_product prime power hprime m hm) r + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +variable {ι I : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] [DecidableEq I] + +theorem residuePrimeCoordinateDensity_congr_on_box + (lo : I → ℤ) (N : I → ℕ) (M : ℕ) (a : I → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (f g : (I → ℤ) → ℝ) + (hfg : ∀ z ∈ translatedIntegerBox lo N, f z = g z) : + residuePrimeCoordinateDensity lo N M a hne q f = + residuePrimeCoordinateDensity lo N M a hne q g := by + have heq : (fun z : IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) a => + f (fun i => (z i).val)) = (fun z => g (fun i => (z i).val)) := by + funext z + apply hfg + apply (mem_translatedIntegerBox lo N _).mpr + intro i + exact Finset.mem_Ico.mp (Finset.mem_filter.mp (z i).property).1 + unfold residuePrimeCoordinateDensity + dsimp only + rw [heq] + +theorem residuePhysicalTruncation_congr_on_box + (lo : I → ℤ) (N : I → ℕ) (M : ℕ) (a : I → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ) (f g : (I → ℤ) → ℝ) + (hfg : ∀ z ∈ translatedIntegerBox lo N, f z = g z) : + residuePhysicalTruncation lo N M a hne q b f = + residuePhysicalTruncation lo N M a hne q b g := by + funext x + unfold residuePhysicalTruncation + rw [residuePrimeCoordinateDensity_congr_on_box lo N M a hne q f g hfg] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem boundedPrimePhysicalTruncation_modulus_error {σ : Type*} [Fintype σ] [DecidableEq σ] + (Q : ℕ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + {b : ℕ} {f : (σ → ℤ) → ℝ} {eta : ℝ} (hQb : Q ≤ 2 ^ b) + (h : ResiduePhysicalTruncationControl lo N M a hne (boundedPrimePower Q) b f eta) + (m : ℕ) [NeZero m] (hmQ : m ≤ Q) (r : σ → ZMod m) : + |𝔼 z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a, + (f (fun k => (z k).val) - residuePhysicalTruncation lo N M a hne + (boundedPrimePower Q) b f (fun k => (z k).val)) * + (if (fun k => ((z k).val : ZMod m)) = r then (1 : ℝ) else 0)| ≤ + eta * residueTruncationCap (BoundedPrime Q) b eta * ((m : ℝ) ^ Fintype.card σ)⁻¹ := by + let : ∀ i : BoundedPrime Q, NeZero (boundedPrime Q i ^ boundedPrimeExponent Q i) := + fun i => ⟨(boundedPrimePower_pos Q i).ne'⟩ + exact residuePhysicalTruncation_small_modulus_error lo N M a hne + (boundedPrime Q) (boundedPrimeExponent Q) (boundedPrime_prime Q) (boundedPrime_injective Q) h m + (boundedPrimeProduct_captures (Nat.pos_of_ne_zero (NeZero.ne m)) hmQ) (hmQ.trans hQb) r + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/BoxResiduePartition.lean b/lean/OAI/Combinatorics/Progressions/Lattices/BoxResiduePartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b48f4c5f3dc1d82c6cd4eb1fde043f5e3d5f6f0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/BoxResiduePartition.lean @@ -0,0 +1,329 @@ +import OAI.Combinatorics.Progressions.Estimates.EmbeddedFiniteConditioning +import OAI.Combinatorics.Progressions.Estimates.FiniteReciprocalTenthTail +import OAI.Combinatorics.Progressions.Estimates.ProgressionPartitionComposition +import OAI.Combinatorics.Progressions.Lattices.ResidueSliceCountingCost +import OAI.Combinatorics.Progressions.Probability.ComplexPartitionMixture + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def integerResidueCount (a b r v : ℤ) : ℕ := + (Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card + +noncomputable def rectangularResidueCount {I : Type*} [Fintype I] (a b r v : I → ℤ) : ℕ := + ∏ i, integerResidueCount (a i) (b i) (r i) (v i) + +noncomputable def integerRectangleVolume {I : Type*} [Fintype I] (a b : I → ℤ) : ℝ := + ∏ i, ((b i - a i : ℤ) : ℝ) + +theorem rectangularResidueCount_eq_card {I : Type*} [Fintype I] [DecidableEq I] (a b r v : I → ℤ) : + rectangularResidueCount a b r v = Fintype.card + (∀ i, ↥(Finset.filter (fun x => x ≡ v i [ZMOD r i]) (Finset.Ico (a i) (b i)))) := by + classical + rw [Fintype.card_pi] + simp [rectangularResidueCount, integerResidueCount] + +theorem rectangularResidueCount_relative_error {I : Type*} [Fintype I] + (a b r v : I → ℤ) (hab : ∀ i, a i < b i) (hr : ∀ i, 0 < r i) + (hsmall : (∑ i, (r i : ℝ) / ((b i - a i : ℤ) : ℝ)) ≤ 1 / 2) : + |(∏ i, (r i : ℝ)) * (rectangularResidueCount a b r v : ℝ) - integerRectangleVolume a b| ≤ + (2 * ∑ i, (r i : ℝ) / ((b i - a i : ℤ) : ℝ)) * integerRectangleVolume a b := by + let L : I → ℝ := fun i => ((b i - a i : ℤ) : ℝ) + let c : I → ℝ := fun i => integerResidueCount (a i) (b i) (r i) (v i) + let f : I → ℝ := fun i => c i * r i / L i + let e : I → ℝ := fun i => (r i : ℝ) / L i + have hL (i) : 0 < L i := by + dsimp only [L] + exact_mod_cast sub_pos.mpr (hab i) + have hrR (i) : (0 : ℝ) < r i := by exact_mod_cast hr i + have hV : 0 < integerRectangleVolume a b := Finset.prod_pos (fun i _ => hL i) + have hprod := positive_prod_sub_one_le_twice_sum Finset.univ f e + (fun i _ => div_nonneg (mul_nonneg (Nat.cast_nonneg _) (hrR i).le) (hL i).le) + (fun i _ => (div_pos (hrR i) (hL i)).le) + (fun i _ => scalarResidue_relative_count_error (a i) (b i) (r i) (v i) (hab i) (hr i)) hsmall + have heq : (∏ i, f i) * integerRectangleVolume a b = + (∏ i, (r i : ℝ)) * (rectangularResidueCount a b r v : ℝ) := by + change (∏ i, f i) * (∏ i, L i) = _ + rw [← Finset.prod_mul_distrib] + calc + (∏ i, f i * L i) = ∏ i, c i * r i := by + apply Finset.prod_congr rfl + intro i _ + exact div_mul_cancel₀ (c i * r i) (hL i).ne' + _ = (∏ i, (r i : ℝ)) * (rectangularResidueCount a b r v : ℝ) := by + simp only [Finset.prod_mul_distrib, rectangularResidueCount, Nat.cast_prod, c] + ring + calc + _ = |((∏ i, f i) - 1) * integerRectangleVolume a b| := by + rw [← heq] + congr 1 + ring + _ = |(∏ i, f i) - 1| * integerRectangleVolume a b := by rw [abs_mul, abs_of_pos hV] + _ ≤ (2 * ∑ i, e i) * integerRectangleVolume a b := mul_le_mul_of_nonneg_right hprod hV.le + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def integerIntervalEquivFin (a : ℤ) (N : ℕ) : + ↥(Finset.Ico a (a + N)) ≃ Fin N where + toFun x := ⟨(x.val - a).toNat, by have hx := Finset.mem_Ico.mp x.property; omega⟩ + invFun n := ⟨a + n.val, by simp only [Finset.mem_Ico]; omega⟩ + left_inv x := by + apply Subtype.ext + have hx := Finset.mem_Ico.mp x.property + dsimp only + omega + right_inv n := by + apply Fin.ext + dsimp only + omega + +theorem integerIntervalEquivFin_val (a : ℤ) (N : ℕ) (x : ↥(Finset.Ico a (a + N))) : + ((integerIntervalEquivFin a N x).val : ℤ) = x.val - a := by + have hx := Finset.mem_Ico.mp x.property + change (((x.val - a).toNat : ℕ) : ℤ) = x.val - a + omega + +@[simp] theorem integerIntervalEquivFin_symm_val (a : ℤ) (N : ℕ) (n : Fin N) : + ((integerIntervalEquivFin a N).symm n).val = a + n.val := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem rectangularResidueCount_pos {I : Type*} [Fintype I] + (a b r v : I → ℤ) (hab : ∀ i, a i < b i) (hr : ∀ i, 0 < r i) + (hsmall : (∑ i, (r i : ℝ) / ((b i - a i : ℤ) : ℝ)) < 1 / 2) : + 0 < rectangularResidueCount a b r v := by + have hV : 0 < integerRectangleVolume a b := + Finset.prod_pos (fun i _ => by exact_mod_cast sub_pos.mpr (hab i)) + have hR : 0 < ∏ i, (r i : ℝ) := Finset.prod_pos (fun i _ => by exact_mod_cast hr i) + have hlower := (abs_le.mp (rectangularResidueCount_relative_error a b r v hab hr hsmall.le)).1 + have hmargin : 0 < (1 - 2 * ∑ i, (r i : ℝ) / ((b i - a i : ℤ) : ℝ)) * integerRectangleVolume a b := + mul_pos (by linarith) hV + have hprod : 0 < (∏ i, (r i : ℝ)) * (rectangularResidueCount a b r v : ℝ) := by nlinarith + exact_mod_cast (mul_pos_iff_of_pos_left hR).mp hprod + +theorem rectangularResidueLaws_l1 {K I : Type*} [Fintype K] [Nonempty K] [Fintype I] + (a b : K → I → ℤ) (r s : I → ℤ) (v w : K → I → ℤ) + (hab : ∀ k i, a k i < b k i) (hr : ∀ i, 0 < r i) (hs : ∀ i, 0 < s i) + {ε : ℝ} (hε : ε < 1 / 2) + (hsmallR : ∀ k, (∑ i, (r i : ℝ) / ((b k i - a k i : ℤ) : ℝ)) ≤ ε) + (hsmallS : ∀ k, (∑ i, (s i : ℝ) / ((b k i - a k i : ℤ) : ℝ)) ≤ ε) : + 0 < (∑ k, (rectangularResidueCount (a k) (b k) r (v k) : ℝ)) ∧ + 0 < (∑ k, (rectangularResidueCount (a k) (b k) s (w k) : ℝ)) ∧ + (∑ k, |(rectangularResidueCount (a k) (b k) r (v k) : ℝ) / + (∑ j, (rectangularResidueCount (a j) (b j) r (v j) : ℝ)) - + (rectangularResidueCount (a k) (b k) s (w k) : ℝ) / + (∑ j, (rectangularResidueCount (a j) (b j) s (w j) : ℝ))|) ≤ 8 * ε := by + let f : K → ℝ := fun k => integerRectangleVolume (a k) (b k) + let R : ℝ := ∏ i, (r i : ℝ) + let S : ℝ := ∏ i, (s i : ℝ) + let cr : K → ℝ := fun k => rectangularResidueCount (a k) (b k) r (v k) + let cs : K → ℝ := fun k => rectangularResidueCount (a k) (b k) s (w k) + let g : K → ℝ := fun k => R * cr k + let h : K → ℝ := fun k => S * cs k + have hf (k) : 0 < f k := Finset.prod_pos (fun i _ => by exact_mod_cast sub_pos.mpr (hab k i)) + have hR : 0 < R := Finset.prod_pos (fun i _ => by exact_mod_cast hr i) + have hS : 0 < S := Finset.prod_pos (fun i _ => by exact_mod_cast hs i) + have hfMass : 0 < ∑ k, f k := Finset.sum_pos (fun k _ => hf k) Finset.univ_nonempty + have hg (k) : 0 ≤ g k := mul_nonneg hR.le (Nat.cast_nonneg _) + have hh (k) : 0 ≤ h k := mul_nonneg hS.le (Nat.cast_nonneg _) + have hgerr (k) : |g k - f k| ≤ (2 * ε) * f k := by + exact (rectangularResidueCount_relative_error (a k) (b k) r (v k) (hab k) hr + ((hsmallR k).trans hε.le)).trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (hsmallR k) (by norm_num)) (hf k).le) + have hherr (k) : |h k - f k| ≤ (2 * ε) * f k := by + exact (rectangularResidueCount_relative_error (a k) (b k) s (w k) (hab k) hs + ((hsmallS k).trans hε.le)).trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (hsmallS k) (by norm_num)) (hf k).le) + have hgMass := finite_weight_mass_pos_of_relative_error f g hfMass (by linarith : 2 * ε < 1) hgerr + have hhMass := finite_weight_mass_pos_of_relative_error f h hfMass (by linarith : 2 * ε < 1) hherr + have hgsum : (∑ k, g k) = R * ∑ k, cr k := (Finset.mul_sum _ _ _).symm + have hhsum : (∑ k, h k) = S * ∑ k, cs k := (Finset.mul_sum _ _ _).symm + have hcr : 0 < ∑ k, cr k := (mul_pos_iff_of_pos_left hR).mp (hgsum ▸ hgMass) + have hcs : 0 < ∑ k, cs k := (mul_pos_iff_of_pos_left hS).mp (hhsum ▸ hhMass) + have hgnorm (k) : g k / (∑ j, g j) = cr k / (∑ j, cr j) := by + rw [hgsum] + dsimp only [g] + field_simp + have hhnorm (k) : h k / (∑ j, h j) = cs k / (∑ j, cs j) := by + rw [hhsum] + dsimp only [h] + field_simp + have hbound := normalized_finite_weights_pair_l1 f g h hg hh hfMass hgMass hhMass hgerr hherr + simp only [hgnorm, hhnorm] at hbound + refine ⟨hcr, hcs, hbound.trans_eq ?_⟩ + ring + +theorem exists_rectangular_residue_piece_discrepancy {K I : Type*} + [Fintype K] [Nonempty K] [Fintype I] + (a b : K → I → ℤ) (r s : I → ℤ) (v w : K → I → ℤ) + (hab : ∀ k i, a k i < b k i) (hr : ∀ i, 0 < r i) (hs : ∀ i, 0 < s i) + {ε : ℝ} (hε : ε < 1 / 2) + (hsmallR : ∀ k, (∑ i, (r i : ℝ) / ((b k i - a k i : ℤ) : ℝ)) ≤ ε) + (hsmallS : ∀ k, (∑ i, (s i : ℝ) / ((b k i - a k i : ℤ) : ℝ)) ≤ ε) + (F G : K → ℂ) (hG : ∀ k, ‖G k‖ ≤ 1) : + let nr : K → ℝ := fun k => rectangularResidueCount (a k) (b k) r (v k) + let ns : K → ℝ := fun k => rectangularResidueCount (a k) (b k) s (w k) + ∃ k, 0 < nr k ∧ 0 < ns k ∧ + ‖(∑ j, (nr j : ℂ) * F j) / ((∑ j, nr j : ℝ) : ℂ) - + (∑ j, (ns j : ℂ) * G j) / ((∑ j, ns j : ℝ) : ℂ)‖ - 8 * ε ≤ ‖F k - G k‖ := by + intro nr ns + obtain ⟨hnr, hns, hl1⟩ := rectangularResidueLaws_l1 a b r s v w hab hr hs hε hsmallR hsmallS + let p := FiniteProbabilityWeights.ofPositiveWeights nr (fun _ => Nat.cast_nonneg _) hnr + let q := FiniteProbabilityWeights.ofPositiveWeights ns (fun _ => Nat.cast_nonneg _) hns + obtain ⟨k, hk, hgap⟩ := p.exists_piece_discrepancy_of_weight_l1 q F G hG hl1 + have hk' : 0 < nr k / (∑ j, nr j) := hk + have hkS : 0 < ns k := by + change (0 : ℝ) < (rectangularResidueCount (a k) (b k) s (w k) : ℝ) + exact_mod_cast rectangularResidueCount_pos (a k) (b k) s (w k) (hab k) hs ((hsmallS k).trans_lt hε) + refine ⟨k, (div_pos_iff_of_pos_right hnr).mp hk', hkS, ?_⟩ + simpa only [p, q, FiniteProbabilityWeights.ofPositiveWeights_complexMean] using hgap + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def intervalCellLower (a : ℤ) {N : ℕ} (P : FiniteProgressionPartition N) (k : P.Label) : ℤ := + a + P.start k + +noncomputable def intervalCellUpper (a : ℤ) {N : ℕ} (P : FiniteProgressionPartition N) (k : P.Label) : ℤ := + a + P.start k + P.length k + +noncomputable def intervalResidueCell (a : ℤ) {N : ℕ} (P : FiniteProgressionPartition N) (r v : ℤ) : + ↥(Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a (a + N))) → P.Label := + fun x => P.cell (integerIntervalEquivFin a N ⟨x.val, (Finset.mem_filter.mp x.property).1⟩) + +theorem intervalResidueCell_eq_iff (a : ℤ) {N : ℕ} (P : FiniteProgressionPartition N) + (hstep : ∀ k, P.step k = 1) (r v : ℤ) + (x : ↥(Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a (a + N)))) (k : P.Label) : + intervalResidueCell a P r v x = k ↔ + intervalCellLower a P k ≤ x.val ∧ x.val < intervalCellUpper a P k := by + let y := integerIntervalEquivFin a N ⟨x.val, (Finset.mem_filter.mp x.property).1⟩ + have hy : (y.val : ℤ) = x.val - a := integerIntervalEquivFin_val a N _ + change P.cell y = k ↔ _ + rw [P.cell_eq_iff_of_step_one hstep] + unfold intervalCellLower intervalCellUpper + constructor + · rintro ⟨hlo, hhi⟩ + have hlo' : (P.start k : ℤ) ≤ y.val := by exact_mod_cast hlo + have hhi' : (y.val : ℤ) < (P.start k : ℤ) + P.length k := by exact_mod_cast hhi + omega + · rintro ⟨hlo, hhi⟩ + constructor + · have h : (P.start k : ℤ) ≤ y.val := by omega + exact_mod_cast h + · have h : (y.val : ℤ) < (P.start k : ℤ) + P.length k := by omega + exact_mod_cast h + +noncomputable def intervalResidueCellEquiv (a : ℤ) {N : ℕ} (P : FiniteProgressionPartition N) + (hstep : ∀ k, P.step k = 1) (hpos : ∀ k, 0 < P.length k) (r v : ℤ) (k : P.Label) : + {x : ↥(Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a (a + N))) // + intervalResidueCell a P r v x = k} ≃ + ↥(Finset.filter (fun x => x ≡ v [ZMOD r]) + (Finset.Ico (intervalCellLower a P k) (intervalCellUpper a P k))) where + toFun x := ⟨x.val.val, Finset.mem_filter.mpr + ⟨Finset.mem_Ico.mpr ((intervalResidueCell_eq_iff a P hstep r v x.val k).mp x.property), + (Finset.mem_filter.mp x.val.property).2⟩⟩ + invFun x := by + have hx := Finset.mem_filter.mp x.property + have hinterval := Finset.mem_Ico.mp hx.1 + have hend := P.end_le_of_step_one hstep k (hpos k) + have hend' : (P.start k : ℤ) + P.length k ≤ N := by exact_mod_cast hend + have hstart : (0 : ℤ) ≤ P.start k := Int.natCast_nonneg _ + have houter : x.val ∈ Finset.Ico a (a + N) := by + simp only [intervalCellLower, intervalCellUpper] at hinterval + exact Finset.mem_Ico.mpr ⟨by omega, by omega⟩ + let y : ↥(Finset.filter (fun z => z ≡ v [ZMOD r]) (Finset.Ico a (a + N))) := + ⟨x.val, Finset.mem_filter.mpr ⟨houter, hx.2⟩⟩ + exact ⟨y, (intervalResidueCell_eq_iff a P hstep r v y k).mpr hinterval⟩ + left_inv _ := rfl + right_inv _ := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +abbrev IntegerResidueBox {I : Type*} (a b r v : I → ℤ) := + ∀ i, ↥(Finset.filter (fun x => x ≡ v i [ZMOD r i]) (Finset.Ico (a i) (b i))) + +noncomputable def boxIntervalResidueCell {I : Type*} (a : I → ℤ) (N : I → ℕ) + (P : ∀ i, FiniteProgressionPartition (N i)) (r v : I → ℤ) + (x : IntegerResidueBox a (fun i => a i + N i) r v) : ∀ i, (P i).Label := + fun i => intervalResidueCell (a i) (P i) (r i) (v i) (x i) + +noncomputable def boxIntervalResidueCellEquiv {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i k, (P i).step k = 1) (hpos : ∀ i k, 0 < (P i).length k) + (r v : I → ℤ) (k : ∀ i, (P i).Label) : + ↥(partitionCell (boxIntervalResidueCell a N P r v) k) ≃ + IntegerResidueBox (fun i => intervalCellLower (a i) (P i) (k i)) + (fun i => intervalCellUpper (a i) (P i) (k i)) r v := by + let e₁ : ↥(partitionCell (boxIntervalResidueCell a N P r v) k) ≃ + {x : IntegerResidueBox a (fun i => a i + N i) r v // + ∀ i, intervalResidueCell (a i) (P i) (r i) (v i) (x i) = k i} := + Equiv.subtypeEquivRight (fun x => by + simp only [mem_partitionCell, boxIntervalResidueCell, funext_iff]) + exact e₁.trans (Equiv.subtypePiEquivPi.trans (Equiv.piCongrRight (fun i => + intervalResidueCellEquiv (a i) (P i) (hstep i) (hpos i) (r i) (v i) (k i)))) + +theorem boxIntervalResidueCell_card {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i k, (P i).step k = 1) (hpos : ∀ i k, 0 < (P i).length k) + (r v : I → ℤ) (k : ∀ i, (P i).Label) : + (partitionCell (boxIntervalResidueCell a N P r v) k).card = + rectangularResidueCount (fun i => intervalCellLower (a i) (P i) (k i)) + (fun i => intervalCellUpper (a i) (P i) (k i)) r v := by + have he := Fintype.card_congr (boxIntervalResidueCellEquiv a N P hstep hpos r v k) + calc + _ = Fintype.card (IntegerResidueBox (fun i => intervalCellLower (a i) (P i) (k i)) + (fun i => intervalCellUpper (a i) (P i) (k i)) r v) := by + simpa only [Fintype.card_coe] using he + _ = _ := (rectangularResidueCount_eq_card _ _ _ _).symm + +theorem boxIntervalResidue_mixture {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i k, (P i).step k = 1) (hpos : ∀ i k, 0 < (P i).length k) + (r v : I → ℤ) (f : IntegerResidueBox a (fun i => a i + N i) r v → ℂ) : + (𝔼 x, f x) = ∑ k : (∀ i, (P i).Label), + ((rectangularResidueCount (fun i => intervalCellLower (a i) (P i) (k i)) + (fun i => intervalCellUpper (a i) (P i) (k i)) r v : ℝ) / + (∑ j : (∀ i, (P i).Label), (rectangularResidueCount + (fun i => intervalCellLower (a i) (P i) (j i)) + (fun i => intervalCellUpper (a i) (P i) (j i)) r v : ℝ)) : ℂ) * + (𝔼 x ∈ partitionCell (boxIntervalResidueCell a N P r v) k, f x) := by + have hm := complex_expect_partition_count_weights (boxIntervalResidueCell a N P r v) f + simpa only [boxIntervalResidueCell_card a N P hstep hpos r v] using hm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/BufferedIntegerLift.lean b/lean/OAI/Combinatorics/Progressions/Lattices/BufferedIntegerLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bdcf86c490ae730e625d914d12c1bce2b303e15 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/BufferedIntegerLift.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.Progressions.Dynamics.FlatPatchReset + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def nearestIntegerLift {m : ℕ} (x : Fin m → ℝ) : Fin m → ℤ := + fun i => round (x i) + +theorem nearestIntegerLift_close {m : ℕ} (x : Fin m → ℝ) (i : Fin m) : + |x i - (nearestIntegerLift x i : ℝ)| ≤ 1 / 2 := abs_sub_round (x i) + +namespace PatchKernel + +theorem buffered_lift_unique {m : ℕ} (Ψ : PatchKernel m) (x : Fin m → ℝ) + (β γ : Fin m → ℤ) (hβ : ∀ i, |x i - (β i : ℝ)| ≤ 1 / 2) + (hγ : Ψ.value (fun i => x i - (γ i : ℝ)) ≠ 0) : γ = β := by + apply (constantSlots x).integer_unique (b := γ) (c := β) (by norm_num : (1 : ℝ) / 4 + 1 / 2 < 1) + · intro i + simpa only [TriangularSlots.residual, constantSlots, abs_sub_comm] using Ψ.support _ hγ i + · intro i + simpa only [TriangularSlots.residual, constantSlots, abs_sub_comm] using hβ i + +theorem buffered_lift_value_eq {m : ℕ} (Ψ : PatchKernel m) (x : Fin m → ℝ) + (β γ : Fin m → ℤ) (hβ : ∀ i, |x i - (β i : ℝ)| ≤ 1 / 2) + (hmatch : Ψ.value (fun i => x i - (β i : ℝ)) ≠ 0 → γ = β) + (f : (Fin m → ℤ) → ℝ) : + Ψ.value (fun i => x i - (γ i : ℝ)) * f γ = Ψ.value (fun i => x i - (β i : ℝ)) * f β := by + by_cases h : Ψ.value (fun i => x i - (β i : ℝ)) = 0 + · have hzero : Ψ.value (fun i => x i - (γ i : ℝ)) = 0 := by + by_contra hγ + exact hγ (by rw [Ψ.buffered_lift_unique x β γ hβ hγ, h]) + rw [hzero, h, zero_mul, zero_mul] + · rw [hmatch h] + +theorem buffered_sum_eq_nearest {m : ℕ} (Ψ : PatchKernel m) (x : Fin m → ℝ) + (f : (Fin m → ℤ) → ℝ) : + (∑' β, Ψ.value (fun i => x i - (β i : ℝ)) * f β) = + Ψ.value (fun i => x i - (nearestIntegerLift x i : ℝ)) * f (nearestIntegerLift x) := by + classical + apply tsum_eq_single (nearestIntegerLift x) + intro γ hγ + have hzero : Ψ.value (fun i => x i - (γ i : ℝ)) = 0 := by + by_contra hn + exact hγ (Ψ.buffered_lift_unique x _ γ (nearestIntegerLift_close x) hn) + rw [hzero, zero_mul] + +end PatchKernel +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CRTInactiveDensityGoodPrimeDeletion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CRTInactiveDensityGoodPrimeDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..c948f03cd49d7a20b73926d56f3d68c9828f6088 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CRTInactiveDensityGoodPrimeDeletion.lean @@ -0,0 +1,202 @@ +import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialInputAffineLaw +import OAI.Combinatorics.Progressions.Polynomial.PrimePowerPolynomialUnchargedDensity + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators Classical + +theorem primePower_integer_polynomial_shifted_uncharged_density + {V : Type*} [Fintype V] {s : ℕ} (hs : 0 < s) + {J : Fin s → Type*} [∀ j, Fintype (J j)] + (p A : ℕ) [NeZero p] (hp : p.Prime) (C : ℝ) (hC : 0 ≤ C) + (hP : ((Fintype.card (Sigma J) + 2 : ℕ) : ℝ) ≤ modularRankDecayExponent s C) + (F : ∀ j, J j → MvPolynomial V ℤ) + (hF : ∀ j i, (F j i).totalDegree ≤ j.val + 1) + (hrank : ∀ (B : ℕ), 0 < B → B ≤ A → ∀ (j : Fin s) + (row : J j → ZMod (p ^ B)), (∃ i, IsUnit (row i)) → + integerPolynomialRankProbability p B j.val (F j) row ≤ (p : ℝ) ^ (-C * B)) + (r : V → ZMod (p ^ A)) (z : ∀ j, J j → ZMod (p ^ A)) : + let law := FiniteProbabilityWeights.uniform (V → ZMod (p ^ A)) + let Y := fun (x : V → ZMod (p ^ A)) j i => + eval₂ (Int.castRingHom (ZMod (p ^ A))) (fun v => r v + x v) (F j i) + |(Fintype.card (∀ j, J j → ZMod (p ^ A)) : ℝ) * finiteImageMass law Y z - 1| ≤ + 2 / (p : ℝ) ^ 2 ∧ + (Fintype.card (∀ j, J j → ZMod (p ^ A)) : ℝ) * finiteImageMass law Y z ≤ + 1 + 2 / (p : ℝ) ^ 2 := by + dsimp only + let law := FiniteProbabilityWeights.uniform (V → ZMod (p ^ A)) + let Y := fun (x : V → ZMod (p ^ A)) j i => + eval₂ (Int.castRingHom (ZMod (p ^ A))) (fun v => r v + x v) (F j i) + have hdecay (χ : AddChar (∀ j, J j → ZMod (p ^ A)) ℂ) (_hχ : χ ≠ 1) : + ‖finiteImageCharacteristic law Y χ‖ ≤ + (orderOf χ : ℝ) ^ (-modularRankDecayExponent s C) := by + have hlocal := primePower_polynomial_image_characteristic_decay hs p A 0 0 hp C hC + (fun j i => map (Int.castRingHom (ZMod (p ^ A))) (F j i)) + (fun j i => (totalDegree_map_le _ _).trans (hF j i)) + (by + intro B hB hBA j row hunit + rw [primePowerHomogeneousRankProbability_integerPolynomial] + exact hrank B hB hBA j row hunit) + r χ + simpa only [law, Y, eval_map, Nat.zero_add, pow_zero, Nat.cast_one, Real.one_rpow, + one_mul] using hlocal + have hann (x : ∀ j, J j → ZMod (p ^ A)) : (p ^ A) • x = 0 := by + ext j i + simp only [Pi.smul_apply, nsmul_eq_mul, ZMod.natCast_self, zero_mul, Pi.zero_apply] + have h := finiteImage_uncharged_prime_density_rpow (taggedIntegerResidue J (p ^ A)) + (taggedIntegerResidue_surjective J (p ^ A)) hp hann law Y hP hdecay z + have hd : |(Fintype.card (∀ j, J j → ZMod (p ^ A)) : ℝ) * finiteImageMass law Y z - 1| ≤ + 2 / (p : ℝ) ^ 2 := by + simpa only [← Nat.card_eq_fintype_card] using h + exact ⟨hd, by linarith [(abs_le.mp hd).2]⟩ + +theorem localPrimePowerIntegerPolynomialOutput_uncharged_density + {V : Type*} [Fintype V] {s : ℕ} (hs : 0 < s) + {J : Fin s → Type*} [∀ j, Fintype (J j)] + (p A : ℕ) [NeZero p] (hp : p.Prime) (C : ℝ) (hC : 0 ≤ C) + (hP : ((Fintype.card (Sigma J) + 2 : ℕ) : ℝ) ≤ modularRankDecayExponent s C) + (F : ∀ j, J j → MvPolynomial V ℤ) + (hF : ∀ j i, (F j i).totalDegree ≤ j.val + 1) + (hrank : ∀ (B : ℕ), 0 < B → B ≤ A → ∀ (j : Fin s) + (row : J j → ZMod (p ^ B)), (∃ i, IsUnit (row i)) → + integerPolynomialRankProbability p B j.val (F j) row ≤ (p : ℝ) ^ (-C * B)) + (r : V → ZMod (p ^ A)) (z : Sigma J → ZMod (p ^ A)) : + |rationalOutputDensity (FiniteProbabilityWeights.uniform (V → ZMod (p ^ A))) + (localPrimePowerIntegerPolynomialOutput p A 0 F r) (p ^ A) z - 1| ≤ + 2 / (p : ℝ) ^ 2 ∧ + rationalOutputDensity (FiniteProbabilityWeights.uniform (V → ZMod (p ^ A))) + (localPrimePowerIntegerPolynomialOutput p A 0 F r) (p ^ A) z ≤ + 1 + 2 / (p : ℝ) ^ 2 := by + let law := FiniteProbabilityWeights.uniform (V → ZMod (p ^ A)) + let Y := fun (x : V → ZMod (p ^ A)) (j : Sigma J) => + (localPrimePowerIntegerPolynomialOutput p A 0 F r x j : ZMod (p ^ A)) + let curry := (taggedPolynomialOutputCurry J (p ^ A)).toEquiv + have hY : (fun x => curry (Y x)) = fun x j i => + eval₂ (Int.castRingHom (ZMod (p ^ A))) (fun v => r v + x v) (F j i) := by + funext x j i + change (localPrimePowerIntegerPolynomialOutput p A 0 F r x ⟨j, i⟩ : ZMod (p ^ A)) = _ + rw [localPrimePowerIntegerPolynomialOutput_reduce] + simp only [pow_zero, one_mul] + have hdensity : rationalOutputDensity law + (localPrimePowerIntegerPolynomialOutput p A 0 F r) (p ^ A) z = + (Fintype.card (∀ j, J j → ZMod (p ^ A)) : ℝ) * finiteImageMass law + (fun x j i => eval₂ (Int.castRingHom (ZMod (p ^ A))) + (fun v => r v + x v) (F j i)) (curry z) := by + change (Fintype.card (Sigma J → ZMod (p ^ A)) : ℝ) * finiteImageMass law Y z = _ + rw [Fintype.card_congr curry, ← finiteImageMass_outputEquiv law Y curry z, hY] + rw [hdensity] + exact primePower_integer_polynomial_shifted_uncharged_density hs p A hp C hC hP + F hF hrank r (curry z) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators Classical + +theorem exists_goodPrimeDeletionCutoff {δ : ℝ} (hδ : 0 < δ) : + ∃ cutoff : ℕ, 0 < cutoff ∧ 2 / (cutoff : ℝ) ≤ 1 / 2 ∧ 4 / (cutoff : ℝ) ≤ δ := by + obtain ⟨cutoff, hcutoff⟩ := exists_nat_ge (max 4 (4 / δ)) + have hfour : (4 : ℝ) ≤ cutoff := (le_max_left _ _).trans hcutoff + have hpos : (0 : ℝ) < cutoff := by linarith + refine ⟨cutoff, Nat.cast_pos.mp hpos, ?_, ?_⟩ + · apply (div_le_iff₀ hpos).mpr + linarith + · apply (div_le_iff₀ hpos).mpr + have h := (div_le_iff₀ hδ).mp ((le_max_right _ _).trans hcutoff) + linarith + +theorem indexed_good_prime_product_tail {L : Type*} + (p : L → ℕ) (hp : Function.Injective p) (S : Finset L) (f : L → ℝ) + (cutoff : ℕ) (hcutoff : 0 < cutoff) (hsmall : 2 / (cutoff : ℝ) ≤ 1 / 2) + (hlarge : ∀ l ∈ S, cutoff < p l) (hnonneg : ∀ l ∈ S, 0 ≤ f l) + (herror : ∀ l ∈ S, |f l - 1| ≤ 2 / (p l : ℝ) ^ 2) : + |(∏ l ∈ S, f l) - 1| ≤ 4 / (cutoff : ℝ) := by + have h := finite_positive_product_tail (S.image p) (Function.extend p f (fun _ => 1)) + hcutoff (by norm_num : (0 : ℝ) ≤ 2) + (by rintro q hq; obtain ⟨l, hl, rfl⟩ := Finset.mem_image.mp hq; exact hlarge l hl) + (by + rintro q hq + obtain ⟨l, hl, rfl⟩ := Finset.mem_image.mp hq + simpa only [hp.extend_apply] using hnonneg l hl) + (by + rintro q hq + obtain ⟨l, hl, rfl⟩ := Finset.mem_image.mp hq + simpa only [hp.extend_apply] using herror l hl) hsmall + simpa only [Finset.prod_image hp.injOn, hp.extend_apply, show (2 : ℝ) * 2 = 4 by norm_num] using h + +theorem crt_integer_polynomial_inactive_good_prime_deletion + {L V I Z : Type*} [Fintype L] [Fintype V] [Fintype I] {s : ℕ} (hs : 0 < s) + {J : Fin s → Type*} [∀ j, Fintype (J j)] + (inactive : FiniteProbabilityWeights I) (gridPoint : I → Z) + (p A bad e : L → ℕ) [∀ l, NeZero (p l)] + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (C : ℝ) (hC : 0 ≤ C) + (hP : ((Fintype.card (Sigma J) + 2 : ℕ) : ℝ) ≤ modularRankDecayExponent s C) + (F : I → ∀ j, J j → MvPolynomial V ℤ) + (hF : ∀ i j a, (F i j a).totalDegree ≤ j.val + 1) + (hrank : ∀ i l B, bad l < B → B ≤ A l → ∀ j + (row : J j → ZMod (p l ^ B)), (∃ a, IsUnit (row a)) → + integerPolynomialRankProbability (p l) B j.val (F i j) row ≤ (p l : ℝ) ^ (-C * B)) + (r : I → ∀ l, V → ZMod (p l ^ A l)) + (cutoff : ℕ) (hcutoff : 0 < cutoff) (hsmall : 2 / (cutoff : ℝ) ≤ 1 / 2) + {δ : ℝ} (hδ : 0 ≤ δ) (haccuracy : 4 / (cutoff : ℝ) ≤ δ) + (retained : Finset L) + (hretained : ∀ l, l ∉ retained → cutoff < p l ∧ bad l = 0 ∧ e l = 0) + (gridVolume : ℝ) (hvolume : 0 ≤ gridVolume) (z : Z) + (β : Sigma J → ZMod (∏ l, p l ^ A l)) : + letI : NeZero (∏ l, p l ^ A l) := + ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (p l)))⟩ + let full := rationalInactiveForecast inactive + (fun _ => crtPrimePowerPolynomialLaw (V := V) p A) gridPoint + (fun i => crtPrimePowerIntegerPolynomialOutput p A e + (primePower_crt_coprime p A hp hinj) (F i) (r i)) + (∏ l, p l ^ A l) gridVolume z β + let truncated := gridVolume * inactive.fiberMean gridPoint z (fun i => + ∏ l ∈ retained, + rationalOutputDensity (FiniteProbabilityWeights.uniform (V → ZMod (p l ^ A l))) + (localPrimePowerIntegerPolynomialOutput (p l) (A l) (e l) (F i) (r i l)) (p l ^ A l) + (fun j => ZMod.castHom (Finset.dvd_prod_of_mem (fun l => p l ^ A l) + (Finset.mem_univ l)) (ZMod (p l ^ A l)) (β j))) + (1 - δ) * truncated ≤ full ∧ full ≤ (1 + δ) * truncated := by + let : NeZero (∏ l, p l ^ A l) := + ⟨Finset.prod_ne_zero_iff.mpr (fun l _ => pow_ne_zero _ (NeZero.ne (p l)))⟩ + dsimp only + rw [crt_integer_polynomial_rational_inactive_density_product] + let factor (i : I) (l : L) := + rationalOutputDensity (FiniteProbabilityWeights.uniform (V → ZMod (p l ^ A l))) + (localPrimePowerIntegerPolynomialOutput (p l) (A l) (e l) (F i) (r i l)) (p l ^ A l) + (fun j => ZMod.castHom (Finset.dvd_prod_of_mem (fun l => p l ^ A l) + (Finset.mem_univ l)) (ZMod (p l ^ A l)) (β j)) + have hnonneg (i : I) (l : L) : 0 ≤ factor i l := rationalOutputDensity_nonneg _ _ _ _ + apply inactive.fiberMean_prod_bounds_of_omitted_prod_sub_one_le gridPoint z + gridVolume δ hvolume hδ retained factor hnonneg + intro i + apply (indexed_good_prime_product_tail p hinj (Finset.univ \ retained) (factor i) + cutoff hcutoff hsmall ?_ (fun l _ => hnonneg i l) ?_).trans haccuracy + · intro l hl + exact (hretained l (Finset.mem_sdiff.mp hl).2).1 + · intro l hl + obtain ⟨_, hbad, he⟩ := hretained l (Finset.mem_sdiff.mp hl).2 + dsimp only [factor] + rw [he] + apply (localPrimePowerIntegerPolynomialOutput_uncharged_density hs (p l) (A l) + (hp l) C hC hP (F i) (hF i) ?_ (r i l) _).1 + intro B hB hBA j row hunit + exact hrank i l B (by simpa only [hbad] using hB) hBA j row hunit + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CRTIntegerRepresentative.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CRTIntegerRepresentative.lean new file mode 100644 index 0000000000000000000000000000000000000000..102774771a64b6e2da88b5e43f43f63c7e47657b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CRTIntegerRepresentative.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Fourier.CRTConfigurationTorus +import OAI.Combinatorics.Progressions.Polynomial.PolynomialPatchProductBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators +open MvPolynomial + +variable {J : Type*} [Fintype J] [DecidableEq J] (N : J → ℕ) + [NeZero (∏ j, N j)] (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) + +noncomputable def crtIntegerCoefficient (j : J) : ℤ := + ((ZMod.prodEquivPi N hN).symm (Pi.single j (1 : ZMod (N j)))).val + +noncomputable def crtIntegerRepresentative (u : J → ℤ) : ℤ := + ∑ j, crtIntegerCoefficient N hN j * u j + +theorem crtIntegerRepresentative_cast (u : J → ℤ) : + (crtIntegerRepresentative N hN u : ZMod (∏ j, N j)) = + (ZMod.prodEquivPi N hN).symm (fun j => (u j : ZMod (N j))) := by + let E := ZMod.prodEquivPi N hN + have hcoeff (j : J) : (crtIntegerCoefficient N hN j : ZMod (∏ j, N j)) = + E.symm (Pi.single j (1 : ZMod (N j))) := by + simp only [crtIntegerCoefficient, Int.cast_natCast, ZMod.natCast_zmod_val, E] + calc + _ = ∑ j, E.symm (Pi.single j (1 : ZMod (N j))) * (u j : ZMod (∏ j, N j)) := by + simp only [crtIntegerRepresentative, Int.cast_sum, Int.cast_mul, hcoeff] + _ = E.symm (∑ j, Pi.single j (1 : ZMod (N j)) * (u j : (j : J) → ZMod (N j))) := by + simp only [map_sum, map_mul, map_intCast] + _ = _ := by + congr 1 + funext j + simp only [Finset.sum_apply, Pi.mul_apply, Pi.intCast_apply] + rw [Finset.sum_eq_single j] + · simp only [Pi.single_eq_same, one_mul] + · intro i _ hij + rw [Pi.single_eq_of_ne hij.symm, zero_mul] + · simp + +noncomputable def crtRepresentativePolynomial : MvPolynomial J ℝ := + ∑ j, ((crtIntegerCoefficient N hN j : ℝ) / (∏ i, N i : ℕ)) • X j + +omit [NeZero (∏ j, N j)] in +theorem crtRepresentativePolynomial_degree : + crtRepresentativePolynomial N hN ∈ weightedSupportLE (fun _ => 1) 1 := by + apply Submodule.sum_mem + intro j _ + exact (weightedSupportLE _ _).smul_mem _ (weightedSupportLE_X _ j) + +omit [NeZero (∏ j, N j)] in +theorem crtRepresentativePolynomial_eval (u : J → ℤ) : + aeval (fun j => (u j : ℝ)) (crtRepresentativePolynomial N hN) = + (crtIntegerRepresentative N hN u : ℝ) / (∏ i, N i : ℕ) := by + simp only [crtRepresentativePolynomial, map_sum, map_smul, aeval_X, + smul_eq_mul, crtIntegerRepresentative, Int.cast_sum, Int.cast_mul, Finset.sum_div] + apply Finset.sum_congr rfl + intro j _ + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CRTPrescribedProductStep.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CRTPrescribedProductStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7f4862a66da349dbdebb6f222e5c6e3c1b9bb84 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CRTPrescribedProductStep.lean @@ -0,0 +1,124 @@ +import Mathlib.Data.Nat.GCD.BigOperators +import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialInputAffineLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {L V : Type*} [Fintype L] [DecidableEq L] + +def prescribedCRTCofactor (p e : L → ℕ) (l : L) : ℕ := + ∏ k ∈ Finset.univ.erase l, p k ^ e k + +theorem prescribedCRTProductStep_eq (p e : L → ℕ) (l : L) : + (∏ k, p k ^ e k) = p l ^ e l * prescribedCRTCofactor p e l := by + exact (Finset.mul_prod_erase Finset.univ (fun k => p k ^ e k) + (Finset.mem_univ l)).symm + +theorem prescribedCRTCofactor_coprime (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) (l : L) : + (prescribedCRTCofactor p e l).Coprime (p l ^ A l) := by + apply Nat.coprime_prod_left_iff.mpr + intro k hk + exact Nat.coprime_pow_primes (e k) (A l) (hp k) (hp l) + (fun h => (Finset.mem_erase.mp hk).1 (hinj h)) + +def prescribedCRTCofactorUnit (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) (l : L) : + (ZMod (p l ^ A l))ˣ := + ZMod.unitOfCoprime (prescribedCRTCofactor p e l) + (prescribedCRTCofactor_coprime p A e hp hinj l) + +@[simp] theorem prescribedCRTCofactorUnit_coe (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) (l : L) : + (prescribedCRTCofactorUnit p A e hp hinj l : ZMod (p l ^ A l)) = + prescribedCRTCofactor p e l := rfl + +theorem prescribedCRTCofactor_isUnit (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) (l : L) : + IsUnit (prescribedCRTCofactor p e l : ZMod (p l ^ A l)) := + (prescribedCRTCofactorUnit p A e hp hinj l).isUnit + +theorem prescribedCRTProductStep_cast (p A e : L → ℕ) (l : L) : + ((∏ k, p k ^ e k : ℕ) : ZMod (p l ^ A l)) = + (p l : ZMod (p l ^ A l)) ^ e l * prescribedCRTCofactor p e l := by + rw [prescribedCRTProductStep_eq p e l, Nat.cast_mul, Nat.cast_pow] + +def prescribedCRTProductStepEquiv (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) : + (∀ l, V → ZMod (p l ^ A l)) ≃+ (∀ l, V → ZMod (p l ^ A l)) where + toFun x l v := prescribedCRTCofactorUnit p A e hp hinj l * x l v + invFun x l v := ↑(prescribedCRTCofactorUnit p A e hp hinj l)⁻¹ * x l v + left_inv x := by + funext l v + simp only [← mul_assoc, Units.inv_mul, one_mul] + right_inv x := by + funext l v + simp only [← mul_assoc, Units.mul_inv, one_mul] + map_add' x y := by + funext l v + exact mul_add _ _ _ + +@[simp] theorem prescribedCRTProductStepEquiv_apply (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (x : ∀ l, V → ZMod (p l ^ A l)) (l : L) (v : V) : + prescribedCRTProductStepEquiv p A e hp hinj x l v = + (prescribedCRTCofactor p e l : ZMod (p l ^ A l)) * x l v := rfl + +theorem prescribedCRTProductStepEquiv_local_step (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (x : ∀ l, V → ZMod (p l ^ A l)) (l : L) (v : V) : + (p l : ZMod (p l ^ A l)) ^ e l * + prescribedCRTProductStepEquiv p A e hp hinj x l v = + ((∏ k, p k ^ e k : ℕ) : ZMod (p l ^ A l)) * x l v := by + rw [prescribedCRTProductStepEquiv_apply, prescribedCRTProductStep_cast, mul_assoc] + +theorem prescribedCRTProductStepEquiv_symm_local_step (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (x : ∀ l, V → ZMod (p l ^ A l)) (l : L) (v : V) : + (p l : ZMod (p l ^ A l)) ^ e l * x l v = + ((∏ k, p k ^ e k : ℕ) : ZMod (p l ^ A l)) * + (prescribedCRTProductStepEquiv p A e hp hinj).symm x l v := by + simpa only [AddEquiv.apply_symm_apply] using + prescribedCRTProductStepEquiv_local_step p A e hp hinj + ((prescribedCRTProductStepEquiv p A e hp hinj).symm x) l v + +theorem prescribedCRTPolynomialInput_product_step (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k))) + (origin x : ∀ l, V → ZMod (p l ^ A l)) (v : V) : + prescribedCRTPolynomialInput p A e hq origin + (prescribedCRTProductStepEquiv p A e hp hinj x) v = + crtInput (fun l => p l ^ A l) hq origin v + + (∏ l, p l ^ e l : ℕ) * crtInput (fun l => p l ^ A l) hq x v := by + apply (ZMod.prodEquivPi (fun l => p l ^ A l) hq).injective + funext l + rw [ZMod.prodEquivPi_apply, ZMod.prodEquivPi_apply] + simp only [prescribedCRTPolynomialInput, map_add, map_mul, map_natCast] + rw [crtInput_reduce (fun l => p l ^ A l) hq _ l v, + crtInput_reduce (fun l => p l ^ A l) hq origin l v, + crtInput_reduce (fun l => p l ^ A l) hq x l v] + exact congrArg (origin l v + ·) + (prescribedCRTProductStepEquiv_local_step p A e hp hinj x l v) + +theorem prescribedCRTPolynomialInput_product_step_symm (p A e : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (hq : Pairwise (fun l k => (p l ^ A l).Coprime (p k ^ A k))) + (origin x : ∀ l, V → ZMod (p l ^ A l)) (v : V) : + prescribedCRTPolynomialInput p A e hq origin x v = + crtInput (fun l => p l ^ A l) hq origin v + + (∏ l, p l ^ e l : ℕ) * crtInput (fun l => p l ^ A l) hq + ((prescribedCRTProductStepEquiv p A e hp hinj).symm x) v := by + simpa only [AddEquiv.apply_symm_apply] using + prescribedCRTPolynomialInput_product_step p A e hp hinj hq origin + ((prescribedCRTProductStepEquiv p A e hp hinj).symm x) v + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CRTProgressionVanishing.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CRTProgressionVanishing.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4022c73b71dabf896864cf1a3a47187e9b919ea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CRTProgressionVanishing.lean @@ -0,0 +1,219 @@ +import OAI.Combinatorics.Progressions.Estimates.InteriorIntervalCutoff +import OAI.Combinatorics.Progressions.Fourier.CRTConfigurationTorus +import OAI.Combinatorics.Progressions.Fourier.TorusCellBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem progression_window_radius_bounds {k : ℕ} (hk : 1 ≤ k) : + 0 < 1 / (16 * (k : ℝ)) ∧ 1 / (16 * (k : ℝ)) ≤ 1 / 16 := by + have hkR : (1 : ℝ) ≤ k := by exact_mod_cast hk + exact ⟨by positivity, one_div_le_one_div_of_le (by norm_num) (by linarith)⟩ + +theorem residue_base_window_bound {N k : ℕ} [NeZero N] (hk : 1 ≤ k) + (x : ZMod N) + (hx : dist (ZMod.toAddCircle x) ((1 / 4 : ℝ) : UnitAddCircle) ≤ 1 / (16 * (k : ℝ))) : + 2 * x.val < N := by + obtain ⟨_, hr⟩ := progression_window_radius_bounds hk + have hc : 1 / (16 * (k : ℝ)) < 1 / 4 ∧ (1 / 4 : ℝ) < 1 - 1 / (16 * (k : ℝ)) := by + constructor <;> linarith + have he := residue_fraction_close_to_interior_center x hc hx + have hfrac : (x.val : ℝ) / N < 1 / 2 := by linarith [(abs_le.mp he).2] + have hNR : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + have hmul : 2 * (x.val : ℝ) < N := by linarith [(div_lt_iff₀ hNR).mp hfrac] + exact_mod_cast hmul + +theorem residue_step_window_bounds {N k : ℕ} [NeZero N] (hk : 1 ≤ k) + (d : ZMod N) + (hd : dist (ZMod.toAddCircle d) ((1 / (4 * (k : ℝ)) : ℝ) : UnitAddCircle) ≤ + 1 / (16 * (k : ℝ))) : + 0 < d.val ∧ 2 * k * d.val < N := by + obtain ⟨hr0, hr⟩ := progression_window_radius_bounds hk + have hkR : (0 : ℝ) < k := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hk) + have heq : 1 / (4 * (k : ℝ)) = 4 * (1 / (16 * (k : ℝ))) := by ring + have hc : 1 / (16 * (k : ℝ)) < 1 / (4 * (k : ℝ)) ∧ + 1 / (4 * (k : ℝ)) < 1 - 1 / (16 * (k : ℝ)) := by + rw [heq] + constructor <;> linarith + have he := residue_fraction_close_to_interior_center d hc hd + have hf0 : 0 < (d.val : ℝ) / N := by rw [heq] at he; linarith [(abs_le.mp he).1] + have heq' : 1 / (2 * (k : ℝ)) = 8 * (1 / (16 * (k : ℝ))) := by ring + have hf1 : (d.val : ℝ) / N < 1 / (2 * (k : ℝ)) := by + rw [heq] at he + rw [heq'] + linarith [(abs_le.mp he).2] + have hNR : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + constructor + · have h := (lt_div_iff₀ hNR).mp hf0 + simpa only [zero_mul, Nat.cast_pos] using h + · have h := (div_lt_div_iff₀ hNR (by positivity : 0 < 2 * (k : ℝ))).mp hf1 + have hh : 2 * (k : ℝ) * d.val < N := by nlinarith + exact_mod_cast hh + +theorem residue_progression_val_of_windows {N k : ℕ} [NeZero N] + (x d : ZMod N) (hx : 2 * x.val < N) (hd : 2 * k * d.val < N) + {i : ℕ} (hi : i < k) : + (x + (i : ZMod N) * d).val = x.val + i * d.val := by + have hid : i * d.val ≤ k * d.val := Nat.mul_le_mul_right _ hi.le + have hsum : x.val + i * d.val < N := by nlinarith + have he : x + (i : ZMod N) * d = ((x.val + i * d.val : ℕ) : ZMod N) := by simp + rw [he, ZMod.val_natCast_of_lt hsum] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +noncomputable def progressionTorusCenter {J : Type*} (k : ℕ) : J × Bool → UnitAddCircle := + fun t => if t.2 then ((1 / (4 * (k : ℝ)) : ℝ) : UnitAddCircle) else ((1 / 4 : ℝ) : UnitAddCircle) + +noncomputable def progressionTorusCutoff {J : Type*} [Fintype J] (k : ℕ) + (w : J × Bool → UnitAddCircle) : ℝ := + centeredTorusTent (64 * k) (progressionTorusCenter k) w + +theorem progressionTorusCutoff_range {J : Type*} [Fintype J] (k : ℕ) + (w : J × Bool → UnitAddCircle) : + 0 ≤ progressionTorusCutoff k w ∧ progressionTorusCutoff k w ≤ 1 := + centeredTorusTent_range _ _ _ + +theorem progressionTorusCutoff_lipschitz {J : Type*} [Fintype J] (k : ℕ) : + LipschitzWith (((64 * k : ℕ) : ℝ≥0) / 4) (progressionTorusCutoff (J := J) k) := + centeredTorusTent_lipschitz _ _ + +theorem progressionTorusCutoff_residue_support {J : Type*} [Fintype J] (N : J → ℕ) + [∀ j, NeZero (N j)] {k : ℕ} (hk : 1 ≤ k) + (u : (t : J × Bool) → ZMod (N t.1)) + (hu : progressionTorusCutoff k (fun t => ZMod.toAddCircle (u t)) ≠ 0) (j : J) : + 2 * (u (j, false)).val < N j ∧ + 0 < (u (j, true)).val ∧ 2 * k * (u (j, true)).val < N j := by + have hk0 : 0 < 64 * k := by omega + have hr : 4 / ((64 * k : ℕ) : ℝ) = 1 / (16 * (k : ℝ)) := by push_cast; ring + have hx := centeredTorusTent_coordinate_support hk0 (progressionTorusCenter k) + (fun t => ZMod.toAddCircle (u t)) hu (j, false) + have hd := centeredTorusTent_coordinate_support hk0 (progressionTorusCenter k) + (fun t => ZMod.toAddCircle (u t)) hu (j, true) + rw [hr] at hx hd + simp only [progressionTorusCenter, Bool.false_eq_true, ↓reduceIte] at hx + simp only [progressionTorusCenter, ↓reduceIte] at hd + exact ⟨residue_base_window_bound hk _ hx.le, residue_step_window_bounds hk _ hd.le⟩ + +theorem progressionTorusCutoff_residue_mean {J : Type*} [Fintype J] [DecidableEq J] + (N : J → ℕ) [∀ j, NeZero (N j)] {k : ℕ} (hk : 1 ≤ k) (hN : ∀ j, 64 * k ≤ N j) : + 1 / (2 * (128 * (k : ℝ)) ^ (Fintype.card J * 2)) ≤ + 𝔼 u : (t : J × Bool) → ZMod (N t.1), + progressionTorusCutoff k (fun t => ZMod.toAddCircle (u t)) := by + have h := centeredTorusTent_residue_mean (fun t : J × Bool => N t.1) + (show 0 < 64 * k by omega) (fun t => hN t.1) (progressionTorusCenter k) + simpa only [progressionTorusCutoff, Fintype.card_prod, Fintype.card_bool, Nat.cast_mul, + Nat.cast_ofNat, show (2 : ℝ) * (64 * (k : ℝ)) = 128 * k by ring] using h + +noncomputable def crtProgressionWeight {J : Type*} [Fintype J] (N : J → ℕ) + [∀ j, NeZero (N j)] (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) (k : ℕ) + (z : ZMod (∏ j, N j) × ZMod (∏ j, N j)) : ℝ := + progressionTorusCutoff k (crtConfigurationTorus N hN z) + +theorem crtProgressionWeight_range {J : Type*} [Fintype J] (N : J → ℕ) + [∀ j, NeZero (N j)] (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) (k : ℕ) + (z : ZMod (∏ j, N j) × ZMod (∏ j, N j)) : + 0 ≤ crtProgressionWeight N hN k z ∧ crtProgressionWeight N hN k z ≤ 1 := + progressionTorusCutoff_range _ _ + +theorem crtProgressionWeight_mean {J : Type*} [Fintype J] (N : J → ℕ) + [∀ j, NeZero (N j)] [NeZero (∏ j, N j)] (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) + {k : ℕ} (hk : 1 ≤ k) (hsize : ∀ j, 64 * k ≤ N j) : + 1 / (2 * (128 * (k : ℝ)) ^ (Fintype.card J * 2)) ≤ + 𝔼 z, crtProgressionWeight N hN k z := by + classical + have he := crt_configuration_expect N hN + (fun u => progressionTorusCutoff k (fun t => ZMod.toAddCircle (u t))) + change (𝔼 z, crtProgressionWeight N hN k z) = _ at he + rw [he] + exact progressionTorusCutoff_residue_mean N hk hsize + +theorem crtProgressionWeight_support {J : Type*} [Fintype J] (N : J → ℕ) + [∀ j, NeZero (N j)] (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) {k : ℕ} (hk : 1 ≤ k) + (x d : ZMod (∏ j, N j)) (h : crtProgressionWeight N hN k (x, d) ≠ 0) : + (∀ j, 0 < (ZMod.prodEquivPi N hN d j).val) ∧ + ∀ i : ℕ, i < k → ∀ j, + (ZMod.prodEquivPi N hN (x + (i : ZMod (∏ j, N j)) * d) j).val = + (ZMod.prodEquivPi N hN x j).val + i * (ZMod.prodEquivPi N hN d j).val := by + have hb (j : J) := progressionTorusCutoff_residue_support N hk + (crtConfigurationEquiv N hN (x, d)) h j + change ∀ j, 2 * (ZMod.prodEquivPi N hN x j).val < N j ∧ + 0 < (ZMod.prodEquivPi N hN d j).val ∧ + 2 * k * (ZMod.prodEquivPi N hN d j).val < N j at hb + refine ⟨fun j => (hb j).2.1, fun i hi j => ?_⟩ + have hv := residue_progression_val_of_windows (ZMod.prodEquivPi N hN x j) + (ZMod.prodEquivPi N hN d j) (hb j).1 (hb j).2.2 hi + simpa only [map_add, map_mul, map_natCast, Pi.add_apply, Pi.mul_apply, Pi.natCast_apply] using hv + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def IntegerVectorAPFree {J : Type*} (A : Set (J → ℤ)) (k : ℕ) : Prop := + ∀ a d : J → ℤ, d ≠ 0 → ∃ i : Fin k, a + (i.val : ℤ) • d ∉ A + +noncomputable def residueBoxIntegerPoint {J : Type*} (N : J → ℕ) + (u : (j : J) → ZMod (N j)) : J → ℤ := fun j => (u j).val + +theorem crtProgressionWeight_mul_prod_eq_zero {J : Type*} [Fintype J] [Nonempty J] + (N : J → ℕ) [∀ j, NeZero (N j)] (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) + {k : ℕ} (hk : 1 ≤ k) (f : ((j : J) → ZMod (N j)) → ℝ) + (hfree : IntegerVectorAPFree (residueBoxIntegerPoint N '' Function.support f) k) + (x d : ZMod (∏ j, N j)) : + crtProgressionWeight N hN k (x, d) * + (∏ i : Fin k, f (ZMod.prodEquivPi N hN (x + (i.val : ZMod (∏ j, N j)) * d))) = 0 := by + classical + by_cases hw : crtProgressionWeight N hN k (x, d) = 0 + · rw [hw, zero_mul] + obtain ⟨hstep, hval⟩ := crtProgressionWeight_support N hN hk x d hw + let a := residueBoxIntegerPoint N (ZMod.prodEquivPi N hN x) + let b := residueBoxIntegerPoint N (ZMod.prodEquivPi N hN d) + have hb : b ≠ 0 := by + intro h + let j : J := Classical.choice inferInstance + have hj : b j = 0 := congrFun h j + have hpos : (0 : ℤ) < b j := by + dsimp [b, residueBoxIntegerPoint] + exact_mod_cast hstep j + omega + obtain ⟨i, hi⟩ := hfree a b hb + have hzero : f (ZMod.prodEquivPi N hN (x + (i.val : ZMod (∏ j, N j)) * d)) = 0 := by + by_contra h + apply hi + refine ⟨ZMod.prodEquivPi N hN (x + (i.val : ZMod (∏ j, N j)) * d), h, ?_⟩ + funext j + change ((ZMod.prodEquivPi N hN (x + (i.val : ZMod (∏ j, N j)) * d) j).val : ℤ) = + ((ZMod.prodEquivPi N hN x j).val : ℤ) + (i.val : ℤ) * (ZMod.prodEquivPi N hN d j).val + exact_mod_cast hval i.val i.isLt j + rw [Finset.prod_eq_zero (Finset.mem_univ i) hzero, mul_zero] + +theorem crtProgressionWeight_product_mean_eq_zero {J : Type*} [Fintype J] [Nonempty J] + (N : J → ℕ) [∀ j, NeZero (N j)] [NeZero (∏ j, N j)] + (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) {k : ℕ} (hk : 1 ≤ k) + (f : ((j : J) → ZMod (N j)) → ℝ) + (hfree : IntegerVectorAPFree (residueBoxIntegerPoint N '' Function.support f) k) : + (𝔼 x, 𝔼 d, crtProgressionWeight N hN k (x, d) * + (∏ i : Fin k, f (ZMod.prodEquivPi N hN (x + (i.val : ZMod (∏ j, N j)) * d)))) = 0 := by + simp only [crtProgressionWeight_mul_prod_eq_zero N hN hk f hfree, Fintype.expect_const] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CRTValuationProduct.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CRTValuationProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..5da5e8a7050f323f628a678906bcb4446d89ed25 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CRTValuationProduct.lean @@ -0,0 +1,42 @@ +import Mathlib.Data.Nat.GCD.BigOperators +import Mathlib.NumberTheory.Padics.PadicVal.Basic + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem crtValuationProduct_finset_dvd {L : Type*} (p : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + (step : ℕ) (s : Finset L) : + (∏ l ∈ s, p l ^ padicValNat (p l) step) ∣ step := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert l s hls ih => + rw [Finset.prod_insert hls] + apply Nat.Coprime.mul_dvd_of_dvd_of_dvd _ pow_padicValNat_dvd ih + apply Nat.coprime_prod_right_iff.mpr + intro k hk + exact Nat.coprime_pow_primes _ _ (hp l) (hp k) + (fun h => hls (hinj h ▸ hk)) + +theorem crtValuationProduct_dvd {L : Type*} [Fintype L] (p : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) (step : ℕ) : + (∏ l, p l ^ padicValNat (p l) step) ∣ step := + crtValuationProduct_finset_dvd p hp hinj step Finset.univ + +theorem crtValuationProduct_le {L : Type*} [Fintype L] (p : L → ℕ) + (hp : ∀ l, (p l).Prime) (hinj : Function.Injective p) + {step : ℕ} (hstep : step ≠ 0) : + (∏ l, p l ^ padicValNat (p l) step) ≤ step := + Nat.le_of_dvd (Nat.pos_of_ne_zero hstep) (crtValuationProduct_dvd p hp hinj step) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CRTWindowScore.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CRTWindowScore.lean new file mode 100644 index 0000000000000000000000000000000000000000..89fd7d9bb4aafd8450e79b772b3dc4c5d42b835d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CRTWindowScore.lean @@ -0,0 +1,51 @@ +import OAI.Combinatorics.Progressions.Geometry.RepresentativeWindowTransport + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +variable {J : Type*} [Fintype J] [DecidableEq J] (N : J → ℕ) + [∀ j, NeZero (N j)] [NeZero (∏ j, N j)] + (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) + +theorem crt_representative_patch_score (s : ℕ) (hs : 1 ≤ s) + (f : ZMod (∏ j, N j) → ℝ) (w : RepresentativeWindow) : + (𝔼 u : (j : J) → ZMod (N j), + f ((ZMod.prodEquivPi N hN).symm u) * + (w.crtPatch N hN s hs).value (fun j => ((u j).val : ℝ))) = + 𝔼 x, f x * w.value ((x.val : ℝ) / (∏ j, N j : ℕ)) := by + apply Fintype.expect_equiv (ZMod.prodEquivPi N hN).symm.toEquiv + intro u + rw [w.crtPatch_value_residues N hN s hs] + rfl + +theorem exists_scored_crt_representative_patch (s : ℕ) (hs : 1 ≤ s) + (f : ZMod (∏ j, N j) → ℝ) {M sigma : ℝ} (hM : 0 < M) (hsigma : 0 < sigma) + (hf : ∀ x, |f x| ≤ M) (hscore : sigma ≤ 𝔼 x, f x) + (hsize : 1 / ((∏ j, N j : ℕ) : ℝ) ≤ sigma / (100 * M)) : + ∃ w : RepresentativeWindow, + (w.lip : ℝ) = 100 * M / sigma + representativeWindowPartitionLip ∧ + 3 * sigma / (4 * representativeWindowCount) ≤ + 𝔼 u : (j : J) → ZMod (N j), + f ((ZMod.prodEquivPi N hN).symm u) * + (w.crtPatch N hN s hs).value (fun j => ((u j).val : ℝ)) := by + let eta : ℝ≥0 := ⟨sigma / (100 * M), by positivity⟩ + have heta : 0 < eta := by change 0 < sigma / (100 * M); positivity + obtain ⟨i, hi⟩ := exists_localizedRepresentativeWindow_score f hM hsigma hf hscore + eta heta le_rfl hsize + let w := localizedRepresentativeWindow eta heta i + refine ⟨w, ?_, ?_⟩ + · change (sigma / (100 * M))⁻¹ + (representativeWindowPartitionLip : ℝ) = _ + rw [inv_div] + · rw [crt_representative_patch_score N hN s hs] + exact hi + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CanonicalResidueCoverLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CanonicalResidueCoverLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..809260e3009a02b0c74437900972e385f739c53b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CanonicalResidueCoverLaw.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.Progressions.Probability.CanonicalCoverLaw + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory +open scoped Classical + +variable {K R : Type*} [Fintype K] [Fintype R] {m : ℕ} {J I : Fin m → Type*} +variable [∀ j, Fintype (J j)] [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable [CompactSpace (CoefficientTorus (K := K) U)] +variable [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] +variable (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +include ν in +theorem canonicalCoefficientResidueCoverLaw + (bL : Basis R ℤ (coefficientIntegerLattice (K := K) U)) + (c w : ∀ j : Fin m, I j → BoundedCoefficientExponent K (j.val + 1) → ℝ) + (p : ∀ j : Fin m, Fin (n j) → BoundedCoefficientExponent K (j.val + 1) → PMF ℤ) + (hw : ∀ j i e, 0 < w j i e) + (hs : ∀ j e x, mixedCoefficientDensity (fun i => c j i e) (fun i => w j i e) + (fun i => p j i e) x ≠ 0 → normalizedLatticePoint (euclideanSubspace (U j)) (b j) + (orthonormalMixedChart (o j) x) ∈ standardLatticeSmallBox (J j)) + (d : ℕ) [NeZero d] : + ((Measure.pi (fun j => mixedScalarArrayLaw (c j) (w j) (p j))).prod + (PMF.uniformOfFintype (R → ZMod d)).toMeasure).map + (fun x => canonicalCoefficientCoverLift U b hb o d x.1 + + (coverKernelBasisEquiv (coefficientIntegerLattice (K := K) U) bL d + (Nat.pos_of_ne_zero (NeZero.ne d)) x.2).val) = + realDensityMeasure μ (fun y => canonicalCoefficientDensity U b hb o c w p + (quotientIntegerCover (coefficientIntegerLattice (K := K) U) d y)) := by + have hd : 0 < d := Nat.pos_of_ne_zero (NeZero.ne d) + let _ := coefficientCoverKernelFintype (K := K) U d hd + let : ∀ j, IsProbabilityMeasure (mixedScalarArrayLaw (c j) (w j) (p j)) := + fun j => mixedScalarArrayLaw_probability _ _ (hw j) _ + let : IsProbabilityMeasure (Measure.pi (fun j => mixedScalarArrayLaw (c j) (w j) (p j))) := + Measure.pi.instIsProbabilityMeasure _ + rw [finiteKernelLiftLaw_basisResidues (coefficientIntegerLattice (K := K) U) bL d + _ _ (canonicalCoefficientCoverLift_measurable U b hb o d)] + exact canonicalCoefficientCoverLaw U b hb o μ ν c w p hw hs d hd + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CellResidueCorrelation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CellResidueCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8c772308e55f75b6e6669b4ec54d303c1c415bc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CellResidueCorrelation.lean @@ -0,0 +1,342 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteProductCellMean + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem finite_fiber_mean_square {Ω R : Type*} [Fintype Ω] [DecidableEq R] + (p : FiniteProbabilityWeights Ω) (F : Ω → R) (e : Ω → ℝ) (r : R) : + (p.mean (fun x => if F x = r then e x else 0)) ^ 2 ≤ + p.eventProbability (fun x => F x = r) * + p.mean (fun x => if F x = r then e x ^ 2 else 0) := by + have h := p.mean_mul_sq_le (fun x => if F x = r then (1 : ℝ) else 0) + (fun x => if F x = r then e x else 0) + have h1 : (fun x => (if F x = r then (1 : ℝ) else 0) * + (if F x = r then e x else 0)) = (fun x => if F x = r then e x else 0) := by + funext x; split_ifs <;> simp + have h2 : (fun x => (if F x = r then (1 : ℝ) else 0) ^ 2) = + (fun x => if F x = r then (1 : ℝ) else 0) := by + funext x; split_ifs <;> norm_num + have h3 : (fun x => (if F x = r then e x else 0) ^ 2) = + (fun x => if F x = r then e x ^ 2 else 0) := by + funext x; split_ifs <;> norm_num + rw [h1, h2, h3] at h + have hmass : p.mean (fun x => if F x = r then (1 : ℝ) else 0) = + p.eventProbability (fun x => F x = r) := by + unfold FiniteProbabilityWeights.eventProbability + apply congrArg p.mean + funext x + split_ifs <;> rfl + rw [hmass] at h + exact h + +theorem finite_fiber_energy_sum {Ω R : Type*} [Fintype Ω] [Fintype R] [DecidableEq R] + (p : FiniteProbabilityWeights Ω) (F : Ω → R) (e : Ω → ℝ) : + (∑ r, p.mean (fun x => if F x = r then e x ^ 2 else 0)) = + p.mean (fun x => e x ^ 2) := by + rw [← p.mean_sum] + congr 1 + funext x + simp + +theorem finite_fiber_square_sum_le {Ω R : Type*} + [Fintype Ω] [Fintype R] [DecidableEq R] + (p : FiniteProbabilityWeights Ω) (F : Ω → R) (e : Ω → ℝ) {c : ℝ} + (hmass : ∀ r, p.eventProbability (fun x => F x = r) ≤ c) : + (∑ r, (p.mean (fun x => if F x = r then e x else 0)) ^ 2) ≤ + c * p.mean (fun x => e x ^ 2) := by + calc + _ ≤ ∑ r, c * p.mean (fun x => if F x = r then e x ^ 2 else 0) := by + apply Finset.sum_le_sum + intro r _ + apply (finite_fiber_mean_square p F e r).trans + exact mul_le_mul_of_nonneg_right (hmass r) + (p.mean_nonneg (fun x => by split_ifs; exact sq_nonneg _; exact le_rfl)) + _ = _ := by rw [← Finset.mul_sum, finite_fiber_energy_sum] + +theorem finite_residue_energy_bound {Ω R : Type*} + [Fintype Ω] [Fintype R] [Nonempty R] [DecidableEq R] + (p : FiniteProbabilityWeights Ω) (F : Ω → R) (e : Ω → ℝ) {K : ℝ} + (hmass : ∀ r, p.eventProbability (fun x => F x = r) ≤ K / Fintype.card R) : + (Fintype.card R : ℝ) * + (∑ r, (p.mean (fun x => if F x = r then |e x| else 0)) ^ 2) ≤ + K * p.mean (fun x => e x ^ 2) := by + have hcard : (0 : ℝ) < Fintype.card R := by exact_mod_cast Fintype.card_pos + have h := finite_fiber_square_sum_le p F (fun x => |e x|) hmass + simp only [sq_abs] at h + calc + _ ≤ (Fintype.card R : ℝ) * ((K / Fintype.card R) * p.mean (fun x => e x ^ 2)) := + mul_le_mul_of_nonneg_left h hcard.le + _ = _ := by field_simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem finite_matching_residue_mean {X Y R : Type*} + [Fintype X] [Fintype Y] [Fintype R] [DecidableEq R] + (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) + (F : X → R) (G : Y → R) (e : X → ℝ) (d : Y → ℝ) : + p.mean (fun x => q.mean (fun y => if F x = G y then |e x| * |d y| else 0)) = + ∑ r, p.mean (fun x => if F x = r then |e x| else 0) * + q.mean (fun y => if G y = r then |d y| else 0) := by + have hpoint (x : X) (y : Y) : + (if F x = G y then |e x| * |d y| else 0) = + ∑ r, (if F x = r then |e x| else 0) * (if G y = r then |d y| else 0) := by + symm + rw [Finset.sum_eq_single (F x)] + · by_cases h : F x = G y <;> simp [h, eq_comm] + · intro r _ hr + simp [Ne.symm hr] + · simp + simp_rw [hpoint, q.mean_sum, p.mean_sum] + apply Finset.sum_congr rfl + intro r _ + simp_rw [q.mean_const_mul, p.mean_mul_const] + +theorem finite_matching_residue_energy {X Y R : Type*} + [Fintype X] [Fintype Y] [Fintype R] [Nonempty R] [DecidableEq R] + (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) + (F : X → R) (G : Y → R) (e : X → ℝ) (d : Y → ℝ) {K : ℝ} + (hp : ∀ r, p.eventProbability (fun x => F x = r) ≤ K / Fintype.card R) + (hq : ∀ r, q.eventProbability (fun y => G y = r) ≤ K / Fintype.card R) : + (Fintype.card R : ℝ) * + p.mean (fun x => q.mean (fun y => if F x = G y then |e x| * |d y| else 0)) ≤ + K / 2 * (p.mean (fun x => e x ^ 2) + q.mean (fun y => d y ^ 2)) := by + rw [finite_matching_residue_mean] + have he := finite_residue_energy_bound p F e hp + have hd := finite_residue_energy_bound q G d hq + have hs : 2 * (∑ r, p.mean (fun x => if F x = r then |e x| else 0) * + q.mean (fun y => if G y = r then |d y| else 0)) ≤ + (∑ r, (p.mean (fun x => if F x = r then |e x| else 0)) ^ 2) + + (∑ r, (q.mean (fun y => if G y = r then |d y| else 0)) ^ 2) := by + rw [Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_le_sum + intro r _ + nlinarith [sq_nonneg (p.mean (fun x => if F x = r then |e x| else 0) - + q.mean (fun y => if G y = r then |d y| else 0))] + have hscaled := mul_le_mul_of_nonneg_left hs (Nat.cast_nonneg (α := ℝ) (Fintype.card R)) + nlinarith only [hscaled, he, hd] + +theorem finite_matching_kernel_error {X Y R : Type*} + [Fintype X] [Fintype Y] [Fintype R] [Nonempty R] [DecidableEq R] + (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) + (F : X → R) (G : Y → R) (e : X → ℝ) (d : Y → ℝ) (k : X → Y → ℝ) + {K epsilon : ℝ} (hepsilon : 0 ≤ epsilon) + (hp : ∀ r, p.eventProbability (fun x => F x = r) ≤ K / Fintype.card R) + (hq : ∀ r, q.eventProbability (fun y => G y = r) ≤ K / Fintype.card R) + (hk : ∀ x y, F x = G y → |k x y| ≤ epsilon) : + (Fintype.card R : ℝ) * + |p.mean (fun x => q.mean (fun y => if F x = G y then k x y * e x * d y else 0))| ≤ + epsilon * (K / 2 * (p.mean (fun x => e x ^ 2) + q.mean (fun y => d y ^ 2))) := by + have ha : |p.mean (fun x => q.mean (fun y => if F x = G y then k x y * e x * d y else 0))| ≤ + epsilon * p.mean (fun x => q.mean (fun y => if F x = G y then |e x| * |d y| else 0)) := by + apply (p.abs_mean_le_mean_abs _).trans + rw [← p.mean_const_mul] + apply p.mean_mono + intro x + apply (q.abs_mean_le_mean_abs _).trans + rw [← q.mean_const_mul] + apply q.mean_mono + intro y + by_cases h : F x = G y + · simp only [h, ite_true, abs_mul] + calc + _ = |k x y| * (|e x| * |d y|) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right (hk x y h) (mul_nonneg (abs_nonneg _) (abs_nonneg _)) + · simp [h] + calc + _ ≤ (Fintype.card R : ℝ) * (epsilon * + p.mean (fun x => q.mean (fun y => if F x = G y then |e x| * |d y| else 0))) := + mul_le_mul_of_nonneg_left ha (Nat.cast_nonneg _) + _ = epsilon * ((Fintype.card R : ℝ) * + p.mean (fun x => q.mean (fun y => if F x = G y then |e x| * |d y| else 0))) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left (finite_matching_residue_energy p q F G e d hp hq) hepsilon + +theorem finite_matching_kernel_approximation {X Y R : Type*} + [Fintype X] [Fintype Y] [Fintype R] [Nonempty R] [DecidableEq R] + (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) + (F : X → R) (G : Y → R) (e : X → ℝ) (d : Y → ℝ) (k l : X → Y → ℝ) + {K epsilon : ℝ} (hepsilon : 0 ≤ epsilon) + (hp : ∀ r, p.eventProbability (fun x => F x = r) ≤ K / Fintype.card R) + (hq : ∀ r, q.eventProbability (fun y => G y = r) ≤ K / Fintype.card R) + (hk : ∀ x y, F x = G y → |k x y - l x y| ≤ epsilon) : + |(Fintype.card R : ℝ) * + p.mean (fun x => q.mean (fun y => if F x = G y then k x y * e x * d y else 0)) - + (Fintype.card R : ℝ) * + p.mean (fun x => q.mean (fun y => if F x = G y then l x y * e x * d y else 0))| ≤ + epsilon * (K / 2 * (p.mean (fun x => e x ^ 2) + q.mean (fun y => d y ^ 2))) := by + have hid : p.mean (fun x => q.mean (fun y => + if F x = G y then (k x y - l x y) * e x * d y else 0)) = + p.mean (fun x => q.mean (fun y => if F x = G y then k x y * e x * d y else 0)) - + p.mean (fun x => q.mean (fun y => if F x = G y then l x y * e x * d y else 0)) := by + rw [← p.mean_sub] + apply congrArg p.mean + funext x + rw [← q.mean_sub] + apply congrArg q.mean + funext y + split_ifs <;> ring + rw [← mul_sub, ← hid, abs_mul, abs_of_nonneg (Nat.cast_nonneg _)] + exact finite_matching_kernel_error p q F G e d (fun x y => k x y - l x y) hepsilon hp hq hk + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem finite_cell_residue_kernel_expand {X Y A B R : Type*} + [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype R] + [DecidableEq A] [DecidableEq B] [DecidableEq R] + (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) + (C : X → A) (D : Y → B) (F : X → R) (G : Y → R) + (e : X → ℝ) (d : Y → ℝ) (k : A → B → R → ℝ) : + p.mean (fun x => q.mean (fun y => if F x = G y then k (C x) (D y) (F x) * e x * d y else 0)) = + ∑ r, ∑ a, ∑ b, k a b r * finiteCellResidueMean p C F e a r * finiteCellResidueMean q D G d b r := by + have hpoint (x : X) (y : Y) : + (if F x = G y then k (C x) (D y) (F x) * e x * d y else 0) = + ∑ r, ∑ a, ∑ b, k a b r * (if C x = a ∧ F x = r then e x else 0) * + (if D y = b ∧ G y = r then d y else 0) := by + symm + rw [Finset.sum_eq_single (F x)] + · rw [Finset.sum_eq_single (C x)] + · rw [Finset.sum_eq_single (D y)] + · by_cases h : F x = G y <;> simp [h, eq_comm] + · intro b _ hb + simp [Ne.symm hb] + · simp + · intro a _ ha + simp [Ne.symm ha] + · simp + · intro r _ hr + simp [Ne.symm hr] + · simp + simp_rw [hpoint, q.mean_sum, p.mean_sum] + apply Finset.sum_congr rfl + intro r _ + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + simp only [finiteCellResidueMean, q.mean_const_mul, p.mean_mul_const, p.mean_const_mul] + +theorem weighted_cell_residue_cancellation {A B R : Type*} + [Fintype A] [Fintype B] [Fintype R] [Nonempty R] + (p : FiniteProbabilityWeights A) (q : FiniteProbabilityWeights B) + (e : A → R → ℝ) (d : B → R → ℝ) (k : A → B → R → ℝ) + {delta gamma L : ℝ} (hdelta : 0 ≤ delta) (hL : 0 ≤ L) + (he : ∀ a r, |e a r| ≤ p.weight a * delta / Fintype.card R) + (hd : ∀ b r, |d b r| ≤ q.weight b * gamma / Fintype.card R) + (hk : ∀ a b r, |k a b r| ≤ L) : + |(Fintype.card R : ℝ) * ∑ r, ∑ a, ∑ b, k a b r * e a r * d b r| ≤ L * delta * gamma := by + let N : ℝ := Fintype.card R + have hN : 0 < N := by dsimp only [N]; exact_mod_cast Fintype.card_pos + have hterm (a : A) (b : B) (r : R) : + |k a b r * e a r * d b r| ≤ (L * delta * gamma / N ^ 2) * (p.weight a * q.weight b) := by + rw [abs_mul, abs_mul] + have h := mul_le_mul (mul_le_mul (hk a b r) (he a r) (abs_nonneg _) hL) + (hd b r) (abs_nonneg _) (mul_nonneg hL (div_nonneg (mul_nonneg (p.nonneg a) hdelta) hN.le)) + apply h.trans_eq + dsimp only [N] + ring + have hs : |∑ r, ∑ a, ∑ b, k a b r * e a r * d b r| ≤ + ∑ _r : R, ∑ a, ∑ b, (L * delta * gamma / N ^ 2) * (p.weight a * q.weight b) := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro r _ + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro a _ + apply (Finset.abs_sum_le_sum_abs _ _).trans + exact Finset.sum_le_sum (fun b _ => hterm a b r) + have hsum : (∑ _r : R, ∑ a, ∑ b, (L * delta * gamma / N ^ 2) * (p.weight a * q.weight b)) = + N * (L * delta * gamma / N ^ 2) := by + simp only [← mul_assoc, ← Finset.mul_sum, q.total, p.total, mul_one, + Finset.sum_const, Finset.card_univ, nsmul_eq_mul, N] + change |N * _| ≤ _ + rw [abs_mul, abs_of_pos hN] + calc + _ ≤ N * (N * (L * delta * gamma / N ^ 2)) := + mul_le_mul_of_nonneg_left (hs.trans_eq hsum) hN.le + _ = _ := by field_simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem finite_cell_kernel_cancellation {X Y A B R : Type*} + [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype R] [Nonempty R] + [DecidableEq A] [DecidableEq B] [DecidableEq R] + (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) + (C : X → A) (D : Y → B) (F : X → R) (G : Y → R) + (e : X → ℝ) (d : Y → ℝ) (k : A → B → R → ℝ) + {delta gamma L : ℝ} (hdelta : 0 ≤ delta) (hL : 0 ≤ L) + (he : ∀ a r, |finiteCellResidueMean p C F e a r| ≤ + (finiteCellWeights p C).weight a * delta / Fintype.card R) + (hd : ∀ b r, |finiteCellResidueMean q D G d b r| ≤ + (finiteCellWeights q D).weight b * gamma / Fintype.card R) + (hk : ∀ a b r, |k a b r| ≤ L) : + |(Fintype.card R : ℝ) * p.mean + (fun x => q.mean (fun y => if F x = G y then k (C x) (D y) (F x) * e x * d y else 0))| ≤ + L * delta * gamma := by + rw [finite_cell_residue_kernel_expand] + exact weighted_cell_residue_cancellation (finiteCellWeights p C) (finiteCellWeights q D) + (finiteCellResidueMean p C F e) (finiteCellResidueMean q D G d) k hdelta hL he hd hk + +theorem finite_cell_kernel_correlation {X Y A B R : Type*} + [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype R] [Nonempty R] + [DecidableEq A] [DecidableEq B] [DecidableEq R] + (p : FiniteProbabilityWeights X) (q : FiniteProbabilityWeights Y) + (C : X → A) (D : Y → B) (F : X → R) (G : Y → R) + (e : X → ℝ) (d : Y → ℝ) (k : X → Y → ℝ) (cell : A → B → R → ℝ) + {delta gamma L K zeta : ℝ} (hdelta : 0 ≤ delta) (hL : 0 ≤ L) (hzeta : 0 ≤ zeta) + (hp : ∀ r, p.eventProbability (fun x => F x = r) ≤ K / Fintype.card R) + (hq : ∀ r, q.eventProbability (fun y => G y = r) ≤ K / Fintype.card R) + (he : ∀ a r, |finiteCellResidueMean p C F e a r| ≤ + (finiteCellWeights p C).weight a * delta / Fintype.card R) + (hd : ∀ b r, |finiteCellResidueMean q D G d b r| ≤ + (finiteCellWeights q D).weight b * gamma / Fintype.card R) + (hcell : ∀ a b r, |cell a b r| ≤ L) + (hgrid : ∀ x y, F x = G y → |k x y - cell (C x) (D y) (F x)| ≤ zeta) : + |(Fintype.card R : ℝ) * p.mean + (fun x => q.mean (fun y => if F x = G y then k x y * e x * d y else 0))| ≤ + L * delta * gamma + zeta * (K / 2 * (p.mean (fun x => e x ^ 2) + q.mean (fun y => d y ^ 2))) := by + have herror := finite_matching_kernel_approximation p q F G e d k + (fun x y => cell (C x) (D y) (F x)) hzeta hp hq hgrid + have hmain := finite_cell_kernel_cancellation p q C D F G e d cell hdelta hL he hd hcell + have htriangle := abs_add_le + ((Fintype.card R : ℝ) * p.mean + (fun x => q.mean (fun y => if F x = G y then k x y * e x * d y else 0)) - + (Fintype.card R : ℝ) * p.mean + (fun x => q.mean (fun y => if F x = G y then cell (C x) (D y) (F x) * e x * d y else 0))) + ((Fintype.card R : ℝ) * p.mean + (fun x => q.mean (fun y => if F x = G y then cell (C x) (D y) (F x) * e x * d y else 0))) + rw [sub_add_cancel] at htriangle + exact (htriangle.trans (add_le_add herror hmain)).trans_eq (add_comm _ _) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CenteredAffineCoefficient.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CenteredAffineCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5e0510a8453f72672e7efb50ceec45941f32464 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CenteredAffineCoefficient.lean @@ -0,0 +1,38 @@ +import OAI.Combinatorics.Progressions.Estimates.CoefficientRowEvaluation + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +variable {K V : Type*} [Fintype K] {m : ℕ} {J : Fin m → Type*} +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (p j) d ∈ U j) + +noncomputable def centeredAffineCoefficientArray (center : ∀ j, U j) (frame : Option K → V → ℝ) : + CoefficientArray (K := K) U := + affineSampleCoefficientArray U p hm frame - constantCoefficientArray U (fun s => center s.1) + +noncomputable def centeredAffineCoefficientTorus (center : ∀ j, U j) (frame : Option K → V → ℝ) : + CoefficientTorus (K := K) U := + QuotientAddGroup.mk' (coefficientIntegerLattice U) (centeredAffineCoefficientArray U p hm center frame) + +theorem coefficientRowPolynomial_centered_affine_eval + (hp : ∀ j, DegreeLE (1 : V → ℕ) (j.val + 1) (p j)) + (center : ∀ j, U j) (frame : Option K → V → ℝ) (j : Fin m) (i : J j) (x : K → ℝ) : + MvPolynomial.eval x + (coefficientRowPolynomial U (centeredAffineCoefficientArray U p hm center frame) j i) = + eval (fun v => frame none v + ∑ k, frame (some k) v * x k) (p j) i - (center j).val i := by + rw [centeredAffineCoefficientArray, coefficientRowPolynomial_sub, map_sub, + coefficientRowPolynomial_constant, MvPolynomial.eval_C, + coefficientRowPolynomial_affine_eval U p hp hm] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CentralLatticeQuotientAction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CentralLatticeQuotientAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..54943e003779a702b0c717e7b672c8b02d65e212 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CentralLatticeQuotientAction.lean @@ -0,0 +1,38 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.GroupTheory.GroupAction.Quotient + +namespace OAI + +section + +namespace Erdos3 + +variable {G : Type*} [Group G] + +theorem central_lattice_smul_eq (Γ : Subgroup G) (z : G) (hz : z ∈ Γ) + (hcentral : ∀ g, z * g = g * z) (x : G ⧸ Γ) : z • x = x := by + induction x using Quotient.inductionOn' with + | h g => + change (QuotientGroup.mk (z * g) : G ⧸ Γ) = QuotientGroup.mk g + rw [hcentral g] + exact QuotientGroup.mk_mul_of_mem g hz + +theorem central_lattice_add_smul_eq (Γ : Subgroup G) (c : ℝ → G) + (hadd : ∀ s t, c (s + t) = c s * c t) (t a : ℝ) + (ha : c a ∈ Γ) (hcentral : ∀ g, c a * g = g * c a) (x : G ⧸ Γ) : + c (t + a) • x = c t • x := by + rw [hadd, mul_smul, central_lattice_smul_eq Γ (c a) ha hcentral] + +theorem central_lattice_int_add_smul_eq (Γ : Subgroup G) (c : ℝ → G) + (hadd : ∀ s t, c (s + t) = c s * c t) + (hlattice : ∀ n : ℤ, c (n : ℝ) ∈ Γ) + (hcentral : ∀ (n : ℤ) g, c (n : ℝ) * g = g * c (n : ℝ)) + (t : ℝ) (n : ℤ) (x : G ⧸ Γ) : + c (t + n) • x = c t • x := + central_lattice_add_smul_eq Γ c hadd t n (hlattice n) (hcentral n) x + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedAffineCutoffCost.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedAffineCutoffCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b248ab35b394b4d59df128b642896ded2a67be2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedAffineCutoffCost.lean @@ -0,0 +1,1002 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateRealThreshold +import OAI.Combinatorics.Progressions.Geometry.CertifiedFullChartRecoveredTerminal +import OAI.Combinatorics.Progressions.Geometry.GlobalMarkedNativeChartResetConditions +import OAI.Combinatorics.Progressions.Lattices.FullTaggedAffineComplementAgreement +import OAI.Combinatorics.Progressions.Sampling.AllocatedExternalCandidateSamplerFacts + +namespace OAI + +section + +namespace Erdos3 +open scoped Classical + +theorem exists_weighted_common_real_grid_vector + {Ω ι : Type*} [Fintype Ω] [Fintype ι] + (outer : FiniteProbabilityWeights Ω) (S : Finset Ω) (hS : 0 < outer.mass S) + (v : Ω → ι → ℝ) (l : ℕ) (hl : 0 < l) {B p : ℝ} + (hp : 0 ≤ p) (hB : 0 ≤ B) (hd : (Fintype.card ι : ℝ) ≤ p) + (hlp : (l : ℝ) ≤ Real.exp p) (hBp : B ≤ Real.exp p) + (hgrid : ∀ a ∈ S, v a ∈ realDenominatorGrid l) + (hbound : ∀ a ∈ S, ∀ i, |v a i| ≤ B) : + ∃ a₀ ∈ S, ∃ T : Finset Ω, T ⊆ S ∧ a₀ ∈ T ∧ + (∀ a ∈ T, v a = v a₀) ∧ + Real.exp (-((p + 3) ^ 3)) * outer.mass S ≤ outer.mass T := by + let window : Set (ι → ℝ) := + {x | x ∈ realDenominatorGrid l ∧ ∀ i, |x i| ≤ B} + obtain ⟨hfinite, hcard⟩ := finite_card_real_grid_window window l ⌈(l : ℝ) * B⌉₊ hl 0 + (fun _ hx => hx.1) (by intro x hx i; simpa only [Pi.zero_apply, sub_zero] using hx.2 i) + (Nat.le_ceil _) + have hcount : (window.ncard : ℝ) ≤ Real.exp ((p + 3) ^ 3) := + (Nat.cast_le.mpr hcard).trans (real_grid_window_count_le_exp _ _ hp hB hd hlp hBp) + obtain ⟨c, _, T, hTS, hT, hc, hmass⟩ := + exists_weighted_exponential_constant_fiber outer S hS v window hfinite + (fun a ha => ⟨hgrid a ha, hbound a ha⟩) hcount + obtain ⟨a₀, ha₀⟩ := hT + exact ⟨a₀, hTS ha₀, T, hTS, ha₀, + fun a ha => (hc a ha).trans (hc a₀ ha₀).symm, hmass⟩ + +theorem exists_weighted_common_coordinate_grid_vector + {Ω ι : Type*} [Fintype Ω] [Fintype ι] + (outer : FiniteProbabilityWeights Ω) (S : Finset Ω) (hS : 0 < outer.mass S) + (v : Ω → ι → ℝ) (den : ι → ℕ) (hden : ∀ i, 0 < den i) {p : ℝ} + (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) + (hdenp : ∀ i, (den i : ℝ) ≤ Real.exp p) + (hgrid : ∀ a ∈ S, ∀ i, ∃ z : ℤ, (den i : ℝ) * v a i = z) + (hbound : ∀ a ∈ S, ∀ i, |v a i| ≤ Real.exp p) : + ∃ a₀ ∈ S, ∃ T : Finset Ω, T ⊆ S ∧ a₀ ∈ T ∧ + (∀ a ∈ T, v a = v a₀) ∧ + Real.exp (-((2 * p + 3) ^ 3)) * outer.mass S ≤ outer.mass T := by + let scaled : Ω → ι → ℝ := fun a i => (den i : ℝ) * v a i + have hscaled_grid (a) (ha : a ∈ S) : scaled a ∈ realDenominatorGrid 1 := by + choose z hz using hgrid a ha + refine ⟨z, ?_⟩ + funext i + simpa only [Nat.cast_one, Pi.smul_apply, smul_eq_mul, one_mul] using (hz i).symm + have hscaled_bound (a) (ha : a ∈ S) (i) : |scaled a i| ≤ Real.exp (2 * p) := by + dsimp only [scaled] + rw [abs_mul, abs_of_nonneg (Nat.cast_nonneg _)] + calc + _ ≤ Real.exp p * Real.exp p := + mul_le_mul (hdenp i) (hbound a ha i) (abs_nonneg _) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + obtain ⟨a₀, ha₀, T, hTS, haT, hsame, hmass⟩ := + exists_weighted_common_real_grid_vector outer S hS scaled 1 (by omega) + (by positivity : 0 ≤ 2 * p) (Real.exp_nonneg _) (hd.trans (by linarith)) + (by simpa only [Nat.cast_one] using Real.one_le_exp (by positivity : 0 ≤ 2 * p)) + le_rfl hscaled_grid hscaled_bound + refine ⟨a₀, ha₀, T, hTS, haT, ?_, hmass⟩ + intro a ha + funext i + exact mul_left_cancel₀ (by exact_mod_cast (hden i).ne' : (den i : ℝ) ≠ 0) + (congrFun (hsame a ha) i) + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule _root_.MvPolynomial _root_.OAI.MvPolynomial BooleanCubeKernel +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_quotient_bound + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C j * ‖x‖) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (j : Fin m) {T : Type*} (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) + (hQU : U j ≤ LinearMap.ker Q) {CQ : ℝ} (hCQ : 0 ≤ CQ) + (hQ : ∀ x t, |Q x t| ≤ CQ * ‖x‖) + (x : LayerSamplerVariables G I n B → ℝ) + (hx : ∀ k, |x k| ≤ layerSamplerBox B U b S k) (t : T) : + |Q (fun i => MvPolynomial.eval x (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) + (Sum.inr ⟨j, i⟩))) t| ≤ + CQ * (C j * (((Fintype.card (I j) : ℝ) + 1) * R j)) := by + let mixed : J j → ℝ := fun i => mixedPolynomialPoint (euclideanSubspace (U j)) + (b j) (o j) Subtype.val (sample j).1 (sample j).2 x i + let integer : J j → ℝ := fun i => MvPolynomial.eval x (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) (Sum.inr ⟨j, i⟩)) + have hrem : eval (fun z => (jointIntegerFrame (a, v) none z : ℝ) + + ∑ k, (jointIntegerFrame (a, v) (some k) z : ℝ) * x k) (poly j) - (c j).val = + mixed + integer := by + funext i + exact h.integerFullChart_remainder B U b hb o S hR hσ poly hm hp c a v sample read x j i + have hretained : eval (fun z => (jointIntegerFrame (a, v) none z : ℝ) + + ∑ k, (jointIntegerFrame (a, v) (some k) z : ℝ) * x k) (poly j) - (c j).val ∈ U j := + (U j).sub_mem ((eval_mem_iff_coefficients (U j) (poly j)).mpr (hm j) _) (c j).property + have hsum : Q mixed + Q integer = 0 := by + rw [← map_add, ← hrem] + exact hQU hretained + have hquotient : Q integer = -Q mixed := by + apply eq_neg_iff_add_eq_zero.mpr + simpa only [add_comm] using hsum + have hnonneg : 0 ≤ C j * (((Fintype.card (I j) : ℝ) + 1) * R j) := + mul_nonneg (hC j) (mul_nonneg (by positivity) (hR j).le) + have hnorm : ‖mixed‖ ≤ C j * (((Fintype.card (I j) : ℝ) + 1) * R j) := by + apply (pi_norm_le_iff_of_nonneg hnonneg).mpr + intro i + simpa only [mixed, Real.norm_eq_abs] using + allocatedLayerSupported_polynomial_bound B U b o hR hσ S hσ1 C hC hchart + j (sample j) (h.2.2.1 j).2 x hx i + change |Q integer t| ≤ _ + calc + _ = |Q mixed t| := by rw [hquotient]; simp + _ ≤ CQ * ‖mixed‖ := hQ mixed t + _ ≤ _ := mul_le_mul_of_nonneg_left hnorm hCQ + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFrozenFullChart_anchor_bound + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C j * ‖x‖) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (j : Fin m) {T : Type*} (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) + (hQU : U j ≤ LinearMap.ker Q) {CQ : ℝ} (hCQ : 0 ≤ CQ) + (hQ : ∀ x t, |Q x t| ≤ CQ * ‖x‖) + (keep : LayerSamplerVariables G I n B → Prop) (fixed : {i // ¬keep i} → ℤ) + (hfixed : ∀ i, |(fixed i : ℝ)| ≤ layerSamplerBox B U b S i.val) (t : T) : + |Q (fun i => MvPolynomial.eval (0 : {k // keep k} → ℝ) (integerSampledRealChart + (allocatedFrozenIntegerFullChart B U b o poly hm c a v sample keep fixed) + (Sum.inr ⟨j, i⟩))) t| ≤ + CQ * (C j * (((Fintype.card (I j) : ℝ) + 1) * R j)) := by + have heval (i : J j) : MvPolynomial.eval (0 : {k // keep k} → ℝ) + (integerSampledRealChart + (allocatedFrozenIntegerFullChart B U b o poly hm c a v sample keep fixed) + (Sum.inr ⟨j, i⟩)) = + MvPolynomial.eval (finiteSplitPoint keep 0 (fun i => (fixed i : ℝ))) + (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) + (Sum.inr ⟨j, i⟩)) := by + change MvPolynomial.eval _ (integerSampledRealChart + (fun z => freezePolynomial keep fixed + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample z)) _) = _ + rw [integerSampledRealChart_freeze, freezePolynomial_eval] + simp_rw [heval] + apply h.integerFullChart_quotient_bound B U b hb o S hR hσ poly hm hσ1 C hC hchart hp + c a v sample read j Q hQU hCQ hQ _ _ t + intro k + by_cases hk : keep k + · simpa [finiteSplitPoint, hk] using + (zero_le_one.trans (layerSamplerBox_one_le B U b S k)) + · simpa [finiteSplitPoint, hk] using hfixed ⟨k, hk⟩ + +theorem allocatedFrozenIntegerFullChart_anchor_grid + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (j : Fin m) {T : Type*} (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) (D : ℝ) + (hgrid : ∀ z : J j → ℤ, ∀ t, ∃ a : ℤ, D * Q (fun i => (z i : ℝ)) t = a) + (keep : LayerSamplerVariables G I n B → Prop) (fixed : {i // ¬keep i} → ℤ) (t : T) : + ∃ z : ℤ, D * Q (fun i => MvPolynomial.eval (0 : {k // keep k} → ℝ) + (integerSampledRealChart + (allocatedFrozenIntegerFullChart B U b o poly hm c a v sample keep fixed) + (Sum.inr ⟨j, i⟩))) t = z := by + have heval (i : J j) : MvPolynomial.eval (0 : {k // keep k} → ℝ) + (integerSampledRealChart + (allocatedFrozenIntegerFullChart B U b o poly hm c a v sample keep fixed) + (Sum.inr ⟨j, i⟩)) = + (MvPolynomial.eval (0 : {k // keep k} → ℤ) + (allocatedFrozenIntegerFullChart B U b o poly hm c a v sample keep fixed + (Sum.inr ⟨j, i⟩)) : ℝ) := by + simpa only [Pi.zero_apply, Int.cast_zero, Pi.zero_def] using + integerSampledRealChart_eval + (allocatedFrozenIntegerFullChart B U b o poly hm c a v sample keep fixed) + (0 : {k // keep k} → ℤ) (Sum.inr ⟨j, i⟩) + simp_rw [heval] + exact hgrid _ t + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +theorem le_monomialScale_of_coordinate {A : Type*} (T : A → ℝ) + (hT : ∀ i, 1 ≤ T i) {α : A →₀ ℕ} (i : A) (hi : α i ≠ 0) : + T i ≤ monomialScale T α := by + classical + have hp : T i ≤ T i ^ α i := by + simpa only [pow_one] using pow_le_pow_right₀ (hT i) (Nat.one_le_iff_ne_zero.mpr hi) + have hs : ({i} : Finset A) ⊆ α.support := + Finset.singleton_subset_iff.mpr (Finsupp.mem_support_iff.mpr hi) + have hprod := Finset.prod_le_prod_of_subset_of_one_le₀ hs + (fun j _ => pow_nonneg (zero_le_one.trans (hT j)) (α j)) + (fun j _ _ => one_le_pow₀ (hT j)) + exact hp.trans (by + simpa only [Finset.prod_singleton, monomialScale, Finsupp.prod] using hprod) + +namespace VectorPolynomial +open Module Submodule _root_.MvPolynomial _root_.OAI.MvPolynomial BooleanCubeKernel +open scoped BigOperators + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_mixed_long_coeff + (hσ1 : ∀ j, σ j ≤ 1) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (j : Fin m) {T : Type*} + (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) (hQU : U j ≤ LinearMap.ker Q) + {C CQ D H : ℝ} (hC : 0 ≤ C) (hCQ : 0 ≤ CQ) (hD : 0 < D) + (hchart : ∀ x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C * ‖x‖) + (hQ : ∀ x t, |Q x t| ≤ CQ * ‖x‖) + (hgrid : ∀ z : J j → ℤ, ∀ t, ∃ a : ℤ, D * Q (fun i => (z i : ℝ)) t = a) + (hthreshold : CQ * (C * (((Fintype.card (I j) : ℝ) + 1) * R j)) * D < H) + (α : LayerSamplerVariables G I n B →₀ ℕ) + (htouches : ∃ i, H ≤ layerSamplerBox B U b S i ∧ α i ≠ 0) : + Q (fun i => (((allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample + (Sum.inr ⟨j, i⟩)).coeff α : ℤ) : ℝ)) = 0 := by + by_cases hdegree : α.degree ≤ j.val + 1 + · let frame : Option (LayerSamplerVariables G I n B) → X → ℝ := + fun k z => (jointIntegerFrame (a, v) k z : ℝ) + let d : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) := + ⟨α, hdegree⟩ + have hc : canonicalCoefficientSample U b hb o sample = + QuotientAddGroup.mk' (coefficientIntegerLattice U) + (centeredAffineCoefficientArray U poly hm c frame) := + h.2.1.trans (affineSampleCoefficientTorus_subtractConstant U poly hm c frame) + change Q (fun i => (((coefficientIntegerFloorPolynomial U b o sample + (centeredAffineCoefficientArray U poly hm c frame) j i).coeff d.val : ℤ) : ℝ)) = 0 + apply canonicalCoefficientSample_floor_coeff_separate U b hb o sample _ hc j d Q hQU hD hgrid + let M : ℝ := C * (((Fintype.card (I j) : ℝ) + 1) * R j) + let scale : ℝ := monomialScale (layerSamplerBox B U b S) α + have hscale : 0 < scale := monomialScale_pos _ + (fun i => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U b S i)) α + have hM : 0 ≤ M := mul_nonneg hC (mul_nonneg (by positivity) (hR j).le) + have hnorm : ‖fun i => mixedLiftCoefficient (euclideanSubspace (U j)) + (b j) (o j) (sample j) d i‖ ≤ M / scale := by + apply (pi_norm_le_iff_of_nonneg (div_nonneg hM hscale.le)).mpr + intro i + simpa only [Real.norm_eq_abs] using + allocatedLayerLiftCoefficient_radius_bound B U b hR hσ S hσ1 o j hC hchart + (sample j) (h.2.2.1 j).2 d i + have hscaleH : H ≤ scale := by + obtain ⟨i, hi, hαi⟩ := htouches + exact hi.trans (le_monomialScale_of_coordinate _ (layerSamplerBox_one_le B U b S) i hαi) + intro t + calc + _ ≤ CQ * ‖fun i => mixedLiftCoefficient (euclideanSubspace (U j)) + (b j) (o j) (sample j) d i‖ := hQ _ t + _ ≤ CQ * (M / scale) := mul_le_mul_of_nonneg_left hnorm hCQ + _ = (CQ * M) / scale := (mul_div_assoc CQ M scale).symm + _ < 1 / D := (div_lt_div_iff₀ hscale hD).mpr (by + simpa only [one_mul] using hthreshold.trans_le hscaleH) + · have hzero (i : J j) : (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample + (Sum.inr ⟨j, i⟩)).coeff α = 0 := + coeff_eq_zero_of_totalDegree_lt ((allocatedRecoveredIntegerFullChart_tag_degree + B U b o poly hm c a v sample j i).trans_lt (lt_of_not_ge hdegree)) + simp only [hzero, Int.cast_zero] + exact map_zero Q + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_frozen_coeff + (hσ1 : ∀ j, σ j ≤ 1) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (j : Fin m) {T : Type*} (keep : LayerSamplerVariables G I n B → Prop) + (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) (hQU : U j ≤ LinearMap.ker Q) + {C CQ D H : ℝ} (hC : 0 ≤ C) (hCQ : 0 ≤ CQ) (hD : 0 < D) + (hchart : ∀ x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C * ‖x‖) + (hQ : ∀ x t, |Q x t| ≤ CQ * ‖x‖) + (hgrid : ∀ z : J j → ℤ, ∀ t, ∃ a : ℤ, D * Q (fun i => (z i : ℝ)) t = a) + (hlong : ∀ i, keep i → H ≤ layerSamplerBox B U b S i) + (hthreshold : CQ * (C * (((Fintype.card (I j) : ℝ) + 1) * R j)) * D < H) + (fixed : {i // ¬ keep i} → ℤ) + (α : {i // keep i} →₀ ℕ) (hα : α ≠ 0) : + Q (fun i => (MvPolynomial.map (Int.castRingHom ℝ) + (freezePolynomial keep fixed (allocatedRecoveredIntegerFullChart B U b o poly hm + c a v sample (Sum.inr ⟨j, i⟩)))).coeff α) = 0 := by + apply frozenPolynomialFamily_coeff_mem _ keep fixed (LinearMap.ker Q) _ α hα + intro d hd + apply h.integerFullChart_mixed_long_coeff B U b hb o S hR hσ poly hm hσ1 c a v sample read + j Q hQU hC hCQ hD hchart hQ hgrid hthreshold d + obtain ⟨i, hi, hdi⟩ := hd + exact ⟨i, hlong i hi, hdi⟩ + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_frozen_affine_range + (hσ1 : ∀ j, σ j ≤ 1) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (j : Fin m) {T : Type*} (keep : LayerSamplerVariables G I n B → Prop) + (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) (hQU : U j ≤ LinearMap.ker Q) + (Ktarget : Submodule ℝ (J j → ℝ)) (hker : LinearMap.ker Q ≤ Ktarget) + {C CQ D H : ℝ} (hC : 0 ≤ C) (hCQ : 0 ≤ CQ) (hD : 0 < D) + (hchart : ∀ x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C * ‖x‖) + (hQ : ∀ x t, |Q x t| ≤ CQ * ‖x‖) + (hgrid : ∀ z : J j → ℤ, ∀ t, ∃ a : ℤ, D * Q (fun i => (z i : ℝ)) t = a) + (hlong : ∀ i, keep i → H ≤ layerSamplerBox B U b S i) + (hthreshold : CQ * (C * (((Fintype.card (I j) : ℝ) + 1) * R j)) * D < H) + (fixed : {i // ¬ keep i} → ℤ) (x : {i // keep i} → ℝ) : + (fun i => + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) + (freezePolynomial keep fixed (allocatedRecoveredIntegerFullChart B U b o poly hm + c a v sample (Sum.inr ⟨j, i⟩)))) - + MvPolynomial.eval 0 (MvPolynomial.map (Int.castRingHom ℝ) + (freezePolynomial keep fixed (allocatedRecoveredIntegerFullChart B U b o poly hm + c a v sample (Sum.inr ⟨j, i⟩))))) ∈ Ktarget := by + apply hker + apply polynomialFamily_eval_sub_zero_mem _ (LinearMap.ker Q) _ x + exact h.integerFullChart_frozen_coeff B U b hb o S hR hσ poly hm hσ1 c a v sample read + j keep Q hQU hC hCQ hD hchart hQ hgrid hlong hthreshold fixed + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule _root_.MvPolynomial _root_.OAI.MvPolynomial BooleanCubeKernel +open scoped BigOperators + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_certified_frozen_affine_range + (hσ1 : ∀ j, σ j ≤ 1) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) {Bstage p M H : ℝ} {blocks : ℕ} + (hcertificate : RationalTaggedConstraintCertificate J Set.univ K Bstage blocks) + (hretained : ∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ U j) → t ∈ K) + (hp : 0 ≤ p) (hBp : Bstage ≤ p) (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C j * ‖x‖) + (hM : 0 ≤ M) (hcap : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ M) + (keep : LayerSamplerVariables G I n B → Prop) + (hlong : ∀ i, keep i → H ≤ layerSamplerBox B U b S i) + (hthreshold : Real.exp ((p + 2) ^ 9) ^ 2 * M < H) + (fixed : {i // ¬ keep i} → ℤ) (x : {i // keep i} → ℝ) : + (fun i => MvPolynomial.eval x + (integerSampledRealChart + (fun z => freezePolynomial keep fixed + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample z)) i) - + MvPolynomial.eval 0 + (integerSampledRealChart + (fun z => freezePolynomial keep fixed + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample z)) i)) ∈ K := by + obtain ⟨cs, _, hbudget, hK⟩ := hcertificate + rw [hK] + refine ⟨Set.mem_univ _, ?_⟩ + intro constraint hc + have hspan : U constraint.tag ≤ + span ℝ (Set.range (fun q i => (constraint.generators q i : ℝ))) := by + apply constraint.retained_le_span U hretained + intro point hpoint + rw [hK] at hpoint + exact hpoint.2 constraint hc + obtain ⟨d, _, Q, hker, hQ, D, hD, hDbound, hgrid⟩ := + exists_rationalTaggedSpanProjection constraint.generators hp (hJ constraint.tag) + ((hbudget constraint hc).1.trans hBp) + (fun q i => ((hbudget constraint hc).2 q i).trans hBp) + have hQU : U constraint.tag ≤ LinearMap.ker Q := by + rw [hker] + exact hspan + have hgrid' : ∀ z : J constraint.tag → ℤ, ∀ t, + ∃ a : ℤ, (D : ℝ) * Q (fun i => (z i : ℝ)) t = a := by + intro z t + obtain ⟨w, hw⟩ := hgrid z + exact ⟨w t, (hw t).symm⟩ + have hnumeric : Real.exp ((p + 2) ^ 9) * + (C constraint.tag * (((Fintype.card (I constraint.tag) : ℝ) + 1) * R constraint.tag)) * + (D : ℝ) < H := by + have hE := Real.exp_nonneg ((p + 2) ^ 9) + calc + _ ≤ Real.exp ((p + 2) ^ 9) * M * (D : ℝ) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left (hcap constraint.tag) hE) + (Nat.cast_nonneg D) + _ ≤ Real.exp ((p + 2) ^ 9) * M * Real.exp ((p + 2) ^ 9) := + mul_le_mul_of_nonneg_left hDbound (mul_nonneg hE hM) + _ = Real.exp ((p + 2) ^ 9) ^ 2 * M := by ring + _ < H := hthreshold + exact h.integerFullChart_frozen_affine_range B U b hb o S hR hσ poly hm hσ1 c a v sample read + constraint.tag keep Q hQU _ (le_of_eq hker) (hC constraint.tag) + (Real.exp_nonneg _) (by exact_mod_cast hD) (hchart constraint.tag) hQ hgrid' + hlong hnumeric fixed x + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalLocalChart +variable {cost : ℝ} (C : AllocatedExternalLocalChart (E := E) A cost) + +noncomputable def tagAnchor (j : Fin m) : J j → ℝ := + fun i => MvPolynomial.eval (0 : C.Variables → ℝ) + (integerSampledRealChart C.integerChart (Sum.inr ⟨j, i⟩)) + +theorem fixed_abs_le_box (i : {i // ¬C.keep i}) : + |(C.fixed i : ℝ)| ≤ layerSamplerBox B U b S i.val := by + rw [abs_of_nonneg (by exact_mod_cast (C.fixed_in_box i).1), + allocatedParameterBox_side_eq B U b S] + exact_mod_cast (C.fixed_in_box i).2.le + +theorem tagAnchor_quotient_bound + (hσone : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (j : Fin m) {T : Type*} (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) + (hQU : U j ≤ LinearMap.ker Q) {CQ : ℝ} (hCQ : 0 ≤ CQ) + (hQ : ∀ x i, |Q x i| ≤ CQ * ‖x‖) (i : T) : + |Q (C.tagAnchor j) i| ≤ CQ * (Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j)) := + C.recovered.integerFrozenFullChart_anchor_bound B U b hb o S hR hσ poly hm + hσone Cgeo hCgeo hchart hp C.centerLift C.path.1.val C.path.2.val C.sample C.read + j Q hQU hCQ hQ C.keep C.fixed C.fixed_abs_le_box i + +theorem tagAnchor_quotient_grid + (j : Fin m) {T : Type*} (Q : (J j → ℝ) →ₗ[ℝ] (T → ℝ)) (den : ℕ) + (hgrid : ∀ z : J j → ℤ, ∀ i, ∃ a : ℤ, (den : ℝ) * Q (fun i => (z i : ℝ)) i = a) + (i : T) : ∃ a : ℤ, (den : ℝ) * Q (C.tagAnchor j) i = a := + allocatedFrozenIntegerFullChart_anchor_grid B U b o poly hm + C.centerLift C.path.1.val C.path.2.val C.sample j Q (den : ℝ) hgrid C.keep C.fixed i + +end AllocatedExternalLocalChart + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +theorem exists_common_affine_anchor_refinement + (Q : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (den : Fin m → ℕ) + (hden : ∀ j, 0 < den j) {p : ℝ} (hp : 0 ≤ p) + (hdim : (Fintype.card (Σ j, J j) : ℝ) ≤ p) + (hdenp : ∀ j, (den j : ℝ) ≤ Real.exp p) + (hgrid : ∀ j (z : J j → ℤ) i, ∃ a : ℤ, (den j : ℝ) * Q j (fun i => (z i : ℝ)) i = a) + (hbound : ∀ z : P.productive, ∀ j i, + |Q j ((P.chart z).tagAnchor j) i| ≤ Real.exp p) + (hmass : 0 < massThreshold) : + ∃ (c : ∀ j, J j → ℝ) + (refinement : P.Refinement cost + (Real.exp (-((2*p+3)^3)) * massThreshold) scoreThreshold), + (∀ j i, |c j i| ≤ Real.exp p) ∧ + (∀ j i, ∃ a : ℤ, (den j : ℝ) * c j i = a) ∧ + (∀ z : refinement.problem.productive, ∀ j, + Q j ((refinement.problem.chart z).tagAnchor j) = c j) ∧ + (∀ z : refinement.problem.productive, + (refinement.problem.chart z).slice.integerPoints = + (P.chart ⟨z.val, refinement.subset z.property⟩).slice.integerPoints) := by + let v (a : A.Path) : (Σ j, J j) → ℝ := + if ha : a ∈ P.productive then fun i => Q i.1 ((P.chart ⟨a,ha⟩).tagAnchor i.1) i.2 + else 0 + have hv (z : P.productive) (i : Σ j, J j) : + v z.val i = Q i.1 ((P.chart z).tagAnchor i.1) i.2 := by + simp only [v, dite_eq_left z.property] + obtain ⟨a₀, ha₀, retained, hsub, haT, hsame, hmassT⟩ := + exists_weighted_common_coordinate_grid_vector A.law P.productive (hmass.trans_le P.mass) + v (fun i => den i.1) (fun i => hden i.1) hp hdim (fun i => hdenp i.1) + (by + intro a ha i + rw [hv ⟨a,ha⟩] + exact (P.chart ⟨a,ha⟩).tagAnchor_quotient_grid i.1 (Q i.1) (den i.1) (hgrid i.1) i.2) + (by intro a ha i; rw [hv ⟨a,ha⟩]; exact hbound ⟨a,ha⟩ i.1 i.2) + let refinement : P.Refinement cost + (Real.exp (-((2*p+3)^3)) * massThreshold) scoreThreshold := + { retained := retained + subset := hsub + mass := (mul_le_mul_of_nonneg_left P.mass (Real.exp_nonneg _)).trans hmassT + cost_le := le_rfl + step := fun z => (P.chart ⟨z.val,hsub z.property⟩).step + step_pos := fun z => (P.chart ⟨z.val,hsub z.property⟩).step_pos + slice := fun z => (P.chart ⟨z.val,hsub z.property⟩).slice + dense := fun z => (P.chart ⟨z.val,hsub z.property⟩).dense + inside := fun _ => Finset.Subset.refl _ + scoreLower := fun z => P.score ⟨z.val,hsub z.property⟩ } + refine ⟨fun j i => v a₀ ⟨j,i⟩, refinement, ?_, ?_, ?_, ?_⟩ + · intro j i + change |v a₀ ⟨j,i⟩| ≤ Real.exp p + rw [hv ⟨a₀,ha₀⟩ ⟨j,i⟩] + exact hbound ⟨a₀,ha₀⟩ j i + · intro j i + change ∃ a : ℤ, (den j : ℝ) * v a₀ ⟨j,i⟩ = a + rw [hv ⟨a₀,ha₀⟩ ⟨j,i⟩] + exact (P.chart ⟨a₀,ha₀⟩).tagAnchor_quotient_grid j (Q j) (den j) (hgrid j) i + · intro z j + funext i + change Q j ((P.chart ⟨z.val,hsub z.property⟩).tagAnchor j) i = v a₀ ⟨j,i⟩ + exact (hv ⟨z.val,hsub z.property⟩ ⟨j,i⟩).symm.trans + (congrFun (hsame z.val z.property) ⟨j,i⟩) + · intro z + rfl + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalLocalChart +variable {cost : ℝ} (C : AllocatedExternalLocalChart (E := E) A cost) + +theorem tag_values_sub_anchor_mem + (hσone : ∀ j, σ j ≤ 1) + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) {p Mbound H : ℝ} {blocks : ℕ} + (hcertificate : RationalTaggedConstraintCertificate J Set.univ K p blocks) + (hretained : ∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ U j) → t ∈ K) + (hp : 0 ≤ p) (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hM : 0 ≤ Mbound) + (hcap : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ Mbound) + (hlong : ∀ i, C.keep i → H ≤ layerSamplerBox B U b S i) + (hthreshold : Real.exp ((p + 2) ^ 9) ^ 2 * Mbound < H) + (x : C.Variables → ℝ) : + (fun i => MvPolynomial.eval x (integerSampledRealChart C.integerChart i) - + MvPolynomial.eval 0 (integerSampledRealChart C.integerChart i)) ∈ K := + C.recovered.integerFullChart_certified_frozen_affine_range B U b hb o S hR hσ poly hm + hσone C.centerLift C.path.1.val C.path.2.val C.sample C.read K hcertificate hretained + hp le_rfl hJ Cgeo hCgeo hchart hM hcap C.keep hlong hthreshold C.fixed x + +end AllocatedExternalLocalChart + +omit [Fintype X] [∀ j, Fintype (J j)] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] in +theorem retained_tag_le_of_product_constraint + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) + (V : ∀ j, Submodule ℝ (J j → ℝ)) + (hK : K = {t | ∀ j, (fun i => t (Sum.inr ⟨j,i⟩)) ∈ V j}) + (hretained : ∀ t, (∀ j, (fun i => t (Sum.inr ⟨j,i⟩)) ∈ U j) → t ∈ K) + (j : Fin m) : U j ≤ V j := by + intro x hx + let t : X ⊕ (Σ k, J k) → ℝ := + Sum.elim (fun _ => 0) (fun i => (Pi.single j x : ∀ k, J k → ℝ) i.1 i.2) + have ht : ∀ k, (fun i => t (Sum.inr ⟨k,i⟩)) ∈ U k := by + intro k + by_cases hk : k = j + · subst k + simpa only [t, Sum.elim_inr, Pi.single_eq_same] using hx + · simpa only [t, Sum.elim_inr, Pi.single_eq_of_ne hk, Pi.zero_apply, Pi.zero_def] using (U k).zero_mem + have htK := hretained t ht + rw [hK] at htK + simpa only [t, Sum.elim_inr, Pi.single_eq_same] using htK j + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +noncomputable def certifiedAffineCenterBudget (p : ℝ) : ℝ := + let q := p + ((p+2)^2+2)^63 + 2*p + (q+2)^10 + (q+2)^8 + 1 + +private theorem affineCenterBudget_arithmetic {p a b : ℝ} + (hp : 0 ≤ p) (ha : 0 ≤ a) (hb : 0 ≤ b) : + 0 ≤ 2*p+a+b+1 ∧ p ≤ 2*p+a+b+1 ∧ a ≤ 2*p+a+b+1 ∧ + 2*p+b+1 ≤ 2*p+a+b+1 := by + constructor + · linarith only [hp, ha, hb] + constructor + · linarith only [hp, ha, hb] + constructor <;> linarith only [hp, ha, hb] + +private theorem affineCenterBudget_exp {p b : ℝ} : + Real.exp (p+b+1) * Real.exp p = Real.exp (2*p+b+1) := by + rw [← Real.exp_add] + congr 1 + ring + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +structure CertifiedAffineRefinement + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) (p : ℝ) where + space : ∀ j, Submodule ℚ (J j → ℚ) + projection : ∀ j, Matrix (J j) (J j) ℚ + denominator : Fin m → ℕ + constraint : K = {t | ∀ j, (fun i => t (Sum.inr ⟨j,i⟩)) ∈ realRationalCoordinateSpan (space j)} + range_eq : ∀ j, LinearMap.range (fullTaggedRealMatrixProjection J projection j) = + realRationalCoordinateSpan (space j) + fixes_space : ∀ j x, x ∈ realRationalCoordinateSpan (space j) → + fullTaggedRealMatrixProjection J projection j x = x + projection_height : ∀ j i a, rationalLogHeight (projection j i a) ≤ + ((p + ((p+2)^2+2)^63) + 2)^8 + denominator_pos : ∀ j, 0 < denominator j + denominator_bound : ∀ j, (denominator j : ℝ) ≤ Real.exp (certifiedAffineCenterBudget p) + projection_grid : ∀ j i a, ∃ z : ℤ, (denominator j : ℝ) * (projection j i a : ℝ) = z + translate : ∀ j, J j → ℝ + translate_bound : ∀ j i, |translate j i| ≤ Real.exp (certifiedAffineCenterBudget p) + translate_grid : ∀ j i, ∃ z : ℤ, (denominator j : ℝ) * translate j i = z + translate_fixed : ∀ j, rationalTagProjectionComplement (projection j) (translate j) = translate j + refinement : P.Refinement cost + (Real.exp (-((2*certifiedAffineCenterBudget p+3)^3)) * massThreshold) scoreThreshold + slice_points : ∀ z : refinement.problem.productive, + (refinement.problem.chart z).slice.integerPoints = + (P.chart ⟨z.val, refinement.subset z.property⟩).slice.integerPoints + chart_fixed : ∀ z : refinement.problem.productive, ∀ x : (refinement.problem.chart z).Variables → ℝ, + (fun v => MvPolynomial.eval + (fun i => MvPolynomial.eval x (integerSampledRealChart (refinement.problem.chart z).integerChart i)) + (fullTaggedAffineMapChart J (fullTaggedRealMatrixProjection J projection) translate v)) = + (fun i => MvPolynomial.eval x (integerSampledRealChart (refinement.problem.chart z).integerChart i)) + +theorem exists_certifiedAffineRefinement + (hσone : ∀ j, σ j ≤ 1) + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) {p H : ℝ} {blocks : ℕ} + (hcertificate : RationalTaggedConstraintCertificate J Set.univ K p blocks) + (hretained : ∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ U j) → t ∈ K) + (hp : 0 ≤ p) (hdim : (Fintype.card (Σ j, J j) : ℝ) ≤ p) + (hblocks : (blocks : ℝ) ≤ p) + (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hcap : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ Real.exp p) + (hlong : ∀ z : P.productive, ∀ i, (P.chart z).keep i → H ≤ layerSamplerBox B U b S i) + (hthreshold : Real.exp ((p + 2) ^ 9) ^ 2 * Real.exp p < H) + (hmass : 0 < massThreshold) : Nonempty (P.CertifiedAffineRefinement K p) := by + let q := p + ((p+2)^2+2)^63 + let labelBudget := certifiedAffineCenterBudget p + have hlabel : labelBudget = 2*p+(q+2)^10+(q+2)^8+1 := rfl + have hbudget := affineCenterBudget_arithmetic hp + (show 0 ≤ (q+2)^10 from by positivity) (show 0 ≤ (q+2)^8 from by positivity) + have hlabel0 : 0 ≤ labelBudget := hlabel.symm ▸ hbudget.1 + have hplabel : p ≤ labelBudget := hlabel.symm ▸ hbudget.2.1 + have hdenlabel : (q+2)^10 ≤ labelBudget := hlabel.symm ▸ hbudget.2.2.1 + have hdimj (j : Fin m) : (Fintype.card (J j) : ℝ) ≤ p := + (Nat.cast_le.mpr (Fintype.card_le_of_injective (Sigma.mk j) (by intro a b h; cases h; rfl))).trans hdim + obtain ⟨V, projection, den, hK, hP⟩ := + hcertificate.exists_bounded_rational_retractions J hp hdimj hblocks + let Q := fun j => rationalTagProjectionComplement (projection j) + have hQU (j : Fin m) : U j ≤ LinearMap.ker (Q j) := by + rw [rationalTagProjectionComplement_ker (projection j) (V j) (hP j).1 (hP j).2.1] + exact retained_tag_le_of_product_constraint K (fun j => realRationalCoordinateSpan (V j)) hK hretained j + have hgrid (j : Fin m) (z : J j → ℤ) (i : J j) : + ∃ a : ℤ, (den j : ℝ) * Q j (fun i => (z i : ℝ)) i = a := by + obtain ⟨a, ha⟩ := rationalTagProjectionComplement_integer_grid (projection j) (den j) + (hP j).2.2.2.2.2.1 z + exact ⟨a i, ha i⟩ + have hbound (z : P.productive) (j : Fin m) (i : J j) : + |Q j ((P.chart z).tagAnchor j) i| ≤ Real.exp labelBudget := by + have hraw := (P.chart z).tagAnchor_quotient_bound hσone Cgeo hCgeo hchart hpoly + j (Q j) (hQU j) (Real.exp_nonneg (p+(q+2)^8+1)) + (rationalTagProjectionComplement_coordinate_exp_bound (projection j) hp + (by positivity : 0 ≤ (q+2)^8) (hdimj j) (hP j).2.2.1) i + calc + _ ≤ Real.exp (p+(q+2)^8+1) * + (Cgeo j * (((Fintype.card (I j) : ℝ)+1)*R j)) := hraw + _ ≤ Real.exp (p+(q+2)^8+1) * Real.exp p := + mul_le_mul_of_nonneg_left (hcap j) (Real.exp_nonneg _) + _ = Real.exp (2*p+(q+2)^8+1) := affineCenterBudget_exp + _ ≤ Real.exp labelBudget := Real.exp_le_exp.mpr (hlabel.symm ▸ hbudget.2.2.2) + obtain ⟨c, refinement, hcBound, hcGrid, hc, hpoints⟩ := + P.exists_common_affine_anchor_refinement Q den (fun j => (hP j).2.2.2.1) + hlabel0 (hdim.trans hplabel) + (fun j => (hP j).2.2.2.2.1.trans (Real.exp_le_exp.mpr hdenlabel)) + hgrid hbound hmass + have hnonempty : refinement.problem.productive.Nonempty := by + apply Finset.nonempty_of_ne_empty + intro he + have h := refinement.mass + change Real.exp (-((2*labelBudget+3)^3)) * massThreshold ≤ + A.law.mass refinement.problem.productive at h + rw [he] at h + have hpos : 0 < Real.exp (-((2*labelBudget+3)^3)) * massThreshold := + mul_pos (Real.exp_pos _) hmass + simpa [FiniteProbabilityWeights.mass] using hpos.trans_le h + obtain ⟨z₀,hz₀⟩ := hnonempty + have hcFixed (j : Fin m) : Q j (c j) = c j := by + rw [← hc ⟨z₀,hz₀⟩ j] + exact rationalTagProjectionComplement_idempotent (projection j) (V j) + (hP j).1 (hP j).2.1 _ + refine ⟨{ + space := V + projection := projection + denominator := den + constraint := hK + range_eq := fun j => (hP j).1 + fixes_space := fun j => (hP j).2.1 + projection_height := fun j => (hP j).2.2.1 + denominator_pos := fun j => (hP j).2.2.2.1 + denominator_bound := fun j => (hP j).2.2.2.2.1.trans (Real.exp_le_exp.mpr hdenlabel) + projection_grid := fun j => (hP j).2.2.2.2.2.1 + translate := c + translate_bound := hcBound + translate_grid := hcGrid + translate_fixed := hcFixed + refinement := refinement + slice_points := hpoints + chart_fixed := ?_ }⟩ + intro z x + apply fullTaggedAffineMatrixChart_eval_eq_of_anchor J projection c + (refinement.problem.chart z).tagAnchor _ ?_ (hc z) hcFixed + intro j + have hkeep (i) (hi : (refinement.problem.chart z).keep i) : H ≤ layerSamplerBox B U b S i := + hlong ⟨z.val,refinement.subset z.property⟩ i hi + have hrange := (refinement.problem.chart z).tag_values_sub_anchor_mem hσone K + hcertificate hretained hp hdimj Cgeo hCgeo hchart (Real.exp_nonneg _) hcap hkeep hthreshold x + rw [hK] at hrange + have hmem := hrange j + rw [← rationalTagProjectionComplement_ker (projection j) (V j) (hP j).1 (hP j).2.1] at hmem + exact hmem + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +namespace CertifiedAffineRefinement +variable {P} {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p : ℝ} + (Raff : P.CertifiedAffineRefinement K p) + {κ : Type*} (cF : Basis κ ℚ M) (ν : κ → ℕ) + (hF : ∀ j, Fmark.layer j = span ℚ (cF '' {i | j ≤ ν i})) + {W : LieSubalgebra ℚ Fmark.AssociatedGraded} + {EF RF : Fmark.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)} + (factors : GlobalMarkedNativeFactors Fmark cF ν hF (fullTaggedVariableWeight J) W + (Fmark.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fullTaggedVariableWeight J) + (fullTaggedAffineMapChart J (fullTaggedRealMatrixProjection J Raff.projection) Raff.translate) + (fullTaggedAffineMapChart_support J _ Raff.translate) + (Fmark.realification.polynomialOrbitCoordinates _ marked)) EF RF) + (z : Raff.refinement.problem.productive) + +theorem actual_chart_product : + let C := Raff.refinement.problem.chart z + let pull := Fmark.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : C.Variables => 1) (integerSampledRealChart C.integerChart) C.integerChart_support + pull factors.left * pull factors.middle * pull factors.right = + pull (Fmark.realification.polynomialOrbitCoordinates _ marked) := by + dsimp only + rw [← map_mul, ← map_mul, factors.product] + exact Fmark.weightedAdaptedRealChartHom_eq_of_fixed_chart _ _ _ _ _ _ + (Raff.chart_fixed z) _ + +theorem actual_chart_native_conditions : + let C := Raff.refinement.problem.chart z + let pull := Fmark.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : C.Variables => 1) (integerSampledRealChart C.integerChart) C.integerChart_support + let residual := (pull factors.left)⁻¹ * + pull (Fmark.realification.polynomialOrbitCoordinates _ marked) * (pull factors.right)⁻¹ + (Fmark.realPolynomialSymbolHom cF ν hF (fun _ : C.Variables => 1) residual).coord ∈ + realificationLieSubalgebra + (Fmark.symbolPointwiseSubalgebra cF ν hF (fun _ : C.Variables => 1) W) ∧ + coefficients (residual.coord : VectorPolynomial C.Variables ℚ (ℝ ⊗[ℚ] M)) 0 ∈ + Fmark.realGradedRefiltrationLayer W 1 := by + exact factors.fixed_chart_native_conditions + (integerSampledRealChart (Raff.refinement.problem.chart z).integerChart) + (Raff.refinement.problem.chart z).integerChart_support (Raff.chart_fixed z) + +theorem actual_chart_right_grid {q : ℕ} + (hgrid : Fmark.PolynomialRationalGrid cF (fullTaggedVariableWeight J) q factors.right) : + let C := Raff.refinement.problem.chart z + Fmark.PolynomialRationalGrid cF (fun _ : C.Variables => 1) q + (Fmark.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : C.Variables => 1) (integerSampledRealChart C.integerChart) + C.integerChart_support factors.right) := by + exact Fmark.polynomialRationalGrid_integerChart cF _ _ + (Raff.refinement.problem.chart z).integerChart + (Raff.refinement.problem.chart z).integerChart_support q factors.right hgrid + +end CertifiedAffineRefinement +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem exists_certifiedAffineCenterBudget_power : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + certifiedAffineCenterBudget p + (2*certifiedAffineCenterBudget p+3)^3 + + (2*(p+2)^9+p+2) ≤ (p+C)^C := by + let X : Polynomial ℕ := Polynomial.X + let Q := X + ((X+2)^2+2)^63 + let L := 2*X+(Q+2)^10+(Q+2)^8+1 + let cost := L + (2*L+3)^3 + (2*(X+2)^9+X+2) + obtain ⟨C,hC,hcost⟩ := exists_natPolynomial_eval_budget cost + refine ⟨C,hC,?_⟩ + intro p hp + simpa only [cost, L, Q, X, certifiedAffineCenterBudget, + Polynomial.eval₂_add, Polynomial.eval₂_mul, Polynomial.eval₂_pow, + Polynomial.eval₂_X, Polynomial.eval₂_ofNat, Polynomial.eval₂_one] using hcost p hp + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem candidateSideCutoffCost_exp_bound {p : ℝ} (hp : 0 ≤ p) : + candidateSideCutoffCost (Real.exp p) ≤ p+2 := by + have hside := candidateSideCutoff_pos (Real.exp p) + rw [candidateSideCutoffCost, max_eq_left hside] + apply (Real.log_le_iff_le_exp (Nat.cast_pos.mpr hside)).mpr + have hcut := candidateSideCutoff_lt_max_add_two (Real.exp p) + rw [max_eq_left (Real.exp_nonneg _)] at hcut + have hlarge := Real.one_le_exp hp + calc + _ ≤ Real.exp p + 2 := hcut.le + _ ≤ 3 * Real.exp p := by linarith only [hlarge] + _ ≤ Real.exp 2 * Real.exp p := + mul_le_mul_of_nonneg_right (by linarith only [Real.add_one_le_exp (2 : ℝ)]) (Real.exp_nonneg _) + _ = Real.exp (p+2) := by rw [← Real.exp_add, add_comm] + +theorem candidateSideCutoffCost_canonical_affine {p : ℝ} (hp : 0 ≤ p) : + candidateSideCutoffCost (Real.exp ((p+2)^9)^2 * Real.exp p) ≤ + 2*(p+2)^9+p+2 := by + have heq : Real.exp ((p+2)^9)^2 * Real.exp p = Real.exp (2*(p+2)^9+p) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + norm_num only [Nat.cast_ofNat] + rw [heq] + exact candidateSideCutoffCost_exp_bound (by positivity) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedAffineNormalizedBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedAffineNormalizedBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..b435329ebd7325a23d27fe0cbea6efc863ca2a39 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedAffineNormalizedBudget.lean @@ -0,0 +1,620 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedCandidateZeroRestrictedNativeCommonTerminal +import OAI.Combinatorics.Progressions.Lattices.AllocatedCertifiedAffinePhysicalSlowBound + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +attribute [local irreducible] integerProgressionSupport + +noncomputable def certifiedAffineLongSideBound (p : ℝ) : ℝ := + Real.exp ((p + 2) ^ 9) ^ 2 * Real.exp p + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +structure CertifiedThresholdAffineRefinement + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) (p separation : ℝ) where + freezing : P.AxisFreezing (P.realThresholdKeep separation) (candidateSideCutoffCost separation) + affine : freezing.problem.CertifiedAffineRefinement K p + +namespace CertifiedThresholdAffineRefinement + +variable {P} {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p separation : ℝ} + (selected : P.CertifiedThresholdAffineRefinement K p separation) + +noncomputable abbrev problem := selected.affine.refinement.problem + +theorem long (z : selected.problem.productive) (i : LayerSamplerVariables G I n B) + (hi : (selected.problem.chart z).keep i) : + separation < layerSamplerBox B U b S i := + selected.freezing.realThreshold_strict_long + ⟨z.val, selected.affine.refinement.subset z.property⟩ i hi + +noncomputable def conclusion {outputCost outputMass outputScore : ℝ} + (out : selected.problem.Conclusion outputCost outputMass outputScore) : + P.Conclusion (max outputCost (candidateSideCutoffCost separation)) outputMass outputScore := + selected.freezing.conclusion (selected.affine.refinement.conclusion out) + +end CertifiedThresholdAffineRefinement + +theorem exists_certifiedThresholdAffineRefinement + (hσone : ∀ j, σ j ≤ 1) + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) {p : ℝ} {blocks : ℕ} + (hcertificate : RationalTaggedConstraintCertificate J Set.univ K p blocks) + (hretained : ∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ U j) → t ∈ K) + (hp : 0 ≤ p) (hdim : (Fintype.card (Σ j, J j) : ℝ) ≤ p) + (hblocks : (blocks : ℝ) ≤ p) + (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hcap : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ Real.exp p) + (separation : ℝ) (hseparation : certifiedAffineLongSideBound p ≤ separation) + (hmass : 0 < massThreshold) : + Nonempty (P.CertifiedThresholdAffineRefinement K p separation) := by + obtain ⟨freezing, hlong, _⟩ := P.exists_realThresholdAxisFreezing separation + have hthreshold : Real.exp ((p + 2) ^ 9) ^ 2 * Real.exp p < + (candidateSideCutoff separation : ℝ) := + hseparation.trans_lt (lt_candidateSideCutoff separation) + obtain ⟨affine⟩ := freezing.problem.exists_certifiedAffineRefinement + hσone K hcertificate hretained hp hdim hblocks Cgeo hCgeo hchart hpoly hcap + hlong hthreshold hmass + exact ⟨⟨freezing, affine⟩⟩ + +theorem exists_certifiedAffineRefinement_after_freezing + (hσone : ∀ j, σ j ≤ 1) + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) {p : ℝ} {blocks : ℕ} + (hcertificate : RationalTaggedConstraintCertificate J Set.univ K p blocks) + (hretained : ∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ U j) → t ∈ K) + (hp : 0 ≤ p) (hdim : (Fintype.card (Σ j, J j) : ℝ) ≤ p) + (hblocks : (blocks : ℝ) ≤ p) + (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hcap : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ Real.exp p) + (hmass : 0 < massThreshold) : + Nonempty (P.CertifiedThresholdAffineRefinement K p (certifiedAffineLongSideBound p)) := + P.exists_certifiedThresholdAffineRefinement hσone K hcertificate hretained hp hdim hblocks + Cgeo hCgeo hchart hpoly hcap (certifiedAffineLongSideBound p) le_rfl hmass + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem.CertifiedThresholdAffineRefinement + +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p separation : ℝ} + +theorem common_keep (selected : P.CertifiedThresholdAffineRefinement K p separation) + (hcost : Real.exp cost ≤ separation) (z : selected.problem.productive) : + (selected.problem.chart z).keep = + fun i => candidateSideCutoff separation ≤ A.sides i := by + funext i + apply propext + change ((P.chart ⟨z.val, selected.affine.refinement.subset z.property⟩).keep i ∧ + candidateSideCutoff separation ≤ A.sides i) ↔ _ + constructor + · exact fun hi => hi.2 + · intro hi + refine ⟨?_, hi⟩ + by_contra hnot + have hfrozen := P.frozen_side + ⟨z.val, selected.affine.refinement.subset z.property⟩ ⟨i, hnot⟩ + have hside : (candidateSideCutoff separation : ℝ) ≤ (A.sides i : ℝ) := + Nat.cast_le.mpr hi + exact (not_lt_of_ge (hfrozen.trans hcost)) + ((lt_candidateSideCutoff separation).trans_le hside) + +end AllocatedExternalCandidateProblem.CertifiedThresholdAffineRefinement +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +attribute [local irreducible] HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates + weightedAdaptedRealChartHom + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + +namespace Refinement + +variable {newCost newMass newScore : ℝ} + (refinement : P.Refinement newCost newMass newScore) + +theorem nativeFactors + {ι : Type*} [Fintype ι] (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = Submodule.span ℚ (bD '' {i | j ≤ ω i})) + (q : ℝ) (l : ℕ) (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (hOriginal : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : (P.chart z).Variables => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (P.candidate z).orbit)) + (z : refinement.problem.productive) : + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : (refinement.problem.chart z).Variables => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (refinement.problem.candidate z).orbit) := + hOriginal ⟨z.val, refinement.subset z.property⟩ + +end Refinement + +namespace CertifiedThresholdAffineRefinement + +variable {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p separation : ℝ} + (selected : P.CertifiedThresholdAffineRefinement K p separation) + +theorem nativeFactors + {ι : Type*} [Fintype ι] (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = Submodule.span ℚ (bD '' {i | j ≤ ω i})) + (q : ℝ) (l : ℕ) (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (hOriginal : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : (P.chart z).Variables => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (P.candidate z).orbit)) + (z : selected.problem.productive) : + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : (selected.problem.chart z).Variables => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (selected.problem.candidate z).orbit) := + selected.affine.refinement.nativeFactors bD ω hD q l W + (fun a => selected.freezing.problem_nativeFactors bD ω hD q l W a (hOriginal a)) z + +theorem withKeep_nativeFactors + (keep : LayerSamplerVariables G I n B → Prop) + (hkeep : ∀ z : selected.problem.productive, (selected.problem.chart z).keep = keep) + {ι : Type*} [Fintype ι] (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = Submodule.span ℚ (bD '' {i | j ≤ ω i})) + (q : ℝ) (l : ℕ) (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (hOriginal : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : (P.chart z).Variables => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (P.candidate z).orbit)) + (z : selected.problem.productive) : + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : {i // keep i} => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + ((selected.problem.withKeep keep hkeep).candidate z).orbit) := + (selected.problem.candidate z).hasCommonRefilteredOrbitFactors_withKeep + keep (hkeep z) bD ω hD q l W (selected.nativeFactors bD ω hD q l W hOriginal z) + +end CertifiedThresholdAffineRefinement +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem.CertifiedThresholdAffineRefinement + +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p separation : ℝ} + +theorem original_dense (selected : P.CertifiedThresholdAffineRefinement K p separation) + (z : selected.problem.productive) : + IsDenseCommonStrideBox + (fun i : (selected.problem.chart z).Variables => A.sides i.val) cost + (selected.problem.chart z).slice.integerPoints := by + rw [selected.affine.slice_points z] + exact selected.freezing.problem_slice_dense + ⟨z.val, selected.affine.refinement.subset z.property⟩ + +theorem slice_length_gt (selected : P.CertifiedThresholdAffineRefinement K p separation) + (degree : ℕ) + (hseparation : Real.exp cost * ((degree + 1 : ℕ) : ℝ) ≤ separation) + (z : selected.problem.productive) (i : (selected.problem.chart z).Variables) : + degree < (selected.problem.chart z).slice.length i := + (selected.problem.chart z).slice_length_gt_of_dense_cutoff + (selected.original_dense z) degree hseparation + (fun a ha => (selected.long z a ha).le) i + +end AllocatedExternalCandidateProblem.CertifiedThresholdAffineRefinement +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +attribute [local irreducible] HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates + weightedAdaptedRealChartHom + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + +namespace CertifiedThresholdAffineRefinement + +variable {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p separation : ℝ} + (selected : P.CertifiedThresholdAffineRefinement K p separation) + +theorem nativeFactors_of_zero_restriction + (initialLong : LayerSamplerVariables G I n B → Prop) + (hsub : ∀ z i, P.realThresholdKeep separation z i → initialLong i) + {ι : Type*} [Fintype ι] (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = Submodule.span ℚ (bD '' {i | j ≤ ω i})) + (q : ℝ) (l : ℕ) (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (hzero : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : {i // initialLong i} => (A.sides i.val : ℝ)) q l W + (D.filtration.weightedAdaptedRealChartHom (fun _ : (P.chart z).Variables => 1) + (fun _ : {i // initialLong i} => 1) + ((P.chart z).axisPolynomial initialLong (fun _ => 0)) + ((P.chart z).axisPolynomial_support initialLong (fun _ => 0)) + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (P.candidate z).orbit))) + (z : selected.problem.productive) : + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : (selected.problem.chart z).Variables => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (selected.problem.candidate z).orbit) := + selected.affine.refinement.nativeFactors bD ω hD q l W + (fun a => selected.freezing.problem_nativeFactors_of_zero_restriction + initialLong hsub bD ω hD q l W a (hzero a)) z + +theorem withKeep_nativeFactors_of_zero_restriction + (keep : LayerSamplerVariables G I n B → Prop) + (hkeep : ∀ z : selected.problem.productive, (selected.problem.chart z).keep = keep) + (initialLong : LayerSamplerVariables G I n B → Prop) + (hsub : ∀ z i, P.realThresholdKeep separation z i → initialLong i) + {ι : Type*} [Fintype ι] (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = Submodule.span ℚ (bD '' {i | j ≤ ω i})) + (q : ℝ) (l : ℕ) (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (hzero : ∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : {i // initialLong i} => (A.sides i.val : ℝ)) q l W + (D.filtration.weightedAdaptedRealChartHom (fun _ : (P.chart z).Variables => 1) + (fun _ : {i // initialLong i} => 1) + ((P.chart z).axisPolynomial initialLong (fun _ => 0)) + ((P.chart z).axisPolynomial_support initialLong (fun _ => 0)) + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + (P.candidate z).orbit))) + (z : selected.problem.productive) : + D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : {i // keep i} => (A.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates (fun _ => 1) + ((selected.problem.withKeep keep hkeep).candidate z).orbit) := + (selected.problem.candidate z).hasCommonRefilteredOrbitFactors_withKeep + keep (hkeep z) bD ω hD q l W (selected.nativeFactors_of_zero_restriction initialLong hsub bD ω hD q l W hzero z) + +end CertifiedThresholdAffineRefinement +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical TensorProduct +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + symbolPointwiseSubalgebra realificationLieSubalgebra PolynomialRationalGrid PolynomialSlowBound + HasCommonRefilteredOrbitFactors polynomialOrbitCoordinates associatedGradedMap realPolynomialGroupMap + AllocatedExternalCandidateProblem.Refinement.problem + +theorem exists_allocatedThresholdAffineFamilyReset (s a : ℕ) : + ∃ Ccompare Cf Cnative : ℕ, 2 ≤ Ccompare ∧ 2 ≤ Cf ∧ 2 ≤ Cnative ∧ + ∀ {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ i, Fintype (B i)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ narrow : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {sampler : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ narrow stride cells center} + {L M κ ξ μ χ : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [Fintype κ] [Fintype ξ] [Fintype μ] [Fintype χ] + {d f : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + (ω : Fin d → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (D.basis '' {i | j ≤ ω i})) + (bF : Basis κ ℚ M) (ν : κ → ℕ) + (hF : ∀ j, Fmark.filtration.layer j = span ℚ (bF '' {i | j ≤ ν i})), + (∀ j, ∀ y ∈ Fmark.filtration.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) → + ∀ (separation : ℝ), + let keep : LayerSamplerVariables G I n B → Prop := + fun i => candidateSideCutoff separation ≤ sampler.sides i; + ∀ (bk : Basis ξ ℚ (LinearMap.ker φ.toLinearMap)) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) (v : μ → D.filtration.AssociatedGraded), + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hD) ω W.toSubmodule → + Submodule.span ℚ (Set.range v) = W.toSubmodule → + ∀ (vg : χ → Fmark.filtration.PolynomialSymbol (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + Submodule.span ℚ (Set.range vg) = + (Fmark.filtration.symbolPointwiseSubalgebra bF ν hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))).toSubmodule → + ∀ [Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ν)] + (H l nFinal : ℕ) (pMap pNative : ℝ), + 1 ≤ H → 0 < l → 0 < nFinal → 0 ≤ pMap → 0 ≤ pNative → + (Fintype.card (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ω) : ℝ) ≤ pMap → + (Fintype.card (SymbolBasisIndex (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) ν) : ℝ) ≤ pMap → + (H : ℝ) ≤ Real.exp pMap → ((l * nFinal : ℕ) : ℝ) ≤ Real.exp pMap → + Real.exp ((pMap + 2) ^ 4) ≤ Real.exp pNative → + (d : ℝ) ≤ pNative → (Fintype.card κ : ℝ) ≤ pNative → + (Fintype.card ξ : ℝ) ≤ pNative → (Fintype.card μ : ℝ) ≤ pNative → + (Fintype.card χ : ℝ) ≤ pNative → (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ pNative → + (H : ℝ) ≤ Real.exp pNative → + (∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) H) → + (∀ i j k, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ k) H) → + (∀ i j, RationalHeightLE (D.basis.repr (bk j : L) i) H) → + (∀ k i, RationalHeightLE (bF.repr (φ (D.basis i)) k) H) → + (∀ j i, RationalHeightLE ((D.filtration.associatedGradedBasis D.basis ω hD).repr (v j) i) H) → + (∀ i z, RationalHeightLE + ((Fmark.filtration.polynomialSymbolBasis bF ν hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)).repr (vg i) z) H) → + ∃ mMap mReset : ℕ, 0 < mMap ∧ (mMap : ℝ) ≤ Real.exp ((pMap + 2) ^ 4) ∧ + l * nFinal ∣ mMap ∧ 0 < mReset ∧ + (mReset : ℝ) ≤ Real.exp ((markedNativeLiftInput + (fullMarkedNativeInput (s + 1) a Cf pNative) + Cnative) ^ Cnative) ∧ mMap ∣ mReset ∧ + ∀ (marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)) + (observable : (X → ℤ) → D.Space → ℂ) (weight : (X → ℤ) → ℂ) + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) sampler D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {pAffine : ℝ} + (selected : P.CertifiedThresholdAffineRefinement K pAffine separation) + (hcost : Real.exp cost ≤ separation) + (EF RF : Fmark.filtration.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (factors : GlobalMarkedNativeFactors Fmark.filtration bF ν hF + (fullTaggedVariableWeight J) + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ)) + (Fmark.filtration.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fullTaggedVariableWeight J) selected.affine.globalChart selected.affine.globalChart_support + (Fmark.filtration.realification.polynomialOrbitCoordinates _ marked)) EF RF), + Fmark.filtration.PolynomialRationalGrid bF (fullTaggedVariableWeight J) nFinal factors.right → + (∀ z : selected.problem.productive, + let C := selected.problem.chart z + Fmark.filtration.PolynomialSlowBound bF (fun _ : C.Variables => 1) + (fun i => (sampler.sides i.val : ℝ)) (Real.exp ((pNative + 2) ^ a)) + (Fmark.filtration.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : C.Variables => 1) (integerSampledRealChart C.integerChart) + C.integerChart_support factors.left)) → + Real.exp ((pNative + Ccompare) ^ Ccompare) ≤ separation → + ∀ (q : ℝ), + Real.exp q ≤ Real.exp ((pNative + 2) ^ a) → + Real.exp ((pMap + 2) ^ 3 + q) ≤ Real.exp ((pNative + 2) ^ a) → + Real.exp cost * ((s + 1 + 1 : ℕ) : ℝ) ≤ separation → + (∀ z : P.productive, + D.filtration.HasCommonRefilteredOrbitFactors D.basis ω hD + (fun i : (P.chart z).Variables => (sampler.sides i.val : ℝ)) q l W + (D.filtration.realification.polynomialOrbitCoordinates _ (P.candidate z).orbit)) → + Nonempty (AllocatedExternalGlobalNativeResetFamily Fmark φ hφ + selected.problem keep (selected.common_keep hcost) W factors + (Real.exp ((markedNativeLiftInput (fullMarkedNativeInput (s + 1) a Cf pNative) + + Cnative) ^ Cnative)) mReset) := by + classical + obtain ⟨Ccompare, Cf, Cnative, hCcompare, hCf, hCnative, hreset⟩ := + exists_allocatedCertifiedAffineFamilyReset s a + refine ⟨Ccompare, Cf, Cnative, hCcompare, hCf, hCnative, ?_⟩ + intro m G X _ _ I E J _ _ n B _ U btag Rad σ S hb o hRad hσ N poly hm + τ narrow stride cells center _ sampler L M κ ξ μ χ _ _ _ _ _ _ _ _ d f + D Fmark φ hφ ω hD bF ν hF hsurj separation keep bk W v hW hvspan vg hvgspan _ _ + H l nFinal pMap pNative hH hl hnFinal hpMap hpNative hsrc htgt hHmap hlmap hmabsorb + hd hκ hξ hμ hχ hvars hHp hbracketD hbracketF hkernel hentries hv hvg + obtain ⟨mMap, mReset, hmMap, hmMapBound, hdiv, hmReset, hmResetBound, hmMapReset, hrun⟩ := + hreset (sampler := sampler) (E := E) D Fmark φ hφ ω hD bF ν hF hsurj keep + bk W v hW hvspan vg hvgspan H l nFinal pMap pNative hH hl hnFinal hpMap hpNative + hsrc htgt hHmap hlmap hmabsorb hd hκ hξ hμ hχ (by + convert hvars using 1 + simp only [Fintype.card_eq_nat_card]) hHp + hbracketD hbracketF hkernel hentries hv hvg + refine ⟨mMap, mReset, hmMap, hmMapBound, hdiv, hmReset, hmResetBound, hmMapReset, ?_⟩ + intro marked observable weight cost massThreshold scoreThreshold P K pAffine selected hcost + EF RF factors hgrid hslow hsideBound q hq hqmap hcutoff hOriginal + have hside (i : {i : LayerSamplerVariables G I n B // keep i}) : + Real.exp ((pNative + Ccompare) ^ Ccompare) ≤ (sampler.sides i.val : ℝ) := by + exact hsideBound.trans ((lt_candidateSideCutoff separation).le.trans + (Nat.cast_le.mpr i.property)) + have hlong (i : LayerSamplerVariables G I n B) (hi : keep i) : + separation ≤ layerSamplerBox B U btag S i := by + rw [allocatedParameterBox_side_eq B U btag S i] + exact (lt_candidateSideCutoff separation).le.trans (Nat.cast_le.mpr hi) + exact hrun marked observable weight selected.freezing.problem selected.affine + (selected.common_keep hcost) EF RF factors hgrid hslow hside q cost separation hq hqmap + selected.original_dense hcutoff hlong + (selected.withKeep_nativeFactors keep (selected.common_keep hcost) + D.basis ω hD q l W hOriginal) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +private theorem affine_selection_budget_arithmetic {p l loss c cutoff R : ℝ} + (_hp : 0 ≤ p) (hl : 0 ≤ l) (hloss : 0 ≤ loss) + (hpc : p ≤ c) (hcut : cutoff ≤ c) (hR : l+loss+c ≤ R) : + max p cutoff ≤ R ∧ + Real.exp (-R) ≤ Real.exp (-loss) * Real.exp (-p) ∧ + Real.exp (-R) ≤ Real.exp (-p) := by + have hpR : p ≤ R := by linarith only [_hp, hl, hloss, hpc, hR] + refine ⟨max_le hpR (by linarith only [_hp, hl, hloss, hpc, hcut, hR]), ?_, + Real.exp_le_exp.mpr (neg_le_neg hpR)⟩ + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + linarith only [hl, hpc, hR] + +theorem exists_certified_affine_normalized_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + max p (candidateSideCutoffCost (certifiedAffineLongSideBound p)) ≤ (p+C)^C ∧ + Real.exp (-(p+C)^C) ≤ + Real.exp (-((2*certifiedAffineCenterBudget p+3)^3)) * Real.exp (-p) ∧ + Real.exp (-(p+C)^C) ≤ Real.exp (-p) := by + obtain ⟨C,hC,hbudget⟩ := exists_certifiedAffineCenterBudget_power + refine ⟨C,hC,?_⟩ + intro p hp + have hL : 0 ≤ certifiedAffineCenterBudget p := by + unfold certifiedAffineCenterBudget + positivity + apply affine_selection_budget_arithmetic hp hL (by positivity) + (show p ≤ 2*(p+2)^9+p+2 by + have h := show 0 ≤ 2*(p+2)^9 from by positivity + linarith only [h]) + (candidateSideCutoffCost_canonical_affine hp) (hbudget p hp) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedFullChartAffineTerminal.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedFullChartAffineTerminal.lean new file mode 100644 index 0000000000000000000000000000000000000000..0237f9a7c19adee24e24ee8a0a50ee7e5bc3b59a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CertifiedFullChartAffineTerminal.lean @@ -0,0 +1,407 @@ +import Mathlib.LinearAlgebra.Projection +import OAI.Combinatorics.Progressions.Geometry.TerminalChartSlowEvaluation + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical + +noncomputable def retainedTagProjection {T : Type*} [Fintype T] + (U : Submodule ℝ (T → ℝ)) : (T → ℝ) →ₗ[ℝ] (T → ℝ) := + (PiLp.continuousLinearEquiv 2 ℝ (fun _ : T => ℝ)).toLinearMap.comp + ((euclideanSubspace U).starProjection.toLinearMap.comp + (PiLp.continuousLinearEquiv 2 ℝ (fun _ : T => ℝ)).symm.toLinearMap) + +theorem retainedTagProjection_mem {T : Type*} [Fintype T] + (U : Submodule ℝ (T → ℝ)) (x : T → ℝ) : retainedTagProjection U x ∈ U := + (euclideanSubspace U).starProjection_apply_mem _ + +theorem retainedTagProjection_eq {T : Type*} [Fintype T] + (U : Submodule ℝ (T → ℝ)) {x : T → ℝ} (hx : x ∈ U) : + retainedTagProjection U x = x := by + have he : (euclideanSubspace U).starProjection (WithLp.toLp 2 x) = WithLp.toLp 2 x := + Submodule.starProjection_eq_self_iff.mpr hx + exact congrArg WithLp.ofLp he + +theorem retainedTagProjection_entry_le_one {T : Type*} [Fintype T] + (U : Submodule ℝ (T → ℝ)) (a i : T) : + |retainedTagProjection U (Pi.single a 1) i| ≤ 1 := by + have h := (PiLp.norm_apply_le + ((euclideanSubspace U).starProjection (WithLp.toLp 2 (Pi.single a (1 : ℝ)))) i).trans + ((euclideanSubspace U).norm_starProjection_apply_le _) + change |((euclideanSubspace U).starProjection + (WithLp.toLp 2 (Pi.single a (1 : ℝ)))) i| ≤ 1 + simpa only [Real.norm_eq_abs, PiLp.toLp_single, PiLp.norm_single, norm_one] using h + +variable {m : ℕ} {X : Type*} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +noncomputable def fullTaggedLinearMapChart + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) : + X ⊕ (Σ j, J j) → MvPolynomial (X ⊕ (Σ j, J j)) ℝ + | Sum.inl x => MvPolynomial.X (Sum.inl x) + | Sum.inr ⟨j, i⟩ => ∑ a : J j, + (P j (Pi.single a 1) i) • MvPolynomial.X (Sum.inr ⟨j, a⟩) + +noncomputable def fullTaggedAffineMapChart + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) : + X ⊕ (Σ j, J j) → MvPolynomial (X ⊕ (Σ j, J j)) ℝ + | Sum.inl x => MvPolynomial.X (Sum.inl x) + | Sum.inr ⟨j, i⟩ => C (c j i - P j (c j) i) + + fullTaggedLinearMapChart J P (Sum.inr ⟨j, i⟩) + +theorem fullTaggedLinearMapChart_homogeneous + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (v : X ⊕ (Σ j, J j)) : + (fullTaggedLinearMapChart J P v).IsWeightedHomogeneous + (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) := by + cases v with + | inl x => exact isWeightedHomogeneous_X (R := ℝ) _ _ + | inr v => + apply (weightedHomogeneousSubmodule ℝ _ _).sum_mem + intro a _ + exact (weightedHomogeneousSubmodule ℝ _ _).smul_mem _ + (isWeightedHomogeneous_X (R := ℝ) (fullTaggedVariableWeight J) (Sum.inr ⟨v.1, a⟩)) + +theorem fullTaggedAffineMapChart_support + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) + (v : X ⊕ (Σ j, J j)) : + fullTaggedAffineMapChart J P c v ∈ + weightedSupportLE (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) := by + cases v with + | inl x => exact weightedSupportLE_X _ _ + | inr v => + apply (weightedSupportLE _ _).add_mem (weightedSupportLE_C _ _ _) + apply (weightedSupportLE _ _).sum_mem + intro a _ + exact (weightedSupportLE _ _).smul_mem _ + (weightedSupportLE_X (R := ℝ) (fullTaggedVariableWeight J) (Sum.inr ⟨v.1, a⟩)) + +theorem fullTaggedAffineMapChart_top + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) + (v : X ⊕ (Σ j, J j)) : + weightedHomogeneousComponent (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) + (fullTaggedAffineMapChart J P c v) = fullTaggedLinearMapChart J P v := by + cases v with + | inl x => exact weightedHomogeneousComponent_eq_self (isWeightedHomogeneous_X (R := ℝ) _ _) + | inr v => + change weightedHomogeneousComponent _ _ (C _ + _) = _ + rw [map_add, weightedHomogeneousComponent_of_mem (isWeightedHomogeneous_C (R := ℝ) _ _)] + simp only [fullTaggedVariableWeight, Sum.elim_inr, Nat.add_eq_zero_iff, + Nat.one_ne_zero, and_false, ↓reduceIte, zero_add] + exact weightedHomogeneousComponent_eq_self (fullTaggedLinearMapChart_homogeneous J P _) + +theorem fullTaggedLinearMapChart_eval_tag + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (x : X ⊕ (Σ j, J j) → ℝ) + (j : Fin m) (i : J j) : + MvPolynomial.eval x (fullTaggedLinearMapChart J P (Sum.inr ⟨j, i⟩)) = + P j (fun a => x (Sum.inr ⟨j, a⟩)) i := by + have hsum : ∑ a : J j, x (Sum.inr ⟨j, a⟩) • Pi.single a (1 : ℝ) = + (fun a => x (Sum.inr ⟨j, a⟩)) := by + ext a + simp [Pi.smul_apply, Pi.single_apply] + rw [fullTaggedLinearMapChart] + simp only [map_sum, smul_eq_C_mul, map_mul, eval_C, eval_X] + rw [← hsum, map_sum] + simp only [map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + apply Finset.sum_congr rfl + intro a _ + exact mul_comm _ _ + +theorem fullTaggedAffineMapChart_eval_tag + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X ⊕ (Σ j, J j) → ℝ) (j : Fin m) (i : J j) : + MvPolynomial.eval x (fullTaggedAffineMapChart J P c (Sum.inr ⟨j, i⟩)) = + c j i + P j ((fun a => x (Sum.inr ⟨j, a⟩)) - c j) i := by + rw [fullTaggedAffineMapChart, map_add, eval_C, fullTaggedLinearMapChart_eval_tag, + map_sub, Pi.sub_apply] + ring + +theorem fullTaggedAffineMapChart_top_mem_set + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (hP : ∀ j x, P j x ∈ U j) + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) + (hK : ∀ y, (∀ j, (fun i => y (Sum.inr ⟨j, i⟩)) ∈ U j) → y ∈ K) + (x : X ⊕ (Σ j, J j) → ℝ) : + (fun v => MvPolynomial.eval x + (weightedHomogeneousComponent (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) + (fullTaggedAffineMapChart J P c v))) ∈ K := by + apply hK + intro j + simp_rw [fullTaggedAffineMapChart_top, fullTaggedLinearMapChart_eval_tag] + exact hP j _ + +theorem fullTaggedAffineMapChart_eval_eq + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (hP : ∀ j y, y ∈ U j → P j y = y) + (x : X ⊕ (Σ j, J j) → ℝ) + (hx : ∀ j, (fun a => x (Sum.inr ⟨j, a⟩)) - c j ∈ U j) : + (fun v => MvPolynomial.eval x (fullTaggedAffineMapChart J P c v)) = x := by + funext v + cases v with + | inl a => exact MvPolynomial.eval_X _ + | inr v => + rw [fullTaggedAffineMapChart_eval_tag, hP _ _ (hx _), Pi.sub_apply] + ring + +theorem fullTaggedAffineMapChart_eval_eq_of_quotient + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (hP : ∀ j y, y ∈ U j → P j y = y) + {D : Fin m → Type*} [∀ j, AddCommGroup (D j)] [∀ j, Module ℝ (D j)] + (Q : ∀ j, (J j → ℝ) →ₗ[ℝ] D j) (hQ : ∀ j, LinearMap.ker (Q j) = U j) + (x : X ⊕ (Σ j, J j) → ℝ) + (hx : ∀ j, Q j (fun a => x (Sum.inr ⟨j, a⟩)) = Q j (c j)) : + (fun v => MvPolynomial.eval x (fullTaggedAffineMapChart J P c v)) = x := by + apply fullTaggedAffineMapChart_eval_eq J P c U hP x + intro j + rw [← hQ j, LinearMap.mem_ker, map_sub, hx j, sub_self] + +noncomputable def fullTaggedLinearRetraction + (U : ∀ j, Submodule ℝ (J j → ℝ)) : + X ⊕ (Σ j, J j) → MvPolynomial (X ⊕ (Σ j, J j)) ℝ + | Sum.inl x => MvPolynomial.X (Sum.inl x) + | Sum.inr ⟨j, i⟩ => ∑ a : J j, + (retainedTagProjection (U j) (Pi.single a 1) i) • MvPolynomial.X (Sum.inr ⟨j, a⟩) + +noncomputable def fullTaggedAffineRetraction + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) : + X ⊕ (Σ j, J j) → MvPolynomial (X ⊕ (Σ j, J j)) ℝ + | Sum.inl x => MvPolynomial.X (Sum.inl x) + | Sum.inr ⟨j, i⟩ => + C (c j i - retainedTagProjection (U j) (c j) i) + + fullTaggedLinearRetraction J U (Sum.inr ⟨j, i⟩) + +theorem fullTaggedLinearRetraction_homogeneous + (U : ∀ j, Submodule ℝ (J j → ℝ)) (v : X ⊕ (Σ j, J j)) : + (fullTaggedLinearRetraction J U v).IsWeightedHomogeneous + (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) := by + classical + cases v with + | inl x => exact isWeightedHomogeneous_X (R := ℝ) _ _ + | inr v => + apply (weightedHomogeneousSubmodule ℝ _ _).sum_mem + intro a _ + exact (weightedHomogeneousSubmodule ℝ _ _).smul_mem _ + (isWeightedHomogeneous_X (R := ℝ) (fullTaggedVariableWeight J) (Sum.inr ⟨v.1, a⟩)) + +theorem fullTaggedAffineRetraction_support + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (v : X ⊕ (Σ j, J j)) : + fullTaggedAffineRetraction J U c v ∈ + weightedSupportLE (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) := by + classical + cases v with + | inl x => exact weightedSupportLE_X _ _ + | inr v => + apply (weightedSupportLE _ _).add_mem (weightedSupportLE_C _ _ _) + apply (weightedSupportLE _ _).sum_mem + intro a _ + exact (weightedSupportLE _ _).smul_mem _ + (weightedSupportLE_X (R := ℝ) (fullTaggedVariableWeight J) (Sum.inr ⟨v.1, a⟩)) + +theorem fullTaggedAffineRetraction_top + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (v : X ⊕ (Σ j, J j)) : + weightedHomogeneousComponent (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) + (fullTaggedAffineRetraction J U c v) = fullTaggedLinearRetraction J U v := by + cases v with + | inl x => exact weightedHomogeneousComponent_eq_self (isWeightedHomogeneous_X (R := ℝ) _ _) + | inr v => + change weightedHomogeneousComponent _ _ (C _ + _) = _ + rw [map_add, weightedHomogeneousComponent_of_mem (isWeightedHomogeneous_C (R := ℝ) _ _)] + simp only [fullTaggedVariableWeight, Sum.elim_inr, Nat.add_eq_zero_iff, + Nat.one_ne_zero, and_false, ↓reduceIte, zero_add] + exact weightedHomogeneousComponent_eq_self (fullTaggedLinearRetraction_homogeneous J U _) + +theorem fullTaggedLinearRetraction_eval_tag + (U : ∀ j, Submodule ℝ (J j → ℝ)) (x : X ⊕ (Σ j, J j) → ℝ) + (j : Fin m) (i : J j) : + MvPolynomial.eval x (fullTaggedLinearRetraction J U (Sum.inr ⟨j, i⟩)) = + retainedTagProjection (U j) (fun a => x (Sum.inr ⟨j, a⟩)) i := by + classical + have hsum : ∑ a : J j, x (Sum.inr ⟨j, a⟩) • Pi.single a (1 : ℝ) = + (fun a => x (Sum.inr ⟨j, a⟩)) := by + ext a + simp [Pi.smul_apply, Pi.single_apply] + rw [fullTaggedLinearRetraction] + simp only [map_sum, smul_eq_C_mul, map_mul, eval_C, eval_X] + rw [← hsum, map_sum] + simp only [map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + apply Finset.sum_congr rfl + intro a _ + exact mul_comm _ _ + +theorem fullTaggedAffineRetraction_eval_tag + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X ⊕ (Σ j, J j) → ℝ) (j : Fin m) (i : J j) : + MvPolynomial.eval x (fullTaggedAffineRetraction J U c (Sum.inr ⟨j, i⟩)) = + c j i + retainedTagProjection (U j) ((fun a => x (Sum.inr ⟨j, a⟩)) - c j) i := by + rw [fullTaggedAffineRetraction, map_add, eval_C, fullTaggedLinearRetraction_eval_tag, + map_sub, Pi.sub_apply] + ring + +theorem fullTaggedAffineRetraction_top_mem + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X ⊕ (Σ j, J j) → ℝ) (j : Fin m) : + (fun i => MvPolynomial.eval x (weightedHomogeneousComponent (fullTaggedVariableWeight J) + (fullTaggedVariableWeight (X := X) J (Sum.inr ⟨j, i⟩)) + (fullTaggedAffineRetraction J U c (Sum.inr ⟨j, i⟩)))) ∈ U j := by + simp_rw [fullTaggedAffineRetraction_top, fullTaggedLinearRetraction_eval_tag] + exact retainedTagProjection_mem _ _ + +theorem fullTaggedAffineRetraction_top_mem_set + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) + (hK : ∀ y, (∀ j, (fun i => y (Sum.inr ⟨j, i⟩)) ∈ U j) → y ∈ K) + (x : X ⊕ (Σ j, J j) → ℝ) : + (fun v => MvPolynomial.eval x + (weightedHomogeneousComponent (fullTaggedVariableWeight J) (fullTaggedVariableWeight J v) + (fullTaggedAffineRetraction J U c v))) ∈ K := + hK _ (fun j => fullTaggedAffineRetraction_top_mem J U c x j) + +theorem fullTaggedAffineRetraction_eval_eq + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X ⊕ (Σ j, J j) → ℝ) + (hx : ∀ j, (fun a => x (Sum.inr ⟨j, a⟩)) - c j ∈ U j) : + (fun v => MvPolynomial.eval x (fullTaggedAffineRetraction J U c v)) = x := by + funext v + cases v with + | inl a => exact MvPolynomial.eval_X _ + | inr v => + rw [fullTaggedAffineRetraction_eval_tag, retainedTagProjection_eq _ (hx _), Pi.sub_apply] + ring + +theorem fullTaggedAffineRetraction_eval_eq_of_quotient + (U : ∀ j, Submodule ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + {D : Fin m → Type*} [∀ j, AddCommGroup (D j)] [∀ j, Module ℝ (D j)] + (Q : ∀ j, (J j → ℝ) →ₗ[ℝ] D j) (hQ : ∀ j, LinearMap.ker (Q j) = U j) + (x : X ⊕ (Σ j, J j) → ℝ) + (hx : ∀ j, Q j (fun a => x (Sum.inr ⟨j, a⟩)) = Q j (c j)) : + (fun v => MvPolynomial.eval x (fullTaggedAffineRetraction J U c v)) = x := by + apply fullTaggedAffineRetraction_eval_eq J U c x + intro j + rw [← hQ j, LinearMap.mem_ker, map_sub, hx j, sub_self] + +theorem RationalTaggedConstraintCertificate.exists_affineRetraction + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p : ℝ} {Cblocks : ℕ} + (hcert : RationalTaggedConstraintCertificate J Set.univ K p Cblocks) + (hp : 0 ≤ p) (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (hblocks : (Cblocks : ℝ) ≤ p) : + ∃ U : ∀ j, Submodule ℝ (J j → ℝ), + K = {x | ∀ j, (fun i => x (Sum.inr ⟨j, i⟩)) ∈ U j} ∧ + ∀ (c : ∀ j, J j → ℝ) (x : X ⊕ (Σ j, J j) → ℝ), + (fun v => MvPolynomial.eval x + (weightedHomogeneousComponent (fullTaggedVariableWeight J) + (fullTaggedVariableWeight J v) (fullTaggedAffineRetraction J U c v))) ∈ K := by + obtain ⟨W, n, b, _, _, hK⟩ := hcert.exists_bounded_tag_bases_univ hp hdim hblocks + let U := fun j => Submodule.span ℝ + (Set.range (fun a i => ((b j a : J j → ℚ) i : ℝ))) + refine ⟨U, hK, ?_⟩ + intro c x + apply fullTaggedAffineRetraction_top_mem_set J U c K _ x + intro y hy + rw [hK] + exact hy + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped TensorProduct + +namespace CertifiedFullChartFiniteHistory + +variable {m s : ℕ} {X ι η L : Type} [Fintype ι] [Fintype η] + [LieRing L] [LieAlgebra ℚ L] + {F : NilpotentLieFiltration L s} {b : Basis ι ℚ L} {ω : ι → ℕ} + {hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})} + {J : Fin m → Type} [∀ j, Fintype (J j)] + {W : LieSubalgebra ℚ F.AssociatedGraded} + {basis : Basis η ℝ (ℝ ⊗[ℚ] (F.AssociatedGraded ⧸ W.toSubmodule))} + {lift : (F.AssociatedGraded ⧸ W.toSubmodule) →ₗ[ℚ] F.AssociatedGraded} + {Z : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)} + {Utag : ∀ j, Submodule ℝ (J j → ℝ)} + {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} {N : X → ℕ} {Bphase : ℝ} + +local notation "wt" => fullTaggedVariableWeight (X := X) J + +theorem exists_affine_globalMarkedNativeFactors + (history : CertifiedFullChartFiniteHistory F b ω hF J W.toSubmodule basis lift + Z Set.univ Utag poly N Bphase s) + (hW : BasisGradedSubmodule (F.associatedGradedBasis b ω hF) ω W.toSubmodule) + (g : (F.realification.adaptedPolynomialFiltration wt).Group) + (hZ : F.realPolynomialSymbolHom b ω hF wt g = Z) + {p : ℝ} {blocks : ℕ} + (hcert : RationalTaggedConstraintCertificate J Set.univ history.K p blocks) + (hp : 0 ≤ p) (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (hblocks : (blocks : ℝ) ≤ p) : + ∃ (V : ∀ j, Submodule ℚ (J j → ℚ)) (n : Fin m → ℕ) + (v : ∀ j, Basis (Fin (n j)) ℚ (V j)), + (∀ j, n j ≤ Fintype.card (J j)) ∧ + (∀ j a i, rationalLogHeight ((v j a : J j → ℚ) i) ≤ ((p + 2) ^ 2 + 2) ^ 63) ∧ + let Ktag := fun j => Submodule.span ℝ + (Set.range (fun a i => ((v j a : J j → ℚ) i : ℝ))) + history.K = {t | ∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ Ktag j} ∧ + ∀ c : ∀ j, J j → ℝ, + let β := fullTaggedAffineRetraction (X := X) J Ktag c + let pull := F.realSymbolHomogeneousPullbackHom b ω hF wt wt + (fun i => weightedHomogeneousComponent wt (wt i) (β i)) + (fun _i => weightedHomogeneousComponent_isWeightedHomogeneous _ _) + Nonempty (GlobalMarkedNativeFactors F b ω hF wt W + (F.weightedAdaptedRealChartHom wt wt β + (fullTaggedAffineRetraction_support J Ktag c) g) + (pull history.outer.1) (pull history.outer.2)) := by + obtain ⟨V, n, v, hn, hv, hK⟩ := hcert.exists_bounded_tag_bases_univ hp hdim hblocks + refine ⟨V, n, v, hn, hv, hK, ?_⟩ + intro c + apply history.nonempty_globalMarkedNativeFactors hW _ _ g hZ + intro t + rw [hK] + exact fun j => fullTaggedAffineRetraction_top_mem J + (fun j => Submodule.span ℝ (Set.range (fun a i => ((v j a : J j → ℚ) i : ℝ)))) c t j + +end CertifiedFullChartFiniteHistory + +namespace GlobalMarkedNativeFactors + +variable {m s : ℕ} {X ι L : Type*} [LieRing L] [LieAlgebra ℚ L] + {F : NilpotentLieFiltration L s} {b : Basis ι ℚ L} {ω : ι → ℕ} + {hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {W : LieSubalgebra ℚ F.AssociatedGraded} + {Ktag : ∀ j, Submodule ℝ (J j → ℝ)} {c : ∀ j, J j → ℝ} + +local notation "wt" => fullTaggedVariableWeight (X := X) J +local notation "β" => fullTaggedAffineRetraction (X := X) J Ktag c + +theorem affine_product_values + {g : (F.realification.adaptedPolynomialFiltration wt).Group} + {E R : F.RealPolynomialSymbolGroup wt} + (A : GlobalMarkedNativeFactors F b ω hF wt W + (F.weightedAdaptedRealChartHom wt wt β + (fullTaggedAffineRetraction_support J Ktag c) g) E R) + (t : X ⊕ (Σ j, J j) → ℝ) + (ht : ∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) - c j ∈ Ktag j) : + F.adaptedPolynomialRealValueHom wt t A.left * + NilpotentLieBCHGroup.realificationMap + (hnil := (F.gradedRefiltration W).lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) (F.gradedRefiltrationSubalgebra W).incl + ((F.gradedRefiltration W).realification.polynomialOrbitRealEval wt t A.markedMiddle) * + F.adaptedPolynomialRealValueHom wt t A.right = + F.adaptedPolynomialRealValueHom wt t g := by + rw [A.product_values, F.adaptedPolynomialRealValueHom_weightedChart] + rw [fullTaggedAffineRetraction_eval_eq J Ktag c t ht] + +end GlobalMarkedNativeFactors +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ChartLatticePeriodization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ChartLatticePeriodization.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2c030d9b5674ac7bfbbc1ca14c43c5c4b16ddeb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ChartLatticePeriodization.lean @@ -0,0 +1,53 @@ +import Mathlib.GroupTheory.Coset.Basic +import OAI.Combinatorics.Progressions.Linear.NativeChartKernel + +namespace OAI + +section + +namespace Erdos3 + +theorem triangular_patchValue_eq_chartObservable {G : Type*} [Group G] {d : ℕ} + (Λ : Subgroup G) [MetricSpace (G ⧸ Λ)] (q : G ≃ (Fin d → ℝ)) + (gamma : (Fin d → ℤ) → G) (hgamma : ∀ b, gamma b ∈ Λ) + (hsurj : ∀ a ∈ Λ, ∃ b, gamma b = a) (z g : G) + (phi : OpenPartialHomeomorph (Fin d → ℝ) (G ⧸ Λ)) + (hphi : ∀ v, phi v = QuotientGroup.mk (z * q.symm v)) + (F : (G ⧸ Λ) → ℝ) (hF : Function.support F ⊆ phi.target) + (A : TriangularSlots d) (Phi : PatchKernel d) (B : ℝ) + (hPhi : ∀ v, Phi.value v = chartCoordinateKernel phi F (B • v)) + (hA : ∀ b, B • A.residual b = q (z⁻¹ * g * gamma b)) : + A.patchValue Phi = F (QuotientGroup.mk g) := by + have hchart (b : Fin d → ℤ) : phi (B • A.residual b) = QuotientGroup.mk g := by + rw [hphi, hA, q.symm_apply_apply] + simp only [← mul_assoc, mul_inv_cancel, one_mul] + exact QuotientGroup.mk_mul_of_mem g (hgamma b) + by_cases hzero : F (QuotientGroup.mk g) = 0 + · rw [hzero] + apply A.patchValue_eq_zero + intro b + rw [hPhi] + by_cases hb : B • A.residual b ∈ phi.source + · rw [chartCoordinateKernel_of_mem phi F hb, hchart b, hzero] + · exact chartCoordinateKernel_of_not_mem phi F hb + · have hx : QuotientGroup.mk g ∈ phi.target := hF hzero + let v := phi.symm (QuotientGroup.mk g) + have hv : v ∈ phi.source := phi.map_target hx + have heq : (QuotientGroup.mk (z * q.symm v) : G ⧸ Λ) = QuotientGroup.mk g := + (hphi v).symm.trans (phi.right_inv hx) + have hmem : g⁻¹ * (z * q.symm v) ∈ Λ := QuotientGroup.eq.mp heq.symm + obtain ⟨b, hb⟩ := hsurj _ hmem + have hcoord : B • A.residual b = v := by + rw [hA, hb] + have hcancel : z⁻¹ * g * (g⁻¹ * (z * q.symm v)) = q.symm v := by group + rw [hcancel, q.apply_symm_apply] + have hvalue : Phi.value (A.residual b) = F (QuotientGroup.mk g) := by + rw [hPhi, hcoord, chartCoordinateKernel_of_mem phi F hv, phi.right_inv hx] + have hnz : Phi.value (A.residual b) ≠ 0 := by rwa [hvalue] + exact (A.patchValue_eq_of_nonzero Phi hnz).trans hvalue + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CircleResiduePartition.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CircleResiduePartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..edbbc04a87cdeec7c52469cdb50221d6d1b8b92c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CircleResiduePartition.lean @@ -0,0 +1,78 @@ +import Mathlib.Analysis.Normed.Group.AddCircle +import Mathlib.Topology.Instances.AddCircle.Real +import OAI.Combinatorics.Progressions.Fourier.RectangularGridCharacter + +namespace OAI + +section + +namespace Erdos3.CircleFourier + +open scoped NNReal + +theorem one_le_mul_dist_toAddCircle {q : ℕ} [NeZero q] {j k : ZMod q} (hjk : j ≠ k) : + 1 ≤ (q : ℝ) * dist (ZMod.toAddCircle j) (ZMod.toAddCircle k) := by + let z := j - k + have hz : z ≠ 0 := sub_ne_zero.mpr hjk + have hzval : 0 < z.val := Nat.pos_of_ne_zero (fun h => hz ((ZMod.val_eq_zero z).mp h)) + have hzlt := z.val_lt + have hmin : 1 ≤ min z.val (q - z.val) := le_min hzval (by omega) + have hdist : dist (ZMod.toAddCircle j) (ZMod.toAddCircle k) = + ((min z.val (q - z.val) : ℕ) : ℝ) / q := by + rw [dist_eq_norm, ← map_sub, ZMod.toAddCircle_apply] + have hn := AddCircle.norm_div_natCast (p := (1 : ℝ)) (m := z.val) (n := q) + simpa only [mul_one, one_mul, Nat.mod_eq_of_lt z.val_lt] using hn + rw [hdist, mul_div_cancel₀ _ (show (q : ℝ) ≠ 0 from Nat.cast_ne_zero.mpr (NeZero.ne q))] + exact_mod_cast hmin + +noncomputable def residueCutoff {q : ℕ} [NeZero q] (j : ZMod q) (x : Circle) : ℝ := + max 0 (1 - (q : ℝ) * dist x (ZMod.toAddCircle j)) + +theorem residueCutoff_unit_interval {q : ℕ} [NeZero q] (j : ZMod q) (x : Circle) : + 0 ≤ residueCutoff j x ∧ residueCutoff j x ≤ 1 := by + refine ⟨le_max_left _ _, max_le (by norm_num) ?_⟩ + linarith [mul_nonneg (Nat.cast_nonneg q) (dist_nonneg (x := x) (y := ZMod.toAddCircle j))] + +theorem residueCutoff_lipschitz {q : ℕ} [NeZero q] (j : ZMod q) : + LipschitzWith (q : ℝ≥0) (residueCutoff j) := by + apply LipschitzWith.of_dist_le_mul + intro x y + change |max 0 (1 - (q : ℝ) * dist x (ZMod.toAddCircle j)) - + max 0 (1 - (q : ℝ) * dist y (ZMod.toAddCircle j))| ≤ (q : ℝ) * dist x y + calc + _ ≤ |(1 - (q : ℝ) * dist x (ZMod.toAddCircle j)) - + (1 - (q : ℝ) * dist y (ZMod.toAddCircle j))| := by + rw [max_comm 0 _, max_comm 0 _] + exact abs_max_sub_max_le_abs _ _ _ + _ = (q : ℝ) * |dist x (ZMod.toAddCircle j) - dist y (ZMod.toAddCircle j)| := by + rw [show (1 - (q : ℝ) * dist x (ZMod.toAddCircle j)) - + (1 - (q : ℝ) * dist y (ZMod.toAddCircle j)) = + -(q : ℝ) * (dist x (ZMod.toAddCircle j) - dist y (ZMod.toAddCircle j)) by ring, + abs_mul, abs_neg, abs_of_nonneg (Nat.cast_nonneg q)] + _ ≤ _ := mul_le_mul_of_nonneg_left (abs_dist_sub_le x y (ZMod.toAddCircle j)) (Nat.cast_nonneg q) + +theorem residueCutoff_at_grid {q : ℕ} [NeZero q] (j k : ZMod q) : + residueCutoff j (ZMod.toAddCircle k) = if k = j then 1 else 0 := by + classical + by_cases h : k = j + · subst k + simp [residueCutoff] + · simp only [h, ↓reduceIte] + exact max_eq_left (by linarith [one_le_mul_dist_toAddCircle h]) + +theorem sum_residueCutoff_at_grid {q : ℕ} [NeZero q] (k : ZMod q) : + ∑ j : ZMod q, residueCutoff j (ZMod.toAddCircle k) = 1 := by + classical + simp [residueCutoff_at_grid] + +theorem residueCutoff_positive_iff {q : ℕ} [NeZero q] (j k : ZMod q) : + 0 < residueCutoff j (ZMod.toAddCircle k) ↔ k = j := by + classical + rw [residueCutoff_at_grid] + split_ifs <;> simp_all + +end Erdos3.CircleFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientDeckResidueMask.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientDeckResidueMask.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6ff6043c9b942eb4154ee0726258d85d416e7eb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientDeckResidueMask.lean @@ -0,0 +1,136 @@ +import OAI.Combinatorics.Progressions.Geometry.CoefficientDeckChartRecovery + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule +open scoped Matrix + +variable {D I : Type*} [Fintype D] [DecidableEq D] [Fintype I] {n : ℕ} +variable (W : Submodule ℝ (EuclideanSpace ℝ D)) +variable (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) +variable (b : Basis (Fin n) ℝ Wᗮ) +variable (hb : span ℤ (Set.range b) = projectedIntegerLattice W) +variable (q : ℕ) [NeZero q] + +noncomputable def normalizedDeckResidueRead (a : D → ZMod q) : Fin n ⊕ I → ZMod q := + integerResidueMatrix (Classical.choose (standardLatticeCoordinates_residue W bW b hb q)) q + *ᵥ (-a) + +theorem normalizedDeckResidueRead_neg_integer (β : D → ℤ) : + normalizedDeckResidueRead W bW b hb q (fun i => -(β i : ZMod q)) = + integerResidueMap (Fin n ⊕ I) q (standardLatticeCoordinates W bW b hb β) := by + have hres := (Classical.choose_spec (standardLatticeCoordinates_residue W bW b hb q)).2 β + unfold normalizedDeckResidueRead + rw [show -(fun i => -(β i : ZMod q)) = integerResidueMap D q β by + funext i + exact neg_neg _] + exact hres.symm + +theorem normalizedDeckResidueRead_latticeDeckInteger (z : Fin n → ℤ) (w : I → ℤ) : + normalizedDeckResidueRead W bW b hb q + (fun i => -(latticeDeckInteger W bW b hb z w i : ZMod q)) = + Sum.elim (fun i => (z i : ZMod q)) (fun i => (w i : ZMod q)) := by + rw [normalizedDeckResidueRead_neg_integer, latticeDeckInteger_coordinates] + funext i + cases i <;> rfl + +theorem normalizedDeckResidueRead_neg_latticeDeckInteger (z : Fin n → ℤ) (w : I → ℤ) : + normalizedDeckResidueRead W bW b hb q + (integerResidueMap D q (-latticeDeckInteger W bW b hb z w)) = + Sum.elim (fun i => (z i : ZMod q)) (fun i => (w i : ZMod q)) := by + convert normalizedDeckResidueRead_latticeDeckInteger W bW b hb q z w using 1 + congr 1 + funext i + change ((-(latticeDeckInteger W bW b hb z w i) : ℤ) : ZMod q) = _ + exact Int.cast_neg _ + +noncomputable def normalizedDeckResidueMask {V : Type*} + (mask : (Fin n ⊕ I → ZMod q) → V) : (D → ZMod q) → V := + fun a => mask (normalizedDeckResidueRead W bW b hb q a) + +theorem normalizedDeckResidueMask_latticeDeckInteger {V : Type*} + (mask : (Fin n ⊕ I → ZMod q) → V) (z : Fin n → ℤ) (w : I → ℤ) : + normalizedDeckResidueMask W bW b hb q mask + (fun i => -(latticeDeckInteger W bW b hb z w i : ZMod q)) = + mask (Sum.elim (fun i => (z i : ZMod q)) (fun i => (w i : ZMod q))) := by + unfold normalizedDeckResidueMask + rw [normalizedDeckResidueRead_latticeDeckInteger] + +theorem normalizedDeckResidueRead_curried_mask {V : Type*} + (mask : (Fin n → ZMod q) → (I → ZMod q) → V) + (z : Fin n → ℤ) (w : I → ℤ) : + mask + (fun i => normalizedDeckResidueRead W bW b hb q + (fun j => -(latticeDeckInteger W bW b hb z w j : ZMod q)) (Sum.inl i)) + (fun i => normalizedDeckResidueRead W bW b hb q + (fun j => -(latticeDeckInteger W bW b hb z w j : ZMod q)) (Sum.inr i)) = + mask (fun i => (z i : ZMod q)) (fun i => (w i : ZMod q)) := by + simp only [normalizedDeckResidueRead_latticeDeckInteger, Sum.elim_inl, Sum.elim_inr] + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule + +variable {K : Type*} [Fintype K] {m : ℕ} {J I E : Fin m → Type*} +variable [∀ j, Fintype (J j)] [∀ j, DecidableEq (J j)] +variable [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] {n : Fin m → ℕ} +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + +abbrev CoefficientChartResidues (K : Type*) {m : ℕ} (n : Fin m → ℕ) (E : Fin m → Type*) (q : ℕ) := + ∀ j, BoundedCoefficientExponent K (j.val + 1) → (Fin (n j) ⊕ E j) → ZMod q + +noncomputable def coefficientDeckResidueRead (q : ℕ) [NeZero q] + (a : CoefficientAmbientIndex K J → ZMod q) : CoefficientChartResidues K n E q := + fun j e => normalizedDeckResidueRead (euclideanSubspace (U j)) (bW j) (b j) (hb j) q + (fun i => a ⟨⟨j, e⟩, i⟩) + +def coefficientSamplerChartResidues (q : ℕ) + (x : CoefficientSamplerArrays (K := K) I n) (r : CoefficientDeckResidues (K := K) E q) : + CoefficientChartResidues K n E q := + fun j e => Sum.elim (fun i => ((x j).2 i e : ZMod q)) (r j e) + +omit [Fintype K] [∀ j, Fintype (I j)] in +theorem coefficientDeckResidueRead_integer_chart (q : ℕ) [NeZero q] + (x : CoefficientSamplerArrays (K := K) I n) + (w : ∀ j, BoundedCoefficientExponent K (j.val + 1) → E j → ℤ) : + coefficientDeckResidueRead U bW b hb q + (fun a => (-coefficientSamplerDeckInteger U bW b hb x w a : ZMod q)) = + coefficientSamplerChartResidues q x (fun j e => integerResidueMap (E j) q (w j e)) := by + funext j e + exact normalizedDeckResidueRead_latticeDeckInteger (euclideanSubspace (U j)) + (bW j) (b j) (hb j) q (fun i => (x j).2 i e) (w j e) + +noncomputable def coefficientDeckResidueMask (q : ℕ) [NeZero q] + (test : CoefficientChartResidues K n E q → ℝ) : + (CoefficientAmbientIndex K J → ZMod q) → ℝ := + fun a => test (coefficientDeckResidueRead U bW b hb q a) + +omit [Fintype K] [∀ j, Fintype (I j)] in +theorem coefficientDeckResidueMask_integer_chart (q : ℕ) [NeZero q] + (test : CoefficientChartResidues K n E q → ℝ) + (x : CoefficientSamplerArrays (K := K) I n) + (w : ∀ j, BoundedCoefficientExponent K (j.val + 1) → E j → ℤ) : + coefficientDeckResidueMask U bW b hb q test + (fun a => (-coefficientSamplerDeckInteger U bW b hb x w a : ZMod q)) = + test (coefficientSamplerChartResidues q x (fun j e => integerResidueMap (E j) q (w j e))) := by + unfold coefficientDeckResidueMask + rw [coefficientDeckResidueRead_integer_chart] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientIntegerFloorRemainder.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientIntegerFloorRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..c245c1aecf3aa8a6f28c536165690b3a695b2b61 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientIntegerFloorRemainder.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.Progressions.Polynomial.CoefficientPolynomialLift + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule +open scoped BigOperators + +variable {K : Type*} [Fintype K] {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + +noncomputable def coefficientIntegerFloorPolynomial + (a : CoefficientSamplerArrays (K := K) I n) (c : CoefficientArray (K := K) U) + (j : Fin m) (i : J j) : MvPolynomial K ℤ := + integerMonomialArrayPolynomial Subtype.val + (fun d : BoundedCoefficientExponent K (j.val + 1) => + ⌊(c ⟨j, d⟩).val i - mixedLiftCoefficient (euclideanSubspace (U j)) (b j) (o j) (a j) d i⌋) + +theorem coefficientIntegerFloorPolynomial_degree + (a : CoefficientSamplerArrays (K := K) I n) (c : CoefficientArray (K := K) U) + (j : Fin m) (i : J j) : + (coefficientIntegerFloorPolynomial U b o a c j i).totalDegree ≤ j.val + 1 := + integerMonomialArrayPolynomial_degree Subtype.val _ (fun d => d.property) + +theorem canonicalCoefficientSample_floor_coefficient_remainder + (a : CoefficientSamplerArrays (K := K) I n) (c : CoefficientArray (K := K) U) + (hc : canonicalCoefficientSample U b hb o a = QuotientAddGroup.mk' (coefficientIntegerLattice U) c) + (j : Fin m) (d : BoundedCoefficientExponent K (j.val + 1)) (i : J j) : + (c ⟨j, d⟩).val i - mixedLiftCoefficient (euclideanSubspace (U j)) (b j) (o j) (a j) d i = + (⌊(c ⟨j, d⟩).val i - mixedLiftCoefficient (euclideanSubspace (U j)) (b j) (o j) (a j) d i⌋ : ℤ) := by + obtain ⟨z, hz⟩ := canonicalCoefficientSample_integer_remainder U b hb o a c hc j d i + rw [mixedLiftCoefficient_eq, hz, Int.floor_intCast] + +theorem canonicalCoefficientSample_floor_polynomial_remainder + (a : CoefficientSamplerArrays (K := K) I n) (c : CoefficientArray (K := K) U) + (hc : canonicalCoefficientSample U b hb o a = QuotientAddGroup.mk' (coefficientIntegerLattice U) c) + (j : Fin m) (i : J j) : + coefficientRowPolynomial U c j i = + mixedLiftPolynomial (euclideanSubspace (U j)) (b j) (o j) Subtype.val (a j) i + + MvPolynomial.map (Int.castRingHom ℝ) (coefficientIntegerFloorPolynomial U b o a c j i) ∧ + (coefficientIntegerFloorPolynomial U b o a c j i).totalDegree ≤ j.val + 1 := by + refine ⟨?_, coefficientIntegerFloorPolynomial_degree U b o a c j i⟩ + rw [coefficientIntegerFloorPolynomial, integerMonomialArrayPolynomial_map] + change (∑ d : BoundedCoefficientExponent K (j.val + 1), MvPolynomial.monomial d.val ((c ⟨j,d⟩).val i)) = _ + unfold mixedLiftPolynomial monomialArrayPolynomial + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro d _ + rw [← map_add] + apply congrArg (MvPolynomial.monomial d.val) + have hd := canonicalCoefficientSample_floor_coefficient_remainder U b hb o a c hc j d i + linarith + +theorem canonicalCoefficientSample_floor_integer_evaluation + (a : CoefficientSamplerArrays (K := K) I n) (c : CoefficientArray (K := K) U) + (hc : canonicalCoefficientSample U b hb o a = QuotientAddGroup.mk' (coefficientIntegerLattice U) c) + (j : Fin m) (i : J j) (x : K → ℤ) : + MvPolynomial.eval (fun v => (x v : ℝ)) (coefficientRowPolynomial U c j i) = + mixedPolynomialPoint (euclideanSubspace (U j)) (b j) (o j) Subtype.val + (a j).1 (a j).2 (fun v => (x v : ℝ)) i + + (MvPolynomial.eval x (coefficientIntegerFloorPolynomial U b o a c j i) : ℝ) := by + have h := integerPolynomial_remainder_eval _ _ _ + (canonicalCoefficientSample_floor_polynomial_remainder U b hb o a c hc j i).1 x + rwa [mixedLiftPolynomial_eval] at h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientLatticeCompact.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientLatticeCompact.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb4d7aa650c06b74951bb98fb06375cd608cf1a7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientLatticeCompact.lean @@ -0,0 +1,36 @@ +import OAI.Combinatorics.Progressions.Fourier.EuclideanJetTorus + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module + +theorem coefficientTorus_compact_of_lattice {K : Type*} [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [∀ j, IsZLattice ℝ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] : + CompactSpace (CoefficientTorus (K := K) U) := by + classical + let Λ := fun j => latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)) + let : ∀ j, Module.Finite ℤ (Λ j) := fun j => ZLattice.module_finite ℝ (Λ j) + let b := fun j => Module.Free.chooseBasis ℤ (Λ j) + let e := fun j => (euclideanSubspaceArrayEquiv (U j)).toLinearEquiv.trans + (LinearEquiv.piUnique ℝ (fun _ : Unit => U j)) + apply coefficientTorus_compact_of_basis U + (fun j => ((b j).ofZLatticeBasis ℝ (Λ j)).map (e j)) + intro j i a + have hi := (euclideanSubspaceArrayEquiv_mem_lattice (U j) + ((b j i : Λ j) : euclideanSubspace (U j))).mpr (b j i).property + simpa only [Basis.map_apply, Basis.ofZLatticeBasis_apply, e, + LinearEquiv.trans_apply, LinearEquiv.piUnique_apply, Equiv.piUnique, + ContinuousLinearEquiv.coe_coe, ContinuousLinearEquiv.coe_toLinearEquiv] using hi default a + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientResidueMixture.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientResidueMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..2279f09dd27cd2a061684c17d7774d92eec875cd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CoefficientResidueMixture.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.Progressions.Probability.RawWeightCellMixture +import OAI.Combinatorics.Progressions.Probability.RefinedSliceLaws + +namespace OAI + +section + +namespace Erdos3.FiniteCoefficientSlice + +open scoped BigOperators Classical + +theorem refineResidues_mixture (s : FiniteCoefficientSlice) + (n : ℕ) (hdvd : s.modulus ∣ n) (w : ℤ → ℝ) (hw : ∀ z, 0 ≤ w z) + (htotal : 0 < ∑ x : s.Domain, w (s.value x)) + (S : Finset (s.ResidueLabel n)) + (hchild : ∀ r : S, 0 < ∑ x : (s.refineResidues n r.val).Domain, + w ((s.refineResidues n r.val).value x)) (f : ℤ → ℂ) : + let p := FiniteProbabilityWeights.ofPositiveWeights + (fun x : s.Domain => w (s.value x)) (fun x => hw (s.value x)) htotal + (∑ r : S, (p.mass (Finset.univ.filter (fun x => s.residueLabelMap n x = r.val)) : ℂ) * + (FiniteProbabilityWeights.ofPositiveWeights + (fun x : (s.refineResidues n r.val).Domain => w ((s.refineResidues n r.val).value x)) + (fun x => hw ((s.refineResidues n r.val).value x)) (hchild r)).complexMean + (fun x => f ((s.refineResidues n r.val).value x))) = + p.complexMean (fun x => if s.residueLabelMap n x ∈ S then f (s.value x) else 0) := by + exact FiniteProbabilityWeights.embedded_cell_mixture + (fun x : s.Domain => w (s.value x)) (fun x => hw (s.value x)) htotal + (s.residueLabelMap n) S (fun r => (s.refineResidues n r.val).Domain) + (fun r => s.refineResiduesEmbedding n hdvd r.val) + (fun r => s.refineResiduesEmbedding_range n hdvd r.val) hchild (fun x => f (s.value x)) + +noncomputable def retainedRefinementLaw (s : FiniteCoefficientSlice) [Nonempty s.Domain] + (n : ℕ) (hdvd : s.modulus ∣ n) (w : ℤ → ℝ) (hw : ∀ z, 0 ≤ w z) {η : ℝ} (hη : 0 < η) + (r : s.ResidueLabel n) (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers + (s.residueLabelMap n) (fun x => w (s.value x)) η) : + FiniteProbabilityWeights (s.refineResidues n r).Domain := + FiniteProbabilityWeights.ofPositiveWeights + (fun x => w ((s.refineResidues n r).value x)) + (fun x => hw ((s.refineResidues n r).value x)) + (s.retained_refineResidues_total_pos n hdvd r w hη hr) + +theorem retainedRefinementLaw_mixture_error (s : FiniteCoefficientSlice) [Nonempty s.Domain] + (n : ℕ) (hdvd : s.modulus ∣ n) (w : ℤ → ℝ) (hw : ∀ z, 0 ≤ w z) + (htotal : 0 < ∑ x : s.Domain, w (s.value x)) + (hm : 0 < (FiniteProbabilityWeights.uniform s.Domain).mean (fun x => w (s.value x))) + {η : ℝ} (hη : 0 < η) (f : ℤ → ℂ) (hf : ∀ z, ‖f z‖ ≤ 1) : + let S := Finset.univ \ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers + (s.residueLabelMap n) (fun x => w (s.value x)) η + let p := FiniteProbabilityWeights.ofPositiveWeights + (fun x : s.Domain => w (s.value x)) (fun x => hw (s.value x)) htotal + ‖p.complexMean (fun x => f (s.value x)) - + ∑ r : S, (p.mass (Finset.univ.filter (fun x => s.residueLabelMap n x = r.val)) : ℂ) * + (s.retainedRefinementLaw n hdvd w hw hη r.val (Finset.mem_sdiff.mp r.property).2).complexMean + (fun x => f ((s.refineResidues n r.val).value x))‖ ≤ + η / (FiniteProbabilityWeights.uniform s.Domain).mean (fun x => w (s.value x)) := by + dsimp only + exact FiniteProbabilityWeights.embedded_lowWeight_cell_mixture_error + (fun x : s.Domain => w (s.value x)) (fun x => hw (s.value x)) htotal hm + (s.residueLabelMap n) hη.le _ rfl (fun r => (s.refineResidues n r.val).Domain) + (fun r => s.refineResiduesEmbedding n hdvd r.val) + (fun r => s.refineResiduesEmbedding_range n hdvd r.val) + (fun r => s.retained_refineResidues_total_pos n hdvd r.val w hη (Finset.mem_sdiff.mp r.property).2) + (fun x => f (s.value x)) (fun x => hf (s.value x)) + +end Erdos3.FiniteCoefficientSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CommonAffineOrbitEvaluation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CommonAffineOrbitEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e2ceb8564d5f8e0c323e4f7d8b6d8d09ab33a1c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CommonAffineOrbitEvaluation.lean @@ -0,0 +1,569 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonMarkedMultidegree + +namespace OAI + +section + +namespace Erdos3 + +open VectorPolynomial +open scoped BigOperators TensorProduct + +namespace VectorPolynomial + +variable {σ L : Type*} [AddCommGroup L] [Module ℚ L] + +noncomputable def monomialLinearMap (α : σ →₀ ℕ) : L →ₗ[ℚ] VectorPolynomial σ ℚ L where + toFun := monomial α + map_add' x y := by simp only [monomial, TensorProduct.tmul_add] + map_smul' a x := by + change monomial α (a • x) = a • monomial α x + simp only [monomial, TensorProduct.tmul_smul] + +theorem realMonomial_eval (α : σ →₀ ℕ) (x : ℝ ⊗[ℚ] L) (a : σ → ℚ) : + (eval a).baseChange ℝ ((monomialLinearMap α).baseChange ℝ x) = + (α.prod (fun i n => a i ^ n)) • x := by + induction x using TensorProduct.inductionOn with + | tmul r x => + change r ⊗ₜ[ℚ] eval a (monomial α x) = (α.prod (fun i n => a i ^ n)) • (r ⊗ₜ[ℚ] x) + rw [eval_monomial, TensorProduct.tmul_smul] + | add x y hx hy => simp only [map_add, hx, hy, smul_add] + +noncomputable def realAffinePolynomial [Fintype σ] (x : ℝ ⊗[ℚ] L) (y : σ → ℝ ⊗[ℚ] L) : + ℝ ⊗[ℚ] VectorPolynomial σ ℚ L := + (monomialLinearMap (0 : σ →₀ ℕ)).baseChange ℝ x + + ∑ i, (monomialLinearMap (Finsupp.single i 1)).baseChange ℝ (y i) + +theorem realAffinePolynomial_eval [Fintype σ] (x : ℝ ⊗[ℚ] L) (y : σ → ℝ ⊗[ℚ] L) (a : σ → ℚ) : + (eval a).baseChange ℝ (realAffinePolynomial x y) = x + ∑ i, a i • y i := by + classical + simp only [realAffinePolynomial, map_add, map_sum, realMonomial_eval, + Finsupp.prod_zero_index, one_smul, Finsupp.prod_single_index, pow_one, pow_zero] + +end VectorPolynomial + +variable {I σ L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem realMonomial_mem_markedPolynomialLayer + (v : I → L) (w : I → ℕ) (marked : I → Bool) (d k l : ℕ) (α : σ →₀ ℕ) + {x : ℝ ⊗[ℚ] L} + (hx : x ∈ (markedLieSpan v w marked d (k + Finsupp.weight (fun _ : σ => 1) α) l).baseChange ℝ) : + (monomialLinearMap α).baseChange ℝ x ∈ + (markedPolynomialLayer v w marked d k l).baseChange ℝ := by + have hmap : (markedLieSpan v w marked d (k + Finsupp.weight (fun _ : σ => 1) α) l).map + (monomialLinearMap α) ≤ markedPolynomialLayer v w marked d k l := by + rintro z ⟨y, hy, rfl⟩ + exact monomial_mem_markedPolynomialLayer v w marked d k l α hy + have h := Submodule.baseChange_mono ℝ hmap + rw [realification_map] at h + exact h ⟨x, hx, rfl⟩ + +theorem realAffinePolynomial_mem_marked [Fintype σ] + (v : I → L) (w : I → ℕ) (marked : I → Bool) {d k l : ℕ} + {x : ℝ ⊗[ℚ] L} {y : σ → ℝ ⊗[ℚ] L} + (hx : x ∈ (markedLieSpan v w marked d k l).baseChange ℝ) + (hy : ∀ i, y i ∈ (markedLieSpan v w marked d (k + 1) l).baseChange ℝ) : + realAffinePolynomial x y ∈ (markedPolynomialLayer v w marked d k l).baseChange ℝ := by + apply Submodule.add_mem + · apply realMonomial_mem_markedPolynomialLayer v w marked d k l 0 + simpa only [map_zero, Nat.add_zero] using hx + · apply Submodule.sum_mem + intro i _ + apply realMonomial_mem_markedPolynomialLayer v w marked d k l (Finsupp.single i 1) + simpa only [Finsupp.weight_single, one_smul] using hy i + +end Erdos3 + +end + +section + +namespace Erdos3 + +open VectorPolynomial +open scoped BigOperators + +noncomputable def correlationExponent (h n : ℕ) : Fin 2 →₀ ℕ := + Finsupp.single 0 h + Finsupp.single 1 n + +@[simp] theorem correlationExponent_apply (h n : ℕ) (i : Fin 2) : + correlationExponent h n i = correlationInput h n i := by + fin_cases i + · change correlationExponent h n 0 = h + simp [correlationExponent] + · change correlationExponent h n 1 = n + simp [correlationExponent] + +theorem eval_correlation_monomial {L : Type*} [AddCommGroup L] [Module ℚ L] + (h n : ℕ) (v : L) (x : Fin 2 → ℚ) : + eval x (monomial (correlationExponent h n) v) = (x 0 ^ h * x 1 ^ n) • v := by + classical + rw [eval_monomial] + simp [correlationExponent, Finsupp.prod_add_index, pow_add] + +noncomputable def affineMixedLog {L : Type*} [AddCommGroup L] [Module ℚ L] + {m : ℕ} (c d : Fin m → L) : VectorPolynomial (Fin 2) ℚ L := + ∑ j, (monomial (correlationExponent 0 (j.val + 1)) (c j) + + monomial (correlationExponent 1 (j.val + 1)) (d j)) + +theorem affineMixedLog_eval {L : Type*} [AddCommGroup L] [Module ℚ L] + {m : ℕ} (c d : Fin m → L) (x : Fin 2 → ℚ) : + eval x (affineMixedLog c d) = + ∑ j, x 1 ^ (j.val + 1) • (c j + x 0 • d j) := by + simp only [affineMixedLog, map_sum, map_add, eval_correlation_monomial, + pow_zero, one_mul, pow_one, smul_add, smul_smul] + apply Finset.sum_congr rfl + intro j _ + rw [mul_comm (x 0)] + +namespace MultidegreeLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s m : ℕ} {bound : Fin 2 → ℕ} + (F : MultidegreeLieFiltration (Fin 2) L s bound) + (c d : Fin m → L) + (hc : ∀ j, c j ∈ F.layer (correlationInput 0 (j.val + 1))) + (hd : ∀ j, d j ∈ F.layer (correlationInput 1 (j.val + 1))) + +include hc hd in +theorem affineMixedLog_adapted : F.Adapted (affineMixedLog c d) := by + apply F.adaptedSubmodule.sum_mem + intro j _ + apply F.adaptedSubmodule.add_mem + · apply F.monomial_mem_adaptedSubmodule + simpa only [correlationExponent_apply] using hc j + · apply F.monomial_mem_adaptedSubmodule + simpa only [correlationExponent_apply] using hd j + +noncomputable def affineMixedOrbit : F.PolynomialOrbit := + F.polynomialOrbitOfLog (affineMixedLog c d) (F.affineMixedLog_adapted c d hc hd) + +theorem affineMixedOrbit_eval (x : Fin 2 → ℤ) : + (F.polynomialOrbitEval x (F.affineMixedOrbit c d hc hd)).coord = + ∑ j, (x 1 : ℚ) ^ (j.val + 1) • (c j + (x 0 : ℚ) • d j) := + affineMixedLog_eval c d _ + +theorem affineMixedOrbit_at_zero (h : ℤ) : + F.polynomialOrbitEval (correlationInput h 0) (F.affineMixedOrbit c d hc hd) = 1 := by + apply NilpotentLieBCHGroup.ext + rw [F.affineMixedOrbit_eval] + have hz : correlationInput h (0 : ℤ) 1 = 0 := rfl + rw [hz] + simp + +theorem affineMixedOrbit_normalized : + F.polynomialOrbitEval 0 (F.affineMixedOrbit c d hc hd) = 1 := by + have hz : correlationInput (0 : ℤ) 0 = 0 := by + ext i + fin_cases i <;> rfl + rw [← hz] + exact F.affineMixedOrbit_at_zero c d hc hd 0 + +end MultidegreeLieFiltration + +end Erdos3 + +end + +section + +namespace Erdos3 + +open VectorPolynomial +open scoped BigOperators + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (hw : ∀ i, 0 < w i) (hv : ∀ i, v i ∈ F.layer (w i) 1) + +theorem markedShiftLayerPolynomialMap_mem (t d k l : ℕ) + (p : markedPolynomialLayer (σ := Fin t) v w marked d k l) : + markedShiftLayerPolynomialMap F v w marked hw hv t d k l p ∈ + markedShiftBiLayer F v w marked t k d := by + refine ⟨?_, fun _ => rfl⟩ + exact markedPolynomialLayer_antitone v w marked le_rfl le_rfl (Nat.zero_le l) p.property + +theorem markedShiftLayerPolynomialMap_quotient_mem (t d k l : ℕ) + (p : markedPolynomialLayer (σ := Fin t) v w marked d k l) : + lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedShiftLayerPolynomialMap F v w marked hw hv t d k l p) ∈ + (markedShiftMultidegree F v w marked hw hv t).layer (correlationInput k d) := by + refine ⟨_, ?_, rfl⟩ + exact markedShiftLayerPolynomialMap_mem F v w marked hw hv t d k l p + +noncomputable def markedAffineShiftCoefficient (t d k l : ℕ) (x : L) (y : Fin t → L) + (hx : x ∈ markedLieSpan v w marked d k l) + (hy : ∀ i, y i ∈ markedLieSpan v w marked d (k + 1) l) : + markedShiftSubalgebra F v w marked t := + markedShiftLayerPolynomialMap F v w marked hw hv t d k l + ⟨markedAffinePolynomial x y, markedAffinePolynomial_mem v w marked hx hy⟩ + +noncomputable def markedDirectionalShiftCoefficient (t d k l : ℕ) (u : Fin t → ℚ) (y : Fin t → L) + (hy : ∀ i, y i ∈ markedLieSpan v w marked d k l) : + markedShiftSubalgebra F v w marked t := + markedShiftLayerPolynomialMap F v w marked hw hv t d k l + ⟨monomial 0 (∑ i, u i • y i), markedPolynomialLayer_constant v w marked + ((markedLieSpan v w marked d k l).sum_mem + (fun i _ => (markedLieSpan v w marked d k l).smul_mem (u i) (hy i)))⟩ + +theorem markedAffineShiftCoefficient_quotient_mem (t d k l : ℕ) (x : L) (y : Fin t → L) + (hx : x ∈ markedLieSpan v w marked d k l) + (hy : ∀ i, y i ∈ markedLieSpan v w marked d (k + 1) l) : + lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedAffineShiftCoefficient F v w marked hw hv t d k l x y hx hy) ∈ + (markedShiftMultidegree F v w marked hw hv t).layer (correlationInput k d) := + markedShiftLayerPolynomialMap_quotient_mem F v w marked hw hv t d k l _ + +theorem markedDirectionalShiftCoefficient_quotient_mem (t d k l : ℕ) + (u : Fin t → ℚ) (y : Fin t → L) + (hy : ∀ i, y i ∈ markedLieSpan v w marked d k l) : + lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedDirectionalShiftCoefficient F v w marked hw hv t d k l u y hy) ∈ + (markedShiftMultidegree F v w marked hw hv t).layer (correlationInput k d) := + markedShiftLayerPolynomialMap_quotient_mem F v w marked hw hv t d k l _ + +theorem markedAffineShiftCoefficient_eval (t d k l : ℕ) (x : L) (y : Fin t → L) + (hx : x ∈ markedLieSpan v w marked d k l) + (hy : ∀ i, y i ∈ markedLieSpan v w marked d (k + 1) l) (a : Fin t → ℚ) : + markedShiftEval F v w marked t a (markedAffineShiftCoefficient F v w marked hw hv t d k l x y hx hy) = + x + ∑ i, a i • y i := markedAffinePolynomial_eval x y a + +theorem markedDirectionalShiftCoefficient_eval (t d k l : ℕ) (u : Fin t → ℚ) (y : Fin t → L) + (hy : ∀ i, y i ∈ markedLieSpan v w marked d k l) (a : Fin t → ℚ) : + markedShiftEval F v w marked t a + (markedDirectionalShiftCoefficient F v w marked hw hv t d k l u y hy) = ∑ i, u i • y i := by + change eval a (monomial 0 (∑ i, u i • y i)) = _ + rw [eval_monomial, Finsupp.prod_zero_index, one_smul] + +theorem markedAffineShiftCoefficient_shift_eval (t d k l : ℕ) + (x : L) (y : Fin t → L) (hx : x ∈ markedLieSpan v w marked d k l) + (hy : ∀ i, y i ∈ markedLieSpan v w marked d (k + 1) l) + (a u : Fin t → ℚ) (h : ℚ) : + markedShiftEval F v w marked t a + (markedAffineShiftCoefficient F v w marked hw hv t d k l x y hx hy + + h • markedDirectionalShiftCoefficient F v w marked hw hv t d (k + 1) l u y hy) = + x + ∑ i, (a i + h * u i) • y i := by + rw [map_add, map_smul, markedAffineShiftCoefficient_eval, markedDirectionalShiftCoefficient_eval] + simp only [add_smul, Finset.sum_add_distrib, Finset.smul_sum, smul_smul, add_assoc] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (hw : ∀ i, 0 < w i) (hv : ∀ i, v i ∈ F.layer (w i) 1) + (t l : ℕ) (x : Fin s → L) (y : Fin s → Fin t → L) + (hx : ∀ j, x j ∈ markedLieSpan v w marked (j.val + 1) 0 l) + (hy : ∀ j i, y j i ∈ markedLieSpan v w marked (j.val + 1) 1 l) + (u : Fin t → ℚ) + +noncomputable def markedAffineBaseCoefficient (j : Fin s) : markedShiftSubalgebra F v w marked t := + markedAffineShiftCoefficient F v w marked hw hv t (j.val + 1) 0 l (x j) (y j) (hx j) (hy j) + +noncomputable def markedAffineSlopeCoefficient (j : Fin s) : markedShiftSubalgebra F v w marked t := + markedDirectionalShiftCoefficient F v w marked hw hv t (j.val + 1) 1 l u (y j) (hy j) + +noncomputable def markedAffineMixedLift (h n : ℚ) : markedShiftSubalgebra F v w marked t := + ∑ j, n ^ (j.val + 1) • (markedAffineBaseCoefficient F v w marked hw hv t l x y hx hy j + + h • markedAffineSlopeCoefficient F v w marked hw hv t l y hy u j) + +theorem markedAffineMixedLift_eval (a : Fin t → ℚ) (h n : ℚ) : + markedShiftEval F v w marked t a (markedAffineMixedLift F v w marked hw hv t l x y hx hy u h n) = + ∑ j, n ^ (j.val + 1) • (x j + ∑ i, (a i + h * u i) • y j i) := by + simp only [markedAffineMixedLift, map_sum, map_smul] + apply Finset.sum_congr rfl + intro j _ + congr 1 + exact markedAffineShiftCoefficient_shift_eval F v w marked hw hv + t (j.val + 1) 0 l (x j) (y j) (hx j) (hy j) a u h + +noncomputable def markedAffineMixedOrbit : + (markedShiftMultidegree F v w marked hw hv t).PolynomialOrbit := + (markedShiftMultidegree F v w marked hw hv t).affineMixedOrbit + (fun j => lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedAffineBaseCoefficient F v w marked hw hv t l x y hx hy j)) + (fun j => lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedAffineSlopeCoefficient F v w marked hw hv t l y hy u j)) + (fun j => markedAffineShiftCoefficient_quotient_mem F v w marked hw hv + t (j.val + 1) 0 l (x j) (y j) (hx j) (hy j)) + (fun j => markedDirectionalShiftCoefficient_quotient_mem F v w marked hw hv + t (j.val + 1) 1 l u (y j) (hy j)) + +theorem markedAffineMixedOrbit_eval (h n : ℤ) : + ((markedShiftMultidegree F v w marked hw hv t).polynomialOrbitEval (correlationInput h n) + (markedAffineMixedOrbit F v w marked hw hv t l x y hx hy u)).coord = + lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedAffineMixedLift F v w marked hw hv t l x y hx hy u (h : ℚ) (n : ℚ)) := by + calc + _ = ∑ j, (n : ℚ) ^ (j.val + 1) • + (lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedAffineBaseCoefficient F v w marked hw hv t l x y hx hy j) + + (h : ℚ) • lieQuotientMap (markedShiftSecondIdeal F v w marked t) + (markedAffineSlopeCoefficient F v w marked hw hv t l y hy u j)) := + MultidegreeLieFiltration.affineMixedOrbit_eval _ _ _ _ _ (correlationInput h n) + _ = _ := by simp only [markedAffineMixedLift, map_sum, map_smul, map_add] + +theorem markedAffineMixedOrbit_at_zero (h : ℤ) : + (markedShiftMultidegree F v w marked hw hv t).polynomialOrbitEval (correlationInput h 0) + (markedAffineMixedOrbit F v w marked hw hv t l x y hx hy u) = 1 := + MultidegreeLieFiltration.affineMixedOrbit_at_zero _ _ _ _ _ h + +theorem markedAffineMixedOrbit_normalized : + (markedShiftMultidegree F v w marked hw hv t).polynomialOrbitEval 0 + (markedAffineMixedOrbit F v w marked hw hv t l x y hx hy u) = 1 := + MultidegreeLieFiltration.affineMixedOrbit_normalized _ _ _ _ _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open VectorPolynomial +open scoped BigOperators TensorProduct + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (hw : ∀ i, 0 < w i) (hv : ∀ i, v i ∈ F.layer (w i) 1) + +noncomputable def realMarkedPolynomialLift (t d k l : ℕ) : + (markedPolynomialLayer (σ := Fin t) v w marked d k l).baseChange ℝ →ₗ[ℝ] + ℝ ⊗[ℚ] (markedShiftSubalgebra F v w marked t) := + ((markedShiftLayerPolynomialMap F v w marked hw hv t d k l).baseChange ℝ).comp + (realificationSubmoduleEquiv (markedPolynomialLayer (σ := Fin t) v w marked d k l)).symm.toLinearMap + +theorem realMarkedPolynomialLift_mem (t d k l : ℕ) + (p : (markedPolynomialLayer (σ := Fin t) v w marked d k l).baseChange ℝ) : + realMarkedPolynomialLift F v w marked hw hv t d k l p ∈ + (markedShiftBiLayer F v w marked t k d).baseChange ℝ := by + obtain ⟨z, rfl⟩ := (realificationSubmoduleEquiv _).surjective p + change (markedShiftLayerPolynomialMap F v w marked hw hv t d k l).baseChange ℝ + ((realificationSubmoduleEquiv _).symm (realificationSubmoduleEquiv _ z)) ∈ _ + rw [LinearEquiv.symm_apply_apply] + induction z using TensorProduct.inductionOn with + | tmul a z => + rw [LinearMap.baseChange_tmul] + exact Submodule.tmul_mem_baseChange_of_mem a + (markedShiftLayerPolynomialMap_mem F v w marked hw hv t d k l z) + | add z z' hz hz' => simpa only [map_add] using Submodule.add_mem _ hz hz' + +theorem realMarkedPolynomialLift_eval (t d k l : ℕ) + (p : (markedPolynomialLayer (σ := Fin t) v w marked d k l).baseChange ℝ) (a : Fin t → ℚ) : + (markedShiftEval F v w marked t a).baseChange ℝ + (realMarkedPolynomialLift F v w marked hw hv t d k l p) = + (eval a).baseChange ℝ p.val := by + obtain ⟨z, rfl⟩ := (realificationSubmoduleEquiv _).surjective p + change (markedShiftEval F v w marked t a).baseChange ℝ + ((markedShiftLayerPolynomialMap F v w marked hw hv t d k l).baseChange ℝ + ((realificationSubmoduleEquiv _).symm (realificationSubmoduleEquiv _ z))) = _ + rw [LinearEquiv.symm_apply_apply] + rw [realificationSubmoduleEquiv_coe] + induction z using TensorProduct.inductionOn with + | tmul a z => rfl + | add z z' hz hz' => simp only [map_add, hz, hz'] + +noncomputable def realMarkedQuotientCoefficient (t d k l : ℕ) : + (markedPolynomialLayer (σ := Fin t) v w marked d k l).baseChange ℝ →ₗ[ℝ] + ℝ ⊗[ℚ] (MarkedShiftQuotient F v w marked t) := + ((lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap.baseChange ℝ).comp + (realMarkedPolynomialLift F v w marked hw hv t d k l) + +theorem realMarkedPolynomialLift_quotient_mem (t d k l : ℕ) + (p : (markedPolynomialLayer (σ := Fin t) v w marked d k l).baseChange ℝ) : + realMarkedQuotientCoefficient F v w marked hw hv t d k l p ∈ + (markedShiftMultidegree F v w marked hw hv t).realification.layer (correlationInput k d) := by + change _ ∈ ((markedShiftBiLayer F v w marked t k d).map + (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap).baseChange ℝ + rw [realification_map] + exact ⟨_, realMarkedPolynomialLift_mem F v w marked hw hv t d k l p, rfl⟩ + +variable (t l : ℕ) + (c : ∀ j : Fin s, (markedPolynomialLayer (σ := Fin t) v w marked (j.val + 1) 0 l).baseChange ℝ) + (d : ∀ j : Fin s, (markedPolynomialLayer (σ := Fin t) v w marked (j.val + 1) 1 l).baseChange ℝ) + +noncomputable def realMarkedAffineMixedOrbit : + (markedShiftMultidegree F v w marked hw hv t).realification.PolynomialOrbit := + (markedShiftMultidegree F v w marked hw hv t).realification.affineMixedOrbit + (fun j => realMarkedQuotientCoefficient F v w marked hw hv t (j.val + 1) 0 l (c j)) + (fun j => realMarkedQuotientCoefficient F v w marked hw hv t (j.val + 1) 1 l (d j)) + (fun j => realMarkedPolynomialLift_quotient_mem F v w marked hw hv t (j.val + 1) 0 l (c j)) + (fun j => realMarkedPolynomialLift_quotient_mem F v w marked hw hv t (j.val + 1) 1 l (d j)) + +theorem realMarkedAffineMixedOrbit_eval (h n : ℤ) : + ((markedShiftMultidegree F v w marked hw hv t).realification.polynomialOrbitEval + (correlationInput h n) (realMarkedAffineMixedOrbit F v w marked hw hv t l c d)).coord = + ∑ j : Fin s, (n : ℚ) ^ (j.val + 1) • + (realMarkedQuotientCoefficient F v w marked hw hv t (j.val + 1) 0 l (c j) + + (h : ℚ) • realMarkedQuotientCoefficient F v w marked hw hv t (j.val + 1) 1 l (d j)) := + MultidegreeLieFiltration.affineMixedOrbit_eval _ _ _ _ _ (correlationInput h n) + +theorem realMarkedAffineMixedOrbit_at_zero (h : ℤ) : + (markedShiftMultidegree F v w marked hw hv t).realification.polynomialOrbitEval + (correlationInput h 0) (realMarkedAffineMixedOrbit F v w marked hw hv t l c d) = 1 := + MultidegreeLieFiltration.affineMixedOrbit_at_zero _ _ _ _ _ h + +theorem realMarkedAffineMixedOrbit_normalized : + (markedShiftMultidegree F v w marked hw hv t).realification.polynomialOrbitEval 0 + (realMarkedAffineMixedOrbit F v w marked hw hv t l c d) = 1 := + MultidegreeLieFiltration.affineMixedOrbit_normalized _ _ _ _ _ + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open VectorPolynomial +open scoped BigOperators TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + (t : ℕ) (x : ∀ j : Fin s, (D.coefficientFreeSpan j).baseChange ℝ) + (y : ∀ j : Fin s, Fin t → (D.dependentFreeSpan j).baseChange ℝ) (u : Fin t → ℝ) + +noncomputable def realAffineMarkedBase (j : Fin s) : + (D.dependentPolynomialLayer (σ := Fin t) (j.val + 1) 0 1).baseChange ℝ := + ⟨realAffinePolynomial (x j).val (fun i => (y j i).val), + realAffinePolynomial_mem_marked D.coefficientFreeGenerator D.coefficientWeight D.coefficientIsDependent + (Submodule.baseChange_mono ℝ (D.coefficientFreeSpan_le_dependentWordLayer j) (x j).property) + (fun i => Submodule.baseChange_mono ℝ (D.dependentFreeSpan_le_dependentWordLayer j) (y j i).property)⟩ + +noncomputable def realAffineMarkedSlope (j : Fin s) : + (D.dependentPolynomialLayer (σ := Fin t) (j.val + 1) 1 1).baseChange ℝ := by + let z := ∑ i, u i • (y j i).val + refine ⟨(monomialLinearMap (0 : Fin t →₀ ℕ)).baseChange ℝ z, ?_⟩ + apply realMonomial_mem_markedPolynomialLayer + simp only [map_zero, Nat.add_zero] + apply Submodule.sum_mem + intro i _ + apply Submodule.smul_mem + exact Submodule.baseChange_mono ℝ (D.dependentFreeSpan_le_dependentWordLayer j) (y j i).property + +theorem realAffineMarkedBase_eval (j : Fin s) (a : Fin t → ℚ) : + (markedShiftEval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t a).baseChange ℝ + (realMarkedPolynomialLift D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t (j.val + 1) 0 1 (D.realAffineMarkedBase t x y j)) = + (x j).val + ∑ i, a i • (y j i).val := by + exact (realMarkedPolynomialLift_eval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t (j.val + 1) 0 1 (D.realAffineMarkedBase t x y j) a).trans + (realAffinePolynomial_eval (x j).val (fun i => (y j i).val) a) + +theorem realAffineMarkedSlope_eval (j : Fin s) (a : Fin t → ℚ) : + (markedShiftEval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t a).baseChange ℝ + (realMarkedPolynomialLift D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t (j.val + 1) 1 1 (D.realAffineMarkedSlope t y u j)) = + ∑ i, u i • (y j i).val := by + apply (realMarkedPolynomialLift_eval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t (j.val + 1) 1 1 (D.realAffineMarkedSlope t y u j) a).trans + change (eval a).baseChange ℝ ((monomialLinearMap 0).baseChange ℝ (∑ i, u i • (y j i).val)) = _ + rw [realMonomial_eval, Finsupp.prod_zero_index, one_smul] + +noncomputable def commonAffineMarkedOrbit : (D.markedQuotientMultidegree t).realification.PolynomialOrbit := + realMarkedAffineMixedOrbit D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t 1 (D.realAffineMarkedBase t x y) (D.realAffineMarkedSlope t y u) + +theorem commonAffineMarkedOrbit_at_zero (h : ℤ) : + (D.markedQuotientMultidegree t).realification.polynomialOrbitEval (correlationInput h 0) + (D.commonAffineMarkedOrbit t x y u) = 1 := + realMarkedAffineMixedOrbit_at_zero _ _ _ _ _ _ _ _ _ _ h + +theorem commonAffineMarkedOrbit_normalized : + (D.markedQuotientMultidegree t).realification.polynomialOrbitEval 0 + (D.commonAffineMarkedOrbit t x y u) = 1 := + realMarkedAffineMixedOrbit_normalized _ _ _ _ _ _ _ _ _ _ + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped BigOperators TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + (t : ℕ) (x : ∀ j : Fin s, (D.coefficientFreeSpan j).baseChange ℝ) + (y : ∀ j : Fin s, Fin t → (D.dependentFreeSpan j).baseChange ℝ) (u : Fin t → ℝ) + +noncomputable def commonAffineMarkedLift (h n : ℤ) : + ℝ ⊗[ℚ] markedShiftSubalgebra D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t := + ∑ j : Fin s, (n : ℚ) ^ (j.val + 1) • + (realMarkedPolynomialLift D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t (j.val + 1) 0 1 (D.realAffineMarkedBase t x y j) + + (h : ℚ) • realMarkedPolynomialLift D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t (j.val + 1) 1 1 (D.realAffineMarkedSlope t y u j)) + +theorem commonAffineMarkedOrbit_eval (h n : ℤ) : + ((D.markedQuotientMultidegree t).realification.polynomialOrbitEval (correlationInput h n) + (D.commonAffineMarkedOrbit t x y u)).coord = + (lieQuotientMap (markedShiftSecondIdeal D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t)).toLinearMap.baseChange ℝ + (D.commonAffineMarkedLift t x y u h n) := by + have he := realMarkedAffineMixedOrbit_eval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent D.coefficientWeight_pos + D.coefficientFreeGenerator_mem_layer t 1 (D.realAffineMarkedBase t x y) (D.realAffineMarkedSlope t y u) h n + apply he.trans + simp only [commonAffineMarkedLift, map_sum, LinearMap.map_smul_of_tower, map_add] + rfl + +theorem commonAffineMarkedLift_eval (a : Fin t → ℚ) (h n : ℤ) : + (markedShiftEval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t a).baseChange ℝ + (D.commonAffineMarkedLift t x y u h n) = + ∑ j : Fin s, (n : ℚ) ^ (j.val + 1) • + ((x j).val + ∑ i, ((a i : ℝ) + (h : ℝ) * u i) • (y j i).val) := by + simp only [commonAffineMarkedLift, map_sum, LinearMap.map_smul_of_tower, map_add] + apply Finset.sum_congr rfl + intro j _ + apply congrArg (fun z : ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra => (n : ℚ) ^ (j.val + 1) • z) + calc + _ = ((x j).val + ∑ i, a i • (y j i).val) + (h : ℚ) • (∑ i, u i • (y j i).val) := + congrArg₂ (fun z z' : ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra => z + (h : ℚ) • z') + (D.realAffineMarkedBase_eval t x y j a) (D.realAffineMarkedSlope_eval t y u j a) + _ = _ := by + simp only [add_smul, Finset.sum_add_distrib, Finset.smul_sum, + ← Rat.cast_smul_eq_qsmul ℝ, Rat.cast_intCast, smul_smul, add_assoc] + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CommonIntegerIntervalCorrelation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CommonIntegerIntervalCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbf81acfb22587aab711bd03fbc528adc31ceb3d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CommonIntegerIntervalCorrelation.lean @@ -0,0 +1,240 @@ +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.Order.Floor.Ring +import OAI.Combinatorics.Progressions.Estimates.FixedPartnerPower + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def integerGridStart (a L : ℕ) : ℕ := L * (a / L + 1) + +def integerGridEnd (b L : ℕ) : ℕ := L * (b / L) + +theorem integerGridStart_bounds (a : ℕ) {L : ℕ} (hL : 0 < L) : + a ≤ integerGridStart a L ∧ integerGridStart a L ≤ a + L := by + constructor + · exact (Nat.lt_mul_div_succ a hL).le + · dsimp [integerGridStart] + rw [Nat.mul_add, Nat.mul_one] + exact Nat.add_le_add_right (by simpa only [Nat.mul_comm] using Nat.div_mul_le_self a L) L + +theorem integerGridEnd_bounds (b : ℕ) {L : ℕ} (hL : 0 < L) : + integerGridEnd b L ≤ b ∧ b < integerGridEnd b L + L := by + exact ⟨by simpa only [integerGridEnd, Nat.mul_comm] using Nat.div_mul_le_self b L, + Nat.lt_mul_div_self_add hL⟩ + +theorem integer_grid_interval_geometry (a len : ℕ) {L : ℕ} (hL : 0 < L) + (hsmall : 4 * L ≤ len) : + a ≤ integerGridStart a L ∧ integerGridEnd (a + len) L ≤ a + len ∧ + integerGridStart a L < integerGridEnd (a + len) L ∧ + integerGridEnd (a + len) L - integerGridStart a L ≤ len ∧ + len ≤ 2 * (integerGridEnd (a + len) L - integerGridStart a L) ∧ + len ≤ (integerGridEnd (a + len) L - integerGridStart a L) + 2 * L := by + have hs := integerGridStart_bounds a hL + have he := integerGridEnd_bounds (a + len) hL + omega + +theorem norm_sum_subset_card_loss {α : Type*} [DecidableEq α] + {S T : Finset α} (hTS : T ⊆ S) (f : α → ℂ) (hf : ∀ x ∈ S, ‖f x‖ ≤ 1) : + ‖∑ x ∈ S, f x‖ ≤ ‖∑ x ∈ T, f x‖ + (S.card : ℝ) - (T.card : ℝ) := by + have hsum := Finset.sum_sdiff (f := f) hTS + have hb : ‖∑ x ∈ S \ T, f x‖ ≤ ((S \ T).card : ℝ) := by + apply (norm_sum_le _ _).trans + simpa using Finset.sum_le_sum (fun x hx => hf x (Finset.mem_sdiff.mp hx).1) + have hc : ((S \ T).card : ℝ) + (T.card : ℝ) = (S.card : ℝ) := by + exact_mod_cast Finset.card_sdiff_add_card_eq_card hTS + have hn := norm_add_le (∑ x ∈ S \ T, f x) (∑ x ∈ T, f x) + rw [hsum] at hn + linarith only [hb, hc, hn] + +theorem integer_grid_interval_correlation (a len : ℕ) {L : ℕ} (hL : 0 < L) + {ρ : ℝ} (hρ : 0 < ρ) (hρone : ρ ≤ 1) (hsmall : 4 * (L : ℝ) ≤ ρ * len) + (f : ℤ → ℂ) (hf : ∀ n, ‖f n‖ ≤ 1) + (hcorr : ρ ≤ ‖𝔼 n ∈ Finset.Ico (a : ℤ) (a + len), f n‖) : + ρ / 2 ≤ ‖𝔼 n ∈ Finset.Ico (integerGridStart a L : ℤ) + (integerGridEnd (a + len) L : ℤ), f n‖ := by + have hsmallNat : 4 * L ≤ len := by + have h := hsmall.trans (mul_le_of_le_one_left (Nat.cast_nonneg len) hρone) + exact_mod_cast h + obtain ⟨hstart, hend, hpos, hlenle, _, hloss⟩ := integer_grid_interval_geometry a len hL hsmallNat + let S := Finset.Ico (a : ℤ) (a + len) + let T := Finset.Ico (integerGridStart a L : ℤ) (integerGridEnd (a + len) L : ℤ) + let d := integerGridEnd (a + len) L - integerGridStart a L + have hTS : T ⊆ S := by + intro n hn + simp only [S, T, Finset.mem_Ico] at hn ⊢ + constructor <;> omega + have hScard : S.card = len := by simp [S, Int.card_Ico] + have hTcard : T.card = d := by + simp only [T, Int.card_Ico] + rw [← Int.natCast_sub hpos.le, Int.toNat_natCast] + have hbound := norm_sum_subset_card_loss hTS f (fun n _ => hf n) + rw [← Finset.card_mul_expect S f, ← Finset.card_mul_expect T f] at hbound + simp only [norm_mul, Complex.norm_natCast, hScard, hTcard] at hbound + have hd : (0 : ℝ) < d := by exact_mod_cast Nat.sub_pos_of_lt hpos + have hdlen : (d : ℝ) ≤ len := by exact_mod_cast hlenle + have hlossR : (len : ℝ) ≤ d + 2 * L := by exact_mod_cast hloss + have hcor := mul_le_mul_of_nonneg_left hcorr (Nat.cast_nonneg len : (0 : ℝ) ≤ len) + change ρ / 2 ≤ ‖𝔼 n ∈ T, f n‖ + nlinarith only [hbound, hcor, hsmall, hd, hdlen, hlossR, hρ] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_exp_integer_grid_scale {p : ℝ} (hp : 0 ≤ p) {N : ℕ} + (hN : Real.exp (2 * p + 8) ≤ (N : ℝ)) : + ∃ L : ℕ, 0 < L ∧ 4 * (L : ℝ) ≤ Real.exp (-(2 * p)) * N ∧ + ((N / L + 2 : ℕ) : ℝ) ≤ Real.exp (2 * p + 5) := by + let x := Real.exp (-(2 * p)) * N / 8 + let L := ⌊x⌋₊ + have hx0 : 0 ≤ x := by dsimp [x]; positivity + have h16 : (16 : ℝ) ≤ Real.exp 8 := + (by norm_num : (16 : ℝ) ≤ 2 ^ 8).trans (two_pow_le_exp_of_le 8 le_rfl) + have hscaled : Real.exp 8 ≤ Real.exp (-(2 * p)) * N := by + calc + _ = Real.exp (-(2 * p)) * Real.exp (2 * p + 8) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ _ := mul_le_mul_of_nonneg_left hN (Real.exp_nonneg _) + have hx2 : 2 ≤ x := by dsimp [x]; linarith only [h16, hscaled] + have hfloor : (L : ℝ) ≤ x := Nat.floor_le hx0 + have hlt : x < (L : ℝ) + 1 := Nat.lt_floor_add_one x + have hL : 0 < L := by + have : (0 : ℝ) < L := by linarith only [hx2, hlt] + exact_mod_cast this + have hhalf : x ≤ 2 * (L : ℝ) := by linarith only [hx2, hlt] + have hupper : 4 * (L : ℝ) ≤ Real.exp (-(2 * p)) * N := by + dsimp [x] at hfloor hx0 + linarith only [hfloor, hx0] + have hlower : Real.exp (-(2 * p)) * N ≤ 16 * (L : ℝ) := by + dsimp [x] at hhalf + linarith only [hhalf] + have hNL : (N : ℝ) ≤ 16 * Real.exp (2 * p) * L := by + calc + _ = Real.exp (2 * p) * (Real.exp (-(2 * p)) * N) := by + rw [← mul_assoc, ← Real.exp_add, add_neg_cancel, Real.exp_zero, one_mul] + _ ≤ Real.exp (2 * p) * (16 * L) := + mul_le_mul_of_nonneg_left hlower (Real.exp_nonneg _) + _ = _ := by ring + have hdiv : ((N / L : ℕ) : ℝ) ≤ 16 * Real.exp (2 * p) := + Nat.cast_div_le.trans ((div_le_iff₀ (by exact_mod_cast hL : (0 : ℝ) < L)).mpr hNL) + have h18 : (18 : ℝ) ≤ Real.exp 5 := + (by norm_num : (18 : ℝ) ≤ 2 ^ 5).trans (two_pow_le_exp_of_le 5 le_rfl) + refine ⟨L, hL, hupper, ?_⟩ + calc + _ = ((N / L : ℕ) : ℝ) + 2 := by norm_cast + _ ≤ 18 * Real.exp (2 * p) := by + have h1 := Real.one_le_exp (show 0 ≤ 2 * p by positivity) + linarith only [hdiv, h1] + _ ≤ Real.exp 5 * Real.exp (2 * p) := mul_le_mul_of_nonneg_right h18 (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_common_integer_interval {G : Type*} {p : ℝ} (hp : 0 ≤ p) {N : ℕ} + (hN : Real.exp (2 * p + 8) ≤ (N : ℝ)) + (H : Finset G) (hH : H.Nonempty) (start len : G → ℕ) + (hend : ∀ t ∈ H, start t + len t ≤ N) + (hshort : ∀ t ∈ H, 2 * ((len t : ℤ) - 1) < N) + (hlength : ∀ t ∈ H, Real.exp (-p) * N ≤ (len t : ℝ)) + (f : G → ℤ → ℂ) (hf : ∀ t ∈ H, ∀ n, ‖f t n‖ ≤ 1) + (hcorr : ∀ t ∈ H, Real.exp (-p) ≤ + ‖𝔼 n ∈ Finset.Ico (start t : ℤ) (start t + len t), f t n‖) : + ∃ S : Finset G, S ⊆ H ∧ S.Nonempty ∧ + Real.exp (-(4 * p + 10)) * (H.card : ℝ) ≤ (S.card : ℝ) ∧ + ∃ a d : ℕ, 0 < d ∧ a + d ≤ N ∧ 2 * ((d : ℤ) - 1) < N ∧ + Real.exp (-(p + 1)) * N ≤ (d : ℝ) ∧ + ∀ t ∈ S, Real.exp (-(p + 1)) ≤ + ‖𝔼 n ∈ Finset.Ico (a : ℤ) (a + d), f t n‖ := by + classical + obtain ⟨L, hL, hscale, hgrid⟩ := exists_exp_integer_grid_scale hp hN + have hrho : Real.exp (-p) ≤ 1 := Real.exp_le_one_iff.mpr (by linarith only [hp]) + have hsmall (t : G) (ht : t ∈ H) : 4 * (L : ℝ) ≤ Real.exp (-p) * len t := by + apply hscale.trans + calc + _ = Real.exp (-p) * (Real.exp (-p) * N) := by + rw [← mul_assoc, ← Real.exp_add] + congr 2 + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (hlength t ht) (Real.exp_nonneg _) + have hsmallNat (t : G) (ht : t ∈ H) : 4 * L ≤ len t := by + exact_mod_cast (hsmall t ht).trans (mul_le_of_le_one_left (Nat.cast_nonneg _) hrho) + let P := Fin (N / L + 2) × Fin (N / L + 2) + let rel (t : G) (_ : Unit) (c : P) : Prop := + start t / L + 1 = c.1.val ∧ (start t + len t) / L = c.2.val + have hchoice : ∀ t ∈ H, ∀ u, ∃ c, rel t u c := by + intro t ht _ + have hs : start t ≤ N := by have hh := hend t ht; omega + have hsd : start t / L ≤ N / L := Nat.div_le_div_right hs + have hed : (start t + len t) / L ≤ N / L := Nat.div_le_div_right (hend t ht) + exact ⟨(⟨start t / L + 1, by omega⟩, ⟨(start t + len t) / L, by omega⟩), rfl, rfl⟩ + have hcount : (Fintype.card P : ℝ) ≤ Real.exp (4 * p + 10) := by + simp only [P, Fintype.card_prod, Fintype.card_fin, Nat.cast_mul] + calc + _ ≤ Real.exp (2 * p + 5) * Real.exp (2 * p + 5) := + mul_le_mul hgrid hgrid (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + obtain ⟨c, S, hSH, hS, hSdense, hfixed⟩ := exists_large_fixed_choices H hH rel hchoice hcount + let a := L * (c ()).1.val + let b := L * (c ()).2.val + let d := b - a + have hround (t : G) (ht : t ∈ S) : + integerGridStart (start t) L = a ∧ integerGridEnd (start t + len t) L = b := by + obtain ⟨hs, he⟩ := hfixed t ht () + constructor + · dsimp only [integerGridStart, a] + rw [hs] + · dsimp only [integerGridEnd, b] + rw [he] + obtain ⟨t0, ht0⟩ := hS + have ht0H := hSH ht0 + have hgeom := integer_grid_interval_geometry (start t0) (len t0) hL (hsmallNat t0 ht0H) + rw [(hround t0 ht0).1, (hround t0 ht0).2] at hgeom + obtain ⟨_, hb, hab, hdlen, hhalf, _⟩ := hgeom + have had : a + d = b := Nat.add_sub_of_le hab.le + have hd : 0 < d := Nat.sub_pos_of_lt hab + have hbN : b ≤ N := hb.trans (hend t0 ht0H) + have hdshort : 2 * ((d : ℤ) - 1) < N := by + have hs := hshort t0 ht0H + change d ≤ len t0 at hdlen + omega + have hhalfR : (len t0 : ℝ) ≤ 2 * d := by exact_mod_cast hhalf + have hvol : Real.exp (-p) / 2 * N ≤ (d : ℝ) := by + have hv := hlength t0 ht0H + nlinarith only [hv, hhalfR] + have hthreshold : Real.exp (-(p + 1)) ≤ Real.exp (-p) / 2 := by + simpa only [show -(p + 1) = -p - 1 by ring] using exp_sub_one_le_half_exp (-p) + refine ⟨S, hSH, ⟨t0, ht0⟩, ?_, a, d, hd, ?_, hdshort, ?_, ?_⟩ + · simpa only [Fintype.card_unit, Nat.cast_one, mul_one] using hSdense + · omega + · exact (mul_le_mul_of_nonneg_right hthreshold (Nat.cast_nonneg _)).trans hvol + · intro t ht + have hc := integer_grid_interval_correlation (start t) (len t) hL + (Real.exp_pos (-p)) hrho (hsmall t (hSH ht)) (f t) (hf t (hSH ht)) (hcorr t (hSH ht)) + rw [(hround t ht).1, (hround t ht).2] at hc + have hupp : (a : ℤ) + d = b := by exact_mod_cast had + simpa only [hupp] using hthreshold.trans hc + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CommonIntegerSiteResidual.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CommonIntegerSiteResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..991d8d44f83798e4b51b457a2dd1cbce70cfa04a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CommonIntegerSiteResidual.lean @@ -0,0 +1,183 @@ +import OAI.Combinatorics.Progressions.Estimates.ScaledLinearResidual +import OAI.Combinatorics.Progressions.Fourier.CommonCoveredSiteCharacter + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix Classical + +theorem clearedMatrix_real {I S : Type*} [Fintype I] [Fintype S] + (T : Matrix I S ℚ) (i : I) (s : S) : + (clearedMatrix T i s : ℝ) = (matrixDenominator T : ℝ) * (T i s : ℝ) := by + have h := congrFun (congrFun (clearedMatrix_cast T) i) s + change (clearedMatrix T i s : ℚ) = (matrixDenominator T : ℚ) * T i s at h + exact_mod_cast h + +theorem matrixModuleAction_cleared {I S W : Type*} [Fintype I] [Fintype S] + [AddCommGroup W] [Module ℝ W] (T : Matrix I S ℚ) (x : S → W) : + matrixModuleAction (fun i s => (clearedMatrix T i s : ℝ)) x = + (matrixDenominator T : ℝ) • matrixModuleAction (fun i s => (T i s : ℝ)) x := by + funext i + change (∑ s, (clearedMatrix T i s : ℝ) • x s) = + (matrixDenominator T : ℝ) • ∑ s, (T i s : ℝ) • x s + simp only [clearedMatrix_real, mul_smul, Finset.smul_sum] + +theorem exists_integer_site_residual {I S : Type*} [Fintype I] [Fintype S] + (E : Matrix S I ℤ) {H : ℕ} (hH : 1 ≤ H) + (hE : ∀ s i, RationalHeightLE (E s i : ℚ) H) : + ∃ (q : ℕ) (T : Matrix I S ℤ), 0 < q ∧ + (∀ {W : Type*} [AddCommGroup W] [Module ℝ W] (x : I → W), + matrixModuleAction (fun s i => (E s i : ℝ)) + (matrixModuleAction (fun i s => (T i s : ℝ)) + (matrixModuleAction (fun s i => (E s i : ℝ)) x)) = + (q : ℝ) • matrixModuleAction (fun s i => (E s i : ℝ)) x) ∧ + (∀ {P : ℝ}, 0 ≤ P → (Fintype.card I : ℝ) ≤ P → (Fintype.card S : ℝ) ≤ P → + (H : ℝ) ≤ Real.exp P → (q : ℝ) ≤ Real.exp ((P + 2) ^ 36)) := by + obtain ⟨T, hT, hTH⟩ := exists_bounded_rational_image_section (fun s i => (E s i : ℚ)) hH hE + refine ⟨matrixDenominator T, clearedMatrix T, matrixDenominator_pos T, ?_, ?_⟩ + · intro W _ _ x + rw [matrixModuleAction_cleared, map_smul] + congr 1 + have he := matrixModuleAction_image_section + (Matrix.of (fun s i => ((E s i : ℚ) : ℝ))) + (Matrix.of (fun i s => (T i s : ℝ))) + (real_matrix_image_section _ T hT) x + have he' := congrFun he + funext s + have hs := he' s + simpa only [matrixModuleAction, LinearMap.coe_mk, AddHom.coe_mk, + Matrix.of_apply, Rat.cast_intCast] using hs + · intro P hP hI hS hHP + simpa only [Nat.mul_one] using real_image_section_denominator_bound T H 1 hTH hP hS hI hHP + (by simpa using Real.one_le_exp hP) + +theorem scaledSiteResidual_preserves_lattice {I S J : Type*} [Fintype I] [Fintype S] + (U : Submodule ℝ (J → ℝ)) (E : Matrix S I ℤ) (T : Matrix I S ℤ) (q : ℕ) + (x : I → U) (hx : x ∈ subspaceArrayIntegerLattice I U) : + scaledLinearResidual (matrixModuleAction (fun s i => (E s i : ℝ))) + (matrixModuleAction (fun i s => (T i s : ℝ))) (q : ℝ) x ∈ subspaceArrayIntegerLattice I U := by + apply (subspaceArrayIntegerLattice I U).sub_mem ?_ + (integerMatrix_preserves_array_lattice U T _ (integerMatrix_preserves_array_lattice U E x hx)) + intro i a + obtain ⟨z, hz⟩ := hx i a + refine ⟨(q : ℤ) * z, ?_⟩ + change (q : ℝ) * (x i).val a = _ + rw [hz, Int.cast_mul, Int.cast_natCast] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix Classical + +theorem cleared_image_section_entry_bound {I S : Type*} [Fintype I] [Fintype S] + (T : Matrix I S ℚ) (H : ℕ) + (hT : ∀ i s, RationalHeightLE (T i s) (rationalKernelHeight (Fintype.card S) H)) + {P : ℝ} (hP : 0 ≤ P) (hI : (Fintype.card I : ℝ) ≤ P) + (hS : (Fintype.card S : ℝ) ≤ P) (hH : (H : ℝ) ≤ Real.exp P) (i : I) (s : S) : + |(clearedMatrix T i s : ℝ)| ≤ Real.exp (2 * (P + 2) ^ 36) := by + have hden : (matrixDenominator T : ℝ) ≤ Real.exp ((P + 2) ^ 36) := by + simpa only [Nat.mul_one] using real_image_section_denominator_bound T H 1 hT hP hS hI hH + (by simpa using Real.one_le_exp hP) + have hentry := (hT i s).abs_real_le.trans + (rationalKernelHeight_le_budget (Fintype.card S) H hP hS hH) + have hpow : (P + 2) ^ 7 ≤ (P + 2) ^ 36 := + pow_le_pow_right₀ (by linarith) (by decide) + rw [clearedMatrix_real, abs_mul, abs_of_nonneg (Nat.cast_nonneg _)] + calc + _ ≤ Real.exp ((P + 2) ^ 36) * Real.exp ((P + 2) ^ 7) := + mul_le_mul hden hentry (abs_nonneg _) (Real.exp_pos _).le + _ = Real.exp ((P + 2) ^ 36 + (P + 2) ^ 7) := (Real.exp_add _ _).symm + _ ≤ Real.exp (2 * (P + 2) ^ 36) := Real.exp_le_exp.mpr (by linarith) + +theorem exists_bounded_integer_site_residual {I S : Type*} [Fintype I] [Fintype S] + (E : Matrix S I ℤ) {H : ℕ} (hH : 1 ≤ H) + (hE : ∀ s i, RationalHeightLE (E s i : ℚ) H) : + ∃ (d : ℕ) (T : Matrix I S ℤ), 0 < d ∧ + (∀ {W : Type*} [AddCommGroup W] [Module ℝ W] (x : I → W), + matrixModuleAction (fun s i => (E s i : ℝ)) + (matrixModuleAction (fun i s => (T i s : ℝ)) + (matrixModuleAction (fun s i => (E s i : ℝ)) x)) = + (d : ℝ) • matrixModuleAction (fun s i => (E s i : ℝ)) x) ∧ + (∀ {P : ℝ}, 0 ≤ P → (Fintype.card I : ℝ) ≤ P → (Fintype.card S : ℝ) ≤ P → + (H : ℝ) ≤ Real.exp P → + (d : ℝ) ≤ Real.exp ((P + 2) ^ 36) ∧ + ∀ i s, |(T i s : ℝ)| ≤ Real.exp (2 * (P + 2) ^ 36)) := by + obtain ⟨T, hT, hTH⟩ := exists_bounded_rational_image_section (fun s i => (E s i : ℚ)) hH hE + refine ⟨matrixDenominator T, clearedMatrix T, matrixDenominator_pos T, ?_, ?_⟩ + · intro W _ _ x + rw [matrixModuleAction_cleared, map_smul] + congr 1 + have he := matrixModuleAction_image_section + (Matrix.of (fun s i => ((E s i : ℚ) : ℝ))) + (Matrix.of (fun i s => (T i s : ℝ))) (real_matrix_image_section _ T hT) x + funext s + simpa only [matrixModuleAction, LinearMap.coe_mk, AddHom.coe_mk, + Matrix.of_apply, Rat.cast_intCast] using congrFun he s + · intro P hP hI hS hHP + refine ⟨?_, cleared_image_section_entry_bound T H hTH hP hI hS hHP⟩ + simpa only [Nat.mul_one] using real_image_section_denominator_bound T H 1 hTH hP hS hI hHP + (by simpa using Real.one_le_exp hP) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem matrixModuleAction_int_smul {I S W : Type*} [Fintype S] + [AddCommGroup W] [Module ℝ W] (T : Matrix I S ℤ) (d : ℕ) (x : S → W) : + matrixModuleAction (fun i s => (((d : ℤ) * T i s : ℤ) : ℝ)) x = + (d : ℝ) • matrixModuleAction (fun i s => (T i s : ℝ)) x := by + funext i + change (∑ s, (((d : ℤ) * T i s : ℤ) : ℝ) • x s) = + (d : ℝ) • ∑ s, (T i s : ℝ) • x s + simp only [Int.cast_mul, Int.cast_natCast, mul_smul, Finset.smul_sum] + +theorem exists_common_integer_site_residual {J S : Type*} [Fintype J] [Fintype S] + {I : J → Type*} [∀ j, Fintype (I j)] (E : ∀ j, Matrix S (I j) ℤ) + (H : J → ℕ) (hH : ∀ j, 1 ≤ H j) + (hE : ∀ j s i, RationalHeightLE (E j s i : ℚ) (H j)) : + ∃ (q : ℕ) (T : ∀ j, Matrix (I j) S ℤ), 0 < q ∧ + (∀ j {W : Type*} [AddCommGroup W] [Module ℝ W] (x : I j → W), + matrixModuleAction (fun s i => (E j s i : ℝ)) + (matrixModuleAction (fun i s => (T j i s : ℝ)) + (matrixModuleAction (fun s i => (E j s i : ℝ)) x)) = + (q : ℝ) • matrixModuleAction (fun s i => (E j s i : ℝ)) x) ∧ + (∀ {P : ℝ}, 0 ≤ P → (∀ j, (Fintype.card (I j) : ℝ) ≤ P) → + (Fintype.card S : ℝ) ≤ P → (∀ j, (H j : ℝ) ≤ Real.exp P) → + (q : ℝ) ≤ Real.exp (Fintype.card J * (P + 2) ^ 36)) := by + choose d T hd hT hbound using fun j => exists_integer_site_residual (E j) (hH j) (hE j) + let q := ∏ j, d j + let c := fun j => ∏ i ∈ Finset.univ.erase j, d i + have hc (j) : c j * d j = q := by + exact (Finset.prod_erase_mul _ _ (Finset.mem_univ j)).trans rfl + refine ⟨q, fun j i s => (c j : ℤ) * T j i s, Finset.prod_pos (fun j _ => hd j), ?_, ?_⟩ + · intro j W _ _ x + rw [matrixModuleAction_int_smul, map_smul, hT j, smul_smul] + congr 1 + exact_mod_cast hc j + · intro P hP hI hS hHP + calc + (q : ℝ) = ∏ j, (d j : ℝ) := Nat.cast_prod _ _ + _ ≤ ∏ _j : J, Real.exp ((P + 2) ^ 36) := + Finset.prod_le_prod₀ (fun j _ => Nat.cast_nonneg _) (fun j _ => hbound j hP (hI j) hS (hHP j)) + _ = Real.exp (Fintype.card J * (P + 2) ^ 36) := by + rw [Finset.prod_const, Finset.card_univ, ← Real.exp_nat_mul] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CommonLocalAffineFamily.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CommonLocalAffineFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7eec24b130e4e8c3ad5589fd0ac50af58da368e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CommonLocalAffineFamily.lean @@ -0,0 +1,142 @@ +import OAI.Combinatorics.Progressions.Estimates.MarkedUnitOrbit +import OAI.Combinatorics.Progressions.Fourier.QuadraticLocalFrequency + +namespace OAI + +section + +namespace Erdos3 + +open Module VectorPolynomial +open scoped BigOperators + +theorem exists_local_affine_polynomial_family + {V : Type} [AddCommGroup V] [Module ℝ V] [Module ℚ V] + {s r N : ℕ} [NeZero N] {p : ℝ} (hp : 0 ≤ p) (hr : (r : ℝ) ≤ p) + (η : (Fin r → ℤ) →+ ZMod N) (R : Fin r → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) + (h₀ : ZMod N) (J : Finset (ZMod N)) (hJ : J.Nonempty) + (hdense : Real.exp (-p) * N ≤ (J.card : ℝ)) (x : ZMod N → Fin r → ℤ) + (hx : ∀ h ∈ J, ∀ i, |x h i| ≤ (R i : ℤ)) + (hrep : ∀ h ∈ J, h = h₀ + η (x h)) + (P : ZMod N → VectorPolynomial Unit ℚ V) (Γ : VectorPolynomial Unit ℚ V) + (α : Fin s → V) (β : Fin r → Fin s → V) (U : Fin s → Submodule ℝ V) + (hα : ∀ d, α d ∈ U d) (hβ : ∀ i d, β i d ∈ U d) + (hP : ∀ h ∈ J, P h = Γ + positiveUnivariate (fun d => α d + ∑ i, (x h i : ℝ) • β i d)) : + ∃ K ⊆ J, K.Nonempty ∧ Real.exp (-((p + 4) ^ 7)) * N ≤ (K.card : ℝ) ∧ + ∃ b : Basis (Fin r) ℤ (cyclicIntegerKernel η), + (∀ i j, |(b i : Fin r → ℝ) j| ≤ + properCyclicKernelBasisBound r (Real.exp (-p)) * ((R j : ℝ) + 1)) ∧ + ∃ (t c : Fin r → ℝ) (α' : Fin s → V) (β' : Fin r → Fin s → V), + (∀ i, t i ∈ Set.Ico (0 : ℝ) 1) ∧ + (∀ i, ∃ k : ℤ, (N : ℝ) * t i = (k : ℝ)) ∧ + (∀ i, |c i| ≤ properCyclicCoordinateBound r (Real.exp (-p)) + 1 / 16) ∧ + (∀ d, α' d ∈ U d) ∧ (∀ i d, β' i d ∈ U d) ∧ + ∀ h ∈ K, + (∀ i, |affineCyclicTorusLocalLift t c h₀ h i| ≤ 1 / 16) ∧ + P h = Γ + positiveUnivariate (fun d => α' d + + ∑ i, affineCyclicTorusLocalLift t c h₀ h i • β' i d) := by + obtain ⟨b, hb, t, ht, hperiod, K, hKJ, hK, hcard, c, hc, hdata⟩ := + exists_localized_cyclic_torus_chart η R hinj h₀ J hJ (Real.exp (-p)) + (Real.exp_pos (-p)) hdense x hx hrep 8 (by norm_num) + let B := b.ofZLatticeBasis ℝ (cyclicIntegerKernel η) + let α' := affineBasisConstant B α β c + let β' := affineBasisCoefficient B β + refine ⟨K, hKJ, hK, local_cyclic_torus_density hp hr J K hdense hcard, + b, hb, t, c, α', β', ht, hperiod, ?_, ?_, ?_, ?_⟩ + · simpa only [Nat.cast_ofNat, div_div, show (2 : ℝ) * 8 = 16 by norm_num] using hc + · exact affineBasisConstant_mem B α β c U hα hβ + · exact affineBasisCoefficient_mem B β U hβ + · intro h hh + obtain ⟨_, hsmall, hcoord⟩ := hdata h hh + refine ⟨?_, ?_⟩ + · norm_num at hsmall ⊢ + exact hsmall + · rw [hP h (hKJ hh)] + have he : (fun d => α d + ∑ i, (x h i : ℝ) • β i d) = + fun d => α' d + ∑ i, affineCyclicTorusLocalLift t c h₀ h i • β' i d := by + funext d + change α d + ∑ i, integerVectorRealMap (x h) i • β i d = _ + rw [hcoord] + exact affine_basis_change B α β c (affineCyclicTorusLocalLift t c h₀ h) d + rw [he] + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module VectorPolynomial +open scoped BigOperators TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem exists_common_local_marked_family + {t : ℕ} {B : ℝ} (hB : 0 ≤ B) (ht : (t : ℝ) ≤ B) + (η : (Fin t → ℤ) →+ ZMod N) (radius : Fin t → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (radius i : ℤ)}) + (h₀ : ZMod N) (J : Finset (ZMod N)) (hJ : J.Nonempty) + (hdense : Real.exp (-B) * N ≤ (J.card : ℝ)) + (v : ZMod N → Fin t → ℤ) (hv : ∀ h ∈ J, ∀ i, |v h i| ≤ (radius i : ℤ)) + (hrep : ∀ h ∈ J, h = h₀ + η (v h)) + (A : ZMod N → VectorPolynomial Unit ℚ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)) + (Γ : VectorPolynomial Unit ℚ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)) + (hΓdeg : DegreeLE (fun _ : Unit => 1) s Γ) (hΓzero : coefficients Γ 0 = 0) + (hΓ : ∀ j : Fin s, coefficients Γ (Finsupp.single () (j.val + 1)) ∈ + (D.coefficientFreeSpan j).baseChange ℝ) + (α : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + (β : Fin t → Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + (hα : ∀ j, α j ∈ (D.dependentFreeSpan j).baseChange ℝ) + (hβ : ∀ i j, β i j ∈ (D.dependentFreeSpan j).baseChange ℝ) + (hA : ∀ h ∈ J, A h = Γ + positiveUnivariate (fun j => α j + ∑ i, (v h i : ℝ) • β i j)) : + ∃ K ⊆ J, K.Nonempty ∧ Real.exp (-((B + 4) ^ 7)) * N ≤ (K.card : ℝ) ∧ + ∃ (u c : Fin t → ℝ) + (x : ∀ j : Fin s, (D.coefficientFreeSpan j).baseChange ℝ) + (y : ∀ j : Fin s, Fin t → (D.dependentFreeSpan j).baseChange ℝ), + (∀ i, u i ∈ Set.Ico (0 : ℝ) 1) ∧ + (∀ i, ∃ k : ℤ, (N : ℝ) * u i = (k : ℝ)) ∧ + (∀ i, |c i| ≤ properCyclicCoordinateBound t (Real.exp (-B)) + 1 / 16) ∧ + ∀ h ∈ K, (∀ i, |affineCyclicTorusLocalLift u c h₀ h i| ≤ 1 / 16) ∧ + A h = positiveUnivariate (fun j => (x j).val + + ∑ i, affineCyclicTorusLocalLift u c h₀ h i • (y j i).val) ∧ + ∀ n : ℤ, + (markedShiftEval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t + (fun i => (-affineCyclicTorusCarry u c h₀ h i : ℤ))).baseChange ℝ + (D.localAffineMarkedLift t x y u c h₀ h n) = eval (fun _ => (n : ℚ)) (A h) := by + obtain ⟨K, hKJ, hK, hcard, _, _, u, c, α', β', hu, hperiod, hc, hα', hβ', hlocal⟩ := + exists_local_affine_polynomial_family hB ht η radius hinj h₀ J hJ hdense v hv hrep + A Γ α β (fun j => (D.dependentFreeSpan j).baseChange ℝ) hα hβ hA + let x : ∀ j : Fin s, (D.coefficientFreeSpan j).baseChange ℝ := fun j => + ⟨coefficients Γ (Finsupp.single () (j.val + 1)) + α' j, + Submodule.add_mem _ (hΓ j) (Submodule.baseChange_mono ℝ + (D.dependentFreeSpan_le_coefficientFreeSpan j) (hα' j))⟩ + let y : ∀ j : Fin s, Fin t → (D.dependentFreeSpan j).baseChange ℝ := + fun j i => ⟨β' i j, hβ' i j⟩ + refine ⟨K, hKJ, hK, hcard, u, c, x, y, hu, hperiod, hc, ?_⟩ + intro h hh + obtain ⟨hsmall, hpoly⟩ := hlocal h hh + have he : A h = positiveUnivariate (fun j => (x j).val + + ∑ i, affineCyclicTorusLocalLift u c h₀ h i • (y j i).val) := by + rw [hpoly, ← positiveUnivariate_reconstruct Γ hΓdeg hΓzero] + simp only [x, y, positiveUnivariate, monomial, TensorProduct.tmul_add, + Finset.sum_add_distrib, add_assoc] + exact ⟨hsmall, he, fun n => D.localAffineMarkedLift_eq_polynomial_eval t x y u c h₀ A h he n⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CommonStrideResidueGeometry.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CommonStrideResidueGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa12e458bea724cbf41bbf21f33804f244c11ef0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CommonStrideResidueGeometry.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Geometry.CommonStrideCoordinates + +namespace OAI + +section + +namespace Erdos3 + +theorem commonStridePoint_index_of_modEq {I : Type*} (c : I → ℤ) (m : ℕ) (y : I → ℤ) + (hy : ∀ i, y i ≡ c i [ZMOD (m : ℤ)]) : + commonStridePoint c m (commonStrideIndex c m y) = y := by + funext i + have hd := Int.modEq_iff_dvd.mp (hy i).symm + change c i + (m : ℤ) * ((y i - c i) / (m : ℤ)) = y i + rw [mul_comm, Int.ediv_mul_cancel hd] + omega + +theorem commonStrideIndex_difference {I : Type*} (c : I → ℤ) (m : ℕ) (y z : I → ℤ) + (hy : ∀ i, y i ≡ c i [ZMOD (m : ℤ)]) (hz : ∀ i, z i ≡ c i [ZMOD (m : ℤ)]) (i : I) : + (m : ℤ) * (commonStrideIndex c m y i - commonStrideIndex c m z i) = y i - z i := by + have hye := congrFun (commonStridePoint_index_of_modEq c m y hy) i + have hze := congrFun (commonStridePoint_index_of_modEq c m z hz) i + change c i + (m : ℤ) * commonStrideIndex c m y i = y i at hye + change c i + (m : ℤ) * commonStrideIndex c m z i = z i at hze + calc + _ = (c i + (m : ℤ) * commonStrideIndex c m y i) - + (c i + (m : ℤ) * commonStrideIndex c m z i) := by ring + _ = _ := by rw [hye, hze] + +theorem commonStrideIndex_period {I : Type*} (c : I → ℤ) {m : ℕ} (hm : 0 < m) + (q : ℕ) (y z : I → ℤ) + (hy : ∀ i, y i ≡ c i [ZMOD (m : ℤ)]) (hz : ∀ i, z i ≡ c i [ZMOD (m : ℤ)]) + (hperiod : ∀ i, ((m * q : ℕ) : ℤ) ∣ (y i - z i)) : + ∀ i, (q : ℤ) ∣ commonStrideIndex c m y i - commonStrideIndex c m z i := by + intro i + apply (mul_dvd_mul_iff_left (by exact_mod_cast hm.ne' : (m : ℤ) ≠ 0)).mp + rw [commonStrideIndex_difference c m y z hy hz i] + simpa only [Nat.cast_mul] using hperiod i + +theorem commonStrideIndex_abs_difference {I : Type*} (c : I → ℤ) (m : ℕ) (y z : I → ℤ) + (hy : ∀ i, y i ≡ c i [ZMOD (m : ℤ)]) (hz : ∀ i, z i ≡ c i [ZMOD (m : ℤ)]) (i : I) : + (m : ℝ) * |(commonStrideIndex c m y i : ℝ) - (commonStrideIndex c m z i : ℝ)| = + |(y i : ℝ) - (z i : ℝ)| := by + have he : (m : ℝ) * ((commonStrideIndex c m y i : ℝ) - (commonStrideIndex c m z i : ℝ)) = + (y i : ℝ) - (z i : ℝ) := by + exact_mod_cast commonStrideIndex_difference c m y z hy hz i + calc + _ = |(m : ℝ) * ((commonStrideIndex c m y i : ℝ) - (commonStrideIndex c m z i : ℝ))| := by + rw [abs_mul, (show |(m : ℝ)| = (m : ℝ) from abs_of_nonneg (Nat.cast_nonneg m))] + _ = _ := congrArg abs he + +theorem commonStrideIndex_distance_le {I : Type*} (c : I → ℤ) {m : ℕ} (hm : 0 < m) + (y z : I → ℤ) (hy : ∀ i, y i ≡ c i [ZMOD (m : ℤ)]) (hz : ∀ i, z i ≡ c i [ZMOD (m : ℤ)]) + (A : I → ℝ) (δ : ℝ) (hdist : ∀ i, |(y i : ℝ) - (z i : ℝ)| ≤ (m : ℝ) * A i * δ) : + ∀ i, |(commonStrideIndex c m y i : ℝ) - (commonStrideIndex c m z i : ℝ)| ≤ A i * δ := by + intro i + apply (mul_le_mul_iff_right₀ (by exact_mod_cast hm : (0 : ℝ) < m)).mp + rw [commonStrideIndex_abs_difference c m y z hy hz i] + simpa only [mul_assoc] using hdist i + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CompactLatticeApproximation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CompactLatticeApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fa2f150f182796ce56a2c13ee598f4d152197f0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CompactLatticeApproximation.lean @@ -0,0 +1,62 @@ +import OAI.Combinatorics.Progressions.Estimates.CompactIntervalIntegral +import OAI.Combinatorics.Progressions.Estimates.PartialComplexScaledQuadrature + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem sampledWeightHistogram_error (ψ : ℝ → ℝ) {L : ℝ≥0} (hLip : LipschitzWith L ψ) + {a S R : ℝ} (hS : 0 < S) (hsupport : ∀ x, R < |x| → ψ x = 0) (x : ℝ) : + ‖sampledWeightHistogram ψ a S R x - ψ x‖ ≤ (L : ℝ) / S := by + rw [sampledWeightHistogram_eq ψ hS hsupport] + calc + _ ≤ (L : ℝ) * ‖latticeSample a S x - x‖ := hLip.norm_sub_le _ _ + _ ≤ (L : ℝ) * (1 / S) := + mul_le_mul_of_nonneg_left (latticeSample_error hS x) L.coe_nonneg + _ = _ := by ring + +theorem sampledWeightHistogram_zero_outside (ψ : ℝ → ℝ) {a S R : ℝ} + (hS : 1 ≤ S) (hsupport : ∀ x, R < |x| → ψ x = 0) (x : ℝ) (hx : R + 1 < |x|) : + sampledWeightHistogram ψ a S R x = 0 := by + have hSp : 0 < S := lt_of_lt_of_le zero_lt_one hS + have he : |latticeSample a S x - x| ≤ 1 := + (latticeSample_error hSp x).trans ((div_le_one hSp).mpr hS) + have ht : |x| ≤ |latticeSample a S x| + |latticeSample a S x - x| := by + have h := abs_sub_le x (latticeSample a S x) 0 + simpa only [sub_zero, abs_sub_comm x (latticeSample a S x), add_comm] using h + rw [sampledWeightHistogram_eq ψ hSp hsupport] + exact hsupport _ (by linarith) + +theorem sampledWeightHistogram_l1_error (ψ : ℝ → ℝ) {L : ℝ≥0} (hLip : LipschitzWith L ψ) + {a S R : ℝ} (hR : 0 ≤ R) (hS : 1 ≤ S) (hsupport : ∀ x, R < |x| → ψ x = 0) : + (∫ x, ‖sampledWeightHistogram ψ a S R x - ψ x‖) ≤ (2 * R + 2) * (L : ℝ) / S := by + have hz : ∀ x, x ∉ Set.Icc (-(R + 1)) (R + 1) → + sampledWeightHistogram ψ a S R x - ψ x = 0 := by + intro x hx + have hx' : R + 1 < |x| := lt_of_not_ge (fun h => hx (abs_le.mp h)) + rw [sampledWeightHistogram_zero_outside ψ hS hsupport x hx', hsupport x (by linarith), sub_self] + have he := integral_norm_le_interval (fun x => sampledWeightHistogram ψ a S R x - ψ x) + (u := -(R + 1)) (v := R + 1) (C := (L : ℝ) / S) (by linarith) + hz (fun x _ => sampledWeightHistogram_error ψ hLip + (lt_of_lt_of_le zero_lt_one hS) hsupport x) + exact he.trans_eq (by ring) + +theorem sampledWeightSum_error (ψ : ℝ → ℝ) {L : ℝ≥0} (hLip : LipschitzWith L ψ) + {a S R : ℝ} (hR : 0 ≤ R) (hS : 1 ≤ S) (hsupport : ∀ x, R < |x| → ψ x = 0) : + |sampledWeightSum ψ a S R / S - ∫ x, ψ x| ≤ (2 * R + 2) * (L : ℝ) / S := by + rw [← sampledWeightHistogram_integral ψ a (lt_of_lt_of_le zero_lt_one hS) R, + ← integral_sub (sampledWeightHistogram_integrable ψ a S R) + (compactInterval_integrable ψ hLip.continuous R hsupport)] + exact (norm_integral_le_integral_norm _).trans + (sampledWeightHistogram_l1_error ψ hLip hR hS hsupport) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ComparableResidueLocalization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ComparableResidueLocalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e60d2c8e2bc642c709ed05fe59f9fc23b38fc0d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ComparableResidueLocalization.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.Progressions.Geometry.PhysicalBoxPartition + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_comparable_residue_piece {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (N H : I → ℕ) (hH : ∀ i, 0 < H i) (hHN : ∀ i, H i ≤ N i) + (r s v w : I → ℤ) (hr : ∀ i, 0 < r i) (hs : ∀ i, 0 < s i) + {ε : ℝ} (hε : ε < 1 / 2) + (hsmallR : (∑ i, (r i : ℝ) / (H i : ℝ)) ≤ ε) + (hsmallS : (∑ i, (s i : ℝ) / (H i : ℝ)) ≤ ε) + (f : IntegerResidueBox a (fun i => a i + N i) r v → ℂ) + (g : IntegerResidueBox a (fun i => a i + N i) s w → ℂ) + (hg : ∀ x, ‖g x‖ ≤ 1) : + let P := comparableBoxPartitions N H hH hHN + ∃ k : (∀ i, (P i).Label), + 0 < (partitionCell (boxIntervalResidueCell a N P r v) k).card ∧ + 0 < (partitionCell (boxIntervalResidueCell a N P s w) k).card ∧ + ‖(𝔼 x, f x) - (𝔼 x, g x)‖ - 8 * ε ≤ + ‖(𝔼 x ∈ partitionCell (boxIntervalResidueCell a N P r v) k, f x) - + (𝔼 x ∈ partitionCell (boxIntervalResidueCell a N P s w) k, g x)‖ := by + intro P + let := comparableBoxPartitions_nonempty N H hH hHN + have hstep : ∀ i k, (P i).step k = 1 := comparableBoxPartitions_step N H hH hHN + have hpos : ∀ i k, 0 < (P i).length k := fun i k => + (hH i).trans_le (comparableBoxPartitions_length N H hH hHN i k).1 + let lo : (∀ i, (P i).Label) → I → ℤ := fun k i => intervalCellLower (a i) (P i) (k i) + let hi : (∀ i, (P i).Label) → I → ℤ := fun k i => intervalCellUpper (a i) (P i) (k i) + have hbox : ∀ k i, lo k i < hi k i := by + intro k i + apply sub_pos.mp + change 0 < intervalCellUpper (a i) (P i) (k i) - intervalCellLower (a i) (P i) (k i) + rw [intervalCell_width] + exact_mod_cast hpos i (k i) + have hR : ∀ k, (∑ i, (r i : ℝ) / ((hi k i - lo k i : ℤ) : ℝ)) ≤ ε := + fun k => (comparableBoxPartitions_ratio_le a N H hH hHN r (fun i => (hr i).le) k).trans hsmallR + have hS : ∀ k, (∑ i, (s i : ℝ) / ((hi k i - lo k i : ℤ) : ℝ)) ≤ ε := + fun k => (comparableBoxPartitions_ratio_le a N H hH hHN s (fun i => (hs i).le) k).trans hsmallS + let F : (∀ i, (P i).Label) → ℂ := fun k => + 𝔼 x ∈ partitionCell (boxIntervalResidueCell a N P r v) k, f x + let G : (∀ i, (P i).Label) → ℂ := fun k => + 𝔼 x ∈ partitionCell (boxIntervalResidueCell a N P s w) k, g x + have hG : ∀ k, ‖G k‖ ≤ 1 := by + intro k + let S := partitionCell (boxIntervalResidueCell a N P s w) k + change ‖𝔼 x ∈ S, g x‖ ≤ 1 + by_cases hS : S.Nonempty + · apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun x _ => hg x)).trans_eq (Finset.expect_const hS 1) + · have he := Finset.not_nonempty_iff_eq_empty.mp hS + simp only [he, Finset.expect_empty, norm_zero, zero_le_one] + obtain ⟨k, hkr, hks, hgap⟩ := exists_rectangular_residue_piece_discrepancy + lo hi r s (fun _ => v) (fun _ => w) hbox hr hs hε hR hS F G hG + have hmR := boxIntervalResidue_mixture a N P hstep hpos r v f + have hmS := boxIntervalResidue_mixture a N P hstep hpos s w g + simp only [div_mul_eq_mul_div, ← Finset.sum_div] at hmR hmS + rw [← hmR, ← hmS] at hgap + refine ⟨k, ?_, ?_, hgap⟩ + · rw [boxIntervalResidueCell_card a N P hstep hpos r v] + exact Nat.cast_pos.mp hkr + · rw [boxIntervalResidueCell_card a N P hstep hpos s w] + exact Nat.cast_pos.mp hks + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ComparableResidueProgressionPartition.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ComparableResidueProgressionPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..77ea6434a20d8e02e2c34ab6d40e5ad62ef6baa1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ComparableResidueProgressionPartition.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.Progressions.Estimates.ProgressionPartitionComposition + +namespace OAI + +section + +namespace Erdos3.FiniteProgressionPartition + +noncomputable def residues (N q : ℕ) (hq : 0 < q) : + FiniteProgressionPartition N := by + let len : Fin q → ℕ := fun r => truncatedProgressionLength N r.val q N + let f : (Σ r : Fin q, Fin (len r)) → Fin N := fun x => + ⟨x.1.val + q * x.2.val, ((lt_truncatedProgressionLength_iff hq).mp x.2.isLt).2⟩ + have hf : Function.Bijective f := by + constructor + · rintro ⟨r, j⟩ ⟨s, k⟩ heq + have he : r.val + q * j.val = s.val + q * k.val := congrArg Fin.val heq + have hrs : r = s := by + apply Fin.ext + have hm := congrArg (fun n => n % q) he + simpa only [Nat.add_mul_mod_self_left, Nat.mod_eq_of_lt r.isLt, + Nat.mod_eq_of_lt s.isLt] using hm + cases hrs + have hjk : j = k := Fin.ext (mul_left_cancel₀ hq.ne' (Nat.add_left_cancel he)) + cases hjk + rfl + · intro n + let r : Fin q := ⟨n.val % q, Nat.mod_lt _ hq⟩ + have hj : n.val / q < len r := by + apply (lt_truncatedProgressionLength_iff hq).mpr + exact ⟨lt_of_le_of_lt (Nat.div_le_self _ _) n.isLt, + by simpa only [r, Nat.mod_add_div] using n.isLt⟩ + exact ⟨⟨r, ⟨n.val / q, hj⟩⟩, Fin.ext (Nat.mod_add_div _ _)⟩ + exact { + Label := Fin q + labelFintype := inferInstance + start := fun r => r.val + step := fun _ => q + length := len + step_pos := fun _ => hq + equiv := Equiv.ofBijective f hf + equiv_val := fun _ _ => rfl } + +@[simp] theorem residues_start (N q : ℕ) (hq : 0 < q) + (r : (residues N q hq).Label) : (residues N q hq).start r = r.val := rfl + +@[simp] theorem residues_step (N q : ℕ) (hq : 0 < q) + (r : (residues N q hq).Label) : (residues N q hq).step r = q := rfl + +theorem residues_length_lower {N q H : ℕ} (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) (r : (residues N q hq).Label) : + H ≤ (residues N q hq).length r := by + have hHN : H ≤ N := le_trans (Nat.le_mul_of_pos_left H hq) hfit + have hpoint : r.val + q * (H - 1) < N := by + have heq : q * (H - 1) + q = q * H := by + rw [← Nat.mul_succ] + congr 1 + omega + have hlt := Nat.add_lt_add_right r.isLt (q * (H - 1)) + omega + have hj : H - 1 < (residues N q hq).length r := + (lt_truncatedProgressionLength_iff hq).mpr ⟨by omega, hpoint⟩ + omega + +noncomputable def comparableResidueProgressions (N q H : ℕ) (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) : FiniteProgressionPartition N := + (residues N q hq).bind (fun r => + mergedIntervals ((residues N q hq).length r) H hH + (residues_length_lower hq hH hfit r)) + +@[simp] theorem comparableResidueProgressions_step (N q H : ℕ) (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) (i : (comparableResidueProgressions N q H hq hH hfit).Label) : + (comparableResidueProgressions N q H hq hH hfit).step i = q := by + rcases i with ⟨r, j⟩ + simp [comparableResidueProgressions] + +theorem comparableResidueProgressions_length_bounds (N q H : ℕ) (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) (i : (comparableResidueProgressions N q H hq hH hfit).Label) : + H ≤ (comparableResidueProgressions N q H hq hH hfit).length i ∧ + (comparableResidueProgressions N q H hq hH hfit).length i < 2 * H := + mergedIntervals_length_bounds _ H hH (residues_length_lower hq hH hfit i.1) i.2 + +theorem exists_comparable_residue_partition (N q H : ℕ) (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) : + ∃ P : FiniteProgressionPartition N, + (∀ i, P.step i = q) ∧ (∀ i, H ≤ P.length i ∧ P.length i < 2 * H) := + ⟨comparableResidueProgressions N q H hq hH hfit, + comparableResidueProgressions_step N q H hq hH hfit, + comparableResidueProgressions_length_bounds N q H hq hH hfit⟩ + +end Erdos3.FiniteProgressionPartition + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ComparableScalarPrimeParameters.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ComparableScalarPrimeParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e58d22e05d13e023fd101ae5b5bc103dfca2abf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ComparableScalarPrimeParameters.lean @@ -0,0 +1,96 @@ +import Mathlib.NumberTheory.Bertrand +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 +open scoped Classical + +theorem exists_distinct_primes_dyadic (n t : ℕ) (ht : 0 < t) : + ∃ N : Fin n → ℕ, StrictMono N ∧ + ∀ i, (N i).Prime ∧ 2 ^ i.val * t < N i ∧ N i ≤ 2 ^ (i.val + 1) * t := by + have hp (i : Fin n) : ∃ p : ℕ, p.Prime ∧ + 2 ^ i.val * t < p ∧ p ≤ 2 ^ (i.val + 1) * t := by + obtain ⟨p, hprime, hlo, hhi⟩ := Nat.exists_prime_lt_and_le_two_mul + (2 ^ i.val * t) (by positivity) + refine ⟨p, hprime, hlo, ?_⟩ + simpa only [pow_succ, Nat.mul_assoc, Nat.mul_left_comm, Nat.mul_comm] using hhi + choose N hN using hp + refine ⟨N, ?_, hN⟩ + intro i j hij + have he : i.val + 1 ≤ j.val := by exact hij + exact ((hN i).2.2.trans (Nat.mul_le_mul_right t + (Nat.pow_le_pow_right (by norm_num : 0 < 2) he))).trans_lt (hN j).2.1 + +theorem exists_distinct_comparable_prime_sides (n L : ℕ) (hL : 0 < L) + (hdiv : 2 ^ (n + 1) ∣ L) : + ∃ N : Fin n → ℕ, (∀ i, (N i).Prime) ∧ Function.Injective N ∧ + ∀ i, (L : ℝ) / (2 : ℝ) ^ (n + 1) < (N i : ℝ) ∧ N i ≤ L := by + let t := L / 2 ^ (n + 1) + have ht : 0 < t := Nat.div_pos (Nat.le_of_dvd hL hdiv) (by positivity) + have hprod : 2 ^ (n + 1) * t = L := Nat.mul_div_cancel' hdiv + obtain ⟨N, hmono, hN⟩ := exists_distinct_primes_dyadic n t ht + have htR : (L : ℝ) / (2 : ℝ) ^ (n + 1) = (t : ℝ) := by + apply (div_eq_iff (by positivity : (2 : ℝ) ^ (n + 1) ≠ 0)).mpr + have hh : (2 : ℝ) ^ (n + 1) * t = L := by exact_mod_cast hprod + linarith + refine ⟨N, fun i => (hN i).1, hmono.injective, ?_⟩ + intro i + constructor + · rw [htR] + exact_mod_cast (show t < N i from + (Nat.le_mul_of_pos_left t (by positivity : 0 < 2 ^ i.val)).trans_lt (hN i).2.1) + · exact ((hN i).2.2.trans (Nat.mul_le_mul_right t + (Nat.pow_le_pow_right (by norm_num : 0 < 2) (by omega : i.val + 1 ≤ n + 1)))).trans_eq hprod + +theorem exists_distinct_comparable_prime_sides_above (n L : ℕ) (hL : 0 < L) + (hdiv : 2 ^ (n + 1) ∣ L) (cutoff : ℝ) + (hcutoff : cutoff ≤ (L : ℝ) / (2 : ℝ) ^ (n + 1)) : + ∃ N : Fin n → ℕ, (∀ i, (N i).Prime) ∧ Function.Injective N ∧ + ∀ i, cutoff < (N i : ℝ) ∧ (L : ℝ) / (2 : ℝ) ^ (n + 1) < (N i : ℝ) ∧ N i ≤ L := by + obtain ⟨N, hp, hi, hN⟩ := exists_distinct_comparable_prime_sides n L hL hdiv + exact ⟨N, hp, hi, fun i => ⟨hcutoff.trans_lt (hN i).1, hN i⟩⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped Classical + +theorem exists_comparableScalarPrimeParameters (d : ℕ) {L : ℝ} (hL : 1 ≤ L) : + ∃ parameters : Fin d → ℕ, (∀ j, (parameters j).Prime) ∧ + Function.Injective parameters ∧ + (∀ j, L ≤ (parameters j : ℝ)) ∧ + ∀ j, (parameters j : ℝ) ≤ (2 : ℝ) ^ (d + 1) * L := by + have hLp : 0 < L := lt_of_lt_of_le zero_lt_one hL + have hceil : L ≤ (⌈L⌉₊ : ℝ) := Nat.le_ceil _ + have hceilp : 0 < ⌈L⌉₊ := by exact_mod_cast hLp.trans_le hceil + have hceilupper : (⌈L⌉₊ : ℝ) ≤ 2 * L := by + have h := Nat.ceil_lt_add_one hLp.le + linarith + obtain ⟨parameters, hmono, hparam⟩ := exists_distinct_primes_dyadic d ⌈L⌉₊ hceilp + refine ⟨parameters, fun j => (hparam j).1, hmono.injective, ?_, ?_⟩ + · intro j + have hlower : ⌈L⌉₊ ≤ parameters j := + (Nat.le_mul_of_pos_left _ (by positivity : 0 < 2 ^ j.val)).trans (hparam j).2.1.le + exact hceil.trans (by exact_mod_cast hlower) + · intro j + have hupper : parameters j ≤ 2 ^ d * ⌈L⌉₊ := + (hparam j).2.2.trans (Nat.mul_le_mul_right _ + (Nat.pow_le_pow_right (by norm_num : 0 < 2) (by omega : j.val + 1 ≤ d))) + calc + (parameters j : ℝ) ≤ (2 : ℝ) ^ d * (⌈L⌉₊ : ℝ) := by exact_mod_cast hupper + _ ≤ (2 : ℝ) ^ d * (2 * L) := + mul_le_mul_of_nonneg_left hceilupper (by positivity) + _ = (2 : ℝ) ^ (d + 1) * L := by rw [pow_succ]; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ComparisonLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ComparisonLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1617da0067f1f914eaf524b41589820c55ce30d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ComparisonLattice.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.Progressions.Estimates.ComparisonAmbient + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +variable {σ : Type} {L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) + +noncomputable def comparisonLattice (p : ℝ) (B : ℕ) (hB : 0 < B) + (hstable : M.SquarefreeGridStable p B) : Subgroup + (M.filtration.comparisonFiltration (fun i : ReplicatedIndex bound => i.1)).Group := + (M.comparisonAmbient p B hB hstable).lattice.comap + (NilpotentLieBCHGroup.mapOfSteps M.comparisonToAmbient) + +theorem comparisonLattice_first (p : ℝ) (B : ℕ) (hB : 0 < B) + (hstable : M.SquarefreeGridStable p B) : + M.comparisonLattice p B hB hstable ≤ D.lattice.comap + (NilpotentLieBCHGroup.mapOfSteps + (M.filtration.comparisonFirst (fun i : ReplicatedIndex bound => i.1))) := by + intro g hg + have hg' : NilpotentLieBCHGroup.mapOfSteps M.comparisonToAmbient g ∈ + (M.comparisonAmbient p B hB hstable).lattice := hg + have h := (mem_piBCHSubgroup _ _ _).mp hg' none + exact D.raiseStep_lattice_back (Nat.le_max_left s (Fintype.card (ReplicatedIndex bound))) h + +theorem comparisonLattice_second (p : ℝ) (B : ℕ) (hB : 0 < B) + (hstable : M.SquarefreeGridStable p B) : + M.comparisonLattice p B hB hstable ≤ (M.squarefreeModel p B hB hstable).lattice.comap + (NilpotentLieBCHGroup.mapOfSteps + (M.filtration.comparisonSecond (fun i : ReplicatedIndex bound => i.1))) := by + intro g hg + have hg' : NilpotentLieBCHGroup.mapOfSteps M.comparisonToAmbient g ∈ + (M.comparisonAmbient p B hB hstable).lattice := hg + have h := (mem_piBCHSubgroup _ _ _).mp hg' (some PUnit.unit) + exact (M.squarefreeModel p B hB hstable).raiseStep_lattice_back + (Nat.le_max_right s (Fintype.card (ReplicatedIndex bound))) h + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ConcreteAffineMeshBoundary.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ConcreteAffineMeshBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fcb818ccdebc913c50e56af3c340ce7f1a45900 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ConcreteAffineMeshBoundary.lean @@ -0,0 +1,501 @@ +import OAI.Combinatorics.Progressions.Dynamics.PhysicalBoundaryBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {I : Type*} [Fintype I] [DecidableEq I] + +noncomputable def integerBoxMeshPoint (lo hi : I → ℤ) (z : ∀ i, Finset.Ico (lo i) (hi i)) : + translatedIntegerBox lo (fun i => (hi i - lo i).toNat) := by + refine ⟨fun i => (z i : ℤ), (mem_translatedIntegerBox _ _ _).mpr ?_⟩ + intro i + have h := Finset.mem_Ico.mp (z i).property + constructor + · exact h.1 + · omega + +noncomputable def integerBoxMesh (lo hi : I → ℤ) + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (z : ∀ i, Finset.Ico (lo i) (hi i)) : ∀ i, (P i).Label := + physicalBoxCell lo (fun i => (hi i - lo i).toNat) P (integerBoxMeshPoint lo hi z) + +theorem integerBoxMesh_distance (lo hi : I → ℤ) + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hstep : ∀ i c, (P i).step c = 1) + (z w : ∀ i, Finset.Ico (lo i) (hi i)) + (hsame : integerBoxMesh lo hi P w = integerBoxMesh lo hi P z) (i : I) : + |(z i : ℤ) - (w i : ℤ)| ≤ ((P i).length (integerBoxMesh lo hi P z i) : ℤ) := by + have hz := (physicalBoxCell_eq_iff lo (fun i => (hi i - lo i).toNat) P hstep + (integerBoxMeshPoint lo hi z) (integerBoxMesh lo hi P z)).mp rfl i + have hw := (physicalBoxCell_eq_iff lo (fun i => (hi i - lo i).toNat) P hstep + (integerBoxMeshPoint lo hi w) (integerBoxMesh lo hi P z)).mp hsame i + change intervalCellLower (lo i) (P i) (integerBoxMesh lo hi P z i) ≤ (z i : ℤ) ∧ + (z i : ℤ) < intervalCellUpper (lo i) (P i) (integerBoxMesh lo hi P z i) at hz + change intervalCellLower (lo i) (P i) (integerBoxMesh lo hi P z i) ≤ (w i : ℤ) ∧ + (w i : ℤ) < intervalCellUpper (lo i) (P i) (integerBoxMesh lo hi P z i) at hw + dsimp only [intervalCellUpper, intervalCellLower] at hz hw + exact abs_le.mpr ⟨by omega, by omega⟩ + +theorem normalized_integerBoxMesh_distance (lo hi : I → ℤ) (H : I → ℝ) (delta : ℝ) + (hlarge : ∀ i, 4 ≤ delta * H i) + (hwhole : ∀ i, delta * H i ≤ 2 * ((hi i - lo i).toNat : ℝ)) + (z w : ∀ i, Finset.Ico (lo i) (hi i)) + (hsame : integerBoxMesh lo hi (normalizedBoxPartitions (fun i => (hi i - lo i).toNat) H delta hlarge hwhole) w = + integerBoxMesh lo hi (normalizedBoxPartitions (fun i => (hi i - lo i).toNat) H delta hlarge hwhole) z) + (i : I) : |((z i : ℤ) : ℝ) - ((w i : ℤ) : ℝ)| ≤ delta * H i := by + let P := normalizedBoxPartitions (fun i => (hi i - lo i).toNat) H delta hlarge hwhole + have h := integerBoxMesh_distance lo hi P (normalizedBoxPartitions_step _ _ _ _ _) z w hsame i + have hreal : |((z i : ℤ) : ℝ) - ((w i : ℤ) : ℝ)| ≤ + ((P i).length (integerBoxMesh lo hi P z i) : ℝ) := by exact_mod_cast h + exact hreal.trans (normalizedBoxPartitions_lengths _ _ _ _ _ i (integerBoxMesh lo hi P z i)).2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {I : Type*} [Fintype I] [DecidableEq I] + +noncomputable def integerBoxMeshPointEquiv (lo hi : I → ℤ) : + (∀ i, Finset.Ico (lo i) (hi i)) ≃ translatedIntegerBox lo (fun i => (hi i - lo i).toNat) where + toFun := integerBoxMeshPoint lo hi + invFun x i := ⟨x.val i, by + have h := (mem_translatedIntegerBox _ _ _).mp x.property i + exact Finset.mem_Ico.mpr ⟨h.1, by omega⟩⟩ + left_inv _ := rfl + right_inv _ := rfl + +noncomputable def integerBoxMeshCellEquiv (lo hi : I → ℤ) + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (c : ∀ i, (P i).Label) : + {z : (∀ i, Finset.Ico (lo i) (hi i)) // integerBoxMesh lo hi P z = c} ≃ + IntegerResidueBox (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => intervalCellLower (lo i) (P i) (c i) + (P i).length (c i)) + (fun _ => 1) (fun _ => 0) := by + let e : {z : (∀ i, Finset.Ico (lo i) (hi i)) // integerBoxMesh lo hi P z = c} ≃ + {x : translatedIntegerBox lo (fun i => (hi i - lo i).toNat) // + physicalBoxCell lo (fun i => (hi i - lo i).toNat) P x = c} := + (integerBoxMeshPointEquiv lo hi).subtypeEquiv (fun _ => Iff.rfl) + exact e.trans (physicalBoxCellEquiv lo (fun i => (hi i - lo i).toNat) P hstep hpos c) + +theorem integerBoxMeshCellEquiv_val (lo hi : I → ℤ) + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (c : ∀ i, (P i).Label) + (z : {z : (∀ i, Finset.Ico (lo i) (hi i)) // integerBoxMesh lo hi P z = c}) (i : I) : + (integerBoxMeshCellEquiv lo hi P hstep hpos c z i).val = (z.val i).val := rfl + +theorem integerBoxMesh_cell_mean (lo hi : I → ℤ) [Nonempty (∀ i, Finset.Ico (lo i) (hi i))] + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (c : ∀ i, (P i).Label) (f : (I → ℤ) → ℝ) : + finiteCellMean (FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (lo i) (hi i))) + (integerBoxMesh lo hi P) (fun z => f (fun i => (z i).val)) c = + (finiteCellWeights (FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (lo i) (hi i))) + (integerBoxMesh lo hi P)).weight c * + (𝔼 z : IntegerResidueBox (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => intervalCellLower (lo i) (P i) (c i) + (P i).length (c i)) + (fun _ => 1) (fun _ => 0), f (fun i => (z i).val)) := by + rw [finiteCellMean_uniform_weighted] + congr 1 + exact Fintype.expect_equiv (integerBoxMeshCellEquiv lo hi P hstep hpos c) + (fun z => f (fun i => (z.val i).val)) (fun z => f (fun i => (z i).val)) (fun _ => rfl) + +theorem integerBoxMesh_mean_partition (lo hi : I → ℤ) + [Nonempty (∀ i, Finset.Ico (lo i) (hi i))] + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (f : (I → ℤ) → ℝ) : + (𝔼 z : (∀ i, Finset.Ico (lo i) (hi i)), f (fun i => (z i).val)) = + ∑ c, (finiteCellWeights (FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (lo i) (hi i))) + (integerBoxMesh lo hi P)).weight c * + (𝔼 z : IntegerResidueBox (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => intervalCellLower (lo i) (P i) (c i) + (P i).length (c i)) + (fun _ => 1) (fun _ => 0), f (fun i => (z i).val)) := by + rw [← FiniteProbabilityWeights.uniform_mean] + rw [← finiteCellMean_sum _ (integerBoxMesh lo hi P)] + exact Finset.sum_congr rfl (fun c _ => integerBoxMesh_cell_mean lo hi P hstep hpos c f) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerWindow_cell_endpoints {a b : ℤ} (hab : a < b) + (P : FiniteProgressionPartition (b - a).toNat) + (hstep : ∀ c, P.step c = 1) (c : P.Label) (hpos : 0 < P.length c) : + a ≤ intervalCellLower a P c ∧ + intervalCellLower a P c + P.length c ≤ b ∧ + intervalCellLower a P c < intervalCellLower a P c + P.length c := by + have hend := P.end_le_of_step_one hstep c hpos + have hcount : ((b - a).toNat : ℤ) = b - a := Int.toNat_of_nonneg (by omega) + have hend' : (P.start c : ℤ) + P.length c ≤ (b - a).toNat := by exact_mod_cast hend + have hstart : (0 : ℤ) ≤ P.start c := Int.natCast_nonneg _ + have hlength : (0 : ℤ) < P.length c := by exact_mod_cast hpos + dsimp only [intervalCellLower] + omega + +theorem integerWindow_cell_endpoint_abs {a b : ℤ} {B : ℝ} (hab : a < b) + (ha : |(a : ℝ)| ≤ B) (hb : |(b : ℝ)| ≤ B) + (P : FiniteProgressionPartition (b - a).toNat) + (hstep : ∀ c, P.step c = 1) (c : P.Label) (hpos : 0 < P.length c) : + |(intervalCellLower a P c : ℝ)| ≤ B ∧ + |((intervalCellLower a P c + P.length c : ℤ) : ℝ)| ≤ B := by + obtain ⟨hleft, hright, hlt⟩ := integerWindow_cell_endpoints hab P hstep c hpos + have hleft' : (a : ℝ) ≤ intervalCellLower a P c := by exact_mod_cast hleft + have hright' : ((intervalCellLower a P c + P.length c : ℤ) : ℝ) ≤ b := by exact_mod_cast hright + have hle : (intervalCellLower a P c : ℝ) ≤ ((intervalCellLower a P c + P.length c : ℤ) : ℝ) := by exact_mod_cast hlt.le + have ha' := abs_le.mp ha + have hb' := abs_le.mp hb + exact ⟨abs_le.mpr ⟨by linarith, by linarith⟩, abs_le.mpr ⟨by linarith, by linarith⟩⟩ + +theorem integerWindow_cell_half_scale {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (S : I → ℝ) (c : ∀ i, (P i).Label) + (hlength : ∀ i, ((P i).length (c i) : ℝ) ≤ S i / 2) : + ∀ z ∈ Fintype.piFinset (fun i => Finset.Ico (intervalCellLower (lo i) (P i) (c i)) + (intervalCellLower (lo i) (P i) (c i) + (P i).length (c i))), ∀ i, + |(z i : ℝ) - (intervalCellLower (lo i) (P i) (c i) : ℝ)| ≤ S i / 2 := by + intro z hz i + have hz' := Finset.mem_Ico.mp ((Fintype.mem_piFinset.mp hz) i) + have hleft : (intervalCellLower (lo i) (P i) (c i) : ℝ) ≤ z i := by exact_mod_cast hz'.1 + have hright : (z i : ℝ) < intervalCellLower (lo i) (P i) (c i) + ((P i).length (c i) : ℝ) := by exact_mod_cast hz'.2 + rw [abs_of_nonneg (sub_nonneg.mpr hleft)] + linarith [hlength i] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +theorem affineIntegerInterval_endpoint_abs (D : ℕ) (anchor a b : ℤ) (hab : a < b) + {F : ℝ} (hD : (D : ℝ) ≤ F) + (hpoint : ∀ t ∈ Finset.Ico a b, |((anchor + (D : ℤ) * t : ℤ) : ℝ)| ≤ F) : + |((anchor + (D : ℤ) * a : ℤ) : ℝ)| ≤ F ∧ + |((anchor + (D : ℤ) * b : ℤ) : ℝ)| ≤ 2 * F := by + refine ⟨hpoint a (Finset.mem_Ico.mpr ⟨le_rfl, hab⟩), ?_⟩ + have hlast := hpoint (b - 1) (Finset.mem_Ico.mpr ⟨by omega, by omega⟩) + have heq : ((anchor + (D : ℤ) * b : ℤ) : ℝ) = + ((anchor + (D : ℤ) * (b - 1) : ℤ) : ℝ) + D := by push_cast; ring + rw [heq] + have htriangle := abs_add_le (((anchor + (D : ℤ) * (b - 1) : ℤ) : ℝ)) (D : ℝ) + rw [abs_of_nonneg (show (0 : ℝ) ≤ (D : ℝ) from Nat.cast_nonneg D)] at htriangle + linarith + +theorem affineIntegerInterval_width_le (D : ℕ) (hD : 0 < D) (anchor a b : ℤ) (hab : a < b) + {F : ℝ} (ha : |((anchor + (D : ℤ) * a : ℤ) : ℝ)| ≤ F) + (hb : |((anchor + (D : ℤ) * b : ℤ) : ℝ)| ≤ F) : + ((b - a : ℤ) : ℝ) ≤ 2 * F := by + have hD1 : (1 : ℝ) ≤ D := by exact_mod_cast hD + have hwidth : (0 : ℝ) ≤ ((b - a : ℤ) : ℝ) := by exact_mod_cast (sub_nonneg.mpr hab.le) + have ha' := (abs_le.mp ha).1 + have hb' := (abs_le.mp hb).2 + push_cast at ha' hb' hwidth ⊢ + nlinarith + +theorem exists_integerBox_width_bound {J : Type*} [Fintype J] + (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) {R : ℝ} (hR : 0 ≤ R) + (hwidth : ∀ j, ((hi j - lo j : ℤ) : ℝ) ≤ R) : + ∃ M : ℕ, (∀ j, hi j - lo j ≤ (M : ℤ)) ∧ (M : ℝ) ≤ R := by + let M := Finset.univ.sup (fun j => (hi j - lo j).toNat) + have hcast j : (((hi j - lo j).toNat : ℕ) : ℝ) = ((hi j - lo j : ℤ) : ℝ) := by + exact_mod_cast Int.toNat_of_nonneg (sub_nonneg.mpr (hlen j).le) + refine ⟨M, ?_, ?_⟩ + · intro j + have hle : (hi j - lo j).toNat ≤ M := Finset.le_sup (f := fun j => (hi j - lo j).toNat) (Finset.mem_univ j) + have hc := Int.toNat_of_nonneg (sub_nonneg.mpr (hlen j).le) + omega + · have hle : M ≤ ⌊R⌋₊ := Finset.sup_le (fun j _ => (Nat.le_floor_iff hR).mpr (by rw [hcast]; exact hwidth j)) + exact (Nat.cast_le.mpr hle).trans (Nat.floor_le hR) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerBoxUniformWeights_eq_uniform {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) [Nonempty (∀ i, Finset.Ico (lo i) (hi i))] : + integerBoxUniformWeights lo hi hlen = FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (lo i) (hi i)) := by + apply FiniteProbabilityWeights.eq_of_weight_eq + intro x + change (∏ i, (Fintype.card (Finset.Ico (lo i) (hi i)) : ℝ)⁻¹) = + (Fintype.card (∀ i, Finset.Ico (lo i) (hi i)) : ℝ)⁻¹ + rw [Fintype.card_pi, Nat.cast_prod, Finset.prod_inv_distrib] + +theorem integerBoxMesh_pair_cell_mean {I J : Type*} [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] + (lo hi : I → ℤ) [Nonempty (∀ i, Finset.Ico (lo i) (hi i))] + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hPstep : ∀ i c, (P i).step c = 1) (hPpos : ∀ i c, 0 < (P i).length c) + (tlo thi : J → ℤ) [Nonempty (∀ j, Finset.Ico (tlo j) (thi j))] + (T : ∀ j, FiniteProgressionPartition (thi j - tlo j).toNat) + (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c) + (c : ∀ i, (P i).Label) (d : ∀ j, (T j).Label) (f : (I → ℤ) → (J → ℤ) → ℝ) : + finiteCellMean ((FiniteProbabilityWeights.uniform (∀ j, Finset.Ico (tlo j) (thi j))).prod + (FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (lo i) (hi i)))) + (fun tx => (integerBoxMesh lo hi P tx.2, integerBoxMesh tlo thi T tx.1)) + (fun tx => f (fun i => (tx.2 i).val) (fun j => (tx.1 j).val)) (c,d) = + (finiteCellWeights (FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (lo i) (hi i))) + (integerBoxMesh lo hi P)).weight c * + (finiteCellWeights (FiniteProbabilityWeights.uniform (∀ j, Finset.Ico (tlo j) (thi j))) + (integerBoxMesh tlo thi T)).weight d * + (𝔼 z : IntegerResidueBox (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => intervalCellLower (lo i) (P i) (c i) + (P i).length (c i)) (fun _ => 1) (fun _ => 0), + 𝔼 t : IntegerResidueBox (fun j => intervalCellLower (tlo j) (T j) (d j)) + (fun j => intervalCellLower (tlo j) (T j) (d j) + (T j).length (d j)) (fun _ => 1) (fun _ => 0), + f (fun i => (z i).val) (fun j => (t j).val)) := by + rw [finiteCellMean_product_uniform (integerBoxMesh lo hi P) (integerBoxMesh tlo thi T) + (fun z t => f (fun i => (z i).val) (fun j => (t j).val)) c d] + congr 1 + apply Fintype.expect_equiv (integerBoxMeshCellEquiv lo hi P hPstep hPpos c) _ _ + intro z + exact Fintype.expect_equiv (integerBoxMeshCellEquiv tlo thi T hTstep hTpos d) _ _ (fun _ => rfl) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerUnitResidue_expect_eq {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (f : (I → ℤ) → ℝ) : + (𝔼 z : IntegerResidueBox lo hi (fun _ => 1) (fun _ => 0), f (fun i => (z i).val)) = + 𝔼 z : (∀ i, Finset.Ico (lo i) (hi i)), f (fun i => (z i).val) := by + let e : IntegerResidueBox lo hi (fun _ => 1) (fun _ => 0) ≃ + (∀ i, Finset.Ico (lo i) (hi i)) := { + toFun := fun x i => ⟨(x i).val, (Finset.mem_filter.mp (x i).property).1⟩ + invFun := fun x i => ⟨(x i).val, Finset.mem_filter.mpr ⟨(x i).property, Int.modEq_one⟩⟩ + left_inv := fun _ => rfl + right_inv := fun _ => rfl } + exact Fintype.expect_equiv e _ _ (fun _ => rfl) + +theorem integerBox_partition_eventProbability_le {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) + (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (E : (I → ℤ) → Prop) (bound : ℝ) + (hcell : ∀ c : ∀ i, (P i).Label, + (integerBoxUniformWeights (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => intervalCellLower (lo i) (P i) (c i) + (P i).length (c i)) + (fun i => lt_add_of_pos_right _ (by exact_mod_cast hpos i (c i)))).eventProbability + (fun z => E (fun i => (z i).val)) ≤ bound) : + (integerBoxUniformWeights lo hi hlen).eventProbability + (fun z => E (fun i => (z i).val)) ≤ bound := by + let : ∀ i, Nonempty (Finset.Ico (lo i) (hi i)) := + fun i => ⟨⟨lo i, Finset.mem_Ico.mpr ⟨le_rfl, hlen i⟩⟩⟩ + let weights := finiteCellWeights (FiniteProbabilityWeights.uniform (∀ i, Finset.Ico (lo i) (hi i))) + (integerBoxMesh lo hi P) + have hcell' (c : ∀ i, (P i).Label) : + (𝔼 z : IntegerResidueBox (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => intervalCellLower (lo i) (P i) (c i) + (P i).length (c i)) + (fun _ => 1) (fun _ => 0), if E (fun i => (z i).val) then (1 : ℝ) else 0) ≤ bound := by + have he := integerUnitResidue_expect_eq + (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => intervalCellLower (lo i) (P i) (c i) + (P i).length (c i)) + (fun z => if E z then (1 : ℝ) else 0) + apply he.trans_le + simpa only [FiniteProbabilityWeights.eventProbability, integerBoxUniformWeights_mean] using hcell c + rw [FiniteProbabilityWeights.eventProbability, integerBoxUniformWeights_mean, + integerBoxMesh_mean_partition lo hi P hstep hpos (fun z => if E z then (1 : ℝ) else 0)] + calc + _ ≤ ∑ c, weights.weight c * bound := Finset.sum_le_sum + (fun c _ => mul_le_mul_of_nonneg_left (hcell' c) (weights.nonneg c)) + _ = bound := by rw [← Finset.sum_mul, weights.total, one_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerBoxMesh_cell_realize {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (P : ∀ i, FiniteProgressionPartition (hi i - lo i).toNat) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (c : ∀ i, (P i).Label) (z : I → ℤ) + (hz : z ∈ translatedIntegerBox (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i))) : + ∃ x : (∀ i, Finset.Ico (lo i) (hi i)), integerBoxMesh lo hi P x = c ∧ + (fun i => (x i).val) = z := by + let y := physicalBoxUnitResidueEquiv + (fun i => intervalCellLower (lo i) (P i) (c i)) (fun i => (P i).length (c i)) ⟨z,hz⟩ + let e := integerBoxMeshCellEquiv lo hi P hstep hpos c + let x := e.symm y + refine ⟨x.val, x.property, ?_⟩ + funext i + have he := congrArg (fun u => (u i).val) (e.apply_symm_apply y) + change (x.val i).val = z i at he + exact he + +theorem retained_integer_mesh_boxes_classify + {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (sourceLo sourceHi : Option J × I → ℤ) + (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat) + (hSstep : ∀ i c, (S i).step c = 1) (hSpos : ∀ i c, 0 < (S i).length c) + (paramLo paramHi : J → ℤ) + (T : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat) + (hTstep : ∀ j c, (T j).step c = 1) (hTpos : ∀ j c, 0 < (T j).length c) + (D : ℕ) (a : J → ℤ) + (x : (∀ j, Finset.Ico (paramLo j) (paramHi j)) × + (∀ i, Finset.Ico (sourceLo i) (sourceHi i))) + (hx : ¬ physicalMeshCrossing lo N P + (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1)) + (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)) x) : + ∀ z ∈ translatedIntegerBox + (fun i => intervalCellLower (sourceLo i) (S i) (integerBoxMesh sourceLo sourceHi S x.2 i)) + (fun i => (S i).length (integerBoxMesh sourceLo sourceHi S x.2 i)), + ∀ t ∈ translatedIntegerBox + (fun j => intervalCellLower (paramLo j) (T j) (integerBoxMesh paramLo paramHi T x.1 j)) + (fun j => (T j).length (integerBoxMesh paramLo paramHi T x.1 j)), + physicalBoxClassify lo N P (smoothAffineSample (fun j => a j + (D : ℤ) * t j) z) = + physicalBoxClassify lo N P + (smoothAffineSample (fun j => a j + (D : ℤ) * (x.1 j).val) (fun i => (x.2 i).val)) := by + intro z hz t ht + obtain ⟨zs, hzs, hzv⟩ := integerBoxMesh_cell_realize sourceLo sourceHi S hSstep hSpos _ z hz + obtain ⟨ts, hts, htv⟩ := integerBoxMesh_cell_realize paramLo paramHi T hTstep hTpos _ t ht + have he := retained_mesh_cell_constant lo N P + (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi T tz.1)) + (fun tz => smoothAffineSample (fun j => a j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)) + x hx (ts,zs) (Prod.ext hzs hts) + have htj (j : J) : (ts j).val = t j := congrFun htv j + simpa only [hzv, htj] using he + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affine_parameter_mesh_distance {J : Type*} [Fintype J] [DecidableEq J] + (lo hi anchor : J → ℤ) (D : ℕ) (hD : 0 < D) (L delta : ℝ) + (hlarge : ∀ _j : J, 4 ≤ delta * (L / D)) + (hwhole : ∀ j, delta * (L / D) ≤ 2 * ((hi j - lo j).toNat : ℝ)) + (t u : ∀ j, Finset.Ico (lo j) (hi j)) + (hsame : integerBoxMesh lo hi (normalizedBoxPartitions (fun j => (hi j - lo j).toNat) + (fun _ => L / D) delta hlarge hwhole) u = + integerBoxMesh lo hi (normalizedBoxPartitions (fun j => (hi j - lo j).toNat) + (fun _ => L / D) delta hlarge hwhole) t) (j : J) : + |((anchor j + (D : ℤ) * (t j : ℤ) : ℤ) : ℝ) - + ((anchor j + (D : ℤ) * (u j : ℤ) : ℤ) : ℝ)| ≤ delta * L := by + have hd := normalized_integerBoxMesh_distance lo hi (fun _ => L / D) delta hlarge hwhole t u hsame j + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + have he : ((anchor j + (D : ℤ) * (t j : ℤ) : ℤ) : ℝ) - + ((anchor j + (D : ℤ) * (u j : ℤ) : ℤ) : ℝ) = + (D : ℝ) * (((t j : ℤ) : ℝ) - ((u j : ℤ) : ℝ)) := by push_cast; ring + rw [he, abs_mul, abs_of_nonneg hDr.le] + calc + _ ≤ (D : ℝ) * (delta * (L / D)) := mul_le_mul_of_nonneg_left hd hDr.le + _ = _ := by field_simp + +theorem concrete_affine_mesh_boundary_probability {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z) + (parLo parHi anchor : J → ℤ) (hpar : ∀ j, parLo j < parHi j) (D : ℕ) (hD : 0 < D) + (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ) {L C B A c rho delta margin : ℝ} + (hL : 0 < L) (hH : ∀ i, 0 < H i) (hC : 0 ≤ C) (hB : 0 ≤ B) (hA : 0 ≤ A) + (hc : 0 < c) (hrho : 0 < rho) (hmargin : 0 < margin) + (hsiteLarge : ∀ i, 4 ≤ rho * H i) (hsiteWhole : ∀ i, rho * H i ≤ 2 * (N i : ℝ)) + (hsiteRatio : ∀ i, (N i : ℝ) ≤ A * H i) + (hbaseWidth : ∀ i, c * H i ≤ ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) + (hround : ∀ i, 1 ≤ margin * H i) + (hparamLo : ∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) + (hparamHi : ∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) + (hsourceLo : ∀ j i, |(sourceLo (some j, i) : ℝ)| ≤ B * H i / L) + (hsourceHi : ∀ j i, |(sourceHi (some j, i) : ℝ)| ≤ B * H i / L) + (hsourceLarge : ∀ z : Option J × I, 4 ≤ delta * smoothPairCoefficientScale (H z.2) L z.1) + (hsourceWhole : ∀ z : Option J × I, delta * smoothPairCoefficientScale (H z.2) L z.1 ≤ + 2 * ((sourceHi z - sourceLo z).toNat : ℝ)) + (hparamLarge : ∀ _j : J, 4 ≤ delta * (L / D)) + (hparamWhole : ∀ j, delta * (L / D) ≤ 2 * ((parHi j - parLo j).toNat : ℝ)) + (hbudget : delta * (1 + (Fintype.card J : ℝ) * (C + B)) ≤ margin) : + let P := normalizedBoxPartitions N H rho hsiteLarge hsiteWhole + let S := fun z : Option J × I => smoothPairCoefficientScale (H z.2) L z.1 + let sourceMesh := integerBoxMesh sourceLo sourceHi + (normalizedBoxPartitions (fun z => (sourceHi z - sourceLo z).toNat) S delta hsourceLarge hsourceWhole) + let parameterMesh := integerBoxMesh parLo parHi + (normalizedBoxPartitions (fun j => (parHi j - parLo j).toNat) (fun _ => L / D) delta hparamLarge hparamWhole) + let parameter := fun t : ∀ j, Finset.Ico (parLo j) (parHi j) => fun j => anchor j + (D : ℤ) * (t j : ℤ) + ((integerBoxUniformWeights parLo parHi hpar).prod (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (physicalMeshCrossing lo N P (fun tz => (sourceMesh tz.2, parameterMesh tz.1)) + (fun tz => smoothAffineSample (parameter tz.1) (fun z => (tz.2 z : ℤ)))) ≤ + 40 * (Fintype.card I : ℝ) * A * margin / (rho * c) := by + intro P S sourceMesh parameterMesh parameter + have ht (t : ∀ j, Finset.Ico (parLo j) (parHi j)) (j : J) : |(parameter t j : ℝ)| ≤ C * L := by + have h := affineInterval_normalized_cap D (anchor j) (parLo j) (parHi j) (t j : ℤ) + hL (t j).property (hparamLo j) (hparamHi j) + exact (div_le_iff₀ hL).mp (by simpa only [abs_div, abs_of_pos hL] using h) + have hv (z : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) (j : J) (i : I) : + |((z (some j, i) : ℤ) : ℝ)| ≤ B * H i / L := by + have hz := Finset.mem_Ico.mp (z (some j, i)).property + have hlo : (sourceLo (some j, i) : ℝ) ≤ (z (some j, i) : ℤ) := by exact_mod_cast hz.1 + have hhi : ((z (some j, i) : ℤ) : ℝ) ≤ sourceHi (some j, i) := by exact_mod_cast hz.2.le + exact abs_le.mpr ⟨(abs_le.mp (hsourceLo j i)).1.trans hlo, hhi.trans (abs_le.mp (hsourceHi j i)).2⟩ + have hb (z w : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) (h : sourceMesh w = sourceMesh z) (i : I) : + |((z (none, i) : ℤ) : ℝ) - ((w (none, i) : ℤ) : ℝ)| ≤ delta * H i := + normalized_integerBoxMesh_distance sourceLo sourceHi S delta hsourceLarge hsourceWhole z w h (none, i) + have hvd (z w : ∀ j, Finset.Ico (sourceLo j) (sourceHi j)) (h : sourceMesh w = sourceMesh z) (j : J) (i : I) : + |((z (some j, i) : ℤ) : ℝ) - ((w (some j, i) : ℤ) : ℝ)| ≤ delta * H i / L := by + have hh := normalized_integerBoxMesh_distance sourceLo sourceHi S delta hsourceLarge hsourceWhole z w h (some j, i) + simpa only [S, smoothPairCoefficientScale, mul_div_assoc] using hh + have hp (t u : ∀ j, Finset.Ico (parLo j) (parHi j)) (h : parameterMesh u = parameterMesh t) (j : J) : + |(parameter t j : ℝ) - parameter u j| ≤ delta * L := + affine_parameter_mesh_distance parLo parHi anchor D hD L delta hparamLarge hparamWhole t u h j + have hr (i : I) : delta * H i + (Fintype.card J : ℝ) * + ((C * L) * (delta * H i / L) + (B * H i / L) * (delta * L)) ≤ (⌈margin * H i⌉₊ : ℝ) := by + calc + _ = (delta * (1 + (Fintype.card J : ℝ) * (C + B))) * H i := by field_simp + _ ≤ margin * H i := mul_le_mul_of_nonneg_right hbudget (hH i).le + _ ≤ _ := Nat.le_ceil _ + have hbad := affine_mesh_crossing_probability (integerBoxUniformWeights parLo parHi hpar) parameter + sourceLo sourceHi hsource sourceMesh parameterMesh lo N P + (normalizedBoxPartitions_step _ _ _ _ _) (normalizedBoxPartitions_positive _ _ _ _ _) + (fun i => ⌈margin * H i⌉₊) (fun i => delta * H i) (fun i => delta * H i / L) + (fun i => B * H i / L) (C * L) (delta * L) (mul_nonneg hC hL.le) (fun i => div_nonneg (mul_nonneg hB (hH i).le) hL.le) + ht hv hb hvd hp hr + exact hbad.trans (normalized_physical_boundary_budget_le N H + (fun i => ((sourceHi (none, i) - sourceLo (none, i) : ℤ) : ℝ)) rho hrho hH + hsiteLarge hsiteWhole hA hc hmargin hsiteRatio hround hbaseWidth) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ConjugatedLatticeGrids.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ConjugatedLatticeGrids.lean new file mode 100644 index 0000000000000000000000000000000000000000..3886fbf9f5e518f6d5b7c2c72d38e21c311d91ac --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ConjugatedLatticeGrids.lean @@ -0,0 +1,70 @@ +import OAI.Combinatorics.Progressions.Dynamics.ConjugationDenominatorBudget + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem denominatorGrid_neg {ι : Type*} (q : ℕ) {x : ι → ℚ} + (hx : x ∈ denominatorGrid q) : -x ∈ denominatorGrid q := by + obtain ⟨z, hz⟩ := hx + refine ⟨-z, ?_⟩ + intro i + have hi : (q : ℚ) * x i = (z i : ℚ) := hz i + simp only [Pi.smul_apply, Pi.neg_apply, smul_eq_mul, Int.cast_neg, mul_neg, hi] + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + +theorem conjugated_subgroup_inner_grid (e : Basis ι ℚ L) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l q : ℕ) (hq : 0 < q) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (z : NilpotentLieBCHGroup L s hnil) (hz : e.equivFun z.coord ∈ denominatorGrid q) : + scaledIntegerGrid (l * polynomialFamilyDenominator (conjugationCoordinatePolynomial e s) * q ^ s) ⊆ + bchSubgroupCoordinates e (Γ.map (MulAut.conj z).toMonoidHom) := by + intro x hx + let g : NilpotentLieBCHGroup L s hnil := ⟨e.equivFun.symm x⟩ + have hg : e.equivFun g.coord ∈ scaledIntegerGrid + (l * polynomialFamilyDenominator (conjugationCoordinatePolynomial e s) * q ^ s) := by + simpa only [g, LinearEquiv.apply_symm_apply] using hx + have hzinv : e.equivFun (z⁻¹).coord ∈ denominatorGrid q := by + simpa only [NilpotentLieBCHGroup.coord_inv, map_neg] using denominatorGrid_neg q hz + have hconj := conjugation_preserves_inner_grid e hnil q l hq z⁻¹ g hzinv hg + have hmem : z⁻¹ * g * z ∈ Γ := by + apply (bchSubgroupCoordinates_repr e Γ _).mp + apply hinner + simpa only [inv_inv] using hconj + change g ∈ Γ.map (MulAut.conj z).toMonoidHom + refine Subgroup.mem_map.mpr ⟨z⁻¹ * g * z, hmem, ?_⟩ + change z * (z⁻¹ * g * z) * z⁻¹ = g + group + +theorem exists_uniform_conjugated_inner_grid (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l q H : ℕ) (p : ℝ), + 0 < l → 0 < q → scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + (l : ℝ) ≤ Real.exp p → (q : ℝ) ≤ Real.exp p → + ∃ M : ℕ, 0 < M ∧ (M : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∀ z : NilpotentLieBCHGroup L s hnil, e.equivFun z.coord ∈ denominatorGrid q → + scaledIntegerGrid M ⊆ bchSubgroupCoordinates e (Γ.map (MulAut.conj z).toMonoidHom) := by + obtain ⟨K, hK, hden⟩ := exists_conjugation_denominator_exp_bound s + refine ⟨K + s + 5, by omega, ?_⟩ + intro ι L _ _ _ e hnil Γ l q H p hl hq hinner hp hd hH hc hlb hqb + refine ⟨l * polynomialFamilyDenominator (conjugationCoordinatePolynomial e s) * q ^ s, + Nat.mul_pos (Nat.mul_pos hl (polynomialFamilyDenominator_pos _)) (pow_pos hq _), ?_, ?_⟩ + · simpa only [Nat.cast_add, Nat.cast_ofNat] using + conjugation_grid_allowance_le_exp K s l _ q hp hlb (hden e H p hp hd hH hc) hqb + · intro z hz + exact conjugated_subgroup_inner_grid e hnil Γ l q hq hinner z hz + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ContainedFullIntervalResidueIdentity.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ContainedFullIntervalResidueIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..0345a4a3808ea9c87ede2082454514cad9978afc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ContainedFullIntervalResidueIdentity.lean @@ -0,0 +1,439 @@ +import OAI.Combinatorics.Progressions.Probability.ContainedSupportedProgressionJetLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] (h : D → ℕ) +variable (L H step : PrincipalTupleIndex B h → ℕ) (c : PrincipalTupleIndex B h → ℤ) +variable (hL : ∀ j, 0 < L j) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (L j : ℤ)) +variable (modulus : ℕ) (hm : 0 < modulus) +variable (r : PrincipalTupleIndex B h → Option α → ZMod modulus) +variable (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + +local notation "weights" => principalResidueWeights B h H hH modulus hm r hsize +local notation "tupleMap" => containedProgressionTupleMap B h L H step c hL hsubset + +theorem principalResidueWeights_cube_support + (v : PrincipalIntegerTuples B h α H) (hv : (weights).weight v ≠ 0) + (j : PrincipalTupleIndex B h) : IntegerScalarCube (H j) (fun i => (v j i : ℤ)) := by + apply scalarCubeResidueWeights_cube_support α (H j) modulus (hH j) + (fun _ => modulus) (r j) (fun _ => hm) (fun _ => le_rfl) (hsize j) + exact FiniteProbabilityWeights.pi_weight_pos_component _ v + (lt_of_le_of_ne ((weights).nonneg v) (Ne.symm hv)) j + +noncomputable def containedProgressionResidueLaw : + FiniteProbabilityWeights (PrincipalIntegerTuples B h α L) := (weights).fiberLaw tupleMap + +theorem containedProgressionResidueLaw_mean (f : (JointBlockParameter B h α → ℝ) → ℝ) : + (containedProgressionResidueLaw B h L H step c hL hH hsubset modulus hm r hsize).mean + (fun v => f (principalTupleNormalized L v)) = + (weights).mean (fun v => f (principalTupleFlatten B h α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j))) := by + exact containedProgressionTupleLaw_mean B h L H step c hL hsubset weights + (principalResidueWeights_cube_support B h H hH modulus hm r hsize) f + +theorem containedProgressionResidueLaw_support + (v : PrincipalIntegerTuples B h α L) + (hv : (containedProgressionResidueLaw B h L H step c hL hH hsubset modulus hm r hsize).weight v ≠ 0) : + ∀ j i, ((v j i : ℤ) : ZMod modulus) = + (if i = none then (c j : ZMod modulus) else 0) + (step j : ZMod modulus) * r j i := by + apply (weights).fiberLaw_support tupleMap + (fun v => ∀ j i, ((v j i : ℤ) : ZMod modulus) = + (if i = none then (c j : ZMod modulus) else 0) + (step j : ZMod modulus) * r j i) _ v hv + intro z hz j i + have hc := principalResidueWeights_cube_support B h H hH modulus hm r hsize z hz j + have hr := scalarCubeResiduePi_support H (fun _ => modulus) hH + (fun _ _ => modulus) r (fun _ _ => hm) (fun _ _ => le_rfl) hsize z hz j i + change ((containedProgressionCubeMap α (L j) (H j) (step j) (c j) (hL j) (hsubset j) (z j) i : ℤ) : ZMod modulus) = _ + rw [containedProgressionCubeMap_value _ _ _ _ _ _ _ _ hc] + simp only [Int.cast_add, Int.cast_mul, Int.cast_natCast, apply_ite, Int.cast_zero, hr] + +theorem containedProgressionResidueLaw_matrix {Z K I N : Type*} + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ JointBlockParameter B h α) + (z : Z → ℤ) (rows : I → Finset α) + (v v₀ : PrincipalIntegerTuples B h α L) + (hv : (containedProgressionResidueLaw B h L H step c hL hH hsubset modulus hm r hsize).weight v ≠ 0) + (hv₀ : (containedProgressionResidueLaw B h L H step c hL hH hsubset modulus hm r hsize).weight v₀ ≠ 0) : + integerResidueMatrix (integerMappedJetMatrix e input z rows (principalTupleIntegers v)) modulus = + integerResidueMatrix (integerMappedJetMatrix e input z rows (principalTupleIntegers v₀)) modulus := by + apply integerMappedJetMatrix_residue + funext a + change ((v ⟨a.1,a.2.1,a.2.2.1⟩ a.2.2.2 : ℤ) : ZMod modulus) = + ((v₀ ⟨a.1,a.2.1,a.2.2.1⟩ a.2.2.2 : ℤ) : ZMod modulus) + rw [containedProgressionResidueLaw_support B h L H step c hL hH hsubset modulus hm r hsize v hv, + containedProgressionResidueLaw_support B h L H step c hL hH hsubset modulus hm r hsize v₀ hv₀] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +theorem containedProgressionResidueLaw_label_eq + {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] (h : D → ℕ) + (L H step : PrincipalTupleIndex B h → ℕ) (c : PrincipalTupleIndex B h → ℤ) + (hL : ∀ j, 0 < L j) (hH : ∀ j, 0 < H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (modulus : ℕ) (hm : 0 < modulus) + (r : PrincipalTupleIndex B h → Option α → ZMod modulus) + (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + (v v₀ : PrincipalIntegerTuples B h α L) + (hv : (containedProgressionResidueLaw B h L H step c hL hH hsubset modulus hm r hsize).weight v ≠ 0) + (hv₀ : (containedProgressionResidueLaw B h L H step c hL hH hsubset modulus hm r hsize).weight v₀ ≠ 0) : + principalResidueLabel modulus v = principalResidueLabel modulus v₀ := by + funext j i + exact (containedProgressionResidueLaw_support B h L H step c hL hH hsubset modulus hm r hsize v hv j i).trans + (containedProgressionResidueLaw_support B h L H step c hL hH hsubset modulus hm r hsize v₀ hv₀ j i).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical NNReal + +theorem FiniteProbabilityWeights.toPMF_injective {X : Type*} [Fintype X] : + Function.Injective (fun p : FiniteProbabilityWeights X => p.toPMF) := by + intro p q hpq + change p.toPMF = q.toPMF at hpq + have hw : p.weight = q.weight := by + funext x + exact (FiniteProbabilityWeights.toPMF_toReal p x).symm.trans + ((congrArg (fun μ : PMF X => (μ x).toReal) hpq).trans + (FiniteProbabilityWeights.toPMF_toReal q x)) + cases p + cases q + cases hw + rfl + +variable {D α : Type*} [Fintype α] [DecidableEq α] +variable (B : D → Type*) (h : D → ℕ) +variable (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ t, 0 < L t) +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hsize : ∀ t, (Fintype.card α + 1) * q ≤ L t) + +noncomputable def principalResidueNormalizedSource (t : PrincipalTupleIndex B h) : + NormalizedScalarCubeSource α := + normalizedUniformCubeSource α (L t) q (hL t) (fun _ => q) (r t) + (fun _ => hq) (fun _ => le_rfl) (hsize t) + +local notation "sources" => principalResidueNormalizedSource B h L hL q hq r hsize + +theorem principalResidueNormalizedSource_toPMF (t : PrincipalTupleIndex B h) : + ((sources) t).source.toPMF = + (scalarCubeResidueWeights α (L t) q (hL t) (fun _ => q) (r t) + (fun _ => hq) (fun _ => le_rfl) (hsize t)).toPMF := + normalizedUniformCubeSource_toPMF α (L t) q (hL t) (fun _ => q) (r t) + (fun _ => hq) (fun _ => le_rfl) (hsize t) + +theorem principalResidueNormalizedSource_source (t : PrincipalTupleIndex B h) : + ((sources) t).source = + scalarCubeResidueWeights α (L t) q (hL t) (fun _ => q) (r t) + (fun _ => hq) (fun _ => le_rfl) (hsize t) := + FiniteProbabilityWeights.toPMF_injective + (principalResidueNormalizedSource_toPMF B h L hL q hq r hsize t) + +theorem principalResidueNormalizedSource_primitive (t : PrincipalTupleIndex B h) (A : ℝ≥0) : + ScalarCubePrimitiveBudget ((sources) t) A (scalarCubePrimitiveEnvelope α A 1 0 q) := + normalizedUniformCubeSource_primitive α (L t) q (hL t) (fun _ => q) (r t) + (fun _ => hq) (fun _ => le_rfl) (hsize t) A + +variable [Fintype D] [DecidableEq D] [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + +theorem principalResidueWeights_normalized_law : + (principalResidueWeights B h L hL q hq r hsize).toPMF = + dependentProductPMF (fun t => ((sources) t).source.toPMF) := by + have hp : (principalResidueWeights B h L hL q hq r hsize).toPMF = + dependentProductPMF (fun t => (scalarCubeResidueWeights α (L t) q (hL t) + (fun _ => q) (r t) (fun _ => hq) (fun _ => le_rfl) (hsize t)).toPMF) := + FiniteProbabilityWeights.toPMF_pi (fun t => scalarCubeResidueWeights α (L t) q (hL t) + (fun _ => q) (r t) (fun _ => hq) (fun _ => le_rfl) (hsize t)) + exact hp.trans (congrArg + (fun p : ∀ t, PMF (IntegerScalarCubeBox α (L t)) => dependentProductPMF p) + (funext (fun t => (principalResidueNormalizedSource_toPMF B h L hL q hq r hsize t).symm))) + +theorem principalResidueWeights_eq_normalized_pi : + principalResidueWeights B h L hL q hq r hsize = + FiniteProbabilityWeights.pi (fun t => ((sources) t).source) := by + apply FiniteProbabilityWeights.toPMF_injective + exact (principalResidueWeights_normalized_law B h L hL q hq r hsize).trans + (FiniteProbabilityWeights.toPMF_pi (fun t => ((sources) t).source)).symm + +theorem principalResidueWeights_normalized_blocks : + (principalResidueWeights B h L hL q hq r hsize).toPMF.map + (fun y a b v => y ⟨a, b, v⟩) = + dependentProductPMF (fun a => dependentProductPMF (fun b => + dependentProductPMF (fun v => ((sources) ⟨a, b, v⟩).source.toPMF))) := by + have hp := congrArg (fun p : PMF (PrincipalIntegerTuples B h α L) => + p.map (fun y a b v => y ⟨a, b, v⟩)) + (principalResidueWeights_normalized_law B h L hL q hq r hsize) + exact hp.trans (dependentProductPMF_sigma_curry + (fun a b v => ((sources) ⟨a, b, v⟩).source.toPMF)) + +theorem principalTuple_complex_disintegrate_normalized [NeZero q] + (f : (PrincipalTupleIndex B h → Option α → ZMod q) → PrincipalIntegerTuples B h α L → ℂ) : + (principalTupleWeights (α := α) B h L hL).complexMean + (fun y => f (principalResidueLabel q y) y) = + ((principalTupleWeights (α := α) B h L hL).fiberLaw (principalResidueLabel q)).complexMean + (fun residue => (FiniteProbabilityWeights.pi (fun t => + (principalResidueNormalizedSource B h L hL q hq residue hsize t).source)).complexMean + (f residue)) := by + refine (principalTuple_complex_disintegrate B h L hL q hq hsize f).trans ?_ + apply congrArg (fun g : (PrincipalTupleIndex B h → Option α → ZMod q) → ℂ => + ((principalTupleWeights (α := α) B h L hL).fiberLaw (principalResidueLabel q)).complexMean g) + funext residue + exact congrArg (fun p : FiniteProbabilityWeights (PrincipalIntegerTuples B h α L) => + p.complexMean (f residue)) + (principalResidueWeights_eq_normalized_pi B h L hL q hq residue hsize) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ t, 0 < L t) +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hsize : ∀ t, (Fintype.card α + 1) * q ≤ L t) (a : D) + +local notation "sources" => principalResidueNormalizedSource B h L hL q hq r hsize +local notation "law" => FiniteProbabilityWeights.toPMF (principalResidueWeights B h L hL q hq r hsize) + +theorem principalResidueWeights_axis_pair_law : + (law).map (fun y (bv : B a × Fin (h a)) => y ⟨a, bv⟩) = + dependentProductPMF (fun bv : B a × Fin (h a) => ((sources) ⟨a, bv⟩).source.toPMF) := by + have hp := congrArg (fun p : PMF (PrincipalIntegerTuples B h α L) => + p.map (fun y (bv : B a × Fin (h a)) => y ⟨a, bv⟩)) + (principalResidueWeights_normalized_law B h L hL q hq r hsize) + exact hp.trans (dependentProductPMF_marginal (fun t => ((sources) t).source.toPMF) + (fun bv : B a × Fin (h a) => ⟨a, bv⟩) (by intro v w h; simpa using h)) + +theorem principalResidueWeights_axis_block_law : + (law).map (fun y (b : B a) (v : Fin (h a)) => y ⟨a, b, v⟩) = + dependentProductPMF (fun b : B a => dependentProductPMF + (fun v : Fin (h a) => ((sources) ⟨a, b, v⟩).source.toPMF)) := by + have hp := congrArg + (fun p : PMF (∀ bv : B a × Fin (h a), IntegerScalarCubeBox α (L ⟨a, bv⟩)) => + p.map (fun y b v => y (b, v))) + (principalResidueWeights_axis_pair_law B h L hL q hq r hsize a) + have hc := PMF.map_comp (fun (y : PrincipalIntegerTuples B h α L) (bv : B a × Fin (h a)) => y ⟨a, bv⟩) + (law) (fun y b v => y (b, v)) + exact hc.symm.trans (hp.trans (dependentProductPMF_curry + (fun (b : B a) (v : Fin (h a)) => ((sources) ⟨a, b, v⟩).source.toPMF))) + +theorem principalResidueWeights_axis_integer_law : + (law).map (fun y (b : B a) (v : Fin (h a)) i => (y ⟨a, b, v⟩ i : ℤ)) = + dependentProductPMF (fun b : B a => + (dependentProductPMF (fun v : Fin (h a) => ((sources) ⟨a, b, v⟩).source.toPMF)).map + (fun y v i => (y v i : ℤ))) := by + have hp := congrArg + (fun p : PMF (∀ b : B a, ∀ v : Fin (h a), IntegerScalarCubeBox α (L ⟨a, b, v⟩)) => + p.map (fun y b v i => (y b v i : ℤ))) + (principalResidueWeights_axis_block_law B h L hL q hq r hsize a) + have hc := PMF.map_comp (fun (y : PrincipalIntegerTuples B h α L) (b : B a) (v : Fin (h a)) => y ⟨a, b, v⟩) + (law) (fun y b v i => (y b v i : ℤ)) + refine hc.symm.trans (hp.trans ?_) + exact dependentProductPMF_map + (fun b : B a => dependentProductPMF + (fun v : Fin (h a) => ((sources) ⟨a, b, v⟩).source.toPMF)) + (fun _ y v i => (y v i : ℤ)) + +noncomputable def principalResidueAxisJetPMF + (c : B a → NormalizedScalarCubeSource Empty) (rows : Finset (Finset α)) + (offset : B a → ℤ) (shift : rows → ℤ) : PMF (rows → ℤ) := + (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind + (fun z => (law).map (fun y => shift + ∑ b : B a, fun row : rows => + (offset b + z b) * integerBooleanBlockJet + (fun v : Fin (h a) => fun i => (y ⟨a, b, v⟩ i : ℤ)) row)) + +theorem principalResidueWeightedAxis_jet_sum_law + (c : B a → NormalizedScalarCubeSource Empty) (rows : Finset (Finset α)) + (offset : B a → ℤ) (shift : rows → ℤ) : + ((weightedModerateIntegerProductSource c (fun b v => (sources) ⟨a, b, v⟩)).toPMF).map + (weightedModerateIntegerJetSum c (fun b v => (sources) ⟨a, b, v⟩) rows offset shift) = + principalResidueAxisJetPMF B h L hL q hq r hsize a c rows offset shift := by + unfold principalResidueAxisJetPMF + have hp := weightedModerateProductSource_jet_sum_law c + (fun b v => (sources) ⟨a, b, v⟩) rows offset shift + refine hp.trans ?_ + have ht := congrArg (fun p : PMF (B a → Fin (h a) → Option α → ℤ) => + (dependentProductPMF (fun b => (c b).source.toPMF.map (fun x => (x none : ℤ)))).bind + (fun z => p.map (fun y => shift + ∑ b : B a, fun row : rows => + (offset b + z b) * integerBooleanBlockJet (y b) row))) + (principalResidueWeights_axis_integer_law B h L hL q hq r hsize a).symm + simpa only [PMF.map_comp, Function.comp_def] using ht + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ t, 0 < L t) +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hsize : ∀ t, (Fintype.card α + 1) * q ≤ L t) (a : D) +variable (c : B a → NormalizedScalarCubeSource Empty) (rows : Finset (Finset α)) +variable (offset : B a → ℤ) (shift : rows → ℤ) + +local notation "sources" => principalResidueNormalizedSource B h L hL q hq r hsize + +noncomputable def principalResidueAxisGridDensity (K M : ℕ) (z : rows → ℤ) : ℝ := + (K : ℝ) ^ rows.card * + (((principalResidueAxisJetPMF B h L hL q hq r hsize a c rows offset shift).map + (integerGridResidue M)) (integerGridResidue M z)).toReal + +theorem principalResidueAxisGridDensity_eq_normalized (K M : ℕ) (z : rows → ℤ) : + principalResidueAxisGridDensity B h L hL q hq r hsize a c rows offset shift K M z = + integerGridDensity (weightedModerateIntegerProductSource c + (fun b v => (sources) ⟨a, b, v⟩)) + (weightedModerateIntegerJetSum c (fun b v => (sources) ⟨a, b, v⟩) rows offset shift) + K M z := by + symm + have hp := integerGridDensity_eq_of_pmf_image + (weightedModerateIntegerProductSource c (fun b v => (sources) ⟨a, b, v⟩)) + (weightedModerateIntegerJetSum c (fun b v => (sources) ⟨a, b, v⟩) rows offset shift) + (principalResidueAxisJetPMF B h L hL q hq r hsize a c rows offset shift) + (principalResidueWeightedAxis_jet_sum_law B h L hL q hq r hsize a c rows offset shift) + K M z + simpa only [principalResidueAxisGridDensity, Fintype.card_coe] using hp + +theorem principalResidueAxisGridDensity_error_of_tail + (K M : ℕ) [NeZero M] (S : Finset (rows → Fin M)) {ε : ℝ} + (htail : spectrumTail S (fun k => + ‖∏ b : B a, weightedModerateGridCoefficient (c b) + (fun v => (sources) ⟨a, b, v⟩) (offset b : ℝ) M rows k‖) ≤ ε) + (z : rows → ℤ) : + ‖(principalResidueAxisGridDensity B h L hL q hq r hsize a c rows offset shift K M z : ℂ) - + weightedModerateGridApproximation c (fun b v => (sources) ⟨a, b, v⟩) + K M rows offset shift z S‖ ≤ ((K : ℝ) / M) ^ rows.card * ε := by + have he := congrArg (fun t : ℝ => ‖(t : ℂ) - + weightedModerateGridApproximation c (fun b v => (sources) ⟨a, b, v⟩) + K M rows offset shift z S‖) + (principalResidueAxisGridDensity_eq_normalized B h L hL q hq r hsize a c rows offset shift K M z) + exact he.trans_le (weightedModerateGridDensity_error_of_tail c + (fun b v => (sources) ⟨a, b, v⟩) K M rows offset S htail shift z) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem fullIntervalProgression_eq (H : ℕ) : + integerProgressionSupport 0 (1 : ℤ) H = Finset.Ico (0 : ℤ) (H : ℤ) := by + simp [integerProgressionSupport, translateSupport, integerStrideHom] + +theorem fullIntervalProgression_subset (H : ℕ) : + integerProgressionSupport 0 (1 : ℤ) H ⊆ Finset.Ico (0 : ℤ) (H : ℤ) := + (fullIntervalProgression_eq H).subset + +theorem fullIntervalProgression_card (H : ℕ) : + (integerProgressionSupport 0 (1 : ℤ) H).card = H := by + rw [fullIntervalProgression_eq] + simp + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] +variable (h : D → ℕ) (H : PrincipalTupleIndex B h → ℕ) (hH : ∀ j, 0 < H j) + +omit [Fintype D] [DecidableEq D] [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] in +theorem containedProgressionTupleMap_fullInterval_of_cube + (y : PrincipalIntegerTuples B h α H) + (hy : ∀ j, IntegerScalarCube (H j) (fun i => (y j i : ℤ))) : + containedProgressionTupleMap B h H H (fun _ => 1) (fun _ => 0) hH + (fun j => fullIntervalProgression_subset (H j)) y = y := by + funext j i + apply Subtype.ext + change (containedProgressionCubeMap α (H j) (H j) 1 0 (hH j) + (fullIntervalProgression_subset (H j)) (y j) i : ℤ) = (y j i : ℤ) + rw [containedProgressionCubeMap_value _ _ _ _ _ _ _ _ (hy j)] + simp + +theorem principalCubeWeights_fullInterval_fiberLaw + (p : FiniteProbabilityWeights (PrincipalIntegerTuples B h α H)) + (hp : ∀ y, p.weight y ≠ 0 → ∀ j, IntegerScalarCube (H j) (fun i => (y j i : ℤ))) : + p.fiberLaw (containedProgressionTupleMap B h H H (fun _ => 1) (fun _ => 0) hH + (fun j => fullIntervalProgression_subset (H j))) = p := by + apply FiniteProbabilityWeights.toPMF_injective + exact (p.toPMF_fiberLaw _).trans ((p.toPMF_map_congr_on_support _ id (fun y hy => + containedProgressionTupleMap_fullInterval_of_cube B h H hH y (hp y hy))).trans + (PMF.map_id p.toPMF)) + +theorem containedProgressionResidueLaw_fullInterval + (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) + (hsize : ∀ j, (Fintype.card α + 1) * q ≤ H j) : + containedProgressionResidueLaw B h H H (fun _ => 1) (fun _ => 0) hH hH + (fun j => fullIntervalProgression_subset (H j)) q hq r hsize = + principalResidueWeights B h H hH q hq r hsize := by + exact principalCubeWeights_fullInterval_fiberLaw B h H hH _ + (principalResidueWeights_cube_support B h H hH q hq r hsize) + +theorem containedSupportedProgressionLaw_fullInterval + (q : ℕ) (r : PrincipalTupleIndex B h → Option α → ZMod q) + (hcell : 0 < (principalTupleWeights (α := α) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) : + containedSupportedProgressionLaw B h H H (fun _ => 1) (fun _ => 0) hH hH + (fun j => fullIntervalProgression_subset (H j)) q r hcell = + (principalTupleWeights (α := α) B h H hH).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell := by + exact principalCubeWeights_fullInterval_fiberLaw B h H hH _ + (principalSupportedResidue_cube_support B h H hH q r hcell) + +theorem containedProgressionResidueLaw_fullInterval_eq_condition + (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) + (hsize : ∀ j, (Fintype.card α + 1) * q ≤ H j) + (hcell : 0 < (principalTupleWeights (α := α) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) : + containedProgressionResidueLaw B h H H (fun _ => 1) (fun _ => 0) hH hH + (fun j => fullIntervalProgression_subset (H j)) q hq r hsize = + (principalTupleWeights (α := α) B h H hH).condition + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell := by + rw [containedProgressionResidueLaw_fullInterval B h H hH q hq r hsize] + exact principalResidueWeights_eq_condition B h H hH q hq r hsize + +theorem containedProgressionResidueLaw_fullInterval_integer_law + (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) + (hsize : ∀ j, (Fintype.card α + 1) * q ≤ H j) : + (containedProgressionResidueLaw B h H H (fun _ => 1) (fun _ => 0) hH hH + (fun j => fullIntervalProgression_subset (H j)) q hq r hsize).toPMF.map + principalTupleIntegers = + (principalResidueWeights B h H hH q hq r hsize).toPMF.map principalTupleIntegers := by + rw [containedProgressionResidueLaw_fullInterval B h H hH q hq r hsize] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ControlledRefilteredResidueExpansion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ControlledRefilteredResidueExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..5580da26e11c1929e9e86f87c5cd3dd0e1d050cc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ControlledRefilteredResidueExpansion.lean @@ -0,0 +1,165 @@ +import OAI.Combinatorics.Progressions.Estimates.ControlledRefilteredCyclicExpansion +import OAI.Combinatorics.Progressions.Estimates.CyclicCellAnchors +import OAI.Combinatorics.Progressions.Estimates.SlowInverseControl + +namespace OAI + +section + +universe u + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct BigOperators + +theorem exists_controlled_refiltered_residue_expansion (s r : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι : Type u} [Fintype ι] [DecidableEq ι] + {L : ι → Type u} [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + {κ : Type*} [Fintype κ] {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) (s + 1) (d i)) (a : ι) + (w : ∀ i, Fin (d i) → ℕ) + (hF : ∀ i j, (D i).filtration.layer j = + Submodule.span ℚ ((D i).basis '' {b | j ≤ w i b})) + (W : LieSubalgebra ℚ (pi D).filtration.AssociatedGraded) + (v₀ : κ → (pi D).filtration.AssociatedGraded) + (_hspan : Submodule.span ℚ (Set.range v₀) = W.toSubmodule) {p : ℝ}, + 1 ≤ p → (Fintype.card ι : ℝ) ≤ p → (∀ i, (D i).GeometryComplexityLE p) → + (Fintype.card κ : ℝ) ≤ p → + (∀ i b, rationalLogHeight (((pi D).filtration.associatedGradedBasis (pi D).basis + (productBasisWeight w) (pi_layer_span D w hF)).repr (v₀ i) b) ≤ p) → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ P : ℕ, 0 < P ∧ (P : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ E : RationalFilteredNilmanifold ((pi D).filtration.gradedRefiltrationSubalgebra W) + (s + 1) (finrank ℚ ((pi D).filtration.gradedRefiltrationSubalgebra W)), + E.filtration = (pi D).filtration.gradedRefiltration W ∧ + E.lattice = (pi D).lattice.comap + (NilpotentLieBCHGroup.map + (hnil := ((pi D).filtration.gradedRefiltration W).lowerCentralSeries_eq_bot) + ((pi D).filtration.gradedRefiltrationSubalgebra W).incl) ∧ + E.GeometryComplexityLE ((p + C) ^ C) ∧ + ∃ n : ℕ, n ≤ finrank ℚ ((pi D).filtration.gradedRefiltrationSubalgebra W) ∧ + ∃ Q : RationalFilteredNilmanifold + (((pi D).filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n, + Q.filtration = E.filtration.quotientTop ∧ + Q.lattice = E.lattice.map + (E.filtration.quotientStepHom (E.filtration.layerIdeal (s + 1)) le_rfl) ∧ + Q.GeometryComplexityLE ((p + C) ^ C) ∧ + (nativeRefilteredTarget D a W E Q).GeometryComplexityLE ((p + C) ^ C) ∧ + RefilteredResidueExpansionSpec D a W E Q p q r P ((p + C) ^ C) := by + obtain ⟨k₀, _, hslowValues⟩ := exists_slow_inverse_control (s + 1) r + let k := max r k₀ + obtain ⟨a₀, _, hreps⟩ := exists_native_residue_representatives (s + 1) + obtain ⟨b₀, _, hmodels⟩ := exists_controlled_lower_refiltered_reconstruction s k + obtain ⟨c₀, _, hexpand⟩ := exists_lower_refiltered_cyclic_expansion s k + let X : Polynomial ℕ := Polynomial.X + let T := X + (X + Polynomial.C a₀) ^ a₀ + let B := (T + Polynomial.C b₀) ^ b₀ + let F := (T + Polynomial.C c₀) ^ c₀ + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (T + B + F) + refine ⟨C, hC, ?_⟩ + intro ι _ _ L _ _ _ _ _ _ κ _ d D a w hF W v₀ hspan p hp hι hD hκ hv q hq hqp + classical + let w₁ := fun _ : Unit => 1 + have hp₀ : 0 ≤ p := by linarith + obtain ⟨P, m, hP, hm, hPb, hmb, hperiod⟩ := + hreps (D a) w₁ (fun _ => by decide) p hp₀ (hD a) + (by simpa only [Fintype.card_unit, Nat.cast_one] using hp) q hq hqp + let t := p + (p + a₀) ^ a₀ + let cost := (p + C) ^ C + have hpt : p ≤ t := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have ht : 0 ≤ t := hp₀.trans hpt + have hat : (p + a₀) ^ a₀ ≤ t := le_add_of_nonneg_left hp₀ + have hsum : t + (t + b₀) ^ b₀ + (t + c₀) ^ c₀ ≤ cost := by + simpa [T, B, F, X, t, cost, Polynomial.eval₂_pow] using hbudget p hp₀ + have hb₀ : 0 ≤ (t + b₀) ^ b₀ := pow_nonneg (by positivity) _ + have hc₀ : 0 ≤ (t + c₀) ^ c₀ := pow_nonneg (by positivity) _ + have htCost : t ≤ cost := by linarith + have hmodelCost : (t + b₀) ^ b₀ ≤ cost := by linarith + have hfreezeCost : (t + c₀) ^ c₀ ≤ cost := by linarith + have hcost : 0 ≤ cost := ht.trans htCost + obtain ⟨E, hEF, hEL, hE, n, hn, Q, hQF, hQL, hQ, htarget, hrec⟩ := + hmodels D a w hF W v₀ hspan ht (hι.trans hpt) (fun i => (hD i).mono (D i) hpt) + (hκ.trans hpt) (fun i b => (hv i b).trans hpt) m hm + (hmb.trans (Real.exp_le_exp.mpr hat)) + have hbase := hexpand D a W E Q (hp.trans hpt) hcost hQF + (LowerRefilteredRecoveryFamily.mono_cost D a W E Q hrec hmodelCost) + refine ⟨P, hP, hPb.trans (Real.exp_le_exp.mpr (hat.trans htCost)), E, hEF, hEL, + hE.mono E hmodelCost, n, hn, Q, hQF, hQL, hQ.mono Q hmodelCost, + htarget.mono _ hmodelCost, ?_⟩ + let H := (pi D).filtration.gradedRefiltrationSubalgebra W + let I₀ := {i : ι // i ≠ a} + let Z₀ := pi (fun i : I₀ => D i.val) + let := moduleTopology ℝ (ℝ ⊗[ℚ] (H ⧸ E.filtration.layerIdeal (s + 1))) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (H ⧸ E.filtration.layerIdeal (s + 1))) + let := realification_moduleTopology_t2 Q.basis + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i : I₀, L i.val)) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (∀ i : I₀, L i.val)) + let := realification_moduleTopology_t2 Z₀.basis + obtain ⟨Q', hQ'F, hQ'b, hQ'le, hQ', Z, hZF, hZb, hZle, hZ, hbase⟩ := hbase + refine ⟨Q', hQ'F, hQ'b, hQ'le, hQ', Z, hZF, hZb, hZle, hZ, ?_⟩ + let := Z.metricSpace + dsimp only + intro J₀ freq hfreq N _ I J _ _ A₁ B₁ label ρ η hρ hη hA hB hAsum hBsum hres hcircle + S hS hpositive hinvariant slow middle rat κ₁ g hκ₁ hfactor hslow hrat hmiddle hdiam + obtain ⟨anchor, hanchor, hnear⟩ := exists_cyclic_cell_anchors N A₁ hρ hcircle + choose right left hright hvalue using fun h => hperiod (rat h) (hrat h) + let r₀ := fun i h => right h (fun _ => label i) + have hrightGrid (i : I) (h : ZMod N) : + ((D a).basis.baseChange ℝ).equivFun (r₀ i h).coord ∈ realDenominatorGrid m := + (hright h _).2.1 + have hclass (i : I) (h x : ZMod N) (_hx : x ∉ cyclicWrapExceptional h ρ) (hAx : 0 < A₁ i x) : + (QuotientGroup.mk ((D a).filtration.adaptedPolynomialRealValueHom w₁ + (fun _ => (x.val : ℝ)) (rat h)) : (D a).Space) = QuotientGroup.mk (r₀ i h) := by + obtain ⟨γ, hγ, heq⟩ := (hvalue h (fun _ => (x.val : ℤ))).1 + have hclass' : + (QuotientGroup.mk ((D a).filtration.adaptedPolynomialRealValueHom w₁ + (fun _ => ((x.val : ℤ) : ℝ)) (rat h)) : (D a).Space) = + QuotientGroup.mk (right h (fun _ => ((x.val : ℤ) : ZMod P))) := by + rw [heq] + exact QuotientGroup.mk_mul_of_mem _ hγ + simpa only [Int.cast_natCast, r₀, hres i x hAx] using hclass' + have hpower {j : ℕ} (hj : j ≤ k) : (p + 2) ^ j ≤ (t + 2) ^ k := + (pow_le_pow_left₀ (by linarith : (0 : ℝ) ≤ p + 2) + (by linarith : p + 2 ≤ t + 2) j).trans + (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ t + 2) hj) + have hslow' (h : ZMod N) : (D a).filtration.PolynomialSlowBound (D a).basis w₁ + (fun _ => (N : ℝ)) (Real.exp ((t + 2) ^ k)) (slow h) := + (D a).filtration.polynomialSlowBound_mono (D a).basis w₁ + (fun _ => (N : ℝ)) (fun _ => Nat.cast_pos.mpr (NeZero.pos N)) + (Real.exp_le_exp.mpr (hpower (le_max_left _ _))) (slow h) (hslow h) + have hleft (i : I) (h : ZMod N) (b : Fin (d a)) : + |((D a).basis.baseChange ℝ).repr + ((D a).filtration.adaptedPolynomialRealValueHom w₁ (fun _ => anchor i h) (slow h)).coord b| ≤ + Real.exp ((t + 2) ^ k) := by + have hinv := ((D a).filtration.polynomialSlowBound_inv_iff (D a).basis w₁ + (fun _ => (N : ℝ)) (Real.exp ((p + 2) ^ r)) (slow h)).mpr (hslow h) + have hval := (hslowValues (D a) w₁ (fun _ => by decide) p hp₀ (hD a) + (by simpa only [Fintype.card_unit, Nat.cast_one] using hp) + (fun _ => (N : ℝ)) (fun _ => Nat.cast_pos.mpr (NeZero.pos N)) (slow h)⁻¹ hinv).1 + (fun _ => anchor i h) (fun _ => hanchor i h) b + have hval' : + |((D a).basis.baseChange ℝ).repr + ((D a).filtration.adaptedPolynomialRealValueHom w₁ (fun _ => anchor i h) (slow h)).coord b| ≤ + Real.exp ((p + 2) ^ k₀) := by + simpa only [map_inv, inv_inv] using hval + exact hval'.trans (Real.exp_le_exp.mpr (hpower (le_max_right _ _))) + obtain ⟨U, hU, hUcomplexity, hUempty, err, herr, hmean⟩ := + hbase freq hfreq N A₁ B₁ hρ hη hA hB hAsum hBsum S + (fun h => (hS h).mono hpt) hpositive hinvariant slow middle rat κ₁ g + hκ₁ hfactor hslow' hmiddle anchor r₀ hanchor hleft hrightGrid hnear hclass hdiam + refine ⟨U, hU, hUcomplexity, hUempty, err, herr, ?_⟩ + intro h + calc + _ ≤ Real.exp ((t + c₀) ^ c₀) * ρ + Real.exp cost * η + 6 * ρ + 3 / N := hmean h + _ ≤ Real.exp cost * (ρ + η) + 6 * ρ + 3 / N := by + have hb := mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hfreezeCost) hρ.le + nlinarith + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CoprimeResiduePhysicalStability.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CoprimeResiduePhysicalStability.lean new file mode 100644 index 0000000000000000000000000000000000000000..a375e1bc4869e92bdfb672959b8096641102eda4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CoprimeResiduePhysicalStability.lean @@ -0,0 +1,509 @@ +import OAI.Combinatorics.Progressions.Geometry.CoordinateTreeRelabel +import OAI.Combinatorics.Progressions.Lattices.AffineResidueCoordinateEquiv +import OAI.Combinatorics.Progressions.Polynomial.PrimeStabilityPolynomialBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residuePrimeCoordinateMean_congr_assignment {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (I : Finset ι) (x y : ∀ i, σ → ZMod (q i)) (hxy : ∀ i ∈ I, x i = y i) : + residuePrimeCoordinateMean f lo N M a q I x = residuePrimeCoordinateMean f lo N M a q I y := by + classical + let e : ResiduePrimeCoordinateCell lo N M a q I x ≃ ResiduePrimeCoordinateCell lo N M a q I y := + Equiv.subtypeEquivRight (fun z => ⟨fun hz i hi => (hz i hi).trans (hxy i hi), + fun hz i hi => (hz i hi).trans (hxy i hi).symm⟩) + exact Fintype.expect_equiv e _ _ (fun _ => rfl) + +theorem ResiduePrimeCoordinateStable.congr_assignment {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {f : (σ → ℤ) → ℂ} {lo : σ → ℤ} {N : σ → ℕ} {M : ℕ} {a : σ → ℤ} {q : ι → ℕ} + {r : ℕ} {δ : ℝ} {I : Finset ι} {x y : ∀ i, σ → ZMod (q i)} + (h : ResiduePrimeCoordinateStable f lo N M a q r δ I x) (hxy : ∀ i ∈ I, x i = y i) : + ResiduePrimeCoordinateStable f lo N M a q r δ I y := by + intro J hIJ hJ z hyz hnonempty + rw [← residuePrimeCoordinateMean_congr_assignment f lo N M a q I x y hxy] + exact h J hIJ hJ z (fun i hi => (hyz i hi).trans (hxy i hi).symm) hnonempty + +theorem residuePrimeCoordinateStable_of_empty {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (r : ℕ) (δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (hempty : ¬ Nonempty (ResiduePrimeCoordinateCell lo N M a q I x)) : + ResiduePrimeCoordinateStable f lo N M a q r δ I x := by + intro J hIJ hJ y hxy hnonempty + obtain ⟨z⟩ := hnonempty + exact False.elim (hempty ⟨⟨z.val, fun i hi => + (z.property i (Finset.mem_union_left J hi)).trans (hxy i hi)⟩⟩) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def residuePrimeCoordinateCellEquiv {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + primeCoordinateCell (fun j => residueIndexLower (lo j) M (a j)) + (fun j => residueIndexLength (lo j) (lo j + N j) M (a j)) q I x ≃ + ResiduePrimeCoordinateCell lo N M a q I + (fun i => affineResidueCoordinateEquiv M (q i) a (hcop i) (x i)) := by + refine (primeCoordinateCell_subtypeEquiv _ _ q I x).trans + ((integerResidueBoxEquiv lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a + (fun _ => Nat.cast_pos.mpr hM)).subtypeEquiv ?_) + intro z + constructor + · intro hz i hi + change (fun j => ((a j + (M : ℤ) * z.val j : ℤ) : ZMod (q i))) = _ + rw [← affineResidueCoordinateEquiv_intCast M (q i) a (hcop i)] + exact congrArg (affineResidueCoordinateEquiv M (q i) a (hcop i)) (hz i hi) + · intro hz i hi + apply (affineResidueCoordinateEquiv M (q i) a (hcop i)).injective + rw [affineResidueCoordinateEquiv_intCast] + exact hz i hi + +theorem residuePrimeCoordinateMean_affine {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + residuePrimeCoordinateMean f lo N M a q I + (fun i => affineResidueCoordinateEquiv M (q i) a (hcop i) (x i)) = + primeCoordinateMean (fun z => f (fun j => a j + (M : ℤ) * z j)) + (fun j => residueIndexLower (lo j) M (a j)) + (fun j => residueIndexLength (lo j) (lo j + N j) M (a j)) q I x := by + classical + exact (Fintype.expect_equiv (residuePrimeCoordinateCellEquiv lo N M a q hM hcop I x) + _ _ (fun _ => rfl)).symm + +theorem PrimeCoordinateStable.on_residue_slice {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) (r : ℕ) (δ : ℝ) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (h : PrimeCoordinateStable (fun z => f (fun j => a j + (M : ℤ) * z j)) + (fun j => residueIndexLower (lo j) M (a j)) + (fun j => residueIndexLength (lo j) (lo j + N j) M (a j)) q r δ I x) : + ResiduePrimeCoordinateStable f lo N M a q r δ I + (fun i => affineResidueCoordinateEquiv M (q i) a (hcop i) (x i)) := by + intro J hIJ hJ y hxy hnonempty + let inv : ∀ i, σ → ZMod (q i) := fun i => + (affineResidueCoordinateEquiv M (q i) a (hcop i)).symm (y i) + have hy : (fun i => affineResidueCoordinateEquiv M (q i) a (hcop i) (inv i)) = y := by + funext i + exact Equiv.apply_symm_apply _ _ + have hagree : ∀ i ∈ I, inv i = x i := by + intro i hi + dsimp only [inv] + rw [hxy i hi] + exact Equiv.symm_apply_apply _ _ + have hne : (primeCoordinateCell (fun j => residueIndexLower (lo j) M (a j)) + (fun j => residueIndexLength (lo j) (lo j + N j) M (a j)) q (I ∪ J) inv).Nonempty := by + rw [← hy] at hnonempty + obtain ⟨z⟩ := hnonempty + exact ⟨((residuePrimeCoordinateCellEquiv lo N M a q hM hcop (I ∪ J) inv).symm z).val, + ((residuePrimeCoordinateCellEquiv lo N M a q hM hcop (I ∪ J) inv).symm z).property⟩ + rw [residuePrimeCoordinateMean_affine f lo N M a q hM hcop I x] + have hmean := residuePrimeCoordinateMean_affine f lo N M a q hM hcop (I ∪ J) inv + rw [hy] at hmean + rw [hmean] + exact h J hIJ hJ inv hagree hne + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residuePrimeCoordinateMean_of_isEmpty {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] [IsEmpty σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + residuePrimeCoordinateMean f lo N M a q I x = f (fun j => isEmptyElim j) := by + classical + let : Nonempty (ResiduePrimeCoordinateCell lo N M a q I x) := + ⟨⟨(fun j => isEmptyElim j), fun _ _ => Subsingleton.elim _ _⟩⟩ + unfold residuePrimeCoordinateMean + calc + (𝔼 z : ResiduePrimeCoordinateCell lo N M a q I x, f (fun j => (z.val j).val)) = + 𝔼 _z : ResiduePrimeCoordinateCell lo N M a q I x, f (fun j => isEmptyElim j) := by + apply Finset.expect_congr rfl + intro z _ + exact congrArg f (Subsingleton.elim _ _) + _ = _ := Fintype.expect_const _ + +theorem residuePrimeCoordinateStable_of_isEmpty {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] [IsEmpty σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (r : ℕ) (δ : ℝ) (hδ : 0 ≤ δ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + ResiduePrimeCoordinateStable f lo N M a q r δ I x := by + intro J _ _ y _ _ + rw [residuePrimeCoordinateMean_of_isEmpty, residuePrimeCoordinateMean_of_isEmpty, sub_self, norm_zero] + exact hδ + +theorem exists_residue_stable_tree_of_isEmpty {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] [IsEmpty σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (r : ℕ) (δ : ℝ) (hδ : 0 ≤ δ) (mandatory : Finset ι) : + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (q i)), + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ ResiduePrimeCoordinateStable f lo N M a q r δ I x) + ∅ (fun _ _ => 0) tree mandatory.card := by + have h := CoordinateDecisionTree.exists_query_batch + (fun I x => mandatory ⊆ I ∧ ResiduePrimeCoordinateStable f lo N M a q r δ I x) + mandatory 0 ∅ (fun _ _ => 0) (by simp) (by + intro y _ + refine ⟨.leaf, .leaf ⟨?_, residuePrimeCoordinateStable_of_isEmpty f lo N M a q r δ hδ _ y⟩⟩ + simp only [Finset.empty_union, Finset.Subset.refl]) + simpa only [Nat.add_zero] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +universe u v w + +theorem exists_adapted_prime_coordinate_stability (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (ω : Fin d → ℕ), + (∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) → + ∀ (p δ : ℝ), 2 ≤ p → (d : ℝ) ≤ p → (Fintype.card σ : ℝ) ≤ p → + 0 < δ → δ ≤ 1 → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (lo : σ → ℤ) (N : σ → ℕ), (∀ i, 0 < N i) → + (∀ i, Real.exp ((p + 2) ^ E) ≤ (N i : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ PrimeCoordinateStable T.eval lo N (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + obtain ⟨parameters⟩ := exists_physical_stability_parameters.{u, v} s + obtain ⟨Lexp, hLexp, hbounds⟩ := + exists_prime_stability_polynomial_budget.{u, v, w} s parameters.K parameters.Kf + let R : Polynomial ℕ := ((Polynomial.X + 2) ^ parameters.A + 2) ^ Lexp + obtain ⟨E, hE, hpoly⟩ := exists_natPolynomial_fixed_power_budget R + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D ω hadapted p δ hp hd hσ hδ hδone hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N hN hlarge + let b := (p + 2) ^ parameters.A + have hp0 : 0 ≤ p := by linarith + have hb : 0 ≤ b := by dsimp [b]; positivity + have hpb : p ≤ b := by + calc + p ≤ p + 2 := by linarith + _ = (p + 2) ^ 1 := (pow_one _).symm + _ ≤ (p + 2) ^ parameters.A := pow_le_pow_right₀ (by linarith) parameters.A_pos + let base : PhysicalEpochSource.{u, v} σ s d := { + Carrier := L + dimension := d + dimension_le := le_rfl + model := D + weights := ω + adapted := hadapted + fixedMap := T + lower := lo + sides := N + sides_pos := hN + incomingBudget := p + recordBudget := b + incoming_nonneg := hp0 + incoming_le_record := hpb + geometry := hcomplexity.1 + coordinates_le := hσ } + let ctx : PrimeStabilityContext.{u, v, w} ι σ s d := { + parameters := parameters + base := base + baseline := T + orbit := rfl + positive := hpositive + complexity := hcomplexity + recordCap := b + recordCap_nonneg := hb + record_le_cap := le_rfl + inflation := le_rfl + record_two := hp.trans hpb + gap := δ + gap_pos := hδ + gap_le_one := hδone + gap_inverse := hδinv + prime := prime + power := power + prime_prime := hprime + prime_injective := hinj + primeBudget := p + primeBudget_nonneg := hp0 + prime_bound := hprimeBound + witnessSize := r + mandatory := mandatory } + obtain ⟨hallowance, hwidth⟩ := hbounds ctx b hb le_rfl le_rfl le_rfl hpb (hr.trans hpb) (hmandatory.trans hpb) (hd.trans hpb) + have hpower : (b + 2) ^ Lexp ≤ (p + 2) ^ E := by + simpa [R, b, Polynomial.eval₂_pow] using hpoly p hp0 + have hctxLarge : ctx.HasLargeSides := by + intro i + exact (Real.exp_le_exp.mpr (hwidth.trans hpower)).trans (hlarge i) + obtain ⟨tree, htree⟩ := ctx.exists_stable_tree hctxLarge + exact ⟨tree, ctx.allowance, hallowance.trans hpower, htree⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +universe u v w + +theorem exists_prime_coordinate_box_stability (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p δ : ℝ), + 2 ≤ p → (Fintype.card σ : ℝ) ≤ p → 0 < δ → δ ≤ 1 → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (lo : σ → ℤ) (N : σ → ℕ), (∀ i, 0 < N i) → + (∀ i, Real.exp ((p + 2) ^ E) ≤ (N i : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ PrimeCoordinateStable T.eval lo N (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + obtain ⟨C, _, hrebase⟩ := RationalFilteredNilmanifold.exists_controlled_adapted_rebase + obtain ⟨E₀, _, hstability⟩ := exists_adapted_prime_coordinate_stability.{u, v, w} s + let P : Polynomial ℕ := ((Polynomial.X + Polynomial.C C) ^ C + 2) ^ E₀ + obtain ⟨E, hE, hpoly⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D p δ hp hσ hδ hδone hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N hN hlarge + have hp0 : 0 ≤ p := by linarith + obtain ⟨F, H, hH, hpq, hgeometry, htest, _⟩ := hrebase D hp0 hcomplexity.1 + let q := (p + C) ^ C + have hpower : (q + 2) ^ E₀ ≤ (p + 2) ^ E := by + simpa [P, q, Polynomial.eval₂_pow] using hpoly p hp0 + have hnewLarge : ∀ i, Real.exp ((q + 2) ^ E₀) ≤ (N i : ℝ) := + fun i => (Real.exp_le_exp.mpr hpower).trans (hlarge i) + obtain ⟨tree, depth, hdepth, htree⟩ := hstability F.model F.weight F.model_layers q δ (hp.trans hpq) + hgeometry.1 (hσ.trans hpq) hδ hδone (hδinv.trans (Real.exp_le_exp.mpr hpq)) + (F.rebaseNiltest H hH T) (F.rebaseNiltest_unit_interval H hH T hpositive) (htest T hcomplexity) + prime power hprime hinj (fun i => (hprimeBound i).trans (Real.exp_le_exp.mpr hpq)) + mandatory r (hmandatory.trans hpq) (hr.trans hpq) lo N hN hnewLarge + have heval : (F.rebaseNiltest H hH T).eval = T.eval := funext (F.rebaseNiltest_eval H hH T) + rw [heval] at htree + exact ⟨tree, depth, hdepth.trans hpower, htree⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem PrimeCoordinateStable.mono_tolerance + {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {f : (σ → ℤ) → ℂ} {lo : σ → ℤ} {N : σ → ℕ} {q : ι → ℕ} + {r : ℕ} {δ ε : ℝ} {I : Finset ι} {x : ∀ i, σ → ZMod (q i)} + (h : PrimeCoordinateStable f lo N q r δ I x) (hδε : δ ≤ ε) : + PrimeCoordinateStable f lo N q r ε I x := by + intro J hIJ hJ y hxy hnonempty + exact (h J hIJ hJ y hxy hnonempty).trans hδε + +universe u v w + +theorem exists_prime_coordinate_box_stability_pos (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p δ : ℝ), + 2 ≤ p → (Fintype.card σ : ℝ) ≤ p → 0 < δ → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (lo : σ → ℤ) (N : σ → ℕ), (∀ i, 0 < N i) → + (∀ i, Real.exp ((p + 2) ^ E) ≤ (N i : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ PrimeCoordinateStable T.eval lo N (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + obtain ⟨E, hE, hstability⟩ := exists_prime_coordinate_box_stability.{u, v, w} s + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N hN hlarge + let ε := min δ 1 + have hε : 0 < ε := lt_min hδ (by norm_num) + have hεone : ε ≤ 1 := min_le_right _ _ + have hεinv : ε⁻¹ ≤ Real.exp p := by + by_cases hsmall : δ ≤ 1 + · simpa only [ε, min_eq_left hsmall] using hδinv + · have hlargeδ : 1 ≤ δ := le_of_lt (lt_of_not_ge hsmall) + simpa only [ε, min_eq_right hlargeδ, inv_one] using Real.one_le_exp (show 0 ≤ p by linarith) + obtain ⟨tree, depth, hdepth, htree⟩ := hstability D p ε hp hσ hε hεone hεinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N hN hlarge + refine ⟨tree, depth, hdepth, htree.map ?_⟩ + intro I x hleaf + exact ⟨hleaf.1, hleaf.2.mono_tolerance (min_le_left δ 1)⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +universe u v w + +theorem exists_coprime_residue_prime_stability (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p δ : ℝ), + 2 ≤ p → (Fintype.card σ : ℝ) ≤ p → 0 < δ → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ), 0 < M → + (∀ i, M.Coprime (prime i ^ power i)) → + (∀ j, Real.exp ((p + 2) ^ E) ≤ + (residueIndexLength (lo j) (lo j + N j) M (a j) : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ + ResiduePrimeCoordinateStable T.eval lo N M a (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + obtain ⟨E, hE, hstability⟩ := exists_prime_coordinate_box_stability_pos.{u, v, w} s + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N M a hM hcop hlarge + let q : ι → ℕ := fun i => prime i ^ power i + let S := T.scalarAffinePullback (M : ℤ) (fun j => (a j : ℚ)) + have hSpos : S.UnitIntervalValued := hpositive + have hScomplexity : S.ComplexityLE p := hcomplexity + have hN : ∀ j, 0 < residueIndexLength (lo j) (lo j + N j) M (a j) := by + intro j + exact_mod_cast (Real.exp_pos ((p + 2) ^ E)).trans_le (hlarge j) + obtain ⟨tree, depth, hdepth, htree⟩ := hstability D p δ hp hσ hδ hδinv S hSpos hScomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr + (fun j => residueIndexLower (lo j) M (a j)) + (fun j => residueIndexLength (lo j) (lo j + N j) M (a j)) hN hlarge + have heval : S.eval = (fun z => T.eval (fun j => a j + (M : ℤ) * z j)) := by + funext z + simpa only [S, add_comm] using T.scalarAffinePullback_eval_integer (M : ℤ) a z + rw [heval] at htree + let e : ∀ i, (σ → ZMod (q i)) ≃ (σ → ZMod (q i)) := + fun i => affineResidueCoordinateEquiv M (q i) a (hcop i) + have hrelabeled := htree.relabel e + have hresult : CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ ResiduePrimeCoordinateStable T.eval lo N M a q r δ I x) + ∅ (CoordinateDecisionTree.relabelAssignment e (fun _ _ => 0)) (tree.relabel e) depth := by + apply hrelabeled.map + intro I x hx + refine ⟨hx.1, ?_⟩ + have hs := PrimeCoordinateStable.on_residue_slice T.eval lo N M a q hM hcop r δ I + (CoordinateDecisionTree.relabelAssignment (fun i => (e i).symm) x) hx.2 + simpa only [CoordinateDecisionTree.relabelAssignment, e, Equiv.apply_symm_apply] using hs + refine ⟨tree.relabel e, depth, hdepth, hresult.congr_assignment ?_ (fun _ _ => 0) ?_⟩ + · intro I x y hxy hx + exact ⟨hx.1, hx.2.congr_assignment hxy⟩ + · intro i hi + exact False.elim (Finset.notMem_empty i hi) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +universe u v w + +theorem exists_coprime_residue_physical_stability (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p δ : ℝ), + 2 ≤ p → (Fintype.card σ : ℝ) ≤ p → 0 < δ → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ), 0 < M → (M : ℝ) ≤ Real.exp p → + (∀ i, M.Coprime (prime i ^ power i)) → + (∀ j, Real.exp ((p + 2) ^ E) ≤ (N j : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ + ResiduePrimeCoordinateStable T.eval lo N M a (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + obtain ⟨E₀, _, hstability⟩ := exists_coprime_residue_prime_stability.{u, v, w} s + let P : Polynomial ℕ := Polynomial.X + (Polynomial.X + 2) ^ E₀ + 2 + obtain ⟨E, hE, hpoly⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N M a hM hmodulus hcop hlarge + have hp0 : 0 ≤ p := by linarith + have hpower : p + (p + 2) ^ E₀ + 2 ≤ (p + 2) ^ E := by + simpa [P, Polynomial.eval₂_pow] using hpoly p hp0 + have hparameters : ∀ j, Real.exp ((p + 2) ^ E₀) ≤ + (residueIndexLength (lo j) (lo j + N j) M (a j) : ℝ) := by + intro j + apply residueIndexLength_large_of_exp (lo j) (a j) (N j) M p ((p + 2) ^ E₀) + hM (by positivity) hmodulus + exact (Real.exp_le_exp.mpr hpower).trans (hlarge j) + obtain ⟨tree, depth, hdepth, htree⟩ := hstability D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N M a hM hcop hparameters + exact ⟨tree, depth, hdepth.trans (by linarith), htree⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CountedSlicePrimeStability.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CountedSlicePrimeStability.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f1ccfa03224e7f1bbed011d2f2724086a41dc13 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CountedSlicePrimeStability.lean @@ -0,0 +1,236 @@ +import OAI.Combinatorics.Progressions.Lattices.ResidueSliceUpperFailure + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +universe u v w + +theorem exists_residue_prime_stability (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p δ : ℝ), + 2 ≤ p → (Fintype.card σ : ℝ) ≤ p → 0 < δ → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ), 0 < M → (M : ℝ) ≤ Real.exp p → + (∀ j, Real.exp ((p + 2) ^ E) ≤ (N j : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ + ResiduePrimeCoordinateStable T.eval lo N M a (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + classical + obtain ⟨E₀, _, hstability⟩ := exists_coprime_residue_physical_stability.{u, v, w} s + let P : Polynomial ℕ := 3 * Polynomial.X + 1 + + (Polynomial.X + 3 * Polynomial.X ^ 2 + 2) ^ E₀ + obtain ⟨E, hE, hpoly⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N M a hM hmodulus hlarge + let q : ι → ℕ := fun i => prime i ^ power i + let K := mandatory ∪ periodPrimeCoordinates prime M + let cap := p + 3 * p ^ 2 + let depth : ℕ := ⌈(cap + 2) ^ E₀⌉₊ + let Good := fun I x => mandatory ⊆ I ∧ ResiduePrimeCoordinateStable T.eval lo N M a q r δ I x + have hp0 : 0 ≤ p := by linarith + have hcap : p ≤ cap := by dsimp only [cap]; nlinarith [sq_nonneg p] + have hcap0 : 0 ≤ cap := hp0.trans hcap + have hpower : 3 * p + 1 + (cap + 2) ^ E₀ ≤ (p + 2) ^ E := by + simpa [P, cap, Polynomial.eval₂_pow] using hpoly p hp0 + have hK := initialResiduePrimeMask_bounds prime power hprime hinj M hM p hp0 hmodulus hprimeBound mandatory hmandatory + have hKcard : (K.card : ℝ) ≤ 3 * p := hK.1 + have hQ : ((M.lcm (∏ i ∈ K, q i) : ℕ) : ℝ) ≤ Real.exp cap := hK.2 + have hQpos : 0 < M.lcm (∏ i ∈ K, q i) := by + apply Nat.pos_of_ne_zero + apply Nat.lcm_ne_zero hM.ne' + exact (Finset.prod_pos (fun i _ => pow_pos (hprime i).pos (power i))).ne' + have hside : ∀ j, Real.exp ((cap + 2) ^ E₀) ≤ (N j : ℝ) := by + intro j + apply le_trans _ (hlarge j) + apply Real.exp_le_exp.mpr + linarith + have hbranches : ∀ base : ∀ i, σ → ZMod (q i), ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (q i)), + CoordinateDecisionTree.Valid Good K base tree depth := by + intro base + by_cases hnonempty : Nonempty (ResiduePrimeCoordinateCell lo N M a q K base) + · obtain ⟨u⟩ := hnonempty + obtain ⟨tree, d', hd', htree⟩ := hstability D cap δ (hp.trans hcap) (hσ.trans hcap) hδ + (hδinv.trans (Real.exp_le_exp.mpr hcap)) T hpositive (hcomplexity.mono hcap) + (fun i : {i // i ∉ K} => prime i.val) (fun i => power i.val) + (fun i => hprime i.val) (fun i j hij => Subtype.ext (hinj hij)) + (fun i => (hprimeBound i.val).trans (Real.exp_le_exp.mpr hcap)) + ∅ r (by simpa only [Finset.card_empty, Nat.cast_zero] using hcap0) (hr.trans hcap) + lo N (M.lcm (∏ i ∈ K, q i)) (fun j => (u.val j).val) hQpos hQ + (fun i => initialResidueCombined_coprime prime power hprime hinj M K + Finset.subset_union_right i.val i.property) hside + have hsub := htree.map (fun _ _ h => h.2) + have hlift := hsub.liftOutside K base (fun S x hx => + (show Good (K ∪ S.image Subtype.val) (CoordinateDecisionTree.outsideAssignment K base x) from + ⟨Finset.subset_union_left.trans Finset.subset_union_left, + hx.lift_outside T.eval lo N M a q + (selectedPrimePowers_pairwise_coprime prime power hprime hinj) K base u r δ S x⟩)) + have hroot : CoordinateDecisionTree.Valid Good K + (CoordinateDecisionTree.outsideAssignment K base (fun _ _ => 0)) (tree.liftOutside K) d' := by + simpa only [Finset.image_empty, Finset.union_empty] using hlift + have hroot' := hroot.congr_assignment (fun I x y hxy hx => + (show Good I y from ⟨hx.1, hx.2.congr_assignment hxy⟩)) base (by + intro i hi + simp only [CoordinateDecisionTree.outsideAssignment, hi, dite_true]) + have hdepth : d' ≤ depth := by + exact_mod_cast hd'.trans (Nat.le_ceil ((cap + 2) ^ E₀)) + exact ⟨tree.liftOutside K, hroot'.mono hdepth⟩ + · exact ⟨.leaf, .leaf ⟨Finset.subset_union_left, + residuePrimeCoordinateStable_of_empty T.eval lo N M a q r δ K base hnonempty⟩⟩ + obtain ⟨tree, htree⟩ := CoordinateDecisionTree.exists_query_batch Good K depth ∅ (fun _ _ => 0) + (by simp) (fun base _ => by simpa only [Finset.empty_union] using hbranches base) + refine ⟨tree, K.card + depth, ?_, htree⟩ + have hceil : (depth : ℝ) ≤ (cap + 2) ^ E₀ + 1 := + (Nat.ceil_lt_add_one (show 0 ≤ (cap + 2) ^ E₀ by positivity)).le + rw [Nat.cast_add] + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +universe u v w + +theorem exists_prescribed_slice_prime_stability (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p δ : ℝ), + 2 ≤ p → (Fintype.card σ : ℝ) ≤ p → 0 < δ → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (H N : σ → ℕ) (lo a : σ → ℤ) (M : ℕ), 0 < M → (M : ℝ) ≤ Real.exp p → + (∀ j, Real.exp (-p) * (H j : ℝ) ≤ (N j : ℝ)) → + (∀ j, Real.exp ((p + 2) ^ E) ≤ (H j : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ + ResiduePrimeCoordinateStable T.eval lo N M a (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + obtain ⟨E₀, _, hstability⟩ := exists_residue_prime_stability.{u, v, w} s + let P : Polynomial ℕ := Polynomial.X + (Polynomial.X + 2) ^ E₀ + obtain ⟨E, hE, hpoly⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr H N lo a M hM hmodulus hwidth hlarge + have hp0 : 0 ≤ p := by linarith + have hpower : p + (p + 2) ^ E₀ ≤ (p + 2) ^ E := by + simpa [P, Polynomial.eval₂_pow] using hpoly p hp0 + have hside : ∀ j, Real.exp ((p + 2) ^ E₀) ≤ (N j : ℝ) := by + intro j + have hparent := (Real.exp_le_exp.mpr hpower).trans (hlarge j) + calc + Real.exp ((p + 2) ^ E₀) = Real.exp (-p) * Real.exp (p + (p + 2) ^ E₀) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ Real.exp (-p) * (H j : ℝ) := mul_le_mul_of_nonneg_left hparent (Real.exp_pos _).le + _ ≤ (N j : ℝ) := hwidth j + obtain ⟨tree, depth, hdepth, htree⟩ := hstability D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr lo N M a hM hmodulus hside + exact ⟨tree, depth, hdepth.trans (by linarith), htree⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +universe u v w + +theorem exists_counted_slice_prime_stability (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {L : Type v} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [TopologicalSpace (ℝ ⊗[ℚ] L)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p δ : ℝ), + 2 ≤ p → (Fintype.card σ : ℝ) ≤ p → 0 < δ → δ⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (prime power : ι → ℕ), (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) → + ∀ (mandatory : Finset ι) (r : ℕ), (mandatory.card : ℝ) ≤ p → (r : ℝ) ≤ p → + ∀ (H N : σ → ℕ) (lo a : σ → ℤ) (M : ℕ), 0 < M → (∀ j, N j ≤ H j) → + (∀ j, Real.exp (-p) * (H j : ℝ) ≤ + (residueIndexLength (lo j) (lo j + N j) M (a j) : ℝ)) → + (∀ j, Real.exp ((p + 2) ^ E) ≤ (H j : ℝ)) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (prime i ^ power i)), ∃ depth : ℕ, + (depth : ℝ) ≤ (p + 2) ^ E ∧ + CoordinateDecisionTree.Valid + (fun I x => mandatory ⊆ I ∧ + ResiduePrimeCoordinateStable T.eval lo N M a (fun i => prime i ^ power i) r δ I x) + ∅ (fun _ _ => 0) tree depth := by + classical + obtain ⟨E₀, _, hstability⟩ := exists_prescribed_slice_prime_stability.{u, v, w} s + let P : Polynomial ℕ := (Polynomial.X + 4) ^ E₀ + Polynomial.X + 2 + obtain ⟨E, hE, hpoly⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨E, hE, ?_⟩ + intro ι σ L _ _ _ _ _ _ _ _ _ _ d D p δ hp hσ hδ hδinv T hpositive hcomplexity + prime power hprime hinj hprimeBound mandatory r hmandatory hr H N lo a M hM hNH hcount hlarge + have hp0 : 0 ≤ p := by linarith + have hpower : (p + 4) ^ E₀ + p + 2 ≤ (p + 2) ^ E := by + simpa [P, Polynomial.eval₂_pow] using hpoly p hp0 + have hnonneg : 0 ≤ (p + 4) ^ E₀ := by positivity + rcases isEmpty_or_nonempty σ with hempty | hnonempty + · let := hempty + obtain ⟨tree, htree⟩ := exists_residue_stable_tree_of_isEmpty T.eval lo N M a + (fun i => prime i ^ power i) r δ hδ.le mandatory + exact ⟨tree, mandatory.card, hmandatory.trans (by linarith), htree⟩ + · let := hnonempty + have hcost := fun j => residue_slice_counting_cost (lo j) (a j) (H j) (N j) M p hM (hNH j) + ((Real.exp_le_exp.mpr (show p + 2 ≤ (p + 2) ^ E by linarith)).trans (hlarge j)) (hcount j) + have hmodulus : (M : ℝ) ≤ Real.exp (p + 2) := (hcost (Classical.choice hnonempty)).1 + have hpinc : p ≤ p + 2 := by linarith + have hwidth : ∀ j, Real.exp (-(p + 2)) * (H j : ℝ) ≤ (N j : ℝ) := by + intro j + exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (by linarith)) + (Nat.cast_nonneg (H j))).trans (hcost j).2 + have hsize : ∀ j, Real.exp ((p + 2 + 2) ^ E₀) ≤ (H j : ℝ) := by + intro j + apply le_trans _ (hlarge j) + apply Real.exp_le_exp.mpr + have heq : p + 2 + 2 = p + 4 := by ring + rw [heq] + linarith + obtain ⟨tree, depth, hdepth, htree⟩ := hstability D (p + 2) δ (hp.trans hpinc) + (hσ.trans hpinc) hδ (hδinv.trans (Real.exp_le_exp.mpr hpinc)) + T hpositive (hcomplexity.mono hpinc) prime power hprime hinj + (fun i => (hprimeBound i).trans (Real.exp_le_exp.mpr hpinc)) + mandatory r (hmandatory.trans hpinc) (hr.trans hpinc) H N lo a M hM hmodulus hwidth hsize + refine ⟨tree, depth, ?_, htree⟩ + have heq : p + 2 + 2 = p + 4 := by ring + rw [heq] at hdepth + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CoverBasisResidues.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CoverBasisResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c412851687bfb055915c33ee32bc5852760d223 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CoverBasisResidues.lean @@ -0,0 +1,153 @@ +import Mathlib.GroupTheory.QuotientGroup.Basic +import OAI.Combinatorics.Progressions.Estimates.LinearQuotientCoverAverage +import OAI.Combinatorics.Progressions.Lattices.ResidueRefinedPeriod + +namespace OAI + +section + +namespace Erdos3 + +variable {E : Type*} [AddCommGroup E] [Module ℝ E] (Γ : AddSubgroup E) + +noncomputable def coverLatticePoint (d : ℕ) (hd : 0 < d) : + Γ →+ (quotientIntegerCover Γ d).ker where + toFun x := ⟨QuotientAddGroup.mk' Γ ((d : ℝ)⁻¹ • x.val), by + change quotientIntegerCover Γ d (QuotientAddGroup.mk' Γ _) = 0 + rw [quotientIntegerCover_mk, smul_smul, mul_inv_cancel₀ (by exact_mod_cast hd.ne'), one_smul] + exact (QuotientAddGroup.eq_zero_iff _).mpr x.property⟩ + map_zero' := by apply Subtype.ext; simp + map_add' x y := by apply Subtype.ext; simp [smul_add] + +theorem coverLatticePoint_val (d : ℕ) (hd : 0 < d) (x : Γ) : + (coverLatticePoint Γ d hd x).val = + QuotientAddGroup.mk' Γ ((d : ℝ)⁻¹ • x.val) := rfl + +theorem coverLatticePoint_surjective (d : ℕ) (hd : 0 < d) : + Function.Surjective (coverLatticePoint Γ d hd) := by + intro y + obtain ⟨x, hx⟩ := QuotientAddGroup.mk'_surjective Γ y.val + have hxΓ : (d : ℝ) • x ∈ Γ := by + apply (QuotientAddGroup.eq_zero_iff _).mp + change QuotientAddGroup.mk' Γ ((d : ℝ) • x) = 0 + rw [← quotientIntegerCover_mk, hx] + exact y.property + refine ⟨⟨(d : ℝ) • x, hxΓ⟩, ?_⟩ + apply Subtype.ext + rw [coverLatticePoint_val, smul_smul, + inv_mul_cancel₀ (by exact_mod_cast hd.ne'), one_smul] + exact hx + +theorem coverLatticePoint_ker (d : ℕ) (hd : 0 < d) : + (coverLatticePoint Γ d hd).ker = (nsmulAddMonoidHom (α := Γ) d).range := by + ext x + constructor + · intro hx + have he : QuotientAddGroup.mk' Γ ((d : ℝ)⁻¹ • x.val) = 0 := + congrArg Subtype.val hx + have hΓ := (QuotientAddGroup.eq_zero_iff _).mp he + refine ⟨⟨(d : ℝ)⁻¹ • x.val, hΓ⟩, ?_⟩ + apply Subtype.ext + change d • ((d : ℝ)⁻¹ • x.val) = x.val + rw [← Nat.cast_smul_eq_nsmul ℝ, smul_smul, + mul_inv_cancel₀ (by exact_mod_cast hd.ne'), one_smul] + · rintro ⟨y, rfl⟩ + change coverLatticePoint Γ d hd (d • y) = 0 + apply Subtype.ext + rw [coverLatticePoint_val] + change QuotientAddGroup.mk' Γ ((d : ℝ)⁻¹ • (d • y.val)) = 0 + rw [← Nat.cast_smul_eq_nsmul ℝ, smul_smul, + inv_mul_cancel₀ (by exact_mod_cast hd.ne'), one_smul] + exact (QuotientAddGroup.eq_zero_iff _).mpr y.property + +abbrev CoverLatticeResidue (d : ℕ) := Γ ⧸ (nsmulAddMonoidHom (α := Γ) d).range + +noncomputable def coverLatticeResidueEquiv (d : ℕ) (hd : 0 < d) : + CoverLatticeResidue Γ d ≃+ (quotientIntegerCover Γ d).ker := + (QuotientAddGroup.quotientAddEquivOfEq (coverLatticePoint_ker Γ d hd)).symm.trans + (QuotientAddGroup.quotientKerEquivOfSurjective (coverLatticePoint Γ d hd) + (coverLatticePoint_surjective Γ d hd)) + +theorem coverLatticeResidueEquiv_mk (d : ℕ) (hd : 0 < d) (x : Γ) : + coverLatticeResidueEquiv Γ d hd (QuotientAddGroup.mk' _ x) = + coverLatticePoint Γ d hd x := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {E I : Type*} [AddCommGroup E] [Module ℝ E] [Fintype I] +variable (Γ : AddSubgroup E) (b : Basis I ℤ Γ) + +noncomputable def latticeBasisResidue (d : ℕ) : Γ →+ (I → ZMod d) := + (integerResidueMap I d).toAddMonoidHom.comp b.equivFun.toAddMonoidHom + +omit [Module ℝ E] in +theorem latticeBasisResidue_surjective (d : ℕ) : + Function.Surjective (latticeBasisResidue Γ b d) := + (integerResidueMap_surjective I d).comp b.equivFun.surjective + +omit [Module ℝ E] in +theorem latticeBasisResidue_ker (d : ℕ) : + (latticeBasisResidue Γ b d).ker = (nsmulAddMonoidHom (α := Γ) d).range := by + ext x + constructor + · intro hx + have hz : b.equivFun x ∈ integerScalarLattice I (d : ℤ) := by + rw [← integerResidueMap_ker] + exact hx + obtain ⟨z, hz⟩ := (integerScalarLattice_mem _ _).mp hz + refine ⟨b.equivFun.symm z, ?_⟩ + apply b.equivFun.injective + change b.equivFun (d • b.equivFun.symm z) = b.equivFun x + rw [map_nsmul, LinearEquiv.apply_symm_apply] + simpa only [natCast_zsmul] using hz + · rintro ⟨y, rfl⟩ + change integerResidueMap I d (b.equivFun (d • y)) = 0 + have hz : b.equivFun (d • y) ∈ integerScalarLattice I (d : ℤ) := by + apply (integerScalarLattice_mem _ _).mpr + exact ⟨b.equivFun y, by simp only [map_nsmul, natCast_zsmul]⟩ + rw [← integerResidueMap_ker] at hz + exact hz + +noncomputable def coverLatticeBasisEquiv (d : ℕ) : + CoverLatticeResidue Γ d ≃+ (I → ZMod d) := + (QuotientAddGroup.quotientAddEquivOfEq (latticeBasisResidue_ker Γ b d)).symm.trans + (QuotientAddGroup.quotientKerEquivOfSurjective (latticeBasisResidue Γ b d) + (latticeBasisResidue_surjective Γ b d)) + +omit [Module ℝ E] in +theorem coverLatticeBasisEquiv_mk (d : ℕ) (x : Γ) : + coverLatticeBasisEquiv Γ b d (QuotientAddGroup.mk' _ x) = + latticeBasisResidue Γ b d x := rfl + +noncomputable def coverKernelBasisEquiv (d : ℕ) (hd : 0 < d) : + (I → ZMod d) ≃+ (quotientIntegerCover Γ d).ker := + (coverLatticeBasisEquiv Γ b d).symm.trans (coverLatticeResidueEquiv Γ d hd) + +theorem coverKernelBasisEquiv_residue (d : ℕ) (hd : 0 < d) (x : Γ) : + coverKernelBasisEquiv Γ b d hd (latticeBasisResidue Γ b d x) = + coverLatticePoint Γ d hd x := by + rw [← coverLatticeBasisEquiv_mk] + simp only [coverKernelBasisEquiv, AddEquiv.trans_apply, AddEquiv.symm_apply_apply] + exact coverLatticeResidueEquiv_mk Γ d hd x + +include b in +theorem coverKernel_card (d : ℕ) (hd : 0 < d) : + Nat.card (quotientIntegerCover Γ d).ker = d ^ Fintype.card I := by + calc + _ = Nat.card (I → ZMod d) := Nat.card_congr (coverKernelBasisEquiv Γ b d hd).symm.toEquiv + _ = (Nat.card (ZMod d)) ^ Nat.card I := Nat.card_fun + _ = _ := by rw [Nat.card_zmod, Nat.card_eq_fintype_card] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CoveredResidueDensityComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CoveredResidueDensityComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..51f88eae1f42b9de0c7d57e4581b1a8ba5ad012e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CoveredResidueDensityComparison.lean @@ -0,0 +1,173 @@ +import OAI.Combinatorics.Progressions.Lattices.PhysicalResidueOffsetShift + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory +open scoped BigOperators Matrix + +variable {K X α : Type*} [Fintype K] [DecidableEq K] [Fintype X] + [Fintype α] [DecidableEq α] + +theorem selectedResidue_physical_product_test_error + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (s : (Unit ⊕ α) ↪ Option K) + (hM : ((physicalCubeCoefficient root D).submatrix id s).det ≠ 0) + (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (T : Finset (ColumnResiduePattern (Option K) X modulus)) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) + (P : X → (Unit ⊕ α) → ℝ) (hP : ∀ x i, 0 < P x i) (hP1 : ∀ x i, 1 ≤ P x i) + (ha : ∀ r : T, ∀ z, |residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus z| ≤ + residueProfileWidth modulus V z) + (hentry : ∀ x i k, |normalizedIntegerColumns (physicalCubeCoefficient root D) + (fun k => residueProfileWidth modulus V (k, x)) (P x) i k| ≤ 1) + (ε : T → X → ℝ) + (he : ∀ (r : T) x v, |(∏ i, P x i) * + (((shiftedSmoothProductPMF + (fun k => residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus (k, x)) + (fun k => residueProfileWidth modulus V (k, x)) + (fun k => residueProfileWidth_pos modulus V hmodulus hV (k, x)) + (shiftedSmoothProductMass_slice_pos _ _ (residueProfileWidth_pos modulus V hmodulus hV) (hc r) x)).map + (fun z => physicalCubeCoefficient root D *ᵥ z)) v).toReal - + coefficientImageMask (physicalCubeCoefficient root D) (P x) + (selectedCoefficientDensity (physicalCubeCoefficient root D) s hM + (fun k => residueProfileWidth modulus V (k, x)) (P x) + (fun k => residueProfileWidth_pos modulus V hmodulus hV (k, x)) (hP x) + (shiftedUnitProfile + (fun k => residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus (k, x)) + (fun k => residueProfileWidth modulus V (k, x)))) v| ≤ ε r x) + (hsmall : ∀ r, (∑ x, shiftedMatrixCountFactor (Unit ⊕ α) (Option K) * ε r x) ≤ 1) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {B : ℝ} (hB : 0 ≤ B) (hφ : ∀ v, ‖φ v‖ ≤ B) : + ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) - + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∫ v, (shiftedProductGridProxy (fun _ : X => physicalCubeCoefficient root D) + (fun _ => s) (fun _ => hM) + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V) P (residueProfileWidth_pos modulus V hmodulus hV) hP v : ℂ) * + φ (physicalResidueReconstruct root D base (boundedColumnResidueRepresentative modulus r.val) + modulus v) ∂Measure.count‖ ≤ + B * ∑ r : T, selectedResidueCellWeight modulus T V r * + (2 * ∑ x, shiftedMatrixCountFactor (Unit ⊕ α) (Option K) * ε r x) := by + apply selectedResidue_physical_index_test_error root D base modulus hmodulus T V hV hZ hc + (fun r => shiftedProductGridProxy (fun _ : X => physicalCubeCoefficient root D) + (fun _ => s) (fun _ => hM) + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V) P (residueProfileWidth_pos modulus V hmodulus hV) hP) + (fun r => shiftedProductGridProxy_integrable _ _ _ _ _ _ _ _ (ha r) hentry) + (fun r => 2 * ∑ x, shiftedMatrixCountFactor (Unit ⊕ α) (Option K) * ε r x) hB _ φ hφ + intro r + exact shiftedProductImage_count_error (fun _ : X => physicalCubeCoefficient root D) + (fun _ => s) (fun _ => hM) _ _ P (residueProfileWidth_pos modulus V hmodulus hV) hP hP1 + (ha r) (hc r) hentry (ε r) (he r) (hsmall r) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators Matrix + +theorem selectedResidue_covered_product_comparison + {I K F : Type*} [Fintype I] [Fintype K] [DecidableEq K] [Fintype F] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (difference : Fin q → K → ℤ) (D : ℕ) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ) (c : F → ℂ) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) + (base : I → ℤ) (modulus : I → ℕ) + (T : Finset (ColumnResiduePattern (Option K) I modulus)) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (density : (Option K × I → ℤ) → ℝ) + {η δ : ℝ} (hη : 0 ≤ η) + (happrox : ∀ z ∈ rectangularWeightIndices 0 V 1, + ‖(density z : ℂ) - affineCubeFourierSum frequency + (fun j => translate (fun i => (base i : ℝ)) (p j)) c (fun k i => (z (k, i) : ℝ))‖ ≤ η) + (hprojection : + ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + (layeredSiteWeight 0 (fun s => affineSite root difference s) + (fun s x => test s ((fun i => (base i : ℝ)) + x)) (fun k i => (z (k, i) : ℝ)) * + affineCubeFourierSum frequency (fun j => translate (fun i => (base i : ℝ)) (p j)) c + (fun k i => (z (k, i) : ℝ)))) - + (∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + (layeredSiteWeight 0 (fun s => affineSite root difference s) + (fun s x => test s ((fun i => (base i : ℝ)) + x)) (fun k i => (z (k, i) : ℝ)) * + retainedSiteFourierSum U root difference frequency b c + (affineCoveredSiteSample U root difference D + (fun j => translate (fun i => (base i : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun i => (base i : ℝ)) (p j) (hm j)) + (fun k i => (z (k, i) : ℝ)))))‖ ≤ δ) + (s : (Unit ⊕ (Fin q)) ↪ Option K) + (hM : ((physicalCubeCoefficient root (Matrix.of difference)).submatrix id s).det ≠ 0) + (hmodulus : ∀ x, 0 < modulus x) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) + (P : I → (Unit ⊕ (Fin q)) → ℝ) (hP : ∀ x i, 0 < P x i) (hP1 : ∀ x i, 1 ≤ P x i) + (ha : ∀ r : T, ∀ z, |residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus z| ≤ + residueProfileWidth modulus V z) + (hentry : ∀ x i k, |normalizedIntegerColumns (physicalCubeCoefficient root (Matrix.of difference)) + (fun k => residueProfileWidth modulus V (k, x)) (P x) i k| ≤ 1) + (ε : T → I → ℝ) + (he : ∀ (r : T) x v, |(∏ i, P x i) * + (((shiftedSmoothProductPMF + (fun k => residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus (k, x)) + (fun k => residueProfileWidth modulus V (k, x)) + (fun k => residueProfileWidth_pos modulus V hmodulus hV (k, x)) + (shiftedSmoothProductMass_slice_pos _ _ (residueProfileWidth_pos modulus V hmodulus hV) (hc r) x)).map + (fun z => physicalCubeCoefficient root (Matrix.of difference) *ᵥ z)) v).toReal - + coefficientImageMask (physicalCubeCoefficient root (Matrix.of difference)) (P x) + (selectedCoefficientDensity (physicalCubeCoefficient root (Matrix.of difference)) s hM + (fun k => residueProfileWidth modulus V (k, x)) (P x) + (fun k => residueProfileWidth_pos modulus V hmodulus hV (k, x)) (hP x) + (shiftedUnitProfile + (fun k => residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus (k, x)) + (fun k => residueProfileWidth modulus V (k, x)))) v| ≤ ε r x) + (hsmall : ∀ r, (∑ x, shiftedMatrixCountFactor (Unit ⊕ (Fin q)) (Option K) * ε r x) ≤ 1) + {Z : ℝ} (hZnorm : 0 < Z) : + ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences root (Matrix.of difference) base z) * + (density z : ℂ))) / (Z : ℂ) - + (∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∫ v, (shiftedProductGridProxy (fun _ : I => physicalCubeCoefficient root (Matrix.of difference)) + (fun _ => s) (fun _ => hM) + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V) P (residueProfileWidth_pos modulus V hmodulus hV) hP v : ℂ) * + physicalCubeCoveredTest U root difference D p hm frequency b c test + (physicalResidueReconstruct root (Matrix.of difference) base + (boundedColumnResidueRepresentative modulus r.val) modulus v) ∂Measure.count) / (Z : ℂ)‖ ≤ + (η + δ + (∑ a, ‖c a‖) * ∑ r : T, selectedResidueCellWeight modulus T V r * + (2 * ∑ x, shiftedMatrixCountFactor (Unit ⊕ Fin q) (Option K) * ε r x)) / Z := by + have hfirst := selectedResidue_density_projection_error U root difference D p hm frequency b c test htest + base modulus T V hV hZ density hη happrox hprojection + simp only [layeredSiteWeight_physicalCube] at hfirst + have hsecond := selectedResidue_physical_product_test_error root (Matrix.of difference) base s hM + modulus hmodulus T V hV hZ hc P hP hP1 ha hentry ε he hsmall + (physicalCubeCoveredTest U root difference D p hm frequency b c test) + (Finset.sum_nonneg (fun a _ => norm_nonneg (c a))) + (fun v => physicalCubeCoveredTest_norm_le U root difference D p hm frequency b c test htest v) + have h := (norm_sub_le_norm_sub_add_norm_sub _ + (∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + physicalCubeCoveredTest U root difference D p hm frequency b c test + (physicalCubeRootDifferences root (Matrix.of difference) base z)) _).trans (add_le_add hfirst hsecond) + rw [← sub_div, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hZnorm] + exact div_le_div_of_nonneg_right h hZnorm.le + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CubeResidueMixture.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CubeResidueMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..13770f3384ac093a46b4692d958c6075050eaa32 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CubeResidueMixture.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Probability.RawWeightCellMixture +import OAI.Combinatorics.Progressions.Probability.RefinedSliceLaws + +namespace OAI + +section + +namespace Erdos3.FiniteCubeSlice + +open scoped BigOperators Classical + +theorem refineResidues_mixture {q : ℕ} (s : FiniteCubeSlice q) + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) + (w : (Option (Fin q) → ℤ) → ℝ) (hw : ∀ z, 0 ≤ w z) + (htotal : 0 < ∑ x : s.Domain, w (s.coordinates x)) + (S : Finset (s.ResidueLabel n)) + (hchild : ∀ r : S, 0 < ∑ x : (s.refineResidues n r.val).Domain, + w ((s.refineResidues n r.val).coordinates x)) (f : (Option (Fin q) → ℤ) → ℂ) : + let p := FiniteProbabilityWeights.ofPositiveWeights + (fun x : s.Domain => w (s.coordinates x)) (fun x => hw (s.coordinates x)) htotal + (∑ r : S, (p.mass (Finset.univ.filter (fun x => s.residueLabelMap n x = r.val)) : ℂ) * + (FiniteProbabilityWeights.ofPositiveWeights + (fun x : (s.refineResidues n r.val).Domain => w ((s.refineResidues n r.val).coordinates x)) + (fun x => hw ((s.refineResidues n r.val).coordinates x)) (hchild r)).complexMean + (fun x => f ((s.refineResidues n r.val).coordinates x))) = + p.complexMean (fun x => if s.residueLabelMap n x ∈ S then f (s.coordinates x) else 0) := by + exact FiniteProbabilityWeights.embedded_cell_mixture + (fun x : s.Domain => w (s.coordinates x)) (fun x => hw (s.coordinates x)) htotal + (s.residueLabelMap n) S (fun r => (s.refineResidues n r.val).Domain) + (fun r => s.refineResiduesEmbedding n hdvd r.val) + (fun r => s.refineResiduesEmbedding_range n hdvd r.val) hchild (fun x => f (s.coordinates x)) + +noncomputable def retainedRefinementLaw {q : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) + (w : (Option (Fin q) → ℤ) → ℝ) (hw : ∀ z, 0 ≤ w z) {η : ℝ} (hη : 0 < η) + (r : s.ResidueLabel n) (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers + (s.residueLabelMap n) (fun x => w (s.coordinates x)) η) : + FiniteProbabilityWeights (s.refineResidues n r).Domain := + FiniteProbabilityWeights.ofPositiveWeights + (fun x => w ((s.refineResidues n r).coordinates x)) + (fun x => hw ((s.refineResidues n r).coordinates x)) + (s.retained_refineResidues_total_pos n hdvd r w hη hr) + +theorem retainedRefinementLaw_mixture_error {q : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) + (w : (Option (Fin q) → ℤ) → ℝ) (hw : ∀ z, 0 ≤ w z) + (htotal : 0 < ∑ x : s.Domain, w (s.coordinates x)) + (hm : 0 < (FiniteProbabilityWeights.uniform s.Domain).mean (fun x => w (s.coordinates x))) + {η : ℝ} (hη : 0 < η) (f : (Option (Fin q) → ℤ) → ℂ) (hf : ∀ z, ‖f z‖ ≤ 1) : + let S := Finset.univ \ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers + (s.residueLabelMap n) (fun x => w (s.coordinates x)) η + let p := FiniteProbabilityWeights.ofPositiveWeights + (fun x : s.Domain => w (s.coordinates x)) (fun x => hw (s.coordinates x)) htotal + ‖p.complexMean (fun x => f (s.coordinates x)) - + ∑ r : S, (p.mass (Finset.univ.filter (fun x => s.residueLabelMap n x = r.val)) : ℂ) * + (s.retainedRefinementLaw n hdvd w hw hη r.val (Finset.mem_sdiff.mp r.property).2).complexMean + (fun x => f ((s.refineResidues n r.val).coordinates x))‖ ≤ + η / (FiniteProbabilityWeights.uniform s.Domain).mean (fun x => w (s.coordinates x)) := by + dsimp only + exact FiniteProbabilityWeights.embedded_lowWeight_cell_mixture_error + (fun x : s.Domain => w (s.coordinates x)) (fun x => hw (s.coordinates x)) htotal hm + (s.residueLabelMap n) hη.le _ rfl (fun r => (s.refineResidues n r.val).Domain) + (fun r => s.refineResiduesEmbedding n hdvd r.val) + (fun r => s.refineResiduesEmbedding_range n hdvd r.val) + (fun r => s.retained_refineResidues_total_pos n hdvd r.val w hη (Finset.mem_sdiff.mp r.property).2) + (fun x => f (s.coordinates x)) (fun x => hf (s.coordinates x)) + +end Erdos3.FiniteCubeSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CubeResidueSupport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CubeResidueSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..571048aed066ddfc64047680082bec7ac13eb955 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CubeResidueSupport.lean @@ -0,0 +1,577 @@ +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Data.Int.Interval +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Estimates.DeterminantCutoffScale +import OAI.Combinatorics.Progressions.Estimates.FiniteProductDomination +import OAI.Combinatorics.Progressions.Estimates.IndependentFiniteConditioning +import OAI.Combinatorics.Progressions.Estimates.ScalarCubeDomain +import OAI.Combinatorics.Progressions.Geometry.SupportedCubeEquivTransport +import OAI.Combinatorics.Progressions.Probability.BoxCokernelProbability + +namespace OAI + + +namespace Erdos3 + +open scoped BigOperators + +def integerScalarCubeValue {I : Type*} [Fintype I] (x : Option I → ℤ) (t : Finset I) : ℤ := + x none + ∑ i ∈ t, x (some i) + +def IntegerScalarCube {I : Type*} [Fintype I] (L : ℕ) (x : Option I → ℤ) : Prop := + ∀ t : Finset I, 0 ≤ integerScalarCubeValue x t ∧ integerScalarCubeValue x t < L + +abbrev IntegerScalarCubeBox (I : Type*) (L : ℕ) := + Option I → Finset.Ico (-(L : ℤ)) (L : ℤ) + +noncomputable def integerScalarCubeSet (I : Type*) [Fintype I] (L : ℕ) : + Finset (IntegerScalarCubeBox I L) := by + classical + exact Finset.univ.filter (fun x => IntegerScalarCube L (fun i => (x i : ℤ))) + +theorem mem_integerScalarCubeSet {I : Type*} [Fintype I] (L : ℕ) + (x : IntegerScalarCubeBox I L) : + x ∈ integerScalarCubeSet I L ↔ IntegerScalarCube L (fun i => (x i : ℤ)) := by + classical + simp [integerScalarCubeSet] + +theorem integerScalarCube_coordinates {I : Type*} [Fintype I] [DecidableEq I] + {L : ℕ} {x : Option I → ℤ} (hx : IntegerScalarCube L x) (i : Option I) : + -(L : ℤ) < x i ∧ x i < L := by + have h0 := hx ∅ + simp only [integerScalarCubeValue, Finset.sum_empty, add_zero] at h0 + cases i with + | none => omega + | some i => + have h1 := hx {i} + simp only [integerScalarCubeValue, Finset.sum_singleton] at h1 + omega + +theorem integerScalarCubeValue_cast {I : Type*} [Fintype I] [DecidableEq I] + (x : Option I → ℤ) (t : Finset I) : + scalarCubeValue (fun i => (x i : ℝ)) t = (integerScalarCubeValue x t : ℝ) := by + simp [scalarCubeValue, integerScalarCubeValue, Fintype.sum_option, booleanFeature, ite_mul] + +theorem integerScalarCube_small_positive {I : Type*} [Fintype I] {L H : ℕ} + (hH : 0 < H) (hHL : (Fintype.card I + 1) * H ≤ L) (x : Option I → Fin H) : + IntegerScalarCube L (fun i => ((x i).val : ℤ)) := by + intro t + have ht : t.card ≤ Fintype.card I := Finset.card_le_univ t + have hx (i : Option I) : (0 : ℤ) ≤ (x i).val ∧ ((x i).val : ℤ) ≤ (H : ℤ) - 1 := by + exact ⟨Nat.cast_nonneg _, by have := (x i).isLt; omega⟩ + have hsum0 : (0 : ℤ) ≤ ∑ i ∈ t, ((x (some i)).val : ℤ) := + Finset.sum_nonneg (fun i _ => (hx (some i)).1) + have hsum : (∑ i ∈ t, ((x (some i)).val : ℤ)) ≤ (t.card : ℤ) * ((H : ℤ) - 1) := by + simpa only [Finset.sum_const, nsmul_eq_mul] using + (Finset.sum_le_sum (fun i (_ : i ∈ t) => (hx (some i)).2)) + have hHL' : ((Fintype.card I : ℤ) + 1) * H ≤ L := by exact_mod_cast hHL + have ht' : (t.card : ℤ) ≤ Fintype.card I := by exact_mod_cast ht + have hH' : (1 : ℤ) ≤ H := by exact_mod_cast hH + dsimp [integerScalarCubeValue] + constructor + · exact add_nonneg (hx none).1 hsum0 + · have h0 := (hx none).2 + have hmul := mul_le_mul_of_nonneg_right ht' (sub_nonneg.mpr hH') + nlinarith [show (0 : ℤ) ≤ Fintype.card I from Nat.cast_nonneg _] + +end Erdos3 + + +namespace Erdos3 + +def integerScalarCubeBoxZero (I : Type*) (L : ℕ) (hL : 0 < L) : IntegerScalarCubeBox I L := + fun _ => ⟨0, Finset.mem_Ico.mpr ⟨by omega, by exact_mod_cast hL⟩⟩ + +theorem integerScalarCubeSet_nonempty (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) (hL : 0 < L) : + (integerScalarCubeSet I L).Nonempty := by + refine ⟨integerScalarCubeBoxZero I L hL, (mem_integerScalarCubeSet L _).mpr ?_⟩ + intro t + simp only [integerScalarCubeValue, integerScalarCubeBoxZero, Finset.sum_const_zero, add_zero] + exact ⟨le_rfl, by exact_mod_cast hL⟩ + +theorem integerScalarCubeBox_card (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) : + Fintype.card (IntegerScalarCubeBox I L) = (2 * L) ^ (Fintype.card I + 1) := by + change Fintype.card (Option I → Finset.Ico (-(L : ℤ)) (L : ℤ)) = _ + rw [Fintype.card_fun, Fintype.card_option, Fintype.card_coe, Int.card_Ico] + congr 1 + omega + +theorem integerScalarCubeSet_card_lower (I : Type*) [Fintype I] [DecidableEq I] (L H : ℕ) + (hH : 0 < H) (hHL : (Fintype.card I + 1) * H ≤ L) : + H ^ (Fintype.card I + 1) ≤ (integerScalarCubeSet I L).card := by + classical + have hHL' : H ≤ L := by nlinarith + let point (x : Option I → Fin H) : IntegerScalarCubeBox I L := fun i => + ⟨((x i).val : ℤ), Finset.mem_Ico.mpr ⟨by omega, by have := (x i).isLt; omega⟩⟩ + have hpoint (x : Option I → Fin H) : point x ∈ integerScalarCubeSet I L := + (mem_integerScalarCubeSet L _).mpr (integerScalarCube_small_positive hH hHL x) + let e : (Option I → Fin H) → ↥(integerScalarCubeSet I L) := fun x => ⟨point x, hpoint x⟩ + have he : Function.Injective e := by + intro x y h + funext i + apply Fin.ext + have hi := congrArg (fun z : ↥(integerScalarCubeSet I L) => (z.val i : ℤ)) h + change ((x i).val : ℤ) = ((y i).val : ℤ) at hi + exact_mod_cast hi + have hc := Fintype.card_le_of_injective e he + simpa only [Fintype.card_fun, Fintype.card_option, Fintype.card_fin, Fintype.card_coe] using hc + +theorem nat_div_half_lower {L n : ℕ} (hn : 0 < n) (hL : n ≤ L) : + L ≤ 2 * n * (L / n) := by + have hd : 0 < L / n := Nat.div_pos hL hn + have hm := Nat.mod_lt L hn + have he := Nat.div_add_mod L n + nlinarith + + +theorem integerScalarCube_iff_supported (q L : ℕ) (x : Option (Fin q) → ℤ) : + IntegerScalarCube L x ↔ ∀ ω : Fin q → Bool, + x none + cubeShift (fun i => x (some i)) ω ∈ Set.Ico (0 : ℤ) (L : ℤ) := by + classical + constructor + · intro h ω + have hx := h (Finset.univ.filter (fun i => ω i)) + simpa only [integerScalarCubeValue, Finset.sum_filter, cubeShift, Set.mem_Ico] using hx + · intro h t + have hx := h (fun i => decide (i ∈ t)) + simpa [integerScalarCubeValue, cubeShift] using hx + +noncomputable def integerScalarCubeEquiv (q L : ℕ) : + ↥(integerScalarCubeSet (Fin q) L) ≃ SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ)) where + toFun x := ⟨(fun i => (x.val (some i) : ℤ), (x.val none : ℤ)), + (integerScalarCube_iff_supported q L _).mp ((mem_integerScalarCubeSet L _).mp x.property)⟩ + invFun p := by + let v : Option (Fin q) → ℤ := fun | none => p.val.2 | some i => p.val.1 i + have hv : IntegerScalarCube L v := (integerScalarCube_iff_supported q L v).mpr p.property + let x : IntegerScalarCubeBox (Fin q) L := fun i => + ⟨v i, Finset.mem_Ico.mpr ⟨(integerScalarCube_coordinates hv i).1.le, + (integerScalarCube_coordinates hv i).2⟩⟩ + exact ⟨x, (mem_integerScalarCubeSet L x).mpr hv⟩ + left_inv x := by + apply Subtype.ext + funext i + apply Subtype.ext + cases i <;> rfl + right_inv p := by + apply Subtype.ext + rfl + + +noncomputable def integerScalarCubeReference (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) (hL : 0 < L) : + FiniteProbabilityWeights (IntegerScalarCubeBox I L) := by + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + exact FiniteProbabilityWeights.uniform _ + +theorem integerScalarCubeReference_mass (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) (hL : 0 < L) : + (integerScalarCubeReference I L hL).mass (integerScalarCubeSet I L) = + ((integerScalarCubeSet I L).card : ℝ) / Fintype.card (IntegerScalarCubeBox I L) := by + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + unfold integerScalarCubeReference + exact FiniteProbabilityWeights.uniform_mass _ + +theorem integerScalarCubeReference_mass_pos (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) (hL : 0 < L) : + 0 < (integerScalarCubeReference I L hL).mass (integerScalarCubeSet I L) := by + rw [integerScalarCubeReference_mass, integerScalarCubeBox_card] + exact div_pos (by exact_mod_cast (integerScalarCubeSet_nonempty I L hL).card_pos) + (by positivity) + +noncomputable def integerScalarCubeDensityCap (I : Type*) [Fintype I] : ℝ := + (4 * (Fintype.card I + 1 : ℕ) : ℝ) ^ (Fintype.card I + 1) + +theorem integerScalarCubeDensityCap_pos (I : Type*) [Fintype I] : + 0 < integerScalarCubeDensityCap I := by + unfold integerScalarCubeDensityCap + positivity + +theorem integerScalarCubeReference_mass_lower (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) (hL : 0 < L) + (hsize : Fintype.card I + 1 ≤ L) : + (integerScalarCubeDensityCap I)⁻¹ ≤ + (integerScalarCubeReference I L hL).mass (integerScalarCubeSet I L) := by + let n := Fintype.card I + 1 + let H := L / n + have hn : 0 < n := by dsimp [n]; omega + have hH : 0 < H := Nat.div_pos hsize hn + have hHL : n * H ≤ L := Nat.mul_div_le L n + have hc := integerScalarCubeSet_card_lower I L H hH hHL + have hfloor : (L : ℝ) ≤ 2 * (n : ℝ) * (H : ℝ) := by + exact_mod_cast nat_div_half_lower hn hsize + have hratio : 1 / (4 * (n : ℝ)) ≤ (H : ℝ) / (2 * (L : ℝ)) := by + apply (div_le_div_iff₀ (by positivity) (by positivity)).mpr + nlinarith + calc + _ = (1 / (4 * (n : ℝ))) ^ n := by + simp only [integerScalarCubeDensityCap, n, one_div, inv_pow] + _ ≤ ((H : ℝ) / (2 * (L : ℝ))) ^ n := pow_le_pow_left₀ (by positivity) hratio n + _ = (H : ℝ) ^ n / (2 * (L : ℝ)) ^ n := div_pow _ _ _ + _ ≤ _ := by + rw [integerScalarCubeReference_mass, integerScalarCubeBox_card] + push_cast + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast hc + +noncomputable def integerScalarCubeWeights (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) (hL : 0 < L) : + FiniteProbabilityWeights (IntegerScalarCubeBox I L) := by + classical + exact (integerScalarCubeReference I L hL).condition (integerScalarCubeSet I L) + (integerScalarCubeReference_mass_pos I L hL) + +theorem integerScalarCubeWeights_weight_le (I : Type*) [Fintype I] [DecidableEq I] (L : ℕ) (hL : 0 < L) + (hsize : Fintype.card I + 1 ≤ L) (x : IntegerScalarCubeBox I L) : + (integerScalarCubeWeights I L hL).weight x ≤ + integerScalarCubeDensityCap I * (Fintype.card (IntegerScalarCubeBox I L) : ℝ)⁻¹ := by + classical + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + have h := FiniteProbabilityWeights.uniform_condition_weight_le (integerScalarCubeSet I L) + (integerScalarCubeReference_mass_pos I L hL) ((integerScalarCubeDensityCap I)⁻¹) + (inv_pos.mpr (integerScalarCubeDensityCap_pos I)) + (integerScalarCubeReference_mass_lower I L hL hsize) x + simpa only [integerScalarCubeWeights, integerScalarCubeReference, inv_inv] using h + + +noncomputable def scalarCubeResidueSet (I : Type*) [Fintype I] (L : ℕ) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) : Finset (IntegerScalarCubeBox I L) := by + classical + exact Finset.univ.filter (fun x => ∀ i, ((x i : ℤ) : ZMod (m i)) = r i) + +theorem mem_scalarCubeResidueSet {I : Type*} [Fintype I] (L : ℕ) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (x : IntegerScalarCubeBox I L) : + x ∈ scalarCubeResidueSet I L m r ↔ ∀ i, ((x i : ℤ) : ZMod (m i)) = r i := by + classical + simp only [scalarCubeResidueSet, Finset.mem_filter, Finset.mem_univ, true_and] + +theorem scalarResiduePoint_bound (m H : ℕ) (hm : 0 < m) (r : ZMod m) (x : Fin H) : + r.val + m * x.val < m * H := by + let : NeZero m := ⟨hm.ne'⟩ + have hr := ZMod.val_lt r + have hx := x.isLt + nlinarith + +theorem scalarResiduePoint_cast (m : ℕ) (hm : 0 < m) (r : ZMod m) (x : ℕ) : + ((r.val + m * x : ℕ) : ZMod m) = r := by + let : NeZero m := ⟨hm.ne'⟩ + simp + +theorem scalarCubeResidueSet_card_lower (I : Type*) [Fintype I] [DecidableEq I] + (L M H : ℕ) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) (hH : 0 < H) + (hbudget : (Fintype.card I + 1) * (M * H) ≤ L) : + H ^ (Fintype.card I + 1) ≤ ((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r).card := by + classical + have hM : 0 < M := (hm none).trans_le (hmM none) + have hML : M * H ≤ L := by nlinarith + let point (x : Option I → Fin H) (i : Option I) : Fin (M * H) := + ⟨(r i).val + m i * (x i).val, + (scalarResiduePoint_bound (m i) H (hm i) (r i) (x i)).trans_le (Nat.mul_le_mul_right H (hmM i))⟩ + let tuple (x : Option I → Fin H) : IntegerScalarCubeBox I L := fun i => + ⟨((point x i).val : ℤ), Finset.mem_Ico.mpr + ⟨by omega, by have := (point x i).isLt; omega⟩⟩ + have hmem (x : Option I → Fin H) : + tuple x ∈ (integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r := by + apply Finset.mem_inter.mpr + constructor + · exact (mem_integerScalarCubeSet L _).mpr + (integerScalarCube_small_positive (Nat.mul_pos hM hH) hbudget (point x)) + · apply (mem_scalarCubeResidueSet L m r _).mpr + intro i + change ((((r i).val + m i * (x i).val : ℕ) : ℤ) : ZMod (m i)) = r i + simpa only [Int.cast_natCast] using scalarResiduePoint_cast (m i) (hm i) (r i) (x i).val + let e : (Option I → Fin H) → ↥((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r) := + fun x => ⟨tuple x, hmem x⟩ + have he : Function.Injective e := by + intro x y h + funext i + apply Fin.ext + have hi := congrArg (fun z : ↥((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r) => + (z.val i : ℤ)) h + change (((r i).val + m i * (x i).val : ℕ) : ℤ) = (((r i).val + m i * (y i).val : ℕ) : ℤ) at hi + have hi' : (r i).val + m i * (x i).val = (r i).val + m i * (y i).val := by exact_mod_cast hi + exact mul_left_cancel₀ (hm i).ne' (Nat.add_left_cancel hi') + have hc := Fintype.card_le_of_injective e he + simpa only [Fintype.card_fun, Fintype.card_option, Fintype.card_fin, Fintype.card_coe] using hc + + +open scoped BigOperators Classical + +theorem integerScalarCubeWeights_root_bounds {α : Type*} [Fintype α] [DecidableEq α] + {H : ℕ} (hH : 0 < H) (z : IntegerScalarCubeBox α H) + (hz : (integerScalarCubeWeights α H hH).weight z ≠ 0) : + 0 ≤ (z none : ℤ) ∧ (z none : ℤ) ≤ ((H - 1 : ℕ) : ℤ) := by + have hmem : z ∈ integerScalarCubeSet α H := by + by_contra hn + apply hz + simp only [integerScalarCubeWeights, FiniteProbabilityWeights.condition, + hn, ite_false, zero_div] + have hr := ((mem_integerScalarCubeSet H z).mp hmem) ∅ + simp only [integerScalarCubeValue, Finset.sum_empty, add_zero] at hr + exact ⟨hr.1, by omega⟩ + +theorem integerScalarCubePi_root_bounds {G : Type*} [Fintype G] + (H : G → ℕ) (hH : ∀ g, 0 < H g) + (z : ∀ g, IntegerScalarCubeBox Empty (H g)) + (hz : (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight z ≠ 0) + (g : G) : + 0 ≤ (z g none : ℤ) ∧ (z g none : ℤ) ≤ ((H g - 1 : ℕ) : ℤ) := by + apply integerScalarCubeWeights_root_bounds (hH g) (z g) + change (∏ g, (integerScalarCubeWeights Empty (H g) (hH g)).weight (z g)) ≠ 0 at hz + exact Finset.prod_ne_zero_iff.mp hz g (Finset.mem_univ g) + +theorem integerScalarCubePi_root_real_bounds {G : Type*} [Fintype G] + (H : G → ℕ) (hH : ∀ g, 0 < H g) + (z : ∀ g, IntegerScalarCubeBox Empty (H g)) + (hz : (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight z ≠ 0) + (g : G) : + 0 ≤ ((z g none : ℤ) : ℝ) ∧ ((z g none : ℤ) : ℝ) ≤ ((H g - 1 : ℕ) : ℝ) := by + have hb := integerScalarCubePi_root_bounds H hH z hz g + exact ⟨by exact_mod_cast hb.1, by exact_mod_cast hb.2⟩ + +theorem affineKernelEndpoint_error {H S step z : ℝ} (lower : ℝ) + (hH : 0 < H) (hS : 0 < S) (hz0 : 0 ≤ z) (hzH : z ≤ H - 1) + (hstep : 0 ≤ step) (hwidth : step * (H - 1) ≤ S) : + |(lower + step * z) / S - (lower + step * (H - 1) * (z / H)) / S| ≤ 1 / H := by + have he : (lower + step * z) / S - (lower + step * (H - 1) * (z / H)) / S = + (step * z / S) / H := by + field_simp + ring + rw [he, abs_of_nonneg (div_nonneg (div_nonneg (mul_nonneg hstep hz0) hS.le) hH.le)] + apply div_le_div_of_nonneg_right _ hH.le + apply (div_le_one hS).mpr + exact (mul_le_mul_of_nonneg_left hzH hstep).trans hwidth + +theorem affineKernelEndpoint_error_nat {H : ℕ} {S step z : ℝ} (lower : ℝ) + (hH : 0 < H) (hS : 0 < S) (hz0 : 0 ≤ z) (hzH : z ≤ ((H - 1 : ℕ) : ℝ)) + (hstep : 0 ≤ step) (hwidth : step * ((H - 1 : ℕ) : ℝ) ≤ S) : + |(lower + step * z) / S - + (lower + step * ((H - 1 : ℕ) : ℝ) * (z / H)) / S| ≤ 1 / H := by + have hcast : ((H - 1 : ℕ) : ℝ) = (H : ℝ) - 1 := by + rw [Nat.cast_sub (by omega : 1 ≤ H), Nat.cast_one] + rw [hcast] at hzH hwidth ⊢ + exact affineKernelEndpoint_error lower (Nat.cast_pos.mpr hH) hS hz0 hzH hstep hwidth + +end Erdos3 + + +namespace Erdos3 + +def scalarCubeDifferenceMatrix {I J : Type*} {L : ℕ} + (x : J → IntegerScalarCubeBox I L) : Matrix I J ℤ := + sampledColumnMatrix (fun _j y i => (y (some i) : ℤ)) x + +def scalarCubeLargeCokernelEvent {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] + {L : ℕ} (B : ℕ) (x : J → IntegerScalarCubeBox I L) : Prop := + (∃ s : I → J, ((scalarCubeDifferenceMatrix x).submatrix id s).det ≠ 0) ∧ + B < integerCokernelExponent (scalarCubeDifferenceMatrix x).mulVecLin.range + +theorem scalarCube_largeCokernel_probability_le {I J : Type*} + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (L B : ℕ) (hL : 0 < L) (hsize : Fintype.card I + 1 ≤ L) (hB : 0 < B) + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) : + (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (scalarCubeLargeCokernelEvent B) ≤ + (integerScalarCubeDensityCap I * (1 + ((Fintype.card I).factorial : ℝ))) ^ + Fintype.card J / (B : ℝ) := by + let R := (Fintype.card I).factorial * L ^ Fintype.card I + have hbound := boxCokernel_probability_le + (I := I) (J := J) (K := Option I) Option.some (Option.some_injective I) + (fun _ => -(L : ℤ)) (fun _ => (L : ℤ)) (fun _ => by omega) + (fun _ => integerScalarCubeWeights I L hL) B R hB + (integerScalarCubeDensityCap I) ((Fintype.card I).factorial : ℝ) + (integerScalarCubeDensityCap_pos I).le (Nat.cast_nonneg _) hJ + (fun _ x => integerScalarCubeWeights_weight_le I L hL hsize x) (fun _ => ?_) + · apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans hbound + intro x hx + apply nonzeroMinor_largeCokernelEvent _ x B L _ hx.1 hx.2 + intro i j + have h := Finset.mem_Ico.mp (x j (some i)).property + have ha : |(x j (some i) : ℤ)| ≤ (L : ℤ) := abs_le.mpr ⟨h.1, h.2.le⟩ + have hn : (((x j (some i) : ℤ).natAbs : ℕ) : ℤ) ≤ (L : ℤ) := by + simpa only [Int.natCast_natAbs] using ha + exact_mod_cast hn + · have h := nat_monomial_root_le (Fintype.card I) (Fintype.card I).factorial L + Fintype.card_pos (Nat.factorial_pos _) + apply h.trans + push_cast + nlinarith [show (0 : ℝ) ≤ (Fintype.card I).factorial from Nat.cast_nonneg _] + + +open scoped BigOperators + +theorem integerScalarCubeWeights_mean (I : Type*) [Fintype I] [DecidableEq I] + (L : ℕ) (hL : 0 < L) (f : IntegerScalarCubeBox I L → ℝ) : + (integerScalarCubeWeights I L hL).mean f = 𝔼 x : integerScalarCubeSet I L, f x := by + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + exact FiniteProbabilityWeights.uniform_condition_mean (integerScalarCubeSet I L) + (integerScalarCubeReference_mass_pos I L hL) f + +theorem integerScalarCubeWeights_supported_mean (q L : ℕ) (hL : 0 < L) + (f : ((Fin q → ℤ) × ℤ) → ℝ) : + (integerScalarCubeWeights (Fin q) L hL).mean + (fun x => f (fun i => (x (some i) : ℤ), (x none : ℤ))) = + 𝔼 p : SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ)), f p.val := by + rw [integerScalarCubeWeights_mean] + exact Fintype.expect_equiv (integerScalarCubeEquiv q L) _ _ (fun _ => rfl) + +end Erdos3 + + +namespace Erdos3 + +noncomputable def scalarCubeResidueDensityCap (I : Type*) [Fintype I] (M : ℕ) : ℝ := + (4 * (Fintype.card I + 1 : ℕ) * (M : ℝ)) ^ (Fintype.card I + 1) + +theorem scalarCubeResidueDensityCap_pos (I : Type*) [Fintype I] (M : ℕ) (hM : 0 < M) : + 0 < scalarCubeResidueDensityCap I M := by + unfold scalarCubeResidueDensityCap + positivity + +theorem scalarCubeResidueReference_mass_lower (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) : + (scalarCubeResidueDensityCap I M)⁻¹ ≤ + (integerScalarCubeReference I L hL).mass + ((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r) := by + let n := Fintype.card I + 1 + let H := L / (n * M) + have hn : 0 < n := by dsimp [n]; omega + have hM : 0 < M := (hm none).trans_le (hmM none) + have hH : 0 < H := Nat.div_pos hsize (Nat.mul_pos hn hM) + have hHL : n * (M * H) ≤ L := by + rw [← Nat.mul_assoc] + exact Nat.mul_div_le L (n * M) + have hc := scalarCubeResidueSet_card_lower I L M H m r hm hmM hH hHL + have hfloor : (L : ℝ) ≤ 2 * ((n : ℝ) * M) * (H : ℝ) := by + exact_mod_cast nat_div_half_lower (Nat.mul_pos hn hM) hsize + have hratio : 1 / (4 * (n : ℝ) * M) ≤ (H : ℝ) / (2 * (L : ℝ)) := by + apply (div_le_div_iff₀ (by positivity) (by positivity)).mpr + nlinarith + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + calc + _ = (1 / (4 * (n : ℝ) * M)) ^ n := by + simp only [scalarCubeResidueDensityCap, n, one_div, inv_pow] + _ ≤ ((H : ℝ) / (2 * (L : ℝ))) ^ n := pow_le_pow_left₀ (by positivity) hratio n + _ = (H : ℝ) ^ n / (2 * (L : ℝ)) ^ n := div_pow _ _ _ + _ ≤ _ := by + unfold integerScalarCubeReference + rw [FiniteProbabilityWeights.uniform_mass, integerScalarCubeBox_card] + push_cast + apply div_le_div_of_nonneg_right _ (by positivity) + exact_mod_cast hc + +theorem scalarCubeResidue_mass_lower (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) : + (scalarCubeResidueDensityCap I M)⁻¹ ≤ + (integerScalarCubeWeights I L hL).mass (scalarCubeResidueSet I L m r) := by + exact (scalarCubeResidueReference_mass_lower I L M hL m r hm hmM hsize).trans + (FiniteProbabilityWeights.mass_inter_le_condition_mass _ _ _ _) + +theorem scalarCubeResidue_mass_pos (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) : + 0 < (integerScalarCubeWeights I L hL).mass (scalarCubeResidueSet I L m r) := + (inv_pos.mpr (scalarCubeResidueDensityCap_pos I M ((hm none).trans_le (hmM none)))).trans_le + (scalarCubeResidue_mass_lower I L M hL m r hm hmM hsize) + + +open scoped BigOperators + +noncomputable def scalarCubeResidueWeights (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) : + FiniteProbabilityWeights (IntegerScalarCubeBox I L) := by + classical + exact (integerScalarCubeWeights I L hL).condition (scalarCubeResidueSet I L m r) + (scalarCubeResidue_mass_pos I L M hL m r hm hmM hsize) + +theorem scalarCubeResidueWeights_mean (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) (f : IntegerScalarCubeBox I L → ℝ) : + (scalarCubeResidueWeights I L M hL m r hm hmM hsize).mean f = + 𝔼 x : ↥((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r), f x := by + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + exact FiniteProbabilityWeights.uniform_condition_condition_mean _ _ + (integerScalarCubeReference_mass_pos I L hL) + (scalarCubeResidue_mass_pos I L M hL m r hm hmM hsize) f + +theorem scalarCubeResidueWeights_weight_le (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) (x : IntegerScalarCubeBox I L) : + (scalarCubeResidueWeights I L M hL m r hm hmM hsize).weight x ≤ + scalarCubeResidueDensityCap I M * (integerScalarCubeWeights I L hL).weight x := by + have hcap := scalarCubeResidueDensityCap_pos I M ((hm none).trans_le (hmM none)) + have h := FiniteProbabilityWeights.condition_weight_le _ _ + (scalarCubeResidue_mass_pos I L M hL m r hm hmM hsize) + (scalarCubeResidueDensityCap I M)⁻¹ (inv_pos.mpr hcap) + (scalarCubeResidue_mass_lower I L M hL m r hm hmM hsize) x + simpa only [scalarCubeResidueWeights, inv_inv] using h + +theorem scalarCubeResidue_pi_eventProbability_le (I J : Type*) + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (L M : ℕ) (hL : 0 < L) (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i)) + (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) (E : (J → IntegerScalarCubeBox I L) → Prop) : + (FiniteProbabilityWeights.pi (fun j => + scalarCubeResidueWeights I L M hL (m j) (r j) (hm j) (hmM j) hsize)).eventProbability E ≤ + (scalarCubeResidueDensityCap I M) ^ Fintype.card J * + (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability E := by + simpa only [Finset.prod_const, Finset.card_univ] using + FiniteProbabilityWeights.pi_eventProbability_le + (fun j => scalarCubeResidueWeights I L M hL (m j) (r j) (hm j) (hmM j) hsize) + (fun _ : J => integerScalarCubeWeights I L hL) (fun _ => scalarCubeResidueDensityCap I M) + (fun j x => scalarCubeResidueWeights_weight_le I L M hL (m j) (r j) (hm j) (hmM j) hsize x) E + +end Erdos3 + + +namespace Erdos3 + +theorem scalarCubeResidueWeights_support (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I+1)*M ≤ L) + (x : IntegerScalarCubeBox I L) + (hx : (scalarCubeResidueWeights I L M hL m r hm hmM hsize).weight x ≠ 0) : + ∀ i, ((x i : ℤ) : ZMod (m i)) = r i := by + classical + apply (mem_scalarCubeResidueSet L m r x).mp + by_contra hnot + apply hx + simp only [scalarCubeResidueWeights, FiniteProbabilityWeights.condition, hnot, ite_false, zero_div] + +theorem scalarCubeResiduePi_support {J I : Type*} [Fintype J] [DecidableEq J] + [Fintype I] [DecidableEq I] + (L M : J → ℕ) (hL : ∀ j, 0 < L j) (m : J → Option I → ℕ) + (r : ∀ j i, ZMod (m j i)) (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M j) + (hsize : ∀ j, (Fintype.card I+1)*M j ≤ L j) + (x : ∀ j, IntegerScalarCubeBox I (L j)) + (hx : (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights I (L j) (M j) (hL j) + (m j) (r j) (hm j) (hmM j) (hsize j))).weight x ≠ 0) : + ∀ j i, ((x j i : ℤ) : ZMod (m j i)) = r j i := by + intro j + apply scalarCubeResidueWeights_support I (L j) (M j) (hL j) (m j) (r j) (hm j) (hmM j) (hsize j) (x j) + intro hz + apply hx + exact Finset.prod_eq_zero (Finset.mem_univ j) hz + +theorem scalarCubeResiduePi_condition {J I : Type*} [Fintype J] [DecidableEq J] + [Fintype I] [DecidableEq I] + (L M : J → ℕ) (hL : ∀ j, 0 < L j) (m : J → Option I → ℕ) + (r : ∀ j i, ZMod (m j i)) (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M j) + (hsize : ∀ j, (Fintype.card I+1)*M j ≤ L j) : + FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights I (L j) (M j) (hL j) + (m j) (r j) (hm j) (hmM j) (hsize j)) = + (FiniteProbabilityWeights.pi (fun j => integerScalarCubeWeights I (L j) (hL j))).condition + (FiniteProbabilityWeights.piRestrictionSet (fun j => scalarCubeResidueSet I (L j) (m j) (r j))) + (FiniteProbabilityWeights.piRestriction_mass_pos _ _ + (fun j => scalarCubeResidue_mass_pos I (L j) (M j) (hL j) (m j) (r j) (hm j) (hmM j) (hsize j))) := + FiniteProbabilityWeights.pi_condition _ _ _ + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/CyclicModelAffineBox.lean b/lean/OAI/Combinatorics/Progressions/Lattices/CyclicModelAffineBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..76662570a1e3d273329ad204b4fa3469448a0a02 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/CyclicModelAffineBox.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Estimates.CyclicProgressionHom +import OAI.Combinatorics.Progressions.Estimates.DenseTranslate +import OAI.Combinatorics.Progressions.Estimates.FreimanFivefoldCardinality +import OAI.Combinatorics.Progressions.Estimates.LocalizedSiftingAlmostPeriods + +namespace OAI + +section + +namespace Erdos3.FreimanModel + +open scoped Pointwise +open CyclicCrootSisask + +theorem exists_affine_box_of_cyclic_model {G : Type*} [AddCommGroup G] [DecidableEq G] + {Q : ℕ} [NeZero Q] (A : Finset G) (hA : A.Nonempty) (B : Finset (ZMod Q)) + (hB : B.Nonempty) (f : G → ZMod Q) (hf : IsAddFreimanIso 8 (A : Set _) (B : Set _) f) + {p : ℝ} (hp : 0 ≤ p) (hdensity : Real.exp (-p) * Q ≤ (B.card : ℝ)) : + ∃ F ⊆ A, F.Nonempty ∧ + Real.exp (-(quarticBogolyubovProgressionConstant * (p + 1) ^ 8)) * A.card ≤ (F.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) (Φ : (Fin r → ℤ) →+ G) (base : G), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (p + 1) ^ 4 ∧ + Set.InjOn Φ {x | ∀ i, |x i| ≤ (R i : ℤ)} ∧ + ∀ a ∈ F, ∃ x : Fin r → ℤ, (∀ i, |x i| ≤ (R i : ℤ)) ∧ a = base + Φ x := by + classical + obtain ⟨T, hrank, hT, hTsub, hTsize⟩ := exists_quartic_bogolyubov_progression B hp hdensity + obtain ⟨L, hmap, hinj, hzero, hadd⟩ := exists_fourfold_lift_of_eight_iso A B hB f hf + have hpair (x y z t : T.Param) (h : T.eval x + T.eval y = T.eval z + T.eval t) : + L (T.eval x) + L (T.eval y) = L (T.eval z) + L (T.eval t) := + (hadd _ (hTsub (T.eval_mem_carrier x)) _ (hTsub (T.eval_mem_carrier y)) + _ (hTsub (T.eval_mem_carrier z)) _ (hTsub (T.eval_mem_carrier t))).mpr h + let Φ := T.freimanHom L + let S := T.coefficientBox.image Φ + have hS : S ⊆ 2 • A - 2 • A := by + intro a ha + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp ha + obtain ⟨y, rfl⟩ := T.mem_coefficientBox.mp hx + change T.freimanHom L (T.coeff y) ∈ _ + rw [T.freimanHom_coeff L hzero hpair] + exact hmap (hTsub (T.eval_mem_carrier y)) + have hScard : S.card = T.carrier.card := by + change (T.coefficientBox.image (T.freimanHom L)).card = T.carrier.card + rw [T.image_freimanHom L hzero hpair] + exact Finset.card_image_of_injOn (hinj.mono hTsub) + have hbound : ((A - S).card : ℝ) ≤ (Q : ℝ) := by + have h := card_sub_le_of_fourfold_subset A S f (hf.mono (hmn := by decide)) hS + have h' : (A - S).card ≤ Q := by simpa only [ZMod.card] using h + exact_mod_cast h' + have hsize : Real.exp (-(quarticBogolyubovProgressionConstant * (p + 1) ^ 8)) * Q ≤ + (S.card : ℝ) := by rw [hScard]; exact hTsize + obtain ⟨base, _hbase, F, hFA, hF, hFsize, hFsub⟩ := exists_dense_translate A S hA + (Real.exp_pos _) (by exact_mod_cast NeZero.pos Q) hbound hsize + refine ⟨F, hFA, hF, hFsize, T.rank, T.radius, Φ, base, hrank, ?_, ?_⟩ + · intro x hx y hy hxy + exact T.freimanHom_injOn hT L (hinj.mono hTsub) hzero hpair + (T.mem_coefficientBox_iff_abs_le.mpr hx) (T.mem_coefficientBox_iff_abs_le.mpr hy) hxy + · intro a ha + obtain ⟨x, hx, heq⟩ := Finset.mem_image.mp (hFsub a ha) + refine ⟨x, T.mem_coefficientBox_iff_abs_le.mp hx, ?_⟩ + rw [heq] + abel + +end Erdos3.FreimanModel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/DenseIntegerSpan.lean b/lean/OAI/Combinatorics/Progressions/Lattices/DenseIntegerSpan.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5b35e4224e9c93e48e90021c0450846719b0e26 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/DenseIntegerSpan.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Estimates.ProperSubspaceCount +import OAI.Combinatorics.Progressions.Lattices.IntegerAbsInterval + +namespace OAI + +section + +namespace Erdos3 + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem bounded_integer_points_card_le_of_proper_subspace + (U : Submodule ℝ (ι → ℝ)) (hU : U ≠ ⊤) + (H : Finset (ι → ℤ)) (T : ι → ℝ) (R : ℝ) + (hT : ∀ i, 1 ≤ T i) (hR : 1 ≤ R) + (hmem : ∀ h ∈ H, (fun i => (h i : ℝ)) ∈ U) + (hbound : ∀ h ∈ H, ∀ i, |(h i : ℝ)| ≤ R * T i) : + ∃ j : ι, (H.card : ℝ) ≤ + (3 * R) ^ (Fintype.card ι - 1) * ∏ i : {i : ι // i ≠ j}, T i.val := by + classical + obtain ⟨j, hj⟩ := integer_points_card_le_of_proper_subspace U hU H + (fun i => integerAbsInterval (R * T i)) hmem + (fun h hh i => (mem_integerAbsInterval _ _).mpr (hbound h hh i)) + refine ⟨j, ?_⟩ + have hnum : Fintype.card {i : ι // i ≠ j} = Fintype.card ι - 1 := by + rw [Fintype.card_subtype_compl] + simp + calc + (H.card : ℝ) ≤ ∏ i : {i : ι // i ≠ j}, ((integerAbsInterval (R * T i.val)).card : ℝ) := by + exact_mod_cast hj + _ ≤ ∏ i : {i : ι // i ≠ j}, (3 * R) * T i.val := by + apply Finset.prod_le_prod₀ + · intro i _ + positivity + · intro i _ + have hRT : 1 ≤ R * T i.val := by + simpa only [mul_one] using mul_le_mul hR (hT i.val) + (show (0 : ℝ) ≤ 1 by norm_num) (show 0 ≤ R by linarith) + simpa only [mul_assoc] using integerAbsInterval_card_le_three (R * T i.val) + hRT + _ = _ := by rw [Finset.prod_mul_distrib]; simp only [Finset.prod_const, + Finset.card_univ, hnum] + +theorem integer_points_span_eq_top_of_density + (H : Finset (ι → ℤ)) (T : ι → ℝ) (R δ : ℝ) + (hT : ∀ i, 1 ≤ T i) (hR : 1 ≤ R) + (hbound : ∀ h ∈ H, ∀ i, |(h i : ℝ)| ≤ R * T i) + (hdense : δ * ∏ i, T i ≤ (H.card : ℝ)) + (hlarge : ∀ i, (3 * R) ^ (Fintype.card ι - 1) < δ * T i) : + Submodule.span ℝ {x : ι → ℝ | ∃ h ∈ H, x = fun i => (h i : ℝ)} = ⊤ := by + classical + by_contra hspan + obtain ⟨j, hj⟩ := bounded_integer_points_card_le_of_proper_subspace _ hspan H T R hT hR + (fun h hh => Submodule.subset_span ⟨h, hh, rfl⟩) hbound + have hp : 0 < ∏ i : {i : ι // i ≠ j}, T i.val := + Finset.prod_pos (fun i _ => lt_of_lt_of_le zero_lt_one (hT i.val)) + have hprod : T j * (∏ i : {i : ι // i ≠ j}, T i.val) = ∏ i, T i := by + have he : (∏ i ∈ Finset.univ.erase j, T i) = ∏ i : {i : ι // i ≠ j}, T i.val := + Finset.prod_subtype _ (by simp) T + rw [← he] + exact Finset.mul_prod_erase Finset.univ T (Finset.mem_univ j) + have hstrict := mul_lt_mul_of_pos_right (hlarge j) hp + have hidentity : δ * T j * (∏ i : {i : ι // i ≠ j}, T i.val) = δ * ∏ i, T i := by + rw [mul_assoc, hprod] + rw [hidentity] at hstrict + exact (hstrict.trans_le hdense).not_ge hj + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueMeshExponentialBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueMeshExponentialBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..16a83583d8dbfb5f016278068c6c4539aaea7eb3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueMeshExponentialBudget.lean @@ -0,0 +1,197 @@ +import Mathlib.Algebra.Order.AbsoluteValue.Basic +import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Data.Rat.Floor +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def denseResidueMeshCap (n : ℕ) (δ ε C : ℝ) : ℕ := + ⌈16 * ((n : ℝ) + 1) * C / (ε * δ)⌉₊ + 1 + +noncomputable def denseResidueMeshStep (n : ℕ) (δ ε L : ℝ) : ℕ := + ⌊ε * δ * L / (8 * ((n : ℝ) + 1))⌋₊ + +theorem denseResidueMesh_budget (n : ℕ) {δ ε C L : ℝ} + (hδ : 0 < δ) (hε : 0 < ε) (hε₁ : ε ≤ 1) (hC : 1 ≤ C) + (hL : 16 * ((n : ℝ) + 1) / (ε * δ) ≤ L) : + 0 < denseResidueMeshStep n δ ε L ∧ + C * L ≤ ((denseResidueMeshCap n δ ε C * denseResidueMeshStep n δ ε L : ℕ) : ℝ) ∧ + 4 * (n : ℝ) * denseResidueMeshStep n δ ε L / (δ * L) ≤ ε / 2 ∧ + 2 * (denseResidueMeshStep n δ ε L : ℝ) < δ * L ∧ + 4 * (denseResidueMeshStep n δ ε L : ℝ) ≤ δ * L := by + let M := denseResidueMeshStep n δ ε L + let K := denseResidueMeshCap n δ ε C + have hn : 0 ≤ (n : ℝ) := Nat.cast_nonneg n + have hd : 0 < ε * δ := mul_pos hε hδ + have hb : 0 < 8 * ((n : ℝ) + 1) := by positivity + have hlarge : 16 * ((n : ℝ) + 1) ≤ L * (ε * δ) := + (div_le_iff₀ hd).mp hL + have hLpos : 0 < L := by + have : 0 < L * (ε * δ) := lt_of_lt_of_le (by positivity) hlarge + exact (mul_pos_iff_of_pos_right hd).mp this + have hδL : 0 < δ * L := mul_pos hδ hLpos + have ht : 2 ≤ ε * δ * L / (8 * ((n : ℝ) + 1)) := by + apply (le_div_iff₀ hb).mpr + nlinarith only [hlarge] + have hMpos : 0 < M := Nat.floor_pos.mpr (by linarith only [ht]) + have hMone : (1 : ℝ) ≤ M := by exact_mod_cast hMpos + have hMnonneg : (0 : ℝ) ≤ M := by positivity + have hMupper : (M : ℝ) * (8 * ((n : ℝ) + 1)) ≤ ε * δ * L := by + apply (le_div_iff₀ hb).mp + exact Nat.floor_le (by positivity) + have hMlower : ε * δ * L ≤ 16 * ((n : ℝ) + 1) * M := by + have hfloor := Nat.lt_floor_add_one (ε * δ * L / (8 * ((n : ℝ) + 1))) + have hhalf : ε * δ * L / (8 * ((n : ℝ) + 1)) ≤ 2 * M := by + change ε * δ * L / (8 * ((n : ℝ) + 1)) < (M : ℝ) + 1 at hfloor + linarith only [hfloor, hMone] + have := (div_le_iff₀ hb).mp hhalf + nlinarith only [this] + have hK : 16 * ((n : ℝ) + 1) * C ≤ (ε * δ) * K := by + have hceil := Nat.le_ceil (16 * ((n : ℝ) + 1) * C / (ε * δ)) + have hbound : 16 * ((n : ℝ) + 1) * C / (ε * δ) ≤ (K : ℝ) := by + dsimp [K, denseResidueMeshCap] + push_cast + linarith only [hceil] + have := (div_le_iff₀ hd).mp hbound + simpa [mul_comm] using this + refine ⟨hMpos, ?_, ?_, ?_, ?_⟩ + · change C * L ≤ ((K * M : ℕ) : ℝ) + rw [Nat.cast_mul] + apply le_of_mul_le_mul_left _ hd + calc + (ε * δ) * (C * L) = C * (ε * δ * L) := by ring + _ ≤ C * (16 * ((n : ℝ) + 1) * M) := + mul_le_mul_of_nonneg_left hMlower (by linarith only [hC]) + _ = (16 * ((n : ℝ) + 1) * C) * M := by ring + _ ≤ ((ε * δ) * K) * M := mul_le_mul_of_nonneg_right hK hMnonneg + _ = (ε * δ) * ((K : ℝ) * M) := by ring + · apply (div_le_iff₀ hδL).mpr + change 4 * (n : ℝ) * M ≤ ε / 2 * (δ * L) + nlinarith only [hMupper, hMnonneg] + · change 2 * (M : ℝ) < δ * L + have hεL : ε * (δ * L) ≤ δ * L := + mul_le_of_le_one_left (le_of_lt hδL) hε₁ + nlinarith only [hMupper, hεL, hn, hMone] + · change 4 * (M : ℝ) ≤ δ * L + have hεL : ε * (δ * L) ≤ δ * L := + mul_le_of_le_one_left (le_of_lt hδL) hε₁ + nlinarith only [hMupper, hεL, hn, hMnonneg] + +theorem exists_denseResidueMesh_budget (n : ℕ) {δ ε C : ℝ} + (hδ : 0 < δ) (hε : 0 < ε) (hε₁ : ε ≤ 1) (hC : 1 ≤ C) : + ∃ K : ℕ, 0 < K ∧ ∀ L : ℝ, + 16 * ((n : ℝ) + 1) / (ε * δ) ≤ L → + ∃ M : ℕ, 0 < M ∧ C * L ≤ ((K * M : ℕ) : ℝ) ∧ + 4 * (n : ℝ) * M / (δ * L) ≤ ε / 2 ∧ + 2 * (M : ℝ) < δ * L ∧ 4 * (M : ℝ) ≤ δ * L := by + refine ⟨denseResidueMeshCap n δ ε C, Nat.succ_pos _, ?_⟩ + intro L hL + exact ⟨denseResidueMeshStep n δ ε L, denseResidueMesh_budget n hδ hε hε₁ hC hL⟩ + +theorem denseResidueMesh_side_budget (n : ℕ) {δ ε C L : ℝ} + (hδ : 0 < δ) (hε : 0 < ε) (hε₁ : ε ≤ 1) (hC : 1 ≤ C) + (hL : 16 * ((n : ℝ) + 1) / (ε * δ) ≤ L) + (N : ℕ) (hlo : δ * L ≤ (N : ℝ)) (hhi : (N : ℝ) ≤ C * L) : + N ≤ denseResidueMeshCap n δ ε C * denseResidueMeshStep n δ ε L ∧ + 2 * denseResidueMeshStep n δ ε L < N ∧ + 4 * (n : ℝ) * denseResidueMeshStep n δ ε L / (N : ℝ) ≤ ε / 2 := by + obtain ⟨hM, hcover, hboundary, htrim, _⟩ := + denseResidueMesh_budget n hδ hε hε₁ hC hL + have hδL : 0 < δ * L := lt_of_le_of_lt (by positivity) htrim + refine ⟨?_, ?_, ?_⟩ + · exact_mod_cast hhi.trans hcover + · have h := htrim.trans_le hlo + exact_mod_cast h + · exact (div_le_div_of_nonneg_left (by positivity) hδL hlo).trans hboundary + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_denseResidueMesh_exponential_budget (n : ℕ) {C : ℝ} (hC : 1 ≤ C) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ (b δ ε : ℝ), 0 ≤ b → + Real.exp (-b) ≤ δ → δ ≤ 1 → Real.exp (-b) ≤ ε → ε ≤ 1 → + let Q := ⌈2 / δ⌉₊ + let K := denseResidueMeshCap n δ ε C + ((Q + 1 : ℕ) : ℝ) ≤ Real.exp ((A : ℝ) + 2 * b) ∧ + ((K + 1 : ℕ) : ℝ) ≤ Real.exp ((A : ℝ) + 2 * b) ∧ + 16 * ((n : ℝ) + 1) / (ε * δ) ≤ Real.exp ((A : ℝ) + 2 * b) := by + let D : ℝ := 16 * ((n : ℝ) + 1) + have hD : 0 ≤ D := by dsimp [D]; positivity + have hC0 : 0 ≤ C := by linarith + have hDC : 0 ≤ D * C := mul_nonneg hD hC0 + obtain ⟨A, hA⟩ := exists_nat_ge (D * C + D + 8) + have hAtwo : 2 ≤ A := by + have : (2 : ℝ) ≤ A := by linarith + exact_mod_cast this + have hAexp : (A : ℝ) ≤ Real.exp A := by linarith [Real.add_one_le_exp (A : ℝ)] + have hAfour : (4 : ℝ) ≤ Real.exp A := by linarith + have hADC : D * C + 3 ≤ Real.exp A := by linarith + have hAD : D ≤ Real.exp A := by linarith + refine ⟨A, hAtwo, ?_⟩ + intro b δ ε hb hδ _hδ₁ hε _hε₁ + have hδ0 : 0 < δ := (Real.exp_pos _).trans_le hδ + have hε0 : 0 < ε := (Real.exp_pos _).trans_le hε + have hδinv : δ⁻¹ ≤ Real.exp b := by + have h := one_div_le_one_div_of_le (Real.exp_pos (-b)) hδ + simpa only [one_div, Real.exp_neg, inv_inv] using h + have hεinv : ε⁻¹ ≤ Real.exp b := by + have h := one_div_le_one_div_of_le (Real.exp_pos (-b)) hε + simpa only [one_div, Real.exp_neg, inv_inv] using h + have hinv : (ε * δ)⁻¹ ≤ Real.exp (2 * b) := by + calc + _ = ε⁻¹ * δ⁻¹ := by simp only [mul_inv_rev, mul_comm] + _ ≤ Real.exp b * Real.exp b := + mul_le_mul hεinv hδinv (inv_nonneg.mpr hδ0.le) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have heone : 1 ≤ Real.exp (2 * b) := Real.one_le_exp_iff.mpr (by positivity) + have hδinv2 : δ⁻¹ ≤ Real.exp (2 * b) := + hδinv.trans (Real.exp_le_exp.mpr (by linarith)) + have hQceil : (⌈2 / δ⌉₊ : ℝ) ≤ 2 / δ + 1 := + (Nat.ceil_lt_add_one (by positivity : (0 : ℝ) ≤ 2 / δ)).le + have hKceil : (⌈D * C / (ε * δ)⌉₊ : ℝ) ≤ D * C / (ε * δ) + 1 := + (Nat.ceil_lt_add_one (by positivity : 0 ≤ D * C / (ε * δ))).le + have hquot : 2 / δ ≤ 2 * Real.exp (2 * b) := by + rw [div_eq_mul_inv] + exact mul_le_mul_of_nonneg_left hδinv2 (by norm_num) + have hmesh : D * C / (ε * δ) ≤ D * C * Real.exp (2 * b) := by + rw [div_eq_mul_inv] + exact mul_le_mul_of_nonneg_left hinv hDC + refine ⟨?_, ?_, ?_⟩ + · calc + ((⌈2 / δ⌉₊ + 1 : ℕ) : ℝ) ≤ 4 * Real.exp (2 * b) := by + push_cast + linarith + _ ≤ Real.exp A * Real.exp (2 * b) := + mul_le_mul_of_nonneg_right hAfour (Real.exp_pos _).le + _ = _ := (Real.exp_add _ _).symm + · calc + ((denseResidueMeshCap n δ ε C + 1 : ℕ) : ℝ) ≤ + (D * C + 3) * Real.exp (2 * b) := by + unfold denseResidueMeshCap + change (((⌈D * C / (ε * δ)⌉₊ + 1) + 1 : ℕ) : ℝ) ≤ _ + push_cast + nlinarith + _ ≤ Real.exp A * Real.exp (2 * b) := + mul_le_mul_of_nonneg_right hADC (Real.exp_pos _).le + _ = _ := (Real.exp_add _ _).symm + · calc + 16 * ((n : ℝ) + 1) / (ε * δ) = D * (ε * δ)⁻¹ := div_eq_mul_inv _ _ + _ ≤ D * Real.exp (2 * b) := mul_le_mul_of_nonneg_left hinv hD + _ ≤ Real.exp A * Real.exp (2 * b) := + mul_le_mul_of_nonneg_right hAD (Real.exp_pos _).le + _ = _ := (Real.exp_add _ _).symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueScalarRectangleGeometry.lean b/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueScalarRectangleGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..97c3fb497b68f12a423e09cb47057ceb221e7b59 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueScalarRectangleGeometry.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.Progressions.Lattices.AffineMeshRetention + +namespace OAI + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped Classical +variable {J : Type*} {N : J → ℕ} {q : ℕ} + +theorem length_le_parent (S : ResidueBoxSlice N q) (hq : 0 < q) (j : J) : + S.length j ≤ N j := by + by_cases hl : 0 < S.length j + · have hi := S.inside j (S.length j - 1) (by omega) + have hm : S.length j - 1 ≤ q * (S.length j - 1) := by + exact Nat.le_mul_of_pos_left _ hq + omega + · omega + +theorem scalarRectangle_geometry (S : ResidueBoxSlice N q) (hq : 0 < q) + {L density ratio : ℝ} (hL : 1 ≤ L) (hdensity : 0 < density) + (hratio : 1 ≤ ratio) (hlong : 4 ≤ density * L) + (hN : ∀ j, (N j : ℝ) ≤ ratio * L) + (hlength : ∀ j, density * L / 2 ≤ (S.length j : ℝ)) : + (∀ j, 2 ≤ S.length j) ∧ + (∀ j, S.length j ≤ ⌈ratio * L⌉₊) ∧ + (⌈ratio * L⌉₊ : ℝ) ≤ (4 * ratio / density) * (density * L / 2) ∧ + (∀ j, |(S.start j : ℝ) / L| ≤ 2 * ratio) ∧ + (∀ j, |((S.start j : ℝ) + (q : ℝ) * S.length j) / L| ≤ 2 * ratio) := by + have hLpos : 0 < L := by linarith + have hratio0 : 0 ≤ ratio := by linarith + have hlen2 (j) : 2 ≤ S.length j := by + exact_mod_cast (show (2 : ℝ) ≤ S.length j by linarith [hlength j]) + refine ⟨hlen2, ?_, ?_, ?_, ?_⟩ + · intro j + exact_mod_cast ((Nat.cast_le.mpr (S.length_le_parent hq j) : + (S.length j : ℝ) ≤ N j).trans (hN j)).trans (Nat.le_ceil _) + · have hc : (⌈ratio * L⌉₊ : ℝ) ≤ ratio * L + 1 := + (Nat.ceil_lt_add_one (mul_nonneg hratio0 hLpos.le)).le + have hprod : 1 ≤ ratio * L := one_le_mul_of_one_le_of_one_le hratio hL + have he : (4 * ratio / density) * (density * L / 2) = 2 * ratio * L := by + field_simp + ring + rw [he] + linarith + · intro j + exact (S.fullSliceRectangle_endpoint_bounds_two hlen2 hLpos hN j).1.trans + (by linarith) + · intro j + exact (S.fullSliceRectangle_endpoint_bounds_two hlen2 hLpos hN j).2 + +end Erdos3.ResidueBoxSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueScalarScoreNet.lean b/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueScalarScoreNet.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe8ef86aa8247c1c7e93f42a46332034ee9ea186 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/DenseResidueScalarScoreNet.lean @@ -0,0 +1,513 @@ +import OAI.Combinatorics.Progressions.Estimates.DenseProductCardDeficit +import OAI.Combinatorics.Progressions.Estimates.RelativeChildSliceGeometry +import OAI.Combinatorics.Progressions.Lattices.DenseResidueMeshExponentialBudget +import OAI.Combinatorics.Progressions.Sampling.RelativeSliceScalarMeshScore + +namespace OAI + +section + +namespace Erdos3 + +abbrev DenseResidueSliceNetCode (X : Type*) (Q K : ℕ) := + Fin (Q + 1) × (X → Fin (Q + 1)) × (X → Fin (K + 1)) × (X → Fin (K + 1)) + +namespace DenseResidueSliceNetCode + +variable {X : Type*} {Q K : ℕ} + +def stride (c : DenseResidueSliceNetCode X Q K) : ℕ := c.1.val + +def start (M : ℕ) (c : DenseResidueSliceNetCode X Q K) (i : X) : ℕ := + (c.2.1 i).val + c.stride * (M * (c.2.2.1 i).val) + +def length (M : ℕ) (c : DenseResidueSliceNetCode X Q K) (i : X) : ℕ := + M * (c.2.2.2 i).val - M * (c.2.2.1 i).val + +def Valid (N : X → ℕ) (H : ℝ) (M : ℕ) (c : DenseResidueSliceNetCode X Q K) : Prop := + 0 < c.stride ∧ + (∀ i j, j < c.length M i → c.start M i + c.stride * j < N i) ∧ + ∀ i, H / 2 ≤ (c.length M i : ℝ) + +def fullParent (N : X → ℕ) : ResidueBoxSlice N 1 where + start _ := 0 + length := N + inside i j hj := by simpa using hj + +noncomputable def realize (N : X → ℕ) (H : ℝ) (M : ℕ) + (c : DenseResidueSliceNetCode X Q K) : Σ q, ResidueBoxSlice N q := by + classical + exact if h : c.Valid N H M then + ⟨c.stride, ⟨c.start M, c.length M, h.2.1⟩⟩ else ⟨1, fullParent N⟩ + +theorem realize_spec (N : X → ℕ) (H : ℝ) (M : ℕ) + (hH : 0 < H) (hN : ∀ i, H ≤ (N i : ℝ)) (hQ : 1 ≤ Q) + (c : DenseResidueSliceNetCode X Q K) : + 0 < (c.realize N H M).1 ∧ (c.realize N H M).1 ≤ Q ∧ + ∀ i, H / 2 ≤ ((c.realize N H M).2.length i : ℝ) := by + classical + let P (z : Σ q, ResidueBoxSlice N q) : Prop := + 0 < z.1 ∧ z.1 ≤ Q ∧ ∀ i, H / 2 ≤ (z.2.length i : ℝ) + change P (c.realize N H M) + unfold realize + split_ifs with hc + · exact ⟨hc.1, Nat.le_of_lt_succ c.1.isLt, hc.2.2⟩ + · refine ⟨by norm_num, hQ, ?_⟩ + intro i + change H / 2 ≤ (N i : ℝ) + linarith [hN i] + +theorem card [Fintype X] [DecidableEq X] (Q K : ℕ) : + Fintype.card (DenseResidueSliceNetCode X Q K) = + (Q + 1) * ((Q + 1) * (K + 1) ^ 2) ^ Fintype.card X := by + simp only [DenseResidueSliceNetCode, Fintype.card_prod, Fintype.card_fun, Fintype.card_fin] + rw [mul_pow, ← pow_mul, Nat.mul_comm 2 _, pow_mul] + ring + +def meshCode {N : X → ℕ} {q : ℕ} (S : ResidueBoxSlice N q) + (hq : 0 < q) (hqQ : q ≤ Q) (M : ℕ) (hM : 0 < M) + (hlen : ∀ i, 2 * M < S.length i) (hbox : ∀ i, N i ≤ K * M) : + DenseResidueSliceNetCode X Q K := + ⟨⟨q, Nat.lt_succ_of_le hqQ⟩, + (fun i => ⟨S.start i % q, (Nat.mod_lt _ hq).trans_le (Nat.le_succ_of_le hqQ)⟩), + (fun i => ⟨S.start i / q / M + 1, Nat.lt_succ_of_le + ((denseResidueMeshInterval_code_bound (S.start i / q) (S.length i) M K hM (hlen i) + ((S.residueIndex_endpoint_le hq (fun j => by have := hlen j; omega) i).trans + (hbox i))).1)⟩), + (fun i => ⟨(S.start i / q + S.length i) / M, Nat.lt_succ_of_le + ((denseResidueMeshInterval_code_bound (S.start i / q) (S.length i) M K hM (hlen i) + ((S.residueIndex_endpoint_le hq (fun j => by have := hlen j; omega) i).trans + (hbox i))).2)⟩)⟩ + +theorem meshCode_valid {N : X → ℕ} {q : ℕ} (S : ResidueBoxSlice N q) + (hq : 0 < q) (hqQ : q ≤ Q) (M : ℕ) (hM : 0 < M) + (hlen : ∀ i, 2 * M < S.length i) (hbox : ∀ i, N i ≤ K * M) + (H : ℝ) (h4 : (4 * M : ℕ) ≤ H) (hH : ∀ i, H ≤ (S.length i : ℝ)) : + (meshCode S hq hqQ M hM hlen hbox).Valid N H M := by + refine ⟨hq, ?_, ?_⟩ + · exact (S.meshRounded hq M hM hlen).inside + · intro i + change H / 2 ≤ ((S.meshRounded hq M hM hlen).length i : ℝ) + obtain ⟨offset, _, hcontained, hloss⟩ := S.meshRounded_contained hq M hM hlen + have hi : S.length i ≤ (S.meshRounded hq M hM hlen).length i + 2 * M := by + have := hcontained i + have := hloss i + omega + have hiR : (S.length i : ℝ) ≤ (S.meshRounded hq M hM hlen).length i + 2 * (M : ℝ) := by + exact_mod_cast hi + have h4R : 4 * (M : ℝ) ≤ H := by exact_mod_cast h4 + linarith [hH i] + +theorem realize_meshCode {N : X → ℕ} {q : ℕ} (S : ResidueBoxSlice N q) + (hq : 0 < q) (hqQ : q ≤ Q) (M : ℕ) (hM : 0 < M) + (hlen : ∀ i, 2 * M < S.length i) (hbox : ∀ i, N i ≤ K * M) + (H : ℝ) (h4 : (4 * M : ℕ) ≤ H) (hH : ∀ i, H ≤ (S.length i : ℝ)) : + (meshCode S hq hqQ M hM hlen hbox).realize N H M = + ⟨q, S.meshRounded hq M hM hlen⟩ := by + classical + rw [realize, dite_eq_left (meshCode_valid S hq hqQ M hM hlen hbox H h4 hH)] + rfl + +theorem exists_realize_meshRounded {N : X → ℕ} {q : ℕ} (S : ResidueBoxSlice N q) + (hq : 0 < q) (hqQ : q ≤ Q) (M : ℕ) (hM : 0 < M) + (hbox : ∀ i, N i ≤ K * M) (H : ℝ) (h4 : (4 * M : ℕ) ≤ H) + (hH : ∀ i, H ≤ (S.length i : ℝ)) : + ∃ (hlen : ∀ i, 2 * M < S.length i) (c : DenseResidueSliceNetCode X Q K), + c.realize N H M = ⟨q, S.meshRounded hq M hM hlen⟩ := by + have hlen (i : X) : 2 * M < S.length i := by + have h4R : 4 * (M : ℝ) ≤ H := by exact_mod_cast h4 + have hMR : (0 : ℝ) < M := by exact_mod_cast hM + have hi : 2 * (M : ℝ) < S.length i := by linarith [hH i] + exact_mod_cast hi + exact ⟨hlen, meshCode S hq hqQ M hM hlen hbox, + realize_meshCode S hq hqQ M hM hlen hbox H h4 hH⟩ + +end DenseResidueSliceNetCode +end Erdos3 + +end + +section + +namespace Erdos3 + +private theorem denseResidueCode_card_exp_bound (n Q K : ℕ) (T : ℝ) + (hQ : ((Q + 1 : ℕ) : ℝ) ≤ Real.exp T) + (hK : ((K + 1 : ℕ) : ℝ) ≤ Real.exp T) : + (Fintype.card (DenseResidueSliceNetCode (Fin n) Q K) : ℝ) ≤ + Real.exp (((1 + 3 * n : ℕ) : ℝ) * T) := by + rw [DenseResidueSliceNetCode.card, Fintype.card_fin] + push_cast + calc + (Q + 1 : ℝ) * ((Q + 1 : ℝ) * (K + 1 : ℝ) ^ 2) ^ n ≤ + Real.exp T * (Real.exp T * (Real.exp T) ^ 2) ^ n := by + push_cast at hQ hK + gcongr + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + push_cast + ring + +theorem exists_denseResidueScalarNet_power_budget (n : ℕ) {C : ℝ} (hC : 1 ≤ C) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ (b δ ε : ℝ), 0 ≤ b → + Real.exp (-b) ≤ δ → δ ≤ 1 → Real.exp (-b) ≤ ε → ε ≤ 1 → + let Q := ⌈2 / δ⌉₊ + let K := denseResidueMeshCap n δ ε C + Real.log (Fintype.card (DenseResidueSliceNetCode (Fin n) Q K) : ℝ) ≤ (b + 2) ^ E ∧ + (Fintype.card (DenseResidueSliceNetCode (Fin n) Q K) : ℝ) ≤ Real.exp ((b + 2) ^ E) ∧ + ((Q + 1 : ℕ) : ℝ) ≤ Real.exp ((b + 2) ^ E) ∧ + ((K + 1 : ℕ) : ℝ) ≤ Real.exp ((b + 2) ^ E) ∧ + 16 * ((n : ℝ) + 1) / (ε * δ) ≤ Real.exp ((b + 2) ^ E) ∧ + (δ / 2)⁻¹ ≤ Real.exp ((b + 2) ^ E) ∧ + 2 * C ≤ Real.exp ((b + 2) ^ E) ∧ + 4 * C / δ ≤ Real.exp ((b + 2) ^ E) ∧ + (∀ L : ℝ, Real.exp ((b + 2) ^ E) ≤ L → 4 ≤ δ * L) ∧ + ∀ ρ : ℝ, Real.exp (-b) ≤ ρ → + Real.log (2 * (Fintype.card (DenseResidueSliceNetCode (Fin n) Q K) : ℝ) / ρ) ≤ + (b + 2) ^ E := by + obtain ⟨A, _, hmesh⟩ := exists_denseResidueMesh_exponential_budget n hC + let P : Polynomial ℕ := Polynomial.C (1 + 3 * n) * + (Polynomial.C A + 2 * Polynomial.X) + Polynomial.X + 2 + obtain ⟨E, hE, hP⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨E, hE, ?_⟩ + intro b δ ε hb hδ hδ1 hε hε1 Q K + obtain ⟨hQ, hK, hL⟩ := hmesh b δ ε hb hδ hδ1 hε hε1 + let T := (A : ℝ) + 2 * b + let U := ((1 + 3 * n : ℕ) : ℝ) * T + have hT : 0 ≤ T := by dsimp [T]; positivity + have hTU : T ≤ U := by + dsimp only [U] + exact le_mul_of_one_le_left hT (by exact_mod_cast (show 1 ≤ 1 + 3 * n by omega)) + have hcost : U + b + 2 ≤ (b + 2) ^ E := by + simpa [P, U, T] using hP b hb + have hUcost : U ≤ (b + 2) ^ E := by linarith + have hTcost := hTU.trans hUcost + have hcard : (Fintype.card (DenseResidueSliceNetCode (Fin n) Q K) : ℝ) ≤ Real.exp U := + denseResidueCode_card_exp_bound n Q K T hQ hK + have hcardpos : 0 < (Fintype.card (DenseResidueSliceNetCode (Fin n) Q K) : ℝ) := by + exact_mod_cast (Fintype.card_pos : 0 < Fintype.card (DenseResidueSliceNetCode (Fin n) Q K)) + have hcardFinal := hcard.trans (Real.exp_le_exp.mpr hUcost) + have hQFinal := hQ.trans (Real.exp_le_exp.mpr hTcost) + have hKFinal := hK.trans (Real.exp_le_exp.mpr hTcost) + have hLFinal := hL.trans (Real.exp_le_exp.mpr hTcost) + have hδpos := (Real.exp_pos (-b)).trans_le hδ + have hεpos := (Real.exp_pos (-b)).trans_le hε + have hC0 : 0 ≤ C := by linarith + have hhalf : (δ / 2)⁻¹ ≤ Real.exp ((b + 2) ^ E) := by + rw [inv_div] + exact (Nat.le_ceil (2 / δ)).trans + ((by exact_mod_cast Nat.le_succ Q : (Q : ℝ) ≤ (Q + 1 : ℕ)).trans hQFinal) + have hfour : 4 * C / δ ≤ Real.exp ((b + 2) ^ E) := by + have harg : 16 * ((n : ℝ) + 1) * C / (ε * δ) ≤ ((K + 1 : ℕ) : ℝ) := by + have hceil := Nat.le_ceil (16 * ((n : ℝ) + 1) * C / (ε * δ)) + dsimp only [K, denseResidueMeshCap] + push_cast + linarith + apply (le_trans ?_ harg).trans hKFinal + calc + 4 * C / δ ≤ 4 * C / (ε * δ) := + div_le_div_of_nonneg_left (by positivity) (mul_pos hεpos hδpos) + (mul_le_of_le_one_left hδpos.le hε1) + _ ≤ 16 * ((n : ℝ) + 1) * C / (ε * δ) := by + apply div_le_div_of_nonneg_right _ (mul_nonneg hεpos.le hδpos.le) + nlinarith [Nat.cast_nonneg (α := ℝ) n, mul_nonneg (Nat.cast_nonneg (α := ℝ) n) hC0] + have htwo : 2 * C ≤ Real.exp ((b + 2) ^ E) := by + apply (le_trans ?_ hfour) + apply (le_div_iff₀ hδpos).mpr + nlinarith [mul_le_mul_of_nonneg_left hδ1 (by positivity : 0 ≤ 2 * C)] + have hlarge (L : ℝ) (hLL : Real.exp ((b + 2) ^ E) ≤ L) : 4 ≤ δ * L := by + have hbound := (div_le_iff₀ (mul_pos hεpos hδpos)).mp (hLFinal.trans hLL) + have hLpos := (Real.exp_pos _).trans_le hLL + have hεL := mul_le_of_le_one_left (mul_nonneg hδpos.le hLpos.le) hε1 + nlinarith [Nat.cast_nonneg (α := ℝ) n] + refine ⟨(Real.log_le_iff_le_exp hcardpos).mpr hcardFinal, hcardFinal, + hQFinal, hKFinal, hLFinal, hhalf, htwo, hfour, hlarge, ?_⟩ + intro ρ hρ + have hρpos := (Real.exp_pos (-b)).trans_le hρ + have hinv : ρ⁻¹ ≤ Real.exp b := by + apply (inv_le_iff_one_le_mul₀' hρpos).mpr + calc + 1 = Real.exp (-b) * Real.exp b := by rw [← Real.exp_add]; simp + _ ≤ ρ * Real.exp b := mul_le_mul_of_nonneg_right hρ (Real.exp_nonneg _) + apply (Real.log_le_iff_le_exp (by positivity)).mpr + calc + 2 * (Fintype.card (DenseResidueSliceNetCode (Fin n) Q K) : ℝ) / ρ ≤ + Real.exp 2 * Real.exp U * Real.exp b := by + rw [div_eq_mul_inv] + gcongr + linarith [Real.add_one_le_exp (2 : ℝ)] + _ = Real.exp (U + b + 2) := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + _ ≤ Real.exp ((b + 2) ^ E) := Real.exp_le_exp.mpr hcost + +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators Classical + +variable {X : Type*} [Fintype X] [DecidableEq X] {N : X → ℕ} {q : ℕ} + +noncomputable def fullSliceSupport (S : ResidueBoxSlice N q) : Finset (integerBox N) := + Finset.univ.image S.fullSlicePointInIntegerBox + +theorem fullSlicePointInIntegerBox_injective (S : ResidueBoxSlice N q) (hq : 0 < q) : + Function.Injective S.fullSlicePointInIntegerBox := by + intro u v he + funext i + apply Fin.ext + have hi := congrArg (fun x : integerBox N => x.val i) he + change ((S.start i + q * (u i).val : ℕ) : ℤ) = + ((S.start i + q * (v i).val : ℕ) : ℤ) at hi + have hi' : S.start i + q * (u i).val = S.start i + q * (v i).val := by + exact_mod_cast hi + exact Nat.eq_of_mul_eq_mul_left hq (Nat.add_left_cancel hi') + +theorem fullSliceSupport_card (S : ResidueBoxSlice N q) (hq : 0 < q) : + S.fullSliceSupport.card = ∏ i, S.length i := by + rw [fullSliceSupport, Finset.card_image_of_injective _ + (fullSlicePointInIntegerBox_injective S hq)] + simp only [Finset.card_univ, Fintype.card_pi, Fintype.card_fin] + +theorem fullSliceSupport_nonempty (S : ResidueBoxSlice N q) + (hlen : ∀ i, 0 < S.length i) : S.fullSliceSupport.Nonempty := by + let u : ∀ i, Fin (S.length i) := fun i => ⟨0, hlen i⟩ + exact ⟨S.fullSlicePointInIntegerBox u, Finset.mem_image.mpr ⟨u, Finset.mem_univ _, rfl⟩⟩ + +theorem fullSliceLaw_mean_eq_support (S : ResidueBoxSlice N q) + (hlen : ∀ i, 0 < S.length i) (hq : 0 < q) (f : integerBox N → ℝ) : + (S.fullSliceLaw hlen).mean f = 𝔼 x ∈ S.fullSliceSupport, f x := by + rw [fullSliceLaw_mean, fullSliceSupport, + Finset.expect_image (fullSlicePointInIntegerBox_injective S hq).injOn] + +theorem fullSliceSupport_subset (S T : ResidueBoxSlice N q) (offset : X → ℕ) + (hstart : ∀ i, T.start i = S.start i + q * offset i) + (hlength : ∀ i, offset i + T.length i ≤ S.length i) : + T.fullSliceSupport ⊆ S.fullSliceSupport := by + intro x hx + obtain ⟨u, _, rfl⟩ := Finset.mem_image.mp hx + let v : ∀ i, Fin (S.length i) := fun i => + ⟨offset i + (u i).val, by have := (u i).isLt; have := hlength i; omega⟩ + apply Finset.mem_image.mpr + refine ⟨v, Finset.mem_univ _, ?_⟩ + apply Subtype.ext + funext i + simp only [fullSlicePointInIntegerBox, point, v, hstart, Nat.mul_add, Nat.add_assoc] + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators Classical + +variable {X : Type*} [Fintype X] [DecidableEq X] {N : X → ℕ} {q : ℕ} + +theorem fullSliceLaw_mean_sub_le_of_coordinate_deficit + (S T : ResidueBoxSlice N q) (hq : 0 < q) + (hlenS : ∀ i, 0 < S.length i) (hlenT : ∀ i, 0 < T.length i) + (offset : X → ℕ) (hstart : ∀ i, T.start i = S.start i + q * offset i) + (hlength : ∀ i, offset i + T.length i ≤ S.length i) + (η : ℝ) (hdeficit : ∀ i, + ((S.length i - T.length i : ℕ) : ℝ) / (S.length i : ℝ) ≤ η) + (f : integerBox N → ℝ) (hf : ∀ x, |f x| ≤ 1) : + |(S.fullSliceLaw hlenS).mean f - (T.fullSliceLaw hlenT).mean f| ≤ + 2 * (Fintype.card X : ℝ) * η := by + have hsub := fullSliceSupport_subset S T offset hstart hlength + have hcard := Finset.card_le_card hsub + have hcardpos : (0 : ℝ) < S.fullSliceSupport.card := by + exact_mod_cast (fullSliceSupport_nonempty S hlenS).card_pos + have hside (i) : T.length i ≤ S.length i := by have := hlength i; omega + have hproduct := denseProductNatCardDeficit_le_card_mul S.length T.length + hlenS hside η hdeficit + have hratio : ((S.fullSliceSupport.card - T.fullSliceSupport.card : ℕ) : ℝ) / + (S.fullSliceSupport.card : ℝ) ≤ (Fintype.card X : ℝ) * η := by + rw [Nat.cast_sub hcard, sub_div, div_self (ne_of_gt hcardpos)] + simpa only [fullSliceSupport_card S hq, fullSliceSupport_card T hq] using hproduct + rw [fullSliceLaw_mean_eq_support S hlenS hq, fullSliceLaw_mean_eq_support T hlenT hq] + have hmean := abs_expect_parent_sub_subset_le_abs S.fullSliceSupport T.fullSliceSupport + (fullSliceSupport_nonempty T hlenT) hsub f (fun x _ => hf x) + exact hmean.trans (by + simpa only [mul_div_assoc, mul_assoc] using mul_le_mul_of_nonneg_left hratio (by norm_num : (0 : ℝ) ≤ 2)) + +theorem fullSliceLaw_mean_sub_le_of_length_loss + (S T : ResidueBoxSlice N q) (hq : 0 < q) + (hlenS : ∀ i, 0 < S.length i) (hlenT : ∀ i, 0 < T.length i) + (offset : X → ℕ) (hstart : ∀ i, T.start i = S.start i + q * offset i) + (hlength : ∀ i, offset i + T.length i ≤ S.length i) + {H M : ℝ} (hH : 0 < H) (hM : 0 ≤ M) + (hLower : ∀ i, H ≤ (S.length i : ℝ)) + (hLoss : ∀ i, ((S.length i - T.length i : ℕ) : ℝ) ≤ 2 * M) + (f : integerBox N → ℝ) (hf : ∀ x, |f x| ≤ 1) : + |(S.fullSliceLaw hlenS).mean f - (T.fullSliceLaw hlenT).mean f| ≤ + 4 * (Fintype.card X : ℝ) * M / H := by + have hdeficit (i) : ((S.length i - T.length i : ℕ) : ℝ) / (S.length i : ℝ) ≤ + 2 * M / H := by + exact (div_le_div_of_nonneg_right (hLoss i) (Nat.cast_nonneg _)).trans + (div_le_div_of_nonneg_left (by positivity) hH (hLower i)) + have h := fullSliceLaw_mean_sub_le_of_coordinate_deficit S T hq hlenS hlenT + offset hstart hlength (2 * M / H) hdeficit f hf + convert h using 1 + ring + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem fullSliceLaw_sigma_congr + {X : Type*} [Fintype X] [DecidableEq X] {N : X → ℕ} + (S T : Σ q, ResidueBoxSlice N q) (h : S = T) + (hS : ∀ i, 0 < S.2.length i) (hT : ∀ i, 0 < T.2.length i) : + S.2.fullSliceLaw hS = T.2.fullSliceLaw hT := by + cases h + rfl + +theorem exists_denseResidueSliceLaw_net + (X : Type*) [Fintype X] [DecidableEq X] + {δ ε C : ℝ} (hδ : 0 < δ) (hδ₁ : δ ≤ 1) + (hε : 0 < ε) (hε₁ : ε ≤ 1) (hC : 1 ≤ C) : + let Q := ⌈2 / δ⌉₊ + let K := denseResidueMeshCap (Fintype.card X) δ ε C + ∀ L : ℝ, 16 * ((Fintype.card X : ℝ) + 1) / (ε * δ) ≤ L → + ∀ N : X → ℕ, (∀ i, L ≤ (N i : ℝ) ∧ (N i : ℝ) ≤ C * L) → + ∃ (stride : DenseResidueSliceNetCode X Q K → ℕ) + (slices : ∀ c, ResidueBoxSlice N (stride c)) + (hlen : ∀ c i, 0 < (slices c).length i), + (∀ c, 0 < stride c ∧ stride c ≤ Q) ∧ + (∀ c i, δ * L / 2 ≤ ((slices c).length i : ℝ)) ∧ + ∀ (q : ℕ), 0 < q → (q : ℝ) ≤ 2 / δ → + ∀ (S : ResidueBoxSlice N q) (hS : ∀ i, 0 < S.length i), + (∀ i, δ * (N i : ℝ) ≤ (S.length i : ℝ)) → + ∃ c : DenseResidueSliceNetCode X Q K, + ∀ (f : integerBox N → ℝ), (∀ x, |f x| ≤ 1) → + |(S.fullSliceLaw hS).mean f - ((slices c).fullSliceLaw (hlen c)).mean f| ≤ ε / 2 := by + intro Q K L hL N hN + have hLpos : 0 < L := + (div_pos (by positivity) (mul_pos hε hδ)).trans_le hL + have hH : 0 < δ * L := mul_pos hδ hLpos + have hNlower : ∀ i, δ * L ≤ (N i : ℝ) := + fun i => (mul_le_of_le_one_left hLpos.le hδ₁).trans (hN i).1 + have hQ : 1 ≤ Q := by + apply Nat.one_le_iff_ne_zero.mpr + exact ne_of_gt (Nat.ceil_pos.mpr (div_pos (by norm_num) hδ)) + let M := denseResidueMeshStep (Fintype.card X) δ ε L + obtain ⟨hM, hcover, herror, htrim, hfour⟩ := + denseResidueMesh_budget (Fintype.card X) hδ hε hε₁ hC hL + have hbox : ∀ i, N i ≤ K * M := by + intro i + exact_mod_cast (hN i).2.trans hcover + have hfour' : ((4 * M : ℕ) : ℝ) ≤ δ * L := by exact_mod_cast hfour + let family (c : DenseResidueSliceNetCode X Q K) := c.realize N (δ * L) M + have hspec (c : DenseResidueSliceNetCode X Q K) := + c.realize_spec N (δ * L) M hH hNlower hQ + have hlen (c : DenseResidueSliceNetCode X Q K) (i : X) : + 0 < (family c).2.length i := by + exact_mod_cast (half_pos hH).trans_le ((hspec c).2.2 i) + refine ⟨fun c => (family c).1, fun c => (family c).2, hlen, + (fun c => ⟨(hspec c).1, (hspec c).2.1⟩), (fun c => (hspec c).2.2), ?_⟩ + intro q hq hqbound S hS hdense + have hqQ : q ≤ Q := by + exact_mod_cast hqbound.trans (Nat.le_ceil (2 / δ)) + have hSlower : ∀ i, δ * L ≤ (S.length i : ℝ) := + fun i => (mul_le_mul_of_nonneg_left (hN i).1 hδ.le).trans (hdense i) + obtain ⟨hround, c, hc⟩ := + DenseResidueSliceNetCode.exists_realize_meshRounded S hq hqQ M hM hbox (δ * L) + hfour' hSlower + refine ⟨c, ?_⟩ + intro f hf + obtain ⟨offset, hstart, hlength, hloss⟩ := S.meshRounded_contained hq M hM hround + have hcompare := S.fullSliceLaw_mean_sub_le_of_length_loss + (S.meshRounded hq M hM hround) hq hS (S.meshRounded_length_pos hq M hM hround) + offset hstart hlength hH (Nat.cast_nonneg M) hSlower + (fun i => by exact_mod_cast hloss i) f hf + have herr := hcompare.trans herror + have hlaw := fullSliceLaw_sigma_congr (family c) + ⟨q, S.meshRounded hq M hM hround⟩ hc (hlen c) + (S.meshRounded_length_pos hq M hM hround) + rw [hlaw] + exact herr + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem exists_denseResidueScalarScore_net + (J : Type*) [Fintype J] [DecidableEq J] [Nonempty J] + {density accuracy ratio : ℝ} (hdensity : 0 < density) (hdensity₁ : density ≤ 1) + (haccuracy : 0 < accuracy) (haccuracy₁ : accuracy ≤ 1) (hratio : 1 ≤ ratio) : + let Q := ⌈2 / density⌉₊ + let K := denseResidueMeshCap (Fintype.card J) density accuracy ratio + ∀ L : ℝ, 16 * ((Fintype.card J : ℝ) + 1) / (accuracy * density) ≤ L → + ∀ N : J → ℕ, (∀ i, L ≤ (N i : ℝ) ∧ (N i : ℝ) ≤ ratio * L) → + ∃ (stride : DenseResidueSliceNetCode J Q K → ℕ) + (slices : ∀ c, ResidueBoxSlice N (stride c)) + (hlen : ∀ c i, 0 < (slices c).length i), + (∀ c, 0 < stride c ∧ stride c ≤ Q) ∧ + (∀ c i, density * L / 2 ≤ ((slices c).length i : ℝ)) ∧ + ∀ {X : Type*} [Fintype X] {s d : ℕ} (P : PolynomialPatch X s d) + (f : (X → ℤ) → ℝ) (parent : X → ℤ) (H : X → ℕ) + (frame : Option J × X → ℤ), + (∀ u : integerBox N, smoothAffineSample u.val frame ∈ translatedIntegerBox parent H) → + (∀ x ∈ translatedIntegerBox parent H, f x ∈ Set.Icc (0 : ℝ) 1) → + ∀ {τ Λ gain : ℝ}, 0 < τ → τ ≤ 1 / 2 → Λ ∈ Set.Icc (0 : ℝ) 1 → + ∀ (q : ℕ), 0 < q → ∀ (original : ResidueBoxSlice N q) + (hOriginal : ∀ j, 0 < original.length j), + (∀ j, density * (N j : ℝ) ≤ original.length j) → + gain ≤ (original.fullSliceLaw hOriginal).mean (fun u => + (f (smoothAffineSample u.val frame) - Λ) * + P.value (fun i => (smoothAffineSample u.val frame i : ℝ))) → + ∃ c, gain - accuracy / 2 ≤ rectangularScalarDiscrepancy parent H + (fun x => ((f x * P.value (fun i => (x i : ℝ)) : ℝ) : ℂ)) + (fun x => (P.value (fun i => (x i : ℝ)) : ℂ)) + (relativeScalarPassageSlack τ) ((1 - τ) * Λ) (stride c) + (fun j => ((slices c).start j : ℤ)) 0 (fun j => ((slices c).length j : ℤ)) + (fun j => by change (0 : ℤ) < ((slices c).length j : ℤ); exact_mod_cast hlen c j) + frame := by + intro Q K L hL N hN + obtain ⟨stride, slices, hlen, hstride, hlength, hnet⟩ := + exists_denseResidueSliceLaw_net J hdensity hdensity₁ haccuracy haccuracy₁ hratio L hL N hN + refine ⟨stride, slices, hlen, hstride, hlength, ?_⟩ + intro X _ s d P f parent H frame hinside hf τ Λ gain hτ hτhalf hΛ + q hq original hOriginal hdense hscore + have hLpos : 0 < L := + (div_pos (by positivity) (mul_pos haccuracy hdensity)).trans_le hL + have hprod := (div_le_iff₀ (mul_pos haccuracy hdensity)).mp hL + have hacc : L * (accuracy * density) ≤ L * density := by + exact mul_le_mul_of_nonneg_left + (mul_le_of_le_one_left hdensity.le haccuracy₁) hLpos.le + have htwo : 2 ≤ density * L := by + have hn : (0 : ℝ) ≤ Fintype.card J := Nat.cast_nonneg _ + nlinarith + let j := Classical.choice (inferInstance : Nonempty J) + have hlenj : 2 ≤ original.length j := by + exact_mod_cast htwo.trans + ((mul_le_mul_of_nonneg_left (hN j).1 hdensity.le).trans (hdense j)) + have hqbound : (q : ℝ) ≤ 2 / density := + (original.stride_lt_two_div_density hq hlenj hdensity (hdense j)).le + obtain ⟨c, hc⟩ := hnet q hq hqbound original hOriginal hdense + exact ⟨c, relativeSlice_scalar_mesh_score original hOriginal (slices c) (hlen c) + P f parent H frame hinside hf hτ hτhalf hΛ hscore hc⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/DerivativeLatticeDivision.lean b/lean/OAI/Combinatorics/Progressions/Lattices/DerivativeLatticeDivision.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb5517f6935129a87eac5a6bedf769c2df587c46 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/DerivativeLatticeDivision.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.Progressions.Geometry.DerivativeVerticalCoordinates + +namespace OAI + +section + +namespace Erdos3 + +theorem realDenominatorGrid_div_nat {ι : Type*} (l I : ℕ) (hI : 0 < I) + (x : ι → ℝ) (hx : x ∈ realDenominatorGrid l) : + ((I : ℝ)⁻¹ • x) ∈ realDenominatorGrid (l * I) := by + have hIr : (I : ℝ) ≠ 0 := by exact_mod_cast hI.ne' + obtain ⟨z, hz⟩ := hx + refine ⟨z, ?_⟩ + funext i + have hi := congrFun hz i + change (z i : ℝ) = (l : ℝ) * x i at hi + change (z i : ℝ) = ((l * I : ℕ) : ℝ) * ((I : ℝ)⁻¹ * x i) + rw [hi, Nat.cast_mul] + field_simp + +theorem divided_derivative_lattice_coordinates + {σ κ : Type*} [Fintype σ] [Fintype κ] [DecidableEq κ] + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (scale : κ → ℝ) (hs : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) + (l : ℕ) (hl : 0 < l) (I : ℕ) (hI : 0 < I) (y : σ → ℝ) + (v : EuclideanSpace ℝ (σ ⊕ κ)) + (hv : v ∈ euclideanDerivativeLattice T hT scale hs Y A l hl) + (hshift : euclideanDerivativeShiftMap T hT v = (I : ℝ) • y) : + ∃ r : κ → ℝ, r ∈ realDenominatorGrid (l * I) ∧ + ∀ j, ((I : ℝ)⁻¹ • v) (Sum.inr j) = scale j * (Y y j - A r j) := by + have hIr : (I : ℝ) ≠ 0 := by exact_mod_cast hI.ne' + have hv' := (euclideanDerivativeLattice_mem_iff T hT scale hs Y A l hl v).mp hv + rw [← SetLike.mem_coe, derivativeLattice_carrier] at hv' + obtain ⟨h, r, hr, he⟩ := hv' + have hleft (i) : v (Sum.inl i) = (h i : ℝ) / T i := + congrArg (fun x : (σ → ℝ) × (κ → ℝ) => x.1 i) he + have hright (j) : v (Sum.inr j) = + scale j * (Y (fun i => (h i : ℝ)) j - A r j) := by + have hc := congrArg (fun x : (σ → ℝ) × (κ → ℝ) => x.2 j) he + change (productEuclideanEquiv.symm v).2 j = _ + simpa only [derivativeGridPoint, LinearMap.toMatrix'_mulVec, + LinearEquiv.coe_coe, Pi.sub_apply] using hc + have hh : (fun i => (h i : ℝ)) = (I : ℝ) • y := by + funext i + have hi := congrFun hshift i + change T i * v (Sum.inl i) = (I : ℝ) * y i at hi + rw [hleft, mul_div_cancel₀ _ (hT i)] at hi + exact hi + refine ⟨(I : ℝ)⁻¹ • r, realDenominatorGrid_div_nat l I hI r hr, ?_⟩ + intro j + change (I : ℝ)⁻¹ * v (Sum.inr j) = _ + rw [hright, hh, map_smul, map_smul] + simp only [Pi.smul_apply, smul_eq_mul] + field_simp + +theorem divided_derivative_horizontal_coordinates + {σ κ : Type*} [Fintype σ] [Fintype κ] + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (I : ℕ) (hI : 0 < I) + (y : σ → ℝ) (v : EuclideanSpace ℝ (σ ⊕ κ)) + (hshift : euclideanDerivativeShiftMap T hT v = (I : ℝ) • y) : + ∀ i, ((I : ℝ)⁻¹ • v) (Sum.inl i) = y i / T i := by + have hIr : (I : ℝ) ≠ 0 := by exact_mod_cast hI.ne' + intro i + have hi := congrFun hshift i + change T i * v (Sum.inl i) = (I : ℝ) * y i at hi + have hv : v (Sum.inl i) = ((I : ℝ) * y i) / T i := + (eq_div_iff (hT i)).mpr (by simpa only [mul_comm] using hi) + change (I : ℝ)⁻¹ * v (Sum.inl i) = _ + rw [hv] + field_simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineCoveredSourceWithCutoff.lean b/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineCoveredSourceWithCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..d95472dc493e6d58a611317df05c2f90b49145c6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineCoveredSourceWithCutoff.lean @@ -0,0 +1,405 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedSlicedIdealTransferWithCutoff +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineWholeProfileComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +universe uJ +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) +variable (d : ℕ) + +include hrows hcard in +theorem allocatedAffineCoefficient_from_reference_l1_withCutoff + {δ η : ℝ} (hδ : 0 < δ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) + (hρpos : ∀ P, 0 < ρ P) (hρone : ∀ P, ρ P ≤ 1) (t : ℝ) (htone : t ≤ 1) : + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + (_hcutoff : AllocatedTailCutoffCompatible U basis S.value d), + ∀ (hσsmall : ∀ j, σ j ≤ t), + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (_hMk : 0 < Mk) + (_hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (_hP : 0 ≤ P) (_hMkP : (Mk : ℝ) ≤ Real.exp P) + (_hRP : ∀ j, R j ≤ Real.exp P) (_hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (_hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + let L := principalAxisLength (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S) + let hL := fun j : PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)) + ∀ (H step : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (_hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (_hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : ℕ) (hm : 0 < modulus) + (residue : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ZMod modulus) + (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + (_hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (_hε : 0 ≤ ε) (_hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) (_hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (_hq : Fintype.card α ≤ d + 1) + {e εcoef : ℝ} (_he : 0 ≤ e) (_hεcoef : 0 < εcoef) (_hεe : εcoef⁻¹ ≤ Real.exp e) + (_hlarge : Real.exp (allocatedKernelReplacementLogWithCutoff (G := G) B d α O P e) ≤ S.value) + (_hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S)) + (_hv₀ : (containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0), + let outputResidue := fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ {mesh Cmask : ℝ} (_hmesh0 : 0 ≤ mesh) (_hmesh1 : mesh ≤ 1) + (_hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (_hCmask : 1 ≤ Cmask) + (_hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ≤ Cmask), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let law := containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize + let proxy := fun z : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) → ℝ => + (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) modulus + (lt_of_lt_of_le (by decide : 0 < 2) (hH j)) (fun _ => modulus) (residue j) (fun _ => hm) (fun _ => le_rfl) (hsize j))).mean + (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (principalTupleFlatten (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j)) z) + (∫ z, |allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z - + allocatedLongProfileDensity B U basis S x rows modulus outputResidue proxy z| + ∂allocatedLongJetReference B U basis S O) ≤ + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask → + (∫ z, |law.mean (fun v => allocatedLongJetDensity B U basis hR hσ S x u v rows s hA + (fun j => (hσsmall j).trans htone) z) - + allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z| + ∂allocatedLongJetReference B U basis S O) ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} * εcoef * + (1 + (layerKernelIndexBound (max m d) Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}) + + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask + := by + intro J _ U basis R σ hR hσ S hcutoff hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L hL H step c hstep hH hsubset hdense modulus hm residue hsize hsmall ε hε hmesh + selection hx hq e εcoef he hεcoef hεe hlarge hperiod v₀ hv₀ outputResidue + mesh Cmask hmesh0 hmesh1 hscaleMesh hCmask hmask + center width ideal law proxy href + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have hw := principalProgressionSlice_parameters (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) + L H step c hL hstep hH hδ hsubset hdense + have hg := allocatedAffineIdeal_profile_integrable B U basis hR S x rows hRP hRi + (ρ (allocatedGridAxis (I := I) U basis S.value)) (hρpos _) (hρone _) + center width (fun i => (hw i).2.2) modulus outputResidue hCmask hmask + have hlong := allocatedSlicedLongJet_ideal_transfer_withCutoff B U basis hR hσ S x rows d hcutoff + hMk selection hx hq hrows hcard hσ1 hP he hεcoef hMkP hRP hRi hσi hcount hεe hlarge + modulus hperiod s hA hi u H step c (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset hm residue hsize + v₀ hv₀ (allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal) + hg (Eref := allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask) href + exact hlong + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) +variable (d : ℕ) + +def AllocatedAffineCoefficientComparisonWithCutoff + (δ η : ℝ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (htone : t ≤ 1) : Prop := + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + (hcutoff : AllocatedTailCutoffCompatible U basis S.value d), + ∀ (hσsmall : ∀ j, σ j ≤ t), + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (hMk : 0 < Mk) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) + (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + let L := principalAxisLength (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S) + let hL := fun j : PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)) + ∀ (H step : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : ℕ) (hm : 0 < modulus) + (residue : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ZMod modulus) + (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ d + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLogWithCutoff (G := G) B d α O P e) ≤ S.value) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0), + let outputResidue := fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ≤ Cmask), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let law := containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize + (∫ z, |law.mean (fun v => allocatedLongJetDensity B U basis hR hσ S x u v rows s hA + (fun j => (hσsmall j).trans htone) z) - + allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z| + ∂allocatedLongJetReference B U basis S O) ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} * εcoef * + (1 + (layerKernelIndexBound (max m d) Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}) + + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask + +omit [∀ j, Nonempty (O j)] in +include hrows hcard in +theorem allocatedAffineCoefficientComparison_of_reference_withCutoff + {δ η : ℝ} (hδ : 0 < δ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) + (hρpos : ∀ P, 0 < ρ P) (hρone : ∀ P, ρ P ≤ 1) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineReferenceComparison.{uJ, _, _, _, _, _} (G := G) B rows δ η ρ t) : + AllocatedAffineCoefficientComparisonWithCutoff.{uJ, _, _, _, _, _} (G := G) B rows d δ η ρ t htone := by + unfold AllocatedAffineCoefficientComparisonWithCutoff + intro J _ U basis R σ hR hσ S hcutoff hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L hL H step c hstep hH hsubset hdense modulus hm residue hsize hsmall ε hε hmesh + selection hx hq e εcoef he hεcoef hεe hlarge hperiod v₀ hv₀ outputResidue + mesh Cmask hmesh0 hmesh1 hscaleMesh hCmask hmask + center width ideal law + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have href := hs U basis hR hσ S hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + L step H (fun _ => modulus) c hL hstep hH hsubset hdense (fun _ _ => modulus) residue + (fun _ _ => hm) (fun _ _ => le_rfl) hsize hsmall hε hmesh + modulus outputResidue hmesh0 hmesh1 hscaleMesh hCmask hmask + with_reducible + refine allocatedAffineCoefficient_from_reference_l1_withCutoff B rows hrows hcard d hδ ρ hρpos hρone t htone + U basis hR hσ S hcutoff hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + H step c hstep hH hsubset hdense modulus hm residue hsize hsmall hε hmesh + selection hx hq he hεcoef hεe hlarge hperiod v₀ hv₀ hmesh0 hmesh1 hscaleMesh hCmask hmask ?_ + exact href + +include hrows hcard in +theorem exists_early_allocated_affine_coefficient_source_withCutoff + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ η : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T (δ / 2) η) ∧ + ∃ t : ℝ, 0 < t ∧ ∃ htone : t ≤ 1, + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T (δ / 2) η ∧ + AllocatedAffineCoefficientComparisonWithCutoff.{uJ, _, _, _, _, _} (G := G) B rows d δ η ρ t htone := by + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_reference_source (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + refine ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, ?_⟩ + exact allocatedAffineCoefficientComparison_of_reference_withCutoff B rows hrows hcard d hδ ρ + (fun P => hρmin.trans_le (hρ P).1) (fun P => (hρ P).2) t htone hs + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory Module Submodule +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) +variable (d : ℕ) + +def AllocatedAffineCoveredComparisonWithCutoff + (δ η : ℝ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) (t : ℝ) (_htone : t ≤ 1) : Prop := + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + (hcutoff : AllocatedTailCutoffCompatible U basis S.value d), + ∀ (hσsmall : ∀ j, σ j ≤ t), + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (hMk : 0 < Mk) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) + (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + let L := principalAxisLength (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S) + let hL := fun j : PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) => allocatedPrincipalSides_pos B U basis S + (Sigma.mk (Subtype.val (Sigma.fst j)) (Sigma.snd j)) + ∀ (H step : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : ℕ) (hm : 0 < modulus) + (residue : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ZMod modulus) + (hsize : ∀ j, (Fintype.card α + 1) * modulus ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((modulus : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x) + (hq : Fintype.card α ≤ d + 1) + {e εcoef : ℝ} (he : 0 ≤ e) (hεcoef : 0 < εcoef) (hεe : εcoef⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLogWithCutoff (G := G) B d α O P e) ≤ S.value) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (v₀ : PrincipalAxisTuples (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a) (allocatedPrincipalSides B U basis S)) + (hv₀ : (containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize).weight v₀ ≠ 0), + let outputResidue := fun j => integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v₀) modulus + ∀ {mesh Cmask : ℝ} (hmesh0 : 0 ≤ mesh) (hmesh1 : mesh ≤ 1) + (hscaleMesh : 1 / (S.value : ℝ) ^ (layerTailDegree m + 1) ≤ mesh) + (hCmask : 1 ≤ Cmask) + (hmask : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (outputResidue j) z ≤ Cmask), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let law := containedProgressionResidueLaw (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step c hL + (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) hsubset modulus hm residue hsize + ∀ (Q : Fin m → Type uQ) [∀ j, Fintype (Q j)] + (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (deckModulus : ℕ) [NeZero deckModulus] + (F : AllocatedFrozenCoefficients B U basis S × EuclideanJetLayers U O → ℂ) + (hF : Measurable F) (hFbound : ∀ p, ‖F p‖ ≤ 1), + ‖(∫ p, law.complexMean (fun v => F (((allocatedCoefficientSplit B U basis S) p.1).1, + euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x (principalAxisJoin (allocatedGridAxis (I := I) U basis S.value) u v)) + (allocatedPhysicalCubeDirections B U basis S x (principalAxisJoin (allocatedGridAxis (I := I) U basis S.value) u v)) rows + (canonicalCoefficientDeckSample U bW basis hb o deckModulus (Nat.pos_of_ne_zero (NeZero.ne deckModulus)) p.1 p.2))) + ∂(allocatedCoefficientSource B U basis hR hσ S).prod + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q deckModulus)).toMeasure) - + ∫ a₀, ∫ z, (allocatedLongProfileDensity B U basis S x rows modulus outputResidue ideal z : ℂ) * + allocatedCoveredFixedTest B U basis S x u v₀ rows Q hb o bW deckModulus F a₀ z + ∂allocatedLongJetReference B U basis S O ∂allocatedFrozenCoefficientSource B U basis hR hσ S‖ ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1)^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + (Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} * εcoef * + (1 + (layerKernelIndexBound (max m d) Mk : ℝ) * Real.exp (allocatedDensityLog (G := G) B α O P) + εcoef)^ + Fintype.card {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}) + + allocatedAffineSourceReferenceError B U basis S α O + (ρ (allocatedGridAxis (I := I) U basis S.value)) P η (fun _ => modulus) H ε mesh Cmask + +omit [∀ j, Nonempty (O j)] in +theorem allocatedAffineCoveredComparison_of_coefficient_withCutoff + {δ η : ℝ} (hδ : 0 < δ) (ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0) + (hρpos : ∀ P, 0 < ρ P) (hρone : ∀ P, ρ P ≤ 1) (t : ℝ) (htone : t ≤ 1) + (hs : AllocatedAffineCoefficientComparisonWithCutoff.{uJ, _, _, _, _, _} (G := G) B rows d δ η ρ t htone) : + AllocatedAffineCoveredComparisonWithCutoff.{uJ, uQ, _, _, _, _, _} (G := G) B rows d δ η ρ t htone := by + unfold AllocatedAffineCoveredComparisonWithCutoff + intro J _ U basis R σ hR hσ S hcutoff hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L hL H step c hstep hH hsubset hdense modulus hm residue hsize hsmall ε hε hmesh + selection hx hq e εcoef he hεcoef hεe hlarge hperiod v₀ hv₀ outputResidue + mesh Cmask hmesh0 hmesh1 hscaleMesh hCmask hmask + center width ideal law + Q _ hb o bW deckModulus _ F hF hFbound + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have hc := hs U basis hR hσ S hcutoff hσsmall x u s hA hMk hi hP hMkP hRP hRi hσi hcount + H step c hstep hH hsubset hdense modulus hm residue hsize hsmall hε hmesh + selection hx hq he hεcoef hεe hlarge hperiod v₀ hv₀ + hmesh0 hmesh1 hscaleMesh hCmask hmask + have hw := principalProgressionSlice_parameters (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) + L H step c hL hstep hH hδ hsubset hdense + have hg := allocatedAffineIdeal_profile_integrable B U basis hR S x rows hRP hRi + (ρ (allocatedGridAxis (I := I) U basis S.value)) (hρpos _) (hρone _) + center width (fun i => (hw i).2.2) modulus outputResidue hCmask hmask + exact allocatedSlicedPhysicalCovered_test_comparison_of_l1 B U basis hR hσ S x u v₀ rows + Q hb o bW deckModulus s hA hσ1 modulus hperiod F H step c (fun j => lt_of_lt_of_le (by decide : 0 < 2) (hH j)) + hsubset hm residue hsize hv₀ _ hg hc hF hFbound + +include hrows hcard in +theorem exists_early_allocated_affine_covered_source_withCutoff + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ η : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T (δ / 2) η) ∧ + ∃ t : ℝ, 0 < t ∧ ∃ htone : t ≤ 1, + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T (δ / 2) η ∧ + AllocatedAffineCoveredComparisonWithCutoff.{uJ, uQ, _, _, _, _, _} (G := G) B rows d δ η ρ t htone := by + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_coefficient_source_withCutoff (G := G) B rows hrows hcard d + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + refine ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, ?_⟩ + exact allocatedAffineCoveredComparison_of_coefficient_withCutoff B rows d hδ ρ + (fun P => hρmin.trans_le (hρ P).1) (fun P => (hρ P).2) t htone hs + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineL1Scales.lean b/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineL1Scales.lean new file mode 100644 index 0000000000000000000000000000000000000000..717c572414adf1a06585dc511c32df614c5ac860 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineL1Scales.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineWholeProfileComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j a, (rows j a).card ≤ j.val + 1) + +include hrows hcard in +theorem exists_early_allocated_affine_l1_scales + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ target Pk F Tmod D : ℝ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) (hδ : 0 < δ) (hδone : δ ≤ 1) + (htarget : 0 ≤ target) (hPk : 0 ≤ Pk) (hF : 0 ≤ F) (hTmod : 0 ≤ Tmod) + (hδF : (δ / 2)⁻¹ ≤ Real.exp F) : + let maskLog := D * ((m * 2 ^ (m + 1) : ℕ) * Pk) + let E := target + maskLog + 5 + let η := Real.exp (-E) + let Prho := 2 * affineProfileInputEnvelope D (A : ℝ) (T : ℝ) E F + 2 + let Ptail := affineProfileToleranceEnvelope m D (D * (D + 1) + D * D + D + 1) (A : ℝ) (T : ℝ) E F + let K := Classical.choose (exists_allocatedAffineScaleLog_bound m) + 0 ≤ Prho ∧ 0 ≤ Ptail ∧ + ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ partition, 0 < ρ partition ∧ ρ partition ≤ 1 ∧ (ρ partition : ℝ)⁻¹ ≤ Real.exp Prho) ∧ + ∃ t : ℝ, 0 < t ∧ ∃ htone : t ≤ 1, + t⁻¹ ≤ Real.exp Ptail ∧ + AllocatedAffineCoveredComparison.{uJ,uQ,_,_,_,_,_} (G := G) B rows δ η ρ t htone ∧ + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + (R : Fin m → ℝ), (∀ j, 0 < R j) → + ∀ {p : ℝ}, 0 ≤ p → (∀ j, (R j)⁻¹ ≤ Real.exp p) → + let P := p + Ptail + ∃ S : LayerSamplerScale (G := G) B U basis R (fun _ => t), + (∀ j, (R j)⁻¹ ≤ Real.exp P) ∧ (∀ j : Fin m, ((fun _ => t) j)⁻¹ ≤ Real.exp P) ∧ + Real.exp (allocatedAffineLengthLog m D P Prho Pk target F Tmod) ≤ S.value ∧ + (S.value : ℝ) ≤ Real.exp ((D + P + Prho + Pk + target + F + Tmod + K) ^ K) := by + intro maskLog E η Prho Ptail K + have hD := hdim.nonneg + have hm : 0 ≤ maskLog := by dsimp [maskLog]; positivity + have hE : 0 ≤ E := by dsimp [E]; positivity + have hcoeff : 0 ≤ affineProfileCoefficientEnvelope D (A : ℝ) (T : ℝ) := by + unfold affineProfileCoefficientEnvelope; positivity + have hinput : 0 ≤ affineProfileInputEnvelope D (A : ℝ) (T : ℝ) E F := + jointAffineSourceEnvelope_nonneg hD hcoeff (by positivity) hF + have hr : 0 ≤ Prho := by dsimp [Prho]; positivity + have htail : 0 ≤ Ptail := by + dsimp [Ptail, affineProfileToleranceEnvelope] + positivity + obtain ⟨ρ, hρ, _, t, ht, htone, htlog, _, hs⟩ := + exists_early_allocated_affine_bounded_source.{uJ,uQ} B rows hrows hcard ψ hψ hrange hzero hone + A T hLip hTransition block hblock hdim hδ hδone htarget hm hF hδF + refine ⟨hr, htail, ρ, ?_, t, ht, htone, htlog, hs, ?_⟩ + · intro partition + refine ⟨(hρ partition).1, (hρ partition).2.1, ?_⟩ + have hlow := (hρ partition).2.2 + rw [Real.exp_neg] at hlow + exact (inv_le_comm₀ (show 0 < (ρ partition : ℝ) from (hρ partition).1) (Real.exp_pos Prho)).mpr hlow + · intro J _ U basis R hR p hp hRi P + have hP : 0 ≤ P := add_nonneg hp htail + have hRbound (j) : (R j)⁻¹ ≤ Real.exp P := + (hRi j).trans (Real.exp_le_exp.mpr (le_add_of_nonneg_right htail)) + have htbound : t⁻¹ ≤ Real.exp P := + htlog.trans (Real.exp_le_exp.mpr (le_add_of_nonneg_left hp)) + let S := allocatedAffineScale (G := G) B U basis hR (fun _ => ht) D P Prho Pk target F Tmod + refine ⟨S, hRbound, fun _ => htbound, + allocatedAffineScale_lower B U basis hR (fun _ => ht) D P Prho Pk target F Tmod, ?_⟩ + exact (allocatedAffineScale_upper B U basis hR (fun _ => ht) hdim hP hr hPk htarget hF hTmod + hRbound (fun _ => htbound)).trans (Real.exp_le_exp.mpr + ((Classical.choose_spec (exists_allocatedAffineScaleLog_bound m)).2 + D P Prho Pk target F Tmod hD hP hr hPk htarget hF hTmod)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineResidueSource.lean b/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineResidueSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cc5bd303ab30158efde505dbd7cfd57666bcf16 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/EarlyAllocatedAffineResidueSource.lean @@ -0,0 +1,565 @@ +import OAI.Combinatorics.Progressions.Estimates.OneCubePrincipalSliceRiemann +import OAI.Combinatorics.Progressions.Geometry.AllocatedProxyOutputSupport +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineRadiusLog + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +include hrows hcard in +theorem exists_early_allocated_affine_proxy_l1_with_scales + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ ε : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T δ ε) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T δ ε ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (_hR : ∀ j, 0 < R j) (_hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + (∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + (center width : (PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ), + (∀ i, δ ≤ |width i|) → (∀ i, |center i| + |width i| ≤ 1) → + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + (∫ v, |diagonalImageDensity + (fun o : (Σ a : {a // ¬allocatedGridAxis (I := I) U basis S.value a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) + (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) v - + allocatedAffineLongJetProxy B U basis S x u rows s hA center width v|) ≤ ε := by + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_tail_test_comparison_with_scales (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hε + refine ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, ?_⟩ + intro J _ U basis R σ hR hσ S hsmall x u center width hwidth hcenter s hA + let P := allocatedGridAxis (I := I) U basis S.value + have hρpos : 0 < ρ P := hρmin.trans_le (hρ P).1 + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hsmall j).trans htone + have hi := activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) + (G × Option α) (layerSamplerDegree I n) P (fun a => rows a.val.1) (ρ P) hρpos center width + have hp := allocatedAffineLongJetProxy_probability B U basis hR hσ S x u rows s hA + center width hσ1 + have hm : Measurable (allocatedAffineLongJetProxy B U basis S x u rows s hA center width) := + (allocatedAffineLongJetDensity_measurable B U basis hR hσ S x u rows s hA + center width hσ1).stronglyMeasurable.integral_prod_left'.measurable + apply diagonalImageDensity_l1_le_of_tests _ (fun o => (hR o.1.val.1).ne') _ _ + hi.2.1.continuous.measurable hm hi.2.2.1 hp.2.1 + intro f hf hfb + rw [allocatedAffineLongJetProxy_test_integral B U basis hR hσ S x u rows s hA center width hσ1 f hf] + exact hs U basis hσ S hsmall x u center width hwidth hcenter f hf hfb + +include hrows hcard in +theorem exists_early_allocated_affine_proxy_l1 + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ ε : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (_hR : ∀ j, 0 < R j) (_hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + (∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)) + (center width : (PrincipalAxisParameter (B := B) (h := (layerSamplerDegree I n)) (α := α) (fun a => ¬(allocatedGridAxis (I := I) U basis S.value) a)) → ℝ), + (∀ i, δ ≤ |width i|) → (∀ i, |center i| + |width i| ≤ 1) → + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + (∫ v, |diagonalImageDensity + (fun o : (Σ a : {a // ¬allocatedGridAxis (I := I) U basis S.value a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) + (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) v - + allocatedAffineLongJetProxy B U basis S x u rows s hA center width v|) ≤ ε := by + obtain ⟨ρmin, hρmin, ρ, hρ, _, t, ht, htone, _, hs⟩ := + exists_early_allocated_affine_proxy_l1_with_scales (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hε + exact ⟨ρmin, hρmin, ρ, hρ, t, ht, htone, hs⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j : Fin m, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := O j) + S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "Jet" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +local notation "bound" => NNReal.mk + (Real.exp (allocatedDensityLog (G := G) B α O P)) (Real.exp_nonneg _) +local notation "cap" => bound ^ Fintype.card (LayerSamplerAxis I n) +local notation "lip" => (Fintype.card (LayerSamplerAxis I n) : ℝ≥0) * bound * cap + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +theorem allocatedAffineLongJetProxy_residue_error (hσ1 : ∀ j, σ j ≤ 1) + (L step H M : Tuple → ℕ) (c : Tuple → ℤ) + (hL : ∀ j, 0 < L j) (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + {δ : ℝ} (hδ : 0 < δ) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : Tuple → Option α → ℕ) (residue : ∀ j i, ZMod (modulus j i)) + (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j) + (hsize : ∀ j, (Fintype.card α + 1) * M j ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((M j : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) (z : Jet → ℝ) : + |(FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) (hsize j))).mean + (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (principalTupleFlatten (fun a : {a // ¬grid a} => B a.val) (fun a => degree a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j)) z) - + allocatedAffineLongJetProxy B U basis S x u rows s hA + (principalProgressionSliceCenter (α := α) (fun a : {a // ¬grid a} => B a.val) + (fun a => degree a.val) L c) + (principalProgressionSliceWidth (α := α) (fun a : {a // ¬grid a} => B a.val) + (fun a => degree a.val) L H step) z| ≤ + (2 * (cap : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + + (lip : ℝ) * 2) * ∑ j, (M j : ℝ) / H j + (lip : ℝ) * ε := by + have hb := allocatedNormalizedLongJetDensity_parameter_bounds B U basis hR hσ S x + rows s hA hMk hi hP hMkP hRP hRi hσi hcount u hσ1 z + exact principalProgressionSlice_residue_riemann + (fun a : {a // ¬grid a} => B a.val) (fun a => degree a.val) + L step H M c hL hstep hH hδ hsubset hdense modulus residue hm hmM hsize hsmall hε hmesh + (fun y => allocatedNormalizedLongJetDensity B U basis S x u rows s hA y z) + hb.2 (NNReal.coe_nonneg cap) (fun y _ => hb.1 y) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [dG : DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {M : ℕ} (hM : 0 < M) +variable (hi : ∀ j : Fin m, + fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMP : (M : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "radius" => Real.exp (allocatedJetSupportLog (G := G) B α O P) +local notation "input" => PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) +local notation "output" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) + +include hR hσ hM hi hP hMP hRP hRi hσi hcount + +theorem allocatedAffineLongJetProxy_output_bounds (hσ1 : ∀ j, σ j ≤ 1) + (center width : input → ℝ) : + let bound : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), Real.exp_nonneg _⟩ + let cap := bound ^ Fintype.card (LayerSamplerAxis I n) + let lip := (Fintype.card (LayerSamplerAxis I n) : ℝ≥0) * bound * cap + (∀ z, allocatedAffineLongJetProxy B U basis S x u rows s hA center width z ∈ Set.Icc (0 : ℝ) cap) ∧ + LipschitzWith lip (allocatedAffineLongJetProxy B U basis S x u rows s hA center width) := by + intro bound cap lip + have hm := allocatedAffineLongJetDensity_measurable B U basis hR hσ S x u rows s hA center width hσ1 + have hb (y : input → ℝ) := allocatedNormalizedLongJetDensity_output_bounds + B U basis hR hσ S x rows s hA hM hi hP hMP hRP hRi hσi hcount u hσ1 + (fun i => center i + width i * y i) + exact densityMixture_uniform_bound (jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val)) + (allocatedAffineLongJetDensity B U basis S x u rows s hA center width) cap lip + (fun z => (hm.comp (measurable_id.prodMk measurable_const)).aestronglyMeasurable) + (Filter.Eventually.of_forall hb) + +theorem allocatedAffineLongJetProxy_zero_off_ball (hσ1 : ∀ j, σ j ≤ 1) + (center width : input → ℝ) (hw : ∀ i, |center i| + |width i| ≤ 1) + (v : output → ℝ) (hv : radius < ‖v‖) : + allocatedAffineLongJetProxy B U basis S x u rows s hA center width v = 0 := by + apply integral_eq_zero_of_ae + filter_upwards [jointBooleanSource_ae_closedBall (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val)] with y hy + have hy' : ‖y‖ ≤ 1 := by simpa only [Metric.mem_closedBall, dist_zero_right] using hy + have hs : ‖fun i => center i + width i * y i‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg (by norm_num : (0 : ℝ) ≤ 1)).mpr + intro i + have hiy : |y i| ≤ 1 := (norm_le_pi_norm y i).trans hy' + calc + ‖center i + width i * y i‖ ≤ |center i| + |width i| * |y i| := by + simpa only [Real.norm_eq_abs, abs_mul] using norm_add_le (center i) (width i * y i) + _ ≤ |center i| + |width i| := add_le_add le_rfl + (by simpa using mul_le_mul_of_nonneg_left hiy (abs_nonneg (width i))) + _ ≤ 1 := hw i + exact allocatedNormalizedLongJetDensity_zero_off_ball B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount u hσ1 _ hs v hv + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j : Fin m, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {Mk : ℕ} (hMk : 0 < Mk) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound (O := O j) + S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (Mk : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMkP : (Mk : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "degree" => layerSamplerDegree I n +local notation "Tuple" => PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) (fun a => degree (Subtype.val a)) +local notation "Jet" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) +local notation "bound" => NNReal.mk + (Real.exp (allocatedDensityLog (G := G) B α O P)) (Real.exp_nonneg _) +local notation "cap" => bound ^ Fintype.card (LayerSamplerAxis I n) +local notation "lip" => (Fintype.card (LayerSamplerAxis I n) : ℝ≥0) * bound * cap + +include hR hσ hMk hi hP hMkP hRP hRi hσi hcount in +theorem allocatedAffineLongJetProxy_residue_l1 (hσ1 : ∀ j, σ j ≤ 1) + (L step H M : Tuple → ℕ) (c : Tuple → ℤ) + (hL : ∀ j, 0 < L j) (hstep : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + {δ : ℝ} (hδ : 0 < δ) + (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (hdense : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : Tuple → Option α → ℕ) (residue : ∀ j i, ZMod (modulus j i)) + (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j) + (hsize : ∀ j, (Fintype.card α + 1) * M j ≤ H j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((M j : ℝ) / H j) < + volume.real (scalarCubeDomain α)) + {ε : ℝ} (hε : 0 ≤ ε) (hmesh : ∀ j, (step j : ℝ) / L j ≤ ε) : + let Δ := fun z : Jet → ℝ => (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) (hsize j))).mean + (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (principalTupleFlatten (fun a : {a // ¬grid a} => B a.val) (fun a => degree a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j)) z) - + allocatedAffineLongJetProxy B U basis S x u rows s hA + (principalProgressionSliceCenter (α := α) (fun a : {a // ¬grid a} => B a.val) + (fun a => degree a.val) L c) + (principalProgressionSliceWidth (α := α) (fun a : {a // ¬grid a} => B a.val) + (fun a => degree a.val) L H step) z + Integrable Δ ∧ (∫ z, |Δ z|) ≤ + ((2 * (cap : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + + (lip : ℝ) * 2) * ∑ j, (M j : ℝ) / H j + (lip : ℝ) * ε) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card Jet := by + intro Δ + let weights := FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) (hsize j)) + let tupleLower := fun (a : {a // ¬grid a}) (p : B a.val × Fin (degree a.val)) => (c ⟨a,p⟩ : ℝ) / L ⟨a,p⟩ + let tupleWidth := fun (a : {a // ¬grid a}) (p : B a.val × Fin (degree a.val)) => + (step ⟨a,p⟩ : ℝ) * ((H ⟨a,p⟩ : ℝ) - 1) / L ⟨a,p⟩ + let F := fun (v : ∀ j, IntegerScalarCubeBox α (H j)) => + principalTupleFlatten (fun a : {a // ¬grid a} => B a.val) (fun a => degree a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j) + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬grid a} => B a.val) + (fun a => degree a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬grid a} => B a.val) + (fun a => degree a.val) L H step + let proxy := allocatedAffineLongJetProxy B U basis S x u rows s hA center width + let density := allocatedNormalizedLongJetDensity B U basis S x u rows s hA + let radius := Real.exp (allocatedJetSupportLog (G := G) B α O P) + have hw (a) (p) : |tupleLower a p| + |tupleWidth a p| ≤ 1 := + (progression_slice_endpoint_geometry (c ⟨a,p⟩) (hL _) (hstep _) (hH _) hδ + (hsubset _) (hdense _)).2.2.1 + have hF (v) (hv : 0 < weights.weight v) : ‖F v‖ ≤ 1 := by + apply (principalTupleFlatten_norm_apply_le _ _ _ _).trans + apply progressionTuple_norm_le L step H c hH (fun j => hw j.1 j.2) v + intro j + exact scalarCubeResidueWeights_cube_support α (H j) (M j) (by have := hH j; omega) + (modulus j) (residue j) (hm j) (hmM j) (hsize j) (v j) + (FiniteProbabilityWeights.pi_weight_pos_component _ v hv j) + have hs (z : Jet → ℝ) (hz : radius < ‖z‖) : Δ z = 0 := by + have hp : proxy z = 0 := allocatedAffineLongJetProxy_zero_off_ball B U basis hR hσ S x rows s hA + hMk hi hP hMkP hRP hRi hσi hcount u hσ1 center width + (fun i => (principalProgressionSlice_parameters (α := α) + (fun a : {a // ¬grid a} => B a.val) (fun a => degree a.val) + L H step c hL hstep hH hδ hsubset hdense i).2.2) z hz + have hd : weights.mean (fun v => density (F v) z) = 0 := by + apply Finset.sum_eq_zero + intro v _ + by_cases hv : weights.weight v = 0 + · simp only [hv, zero_mul] + · have hf := allocatedNormalizedLongJetDensity_zero_off_ball B U basis hR hσ S x + rows s hA hMk hi hP hMkP hRP hRi hσi hcount u hσ1 (F v) + (hF v (lt_of_le_of_ne (weights.nonneg v) (Ne.symm hv))) z hz + exact mul_eq_zero_of_right _ hf + exact sub_eq_zero.mpr (hd.trans hp.symm) + have hint : Integrable (fun z => weights.mean (fun v => density (F v) z)) := by + apply integrable_finsetSum + intro v _ + exact ((allocatedNormalizedLongJetDensity_probability B U basis hR hσ S x u + rows s hA hσ1 (F v)).2.1).const_mul (weights.weight v) + have hip := (allocatedAffineLongJetProxy_probability B U basis hR hσ S x u rows s hA + center width hσ1).2.1 + refine ⟨hint.sub hip, ?_⟩ + apply integral_norm_le_box Δ (Real.exp_nonneg _) hs + intro z _ + exact allocatedAffineLongJetProxy_residue_error B U basis hR hσ S x u rows s hA hMk hi hP hMkP + hRP hRi hσi hcount hσ1 L step H M c hL hstep hH hδ hsubset hdense + modulus residue hm hmM hsize hsmall hε hmesh z + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory +open scoped BigOperators ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + +include hrows hcard in +theorem exists_early_allocated_affine_residue_source_with_scales + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ η : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ + (∀ P, (ρ P : ℝ) = partitionedAffineSourceRadius (B := B) + (O := fun a : {a // ¬P a} => O a.val.1) (α := α) (layerSamplerDegree I n) P A T (δ / 2) η) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = allocatedAffineSourceTolerance (G := G) (O := O) (α := α) B A T (δ / 2) η ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (_hR : ∀ j, 0 < R j) (_hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + (∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (_ : 0 < Mk) + (_ : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (_ : 0 ≤ P) (_ : (Mk : ℝ) ≤ Real.exp P) + (_ : ∀ j, R j ≤ Real.exp P) (_ : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (_ : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_ : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + ∀ (L step H M : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (_ : ∀ j, 0 < L j) (_ : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (_ : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (_ : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ℕ) (residue : ∀ j i, ZMod (modulus j i)) + (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j) + (hsize : ∀ j, (Fintype.card α + 1) * M j ≤ H j) + (_ : ∀ j, scalarCubeGridBoundaryConstant α * ((M j : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (_ : 0 ≤ ε) (_ : ∀ j, (step j : ℝ) / L j ≤ ε), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let discrete := fun z : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) → ℝ => + (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) (hsize j))).mean + (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (principalTupleFlatten (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j)) z) + let bound : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), Real.exp_nonneg _⟩ + let cap := bound ^ Fintype.card (LayerSamplerAxis I n) + let lip := (Fintype.card (LayerSamplerAxis I n) : ℝ≥0) * bound * cap + (∫ z, |ideal z - discrete z|) ≤ η + + ((2 * (cap : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + + (lip : ℝ) * 2) * ∑ j, (M j : ℝ) / H j + (lip : ℝ) * ε) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) := by + have hδhalf1 : δ / 2 ≤ 1 := by linarith + obtain ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, hs⟩ := + exists_early_allocated_affine_proxy_l1_with_scales (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock (half_pos hδ) hδhalf1 hη + refine ⟨ρmin, hρmin, ρ, hρ, hρeq, t, ht, htone, hteq, ?_⟩ + intro J _ U basis R σ hR hσ S hσsmall x u s hA Mk hMk hi P hP hMkP hRP hRi hσi hcount + L step H M c hL hstep hH hsubset hdense modulus residue hm hmM hsize hsmall ε hε hmesh + center width ideal discrete bound cap lip + have hσ1 : ∀ j, σ j ≤ 1 := fun j => (hσsmall j).trans htone + have hg := principalProgressionSlice_parameters (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) + L H step c hL hstep hH hδ hsubset hdense + have hcont := hs U basis hR hσ S hσsmall x u center width + (fun i => (hg i).2.1) (fun i => (hg i).2.2) s hA + have hdisc := allocatedAffineLongJetProxy_residue_l1 B U basis hR hσ S x u rows s hA + hMk hi hP hMkP hRP hRi hσi hcount hσ1 L step H M c hL hstep hH hδ hsubset hdense + modulus residue hm hmM hsize hsmall hε hmesh + let proxy := allocatedAffineLongJetProxy B U basis S x u rows s hA center width + have hρpos : 0 < ρ (allocatedGridAxis (I := I) U basis S.value) := hρmin.trans_le (hρ (allocatedGridAxis (I := I) U basis S.value)).1 + have hideal := activeAveragedSlicedProfileIdeal_spec (G := G) (B := B) + (G × Option α) (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) hρpos center width + have hIi : Integrable ideal := diagonalImageDensity_integrable + (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) (fun o => (hR o.1.val.1).ne') hideal.2.2.1 + have hp := (allocatedAffineLongJetProxy_probability B U basis hR hσ S x u rows s hA center width hσ1).2.1 + have hdiff : Integrable (fun z => ideal z - proxy z) := hIi.sub hp + calc + _ ≤ ∫ z, (|ideal z - proxy z| + |discrete z - proxy z|) := by + apply integral_mono_of_nonneg (Filter.Eventually.of_forall (fun _ => abs_nonneg _)) + (hdiff.abs.add hdisc.1.abs) + apply Filter.Eventually.of_forall + intro z + change |ideal z - discrete z| ≤ |ideal z - proxy z| + |discrete z - proxy z| + simpa only [abs_sub_comm (proxy z) (discrete z)] using abs_sub_le (ideal z) (proxy z) (discrete z) + _ = (∫ z, |ideal z - proxy z|) + ∫ z, |discrete z - proxy z| := integral_add hdiff.abs hdisc.1.abs + _ ≤ _ := add_le_add hcont hdisc.2 + +include hrows hcard in +theorem exists_early_allocated_affine_residue_source + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) + (hblock : ∀ a, Function.Injective (block a)) + {δ η : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + ∃ ρmin : ℝ≥0, 0 < ρmin ∧ ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, ρmin ≤ ρ P ∧ ρ P ≤ 1) ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ∀ {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (_hR : ∀ j, 0 < R j) (_hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ), + (∀ j, σ j ≤ t) → + ∀ (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) (allocatedPrincipalSides B U basis S)), + ∀ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + ∀ {Mk : ℕ} (_ : 0 < Mk) + (_ : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) + (s j) (hA j) (1 / (Mk : ℝ))) + {P : ℝ} (_ : 0 ≤ P) (_ : (Mk : ℝ) ≤ Real.exp P) + (_ : ∀ j, R j ≤ Real.exp P) (_ : ∀ j, (R j)⁻¹ ≤ Real.exp P) + (_ : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_ : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P), + ∀ (L step H M : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℕ) (c : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → ℤ) + (_ : ∀ j, 0 < L j) (_ : ∀ j, 0 < step j) (hH : ∀ j, 2 ≤ H j) + (_ : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ Finset.Ico (0 : ℤ) (L j : ℤ)) + (_ : ∀ j, δ * L j ≤ ((integerProgressionSupport (c j) (step j : ℤ) (H j)).card : ℝ)) + (modulus : (PrincipalTupleIndex (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val)) → Option α → ℕ) (residue : ∀ j i, ZMod (modulus j i)) + (hm : ∀ j i, 0 < modulus j i) (hmM : ∀ j i, modulus j i ≤ M j) + (hsize : ∀ j, (Fintype.card α + 1) * M j ≤ H j) + (_ : ∀ j, scalarCubeGridBoundaryConstant α * ((M j : ℝ) / H j) < volume.real (scalarCubeDomain α)) + {ε : ℝ} (_ : 0 ≤ ε) (_ : ∀ j, (step j : ℝ) / L j ≤ ε), + let center := principalProgressionSliceCenter (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L c + let width := principalProgressionSliceWidth (α := α) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) L H step + let ideal := diagonalImageDensity (fun o : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) => R o.1.val.1) + (activeAveragedSlicedProfileIdeal (G := G) (B := B) (G × Option α) + (layerSamplerDegree I n) (allocatedGridAxis (I := I) U basis S.value) (fun a => rows a.val.1) (ρ (allocatedGridAxis (I := I) U basis S.value)) center width) + let discrete := fun z : (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) → ℝ => + (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (H j) (M j) + (by have := hH j; omega) (modulus j) (residue j) (hm j) (hmM j) (hsize j))).mean + (fun v => allocatedNormalizedLongJetDensity B U basis S x u rows s hA + (principalTupleFlatten (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => B a.val) (fun a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a} => layerSamplerDegree I n a.val) α + (fun j i => ((if i = none then (c j : ℝ) else 0) + (step j : ℝ) * (v j i : ℝ)) / L j)) z) + let bound : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), Real.exp_nonneg _⟩ + let cap := bound ^ Fintype.card (LayerSamplerAxis I n) + let lip := (Fintype.card (LayerSamplerAxis I n) : ℝ≥0) * bound * cap + (∫ z, |ideal z - discrete z|) ≤ η + + ((2 * (cap : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + + (lip : ℝ) * 2) * ∑ j, (M j : ℝ) / H j + (lip : ℝ) * ε) * + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P)) ^ Fintype.card (Σ a : {a // ¬(allocatedGridAxis (I := I) U basis S.value) a}, O a.val.1) := by + obtain ⟨ρmin, hρmin, ρ, hρ, _, t, ht, htone, _, hs⟩ := + exists_early_allocated_affine_residue_source_with_scales (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη + exact ⟨ρmin, hρmin, ρ, hρ, t, ht, htone, hs⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanDerivativeLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanDerivativeLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..dde1c5862d957122cb4726822fc946ab30a8293e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanDerivativeLattice.lean @@ -0,0 +1,309 @@ +import Mathlib.Algebra.Module.ZLattice.Basic +import Mathlib.LinearAlgebra.Basis.Prod +import Mathlib.LinearAlgebra.Prod +import OAI.Combinatorics.Progressions.Geometry.ProductEuclideanCoordinates +import OAI.Combinatorics.Progressions.Linear.ShortVectorProjection +import OAI.Combinatorics.Progressions.Sampling.DerivativeGridPoints + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def coordinateScaleEquiv {ι : Type*} (d : ι → ℝ) (hd : ∀ i, d i ≠ 0) : + (ι → ℝ) ≃ₗ[ℝ] (ι → ℝ) where + toFun x i := d i * x i + invFun x i := x i / d i + left_inv x := by funext i; exact mul_div_cancel_left₀ (x i) (hd i) + right_inv x := by funext i; exact mul_div_cancel₀ (x i) (hd i) + map_add' x y := by funext i; exact mul_add _ _ _ + map_smul' c x := by funext i; simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply]; ring + +@[simp] theorem coordinateScaleEquiv_apply {ι : Type*} (d : ι → ℝ) (hd : ∀ i, d i ≠ 0) + (x : ι → ℝ) (i : ι) : coordinateScaleEquiv d hd x i = d i * x i := rfl + +@[simp] theorem coordinateScaleEquiv_symm_apply {ι : Type*} (d : ι → ℝ) (hd : ∀ i, d i ≠ 0) + (x : ι → ℝ) (i : ι) : (coordinateScaleEquiv d hd).symm x i = x i / d i := rfl + +noncomputable def derivativeShearEquiv {E F : Type*} [AddCommGroup E] [Module ℝ E] + [AddCommGroup F] [Module ℝ F] (Y : E →ₗ[ℝ] F) (A : F ≃ₗ[ℝ] F) : + (E × F) ≃ₗ[ℝ] (E × F) where + toFun x := (x.1, Y x.1 - A x.2) + invFun x := (x.1, A.symm (Y x.1 - x.2)) + left_inv x := by simp + right_inv x := by simp + map_add' x y := by + refine Prod.ext ?_ ?_ + · rfl + · change Y (x.1 + y.1) - A (x.2 + y.2) = (Y x.1 - A x.2) + (Y y.1 - A y.2) + rw [map_add, map_add] + abel + map_smul' c x := by + refine Prod.ext ?_ ?_ + · rfl + · change Y (c • x.1) - A (c • x.2) = c • (Y x.1 - A x.2) + rw [map_smul, map_smul, smul_sub] + +@[simp] theorem derivativeShearEquiv_apply {E F : Type*} [AddCommGroup E] [Module ℝ E] + [AddCommGroup F] [Module ℝ F] (Y : E →ₗ[ℝ] F) (A : F ≃ₗ[ℝ] F) (x : E × F) : + derivativeShearEquiv Y A x = (x.1, Y x.1 - A x.2) := rfl + +noncomputable def derivativeLatticeEquiv {σ κ : Type*} + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) + (l : ℕ) (hl : 0 < l) : + ((σ → ℝ) × (κ → ℝ)) ≃ₗ[ℝ] ((σ → ℝ) × (κ → ℝ)) := + ((LinearEquiv.refl ℝ (σ → ℝ)).prodCongr + (coordinateScaleEquiv (fun _ : κ => (l : ℝ)⁻¹) (fun _ => inv_ne_zero (by exact_mod_cast hl.ne')))).trans + ((derivativeShearEquiv Y A).trans + ((coordinateScaleEquiv (fun i => (T i)⁻¹) (fun i => inv_ne_zero (hT i))).prodCongr + (coordinateScaleEquiv scale hscale))) + +theorem derivativeLatticeEquiv_apply {σ κ : Type*} + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) + (l : ℕ) (hl : 0 < l) (x : (σ → ℝ) × (κ → ℝ)) : + derivativeLatticeEquiv T hT scale hscale Y A l hl x = + (fun i => x.1 i / T i, fun j => scale j * (Y x.1 - A (fun k => x.2 k / l)) j) := by + simp only [derivativeLatticeEquiv, LinearEquiv.trans_apply, LinearEquiv.prodCongr_apply, + LinearEquiv.refl_apply, derivativeShearEquiv_apply] + refine Prod.ext ?_ ?_ + · funext i + simp only [coordinateScaleEquiv_apply, div_eq_mul_inv, mul_comm] + · funext j + have he : coordinateScaleEquiv (fun _ : κ => (l : ℝ)⁻¹) + (fun _ => inv_ne_zero (by exact_mod_cast hl.ne')) x.2 = (fun k => x.2 k / l) := by + funext k + simp only [coordinateScaleEquiv_apply, div_eq_mul_inv, mul_comm] + exact congrArg (fun v : κ → ℝ => scale j * (Y x.1 - A v) j) he + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {σ κ : Type*} [Fintype σ] [Fintype κ] + +noncomputable def standardProductBasis : + Basis (σ ⊕ κ) ℝ ((σ → ℝ) × (κ → ℝ)) := + (Pi.basisFun ℝ σ).prod (Pi.basisFun ℝ κ) + +theorem standardProductBasis_mem_iff (x : (σ → ℝ) × (κ → ℝ)) : + x ∈ Submodule.span ℤ (Set.range (standardProductBasis (σ := σ) (κ := κ))) ↔ + x.1 ∈ realIntegerGrid ∧ x.2 ∈ realIntegerGrid := by + rw [(standardProductBasis (σ := σ) (κ := κ)).mem_span_iff_repr_mem ℤ x] + constructor + · intro h + have h₁ : ∀ i : σ, ∃ n : ℤ, (n : ℝ) = x.1 i := by + intro i + simpa [standardProductBasis] using h (Sum.inl i) + have h₂ : ∀ i : κ, ∃ n : ℤ, (n : ℝ) = x.2 i := by + intro i + simpa [standardProductBasis] using h (Sum.inr i) + choose a ha using h₁ + choose b hb using h₂ + exact ⟨⟨a, funext ha⟩, ⟨b, funext hb⟩⟩ + · rintro ⟨⟨a, ha⟩, ⟨b, hb⟩⟩ i + cases i with + | inl i => exact ⟨a i, by simpa [standardProductBasis] using congrFun ha i⟩ + | inr i => exact ⟨b i, by simpa [standardProductBasis] using congrFun hb i⟩ + +variable (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) (l : ℕ) (hl : 0 < l) + +noncomputable def derivativeLatticeBasis : Basis (σ ⊕ κ) ℝ ((σ → ℝ) × (κ → ℝ)) := + standardProductBasis.map (derivativeLatticeEquiv T hT scale hscale Y A l hl) + +noncomputable def derivativeLattice : Submodule ℤ ((σ → ℝ) × (κ → ℝ)) := + Submodule.span ℤ (Set.range (derivativeLatticeBasis T hT scale hscale Y A l hl)) + +instance derivativeLattice_discrete : DiscreteTopology (derivativeLattice T hT scale hscale Y A l hl) := + inferInstanceAs (DiscreteTopology (Submodule.span ℤ + (Set.range (derivativeLatticeBasis T hT scale hscale Y A l hl)))) + +instance derivativeLattice_full : IsZLattice ℝ (derivativeLattice T hT scale hscale Y A l hl) := + inferInstanceAs (IsZLattice ℝ (Submodule.span ℤ + (Set.range (derivativeLatticeBasis T hT scale hscale Y A l hl)))) + +theorem derivativeLattice_mem_iff (v : (σ → ℝ) × (κ → ℝ)) : + v ∈ derivativeLattice T hT scale hscale Y A l hl ↔ + ∃ h : σ → ℤ, ∃ z : κ → ℤ, + v = derivativeLatticeEquiv T hT scale hscale Y A l hl + (fun i => (h i : ℝ), fun j => (z j : ℝ)) := by + change v ∈ Submodule.span ℤ (Set.range + (standardProductBasis.map (derivativeLatticeEquiv T hT scale hscale Y A l hl))) ↔ _ + rw [← ZSpan.map] + constructor + · rintro ⟨x, hx, hxv⟩ + obtain ⟨⟨h, hh⟩, ⟨z, hz⟩⟩ := (standardProductBasis_mem_iff x).mp hx + have he : x = ((fun i => (h i : ℝ)), (fun j => (z j : ℝ))) := Prod.ext hh.symm hz.symm + exact ⟨h, z, hxv.symm.trans (congrArg (derivativeLatticeEquiv T hT scale hscale Y A l hl) he)⟩ + · rintro ⟨h, z, rfl⟩ + refine ⟨((fun i => (h i : ℝ)), (fun j => (z j : ℝ))), ?_, rfl⟩ + exact (standardProductBasis_mem_iff _).mpr ⟨⟨h, rfl⟩, ⟨z, rfl⟩⟩ + +theorem derivativeLattice_carrier [DecidableEq κ] : + (derivativeLattice T hT scale hscale Y A l hl : Set ((σ → ℝ) × (κ → ℝ))) = + derivativeGridPoints T scale Y (LinearMap.toMatrix' A.toLinearMap) l := by + ext v + change (v ∈ derivativeLattice T hT scale hscale Y A l hl) ↔ _ + rw [derivativeLattice_mem_iff] + have hlr : (l : ℝ) ≠ 0 := by exact_mod_cast hl.ne' + constructor + · rintro ⟨h, z, rfl⟩ + refine ⟨h, (fun j => (z j : ℝ) / l), ⟨z, ?_⟩, ?_⟩ + · funext j + change (z j : ℝ) = (l : ℝ) * ((z j : ℝ) / l) + field_simp + · simp only [derivativeLatticeEquiv_apply, derivativeGridPoint, LinearMap.toMatrix'_mulVec, + LinearEquiv.coe_coe] + · rintro ⟨h, r, ⟨z, hz⟩, hv⟩ + have hdiv : (fun j => (z j : ℝ) / l) = r := by + funext j + have hj : (z j : ℝ) = (l : ℝ) * r j := congrFun hz j + rw [hj] + field_simp + refine ⟨h, z, hv.trans ?_⟩ + simp only [derivativeLatticeEquiv_apply, derivativeGridPoint, LinearMap.toMatrix'_mulVec, hdiv, + LinearEquiv.coe_coe] + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {σ κ : Type*} [Fintype σ] [Fintype κ] [DecidableEq σ] [DecidableEq κ] + +omit [DecidableEq σ] [DecidableEq κ] in +theorem derivativeGridPoint_shift_bound + (T : σ → ℝ) (hT : ∀ i, 0 < T i) (scale : κ → ℝ) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (M : Matrix κ κ ℝ) + (h : σ → ℤ) (r : κ → ℝ) (R : ℝ) + (hR : ‖derivativeGridPoint T scale Y M h r‖ ≤ R) : + ∀ i, |(h i : ℝ)| ≤ R * T i := by + intro i + have hi := (norm_le_pi_norm (derivativeGridPoint T scale Y M h r).1 i).trans + ((norm_fst_le _).trans hR) + change ‖(h i : ℝ) / T i‖ ≤ R at hi + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hT i)] at hi + exact (div_le_iff₀ (hT i)).mp hi + +theorem derivativeLattice_shortSpan_projection + (T : σ → ℝ) (hT : ∀ i, 1 ≤ T i) + (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) + (l : ℕ) (hl : 0 < l) (R δ : ℝ) (hR : 1 ≤ R) + (H : Finset (σ → ℤ)) (r : (σ → ℤ) → κ → ℝ) + (hr : ∀ h ∈ H, r h ∈ realDenominatorGrid l) + (hnorm : ∀ h ∈ H, + ‖derivativeGridPoint T scale Y (LinearMap.toMatrix' A.toLinearMap) h (r h)‖ ≤ R) + (hdense : δ * ∏ i, T i ≤ (H.card : ℝ)) + (hlarge : ∀ i, (3 * R) ^ (Fintype.card σ - 1) < δ * T i) : + (shortVectorSpan (derivativeLattice T (fun i => (lt_of_lt_of_le zero_lt_one (hT i)).ne') + scale hscale Y A l hl) R).map (LinearMap.fst ℝ (σ → ℝ) (κ → ℝ)) = ⊤ := by + let hT0 : ∀ i, 0 < T i := fun i => lt_of_lt_of_le zero_lt_one (hT i) + let e := coordinateScaleEquiv T (fun i => (hT0 i).ne') + let π := e.toLinearMap.comp (LinearMap.fst ℝ (σ → ℝ) (κ → ℝ)) + let Λ := derivativeLattice T (fun i => (hT0 i).ne') scale hscale Y A l hl + have hmap : (shortVectorSpan Λ R).map π = ⊤ := by + apply shortVectorSpan_map_eq_top_of_dense_integer_images Λ π H T R δ hT hR + (fun h hh => derivativeGridPoint_shift_bound T hT0 scale Y _ h (r h) R (hnorm h hh)) + hdense hlarge + intro h hh + refine ⟨derivativeGridPoint T scale Y (LinearMap.toMatrix' A.toLinearMap) h (r h), + ?_, hnorm h hh, ?_⟩ + · change _ ∈ Λ + rw [← SetLike.mem_coe, derivativeLattice_carrier] + exact derivativeGridPoint_mem T scale Y _ l h (r h) (hr h hh) + · funext i + change T i * ((h i : ℝ) / T i) = (h i : ℝ) + exact mul_div_cancel₀ (h i : ℝ) (hT0 i).ne' + have hmap' : ((shortVectorSpan Λ R).map (LinearMap.fst ℝ (σ → ℝ) (κ → ℝ))).map + e.toLinearMap = ⊤ := by + simpa only [← Submodule.map_comp] using hmap + exact (Submodule.map_eq_top_iff (e := e)).mp hmap' + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {σ κ : Type*} [Fintype σ] [Fintype κ] + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) (l : ℕ) (hl : 0 < l) + +noncomputable def euclideanDerivativeLatticeBasis : + Basis (σ ⊕ κ) ℝ (EuclideanSpace ℝ (σ ⊕ κ)) := + (derivativeLatticeBasis T hT scale hscale Y A l hl).map productEuclideanEquiv + +noncomputable def euclideanDerivativeLattice : Submodule ℤ (EuclideanSpace ℝ (σ ⊕ κ)) := + Submodule.span ℤ (Set.range (euclideanDerivativeLatticeBasis T hT scale hscale Y A l hl)) + +instance euclideanDerivativeLattice_discrete : + DiscreteTopology (euclideanDerivativeLattice T hT scale hscale Y A l hl) := + inferInstanceAs (DiscreteTopology (Submodule.span ℤ + (Set.range (euclideanDerivativeLatticeBasis T hT scale hscale Y A l hl)))) + +instance euclideanDerivativeLattice_full : + IsZLattice ℝ (euclideanDerivativeLattice T hT scale hscale Y A l hl) := + inferInstanceAs (IsZLattice ℝ (Submodule.span ℤ + (Set.range (euclideanDerivativeLatticeBasis T hT scale hscale Y A l hl)))) + +theorem euclideanDerivativeLattice_mem_iff (v : EuclideanSpace ℝ (σ ⊕ κ)) : + v ∈ euclideanDerivativeLattice T hT scale hscale Y A l hl ↔ + productEuclideanEquiv.symm v ∈ derivativeLattice T hT scale hscale Y A l hl := by + change v ∈ Submodule.span ℤ (Set.range + ((derivativeLatticeBasis T hT scale hscale Y A l hl).map productEuclideanEquiv)) ↔ _ + rw [← ZSpan.map] + constructor + · rintro ⟨x, hx, hxv⟩ + change productEuclideanEquiv x = v at hxv + rw [← hxv, LinearEquiv.symm_apply_apply] + exact hx + · intro hv + exact ⟨productEuclideanEquiv.symm v, hv, productEuclideanEquiv.apply_symm_apply v⟩ + +theorem productEuclideanEquiv_mem_derivativeLattice (v : (σ → ℝ) × (κ → ℝ)) : + productEuclideanEquiv v ∈ euclideanDerivativeLattice T hT scale hscale Y A l hl ↔ + v ∈ derivativeLattice T hT scale hscale Y A l hl := by + rw [euclideanDerivativeLattice_mem_iff, LinearEquiv.symm_apply_apply] + +theorem exists_bounded_euclideanDerivativeLattice_family [DecidableEq κ] + (R : ℝ) (P : Finset ((σ → ℝ) × (κ → ℝ))) + (hP : ∀ v ∈ P, + v ∈ derivativeGridPoints T scale Y (LinearMap.toMatrix' A.toLinearMap) l ∧ ‖v‖ ≤ R) : + ∃ Q : Finset (EuclideanSpace ℝ (σ ⊕ κ)), Q.card = P.card ∧ + ∀ v ∈ Q, v ∈ euclideanDerivativeLattice T hT scale hscale Y A l hl ∧ + ‖v‖ ≤ ((Fintype.card σ + Fintype.card κ : ℕ) : ℝ) * R := by + classical + refine ⟨P.image productEuclideanEquiv, Finset.card_image_of_injective _ + productEuclideanEquiv.injective, ?_⟩ + intro v hv + obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hv + constructor + · apply (productEuclideanEquiv_mem_derivativeLattice T hT scale hscale Y A l hl w).mpr + rw [← SetLike.mem_coe, derivativeLattice_carrier] + exact (hP w hw).1 + · exact (productEuclideanEquiv_norm_le w).trans + (mul_le_mul_of_nonneg_left (hP w hw).2 (Nat.cast_nonneg _)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanLatticeGraph.lean b/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanLatticeGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a8c1416d0f415199f023326cd76d4f88aa5d20e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanLatticeGraph.lean @@ -0,0 +1,64 @@ +import OAI.Combinatorics.Progressions.Estimates.EuclideanGraphNorm +import OAI.Combinatorics.Progressions.Estimates.EuclideanGraphResidual + +namespace OAI + +section + +namespace Erdos3 + +theorem euclidean_shift_subspace_surjective + {σ κ : Type*} [Fintype σ] [Fintype κ] + (Z : Submodule ℝ (EuclideanSpace ℝ (σ ⊕ κ))) + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) + (hproj : Z.map ((LinearMap.fst ℝ (σ → ℝ) (κ → ℝ)).comp + productEuclideanEquiv.symm.toLinearMap) = ⊤) : + Function.Surjective ((euclideanDerivativeShiftMap T hT).comp Z.subtype) := by + have hmap : Z.map (euclideanDerivativeShiftMap T hT) = ⊤ := by + change Z.map ((coordinateScaleEquiv T hT).toLinearMap.comp + ((LinearMap.fst ℝ (σ → ℝ) (κ → ℝ)).comp productEuclideanEquiv.symm.toLinearMap)) = ⊤ + rw [Submodule.map_comp, hproj, Submodule.map_top] + exact (coordinateScaleEquiv T hT).range + intro x + have hx : x ∈ Z.map (euclideanDerivativeShiftMap T hT) := by rw [hmap]; trivial + obtain ⟨v, hv, he⟩ := hx + exact ⟨⟨v, hv⟩, he⟩ + +theorem exists_euclidean_lattice_graph_identity + {σ κ : Type*} [Fintype σ] [Fintype κ] [DecidableEq σ] + (Z : Submodule ℝ (EuclideanSpace ℝ (σ ⊕ κ))) + (Λ : Submodule ℤ Z) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (T : σ → ℝ) (hT : ∀ i, 0 < T i) + (hinteger : ∀ x ∈ Λ, + euclideanDerivativeShiftMap T (fun i => (hT i).ne') x.val ∈ realIntegerGrid) + (hsurj : Function.Surjective + ((euclideanDerivativeShiftMap T (fun i => (hT i).ne')).comp Z.subtype)) : + let π : Z →ₗ[ℝ] (σ → ℝ) := + (euclideanDerivativeShiftMap T (fun i => (hT i).ne')).comp Z.subtype + ∃ G : (σ → ℝ) →ₗ[ℝ] Z, + (∀ y i, (G y).val (Sum.inl i) = y i) ∧ + (∀ x : Z, G (fun i => x.val (Sum.inl i)) = x - (LinearMap.ker π).starProjection x) ∧ + ZLattice.covolume Λ = ZLattice.covolume (latticeKernel Λ π) + (MeasureTheory.volume (α := LinearMap.ker π)) * + (((latticeImage Λ π).toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup : ℝ) / + ∏ i, T i) * + Real.sqrt (Matrix.gram ℝ (fun i => G (Pi.basisFun ℝ σ i))).det := by + let π := (euclideanDerivativeShiftMap T (fun i => (hT i).ne')).comp Z.subtype + obtain ⟨G, hright, hsection, hcov⟩ := + exists_scaled_lattice_covolume_identity Λ π hinteger hsurj T hT + refine ⟨G, ?_, ?_, hcov⟩ + · intro y i + have he := congrFun (hright y) i + change T i * (G y).val (Sum.inl i) = T i * y i at he + exact mul_left_cancel₀ (hT i).ne' he + · intro x + have he : (fun i => π x i / T i) = fun i => x.val (Sum.inl i) := by + funext i + exact mul_div_cancel_left₀ _ (hT i).ne' + simpa only [he] using hsection x + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanShortLatticeBasis.lean b/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanShortLatticeBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..a02c9de7f17c38d873284f95f049a9a7393fd2eb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/EuclideanShortLatticeBasis.lean @@ -0,0 +1,157 @@ +import Mathlib.Algebra.Module.ZLattice.Covolume +import OAI.Combinatorics.Progressions.Geometry.ProductEuclideanCoordinates +import OAI.Combinatorics.Progressions.Linear.ShortGeneratingBasisBound + +namespace OAI + +section + +namespace Erdos3 + +open Module MeasureTheory +open scoped BigOperators + +variable {I E : Type*} [Fintype I] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +noncomputable def orthonormalChart (b : OrthonormalBasis I ℝ E) : (I → ℝ) ≃L[ℝ] E := + (EuclideanSpace.equiv I ℝ).symm.trans b.repr.toContinuousLinearEquiv.symm + +omit [FiniteDimensional ℝ E] in +theorem orthonormalChart_norm_le (b : OrthonormalBasis I ℝ E) (x : I → ℝ) : + ‖orthonormalChart b x‖ ≤ (Fintype.card I : ℝ) * ‖x‖ := by + change ‖b.repr.symm ((EuclideanSpace.equiv I ℝ).symm x)‖ ≤ _ + rw [LinearIsometryEquiv.norm_map] + calc + _ ≤ ∑ i, |x i| := euclidean_norm_le_sum_abs _ + _ ≤ ∑ _i : I, ‖x‖ := by + apply Finset.sum_le_sum + intro i _ + simpa only [Real.norm_eq_abs] using norm_le_pi_norm x i + _ = _ := by simp + +omit [FiniteDimensional ℝ E] in +theorem orthonormalChart_symm_norm_le (b : OrthonormalBasis I ℝ E) (x : E) : + ‖(orthonormalChart b).symm x‖ ≤ ‖x‖ := by + apply (pi_norm_le_iff_of_nonneg (norm_nonneg x)).mpr + intro i + have h := PiLp.norm_apply_le (b.repr x) i + simpa [orthonormalChart] using h + +noncomputable def orthonormalCoordinateLattice (Λ : Submodule ℤ E) + (b : OrthonormalBasis I ℝ E) : Submodule ℤ (I → ℝ) := + ZLattice.comap ℝ Λ (orthonormalChart b).toLinearMap + +instance orthonormalCoordinateLattice_discrete (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (b : OrthonormalBasis I ℝ E) : DiscreteTopology (orthonormalCoordinateLattice Λ b) := + inferInstanceAs (DiscreteTopology (ZLattice.comap ℝ Λ (orthonormalChart b).toLinearMap)) + +instance orthonormalCoordinateLattice_full (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : OrthonormalBasis I ℝ E) : + IsZLattice ℝ (orthonormalCoordinateLattice Λ b) := + inferInstanceAs (IsZLattice ℝ (ZLattice.comap ℝ Λ (orthonormalChart b).toLinearMap)) + +variable [MeasurableSpace E] [BorelSpace E] + +theorem orthonormalChart_measurePreserving (b : OrthonormalBasis I ℝ E) : + MeasurePreserving (orthonormalChart b) := + b.measurePreserving_repr_symm.comp (PiLp.volume_preserving_toLp I) + +theorem orthonormalCoordinateLattice_covolume (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : OrthonormalBasis I ℝ E) : + ZLattice.covolume (orthonormalCoordinateLattice Λ b) = ZLattice.covolume Λ := + ZLattice.covolume_comap Λ volume volume (orthonormalChart_measurePreserving b) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule MeasureTheory BohrLattice.MinkowskiSecondBox +open scoped BigOperators + +theorem exists_short_euclidean_lattice_basis {E A : Type*} {n : ℕ} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (o : OrthonormalBasis (Fin n) ℝ E) (v : A → E) {R : ℝ} + (hspan : span ℝ (Set.range v) = ⊤) (hmem : ∀ a, v a ∈ Λ) + (hnorm : ∀ a, ‖v a‖ ≤ R) : + ∃ b : Basis (Fin n) ℝ E, + span ℤ (Set.range b) = Λ ∧ + (∏ i, ‖b i‖) ≤ (n : ℝ) ^ n * minkowskiSecondConstant n * ZLattice.covolume Λ ∧ + ∀ i, ‖b i‖ ≤ (n : ℝ) * n.factorial * minkowskiSecondConstant n * R := by + classical + let e := orthonormalChart o + let L := orthonormalCoordinateLattice Λ o + let B := IsZLattice.basis L + let b₀ := B.ofZLatticeBasis ℝ L + let u := fun a => e.symm (v a) + have huSpan : span ℝ (Set.range u) = ⊤ := by + change span ℝ (Set.range (e.symm.toLinearMap ∘ v)) = ⊤ + rw [Set.range_comp, ← Submodule.map_span, hspan, Submodule.map_top] + exact e.symm.toLinearEquiv.range + have huMem : ∀ a, u a ∈ span ℤ (Set.range b₀) := by + intro a + rw [show span ℤ (Set.range b₀) = L from B.ofZLatticeBasis_span ℝ L] + change e (e.symm (v a)) ∈ Λ + simpa only [ContinuousLinearEquiv.apply_symm_apply] using hmem a + have huNorm : ∀ a, ‖u a‖ ≤ R := fun a => + (orthonormalChart_symm_norm_le o (v a)).trans (hnorm a) + obtain ⟨c, hcSpan, hcProd, hcNorm⟩ := exists_short_same_lattice_basis b₀ u huSpan huMem huNorm + let b := c.map e.toLinearEquiv + have hb (i) : b i = e (c i) := by simp [b] + have hmap : L.map (e.toLinearMap.restrictScalars ℤ) = Λ := by + ext y + constructor + · rintro ⟨x, hx, rfl⟩ + exact hx + · intro hy + refine ⟨e.symm y, ?_, e.apply_symm_apply y⟩ + change e (e.symm y) ∈ Λ + simpa only [ContinuousLinearEquiv.apply_symm_apply] using hy + have hbSpan : span ℤ (Set.range b) = Λ := by + calc + _ = (span ℤ (Set.range c)).map (e.toLinearMap.restrictScalars ℤ) := by + rw [Submodule.map_span, ← Set.range_comp] + congr 2 + _ = L.map (e.toLinearMap.restrictScalars ℤ) := by + rw [hcSpan, show span ℤ (Set.range b₀) = L from B.ofZLatticeBasis_span ℝ L] + _ = Λ := hmap + have hdet : |(Matrix.of c).det| = ZLattice.covolume Λ := by + calc + _ = |(Matrix.of b₀).det| := abs_det_eq_of_same_integer_span c b₀ hcSpan + _ = ZLattice.covolume L := by + have hb₀ : (b₀ : Fin n → Fin n → ℝ) = fun i => (B i : Fin n → ℝ) := + funext (fun i => Basis.ofZLatticeBasis_apply ℝ L B i) + rw [hb₀] + exact (ZLattice.covolume_eq_det L B).symm + _ = ZLattice.covolume Λ := orthonormalCoordinateLattice_covolume Λ o + rfl + have hbNorm (i) : ‖b i‖ ≤ (n : ℝ) * ‖c i‖ := by + rw [hb] + simpa only [Fintype.card_fin] using orthonormalChart_norm_le o (c i) + refine ⟨b, hbSpan, ?_, ?_⟩ + · calc + _ ≤ ∏ i, (n : ℝ) * ‖c i‖ := + Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun i _ => hbNorm i) + _ = (n : ℝ) ^ n * ∏ i, ‖c i‖ := by simp [Finset.prod_mul_distrib] + _ ≤ (n : ℝ) ^ n * (minkowskiSecondConstant n * ZLattice.covolume Λ) := by + apply mul_le_mul_of_nonneg_left _ (pow_nonneg (Nat.cast_nonneg _) _) + simpa only [hdet] using hcProd + _ = _ := by ring + · intro i + calc + _ ≤ (n : ℝ) * ‖c i‖ := hbNorm i + _ ≤ (n : ℝ) * ((n.factorial : ℝ) * minkowskiSecondConstant n * R) := + mul_le_mul_of_nonneg_left (hcNorm i) (Nat.cast_nonneg _) + _ = _ := by ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FactorialIntegerScalars.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FactorialIntegerScalars.lean new file mode 100644 index 0000000000000000000000000000000000000000..649b6f144f55fdea3e03c58c4fe2108cb2898bec --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FactorialIntegerScalars.lean @@ -0,0 +1,42 @@ +import Mathlib.Data.Nat.Factorial.Basic +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +theorem rat_nat_div_integer_of_dvd {m n : ℕ} (h : n ∣ m) : + ∃ z : ℤ, (m : ℚ) / n = (z : ℚ) := by + obtain ⟨d, rfl⟩ := h + by_cases hn : n = 0 + · exact ⟨0, by simp [hn]⟩ + · exact ⟨d, by push_cast; field_simp⟩ + +theorem factorial_log_scalar_integer (s k : ℕ) (hk : k ≤ s) : + ∃ z : ℤ, (s.factorial : ℚ) * ((-1 : ℚ) ^ (k + 1) / k) = (z : ℚ) := by + by_cases hzero : k = 0 + · exact ⟨0, by simp [hzero]⟩ + obtain ⟨z, hz⟩ := rat_nat_div_integer_of_dvd (Nat.dvd_factorial (Nat.pos_of_ne_zero hzero) hk) + refine ⟨(-1 : ℤ) ^ (k + 1) * z, ?_⟩ + push_cast + rw [show (s.factorial : ℚ) * ((-1 : ℚ) ^ (k + 1) / k) = + (-1 : ℚ) ^ (k + 1) * ((s.factorial : ℚ) / k) by ring, hz] + +theorem factorial_exp_scalar_integer (s k : ℕ) (hk : k ≤ s) : + ∃ z : ℤ, (k.factorial : ℚ)⁻¹ * (s.factorial : ℚ) ^ k = (z : ℚ) := by + cases k with + | zero => exact ⟨1, by simp⟩ + | succ k => + have hd : (k + 1).factorial ∣ s.factorial ^ (k + 1) := by + rw [pow_succ'] + exact (Nat.factorial_dvd_factorial hk).trans (Nat.dvd_mul_right _ _) + obtain ⟨z, hz⟩ := rat_nat_div_integer_of_dvd hd + exact ⟨z, by simpa only [Nat.cast_pow, div_eq_mul_inv, mul_comm] using hz⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FilteredLatticePowerIndex.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FilteredLatticePowerIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..e74f47958dd4fd64fcf247e2b04511d2d206874d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FilteredLatticePowerIndex.lean @@ -0,0 +1,38 @@ +import OAI.Combinatorics.Progressions.Linear.CentralBasisPowerCover + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} (F : NilpotentLieFiltration L s) + +theorem subgroupPowerCover_index_le (e : Basis ι ℚ L) (Γ : Subgroup F.Group) + (l : ℕ) (hl : 0 < l) (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (m : ℕ) (hm : 0 < m) : + ((subgroupPowerCover Γ m).subgroupOf Γ).FiniteIndex ∧ + (subgroupPowerCover Γ m).relIndex Γ ≤ m ^ Fintype.card ι := by + let : FiniteDimensional ℚ L := Module.Finite.of_basis e + obtain ⟨b, hb⟩ := F.exists_central_basis + obtain ⟨N, hN, hgrid⟩ := exists_bchSubgroup_outer_grid_change_basis e b Γ l hl houter + simpa only [finrank_eq_card_basis e] using + hb.subgroupPowerCover_index_le F.lowerCentralSeries_eq_bot Γ N hN hgrid m hm + +theorem exists_ordered_integral_generators (e : Basis ι ℚ L) (Γ : Subgroup F.Group) + (l : ℕ) (hl : 0 < l) (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ a : Fin (Fintype.card ι) → Γ, Function.Surjective (orderedZpowProduct a) := by + let : FiniteDimensional ℚ L := Module.Finite.of_basis e + obtain ⟨b, hb⟩ := F.exists_central_basis + obtain ⟨N, hN, hgrid⟩ := exists_bchSubgroup_outer_grid_change_basis e b Γ l hl houter + rw [← finrank_eq_card_basis e] + exact hb.exists_surjective_orderedZpowProduct F.lowerCentralSeries_eq_bot Γ N hN hgrid + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FiniteAffineClassAverage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FiniteAffineClassAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0e912f33d2512d1abbbf81920b49d2c83a2c18a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FiniteAffineClassAverage.lean @@ -0,0 +1,58 @@ +import OAI.Combinatorics.Progressions.Estimates.CorrelationDerivative + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {G H K : Type*} [AddCommGroup G] [AddCommGroup H] [AddCommGroup K] + [Fintype H] [Fintype K] + +theorem expect_affine_class_refinement (e : H →+ G) (d : K →+ H) + (r : G) (f : G → ℂ) : + (𝔼 y : H, 𝔼 x : K, f ((r + e y) + e (d x))) = + 𝔼 y : H, f (r + e y) := by + rw [Finset.expect_comm] + have hpoint (x : K) : (𝔼 y : H, f ((r + e y) + e (d x))) = + 𝔼 y : H, f (r + e y) := by + calc + _ = 𝔼 y : H, f (r + e (d x + y)) := by + apply Finset.expect_congr rfl + intro y _ + rw [map_add] + congr 1 + abel + _ = _ := expect_translate (fun y => f (r + e y)) (d x) + simp only [hpoint, Fintype.expect_const] + +theorem norm_affine_class_mean_le_of_refinement (e : H →+ G) (d : K →+ H) + (r : G) (f : G → ℂ) (β : ℝ) + (hbound : ∀ y : H, ‖𝔼 x : K, f ((r + e y) + e (d x))‖ ≤ β) : + ‖𝔼 y : H, f (r + e y)‖ ≤ β := by + rw [← expect_affine_class_refinement e d r f] + exact (RCLike.norm_expect_le (K := ℂ)).trans + ((Finset.expect_le_expect (fun y _ => hbound y)).trans_eq (Fintype.expect_const β)) + +def scalarTupleHom {I R : Type*} [CommRing R] (c : R) : (I → R) →+ (I → R) where + toFun x i := c * x i + map_zero' := by ext i; simp + map_add' := by intro x y; ext i; simp [mul_add] + +theorem norm_scalar_affine_class_mean_le {I R : Type*} [Fintype I] + [CommRing R] [Fintype R] (e d : R) (r : I → R) (f : (I → R) → ℂ) (β : ℝ) + (hbound : ∀ t : I → R, + ‖𝔼 x : I → R, f (fun i => t i + (e * d) * x i)‖ ≤ β) : + ‖𝔼 y : I → R, f (fun i => r i + e * y i)‖ ≤ β := by + apply norm_affine_class_mean_le_of_refinement (scalarTupleHom e) (scalarTupleHom d) r f β + intro y + change ‖𝔼 x : I → R, f (fun i => (r i + e * y i) + e * (d * x i))‖ ≤ β + simpa only [mul_assoc] using hbound (fun i => r i + e * y i) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FiniteLatticeBasis.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FiniteLatticeBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..f45116c94dff9cb977c8c9b97337b4d6f64e8fa8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FiniteLatticeBasis.lean @@ -0,0 +1,20 @@ +import Mathlib.Algebra.Module.ZLattice.Basic + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def finiteLatticeBasis {E : Type*} + [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] : + Module.Basis (Fin (Module.finrank ℝ E)) ℤ Λ := + (Module.Free.chooseBasis ℤ Λ).reindex (Fintype.equivOfCardEq + (by rw [← Module.finrank_eq_card_chooseBasisIndex, ZLattice.rank ℝ, Fintype.card_fin])) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FiniteUnchargedPrimeDensity.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FiniteUnchargedPrimeDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..255e90d21bc27eb8ad7b71f85ed5dc34ec25e615 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FiniteUnchargedPrimeDensity.lean @@ -0,0 +1,173 @@ +import OAI.Combinatorics.Progressions.Fourier.FiniteCharacterOrderTail + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +private theorem finite_prime_depth_mass {p : ℕ} (hp : 2 ≤ p) (A : ℕ) : + (∑ a ∈ Finset.range A, 1 / ((p : ℝ) ^ (a + 1)) ^ 2) ≤ 2 / (p : ℝ) ^ 2 := by + let r : ℝ := 1 / (p : ℝ) ^ 2 + have hpR : (2 : ℝ) ≤ p := by exact_mod_cast hp + have hp0 : (0 : ℝ) < p := by linarith + have hr0 : 0 ≤ r := by dsimp only [r]; positivity + have hr : r ≤ 1 / 2 := by + dsimp only [r] + apply (div_le_div_iff₀ (pow_pos hp0 2) (by norm_num)).mpr + nlinarith + calc + _ = r * ∑ a ∈ Finset.range A, r ^ a := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + dsimp only [r] + simp only [one_div, inv_pow] + rw [pow_right_comm, pow_succ' _ a, mul_inv] + _ ≤ r * ∑ a ∈ Finset.range A, (1 / (2 : ℝ)) ^ a := by + apply mul_le_mul_of_nonneg_left _ hr0 + exact Finset.sum_le_sum (fun a _ => pow_le_pow_left₀ hr0 hr a) + _ ≤ r * 2 := mul_le_mul_of_nonneg_left (sum_geometric_two_le A) hr0 + _ = _ := by dsimp only [r]; ring + +theorem finiteCharacter_order_dvd_of_annihilation {H : Type*} [AddCommGroup H] + (N : ℕ) (hN : ∀ x : H, N • x = 0) (χ : AddChar H ℂ) : orderOf χ ∣ N := by + apply orderOf_dvd_of_pow_eq_one + ext x + rw [AddChar.pow_apply, ← AddChar.map_nsmul_eq_pow, hN x] + exact χ.map_zero_eq_one + +theorem finiteCharacter_uncharged_prime_mass {I H : Type*} [Fintype I] + [AddCommGroup H] [Fintype H] (π : (I → ℤ) →+ H) (hπ : Function.Surjective π) + {p A : ℕ} (hp : p.Prime) (hann : ∀ x : H, (p ^ A) • x = 0) + (f : AddChar H ℂ → ℝ) + (hdecay : ∀ χ, χ ≠ 1 → f χ ≤ 1 / (orderOf χ : ℝ) ^ (Fintype.card I + 2)) : + (∑ χ : AddChar H ℂ with χ ≠ 1, f χ) ≤ 2 / (p : ℝ) ^ 2 := by + let S := Finset.univ.filter (fun χ : AddChar H ℂ => χ ≠ 1) + let orders := (Finset.range A).image (fun a => p ^ (a + 1)) + have hmap : (S : Set (AddChar H ℂ)).MapsTo orderOf orders := by + intro χ hχ + obtain ⟨a, ha, heq⟩ := (Nat.dvd_prime_pow hp).mp + (finiteCharacter_order_dvd_of_annihilation (p ^ A) hann χ) + have ha0 : 0 < a := by + by_contra hz + have haZ : a = 0 := by omega + have ho : orderOf χ = 1 := by simpa only [haZ, pow_zero] using heq + exact (Finset.mem_filter.mp hχ).2 (orderOf_eq_one_iff.mp ho) + exact Finset.mem_image.mpr ⟨a - 1, Finset.mem_range.mpr (by omega), + by rw [Nat.sub_add_cancel ha0]; exact heq.symm⟩ + change (∑ χ ∈ S, f χ) ≤ _ + rw [← Finset.sum_fiberwise_of_maps_to hmap f] + have hinner (q : ℕ) (hq : q ∈ orders) : + (∑ χ ∈ S with orderOf χ = q, f χ) ≤ 1 / (q : ℝ) ^ 2 := by + obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hq + have hq0 : 0 < p ^ (a + 1) := pow_pos hp.pos _ + have hqR : (0 : ℝ) < ((p ^ (a + 1) : ℕ) : ℝ) := Nat.cast_pos.mpr hq0 + have hc : (S.filter (fun χ => orderOf χ = p ^ (a + 1))).card ≤ + (p ^ (a + 1)) ^ Fintype.card I := + (Finset.card_le_card (by + intro χ hχ + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hχ).2⟩)).trans + (finiteCharacter_exactOrder_card_le π hπ _ hq0) + calc + _ ≤ ∑ _χ ∈ S with orderOf _χ = p ^ (a + 1), + 1 / ((p ^ (a + 1) : ℕ) : ℝ) ^ (Fintype.card I + 2) := by + apply Finset.sum_le_sum + intro χ hχ + simpa only [(Finset.mem_filter.mp hχ).2] using + hdecay χ (Finset.mem_filter.mp (Finset.mem_filter.mp hχ).1).2 + _ = (S.filter (fun χ => orderOf χ = p ^ (a + 1))).card * + (1 / ((p ^ (a + 1) : ℕ) : ℝ) ^ (Fintype.card I + 2)) := by + rw [Finset.sum_const, nsmul_eq_mul] + _ ≤ ((p ^ (a + 1) : ℕ) : ℝ) ^ Fintype.card I * + (1 / ((p ^ (a + 1) : ℕ) : ℝ) ^ (Fintype.card I + 2)) := + mul_le_mul_of_nonneg_right (by exact_mod_cast hc) (by positivity) + _ = _ := by + rw [pow_add (((p ^ (a + 1) : ℕ) : ℝ)) (Fintype.card I) 2] + field_simp + calc + _ ≤ ∑ q ∈ orders, 1 / (q : ℝ) ^ 2 := Finset.sum_le_sum hinner + _ = ∑ a ∈ Finset.range A, 1 / ((p : ℝ) ^ (a + 1)) ^ 2 := by + rw [Finset.sum_image] + · simp only [Nat.cast_pow] + · intro a _ b _ hab + exact Nat.add_right_cancel (Nat.pow_right_injective hp.two_le hab) + _ ≤ _ := finite_prime_depth_mass hp.two_le A + +theorem finiteImage_uncharged_prime_density {I H X : Type*} [Fintype I] + [AddCommGroup H] [Fintype H] [DecidableEq H] [Fintype X] + (π : (I → ℤ) →+ H) (hπ : Function.Surjective π) + {p A : ℕ} (hp : p.Prime) (hann : ∀ x : H, (p ^ A) • x = 0) + (w : FiniteProbabilityWeights X) (Y : X → H) + (hdecay : ∀ χ : AddChar H ℂ, χ ≠ 1 → ‖finiteImageCharacteristic w Y χ‖ ≤ + 1 / (orderOf χ : ℝ) ^ (Fintype.card I + 2)) (z : H) : + |(Fintype.card H : ℝ) * finiteImageMass w Y z - 1| ≤ 2 / (p : ℝ) ^ 2 := by + have he := finiteImageFourier_truncation w Y {1} z (Nat.cast_nonneg (Fintype.card H)) + have hcard : (Fintype.card H : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + have hcardC : (Fintype.card H : ℂ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + simp only [Complex.ofReal_natCast, div_self hcard, div_self hcardC, one_mul, + Finset.sum_singleton, finiteImageCharacteristic, AddChar.one_apply, + FiniteProbabilityWeights.complexMean_const, star_one, mul_one] at he + have htail := finiteCharacter_uncharged_prime_mass π hπ hp hann _ hdecay + have htail' : spectrumTail {1} (fun χ => ‖finiteImageCharacteristic w Y χ‖) ≤ 2 / (p : ℝ) ^ 2 := by + simpa only [spectrumTail, Finset.mem_singleton, Finset.sum_filter, ite_not] using htail + have hbound := he.trans htail' + simpa only [← Complex.ofReal_natCast, ← Complex.ofReal_mul, ← Complex.ofReal_one, + ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] using hbound + +theorem finiteImage_uncharged_prime_density_rpow {I H X : Type*} [Fintype I] + [AddCommGroup H] [Fintype H] [DecidableEq H] [Fintype X] + (π : (I → ℤ) →+ H) (hπ : Function.Surjective π) + {p A : ℕ} (hp : p.Prime) (hann : ∀ x : H, (p ^ A) • x = 0) + (w : FiniteProbabilityWeights X) (Y : X → H) {P : ℝ} + (hP : ((Fintype.card I + 2 : ℕ) : ℝ) ≤ P) + (hdecay : ∀ χ : AddChar H ℂ, χ ≠ 1 → ‖finiteImageCharacteristic w Y χ‖ ≤ + (orderOf χ : ℝ) ^ (-P)) (z : H) : + |(Fintype.card H : ℝ) * finiteImageMass w Y z - 1| ≤ 2 / (p : ℝ) ^ 2 := by + have hfull (χ : AddChar H ℂ) : ‖finiteImageCharacteristic w Y χ‖ ≤ + 1 * (orderOf χ : ℝ) ^ (-P) := by + by_cases hχ : χ = 1 + · subst χ + simp only [finiteImageCharacteristic, AddChar.one_apply, + FiniteProbabilityWeights.complexMean_const, norm_one, orderOf_one, + Nat.cast_one, Real.one_rpow, mul_one, le_refl] + · simpa only [one_mul] using hdecay χ hχ + have hinteger := finiteCharacter_integer_decay_of_rpow (I := I) + (show (0 : ℝ) ≤ 1 by norm_num) hP _ hfull + exact finiteImage_uncharged_prime_density π hπ hp hann w Y (fun χ _ => hinteger χ) z + +theorem finiteImage_uncharged_prime_quotient_density {I H X : Type*} [Fintype I] + [AddCommGroup H] [Fintype H] [DecidableEq H] [Fintype X] + {p A : ℕ} (hp : p.Prime) + (q : (I → ZMod (p ^ A)) →+ H) (hq : Function.Surjective q) + (w : FiniteProbabilityWeights X) (Y : X → H) {P : ℝ} + (hP : ((Fintype.card I + 2 : ℕ) : ℝ) ≤ P) + (hdecay : ∀ χ : AddChar H ℂ, χ ≠ 1 → ‖finiteImageCharacteristic w Y χ‖ ≤ + (orderOf χ : ℝ) ^ (-P)) (z : H) : + |(Fintype.card H : ℝ) * finiteImageMass w Y z - 1| ≤ 2 / (p : ℝ) ^ 2 ∧ + (Fintype.card H : ℝ) * finiteImageMass w Y z ≤ 1 + 2 / (p : ℝ) ^ 2 := by + let reduction : (I → ℤ) →+ (I → ZMod (p ^ A)) := + { toFun := fun v i => (v i : ZMod (p ^ A)) + map_zero' := by ext i; simp + map_add' := by intro v w; ext i; simp } + have hred : Function.Surjective reduction := by + intro v + choose lift hlift using (fun i => ZMod.intCast_surjective (v i)) + exact ⟨lift, funext hlift⟩ + have hann (x : H) : (p ^ A) • x = 0 := by + obtain ⟨v, rfl⟩ := hq x + rw [← map_nsmul] + have hz : (p ^ A) • v = 0 := by + ext i + simp only [Pi.smul_apply, nsmul_eq_mul, ZMod.natCast_self, zero_mul, Pi.zero_apply] + rw [hz, map_zero] + have hdensity := finiteImage_uncharged_prime_density_rpow (q.comp reduction) + (hq.comp hred) hp hann w Y hP hdecay z + exact ⟨hdensity, by linarith [(abs_le.mp hdensity).2]⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FirstCoefficientLatticeCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FirstCoefficientLatticeCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..814989e8deeb4935b984da02966a632bbe9d4b5f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FirstCoefficientLatticeCoordinates.lean @@ -0,0 +1,42 @@ +import OAI.Combinatorics.Progressions.Estimates.FastCoefficientImage +import OAI.Combinatorics.Progressions.Linear.SortedBasisTriangular + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +theorem exists_lattice_ready_firstCoefficient_basis + {σ ι E : Type*} [AddCommGroup E] [Module ℝ E] {d : ℕ} + (ω : ι → ℕ) (rows : Fin d → FirstCoefficientIndex (fun _ : σ => 1) ω) + (b : Basis (Fin d) ℝ E) : + ∃ (e : Equiv.Perm (Fin d)) (a : ℕ), a ≤ d ∧ + (∀ i, i.val < a ↔ (rows (e i)).val.1 = 0) ∧ + ∀ (f : E ≃ₗ[ℝ] E), + (∀ i j, ω (rows i).val.2 ≤ ω (rows j).val.2 → + LinearMap.toMatrix b b f.toLinearMap i j = (1 : Matrix (Fin d) (Fin d) ℝ) i j) → + let b' := b.reindex e.symm + let A := b'.equivFun.symm.trans (f.trans b'.equivFun) + (∀ i j, i < j → (LinearMap.toMatrix' A.toLinearMap) i j = 0) ∧ + (∀ i, (LinearMap.toMatrix' A.toLinearMap) i i = 1) ∧ + (∀ i j, i.val < a → j.val < a → + (LinearMap.toMatrix' A.toLinearMap) i j = (1 : Matrix (Fin d) (Fin d) ℝ) i j) := by + obtain ⟨e, a, ha, hm, hz⟩ := exists_sorted_firstCoefficient_rows ω rows + refine ⟨e, a, ha, hz, ?_⟩ + intro f hf + dsimp only + simp only [basis_coordinate_linearEquiv_matrix] + have hfirst (i) (hi : i.val < a) : ω (rows (e i)).val.2 = 1 := + (firstCoefficientIndex_zero_iff_grade_one ω (rows (e i))).mp ((hz i).mp hi) + exact ⟨sorted_basis_upper_zero b (fun i => ω (rows i).val.2) f.toLinearMap hf e hm, + sorted_basis_diagonal_one b (fun i => ω (rows i).val.2) f.toLinearMap hf e, + sorted_basis_initial_identity b (fun i => ω (rows i).val.2) f.toLinearMap hf e hfirst⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FixedAffineEpochTransition.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FixedAffineEpochTransition.lean new file mode 100644 index 0000000000000000000000000000000000000000..f670633de1fe1d3661741afe087bd767ae37c265 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FixedAffineEpochTransition.lean @@ -0,0 +1,186 @@ +import OAI.Combinatorics.Progressions.Dynamics.RetainedEpochRefinement +import OAI.Combinatorics.Progressions.Estimates.AdaptedAnchoredComparison + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup NilpotentLieFiltration RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +theorem exists_separated_residue_event_or_child (s : ℕ) (hs : 1 ≤ s) : + ∃ B : ℕ, 2 ≤ B ∧ ∀ {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {d t e : ℕ} + (D : RationalFilteredNilmanifold L s d) (V : RationalFilteredNilmanifold K t e) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p work q rho : ℝ), 0 ≤ p → p ≤ work → p ≤ q → (Fintype.card σ : ℝ) ≤ q → + verticalDecompositionBudget p ≤ q → 0 < rho → rho⁻¹ ≤ Real.exp p → + ∀ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (b : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1)) + (q₀ P C a : ℕ) (hP : 0 < P) (cost : ℝ), + FixedResidueDescent D W V (fun _ : σ => 1) b child work q₀ P hP C a cost → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (E R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (κ : D.RealGroup), κ ∈ D.realLattice → + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨T.orbit.log, T.orbit.property⟩⟩ → + D.filtration.PolynomialRationalGrid D.basis (fun _ : σ => 1) q₀ R → + ∀ A : σ → ℝ, (∀ i, 0 < A i) → + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) A (Real.exp ((work + 2) ^ a)) E → + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (_hM : 0 < M) (u v : σ → ℤ) (J : σ → ℕ), + (∀ i, 0 < J i) → ∀ _hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)], + (∀ i, (M * (M * P)).Coprime (J i)) → + (∀ i, ((M * J i : ℕ) : ℝ) * (Real.exp ((q + B) ^ B) + 1) ≤ (N i : ℝ)) → + ∀ Δ ε δ : ℝ, 0 < δ → δ ≤ 1 → ε < 1 / 2 → + 2 * (2 * rho + Real.exp (verticalDecompositionBudget p - q)) ≤ Δ / 2 → + 8 * ε + 2 * (Real.exp ((work + 2) ^ C) * δ) ≤ Δ / 4 → + (∀ i, 8 ≤ δ * (N i : ℝ)) → + (∀ i, (u i : ℝ) - (M : ℝ) * A i ≤ (lo i : ℝ) ∧ + (lo i : ℝ) + (N i : ℝ) ≤ (u i : ℝ) + (M : ℝ) * A i) → + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ δ * ε / 8 → + Δ ≤ ‖residuePairMean T.eval lo N M u v J false - residuePairMean T.eval lo N M u v J true‖ → + ResiduePairDimensionDrop D ω hF T W lo N M u v J ((q + B) ^ B) ∨ + AnchoredChildResidueComparison V child cost (Δ / 4) δ lo N M P u v J := by + obtain ⟨B, hB, hstep⟩ := exists_residue_pair_stability_step s hs + refine ⟨B, hB, ?_⟩ + intro σ L K _ _ _ _ _ _ _ _ _ _ _ _ _ _ d t e D V ω hF p work q rho hp hpwork hpq hσ hfreq hrho hrhop + W b child q₀ P C a hP cost hdesc T hunit hT E R κ hκ hprod hgrid A hA hE + lo N M hM u v J hJ hv hcop hsteplarge Δ ε δ hδ hδone hε hprojection hfreezing + hlarge hphysical hcount hgap + rcases hstep D ω hF p q rho hp hpq hσ hfreq hrho hrhop T hunit hT W lo N M u v J + hM hJ hv hsteplarge with hevent | hprojected + · exact Or.inl hevent + · obtain ⟨S, hunitS, hS, hSo, hinvariant, _, hSgap⟩ := hprojected + have hprodS : E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩ := by + simpa only [hSo] using hprod + have hgapS : Δ / 2 ≤ + ‖residuePairMean S.eval lo N M u v J false - residuePairMean S.eval lo N M u v J true‖ := by + linarith + simp only [residuePairMean_false, residuePairMean_true] at hgapS + have hresult := hdesc.half_discrepancy S (hS.mono hpwork) hunitS hinvariant E R κ hκ hprodS hgrid A hA hE + M hM lo N u v J hJ hv hcop (Δ / 2) ε δ hδ hδone hε + (by nlinarith : 8 * ε + 2 * (Real.exp ((work + 2) ^ C) * δ) ≤ (Δ / 2) / 2) + hlarge hphysical hcount hgapS + obtain ⟨H, hH, hHN, hlower, hupper, k, hk₀, hk₁, U, hU, hunitU, hcostU, hgapU⟩ := hresult + exact Or.inr (anchored_child_comparison_of_piece V child cost (Δ / 4) δ lo N H hH hHN + hlower hupper M P hM hP u v J hv hcop k hk₀ hk₁ U hU hunitU hcostU + (by simpa only [show (Δ / 2) / 2 = Δ / 4 by ring] using hgapU)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +noncomputable def FixedAffineEpochTransition + {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {s d t e : ℕ} + (D : RationalFilteredNilmanifold L s d) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (T : D.Niltest (fun _ : σ => 1)) (A : σ → ℝ) + (V : RationalFilteredNilmanifold K t e) + (child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1)) + (work cost : ℝ) (P C B : ℕ) : Prop := + ∀ p : ℝ, 0 ≤ p → p ≤ work → ∀ (r : ℤ) (h : σ → ℤ) (A' : σ → ℝ), + (∀ i, 0 < A' i) → (∀ i, |(h i : ℝ)| ≤ A i) → + (∀ i, |(r : ℝ)| * A' i ≤ A i) → + ∀ S : D.Niltest (fun _ : σ => 1), + S.orbit = D.filtration.realification.scalarAffineOrbitHom (r : ℚ) + (fun i => (h i : ℚ)) T.orbit → + S.UnitIntervalValued → S.ComplexityLE p → + ∀ q rho : ℝ, p ≤ q → (Fintype.card σ : ℝ) ≤ q → + verticalDecompositionBudget p ≤ q → 0 < rho → rho⁻¹ ≤ Real.exp p → + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ), 0 < M → + ∀ (u v : σ → ℤ) (J : σ → ℕ), (∀ i, 0 < J i) → + (∀ i, v i ≡ u i [ZMOD (M : ℤ)]) → + (∀ i, (M * (M * P)).Coprime (J i)) → + (∀ i, ((M * J i : ℕ) : ℝ) * (Real.exp ((q + B) ^ B) + 1) ≤ (N i : ℝ)) → + ∀ Δ ε δ : ℝ, 0 < δ → δ ≤ 1 → ε < 1 / 2 → + 2 * (2 * rho + Real.exp (verticalDecompositionBudget p - q)) ≤ Δ / 2 → + 8 * ε + 2 * (Real.exp ((work + 2) ^ C) * δ) ≤ Δ / 4 → + (∀ i, 8 ≤ δ * (N i : ℝ)) → + (∀ i, (u i : ℝ) - (M : ℝ) * A' i ≤ (lo i : ℝ) ∧ + (lo i : ℝ) + (N i : ℝ) ≤ (u i : ℝ) + (M : ℝ) * A' i) → + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ δ * ε / 8 → + Δ ≤ ‖residuePairMean S.eval lo N M u v J false - residuePairMean S.eval lo N M u v J true‖ → + ResiduePairDimensionDrop D ω hF S W lo N M u v J ((q + B) ^ B) ∨ + AnchoredChildResidueComparison V + (V.filtration.realification.scalarAffineOrbitHom (r : ℚ) (fun i => (h i : ℚ)) child) + cost (Δ / 4) δ lo N M P u v J + +theorem exists_fixed_affine_epoch_transition (s : ℕ) (hs : 1 ≤ s) : + ∃ B : ℕ, 2 ≤ B ∧ ∀ {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {d t e : ℕ} + (D : RationalFilteredNilmanifold L s d) (V : RationalFilteredNilmanifold K t e) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (T : D.Niltest (fun _ : σ => 1)) (A : σ → ℝ) + (work cost : ℝ) (q₀ P C : ℕ) (hP : 0 < P), 0 ≤ work → + ∀ (E b R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (κ : D.RealGroup), + κ ∈ D.realLattice → + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨T.orbit.log, T.orbit.property⟩⟩ → + D.filtration.PolynomialRationalGrid D.basis (fun _ : σ => 1) q₀ R → + (∀ A' : σ → ℝ, (∀ i, 0 < A' i) → ∀ (r : ℚ) (h : σ → ℚ), + (∀ i, |(h i : ℝ)| ≤ A i) → (∀ i, |(r : ℝ)| * A' i ≤ A i) → + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) A' (Real.exp (work + 2)) + (D.filtration.realification.scalarAffineAdaptedHom r h E)) → + ∀ child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1), + FixedAffineResidueDescent D W V b child work q₀ P hP C 1 cost → + FixedAffineEpochTransition D ω hF W T A V child work cost P C B := by + obtain ⟨B, hB, hstep⟩ := exists_separated_residue_event_or_child s hs + refine ⟨B, hB, ?_⟩ + intro σ L K _ _ _ _ _ _ _ _ _ _ _ _ _ _ d t e D V ω hF W T A work cost q₀ P C hP _hwork + E b R κ hκ hprod hgrid hslow child hchild p hp hpwork r h A' hA' hh hr S hS hunit hcost q rho hpq hσ hfreq hrho hrhop + lo N M hM u v J hJ hv hcop hsteplarge Δ ε δ hδ hδone hε hprojection hfreezing + hlarge hphysical hcount hgap + let E' := D.filtration.realification.scalarAffineAdaptedHom (r : ℚ) (fun i => (h i : ℚ)) E + let b' := D.filtration.realification.scalarAffineAdaptedHom (r : ℚ) (fun i => (h i : ℚ)) b + let R' := D.filtration.realification.scalarAffineAdaptedHom (r : ℚ) (fun i => (h i : ℚ)) R + have horbit : (T.scalarAffinePullback (r : ℚ) (fun i => (h i : ℚ))).orbit = S.orbit := hS.symm + have hprod' : E' * b' * R' * + D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩ := by + simpa only [horbit] using T.scalarAffinePullback_normalized_factorization E b R κ hprod + (r : ℚ) (fun i => (h i : ℚ)) + have hgrid' := D.filtration.polynomialRationalGrid_scalarAffine_integer D.basis q₀ R hgrid r h + have hslow' := hslow A' hA' (r : ℚ) (fun i => (h i : ℚ)) + (fun i => by simpa only [Rat.cast_intCast] using hh i) + (fun i => by simpa only [Rat.cast_intCast] using hr i) + exact hstep D V ω hF p work q rho hp hpwork hpq hσ hfreq hrho hrhop W b' + (V.filtration.realification.scalarAffineOrbitHom (r : ℚ) (fun i => (h i : ℚ)) child) + q₀ P C 1 hP cost (hchild r h) S hunit hcost E' R' κ hκ hprod' hgrid' A' hA' + (by simpa only [pow_one] using hslow') lo N M hM u v J hJ hv hcop hsteplarge + Δ ε δ hδ hδone hε hprojection hfreezing hlarge hphysical hcount hgap + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FixedAffineResidueDescent.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FixedAffineResidueDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe77cc197f66408d64b7af3a5862020f7e86b0d3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FixedAffineResidueDescent.lean @@ -0,0 +1,574 @@ +import OAI.Combinatorics.Progressions.Estimates.ControlledSingleRefilteredReconstruction + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +theorem scalarAffinePolynomial_integer {σ : Type*} (a : ℤ) (shift : σ → ℤ) (i : σ) : + scalarAffinePolynomial (a : ℚ) (fun j => (shift j : ℚ)) i ∈ integerCoefficientPolynomials σ := by + exact (integerCoefficientPolynomials σ).add_mem (integerCoefficientPolynomials_C (shift i)) + ((integerCoefficientPolynomials σ).mul_mem (integerCoefficientPolynomials_C a) + (integerCoefficientPolynomials_X i)) + +theorem scalarAffine_monomial_integer_coefficients {σ : Type*} + (a : ℤ) (shift : σ → ℤ) (α β : σ →₀ ℕ) : + ∃ z : ℤ, (MvPolynomial.aeval (R := ℚ) + (scalarAffinePolynomial (a : ℚ) (fun i => (shift i : ℚ))) (monomial β 1)).coeff α = + (z : ℚ) := by + apply (mem_integerCoefficientPolynomials_iff _).mp ?_ α + apply integerPolynomialHom_preserves + (MvPolynomial.aeval (R := ℚ) (scalarAffinePolynomial (a : ℚ) (fun i => (shift i : ℚ)))) + · intro i + simpa only [aeval_X] using scalarAffinePolynomial_integer a shift i + · refine ⟨monomial β (1 : ℤ), ?_⟩ + simp + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +noncomputable def scalarAffineAdaptedHom {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (r : ℚ) (h : σ → ℚ) : + (F.adaptedPolynomialFiltration (fun _ : σ => 1)).Group →* + (F.adaptedPolynomialFiltration (fun _ : σ => 1)).Group := + (F.polynomialOrbitCoordinates (fun _ => 1)).toMonoidHom.comp + ((F.polynomialOrbitSubstitute (scalarAffinePolynomial r h) (scalarAffinePolynomial_support r h)).comp + (F.polynomialOrbitCoordinates (fun _ => 1)).symm.toMonoidHom) + +theorem scalarAffineAdaptedHom_coord {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (r : ℚ) (h : σ → ℚ) + (g : (F.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) : + ((F.scalarAffineAdaptedHom r h g).coord : VectorPolynomial σ ℚ L) = + weightedDilation (fun _ : σ => 1) r (translate h (g.coord : VectorPolynomial σ ℚ L)) := by + change substitute (scalarAffinePolynomial r h) (g.coord : VectorPolynomial σ ℚ L) = _ + exact substitute_scalarAffinePolynomial r h _ + +theorem PolynomialSlowBound.scalarAffine {σ ι L : Type*} [Fintype σ] + [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (T A : σ → ℝ) + (hT : ∀ i, 0 < T i) (hA : ∀ i, 0 < A i) {M B : ℝ} + (g : (F.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (hg : F.PolynomialSlowBound b (fun _ => 1) T M g) (hM : 0 ≤ M) (hB : 1 ≤ B) + (r : ℚ) (h : σ → ℚ) + (hphysical : ∀ i, |(h i : ℝ)| + |(r : ℝ)| * A i ≤ B * T i) : + F.PolynomialSlowBound b (fun _ => 1) A + (((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * M * B ^ s) + (F.realification.scalarAffineAdaptedHom r h g) := by + have hdegree : DegreeLE (fun _ : σ => 1) s (g.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) := + (F.realification.adaptedBCHToOrbit (fun _ => 1) g).degreeLE + change CoefficientBound (b.baseChange ℝ) A _ + ((F.realification.scalarAffineAdaptedHom r h g).coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + rw [scalarAffineAdaptedHom_coord] + exact CoefficientBound.scalarAffine (b.baseChange ℝ) T A hT hA hg hM hB hdegree r h hphysical + +theorem exists_scalarAffine_slow_bound (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ ι L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (p : ℝ), + 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → + ∀ T A : σ → ℝ, (∀ i, 0 < T i) → (∀ i, 0 < A i) → + ∀ g : (F.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group, + F.PolynomialSlowBound b (fun _ => 1) T (Real.exp ((p + 2) ^ a)) g → + ∀ (r : ℚ) (h : σ → ℚ), (∀ i, |(h i : ℝ)| ≤ T i) → + (∀ i, |(r : ℝ)| * A i ≤ T i) → + F.PolynomialSlowBound b (fun _ => 1) A (Real.exp ((p + C) ^ C)) + (F.realification.scalarAffineAdaptedHom r h g) := by + let P : Polynomial ℕ := Polynomial.C ((s + 1) * 2 ^ s) * (Polynomial.X + 1) ^ s + + (Polynomial.X + 2) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ ι L _ _ _ F b p hp hσ T A hT hA g hg r h hh hr + have hbound := PolynomialSlowBound.scalarAffine F b T A hT hA g hg + (Real.exp_nonneg _) (by norm_num : (1 : ℝ) ≤ 2) r h (fun i => by linarith [hh i, hr i]) + let K := ((s : ℝ) + 1) * (p + 1) ^ s * 2 ^ s + have hK : ((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * 2 ^ s ≤ K := by + dsimp [K] + gcongr + have hKe : K ≤ Real.exp K := by linarith [Real.add_one_le_exp K] + have hcost : K + (p + 2) ^ a ≤ (p + C) ^ C := by + simpa [P, K, Polynomial.eval₂_pow, Nat.cast_add, Nat.cast_mul, Nat.cast_pow, mul_assoc, + mul_left_comm, mul_comm] using hbudget p hp + apply F.polynomialSlowBound_mono b (fun _ => 1) A hA _ _ hbound + calc + ((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * Real.exp ((p + 2) ^ a) * 2 ^ s = + (((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * 2 ^ s) * Real.exp ((p + 2) ^ a) := by ring + _ ≤ K * Real.exp ((p + 2) ^ a) := mul_le_mul_of_nonneg_right hK (Real.exp_nonneg _) + _ ≤ Real.exp K * Real.exp ((p + 2) ^ a) := mul_le_mul_of_nonneg_right hKe (Real.exp_nonneg _) + _ = Real.exp (K + (p + 2) ^ a) := (Real.exp_add _ _).symm + _ ≤ Real.exp ((p + C) ^ C) := Real.exp_le_exp.mpr hcost + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct BigOperators + +theorem polynomialRationalGrid_scalarAffine_integer {σ ι L : Type*} + [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (q : ℕ) + (g : (F.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (hg : F.PolynomialRationalGrid b (fun _ : σ => 1) q g) + (a : ℤ) (shift : σ → ℤ) : + F.PolynomialRationalGrid b (fun _ : σ => 1) q + (F.realification.scalarAffineAdaptedHom (a : ℚ) (fun i => (shift i : ℚ)) g) := by + classical + obtain ⟨u, hu⟩ := hg + choose c hc using fun α β => scalarAffine_monomial_integer_coefficients a shift α β + refine ⟨fun z => ∑ β ∈ (coefficients (g.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L))).support, + c z.1 β * u (β, z.2), ?_⟩ + funext z + change ((∑ β ∈ (coefficients (g.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L))).support, + c z.1 β * u (β, z.2) : ℤ) : ℝ) = (q : ℝ) * (b.baseChange ℝ).repr + (coefficients ((F.realification.scalarAffineAdaptedHom (a : ℚ) + (fun i => (shift i : ℚ)) g).coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) z.1) z.2 + rw [scalarAffineAdaptedHom_coord, ← substitute_scalarAffinePolynomial, coefficients_substitute] + simp only [Int.cast_sum, Int.cast_mul, map_sum, Finsupp.finsetSum_apply, + map_rat_smul, Finsupp.smul_apply, Rat.smul_def, Finset.mul_sum] + apply Finset.sum_congr rfl + intro β _ + rw [hc z.1 β] + have hβ := congrFun hu (β, z.2) + change (u (β, z.2) : ℝ) = (q : ℝ) * (b.baseChange ℝ).repr + (coefficients (g.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) β) z.2 at hβ + rw [hβ] + push_cast + ring + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3 + +open VectorPolynomial +open scoped TensorProduct + +namespace NilpotentLieFiltration + +theorem scalarAffineAdaptedHom_constant {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (r : ℚ) (h : σ → ℚ) (κ : F.Group) : + F.scalarAffineAdaptedHom r h (F.adaptedConstantGroupHom (fun _ : σ => 1) κ) = + F.adaptedConstantGroupHom (fun _ : σ => 1) κ := by + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + change substitute (scalarAffinePolynomial r h) (monomial 0 κ.coord) = monomial 0 κ.coord + simp [monomial] + +end NilpotentLieFiltration + +namespace RationalFilteredNilmanifold.Niltest + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +theorem scalarAffinePullback_normalized_factorization (S : D.Niltest (fun _ : σ => 1)) + (E b R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (κ : D.RealGroup) + (hprod : E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩) + (r : ℚ) (h : σ → ℚ) : + D.filtration.realification.scalarAffineAdaptedHom r h E * + D.filtration.realification.scalarAffineAdaptedHom r h b * + D.filtration.realification.scalarAffineAdaptedHom r h R * + D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨(S.scalarAffinePullback r h).orbit.log, (S.scalarAffinePullback r h).orbit.property⟩⟩ := by + have heq := congrArg (D.filtration.realification.scalarAffineAdaptedHom r h) hprod + simp only [map_mul, NilpotentLieFiltration.scalarAffineAdaptedHom_constant] at heq + refine heq.trans ?_ + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + rw [NilpotentLieFiltration.scalarAffineAdaptedHom_coord] + exact (S.scalarAffinePullback_log r h).symm + +end RationalFilteredNilmanifold.Niltest +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open VectorPolynomial +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem scalarAffineAdaptedHom_value (r : ℚ) (h : σ → ℚ) (x : σ → ℝ) + (g : (F.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) : + F.adaptedPolynomialRealValueHom (fun _ : σ => 1) x + (F.realification.scalarAffineAdaptedHom r h g) = + F.adaptedPolynomialRealValueHom (fun _ : σ => 1) + (fun i => (h i : ℝ) + (r : ℝ) * x i) g := by + apply NilpotentLieBCHGroup.ext + rw [adaptedPolynomialRealValueHom_coord, adaptedPolynomialRealValueHom_coord, + scalarAffineAdaptedHom_coord, ← substitute_scalarAffinePolynomial, eval₂_substitute] + apply congrArg (fun y : σ → ℝ => eval₂ y (g.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L))) + funext i + simp [scalarAffinePolynomial] + +theorem scalarAffineAdaptedHom_value_integer (r : ℚ) (h : σ → ℚ) (x y : σ → ℤ) + (hxy : ∀ i, h i + r * (x i : ℚ) = (y i : ℚ)) + (g : (F.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) : + F.adaptedPolynomialRealValueHom (fun _ : σ => 1) (fun i => (x i : ℝ)) + (F.realification.scalarAffineAdaptedHom r h g) = + F.adaptedPolynomialRealValueHom (fun _ : σ => 1) (fun i => (y i : ℝ)) g := by + rw [scalarAffineAdaptedHom_value] + have heq : (fun i => (h i : ℝ) + (r : ℝ) * (x i : ℝ)) = (fun i => (y i : ℝ)) := by + funext i + exact_mod_cast hxy i + rw [heq] + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open NilpotentLieBCHGroup +open scoped TensorProduct + +theorem exists_scalarAffine_factor_freezing (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p : ℝ), + 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → + ∀ S : D.Niltest (fun _ : σ => 1), S.ComplexityLE p → + ∀ (E b R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (κ : D.RealGroup), κ ∈ D.realLattice → + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩ → + ∀ T A : σ → ℝ, (∀ i, 0 < T i) → (∀ i, 0 < A i) → + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) T + (Real.exp ((p + 2) ^ a)) E → + ∀ (r : ℚ) (h : σ → ℚ), (∀ i, |(h i : ℝ)| ≤ T i) → + (∀ i, |(r : ℝ)| * A i ≤ T i) → + ∀ (x : σ → ℤ) (z : σ → ℝ) (r₀ : D.RealGroup) (δ : ℝ), 0 ≤ δ → + (∀ i, |(x i : ℝ)| ≤ A i) → (∀ i, |z i| ≤ A i) → + (∀ i, |(x i : ℝ) - z i| ≤ A i * δ) → + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) + (fun i => (x i : ℝ)) (D.filtration.realification.scalarAffineAdaptedHom r h R)) : + D.Space) = QuotientGroup.mk r₀ → + ‖(S.scalarAffinePullback r h).eval x - S.observable (QuotientGroup.mk + (D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) z + (D.filtration.realification.scalarAffineAdaptedHom r h E) * + D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) (fun i => (x i : ℝ)) + (D.filtration.realification.scalarAffineAdaptedHom r h b) * r₀))‖ ≤ + Real.exp ((p + C) ^ C) * δ := by + obtain ⟨u, _, hslow⟩ := NilpotentLieFiltration.exists_scalarAffine_slow_bound s a + obtain ⟨v, _, hfreeze⟩ := exists_slow_factor_freezing s 1 + let P : Polynomial ℕ := (Polynomial.X + (Polynomial.X + Polynomial.C u) ^ u + Polynomial.C v) ^ v + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ _ _ _ d D p hp hσ S hS E b R κ hκ hprod T A hT hA hE r h hh hr x z r₀ δ hδ hx hz hxz hR + let q := p + (p + u) ^ u + have hpq : p ≤ q := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have hq : 0 ≤ q := hp.trans hpq + have hE' := hslow D.filtration D.basis p hp hσ T A hT hA E hE r h hh hr + have hcost : (p + u) ^ u ≤ (q + 2) ^ (1 : ℕ) := by + dsimp [q] + rw [pow_one] + linarith + have hE'' := D.filtration.polynomialSlowBound_mono D.basis (fun _ : σ => 1) A hA + (Real.exp_le_exp.mpr hcost) _ hE' + have hS' : (S.scalarAffinePullback r h).ComplexityLE q := + (S.scalarAffinePullback_complexityLE r h q).mpr (hS.mono hpq) + have hprod' := S.scalarAffinePullback_normalized_factorization E b R κ hprod r h + have hbound := hfreeze D (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) q hq (hσ.trans hpq) + (S.scalarAffinePullback r h) hS' + (D.filtration.realification.scalarAffineAdaptedHom r h E) + (D.filtration.realification.scalarAffineAdaptedHom r h b) + (D.filtration.realification.scalarAffineAdaptedHom r h R) κ hκ hprod' A hA hE'' + x z r₀ δ hδ hx hz hxz hR + apply hbound.trans + apply mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr _) hδ + simpa [P, q, Polynomial.eval₂_pow] using hbudget p hp + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open NilpotentLieBCHGroup +open scoped TensorProduct + +theorem exists_periodic_scalarAffine_freezing (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (p : ℝ), + 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card σ : ℝ) ≤ p → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ M : ℕ, 0 < M ∧ (M : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∀ S : D.Niltest (fun _ : σ => 1), S.ComplexityLE p → + ∀ (E b R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (κ : D.RealGroup), κ ∈ D.realLattice → + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩ → + D.filtration.PolynomialRationalGrid D.basis (fun _ : σ => 1) q R → + ∀ T A : σ → ℝ, (∀ i, 0 < T i) → (∀ i, 0 < A i) → + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) T + (Real.exp ((p + 2) ^ a)) E → + ∀ (r : ℚ) (h : σ → ℚ), (∀ i, |(h i : ℝ)| ≤ T i) → + (∀ i, |(r : ℝ)| * A i ≤ T i) → + ∀ (x : σ → ℤ) (z : σ → ℝ) (y t : σ → ℤ) (δ : ℝ), 0 ≤ δ → + (∀ i, h i + r * (x i : ℚ) = (y i : ℚ)) → + (∀ i, (M : ℤ) ∣ y i - t i) → + (∀ i, |(x i : ℝ)| ≤ A i) → (∀ i, |z i| ≤ A i) → + (∀ i, |(x i : ℝ) - z i| ≤ A i * δ) → + let r₀ := D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) + (fun i => (t i : ℝ)) R + (D.basis.baseChange ℝ).equivFun r₀.coord ∈ realDenominatorGrid q ∧ + ‖(S.scalarAffinePullback r h).eval x - S.observable (QuotientGroup.mk + (D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) z + (D.filtration.realification.scalarAffineAdaptedHom r h E) * + D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) (fun i => (x i : ℝ)) + (D.filtration.realification.scalarAffineAdaptedHom r h b) * r₀))‖ ≤ + Real.exp ((p + C) ^ C) * δ := by + obtain ⟨u, _, hperiod⟩ := exists_native_rational_period s + obtain ⟨v, _, hfreeze⟩ := exists_scalarAffine_factor_freezing s a + let P : Polynomial ℕ := (Polynomial.X + Polynomial.C u) ^ u + + (Polynomial.X + Polynomial.C v) ^ v + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ _ _ _ d D p hp hD hσ q hq hqp + have hcost : (p + u) ^ u + (p + v) ^ v ≤ (p + C) ^ C := by + simpa [P, Polynomial.eval₂_pow] using hbudget p hp + have hucost : (p + u) ^ u ≤ (p + C) ^ C := + (le_add_of_nonneg_right (by positivity)).trans hcost + have hvcost : (p + v) ^ v ≤ (p + C) ^ C := + (le_add_of_nonneg_left (by positivity)).trans hcost + obtain ⟨M, hM, hMb, hcoset⟩ := hperiod D (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) + p hp hD hσ q hq hqp + refine ⟨M, hM, hMb.trans (Real.exp_le_exp.mpr hucost), ?_⟩ + intro S hS E b R κ hκ hprod hgrid T A hT hA hE r h hh hr x z y t δ hδ hxy hcongr hx hz hxz r₀ + have hR : (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) + (fun i => (x i : ℝ)) (D.filtration.realification.scalarAffineAdaptedHom r h R)) : D.Space) = + QuotientGroup.mk r₀ := by + rw [D.filtration.scalarAffineAdaptedHom_value_integer r h x y hxy] + exact (hcoset R hgrid y t hcongr).1 + refine ⟨D.filtration.polynomialRationalGrid_value D.basis (fun _ : σ => 1) q R hgrid t, ?_⟩ + have hb := hfreeze D p hp hσ S hS E b R κ hκ hprod T A hT hA hE r h hh hr x z r₀ δ hδ hx hz hxz hR + exact hb.trans (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hvcost) hδ) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +namespace NilpotentLieFiltration + +noncomputable def scalarAffineOrbitHom {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (r : ℚ) (h : σ → ℚ) : + F.PolynomialOrbit (fun _ : σ => 1) →* F.PolynomialOrbit (fun _ : σ => 1) := + F.polynomialOrbitSubstitute (scalarAffinePolynomial r h) (scalarAffinePolynomial_support r h) + +end NilpotentLieFiltration + +namespace RationalFilteredNilmanifold + +theorem FixedPositiveNiltestRealization.scalarAffine + {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} + {child : D.filtration.realification.PolynomialOrbit (fun _ : σ => 1)} + {cost : ℝ} {f : (σ → ℤ) → ℂ} + (h : D.FixedPositiveNiltestRealization child cost f) (a : ℤ) (shift : σ → ℤ) : + D.FixedPositiveNiltestRealization + (D.filtration.realification.scalarAffineOrbitHom (a : ℚ) (fun i => (shift i : ℚ)) child) + cost (fun x => f (fun i => a * x i + shift i)) := by + obtain ⟨U, hU, hunit, hcost, heval⟩ := h + refine ⟨U.scalarAffinePullback (a : ℚ) (fun i => (shift i : ℚ)), ?_, hunit, hcost, ?_⟩ + · change D.filtration.realification.scalarAffineOrbitHom (a : ℚ) (fun i => (shift i : ℚ)) U.orbit = _ + rw [hU] + · intro x + rw [U.scalarAffinePullback_eval_integer] + exact heval _ + +end RationalFilteredNilmanifold + +end Erdos3 + +end + +section + +namespace Erdos3 + +namespace NilpotentLieFiltration + +theorem scalarAffineOrbitHom_comp {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (g : F.PolynomialOrbit (fun _ : σ => 1)) + (r₀ r₁ : ℚ) (h₀ h₁ : σ → ℚ) : + F.scalarAffineOrbitHom r₁ h₁ (F.scalarAffineOrbitHom r₀ h₀ g) = + F.scalarAffineOrbitHom (r₀ * r₁) (fun i => r₀ * h₁ i + h₀ i) g := by + apply Subtype.ext + apply NilpotentLieBCHGroup.ext + change VectorPolynomial.substitute (scalarAffinePolynomial r₁ h₁) + (VectorPolynomial.substitute (scalarAffinePolynomial r₀ h₀) g.log) = + VectorPolynomial.substitute (scalarAffinePolynomial (r₀ * r₁) (fun i => r₀ * h₁ i + h₀ i)) g.log + rw [VectorPolynomial.substitute_comp] + simp only [scalarAffinePolynomial_comp] + +end NilpotentLieFiltration + +theorem commonStrideIndex_refinement_tower {σ : Type*} (u v w : σ → ℤ) + {A B : ℕ} (hA : 0 < A) (hAB : A ∣ B) + (huv : ∀ i, v i ≡ u i [ZMOD (A : ℤ)]) + (hvw : ∀ i, w i ≡ v i [ZMOD (B : ℤ)]) : + commonStrideIndex u A w = fun i => + ((B / A : ℕ) : ℤ) * commonStrideIndex v B w i + commonStrideIndex u A v i := by + have h := commonStrideIndex_of_refinement u v hA hAB huv (commonStrideIndex v B w) + simpa only [commonStridePoint_index_of_modEq v B w hvw] using h + +theorem residue_refinement_scale_tower {A B C : ℕ} (hAB : A ∣ B) (hBC : B ∣ C) : + ((B / A : ℕ) : ℚ) * (C / B : ℕ) = (C / A : ℕ) := by + exact_mod_cast (show B / A * (C / B) = C / A by + rw [mul_comm] + exact Nat.div_mul_div hBC hAB) + +namespace NilpotentLieFiltration + +theorem scalarAffineOrbitHom_refinement_tower {σ L : Type*} + [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (g : F.PolynomialOrbit (fun _ : σ => 1)) + (u v w : σ → ℤ) {A B C : ℕ} (hA : 0 < A) (hAB : A ∣ B) (hBC : B ∣ C) + (huv : ∀ i, v i ≡ u i [ZMOD (A : ℤ)]) + (hvw : ∀ i, w i ≡ v i [ZMOD (B : ℤ)]) : + F.scalarAffineOrbitHom (C / B : ℕ) (fun i => (commonStrideIndex v B w i : ℚ)) + (F.scalarAffineOrbitHom (B / A : ℕ) (fun i => (commonStrideIndex u A v i : ℚ)) g) = + F.scalarAffineOrbitHom (C / A : ℕ) (fun i => (commonStrideIndex u A w i : ℚ)) g := by + rw [scalarAffineOrbitHom_comp, residue_refinement_scale_tower hAB hBC] + have hshift : (fun i => ((B / A : ℕ) : ℚ) * (commonStrideIndex v B w i : ℚ) + + (commonStrideIndex u A v i : ℚ)) = (fun i => (commonStrideIndex u A w i : ℚ)) := by + funext i + have h := congrFun (commonStrideIndex_refinement_tower u v w hA hAB huv hvw) i + have hc := congrArg (fun z : ℤ => (z : ℚ)) h.symm + simpa only [Int.cast_add, Int.cast_mul, Int.cast_natCast] using hc + rw [hshift] + +end NilpotentLieFiltration + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct BigOperators + +noncomputable def FixedResidueDescent {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {s d t e : ℕ} + (D : RationalFilteredNilmanifold L s d) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (V : RationalFilteredNilmanifold K t e) (w : σ → ℕ) + (b : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (child : V.filtration.realification.PolynomialOrbit w) + (p : ℝ) (q P : ℕ) (hP : 0 < P) (C a : ℕ) (cost : ℝ) : Prop := + ∀ S : D.Niltest w, S.ComplexityLE p → S.UnitIntervalValued → + (∀ z : D.RealGroup, z.coord ∈ D.filtration.realGradedRefiltrationLayer W s → + ∀ x, S.observable (z • x) = S.observable x) → + ∀ (E R : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (κ : D.RealGroup), κ ∈ D.realLattice → + E * b * R * D.filtration.realification.adaptedConstantGroupHom w κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩ → + D.filtration.PolynomialRationalGrid D.basis w q R → + ∀ A : σ → ℝ, (∀ i, 0 < A i) → + D.filtration.PolynomialSlowBound D.basis w A (Real.exp ((p + 2) ^ a)) E → + ∀ (M : ℕ) (hM : 0 < M) (lo : σ → ℤ) (N H : σ → ℕ) + (hH : ∀ i, 0 < H i) (hHN : ∀ i, H i ≤ N i) (u v : σ → ℤ) (J : σ → ℕ), + (∀ i, 0 < J i) → ∀ (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]), + (∀ i, (M * (M * P)).Coprime (J i)) → + ∀ (δ ε : ℝ), 0 ≤ δ → ε < 1 / 2 → + (∀ i, 2 * (H i : ℝ) ≤ (M : ℝ) * A i * δ) → + (∀ i, (u i : ℝ) - (M : ℝ) * A i ≤ (lo i : ℝ) ∧ + (lo i : ℝ) + (N i : ℝ) ≤ (u i : ℝ) + (M : ℝ) * A i) → + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (H i : ℝ)) ≤ ε → + let Q := comparableBoxPartitions N H hH hHN + let c₀ := baseAuxiliaryBoxCell lo N Q (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u + let c₁ := refinedAuxiliaryBoxCell lo N Q (fun _ => M) (fun _ => M * P) J + (fun _ => Nat.mul_pos hM hP) u v hv + let F : IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) u → ℂ := + residueBoxStrideValue S.eval u M + let G : IntegerResidueBox lo (fun i => lo i + N i) (fun i => (M * J i : ℕ)) v → ℂ := + residueBoxStrideValue S.eval u M + ∃ k : AuxiliaryBoxLabels Q (fun _ => M) (fun _ => M * P) u, + 0 < (partitionCell c₀ k).card ∧ 0 < (partitionCell c₁ k).card ∧ + ∃ U : V.Niltest w, U.orbit = child ∧ U.UnitIntervalValued ∧ U.ComplexityLE cost ∧ + ‖(𝔼 x, F x) - (𝔼 x, G x)‖ - 8 * ε - 2 * (Real.exp ((p + 2) ^ C) * δ) ≤ + ‖(𝔼 x ∈ partitionCell c₀ k, residueBoxStrideValue U.eval u M x) - + (𝔼 x ∈ partitionCell c₁ k, residueBoxStrideValue U.eval u M x)‖ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +noncomputable def FixedAffineResidueDescent {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {s d t e : ℕ} + (D : RationalFilteredNilmanifold L s d) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (V : RationalFilteredNilmanifold K t e) + (b : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1)) + (p : ℝ) (q P : ℕ) (hP : 0 < P) (C a : ℕ) (cost : ℝ) : Prop := + ∀ (scale : ℤ) (shift : σ → ℤ), + FixedResidueDescent D W V (fun _ : σ => 1) + (D.filtration.realification.scalarAffineAdaptedHom (scale : ℚ) (fun i => (shift i : ℚ)) b) + (V.filtration.realification.scalarAffineOrbitHom (scale : ℚ) (fun i => (shift i : ℚ)) child) + p q P hP C a cost + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ForecastBufferedIntegerDeckFactor.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastBufferedIntegerDeckFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a6870b0ce016e163b14a510d4a2feaa3341a6fb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastBufferedIntegerDeckFactor.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Sampling.ActualForecastModelPrecision +import OAI.Combinatorics.Progressions.Sampling.ForecastPhysicalQuarterRecovery + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule _root_.Set _root_.OAI.Set +open scoped Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "single" => (fun _ : Fin m => Unit) + +theorem forecastBufferedCoveredSiteFactor_integer_deck + (d : ℕ) [NeZero d] (r : ℝ≥0) (hr : 0 < r) {Y : Type*} + (F : (∀ j, Fin (n j) ⊕ E j → ZMod d) → Y × (LayerSamplerAxis I n → ℝ) → ℂ) + (s : Y) (w : ∀ j, (I j → ℝ) × (Fin (n j) → ℤ)) (deck : ∀ j, E j → ℤ) + (u : ∀ j, euclideanSubspace (U j)) + (hdeck : ∀ j, normalizedLatticeRepresentative (euclideanSubspace (U j)) (b j) (hb j) + (orthonormalMixedChart (o j) (w j)) + ((bW j).equivFun.symm (deck j)).val = u j) + (hquarter : ∀ j i, |normalizedLatticePoint (euclideanSubspace (U j)) (b j) + (orthonormalMixedChart (o j) (w j)) i| ≤ 1 / 4) : + let y : EuclideanJetLayers U single := fun j _ => QuotientAddGroup.mk ((d : ℝ)⁻¹ • u j) + forecastBufferedCoveredSiteFactor B U b S o hb bW d r hr d F s y = + allocatedBufferedSiteChartFactor B U b S o hb bW d r hr (fun _ => 1) y * + F (fun j => Sum.elim (fun i => ((w j).2 i : ZMod d)) + (fun i => (deck j i : ZMod d))) (s, allocatedFullMixedSiteValue (R := R) U b w) := by + let z : MixedCoveredJetSource I single E n d := + (fun j => (fun i _ => (w j).1 i, fun i _ => (w j).2 i), + fun j _ => integerResidueMap (E j) d (deck j)) + have hz : z ∈ mixedCoveredJetRegion (O := single) (E := E) U o b d + (fun j (_ : Unit) => standardLatticeClosedQuarterBox (J j)) := by + intro j _ t _ + exact ⟨hquarter j, mem_univ _⟩ + have hchart : mixedCoveredJetChart U o b hb bW d z = + fun j (_ : Unit) => QuotientAddGroup.mk ((d : ℝ)⁻¹ • u j) := by + funext j t + exact (normalizedCoveredChart_of_integer_deck (euclideanSubspace (U j)) (bW j) (b j) (hb j) + d (u j) (orthonormalMixedChart (o j) (w j)) (deck j) (hdeck j)).symm + have h := forecastBufferedCoveredSiteFactor_on_chart B U b S o hb bW d r hr d F s z hz + rw [hchart] at h + have hres : forecastBufferedFullResidue d d z = fun j => + Sum.elim (fun i => ((w j).2 i : ZMod d)) (fun i => (deck j i : ZMod d)) := by + funext j i + cases i with + | inl i => rfl + | inr i => exact ZMod.natCast_zmod_val (deck j i : ZMod d) + rw [hres] at h + exact h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ForecastInactiveAffineIntervalFixedResidueSite.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastInactiveAffineIntervalFixedResidueSite.lean new file mode 100644 index 0000000000000000000000000000000000000000..19ee802d47342710fb6bee1346dc902c0da2859e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastInactiveAffineIntervalFixedResidueSite.lean @@ -0,0 +1,544 @@ +import OAI.Combinatorics.Progressions.Sampling.ContainedProgressionForecastDisintegration +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveFixedPath +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveFixedProduct +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveSlicedFixedPath + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {A : Type*} [Fintype A] + +attribute [local instance] ScalarSiteExpansion.termFinite + +noncomputable def forecastInactiveFixedOutput + (selected : A → Σ j : Fin m, Fin (n j)) + (c : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + ((selected a).1.val + 1) → ℤ) + (x : G → IntegerScalarCubeBox Empty S.value) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty (allocatedPrincipalSides B U b S)) : + A → ((Finset.univ : Finset (Finset Empty)) : Type) → ℤ := fun a => + boundedCoefficientJetMatrix (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) ((selected a).1.val + 1) + (fun t : (Finset.univ : Finset (Finset Empty)) => (t : Finset Empty)) *ᵥ c a + +theorem exists_forecastInactive_fixed_residue_site + (selected : A → Σ j : Fin m, Fin (n j)) + (hselected : Function.Injective selected) + [∀ a, Nonempty (B ⟨(selected a).1, Sum.inr (selected a).2⟩)] + (q : ℕ) [NeZero q] + (coefficient : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q) → ℂ) + (hcoefficient : ∀ r, ‖coefficient r‖ ≤ 1) + {D P p v δ E : ℝ} + (hD : AllocatedComparisonDimensions (G := G) B Empty + (fun _ : Fin m => ((Finset.univ : Finset (Finset Empty)) : Type)) D) + (hP : 1 ≤ P) (hp : 0 ≤ p) (hv : 0 ≤ v) + (hPp : P ≤ Real.exp p) (hqv : (q : ℝ) ≤ Real.exp v) + (hδ : 0 < δ) (hE : 0 ≤ E) + (hδE : δ⁻¹ ≤ Real.exp E) + (hsize : q ≤ S.value) (hR1 : ∀ a, R (selected a).1 ≤ 1) + (hsmall : ∀ a, basisAxisScale (b (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (hgrid : ∀ a, allocatedGridAxis (I := I) U b S.value + ⟨(selected a).1, Sum.inr (selected a).2⟩) + (c : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + ((selected a).1.val + 1) → ℤ) + (hc : ∀ a d, c a d ∈ (allocatedLayerIntegerPMFs B U b hR hσ S + (selected a).1 (selected a).2 d).support) + (hσ1 : ∀ a, σ (selected a).1 ≤ 1) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hprimitive : scalarCubePrimitiveEnvelope Empty L 1 0 q ≤ P) + (hB : ∀ a, uniformSpectrumBlockCount (selected a).1.val 1 ((selected a).1.val + 1) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) : + let law := principalTupleWeights (α := Empty) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let Pos := {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q // + 0 < law.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))} + let scale := fun a => allocatedPrincipalGridScale (G := G) B U b (R := R) + (selected a).1 (selected a).2 + let O := allocatedInactiveJointSiteLog m D p v E + ∃ e : Pos → A → ScalarSiteExpansion.{0,0} (Finset Empty), + (∀ r a, (e r a).Bounds (Real.exp O) (Real.exp O) (Real.exp O) + ⟨Real.exp O, Real.exp_nonneg _⟩ (Real.exp (allocatedInactiveSupportLog D))) ∧ + (∑ t : Σ r, ∀ a, (e r a).Term, ‖forecastSiteMixtureCoefficient e + (fun r => (law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val)) : ℂ) * coefficient r.val) t‖) + ≤ Real.exp (Fintype.card A * O) ∧ + ∀ (x : G → IntegerScalarCubeBox Empty S.value) (z : A → ℤ), + ‖((∏ a, (scale a : ℝ)) : ℂ) * + law.complexMean (fun y => coefficient (principalResidueLabel q y) * + (if forecastInactiveFixedOutput B U b S selected c x y = (fun a _ => z a) + then (1 : ℂ) else 0)) - + (∑ r : Pos, (law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val)) : ℂ) * coefficient r.val * + siteFamilyEval (e r) (fun _ => z) (fun _ a => (z a : ℝ) / scale a))‖ ≤ δ := by + intro law Pos scale O + let c₀ (a : A) := c a (constantCoefficientSlot _ _) + have hc₀ (a : A) : allocatedLayerIntegerPMFs B U b hR hσ S (selected a).1 (selected a).2 + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) + ⟨(selected a).1, Sum.inr (selected a).2⟩ none) (c₀ a) ≠ 0 := by + exact hc a _ + have heach (r : Pos) := exists_forecastInactive_fixed_product_site B U b S hR hσ + selected hselected q (NeZero.pos q) r.val hD hP hp hv hPp hqv hδ hE hδE + hsize hR1 hsmall r.property hgrid c₀ hc₀ hσ1 L hL hprimitive hB + choose e he herr using heach + have hmass : (∑ r : Pos, law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val))) ≤ 1 := + (forecastInactive_positiveResidue_mass_sum law (principalResidueLabel q)).le + let w (r : Pos) := law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val)) + have hw (r : Pos) : 0 ≤ w r := law.mass_nonneg _ + refine ⟨e, he, ?_, ?_⟩ + · have hm := forecastSiteMixture_weighted_mass e he + (fun _ => Real.exp_nonneg O) w (fun r => coefficient r.val) hw hmass + (fun r => hcoefficient r.val) + simpa only [Finset.prod_const, Finset.card_univ, Real.exp_nat_mul] using hm + · intro x z + let μ (r : Pos) : ℂ := (((∏ a, (scale a : ℝ)) * + (dependentProductPMF (fun a => allocatedSupportedResidueJetPMF B U b hR hσ S q r.val r.property + (selected a).1 (selected a).2 (Finset.univ : Finset (Finset Empty)) (fun _ => c₀ a)) + (fun a _ => z a)).toReal : ℝ) : ℂ) + have herr' := forecastSiteMixture_weighted_error e w (fun r => coefficient r.val) μ + hw hmass (fun r => hcoefficient r.val) (fun _ => z) + (fun _ a => (z a : ℝ) / scale a) hδ.le (fun r => herr r z) + have hdis := forecastInactive_indicator_disintegration law (principalResidueLabel q) + (forecastInactiveFixedOutput B U b S selected c x) (fun a _ => z a) coefficient + have hconst (c : ℤ) (t : Finset Empty) : booleanCoefficient (fun _ : Finset Empty => c) t = c := by + simp only [booleanCoefficient_const, (Subsingleton.elim t ∅ : t = ∅), ↓reduceIte] + have hjoint (r : Pos) : + (law.condition (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) + r.property).toPMF.map (forecastInactiveFixedOutput B U b S selected c x) = + dependentProductPMF (fun a => allocatedSupportedResidueJetPMF B U b hR hσ S q r.val r.property + (selected a).1 (selected a).2 (Finset.univ : Finset (Finset Empty)) (fun _ => c₀ a)) := by + have h := forecastInactiveFixedPath_joint_law B U b hR hσ S q r.val r.property + selected hselected hsmall c hc x (fun _ => (Finset.univ : Finset (Finset Empty))) + unfold forecastInactiveFixedOutput + simpa only [hconst, law, c₀] using h + simp_rw [hjoint] at hdis + rw [hdis, Finset.mul_sum] + have heq : (∑ r : Pos, ((∏ a, (scale a : ℝ)) : ℂ) * + ((w r : ℂ) * coefficient r.val * + ((dependentProductPMF (fun a => allocatedSupportedResidueJetPMF B U b hR hσ S q r.val r.property + (selected a).1 (selected a).2 (Finset.univ : Finset (Finset Empty)) (fun _ => c₀ a)) + (fun a _ => z a)).toReal : ℂ))) = + ∑ r : Pos, (w r : ℂ) * coefficient r.val * μ r := by + apply Finset.sum_congr rfl + intro r _ + dsimp only [μ] + push_cast + ring + rw [heq] + exact herr' + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {A : Type*} [Fintype A] + +attribute [local instance] ScalarSiteExpansion.termFinite + +theorem forecastInactive_sliced_fixed_residue_identity + (selected : A → Σ j : Fin m, Fin (n j)) + (hselected : Function.Injective selected) + (q : ℕ) [NeZero q] + (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) + (lower : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) + (hH : ∀ t, 0 < H t) + (hsubset : ∀ t, integerProgressionSupport (lower t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S t : ℤ)) + (coefficient : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q) → ℂ) + (hsmall : ∀ a, basisAxisScale (b (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (c : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + ((selected a).1.val + 1) → ℤ) + (hc : ∀ a d, c a d ∈ (allocatedLayerIntegerPMFs B U b hR hσ S + (selected a).1 (selected a).2 d).support) + (x : G → IntegerScalarCubeBox Empty S.value) (z : A → ℤ) : + let p := principalTupleWeights (α := Empty) B (layerSamplerDegree I n) H hH + let map := containedProgressionTupleMap B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step lower (allocatedPrincipalSides_pos B U b S) hsubset + (p.fiberLaw map).complexMean (fun y => coefficient (principalResidueLabel q y) * + (if forecastInactiveFixedOutput B U b S selected c x y = (fun a _ => z a) then 1 else 0)) = + ∑ r : {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q // + 0 < p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + (p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + coefficient (progressionPrincipalResidue B (layerSamplerDegree I n) step lower q r.val) * + ((dependentProductPMF (fun a => allocatedSupportedSlicedResidueJetPMF B U b hR hσ S q r.val + H step lower hH hsubset r.property (selected a).1 (selected a).2 + (Finset.univ : Finset (Finset Empty)) (fun _ => c a (constantCoefficientSlot _ _))) + (fun a _ => z a)).toReal : ℂ) := by + intro p map + rw [containedProgressionForecast_indicator_disintegration] + apply Finset.sum_congr rfl + intro r _ + have hj := forecastInactiveSlicedFixedPath_joint_law B U b hR hσ S q r.val + H step lower hH hsubset r.property selected hselected hsmall c hc x + (fun _ => (Finset.univ : Finset (Finset Empty))) + have hconst (v : ℤ) (t : Finset Empty) : booleanCoefficient (fun _ : Finset Empty => v) t = v := by + simp only [booleanCoefficient_const, (Subsingleton.elim t ∅ : t = ∅), ↓reduceIte] + simp only [hconst] at hj + rw [show (containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step lower (allocatedPrincipalSides_pos B U b S) + hH hsubset q r.val r.property).toPMF.map (forecastInactiveFixedOutput B U b S selected c x) = _ + from hj] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {A : Type*} [Fintype A] + +attribute [local instance] ScalarSiteExpansion.termFinite + +theorem forecastInactive_affineInterval_fixed_residue_identity + (selected : A → Σ j : Fin m, Fin (n j)) + (hselected : Function.Injective selected) + (q : ℕ) [NeZero q] + (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) + (lower : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) + (hH : ∀ t, 0 < H t) + (hinside : ∀ j (t : Fin (H j)), + 0 ≤ lower j + (step j : ℤ) * t.val ∧ + lower j + (step j : ℤ) * t.val < allocatedPrincipalSides B U b S j) + (hsubset : ∀ t, integerProgressionSupport (lower t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S t : ℤ)) + (coefficient : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q) → ℂ) + (hsmall : ∀ a, basisAxisScale (b (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (c : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + ((selected a).1.val + 1) → ℤ) + (hc : ∀ a d, c a d ∈ (allocatedLayerIntegerPMFs B U b hR hσ S + (selected a).1 (selected a).2 d).support) + (x : G → IntegerScalarCubeBox Empty S.value) (z : A → ℤ) : + let p := principalTupleWeights (α := Empty) B (layerSamplerDegree I n) H hH + (principalAffineIntervalLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step lower hinside hH).complexMean (fun y => coefficient (principalResidueLabel q y) * + (if forecastInactiveFixedOutput B U b S selected c x y = (fun a _ => z a) then 1 else 0)) = + ∑ r : {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q // + 0 < p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))}, + (p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + coefficient (progressionPrincipalResidue B (layerSamplerDegree I n) step lower q r.val) * + ((dependentProductPMF (fun a => allocatedSupportedSlicedResidueJetPMF B U b hR hσ S q r.val + H step lower hH hsubset r.property (selected a).1 (selected a).2 + (Finset.univ : Finset (Finset Empty)) (fun _ => c a (constantCoefficientSlot _ _))) + (fun a _ => z a)).toReal : ℂ) := by + intro p + rw [principalAffineIntervalLaw_eq_contained B (layerSamplerDegree I n) H hH + (allocatedPrincipalSides B U b S) step lower (allocatedPrincipalSides_pos B U b S) hinside hsubset] + exact forecastInactive_sliced_fixed_residue_identity B U b S hR hσ selected hselected + q H step lower hH hsubset coefficient hsmall c hc x z + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable (q : ℕ) [NeZero q] +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ t, 0 < H t) +variable (hsubset : ∀ t, integerProgressionSupport (c t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable {A : Type*} [Fintype A] +attribute [local instance] ScalarSiteExpansion.termFinite + +theorem exists_forecastInactive_sliced_fixed_residue_site + (selected : A → Σ j : Fin m, Fin (n j)) + (hselected : Function.Injective selected) + (coefficient : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q) → ℂ) + (hcoefficient : ∀ r, ‖coefficient r‖ ≤ 1) + (δ P : ℝ) (Hchild : ℕ) (hδ : 0 < δ) + (hreg : ∀ a, (∃ b0 v0, + allocatedPrincipalSides B U basis S ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b0,v0⟩ < Hchild) ∨ + ((∀ b v, δ * allocatedPrincipalSides B U basis S ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩ ≤ + (H ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩ : ℝ)) ∧ + (∀ b v, 0 < step ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩))) + (hsmall : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value ⟨(selected a).1, Sum.inr (selected a).2⟩) + (coefficients : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + ((selected a).1.val + 1) → ℤ) + (hcoefficients : ∀ a d, coefficients a d ∈ (allocatedLayerIntegerPMFs B U basis hR hσ S + (selected a).1 (selected a).2 d).support) + (hσ1 : ∀ a, σ (selected a).1 ≤ 1) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hP : 1 ≤ P) (hsP : scalarCubePrimitiveEnvelope Empty L 1 0 q ≤ P) + (hstride : ∀ a b v, ((step ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩ * q : ℕ) : ℝ) ≤ P) + (hB : ∀ a, uniformSpectrumBlockCount (selected a).1.val 1 ((selected a).1.val + 1) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) + (Cactual δout Q Nt Vt Ct Ht : ℝ) (Lt : ℝ≥0) + (hCactual : 0 ≤ Cactual) (hCtNonneg : 0 ≤ Ct) (hδout : 0 < δout) (hQ : 0 ≤ Q) : + let degree := fun a => (selected a).1.val + 1 + let height := fun a => basisAxisScale (basis (selected a).1) (selected a).2 + let denom := fun a => inactiveDenominator (principalProfileSize (R (selected a).1) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (selected a).1 (selected a).2))) + let torus := fun a => blockTorusFactor (Fintype.card Empty) (degree a) + (Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) 1 + let V := fun a => (torus a : ℝ) * ((denom a : ℝ) * 2 ^ degree a) / δ ^ degree a + let cap := fun a => uniformSpectrumAbsoluteCap (selected a).1.val 1 (degree a) P (V a) (V a) + let cutoff := fun a => max (allocatedSlicedGridHeightCutoff (G := G) B (R := R) + (selected a).1 (selected a).2 (Nat.ceil ((q : ℝ) / δ))) + (denom a * 2 ^ degree a * Hchild ^ degree a + 2 * denom a) + let R0 := fun a => (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (degree a)) : ℝ) * + R (selected a).1 + let ε := uniformProductAccuracy (Fintype.card A) Cactual δout / 2 + let ζ := fun a => uniformBlockRetainedBias (selected a).1.val 1 (degree a) P (V a) (V a) ε + let freq := fun a => Real.toNNReal (uniformScaledRetainedFrequencyBound (selected a).1.val 1 P (V a) (ζ a)) + (∀ a, max (cutoff a : ℝ) (cap a) ≤ Cactual) → + (∀ a, R0 a + 1 / 4 ≤ Real.exp Q) → + (∀ a, (ε / (cap a + 1))⁻¹ ≤ Real.exp Q) → + (∀ a, (CircleFourier.characterLipConstant * freq a + 4 : ℝ≥0) ≤ Real.exp Q) → + (∀ a, (cutoff a : ℝ) ≤ Real.exp Q) → + (∀ a, (2 * (cutoff a : ℝ≥0) ^ 2 * (cutoff a : ℝ≥0) : ℝ≥0) ≤ Real.exp Q) → + ε⁻¹ ≤ Real.exp Q → + (∀ a, max ((uniformSpectrumSizeConstant (selected a).1.val 1 (degree a) P (V a) (V a) / + ε ^ max (majorArcSpectrumExponent (selected a).1.val 1) + (majorArcLengthExponent (selected a).1.val * degree a)) * Real.exp (4 * Q + 8)) + (Real.exp (4 * Q + 8)) ≤ Nt) → + (∀ a, max (uniformScaledRetainedDenominatorBound (selected a).1.val 1 (degree a) P + (V a) (V a) (ζ a)) 1 ≤ Vt) → + (∀ a, max (cap a * Real.exp (4 * Q + 8 + Q)) (Real.exp (4 * Q + 8 + Q)) ≤ Ct) → + (⟨Real.exp (1 + 6 * Q + 12), Real.exp_nonneg _⟩ + 4 : ℝ≥0) ≤ Lt → + (∀ a, R0 a + 1 / 4 ≤ Ht) → + let p := principalTupleWeights (α := Empty) B (layerSamplerDegree I n) H hH + let Pos := {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q // + 0 < p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))} + let map := containedProgressionTupleMap B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H step c (allocatedPrincipalSides_pos B U basis S) hsubset + let w := fun r : Pos => (p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + coefficient (progressionPrincipalResidue B (layerSamplerDegree I n) step c q r.val) + ∃ e : Pos → A → ScalarSiteExpansion.{0,0} (Finset Empty), + (∀ r a, (e r a).Bounds Nt Vt Ct Lt Ht) ∧ + (∑ t : Σ r : Pos, ∀ a, (e r a).Term, ‖forecastSiteMixtureCoefficient e w t‖) ≤ Ct ^ Fintype.card A ∧ + ∀ (x : G → IntegerScalarCubeBox Empty S.value) (z : A → ℤ), + ‖((∏ a, (height a : ℝ)) : ℂ) * + (p.fiberLaw map).complexMean (fun y => coefficient (principalResidueLabel q y) * + (if forecastInactiveFixedOutput B U basis S selected coefficients x y = (fun a _ => z a) + then 1 else 0)) - + (∑ r : Pos, w r * siteFamilyEval (e r) (fun _ => z) + (fun _ a => (z a : ℝ) / height a))‖ ≤ δout := by + intro degree height denom torus V cap cutoff R0 ε ζ freq + hactual hRQ hεQ hLQ hKQ hKLQ hεinvQ hNt hVt hCt hLt hHt p Pos map w + let c0 (a : A) := coefficients a (constantCoefficientSlot _ _) + have hc0 (a : A) : allocatedLayerIntegerPMFs B U basis hR hσ S (selected a).1 (selected a).2 + (principalCoefficientChoice (G := G) (layerSamplerDegree I n) + ⟨(selected a).1, Sum.inr (selected a).2⟩ none) (c0 a) ≠ 0 := hcoefficients a _ + have heach (r : Pos) := exists_forecastInactive_sliced_fixed_product_site + B U basis hR hσ S q (NeZero.pos q) r.val H step c hH hsubset r.property selected + δ P Hchild hδ hreg hsmall hgrid c0 hc0 hσ1 L hL hP hsP hstride hB + Cactual δout Q Nt Vt Ct Ht Lt hCactual hδout hQ + hactual hRQ hεQ hLQ hKQ hKLQ hεinvQ hNt hVt hCt hLt hHt + choose e he herr using heach + let mass (r : Pos) := p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) + let co (r : Pos) := coefficient (progressionPrincipalResidue B (layerSamplerDegree I n) step c q r.val) + have hmass : (∑ r : Pos, mass r) ≤ 1 := + (forecastInactive_positiveResidue_mass_sum p (principalResidueLabel q)).le + have hm (r : Pos) : 0 ≤ mass r := p.mass_nonneg _ + refine ⟨e, he, ?_, ?_⟩ + · have hbound := forecastSiteMixture_weighted_mass e he (fun _ => hCtNonneg) mass co hm hmass + (fun r => hcoefficient _) + simpa only [Finset.prod_const, Finset.card_univ] using hbound + · intro x z + let μ (r : Pos) : ℂ := (((∏ a, (height a : ℝ)) * + (dependentProductPMF (fun a => allocatedSupportedSlicedResidueJetPMF B U basis hR hσ S q r.val + H step c hH hsubset r.property (selected a).1 (selected a).2 + (Finset.univ : Finset (Finset Empty)) (fun _ => c0 a)) (fun a _ => z a)).toReal : ℝ) : ℂ) + have herr' := forecastSiteMixture_weighted_error e mass co μ hm hmass + (fun r => hcoefficient _) (fun _ => z) (fun _ a => (z a : ℝ) / height a) + hδout.le (fun r => herr r z) + rw [forecastInactive_sliced_fixed_residue_identity B U basis S hR hσ selected hselected q + H step c hH hsubset coefficient hsmall coefficients hcoefficients x z, Finset.mul_sum] + have heq : (∑ r : Pos, ((∏ a, (height a : ℝ)) : ℂ) * + ((mass r : ℂ) * co r * + ((dependentProductPMF (fun a => allocatedSupportedSlicedResidueJetPMF B U basis hR hσ S q r.val + H step c hH hsubset r.property (selected a).1 (selected a).2 + (Finset.univ : Finset (Finset Empty)) (fun _ => c0 a)) (fun a _ => z a)).toReal : ℂ))) = + ∑ r : Pos, (mass r : ℂ) * co r * μ r := by + apply Finset.sum_congr rfl + intro r _ + dsimp only [μ] + push_cast + ring + rw [heq] + exact herr' + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable (q : ℕ) [NeZero q] +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ t, 0 < H t) +variable (hinside : ∀ j (t : Fin (H j)), + 0 ≤ c j + (step j : ℤ) * t.val ∧ + c j + (step j : ℤ) * t.val < allocatedPrincipalSides B U basis S j) +variable (hsubset : ∀ t, integerProgressionSupport (c t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ)) +variable {A : Type*} [Fintype A] +attribute [local instance] ScalarSiteExpansion.termFinite + +theorem exists_forecastInactive_affineInterval_fixed_residue_site + (selected : A → Σ j : Fin m, Fin (n j)) + (hselected : Function.Injective selected) + (coefficient : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q) → ℂ) + (hcoefficient : ∀ r, ‖coefficient r‖ ≤ 1) + (δ P : ℝ) (Hchild : ℕ) (hδ : 0 < δ) + (hreg : ∀ a, (∃ b0 v0, + allocatedPrincipalSides B U basis S ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b0,v0⟩ < Hchild) ∨ + ((∀ b v, δ * allocatedPrincipalSides B U basis S ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩ ≤ + (H ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩ : ℝ)) ∧ + (∀ b v, 0 < step ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩))) + (hsmall : ∀ a, basisAxisScale (basis (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (hgrid : ∀ a, allocatedGridAxis (I := I) U basis S.value ⟨(selected a).1, Sum.inr (selected a).2⟩) + (coefficients : ∀ a, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + ((selected a).1.val + 1) → ℤ) + (hcoefficients : ∀ a d, coefficients a d ∈ (allocatedLayerIntegerPMFs B U basis hR hσ S + (selected a).1 (selected a).2 d).support) + (hσ1 : ∀ a, σ (selected a).1 ≤ 1) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hP : 1 ≤ P) (hsP : scalarCubePrimitiveEnvelope Empty L 1 0 q ≤ P) + (hstride : ∀ a b v, ((step ⟨⟨(selected a).1,Sum.inr (selected a).2⟩,b,v⟩ * q : ℕ) : ℝ) ≤ P) + (hB : ∀ a, uniformSpectrumBlockCount (selected a).1.val 1 ((selected a).1.val + 1) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) + (Cactual δout Q Nt Vt Ct Ht : ℝ) (Lt : ℝ≥0) + (hCactual : 0 ≤ Cactual) (hCtNonneg : 0 ≤ Ct) (hδout : 0 < δout) (hQ : 0 ≤ Q) : + let degree := fun a => (selected a).1.val + 1 + let height := fun a => basisAxisScale (basis (selected a).1) (selected a).2 + let denom := fun a => inactiveDenominator (principalProfileSize (R (selected a).1) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (selected a).1 (selected a).2))) + let torus := fun a => blockTorusFactor (Fintype.card Empty) (degree a) + (Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) 1 + let V := fun a => (torus a : ℝ) * ((denom a : ℝ) * 2 ^ degree a) / δ ^ degree a + let cap := fun a => uniformSpectrumAbsoluteCap (selected a).1.val 1 (degree a) P (V a) (V a) + let cutoff := fun a => max (allocatedSlicedGridHeightCutoff (G := G) B (R := R) + (selected a).1 (selected a).2 (Nat.ceil ((q : ℝ) / δ))) + (denom a * 2 ^ degree a * Hchild ^ degree a + 2 * denom a) + let R0 := fun a => (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (degree a)) : ℝ) * + R (selected a).1 + let ε := uniformProductAccuracy (Fintype.card A) Cactual δout / 2 + let ζ := fun a => uniformBlockRetainedBias (selected a).1.val 1 (degree a) P (V a) (V a) ε + let freq := fun a => Real.toNNReal (uniformScaledRetainedFrequencyBound (selected a).1.val 1 P (V a) (ζ a)) + (∀ a, max (cutoff a : ℝ) (cap a) ≤ Cactual) → + (∀ a, R0 a + 1 / 4 ≤ Real.exp Q) → + (∀ a, (ε / (cap a + 1))⁻¹ ≤ Real.exp Q) → + (∀ a, (CircleFourier.characterLipConstant * freq a + 4 : ℝ≥0) ≤ Real.exp Q) → + (∀ a, (cutoff a : ℝ) ≤ Real.exp Q) → + (∀ a, (2 * (cutoff a : ℝ≥0) ^ 2 * (cutoff a : ℝ≥0) : ℝ≥0) ≤ Real.exp Q) → + ε⁻¹ ≤ Real.exp Q → + (∀ a, max ((uniformSpectrumSizeConstant (selected a).1.val 1 (degree a) P (V a) (V a) / + ε ^ max (majorArcSpectrumExponent (selected a).1.val 1) + (majorArcLengthExponent (selected a).1.val * degree a)) * Real.exp (4 * Q + 8)) + (Real.exp (4 * Q + 8)) ≤ Nt) → + (∀ a, max (uniformScaledRetainedDenominatorBound (selected a).1.val 1 (degree a) P + (V a) (V a) (ζ a)) 1 ≤ Vt) → + (∀ a, max (cap a * Real.exp (4 * Q + 8 + Q)) (Real.exp (4 * Q + 8 + Q)) ≤ Ct) → + (⟨Real.exp (1 + 6 * Q + 12), Real.exp_nonneg _⟩ + 4 : ℝ≥0) ≤ Lt → + (∀ a, R0 a + 1 / 4 ≤ Ht) → + let p := principalTupleWeights (α := Empty) B (layerSamplerDegree I n) H hH + let Pos := {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q // + 0 < p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))} + let w := fun r : Pos => (p.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r.val)) : ℂ) * + coefficient (progressionPrincipalResidue B (layerSamplerDegree I n) step c q r.val) + ∃ e : Pos → A → ScalarSiteExpansion.{0,0} (Finset Empty), + (∀ r a, (e r a).Bounds Nt Vt Ct Lt Ht) ∧ + (∑ t : Σ r : Pos, ∀ a, (e r a).Term, ‖forecastSiteMixtureCoefficient e w t‖) ≤ Ct ^ Fintype.card A ∧ + ∀ (x : G → IntegerScalarCubeBox Empty S.value) (z : A → ℤ), + ‖((∏ a, (height a : ℝ)) : ℂ) * + (principalAffineIntervalLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) H step c hinside hH).complexMean (fun y => coefficient (principalResidueLabel q y) * + (if forecastInactiveFixedOutput B U basis S selected coefficients x y = (fun a _ => z a) + then 1 else 0)) - + (∑ r : Pos, w r * siteFamilyEval (e r) (fun _ => z) + (fun _ a => (z a : ℝ) / height a))‖ ≤ δout := by + intro degree height denom torus V cap cutoff R0 ε ζ freq + hactual hRQ hεQ hLQ hKQ hKLQ hεinvQ hNt hVt hCt hLt hHt p Pos w + have hsubset : ∀ t, integerProgressionSupport (c t) (step t : ℤ) (H t) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U basis S t : ℤ) := + fun t => integerProgressionSupport_subset_of_fin _ _ _ _ (hinside t) + rw [principalAffineIntervalLaw_eq_contained B (layerSamplerDegree I n) H hH + (allocatedPrincipalSides B U basis S) step c (allocatedPrincipalSides_pos B U basis S) hinside hsubset] + exact exists_forecastInactive_sliced_fixed_residue_site B U basis hR hσ S q H step c hH hsubset + selected hselected coefficient hcoefficient δ P Hchild hδ hreg hsmall hgrid coefficients hcoefficients + hσ1 L hL hP hsP hstride hB Cactual δout Q Nt Vt Ct Ht Lt hCactual hCtNonneg hδout hQ + hactual hRQ hεQ hLQ hKQ hKLQ hεinvQ hNt hVt hCt hLt hHt + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ForecastInactiveResidueApproximation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastInactiveResidueApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab0754ee920fee4fd69a2badc0f97fe272769739 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastInactiveResidueApproximation.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedOriginalSampleResidueMixtureForecast +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveProduct + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {A : Type*} [Fintype A] + +attribute [local instance] ScalarSiteExpansion.termFinite + +theorem exists_forecast_inactive_residue_site + (selected : A → Σ j : Fin m, Fin (n j)) + (hselected : Function.Injective selected) + [∀ a, Nonempty (B ⟨(selected a).1, Sum.inr (selected a).2⟩)] + (q : ℕ) [NeZero q] + (coefficient : (PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q) → ℂ) + (hcoefficient : ∀ r, ‖coefficient r‖ ≤ 1) + {D P p v δ E : ℝ} + (hD : AllocatedComparisonDimensions (G := G) B Empty + (fun _ : Fin m => ((Finset.univ : Finset (Finset Empty)) : Type)) D) + (hP : 1 ≤ P) (hp : 0 ≤ p) (hv : 0 ≤ v) + (hPp : P ≤ Real.exp p) (hqv : (q : ℝ) ≤ Real.exp v) + (hδ : 0 < δ) (hE : 0 ≤ E) + (hδE : δ⁻¹ ≤ Real.exp E) + (hsize : q ≤ S.value) (hR1 : ∀ a, R (selected a).1 ≤ 1) + (hsmall : ∀ a, basisAxisScale (b (selected a).1) (selected a).2 ≤ + S.value ^ ((selected a).1.val + 1)) + (hgrid : ∀ a, allocatedGridAxis (I := I) U b S.value + ⟨(selected a).1, Sum.inr (selected a).2⟩) + (hσ1 : ∀ a, σ (selected a).1 ≤ 1) + (L : ℝ≥0) (hL : LipschitzWith L Real.smoothTransition) + (hprimitive : scalarCubePrimitiveEnvelope Empty L 1 0 q ≤ P) + (hB : ∀ a, uniformSpectrumBlockCount (selected a).1.val 1 ((selected a).1.val + 1) ≤ + Fintype.card (B ⟨(selected a).1, Sum.inr (selected a).2⟩)) : + let law := principalTupleWeights (α := Empty) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let Pos := {r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option Empty → ZMod q // + 0 < law.mass (Finset.univ.filter (fun y => principalResidueLabel q y = r))} + let scale := fun a => allocatedPrincipalGridScale (G := G) B U b (R := R) + (selected a).1 (selected a).2 + let O := allocatedInactiveJointSiteLog m D p v E + ∃ e : Pos → A → ScalarSiteExpansion.{0,0} (Finset Empty), + (∀ r a, (e r a).Bounds (Real.exp O) (Real.exp O) (Real.exp O) + ⟨Real.exp O, Real.exp_nonneg _⟩ (Real.exp (allocatedInactiveSupportLog D))) ∧ + (∑ t : Σ r, ∀ a, (e r a).Term, ‖forecastSiteMixtureCoefficient e + (fun r => (law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val)) : ℂ) * coefficient r.val) t‖) + ≤ Real.exp (Fintype.card A * O) ∧ + ∀ (x : G → IntegerScalarCubeBox Empty S.value) (z : A → ℤ), + ‖((∏ a, (scale a : ℝ)) : ℂ) * + law.complexMean (fun y => coefficient (principalResidueLabel q y) * + ((forecastInactivePhysicalJointKernel B U b hR hσ S selected + (fun _ => Finset.univ) x y (fun a _ => z a)).toReal : ℂ)) - + (∑ r : Pos, (law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val)) : ℂ) * coefficient r.val * + siteFamilyEval (e r) (fun _ => z) (fun _ a => (z a : ℝ) / scale a))‖ ≤ δ := by + intro law Pos scale O + have heach (r : Pos) := exists_forecast_inactive_product_site B U b S hR hσ + selected hselected q (NeZero.pos q) r.val hD hP hp hv hPp hqv hδ hE hδE + hsize hR1 hsmall r.property hgrid hσ1 L hL hprimitive hB + choose e he herr using heach + have hmass : (∑ r : Pos, law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val))) ≤ 1 := + (forecastInactive_positiveResidue_mass_sum law (principalResidueLabel q)).le + let w (r : Pos) := law.mass (Finset.univ.filter + (fun y => principalResidueLabel q y = r.val)) + have hw (r : Pos) : 0 ≤ w r := law.mass_nonneg _ + refine ⟨e, he, ?_, ?_⟩ + · have hm := forecastSiteMixture_weighted_mass e he + (fun _ => Real.exp_nonneg O) w (fun r => coefficient r.val) hw hmass + (fun r => hcoefficient r.val) + simpa only [Finset.prod_const, Finset.card_univ, Real.exp_nat_mul] using hm + · intro x z + let μ (r : Pos) : ℂ := (((∏ a, (scale a : ℝ)) * + (allocatedSupportedPhysicalJointPMF B U b hR hσ S q r.val r.property selected + (fun _ => Finset.univ) x (fun a _ => z a)).toReal : ℝ) : ℂ) + have herr' := forecastSiteMixture_weighted_error e w (fun r => coefficient r.val) μ + hw hmass (fun r => hcoefficient r.val) (fun _ => z) + (fun _ a => (z a : ℝ) / scale a) hδ.le (fun r => herr r x z) + have hdis := forecastInactive_physical_kernel_disintegration B U b hR hσ S selected + (fun _ => (Finset.univ : Finset (Finset Empty))) x q coefficient (fun a _ => z a) + change law.complexMean _ = _ at hdis + rw [hdis, Finset.mul_sum] + have heq : (∑ r : Pos, ((∏ a, (scale a : ℝ)) : ℂ) * + ((w r : ℂ) * coefficient r.val * + ((allocatedSupportedPhysicalJointPMF B U b hR hσ S q r.val r.property selected + (fun _ => Finset.univ) x (fun a _ => z a)).toReal : ℂ))) = + ∑ r : Pos, (w r : ℂ) * coefficient r.val * μ r := by + apply Finset.sum_congr rfl + intro r _ + dsimp only [μ] + push_cast + ring + rw [heq] + exact herr' + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ForecastIntegerAxisSplit.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastIntegerAxisSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed57e50a7ed519ccebe97a2b28996da3bf9a39fd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastIntegerAxisSplit.lean @@ -0,0 +1,197 @@ +import Mathlib.MeasureTheory.Integral.Bochner.SumMeasure +import Mathlib.MeasureTheory.Integral.Prod +import OAI.Combinatorics.Progressions.Estimates.AllocatedOriginalSampleQuadratureUniformBounds + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {n : Fin m → ℕ} +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + +def AllocatedActiveIntegerAxis (L : ℕ) := + {a : Σ j : Fin m, Fin (n j) // L ^ (a.1.val + 1) < basisAxisScale (basis a.1) a.2} + +noncomputable instance (L : ℕ) : Fintype (AllocatedActiveIntegerAxis U basis L) := + inferInstanceAs (Fintype {a : Σ j : Fin m, Fin (n j) // + L ^ (a.1.val + 1) < basisAxisScale (basis a.1) a.2}) + +noncomputable def allocatedActiveIntegerGridScale (R : Fin m → ℝ) (L : ℕ) + (a : AllocatedActiveIntegerAxis U basis L) : ℝ := + R a.val.1 * (basisAxisScale (basis a.val.1) a.val.2 : ℝ) + +theorem allocatedActiveIntegerGridScale_pos {R : Fin m → ℝ} (hR : ∀ j, 0 < R j) + (L : ℕ) (a : AllocatedActiveIntegerAxis U basis L) : + 0 < allocatedActiveIntegerGridScale U basis R L a := + mul_pos (hR a.val.1) (Nat.cast_pos.mpr (basisAxisScale_pos _ _)) + +theorem allocatedActiveIntegerGridScale_mesh {R : Fin m → ℝ} (hR : ∀ j, 0 < R j) + {L : ℕ} (hL : 0 < L) {H q : ℝ} (hq : 0 ≤ q) (hRinv : ∀ j, (R j)⁻¹ ≤ H) + (a : AllocatedActiveIntegerAxis U basis L) : + q / allocatedActiveIntegerGridScale U basis R L a ≤ q * H / L := by + have hLR : (0 : ℝ) < L := Nat.cast_pos.mpr hL + have hpow : L ≤ L ^ (a.val.1.val + 1) := + Nat.le_self_pow (by omega) L + have hscale : (L : ℝ) ≤ basisAxisScale (basis a.val.1) a.val.2 := by + exact_mod_cast hpow.trans a.property.le + have hqR : 0 ≤ q / R a.val.1 := div_nonneg hq (hR _).le + calc + q / allocatedActiveIntegerGridScale U basis R L a = + (q / R a.val.1) / basisAxisScale (basis a.val.1) a.val.2 := by + simp only [allocatedActiveIntegerGridScale, div_div] + _ ≤ (q / R a.val.1) / L := div_le_div_of_nonneg_left hqR hLR hscale + _ ≤ q * H / L := by + apply div_le_div_of_nonneg_right _ hLR.le + simpa only [div_eq_mul_inv] using mul_le_mul_of_nonneg_left (hRinv _) hq + +variable {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +theorem allocatedActiveIntegerGrid_complex_quadrature + (hR : ∀ j, 0 < R j) {H q radius : ℝ} (hH : 0 ≤ H) (hq : 0 < q) + (hRinv : ∀ j, (R j)⁻¹ ≤ H) (hradius : 0 ≤ radius) + (hmesh : q * H / S.value ≤ 1) + (f : (AllocatedActiveIntegerAxis U basis S.value → ℝ) → ℂ) {K : ℝ≥0} + (hLip : LipschitzWith K f) (c : AllocatedActiveIntegerAxis U basis S.value → ℝ) + (hsupport : ∀ x, radius < ‖x‖ → f x = 0) : + ‖((q ^ Fintype.card (AllocatedActiveIntegerAxis U basis S.value) / + (∏ a, allocatedActiveIntegerGridScale U basis R S.value a) : ℝ) : ℂ) * + (∑' z : AllocatedActiveIntegerAxis U basis S.value → ℤ, + f (fun a => (c a + q * z a) / + allocatedActiveIntegerGridScale U basis R S.value a)) - ∫ x, f x‖ ≤ + 2 * (2 * radius + 2) ^ Fintype.card (AllocatedActiveIntegerAxis U basis S.value) * + (K : ℝ) * (q * H / S.value) := by + apply scaledRectangular_complex_quadrature f hLip c + (allocatedActiveIntegerGridScale U basis R S.value) hq + (allocatedActiveIntegerGridScale_pos U basis hR S.value) hradius + (div_nonneg (mul_nonneg hq.le hH) (Nat.cast_nonneg _)) hmesh + (fun a => allocatedActiveIntegerGridScale_mesh U basis hR S.positive hq.le hRinv a) + hsupport + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped Classical BigOperators + +variable {m : ℕ} {n : Fin m → ℕ} +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (L : ℕ) + +noncomputable def forecastIntegerAxisMerge + (short : AllocatedShortIntegerAxis U basis L → ℤ) + (active : AllocatedActiveIntegerAxis U basis L → ℤ) + (a : Σ j : Fin m, Fin (n j)) : ℤ := + if h : basisAxisScale (basis a.1) a.2 ≤ L ^ (a.1.val + 1) + then short ⟨a, h⟩ else active ⟨a, Nat.lt_of_not_ge h⟩ + +theorem forecastIntegerAxisMerge_short + (short : AllocatedShortIntegerAxis U basis L → ℤ) + (active : AllocatedActiveIntegerAxis U basis L → ℤ) + (a : AllocatedShortIntegerAxis U basis L) : + forecastIntegerAxisMerge U basis L short active a.val = short a := by + rw [forecastIntegerAxisMerge, dite_eq_left a.property] + rfl + +theorem forecastIntegerAxisMerge_active + (short : AllocatedShortIntegerAxis U basis L → ℤ) + (active : AllocatedActiveIntegerAxis U basis L → ℤ) + (a : AllocatedActiveIntegerAxis U basis L) : + forecastIntegerAxisMerge U basis L short active a.val = active a := by + rw [forecastIntegerAxisMerge, dite_eq_right (Nat.not_le.mpr a.property)] + rfl + +noncomputable def forecastIntegerAxisSplit : + ((Σ j : Fin m, Fin (n j)) → ℤ) ≃ᵐ + ((AllocatedShortIntegerAxis U basis L → ℤ) × + (AllocatedActiveIntegerAxis U basis L → ℤ)) where + toFun z := (fun a => z a.val, fun a => z a.val) + invFun z := forecastIntegerAxisMerge U basis L z.1 z.2 + left_inv z := by + funext a + dsimp only [forecastIntegerAxisMerge] + split <;> rfl + right_inv z := by + apply Prod.ext + · funext a + exact forecastIntegerAxisMerge_short U basis L z.1 z.2 a + · funext a + exact forecastIntegerAxisMerge_active U basis L z.1 z.2 a + measurable_toFun := measurable_of_countable _ + measurable_invFun := measurable_of_countable _ + +theorem forecastIntegerAxisSplit_measurePreserving : + MeasurePreserving (forecastIntegerAxisSplit U basis L) Measure.count + (Measure.count.prod Measure.count) := by + refine ⟨(forecastIntegerAxisSplit U basis L).measurable, ?_⟩ + apply Measure.ext_of_singleton + intro z + rw [Measure.map_apply (forecastIntegerAxisSplit U basis L).measurable + (measurableSet_singleton z)] + have he : (forecastIntegerAxisSplit U basis L) ⁻¹' {z} = + {(forecastIntegerAxisSplit U basis L).symm z} := by + ext x + simp only [Set.mem_preimage, Set.mem_singleton_iff] + constructor + · intro hx + apply (forecastIntegerAxisSplit U basis L).injective + rw [hx, MeasurableEquiv.apply_symm_apply] + · intro hx + rw [hx, MeasurableEquiv.apply_symm_apply] + rw [he, Measure.count_singleton, ← Set.singleton_prod_singleton, + Measure.prod_prod, Measure.count_singleton, Measure.count_singleton, one_mul] + +theorem forecastIntegerAxisSplit_integrable_iff + (f : ((Σ j : Fin m, Fin (n j)) → ℤ) → ℂ) : + Integrable (fun z => f (forecastIntegerAxisMerge U basis L z.1 z.2)) + (Measure.count.prod Measure.count) ↔ Integrable f Measure.count := by + exact ((forecastIntegerAxisSplit_measurePreserving U basis L).symm + (forecastIntegerAxisSplit U basis L)).integrable_comp_emb + (forecastIntegerAxisSplit U basis L).symm.measurableEmbedding + +theorem forecastIntegerAxisSplit_integral + (f : ((Σ j : Fin m, Fin (n j)) → ℤ) → ℂ) : + (∫ z, f z ∂Measure.count) = + ∫ z, f (forecastIntegerAxisMerge U basis L z.1 z.2) + ∂Measure.count.prod Measure.count := by + exact (((forecastIntegerAxisSplit_measurePreserving U basis L).symm + (forecastIntegerAxisSplit U basis L)).integral_comp + (forecastIntegerAxisSplit U basis L).symm.measurableEmbedding f).symm + +theorem forecastIntegerAxisSplit_integral_tsum + (f : ((Σ j : Fin m, Fin (n j)) → ℤ) → ℂ) + (hf : Integrable f Measure.count) : + (∫ z, f z ∂Measure.count) = + ∑' short : AllocatedShortIntegerAxis U basis L → ℤ, + ∑' active : AllocatedActiveIntegerAxis U basis L → ℤ, + f (forecastIntegerAxisMerge U basis L short active) := by + have hi := (forecastIntegerAxisSplit_integrable_iff U basis L f).mpr hf + rw [forecastIntegerAxisSplit_integral U basis L f, integral_prod _ hi, + integral_countable hi.integral_prod_left] + simp only [count_real_singleton, one_smul] + apply tsum_congr + intro short + have hrow := Measure.ae_count_iff.mp hi.prod_right_ae short + simpa only [count_real_singleton, one_smul] using integral_countable hrow + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ForecastJointNativeResidue.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastJointNativeResidue.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea200eb93c0be7034dc1ef7f4b9f6cfa18df47a5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastJointNativeResidue.lean @@ -0,0 +1,44 @@ +import OAI.Combinatorics.Progressions.Fourier.ForecastSpatialCharacterSplit + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (L : ℕ) +local notation "short" => allocatedShortAxis (I := I) U basis L +local notation "Out" => Sigma (AllocatedCongruenceRankOutput X E short) + +def forecastJointNativeResidue {A : Type*} + (deck : ∀ j, E j → A) (r : X ⊕ AllocatedActiveIntegerAxis U basis L → A) : Out → A + | ⟨_, .inl x⟩ => r (.inl x.val) + | ⟨j, .inr (.inl e)⟩ => deck j e + | ⟨j, .inr (.inr i)⟩ => r (.inr ⟨⟨j, i.val⟩, Nat.lt_of_not_ge i.property⟩) + +theorem forecastJointNativeResidue_integer (q : ℕ) + (u : X → ℤ) (ks : AllocatedShortIntegerAxis U basis L → ℤ) + (ka : AllocatedActiveIntegerAxis U basis L → ℤ) (deck : ∀ j, E j → ℤ) : + forecastJointNativeResidue (I := I) U basis L (fun j e => (deck j e : ZMod q)) + (Sum.elim (fun x => (u x : ZMod q)) (fun a => (ka a : ZMod q))) = + fun output => (forecastCongruenceOutput (R := ℤ) short u + (fun j => Sum.elim (fun i => forecastIntegerAxisMerge U basis L ks ka ⟨j, i⟩) + (deck j)) output : ZMod q) := by + funext output + rcases output with ⟨j, x | e | i⟩ + · rfl + · rfl + · change (ka ⟨⟨j, i.val⟩, Nat.lt_of_not_ge i.property⟩ : ZMod q) = + (forecastIntegerAxisMerge U basis L ks ka ⟨j, i.val⟩ : ZMod q) + rw [forecastIntegerAxisMerge_active U basis L ks ka ⟨⟨j, i.val⟩, Nat.lt_of_not_ge i.property⟩] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ForecastNativeResidueTest.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastNativeResidueTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6b387337af0b45e61927012f0fe988a2f11beaa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastNativeResidueTest.lean @@ -0,0 +1,204 @@ +import OAI.Combinatorics.Progressions.Fourier.ForecastSpatialCharacterSplit +import OAI.Combinatorics.Progressions.Sampling.ForecastNativePullbackBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module +open scoped Classical Matrix + +variable {m : ℕ} {X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} +variable (inactive : LayerSamplerAxis I n → Prop) + +def forecastNativeSpatialResidue (hm : 0 < m) {R : Type*} + (out : Sigma (AllocatedCongruenceRankOutput X E inactive) → R) : X → R := + fun x => out ⟨⟨0, hm⟩, .inl ⟨x, rfl⟩⟩ + +theorem forecastNativeSpatialResidue_output (hm : 0 < m) {R : Type*} + (u : X → R) (label : ∀ j, Fin (n j) ⊕ E j → R) : + forecastNativeSpatialResidue inactive hm (forecastCongruenceOutput inactive u label) = u := rfl + +theorem forecastNativeSpatialResidue_reduction (hm : 0 < m) {q d : ℕ} (hd : d ∣ q) + (u : X → ℤ) (label : ∀ j, Fin (n j) ⊕ E j → ℤ) : + zmodPiReduction hd (forecastNativeSpatialResidue inactive hm + (fun a => (forecastCongruenceOutput (R := ℤ) inactive u label a : ZMod q))) = + fun x => (u x : ZMod d) := by + funext x + exact map_intCast (ZMod.castHom hd (ZMod d)) (u x) + +noncomputable def forecastNativeSheetResidue (q : ℕ) + (frozen : ∀ j, {i : Fin (n j) // inactive ⟨j, .inr i⟩} → ℤ) + (out : Sigma (AllocatedCongruenceRankOutput X E inactive) → ZMod q) + (j : Fin m) (i : Fin (n j)) : ZMod q := + if hi : inactive ⟨j, .inr i⟩ then (frozen j ⟨i, hi⟩ : ZMod q) + else out ⟨j, .inr (.inr ⟨i, hi⟩)⟩ + +def forecastNativeFreeDeckResidue {R : Type*} + (out : Sigma (AllocatedCongruenceRankOutput X E inactive) → R) + (j : Fin m) (e : E j) : R := out ⟨j, .inr (.inl e)⟩ + +noncomputable def forecastNativeCoordinateResidue (q : ℕ) + (frozen : ∀ j, {i : Fin (n j) // inactive ⟨j, .inr i⟩} → ℤ) + (out : Sigma (AllocatedCongruenceRankOutput X E inactive) → ZMod q) + (j : Fin m) : Fin (n j) ⊕ E j → ZMod q := + Sum.elim (forecastNativeSheetResidue inactive q frozen out j) + (forecastNativeFreeDeckResidue inactive out j) + +theorem forecastNativeCoordinateResidue_output (q : ℕ) (u : X → ℤ) + (label : ∀ j, Fin (n j) ⊕ E j → ℤ) : + forecastNativeCoordinateResidue inactive q (fun j i => label j (.inl i.val)) + (fun a => (forecastCongruenceOutput (R := ℤ) inactive u label a : ZMod q)) = + fun j i => (label j i : ZMod q) := by + funext j i + cases i with + | inl i => + simp only [forecastNativeCoordinateResidue, Sum.elim_inl, forecastNativeSheetResidue] + split <;> rfl + | inr e => rfl + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] [∀ j, Fintype (E j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = + projectedIntegerLattice (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +noncomputable def forecastNativeDeckResidueMatrix (q : ℕ) [NeZero q] (j : Fin m) : + Matrix (J j) (Fin (n j) ⊕ E j) ℤ := + Classical.choose (exists_bounded_integerMap_residue_matrix + (standardLatticeCoordinates (euclideanSubspace (U j)) (bW j) (b j) (hb j)).symm.toLinearMap q) + +theorem forecastNativeDeckResidueMatrix_bounds (q : ℕ) [NeZero q] (j : Fin m) + (a : J j) (i : Fin (n j) ⊕ E j) : + 0 ≤ forecastNativeDeckResidueMatrix U b hb bW q j a i ∧ + forecastNativeDeckResidueMatrix U b hb bW q j a i < q := + (Classical.choose_spec (exists_bounded_integerMap_residue_matrix + (standardLatticeCoordinates (euclideanSubspace (U j)) (bW j) (b j) (hb j)).symm.toLinearMap q)).1 a i + +theorem forecastNativeDeckResidueMatrix_apply (q : ℕ) [NeZero q] (j : Fin m) + (label : Fin (n j) ⊕ E j → ℤ) : + integerResidueMatrix (forecastNativeDeckResidueMatrix U b hb bW q j) q *ᵥ + integerResidueMap _ q label = + integerResidueMap _ q + ((standardLatticeCoordinates (euclideanSubspace (U j)) (bW j) (b j) (hb j)).symm label) := + ((Classical.choose_spec (exists_bounded_integerMap_residue_matrix + (standardLatticeCoordinates (euclideanSubspace (U j)) (bW j) (b j) (hb j)).symm.toLinearMap q)).2 label).symm + +noncomputable def forecastNativeAmbientDeckResidue (q : ℕ) [NeZero q] + (frozen : ∀ j, {i : Fin (n j) // inactive ⟨j, .inr i⟩} → ℤ) + (out : Sigma (AllocatedCongruenceRankOutput X E inactive) → ZMod q) : + (Σ j, J j) → ZMod q := fun a => + (integerResidueMatrix (forecastNativeDeckResidueMatrix U b hb bW q a.1) q *ᵥ + forecastNativeCoordinateResidue inactive q frozen out a.1) a.2 + +theorem forecastNativeAmbientDeckResidue_output (q : ℕ) [NeZero q] + (u : X → ℤ) (sheet : ∀ j, Fin (n j) → ℤ) (deck : ∀ j, E j → ℤ) : + forecastNativeAmbientDeckResidue inactive U b hb bW q (fun j i => sheet j i.val) + (fun a => (forecastCongruenceOutput (R := ℤ) inactive u (fun j => Sum.elim (sheet j) (deck j)) a : ZMod q)) = + fun a : Σ j, J j => + (latticeDeckInteger (euclideanSubspace (U a.1)) (bW a.1) (b a.1) (hb a.1) + (sheet a.1) (deck a.1) a.2 : ZMod q) := by + unfold forecastNativeAmbientDeckResidue + have hcoord := forecastNativeCoordinateResidue_output inactive q u + (fun j => Sum.elim (sheet j) (deck j)) + simp only [Sum.elim_inl] at hcoord + simp only [hcoord] + funext a + exact congrFun (forecastNativeDeckResidueMatrix_apply U b hb bW q a.1 + (Sum.elim (sheet a.1) (deck a.1))) a.2 + +theorem forecastNativeAmbientDeckResidue_reduction (q : ℕ) [NeZero q] + {d : ℕ} (hd : d ∣ q) (u : X → ℤ) + (sheet : ∀ j, Fin (n j) → ℤ) (deck : ∀ j, E j → ℤ) : + zmodPiReduction hd + (forecastNativeAmbientDeckResidue inactive U b hb bW q (fun j i => sheet j i.val) + (fun a => (forecastCongruenceOutput (R := ℤ) inactive u + (fun j => Sum.elim (sheet j) (deck j)) a : ZMod q))) = + fun a : Σ j, J j => + (latticeDeckInteger (euclideanSubspace (U a.1)) (bW a.1) (b a.1) (hb a.1) + (sheet a.1) (deck a.1) a.2 : ZMod d) := by + rw [forecastNativeAmbientDeckResidue_output] + funext a + exact map_intCast (ZMod.castHom hd (ZMod d)) _ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module +open scoped Classical NNReal +variable {m : ℕ} {X : Type*} [Fintype X] +variable {I E : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] +variable {n : Fin m → ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (R : Fin m → ℝ) (P : LayerSamplerAxis I n → Prop) [DecidablePred P] +local notation "Out" => Sigma (AllocatedCongruenceRankOutput X E P) +local notation "Output" => (Σ _a : {a : LayerSamplerAxis I n // ¬P a}, Unit) +local notation "Domain" => (((Σ _ : X, Unit ⊕ Empty) → ℝ) × (Output → ℝ)) + +namespace NormalizedPolynomialTwist +variable {periodCap coverCap : ℝ} {L : ℝ≥0} +variable (W : NormalizedPolynomialTwist X (Σ j, J j) periodCap coverCap L) + +noncomputable def forecastResidueTest (q : ℕ) [NeZero q] (hm : 0 < m) + (hperiod : W.modulus ∣ q) (hcover : W.cover ∣ q) + (sheet : ∀ j, {i : Fin (n j) // P ⟨j, .inr i⟩} → ℤ) + (frozen : {a : LayerSamplerAxis I n // P a} → ℝ) + (center : X → ℝ) (τ : ℝ) (out : Out → ZMod q) : Domain → ℂ := + W.forecastPullback U b o R P + (zmodPiReduction hperiod (forecastNativeSpatialResidue P hm out)) + (zmodPiReduction hcover (forecastNativeAmbientDeckResidue P U b hb bW q sheet out)) + center τ frozen + +theorem forecastResidueTest_bounds (q : ℕ) [NeZero q] (hm : 0 < m) + (hperiod : W.modulus ∣ q) (hcover : W.cover ∣ q) + (sheet : ∀ j, {i : Fin (n j) // P ⟨j, .inr i⟩} → ℤ) + (frozen : {a : LayerSamplerAxis I n // P a} → ℝ) + (center : X → ℝ) (τ : ℝ) (out : Out → ZMod q) : + (∀ y, ‖W.forecastResidueTest U b hb o bW R P q hm hperiod hcover sheet frozen center τ out y‖ ≤ 1) ∧ + LipschitzWith (L * max ‖τ / 8‖₊ (forecastNativeAmbientLip U b o R)) + (W.forecastResidueTest U b hb o bW R P q hm hperiod hcover sheet frozen center τ out) := + ⟨W.forecastPullback_norm_le U b o R P _ _ center τ frozen, + W.forecastPullback_lipschitz U b o R P _ _ center τ frozen⟩ + +theorem forecastResidueTest_eq_eval (q : ℕ) [NeZero q] (hm : 0 < m) + (hperiod : W.modulus ∣ q) (hcover : W.cover ∣ q) + (hR : ∀ j, R j ≠ 0) (base u : X → ℤ) (N : X → ℕ) (hN : ∀ x, 0 < N x) + {τ : ℝ} (hτ : τ ≠ 0) + (w : ∀ j, (I j → ℝ) × (Fin (n j) → ℤ)) (deck : ∀ j, E j → ℤ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hmem : ∀ j a, coefficients (poly j) a ∈ U j) + (hchart : let _ : NeZero W.cover := ⟨W.cover_pos.ne'⟩ + ∀ j, BooleanCubeKernel.physicalSingleSiteValue U W.cover poly hmem (fun x => (u x : ℝ)) j () = + normalizedCoveredChart (euclideanSubspace (U j)) (b j) (hb j) (bW j) W.cover + (orthonormalMixedChart (o j) (w j), integerResidueMap (E j) W.cover (deck j))) : + W.forecastResidueTest U b hb o bW R P q hm hperiod hcover + (fun j i => (w j).2 i.val) + (fun a => allocatedFullMixedSiteValue (R := R) U b w a.val) + (fun x => (base x : ℝ) / N x) τ + (fun a => (forecastCongruenceOutput (R := ℤ) P u + (fun j => Sum.elim (w j).2 (deck j)) a : ZMod q)) + ((fun a => ((u a.1 : ℝ) - base a.1) / (τ * N a.1 / 8)), + fun a : Output => allocatedFullMixedSiteValue (R := R) U b w a.1.val) = + W.eval N poly u := by + unfold forecastResidueTest + rw [forecastNativeSpatialResidue_reduction, forecastNativeAmbientDeckResidue_reduction] + exact W.forecastPullback_eval_of_chart U b o R P hR base u N hN hτ hb bW w deck poly hmem hchart + +end NormalizedPolynomialTwist +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ForecastOriginalSampleResidueFactor.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastOriginalSampleResidueFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..b362fe8fb445459a03815a164c43a069e42eb3d3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ForecastOriginalSampleResidueFactor.lean @@ -0,0 +1,368 @@ +import OAI.Combinatorics.Progressions.Fourier.ForecastSpatialCharacterSplit +import OAI.Combinatorics.Progressions.Sampling.ForecastNativePullbackBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical NNReal BigOperators + +variable {m : ℕ} {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (P : LayerSamplerAxis I n → Prop) +variable {A Y Site : Type*} [Fintype A] [Fintype Y] +variable (selected : A → Σ j : Fin m, Fin (n j)) (R : Fin m → ℝ) +variable (e : A → ScalarSiteExpansion Site) (k : ∀ a, (e a).Term) (site : Site) +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (M : ℕ) (hd : ∀ a, (e a).period (k a) ∣ M) + +noncomputable def forecastNormalizedResidues + (label : ∀ j, Fin (n j) ⊕ E j → ZMod M) : ∀ a, ZMod ((e a).period (k a)) := + fun a => ZMod.castHom (hd a) (ZMod ((e a).period (k a))) + (label (selected a).1 (.inl (selected a).2)) + +noncomputable def forecastNormalizedResidueFactor + (ψ : AddChar (∀ j, Fin (n j) ⊕ E j → ZMod M) ℂ) + (f : (Y → ℝ) × ((Σ _a : {a : LayerSamplerAxis I n // ¬P a}, Unit) → ℝ) → ℂ) + (label : ∀ j, Fin (n j) ⊕ E j → ZMod M) + (x : (Y → ℝ) × (LayerSamplerAxis I n → ℝ)) : ℂ := + star (ψ label) * f (x.1, forecastNormalizedActiveCoordinates P x.2) * + siteFamilyFactor e k site (forecastNormalizedResidues selected e k M hd label) + (forecastNormalizedInactiveCoordinates selected R x.2) + +theorem forecastNormalizedResidueFactor_bounds [NeZero M] + (ψ : AddChar (∀ j, Fin (n j) ⊕ E j → ZMod M) ℂ) + (f : (Y → ℝ) × ((Σ _a : {a : LayerSamplerAxis I n // ¬P a}, Unit) → ℝ) → ℂ) + {Lf Lsite : ℝ≥0} (hf : ∀ x, ‖f x‖ ≤ 1) (hLf : LipschitzWith Lf f) + {Tsite Dsite Csite Hsite : A → ℝ} + (he : ∀ a, (e a).Bounds (Tsite a) (Dsite a) (Csite a) Lsite (Hsite a)) + (hR : ∀ a, |R (selected a).1| ≤ 1) + (label : ∀ j, Fin (n j) ⊕ E j → ZMod M) : + (∀ x, ‖forecastNormalizedResidueFactor P selected R e k site M hd ψ f label x‖ ≤ 1) ∧ + LipschitzWith (Lf + Fintype.card A * Lsite) + (forecastNormalizedResidueFactor P selected R e k site M hd ψ f label) := by + let F := fun x : (Y → ℝ) × (LayerSamplerAxis I n → ℝ) => + star (ψ label) * f (x.1, forecastNormalizedActiveCoordinates P x.2) + let g := fun x : (Y → ℝ) × (LayerSamplerAxis I n → ℝ) => + siteFamilyFactor e k site (forecastNormalizedResidues selected e k M hd label) + (forecastNormalizedInactiveCoordinates selected R x.2) + have hphase : ‖star (ψ label)‖ = 1 := by + rw [norm_star, AddChar.norm_apply] + have hactive : LipschitzWith 1 (fun x : (Y → ℝ) × (LayerSamplerAxis I n → ℝ) => + (x.1, forecastNormalizedActiveCoordinates P x.2)) := by + simpa only [Function.comp_def, one_mul, max_self] using + (LipschitzWith.prod_fst (α := Y → ℝ) (β := LayerSamplerAxis I n → ℝ)).prodMk + ((forecastNormalizedActiveCoordinates_lipschitz P).comp LipschitzWith.prod_snd) + have hFL : LipschitzWith Lf F := by + have hcomp : LipschitzWith Lf (fun x : (Y → ℝ) × (LayerSamplerAxis I n → ℝ) => + f (x.1, forecastNormalizedActiveCoordinates P x.2)) := by + simpa only [mul_one, Function.comp_def] using hLf.comp hactive + apply LipschitzWith.of_dist_le_mul + intro x y + change dist (star (ψ label) * _) (star (ψ label) * _) ≤ _ + rw [dist_eq_norm, ← mul_sub, norm_mul, hphase, one_mul] + simpa only [dist_eq_norm] using hcomp.dist_le_mul x y + have hFb : ∀ x, ‖F x‖ ≤ 1 := by + intro x + change ‖star (ψ label) * _‖ ≤ 1 + rw [norm_mul, hphase, one_mul] + exact hf _ + obtain ⟨hgb, hgL⟩ := siteFamilyFactor_bounds e he k site + (forecastNormalizedResidues selected e k M hd label) + have hinactive : LipschitzWith 1 (fun x : (Y → ℝ) × (LayerSamplerAxis I n → ℝ) => + forecastNormalizedInactiveCoordinates selected R x.2) := by + simpa only [one_mul, Function.comp_def] using + (forecastNormalizedInactiveCoordinates_lipschitz selected R hR).comp + (LipschitzWith.prod_snd (α := Y → ℝ) (β := LayerSamplerAxis I n → ℝ)) + have hg : LipschitzWith (Fintype.card A * Lsite) g := by + simpa only [mul_one, Function.comp_def] using hgL.comp hinactive + have hgn : ∀ x, ‖g x‖ ≤ 1 := fun x => hgb _ + constructor + · intro x + change ‖F x * g x‖ ≤ 1 + rw [norm_mul] + exact (mul_le_mul (hFb x) (hgn x) (norm_nonneg _) zero_le_one).trans_eq (one_mul 1) + · apply LipschitzWith.of_dist_le_mul + intro x y + have hh := (lipschitz_mul_of_bounds + (X := (Y → ℝ) × (LayerSamplerAxis I n → ℝ)) + F g hFL hg (Bf := 1) (Bg := 1) hFb hgn).dist_le_mul x y + simpa only [one_mul, add_comm, F, g, forecastNormalizedResidueFactor] using hh + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + +omit [∀ j, Fintype (I j)] [Fintype Y] [∀ j, Fintype (E j)] in + +theorem forecastNormalizedResidueFactor_mixed + (ψ : AddChar (∀ j, Fin (n j) ⊕ E j → ZMod M) ℂ) + (f : (Y → ℝ) × ((Σ _a : {a : LayerSamplerAxis I n // ¬P a}, Unit) → ℝ) → ℂ) + (hR : ∀ j, R j ≠ 0) + (w : ∀ j, (I j → ℝ) × (Fin (n j) → ℤ)) (deck : ∀ j, E j → ℤ) (y : Y → ℝ) : + forecastNormalizedResidueFactor P selected R e k site M hd ψ f + (fun j => Sum.elim (fun i => ((w j).2 i : ZMod M)) (fun a => (deck j a : ZMod M))) + (y, allocatedFullMixedSiteValue (R := R) U b w) = + star (ψ (fun j => Sum.elim (fun i => ((w j).2 i : ZMod M)) (fun a => (deck j a : ZMod M)))) * + f (y, forecastNormalizedActiveCoordinates P (allocatedFullMixedSiteValue (R := R) U b w)) * + siteFamilyFactor e k site + (fun a => ((w (selected a).1).2 (selected a).2 : ZMod ((e a).period (k a)))) + (fun a => ((w (selected a).1).2 (selected a).2 : ℝ) / + basisAxisScale (b (selected a).1) (selected a).2) := by + unfold forecastNormalizedResidueFactor forecastNormalizedResidues + simp only [Sum.elim_inl, map_intCast] + rw [forecastNormalizedInactiveCoordinates_mixed selected R U b hR w] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical NNReal + +theorem forecastDensity_normalized_bounds {Y : Type*} [PseudoMetricSpace Y] + (density : Y → ℝ) (C L : ℝ≥0) (hbound : ∀ y, |density y| ≤ (C : ℝ)) + (hLips : LipschitzWith L density) : + let F := fun y => (density y : ℂ) / (((C : ℝ) + 1 : ℝ) : ℂ) + (∀ y, ‖F y‖ ≤ 1) ∧ LipschitzWith L F ∧ + (∀ y, (density y : ℂ) = (((C : ℝ) + 1 : ℝ) : ℂ) * F y) := by + intro F + have hpos : (0 : ℝ) < C + 1 := by positivity + have hden : ‖(((C : ℝ) + 1 : ℝ) : ℂ)‖ = (C : ℝ) + 1 := by + rw [Complex.norm_real, Real.norm_of_nonneg hpos.le] + refine ⟨?_, ?_, ?_⟩ + · intro y + change ‖(density y : ℂ) / (((C : ℝ) + 1 : ℝ) : ℂ)‖ ≤ 1 + rw [norm_div, hden, Complex.norm_real, Real.norm_eq_abs] + exact (div_le_one hpos).mpr ((hbound y).trans (by linarith)) + · apply LipschitzWith.of_dist_le_mul + intro x y + change dist ((density x : ℂ) / (((C : ℝ) + 1 : ℝ) : ℂ)) + ((density y : ℂ) / (((C : ℝ) + 1 : ℝ) : ℂ)) ≤ (L : ℝ) * dist x y + rw [dist_eq_norm, ← sub_div, norm_div, ← Complex.ofReal_sub, Complex.norm_real, hden] + have hd := hLips.dist_le_mul x y + rw [dist_eq_norm] at hd + exact (div_le_self (norm_nonneg _) (by linarith [C.coe_nonneg] : (1 : ℝ) ≤ C + 1)).trans hd + · intro y + change (density y : ℂ) = (((C : ℝ) + 1 : ℝ) : ℂ) * + ((density y : ℂ) / (((C : ℝ) + 1 : ℝ) : ℂ)) + rw [mul_div_cancel₀ _ (Complex.ofReal_ne_zero.mpr hpos.ne')] + +variable {m : ℕ} {G X Spatial : Type*} [Fintype G] [Fintype X] [Fintype Spatial] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "Output" => (Σ _a : Active, Unit) + +include hR in +theorem exists_forecastDensityResidueFactor + (density : ((Spatial → ℝ) × (Output → ℝ)) → ℝ) + (C L : ℝ≥0) (hbound : ∀ y, |density y| ≤ (C : ℝ)) + (hLips : LipschitzWith L density) + {A Site : Type*} [Fintype A] + {Eout : Fin m → Type*} [∀ j, Fintype (Eout j)] + (selected : A → Σ j : Fin m, Fin (n j)) + (hR1 : ∀ a, R (selected a).1 ≤ 1) + {N : ℕ} [NeZero N] + (χ : AddChar (Sigma (AllocatedCongruenceRankOutput X Eout short) → ZMod N) ℂ) + (M : ℕ) [NeZero M] (hM : orderOf χ ∣ M) + (e : A → ScalarSiteExpansion Site) + {Tsite Dsite Csite Hsite : A → ℝ} {Lsite : ℝ≥0} + (he : ∀ a, (e a).Bounds (Tsite a) (Dsite a) (Csite a) Lsite (Hsite a)) + (k : ∀ a, (e a).Term) (site : Site) + (hd : ∀ a, (e a).period (k a) ∣ M) : + ∃ mask : AddChar (X → ZMod M) ℂ, + ∃ F : (∀ j, Fin (n j) ⊕ Eout j → ZMod M) → + ((Spatial → ℝ) × (LayerSamplerAxis I n → ℝ)) → ℂ, + (∀ u, ‖mask u‖ = 1) ∧ + (∀ label y, ‖F label y‖ ≤ 1) ∧ + (∀ label, LipschitzWith (L + Fintype.card A * Lsite) (F label)) ∧ + ∀ (u : X → ℤ) (deck : ∀ j, Eout j → ℤ) + (w : ∀ j, (I j → ℝ) × (Fin (n j) → ℤ)) (y : Spatial → ℝ), + (density (y, forecastNormalizedActiveCoordinates short + (allocatedFullMixedSiteValue (R := R) U basis w)) : ℂ) * + star (χ (fun o => (forecastCongruenceOutput (R := ℤ) short u + (fun j => Sum.elim (w j).2 (deck j)) o : ZMod N))) * + siteFamilyFactor e k site + (fun a => ((w (selected a).1).2 (selected a).2 : ZMod ((e a).period (k a)))) + (fun a => ((w (selected a).1).2 (selected a).2 : ℝ) / + basisAxisScale (basis (selected a).1) (selected a).2) = + (((C : ℝ) + 1 : ℝ) : ℂ) * star (mask (fun x => (u x : ZMod M))) * + F (fun j => Sum.elim (fun i => ((w j).2 i : ZMod M)) + (fun i => (deck j i : ZMod M))) + (y, allocatedFullMixedSiteValue (R := R) U basis w) := by + let normalized := fun z => (density z : ℂ) / (((C : ℝ) + 1 : ℝ) : ℂ) + have hb := forecastDensity_normalized_bounds density C L hbound hLips + obtain ⟨mask, coeff, hmask, hcoeff, heq, hstar⟩ := + exists_forecastSpatialCharacterSplit short χ M hM + let F := forecastNormalizedResidueFactor short selected R e k site M hd coeff (normalized) + have hRabs : ∀ a, |R (selected a).1| ≤ 1 := fun a => by + rw [abs_of_pos (hR (selected a).1)] + exact hR1 a + have hF := forecastNormalizedResidueFactor_bounds short selected R e k site M hd coeff + (normalized) hb.1 hb.2.1 he hRabs + refine ⟨mask, F, hmask, ?_, ?_, ?_⟩ + · intro label y + exact (hF label).1 y + · intro label + exact (hF label).2 + · intro u deck w y + dsimp only [F] + rw [forecastNormalizedResidueFactor_mixed short selected R e k site M hd U basis coeff + (normalized) (fun j => (hR j).ne') w deck y] + have hlabels : (fun j i => ((Sum.elim (w j).2 (deck j) i : ℤ) : ZMod M)) = + (fun j => Sum.elim (fun i => ((w j).2 i : ZMod M)) + (fun i => (deck j i : ZMod M))) := by + funext j i + cases i <;> rfl + rw [hb.2.2, hstar, hlabels] + ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G X Zsp : Type*} [Fintype G] [Fintype X] + [Fintype Zsp] [DecidableEq Zsp] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable (s : Empty ↪ Zsp) (root : Zsp → ℤ) (D : Matrix Empty Zsp ℤ) + (hp : (selectedSpatialPivot root D s).det ≠ 0) + {W L : ℝ} (hW : 0 ≤ W) (hL : 0 < L) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Active" => {a : LayerSamplerAxis I n // ¬short a} +local notation "Sample" => CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n +local notation "Output" => (Σ _a : Active, Unit) +local notation "Spatial" => (Σ _ : X, Unit ⊕ Empty) +local notation "Domain" => ((Spatial → ℝ) × (Output → ℝ)) +local notation "noise" => allocatedSampleRestrictedProfileNoise B U basis S short +local notation "hamin" => unitProfilePrincipalLowerBound_pos B + +variable (hB : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis (I := I) U basis S.value a}, + 4 ≤ Fintype.card (B a.val)) + (lower width : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis (I := I) U basis S.value a}, + B a.val × Fin (layerSamplerDegree I n a.val) → ℝ) + {δ : ℝ} (hδ : 0 < δ) + (hw : ∀ a p, δ ≤ width a p) (hl : ∀ a p, 0 ≤ lower a p) + +local notation "density" => allocatedOriginalSampleForecastDensity (X := X) + B U basis S s root D hp hW hL hB lower width +local notation "cap" => allocatedOriginalForecastCap (X := X) B U basis S s hδ +local notation "lip" => allocatedOriginalForecastLip (X := X) B U basis S s hδ + +local notation "normalized" => allocatedOriginalSampleNormalizedForecast (X := X) + B U basis S s root D hp hW hL hB lower width hδ + +include hR hσ hw hl in + +theorem allocatedOriginalSampleNormalizedForecast_supported_bounds + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (hroot : ∀ j, |(root j : ℝ)| ≤ 1 + W) : + (∀ y, ‖normalized sample y‖ ≤ 1) ∧ LipschitzWith lip (normalized sample) ∧ + (∀ y, (density sample y : ℂ) = (((cap : ℝ) + 1 : ℝ) : ℂ) * normalized sample y) := by + exact allocatedFixedPathForecastDensity_normalized_bounds (X := X) + B short R σ s root D hp hW hL (fun j => (hR j).ne') hB lower width + hamin hδ (fun a => unitProfilePrincipalLowerBound_le B a.val) hw hl (noise sample) + (allocatedSampleRestrictedProfileNoise_short_abs_le B U basis hR hσ S sample hs) + zero_lt_one hroot (by simp only [Matrix.det_isEmpty, abs_one, le_refl]) + +include hR hσ hw hl in + +theorem exists_forecastOriginalSampleResidueFactor + (sample : Sample) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (hroot : ∀ j, |(root j : ℝ)| ≤ 1 + W) + {A Site : Type*} [Fintype A] + {Eout : Fin m → Type*} [∀ j, Fintype (Eout j)] + (selected : A → Σ j : Fin m, Fin (n j)) + (hR1 : ∀ a, R (selected a).1 ≤ 1) + {N : ℕ} [NeZero N] + (χ : AddChar (Sigma (AllocatedCongruenceRankOutput X Eout short) → ZMod N) ℂ) + (M : ℕ) [NeZero M] (hM : orderOf χ ∣ M) + (e : A → ScalarSiteExpansion Site) + {Tsite Dsite Csite Hsite : A → ℝ} {Lsite : ℝ≥0} + (he : ∀ a, (e a).Bounds (Tsite a) (Dsite a) (Csite a) Lsite (Hsite a)) + (k : ∀ a, (e a).Term) (site : Site) + (hd : ∀ a, (e a).period (k a) ∣ M) : + ∃ mask : AddChar (X → ZMod M) ℂ, + ∃ F : (∀ j, Fin (n j) ⊕ Eout j → ZMod M) → + ((Spatial → ℝ) × (LayerSamplerAxis I n → ℝ)) → ℂ, + (∀ u, ‖mask u‖ = 1) ∧ + (∀ label y, ‖F label y‖ ≤ 1) ∧ + (∀ label, LipschitzWith (lip + Fintype.card A * Lsite) (F label)) ∧ + ∀ (u : X → ℤ) (deck : ∀ j, Eout j → ℤ) + (w : ∀ j, (I j → ℝ) × (Fin (n j) → ℤ)) (y : Spatial → ℝ), + (density sample (y, forecastNormalizedActiveCoordinates short + (allocatedFullMixedSiteValue (R := R) U basis w)) : ℂ) * + star (χ (fun o => (forecastCongruenceOutput (R := ℤ) short u + (fun j => Sum.elim (w j).2 (deck j)) o : ZMod N))) * + siteFamilyFactor e k site + (fun a => ((w (selected a).1).2 (selected a).2 : ZMod ((e a).period (k a)))) + (fun a => ((w (selected a).1).2 (selected a).2 : ℝ) / + basisAxisScale (basis (selected a).1) (selected a).2) = + (((cap : ℝ) + 1 : ℝ) : ℂ) * star (mask (fun x => (u x : ZMod M))) * + F (fun j => Sum.elim (fun i => ((w j).2 i : ZMod M)) + (fun i => (deck j i : ZMod M))) + (y, allocatedFullMixedSiteValue (R := R) U basis w) := by + have hb := allocatedOriginalSampleNormalizedForecast_supported_bounds (X := X) + B U basis hR hσ S s root D hp hW hL hB lower width hδ hw hl sample hs hroot + obtain ⟨mask, coeff, hmask, hcoeff, heq, hstar⟩ := + exists_forecastSpatialCharacterSplit short χ M hM + let F := forecastNormalizedResidueFactor short selected R e k site M hd coeff (normalized sample) + have hRabs : ∀ a, |R (selected a).1| ≤ 1 := fun a => by + rw [abs_of_pos (hR (selected a).1)] + exact hR1 a + have hF := forecastNormalizedResidueFactor_bounds short selected R e k site M hd coeff + (normalized sample) hb.1 hb.2.1 he hRabs + refine ⟨mask, F, hmask, ?_, ?_, ?_⟩ + · intro label y + exact (hF label).1 y + · intro label + exact (hF label).2 + · intro u deck w y + dsimp only [F] + rw [forecastNormalizedResidueFactor_mixed short selected R e k site M hd U basis coeff + (normalized sample) (fun j => (hR j).ne') w deck y] + have hlabels : (fun j i => ((Sum.elim (w j).2 (deck j) i : ℤ) : ZMod M)) = + (fun j => Sum.elim (fun i => ((w j).2 i : ZMod M)) + (fun i => (deck j i : ZMod M))) := by + funext j i + cases i <;> rfl + rw [hb.2.2, hstar, hlabels] + ring + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FourAffineRefinement.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FourAffineRefinement.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7507ae2170af28d149f43e32433d48eb98456d3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FourAffineRefinement.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.Progressions.Estimates.FourBalancedRelations + +namespace OAI + +section + +namespace Erdos3 + +variable {R I E : Type*} {V : I → Type*} [CommRing R] + [∀ i, AddCommGroup (V i)] [∀ i, Module R (V i)] + [AddCommGroup E] [Module R E] + +def fourFunctionDifference (f : (∀ i, V i) → E) (v : ∀ i, Fin 4 → V i) : E := + f (fun i => v i 0) + f (fun i => v i 1) - f (fun i => v i 2) - f (fun i => v i 3) + +theorem four_affine_balanced_invariant (f : (∀ i, V i) → E) (C D : ∀ i, Submodule R (V i)) + (haffine : ∀ x : ∀ i, V i, (∀ i, x i ∈ C i) → + ∃ A : (∀ i, D i) →ₗ[R] E, ∀ y : ∀ i, D i, + f (fun i => x i + (y i : V i)) = f x + A y) + (v z : ∀ i, Fin 4 → V i) (hv : ∀ i, v i ∈ fourCommonModulo (C i) (D i)) + (hz : ∀ i, z i ∈ fourBalancedDependent (D i)) : + fourFunctionDifference f (fun i k => v i k + z i k) = fourFunctionDifference f v := by + let x : ∀ i, V i := fun i => v i 0 + obtain ⟨A, hA⟩ := haffine x (fun i => ((mem_fourCommonModulo (C i) (D i) (v i)).mp (hv i)).1 0) + let y (k : Fin 4) : ∀ i, D i := fun i => + ⟨v i k - v i 0, ((mem_fourCommonModulo (C i) (D i) (v i)).mp (hv i)).2 k⟩ + let t (k : Fin 4) : ∀ i, D i := fun i => + ⟨z i k, ((mem_fourBalancedDependent (D i) (z i)).mp (hz i)).1 k⟩ + have hbase (k : Fin 4) : f (fun i => v i k) = f x + A (y k) := by + have heq : (fun i => x i + ((y k) i : V i)) = fun i => v i k := by + funext i + dsimp only [x, y] + abel + simpa only [heq] using hA (y k) + have hnew (k : Fin 4) : f (fun i => v i k + z i k) = f x + (A (y k) + A (t k)) := by + have heq : (fun i => x i + ((y k + t k) i : V i)) = fun i => v i k + z i k := by + funext i + change v i 0 + (v i k - v i 0 + z i k) = _ + abel + simpa only [heq, map_add] using hA (y k + t k) + have ht : t 0 + t 1 - t 2 - t 3 = 0 := by + funext i + apply Subtype.ext + change z i 0 + z i 1 - z i 2 - z i 3 = 0 + exact ((mem_fourBalancedDependent (D i) (z i)).mp (hz i)).2 + have hAt : A (t 0) + A (t 1) - A (t 2) - A (t 3) = 0 := by + rw [← map_add, ← map_sub, ← map_sub, ht, map_zero] + calc + _ = fourFunctionDifference f v + (A (t 0) + A (t 1) - A (t 2) - A (t 3)) := by + unfold fourFunctionDifference + rw [hnew 0, hnew 1, hnew 2, hnew 3, hbase 0, hbase 1, hbase 2, hbase 3] + abel + _ = _ := by rw [hAt, add_zero] + +theorem four_refined_affine_identity (f : (∀ i, V i) → E) (C D : ∀ i, Submodule R (V i)) + (haffine : ∀ x : ∀ i, V i, (∀ i, x i ∈ C i) → + ∃ A : (∀ i, D i) →ₗ[R] E, ∀ y : ∀ i, D i, + f (fun i => x i + (y i : V i)) = f x + A y) + (K : ∀ i, Submodule R (Fin 4 → V i)) + (hK : ∀ v : ∀ i, Fin 4 → V i, (∀ i, v i ∈ K i) → fourFunctionDifference f v = 0) + (v : ∀ i, Fin 4 → V i) (hv : ∀ i, v i ∈ fourRefinedRelation (C i) (D i) (K i)) : + fourFunctionDifference f v = 0 := by + classical + have hdecomp (i : I) : ∃ u ∈ K i ⊓ fourCommonModulo (C i) (D i), + ∃ z ∈ fourBalancedDependent (D i), u + z = v i := Submodule.mem_sup.mp (hv i) + choose u hu z hz heq using hdecomp + have hvEq : (fun i k => u i k + z i k) = v := by + funext i k + exact congrFun (heq i) k + rw [← hvEq, four_affine_balanced_invariant f C D haffine u z (fun i => (hu i).2) hz] + exact hK u (fun i => (hu i).1) + +omit [Module R E] in +theorem four_single_input_vanish (f : (∀ i, V i) → E) + (K : ∀ i, Submodule R (Fin 4 → V i)) + (hK : ∀ v : ∀ i, Fin 4 → V i, (∀ i, v i ∈ K i) → fourFunctionDifference f v = 0) + (v : ∀ i, V i) (hv : ∀ i, v i ∈ (K i).map (LinearMap.proj 0)) + (i : I) (hzero : ∀ x : ∀ i, V i, x i = 0 → f x = 0) + (hi : LinearMap.single R (fun _ : Fin 4 => V i) 0 (v i) ∈ K i) : f v = 0 := by + classical + have hlift (j : I) : ∃ w ∈ K j, w 0 = v j := hv j + choose w hw hw0 using hlift + let z : ∀ j, Fin 4 → V j := Function.update w i (LinearMap.single R (fun _ : Fin 4 => V i) 0 (v i)) + have hz (j : I) : z j ∈ K j := by + by_cases hji : j = i + · subst j; simpa only [z, Function.update_self] using hi + · simpa only [z, Function.update_of_ne hji] using hw j + have hz0 : (fun j => z j 0) = v := by + funext j + by_cases hji : j = i + · subst j; simp [z, LinearMap.single_apply] + · simpa only [z, Function.update_of_ne hji] using hw0 j + have hz1 : f (fun j => z j 1) = 0 := hzero _ (by simp [z, LinearMap.single_apply]) + have hz2 : f (fun j => z j 2) = 0 := hzero _ (by simp [z, LinearMap.single_apply]) + have hz3 : f (fun j => z j 3) = 0 := hzero _ (by simp [z, LinearMap.single_apply]) + simpa only [fourFunctionDifference, hz0, hz1, hz2, hz3, add_zero, sub_zero] using hK z hz + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FullAffineCoefficientBound.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FullAffineCoefficientBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..be099a74c1106cfcc65cac60b5dff3218cd449b8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FullAffineCoefficientBound.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.Progressions.Polynomial.JointPolynomialDilationGrid + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +noncomputable def realAxisAffinePolynomial {σ : Type*} (h r : σ → ℝ) (i : σ) : MvPolynomial σ ℝ := + C (h i) + C (r i) * X i + +noncomputable def realAxisAffinePullback {σ : Type*} (h r : σ → ℝ) : + MvPolynomial σ ℝ →+* MvPolynomial σ ℝ := + eval₂Hom C (realAxisAffinePolynomial h r) + +theorem realAxisAffinePullback_eval {σ : Type*} (h r x : σ → ℝ) (P : MvPolynomial σ ℝ) : + eval x (realAxisAffinePullback h r P) = eval (fun i => h i + r i * x i) P := by + have heq : (eval x).comp (realAxisAffinePullback h r) = eval (fun i => h i + r i * x i) := by + ext <;> simp [realAxisAffinePullback, realAxisAffinePolynomial] + exact RingHom.congr_fun heq P + +theorem realAxisAffinePullback_totalDegree_le {σ : Type*} (h r : σ → ℝ) + (P : MvPolynomial σ ℝ) : + (realAxisAffinePullback h r P).totalDegree ≤ P.totalDegree := by + have hf (i : σ) : (realAxisAffinePolynomial h r i).totalDegree ≤ 1 := by + apply (totalDegree_add _ _).trans + apply max_le + · simp + · apply (totalDegree_mul _ _).trans + simp + simpa only [realAxisAffinePullback, mul_one] using polynomial_substitution_totalDegree_le P + (realAxisAffinePolynomial h r) hf le_rfl + +theorem realAxisAffinePolynomial_mass_le {σ : Type*} (h r : σ → ℝ) (i : σ) : + realPolynomialMass (realAxisAffinePolynomial h r i) ≤ |h i| + |r i| := by + apply (realPolynomialMass_add_le _ _).trans + apply add_le_add + · exact (realPolynomialMass_C _).le + · simpa only [realPolynomialMass_X, mul_one] using realPolynomialMass_C_mul_le (r i) (X i) + +theorem scaleMvPolynomialAxes_affine {σ : Type*} (T A h r : σ → ℝ) + (hT : ∀ i, T i ≠ 0) (P : MvPolynomial σ ℝ) : + scaleMvPolynomialAxes A (realAxisAffinePullback h r P) = + realAxisAffinePullback (fun i => h i / T i) (fun i => r i * A i / T i) + (scaleMvPolynomialAxes T P) := by + apply MvPolynomial.funext + intro x + rw [scaleMvPolynomialAxes_eval, realAxisAffinePullback_eval, + realAxisAffinePullback_eval, scaleMvPolynomialAxes_eval] + apply congrArg (fun y : σ → ℝ => eval y P) + funext i + field_simp [hT i] + +theorem realAxisAffinePullback_coeff_bound {σ : Type*} + (T A h r : σ → ℝ) (hT : ∀ i, 0 < T i) (hA : ∀ i, 0 < A i) + (P : MvPolynomial σ ℝ) {M B : ℝ} {s : ℕ} (hB : 1 ≤ B) + (hcoeff : ∀ α, |P.coeff α| ≤ M / monomialScale T α) + (hphysical : ∀ i, |h i| + |r i| * A i ≤ B * T i) + (hdegree : P.totalDegree ≤ s) (α : σ →₀ ℕ) : + |(realAxisAffinePullback h r P).coeff α| ≤ + (P.support.card * M * B ^ s) / monomialScale A α := by + have hf (i : σ) : realPolynomialMass + (realAxisAffinePolynomial (fun j => h j / T j) (fun j => r j * A j / T j) i) ≤ B := by + apply (realAxisAffinePolynomial_mass_le _ _ i).trans + calc + _ = (|h i| + |r i| * A i) / T i := by + rw [abs_div, abs_div, abs_mul, abs_of_pos (hT i), abs_of_pos (hA i)] + ring + _ ≤ B := (div_le_iff₀ (hT i)).mpr (hphysical i) + have hmass : realPolynomialMass (scaleMvPolynomialAxes A (realAxisAffinePullback h r P)) ≤ + P.support.card * M * B ^ s := by + rw [scaleMvPolynomialAxes_affine T A h r (fun i => (hT i).ne')] + apply (realPolynomialMass_substitution_le (scaleMvPolynomialAxes T P) _ hB hf + ((scaleMvPolynomialAxes_totalDegree_le T P).trans hdegree)).trans + exact mul_le_mul_of_nonneg_right (scaleMvPolynomialAxes_mass_le T hT P hcoeff) + (pow_nonneg (zero_le_one.trans hB) _) + have hc := (realPolynomialMass_coeff_le (scaleMvPolynomialAxes A (realAxisAffinePullback h r P)) α).trans hmass + rw [scaleMvPolynomialAxes_coeff, abs_mul, abs_of_pos (monomialScale_pos A hA α)] at hc + exact (le_div_iff₀ (monomialScale_pos A hA α)).mpr hc + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/FullTaggedAffineComplementAgreement.lean b/lean/OAI/Combinatorics/Progressions/Lattices/FullTaggedAffineComplementAgreement.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7ef7ca78ac6aca1ca1d0476960f070fd02faf97 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/FullTaggedAffineComplementAgreement.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.Progressions.Linear.RationalTagProjectionComplement + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open _root_.MvPolynomial _root_.OAI.MvPolynomial + +variable {m : ℕ} {X : Type*} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +theorem fullTaggedAffineMapChart_eval_eq_of_complement + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X ⊕ (Σ j, J j) → ℝ) + (hvalue : ∀ j, ((LinearMap.id : (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) - P j) (fun a => x (Sum.inr ⟨j, a⟩)) = c j) + (hconstant : ∀ j, ((LinearMap.id : (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) - P j) (c j) = c j) : + (fun v => MvPolynomial.eval x (fullTaggedAffineMapChart J P c v)) = x := by + have hfixed : ∀ j y, y ∈ LinearMap.ker + ((LinearMap.id : (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) - P j) → P j y = y := by + intro j y hy + change y - P j y = 0 at hy + exact (sub_eq_zero.mp hy).symm + apply fullTaggedAffineMapChart_eval_eq_of_quotient J P c + (fun j => LinearMap.ker ((LinearMap.id : (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) - P j)) hfixed + (fun j => (LinearMap.id : (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) - P j) (fun _ => rfl) x + intro j + rw [hvalue j, hconstant j] + +theorem fullTaggedAffineMatrixChart_eval_eq_of_complement + (P : ∀ j, Matrix (J j) (J j) ℚ) (c : ∀ j, J j → ℝ) + (x : X ⊕ (Σ j, J j) → ℝ) + (hvalue : ∀ j, rationalTagProjectionComplement (P j) + (fun a => x (Sum.inr ⟨j, a⟩)) = c j) + (hconstant : ∀ j, rationalTagProjectionComplement (P j) (c j) = c j) : + (fun v => MvPolynomial.eval x + (fullTaggedAffineMapChart J (fullTaggedRealMatrixProjection J P) c v)) = x := by + exact fullTaggedAffineMapChart_eval_eq_of_complement J + (fullTaggedRealMatrixProjection J P) c x hvalue hconstant + +theorem fullTaggedAffineMatrixChart_eval_eq_of_anchor + (P : ∀ j, Matrix (J j) (J j) ℚ) (c anchor : ∀ j, J j → ℝ) + (x : X ⊕ (Σ j, J j) → ℝ) + (hdisplacement : ∀ j, rationalTagProjectionComplement (P j) + ((fun a => x (Sum.inr ⟨j, a⟩)) - anchor j) = 0) + (hanchor : ∀ j, rationalTagProjectionComplement (P j) (anchor j) = c j) + (hconstant : ∀ j, rationalTagProjectionComplement (P j) (c j) = c j) : + (fun v => MvPolynomial.eval x + (fullTaggedAffineMapChart J (fullTaggedRealMatrixProjection J P) c v)) = x := by + apply fullTaggedAffineMatrixChart_eval_eq_of_complement J P c x ?_ hconstant + intro j + have h := hdisplacement j + rw [map_sub, sub_eq_zero, hanchor j] at h + exact h + +theorem fullTaggedAffineMatrixChart_eval_eq_of_retraction_anchor + (P : ∀ j, Matrix (J j) (J j) ℚ) (V : ∀ j, Submodule ℚ (J j → ℚ)) + (hrange : ∀ j, LinearMap.range (fullTaggedRealMatrixProjection J P j) = + realRationalCoordinateSpan (V j)) + (hfix : ∀ j y, y ∈ realRationalCoordinateSpan (V j) → + fullTaggedRealMatrixProjection J P j y = y) + (anchor : ∀ j, J j → ℝ) (x : X ⊕ (Σ j, J j) → ℝ) + (hdisplacement : ∀ j, rationalTagProjectionComplement (P j) + ((fun a => x (Sum.inr ⟨j, a⟩)) - anchor j) = 0) : + (fun v => MvPolynomial.eval x + (fullTaggedAffineMapChart J (fullTaggedRealMatrixProjection J P) + (fun j => rationalTagProjectionComplement (P j) (anchor j)) v)) = x := by + apply fullTaggedAffineMatrixChart_eval_eq_of_anchor J P _ anchor x + hdisplacement (fun _ => rfl) + intro j + exact rationalTagProjectionComplement_idempotent (P j) (V j) + (hrange j) (hfix j) (anchor j) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/GaussianLatticeDistance.lean b/lean/OAI/Combinatorics/Progressions/Lattices/GaussianLatticeDistance.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef6d293bd706acbc26622e135c1800bc2dd873d3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/GaussianLatticeDistance.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.Progressions.Fourier.LatticeGaussianMeanFourier + +namespace OAI + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + +theorem latticeGaussianMass_quarter_temperature {t : ℝ} (ht : 0 < t) : + latticeGaussianMass Λ (t / 4) 0 ≤ + (2 : ℝ) ^ Module.finrank ℝ E * latticeGaussianMass Λ t 0 := by + have hmono := normalizedLatticeGaussian_origin_mono Λ (show 0 < t / 4 by positivity) + (show t / 4 ≤ t by linarith) + have hsqrt : Real.sqrt (t / 4) = Real.sqrt t / 2 := by + rw [Real.sqrt_div ht.le] + norm_num + have hn := latticeGaussianNormalizer_pos Λ ht + have htwo : (0 : ℝ) < 2 ^ Module.finrank ℝ E := by positivity + have hnorm : latticeGaussianNormalizer Λ (t / 4) = + latticeGaussianNormalizer Λ t / (2 : ℝ) ^ Module.finrank ℝ E := by + unfold latticeGaussianNormalizer + rw [hsqrt, div_pow] + ring + change latticeGaussianNormalizer Λ (t / 4) * latticeGaussianMass Λ (t / 4) 0 ≤ + latticeGaussianNormalizer Λ t * latticeGaussianMass Λ t 0 at hmono + rw [hnorm, div_mul_eq_mul_div] at hmono + have h := (div_le_iff₀ htwo).mp hmono + nlinarith + +noncomputable def latticeGaussianTail (t R : ℝ) : ℝ := + ∑' m : Λ, if R < ‖(m : E)‖ then Real.exp (-Real.pi * t * ‖(m : E)‖ ^ 2) else 0 + +omit [MeasurableSpace E] [BorelSpace E] [IsZLattice ℝ Λ] in +theorem latticeGaussianTail_summable {t : ℝ} (ht : 0 < t) (R : ℝ) : + Summable (fun m : Λ => if R < ‖(m : E)‖ then Real.exp (-Real.pi * t * ‖(m : E)‖ ^ 2) else 0) := by + classical + convert! (lattice_gaussian_summable Λ ht 0).indicator {m : Λ | R < ‖(m : E)‖} using 1 + funext m + simp only [Set.indicator_apply, Set.mem_ofPred_eq, zero_sub, norm_neg] + +theorem latticeGaussianTail_bound {t R : ℝ} (ht : 0 < t) (hR : 0 ≤ R) : + latticeGaussianTail Λ t R ≤ Real.exp (-Real.pi * t * R ^ 2 / 2) * + (2 : ℝ) ^ Module.finrank ℝ E * latticeGaussianMass Λ t 0 := by + classical + have hpoint (m : Λ) : + (if R < ‖(m : E)‖ then Real.exp (-Real.pi * t * ‖(m : E)‖ ^ 2) else 0) ≤ + Real.exp (-Real.pi * t * R ^ 2 / 2) * Real.exp (-Real.pi * (t / 4) * ‖(m : E)‖ ^ 2) := by + split_ifs with hm + · rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hsq : R ^ 2 ≤ ‖(m : E)‖ ^ 2 := pow_le_pow_left₀ hR hm.le 2 + nlinarith [mul_nonneg (mul_nonneg Real.pi_pos.le ht.le) (sub_nonneg.mpr hsq), + mul_nonneg (mul_nonneg Real.pi_pos.le ht.le) (sq_nonneg ‖(m : E)‖)] + · positivity + have hs := (lattice_gaussian_summable Λ (show 0 < t / 4 by positivity) 0).mul_left + (Real.exp (-Real.pi * t * R ^ 2 / 2)) + simp only [zero_sub, norm_neg] at hs + have h := (latticeGaussianTail_summable Λ ht R).tsum_le_tsum hpoint hs + rw [tsum_mul_left] at h + have h' : latticeGaussianTail Λ t R ≤ Real.exp (-Real.pi * t * R ^ 2 / 2) * + latticeGaussianMass Λ (t / 4) 0 := by + simpa only [latticeGaussianTail, latticeGaussianMass, zero_sub, norm_neg] using h + exact h'.trans (by + simpa only [mul_assoc] using mul_le_mul_of_nonneg_left + (latticeGaussianMass_quarter_temperature Λ ht) (Real.exp_pos _).le) + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + +theorem latticeGaussianMass_le_origin {t : ℝ} (ht : 0 < t) (x : E) : + latticeGaussianMass Λ t x ≤ latticeGaussianMass Λ t 0 := by + have h := normalizedLatticeGaussian_le_origin Λ ht x + exact (mul_le_mul_iff_right₀ (latticeGaussianNormalizer_pos Λ ht)).mp h + +theorem normalizedLatticeGaussian_le_of_far {t R : ℝ} (ht : 0 < t) (hR : 0 ≤ R) + (x : E) (hfar : ∀ m : Λ, R ≤ ‖x - (m : E)‖) : + normalizedLatticeGaussian Λ t x ≤ Real.exp (-Real.pi * t * R ^ 2 / 2) * + (2 : ℝ) ^ Module.finrank ℝ E * normalizedLatticeGaussian Λ t 0 := by + have hpoint (m : Λ) : Real.exp (-Real.pi * t * ‖x - (m : E)‖ ^ 2) ≤ + Real.exp (-Real.pi * t * R ^ 2 / 2) * Real.exp (-Real.pi * (t / 4) * ‖x - (m : E)‖ ^ 2) := by + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hsq := pow_le_pow_left₀ hR (hfar m) 2 + nlinarith [mul_nonneg (mul_nonneg Real.pi_pos.le ht.le) (sub_nonneg.mpr hsq), + mul_nonneg (mul_nonneg Real.pi_pos.le ht.le) (sq_nonneg ‖x - (m : E)‖)] + have hs := (lattice_gaussian_summable Λ (show 0 < t / 4 by positivity) x).mul_left + (Real.exp (-Real.pi * t * R ^ 2 / 2)) + have hsum := (lattice_gaussian_summable Λ ht x).tsum_le_tsum hpoint hs + rw [tsum_mul_left] at hsum + have hmass : latticeGaussianMass Λ t x ≤ Real.exp (-Real.pi * t * R ^ 2 / 2) * + ((2 : ℝ) ^ Module.finrank ℝ E * latticeGaussianMass Λ t 0) := by + exact hsum.trans (mul_le_mul_of_nonneg_left + ((latticeGaussianMass_le_origin Λ (by positivity : 0 < t / 4) x).trans + (latticeGaussianMass_quarter_temperature Λ ht)) (Real.exp_pos _).le) + have hnorm := mul_le_mul_of_nonneg_left hmass (latticeGaussianNormalizer_pos Λ ht).le + change latticeGaussianNormalizer Λ t * latticeGaussianMass Λ t x ≤ _ + calc + _ ≤ latticeGaussianNormalizer Λ t * (Real.exp (-Real.pi * t * R ^ 2 / 2) * + ((2 : ℝ) ^ Module.finrank ℝ E * latticeGaussianMass Λ t 0)) := hnorm + _ = _ := by change _ = _ * _ * (latticeGaussianNormalizer Λ t * latticeGaussianMass Λ t 0); ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/GlobalCutoffAffineComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/GlobalCutoffAffineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a4bb0c04eedac76910656efbbfbb5ae888171ec --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/GlobalCutoffAffineComparison.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.Progressions.Polynomial.InitialMaskedAffineComparisonAtDegree + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +section + +variable {ι σ J : Type*} [Fintype J] [Fintype ι] [LinearOrder ι] [Fintype σ] +variable {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} +variable [∀ i, NeZero (q i)] +variable {ε L T C shell modLog level : ℝ} {K : Finset ι} {base : ∀ i, σ → ZMod (q i)} +variable {A B : ℕ} +variable (hKcard : K.card ≤ A) +variable (hB : A + affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog ≤ B) + +variable (hstable : ResiduePrimeCoordinateStable g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) (affineStabilityTolerance T) K base) + +variable (hupper : PrimeRefinementUpperBound h g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base) + +variable (hM : 0 < M) + +variable (u : ResiduePrimeCoordinateCell lo N M a q K base) + +variable (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + +variable (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + +variable (hL : 0 ≤ L) + +variable (hT : 0 ≤ T) + +variable (hlower : Real.exp (-L) ≤ level) + +variable (prime power : ι → ℕ) + +variable (hprime : ∀ i, (prime i).Prime) + +variable (hpower : ∀ i, q i = prime i ^ power i) + +variable (hJ : 2 ≤ Fintype.card J) + +variable (hshell : 0 < shell) + +variable (hlevel2 : level ≤ 2) + +variable (hmodLog : 0 ≤ modLog) + +variable (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + +variable (hε : 0 < ε) +variable (hC : 0 ≤ C) +variable (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) +variable (dimLog : ℝ) +variable (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) +variable (hlength : ∀ k, Real.exp (affineComparisonLengthLog B ε L T C modLog dimLog) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) + +variable (sourceLo sourceA : Option J × σ → ℤ) (sourceN : Option J × σ → ℕ) (sourceM : ℕ) +variable (sourceBase : ∀ i, Option J × σ → ZMod (q i)) +variable (sourceCell : ResiduePrimeCoordinateCell sourceLo sourceN sourceM sourceA q K sourceBase) +variable (w : (Option J × σ → ℤ) → ℝ) +variable (hw : ∀ z : ResiduePrimeCoordinateCell sourceLo sourceN sourceM sourceA q K sourceBase, + 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1) +variable (hsourceM : 0 < sourceM) +variable (sourceDimLog : ℝ) +variable (hsourceDim : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp sourceDimLog) +variable (hsourceLength : ∀ k, Real.exp (affineComparisonLengthLog B ε L T C modLog sourceDimLog) ≤ + (residueIndexLength (sourceLo k) (sourceLo k + sourceN k) (sourceM.lcm (∏ i ∈ K, q i)) ((sourceCell.val k).val) : ℝ)) + +variable (hinj : Function.Injective prime) +variable (hmask : affineInitialPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) sourceM M ⊆ K) + +include hKcard hB hstable hupper hM u hg hh hL hT hlower prime power hprime hpower hJ hshell hlevel2 hmodLog hmoduli hε hC hcount dimLog hdim hlength sourceLo sourceA sourceN sourceM sourceBase sourceCell w hw hsourceM sourceDimLog hsourceDim hsourceLength hinj hmask + +theorem global_cutoff_masked_affine_comparison : + let density := fun f => residueCellOutsideDensity lo N M a q K base u f + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (B - K.card)) (residueCellOutsideDensity sourceLo sourceN sourceM sourceA q K sourceBase sourceCell w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * (Real.exp (-T)) + shell / 16 + Real.sqrt (3 * (Real.exp (-T))) * (3 + (1 + ε) * level * 3) := by + have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1 + have hdegree := affineGlobalCutoff_outside hKcard hB + have hlength' (k : σ) : Real.exp (affineComparisonLengthLog (B - K.card) ε L T C modLog dimLog) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ) := + (Real.exp_le_exp.mpr (affineComparisonLengthLog_mono_degree hdegree.2.1 hP hmodLog)).trans (hlength k) + have hsourceLength' (k : Option J × σ) : + Real.exp (affineComparisonLengthLog (B - K.card) ε L T C modLog sourceDimLog) ≤ + (residueIndexLength (sourceLo k) (sourceLo k + sourceN k) (sourceM.lcm (∏ i ∈ K, q i)) ((sourceCell.val k).val) : ℝ) := + (Real.exp_le_exp.mpr (affineComparisonLengthLog_mono_degree hdegree.2.1 hP hmodLog)).trans (hsourceLength k) + exact initial_masked_affine_comparison_at_degree (b := B - K.card) (hb := hdegree.1) + (ι := ι) (σ := σ) (J := J) (h := h) (g := g) (lo := lo) (a := a) (N := N) + (M := M) (q := q) (ε := ε) (L := L) (T := T) (C := C) (shell := shell) + (modLog := modLog) (level := level) (K := K) (base := base) + (hstable := hstable) (hupper := hupper) (hM := hM) (u := u) (hg := hg) (hh := hh) + (hL := hL) (hT := hT) (hlower := hlower) (prime := prime) (power := power) + (hprime := hprime) (hpower := hpower) (hJ := hJ) (hshell := hshell) (hlevel2 := hlevel2) + (hmodLog := hmodLog) (hmoduli := hmoduli) (hε := hε) (hC := hC) (hcount := hcount) + (dimLog := dimLog) (hdim := hdim) (hlength := hlength') + (sourceLo := sourceLo) (sourceA := sourceA) (sourceN := sourceN) (sourceM := sourceM) + (sourceBase := sourceBase) (sourceCell := sourceCell) (w := w) (hw := hw) + (hsourceM := hsourceM) (sourceDimLog := sourceDimLog) (hsourceDim := hsourceDim) + (hsourceLength := hsourceLength') (hinj := hinj) (hmask := hmask) + +end + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/HalfResidueDescent.lean b/lean/OAI/Combinatorics/Progressions/Lattices/HalfResidueDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..947ad2afbb1490db6457887d7d161c8eeb8bcb99 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/HalfResidueDescent.lean @@ -0,0 +1,423 @@ +import OAI.Combinatorics.Progressions.Estimates.DescentPartitionLengths +import OAI.Combinatorics.Progressions.Lattices.FixedAffineResidueDescent + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_residue_descent_precision (C : ℕ) : + ∃ K : ℕ, 2 ≤ K ∧ ∀ p : ℝ, 0 ≤ p → ∀ Δ : ℝ, 0 < Δ → Δ ≤ 1 → Δ⁻¹ ≤ Real.exp p → + ∃ ε δ : ℝ, 0 < ε ∧ ε < 1 / 2 ∧ 0 < δ ∧ δ ≤ 1 ∧ + ε⁻¹ ≤ Real.exp ((p + 2) ^ K) ∧ δ⁻¹ ≤ Real.exp ((p + 2) ^ K) ∧ + 8 * ε + 2 * (Real.exp ((p + 2) ^ C) * δ) = Δ / 2 := by + let B : Polynomial ℕ := (Polynomial.X + 2) ^ C + Polynomial.X + Polynomial.C 32 + obtain ⟨K, hK, hbudget⟩ := exists_natPolynomial_fixed_power_budget B + refine ⟨K, hK, ?_⟩ + intro p hp Δ hΔ hΔone hΔinv + let E := Real.exp ((p + 2) ^ C) + let ε := Δ / 32 + let δ := Δ / (8 * E) + have hE : 0 < E := Real.exp_pos _ + have hEone : 1 ≤ E := Real.one_le_exp (pow_nonneg (by linarith) _) + have hε : 0 < ε := div_pos hΔ (by norm_num) + have hδ : 0 < δ := div_pos hΔ (mul_pos (by norm_num) hE) + have htotal : (p + 2) ^ C + p + 32 ≤ (p + 2) ^ K := by + simpa [B, Polynomial.eval₂_pow] using hbudget p hp + have hεinv : ε⁻¹ = 32 * Δ⁻¹ := by + change (Δ / 32)⁻¹ = 32 * Δ⁻¹ + rw [inv_div, div_eq_mul_inv] + have hδinv : δ⁻¹ = 8 * E * Δ⁻¹ := by + change (Δ / (8 * E))⁻¹ = 8 * E * Δ⁻¹ + rw [inv_div, div_eq_mul_inv] + have h32 : (32 : ℝ) ≤ Real.exp 32 := by linarith [Real.add_one_le_exp (32 : ℝ)] + have h8 : (8 : ℝ) ≤ Real.exp 8 := by linarith [Real.add_one_le_exp (8 : ℝ)] + have hεbound : ε⁻¹ ≤ Real.exp ((p + 2) ^ K) := by + rw [hεinv] + calc + 32 * Δ⁻¹ ≤ 32 * Real.exp p := mul_le_mul_of_nonneg_left hΔinv (by norm_num) + _ ≤ Real.exp 32 * Real.exp p := mul_le_mul_of_nonneg_right h32 (Real.exp_nonneg _) + _ = Real.exp (32 + p) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith [pow_nonneg (by linarith : 0 ≤ p + 2) C]) + have hδbound : δ⁻¹ ≤ Real.exp ((p + 2) ^ K) := by + rw [hδinv] + calc + 8 * E * Δ⁻¹ ≤ 8 * E * Real.exp p := mul_le_mul_of_nonneg_left hΔinv (by positivity) + _ ≤ Real.exp 8 * E * Real.exp p := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right h8 hE.le) (Real.exp_nonneg _) + _ = Real.exp (8 + (p + 2) ^ C + p) := by + dsimp only [E] + rw [← Real.exp_add, ← Real.exp_add] + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + have hcancel : E * δ = Δ / 8 := by + dsimp only [δ] + field_simp + refine ⟨ε, δ, hε, ?_, hδ, ?_, hεbound, hδbound, ?_⟩ + · dsimp only [ε] + linarith + · apply (div_le_one (mul_pos (by norm_num) hE)).mpr + linarith + · change 8 * ε + 2 * (E * δ) = Δ / 2 + rw [hcancel] + dsimp only [ε] + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_residue_event_descent_precision (C : ℕ) : + ∃ K : ℕ, 2 ≤ K ∧ ∀ p : ℝ, 0 ≤ p → ∀ Δ : ℝ, + 0 < Δ → Δ ≤ 1 → Δ⁻¹ ≤ Real.exp p → + ∃ rho q ε δ : ℝ, + p + 16 ≤ q ∧ verticalDecompositionBudget (p + 16) ≤ q ∧ q ≤ (p + 2) ^ K ∧ + 0 < rho ∧ rho⁻¹ ≤ Real.exp (p + 16) ∧ + 0 < ε ∧ ε < 1 / 2 ∧ 0 < δ ∧ δ ≤ 1 ∧ + ε⁻¹ ≤ Real.exp ((p + 2) ^ K) ∧ δ⁻¹ ≤ Real.exp ((p + 2) ^ K) ∧ + 2 * (2 * rho + Real.exp (verticalDecompositionBudget (p + 16) - q)) ≤ Δ / 2 ∧ + 8 * ε + 2 * (Real.exp (((p + 16) + 2) ^ C) * δ) = Δ / 4 := by + obtain ⟨C₀, _, hvertical⟩ := exists_verticalDecompositionBudget_bound + obtain ⟨K₀, _, hprecision⟩ := exists_residue_descent_precision C + let P : Polynomial ℕ := (Polynomial.X + 18) ^ K₀ + + (Polynomial.X + Polynomial.C (16 + C₀)) ^ C₀ + Polynomial.X + 32 + obtain ⟨K, hK, hbudget⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨K, hK, ?_⟩ + intro p hp Δ hΔ hΔone hΔinv + have hp16 : 0 ≤ p + 16 := by linarith + have h16 : (16 : ℝ) ≤ Real.exp 16 := by linarith [Real.add_one_le_exp (16 : ℝ)] + have hdouble : (Δ / 2)⁻¹ ≤ Real.exp (p + 16) := by + rw [inv_div, div_eq_mul_inv] + calc + 2 * Δ⁻¹ ≤ 2 * Real.exp p := mul_le_mul_of_nonneg_left hΔinv (by norm_num) + _ ≤ Real.exp 16 * Real.exp p := mul_le_mul_of_nonneg_right (by linarith) (Real.exp_nonneg _) + _ = Real.exp (p + 16) := by rw [← Real.exp_add]; congr 1; ring + obtain ⟨ε, δ, hε, hεhalf, hδ, hδone, hεbound, hδbound, herror⟩ := + hprecision (p + 16) hp16 (Δ / 2) (by positivity) (by linarith) hdouble + let rho := Δ / 16 + let q := verticalDecompositionBudget (p + 16) + p + 32 + have hfreq0 : 0 ≤ verticalDecompositionBudget (p + 16) := + verticalDecompositionBudget_nonneg hp16 + have hpoly : (p + 18) ^ K₀ + (p + (16 + C₀ : ℕ)) ^ C₀ + p + 32 ≤ (p + 2) ^ K := by + simpa [P, Polynomial.eval₂_pow] using hbudget p hp + have hfreq : verticalDecompositionBudget (p + 16) ≤ (p + (16 + C₀ : ℕ)) ^ C₀ := by + simpa [Nat.cast_add, Nat.cast_ofNat, add_assoc] using hvertical (p + 16) hp16 + have hpow : ((p + 16) + 2) ^ K₀ ≤ (p + 2) ^ K := by + have hother : 0 ≤ (p + (16 + C₀ : ℕ)) ^ C₀ := by positivity + have heq : (p + 16) + 2 = p + 18 := by ring + rw [heq] + linarith + have hq : q ≤ (p + 2) ^ K := by + have hother : 0 ≤ (p + 18) ^ K₀ := by positivity + dsimp only [q] + linarith + have hrho : rho⁻¹ ≤ Real.exp (p + 16) := by + change (Δ / 16)⁻¹ ≤ Real.exp (p + 16) + rw [inv_div, div_eq_mul_inv] + calc + 16 * Δ⁻¹ ≤ 16 * Real.exp p := mul_le_mul_of_nonneg_left hΔinv (by norm_num) + _ ≤ Real.exp 16 * Real.exp p := mul_le_mul_of_nonneg_right h16 (Real.exp_nonneg _) + _ = Real.exp (p + 16) := by rw [← Real.exp_add]; congr 1; ring + have hsmall : Real.exp (-p) ≤ Δ := by + rw [Real.exp_neg] + exact (inv_le_comm₀ hΔ (Real.exp_pos p)).mp hΔinv + have h32 : (8 : ℝ) ≤ Real.exp 32 := by linarith [Real.add_one_le_exp (32 : ℝ)] + have htail : Real.exp (-32 : ℝ) ≤ 1 / 8 := by + rw [Real.exp_neg] + simpa only [one_div] using one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 8) h32 + have htailbound : Real.exp (verticalDecompositionBudget (p + 16) - q) ≤ Δ / 8 := by + have heq : verticalDecompositionBudget (p + 16) - q = -p + (-32) := by + dsimp only [q] + ring + rw [heq, Real.exp_add] + calc + Real.exp (-p) * Real.exp (-32) ≤ Δ * (1 / 8) := + mul_le_mul hsmall htail (Real.exp_nonneg _) hΔ.le + _ = _ := by ring + refine ⟨rho, q, ε, δ, ?_, ?_, hq, by dsimp only [rho]; positivity, hrho, + hε, hεhalf, hδ, hδone, hεbound.trans (Real.exp_le_exp.mpr hpow), + hδbound.trans (Real.exp_le_exp.mpr hpow), ?_, ?_⟩ + · dsimp only [q] + linarith + · dsimp only [q] + linarith + · dsimp only [rho] + linarith + · linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residue_descent_size_bounds {σ : Type*} [Fintype σ] + (N : σ → ℕ) (M P : ℕ) (J : σ → ℕ) (E Q ε δ : ℝ) + (hE : 1 ≤ E) (hQ : Q ≤ E) (hM : (M : ℝ) ≤ E) (hP : (P : ℝ) ≤ E) + (hJ : ∀ i, (J i : ℝ) ≤ E) (hcard : (Fintype.card σ : ℝ) ≤ E) + (hε : 0 < ε) (hδ : 0 < δ) (hεinv : ε⁻¹ ≤ E) (hδinv : δ⁻¹ ≤ E) + (hN : ∀ i, 8 * E ^ 6 ≤ (N i : ℝ)) : + (∀ i, ((M * J i : ℕ) : ℝ) * (Q + 1) ≤ (N i : ℝ)) ∧ + (∀ i, 8 ≤ δ * (N i : ℝ)) ∧ + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ δ * ε / 8 := by + have hE0 : 0 < E := by linarith + have hsize0 : 0 < 8 * E ^ 6 := by positivity + have hN0 : ∀ i, 0 < (N i : ℝ) := fun i => hsize0.trans_le (hN i) + have hεlower : E⁻¹ ≤ ε := (inv_le_comm₀ hε hE0).mp hεinv + have hδlower : E⁻¹ ≤ δ := (inv_le_comm₀ hδ hE0).mp hδinv + have hδmul : 1 ≤ δ * E := + (div_le_iff₀ hE0).mp (by simpa only [one_div] using hδlower) + have hE16 : E ≤ E ^ 6 := by + simpa only [pow_one] using pow_le_pow_right₀ hE (by norm_num : 1 ≤ 6) + have hE36 : E ^ 3 ≤ E ^ 6 := pow_le_pow_right₀ hE (by norm_num : 3 ≤ 6) + have hpair : ∀ i, ((M * J i : ℕ) : ℝ) ≤ E ^ 2 := by + intro i + simpa only [Nat.cast_mul, pow_two] using + mul_le_mul hM (hJ i) (Nat.cast_nonneg (J i)) hE0.le + have hlcm : Nat.lcm M (M * P) = M * P := + Nat.lcm_eq_right_iff_dvd.mpr (Nat.dvd_mul_right M P) + have htriple : ∀ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) ≤ E ^ 3 := by + intro i + rw [hlcm, Nat.cast_mul, Nat.cast_mul] + calc + (M : ℝ) * P * J i ≤ (E * E) * E := + mul_le_mul (mul_le_mul hM hP (Nat.cast_nonneg P) hE0.le) + (hJ i) (Nat.cast_nonneg (J i)) (by positivity) + _ = E ^ 3 := by ring + refine ⟨?_, ?_, ?_⟩ + · intro i + calc + ((M * J i : ℕ) : ℝ) * (Q + 1) ≤ ((M * J i : ℕ) : ℝ) * (E + 1) := + mul_le_mul_of_nonneg_left (add_le_add hQ (le_refl 1)) (Nat.cast_nonneg _) + _ ≤ E ^ 2 * (E + 1) := mul_le_mul_of_nonneg_right (hpair i) (by positivity) + _ ≤ E ^ 2 * (2 * E) := mul_le_mul_of_nonneg_left (by linarith) (by positivity) + _ = 2 * E ^ 3 := by ring + _ ≤ 8 * E ^ 6 := by nlinarith [pow_nonneg hE0.le 6] + _ ≤ (N i : ℝ) := hN i + · intro i + have hn : 8 * E ≤ (N i : ℝ) := + (mul_le_mul_of_nonneg_left hE16 (by norm_num)).trans (hN i) + calc + 8 ≤ δ * (8 * E) := by nlinarith + _ ≤ δ * (N i : ℝ) := mul_le_mul_of_nonneg_left hn hδ.le + · have hterm : ∀ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ) ≤ + E ^ 3 / (8 * E ^ 6) := by + intro i + exact (div_le_div_of_nonneg_right (htriple i) (hN0 i).le).trans + (div_le_div_of_nonneg_left (by positivity) hsize0 (hN i)) + calc + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ + ∑ _ : σ, E ^ 3 / (8 * E ^ 6) := Finset.sum_le_sum (fun i _ => hterm i) + _ = (Fintype.card σ : ℝ) * (E ^ 3 / (8 * E ^ 6)) := by + rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + _ ≤ E * (E ^ 3 / (8 * E ^ 6)) := mul_le_mul_of_nonneg_right hcard (by positivity) + _ = E⁻¹ * E⁻¹ / 8 := by field_simp + _ ≤ δ * ε / 8 := div_le_div_of_nonneg_right + (mul_le_mul hδlower hεlower (by positivity) hδ.le) (by norm_num) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_separated_residue_precision : + ∃ Kevent : ℕ, 2 ≤ Kevent ∧ ∀ C : ℕ, ∃ Kfreeze : ℕ, 2 ≤ Kfreeze ∧ + ∀ p : ℝ, 0 ≤ p → ∀ Δ : ℝ, 0 < Δ → Δ ≤ 1 → Δ⁻¹ ≤ Real.exp p → + ∃ rho q : ℝ, + p + 16 ≤ q ∧ verticalDecompositionBudget (p + 16) ≤ q ∧ q ≤ (p + 2) ^ Kevent ∧ + 0 < rho ∧ rho⁻¹ ≤ Real.exp (p + 16) ∧ + 2 * (2 * rho + Real.exp (verticalDecompositionBudget (p + 16) - q)) ≤ Δ / 2 ∧ + ∀ work : ℝ, p + 16 ≤ work → ∃ ε δ : ℝ, + 0 < ε ∧ ε < 1 / 2 ∧ 0 < δ ∧ δ ≤ 1 ∧ + ε⁻¹ ≤ Real.exp ((work + 2) ^ Kfreeze) ∧ δ⁻¹ ≤ Real.exp ((work + 2) ^ Kfreeze) ∧ + 8 * ε + 2 * (Real.exp ((work + 2) ^ C) * δ) = Δ / 4 := by + obtain ⟨Kevent, hKevent, hevent⟩ := exists_residue_event_descent_precision 0 + refine ⟨Kevent, hKevent, ?_⟩ + intro C + obtain ⟨Kfreeze, hKfreeze, hfreeze⟩ := exists_residue_descent_precision C + refine ⟨Kfreeze, hKfreeze, ?_⟩ + intro p hp Δ hΔ hΔone hΔinv + obtain ⟨rho, q, _, _, hpq, hfreq, hq, hrho, hrhop, _, _, _, _, _, _, hprojection, _⟩ := + hevent p hp Δ hΔ hΔone hΔinv + refine ⟨rho, q, hpq, hfreq, hq, hrho, hrhop, hprojection, ?_⟩ + intro work hwork + have h16 : (2 : ℝ) ≤ Real.exp 16 := by linarith [Real.add_one_le_exp (16 : ℝ)] + have hdouble : (Δ / 2)⁻¹ ≤ Real.exp work := by + rw [inv_div, div_eq_mul_inv] + calc + 2 * Δ⁻¹ ≤ 2 * Real.exp p := mul_le_mul_of_nonneg_left hΔinv (by norm_num) + _ ≤ Real.exp 16 * Real.exp p := mul_le_mul_of_nonneg_right h16 (Real.exp_nonneg _) + _ = Real.exp (p + 16) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp work := Real.exp_le_exp.mpr hwork + obtain ⟨ε, δ, hε, hεhalf, hδ, hδone, hεbound, hδbound, herror⟩ := + hfreeze work (by linarith) (Δ / 2) (by positivity) (by linarith) hdouble + exact ⟨ε, δ, hε, hεhalf, hδ, hδone, hεbound, hδbound, by linarith⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct BigOperators NNReal + +theorem exists_fixed_child_residue_descent (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) (w : σ → ℕ), + (∀ i, 0 < w i) → ∀ p : ℝ, 0 ≤ p → D.GeometryComplexityLE p → + (Fintype.card σ : ℝ) ≤ p → ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ (P : ℕ) (hP : 0 < P), (P : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + ∀ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) {e n : ℕ} + (E : RationalFilteredNilmanifold (D.filtration.gradedRefiltrationSubalgebra W) (s + 1) e) + (Q : RationalFilteredNilmanifold + ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n) + (_hEF : E.filtration = D.filtration.gradedRefiltration W) + (_hQF : Q.filtration = E.filtration.quotientTop) + (b : (D.filtration.realification.adaptedPolynomialFiltration w).Group), + (∀ α, coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α ∈ + D.filtration.realGradedRefiltrationLayer W (Finsupp.weight w α)) → + coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 → + ∀ cost : ℝ, 0 ≤ cost → SingleRefilteredRecoveryFamily D W E Q p q C cost → + let H := D.filtration.gradedRefiltrationSubalgebra W + let N := H ⧸ E.filtration.layerIdeal (s + 1) + let := moduleTopology ℝ (ℝ ⊗[ℚ] N) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] N) + let := realification_moduleTopology_t2 Q.basis + let T := Q.raiseStep (Nat.le_succ s) + ∃ Λ : Subgroup T.filtration.Group, Λ ≤ T.lattice ∧ + (Λ.subgroupOf T.lattice).Characteristic ∧ (Λ.subgroupOf T.lattice).Normal ∧ + (Λ.subgroupOf T.lattice).FiniteIndex ∧ (Λ.relIndex T.lattice : ℝ) ≤ Real.exp cost ∧ + ∃ (B : ℕ) (hB : 0 < B) + (hin : scaledIntegerGrid B ⊆ bchSubgroupCoordinates Q.basis Λ) + (hout : bchSubgroupCoordinates Q.basis Λ ⊆ denominatorGrid B), + let V := Q.loweredCover (Nat.le_succ s) Λ B hB hin hout + V.filtration = Q.filtration ∧ V.lattice ≤ Q.lattice ∧ V.GeometryComplexityLE cost ∧ + ∃ child : V.filtration.realification.PolynomialOrbit w, + DegreeLE w s child.log ∧ + FixedResidueDescent D W V w b child p q P hP C a (cost + 4) := by + obtain ⟨C, hC, hfreezing⟩ := Niltest.exists_auxiliary_frozen_discrepancy (s + 1) a + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ _ _ _ _ d D w hw p hp hD hσ q hq hqp + obtain ⟨P, hP, hPb, hfreeze⟩ := hfreezing D w hw p hp hD hσ q hq hqp + refine ⟨P, hP, hPb, ?_⟩ + intro W e n E Q hEF hQF b hb hb0 cost hcost hfamily H N _ _ _ T + obtain ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex, B, hB, hin, hout, hVF, hVL, hV, + child, hdegree, hrealize⟩ := + SingleRefilteredRecoveryFamily.exists_fixed_child D W E Q hEF hQF w hw b hb hb0 hcost hfamily + let V := Q.loweredCover (Nat.le_succ s) Λ B hB hin hout + refine ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex, B, hB, hin, hout, hVF, hVL, hV, + child, hdegree, ?_⟩ + change FixedResidueDescent D W V w b child p q P hP C a (cost + 4) + intro S hS hunit hinvariant slow rational κ hκ hprod hgrid A hA hslow M hM lo length width + hwidth hwidthN u v J hJ hv hcop δ ε hδ hε hsize hphysical hsmall cells c₀ c₁ F G + obtain ⟨k, hk₀, hk₁, l₀, r₀, hl₀, hr₀, hgap⟩ := + hfreeze S hS hunit slow b rational κ hκ hprod hgrid A hA hslow + M hM lo length width hwidth hwidthN u v J hJ hv hcop δ ε hδ hε hsize hphysical hsmall + have hℓ : (S.lipBound : ℝ) ≤ Real.exp p := by + linarith [S.observable_budget hS, S.normBound.coe_nonneg] + have hreal := hrealize l₀ r₀ hl₀ hr₀ S.observable S.lipBound hℓ S.lipschitz hunit hinvariant + obtain ⟨U, hU, hunitU, hcostU, hgapU⟩ := hreal.transfer_discrepancy + (partitionCell c₀ k) (partitionCell c₁ k) + (fun x => commonStrideIndex u M (fun i => (x i).val)) + (fun x => commonStrideIndex u M (fun i => (x i).val)) hgap + exact ⟨k, hk₀, hk₁, U, hU, hunitU, hcostU, hgapU⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct BigOperators + +theorem FixedResidueDescent.half_discrepancy + {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {s d t e : ℕ} + {D : RationalFilteredNilmanifold L s d} + {W : LieSubalgebra ℚ D.filtration.AssociatedGraded} + {V : RationalFilteredNilmanifold K t e} {w : σ → ℕ} + {b : (D.filtration.realification.adaptedPolynomialFiltration w).Group} + {child : V.filtration.realification.PolynomialOrbit w} + {p cost : ℝ} {q P C a : ℕ} {hP : 0 < P} + (hdesc : FixedResidueDescent D W V w b child p q P hP C a cost) + (S : D.Niltest w) (hS : S.ComplexityLE p) (hunit : S.UnitIntervalValued) + (hinvariant : ∀ z : D.RealGroup, z.coord ∈ D.filtration.realGradedRefiltrationLayer W s → + ∀ x, S.observable (z • x) = S.observable x) + (E R : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (κ : D.RealGroup) (hκ : κ ∈ D.realLattice) + (hprod : E * b * R * D.filtration.realification.adaptedConstantGroupHom w κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩) + (hgrid : D.filtration.PolynomialRationalGrid D.basis w q R) + (A : σ → ℝ) (hA : ∀ i, 0 < A i) + (hE : D.filtration.PolynomialSlowBound D.basis w A (Real.exp ((p + 2) ^ a)) E) + (M : ℕ) (hM : 0 < M) (lo : σ → ℤ) (N : σ → ℕ) (u v : σ → ℤ) (J : σ → ℕ) + (hJ : ∀ i, 0 < J i) (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) + (hcop : ∀ i, (M * (M * P)).Coprime (J i)) (Δ ε δ : ℝ) + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : ε < 1 / 2) + (hprecision : 8 * ε + 2 * (Real.exp ((p + 2) ^ C) * δ) ≤ Δ / 2) + (hlarge : ∀ i, 8 ≤ δ * (N i : ℝ)) + (hphysical : ∀ i, (u i : ℝ) - (M : ℝ) * A i ≤ (lo i : ℝ) ∧ + (lo i : ℝ) + (N i : ℝ) ≤ (u i : ℝ) + (M : ℝ) * A i) + (hcount : (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ δ * ε / 8) + (hgap : Δ ≤ + ‖(𝔼 x : IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) u, + residueBoxStrideValue S.eval u M x) - + (𝔼 x : IntegerResidueBox lo (fun i => lo i + N i) (fun i => (M * J i : ℕ)) v, + residueBoxStrideValue S.eval u M x)‖) : + ∃ (H : σ → ℕ) (hH : ∀ i, 0 < H i) (hHN : ∀ i, H i ≤ N i), + (∀ i, δ * (N i : ℝ) / 8 ≤ (H i : ℝ)) ∧ + (∀ i, (H i : ℝ) ≤ δ * (N i : ℝ) / 4) ∧ + let Q := comparableBoxPartitions N H hH hHN + let c₀ := baseAuxiliaryBoxCell lo N Q (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u + let c₁ := refinedAuxiliaryBoxCell lo N Q (fun _ => M) (fun _ => M * P) J + (fun _ => Nat.mul_pos hM hP) u v hv + ∃ k : AuxiliaryBoxLabels Q (fun _ => M) (fun _ => M * P) u, + 0 < (partitionCell c₀ k).card ∧ 0 < (partitionCell c₁ k).card ∧ + ∃ U : V.Niltest w, U.orbit = child ∧ U.UnitIntervalValued ∧ U.ComplexityLE cost ∧ + Δ / 2 ≤ + ‖(𝔼 x ∈ partitionCell c₀ k, residueBoxStrideValue U.eval u M x) - + (𝔼 x ∈ partitionCell c₁ k, residueBoxStrideValue U.eval u M x)‖ := by + have hsize : ∀ i, (N i : ℝ) ≤ 2 * (M : ℝ) * A i := by + intro i + linarith [(hphysical i).1, (hphysical i).2] + obtain ⟨H, hH, hHN, hlo, hhi, hfreeze, hcounts⟩ := exists_descent_partition_lengths N M A δ hδ hδone + hsize hlarge (fun i => ((Nat.lcm M (M * P) * J i : ℕ) : ℝ)) + (fun _ => Nat.cast_nonneg _) ε hcount + refine ⟨H, hH, hHN, hlo, hhi, ?_⟩ + intro Q c₀ c₁ + obtain ⟨k, hk₀, hk₁, U, hU, hunitU, hcostU, hchild⟩ := hdesc S hS hunit hinvariant + E R κ hκ hprod hgrid A hA hE M hM lo N H hH hHN u v J hJ hv hcop + δ ε hδ.le hε hfreeze hphysical hcounts + refine ⟨k, hk₀, hk₁, U, hU, hunitU, hcostU, ?_⟩ + linarith + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ImageLatticeSubgroup.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ImageLatticeSubgroup.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ef5dbdbfdfb5c918bfe5adf670523329883bb94 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ImageLatticeSubgroup.lean @@ -0,0 +1,154 @@ +import OAI.Combinatorics.Progressions.Estimates.ControlledSurjectiveReconstruction + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup +open scoped Matrix TensorProduct + +theorem matrix_mulVec_fine_grid {ι κ : Type*} [Fintype ι] [Fintype κ] + (S : Matrix ι κ ℚ) (l : ℕ) : + scaledIntegerGrid (l * matrixDenominator S) ⊆ S.mulVec ⁻¹' scaledIntegerGrid l := by + classical + rintro y ⟨z, rfl⟩ + obtain ⟨w, hw⟩ := integralVector_denominator_mulVec S (fun j => (z j : ℚ)) ⟨z, fun _ => rfl⟩ + refine ⟨w, ?_⟩ + rw [Matrix.mulVec_smul] + ext i + have hi := hw i + change (matrixDenominator S : ℚ) * (S *ᵥ fun j => (z j : ℚ)) i = (w i : ℚ) at hi + simp only [Pi.smul_apply, smul_eq_mul, Nat.cast_mul] + rw [mul_assoc, hi] + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +theorem real_image_lattice_lift [DecidableEq ι] [DecidableEq κ] + (e : Basis ι ℚ L) (f : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) (σ : M →ₗ[ℚ] L) + (hσ : (φ.toLinearMap.comp σ).comp φ.toLinearMap = φ.toLinearMap) + (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) + (Λ : Subgroup (NilpotentLieBCHGroup M s hM)) (l B : ℕ) + (hΓ : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (hΛ : bchSubgroupCoordinates f Λ ⊆ scaledIntegerGrid B) + (hdiv : l * matrixDenominator (LinearMap.toMatrix f e σ) ∣ B) : + Λ.map realificationHom ⊓ (realificationMap (hnil := hL) (hM := hM) φ).range ≤ + (Γ.map realificationHom).map (realificationMap (hnil := hL) (hM := hM) φ) := by + rintro g ⟨hg, himage⟩ + obtain ⟨γ, hγ, rfl⟩ := hg + obtain ⟨x, hx⟩ := himage + have hxcoord := congrArg NilpotentLieBCHGroup.coord hx + change φ.toLinearMap.baseChange ℝ x.coord = (1 : ℝ) ⊗ₜ[ℚ] γ.coord at hxcoord + have hsection := DFunLike.congr_fun (linearMap_baseChange_image_section φ.toLinearMap σ hσ) x.coord + change φ.toLinearMap.baseChange ℝ (σ.baseChange ℝ (φ.toLinearMap.baseChange ℝ x.coord)) = + φ.toLinearMap.baseChange ℝ x.coord at hsection + rw [hxcoord] at hsection + have hpre : φ (σ γ.coord) = γ.coord := by + apply rationalLieInclusion_injective f + change (1 : ℝ) ⊗ₜ[ℚ] φ (σ γ.coord) = (1 : ℝ) ⊗ₜ[ℚ] γ.coord + rw [LinearMap.baseChange_tmul, LinearMap.baseChange_tmul] at hsection + exact hsection + let a : NilpotentLieBCHGroup L s hL := ⟨σ γ.coord⟩ + have ha : a ∈ Γ := by + apply (bchSubgroupCoordinates_repr e Γ a).mp + apply hΓ + have hy := scaledIntegerGrid_subset_of_dvd hdiv + (hΛ ((bchSubgroupCoordinates_repr f Λ γ).mpr hγ)) + have hs := matrix_mulVec_fine_grid (LinearMap.toMatrix f e σ) l hy + change LinearMap.toMatrix f e σ *ᵥ f.equivFun γ.coord ∈ scaledIntegerGrid l at hs + rw [basisMatrix_mulVec, LinearEquiv.symm_apply_apply] at hs + exact hs + refine ⟨realificationHom a, ⟨a, ha, rfl⟩, ?_⟩ + rw [realificationMap_realificationHom] + apply congrArg realificationHom + exact ext hpre + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +theorem exists_image_lattice_subgroup (e : Basis ι ℚ L) (f : Basis κ ℚ M) + (φ : L →ₗ⁅ℚ⁆ M) (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) + (Δ : Subgroup (NilpotentLieBCHGroup M s hM)) + (l m H : ℕ) (hl : 0 < l) (hm : 0 < m) (hH : 1 ≤ H) + (hΓ : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (hΔ : scaledIntegerGrid m ⊆ bchSubgroupCoordinates f Δ) + (hentries : ∀ i j, RationalHeightLE (f.repr (φ (e j)) i) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants f i j k) H) : + ∃ (B : ℕ) (Λ : Subgroup (NilpotentLieBCHGroup M s hM)), + 0 < B ∧ m ∣ B ∧ B ≤ bchIntegralDenominatorBound s * H ^ (Fintype.card κ ^ 3) * + (m * (l * rationalKernelHeight (Fintype.card κ) H ^ (Fintype.card ι * Fintype.card κ))) ∧ + Λ ≤ Δ ∧ bchSubgroupCoordinates f Λ = scaledIntegerGrid B ∧ + Λ.map realificationHom ⊓ (realificationMap (hnil := hL) (hM := hM) φ).range ≤ + (Γ.map realificationHom).map (realificationMap (hnil := hL) (hM := hM) φ) := by + classical + obtain ⟨σ, hσ, hσH⟩ := exists_bounded_linear_image_section e f φ.toLinearMap hH hentries + let D := matrixDenominator (LinearMap.toMatrix f e σ) + have hD : 0 < D := matrixDenominator_pos _ + have hDb : D ≤ rationalKernelHeight (Fintype.card κ) H ^ (Fintype.card ι * Fintype.card κ) := by + apply matrixDenominator_le + intro i j + rw [LinearMap.toMatrix_apply] + exact hσH i j + let q := m * (l * D) + have hq : 0 < q := Nat.mul_pos hm (Nat.mul_pos hl hD) + have hΔq : scaledIntegerGrid q ⊆ bchSubgroupCoordinates f Δ := + (scaledIntegerGrid_subset_of_dvd (dvd_mul_right m (l * D))).trans hΔ + obtain ⟨B, Λ, hB, hqB, hBb, hΛ, hgrid⟩ := exists_integral_grid_subgroup f hM Δ q hq hc hΔq + refine ⟨B, Λ, hB, (dvd_mul_right m (l * D)).trans hqB, ?_, hΛ, hgrid, ?_⟩ + · exact hBb.trans (Nat.mul_le_mul_left _ (Nat.mul_le_mul_left m (Nat.mul_le_mul_left l hDb))) + · apply real_image_lattice_lift e f φ σ hσ Γ Λ l B hΓ + · exact hgrid.le + · exact (dvd_mul_left (l * D) m).trans hqB + +namespace NilpotentLieFiltration + +theorem exists_image_lattice_cover (F : NilpotentLieFiltration M s) + (e : Basis ι ℚ L) (f : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) (Δ : Subgroup F.Group) + (l m H : ℕ) (hl : 0 < l) (hm : 0 < m) (hH : 1 ≤ H) + (hΓ : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (hΔin : scaledIntegerGrid m ⊆ bchSubgroupCoordinates f Δ) + (hΔout : bchSubgroupCoordinates f Δ ⊆ denominatorGrid m) + (hentries : ∀ i j, RationalHeightLE (f.repr (φ (e j)) i) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants f i j k) H) : + ∃ (B : ℕ) (Λ : Subgroup F.Group), + 0 < B ∧ B ≤ bchIntegralDenominatorBound s * H ^ (Fintype.card κ ^ 3) * + (m * (l * rationalKernelHeight (Fintype.card κ) H ^ (Fintype.card ι * Fintype.card κ))) ∧ + Λ ≤ Δ ∧ (Λ.subgroupOf Δ).Characteristic ∧ (Λ.subgroupOf Δ).Normal ∧ + (Λ.subgroupOf Δ).FiniteIndex ∧ Λ.relIndex Δ ≤ (m * B) ^ Fintype.card κ ∧ + scaledIntegerGrid ((m * B) * m) ⊆ bchSubgroupCoordinates f Λ ∧ + bchSubgroupCoordinates f Λ ⊆ denominatorGrid ((m * B) * m) ∧ + Λ.map realificationHom ⊓ + (realificationMap (hnil := hL) (hM := F.lowerCentralSeries_eq_bot) φ).range ≤ + (Γ.map realificationHom).map + (realificationMap (hnil := hL) (hM := F.lowerCentralSeries_eq_bot) φ) := by + obtain ⟨B, Λ₀, hB, _, hBb, _, hgrid, hlift⟩ := exists_image_lattice_subgroup e f φ Γ Δ + l m H hl hm hH hΓ hΔin hentries hc + obtain ⟨Λ, hΛ₀, hΛ, hchar, hnormal, hfinite, hindex, hin, hout⟩ := + F.exists_sharp_normal_cover f Δ Λ₀ m B hm hB hΔin hΔout hgrid.ge + refine ⟨B, Λ, hB, hBb, hΛ, hchar, hnormal, hfinite, hindex, hin, hout, ?_⟩ + exact le_trans (inf_le_inf_right _ (Subgroup.map_mono hΛ₀)) hlift + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IndependentIntegerSiteDirections.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IndependentIntegerSiteDirections.lean new file mode 100644 index 0000000000000000000000000000000000000000..cefcb6a1a84dfd590683b1d2ebd24c706890a002 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IndependentIntegerSiteDirections.lean @@ -0,0 +1,94 @@ +import Mathlib.Algebra.BigOperators.Fin +import OAI.Combinatorics.Progressions.Estimates.LowerTriangularMinor +import OAI.Combinatorics.Progressions.Estimates.PrincipalCoefficientMarginal + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators TensorProduct Classical + +theorem exists_integer_site_directions {α K W : Type*} [Fintype α] [DecidableEq α] [Fintype K] + [AddCommGroup W] [Module ℝ W] + (root : K → ℤ) (difference : α → K → ℤ) (selection : α → K) + (hdet : (integerDifferencePivot difference selection).det ≠ 0) + {H D : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) + (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D) + (Λ : VectorPolynomial (Option K) ℝ W →ₗ[ℝ] ℝ) (h : ℕ) + (hnonfactor : ¬ ∃ M : (Finset α → W) →ₗ[ℝ] ℝ, + ∀ p, VectorPolynomial.Homogeneous h p → Λ p = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) : + ∃ rows : Fin h → Option K → ℤ, + (∀ i k, |(rows i k : ℝ)| ≤ integerCubeWitnessBound (Fintype.card α) H D) ∧ + (∀ s : Finset α, ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧ + ∃ w : W, Λ ((map (Int.castRingHom ℝ) (∏ i, rowPolynomial (rows i))) ⊗ₜ[ℝ] w) ≠ 0 := by + obtain ⟨forms, hlen, hforms, hz, hΛ⟩ := exists_integral_vector_mode_witness + root difference selection hdet hH hD hroot hdiff Λ h hnonfactor + subst h + let rows := fun i : Fin forms.length => polynomialLinearRow (forms.get i) + have hmem (i : Fin forms.length) : forms.get i ∈ forms := List.get_mem _ _ + have hpoly (i : Fin forms.length) : rowPolynomial (rows i) = forms.get i := + (homogeneous_eq_rowPolynomial _ (hforms _ (hmem i)).1).symm + have hprod : (∏ i : Fin forms.length, rowPolynomial (rows i)) = forms.prod := by + simp_rw [hpoly] + rw [← Fin.prod_ofFn, List.ofFn_get] + refine ⟨rows, ?_, ?_, ?_⟩ + · intro i k + exact (integer_coefficient_le_mass (forms.get i) (Finsupp.single k 1)).trans (hforms _ (hmem i)).2 + · intro s + obtain ⟨i, hi⟩ := List.exists_mem_iff_get.mp (hz s) + refine ⟨i, ?_⟩ + change (∑ k, polynomialLinearRow (forms.get i) k * affineSite root difference s k) = 0 + rw [← homogeneous_eval_eq_row _ (hforms _ (hmem i)).1] + exact hi + · rw [hprod] + exact hΛ + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators TensorProduct Classical + +theorem integer_difference_exists_pivot {K : Type*} [Fintype K] {q : ℕ} + (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) : + ∃ selection : Fin q → K, (integerDifferencePivot difference selection).det ≠ 0 := by + let A : Matrix K (Fin q) ℝ := fun k i => difference i k + obtain ⟨selection, hdet⟩ := exists_nonzero_row_minor A hlin + have he : A.submatrix selection id = (realDifferencePivot + (fun i k => (difference i k : ℝ)) selection).transpose := rfl + rw [he, Matrix.det_transpose, ← integerDifferencePivot_det_cast] at hdet + exact ⟨selection, fun hz => hdet (by rw [hz, Int.cast_zero])⟩ + +theorem exists_integer_site_directions_of_independent {K W : Type*} [Fintype K] {q : ℕ} + [AddCommGroup W] [Module ℝ W] + (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {H D : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) + (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D) + (Λ : VectorPolynomial (Option K) ℝ W →ₗ[ℝ] ℝ) (h : ℕ) + (hnonfactor : ¬ ∃ M : (Finset (Fin q) → W) →ₗ[ℝ] ℝ, + ∀ p, VectorPolynomial.Homogeneous h p → Λ p = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) p)) : + ∃ rows : Fin h → Option K → ℤ, + (∀ i k, |(rows i k : ℝ)| ≤ integerCubeWitnessBound q H D) ∧ + (∀ s : Finset (Fin q), ∃ i, (∑ k, rows i k * affineSite root difference s k) = 0) ∧ + ∃ w : W, Λ ((map (Int.castRingHom ℝ) (∏ i, rowPolynomial (rows i))) ⊗ₜ[ℝ] w) ≠ 0 := by + obtain ⟨selection, hdet⟩ := integer_difference_exists_pivot difference hlin + simpa only [Fintype.card_fin] using exists_integer_site_directions + root difference selection hdet hH hD hroot hdiff Λ h hnonfactor + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/InitialMaskedAffineComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/InitialMaskedAffineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..492cb409476633e67949ad06d98b5c7eae31b731 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/InitialMaskedAffineComparison.lean @@ -0,0 +1,1085 @@ +import OAI.Combinatorics.Progressions.Lattices.RetainedPhysicalCRT +import OAI.Combinatorics.Progressions.Linear.StableCountedKernel + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +section + +variable {Ω ι σ J : Type*} + +variable [Fintype J] + +variable [Fintype Ω] + +variable [Fintype ι] + +variable [LinearOrder ι] + +variable [Fintype σ] + +variable {h g : (σ → ℤ) → ℂ} + +variable {lo a : σ → ℤ} + +variable {N : σ → ℕ} + +variable {M : ℕ} + +variable {q : ι → ℕ} + +variable [∀ i, NeZero (q i)] + +variable {j r b moment : ℕ} + +variable {level inc δ η τ L T P : ℝ} + +variable {K : Finset ι} + +variable {base : ∀ i, σ → ZMod (q i)} + +variable (p : FiniteProbabilityWeights Ω) + +variable (F : Ω → ∀ i : {i // i ∉ K}, Option J × σ → ZMod (q i.val)) + +variable (sourceBase : ∀ i : {i // i ∉ K}, Option J × σ → ZMod (q i.val)) + +variable (siteBase : ∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) + +variable {regK κ ε ξ shell modLog : ℝ} + +variable {w rem : Ω → ℝ} + +variable {cs : List (ProductCylinder (fun i : {i // i ∉ K} => Option J × σ → ZMod (q i.val)))} + +variable (hchain : CylinderRemovalChain (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) sourceBase p F regK τ j r w rem cs) + +variable (hregK : 1 ≤ regK) + +variable (hw : ∀ z, 0 ≤ w z ∧ w z ≤ 1) + +variable (hrem : ∀ z, 0 ≤ rem z ∧ rem z ≤ 1) + +variable (hmass : p.mean rem ≤ τ) + +variable (hstable : ResiduePrimeCoordinateStable g lo N M a q (j + r) δ K base) + +variable (hupper : PrimeRefinementUpperBound h g lo N M a q (j + r) level inc δ K base) + +variable (hM : 0 < M) + +variable (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + +variable (hcop : ∀ i ∉ K, M.Coprime (q i)) + +variable (u : ResiduePrimeCoordinateCell lo N M a q K base) + +variable (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + +variable (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + +variable (hlevel : 0 < level) + +variable (hτ : 0 < τ) + +variable (hδ : δ ≤ τ / 8) + +variable (hinc : inc ≤ level * τ / 8) + +variable (hη0 : 0 ≤ η) + +variable (hη : η < 1) + +variable (hητ : η ≤ τ / 8) + +variable (hηlevel : η ≤ level * τ / 8) + +variable (hL : 0 ≤ L) + +variable (hT : 0 ≤ T) + +variable (hlower : Real.exp (-L) ≤ level) + +variable (hτinv : τ⁻¹ ≤ Real.exp T) + +variable (hlog : L + T + 2 ≤ P) + +variable (hrP : ((j + r : ℕ) : ℝ) ≤ P) + +variable (hmoment : 2 ≤ moment) + +variable (heven : Even moment) + +variable (hPq : P ≤ (moment : ℝ)) + +variable (hqP : (moment : ℝ) ≤ P + 2) + +variable (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + +variable (hηsmall : η ≤ (1 / 2) * Real.exp (-((P + 3) ^ 3))) + +variable (herror : ∀ S : Finset {i // i ∉ K}, S.card ≤ j + r → + 2 * (∑ k, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val)) ≤ η) + +variable (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) (fun k => (u.val k).val) + (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) (fun _ => 1)) η + (max ((j + r) * (moment + 1)) (2 * b + j))) + +variable (hgram : 2 * η * ((lowDegreeCoordinateSets {i // i ∉ K} b).card : ℝ) ^ 2 * + (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ 1) + +variable (hsourceclose : ProductMarginalsClose (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) (observedProductDensity (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) p F (fun _ => 1)) η + (max ((j + r) * (moment + 1)) (2 * b + j))) + +variable (hresGram : 2 * η * ((lowDegreeCoordinateSets {i // i ∉ K} b).card : ℝ) ^ 2 * + (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ τ) + +variable (prime power : ι → ℕ) + +variable (hprime : ∀ i, (prime i).Prime) + +variable (hpower : ∀ i, q i = prime i ^ power i) + +variable (hJ : 2 ≤ Fintype.card J) + +variable (hlarge : ∀ i ∉ K, (prime i : ℝ)⁻¹ ≤ κ) + +variable (hε : 0 ≤ ε) + +variable (hξ : 0 < ξ) + +variable (hξ1 : ξ ≤ 1) + +variable (hslack : ξ * (2 + ε) ≤ ε) + +variable (hκ0 : 0 ≤ κ) + +variable (hκhalf : κ ≤ 1 / 2) + +variable (hlow : κ * (8 * (1 + regK) * (P + 2)) ^ 2 * (16 * (P + 2)) ^ 2 ≤ ξ / 16) + +variable (hrtail : CyclicCrootSisask.spectralIterations ξ (L + 2 * T + 4) ≤ r) + +variable (hrb : j + r ≤ b) + +variable (hshell : 0 < shell) + +variable (hb : j + CyclicCrootSisask.spectralIterations shell ((j : ℝ) * (P + ((Fintype.card (Option J × σ) : ℝ) * modLog) + ((Fintype.card σ : ℝ) * modLog) + 2) + ε + L + 2 * T + 10) ≤ b) + +variable (hlevel2 : level ≤ 2) + +variable (hτ1 : τ ≤ 1) + +variable (hmodLog : 0 ≤ modLog) + +variable (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + +include p F sourceBase siteBase hchain hregK hw hrem hmass hstable hupper hM hpair hcop u hg hh hlevel hτ hδ hinc hη0 hη hητ hηlevel hL hT hlower hτinv hlog hrP hmoment heven hPq hqP hcount hηsmall herror hclose hgram hsourceclose hresGram prime power hprime hpower hJ hlarge hε hξ hξ1 hslack hκ0 hκhalf hlow hrtail hrb hshell hb hlevel2 hτ1 hmodLog hmoduli + +theorem stable_residue_affine_total : + let density := fun f => residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f + let μ := primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val) + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} b) (observedProductDensity μ p F w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * τ + shell / 16 + Real.sqrt (3 * τ) * (3 + (1 + ε) * level * 3) := by + let μ := primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val) + have hμ : ∀ i x, 0 < (μ i).weight x := primeCoordinateReference_weight_pos _ + have hsourceAlphabet : ∀ i : {i // i ∉ K}, + (Fintype.card (Option J × σ → ZMod (q i.val)) : ℝ) ≤ + Real.exp ((Fintype.card (Option J × σ) : ℝ) * modLog) := + fun i => by + simpa only [Fintype.card_fun, ZMod.card, Nat.cast_pow] using + (residue_function_alphabet_card_le_exp (I := Option J × σ) (q := q i.val) (hmoduli i.val i.property)) + have hsiteAlphabet : ∀ i : {i // i ∉ K}, (Fintype.card (σ → ZMod (q i.val)) : ℝ) ≤ + Real.exp ((Fintype.card σ : ℝ) * modLog) := + fun i => by + simpa only [Fintype.card_fun, ZMod.card, Nat.cast_pow] using + (residue_function_alphabet_card_le_exp (I := σ) (q := q i.val) (hmoduli i.val i.property)) + have result := stable_residue_counted_kernel_total (Ω := Ω) (ι := ι) (σ := σ) + (h := h) (g := g) (lo := lo) (a := a) (N := N) (M := M) (q := q) + (j := j) (r := r) (b := b) (moment := moment) (level := level) (inc := inc) + (δ := δ) (η := η) (τ := τ) (L := L) (T := T) (P := P) (K := K) (base := base) + (X := fun i : {i // i ∉ K} => Option J × σ → ZMod (q i.val)) + (regK := regK) (κ := κ) (ε := ε) (ξ := ξ) (shell := shell) + (sourceLog := (Fintype.card (Option J × σ) : ℝ) * modLog) + (siteLog := (Fintype.card σ : ℝ) * modLog) (w := w) (rem := rem) (cs := cs) + μ p F sourceBase siteBase hchain hμ hregK hw hrem hmass + hstable hupper hM hpair hcop u hg hh hlevel hτ hδ hinc hη0 hη hητ hηlevel hL hT hlower hτinv + hlog hrP hmoment heven hPq hqP hcount hηsmall herror hclose hgram hsourceclose hresGram + (fun i => affineSampleKernel (J := J) (I := σ) (q := q i.val)) (fun _ => κ ^ 2) + (fun _ => sq_nonneg _) (fun i f hf => affineSampleKernel_centered_sq_of_inverse_le + (hprime i.val) (hpower i.val) hJ hκ0 (hlarge i.val i.property) f hf) + (fun i f => affineSampleKernel_preserves_mean (J := J) (I := σ) (q := q i.val) f) + hε hξ hξ1 hslack hκ0 hκhalf (fun _ => le_rfl) hlow hrtail hrb hshell hb hlevel2 hτ1 + (by positivity) (by positivity) hsourceAlphabet hsiteAlphabet + exact result + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def affineComparisonDegree (sourceDim siteDim : ℕ) (ε L T C shell modLog : ℝ) : ℕ := + let j := affineRemovalDepth T + let r := affineComparisonTail ε L T + let P := affineComparisonScale ε L T C + affineFinalDegree j r shell + ((j : ℝ) * (P + (sourceDim : ℝ) * modLog + (siteDim : ℝ) * modLog + 2) + ε + L + 2 * T + 10) + +section + +variable {Ω ι σ J : Type*} [Fintype J] [Fintype Ω] [Fintype ι] [LinearOrder ι] [Fintype σ] +variable {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} +variable [∀ i, NeZero (q i)] +variable {ε L T C shell modLog level : ℝ} {K : Finset ι} {base : ∀ i, σ → ZMod (q i)} + +variable (p : FiniteProbabilityWeights Ω) + +variable (F : Ω → ∀ i : {i // i ∉ K}, Option J × σ → ZMod (q i.val)) + +variable (sourceBase : ∀ i : {i // i ∉ K}, Option J × σ → ZMod (q i.val)) + +variable (siteBase : ∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) + +variable {w rem : Ω → ℝ} + +variable {cs : List (ProductCylinder (fun i : {i // i ∉ K} => Option J × σ → ZMod (q i.val)))} + +variable (hchain : CylinderRemovalChain (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) sourceBase p F (2 : ℝ) (Real.exp (-T)) (affineRemovalDepth T) (affineComparisonTail ε L T) w rem cs) + +variable (hw : ∀ z, 0 ≤ w z ∧ w z ≤ 1) + +variable (hrem : ∀ z, 0 ≤ rem z ∧ rem z ≤ 1) + +variable (hmass : p.mean rem ≤ (Real.exp (-T))) + +variable (hstable : ResiduePrimeCoordinateStable g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) (affineStabilityTolerance T) K base) + +variable (hupper : PrimeRefinementUpperBound h g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base) + +variable (hM : 0 < M) + +variable (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + +variable (hcop : ∀ i ∉ K, M.Coprime (q i)) + +variable (u : ResiduePrimeCoordinateCell lo N M a q K base) + +variable (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + +variable (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + +variable (hL : 0 ≤ L) + +variable (hT : 0 ≤ T) + +variable (hlower : Real.exp (-L) ≤ level) + +variable (hsourceclose : ProductMarginalsClose (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) (observedProductDensity (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) p F (fun _ => 1)) (affineComparisonAccuracy (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T) + (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)))) + +variable (prime power : ι → ℕ) + +variable (hprime : ∀ i, (prime i).Prime) + +variable (hpower : ∀ i, q i = prime i ^ power i) + +variable (hJ : 2 ≤ Fintype.card J) + +variable (hshell : 0 < shell) + +variable (hlevel2 : level ≤ 2) + +variable (hmodLog : 0 ≤ modLog) + +variable (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + +variable (hε : 0 < ε) +variable (hC : 0 ≤ C) +variable (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) +variable (hmandatory : affineMandatoryPrimes prime (ε / (2 + ε)) (affineComparisonScale ε L T C) ⊆ K) +variable (dimLog : ℝ) +variable (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) +variable (hlength : ∀ k, Real.exp (modLog * (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)) : ℕ) + + affineComparisonAccuracyLog (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) + +include p F sourceBase siteBase hchain hw hrem hmass hstable hupper hM hpair hcop u hg hh hL hT hlower hsourceclose prime power hprime hpower hJ hshell hlevel2 hmodLog hmoduli hε hC hcount hmandatory dimLog hdim hlength + +theorem chosen_stable_residue_affine_total : + let density := fun f => residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f + let μ := primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val) + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog)) (observedProductDensity μ p F w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * (Real.exp (-T)) + shell / 16 + Real.sqrt (3 * (Real.exp (-T))) * (3 + (1 + ε) * level * 3) := by + have hscale := affineComparisonScale_bounds (ε := ε) hL hT hC + have hlargeStep := affineMandatoryPrimes_outside_inverse (ι := ι) (ξ := (ε / (2 + ε))) (P := (affineComparisonScale ε L T C)) + prime hscale.1 K + have hlarge := hlargeStep hmandatory + have hmom := affineComparisonMoment_bounds hscale.1 + have hcnt : (Fintype.card ι : ℝ) ≤ Real.exp (affineComparisonScale ε L T C) := affineComparisonScale_count (ι := ι) (ε := ε) hL hT hC hcount + have hcnt' : (Fintype.card {i // i ∉ K} : ℝ) ≤ Real.exp (affineComparisonScale ε L T C) := + (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans hcnt + have htol := affineComparisonTolerance_bounds hT hlower + have heta := affineComparisonAccuracy_bounds (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) hscale.1 hL hT hlower + have hgram := affineComparisonAccuracy_gram (ι := {i // i ∉ K}) (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) hscale.1 hL hT hcnt' + have hxi := retained_core_allowance_spec hε + have hκ := affineComparisonContraction_bounds hxi.1 hscale.1 + have hdeg := affineFinalDegree_bounds (affineRemovalDepth T) (affineComparisonTail ε L T) shell + (((affineRemovalDepth T) : ℝ) * ((affineComparisonScale ε L T C) + (Fintype.card (Option J × σ) : ℝ) * modLog + + (Fintype.card σ : ℝ) * modLog + 2) + ε + L + 2 * T + 10) + have hs0 := retained_residue_marginals_of_lengths (ι := ι) (σ := σ) + lo N M a q hM hpair K base hcop u + have hs1 := hs0 (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T))) modLog dimLog + (affineComparisonAccuracyLog (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T) (affineComparisonAccuracy (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T) + have hs2 := hs1 hmodLog heta.2.1.le + have he : Real.exp (-affineComparisonAccuracyLog (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T) ≤ (affineComparisonAccuracy (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T) := by + unfold affineComparisonAccuracy + exact le_rfl + have hs3 := hs2 he + have hs4 := hs3 hmoduli hdim + have hsite := hs4 hlength + have hrank : (affineRemovalDepth T) + (affineComparisonTail ε L T) ≤ max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)) := by + have hmul : (affineRemovalDepth T) + (affineComparisonTail ε L T) ≤ ((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1) := by + calc + (affineRemovalDepth T) + (affineComparisonTail ε L T) = ((affineRemovalDepth T) + (affineComparisonTail ε L T)) * 1 := (Nat.mul_one _).symm + _ ≤ ((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1) := Nat.mul_le_mul_left _ (by omega) + exact hmul.trans (le_max_left _ _) + have hc0 := stable_residue_affine_total (Ω := Ω) (ι := ι) (σ := σ) (J := J) + (h := h) (g := g) (lo := lo) (a := a) (N := N) (M := M) (q := q) + (j := (affineRemovalDepth T)) (r := (affineComparisonTail ε L T)) (b := (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog)) (moment := (affineComparisonMoment (affineComparisonScale ε L T C))) (level := level) (inc := (affineIncrementTolerance L T)) + (δ := (affineStabilityTolerance T)) (η := (affineComparisonAccuracy (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T)) (τ := (Real.exp (-T))) (L := L) (T := T) (P := (affineComparisonScale ε L T C)) (K := K) (base := base) + (regK := 2) (κ := (affineComparisonContraction (ε / (2 + ε)) (affineComparisonScale ε L T C))) (ε := ε) (ξ := (ε / (2 + ε))) (shell := shell) (modLog := modLog) + (w := w) (rem := rem) (cs := cs) + p F sourceBase siteBase hchain (by norm_num) hw hrem hmass hstable hupper hM hpair hcop u hg hh + have hc1 := hc0 htol.2.2.2.1 htol.1 htol.2.2.2.2.2.1 htol.2.2.2.2.2.2.2 + heta.1.le heta.2.1 heta.2.2.1 heta.2.2.2.1 hL hT hlower htol.2.2.1 + have hc2 := hc1 hscale.2.1 hscale.2.2.1 hmom.1 hmom.2.1 hmom.2.2.1 hmom.2.2.2 hcnt heta.2.2.2.2 + have hc3 := hc2 (fun S hS => hsite.2 S (hS.trans hrank)) hsite.1 (hgram.trans htol.2.1) hsourceclose hgram + have hc4a := hc3 prime power + have hc4b := hc4a hprime hpower hJ + have hc4 := hc4b hlarge + have hc5 := hc4 hε.le hxi.1 hxi.2.1 hxi.2.2 hκ.1.le hκ.2.1 hκ.2.2 + have htail : CyclicCrootSisask.spectralIterations (ε / (2 + ε)) (L + 2 * T + 4) ≤ (affineComparisonTail ε L T) := by + unfold affineComparisonTail + exact le_rfl + have hc6 := hc5 htail + hdeg.1 hshell hdeg.2 hlevel2 htol.2.1 hmodLog hmoduli + exact hc6 + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem affineComparisonAccuracyLog_mono_degree {b B : ℕ} {P L T : ℝ} + (hb : b ≤ B) (hP : 0 ≤ P) : + affineComparisonAccuracyLog b P L T ≤ affineComparisonAccuracyLog B P L T := by + unfold affineComparisonAccuracyLog + gcongr + +theorem affineComparisonAccuracy_antitone_degree {b B : ℕ} {P L T : ℝ} + (hb : b ≤ B) (hP : 0 ≤ P) : + affineComparisonAccuracy B P L T ≤ affineComparisonAccuracy b P L T := by + apply Real.exp_le_exp.mpr + exact neg_le_neg (affineComparisonAccuracyLog_mono_degree hb hP) + +noncomputable def affineComparisonRequiredOrder (b : ℕ) (ε L T C : ℝ) : ℕ := + max ((affineRemovalDepth T + affineComparisonTail ε L T) * + (affineComparisonMoment (affineComparisonScale ε L T C) + 1)) + (2 * b + affineRemovalDepth T) + +noncomputable def affineComparisonLengthLog (b : ℕ) (ε L T C modLog dimLog : ℝ) : ℝ := + modLog * (affineComparisonRequiredOrder b ε L T C : ℕ) + + affineComparisonAccuracyLog b (affineComparisonScale ε L T C) L T + dimLog + 1 + +theorem affineComparisonRequiredOrder_mono {b B : ℕ} (hb : b ≤ B) (ε L T C : ℝ) : + affineComparisonRequiredOrder b ε L T C ≤ affineComparisonRequiredOrder B ε L T C := by + unfold affineComparisonRequiredOrder + omega + +theorem affineComparisonRequiredOrder_two_mul (b : ℕ) (ε L T C : ℝ) : + 2 * b ≤ affineComparisonRequiredOrder b ε L T C := by + unfold affineComparisonRequiredOrder + omega + +theorem affineComparisonLengthLog_mono_degree {b B : ℕ} {ε L T C modLog dimLog : ℝ} + (hb : b ≤ B) (hP : 0 ≤ affineComparisonScale ε L T C) (hmodLog : 0 ≤ modLog) : + affineComparisonLengthLog b ε L T C modLog dimLog ≤ + affineComparisonLengthLog B ε L T C modLog dimLog := by + unfold affineComparisonLengthLog + have ho : (affineComparisonRequiredOrder b ε L T C : ℝ) ≤ + (affineComparisonRequiredOrder B ε L T C : ℝ) := by + exact_mod_cast affineComparisonRequiredOrder_mono hb ε L T C + have ha := affineComparisonAccuracyLog_mono_degree (L := L) (T := T) hb hP + have hm := mul_le_mul_of_nonneg_left ho hmodLog + linarith + +theorem affineComparisonLengthLog_initial {ε L T C modLog dimLog : ℝ} (B : ℕ) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hmodLog : 0 ≤ modLog) : + modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B (affineComparisonScale ε L T C) 0 0 + dimLog + 1 ≤ + affineComparisonLengthLog B ε L T C modLog dimLog := by + have ho : ((2 * B : ℕ) : ℝ) ≤ (affineComparisonRequiredOrder B ε L T C : ℝ) := by + exact_mod_cast affineComparisonRequiredOrder_two_mul B ε L T C + have ha : affineComparisonAccuracyLog B (affineComparisonScale ε L T C) 0 0 ≤ + affineComparisonAccuracyLog B (affineComparisonScale ε L T C) L T := by + unfold affineComparisonAccuracyLog + linarith + have hm := mul_le_mul_of_nonneg_left ho hmodLog + change _ ≤ _ + dsimp only [affineComparisonLengthLog] + linarith + +theorem affineGlobalCutoff_outside {A B n b : ℕ} (hn : n ≤ A) (hB : A + b ≤ B) : + b ≤ B - n ∧ B - n ≤ B ∧ n ≤ B := by omega + +theorem CyclicCrootSisask.spectralIterations_mono_budget {shell P Q : ℝ} (hPQ : P ≤ Q) : + CyclicCrootSisask.spectralIterations shell P ≤ CyclicCrootSisask.spectralIterations shell Q := by + unfold CyclicCrootSisask.spectralIterations + apply Nat.add_le_add_right + apply Nat.ceil_mono + exact div_le_div_of_nonneg_right (by linarith) (Real.log_pos (by norm_num : (1 : ℝ) < 2)).le + +theorem affineGlobalCutoff_initial {n A B : ℕ} {V W shell : ℝ} + (hn : n ≤ A) (hV : 0 ≤ V) (hW : 0 ≤ W) + (hB : A + CyclicCrootSisask.spectralIterations shell ((A : ℝ) * (V + W + 1) + 4) ≤ B) : + n + CyclicCrootSisask.spectralIterations shell ((n : ℝ) * (V + W + 1) + 4) ≤ B := by + have hn' : (n : ℝ) ≤ A := by exact_mod_cast hn + have hp : (n : ℝ) * (V + W + 1) + 4 ≤ (A : ℝ) * (V + W + 1) + 4 := by gcongr + have hs := CyclicCrootSisask.spectralIterations_mono_budget (shell := shell) hp + omega + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +section + +variable {Ω ι σ J : Type*} [Fintype J] [Fintype Ω] [Fintype ι] [LinearOrder ι] [Fintype σ] +variable {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} +variable [∀ i, NeZero (q i)] +variable {ε L T C shell modLog level : ℝ} {K : Finset ι} {base : ∀ i, σ → ZMod (q i)} + +variable (p : FiniteProbabilityWeights Ω) + +variable (F : Ω → ∀ i : {i // i ∉ K}, Option J × σ → ZMod (q i.val)) + +variable (sourceBase : ∀ i : {i // i ∉ K}, Option J × σ → ZMod (q i.val)) + +variable (siteBase : ∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) + +variable {w : Ω → ℝ} + +variable (hw : ∀ z, 0 ≤ w z ∧ w z ≤ 1) + +variable (hstable : ResiduePrimeCoordinateStable g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) (affineStabilityTolerance T) K base) + +variable (hupper : PrimeRefinementUpperBound h g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base) + +variable (hM : 0 < M) + +variable (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + +variable (hcop : ∀ i ∉ K, M.Coprime (q i)) + +variable (u : ResiduePrimeCoordinateCell lo N M a q K base) + +variable (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + +variable (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + +variable (hL : 0 ≤ L) + +variable (hT : 0 ≤ T) + +variable (hlower : Real.exp (-L) ≤ level) + +variable (hsourceclose : ProductMarginalsClose (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) (observedProductDensity (primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val)) p F (fun _ => 1)) (affineComparisonAccuracy (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T) + (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)))) + +variable (prime power : ι → ℕ) + +variable (hprime : ∀ i, (prime i).Prime) + +variable (hpower : ∀ i, q i = prime i ^ power i) + +variable (hJ : 2 ≤ Fintype.card J) + +variable (hshell : 0 < shell) + +variable (hlevel2 : level ≤ 2) + +variable (hmodLog : 0 ≤ modLog) + +variable (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + +variable (hε : 0 < ε) +variable (hC : 0 ≤ C) +variable (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) +variable (hmandatory : affineMandatoryPrimes prime (ε / (2 + ε)) (affineComparisonScale ε L T C) ⊆ K) +variable (dimLog : ℝ) +variable (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) +variable (hlength : ∀ k, Real.exp (modLog * (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)) : ℕ) + + affineComparisonAccuracyLog (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) + +include p F sourceBase siteBase hw hstable hupper hM hpair hcop u hg hh hL hT hlower hsourceclose prime power hprime hpower hJ hshell hlevel2 hmodLog hmoduli hε hC hcount hmandatory dimLog hdim hlength + +theorem chosen_stable_affine_from_source_marginals : + let density := fun f => residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f + let μ := primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val) + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog)) (observedProductDensity μ p F w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * (Real.exp (-T)) + shell / 16 + Real.sqrt (3 * (Real.exp (-T))) * (3 + (1 + ε) * level * 3) := by + let j := affineRemovalDepth T + let r := affineComparisonTail ε L T + let P := affineComparisonScale ε L T C + let b := affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog + let η := affineComparisonAccuracy b P L T + let μ := primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val) + have hscale := affineComparisonScale_bounds (ε := ε) hL hT hC + have heta := affineComparisonAccuracy_bounds b hscale.1 hL hT hlower + have hrank : j + r ≤ max ((j + r) * (affineComparisonMoment P + 1)) (2 * b + j) := by + have hm : j + r ≤ (j + r) * (affineComparisonMoment P + 1) := by + calc + j + r = (j + r) * 1 := (Nat.mul_one _).symm + _ ≤ _ := Nat.mul_le_mul_left _ (by omega) + exact hm.trans (le_max_left _ _) + obtain ⟨rem, cs, hchain, _, hmass, hrem⟩ := + exists_finite_cylinder_removal μ (primeCoordinateReference_weight_pos _) + sourceBase p F 2 (Real.exp (-T)) η j r (by norm_num) (Real.exp_pos _).le heta.2.1.le + (affineRemovalDepth_cutoff T) (ProductMarginalsClose.mono μ hsourceclose hrank) + w (fun z => (hw z).1) (fun z => (hw z).2) + have hc := chosen_stable_residue_affine_total (Ω := Ω) (ι := ι) (σ := σ) (J := J) + (h := h) (g := g) (lo := lo) (a := a) (N := N) (M := M) (q := q) + (ε := ε) (L := L) (T := T) (C := C) (shell := shell) (modLog := modLog) + (level := level) (K := K) (base := base) (w := w) (rem := rem) (cs := cs) + p F sourceBase siteBase hchain hw hrem hmass hstable hupper hM hpair hcop u hg hh + exact hc hL hT hlower hsourceclose prime power hprime hpower hJ hshell hlevel2 + hmodLog hmoduli hε hC hcount hmandatory dimLog hdim hlength + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem affineComparisonLengthLog_nonneg {ε L T C modLog dimLog : ℝ} (B : ℕ) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmodLog : 0 ≤ modLog) (hdim : 0 ≤ dimLog) : + 0 ≤ affineComparisonLengthLog B ε L T C modLog dimLog := by + have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1 + unfold affineComparisonLengthLog affineComparisonAccuracyLog + positivity + +theorem affineComparisonLengthLog_base_order {A B : ℕ} {ε L T C modLog dimLog : ℝ} + (hAB : A ≤ B) (hmodLog : 0 ≤ modLog) : + modLog * A + affineComparisonAccuracyLog B (affineComparisonScale ε L T C) L T + dimLog + 1 ≤ + affineComparisonLengthLog B ε L T C modLog dimLog := by + have horder := affineComparisonRequiredOrder_two_mul B ε L T C + have hnat : A ≤ affineComparisonRequiredOrder B ε L T C := by omega + have hreal : (A : ℝ) ≤ (affineComparisonRequiredOrder B ε L T C : ℝ) := by exact_mod_cast hnat + have hm := mul_le_mul_of_nonneg_left hreal hmodLog + unfold affineComparisonLengthLog + linarith + +theorem residuePrime_retained_length_uniform {ι : Type*} [DecidableEq ι] + (q : ι → ℕ) (hqpos : ∀ i, 0 < q i) (M : ℕ) (hM : 0 < M) + (K : Finset ι) {A : ℕ} (hK : K.card ≤ A) + {periodLog modLog targetLog : ℝ} (hmodLog : 0 ≤ modLog) (htarget : 0 ≤ targetLog) + (hperiod : (M : ℝ) ≤ Real.exp periodLog) (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (lo anchor : ℤ) (N : ℕ) + (hside : Real.exp (periodLog + modLog * A + targetLog + 2) ≤ (N : ℝ)) : + Real.exp targetLog ≤ (residueIndexLength lo (lo + N) (M.lcm (∏ i ∈ K, q i)) anchor : ℝ) := by + have hm := residuePrimeModulus_le_exp q hqpos K M hM periodLog modLog (A : ℝ) + hmodLog hperiod hmoduli (by exact_mod_cast hK) + have hpos : 0 < M.lcm (∏ i ∈ K, q i) := + Nat.pos_of_ne_zero (Nat.lcm_ne_zero hM.ne' (Finset.prod_pos (fun i _ => hqpos i)).ne') + exact residueIndexLength_large_of_exp lo anchor N _ _ targetLog hpos htarget hm hside + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +section + +variable {ι σ J : Type*} [Fintype J] [Fintype ι] [LinearOrder ι] [Fintype σ] +variable {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} +variable [∀ i, NeZero (q i)] +variable {ε L T C shell modLog level : ℝ} {K : Finset ι} {base : ∀ i, σ → ZMod (q i)} + +variable (hstable : ResiduePrimeCoordinateStable g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) (affineStabilityTolerance T) K base) + +variable (hupper : PrimeRefinementUpperBound h g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base) + +variable (hM : 0 < M) + +variable (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + +variable (hcop : ∀ i ∉ K, M.Coprime (q i)) + +variable (u : ResiduePrimeCoordinateCell lo N M a q K base) + +variable (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + +variable (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + +variable (hL : 0 ≤ L) + +variable (hT : 0 ≤ T) + +variable (hlower : Real.exp (-L) ≤ level) + +variable (prime power : ι → ℕ) + +variable (hprime : ∀ i, (prime i).Prime) + +variable (hpower : ∀ i, q i = prime i ^ power i) + +variable (hJ : 2 ≤ Fintype.card J) + +variable (hshell : 0 < shell) + +variable (hlevel2 : level ≤ 2) + +variable (hmodLog : 0 ≤ modLog) + +variable (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + +variable (hε : 0 < ε) +variable (hC : 0 ≤ C) +variable (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) +variable (hmandatory : affineMandatoryPrimes prime (ε / (2 + ε)) (affineComparisonScale ε L T C) ⊆ K) +variable (dimLog : ℝ) +variable (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) +variable (hlength : ∀ k, Real.exp (modLog * (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)) : ℕ) + + affineComparisonAccuracyLog (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) + +variable (sourceLo sourceA : Option J × σ → ℤ) (sourceN : Option J × σ → ℕ) (sourceM : ℕ) +variable (sourceNonempty : Nonempty (IntegerResidueBox sourceLo + (fun k => sourceLo k + sourceN k) (fun _ => (sourceM : ℤ)) sourceA)) +variable (w : (Option J × σ → ℤ) → ℝ) +variable (hw : ∀ z : IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k) + (fun _ => (sourceM : ℤ)) sourceA, + 0 ≤ w (fun k => (z k).val) ∧ w (fun k => (z k).val) ≤ 1) +variable (hsourceM : 0 < sourceM) +variable (hsourceCop : ∀ i ∉ K, sourceM.Coprime (q i)) +variable (sourceDimLog : ℝ) +variable (hsourceDim : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp sourceDimLog) +variable (hsourceLength : ∀ k, Real.exp (modLog * + (max ((affineRemovalDepth T + affineComparisonTail ε L T) * + (affineComparisonMoment (affineComparisonScale ε L T C) + 1)) + (2 * affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog + affineRemovalDepth T) : ℕ) + + affineComparisonAccuracyLog + (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineComparisonScale ε L T C) L T + sourceDimLog + 1) ≤ + (residueIndexLength (sourceLo k) (sourceLo k + sourceN k) sourceM (sourceA k) : ℝ)) + +include hstable hupper hM hpair hcop u hg hh hL hT hlower prime power hprime hpower hJ hshell hlevel2 hmodLog hmoduli hε hC hcount hmandatory dimLog hdim hlength sourceLo sourceA sourceN sourceM sourceNonempty w hw hsourceM hsourceCop sourceDimLog hsourceDim hsourceLength + +theorem residue_source_stable_affine_comparison : + let density := fun f => residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog)) (residuePrimeCoordinateDensity sourceLo sourceN sourceM sourceA sourceNonempty + (fun i : {i // i ∉ K} => q i.val) w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * (Real.exp (-T)) + shell / 16 + Real.sqrt (3 * (Real.exp (-T))) * (3 + (1 + ε) * level * 3) := by + let P := affineComparisonScale ε L T C + let b := affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog + let η := affineComparisonAccuracy b P L T + let R := max ((affineRemovalDepth T + affineComparisonTail ε L T) * (affineComparisonMoment P + 1)) + (2 * b + affineRemovalDepth T) + let μ := primeCoordinateReference (σ := Option J × σ) (fun i : {i // i ∉ K} => q i.val) + let p := @FiniteProbabilityWeights.uniform + (IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k) (fun _ => (sourceM : ℤ)) sourceA) _ sourceNonempty + let F := fun z : IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k) + (fun _ => (sourceM : ℤ)) sourceA => + primeCoordinateObservation (fun i : {i // i ∉ K} => q i.val) (fun k => (z k).val) + have hscale := affineComparisonScale_bounds (ε := ε) hL hT hC + have heta := affineComparisonAccuracy_bounds b hscale.1 hL hT hlower + have hpair' : Pairwise (fun i k : {i // i ∉ K} => (q i.val).Coprime (q k.val)) := + fun i k hik => hpair (fun heq => hik (Subtype.ext heq)) + have hsrc0 := residuePrimeDensity_close_of_lengths (ι := {i // i ∉ K}) (σ := Option J × σ) + sourceLo sourceN sourceM sourceA sourceNonempty (fun i : {i // i ∉ K} => q i.val) + hsourceM (fun i => hsourceCop i.val i.property) hpair' + R modLog sourceDimLog (affineComparisonAccuracyLog b P L T) η + have he : Real.exp (-affineComparisonAccuracyLog b P L T) ≤ η := by + unfold η affineComparisonAccuracy + exact le_rfl + have hsrc1 := hsrc0 hmodLog heta.2.1.le he + have hsrc := hsrc1 (fun i => hmoduli i.val i.property) hsourceDim hsourceLength + change ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η R at hsrc + have hc := chosen_stable_affine_from_source_marginals + (Ω := IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k) (fun _ => (sourceM : ℤ)) sourceA) + (ι := ι) (σ := σ) (J := J) (h := h) (g := g) (lo := lo) (a := a) (N := N) (M := M) (q := q) + (ε := ε) (L := L) (T := T) (C := C) (shell := shell) (modLog := modLog) + (level := level) (K := K) (base := base) (w := fun z => w (fun k => (z k).val)) + p F (fun _ _ => 0) (fun _ _ => 0) hw hstable hupper hM hpair hcop u hg hh hL hT hlower + exact hc hsrc prime power hprime hpower hJ hshell hlevel2 hmodLog hmoduli hε hC + hcount hmandatory dimLog hdim hlength + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem unconditioned_affine_cell_bounds {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (1 : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + {A B : ℕ} (hAB : A ≤ B) {ε L T C modLog dimLog : ℝ} + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmodLog : 0 ≤ modLog) (hdimLog : 0 ≤ dimLog) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) + (hside : ∀ k, Real.exp (modLog * A + affineComparisonLengthLog B ε L T C modLog dimLog + 2) ≤ (N k : ℝ)) : + ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (residuePrimeCoordinateDensity lo N 1 a hne q (fun _ => 1)) + (affineComparisonAccuracy B (affineComparisonScale ε L T C) L T) A ∧ + (∀ (K : Finset ι), K.card ≤ A → ∀ base : ∀ i, σ → ZMod (q i), + Nonempty (ResiduePrimeCoordinateCell lo N 1 a q K base)) ∧ + (∀ (K : Finset ι), K.card ≤ A → ∀ (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N 1 a q K base) (k : σ), + Real.exp (affineComparisonLengthLog B ε L T C modLog dimLog) ≤ + (residueIndexLength (lo k) (lo k + N k) (Nat.lcm 1 (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) := by + have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1 + have heta := affineComparisonAccuracy_bounds (level := Real.exp (-L)) B hP hL hT le_rfl + have hlog := affineComparisonLengthLog_nonneg (ε := ε) B hL hT hC hmodLog hdimLog + have hret (K : Finset ι) (hK : K.card ≤ A) (anchor : ℤ) (k : σ) : + Real.exp (affineComparisonLengthLog B ε L T C modLog dimLog) ≤ + (residueIndexLength (lo k) (lo k + N k) (Nat.lcm 1 (∏ i ∈ K, q i)) anchor : ℝ) := by + apply residuePrime_retained_length_uniform q (fun i => Nat.pos_of_ne_zero (NeZero.ne (q i))) 1 + (by decide) K hK hmodLog hlog (periodLog := 0) (by simp) hmoduli + simpa only [zero_add] using hside k + have hbase (k : σ) : + Real.exp (modLog * A + affineComparisonAccuracyLog B (affineComparisonScale ε L T C) L T + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) 1 (a k) : ℝ) := by + apply (Real.exp_le_exp.mpr (affineComparisonLengthLog_base_order hAB hmodLog)).trans + simpa using hret ∅ (by simp) (a k) k + have hclose := residuePrimeDensity_close_of_lengths lo N 1 a hne q (by decide) (by simp) hpair + A modLog dimLog (affineComparisonAccuracyLog B (affineComparisonScale ε L T C) L T) + (affineComparisonAccuracy B (affineComparisonScale ε L T C) L T) hmodLog heta.2.1.le + (by exact le_rfl) hmoduli hdim hbase + refine ⟨hclose, ?_, ?_⟩ + · intro K hK base + exact residuePrimeCoordinateCell_nonempty_of_marginals lo N 1 a hne q hclose heta.2.1 K hK base + · intro K hK base u k + exact hret K hK ((u.val k).val) k + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +section + +variable {ι σ J : Type*} [Fintype J] [Fintype ι] [LinearOrder ι] [Fintype σ] +variable {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} +variable [∀ i, NeZero (q i)] +variable {ε L T C shell modLog level : ℝ} {K : Finset ι} {base : ∀ i, σ → ZMod (q i)} + +variable (hstable : ResiduePrimeCoordinateStable g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) (affineStabilityTolerance T) K base) + +variable (hupper : PrimeRefinementUpperBound h g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base) + +variable (hM : 0 < M) + +variable (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + +variable (hcop : ∀ i ∉ K, M.Coprime (q i)) + +variable (u : ResiduePrimeCoordinateCell lo N M a q K base) + +variable (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + +variable (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + +variable (hL : 0 ≤ L) + +variable (hT : 0 ≤ T) + +variable (hlower : Real.exp (-L) ≤ level) + +variable (prime power : ι → ℕ) + +variable (hprime : ∀ i, (prime i).Prime) + +variable (hpower : ∀ i, q i = prime i ^ power i) + +variable (hJ : 2 ≤ Fintype.card J) + +variable (hshell : 0 < shell) + +variable (hlevel2 : level ≤ 2) + +variable (hmodLog : 0 ≤ modLog) + +variable (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + +variable (hε : 0 < ε) +variable (hC : 0 ≤ C) +variable (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) +variable (hmandatory : affineMandatoryPrimes prime (ε / (2 + ε)) (affineComparisonScale ε L T C) ⊆ K) +variable (dimLog : ℝ) +variable (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) +variable (hlength : ∀ k, Real.exp (modLog * (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)) : ℕ) + + affineComparisonAccuracyLog (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) + +variable (sourceLo sourceA : Option J × σ → ℤ) (sourceN : Option J × σ → ℕ) (sourceM : ℕ) +variable (sourceBase : ∀ i, Option J × σ → ZMod (q i)) +variable (sourceCell : ResiduePrimeCoordinateCell sourceLo sourceN sourceM sourceA q K sourceBase) +variable (w : (Option J × σ → ℤ) → ℝ) +variable (hw : ∀ z : ResiduePrimeCoordinateCell sourceLo sourceN sourceM sourceA q K sourceBase, + 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1) +variable (hsourceM : 0 < sourceM) +variable (hsourceCop : ∀ i ∉ K, sourceM.Coprime (q i)) +variable (sourceDimLog : ℝ) +variable (hsourceDim : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp sourceDimLog) +variable (hsourceLength : ∀ k, Real.exp (modLog * + (max ((affineRemovalDepth T + affineComparisonTail ε L T) * + (affineComparisonMoment (affineComparisonScale ε L T C) + 1)) + (2 * affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog + affineRemovalDepth T) : ℕ) + + affineComparisonAccuracyLog + (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineComparisonScale ε L T C) L T + sourceDimLog + 1) ≤ + (residueIndexLength (sourceLo k) (sourceLo k + sourceN k) (sourceM.lcm (∏ i ∈ K, q i)) ((sourceCell.val k).val) : ℝ)) + +include hstable hupper hM hpair hcop u hg hh hL hT hlower prime power hprime hpower hJ hshell hlevel2 hmodLog hmoduli hε hC hcount hmandatory dimLog hdim hlength sourceLo sourceA sourceN sourceM sourceBase sourceCell w hw hsourceM hsourceCop sourceDimLog hsourceDim hsourceLength + +theorem conditioned_source_stable_affine_comparison : + let density := fun f => residueCellOutsideDensity lo N M a q K base u f + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog)) (residueCellOutsideDensity sourceLo sourceN sourceM sourceA q K sourceBase sourceCell w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * (Real.exp (-T)) + shell / 16 + Real.sqrt (3 * (Real.exp (-T))) * (3 + (1 + ε) * level * 3) := by + let e := residuePrimeCoordinateCell_lcmEquiv sourceLo sourceN sourceM sourceA q hpair K sourceBase sourceCell + have hQ : 0 < sourceM.lcm (∏ i ∈ K, q i) := + Nat.pos_of_ne_zero (Nat.lcm_ne_zero hsourceM.ne' + (Finset.prod_pos (fun i _ => Nat.pos_of_ne_zero (NeZero.ne (q i)))).ne') + have hQcop : ∀ i ∉ K, (sourceM.lcm (∏ k ∈ K, q k)).Coprime (q i) := + fun i hi => selectedCombined_coprime_outside q hpair sourceM K hsourceCop i hi + have hw' (z : IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k) + (fun _ => (sourceM.lcm (∏ i ∈ K, q i) : ℤ)) (fun k => (sourceCell.val k).val)) : + 0 ≤ w (fun k => (z k).val) ∧ w (fun k => (z k).val) ≤ 1 := + hw (e.symm z) + have result := residue_source_stable_affine_comparison (ι := ι) (σ := σ) (J := J) + (h := h) (g := g) (lo := lo) (a := a) (N := N) (M := M) (q := q) + (ε := ε) (L := L) (T := T) (C := C) (shell := shell) (modLog := modLog) + (level := level) (K := K) (base := base) + (hstable := hstable) (hupper := hupper) (hM := hM) (hpair := hpair) (hcop := hcop) + (u := u) (hg := hg) (hh := hh) (hL := hL) (hT := hT) (hlower := hlower) + (prime := prime) (power := power) (hprime := hprime) (hpower := hpower) (hJ := hJ) + (hshell := hshell) (hlevel2 := hlevel2) (hmodLog := hmodLog) (hmoduli := hmoduli) + (hε := hε) (hC := hC) (hcount := hcount) (hmandatory := hmandatory) + (dimLog := dimLog) (hdim := hdim) (hlength := hlength) + (sourceLo := sourceLo) (sourceN := sourceN) (sourceM := sourceM.lcm (∏ i ∈ K, q i)) + (sourceA := fun k => (sourceCell.val k).val) + (sourceNonempty := residuePrimeCoordinateCell_lcm_nonempty sourceLo sourceN sourceM sourceA q hpair K sourceBase sourceCell) + (w := w) (hw := hw') (hsourceM := hQ) (hsourceCop := hQcop) + (sourceDimLog := sourceDimLog) (hsourceDim := hsourceDim) (hsourceLength := hsourceLength) + have hsrc := residueCellOutsideDensity_lcm sourceLo sourceN sourceM sourceA q hpair K sourceBase sourceCell w + have hsiteH := residueCellOutsideDensity_lcm lo N M a q hpair K base u (fun x => (h x).re) + have hsiteG := residueCellOutsideDensity_lcm lo N M a q hpair K base u (fun x => (g x).re) + have htest := congrArg₂ + (fun f g : (∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) → ℝ => + fun z => f z - (1 + ε) * level * g z) hsiteH hsiteG + have heq := congrArg₂ + (affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} + (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog))) + hsrc htest + exact heq.trans_le result + +end + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +section + +variable {ι σ J : Type*} [Fintype J] [Fintype ι] [LinearOrder ι] [Fintype σ] +variable {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} +variable [∀ i, NeZero (q i)] +variable {ε L T C shell modLog level : ℝ} {K : Finset ι} {base : ∀ i, σ → ZMod (q i)} + +variable (hstable : ResiduePrimeCoordinateStable g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) (affineStabilityTolerance T) K base) + +variable (hupper : PrimeRefinementUpperBound h g lo N M a q ((affineRemovalDepth T) + (affineComparisonTail ε L T)) level (affineIncrementTolerance L T) (affineStabilityTolerance T) K base) + +variable (hM : 0 < M) + +variable (u : ResiduePrimeCoordinateCell lo N M a q K base) + +variable (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + +variable (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + +variable (hL : 0 ≤ L) + +variable (hT : 0 ≤ T) + +variable (hlower : Real.exp (-L) ≤ level) + +variable (prime power : ι → ℕ) + +variable (hprime : ∀ i, (prime i).Prime) + +variable (hpower : ∀ i, q i = prime i ^ power i) + +variable (hJ : 2 ≤ Fintype.card J) + +variable (hshell : 0 < shell) + +variable (hlevel2 : level ≤ 2) + +variable (hmodLog : 0 ≤ modLog) + +variable (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + +variable (hε : 0 < ε) +variable (hC : 0 ≤ C) +variable (hcount : (Fintype.card ι : ℝ) ≤ Real.exp C) +variable (dimLog : ℝ) +variable (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) +variable (hlength : ∀ k, Real.exp (modLog * (max (((affineRemovalDepth T) + (affineComparisonTail ε L T)) * ((affineComparisonMoment (affineComparisonScale ε L T C)) + 1)) (2 * (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineRemovalDepth T)) : ℕ) + + affineComparisonAccuracyLog (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) (affineComparisonScale ε L T C) L T + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) + +variable (sourceLo sourceA : Option J × σ → ℤ) (sourceN : Option J × σ → ℕ) (sourceM : ℕ) +variable (sourceBase : ∀ i, Option J × σ → ZMod (q i)) +variable (sourceCell : ResiduePrimeCoordinateCell sourceLo sourceN sourceM sourceA q K sourceBase) +variable (w : (Option J × σ → ℤ) → ℝ) +variable (hw : ∀ z : ResiduePrimeCoordinateCell sourceLo sourceN sourceM sourceA q K sourceBase, + 0 ≤ w (fun k => (z.val k).val) ∧ w (fun k => (z.val k).val) ≤ 1) +variable (hsourceM : 0 < sourceM) +variable (sourceDimLog : ℝ) +variable (hsourceDim : (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp sourceDimLog) +variable (hsourceLength : ∀ k, Real.exp (modLog * + (max ((affineRemovalDepth T + affineComparisonTail ε L T) * + (affineComparisonMoment (affineComparisonScale ε L T C) + 1)) + (2 * affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog + affineRemovalDepth T) : ℕ) + + affineComparisonAccuracyLog + (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog) + (affineComparisonScale ε L T C) L T + sourceDimLog + 1) ≤ + (residueIndexLength (sourceLo k) (sourceLo k + sourceN k) (sourceM.lcm (∏ i ∈ K, q i)) ((sourceCell.val k).val) : ℝ)) + +variable (hinj : Function.Injective prime) +variable (hmask : affineInitialPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) sourceM M ⊆ K) + +include hstable hupper hM u hg hh hL hT hlower prime power hprime hpower hJ hshell hlevel2 hmodLog hmoduli hε hC hcount dimLog hdim hlength sourceLo sourceA sourceN sourceM sourceBase sourceCell w hw hsourceM sourceDimLog hsourceDim hsourceLength hinj hmask + +theorem initial_masked_affine_comparison : + let density := fun f => residueCellOutsideDensity lo N M a q K base u f + affineResidueTruncatedPairing (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) + (lowDegreeCoordinateSets {i // i ∉ K} (affineComparisonDegree (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C shell modLog)) (residueCellOutsideDensity sourceLo sourceN sourceM sourceA q K sourceBase sourceCell w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * (Real.exp (-T)) + shell / 16 + Real.sqrt (3 * (Real.exp (-T))) * (3 + (1 + ε) * level * 3) := by + have hpair : Pairwise (fun i k => (q i).Coprime (q k)) := by + intro i k hik + rw [hpower i, hpower k] + exact selectedPrimePowers_pairwise_coprime prime power hprime hinj hik + have hboth := affineInitialPrimeMask_outside_coprime (ι := ι) prime power hprime + (ξ := ε / (2 + ε)) (P := affineComparisonScale ε L T C) (sourceM := sourceM) (siteM := M) K hmask + have hcop : ∀ i ∉ K, M.Coprime (q i) := by + intro i hi + rw [hpower i] + exact (hboth i hi).2 + have hsourceCop : ∀ i ∉ K, sourceM.Coprime (q i) := by + intro i hi + rw [hpower i] + exact (hboth i hi).1 + have hmandatory := + (affineInitialPrimeMask_contains prime (ε / (2 + ε)) (affineComparisonScale ε L T C) sourceM M).1.trans hmask + exact conditioned_source_stable_affine_comparison + (ι := ι) (σ := σ) (J := J) (h := h) + (g := g) (lo := lo) (a := a) (N := N) + (M := M) (q := q) (ε := ε) (L := L) + (T := T) (C := C) (shell := shell) (modLog := modLog) + (level := level) (K := K) (base := base) (hstable := hstable) + (hupper := hupper) (hM := hM) (hpair := hpair) (hcop := hcop) + (u := u) (hg := hg) (hh := hh) (hL := hL) + (hT := hT) (hlower := hlower) (prime := prime) (power := power) + (hprime := hprime) (hpower := hpower) (hJ := hJ) (hshell := hshell) + (hlevel2 := hlevel2) (hmodLog := hmodLog) (hmoduli := hmoduli) (hε := hε) + (hC := hC) (hcount := hcount) (hmandatory := hmandatory) (dimLog := dimLog) + (hdim := hdim) (hlength := hlength) (sourceLo := sourceLo) (sourceN := sourceN) + (sourceM := sourceM) (sourceA := sourceA) (sourceBase := sourceBase) (sourceCell := sourceCell) + (w := w) (hw := hw) (hsourceM := hsourceM) (hsourceCop := hsourceCop) + (sourceDimLog := sourceDimLog) (hsourceDim := hsourceDim) (hsourceLength := hsourceLength) + +end + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/InjectiveSmallPrimeProduct.lean b/lean/OAI/Combinatorics/Progressions/Lattices/InjectiveSmallPrimeProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a6f8451097998c289b8af7d73063d5c7f31c2b0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/InjectiveSmallPrimeProduct.lean @@ -0,0 +1,43 @@ +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Data.Finset.Card +import Mathlib.Data.Finset.Range + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem card_filter_le_cutoff_of_injective + {L : Type*} [Fintype L] (p : L → ℕ) (hp : Function.Injective p) + (cutoff : ℕ) : + (Finset.univ.filter (fun l => p l ≤ cutoff)).card ≤ cutoff + 1 := by + classical + have hcard := Finset.card_le_card_of_injOn + (s := Finset.univ.filter (fun l => p l ≤ cutoff)) + (t := Finset.range (cutoff + 1)) p + (fun l hl => Finset.mem_range.mpr + (Nat.lt_succ_of_le (Finset.mem_filter.mp hl).2)) + (fun _ _ _ _ heq => hp heq) + simpa only [Finset.card_range] using hcard + +theorem prod_filter_le_cutoff_pow_of_injective + {L : Type*} [Fintype L] (p : L → ℕ) (hp : Function.Injective p) + (cutoff : ℕ) : + (∏ l ∈ Finset.univ.filter (fun l => p l ≤ cutoff), p l) ≤ + (cutoff + 1) ^ (cutoff + 1) := by + classical + calc + _ ≤ (cutoff + 1) ^ (Finset.univ.filter (fun l => p l ≤ cutoff)).card := + Finset.prod_le_pow_card _ p (cutoff + 1) + (fun l hl => (Finset.mem_filter.mp hl).2.trans (Nat.le_succ cutoff)) + _ ≤ _ := Nat.pow_le_pow_right (Nat.succ_pos cutoff) + (card_filter_le_cutoff_of_injective p hp cutoff) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/InputQuantitativeAffineL1.lean b/lean/OAI/Combinatorics/Progressions/Lattices/InputQuantitativeAffineL1.lean new file mode 100644 index 0000000000000000000000000000000000000000..4292ed6cc655fffb58dd4b16efc2ae25f96e6095 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/InputQuantitativeAffineL1.lean @@ -0,0 +1,85 @@ +import OAI.Combinatorics.Progressions.Lattices.AveragedAffineGrid + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal ContDiff BigOperators + +theorem exists_averaged_affine_l1_from_input_bounds + {W D G Z α : Type*} [MeasurableSpace W] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J N : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (Sum.elim (eK d) (eN d))) + (index : ∀ d, B d → J d ⊕ N d) + (hindex : ∀ d b, Sum.elim (eK d) (eN d) (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d ⊕ N d → ℝ) (hw : ∀ d j, 0 < w d j) + (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) + (z : W → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A L : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith L Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (Sum.elim (eK d) (eN d) j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) {P E : ℝ} (hP : 0 ≤ P) + (hE : 0 ≤ E) + (hcP : ∀ d, (c₀ d)⁻¹ ≤ Real.exp P) (hCP : ∀ d, C d ≤ Real.exp P) + (hAP : (A : ℝ) ≤ Real.exp P) (hLP : (L : ℝ) ≤ Real.exp P) + (hCsumP : Csum ≤ Real.exp P) (hWsumP : Wsum ≤ Real.exp P) + (hεE : ε⁻¹ ≤ Real.exp E) : + let P' := affineComparisonInputLog (B := B) (O := O) (α := α) + (AffineAuxiliaryIndex Z (fun d => J d ⊕ N d)) h degree P E + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ)⁻¹ ≤ Real.exp (2*P'+2) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t⁻¹ ≤ Real.exp (6*P'+8) ∧ + ∀ (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) + (T : SamplerTupleIndex G B h → ℝ), (∀ k, 0 < T k) → + (∀ a x d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) (z a) x) (sets d)) → + ∀ μ : Measure W, IsProbabilityMeasure μ → (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + (∫ p : W × ((Σ d, O d) → ℝ), + |averagedRegularizedIdeal h (fun d => Sum.elim (eK d) (eN d)) index c w sets δ p.2 - + smallAffineMixtureDensity h eK eN s E F sets extra c w t z p.1 p.2| ∂μ.prod volume) ≤ ε := by + obtain ⟨hNoise, hm, hK, hM, hQbudget, hAccuracy⟩ := + affineComparisonInputLog_bounds (B := B) (O := O) (α := α) + (AffineAuxiliaryIndex Z (fun d => J d ⊕ N d)) h hh c₀ C hc₀ hC A L degree + hCsum hWsum hε hP hE hcP hCP hAP hLP hCsumP hWsumP hεE + exact exists_averaged_affine_l1_with_parameter_bounds + h hh eK eN he index hindex c w hw R hsupport z hz sets hsets hcard block hblock + c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A L hLip hTransition extra + hdegree htaildegree hCsum hWsum hcsum hwsum hε + (affineComparisonInputLog_nonneg (B := B) (O := O) (α := α) + (AffineAuxiliaryIndex Z (fun d => J d ⊕ N d)) h degree hP hE) + hNoise hm hK hM hQbudget hAccuracy + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAbsInterval.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAbsInterval.lean new file mode 100644 index 0000000000000000000000000000000000000000..214dd4a5b1302d595ddc5d97d3c26de377519420 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAbsInterval.lean @@ -0,0 +1,49 @@ +import Mathlib.Algebra.Order.AbsoluteValue.Basic +import Mathlib.Algebra.Order.Floor.Ring +import Mathlib.Data.Int.Interval +import Mathlib.Data.Rat.Floor +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def integerAbsInterval (B : ℝ) : Finset ℤ := + Finset.Icc (-⌊B⌋) ⌊B⌋ + +theorem mem_integerAbsInterval (B : ℝ) (z : ℤ) : + z ∈ integerAbsInterval B ↔ |(z : ℝ)| ≤ B := by + rw [integerAbsInterval, Finset.mem_Icc, abs_le] + constructor + · rintro ⟨hlo, hhi⟩ + have hn : -z ≤ ⌊B⌋ := by omega + have hn' := Int.le_floor.mp hn + have hp := Int.le_floor.mp hhi + push_cast at hn' + exact ⟨by linarith, hp⟩ + · rintro ⟨hlo, hhi⟩ + have hn : (-z : ℤ) ≤ ⌊B⌋ := Int.le_floor.mpr (by push_cast; linarith) + exact ⟨by omega, Int.le_floor.mpr hhi⟩ + +theorem integerAbsInterval_card_le (B : ℝ) (hB : 0 ≤ B) : + ((integerAbsInterval B).card : ℝ) ≤ 2 * B + 1 := by + have hf : (0 : ℤ) ≤ ⌊B⌋ := Int.floor_nonneg.mpr hB + have hc : ((integerAbsInterval B).card : ℤ) = 2 * ⌊B⌋ + 1 := by + rw [integerAbsInterval, Int.card_Icc] + omega + have hc' : ((integerAbsInterval B).card : ℝ) = 2 * (⌊B⌋ : ℝ) + 1 := by + exact_mod_cast hc + rw [hc'] + linarith [Int.floor_le B] + +theorem integerAbsInterval_card_le_three (B : ℝ) (hB : 1 ≤ B) : + ((integerAbsInterval B).card : ℝ) ≤ 3 * B := + (integerAbsInterval_card_le B (by linarith)).trans (by linarith) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineRemainder.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..d323252b7fbb66ab626998a15b494aaa8417d2fd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineRemainder.lean @@ -0,0 +1,96 @@ +import Mathlib.Algebra.MvPolynomial.NoZeroDivisors +import OAI.Combinatorics.Progressions.Estimates.RationalRowReduction +import OAI.Combinatorics.Progressions.Estimates.ScalarExtensionSubstitution + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +theorem exists_integer_affine_remainder {I : Type*} + (P : MvPolynomial I ℤ) (r : I → ℤ) (a : ℤ) : + ∃ Q : MvPolynomial I ℤ, + aeval (fun i => C (r i) + C a * X i) P = C (eval r P) + C a * Q := by + induction P using MvPolynomial.induction_on with + | C c => exact ⟨0, by simp⟩ + | add P S hP hS => + obtain ⟨Q, hQ⟩ := hP + obtain ⟨T, hT⟩ := hS + refine ⟨Q + T, ?_⟩ + simp only [map_add, hQ, hT] + ring + | mul_X P i hP => + obtain ⟨Q, hQ⟩ := hP + refine ⟨Q * (C (r i) + C a * X i) + C (eval r P) * X i, ?_⟩ + simp only [map_mul, aeval_X, eval_X, hQ] + ring + +theorem exists_integer_affine_remainder_degree {I : Type*} + (P : MvPolynomial I ℤ) (r : I → ℤ) {a : ℤ} (ha : a ≠ 0) : + ∃ Q : MvPolynomial I ℤ, + aeval (fun i => C (r i) + C a * X i) P = C (eval r P) + C a * Q ∧ + Q.totalDegree ≤ P.totalDegree := by + obtain ⟨Q, hQ⟩ := exists_integer_affine_remainder P r a + refine ⟨Q, hQ, ?_⟩ + by_cases hQ0 : Q = 0 + · simp [hQ0] + have hCa : (C a : MvPolynomial I ℤ) ≠ 0 := by simpa using ha + have hprod : C a * Q = aeval (fun i => C (r i) + C a * X i) P - C (eval r P) := by + rw [hQ] + ring + have hdeg : (aeval (fun i => C (r i) + C a * X i) P).totalDegree ≤ P.totalDegree := by + have hf (i : I) : (C (r i) + C a * X i).totalDegree ≤ 1 := by + apply (totalDegree_add _ _).trans + simp only [max_le_iff, totalDegree_C] + refine ⟨by omega, ?_⟩ + simpa only [totalDegree_C, totalDegree_X, zero_add] using totalDegree_mul (C a) (X i) + simpa only [Nat.mul_one] using aeval_polynomial_totalDegree_le P _ le_rfl hf + have hbound := (totalDegree_sub_C_le (aeval (fun i => C (r i) + C a * X i) P) + (eval r P)).trans hdeg + rwa [← hprod, totalDegree_mul_of_isDomain hCa hQ0, totalDegree_C, zero_add] at hbound + +theorem integer_affine_remainder_eval {I : Type*} + (P Q : MvPolynomial I ℤ) (r : I → ℤ) (a : ℤ) + (hQ : aeval (fun i => C (r i) + C a * X i) P = C (eval r P) + C a * Q) + (x : I → ℤ) : eval (fun i => r i + a * x i) P = eval r P + a * eval x Q := by + have he := congrArg (aeval (R := ℤ) x) hQ + rw [comp_aeval_apply] at he + simpa only [map_add, map_mul, aeval_C, aeval_X, Algebra.algebraMap_self, + RingHom.id_apply, aeval_eq_eval] using he + +theorem exists_rational_affine_integer_remainder {I J : Type*} [Fintype J] + (P : MvPolynomial I ℤ) (e : J → ℚ) {H : ℕ} + (he : ∀ i, RationalHeightLE (e i) H) : + ∃ d : ℕ, 0 < d ∧ d ≤ H ^ Fintype.card J ∧ + ∀ D : ℕ, 0 < D → ∀ r : I → ℤ, ∃ Q : J → MvPolynomial I ℤ, + (∀ i, (Q i).totalDegree ≤ P.totalDegree) ∧ + ∀ (x : I → ℤ) (i : J), + (eval (fun j => r j + (D * d : ℕ) * x j) P : ℝ) / D * (e i : ℝ) = + (eval r P : ℝ) / D * (e i : ℝ) + (eval x (Q i) : ℝ) := by + classical + obtain ⟨d, hd, hdH, z, hz, _⟩ := exists_bounded_integer_array e he + refine ⟨d, hd, hdH, ?_⟩ + intro D hD r + have ha : ((D * d : ℕ) : ℤ) ≠ 0 := by exact_mod_cast (Nat.mul_pos hD hd).ne' + obtain ⟨Q, hQ, hdegree⟩ := exists_integer_affine_remainder_degree P r ha + refine ⟨fun i => C (z i) * Q, ?_, ?_⟩ + · intro i + exact (totalDegree_mul _ _).trans (by simpa only [totalDegree_C, zero_add] using hdegree) + · intro x i + have hvalue := integer_affine_remainder_eval P Q r ((D * d : ℕ) : ℤ) hQ x + have hvalueR : (eval (fun j => r j + (D * d : ℕ) * x j) P : ℝ) = + (eval r P : ℝ) + (D : ℝ) * d * (eval x Q : ℝ) := by exact_mod_cast hvalue + have hzi : (z i : ℝ) = (d : ℝ) * (e i : ℝ) := by + exact_mod_cast hz i + rw [hvalueR, map_mul, eval_C, Int.cast_mul, hzi] + have hD0 : (D : ℝ) ≠ 0 := by exact_mod_cast hD.ne' + field_simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineResidues.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..f31bb6a69271949c9e43d98d3563efb33393ee8d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineResidues.lean @@ -0,0 +1,442 @@ +import Mathlib.Algebra.MvPolynomial.CommRing +import Mathlib.Algebra.MvPolynomial.Degrees +import OAI.Combinatorics.Progressions.Polynomial.BoundedRealPolynomialBasis +import OAI.Combinatorics.Progressions.Polynomial.IntegerPolynomialResidues +import OAI.Combinatorics.Progressions.Polynomial.RealPolynomialEvaluationMass + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +noncomputable def integerJetMatrix {α K O J : Type*} [DecidableEq α] + (basis : J → MvPolynomial K ℤ) (vertices : Finset α → K → ℤ) + (rows : O → Finset α) : Matrix O J ℤ := + fun o j => booleanCoefficient (fun t => MvPolynomial.eval (vertices t) (basis j)) (rows o) + +theorem integerJetMatrix_apply_coefficients {α K O J : Type*} [DecidableEq α] [Fintype J] + (basis : J → MvPolynomial K ℤ) (vertices : Finset α → K → ℤ) + (rows : O → Finset α) (c : J → ℤ) (o : O) : + (integerJetMatrix basis vertices rows *ᵥ c) o = + booleanCoefficient (fun t => MvPolynomial.eval (vertices t) + (∑ j, MvPolynomial.C (c j) * basis j)) (rows o) := by + simp only [map_sum, map_mul, MvPolynomial.eval_C, + booleanCoefficient_sum, booleanCoefficient_const_mul] + change (∑ j, integerJetMatrix basis vertices rows o j * c j) = _ + apply Finset.sum_congr rfl + intro j _ + exact mul_comm _ _ + +theorem integerJetMatrix_residue_eq {α K O J : Type*} [DecidableEq α] + (basis : J → MvPolynomial K ℤ) (vertices vertices' : Finset α → K → ℤ) + (rows : O → Finset α) (m : ℕ) + (hvertices : ∀ o t, t ∈ (rows o).powerset → + integerResidueMap K m (vertices t) = integerResidueMap K m (vertices' t)) : + integerResidueMatrix (integerJetMatrix basis vertices rows) m = + integerResidueMatrix (integerJetMatrix basis vertices' rows) m := by + ext o j + apply integerBooleanCoefficient_congr + intro t ht + exact integerPolynomial_eval_congr (basis j) m (hvertices o t ht) + +theorem integerJetMatrix_image_eq {α K O J : Type*} [DecidableEq α] [Fintype O] [Fintype J] + (basis : J → MvPolynomial K ℤ) (vertices vertices' : Finset α → K → ℤ) + (rows : O → Finset α) (m : ℕ) + (hvertices : ∀ o t, t ∈ (rows o).powerset → + integerResidueMap K m (vertices t) = integerResidueMap K m (vertices' t)) + (hperiod : integerScalarLattice O (m : ℤ) ≤ (integerJetMatrix basis vertices rows).mulVecLin.range) + (hperiod' : integerScalarLattice O (m : ℤ) ≤ (integerJetMatrix basis vertices' rows).mulVecLin.range) : + (integerJetMatrix basis vertices rows).mulVecLin.range = + (integerJetMatrix basis vertices' rows).mulVecLin.range := + integerMatrixImage_eq_of_residueMatrix _ _ m hperiod hperiod' + (integerJetMatrix_residue_eq basis vertices vertices' rows m hvertices) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def integerBooleanInterpolant {α K : Type*} [DecidableEq α] + (q : α → MvPolynomial K ℤ) (a : ℤ) (h : ℕ) (s : Finset α) : MvPolynomial K ℤ := + MvPolynomial.C (a ^ (h - s.card)) * ∏ r ∈ s, q r + +theorem integerBooleanInterpolant_eval {α K : Type*} [DecidableEq α] + (q : α → MvPolynomial K ℤ) (a : ℤ) (h : ℕ) (s : Finset α) (hs : s.card ≤ h) + (vertices : Finset α → K → ℤ) + (hq : ∀ r t, MvPolynomial.eval (vertices t) (q r) = if r ∈ t then a else 0) + (t : Finset α) : + MvPolynomial.eval (vertices t) (integerBooleanInterpolant q a h s) = + a ^ h * if s ⊆ t then 1 else 0 := by + have hprod : (∏ r ∈ s, MvPolynomial.eval (vertices t) (q r)) = + if s ⊆ t then a ^ s.card else 0 := by + by_cases hst : s ⊆ t + · rw [ite_eq_left hst] + calc + _ = ∏ _r ∈ s, a := Finset.prod_congr rfl (fun r hr => by rw [hq r t, ite_eq_left (hst hr)]) + _ = _ := by simp + · rw [ite_eq_right hst] + obtain ⟨r, hrs, hrt⟩ := Finset.not_subset.mp hst + exact Finset.prod_eq_zero hrs (by rw [hq r t, ite_eq_right hrt]) + rw [integerBooleanInterpolant, map_mul, MvPolynomial.eval_C, map_prod, hprod] + by_cases hst : s ⊆ t + · simp only [ite_eq_left hst, mul_one] + rw [← pow_add, Nat.sub_add_cancel hs] + · simp only [ite_eq_right hst, mul_zero] + +theorem integerBooleanInterpolant_jet {α K : Type*} [DecidableEq α] + (q : α → MvPolynomial K ℤ) (a : ℤ) (h : ℕ) (s : Finset α) (hs : s.card ≤ h) + (vertices : Finset α → K → ℤ) + (hq : ∀ r t, MvPolynomial.eval (vertices t) (q r) = if r ∈ t then a else 0) + (row : Finset α) : + booleanCoefficient (fun t => MvPolynomial.eval (vertices t) + (integerBooleanInterpolant q a h s)) row = if row = s then a ^ h else 0 := by + simp_rw [integerBooleanInterpolant_eval q a h s hs vertices hq] + rw [booleanCoefficient_const_mul, booleanCoefficient_monomial] + split_ifs <;> simp + +theorem integerBooleanInterpolant_degree {α K : Type*} [DecidableEq α] + (q : α → MvPolynomial K ℤ) (a : ℤ) (h : ℕ) (s : Finset α) (hs : s.card ≤ h) + (hq : ∀ r ∈ s, (q r).totalDegree ≤ 1) : + (integerBooleanInterpolant q a h s).totalDegree ≤ h := by + unfold integerBooleanInterpolant + apply (MvPolynomial.totalDegree_mul _ _).trans + rw [MvPolynomial.totalDegree_C, zero_add] + apply (MvPolynomial.totalDegree_finsetProd s q).trans + calc + _ ≤ ∑ _r ∈ s, 1 := Finset.sum_le_sum hq + _ = s.card := by simp + _ ≤ h := hs + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def integerAffineCube {α K : Type*} (root : K → ℤ) (difference : α → K → ℤ) + (t : Finset α) : K → ℤ := fun k => root k + ∑ r ∈ t, difference r k + +noncomputable def integerAffineNumerator {K : Type*} [Fintype K] + (root n : K → ℤ) : MvPolynomial K ℤ := + ∑ k, MvPolynomial.C (n k) * (MvPolynomial.X k - MvPolynomial.C (root k)) + +theorem integerAffineNumerator_eval {α K : Type*} [Fintype K] + (root n : K → ℤ) (difference : α → K → ℤ) (t : Finset α) : + MvPolynomial.eval (integerAffineCube root difference t) (integerAffineNumerator root n) = + ∑ r ∈ t, ∑ k, n k * difference r k := by + simp only [integerAffineNumerator, map_sum, map_mul, map_sub, + MvPolynomial.eval_C, MvPolynomial.eval_X, integerAffineCube, add_sub_cancel_left, + Finset.mul_sum] + exact Finset.sum_comm + +theorem integerAffineNumerator_boolean {α K : Type*} [DecidableEq α] [Fintype K] + (root : K → ℤ) (difference : α → K → ℤ) (n : α → K → ℤ) (a : ℤ) + (hdual : ∀ r s, (∑ k, n r k * difference s k) = if r = s then a else 0) + (r : α) (t : Finset α) : + MvPolynomial.eval (integerAffineCube root difference t) (integerAffineNumerator root (n r)) = + if r ∈ t then a else 0 := by + rw [integerAffineNumerator_eval] + simp only [hdual, Finset.sum_ite_eq] + +theorem integerAffineNumerator_degree {K : Type*} [Fintype K] (root n : K → ℤ) : + (integerAffineNumerator root n).totalDegree ≤ 1 := by + unfold integerAffineNumerator + apply MvPolynomial.totalDegree_finsetSum_le + intro k _ + apply (MvPolynomial.totalDegree_mul _ _).trans + rw [MvPolynomial.totalDegree_C, zero_add] + exact (MvPolynomial.totalDegree_sub_C_le _ _).trans (by simp) + +theorem integerAffine_interpolation {α K : Type*} [DecidableEq α] [Fintype K] + (root : K → ℤ) (difference : α → K → ℤ) (n : α → K → ℤ) (a : ℤ) + (hdual : ∀ r s, (∑ k, n r k * difference s k) = if r = s then a else 0) + (h : ℕ) (s : Finset α) (hs : s.card ≤ h) : + ∃ p : MvPolynomial K ℤ, p.totalDegree ≤ h ∧ ∀ row : Finset α, + booleanCoefficient (fun t => MvPolynomial.eval (integerAffineCube root difference t) p) row = + if row = s then a ^ h else 0 := by + let q := fun r => integerAffineNumerator root (n r) + refine ⟨integerBooleanInterpolant q a h s, + integerBooleanInterpolant_degree q a h s hs (fun r _ => integerAffineNumerator_degree root (n r)), ?_⟩ + exact integerBooleanInterpolant_jet q a h s hs (integerAffineCube root difference) + (integerAffineNumerator_boolean root difference n a hdual) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem exists_integer_kernel_dual {α K : Type*} [Fintype α] [DecidableEq α] [Fintype K] + (D : Matrix α K ℤ) (a : ℤ) (hperiod : integerScalarLattice α a ≤ D.mulVecLin.range) : + ∃ n : α → K → ℤ, ∀ r s, (∑ k, n r k * D s k) = if r = s then a else 0 := by + have hex (r : α) : ∃ n : K → ℤ, D *ᵥ n = a • Pi.single r 1 := + hperiod ((integerScalarLattice_mem a _).mpr ⟨Pi.single r 1, rfl⟩) + choose n hn using hex + refine ⟨n, fun r s => ?_⟩ + calc + _ = (D *ᵥ n r) s := by simp [Matrix.mulVec, dotProduct, mul_comm] + _ = (a • (Pi.single r 1 : α → ℤ)) s := congrFun (hn r) s + _ = _ := by + by_cases hrs : r = s + · subst s; simp + · simp [hrs, Ne.symm hrs] + +theorem integerKernel_interpolation {α K : Type*} [Fintype α] [DecidableEq α] [Fintype K] + (D : Matrix α K ℤ) (a : ℤ) (hperiod : integerScalarLattice α a ≤ D.mulVecLin.range) + (root : K → ℤ) (h : ℕ) (s : Finset α) (hs : s.card ≤ h) : + ∃ p : MvPolynomial K ℤ, p.totalDegree ≤ h ∧ ∀ row : Finset α, + booleanCoefficient (fun t => MvPolynomial.eval (integerAffineCube root D t) p) row = + if row = s then a ^ h else 0 := by + obtain ⟨n, hn⟩ := exists_integer_kernel_dual D a hperiod + exact integerAffine_interpolation root D n a hn h s hs + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def realAffineCube {α K : Type*} (root : K → ℝ) (difference : α → K → ℝ) + (t : Finset α) : K → ℝ := fun k => root k + ∑ r ∈ t, difference r k + +noncomputable def realAffineDualPolynomial {I K : Type*} [Fintype I] + (root : K → ℝ) (selection : I → K) (n : I → ℝ) : MvPolynomial K ℝ := + ∑ j, MvPolynomial.C (n j) * + (MvPolynomial.X (selection j) - MvPolynomial.C (root (selection j))) + +theorem realAffineDualPolynomial_eval {α I K : Type*} [Fintype I] + (root : K → ℝ) (difference : α → K → ℝ) (selection : I → K) + (n : I → ℝ) (t : Finset α) : + MvPolynomial.eval (realAffineCube root difference t) + (realAffineDualPolynomial root selection n) = + ∑ r ∈ t, ∑ j, n j * difference r (selection j) := by + simp only [realAffineDualPolynomial, map_sum, map_mul, map_sub, + MvPolynomial.eval_C, MvPolynomial.eval_X, realAffineCube, + add_sub_cancel_left, Finset.mul_sum] + exact Finset.sum_comm + +theorem realAffineDualPolynomial_boolean {α I K : Type*} + [DecidableEq α] [Fintype I] + (root : K → ℝ) (difference : α → K → ℝ) (selection : I → K) + (n : α → I → ℝ) + (hdual : ∀ r s, (∑ j, n r j * difference s (selection j)) = + if r = s then 1 else 0) (r : α) (t : Finset α) : + MvPolynomial.eval (realAffineCube root difference t) + (realAffineDualPolynomial root selection (n r)) = if r ∈ t then 1 else 0 := by + rw [realAffineDualPolynomial_eval] + simp only [hdual, Finset.sum_ite_eq] + +theorem realAffineDualPolynomial_degree {I K : Type*} [Fintype I] + (root : K → ℝ) (selection : I → K) (n : I → ℝ) : + (realAffineDualPolynomial root selection n).totalDegree ≤ 1 := by + unfold realAffineDualPolynomial + apply MvPolynomial.totalDegree_finsetSum_le + intro j _ + apply (MvPolynomial.totalDegree_mul _ _).trans + rw [MvPolynomial.totalDegree_C, zero_add] + exact (MvPolynomial.totalDegree_sub_C_le _ _).trans (by simp) + +theorem realPolynomialMass_neg {K : Type*} (p : MvPolynomial K ℝ) : + realPolynomialMass (-p) = realPolynomialMass p := by + classical + simp [realPolynomialMass] + +theorem realPolynomialMass_sub_le {K : Type*} (p q : MvPolynomial K ℝ) : + realPolynomialMass (p - q) ≤ realPolynomialMass p + realPolynomialMass q := by + simpa only [sub_eq_add_neg, realPolynomialMass_neg] using realPolynomialMass_add_le p (-q) + +theorem realAffineDualPolynomial_mass {I K : Type*} [Fintype I] + (root : K → ℝ) (selection : I → K) (n : I → ℝ) + (hroot : ∀ j, |root (selection j)| ≤ 1) {V : ℝ} (hV : 0 ≤ V) + (hn : ∀ j, |n j| ≤ V) : + realPolynomialMass (realAffineDualPolynomial root selection n) ≤ + (Fintype.card I : ℝ) * (2 * V) := by + unfold realAffineDualPolynomial + apply (realPolynomialMass_sum_le _ _).trans + calc + _ ≤ ∑ _j : I, 2 * V := by + apply Finset.sum_le_sum + intro j _ + apply (realPolynomialMass_C_mul_le _ _).trans + have hm : realPolynomialMass + (MvPolynomial.X (selection j) - MvPolynomial.C (root (selection j))) ≤ 2 := by + apply (realPolynomialMass_sub_le _ _).trans + simp only [realPolynomialMass_X, realPolynomialMass_C] + linarith [hroot j] + calc + _ ≤ V * 2 := mul_le_mul (hn j) hm (realPolynomialMass_nonneg _) hV + _ = 2 * V := mul_comm _ _ + _ = _ := by simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +noncomputable def boundedDegreeIntegerJetMatrix {α K O : Type*} [DecidableEq α] [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (h : ℕ) (rows : O → Finset α) : + Matrix O (BoundedIntegerExponent K h) ℤ := + integerJetMatrix (fun e => MvPolynomial.monomial e.val 1) (integerAffineCube root D) rows + +theorem boundedDegreeIntegerJetMatrix_period {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] + (root : K → ℤ) (D : Matrix α K ℤ) (a : ℤ) + (hperiod : integerScalarLattice α a ≤ D.mulVecLin.range) + (h : ℕ) (rows : O → Finset α) (hinj : Function.Injective rows) + (hdegree : ∀ o, (rows o).card ≤ h) : + integerScalarLattice O (a ^ h) ≤ (boundedDegreeIntegerJetMatrix root D h rows).mulVecLin.range := by + classical + have hex (o : O) := integerKernel_interpolation D a hperiod root h (rows o) (hdegree o) + choose p hp hjet using hex + let E := boundedDegreeIntegerJetMatrix root D h rows + have hunit (o : O) : a ^ h • Pi.single o 1 ∈ E.mulVecLin.range := by + let c : BoundedIntegerExponent K h → ℤ := fun e => (p o).coeff e.val + refine ⟨c, ?_⟩ + ext r + change (integerJetMatrix (fun e : BoundedIntegerExponent K h => MvPolynomial.monomial e.val 1) + (integerAffineCube root D) rows *ᵥ c) r = _ + rw [integerJetMatrix_apply_coefficients] + change booleanCoefficient (fun t => MvPolynomial.eval (integerAffineCube root D t) + (∑ e : BoundedIntegerExponent K h, MvPolynomial.C ((p o).coeff e.val) * + MvPolynomial.monomial e.val 1)) (rows r) = _ + rw [boundedIntegerPolynomial_expansion (p o) h (hp o), hjet o] + by_cases hro : r = o + · subst r; simp + · simp [hinj.eq_iff, hro] + rintro y ⟨z, rfl⟩ + change a ^ h • z ∈ E.mulVecLin.range + have hs : (∑ o, z o • (a ^ h • Pi.single o 1)) ∈ E.mulVecLin.range := + E.mulVecLin.range.sum_mem (fun o _ => E.mulVecLin.range.smul_mem (z o) (hunit o)) + convert hs using 1 + ext r + simp [Pi.single_apply, mul_comm] + +theorem boundedDegreeIntegerJetMatrix_index_le {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] + (root : K → ℤ) (D : Matrix α K ℤ) (a : ℕ) [NeZero a] + (hperiod : integerScalarLattice α (a : ℤ) ≤ D.mulVecLin.range) + (h : ℕ) (rows : O → Finset α) (hinj : Function.Injective rows) + (hdegree : ∀ o, (rows o).card ≤ h) : + (boundedDegreeIntegerJetMatrix root D h rows).mulVecLin.range.toAddSubgroup.index ≤ + (a ^ h) ^ Fintype.card O := by + have hp := boundedDegreeIntegerJetMatrix_period root D (a : ℤ) hperiod h rows hinj hdegree + rw [← Nat.cast_pow] at hp + exact residueLatticeImage_index_le _ (a ^ h) hp + +theorem integerScalarLattice_pow_le {O : Type*} [Fintype O] + (a : ℤ) {h s : ℕ} (hh : h ≤ s) : + integerScalarLattice O (a ^ s) ≤ integerScalarLattice O (a ^ h) := by + rintro y ⟨z, rfl⟩ + refine ⟨a ^ (s - h) • z, ?_⟩ + change a ^ h • (a ^ (s - h) • z) = a ^ s • z + rw [smul_smul, ← pow_add, Nat.add_sub_of_le hh] + +theorem boundedDegreeIntegerJetMatrix_common_period {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] + (root : K → ℤ) (D : Matrix α K ℤ) (a : ℤ) + (hperiod : integerScalarLattice α a ≤ D.mulVecLin.range) + (s h : ℕ) (hh : h ≤ s) (rows : O → Finset α) (hinj : Function.Injective rows) + (hdegree : ∀ o, (rows o).card ≤ h) : + integerScalarLattice O (a ^ s) ≤ (boundedDegreeIntegerJetMatrix root D h rows).mulVecLin.range := + (integerScalarLattice_pow_le a hh).trans + (boundedDegreeIntegerJetMatrix_period root D a hperiod h rows hinj hdegree) + +theorem boundedDegreeIntegerJetMatrix_residue_iff {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] + (root : K → ℤ) (D : Matrix α K ℤ) (a : ℕ) + (hperiod : integerScalarLattice α (a : ℤ) ≤ D.mulVecLin.range) + (s h : ℕ) (hh : h ≤ s) (rows : O → Finset α) (hinj : Function.Injective rows) + (hdegree : ∀ o, (rows o).card ≤ h) (v : O → ℤ) : + v ∈ (boundedDegreeIntegerJetMatrix root D h rows).mulVecLin.range ↔ + ∃ x : BoundedIntegerExponent K h → ZMod (a ^ s), + integerResidueMatrix (boundedDegreeIntegerJetMatrix root D h rows) (a ^ s) *ᵥ x = + integerResidueMap O (a ^ s) v := by + have hp := boundedDegreeIntegerJetMatrix_common_period root D (a : ℤ) hperiod s h hh rows hinj hdegree + rw [← Nat.cast_pow] at hp + exact integerMatrixImage_residue_iff _ (a ^ s) hp v + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem integerAffineCube_residue_eq {α K : Type*} + (root root' : K → ℤ) (D D' : Matrix α K ℤ) (m : ℕ) + (hroot : integerResidueMap K m root = integerResidueMap K m root') + (hD : integerResidueMatrix D m = integerResidueMatrix D' m) (t : Finset α) : + integerResidueMap K m (integerAffineCube root D t) = + integerResidueMap K m (integerAffineCube root' D' t) := by + funext k + change ((root k + ∑ r ∈ t, D r k : ℤ) : ZMod m) = + ((root' k + ∑ r ∈ t, D' r k : ℤ) : ZMod m) + push_cast + have hk : (root k : ZMod m) = (root' k : ZMod m) := congrFun hroot k + rw [hk] + congr 1 + apply Finset.sum_congr rfl + intro r _ + exact congrFun (congrFun hD r) k + +theorem boundedDegreeIntegerJetMatrix_residue_eq {α K O : Type*} + [DecidableEq α] [Fintype K] + (root root' : K → ℤ) (D D' : Matrix α K ℤ) (h : ℕ) (rows : O → Finset α) (m : ℕ) + (hroot : integerResidueMap K m root = integerResidueMap K m root') + (hD : integerResidueMatrix D m = integerResidueMatrix D' m) : + integerResidueMatrix (boundedDegreeIntegerJetMatrix root D h rows) m = + integerResidueMatrix (boundedDegreeIntegerJetMatrix root' D' h rows) m := by + apply integerJetMatrix_residue_eq + intro o t _ + exact integerAffineCube_residue_eq root root' D D' m hroot hD t + +theorem boundedDegreeIntegerJetMatrix_image_eq {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] + (root root' : K → ℤ) (D D' : Matrix α K ℤ) (a : ℕ) + (hperiod : integerScalarLattice α (a : ℤ) ≤ D.mulVecLin.range) + (hperiod' : integerScalarLattice α (a : ℤ) ≤ D'.mulVecLin.range) + (s h : ℕ) (hh : h ≤ s) (rows : O → Finset α) (hinj : Function.Injective rows) + (hdegree : ∀ o, (rows o).card ≤ h) + (hroot : integerResidueMap K (a ^ s) root = integerResidueMap K (a ^ s) root') + (hD : integerResidueMatrix D (a ^ s) = integerResidueMatrix D' (a ^ s)) : + (boundedDegreeIntegerJetMatrix root D h rows).mulVecLin.range = + (boundedDegreeIntegerJetMatrix root' D' h rows).mulVecLin.range := by + have hp := boundedDegreeIntegerJetMatrix_common_period root D (a : ℤ) hperiod s h hh rows hinj hdegree + have hp' := boundedDegreeIntegerJetMatrix_common_period root' D' (a : ℤ) hperiod' s h hh rows hinj hdegree + rw [← Nat.cast_pow] at hp hp' + exact integerMatrixImage_eq_of_residueMatrix _ _ (a ^ s) hp hp' + (boundedDegreeIntegerJetMatrix_residue_eq root root' D D' h rows (a ^ s) hroot hD) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineSubstitution.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineSubstitution.lean new file mode 100644 index 0000000000000000000000000000000000000000..3bf490f82556db643f2d196df8dc6066bd5ab23b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAffineSubstitution.lean @@ -0,0 +1,51 @@ +import Mathlib.Algebra.BigOperators.Pi +import OAI.Combinatorics.Progressions.Polynomial.MixedWeightedPolynomialRename + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {σ τ : Type*} [Fintype τ] + +def integerAffineMap (A : σ → τ → ℤ) (b : σ → ℤ) (x : τ → ℤ) (i : σ) : ℤ := + b i + ∑ j, A i j * x j + +noncomputable def integerAffinePolynomial (A : σ → τ → ℤ) (b : σ → ℤ) (i : σ) : + MvPolynomial τ ℚ := + MvPolynomial.C (b i : ℚ) + ∑ j, MvPolynomial.C (A i j : ℚ) * MvPolynomial.X j + +theorem integerAffinePolynomial_support (A : σ → τ → ℤ) (b : σ → ℤ) (i : σ) : + integerAffinePolynomial A b i ∈ weightedSupportLE (fun _ : τ => 1) 1 := by + apply Submodule.add_mem + · exact weightedSupportLE_C _ 1 (b i : ℚ) + · apply Submodule.sum_mem + intro j _ + have hx : (MvPolynomial.X j : MvPolynomial τ ℚ) ∈ weightedSupportLE (fun _ : τ => 1) 1 := by + simpa only [MvPolynomial.X, Finsupp.weight_single, smul_eq_mul, mul_one] using + weightedSupportLE_monomial (fun _ : τ => 1) (Finsupp.single j 1) (1 : ℚ) + simpa only [zero_add] using weightedSupportLE_mul (weightedSupportLE_C _ 0 (A i j : ℚ)) hx + +theorem integerAffinePolynomial_eval (A : σ → τ → ℤ) (b : σ → ℤ) (x : τ → ℤ) (i : σ) : + MvPolynomial.aeval (fun j => (x j : ℚ)) (integerAffinePolynomial A b i) = + (integerAffineMap A b x i : ℚ) := by + simp [integerAffinePolynomial, integerAffineMap] + +theorem integerLinearForm_eq_sum [DecidableEq τ] (f : (τ → ℤ) →+ ℤ) (x : τ → ℤ) : + f x = ∑ j, f (Pi.single j 1) * x j := by + conv_lhs => rw [pi_eq_sum_univ' x] + rw [map_sum] + apply Finset.sum_congr rfl + intro j _ + rw [map_zsmul] + change x j * f (Pi.single j 1) = f (Pi.single j 1) * x j + exact mul_comm _ _ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAxisPrincipalLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAxisPrincipalLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..595f467f37b720bcf0cc200462c5d4a0dc2c1932 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAxisPrincipalLaw.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.Progressions.Probability.InactivePrincipalLaw +import OAI.Combinatorics.Progressions.Sampling.PrincipalSamplingScale + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def integerAxisSideLength (h K L : ℕ) (γ : ℝ) : ℕ := + if L ^ h < K then L else inactiveSideLength h K (inactiveDenominator γ) + +theorem integerAxisSideLength_pos {h K L : ℕ} (hh : 0 < h) (hL : 0 < L) (γ : ℝ) : + 0 < integerAxisSideLength h K L γ := by + unfold integerAxisSideLength + split_ifs + · exact hL + · exact inactiveSideLength_pos hh (inactiveDenominator_pos γ) + +theorem integerAxisSideLength_le {h K L : ℕ} (hh : 0 < h) (hL : 0 < L) (γ : ℝ) : + integerAxisSideLength h K L γ ≤ L := by + unfold integerAxisSideLength + split_ifs with ha + · exact le_rfl + · exact inactiveSideLength_le hh hL (Nat.le_of_not_gt ha) + +theorem integerAxisPrincipal_width {h K L : ℕ} (hh : 0 < h) (hL : 0 < L) + {γ : ℝ} (hγ : 0 < γ) + (hgap : (principalSamplingGapRatio γ * L) ^ h ≤ K) : + 8 * (probabilityProfileLipschitz : ℝ) ≤ (γ / 2) * ((K : ℝ) / (L : ℝ) ^ h) := by + apply coefficient_gap_principal_width (A := (principalSamplingGapRatio γ : ℝ)) (by exact_mod_cast hL) + (by exact_mod_cast principalSamplingGapRatio_one_le γ) hγ hh + · exact_mod_cast hgap + · exact principalSamplingGapRatio_width hγ + +noncomputable def integerAxisPrincipalPMF (h K L : ℕ) (hh : 0 < h) (hK : 0 < K) + (hL : 0 < L) (γ : ℝ) (hγ : 0 < γ) + (hgap : L ^ h < K → (principalSamplingGapRatio γ * L) ^ h ≤ K) : PMF ℤ := + if ha : L ^ h < K then + principalIntegerPMF K ((L : ℝ) ^ h) γ (by exact_mod_cast hK) + (pow_pos (by exact_mod_cast hL) _) hγ (integerAxisPrincipal_width hh hL hγ (hgap ha)) + else inactivePrincipalPMF K (inactiveDenominator γ) + +theorem integerAxisPrincipalPMF_active {h K L : ℕ} (hh : 0 < h) (hK : 0 < K) + (hL : 0 < L) {γ : ℝ} (hγ : 0 < γ) + (hgap : L ^ h < K → (principalSamplingGapRatio γ * L) ^ h ≤ K) (ha : L ^ h < K) + {k : ℤ} (hk : k ∈ (integerAxisPrincipalPMF h K L hh hK hL γ hγ hgap).support) : + γ < (L : ℝ) ^ h * (k : ℝ) / K ∧ (L : ℝ) ^ h * (k : ℝ) / K < 2 * γ := by + simp only [integerAxisPrincipalPMF, ha, ↓reduceDIte] at hk + exact principalIntegerPMF_support (by exact_mod_cast hK) + (pow_pos (by exact_mod_cast hL) _) hγ (integerAxisPrincipal_width hh hL hγ (hgap ha)) hk + +theorem integerAxisPrincipalPMF_inactive {h K L : ℕ} (hh : 0 < h) (hK : 0 < K) + (hL : 0 < L) {γ : ℝ} (hγ : 0 < γ) + (hgap : L ^ h < K → (principalSamplingGapRatio γ * L) ^ h ≤ K) (ha : K ≤ L ^ h) : + integerAxisPrincipalPMF h K L hh hK hL γ hγ hgap = + inactivePrincipalPMF K (inactiveDenominator γ) := by + simp [integerAxisPrincipalPMF, Nat.not_lt.mpr ha] + +theorem integerAxisPrincipalPMF_bound {h K L : ℕ} (hh : 0 < h) (hK : 0 < K) + (hL : 0 < L) {γ : ℝ} (hγ : 0 < γ) + (hgap : L ^ h < K → (principalSamplingGapRatio γ * L) ^ h ≤ K) + {k : ℤ} (hk : k ∈ (integerAxisPrincipalPMF h K L hh hK hL γ hγ hgap).support) : + |(k : ℝ) / K| * (integerAxisSideLength h K L γ : ℝ) ^ h ≤ 2 * γ := by + by_cases ha : L ^ h < K + · have hb := integerAxisPrincipalPMF_active hh hK hL hγ hgap ha hk + have he : |(k : ℝ) / K| * (L : ℝ) ^ h = |(L : ℝ) ^ h * (k : ℝ) / K| := by + calc + _ = |((k : ℝ) / K) * (L : ℝ) ^ h| := by + rw [abs_mul, abs_of_pos (pow_pos (show (0 : ℝ) < L by exact_mod_cast hL) h)] + _ = _ := by congr 1; ring + simp only [integerAxisSideLength, ha, ↓reduceIte] + rw [he, abs_of_pos (hγ.trans hb.1)] + exact hb.2.le + · rw [integerAxisPrincipalPMF_inactive hh hK hL hγ hgap (Nat.le_of_not_gt ha)] at hk + rw [inactivePrincipalPMF_support hk] + simp only [integerAxisSideLength, ha, ↓reduceIte, abs_div, + abs_of_pos (show (0 : ℝ) < K by exact_mod_cast hK)] + calc + _ = |(inactivePrincipalCoefficient K (inactiveDenominator γ) : ℝ)| * + (inactiveSideLength h K (inactiveDenominator γ) : ℝ) ^ h / K := by ring + _ ≤ 1 / (inactiveDenominator γ : ℝ) := + inactivePrincipal_scaled_upper hh hK (inactiveDenominator_pos γ) + _ ≤ γ := inactiveDenominator_bound hγ + _ ≤ 2 * γ := by linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAxisTailLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAxisTailLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..27eeb66e6d010f0c76f57622be04b85897433feb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerAxisTailLaw.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.Progressions.Probability.PerturbationCoefficientLaw + +namespace OAI + +section + +namespace Erdos3 + +theorem integerAxisTail_width {V : Type*} (T : V → ℝ) (hT : ∀ v, 0 < T v) + {K L s : ℕ} (hL : 0 < L) (hTL : ∀ v, T v ≤ L) {ε : ℝ} (hε : 0 < ε) + (hεL : 8 * (probabilityProfileLipschitz : ℝ) ≤ ε * L) + (e : V →₀ ℕ) (he : e.sum (fun _ n => n) ≤ s) (ha : L ^ (s + 1) < K) : + 8 * (probabilityProfileLipschitz : ℝ) ≤ (ε / monomialScale T e) * K := by + apply enormousPerturbation_large T hT (by exact_mod_cast hL) hε hTL + · exact_mod_cast ha.le + · exact hεL + · exact he + +noncomputable def integerAxisTailPMF {V : Type*} (T : V → ℝ) (hT : ∀ v, 0 < T v) + (K L s : ℕ) (hK : 0 < K) (hL : 0 < L) (hTL : ∀ v, T v ≤ L) (ε : ℝ) (hε : 0 < ε) + (hεL : 8 * (probabilityProfileLipschitz : ℝ) ≤ ε * L) + (e : V →₀ ℕ) (he : e.sum (fun _ n => n) ≤ s) : PMF ℤ := + if ha : L ^ (s + 1) < K then + normalizedIntegerPMF K 0 (ε / monomialScale T e) (by exact_mod_cast hK) + (div_pos hε (monomialScale_pos T hT e)) (integerAxisTail_width T hT hL hTL hε hεL e he ha) + else PMF.pure 0 + +theorem integerAxisTailPMF_small {V : Type*} (T : V → ℝ) (hT : ∀ v, 0 < T v) + {K L s : ℕ} (hK : 0 < K) (hL : 0 < L) (hTL : ∀ v, T v ≤ L) {ε : ℝ} (hε : 0 < ε) + (hεL : 8 * (probabilityProfileLipschitz : ℝ) ≤ ε * L) + (e : V →₀ ℕ) (he : e.sum (fun _ n => n) ≤ s) (ha : K ≤ L ^ (s + 1)) : + integerAxisTailPMF T hT K L s hK hL hTL ε hε hεL e he = PMF.pure 0 := by + simp [integerAxisTailPMF, Nat.not_lt.mpr ha] + +theorem integerAxisTailPMF_support {V : Type*} (T : V → ℝ) (hT : ∀ v, 0 < T v) + {K L s : ℕ} (hK : 0 < K) (hL : 0 < L) (hTL : ∀ v, T v ≤ L) {ε : ℝ} (hε : 0 < ε) + (hεL : 8 * (probabilityProfileLipschitz : ℝ) ≤ ε * L) + (e : V →₀ ℕ) (he : e.sum (fun _ n => n) ≤ s) {k : ℤ} + (hk : k ∈ (integerAxisTailPMF T hT K L s hK hL hTL ε hε hεL e he).support) : + |(k : ℝ) / K| * monomialScale T e < 3 * ε / 4 := by + by_cases ha : L ^ (s + 1) < K + · simp only [integerAxisTailPMF, ha, ↓reduceDIte] at hk + exact integerPerturbation_scaled_support (by exact_mod_cast hK) hε + (monomialScale_pos T hT e) (integerAxisTail_width T hT hL hTL hε hεL e he ha) hk + · rw [integerAxisTailPMF_small T hT hK hL hTL hε hεL e he (Nat.le_of_not_gt ha)] at hk + have hk0 : k = 0 := by simpa only [PMF.support_pure, Set.mem_singleton_iff] using hk + subst k + simp only [Int.cast_zero, zero_div, abs_zero, zero_mul] + positivity + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBooleanSiteReconstruction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBooleanSiteReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f3081f10fd90d7521f696c6a6f2c239d750a3a1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBooleanSiteReconstruction.lean @@ -0,0 +1,160 @@ +import OAI.Combinatorics.Progressions.Estimates.MixedBooleanSiteValues + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix Classical + +variable {α : Type*} [Fintype α] [DecidableEq α] + +theorem integer_boolean_reconstruction (y : Finset α → ℤ) (s : Finset α) : + y s = ∑ t : Finset α, if t ⊆ s then booleanCoefficient y t else 0 := by + have h := congrArg (fun M : Matrix (Finset α) (Finset α) ℤ => M *ᵥ y) + (booleanReconstruction_mul_extraction (α := α)) + rw [Matrix.one_mulVec, ← Matrix.mulVec_mulVec] at h + have hv : booleanJetExtractionMatrix (id : Finset α → Finset α) *ᵥ y = + fun t => booleanCoefficient y t := by + funext t + exact booleanJetExtractionMatrix_mulVec id y t + rw [hv] at h + have hs := congrFun h s + simpa only [Matrix.mulVec, dotProduct, booleanReconstructionMatrix, + ite_mul, one_mul, zero_mul] using hs.symm + +theorem integer_boolean_reconstruction_rows (y : Finset α → ℤ) + (rows : Finset (Finset α)) (hrows : ∀ t ∉ rows, booleanCoefficient y t = 0) + (s : Finset α) : + y s = ∑ t ∈ rows, if t ⊆ s then booleanCoefficient y t else 0 := by + rw [integer_boolean_reconstruction y s] + symm + apply Finset.sum_subset (Finset.subset_univ rows) + intro t _ ht + simp only [hrows t ht, ite_self] + +theorem integer_boolean_sites_bound (y : Finset α → ℤ) (rows : Finset (Finset α)) + (hrows : ∀ t ∉ rows, booleanCoefficient y t = 0) + {H N : ℝ} (hH : 0 ≤ H) (hN : 0 < N) + (hcoeff : ∀ t ∈ rows, |((booleanCoefficient y t : ℤ) : ℝ)| ≤ H * N) (s : Finset α) : + |(y s : ℝ) / N| ≤ rows.card * H := by + have hs : |(y s : ℝ)| ≤ (rows.card : ℝ) * (H * N) := by + rw [integer_boolean_reconstruction_rows y rows hrows s, Int.cast_sum] + calc + _ ≤ ∑ t ∈ rows, |((if t ⊆ s then booleanCoefficient y t else 0 : ℤ) : ℝ)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _t ∈ rows, H * N := by + apply Finset.sum_le_sum + intro t ht + split_ifs + · exact hcoeff t ht + · simp only [Int.cast_zero, abs_zero] + positivity + _ = _ := by simp + rw [abs_div, abs_of_pos hN] + apply (div_le_iff₀ hN).mpr + simpa only [mul_assoc] using hs + +theorem bounded_affine_site_coefficients_outside_rows {K : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (h : ℕ) (rows : Finset (Finset α)) + (hrows : ∀ t : Finset α, t.card ≤ h → t ∈ rows) + (c : VectorPolynomial.BoundedCoefficientExponent K h → ℤ) : + ∀ t ∉ rows, booleanCoefficient + (VectorPolynomial.boundedSiteMatrix h (integerAffineCube root D) *ᵥ c) t = 0 := by + intro t ht + have hh : h < t.card := lt_of_not_ge (fun hle => ht (hrows t hle)) + have heq : VectorPolynomial.boundedSiteMatrix h (integerAffineCube root D) *ᵥ c = + fun s => ∑ e, c e * VectorPolynomial.boundedSiteMatrix h (integerAffineCube root D) s e := by + funext s + apply Finset.sum_congr rfl + intro e _ + exact mul_comm _ _ + rw [heq, booleanCoefficient_sum] + apply Finset.sum_eq_zero + intro e _ + rw [booleanCoefficient_const_mul, + BooleanCubeKernel.boundedSiteMatrix_high_jet_zero root D h e t hh, mul_zero] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix Classical + +variable {α : Type*} [Fintype α] [DecidableEq α] + +noncomputable def integerBooleanSitesFromRows (rows : Finset (Finset α)) + (z : rows → ℤ) : Finset α → ℤ := + booleanReconstructionMatrix α *ᵥ (fun t => if ht : t ∈ rows then z ⟨t, ht⟩ else 0) + +theorem integerBooleanSitesFromRows_coefficient (rows : Finset (Finset α)) + (z : rows → ℤ) (t : Finset α) : + booleanCoefficient (integerBooleanSitesFromRows rows z) t = + if ht : t ∈ rows then z ⟨t, ht⟩ else 0 := by + calc + _ = (booleanJetExtractionMatrix (id : Finset α → Finset α) *ᵥ + integerBooleanSitesFromRows rows z) t := + (booleanJetExtractionMatrix_mulVec id (integerBooleanSitesFromRows rows z) t).symm + _ = _ := by + unfold integerBooleanSitesFromRows + rw [Matrix.mulVec_mulVec, booleanJetExtraction_mul_reconstruction, Matrix.one_mulVec] + +theorem integerBooleanSitesFromRows_coefficient_mem (rows : Finset (Finset α)) + (z : rows → ℤ) (t : rows) : + booleanCoefficient (integerBooleanSitesFromRows rows z) t.val = z t := by + rw [integerBooleanSitesFromRows_coefficient, dite_eq_left t.property] + +theorem integerBooleanSitesFromRows_coefficient_outside (rows : Finset (Finset α)) + (z : rows → ℤ) (t : Finset α) (ht : t ∉ rows) : + booleanCoefficient (integerBooleanSitesFromRows rows z) t = 0 := by + rw [integerBooleanSitesFromRows_coefficient, dite_eq_right ht] + +theorem integerBooleanSitesFromRows_eq (rows : Finset (Finset α)) + (y : Finset α → ℤ) (hy : ∀ t ∉ rows, booleanCoefficient y t = 0) : + integerBooleanSitesFromRows rows (fun t => booleanCoefficient y t.val) = y := by + have hc : (fun t => if ht : t ∈ rows then + (fun t : rows => booleanCoefficient y t.val) ⟨t, ht⟩ else 0) = + fun t => booleanCoefficient y t := by + funext t + by_cases ht : t ∈ rows + · rw [dite_eq_left ht] + · rw [dite_eq_right ht, hy t ht] + have he : booleanJetExtractionMatrix (id : Finset α → Finset α) *ᵥ y = + fun t => booleanCoefficient y t := funext (booleanJetExtractionMatrix_mulVec id y) + unfold integerBooleanSitesFromRows + rw [hc, ← he, Matrix.mulVec_mulVec, booleanReconstruction_mul_extraction, Matrix.one_mulVec] + +omit [Fintype α] in +theorem integer_boolean_coefficient_bound (y : Finset α → ℤ) (t : Finset α) + {H N : ℝ} (hy : ∀ s, |(y s : ℝ)| ≤ H * N) : + |((booleanCoefficient y t : ℤ) : ℝ)| ≤ (2 : ℝ) ^ t.card * (H * N) := by + rw [booleanCoefficient, Int.cast_sum] + calc + _ ≤ ∑ s ∈ t.powerset, |(((-1 : ℤ) ^ (t \ s).card * y s : ℤ) : ℝ)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _s ∈ t.powerset, H * N := by + apply Finset.sum_le_sum + intro s _ + simpa only [Int.cast_mul, Int.cast_pow, Int.cast_neg, Int.cast_one, abs_mul, + abs_pow, abs_neg, abs_one, one_pow, one_mul] using hy s + _ = _ := by simp only [Finset.sum_const, nsmul_eq_mul, Finset.card_powerset, + Nat.cast_pow, Nat.cast_ofNat] + +omit [Fintype α] in +theorem integer_boolean_coefficient_degree_bound (y : Finset α → ℤ) (t : Finset α) + {d : ℕ} (ht : t.card ≤ d) {H N : ℝ} (hH : 0 ≤ H) (hN : 0 ≤ N) + (hy : ∀ s, |(y s : ℝ)| ≤ H * N) : + |((booleanCoefficient y t : ℤ) : ℝ)| ≤ (2 : ℝ) ^ d * (H * N) := + (integer_boolean_coefficient_bound y t hy).trans + (mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) ht) (mul_nonneg hH hN)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxCoordinateEquiv.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxCoordinateEquiv.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e180231539e5be8634357b705e44e6650fc08f8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxCoordinateEquiv.lean @@ -0,0 +1,153 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativePatchAmplification + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {X Y : Type*} + +def coordinateReindexedSides (e : X ≃ Y) (N : X → ℕ) : Y → ℕ := + fun y => N (e.symm y) + +def coordinateReindexedFunction (e : X ≃ Y) (f : (X → ℤ) → ℝ) : (Y → ℤ) → ℝ := + fun y => f (fun x => y (e x)) + +variable [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] + +theorem coordinateReindexedSides_mem_integerBox (e : X ≃ Y) (N : X → ℕ) (y : Y → ℤ) : + y ∈ integerBox (coordinateReindexedSides e N) ↔ + (fun x => y (e x)) ∈ integerBox N := by + simp only [mem_integerBox, coordinateReindexedSides] + constructor + · intro hy x + simpa only [e.symm_apply_apply] using hy (e x) + · intro hy j + simpa only [e.apply_symm_apply] using hy (e.symm j) + +theorem coordinateReindexedFunction_expect (e : X ≃ Y) (N : X → ℕ) + (f : (X → ℤ) → ℝ) : + (𝔼 y ∈ integerBox (coordinateReindexedSides e N), coordinateReindexedFunction e f y) = + 𝔼 x ∈ integerBox N, f x := by + apply Finset.expect_bij (fun y _ x => y (e x)) + · intro y hy + exact (coordinateReindexedSides_mem_integerBox e N y).mp hy + · intro y _ + rfl + · intro y _ z _ he + funext j + simpa only [e.apply_symm_apply] using congrFun he (e.symm j) + · intro x hx + refine ⟨fun j => x (e.symm j), ?_, ?_⟩ + · apply (coordinateReindexedSides_mem_integerBox e N _).mpr + simpa only [e.symm_apply_apply] using hx + · funext i + simp only [e.symm_apply_apply] + +theorem coordinateReindexedFunction_bounds (e : X ≃ Y) (N : X → ℕ) + (f : (X → ℤ) → ℝ) (hf : ∀ x ∈ integerBox N, f x ∈ Set.Icc (0 : ℝ) 1) : + ∀ y ∈ integerBox (coordinateReindexedSides e N), + coordinateReindexedFunction e f y ∈ Set.Icc (0 : ℝ) 1 := by + intro y hy + exact hf _ ((coordinateReindexedSides_mem_integerBox e N y).mp hy) + +theorem coordinateReindexedFunction_apFree (e : X ≃ Y) (N : X → ℕ) + (f : (X → ℤ) → ℝ) {k : ℕ} + (hfree : IntegerVectorAPFree {x | x ∈ integerBox N ∧ f x ≠ 0} k) : + IntegerVectorAPFree + {y | y ∈ integerBox (coordinateReindexedSides e N) ∧ + coordinateReindexedFunction e f y ≠ 0} k := by + intro a d hd + have hd' : (fun x => d (e x)) ≠ 0 := by + intro hzero + apply hd + funext j + simpa only [e.apply_symm_apply, Pi.zero_apply] using congrFun hzero (e.symm j) + obtain ⟨i, hi⟩ := hfree (fun x => a (e x)) (fun x => d (e x)) hd' + refine ⟨i, ?_⟩ + rintro ⟨hbox, hnonzero⟩ + apply hi + refine ⟨?_, ?_⟩ + · exact (coordinateReindexedSides_mem_integerBox e N _).mp hbox + · exact hnonzero + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {X Y : Type*} + +def integerPointCoordinateEquiv (e : X ≃ Y) : (X → ℤ) ≃ (Y → ℤ) where + toFun x y := x (e.symm y) + invFun y x := y (e x) + left_inv x := by funext i; simp only [e.symm_apply_apply] + right_inv y := by funext j; simp only [e.apply_symm_apply] + +@[simp] theorem integerPointCoordinateEquiv_apply (e : X ≃ Y) (x : X → ℤ) (y : Y) : + integerPointCoordinateEquiv e x y = x (e.symm y) := rfl + +@[simp] theorem integerPointCoordinateEquiv_symm_apply (e : X ≃ Y) (y : Y → ℤ) (x : X) : + (integerPointCoordinateEquiv e).symm y x = y (e x) := rfl + +@[simp] theorem integerPointCoordinateEquiv_symm (e : X ≃ Y) : + integerPointCoordinateEquiv e.symm = (integerPointCoordinateEquiv e).symm := rfl + +variable [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] + +@[simp] theorem integerPointCoordinateEquiv_mem_integerBox (e : X ≃ Y) + (N : X → ℕ) (x : X → ℤ) : + integerPointCoordinateEquiv e x ∈ integerBox (coordinateReindexedSides e N) ↔ + x ∈ integerBox N := by + rw [coordinateReindexedSides_mem_integerBox] + simp only [integerPointCoordinateEquiv_apply, e.symm_apply_apply] + +def integerBoxCoordinateEquiv (e : X ≃ Y) (N : X → ℕ) : + integerBox N ≃ integerBox (coordinateReindexedSides e N) where + toFun x := ⟨integerPointCoordinateEquiv e x.val, + (integerPointCoordinateEquiv_mem_integerBox e N x.val).mpr x.property⟩ + invFun y := ⟨(integerPointCoordinateEquiv e).symm y.val, + (coordinateReindexedSides_mem_integerBox e N y.val).mp y.property⟩ + left_inv x := by apply Subtype.ext; exact (integerPointCoordinateEquiv e).left_inv x.val + right_inv y := by apply Subtype.ext; exact (integerPointCoordinateEquiv e).right_inv y.val + +@[simp] theorem integerBoxCoordinateEquiv_val (e : X ≃ Y) (N : X → ℕ) + (x : integerBox N) : + (integerBoxCoordinateEquiv e N x).val = integerPointCoordinateEquiv e x.val := rfl + +@[simp] theorem integerBoxCoordinateEquiv_symm_val (e : X ≃ Y) (N : X → ℕ) + (y : integerBox (coordinateReindexedSides e N)) : + ((integerBoxCoordinateEquiv e N).symm y).val = + (integerPointCoordinateEquiv e).symm y.val := rfl + +theorem integerBox_map_coordinateEquiv (e : X ≃ Y) (N : X → ℕ) : + (integerBox N).map (integerPointCoordinateEquiv e).toEmbedding = + integerBox (coordinateReindexedSides e N) := by + ext y + constructor + · intro hy + obtain ⟨x, hx, rfl⟩ := Finset.mem_map.mp hy + exact (integerPointCoordinateEquiv_mem_integerBox e N x).mpr hx + · intro hy + refine Finset.mem_map.mpr ⟨(integerPointCoordinateEquiv e).symm y, ?_, ?_⟩ + · exact (coordinateReindexedSides_mem_integerBox e N y).mp hy + · exact (integerPointCoordinateEquiv e).apply_symm_apply y + +theorem integerBox_image_coordinateEquiv (e : X ≃ Y) (N : X → ℕ) : + (integerBox N).image (integerPointCoordinateEquiv e) = + integerBox (coordinateReindexedSides e N) := by + classical + exact (Finset.map_eq_image (integerPointCoordinateEquiv e).toEmbedding (integerBox N)).symm.trans + (integerBox_map_coordinateEquiv e N) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxCutoffLogBounds.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxCutoffLogBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c97ea4571f1c4a485292110b634dc75a5eed5ae7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxCutoffLogBounds.lean @@ -0,0 +1,169 @@ +import OAI.Combinatorics.Progressions.Lattices.AffineMeshRetention + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def integerBoxGcdCutoff (d : ℕ) (C epsilon : ℝ) : ℕ := + ⌈2 * (2 : ℝ) ^ (d - 1) * (1 + C) / epsilon⌉₊ + 1 + +noncomputable def integerBoxNearRatio (d : ℕ) (epsilon : ℝ) : ℝ := + replacementAccuracy (2 * (3 : ℝ) ^ d) epsilon + +noncomputable def integerBoxPairScale (d : ℕ) (C epsilon : ℝ) : ℝ := + max (integerBoxGcdCutoff d C epsilon : ℝ) (1 / integerBoxNearRatio d epsilon) + +noncomputable def integerBoxRetainedGap (d D : ℕ) (c epsilon : ℝ) : ℝ := + (D : ℝ) * integerBoxNearRatio d epsilon * c + +theorem integerBoxGcdCutoff_spec (d : ℕ) {C epsilon : ℝ} + (heps : 0 < epsilon) : + 0 < integerBoxGcdCutoff d C epsilon ∧ + (2 : ℝ) ^ (d - 1) * (1 + C) / integerBoxGcdCutoff d C epsilon ≤ epsilon / 2 := by + have hp : 0 < integerBoxGcdCutoff d C epsilon := by + unfold integerBoxGcdCutoff + omega + refine ⟨hp, ?_⟩ + have hpr : (0 : ℝ) < integerBoxGcdCutoff d C epsilon := by exact_mod_cast hp + have hceil : 2 * (2 : ℝ) ^ (d - 1) * (1 + C) / epsilon ≤ + (integerBoxGcdCutoff d C epsilon : ℝ) := by + unfold integerBoxGcdCutoff + push_cast + linarith [Nat.le_ceil (2 * (2 : ℝ) ^ (d - 1) * (1 + C) / epsilon)] + have hh := (div_le_iff₀ heps).mp hceil + apply (div_le_iff₀ hpr).mpr + nlinarith + +theorem integerBoxNearRatio_spec (d : ℕ) {epsilon : ℝ} (heps : 0 < epsilon) : + 0 < integerBoxNearRatio d epsilon ∧ integerBoxNearRatio d epsilon ≤ 1 ∧ + (3 : ℝ) ^ d * integerBoxNearRatio d epsilon ≤ epsilon / 2 := by + have h := replacementAccuracy_spec (by positivity : 0 ≤ 2 * (3 : ℝ) ^ d) heps + change 0 < integerBoxNearRatio d epsilon ∧ integerBoxNearRatio d epsilon ≤ 1 ∧ + 2 * (3 : ℝ) ^ d * integerBoxNearRatio d epsilon ≤ epsilon at h + exact ⟨h.1, h.2.1, by linarith [h.2.2]⟩ + +theorem integerBoxBadPairBudget_of_cutoffs (d R : ℕ) {C epsilon M : ℝ} + (hd : 2 ≤ d) (hC : 0 ≤ C) (heps : 0 < epsilon) + (hscale : integerBoxPairScale d C epsilon ≤ M) (hR : (R : ℝ) ≤ C * M) : + integerBoxBadPairBudget d (integerBoxGcdCutoff d C epsilon) R + ⌊integerBoxNearRatio d epsilon * M⌋₊ M ≤ epsilon := by + have hB := integerBoxGcdCutoff_spec d (C := C) heps + have hnu := integerBoxNearRatio_spec d heps + have hBM : (integerBoxGcdCutoff d C epsilon : ℝ) ≤ M := (le_max_left _ _).trans hscale + have hM : 0 < M := (by exact_mod_cast hB.1 : (0 : ℝ) < integerBoxGcdCutoff d C epsilon).trans_le hBM + have hinv : 1 / M ≤ integerBoxNearRatio d epsilon := by + have h := (le_max_right (integerBoxGcdCutoff d C epsilon : ℝ) + (1 / integerBoxNearRatio d epsilon)).trans hscale + have hh := (div_le_iff₀ hnu.1).mp h + apply (div_le_iff₀ hM).mpr + nlinarith + have h := integerBoxBadPairBudget_le_linear d (integerBoxGcdCutoff d C epsilon) R + ⌊integerBoxNearRatio d epsilon * M⌋₊ hd hB.1 hBM hC hR + (Nat.floor_le (mul_nonneg hnu.1.le hM.le)) hinv hnu.2.1 + linarith [hB.2, hnu.2.2] + +theorem integerBoxRetainedGap_spec (d D : ℕ) {c epsilon L M : ℝ} + (hD : 0 < D) (hc : 0 < c) (heps : 0 < epsilon) (hside : c * L ≤ M) : + 0 < integerBoxRetainedGap d D c epsilon ∧ + integerBoxRetainedGap d D c epsilon * L ≤ + (D : ℝ) * (⌊integerBoxNearRatio d epsilon * M⌋₊ + 1 : ℕ) := by + have hnu := (integerBoxNearRatio_spec d heps).1 + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + constructor + · unfold integerBoxRetainedGap + positivity + · unfold integerBoxRetainedGap + push_cast + calc + _ = (D : ℝ) * (integerBoxNearRatio d epsilon * (c * L)) := by ring + _ ≤ (D : ℝ) * (integerBoxNearRatio d epsilon * M) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hside hnu.le) hDr.le + _ ≤ _ := mul_le_mul_of_nonneg_left (Nat.lt_floor_add_one _).le hDr.le + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem integerBoxGcdCutoff_le_exp (d : ℕ) {C epsilon P : ℝ} + (hC0 : 0 ≤ C) (heps0 : 0 < epsilon) (hP : 0 ≤ P) + (hpow : (2 : ℝ) ^ (d - 1) ≤ Real.exp P) + (hC : C ≤ Real.exp P) (heps : epsilon⁻¹ ≤ Real.exp P) : + (integerBoxGcdCutoff d C epsilon : ℝ) ≤ Real.exp (3 * P + 6) := by + have h2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hsum := one_add_le_exp_succ hP hC + have hx : 2 * (2 : ℝ) ^ (d - 1) * (1 + C) / epsilon ≤ Real.exp (3 * P + 3) := by + calc + _ = 2 * (2 : ℝ) ^ (d - 1) * (1 + C) * epsilon⁻¹ := by rw [div_eq_mul_inv] + _ ≤ Real.exp 2 * Real.exp P * Real.exp (P + 1) * Real.exp P := by gcongr + _ = _ := by simp only [← Real.exp_add]; congr 1; ring + have hceil := (Nat.ceil_lt_add_one + (by positivity : 0 ≤ 2 * (2 : ℝ) ^ (d - 1) * (1 + C) / epsilon)).le + have hbase : 1 ≤ Real.exp (3 * P + 3) := Real.one_le_exp_iff.mpr (by linarith) + have h3 : (3 : ℝ) ≤ Real.exp 3 := by linarith [Real.add_one_le_exp (3 : ℝ)] + calc + (integerBoxGcdCutoff d C epsilon : ℝ) ≤ Real.exp (3 * P + 3) + 2 := by + unfold integerBoxGcdCutoff + push_cast + linarith + _ ≤ 3 * Real.exp (3 * P + 3) := by linarith + _ ≤ Real.exp 3 * Real.exp (3 * P + 3) := + mul_le_mul_of_nonneg_right h3 (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem integerBoxNearRatio_inverse_le_exp (d : ℕ) {epsilon P : ℝ} + (heps0 : 0 < epsilon) (hP : 0 ≤ P) + (hpow : 2 * (3 : ℝ) ^ d ≤ Real.exp P) (heps : epsilon⁻¹ ≤ Real.exp P) : + (integerBoxNearRatio d epsilon)⁻¹ ≤ Real.exp (2 * P + 2) := + replacementAccuracy_inverse_le_exp (by positivity) heps0 hP hpow heps + +theorem integerBoxPairScale_le_exp (d : ℕ) {C epsilon P : ℝ} + (hC0 : 0 ≤ C) (heps0 : 0 < epsilon) (hP : 0 ≤ P) + (hpow2 : (2 : ℝ) ^ (d - 1) ≤ Real.exp P) + (hpow3 : 2 * (3 : ℝ) ^ d ≤ Real.exp P) + (hC : C ≤ Real.exp P) (heps : epsilon⁻¹ ≤ Real.exp P) : + integerBoxPairScale d C epsilon ≤ Real.exp (3 * P + 6) := by + apply max_le (integerBoxGcdCutoff_le_exp d hC0 heps0 hP hpow2 hC heps) + rw [one_div] + exact (integerBoxNearRatio_inverse_le_exp d heps0 hP hpow3 heps).trans + (Real.exp_le_exp.mpr (by linarith)) + +theorem integerBoxRetainedGap_inverse_le_exp (d D : ℕ) {c epsilon P : ℝ} + (hD : 0 < D) (hc0 : 0 < c) (heps0 : 0 < epsilon) (hP : 0 ≤ P) + (hpow : 2 * (3 : ℝ) ^ d ≤ Real.exp P) + (hc : c⁻¹ ≤ Real.exp P) (heps : epsilon⁻¹ ≤ Real.exp P) : + (integerBoxRetainedGap d D c epsilon)⁻¹ ≤ Real.exp (3 * P + 2) := by + have hD1 : (1 : ℝ) ≤ D := by exact_mod_cast hD + have hDinv : (D : ℝ)⁻¹ ≤ 1 := by + simpa only [one_div, inv_one] using one_div_le_one_div_of_le zero_lt_one hD1 + have hnu0 := (integerBoxNearRatio_spec d heps0).1 + have hnu := integerBoxNearRatio_inverse_le_exp d heps0 hP hpow heps + calc + _ = (D : ℝ)⁻¹ * (integerBoxNearRatio d epsilon)⁻¹ * c⁻¹ := by + simp only [integerBoxRetainedGap, mul_inv_rev] + ring + _ ≤ 1 * Real.exp (2 * P + 2) * Real.exp P := by gcongr + _ = _ := by rw [one_mul, ← Real.exp_add]; congr 1; ring + +theorem integerBoxGcdModulus_le_exp (d D : ℕ) {C epsilon P : ℝ} + (hC0 : 0 ≤ C) (heps0 : 0 < epsilon) (hP : 0 ≤ P) + (hpow : (2 : ℝ) ^ (d - 1) ≤ Real.exp P) + (hD : (D : ℝ) ≤ Real.exp P) (hC : C ≤ Real.exp P) (heps : epsilon⁻¹ ≤ Real.exp P) : + ((D * integerBoxGcdCutoff d C epsilon : ℕ) : ℝ) ≤ Real.exp (4 * P + 6) := by + rw [Nat.cast_mul] + calc + _ ≤ Real.exp P * Real.exp (3 * P + 6) := + mul_le_mul hD (integerBoxGcdCutoff_le_exp d hC0 heps0 hP hpow hC heps) + (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxObservedMean.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxObservedMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..d34bf75d8c4ea1d110a2d8bbbff8512243aa65eb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxObservedMean.lean @@ -0,0 +1,301 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedTwistParameterPartition +import OAI.Combinatorics.Progressions.Estimates.PhysicalBaseInjection +import OAI.Combinatorics.Progressions.Sampling.FiniteObservationRetraction + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +def integerPhysicalSite {K I : Type*} [Fintype K] (root : K → ℤ) + (z : Option K × I → ℤ) : I → ℤ := + fun i => z (none,i) + ∑ k, root k * z (some k,i) + +theorem integerPhysicalSite_cast_apply {K I : Type*} [Fintype K] + (root : K → ℤ) (z : Option K × I → ℤ) (i : I) : + (integerPhysicalSite root z i : ℝ) = physicalAffineSite root z i := by + have h := physicalAffineSite_baseArrayJoin_apply root + (fun k => z (some k.1,k.2)) (fun i => z (none,i)) i + rw [baseArrayJoin_eta] at h + simpa only [integerPhysicalSite, Int.cast_add, Int.cast_sum, Int.cast_mul] using h.symm + +def integerBoxCenter {I : Type*} (N : I → ℕ) : I → ℤ := fun i => (N i / 2 : ℕ) + +def centeredIntegerPhysicalSite {K I : Type*} [Fintype K] (root : K → ℤ) (N : I → ℕ) + (z : Option K × I → ℤ) : I → ℤ := integerBoxCenter N + integerPhysicalSite root z + +theorem centeredIntegerPhysicalSite_cast {K I : Type*} [Fintype K] + (root : K → ℤ) (N : I → ℕ) (z : Option K × I → ℤ) : + (fun i => (centeredIntegerPhysicalSite root N z i : ℝ)) = + (fun i => (integerBoxCenter N i : ℝ)) + physicalAffineSite root z := by + funext i + simp only [centeredIntegerPhysicalSite, Pi.add_apply, Int.cast_add, integerPhysicalSite_cast_apply] + +noncomputable def physicalSiteWidth {K I : Type*} [Fintype K] + (root : K → ℤ) (W : Option K × I → ℝ) (i : I) : ℝ := + W (none,i) + ∑ k, |(root k : ℝ)| * W (some k,i) + +theorem integerPhysicalSite_abs_bound {K I : Type*} [Fintype K] + (root : K → ℤ) (W : Option K × I → ℝ) (z : Option K × I → ℤ) + (hz : ∀ a, |(z a : ℝ)| ≤ W a) (i : I) : + |(integerPhysicalSite root z i : ℝ)| ≤ physicalSiteWidth root W i := by + simp only [integerPhysicalSite, Int.cast_add, Int.cast_sum, Int.cast_mul, physicalSiteWidth] + calc + _ ≤ |(z (none,i) : ℝ)| + |∑ k, (root k : ℝ) * (z (some k,i) : ℝ)| := abs_add_le _ _ + _ ≤ |(z (none,i) : ℝ)| + ∑ k, |(root k : ℝ) * (z (some k,i) : ℝ)| := + add_le_add_right (Finset.abs_sum_le_sum_abs _ _) _ + _ ≤ _ := add_le_add (hz _) (Finset.sum_le_sum (fun k _ => by + rw [abs_mul] + exact mul_le_mul_of_nonneg_left (hz _) (abs_nonneg _))) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3 + +def integerBaseTranslation {K I : Type*} (b : I → ℤ) : Option K × I → ℤ := + baseArrayJoin 0 b + +namespace BooleanCubeKernel + +open scoped BigOperators + +theorem integerPhysicalSite_add {K I : Type*} [Fintype K] + (root : K → ℤ) (z w : Option K × I → ℤ) : + integerPhysicalSite root (z + w) = integerPhysicalSite root z + integerPhysicalSite root w := by + funext i + simp only [integerPhysicalSite, Pi.add_apply, mul_add, Finset.sum_add_distrib] + ring + +theorem integerPhysicalSite_baseTranslation {K I : Type*} [Fintype K] + (root : K → ℤ) (b : I → ℤ) : + integerPhysicalSite root (integerBaseTranslation b) = b := by + funext i + simp [integerPhysicalSite, integerBaseTranslation, baseArrayJoin] + +theorem integerPhysicalSite_baseTranslation_add {K I : Type*} [Fintype K] + (root : K → ℤ) (b : I → ℤ) (z : Option K × I → ℤ) : + integerPhysicalSite root (integerBaseTranslation b + z) = b + integerPhysicalSite root z := by + rw [integerPhysicalSite_add, integerPhysicalSite_baseTranslation] + +theorem physicalAffineSite_baseTranslation_add {K I : Type*} [Fintype K] + (root : K → ℤ) (b : I → ℤ) (z : Option K × I → ℤ) : + physicalAffineSite root (integerBaseTranslation b + z) = + (fun i => (b i : ℝ)) + physicalAffineSite root z := by + funext i + simp only [← integerPhysicalSite_cast_apply, integerPhysicalSite_baseTranslation_add, + Pi.add_apply, Int.cast_add] + +end BooleanCubeKernel +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [DecidableEq I] +variable (N : I → ℕ) (hN : (integerBox N).Nonempty) + +noncomputable def integerBoxObservation : (I → ℝ) → integerBox N := + finiteObservation (integerBox N) hN (fun x i => (x i : ℝ)) + +theorem integerBoxObservation_cast (x : integerBox N) : + integerBoxObservation N hN (fun i => (x.val i : ℝ)) = x := by + apply finiteObservation_apply + intro a b h + funext i + have hi := congrFun h i + change (a i : ℝ) = (b i : ℝ) at hi + exact_mod_cast hi + +theorem integerBoxObservation_reference : + (FiniteProbabilityWeights.uniformFinset (integerBox N) hN).fiberLaw + (fun x => integerBoxObservation N hN (fun i => (x.val i : ℝ))) = + FiniteProbabilityWeights.uniformFinset (integerBox N) hN := by + have he : (fun x : integerBox N => integerBoxObservation N hN (fun i => (x.val i : ℝ))) = id := + funext (integerBoxObservation_cast N hN) + rw [he, FiniteProbabilityWeights.fiberLaw_id] + +namespace BooleanCubeKernel + +theorem integerBoxObservation_physical {K : Type*} [Fintype K] + (root : K → ℤ) (z : Option K × I → ℤ) + (hz : integerPhysicalSite root z ∈ integerBox N) : + (integerBoxObservation N hN (physicalAffineSite root z)).val = integerPhysicalSite root z := by + have he := congrArg Subtype.val (integerBoxObservation_cast N hN ⟨integerPhysicalSite root z,hz⟩) + simpa only [integerPhysicalSite_cast_apply] using he + +end BooleanCubeKernel +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open BooleanCubeKernel +open scoped BigOperators Classical + +variable {K : Type*} {P : K → ℕ} {q r : ℕ} + +def composeSlice (S : ResidueBoxSlice P q) (T : ResidueBoxSlice S.length r) : + ResidueBoxSlice P (q * r) where + start k := S.start k + q * T.start k + length := T.length + inside k j hj := by + have h := S.inside k _ (T.inside k j hj) + convert h using 1; ring + +theorem composeSlice_point (S : ResidueBoxSlice P q) (T : ResidueBoxSlice S.length r) + (u : ∀ k, Fin (T.length k)) : (S.composeSlice T).point u = S.point (T.point u) := by + funext k + apply Fin.ext + change S.start k + q * T.start k + (q * r) * (u k).val = + S.start k + q * (T.start k + r * (u k).val) + ring + +def parameterCell (Q : ∀ k, FiniteProgressionPartition (P k)) + (hstep : ∀ k c, (Q k).step c = r) (c : ∀ k, (Q k).Label) : ResidueBoxSlice P r where + start k := (Q k).start (c k) + length k := (Q k).length (c k) + inside k j hj := by simpa only [hstep] using (Q k).point_lt (c k) hj + +theorem parameterCell_point [Fintype K] [DecidableEq K] + (Q : ∀ k, FiniteProgressionPartition (P k)) + (hstep : ∀ k c, (Q k).step c = r) (c : ∀ k, (Q k).Label) + (u : ∀ k, Fin ((Q k).length (c k))) : + (parameterCell Q hstep c).point u = BoxProgressionPartition.point Q c u := by + funext k + apply Fin.ext + simp only [point, parameterCell, BoxProgressionPartition.point_val, hstep] + +theorem stride_mul_length_le_twice (S : ResidueBoxSlice P q) (k : K) + (hlen : 2 ≤ S.length k) : q * S.length k ≤ 2 * P k := by + have hlast := S.inside k (S.length k - 1) (by omega) + have hlen' : S.length k ≤ 2 * (S.length k - 1) := by omega + have hmul := Nat.mul_le_mul_left q hlen' + nlinarith + +theorem composeSlice_length_lower (S : ResidueBoxSlice P q) + (T : ResidueBoxSlice S.length r) {cost loss : ℝ} + (hS : ∀ k, Real.exp (-cost) * (P k : ℝ) ≤ S.length k) + (hT : ∀ k, (S.length k : ℝ) * Real.exp (-loss) ≤ T.length k) (k : K) : + Real.exp (-(cost + loss)) * (P k : ℝ) ≤ (S.composeSlice T).length k := by + calc + _ = (Real.exp (-cost) * (P k : ℝ)) * Real.exp (-loss) := by + rw [mul_right_comm, ← Real.exp_add] + congr 2 + ring + _ ≤ (S.length k : ℝ) * Real.exp (-loss) := + mul_le_mul_of_nonneg_right (hS k) (Real.exp_nonneg _) + _ ≤ _ := hT k + +theorem length_large_of_cost (S : ResidueBoxSlice P q) {cost target : ℝ} + (hS : ∀ k, Real.exp (-cost) * (P k : ℝ) ≤ S.length k) + (hP : ∀ k, Real.exp (cost + target) ≤ (P k : ℝ)) (k : K) : + Real.exp target ≤ (S.length k : ℝ) := by + calc + _ = Real.exp (-cost) * Real.exp (cost + target) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ Real.exp (-cost) * (P k : ℝ) := + mul_le_mul_of_nonneg_left (hP k) (Real.exp_nonneg _) + _ ≤ _ := hS k + +theorem stride_le_twice_exp_cost (S : ResidueBoxSlice P q) {cost : ℝ} + (k : K) (hlen : 2 ≤ S.length k) + (hS : Real.exp (-cost) * (P k : ℝ) ≤ S.length k) : + (q : ℝ) ≤ 2 * Real.exp cost := by + have hP : (0 : ℝ) < P k := by + have h := S.inside k 0 (by omega) + exact_mod_cast (show 0 < P k by omega) + have hspan : (q : ℝ) * S.length k ≤ 2 * (P k : ℝ) := by + exact_mod_cast S.stride_mul_length_le_twice k hlen + have hmul := (mul_le_mul_of_nonneg_left hS (Nat.cast_nonneg q)).trans hspan + have hq : (q : ℝ) * Real.exp (-cost) ≤ 2 := by nlinarith + have h := mul_le_mul_of_nonneg_right hq (Real.exp_nonneg cost) + simpa only [mul_assoc, ← Real.exp_add, neg_add_cancel, Real.exp_zero, mul_one] using h + +variable [Fintype K] {X : Type*} + +def pullbackIntegerFrame (S : ResidueBoxSlice P q) (frame : Option K × X → ℤ) : + Option K × X → ℤ := fun i => match i.1 with + | none => integerPhysicalSite (fun k => (S.start k : ℤ)) frame i.2 + | some k => (q : ℤ) * frame (some k, i.2) + +theorem integerPhysicalSite_pullback (S : ResidueBoxSlice P q) + (frame : Option K × X → ℤ) (u : K → ℤ) : + integerPhysicalSite u (S.pullbackIntegerFrame frame) = + integerPhysicalSite (fun k => (S.start k : ℤ) + (q : ℤ) * u k) frame := by + funext x + simp only [integerPhysicalSite, pullbackIntegerFrame, add_mul, Finset.sum_add_distrib] + rw [add_assoc] + congr 1 + congr 1 + apply Finset.sum_congr rfl + intro k _ + ring + +theorem pullback_normalized_slope_bound (S : ResidueBoxSlice P q) + (hlen : ∀ k, 2 ≤ S.length k) (frame : Option K × X → ℤ) + (N : X → ℕ) (C : K → ℝ) + (hslope : ∀ k x, |(frame (some k, x) : ℝ) / N x| * P k ≤ C k) + (k : K) (x : X) : + |(S.pullbackIntegerFrame frame (some k, x) : ℝ) / N x| * S.length k ≤ 2 * C k := by + have hspan : (q : ℝ) * S.length k ≤ 2 * (P k : ℝ) := by + exact_mod_cast S.stride_mul_length_le_twice k (hlen k) + calc + _ = |(frame (some k, x) : ℝ) / N x| * ((q : ℝ) * S.length k) := by + simp only [pullbackIntegerFrame, Int.cast_mul, Int.cast_natCast, mul_div_assoc, + abs_mul, abs_of_nonneg (Nat.cast_nonneg q : (0 : ℝ) ≤ _)] + ring + _ ≤ |(frame (some k, x) : ℝ) / N x| * (2 * (P k : ℝ)) := + mul_le_mul_of_nonneg_left hspan (abs_nonneg _) + _ = 2 * (|(frame (some k, x) : ℝ) / N x| * P k) := by ring + _ ≤ 2 * C k := mul_le_mul_of_nonneg_left (hslope k x) (by norm_num) + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem integerBoxObservation_mean {I : Type*} [Fintype I] [DecidableEq I] + (N : I → ℕ) (hN : (integerBox N).Nonempty) (f : integerBox N → ℝ) : + (𝔼 x ∈ integerBox N, f (integerBoxObservation N hN (fun i => (x i : ℝ)))) = + (FiniteProbabilityWeights.uniformFinset (integerBox N) hN).mean f := by + have h := (FiniteProbabilityWeights.uniformFinset (integerBox N) hN).fiberLaw_mean + (fun x => integerBoxObservation N hN (fun i => (x.val i : ℝ))) f + rw [integerBoxObservation_reference, FiniteProbabilityWeights.uniformFinset_mean + (integerBox N) hN (fun x => f (integerBoxObservation N hN (fun i => (x i : ℝ))))] at h + exact h.symm + +theorem integerBoxObservation_complexMean {I : Type*} [Fintype I] [DecidableEq I] + (N : I → ℕ) (hN : (integerBox N).Nonempty) (f : integerBox N → ℂ) : + (𝔼 x ∈ integerBox N, f (integerBoxObservation N hN (fun i => (x i : ℝ)))) = + (FiniteProbabilityWeights.uniformFinset (integerBox N) hN).complexMean f := by + have h := (FiniteProbabilityWeights.uniformFinset (integerBox N) hN).fiberLaw_complexMean + (fun x => integerBoxObservation N hN (fun i => (x.val i : ℝ))) f + rw [integerBoxObservation_reference, FiniteProbabilityWeights.uniformFinset_complexMean + (integerBox N) hN (fun x => f (integerBoxObservation N hN (fun i => (x i : ℝ))))] at h + exact h.symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxUniformMeanInstance.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxUniformMeanInstance.lean new file mode 100644 index 0000000000000000000000000000000000000000..439184b0c8fb115f39f115c365c86e4831a451de --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxUniformMeanInstance.lean @@ -0,0 +1,22 @@ +import OAI.Combinatorics.Progressions.Geometry.BoxPairDivisibility + +namespace OAI + +section + +namespace Erdos3 +open scoped Classical + +theorem integerBoxUniformWeights_mean_decidableEq {J : Type*} [Fintype J] + (dec₁ dec₂ : DecidableEq J) (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (f : (∀ j, Finset.Ico (lo j) (hi j)) → ℝ) : + (letI := dec₁; (integerBoxUniformWeights lo hi hlen).mean f) = + (letI := dec₂; (integerBoxUniformWeights lo hi hlen).mean f) := by + cases Subsingleton.elim dec₁ dec₂ + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxUniformWeightVolume.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxUniformWeightVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..cacf1182fcd112ac70d8e6030ff38ab52503e889 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerBoxUniformWeightVolume.lean @@ -0,0 +1,37 @@ +import OAI.Combinatorics.Progressions.Geometry.BoxPairDivisibility + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] + +theorem integerBox_volume_pos (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) : + 0 < ∏ i, ((hi i - lo i : ℤ) : ℝ) := by + apply Finset.prod_pos + intro i _ + exact_mod_cast sub_pos.mpr (hlen i) + +theorem integerBoxUniformWeights_weight_eq_inv_volume + [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) + (y : ∀ i, Finset.Ico (lo i) (hi i)) : + (integerBoxUniformWeights lo hi hlen).weight y = + (∏ i, ((hi i - lo i : ℤ) : ℝ))⁻¹ := by + change (∏ i, (Fintype.card (Finset.Ico (lo i) (hi i)) : ℝ)⁻¹) = _ + rw [Finset.prod_inv_distrib] + congr 1 + apply Finset.prod_congr rfl + intro i _ + rw [Fintype.card_coe, Int.card_Ico] + exact_mod_cast Int.toNat_of_nonneg (sub_nonneg.mpr (hlen i).le) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerCokernelExponent.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerCokernelExponent.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f59c503ffc698633ef2da4f911336c87a7d182a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerCokernelExponent.lean @@ -0,0 +1,55 @@ +import Mathlib.GroupTheory.Exponent +import OAI.Combinatorics.Progressions.Lattices.ResidueRefinedPeriod + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def integerCokernelExponent {I : Type*} (L : Submodule ℤ (I → ℤ)) : ℕ := + AddMonoid.exponent ((I → ℤ) ⧸ L.toAddSubgroup) + +theorem integerCokernel_finite {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + Finite ((I → ℤ) ⧸ L.toAddSubgroup) := by + have h := residueLatticeImage_card_mul_index L m hperiod + have hindex : L.toAddSubgroup.index ≠ 0 := by + intro hz + rw [hz, mul_zero] at h + exact (pow_ne_zero _ (NeZero.ne m)) h.symm + let : L.toAddSubgroup.FiniteIndex := ⟨hindex⟩ + infer_instance + +theorem integerCokernelExponent_pos {I : Type*} (L : Submodule ℤ (I → ℤ)) + [Finite ((I → ℤ) ⧸ L.toAddSubgroup)] : 0 < integerCokernelExponent L := + AddMonoid.ExponentExists.of_finite.exponent_pos + +theorem integerCokernelExponent_period {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) : + integerScalarLattice I (integerCokernelExponent L : ℤ) ≤ L := by + rintro y ⟨z, rfl⟩ + change (integerCokernelExponent L : ℤ) • z ∈ L + rw [natCast_zsmul] + have h := AddMonoid.exponent_nsmul_eq_zero (QuotientAddGroup.mk' L.toAddSubgroup z) + rw [← map_nsmul, QuotientAddGroup.mk'_apply, QuotientAddGroup.eq_zero_iff] at h + exact h + +theorem integerCokernelExponent_dvd_period {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) + (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + integerCokernelExponent L ∣ m := by + apply AddMonoid.exponent_dvd_of_forall_nsmul_eq_zero + intro x + obtain ⟨z, rfl⟩ := QuotientAddGroup.mk'_surjective L.toAddSubgroup x + rw [← map_nsmul, QuotientAddGroup.mk'_apply, QuotientAddGroup.eq_zero_iff] + change m • z ∈ L + have h := hperiod ((integerScalarLattice_mem (m : ℤ) _).mpr ⟨z, rfl⟩) + simpa only [natCast_zsmul] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerColumnMinor.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerColumnMinor.lean new file mode 100644 index 0000000000000000000000000000000000000000..9941a59eecfa3ae9b95ed93bca2a43f78d99b725 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerColumnMinor.lean @@ -0,0 +1,126 @@ +import Mathlib.LinearAlgebra.Matrix.AbsoluteValue +import Mathlib.LinearAlgebra.Matrix.NonsingularInverse +import OAI.Combinatorics.Progressions.Estimates.RationalHeight +import OAI.Combinatorics.Progressions.Probability.LargeCokernelProbability + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem integer_det_natAbs_le (A : Matrix ι ι ℤ) {H : ℕ} + (hA : ∀ i j, (A i j).natAbs ≤ H) : + A.det.natAbs ≤ (Fintype.card ι).factorial * H ^ Fintype.card ι := by + have h := Matrix.det_le (A := A) (abv := AbsoluteValue.abs) (x := (H : ℤ)) + (fun i j => show |A i j| ≤ (H : ℤ) from by + simpa only [← Int.natCast_natAbs] using (show + ((A i j).natAbs : ℤ) ≤ (H : ℤ) from by exact_mod_cast hA i j)) + change |A.det| ≤ (Fintype.card ι).factorial • (H : ℤ) ^ Fintype.card ι at h + rw [← Int.natCast_natAbs, nsmul_eq_mul] at h + exact_mod_cast h + +theorem integer_cramer_natAbs_le (A : Matrix ι ι ℤ) (b : ι → ℤ) {H : ℕ} + (hA : ∀ i j, (A i j).natAbs ≤ H) (hb : ∀ i, (b i).natAbs ≤ H) (i : ι) : + (A.cramer b i).natAbs ≤ (Fintype.card ι).factorial * H ^ Fintype.card ι := by + rw [Matrix.cramer_apply] + apply integer_det_natAbs_le + intro j k + rw [Matrix.updateCol_apply] + split + · exact hb j + · exact hA j k + +def rationalCramerSolution (A : Matrix ι ι ℚ) (b : ι → ℚ) : ι → ℚ := + A.det⁻¹ • A.cramer b + +theorem rationalCramerSolution_solves (A : Matrix ι ι ℚ) (b : ι → ℚ) + (hA : A.det ≠ 0) : A *ᵥ rationalCramerSolution A b = b := by + rw [rationalCramerSolution, Matrix.mulVec_smul, Matrix.mulVec_cramer, + smul_smul, inv_mul_cancel₀ hA, one_smul] + +theorem rationalCramerSolution_unique (A : Matrix ι ι ℚ) (b x : ι → ℚ) + (hA : A.det ≠ 0) (hx : A *ᵥ x = b) : x = rationalCramerSolution A b := by + apply Matrix.mulVec_injective_of_isUnit (A.isUnit_iff_isUnit_det.mpr + (isUnit_iff_ne_zero.mpr hA)) + exact hx.trans (rationalCramerSolution_solves A b hA).symm + +theorem integerCramerSolution_apply (A : Matrix ι ι ℤ) (b : ι → ℤ) (i : ι) : + rationalCramerSolution (A.map (Int.castRingHom ℚ)) (fun j => (b j : ℚ)) i = + (A.cramer b i : ℚ) / (A.det : ℚ) := by + have hdet : (A.map (Int.castRingHom ℚ)).det = (A.det : ℚ) := + ((Int.castRingHom ℚ).map_det A).symm + have hnum : (A.map (Int.castRingHom ℚ)).cramer (fun j => (b j : ℚ)) i = + (A.cramer b i : ℚ) := by + rw [Matrix.cramer_apply, Matrix.cramer_apply] + have h := ((Int.castRingHom ℚ).map_det (A.updateCol i b)).symm + change ((A.updateCol i b).map (Int.castRingHom ℚ)).det = _ at h + rw [Matrix.map_updateCol] at h + exact h + simp only [rationalCramerSolution, Pi.smul_apply, smul_eq_mul, hdet, hnum, + div_eq_mul_inv, mul_comm] + +theorem integerCramerSolution_height (A : Matrix ι ι ℤ) (b : ι → ℤ) + (hdet : A.det ≠ 0) {H : ℕ} (hA : ∀ i j, (A i j).natAbs ≤ H) + (hb : ∀ i, (b i).natAbs ≤ H) (i : ι) : + RationalHeightLE + (rationalCramerSolution (A.map (Int.castRingHom ℚ)) (fun j => (b j : ℚ)) i) + ((Fintype.card ι).factorial * H ^ Fintype.card ι) := by + rw [integerCramerSolution_apply] + exact rationalHeightLE_fraction _ _ hdet (integer_cramer_natAbs_le A b hA hb i) + (integer_det_natAbs_le A hA) + +theorem exists_bounded_integer_system_solution (A : Matrix ι ι ℤ) (b : ι → ℤ) + (hdet : A.det ≠ 0) {H : ℕ} (hA : ∀ i j, (A i j).natAbs ≤ H) + (hb : ∀ i, (b i).natAbs ≤ H) : + ∃ x : ι → ℚ, (A.map (Int.castRingHom ℚ)) *ᵥ x = (fun i => (b i : ℚ)) ∧ + ∀ i, RationalHeightLE (x i) + ((Fintype.card ι).factorial * H ^ Fintype.card ι) := by + refine ⟨rationalCramerSolution _ _, rationalCramerSolution_solves _ _ ?_, + integerCramerSolution_height A b hdet hA hb⟩ + have h : (A.map (Int.castRingHom ℚ)).det = (A.det : ℚ) := + ((Int.castRingHom ℚ).map_det A).symm + rw [h] + exact_mod_cast hdet + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem integerColumnMinor_range_le {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I J ℤ) (s : I → J) : + (A.submatrix id s).mulVecLin.range ≤ A.mulVecLin.range := by + rw [Matrix.range_mulVecLin, Matrix.range_mulVecLin] + apply Submodule.span_mono + rintro v ⟨i, rfl⟩ + exact ⟨s i, rfl⟩ + +theorem integerColumnMinor_det_bound {I J : Type*} [Fintype I] [DecidableEq I] + (A : Matrix I J ℤ) (s : I → J) (H : ℕ) (hA : ∀ i j, (A i j).natAbs ≤ H) : + (A.submatrix id s).det.natAbs ≤ (Fintype.card I).factorial * H ^ Fintype.card I := + integer_det_natAbs_le _ (fun i j => hA i (s j)) + +theorem nonzeroMinor_largeCokernelEvent {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] + {Ω : J → Type*} (column : ∀ j, Ω j → I → ℤ) (x : ∀ j, Ω j) (B H : ℕ) + (hbound : ∀ i j, (column j (x j) i).natAbs ≤ H) + (hminor : ∃ s : I → J, ((sampledColumnMatrix column x).submatrix id s).det ≠ 0) + (hB : B < integerCokernelExponent (sampledColumnMatrix column x).mulVecLin.range) : + largeCokernelEvent column B ((Fintype.card I).factorial * H ^ Fintype.card I) x := by + obtain ⟨s, hs⟩ := hminor + exact ⟨_, hs, integerColumnMinor_range_le _ s, + integerColumnMinor_det_bound _ s H hbound, hB⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFiberCount.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFiberCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..624773f4907ea607712fd958107bfc044ea719b4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFiberCount.lean @@ -0,0 +1,118 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem card_integer_set_le_diameter_add_one (A : Finset ℤ) {L : ℝ} (hL : 0 ≤ L) + (hdiam : ∀ x ∈ A, ∀ y ∈ A, |(x : ℝ) - y| ≤ L) : + (A.card : ℝ) ≤ L + 1 := by + rcases A.eq_empty_or_nonempty with rfl | hA + · simp only [Finset.card_empty, Nat.cast_zero] + linarith + have hsub : A ⊆ Finset.Icc (A.min' hA) (A.max' hA) := by + intro x hx + exact Finset.mem_Icc.mpr ⟨A.min'_le x hx, A.le_max' x hx⟩ + have hcard : (A.card : ℝ) ≤ (A.max' hA : ℝ) + 1 - A.min' hA := by + have hc := Finset.card_le_card hsub + have hi := Int.card_Icc_of_le (A.min' hA) (A.max' hA) + (le_trans (A.min'_le_max' hA) (by omega)) + have hc' : (A.card : ℤ) ≤ A.max' hA + 1 - A.min' hA := by + exact_mod_cast hi ▸ (show (A.card : ℤ) ≤ (Finset.Icc (A.min' hA) (A.max' hA)).card by + exact_mod_cast hc) + exact_mod_cast hc' + have hd := (abs_le.mp (hdiam _ (A.max'_mem hA) _ (A.min'_mem hA))).2 + linarith + +theorem count_integer_phase_fibers (D : Finset ℤ) (m : ℤ → ℤ) + {H θ η : ℝ} (hH : 0 ≤ H) (hθ : 0 < θ) (hη : 0 ≤ η) + (hD : ∀ h ∈ D, |(h : ℝ)| ≤ H) + (hclose : ∀ h ∈ D, |(h : ℝ) * θ - m h| ≤ η) : + (D.card : ℝ) ≤ (2 * H * θ + 2 * η + 1) * (2 * η / θ + 1) := by + have hm (h : ℤ) (hh : h ∈ D) : |(m h : ℝ)| ≤ H * θ + η := by + have ha := abs_le.mp (hD h hh) + have he := abs_le.mp (hclose h hh) + have hlo := mul_le_mul_of_nonneg_right ha.1 hθ.le + have hhi := mul_le_mul_of_nonneg_right ha.2 hθ.le + rw [abs_le] + constructor <;> nlinarith only [hlo, hhi, he.1, he.2] + have himage : ((D.image m).card : ℝ) ≤ 2 * H * θ + 2 * η + 1 := by + apply card_integer_set_le_diameter_add_one _ (by positivity) + intro a ha b hb + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp ha + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hb + have hx' := abs_le.mp (hm x hx) + have hy' := abs_le.mp (hm y hy) + rw [abs_le] + constructor <;> linarith + have hfiber (a : ℤ) : ((D.filter (fun h => m h = a)).card : ℝ) ≤ 2 * η / θ + 1 := by + apply card_integer_set_le_diameter_add_one _ (by positivity) + intro x hx y hy + obtain ⟨hx, hmx⟩ := Finset.mem_filter.mp hx + obtain ⟨hy, hmy⟩ := Finset.mem_filter.mp hy + have he₁ := abs_le.mp (hclose x hx) + have he₂ := abs_le.mp (hclose y hy) + rw [hmx] at he₁ + rw [hmy] at he₂ + apply (le_div_iff₀ hθ).mpr + rw [← abs_of_pos hθ, ← abs_mul, abs_le] + constructor <;> nlinarith only [he₁.1, he₁.2, he₂.1, he₂.2] + calc + (D.card : ℝ) = ∑ a ∈ D.image m, ((D.filter (fun h => m h = a)).card : ℝ) := by + exact_mod_cast Finset.card_eq_sum_card_fiberwise (fun x hx => Finset.mem_image.mpr ⟨x, hx, rfl⟩) + _ ≤ ∑ _a ∈ D.image m, (2 * η / θ + 1) := Finset.sum_le_sum (fun a _ => hfiber a) + _ = ((D.image m).card : ℝ) * (2 * η / θ + 1) := by + simp only [Finset.sum_const, nsmul_eq_mul] + _ ≤ (2 * H * θ + 2 * η + 1) * (2 * η / θ + 1) := + mul_le_mul_of_nonneg_right himage (by positivity) + +theorem count_integer_phase_fibers_abs (D : Finset ℤ) (m : ℤ → ℤ) + {H θ η : ℝ} (hH : 0 ≤ H) (hθ : θ ≠ 0) (hη : 0 ≤ η) + (hD : ∀ h ∈ D, |(h : ℝ)| ≤ H) + (hclose : ∀ h ∈ D, |(h : ℝ) * θ - m h| ≤ η) : + (D.card : ℝ) ≤ (2 * H * |θ| + 2 * η + 1) * (2 * η / |θ| + 1) := by + rcases lt_or_gt_of_ne hθ with ht | ht + · have he : ∀ h ∈ D, |(h : ℝ) * (-θ) - ((-m h : ℤ) : ℝ)| ≤ η := by + intro h hh + simpa only [Int.cast_neg, mul_neg, neg_sub_neg, abs_sub_comm] using hclose h hh + simpa only [abs_of_neg ht] using count_integer_phase_fibers D (fun h => -m h) + hH (neg_pos.mpr ht) hη hD he + · simpa only [abs_of_pos ht] using count_integer_phase_fibers D m hH ht hη hD hclose + +theorem small_linear_phase_of_many_near_integers (D : Finset ℤ) (m : ℤ → ℤ) + {H θ η ρ : ℝ} (hH : 0 < H) (hρ : 0 < ρ) (hη : 0 ≤ η) (hηone : η ≤ 1) + (hsmall : 16 * η ≤ ρ) (hθsmall : |θ| ≤ 2 * η) + (hsize : ρ * H ≤ (D.card : ℝ)) + (hD : ∀ h ∈ D, |(h : ℝ)| ≤ H) + (hclose : ∀ h ∈ D, |(h : ℝ) * θ - m h| ≤ η) : + |θ| ≤ 24 * η / (ρ * H) := by + by_cases ht : θ = 0 + · rw [ht, abs_zero] + positivity + have hθ : 0 < |θ| := abs_pos.mpr ht + have hc := count_integer_phase_fibers_abs D m hH.le ht hη hD hclose + have hc' : ρ * H ≤ (2 * H * |θ| + 3) * (2 * η / |θ| + 1) := by + apply hsize.trans (hc.trans _) + apply mul_le_mul_of_nonneg_right (by linarith) (by positivity) + have hp := mul_le_mul_of_nonneg_right hc' hθ.le + have hid : ((2 * H * |θ| + 3) * (2 * η / |θ| + 1)) * |θ| = + 4 * H * |θ| * η + 2 * H * |θ| ^ 2 + 6 * η + 3 * |θ| := by + field_simp + ring + rw [hid] at hp + have hsquare := mul_le_mul_of_nonneg_left hθsmall + (show 0 ≤ 2 * H * |θ| by positivity) + have hcost := mul_le_mul_of_nonneg_right hsmall + (show 0 ≤ H * |θ| by positivity) + apply (le_div_iff₀ (mul_pos hρ hH)).mpr + nlinarith only [hp, hsquare, hcost, hθsmall] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFiberUniformBound.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFiberUniformBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..ceee3c9c9abc86ec2f001b4a3b056da297cabdd4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFiberUniformBound.lean @@ -0,0 +1,297 @@ +import OAI.Combinatorics.Progressions.Estimates.PivotJacobianBound +import OAI.Combinatorics.Progressions.Sampling.PivotGridErrorTransfer + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +noncomputable def normalizedIntegerColumns (B : Matrix I J ℤ) (T : J → ℝ) (P : I → ℝ) : + Matrix I J ℝ := + Matrix.diagonal (fun i => (P i)⁻¹) * B.map (Int.castRingHom ℝ) * Matrix.diagonal T + +theorem normalizedIntegerColumns_mulVec (B : Matrix I J ℤ) (T : J → ℝ) (P : I → ℝ) + (hT : ∀ j, T j ≠ 0) (y : J → ℤ) : + normalizedIntegerColumns B T P *ᵥ (fun j => (y j : ℝ) / T j) = + fun i => ((B *ᵥ y) i : ℝ) / P i := by + have hc : Matrix.diagonal T *ᵥ (fun j => (y j : ℝ) / T j) = fun j => (y j : ℝ) := by + funext j + simp only [Matrix.mulVec_diagonal] + field_simp [hT j] + unfold normalizedIntegerColumns + rw [← Matrix.mulVec_mulVec, hc, ← Matrix.mulVec_mulVec] + funext i + simp only [Matrix.mulVec_diagonal] + have hcast : ((B *ᵥ y) i : ℝ) = (B.map (Int.castRingHom ℝ) *ᵥ fun j => (y j : ℝ)) i := + (Int.castRingHom ℝ).map_mulVec B y i + rw [← hcast, div_eq_mul_inv] + ring + +noncomputable def normalizedPivotEquiv (A : Matrix I I ℤ) (hA : A.det ≠ 0) + (S P : I → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) : + (I → ℝ) ≃L[ℝ] (I → ℝ) := + (matrixSupCLM_inverse_spec (normalizedIntegerPivot A S P) + (normalizedIntegerPivot_det_ne_zero A hA S P hS hP)).1.choose + +theorem normalizedPivotEquiv_coe (A : Matrix I I ℤ) (hA : A.det ≠ 0) + (S P : I → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) : + (normalizedPivotEquiv A hA S P hS hP).toContinuousLinearMap = + matrixSupCLM (normalizedIntegerPivot A S P) := + (matrixSupCLM_inverse_spec (normalizedIntegerPivot A S P) + (normalizedIntegerPivot_det_ne_zero A hA S P hS hP)).1.choose_spec + +theorem normalizedPivotEquiv_inverseJacobian (A : Matrix I I ℤ) (hA : A.det ≠ 0) + (S P : I → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) : + inverseJacobian (normalizedPivotEquiv A hA S P hS hP) = + |(normalizedIntegerPivot A S P).det|⁻¹ := by + rw [inverseJacobian_eq] + have he := congrArg ContinuousLinearMap.toLinearMap (normalizedPivotEquiv_coe A hA S P hS hP) + change (normalizedPivotEquiv A hA S P hS hP).toLinearEquiv.toLinearMap = + (normalizedIntegerPivot A S P).mulVecLin at he + rw [he, ← Matrix.toLin'_apply', LinearMap.det_toLin'] + +theorem scaledIntegerFiber_graph (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (S P : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) + (hT : ∀ j, 0 < T j) {x : I → ℤ} {y : J → ℤ} {v : I → ℤ} + (hxy : A *ᵥ x + B *ᵥ y = v) : + (fun i => (x i : ℝ) / S i) = (normalizedPivotEquiv A hA S P hS hP).symm + ((fun i => (v i : ℝ) / P i) - + matrixSupCLM (normalizedIntegerColumns B T P) (fun j => (y j : ℝ) / T j)) := by + apply (normalizedPivotEquiv A hA S P hS hP).injective + rw [ContinuousLinearEquiv.apply_symm_apply] + change (normalizedPivotEquiv A hA S P hS hP).toContinuousLinearMap _ = _ + rw [normalizedPivotEquiv_coe, matrixSupCLM_apply, matrixSupCLM_apply] + change normalizedIntegerColumns A S P *ᵥ _ = _ + rw [normalizedIntegerColumns_mulVec A S P (fun i => (hS i).ne') x, + normalizedIntegerColumns_mulVec B T P (fun j => (hT j).ne') y] + funext i + have hi := congrFun hxy i + have hi' : ((A *ᵥ x) i : ℝ) + ((B *ᵥ y) i : ℝ) = v i := by exact_mod_cast hi + change ((A *ᵥ x) i : ℝ) / P i = (v i : ℝ) / P i - ((B *ᵥ y) i : ℝ) / P i + rw [← sub_div, ← hi'] + congr 1 + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +noncomputable def scaledIntegerWeight (f : (J → ℝ) × (I → ℝ) → ℝ) + (S : I → ℝ) (T : J → ℝ) (p : (I → ℤ) × (J → ℤ)) : ℝ := + f ((fun j => (p.2 j : ℝ) / T j), (fun i => (p.1 i : ℝ) / S i)) + +theorem scaledIntegerWeight_eq_slice (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (S P : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) + (hT : ∀ j, 0 < T j) (f : (J → ℝ) × (I → ℝ) → ℝ) + {p : (I → ℤ) × (J → ℤ)} {v : I → ℤ} (hp : A *ᵥ p.1 + B *ᵥ p.2 = v) : + scaledIntegerWeight f S T p = + pivotSliceProfile (normalizedPivotEquiv A hA S P hS hP) + (matrixSupCLM (normalizedIntegerColumns B T P)) f (fun i => (v i : ℝ) / P i) + (fun j => (p.2 j : ℝ) / T j) := by + unfold scaledIntegerWeight pivotSliceProfile + rw [scaledIntegerFiber_graph A hA B S P T hS hP hT hp] + +omit [DecidableEq J] in +theorem integerFiber_free_injective (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (v : I → ℤ) : + Function.Injective (fun p : {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v} => p.val.2) := by + intro p q hpq + change p.val.2 = q.val.2 at hpq + apply Subtype.ext + apply Prod.ext + · apply Matrix.mulVec_injective_of_det_ne_zero hA + have he := p.property.trans q.property.symm + rw [hpq] at he + exact add_right_cancel he + · exact hpq + +theorem scaledIntegerWeight_fiber_summable (A : Matrix I I ℤ) (hA : A.det ≠ 0) + (B : Matrix I J ℤ) (v : I → ℤ) (S P : I → ℝ) (T : J → ℝ) + (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) (hT : ∀ j, 0 < T j) + (f : (J → ℝ) × (I → ℝ) → ℝ) {R : ℝ} (hsupport : ∀ p, R < ‖p‖ → f p = 0) : + Summable (fun p : {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v} => + scaledIntegerWeight f S T p.val) := by + let g := pivotSliceProfile (normalizedPivotEquiv A hA S P hS hP) + (matrixSupCLM (normalizedIntegerColumns B T P)) f (fun i => (v i : ℝ) / P i) + have hg : ∀ y, R < ‖y‖ → g y = 0 := + pivotSliceProfile_zero_outside _ _ hsupport _ + have hs : Summable (fun y : J → ℤ => g (fun j => (y j : ℝ) / T j)) := by + simpa only [zero_add, one_mul] using + scaledRectangularWeight_summable g (fun _ => 0) T (m := 1) zero_lt_one hT hg + apply (hs.comp_injective (integerFiber_free_injective A hA B v)).congr + intro p + exact (scaledIntegerWeight_eq_slice A hA B S P T hS hP hT f p.property).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped Matrix BigOperators NNReal + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +noncomputable def scaledIntegerFiberOutputMass (A : Matrix I I ℤ) (B : Matrix I J ℤ) + (S P : I → ℝ) (T : J → ℝ) (f : (J → ℝ) × (I → ℝ) → ℝ) (v : I → ℤ) : ℝ := + ((∏ i, P i) / ((∏ i, S i) * (∏ j, T j))) * + ∑' p : {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v}, scaledIntegerWeight f S T p.val + +noncomputable def normalizedFiberDensity (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (S P : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) + (f : (J → ℝ) × (I → ℝ) → ℝ) : (I → ℝ) → ℝ := + pivotOutputDensity (normalizedPivotEquiv A hA S P hS hP) + (matrixSupCLM (normalizedIntegerColumns B T P)) f + +theorem integerFiber_grid_error (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (v : I → ℤ) (y₀ : J → ℤ) (hy₀ : pivotFreeAdmissible A B v y₀) + {m : ℤ} (hm : 0 < m) (hdiv : A.det ∣ m) + (S P : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) (hT : ∀ j, 0 < T j) + (f : (J → ℝ) × (I → ℝ) → ℝ) {K : ℝ≥0} (hf : LipschitzWith K f) + {R δ : ℝ} (hR : 0 ≤ R) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ j, (m : ℝ) / T j ≤ δ) + (hsupport : ∀ p, R < ‖p‖ → f p = 0) + (r : integerLatticeResidue (pivotFreeLattice A B) m) : + let e := normalizedPivotEquiv A hA S P hS hP + let b := matrixSupCLM (normalizedIntegerColumns B T P) + |((m.natAbs : ℝ) ^ Fintype.card J / (∏ j, T j)) * + (∑' z : J → ℤ, scaledIntegerWeight f S T + ((pivotFiberGridEquiv A hA B v y₀ hy₀ hm.ne' hdiv).symm (r, z)).val) - + ∫ y, pivotSliceProfile e b f (fun i => (v i : ℝ) / P i) y| ≤ + (2 * R + 2) ^ Fintype.card J * ((K * pivotGraphLipschitz e b : ℝ≥0) : ℝ) * δ := by + let e := normalizedPivotEquiv A hA S P hS hP + let b := matrixSupCLM (normalizedIntegerColumns B T P) + let g := pivotSliceProfile e b f (fun i => (v i : ℝ) / P i) + let c : J → ℝ := fun j => ((y₀ j + r.out.val j : ℤ) : ℝ) + have hmR : (0 : ℝ) < m := by exact_mod_cast hm + have heq (z : J → ℤ) : scaledIntegerWeight f S T + ((pivotFiberGridEquiv A hA B v y₀ hy₀ hm.ne' hdiv).symm (r, z)).val = + g (fun j => (c j + (m : ℝ) * z j) / T j) := by + rw [scaledIntegerWeight_eq_slice A hA B S P T hS hP hT f + ((pivotFiberGridEquiv A hA B v y₀ hy₀ hm.ne' hdiv).symm (r, z)).property] + change g _ = g _ + congr 1 + rw [pivotFiberGridEquiv_free] + funext j + simp only [c, Pi.add_apply, Pi.smul_apply, smul_eq_mul, Int.cast_add, Int.cast_mul] + have hq := scaledRectangular_quadrature g (pivotSliceProfile_lipschitz e b hf _) + c T hmR hT hR hδ hδ1 hmesh (pivotSliceProfile_zero_outside e b hsupport _) + have habs : (m.natAbs : ℝ) = m := by + rw [Nat.cast_natAbs, abs_of_pos hm] + simp_rw [heq, habs] + exact hq + +theorem integerFiber_quadrature (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (v : I → ℤ) (hv : v ∈ pivotFullImage A B) + {m : ℤ} (hm : 0 < m) (hdiv : A.det ∣ m) + (S P : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) (hT : ∀ j, 0 < T j) + (f : (J → ℝ) × (I → ℝ) → ℝ) {K : ℝ≥0} (hf : LipschitzWith K f) + {R δ : ℝ} (hR : 0 ≤ R) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ j, (m : ℝ) / T j ≤ δ) + (hsupport : ∀ p, R < ‖p‖ → f p = 0) : + let e := normalizedPivotEquiv A hA S P hS hP + let b := matrixSupCLM (normalizedIntegerColumns B T P) + |scaledIntegerFiberOutputMass A B S P T f v - + ((pivotFullImage A B).toAddSubgroup.index : ℝ) * + normalizedFiberDensity A hA B S P T hS hP f (fun i => (v i : ℝ) / P i)| ≤ + (((pivotFullImage A B).toAddSubgroup.index : ℝ) / |(normalizedIntegerPivot A S P).det|) * + ((2 * R + 2) ^ Fintype.card J * ((K * pivotGraphLipschitz e b : ℝ≥0) : ℝ) * δ) := by + obtain ⟨x₀, y₀, hxy⟩ := (pivotFullImage_iff A B v).mp hv + have hy₀ := (pivotFreeAdmissible_iff A B v y₀).mpr ⟨x₀, hxy⟩ + have ht := pivotFiber_error_of_grid_errors A hA B v y₀ hy₀ hm.ne' hdiv S P T hS hP hT + (scaledIntegerWeight f S T) (scaledIntegerWeight_fiber_summable A hA B v S P T hS hP hT f hsupport) + (integerFiber_grid_error A hA B v y₀ hy₀ hm hdiv S P T hS hP hT f hf hR hδ hδ1 hmesh hsupport) + dsimp only + unfold scaledIntegerFiberOutputMass normalizedFiberDensity + rw [pivotOutputDensity_slice_formula, normalizedPivotEquiv_inverseJacobian] + simpa only [div_eq_mul_inv, mul_assoc] using ht + +omit [DecidableEq I] [DecidableEq J] in +theorem scaledIntegerFiberOutputMass_zero_off_image (A : Matrix I I ℤ) (B : Matrix I J ℤ) + (S P : I → ℝ) (T : J → ℝ) (f : (J → ℝ) × (I → ℝ) → ℝ) (v : I → ℤ) + (hv : v ∉ pivotFullImage A B) : scaledIntegerFiberOutputMass A B S P T f v = 0 := by + have hempty : IsEmpty {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v} := + ⟨fun p => hv ((pivotFullImage_iff A B v).mpr ⟨p.val.1, p.val.2, p.property⟩)⟩ + simp only [scaledIntegerFiberOutputMass, tsum_empty, mul_zero] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix NNReal + +noncomputable def integerFiberErrorConstant (j d : ℕ) (G U V R : ℝ) (K : ℝ≥0) : ℝ := + G * (j.factorial * U ^ j) * (2 * R + 2) ^ d * K * max 1 (U * V) + +theorem integerFiberErrorConstant_nonneg (j d : ℕ) {G U V R : ℝ} (K : ℝ≥0) + (hG : 0 ≤ G) (hU : 0 ≤ U) (hR : 0 ≤ R) : + 0 ≤ integerFiberErrorConstant j d G U V R K := by + unfold integerFiberErrorConstant + positivity + +theorem integerFiber_uniform_quadrature {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (v : I → ℤ) (hv : v ∈ pivotFullImage A B) + {m : ℤ} (hm : 0 < m) (hdiv : A.det ∣ m) + (S P : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) (hT : ∀ j, 0 < T j) + (f : (J → ℝ) × (I → ℝ) → ℝ) {K : ℝ≥0} (hf : LipschitzWith K f) + {R δ G U V : ℝ} (hR : 0 ≤ R) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hmesh : ∀ j, (m : ℝ) / T j ≤ δ) (hsupport : ∀ p, R < ‖p‖ → f p = 0) + (hindex : ((pivotFullImage A B).toAddSubgroup.index : ℝ) ≤ G) + (hinv : ‖(normalizedPivotEquiv A hA S P hS hP).symm.toContinuousLinearMap‖ ≤ U) + (hcol : ‖matrixSupCLM (normalizedIntegerColumns B T P)‖ ≤ V) : + |scaledIntegerFiberOutputMass A B S P T f v - + ((pivotFullImage A B).toAddSubgroup.index : ℝ) * + normalizedFiberDensity A hA B S P T hS hP f (fun i => (v i : ℝ) / P i)| ≤ + integerFiberErrorConstant (Fintype.card I) (Fintype.card J) G U V R K * δ := by + let e := normalizedPivotEquiv A hA S P hS hP + let b := matrixSupCLM (normalizedIntegerColumns B T P) + have hU : 0 ≤ U := (norm_nonneg _).trans hinv + have hG : 0 ≤ G := (Nat.cast_nonneg _).trans hindex + have hJ := inverseJacobian_le_norm_bound e hinv + have hgraph := pivotGraphLipschitz_le_norm_bounds e b hinv hcol + have hJac : |(normalizedIntegerPivot A S P).det|⁻¹ = inverseJacobian e := + (normalizedPivotEquiv_inverseJacobian A hA S P hS hP).symm + have ht := integerFiber_quadrature A hA B v hv hm hdiv S P T hS hP hT f hf + hR hδ hδ1 hmesh hsupport + dsimp only at ht + rw [div_eq_mul_inv, hJac] at ht + have houter : ((pivotFullImage A B).toAddSubgroup.index : ℝ) * inverseJacobian e ≤ + G * ((Fintype.card I).factorial * U ^ Fintype.card I) := + mul_le_mul hindex hJ (inverseJacobian_pos e).le hG + have hinner : (2 * R + 2) ^ Fintype.card J * ((K * pivotGraphLipschitz e b : ℝ≥0) : ℝ) * δ ≤ + (2 * R + 2) ^ Fintype.card J * ((K : ℝ) * max 1 (U * V)) * δ := by + apply mul_le_mul_of_nonneg_right _ hδ + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact mul_le_mul_of_nonneg_left hgraph K.coe_nonneg + calc + _ ≤ _ := ht + _ ≤ (G * ((Fintype.card I).factorial * U ^ Fintype.card I)) * + ((2 * R + 2) ^ Fintype.card J * ((K : ℝ) * max 1 (U * V)) * δ) := + mul_le_mul houter hinner (by positivity) (by positivity) + _ = _ := by unfold integerFiberErrorConstant; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFrozenChart.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFrozenChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4cdd27ced47163087bf1e710c3e6a9a6b0db5ef --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerFrozenChart.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.Progressions.Polynomial.BufferedSampledCurrentGradePhase + +namespace OAI + +section + +namespace Erdos3 +open _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped Classical + +variable {I R : Type*} [CommRing R] + +noncomputable def frozenCoordinate (keep : I → Prop) (fixed : {i // ¬keep i} → R) + (i : I) : MvPolynomial {i // keep i} R := + if hi : keep i then X ⟨i, hi⟩ else C (fixed ⟨i, hi⟩) + +noncomputable def freezePolynomial (keep : I → Prop) (fixed : {i // ¬keep i} → R) : + MvPolynomial I R →ₐ[R] MvPolynomial {i // keep i} R := + aeval (frozenCoordinate keep fixed) + +theorem frozenCoordinate_support (keep : I → Prop) (fixed : {i // ¬keep i} → R) (i : I) : + frozenCoordinate keep fixed i ∈ weightedSupportLE (fun _ => 1) 1 := by + by_cases hi : keep i + · simp only [frozenCoordinate, dite_eq_left hi] + exact weightedSupportLE_X (R := R) (fun _ : {i // keep i} => 1) ⟨i, hi⟩ + · simp only [frozenCoordinate, dite_eq_right hi] + exact weightedSupportLE_C (fun _ : {i // keep i} => 1) 1 (fixed ⟨i, hi⟩) + +theorem freezePolynomial_support (keep : I → Prop) (fixed : {i // ¬keep i} → R) + {P : MvPolynomial I R} {d : ℕ} (hP : P ∈ weightedSupportLE (fun _ => 1) d) : + freezePolynomial keep fixed P ∈ weightedSupportLE (fun _ => 1) d := + weightedSupportLE_aeval (fun _ => 1) (fun _ => 1) _ (frozenCoordinate_support keep fixed) hP + +theorem freezePolynomial_degree (keep : I → Prop) (fixed : {i // ¬keep i} → R) + {P : MvPolynomial I R} {d : ℕ} (hP : P.totalDegree ≤ d) : + (freezePolynomial keep fixed P).totalDegree ≤ d := + (mem_weightedSupportLE_one_iff _ _).mp + (freezePolynomial_support keep fixed ((mem_weightedSupportLE_one_iff _ _).mpr hP)) + +theorem freezePolynomial_eval (keep : I → Prop) (fixed : {i // ¬keep i} → R) + (P : MvPolynomial I R) (x : {i // keep i} → R) : + eval x (freezePolynomial keep fixed P) = eval (finiteSplitPoint keep x fixed) P := by + calc + _ = eval (fun i => eval x (frozenCoordinate keep fixed i)) P := + MvPolynomial.comp_aeval_apply _ (MvPolynomial.aeval x) P + _ = _ := by + apply congrArg (fun y => eval y P) + funext i + by_cases hi : keep i <;> simp [frozenCoordinate, finiteSplitPoint, hi] + +theorem freezePolynomial_sub_lower (keep : I → Prop) + (fixed fixed' : {i // ¬keep i} → R) {P : MvPolynomial I R} {d : ℕ} + (hP : P ∈ weightedSupportLE (fun _ => 1) d) : + freezePolynomial keep fixed P - freezePolynomial keep fixed' P ∈ + weightedSupportLT (fun _ => 1) d := by + apply weightedComparison_difference (fun _ => 1) (fun _ => 1) + (freezePolynomial keep fixed) (freezePolynomial keep fixed') + (fun i => by simpa only [freezePolynomial, aeval_X] using frozenCoordinate_support keep fixed i) + (fun i => by simpa only [freezePolynomial, aeval_X] using frozenCoordinate_support keep fixed' i) + _ hP + intro i + by_cases hi : keep i + · simp only [freezePolynomial, aeval_X, frozenCoordinate, dite_eq_left hi, sub_self] + exact Submodule.zero_mem _ + · simp only [freezePolynomial, aeval_X, frozenCoordinate, dite_eq_right hi, ← map_sub] + exact weightedSupportLE_lt_succ (weightedSupportLE_C (fun _ => 1) 0 _) + +theorem freezePolynomial_top_independent (keep : I → Prop) + (fixed fixed' : {i // ¬keep i} → R) {P : MvPolynomial I R} {d : ℕ} + (hP : P.totalDegree ≤ d) : + homogeneousComponent d (freezePolynomial keep fixed P) = + homogeneousComponent d (freezePolynomial keep fixed' P) := by + have hlower := freezePolynomial_sub_lower keep fixed fixed' + ((mem_weightedSupportLE_one_iff _ _).mpr hP) + change weightedHomogeneousComponent (fun _ => 1) d _ = + weightedHomogeneousComponent (fun _ => 1) d _ + ext α + rw [coeff_weightedHomogeneousComponent, coeff_weightedHomogeneousComponent] + split_ifs with hα + · have hz : (freezePolynomial keep fixed P - freezePolynomial keep fixed' P).coeff α = 0 := by + by_contra hn + have hlt := hlower (mem_support_iff.mpr hn) + exact (Nat.lt_irrefl d) (hα ▸ hlt) + exact sub_eq_zero.mp (by simpa only [AddMonoidAlgebra.coeff_sub, Finsupp.sub_apply] using hz) + · rfl + +theorem freezePolynomial_map {S : Type*} [CommRing S] (φ : R →+* S) + (keep : I → Prop) (fixed : {i // ¬keep i} → R) (P : MvPolynomial I R) : + MvPolynomial.map φ (freezePolynomial keep fixed P) = + freezePolynomial keep (fun i => φ (fixed i)) (MvPolynomial.map φ P) := by + change MvPolynomial.map φ (eval₂ C (frozenCoordinate keep fixed) P) = + eval₂ C (frozenCoordinate keep (fun i => φ (fixed i))) (MvPolynomial.map φ P) + rw [map_eval₂] + apply congrArg (fun f => eval₂ C f (MvPolynomial.map φ P)) + funext i + by_cases hi : keep i <;> simp [frozenCoordinate, hi] + +theorem frozenCoordinate_zero_homogeneous (keep : I → Prop) (i : I) : + (frozenCoordinate keep (0 : {i // ¬keep i} → R) i).IsWeightedHomogeneous + (fun _ => 1) 1 := by + by_cases hi : keep i + · simp only [frozenCoordinate, dite_eq_left hi] + exact isWeightedHomogeneous_X R (fun _ : {i // keep i} => 1) ⟨i, hi⟩ + · simp only [frozenCoordinate, dite_eq_right hi, Pi.zero_apply, map_zero] + exact isWeightedHomogeneous_zero R (fun _ : {i // keep i} => 1) 1 + +theorem freezePolynomial_top (keep : I → Prop) (fixed : {i // ¬keep i} → R) + {P : MvPolynomial I R} {d : ℕ} (hP : P.totalDegree ≤ d) : + homogeneousComponent d (freezePolynomial keep fixed P) = + freezePolynomial keep 0 (homogeneousComponent d P) := by + rw [freezePolynomial_top_independent keep fixed 0 hP] + exact (aeval_weightedHomogeneousComponent (fun _ : I => 1) (fun _ => 1) + (frozenCoordinate keep 0) (frozenCoordinate_zero_homogeneous keep) d P).symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGaussianGeometric.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGaussianGeometric.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d69a8ba7e777466fb46a75844728eae629f2091 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGaussianGeometric.lean @@ -0,0 +1,72 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +theorem hasSum_geometric_natAbs {r : ℝ} (hr : 0 ≤ r) (hr1 : r < 1) : + HasSum (fun n : ℤ => r ^ n.natAbs) ((1 - r)⁻¹ + r * (1 - r)⁻¹) := by + have h := hasSum_geometric_of_lt_one hr hr1 + apply HasSum.of_nat_of_neg_add_one + · simpa using h + · convert! h.mul_left r using 1 + funext n + have hn : (-((n : ℤ) + 1)).natAbs = n + 1 := by + rw [Int.natAbs_neg, show (n : ℤ) + 1 = ((n + 1 : ℕ) : ℤ) by omega] + rfl + rw [hn, pow_succ, mul_comm] + +theorem integer_geometric_sum_bound {t : ℝ} (ht : 0 < t) : + (∑' n : ℤ, (Real.exp (-1 / t)) ^ n.natAbs) ≤ 1 + 2 * t := by + let r := Real.exp (-1 / t) + have hr : 0 < r := Real.exp_pos _ + have hr1 : r < 1 := Real.exp_lt_one_iff.mpr (div_neg_of_neg_of_pos (by norm_num) ht) + rw [(hasSum_geometric_natAbs hr.le hr1).tsum_eq] + have hs : 0 < 1 - r := by linarith + have he : r * Real.exp (1 / t) = 1 := by + dsimp [r] + rw [← Real.exp_add, show -1 / t + 1 / t = 0 by ring, Real.exp_zero] + have hlin : t * r + r ≤ t := by + have h := mul_le_mul_of_nonneg_left (Real.add_one_le_exp (1 / t)) (mul_pos ht hr).le + have hl : t * r * (1 / t + 1) = t * r + r := by field_simp; ring + have hu : t * r * Real.exp (1 / t) = t := by rw [mul_assoc, he, mul_one] + rwa [hl, hu] at h + have hid : (1 - r)⁻¹ + r * (1 - r)⁻¹ = (1 + r) / (1 - r) := by ring + rw [hid] + apply (div_le_iff₀ hs).mpr + nlinarith + +theorem integer_gaussian_le_geometric (n : ℤ) {t : ℝ} (ht : 0 < t) : + Real.exp (-Real.pi / t * (n : ℝ) ^ 2) ≤ (Real.exp (-1 / t)) ^ n.natAbs := by + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + have hn : (n.natAbs : ℝ) ≤ (n.natAbs : ℝ) ^ 2 := by + exact_mod_cast (show n.natAbs ≤ n.natAbs ^ 2 by simpa only [pow_two] using Nat.le_mul_self n.natAbs) + have habs : (n.natAbs : ℝ) = |(n : ℝ)| := by simp + rw [habs, sq_abs] at hn + have hpi : |(n : ℝ)| ≤ Real.pi * (n : ℝ) ^ 2 := by + nlinarith [mul_nonneg (show 0 ≤ Real.pi - 1 by linarith [Real.pi_gt_three]) (sq_nonneg (n : ℝ))] + have hmul := mul_le_mul_of_nonneg_right hpi (inv_nonneg.mpr ht.le) + rw [habs] + simp only [div_eq_mul_inv] at hmul ⊢ + nlinarith + +theorem integer_gaussian_sum_bound {t : ℝ} (ht : 0 < t) (s : Finset ℤ) : + (∑ n ∈ s, Real.exp (-Real.pi / t * (n : ℝ) ^ 2)) ≤ 1 + 2 * t := by + have hr0 : 0 ≤ Real.exp (-1 / t) := (Real.exp_pos _).le + have hr1 : Real.exp (-1 / t) < 1 := + Real.exp_lt_one_iff.mpr (div_neg_of_neg_of_pos (by norm_num) ht) + calc + _ ≤ ∑ n ∈ s, (Real.exp (-1 / t)) ^ n.natAbs := + Finset.sum_le_sum fun n _ => integer_gaussian_le_geometric n ht + _ ≤ ∑' n : ℤ, (Real.exp (-1 / t)) ^ n.natAbs := + (hasSum_geometric_natAbs hr0 hr1).summable.sum_le_tsum s (fun n _ => by positivity) + _ ≤ _ := integer_geometric_sum_bound ht + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGridPlateauTransfer.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGridPlateauTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..36a5d4e274c8c44592af8749d38c4a15ddd07626 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGridPlateauTransfer.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.Progressions.Geometry.NormalizedSupportPlateau +import OAI.Combinatorics.Progressions.Probability.WeightedModeratePointMass + +namespace OAI + +section + +namespace Erdos3 + +theorem integerSupportTorusFactor_margin (H : ℝ) : + 2 * H + 1 ≤ (integerSupportTorusFactor H : ℝ) := by + have h := Nat.le_ceil H + simp only [integerSupportTorusFactor, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] + linarith + +theorem scaled_integer_support_close_buffered {J : Type*} (y z center : J → ℤ) + {H : ℝ} {K : ℕ} (hK : 0 < K) + (hy : ∀ j, |(y j : ℝ) - center j| ≤ H * K) + (hz : ∀ j, |(z j : ℝ) - center j| ≤ (H + 1 / 4) * K) : + ∀ j, |y j - z j| < (integerSupportTorusFactor H * K : ℕ) := by + intro j + have hK' : (0 : ℝ) < K := by exact_mod_cast hK + have hgap : (2 * H + 1 / 4) * K < (integerSupportTorusFactor H : ℝ) * K := by + apply mul_lt_mul_of_pos_right _ hK' + linarith [integerSupportTorusFactor_margin H] + have ht : |(y j : ℝ) - z j| ≤ (2 * H + 1 / 4) * K := by + calc + _ = |((y j : ℝ) - center j) + (center j - z j)| := by congr 1; ring + _ ≤ |(y j : ℝ) - center j| + |(center j : ℝ) - z j| := abs_add_le _ _ + _ ≤ H * K + (H + 1 / 4) * K := + add_le_add (hy j) (by simpa only [abs_sub_comm] using hz j) + _ = _ := by ring + have hlt := ht.trans_lt hgap + exact_mod_cast hlt + +theorem integerGridMass_eq_imageMass_on_buffered_support {X J : Type*} + [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (center z : J → ℤ) + {H : ℝ} {K : ℕ} (hK : 0 < K) + (hY : ∀ x, p.weight x ≠ 0 → ∀ j, |(Y x j : ℝ) - center j| ≤ H * K) + (hz : ∀ j, |(z j : ℝ) - center j| ≤ (H + 1 / 4) * K) : + integerGridMass p Y (integerSupportTorusFactor H * K) z = finiteImageMass p Y z := by + apply integerGridMass_eq_imageMass + intro x hx + exact scaled_integer_support_close_buffered (Y x) z center hK (hY x hx) hz + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +theorem integerGridDensity_plateau_transfer {X J : Type*} + [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (center z : J → ℤ) + {H ε : ℝ} {K M : ℕ} (hH : 0 ≤ H) (hK : 0 < K) + (hM : M = integerSupportTorusFactor H * K) + (hY : ∀ x, p.weight x ≠ 0 → ∀ j, |(Y x j : ℝ) - center j| ≤ H * K) + (a : ℂ) (hε : 0 ≤ ε) + (ha : ‖(integerGridDensity p Y K M z : ℂ) - a‖ ≤ ε) : + ‖(((K : ℝ) ^ Fintype.card J * ((p.toPMF.map Y) z).toReal : ℝ) : ℂ) - + (normalizedSupportPlateau H (fun j => ((z j : ℝ) - center j) / K) : ℂ) * a‖ ≤ ε := by + let χ := normalizedSupportPlateau H (fun j => ((z j : ℝ) - center j) / K) + let v : ℂ := ((K : ℝ) ^ Fintype.card J * ((p.toPMF.map Y) z).toReal : ℝ) + have hχ := normalizedSupportPlateau_range H (fun j => ((z j : ℝ) - center j) / K) + have hfix : (χ : ℂ) * v = v := by + by_cases hz : ∀ j, |(z j : ℝ) - center j| ≤ H * K + · have he : χ = 1 := normalizedSupportPlateau_grid_one hH hK center z hz + simp only [he, Complex.ofReal_one, one_mul] + · have he : finiteImageMass p Y z = 0 := by + unfold finiteImageMass FiniteProbabilityWeights.mean + apply Finset.sum_eq_zero + intro x _ + by_cases hx : p.weight x = 0 + · simp only [hx, zero_mul] + · have hn : Y x ≠ z := fun he => hz (he ▸ hY x hx) + simp only [ite_eq_right hn, mul_zero] + rw [finiteImageMass_eq_toPMF] at he + simp only [v, he, mul_zero, Complex.ofReal_zero] + change ‖v - (χ : ℂ) * a‖ ≤ ε + by_cases hχ0 : χ = 0 + · have hv : v = 0 := by simpa only [hχ0, Complex.ofReal_zero, zero_mul] using hfix.symm + simpa only [hv, hχ0, Complex.ofReal_zero, zero_mul, sub_self, norm_zero] using hε + · have hz := normalizedSupportPlateau_grid_support hK center z hχ0 + have hd : integerGridDensity p Y K M z = + (K : ℝ) ^ Fintype.card J * ((p.toPMF.map Y) z).toReal := by + unfold integerGridDensity + rw [hM, integerGridMass_eq_imageMass_on_buffered_support p Y center z hK hY hz, + finiteImageMass_eq_toPMF] + rw [hd] at ha + calc + _ = ‖(χ : ℂ) * (v - a)‖ := by rw [mul_sub, hfix] + _ = χ * ‖v - a‖ := by + rw [norm_mul, Complex.norm_real, Real.norm_of_nonneg hχ.1] + _ ≤ 1 * ε := mul_le_mul hχ.2 ha (norm_nonneg _) zero_le_one + _ = ε := one_mul ε + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGridPointCap.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGridPointCap.lean new file mode 100644 index 0000000000000000000000000000000000000000..75aad1df91d3c4187af0ceface4ddd848d9d49c1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerGridPointCap.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.Progressions.Estimates.WeightedApproximationCaps +import OAI.Combinatorics.Progressions.Probability.WeightedModeratePointMass + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerPointDensity_norm_le_fourier_sum {X J : Type*} + [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) + (K M : ℕ) [NeZero M] (z : J → ℤ) : + ‖(((K : ℝ) ^ Fintype.card J * ((p.toPMF.map Y) z).toReal : ℝ) : ℂ)‖ ≤ + ((K : ℝ) / M) ^ Fintype.card J * ∑ k, ‖integerGridCoefficient p Y M k‖ := by + have hmass : finiteImageMass p Y z ≤ integerGridMass p Y M z := by + apply p.mean_mono + intro x + by_cases hx : Y x = z + · simp only [hx, ite_true, le_refl] + · simp only [ite_eq_right hx] + split_ifs <;> norm_num + rw [Complex.norm_real, Real.norm_of_nonneg (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) ENNReal.toReal_nonneg)] + rw [← finiteImageMass_eq_toPMF] + calc + _ ≤ integerGridDensity p Y K M z := + mul_le_mul_of_nonneg_left hmass (pow_nonneg (Nat.cast_nonneg _) _) + _ ≤ ‖(integerGridDensity p Y K M z : ℂ)‖ := by + rw [Complex.norm_real, Real.norm_eq_abs] + exact le_abs_self _ + _ ≤ _ := by + rw [integerGridDensity_fourier, norm_mul, norm_pow, norm_div, + Complex.norm_natCast, Complex.norm_natCast] + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro k _ + simp only [norm_mul, norm_star, rectangularGridCharacter_norm, mul_one, le_refl] + +theorem pmf_bind_point_norm_le {X Y : Type*} (p : PMF X) (q : X → PMF Y) + (K C : ℝ) (z : Y) + (hcap : ∀ x, ‖((K * (q x z).toReal : ℝ) : ℂ)‖ ≤ C) : + ‖((K * ((p.bind q) z).toReal : ℝ) : ℂ)‖ ≤ C := by + rw [← pmf_bind_scaled_complex_average] + exact pmf_complex_average_norm_le p _ hcap + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerHomogeneousSymbolPullbackGrid.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerHomogeneousSymbolPullbackGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..32c9792815391712d6202e29e1be11faf672a089 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerHomogeneousSymbolPullbackGrid.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.Progressions.Estimates.HomogeneousRealSymbolPullback + +namespace OAI + +section + +namespace Erdos3 +open Module MvPolynomial +open scoped TensorProduct + +namespace VectorPolynomial + +variable {σ τ ι V : Type*} [LieRing V] [LieAlgebra ℚ V] [LieAlgebra ℝ V] + [IsScalarTower ℚ ℝ V] + +theorem coordinate_realChartSubstitute_for_grid + (A : σ → MvPolynomial τ ℝ) (f : V →ₗ[ℝ] ℝ) + (P : VectorPolynomial σ ℚ V) : + coordinate f.toAddMonoidHom (realChartSubstitute A P) = + aeval A (coordinate f.toAddMonoidHom P) := by + apply MvPolynomial.funext + intro u + rw [← coordinate_eval₂, eval₂_realChartSubstitute, coordinate_eval₂] + exact (MvPolynomial.comp_aeval_apply A (MvPolynomial.aeval u) _).symm + +omit [IsScalarTower ℚ ℝ V] in +theorem coefficientGrid_iff_coordinate (b : Basis ι ℝ V) (q : ℕ) + (P : VectorPolynomial σ ℚ V) : + CoefficientGrid b q P ↔ + ∀ i, realPolynomialCoefficientGrid q (coordinate (b.coord i).toAddMonoidHom P) := by + constructor + · intro h i + choose z hz using h + refine ⟨fun α => z α i, funext fun α => ?_⟩ + simpa only [coeff_coordinate, LinearMap.toAddMonoidHom_coe, Basis.coord_apply, + Pi.smul_apply, smul_eq_mul] + using congrFun (hz α) i + · intro h α + choose z hz using h + refine ⟨fun i => z i α, funext fun i => ?_⟩ + simpa only [coeff_coordinate, LinearMap.toAddMonoidHom_coe, Basis.coord_apply, + Pi.smul_apply, smul_eq_mul] + using congrFun (hz i) α + +theorem CoefficientGrid.realChartSubstitute_integral + (b : Basis ι ℝ V) (q : ℕ) (P : VectorPolynomial σ ℚ V) + (hP : CoefficientGrid b q P) (A : σ → MvPolynomial τ ℝ) + (hA : ∀ i, realPolynomialCoefficientGrid 1 (A i)) : + CoefficientGrid b q (realChartSubstitute A P) := by + rw [coefficientGrid_iff_coordinate] + intro i + rw [coordinate_realChartSubstitute_for_grid] + exact realPolynomialCoefficientGrid_aeval_integral + (coordinate (b.coord i).toAddMonoidHom P) A q + ((coefficientGrid_iff_coordinate b q P).mp hP i) hA + +end VectorPolynomial + +namespace NilpotentLieFiltration +open VectorPolynomial +variable {σ τ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (w : σ → ℕ) (v : τ → ℕ) + +theorem symbolRationalGrid_homogeneousPullback_of_coefficientGrid + (A : σ → MvPolynomial τ ℝ) + (hA : ∀ i, (A i).IsWeightedHomogeneous v (w i)) + (hAZ : ∀ i, realPolynomialCoefficientGrid 1 (A i)) + (q : ℕ) (R : F.RealPolynomialSymbolGroup w) + (hR : CoefficientGrid ((F.associatedGradedBasis b ω hF).baseChange ℝ) q + (F.realGradedSymbolPolynomial b ω hF w R.coord)) : + F.SymbolRationalGrid b ω hF v q + (F.realSymbolHomogeneousPullbackHom b ω hF w v A hA R) := by + apply F.symbolRationalGrid_of_gradedPolynomial b ω hF v q + change CoefficientGrid _ q + (F.realGradedSymbolPolynomial b ω hF v + (F.realSymbolHomogeneousPullback b ω hF w v A R.coord)) + rw [F.realGradedSymbolPolynomial_homogeneousPullback b ω hF w v A hA] + with_reducible exact (CoefficientGrid.realChartSubstitute_integral + (V := ℝ ⊗[ℚ] F.AssociatedGraded) + ((F.associatedGradedBasis b ω hF).baseChange ℝ) q + (F.realGradedSymbolPolynomial b ω hF w R.coord) hR A hAZ) + +theorem symbolRationalGrid_homogeneousPullback_integral + (A : σ → MvPolynomial τ ℝ) + (hA : ∀ i, (A i).IsWeightedHomogeneous v (w i)) + (hAZ : ∀ i, realPolynomialCoefficientGrid 1 (A i)) + (q : ℕ) (R : F.RealPolynomialSymbolGroup w) + (hR : F.SymbolRationalGrid b ω hF w q R) : + F.SymbolRationalGrid b ω hF v q + (F.realSymbolHomogeneousPullbackHom b ω hF w v A hA R) := by + apply F.symbolRationalGrid_homogeneousPullback_of_coefficientGrid b ω hF w v A hA hAZ q R + obtain ⟨z, hz⟩ := F.realGradedSymbolPolynomial_rational_coefficients b ω hF w q R hR + exact fun α => ⟨fun i => z (α, i), funext fun i => congrFun hz (α, i)⟩ + +theorem symbolRationalGrid_integerTopPullback + (βZ : σ → MvPolynomial τ ℤ) (q : ℕ) (R : F.RealPolynomialSymbolGroup w) + (hR : F.SymbolRationalGrid b ω hF w q R) : + F.SymbolRationalGrid b ω hF v q + (F.realSymbolHomogeneousPullbackHom b ω hF w v + (fun i => weightedHomogeneousComponent v (w i) (MvPolynomial.map (Int.castRingHom ℝ) (βZ i))) + (fun _ => weightedHomogeneousComponent_isWeightedHomogeneous _ _) R) := by + apply F.symbolRationalGrid_homogeneousPullback_integral b ω hF w v _ _ ?_ q R hR + intro i + exact realPolynomialCoefficientGrid_weightedHomogeneousComponent v (w i) 1 _ + (realPolynomialCoefficientGrid_intCast (βZ i)) + +theorem symbolRationalGrid_integerTopPullback_of_coefficientGrid + (βZ : σ → MvPolynomial τ ℤ) (q : ℕ) (R : F.RealPolynomialSymbolGroup w) + (hR : CoefficientGrid ((F.associatedGradedBasis b ω hF).baseChange ℝ) q + (F.realGradedSymbolPolynomial b ω hF w R.coord)) : + F.SymbolRationalGrid b ω hF v q + (F.realSymbolHomogeneousPullbackHom b ω hF w v + (fun i => weightedHomogeneousComponent v (w i) (MvPolynomial.map (Int.castRingHom ℝ) (βZ i))) + (fun _ => weightedHomogeneousComponent_isWeightedHomogeneous _ _) R) := by + apply F.symbolRationalGrid_homogeneousPullback_of_coefficientGrid b ω hF w v _ _ ?_ q R hR + intro i + exact realPolynomialCoefficientGrid_weightedHomogeneousComponent v (w i) 1 _ + (realPolynomialCoefficientGrid_intCast (βZ i)) + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerImageProbabilityLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerImageProbabilityLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..22281d01e2b479c82749ec34db2f81c60f386abb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerImageProbabilityLaw.lean @@ -0,0 +1,121 @@ +import OAI.Combinatorics.Progressions.Estimates.PointwiseNormalization +import OAI.Combinatorics.Progressions.Probability.PivotDensityCap +import OAI.Combinatorics.Progressions.Probability.ScaledInputProbability + +namespace OAI + + +namespace Erdos3 + +open MeasureTheory +open scoped Matrix NNReal BigOperators + +noncomputable def normalizedIntegerFiberOutputMass {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (S P : I → ℝ) (T : J → ℝ) + (f : (J → ℝ) × (I → ℝ) → ℝ) (v : I → ℤ) : ℝ := + scaledIntegerFiberOutputMass A B S P T f v / scaledInputMass f S T + +noncomputable def normalizedFiberErrorConstant (j d : ℕ) (G U V R H : ℝ) (K : ℝ≥0) : ℝ := + 2 * integerFiberErrorConstant j d G U V R K + + 2 * (G * (j.factorial * U ^ j) * H * (2 * R) ^ d) * ((2 * R + 2) ^ (j + d) * K) + +theorem normalizedIntegerFiberOutputMass_pmf {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (f : (J → ℝ) × (I → ℝ) → ℝ) + (hf0 : ∀ p, 0 ≤ f p) (S P : I → ℝ) (T : J → ℝ) + (hS : ∀ i, 0 < S i) (hT : ∀ j, 0 < T j) {R : ℝ} + (hsupport : ∀ p, R < ‖p‖ → f p = 0) (hM : 0 < scaledInputMass f S T) (v : I → ℤ) : + normalizedIntegerFiberOutputMass A B S P T f v = + (∏ i, P i) * (integerImagePMF A B f hf0 S T hS hT hsupport hM v).toReal := + (integerImagePMF_scaled A B f hf0 S P T hS hT hsupport hM v).symm + +theorem normalizedIntegerFiber_uniform_error {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (v : I → ℤ) (hv : v ∈ pivotFullImage A B) {m : ℤ} (hm : 0 < m) (hdiv : A.det ∣ m) + (S P : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) (hT : ∀ j, 0 < T j) + (f : (J → ℝ) × (I → ℝ) → ℝ) {K : ℝ≥0} (hf : LipschitzWith K f) + {R δ G U V H : ℝ} (hR : 0 ≤ R) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hH : 0 ≤ H) + (hmeshS : ∀ i, 1 / S i ≤ δ) (hmeshT : ∀ j, (m : ℝ) / T j ≤ δ) + (hsupport : ∀ p, R < ‖p‖ → f p = 0) (hmass : (∫ p, f p) = 1) + (hsmall : (2 * R + 2) ^ (Fintype.card I + Fintype.card J) * K * δ ≤ 1 / 2) + (hbound : ∀ p, ‖f p‖ ≤ H) + (hindex : ((pivotFullImage A B).toAddSubgroup.index : ℝ) ≤ G) + (hinv : ‖(normalizedPivotEquiv A hA S P hS hP).symm.toContinuousLinearMap‖ ≤ U) + (hcol : ‖matrixSupCLM (normalizedIntegerColumns B T P)‖ ≤ V) : + 0 < scaledInputMass f S T ∧ + |normalizedIntegerFiberOutputMass A B S P T f v - + ((pivotFullImage A B).toAddSubgroup.index : ℝ) * + normalizedFiberDensity A hA B S P T hS hP f (fun i => (v i : ℝ) / P i)| ≤ + normalizedFiberErrorConstant (Fintype.card I) (Fintype.card J) G U V R H K * δ := by + have hm1 : (1 : ℝ) ≤ m := by exact_mod_cast (show (1 : ℤ) ≤ m by omega) + have hmeshT' (j) : 1 / T j ≤ δ := + (div_le_div_of_nonneg_right hm1 (hT j).le).trans (hmeshT j) + have hM := (scaledInputMass_bounds f hf S T hS hT hR hδ hδ1 hmeshS hmeshT' hsupport hmass hsmall).1 + have hMpos : 0 < scaledInputMass f S T := by linarith + refine ⟨hMpos, ?_⟩ + have hmassError := scaledInputMass_error f hf S T hS hT hR hδ hδ1 hmeshS hmeshT' hsupport + rw [hmass] at hmassError + have herror := integerFiber_uniform_quadrature A hA B v hv hm hdiv S P T hS hP hT f hf + hR hδ hδ1 hmeshT hsupport hindex hinv hcol + have hcapDensity := pivotOutputDensity_abs_le_uniform (normalizedPivotEquiv A hA S P hS hP) + (matrixSupCLM (normalizedIntegerColumns B T P)) f hR hH hsupport hbound hinv + (fun i => (v i : ℝ) / P i) + have hG : 0 ≤ G := (Nat.cast_nonneg _).trans hindex + have hcap : |((pivotFullImage A B).toAddSubgroup.index : ℝ) * + normalizedFiberDensity A hA B S P T hS hP f (fun i => (v i : ℝ) / P i)| ≤ + G * ((Fintype.card I).factorial * U ^ Fintype.card I) * H * (2 * R) ^ Fintype.card J := by + rw [abs_mul, abs_of_nonneg (Nat.cast_nonneg _)] + exact (mul_le_mul hindex hcapDensity (abs_nonneg _) hG).trans_eq (by ring) + have h := pointwise_normalization_error hM herror hmassError hcap + exact h.trans_eq (by unfold normalizedFiberErrorConstant; ring) + +end Erdos3 + + +namespace Erdos3 + +open MeasureTheory +open scoped Matrix + +variable {I J : Type*} [Fintype I] [Fintype J] + +theorem integerImagePMF_measure_map (A : Matrix I I ℤ) (B : Matrix I J ℤ) + (f : (J → ℝ) × (I → ℝ) → ℝ) (hf0 : ∀ p, 0 ≤ f p) + (S : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hT : ∀ j, 0 < T j) + {R : ℝ} (hsupport : ∀ p, R < ‖p‖ → f p = 0) (hM : 0 < scaledInputMass f S T) : + (scaledInputPMF f hf0 S T hS hT hsupport hM).toMeasure.map + (fun p => A *ᵥ p.1 + B *ᵥ p.2) = + (integerImagePMF A B f hf0 S T hS hT hsupport hM).toMeasure := + PMF.toMeasure_map (fun p : (I → ℤ) × (J → ℤ) => A *ᵥ p.1 + B *ᵥ p.2) + _ (measurable_of_countable _) + +theorem integerImagePMF_singleton (A : Matrix I I ℤ) (B : Matrix I J ℤ) + (f : (J → ℝ) × (I → ℝ) → ℝ) (hf0 : ∀ p, 0 ≤ f p) + (S : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hT : ∀ j, 0 < T j) + {R : ℝ} (hsupport : ∀ p, R < ‖p‖ → f p = 0) (hM : 0 < scaledInputMass f S T) (v : I → ℤ) : + (integerImagePMF A B f hf0 S T hS hT hsupport hM).toMeasure.real {v} = + (∑' p : {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v}, + scaledIntegerWeight f S T p.val) / scaledInputWeightSum f S T := by + rw [measureReal_def, PMF.toMeasure_apply_singleton _ v (measurableSet_singleton v)] + exact integerImagePMF_apply A B f hf0 S T hS hT hsupport hM v + +theorem integerImagePMF_zero_off_image (A : Matrix I I ℤ) (B : Matrix I J ℤ) + (f : (J → ℝ) × (I → ℝ) → ℝ) (hf0 : ∀ p, 0 ≤ f p) + (S : I → ℝ) (T : J → ℝ) (hS : ∀ i, 0 < S i) (hT : ∀ j, 0 < T j) + {R : ℝ} (hsupport : ∀ p, R < ‖p‖ → f p = 0) (hM : 0 < scaledInputMass f S T) + (v : I → ℤ) (hv : v ∉ pivotFullImage A B) : + integerImagePMF A B f hf0 S T hS hT hsupport hM v = 0 := by + apply (PMF.apply_eq_zero_iff _ v).mpr + intro hmem + obtain ⟨p, _, hp⟩ := (PMF.mem_support_map_iff _ _ _).mp hmem + exact hv ((pivotFullImage_iff A B v).mpr ⟨p.1, p.2, hp⟩) + +theorem normalizedIntegerFiberOutputMass_zero_off_image (A : Matrix I I ℤ) (B : Matrix I J ℤ) + (S P : I → ℝ) (T : J → ℝ) (f : (J → ℝ) × (I → ℝ) → ℝ) (v : I → ℤ) + (hv : v ∉ pivotFullImage A B) : normalizedIntegerFiberOutputMass A B S P T f v = 0 := by + rw [normalizedIntegerFiberOutputMass, scaledIntegerFiberOutputMass_zero_off_image A B S P T f v hv, + zero_div] + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerInterpolationExpBounds.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerInterpolationExpBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..52d0f62be26b666256950ca97f697330d4607ff4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerInterpolationExpBounds.lean @@ -0,0 +1,155 @@ +import OAI.Combinatorics.Progressions.Polynomial.IntegerPolynomialInterpolation + +namespace OAI + +section + +namespace Erdos3 + +theorem constantIntegerInterpolation_power_bounds {X ρ : ℝ} + (hX : 8 ≤ X) (hA : (probabilityProfileLipschitz : ℝ) ≤ X) + (hρ : 0 < ρ) (hρX : ρ⁻¹ ≤ X) : + constantIntegerInterpolationCap ρ ≤ X^3 ∧ constantIntegerInterpolationLip ρ ≤ X^7 := by + have hX0 : 0 ≤ X := by linarith + have hX1 : 1 ≤ X := by linarith + have h2 : (2 : ℝ) ≤ X := by linarith + have hc : constantIntegerInterpolationCap ρ ≤ X^3 := by + unfold constantIntegerInterpolationCap + rw [div_eq_mul_inv] + calc + _ ≤ X * X * X := by gcongr + _ = _ := by ring + refine ⟨hc, ?_⟩ + unfold constantIntegerInterpolationLip + apply max_le + · have ht : 2 * (probabilityProfileLipschitz : ℝ) / ρ^2 ≤ X^4 := by + rw [div_eq_mul_inv, ← inv_pow] + calc + _ ≤ X * X * X^2 := by gcongr + _ = _ := by ring + exact ht.trans (pow_le_pow_right₀ hX1 (by norm_num)) + · have hc0 : 0 ≤ constantIntegerInterpolationCap ρ := by + unfold constantIntegerInterpolationCap + positivity + calc + _ ≤ X * (X^3)^2 := by gcongr + _ = _ := by ring + +theorem principalAxisInterpolation_power_bounds (h L : ℕ) {X γ : ℝ} + (hX : 8 ≤ X) (hA : (probabilityProfileLipschitz : ℝ) ≤ X) + (hγ : 0 < γ) (hγX : γ⁻¹ ≤ X) (hL : (L : ℝ)^h ≤ X) : + principalAxisInterpolationCap h L γ ≤ X^3 ∧ principalAxisInterpolationLip h L γ ≤ X^7 := by + have hX0 : 0 ≤ X := by linarith + have hX1 : 1 ≤ X := by linarith + have h2 : (2 : ℝ) ≤ X := by linarith + have h4 : (4 : ℝ) ≤ X := by linarith + have hX3 : X ≤ X^3 := by simpa only [pow_one] using (pow_le_pow_right₀ hX1 (show 1 ≤ 3 by norm_num)) + constructor + · unfold principalAxisInterpolationCap + apply max_le + · rw [div_eq_mul_inv] + calc + _ ≤ X * X * X := by gcongr + _ = _ := by ring + · exact hL.trans hX3 + · unfold principalAxisInterpolationLip + apply max_le + · have ht : 8 * (probabilityProfileLipschitz : ℝ) * ((L : ℝ)^h)^2 / γ^2 ≤ X^6 := by + rw [div_eq_mul_inv, ← inv_pow] + calc + _ ≤ X * X * X^2 * X^2 := by gcongr + _ = _ := by ring + exact ht.trans (pow_le_pow_right₀ hX1 (by norm_num)) + · have ht : 2 * ((L : ℝ)^h)^2 ≤ X^3 := by + calc + _ ≤ X * X^2 := by gcongr + _ = _ := by ring + exact ht.trans (pow_le_pow_right₀ hX1 (by norm_num)) + +theorem tailAxisInterpolation_power_bounds (L s : ℕ) {X ε : ℝ} + (hX : 8 ≤ X) (hA : (probabilityProfileLipschitz : ℝ) ≤ X) + (hε : 0 < ε) (hεX : ε⁻¹ ≤ X) (hL : (L : ℝ)^s ≤ X) (hL1 : (L : ℝ)^(s+1) ≤ X) : + tailAxisInterpolationCap L s ε ≤ X^3 ∧ tailAxisInterpolationLip L s ε ≤ X^7 := by + have hX0 : 0 ≤ X := by linarith + have hX1 : 1 ≤ X := by linarith + have h2 : (2 : ℝ) ≤ X := by linarith + have hX3 : X ≤ X^3 := by simpa only [pow_one] using (pow_le_pow_right₀ hX1 (show 1 ≤ 3 by norm_num)) + constructor + · unfold tailAxisInterpolationCap + apply max_le + · rw [div_eq_mul_inv] + calc + _ ≤ X * X * X := by gcongr + _ = _ := by ring + · exact hL1.trans hX3 + · unfold tailAxisInterpolationLip + apply max_le + · have ht : 2 * (probabilityProfileLipschitz : ℝ) * ((L : ℝ)^s)^2 / ε^2 ≤ X^6 := by + rw [div_eq_mul_inv, ← inv_pow] + calc + _ ≤ X * X * X^2 * X^2 := by gcongr + _ = _ := by ring + exact ht.trans (pow_le_pow_right₀ hX1 (by norm_num)) + · have ht : 2 * ((L : ℝ)^(s+1))^2 ≤ X^3 := by + calc + _ ≤ X * X^2 := by gcongr + _ = _ := by ring + exact ht.trans (pow_le_pow_right₀ hX1 (by norm_num)) + +theorem integerPolynomialInterpolation_power_bounds (h L s : ℕ) {X ρ γ ε : ℝ} + (hX : 8 ≤ X) (hA : (probabilityProfileLipschitz : ℝ) ≤ X) + (hρ : 0 < ρ) (hγ : 0 < γ) (hε : 0 < ε) + (hρX : ρ⁻¹ ≤ X) (hγX : γ⁻¹ ≤ X) (hεX : ε⁻¹ ≤ X) + (hLh : (L : ℝ)^h ≤ X) (hLs : (L : ℝ)^s ≤ X) (hLs1 : (L : ℝ)^(s+1) ≤ X) : + integerPolynomialInterpolationCap h L s ρ γ ε ≤ X^3 ∧ + integerPolynomialInterpolationLip h L s ρ γ ε ≤ X^7 := by + obtain ⟨hc, hl⟩ := constantIntegerInterpolation_power_bounds hX hA hρ hρX + obtain ⟨pc, pl⟩ := principalAxisInterpolation_power_bounds h L hX hA hγ hγX hLh + obtain ⟨tc, tl⟩ := tailAxisInterpolation_power_bounds L s hX hA hε hεX hLs hLs1 + exact ⟨max_le hc (max_le pc tc), max_le hl (max_le pl tl)⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +def integerInterpolationLogEnvelope (m : ℕ) (P : ℝ) : ℝ := ((m : ℝ) + 1) * P + 8 + +theorem integerPolynomialInterpolation_exp_bounds (m h L s : ℕ) + (hh : h ≤ m) (hs : s ≤ m) {P ρ γ ε : ℝ} (hP : 0 ≤ P) + (hA : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) (hL : (L : ℝ) ≤ Real.exp P) + (hρ : 0 < ρ) (hγ : 0 < γ) (hε : 0 < ε) + (hρP : ρ⁻¹ ≤ Real.exp P) (hγP : γ⁻¹ ≤ Real.exp P) (hεP : ε⁻¹ ≤ Real.exp P) : + integerPolynomialInterpolationCap h L s ρ γ ε ≤ + Real.exp (3 * integerInterpolationLogEnvelope m P) ∧ + integerPolynomialInterpolationLip h L s ρ γ ε ≤ + Real.exp (7 * integerInterpolationLogEnvelope m P) := by + let Q := integerInterpolationLogEnvelope m P + let X := Real.exp Q + have hm0 := Nat.cast_nonneg (α := ℝ) m + have hPQ : P ≤ Q := by dsimp [Q, integerInterpolationLogEnvelope]; nlinarith + have hQ8 : 8 ≤ Q := by dsimp [Q, integerInterpolationLogEnvelope]; nlinarith + have hX : 8 ≤ X := by dsimp [X]; linarith [Real.add_one_le_exp Q] + have hPX : Real.exp P ≤ X := Real.exp_le_exp.mpr hPQ + have hp (k : ℕ) (hk : k ≤ m + 1) : (L : ℝ)^k ≤ X := by + calc + _ ≤ (Real.exp P)^k := pow_le_pow_left₀ (Nat.cast_nonneg _) hL _ + _ = Real.exp ((k : ℝ) * P) := (Real.exp_nat_mul P k).symm + _ ≤ X := by + apply Real.exp_le_exp.mpr + have hkr : (k : ℝ) ≤ (m : ℝ) + 1 := by exact_mod_cast hk + have hmul := mul_le_mul_of_nonneg_right hkr hP + dsimp [Q, integerInterpolationLogEnvelope] + linarith + have h := integerPolynomialInterpolation_power_bounds h L s hX (hA.trans hPX) hρ hγ hε + (hρP.trans hPX) (hγP.trans hPX) (hεP.trans hPX) (hp h (by omega)) (hp s (by omega)) (hp (s+1) (by omega)) + simpa only [X, ← Real.exp_nat_mul, Nat.cast_ofNat, Q] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalCyclicAverage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalCyclicAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..de5ed28a46f273cf2b76741dd852e8299d9410a2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalCyclicAverage.lean @@ -0,0 +1,34 @@ +import OAI.Combinatorics.Progressions.Sampling.CyclicIntervalSampling + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem cyclicInterval_zeroExtension_average {N : ℕ} [NeZero N] + (a len : ℕ) (hbound : a + len ≤ N) (hshort : 2 * ((len : ℤ) - 1) < N) + (f : ℤ → ℂ) : + (𝔼 n : ZMod N, finiteIndicator (cyclicInterval (a : ZMod N) len) n * f (n.val : ℤ)) = + (((len : ℝ) / N : ℝ) : ℂ) * (𝔼 n ∈ Finset.Ico (a : ℤ) (a + len), f n) := by + let I := cyclicInterval (a : ZMod N) len + have hrep : (𝔼 n ∈ I, f (n.val : ℤ)) = + 𝔼 n ∈ Finset.Ico (a : ℤ) (a + len), f n := by + simpa only [finiteCorrelation, one_mul, star_star] using + cyclicInterval_representative_correlation a len hbound hshort + (fun _ : ZMod N => (1 : ℂ)) (fun n => star (f n)) + have hstar (n : ZMod N) : star (finiteIndicator I n) = finiteIndicator I n := by + by_cases hn : n ∈ I <;> simp [finiteIndicator, hn] + have h := finiteCorrelation_mul_indicator I (fun _ : ZMod N => (1 : ℂ)) + (fun n => star (f (n.val : ℤ))) + simp only [finiteCorrelation, one_mul, star_mul, star_star, hstar, hrep] at h + have hcard : I.card = len := cyclicInterval_card _ (by omega) + simpa only [hcard, ZMod.card, Complex.ofReal_div, Complex.ofReal_natCast, mul_comm] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalOverlap.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalOverlap.lean new file mode 100644 index 0000000000000000000000000000000000000000..555a12e832a9bd29cd11e769dcb0eb981da676e3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalOverlap.lean @@ -0,0 +1,50 @@ +import Mathlib.Data.Int.Interval +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +theorem integerIco_card (c len : ℕ) : + (Finset.Ico (c : ℤ) (c + len)).card = len := by + simp + +theorem integerIco_subset_range (c len N : ℕ) (hN : c + len ≤ N) : + Finset.Ico (c : ℤ) (c + len) ⊆ Finset.Ico (0 : ℤ) N := by + intro x hx + obtain ⟨hx₀, hx₁⟩ := Finset.mem_Ico.mp hx + exact Finset.mem_Ico.mpr ⟨by omega, by omega⟩ + +theorem integerIco_intersection (c₁ l₁ c₂ l₂ N : ℕ) + (hN₁ : c₁ + l₁ ≤ N) (hN₂ : c₂ + l₂ ≤ N) + (hne : (Finset.Ico (c₁ : ℤ) (c₁ + l₁) ∩ Finset.Ico (c₂ : ℤ) (c₂ + l₂)).Nonempty) : + ∃ c len : ℕ, 0 < len ∧ c + len ≤ N ∧ len ≤ l₁ ∧ len ≤ l₂ ∧ + Finset.Ico (c₁ : ℤ) (c₁ + l₁) ∩ Finset.Ico (c₂ : ℤ) (c₂ + l₂) = + Finset.Ico (c : ℤ) (c + len) := by + let c := max c₁ c₂ + let e := min (c₁ + l₁) (c₂ + l₂) + obtain ⟨x, hx⟩ := hne + obtain ⟨hx₁, hx₂⟩ := Finset.mem_inter.mp hx + obtain ⟨hx₁₀, hx₁₁⟩ := Finset.mem_Ico.mp hx₁ + obtain ⟨hx₂₀, hx₂₁⟩ := Finset.mem_Ico.mp hx₂ + have hce : c < e := by dsimp [c, e]; omega + have heq : c + (e - c) = e := by omega + refine ⟨c, e - c, by omega, ?_, ?_, ?_, ?_⟩ + · dsimp [e] at heq + omega + · dsimp [c, e] + omega + · dsimp [c, e] + omega + · ext y + simp only [Finset.mem_inter, Finset.mem_Ico] + dsimp [c, e] at * + omega + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalReindex.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..418ddc850a5b62a59bf14688b69d8865182e4e33 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalReindex.lean @@ -0,0 +1,36 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem sum_integerInterval_eq_range {M : Type*} [AddCommMonoid M] + (f : ℤ → M) (u v : ℤ) : + (∑ x ∈ Finset.Ico u v, f x) = + ∑ n ∈ Finset.range (v - u).toNat, f (u + (n : ℤ)) := by + symm + apply Finset.sum_bij (fun (n : ℕ) _ => u + (n : ℤ)) + · intro n hn + simp only [Finset.mem_range] at hn + simp only [Finset.mem_Ico] + omega + · intro n hn m hm heq + omega + · intro x hx + simp only [Finset.mem_Ico] at hx + refine ⟨(x - u).toNat, ?_, ?_⟩ + · simp only [Finset.mem_range] + omega + · omega + · intro n hn + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalShift.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..f52cbf5fa7c6e1af9b6f074c6724830759d0653f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerIntervalShift.lean @@ -0,0 +1,76 @@ +import OAI.Combinatorics.Progressions.Estimates.ShiftDifferenceCount + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_large_interval_shift (f : ℤ → ℂ) {N H : ℕ} + (hN : 0 < N) (hH : H ≤ N) + (hsupport : ∀ x, x ∉ Finset.Ico (0 : ℤ) (N : ℤ) → f x = 0) + (hf : ∀ x ∈ Finset.Ico (0 : ℤ) (N : ℤ), ‖f x‖ ≤ 1) + {δ : ℝ} (hδ : 0 < δ) (hshift : 8 ≤ δ ^ 2 * H) + (hscore : δ * N ≤ ‖∑ x ∈ Finset.Ico (0 : ℤ) (N : ℤ), f x‖) : + ∃ h : ℤ, h ≠ 0 ∧ |h| < (H : ℤ) ∧ + δ ^ 2 * N / 4 ≤ ‖shiftCorrelation (Finset.Ico (0 : ℤ) (N : ℤ)) f h‖ := by + let Q := Finset.Ico (0 : ℤ) (N : ℤ) + let S := Finset.Ico (0 : ℤ) (H : ℤ) + let T := Finset.Ico (0 : ℤ) ((N + H : ℕ) : ℤ) + have hQ : Q.Nonempty := Finset.nonempty_Ico.mpr (by exact_mod_cast hN) + have hcover : ∀ s ∈ S, ∀ x ∈ Q, x + s ∈ T := by + intro s hs x hx + simp only [S, Q, T, Finset.mem_Ico, Nat.cast_add] at * + omega + have hT : T.card ≤ 2 * Q.card := by + simp only [T, Q, Int.card_Ico, sub_zero, Int.toNat_natCast] + omega + obtain ⟨s, hs, t, ht, hst, hcorr⟩ := exists_large_shift_pair Q T S f hQ hsupport hf hcover hT + hδ (by simpa only [S, Int.card_Ico, sub_zero, Int.toNat_natCast] using hshift) + (by simpa only [Q, Int.card_Ico, sub_zero, Int.toNat_natCast] using hscore) + refine ⟨s - t, sub_ne_zero.mpr hst, ?_, ?_⟩ + · simp only [S, Finset.mem_Ico] at hs ht + rw [abs_lt] + omega + · simpa only [Q, Int.card_Ico, sub_zero, Int.toNat_natCast] using hcorr + +theorem many_large_interval_shifts (f : ℤ → ℂ) {N H : ℕ} + (hN : 0 < N) (hH : H ≤ N) + (hsupport : ∀ x, x ∉ Finset.Ico (0 : ℤ) (N : ℤ) → f x = 0) + (hf : ∀ x ∈ Finset.Ico (0 : ℤ) (N : ℤ), ‖f x‖ ≤ 1) + {δ : ℝ} (hδ : 0 < δ) (hshift : 8 ≤ δ ^ 2 * H) + (hscore : δ * N ≤ ‖∑ x ∈ Finset.Ico (0 : ℤ) (N : ℤ), f x‖) : + ∃ D : Finset ℤ, δ ^ 2 * H / 8 ≤ (D.card : ℝ) ∧ + ∀ h ∈ D, h ≠ 0 ∧ |h| < (H : ℤ) ∧ + δ ^ 2 * N / 8 ≤ ‖shiftCorrelation (Finset.Ico (0 : ℤ) (N : ℤ)) f h‖ := by + let Q := Finset.Ico (0 : ℤ) (N : ℤ) + let S := Finset.Ico (0 : ℤ) (H : ℤ) + let T := Finset.Ico (0 : ℤ) ((N + H : ℕ) : ℤ) + have hQ : Q.Nonempty := Finset.nonempty_Ico.mpr (by exact_mod_cast hN) + have hcover : ∀ s ∈ S, ∀ x ∈ Q, x + s ∈ T := by + intro s hs x hx + simp only [S, Q, T, Finset.mem_Ico, Nat.cast_add] at * + omega + have hT : T.card ≤ 2 * Q.card := by + simp only [T, Q, Int.card_Ico, sub_zero, Int.toNat_natCast] + omega + obtain ⟨D, hD, hgood⟩ := many_large_shift_differences Q T S f hQ hsupport hf hcover hT + hδ (by simpa only [S, Int.card_Ico, sub_zero, Int.toNat_natCast] using hshift) + (by simpa only [Q, Int.card_Ico, sub_zero, Int.toNat_natCast] using hscore) + refine ⟨D, ?_, ?_⟩ + · simpa only [S, Int.card_Ico, sub_zero, Int.toNat_natCast] using hD + · intro h hh + obtain ⟨hne, ⟨s, hs, t, ht, rfl⟩, hcorr⟩ := hgood h hh + refine ⟨hne, ?_, ?_⟩ + · simp only [S, Finset.mem_Ico] at hs ht + rw [abs_lt] + omega + · simpa only [Q, Int.card_Ico, sub_zero, Int.toNat_natCast] using hcorr + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerKernelCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerKernelCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fcab86d218dc5430c66095e6ce304d7e535395b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerKernelCoordinates.lean @@ -0,0 +1,44 @@ +import OAI.Combinatorics.Progressions.Estimates.LinearQuotientCoverAverage + +namespace OAI + +section + +namespace Erdos3 + +def nsmulKernelCongr {G H : Type*} [AddCommGroup G] [AddCommGroup H] + (e : G ≃+ H) (d : ℕ) : + (nsmulAddMonoidHom (α := G) d).ker ≃+ + (nsmulAddMonoidHom (α := H) d).ker where + toFun x := ⟨e x.val, by + change d • e x.val = 0 + rw [← map_nsmul, show d • x.val = 0 from x.property, map_zero]⟩ + invFun y := ⟨e.symm y.val, by + change d • e.symm y.val = 0 + rw [← map_nsmul, show d • y.val = 0 from y.property, map_zero]⟩ + left_inv x := Subtype.ext (e.symm_apply_apply x.val) + right_inv y := Subtype.ext (e.apply_symm_apply y.val) + map_add' x y := Subtype.ext (e.map_add x.val y.val) + +theorem nsmulKernelCongr_val {G H : Type*} [AddCommGroup G] [AddCommGroup H] + (e : G ≃+ H) (d : ℕ) (x : (nsmulAddMonoidHom (α := G) d).ker) : + (nsmulKernelCongr e d x).val = e x.val := rfl + +def nsmulKernelPiEquiv {I : Type*} (G : I → Type*) [∀ i, AddCommGroup (G i)] + (d : ℕ) : (nsmulAddMonoidHom (α := ∀ i, G i) d).ker ≃+ + ∀ i, (nsmulAddMonoidHom (α := G i) d).ker where + toFun x i := ⟨x.val i, congrFun x.property i⟩ + invFun y := ⟨fun i => (y i).val, funext fun i => (y i).property⟩ + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + +theorem nsmulKernelPiEquiv_val {I : Type*} (G : I → Type*) [∀ i, AddCommGroup (G i)] + (d : ℕ) (x : (nsmulAddMonoidHom (α := ∀ i, G i) d).ker) (i : I) : + (nsmulKernelPiEquiv G d x i).val = x.val i := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerLiftOffset.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerLiftOffset.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e7179cb628ae534ff9c9fce6b5863093224bc0d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerLiftOffset.lean @@ -0,0 +1,78 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +theorem integer_lift_offset_eq {d m : ℕ} (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) + (x x' : Fin d → ℝ) (k k' : Fin d → ℤ) (β β' : Fin m → ℤ) {K r : ℝ} + (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) (hr : 0 ≤ r) (hgap : 2 * K * r + 1 / 2 < 1) + (hx : ∀ j, |x j - (k j : ℝ) - a j| ≤ r) + (hx' : ∀ j, |x' j - (k' j : ℝ) - a j| ≤ r) + (hβ : ∀ i, |(∑ j, (M i j : ℝ) * x j) - β i| ≤ 1 / 4) + (hβ' : ∀ i, |(∑ j, (M i j : ℝ) * x' j) - β' i| ≤ 1 / 4) : + (fun i => β i - ∑ j, M i j * k j) = fun i => β' i - ∑ j, M i j * k' j := by + funext i + have herr (j : Fin d) : + |(x j - (k j : ℝ) - a j) - (x' j - (k' j : ℝ) - a j)| ≤ 2 * r := + (abs_sub _ _).trans (by linarith [hx j, hx' j]) + have hsum : |∑ j, (M i j : ℝ) * + ((x j - (k j : ℝ) - a j) - (x' j - (k' j : ℝ) - a j))| ≤ K * (2 * r) := by + calc + _ ≤ ∑ j, |(M i j : ℝ) * + ((x j - (k j : ℝ) - a j) - (x' j - (k' j : ℝ) - a j))| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ j, |(M i j : ℝ)| * (2 * r) := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + exact mul_le_mul_of_nonneg_left (herr j) (abs_nonneg _) + _ = (∑ j, |(M i j : ℝ)|) * (2 * r) := (Finset.sum_mul _ _ _).symm + _ ≤ K * (2 * r) := mul_le_mul_of_nonneg_right (hM i) (by positivity) + have hlifts : |((∑ j, (M i j : ℝ) * x j) - β i) - + ((∑ j, (M i j : ℝ) * x' j) - β' i)| ≤ 1 / 2 := + (abs_sub _ _).trans (by linarith [hβ i, hβ' i]) + have hid : (((β i - ∑ j, M i j * k j) - (β' i - ∑ j, M i j * k' j) : ℤ) : ℝ) = + (∑ j, (M i j : ℝ) * + ((x j - (k j : ℝ) - a j) - (x' j - (k' j : ℝ) - a j))) - + (((∑ j, (M i j : ℝ) * x j) - β i) - ((∑ j, (M i j : ℝ) * x' j) - β' i)) := by + push_cast + simp only [mul_sub, Finset.sum_sub_distrib] + ring + have hbound := (abs_sub _ _).trans (add_le_add hsum hlifts) + rw [← hid] at hbound + have habs : |(((β i - ∑ j, M i j * k j) - (β' i - ∑ j, M i j * k' j) : ℤ) : ℝ)| < 1 := + hbound.trans_lt (by nlinarith [hgap]) + have hlo : (-1 : ℤ) < (β i - ∑ j, M i j * k j) - (β' i - ∑ j, M i j * k' j) := by + exact_mod_cast (abs_lt.mp habs).1 + have hhi : (β i - ∑ j, M i j * k j) - (β' i - ∑ j, M i j * k' j) < (1 : ℤ) := by + exact_mod_cast (abs_lt.mp habs).2 + omega + +theorem exists_integer_lift_offset {Ω : Type*} {d m : ℕ} (S : Set Ω) + (M : Fin m → Fin d → ℤ) (a : Fin d → ℝ) (x : Ω → Fin d → ℝ) + (k : Ω → Fin d → ℤ) (β : Ω → Fin m → ℤ) {K r : ℝ} + (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) (hr : 0 ≤ r) (hgap : 2 * K * r + 1 / 2 < 1) + (hx : ∀ u ∈ S, ∀ j, |x u j - (k u j : ℝ) - a j| ≤ r) + (hβ : ∀ u ∈ S, ∀ i, |(∑ j, (M i j : ℝ) * x u j) - β u i| ≤ 1 / 4) : + ∃ c : Fin m → ℤ, ∀ u ∈ S, β u = fun i => c i + ∑ j, M i j * k u j := by + classical + by_cases hS : S.Nonempty + · obtain ⟨v, hv⟩ := hS + refine ⟨fun i => β v i - ∑ j, M i j * k v j, ?_⟩ + intro u hu + have heq := integer_lift_offset_eq M a (x u) (x v) (k u) (k v) (β u) (β v) + hM hr hgap (hx u hu) (hx v hv) (hβ u hu) (hβ v hv) + funext i + have hi := congrFun heq i + dsimp only at hi ⊢ + omega + · exact ⟨0, fun u hu => (hS ⟨u, hu⟩).elim⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMatrixPMFSupport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMatrixPMFSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..afd366f08f6d62b0ef063b2ba07fafa8a2885358 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMatrixPMFSupport.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Probability.CoefficientJetDensityFactors + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +variable {O J : Type*} [Fintype O] [DecidableEq O] [Fintype J] [DecidableEq J] + +omit [Fintype O] [DecidableEq O] [DecidableEq J] in +theorem integerMatrixImagePMF_preimage_of_toReal_ne_zero + (A : Matrix O J ℤ) (p : J → PMF ℤ) (y : O → ℤ) + (hy : (integerMatrixImagePMF A p y).toReal ≠ 0) : + ∃ z : J → ℤ, (∀ j, z j ∈ (p j).support) ∧ A *ᵥ z = y := by + have hy' : y ∈ (integerMatrixImagePMF A p).support := by + apply (PMF.mem_support_iff _ _).mpr + intro h + exact hy (by rw [h, ENNReal.toReal_zero]) + obtain ⟨z, hz, heq⟩ := (PMF.mem_support_map_iff _ _ _).mp hy' + refine ⟨z, ?_, heq⟩ + intro j + apply (PMF.mem_support_iff _ _).mpr + intro h + apply (PMF.mem_support_iff _ _).mp hz + rw [independentProductPMF_apply] + exact Finset.prod_eq_zero (Finset.mem_univ j) h + +omit [Fintype O] [DecidableEq O] [DecidableEq J] in +theorem integerMatrixImagePMF_scaled_support_bound + (A : Matrix O J ℤ) (p : J → PMF ℤ) (T : J → ℝ) (hT : ∀ j, 0 < T j) + {H M R : ℝ} (hM : 0 ≤ M) + (hA : ∀ o j, |(A o j : ℝ)| / T j ≤ M) + (hp : ∀ j z, z ∈ (p j).support → |(z : ℝ) / H| * T j ≤ R) + (y : O → ℤ) (hy : (integerMatrixImagePMF A p y).toReal ≠ 0) (o : O) : + |(y o : ℝ) / H| ≤ (Fintype.card J : ℝ) * M * R := by + obtain ⟨z, hz, rfl⟩ := integerMatrixImagePMF_preimage_of_toReal_ne_zero A p y hy + calc + _ = |∑ j, (A o j : ℝ) * ((z j : ℝ) / H)| := by + simp only [Matrix.mulVec, dotProduct, Int.cast_sum, Int.cast_mul, Finset.sum_div, mul_div_assoc] + _ ≤ ∑ j, |(A o j : ℝ) * ((z j : ℝ) / H)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : J, M * R := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + calc + _ ≤ (M * T j) * |(z j : ℝ) / H| := + mul_le_mul_of_nonneg_right ((div_le_iff₀ (hT j)).mp (hA o j)) (abs_nonneg _) + _ = M * (|(z j : ℝ) / H| * T j) := by ring + _ ≤ M * R := mul_le_mul_of_nonneg_left (hp j (z j) (hz j)) hM + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_assoc] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMatrixRealDensity.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMatrixRealDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a933b4c0f59e80b01353d0f0152b1e28f9913a7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMatrixRealDensity.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Probability.MixedDensityInterpolation + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped Matrix + +variable {O J : Type*} [Fintype O] [DecidableEq O] [Fintype J] [DecidableEq J] +variable (A : Matrix O J ℤ) (s : O ↪ J) (hA : (A.submatrix id s).det ≠ 0) + +noncomputable def integerMatrixRealDensity (f : (J → ℝ) → ℝ) : (O → ℝ) → ℝ := + selectedCoefficientDensity A s hA (fun _ => 1) (fun _ => 1) + (fun _ => zero_lt_one) (fun _ => zero_lt_one) f + +theorem integerMatrixRealDensity_measurable {f : (J → ℝ) → ℝ} (hf : Measurable f) : + Measurable (integerMatrixRealDensity A s hA f) := + pivotOutputDensity_measurable _ _ + (hf.comp (selectedCoefficientMeasurableEquiv s).measurable) + +theorem integerMatrixRealDensity_nonneg {f : (J → ℝ) → ℝ} (hf : ∀ x, 0 ≤ f x) + (x : O → ℝ) : 0 ≤ integerMatrixRealDensity A s hA f x := + pivotOutputDensity_nonneg _ _ (selectedCoefficientProfile_nonneg s hf) x + +theorem integerMatrixRealDensity_integrable {f : (J → ℝ) → ℝ} (hf : Integrable f) : + Integrable (integerMatrixRealDensity A s hA f) := + pivotOutputDensity_integrable _ _ (selectedCoefficientProfile_integrable s hf) + +theorem integerMatrixRealDensity_integral {f : (J → ℝ) → ℝ} (hf : Integrable f) : + (∫ x, integerMatrixRealDensity A s hA f x) = ∫ x, f x := + (pivotOutputDensity_integral _ _ (selectedCoefficientProfile_integrable s hf)).trans + (selectedCoefficientProfile_integral s f) + +theorem integerMatrixRealDensity_law {f : (J → ℝ) → ℝ} + (hf : Integrable f) (hf0 : ∀ x, 0 ≤ f x) : + (realDensityMeasure volume f).map (fun x => A.map (Int.cast : ℤ → ℝ) *ᵥ x) = + realDensityMeasure volume (integerMatrixRealDensity A s hA f) := by + have h := selectedCoefficientDensity_law A s hA (fun _ => 1) (fun _ => 1) + (fun _ => zero_lt_one) (fun _ => zero_lt_one) f hf hf0 + simpa only [normalizedIntegerColumns, inv_one, Matrix.diagonal_one, + Matrix.one_mul, Matrix.mul_one, Int.coe_castRingHom, integerMatrixRealDensity] using h + +omit [DecidableEq J] in +theorem affineCoefficientProduct_density (c w : J → ℝ) (hw : ∀ j, 0 < w j) : + Measure.pi (fun j => affineCoefficientMeasure (c j) (w j)) = + realDensityMeasure volume (affineProductProfile c w) := + independentCoordinateDensity_measure (fun j => affineProbabilityProfile (c j) (w j)) + (fun j => affineProbabilityProfile_integrable (c j) (hw j)) + (fun j => affineProbabilityProfile_nonneg (c j) (hw j)) + (fun j => affineProbabilityProfile_integral (c j) (hw j)) + +theorem integerMatrixRealDensity_affine_law (c w : J → ℝ) (hw : ∀ j, 0 < w j) : + (Measure.pi (fun j => affineCoefficientMeasure (c j) (w j))).map + (fun x => A.map (Int.cast : ℤ → ℝ) *ᵥ x) = + realDensityMeasure volume (integerMatrixRealDensity A s hA (affineProductProfile c w)) := by + rw [affineCoefficientProduct_density c w hw] + exact integerMatrixRealDensity_law A s hA (affineProductProfile_integrable c w hw) + (affineProductProfile_nonneg c w hw) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMinorNormalization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMinorNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ef895910c932d20fd6f0a93c0c09c170821a99b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerMinorNormalization.lean @@ -0,0 +1,41 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalHeight +import OAI.Combinatorics.Progressions.Geometry.NormalizedMinorCoordinates + +namespace OAI + +section + +namespace Erdos3 + +theorem integer_row_normalization_entry {ι : Type*} {k : ℕ} + (Z : Matrix ι (Fin k) ℤ) (p : Fin k → ι) (hp : (Z.submatrix p id).det ≠ 0) + (i : ι) (j : Fin k) : + let H := Z.map (Int.castRingHom ℚ) + (H * (H.submatrix p id)⁻¹) i j = + ((Z.submatrix (Function.update p j i) id).det : ℚ) / ((Z.submatrix p id).det : ℚ) := by + let H := Z.map (Int.castRingHom ℚ) + have hdet (q : Fin k → ι) : (H.submatrix q id).det = ((Z.submatrix q id).det : ℚ) := by + change ((Z.submatrix q id).map (Int.castRingHom ℚ)).det = _ + exact ((Int.castRingHom ℚ).map_det _).symm + have hp' : (H.submatrix p id).det ≠ 0 := by rw [hdet]; exact_mod_cast hp + change (H * (H.submatrix p id)⁻¹) i j = _ + calc + _ = (H.submatrix (Function.update p j i) id).det / (H.submatrix p id).det := + row_normalization_entry H p hp' i j + _ = _ := by rw [hdet, hdet] + +theorem integer_row_normalization_height {ι : Type*} {k : ℕ} + (Z : Matrix ι (Fin k) ℤ) (p : Fin k → ι) (hp : (Z.submatrix p id).det ≠ 0) + (N : ℕ) (hN : ∀ q : Fin k → ι, (Z.submatrix q id).det.natAbs ≤ N) + (i : ι) (j : Fin k) : + let H := Z.map (Int.castRingHom ℚ) + RationalHeightLE ((H * (H.submatrix p id)⁻¹) i j) N := by + dsimp only + rw [integer_row_normalization_entry Z p hp i j] + exact rationalHeightLE_fraction _ _ hp (hN _) (hN _) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerNormalizedJetColumns.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerNormalizedJetColumns.lean new file mode 100644 index 0000000000000000000000000000000000000000..72e77e5bc1247773e828f1ad90acfb74f5415ead --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerNormalizedJetColumns.lean @@ -0,0 +1,123 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedJetColumns +import OAI.Combinatorics.Progressions.Estimates.SelectedCoefficientEvaluation + +namespace OAI + + +namespace Erdos3 + +open scoped BigOperators + +theorem real_monomial_eval_div_scale {K : Type*} (e : K →₀ ℕ) (x T : K → ℝ) : + MvPolynomial.eval (fun k => x k / T k) (MvPolynomial.monomial e (1 : ℝ)) = + MvPolynomial.eval x (MvPolynomial.monomial e (1 : ℝ)) / monomialScale T e := by + classical + simp only [MvPolynomial.eval_monomial, one_mul, monomialScale, Finsupp.prod, + div_pow, Finset.prod_div_distrib] + +theorem integer_monomial_eval_cast {K : Type*} (e : K →₀ ℕ) (x : K → ℤ) : + (MvPolynomial.eval x (MvPolynomial.monomial e (1 : ℤ)) : ℝ) = + MvPolynomial.eval (fun k => (x k : ℝ)) (MvPolynomial.monomial e (1 : ℝ)) := by + classical + simp only [MvPolynomial.eval_monomial, one_mul, Finsupp.prod, Int.cast_prod, Int.cast_pow] + +theorem normalizedIntegerMonomialJetMatrix_eq {α K O J : Type*} [DecidableEq α] + [Fintype O] [DecidableEq O] [Fintype J] [DecidableEq J] + (e : J → K →₀ ℕ) (vertices : Finset α → K → ℤ) (rows : O → Finset α) + (T : K → ℝ) {H : ℝ} (hH : H ≠ 0) : + normalizedIntegerColumns + (integerJetMatrix (fun j => MvPolynomial.monomial (e j) 1) vertices rows) + (fun j => H / monomialScale T (e j)) (fun _ => H) = + realJetMatrix (fun j => MvPolynomial.monomial (e j) 1) + (fun t k => (vertices t k : ℝ) / T k) rows := by + ext o j + rw [normalizedIntegerColumns_entry_div] + change ((booleanCoefficient (fun t => MvPolynomial.eval (vertices t) + (MvPolynomial.monomial (e j) (1 : ℤ))) (rows o) : ℤ) : ℝ) * + (H / monomialScale T (e j)) / H = + booleanCoefficient (fun t => MvPolynomial.eval (fun k => (vertices t k : ℝ) / T k) + (MvPolynomial.monomial (e j) (1 : ℝ))) (rows o) + have hcast := booleanCoefficient_map (Int.castRingHom ℝ) + (fun t => MvPolynomial.eval (vertices t) (MvPolynomial.monomial (e j) (1 : ℤ))) (rows o) + change ((booleanCoefficient _ (rows o) : ℤ) : ℝ) = + booleanCoefficient (fun t => (MvPolynomial.eval (vertices t) + (MvPolynomial.monomial (e j) (1 : ℤ)) : ℝ)) (rows o) at hcast + rw [hcast] + simp only [real_monomial_eval_div_scale, integer_monomial_eval_cast] + rw [booleanCoefficient_div] + simp [div_eq_mul_inv, hH, mul_assoc, mul_comm] + +theorem realAffineCube_normalized_integer {α K : Type*} + (root : K → ℤ) (difference : α → K → ℤ) (T : K → ℝ) (t : Finset α) (k : K) : + realAffineCube (fun k => (root k : ℝ) / T k) + (fun r k => (difference r k : ℝ) / T k) t k = + (integerAffineCube root difference t k : ℝ) / T k := by + simp only [realAffineCube, integerAffineCube, Int.cast_add, Int.cast_sum, + add_div, Finset.sum_div] + +theorem normalizedBoundedIntegerJetMatrix_eq {α K O : Type*} + [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℤ) (difference : Matrix α K ℤ) (h : ℕ) (rows : O → Finset α) + (T : K → ℝ) {H : ℝ} (hH : H ≠ 0) : + normalizedIntegerColumns (boundedDegreeIntegerJetMatrix root difference h rows) + (fun e => H / monomialScale T e.val) (fun _ => H) = + boundedDegreeRealJetMatrix (fun k => (root k : ℝ) / T k) + (fun r k => (difference r k : ℝ) / T k) h rows := by + have hv : (fun t k => (integerAffineCube root difference t k : ℝ) / T k) = + realAffineCube (fun k => (root k : ℝ) / T k) + (fun r k => (difference r k : ℝ) / T k) := by + funext t k + exact (realAffineCube_normalized_integer root difference T t k).symm + have he := normalizedIntegerMonomialJetMatrix_eq + (fun e : BoundedIntegerExponent K h => e.val) (integerAffineCube root difference) rows T hH + rw [hv] at he + exact he + +end Erdos3 + + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem normalizedJetColumns_eq_realJetMatrix {Z P K α I N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [Fintype N] + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ P) (z : Z → ℝ) + (rows : I → Finset α) (x : P → ℝ) : + polynomialColumns (fun i n => normalizedJetColumn (e n) input z (rows i)) x = + matrixSupCLM (realJetMatrix (fun n => MvPolynomial.monomial (e n) 1) + (normalizedCubeTuple input z x) rows) := by + unfold polynomialColumns + congr 1 + funext i n + simp only [normalizedJetColumn, booleanJetColumnPolynomial_eval, frozenTupleCoordinate_eval, + realJetMatrix, MvPolynomial.eval_monomial, one_mul, Finsupp.prod, normalizedCubeTuple] + +theorem normalizedIntegerJetColumns_eq {Z P K α I N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [DecidableEq I] [Fintype N] [DecidableEq N] + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ P) (z : Z → ℝ) + (rows : I → Finset α) (x : P → ℝ) (vertices : Finset α → K → ℤ) (T : K → ℝ) + (hcoords : ∀ t k, (vertices t k : ℝ) / T k = normalizedCubeTuple input z x t k) + {H : ℝ} (hH : H ≠ 0) : + matrixSupCLM (normalizedIntegerColumns + (integerJetMatrix (fun n => MvPolynomial.monomial (e n) 1) vertices rows) + (fun n => H / monomialScale T (e n)) (fun _ => H)) = + polynomialColumns (fun i n => normalizedJetColumn (e n) input z (rows i)) x := by + rw [normalizedIntegerMonomialJetMatrix_eq e vertices rows T hH] + simp_rw [hcoords] + exact (normalizedJetColumns_eq_realJetMatrix e input z rows x).symm + +theorem normalizedCubeTuple_eq_integerAffineCube {Z P K α : Type*} + [Fintype α] [DecidableEq α] (input : K → Option α → Z ⊕ P) (z : Z → ℝ) (x : P → ℝ) + (root : K → ℤ) (difference : α → K → ℤ) (T : K → ℝ) + (hroot : ∀ k, Sum.elim z x (input k none) = (root k : ℝ) / T k) + (hdiff : ∀ i k, Sum.elim z x (input k (some i)) = (difference i k : ℝ) / T k) + (t : Finset α) (k : K) : + normalizedCubeTuple input z x t k = (integerAffineCube root difference t k : ℝ) / T k := by + rw [← realAffineCube_normalized_integer] + simp only [normalizedCubeTuple, Fintype.sum_option, booleanFeature, one_mul, hroot, hdiff, + ite_mul, zero_mul, Finset.sum_ite_mem, Finset.univ_inter, realAffineCube] + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerOrbitTranslation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerOrbitTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..785a0438d03362faadd9d593b5090637df8658dc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerOrbitTranslation.lean @@ -0,0 +1,25 @@ +import OAI.Combinatorics.Progressions.Estimates.ProjectedNativeCoefficient + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +@[simp] theorem integerOrbitPoint_translate + (g : D.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (c n : ℤ) : + D.integerOrbitPoint (g.translate (fun _ => Nat.zero_lt_one) (fun _ => c)) n = + D.integerOrbitPoint g (n + c) := by + unfold integerOrbitPoint + rw [NilpotentLieFiltration.polynomialOrbitEval_translate] + rfl + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerPMFNormalizedSource.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerPMFNormalizedSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e3cfb90bb8c530380f72edf2e81d9a365e3757d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerPMFNormalizedSource.lean @@ -0,0 +1,147 @@ +import OAI.Combinatorics.Progressions.Estimates.CoefficientSliceEmbedding +import OAI.Combinatorics.Progressions.Lattices.IntegerRowInterpolationMixture + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +theorem pmf_interval_toReal_mass (L : ℕ) (p : PMF ℤ) + (hs : ∀ k, p k ≠ 0 → k ∈ Finset.Ico 0 (L : ℤ)) : + (∑ k ∈ Finset.Ico 0 (L : ℤ), (p k).toReal) = 1 := by + have hm : (∑ k ∈ Finset.Ico 0 (L : ℤ), p k) = 1 := by + rw [← p.tsum_coe] + apply (tsum_eq_sum (s := Finset.Ico 0 (L : ℤ)) _).symm + intro k hk + by_contra hn + exact hk (hs k hn) + rw [← ENNReal.toReal_sum (fun k _ => p.apply_ne_top k), hm, ENNReal.toReal_one] + +theorem scalarCubeResidueWeights_empty_one_mean (L : ℕ) (hL : 0 < L) (f : ℤ → ℝ) : + (scalarCubeResidueWeights Empty L 1 hL (fun _ => 1) (fun _ => 0) + (fun _ => by norm_num) (fun _ => le_rfl) (by change 1 ≤ L; exact Nat.succ_le_iff.mpr hL)).mean + (fun x => f (x none : ℤ)) = + (∑ k ∈ Finset.Ico 0 (L : ℤ), f k) / (L : ℝ) := by + rw [scalarCubeResidueWeights_mean] + calc + _ = 𝔼 k : coefficientResidueSet L 1 0, f k := + Fintype.expect_equiv (emptyScalarCubeResidueEquiv L (fun _ => 1) (fun _ => 0)) + _ _ (fun _ => rfl) + _ = _ := by + have hr : coefficientResidueSet L 1 0 = Finset.Ico 0 (L : ℤ) := by + ext k + simp only [coefficientResidueSet, Finset.mem_filter] + exact ⟨And.left, fun hk => ⟨hk, Subsingleton.elim _ _⟩⟩ + rw [hr, Fintype.expect_eq_sum_div_card] + simp [Finset.sum_attach] + +noncomputable def normalizedScalarCubeSourceOfIntegerPMF + (L : ℕ) (hL : 0 < L) (p : PMF ℤ) + (hs : ∀ k, p k ≠ 0 → k ∈ Finset.Ico 0 (L : ℤ)) + (w : (Option Empty → ℝ) → ℝ) (B T : ℝ≥0) (hB : 0 < B) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hgrid : ∀ k : ℤ, w (fun _ => (k : ℝ) / L) = L * (p k).toReal) : + NormalizedScalarCubeSource Empty where + length := L + modulusBound := 1 + length_pos := hL + modulus := fun _ => 1 + residue := fun _ => 0 + modulus_pos := fun _ => by norm_num + modulus_le := fun _ => le_rfl + size := by change 1 ≤ L; exact Nat.succ_le_iff.mpr hL + weight := w + weightBound := B + weightLipschitz := T + weightBound_pos := hB + weight_range := hw + weight_lipschitz := hLip + normalized := by + have he (x : IntegerScalarCubeBox Empty L) : + w (fun i => (x i : ℝ) / L) = w (fun _ => (x none : ℝ) / L) := by + congr 1 + funext i + cases i with + | none => rfl + | some e => exact e.elim + simp only [he] + refine (scalarCubeResidueWeights_empty_one_mean L hL + (fun k => w (fun _ => (k : ℝ) / L))).trans ?_ + simp_rw [hgrid] + rw [← Finset.mul_sum, pmf_interval_toReal_mass L p hs, mul_one] + exact div_self (by exact_mod_cast (Nat.ne_of_gt hL)) + +namespace FiniteProbabilityWeights + +theorem toPMF_map_toReal {X Y : Type*} [Fintype X] (p : FiniteProbabilityWeights X) + (f : X → Y) (y : Y) : + ((p.toPMF.map f) y).toReal = p.mean (fun x => if f x = y then 1 else 0) := by + change ((p.toPMF.bind (fun x => PMF.pure (f x))) y).toReal = _ + rw [toPMF_bind_toReal] + congr 1 + funext x + by_cases h : f x = y + · simp [PMF.pure_apply, h] + · have h' : y ≠ f x := Ne.symm h + simp [PMF.pure_apply, h, h'] + +end FiniteProbabilityWeights + +section IntegerSourceLaw + +variable (L : ℕ) (hL : 0 < L) (p : PMF ℤ) +variable (hs : ∀ k, p k ≠ 0 → k ∈ Finset.Ico 0 (L : ℤ)) +variable (w : (Option Empty → ℝ) → ℝ) (B T : ℝ≥0) (hB : 0 < B) +variable (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) +variable (hgrid : ∀ k : ℤ, w (fun _ => (k : ℝ) / L) = L * (p k).toReal) + +local notation "intervalSource" => + normalizedScalarCubeSourceOfIntegerPMF L hL p hs w B T hB hw hLip hgrid + +theorem normalizedScalarCubeSourceOfIntegerPMF_mean (f : ℤ → ℝ) : + (intervalSource).source.mean (fun x => f (x none : ℤ)) = + ∑ k ∈ Finset.Ico 0 (L : ℤ), (p k).toReal * f k := by + apply ((intervalSource).source_coefficient_mean f).trans + change (FiniteProbabilityWeights.ofDensity _ _ _).mean _ = _ + rw [FiniteProbabilityWeights.ofDensity_mean] + change (𝔼 k : coefficientResidueSet L 1 0, + w (fun _ => (k.val : ℝ) / L) * f k.val) = _ + have hr : coefficientResidueSet L 1 0 = Finset.Ico 0 (L : ℤ) := by + ext k + simp only [coefficientResidueSet, Finset.mem_filter] + exact ⟨And.left, fun hk => ⟨hk, Subsingleton.elim _ _⟩⟩ + rw [hr, Fintype.expect_eq_sum_div_card] + simp only [Fintype.card_coe, Int.card_Ico, sub_zero, Int.toNat_natCast] + simp_rw [hgrid, mul_assoc] + rw [← Finset.mul_sum] + field_simp + exact Finset.sum_coe_sort (Finset.Ico 0 (L : ℤ)) (fun k => (p k).toReal * f k) + +theorem normalizedScalarCubeSourceOfIntegerPMF_law : + (intervalSource).source.toPMF.map (fun x => (x none : ℤ)) = p := by + ext z + let q := (intervalSource).source.toPMF.map (fun x => (x none : ℤ)) + have hreal : (q z).toReal = (p z).toReal := by + change (((intervalSource).source.toPMF.map (fun x => (x none : ℤ))) z).toReal = _ + rw [FiniteProbabilityWeights.toPMF_map_toReal] + refine (normalizedScalarCubeSourceOfIntegerPMF_mean L hL p hs w B T hB hw hLip hgrid + (fun k => @ite ℝ (k = z) (Classical.propDecidable (k = z)) 1 0)).trans ?_ + by_cases hz : z ∈ Finset.Ico 0 (L : ℤ) + · simp [mul_ite, hz] + · have hpz : p z = 0 := by + by_contra h + exact hz (hs z h) + simp [mul_ite, hz, hpz] + exact (ENNReal.ofReal_toReal (q.apply_ne_top z)).symm.trans + ((congrArg ENNReal.ofReal hreal).trans (ENNReal.ofReal_toReal (p.apply_ne_top z))) + +end IntegerSourceLaw + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerPeriodPivot.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerPeriodPivot.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f58eaf61881f31c4b4aa1eaf01cfba58e166518 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerPeriodPivot.lean @@ -0,0 +1,52 @@ +import OAI.Combinatorics.Progressions.Linear.BooleanJetMatrixFactor + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem integerPeriod_exists_pivot {O J : Type*} [Fintype O] [DecidableEq O] [Fintype J] + (A : Matrix O J ℤ) {a : ℤ} (ha : a ≠ 0) + (hperiod : integerScalarLattice O a ≤ A.mulVecLin.range) : + ∃ s : O ↪ J, (A.submatrix id s).det ≠ 0 := by + classical + have hcol (i : O) : ∃ v : J → ℤ, A *ᵥ v = a • Pi.single i 1 := + hperiod ((integerScalarLattice_mem a _).mpr ⟨Pi.single i 1, rfl⟩) + choose v hv using hcol + let B : Matrix J O ℤ := fun j i => v i j + have hAB : A * B = a • (1 : Matrix O O ℤ) := by + ext i k + change (A *ᵥ v k) i = (a • (1 : Matrix O O ℤ)) i k + simpa only [Pi.smul_apply, smul_eq_mul, Matrix.smul_apply, Matrix.one_apply, + Pi.single_apply, eq_comm] using congrFun (hv k) i + have hdet : (A * B).det ≠ 0 := by + rw [hAB, Matrix.det_smul, Matrix.det_one, mul_one] + exact pow_ne_zero _ ha + rw [rectangular_det_expansion] at hdet + obtain ⟨s, _, hs⟩ := Finset.exists_ne_zero_of_sum_ne_zero hdet + have hminor : (A.submatrix id s).det ≠ 0 := left_ne_zero_of_mul hs + refine ⟨⟨s, ?_⟩, hminor⟩ + intro i j hij + by_contra hne + apply hminor + exact Matrix.det_zero_of_column_eq hne (fun k => by simp only [Matrix.submatrix_apply, hij]) + +theorem boundedCoefficientJetMatrix_exists_pivot {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℤ) (A : Matrix α K ℤ) {a : ℤ} (ha : a ≠ 0) + (hperiod : integerScalarLattice α a ≤ A.mulVecLin.range) + (h : ℕ) (rows : O → Finset α) (hinj : Function.Injective rows) + (hdegree : ∀ o, (rows o).card ≤ h) : + ∃ s : O ↪ VectorPolynomial.BoundedCoefficientExponent K h, + ((boundedCoefficientJetMatrix root A h rows).submatrix id s).det ≠ 0 := + integerPeriod_exists_pivot (boundedCoefficientJetMatrix root A h rows) (pow_ne_zero _ ha) + (boundedCoefficientJetMatrix_period root A a hperiod h rows hinj hdegree) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRadixCoding.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRadixCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..c10b243d03f29c3485cce30a44042572a98f4f9e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRadixCoding.lean @@ -0,0 +1,83 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def integerRadixValue : {n : ℕ} → (Fin n → ℕ) → (Fin n → ℤ) → ℤ + | 0, _, _ => 0 + | n + 1, R, x => x 0 + (R 0 : ℤ) * integerRadixValue (fun i : Fin n => R i.succ) (fun i => x i.succ) + +theorem integerRadixValue_zero {n : ℕ} (R : Fin n → ℕ) : + integerRadixValue R 0 = 0 := by + induction n with + | zero => rfl + | succ n ih => + change (0 : ℤ) + (R 0 : ℤ) * integerRadixValue (fun i : Fin n => R i.succ) 0 = 0 + rw [ih, mul_zero, add_zero] + +theorem integerRadixValue_add {n : ℕ} (R : Fin n → ℕ) (x y : Fin n → ℤ) : + integerRadixValue R (x + y) = integerRadixValue R x + integerRadixValue R y := by + induction n with + | zero => rfl + | succ n ih => + simp only [integerRadixValue, Pi.add_apply] + rw [show (fun i : Fin n => x i.succ + y i.succ) = + (fun i => x i.succ) + (fun i => y i.succ) from rfl, ih] + ring + +def integerRadixHom {n : ℕ} (R : Fin n → ℕ) : (Fin n → ℤ) →+ ℤ where + toFun := integerRadixValue R + map_zero' := integerRadixValue_zero R + map_add' := integerRadixValue_add R + +theorem integerRadixValue_bounds {n : ℕ} (R : Fin n → ℕ) (x : Fin n → ℤ) + (hx : ∀ i, 0 ≤ x i ∧ x i < (R i : ℤ)) : + 0 ≤ integerRadixValue R x ∧ integerRadixValue R x < ((∏ i, R i : ℕ) : ℤ) := by + induction n with + | zero => simp [integerRadixValue] + | succ n ih => + have h0 := hx 0 + have ht := ih (fun i => R i.succ) (fun i => x i.succ) (fun i => hx i.succ) + have hm := mul_le_mul_of_nonneg_left + (show integerRadixValue (fun i : Fin n => R i.succ) (fun i => x i.succ) ≤ + ((∏ i : Fin n, R i.succ : ℕ) : ℤ) - 1 by omega) + (Nat.cast_nonneg (R 0) : (0 : ℤ) ≤ R 0) + rw [integerRadixValue, Fin.prod_univ_succ, Nat.cast_mul] + constructor + · exact add_nonneg h0.1 (mul_nonneg (Nat.cast_nonneg _) ht.1) + · nlinarith + +theorem integerRadixValue_injective_on_digits {n : ℕ} (R : Fin n → ℕ) + (x y : Fin n → ℤ) (hx : ∀ i, 0 ≤ x i ∧ x i < (R i : ℤ)) + (hy : ∀ i, 0 ≤ y i ∧ y i < (R i : ℤ)) + (he : integerRadixValue R x = integerRadixValue R y) : x = y := by + induction n with + | zero => exact Subsingleton.elim _ _ + | succ n ih => + have hx0 := hx 0 + have hy0 := hy 0 + have hR : (R 0 : ℤ) ≠ 0 := ne_of_gt (lt_of_le_of_lt hx0.1 hx0.2) + have h0 : x 0 = y 0 := by + have h := congrArg (fun z : ℤ => z % (R 0 : ℤ)) he + simpa only [integerRadixValue, Int.add_emod, Int.mul_emod, Int.emod_self, + zero_mul, Int.zero_emod, add_zero, Int.emod_eq_of_lt hx0.1 hx0.2, + Int.emod_eq_of_lt hy0.1 hy0.2] using h + have ht : integerRadixValue (fun i : Fin n => R i.succ) (fun i => x i.succ) = + integerRadixValue (fun i : Fin n => R i.succ) (fun i => y i.succ) := by + apply mul_left_cancel₀ hR + simpa only [integerRadixValue, h0, add_left_cancel_iff] using he + have hh := ih (fun i => R i.succ) (fun i => x i.succ) (fun i => y i.succ) + (fun i => hx i.succ) (fun i => hy i.succ) ht + funext i + exact Fin.cases h0 (fun j => congrFun hh j) i + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRepresentativeFraction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRepresentativeFraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b2a11b448e2dfafa054664f5c520df4298360c3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRepresentativeFraction.lean @@ -0,0 +1,24 @@ +import OAI.Combinatorics.Progressions.Fourier.CRTConfigurationTorus + +namespace OAI + +section + +namespace Erdos3 + +theorem integer_fraction_eq_zmod_val {N : ℕ} [NeZero N] (a : ℤ) : + Int.fract ((a : ℝ) / N) = (((a : ZMod N).val : ℝ) / N) := by + rw [Int.fract_div_intCast_eq_div_intCast_mod] + exact congrArg (fun z : ℤ => (z : ℝ) / N) (ZMod.val_intCast a).symm + +theorem integer_sub_floor_eq_zmod_val {N : ℕ} [NeZero N] (a : ℤ) : + a - (N : ℤ) * ⌊(a : ℝ) / N⌋ = ((a : ZMod N).val : ℤ) := by + rw [Int.floor_div_natCast, Int.floor_intCast, ZMod.val_intCast] + have h := Int.emod_add_mul_ediv a (N : ℤ) + omega + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerResidueLatticeSum.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerResidueLatticeSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f42e26dcd306cd6889178fc8b7f45b3a862078d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerResidueLatticeSum.lean @@ -0,0 +1,76 @@ +import Mathlib.Analysis.Complex.Basic +import Mathlib.Data.ZMod.Basic +import Mathlib.Topology.Algebra.InfiniteSum.Constructions + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {J : Type*} (q : ℕ) [NeZero q] + +def integerResidueLatticePoint (r : J → ZMod q) (k : J → ℤ) : J → ℤ := + fun j => (r j).val + q * k j + +@[simp] theorem integerResidueLatticePoint_cast + (r : J → ZMod q) (k : J → ℤ) (j : J) : + (integerResidueLatticePoint q r k j : ZMod q) = r j := by + exact (ZMod.intCast_eq_iff q _ _).2 ⟨k j, rfl⟩ + +theorem integerResidueLatticePoint_bijective : + Function.Bijective (fun p : (J → ZMod q) × (J → ℤ) => + integerResidueLatticePoint q p.1 p.2) := by + constructor + · rintro ⟨r, k⟩ ⟨r', k'⟩ h + have hr : r = r' := by + funext j + have hj := congrArg (fun x : J → ℤ => (x j : ZMod q)) h + simpa only [integerResidueLatticePoint_cast] using hj + subst r' + have hk : k = k' := by + funext j + have hj := congrFun h j + change (r j).val + (q : ℤ) * k j = (r j).val + (q : ℤ) * k' j at hj + exact mul_left_cancel₀ (show (q : ℤ) ≠ 0 by exact_mod_cast NeZero.ne q) + (add_left_cancel hj) + exact Prod.ext rfl hk + · intro x + refine ⟨(fun j => (x j : ZMod q), fun j => x j / q), ?_⟩ + funext j + change ((x j : ZMod q).val : ℤ) + q * (x j / q) = x j + rw [ZMod.val_intCast, Int.emod_add_mul_ediv] + +noncomputable def integerResidueLatticeEquiv : + ((J → ZMod q) × (J → ℤ)) ≃ (J → ℤ) := + Equiv.ofBijective _ (integerResidueLatticePoint_bijective q) + +@[simp] theorem integerResidueLatticeEquiv_apply + (r : J → ZMod q) (k : J → ℤ) : + integerResidueLatticeEquiv q (r, k) = integerResidueLatticePoint q r k := rfl + +theorem summable_integerResidueLatticePoint + (f : (J → ℤ) → ℂ) (hf : Summable f) (r : J → ZMod q) : + Summable (fun k => f (integerResidueLatticePoint q r k)) := by + have he : Summable (fun p => f (integerResidueLatticeEquiv (J := J) q p)) := + (integerResidueLatticeEquiv q).summable_iff.2 hf + exact he.prod_factor r + +theorem tsum_integerResidueLatticePoint [Fintype J] + (f : (J → ℤ) → ℂ) (hf : Summable f) : + ∑' x, f x = ∑ r : J → ZMod q, ∑' k, f (integerResidueLatticePoint q r k) := by + classical + let e := integerResidueLatticeEquiv (J := J) q + have he : Summable (fun p => f (e p)) := e.summable_iff.2 hf + calc + _ = ∑' p, f (e p) := (e.tsum_eq f).symm + _ = ∑' r, ∑' k, f (integerResidueLatticePoint q r k) := he.tsum_prod + _ = _ := tsum_fintype _ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRowInterpolationMixture.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRowInterpolationMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a07700224fe4a19308c05a8b16ea5b9a280217a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerRowInterpolationMixture.lean @@ -0,0 +1,702 @@ +import Mathlib.MeasureTheory.Integral.Bochner.Set +import Mathlib.Topology.MetricSpace.Lipschitz +import OAI.Combinatorics.Progressions.Estimates.InactiveShortLogBounds +import OAI.Combinatorics.Progressions.Probability.PMFPointMassMixture + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem affineProfile_sample_coordinate (c x : ℝ) {w S : ℝ} (hw : 0 < w) (hS : 0 < S) : + (x / S - c) / w = (x - c*S) / (w*S) := by + field_simp [hw.ne', hS.ne'] + +theorem affineProductProfile_sample {I : Type*} [Fintype I] + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) (z : I → ℤ) : + coefficientWeight (affineProductProfile c w) S z = profileWidthFactor w * + smoothProductProfile I (fun i => ((z i : ℝ) - c i * S i) / (w i * S i)) := by + rw [coefficientWeight, affineProductProfile_eq] + congr 1 + congr 1 + funext i + exact affineProfile_sample_coordinate (c i) (z i) (hw i) (hS i) + +theorem affineProductProfile_sample_sum {I : Type*} [Fintype I] + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) : + coefficientWeightSum (affineProductProfile c w) S = + profileWidthFactor w * ∏ i, shiftedSmoothSampleSum (c i * S i) (w i * S i) := by + unfold coefficientWeightSum + simp_rw [affineProductProfile_sample c w S hw hS] + rw [tsum_mul_left, shiftedSmoothProductSamples_sum _ _ (fun i => mul_pos (hw i) (hS i))] + +theorem affineProfile_coordinate_sum_pos {I : Type*} [Fintype I] + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) + (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) (i : I) : + 0 < shiftedSmoothSampleSum (c i * S i) (w i * S i) := by + classical + have hn : 0 ≤ shiftedSmoothSampleSum (c i * S i) (w i * S i) := + tsum_nonneg (fun k => (smoothProbabilityProfile_range _).1) + by_contra! hi + have hz := le_antisymm hi hn + have hp : (∏ j, shiftedSmoothSampleSum (c j * S j) (w j * S j)) = 0 := + Finset.prod_eq_zero (Finset.mem_univ i) hz + rw [affineProductProfile_sample_sum c w S hw hS, hp, mul_zero] at hZ + exact (lt_irrefl 0) hZ + +theorem affineProductProfile_sample_sum_pos {I : Type*} [Fintype I] + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) + (hlarge : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ w i * S i) : + 0 < coefficientWeightSum (affineProductProfile c w) S := by + rw [affineProductProfile_sample_sum c w S hw hS] + exact mul_pos (profileWidthFactor_pos w hw) + (Finset.prod_pos (fun i _ => shiftedSmoothSampleSum_pos _ (hlarge i))) + +theorem affineCoefficientPMF_apply {I : Type*} [Fintype I] + (c w S : I → ℝ) (hw : ∀ i, 0 < w i) (hS : ∀ i, 0 < S i) + {R : ℝ} (hsupport : ∀ x, R < ‖x‖ → affineProductProfile c w x = 0) + (hZ : 0 < coefficientWeightSum (affineProductProfile c w) S) (z : I → ℤ) : + (coefficientPMF (affineProductProfile c w) (affineProductProfile_nonneg c w hw) + S hS hsupport hZ z).toReal = + ∏ i, (shiftedSmoothCoefficientPMF (c i * S i) (w i * S i) (mul_pos (hw i) (hS i)) + (affineProfile_coordinate_sum_pos c w S hw hS hZ i) (z i)).toReal := by + rw [coefficientPMF_apply, affineProductProfile_sample c w S hw hS, + affineProductProfile_sample_sum c w S hw hS, + mul_div_mul_left _ _ (profileWidthFactor_pos w hw).ne'] + simp only [shiftedSmoothCoefficientPMF_apply, smoothProductProfile, Finset.prod_div_distrib] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped ContDiff + +noncomputable def normalizedIntegerPMF (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) : PMF ℤ := + shiftedSmoothCoefficientPMF (c * K) (δ * K) (mul_pos hδ hK) + (shiftedSmoothSampleSum_pos (c * K) hlarge) + +theorem normalizedIntegerPMF_apply (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) (k : ℤ) : + (normalizedIntegerPMF K c δ hK hδ hlarge k).toReal = + smoothProbabilityProfile (((k : ℝ) - c * K) / (δ * K)) / + shiftedSmoothSampleSum (c * K) (δ * K) := + shiftedSmoothCoefficientPMF_apply _ _ _ _ _ + +theorem normalizedIntegerPMF_support (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) {k : ℤ} + (hk : k ∈ (normalizedIntegerPMF K c δ hK hδ hlarge).support) : + |(k : ℝ) / K - c| < 3 * δ / 4 := by + have hb := shiftedSmoothCoefficientPMF_support (c * K) (mul_pos hδ hK) + (shiftedSmoothSampleSum_pos (c * K) hlarge) hk + rw [show (k : ℝ) / K - c = ((k : ℝ) - c * K) / K by field_simp, + abs_div, abs_of_pos hK] + apply (div_lt_iff₀ hK).mpr + nlinarith + +theorem normalizedIntegerPMF_cap (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) (k : ℤ) : + K * (normalizedIntegerPMF K c δ hK hδ hlarge k).toReal ≤ 2 / δ := by + have hb := shiftedSmoothCoefficientPMF_le (c * K) hlarge k + calc + _ ≤ K * (2 / (δ * K)) := mul_le_mul_of_nonneg_left hb hK.le + _ = 2 / δ := by field_simp + +noncomputable def normalizedIntegerInterpolation (K c δ u : ℝ) : ℝ := + K * smoothProbabilityProfile ((u - c) / δ) / shiftedSmoothSampleSum (c * K) (δ * K) + +theorem normalizedIntegerInterpolation_grid (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) (k : ℤ) : + normalizedIntegerInterpolation K c δ ((k : ℝ) / K) = + K * (normalizedIntegerPMF K c δ hK hδ hlarge k).toReal := by + rw [normalizedIntegerInterpolation, affineProfile_sample_coordinate c (k : ℝ) hδ hK, + normalizedIntegerPMF_apply, mul_div_assoc] + +theorem normalizedIntegerInterpolation_contDiff (K c δ : ℝ) : + ContDiff ℝ ∞ (normalizedIntegerInterpolation K c δ) := by + unfold normalizedIntegerInterpolation + exact (contDiff_const.mul + (smoothProbabilityProfile_contDiff.comp ((contDiff_id.sub contDiff_const).div_const δ))).div_const _ + +theorem normalizedIntegerInterpolation_range (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) (u : ℝ) : + 0 ≤ normalizedIntegerInterpolation K c δ u ∧ + normalizedIntegerInterpolation K c δ u ≤ 2 / δ := by + have hZ := shiftedSmoothSampleSum_pos (c * K) hlarge + have hlo := (shiftedSmoothSampleSum_bounds (c * K) hlarge).1 + constructor + · exact div_nonneg (mul_nonneg hK.le (smoothProbabilityProfile_range _).1) hZ.le + · calc + _ ≤ K / shiftedSmoothSampleSum (c * K) (δ * K) := + div_le_div_of_nonneg_right + (by simpa using mul_le_mul_of_nonneg_left (smoothProbabilityProfile_range ((u-c)/δ)).2 hK.le) + hZ.le + _ ≤ 2 / δ := (div_le_div_iff₀ hZ hδ).mpr (by nlinarith) + +theorem normalizedIntegerInterpolation_zero (K c δ : ℝ) (hδ : 0 < δ) (u : ℝ) + (hu : 3 * δ / 4 ≤ |u - c|) : normalizedIntegerInterpolation K c δ u = 0 := by + have hz : smoothProbabilityProfile ((u-c)/δ) = 0 := by + apply smoothProbabilityProfile_zero + rw [abs_div, abs_of_pos hδ] + apply (le_div_iff₀ hδ).mpr + linarith + simp only [normalizedIntegerInterpolation, hz, mul_zero, zero_div] + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def constantIntegerPMF (K δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) : PMF ℤ := + if h : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K then + normalizedIntegerPMF K 0 δ hK hδ h + else PMF.pure 0 + +theorem constantIntegerPMF_large (K δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) : + constantIntegerPMF K δ hK hδ = normalizedIntegerPMF K 0 δ hK hδ hlarge := by + simp [constantIntegerPMF, hlarge] + +theorem constantIntegerPMF_small (K δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hsmall : δ * K < 8 * (probabilityProfileLipschitz : ℝ)) : + constantIntegerPMF K δ hK hδ = PMF.pure 0 ∧ + K < 8 * (probabilityProfileLipschitz : ℝ) / δ := by + refine ⟨by simp [constantIntegerPMF, not_le.mpr hsmall], ?_⟩ + apply (lt_div_iff₀ hδ).mpr + nlinarith + +theorem constantIntegerPMF_support (K δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) {k : ℤ} + (hk : k ∈ (constantIntegerPMF K δ hK hδ).support) : + |(k : ℝ) / K| < 3 * δ / 4 := by + by_cases hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K + · rw [constantIntegerPMF_large K δ hK hδ hlarge] at hk + simpa only [sub_zero] using normalizedIntegerPMF_support K 0 δ hK hδ hlarge hk + · rw [(constantIntegerPMF_small K δ hK hδ (lt_of_not_ge hlarge)).1] at hk + have hk0 : k = 0 := by simpa only [PMF.support_pure, Set.mem_singleton_iff] using hk + subst k + simp only [Int.cast_zero, zero_div, abs_zero] + positivity + +theorem constantIntegerPMF_cap (K δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) (k : ℤ) : + K * (constantIntegerPMF K δ hK hδ k).toReal ≤ + 8 * (probabilityProfileLipschitz : ℝ) / δ := by + by_cases hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K + · rw [constantIntegerPMF_large K δ hK hδ hlarge] + refine (normalizedIntegerPMF_cap K 0 δ hK hδ hlarge k).trans ?_ + apply div_le_div_of_nonneg_right _ hδ.le + have hA : (1 : ℝ) ≤ probabilityProfileLipschitz := probabilityProfileLipschitz_one_le + linarith + · have hKbound := (constantIntegerPMF_small K δ hK hδ (lt_of_not_ge hlarge)).2 + have hp : (constantIntegerPMF K δ hK hδ k).toReal ≤ 1 := by + simpa only [ENNReal.toReal_one] using + ENNReal.toReal_mono ENNReal.one_ne_top ((constantIntegerPMF K δ hK hδ).coe_le_one k) + exact (mul_le_mul_of_nonneg_left hp hK.le).trans (by simpa only [mul_one] using hKbound.le) + +end Erdos3 + +end + +section + +namespace Erdos3 + +def IsIntegerMassInterpolation (K : ℝ) (p : PMF ℤ) (B L : ℝ) (f : ℝ → ℝ) : Prop := + (∀ k : ℤ, f ((k : ℝ) / K) = K * (p k).toReal) ∧ + (∀ x, 0 ≤ f x ∧ f x ≤ B) ∧ + (∀ x y, |f x - f y| ≤ L * |x - y|) + +theorem IsIntegerMassInterpolation.lipschitz {K B L : ℝ} {p : PMF ℤ} {f : ℝ → ℝ} + (h : IsIntegerMassInterpolation K p B L f) (hL : 0 ≤ L) : + LipschitzWith (Real.toNNReal L) f := by + apply LipschitzWith.of_dist_le_mul + intro x y + simpa only [Real.dist_eq, Real.coe_toNNReal _ hL] using h.2.2 x y + +theorem IsIntegerMassInterpolation.mono {K B L B' L' : ℝ} {p : PMF ℤ} {f : ℝ → ℝ} + (h : IsIntegerMassInterpolation K p B L f) (hB : B ≤ B') (hL : L ≤ L') : + IsIntegerMassInterpolation K p B' L' f := + ⟨h.1, fun x => ⟨(h.2.1 x).1, (h.2.1 x).2.trans hB⟩, + fun x y => (h.2.2 x y).trans (mul_le_mul_of_nonneg_right hL (abs_nonneg _))⟩ + +theorem normalizedIntegerInterpolation_difference (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) (x y : ℝ) : + |normalizedIntegerInterpolation K c δ x - normalizedIntegerInterpolation K c δ y| ≤ + (2 * (probabilityProfileLipschitz : ℝ) / δ ^ 2) * |x - y| := by + have hZ := shiftedSmoothSampleSum_pos (c * K) hlarge + have hlo := (shiftedSmoothSampleSum_bounds (c * K) hlarge).1 + have hratio : K / shiftedSmoothSampleSum (c * K) (δ * K) ≤ 2 / δ := + (div_le_div_iff₀ hZ hδ).mpr (by nlinarith) + have hprof := smoothProbabilityProfile_lipschitz.dist_le_mul ((x-c)/δ) ((y-c)/δ) + rw [Real.dist_eq, Real.dist_eq, ← sub_div, sub_sub_sub_cancel_right, abs_div, abs_of_pos hδ] at hprof + have he : normalizedIntegerInterpolation K c δ x - normalizedIntegerInterpolation K c δ y = + (K / shiftedSmoothSampleSum (c*K) (δ*K)) * + (smoothProbabilityProfile ((x-c)/δ) - smoothProbabilityProfile ((y-c)/δ)) := by + unfold normalizedIntegerInterpolation + ring + rw [he, abs_mul, abs_of_pos (div_pos hK hZ)] + calc + _ ≤ (K / shiftedSmoothSampleSum (c*K) (δ*K)) * + ((probabilityProfileLipschitz : ℝ) * (|x-y| / δ)) := + mul_le_mul_of_nonneg_left hprof (div_nonneg hK.le hZ.le) + _ ≤ (2 / δ) * ((probabilityProfileLipschitz : ℝ) * (|x-y| / δ)) := + mul_le_mul_of_nonneg_right hratio (by positivity) + _ = _ := by ring + +theorem normalizedIntegerInterpolation_spec (K c δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) : + IsIntegerMassInterpolation K (normalizedIntegerPMF K c δ hK hδ hlarge) + (2 / δ) (2 * (probabilityProfileLipschitz : ℝ) / δ ^ 2) (normalizedIntegerInterpolation K c δ) := + ⟨normalizedIntegerInterpolation_grid K c δ hK hδ hlarge, + normalizedIntegerInterpolation_range K c δ hK hδ hlarge, + normalizedIntegerInterpolation_difference K c δ hK hδ hlarge⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem normalizedIntegerInterpolation_lipschitz_bound (K c δ : ℝ) + (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K) (u v : ℝ) : + |normalizedIntegerInterpolation K c δ u - normalizedIntegerInterpolation K c δ v| ≤ + (2 * (probabilityProfileLipschitz : ℝ) / δ ^ 2) * |u - v| := by + have hZ := shiftedSmoothSampleSum_pos (c * K) hlarge + have hratio : K / shiftedSmoothSampleSum (c * K) (δ * K) ≤ 2 / δ := + (div_le_div_iff₀ hZ hδ).mpr (by nlinarith [(shiftedSmoothSampleSum_bounds (c * K) hlarge).1]) + have hb := smoothProbabilityProfile_lipschitz.dist_le_mul ((u-c)/δ) ((v-c)/δ) + rw [Real.dist_eq, Real.dist_eq, ← sub_div, sub_sub_sub_cancel_right, + abs_div, abs_of_pos hδ] at hb + rw [normalizedIntegerInterpolation, normalizedIntegerInterpolation, + ← sub_div, ← mul_sub, abs_div, abs_mul, abs_of_pos hK, abs_of_pos hZ] + calc + _ ≤ K * ((probabilityProfileLipschitz : ℝ) * (|u-v| / δ)) / + shiftedSmoothSampleSum (c * K) (δ * K) := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hb hK.le) hZ.le + _ = (K / shiftedSmoothSampleSum (c * K) (δ * K)) * + ((probabilityProfileLipschitz : ℝ) / δ) * |u-v| := by ring + _ ≤ (2 / δ) * ((probabilityProfileLipschitz : ℝ) / δ) * |u-v| := + mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right hratio + (show 0 ≤ (probabilityProfileLipschitz : ℝ) / δ by positivity)) (abs_nonneg _) + _ = _ := by ring + +theorem normalizedIntegerInterpolation_lipschitz (K c : ℝ) {δ : ℝ≥0} + (hK : 0 < K) (hδ : 0 < δ) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ (δ : ℝ) * K) : + LipschitzWith (2 * probabilityProfileLipschitz / δ ^ 2) + (normalizedIntegerInterpolation K c δ) := by + apply LipschitzWith.of_dist_le_mul + intro u v + simpa only [Real.dist_eq, NNReal.coe_div, NNReal.coe_mul, NNReal.coe_ofNat, NNReal.coe_pow] using + normalizedIntegerInterpolation_lipschitz_bound K c δ hK hδ hlarge u v + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def integerMassTent (K : ℝ) (a : ℤ) (x : ℝ) : ℝ := + K * max 0 (1 - 2 * |K * x - a|) + +theorem integerMassTent_grid (K : ℝ) (hK : 0 < K) (a k : ℤ) : + integerMassTent K a ((k : ℝ) / K) = K * ((PMF.pure a) k).toReal := by + classical + unfold integerMassTent + rw [mul_div_cancel₀ _ hK.ne'] + by_cases h : k = a + · subst k + simp + · have hn : (1 : ℤ) ≤ |k-a| := Int.one_le_abs (sub_ne_zero.mpr h) + have hn' : (1 : ℝ) ≤ |(k : ℝ) - a| := by exact_mod_cast hn + have hz : max 0 (1 - 2 * |(k : ℝ) - a|) = 0 := max_eq_left (by linarith) + simp [hz, h] + +theorem integerMassTent_range (K : ℝ) (hK : 0 ≤ K) (a : ℤ) (x : ℝ) : + 0 ≤ integerMassTent K a x ∧ integerMassTent K a x ≤ K := by + refine ⟨mul_nonneg hK (le_max_left _ _), ?_⟩ + have ht : max 0 (1 - 2 * |K*x-a|) ≤ (1 : ℝ) := + max_le (by norm_num) (by linarith [abs_nonneg (K*x-a)]) + exact (mul_le_mul_of_nonneg_left ht hK).trans_eq (mul_one K) + +theorem integerMassTent_difference (K : ℝ) (hK : 0 ≤ K) (a : ℤ) (x y : ℝ) : + |integerMassTent K a x - integerMassTent K a y| ≤ (2 * K ^ 2) * |x-y| := by + have hm : |max 0 (1 - 2 * |K*x-a|) - max 0 (1 - 2 * |K*y-a|)| ≤ + |(1 - 2 * |K*x-a|) - (1 - 2 * |K*y-a|)| := by + simpa only [max_comm] using abs_max_sub_max_le_abs (1 - 2 * |K*x-a|) (1 - 2 * |K*y-a|) (0 : ℝ) + have ha := abs_abs_sub_abs_le_abs_sub (K*x-a) (K*y-a) + rw [sub_sub_sub_cancel_right, ← mul_sub, abs_mul, abs_of_nonneg hK] at ha + have he : (1 - 2 * |K*x-a|) - (1 - 2 * |K*y-a|) = + -(2 * (|K*x-a| - |K*y-a|)) := by ring + rw [he, abs_neg, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 2)] at hm + unfold integerMassTent + rw [← mul_sub, abs_mul, abs_of_nonneg hK] + calc + _ ≤ K * (2 * abs (|K*x-a| - |K*y-a|)) := mul_le_mul_of_nonneg_left hm hK + _ ≤ K * (2 * (K * |x-y|)) := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left ha (by norm_num)) hK + _ = _ := by ring + +theorem integerMassTent_spec (K : ℝ) (hK : 0 < K) (a : ℤ) : + IsIntegerMassInterpolation K (PMF.pure a) K (2 * K ^ 2) (integerMassTent K a) := + ⟨integerMassTent_grid K hK a, integerMassTent_range K hK.le a, integerMassTent_difference K hK.le a⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +theorem affineCoefficientImage_enormous_error {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (s : I ↪ J) (S : J → ℝ) (hS : ∀ j, 0 < S j) + {H L C U G : ℝ} (h : ℕ) (ctrl : CoefficientFiberControl A s S H L h C U G) + (hL : 0 < L) (hH : 0 < H) (hC : 0 ≤ C) + (c w : J → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w j) {R : ℝ} (hR : 0 ≤ R) (hsupport : ∀ j, |c j| + w j ≤ R) + (hlarge : 2 * (1 + (2 * R + 2) ^ (Fintype.card I + Fintype.card (UnselectedColumn s)) * + affineProductProfileLip J δ) * ((Fintype.card I).factorial * C ^ Fintype.card I) * + L ^ (h * (Fintype.card I + 1)) ≤ H) : + ∃ hZ : 0 < coefficientWeightSum (affineProductProfile c w) S, ∀ v, + |H ^ Fintype.card I * + (coefficientImagePMF A (affineProductProfile c w) (affineProductProfile_nonneg c w hw) + S hS (affineProductProfile_zero_outside c w hw hR hsupport) hZ v).toReal - + coefficientImageMask A (fun _ => H) + (selectedCoefficientDensity A s ctrl.det_ne_zero S (fun _ => H) hS (fun _ => hH) + (affineProductProfile c w)) v| ≤ + (normalizedFiberErrorConstant (Fintype.card I) (Fintype.card (UnselectedColumn s)) + G U (Fintype.card (UnselectedColumn s) * C) R ((δ : ℝ)⁻¹ ^ Fintype.card J) + (affineProductProfileLip J δ) * ((Fintype.card I).factorial * C ^ Fintype.card I)) * + L ^ (h * (Fintype.card I + 1)) / H := by + exact coefficientImage_enormous_of_control A s S hS h ctrl hL hH hC + (affineProductProfile c w) (affineProductProfile_nonneg c w hw) + (affineProductProfile_lipschitz c w hδ hwidth) hR (by positivity) + (affineProductProfile_zero_outside c w hw hR hsupport) + (affineProductProfile_integral c w hw) (affineProductProfile_cap c w hδ hwidth) hlarge + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def constantIntegerInterpolation (K δ : ℝ) : ℝ → ℝ := + if 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K then normalizedIntegerInterpolation K 0 δ + else integerMassTent K 0 + +noncomputable def constantIntegerInterpolationCap (δ : ℝ) : ℝ := + 8 * (probabilityProfileLipschitz : ℝ) / δ + +noncomputable def constantIntegerInterpolationLip (δ : ℝ) : ℝ := + max (2 * (probabilityProfileLipschitz : ℝ) / δ ^ 2) + (2 * (constantIntegerInterpolationCap δ) ^ 2) + +theorem constantIntegerInterpolation_spec (K δ : ℝ) (hK : 0 < K) (hδ : 0 < δ) : + IsIntegerMassInterpolation K (constantIntegerPMF K δ hK hδ) + (constantIntegerInterpolationCap δ) (constantIntegerInterpolationLip δ) + (constantIntegerInterpolation K δ) := by + by_cases hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ δ * K + · rw [constantIntegerPMF_large K δ hK hδ hlarge] + simp only [constantIntegerInterpolation, hlarge, ↓reduceIte] + apply (normalizedIntegerInterpolation_spec K 0 δ hK hδ hlarge).mono + · apply div_le_div_of_nonneg_right _ hδ.le + have hA : (1 : ℝ) ≤ probabilityProfileLipschitz := probabilityProfileLipschitz_one_le + linarith + · exact le_max_left _ _ + · obtain ⟨hp, hbound⟩ := constantIntegerPMF_small K δ hK hδ (lt_of_not_ge hlarge) + rw [hp] + simp only [constantIntegerInterpolation, hlarge, ↓reduceIte] + apply (integerMassTent_spec K hK 0).mono hbound.le + exact (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hK.le hbound.le 2) (by norm_num)).trans + (le_max_right _ _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def integerPointDensity (A : ℝ) (z : ℤ) (t : ℝ) : ℝ := + A * max 0 (1 - |A * t - z|) + +theorem integerPointDensity_grid (A : ℝ) (hA : 0 < A) (z k : ℤ) : + integerPointDensity A z ((k : ℝ) / A) = A * ((PMF.pure z) k).toReal := by + classical + unfold integerPointDensity + rw [mul_div_cancel₀ _ hA.ne'] + by_cases h : k = z + · subst k + simp + · have hn : (1 : ℤ) ≤ |k - z| := Int.one_le_abs (sub_ne_zero.mpr h) + have hn' : (1 : ℝ) ≤ |(k : ℝ) - z| := by exact_mod_cast hn + have hz : max 0 (1 - |(k : ℝ) - z|) = 0 := max_eq_left (by linarith) + simp [hz, h] + +theorem integerPointDensity_range (A : ℝ) (hA : 0 ≤ A) (z : ℤ) (t : ℝ) : + 0 ≤ integerPointDensity A z t ∧ integerPointDensity A z t ≤ A := by + refine ⟨mul_nonneg hA (le_max_left _ _), ?_⟩ + have ht : max 0 (1 - |A * t - z|) ≤ (1 : ℝ) := + max_le (by norm_num) (by linarith [abs_nonneg (A * t - z)]) + exact (mul_le_mul_of_nonneg_left ht hA).trans_eq (mul_one A) + +theorem integerPointDensity_difference (A : ℝ) (hA : 0 ≤ A) (z : ℤ) (x y : ℝ) : + |integerPointDensity A z x - integerPointDensity A z y| ≤ A ^ 2 * |x - y| := by + have hm : |max 0 (1 - |A*x-z|) - max 0 (1 - |A*y-z|)| ≤ + |(1 - |A*x-z|) - (1 - |A*y-z|)| := by + simpa only [max_comm] using abs_max_sub_max_le_abs (1 - |A*x-z|) (1 - |A*y-z|) (0 : ℝ) + have ha := abs_abs_sub_abs_le_abs_sub (A*x-z) (A*y-z) + rw [sub_sub_sub_cancel_right, ← mul_sub, abs_mul, abs_of_nonneg hA] at ha + have he : (1 - |A*x-z|) - (1 - |A*y-z|) = -(|A*x-z| - |A*y-z|) := by ring + rw [he, abs_neg] at hm + unfold integerPointDensity + rw [← mul_sub, abs_mul, abs_of_nonneg hA] + exact (mul_le_mul_of_nonneg_left (hm.trans ha) hA).trans_eq (by ring) + +theorem integerPointDensity_lipschitz (A : ℝ) (hA : 0 ≤ A) (z : ℤ) : + LipschitzWith ⟨A ^ 2, sq_nonneg A⟩ (integerPointDensity A z) := by + apply LipschitzWith.of_dist_le_mul + intro x y + exact integerPointDensity_difference A hA z x y + +theorem integerPointDensity_support (A : ℝ) (z : ℤ) (t : ℝ) + (ht : integerPointDensity A z t ≠ 0) : |A * t - z| < 1 := by + by_contra! h + have hz : max 0 (1 - |A * t - z|) = 0 := max_eq_left (by linarith) + exact ht (by simp only [integerPointDensity, hz, mul_zero]) + +theorem integerPointDensity_support_quarter (A : ℝ) (hA : 0 < A) (z : ℤ) + (hz : |(z : ℝ)| + 1 ≤ A / 4) (t : ℝ) + (ht : integerPointDensity A z t ≠ 0) : |t| < 1 / 4 := by + have hs := abs_lt.mp (integerPointDensity_support A z t ht) + rw [abs_lt] + constructor + · nlinarith [neg_abs_le (z : ℝ)] + · nlinarith [le_abs_self (z : ℝ)] + +theorem integerPointDensity_spec (A : ℝ) (hA : 0 < A) (z : ℤ) : + IsIntegerMassInterpolation A (PMF.pure z) A (A ^ 2) (integerPointDensity A z) := + ⟨integerPointDensity_grid A hA z, integerPointDensity_range A hA.le z, + integerPointDensity_difference A hA.le z⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators NNReal + +variable {O : Type*} [Fintype O] + +noncomputable def integerRowMassTent (K : ℝ) (z : O → ℤ) (x : O → ℝ) : ℝ := + ∏ i, integerMassTent K (z i) (x i) + +theorem integerRowMassTent_range {K : ℝ} (hK : 0 ≤ K) (z : O → ℤ) (x : O → ℝ) : + 0 ≤ integerRowMassTent K z x ∧ integerRowMassTent K z x ≤ K ^ Fintype.card O := by + refine ⟨Finset.prod_nonneg (fun i _ => (integerMassTent_range K hK (z i) (x i)).1), ?_⟩ + simpa only [integerRowMassTent, Finset.prod_const, Finset.card_univ] using + Finset.prod_le_prod₀ (s := Finset.univ) + (fun i _ => (integerMassTent_range K hK (z i) (x i)).1) + (fun i _ => (integerMassTent_range K hK (z i) (x i)).2) + +theorem integerRowMassTent_grid {K : ℝ} (hK : 0 < K) (z k : O → ℤ) : + integerRowMassTent K z (fun i => (k i : ℝ) / K) = + if z = k then K ^ Fintype.card O else 0 := by + classical + by_cases he : z = k + · subst z + simp [integerRowMassTent, integerMassTent_grid K hK] + · obtain ⟨i, hi⟩ : ∃ i, z i ≠ k i := Function.ne_iff.mp he + have hz : integerMassTent K (z i) ((k i : ℝ) / K) = 0 := by + rw [integerMassTent_grid K hK] + simp [Ne.symm hi] + simp only [he, ↓reduceIte] + exact Finset.prod_eq_zero (Finset.mem_univ i) hz + +theorem integerRowMassTent_lipschitz (K : ℝ≥0) (hK : 1 ≤ K) (z : O → ℤ) : + LipschitzWith (Fintype.card O * (2 * K ^ 2) * K ^ Fintype.card O) + (integerRowMassTent (K : ℝ) z) := by + have hf (i : O) : LipschitzWith (2 * K ^ 2) (fun x : O → ℝ => integerMassTent K (z i) (x i)) := by + apply LipschitzWith.of_dist_le_mul + intro x y + calc + _ ≤ (2 * (K : ℝ) ^ 2) * |x i - y i| := integerMassTent_difference K K.coe_nonneg (z i) (x i) (y i) + _ ≤ _ := by + simpa only [NNReal.coe_mul, NNReal.coe_ofNat, NNReal.coe_pow, Real.dist_eq] using + mul_le_mul_of_nonneg_left (dist_le_pi_dist x y i) (by positivity : 0 ≤ 2 * (K : ℝ) ^ 2) + exact (bounded_lipschitz_real_prod _ hK hf (fun i x => by + rw [abs_of_nonneg (integerMassTent_range K K.coe_nonneg (z i) (x i)).1] + exact (integerMassTent_range K K.coe_nonneg (z i) (x i)).2)).2 + +noncomputable def integerRowMassInterpolation (K : ℝ) (p : PMF (O → ℤ)) (x : O → ℝ) : ℝ := + ∫ z, integerRowMassTent K z x ∂p.toMeasure + +theorem integerRowMassTent_integrable {K : ℝ} (hK : 0 ≤ K) (p : PMF (O → ℤ)) (x : O → ℝ) : + Integrable (fun z => integerRowMassTent K z x) p.toMeasure := by + apply (integrable_const (K ^ Fintype.card O)).mono' (measurable_of_countable _).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun z => by + rw [Real.norm_eq_abs, abs_of_nonneg (integerRowMassTent_range hK z x).1] + exact (integerRowMassTent_range hK z x).2) + +theorem integerRowMassInterpolation_range {K : ℝ} (hK : 0 ≤ K) (p : PMF (O → ℤ)) (x : O → ℝ) : + 0 ≤ integerRowMassInterpolation K p x ∧ integerRowMassInterpolation K p x ≤ K ^ Fintype.card O := by + refine ⟨integral_nonneg (fun z => (integerRowMassTent_range hK z x).1), ?_⟩ + have h := integral_mono (integerRowMassTent_integrable hK p x) (integrable_const (K ^ Fintype.card O)) + (fun z => (integerRowMassTent_range hK z x).2) + simpa only [integerRowMassInterpolation, integral_const, measureReal_def, measure_univ, + ENNReal.toReal_one, one_smul] using h + +theorem integerRowMassInterpolation_grid {K : ℝ} (hK : 0 < K) (p : PMF (O → ℤ)) (k : O → ℤ) : + integerRowMassInterpolation K p (fun i => (k i : ℝ) / K) = + K ^ Fintype.card O * (p k).toReal := by + classical + have he : (fun z => integerRowMassTent K z (fun i => (k i : ℝ) / K)) = + Set.indicator {k} (fun _ => K ^ Fintype.card O) := by + funext z + simp only [integerRowMassTent_grid hK, Set.indicator_apply, Set.mem_singleton_iff] + rw [integerRowMassInterpolation, he, integral_indicator (measurableSet_singleton k), integral_singleton, + measureReal_def, PMF.toMeasure_apply_singleton _ k (measurableSet_singleton k), smul_eq_mul, mul_comm] + +theorem integerRowMassInterpolation_lipschitz (K : ℝ≥0) (hK : 1 ≤ K) (p : PMF (O → ℤ)) : + LipschitzWith (Fintype.card O * (2 * K ^ 2) * K ^ Fintype.card O) + (integerRowMassInterpolation (K : ℝ) p) := by + apply LipschitzWith.of_dist_le_mul + intro x y + change ‖integerRowMassInterpolation (K : ℝ) p x - integerRowMassInterpolation (K : ℝ) p y‖ ≤ _ + rw [integerRowMassInterpolation, integerRowMassInterpolation, + ← integral_sub (integerRowMassTent_integrable K.coe_nonneg p x) (integerRowMassTent_integrable K.coe_nonneg p y)] + have h := norm_integral_le_of_norm_le_const (μ := p.toMeasure) + (f := fun z => integerRowMassTent (K : ℝ) z x - integerRowMassTent (K : ℝ) z y) + (C := (Fintype.card O * (2 * K ^ 2) * K ^ Fintype.card O : ℝ≥0) * dist x y) + (Filter.Eventually.of_forall (fun z => by + simpa only [dist_eq_norm] using (integerRowMassTent_lipschitz K hK z).dist_le_mul x y)) + simpa only [measureReal_def, measure_univ, ENNReal.toReal_one, mul_one] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +variable {O : Type*} [Fintype O] + +noncomputable def normalizedIntegerRowInterpolation (K : ℝ) (p : PMF (O → ℤ)) + (x : O → ℝ) : ℝ := integerRowMassInterpolation K p x / K ^ Fintype.card O + +theorem normalizedIntegerRowInterpolation_range {K : ℝ} (hK : 0 < K) + (p : PMF (O → ℤ)) (x : O → ℝ) : + normalizedIntegerRowInterpolation K p x ∈ Set.Icc (0 : ℝ) 1 := by + have h := integerRowMassInterpolation_range hK.le p x + exact ⟨div_nonneg h.1 (pow_nonneg hK.le _), (div_le_one (pow_pos hK _)).mpr h.2⟩ + +theorem normalizedIntegerRowInterpolation_grid {K : ℝ} (hK : 0 < K) + (p : PMF (O → ℤ)) (z : O → ℤ) : + normalizedIntegerRowInterpolation K p (fun i => (z i : ℝ) / K) = (p z).toReal := by + rw [normalizedIntegerRowInterpolation, integerRowMassInterpolation_grid hK] + exact mul_div_cancel_left₀ _ (pow_ne_zero _ hK.ne') + +theorem normalizedIntegerRowInterpolation_lipschitz (K : ℝ≥0) (hK : 1 ≤ K) + (p : PMF (O → ℤ)) : + LipschitzWith (Fintype.card O * (2 * K ^ 2)) (normalizedIntegerRowInterpolation K p) := by + have hp : 0 < (K : ℝ) ^ Fintype.card O := + pow_pos (lt_of_lt_of_le zero_lt_one (by exact_mod_cast hK)) _ + apply LipschitzWith.of_dist_le_mul + intro x y + have h := (integerRowMassInterpolation_lipschitz K hK p).dist_le_mul x y + rw [Real.dist_eq] at h ⊢ + simp only [normalizedIntegerRowInterpolation, ← sub_div, abs_div, abs_of_pos hp] + simp only [NNReal.coe_mul, NNReal.coe_natCast, NNReal.coe_ofNat, NNReal.coe_pow] at h ⊢ + apply (div_le_iff₀ hp).mpr + calc + _ ≤ (Fintype.card O * (2 * (K : ℝ) ^ 2) * (K : ℝ) ^ Fintype.card O) * dist x y := h + _ = _ := by ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +variable {O : Type*} [Fintype O] + +theorem integerRowMassInterpolation_bind {X : Type*} + [Countable X] [MeasurableSpace X] [MeasurableSingletonClass X] + (K : ℝ) (hK : 0 ≤ K) (p : PMF X) (q : X → PMF (O → ℤ)) (x : O → ℝ) : + integerRowMassInterpolation K (p.bind q) x = + ∫ a, integerRowMassInterpolation K (q a) x ∂p.toMeasure := by + apply pmf_integral_bind p q (fun z => integerRowMassTent K z x) + (integerRowMassTent_integrable hK (p.bind q) x) + apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable (K ^ Fintype.card O) + apply ae_of_all + intro a + change ‖integerRowMassInterpolation K (q a) x‖ ≤ K ^ Fintype.card O + rw [Real.norm_eq_abs, abs_of_nonneg (integerRowMassInterpolation_range hK (q a) x).1] + exact (integerRowMassInterpolation_range hK (q a) x).2 + +theorem normalizedIntegerRowInterpolation_bind {X : Type*} + [Countable X] [MeasurableSpace X] [MeasurableSingletonClass X] + (K : ℝ) (hK : 0 ≤ K) (p : PMF X) (q : X → PMF (O → ℤ)) (x : O → ℝ) : + normalizedIntegerRowInterpolation K (p.bind q) x = + ∫ a, normalizedIntegerRowInterpolation K (q a) x ∂p.toMeasure := by + unfold normalizedIntegerRowInterpolation + rw [integerRowMassInterpolation_bind K hK p q x, integral_div] + +theorem integerRowMassInterpolation_finite_bind {X : Type*} [Fintype X] + (K : ℝ) (hK : 0 ≤ K) (p : FiniteProbabilityWeights X) + (q : X → PMF (O → ℤ)) (x : O → ℝ) : + integerRowMassInterpolation K (p.toPMF.bind q) x = + p.mean (fun a => integerRowMassInterpolation K (q a) x) := + p.integral_bind_real q (fun z => integerRowMassTent K z x) + (integerRowMassTent_integrable hK (p.toPMF.bind q) x) + +theorem normalizedIntegerRowInterpolation_finite_bind {X : Type*} [Fintype X] + (K : ℝ) (hK : 0 ≤ K) (p : FiniteProbabilityWeights X) + (q : X → PMF (O → ℤ)) (x : O → ℝ) : + normalizedIntegerRowInterpolation K (p.toPMF.bind q) x = + p.mean (fun a => normalizedIntegerRowInterpolation K (q a) x) := by + unfold normalizedIntegerRowInterpolation + rw [integerRowMassInterpolation_finite_bind K hK p q x] + simp only [FiniteProbabilityWeights.mean, Finset.sum_div, mul_div_assoc] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerSectionFactorization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerSectionFactorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a0ade5d8c0a5ea111204b890efd171b898dd51d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerSectionFactorization.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.Progressions.Fourier.ClearedSectionFrequency +import OAI.Combinatorics.Progressions.Linear.QuotientProjectionCoordinates + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +theorem subspaceArrayFunctional_integer_section {I S J : Type*} + [Fintype I] [Fintype S] [Fintype J] [DecidableEq I] [DecidableEq S] + (U : Submodule ℝ (J → ℝ)) (E : Matrix S I ℚ) (T : Matrix I S ℚ) + (hT : E * T * E = E) (frequency : Matrix I J ℤ) + (M : (S → U) →ₗ[ℝ] ℝ) + (hfactor : ∀ x, subspaceArrayFunctional U (fun i a => (frequency i a : ℝ)) x = + M (matrixModuleAction (fun s i => (E s i : ℝ)) x)) (x : I → U) : + subspaceArrayFunctional U (fun i a => (frequency i a : ℝ)) x = + subspaceArrayFunctional U (fun s a => (sectionIntegerFrequency T frequency s a : ℝ)) + (matrixModuleAction (fun s i => (E s i : ℝ)) ((matrixDenominator T : ℝ)⁻¹ • x)) := by + have hq : (matrixDenominator T : ℝ) ≠ 0 := by + exact_mod_cast (matrixDenominator_pos T).ne' + have hreal := real_matrix_image_section E T hT + have hf := subspaceArrayFunctional_factor_section U + (fun s i => (E s i : ℝ)) (fun i s => (T i s : ℝ)) hreal + (fun i a => (frequency i a : ℝ)) M hfactor ((matrixDenominator T : ℝ)⁻¹ • x) + have hc := congrArg + (fun B : Matrix S J ℝ => subspaceArrayFunctional U B + (matrixModuleAction (fun s i => (E s i : ℝ)) ((matrixDenominator T : ℝ)⁻¹ • x))) + (sectionIntegerFrequency_real T frequency) + simp only [subspaceArrayFunctional_smul] at hc + calc + _ = (matrixDenominator T : ℝ) * + subspaceArrayFunctional U (fun i a => (frequency i a : ℝ)) ((matrixDenominator T : ℝ)⁻¹ • x) := by + rw [map_smul, smul_eq_mul, ← mul_assoc, mul_inv_cancel₀ hq, one_mul] + _ = _ := (congrArg (fun r : ℝ => (matrixDenominator T : ℝ) * r) hf).trans hc.symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerVectorFreimanEmbedding.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerVectorFreimanEmbedding.lean new file mode 100644 index 0000000000000000000000000000000000000000..48f6df5e419a4fbdaae3088b7487bd129db20682 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerVectorFreimanEmbedding.lean @@ -0,0 +1,115 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3.FreimanModel + +open scoped BigOperators Pointwise + +noncomputable def coordinatePolynomial (n : ℕ) : (Fin n → ℤ) →+ Polynomial ℤ where + toFun x := ∑ i : Fin n, Polynomial.monomial (i : ℕ) (x i) + map_zero' := by simp + map_add' x y := by simp [Finset.sum_add_distrib] + +theorem coordinatePolynomial_coeff {n : ℕ} (x : Fin n → ℤ) (i : Fin n) : + (coordinatePolynomial n x).coeff (i : ℕ) = x i := by + change (∑ j : Fin n, Polynomial.monomial (j : ℕ) (x j)).coeff (i : ℕ) = x i + rw [Polynomial.finsetSum_coeff, Finset.sum_eq_single i] + · simp + · intro j _ hji + simp [Polynomial.coeff_monomial, Fin.val_inj.ne.mpr hji] + · simp + +theorem coordinatePolynomial_injective (n : ℕ) : + Function.Injective (coordinatePolynomial n) := by + intro x y h + funext i + simpa only [coordinatePolynomial_coeff] using + congrArg (fun p : Polynomial ℤ => p.coeff (i : ℕ)) h + +theorem exists_fin_integer_embedding {n : ℕ} (A : Finset (Fin n → ℤ)) : + ∃ f : (Fin n → ℤ) →+ ℤ, Set.InjOn f (A : Set _) := by + classical + let P := coordinatePolynomial n + let R := (A ×ˢ A).biUnion fun xy => (P xy.1 - P xy.2).roots.toFinset + obtain ⟨t, ht⟩ := R.exists_notMem + let f := (Polynomial.evalRingHom t).toAddMonoidHom.comp P + refine ⟨f, ?_⟩ + intro x hx y hy hxy + by_contra hne + have hP : P x - P y ≠ 0 := + sub_ne_zero.mpr (fun h => hne (coordinatePolynomial_injective n h)) + apply ht + apply Finset.mem_biUnion.mpr + refine ⟨(x, y), Finset.mem_product.mpr ⟨hx, hy⟩, ?_⟩ + rw [Multiset.mem_toFinset, Polynomial.mem_roots hP] + change (P x - P y).eval t = 0 + rw [Polynomial.eval_sub, sub_eq_zero] + exact hxy + +theorem exists_integer_vector_embedding {I : Type*} [Fintype I] + (A : Finset (I → ℤ)) : ∃ f : (I → ℤ) →+ ℤ, Set.InjOn f (A : Set _) := by + classical + let e := Fintype.equivFin I + let r : (I → ℤ) →+ (Fin (Fintype.card I) → ℤ) := + { toFun := fun x j => x (e.symm j) + map_zero' := rfl + map_add' := fun _ _ => rfl } + have hr : Function.Injective r := by + intro x y h + funext i + simpa only [r, AddMonoidHom.coe_mk, ZeroHom.coe_mk, Equiv.symm_apply_apply] using + congrFun h (e i) + obtain ⟨f, hf⟩ := exists_fin_integer_embedding (A.image r) + refine ⟨f.comp r, ?_⟩ + intro x hx y hy hxy + exact hr (hf (Finset.mem_image.mpr ⟨x, hx, rfl⟩) + (Finset.mem_image.mpr ⟨y, hy, rfl⟩) hxy) + +theorem multiset_sum_mem_iterated_sumset {G : Type*} [AddCommMonoid G] [DecidableEq G] + (A : Finset G) {T : Multiset G} (hT : ∀ x ∈ T, x ∈ A) : + T.sum ∈ T.card • A := by + induction T using Multiset.induction_on with + | empty => simp + | @cons a T ih => + rw [Multiset.card_cons, succ_nsmul, Finset.mem_add] + refine ⟨T.sum, ih ?_, a, hT a (by simp), ?_⟩ + · intro x hx + exact hT x (by simp [hx]) + · simp [add_comm] + +theorem isAddFreimanIso_of_injOn_iterated_sums + {G H : Type*} [AddCommMonoid G] [AddCommMonoid H] [DecidableEq G] [DecidableEq H] + (f : G →+ H) (A : Finset G) (s : ℕ) (hinj : Set.InjOn f (A : Set G)) + (hsinj : Set.InjOn f (s • A : Finset G)) : + IsAddFreimanIso s (A : Set G) (A.image f : Set H) f := by + refine ⟨⟨?_, hinj, ?_⟩, ?_⟩ + · intro x hx + exact Finset.mem_image.mpr ⟨x, hx, rfl⟩ + · intro y hy + exact Finset.mem_image.mp hy + · intro T U hT hU hTc hUc + rw [← map_multiset_sum, ← map_multiset_sum] + have hTs : T.sum ∈ s • A := by + simpa only [hTc] using multiset_sum_mem_iterated_sumset A (fun x hx => hT hx) + have hUs : U.sum ∈ s • A := by + simpa only [hUc] using multiset_sum_mem_iterated_sumset A (fun x hx => hU hx) + exact ⟨fun h => hsinj hTs hUs h, congrArg f⟩ + +theorem exists_integer_freiman_embedding {I : Type*} [Fintype I] + (A : Finset (I → ℤ)) (s : ℕ) : + ∃ f : (I → ℤ) →+ ℤ, IsAddFreimanIso s (A : Set _) + (A.image f : Set ℤ) f := by + classical + obtain ⟨f, hf⟩ := exists_integer_vector_embedding (A ∪ s • A) + refine ⟨f, isAddFreimanIso_of_injOn_iterated_sums f A s ?_ ?_⟩ + · exact hf.mono (fun _ hx => Finset.mem_union_left _ hx) + · exact hf.mono (fun _ hx => Finset.mem_union_right _ hx) + +end Erdos3.FreimanModel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerWeightedLoweringGroup.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerWeightedLoweringGroup.lean new file mode 100644 index 0000000000000000000000000000000000000000..028adecd9e76e9ab64328693da02207df14cab91 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerWeightedLoweringGroup.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialTranslationActionCompatibility + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +variable {σ : Type*} {w : σ → ℕ} + +theorem integerWeightedLowering_preimage (e : WeightedLoweringAut w ℚ) + (he : ∀ i, e.val (X i) ∈ integerCoefficientPolynomials σ) + {P : MvPolynomial σ ℚ} {n : ℕ} (hP : P ∈ integerCoefficientPolynomials σ) + (hdegree : P ∈ weightedSupportLE w n) : + ∃ Q, Q ∈ integerCoefficientPolynomials σ ∧ Q ∈ weightedSupportLE w n ∧ e.val Q = P := by + induction n generalizing P with + | zero => + refine ⟨P, hP, hdegree, ?_⟩ + exact sub_eq_zero.mp (weightedSupportLT_zero_eq (e.difference_lower hdegree)) + | succ n ih => + have hI : e.val P - P ∈ integerCoefficientPolynomials σ := + (integerCoefficientPolynomials σ).sub_mem (integerPolynomialHom_preserves e.val.toAlgHom he hP) hP + have hD : e.val P - P ∈ weightedSupportLE w n := + weightedSupportLT_succ_le (e.difference_lower hdegree) + obtain ⟨Q, hQI, hQD, hQ⟩ := ih hI hD + refine ⟨P - Q, (integerCoefficientPolynomials σ).sub_mem hP hQI, + (weightedSupportLE w (n + 1)).sub_mem hdegree (weightedSupportLE_mono (Nat.le_succ n) hQD), ?_⟩ + rw [map_sub, hQ] + abel + +theorem integerWeightedLowering_inverse_preserves (e : WeightedLoweringAut w ℚ) + (he : ∀ i, e.val (X i) ∈ integerCoefficientPolynomials σ) + {P : MvPolynomial σ ℚ} (hP : P ∈ integerCoefficientPolynomials σ) : + e.val.symm P ∈ integerCoefficientPolynomials σ := by + obtain ⟨Q, hQI, _, hQ⟩ := integerWeightedLowering_preimage e he hP + ((mem_weightedSupportLE_iff w _ P).mpr le_rfl) + have hEQ : e.val.symm P = Q := by + apply e.val.injective + rw [e.val.apply_symm_apply, hQ] + rw [hEQ] + exact hQI + +noncomputable def integerWeightedLoweringSubgroup (w : σ → ℕ) : Subgroup (WeightedLoweringAut w ℚ) where + carrier := {e | ∀ i, e.val (X i) ∈ integerCoefficientPolynomials σ} + one_mem' := fun i => integerCoefficientPolynomials_X i + mul_mem' := by + intro e f he hf i + exact integerPolynomialHom_preserves e.val.toAlgHom he (hf i) + inv_mem' := by + intro e he i + exact integerWeightedLowering_inverse_preserves e he (integerCoefficientPolynomials_X i) + +theorem integerWeightedLowering_preserves (e : WeightedLoweringAut w ℚ) + (he : e ∈ integerWeightedLoweringSubgroup w) + {P : MvPolynomial σ ℚ} (hP : P ∈ integerCoefficientPolynomials σ) : + e.val P ∈ integerCoefficientPolynomials σ := + integerPolynomialHom_preserves e.val.toAlgHom he hP + +theorem integerWeightedLowering_difference_pow (e : WeightedLoweringAut w ℚ) + (he : e ∈ integerWeightedLoweringSubgroup w) + {P : MvPolynomial σ ℚ} (hP : P ∈ integerCoefficientPolynomials σ) (k : ℕ) : + (polynomialHomDifference e.val.toAlgHom ^ k) P ∈ integerCoefficientPolynomials σ := by + induction k with + | zero => exact hP + | succ k ih => + rw [pow_succ', Module.End.mul_apply] + exact (integerCoefficientPolynomials σ).sub_mem (integerWeightedLowering_preserves e he ih) ih + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegerWindowFactor.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerWindowFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbb72785ede6ff789f154adecd57847dfe9473e5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegerWindowFactor.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.Progressions.Dynamics.PhysicalBoundaryBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem integerIntervalBox_card_real {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i ≤ hi i) : + ((Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i))).card : ℝ) = + ∏ i, ((hi i - lo i : ℤ) : ℝ) := by + rw [Fintype.card_piFinset, Nat.cast_prod] + apply Finset.prod_congr rfl + intro i _ + exact_mod_cast Int.card_Ico_of_le (lo i) (hi i) (hlen i) + +theorem integerIntervalBox_window_factor_le {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) + (S : I → ℝ) (hS : ∀ i, 0 ≤ S i) {K : ℝ} + (hside : ∀ i, S i ≤ K * ((hi i - lo i : ℤ) : ℝ)) : + (3 : ℝ) ^ Fintype.card I * (∏ i, S i) / + (Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i))).card ≤ + (3 * K) ^ Fintype.card I := by + rw [integerIntervalBox_card_real lo hi (fun i => (hlen i).le)] + have hlenR (i : I) : (0 : ℝ) < ((hi i - lo i : ℤ) : ℝ) := by + exact_mod_cast sub_pos.mpr (hlen i) + calc + _ = ∏ i, 3 * (S i / ((hi i - lo i : ℤ) : ℝ)) := by + rw [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, Finset.prod_div_distrib] + ring + _ ≤ ∏ _i : I, 3 * K := Finset.prod_le_prod₀ + (fun i _ => mul_nonneg (by norm_num) (div_nonneg (hS i) (hlenR i).le)) + (fun i _ => mul_le_mul_of_nonneg_left ((div_le_iff₀ (hlenR i)).mpr (hside i)) (by norm_num)) + _ = _ := by rw [Finset.prod_const, Finset.card_univ] + +theorem translated_box_window_factor_le {I : Type*} [Fintype I] [DecidableEq I] + (lo : I → ℤ) (N : I → ℕ) (hN : ∀ i, 0 < N i) + (S : I → ℝ) (hS : ∀ i, 0 ≤ S i) {K : ℝ} + (hside : ∀ i, S i ≤ K * (N i : ℝ)) : + (3 : ℝ) ^ Fintype.card I * (∏ i, S i) / (translatedIntegerBox lo N).card ≤ + (3 * K) ^ Fintype.card I := by + simp only [translatedIntegerBox, card_translateSupport, card_integerBox, Nat.cast_prod] + have hNR (i : I) : (0 : ℝ) < N i := by exact_mod_cast hN i + calc + _ = ∏ i, 3 * (S i / (N i : ℝ)) := by + rw [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, Finset.prod_div_distrib] + ring + _ ≤ ∏ _i : I, 3 * K := Finset.prod_le_prod₀ + (fun i _ => mul_nonneg (by norm_num) (div_nonneg (hS i) (hNR i).le)) + (fun i _ => mul_le_mul_of_nonneg_left ((div_le_iff₀ (hNR i)).mpr (hside i)) (by norm_num)) + _ = _ := by rw [Finset.prod_const, Finset.card_univ] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntegralAffineModeRemoval.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntegralAffineModeRemoval.lean new file mode 100644 index 0000000000000000000000000000000000000000..945f6a34cb4bf49e1b4568a9946a4b28a7b840e3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntegralAffineModeRemoval.lean @@ -0,0 +1,196 @@ +import OAI.Combinatorics.Progressions.Lattices.NormalizedIntegerDual + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators Classical + +def integerFormMassBound (n : ℕ) (H D A B : ℝ) : ℝ := A * (2 + H) + ((n : ℝ) * D + 1) * B + +theorem scaledFrameForm_mass {α K : Type*} [Fintype α] + (root : K → ℤ) (difference : α → K → ℤ) (a : ℤ) + (numerator : α → MvPolynomial (Option K) ℤ) {H D A B : ℝ} + (hH : 0 ≤ H) (hD : 0 ≤ D) (hA : 0 ≤ A) (hB : 0 ≤ B) + (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D) + (ha : |(a : ℝ)| ≤ A) (hn : ∀ i, realPolynomialMass (map (Int.castRingHom ℝ) (numerator i)) ≤ B) + (f : Form α K) : + realPolynomialMass (map (Int.castRingHom ℝ) (scaledFrameForm root difference a numerator f)) ≤ + integerFormMassBound (Fintype.card α) H D A B := by + have hcross : 0 ≤ (Fintype.card α : ℝ) * D * B := mul_nonneg (mul_nonneg (Nat.cast_nonneg _) hD) hB + have hax : realPolynomialMass (C (a : ℝ) * X (none : Option K)) ≤ A := by + exact (realPolynomialMass_C_mul_le _ _).trans (by simpa only [realPolynomialMass_X, mul_one] using ha) + have hbase (k : K) : realPolynomialMass (X (some k) - C (root k : ℝ) * X (none : Option K)) ≤ 1 + H := by + have hr : realPolynomialMass (C (root k : ℝ) * X (none : Option K)) ≤ H := by + exact (realPolynomialMass_C_mul_le _ _).trans (by simpa only [realPolynomialMass_X, mul_one] using hroot k) + exact (realPolynomialMass_sub_le _ _).trans (by rw [realPolynomialMass_X]; linarith) + cases f with + | coordinate v => + cases v with + | none => + simp only [scaledFrameForm, map_mul, map_C, map_X, Int.coe_castRingHom] + exact hax.trans (by unfold integerFormMassBound; nlinarith) + | some v => + cases v with + | inl i => + exact (hn i).trans (by unfold integerFormMassBound; nlinarith) + | inr k => + have hp : realPolynomialMass (C (a : ℝ) * (X (some k) - C (root k : ℝ) * X none)) ≤ A * (1 + H) := + (realPolynomialMass_C_mul_le _ _).trans + (mul_le_mul ha (hbase k) (realPolynomialMass_nonneg _) hA) + have hs : realPolynomialMass (∑ i, C (difference i k : ℝ) * map (Int.castRingHom ℝ) (numerator i)) ≤ + (Fintype.card α : ℝ) * (D * B) := by + apply (realPolynomialMass_sum_le _ _).trans + calc + _ ≤ ∑ _i : α, D * B := by + apply Finset.sum_le_sum + intro i _ + exact (realPolynomialMass_C_mul_le _ _).trans + (mul_le_mul (hdiff i k) (hn i) (realPolynomialMass_nonneg _) hD) + _ = _ := by simp + simp only [scaledFrameForm, map_sub, map_mul, map_sum, map_C, map_X, Int.coe_castRingHom] + apply (realPolynomialMass_sub_le _ _).trans + unfold integerFormMassBound + nlinarith + | difference i => + simp only [scaledFrameForm, map_sub, map_mul, map_C, map_X, Int.coe_castRingHom] + apply (realPolynomialMass_sub_le _ _).trans + have hi := hn i + unfold integerFormMassBound + nlinarith + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped Classical + +theorem exists_affine_vanishing_labels {α K R V : Type*} [Fintype α] [DecidableEq α] + [CommRing R] [AddCommGroup V] [Module R V] + (root : K → R) (difference : α → K → R) (q : α → MvPolynomial (Option K) R) + (hdual : ∀ i s, eval (affineSite root difference s) (q i) = if i ∈ s then 1 else 0) + (Λ : MvPolynomial (Option K) R →ₗ[R] V) (h : ℕ) + (hnonfactor : ¬ ∃ L : (Finset α → R) →ₗ[R] V, + ∀ P, P.IsHomogeneous h → Λ P = L (fun s => eval (affineSite root difference s) P)) : + ∃ l : List (Form α K), l.length = h ∧ + (∀ s, eval (affineSite root difference s) (frameProjection root difference q (formProduct l)) = 0) ∧ + Λ (frameProjection root difference q (formProduct l)) ≠ 0 := by + let E := frameProjection root difference q + let Λ' := Λ.comp E.toLinearMap + have hn : ¬ ∃ L : (Finset α → R) →ₗ[R] V, + ∀ P, P.IsHomogeneous h → Λ' P = L (siteEvaluation P) := by + rintro ⟨L, hL⟩ + apply hnonfactor + refine ⟨L, ?_⟩ + intro P hP + have he := hL (frameLift root difference P) (frameLift_homogeneous root difference hP) + change Λ (frameProjection root difference q (frameLift root difference P)) = _ at he + rw [frameProjection_lift, frameLift_siteEvaluation root difference q hdual] at he + exact he + obtain ⟨l, hl, hz, hΛ⟩ := exists_vanishing_product_of_nonfactor Λ' h hn + refine ⟨l, hl, ?_, hΛ⟩ + intro s + exact (frameProjection_eval root difference q hdual s (formProduct l)).trans (hz s) + +theorem exists_integer_vanishing_product {α K V : Type*} [Fintype α] [DecidableEq α] + [AddCommGroup V] [Module ℝ V] + (root : K → ℤ) (difference : α → K → ℤ) (a : ℤ) (ha : a ≠ 0) + (numerator : α → MvPolynomial (Option K) ℤ) + (hlinear : ∀ i, (numerator i).IsHomogeneous 1) + (hdual : ∀ i s, eval (affineSite root difference s) (numerator i) = if i ∈ s then a else 0) + (Λ : MvPolynomial (Option K) ℝ →ₗ[ℝ] V) (h : ℕ) + (hnonfactor : ¬ ∃ L : (Finset α → ℝ) →ₗ[ℝ] V, + ∀ P, P.IsHomogeneous h → Λ P = + L (fun s => eval (affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) P)) : + ∃ forms : List (MvPolynomial (Option K) ℤ), forms.length = h ∧ + (∀ P ∈ forms, P.IsHomogeneous 1 ∧ ∃ f : Form α K, P = scaledFrameForm root difference a numerator f) ∧ + (∀ s : Finset α, ∃ P ∈ forms, eval (affineSite root difference s) P = 0) ∧ + Λ (map (Int.castRingHom ℝ) forms.prod) ≠ 0 := by + let q := normalizedIntegerDual a numerator + obtain ⟨l, hl, hz, hΛ⟩ := exists_affine_vanishing_labels + (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) q + (normalizedIntegerDual_boolean root difference a ha numerator hdual) Λ h hnonfactor + have hm := scaledFrameProduct_map (Int.castRingHom ℝ) root difference a numerator q + (normalizedIntegerDual_clear a ha numerator) l + simp only [Int.coe_castRingHom] at hm + let forms := l.map (scaledFrameForm root difference a numerator) + have hzero (s : Finset α) : eval (affineSite root difference s) forms.prod = 0 := by + have he := affineSite_eval_map (Int.castRingHom ℝ) root difference s forms.prod + simp only [Int.coe_castRingHom] at he + have hc : ((eval (affineSite root difference s) forms.prod : ℤ) : ℝ) = 0 := by + rw [← he] + change eval _ (map (Int.castRingHom ℝ) ((l.map (scaledFrameForm root difference a numerator)).prod)) = 0 + rw [hm, map_mul, eval_C, hz, mul_zero] + exact_mod_cast hc + refine ⟨forms, ?_, ?_, ?_, ?_⟩ + · simpa only [forms, List.length_map] using hl + · intro P hP + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hP + exact ⟨scaledFrameForm_homogeneous root difference a numerator hlinear f, f, rfl⟩ + · intro s + have hp : (forms.map (fun P => eval (affineSite root difference s) P)).prod = 0 := by + simpa only [map_list_prod] using hzero s + exact List.mem_map.mp (List.prod_eq_zero_iff.mp hp) + · change Λ (map (Int.castRingHom ℝ) ((l.map (scaledFrameForm root difference a numerator)).prod)) ≠ 0 + rw [hm, ← smul_eq_C_mul, map_smul] + have ha' : (a : ℝ) ≠ 0 := by exact_mod_cast ha + exact smul_ne_zero (pow_ne_zero _ ha') hΛ + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped Classical + +theorem exists_bounded_integer_vanishing_product {α K V : Type*} [Fintype α] [DecidableEq α] + [AddCommGroup V] [Module ℝ V] + (root : K → ℤ) (difference : α → K → ℤ) (selection : α → K) + (hdet : (integerDifferencePivot difference selection).det ≠ 0) + {H D : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) + (hroot : ∀ k, |(root k : ℝ)| ≤ H) (hdiff : ∀ i k, |(difference i k : ℝ)| ≤ D) + (Λ : MvPolynomial (Option K) ℝ →ₗ[ℝ] V) (h : ℕ) + (hnonfactor : ¬ ∃ L : (Finset α → ℝ) →ₗ[ℝ] V, + ∀ P, P.IsHomogeneous h → Λ P = + L (fun s => eval (affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) P)) : + let A := ((Fintype.card α).factorial : ℝ) * D ^ Fintype.card α + let B := (Fintype.card α : ℝ) * + ((((Fintype.card α).factorial : ℝ) * D ^ (Fintype.card α - 1)) * (1 + H)) + ∃ forms : List (MvPolynomial (Option K) ℤ), forms.length = h ∧ + (∀ P ∈ forms, P.IsHomogeneous 1 ∧ + realPolynomialMass (map (Int.castRingHom ℝ) P) ≤ integerFormMassBound (Fintype.card α) H D A B) ∧ + (∀ s : Finset α, ∃ P ∈ forms, eval (affineSite root difference s) P = 0) ∧ + Λ (map (Int.castRingHom ℝ) forms.prod) ≠ 0 := by + intro A B + let a := (integerDifferencePivot difference selection).det + let numerator := integerPivotNumerator root difference selection + obtain ⟨forms, hlen, hforms, hz, hΛ⟩ := exists_integer_vanishing_product root difference a hdet numerator + (integerPivotNumerator_homogeneous root difference selection) + (integerPivotNumerator_eval root difference selection) Λ h hnonfactor + refine ⟨forms, hlen, ?_, hz, hΛ⟩ + intro P hP + obtain ⟨hhom, f, rfl⟩ := hforms P hP + refine ⟨hhom, scaledFrameForm_mass root difference a numerator hH hD + (show 0 ≤ A by dsimp [A]; positivity) (show 0 ≤ B by dsimp [B]; positivity) hroot hdiff ?_ ?_ f⟩ + · exact integerDifferencePivot_det_bound difference selection (fun i j => hdiff i (selection j)) + · intro i + exact integerPivotNumerator_mass root difference selection hD + (fun j => hroot (selection j)) (fun i j => hdiff i (selection j)) i + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/IntervalIntegerVectorAPFree.lean b/lean/OAI/Combinatorics/Progressions/Lattices/IntervalIntegerVectorAPFree.lean new file mode 100644 index 0000000000000000000000000000000000000000..29c8660b9d756f0838215d1e1a314ff7a705471a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/IntervalIntegerVectorAPFree.lean @@ -0,0 +1,118 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativePatchPositivePowerInduction +import OAI.Combinatorics.Progressions.Probability.RelativeSourceDensityParameter + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem APFree.integer_nonnegative_pullback {A : Set ℕ} {k : ℕ} + (hA : APFree A k) (hk : 0 < k) : + IntegerVectorAPFree {x : Unit → ℤ | 0 ≤ x () ∧ (x ()).toNat ∈ A} k := by + classical + intro a d hd + by_contra h + have hall (i : ℕ) (hi : i < k) : + 0 ≤ a () + (i : ℤ) * d () ∧ (a () + (i : ℤ) * d ()).toNat ∈ A := by + have hp : a + (i : ℤ) • d ∈ {x : Unit → ℤ | 0 ≤ x () ∧ (x ()).toNat ∈ A} := by + by_contra hn + exact h ⟨⟨i, hi⟩, hn⟩ + simpa only [Set.mem_ofPred_eq, Pi.add_apply, Pi.smul_apply, smul_eq_mul] using hp + have hd0 : d () ≠ 0 := by + intro he + apply hd + funext j + cases j + exact he + apply hA + rcases lt_or_gt_of_ne hd0 with hdneg | hdpos + · let b := a () + ((k - 1 : ℕ) : ℤ) * d () + have hb : 0 ≤ b := (hall (k - 1) (by omega)).1 + refine ⟨b.toNat, (-d ()).toNat, by omega, ?_⟩ + intro i hi + have hj : k - 1 - i < k := by omega + have he : (b.toNat + i * (-d ()).toNat : ℕ) = + (a () + ((k - 1 - i : ℕ) : ℤ) * d ()).toNat := by + have hindex : ((k - 1 - i : ℕ) : ℤ) + (i : ℤ) = ((k - 1 : ℕ) : ℤ) := by omega + have hecast : ((b.toNat + i * (-d ()).toNat : ℕ) : ℤ) = + a () + ((k - 1 - i : ℕ) : ℤ) * d () := by + push_cast + rw [Int.toNat_of_nonneg hb, Int.toNat_of_nonneg (by omega : 0 ≤ -d ())] + dsimp only [b] + nlinarith [hindex] + simpa only [Int.toNat_natCast] using congrArg Int.toNat hecast + rw [he] + exact (hall _ hj).2 + · have ha : 0 ≤ a () := by simpa using (hall 0 hk).1 + refine ⟨(a ()).toNat, (d ()).toNat, by omega, ?_⟩ + intro i hi + have he : (a ()).toNat + i * (d ()).toNat = (a () + (i : ℤ) * d ()).toNat := by + have hecast : (((a ()).toNat + i * (d ()).toNat : ℕ) : ℤ) = + a () + (i : ℤ) * d () := by + push_cast + rw [Int.toNat_of_nonneg ha, Int.toNat_of_nonneg hdpos.le] + simpa only [Int.toNat_natCast] using congrArg Int.toNat hecast + rw [he] + exact (hall i hi).2 + +theorem integerBox_unit_expect (N : ℕ) (f : (Unit → ℤ) → ℝ) : + (𝔼 x ∈ integerBox (fun _ : Unit => N), f x) = + 𝔼 n : Fin N, f (fun _ => (n.val : ℤ)) := by + classical + symm + apply Finset.expect_bij (fun (n : Fin N) _ (_ : Unit) => (n.val : ℤ)) + · intro n _ + exact (mem_integerBox _ _).mpr (fun _ => ⟨Int.natCast_nonneg _, by exact_mod_cast n.isLt⟩) + · intro n _ + rfl + · intro n _ m _ he + apply Fin.ext + exact_mod_cast congrFun he () + · intro x hx + have hx' := (mem_integerBox _ _).mp hx () + refine ⟨⟨(x ()).toNat, by omega⟩, Finset.mem_univ _, ?_⟩ + funext j + cases j + exact Int.toNat_of_nonneg hx'.1 + +namespace APFreeInterval + +noncomputable def integerIndicator {k : ℕ} (S : APFreeInterval k) (x : Unit → ℤ) : ℝ := + intervalIndicator S.points (x ()).toNat + +@[simp] theorem integerIndicator_nat {k : ℕ} (S : APFreeInterval k) (n : ℕ) : + S.integerIndicator (fun _ => (n : ℤ)) = intervalIndicator S.points n := by + simp [integerIndicator] + +theorem integerIndicator_mem_Icc {k : ℕ} (S : APFreeInterval k) (x : Unit → ℤ) : + S.integerIndicator x ∈ Set.Icc (0 : ℝ) 1 := + intervalIndicator_mem_Icc _ _ + +theorem integerIndicator_mean {k : ℕ} (S : APFreeInterval k) : + (𝔼 x ∈ integerBox (fun _ : Unit => S.length), S.integerIndicator x) = S.density := by + rw [integerBox_unit_expect] + simp only [integerIndicator_nat] + exact mean_intervalIndicator S.subset + +theorem integerIndicator_apFree {k : ℕ} (S : APFreeInterval k) (hk : 0 < k) : + IntegerVectorAPFree {x | x ∈ integerBox (fun _ : Unit => S.length) ∧ + S.integerIndicator x ≠ 0} k := by + intro a d hd + obtain ⟨i, hi⟩ := S.free.integer_nonnegative_pullback hk a d hd + refine ⟨i, ?_⟩ + rintro ⟨hbox, hnonzero⟩ + apply hi + refine ⟨((mem_integerBox _ _).mp hbox ()).1, ?_⟩ + by_contra hmem + exact hnonzero (ite_eq_right hmem) + +end APFreeInterval + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineBooleanSource.lean b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineBooleanSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..0764bd35c9c75d83aa396f1e4d76e86593c91a88 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineBooleanSource.lean @@ -0,0 +1,695 @@ +import OAI.Combinatorics.Progressions.Estimates.DiagonalSliceBounds +import OAI.Combinatorics.Progressions.Lattices.AffineBooleanCubeComparison + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff BigOperators + +variable {D α : Type*} [Fintype D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] {h : D → ℕ} + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (block : ∀ d, O d → B d) + (v : ∀ d, Fin (h d)) (sel : ∀ d, O d → Option α) + (L : ∀ d, (BlockParameter (B d) (Fin (h d)) α → ℝ) →L[ℝ] + (BlockParameter (B d) (Fin (h d)) α → ℝ)) + (b : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (ψ : ℝ → ℝ) (r : ∀ d, B d × Fin (h d) → ℝ) (κ : D → ℝ) + +noncomputable def jointAffineBooleanGoodWeight : (JointBlockParameter B h α → ℝ) → ℝ := + sigmaAxisWeight (fun d => affineBooleanCubeGoodWeight (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d)) + +noncomputable def jointAffineBooleanCutoff : (JointBlockParameter B h α → ℝ) → ℝ := + sigmaAxisWeight (fun d => affineBooleanCubeCutoff (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d)) + +theorem jointAffineBooleanCutoff_contDiff (hψ : ContDiff ℝ ∞ ψ) : + ContDiff ℝ 1 (jointAffineBooleanCutoff c sets block v sel L b ψ r κ) := + sigmaAxisWeight_contDiff _ (fun d => + (affineBooleanCubeCutoff_contDiff (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) hψ).of_le + (by norm_num)) + +theorem jointAffineBooleanCutoff_range (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (x : JointBlockParameter B h α → ℝ) : + jointAffineBooleanCutoff c sets block v sel L b ψ r κ x ∈ Set.Icc (0 : ℝ) 1 := + product_cutoff_range _ (fun d => affineBooleanCubeCutoff_range (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) hrange _) + +theorem jointAffineBooleanGoodWeight_spec + (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hr : ∀ d i, 0 < r d i) (hκ : ∀ d, 0 < κ d) : + let w := jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ + ContDiff ℝ 1 w ∧ HasCompactSupport w ∧ (∀ x, 0 ≤ w x) ∧ (∫ x, |w x|) ≤ 1 ∧ + ∀ x ∈ tsupport w, (∀ s, |x s| ≤ 1) ∧ ∀ d, κ d ≤ + |booleanMinorDeterminant (c d) (sets d) (block d) (v d) (sel d) + (b d + L d (fun i => x ⟨d, i⟩))| := by + have hs (d) := affineBooleanCubeGoodWeight_spec (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + hψ hrange hzero (hr d) (fun _ => hκ d) + refine ⟨sigmaAxisWeight_contDiff _ (fun d => (hs d).1), + sigmaAxisWeight_compact _ (fun d => (hs d).2.1), + sigmaAxisWeight_nonneg _ (fun d => (hs d).2.2.1), + sigmaAxisWeight_abs_mass_le_one _ (fun d => (hs d).2.2.2.1), ?_⟩ + intro x hx + have hp (d) := (hs d).2.2.2.2 _ (sigmaAxisWeight_tsupport _ hx d) + exact ⟨fun s => (hp s.1).1 s.2, fun d => (hp d).2 ()⟩ + +theorem jointAffineBooleanGoodWeight_measure + (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hr : ∀ d i, 0 < r d i) (hκ : ∀ d, 0 < κ d) : + realDensityMeasure volume (jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ) = + realDensityMeasure (jointBooleanSource h) (jointAffineBooleanCutoff c sets block v sel L b ψ r κ) := by + let w := fun d => affineBooleanCubeGoodWeight (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + let χ := fun d => affineBooleanCubeCutoff (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + have hw (d) := affineBooleanCubeGoodWeight_spec (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + hψ hrange hzero (hr d) (fun _ => hκ d) + have hm (d) : Measurable (χ d) := (affineBooleanCubeCutoff_contDiff (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) hψ).continuous.measurable + have h01 (d) := affineBooleanCubeCutoff_range (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) hrange + change realDensityMeasure volume (sigmaAxisWeight w) = + realDensityMeasure (sigmaAxisMeasure _) (sigmaAxisWeight χ) + rw [← sigmaAxisMeasure_density w (fun d => + (hw d).1.continuous.integrable_of_hasCompactSupport (hw d).2.1) (fun d => (hw d).2.2.1)] + have hlaw (d) : realDensityMeasure volume (w d) = + realDensityMeasure (blockCubeMeasure (B d) (Fin (h d)) α) (χ d) := + affineBooleanCubeGoodWeight_measure (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + hψ hrange hzero (hr d) (fun _ => hκ d) + simp_rw [hlaw] + exact sigmaAxisMeasure_withDensity _ χ (fun d => cutoff_integrable _ _ (hm d) (h01 d)) + (fun d x => (h01 d x).1) + +theorem jointAffineBooleanGoodWeight_mass_lower + (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (hr : ∀ d i, 0 < r d i) (hκ : ∀ d, 0 < κ d) : + 1 - ∑ d, (scalarCubeBoundaryConstant α * ∑ i, r d i + + (blockCubeMeasure (B d) (Fin (h d)) α).real + {a | |booleanMinorDeterminant (c d) (sets d) (block d) (v d) (sel d) (b d + L d a)| < 2 * κ d}) ≤ + ∫ x, jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ x := by + let w := fun d => affineBooleanCubeGoodWeight (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + have hs (d) := affineBooleanCubeGoodWeight_spec (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + hψ hrange hzero (hr d) (fun _ => hκ d) + have hm (d) : (∫ y, w d y) ≤ 1 := by + have he : (fun y => |w d y|) = w d := funext (fun y => abs_of_nonneg ((hs d).2.2.1 y)) + have hm := (hs d).2.2.2.1 + change (∫ y, |w d y|) ≤ 1 at hm + rw [he] at hm + exact hm + apply sigmaAxisWeight_mass_loss w (fun d => (hs d).2.2.1) hm + intro d + have hd := affineBooleanCubeGoodWeight_mass_lower (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + hψ hrange hone (hr d) (fun _ => hκ d) + simpa only [Fintype.sum_unique, sub_add_eq_sub_sub] using hd + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators ContDiff + +variable {D α : Type*} [Fintype D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] + +theorem exists_joint_affine_boolean_good_mass + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (N : D → ℕ) (e : ∀ d, BlockParameter (O d) (Fin (h d)) α ≃ Fin (N d)) + (hN : ∀ d, 0 < N d) (degree : D → ℕ) (hdegree : ∀ d, 0 < degree d) + (hdeg : ∀ d, Fintype.card (O d) * (h d - 1) ≤ degree d) + (c₀ : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hc : ∀ d o, c₀ d ≤ |c d (block d o)|) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) : + ∃ sel : ∀ d, O d → Option α, ∀ (δ : ℝ) (η : D → ℝ), 0 < δ → (∀ d, 0 < η d) → + ∀ (center width : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (hw : ∀ d z, width d z ≠ 0), + (∀ d z, δ ≤ |restrictBlockParameters (block d) (width d) z|) → + (∀ d z, |restrictBlockParameters (block d) (center d) z| + + |restrictBlockParameters (block d) (width d) z| ≤ 1) → + 1 - ∑ d, η d ≤ ∫ x, jointAffineBooleanGoodWeight c sets block + (fun d => (⟨0, hh d⟩ : Fin (h d))) sel + (fun d => (coordinateScaleEquiv (width d) (hw d)).toContinuousLinearEquiv.toContinuousLinearMap) + center ψ (fun d _ => scalarCubeProductBoundaryRadius (B d × Fin (h d)) α (η d / 2)) + (fun d => affineCubeMinorThreshold Unit (O d) α (h d) (N d) (degree d) (c₀ d) δ (η d)) x := by + choose sel hs using fun d => exists_affine_cube_good_mass (fun _ : Unit => c d) (sets d) (hsets d) + (h d) (hh d) (hcard d) (fun _ => block d) (fun _ => hblock d) (e d) (hN d) + (degree d) (hdegree d) (hdeg d) (hc₀ d) (fun _ => hc d) ψ hψ hrange hone + refine ⟨fun d => sel d (), ?_⟩ + intro δ η hδ hη center width hw hwidth hbox + let κ := fun d => affineCubeMinorThreshold Unit (O d) α (h d) (N d) (degree d) (c₀ d) δ (η d) + let r := fun d (_ : B d × Fin (h d)) => scalarCubeProductBoundaryRadius (B d × Fin (h d)) α (η d / 2) + let w := fun d => affineBooleanCubeGoodWeight (fun _ : Unit => c d) (sets d) (fun _ => block d) + (⟨0, hh d⟩ : Fin (h d)) (fun _ => sel d ()) + (coordinateScaleEquiv (width d) (hw d)).toContinuousLinearEquiv.toContinuousLinearMap + (center d) ψ (r d) (fun _ => κ d) + have hspec (d) := affineBooleanCubeGoodWeight_spec (fun _ : Unit => c d) (sets d) (fun _ => block d) + (⟨0, hh d⟩ : Fin (h d)) (fun _ => sel d ()) + (coordinateScaleEquiv (width d) (hw d)).toContinuousLinearEquiv.toContinuousLinearMap + (center d) ψ (r d) (fun _ => κ d) hψ hrange hzero + (fun _ => scalarCubeProductBoundaryRadius_pos _ _ (half_pos (hη d))) + (fun _ => affineCubeMinorThreshold_pos Unit (O d) α (h d) (hN d) (degree d) (hc₀ d) hδ (hη d)) + have hu (d) : (∫ y, w d y) ≤ 1 := by + have he : (fun y => |w d y|) = w d := funext (fun y => abs_of_nonneg ((hspec d).2.2.1 y)) + have hu := (hspec d).2.2.2.1 + change (∫ y, |w d y|) ≤ 1 at hu + rw [he] at hu + exact hu + apply sigmaAxisWeight_mass_loss w (fun d => (hspec d).2.2.1) hu η + intro d + have he : (fun _ : Unit => sel d ()) = sel d := funext (fun j => by cases j; rfl) + change 1 - η d ≤ ∫ a, affineBooleanCubeGoodWeight _ _ _ _ (fun _ : Unit => sel d ()) _ _ _ _ _ a + rw [he] + exact hs d δ (η d) hδ (hη d) (center d) (width d) (hw d) (fun _ => hwidth d) (fun _ => hbox d) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff NNReal BigOperators + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] + +theorem jointAffineBooleanGoodWeight_derivative_budget {h : D → ℕ} + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (block : ∀ d, O d → B d) + (v : ∀ d, Fin (h d)) (sel : ∀ d, O d → Option α) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (L : ∀ d, (BlockParameter (B d) (Fin (h d)) α → ℝ) →L[ℝ] + (BlockParameter (B d) (Fin (h d)) α → ℝ)) + (b : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (hL : ∀ d, ‖L d‖ ≤ 1) + (hbox : ∀ d x, x ∈ scalarCubeProductDomain (B d × Fin (h d)) α → + ∀ z, |(b d + L d (blockCubeFlatten (B d) (Fin (h d)) α x)) z| ≤ 1) + (C : D → ℝ) (hC : ∀ d, 0 ≤ C d) (hc : ∀ d o, |c d (block d o)| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (r : ∀ d, B d × Fin (h d) → ℝ) (hr : ∀ d i, 0 < r d i) + (κ : D → ℝ) (hκ : ∀ d, 0 < κ d) : + (∑ s : JointBlockParameter B h α, ∫ x, + |fderiv ℝ (jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ) x (Pi.single s 1)|) ≤ + jointBooleanWeightBudget (O := O) (α := α) h C A T r κ := by + have hs (d) := affineBooleanCubeGoodWeight_spec (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (L d) (b d) ψ (r d) (fun _ => κ d) + hψ hrange hzero (hr d) (fun _ => hκ d) + apply (sigmaAxisWeight_derivative_sum_le _ (fun d => (hs d).1) + (fun d => (hs d).2.2.2.1)).trans + unfold jointBooleanWeightBudget + apply Finset.sum_le_sum + intro d _ + have hb := affineBooleanCubeGoodWeight_derivative_budget (fun _ : Unit => c d) (sets d) + (fun _ => block d) (v d) (fun _ => sel d) (hcard d) (L d) (b d) (hL d) (hbox d) + (fun _ => C d) (fun _ => hC d) (fun _ => hc d) ψ hψ hrange A T hLip hTransition + (r d) (hr d) (fun _ => κ d) (fun _ => hκ d) + simpa only [Fintype.sum_unique, BlockParameter, Fintype.card_prod, Fintype.card_option, + Nat.cast_mul, Nat.cast_add, Nat.cast_one, mul_assoc] using hb + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff NNReal BigOperators + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] {h : D → ℕ} + +theorem jointAffineBoolean_good_weight_comparison + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (block : ∀ d, O d → B d) + (hblock : ∀ d, Function.Injective (block d)) + (v : ∀ d, Fin (h d)) (sel : ∀ d, O d → Option α) (hcard : ∀ d o, (sets d o).card ≤ h d) + (L : ∀ d, (BlockParameter (B d) (Fin (h d)) α → ℝ) ≃L[ℝ] + (BlockParameter (B d) (Fin (h d)) α → ℝ)) + (b : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (δ : D → ℝ) (hδ : ∀ d, 0 < δ d) (hδone : ∀ d, δ d ≤ 1) + (hL : ∀ d, ‖(L d).toContinuousLinearMap‖ ≤ 1) + (hLinv : ∀ d, δ d * ‖(L d).symm.toContinuousLinearMap‖ ≤ 1) + (hbox : ∀ d x, (∀ z, |x z| ≤ 1) → ∀ z, |(b d + L d x) z| ≤ 1) + (C : D → ℝ) (hC : ∀ d, 0 ≤ C d) (hc : ∀ d o, |c d (block d o)| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (r : ∀ d, B d × Fin (h d) → ℝ) (hr : ∀ d i, 0 < r d i) + (κ : D → ℝ) (hκ : ∀ d, 0 < κ d) (K H₀ : ℝ≥0) + (hK : ∀ d, (δ d)⁻¹ * productMinorInverseBound (Fintype.card (O d)) (Fintype.card α) + (h d) (C d) 1 (κ d) ≤ K) + (hH : ∀ d, productMinorDerivativeBound (Fintype.card (BlockParameter (B d) (Fin (h d)) α)) + (Fintype.card (O d)) (Fintype.card α) (h d) (C d) 1 ≤ H₀) + (V : (JointBlockParameter B h α → ℝ) → ((Σ d, O d) → ℝ)) (hV : ContDiff ℝ 2 V) + {ε η : ℝ} (hε : 0 < ε) (hεone : ε ≤ 1) (hsmall : (K : ℝ) * ε ≤ 1 / 2) + (hmass : 1 - η ≤ ∫ x, jointAffineBooleanGoodWeight c sets block v sel + (fun d => (L d).toContinuousLinearMap) b ψ r κ x) + (herr : ∀ x, (∀ z, |x z| ≤ 1) → + ‖V x - jointAffineBooleanSampler c sets L b x‖ ≤ ε ∧ + ‖fderiv ℝ V x - fderiv ℝ (jointAffineBooleanSampler c sets L b) x‖ ≤ ε ∧ + ‖fderiv ℝ (fderiv ℝ V) x - fderiv ℝ (fderiv ℝ (jointAffineBooleanSampler c sets L b)) x‖ ≤ ε) + (φ : ((Σ d, O d) → ℝ) → ℝ) (hφ : Measurable φ) (hbound : ∀ y, ‖φ y‖ ≤ 1) : + let S := jointBooleanWeightBudget (O := O) (α := α) h C A T r κ + let Q := 1 + 2 * (K : ℝ) * S + + (Fintype.card (JointBlockParameter B h α) : ℝ) * ((2 * (K : ℝ)) ^ 2 * ((H₀ : ℝ) + 1)) + |mappedTest (jointBooleanSource h) (jointAffineBooleanSampler c sets L b) φ - + mappedTest (jointBooleanSource h) V φ| ≤ + 2 * η + 4 * (Fintype.card (Σ d, O d) : ℝ) * Real.sqrt (Q * ε) := by + let w := jointAffineBooleanGoodWeight c sets block v sel (fun d => (L d).toContinuousLinearMap) b ψ r κ + let χ := jointAffineBooleanCutoff c sets block v sel (fun d => (L d).toContinuousLinearMap) b ψ r κ + let U := jointAffineBooleanSampler c sets L b + let J := jointAffineBooleanInjection block v sel L δ + let S : ℝ≥0 := ⟨jointBooleanWeightBudget (O := O) (α := α) h C A T r κ, + jointBooleanWeightBudget_nonneg h C hC A T r (fun d i => (hr d i).le) κ (fun d => (hκ d).le)⟩ + have hU : ContDiff ℝ 2 U := (jointAffineBooleanSampler_contDiff c sets L b).of_le (by norm_num) + have hJ : ‖J‖ ≤ 1 := jointAffineBooleanInjection_norm_le block v sel L δ hblock + (fun d => (hδ d).le) hLinv + have hw := jointAffineBooleanGoodWeight_spec c sets block v sel (fun d => (L d).toContinuousLinearMap) + b ψ r κ hψ hrange hzero hr hκ + have hb (x) (hx : x ∈ tsupport w) : ∀ z, |x z| ≤ 1 := (hw.2.2.2.2 x hx).1 + have hbx (x) (hx : x ∈ tsupport w) (d) (z) : + |(b d + L d (fun i => x ⟨d, i⟩)) z| ≤ 1 := hbox d _ (fun i => hb x hx ⟨d, i⟩) z + have hi (x) (hx : x ∈ tsupport w) := jointAffineBoolean_selected_inverse_bound c sets block v sel L b δ + hcard x C κ hC hκ hδ hc (hbx x hx) ((hw.2.2.2.2 x hx).2) K.coe_nonneg hK + have hHU₀ (x) (hx : x ∈ tsupport w) : ‖fderiv ℝ (selectedDerivative U J) x‖ ≤ H₀ := + jointAffineBoolean_selected_derivative_bound c sets block v sel L b δ hcard x C hC + (fun d => (hδ d).le) hδone hL hc (hbx x hx) H₀.coe_nonneg hH + have hHU (x) (hx : x ∈ tsupport w) : ‖fderiv ℝ (selectedDerivative U J) x‖ ≤ (H₀ + 1 : ℝ≥0) := + (hHU₀ x hx).trans (by simp only [NNReal.coe_add, NNReal.coe_one]; linarith) + have hHV (x) (hx : x ∈ tsupport w) : ‖fderiv ℝ (selectedDerivative V J) x‖ ≤ (H₀ + 1 : ℝ≥0) := + (selectedDerivative_bound_of_second_error U V hU hV J hJ x (hHU₀ x hx) + (herr x (hb x hx)).2.2).trans (by exact add_le_add le_rfl hεone) + have ht := selected_cutoff_comparison_of_close_derivatives (jointBooleanSource h) χ w + (jointAffineBooleanCutoff_contDiff _ _ _ _ _ _ _ _ _ _ hψ).continuous.measurable + (jointAffineBooleanCutoff_range _ _ _ _ _ _ _ _ _ _ hrange) hw.1 hw.2.1 hw.2.2.1 + (jointAffineBooleanGoodWeight_measure _ _ _ _ _ _ _ _ _ _ hψ hrange hzero hr hκ) + U V hU hV J hJ K (H₀ + 1) S (fun x hx => (hi x hx).1) (fun x hx => (hi x hx).2) + (fun x hx => (mul_le_mul_of_nonneg_left (herr x (hb x hx)).2.1 K.coe_nonneg).trans hsmall) + hHU hHV (jointAffineBooleanGoodWeight_derivative_budget c sets block v sel hcard + (fun d => (L d).toContinuousLinearMap) b hL + (fun d x hx => hbox d _ (blockCubeFlatten_box hx)) C hC hc ψ hψ hrange hzero A T hLip hTransition r hr κ hκ) + hε hmass (fun x hx => by + rw [dist_comm, dist_eq_norm] + exact (herr x (hb x (subset_tsupport w hx))).1) φ hφ hbound + have hScoe : (S : ℝ) = jointBooleanWeightBudget (O := O) (α := α) h C A T r κ := rfl + simp only [NNReal.coe_add, NNReal.coe_one, hScoe] at ht + exact ht + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped ContDiff NNReal BigOperators + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] {h : D → ℕ} + +noncomputable def jointAffineBooleanTranslationBudget + (C : D → ℝ) (A T : ℝ≥0) (r : ∀ d, B d × Fin (h d) → ℝ) + (κ : D → ℝ) (K H : ℝ≥0) : ℝ≥0 := + (Fintype.card (Σ d, O d) : ℝ≥0) * + (K * Real.toNNReal (jointBooleanWeightBudget (O := O) (α := α) h C A T r κ) + + (Fintype.card (JointBlockParameter B h α) : ℝ≥0) * (K ^ 2 * H)) + +theorem jointAffineBoolean_translation_bound + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (block : ∀ d, O d → B d) + (hblock : ∀ d, Function.Injective (block d)) + (v : ∀ d, Fin (h d)) (sel : ∀ d, O d → Option α) (hcard : ∀ d o, (sets d o).card ≤ h d) + (L : ∀ d, (BlockParameter (B d) (Fin (h d)) α → ℝ) ≃L[ℝ] + (BlockParameter (B d) (Fin (h d)) α → ℝ)) + (b : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (δ : D → ℝ) (hδ : ∀ d, 0 < δ d) (hδone : ∀ d, δ d ≤ 1) + (hL : ∀ d, ‖(L d).toContinuousLinearMap‖ ≤ 1) + (hLinv : ∀ d, δ d * ‖(L d).symm.toContinuousLinearMap‖ ≤ 1) + (hbox : ∀ d x, (∀ z, |x z| ≤ 1) → ∀ z, |(b d + L d x) z| ≤ 1) + (C : D → ℝ) (hC : ∀ d, 0 ≤ C d) (hc : ∀ d o, |c d (block d o)| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (r : ∀ d, B d × Fin (h d) → ℝ) (hr : ∀ d i, 0 < r d i) + (κ : D → ℝ) (hκ : ∀ d, 0 < κ d) (K H : ℝ≥0) + (hK : ∀ d, (δ d)⁻¹ * productMinorInverseBound (Fintype.card (O d)) (Fintype.card α) + (h d) (C d) 1 (κ d) ≤ K) + (hH : ∀ d, productMinorDerivativeBound (Fintype.card (BlockParameter (B d) (Fin (h d)) α)) + (Fintype.card (O d)) (Fintype.card α) (h d) (C d) 1 ≤ H) + : ImageTranslationBound + (realDensityMeasure (jointBooleanSource h) + (jointAffineBooleanCutoff c sets block v sel (fun d => (L d).toContinuousLinearMap) b ψ r κ)) + (jointAffineBooleanSampler c sets L b) + (jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H) := by + let w := jointAffineBooleanGoodWeight c sets block v sel (fun d => (L d).toContinuousLinearMap) b ψ r κ + let U := jointAffineBooleanSampler c sets L b + let J := jointAffineBooleanInjection block v sel L δ + let S : ℝ≥0 := ⟨jointBooleanWeightBudget (O := O) (α := α) h C A T r κ, + jointBooleanWeightBudget_nonneg h C hC A T r (fun d i => (hr d i).le) κ (fun d => (hκ d).le)⟩ + have hU : ContDiff ℝ 2 U := (jointAffineBooleanSampler_contDiff c sets L b).of_le (by norm_num) + have hJ : ‖J‖ ≤ 1 := jointAffineBooleanInjection_norm_le block v sel L δ hblock + (fun d => (hδ d).le) hLinv + have hw := jointAffineBooleanGoodWeight_spec c sets block v sel (fun d => (L d).toContinuousLinearMap) + b ψ r κ hψ hrange hzero hr hκ + have hb (x) (hx : x ∈ tsupport w) : ∀ z, |x z| ≤ 1 := (hw.2.2.2.2 x hx).1 + have hbx (x) (hx : x ∈ tsupport w) (d) (z) : + |(b d + L d (fun i => x ⟨d, i⟩)) z| ≤ 1 := hbox d _ (fun i => hb x hx ⟨d, i⟩) z + have hi (x) (hx : x ∈ tsupport w) := jointAffineBoolean_selected_inverse_bound c sets block v sel L b δ + hcard x C κ hC hκ hδ hc (hbx x hx) ((hw.2.2.2.2 x hx).2) K.coe_nonneg hK + have hHU₀ (x) (hx : x ∈ tsupport w) : ‖fderiv ℝ (selectedDerivative U J) x‖ ≤ H := + jointAffineBoolean_selected_derivative_bound c sets block v sel L b δ hcard x C hC + (fun d => (hδ d).le) hδone hL hc (hbx x hx) H.coe_nonneg hH + have hS := jointAffineBooleanGoodWeight_derivative_budget c sets block v sel hcard + (fun d => (L d).toContinuousLinearMap) b hL + (fun d x hx => hbox d _ (blockCubeFlatten_box hx)) C hC hc ψ hψ hrange hzero + A T hLip hTransition r hr κ hκ + let Q : ℝ≥0 := K * S + (Fintype.card (JointBlockParameter B h α) : ℝ≥0) * (K ^ 2 * H) + have ht := imageTranslationBound_of_inverse_budget U hU J hJ w hw.1 hw.2.1 hw.2.2.1 + hw.2.2.2.1 K H S Q (fun x hx => (hi x hx).1) (fun x hx => (hi x hx).2) + hHU₀ hS (by simp only [Q, NNReal.coe_add, NNReal.coe_mul, NNReal.coe_natCast, NNReal.coe_pow]; exact le_rfl) + have hSdef : S = Real.toNNReal (jointBooleanWeightBudget (O := O) (α := α) h C A T r κ) := by + ext + exact (Real.coe_toNNReal _ S.coe_nonneg).symm + rw [jointAffineBooleanGoodWeight_measure c sets block v sel + (fun d => (L d).toContinuousLinearMap) b ψ r κ hψ hrange hzero hr hκ] at ht + simpa only [Q, hSdef, jointAffineBooleanTranslationBudget] using ht + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators ContDiff NNReal + +noncomputable def canonicalAffineCubeMinorThreshold (O α : Type*) [Fintype O] [Fintype α] + [DecidableEq α] (h : ℕ) (c₀ δ η : ℝ) : ℝ := + affineCubeMinorThreshold Unit O α h (cubeMinorVariableCount O α h) (cubeMinorDegree O h) c₀ δ η + +theorem canonicalAffineCubeMinorThreshold_pos (O α : Type*) [Fintype O] [Nonempty O] + [Fintype α] [DecidableEq α] {h : ℕ} (hh : 0 < h) {c₀ δ η : ℝ} + (hc₀ : 0 < c₀) (hδ : 0 < δ) (hη : 0 < η) : + 0 < canonicalAffineCubeMinorThreshold O α h c₀ δ η := + affineCubeMinorThreshold_pos Unit O α h (boolean_minor_parameter_count_pos O α hh) _ hc₀ hδ hη + +variable {D α : Type*} [Fintype D] [Fintype α] [decidableEqAlpha : DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + +noncomputable def jointAffineBooleanInverseBudget (h : D → ℕ) (C κ : D → ℝ) (δ : ℝ) : ℝ≥0 := + ∑ d, Real.toNNReal (δ⁻¹ * productMinorInverseBound (Fintype.card (O d)) (Fintype.card α) + (h d) (C d) 1 (κ d)) + +omit decidableEqAlpha in +theorem jointAffineBooleanInverseBudget_le [DecidableEq α] + (h : D → ℕ) (C κ : D → ℝ) (δ : ℝ) (d : D) : + δ⁻¹ * productMinorInverseBound (Fintype.card (O d)) (Fintype.card α) (h d) (C d) 1 (κ d) ≤ + jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ := by + classical + apply (Real.le_coe_toNNReal _).trans + exact_mod_cast Finset.single_le_sum (f := fun e => Real.toNNReal + (δ⁻¹ * productMinorInverseBound (Fintype.card (O e)) (Fintype.card α) (h e) (C e) 1 (κ e))) + (fun _ _ => zero_le) (Finset.mem_univ d) + +noncomputable def jointAffineBooleanErrorBudget (h : D → ℕ) (C κ : D → ℝ) (A T : ℝ≥0) + (r : ∀ d, B d × Fin (h d) → ℝ) (δ : ℝ) : ℝ := + let K := jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ + let H := jointBooleanDerivativeBudget (B := B) (O := O) (α := α) h C + 1 + 2 * (K : ℝ) * jointBooleanWeightBudget (O := O) (α := α) h C A T r κ + + (Fintype.card (JointBlockParameter B h α) : ℝ) * ((2 * (K : ℝ)) ^ 2 * ((H : ℝ) + 1)) + +theorem exists_canonical_joint_affine_good_mass + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hc : ∀ d o, c₀ d ≤ |c d (block d o)|) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) : + ∃ sel : ∀ d, O d → Option α, ∀ (δ : ℝ) (η : D → ℝ), 0 < δ → (∀ d, 0 < η d) → + ∀ (center width : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (hw : ∀ d z, width d z ≠ 0), + (∀ d z, δ ≤ |width d z|) → (∀ d z, |center d z| + |width d z| ≤ 1) → + 1 - ∑ d, η d ≤ ∫ x, jointAffineBooleanGoodWeight c sets block + (fun d => (⟨0, hh d⟩ : Fin (h d))) sel + (fun d => (coordinateScaleEquiv (width d) (hw d)).toContinuousLinearEquiv.toContinuousLinearMap) + center ψ (fun d _ => scalarCubeProductBoundaryRadius (B d × Fin (h d)) α (η d / 2)) + (fun d => canonicalAffineCubeMinorThreshold (O d) α (h d) (c₀ d) δ (η d)) x := by + obtain ⟨sel, hs⟩ := exists_joint_affine_boolean_good_mass h hh c sets hsets hcard block hblock + (fun d => cubeMinorVariableCount (O d) α (h d)) (fun d => booleanBlockParameterEquiv (O d) α (h d)) + (fun d => boolean_minor_parameter_count_pos (O d) α (hh d)) + (fun d => cubeMinorDegree (O d) (h d)) (fun _ => lt_of_lt_of_le Nat.zero_lt_one (le_max_left _ _)) + (fun _ => le_max_right _ _) c₀ hc₀ hc ψ hψ hrange hzero hone + refine ⟨sel, ?_⟩ + intro δ η hδ hη center width hw hwidth hbox + exact hs δ η hδ hη center width hw + (fun d z => hwidth d ((block d z.1, z.2.1, z.2.2))) + (fun d z => hbox d ((block d z.1, z.2.1, z.2.2))) + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped ContDiff NNReal BigOperators + +theorem jointAffineBooleanCutoff_loss {D α : Type*} + [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] {h : D → ℕ} + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (block : ∀ d, O d → B d) + (v : ∀ d, Fin (h d)) (sel : ∀ d, O d → Option α) + (L : ∀ d, (BlockParameter (B d) (Fin (h d)) α → ℝ) →L[ℝ] + (BlockParameter (B d) (Fin (h d)) α → ℝ)) + (b : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) + (r : ∀ d, B d × Fin (h d) → ℝ) (hr : ∀ d i, 0 < r d i) + (κ : D → ℝ) (hκ : ∀ d, 0 < κ d) {η : ℝ} + (hmass : 1-η ≤ ∫ x, jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ x) : + (∫ x, 1-jointAffineBooleanCutoff c sets block v sel L b ψ r κ x ∂jointBooleanSource h) ≤ η := by + let : IsProbabilityMeasure (jointBooleanSource (B := B) (α := α) h) := jointBooleanSource_probability h + have hs := jointAffineBooleanGoodWeight_spec c sets block v sel L b ψ r κ hψ hrange hzero hr hκ + have hwi : Integrable (jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ) := + hs.1.continuous.integrable_of_hasCompactSupport hs.2.1 + have hw0 : ∀ x, 0 ≤ jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ x := hs.2.2.1 + have hχ : Measurable (jointAffineBooleanCutoff c sets block v sel L b ψ r κ) := + (jointAffineBooleanCutoff_contDiff c sets block v sel L b ψ r κ hψ).continuous.measurable + have hχ01 : ∀ x, jointAffineBooleanCutoff c sets block v sel L b ψ r κ x ∈ Set.Icc (0 : ℝ) 1 := + jointAffineBooleanCutoff_range c sets block v sel L b ψ r κ hrange + have hlaw : realDensityMeasure volume (jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ) = + realDensityMeasure (jointBooleanSource (B := B) (α := α) h) (jointAffineBooleanCutoff c sets block v sel L b ψ r κ) := + jointAffineBooleanGoodWeight_measure c sets block v sel L b ψ r κ hψ hrange hzero hr hκ + exact cutoff_loss_of_density_mass (X := JointBlockParameter B h α → ℝ) + (jointBooleanSource (B := B) (α := α) h) volume + (jointAffineBooleanCutoff c sets block v sel L b ψ r κ) (jointAffineBooleanGoodWeight c sets block v sel L b ψ r κ) + hχ hχ01 hwi hw0 hlaw hmass + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] {h : D → ℕ} + +theorem jointAffineBoolean_regularization_error + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (block : ∀ d, O d → B d) + (hblock : ∀ d, Function.Injective (block d)) + (v : ∀ d, Fin (h d)) (sel : ∀ d, O d → Option α) (hcard : ∀ d o, (sets d o).card ≤ h d) + (L : ∀ d, (BlockParameter (B d) (Fin (h d)) α → ℝ) ≃L[ℝ] + (BlockParameter (B d) (Fin (h d)) α → ℝ)) + (b : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (δ : D → ℝ) (hδ : ∀ d, 0 < δ d) (hδone : ∀ d, δ d ≤ 1) + (hL : ∀ d, ‖(L d).toContinuousLinearMap‖ ≤ 1) + (hLinv : ∀ d, δ d * ‖(L d).symm.toContinuousLinearMap‖ ≤ 1) + (hbox : ∀ d x, (∀ z, |x z| ≤ 1) → ∀ z, |(b d + L d x) z| ≤ 1) + (C : D → ℝ) (hC : ∀ d, 0 ≤ C d) (hc : ∀ d o, |c d (block d o)| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (r : ∀ d, B d × Fin (h d) → ℝ) (hr : ∀ d i, 0 < r d i) + (κ : D → ℝ) (hκ : ∀ d, 0 < κ d) (K H : ℝ≥0) + (hK : ∀ d, (δ d)⁻¹ * productMinorInverseBound (Fintype.card (O d)) (Fintype.card α) + (h d) (C d) 1 (κ d) ≤ K) + (hH : ∀ d, productMinorDerivativeBound (Fintype.card (BlockParameter (B d) (Fin (h d)) α)) + (Fintype.card (O d)) (Fintype.card α) (h d) (C d) 1 ≤ H) + {η : ℝ} + (hmass : 1 - η ≤ ∫ x, jointAffineBooleanGoodWeight c sets block v sel + (fun d => (L d).toContinuousLinearMap) b ψ r κ x) + (ρ : ℝ≥0) (hρ : 0 < ρ) (φ : ((Σ d, O d) → ℝ) → ℝ) + (hφ : Measurable φ) (hbound : ∀ x, ‖φ x‖ ≤ 1) : + |(∫ x, regularizedImageDensity (jointBooleanSource h) + (jointAffineBooleanSampler c sets L b) ρ x * φ x) - + mappedTest (jointBooleanSource h) (jointAffineBooleanSampler c sets L b) φ| ≤ + 2 * η + jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H * ρ := by + have htrans := jointAffineBoolean_translation_bound c sets block hblock v sel hcard L b δ + hδ hδone hL hLinv hbox C hC hc ψ hψ hrange hzero A T hLip hTransition r hr κ hκ K H hK hH + have hcut := jointAffineBooleanCutoff_loss c sets block v sel (fun d => (L d).toContinuousLinearMap) + b ψ hψ hrange hzero r hr κ hκ hmass + exact regularizedImageDensity_cutoff_error (jointBooleanSource h) + (jointAffineBooleanCutoff c sets block v sel (fun d => (L d).toContinuousLinearMap) b ψ r κ) + (jointAffineBooleanCutoff_contDiff _ _ _ _ _ _ _ _ _ _ hψ).continuous.measurable + (jointAffineBooleanCutoff_range _ _ _ _ _ _ _ _ _ _ hrange) + (jointAffineBooleanSampler c sets L b) (jointAffineBooleanSampler_contDiff c sets L b).continuous.measurable + (jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H) htrans hcut ρ hρ φ hφ hbound + +end Erdos3 + +end + +section + +namespace Erdos3 + + theorem affineCubeMinorThreshold_log_inv_relative (J O α : Type*) [Fintype J] [Fintype O] + [Fintype α] [DecidableEq α] (h : ℕ) {N : ℕ} (hN : 0 < N) (d : ℕ) + {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + Real.log (affineCubeMinorThreshold J O α h N d c₀ δ η)⁻¹ ≤ + Real.log (affineCubeMinorThreshold J O α h N d c₀ 1 η)⁻¹ + + (N * d : ℕ) * (N : ℝ) * Real.log δ⁻¹ := by + have he := affineCubeMinorThreshold_log_inv_slice_bound J O α h hN d hc₀ hδ hδone hη + have hb := affineCubeMinorThreshold_log_inv J O α h hN d hc₀ zero_lt_one hη + simp only [inv_one, one_pow, mul_one] at hb + rw [hb] + calc + _ ≤ _ := he + _ = _ := by ring + + theorem canonicalAffineCubeMinorThreshold_log_inv_relative (O α : Type*) [Fintype O] + [Nonempty O] [Fintype α] [DecidableEq α] {h : ℕ} (hh : 0 < h) + {c₀ δ η : ℝ} (hc₀ : 0 < c₀) (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) : + Real.log (canonicalAffineCubeMinorThreshold O α h c₀ δ η)⁻¹ ≤ + Real.log (canonicalAffineCubeMinorThreshold O α h c₀ 1 η)⁻¹ + + (cubeMinorVariableCount O α h * cubeMinorDegree O h : ℕ) * + (cubeMinorVariableCount O α h : ℝ) * Real.log δ⁻¹ := + affineCubeMinorThreshold_log_inv_relative Unit O α h + (boolean_minor_parameter_count_pos O α hh) (cubeMinorDegree O h) hc₀ hδ hδone hη + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators ContDiff NNReal + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + +theorem jointAffineBoolean_source_density_comparison + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (c : ∀ d, B d → ℝ) (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (block d o)|) (hcup : ∀ d o, |c d (block d o)| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (δ : ℝ) (hδ : 0 < δ) (hδone : δ ≤ 1) (η : D → ℝ) (hη : ∀ d, 0 < η d) + (center width : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (hw : ∀ d z, width d z ≠ 0) (hwidth : ∀ d z, δ ≤ |width d z|) + (hbox : ∀ d z, |center d z| + |width d z| ≤ 1) + (ρ : ℝ≥0) (hρ : 0 < ρ) : + let L := fun d => (coordinateScaleEquiv (width d) (hw d)).toContinuousLinearEquiv + let slice := fun x : JointBlockParameter B h α → ℝ => + (fun s => center s.1 s.2) + sigmaAxisOperator (fun d => (L d).toContinuousLinearMap) x + let U := jointAffineBooleanSampler c sets L center + let f := regularizedImageDensity (jointBooleanSource h) U ρ + let r := fun d (_ : B d × Fin (h d)) => scalarCubeProductBoundaryRadius (B d × Fin (h d)) α (η d / 2) + let κ := fun d => canonicalAffineCubeMinorThreshold (O d) α (h d) (c₀ d) δ (η d) + let K := jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ + let H := jointBooleanDerivativeBudget (B := B) (O := O) (α := α) h C + (∀ x, f x ∈ Set.Icc (0 : ℝ) (ρ⁻¹ ^ Fintype.card (Σ d, O d) : ℝ≥0)) ∧ + Integrable f ∧ (∫ x, f x) = 1 ∧ LipschitzWith (affineProductProfileLip (Σ d, O d) ρ) f ∧ + ∀ (V : (JointBlockParameter B h α → ℝ) → ((Σ d, O d) → ℝ)), ContDiff ℝ 2 V → + ∀ ε : ℝ, 0 < ε → ε ≤ 1 → (K : ℝ) * ε ≤ 1 / 2 → + (∀ x, (∀ z, |x z| ≤ 1) → + ‖V x - jointBooleanSampler h c sets x‖ ≤ ε ∧ + ‖fderiv ℝ V x - fderiv ℝ (jointBooleanSampler h c sets) x‖ ≤ ε ∧ + ‖fderiv ℝ (fderiv ℝ V) x - fderiv ℝ (fderiv ℝ (jointBooleanSampler h c sets)) x‖ ≤ ε) → + ∀ φ : ((Σ d, O d) → ℝ) → ℝ, Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + |(∫ y, f y * φ y) - mappedTest (jointBooleanSource h) (V ∘ slice) φ| ≤ + 4 * (∑ d, η d) + jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H * ρ + + 4 * (Fintype.card (Σ d, O d) : ℝ) * + Real.sqrt (jointAffineBooleanErrorBudget (O := O) (α := α) h C κ A T r δ * ε) := by + intro L slice U f r κ K H + let : IsProbabilityMeasure (jointBooleanSource (B := B) (α := α) h) := jointBooleanSource_probability h + have hUm : Measurable U := (jointAffineBooleanSampler_contDiff c sets L center).continuous.measurable + have hp := regularizedImageDensity_probability (jointBooleanSource h) U hUm ρ hρ + have hb := regularizedImageDensity_bounds (jointBooleanSource h) U hUm ρ hρ + refine ⟨hb.1, hp.2.1, hp.2.2, hb.2, ?_⟩ + intro V hV ε hε hεone hsmall herr φ hφ hbound + obtain ⟨sel, hs⟩ := exists_canonical_joint_affine_good_mass h hh c sets hsets hcard block hblock + c₀ hc₀ hclow ψ hψ hrange hzero hone + have hmass := hs δ η hδ hη center width hw hwidth hbox + have hr (d) (i : B d × Fin (h d)) : 0 < r d i := + scalarCubeProductBoundaryRadius_pos _ _ (half_pos (hη d)) + have hκ (d) : 0 < κ d := canonicalAffineCubeMinorThreshold_pos (O d) α (hh d) (hc₀ d) hδ (hη d) + have hL (d) : ‖(L d).toContinuousLinearMap‖ ≤ 1 := + coordinateScaleEquiv_norm_le (width d) (hw d) zero_le_one + (fun z => (le_add_of_nonneg_left (abs_nonneg (center d z))).trans (hbox d z)) + have hLinv (d) : δ * ‖(L d).symm.toContinuousLinearMap‖ ≤ 1 := + coordinateScaleEquiv_scaled_inverse_norm_le (width d) (hw d) hδ (hwidth d) + have hbx (d) (x : BlockParameter (B d) (Fin (h d)) α → ℝ) (hx : ∀ z, |x z| ≤ 1) : + ∀ z, |(center d + L d x) z| ≤ 1 := coordinateScaleEquiv_affine_box _ _ _ (hbox d) x hx + have hK := jointAffineBooleanInverseBudget_le (O := O) (α := α) h C κ δ + have hH := jointBooleanDerivativeBudget_le (B := B) (O := O) (α := α) h C + have hreg := jointAffineBoolean_regularization_error c sets block hblock + (fun d => ⟨0, hh d⟩) sel hcard L center (fun _ => δ) (fun _ => hδ) (fun _ => hδone) + hL hLinv hbx C hC hcup ψ hψ hrange hzero A T hLip hTransition r hr κ hκ K H hK hH + hmass ρ hρ φ hφ hbound + have hsmooth : ContDiff ℝ 2 (V ∘ slice) := hV.comp + (contDiff_const.add (sigmaAxisOperator (fun d => (L d).toContinuousLinearMap)).contDiff) + have he := jointAffineBoolean_c2_error_transport c sets L center hL hbx V hV herr + have hcomp := jointAffineBoolean_good_weight_comparison c sets block hblock + (fun d => ⟨0, hh d⟩) sel hcard L center (fun _ => δ) (fun _ => hδ) (fun _ => hδone) + hL hLinv hbx C hC hcup ψ hψ hrange hzero A T hLip hTransition r hr κ hκ K H hK hH + (V ∘ slice) hsmooth hε hεone hsmall hmass he φ hφ hbound + calc + _ ≤ |(∫ y, f y * φ y) - mappedTest (jointBooleanSource h) U φ| + + |mappedTest (jointBooleanSource h) U φ - mappedTest (jointBooleanSource h) (V ∘ slice) φ| := + abs_sub_le _ _ _ + _ ≤ _ := by + have ht := add_le_add hreg hcomp + dsimp only [jointAffineBooleanErrorBudget] + linarith only [ht] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineBooleanTolerance.lean b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineBooleanTolerance.lean new file mode 100644 index 0000000000000000000000000000000000000000..3de5dcc5224b7823601ba31d6ac2395cdef9d3f7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineBooleanTolerance.lean @@ -0,0 +1,176 @@ +import OAI.Combinatorics.Progressions.Lattices.JointAffineBooleanSource + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators NNReal + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] + +noncomputable def jointAffineSourceBoundaryRadius (h : D → ℕ) (E : ℝ) + (d : D) (_ : B d × Fin (h d)) : ℝ := + scalarCubeProductBoundaryRadius (B d × Fin (h d)) α + ((E / (12 * ((Fintype.card D : ℝ) + 1))) / 2) + +noncomputable def jointAffineSourceMinorThreshold (h : D → ℕ) (c₀ : D → ℝ) (δ E : ℝ) + (d : D) : ℝ := + canonicalAffineCubeMinorThreshold (O d) α (h d) (c₀ d) δ + (E / (12 * ((Fintype.card D : ℝ) + 1))) + +noncomputable def jointAffineSourceRadius (h : D → ℕ) (c₀ C : D → ℝ) + (A T : ℝ≥0) (δ E : ℝ) : ℝ := + let r := jointAffineSourceBoundaryRadius (B := B) (α := α) h E + let κ := jointAffineSourceMinorThreshold (O := O) (α := α) h c₀ δ E + let K := jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ + let H := jointBooleanDerivativeBudget (B := B) (O := O) (α := α) h C + let L := jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H + min 1 (E / (3 * (1 + (L : ℝ)))) + +noncomputable def jointAffineSourceTolerance (h : D → ℕ) (c₀ C : D → ℝ) + (A T : ℝ≥0) (δ E : ℝ) : ℝ := + let r := jointAffineSourceBoundaryRadius (B := B) (α := α) h E + let κ := jointAffineSourceMinorThreshold (O := O) (α := α) h c₀ δ E + let K := jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ + let Q := jointAffineBooleanErrorBudget (O := O) (α := α) h C κ A T r δ + polynomialPerturbationScale K 1 Q (E / 3) (Fintype.card (Σ d, O d)) + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators ContDiff NNReal + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + +theorem exists_uniform_joint_affine_source_tolerance_with_scales + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (δ : ℝ) (hδ : 0 < δ) (hδone : δ ≤ 1) {E : ℝ} (hE : 0 < E) : + ∃ ρ : ℝ≥0, 0 < ρ ∧ ρ ≤ 1 ∧ + (ρ : ℝ) = jointAffineSourceRadius (B := B) (O := O) (α := α) h c₀ C A T δ E ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = jointAffineSourceTolerance (B := B) (O := O) (α := α) h c₀ C A T δ E ∧ + ∀ (c : ∀ d, B d → ℝ), (∀ d o, c₀ d ≤ |c d (block d o)|) → + (∀ d o, |c d (block d o)| ≤ C d) → + ∀ (center width : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (hw : ∀ d z, width d z ≠ 0), + (∀ d z, δ ≤ |width d z|) → (∀ d z, |center d z| + |width d z| ≤ 1) → + let L := fun d => (coordinateScaleEquiv (width d) (hw d)).toContinuousLinearEquiv + let slice := fun x : JointBlockParameter B h α → ℝ => + (fun s => center s.1 s.2) + sigmaAxisOperator (fun d => (L d).toContinuousLinearMap) x + let f := regularizedImageDensity (jointBooleanSource h) (jointAffineBooleanSampler c sets L center) ρ + (∀ x, f x ∈ Set.Icc (0 : ℝ) (ρ⁻¹ ^ Fintype.card (Σ d, O d) : ℝ≥0)) ∧ + Integrable f ∧ (∫ x, f x) = 1 ∧ LipschitzWith (affineProductProfileLip (Σ d, O d) ρ) f ∧ + ∀ (V : (JointBlockParameter B h α → ℝ) → ((Σ d, O d) → ℝ)), ContDiff ℝ 2 V → + (∀ x, (∀ z, |x z| ≤ 1) → + ‖V x - jointBooleanSampler h c sets x‖ ≤ t ∧ + ‖fderiv ℝ V x - fderiv ℝ (jointBooleanSampler h c sets) x‖ ≤ t ∧ + ‖fderiv ℝ (fderiv ℝ V) x - fderiv ℝ (fderiv ℝ (jointBooleanSampler h c sets)) x‖ ≤ t) → + ∀ φ : ((Σ d, O d) → ℝ) → ℝ, Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + |(∫ y, f y * φ y) - mappedTest (jointBooleanSource h) (V ∘ slice) φ| ≤ E := by + let η : D → ℝ := fun _ => E / (12 * ((Fintype.card D : ℝ) + 1)) + have hη : ∀ d, 0 < η d := fun _ => div_pos hE (by positivity) + have hmass : 4 * (∑ d, η d) ≤ E / 3 := by + have hn : (0 : ℝ) ≤ Fintype.card D := Nat.cast_nonneg _ + have hv : 0 ≤ E / (12 * ((Fintype.card D : ℝ) + 1)) := (div_pos hE (by positivity)).le + have he : ((Fintype.card D : ℝ) + 1) * (E / (12 * ((Fintype.card D : ℝ) + 1))) = E / 12 := by + field_simp + have hm := mul_le_mul_of_nonneg_right (show (Fintype.card D : ℝ) ≤ (Fintype.card D : ℝ) + 1 by linarith) hv + rw [he] at hm + simp only [η, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + linarith + let r := fun d (_ : B d × Fin (h d)) => scalarCubeProductBoundaryRadius (B d × Fin (h d)) α (η d / 2) + let κ := fun d => canonicalAffineCubeMinorThreshold (O d) α (h d) (c₀ d) δ (η d) + let K := jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ + let H := jointBooleanDerivativeBudget (B := B) (O := O) (α := α) h C + let Q := jointAffineBooleanErrorBudget (O := O) (α := α) h C κ A T r δ + let L := jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H + have hr : ∀ d i, 0 ≤ r d i := fun d _ => (scalarCubeProductBoundaryRadius_pos _ _ (half_pos (hη d))).le + have hκ : ∀ d, 0 ≤ κ d := fun d => (canonicalAffineCubeMinorThreshold_pos (O d) α (hh d) (hc₀ d) hδ (hη d)).le + have hQ : 0 ≤ Q := by + have hS := jointBooleanWeightBudget_nonneg (O := O) (α := α) h C hC A T r hr κ hκ + dsimp only [Q, jointAffineBooleanErrorBudget] + positivity + let ρ : ℝ≥0 := ⟨min 1 (E / (3 * (1 + (L : ℝ)))), by positivity⟩ + have hρ : 0 < ρ := lt_min zero_lt_one (div_pos hE (by positivity)) + have hρone : ρ ≤ 1 := by + change min (1 : ℝ) (E / (3 * (1 + (L : ℝ)))) ≤ 1 + exact min_le_left _ _ + have hnoise : (L : ℝ) * ρ ≤ E / 3 := by + have hd : (ρ : ℝ) ≤ E / (3 * (1 + (L : ℝ))) := min_le_right _ _ + have he := (le_div_iff₀ (show 0 < 3 * (1 + (L : ℝ)) by positivity)).mp hd + nlinarith [ρ.coe_nonneg] + let t := polynomialPerturbationScale K 1 Q (E / 3) (Fintype.card (Σ d, O d)) + have ht := polynomialPerturbationScale_spec K.coe_nonneg (show (0 : ℝ) ≤ 1 by norm_num) + hQ (show 0 < E / 3 by positivity) (Fintype.card (Σ d, O d)) + have hsmall : (K : ℝ) * t ≤ 1 / 2 := by simpa only [mul_one] using ht.2.2.1 + have hroot : 4 * (Fintype.card (Σ d, O d) : ℝ) * Real.sqrt (Q * t) ≤ E / 3 := by + apply le_trans _ ht.2.2.2.2 + gcongr + nlinarith [ht.1] + refine ⟨ρ, hρ, hρone, rfl, t, ht.1, ht.2.1, rfl, ?_⟩ + intro c hclow hcup center width hw hwidth hbox + have hs := jointAffineBoolean_source_density_comparison h hh c sets hsets hcard block hblock + c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A T hLip hTransition δ hδ hδone η hη + center width hw hwidth hbox ρ hρ + refine ⟨hs.1, hs.2.1, hs.2.2.1, hs.2.2.2.1, ?_⟩ + intro V hV herr φ hφ hbound + have he := hs.2.2.2.2 V hV t ht.1 ht.2.1 hsmall herr φ hφ hbound + exact he.trans (by change 4 * (∑ d, η d) + (L : ℝ) * ρ + + 4 * (Fintype.card (Σ d, O d) : ℝ) * Real.sqrt (Q * t) ≤ E; linarith only [hmass, hnoise, hroot]) + +theorem exists_uniform_joint_affine_source_tolerance + (h : D → ℕ) (hh : ∀ d, 0 < h d) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (δ : ℝ) (hδ : 0 < δ) (hδone : δ ≤ 1) {E : ℝ} (hE : 0 < E) : + ∃ ρ : ℝ≥0, 0 < ρ ∧ ρ ≤ 1 ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ∀ (c : ∀ d, B d → ℝ), (∀ d o, c₀ d ≤ |c d (block d o)|) → + (∀ d o, |c d (block d o)| ≤ C d) → + ∀ (center width : ∀ d, BlockParameter (B d) (Fin (h d)) α → ℝ) + (hw : ∀ d z, width d z ≠ 0), + (∀ d z, δ ≤ |width d z|) → (∀ d z, |center d z| + |width d z| ≤ 1) → + let L := fun d => (coordinateScaleEquiv (width d) (hw d)).toContinuousLinearEquiv + let slice := fun x : JointBlockParameter B h α → ℝ => + (fun s => center s.1 s.2) + sigmaAxisOperator (fun d => (L d).toContinuousLinearMap) x + let f := regularizedImageDensity (jointBooleanSource h) (jointAffineBooleanSampler c sets L center) ρ + (∀ x, f x ∈ Set.Icc (0 : ℝ) (ρ⁻¹ ^ Fintype.card (Σ d, O d) : ℝ≥0)) ∧ + Integrable f ∧ (∫ x, f x) = 1 ∧ LipschitzWith (affineProductProfileLip (Σ d, O d) ρ) f ∧ + ∀ (V : (JointBlockParameter B h α → ℝ) → ((Σ d, O d) → ℝ)), ContDiff ℝ 2 V → + (∀ x, (∀ z, |x z| ≤ 1) → + ‖V x - jointBooleanSampler h c sets x‖ ≤ t ∧ + ‖fderiv ℝ V x - fderiv ℝ (jointBooleanSampler h c sets) x‖ ≤ t ∧ + ‖fderiv ℝ (fderiv ℝ V) x - fderiv ℝ (fderiv ℝ (jointBooleanSampler h c sets)) x‖ ≤ t) → + ∀ φ : ((Σ d, O d) → ℝ) → ℝ, Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + |(∫ y, f y * φ y) - mappedTest (jointBooleanSource h) (V ∘ slice) φ| ≤ E := by + obtain ⟨ρ, hρ, hρone, _, t, ht, htone, _, hs⟩ := + exists_uniform_joint_affine_source_tolerance_with_scales h hh sets hsets hcard block hblock + c₀ C hc₀ hC ψ hψ hrange hzero hone A T hLip hTransition δ hδ hδone hE + exact ⟨ρ, hρ, hρone, t, ht, htone, hs⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineL1Parameter.lean b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineL1Parameter.lean new file mode 100644 index 0000000000000000000000000000000000000000..766b3165ac2da1269680b3a03cb3a7fb16ed83c3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineL1Parameter.lean @@ -0,0 +1,577 @@ +import OAI.Combinatorics.Progressions.Dynamics.JetOutputRadiusLogBudget +import OAI.Combinatorics.Progressions.Estimates.NormalizedJetL1Parameter +import OAI.Combinatorics.Progressions.Estimates.NormalizedJetMeasurability +import OAI.Combinatorics.Progressions.Estimates.SelectedProfileTranslationL1 +import OAI.Combinatorics.Progressions.Polynomial.PolynomialDensityRiemann +import OAI.Combinatorics.Progressions.Probability.CoefficientDensitySplit + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +theorem affineProductProfile_range_bound {J : Type*} [Fintype J] + (c w : J → ℝ) {δ : ℝ≥0} (hδ : 0 < δ) (hw : ∀ j, (δ : ℝ) ≤ w j) (x : J → ℝ) : + affineProductProfile c w x ∈ Set.Icc (0 : ℝ) ((δ⁻¹^Fintype.card J : ℝ≥0) : ℝ) := by + have hwpos : ∀ j, 0 < w j := fun j => (show (0 : ℝ) < δ from hδ).trans_le (hw j) + refine ⟨affineProductProfile_nonneg c w hwpos x, ?_⟩ + have hb := affineProductProfile_cap c w (show (0 : ℝ) < δ from hδ) hw x + rw [Real.norm_eq_abs, abs_of_nonneg (affineProductProfile_nonneg c w hwpos x)] at hb + simpa only [NNReal.coe_pow, NNReal.coe_inv] using hb + +theorem affineCoefficientDensity_split {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (A : Matrix I J ℤ) (C : Matrix I N ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) + (hfull : ((Matrix.fromCols A C).submatrix id (s.trans Function.Embedding.inl)).det ≠ 0) + (S : J → ℝ) (T : N → ℝ) (P : I → ℝ) (hS : ∀ j, 0 < S j) (hT : ∀ n, 0 < T n) + (hP : ∀ i, 0 < P i) (c w : J ⊕ N → ℝ) {δ : ℝ≥0} (hδ : 0 < δ) + (hw : ∀ j, (δ : ℝ) ≤ w j) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) : + selectedCoefficientDensity (Matrix.fromCols A C) (s.trans Function.Embedding.inl) hfull + (Sum.elim S T) P (Sum.rec hS hT) hP (affineProductProfile c w) = + pivotOutputDensity + (normalizedPivotEquiv (A.submatrix id s) hA (fun i => S (s i)) P (fun i => hS (s i)) hP) + (splitFreeColumns + (matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns A s) (fun j => S j.val) P)) + (matrixSupCLM (normalizedIntegerColumns C T P))) + (splitFreeProfile + (selectedCoefficientProfile s (affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)))) + (affineProductProfile (fun n => c (.inr n)) (fun n => w (.inr n)))) := by + have hwpos : ∀ j, 0 < w j := fun j => (show (0 : ℝ) < δ from hδ).trans_le (hw j) + rw [affineProductProfile_joined] + exact selectedCoefficientDensity_split A C s hA hfull S T P hS hT hP _ _ R R + (δ⁻¹^Fintype.card J) (δ⁻¹^Fintype.card N) (affineProductProfileLip J δ) (affineProductProfileLip N δ) + (affineProductProfile_lipschitz _ _ hδ (fun j => hw (.inl j))) + (affineProductProfile_lipschitz _ _ hδ (fun n => hw (.inr n))) + (affineProductProfile_range_bound _ _ hδ (fun j => hw (.inl j))) + (affineProductProfile_range_bound _ _ hδ (fun n => hw (.inr n))) + (affineProductProfile_zero_outside _ _ (fun j => hwpos (.inl j)) R.coe_nonneg (fun j => hsupport (.inl j))) + (affineProductProfile_zero_outside _ _ (fun n => hwpos (.inr n)) R.coe_nonneg (fun n => hsupport (.inr n))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +noncomputable def affineSelectedJetDensity {Z X K α I J N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) (rows : I → Finset α) + (c w : J ⊕ N → ℝ) (x : X → ℝ) : (I → ℝ) → ℝ := + normalizedJetDensity A F e input z rows + (selectedCoefficientProfile s (affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)))) + (affineProductProfile (fun n => c (.inr n)) (fun n => w (.inr n))) x + +theorem affineSelectedJetDensity_bounds {Z X K α I J N : Type*} + [Fintype X] [DecidableEq X] [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) (hz : ∀ j, |z j| ≤ 1) + (rows : I → Finset α) {degree : ℕ} (hd : ∀ n, (e n).sum (fun _ k => k) ≤ degree) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w (.inl j)) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + (v : I → ℝ) : + (∀ x, ‖affineSelectedJetDensity s A F e input z rows c w x v‖ ≤ + pivotKernelCap (UnselectedColumn s) A R (δ⁻¹^Fintype.card J)) ∧ + LipschitzOnWith (pivotKernelLip (UnselectedColumn s) A R (affineProductProfileLip J δ) * + (Fintype.card N * polynomialBoxLip (Fintype.card X) degree (normalizedJetMass α degree)) * R) + (fun x => affineSelectedJetDensity s A F e input z rows c w x v) (Metric.closedBall 0 1) := by + have hcap := affineProductProfile_cap (fun j => c (.inl j)) (fun j => w (.inl j)) + (show (0 : ℝ) < δ from hδ) hwidth + have hcap' : ∀ x, ‖affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)) x‖ ≤ + ((δ⁻¹^Fintype.card J : ℝ≥0) : ℝ) := by + simpa only [NNReal.coe_pow, NNReal.coe_inv] using hcap + exact normalizedJetDensity_bounds A F e input z hz rows hd R (δ⁻¹^Fintype.card J) + (affineProductProfileLip J δ) R + (selectedCoefficientProfile_lipschitz s (affineProductProfile_lipschitz _ _ hδ hwidth)) + (affineProductProfile_contDiff _ _).continuous + (selectedCoefficientProfile_zero_outside s + (affineProductProfile_zero_outside _ _ (fun j => hw (.inl j)) R.coe_nonneg (fun j => hsupport (.inl j)))) + (affineProductProfile_zero_outside _ _ (fun n => hw (.inr n)) R.coe_nonneg (fun n => hsupport (.inr n))) + (selectedCoefficientProfile_norm_le s hcap') + (affineProductProfile_nonneg _ _ (fun n => hw (.inr n))) + (affineProductProfile_integral _ _ (fun n => hw (.inr n))) v + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +noncomputable def affineJetL1Cost (P α J N : Type*) [Fintype P] [Fintype α] [Fintype J] [Fintype N] + {I : Type*} [Fintype I] (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (degree : ℕ) (δ R : ℝ≥0) : ℝ≥0 := + (Fintype.card J * (4 * probabilityProfileLipschitz / δ) * ‖A.symm.toContinuousLinearMap‖₊) * + (Fintype.card N * polynomialBoxLip (Fintype.card P) degree (normalizedJetMass α degree)) * R + +theorem affineSelectedJetDensity_l1_regular {Z P K α I J N : Type*} + [Fintype P] [DecidableEq P] [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ P) (z : Z → ℝ) (hz : ∀ j, |z j| ≤ 1) + (rows : I → Finset α) {degree : ℕ} (hd : ∀ n, (e n).sum (fun _ k => k) ≤ degree) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w (.inl j)) (R : ℝ≥0) (hsupport : ∀ j, |c j| + w j ≤ R) + (a : P → ℝ) (ha : a ∈ Metric.closedBall 0 1) (b : P → ℝ) (hb : b ∈ Metric.closedBall 0 1) : + (∫ v, |affineSelectedJetDensity s A F e input z rows c w a v - + affineSelectedJetDensity s A F e input z rows c w b v|) ≤ + affineJetL1Cost P α J N A degree δ R * dist a b := by + have hf : Continuous (selectedCoefficientProfile s + (affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)))) := + (affineProductProfile_contDiff (fun j => c (.inl j)) (fun j => w (.inl j))).continuous.comp + (selectedCoefficientEquiv_lipschitz s).continuous + apply normalizedJetDensity_l1_regular A F e input z hz rows hd hf + (affineProductProfile_contDiff (fun n => c (.inr n)) (fun n => w (.inr n))).continuous R R + (Fintype.card J * (4 * probabilityProfileLipschitz / δ) * ‖A.symm.toContinuousLinearMap‖₊) + (selectedCoefficientProfile_zero_outside s (affineProductProfile_zero_outside _ _ + (fun j => hw (.inl j)) R.coe_nonneg (fun j => hsupport (.inl j)))) + (affineProductProfile_zero_outside _ _ (fun n => hw (.inr n)) R.coe_nonneg (fun n => hsupport (.inr n))) + (selectedCoefficientProfile_nonneg s (affineProductProfile_nonneg _ _ (fun j => hw (.inl j)))) + (affineProductProfile_nonneg _ _ (fun n => hw (.inr n))) + _ (affineProductProfile_integral _ _ (fun n => hw (.inr n))) _ a ha b hb + · rw [selectedCoefficientProfile_integral, affineProductProfile_integral _ _ (fun j => hw (.inl j))] + · intro u v + simpa only [NNReal.coe_mul, NNReal.coe_natCast, NNReal.coe_div, NNReal.coe_ofNat, coe_nnnorm] using + affineSelectedPivot_translation_l1 s A F (fun j => c (.inl j)) (fun j => w (.inl j)) + (show (0 : ℝ) < δ from hδ) hwidth u v + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators NNReal + +theorem affineSelectedJetDensity_principalTuple_riemann {Z K D α I J N : Type*} + [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + [Fintype I] [Fintype J] [Fintype N] + (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] (h : D → ℕ) + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ JointBlockParameter B h α) + (z : Z → ℝ) (hz : ∀ j, |z j| ≤ 1) (rows : I → Finset α) + {degree : ℕ} (hd : ∀ n, (e n).sum (fun _ k => k) ≤ degree) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w (.inl j)) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + (L M : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) + (m : PrincipalTupleIndex B h → Option α → ℕ) (r : ∀ j i, ZMod (m j i)) + (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M j) + (hsize : ∀ j, (Fintype.card α+1)*M j ≤ L j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant α * ((M j : ℝ)/L j) < volume.real (scalarCubeDomain α)) + (v : I → ℝ) : + let ρ := fun x => affineSelectedJetDensity s A F e input z rows c w x v + let Cap := pivotKernelCap (UnselectedColumn s) A R (δ⁻¹^Fintype.card J) + let Lip := pivotKernelLip (UnselectedColumn s) A R (affineProductProfileLip J δ) * + (Fintype.card N * polynomialBoxLip (Fintype.card (JointBlockParameter B h α)) degree + (normalizedJetMass α degree)) * R + |(FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (L j) (M j) (hL j) + (m j) (r j) (hm j) (hmM j) (hsize j))).mean + (fun y => ρ (fun a => (y ⟨a.1, a.2.1, a.2.2.1⟩ a.2.2.2 : ℝ) / L ⟨a.1, a.2.1, a.2.2.1⟩)) - + ∫ x, ρ x ∂jointBooleanSource h| ≤ + (2 * (Cap : ℝ) * scalarCubeGridBoundaryConstant α / volume.real (scalarCubeDomain α) + Lip) * + ∑ j, (M j : ℝ)/L j := by + dsimp only + have hb := affineSelectedJetDensity_bounds s A F e input z hz rows hd c w hw hδ hwidth R hsupport v + exact principalTuple_residue_riemann_on_box B h L M hL m r hm hmM hsize hsmall _ hb.2 + (pivotKernelCap (UnselectedColumn s) A R (δ⁻¹^Fintype.card J)).coe_nonneg (fun x _ => hb.1 x) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem splitPivotDensity_output_lipschitz {I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (B : (J → ℝ) →L[ℝ] (I → ℝ)) + (C : (N → ℝ) →L[ℝ] (I → ℝ)) {f : (J → ℝ) × (I → ℝ) → ℝ} {g : (N → ℝ) → ℝ} + (R K S : ℝ≥0) (hf : LipschitzWith K f) (hg : Continuous g) + (hfs : ∀ p, (R : ℝ) < ‖p‖ → f p = 0) (hgs : ∀ n, (S : ℝ) < ‖n‖ → g n = 0) + (hg0 : ∀ n, 0 ≤ g n) (hgmass : (∫ n, g n) = 1) : + LipschitzWith (pivotKernelLip J A R K) + (pivotOutputDensity A (splitFreeColumns B C) (splitFreeProfile f g)) := by + have hρ := pivotOutputDensity_lipschitz A B R K hf hfs + have hi (v : I → ℝ) : Integrable (fun n => g n*pivotOutputDensity A B f (v-C n)) := + compactBox_integrable _ (hg.mul (hρ.continuous.comp (by fun_prop))) S + (fun n hn => by rw [hgs n hn, zero_mul]) + apply LipschitzWith.of_dist_le_mul + intro v w + rw [Real.dist_eq, splitPivotDensity_formula A B C hf.continuous hg hfs hgs v, + splitPivotDensity_formula A B C hf.continuous hg hfs hgs w] + apply fixedKernelMixture_difference_le volume g _ _ (compactBox_integrable g hg S hgs) hg0 hgmass (hi v) (hi w) + intro n _ + simpa only [Real.dist_eq, dist_sub_right] using hρ.dist_le_mul (v-C n) (w-C n) + +theorem affineSelectedJetDensity_output_lipschitz {Z X K α I J N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) (rows : I → Finset α) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w (.inl j)) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + (x : X → ℝ) : + LipschitzWith (pivotKernelLip (UnselectedColumn s) A R (affineProductProfileLip J δ)) + (affineSelectedJetDensity s A F e input z rows c w x) := by + apply splitPivotDensity_output_lipschitz A F _ R (affineProductProfileLip J δ) R + (selectedCoefficientProfile_lipschitz s (affineProductProfile_lipschitz _ _ hδ hwidth)) + (affineProductProfile_contDiff _ _).continuous + (selectedCoefficientProfile_zero_outside s + (affineProductProfile_zero_outside _ _ (fun j => hw (.inl j)) R.coe_nonneg (fun j => hsupport (.inl j)))) + (affineProductProfile_zero_outside _ _ (fun n => hw (.inr n)) R.coe_nonneg (fun n => hsupport (.inr n))) + (affineProductProfile_nonneg _ _ (fun n => hw (.inr n))) + (affineProductProfile_integral _ _ (fun n => hw (.inr n))) + +theorem affineSelectedJetDensity_output_cap {Z X K α I J N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) (rows : I → Finset α) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w (.inl j)) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + (x : X → ℝ) (v : I → ℝ) : + |affineSelectedJetDensity s A F e input z rows c w x v| ≤ + pivotKernelCap (UnselectedColumn s) A R (δ⁻¹^Fintype.card J) := by + have hcap : ∀ u, ‖affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)) u‖ ≤ + ((δ⁻¹^Fintype.card J : ℝ≥0) : ℝ) := by + simpa only [NNReal.coe_pow, NNReal.coe_inv] using + affineProductProfile_cap (fun j => c (.inl j)) (fun j => w (.inl j)) + (show (0 : ℝ) < δ from hδ) hwidth + exact splitPivotDensity_norm_le_cap A F _ R (δ⁻¹^Fintype.card J) R + (selectedCoefficientProfile_lipschitz s (affineProductProfile_lipschitz _ _ hδ hwidth)).continuous + (affineProductProfile_contDiff _ _).continuous + (selectedCoefficientProfile_zero_outside s + (affineProductProfile_zero_outside _ _ (fun j => hw (.inl j)) R.coe_nonneg (fun j => hsupport (.inl j)))) + (affineProductProfile_zero_outside _ _ (fun n => hw (.inr n)) R.coe_nonneg (fun n => hsupport (.inr n))) + (selectedCoefficientProfile_norm_le s hcap) (affineProductProfile_nonneg _ _ (fun n => hw (.inr n))) + (affineProductProfile_integral _ _ (fun n => hw (.inr n))) v + +theorem affineSelectedJetDensity_output_support {Z X K α I J N : Type*} + [Fintype X] [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) (hz : ∀ j, |z j| ≤ 1) + (rows : I → Finset α) {degree : ℕ} (hd : ∀ n, (e n).sum (fun _ k => k) ≤ degree) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + (x : X → ℝ) (hx : ‖x‖ ≤ 1) (v : I → ℝ) + (hv : (normalizedJetOutputRadius α N A F degree R R : ℝ) < ‖v‖) : + affineSelectedJetDensity s A F e input z rows c w x v = 0 := by + exact normalizedJetDensity_zero_outside A F e input z hz rows hd R R + ((affineProductProfile_contDiff _ _).continuous.comp (selectedCoefficientEquiv_lipschitz s).continuous) + (affineProductProfile_contDiff _ _).continuous + (selectedCoefficientProfile_zero_outside s + (affineProductProfile_zero_outside _ _ (fun j => hw (.inl j)) R.coe_nonneg (fun j => hsupport (.inl j)))) + (affineProductProfile_zero_outside _ _ (fun n => hw (.inr n)) R.coe_nonneg (fun n => hsupport (.inr n))) + x hx v hv + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal BigOperators + +noncomputable def jointAffineJetDensity {Q Z X K α : Type*} [Fintype Q] + [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) + (x : X → ℝ) (v : ∀ q, I q → ℝ) : ℝ := + ∏ q, affineSelectedJetDensity (s q) (A q) (F q) (e q) input z (rows q) (c q) (w q) x (v q) + +theorem jointAffineJetDensity_bounds {Q Z X K α : Type*} [Fintype Q] + [Fintype X] [DecidableEq X] [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) (hz : ∀ j, |z j| ≤ 1) + (rows : ∀ q, I q → Finset α) (degree : Q → ℕ) + (hd : ∀ q n, (e q n).sum (fun _ k => k) ≤ degree q) + (c w : ∀ q, J q ⊕ N q → ℝ) (hw : ∀ q j, 0 < w q j) (δ R : Q → ℝ≥0) + (hδ : ∀ q, 0 < δ q) (hwidth : ∀ q j, (δ q : ℝ) ≤ w q (.inl j)) + (hsupport : ∀ q j, |c q j|+w q j ≤ R q) + (Cap Lip : ℝ≥0) (hCap : 1 ≤ Cap) + (hcap : ∀ q, pivotKernelCap (UnselectedColumn (s q)) (A q) (R q) ((δ q)⁻¹^Fintype.card (J q)) ≤ Cap) + (hlip : ∀ q, pivotKernelLip (UnselectedColumn (s q)) (A q) (R q) (affineProductProfileLip (J q) (δ q)) * + (Fintype.card (N q) * polynomialBoxLip (Fintype.card X) (degree q) (normalizedJetMass α (degree q))) * R q ≤ Lip) + (v : ∀ q, I q → ℝ) : + (∀ x, |jointAffineJetDensity s A F e input z rows c w x v| ≤ (Cap : ℝ)^Fintype.card Q) ∧ + LipschitzOnWith (Fintype.card Q*Lip*Cap^Fintype.card Q) + (fun x => jointAffineJetDensity s A F e input z rows c w x v) (Metric.closedBall 0 1) := by + let f := fun q x => affineSelectedJetDensity (s q) (A q) (F q) (e q) input z (rows q) (c q) (w q) x (v q) + have hreg (q) := affineSelectedJetDensity_bounds (s q) (A q) (F q) (e q) input z hz + (rows q) (hd q) (c q) (w q) (hw q) (hδ q) (hwidth q) (R q) (hsupport q) (v q) + have hfcap : ∀ q x, |f q x| ≤ Cap := fun q x => (hreg q).1 x |>.trans (hcap q) + have hfLip : ∀ q, LipschitzOnWith Lip (f q) (Metric.closedBall 0 1) := by + intro q + apply LipschitzOnWith.of_dist_le_mul + intro x hx y hy + exact ((hreg q).2.dist_le_mul x hx y hy).trans + (mul_le_mul_of_nonneg_right (show (_ : ℝ) ≤ Lip from hlip q) dist_nonneg) + exact ⟨finiteProduct_cap f Cap.coe_nonneg hfcap, + finiteProduct_lipschitzOn f (Metric.closedBall 0 1) Cap Lip hCap hfLip (fun q x _ => hfcap q x)⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def affineJetL1Log (u a j n d : ℕ) (p v : ℝ) : ℝ := + j + 4 * (probabilityProfileLipschitz : ℝ) + 2*p + v + + n + 3*(u : ℝ)*d + (a : ℝ)*(d+1) + +theorem affineJetL1Log_nonneg (u a j n d : ℕ) {p v : ℝ} + (hp : 0 ≤ p) (hv : 0 ≤ v) : 0 ≤ affineJetL1Log u a j n d p v := by + unfold affineJetL1Log + positivity + +theorem affineJetL1Cost_le_exp (P α J N : Type*) + [Fintype P] [Fintype α] [Fintype J] [Fintype N] + {I : Type*} [Fintype I] (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (d : ℕ) + (δ R : ℝ≥0) {p v : ℝ} (hδ : (δ : ℝ)⁻¹ ≤ Real.exp p) + (hR : (R : ℝ) ≤ Real.exp p) (hi : ‖A.symm.toContinuousLinearMap‖ ≤ Real.exp v) : + (affineJetL1Cost P α J N A d δ R : ℝ) ≤ + Real.exp (affineJetL1Log (Fintype.card P) (Fintype.card α) + (Fintype.card J) (Fintype.card N) d p v) := by + have hj : (Fintype.card J : ℝ) ≤ Real.exp (Fintype.card J : ℝ) := by + linarith [Real.add_one_le_exp (Fintype.card J : ℝ)] + have ha : 4 * (probabilityProfileLipschitz : ℝ) ≤ + Real.exp (4 * (probabilityProfileLipschitz : ℝ)) := by + linarith [Real.add_one_le_exp (4 * (probabilityProfileLipschitz : ℝ))] + have hn := normalizedJetColumnLip_le_exp α (Fintype.card N) (Fintype.card P) d + simp only [affineJetL1Cost, NNReal.coe_mul, NNReal.coe_natCast, NNReal.coe_inv, + NNReal.coe_ofNat, coe_nnnorm, div_eq_mul_inv] + calc + _ ≤ (Real.exp (Fintype.card J : ℝ) * + (Real.exp (4 * (probabilityProfileLipschitz : ℝ)) * Real.exp p) * Real.exp v) * + Real.exp (Fintype.card N + 3*(Fintype.card P : ℝ)*d + (Fintype.card α : ℝ)*(d+1)) * + Real.exp p := by gcongr + _ = _ := by + rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add, ← Real.exp_add, ← Real.exp_add] + congr 1 + unfold affineJetL1Log + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +noncomputable def affineSelectedJetProfile {I J N : Type*} [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (c w : J ⊕ N → ℝ) : (UnselectedColumn s ⊕ N → ℝ) × (I → ℝ) → ℝ := + splitFreeProfile + (selectedCoefficientProfile s (affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)))) + (affineProductProfile (fun n => c (.inr n)) (fun n => w (.inr n))) + +theorem affineSelectedJetProfile_probability_data {I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] (s : I ↪ J) (c w : J ⊕ N → ℝ) + (hw : ∀ j, 0 < w j) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) : + Integrable (affineSelectedJetProfile s c w) ∧ + (∀ u, 0 ≤ affineSelectedJetProfile s c w u) ∧ + (∫ u, affineSelectedJetProfile s c w u) = 1 := by + have hf : Continuous (selectedCoefficientProfile s + (affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)))) := + (affineProductProfile_contDiff (fun j => c (.inl j)) (fun j => w (.inl j))).continuous.comp + (selectedCoefficientEquiv_lipschitz s).continuous + have hg := (affineProductProfile_contDiff (fun n => c (.inr n)) (fun n => w (.inr n))).continuous + have hfs := selectedCoefficientProfile_zero_outside s + (affineProductProfile_zero_outside _ _ (fun j => hw (.inl j)) R.coe_nonneg (fun j => hsupport (.inl j))) + have hgs := affineProductProfile_zero_outside _ _ (fun n => hw (.inr n)) R.coe_nonneg + (fun n => hsupport (.inr n)) + refine ⟨splitFreeProfile_integrable hf hg hfs hgs, + splitFreeProfile_nonneg (selectedCoefficientProfile_nonneg s + (affineProductProfile_nonneg _ _ (fun j => hw (.inl j)))) + (affineProductProfile_nonneg _ _ (fun n => hw (.inr n))), ?_⟩ + change (∫ u, splitFreeProfile _ _ u) = 1 + rw [splitFreeProfile_integral hf hg hfs hgs, selectedCoefficientProfile_integral, + affineProductProfile_integral _ _ (fun j => hw (.inl j)), + affineProductProfile_integral _ _ (fun n => hw (.inr n)), one_mul] + +theorem jointAffineJetDensity_law {Q Z X K α : Type*} [Fintype Q] + [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) (hw : ∀ q j, 0 < w q j) + (R : Q → ℝ≥0) (hsupport : ∀ q j, |c q j|+w q j ≤ R q) (x : X → ℝ) : + (Measure.pi (fun q => realDensityMeasure volume (affineSelectedJetProfile (s q) (c q) (w q)))).map + (fun u q => A q (u q).2 + + splitFreeColumns (F q) + (polynomialColumns (fun o n => normalizedJetColumn (e q n) input z (rows q o)) x) (u q).1) = + realDensityMeasure (Measure.pi (fun q => (volume : Measure (I q → ℝ)))) + (jointAffineJetDensity s A F e input z rows c w x) := by + let V := fun q => splitFreeColumns (F q) + (polynomialColumns (fun o n => normalizedJetColumn (e q n) input z (rows q o)) x) + have hp (q) := affineSelectedJetProfile_probability_data (s q) (c q) (w q) (hw q) (R q) (hsupport q) + let : ∀ q, IsProbabilityMeasure (realDensityMeasure volume (affineSelectedJetProfile (s q) (c q) (w q))) := + fun q => realDensityMeasure_probability volume _ (hp q).1 (hp q).2.1 (hp q).2.2 + have hm (q) : Measurable (fun u : (UnselectedColumn (s q) ⊕ N q → ℝ) × (I q → ℝ) => + A q u.2 + V q u.1) := by fun_prop + change (Measure.pi _).map + (fun (u : ∀ q, (UnselectedColumn (s q) ⊕ N q → ℝ) × (I q → ℝ)) q => + A q (u q).2 + V q (u q).1) = _ + rw [Measure.pi_map_pi (fun q => (hm q).aemeasurable)] + have hlaw (q) := pivotOutputDensity_law (A q) (V q) (hp q).1 (hp q).2.1 + simp_rw [hlaw] + exact realDensityMeasure_pi (fun _ => volume) _ + (fun q => pivotOutputDensity_integrable (A q) (V q) (hp q).1) + (fun q => pivotOutputDensity_nonneg (A q) (V q) (hp q).2.1) + +theorem jointAffineJetDensity_probability_data {Q Z X K α : Type*} [Fintype Q] + [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) (hw : ∀ q j, 0 < w q j) + (R : Q → ℝ≥0) (hsupport : ∀ q j, |c q j|+w q j ≤ R q) (x : X → ℝ) : + Integrable (jointAffineJetDensity s A F e input z rows c w x) (Measure.pi (fun _ => volume)) ∧ + (∀ v, 0 ≤ jointAffineJetDensity s A F e input z rows c w x v) ∧ + (∫ v, jointAffineJetDensity s A F e input z rows c w x v ∂Measure.pi (fun _ => volume)) = 1 := by + let V := fun q => splitFreeColumns (F q) + (polynomialColumns (fun o n => normalizedJetColumn (e q n) input z (rows q o)) x) + have hp (q) := affineSelectedJetProfile_probability_data (s q) (c q) (w q) (hw q) (R q) (hsupport q) + have hfi (q) := pivotOutputDensity_integrable (A q) (V q) (hp q).1 + refine ⟨Integrable.fintype_prod_dep hfi, ?_, ?_⟩ + · intro v + exact Finset.prod_nonneg (fun q _ => pivotOutputDensity_nonneg (A q) (V q) (hp q).2.1 (v q)) + · change (∫ v, (∏ q, pivotOutputDensity (A q) (V q) (affineSelectedJetProfile (s q) (c q) (w q)) (v q)) + ∂Measure.pi (fun _ => volume)) = 1 + rw [integral_fintype_prod_eq_prod] + apply Finset.prod_eq_one + intro q _ + exact (pivotOutputDensity_integral (A q) (V q) (hp q).1).trans (hp q).2.2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem jointAffineJetDensity_measurable_comp {Ω Q Z X K α : Type*} + [MeasurableSpace Ω] [Fintype Q] [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) + (hw : ∀ q j, 0 < w q j) (R : Q → ℝ≥0) (hsupport : ∀ q j, |c q j|+w q j ≤ R q) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun ω => z ω j)) + (x : Ω → X → ℝ) (hx : ∀ j, Measurable (fun ω => x ω j)) + (v : Ω → ∀ q, I q → ℝ) (hv : ∀ q i, Measurable (fun ω => v ω q i)) : + Measurable (fun ω => jointAffineJetDensity s A F e input (z ω) rows c w (x ω) (v ω)) := by + have hm (q) : Measurable (fun ω => + affineSelectedJetDensity (s q) (A q) (F q) (e q) input (z ω) (rows q) (c q) (w q) (x ω) (v ω q)) := + normalizedJetDensity_measurable_comp (Ω := Ω) (A q) (F q) (e q) input (rows q) + ((affineProductProfile_contDiff _ _).continuous.comp (selectedCoefficientEquiv_lipschitz (s q)).continuous) + (affineProductProfile_contDiff _ _).continuous + (selectedCoefficientProfile_zero_outside (s q) + (affineProductProfile_zero_outside _ _ (fun j => hw q (.inl j)) (R q).coe_nonneg + (fun j => hsupport q (.inl j)))) + (affineProductProfile_zero_outside _ _ (fun n => hw q (.inr n)) (R q).coe_nonneg + (fun n => hsupport q (.inr n))) + z hz x hx (fun ω => v ω q) (hv q) + unfold jointAffineJetDensity + exact Finset.measurable_prod Finset.univ (fun q _ => hm q) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem affineSelectedJetDensity_probability_data {Z P K α I J N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ P) (z : Z → ℝ) (rows : I → Finset α) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) (R : ℝ≥0) (hsupport : ∀ j, |c j| + w j ≤ R) + (x : P → ℝ) : + (∀ v, 0 ≤ affineSelectedJetDensity s A F e input z rows c w x v) ∧ + Integrable (affineSelectedJetDensity s A F e input z rows c w x) ∧ + (∫ v, affineSelectedJetDensity s A F e input z rows c w x v) = 1 := by + have hp := affineSelectedJetProfile_probability_data s c w hw R hsupport + exact ⟨pivotOutputDensity_nonneg _ _ hp.2.1, pivotOutputDensity_integrable _ _ hp.1, + (pivotOutputDensity_integral _ _ hp.1).trans hp.2.2⟩ + +theorem jointAffineJetDensity_l1_regular {Q Z P K α : Type*} [Fintype Q] [DecidableEq Q] + [Fintype P] [DecidableEq P] [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ P) (z : Z → ℝ) (hz : ∀ j, |z j| ≤ 1) + (rows : ∀ q, I q → Finset α) (degree : Q → ℕ) (hd : ∀ q n, (e q n).sum (fun _ k => k) ≤ degree q) + (c w : ∀ q, J q ⊕ N q → ℝ) (hw : ∀ q j, 0 < w q j) (δ R : Q → ℝ≥0) + (hδ : ∀ q, 0 < δ q) (hwidth : ∀ q j, (δ q : ℝ) ≤ w q (.inl j)) + (hsupport : ∀ q j, |c q j| + w q j ≤ R q) + (a : P → ℝ) (ha : a ∈ Metric.closedBall 0 1) (b : P → ℝ) (hb : b ∈ Metric.closedBall 0 1) : + (∫ v, |jointAffineJetDensity s A F e input z rows c w a v - + jointAffineJetDensity s A F e input z rows c w b v| ∂Measure.pi (fun _ => volume)) ≤ + ((∑ q, affineJetL1Cost P α (J q) (N q) (A q) (degree q) (δ q) (R q) : ℝ≥0) : ℝ) * dist a b := by + have hp (q) (x : P → ℝ) := affineSelectedJetDensity_probability_data (s q) (A q) (F q) + (e q) input z (rows q) (c q) (w q) (hw q) (R q) (hsupport q) x + have he := tensor_density_l1_le_sum (fun q => (volume : Measure (I q → ℝ))) + (fun q => affineSelectedJetDensity (s q) (A q) (F q) (e q) input z (rows q) (c q) (w q) a) + (fun q => affineSelectedJetDensity (s q) (A q) (F q) (e q) input z (rows q) (c q) (w q) b) + (fun q => (hp q a).2.1) (fun q => (hp q b).2.1) (fun q => (hp q a).1) (fun q => (hp q b).1) + (fun q => (hp q a).2.2) (fun q => (hp q b).2.2) + apply he.trans + rw [NNReal.coe_sum, Finset.sum_mul] + apply Finset.sum_le_sum + intro q _ + exact affineSelectedJetDensity_l1_regular (s q) (A q) (F q) (e q) input z hz (rows q) + (hd q) (c q) (w q) (hw q) (hδ q) (hwidth q) (R q) (hsupport q) a ha b hb + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineUnitSource.lean b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineUnitSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0680c5eab59414bec36c6b72dd5e28de7ebdfaf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/JointAffineUnitSource.lean @@ -0,0 +1,141 @@ +import OAI.Combinatorics.Progressions.Estimates.SelectedSplitUnitSource + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +noncomputable def affineJetUnitMap {Z X K α I J N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : I → Finset α) (c w : J ⊕ N → ℝ) (x : X → ℝ) (r : J ⊕ N → ℝ) : I → ℝ := + A (fun i => c (.inl (s i))+w (.inl (s i))*r (.inl (s i))) + + F (fun j => c (.inl j.val)+w (.inl j.val)*r (.inl j.val)) + + polynomialColumns (fun o n => normalizedJetColumn (e n) input z (rows o)) x + (fun n => c (.inr n)+w (.inr n)*r (.inr n)) + +theorem affineJetUnitMap_measurable_comp {Ω Z X K α I J N : Type*} [MeasurableSpace Ω] + [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (rows : I → Finset α) + (c w r : Ω → J ⊕ N → ℝ) (hc : Measurable c) (hw : Measurable w) (hr : Measurable r) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (x : Ω → X → ℝ) (hx : ∀ j, Measurable (fun a => x a j)) : + Measurable (fun a => affineJetUnitMap s A F e input (z a) rows (c a) (w a) (x a) (r a)) := by + have htail := normalizedJetColumns_measurable_comp e input rows z hz x hx + (fun a n => c a (.inr n)+w a (.inr n)*r a (.inr n)) (fun _ => by fun_prop) + have hker : Measurable (fun a => + A (fun i => c a (.inl (s i))+w a (.inl (s i))*r a (.inl (s i))) + + F (fun j => c a (.inl j.val)+w a (.inl j.val)*r a (.inl j.val))) := by fun_prop + exact hker.add htail + +theorem affineSelectedJetDensity_unit_law {Z X K α I J N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [Fintype J] [Fintype N] + (s : I ↪ J) (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) + (F : (UnselectedColumn s → ℝ) →L[ℝ] (I → ℝ)) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : I → Finset α) (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) + (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) (x : X → ℝ) : + (realDensityMeasure volume (smoothProductProfile (J ⊕ N))).map + (affineJetUnitMap s A F e input z rows c w x) = + realDensityMeasure volume (affineSelectedJetDensity s A F e input z rows c w x) := by + let C := polynomialColumns (fun o n => normalizedJetColumn (e n) input z (rows o)) x + let H := fun p : (UnselectedColumn s ⊕ N → ℝ) × (I → ℝ) => A p.2+splitFreeColumns F C p.1 + have hH : Measurable H := by fun_prop + have he : affineJetUnitMap s A F e input z rows c w x = + H ∘ (fun r => (selectedSplitMeasurableEquiv s).symm (fun j => c j+w j*r j)) := by + funext r + simp only [Function.comp_def, selectedSplitMeasurableEquiv_symm_apply, + H, splitFreeColumns_apply, affineJetUnitMap, add_assoc, C, Sum.elim_inl, Sum.elim_inr] + have hinput : Measurable (fun r : J ⊕ N → ℝ => + (selectedSplitMeasurableEquiv s).symm (fun j => c j+w j*r j)) := + (selectedSplitMeasurableEquiv s).symm.measurable.comp (by fun_prop) + rw [he, ← Measure.map_map hH hinput, selectedSplit_unit_law s c w hw] + have hp := affineSelectedJetProfile_probability_data s c w hw R hsupport + exact pivotOutputDensity_law A (splitFreeColumns F C) hp.1 hp.2.1 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +noncomputable def jointUnitCoefficientSource {Q : Type*} [Fintype Q] + (J N : Q → Type*) [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] : + Measure (∀ q, J q ⊕ N q → ℝ) := Measure.pi (fun q => unitCoefficientSource (J q ⊕ N q)) + +instance jointUnitCoefficientSource_probability {Q : Type*} [Fintype Q] + (J N : Q → Type*) [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] : + IsProbabilityMeasure (jointUnitCoefficientSource J N) := by + unfold jointUnitCoefficientSource + infer_instance + +noncomputable def jointAffineJetUnitMap {Q Z X K α : Type*} + [Fintype Q] [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) + (x : X → ℝ) (r : ∀ q, J q ⊕ N q → ℝ) : ∀ q, I q → ℝ := + fun q => affineJetUnitMap (s q) (A q) (F q) (e q) input z (rows q) (c q) (w q) x (r q) + +theorem jointAffineJetUnitMap_measurable_comp {Ω Q Z X K α : Type*} [MeasurableSpace Ω] + [Fintype Q] [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (rows : ∀ q, I q → Finset α) + (c w r : Ω → ∀ q, J q ⊕ N q → ℝ) + (hc : ∀ q, Measurable (fun a => c a q)) (hw : ∀ q, Measurable (fun a => w a q)) + (hr : ∀ q, Measurable (fun a => r a q)) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (x : Ω → X → ℝ) (hx : ∀ j, Measurable (fun a => x a j)) : + Measurable (fun a => jointAffineJetUnitMap s A F e input (z a) rows (c a) (w a) (x a) (r a)) := by + apply Measurable.of_eval + intro q + exact affineJetUnitMap_measurable_comp (s q) (A q) (F q) (e q) input (rows q) + (fun a => c a q) (fun a => w a q) (fun a => r a q) (hc q) (hw q) (hr q) z hz x hx + +theorem jointAffineJetDensity_unit_law {Q Z X K α : Type*} + [Fintype Q] [Fintype α] [DecidableEq α] {I J N : Q → Type*} + [∀ q, Fintype (I q)] [∀ q, Fintype (J q)] [∀ q, Fintype (N q)] + (s : ∀ q, I q ↪ J q) (A : ∀ q, (I q → ℝ) ≃L[ℝ] (I q → ℝ)) + (F : ∀ q, (UnselectedColumn (s q) → ℝ) →L[ℝ] (I q → ℝ)) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : ∀ q, I q → Finset α) (c w : ∀ q, J q ⊕ N q → ℝ) (hw : ∀ q j, 0 < w q j) + (R : Q → ℝ≥0) (hsupport : ∀ q j, |c q j|+w q j ≤ R q) (x : X → ℝ) : + (jointUnitCoefficientSource J N).map (jointAffineJetUnitMap s A F e input z rows c w x) = + realDensityMeasure volume (jointAffineJetDensity s A F e input z rows c w x) := by + have hm (q) : Measurable (affineJetUnitMap (s q) (A q) (F q) (e q) input z (rows q) (c q) (w q) x) := + affineJetUnitMap_measurable_comp (s q) (A q) (F q) (e q) input (rows q) + (fun _ => c q) (fun _ => w q) id measurable_const measurable_const measurable_id + (fun _ => z) (fun _ => measurable_const) (fun _ => x) (fun _ => measurable_const) + unfold jointUnitCoefficientSource jointAffineJetUnitMap + rw [Measure.pi_map_pi (fun q => (hm q).aemeasurable)] + have hlaw (q) := affineSelectedJetDensity_unit_law (s q) (A q) (F q) (e q) input z + (rows q) (c q) (w q) (hw q) (R q) (hsupport q) x + change (Measure.pi (fun q => (realDensityMeasure volume (smoothProductProfile (J q ⊕ N q))).map _)) = _ + simp_rw [hlaw] + have hp (q) := affineSelectedJetProfile_probability_data (s q) (c q) (w q) (hw q) (R q) (hsupport q) + exact realDensityMeasure_pi (fun _ => volume) _ + (fun q => pivotOutputDensity_integrable (A q) _ (hp q).1) + (fun q => pivotOutputDensity_nonneg (A q) _ (hp q).2.1) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/JointIntegerNormalization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/JointIntegerNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..798f3b31bd5f37c442db81bdb84aae8635073125 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/JointIntegerNormalization.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.Progressions.Sampling.JointGridAccuracy + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem jointIntegerImageMass_total {D : Type*} [Fintype D] [DecidableEq D] + {X J : D → Type*} [∀ d, Fintype (X d)] [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] + (p : ∀ d, FiniteProbabilityWeights (X d)) (Y : ∀ d, X d → J d → ℤ) + (H : D → ℝ) (K : D → ℕ) [∀ d, NeZero (K d)] (hH : ∀ d, 0 ≤ H d) + (center : ∀ d, J d → ℤ) + (hY : ∀ d x, (p d).weight x ≠ 0 → ∀ j, |(Y d x j : ℝ) - center d j| ≤ H d * K d) : + (∑ r : ∀ d, J d → ZMod ((2 * commonSupportRadius H + 1) * K d), + finiteImageMass (FiniteProbabilityWeights.pi p) (fun x d => Y d (x d)) + (fun d => centeredGridRepresentative (commonSupportRadius H) (K d) (center d) (r d))) = 1 := by + have hK (d) : 0 < K d := Nat.pos_of_ne_zero (NeZero.ne (K d)) + let scale := ∏ d, (K d : ℝ) ^ Fintype.card (J d) + have hp : 0 < scale := Finset.prod_pos (fun d _ => pow_pos (by exact_mod_cast hK d) _) + have he : scale * (∑ r : ∀ d, J d → ZMod ((2 * commonSupportRadius H + 1) * K d), + finiteImageMass (FiniteProbabilityWeights.pi p) (fun x d => Y d (x d)) + (fun d => centeredGridRepresentative (commonSupportRadius H) (K d) (center d) (r d))) = scale := by + rw [Finset.mul_sum] + calc + _ = ∑ r : ∀ d, J d → ZMod ((2 * commonSupportRadius H + 1) * K d), ∏ d, + integerGridDensity (p d) (Y d) (K d) ((2 * commonSupportRadius H + 1) * K d) + (centeredGridRepresentative (commonSupportRadius H) (K d) (center d) (r d)) := by + apply Finset.sum_congr rfl + intro r _ + exact jointImageMass_at_representatives p Y H K hK hH center hY r + _ = scale := jointGridDensity_total p Y _ K center + exact (mul_left_cancel₀ hp.ne' (he.trans (mul_one scale).symm)) + +theorem commonTorusFactor_uniform {D : Type*} [Fintype D] (H : D → ℝ) + {C : ℝ} (hH : ∀ d, 0 ≤ H d) (hC : ∀ d, H d ≤ C) : + ((2 * commonSupportRadius H + 1 : ℕ) : ℝ) ≤ 2 * Fintype.card D * C + 3 := by + have h := commonSupportRadius_uniform H hH hC + push_cast + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LargestBadPrimeProduct.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LargestBadPrimeProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2c8032fbcf9c91ea54760a1c4b7bd104cad531b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LargestBadPrimeProduct.lean @@ -0,0 +1,171 @@ +import Mathlib.Data.Nat.Factorization.Basic +import Mathlib.Data.Nat.Log + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem selected_primePower_factorization (T : Finset ℕ) (a : ℕ → ℕ) + (hprime : ∀ p ∈ T, Nat.Prime p) (p : ℕ) : + (∏ q ∈ T, q ^ a q).factorization p = if p ∈ T then a p else 0 := by + rw [Nat.factorization_prod_apply (fun q hq => pow_ne_zero _ (hprime q hq).ne_zero)] + calc + ∑ q ∈ T, (q ^ a q).factorization p = + ∑ q ∈ T, if p = q then a q else 0 := by + apply Finset.sum_congr rfl + intro q hq + rw [(hprime q hq).factorization_pow] + simp only [Finsupp.single_apply, eq_comm] + _ = _ := by simp + +theorem selected_primePower_primeFactors (T : Finset ℕ) (a : ℕ → ℕ) + (hprime : ∀ p ∈ T, Nat.Prime p) (ha : ∀ p ∈ T, 0 < a p) : + (∏ p ∈ T, p ^ a p).primeFactors = T := by + ext p + rw [← Nat.support_factorization, Finsupp.mem_support_iff, + selected_primePower_factorization T a hprime] + by_cases hp : p ∈ T + · simp only [hp, ↓reduceIte, iff_true] + exact (ha p hp).ne' + · simp only [hp, ↓reduceIte, ne_eq, not_true_eq_false] + +theorem selected_primePower_factorization_of_mem (T : Finset ℕ) (a : ℕ → ℕ) + (hprime : ∀ p ∈ T, Nat.Prime p) {p : ℕ} (hp : p ∈ T) : + (∏ q ∈ T, q ^ a q).factorization p = a p := by + rw [selected_primePower_factorization T a hprime, ite_eq_left hp] + +def badPrimeModulusEvent {Ω : Type*} (S : Finset ℕ) (A : ℕ → ℕ) (Qs : ℕ) + (bad : ℕ → ℕ → Ω → Prop) (d : ℕ) (x : Ω) : Prop := + (∀ p ∈ d.primeFactors, p ∈ S ∧ 0 < d.factorization p ∧ + d.factorization p ≤ A p ∧ Qs ≤ p ^ d.factorization p) ∧ + (∀ p ∈ d.primeFactors, bad p (d.factorization p) x) + +theorem selected_primePower_badPrimeModulusEvent {Ω : Type*} + (S T : Finset ℕ) (A a : ℕ → ℕ) (Qs : ℕ) (bad : ℕ → ℕ → Ω → Prop) + (x : Ω) (hprime : ∀ p ∈ T, Nat.Prime p) (hTS : T ⊆ S) + (ha : ∀ p ∈ T, 0 < a p) (hA : ∀ p ∈ T, a p ≤ A p) + (hQs : ∀ p ∈ T, Qs ≤ p ^ a p) (hbad : ∀ p ∈ T, bad p (a p) x) : + badPrimeModulusEvent S A Qs bad (∏ p ∈ T, p ^ a p) x := by + constructor + · intro p hp + have hpT : p ∈ T := by rwa [selected_primePower_primeFactors T a hprime ha] at hp + rw [selected_primePower_factorization_of_mem T a hprime hpT] + exact ⟨hTS hpT, ha p hpT, hA p hpT, hQs p hpT⟩ + · intro p hp + have hpT : p ∈ T := by rwa [selected_primePower_primeFactors T a hprime ha] at hp + rw [selected_primePower_factorization_of_mem T a hprime hpT] + exact hbad p hpT + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +noncomputable def largestTestedBadDepth {Ω : Type*} (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) (p : ℕ) (x : Ω) : ℕ := + ((Finset.Icc 1 (A p)).filter (fun a => bad p a x)).sup id + +theorem largestTestedBadDepth_le {Ω : Type*} (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) (p : ℕ) (x : Ω) : + largestTestedBadDepth A bad p x ≤ A p := by + exact Finset.sup_le (fun _ ha => (Finset.mem_Icc.mp (Finset.mem_filter.mp ha).1).2) + +theorem largestTestedBadDepth_bad {Ω : Type*} (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) (p : ℕ) (x : Ω) + (hpos : 0 < largestTestedBadDepth A bad p x) : + bad p (largestTestedBadDepth A bad p x) x := by + obtain ⟨a, ha, hle⟩ := (Finset.le_sup_iff hpos).mp + (le_refl (largestTestedBadDepth A bad p x)) + have hge : a ≤ largestTestedBadDepth A bad p x := Finset.le_sup (f := id) ha + have heq : a = largestTestedBadDepth A bad p x := le_antisymm hge hle + exact heq ▸ (Finset.mem_filter.mp ha).2 + +noncomputable def smallPrimePowerCorrection (Qs : ℕ) : ℕ := + ∏ p ∈ (Finset.range Qs).filter Nat.Prime, p ^ Nat.log p (Qs - 1) + +theorem prime_power_small_correction (S : Finset ℕ) (b : ℕ → ℕ) {Qs : ℕ} + (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) : + (∏ p ∈ S, p ^ b p) ≤ smallPrimePowerCorrection Qs * + ∏ p ∈ S, (if Qs ≤ p ^ b p then p ^ b p else 1) := by + let small := (Finset.range Qs).filter Nat.Prime + let g := fun p => p ^ Nat.log p (Qs - 1) + have hg (p) (hp : p.Prime) : 1 ≤ g p := one_le_pow₀ hp.one_le + have hlocal (p) (hp : p ∈ S) : p ^ b p ≤ g p * (if Qs ≤ p ^ b p then p ^ b p else 1) := by + by_cases hlarge : Qs ≤ p ^ b p + · simp only [hlarge, ite_true] + simpa only [one_mul] using Nat.mul_le_mul_right (p ^ b p) (hg p (hprime p hp)) + · simp only [hlarge, ite_false, mul_one] + exact Nat.pow_le_pow_right (hprime p hp).pos + (Nat.le_log_of_pow_le (hprime p hp).one_lt (by omega)) + have hout (p) (hp : p ∈ S ∪ small) (hnot : p ∉ small) : g p = 1 := by + have hpp : p.Prime := by + rcases Finset.mem_union.mp hp with hp | hp + · exact hprime p hp + · exact (Finset.mem_filter.mp hp).2 + have hcut : Qs ≤ p := by + by_contra h + exact hnot (Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (by omega), hpp⟩) + dsimp only [g] + rw [Nat.log_eq_zero_iff.mpr (Or.inl (by omega)), pow_zero] + have hbase : (∏ p ∈ S, g p) ≤ smallPrimePowerCorrection Qs := by + calc + _ ≤ ∏ p ∈ S ∪ small, g p := + Finset.prod_le_prod_of_subset_of_one_le Finset.subset_union_left (fun p hp _ => by + apply hg + rcases Finset.mem_union.mp hp with hp | hp + · exact hprime p hp + · exact (Finset.mem_filter.mp hp).2) + _ = ∏ p ∈ small, g p := (Finset.prod_subset Finset.subset_union_right hout).symm + _ = _ := rfl + calc + _ ≤ ∏ p ∈ S, g p * (if Qs ≤ p ^ b p then p ^ b p else 1) := + Finset.prod_le_prod hlocal + _ = (∏ p ∈ S, g p) * ∏ p ∈ S, (if Qs ≤ p ^ b p then p ^ b p else 1) := + Finset.prod_mul_distrib + _ ≤ _ := Nat.mul_le_mul_right _ hbase + +theorem largestBadPrime_large_valid {Ω : Type*} (S : Finset ℕ) (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) (x : Ω) {Qs p : ℕ} (hQs : 2 ≤ Qs) + (_hp : p ∈ S) (hlarge : Qs ≤ p ^ largestTestedBadDepth A bad p x) : + 0 < largestTestedBadDepth A bad p x ∧ + largestTestedBadDepth A bad p x ≤ A p ∧ + bad p (largestTestedBadDepth A bad p x) x := by + have hb : 0 < largestTestedBadDepth A bad p x := by + by_contra hn + have heq : largestTestedBadDepth A bad p x = 0 := by omega + simp only [heq, pow_zero] at hlarge + omega + exact ⟨hb, largestTestedBadDepth_le A bad p x, largestTestedBadDepth_bad A bad p x hb⟩ + +theorem largestBadPrime_subproduct_modulus_event {Ω : Type*} + (S T : Finset ℕ) (A : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) + (x : Ω) {Qs : ℕ} (hQs : 2 ≤ Qs) (hprime : ∀ p ∈ S, p.Prime) (hTS : T ⊆ S) : + badPrimeModulusEvent S A Qs bad + (∏ p ∈ T, if Qs ≤ p ^ largestTestedBadDepth A bad p x then + p ^ largestTestedBadDepth A bad p x else 1) x := by + let U := T.filter (fun p => Qs ≤ p ^ largestTestedBadDepth A bad p x) + have hUS : U ⊆ S := (Finset.filter_subset _ _).trans hTS + have hvalid (p) (hp : p ∈ U) := largestBadPrime_large_valid S A bad x hQs + (hUS hp) (Finset.mem_filter.mp hp).2 + have heq : (∏ p ∈ T, if Qs ≤ p ^ largestTestedBadDepth A bad p x then + p ^ largestTestedBadDepth A bad p x else 1) = + ∏ p ∈ U, p ^ largestTestedBadDepth A bad p x := (Finset.prod_filter _ _).symm + rw [heq] + exact selected_primePower_badPrimeModulusEvent S U A + (fun p => largestTestedBadDepth A bad p x) Qs bad x + (fun p hp => hprime p (hUS hp)) hUS (fun p hp => (hvalid p hp).1) + (fun p hp => (hvalid p hp).2.1) (fun _ hp => (Finset.mem_filter.mp hp).2) + (fun p hp => (hvalid p hp).2.2) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeCoordinateLifts.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeCoordinateLifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4726b0d10cef27b3eade554327178466c4e9f80 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeCoordinateLifts.lean @@ -0,0 +1,340 @@ +import Mathlib.Algebra.Module.ZLattice.Covolume +import Mathlib.Data.ZMod.Basic +import Mathlib.GroupTheory.OrderOfElement +import OAI.Combinatorics.Progressions.Estimates.MinkowskiSecondInduction +import OAI.Combinatorics.Progressions.Lattices.FiniteLatticeBasis +import OAI.Combinatorics.Progressions.Linear.BasisImageSection +import OAI.Combinatorics.Progressions.Linear.MatrixSupInverse +import OAI.Combinatorics.Progressions.Sampling.RationalSpanGrid + +namespace OAI + +section + +namespace Erdos3 + +open Module MeasureTheory + +variable {ι : Type*} [Fintype ι] + +noncomputable def integerCoordinateLattice : Submodule ℤ (ι → ℝ) := + Submodule.span ℤ (Set.range (Pi.basisFun ℝ ι)) + +instance integerCoordinateLattice_discrete : + DiscreteTopology (integerCoordinateLattice (ι := ι)) := + inferInstanceAs (DiscreteTopology (Submodule.span ℤ (Set.range (Pi.basisFun ℝ ι)))) + +instance integerCoordinateLattice_full : IsZLattice ℝ (integerCoordinateLattice (ι := ι)) := + inferInstanceAs (IsZLattice ℝ (Submodule.span ℤ (Set.range (Pi.basisFun ℝ ι)))) + +theorem mem_integerCoordinateLattice_iff (x : ι → ℝ) : + x ∈ integerCoordinateLattice ↔ x ∈ realIntegerGrid := by + change x ∈ Submodule.span ℤ (Set.range (Pi.basisFun ℝ ι)) ↔ _ + rw [(Pi.basisFun ℝ ι).mem_span_iff_repr_mem ℤ x] + constructor + · intro hx + have h : ∀ i, ∃ n : ℤ, (n : ℝ) = x i := by + intro i + simpa using hx i + choose z hz using h + exact ⟨z, funext hz⟩ + · rintro ⟨z, hz⟩ i + exact ⟨z i, by simpa using congrFun hz i⟩ + +theorem integerCoordinateLattice_covolume : + ZLattice.covolume (integerCoordinateLattice (ι := ι)) = 1 := by + change ZLattice.covolume (Submodule.span ℤ (Set.range (Pi.basisFun ℝ ι))) = 1 + rw [ZLattice.covolume_eq_measure_fundamentalDomain _ volume + (ZSpan.isAddFundamentalDomain (Pi.basisFun ℝ ι) volume), measureReal_def] + have hv : volume (ZSpan.fundamentalDomain (Pi.basisFun ℝ ι)) = 1 := by + rw [ZSpan.fundamentalDomain_pi_basisFun, volume_pi, Measure.pi_pi] + simp only [Real.volume_Ico, sub_zero, ENNReal.ofReal_one, Finset.prod_const_one] + rw [hv] + simp + +theorem integer_lattice_covolume_eq_index + (L : Submodule ℤ (ι → ℝ)) [DiscreteTopology L] [IsZLattice ℝ L] + (hL : L ≤ integerCoordinateLattice) : + ZLattice.covolume L = L.toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup := by + have h := ZLattice.covolume_div_covolume_eq_relIndex L integerCoordinateLattice hL + simpa only [integerCoordinateLattice_covolume, div_one] using h + +theorem integer_lattice_index_pos + (L : Submodule ℤ (ι → ℝ)) [DiscreteTopology L] [IsZLattice ℝ L] + (hL : L ≤ integerCoordinateLattice) : + 0 < L.toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup := by + have h := ZLattice.covolume_pos L volume + rw [integer_lattice_covolume_eq_index L hL] at h + exact_mod_cast h + +theorem integer_lattice_index_nsmul_mem (L : Submodule ℤ (ι → ℝ)) + (x : ι → ℝ) (hx : x ∈ realIntegerGrid) : + L.toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup • x ∈ L := + L.toAddSubgroup.nsmul_relIndex_mem ((mem_integerCoordinateLattice_iff x).mpr hx) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {ι : Type*} + +def integerVectorRealMap : (ι → ℤ) →ₗ[ℤ] (ι → ℝ) where + toFun x i := (x i : ℝ) + map_add' x y := by ext i; simp + map_smul' a x := by ext i; simp + +theorem integerVectorRealMap_injective : + Function.Injective (integerVectorRealMap (ι := ι)) := by + intro x y h + ext i + exact Int.cast_injective (congrFun h i) + +variable [Fintype ι] {N : ℕ} + +noncomputable def integerVectorRealEquiv : + (ι → ℤ) ≃ₗ[ℤ] (integerCoordinateLattice (ι := ι)) := + LinearEquiv.ofBijective + (integerVectorRealMap.codRestrict integerCoordinateLattice (fun x => + (mem_integerCoordinateLattice_iff _).mpr ⟨x, rfl⟩)) + ⟨fun _ _ h => integerVectorRealMap_injective (congrArg Subtype.val h), by + intro y + obtain ⟨x, hx⟩ := (mem_integerCoordinateLattice_iff _).mp y.property + exact ⟨x, Subtype.ext hx⟩⟩ + +def cyclicIntegerKernel (η : (ι → ℤ) →+ ZMod N) : Submodule ℤ (ι → ℝ) := + (LinearMap.ker η.toIntLinearMap).map integerVectorRealMap + +omit [Fintype ι] in +theorem mem_cyclicIntegerKernel (η : (ι → ℤ) →+ ZMod N) (y : ι → ℝ) : + y ∈ cyclicIntegerKernel η ↔ ∃ x : ι → ℤ, η x = 0 ∧ integerVectorRealMap x = y := + Iff.rfl + +omit [Fintype ι] in +theorem integerVectorRealMap_mem_cyclicIntegerKernel + (η : (ι → ℤ) →+ ZMod N) (x : ι → ℤ) : + integerVectorRealMap x ∈ cyclicIntegerKernel η ↔ η x = 0 := by + constructor + · rintro ⟨y, hy, he⟩ + exact integerVectorRealMap_injective he ▸ hy + · intro hx + exact ⟨x, hx, rfl⟩ + +theorem cyclicIntegerKernel_le_integerCoordinateLattice + (η : (ι → ℤ) →+ ZMod N) : cyclicIntegerKernel η ≤ integerCoordinateLattice := by + rintro y ⟨x, _, rfl⟩ + exact (mem_integerCoordinateLattice_iff _).mpr ⟨x, rfl⟩ + +instance cyclicIntegerKernel_discrete (η : (ι → ℤ) →+ ZMod N) : + DiscreteTopology (cyclicIntegerKernel η) := by + apply isDiscrete_iff_discreteTopology.mp + apply isDiscrete_realIntegerGrid.mono + intro y hy + exact (mem_integerCoordinateLattice_iff _).mp + (cyclicIntegerKernel_le_integerCoordinateLattice η hy) + +omit [Fintype ι] in +theorem nsmul_integerVectorRealMap_mem_cyclicIntegerKernel + (η : (ι → ℤ) →+ ZMod N) (x : ι → ℤ) : + N • integerVectorRealMap x ∈ cyclicIntegerKernel η := by + rw [← map_nsmul, integerVectorRealMap_mem_cyclicIntegerKernel, map_nsmul] + simp [nsmul_eq_mul] + +instance cyclicIntegerKernel_full [NeZero N] (η : (ι → ℤ) →+ ZMod N) : + IsZLattice ℝ (cyclicIntegerKernel η) := by + classical + constructor + apply top_unique + rw [← (Pi.basisFun ℝ ι).span_eq] + apply Submodule.span_le.mpr + rintro y ⟨i, rfl⟩ + have hmem := nsmul_integerVectorRealMap_mem_cyclicIntegerKernel η (Pi.single i 1) + have hcast : integerVectorRealMap (Pi.single i (1 : ℤ)) = Pi.basisFun ℝ ι i := by + ext j + simp [integerVectorRealMap, Pi.basisFun_apply, Pi.single_apply] + rw [hcast] at hmem + have hmemR : (N : ℝ) • Pi.basisFun ℝ ι i ∈ cyclicIntegerKernel η := by + rw [Nat.cast_smul_eq_nsmul] + exact hmem + have hspan : (N : ℝ) • Pi.basisFun ℝ ι i ∈ + Submodule.span ℝ (cyclicIntegerKernel η : Set (ι → ℝ)) := Submodule.subset_span hmemR + have hscale := (Submodule.span ℝ (cyclicIntegerKernel η : Set (ι → ℝ))).smul_mem + ((N : ℝ)⁻¹) hspan + have hN : (N : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne N) + rw [smul_smul, inv_mul_cancel₀ hN, one_smul] at hscale + exact hscale + +theorem cyclicIntegerKernel_covolume_eq_card_range [NeZero N] + (η : (ι → ℤ) →+ ZMod N) : + ZLattice.covolume (cyclicIntegerKernel η) = (Nat.card η.range : ℝ) := by + classical + rw [integer_lattice_covolume_eq_index _ (cyclicIntegerKernel_le_integerCoordinateLattice η)] + have hindex : (cyclicIntegerKernel η).toAddSubgroup.relIndex + integerCoordinateLattice.toAddSubgroup = Nat.card η.range := by + let e := (integerVectorRealEquiv (ι := ι)).toAddEquiv.toAddMonoidHom + let H := (cyclicIntegerKernel η).toAddSubgroup.addSubgroupOf + (integerCoordinateLattice (ι := ι)).toAddSubgroup + have he : H.comap e = η.ker := by + ext x + exact integerVectorRealMap_mem_cyclicIntegerKernel η x + change H.index = Nat.card η.range + rw [← H.index_comap_of_surjective (f := e) (integerVectorRealEquiv (ι := ι)).surjective, + he, AddSubgroup.index_ker] + exact_mod_cast hindex + +theorem cyclicIntegerKernel_covolume_le [NeZero N] + (η : (ι → ℤ) →+ ZMod N) : + ZLattice.covolume (cyclicIntegerKernel η) ≤ (N : ℝ) := by + rw [cyclicIntegerKernel_covolume_eq_card_range] + have h := Nat.card_le_card_of_injective (fun x : η.range => (x : ZMod N)) + Subtype.val_injective + have hcard : Nat.card (ZMod N) = N := by simp + rw [hcard] at h + exact_mod_cast h + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [Fintype ι] + (Λ : Submodule ℤ E) (π : E →ₗ[ℝ] (ι → ℝ)) + +def latticeImage : Submodule ℤ (ι → ℝ) := Λ.map (π.restrictScalars ℤ) + +theorem latticeImage_le_integer (hπ : ∀ x ∈ Λ, π x ∈ realIntegerGrid) : + latticeImage Λ π ≤ integerCoordinateLattice := by + rintro y ⟨x, hx, rfl⟩ + exact (mem_integerCoordinateLattice_iff _).mpr (hπ x hx) + +theorem latticeImage_discrete (hπ : ∀ x ∈ Λ, π x ∈ realIntegerGrid) : + DiscreteTopology (latticeImage Λ π) := by + apply isDiscrete_iff_discreteTopology.mp + apply isDiscrete_realIntegerGrid.mono + intro y hy + exact (mem_integerCoordinateLattice_iff y).mp (latticeImage_le_integer Λ π hπ hy) + +theorem latticeImage_full [DiscreteTopology Λ] [IsZLattice ℝ Λ] + [DiscreteTopology (latticeImage Λ π)] (hπ : Function.Surjective π) : + IsZLattice ℝ (latticeImage Λ π) := by + constructor + change Submodule.span ℝ (π '' (Λ : Set E)) = ⊤ + rw [Submodule.span_image, IsZLattice.span_top, Submodule.map_top] + exact LinearMap.range_eq_top.mpr hπ + +theorem latticeImage_index_lift (x : ι → ℝ) (hx : x ∈ realIntegerGrid) : + ∃ y ∈ Λ, π y = (latticeImage Λ π).toAddSubgroup.relIndex + integerCoordinateLattice.toAddSubgroup • x := by + exact integer_lattice_index_nsmul_mem (latticeImage Λ π) x hx + +theorem latticeImage_index_pos [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (hinteger : ∀ x ∈ Λ, π x ∈ realIntegerGrid) (hsurj : Function.Surjective π) : + 0 < (latticeImage Λ π).toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup := by + let : DiscreteTopology (latticeImage Λ π) := latticeImage_discrete Λ π hinteger + let : IsZLattice ℝ (latticeImage Λ π) := latticeImage_full Λ π hsurj + exact integer_lattice_index_pos (latticeImage Λ π) (latticeImage_le_integer Λ π hinteger) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module BohrLattice.MinkowskiDiagonalNormalization +open scoped BigOperators Matrix + +theorem lattice_basis_coordinates_bound + {r : ℕ} (Λ : Submodule ℤ (Fin r → ℝ)) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (b : Basis (Fin r) ℤ Λ) (ρ : Fin r → ℝ) (hρ : ∀ j, 0 < ρ j) + {H : ℝ} (hH : 0 ≤ H) (hb : ∀ i j, |(b i : Fin r → ℝ) j| ≤ H * ρ j) + (hcov : (∏ j, ρ j) ≤ ZLattice.covolume Λ) + (x : Fin r → ℝ) (hx : ∀ j, |x j| ≤ ρ j) (i : Fin r) : + |(b.ofZLatticeBasis ℝ Λ).equivFun x i| ≤ + (r : ℝ) * r.factorial * H ^ (r - 1) := by + classical + let B := b.ofZLatticeBasis ℝ Λ + let M : Matrix (Fin r) (Fin r) ℝ := fun i j => B j i / ρ i + have hM : M = (Matrix.of (normalizedBasis B ρ hρ))ᵀ := by + ext i j + simp [M] + have hB : |(Matrix.of B).det| = ZLattice.covolume Λ := by + have he : (B : Fin r → Fin r → ℝ) = fun j => (b j : Fin r → ℝ) := + funext (fun j => Basis.ofZLatticeBasis_apply ℝ Λ b j) + rw [he] + exact (ZLattice.covolume_eq_det Λ b).symm + have hprod : 0 < ∏ j, ρ j := Finset.prod_pos (fun j _ => hρ j) + have hdet : 1 ≤ |M.det| := by + rw [hM, Matrix.det_transpose, abs_det_normalizedBasis, hB, ← div_eq_mul_inv] + exact (le_div_iff₀ hprod).mpr (by simpa using hcov) + have hentry : ∀ j k, |M j k| ≤ H := by + intro j k + change |B k j / ρ j| ≤ H + rw [abs_div, abs_of_pos (hρ j)] + apply (div_le_iff₀ (hρ j)).mpr + simpa only [B, Basis.ofZLatticeBasis_apply] using hb k j + have hinv : ∀ j k, |M⁻¹ j k| ≤ (r.factorial : ℝ) * H ^ (r - 1) := by + intro j k + simpa only [Fintype.card_fin, div_one] using + matrix_inverse_entry_abs_le M hentry (by norm_num : (0 : ℝ) < 1) hdet j k + have hMx : M.mulVec (B.equivFun x) = fun j => x j / ρ j := by + exact basis_coordinate_matrix_mulVec B (divideCoordinates ρ hρ).toLinearMap x + have hback : M⁻¹.mulVec (fun j => x j / ρ j) = B.equivFun x := by + rw [← hMx, Matrix.mulVec_mulVec, Matrix.nonsing_inv_mul _ + (isUnit_iff_ne_zero.mpr (abs_pos.mp (lt_of_lt_of_le zero_lt_one hdet))), Matrix.one_mulVec] + have hsmall (j) : |x j / ρ j| ≤ 1 := by + rw [abs_div, abs_of_pos (hρ j)] + exact (div_le_one (hρ j)).mpr (hx j) + change |B.equivFun x i| ≤ _ + rw [← hback] + change |∑ j, M⁻¹ i j * (x j / ρ j)| ≤ _ + calc + _ ≤ ∑ j, |M⁻¹ i j * (x j / ρ j)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : Fin r, (r.factorial : ℝ) * H ^ (r - 1) := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + have h := mul_le_mul (hinv i j) (hsmall j) (abs_nonneg _) (by positivity) + simpa only [mul_one] using h + _ = _ := by simp [mul_assoc] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem basisFun_mem_realIntegerGrid {ι : Type*} [Fintype ι] [DecidableEq ι] (i : ι) : + Pi.basisFun ℝ ι i ∈ realIntegerGrid := by + refine ⟨Pi.single i (1 : ℤ), ?_⟩ + funext j + simp [Pi.basisFun_apply, Pi.single_apply] + +theorem latticeImage_basis_lifts {E ι : Type*} + [NormedAddCommGroup E] [NormedSpace ℝ E] [Fintype ι] [DecidableEq ι] + (Λ : Submodule ℤ E) (π : E →ₗ[ℝ] (ι → ℝ)) : + let I := (latticeImage Λ π).toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup + ∀ i, ∃ x ∈ Λ, π x = (I : ℝ) • Pi.basisFun ℝ ι i := by + intro I i + obtain ⟨x, hx, hπx⟩ := latticeImage_index_lift Λ π (Pi.basisFun ℝ ι i) + (basisFun_mem_realIntegerGrid i) + refine ⟨x, hx, ?_⟩ + simpa only [Nat.cast_smul_eq_nsmul] using hπx + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeCoverMeasure.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeCoverMeasure.lean new file mode 100644 index 0000000000000000000000000000000000000000..d087a14374ef66c20447fdae13b0e0f374c1e29c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeCoverMeasure.lean @@ -0,0 +1,49 @@ +import Mathlib.Algebra.Module.ZLattice.Basic +import Mathlib.Analysis.Normed.Group.Quotient +import Mathlib.MeasureTheory.Measure.Haar.Unique +import OAI.Combinatorics.Progressions.Estimates.LinearQuotientCoverAverage + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] +variable (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + +theorem latticeQuotient_compact : CompactSpace (E ⧸ Λ.toAddSubgroup) := by + have hc := IsZLattice.isCompact_range_of_periodic Λ + (QuotientAddGroup.mk' Λ.toAddSubgroup) QuotientAddGroup.continuous_mk (by + intro x z hz + have hz0 : QuotientAddGroup.mk' Λ.toAddSubgroup z = 0 := + (QuotientAddGroup.eq_zero_iff z).mpr hz + rw [map_add, hz0, add_zero]) + rw [Set.range_eq_univ.mpr (QuotientAddGroup.mk'_surjective _)] at hc + exact ⟨hc⟩ + +variable [MeasurableSpace E] [BorelSpace E] + +theorem latticeCover_measurePreserving + (μ : Measure (E ⧸ Λ.toAddSubgroup)) [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] + (d : ℕ) (hd : 0 < d) : + MeasurePreserving (quotientIntegerCover Λ.toAddSubgroup d) μ μ := by + let : IsClosed (Λ.toAddSubgroup : Set E) := AddSubgroup.isClosed_of_discreteTopology + let : CompactSpace (E ⧸ Λ.toAddSubgroup) := latticeQuotient_compact Λ + let : BorelSpace (E ⧸ Λ.toAddSubgroup) := QuotientAddGroup.borelSpace + let : μ.IsAddHaarMeasure := + { toIsFiniteMeasureOnCompacts := inferInstance + toIsAddLeftInvariant := inferInstance + toIsOpenPosMeasure := isOpenPosMeasure_of_addLeftInvariant_of_compact + (μ := μ) Set.univ isCompact_univ (by simp) } + exact AddMonoidHom.measurePreserving + (quotientIntegerCover_continuous Λ.toAddSubgroup d) + (quotientIntegerCover_surjective Λ.toAddSubgroup d hd) rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeDensityL1.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeDensityL1.lean new file mode 100644 index 0000000000000000000000000000000000000000..b439af2540820473da4ddf243c9cc255a964dc9e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeDensityL1.lean @@ -0,0 +1,70 @@ +import OAI.Combinatorics.Progressions.Estimates.PartialComplexScaledQuadrature + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem densityDifference_lipschitz {X : Type*} [PseudoMetricSpace X] + {f g : X → ℝ} {Kf Kg : ℝ≥0} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) : + LipschitzWith (Kf+Kg) (fun x => |f x-g x|) := by + simpa only [one_mul, Function.comp_def, Real.norm_eq_abs] using lipschitzWith_one_norm.comp (hf.sub hg) + +theorem rectangular_density_l1_sum_le {J : Type*} [Fintype J] + (f g : (J → ℝ) → ℝ) {Kf Kg : ℝ≥0} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (a S : J → ℝ) (hS : ∀ j, 0 < S j) {R δ : ℝ} + (hR : 0 ≤ R) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ j, 1/S j ≤ δ) + (hfs : ∀ x, R < ‖x‖ → f x = 0) (hgs : ∀ x, R < ‖x‖ → g x = 0) : + (∑' k : J → ℤ, |f (rectangularLatticePoint a S k)-g (rectangularLatticePoint a S k)|)/(∏ j, S j) ≤ + (∫ x, |f x-g x|)+(2*R+2)^Fintype.card J*((Kf : ℝ)+Kg)*δ := by + have hs : ∀ x, R < ‖x‖ → |f x-g x| = 0 := by + intro x hx + rw [hfs x hx, hgs x hx, sub_self, abs_zero] + have he := rectangularLattice_quadrature (fun x => |f x-g x|) (densityDifference_lipschitz hf hg) + a S hS hR hδ hδ1 hmesh hs + have hu := (le_abs_self _).trans he + change _ ≤ (2*R+2)^Fintype.card J*((Kf : ℝ)+Kg)*δ at hu + linarith + +theorem rectangular_density_finite_l1_le {J : Type*} [Fintype J] + (f g : (J → ℝ) → ℝ) {Kf Kg : ℝ≥0} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (a S : J → ℝ) (hS : ∀ j, 0 < S j) {R δ : ℝ} + (hR : 0 ≤ R) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ j, 1/S j ≤ δ) + (hfs : ∀ x, R < ‖x‖ → f x = 0) (hgs : ∀ x, R < ‖x‖ → g x = 0) + (s : Finset (J → ℤ)) : + (∑ k ∈ s, |f (rectangularLatticePoint a S k)-g (rectangularLatticePoint a S k)|)/(∏ j, S j) ≤ + (∫ x, |f x-g x|)+(2*R+2)^Fintype.card J*((Kf : ℝ)+Kg)*δ := by + have hs : ∀ x, R < ‖x‖ → |f x-g x| = 0 := by + intro x hx + rw [hfs x hx, hgs x hx, sub_self, abs_zero] + have hsum := rectangularWeight_summable (fun x => |f x-g x|) a S hS hs + apply le_trans (div_le_div_of_nonneg_right + (hsum.sum_le_tsum s (fun _ _ => abs_nonneg _)) (Finset.prod_nonneg (fun j _ => (hS j).le))) + exact rectangular_density_l1_sum_le f g hf hg a S hS hR hδ hδ1 hmesh hfs hgs + +theorem scaled_density_l1_sum_le {J : Type*} [Fintype J] + (f g : (J → ℝ) → ℝ) {Kf Kg : ℝ≥0} (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (c T : J → ℝ) {m : ℝ} (hm : 0 < m) (hT : ∀ j, 0 < T j) {R δ : ℝ} + (hR : 0 ≤ R) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hmesh : ∀ j, m/T j ≤ δ) + (hfs : ∀ x, R < ‖x‖ → f x = 0) (hgs : ∀ x, R < ‖x‖ → g x = 0) : + (m^Fintype.card J/(∏ j, T j)) * + (∑' k : J → ℤ, |f (fun j => (c j+m*k j)/T j)-g (fun j => (c j+m*k j)/T j)|) ≤ + (∫ x, |f x-g x|)+(2*R+2)^Fintype.card J*((Kf : ℝ)+Kg)*δ := by + have hs : ∀ x, R < ‖x‖ → |f x-g x| = 0 := by + intro x hx + rw [hfs x hx, hgs x hx, sub_self, abs_zero] + have he := scaledRectangular_quadrature (fun x => |f x-g x|) (densityDifference_lipschitz hf hg) + c T hm hT hR hδ hδ1 hmesh hs + have hu := (le_abs_self _).trans he + change _ ≤ (2*R+2)^Fintype.card J*((Kf : ℝ)+Kg)*δ at hu + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeDualCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeDualCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..a37af9dc9dad83a10e2713f4faacc07be980967c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeDualCoordinates.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.Progressions.Fourier.MonomialCharacterMean + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + +noncomputable def latticeDualBasis (b : Basis ι ℤ Λ) : Basis ι ℝ E := by + classical + exact LinearMap.BilinForm.dualBasis (innerₗ E) realInner_nondegenerate (b.ofZLatticeBasis ℝ Λ) + +theorem euclideanDualLattice_eq_span (b : Basis ι ℤ Λ) : + euclideanDualLattice Λ = Submodule.span ℤ (Set.range (latticeDualBasis Λ b)) := by + classical + have h := LinearMap.BilinForm.dualSubmodule_span_of_basis (R := ℤ) (innerₗ E) + realInner_nondegenerate (b.ofZLatticeBasis ℝ Λ) + simpa only [euclideanDualLattice, latticeDualBasis, Basis.ofZLatticeBasis_span] using h + +noncomputable def latticeDualPoint (b : Basis ι ℤ Λ) (n : ι → ℤ) : E := + (latticeDualBasis Λ b).equivFun.symm (fun i => (n i : ℝ)) + +@[simp] +theorem latticeDualPoint_neg (b : Basis ι ℤ Λ) (n : ι → ℤ) : + latticeDualPoint Λ b (-n) = -latticeDualPoint Λ b n := by + simp only [latticeDualPoint, Pi.neg_apply, Int.cast_neg] + change (latticeDualBasis Λ b).equivFun.symm (-(fun i => (n i : ℝ))) = _ + exact map_neg _ _ + +theorem latticeDualPoint_inner_basis (b : Basis ι ℤ Λ) (n : ι → ℤ) (i : ι) : + inner ℝ (latticeDualPoint Λ b n) (b.ofZLatticeBasis ℝ Λ i) = (n i : ℝ) := by + have h := congrFun ((latticeDualBasis Λ b).equivFun.apply_symm_apply (fun j => (n j : ℝ))) i + simpa only [Basis.equivFun_apply, latticeDualBasis, latticeDualPoint, + LinearMap.BilinForm.dualBasis_repr_apply, innerₗ_apply_apply] using h + +theorem latticeDualPoint_mem (b : Basis ι ℤ Λ) (n : ι → ℤ) : + latticeDualPoint Λ b n ∈ euclideanDualLattice Λ := by + rw [euclideanDualLattice_eq_span Λ b, (latticeDualBasis Λ b).mem_span_iff_repr_mem ℤ] + intro i + refine ⟨n i, ?_⟩ + have h := congrFun ((latticeDualBasis Λ b).equivFun.apply_symm_apply (fun j => (n j : ℝ))) i + exact h.symm + +theorem latticeDualPoint_injective (b : Basis ι ℤ Λ) : Function.Injective (latticeDualPoint Λ b) := by + intro n m h + have he := congrArg (latticeDualBasis Λ b).equivFun h + simp only [latticeDualPoint, LinearEquiv.apply_symm_apply] at he + ext i + exact Int.cast_injective (congrFun he i) + +theorem latticeDualPoint_surjective (b : Basis ι ℤ Λ) (ξ : euclideanDualLattice Λ) : + ∃ n : ι → ℤ, latticeDualPoint Λ b n = ξ := by + classical + have hmem := ((latticeDualBasis Λ b).mem_span_iff_repr_mem ℤ (ξ : E)).mp + ((euclideanDualLattice_eq_span Λ b).le ξ.property) + choose n hn using hmem + refine ⟨n, ?_⟩ + apply (latticeDualBasis Λ b).equivFun.injective + ext i + change (latticeDualBasis Λ b).equivFun + ((latticeDualBasis Λ b).equivFun.symm (fun j => (n j : ℝ))) i = _ + rw [LinearEquiv.apply_symm_apply] + exact hn i + +noncomputable def latticeDualEquiv (b : Basis ι ℤ Λ) : (ι → ℤ) ≃ euclideanDualLattice Λ := + Equiv.ofBijective (fun n => ⟨latticeDualPoint Λ b n, latticeDualPoint_mem Λ b n⟩) + ⟨fun _ _ h => latticeDualPoint_injective Λ b (congrArg Subtype.val h), fun ξ => by + obtain ⟨n, hn⟩ := latticeDualPoint_surjective Λ b ξ + exact ⟨n, Subtype.ext hn⟩⟩ + +@[simp] +theorem latticeDualEquiv_coe (b : Basis ι ℤ Λ) (n : ι → ℤ) : + ((latticeDualEquiv Λ b n : euclideanDualLattice Λ) : E) = latticeDualPoint Λ b n := rfl + +theorem latticeDualPoint_inner_coordinates (b : Basis ι ℤ Λ) (n : ι → ℤ) (x : ι → ℝ) : + inner ℝ (latticeDualPoint Λ b n) ((b.ofZLatticeBasis ℝ Λ).equivFun.symm x) = + ∑ i, (n i : ℝ) * x i := by + rw [Basis.equivFun_symm_apply, inner_sum] + apply Finset.sum_congr rfl + intro i _ + rw [inner_smul_right, latticeDualPoint_inner_basis, mul_comm] + +theorem latticeDualPoint_character (b : Basis ι ℤ Λ) (n : ι → ℤ) (x : ι → ℝ) : + euclideanCharacter (latticeDualPoint Λ b n) ((b.ofZLatticeBasis ℝ Λ).equivFun.symm x) = + UnitAddTorus.mFourier n (fun i => (x i : UnitAddCircle)) := by + rw [euclideanCharacter_eq_exp, latticeDualPoint_inner_coordinates] + simp only [Complex.ofReal_sum, Finset.mul_sum, Complex.exp_sum, + UnitAddTorus.mFourier, ContinuousMap.coe_mk, fourier_coe_apply] + apply Finset.prod_congr rfl + intro i _ + push_cast + congr 1 + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianCoefficient.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..39e61f67e3fefbd702d8ea136e7b8a560c640ba1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianCoefficient.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformIntegralSeries +import OAI.Combinatorics.Progressions.Fourier.MonomialCharacterMean + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory Filter + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +theorem lattice_periodization_integral (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (μ : Measure E) [μ.IsAddHaarMeasure] + (S : Set E) (hS : MeasurableSet S) (hfinite : μ S < ⊤) + (hfund : IsAddFundamentalDomain Λ S μ) (f : E → ℂ) + (hf : Continuous f) (hint : Integrable f μ) (C : Λ → ℝ) (hC : Summable C) + (hbound : ∀ m : Λ, ∀ x ∈ S, ‖f (x - m)‖ ≤ C m) : + (∫ x in S, ∑' m : Λ, f (x - m) ∂μ) = ∫ x, f x ∂μ := by + let : VAddInvariantMeasure Λ E μ := inferInstanceAs (VAddInvariantMeasure Λ.toAddSubgroup E μ) + let : IsFiniteMeasure (μ.restrict S) := ⟨by simpa using hfinite⟩ + rw [integral_tsum_of_uniform_domination (μ.restrict S) + (fun (m : Λ) x => f (x - m)) C + (fun m => (hf.comp (continuous_id.sub continuous_const)).aestronglyMeasurable) hC + (fun m => ?_)] + · have h := hfund.integral_eq_tsum' f hint + simpa only [Submodule.vadd_def, vadd_eq_add, Submodule.coe_neg, sub_eq_add_neg, add_comm] using h.symm + · filter_upwards [ae_restrict_mem hS] with x hx + exact hbound m x hx + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +theorem latticeGaussian_integral_character (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (S : Set E) (hS : MeasurableSet S) (hbounded : Bornology.IsBounded S) + (hfund : IsAddFundamentalDomain Λ S volume) {t : ℝ} (ht : 0 < t) + (ξ : E) (hξ : ξ ∈ euclideanDualLattice Λ) : + (∫ x in S, euclideanCharacter (-ξ) x * (latticeGaussianMass Λ t x : ℂ)) = + ((((Real.sqrt t) ^ Module.finrank ℝ E)⁻¹ * + Real.exp (-Real.pi / t * ‖ξ‖ ^ 2) : ℝ) : ℂ) := by + obtain ⟨R, hR, hball⟩ := hbounded.exists_pos_norm_le + let f : E → ℂ := fun x => euclideanCharacter (-ξ) x * + (Real.exp (-Real.pi * t * ‖x‖ ^ 2) : ℂ) + let C : Λ → ℝ := fun m => Real.exp (Real.pi * t * R ^ 2) * + Real.exp (-Real.pi * (t / 2) * ‖(0 : E) - m‖ ^ 2) + have hC : Summable C := (lattice_gaussian_summable Λ (half_pos ht) 0).mul_left _ + have hf : Continuous f := (continuous_euclideanCharacter (-ξ)).mul (by fun_prop) + have hbound (m : Λ) (x : E) (hx : x ∈ S) : ‖f (x - m)‖ ≤ C m := by + simp only [f, C, norm_mul, norm_euclideanCharacter, one_mul, Complex.norm_real, + Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), zero_sub, norm_neg] + exact gaussian_translate_bound t R ht.le hR.le x m (hball x hx) + have hperiod (x : E) : (∑' m : Λ, f (x - m)) = + euclideanCharacter (-ξ) x * (latticeGaussianMass Λ t x : ℂ) := by + simp only [f, euclideanCharacter_sub_lattice Λ (-ξ) ((euclideanDualLattice Λ).neg_mem hξ)] + rw [tsum_mul_left, ← Complex.ofReal_tsum] + rfl + have h := lattice_periodization_integral Λ volume S hS hbounded.measure_lt_top hfund + f hf (gaussian_character_integrable ht (-ξ)) C hC hbound + simp only [hperiod] at h + exact h.trans (gaussian_fourier_integral ht ξ) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianDilation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianDilation.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e666f980a91efe0c02e3de655bda6ef997f1581 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianDilation.lean @@ -0,0 +1,45 @@ +import OAI.Combinatorics.Progressions.Polynomial.SchmidtGaussianMean + +namespace OAI + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +theorem latticeGaussianMean_dilation (Λ : Submodule ℤ E) (t : ℝ) (k : ℕ) (α : E) + (a : ℤ) (ha : a ≠ 0) (H N : ℕ) (hsize : |(a : ℝ)| * H ≤ N) : + (2 * (H : ℝ) + 1) * latticeGaussianMean Λ t k ((a : ℝ) ^ k • α) H ≤ + (2 * (N : ℝ) + 1) * latticeGaussianMean Λ t k α N := by + have h := symmetricInterval_sum_dilation + (fun n => normalizedLatticeGaussian Λ t ((n : ℝ) ^ k • α)) + (fun n => normalizedLatticeGaussian_nonneg Λ t _) a ha H N hsize + have hid (n : ℤ) : ((a * n : ℤ) : ℝ) ^ k • α = + (n : ℝ) ^ k • ((a : ℝ) ^ k • α) := by + rw [Int.cast_mul, mul_pow, smul_smul, mul_comm] + simp only [hid] at h + unfold latticeGaussianMean + simp only [symmetricInterval_card, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] + rw [mul_div_cancel₀ _ (by positivity : 2 * (H : ℝ) + 1 ≠ 0), + mul_div_cancel₀ _ (by positivity : 2 * (N : ℝ) + 1 ≠ 0)] + exact h + +theorem latticeGaussianMean_dilation_loss (Λ : Submodule ℤ E) (t : ℝ) (k : ℕ) (α : E) + (a : ℤ) (ha : a ≠ 0) (H N : ℕ) {K : ℝ} + (hsize : |(a : ℝ)| * H ≤ N) (hK : 1 ≤ K) (hlength : (N : ℝ) ≤ 2 * K * H) : + latticeGaussianMean Λ t k ((a : ℝ) ^ k • α) H ≤ + 2 * K * latticeGaussianMean Λ t k α N := by + have h := latticeGaussianMean_dilation Λ t k α a ha H N hsize + have hratio : 2 * (N : ℝ) + 1 ≤ 2 * K * (2 * H + 1) := by nlinarith + have hnonneg := latticeGaussianMean_nonneg Λ t k α N + have hh : 0 < 2 * (H : ℝ) + 1 := by positivity + have hupper := mul_le_mul_of_nonneg_right hratio hnonneg + nlinarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianHyperplane.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianHyperplane.lean new file mode 100644 index 0000000000000000000000000000000000000000..de85f2fc544bd118aaf9a592abcbc267a9cb25e0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianHyperplane.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.Progressions.Estimates.IntegralHyperplaneCorrection + +namespace OAI + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + +noncomputable def latticeHyperplaneInclusion (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) : + latticeHyperplane Λ f →ₗ[ℤ] Λ where + toFun x := ⟨((x : f.ker) : E), (mem_latticeHyperplane Λ f (x : f.ker)).mp x.property⟩ + map_add' _ _ := rfl + map_smul' _ _ := rfl + +omit [FiniteDimensional ℝ E] in +theorem latticeHyperplaneInclusion_injective (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) : + Function.Injective (latticeHyperplaneInclusion Λ f) := by + intro x y hxy + apply Subtype.ext + apply Subtype.ext + exact congrArg (fun z : Λ => (z : E)) hxy + +theorem latticeGaussianMass_hyperplane_le (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (f : E →ₗ[ℝ] ℝ) {t : ℝ} (ht : 0 < t) (x : f.ker) : + latticeGaussianMass (latticeHyperplane Λ f) t x ≤ latticeGaussianMass Λ t (x : E) := by + have h := tsum_comp_le_tsum_of_inj (lattice_gaussian_summable Λ ht (x : E)) + (fun _ => (Real.exp_pos _).le) (latticeHyperplaneInclusion_injective Λ f) + exact h + +theorem latticeGaussianMass_hyperplane_translate_le (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (f : E →ₗ[ℝ] ℝ) {t : ℝ} (ht : 0 < t) (x : E) (y : f.ker) + (hxy : x - (y : E) ∈ Λ) : + latticeGaussianMass (latticeHyperplane Λ f) t y ≤ latticeGaussianMass Λ t x := by + rw [latticeGaussianMass_eq_of_sub_mem Λ t hxy] + exact latticeGaussianMass_hyperplane_le Λ f ht y + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianPoisson.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianPoisson.lean new file mode 100644 index 0000000000000000000000000000000000000000..d29f5815f23d012ff7e8e2a5d263219754bdda04 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianPoisson.lean @@ -0,0 +1,85 @@ +import OAI.Combinatorics.Progressions.Fourier.LatticeTorusFourierCoefficient + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + +theorem latticeGaussianTorus_coefficient_eq (b : Basis ι ℤ Λ) {t : ℝ} (ht : 0 < t) (n : ι → ℤ) : + UnitAddTorus.mFourierCoeff (latticeGaussianTorus Λ b ht) n = + ((latticeGaussianNormalizer Λ t)⁻¹ * + Real.exp (-Real.pi / t * ‖latticeDualPoint Λ b n‖ ^ 2) : ℝ) := by + have hc : (ZLattice.covolume Λ : ℂ) ≠ 0 := by + exact_mod_cast (ZLattice.covolume_pos Λ MeasureTheory.volume).ne' + have hs : (((Real.sqrt t) ^ Module.finrank ℝ E : ℝ) : ℂ) ≠ 0 := by + exact_mod_cast pow_ne_zero (Module.finrank ℝ E) (Real.sqrt_pos.mpr ht).ne' + apply mul_left_cancel₀ hc + rw [latticeGaussianTorus_coefficient, latticeGaussianNormalizer] + push_cast + field_simp + +theorem summable_latticeGaussianTorus_coefficients (b : Basis ι ℤ Λ) {t : ℝ} (ht : 0 < t) : + Summable (UnitAddTorus.mFourierCoeff (latticeGaussianTorus Λ b ht)) := by + have hs := (lattice_gaussian_summable (euclideanDualLattice Λ) (inv_pos.mpr ht) 0).comp_injective + (latticeDualEquiv Λ b).injective + have hw : Summable (fun n : ι → ℤ => Real.exp (-Real.pi / t * ‖latticeDualPoint Λ b n‖ ^ 2)) := by + simpa only [Function.comp_def, zero_sub, norm_neg, latticeDualEquiv_coe, div_eq_mul_inv] using hs + change Summable (fun n : ι → ℤ => UnitAddTorus.mFourierCoeff (latticeGaussianTorus Λ b ht) n) + simp_rw [latticeGaussianTorus_coefficient_eq Λ b ht] + exact Complex.summable_ofReal.mpr (hw.mul_left _) + +theorem normalizedLatticeGaussian_poisson_basis (b : Basis ι ℤ Λ) {t : ℝ} (ht : 0 < t) (x : E) : + (normalizedLatticeGaussian Λ t x : ℂ) = + ∑' ξ : euclideanDualLattice Λ, + (Real.exp (-Real.pi / t * ‖(ξ : E)‖ ^ 2) : ℂ) * euclideanCharacter (ξ : E) x := by + let bR := b.ofZLatticeBasis ℝ Λ + have hseries := UnitAddTorus.hasSum_mFourier_series_apply_of_summable + (summable_latticeGaussianTorus_coefficients Λ b ht) + (fun i => (bR.equivFun x i : UnitAddCircle)) + have hn : (latticeGaussianNormalizer Λ t : ℂ) ≠ 0 := by + exact_mod_cast (latticeGaussianNormalizer_pos Λ ht).ne' + have hs : HasSum (fun n : ι → ℤ => + (Real.exp (-Real.pi / t * ‖latticeDualPoint Λ b n‖ ^ 2) : ℂ) * + euclideanCharacter (latticeDualPoint Λ b n) x) + (normalizedLatticeGaussian Λ t x : ℂ) := by + convert! hseries.mul_left (latticeGaussianNormalizer Λ t : ℂ) using 1 + · funext n + simp only [smul_eq_mul] + rw [latticeGaussianTorus_coefficient_eq Λ b ht, + ← latticeDualPoint_character Λ b n (bR.equivFun x)] + change _ = (latticeGaussianNormalizer Λ t : ℂ) * + (((latticeGaussianNormalizer Λ t)⁻¹ * Real.exp + (-Real.pi / t * ‖latticeDualPoint Λ b n‖ ^ 2) : ℝ) * + euclideanCharacter (latticeDualPoint Λ b n) (bR.equivFun.symm (bR.equivFun x))) + rw [LinearEquiv.symm_apply_apply] + push_cast + field_simp + · rw [latticeGaussianTorus_coe] + change _ = (latticeGaussianNormalizer Λ t : ℂ) * + (latticeGaussianMass Λ t (bR.equivFun.symm (bR.equivFun x)) : ℂ) + rw [LinearEquiv.symm_apply_apply] + simp only [normalizedLatticeGaussian, Complex.ofReal_mul] + rw [← hs.tsum_eq] + simpa only [latticeDualEquiv_coe] using (latticeDualEquiv Λ b).tsum_eq + (fun ξ : euclideanDualLattice Λ => + (Real.exp (-Real.pi / t * ‖(ξ : E)‖ ^ 2) : ℂ) * euclideanCharacter (ξ : E) x) + +omit [Fintype ι] in +theorem normalizedLatticeGaussian_poisson {t : ℝ} (ht : 0 < t) (x : E) : + (normalizedLatticeGaussian Λ t x : ℂ) = + ∑' ξ : euclideanDualLattice Λ, + (Real.exp (-Real.pi / t * ‖(ξ : E)‖ ^ 2) : ℂ) * euclideanCharacter (ξ : E) x := + normalizedLatticeGaussian_poisson_basis Λ (Module.Free.chooseBasis ℤ Λ) ht x + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianTemperature.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianTemperature.lean new file mode 100644 index 0000000000000000000000000000000000000000..54aa553a93c6a4bd67948d013d4ec9c36931f5d1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeGaussianTemperature.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.Progressions.Estimates.GaussianPerturbation +import OAI.Combinatorics.Progressions.Lattices.LatticeHyperplaneBasis + +namespace OAI + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + +theorem latticeGaussianMass_stability (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (x y : E) {ε : ℝ} (hε : 0 ≤ ε) (hεone : ε ≤ 1) (hxy : ‖x - y‖ ≤ ε) : + Real.exp (-4 * Real.pi) * latticeGaussianMass Λ ((1 + ε) ^ 2) y ≤ + latticeGaussianMass Λ 1 x := by + unfold latticeGaussianMass + rw [← tsum_mul_left] + apply Summable.tsum_le_tsum _ + ((lattice_gaussian_summable Λ (sq_pos_of_pos (by linarith)) y).mul_left _) + (lattice_gaussian_summable Λ (by norm_num) x) + intro m + have he : ‖(x - (m : E)) - (y - (m : E))‖ ≤ ε := by + simpa only [sub_sub_sub_cancel_right] using hxy + have h := gaussian_perturbation_lower (x - (m : E)) (y - (m : E)) hε hεone he + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (by linarith : 0 ≤ 1 + ε), mul_pow] at h + convert h using 1 <;> congr 2 <;> ring + +theorem latticeGaussianMass_orbit_stability (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (α β : E) {N k : ℕ} {ε : ℝ} + (hε : 0 ≤ ε) (hεone : ε ≤ 1) (hclose : (N : ℝ) ^ k * ‖α - β‖ ≤ ε) + (n : ℤ) (hn : |n| ≤ (N : ℤ)) : + Real.exp (-4 * Real.pi) * latticeGaussianMass Λ ((1 + ε) ^ 2) ((n : ℝ) ^ k • β) ≤ + latticeGaussianMass Λ 1 ((n : ℝ) ^ k • α) := by + apply latticeGaussianMass_stability Λ _ _ hε hεone + rw [← smul_sub, norm_smul, Real.norm_eq_abs, abs_pow] + have hnR : |(n : ℝ)| ≤ (N : ℝ) := by exact_mod_cast hn + exact (mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (abs_nonneg _) hnR k) (norm_nonneg _)).trans hclose + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +theorem gaussian_perturbation_at_temperature (x y : E) {t ε : ℝ} + (ht : 0 ≤ t) (hε : 0 ≤ ε) (hεone : ε ≤ 1) + (hxy : Real.sqrt t * ‖x - y‖ ≤ ε) : + Real.exp (-4 * Real.pi) * Real.exp (-Real.pi * (t * (1 + ε) ^ 2) * ‖y‖ ^ 2) ≤ + Real.exp (-Real.pi * t * ‖x‖ ^ 2) := by + have he : ‖Real.sqrt t • x - Real.sqrt t • y‖ ≤ ε := by + rw [← smul_sub, norm_smul, Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg t)] + exact hxy + have h := gaussian_perturbation_lower (Real.sqrt t • x) (Real.sqrt t • y) hε hεone he + simp only [norm_smul, Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg t), + abs_of_nonneg (show 0 ≤ 1 + ε by linarith), mul_pow, Real.sq_sqrt ht] at h + rw [show -Real.pi * (t * (1 + ε) ^ 2) * ‖y‖ ^ 2 = + -Real.pi * ((1 + ε) ^ 2 * (t * ‖y‖ ^ 2)) by ring, + show -Real.pi * t * ‖x‖ ^ 2 = -Real.pi * (t * ‖x‖ ^ 2) by ring] + exact h + +variable [FiniteDimensional ℝ E] + +theorem latticeGaussianMass_temperature_stability (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (x y : E) {t ε : ℝ} (ht : 0 < t) (hε : 0 ≤ ε) (hεone : ε ≤ 1) + (hxy : Real.sqrt t * ‖x - y‖ ≤ ε) : + Real.exp (-4 * Real.pi) * latticeGaussianMass Λ (t * (1 + ε) ^ 2) y ≤ + latticeGaussianMass Λ t x := by + unfold latticeGaussianMass + rw [← tsum_mul_left] + apply Summable.tsum_le_tsum _ + ((lattice_gaussian_summable Λ (mul_pos ht (sq_pos_of_pos (by linarith))) y).mul_left _) + (lattice_gaussian_summable Λ ht x) + intro m + apply gaussian_perturbation_at_temperature _ _ ht.le hε hεone + simpa only [sub_sub_sub_cancel_right] using hxy + +theorem latticeGaussianMass_temperature_orbit_stability (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (α β : E) {N k : ℕ} {t ε : ℝ} + (ht : 0 < t) (hε : 0 ≤ ε) (hεone : ε ≤ 1) + (hclose : Real.sqrt t * ((N : ℝ) ^ k * ‖α - β‖) ≤ ε) + (n : ℤ) (hn : |n| ≤ (N : ℤ)) : + Real.exp (-4 * Real.pi) * latticeGaussianMass Λ (t * (1 + ε) ^ 2) ((n : ℝ) ^ k • β) ≤ + latticeGaussianMass Λ t ((n : ℝ) ^ k • α) := by + apply latticeGaussianMass_temperature_stability Λ _ _ ht hε hεone + rw [← smul_sub, norm_smul, Real.norm_eq_abs, abs_pow] + have hnR : |(n : ℝ)| ≤ (N : ℝ) := by exact_mod_cast hn + exact (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (abs_nonneg _) hnR k) (norm_nonneg _)) (Real.sqrt_nonneg t)).trans hclose + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeHyperplaneBasis.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeHyperplaneBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d53a884359e8bf3ad0e3ede49c6e5d7c1d218ec --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeHyperplaneBasis.lean @@ -0,0 +1,411 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def latticeHyperplane (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) : Submodule ℤ f.ker := + ZLattice.comap ℝ Λ f.ker.subtype + +@[simp] +theorem mem_latticeHyperplane (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) (x : f.ker) : + x ∈ latticeHyperplane Λ f ↔ (x : E) ∈ Λ := Iff.rfl + +noncomputable def hyperplaneRetraction (f : E →ₗ[ℝ] ℝ) (w : E) (hw : f w = 1) : + E →ₗ[ℝ] f.ker where + toFun x := ⟨x - f x • w, by simp only [LinearMap.mem_ker, map_sub, map_smul, hw, smul_eq_mul, mul_one, sub_self]⟩ + map_add' x y := by + apply Subtype.ext + change (x + y) - f (x + y) • w = (x - f x • w) + (y - f y • w) + rw [map_add, add_smul] + abel + map_smul' a x := by + apply Subtype.ext + change a • x - f (a • x) • w = a • (x - f x • w) + rw [map_smul, smul_eq_mul, smul_sub, smul_smul] + +@[simp] +theorem hyperplaneRetraction_coe (f : E →ₗ[ℝ] ℝ) (w : E) (hw : f w = 1) (x : E) : + (hyperplaneRetraction f w hw x : E) = x - f x • w := rfl + +@[simp] +theorem hyperplaneRetraction_on_kernel (f : E →ₗ[ℝ] ℝ) (w : E) (hw : f w = 1) (x : f.ker) : + hyperplaneRetraction f w hw (x : E) = x := by + apply Subtype.ext + simp only [hyperplaneRetraction_coe, LinearMap.mem_ker.mp x.property, zero_smul, sub_zero] + +theorem hyperplaneRetraction_surjective (f : E →ₗ[ℝ] ℝ) (w : E) (hw : f w = 1) : + Function.Surjective (hyperplaneRetraction f w hw) := + fun x => ⟨x, hyperplaneRetraction_on_kernel f w hw x⟩ + +theorem hyperplaneRetraction_mem (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) (x : E) (hx : x ∈ Λ) : + hyperplaneRetraction f w hw x ∈ latticeHyperplane Λ f := by + change x - f x • w ∈ Λ + obtain ⟨n, hn⟩ := hint x hx + rw [hn] + simpa only [Int.cast_smul_eq_zsmul] using Λ.sub_mem hx (Λ.smul_mem n hwΛ) + +theorem latticeHyperplane_span_top (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hspan : Submodule.span ℝ (Λ : Set E) = ⊤) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) : + Submodule.span ℝ (latticeHyperplane Λ f : Set f.ker) = ⊤ := by + let S := Submodule.span ℝ (latticeHyperplane Λ f : Set f.ker) + have hall : ∀ x : E, hyperplaneRetraction f w hw x ∈ S := by + intro x + have hx : x ∈ Submodule.span ℝ (Λ : Set E) := by rw [hspan]; trivial + induction hx using Submodule.span_induction with + | mem x hx => exact Submodule.subset_span (hyperplaneRetraction_mem Λ f hint w hwΛ hw x hx) + | zero => simpa only [map_zero] using S.zero_mem + | add x y hx hy hpx hpy => simpa only [map_add] using S.add_mem hpx hpy + | smul a x hx hpx => simpa only [map_smul] using S.smul_mem a hpx + apply top_le_iff.mp + intro x hx + simpa only [hyperplaneRetraction_on_kernel] using hall (x : E) + +instance latticeHyperplane_discrete (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (f : E →ₗ[ℝ] ℝ) : DiscreteTopology (latticeHyperplane Λ f) := + ZLattice.comap_discreteTopology ℝ Λ (by fun_prop) Subtype.val_injective + +theorem latticeHyperplane_isZLattice (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) : + IsZLattice ℝ (latticeHyperplane Λ f) := + ⟨latticeHyperplane_span_top Λ f (IsZLattice.span_top (K := ℝ)) hint w hwΛ hw⟩ + +theorem hyperplane_finrank [FiniteDimensional ℝ E] (f : E →ₗ[ℝ] ℝ) + (w : E) (hw : f w = 1) : Module.finrank ℝ f.ker + 1 = Module.finrank ℝ E := by + have hsurj : Function.Surjective f := by + intro a + exact ⟨a • w, by simp only [map_smul, hw, smul_eq_mul, mul_one]⟩ + have h := f.finrank_range_add_finrank_ker + rw [LinearMap.range_eq_top.mpr hsurj, finrank_top, Module.finrank_self] at h + omega + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def integralLatticeValue (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) (x : Λ) : ℤ := + (hint x x.property).choose + +theorem integralLatticeValue_cast (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) (x : Λ) : + (integralLatticeValue Λ f hint x : ℝ) = f (x : E) := + (hint x x.property).choose_spec.symm + +noncomputable def integralLatticeCoordinate (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) : Λ →ₗ[ℤ] ℤ where + toFun := integralLatticeValue Λ f hint + map_add' x y := by + apply Int.cast_injective (α := ℝ) + simp only [Int.cast_add, integralLatticeValue_cast, Submodule.coe_add, map_add] + map_smul' a x := by + apply Int.cast_injective (α := ℝ) + simp only [integralLatticeValue_cast, Submodule.coe_smul, map_zsmul, RingHom.id_apply, + smul_eq_mul, Int.cast_mul, zsmul_eq_mul] + +theorem integralLatticeCoordinate_cast (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) (x : Λ) : + (integralLatticeCoordinate Λ f hint x : ℝ) = f (x : E) := + integralLatticeValue_cast Λ f hint x + +theorem integralLatticeCoordinate_eq_iff (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) (x : Λ) (n : ℤ) : + integralLatticeCoordinate Λ f hint x = n ↔ f (x : E) = (n : ℝ) := by + rw [← integralLatticeCoordinate_cast Λ f hint x] + exact Int.cast_inj.symm + +theorem integralLatticeCoordinate_surjective (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) : + Function.Surjective (integralLatticeCoordinate Λ f hint) := by + have hw' : integralLatticeCoordinate Λ f hint ⟨w, hwΛ⟩ = 1 := + (integralLatticeCoordinate_eq_iff Λ f hint ⟨w, hwΛ⟩ 1).mpr (by simpa using hw) + intro n + exact ⟨n • (⟨w, hwΛ⟩ : Λ), by rw [map_smul, hw']; simp⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Filter +open scoped Topology + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + +theorem lattice_gaussian_summable (Λ : Submodule ℤ E) [DiscreteTopology Λ] + {t : ℝ} (ht : 0 < t) (x : E) : + Summable (fun m : Λ => Real.exp (-Real.pi * t * ‖x - (m : E)‖ ^ 2)) := by + let r : ℝ := -(Module.finrank ℤ Λ : ℝ) - 1 + have hr : r < -(Module.finrank ℤ Λ : ℝ) := by dsimp [r]; linarith + have hs := ZLattice.summable_norm_sub_rpow Λ r hr x + have hc : IsClosed (Λ : Set E) := @AddSubgroup.isClosed_of_discreteTopology E _ _ _ _ + Λ.toAddSubgroup (inferInstanceAs (DiscreteTopology Λ)) + have he : Topology.IsClosedEmbedding (fun m : Λ => (m : E) - x) := by + exact (Homeomorph.subRight x).isClosedEmbedding.comp (Λ.isClosedEmbedding_subtype hc) + have hn : Tendsto (fun m : Λ => ‖(m : E) - x‖) cofinite atTop := + tendsto_norm_comp_cofinite_atTop_of_isClosedEmbedding he + have hd := (rexp_neg_quadratic_isLittleO_rpow_atTop + (show -Real.pi * t < 0 by nlinarith [Real.pi_pos]) 0 r).isBigO.comp_tendsto hn + have hsum := summable_of_isBigO hs hd + simpa only [Function.comp_def, zero_mul, add_zero, norm_sub_rev] using hsum + +noncomputable def latticeGaussianMass (Λ : Submodule ℤ E) (t : ℝ) (x : E) : ℝ := + ∑' m : Λ, Real.exp (-Real.pi * t * ‖x - (m : E)‖ ^ 2) + +omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] in +theorem latticeGaussianMass_nonneg (Λ : Submodule ℤ E) (t : ℝ) (x : E) : + 0 ≤ latticeGaussianMass Λ t x := tsum_nonneg (fun _ => (Real.exp_pos _).le) + +theorem latticeGaussianMass_pos (Λ : Submodule ℤ E) [DiscreteTopology Λ] + {t : ℝ} (ht : 0 < t) (x : E) : 0 < latticeGaussianMass Λ t x := by + have h := (lattice_gaussian_summable Λ ht x).le_tsum (0 : Λ) (fun _ _ => (Real.exp_pos _).le) + exact (Real.exp_pos _).trans_le h + +omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] in +theorem latticeGaussianMass_add_lattice (Λ : Submodule ℤ E) (t : ℝ) (x : E) (v : Λ) : + latticeGaussianMass Λ t (x + (v : E)) = latticeGaussianMass Λ t x := by + have h := (Equiv.addRight v).tsum_eq (fun m : Λ => Real.exp (-Real.pi * t * ‖x + (v : E) - (m : E)‖ ^ 2)) + simpa only [latticeGaussianMass, Equiv.coe_addRight, Submodule.coe_add, add_sub_add_right_eq_sub] using h.symm + +omit [NormedSpace ℝ E] [FiniteDimensional ℝ E] in +theorem latticeGaussianMass_eq_of_sub_mem (Λ : Submodule ℤ E) (t : ℝ) {x y : E} + (hxy : x - y ∈ Λ) : latticeGaussianMass Λ t x = latticeGaussianMass Λ t y := by + have h := latticeGaussianMass_add_lattice Λ t y ⟨x - y, hxy⟩ + simpa only [add_sub_cancel] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def latticeHyperplaneRetraction (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) : Λ →ₗ[ℤ] latticeHyperplane Λ f where + toFun x := ⟨hyperplaneRetraction f w hw x, hyperplaneRetraction_mem Λ f hint w hwΛ hw x x.property⟩ + map_add' x y := by + apply Subtype.ext + change hyperplaneRetraction f w hw ((x : E) + y) = _ + exact map_add (hyperplaneRetraction f w hw) (x : E) (y : E) + map_smul' n x := by + apply Subtype.ext + change hyperplaneRetraction f w hw (n • (x : E)) = n • hyperplaneRetraction f w hw x + exact map_zsmul (hyperplaneRetraction f w hw) n (x : E) + +@[simp] +theorem latticeHyperplaneRetraction_coe (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) (x : Λ) : + (((latticeHyperplaneRetraction Λ f hint w hwΛ hw x : latticeHyperplane Λ f) : f.ker) : E) = + (x : E) - f (x : E) • w := rfl + +noncomputable def latticeHyperplaneSplit (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) : + Λ ≃ₗ[ℤ] (latticeHyperplane Λ f × ℤ) := + { (latticeHyperplaneRetraction Λ f hint w hwΛ hw).prod (integralLatticeCoordinate Λ f hint) with + invFun y := ⟨((y.1 : f.ker) : E) + y.2 • w, + Λ.add_mem ((mem_latticeHyperplane Λ f (y.1 : f.ker)).mp y.1.property) (Λ.smul_mem y.2 hwΛ)⟩ + left_inv x := by + apply Subtype.ext + change (x : E) - f (x : E) • w + integralLatticeCoordinate Λ f hint x • w = (x : E) + rw [← Int.cast_smul_eq_zsmul ℝ, integralLatticeCoordinate_cast] + exact sub_add_cancel _ _ + right_inv y := by + apply Prod.ext + · apply Subtype.ext + apply Subtype.ext + change ((y.1 : f.ker) : E) + y.2 • w - + f (((y.1 : f.ker) : E) + y.2 • w) • w = ((y.1 : f.ker) : E) + have hy : f ((y.1 : f.ker) : E) = 0 := (y.1 : f.ker).property + rw [map_add, map_zsmul, hy, hw, zero_add, zsmul_eq_mul, mul_one, + Int.cast_smul_eq_zsmul] + exact add_sub_cancel_right _ _ + · apply Int.cast_injective (α := ℝ) + change (integralLatticeCoordinate Λ f hint _ : ℝ) = (y.2 : ℝ) + rw [integralLatticeCoordinate_cast] + change f (((y.1 : f.ker) : E) + y.2 • w) = (y.2 : ℝ) + have hy : f ((y.1 : f.ker) : E) = 0 := (y.1 : f.ker).property + simp only [map_add, map_zsmul, hy, hw, zero_add, zsmul_eq_mul, mul_one] } + +theorem latticeHyperplaneSplit_symm_coe (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) (y : latticeHyperplane Λ f × ℤ) : + ((latticeHyperplaneSplit Λ f hint w hwΛ hw).symm y : E) = + ((y.1 : f.ker) : E) + y.2 • w := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem integer_functional_image_generator {M : Type*} [AddCommGroup M] [Module ℤ M] + (f : M →ₗ[ℤ] ℤ) (hf : f ≠ 0) : + ∃ (m : ℤ) (w : M), m ≠ 0 ∧ f w = m ∧ ∀ x, ∃ n : ℤ, f x = n * m := by + let m := Submodule.IsPrincipal.generator f.range + have hspan : Submodule.span ℤ {m} = f.range := Submodule.IsPrincipal.span_singleton_generator _ + obtain ⟨w, hw⟩ := Submodule.IsPrincipal.generator_mem f.range + have hm : m ≠ 0 := by + intro hm + have hz : f.range = ⊥ := by rw [← hspan, hm]; simp + exact hf (LinearMap.range_eq_bot.mp hz) + refine ⟨m, w, hm, hw, ?_⟩ + intro x + have hx : f x ∈ Submodule.span ℤ {m} := by rw [hspan]; exact ⟨x, rfl⟩ + obtain ⟨n, hn⟩ := Submodule.mem_span_singleton.mp hx + exact ⟨n, (by simpa only [smul_eq_mul] using hn.symm)⟩ + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +theorem integralLatticeCoordinate_ne_zero (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hspan : Submodule.span ℝ (Λ : Set E) = ⊤) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) (hf : f ≠ 0) : + integralLatticeCoordinate Λ f hint ≠ 0 := by + intro hz + apply hf + apply LinearMap.ext_on hspan + intro x hx + have h := integralLatticeCoordinate_cast Λ f hint ⟨x, hx⟩ + rw [hz, LinearMap.zero_apply, Int.cast_zero] at h + exact h.symm + +theorem exists_primitive_lattice_functional (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hspan : Submodule.span ℝ (Λ : Set E) = ⊤) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) (hf : f ≠ 0) : + ∃ (m : ℤ) (g : E →ₗ[ℝ] ℝ) (w : E), m ≠ 0 ∧ + f = (m : ℝ) • g ∧ (∀ x ∈ Λ, ∃ n : ℤ, g x = (n : ℝ)) ∧ + w ∈ Λ ∧ g w = 1 ∧ g.ker = f.ker := by + obtain ⟨m, w, hm, hw, hmult⟩ := integer_functional_image_generator + (integralLatticeCoordinate Λ f hint) (integralLatticeCoordinate_ne_zero Λ f hspan hint hf) + let g : E →ₗ[ℝ] ℝ := (m : ℝ)⁻¹ • f + have hmR : (m : ℝ) ≠ 0 := by exact_mod_cast hm + have hg (x : E) : g x = f x / m := by simp only [g, LinearMap.smul_apply, smul_eq_mul, div_eq_mul_inv, mul_comm] + have hfw : f (w : E) = (m : ℝ) := by + rw [← integralLatticeCoordinate_cast Λ f hint w, hw] + refine ⟨m, g, w, hm, ?_, ?_, w.property, ?_, ?_⟩ + · ext x + simp only [LinearMap.smul_apply, smul_eq_mul, hg] + field_simp + · intro x hx + obtain ⟨n, hn⟩ := hmult ⟨x, hx⟩ + refine ⟨n, ?_⟩ + rw [hg, ← integralLatticeCoordinate_cast Λ f hint ⟨x, hx⟩, hn, Int.cast_mul] + exact mul_div_cancel_right₀ (n : ℝ) hmR + · rw [hg, hfw, div_self hmR] + · ext x + simp only [LinearMap.mem_ker, hg, div_eq_zero_iff, hmR, or_false] + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +omit [NormedSpace ℝ E] in +theorem gaussian_translate_bound (t R : ℝ) (ht : 0 ≤ t) (hR : 0 ≤ R) + (x m : E) (hx : ‖x‖ ≤ R) : + Real.exp (-Real.pi * t * ‖x - m‖ ^ 2) ≤ + Real.exp (Real.pi * t * R ^ 2) * Real.exp (-Real.pi * (t / 2) * ‖m‖ ^ 2) := by + have htriangle : ‖m‖ ≤ ‖x - m‖ + ‖x‖ := by + calc + ‖m‖ = ‖(m - x) + x‖ := by rw [sub_add_cancel] + _ ≤ ‖m - x‖ + ‖x‖ := norm_add_le _ _ + _ = _ := by rw [norm_sub_rev] + have hsquare : ‖m‖ ^ 2 ≤ 2 * ‖x - m‖ ^ 2 + 2 * R ^ 2 := by + have hx0 := norm_nonneg x + have hm0 := norm_nonneg m + have hxm0 := norm_nonneg (x - m) + nlinarith [sq_nonneg (‖x - m‖ - ‖x‖)] + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + nlinarith [mul_nonneg (mul_nonneg Real.pi_pos.le ht) + (sub_nonneg.mpr hsquare)] + +variable [FiniteDimensional ℝ E] + +theorem continuousOn_latticeGaussianMass (Λ : Submodule ℤ E) [DiscreteTopology Λ] + {t : ℝ} (ht : 0 < t) (R : ℝ) (hR : 0 ≤ R) : + ContinuousOn (latticeGaussianMass Λ t) (Metric.closedBall 0 R) := by + have hs := (lattice_gaussian_summable Λ (half_pos ht) 0).mul_left + (Real.exp (Real.pi * t * R ^ 2)) + apply continuousOn_tsum (fun _ => (by fun_prop : Continuous _).continuousOn) hs + intro m x hx + simp only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), zero_sub, norm_neg] + exact gaussian_translate_bound t R ht.le hR x m (by simpa using hx) + +theorem continuous_latticeGaussianMass (Λ : Submodule ℤ E) [DiscreteTopology Λ] + {t : ℝ} (ht : 0 < t) : Continuous (latticeGaussianMass Λ t) := by + rw [continuous_iff_continuousAt] + intro x + exact (continuousOn_latticeGaussianMass Λ ht (‖x‖ + 1) (by positivity)).continuousAt + (Metric.closedBall_mem_nhds_of_mem (by simp)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def latticeHyperplaneBasis (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) + (b : Module.Basis ι ℤ (latticeHyperplane Λ f)) : Module.Basis (ι ⊕ Unit) ℤ Λ := + (b.prod (Module.Basis.singleton Unit ℤ)).map + (latticeHyperplaneSplit Λ f hint w hwΛ hw).symm + +@[simp] +theorem latticeHyperplaneBasis_inl (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) + (b : Module.Basis ι ℤ (latticeHyperplane Λ f)) (i : ι) : + (latticeHyperplaneBasis Λ f hint w hwΛ hw b (Sum.inl i) : E) = (b i : f.ker) := by + simp [latticeHyperplaneBasis, latticeHyperplaneSplit_symm_coe] + +@[simp] +theorem latticeHyperplaneBasis_inr (Λ : Submodule ℤ E) (f : E →ₗ[ℝ] ℝ) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, f x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : f w = 1) + (b : Module.Basis ι ℤ (latticeHyperplane Λ f)) (j : Unit) : + (latticeHyperplaneBasis Λ f hint w hwΛ hw b (Sum.inr j) : E) = w := by + simp [latticeHyperplaneBasis, latticeHyperplaneSplit_symm_coe] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMeasurableRepresentative.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMeasurableRepresentative.lean new file mode 100644 index 0000000000000000000000000000000000000000..377ed788b34687fa672aa6921b8694f2dbebc975 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMeasurableRepresentative.lean @@ -0,0 +1,59 @@ +import Mathlib.Algebra.Module.ZLattice.Basic +import Mathlib.MeasureTheory.Constructions.Polish.Basic + +namespace OAI + +section + +open MeasureTheory Module + +namespace Erdos3 + +variable {E I : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype I] + +theorem exists_measurable_representative_zspan (b : Basis I ℝ E) : + ∃ r : E ⧸ (Submodule.span ℤ (Set.range b)).toAddSubgroup → E, + Measurable r ∧ ∀ x, + QuotientAddGroup.mk' (Submodule.span ℤ (Set.range b)).toAddSubgroup (r x) = x := by + let e : E ⧸ (Submodule.span ℤ (Set.range b)).toAddSubgroup ≃ + ZSpan.fundamentalDomain b := ZSpan.quotientEquiv b + have hsymm (x : ZSpan.fundamentalDomain b) : + e.symm x = QuotientAddGroup.mk' (Submodule.span ℤ (Set.range b)).toAddSubgroup (x : E) := by + exact ZSpan.quotientEquiv.symm_apply b x + have hcont : Continuous (fun x : E => + (QuotientAddGroup.mk' (Submodule.span ℤ (Set.range b)).toAddSubgroup) x) := + QuotientAddGroup.continuous_mk + have hinj : Set.InjOn + (QuotientAddGroup.mk' (Submodule.span ℤ (Set.range b)).toAddSubgroup) + (ZSpan.fundamentalDomain b) := by + intro x hx y hy hxy + have he : e.symm ⟨x, hx⟩ = e.symm ⟨y, hy⟩ := by + simpa only [hsymm] using hxy + exact congrArg Subtype.val (e.symm.injective he) + have hfun : (e.symm : ZSpan.fundamentalDomain b → _) = + (ZSpan.fundamentalDomain b).domRestrict + (QuotientAddGroup.mk' (Submodule.span ℤ (Set.range b)).toAddSubgroup) := + funext hsymm + have hem : MeasurableEmbedding (e.symm : ZSpan.fundamentalDomain b → _) := by + rw [hfun] + exact hcont.continuousOn.measurableEmbedding (ZSpan.fundamentalDomain_measurableSet b) hinj + have he : Measurable e := hem.measurable_comp_iff.mp (by simpa using measurable_id) + refine ⟨fun x => (e x : E), measurable_subtype_coe.comp he, ?_⟩ + intro x + simpa only [hsymm] using e.symm_apply_apply x + +theorem lattice_exists_measurable_representative (Λ : Submodule ℤ E) + [DiscreteTopology Λ] [IsZLattice ℝ Λ] (b : Basis I ℤ Λ) : + ∃ r : E ⧸ Λ.toAddSubgroup → E, + Measurable r ∧ ∀ x, QuotientAddGroup.mk' Λ.toAddSubgroup (r x) = x := by + have hspan : Submodule.span ℤ (Set.range (b.ofZLatticeBasis ℝ Λ : I → E)) = Λ := + b.ofZLatticeBasis_span ℝ Λ + rw [← hspan] + exact exists_measurable_representative_zspan (b.ofZLatticeBasis ℝ Λ) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMetricGapBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMetricGapBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef58aba80acb1a53f4b4fa537affd187203fbfb2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMetricGapBudget.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Nilpotent.BCHSmoothPartitionBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +theorem exists_bchLatticeSeparationRadius_inv_exp_bound (s : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ (d H l : ℕ) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + 1 / bchLatticeSeparationRadius s d H l ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C, hC, hmetric⟩ := exists_bchBoxMetricConstant_exp_bound s 0 + refine ⟨C + 5, by omega, ?_⟩ + intro d H l p hp hd hH hl + have hunit : ((1 : ℝ≥0) : ℝ) ≤ Real.exp ((p + 2) ^ 0) := by + simpa only [NNReal.coe_one, pow_zero] using Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1) + have hA := bchBoxCoordinateBound_nonneg s d H (B := 1) (by norm_num) + have hAq := (bchBoxCoordinateBound_le_bchBoxMetricConstant s d H 1).trans + (hmetric d H 1 p hp hd hH hunit) + have hC' : (2 : ℝ) ≤ C := by exact_mod_cast hC + have hpq : p ≤ (p + C) ^ C := by + apply (show p ≤ p + C by linarith).trans + simpa only [pow_one] using + pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + C) (by omega : 1 ≤ C) + have hprod := inverse_radius_product_exp_bound hA (by positivity : 0 ≤ (p + C) ^ C) + hAq (hl.trans (Real.exp_le_exp.mpr hpq)) + calc + 1 / bchLatticeSeparationRadius s d H l = + ((l : ℝ) + 1) * (bchBoxCoordinateBound s d H 1 + 1) := by + simp only [bchLatticeSeparationRadius, bchLogMetricConstant, NNReal.toReal] + field_simp + norm_num + _ ≤ 4 * ((l : ℝ) + 1) * (bchBoxCoordinateBound s d H 1 + 1) := by + nlinarith [mul_nonneg (show (0 : ℝ) ≤ l + 1 by positivity) (by linarith : 0 ≤ bchBoxCoordinateBound s d H 1 + 1)] + _ ≤ Real.exp (2 * (p + C) ^ C + 16) := hprod + _ ≤ _ := Real.exp_le_exp.mpr (enlarged_power_dominates_twice_add_sixteen hp C hC) + +theorem quotient_radius_inverse_le_exp {δ K p : ℝ} (hδ : 0 < δ) (hK : 0 < K) + (hp : 0 ≤ p) (hδp : 1 / δ ≤ Real.exp p) (hKp : K ≤ Real.exp p) : + 1 / (δ / (4 * K)) ≤ Real.exp (2 * p + 16) := by + have hprod := inverse_radius_product_exp_bound (show 0 ≤ 1 / δ by positivity) hp hδp hKp + calc + 1 / (δ / (4 * K)) = 4 * K * (1 / δ) := by field_simp + _ ≤ 4 * (K + 1) * (1 / δ + 1) := by + nlinarith [mul_nonneg hK.le (show 0 ≤ 1 / δ by positivity)] + _ ≤ _ := hprod + +theorem quotient_radius_inverse_power_budget (A B : ℕ) (hA : 2 ≤ A) (hB : 2 ≤ B) + {δ K p : ℝ} (hδ : 0 < δ) (hK : 0 < K) (hp : 0 ≤ p) + (hδp : 1 / δ ≤ Real.exp ((p + A) ^ A)) (hKp : K ≤ Real.exp ((p + B) ^ B)) : + 1 / (δ / (4 * K)) ≤ Real.exp ((p + (A + B + 5 : ℕ)) ^ (A + B + 5)) := by + have hqδ := hδp.trans (Real.exp_le_exp.mpr + (shifted_power_self_mono (C := A) (D := A + B) hp (by omega) (by omega))) + have hqK := hKp.trans (Real.exp_le_exp.mpr + (shifted_power_self_mono (C := B) (D := A + B) hp (by omega) (by omega))) + exact (quotient_radius_inverse_le_exp hδ hK (by positivity) hqδ hqK).trans + (Real.exp_le_exp.mpr (enlarged_power_dominates_twice_add_sixteen hp (A + B) (by omega))) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMinorNormBound.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMinorNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f13c31d1bb77925b6733387ad37000664932391 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeMinorNormBound.lean @@ -0,0 +1,126 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedMinorBounds +import OAI.Combinatorics.Progressions.Geometry.CoordinateMinorCovolume + +namespace OAI + +section + +namespace Erdos3 + +theorem lattice_projection_all_minors_bound {ι κ E : Type*} [Fintype ι] {k : ℕ} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (b : Module.Basis (Fin k) ℤ Λ) (f : E →ₗᵢ[ℝ] EuclideanSpace ℝ ι) + (e : κ → ι) (he : Function.Injective e) + (H : Matrix κ (Fin k) ℝ) (hH : ∀ i j, H i j = f (b j).val (e i)) : + ∀ q : Fin k → κ, |(H.submatrix q id).det| ≤ ZLattice.covolume Λ := by + intro q + by_cases hq : Function.Injective q + · have h := abs_isometric_lattice_basis_det_le_covolume Λ b f (e ∘ q) (he.comp hq) + have hm : Matrix.of (fun i j => f (b i).val ((e ∘ q) j)) = + (H.submatrix q id).transpose := by + ext i j + exact (hH (q j) i).symm + simpa only [hm, Matrix.det_transpose] using h + · have hd : (H.submatrix q id).det = 0 := by + by_contra hd + exact hq (nonzero_row_minor_injective H q hd) + rw [hd, abs_zero] + exact (ZLattice.covolume_pos Λ MeasureTheory.volume).le + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem lattice_norm_le_selected_coordinates {ι E : Type*} [Fintype ι] {k : ℕ} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (b : Module.Basis (Fin k) ℤ Λ) (f : E →ₗᵢ[ℝ] EuclideanSpace ℝ ι) + (p : Fin k → ι) + (hp : (Matrix.of (fun i j => f (b j).val (p i))).det ≠ 0) + (C D : ℝ) (hD : 0 < D) (hC : ZLattice.covolume Λ ≤ C) + (hlower : 1 / D ≤ |(Matrix.of (fun i j => f (b j).val (p i))).det|) + (x : E) : + ‖x‖ ≤ (Fintype.card ι : ℝ) * k * (C * D) * ‖fun j => f x (p j)‖ := by + let bR := b.ofZLatticeBasis ℝ Λ + let g := (EuclideanSpace.equiv ι ℝ).toLinearMap.comp f.toLinearMap + let F := Matrix.of (fun i j => g (bR j) i) + have hF (i j) : F i j = f (b j).val i := by + simp only [F, Matrix.of_apply, bR, Module.Basis.ofZLatticeBasis_apply] + rfl + have hminor : ∀ q : Fin k → ι, |(F.submatrix q id).det| ≤ C := by + intro q + exact (lattice_projection_all_minors_bound Λ b f id Function.injective_id F hF q).trans hC + have hp' : (F.submatrix p id).det ≠ 0 := by + have he : F.submatrix p id = Matrix.of (fun i j => f (b j).val (p i)) := by + ext i j + exact hF (p i) j + rwa [he] + have hlower' : 1 / D ≤ |(F.submatrix p id).det| := by + have he : F.submatrix p id = Matrix.of (fun i j => f (b j).val (p i)) := by + ext i j + exact hF (p i) j + rwa [he] + have hC0 : 0 ≤ C := (ZLattice.covolume_pos Λ MeasureTheory.volume).le.trans hC + have hbound := euclidean_matrix_mulVec_norm_le (F * (F.submatrix p id)⁻¹) + (C * D) (mul_nonneg hC0 hD.le) + (row_normalization_abs_le F p hp' C D hD hminor hlower') (fun j => f x (p j)) + have hreconstruct : + (F * (F.submatrix p id)⁻¹) *ᵥ (fun j => f x (p j)) = g x := + basis_image_reconstruct_from_minor bR g p hp' x + have he : (EuclideanSpace.equiv ι ℝ).symm + ((F * (F.submatrix p id)⁻¹) *ᵥ (fun j => f x (p j))) = f x := by + rw [hreconstruct] + exact (EuclideanSpace.equiv ι ℝ).symm_apply_apply (f x) + rw [he, f.norm_map] at hbound + exact hbound + +theorem lattice_norm_le_projection_of_grid_minor + {ι κ E : Type*} [Fintype ι] [Fintype κ] {k : ℕ} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (b : Module.Basis (Fin k) ℤ Λ) (f : E →ₗᵢ[ℝ] EuclideanSpace ℝ ι) + (e : κ → ι) (l : ℕ) (hl : 0 < l) (B : Matrix κ (Fin k) ℝ) + (hB : ∀ i j, B i j = f (b j).val (e i)) + (hgrid : ∀ j, B.col j ∈ realDenominatorGrid l) + (p : Fin k → κ) (hp : (B.submatrix p id).det ≠ 0) + (C : ℝ) (hC : ZLattice.covolume Λ ≤ C) (x : E) : + ‖x‖ ≤ (Fintype.card ι : ℝ) * k * (C * (l : ℝ) ^ k) * + ‖fun i => f x (e i)‖ := by + let M := B.submatrix p id + have hm : Matrix.of (fun i j => f (b j).val ((e ∘ p) i)) = M := by + ext i j + exact (hB (p i) j).symm + have hMgrid (j) : (fun i => M i j) ∈ realDenominatorGrid l := by + obtain ⟨z, hz⟩ := hgrid j + refine ⟨fun i => z (p i), ?_⟩ + funext i + exact congrFun hz (p i) + have hMlower : 1 / (l : ℝ) ^ k ≤ |M.det| := by + simpa only [Fintype.card_fin] using one_div_pow_le_abs_grid_det M l hl hMgrid hp + have hp' : (Matrix.of (fun i j => f (b j).val ((e ∘ p) i))).det ≠ 0 := by rwa [hm] + have hlower : 1 / (l : ℝ) ^ k ≤ + |(Matrix.of (fun i j => f (b j).val ((e ∘ p) i))).det| := by rwa [hm] + have hn := lattice_norm_le_selected_coordinates Λ b f (e ∘ p) hp' C ((l : ℝ) ^ k) + (pow_pos (by exact_mod_cast hl) _) hC hlower x + have hr : ‖fun j => f x ((e ∘ p) j)‖ ≤ ‖fun i => f x (e i)‖ := by + apply (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr + intro j + exact norm_le_pi_norm (fun i => f x (e i)) (p j) + have hC0 : 0 ≤ C := (ZLattice.covolume_pos Λ MeasureTheory.volume).le.trans hC + exact hn.trans (mul_le_mul_of_nonneg_left hr (by positivity)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeNormalizedRefiltering.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeNormalizedRefiltering.lean new file mode 100644 index 0000000000000000000000000000000000000000..40552d3d3b0650278c147c81e94667779ae1c506 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeNormalizedRefiltering.lean @@ -0,0 +1,123 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonRefilteredFactorization +import OAI.Combinatorics.Progressions.Estimates.NativeSlowConstantProduct +import OAI.Combinatorics.Progressions.Polynomial.PrescribedFastPolynomialFactorization + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration VectorPolynomial +open scoped TensorProduct + +theorem exists_lattice_normalized_refiltered_factorization (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ J L : Type*} [Fintype σ] [Fintype J] + [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (w : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ w i})) + (eta : J → L →ₗ[ℚ] ℚ) (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (Fintype.card σ : ℝ) ≤ p → (Fintype.card J : ℝ) ≤ p → + ∀ A : σ → ℝ, (∀ i, Real.exp ((p + C) ^ C) ≤ A i) → + ∀ g : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group, + (∀ j, D.filtration.ControlledSymbolFactorization D.basis w hF (eta j) A + (D.filtration.realPolynomialSymbolHom D.basis w hF (fun _ => 1) g) p) → + ∃ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (v : Fin d → D.filtration.AssociatedGraded) (m : ℕ) (κ : D.RealGroup) + (E b R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group), + Submodule.span ℚ (Set.range v) = W.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis w hF) w W.toSubmodule ∧ + (∀ i k, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis w hF).repr (v i) k) ≤ + (p + C) ^ C) ∧ + (∀ j x, x ∈ D.filtration.realGradedRefiltrationLayer W s → realifyFunctional (eta j) x = 0) ∧ + 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ κ ∈ D.realLattice ∧ + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) κ = g ∧ + (∀ α i, |(D.basis.baseChange ℝ).repr + (coefficients (E.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α) i| ≤ + Real.exp ((p + C) ^ C) / monomialScale A α) ∧ + ((fun z : (σ →₀ ℕ) × Fin d => (D.basis.baseChange ℝ).repr + (coefficients (R.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) z.1) z.2) ∈ realDenominatorGrid m) ∧ + coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 ∧ + coefficients (R.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 ∧ + (∀ α, coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α ∈ + D.filtration.realGradedRefiltrationLayer W (Finsupp.weight (fun _ => 1) α)) ∧ + (∀ t : σ → ℝ, eval₂ t (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) ∈ + realificationLieSubalgebra (D.filtration.gradedRefiltrationSubalgebra W)) := by + obtain ⟨c, _, hnormalize⟩ := exists_native_polynomial_normalization s + obtain ⟨k, _, hcommon⟩ := exists_common_refiltered_factorization s + obtain ⟨l, _, hleft⟩ := exists_native_slow_left_constant_bound s + let N : Polynomial ℕ := (Polynomial.X + Polynomial.C c) ^ c + let F : Polynomial ℕ := (Polynomial.X + 2) ^ k + let H : Polynomial ℕ := ((Polynomial.X + 2) ^ 2 + 2) ^ 63 + 1 + let Q : Polynomial ℕ := Polynomial.X + N + F + let P : Polynomial ℕ := F + H + (Q + Polynomial.C l) ^ l + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ J L _ _ _ _ d _ _ _ D w hF eta p hp hD hσ hJ A hA g hfactor + let q := p + (p + c) ^ c + (p + 2) ^ k + have hn0 : 0 ≤ (p + c) ^ c := by positivity + have hf0 : 0 ≤ (p + 2) ^ k := by positivity + have hh0 : 0 ≤ ((p + 2) ^ 2 + 2) ^ 63 + 1 := by positivity + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have hnq : (p + c) ^ c ≤ q := by dsimp [q]; linarith + have hfq : (p + 2) ^ k ≤ q := by dsimp [q]; linarith + have hb : (p + 2) ^ k + (((p + 2) ^ 2 + 2) ^ 63 + 1) + (q + l) ^ l ≤ (p + C) ^ C := by + simpa [P, Q, N, F, H, q, Polynomial.eval₂_pow] using hbudget p hp + have hl0 : 0 ≤ (q + l) ^ l := by positivity + have hfC : (p + 2) ^ k ≤ (p + C) ^ C := by linarith + have hhC : ((p + 2) ^ 2 + 2) ^ 63 + 1 ≤ (p + C) ^ C := by linarith + have hlC : (q + l) ^ l ≤ (p + C) ^ C := by linarith + have hApos : ∀ i, 0 < A i := fun i => (Real.exp_pos _).trans_le (hA i) + obtain ⟨a, κ, g₀, ha, hκ, hnormalizeEq, hg₀zero, hsymbol⟩ := + hnormalize D w hF (fun _ : σ => 1) p hp hD g + have hfactor₀ : ∀ j, D.filtration.ControlledSymbolFactorization D.basis w hF (eta j) A + (D.filtration.realPolynomialSymbolHom D.basis w hF (fun _ => 1) g₀) p := by + intro j + rw [hsymbol] + exact hfactor j + obtain ⟨W, v, m, e₀, b, R, hv, hW, hheight, hfreq, hm, hmp, hebr, + hmid, he, hR, _, hR0, hb0, hvalues⟩ := + hcommon D.filtration D.basis w hF eta p hp + (by simpa only [Fintype.card_fin] using hD.1) hσ hJ (fun i j k => hD.2.2.1 i j k) + A (fun i => (Real.exp_le_exp.mpr hfC).trans (hA i)) g₀ hfactor₀ + let E := D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) a * e₀ + have hE : D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) A + (Real.exp ((p + C) ^ C)) E := by + have hsmall := hleft D w hF q hq (RationalFilteredNilmanifold.GeometryComplexityLE.mono D hD hpq) + (hσ.trans hpq) A hApos a (fun i => (ha i).trans (Real.exp_le_exp.mpr hnq)) e₀ + (D.filtration.polynomialSlowBound_mono D.basis (fun _ => 1) A hApos (Real.exp_le_exp.mpr hfq) e₀ he) + exact D.filtration.polynomialSlowBound_mono D.basis (fun _ => 1) A hApos + (Real.exp_le_exp.mpr hlC) E hsmall + have hprod : E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) κ = g := by + calc + _ = D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) a * + (e₀ * b * R) * D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) κ := by + simp only [E, mul_assoc] + _ = g := by rw [hebr]; exact hnormalizeEq + let e := Fintype.equivFin (Fin d) + have hrange : Set.range (fun i => v (e i)) = Set.range v := by + ext x + constructor + · rintro ⟨i, rfl⟩ + exact ⟨e i, rfl⟩ + · rintro ⟨i, rfl⟩ + obtain ⟨j, hj⟩ := e.surjective i + exact ⟨j, congrArg v hj⟩ + have hv' : Submodule.span ℚ (Set.range (fun i => v (e i))) = W.toSubmodule := by + rw [hrange] + exact hv + refine ⟨W, (fun i => v (e i)), m, κ, E, b, R, hv', hW, + (fun i j => (hheight (e i) j).trans hhC), hfreq, hm, + hmp.trans (Real.exp_le_exp.mpr hfC), hκ, hprod, hE, hR, + hb0.trans hg₀zero, hR0, ?_, hvalues hg₀zero⟩ + exact (D.filtration.real_symbol_values_iff_refiltration_coefficients D.basis w hF + (fun _ => 1) W b.coord).mp hmid + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeOrderedGenerators.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeOrderedGenerators.lean new file mode 100644 index 0000000000000000000000000000000000000000..78ed2132c52c49f3326bf5675731e68cd5df5dec --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeOrderedGenerators.lean @@ -0,0 +1,153 @@ +import Mathlib.GroupTheory.SpecificGroups.Cyclic.Basic +import OAI.Combinatorics.Progressions.Estimates.PowerIndexFromOrderedGenerators +import OAI.Combinatorics.Progressions.Nilpotent.BCHOuterGridChangeBasis + +namespace OAI + +section + +namespace Erdos3.IsCentralLieBasis + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d s : ℕ} + {e : Basis (Fin d) ℚ L} (he : IsCentralLieBasis e) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + +include he + +def leadingCoordinateSubgroup (j : Fin d) : AddSubgroup ℚ where + carrier := {q | ∃ g ∈ Γ, g.coord ∈ basisTail e j.val ∧ e.repr g.coord j = q} + zero_mem' := ⟨1, Γ.one_mem, (basisTail e j.val).zero_mem, by simp⟩ + add_mem' := by + rintro a b ⟨g, hg, hgt, rfl⟩ ⟨h, hh, hht, rfl⟩ + refine ⟨g * h, Γ.mul_mem hg hh, ?_, ?_⟩ + · exact (NilpotentLieBCHGroup.subgroup (he.tailIdeal j.val).toLieSubalgebra).mul_mem hgt hht + · exact he.bch_low_coordinate hnil j.val g.coord hht j le_rfl + neg_mem' := by + rintro a ⟨g, hg, hgt, rfl⟩ + exact ⟨g⁻¹, Γ.inv_mem hg, (basisTail e j.val).neg_mem hgt, by simp⟩ + +theorem leadingCoordinateSubgroup_le_zmultiples (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) (j : Fin d) : + he.leadingCoordinateSubgroup hnil Γ j ≤ AddSubgroup.zmultiples ((l : ℚ)⁻¹) := by + rintro q ⟨g, hg, _, rfl⟩ + obtain ⟨z, hz⟩ := (mem_denominatorGrid_iff l hl _).mp + (hgrid ((bchSubgroupCoordinates_repr e Γ g).mpr hg)) + apply AddSubgroup.mem_zmultiples_iff.mpr + refine ⟨z j, ?_⟩ + simpa only [zsmul_eq_mul, div_eq_mul_inv, Basis.equivFun_apply] using (hz j).symm + +theorem leadingCoordinateSubgroup_isAddCyclic (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) (j : Fin d) : + IsAddCyclic (he.leadingCoordinateSubgroup hnil Γ j) := + AddSubgroup.isAddCyclic_of_le (he.leadingCoordinateSubgroup_le_zmultiples hnil Γ l hl hgrid j) + +theorem exists_tail_generator (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) (j : Fin d) : + ∃ a ∈ Γ, a.coord ∈ basisTail e j.val ∧ + ∀ g ∈ Γ, g.coord ∈ basisTail e j.val → + ∃ n : ℤ, ((a ^ n)⁻¹ * g).coord ∈ basisTail e (j.val + 1) := by + let H := he.leadingCoordinateSubgroup hnil Γ j + let : IsAddCyclic H := he.leadingCoordinateSubgroup_isAddCyclic hnil Γ l hl hgrid j + obtain ⟨q, hq⟩ := (AddSubgroup.isAddCyclic_iff_exists_zmultiples_eq_top H).mp inferInstance + have hqmem : q ∈ H := hq ▸ AddSubgroup.mem_zmultiples q + obtain ⟨a, ha, hat, haq⟩ := hqmem + refine ⟨a, ha, hat, ?_⟩ + intro g hg hgt + have hcoord : e.repr g.coord j ∈ H := ⟨g, hg, hgt, rfl⟩ + rw [← hq] at hcoord + obtain ⟨n, hn⟩ := AddSubgroup.mem_zmultiples_iff.mp hcoord + refine ⟨n, (mem_basisTail_succ_iff e j _).mpr ⟨?_, ?_⟩⟩ + · let T := NilpotentLieBCHGroup.subgroup (hnil := hnil) (he.tailIdeal j.val).toLieSubalgebra + exact T.mul_mem (T.inv_mem (T.zpow_mem hat n)) hgt + · change e.repr (lieBCH s (-((a ^ n).coord)) g.coord) j = 0 + rw [he.bch_low_coordinate hnil j.val _ hgt j le_rfl] + simp only [map_neg, Finsupp.neg_apply, NilpotentLieBCHGroup.coord_zpow, + map_zsmul, Finsupp.smul_apply, haq, hn, neg_add_cancel] + +end Erdos3.IsCentralLieBasis + +end + +section + +namespace Erdos3.IsCentralLieBasis + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d s : ℕ} + {e : Basis (Fin d) ℚ L} (he : IsCentralLieBasis e) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + +include he + +theorem exists_ordered_lattice_generators (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ a : Fin d → NilpotentLieBCHGroup L s hnil, + (∀ j, a j ∈ Γ) ∧ (∀ j, (a j).coord ∈ basisTail e j.val) ∧ + ∀ g ∈ Γ, ∃ z : Fin d → ℤ, orderedZpowProduct a z = g := by + classical + choose a ha hat hpeel using fun j => he.exists_tail_generator hnil Γ l hl hgrid j + have hfactor (k i : ℕ) (hik : i + k = d) + (g : NilpotentLieBCHGroup L s hnil) (hg : g ∈ Γ) (hgt : g.coord ∈ basisTail e i) : + ∃ z : Fin d → ℤ, orderedGroupTailProduct (fun j => a j ^ z j) i = g := by + induction k generalizing i g with + | zero => + have hi : i = d := by omega + subst i + refine ⟨fun _ => 0, ?_⟩ + rw [orderedGroupTailProduct_terminal _ le_rfl] + apply NilpotentLieBCHGroup.ext + have hz : g.coord = 0 := by + simpa only [basisTail_terminal, Submodule.mem_bot] using hgt + exact hz.symm + | succ k ih => + have hi : i < d := by omega + let j : Fin d := ⟨i, hi⟩ + obtain ⟨n, hn⟩ := hpeel j g hg hgt + let r := (a j ^ n)⁻¹ * g + have hr : r ∈ Γ := Γ.mul_mem (Γ.inv_mem (Γ.zpow_mem (ha j) n)) hg + obtain ⟨z, hz⟩ := ih (i + 1) (by omega) r hr hn + let u := Function.update z j n + have huj : u j = n := by simp [u] + have hu : orderedGroupTailProduct (fun j => a j ^ u j) (i + 1) = + orderedGroupTailProduct (fun j => a j ^ z j) (i + 1) := by + apply orderedGroupTailProduct_congr + intro v hv + have hvj : v ≠ j := by + intro h + subst v + change i + 1 ≤ i at hv + omega + change a v ^ Function.update z j n v = a v ^ z v + rw [Function.update_of_ne hvj] + refine ⟨u, ?_⟩ + change orderedGroupTailProduct (fun j => a j ^ u j) j.val = g + rw [orderedGroupTailProduct_step, huj] + change a j ^ n * orderedGroupTailProduct (fun j => a j ^ u j) (i + 1) = g + rw [hu, hz] + exact mul_inv_cancel_left (a j ^ n) g + refine ⟨a, ha, hat, ?_⟩ + intro g hg + exact hfactor d 0 (by omega) g hg (by simp [basisTail_zero]) + +theorem exists_surjective_orderedZpowProduct (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ a : Fin d → Γ, Function.Surjective (orderedZpowProduct a) := by + obtain ⟨a, ha, _, hgen⟩ := he.exists_ordered_lattice_generators hnil Γ l hl hgrid + refine ⟨fun j => ⟨a j, ha j⟩, ?_⟩ + intro g + obtain ⟨z, hz⟩ := hgen g g.property + refine ⟨z, Subtype.ext ?_⟩ + change Γ.subtype (orderedZpowProduct (fun j => ⟨a j, ha j⟩) z) = g.val + rw [orderedZpowProduct_map] + exact hz + +end Erdos3.IsCentralLieBasis + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeSheetHaar.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeSheetHaar.lean new file mode 100644 index 0000000000000000000000000000000000000000..53e4ae65f7626cd28581f08f8298774877b6cca8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeSheetHaar.lean @@ -0,0 +1,568 @@ +import OAI.Combinatorics.Progressions.Estimates.OrthogonalBlockGram +import OAI.Combinatorics.Progressions.Estimates.QuotientTranslatePartition +import OAI.Combinatorics.Progressions.Linear.NormalHyperplaneProjection +import OAI.Combinatorics.Progressions.Polynomial.SchmidtHyperplaneTransfer + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem zspan_covolume_sq_eq_det_gram_fintype + {ι E : Type*} [Fintype ι] [DecidableEq ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] (b : Basis ι ℝ E) : + ZLattice.covolume (Submodule.span ℤ (Set.range b)) ^ 2 = (Matrix.gram ℝ b).det := by + classical + let e := Fintype.equivFin ι + let b' := b.reindex e + have hspan : Submodule.span ℤ (Set.range b') = Submodule.span ℤ (Set.range b) := by + congr 1 + simp [b', Basis.coe_reindex] + have hgram : Matrix.gram ℝ b' = (Matrix.gram ℝ b).submatrix e.symm e.symm := by + ext i j + simp [b', Matrix.gram_apply] + have h := zspan_covolume_sq_eq_det_gram b' + rw [hspan, hgram, Matrix.det_submatrix_equiv_self] at h + exact h + +theorem lattice_covolume_sq_eq_gram + {ι E : Type*} [Fintype ι] [DecidableEq ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] (b : Basis ι ℤ Λ) : + ZLattice.covolume Λ ^ 2 = (Matrix.gram ℝ (b.ofZLatticeBasis ℝ Λ)).det := by + have h := zspan_covolume_sq_eq_det_gram_fintype (b.ofZLatticeBasis ℝ Λ) + simpa only [b.ofZLatticeBasis_span ℝ] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +theorem latticeHyperplane_covolume_sq (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (ξ : E) (hξ : ξ ≠ 0) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : inner ℝ ξ w = 1) : + ZLattice.covolume Λ ^ 2 = + ZLattice.covolume (latticeHyperplane Λ (normalFunctional ξ)) ^ 2 * (‖ξ‖⁻¹) ^ 2 := by + classical + let f := normalFunctional ξ + let K := latticeHyperplane Λ f + let : IsZLattice ℝ K := latticeHyperplane_isZLattice Λ f hint w hwΛ hw + let bK := Module.Free.chooseBasis ℤ K + let b := latticeHyperplaneBasis Λ f hint w hwΛ hw bK + let bR := b.ofZLatticeBasis ℝ Λ + let bKR := bK.ofZLatticeBasis ℝ K + have hinl (i) : bR (Sum.inl i) = (bKR i : E) := by + simpa only [bR, bKR, Module.Basis.ofZLatticeBasis_apply, b] using + latticeHyperplaneBasis_inl Λ f hint w hwΛ hw bK i + have hinr (j : Unit) : bR (Sum.inr j) = w := by + simpa only [bR, Module.Basis.ofZLatticeBasis_apply, b] using + latticeHyperplaneBasis_inr Λ f hint w hwΛ hw bK j + have hspan : Submodule.span ℝ (Set.range (fun i => bR (Sum.inl i))) = f.ker := by + rw [show (fun i => bR (Sum.inl i)) = (fun i => (bKR i : E)) from funext hinl] + change Submodule.span ℝ (Set.range (f.ker.subtype ∘ bKR)) = _ + rw [Set.range_comp, ← Submodule.map_span, bKR.span_eq, + Submodule.map_top, Submodule.range_subtype] + have hkernel : (Matrix.gram ℝ (fun i => bR (Sum.inl i))).det = ZLattice.covolume K ^ 2 := by + have he : Matrix.gram ℝ (fun i => bR (Sum.inl i)) = Matrix.gram ℝ bKR := by + ext i j + simp only [Matrix.gram_apply, hinl] + rfl + rw [he] + exact (lattice_covolume_sq_eq_gram K bK).symm + have hblock := gram_det_orthogonal_block bR + dsimp only at hblock + rw [hspan, hkernel, Matrix.det_unique (n := Unit), Matrix.gram_apply, hinr, + real_inner_self_eq_norm_sq, normalHyperplane_height ξ w hξ hw] at hblock + rw [lattice_covolume_sq_eq_gram Λ b] + exact hblock + +theorem latticeHyperplane_covolume (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (ξ : E) (hξ : ξ ≠ 0) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : inner ℝ ξ w = 1) : + ZLattice.covolume (latticeHyperplane Λ (normalFunctional ξ)) = + ‖ξ‖ * ZLattice.covolume Λ := by + let := latticeHyperplane_isZLattice Λ (normalFunctional ξ) hint w hwΛ hw + have h := latticeHyperplane_covolume_sq Λ ξ hξ hint w hwΛ hw + have hn : 0 < ‖ξ‖ := norm_pos_iff.mpr hξ + have hc := ZLattice.covolume_pos Λ MeasureTheory.volume + have hk := ZLattice.covolume_pos (latticeHyperplane Λ (normalFunctional ξ)) MeasureTheory.volume + have hs : (‖ξ‖ * ZLattice.covolume Λ) ^ 2 = + ZLattice.covolume (latticeHyperplane Λ (normalFunctional ξ)) ^ 2 := by + rw [mul_pow, h] + field_simp + nlinarith [mul_pos hn hc] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory Module + +variable {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +omit [FiniteDimensional ℝ E] in +theorem basis_equivFun_measurePreserving (b : Basis ι ℝ E) : + MeasurePreserving b.equivFunL b.addHaar volume := by + classical + refine ⟨b.equivFunL.continuous.measurable, ?_⟩ + rw [Basis.map_addHaar] + have hb : b.map b.equivFun = Pi.basisFun ℝ ι := by + ext i j + simp [Basis.equivFun_self, Pi.basisFun_apply, Pi.single_apply, eq_comm] + change (b.map b.equivFun).addHaar = volume + rw [hb, Basis.addHaar_def, Basis.parallelepiped_basisFun, + addHaarMeasure_eq_volume_pi] + +theorem volume_eq_covolume_smul_basis_addHaar (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : Basis ι ℤ Λ) : + (volume : Measure E) = ENNReal.ofReal (ZLattice.covolume Λ) • + (b.ofZLatticeBasis ℝ Λ).addHaar := by + let bR := b.ofZLatticeBasis ℝ Λ + have hcov : ZLattice.covolume Λ = volume.real (parallelepiped bR) := by + rw [ZLattice.covolume_eq_measure_fundamentalDomain Λ volume + (ZLattice.isAddFundamentalDomain b volume)] + exact measureReal_congr (ZSpan.fundamentalDomain_ae_parallelepiped bR volume) + have h := Measure.addHaarMeasure_unique (volume : Measure E) bR.parallelepiped + have hfinite : volume (parallelepiped bR) ≠ ⊤ := by + simpa only [Basis.coe_parallelepiped] using bR.parallelepiped.isCompact.measure_ne_top (μ := volume) + rw [Basis.addHaar_def] + rw [hcov, measureReal_def, ENNReal.ofReal_toReal hfinite] + exact h + +theorem latticeBasis_integral_cube (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : Basis ι ℤ Λ) (f : E → ℂ) : + (ZLattice.covolume Λ : ℂ) * + (∫ x : ι → ℝ in Set.pi Set.univ (fun _ => Set.Ico (0 : ℝ) 1), + f ((b.ofZLatticeBasis ℝ Λ).equivFun.symm x)) = + ∫ x in ZSpan.fundamentalDomain (b.ofZLatticeBasis ℝ Λ), f x := by + let bR := b.ofZLatticeBasis ℝ Λ + have hp := basis_equivFun_measurePreserving bR + have hpre : bR.equivFunL ⁻¹' Set.pi Set.univ (fun _ => Set.Ico (0 : ℝ) 1) = + ZSpan.fundamentalDomain bR := by + ext x + simp [ZSpan.fundamentalDomain] + have hi := hp.setIntegral_preimage_emb bR.equivFunL.toHomeomorph.measurableEmbedding + (f ∘ bR.equivFun.symm) (Set.pi Set.univ (fun _ => Set.Ico (0 : ℝ) 1)) + simp only [hpre, Function.comp_apply] at hi + have hi' : (∫ x in ZSpan.fundamentalDomain bR, f x ∂bR.addHaar) = + ∫ x : ι → ℝ in Set.pi Set.univ (fun _ => Set.Ico (0 : ℝ) 1), f (bR.equivFun.symm x) := by + convert hi using 1 + congr 1 + funext x + exact congrArg f (bR.equivFun.symm_apply_apply x).symm + conv_rhs => rw [volume_eq_covolume_smul_basis_addHaar Λ b, Measure.restrict_smul, + integral_smul_measure, ENNReal.toReal_ofReal (ZLattice.covolume_pos Λ volume).le] + change _ = (ZLattice.covolume Λ : ℂ) * _ + rw [hi'] + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +noncomputable def latticeGaussianNormalizer (Λ : Submodule ℤ E) (t : ℝ) : ℝ := + (Real.sqrt t) ^ Module.finrank ℝ E * ZLattice.covolume Λ + +noncomputable def normalizedLatticeGaussian (Λ : Submodule ℤ E) (t : ℝ) (x : E) : ℝ := + latticeGaussianNormalizer Λ t * latticeGaussianMass Λ t x + +theorem latticeGaussianNormalizer_nonneg (Λ : Submodule ℤ E) (t : ℝ) : + 0 ≤ latticeGaussianNormalizer Λ t := + mul_nonneg (pow_nonneg (Real.sqrt_nonneg _) _) ENNReal.toReal_nonneg + +theorem latticeGaussianNormalizer_pos (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] {t : ℝ} (ht : 0 < t) : 0 < latticeGaussianNormalizer Λ t := + mul_pos (pow_pos (Real.sqrt_pos.mpr ht) _) (ZLattice.covolume_pos Λ MeasureTheory.volume) + +theorem normalizedLatticeGaussian_nonneg (Λ : Submodule ℤ E) (t : ℝ) (x : E) : + 0 ≤ normalizedLatticeGaussian Λ t x := + mul_nonneg (latticeGaussianNormalizer_nonneg Λ t) (latticeGaussianMass_nonneg Λ t x) + +theorem normalizedLatticeGaussian_pos (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] {t : ℝ} (ht : 0 < t) (x : E) : + 0 < normalizedLatticeGaussian Λ t x := + mul_pos (latticeGaussianNormalizer_pos Λ ht) (latticeGaussianMass_pos Λ ht x) + +theorem latticeGaussianNormalizer_hyperplane (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (ξ : E) (hξ : ξ ≠ 0) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : inner ℝ ξ w = 1) + {t ε : ℝ} (ht : 0 ≤ t) (hε : 0 ≤ 1 + ε) : + Real.sqrt t * latticeGaussianNormalizer (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2) = + ‖ξ‖ * (1 + ε) ^ Module.finrank ℝ (normalFunctional ξ).ker * + latticeGaussianNormalizer Λ t := by + unfold latticeGaussianNormalizer + rw [Real.sqrt_mul ht, Real.sqrt_sq hε, + latticeHyperplane_covolume Λ ξ hξ hint w hwΛ hw, + ← hyperplane_finrank (normalFunctional ξ) w hw, pow_succ, mul_pow] + ring + +theorem normalizedLatticeGaussian_transfer (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (ξ : E) (hξ : ξ ≠ 0) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : inner ℝ ξ w = 1) + {t ε c : ℝ} (ht : 0 ≤ t) (hε : 0 ≤ 1 + ε) + (x : E) (y : (normalFunctional ξ).ker) + (htransfer : c * latticeGaussianMass (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2) y ≤ latticeGaussianMass Λ t x) : + c * Real.sqrt t * normalizedLatticeGaussian (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2) y ≤ + ‖ξ‖ * (1 + ε) ^ Module.finrank ℝ (normalFunctional ξ).ker * + normalizedLatticeGaussian Λ t x := by + have h := mul_le_mul_of_nonneg_left htransfer + (mul_nonneg (mul_nonneg (norm_nonneg ξ) + (pow_nonneg hε (Module.finrank ℝ (normalFunctional ξ).ker))) + (latticeGaussianNormalizer_nonneg Λ t)) + have hid := latticeGaussianNormalizer_hyperplane Λ ξ hξ hint w hwΛ hw ht hε + unfold normalizedLatticeGaussian + calc + _ = (Real.sqrt t * latticeGaussianNormalizer (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2)) * + (c * latticeGaussianMass (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2) y) := by ring + _ = (‖ξ‖ * (1 + ε) ^ Module.finrank ℝ (normalFunctional ξ).ker * + latticeGaussianNormalizer Λ t) * + (c * latticeGaussianMass (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2) y) := by rw [hid] + _ ≤ _ := by simpa only [mul_assoc] using h + +theorem exists_normalized_schmidt_hyperplane_transfer (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (ξ : E) (hξ : ξ ≠ 0) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : inner ℝ ξ w = 1) + (α : E) {N k : ℕ} {t ε : ℝ} (ht : 0 < t) (hε : 0 ≤ ε) (hεone : ε ≤ 1) + (hsmall : Real.sqrt t * ((N : ℝ) ^ k * + (CircleFourier.integerDistance ((inner ℝ ξ α : ℝ) : CircleFourier.Circle) / ‖ξ‖)) ≤ ε) : + ∃ β : (normalFunctional ξ).ker, ∀ n : ℤ, |n| ≤ (N : ℤ) → + Real.exp (-4 * Real.pi) * Real.sqrt t * + normalizedLatticeGaussian (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2) ((n : ℝ) ^ k • β) ≤ + ‖ξ‖ * (1 + ε) ^ Module.finrank ℝ (normalFunctional ξ).ker * + normalizedLatticeGaussian Λ t ((n : ℝ) ^ k • α) := by + obtain ⟨β, hβ⟩ := exists_schmidt_hyperplane_transfer_at_temperature Λ ξ hξ w hwΛ hw + α ht hε hεone hsmall + exact ⟨β, fun n hn => normalizedLatticeGaussian_transfer Λ ξ hξ hint w hwΛ hw ht.le + (by linarith) _ _ (hβ n hn)⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory Module + +variable {E I : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype I] + +theorem lattice_fundamentalDomain_volume (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : Basis I ℤ Λ) : + volume (ZSpan.fundamentalDomain (b.ofZLatticeBasis ℝ Λ)) = + ENNReal.ofReal (ZLattice.covolume Λ) := by + rw [ZLattice.covolume_eq_measure_fundamentalDomain Λ volume + (ZLattice.isAddFundamentalDomain b volume), measureReal_def, + ENNReal.ofReal_toReal (ZSpan.fundamentalDomain_isBounded _).measure_lt_top.ne] + +theorem lattice_quotient_scaled_haar (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : Basis I ℤ Λ) + (μ : Measure (E ⧸ Λ.toAddSubgroup)) [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] : + ENNReal.ofReal (ZLattice.covolume Λ) • μ = + Measure.map (QuotientAddGroup.mk : E → E ⧸ Λ.toAddSubgroup) + (volume.restrict (ZSpan.fundamentalDomain (b.ofZLatticeBasis ℝ Λ))) := by + let F := ZSpan.fundamentalDomain (b.ofZLatticeBasis ℝ Λ) + let : Countable Λ.toAddSubgroup := b.repr.injective.countable + let : Countable Λ.toAddSubgroup.op := Λ.toAddSubgroup.equivOp.symm.injective.countable + have hF : IsAddFundamentalDomain Λ.toAddSubgroup F volume := + ZLattice.isAddFundamentalDomain b volume + have hop := additiveFundamentalDomain_op Λ.toAddSubgroup hF + let : HasAddFundamentalDomain Λ.toAddSubgroup.op E volume := ⟨F, hop⟩ + have hclosed : IsClosed (Λ.toAddSubgroup : Set E) := AddSubgroup.isClosed_of_discreteTopology + let : IsClosed (Λ.toAddSubgroup : Set E) := hclosed + let c := ENNReal.ofReal (ZLattice.covolume Λ) + let : IsFiniteMeasure (c • μ) := μ.smul_finite ENNReal.ofReal_ne_top + have hscale : addCovolume Λ.toAddSubgroup.op E volume = (c • μ) Set.univ := by + rw [hop.covolume_eq_volume volume, Measure.smul_apply, measure_univ, smul_eq_mul, mul_one] + exact lattice_fundamentalDomain_volume Λ b + let : AddQuotientMeasureEqMeasurePreimage volume (c • μ) := + leftInvariantIsAddQuotientMeasureEqMeasurePreimage (ν := volume) hscale + exact hop.addProjection_respects_measure (c • μ) + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +omit [MeasurableSpace E] [BorelSpace E] in +theorem latticeGaussianMass_antitone (Λ : Submodule ℤ E) [DiscreteTopology Λ] + {s t : ℝ} (hs : 0 < s) (hst : s ≤ t) (x : E) : + latticeGaussianMass Λ t x ≤ latticeGaussianMass Λ s x := by + apply (lattice_gaussian_summable Λ (hs.trans_le hst) x).tsum_le_tsum + _ (lattice_gaussian_summable Λ hs x) + intro m + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonpos_left hst (neg_nonpos.mpr Real.pi_pos.le)) (sq_nonneg _) + +theorem normalizedLatticeGaussian_hyperplane_origin_le (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (ξ : E) (hξ : ξ ≠ 0) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ)) + (w : E) (hwΛ : w ∈ Λ) (hw : inner ℝ ξ w = 1) + {t ε : ℝ} (ht : 0 < t) (hε : 0 ≤ ε) : + Real.sqrt t * normalizedLatticeGaussian (latticeHyperplane Λ (normalFunctional ξ)) + (t * (1 + ε) ^ 2) 0 ≤ + ‖ξ‖ * (1 + ε) ^ Module.finrank ℝ (normalFunctional ξ).ker * + normalizedLatticeGaussian Λ t 0 := by + have htemp : t ≤ t * (1 + ε) ^ 2 := by nlinarith [mul_nonneg ht.le (sq_nonneg ε)] + have hmass := (latticeGaussianMass_antitone (latticeHyperplane Λ (normalFunctional ξ)) + ht htemp 0).trans (latticeGaussianMass_hyperplane_le Λ (normalFunctional ξ) ht 0) + simpa only [one_mul] using normalizedLatticeGaussian_transfer Λ ξ hξ hint w hwΛ hw + ht.le (by linarith) 0 0 (c := 1) (by simpa only [one_mul, Submodule.coe_zero] using hmass) + +theorem lattice_covolume_of_finrank_zero (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (hd : Module.finrank ℝ E = 0) : ZLattice.covolume Λ = 1 := by + classical + let b := Module.Free.chooseBasis ℤ Λ + have hcard : Fintype.card (Module.Free.ChooseBasisIndex ℤ Λ) = 0 := by + rw [← Module.finrank_eq_card_basis b, ZLattice.rank ℝ Λ, hd] + let : IsEmpty (Module.Free.ChooseBasisIndex ℤ Λ) := Fintype.card_eq_zero_iff.mp hcard + have h := lattice_covolume_sq_eq_gram Λ b + rw [Matrix.det_isEmpty] at h + nlinarith [ZLattice.covolume_pos Λ MeasureTheory.volume] + +theorem normalizedLatticeGaussian_of_finrank_zero (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (hd : Module.finrank ℝ E = 0) (t : ℝ) (x : E) : + normalizedLatticeGaussian Λ t x = 1 := by + let : Subsingleton E := Module.finrank_zero_iff.mp hd + have hx : x = 0 := Subsingleton.elim _ _ + let : Unique Λ := ⟨⟨0⟩, fun _ => Subsingleton.elim _ _⟩ + simp [normalizedLatticeGaussian, latticeGaussianNormalizer, hd, + lattice_covolume_of_finrank_zero Λ hd, latticeGaussianMass, hx] + exact Or.inr (Subsingleton.elim _ _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory Module Set + +variable {E I : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype I] + +theorem lattice_quotient_haar_image (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : Basis I ℤ Λ) + (μ : Measure (E ⧸ Λ.toAddSubgroup)) [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] + {A : Set E} (hAm : MeasurableSet A) + (hA : InjOn (QuotientAddGroup.mk : E → E ⧸ Λ.toAddSubgroup) A) : + μ ((QuotientAddGroup.mk : E → E ⧸ Λ.toAddSubgroup) '' A) = + volume A / ENNReal.ofReal (ZLattice.covolume Λ) := by + let : Countable Λ.toAddSubgroup := b.repr.injective.countable + let : IsClosed (Λ.toAddSubgroup : Set E) := AddSubgroup.isClosed_of_discreteTopology + have hq : Continuous (QuotientAddGroup.mk : E → E ⧸ Λ.toAddSubgroup) := + continuous_quotient_mk' + have him := hAm.image_of_continuousOn_injOn hq.continuousOn hA + have he := congrArg + (fun ν : Measure (E ⧸ Λ.toAddSubgroup) => ν + ((QuotientAddGroup.mk : E → E ⧸ Λ.toAddSubgroup) '' A)) + (lattice_quotient_scaled_haar Λ b μ) + rw [Measure.smul_apply, smul_eq_mul, Measure.map_apply hq.measurable him, + Measure.restrict_apply (him.preimage hq.measurable)] at he + rw [quotient_injective_lift_measure Λ.toAddSubgroup volume + (ZLattice.isAddFundamentalDomain b volume) + (ZSpan.fundamentalDomain_measurableSet _) hAm hA] at he + exact (ENNReal.eq_div_iff (ENNReal.ofReal_pos.mpr (ZLattice.covolume_pos Λ volume)).ne' + ENNReal.ofReal_ne_top).mpr he + +theorem lattice_quotient_haar_translated_image (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (b : Basis I ℤ Λ) + (μ : Measure (E ⧸ Λ.toAddSubgroup)) [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] + (v : E) {A : Set E} (hAm : MeasurableSet A) + (hA : InjOn (fun x => (QuotientAddGroup.mk (x - v) : E ⧸ Λ.toAddSubgroup)) A) : + μ ((fun x => (QuotientAddGroup.mk (x - v) : E ⧸ Λ.toAddSubgroup)) '' A) = + volume A / ENNReal.ofReal (ZLattice.covolume Λ) := by + have hBm : MeasurableSet ((fun x : E => x - v) '' A) := + hAm.image_of_continuousOn_injOn (continuous_id.sub continuous_const).continuousOn + (fun _ _ _ _ he => sub_left_inj.mp he) + have hB : InjOn (QuotientAddGroup.mk : E → E ⧸ Λ.toAddSubgroup) + ((fun x : E => x - v) '' A) := by + rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ he + exact congrArg (fun z => z - v) (hA hx hy he) + have hset : ((fun x : E => x - v) '' A) = (fun x => x + v) ⁻¹' A := by + ext x + constructor + · rintro ⟨y, hy, rfl⟩ + simpa only [mem_preimage, sub_add_cancel] using hy + · intro hx + exact ⟨x + v, hx, add_sub_cancel_right x v⟩ + have he := lattice_quotient_haar_image Λ b μ hBm hB + rw [image_image] at he + rw [he, hset, measure_preimage_add_right] + +theorem lattice_quotient_haar_countable_sheets {T : Type*} [Countable T] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] (b : Basis I ℤ Λ) + (μ : Measure (E ⧸ Λ.toAddSubgroup)) [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] + (v : T → E) (A : T → Set E) (hAm : ∀ t, MeasurableSet (A t)) + (hA : ∀ t, InjOn (fun x => (QuotientAddGroup.mk (x - v t) : E ⧸ Λ.toAddSubgroup)) (A t)) + (hdisj : Pairwise (fun s t => Disjoint + ((fun x => (QuotientAddGroup.mk (x - v s) : E ⧸ Λ.toAddSubgroup)) '' A s) + ((fun x => (QuotientAddGroup.mk (x - v t) : E ⧸ Λ.toAddSubgroup)) '' A t))) : + μ (⋃ t, (fun x => (QuotientAddGroup.mk (x - v t) : E ⧸ Λ.toAddSubgroup)) '' A t) = + (∑' t, volume (A t)) / ENNReal.ofReal (ZLattice.covolume Λ) := by + let : IsClosed (Λ.toAddSubgroup : Set E) := AddSubgroup.isClosed_of_discreteTopology + rw [measure_iUnion hdisj (fun t => (hAm t).image_of_continuousOn_injOn + (continuous_quotient_mk'.comp (continuous_id.sub continuous_const)).continuousOn (hA t))] + simp_rw [lattice_quotient_haar_translated_image Λ b μ _ (hAm _) (hA _)] + simpa only [div_eq_mul_inv] using ENNReal.tsum_mul_right + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule MeasureTheory + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +theorem orthogonalLattice_covolume_sq (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (W : Submodule ℝ E) + [IsZLattice ℝ (latticeSection Λ Wᗮ)] + [DiscreteTopology (orthogonalLatticeImage Λ W)] [IsZLattice ℝ (orthogonalLatticeImage Λ W)] : + ZLattice.covolume Λ ^ 2 = ZLattice.covolume (latticeSection Λ Wᗮ) ^ 2 * + ZLattice.covolume (orthogonalLatticeImage Λ W) ^ 2 := by + classical + let bK := Free.chooseBasis ℤ (latticeSection Λ Wᗮ) + let bP := Free.chooseBasis ℤ (orthogonalLatticeImage Λ W) + obtain ⟨b, hbK, hbP⟩ := exists_orthogonal_lattice_split_basis Λ W bK bP + let B := b.ofZLatticeBasis ℝ Λ + let K := bK.ofZLatticeBasis ℝ (latticeSection Λ Wᗮ) + let P := bP.ofZLatticeBasis ℝ (orthogonalLatticeImage Λ W) + have hleft (i) : B (Sum.inl i) = (K i : E) := by + simpa only [B, K, Basis.ofZLatticeBasis_apply] using hbK i + have hspan : span ℝ (Set.range (fun i => B (Sum.inl i))) = Wᗮ := by + rw [show (fun i => B (Sum.inl i)) = (fun i => (K i : E)) from funext hleft] + change span ℝ (Set.range (Wᗮ.subtype ∘ K)) = Wᗮ + rw [Set.range_comp, ← Submodule.map_span, K.span_eq, Submodule.map_top, + Submodule.range_subtype] + have hright (j) : B (Sum.inr j) - Wᗮ.starProjection (B (Sum.inr j)) = (P j : E) := by + have hp : W.starProjection (B (Sum.inr j)) = (P j : E) := by + simpa only [B, P, Basis.ofZLatticeBasis_apply, Submodule.coe_orthogonalProjectionOnto_apply] + using congrArg Subtype.val (hbP j) + have hsum := W.starProjection_add_starProjection_orthogonal (B (Sum.inr j)) + rw [hp] at hsum + exact (eq_sub_iff_add_eq.mpr hsum).symm + have hKGram : (Matrix.gram ℝ (fun i => B (Sum.inl i))).det = + ZLattice.covolume (latticeSection Λ Wᗮ) ^ 2 := by + have hg : Matrix.gram ℝ (fun i => B (Sum.inl i)) = Matrix.gram ℝ K := by + ext i j + simp only [Matrix.gram_apply, hleft] + rfl + rw [hg] + exact (lattice_covolume_sq_eq_gram (latticeSection Λ Wᗮ) bK).symm + have hPGram : (Matrix.gram ℝ (fun j => B (Sum.inr j) - + Wᗮ.starProjection (B (Sum.inr j)))).det = + ZLattice.covolume (orthogonalLatticeImage Λ W) ^ 2 := by + have hg : Matrix.gram ℝ (fun j => B (Sum.inr j) - Wᗮ.starProjection (B (Sum.inr j))) = + Matrix.gram ℝ P := by + ext i j + simp only [Matrix.gram_apply, hright] + rfl + rw [hg] + exact (lattice_covolume_sq_eq_gram (orthogonalLatticeImage Λ W) bP).symm + have hblock := gram_det_orthogonal_block B + dsimp only at hblock + rw [hspan, hKGram, hPGram] at hblock + rw [lattice_covolume_sq_eq_gram Λ b] + exact hblock + +theorem orthogonalLattice_covolume (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (W : Submodule ℝ E) + [IsZLattice ℝ (latticeSection Λ Wᗮ)] + [DiscreteTopology (orthogonalLatticeImage Λ W)] [IsZLattice ℝ (orthogonalLatticeImage Λ W)] : + ZLattice.covolume Λ = ZLattice.covolume (latticeSection Λ Wᗮ) * + ZLattice.covolume (orthogonalLatticeImage Λ W) := by + apply (sq_eq_sq₀ (ZLattice.covolume_pos Λ volume).le + (mul_nonneg (ZLattice.covolume_pos (latticeSection Λ Wᗮ) volume).le + (ZLattice.covolume_pos (orthogonalLatticeImage Λ W) volume).le)).mp + simpa only [mul_pow] using orthogonalLattice_covolume_sq Λ W + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory Module Set + +variable {E I : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] [Fintype I] + +theorem lattice_sheet_haar_formula (Λ : Submodule ℤ E) [DiscreteTopology Λ] [Countable Λ] + (W : Submodule ℝ E) [IsZLattice ℝ (latticeSection Λ W)] + (b : Basis I ℤ (latticeSection Λ W)) + (μ : Measure (W ⧸ (latticeSection Λ W).toAddSubgroup)) + [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] + {Ω : Set E} (hΩm : MeasurableSet Ω) + (hΩ : ∀ x ∈ Ω, ∀ y ∈ Ω, x - y ∈ Λ → x = y) : + μ (⋃ z : orthogonalLatticeImage Λ Wᗮ, + latticeSheetQuotient Λ W z '' {u | latticeSheetPoint W z.val u ∈ Ω}) = + (∑' z : orthogonalLatticeImage Λ Wᗮ, + volume {u : W | latticeSheetPoint W z.val u ∈ Ω}) / + ENNReal.ofReal (ZLattice.covolume (latticeSection Λ W)) := by + let : Countable (orthogonalLatticeImage Λ Wᗮ) := + (orthogonalLatticeProjection_surjective Λ Wᗮ).countable + apply lattice_quotient_haar_countable_sheets (latticeSection Λ W) b μ + (projectedLatticeShift Λ W) (fun z => {u | latticeSheetPoint W z.val u ∈ Ω}) + · intro z + exact hΩm.preimage (continuous_subtype_val.add continuous_const).measurable + · intro z u hu v hv h + exact (latticeSheetQuotient_injective_on_region Λ W hΩ hu hv h).2 + · intro z w hzw + apply Set.disjoint_left.mpr + rintro q ⟨u, hu, rfl⟩ ⟨v, hv, he⟩ + exact hzw (latticeSheetQuotient_injective_on_region Λ W hΩ hu hv he.symm).1 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LatticeVoronoiPacking.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeVoronoiPacking.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d4c5f454630ed56fdd7fd1ce74e1bc2fbea2813 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LatticeVoronoiPacking.lean @@ -0,0 +1,194 @@ +import Mathlib.Algebra.Module.ZLattice.Covolume +import Mathlib.Topology.MetricSpace.HausdorffDistance +import OAI.Combinatorics.Progressions.Estimates.EuclideanBisectorNull +import OAI.Combinatorics.Progressions.Linear.SpanSubsetBasis +import OAI.Combinatorics.Progressions.Linear.ZSpanRounding + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped Pointwise + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] (Λ : Submodule ℤ E) + +def latticeVoronoi : Set E := {x : E | ∀ z : Λ, ‖x‖ ≤ ‖x - z.val‖} + +omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] in +theorem latticeVoronoi_closed : IsClosed (latticeVoronoi Λ) := by + change IsClosed {x : E | ∀ z : Λ, ‖x‖ ≤ ‖x - z.val‖} + simp only [Set.ofPred_forall] + exact isClosed_iInter (fun z => isClosed_le continuous_norm ((continuous_id.sub continuous_const).norm)) + +theorem exists_sub_mem_latticeVoronoi [DiscreteTopology Λ] (x : E) : + ∃ z : Λ, x - z.val ∈ latticeVoronoi Λ := by + have hclosed : IsClosed (Λ : Set E) := + (AddSubgroup.isClosed_of_discreteTopology : IsClosed (Λ.toAddSubgroup : Set E)) + obtain ⟨z, hz, he⟩ := hclosed.exists_infDist_eq_dist ⟨0, Λ.zero_mem⟩ x + refine ⟨⟨z, hz⟩, ?_⟩ + intro w + have hnear := Metric.infDist_le_dist_of_mem (x := x) (Λ.add_mem hz w.property) + rw [he, dist_eq_norm, dist_eq_norm] at hnear + simpa only [sub_add_eq_sub_sub] using hnear + +omit [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] in +theorem latticeVoronoi_subset_closedBall (B : ℝ) + (hcover : ∀ x : E, ∃ z : Λ, ‖x - z.val‖ ≤ B) : + latticeVoronoi Λ ⊆ Metric.closedBall 0 B := by + intro x hx + obtain ⟨z, hz⟩ := hcover x + exact mem_closedBall_zero_iff.mpr ((hx z).trans hz) + +theorem latticeVoronoi_isAddFundamentalDomain [DiscreteTopology Λ] + [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [Measure.IsAddHaarMeasure μ] : + IsAddFundamentalDomain Λ (latticeVoronoi Λ) μ where + nullMeasurableSet := (latticeVoronoi_closed Λ).measurableSet.nullMeasurableSet + ae_covers := Filter.Eventually.of_forall fun x => by + obtain ⟨z, hz⟩ := exists_sub_mem_latticeVoronoi Λ x + refine ⟨-z, ?_⟩ + simpa only [Submodule.vadd_def, vadd_eq_add, Submodule.coe_neg, neg_add_eq_sub] using hz + aedisjoint := by + intro a b hab + apply measure_mono_null (t := {x : E | ‖x - a.val‖ = ‖x - b.val‖}) + · intro x hx + obtain ⟨y, hy, hya⟩ := hx.1 + obtain ⟨z, hz, hzb⟩ := hx.2 + have hay : a.val + y = x := hya + have hbz : b.val + z = x := hzb + have hyx : y = x - a.val := by rw [← hay]; abel + have hzx : z = x - b.val := by rw [← hbz]; abel + have h₁ := hy (b - a) + have h₂ := hz (a - b) + change ‖y‖ ≤ ‖y - (b.val - a.val)‖ at h₁ + change ‖z‖ ≤ ‖z - (a.val - b.val)‖ at h₂ + rw [hyx] at h₁ + rw [hzx] at h₂ + have hsub₁ : x - a.val - (b.val - a.val) = x - b.val := by abel + have hsub₂ : x - b.val - (a.val - b.val) = x - a.val := by abel + rw [hsub₁] at h₁ + rw [hsub₂] at h₂ + exact le_antisymm h₁ h₂ + · exact euclidean_bisector_measure_zero μ a.val b.val (fun he => hab (Subtype.ext he)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] (Λ : Submodule ℤ E) (R : ℝ) + +def shortVectorSpan : Submodule ℝ E := + Submodule.span ℝ {x : E | x ∈ Λ ∧ ‖x‖ ≤ R} + +noncomputable def shortVectorLattice : Submodule ℤ (shortVectorSpan Λ R) := + ZLattice.comap ℝ Λ (shortVectorSpan Λ R).subtype + +omit [FiniteDimensional ℝ E] in +theorem mem_shortVectorSpan {x : E} (hx : x ∈ Λ) (hR : ‖x‖ ≤ R) : + x ∈ shortVectorSpan Λ R := Submodule.subset_span ⟨hx, hR⟩ + +theorem exists_shortVectorSpan_basis : + ∃ d : ℕ, ∃ b : Basis (Fin d) ℝ (shortVectorSpan Λ R), + d = finrank ℝ (shortVectorSpan Λ R) ∧ + ∀ i, b i ∈ shortVectorLattice Λ R ∧ ‖b i‖ ≤ R := by + obtain ⟨d, b, hd, hb⟩ := exists_basis_of_span_subset {x : E | x ∈ Λ ∧ ‖x‖ ≤ R} + exact ⟨d, b, hd, hb⟩ + +instance shortVectorLattice_discrete [DiscreteTopology Λ] : + DiscreteTopology (shortVectorLattice Λ R) := + ZLattice.comap_discreteTopology ℝ Λ continuous_subtype_val Subtype.val_injective + +instance shortVectorLattice_full [DiscreteTopology Λ] : IsZLattice ℝ (shortVectorLattice Λ R) := by + obtain ⟨d, b, _, hb⟩ := exists_shortVectorSpan_basis Λ R + constructor + apply top_unique + calc + ⊤ = Submodule.span ℝ (Set.range b) := b.span_eq.symm + _ ≤ Submodule.span ℝ (shortVectorLattice Λ R : Set (shortVectorSpan Λ R)) := by + apply Submodule.span_mono + rintro x ⟨i, rfl⟩ + exact (hb i).1 + +theorem shortVectorLattice_covering (x : shortVectorSpan Λ R) : + ∃ z : shortVectorLattice Λ R, + ‖x - z.val‖ ≤ (finrank ℝ (shortVectorSpan Λ R) : ℝ) * R / 2 := by + obtain ⟨d, b, hd, hb⟩ := exists_shortVectorSpan_basis Λ R + obtain ⟨z, hz, hnear⟩ := exists_zspan_near_of_basis_bound b R (fun i => (hb i).2) x + have hsub : Submodule.span ℤ (Set.range b) ≤ shortVectorLattice Λ R := by + apply Submodule.span_le.mpr + rintro x ⟨i, rfl⟩ + exact (hb i).1 + refine ⟨⟨z, hsub hz⟩, ?_⟩ + simpa only [Fintype.card_fin, hd] using hnear + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory Module +open scoped Pointwise + +theorem lattice_points_mul_covolume_le_closedBall + {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (μ : Measure E) [Measure.IsAddHaarMeasure μ] + (B R : ℝ) (hcover : ∀ x : E, ∃ z : Λ, ‖x - z.val‖ ≤ B) + (P : Finset Λ) (hP : ∀ p ∈ P, ‖(p : E)‖ ≤ R) : + (P.card : ℝ) * ZLattice.covolume Λ μ ≤ μ.real (Metric.closedBall 0 (R + B)) := by + have : MeasurableVAdd Λ E := (inferInstance : MeasurableVAdd Λ.toAddSubgroup E) + have : VAddInvariantMeasure Λ E μ := (inferInstance : VAddInvariantMeasure Λ.toAddSubgroup E μ) + let F := latticeVoronoi Λ + have hfd := latticeVoronoi_isAddFundamentalDomain Λ μ + have hF : F ⊆ Metric.closedBall 0 B := latticeVoronoi_subset_closedBall Λ B hcover + have hfinite : μ F ≠ ⊤ := measure_ne_top_of_subset hF measure_closedBall_lt_top.ne + have hbound : (⋃ p ∈ P, p +ᵥ F) ⊆ Metric.closedBall 0 (R + B) := by + intro x hx + obtain ⟨p, hpUnion⟩ := Set.mem_iUnion.mp hx + obtain ⟨hpmem, hxTranslate⟩ := Set.mem_iUnion.mp hpUnion + obtain ⟨y, hy, rfl⟩ := hxTranslate + apply mem_closedBall_zero_iff.mpr + change ‖(p : E) + y‖ ≤ R + B + exact (norm_add_le _ _).trans + (add_le_add (hP p hpmem) (mem_closedBall_zero_iff.mp (hF hy))) + have hvol : μ.real (⋃ p ∈ P, p +ᵥ F) = (P.card : ℝ) * μ.real F := by + rw [measureReal_biUnion_finset₀ + (fun p _ q _ hpq => hfd.aedisjoint hpq) + (fun p _ => hfd.nullMeasurableSet.vadd p) + (fun p _ => by rw [measure_vadd]; exact hfinite)] + simp only [F, measureReal_def, measure_vadd, Finset.sum_const, nsmul_eq_mul] + rw [ZLattice.covolume_eq_measure_fundamentalDomain Λ μ hfd, ← hvol] + exact measureReal_mono hbound measure_closedBall_lt_top.ne + +theorem shortVectorLattice_covolume_packing + {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] (R : ℝ) + (P : Finset (shortVectorLattice Λ R)) + (hP : ∀ p ∈ P, ‖(p : shortVectorSpan Λ R)‖ ≤ R) : + (P.card : ℝ) * ZLattice.covolume (shortVectorLattice Λ R) ≤ + volume.real (Metric.closedBall (0 : shortVectorSpan Λ R) + (R + (finrank ℝ (shortVectorSpan Λ R) : ℝ) * R / 2)) := by + exact lattice_points_mul_covolume_le_closedBall (shortVectorLattice Λ R) volume + ((finrank ℝ (shortVectorSpan Λ R) : ℝ) * R / 2) R + (shortVectorLattice_covering Λ R) P hP + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LayerSamplerIntegerBox.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LayerSamplerIntegerBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..b39fad952c423cea2288b9b04616ae246ba47f21 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LayerSamplerIntegerBox.lean @@ -0,0 +1,52 @@ +import OAI.Combinatorics.Progressions.Fourier.SelectedDensityAmbientProductFourier + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule +open scoped Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + +noncomputable def layerSamplerIntegerBox : Finset (LayerSamplerVariables G I n B → ℤ) := + integerBox (layerSamplerSides B U b R S.value) + +theorem layerSamplerIntegerBox_nonempty : (layerSamplerIntegerBox B U b S).Nonempty := by + refine ⟨0, (mem_integerBox _ _).mpr ?_⟩ + intro v + change 0 ≤ (0 : ℤ) ∧ (0 : ℤ) < layerSamplerSides B U b R S.value v + exact ⟨le_rfl, by exact_mod_cast layerSamplerSides_pos B U b R S.positive v⟩ + +theorem layerSamplerIntegerBox_abs_bound {x : LayerSamplerVariables G I n B → ℤ} + (hx : x ∈ layerSamplerIntegerBox B U b S) (v : LayerSamplerVariables G I n B) : + |(x v : ℝ)| ≤ layerSamplerBox B U b S v := by + have h := (mem_integerBox _ _).mp hx v + have h0 : (0 : ℝ) ≤ x v := by exact_mod_cast h.1 + rw [abs_of_nonneg h0] + change (x v : ℝ) ≤ (layerSamplerSides B U b R S.value v : ℝ) + exact_mod_cast h.2.le + +theorem layerSamplerIntegerBox_root_bound {M : ℝ} (hM : (S.value : ℝ) ≤ M) + {x : LayerSamplerVariables G I n B → ℤ} (hx : x ∈ layerSamplerIntegerBox B U b S) + (v : LayerSamplerVariables G I n B) : |(x v : ℝ)| ≤ M := + (layerSamplerIntegerBox_abs_bound B U b S hx v).trans ((layerSamplerBox_le B U b S v).trans hM) + +theorem layerSamplerSides_free (g : G) : + layerSamplerSides B U b R S.value (.inl g) = S.value := rfl + +theorem layerSamplerSides_attains_scale [Nonempty G] : + ∃ v : LayerSamplerVariables G I n B, layerSamplerSides B U b R S.value v = S.value := + ⟨.inl (Classical.choice inferInstance), rfl⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LayerSamplingRankAffine.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LayerSamplingRankAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..de28d2f02aafdb8e941eefc760ef0d1163402b2f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LayerSamplingRankAffine.lean @@ -0,0 +1,205 @@ +import OAI.Combinatorics.Progressions.Lattices.AlgebraicMajorWeightedAffineTopPullback +import OAI.Combinatorics.Progressions.Sampling.SamplingRankProjectedContainment + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators + +theorem monomialScale_const_mul_degree {I : Type*} (T : I → ℝ) (c : ℝ) (α : I →₀ ℕ) : + monomialScale (fun i => c * T i) α = c ^ α.degree * monomialScale T α := by + classical + simp only [monomialScale, Finsupp.prod, mul_pow, Finset.prod_mul_distrib, + Finset.prod_pow_eq_pow_sum, Finsupp.degree_apply] + +theorem monomialScale_le_const_mul {I : Type*} (N L : I → ℝ) + (hN : ∀ i, 0 ≤ N i) (c : ℝ) (hNL : ∀ i, N i ≤ c * L i) (α : I →₀ ℕ) : + monomialScale N α ≤ c ^ α.degree * monomialScale L α := by + rw [← monomialScale_const_mul_degree] + exact Finset.prod_le_prod₀ (fun i _ => pow_nonneg (hN i) _) + (fun i _ => pow_le_pow_left₀ (hN i) (hNL i) _) + +theorem PolynomialRationalApproximation.homogeneous_dilation_pullback {I : Type*} + (N L : I → ℝ) (hN : ∀ i, 0 < N i) (hL : ∀ i, 0 < L i) + (q h : ℕ) (hq : 0 < q) (K : ℝ) (_hK : 1 ≤ K) + (hNL : ∀ i, N i ≤ K * (q : ℝ) * L i) + (R R' : ℝ) (hden : (q : ℝ) ^ h * R ≤ R') (hslow : K ^ h * R ≤ R') + (P : MvPolynomial I ℝ) (hP : P.IsHomogeneous h) + (happrox : PolynomialRationalApproximation L R (C ((q : ℝ) ^ h) * P)) : + PolynomialRationalApproximation N R' P := by + classical + obtain ⟨D, hD, hDR, Q, hQ⟩ := happrox + have hR : 0 ≤ R := (Nat.cast_nonneg D).trans hDR + have hqpow : 0 < (q : ℝ) ^ h := pow_pos (by exact_mod_cast hq) h + have hDreal : (D : ℝ) ≠ 0 := by exact_mod_cast hD.ne' + have hR' : 0 ≤ R' := (mul_nonneg hqpow.le hR).trans hden + refine ⟨q ^ h * D, Nat.mul_pos (Nat.pow_pos hq) hD, ?_, + homogeneousComponent h Q, ?_⟩ + · push_cast + exact (mul_le_mul_of_nonneg_left hDR hqpow.le).trans hden + · intro α + by_cases hα : α.degree = h + · rw [coeff_homogeneousComponent, ite_eq_left hα] + have hid : P.coeff α - ((Q.coeff α : ℤ) : ℝ) / (q ^ h * D : ℕ) = + ((q : ℝ) ^ h * P.coeff α - ((Q.coeff α : ℤ) : ℝ) / D) / (q : ℝ) ^ h := by + push_cast + field_simp + rw [hid, abs_div, abs_of_pos hqpow] + have hscale := monomialScale_le_const_mul N L (fun i => (hN i).le) (K * q) hNL α + rw [hα, mul_pow] at hscale + have hscaleN := monomialScale_pos N hN α + have hscaleL := monomialScale_pos L hL α + calc + _ ≤ (R / monomialScale L α) / (q : ℝ) ^ h := + div_le_div_of_nonneg_right (by simpa only [coeff_C_mul] using hQ α) hqpow.le + _ ≤ K ^ h * R / monomialScale N α := by + rw [div_div] + apply (div_le_div_iff₀ (mul_pos hscaleL hqpow) hscaleN).mpr + calc + R * monomialScale N α ≤ R * (K ^ h * (q : ℝ) ^ h * monomialScale L α) := + mul_le_mul_of_nonneg_left hscale hR + _ = (K ^ h * R) * (monomialScale L α * (q : ℝ) ^ h) := by ring + _ ≤ _ := div_le_div_of_nonneg_right hslow hscaleN.le + · rw [hP.coeff_eq_zero hα, coeff_homogeneousComponent, ite_eq_right hα, Int.cast_zero, + zero_div, sub_zero, abs_zero] + exact div_nonneg hR' (monomialScale_pos N hN α).le + +theorem PolynomialRationalApproximation.homogeneous_dilation_pullback_max {I : Type*} + (N L : I → ℝ) (hN : ∀ i, 0 < N i) (hL : ∀ i, 0 < L i) + (q h : ℕ) (hq : 0 < q) (K : ℝ) (hK : 1 ≤ K) + (hNL : ∀ i, N i ≤ K * (q : ℝ) * L i) + (R : ℝ) (P : MvPolynomial I ℝ) (hP : P.IsHomogeneous h) + (happrox : PolynomialRationalApproximation L R (C ((q : ℝ) ^ h) * P)) : + PolynomialRationalApproximation N (max ((q : ℝ) ^ h) (K ^ h) * R) P := by + have hR : 0 ≤ R := by + obtain ⟨D, _, hDR, _⟩ := happrox + exact (Nat.cast_nonneg D).trans hDR + exact happrox.homogeneous_dilation_pullback N L hN hL q h hq K hK hNL R _ + (mul_le_mul_of_nonneg_right (le_max_left _ _) hR) + (mul_le_mul_of_nonneg_right (le_max_right _ _) hR) P hP + +theorem PolynomialRationalApproximation.affine_pullback {I : Type*} + (N L : I → ℝ) (hN : ∀ i, 0 < N i) (hL : ∀ i, 0 < L i) + (q h : ℕ) (hq : 0 < q) (r : I → ℤ) (K : ℝ) (hK : 1 ≤ K) + (hNL : ∀ i, N i ≤ K * (q : ℝ) * L i) + (R R' : ℝ) (hden : (q : ℝ) ^ h * R ≤ R') (hslow : K ^ h * R ≤ R') + (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ h) + (happrox : PolynomialRationalApproximation L R + (homogeneousComponent h (residueAffinePolynomial q r P))) : + PolynomialRationalApproximation N R' (homogeneousComponent h P) := by + rw [residueAffinePolynomial_homogeneousComponent q h r P hP] at happrox + exact happrox.homogeneous_dilation_pullback N L hN hL q h hq K hK hNL R R' + hden hslow (homogeneousComponent h P) (homogeneousComponent_isHomogeneous _ _) + +theorem PolynomialRationalApproximation.affine_pullback_max {I : Type*} + (N L : I → ℝ) (hN : ∀ i, 0 < N i) (hL : ∀ i, 0 < L i) + (q h : ℕ) (hq : 0 < q) (r : I → ℤ) (K : ℝ) (hK : 1 ≤ K) + (hNL : ∀ i, N i ≤ K * (q : ℝ) * L i) + (R : ℝ) (P : MvPolynomial I ℝ) (hP : P.totalDegree ≤ h) + (happrox : PolynomialRationalApproximation L R + (homogeneousComponent h (residueAffinePolynomial q r P))) : + PolynomialRationalApproximation N (max ((q : ℝ) ^ h) (K ^ h) * R) + (homogeneousComponent h P) := by + rw [residueAffinePolynomial_homogeneousComponent q h r P hP] at happrox + exact happrox.homogeneous_dilation_pullback_max N L hN hL q h hq K hK hNL R + (homogeneousComponent h P) (homogeneousComponent_isHomogeneous _ _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residueAffinePolynomial_eval_real {I : Type*} (q : ℕ) (r : I → ℤ) + (x : I → ℝ) (P : MvPolynomial I ℝ) : + MvPolynomial.eval x (residueAffinePolynomial q r P) = + MvPolynomial.eval (fun i => (r i : ℝ) + (q : ℝ)*x i) P := by + induction P using MvPolynomial.induction_on with + | C c => simp [residueAffinePolynomial] + | add P Q hP hQ => + simpa only [residueAffinePolynomial, map_add] using congrArg₂ (· + ·) hP hQ + | mul_X P i hP => + simp only [residueAffinePolynomial, map_mul, MvPolynomial.eval₂Hom_X', map_add, + MvPolynomial.eval_C, MvPolynomial.eval_X] at * + rw [hP] + +namespace VectorPolynomial + +noncomputable def residueAffine {I V : Type*} [AddCommGroup V] [Module ℝ V] + (q : ℕ) (r : I → ℤ) : VectorPolynomial I ℝ V →ₗ[ℝ] VectorPolynomial I ℝ V := + substitute (fun i => MvPolynomial.C (r i : ℝ) + + MvPolynomial.C (q : ℝ) * MvPolynomial.X i) + +theorem eval_residueAffine {I V : Type*} [AddCommGroup V] [Module ℝ V] + (q : ℕ) (r : I → ℤ) (x : I → ℝ) (P : VectorPolynomial I ℝ V) : + eval x (residueAffine q r P) = eval (fun i => (r i : ℝ) + (q : ℝ)*x i) P := by + simp only [residueAffine, eval_substitute, map_add, map_mul, MvPolynomial.aeval_C, + MvPolynomial.aeval_X, Algebra.algebraMap_self, RingHom.id_apply] + +theorem integerRowPolynomial_residueAffine {I J : Type*} [Fintype J] + (a : J → ℤ) (q : ℕ) (r : I → ℤ) (P : VectorPolynomial I ℝ (J → ℝ)) : + integerRowPolynomial a (residueAffine q r P) = + residueAffinePolynomial q r (integerRowPolynomial a P) := by + apply MvPolynomial.funext + intro x + rw [integerRowPolynomial_eval, eval_residueAffine, + residueAffinePolynomial_eval_real, integerRowPolynomial_eval] + +end VectorPolynomial + +theorem HasLayerSamplingRank.residueAffine {I J : Type*} [Fintype J] + {h : ℕ} {N L : I → ℝ} {Rbig Rsmall : ℝ} + {W : Submodule ℝ (J → ℝ)} {P : VectorPolynomial I ℝ (J → ℝ)} + (hrank : HasLayerSamplingRank h N Rbig W P) + (hP : VectorPolynomial.DegreeLE (fun _ => 1) h P) + (hN : ∀ i, 0 < N i) (hL : ∀ i, 0 < L i) + (q : ℕ) (hq : 0 < q) (r : I → ℤ) (K : ℝ) + (hNL : ∀ i, N i ≤ K * (q : ℝ) * L i) + (hrow : Rsmall ≤ Rbig) + (hden : (q : ℝ)^h * Rsmall ≤ Rbig) + (hslow : K^h * Rsmall ≤ Rbig) : + HasLayerSamplingRank h L Rsmall W (VectorPolynomial.residueAffine q r P) := by + intro a ha hw happ + apply hrank a (fun j => (ha j).trans hrow) hw + rw [VectorPolynomial.integerRowPolynomial_residueAffine] at happ + have hcomparison (i : I) : N i ≤ max 1 K * (q : ℝ) * L i := by + apply (hNL i).trans + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (le_max_right 1 K) (Nat.cast_nonneg q)) (hL i).le + have hslow' : (max 1 K)^h * Rsmall ≤ Rbig := by + by_cases hK : K ≤ 1 + · simpa only [max_eq_left hK, one_pow, one_mul] using hrow + · simpa only [max_eq_right (le_of_not_ge hK)] using hslow + exact happ.affine_pullback N L hN hL q h hq r (max 1 K) (le_max_left _ _) + hcomparison Rsmall Rbig hden hslow' (VectorPolynomial.integerRowPolynomial a P) + (VectorPolynomial.integerRowPolynomial_totalDegree_le a hP) + +theorem HasLayerSamplingRank.residueAffine_homogeneousPart {I J : Type*} [Fintype J] + {h : ℕ} {N L : I → ℝ} {Rbig Rsmall : ℝ} + {W : Submodule ℝ (J → ℝ)} {P : VectorPolynomial I ℝ (J → ℝ)} + (hrank : HasLayerSamplingRank h N Rbig W P) + (hP : VectorPolynomial.DegreeLE (fun _ => 1) h P) + (hN : ∀ i, 0 < N i) (hL : ∀ i, 0 < L i) + (q : ℕ) (hq : 0 < q) (r : I → ℤ) (K : ℝ) + (hNL : ∀ i, N i ≤ K * (q : ℝ) * L i) + (hrow : Rsmall ≤ Rbig) + (hden : (q : ℝ)^h * Rsmall ≤ Rbig) + (hslow : K^h * Rsmall ≤ Rbig) : + HasLayerSamplingRank h L Rsmall W + (VectorPolynomial.homogeneousPart h (VectorPolynomial.residueAffine q r P)) := + (hasLayerSamplingRank_homogeneousPart_iff h L Rsmall W _).mpr + (hrank.residueAffine hP hN hL q hq r K hNL hrow hden hslow) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LieSubalgebraLatticeInnerGrid.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LieSubalgebraLatticeInnerGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b85482ead7495b535e4ccfc75d4944a4b6c80ed --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LieSubalgebraLatticeInnerGrid.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.Progressions.Estimates.PetalComparisonTree + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped BigOperators Matrix TensorProduct + +theorem integralVector_mulVec_of_column_denominators + {ι κ : Type*} [Fintype κ] (B : Matrix ι κ ℚ) (q : ℕ) + (hB : ∀ j, B.col j ∈ denominatorGrid q) (z : κ → ℤ) : + IntegralVector (B *ᵥ ((q : ℚ) • (fun j => (z j : ℚ)))) := by + classical + choose c hc using hB + refine ⟨fun i => ∑ j, c j i * z j, fun i => ?_⟩ + simp only [Matrix.mulVec, dotProduct, Pi.smul_apply, smul_eq_mul, Int.cast_sum, + Int.cast_mul] + apply Finset.sum_congr rfl + intro j _ + have h : (q : ℚ) * B i j = (c j i : ℚ) := hc j i + rw [← h] + ring + +theorem scaledIntegerGrid_mulVec_of_column_denominators + {ι κ : Type*} [Fintype κ] (B : Matrix ι κ ℚ) (l q : ℕ) + (hB : ∀ j, B.col j ∈ denominatorGrid q) : + scaledIntegerGrid (l * q) ⊆ B.mulVec ⁻¹' scaledIntegerGrid l := by + rintro x ⟨z, rfl⟩ + have h := scaled_grid_mulVec B l _ (integralVector_mulVec_of_column_denominators B q hB z) + simpa only [Set.mem_preimage, smul_smul, Nat.cast_mul] using h + +theorem bchSubgroup_comap_inner_grid_of_columns + {ι κ L M : Type*} [Fintype ι] [Fintype κ] [DecidableEq κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + (b : Basis κ ℚ M) (e : Basis ι ℚ L) (φ : M →ₗ⁅ℚ⁆ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) (l q : ℕ) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (hcolumns : ∀ j, e.equivFun (φ (b j)) ∈ denominatorGrid q) : + scaledIntegerGrid (l * q) ⊆ bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.map (hnil := hM) φ)) := by + rw [bchSubgroupCoordinates_comap b e φ Γ] + have hB : ∀ j, (LinearMap.toMatrix b e φ.toLinearMap).col j ∈ denominatorGrid q := by + intro j + have he : (LinearMap.toMatrix b e φ.toLinearMap).col j = + e.equivFun (φ (b j)) := by + funext i + exact LinearMap.toMatrix_apply b e φ.toLinearMap i j + rw [he] + exact hcolumns j + intro x hx + exact hinner (scaledIntegerGrid_mulVec_of_column_denominators _ l q hB hx) + +theorem lieSubalgebra_comap_inner_grid_of_columns + {ι κ L : Type*} [Fintype ι] [Fintype κ] [DecidableEq κ] + [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + (K : LieSubalgebra ℚ L) (bk : Basis κ ℚ K) (b : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l q : ℕ) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates b Γ) + (hcolumns : ∀ j, b.equivFun (bk j : L) ∈ denominatorGrid q) : + scaledIntegerGrid (l * q) ⊆ bchSubgroupCoordinates bk + (Γ.comap (NilpotentLieBCHGroup.map + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)) := + bchSubgroup_comap_inner_grid_of_columns bk b K.incl Γ l q hinner hcolumns + +namespace NilpotentLieBCHGroup + +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem realification_comap_incl_mem (K : LieSubalgebra ℚ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (x : NilpotentLieBCHGroup (ℝ ⊗[ℚ] K) s + (realification_lowerCentralSeries_eq_bot (lie_subalgebra_lowerCentralSeries_eq_bot hnil K))) + (hx : x ∈ (Γ.comap + (map (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)).map + (realificationHom (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K))) : + realificationMap (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) + (hM := hnil) K.incl x ∈ Γ.map realificationHom := by + change x ∈ (Γ.map realificationHom).comap + (realificationMap (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) + (hM := hnil) K.incl) + rw [realification_subgroup_comap_incl] + exact hx + +theorem realification_comap_incl_map_le (K : LieSubalgebra ℚ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) : + ((Γ.comap (map (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)).map + (realificationHom (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K))).map + (realificationMap (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) + (hM := hnil) K.incl) ≤ Γ.map realificationHom := by + rw [← realification_subgroup_comap_incl] + exact Subgroup.map_comap_le _ _ + +end NilpotentLieBCHGroup + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LocalLatticeChart.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LocalLatticeChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..daa18af64140de64ae188d90eb535f692a07f827 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LocalLatticeChart.lean @@ -0,0 +1,45 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedSmallLiftHaar +import OAI.Combinatorics.Progressions.Geometry.QuantitativeProjectedChart + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory Module Submodule +open scoped BigOperators + +theorem exists_local_lattice_chart {J : Type*} [Fintype J] + (W : Submodule ℝ (EuclideanSpace ℝ J)) + [IsZLattice ℝ (latticeSection (standardEuclideanLattice J) W)] : + let n := finrank ℝ Wᗮ + let C : ℝ := 20 * ((n : ℝ) + 1) ^ 3 + ∃ b : Basis (Fin n) ℝ Wᗮ, + span ℤ (Set.range b) = projectedIntegerLattice W ∧ + (∀ i, 0 < basisAxisScale b i) ∧ + (∀ x, ‖normalizedOrthogonalChart W b x‖ ≤ Real.exp C * ‖x‖) ∧ + (∀ p, ‖(normalizedOrthogonalChart W b).symm p‖ ≤ Real.exp C * ‖p‖) ∧ + Real.exp (-C) ≤ + ZLattice.covolume (latticeSection (standardEuclideanLattice J) W) / + (∏ i, (basisAxisScale b i : ℝ)) ∧ + ZLattice.covolume (latticeSection (standardEuclideanLattice J) W) / + (∏ i, (basisAxisScale b i : ℝ)) ≤ Real.exp C ∧ + ∀ (μ : Measure (W ⧸ (latticeSection (standardEuclideanLattice J) W).toAddSubgroup)) + [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] + (Ω : Set (EuclideanSpace ℝ J)), MeasurableSet Ω → Ω ⊆ standardLatticeSmallBox J → + μ (latticeSmallLiftRegion (standardEuclideanLattice J) W Ω) = + (∑' z : Fin n → ℤ, volume {u : W | + (normalizedOrthogonalChart W b).symm + (u, fun i => (z i : ℝ) / (basisAxisScale b i : ℝ)) ∈ Ω}) / + ENNReal.ofReal (ZLattice.covolume (latticeSection (standardEuclideanLattice J) W)) := by + obtain ⟨b, hb, hK, hf, hi, hlo, hhi⟩ := exists_quantitative_projected_chart W + refine ⟨b, hb, hK, hf, hi, hlo, hhi, ?_⟩ + intro μ _ _ Ω hΩm hΩ + exact normalized_smallLift_haar_formula W b hb μ hΩm hΩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LocalMarkedLatticeCorrection.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LocalMarkedLatticeCorrection.lean new file mode 100644 index 0000000000000000000000000000000000000000..02cafaa390b46ab29372c39de78892d8ab891965 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LocalMarkedLatticeCorrection.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonMarkedDirectionModel +import OAI.Combinatorics.Progressions.Estimates.MarkedUnitOrbit + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem scaledLocalAffineCorrectingElement_mem_realLattice + {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} + (D : R.CommonData P) (t : ℕ) (u c : Fin t → ℝ) (h₀ : ZMod N) (m : ℕ) {d : ℕ} + (E : RationalFilteredNilmanifold + (MarkedShiftQuotient D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t) (s + 1) d) + (hm : ∀ a : Fin t → ℤ, + (⟨(m : ℚ) • markedQuotientDirection D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t (fun i => (a i : ℚ))⟩ : + E.filtration.Group) ∈ E.lattice) (h : ZMod N) : + D.scaledLocalAffineCorrectingElement t u c h₀ m h ∈ E.realLattice := by + exact markedDirection_mem_realLattice_of_smul D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t E (m : ℚ) + (fun i => ((-affineCyclicTorusCarry u c h₀ h i : ℤ) : ℚ)) + (hm (fun i => -affineCyclicTorusCarry u c h₀ h i)) + +theorem exists_native_marked_local_correction_model (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p q P M : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} + (D : R.CommonData P) (B : D.CoefficientBases M) (t : ℕ) (x : Fin t → ℚ) (l : ℕ), + 0 ≤ M → b ≤ M → (t : ℝ) ≤ M → (∀ i, rationalLogHeight (x i) ≤ M) → + 0 < l → (l : ℝ) ≤ Real.exp M → + ∃ d : ℕ, + ∃ E : RationalFilteredNilmanifold + (MarkedShiftQuotient D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t) (s + 1) d, + ∃ T : E.MultidegreeStructure (mixedCorrelationDegree s), + ∃ ξ : MarkedShiftQuotient D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t →ₗ[ℚ] ℚ, + T.filtration = D.markedQuotientMultidegree t ∧ + T.ComplexityLE ((M + C) ^ C) ∧ l ∣ E.grid ∧ + bchSubgroupCoordinates E.basis E.lattice = scaledIntegerGrid E.grid ∧ + (∀ i j, rationalLogHeight + (E.basis.repr (markedQuotientDirection D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t (RationalTorus.basis t i)) j) ≤ + (M + C) ^ C) ∧ + (∀ i, rationalLogHeight (ξ (E.basis i)) ≤ (M + C) ^ C) ∧ + (∀ z ∈ markedShiftPolynomialSubmodule D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t s 1 r, + ξ (lieQuotientMap (markedShiftSecondIdeal D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t) z) = + B.freeFrequency D (markedShiftEval D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t x z)) ∧ + (∀ z : E.filtration.Group, z ∈ E.lattice → ∃ n : ℤ, ξ z.coord = n) ∧ + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp (((M + C) ^ C + 3) ^ 3) ∧ + ∀ (u c : Fin t → ℝ) (h₀ h : ZMod N), + D.scaledLocalAffineCorrectingElement t u c h₀ m h ∈ E.realLattice := by + obtain ⟨C, hC, hmodel⟩ := exists_native_marked_common_direction_model s hs + refine ⟨C, hC, ?_⟩ + intro r N _ b p q P M W out H R D B t x l hM hbM ht hx hl hlM + obtain ⟨d, E, T, ξ, hTF, hT, hdiv, hcoords, hdirection, hξ, hpreserve, hintegral, + m, hm, hmb, hmem⟩ := hmodel D B t x l hM hbM ht hx hl hlM + refine ⟨d, E, T, ξ, hTF, hT, hdiv, hcoords, hdirection, hξ, + hpreserve, hintegral, m, hm, hmb, ?_⟩ + intro u c h₀ h + exact D.scaledLocalAffineCorrectingElement_mem_realLattice t u c h₀ m E hmem h + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/LowTaggedAffineCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Lattices/LowTaggedAffineCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe6ac1bbbe09866beabbda470ad1ecd4fd9cf31e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/LowTaggedAffineCoordinates.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Polynomial.VectorPolynomialAffineSubspace +import OAI.Combinatorics.Progressions.Sampling.LowTaggedSamplingRank + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MvPolynomial +open scoped BigOperators + +variable {m : ℕ} (J : Fin m → Type*) [∀ j, Fintype (J j)] {X : Type*} + +theorem lowTaggedPolynomial_residueAffine (d : ℕ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (q : ℕ) (r : X → ℤ) + (i : Fin (Fintype.card (LowTaggedIndex J d))) : + lowTaggedPolynomial J d (fun j => residueAffine q r (poly j)) i = + residueAffinePolynomial q r (lowTaggedPolynomial J d poly i) := by + apply MvPolynomial.funext + intro x + rw [lowTaggedPolynomial_eval, eval_residueAffine, + residueAffinePolynomial_eval_real, lowTaggedPolynomial_eval] + +theorem lowTaggedPolynomial_centered_residueAffine_homogeneousComponent (d : ℕ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (q : ℕ) (r : X → ℤ) + (c : Fin (Fintype.card (LowTaggedIndex J d)) → ℝ) + (i : Fin (Fintype.card (LowTaggedIndex J d))) : + homogeneousComponent (lowTaggedWeight J d i) + (residueAffinePolynomial q r (lowTaggedPolynomial J d poly i - C (c i))) = + homogeneousComponent (lowTaggedWeight J d i) + (lowTaggedPolynomial J d (fun j => residueAffine q r (poly j)) i) := by + rw [lowTaggedPolynomial_residueAffine] + have hc : homogeneousComponent (lowTaggedWeight J d i) (C (c i) : MvPolynomial X ℝ) = 0 := by + apply homogeneousComponent_eq_zero + simpa using lowTaggedWeight_pos J d i + simp only [residueAffinePolynomial, map_sub, eval₂Hom_C, hc, sub_zero] + +theorem lowTaggedTopPolynomial_centered_residueAffine (d : ℕ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (q : ℕ) (r : X → ℤ) + (c : Fin (Fintype.card (LowTaggedIndex J d)) → ℝ) : + ofCoordinates (R := ℝ) (Pi.basisFun ℝ _) + (fun i => homogeneousComponent (lowTaggedWeight J d i) + (residueAffinePolynomial q r (lowTaggedPolynomial J d poly i - C (c i)))) = + lowTaggedTopPolynomial J d (fun j => residueAffine q r (poly j)) := by + unfold lowTaggedTopPolynomial + congr 1 + funext i + exact lowTaggedPolynomial_centered_residueAffine_homogeneousComponent J d poly q r c i + +theorem lowTaggedTopPolynomial_residueAffine_coeff_mem_iSup (d : ℕ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (W : ∀ j, Submodule ℝ (J j → ℝ)) + (hcoeff : ∀ j α, α ≠ 0 → coefficients (poly j) α ∈ W j) + (q : ℕ) (r : X → ℤ) (α : X →₀ ℕ) : + coefficients (lowTaggedTopPolynomial J d (fun j => residueAffine q r (poly j))) α ∈ + ⨆ h : Fin d, lowTaggedRetained J d W h := + lowTaggedTopPolynomial_coeff_mem_iSup J d (fun j => residueAffine q r (poly j)) W + (fun j β hβ => coefficients_residueAffine_nonzero_mem (W j) q r (poly j) + (hcoeff j) β hβ) α + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MajorTranslationIntegerEvaluation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MajorTranslationIntegerEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..abb40cfa807a512c0687a4190cf4e5559f438da1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MajorTranslationIntegerEvaluation.lean @@ -0,0 +1,31 @@ +import OAI.Combinatorics.Progressions.Polynomial.MajorTranslationDegreeSymbol + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial + +variable {U B : Type*} [Fintype B] + +theorem majorTranslationPolynomialOrbit_integerEval + (w : B → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + (F : MvPolynomial (U ⊕ B) ℝ) + (hF : F ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (A : B → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + (x : U → ℤ) : + bchRealTranslationHom w d hwd + ((weightedFiltration w d hwd).realification.polynomialOrbitEval + (fun _ : U => 1) x (majorTranslationPolynomialOrbit w d hw hwd F hF A hA)) = + algebraicMajorSymbol F (specializeMajorParameters (RingHom.id ℝ) F 0) A + (fun i => (x i : ℝ)) := by + rw [← NilpotentLieFiltration.polynomialOrbitRealEval_integer] + exact majorTranslationPolynomialOrbit_realEval w d hw hwd F hF A hA _ + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MarkedDirectionLatticeScale.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MarkedDirectionLatticeScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..8cfa7c23bfdab3ada55af423d44fa3c2e76bdcd0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MarkedDirectionLatticeScale.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.Progressions.Geometry.MarkedDirectionCoordinates + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +theorem direction_lattice_scale_bound (d t B H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hd : (d : ℝ) ≤ p) (ht : (t : ℝ) ≤ p) + (hB : (B : ℝ) ≤ Real.exp p) (hH : (H : ℝ) ≤ Real.exp p) : + ((B * H ^ (d * t) : ℕ) : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + rw [Nat.cast_mul, Nat.cast_pow] + calc + _ ≤ Real.exp p * (Real.exp p) ^ (d * t) := + mul_le_mul hB (pow_le_pow_left₀ (Nat.cast_nonneg _) hH _) (by positivity) (Real.exp_nonneg _) + _ = Real.exp (p + (d * t : ℕ) * p) := by rw [← Real.exp_nat_mul, ← Real.exp_add] + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hdt : (d : ℝ) * t ≤ p * p := + mul_le_mul hd ht (Nat.cast_nonneg _) hp + have hmul := mul_le_mul_of_nonneg_right hdt hp + push_cast + nlinarith only [hp, hmul, sq_nonneg p] + +namespace RationalFilteredNilmanifold + +variable {L V : Type*} [LieRing L] [LieAlgebra ℚ L] [AddCommGroup V] [Module ℚ V] + {s d t : ℕ} (E : RationalFilteredNilmanifold L s d) (e : Basis (Fin t) ℚ V) + (φ : V →ₗ[ℚ] L) + +theorem exists_direction_lattice_scale {H : ℕ} + (hφ : ∀ i j, RationalHeightLE (E.basis.repr (φ (e i)) j) H) : + ∃ m : ℕ, 0 < m ∧ m ≤ E.grid * H ^ (d * t) ∧ + ∀ x : V, IntegralVector (e.equivFun x) → + (⟨(m : ℚ) • φ x⟩ : E.filtration.Group) ∈ E.lattice := by + classical + let A := LinearMap.toMatrix e E.basis φ + let m := E.grid * matrixDenominator A + have hA : ∀ j i, RationalHeightLE (A j i) H := by + intro j i + simpa only [A, LinearMap.toMatrix_apply] using hφ i j + have hm : m ≤ E.grid * H ^ (d * t) := by + exact Nat.mul_le_mul_left _ (by simpa only [Fintype.card_fin] using matrixDenominator_le A hA) + refine ⟨m, Nat.mul_pos E.grid_pos (matrixDenominator_pos A), hm, ?_⟩ + intro x hx + apply (bchSubgroupCoordinates_repr E.basis E.lattice _).mp + apply E.inner_grid + have he : A *ᵥ e.equivFun x = E.basis.equivFun (φ x) := + LinearMap.toMatrix_mulVec_repr e E.basis φ x + have hint := integralVector_denominator_mulVec A (e.equivFun x) hx + rw [he] at hint + obtain ⟨z, hz⟩ := hint + refine ⟨z, ?_⟩ + change E.basis.equivFun ((m : ℚ) • φ x) = _ + calc + _ = (E.grid : ℚ) • ((matrixDenominator A : ℚ) • E.basis.equivFun (φ x)) := by + simp only [m, Nat.cast_mul, map_smul, mul_smul] + _ = _ := congrArg (fun v : Fin d → ℚ => (E.grid : ℚ) • v) (funext hz) + +theorem exists_direction_lattice_scale_with_budget {H : ℕ} {p : ℝ} + (hp : 0 ≤ p) (hd : (d : ℝ) ≤ p) (ht : (t : ℝ) ≤ p) + (hgrid : (E.grid : ℝ) ≤ Real.exp p) (hH : (H : ℝ) ≤ Real.exp p) + (hφ : ∀ i j, RationalHeightLE (E.basis.repr (φ (e i)) j) H) : + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + 2) ^ 3) ∧ + ∀ x : V, IntegralVector (e.equivFun x) → + (⟨(m : ℚ) • φ x⟩ : E.filtration.Group) ∈ E.lattice := by + obtain ⟨m, hm, hmb, hmem⟩ := E.exists_direction_lattice_scale e φ hφ + exact ⟨m, hm, (Nat.cast_le.mpr hmb).trans + (direction_lattice_scale_bound d t E.grid H hp hd ht hgrid hH), hmem⟩ + +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r k d : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (t : ℕ) (E : RationalFilteredNilmanifold (MarkedShiftQuotient F v w marked t) k d) + +theorem exists_marked_direction_lattice_scale {p : ℝ} (hp : 0 ≤ p) + (hd : (d : ℝ) ≤ p) (ht : (t : ℝ) ≤ p) (hgrid : (E.grid : ℝ) ≤ Real.exp p) + (hdir : ∀ i j, rationalLogHeight + (E.basis.repr (markedQuotientDirection F v w marked t (RationalTorus.basis t i)) j) ≤ p) : + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + 3) ^ 3) ∧ + ∀ a : Fin t → ℤ, + (⟨(m : ℚ) • markedQuotientDirection F v w marked t (fun i => (a i : ℚ))⟩ : + E.filtration.Group) ∈ E.lattice := by + have hp1 : p ≤ p + 1 := le_add_of_nonneg_right zero_le_one + obtain ⟨m, hm, hmb, hmem⟩ := E.exists_direction_lattice_scale_with_budget (RationalTorus.basis t) + (markedQuotientDirectionLinear F v w marked t) + (p := p + 1) (hp.trans hp1) (hd.trans hp1) (ht.trans hp1) + (hgrid.trans (Real.exp_le_exp.mpr hp1)) (ceil_exp_le_exp_add_one hp) + (fun i j => rationalHeightLE_ceil_exp (hdir i j)) + refine ⟨m, hm, ?_, ?_⟩ + · simpa only [add_assoc, show (1 : ℝ) + 2 = 3 by norm_num] using hmb + · intro a + exact hmem (fun i => (a i : ℚ)) + ⟨a, fun i => congrFun (RationalTorus.basis_equivFun t (fun j => (a j : ℚ))) i⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MarkedShiftLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MarkedShiftLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..28be9920f52521013cde7e40faac78e2c0e5d87a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MarkedShiftLattice.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonMarkedMultidegree +import OAI.Combinatorics.Progressions.Estimates.MarkedEvaluationJointBounds +import OAI.Combinatorics.Progressions.Estimates.MultidegreeIntegralModel + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {I ι L : Type*} [Fintype I] [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.associatedDegree.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (hω : ∀ i, ω i ≤ s) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (hw : ∀ i, 0 < w i) (hv : ∀ i, v i ∈ F.layer (w i) 1) + {H : ℕ} (hH : 1 ≤ H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) + (hgen : ∀ i j, RationalHeightLE (b.repr (v i) j) H) + +include hF hω hH hc hgen in +theorem exists_markedShiftQuotient_integral_model (t l : ℕ) (hl : 0 < l) : + let a := finrank ℚ (F.associatedDegree.PolynomialShiftAlgebra t) + let d := finrank ℚ (markedShiftSubalgebra F v w marked t) + ∃ m : ℕ, m ≤ finrank ℚ (markedShiftSecondIdeal F v w marked t).toSubmodule ∧ + ∃ q : ℕ, q ≤ d ∧ ∃ B : ℕ, 0 < B ∧ l ∣ B ∧ + B ≤ bchIntegralDenominatorBound (s + 1) * + markedQuotientHeight s (Fintype.card ι) a d m q H ^ (q ^ 3) * l ∧ + ∃ D : RationalFilteredNilmanifold (MarkedShiftQuotient F v w marked t) (s + 1) q, + ∃ M : D.MultidegreeStructure (mixedCorrelationDegree s), + M.filtration = markedShiftMultidegree F v w marked hw hv t ∧ D.grid = B ∧ + bchSubgroupCoordinates D.basis D.lattice = scaledIntegerGrid B ∧ + ∀ p : ℝ, (q : ℝ) ≤ p → (B : ℝ) ≤ Real.exp p → + (markedQuotientHeight s (Fintype.card ι) a d m q H : ℝ) ≤ Real.exp p → + M.ComplexityLE p := by + classical + obtain ⟨m, hm, q, hq, f, hstructure, hlayers⟩ := + exists_markedShiftQuotient_bounded_data F b ω hF hω v w marked hw hv hH hc hgen t + choose c hcoords using hlayers + let M₀ := markedShiftMultidegree F v w marked hw hv t + obtain ⟨B, hB, hdiv, hbound, D, M, hMF, _, hgrid, hcoord, hcomplex⟩ := + M₀.exists_bounded_integral_model f c hcoords hstructure l hl + exact ⟨m, hm, q, hq, B, hB, hdiv, hbound, D, M, hMF, hgrid, hcoord, hcomplex⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MaskedIntegerPeriodization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MaskedIntegerPeriodization.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6b9b20d1573b45ede0dd2ee41ac63b82b2b25c2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MaskedIntegerPeriodization.lean @@ -0,0 +1,241 @@ +import OAI.Combinatorics.Progressions.Fourier.CanonicalDensityFourier + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators NNReal + +variable {D : Type*} [Fintype D] + +noncomputable def maskedIntegerPeriodization (q : ℕ) (mask : (D → ZMod q) → ℝ) + (H : (D → ℝ) → ℝ) (x : D → ℝ) : ℝ := + ∑' n : D → ℤ, mask (fun i => (n i : ZMod q)) * H (fun i => x i + (n i : ℝ)) + +omit [Fintype D] in +private theorem masked_shift_nonzero (q : ℕ) (mask : (D → ZMod q) → ℝ) + (H : (D → ℝ) → ℝ) (x : D → ℝ) (n : D → ℤ) + (h : mask (fun i => (n i : ZMod q)) * H (fun i => x i + (n i : ℝ)) ≠ 0) : + H (fun i => x i + (n i : ℝ)) ≠ 0 := (mul_ne_zero_iff.mp h).2 + +theorem maskedIntegerPeriodization_lipschitz (q : ℕ) (mask : (D → ZMod q) → ℝ) + (hmask : ∀ r, mask r ∈ Set.Icc (0 : ℝ) 1) + (H : (D → ℝ) → ℝ) {L : ℝ≥0} (hH : LipschitzWith L H) + (h0 : ∀ x, 0 ≤ H x) (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) : + LipschitzWith L (maskedIntegerPeriodization q mask H) := by + apply separated_tsum_lipschitz + · intro n + apply LipschitzWith.of_dist_le_mul + intro x y + have h := hH.dist_le_mul (x + fun i => (n i : ℝ)) (y + fun i => (n i : ℝ)) + rw [dist_add_right] at h + rw [Real.dist_eq, ← mul_sub, abs_mul, abs_of_nonneg (hmask _).1] + calc + _ ≤ 1 * |H (fun i => x i + (n i : ℝ)) - H (fun i => y i + (n i : ℝ))| := + mul_le_mul_of_nonneg_right (hmask _).2 (abs_nonneg _) + _ ≤ L * dist x y := by simpa only [one_mul, Real.dist_eq, Pi.add_def] using h + · intro n x + exact mul_nonneg (hmask _).1 (h0 _) + · intro x n k hn hk + exact integer_shifts_small_box_injective x n k + (hs _ (masked_shift_nonzero q mask H x n hn)) + (hs _ (masked_shift_nonzero q mask H x k hk)) + +omit [Fintype D] in +theorem maskedIntegerPeriodization_local (q : ℕ) (mask : (D → ZMod q) → ℝ) + (H : (D → ℝ) → ℝ) (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) + (x : D → ℝ) (hx : ∀ i, |x i| < 1/2) (k : D → ℤ) : + maskedIntegerPeriodization q mask H (fun i => x i + (k i : ℝ)) = + mask (fun i => (-k i : ZMod q)) * H x := by + unfold maskedIntegerPeriodization + rw [tsum_eq_single (-k)] + · simp + · intro n hn + by_contra hnonzero + have hH := masked_shift_nonzero q mask H (fun i => x i + (k i : ℝ)) n hnonzero + have he := integer_shifts_small_box_injective (fun i => x i + (k i : ℝ)) n (-k) + (hs _ hH) (by simpa using hx) + exact hn he + +omit [Fintype D] in +theorem maskedIntegerPeriodization_range (q : ℕ) (mask : (D → ZMod q) → ℝ) + (hmask : ∀ r, mask r ∈ Set.Icc (0 : ℝ) 1) + (H : (D → ℝ) → ℝ) {B : ℝ} (hB : 0 ≤ B) + (hH : ∀ x, H x ∈ Set.Icc (0 : ℝ) B) + (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) (x : D → ℝ) : + maskedIntegerPeriodization q mask H x ∈ Set.Icc (0 : ℝ) B := by + refine ⟨tsum_nonneg (fun n => mul_nonneg (hmask _).1 (hH _).1), ?_⟩ + by_cases hx : ∃ n : D → ℤ, H (fun i => x i + (n i : ℝ)) ≠ 0 + · obtain ⟨n, hn⟩ := hx + unfold maskedIntegerPeriodization + rw [tsum_eq_single n] + · exact (mul_le_of_le_one_left (hH _).1 (hmask _).2).trans (hH _).2 + · intro k hk + have hz : H (fun i => x i + (k i : ℝ)) = 0 := by + by_contra hh + exact hk (integer_shifts_small_box_injective x k n (hs _ hh) (hs _ hn)) + rw [hz, mul_zero] + · have hz : ∀ n : D → ℤ, H (fun i => x i + (n i : ℝ)) = 0 := by simpa using hx + simpa only [maskedIntegerPeriodization, hz, mul_zero, tsum_zero] using hB + +omit [Fintype D] in +theorem maskedIntegerPeriodization_periodic (q : ℕ) (mask : (D → ZMod q) → ℝ) + (H : (D → ℝ) → ℝ) (x : D → ℝ) (k : D → ℤ) : + maskedIntegerPeriodization q mask H (fun i => x i + q * (k i : ℝ)) = + maskedIntegerPeriodization q mask H x := by + unfold maskedIntegerPeriodization + let v : D → ℤ := fun i => q * k i + have h := (Equiv.addRight v).tsum_eq (fun n : D → ℤ => + mask (fun i => (n i : ZMod q)) * H (fun i => x i + (n i : ℝ))) + convert h using 1 + apply tsum_congr + intro n + congr 1 + · congr 1 + funext i + simp [v] + · congr 1 + funext i + simp [v] + ring + +noncomputable def maskedIntegerTorusKernel (q : ℕ) (mask : (D → ZMod q) → ℝ) + (H : (D → ℝ) → ℝ) : (D → UnitAddCircle) → ℝ := + realPeriodicTorusLift (fun x => maskedIntegerPeriodization q mask H (fun i => q * x i)) + +omit [Fintype D] in +private theorem maskedIntegerPeriodization_rescale_periodic (q : ℕ) + (mask : (D → ZMod q) → ℝ) (H : (D → ℝ) → ℝ) + (x : D → ℝ) (k : D → ℤ) : + maskedIntegerPeriodization q mask H (fun i => q * (x i + (k i : ℝ))) = + maskedIntegerPeriodization q mask H (fun i => q * x i) := by + simp_rw [mul_add] + exact maskedIntegerPeriodization_periodic q mask H _ k + +omit [Fintype D] in +theorem maskedIntegerTorusKernel_coe (q : ℕ) (mask : (D → ZMod q) → ℝ) + (H : (D → ℝ) → ℝ) (x : D → ℝ) : + maskedIntegerTorusKernel q mask H (fun i => (x i : UnitAddCircle)) = + maskedIntegerPeriodization q mask H (fun i => q * x i) := + realPeriodicTorusLift_coe _ (maskedIntegerPeriodization_rescale_periodic q mask H) x + +theorem maskedIntegerTorusKernel_lipschitz (q : ℕ) (mask : (D → ZMod q) → ℝ) + (hmask : ∀ r, mask r ∈ Set.Icc (0 : ℝ) 1) + (H : (D → ℝ) → ℝ) {L : ℝ≥0} (hH : LipschitzWith L H) + (h0 : ∀ x, 0 ≤ H x) (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) : + LipschitzWith ((q : ℝ≥0) * L) (maskedIntegerTorusKernel q mask H) := by + apply realPeriodicTorusLift_lipschitz _ _ (maskedIntegerPeriodization_rescale_periodic q mask H) + apply LipschitzWith.of_dist_le_mul + intro x y + have h := (maskedIntegerPeriodization_lipschitz q mask hmask H hH h0 hs).dist_le_mul + ((q : ℝ) • x) ((q : ℝ) • y) + rw [dist_smul₀] at h + simpa only [Pi.smul_def, smul_eq_mul, Real.norm_natCast, NNReal.coe_mul, + NNReal.coe_natCast, mul_assoc, mul_left_comm] using h + +omit [Fintype D] in +theorem maskedIntegerTorusKernel_range (q : ℕ) (mask : (D → ZMod q) → ℝ) + (hmask : ∀ r, mask r ∈ Set.Icc (0 : ℝ) 1) + (H : (D → ℝ) → ℝ) {B : ℝ} (hB : 0 ≤ B) + (hH : ∀ x, H x ∈ Set.Icc (0 : ℝ) B) + (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) (x : D → UnitAddCircle) : + maskedIntegerTorusKernel q mask H x ∈ Set.Icc (0 : ℝ) B := + realPeriodicTorusLift_range _ (fun y => + maskedIntegerPeriodization_range q mask hmask H hB hH hs (fun i => q * y i)) x + +omit [Fintype D] in +theorem maskedIntegerPeriodization_le (q : ℕ) (mask : (D → ZMod q) → ℝ) + (hmask : ∀ r, mask r ≤ 1) (H : (D → ℝ) → ℝ) + (h0 : ∀ x, 0 ≤ H x) (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) + (x : D → ℝ) : + maskedIntegerPeriodization q mask H x ≤ positiveIntegerPeriodization H x := by + by_cases hx : ∃ n : D → ℤ, H (fun i => x i + (n i : ℝ)) ≠ 0 + · obtain ⟨n, hn⟩ := hx + have hz (k : D → ℤ) (hk : k ≠ n) : H (fun i => x i + (k i : ℝ)) = 0 := by + by_contra hh + exact hk (integer_shifts_small_box_injective x k n (hs _ hh) (hs _ hn)) + unfold maskedIntegerPeriodization positiveIntegerPeriodization + rw [tsum_eq_single n (fun k hk => by rw [hz k hk, mul_zero]), tsum_eq_single n hz] + exact mul_le_of_le_one_left (h0 _) (hmask _) + · have hz : ∀ n : D → ℤ, H (fun i => x i + (n i : ℝ)) = 0 := by simpa using hx + simp only [maskedIntegerPeriodization, positiveIntegerPeriodization, hz, mul_zero, tsum_zero, le_refl] + +omit [Fintype D] in +theorem maskedIntegerTorusKernel_one (q : ℕ) (H : (D → ℝ) → ℝ) + (z : D → UnitAddCircle) : + maskedIntegerTorusKernel q (fun _ => 1) H z = smallBoxTorusKernel H (q • z) := by + let x : D → ℝ := fun i => centeredCircleLift (z i) + have hx : (fun i => (x i : UnitAddCircle)) = z := funext (fun i => coe_centeredCircleLift _) + have hqx : (fun i => (((q : ℝ) * x i : ℝ) : UnitAddCircle)) = q • z := by + funext i + simp only [← nsmul_eq_mul, AddCircle.coe_nsmul, x, coe_centeredCircleLift, Pi.smul_apply] + rw [← hx, maskedIntegerTorusKernel_coe, hx, ← hqx] + rw [smallBoxTorusKernel, realPeriodicTorusLift_coe _ (positiveIntegerPeriodization_periodic H)] + simp only [maskedIntegerPeriodization, positiveIntegerPeriodization, one_mul] + +omit [Fintype D] in +theorem maskedIntegerTorusKernel_le (q : ℕ) (mask : (D → ZMod q) → ℝ) + (hmask : ∀ r, mask r ≤ 1) (H : (D → ℝ) → ℝ) + (h0 : ∀ x, 0 ≤ H x) (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) + (z : D → UnitAddCircle) : + maskedIntegerTorusKernel q mask H z ≤ smallBoxTorusKernel H (q • z) := by + let x : D → ℝ := fun i => centeredCircleLift (z i) + have hx : (fun i => (x i : UnitAddCircle)) = z := funext (fun i => coe_centeredCircleLift _) + have hqx : (fun i => (((q : ℝ) * x i : ℝ) : UnitAddCircle)) = q • z := by + funext i + simp only [← nsmul_eq_mul, AddCircle.coe_nsmul, x, coe_centeredCircleLift, Pi.smul_apply] + rw [← hx, maskedIntegerTorusKernel_coe, hx, ← hqx] + rw [smallBoxTorusKernel, realPeriodicTorusLift_coe _ (positiveIntegerPeriodization_periodic H)] + exact maskedIntegerPeriodization_le q mask hmask H h0 hs _ + +omit [Fintype D] in +theorem maskedIntegerTorusKernel_local (q : ℕ) (hq : 0 < q) + (mask : (D → ZMod q) → ℝ) (H : (D → ℝ) → ℝ) + (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) + (x : D → ℝ) (hx : ∀ i, |x i| < 1/2) (k : D → ℤ) : + maskedIntegerTorusKernel q mask H + (fun i => (((x i + (k i : ℝ)) / q : ℝ) : UnitAddCircle)) = + mask (fun i => (-k i : ZMod q)) * H x := by + rw [maskedIntegerTorusKernel_coe] + have he : (fun i => (q : ℝ) * ((x i + (k i : ℝ)) / q)) = + (fun i => x i + (k i : ℝ)) := by + funext i + field_simp + rw [he] + exact maskedIntegerPeriodization_local q mask H hs x hx k + +theorem exists_masked_integer_fourier_approximation + (q : ℕ) (mask : (D → ZMod q) → ℝ) + (hmask : ∀ r, mask r ∈ Set.Icc (0 : ℝ) 1) + (H : (D → ℝ) → ℝ) (L B : ℝ≥0) (hH : LipschitzWith L H) + (hB : ∀ x, H x ∈ Set.Icc (0 : ℝ) B) + (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) + {δ P : ℝ} (hδ : 0 < δ) (hP : 0 ≤ P) + (hD : (Fintype.card D : ℝ) ≤ P) + (hLP : (q : ℝ) * L ≤ Real.exp P) (hδP : δ⁻¹ ≤ Real.exp P) : + ∃ (F : Type) (inst : Fintype F), letI := inst + ∃ (frequency : F → D → ℤ) (c : F → ℂ), + (Fintype.card F : ℝ) ≤ Real.exp (2 * P * (2 * P + 2) ^ 4) ∧ + (∀ a i, |(frequency a i : ℝ)| ≤ Real.exp ((2 * P + 2) ^ 4)) ∧ + (∑ a, ‖c a‖) ≤ Real.exp (2 * P * (2 * P + 2) ^ 4) * B ∧ + ∀ x : D → UnitAddCircle, + ‖(maskedIntegerTorusKernel q mask H x : ℂ) - + ∑ a, c a * ∏ i, CircleFourier.character (frequency a i • x i)‖ ≤ δ := by + have hl : LipschitzWith ((q : ℝ≥0) * L) + (fun x => (maskedIntegerTorusKernel q mask H x : ℂ)) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [Complex.isometry_ofReal.dist_eq] + exact (maskedIntegerTorusKernel_lipschitz q mask hmask H hH (fun x => (hB x).1) hs).dist_le_mul x y + have hb (x : D → UnitAddCircle) : ‖(maskedIntegerTorusKernel q mask H x : ℂ)‖ ≤ B := by + obtain ⟨h0, hcap⟩ := maskedIntegerTorusKernel_range q mask hmask H B.coe_nonneg hB hs x + simpa only [Complex.norm_real, Real.norm_of_nonneg h0] using hcap + exact exists_ambient_torus_fourier_approximation _ _ B hl hb hδ hP hD + (by simpa only [NNReal.coe_mul, NNReal.coe_natCast] using hLP) hδP + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MaskedIntegerProductLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MaskedIntegerProductLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..55eb9c0241e2f10a1f01882572aee9119d813e5f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MaskedIntegerProductLaw.lean @@ -0,0 +1,149 @@ +import Mathlib.Probability.ProbabilityMassFunction.Monad +import OAI.Combinatorics.Progressions.Probability.PMFPointMassMixture + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical +variable {I : Type*} [Fintype I] [DecidableEq I] + +noncomputable def selectedIntegerMass (p : I → PMF ℤ) (H : Finset I) + (K : H → Finset ℤ) (z : ∀ i : H, K i) : ℝ := + ∏ i : H, (p i (z i).val).toReal + +noncomputable def selectedConditionedIntegerPMF (p : I → PMF ℤ) (H : Finset I) + (K : H → Finset ℤ) (z : ∀ i : H, K i) (i : I) : PMF ℤ := + if hi : i ∈ H then PMF.pure (z ⟨i, hi⟩).val else p i + +noncomputable def integerProductMass (p : I → PMF ℤ) (x : I → ℤ) : ℝ := + ∏ i, (p i (x i)).toReal + +theorem integerProductMass_split (p : I → PMF ℤ) (H : Finset I) (x : I → ℤ) : + integerProductMass p x = (∏ i : H, (p i (x i)).toReal) * + ∏ i : {i // i ∉ H}, (p i (x i)).toReal := by + have hu : @Finset.univ H (Subtype.fintype (fun i : I => i ∈ H)) = + @Finset.univ H (Finset.Subtype.fintype H) := by ext i; simp + simpa only [integerProductMass, hu] using + (Fintype.prod_subtype_mul_prod_subtype (fun i => i ∈ H) + (fun i => (p i (x i)).toReal)).symm + +theorem selectedIntegerMass_conditioned_product (p : I → PMF ℤ) (H : Finset I) + (K : H → Finset ℤ) (z : ∀ i : H, K i) (x : I → ℤ) : + selectedIntegerMass p H K z * integerProductMass (selectedConditionedIntegerPMF p H K z) x = + if ∀ i : H, (z i).val = x i then integerProductMass p x else 0 := by + by_cases hx : ∀ i : H, (z i).val = x i + · rw [ite_eq_left hx, integerProductMass_split _ H] + have hm : selectedIntegerMass p H K z = ∏ i : H, (p i (x i)).toReal := by + simp only [selectedIntegerMass, hx] + have hs : (∏ i : H, (selectedConditionedIntegerPMF p H K z i (x i)).toReal) = 1 := by + apply Finset.prod_eq_one + intro i _ + simp only [selectedConditionedIntegerPMF, dite_eq_left i.property, hx, + PMF.pure_apply_self, ENNReal.toReal_one] + have hc : (∏ i : {i // i ∉ H}, + (selectedConditionedIntegerPMF p H K z i (x i)).toReal) = + ∏ i : {i // i ∉ H}, (p i (x i)).toReal := by + apply Finset.prod_congr rfl + intro i _ + simp only [selectedConditionedIntegerPMF, dite_eq_right i.property] + rw [hs, hc, one_mul, hm, integerProductMass_split p H] + · rw [ite_eq_right hx] + obtain ⟨i, hi⟩ := not_forall.mp hx + have hz : (selectedConditionedIntegerPMF p H K z i (x i)).toReal = 0 := by + simp only [selectedConditionedIntegerPMF, dite_eq_left i.property, + PMF.pure_apply_of_ne _ _ (Ne.symm hi), ENNReal.toReal_zero] + have hp : integerProductMass (selectedConditionedIntegerPMF p H K z) x = 0 := + Finset.prod_eq_zero (Finset.mem_univ i.val) hz + rw [hp, mul_zero] + +theorem selectedIntegerMass_product_decomposition (p : I → PMF ℤ) (H : Finset I) + (K : H → Finset ℤ) (hK : ∀ i : H, ∀ k, p i k ≠ 0 → k ∈ K i) (x : I → ℤ) : + (∑ z : ∀ i : H, K i, selectedIntegerMass p H K z * + integerProductMass (selectedConditionedIntegerPMF p H K z) x) = + integerProductMass p x := by + simp_rw [selectedIntegerMass_conditioned_product] + by_cases hx : ∀ i : H, x i ∈ K i + · let z₀ : ∀ i : H, K i := fun i => ⟨x i, hx i⟩ + rw [Finset.sum_eq_single z₀] + · simp [z₀] + · intro z _ hz + have hne : ¬∀ i : H, (z i).val = x i := by + intro h + apply hz + funext i + exact Subtype.ext (h i) + rw [ite_eq_right hne] + · intro h + exact (h (Finset.mem_univ _)).elim + · obtain ⟨i, hi⟩ := not_forall.mp hx + have hz : p i (x i) = 0 := by by_contra h; exact hi (hK i (x i) h) + have hp : integerProductMass p x = 0 := Finset.prod_eq_zero + (Finset.mem_univ i.val) (by simp only [hz, ENNReal.toReal_zero]) + simp [hp] + +theorem selectedIntegerMass_masked_product_bounds (p : I → PMF ℤ) (H : Finset I) + (K : H → Finset ℤ) (hK : ∀ i : H, ∀ k, p i k ≠ 0 → k ∈ K i) + (E : (∀ i : H, K i) → Prop) (x : I → ℤ) : + 0 ≤ (∑ z : ∀ i : H, K i, if E z then selectedIntegerMass p H K z * + integerProductMass (selectedConditionedIntegerPMF p H K z) x else 0) ∧ + (∑ z : ∀ i : H, K i, if E z then selectedIntegerMass p H K z * + integerProductMass (selectedConditionedIntegerPMF p H K z) x else 0) ≤ + integerProductMass p x := by + have hnonneg (z : ∀ i : H, K i) : 0 ≤ selectedIntegerMass p H K z * + integerProductMass (selectedConditionedIntegerPMF p H K z) x := by + unfold selectedIntegerMass integerProductMass + positivity + constructor + · apply Finset.sum_nonneg + intro z _ + split_ifs + · exact hnonneg z + · exact le_rfl + · rw [← selectedIntegerMass_product_decomposition p H K hK x] + apply Finset.sum_le_sum + intro z _ + split_ifs <;> simp only [le_refl, hnonneg] + +omit [Fintype I] in +theorem selectedIntegerMass_total (p : I → PMF ℤ) (H : Finset I) + (K : H → Finset ℤ) (hK : ∀ i : H, ∀ k, p i k ≠ 0 → k ∈ K i) : + (∑ z : ∀ i : H, K i, selectedIntegerMass p H K z) = 1 := by + unfold selectedIntegerMass + rw [← Fintype.prod_sum (fun (i : H) (z : K i) => (p i z.val).toReal)] + apply Finset.prod_eq_one + intro i _ + rw [Finset.sum_coe_sort (K i) (fun k => (p i k).toReal)] + have hz (k : ℤ) (hk : k ∉ K i) : (p i k).toReal = 0 := by + have hp : p i k = 0 := by by_contra h; exact hk (hK i k h) + rw [hp, ENNReal.toReal_zero] + exact (hasSum_sum_of_ne_finset_zero hz).unique (pmf_toReal_hasSum (p i)) + +omit [Fintype I] in +theorem selectedIntegerMass_masked_total_bounds (p : I → PMF ℤ) (H : Finset I) + (K : H → Finset ℤ) (hK : ∀ i : H, ∀ k, p i k ≠ 0 → k ∈ K i) + (E : (∀ i : H, K i) → Prop) : + 0 ≤ (∑ z : ∀ i : H, K i, if E z then selectedIntegerMass p H K z else 0) ∧ + (∑ z : ∀ i : H, K i, if E z then selectedIntegerMass p H K z else 0) ≤ 1 := by + have hpos (z : ∀ i : H, K i) : 0 ≤ selectedIntegerMass p H K z := by + unfold selectedIntegerMass + positivity + constructor + · apply Finset.sum_nonneg + intro z _ + split_ifs + · exact hpos z + · exact le_rfl + · rw [← selectedIntegerMass_total p H K hK] + apply Finset.sum_le_sum + intro z _ + split_ifs + · exact le_rfl + · exact hpos z + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MixedArrayIntegerImage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MixedArrayIntegerImage.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8956893bd492796ac38d480b090ea32394c6e97 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MixedArrayIntegerImage.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.Progressions.Geometry.MixedArraySourceSupport + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule +open scoped BigOperators Matrix + +variable {D I J O Z : Type*} [Fintype D] [Fintype I] [Fintype J] {n : ℕ} + +noncomputable def mixedArrayIntegerImage (A : Matrix O J ℤ) + (x : (I → J → ℝ) × (Z → J → ℤ)) : (I → O → ℝ) × (Z → O → ℤ) := + (fun i => (A.map (Int.cast : ℤ → ℝ)) *ᵥ x.1 i, fun z => A *ᵥ x.2 z) + +omit [Fintype I] in +theorem mixedArrayIntegerImage_regroup (A : Matrix O J ℤ) + (x : (I → J → ℝ) × (Z → J → ℤ)) (r : O) : + mixedArrayRegroup I Z O (mixedArrayIntegerImage A x) r = + ∑ j, A r j • mixedArrayRegroup I Z J x j := by + apply Prod.ext + · funext i + simp only [mixedArrayIntegerImage, mixedArrayRegroup_apply, Prod.fst_sum, + Finset.sum_apply] + change (∑ j, (A r j : ℝ) * x.1 i j) = ∑ j, A r j • x.1 i j + exact Finset.sum_congr rfl (fun j _ => Int.cast_smul_eq_zsmul ℝ (A r j) (x.1 i j)) + · funext z + simp only [mixedArrayIntegerImage, mixedArrayRegroup_apply, Prod.snd_sum, + Finset.sum_apply] + change (∑ j, A r j * x.2 z j) = ∑ j, A r j • x.2 z j + simp only [smul_eq_mul] + +variable (W : Submodule ℝ (EuclideanSpace ℝ D)) (b : Basis (Fin n) ℝ Wᗮ) +variable (hb : span ℤ (Set.range b) = projectedIntegerLattice W) +variable (o : OrthonormalBasis I ℝ W) + +theorem mixedArrayIntegerImage_quotient [Fintype O] (A : Matrix O J ℤ) + (x : (I → J → ℝ) × (Fin n → J → ℤ)) (r : O) : + mixedArrayQuotient W b hb o (mixedArrayIntegerImage A x) r = + ∑ j, A r j • mixedArrayQuotient W b hb o x j := by + unfold mixedArrayQuotient + rw [mixedArrayIntegerImage_regroup] + rw [orthonormalMixedChart_sum_zsmul, normalizedLatticeQuotient_sum_zsmul] + +theorem mixedArrayIntegerImage_point (A : Matrix O J ℤ) + (x : (I → J → ℝ) × (Fin n → J → ℤ)) (r : O) : + normalizedLatticePoint W b (orthonormalMixedChart o + (mixedArrayRegroup I (Fin n) O (mixedArrayIntegerImage A x) r)) = + ∑ j, A r j • normalizedLatticePoint W b + (orthonormalMixedChart o (mixedArrayRegroup I (Fin n) J x j)) := by + rw [mixedArrayIntegerImage_regroup] + rw [orthonormalMixedChart_sum_zsmul, normalizedLatticePoint_sum_zsmul] + +theorem mixedArrayIntegerImage_unique [Fintype O] (A : Matrix O J ℤ) + (x : (I → J → ℝ) × (Fin n → J → ℤ)) + (y : (I → O → ℝ) × (Fin n → O → ℤ)) + (hx : mixedArrayInChart W b o (mixedArrayIntegerImage A x)) + (hy : mixedArrayInChart W b o y) + (hq : ∀ r, mixedArrayQuotient W b hb o y r = + ∑ j, A r j • mixedArrayQuotient W b hb o x j) : + y = mixedArrayIntegerImage A x := by + apply mixedArrayQuotient_injOn_chart W b hb o hy hx + exact funext (fun r => (hq r).trans (mixedArrayIntegerImage_quotient W b hb o A x r).symm) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MixedCoveredIntegerReconstruction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MixedCoveredIntegerReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..f775ecab7a6cd7bbbf842e40c378c6d6600fc0fa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MixedCoveredIntegerReconstruction.lean @@ -0,0 +1,88 @@ +import OAI.Combinatorics.Progressions.Geometry.MixedCoveredChart + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule +open scoped BigOperators + +variable {D Q : Type*} [Fintype D] [Fintype Q] {n : ℕ} +variable (W : Submodule ℝ (EuclideanSpace ℝ D)) (b : Basis (Fin n) ℝ Wᗮ) +variable (hb : span ℤ (Set.range b) = projectedIntegerLattice W) +variable (bW : Basis Q ℤ (latticeSection (standardEuclideanLattice D) W).toAddSubgroup) +variable (d : ℕ) [NeZero d] + +theorem normalizedCoveredChart_sum_zsmul {S : Type*} (s : Finset S) + (a : S → ℤ) (x : S → W × (Fin n → ℤ)) (r : S → Q → ZMod d) : + normalizedCoveredChart W b hb bW d (∑ i ∈ s, a i • x i, ∑ i ∈ s, a i • r i) = + ∑ i ∈ s, a i • normalizedCoveredChart W b hb bW d (x i, r i) := by + let Γ := (latticeSection (standardEuclideanLattice D) W).toAddSubgroup + let e := coverKernelBasisEquiv Γ bW d (Nat.pos_of_ne_zero (NeZero.ne d)) + let deck : (Q → ZMod d) →+ W ⧸ Γ := (quotientIntegerCover Γ d).ker.subtype.comp e.toAddMonoidHom + change normalizedCoverLift W b hb d (∑ i ∈ s, a i • x i) + deck (∑ i ∈ s, a i • r i) = + ∑ i ∈ s, a i • (normalizedCoverLift W b hb d (x i) + deck (r i)) + rw [normalizedCoverLift_sum_zsmul] + simp only [map_sum, map_zsmul, smul_add, Finset.sum_add_distrib] + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule +open scoped BigOperators Classical + +variable {m : ℕ} {I O P J Q : Fin m → Type*} {n : Fin m → ℕ} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (O j)] [∀ j, Fintype (J j)] [∀ j, Fintype (Q j)] + +noncomputable def mixedCoveredJetIntegerImage (d : ℕ) + (A : ∀ j, Matrix (P j) (O j) ℤ) (z : MixedCoveredJetSource I O Q n d) : + MixedCoveredJetSource I P Q n d := + (fun j => mixedArrayIntegerImage (A j) (z.1 j), + fun j t k => ∑ r, A j t r • z.2 j r k) + +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +theorem mixedCoveredJetIntegerImage_chart + (A : ∀ j, Matrix (P j) (O j) ℤ) (z : MixedCoveredJetSource I O Q n d) + (j : Fin m) (t : P j) : + mixedCoveredJetChart U o b hb bW d (mixedCoveredJetIntegerImage d A z) j t = + ∑ r, A j t r • mixedCoveredJetChart U o b hb bW d z j r := by + change normalizedCoveredChart (euclideanSubspace (U j)) (b j) (hb j) (bW j) d + (orthonormalMixedChart (o j) (mixedArrayRegroup _ _ _ (mixedArrayIntegerImage (A j) (z.1 j)) t), + fun k => ∑ r, A j t r • z.2 j r k) = _ + rw [mixedArrayIntegerImage_regroup, orthonormalMixedChart_sum_zsmul] + have hdeck : (fun k => ∑ r, A j t r • z.2 j r k) = ∑ r, A j t r • z.2 j r := by + funext k + simp only [Finset.sum_apply, Pi.smul_apply] + rw [hdeck] + exact normalizedCoveredChart_sum_zsmul (euclideanSubspace (U j)) (b j) (hb j) (bW j) d + Finset.univ (A j t) (fun r => orthonormalMixedChart (o j) (mixedArrayRegroup _ _ _ (z.1 j) r)) + (z.2 j) + +omit [∀ j, Fintype (Q j)] [NeZero d] in +theorem mixedCoveredJetIntegerImage_point + (A : ∀ j, Matrix (P j) (O j) ℤ) (z : MixedCoveredJetSource I O Q n d) + (j : Fin m) (t : P j) : + normalizedLatticePoint (euclideanSubspace (U j)) (b j) + (mixedCoveredJetCoordinates U o d (mixedCoveredJetIntegerImage d A z) j t).1 = + ∑ r, A j t r • normalizedLatticePoint (euclideanSubspace (U j)) (b j) + (mixedCoveredJetCoordinates U o d z j r).1 := by + exact mixedArrayIntegerImage_point (euclideanSubspace (U j)) (b j) (o j) (A j) (z.1 j) t + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MixedSmoothUniformBadPrimeProduct.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MixedSmoothUniformBadPrimeProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f0ab07fe141a089895e54fccf04589d6dec42bc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MixedSmoothUniformBadPrimeProduct.lean @@ -0,0 +1,502 @@ +import Mathlib.RingTheory.Coprime.Lemmas +import OAI.Combinatorics.Progressions.Estimates.FiniteFiberPMF +import OAI.Combinatorics.Progressions.Lattices.SmoothBadPrimeProduct + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem uniform_fiberLaw_surjective_hom {G H : Type*} + [AddCommGroup G] [AddCommGroup H] [Fintype G] [Fintype H] + (f : G →+ H) (hf : Function.Surjective f) : + (FiniteProbabilityWeights.uniform G).fiberLaw f = + FiniteProbabilityWeights.uniform H := by + apply FiniteProbabilityWeights.eq_of_weight_eq + intro y + have hh := uniform_mean_surjective_hom_fiber f hf y + change _ = (Fintype.card H : ℝ)⁻¹ + convert hh using 1 + unfold FiniteProbabilityWeights.fiberLaw FiniteProbabilityWeights.fiberMean + congr 1 + +theorem uniform_complexMean_surjective_hom {G H : Type*} + [AddCommGroup G] [AddCommGroup H] [Fintype G] [Fintype H] + (f : G →+ H) (hf : Function.Surjective f) (g : H → ℂ) : + (FiniteProbabilityWeights.uniform G).complexMean (fun x => g (f x)) = + (FiniteProbabilityWeights.uniform H).complexMean g := by + rw [← FiniteProbabilityWeights.fiberLaw_complexMean, + uniform_fiberLaw_surjective_hom f hf] + +theorem uniform_tupleResidueReduction_fiberLaw {D : Type*} + [Fintype D] [DecidableEq D] {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) : + (FiniteProbabilityWeights.uniform (D → ZMod N)).fiberLaw (tupleResidueReduction hMN) = + FiniteProbabilityWeights.uniform (D → ZMod M) := + uniform_fiberLaw_surjective_hom (tupleResidueReduction hMN) + (tupleResidueReduction_surjective hMN) + +theorem uniform_tupleResidueReduction_mean {D : Type*} + [Fintype D] [DecidableEq D] {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) (g : (D → ZMod M) → ℝ) : + (FiniteProbabilityWeights.uniform (D → ZMod N)).mean + (fun x => g (tupleResidueReduction hMN x)) = + (FiniteProbabilityWeights.uniform (D → ZMod M)).mean g := + uniform_mean_surjective_hom (tupleResidueReduction hMN) + (tupleResidueReduction_surjective hMN) g + +theorem uniform_tupleResidueReduction_complexMean {D : Type*} + [Fintype D] [DecidableEq D] {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) (g : (D → ZMod M) → ℂ) : + (FiniteProbabilityWeights.uniform (D → ZMod N)).complexMean + (fun x => g (tupleResidueReduction hMN x)) = + (FiniteProbabilityWeights.uniform (D → ZMod M)).complexMean g := + uniform_complexMean_surjective_hom (tupleResidueReduction hMN) + (tupleResidueReduction_surjective hMN) g + +theorem expect_tupleResidueReduction {D : Type*} + [Fintype D] [DecidableEq D] {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) (g : (D → ZMod M) → ℝ) : + (𝔼 x : D → ZMod N, g (tupleResidueReduction hMN x)) = + 𝔼 y : D → ZMod M, g y := by + simpa only [FiniteProbabilityWeights.uniform_mean] using + uniform_tupleResidueReduction_mean hMN g + +theorem uniform_tupleResidueReduction_toPMF_map {D : Type*} + [Fintype D] [DecidableEq D] {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) : + (FiniteProbabilityWeights.uniform (D → ZMod N)).toPMF.map (tupleResidueReduction hMN) = + (FiniteProbabilityWeights.uniform (D → ZMod M)).toPMF := by + rw [← FiniteProbabilityWeights.toPMF_fiberLaw, + uniform_tupleResidueReduction_fiberLaw hMN] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical +open FiniteProbabilityWeights + +theorem finiteWeights_prod_same_l1 {X Y : Type*} [Fintype X] [Fintype Y] + (p q : FiniteProbabilityWeights X) (u : FiniteProbabilityWeights Y) : + (∑ z : X × Y, |(p.prod u).weight z - (q.prod u).weight z|) = + ∑ x : X, |p.weight x - q.weight x| := by + simp only [FiniteProbabilityWeights.prod, ← sub_mul, abs_mul, + abs_of_nonneg (u.nonneg _), Fintype.sum_prod_type, ← Finset.mul_sum, + u.total, mul_one] + +def mixedResidueArrayEquiv (J D R : Type*) : ((J → R) × (D → R)) ≃ ((J ⊕ D) → R) where + toFun p := Sum.elim p.1 p.2 + invFun f := (fun j => f (.inl j), fun d => f (.inr d)) + left_inv _ := rfl + right_inv f := by funext t; cases t <;> rfl + +private theorem uniform_pair_sum_complexMean {J D : Type*} [Fintype J] [Fintype D] + (M : ℕ) [NeZero M] (f : ((J ⊕ D) → ZMod M) → ℂ) : + ((uniform (J → ZMod M)).prod (uniform (D → ZMod M))).complexMean + (fun p => f (Sum.elim p.1 p.2)) = + (uniform ((J ⊕ D) → ZMod M)).complexMean f := by + rw [complexMean_prod] + simp_rw [uniform_complexMean] + have hprod := Finset.expect_product' (Finset.univ : Finset (J → ZMod M)) + (Finset.univ : Finset (D → ZMod M)) (fun x y => f (Sum.elim x y)) + rw [Finset.univ_product_univ] at hprod + rw [← hprod] + exact Fintype.expect_equiv (mixedResidueArrayEquiv J D (ZMod M)) _ _ (fun _ => rfl) + +theorem mixedSmoothUniform_residue_complexMean_eq {J D : Type*} [Fintype J] [Fintype D] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) (hZ : 0 < shiftedSmoothProductMass a S) + {M N : ℕ} [NeZero M] [NeZero N] (hMN : M ∣ N) + (f : ((J ⊕ D) → ZMod M) → ℂ) : + ((shiftedSmoothProductFiniteWeights a S hS hZ).prod (uniform (D → ZMod N))).complexMean + (fun z => f (Sum.elim (fun j => (z.1.val j : ZMod M)) + (fun d => ZMod.castHom hMN (ZMod M) (z.2 d)))) = + ((ofPMF ((shiftedSmoothProductPMF a S hS hZ).map + (fun x j => (x j : ZMod M)))).prod (uniform (D → ZMod M))).complexMean + (fun z => f (Sum.elim z.1 z.2)) := by + rw [complexMean_prod, complexMean_prod] + have hred (x : J → ZMod M) : + (uniform (D → ZMod N)).complexMean (fun y => f (Sum.elim x + (fun d => ZMod.castHom hMN (ZMod M) (y d)))) = + (uniform (D → ZMod M)).complexMean (fun y => f (Sum.elim x y)) := + uniform_tupleResidueReduction_complexMean hMN (fun y => f (Sum.elim x y)) + simp_rw [hred] + exact shiftedSmoothProductFiniteWeights_map_complexMean a S hS hZ + (fun x j => (x j : ZMod M)) (fun x => (uniform (D → ZMod M)).complexMean + (fun y => f (Sum.elim x y))) + +theorem mixedSmoothUniform_residue_l1 {J D : Type*} [Fintype J] [Fintype D] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) (hZ : 0 < shiftedSmoothProductMass a S) + (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) : + (∑ z : (J → ZMod M) × (D → ZMod M), + |((ofPMF ((shiftedSmoothProductPMF a S hS hZ).map + (fun x j => (x j : ZMod M)))).prod (uniform (D → ZMod M))).weight z - + ((uniform (J → ZMod M)).prod (uniform (D → ZMod M))).weight z|) ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + rw [finiteWeights_prod_same_l1] + exact shiftedSmoothProductPMF_residue_l1 a S hS hZ M hlarge + +theorem mixedSmoothUniform_residue_complexMean_error {J D : Type*} [Fintype J] [Fintype D] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) (hZ : 0 < shiftedSmoothProductMass a S) + {M N : ℕ} [NeZero M] [NeZero N] (hMN : M ∣ N) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (f : ((J ⊕ D) → ZMod M) → ℂ) (hf : ∀ r, ‖f r‖ ≤ 1) : + ‖((shiftedSmoothProductFiniteWeights a S hS hZ).prod (uniform (D → ZMod N))).complexMean + (fun z => f (Sum.elim (fun j => (z.1.val j : ZMod M)) + (fun d => ZMod.castHom hMN (ZMod M) (z.2 d)))) - + (uniform ((J ⊕ D) → ZMod M)).complexMean f‖ ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + rw [mixedSmoothUniform_residue_complexMean_eq a S hS hZ hMN, + ← uniform_pair_sum_complexMean M f] + let p : FiniteProbabilityWeights (J → ZMod M) := + ofPMF ((shiftedSmoothProductPMF a S hS hZ).map (fun x j => (x j : ZMod M))) + let q : FiniteProbabilityWeights (J → ZMod M) := uniform (J → ZMod M) + let u : FiniteProbabilityWeights (D → ZMod M) := uniform (D → ZMod M) + let g : (J → ZMod M) × (D → ZMod M) → ℂ := fun z => f (Sum.elim z.1 z.2) + have hg : ∀ z, ‖g z‖ ≤ 1 := fun z => hf (Sum.elim z.1 z.2) + have htest := norm_complexMean_sub_le_weight_l1 (p.prod u) (q.prod u) g hg + have hweight : (∑ z, |(p.prod u).weight z - (q.prod u).weight z|) ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := + mixedSmoothUniform_residue_l1 (D := D) a S hS hZ M hlarge + exact htest.trans hweight + +private theorem complexMean_indicator_eq_event {T : Type*} [Fintype T] + (p : FiniteProbabilityWeights T) (E : T → Prop) : + p.complexMean (fun x => if E x then (1 : ℂ) else 0) = (p.eventProbability E : ℂ) := by + simp only [complexMean, eventProbability, mean, Complex.ofReal_sum, Complex.ofReal_mul] + apply Finset.sum_congr rfl + intro x _ + split_ifs <;> simp + +theorem mixedSmoothUniform_residue_event_error {J D : Type*} [Fintype J] [Fintype D] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) (hZ : 0 < shiftedSmoothProductMass a S) + {M N : ℕ} [NeZero M] [NeZero N] (hMN : M ∣ N) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (E : ((J ⊕ D) → ZMod M) → Prop) : + |((shiftedSmoothProductFiniteWeights a S hS hZ).prod (uniform (D → ZMod N))).eventProbability + (fun z => E (Sum.elim (fun j => (z.1.val j : ZMod M)) + (fun d => ZMod.castHom hMN (ZMod M) (z.2 d)))) - + (uniform ((J ⊕ D) → ZMod M)).eventProbability E| ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + have h := mixedSmoothUniform_residue_complexMean_error a S hS hZ hMN hlarge + (fun r => if E r then (1 : ℂ) else 0) (fun r => by split_ifs <;> norm_num) + rw [complexMean_indicator_eq_event, complexMean_indicator_eq_event, + ← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] at h + exact h + +theorem mixedSmoothUniform_residue_event_error_of_width + {J D : Type*} [Fintype J] [Fintype D] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) (hZ : 0 < shiftedSmoothProductMass a S) + {B W η : ℝ} (hW : 0 < W) (hwidth : ∀ j, W ≤ S j) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) * B ≤ W) + (herror : (Fintype.card J : ℝ) * + (16 * (probabilityProfileLipschitz : ℝ) * B / W) ≤ η) + {M N : ℕ} [NeZero M] [NeZero N] (hMN : M ∣ N) (hM : (M : ℝ) ≤ B) + (E : ((J ⊕ D) → ZMod M) → Prop) : + |((shiftedSmoothProductFiniteWeights a S hS hZ).prod (uniform (D → ZMod N))).eventProbability + (fun z => E (Sum.elim (fun j => (z.1.val j : ZMod M)) + (fun d => ZMod.castHom hMN (ZMod M) (z.2 d)))) - + (uniform ((J ⊕ D) → ZMod M)).eventProbability E| ≤ η := by + have hB : 0 ≤ B := (Nat.cast_nonneg M).trans hM + have hscale (j) : 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j := + ((mul_le_mul_of_nonneg_left hM (by positivity)).trans hlarge).trans (hwidth j) + apply (mixedSmoothUniform_residue_event_error a S hS hZ hMN hscale E).trans + calc + _ ≤ ∑ _j : J, 16 * (probabilityProfileLipschitz : ℝ) * B / W := by + apply Finset.sum_le_sum + intro j _ + exact div_le_div₀ (by positivity) (mul_le_mul_of_nonneg_left hM (by positivity)) + hW (hwidth j) + _ ≤ η := by + simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using herror + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +theorem FiniteProbabilityWeights.fiberLaw_comp {X Y Z : Type*} + [Fintype X] [Fintype Y] [Fintype Z] + (p : FiniteProbabilityWeights X) (f : X → Y) (g : Y → Z) : + (p.fiberLaw f).fiberLaw g = p.fiberLaw (g ∘ f) := by + apply FiniteProbabilityWeights.eq_of_weight_eq + intro z + change (p.fiberLaw f).mean (fun y => if g y = z then (1 : ℝ) else 0) = + p.mean (fun x => if g (f x) = z then (1 : ℝ) else 0) + exact p.fiberLaw_mean f _ + +theorem uniform_tupleResidueReduction_fiberLaw_postcompose {D Y : Type*} + [Fintype D] [DecidableEq D] [Fintype Y] + {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) (f : (D → ZMod M) → Y) : + (FiniteProbabilityWeights.uniform (D → ZMod N)).fiberLaw + (fun x => f (tupleResidueReduction hMN x)) = + (FiniteProbabilityWeights.uniform (D → ZMod M)).fiberLaw f := by + rw [← uniform_tupleResidueReduction_fiberLaw hMN, + FiniteProbabilityWeights.fiberLaw_comp] + rfl + +theorem tupleResidueReduction_affine {D : Type*} {M N : ℕ} + (hMN : M ∣ N) (a x : D → ZMod N) (step : ℕ) : + tupleResidueReduction hMN (fun d => a d + (step : ZMod N) * x d) = + fun d => tupleResidueReduction hMN a d + + (step : ZMod M) * tupleResidueReduction hMN x d := by + funext d + change ZMod.castHom hMN (ZMod M) (a d + (step : ZMod N) * x d) = _ + simp only [map_add, map_mul, map_natCast] + rfl + +theorem uniform_affine_tupleResidueReduction_fiberLaw {D : Type*} + [Fintype D] [DecidableEq D] {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) (a : D → ZMod N) (step : ℕ) : + ((FiniteProbabilityWeights.uniform (D → ZMod N)).fiberLaw + (fun x d => a d + (step : ZMod N) * x d)).fiberLaw + (tupleResidueReduction hMN) = + (FiniteProbabilityWeights.uniform (D → ZMod M)).fiberLaw + (fun y d => tupleResidueReduction hMN a d + (step : ZMod M) * y d) := by + rw [FiniteProbabilityWeights.fiberLaw_comp] + simp only [Function.comp_def, tupleResidueReduction_affine] + exact uniform_tupleResidueReduction_fiberLaw_postcompose (D := D) hMN + (fun y d => tupleResidueReduction hMN a d + (step : ZMod M) * y d) + +theorem uniform_affine_tupleResidueReduction_complexMean {D : Type*} + [Fintype D] [DecidableEq D] {M N : ℕ} [NeZero M] [NeZero N] + (hMN : M ∣ N) (a : D → ZMod N) (step : ℕ) + (f : (D → ZMod M) → ℂ) : + (FiniteProbabilityWeights.uniform (D → ZMod N)).complexMean + (fun x => f (tupleResidueReduction hMN + (fun d => a d + (step : ZMod N) * x d))) = + (FiniteProbabilityWeights.uniform (D → ZMod M)).complexMean + (fun y => f (fun d => tupleResidueReduction hMN a d + + (step : ZMod M) * y d)) := by + simp only [tupleResidueReduction_affine] + exact uniform_tupleResidueReduction_complexMean (D := D) hMN + (fun y => f (fun d => tupleResidueReduction hMN a d + (step : ZMod M) * y d)) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +open FiniteProbabilityWeights + +theorem selectedPrimePower_product_dvd (S : Finset ℕ) (a : ℕ → ℕ) + (hprime : ∀ p ∈ S, Nat.Prime p) {N : ℕ} + (hcover : ∀ p ∈ S, p ^ a p ∣ N) : + (∏ p : S, p.val ^ a p) ∣ N := by + apply Fintype.prod_dvd_of_isRelPrime + · intro p q hpq + exact Nat.coprime_iff_isRelPrime.mp (selectedPrimePower_coprime S a hprime hpq) + · intro p + exact hcover p p.property + +theorem coefficientCRTEquiv_mixed_reduction {L J D : Type*} [Fintype L] + (q : L → ℕ) (hq : Pairwise (fun l k => (q l).Coprime (q k))) + {N : ℕ} (hMN : (∏ l, q l) ∣ N) (x : J → ℤ) (r : D → ZMod N) : + coefficientCRTEquiv q hq + (Sum.elim (fun j => (x j : ZMod (∏ l, q l))) + (fun d => ZMod.castHom hMN (ZMod (∏ l, q l)) (r d))) = + (fun l => Sum.elim (fun j => (x j : ZMod (q l))) + (fun d => ZMod.cast (r d))) := by + funext l k + cases k with + | inl j => + rw [coefficientCRTEquiv_apply] + exact map_intCast _ _ + | inr d => + rw [coefficientCRTEquiv_apply] + change ZMod.castHom _ (ZMod (q l)) + (ZMod.castHom hMN (ZMod (∏ l, q l)) (r d)) = ZMod.cast (r d) + rw [← RingHom.comp_apply, ZMod.castHom_comp, ZMod.castHom_apply] + +private theorem uniform_event_fintype_congr {X : Type*} [Nonempty X] + (i₁ i₂ : Fintype X) (E : X → Prop) : + @eventProbability X i₁ (@uniform X i₁ inferInstance) E = + @eventProbability X i₂ (@uniform X i₂ inferInstance) E := by + cases Subsingleton.elim i₁ i₂ + rfl + +theorem mixedSmoothUniform_primePower_event + {J D : Type*} [Fintype J] [Fintype D] {N : ℕ} [NeZero N] + (center width : J → ℝ) (hwidth : ∀ j, 0 < width j) + (hZ : 0 < shiftedSmoothProductMass center width) + (S : Finset ℕ) (a : ℕ → ℕ) (hprime : ∀ p ∈ S, Nat.Prime p) + (hcover : ∀ p ∈ S, p ^ a p ∣ N) + [∀ p : S, NeZero (p.val ^ a p)] + (E : ∀ p : S, ((J ⊕ D) → ZMod (p.val ^ a p)) → Prop) + (hprob : ∀ p : S, + (uniform ((J ⊕ D) → ZMod (p.val ^ a p))).eventProbability (E p) ≤ + 1 / ((p.val ^ a p : ℕ) : ℝ) ^ 10) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (∏ p : S, p.val ^ a p) ≤ width j) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (D → ZMod N))).eventProbability + (fun x => ∀ p : S, E p (Sum.elim + (fun j => (x.1.val j : ZMod (p.val ^ a p))) + (fun d => ZMod.cast (x.2 d)))) ≤ + 1 / ((∏ p : S, p.val ^ a p : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : S, p.val ^ a p) / width j := by + let : NeZero (∏ p : S, p.val ^ a p) := ⟨(selectedPrimePower_nonzero S a hprime).2⟩ + let q : S → ℕ := fun p => p.val ^ a p + let hq := selectedPrimePower_coprime S a hprime + have hMN : (∏ p : S, q p) ∣ N := selectedPrimePower_product_dvd S a hprime hcover + let F : ((J ⊕ D) → ZMod (∏ p : S, q p)) → Prop := + fun y => ∀ p : S, E p (coefficientCRTEquiv q hq y p) + have htransfer := mixedSmoothUniform_residue_event_error center width hwidth hZ hMN hlarge F + have hF (x : rectangularWeightIndices center width 1 × (D → ZMod N)) : + F (Sum.elim (fun j => (x.1.val j : ZMod (∏ p : S, q p))) + (fun d => ZMod.castHom hMN (ZMod (∏ p : S, q p)) (x.2 d))) = + (∀ p : S, E p (Sum.elim (fun j => (x.1.val j : ZMod (p.val ^ a p))) + (fun d => ZMod.cast (x.2 d)))) := by + unfold F + rw [coefficientCRTEquiv_mixed_reduction] + simp only [hF] at htransfer + have huniform : (uniform ((J ⊕ D) → ZMod (∏ p : S, q p))).eventProbability F ≤ + 1 / ((∏ p : S, p.val ^ a p : ℕ) : ℝ) ^ 10 := by + have hu : (uniform ((J ⊕ D) → ZMod (∏ p : S, q p))).eventProbability F = + ∏ p : S, (uniform ((J ⊕ D) → ZMod (q p))).eventProbability (E p) := by + convert uniform_coefficientCRT_event q hq E using 1 + · exact uniform_event_fintype_congr _ _ _ + · apply Finset.prod_congr rfl + intro p _ + exact uniform_event_fintype_congr _ _ _ + rw [hu] + calc + _ ≤ ∏ p : S, 1 / ((p.val ^ a p : ℕ) : ℝ) ^ 10 := + Finset.prod_le_prod₀ (fun p _ => (uniform _).eventProbability_nonneg (E p)) + (fun p _ => hprob p) + _ = _ := by + simp only [one_div, ← Finset.prod_inv_distrib, ← Finset.prod_pow, Nat.cast_prod] + have hupper := (abs_le.mp htransfer).2 + dsimp only [q] at hupper huniform + linarith only [hupper, huniform] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +open FiniteProbabilityWeights + +def mixedSmoothUniformResiduePrimeBad {J D : Type*} {N : ℕ} (P : Finset ℕ) + (E : ∀ p : P, ∀ a : ℕ, ((J ⊕ D) → ZMod (p.val ^ a)) → Prop) + (p a : ℕ) (x : (J → ℤ) × (D → ZMod N)) : Prop := + ∃ hp : p ∈ P, E ⟨p, hp⟩ a + (Sum.elim (fun j => (x.1 j : ZMod (p ^ a))) (fun d => ZMod.cast (x.2 d))) + +theorem mixedSmoothUniform_badPrimeProduct_probability + {J D : Type*} [Fintype J] [Fintype D] {N : ℕ} [NeZero N] + (center width : J → ℝ) (hwidth : ∀ j, 0 < width j) + (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (E : ∀ p : P, ∀ a : ℕ, ((J ⊕ D) → ZMod (p.val ^ a)) → Prop) + {Qs Q R : ℕ} (hprime : ∀ p ∈ P, p.Prime) + (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hQs : 2 ≤ Qs) (hQ : 1 ≤ Q) (hR : 0 < R) + (hdepth : ∀ p ∈ P, p ^ A p ≤ Q) + (hprob : ∀ (p : P) a, 0 < a → a ≤ A p → Qs ≤ p.val ^ a → + (uniform ((J ⊕ D) → ZMod (p.val ^ a))).eventProbability (E p a) ≤ + 1 / ((p.val ^ a : ℕ) : ℝ) ^ 10) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (max Q (R ^ 2) : ℕ) ≤ width j) + {η : ℝ} (hη : 0 ≤ η) + (herror : (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (max Q (R ^ 2) : ℕ) / width j) ≤ η) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (D → ZMod N))).eventProbability + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => mixedSmoothUniformResiduePrimeBad P E p a (x.1.val, x.2)) p x) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + apply largestBadPrimeProduct_probability_bounded _ P A _ hprime hQs hQ hR hdepth hη + intro T hTP a ha hd + let (p : T) : NeZero (p.val ^ a p) := + ⟨pow_ne_zero _ (hprime p (hTP p.property)).ne_zero⟩ + let F (p : T) := E ⟨p.val, hTP p.property⟩ (a p) + have hprod : (∏ p : T, p.val ^ a p) = ∏ p ∈ T, p ^ a p := + Finset.prod_coe_sort T (fun p => p ^ a p) + have hd' : (∏ p : T, p.val ^ a p) ≤ max Q (R ^ 2) := by + rw [hprod] + exact hd + have hs (j) : 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : T, p.val ^ a p) ≤ width j := + (mul_le_mul_of_nonneg_left (by exact_mod_cast hd') (by positivity)).trans (hlarge j) + have h := mixedSmoothUniform_primePower_event (D := D) (N := N) + center width hwidth hZ T a (fun p hp => hprime p (hTP hp)) + (fun p hp => (pow_dvd_pow p (ha p hp).2.1).trans (hcover p (hTP hp))) F + (fun p => hprob ⟨p.val, hTP p.property⟩ (a p) (ha p p.property).1 + (ha p p.property).2.1 (ha p p.property).2.2) hs + have hevents : + (fun x : rectangularWeightIndices center width 1 × (D → ZMod N) => + ∀ p ∈ T, mixedSmoothUniformResiduePrimeBad P E p (a p) (x.1.val, x.2)) = + (fun x => ∀ p : T, F p + (Sum.elim (fun j => (x.1.val j : ZMod (p.val ^ a p))) + (fun d => ZMod.cast (x.2 d)))) := by + funext x + apply propext + constructor + · intro hx p + obtain ⟨hp, he⟩ := hx p p.property + exact he + · intro hx p hp + exact ⟨hTP hp, hx ⟨p, hp⟩⟩ + rw [hevents] + have herr : (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (∏ p : T, p.val ^ a p) / width j) ≤ η := by + apply le_trans (Finset.sum_le_sum (fun j _ => ?_)) herror + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left (by exact_mod_cast hd') (by positivity)) (hwidth j).le + rw [hprod] at h herr + exact h.trans (add_le_add le_rfl herr) + +theorem exists_early_mixedSmoothUniform_badPrimeProduct_cutoff + (Qs : ℕ) (hQs : 2 ≤ Qs) {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ (J D : Type*) [Fintype J] [Fintype D] + (N : ℕ) [NeZero N] + (center width : J → ℝ) (hwidth : ∀ j, 0 < width j) + (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (E : ∀ p : P, ∀ a : ℕ, ((J ⊕ D) → ZMod (p.val ^ a)) → Prop) (Q : ℕ), + (∀ p ∈ P, p.Prime) → (∀ p ∈ P, p ^ A p ∣ N) → + 1 ≤ Q → (∀ p ∈ P, p ^ A p ≤ Q) → + (∀ (p : P) a, 0 < a → a ≤ A p → Qs ≤ p.val ^ a → + (uniform ((J ⊕ D) → ZMod (p.val ^ a))).eventProbability (E p a) ≤ + 1 / ((p.val ^ a : ℕ) : ℝ) ^ 10) → + (∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (max Q (R ^ 2) : ℕ) ≤ width j) → + (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) / width j) ≤ + δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2)) → + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (D → ZMod N))).eventProbability + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => mixedSmoothUniformResiduePrimeBad P E p a (x.1.val, x.2)) p x) ≤ δ := by + obtain ⟨R, hR, hradius⟩ := exists_early_badPrime_radius hδ + refine ⟨R, hR, ?_⟩ + intro J D _ _ N _ center width hwidth hZ P A _ E Q hprime hcover hQ hdepth hprob hlarge herror + exact (mixedSmoothUniform_badPrimeProduct_probability center width hwidth hZ P A E + hprime hcover hQs hQ hR hdepth hprob hlarge + (hradius Q hQ).1.le herror).trans (hradius Q hQ).2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MixedTranslationAffineInput.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MixedTranslationAffineInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3e589639d05f679497a8de06181281db95687fe --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MixedTranslationAffineInput.lean @@ -0,0 +1,47 @@ +import OAI.Combinatorics.Progressions.Geometry.MixedEvaluationCoordinates + +namespace OAI + +section + +namespace Erdos3 + +def mixedTranslationSlope (s : ℕ) : Option (ReplicatedIndex (mixedCorrelationDegree s)) → ℤ + | none => 0 + | some j => if j.1 = 1 then 1 else 0 + +def mixedTranslationIntercept (s : ℕ) (h δ : ℤ) : + Option (ReplicatedIndex (mixedCorrelationDegree s)) → ℤ + | none => δ + | some j => if j.1 = 1 then 0 else h + +theorem mixedTranslationSample_affine (s : ℕ) (h n δ : ℤ) : + (fun j => mixedTranslationIntercept s h δ j + mixedTranslationSlope s j * n) = + mixedTranslationSample s ![h, n, δ] := by + funext j + rcases j with _ | ⟨j, k⟩ + · simp [mixedTranslationIntercept, mixedTranslationSlope, mixedTranslationSample] + · fin_cases j <;> simp [mixedTranslationIntercept, mixedTranslationSlope, + mixedTranslationSample, correlationInput] + rfl + +theorem mixedTranslationSlope_replaced_none (s : ℕ) (i : ReplicatedIndex (mixedCorrelationDegree s)) : + mixedTranslationSlope s (coordinateReplaceIndex i none) = 0 := by + simp [coordinateReplaceIndex, mixedTranslationSlope] + +theorem mixedTranslationSlope_replaced_vanishes (s : ℕ) + (i j : ReplicatedIndex (mixedCorrelationDegree s)) + (hj : j ∉ (mixedEvaluationCoordinates s).erase i) : + mixedTranslationSlope s (coordinateReplaceIndex i (some j)) = 0 := by + by_cases hji : j = i + · simp [coordinateReplaceIndex, hji, mixedTranslationSlope] + · have hj₁ : j.1 ≠ 1 := by + intro h + exact hj (Finset.mem_erase.mpr ⟨hji, (mem_mixedEvaluationCoordinates s j).mpr h⟩) + simp [coordinateReplaceIndex, hji, mixedTranslationSlope, hj₁] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ModularAffineSpatialGCD.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ModularAffineSpatialGCD.lean new file mode 100644 index 0000000000000000000000000000000000000000..e60bba37a7778c28fd911b8e7438d90022617beb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ModularAffineSpatialGCD.lean @@ -0,0 +1,37 @@ +import Mathlib.Data.Nat.Factorization.Basic +import Mathlib.Data.ZMod.Basic + +namespace OAI + +section + +namespace Erdos3 + +theorem nat_gcd_primePower_eq_pow_min_factorization {stride p : ℕ} + (hstride : 0 < stride) (hp : p.Prime) (a : ℕ) : + Nat.gcd stride (p ^ a) = p ^ min (stride.factorization p) a := by + obtain ⟨b, hba, hb⟩ := (Nat.dvd_prime_pow hp).mp (Nat.gcd_dvd_right stride (p ^ a)) + have hbs : p ^ b ∣ stride := by + rw [← hb] + exact Nat.gcd_dvd_left stride (p ^ a) + have hbval : b ≤ stride.factorization p := + (hp.pow_dvd_iff_le_factorization hstride.ne').mp hbs + apply Nat.dvd_antisymm + · rw [hb] + exact pow_dvd_pow p (le_min hbval hba) + · exact Nat.dvd_gcd + ((hp.pow_dvd_iff_le_factorization hstride.ne').mpr (min_le_left _ _)) + (pow_dvd_pow p (min_le_right _ _)) + +theorem zmod_natCast_gcd_primePower_eq_pow_min_factorization {stride p : ℕ} + (hstride : 0 < stride) (hp : p.Prime) (a : ℕ) : + Nat.gcd ((stride : ZMod (p ^ a)).val) (p ^ a) = + p ^ min (stride.factorization p) a := by + rw [ZMod.val_natCast, ← Nat.gcd_rec, Nat.gcd_comm] + exact nat_gcd_primePower_eq_pow_min_factorization hstride hp a + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ModularCoefficientBadPrimeProduct.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ModularCoefficientBadPrimeProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..914016c743faaa4a99f0db36e56f555cc924e2e1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ModularCoefficientBadPrimeProduct.lean @@ -0,0 +1,194 @@ +import OAI.Combinatorics.Progressions.Estimates.ModularVectorCoefficientExceptions + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +noncomputable def modularCoefficientPrimeThreshold (s : ℕ) : ℕ := + max 2 ⌈(s : ℝ) ^ (4 / modularRankSmallBallExponent s)⌉₊ + +theorem modularCoefficientPrimeThreshold_two_le (s : ℕ) : + 2 ≤ modularCoefficientPrimeThreshold s := le_max_left _ _ + +theorem modularCoefficientPrimeThreshold_real (s : ℕ) : + max 2 ((s : ℝ) ^ (4 / modularRankSmallBallExponent s)) ≤ + (modularCoefficientPrimeThreshold s : ℝ) := by + apply max_le + · exact_mod_cast modularCoefficientPrimeThreshold_two_le s + · exact (Nat.le_ceil _).trans + (Nat.cast_le.mpr (le_max_right 2 ⌈(s : ℝ) ^ (4 / modularRankSmallBallExponent s)⌉₊)) + +theorem modularCoefficientPrimeThreshold_le_primePower {s p a : ℕ} + (h : modularCoefficientPrimeThreshold s ≤ p ^ a) : + max 2 ((s : ℝ) ^ (4 / modularRankSmallBallExponent s)) ≤ (p : ℝ) ^ a := by + have hc : (modularCoefficientPrimeThreshold s : ℝ) ≤ (p : ℝ) ^ a := by + exact_mod_cast h + exact (modularCoefficientPrimeThreshold_real s).trans hc + +theorem primePower_rpow_neg_ten (p a : ℕ) : + ((p : ℝ) ^ a) ^ (-(10 : ℝ)) = 1 / ((p ^ a : ℕ) : ℝ) ^ 10 := by + rw [Real.rpow_neg (by positivity)] + norm_cast + rw [one_div] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {T D : Type*} {B : T → Type*} + +noncomputable def taggedCoefficientReduction {M N : ℕ} (hMN : M ∣ N) : + (∀ t, B t → D → ZMod N) →+ (∀ t, B t → D → ZMod M) where + toFun c t b j := ZMod.castHom hMN (ZMod M) (c t b j) + map_zero' := by ext t b j; simp + map_add' := by + intro c d + ext t b j + exact map_add (ZMod.castHom hMN (ZMod M)) (c t b j) (d t b j) + +theorem taggedCoefficientReduction_surjective {M N : ℕ} (hMN : M ∣ N) : + Function.Surjective (taggedCoefficientReduction (T := T) (B := B) (D := D) hMN) := by + intro y + choose c hc using fun t b j => ZMod.castHom_surjective hMN (y t b j) + exact ⟨c, funext fun t => funext fun b => funext (hc t b)⟩ + +theorem uniform_taggedCoefficientReduction_event + [Fintype T] [DecidableEq T] [Fintype D] [DecidableEq D] + [∀ t, Fintype (B t)] [∀ t, DecidableEq (B t)] + {M N : ℕ} [NeZero M] [NeZero N] (hMN : M ∣ N) + (E : (∀ t, B t → D → ZMod M) → Prop) : + (FiniteProbabilityWeights.uniform (∀ t, B t → D → ZMod N)).eventProbability + (fun c => E (taggedCoefficientReduction hMN c)) = + (FiniteProbabilityWeights.uniform (∀ t, B t → D → ZMod M)).eventProbability E := by + exact uniform_mean_surjective_hom (taggedCoefficientReduction hMN) + (taggedCoefficientReduction_surjective hMN) (fun c => if E c then 1 else 0) + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +variable {T D I : Type*} [Fintype T] [DecidableEq T] + [Fintype D] [DecidableEq D] [Fintype I] [DecidableEq I] + {B : T → Type*} [∀ t, Fintype (B t)] [∀ t, DecidableEq (B t)] + +def topDepthCoefficientBad {p : ℕ} [NeZero p] (depth : ℕ) + (n : T → ℕ) (S : ∀ t, B t → D → Finset I) + (Q : ∀ t, B t → MvPolynomial I (ZMod (p ^ depth))) + (C : ℝ) (a : ℕ) (c : ∀ t, B t → D → ZMod (p ^ depth)) : Prop := + ∃ ha : a ≤ depth, ∃ t, ∃ w : B t → ZMod (p ^ a), (∃ b, IsUnit (w b)) ∧ + ((p : ℝ) ^ a) ^ (-C) < + vectorDesignatedRankFailureProbability (p ^ a) (n t) (S t) + (fun b => (Q t b).map (ZMod.castHom (pow_dvd_pow p ha) (ZMod (p ^ a)))) w + (taggedCoefficientReduction (pow_dvd_pow p ha) c t) + +omit [Fintype T] [DecidableEq T] in +theorem topDepthCoefficientBad_iff {p depth a : ℕ} [NeZero p] (ha : a ≤ depth) + (n : T → ℕ) (S : ∀ t, B t → D → Finset I) + (Q : ∀ t, B t → MvPolynomial I (ZMod (p ^ depth))) + (C : ℝ) (c : ∀ t, B t → D → ZMod (p ^ depth)) : + topDepthCoefficientBad depth n S Q C a c ↔ + ∃ t, ∃ w : B t → ZMod (p ^ a), (∃ b, IsUnit (w b)) ∧ + ((p : ℝ) ^ a) ^ (-C) < + vectorDesignatedRankFailureProbability (p ^ a) (n t) (S t) + (fun b => (Q t b).map (ZMod.castHom (pow_dvd_pow p ha) (ZMod (p ^ a)))) w + (taggedCoefficientReduction (pow_dvd_pow p ha) c t) := by + constructor + · rintro ⟨h, ht⟩ + exact ht + · exact fun ht => ⟨ha, ht⟩ + +theorem topDepthCoefficientBad_probability {p depth a s m : ℕ} [NeZero p] + (hp : p.Prime) (ha : 0 < a) (had : a ≤ depth) + (n : T → ℕ) (hns : ∀ t, n t + 1 ≤ s) (hTs : Fintype.card T ≤ s) + (hBm : ∀ t, Fintype.card (B t) ≤ m) + (S : ∀ t, B t → D → Finset I) + (Q : ∀ t, B t → MvPolynomial I (ZMod (p ^ depth))) + (hcard : ∀ t b j, (S t b j).card = n t + 1) + (hdisjoint : ∀ t b, Pairwise (fun j k => Disjoint (S t b j) (S t b k))) + {C : ℝ} (hC : 0 ≤ C) + (hq : max 2 ((s : ℝ) ^ (4 / modularRankSmallBallExponent s)) ≤ (p : ℝ) ^ a) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ Fintype.card D) : + (FiniteProbabilityWeights.uniform (∀ t, B t → D → ZMod (p ^ depth))).eventProbability + (topDepthCoefficientBad depth n S Q C a) ≤ ((p : ℝ) ^ a) ^ (-(10 : ℝ)) := by + let f := ZMod.castHom (pow_dvd_pow p had) (ZMod (p ^ a)) + let Qlow := fun t b => (Q t b).map f + let E : (∀ t, B t → D → ZMod (p ^ a)) → Prop := fun c => + ∃ t, ∃ w : B t → ZMod (p ^ a), (∃ b, IsUnit (w b)) ∧ + ((p : ℝ) ^ a) ^ (-C) < + vectorDesignatedRankFailureProbability (p ^ a) (n t) (S t) (Qlow t) w (c t) + have he : topDepthCoefficientBad depth n S Q C a = + fun c => E (taggedCoefficientReduction (pow_dvd_pow p had) c) := by + funext c + exact propext (topDepthCoefficientBad_iff had n S Q C c) + rw [he, uniform_taggedCoefficientReduction_event] + exact taggedVectorDesignatedRank_exceptional_probability hp ha n hns hTs hBm + S Qlow hcard hdisjoint hC hq hJ + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +variable {T D I : Type*} [Fintype T] [DecidableEq T] + [Fintype D] [DecidableEq D] [Fintype I] [DecidableEq I] + {B : T → Type*} [∀ t, Fintype (B t)] [∀ t, DecidableEq (B t)] + +def coefficientPrimeArrayBad (P : Finset ℕ) (depth : ℕ → ℕ) + [∀ p : P, NeZero p.val] (n : T → ℕ) (S : ∀ t, B t → D → Finset I) + (Q : ∀ p : P, ∀ t, B t → MvPolynomial I (ZMod (p.val ^ depth p.val))) (C : ℝ) : + ℕ → ℕ → (∀ p : P, ∀ t, B t → D → ZMod (p.val ^ depth p.val)) → Prop := + primeArrayBad P (fun p a => topDepthCoefficientBad (depth p.val) n S (Q p) C a) + +theorem coefficientPrimeArray_bad_product_probability + (P : Finset ℕ) (depth : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) {s m R : ℕ} (hR : 0 < R) + (n : T → ℕ) (hns : ∀ t, n t + 1 ≤ s) (hTs : Fintype.card T ≤ s) + (hBm : ∀ t, Fintype.card (B t) ≤ m) + (S : ∀ t, B t → D → Finset I) + (Q : ∀ p : P, ∀ t, B t → MvPolynomial I (ZMod (p.val ^ depth p.val))) + (hcard : ∀ t b j, (S t b j).card = n t + 1) + (hdisjoint : ∀ t b, Pairwise (fun j k => Disjoint (S t b j) (S t b k))) + {C : ℝ} (hC : 0 ≤ C) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ Fintype.card D) : + (FiniteProbabilityWeights.pi (fun p : P => + FiniteProbabilityWeights.uniform (∀ t, B t → D → ZMod (p.val ^ depth p.val)))).eventProbability + (fun c => smallPrimePowerCorrection (modularCoefficientPrimeThreshold s) * R < + ∏ p ∈ P, p ^ largestTestedBadDepth depth + (coefficientPrimeArrayBad P depth n S Q C) p c) ≤ 2 / (9 * (R : ℝ) ^ 9) := by + let maxPower := max 1 (P.sup (fun p => p ^ depth p)) + have hmax : ∀ p ∈ P, p ^ depth p ≤ maxPower := by + intro p hp + exact (Finset.le_sup (f := fun p => p ^ depth p) hp).trans (le_max_right _ _) + apply independent_largestBadPrimeProduct_probability P + (fun p : P => FiniteProbabilityWeights.uniform (∀ t, B t → D → ZMod (p.val ^ depth p.val))) + (fun p a => topDepthCoefficientBad (depth p.val) n S (Q p) C a) depth + hprime (modularCoefficientPrimeThreshold_two_le s) (le_max_left 1 _) hR hmax + intro p a ha had hlarge + have h := topDepthCoefficientBad_probability (hprime p.val p.property) ha had n hns hTs hBm + S (Q p) hcard hdisjoint hC (modularCoefficientPrimeThreshold_le_primePower hlarge) hJ + simpa only [primePower_rpow_neg_ten] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ModularMultilinearAffineCost.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ModularMultilinearAffineCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..063f96ae675b4c2494b736ab8eaec9095110b5b0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ModularMultilinearAffineCost.lean @@ -0,0 +1,76 @@ +import OAI.Combinatorics.Progressions.Estimates.ModularMultilinearAmbientSublevel + +namespace OAI + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +theorem modularMultilinear_affine_mean_sublevel {I : Type*} [Fintype I] [DecidableEq I] + {r p a : ℕ} [NeZero p] (hr : 0 < r) (hp : p.Prime) (ha : 0 < a) + (P : MvPolynomial I (ZMod (p ^ a))) (f : Fin r → I) + (hf : Function.Injective f) (hdeg : P.totalDegree ≤ r) + (hP : ∀ i, degreeOf i P ≤ 1) + (hunit : IsUnit (P.coeff ((fullShiftExponent r).mapDomain f))) + (offset : (I → ZMod (p ^ a)) → ZMod (p ^ a)) : + (𝔼 x : I → ZMod (p ^ a), 𝔼 t : ZMod (p ^ a), + if t * eval x P + offset x = 0 then (1 : ℝ) else 0) ≤ + ((r + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ r) := by + let b := (a + 1) / 2 + have hb := modularSublevel_half_depth ha + let reduce : ZMod (p ^ a) →+* ZMod (p ^ b) := + ZMod.castHom (pow_dvd_pow p hb.2.1) (ZMod (p ^ b)) + have hmap : ∀ i, degreeOf i (P.map reduce) ≤ 1 := by + intro i + rw [degreeOf_le_iff] + intro m hm + exact degreeOf_le_iff.mp (hP i) m (support_map_subset reduce P hm) + have hunit' : IsUnit ((P.map reduce).coeff ((fullShiftExponent r).mapDomain f)) := by + rw [coeff_map] + exact hunit.map reduce + have hdeg' : (P.map reduce).totalDegree ≤ r := by + unfold totalDegree + apply Finset.sup_le + intro m hm + exact (le_totalDegree (support_map_subset reduce P hm)).trans hdeg + have hsmall := modularMultilinear_sublevel_of_pos hr hp hb.1 + (P.map reduce) f hf hdeg' hmap hunit' + have hbad : (𝔼 x : I → ZMod (p ^ a), + if reduce (eval x P) = 0 then (1 : ℝ) else 0) ≤ + (r : ℝ) * (p : ℝ) ^ (-(b : ℝ) / (2 : ℝ) ^ (r - 1)) := by + change (𝔼 x : I → ZMod (p ^ a), + if ZMod.castHom (pow_dvd_pow p hb.2.1) (ZMod (p ^ b)) (eval x P) = 0 + then (1 : ℝ) else 0) ≤ _ + rw [modularPolynomial_zero_reduction (pow_dvd_pow p hb.2.1)] + exact hsmall + have hp1 : (1 : ℝ) ≤ p := by exact_mod_cast hp.one_lt.le + have hfiber (c d : ZMod (p ^ a)) (hc : reduce c ≠ 0) : + (𝔼 t : ZMod (p ^ a), if t * c + d = 0 then (1 : ℝ) else 0) ≤ + (p : ℝ) ^ (-(a : ℝ) / 2) := by + have h := zmod_prime_power_affine_zero_expect_le_rpow hp hb.1 hb.2.1 c d hc + simpa only [mul_comm c] using h.trans (modularSublevel_fiber_exponent hp1 ha) + have hsplit := modularAffine_zero_split (fun x => eval x P) offset reduce + (Real.rpow_nonneg (show (0 : ℝ) ≤ p by positivity) (-(a : ℝ) / 2)) hfiber + exact hsplit.trans ((add_le_add hbad le_rfl).trans + (modularSublevel_induction_bound hp1 ha hr)) + +theorem modularMultilinear_gcd_mean_sublevel {I : Type*} [Fintype I] [DecidableEq I] + {r p a : ℕ} [NeZero p] (hr : 0 < r) (hp : p.Prime) (ha : 0 < a) + (P : MvPolynomial I (ZMod (p ^ a))) (f : Fin r → I) + (hf : Function.Injective f) (hdeg : P.totalDegree ≤ r) + (hP : ∀ i, degreeOf i P ≤ 1) + (hunit : IsUnit (P.coeff ((fullShiftExponent r).mapDomain f))) : + (𝔼 x : I → ZMod (p ^ a), ((eval x P).val.gcd (p ^ a) : ℝ) / (p ^ a : ℕ)) ≤ + ((r + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ r) := by + have h := modularMultilinear_affine_mean_sublevel hr hp ha P f hf hdeg hP hunit + (fun _ => 0) + rw [zmod_gcd_expect_eq_mul_zero_expect (p ^ a) (fun x => eval x P)] + simpa only [add_zero, mul_comm] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MultidegreeIntegerTranslation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MultidegreeIntegerTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d41228a7b4f373cffaee134bcfa64ab519e7eba --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MultidegreeIntegerTranslation.lean @@ -0,0 +1,113 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeNilcharacterTranslationEquivalence + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +open scoped TensorProduct BigOperators + +theorem exists_integer_translation_equivalence_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type} {I σ : Type*} + [LieRing L] [LieAlgebra ℚ L] [Fintype I] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) {p : ℝ} + (V : D.UnitVerticalObservable (D.filtration.realification.subgroup (s + 1)) I p) + (g : D.filtration.realification.PolynomialOrbit (fun _ : σ => 1)), + 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card I : ℝ) ≤ Real.exp p → + ∀ a b : σ → ℤ, + NativeIntegerVectorEquivalence s ((p + C) ^ C) + (fun i x => V.observable i (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval (fun _ : σ => 1) (x + a) g))) + (fun i x => V.observable i (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval (fun _ : σ => 1) (x + b) g))) := by + obtain ⟨A, _, hexpand⟩ := exists_shifted_product_expansion s + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A) ^ A + X + 4) + refine ⟨C, hC, ?_⟩ + intro L I σ _ _ _ _ _ _ _ d D p V g hp hD hI a b + let r := (p + A) ^ A + let q := r + p + 4 + have hr : 0 ≤ r := by dsimp [r]; positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have hrq : r ≤ q := by dsimp [q]; linarith + have hq : 0 ≤ q := hp.trans hpq + have hbound : q ≤ (p + C) ^ C := by + simpa [q, r, X, Polynomial.eval₂_pow] using hbudget p hp + have hd := hI.trans (Real.exp_le_exp.mpr (hpq.trans hbound)) + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra) := + realification_moduleTopology_t2 (Module.finBasis ℚ D.filtration.squareLieSubalgebra) + let := moduleTopology ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1))) := IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1))) := + realification_moduleTopology_t2 (Module.finBasis ℚ (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1))) + refine ⟨hd, hd, ?_⟩ + intro i j + obtain ⟨n, Q, S, _, hSc, hSe⟩ := hexpand D V g hp hD (fun _ => Nat.zero_lt_one) i j a b + have hcard : (Fintype.card (Fin 4) : ℝ) ≤ Real.exp q := by + simp only [Fintype.card_fin, Nat.cast_ofNat] + have h4 : 4 ≤ q := by dsimp [q]; linarith + linarith [Real.add_one_le_exp q] + have hcost : (∑ k, ‖polarizationWeight k‖) ≤ Real.exp q := by + rw [polarizationWeight_cost] + exact Real.one_le_exp hq + exact ⟨(NativeIntegerExpansion.ofFamily Q S polarizationWeight hcard + (fun k => (hSc k).mono hrq) hcost hSe).mono hbound⟩ + +end Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +end + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + +theorem exists_multidegree_integer_translation (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ : Type*} [Fintype σ] (bound : σ → ℕ), + (∑ i, bound i) = s + 1 → ∀ {p : ℝ} (W : NativeMultidegreeNilcharacter bound p) + (a b : σ → ℤ), NativeIntegerVectorEquivalence s ((p + C) ^ C) + (fun i x => W.eval i (x + a)) (fun i x => W.eval i (x + b)) := by + obtain ⟨C, hC, htranslate⟩ := UnitVerticalObservable.exists_integer_translation_equivalence_budget s + refine ⟨C, hC, ?_⟩ + intro σ _ bound hdegree p W a b + rw [← hdegree] at htranslate + have hp : 0 ≤ p := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + let U : W.model.UnitVerticalObservable + (W.model.filtration.realification.subgroup (∑ i, bound i)) (Fin W.outputDim) p := + { W.vertical with + vertical := fun i z hz x => W.vertical.vertical i z (W.multi.realSubgroup_top.symm ▸ hz) x + integral := fun z hz hL => W.vertical.integral z (W.multi.realSubgroup_top.symm ▸ hz) hL } + have hI : (Fintype.card (Fin W.outputDim) : ℝ) ≤ Real.exp p := by + simpa only [Fintype.card_fin] using W.output_bound + have E := htranslate W.model U (W.multi.orbitToOrdinary W.orbit) hp W.complexity.1 hI a b + have heval (i : Fin W.outputDim) (x : σ → ℤ) : + U.observable i (QuotientGroup.mk + (W.model.filtration.realification.polynomialOrbitEval (fun _ => 1) x + (W.multi.orbitToOrdinary W.orbit))) = W.eval i x := by + rw [W.multi.orbitToOrdinary_eval] + rfl + simpa only [heval] using E + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/MultilinearAffineExpansion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/MultilinearAffineExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef85a87142a0afcc4dc231793c6252c2e193415c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/MultilinearAffineExpansion.lean @@ -0,0 +1,33 @@ +import Mathlib.Data.Finset.Piecewise +import Mathlib.LinearAlgebra.Multilinear.Basic + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem multilinear_affine_expansion {H R M : Type*} [Fintype H] [DecidableEq H] [CommRing R] + [AddCommGroup M] [Module R M] (F : MultilinearMap R (fun _ : H => M) R) + (b w : H → M) (x : H → R) : + F (fun i => b i + x i • w i) = + ∑ S : Finset H, F (S.piecewise w b) * ∏ i ∈ S, x i := by + have he : (fun i => b i + x i • w i) = (fun i => x i • w i) + b := by + funext i + exact add_comm _ _ + rw [he, F.map_add_univ] + apply Finset.sum_congr rfl + intro S _ + have hs : S.piecewise (fun i => x i • w i) b = + (fun i => (if i ∈ S then x i else 1) • S.piecewise w b i) := by + funext i + by_cases hi : i ∈ S <;> simp [Finset.piecewise, hi] + rw [hs, F.map_smul_univ, Finset.prod_ite_mem_eq, smul_eq_mul, mul_comm] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeCorrelatedAffineExistence.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeCorrelatedAffineExistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..161d3f56cd4bfe50a65d81fb8418636cb69b7118 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeCorrelatedAffineExistence.lean @@ -0,0 +1,272 @@ +import OAI.Combinatorics.Progressions.Estimates.SharedFreeCorrelatedFactorization + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module VectorPolynomial RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s (r + 1) N b f} {out : Fin W.family.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P) + (B₀ : D.CoefficientBases Q) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure (r + 1)) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q) + (F : FreeCoordinateFrame E.basis Q) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) Q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ} + {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'} + (D' : R'.CommonData P') + +def CorrelatedAffineComparison (hs : 2 ≤ s) : Prop := + let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + let C := sharedFreeCorrelationBudget s hs P' + let Qc := C + sharedFreeComparisonBasisBudget Q P' + 2 + let Lv := sharedFreePetalLiftBudget s Q P' + let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D' + ∃ J ⊆ H', J.Nonempty ∧ Real.exp (-(Λ + C)) * H'.card ≤ (J.card : ℝ) ∧ + ∃ (r₀ : ℕ) (R₀ : Fin r₀ → ℕ) (η : (Fin r₀ → ℤ) →+ ZMod N) (h₀ : ZMod N) + (Γ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (α : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + (β : Fin r₀ → Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra), + (r₀ : ℝ) ≤ Λ ∧ Set.InjOn η {x | ∀ j, |x j| ≤ (R₀ j : ℤ)} ∧ E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 Γ = 1 ∧ + (∀ d : Fin s, coefficients Γ.log (Finsupp.single () (d.val + 1)) ∈ + ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ) ∧ + (∀ d, α d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + ‖(E.basis.baseChange ℝ).equivFun (α d)‖ ≤ Real.exp Lv) ∧ + (∀ j d, β j d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + ‖(E.basis.baseChange ℝ).equivFun (β j d)‖ ≤ Real.exp Lv) ∧ + ∃ (x : {h // h ∈ J} → Fin r₀ → ℤ) + (A K U : {h // h ∈ J} → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)), + (∀ h : {h // h ∈ J}, + (∀ j, |x h j| ≤ (R₀ j : ℤ)) ∧ h.val = h₀ + η (x h) ∧ + (A h).log = Γ.log + positiveUnivariate (fun d => α d + ∑ j, (x h j : ℝ) • β j d) ∧ + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (A h) = 1 ∧ + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (K h) = 1 ∧ + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (U h) = 1 ∧ + ∀ d : Fin s, + coefficients (K h).log (Finsupp.single () (d.val + 1)) ∈ + (T.filtration.layer (d.val + 1) 2).baseChange ℝ ∧ + coefficients (U h).log (Finsupp.single () (d.val + 1)) ∈ + (fourPetalSpace (D.dependentFreeSpan d) + (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ) ∧ + ∃ Δ : Subgroup E.filtration.Group, Δ ≤ E.lattice ∧ + (Δ.subgroupOf E.lattice).Characteristic ∧ (Δ.subgroupOf E.lattice).Normal ∧ + (Δ.subgroupOf E.lattice).FiniteIndex ∧ (Δ.relIndex E.lattice : ℝ) ≤ Real.exp C ∧ + ∃ (l : ℕ) (hl : 0 < l) + (hin : scaledIntegerGrid l ⊆ bchSubgroupCoordinates E.basis Δ) + (hout : bchSubgroupCoordinates E.basis Δ ⊆ denominatorGrid l), + (T.withLattice Δ l hl hin hout).ComplexityLE C ∧ + ∃ V₁ : (E.withLattice Δ l hl hin hout).UnitVerticalObservable + ((T.withLattice Δ l hl hin hout).realSubgroup s (r + 1)) (Fin W.family.outputDim) C, + V₁.frequency = V.frequency ∧ + (∀ h : {h // h ∈ J}, Nonempty (NativeVectorCorrelation (s - 1) N C + (W.replacedRankResidual h.val (fun i z => V₁.observable i (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (fun _ => (z.val : ℤ)) (A h * K h * U h))))))) ∧ + ∃ M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S (r + 1)) s + (finrank ℚ (SubspaceFreeLift.Algebra S (r + 1))), + ∃ Tm : M.DegreeRankStructure (r + 1), + Tm.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree ∧ + Tm.ComplexityLE ((Qc + nativePairModelConstant s) ^ nativePairModelConstant s) ∧ + M.HasLowerRankOrbitFamily Tm (fun _ : Unit => 1) + (fun h (i : Fin W.family.outputDim × Fin W.family.outputDim) z => + V₁.observable i.1 (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) z (A h * K h * U h))) * + star (V₁.observable i.2 (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) z (A h))))) + (nativeLowerPairModelBudget s Qc) + +include F + +theorem CoefficientBases.has_correlated_affine_comparison + (hTfil : T.filtration = D.coefficientFreeFiltration) + (hfreq : V.frequency = B₀.freeFrequency D) + (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P') + (hf : ∀ x, ‖f x‖ ≤ 1) + (Hsource : Finset (ZMod N)) (hsource : Hsource.Nonempty) + (hsourceDense : Real.exp (-Q) * Fintype.card (ZMod N) ≤ (Hsource.card : ℝ)) + (hHsource : H' ⊆ Hsource) + (hcorr : ∀ h ∈ Hsource, Nonempty (NativeVectorCorrelation (s - 1) N Q + (W.replacedRankResidual h (fun i x => V.observable i (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) (fun _ => (x.val : ℤ)) (g h))))))) + (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hsplit : ∀ h, g h = ξ * v h) + (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ + (D.commonFreeSpan d).baseChange ℝ) + (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) + (hN : Real.exp (sharedFreeCorrelationBudget s hs P') ≤ (N : ℝ)) : + D.CorrelatedAffineComparison E T hbQ hT V g hg D' hs := by + exact B₀.exists_correlated_lower_factorization D E T hbQ hT F V g hg D' + hTfil hfreq hs hp' hP' hQP' hpp' hf Hsource hsource hsourceDense hHsource hcorr + ξ v hsplit hξ hv hN + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold VectorPolynomial +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +noncomputable def nativeSharedFreeRelationConstant (s : ℕ) (hs : 2 ≤ s) : ℕ := + (exists_native_shared_free_rank_relation s hs).choose + +theorem exists_native_correlated_comparison_budget (s : ℕ) (hs : 2 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + let Z := (p + nativeSharedFreeRelationConstant s hs) ^ nativeSharedFreeRelationConstant s hs + Z ≤ (p + C) ^ C ∧ ∀ A : ℝ, 0 ≤ A → A ≤ Z → + sharedFreeCorrelationBudget s hs Z ≤ (p + C) ^ C ∧ + Z + (Z + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + + sharedFreeCorrelationBudget s hs Z ≤ (p + C) ^ C ∧ + ((sharedFreeCorrelationBudget s hs Z + sharedFreeComparisonBasisBudget A Z + 2) + + nativePairModelConstant s) ^ nativePairModelConstant s ≤ (p + C) ^ C ∧ + nativeLowerPairModelBudget s + (sharedFreeCorrelationBudget s hs Z + sharedFreeComparisonBasisBudget A Z + 2) ≤ + (p + C) ^ C := by + let a := nativeSharedFreeRelationConstant s hs + obtain ⟨b, _, hbound⟩ := exists_sharedFreeCorrelationBudget_bound s hs + let Z₀ : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Z₀ + (Z₀ + Polynomial.C b) ^ b) + refine ⟨C, hC, ?_⟩ + intro p hp Z + have hZ : 0 ≤ Z := pow_nonneg (add_nonneg hp (Nat.cast_nonneg _)) _ + have hsum : Z + (Z + b) ^ b ≤ (p + C) ^ C := by + change (p + a) ^ a + ((p + a) ^ a + b) ^ b ≤ (p + C) ^ C + simpa [Z₀, Polynomial.eval₂_pow] using hbudget p hp + have hZC : Z ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (add_nonneg hZ (Nat.cast_nonneg b)) b)).trans hsum + have hbC : (Z + b) ^ b ≤ (p + C) ^ C := (le_add_of_nonneg_left hZ).trans hsum + refine ⟨hZC, ?_⟩ + intro A hA hAZ + obtain ⟨hmain, hpair, hlower⟩ := hbound A Z hA hAZ hZ + have hΛ : 0 ≤ (Z + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s := + pow_nonneg (add_nonneg hZ (Nat.cast_nonneg _)) _ + have hcorrCost : sharedFreeCorrelationBudget s hs Z ≤ (p + C) ^ C := + (le_add_of_nonneg_left hΛ).trans (hmain.trans hbC) + have htotal : Z + (Z + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + + sharedFreeCorrelationBudget s hs Z ≤ (p + C) ^ C := by + linarith only [hmain, hsum] + exact ⟨hcorrCost, htotal, hpair.trans hbC, hlower.trans hbC⟩ + +def NativeCorrelationStructure.HasCorrelatedAffineComparison + {s r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s (r + 1) N p f) (hs : 2 ≤ s) (C : ℕ) : Prop := + let Z := (p + nativeSharedFreeRelationConstant s hs) ^ nativeSharedFreeRelationConstant s hs + ∃ (A : ℝ) (hpA : p ≤ A), A ≤ Z ∧ + ∃ (out : Fin W.family.outputDim) (H : Finset (ZMod N)) (q P : ℝ), + H ⊆ W.shifts ∧ H.Nonempty ∧ CyclicShortShiftSet H ∧ p ≤ q ∧ q ≤ P ∧ P ≤ A ∧ + ∃ (R : NativeRankRelation W.family out H q q) (D : R.CommonData P) + (B : D.CoefficientBases A) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure (r + 1)) (hT : T.ComplexityLE A), + T.filtration = D.coefficientFreeFiltration ∧ IsCentralLieBasis E.basis ∧ + Nonempty (FreeCoordinateFrame E.basis A) ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 E.basis + ∃ V : E.UnitVerticalObservable (T.realSubgroup s (r + 1)) (Fin W.family.outputDim) A, + V.frequency = B.freeFrequency D ∧ + ∃ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hξ : E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 ξ = 1), + (∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ + (D.commonFreeSpan d).baseChange ℝ) ∧ + ∃ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hv : ∀ h, E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) 0 (v h) = 1), + (∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) ∧ + (let U := W.replacementFamily E T hpA hT V (fun h => ξ * v h) + (fun h => by rw [map_mul, hξ, hv h, one_mul]) + ∃ (out' : Fin U.outputDim) (H' : Finset (ZMod N)) (q' : ℝ), + H' ⊆ W.shifts ∧ H'.Nonempty ∧ CyclicShortShiftSet H' ∧ + Real.exp (-Z) * Fintype.card (ZMod N) ≤ (H'.card : ℝ) ∧ + A ≤ q' ∧ q' ≤ Z ∧ + ∃ (R' : NativeRankRelation U out' H' q' q') (D' : R'.CommonData Z), + D.CorrelatedAffineComparison E T hpA hT V (fun h => ξ * v h) + (fun h => by rw [map_mul, hξ, hv h, one_mul]) D' hs ∧ + Z + (Z + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + + sharedFreeCorrelationBudget s hs Z ≤ (p + C) ^ C ∧ + ((sharedFreeCorrelationBudget s hs Z + sharedFreeComparisonBasisBudget A Z + 2) + + nativePairModelConstant s) ^ nativePairModelConstant s ≤ (p + C) ^ C ∧ + nativeLowerPairModelBudget s + (sharedFreeCorrelationBudget s hs Z + sharedFreeComparisonBasisBudget A Z + 2) ≤ + (p + C) ^ C)) + +theorem exists_native_correlated_affine_comparison (s : ℕ) (hs : 2 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s (r + 1) N p f), (∀ x, ‖f x‖ ≤ 1) → + Real.exp ((p + C) ^ C) ≤ (N : ℝ) → W.HasCorrelatedAffineComparison hs C := by + obtain ⟨C, hC, hbudget⟩ := exists_native_correlated_comparison_budget s hs + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf hN + unfold NativeCorrelationStructure.HasCorrelatedAffineComparison + intro Z + have hp : 0 ≤ p := (Nat.cast_nonneg _).trans W.family.complexity.1.1 + obtain ⟨hZC, hcost⟩ := hbudget p hp + have hZ : 0 ≤ Z := pow_nonneg (add_nonneg hp (Nat.cast_nonneg _)) _ + obtain ⟨A, hpA, hAZ, out, H, q, P, hHW, hH, hshort, hpq, hqP, hPA, + R, D, B, E, T, hT, hTfil, hcentral, hframe, hdata⟩ := + (exists_native_shared_free_rank_relation s hs).choose_spec.2 W hf + ((Real.exp_le_exp.mpr hZC).trans hN) + let := moduleTopology ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 E.basis + obtain ⟨V, hfreq, ξ, hξ, hcommon, Hsource, _, hsourceW, hsource, _, hsourceDense, + v, hv, hdep, hcorr, hnext⟩ := hdata + obtain ⟨out', H', q', hsub, hH', hshort', hdense, hAq', hq'Z, R', ⟨D'⟩⟩ := hnext + obtain ⟨F⟩ := hframe + have hA : 0 ≤ A := hp.trans hpA + obtain ⟨hcorrCost, htotal, hpair, hlower⟩ := hcost A hA hAZ + have hmodel := B.has_correlated_affine_comparison D E T hpA hT F V (fun h => ξ * v h) + (fun h => by rw [map_mul, hξ, hv h, one_mul]) D' + hTfil hfreq hs (hA.trans hAq') hZ hAZ hq'Z hf + Hsource hsource hsourceDense hsub hcorr ξ v (fun _ => rfl) hcommon hdep + ((Real.exp_le_exp.mpr hcorrCost).trans hN) + refine ⟨A, hpA, hAZ, out, H, q, P, hHW, hH, hshort, hpq, hqP, hPA, + R, D, B, E, T, hT, hTfil, hcentral, ⟨F⟩, V, hfreq, ξ, hξ, hcommon, + v, hv, hdep, out', H', q', (fun h hh => hsourceW (hsub hh)), hH', hshort', + hdense, hAq', hq'Z, R', D', hmodel, htotal, hpair, hlower⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeFrozenAffineExpansion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeFrozenAffineExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..0df7d18f704a6e7bfc32f098d0b6cdda914e74f9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeFrozenAffineExpansion.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeTwoVariableSplitFreezing + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open Module +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + +theorem exists_frozen_affine_expansion {σ : Type*} [Fintype σ] [DecidableEq σ] + (bound : σ → ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ} (W : NativeMultidegreeNilcharacter bound p) + (S : Finset σ) (A b : σ → ℤ) (k : Fin W.outputDim), + (∀ i, i ∉ S → A i = 0) → + ∃ E : NativeIntegerExpansion (fun _ : Unit => 1) (∑ i ∈ S, bound i) ((p + C) ^ C) + (fun x => W.eval k (fun i => b i + A i * x ())), E.count = 1 := by + obtain ⟨C, hC, hfreeze⟩ := exists_freezing_niltest bound + refine ⟨C, hC, ?_⟩ + intro p W S A b k hA + classical + obtain ⟨t, n, ht, _, D, hD⟩ := hfreeze W S b k + subst t + let K := W.multi.filtration.weightedSubalgebra (retainedCoordinateWeight S) + let := moduleTopology ℝ (ℝ ⊗[ℚ] K) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] K) := IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] K) := realification_moduleTopology_t2 D.basis + obtain ⟨T, _, hT, _, heval⟩ := hD + let U := T.affinePullback (fun i (_ : Unit) => A i.val) (fun i => b i.val) + have hU : U.ComplexityLE ((p + C) ^ C) := hT + have hval (x : Unit → ℤ) : U.eval x = W.eval k (fun i => b i + A i * x ()) := by + rw [RationalFilteredNilmanifold.Niltest.eval_affinePullback, heval] + congr 1 + funext i + by_cases hi : i ∈ S + · simp [freezeCoordinates, hi, integerAffineMap] + · simp [freezeCoordinates, hi, hA i hi] + exact ⟨NativeIntegerExpansion.ofTest U hU (fun x => (hval x).symm), rfl⟩ + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerAffinePullbackHom.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerAffinePullbackHom.lean new file mode 100644 index 0000000000000000000000000000000000000000..06f02a3c379b3b452008f9a6649ef59de49d8c35 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerAffinePullbackHom.lean @@ -0,0 +1,660 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeEquivalenceTransitivity +import OAI.Combinatorics.Progressions.Nilpotent.NiltestAffineProjection + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +structure NativeIntegerModelFamily {σ I : Type*} (w : σ → ℕ) + (degree : ℕ) (p : ℝ) (f : I → (σ → ℤ) → ℂ) where + L : Type + [lie : LieRing L] + [algebra : LieAlgebra ℚ L] + dim : ℕ + [topology : TopologicalSpace (ℝ ⊗[ℚ] L)] + [topologicalAdd : IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [continuousSMul : ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + [hausdorff : T2Space (ℝ ⊗[ℚ] L)] + model : RationalFilteredNilmanifold L degree dim + test : I → model.Niltest w + norm : ∀ i, (test i).normBound ≤ 1 + complexity : ∀ i, (test i).ComplexityLE p + normalized : ∀ i, model.filtration.realification.polynomialOrbitEval w 0 (test i).orbit = 1 + eval : ∀ i x, (test i).eval x = f i x + +attribute [local instance] NativeIntegerModelFamily.lie NativeIntegerModelFamily.algebra + NativeIntegerModelFamily.topology NativeIntegerModelFamily.topologicalAdd + NativeIntegerModelFamily.continuousSMul NativeIntegerModelFamily.hausdorff + +namespace NativeIntegerModelFamily + +variable {σ I : Type*} {w : σ → ℕ} {s : ℕ} {p q : ℝ} {f : I → (σ → ℤ) → ℂ} + +noncomputable def mono (R : NativeIntegerModelFamily w s p f) (hpq : p ≤ q) : + NativeIntegerModelFamily w s q f := + { R with complexity := fun i => (R.complexity i).mono hpq } + +@[simp] theorem mono_dim (R : NativeIntegerModelFamily w s p f) (hpq : p ≤ q) : + (R.mono hpq).dim = R.dim := rfl + +end NativeIntegerModelFamily + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +structure NativeIntegerExpansion {σ : Type*} (w : σ → ℕ) + (s : ℕ) (p : ℝ) (f : (σ → ℤ) → ℂ) where + count : ℕ + count_bound : (count : ℝ) ≤ Real.exp p + L : Fin count → Type + [lie : ∀ i, LieRing (L i)] + [algebra : ∀ i, LieAlgebra ℚ (L i)] + dim : Fin count → ℕ + [topology : ∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] + [topologicalAdd : ∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [continuousSMul : ∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] + [hausdorff : ∀ i, T2Space (ℝ ⊗[ℚ] L i)] + model : ∀ i, RationalFilteredNilmanifold (L i) s (dim i) + test : ∀ i, (model i).Niltest w + complexity : ∀ i, (test i).ComplexityLE p + coefficient : Fin count → ℂ + cost : (∑ i, ‖coefficient i‖) ≤ Real.exp p + eval : ∀ x, f x = ∑ i, coefficient i * (test i).eval x + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + NativeIntegerModelFamily.lie NativeIntegerModelFamily.algebra + NativeIntegerModelFamily.topology NativeIntegerModelFamily.topologicalAdd + NativeIntegerModelFamily.continuousSMul NativeIntegerModelFamily.hausdorff + +namespace NativeIntegerExpansion + +variable {σ : Type*} {w : σ → ℕ} {s : ℕ} {p q : ℝ} {f : (σ → ℤ) → ℂ} + +noncomputable def mono (E : NativeIntegerExpansion w s p f) (hpq : p ≤ q) : + NativeIntegerExpansion w s q f := + { E with + count_bound := E.count_bound.trans (Real.exp_le_exp.mpr hpq) + complexity := fun i => (E.complexity i).mono hpq + cost := E.cost.trans (Real.exp_le_exp.mpr hpq) } + +noncomputable def conjugate (E : NativeIntegerExpansion w s p f) : + NativeIntegerExpansion w s p (fun x => star (f x)) := + { E with + test := fun i => (E.test i).conjugate + complexity := E.complexity + coefficient := fun i => star (E.coefficient i) + cost := by simpa only [norm_star] using E.cost + eval := by + intro x + have h := congrArg star (E.eval x) + simpa only [star_sum, star_mul, mul_comm, + RationalFilteredNilmanifold.Niltest.eval_conjugate] using h } + +noncomputable def ofTest {L : Type} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} {D : RationalFilteredNilmanifold L s d} + (T : D.Niltest w) (hT : T.ComplexityLE p) (hf : ∀ x, f x = T.eval x) : + NativeIntegerExpansion w s p f := by + have hp : 0 ≤ p := (Nat.cast_nonneg d).trans hT.1.1 + exact { + count := 1 + count_bound := by simpa only [Nat.cast_one] using Real.one_le_exp hp + L := fun _ => L + dim := fun _ => d + model := fun _ => D + test := fun _ => T + complexity := fun _ => hT + coefficient := fun _ => 1 + cost := by simpa using Real.one_le_exp hp + eval := fun x => by simpa using hf x } + +noncomputable def ofModelFamily {I : Type*} {g : I → (σ → ℤ) → ℂ} + (R : NativeIntegerModelFamily w s p g) (i : I) : + NativeIntegerExpansion w s p (g i) := + ofTest (R.test i) (R.complexity i) (fun x => (R.eval i x).symm) + +end NativeIntegerExpansion + +end Erdos3 + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped BigOperators TensorProduct + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem select_sample_correlation {σ X : Type*} {w : σ → ℕ} {s : ℕ} {p q : ℝ} + {eta : (σ → ℤ) → ℂ} (E : NativeIntegerExpansion w s p eta) + (S : Finset X) (sample : X → σ → ℤ) (f : X → ℂ) + (hcorr : Real.exp (-q) ≤ ‖𝔼 u ∈ S, f u * star (eta (sample u))‖) : + ∃ i : Fin E.count, Real.exp (-(q + p)) ≤ + ‖𝔼 u ∈ S, f u * star ((E.test i).eval (sample u))‖ := by + have hpoint (u : X) : f u * star (eta (sample u)) = + ∑ i, star (E.coefficient i) * (f u * star ((E.test i).eval (sample u))) := by + rw [E.eval, star_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + rw [star_mul] + ring + have hmean : (𝔼 u ∈ S, f u * star (eta (sample u))) = + ∑ i, star (E.coefficient i) * (𝔼 u ∈ S, f u * star ((E.test i).eval (sample u))) := by + calc + _ = 𝔼 u ∈ S, ∑ i, star (E.coefficient i) * + (f u * star ((E.test i).eval (sample u))) := Finset.expect_congr rfl (fun u _ => hpoint u) + _ = _ := by simp_rw [Finset.expect_sum_comm, ← Finset.mul_expect] + obtain ⟨i, hi⟩ := exists_large_weighted_term (fun i => star (E.coefficient i)) + (fun i => 𝔼 u ∈ S, f u * star ((E.test i).eval (sample u))) + (Real.exp_pos (-q)) (Real.exp_pos p) (by simpa only [norm_star] using E.cost) + (by rwa [← hmean]) + refine ⟨i, ?_⟩ + have heq : Real.exp (-q) / Real.exp p = Real.exp (-(q + p)) := by + rw [← Real.exp_sub] + congr 1 + ring + rwa [heq] at hi + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped BigOperators + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem norm_eval_le {σ : Type*} {w : σ → ℕ} {s : ℕ} {p : ℝ} {f : (σ → ℤ) → ℂ} + (E : NativeIntegerExpansion w s p f) (x : σ → ℤ) : ‖f x‖ ≤ Real.exp (2 * p) := by + rw [E.eval x] + calc + ‖∑ i, E.coefficient i * (E.test i).eval x‖ ≤ + ∑ i, ‖E.coefficient i * (E.test i).eval x‖ := norm_sum_le _ _ + _ ≤ ∑ i, ‖E.coefficient i‖ * Real.exp p := by + apply Finset.sum_le_sum + intro i _ + rw [norm_mul] + exact mul_le_mul_of_nonneg_left ((E.test i).eval_budget (E.complexity i) x) (norm_nonneg _) + _ = (∑ i, ‖E.coefficient i‖) * Real.exp p := (Finset.sum_mul _ _ _).symm + _ ≤ Real.exp p * Real.exp p := mul_le_mul_of_nonneg_right E.cost (Real.exp_nonneg _) + _ = Real.exp (2 * p) := by rw [← Real.exp_add, two_mul] + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +noncomputable def ofFamily {I : Type*} [Fintype I] {L : I → Type} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {σ : Type*} {w : σ → ℕ} {s : ℕ} {d : I → ℕ} + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (T : ∀ i, (D i).Niltest w) (c : I → ℂ) + {p : ℝ} {f : (σ → ℤ) → ℂ} (hcard : (Fintype.card I : ℝ) ≤ Real.exp p) + (hT : ∀ i, (T i).ComplexityLE p) (hc : (∑ i, ‖c i‖) ≤ Real.exp p) + (hf : ∀ x, f x = ∑ i, c i * (T i).eval x) : + NativeIntegerExpansion w s p f := by + let e := (Fintype.equivFin I).symm + exact { + count := Fintype.card I + count_bound := hcard + L := fun i => L (e i) + dim := fun i => d (e i) + model := fun i => D (e i) + test := fun i => T (e i) + complexity := fun i => hT (e i) + coefficient := fun i => c (e i) + cost := (e.sum_comp (fun i => ‖c i‖)).le.trans hc + eval := fun x => (hf x).trans (e.sum_comp + (fun i => c i * (T i).eval x)).symm + } + +noncomputable def weightedSum {I : Type*} [Fintype I] {σ : Type*} {w : σ → ℕ} {s : ℕ} + {p q : ℝ} {f : I → (σ → ℤ) → ℂ} (E : ∀ i, NativeIntegerExpansion w s p (f i)) + (c : I → ℂ) (hq : 0 ≤ q) (hcard : (Fintype.card I : ℝ) ≤ Real.exp q) + (hc : (∑ i, ‖c i‖) ≤ Real.exp q) : + NativeIntegerExpansion w s (p + q) (fun x => ∑ i, c i * f i x) := by + classical + let A := Σ i, Fin (E i).count + refine ofFamily (I := A) (fun a => (E a.1).model a.2) + (fun a => (E a.1).test a.2) (fun a => c a.1 * (E a.1).coefficient a.2) ?_ + (fun a => ((E a.1).complexity a.2).mono (by linarith)) ?_ ?_ + · change (Fintype.card (Σ i, Fin (E i).count) : ℝ) ≤ _ + rw [Fintype.card_sigma, Nat.cast_sum] + calc + _ ≤ ∑ _ : I, Real.exp p := Finset.sum_le_sum (fun i _ => by + simpa only [Fintype.card_fin] using (E i).count_bound) + _ = (Fintype.card I : ℝ) * Real.exp p := by simp + _ ≤ Real.exp q * Real.exp p := mul_le_mul_of_nonneg_right hcard (Real.exp_nonneg _) + _ = Real.exp (p + q) := by rw [← Real.exp_add, add_comm] + · exact (sum_pair_coefficient_norms_le c (fun i => (E i).coefficient) + (Real.exp_nonneg p) hc (fun i => (E i).cost)).trans_eq + (by rw [← Real.exp_add, add_comm]) + · intro x + change (∑ i, c i * f i x) = ∑ a : Sigma (fun i => Fin (E i).count), _ + rw [Fintype.sum_sigma] + apply Finset.sum_congr rfl + intro i _ + rw [(E i).eval x, Finset.mul_sum] + simp only [mul_assoc] + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped TensorProduct + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +noncomputable def affinePullback {σ τ : Type*} [Fintype τ] {s : ℕ} {p : ℝ} + {f : (σ → ℤ) → ℂ} (E : NativeIntegerExpansion (fun _ : σ => 1) s p f) + (A : σ → τ → ℤ) (b : σ → ℤ) : + NativeIntegerExpansion (fun _ : τ => 1) s p (fun x => f (integerAffineMap A b x)) := + { E with + test := fun i => (E.test i).affinePullback A b + complexity := E.complexity + eval := fun x => by + simpa only [RationalFilteredNilmanifold.Niltest.eval_affinePullback] using + E.eval (integerAffineMap A b x) } + +noncomputable def toCyclic {s : ℕ} {p : ℝ} {f : (Unit → ℤ) → ℂ} + (E : NativeIntegerExpansion (fun _ : Unit => 1) s p f) (N : ℕ) [NeZero N] : + NativeNilsequenceExpansion s N p (fun x => f (fun _ => (x.val : ℤ))) where + count := E.count + count_bound := E.count_bound + L := E.L + dim := E.dim + model := E.model + test := E.test + complexity := E.complexity + coefficient := E.coefficient + cost := E.cost + eval x := E.eval (fun _ => (x.val : ℤ)) + +noncomputable def cyclicAffinePullback {σ : Type*} {s : ℕ} {p : ℝ} + {f : (σ → ℤ) → ℂ} (E : NativeIntegerExpansion (fun _ : σ => 1) s p f) + (A : σ → Unit → ℤ) (b : σ → ℤ) (N : ℕ) [NeZero N] : + NativeNilsequenceExpansion s N p + (fun x => f (integerAffineMap A b (fun _ => (x.val : ℤ)))) := + (E.affinePullback A b).toCyclic N + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped BigOperators + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +noncomputable def scaleNormLeOne {σ : Type*} {w : σ → ℕ} {s : ℕ} {p : ℝ} + {f : (σ → ℤ) → ℂ} (E : NativeIntegerExpansion w s p f) + (c : ℂ) (hc : ‖c‖ ≤ 1) : + NativeIntegerExpansion w s p (fun x => c * f x) := + { E with + coefficient := fun i => c * E.coefficient i + cost := by + simp only [norm_mul, ← Finset.mul_sum] + exact (mul_le_of_le_one_left (Finset.sum_nonneg (fun _ _ => norm_nonneg _)) hc).trans E.cost + eval := by + intro x + rw [E.eval, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + exact (mul_assoc _ _ _).symm } + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {σ τ : Type*} {w : σ → ℕ} {v : τ → ℕ} {s : ℕ} {p : ℝ} + {f : (σ → ℤ) → ℂ} + +noncomputable def substitutedValue (E : NativeIntegerExpansion w s p f) + (P : σ → MvPolynomial τ ℚ) (hP : ∀ i, P i ∈ weightedSupportLE v (w i)) + (x : τ → ℤ) : ℂ := + ∑ i, E.coefficient i * ((E.test i).substitute P hP).eval x + +noncomputable def substituteExpansion (E : NativeIntegerExpansion w s p f) + (P : σ → MvPolynomial τ ℚ) (hP : ∀ i, P i ∈ weightedSupportLE v (w i)) : + NativeIntegerExpansion v s p (E.substitutedValue P hP) := + { E with + test := fun i => (E.test i).substitute P hP + complexity := E.complexity + eval := fun _ => rfl } + +theorem substitutedValue_eq (E : NativeIntegerExpansion w s p f) + (P : σ → MvPolynomial τ ℚ) (hP : ∀ i, P i ∈ weightedSupportLE v (w i)) + (x : τ → ℤ) (y : σ → ℤ) + (hxy : ∀ i, MvPolynomial.aeval (R := ℚ) (fun j => (x j : ℚ)) (P i) = (y i : ℚ)) : + E.substitutedValue P hP x = f y := by + rw [E.eval y] + unfold substitutedValue + apply Finset.sum_congr rfl + intro i _ + rw [RationalFilteredNilmanifold.Niltest.eval_substitute _ _ _ x y hxy] + +end Erdos3.NativeIntegerExpansion + +namespace Erdos3 + +noncomputable def halvingPolynomial {σ : Type*} (r : σ → ℤ) (i : σ) : MvPolynomial σ ℚ := + MvPolynomial.C (1 / 2 : ℚ) * (MvPolynomial.X i - MvPolynomial.C (r i : ℚ)) + +theorem halvingPolynomial_support {σ : Type*} (r : σ → ℤ) (i : σ) : + halvingPolynomial r i ∈ weightedSupportLE (fun _ : σ => 1) 1 := by + have hx : (MvPolynomial.X i : MvPolynomial σ ℚ) ∈ weightedSupportLE (fun _ : σ => 1) 1 := by + simpa only [MvPolynomial.X, Finsupp.weight_single, smul_eq_mul, mul_one] using + weightedSupportLE_monomial (fun _ : σ => 1) (Finsupp.single i 1) (1 : ℚ) + simpa only [halvingPolynomial, zero_add] using + weightedSupportLE_mul (weightedSupportLE_C (fun _ : σ => 1) 0 (1 / 2 : ℚ)) + (Submodule.sub_mem _ hx (weightedSupportLE_C _ 1 (r i : ℚ))) + +theorem halvingPolynomial_eval {σ : Type*} (r x : σ → ℤ) + (hr : ∀ i, x i % 2 = r i) (i : σ) : + MvPolynomial.aeval (R := ℚ) (fun j => (x j : ℚ)) (halvingPolynomial r i) = + ((x i / 2 : ℤ) : ℚ) := by + have hi : x i = 2 * (x i / 2) + r i := by + have h := hr i + omega + have hiq : (x i : ℚ) = 2 * ((x i / 2 : ℤ) : ℚ) + (r i : ℚ) := by exact_mod_cast hi + simp only [halvingPolynomial, map_mul, map_sub, MvPolynomial.aeval_C, MvPolynomial.aeval_X] + change (1 / 2 : ℚ) * ((x i : ℚ) - (r i : ℚ)) = ((x i / 2 : ℤ) : ℚ) + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +structure NativeIntegerVectorEquivalence {σ J K : Type*} [Fintype J] [Fintype K] + (s : ℕ) (p : ℝ) (chi : J → (σ → ℤ) → ℂ) (eta : K → (σ → ℤ) → ℂ) : Prop where + left_dimension : (Fintype.card J : ℝ) ≤ Real.exp p + right_dimension : (Fintype.card K : ℝ) ≤ Real.exp p + expansion : ∀ j k, Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s p + (fun x => chi j x * star (eta k x))) + +namespace NativeIntegerVectorEquivalence + +variable {σ J K : Type*} [Fintype J] [Fintype K] {s : ℕ} {p q : ℝ} + {chi : J → (σ → ℤ) → ℂ} {eta : K → (σ → ℤ) → ℂ} + +theorem mono (E : NativeIntegerVectorEquivalence s p chi eta) (hpq : p ≤ q) : + NativeIntegerVectorEquivalence s q chi eta where + left_dimension := E.left_dimension.trans (Real.exp_le_exp.mpr hpq) + right_dimension := E.right_dimension.trans (Real.exp_le_exp.mpr hpq) + expansion j k := by + obtain ⟨R⟩ := E.expansion j k + exact ⟨R.mono hpq⟩ + +theorem symm (E : NativeIntegerVectorEquivalence s p chi eta) : + NativeIntegerVectorEquivalence s p eta chi where + left_dimension := E.right_dimension + right_dimension := E.left_dimension + expansion k j := by + obtain ⟨R⟩ := E.expansion j k + have h : Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s p + (fun x => star (chi j x * star (eta k x)))) := ⟨R.conjugate⟩ + simpa only [star_mul, star_star, mul_comm] using h + +theorem conjugate (E : NativeIntegerVectorEquivalence s p chi eta) : + NativeIntegerVectorEquivalence s p (fun j x => star (chi j x)) + (fun k x => star (eta k x)) where + left_dimension := E.left_dimension + right_dimension := E.right_dimension + expansion j k := by + obtain ⟨R⟩ := E.expansion j k + have h : Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s p + (fun x => star (chi j x * star (eta k x)))) := ⟨R.conjugate⟩ + simpa only [star_mul, star_star, mul_comm] using h + +theorem affinePullback {τ : Type*} [Fintype τ] + (E : NativeIntegerVectorEquivalence s p chi eta) (A : σ → τ → ℤ) (b : σ → ℤ) : + NativeIntegerVectorEquivalence s p + (fun j x => chi j (integerAffineMap A b x)) (fun k x => eta k (integerAffineMap A b x)) where + left_dimension := E.left_dimension + right_dimension := E.right_dimension + expansion j k := by + obtain ⟨R⟩ := E.expansion j k + exact ⟨R.affinePullback A b⟩ + +theorem cyclicAffinePullback (E : NativeIntegerVectorEquivalence s p chi eta) + (A : σ → Unit → ℤ) (b : σ → ℤ) (N : ℕ) [NeZero N] : + NativeVectorEquivalence s N p + (fun j x => chi j (integerAffineMap A b (fun _ => (x.val : ℤ)))) + (fun k x => eta k (integerAffineMap A b (fun _ => (x.val : ℤ)))) where + left_dimension := E.left_dimension + right_dimension := E.right_dimension + expansion j k := by + obtain ⟨R⟩ := E.expansion j k + exact ⟨R.cyclicAffinePullback A b N⟩ + +end NativeIntegerVectorEquivalence + +end Erdos3 + +end + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {σ J K : Type*} [Fintype J] [Fintype K] {s : ℕ} {p : ℝ} + {chi : J → (σ → ℤ) → ℂ} {eta : K → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p chi eta) + +noncomputable def selectedExpansion (j : J) (k : K) : + NativeIntegerExpansion (fun _ : σ => 1) s p + (fun x => chi j x * star (eta k x)) := + Classical.choice (E.expansion j k) + +theorem transfer_sample_correlation {X : Type*} (S : Finset X) (x : X → σ → ℤ) + (j : J) (f : X → ℂ) {q : ℝ} + (hunit : ∀ u ∈ S, ∑ k, ‖eta k (x u)‖ ^ 2 = 1) + (hcorr : Real.exp (-q) ≤ ‖𝔼 u ∈ S, f u * star (chi j (x u))‖) : + ∃ (k : K) (a : Fin (E.selectedExpansion j k).count), + Real.exp (-(q + 2 * p)) ≤ + ‖𝔼 u ∈ S, f u * star (eta k (x u)) * + star (((E.selectedExpansion j k).test a).eval (x u))‖ := by + classical + let R (k : K) := E.selectedExpansion j k + have hexp (k : K) (u : X) (_hu : u ∈ S) : + star (chi j (x u)) * star (star (eta k (x u))) = + ∑ a, star ((R k).coefficient a) * star (((R k).test a).eval (x u)) := by + have h := congrArg star ((R k).eval (x u)) + simpa only [star_sum, star_mul, star_star, mul_comm] using h + obtain ⟨k, a, hka⟩ := exists_unit_expansion_correlation S f + (fun u => star (chi j (x u))) (fun k u => star (eta k (x u))) + (fun k a => star ((R k).coefficient a)) + (fun k a u => star (((R k).test a).eval (x u))) + (fun u hu => by simpa only [norm_star] using hunit u hu) hexp + (Real.exp_pos (-q)) (Real.exp_pos p) (Real.exp_pos p) E.right_dimension + (fun k => by simpa only [norm_star] using (R k).cost) hcorr + have hfrac : Real.exp (-q) / (Real.exp p * Real.exp p) = + Real.exp (-(q + 2 * p)) := by + rw [← Real.exp_add, ← Real.exp_sub] + congr 1 + ring + rw [hfrac] at hka + exact ⟨k, a, hka⟩ + +end Erdos3.NativeIntegerVectorEquivalence + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +namespace NativeIntegerExpansion + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +noncomputable def linearPullbackHom {σ τ : Type*} [Fintype τ] {s : ℕ} {p : ℝ} + {f : (σ → ℤ) → ℂ} (E : NativeIntegerExpansion (fun _ : σ => 1) s p f) + (A : σ → ((τ → ℤ) →+ ℤ)) : + NativeIntegerExpansion (fun _ : τ => 1) s p (fun x => f (fun i => A i x)) := + { E with + test := fun i => (E.test i).linearPullbackHom A + complexity := E.complexity + eval := fun x => by + simpa only [RationalFilteredNilmanifold.Niltest.eval_linearPullbackHom] + using E.eval (fun i => A i x) } + +end NativeIntegerExpansion + +namespace NativeIntegerVectorEquivalence + +theorem linearPullbackHom {σ τ J K : Type*} [Fintype τ] [Fintype J] [Fintype K] + {s : ℕ} {p : ℝ} {f : J → (σ → ℤ) → ℂ} {g : K → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p f g) (A : σ → ((τ → ℤ) →+ ℤ)) : + NativeIntegerVectorEquivalence s p + (fun j x => f j (fun i => A i x)) (fun k x => g k (fun i => A i x)) where + left_dimension := E.left_dimension + right_dimension := E.right_dimension + expansion j k := by + obtain ⟨R⟩ := E.expansion j k + exact ⟨R.linearPullbackHom A⟩ + +theorem coordinatePullback {σ τ J K : Type*} [Fintype τ] [Fintype J] [Fintype K] + {s : ℕ} {p : ℝ} {f : J → (σ → ℤ) → ℂ} {g : K → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p f g) (a : σ → τ) : + NativeIntegerVectorEquivalence s p (fun j x => f j (fun i => x (a i))) + (fun k x => g k (fun i => x (a i))) := + E.linearPullbackHom (fun i => ⟨⟨fun x => x (a i), rfl⟩, fun _ _ => rfl⟩) + +end NativeIntegerVectorEquivalence + +end Erdos3 + +end + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +open scoped BigOperators + +theorem selectedChoice_card_bound {σ I J : Type*} [Fintype I] [Fintype J] + {s : ℕ} {p : ℝ} {f : I → (σ → ℤ) → ℂ} {g : J → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p f g) (i : I) : + (Fintype.card (Σ j : J, Fin (E.selectedExpansion i j).count) : ℝ) ≤ Real.exp (2 * p) := by + rw [Fintype.card_sigma, Nat.cast_sum] + calc + _ ≤ ∑ _j : J, Real.exp p := Finset.sum_le_sum (fun j _ => by + simpa only [Fintype.card_fin] using (E.selectedExpansion i j).count_bound) + _ = (Fintype.card J : ℝ) * Real.exp p := by simp + _ ≤ Real.exp p * Real.exp p := mul_le_mul_of_nonneg_right E.right_dimension (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, two_mul] + +theorem selectedChainedChoice_card_bound {σ I J K : Type*} [Fintype I] [Fintype J] [Fintype K] + {s : ℕ} {p q : ℝ} {f : I → (σ → ℤ) → ℂ} {g : J → (σ → ℤ) → ℂ} + {h : K → (σ → ℤ) → ℂ} (E : NativeIntegerVectorEquivalence s p f g) + (F : NativeIntegerVectorEquivalence s q g h) (i : I) : + (Fintype.card (Σ j : J, Fin (E.selectedExpansion i j).count × + (Σ k : K, Fin (F.selectedExpansion j k).count)) : ℝ) ≤ Real.exp (2 * p + 2 * q) := by + rw [Fintype.card_sigma, Nat.cast_sum] + calc + _ ≤ ∑ _j : J, Real.exp p * Real.exp (2 * q) := by + apply Finset.sum_le_sum + intro j _ + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul] + exact mul_le_mul (E.selectedExpansion i j).count_bound (F.selectedChoice_card_bound j) + (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = (Fintype.card J : ℝ) * (Real.exp p * Real.exp (2 * q)) := by simp + _ ≤ Real.exp p * (Real.exp p * Real.exp (2 * q)) := + mul_le_mul_of_nonneg_right E.right_dimension (by positivity) + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + +end Erdos3.NativeIntegerVectorEquivalence + +end + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +theorem affinePullbackHom {σ τ J K : Type*} [Fintype τ] [Fintype J] [Fintype K] + {s : ℕ} {p : ℝ} {f : J → (σ → ℤ) → ℂ} {g : K → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p f g) (A : σ → ((τ → ℤ) →+ ℤ)) (b : σ → ℤ) : + NativeIntegerVectorEquivalence s p + (fun j x => f j (fun i => b i + A i x)) + (fun k x => g k (fun i => b i + A i x)) := by + classical + have hinput (x : τ → ℤ) : + integerAffineMap (fun i j => A i (Pi.single j 1)) b x = fun i => b i + A i x := by + funext i + rw [integerAffineMap, ← integerLinearForm_eq_sum] + simpa only [hinput] using E.affinePullback (fun i j => A i (Pi.single j 1)) b + +end Erdos3.NativeIntegerVectorEquivalence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerBoxInverse.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerBoxInverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..8923139e85c3a2a9acf065b59d363da03317d813 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerBoxInverse.lean @@ -0,0 +1,61 @@ +import OAI.Combinatorics.Progressions.Estimates.AxisCompression +import OAI.Combinatorics.Progressions.Geometry.BoxCyclicEncoding + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +attribute [local instance] NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +theorem exists_native_integer_box_inverse (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {n : ℕ} (T : Fin n → ℕ) [∀ i, NeZero (T i)] + {p : ℝ}, 2 ≤ p → ∀ f : (Fin n → ℤ) → ℂ, + (∀ x ∈ integerBox T, ‖f x‖ ≤ 1) → Real.exp (-p) ≤ integerBoxGowersNorm T (s + 1) f → + ∃ V : NativeSampleCorrelation (fun _ : Fin n => 1) s ((p + n + C) ^ C) (integerBox T) id f, + V.test.normBound ≤ 1 := by + obtain ⟨A, _, htransfer⟩ := exists_native_inverse_on_cyclic_encoding s hs + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((4 * X + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro n T _ p hp f hf hGowers + have hp0 : 0 ≤ p := by linarith + have hcost : (p + 4 * (n : ℝ) + A) ^ A ≤ (p + n + C) ^ C := by + apply (pow_le_pow_left₀ (by positivity) + (show p + 4 * (n : ℝ) + A ≤ 4 * (p + n) + A by linarith) A).trans + simpa [X, Polynomial.eval₂_pow] using hbudget (p + n) (by positivity) + obtain ⟨V, hV⟩ := htransfer (integerBox T) (integerBox_nonempty T) (boxIntegerCode T) + (boxCyclicCode_reflectsPairSums T) (fun x hx => boxIntegerCode_bounds T x hx) + hp (by positivity : (0 : ℝ) ≤ 4 * n) (boxCode_density_lower T) f hf hGowers + exact ⟨V.mono hcost, hV⟩ + +theorem exists_native_integer_box_inverse_bounded_dimension (s : ℕ) (hs : 1 ≤ s) (D : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {n : ℕ} (T : Fin n → ℕ) [∀ i, NeZero (T i)] + {p : ℝ}, 2 ≤ p → (n : ℝ) ≤ (p + D) ^ D → ∀ f : (Fin n → ℤ) → ℂ, + (∀ x ∈ integerBox T, ‖f x‖ ≤ 1) → Real.exp (-p) ≤ integerBoxGowersNorm T (s + 1) f → + ∃ V : NativeSampleCorrelation (fun _ : Fin n => 1) s ((p + C) ^ C) (integerBox T) id f, + V.test.normBound ≤ 1 := by + obtain ⟨A, _, hinverse⟩ := exists_native_integer_box_inverse s hs + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + (X + Polynomial.C D) ^ D + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro n T _ p hp hn f hf hGowers + have hp0 : 0 ≤ p := by linarith + have hcost : (p + n + A) ^ A ≤ (p + C) ^ C := by + apply (pow_le_pow_left₀ (by positivity) + (show p + (n : ℝ) + A ≤ p + (p + D) ^ D + A by linarith) A).trans + simpa [X, Polynomial.eval₂_pow] using hbudget p hp0 + obtain ⟨V, hV⟩ := hinverse T hp f hf hGowers + exact ⟨V.mono hcost, hV⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerDivision.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerDivision.lean new file mode 100644 index 0000000000000000000000000000000000000000..47a06572fc3be7984869d9a8245a29d293a079be --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerDivision.lean @@ -0,0 +1,142 @@ +import OAI.Combinatorics.Progressions.Polynomial.PositiveDegreeCyclicDifference + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def divisionPolynomial {σ : Type*} (d : ℕ) (r : σ → ℤ) (i : σ) : MvPolynomial σ ℚ := + MvPolynomial.C (d : ℚ)⁻¹ * (MvPolynomial.X i - MvPolynomial.C (r i : ℚ)) + +theorem divisionPolynomial_support {σ : Type*} (d : ℕ) (r : σ → ℤ) (i : σ) : + divisionPolynomial d r i ∈ weightedSupportLE (fun _ : σ => 1) 1 := by + have hx : (MvPolynomial.X i : MvPolynomial σ ℚ) ∈ weightedSupportLE (fun _ : σ => 1) 1 := by + simpa only [MvPolynomial.X, Finsupp.weight_single, smul_eq_mul, mul_one] using + weightedSupportLE_monomial (fun _ : σ => 1) (Finsupp.single i 1) (1 : ℚ) + simpa only [divisionPolynomial, zero_add] using + weightedSupportLE_mul (weightedSupportLE_C (fun _ : σ => 1) 0 (d : ℚ)⁻¹) + (Submodule.sub_mem _ hx (weightedSupportLE_C _ 1 (r i : ℚ))) + +theorem divisionPolynomial_eval {σ : Type*} (d : ℕ) [NeZero d] (r x : σ → ℤ) + (hr : ∀ i, x i % (d : ℤ) = r i) (i : σ) : + MvPolynomial.aeval (R := ℚ) (fun j => (x j : ℚ)) (divisionPolynomial d r i) = + ((x i / (d : ℤ) : ℤ) : ℚ) := by + have hi : x i = (d : ℤ) * (x i / (d : ℤ)) + r i := by + calc + _ = x i % (d : ℤ) + (d : ℤ) * (x i / (d : ℤ)) := (Int.emod_add_mul_ediv _ _).symm + _ = _ := by rw [hr i]; ring + have hiq : (x i : ℚ) = (d : ℚ) * ((x i / (d : ℤ) : ℤ) : ℚ) + (r i : ℚ) := by + exact_mod_cast hi + simp only [divisionPolynomial, map_mul, map_sub, MvPolynomial.aeval_C, MvPolynomial.aeval_X] + change (d : ℚ)⁻¹ * ((x i : ℚ) - (r i : ℚ)) = ((x i / (d : ℤ) : ℤ) : ℚ) + rw [hiq, add_sub_cancel_right, ← mul_assoc, inv_mul_cancel₀ (Nat.cast_ne_zero.mpr (NeZero.ne d)), one_mul] + +noncomputable def pairResidueIndicator {d : ℕ} (r : Fin 2 → ZMod d) (x : Fin 2 → ℤ) : ℂ := + if (fun i => (x i : ZMod d)) = r then 1 else 0 + +theorem pairResidueIndicator_product {d : ℕ} (r : Fin 2 → ZMod d) (x : Fin 2 → ℤ) : + pairResidueIndicator r x = + (if (x 0 : ZMod d) = r 0 then 1 else 0) * + (if (x 1 : ZMod d) = r 1 then 1 else 0) := by + classical + have heq : (fun i => (x i : ZMod d)) = r ↔ (x 0 : ZMod d) = r 0 ∧ (x 1 : ZMod d) = r 1 := by + constructor + · intro h + exact ⟨congrFun h 0, congrFun h 1⟩ + · rintro ⟨h0, h1⟩ + funext i + fin_cases i <;> assumption + unfold pairResidueIndicator + simp only [heq] + split_ifs <;> simp_all + +theorem exists_pairResidueIndicator_expansion (d s : ℕ) [NeZero d] (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ r : Fin 2 → ZMod d, + Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) s (C : ℝ) (pairResidueIndicator r)) := by + obtain ⟨A, _, hmul⟩ := NativeIntegerExpansion.exists_mul_budget + let D := d + 2 + (d + 4) ^ 2 + 3 + refine ⟨(D + A) ^ A + 2, by omega, ?_⟩ + intro r + have hd : (d : ℝ) ≤ Real.exp d := by linarith [Real.add_one_le_exp (d : ℝ)] + obtain ⟨E0⟩ := exists_coordinate_residue_expansion (σ := Fin 2) 0 (r 0) (Nat.cast_nonneg d) hd + obtain ⟨E1⟩ := exists_coordinate_residue_expansion (σ := Fin 2) 1 (r 1) (Nat.cast_nonneg d) hd + have hraise : raisedNiltestBudget ((d : ℝ) + 2) = (D : ℝ) := by + dsimp [D, raisedNiltestBudget] + push_cast + ring + have F0 : NativeIntegerExpansion (fun _ : Fin 2 => 1) s D + (fun x => if (x 0 : ZMod d) = r 0 then 1 else 0) := by + simpa only [hraise] using E0.raiseStep hs (by positivity) + have F1 : NativeIntegerExpansion (fun _ : Fin 2 => 1) s D + (fun x => if (x 1 : ZMod d) = r 1 then 1 else 0) := by + simpa only [hraise] using E1.raiseStep hs (by positivity) + obtain ⟨F⟩ := hmul (Nat.cast_nonneg D) F0 F1 + have hb : ((D : ℝ) + A) ^ A ≤ (((D + A) ^ A + 2 : ℕ) : ℝ) := by + push_cast + linarith + have heq : (fun x => (if (x 0 : ZMod d) = r 0 then (1 : ℂ) else 0) * + (if (x 1 : ZMod d) = r 1 then 1 else 0)) = pairResidueIndicator r := by + funext x + exact (pairResidueIndicator_product r x).symm + rw [heq] at F + exact ⟨F.mono hb⟩ + +theorem card_pairResidue_le_exp (d : ℕ) [NeZero d] : + (Fintype.card (Fin 2 → ZMod d) : ℝ) ≤ Real.exp ((d : ℝ) ^ 2) := by + simp only [Fintype.card_fun, ZMod.card, Fintype.card_fin, Nat.cast_pow] + linarith [Real.add_one_le_exp ((d : ℝ) ^ 2)] + +theorem NativeIntegerExpansion.exists_division_expansion (d s : ℕ) [NeZero d] (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ} {f : (Fin 2 → ℤ) → ℂ}, 0 ≤ p → + NativeIntegerExpansion (fun _ : Fin 2 => 1) s p f → + Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) s ((p + C) ^ C) + (fun x => f (fun i => x i / (d : ℤ)))) := by + obtain ⟨A, _, hresidue⟩ := exists_pairResidueIndicator_expansion d s hs + obtain ⟨B, _, hmul⟩ := NativeIntegerExpansion.exists_mul_budget + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A + 2 + Polynomial.C B) ^ B + Polynomial.C (d ^ 2)) + refine ⟨C, hC, ?_⟩ + intro p f hp E + classical + let t : ℝ := p + A + 2 + have ht : 0 ≤ t := by dsimp [t]; positivity + have hpt : p ≤ t := by dsimp [t]; have := Nat.cast_nonneg (α := ℝ) A; linarith + have hAt : (A : ℝ) ≤ t := by dsimp [t]; linarith + let P (r : Fin 2 → ZMod d) := divisionPolynomial d (fun i => ((r i).val : ℤ)) + have hP (r : Fin 2 → ZMod d) (i : Fin 2) : + P r i ∈ weightedSupportLE (fun _ : Fin 2 => 1) 1 := divisionPolynomial_support d _ i + let F (r : Fin 2 → ZMod d) := E.substitutedValue (P r) (hP r) + have hF (r : Fin 2 → ZMod d) : Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) s + ((t + B) ^ B) (fun x => pairResidueIndicator r x * F r x)) := + hmul ht ((Classical.choice (hresidue r)).mono hAt) + ((E.substituteExpansion (P r) (hP r)).mono hpt) + have hcost : (∑ _ : Fin 2 → ZMod d, ‖(1 : ℂ)‖) ≤ Real.exp ((d : ℝ) ^ 2) := by + simpa using card_pairResidue_le_exp d + let S := NativeIntegerExpansion.weightedSum (fun r => Classical.choice (hF r)) (fun _ => 1) + (sq_nonneg (d : ℝ)) (card_pairResidue_le_exp d) hcost + have heq : (fun x => ∑ r : Fin 2 → ZMod d, (1 : ℂ) * (pairResidueIndicator r x * F r x)) = + (fun x => f (fun i => x i / (d : ℤ))) := by + funext x + let r : Fin 2 → ZMod d := fun i => (x i : ZMod d) + rw [Finset.sum_eq_single r] + · simp only [pairResidueIndicator, r, ite_true, one_mul] + apply E.substitutedValue_eq (P r) (hP r) x (fun i => x i / (d : ℤ)) + exact divisionPolynomial_eval d _ x (fun i => (ZMod.val_intCast (x i)).symm) + · intro a _ ha + have hne : (fun i => (x i : ZMod d)) ≠ a := fun h => ha h.symm + simp only [pairResidueIndicator, hne, ite_false, zero_mul, mul_zero] + · simp + have hb : (t + B) ^ B + (d : ℝ) ^ 2 ≤ (p + C) ^ C := by + simpa [t, X, Polynomial.eval₂_pow] using hbudget p hp + rw [heq] at S + exact ⟨S.mono hb⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerEquivalenceFiniteFamily.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerEquivalenceFiniteFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..2604e563a415302fe40103333002fde12c8dc9ef --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerEquivalenceFiniteFamily.lean @@ -0,0 +1,105 @@ +import OAI.Combinatorics.Progressions.Lattices.NativeIntegerHalving + +namespace OAI + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +open scoped BigOperators + +theorem exists_fin_product_budget (n : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ I J : Type*} [Fintype I] [Fintype J] {s : ℕ} {p : ℝ} + (f : Fin n → I → (σ → ℤ) → ℂ) (g : Fin n → J → (σ → ℤ) → ℂ), + 0 ≤ p → (Fintype.card I : ℝ) ≤ Real.exp p → (Fintype.card J : ℝ) ≤ Real.exp p → + (∀ i, NativeIntegerVectorEquivalence s p (f i) (g i)) → + NativeIntegerVectorEquivalence s ((p + C) ^ C) + (fun a : Fin n → I => fun x => ∏ i, f i (a i) x) + (fun b : Fin n → J => fun x => ∏ i, g i (b i) x) := by + obtain ⟨A, _, hprod⟩ := NativeIntegerExpansion.exists_fin_prod_budget n + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A) ^ A + Polynomial.C n * X) + refine ⟨C, hC, ?_⟩ + intro σ I J _ _ s p f g hp hI hJ E + have hsum : (p + A) ^ A + n * p ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + have hcost : (p + A) ^ A ≤ (p + C) ^ C := by + have hn : 0 ≤ (n : ℝ) * p := mul_nonneg (Nat.cast_nonneg _) hp + linarith + have hnp : (n : ℝ) * p ≤ (p + C) ^ C := by + have ha : 0 ≤ (p + A) ^ A := by positivity + linarith + have hIn : (Fintype.card (Fin n → I) : ℝ) ≤ Real.exp ((p + C) ^ C) := by + simp only [Fintype.card_fun, Fintype.card_fin, Nat.cast_pow] + calc + _ ≤ (Real.exp p) ^ n := pow_le_pow_left₀ (Nat.cast_nonneg _) hI n + _ = Real.exp ((n : ℝ) * p) := (Real.exp_nat_mul p n).symm + _ ≤ _ := Real.exp_le_exp.mpr hnp + have hJn : (Fintype.card (Fin n → J) : ℝ) ≤ Real.exp ((p + C) ^ C) := by + simp only [Fintype.card_fun, Fintype.card_fin, Nat.cast_pow] + calc + _ ≤ (Real.exp p) ^ n := pow_le_pow_left₀ (Nat.cast_nonneg _) hJ n + _ = Real.exp ((n : ℝ) * p) := (Real.exp_nat_mul p n).symm + _ ≤ _ := Real.exp_le_exp.mpr hnp + refine ⟨hIn, hJn, ?_⟩ + intro a b + obtain ⟨F⟩ := hprod (σ := σ) (w := fun _ : σ => 1) (s := s) + (fun k x => f k (a k) x * star (g k (b k) x)) hp + (fun k => (E k).expansion (a k) (b k)) + have heq : (fun x => ∏ k, f k (a k) x * star (g k (b k) x)) = + (fun x => (∏ k, f k (a k) x) * star (∏ k, g k (b k) x)) := by + funext x + simp only [Finset.prod_mul_distrib, star_prod] + exact ⟨heq ▸ F.mono hcost⟩ + +end Erdos3.NativeIntegerVectorEquivalence + +end + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +open scoped BigOperators + +theorem conjugationPower {σ I J : Type*} [Fintype I] [Fintype J] {s : ℕ} {p : ℝ} + {f : I → (σ → ℤ) → ℂ} {g : J → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p f g) (n : ℕ) : + NativeIntegerVectorEquivalence s p + (fun i x => Erdos3.conjugationPower n (f i x)) + (fun j x => Erdos3.conjugationPower n (g j x)) := by + induction n with + | zero => exact E + | succ n ih => exact ih.conjugate + +theorem exists_finite_product_budget (ι : Type*) [Fintype ι] [DecidableEq ι] : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ I J : Type*} [Fintype I] [Fintype J] {s : ℕ} {p : ℝ} + (f : ι → I → (σ → ℤ) → ℂ) (g : ι → J → (σ → ℤ) → ℂ), + 0 ≤ p → (Fintype.card I : ℝ) ≤ Real.exp p → (Fintype.card J : ℝ) ≤ Real.exp p → + (∀ i, NativeIntegerVectorEquivalence s p (f i) (g i)) → + NativeIntegerVectorEquivalence s ((p + C) ^ C) + (fun a : ι → I => fun x => ∏ i, f i (a i) x) + (fun b : ι → J => fun x => ∏ i, g i (b i) x) := by + obtain ⟨C, hC, hprod⟩ := exists_fin_product_budget (Fintype.card ι) + refine ⟨C, hC, ?_⟩ + intro σ I J _ _ s p f g hp hI hJ E + classical + let e := (Fintype.equivFin ι).symm + have F := hprod (fun j => f (e j)) (fun j => g (e j)) hp hI hJ (fun j => E (e j)) + refine ⟨?_, ?_, ?_⟩ + · simpa only [Fintype.card_fun, Fintype.card_fin] using F.left_dimension + · simpa only [Fintype.card_fun, Fintype.card_fin] using F.right_dimension + · intro a b + have h := F.expansion (fun j => a (e j)) (fun j => b (e j)) + have hf (x : σ → ℤ) : (∏ j, f (e j) (a (e j)) x) = ∏ i, f i (a i) x := + e.prod_comp (fun i => f i (a i) x) + have hg (x : σ → ℤ) : (∏ j, g (e j) (b (e j)) x) = ∏ i, g i (b i) x := + e.prod_comp (fun i => g i (b i) x) + simpa only [hf, hg] using h + +end Erdos3.NativeIntegerVectorEquivalence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerHalving.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerHalving.lean new file mode 100644 index 0000000000000000000000000000000000000000..6469c5c65e422a0e55b78b09e2d5f5ad3ca37da4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerHalving.lean @@ -0,0 +1,556 @@ +import OAI.Combinatorics.Progressions.Estimates.SymmetricSquarefreeMonotonicity +import OAI.Combinatorics.Progressions.Geometry.NativeEquivalenceCoordinateMaps + +namespace OAI + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +noncomputable def ofProduct {L M : Type} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + {σ : Type*} {w : σ → ℕ} {s d e : ℕ} {p : ℝ} + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M s e) + (T : D.Niltest w) (U : E.Niltest w) + (hp : 2 ≤ p) (hT : T.ComplexityLE p) (hU : U.ComplexityLE p) : + NativeIntegerExpansion w s (productNiltestBudget p) + (fun x => T.eval x * U.eval x) := by + have hp0 : 0 ≤ p := by linarith + let K : Bool → Type := BoolLieFamily L M + let dims : Bool → ℕ := fun b => Bool.rec e d b + let models : ∀ b, RationalFilteredNilmanifold (K b) s (dims b) := fun b => by + cases b + · exact E + · exact D + let tests : ∀ b, (models b).Niltest w := fun b => by + cases b + · exact U + · exact T + have htests : ∀ b, (tests b).ComplexityLE p := by + intro b + cases b + · exact hU + · exact hT + have hcard : (Fintype.card Bool : ℝ) ≤ p := by + simpa only [Fintype.card_bool, Nat.cast_ofNat] using hp + let : FiniteDimensional ℚ (∀ b, K b) := + (RationalFilteredNilmanifold.productFinBasis models).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ b, K b)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ b, K b)) := IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (∀ b, K b)) := + realification_moduleTopology_t2 (RationalFilteredNilmanifold.productFinBasis models) + let S := RationalFilteredNilmanifold.piNiltest models tests hp0 hcard htests + have heval (x : σ → ℤ) : S.eval x = + T.eval x * U.eval x := by + change (RationalFilteredNilmanifold.piNiltest models tests hp0 hcard htests).eval + x = _ + rw [RationalFilteredNilmanifold.piNiltest_eval, Fintype.prod_bool] + rfl + exact ofTest S + (RationalFilteredNilmanifold.piNiltest_complexity models tests hp0 hcard htests) + (fun x => (heval x).symm) + +noncomputable def mul {σ : Type*} {w : σ → ℕ} {s : ℕ} {p : ℝ} {f g : (σ → ℤ) → ℂ} + (E : NativeIntegerExpansion w s p f) (F : NativeIntegerExpansion w s p g) + (hp : 2 ≤ p) : + NativeIntegerExpansion w s (productNiltestBudget p + 2 * p) (fun x => f x * g x) := by + let c : Fin E.count × Fin F.count → ℂ := fun ij => E.coefficient ij.1 * F.coefficient ij.2 + let v : Fin E.count × Fin F.count → (σ → ℤ) → ℂ := fun ij x => + (E.test ij.1).eval x * (F.test ij.2).eval x + let R : ∀ ij, NativeIntegerExpansion w s (productNiltestBudget p) (v ij) := + fun ij => ofProduct (E.model ij.1) (F.model ij.2) (E.test ij.1) (F.test ij.2) + hp (E.complexity ij.1) (F.complexity ij.2) + have hexp : Real.exp p * Real.exp p = Real.exp (2 * p) := by + rw [← Real.exp_add, two_mul] + have hcard : (Fintype.card (Fin E.count × Fin F.count) : ℝ) ≤ Real.exp (2 * p) := by + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul] + exact (mul_le_mul E.count_bound F.count_bound (Nat.cast_nonneg _) (Real.exp_nonneg _)).trans_eq hexp + have hc : (∑ ij, ‖c ij‖) ≤ Real.exp (2 * p) := by + calc + _ = (∑ i, ‖E.coefficient i‖) * (∑ j, ‖F.coefficient j‖) := by + simp only [c, norm_mul, Fintype.sum_prod_type, Finset.sum_mul_sum] + _ ≤ Real.exp p * Real.exp p := + mul_le_mul E.cost F.cost (Finset.sum_nonneg (fun _ _ => norm_nonneg _)) (Real.exp_nonneg _) + _ = _ := hexp + have heq : (fun x => ∑ ij, c ij * v ij x) = (fun x => f x * g x) := by + funext x + rw [E.eval x, F.eval x] + simp only [c, v, Fintype.sum_prod_type, Finset.sum_mul_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + exact heq ▸ weightedSum R c (by linarith) hcard hc + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +open scoped BigOperators + +theorem trans {σ J K M : Type*} [Fintype J] [Fintype K] [Fintype M] + {s : ℕ} {p : ℝ} + {chi : J → (σ → ℤ) → ℂ} {eta : K → (σ → ℤ) → ℂ} {psi : M → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p chi eta) (F : NativeIntegerVectorEquivalence s p eta psi) + (hunit : ∀ x, ∑ k, ‖eta k x‖ ^ 2 = 1) (hp : 2 ≤ p) : + NativeIntegerVectorEquivalence s (productNiltestBudget p + 2 * p + p) chi psi := by + classical + have hp0 : 0 ≤ p := by linarith + have hB : 0 ≤ productNiltestBudget p := + (sq_nonneg (p + 2)).trans (productNiltestBudget_geometry hp0) + have hpq : p ≤ productNiltestBudget p + 2 * p + p := by linarith + refine { + left_dimension := E.left_dimension.trans (Real.exp_le_exp.mpr hpq) + right_dimension := F.right_dimension.trans (Real.exp_le_exp.mpr hpq) + expansion := ?_ + } + intro j l + let A : ∀ k, NativeIntegerExpansion (fun _ : σ => 1) s p (fun x => chi j x * star (eta k x)) := + fun k => Classical.choice (E.expansion j k) + let B : ∀ k, NativeIntegerExpansion (fun _ : σ => 1) s p (fun x => eta k x * star (psi l x)) := + fun k => Classical.choice (F.expansion k l) + let R := fun k => (A k).mul (B k) hp + have hc : (∑ _ : K, ‖(1 : ℂ)‖) ≤ Real.exp p := by + simpa only [norm_one, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] + using E.right_dimension + let S := NativeIntegerExpansion.weightedSum R (fun _ => 1) hp0 E.right_dimension hc + have heq : (fun x => ∑ k, (1 : ℂ) * + ((chi j x * star (eta k x)) * (eta k x * star (psi l x)))) = + (fun x => chi j x * star (psi l x)) := by + funext x + calc + _ = ∑ k, ((chi j x * star (psi l x)) * star (eta k x)) * eta k x := by + apply Finset.sum_congr rfl + intro k _ + ring + _ = _ := (complex_unit_vector_resolution (fun k => eta k x) (hunit x) _).symm + exact ⟨heq ▸ S⟩ + +theorem exists_trans_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ J K M : Type*} [Fintype J] [Fintype K] [Fintype M] + {s : ℕ} {p : ℝ} + {chi : J → (σ → ℤ) → ℂ} {eta : K → (σ → ℤ) → ℂ} {psi : M → (σ → ℤ) → ℂ}, + 0 ≤ p → NativeIntegerVectorEquivalence s p chi eta → NativeIntegerVectorEquivalence s p eta psi → + (∀ x, ∑ k, ‖eta k x‖ ^ 2 = 1) → NativeIntegerVectorEquivalence s ((p + C) ^ C) chi psi := by + let Y : Polynomial ℕ := Polynomial.X + 2 + let P := (Y + 2) ^ 2 + Y + (Y + (Y ^ 2 + Y + 3) ^ 2) + Y ^ 2 + 4 + 2 * Y + Y + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ J K M _ _ _ s p chi eta psi hp E F hunit + have hpq : p ≤ p + 2 := by linarith + have hbudget : productNiltestBudget (p + 2) + 2 * (p + 2) + (p + 2) ≤ (p + C) ^ C := by + simpa [P, Y, Polynomial.eval₂_pow, productNiltestBudget, productObservableLipBudget] + using hbound p hp + exact ((E.mono hpq).trans (F.mono hpq) hunit (by linarith)).mono hbudget + +end Erdos3.NativeIntegerVectorEquivalence + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +noncomputable def constOne {σ : Type*} (w : σ → ℕ) (s : ℕ) {p : ℝ} (hp : 2 ≤ p) : + NativeIntegerExpansion w s p (fun _ => 1) := + ofTest (RationalFilteredNilmanifold.Niltest.const (RationalTorus.trivialNilmanifold s) w 1) + (RationalTorus.trivialNilmanifold_const_one_complexity s w hp) (fun _ => rfl) + +theorem exists_mul_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ : Type*} {w : σ → ℕ} {s : ℕ} {p : ℝ} + {f g : (σ → ℤ) → ℂ}, 0 ≤ p → + NativeIntegerExpansion w s p f → NativeIntegerExpansion w s p g → + Nonempty (NativeIntegerExpansion w s ((p + C) ^ C) (fun x => f x * g x)) := by + obtain ⟨a, _, ha⟩ := exists_productNiltestBudget_bound + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + 2 + Polynomial.C a) ^ a + 2 * (X + 2)) + refine ⟨C, hC, ?_⟩ + intro σ w s p f g hp E F + have hpq : p ≤ p + 2 := by linarith + have hcost : (p + 2 + a) ^ a + 2 * (p + 2) ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + have hbound : productNiltestBudget (p + 2) + 2 * (p + 2) ≤ (p + C) ^ C := + (add_le_add (ha _ (by linarith)) (le_refl _)).trans hcost + exact ⟨(((E.mono hpq).mul (F.mono hpq) (by linarith)).mono hbound)⟩ + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3 + +theorem card_product_le_exp_two {A B : Type*} [Fintype A] [Fintype B] {p : ℝ} + (ha : (Fintype.card A : ℝ) ≤ Real.exp p) (hb : (Fintype.card B : ℝ) ≤ Real.exp p) : + (Fintype.card (A × B) : ℝ) ≤ Real.exp (2 * p) := by + simp only [Fintype.card_prod, Nat.cast_mul] + exact (mul_le_mul ha hb (Nat.cast_nonneg _) (Real.exp_nonneg _)).trans_eq + (by rw [← Real.exp_add, two_mul]) + +theorem complex_tensor_cross_product (a b c d : ℂ) : + (a * star b) * (c * star d) = (a * c) * star (b * d) := by + simp only [star_mul] + ring + +noncomputable def NativeIntegerExpansion.tensorCrossProduct {σ : Type*} {s : ℕ} {p : ℝ} + {f g h k : (σ → ℤ) → ℂ} + (A : NativeIntegerExpansion (fun _ : σ => 1) s p (fun x => f x * star (h x))) + (B : NativeIntegerExpansion (fun _ : σ => 1) s p (fun x => g x * star (k x))) + (hp : 2 ≤ p) : + NativeIntegerExpansion (fun _ : σ => 1) s (productNiltestBudget p + 2 * p) + (fun x => (f x * g x) * star (h x * k x)) := by + have heq : (fun x => (f x * star (h x)) * (g x * star (k x))) = + (fun x => (f x * g x) * star (h x * k x)) := + funext (fun x => complex_tensor_cross_product (f x) (h x) (g x) (k x)) + exact heq ▸ A.mul B hp + +namespace NativeIntegerVectorEquivalence + +theorem tensor {σ J K L M : Type*} [Fintype J] [Fintype K] [Fintype L] [Fintype M] + {s : ℕ} {p : ℝ} {chi : J → (σ → ℤ) → ℂ} {eta : K → (σ → ℤ) → ℂ} + {psi : L → (σ → ℤ) → ℂ} {phi : M → (σ → ℤ) → ℂ} + (E : NativeIntegerVectorEquivalence s p chi eta) + (F : NativeIntegerVectorEquivalence s p psi phi) (hp : 2 ≤ p) : + NativeIntegerVectorEquivalence s (productNiltestBudget p + 2 * p) + (fun jl : J × L => fun x => chi jl.1 x * psi jl.2 x) + (fun km : K × M => fun x => eta km.1 x * phi km.2 x) := by + have hp0 : 0 ≤ p := by linarith + have hB : 0 ≤ productNiltestBudget p := + (sq_nonneg (p + 2)).trans (productNiltestBudget_geometry hp0) + have hcost : Real.exp (2 * p) ≤ Real.exp (productNiltestBudget p + 2 * p) := + Real.exp_le_exp.mpr (le_add_of_nonneg_left hB) + refine ⟨(card_product_le_exp_two E.left_dimension F.left_dimension).trans hcost, + (card_product_le_exp_two E.right_dimension F.right_dimension).trans hcost, ?_⟩ + intro jl km + obtain ⟨A⟩ := E.expansion jl.1 km.1 + obtain ⟨B⟩ := F.expansion jl.2 km.2 + exact ⟨A.tensorCrossProduct B hp⟩ + +theorem exists_tensor_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ J K L M : Type*} + [Fintype J] [Fintype K] [Fintype L] [Fintype M] {s : ℕ} {p : ℝ} + {chi : J → (σ → ℤ) → ℂ} {eta : K → (σ → ℤ) → ℂ} + {psi : L → (σ → ℤ) → ℂ} {phi : M → (σ → ℤ) → ℂ}, + 0 ≤ p → NativeIntegerVectorEquivalence s p chi eta → + NativeIntegerVectorEquivalence s p psi phi → + NativeIntegerVectorEquivalence s ((p + C) ^ C) + (fun jl : J × L => fun x => chi jl.1 x * psi jl.2 x) + (fun km : K × M => fun x => eta km.1 x * phi km.2 x) := by + obtain ⟨a, _, ha⟩ := exists_productNiltestBudget_bound + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + 2 + Polynomial.C a) ^ a + 2 * (X + 2)) + refine ⟨C, hC, ?_⟩ + intro σ J K L M _ _ _ _ s p chi eta psi phi hp E F + have hpq : p ≤ p + 2 := by linarith + have hcost : (p + 2 + a) ^ a + 2 * (p + 2) ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + have hbound : productNiltestBudget (p + 2) + 2 * (p + 2) ≤ (p + C) ^ C := + (add_le_add (ha _ (by linarith)) (le_refl _)).trans hcost + exact ((E.mono hpq).tensor (F.mono hpq) (by linarith)).mono hbound + +end NativeIntegerVectorEquivalence + +end Erdos3 + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped BigOperators + +theorem exists_fin_prod_budget (n : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ : Type*} {w : σ → ℕ} {s : ℕ} {p : ℝ} + (f : Fin n → (σ → ℤ) → ℂ), 0 ≤ p → + (∀ i, Nonempty (NativeIntegerExpansion w s p (f i))) → + Nonempty (NativeIntegerExpansion w s ((p + C) ^ C) (fun x => ∏ i, f i x)) := by + induction n with + | zero => + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Polynomial.X + 2) + refine ⟨C, hC, ?_⟩ + intro σ w s p f hp _ + have hcost : p + 2 ≤ (p + C) ^ C := by simpa using hbudget p hp + exact ⟨by simpa using (constOne w s (by linarith : 2 ≤ p + 2)).mono hcost⟩ + | succ n ih => + obtain ⟨A, _, hprod⟩ := ih + obtain ⟨B, _, hmul⟩ := exists_mul_budget + let X : Polynomial ℕ := Polynomial.X + let T := X + (X + Polynomial.C A) ^ A + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((T + Polynomial.C B) ^ B) + refine ⟨C, hC, ?_⟩ + intro σ w s p f hp hf + let t := p + (p + A) ^ A + have ht : 0 ≤ t := by dsimp [t]; positivity + have hpt : p ≤ t := le_add_of_nonneg_right (by positivity) + have hAt : (p + A) ^ A ≤ t := le_add_of_nonneg_left hp + obtain ⟨tail⟩ := hprod (fun i => f i.succ) hp (fun i => hf i.succ) + obtain ⟨H⟩ := hmul ht ((Classical.choice (hf 0)).mono hpt) (tail.mono hAt) + have hcost : (t + B) ^ B ≤ (p + C) ^ C := by + simpa [X, T, t, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨by simpa only [Fin.prod_univ_succ] using H.mono hcost⟩ + +end Erdos3.NativeIntegerExpansion + +end + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +open scoped BigOperators + +theorem exists_cancel_left_tensor_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ I J K L : Type*} + [Fintype I] [Fintype J] [Fintype K] [Fintype L] {s : ℕ} {p : ℝ} + {a : I → (σ → ℤ) → ℂ} {b : J → (σ → ℤ) → ℂ} + {c : K → (σ → ℤ) → ℂ} {d : L → (σ → ℤ) → ℂ}, + 0 ≤ p → NativeIntegerVectorEquivalence s p a b → + NativeIntegerVectorEquivalence s p c (fun jl : J × L => fun x => b jl.1 x * d jl.2 x) → + (∀ x, ∑ j, ‖b j x‖ ^ 2 = 1) → (Fintype.card L : ℝ) ≤ Real.exp p → + NativeIntegerVectorEquivalence s ((p + C) ^ C) + (fun ik : I × K => fun x => a ik.1 x * star (c ik.2 x)) (fun l x => star (d l x)) := by + obtain ⟨A, _, hmul⟩ := NativeIntegerExpansion.exists_mul_budget + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((X + Polynomial.C A) ^ A + 3 * X + 2) + refine ⟨C, hC, ?_⟩ + intro σ I J K L _ _ _ _ s p a b c d hp E F hunit hdim + have hcost : (p + A) ^ A + 3 * p + 2 ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + have hpow : 0 ≤ (p + A) ^ A := by positivity + have hpC : p ≤ (p + C) ^ C := by linarith + have htwo : 2 * p ≤ (p + C) ^ C := by linarith + have hsumCost : (p + A) ^ A + p ≤ (p + C) ^ C := by linarith + refine ⟨(card_product_le_exp_two E.left_dimension F.left_dimension).trans + (Real.exp_le_exp.mpr htwo), hdim.trans (Real.exp_le_exp.mpr hpC), ?_⟩ + intro ik l + let term (j : J) (x : σ → ℤ) := + (a ik.1 x * star (b j x)) * star (c ik.2 x * star (b j x * d l x)) + have hterm (j : J) : Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s ((p + A) ^ A) (term j)) := + hmul hp (Classical.choice (E.expansion ik.1 j)) (Classical.choice (F.expansion ik.2 (j, l))).conjugate + have hcoeff : (∑ _j : J, ‖(1 : ℂ)‖) ≤ Real.exp p := by simpa using E.right_dimension + have S := (NativeIntegerExpansion.weightedSum (fun j => Classical.choice (hterm j)) + (fun _ => (1 : ℂ)) hp E.right_dimension hcoeff).mono hsumCost + have heq : (fun x => ∑ j : J, (1 : ℂ) * term j x) = + (fun x => (a ik.1 x * star (c ik.2 x)) * star (star (d l x))) := by + funext x + simp only [one_mul, star_star] + calc + _ = (∑ j : J, (a ik.1 x * star (b j x)) * b j x) * (star (c ik.2 x) * d l x) := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro j _ + simp only [term, star_mul, star_star] + ring + _ = _ := by + rw [← complex_unit_vector_resolution (fun j => b j x) (hunit x) (a ik.1 x)] + ring + exact ⟨heq ▸ S⟩ + +end Erdos3.NativeIntegerVectorEquivalence + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +theorem RationalTorus.residueNiltest_eval {q : ℕ} [NeZero q] (j : ZMod q) (n : ℤ) : + (residueNiltest j).eval (fun _ : Unit => n) = if (n : ZMod q) = j then 1 else 0 := by + classical + unfold residueNiltest realAffineNiltest + rw [affineNiltest_eval] + simp only [reindexedRealObservable, Equiv.refl_apply, + Finset.univ_unique, Finset.sum_singleton, Pi.add_apply, Pi.smul_apply, + zero_add, smul_eq_mul, mul_one_div] + rw [← ZMod.toAddCircle_intCast, CircleFourier.residueCutoff_at_grid] + split_ifs <;> rfl + +theorem exists_coordinate_residue_expansion {σ : Type*} [Fintype σ] + {q : ℕ} [NeZero q] (k : σ) (j : ZMod q) {p : ℝ} + (hp : 0 ≤ p) (hq : (q : ℝ) ≤ Real.exp p) : + Nonempty (NativeIntegerExpansion (fun _ : σ => 1) 1 (p + 2) + (fun x => if (x k : ZMod q) = j then 1 else 0)) := by + let T := RationalTorus.residueNiltest j + let a : (σ → ℤ) →+ ℤ := { toFun := fun x => x k, map_zero' := rfl, map_add' := fun _ _ => rfl } + let U := T.linearPullbackHom (fun _ : Unit => a) + refine ⟨NativeIntegerExpansion.ofTest U (RationalTorus.residueNiltest_complexity j hp hq) ?_⟩ + intro x + rw [RationalFilteredNilmanifold.Niltest.eval_linearPullbackHom] + exact (RationalTorus.residueNiltest_eval j (x k)).symm + +noncomputable def pairParityIndicator (r : Fin 2 → ZMod 2) (x : Fin 2 → ℤ) : ℂ := + if (fun i => (x i : ZMod 2)) = r then 1 else 0 + +theorem pairParityIndicator_product (r : Fin 2 → ZMod 2) (x : Fin 2 → ℤ) : + pairParityIndicator r x = + (if (x 0 : ZMod 2) = r 0 then 1 else 0) * + (if (x 1 : ZMod 2) = r 1 then 1 else 0) := by + classical + have heq : (fun i => (x i : ZMod 2)) = r ↔ (x 0 : ZMod 2) = r 0 ∧ (x 1 : ZMod 2) = r 1 := by + constructor + · intro h + exact ⟨congrFun h 0, congrFun h 1⟩ + · rintro ⟨h0, h1⟩ + funext i + fin_cases i <;> assumption + unfold pairParityIndicator + simp only [heq] + split_ifs <;> simp_all + +theorem exists_pairParityIndicator_expansion : + ∃ C : ℕ, 2 ≤ C ∧ ∀ r : Fin 2 → ZMod 2, + Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 1 (C : ℝ) (pairParityIndicator r)) := by + obtain ⟨A, hA, hmul⟩ := NativeIntegerExpansion.exists_mul_budget + refine ⟨(4 + A) ^ A + 2, by omega, ?_⟩ + intro r + have htwo : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + obtain ⟨E0⟩ := exists_coordinate_residue_expansion (σ := Fin 2) 0 (r 0) (by norm_num : (0 : ℝ) ≤ 2) htwo + obtain ⟨E1⟩ := exists_coordinate_residue_expansion (σ := Fin 2) 1 (r 1) (by norm_num : (0 : ℝ) ≤ 2) htwo + obtain ⟨E⟩ := hmul (by norm_num : (0 : ℝ) ≤ 2 + 2) E0 E1 + have hb : ((2 : ℝ) + 2 + A) ^ A ≤ (((4 + A) ^ A + 2 : ℕ) : ℝ) := by + push_cast + norm_num + have heq : (fun x => (if (x 0 : ZMod 2) = r 0 then (1 : ℂ) else 0) * + (if (x 1 : ZMod 2) = r 1 then 1 else 0)) = pairParityIndicator r := by + funext x + exact (pairParityIndicator_product r x).symm + rw [heq] at E + exact ⟨E.mono hb⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.NativeIntegerVectorEquivalence + +open scoped BigOperators + +theorem exists_tensor_power_budget (n : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ I J : Type*} [Fintype I] [Fintype J] {s : ℕ} {p : ℝ} + {f : I → (σ → ℤ) → ℂ} {g : J → (σ → ℤ) → ℂ}, + 0 ≤ p → NativeIntegerVectorEquivalence s p f g → + NativeIntegerVectorEquivalence s ((p + C) ^ C) (tensorVector f n) (tensorVector g n) := by + obtain ⟨A, _, hprod⟩ := NativeIntegerExpansion.exists_fin_prod_budget n + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A) ^ A + Polynomial.C n * X) + refine ⟨C, hC, ?_⟩ + intro σ I J _ _ s p f g hp E + have hsum : (p + A) ^ A + n * p ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + have hcost : (p + A) ^ A ≤ (p + C) ^ C := by + have hn : 0 ≤ (n : ℝ) * p := mul_nonneg (Nat.cast_nonneg _) hp + linarith + have hnp : (n : ℝ) * p ≤ (p + C) ^ C := by + have ha : 0 ≤ (p + A) ^ A := by positivity + linarith + have hI : (Fintype.card (Fin n → I) : ℝ) ≤ Real.exp ((p + C) ^ C) := by + simp only [Fintype.card_fun, Fintype.card_fin, Nat.cast_pow] + calc + _ ≤ (Real.exp p) ^ n := pow_le_pow_left₀ (Nat.cast_nonneg _) E.left_dimension n + _ = Real.exp ((n : ℝ) * p) := (Real.exp_nat_mul p n).symm + _ ≤ _ := Real.exp_le_exp.mpr hnp + have hJ : (Fintype.card (Fin n → J) : ℝ) ≤ Real.exp ((p + C) ^ C) := by + simp only [Fintype.card_fun, Fintype.card_fin, Nat.cast_pow] + calc + _ ≤ (Real.exp p) ^ n := pow_le_pow_left₀ (Nat.cast_nonneg _) E.right_dimension n + _ = Real.exp ((n : ℝ) * p) := (Real.exp_nat_mul p n).symm + _ ≤ _ := Real.exp_le_exp.mpr hnp + refine ⟨hI, hJ, ?_⟩ + intro a b + obtain ⟨F⟩ := hprod (fun k x => f (a k) x * star (g (b k) x)) hp + (fun k => E.expansion (a k) (b k)) + have heq : (fun x => ∏ k, f (a k) x * star (g (b k) x)) = + (fun x => tensorVector f n a x * star (tensorVector g n b x)) := by + funext x + simp only [tensorVector, Finset.prod_mul_distrib, star_prod] + exact ⟨heq ▸ F.mono hcost⟩ + +end Erdos3.NativeIntegerVectorEquivalence + +end + +section + +namespace Erdos3.NativeIntegerExpansion + +open scoped BigOperators + +theorem exists_halving_expansion : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ} {f : (Fin 2 → ℤ) → ℂ}, 0 ≤ p → + NativeIntegerExpansion (fun _ : Fin 2 => 1) 1 p f → + Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 1 ((p + C) ^ C) + (fun x => f (fun i => x i / 2))) := by + obtain ⟨A, hA, hparity⟩ := exists_pairParityIndicator_expansion + obtain ⟨B, _, hmul⟩ := exists_mul_budget + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A + 2 + Polynomial.C B) ^ B + 2) + refine ⟨C, hC, ?_⟩ + intro p f hp E + classical + let t : ℝ := p + A + 2 + have ht : 0 ≤ t := by dsimp [t]; positivity + have hpt : p ≤ t := by dsimp [t]; have := Nat.cast_nonneg (α := ℝ) A; linarith + have hAt : (A : ℝ) ≤ t := by dsimp [t]; linarith + let P (r : Fin 2 → ZMod 2) := halvingPolynomial (fun i => ((r i).val : ℤ)) + have hP (r : Fin 2 → ZMod 2) (i : Fin 2) : + P r i ∈ weightedSupportLE (fun _ : Fin 2 => 1) 1 := halvingPolynomial_support _ i + let F (r : Fin 2 → ZMod 2) := E.substitutedValue (P r) (hP r) + have hF (r : Fin 2 → ZMod 2) : Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 1 + ((t + B) ^ B) (fun x => pairParityIndicator r x * F r x)) := + hmul ht ((Classical.choice (hparity r)).mono hAt) + ((E.substituteExpansion (P r) (hP r)).mono hpt) + have hc : (Fintype.card (Fin 2 → ZMod 2) : ℝ) ≤ Real.exp 2 := by + norm_num only [Fintype.card_fun, ZMod.card, Fintype.card_fin] + have hh := Real.add_one_le_exp (1 : ℝ) + rw [show (2 : ℝ) = 1 + 1 by norm_num, Real.exp_add] + nlinarith + have hcost : (∑ _ : Fin 2 → ZMod 2, ‖(1 : ℂ)‖) ≤ Real.exp 2 := by simpa using hc + let S := weightedSum (fun r => Classical.choice (hF r)) (fun _ => 1) + (by norm_num : (0 : ℝ) ≤ 2) hc hcost + have heq : (fun x => ∑ r : Fin 2 → ZMod 2, (1 : ℂ) * (pairParityIndicator r x * F r x)) = + (fun x => f (fun i => x i / 2)) := by + funext x + let r : Fin 2 → ZMod 2 := fun i => (x i : ZMod 2) + rw [Finset.sum_eq_single r] + · simp only [pairParityIndicator, r, ite_true, one_mul] + apply E.substitutedValue_eq (P r) (hP r) x (fun i => x i / 2) + exact halvingPolynomial_eval _ x (fun i => (ZMod.val_intCast (x i)).symm) + · intro a _ ha + have hne : (fun i => (x i : ZMod 2)) ≠ a := fun h => ha h.symm + simp only [pairParityIndicator, hne, ite_false, zero_mul, mul_zero] + · simp + have hb : (t + B) ^ B + 2 ≤ (p + C) ^ C := by + simpa [t, X, Polynomial.eval₂_pow] using hbudget p hp + rw [heq] at S + exact ⟨S.mono hb⟩ + +end Erdos3.NativeIntegerExpansion + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerIntervalInverse.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerIntervalInverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..d695705190d8e7a3757770257b19eb721dcd73b0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerIntervalInverse.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.Progressions.Geometry.NativeTranslatedBoxInverse + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +theorem exists_native_integer_interval_inverse (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (a : ℤ) (L : ℕ) [NeZero L] {p : ℝ}, 2 ≤ p → + ∀ f : ℤ → ℂ, (∀ x ∈ Finset.Ico a (a + L), ‖f x‖ ≤ 1) → + Real.exp (-p) ≤ finiteSupportGowersNorm (s + 1) (Finset.Ico a (a + L)) f → + ∃ V : NativeSampleCorrelation (fun _ : Unit => 1) s ((p + C) ^ C) + (Finset.Ico a (a + L)) (fun x _ => x) f, V.test.normBound ≤ 1 := by + obtain ⟨C, hC, hbox⟩ := exists_native_translated_box_inverse_bounded_dimension s hs 1 + refine ⟨C, hC, ?_⟩ + intro a L _ p hp f hf hGowers + have hdim : (1 : ℝ) ≤ (p + (1 : ℕ)) ^ (1 : ℕ) := by norm_num; linarith + have hcap : ∀ x ∈ translatedIntegerBox (fun _ : Fin 1 => a) (fun _ => L), ‖f (x 0)‖ ≤ 1 := by + intro x hx + apply hf + exact Finset.mem_Ico.mpr ((mem_translatedIntegerBox _ _ _).mp hx 0) + have hnorm : Real.exp (-p) ≤ finiteSupportGowersNorm (s + 1) + (translatedIntegerBox (fun _ : Fin 1 => a) (fun _ => L)) (fun x => f (x 0)) := by + rw [oneDimensionalBox_norm] + exact hGowers + obtain ⟨V, hV⟩ := hbox (fun _ : Fin 1 => a) (fun _ => L) hp (by simpa only [Nat.cast_one] using hdim) + (fun x => f (x 0)) hcap hnorm + let A : Fin 1 → ((Unit → ℤ) →+ ℤ) := fun _ => + { toFun := fun x => x (), map_zero' := rfl, map_add' := fun _ _ => rfl } + refine ⟨{ + L := V.L + dim := V.dim + model := V.model + test := V.test.linearPullbackHom A + complexity := V.complexity + correlation := ?_ }, hV⟩ + have hh := V.correlation + change Real.exp (-((p + C) ^ C)) ≤ ‖finiteCorrelation + (translatedIntegerBox (fun _ : Fin 1 => a) (fun _ => L)) (fun x => f (x 0)) V.test.eval‖ at hh + rw [oneDimensionalBox_correlation] at hh + simpa only [finiteCorrelation, RationalFilteredNilmanifold.Niltest.eval_linearPullbackHom, A, + AddMonoidHom.coe_mk, ZeroHom.coe_mk] using hh + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerSelfEquivalence.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerSelfEquivalence.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae143262253aecf919c6435e65b492ab0430c606 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerSelfEquivalence.lean @@ -0,0 +1,44 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeMultilinearityCorrelation + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open scoped BigOperators + +theorem exists_integer_self_equivalence {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ] : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ} (W : NativeMultidegreeNilcharacter (fun _ : σ => 1) p), + NativeIntegerVectorEquivalence (Fintype.card σ - 1) ((p + C) ^ C) W.eval W.eval := by + obtain ⟨a, _, hadd⟩ := exists_multilinearity_equivalence (σ := σ) + obtain ⟨c, _, htrans⟩ := NativeIntegerVectorEquivalence.exists_trans_budget + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (((X + Polynomial.C a) ^ a + Polynomial.C c) ^ c) + refine ⟨C, hC, ?_⟩ + intro p W + classical + let i : σ := Classical.arbitrary σ + let A : Option σ → ((σ → ℤ) →+ ℤ) := fun j => match j with + | none => 0 + | some k => ⟨⟨fun x => x k, rfl⟩, fun _ _ => rfl⟩ + let E := (hadd W i).linearPullbackHom A + have hleft (k : Fin W.outputDim) (x : σ → ℤ) : + coordinateSumVector W.eval i k (fun j => A j x) = W.eval k x := by + simp [coordinateSumVector, coordinateAdditionInputs, A] + have hunit (x : σ → ℤ) : + ∑ k, ‖coordinateTensorVector W.eval i k (fun j => A j x)‖ ^ 2 = 1 := + coordinateTensorVector_unit W.eval W.unit_eval i _ + have hp : 0 ≤ p := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + have hq : 0 ≤ (p + a) ^ a := by positivity + have F := htrans hq E E.symm hunit + have hcost : ((p + a) ^ a + c) ^ c ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + simpa only [hleft] using F.mono hcost + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerThirds.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerThirds.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d984548967bbba4e0fafc3ee4d7a69eb85e9cb9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntegerThirds.lean @@ -0,0 +1,137 @@ +import OAI.Combinatorics.Progressions.Polynomial.PositiveDegreeCyclicDifference + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def thirdsPolynomial {σ : Type*} (r : σ → ℤ) (i : σ) : MvPolynomial σ ℚ := + MvPolynomial.C (1 / 3 : ℚ) * (MvPolynomial.X i - MvPolynomial.C (r i : ℚ)) + +theorem thirdsPolynomial_support {σ : Type*} (r : σ → ℤ) (i : σ) : + thirdsPolynomial r i ∈ weightedSupportLE (fun _ : σ => 1) 1 := by + have hx : (MvPolynomial.X i : MvPolynomial σ ℚ) ∈ weightedSupportLE (fun _ : σ => 1) 1 := by + simpa only [MvPolynomial.X, Finsupp.weight_single, smul_eq_mul, mul_one] using + weightedSupportLE_monomial (fun _ : σ => 1) (Finsupp.single i 1) (1 : ℚ) + simpa only [thirdsPolynomial, zero_add] using + weightedSupportLE_mul (weightedSupportLE_C (fun _ : σ => 1) 0 (1 / 3 : ℚ)) + (Submodule.sub_mem _ hx (weightedSupportLE_C _ 1 (r i : ℚ))) + +theorem thirdsPolynomial_eval {σ : Type*} (r x : σ → ℤ) + (hr : ∀ i, x i % 3 = r i) (i : σ) : + MvPolynomial.aeval (R := ℚ) (fun j => (x j : ℚ)) (thirdsPolynomial r i) = + ((x i / 3 : ℤ) : ℚ) := by + have hi : x i = 3 * (x i / 3) + r i := by + have h := hr i + omega + have hiq : (x i : ℚ) = 3 * ((x i / 3 : ℤ) : ℚ) + (r i : ℚ) := by exact_mod_cast hi + simp only [thirdsPolynomial, map_mul, map_sub, MvPolynomial.aeval_C, MvPolynomial.aeval_X] + change (1 / 3 : ℚ) * ((x i : ℚ) - (r i : ℚ)) = ((x i / 3 : ℤ) : ℚ) + linarith + +noncomputable def pairThirdIndicator (r : Fin 2 → ZMod 3) (x : Fin 2 → ℤ) : ℂ := + if (fun i => (x i : ZMod 3)) = r then 1 else 0 + +theorem pairThirdIndicator_product (r : Fin 2 → ZMod 3) (x : Fin 2 → ℤ) : + pairThirdIndicator r x = + (if (x 0 : ZMod 3) = r 0 then 1 else 0) * + (if (x 1 : ZMod 3) = r 1 then 1 else 0) := by + classical + have heq : (fun i => (x i : ZMod 3)) = r ↔ (x 0 : ZMod 3) = r 0 ∧ (x 1 : ZMod 3) = r 1 := by + constructor + · intro h + exact ⟨congrFun h 0, congrFun h 1⟩ + · rintro ⟨h0, h1⟩ + funext i + fin_cases i <;> assumption + unfold pairThirdIndicator + simp only [heq] + split_ifs <;> simp_all + +theorem exists_pairThirdIndicator_expansion : + ∃ C : ℕ, 2 ≤ C ∧ ∀ r : Fin 2 → ZMod 3, + Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 2 (C : ℝ) (pairThirdIndicator r)) := by + obtain ⟨A, _, hmul⟩ := NativeIntegerExpansion.exists_mul_budget + refine ⟨(43 + A) ^ A + 2, by omega, ?_⟩ + intro r + have hthree : (3 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + obtain ⟨E0⟩ := exists_coordinate_residue_expansion (σ := Fin 2) 0 (r 0) + (by norm_num : (0 : ℝ) ≤ 2) hthree + obtain ⟨E1⟩ := exists_coordinate_residue_expansion (σ := Fin 2) 1 (r 1) + (by norm_num : (0 : ℝ) ≤ 2) hthree + have hraise : raisedNiltestBudget ((2 : ℝ) + 2) = 43 := by norm_num [raisedNiltestBudget] + have F0 : NativeIntegerExpansion (fun _ : Fin 2 => 1) 2 43 + (fun x => if (x 0 : ZMod 3) = r 0 then 1 else 0) := by + simpa only [hraise] using E0.raiseStep (by decide : 1 ≤ 2) (by norm_num) + have F1 : NativeIntegerExpansion (fun _ : Fin 2 => 1) 2 43 + (fun x => if (x 1 : ZMod 3) = r 1 then 1 else 0) := by + simpa only [hraise] using E1.raiseStep (by decide : 1 ≤ 2) (by norm_num) + obtain ⟨F⟩ := hmul (by norm_num : (0 : ℝ) ≤ 43) F0 F1 + have hb : (43 + (A : ℝ)) ^ A ≤ (((43 + A) ^ A + 2 : ℕ) : ℝ) := by + push_cast + norm_num + have heq : (fun x => (if (x 0 : ZMod 3) = r 0 then (1 : ℂ) else 0) * + (if (x 1 : ZMod 3) = r 1 then 1 else 0)) = pairThirdIndicator r := by + funext x + exact (pairThirdIndicator_product r x).symm + rw [heq] at F + exact ⟨F.mono hb⟩ + +theorem card_pairThird_le_exp : (Fintype.card (Fin 2 → ZMod 3) : ℝ) ≤ Real.exp 9 := by + norm_num only [Fintype.card_fun, ZMod.card, Fintype.card_fin, Nat.cast_ofNat] + linarith [Real.add_one_le_exp (9 : ℝ)] + +theorem NativeIntegerExpansion.exists_thirds_expansion : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ} {f : (Fin 2 → ℤ) → ℂ}, 0 ≤ p → + NativeIntegerExpansion (fun _ : Fin 2 => 1) 2 p f → + Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 2 ((p + C) ^ C) + (fun x => f (fun i => x i / 3))) := by + obtain ⟨A, _, hresidue⟩ := exists_pairThirdIndicator_expansion + obtain ⟨B, _, hmul⟩ := NativeIntegerExpansion.exists_mul_budget + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A + 2 + Polynomial.C B) ^ B + 9) + refine ⟨C, hC, ?_⟩ + intro p f hp E + classical + let t : ℝ := p + A + 2 + have ht : 0 ≤ t := by dsimp [t]; positivity + have hpt : p ≤ t := by dsimp [t]; have := Nat.cast_nonneg (α := ℝ) A; linarith + have hAt : (A : ℝ) ≤ t := by dsimp [t]; linarith + let P (r : Fin 2 → ZMod 3) := thirdsPolynomial (fun i => ((r i).val : ℤ)) + have hP (r : Fin 2 → ZMod 3) (i : Fin 2) : + P r i ∈ weightedSupportLE (fun _ : Fin 2 => 1) 1 := thirdsPolynomial_support _ i + let F (r : Fin 2 → ZMod 3) := E.substitutedValue (P r) (hP r) + have hF (r : Fin 2 → ZMod 3) : Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 2 + ((t + B) ^ B) (fun x => pairThirdIndicator r x * F r x)) := + hmul ht ((Classical.choice (hresidue r)).mono hAt) + ((E.substituteExpansion (P r) (hP r)).mono hpt) + have hcost : (∑ _ : Fin 2 → ZMod 3, ‖(1 : ℂ)‖) ≤ Real.exp 9 := by + simpa using card_pairThird_le_exp + let S := NativeIntegerExpansion.weightedSum (fun r => Classical.choice (hF r)) (fun _ => 1) + (by norm_num : (0 : ℝ) ≤ 9) card_pairThird_le_exp hcost + have heq : (fun x => ∑ r : Fin 2 → ZMod 3, (1 : ℂ) * (pairThirdIndicator r x * F r x)) = + (fun x => f (fun i => x i / 3)) := by + funext x + let r : Fin 2 → ZMod 3 := fun i => (x i : ZMod 3) + rw [Finset.sum_eq_single r] + · simp only [pairThirdIndicator, r, ite_true, one_mul] + apply E.substitutedValue_eq (P r) (hP r) x (fun i => x i / 3) + exact thirdsPolynomial_eval _ x (fun i => (ZMod.val_intCast (x i)).symm) + · intro a _ ha + have hne : (fun i => (x i : ZMod 3)) ≠ a := fun h => ha h.symm + simp only [pairThirdIndicator, hne, ite_false, zero_mul, mul_zero] + · simp + have hb : (t + B) ^ B + 9 ≤ (p + C) ^ C := by + simpa [t, X, Polynomial.eval₂_pow] using hbudget p hp + rw [heq] at S + exact ⟨S.mono hb⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntervalResiduePartition.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntervalResiduePartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b971a933816098a4ba5a7ce78fd2e1818288935 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeIntervalResiduePartition.lean @@ -0,0 +1,243 @@ +import OAI.Combinatorics.Progressions.Nilpotent.NativeResidueNiltests +import OAI.Combinatorics.Progressions.Sampling.FixedObservationRefinement + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residue_indicator_positiveCyclicNiltest {q N : ℕ} [NeZero q] [NeZero N] + (j : ZMod q) {p : ℝ} (hp : 0 ≤ p) (hq : (q : ℝ) ≤ Real.exp p) : + PositiveCyclicNiltest.{0} 1 N (p + 2) + (fun x => if (x.val : ZMod q) = j then 1 else 0) := by + classical + refine .of_test (RationalTorus.nilmanifold 1) le_rfl (RationalTorus.residueNiltest j) + (RationalTorus.residueNiltest_unit_interval j) (RationalTorus.residueNiltest_complexity j hp hq) ?_ + intro x + rw [RationalTorus.residueNiltest_evalCyclic] + split_ifs <;> rfl + +theorem refine_positive_partition_by_residue {I : Type*} [Fintype I] + {degree q N : ℕ} [NeZero q] [NeZero N] (A : I → ZMod N → ℝ) {p : ℝ} + (hp : 0 ≤ p) (hdegree : 1 ≤ degree) (hq : (q : ℝ) ≤ Real.exp p) + (hA : ∀ i, PositiveCyclicNiltest.{0} degree N p (A i)) (hsum : ∀ x, ∑ i, A i x = 1) : + ∃ B : (I × ZMod q) → ZMod N → ℝ, + (∀ j, PositiveCyclicNiltest.{0} degree N + (productNiltestBudget (raisedNiltestBudget (p + 2))) (B j)) ∧ + (∀ x, ∑ j, B j x = 1) ∧ + (∀ j x, 0 < B j x → 0 < A j.1 x ∧ (x.val : ZMod q) = j.2) := by + classical + let B : (I × ZMod q) → ZMod N → ℝ := fun j x => + A j.1 x * if (x.val : ZMod q) = j.2 then 1 else 0 + refine ⟨B, ?_, ?_, ?_⟩ + · intro j + exact ((hA j.1).mono le_rfl (by linarith)).mul + ((residue_indicator_positiveCyclicNiltest j.2 hp hq).mono hdegree le_rfl) (by linarith) + · intro x + simpa [B, Fintype.sum_prod_type, mul_ite] using hsum x + · intro j x hx + by_cases h : (x.val : ZMod q) = j.2 + · exact ⟨by simpa only [B, h, ↓reduceIte, mul_one] using hx, h⟩ + · simp only [B, h, ↓reduceIte, mul_zero, lt_self_iff_false] at hx + +theorem exists_controlled_residue_refinement : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {I : Type*} [Fintype I] + {degree q N : ℕ} [NeZero q] [NeZero N] (A : I → ZMod N → ℝ) {p : ℝ}, + 0 ≤ p → 1 ≤ degree → (Fintype.card I : ℝ) ≤ Real.exp p → (q : ℝ) ≤ Real.exp p → + (∀ i, PositiveCyclicNiltest.{0} degree N p (A i)) → (∀ x, ∑ i, A i x = 1) → + ∃ B : (I × ZMod q) → ZMod N → ℝ, + (Fintype.card (I × ZMod q) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (∀ j, PositiveCyclicNiltest.{0} degree N ((p + C) ^ C) (B j)) ∧ + (∀ x, ∑ j, B j x = 1) ∧ + ∀ j x, 0 < B j x → 0 < A j.1 x ∧ (x.val : ZMod q) = j.2 := by + let X : Polynomial ℕ := Polynomial.X + let R := (X + 2) + (X + 4) ^ 2 + 3 + let Q := (R + 2) ^ 2 + R + (R + (R ^ 2 + R + 3) ^ 2) + R ^ 2 + 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (2 * X + Q) + refine ⟨C, hC, ?_⟩ + intro I _ degree q N _ _ A p hp hdegree hcard hq hA hsum + obtain ⟨B, hB, hBsum, hsupport⟩ := refine_positive_partition_by_residue A hp hdegree hq hA hsum + have hcost : 2 * p + productNiltestBudget (raisedNiltestBudget (p + 2)) ≤ (p + C) ^ C := by + simpa [X, Q, R, Polynomial.eval₂_pow, raisedNiltestBudget, productNiltestBudget, + productObservableLipBudget, show p + 2 + 2 = p + 4 by ring] using hbudget p hp + have hnonneg : 0 ≤ productNiltestBudget (raisedNiltestBudget (p + 2)) := by + unfold productNiltestBudget productObservableLipBudget raisedNiltestBudget + positivity + refine ⟨B, ?_, fun j => (hB j).mono le_rfl (by linarith), hBsum, hsupport⟩ + calc + _ = (Fintype.card I : ℝ) * q := by rw [Fintype.card_prod, ZMod.card, Nat.cast_mul] + _ ≤ Real.exp p * Real.exp p := mul_le_mul hcard hq (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = Real.exp (2 * p) := by rw [← Real.exp_add, two_mul] + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +theorem exists_fixed_observation_residue_partition (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι : Type} [Fintype ι] [DecidableEq ι] + {L : ι → Type} [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + {d : ι → ℕ} (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (g : ∀ i, (D i).filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (q N : ℕ) [NeZero q] [NeZero N] {p ρ : ℝ}, + 1 ≤ s → 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (∀ i, (D i).GeometryComplexityLE p) → + (q : ℝ) ≤ Real.exp p → 0 < ρ → 1 / ρ ≤ Real.exp ((p + 2) ^ a) → + ∃ n : ℕ, 0 < n ∧ ((n * q : ℕ) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ A : (Fin n × ZMod q) → ZMod N → ℝ, + (∀ j, PositiveCyclicNiltest.{0} s N ((p + C) ^ C) (A j)) ∧ + (∀ x, ∑ j, A j x = 1) ∧ + (∀ j x, 0 < A j x → (x.val : ZMod q) = j.2) ∧ + (letI : ∀ i, MetricSpace (D i).Space := fun i => (D i).metricSpace + ∀ j x y, 0 < A j x → 0 < A j y → ∀ i, + dist ((D i).cyclicOrbitPoint (g i) N (fun _ : Unit => x)) + ((D i).cyclicOrbitPoint (g i) N (fun _ : Unit => y)) ≤ ρ) := by + obtain ⟨B, _, hpartition⟩ := exists_fixed_observation_partition.{0, 0} s a + obtain ⟨R, _, hrefine⟩ := exists_controlled_residue_refinement + let X : Polynomial ℕ := Polynomial.X + let T := X + (X + Polynomial.C B) ^ B + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (T + (T + Polynomial.C R) ^ R) + refine ⟨C, hC, ?_⟩ + intro ι _ _ L _ _ _ _ _ _ _ _ _ _ d D g q N _ _ p ρ hs hp hι hD hq hρ hρinv + obtain ⟨n, hn, hnb, A, hA, hsum, hdiam⟩ := hpartition D g N hp hι hD hρ hρinv + let t := p + (p + B) ^ B + have hpt : p ≤ t := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have ht : 0 ≤ t := hp.trans hpt + have hBt : (p + B) ^ B ≤ t := le_add_of_nonneg_left hp + obtain ⟨U, hcount, hU, hUsum, hsupport⟩ := hrefine (q := q) A ht hs + (by simpa only [Fintype.card_fin] using hnb.trans (Real.exp_le_exp.mpr hBt)) + (hq.trans (Real.exp_le_exp.mpr hpt)) (fun j => (hA j).mono le_rfl hBt) hsum + have hsumcost : t + (t + R) ^ R ≤ (p + C) ^ C := by + simpa [T, X, t, Polynomial.eval₂_pow] using hbudget p hp + have hcost : (t + R) ^ R ≤ (p + C) ^ C := (le_add_of_nonneg_left ht).trans hsumcost + refine ⟨n, hn, ?_, U, fun j => (hU j).mono le_rfl hcost, hUsum, + fun j x hx => (hsupport j x hx).2, ?_⟩ + · simpa only [Fintype.card_prod, Fintype.card_fin, ZMod.card] using + hcount.trans (Real.exp_le_exp.mpr hcost) + · let : ∀ i, MetricSpace (D i).Space := fun i => (D i).metricSpace + intro j x y hx hy i + exact hdiam j.1 x y (hsupport j x hx).1 (hsupport j y hy).1 i + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +theorem exists_fixed_shifted_residue_partition (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι : Type} [Fintype ι] [DecidableEq ι] + {L : ι → Type} [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + {d : ι → ℕ} (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (g : ∀ i, (D i).filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (q N : ℕ) [NeZero q] [NeZero N] {p ρ : ℝ}, + 1 ≤ s → 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (∀ i, (D i).GeometryComplexityLE p) → + (q : ℝ) ≤ Real.exp p → 0 < ρ → 1 / ρ ≤ Real.exp ((p + 2) ^ a) → + ∃ n : ℕ, 0 < n ∧ ((n * q : ℕ) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ A : (Fin n × ZMod q) → ZMod N → ℝ, + (∀ j, PositiveCyclicNiltest.{0} s N ((p + C) ^ C) (A j)) ∧ + (∀ x, ∑ j, A j x = 1) ∧ + (∀ j x, 0 < A j x → (x.val : ZMod q) = j.2) ∧ + (letI : ∀ i, MetricSpace (D i).Space := fun i => (D i).metricSpace + ∀ j x y, 0 < A j x → 0 < A j y → ∀ i (t : ℤ), |t| ≤ 1 → + dist ((D i).integerOrbitPoint (g i) ((x.val : ℤ) + t * N)) + ((D i).integerOrbitPoint (g i) ((y.val : ℤ) + t * N)) ≤ ρ) := by + obtain ⟨B, _, hpartition⟩ := exists_fixed_shifted_observation_partition s a + obtain ⟨R, _, hrefine⟩ := exists_controlled_residue_refinement + let X : Polynomial ℕ := Polynomial.X + let T := X + (X + Polynomial.C B) ^ B + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (T + (T + Polynomial.C R) ^ R) + refine ⟨C, hC, ?_⟩ + intro ι _ _ L _ _ _ _ _ _ d D g q N _ _ p ρ hs hp hι hD hq hρ hρinv + obtain ⟨n, hn, hnb, A, hA, hsum, hdiam⟩ := hpartition D g N hp hι hD hρ hρinv + let t := p + (p + B) ^ B + have hpt : p ≤ t := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have ht : 0 ≤ t := hp.trans hpt + have hBt : (p + B) ^ B ≤ t := le_add_of_nonneg_left hp + obtain ⟨U, hcount, hU, hUsum, hsupport⟩ := hrefine (q := q) A ht hs + (by simpa only [Fintype.card_fin] using hnb.trans (Real.exp_le_exp.mpr hBt)) + (hq.trans (Real.exp_le_exp.mpr hpt)) (fun j => (hA j).mono le_rfl hBt) hsum + have hsumcost : t + (t + R) ^ R ≤ (p + C) ^ C := by + simpa [T, X, t, Polynomial.eval₂_pow] using hbudget p hp + have hcost : (t + R) ^ R ≤ (p + C) ^ C := (le_add_of_nonneg_left ht).trans hsumcost + refine ⟨n, hn, ?_, U, fun j => (hU j).mono le_rfl hcost, hUsum, + fun j x hx => (hsupport j x hx).2, ?_⟩ + · simpa only [Fintype.card_prod, Fintype.card_fin, ZMod.card] using + hcount.trans (Real.exp_le_exp.mpr hcost) + · let : ∀ i, MetricSpace (D i).Space := fun i => (D i).metricSpace + intro j x y hx hy i t ht + exact hdiam j.1 x y (hsupport j x hx).1 (hsupport j y hy).1 i t ht + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_interval_residue_partition (a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (N M : ℕ) [NeZero N] [NeZero M] {p ρ : ℝ}, + 0 ≤ p → (M : ℝ) ≤ Real.exp p → 0 < ρ → + 1 / ρ ≤ Real.exp ((p + 2) ^ a) → + ∃ n : ℕ, 0 < n ∧ (Fintype.card (Fin n × ZMod M) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ A : (Fin n × ZMod M) → ZMod N → ℝ, + (∀ j, PositiveCyclicNiltest.{0} 1 N ((p + C) ^ C) (A j)) ∧ + (∀ x, ∑ j, A j x = 1) ∧ + ∀ j x y, x ∉ cyclicWrapExceptional 0 ρ → y ∉ cyclicWrapExceptional 0 ρ → + 0 < A j x → 0 < A j y → + |(x.val : ℝ) - y.val| ≤ N * ρ ∧ (M : ℤ) ∣ (x.val : ℤ) - y.val := by + obtain ⟨b, _, hpart⟩ := exists_interval_circle_partition a + obtain ⟨c, _, hrefine⟩ := exists_controlled_residue_refinement + let B : Polynomial ℕ := Polynomial.X + (Polynomial.X + Polynomial.C b) ^ b + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((B + Polynomial.C c) ^ c) + refine ⟨C, hC, ?_⟩ + intro N M _ _ p ρ hp hM hρ hprec + classical + obtain ⟨n, hn, hnb, V, hV, hsum, hdiam⟩ := hpart N hp hρ hprec + let t := p + (p + b) ^ b + have hpt : p ≤ t := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have hbt : (p + b) ^ b ≤ t := le_add_of_nonneg_left hp + have hcost : (t + c) ^ c ≤ (p + C) ^ C := by + simpa [B, t, Polynomial.eval₂_pow] using hbudget p hp + obtain ⟨A, hcard, hA, hAsum, hsupport⟩ := hrefine V (hp.trans hpt) le_rfl + (by simpa only [Fintype.card_fin] using hnb.trans (Real.exp_le_exp.mpr hbt)) + (hM.trans (Real.exp_le_exp.mpr hpt)) (fun j => (hV j).mono le_rfl hbt) hsum + refine ⟨n, hn, hcard.trans (Real.exp_le_exp.mpr hcost), A, + fun j => (hA j).mono le_rfl hcost, hAsum, ?_⟩ + intro j x y hx hy hAx hAy + obtain ⟨hVx, hMx⟩ := hsupport j x hAx + obtain ⟨hVy, hMy⟩ := hsupport j y hAy + have hnear := good_circle_observations_control_representatives 0 x y hρ hx hy + (hdiam j.1 x y hVx hVy) + have hN : (0 : ℝ) < N := Nat.cast_pos.mpr (NeZero.pos N) + rw [← sub_div, abs_div, abs_of_pos hN] at hnear + refine ⟨by simpa only [mul_comm] using (div_le_iff₀ hN).mp hnear, ?_⟩ + apply (ZMod.intCast_zmod_eq_zero_iff_dvd ((x.val : ℤ) - y.val) M).mp + push_cast + rw [hMx, hMy, sub_self] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeJointAffineGraphRecovery.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeJointAffineGraphRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cfbcc09df80f285f8a05b9802dd9ca4631be479 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeJointAffineGraphRecovery.lean @@ -0,0 +1,79 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeRoundedCyclicModel + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped BigOperators Pointwise +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem joint_affine_graph_recovery {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (l : I → ℕ) (hl : ∀ i, 0 < l i) + (ε : I → ℝ) (hε : ∀ i, 0 < ε i) (hsmall : ∀ i, 2 * (l i : ℝ) * ε i ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ coordinateDenominatorGrid l, + ∀ i, |c i + (a (rankQuadrupleParameters t 1) i + a (rankQuadrupleParameters t 2) i - + a (rankQuadrupleParameters t 0) i - a (rankQuadrupleParameters t 3) i) - q i| ≤ ε i) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + ∃ M : I → ℕ, (∀ i, 0 < M i) ∧ + (∀ i, (M i : ℝ) * l i * ε i ≤ 1) ∧ + (∀ i, 1 / ((M i : ℝ) * l i) ≤ 2 * ε i) ∧ + ∃ J' ⊆ H, J'.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J'.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) + (Φ : (Fin r → ℤ) →+ (ZMod N × (∀ i, ZMod (M i)))) + (base : ZMod N × (∀ i, ZMod (M i))), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + Set.InjOn Φ {x | ∀ i, |x i| ≤ (R i : ℤ)} ∧ + (let ψ := (AddMonoidHom.snd (ZMod N) (∀ i, ZMod (M i))).comp Φ + let α := variableCoefficientLift l base.2 + let β := fun j => variableCoefficientLift l (ψ (Pi.single j 1)) + (∀ i, α i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + (∀ j i, β j i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + ∀ h ∈ J', ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ + (h, variableRoundedCoefficient M l (a h)) = base + Φ x ∧ + (∀ y : Fin r → ℤ, (∀ i, |y i| ≤ (R i : ℤ)) → + (h, variableRoundedCoefficient M l (a h)) = base + Φ y → y = x) ∧ + ∃ q ∈ coordinateDenominatorGrid l, ∀ i, + |a h i - (α + ∑ j, (x j : ℝ) • β j) i - q i| ≤ 2 * ε i) := by + intro K z δ + obtain ⟨M, hM, hMsmall, hMerror⟩ := exists_coordinate_rounding_moduli l hl ε hε hsmall + let _ : ∀ i, NeZero (M i) := fun i => ⟨(hM i).ne'⟩ + obtain ⟨J', hJH, hJ, hsize, r, R, Φ, base, hrank, hinj, hrepr⟩ := + D.variable_graph_affine_model a c M l ε hMsmall hnear + refine ⟨M, hM, hMsmall, hMerror, J', hJH, hJ, hsize, r, R, Φ, base, + hrank, hinj, ?_⟩ + dsimp only + refine ⟨variableCoefficientLift_mem_Ico l hl base.2, ?_, ?_⟩ + · intro j + exact variableCoefficientLift_mem_Ico l hl _ + · intro h hh + obtain ⟨x, hx, heq⟩ := hrepr h hh + refine ⟨x, hx, heq, ?_, ?_⟩ + · intro y hy hey + exact hinj hy hx (add_left_cancel (hey.symm.trans heq)) + · obtain ⟨q, hq, herr⟩ := exists_variable_unrounded_affine l hl base.2 + ((AddMonoidHom.snd (ZMod N) (∀ i, ZMod (M i))).comp Φ) x (a h) + (congrArg Prod.snd heq) + exact ⟨q, hq, fun i => (herr i).trans (hMerror i)⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeJointAffineRecovery.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeJointAffineRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..d567f78eafd35217c3b7b84b4c052f11c617065d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeJointAffineRecovery.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeRoundedCyclicModel + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped BigOperators Pointwise +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem joint_affine_recovery {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (l : I → ℕ) (hl : ∀ i, 0 < l i) + (ε : I → ℝ) (hε : ∀ i, 0 < ε i) (hsmall : ∀ i, 2 * (l i : ℝ) * ε i ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ coordinateDenominatorGrid l, + ∀ i, |c i + (a (rankQuadrupleParameters t 1) i + a (rankQuadrupleParameters t 2) i - + a (rankQuadrupleParameters t 0) i - a (rankQuadrupleParameters t 3) i) - q i| ≤ ε i) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + ∃ J' ⊆ H, J'.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J'.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) (ξ : (Fin r → ℤ) →+ ZMod N) + (h₀ : ZMod N) (α : I → ℝ) (β : Fin r → I → ℝ), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + (∀ i, α i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + (∀ j i, β j i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + ∀ h ∈ J', ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + ξ x ∧ + ∃ q ∈ coordinateDenominatorGrid l, ∀ i, + |a h i - (α + ∑ j, (x j : ℝ) • β j) i - q i| ≤ 2 * ε i := by + intro K z δ + obtain ⟨M, hM, hMsmall, hMerror⟩ := exists_coordinate_rounding_moduli l hl ε hε hsmall + let _ : ∀ i, NeZero (M i) := fun i => ⟨(hM i).ne'⟩ + obtain ⟨J', hJH, hJ, hsize, r, R, Φ, base, hrank, _hinj, hrepr⟩ := + D.variable_graph_affine_model a c M l ε hMsmall hnear + let ξ := (AddMonoidHom.fst (ZMod N) (∀ i, ZMod (M i))).comp Φ + let ψ := (AddMonoidHom.snd (ZMod N) (∀ i, ZMod (M i))).comp Φ + refine ⟨J', hJH, hJ, hsize, r, R, ξ, base.1, variableCoefficientLift l base.2, + (fun j => variableCoefficientLift l (ψ (Pi.single j 1))), hrank, ?_, ?_, ?_⟩ + · exact variableCoefficientLift_mem_Ico l hl base.2 + · intro j + exact variableCoefficientLift_mem_Ico l hl (ψ (Pi.single j 1)) + · intro h hh + obtain ⟨x, hx, heq⟩ := hrepr h hh + obtain ⟨q, hq, herr⟩ := exists_variable_unrounded_affine l hl base.2 ψ x (a h) + (congrArg Prod.snd heq) + exact ⟨x, hx, congrArg Prod.fst heq, q, hq, fun i => (herr i).trans (hMerror i)⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativePairAffineCellStepDrop.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativePairAffineCellStepDrop.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dba32ea3becf3995f841c7f1d16f56d6925da18 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativePairAffineCellStepDrop.lean @@ -0,0 +1,279 @@ +import OAI.Combinatorics.Progressions.Estimates.JoinedPairQuotientRefiltration + +namespace OAI + +universe u + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module VectorPolynomial +open scoped TensorProduct BigOperators + +variable {L M : Type u} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d e : ℕ} (D : RationalFilteredNilmanifold L s d) + (E : RationalFilteredNilmanifold M s e) + {σ τ ι : Type*} + +theorem pairOrbit_substitute_log {w : σ → ℕ} {v : τ → ℕ} + (p : D.filtration.realification.PolynomialOrbit w) + (q : E.filtration.realification.PolynomialOrbit w) + (f : σ → MvPolynomial τ ℚ) (hf : ∀ i, f i ∈ weightedSupportLE v (w i)) : + (pairOrbit D E + (D.filtration.realification.polynomialOrbitSubstitute f hf p) + (E.filtration.realification.polynomialOrbitSubstitute f hf q)).log = + VectorPolynomial.substitute f (pairOrbit D E p q).log := by + simp only [pairOrbit, NilpotentLieFiltration.piRealOrbit, + NilpotentLieFiltration.PolynomialOrbit.log, NilpotentLieFiltration.polynomialOrbitOfLog, map_sum] + apply Finset.sum_congr rfl + intro i _ + cases i <;> exact VectorPolynomial.map_substitute f _ _ + +theorem pairOrbitSymbol_scalarAffine_substitute + (p : D.filtration.realification.PolynomialOrbit (fun _ : σ => 1)) + (q : E.filtration.realification.PolynomialOrbit (fun _ : σ => 1)) + (b : Basis ι ℚ (PairAlgebra L M)) (ω : ι → ℕ) + (hF : ∀ k, (pi (pairModels D E)).filtration.layer k = + Submodule.span ℚ (b '' {i | k ≤ ω i})) + (r : ℚ) (shift : σ → ℚ) : + pairOrbitSymbol D E + (D.filtration.realification.polynomialOrbitSubstitute + (scalarAffinePolynomial r shift) (scalarAffinePolynomial_support r shift) p) + (E.filtration.realification.polynomialOrbitSubstitute + (scalarAffinePolynomial r shift) (scalarAffinePolynomial_support r shift) q) b ω hF = + (pi (pairModels D E)).filtration.realPolynomialSymbolDilationHom (fun _ => 1) r + (pairOrbitSymbol D E p q b ω hF) := by + apply NilpotentLieBCHGroup.ext + change (pi (pairModels D E)).filtration.realSymbolOfPolynomial b ω hF (fun _ => 1) + (pairOrbit D E _ _).log = + (pi (pairModels D E)).filtration.realPolynomialSymbolDilation (fun _ => 1) r + ((pi (pairModels D E)).filtration.realSymbolOfPolynomial b ω hF (fun _ => 1) + (pairOrbit D E p q).log) + rw [pairOrbit_substitute_log, VectorPolynomial.substitute_scalarAffinePolynomial] + apply NilpotentLieFiltration.realSymbolOfPolynomial_affine + · exact fun _ => Nat.zero_lt_one + · exact (pairOrbit D E p q).adapted + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + +theorem pairOrbitSymbol_scalarAffinePullback + (V : D.Niltest (fun _ : σ => 1)) (W : E.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ (PairAlgebra L M)) (ω : ι → ℕ) + (hF : ∀ k, (pi (pairModels D E)).filtration.layer k = + Submodule.span ℚ (b '' {i | k ≤ ω i})) + (r : ℚ) (shift : σ → ℚ) : + pairOrbitSymbol D E (V.scalarAffinePullback r shift).orbit + (W.scalarAffinePullback r shift).orbit b ω hF = + (pi (pairModels D E)).filtration.realPolynomialSymbolDilationHom (fun _ => 1) r + (pairOrbitSymbol D E V.orbit W.orbit b ω hF) := + pairOrbitSymbol_scalarAffine_substitute D E V.orbit W.orbit b ω hF r shift + +theorem pairOrbitSymbol_scalarAffinePullback_inverse_stride + (V : D.Niltest (fun _ : σ => 1)) (W : E.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ (PairAlgebra L M)) (ω : ι → ℕ) + (hF : ∀ k, (pi (pairModels D E)).filtration.layer k = + Submodule.span ℚ (b '' {i | k ≤ ω i})) + (Q : ℕ) (hQ : 0 < Q) (shift : σ → ℚ) : + (pi (pairModels D E)).filtration.realPolynomialSymbolDilationHom (fun _ => 1) ((Q : ℚ)⁻¹) + (pairOrbitSymbol D E (V.scalarAffinePullback Q shift).orbit + (W.scalarAffinePullback Q shift).orbit b ω hF) = + pairOrbitSymbol D E V.orbit W.orbit b ω hF := by + rw [pairOrbitSymbol_scalarAffinePullback] + apply NilpotentLieBCHGroup.ext + simp only [NilpotentLieFiltration.realPolynomialSymbolDilationHom_coord, + ← NilpotentLieFiltration.realPolynomialSymbolDilation_mul, + inv_mul_cancel₀ (show (Q : ℚ) ≠ 0 by exact_mod_cast hQ.ne'), + NilpotentLieFiltration.realPolynomialSymbolDilation_one] + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem ControlledSymbolFactorizationAtFast.dilate_ratio + {η : L →ₗ[ℚ] ℚ} {S T : σ → ℝ} + {X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)} {p q r : ℝ} + {U : LieSubalgebra ℚ F.AssociatedGraded} + (h : F.ControlledSymbolFactorizationAtFast b ω hF η S X p U) + (a : ℤ) (d : ℕ) (ha : a ≠ 0) (hd : 0 < d) + (hS : ∀ i, 0 < S i) (hT : ∀ i, 0 < T i) (hq : 0 ≤ q) (hr : 0 ≤ r) + (hdr : (d : ℝ) ≤ Real.exp r) + (hphysical : ∀ i, Real.exp (-q) * (|(((a : ℚ) / d : ℚ) : ℝ)| * T i) ≤ S i) : + F.ControlledSymbolFactorizationAtFast b ω hF η T + (F.realPolynomialSymbolDilationHom (fun _ => 1) ((a : ℚ) / d) X) + (p + (s : ℝ) * (q + r)) U := by + obtain ⟨m, E, P, R, v, hm, hmp, hprod, hE, hR, hv, hgraded, hh, hzero, hP⟩ := h + have hf : F.SymbolFactorizationIn b ω hF S X p m U := + ⟨E, P, R, hprod, hE, hR, hP⟩ + have hcost : p + (s : ℝ) * q ≤ p + (s : ℝ) * (q + r) := by + have := mul_nonneg (Nat.cast_nonneg s : (0 : ℝ) ≤ s) hr + nlinarith + have hp : p ≤ p + (s : ℝ) * (q + r) := le_add_of_nonneg_right (by positivity) + obtain ⟨E', P', R', hprod', hE', hR', hP'⟩ := + (SymbolFactorizationIn.dilate_ratio F b ω hF hf a d ha hd hS hT hq hphysical).mono + F b ω hF hcost hT + refine ⟨m * d ^ s, E', P', R', v, Nat.mul_pos hm (pow_pos hd _), ?_, hprod', + hE', hR', hv, hgraded, (fun i j => (hh i j).trans hp), hzero, hP'⟩ + calc + ((m * d ^ s : ℕ) : ℝ) = (m : ℝ) * (d : ℝ) ^ s := by push_cast; rfl + _ ≤ Real.exp p * (Real.exp r) ^ s := + mul_le_mul hmp (pow_le_pow_left₀ (Nat.cast_nonneg d) hdr s) + (by positivity) (Real.exp_pos p).le + _ = Real.exp (p + (s : ℝ) * r) := by rw [← Real.exp_nat_mul, Real.exp_add] + _ ≤ Real.exp (p + (s : ℝ) * (q + r)) := by + apply Real.exp_le_exp.mpr + have := mul_nonneg (Nat.cast_nonneg s : (0 : ℝ) ≤ s) hq + nlinarith + +theorem ControlledSymbolFactorization.dilate_ratio + {η : L →ₗ[ℚ] ℚ} {S T : σ → ℝ} + {X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)} {p q r : ℝ} + (h : F.ControlledSymbolFactorization b ω hF η S X p) + (a : ℤ) (d : ℕ) (ha : a ≠ 0) (hd : 0 < d) + (hS : ∀ i, 0 < S i) (hT : ∀ i, 0 < T i) (hq : 0 ≤ q) (hr : 0 ≤ r) + (hdr : (d : ℝ) ≤ Real.exp r) + (hphysical : ∀ i, Real.exp (-q) * (|(((a : ℚ) / d : ℚ) : ℝ)| * T i) ≤ S i) : + F.ControlledSymbolFactorization b ω hF η T + (F.realPolynomialSymbolDilationHom (fun _ => 1) ((a : ℚ) / d) X) + (p + (s : ℝ) * (q + r)) := by + obtain ⟨U, hU⟩ := h.exists_fastWitness F b ω hF + obtain ⟨m, E, P, R, v, hdata⟩ := + hU.dilate_ratio F b ω hF a d ha hd hS hT hq hr hdr hphysical + exact ⟨m, E, P, R, U, v, hdata⟩ + +end Erdos3.NilpotentLieFiltration + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +theorem scalarAffineCell_controlled_factorization_to_original + (T : D.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (Q : ℕ) (hQ : 0 < Q) (shift : σ → ℚ) + {η : L →ₗ[ℚ] ℚ} {S H : σ → ℝ} {p q r : ℝ} + (h : D.filtration.ControlledSymbolFactorization b ω hF η S + ((T.scalarAffinePullback Q shift).symbol b ω hF) p) + (hS : ∀ i, 0 < S i) (hH : ∀ i, 0 < H i) (hq : 0 ≤ q) (hr : 0 ≤ r) + (hQr : (Q : ℝ) ≤ Real.exp r) + (hphysical : ∀ i, Real.exp (-q) * (H i / (Q : ℝ)) ≤ S i) : + D.filtration.ControlledSymbolFactorization b ω hF η H (T.symbol b ω hF) + (p + (s : ℝ) * (q + r)) := by + have hQreal : (0 : ℝ) < Q := by exact_mod_cast hQ + have hratio (i : σ) : + Real.exp (-q) * (|(((1 : ℚ) / Q : ℚ) : ℝ)| * H i) ≤ S i := by + convert hphysical i using 1 + push_cast + rw [abs_div, abs_one, abs_of_pos hQreal] + ring + have hf := h.dilate_ratio D.filtration b ω hF 1 Q (by norm_num) hQ hS hH hq hr hQr hratio + rw [Int.cast_one, one_div, + T.scalarAffinePullback_symbol_inverse_stride b ω hF Q hQ shift] at hf + exact hf + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +theorem exists_native_pair_affine_cell_step_drop (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ : Type*} [Fintype σ] [DecidableEq σ] + {L M : Type u} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {d e : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M s e) + (V : D.Niltest (fun _ : σ => 1)) (W : E.Niltest (fun _ : σ => 1)) + {p q r : ℝ} (_hp : 2 ≤ p) (_hq : 0 ≤ q) (_hr : 0 ≤ r) + (_hV : V.ComplexityLE p) (_hW : W.ComplexityLE p) + (Q : ℕ) (_hQ : 0 < Q) (_hQr : (Q : ℝ) ≤ Real.exp r) (shift : σ → ℤ) + (η : L →ₗ[ℚ] ℚ) (θ : M →ₗ[ℚ] ℚ) + (_hηheight : ∀ i, rationalLogHeight (η (D.basis i)) ≤ p) + (_hθheight : ∀ i, rationalLogHeight (θ (E.basis i)) ≤ p) + (_hη : ∀ z, z ∈ D.filtration.realification.subgroup s → ∀ x, + V.observable (z • x) = CircleFourier.character + ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * V.observable x) + (_hθ : ∀ z, z ∈ E.filtration.realification.subgroup s → ∀ x, + W.observable (z • x) = CircleFourier.character + ((realifyFunctional θ z.coord : ℝ) : CircleFourier.Circle) * W.observable x) + (origin : σ → ℤ) (lengths : σ → ℕ) (H : σ → ℝ) + (_hlen : ∀ i, 0 < lengths i) (_hH : ∀ i, 0 < H i) + (_hσ : (Fintype.card σ : ℝ) ≤ p) + (_hlarge : ∀ i, Real.exp ((p + C) ^ C) ≤ (lengths i : ℝ)) + (_hphysical : ∀ i, Real.exp (-q) * (H i / (Q : ℝ)) ≤ lengths i) + (_hbias : Real.exp (-p) ≤ ‖𝔼 x ∈ translatedIntegerBox origin lengths, + V.eval (fun i => (Q : ℤ) * x i + shift i) * + W.eval (fun i => (Q : ℤ) * x i + shift i)‖), + ∃ (b : Basis (Fin (finrank ℚ (PairAlgebra L M))) ℚ (PairAlgebra L M)) + (ω : Fin (finrank ℚ (PairAlgebra L M)) → ℕ) + (hF : ∀ k, (pi (pairModels D E)).filtration.layer k = + Submodule.span ℚ (b '' {i | k ≤ ω i})), + (∀ i j, rationalLogHeight ((pi (pairModels D E)).basis.repr (b i) j) ≤ (p + C) ^ C) ∧ + (pi (pairModels D E)).filtration.ControlledSymbolFactorization b ω hF + (pairFrequency η θ) H (pairOrbitSymbol D E V.orbit W.orbit b ω hF) + ((p + C) ^ C + (s : ℝ) * (q + r)) := by + obtain ⟨C, hC, hstep⟩ := exists_native_pair_positive_step_drop s hs + refine ⟨C, hC, ?_⟩ + intro σ _ _ L M _ _ _ _ d e _ _ _ _ _ _ _ _ D E V W p q r hp hq hr hV hW + Q hQ hQr shift η θ hηheight hθheight hη hθ origin lengths H hlen hH hσ hlarge hphysical hbias + let V' := V.scalarAffinePullback (Q : ℚ) (fun i => (shift i : ℚ)) + let W' := W.scalarAffinePullback (Q : ℚ) (fun i => (shift i : ℚ)) + have hV' : V'.ComplexityLE p := hV + have hW' : W'.ComplexityLE p := hW + obtain ⟨b, ω, hF, hb, hfactor⟩ := hstep D E V' W' hp hV' hW' + have hevalV (x : σ → ℤ) : V'.eval x = + V.eval (fun i => (Q : ℤ) * x i + shift i) := by + exact_mod_cast V.scalarAffinePullback_eval_integer (Q : ℤ) shift x + have hevalW (x : σ → ℤ) : W'.eval x = + W.eval (fun i => (Q : ℤ) * x i + shift i) := by + exact_mod_cast W.scalarAffinePullback_eval_integer (Q : ℤ) shift x + have hc := hfactor η θ hηheight hθheight hη hθ origin lengths hlen hσ hlarge + (by simpa only [hevalV, hevalW] using hbias) + have hQreal : (0 : ℝ) < Q := by exact_mod_cast hQ + have hratio (i : σ) : + Real.exp (-q) * (|(((1 : ℚ) / Q : ℚ) : ℝ)| * H i) ≤ (lengths i : ℝ) := by + convert hphysical i using 1 + push_cast + rw [abs_div, abs_one, abs_of_pos hQreal] + ring + have hf := hc.dilate_ratio (pi (pairModels D E)).filtration b ω hF 1 Q + (by norm_num) hQ (fun i => by exact_mod_cast hlen i) hH hq hr hQr hratio + refine ⟨b, ω, hF, hb, ?_⟩ + + simpa only [Int.cast_one, one_div, V', W', + pairOrbitSymbol_scalarAffinePullback_inverse_stride D E V W b ω hF Q hQ + (fun i => (shift i : ℚ))] using hf + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeProperAffineRecovery.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeProperAffineRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..51ede599847066118dbfdeafbeede56e29fb327b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeProperAffineRecovery.lean @@ -0,0 +1,871 @@ +import OAI.Combinatorics.Progressions.Estimates.CyclicProgressionHom +import OAI.Combinatorics.Progressions.Estimates.DenseCyclicFreimanModel +import OAI.Combinatorics.Progressions.Estimates.DenseTranslate +import OAI.Combinatorics.Progressions.Estimates.FreimanFivefoldCardinality +import OAI.Combinatorics.Progressions.Estimates.NativeGraphSmallDifference +import OAI.Combinatorics.Progressions.Geometry.VariableRoundedGraphCoordinates +import OAI.Combinatorics.Progressions.Lattices.IntegerVectorFreimanEmbedding +import OAI.Combinatorics.Progressions.Lattices.ProperAffineBoxRestriction +import OAI.Combinatorics.Progressions.Lattices.SharedFreeAffineBudget + +namespace OAI + +section + +namespace Erdos3.FreimanModel + +def residueBlock {q : ℕ} [NeZero q] (x : ZMod q) : Fin 16 := by + refine ⟨x.val / (q / 16 + 1), ?_⟩ + apply (Nat.div_lt_iff_lt_mul (Nat.succ_pos _)).mpr + exact x.val_lt.trans (Nat.lt_mul_div_succ q (by decide)) + +def residueLift {q : ℕ} (x : ZMod q) : ℤ := x.val + +theorem residueBlock_bounds {q : ℕ} [NeZero q] {x : ZMod q} {c : Fin 16} + (hc : residueBlock x = c) : + c.val * (q / 16 + 1) ≤ x.val ∧ + x.val ≤ c.val * (q / 16 + 1) + q / 16 := by + have hdiv : x.val / (q / 16 + 1) = c.val := congrArg Fin.val hc + have hmod := Nat.mod_lt x.val (Nat.succ_pos (q / 16)) + have hrem : x.val % (q / 16 + 1) ≤ q / 16 := Nat.le_of_lt_succ hmod + have hid := Nat.mod_add_div x.val (q / 16 + 1) + rw [hdiv, Nat.mul_comm (q / 16 + 1)] at hid + omega + +theorem residueLift_sum_cast {q : ℕ} [NeZero q] (T : Multiset (ZMod q)) : + (((T.map residueLift).sum : ℤ) : ZMod q) = T.sum := by + induction T using Multiset.induction_on with + | empty => simp + | @cons x T ih => + simp only [Multiset.map_cons, Multiset.sum_cons, Int.cast_add, ih] + simp [residueLift] + +theorem residueLift_sum_bounds {q : ℕ} [NeZero q] {c : Fin 16} + (T : Multiset (ZMod q)) (hT : T.card = 8) + (hc : ∀ x ∈ T, residueBlock x = c) : + (8 : ℤ) * (c.val * (q / 16 + 1) : ℕ) ≤ (T.map residueLift).sum ∧ + (T.map residueLift).sum ≤ + (8 : ℤ) * ((c.val * (q / 16 + 1) : ℕ) + (q / 16 : ℕ)) := by + have hlo := Multiset.card_nsmul_le_sum + (s := T.map residueLift) (a := ((c.val * (q / 16 + 1) : ℕ) : ℤ)) (by + intro y hy + obtain ⟨x, hx, rfl⟩ := Multiset.mem_map.mp hy + change ((c.val * (q / 16 + 1) : ℕ) : ℤ) ≤ (x.val : ℤ) + exact_mod_cast (residueBlock_bounds (hc x hx)).1) + have hhi := Multiset.sum_le_card_nsmul + (s := T.map residueLift) (n := (((c.val * (q / 16 + 1) : ℕ) + (q / 16 : ℕ)) : ℤ)) (by + intro y hy + obtain ⟨x, hx, rfl⟩ := Multiset.mem_map.mp hy + change (x.val : ℤ) ≤ (((c.val * (q / 16 + 1) : ℕ) + (q / 16 : ℕ)) : ℤ) + exact_mod_cast (residueBlock_bounds (hc x hx)).2) + simpa only [Multiset.card_map, hT, nsmul_eq_mul, Nat.cast_add, Nat.cast_ofNat] + using And.intro hlo hhi + +theorem residueLift_sum_sub_abs_lt {q : ℕ} [NeZero q] {c : Fin 16} + (T U : Multiset (ZMod q)) (hT : T.card = 8) (hU : U.card = 8) + (hcT : ∀ x ∈ T, residueBlock x = c) (hcU : ∀ x ∈ U, residueBlock x = c) : + |(T.map residueLift).sum - (U.map residueLift).sum| < (q : ℤ) := by + obtain ⟨hTlo, hThi⟩ := residueLift_sum_bounds T hT hcT + obtain ⟨hUlo, hUhi⟩ := residueLift_sum_bounds U hU hcU + have hdiv : (16 : ℤ) * (q / 16 : ℕ) ≤ q := by + exact_mod_cast Nat.mul_div_le q 16 + have hq : (0 : ℤ) < q := by exact_mod_cast NeZero.pos q + rw [abs_lt] + constructor <;> omega + +theorem residueLift_sum_eq_iff {q : ℕ} [NeZero q] {c : Fin 16} + (T U : Multiset (ZMod q)) (hT : T.card = 8) (hU : U.card = 8) + (hcT : ∀ x ∈ T, residueBlock x = c) (hcU : ∀ x ∈ U, residueBlock x = c) : + (T.map residueLift).sum = (U.map residueLift).sum ↔ T.sum = U.sum := by + constructor + · intro h + simpa only [residueLift_sum_cast] using congrArg (fun z : ℤ => (z : ZMod q)) h + · intro h + have hsmall := abs_lt.mp (residueLift_sum_sub_abs_lt T U hT hU hcT hcU) + have hdiv : (q : ℤ) ∣ (T.map residueLift).sum - (U.map residueLift).sum := by + apply (ZMod.intCast_zmod_eq_zero_iff_dvd _ q).mp + rw [Int.cast_sub, residueLift_sum_cast, residueLift_sum_cast, h, sub_self] + apply sub_eq_zero.mp + apply Int.eq_zero_of_dvd_of_natAbs_lt_natAbs hdiv + simpa only [Int.natAbs_natCast] using + int_natAbs_lt_of_neg_lt_and_lt hsmall.1 hsmall.2 + +end Erdos3.FreimanModel + +end + +section + +namespace Erdos3.FreimanModel + +variable {I : Type*} (q : I → ℕ) [∀ i, NeZero (q i)] + +def cyclicProductLift (x : ∀ i, ZMod (q i)) : I → ℤ := fun i => residueLift (x i) + +def cyclicProductBlock (x : ∀ i, ZMod (q i)) : I → Fin 16 := fun i => residueBlock (x i) + +theorem cyclicProductLift_injective : Function.Injective (cyclicProductLift q) := by + intro x y h + funext i + have hi := congrArg (fun z : ℤ => (z : ZMod (q i))) (congrFun h i) + simpa [cyclicProductLift, residueLift] using hi + +omit [∀ i, NeZero (q i)] in +theorem cyclicProductLift_sum_apply (T : Multiset (∀ i, ZMod (q i))) (i : I) : + ((T.map (cyclicProductLift q)).sum) i = (T.map fun x => residueLift (x i)).sum := by + induction T using Multiset.induction_on with + | empty => simp + | @cons x T ih => simp [ih, cyclicProductLift] + +omit [∀ i, NeZero (q i)] in +theorem cyclicProduct_sum_apply (T : Multiset (∀ i, ZMod (q i))) (i : I) : + T.sum i = (T.map fun x => x i).sum := by + induction T using Multiset.induction_on with + | empty => simp + | @cons x T ih => simp [ih] + +theorem cyclicProductLift_sum_eq_iff {c : I → Fin 16} + (T U : Multiset (∀ i, ZMod (q i))) (hT : T.card = 8) (hU : U.card = 8) + (hcT : ∀ x ∈ T, cyclicProductBlock q x = c) + (hcU : ∀ x ∈ U, cyclicProductBlock q x = c) : + (T.map (cyclicProductLift q)).sum = (U.map (cyclicProductLift q)).sum ↔ T.sum = U.sum := by + have hi (i : I) : + ((T.map (cyclicProductLift q)).sum) i = ((U.map (cyclicProductLift q)).sum) i ↔ + T.sum i = U.sum i := by + rw [cyclicProductLift_sum_apply, cyclicProductLift_sum_apply, + cyclicProduct_sum_apply, cyclicProduct_sum_apply] + have ht : ∀ x ∈ T.map (fun x => x i), residueBlock x = c i := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Multiset.mem_map.mp hx + exact congrFun (hcT y hy) i + have hu : ∀ x ∈ U.map (fun x => x i), residueBlock x = c i := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Multiset.mem_map.mp hx + exact congrFun (hcU y hy) i + simpa only [Multiset.map_map, Function.comp_def] using + residueLift_sum_eq_iff (T.map fun x => x i) (U.map fun x => x i) + (by simpa only [Multiset.card_map] using hT) + (by simpa only [Multiset.card_map] using hU) ht hu + constructor + · intro h + funext i + exact (hi i).mp (congrFun h i) + · intro h + funext i + exact (hi i).mpr (congrFun h i) + +theorem isAddFreimanIso_cyclicProductLift [Fintype I] + (A : Finset (∀ i, ZMod (q i))) {c : I → Fin 16} + (hc : ∀ x ∈ A, cyclicProductBlock q x = c) : + IsAddFreimanIso 8 (A : Set _) (A.image (cyclicProductLift q) : Set (I → ℤ)) + (cyclicProductLift q) := by + refine ⟨⟨?_, (cyclicProductLift_injective q).injOn, ?_⟩, ?_⟩ + · intro x hx + exact Finset.mem_image.mpr ⟨x, hx, rfl⟩ + · intro x hx + exact Finset.mem_image.mp hx + · intro T U hTA hUA hT hU + exact cyclicProductLift_sum_eq_iff q T U hT hU + (fun x hx => hc x (hTA hx)) (fun x hx => hc x (hUA hx)) + +theorem exists_large_cyclicProduct_integer_lift [Fintype I] + (A : Finset (∀ i, ZMod (q i))) (hA : A.Nonempty) : + ∃ J : Finset (∀ i, ZMod (q i)), J.Nonempty ∧ J ⊆ A ∧ + A.card ≤ 16 ^ Fintype.card I * J.card ∧ + IsAddFreimanIso 8 (J : Set _) (J.image (cyclicProductLift q) : Set (I → ℤ)) + (cyclicProductLift q) := by + classical + obtain ⟨c, hJ, hsize⟩ := exists_nonempty_large_fiber A hA (cyclicProductBlock q) + let J := A.filter fun x => cyclicProductBlock q x = c + refine ⟨J, hJ, Finset.filter_subset _ _, ?_, ?_⟩ + · simpa only [Fintype.card_fun, Fintype.card_fin] using hsize + · apply isAddFreimanIso_cyclicProductLift q J + intro x hx + exact (Finset.mem_filter.mp hx).2 + +end Erdos3.FreimanModel + +end + +section + +namespace Erdos3.FreimanModel + +open scoped Pointwise + +theorem exists_dense_cyclic_model_of_integer_vectors {I : Type*} [Fintype I] + (A : Finset (I → ℤ)) (hA : A.Nonempty) {K : ℝ} (hK : 0 < K) + (hsmall : ((A - A).card : ℝ) ≤ K * A.card) (s : ℕ) (hs : 0 < s) : + ∃ (N : ℕ) (J : Finset (I → ℤ)) (B : Finset (ZMod N)) (f : (I → ℤ) → ZMod N), + 0 < N ∧ J.Nonempty ∧ J ⊆ A ∧ A.card ≤ (2 * s) * J.card ∧ + B.Nonempty ∧ B = J.image f ∧ B.card = J.card ∧ + IsAddFreimanIso s (J : Set _) (B : Set _) f ∧ + (N : ℝ) ≤ 2 * K ^ (2 * s) * A.card ∧ + (4 * (s : ℝ) * K ^ (2 * s))⁻¹ ≤ (B.card : ℝ) / N := by + classical + obtain ⟨e, he⟩ := exists_integer_freiman_embedding A s + let X := A.image e + have hX : X.Nonempty := hA.image e + have hXcard : X.card = A.card := Finset.card_image_of_injOn he.bijOn.injOn + have hXsmall : ((X - X).card : ℝ) ≤ K * X.card := by + have hdiff : X - X = (A - A).image e := by + ext z + simp only [X, Finset.mem_sub, Finset.mem_image] + constructor + · rintro ⟨_, ⟨x, hx, rfl⟩, _, ⟨y, hy, rfl⟩, rfl⟩ + exact ⟨x - y, ⟨x, hx, y, hy, rfl⟩, e.map_sub x y⟩ + · rintro ⟨_, ⟨x, hx, y, hy, rfl⟩, rfl⟩ + exact ⟨e x, ⟨x, hx, rfl⟩, e y, ⟨y, hy, rfl⟩, (e.map_sub x y).symm⟩ + rw [hdiff, hXcard] + exact (show (((A - A).image e).card : ℝ) ≤ (A - A).card by + exact_mod_cast Finset.card_image_le).trans hsmall + obtain ⟨N, X', B, g, hN, hX'ne, hX'sub, hsize, hBne, hB, hBcard, + hg, hNsize, hdensity⟩ := exists_dense_cyclic_model X hX hK hXsmall s hs + let J := A.filter fun x => e x ∈ X' + have hJA : J ⊆ A := Finset.filter_subset _ _ + have hJimage : J.image e = X' := by + ext z + constructor + · rintro hz + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hz + exact (Finset.mem_filter.mp hx).2 + · intro hz + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp (hX'sub hz) + exact Finset.mem_image.mpr ⟨x, Finset.mem_filter.mpr ⟨hx, hz⟩, rfl⟩ + have heJ : IsAddFreimanIso s (J : Set _) (X' : Set ℤ) e := by + apply he.subset hJA + refine ⟨?_, he.bijOn.injOn.mono hJA, ?_⟩ + · intro x hx + exact (Finset.mem_filter.mp hx).2 + · intro z hz + rw [← hJimage] at hz + exact Finset.mem_image.mp hz + have hJcard : X'.card = J.card := by + rw [← hJimage] + exact Finset.card_image_of_injOn heJ.bijOn.injOn + have hJne : J.Nonempty := by + apply Finset.card_pos.mp + rw [← hJcard] + exact hX'ne.card_pos + have hJsize : A.card ≤ (2 * s) * J.card := by + simpa only [hXcard, hJcard] using hsize + have hBimage : B = J.image (g ∘ e) := by + rw [hB, ← hJimage, Finset.image_image] + have hNsize' : (N : ℝ) ≤ 2 * K ^ (2 * s) * A.card := by + simpa only [hXcard] using hNsize + exact ⟨N, J, B, g ∘ e, hN, hJne, hJA, hJsize, hBne, hBimage, + hBcard.trans hJcard, hg.comp heJ, hNsize', hdensity⟩ + +end Erdos3.FreimanModel + +end + +section + +namespace Erdos3.FreimanModel + +open scoped Pointwise + +theorem exists_dense_cyclicProduct_integer_model {I : Type*} [Fintype I] + (q : I → ℕ) [∀ i, NeZero (q i)] (A : Finset (∀ i, ZMod (q i))) + (hA : A.Nonempty) {K : ℝ} (hK : 0 < K) + (hsmall : ((A - A).card : ℝ) ≤ K * A.card) : + ∃ (N : ℕ) (J : Finset (∀ i, ZMod (q i))) (B : Finset (ZMod N)) + (g : (I → ℤ) → ZMod N), + 0 < N ∧ J.Nonempty ∧ J ⊆ A ∧ + A.card ≤ 16 ^ (Fintype.card I + 1) * J.card ∧ + B.Nonempty ∧ B = (J.image (cyclicProductLift q)).image g ∧ B.card = J.card ∧ + IsAddFreimanIso 8 (J : Set _) (J.image (cyclicProductLift q) : Set (I → ℤ)) + (cyclicProductLift q) ∧ + IsAddFreimanIso 8 (J.image (cyclicProductLift q) : Set (I → ℤ)) (B : Set _) g ∧ + (N : ℝ) ≤ 2 * (K * 16 ^ Fintype.card I) ^ 16 * A.card ∧ + (32 * (K * 16 ^ Fintype.card I) ^ 16)⁻¹ ≤ (B.card : ℝ) / N := by + classical + obtain ⟨A₀, hA₀, hA₀A, hlarge, he⟩ := exists_large_cyclicProduct_integer_lift q A hA + let e := cyclicProductLift q + let X := A₀.image e + let R : ℝ := K * 16 ^ Fintype.card I + have hR : 0 < R := mul_pos hK (by positivity) + have hX : X.Nonempty := hA₀.image e + have hXcard : X.card = A₀.card := Finset.card_image_of_injOn he.bijOn.injOn + have hdiff : (X - X).card = (A₀ - A₀).card := + card_difference_image_of_freiman A₀ e (he.mono (hmn := by decide)) + have hsub : A₀ - A₀ ⊆ A - A := by + intro x hx + obtain ⟨a, ha, b, hb, rfl⟩ := Finset.mem_sub.mp hx + exact Finset.mem_sub.mpr ⟨a, hA₀A ha, b, hA₀A hb, rfl⟩ + have hlargeR : (A.card : ℝ) ≤ 16 ^ Fintype.card I * A₀.card := by + exact_mod_cast hlarge + have hXsmall : ((X - X).card : ℝ) ≤ R * X.card := by + rw [hdiff, hXcard] + calc + ((A₀ - A₀).card : ℝ) ≤ (A - A).card := by exact_mod_cast Finset.card_le_card hsub + _ ≤ K * A.card := hsmall + _ ≤ K * (16 ^ Fintype.card I * A₀.card) := mul_le_mul_of_nonneg_left hlargeR hK.le + _ = R * A₀.card := by simp only [R, mul_assoc] + obtain ⟨N, X', B, g, hN, hX', hX'X, hsize, hB, hBimage, hBcard, hg, hNsize, hdensity⟩ := + exists_dense_cyclic_model_of_integer_vectors X hX hR hXsmall 8 (by decide) + let J := A₀.filter fun x => e x ∈ X' + have hJA₀ : J ⊆ A₀ := Finset.filter_subset _ _ + have hJimage : J.image e = X' := by + ext z + constructor + · intro hz + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hz + exact (Finset.mem_filter.mp hx).2 + · intro hz + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp (hX'X hz) + exact Finset.mem_image.mpr ⟨x, Finset.mem_filter.mpr ⟨hx, hz⟩, rfl⟩ + have heJ : IsAddFreimanIso 8 (J : Set _) (X' : Set (I → ℤ)) e := by + apply he.subset hJA₀ + refine ⟨?_, he.bijOn.injOn.mono hJA₀, ?_⟩ + · intro x hx + exact (Finset.mem_filter.mp hx).2 + · intro z hz + rw [← hJimage] at hz + exact Finset.mem_image.mp hz + have hJcard : X'.card = J.card := by + rw [← hJimage] + exact Finset.card_image_of_injOn heJ.bijOn.injOn + have hJ : J.Nonempty := by + apply Finset.card_pos.mp + rw [← hJcard] + exact hX'.card_pos + have hsize₀ : A₀.card ≤ 16 * J.card := by + simpa only [hXcard, hJcard, Nat.reduceMul] using hsize + have hsize' : A.card ≤ 16 ^ (Fintype.card I + 1) * J.card := by + calc + A.card ≤ 16 ^ Fintype.card I * A₀.card := hlarge + _ ≤ 16 ^ Fintype.card I * (16 * J.card) := Nat.mul_le_mul_left _ hsize₀ + _ = _ := by rw [pow_succ, mul_assoc] + have hBimage' : B = (J.image e).image g := by + rw [hJimage] + exact hBimage + have hNsize' : (N : ℝ) ≤ 2 * R ^ 16 * A.card := by + have hcard : (X.card : ℝ) ≤ A.card := by rw [hXcard]; exact_mod_cast Finset.card_le_card hA₀A + have hn : (N : ℝ) ≤ 2 * R ^ 16 * X.card := by + simpa only [Nat.reduceMul] using hNsize + exact hn.trans + (mul_le_mul_of_nonneg_left hcard (by positivity)) + refine ⟨N, J, B, g, hN, hJ, hJA₀.trans hA₀A, hsize', hB, hBimage', + hBcard.trans hJcard, ?_, ?_, hNsize', ?_⟩ + · change IsAddFreimanIso 8 (J : Set _) (J.image e : Set (I → ℤ)) e + rw [hJimage] + exact heJ + · change IsAddFreimanIso 8 (J.image e : Set (I → ℤ)) (B : Set _) g + rw [hJimage] + exact hg + · norm_num only [Nat.reduceMul, Nat.cast_ofNat, mul_one] at hdensity + simpa only [R, show (4 : ℝ) * 8 = 32 by norm_num] using hdensity + +end Erdos3.FreimanModel + +end + +section + +namespace Erdos3.FreimanModel + +open scoped Pointwise + +variable {I : Type*} + +def variableIntegerGraphLift (N : ℕ) (M : I → ℕ) + (x : ZMod N × (∀ i, ZMod (M i))) : Option I → ℤ := + cyclicProductLift (variableRoundedGraphModuli N M) + (variableRoundedGraphCoordinateEquiv N M x) + +def variableIntegerGraphReduction (N : ℕ) (M : I → ℕ) : + (Option I → ℤ) →+ (ZMod N × (∀ i, ZMod (M i))) where + toFun z := ((z none : ZMod N), fun i => (z (some i) : ZMod (M i))) + map_zero' := by ext <;> simp + map_add' x y := by ext <;> simp + +@[simp] theorem variableIntegerGraphReduction_lift (N : ℕ) (M : I → ℕ) + [NeZero N] [∀ i, NeZero (M i)] (x : ZMod N × (∀ i, ZMod (M i))) : + variableIntegerGraphReduction N M (variableIntegerGraphLift N M x) = x := by + apply Prod.ext + · change (((x.1.val : ℤ) : ZMod N)) = x.1 + simp only [Int.cast_natCast, ZMod.natCast_zmod_val] + · funext i + change ((((x.2 i).val : ℤ) : ZMod (M i))) = x.2 i + simp only [Int.cast_natCast, ZMod.natCast_zmod_val] + +@[simp] theorem variableIntegerGraphLift_none (N : ℕ) (M : I → ℕ) + (x : ZMod N × (∀ i, ZMod (M i))) : + variableIntegerGraphLift N M x none = (x.1.val : ℤ) := rfl + +@[simp] theorem variableIntegerGraphLift_some (N : ℕ) (M : I → ℕ) + (x : ZMod N × (∀ i, ZMod (M i))) (i : I) : + variableIntegerGraphLift N M x (some i) = ((x.2 i).val : ℤ) := rfl + +theorem variableIntegerGraphLift_injective (N : ℕ) (M : I → ℕ) + [NeZero N] [∀ i, NeZero (M i)] : Function.Injective (variableIntegerGraphLift N M) := by + intro x y h + have heq := congrArg (variableIntegerGraphReduction N M) h + simpa only [variableIntegerGraphReduction_lift] using heq + +theorem exists_variableIntegerGraph_cyclic_model [Fintype I] + (N : ℕ) (M : I → ℕ) [NeZero N] [∀ i, NeZero (M i)] + (A : Finset (ZMod N × (∀ i, ZMod (M i)))) (hA : A.Nonempty) + {K : ℝ} (hK : 0 < K) (hsmall : ((A - A).card : ℝ) ≤ K * A.card) : + ∃ (Q : ℕ) (S : Finset (Option I → ℤ)) (B : Finset (ZMod Q)) + (g : (Option I → ℤ) → ZMod Q), + 0 < Q ∧ S.Nonempty ∧ S ⊆ A.image (variableIntegerGraphLift N M) ∧ + A.card ≤ 16 ^ (Fintype.card I + 2) * S.card ∧ + B.Nonempty ∧ B = S.image g ∧ B.card = S.card ∧ + IsAddFreimanIso 8 (S : Set _) (B : Set _) g ∧ + (Q : ℝ) ≤ 2 * (K * 16 ^ (Fintype.card I + 1)) ^ 16 * A.card ∧ + (32 * (K * 16 ^ (Fintype.card I + 1)) ^ 16)⁻¹ ≤ (B.card : ℝ) / Q := by + classical + let q : Option I → ℕ := variableRoundedGraphModuli N M + let _ : ∀ i, NeZero (q i) := variableRoundedGraphModuli_neZero N M + let e := variableRoundedGraphCoordinateEquiv (I := I) N M + let X := A.image e + have he : IsAddFreimanIso 8 (A : Set _) (X : Set _) e := + isAddFreimanIso_of_injOn_iterated_sums e.toAddMonoidHom A 8 + e.injective.injOn e.injective.injOn + have hX : X.Nonempty := hA.image e + have hXcard : X.card = A.card := Finset.card_image_of_injOn e.injective.injOn + have hXsmall : ((X - X).card : ℝ) ≤ K * X.card := by + rw [card_difference_image_of_freiman A e (he.mono (hmn := by decide)), hXcard] + exact hsmall + obtain ⟨Q, J, B, g, hQ, hJ, hJX, hsize, hB, hBimage, hBcard, hlift, hg, + hQsize, hdensity⟩ := exists_dense_cyclicProduct_integer_model q X hX hK hXsmall + let S := J.image (cyclicProductLift q) + have hScard : S.card = J.card := Finset.card_image_of_injOn hlift.bijOn.injOn + have hSA : S ⊆ A.image (variableIntegerGraphLift N M) := by + intro z hz + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hz + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp (hJX hx) + exact Finset.mem_image.mpr ⟨y, hy, rfl⟩ + refine ⟨Q, S, B, g, hQ, hJ.image _, hSA, ?_, hB, hBimage, + hBcard.trans hScard.symm, hg, ?_, ?_⟩ + · simpa only [hXcard, hScard, Fintype.card_option, Nat.add_assoc] using hsize + · simpa only [hXcard, Fintype.card_option] using hQsize + · simpa only [Fintype.card_option] using hdensity + +end Erdos3.FreimanModel + +end + +section + +namespace Erdos3.FreimanModel + +open scoped Pointwise BigOperators +open CyclicCrootSisask + +theorem exists_bounded_affine_box_of_cyclic_model {G : Type*} [AddCommGroup G] [DecidableEq G] + {Q : ℕ} [NeZero Q] (A : Finset G) (hA : A.Nonempty) (B : Finset (ZMod Q)) + (hB : B.Nonempty) (f : G → ZMod Q) (hf : IsAddFreimanIso 8 (A : Set _) (B : Set _) f) + {p : ℝ} (hp : 0 ≤ p) (hdensity : Real.exp (-p) * Q ≤ (B.card : ℝ)) : + ∃ F ⊆ A, F.Nonempty ∧ + Real.exp (-(quarticBogolyubovProgressionConstant * (p + 1) ^ 8)) * A.card ≤ (F.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) (Φ : (Fin r → ℤ) →+ G) (base : G), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (p + 1) ^ 4 ∧ + (∏ i, (2 * R i + 1)) ≤ Q ∧ + Set.InjOn Φ {x | ∀ i, |x i| ≤ (R i : ℤ)} ∧ + ∀ a ∈ F, ∃ x : Fin r → ℤ, (∀ i, |x i| ≤ (R i : ℤ)) ∧ a = base + Φ x := by + classical + obtain ⟨T, hrank, hT, hTsub, hTsize⟩ := exists_quartic_bogolyubov_progression B hp hdensity + obtain ⟨L, hmap, hinj, hzero, hadd⟩ := exists_fourfold_lift_of_eight_iso A B hB f hf + have hpair (x y z t : T.Param) (h : T.eval x + T.eval y = T.eval z + T.eval t) : + L (T.eval x) + L (T.eval y) = L (T.eval z) + L (T.eval t) := + (hadd _ (hTsub (T.eval_mem_carrier x)) _ (hTsub (T.eval_mem_carrier y)) + _ (hTsub (T.eval_mem_carrier z)) _ (hTsub (T.eval_mem_carrier t))).mpr h + let Φ := T.freimanHom L + let S := T.coefficientBox.image Φ + have hS : S ⊆ 2 • A - 2 • A := by + intro a ha + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp ha + obtain ⟨y, rfl⟩ := T.mem_coefficientBox.mp hx + change T.freimanHom L (T.coeff y) ∈ _ + rw [T.freimanHom_coeff L hzero hpair] + exact hmap (hTsub (T.eval_mem_carrier y)) + have hScard : S.card = T.carrier.card := by + change (T.coefficientBox.image (T.freimanHom L)).card = T.carrier.card + rw [T.image_freimanHom L hzero hpair] + exact Finset.card_image_of_injOn (hinj.mono hTsub) + have hbound : ((A - S).card : ℝ) ≤ (Q : ℝ) := by + have h := card_sub_le_of_fourfold_subset A S f (hf.mono (hmn := by decide)) hS + have h' : (A - S).card ≤ Q := by simpa only [ZMod.card] using h + exact_mod_cast h' + have hsize : Real.exp (-(quarticBogolyubovProgressionConstant * (p + 1) ^ 8)) * Q ≤ + (S.card : ℝ) := by rw [hScard]; exact hTsize + obtain ⟨base, _hbase, F, hFA, hF, hFsize, hFsub⟩ := exists_dense_translate A S hA + (Real.exp_pos _) (by exact_mod_cast NeZero.pos Q) hbound hsize + refine ⟨F, hFA, hF, hFsize, T.rank, T.radius, Φ, base, hrank, ?_, ?_, ?_⟩ + · rw [← T.card_carrier_of_proper hT] + simpa only [ZMod.card] using Finset.card_le_univ T.carrier + · intro x hx y hy hxy + exact T.freimanHom_injOn hT L (hinj.mono hTsub) hzero hpair + (T.mem_coefficientBox_iff_abs_le.mpr hx) (T.mem_coefficientBox_iff_abs_le.mpr hy) hxy + · intro a ha + obtain ⟨x, hx, heq⟩ := Finset.mem_image.mp (hFsub a ha) + refine ⟨x, T.mem_coefficientBox_iff_abs_le.mp hx, ?_⟩ + rw [heq] + abel + +end Erdos3.FreimanModel + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped Pointwise BigOperators +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem integer_graph_affine_model {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (M l : I → ℕ) [∀ i, NeZero (M i)] (ε : I → ℝ) + (hsmall : ∀ i, (M i : ℝ) * l i * ε i ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ coordinateDenominatorGrid l, + ∀ i, |c i + (a (rankQuadrupleParameters t 1) i + a (rankQuadrupleParameters t 2) i - + a (rankQuadrupleParameters t 0) i - a (rankQuadrupleParameters t 3) i) - q i| ≤ ε i) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + let v := fun h => variableRoundedCoefficient M l (a h) + ∃ J' ⊆ H, J'.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J'.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) + (Φ : (Fin r → ℤ) →+ (Option I → ℤ)) + (base : Option I → ℤ), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + ((∏ i, (2 * R i + 1) : ℕ) : ℝ) ≤ + 2 * ((2 ^ 14 : ℝ) * K ^ 6 * 16 ^ (Fintype.card I + 1)) ^ 16 * H.card ∧ + Set.InjOn Φ {x | ∀ i, |x i| ≤ (R i : ℤ)} ∧ + ∀ h ∈ J', ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ + FreimanModel.variableIntegerGraphLift N M (h, v h) = base + Φ x := by + intro K z δ v + classical + obtain ⟨J, hJH, hJ, hsize, hsmallJ⟩ := + D.variable_graph_small_difference a c M l ε hsmall hnear + let A := additiveGraph J v + have hA : A.Nonempty := hJ.image _ + have hAsmall : ((A - A).card : ℝ) ≤ (2 ^ 14 : ℝ) * K ^ 6 * A.card := by + simpa only [A, additiveGraph_card] using hsmallJ + obtain ⟨Q, S, B, f, hQ, hS, hSA, hASsize, hB, _hBimage, _hBcard, hf, + hQsize, hdensity⟩ := + FreimanModel.exists_variableIntegerGraph_cyclic_model N M A hA + (by dsimp [K]; positivity) hAsmall + let _ : NeZero Q := ⟨hQ.ne'⟩ + have hdensity' : Real.exp (-z) * Q ≤ (B.card : ℝ) := by + apply (le_div_iff₀ (by exact_mod_cast hQ : (0 : ℝ) < Q)).mp + exact (exp_neg_roundedModelLogBudget_le_density P (Fintype.card I)).trans hdensity + obtain ⟨F, hFS, hF, hFsize, r, R, Φ, base, hrank, hbox, hinj, hrepr⟩ := + FreimanModel.exists_bounded_affine_box_of_cyclic_model S hS B hB f hf + (roundedModelLogBudget_nonneg P (Fintype.card I)) hdensity' + have hboxSize : ((∏ i, (2 * R i + 1) : ℕ) : ℝ) ≤ + 2 * ((2 ^ 14 : ℝ) * K ^ 6 * 16 ^ (Fintype.card I + 1)) ^ 16 * H.card := by + have hcast : ((∏ i, (2 * R i + 1) : ℕ) : ℝ) ≤ Q := by exact_mod_cast hbox + have hJcard : (A.card : ℝ) ≤ H.card := by + rw [show A.card = J.card from additiveGraph_card J v] + exact_mod_cast Finset.card_le_card hJH + exact hcast.trans (hQsize.trans (mul_le_mul_of_nonneg_left hJcard (by positivity))) + have hFA : F ⊆ A.image (FreimanModel.variableIntegerGraphLift N M) := hFS.trans hSA + let π : (Option I → ℤ) → ZMod N := fun z => (z none : ZMod N) + have hback (z : Option I → ℤ) (hz : z ∈ F) : + π z ∈ J ∧ FreimanModel.variableIntegerGraphLift N M (π z, v (π z)) = z := by + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp (hFA hz) + obtain ⟨hyJ, hyv⟩ := (mem_additiveGraph_iff J v y).mp hy + have hπ : π (FreimanModel.variableIntegerGraphLift N M y) = y.1 := by + simp [π] + rw [hπ] + exact ⟨hyJ, congrArg (FreimanModel.variableIntegerGraphLift N M) (Prod.ext rfl hyv.symm)⟩ + let J' := F.image π + have hπinj : Set.InjOn π (F : Set _) := by + intro x hx y hy hxy + calc + x = FreimanModel.variableIntegerGraphLift N M (π x, v (π x)) := (hback x hx).2.symm + _ = FreimanModel.variableIntegerGraphLift N M (π y, v (π y)) := by rw [hxy] + _ = y := (hback y hy).2 + have hFcard : F.card = J'.card := (Finset.card_image_of_injOn hπinj).symm + have hJ' : J' ⊆ H := by + intro h hh + obtain ⟨z, hz, rfl⟩ := Finset.mem_image.mp hh + exact hJH (hback z hz).1 + have hJS : (J.card : ℝ) ≤ 16 ^ (Fintype.card I + 2) * (S.card : ℝ) := by + have h : J.card ≤ 16 ^ (Fintype.card I + 2) * S.card := by + simpa only [A, additiveGraph_card] using hASsize + exact_mod_cast h + have hretain : δ * (S.card : ℝ) ≤ (J'.card : ℝ) := by + simpa only [hFcard] using hFsize + refine ⟨J', hJ', hF.image _, ?_, r, R, Φ, base, hrank, hboxSize, hinj, ?_⟩ + · calc + _ ≤ δ * (J.card : ℝ) := mul_le_mul_of_nonneg_left hsize (Real.exp_pos _).le + _ ≤ δ * (16 ^ (Fintype.card I + 2) * (S.card : ℝ)) := + mul_le_mul_of_nonneg_left hJS (Real.exp_pos _).le + _ = 16 ^ (Fintype.card I + 2) * (δ * S.card) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hretain (by positivity) + · intro h hh + obtain ⟨z, hz, rfl⟩ := Finset.mem_image.mp hh + rw [(hback z hz).2] + exact hrepr z hz + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped BigOperators Pointwise +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem integer_affine_graph_recovery {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (l : I → ℕ) (hl : ∀ i, 0 < l i) + (ε : I → ℝ) (hε : ∀ i, 0 < ε i) (hsmall : ∀ i, 2 * (l i : ℝ) * ε i ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ coordinateDenominatorGrid l, + ∀ i, |c i + (a (rankQuadrupleParameters t 1) i + a (rankQuadrupleParameters t 2) i - + a (rankQuadrupleParameters t 0) i - a (rankQuadrupleParameters t 3) i) - q i| ≤ ε i) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + ∃ M : I → ℕ, (∀ i, 0 < M i) ∧ + (∀ i, (M i : ℝ) * l i * ε i ≤ 1) ∧ + (∀ i, 1 / ((M i : ℝ) * l i) ≤ 2 * ε i) ∧ + ∃ J' ⊆ H, J'.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J'.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) + (Φ : (Fin r → ℤ) →+ (Option I → ℤ)) + (base : Option I → ℤ), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + ((∏ i, (2 * R i + 1) : ℕ) : ℝ) ≤ + 2 * ((2 ^ 14 : ℝ) * K ^ 6 * 16 ^ (Fintype.card I + 1)) ^ 16 * H.card ∧ + Set.InjOn Φ {x | ∀ i, |x i| ≤ (R i : ℤ)} ∧ + (let reduce := FreimanModel.variableIntegerGraphReduction N M + let ψ := (AddMonoidHom.snd (ZMod N) (∀ i, ZMod (M i))).comp (reduce.comp Φ) + let α := variableCoefficientLift l (reduce base).2 + let β := fun j => variableCoefficientLift l (ψ (Pi.single j 1)) + (∀ i, α i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + (∀ j i, β j i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + ∀ h ∈ J', ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ + (h.val : ℤ) = base none + Φ x none ∧ + FreimanModel.variableIntegerGraphLift N M + (h, variableRoundedCoefficient M l (a h)) = base + Φ x ∧ + (∀ y : Fin r → ℤ, (∀ i, |y i| ≤ (R i : ℤ)) → + FreimanModel.variableIntegerGraphLift N M + (h, variableRoundedCoefficient M l (a h)) = base + Φ y → y = x) ∧ + ∃ q ∈ coordinateDenominatorGrid l, ∀ i, + |a h i - (α + ∑ j, (x j : ℝ) • β j) i - q i| ≤ 2 * ε i) := by + intro K z δ + obtain ⟨M, hM, hMsmall, hMerror⟩ := exists_coordinate_rounding_moduli l hl ε hε hsmall + let _ : ∀ i, NeZero (M i) := fun i => ⟨(hM i).ne'⟩ + obtain ⟨J', hJH, hJ, hsize, r, R, Φ, base, hrank, hbox, hinj, hrepr⟩ := + D.integer_graph_affine_model a c M l ε hMsmall hnear + refine ⟨M, hM, hMsmall, hMerror, J', hJH, hJ, hsize, r, R, Φ, base, + hrank, hbox, hinj, ?_⟩ + dsimp only + refine ⟨variableCoefficientLift_mem_Ico l hl _, ?_, ?_⟩ + · intro j + exact variableCoefficientLift_mem_Ico l hl _ + · intro h hh + obtain ⟨x, hx, heq⟩ := hrepr h hh + refine ⟨x, hx, ?_, heq, ?_, ?_⟩ + · exact congrFun heq none + · intro y hy hey + exact hinj hy hx (add_left_cancel (hey.symm.trans heq)) + · let reduce := FreimanModel.variableIntegerGraphReduction N M + have hred : (h, variableRoundedCoefficient M l (a h)) = + reduce base + reduce (Φ x) := by + have hr := congrArg reduce heq + simpa only [reduce, FreimanModel.variableIntegerGraphReduction_lift, map_add] using hr + obtain ⟨q, hq, herr⟩ := exists_variable_unrounded_affine l hl (reduce base).2 + ((AddMonoidHom.snd (ZMod N) (∀ i, ZMod (M i))).comp (reduce.comp Φ)) x (a h) + (congrArg Prod.snd hred) + exact ⟨q, hq, fun i => (herr i).trans (hMerror i)⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped Pointwise BigOperators +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem proper_integer_graph_affine_model {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (M l : I → ℕ) [∀ i, NeZero (M i)] (ε : I → ℝ) + (hsmall : ∀ i, (M i : ℝ) * l i * ε i ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ coordinateDenominatorGrid l, + ∀ i, |c i + (a (rankQuadrupleParameters t 1) i + a (rankQuadrupleParameters t 2) i - + a (rankQuadrupleParameters t 0) i - a (rankQuadrupleParameters t 3) i) - q i| ≤ ε i) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + let v := fun h => variableRoundedCoefficient M l (a h) + ∃ J₀ ⊆ H, J₀.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J₀.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) (Φ : (Fin r → ℤ) →+ (Option I → ℤ)), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + ((∏ i, (2 * R i + 1) : ℕ) : ℝ) ≤ + 2 * ((2 ^ 14 : ℝ) * K ^ 6 * 16 ^ (Fintype.card I + 1)) ^ 16 * H.card ∧ + (let k := (2 ^ r * ∏ i, (2 * R i + 1)) / J₀.card + 1 + let reduce := FreimanModel.variableIntegerGraphReduction N M + let η := (AddMonoidHom.fst (ZMod N) (∀ i, ZMod (M i))).comp (reduce.comp Φ) + ∃ J ⊆ J₀, J.Nonempty ∧ J₀.card ≤ (4 * k) ^ r * J.card ∧ + ∃ base : Option I → ℤ, + Set.InjOn η (centeredIntegerBox (fun i => R i / (2 * k)) : Set _) ∧ + ∀ h ∈ J, ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i / (2 * k) : ℕ)) ∧ + FreimanModel.variableIntegerGraphLift N M (h, v h) = base + Φ x) := by + intro K z δ v + classical + obtain ⟨J₀, hJ₀H, hJ₀, hsize, r, R, Φ, base, hrank, hvolume, _hfull, hrepr⟩ := + D.integer_graph_affine_model a c M l ε hsmall hnear + let reduce := FreimanModel.variableIntegerGraphReduction N M + let η := (AddMonoidHom.fst (ZMod N) (∀ i, ZMod (M i))).comp (reduce.comp Φ) + have hall (h : {h // h ∈ J₀}) : ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ + FreimanModel.variableIntegerGraphLift N M (h.val, v h.val) = base + Φ x := + hrepr h.val h.property + choose x hx hgraph using hall + have hspace (h : {h // h ∈ J₀}) : h.val = (reduce base).1 + η (x h) := by + change h.val = (reduce base).1 + (reduce (Φ (x h))).1 + have hh := congrArg (fun y => (reduce y).1) (hgraph h) + simpa only [reduce, FreimanModel.variableIntegerGraphReduction_lift, map_add, + Prod.fst_add] using hh + obtain ⟨J, hJJ₀, hJ, hretain, t, hproper, hsmallBox⟩ := + exists_dense_proper_coordinate_restriction J₀ hJ₀ R η (reduce base).1 x hx hspace + refine ⟨J₀, hJ₀H, hJ₀, hsize, r, R, Φ, hrank, hvolume, J, hJJ₀, + hJ, hretain, base + Φ t, hproper, ?_⟩ + intro h hh + let h₀ : {h // h ∈ J₀} := ⟨h, hJJ₀ hh⟩ + refine ⟨x h₀ - t, hsmallBox ⟨h, hh⟩, ?_⟩ + rw [hgraph h₀, map_sub] + abel + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped BigOperators Pointwise +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem proper_affine_graph_recovery {I : Type*} [Fintype I] (hP : 0 ≤ P) + (a : ZMod N → I → ℝ) (c : I → ℝ) (l : I → ℕ) (hl : ∀ i, 0 < l i) + (ε : I → ℝ) (hε : ∀ i, 0 < ε i) (hsmall : ∀ i, 2 * (l i : ℝ) * ε i ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ coordinateDenominatorGrid l, + ∀ i, |c i + (a (rankQuadrupleParameters t 1) i + a (rankQuadrupleParameters t 2) i - + a (rankQuadrupleParameters t 0) i - a (rankQuadrupleParameters t 3) i) - q i| ≤ ε i) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + ∃ M : I → ℕ, (∀ i, 0 < M i) ∧ + (∀ i, (M i : ℝ) * l i * ε i ≤ 1) ∧ + (∀ i, 1 / ((M i : ℝ) * l i) ≤ 2 * ε i) ∧ + ∃ J₀ ⊆ H, J₀.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J₀.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) (Φ : (Fin r → ℤ) →+ (Option I → ℤ)), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + ((∏ i, (2 * R i + 1) : ℕ) : ℝ) ≤ + 2 * ((2 ^ 14 : ℝ) * K ^ 6 * 16 ^ (Fintype.card I + 1)) ^ 16 * H.card ∧ + (let k := (2 ^ r * ∏ i, (2 * R i + 1)) / J₀.card + 1 + let reduce := FreimanModel.variableIntegerGraphReduction N M + let η := (AddMonoidHom.fst (ZMod N) (∀ i, ZMod (M i))).comp (reduce.comp Φ) + ∃ J ⊆ J₀, J.Nonempty ∧ J₀.card ≤ (4 * k) ^ r * J.card ∧ + Real.exp (-properAffineRecoveryLogLoss P (Fintype.card I)) * H.card ≤ (J.card : ℝ) ∧ + (k : ℝ) ≤ Real.exp (properAffineScaleLog P (Fintype.card I)) ∧ + ∃ base : Option I → ℤ, + Set.InjOn η (centeredIntegerBox (fun i => R i / (2 * k)) : Set _) ∧ + (let ψ := (AddMonoidHom.snd (ZMod N) (∀ i, ZMod (M i))).comp (reduce.comp Φ) + let α := variableCoefficientLift l (reduce base).2 + let β := fun j => variableCoefficientLift l (ψ (Pi.single j 1)) + (∀ i, α i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + (∀ j i, β j i ∈ Set.Ico (0 : ℝ) (1 / l i)) ∧ + ∀ h ∈ J, ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i / (2 * k) : ℕ)) ∧ + h = (reduce base).1 + η x ∧ + FreimanModel.variableIntegerGraphLift N M + (h, variableRoundedCoefficient M l (a h)) = base + Φ x ∧ + ∃ q ∈ coordinateDenominatorGrid l, ∀ i, + |a h i - (α + ∑ j, (x j : ℝ) • β j) i - q i| ≤ 2 * ε i)) := by + intro K z δ + obtain ⟨M, hM, hMsmall, hMerror⟩ := exists_coordinate_rounding_moduli l hl ε hε hsmall + let _ : ∀ i, NeZero (M i) := fun i => ⟨(hM i).ne'⟩ + obtain ⟨J₀, hJ₀H, hJ₀, hsize, r, R, Φ, hrank, hvolume, + J, hJJ₀, hJ, hretain, base, hproper, hrepr⟩ := + D.proper_integer_graph_affine_model a c M l ε hMsmall hnear + have hcost := properAffineSelection_bounds hP (Fintype.card I) r + (∏ i, (2 * R i + 1)) H.card J₀.card J.card hJ₀.card_pos hrank hvolume + (exp_neg_affineRecoveryLogLoss_card_le P (Fintype.card I) H.card J₀.card hsize) hretain + refine ⟨M, hM, hMsmall, hMerror, J₀, hJ₀H, hJ₀, hsize, r, R, Φ, hrank, hvolume, + J, hJJ₀, hJ, hretain, hcost.2, hcost.1, base, hproper, ?_⟩ + dsimp only + refine ⟨variableCoefficientLift_mem_Ico l hl _, ?_, ?_⟩ + · intro j + exact variableCoefficientLift_mem_Ico l hl _ + · intro h hh + obtain ⟨x, hx, heq⟩ := hrepr h hh + let reduce := FreimanModel.variableIntegerGraphReduction N M + have hred : (h, variableRoundedCoefficient M l (a h)) = + reduce base + reduce (Φ x) := by + have hr := congrArg reduce heq + simpa only [reduce, FreimanModel.variableIntegerGraphReduction_lift, map_add] using hr + refine ⟨x, hx, congrArg Prod.fst hred, heq, ?_⟩ + obtain ⟨q, hq, herr⟩ := exists_variable_unrounded_affine l hl (reduce base).2 + ((AddMonoidHom.snd (ZMod N) (∀ i, ZMod (M i))).comp (reduce.comp Φ)) x (a h) + (congrArg Prod.snd hred) + exact ⟨q, hq, fun i => (herr i).trans (hMerror i)⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeRealAffineRecovery.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeRealAffineRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e930498fea00a36e08043c2ba33bef71a5583ad --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeRealAffineRecovery.lean @@ -0,0 +1,205 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeRoundedHomModel + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped Pointwise +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem rounded_graph_affine_model {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (M l : ℕ) [NeZero M] {ε : ℝ} + (hsmall : (M : ℝ) * l * ε ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ realDenominatorGrid l, + ‖c + (a (rankQuadrupleParameters t 1) + a (rankQuadrupleParameters t 2) - + a (rankQuadrupleParameters t 0) - a (rankQuadrupleParameters t 3)) - q‖ ≤ ε) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + let v := fun h => roundedCoefficient M l (a h) + ∃ J' ⊆ H, J'.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J'.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) + (Φ : (Fin r → ℤ) →+ (ZMod N × (I → ZMod M))) + (base : ZMod N × (I → ZMod M)), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + Set.InjOn Φ {x | ∀ i, |x i| ≤ (R i : ℤ)} ∧ + ∀ h ∈ J', ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ (h, v h) = base + Φ x := by + intro K z δ v + classical + obtain ⟨J, hJH, hJ, hsize, Q, B, f, T, Φ, hB, hBimage, hBcard, hf, + hQsize, hTdim, hT, hTsub, hTsize, hmap, hinj, hcard⟩ := + D.rounded_graph_coordinate_model a c M l hsmall hnear + let A := additiveGraph J v + let S := T.coefficientBox.image Φ + have hS : S ⊆ 2 • A - 2 • A := by + intro y hy + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hy + exact hmap hx + have hbound : ((A - S).card : ℝ) ≤ (Q : ℝ) := by + have hb := FreimanModel.card_sub_le_of_fourfold_subset A S f + (hf.mono (hmn := by decide)) hS + have hb' : (A - S).card ≤ (Q : ℕ) := by simpa only [ZMod.card] using hb + exact_mod_cast hb' + have hSsize : δ * (Q : ℝ) ≤ (S.card : ℝ) := by + change δ * (Q : ℝ) ≤ ((T.coefficientBox.image Φ).card : ℝ) + rw [hcard] + exact hTsize + obtain ⟨base, _hbase, F, hFA, hF, hFsize, hFsub⟩ := exists_dense_translate A S + (hJ.image _) (Real.exp_pos _) (by exact_mod_cast Q.pos) hbound hSsize + let J' := F.image Prod.fst + have hgraph : additiveGraph J' v = F := additiveGraph_image_fst J v F hFA + have hFcard : F.card = J'.card := by rw [← hgraph, additiveGraph_card] + have hJ' : J' ⊆ H := by + intro h hh + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hh + exact hJH ((mem_additiveGraph_iff J v y).mp (hFA hy)).1 + have hretain : δ * (J.card : ℝ) ≤ (J'.card : ℝ) := by + simpa only [A, additiveGraph_card, hFcard] using hFsize + refine ⟨J', hJ', hF.image _, ?_, T.rank, T.radius, Φ, base, hTdim, ?_, ?_⟩ + · calc + _ ≤ δ * (16 ^ (Fintype.card I + 2) * (J.card : ℝ)) := + mul_le_mul_of_nonneg_left hsize (Real.exp_pos _).le + _ = 16 ^ (Fintype.card I + 2) * (δ * J.card) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hretain (by positivity) + · intro x hx y hy hxy + exact hinj (T.mem_coefficientBox_iff_abs_le.mpr hx) + (T.mem_coefficientBox_iff_abs_le.mpr hy) hxy + · intro h hh + have hhF : (h, v h) ∈ F := by + rw [← hgraph, mem_additiveGraph_iff] + exact ⟨hh, rfl⟩ + obtain ⟨x, hx, heq⟩ := Finset.mem_image.mp (hFsub (h, v h) hhF) + refine ⟨x, T.mem_coefficientBox_iff_abs_le.mp hx, ?_⟩ + rw [heq] + abel + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped BigOperators Pointwise +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem unrounded_affine_model {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (M l : ℕ) [NeZero M] (hl : 0 < l) {ε : ℝ} + (hsmall : (M : ℝ) * l * ε ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ realDenominatorGrid l, + ‖c + (a (rankQuadrupleParameters t 1) + a (rankQuadrupleParameters t 2) - + a (rankQuadrupleParameters t 0) - a (rankQuadrupleParameters t 3)) - q‖ ≤ ε) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + ∃ J' ⊆ H, J'.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J'.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) (ξ : (Fin r → ℤ) →+ ZMod N) + (h₀ : ZMod N) (α : I → ℝ) (β : Fin r → I → ℝ), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + (∀ i, α i ∈ Set.Ico (0 : ℝ) (1 / l)) ∧ + (∀ j i, β j i ∈ Set.Ico (0 : ℝ) (1 / l)) ∧ + ∀ h ∈ J', ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + ξ x ∧ + ∃ q ∈ realDenominatorGrid l, + ‖a h - (α + ∑ j, (x j : ℝ) • β j) - q‖ ≤ 1 / ((M : ℝ) * l) := by + intro K z δ + obtain ⟨J', hJH, hJ, hsize, r, R, Φ, base, hrank, _hinj, hrepr⟩ := + D.rounded_graph_affine_model a c M l hsmall hnear + let ξ := (AddMonoidHom.fst (ZMod N) (I → ZMod M)).comp Φ + let ψ := (AddMonoidHom.snd (ZMod N) (I → ZMod M)).comp Φ + refine ⟨J', hJH, hJ, hsize, r, R, ξ, base.1, finiteCoefficientLift l base.2, + (fun j => finiteCoefficientLift l (ψ (Pi.single j 1))), hrank, ?_, ?_, ?_⟩ + · exact finiteCoefficientLift_mem_Ico l hl base.2 + · intro j + exact finiteCoefficientLift_mem_Ico l hl (ψ (Pi.single j 1)) + · intro h hh + obtain ⟨x, hx, heq⟩ := hrepr h hh + refine ⟨x, hx, ?_, ?_⟩ + · exact congrArg Prod.fst heq + · exact exists_unrounded_affine l hl base.2 ψ x (a h) (congrArg Prod.snd heq) + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped BigOperators Pointwise +open CyclicCrootSisask + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem real_affine_recovery {I : Type*} [Fintype I] + (a : ZMod N → I → ℝ) (c : I → ℝ) (l : ℕ) (hl : 0 < l) {ε : ℝ} (hε : 0 < ε) + (hsmall : 2 * (l : ℝ) * ε ≤ 1) + (hnear : ∀ t ∈ D.quadruples, ∃ q ∈ realDenominatorGrid l, + ‖c + (a (rankQuadrupleParameters t 1) + a (rankQuadrupleParameters t 2) - + a (rankQuadrupleParameters t 0) - a (rankQuadrupleParameters t 3)) - q‖ ≤ ε) : + let K := Real.exp (P + 13 * Fintype.card I) + let z := roundedModelLogBudget P (Fintype.card I) + let δ := Real.exp (-(quarticBogolyubovProgressionConstant * (z + 1) ^ 8)) + ∃ J' ⊆ H, J'.Nonempty ∧ + δ * ((2 ^ 4 : ℝ)⁻¹ * K⁻¹ * H.card) ≤ 16 ^ (Fintype.card I + 2) * (J'.card : ℝ) ∧ + ∃ (r : ℕ) (R : Fin r → ℕ) (ξ : (Fin r → ℤ) →+ ZMod N) + (h₀ : ZMod N) (α : I → ℝ) (β : Fin r → I → ℝ), + (r : ℝ) ≤ 2 + quarticBogolyubovConstant * (z + 1) ^ 4 ∧ + (∀ i, α i ∈ Set.Ico (0 : ℝ) (1 / l)) ∧ + (∀ j i, β j i ∈ Set.Ico (0 : ℝ) (1 / l)) ∧ + ∀ h ∈ J', ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + ξ x ∧ + ∃ q ∈ realDenominatorGrid l, + ‖a h - (α + ∑ j, (x j : ℝ) • β j) - q‖ ≤ 2 * ε := by + intro K z δ + obtain ⟨M, hM, hMsmall, hMerror⟩ := exists_rounding_modulus_with_recovery l hl hε hsmall + let _ : NeZero M := ⟨hM.ne'⟩ + obtain ⟨J', hJH, hJ, hsize, r, R, ξ, h₀, α, β, hrank, hα, hβ, hrepr⟩ := + D.unrounded_affine_model a c M l hl hMsmall hnear + refine ⟨J', hJH, hJ, hsize, r, R, ξ, h₀, α, β, hrank, hα, hβ, ?_⟩ + intro h hh + obtain ⟨x, hx, hspace, q, hq, herr⟩ := hrepr h hh + exact ⟨x, hx, hspace, q, hq, herr.trans hMerror⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeRetainedIntegerMultilinearQuadruples.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeRetainedIntegerMultilinearQuadruples.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c1a47b82e0fc78b44b4f2602db5bbf5dcf41a50 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeRetainedIntegerMultilinearQuadruples.lean @@ -0,0 +1,483 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeMultilinearQuadruples + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def cyclicBranchOffset {N : ℕ} (h : ZMod N) (branch : Bool) : ℤ := + (h.val : ℤ) - if branch then (N : ℤ) else 0 + +theorem cyclicTranslationOffset_eq_branch {N : ℕ} (h : ZMod N) (a : ℕ) : + cyclicTranslationOffset h a = cyclicBranchOffset h (decide (N - h.val ≤ a)) := by + by_cases hwrap : N - h.val ≤ a <;> simp [cyclicTranslationOffset, cyclicBranchOffset, hwrap] + +theorem exists_two_shift_integer_interval {N : ℕ} [NeZero N] + (f R : ℤ → ℂ) (h h0 : ZMod N) {rho : ℝ} (hrho : 0 < rho) + (hf : ∀ n, ‖f n‖ ≤ 1) (hR : ∀ n, ‖R n‖ ≤ 1) + (hcorr : rho ≤ ‖𝔼 x : ZMod N, + f x.val * R ((x + h).val : ℤ) * star (R ((x + h0).val : ℤ))‖) : + ∃ (branch branch0 : Bool) (a len : ℕ), 0 < len ∧ a + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + rho / 20 ≤ ‖𝔼 n ∈ Finset.Ico (a : ℤ) (a + len), + f n * R (n + cyclicBranchOffset h branch) * star (R (n + cyclicBranchOffset h0 branch0))‖ ∧ + rho / 20 ≤ (len : ℝ) / N := by + let shifts : Fin 2 → ZMod N := ![h, h0] + let u : Fin 2 → ℤ → ℂ := ![(fun n => star (R n)), R] + have heval (x : ZMod N) : translatedCyclicProduct shifts u x = + star (R ((x + h).val : ℤ)) * R ((x + h0).val : ℤ) := by + simp [translatedCyclicProduct, shifts, u, Fin.prod_univ_two, add_comm] + have hucap (x : ZMod N) : ‖translatedCyclicProduct shifts u x‖ ≤ 1 := by + rw [heval, norm_mul, norm_star] + exact (mul_le_of_le_one_left (norm_nonneg _) (hR _)).trans (hR _) + have hc : rho ≤ ‖finiteCorrelation Finset.univ (fun x : ZMod N => f x.val) + (translatedCyclicProduct shifts u)‖ := by + convert hcorr using 1 + congr 1 + unfold finiteCorrelation + apply Finset.expect_congr rfl + intro x _ + rw [heval] + simp only [star_mul, star_star] + ring + obtain ⟨a, hlen, hbound, hshort, hcor, hvol⟩ := exists_correlating_integer_product_interval + shifts u (fun x : ZMod N => f x.val) hrho (by norm_num : (0 : ℝ) < 1) + (fun x => hf x.val) hucap hc + norm_num only [Fintype.card_fin, Nat.cast_ofNat] at hcor hvol + let branch := decide (N - h.val ≤ a.val) + let branch0 := decide (N - h0.val ≤ a.val) + let len := intervalCutUpper (commonCyclicCuts shifts) N a.val - a.val + have hprod (n : ℤ) : (∏ i, u i (n + cyclicTranslationOffset (shifts i) a.val)) = + star (R (n + cyclicBranchOffset h branch)) * R (n + cyclicBranchOffset h0 branch0) := by + simp only [Fin.prod_univ_two, shifts, u, Matrix.cons_val_zero, Matrix.cons_val_one, + cyclicTranslationOffset_eq_branch, branch, branch0] + rfl + have heq : finiteCorrelation (Finset.Ico (a.val : ℤ) (a.val + len)) + (fun n => f ((n : ZMod N).val : ℤ)) + (fun n => ∏ i, u i (n + cyclicTranslationOffset (shifts i) a.val)) = + 𝔼 n ∈ Finset.Ico (a.val : ℤ) (a.val + len), + f n * R (n + cyclicBranchOffset h branch) * star (R (n + cyclicBranchOffset h0 branch0)) := by + unfold finiteCorrelation + apply Finset.expect_congr rfl + intro n hn + have hn' := Finset.mem_Ico.mp hn + have hrep : (((n : ZMod N).val : ℕ) : ℤ) = n := by + rw [ZMod.val_intCast, Int.emod_eq_of_lt (by omega) (by omega)] + change f (((n : ZMod N).val : ℕ) : ℤ) * + star (∏ i, u i (n + cyclicTranslationOffset (shifts i) a.val)) = _ + rw [hrep, hprod, star_mul, star_star] + ring + refine ⟨branch, branch0, a.val, len, hlen, hbound, hshort, ?_, ?_⟩ + · rw [← heq] + exact hcor + · exact hvol + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_fourPoint_integer_interval {N : ℕ} [NeZero N] + (f₁ f₂ f₃ f₄ : ℤ → ℂ) (a : ZMod N) {ρ B : ℝ} + (hρ : 0 < ρ) (hB : 0 < B) + (hbound : ∀ x : ZMod N, + ‖fourPointProduct (fun x : ZMod N => f₁ x.val) (fun x : ZMod N => f₂ x.val) + (fun x : ZMod N => f₃ x.val) (fun x : ZMod N => f₄ x.val) a x‖ ≤ B) + (hcorr : ρ ≤ ‖𝔼 x : ZMod N, + fourPointProduct (fun x : ZMod N => f₁ x.val) (fun x : ZMod N => f₂ x.val) + (fun x : ZMod N => f₃ x.val) (fun x : ZMod N => f₄ x.val) a x‖) : + ∃ (branch : Bool) (c len : ℕ), 0 < len ∧ c + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + ρ / 20 ≤ ‖𝔼 n ∈ Finset.Ico (c : ℤ) (c + len), + fourPointProduct f₁ f₂ f₃ f₄ (cyclicBranchOffset a branch) n‖ ∧ + ρ / (20 * B) ≤ (len : ℝ) / N := by + let shifts : Fin 2 → ZMod N := ![0, a] + let u : Fin 2 → ℤ → ℂ := ![(fun n => f₁ n * star (f₃ n)), (fun n => star (f₂ n) * f₄ n)] + have heval (x : ZMod N) : star (translatedCyclicProduct shifts u x) = + fourPointProduct (fun x : ZMod N => f₁ x.val) (fun x : ZMod N => f₂ x.val) + (fun x : ZMod N => f₃ x.val) (fun x : ZMod N => f₄ x.val) a x := by + simp only [translatedCyclicProduct, shifts, u, Fin.prod_univ_two, + Matrix.cons_val_zero, Matrix.cons_val_one, zero_add, star_mul, star_star, + fourPointProduct, add_comm a x] + ring + have hu (x : ZMod N) : ‖translatedCyclicProduct shifts u x‖ ≤ B := by + rw [← norm_star, heval] + exact hbound x + have hc : ρ ≤ ‖finiteCorrelation Finset.univ (fun _ : ZMod N => (1 : ℂ)) + (translatedCyclicProduct shifts u)‖ := by + simpa only [finiteCorrelation, one_mul, heval] using hcorr + obtain ⟨c, hlen, hN, hshort, hcor, hvol⟩ := exists_correlating_integer_product_interval + shifts u (fun _ : ZMod N => (1 : ℂ)) hρ hB (fun _ => by norm_num) hu hc + norm_num only [Fintype.card_fin, Nat.cast_ofNat] at hcor hvol + let len := intervalCutUpper (commonCyclicCuts shifts) N c.val - c.val + have hcN : c.val < N := by omega + have hoff : cyclicTranslationOffset (shifts 0) c.val = 0 := by + simp [shifts, cyclicTranslationOffset, Nat.not_le.mpr hcN] + let branch := decide (N - a.val ≤ c.val) + have hprod (n : ℤ) : star (∏ i, u i (n + cyclicTranslationOffset (shifts i) c.val)) = + fourPointProduct f₁ f₂ f₃ f₄ (cyclicBranchOffset a branch) n := by + rw [Fin.prod_univ_two, hoff] + simp only [u, shifts, Matrix.cons_val_zero, Matrix.cons_val_one, add_zero, + cyclicTranslationOffset_eq_branch, star_mul, star_star, fourPointProduct, branch] + ring + refine ⟨branch, c.val, len, hlen, hN, hshort, ?_, ?_⟩ + · simpa only [finiteCorrelation, one_mul, hprod] using hcor + · exact hvol + +end Erdos3 + +end + +section + +namespace Erdos3.NativeCrossWitnesses + +open scoped BigOperators TensorProduct + +attribute [local instance] NativeVectorCorrelation.lie NativeVectorCorrelation.algebra + NativeVectorCorrelation.topology NativeVectorCorrelation.topologicalAdd + NativeVectorCorrelation.continuousSMul NativeVectorCorrelation.hausdorff + +variable {s N : ℕ} [NeZero N] {p : ℝ} {f₀ f₁ : ZMod N → ℂ} + {m : ZMod N → ZMod N → ℂ} {H : Finset (ZMod N)} + (U : NativeCrossWitnesses s N p f₀ f₁ m H) + +noncomputable def integerLower (h : H) (n : ℤ) : ℂ := (U h).test.eval (fun _ => n) + +noncomputable def integerProduct (M : ZMod N → ℤ → ℂ) (h : H) (n : ℤ) : ℂ := + M h.val n * U.integerLower h n + +theorem integerLower_val (h : H) (x : ZMod N) : U.integerLower h x.val = U.lower h x := rfl + +theorem integerProduct_val (M : ZMod N → ℤ → ℂ) + (hM : ∀ h x, m h x = M h x.val) (h : H) (x : ZMod N) : + U.integerProduct M h x.val = U.product h x := by + rw [integerProduct, integerLower_val, product, hM] + rfl + +theorem extension_quadruple_integer (M : ZMod N → ℤ → ℂ) + (hM : ∀ h x, m h x = M h x.val) (a h k : ZMod N) + (h₁ : h ∈ H) (h₂ : h - a ∈ H) (h₃ : k ∈ H) (h₄ : k - a ∈ H) : + additiveQuadrupleCorrelation U.extension a h k = + ‖𝔼 x : ZMod N, + fourPointProduct (fun x : ZMod N => U.integerProduct M ⟨h, h₁⟩ x.val) + (fun x : ZMod N => U.integerProduct M ⟨h - a, h₂⟩ x.val) + (fun x : ZMod N => U.integerProduct M ⟨k, h₃⟩ x.val) + (fun x : ZMod N => U.integerProduct M ⟨k - a, h₄⟩ x.val) a x‖ := by + simp only [additiveQuadrupleCorrelation, fourPointProduct, U.integerProduct_val M hM, + U.extension_of_mem h h₁, U.extension_of_mem (h - a) h₂, + U.extension_of_mem k h₃, U.extension_of_mem (k - a) h₄] + +theorem exists_integer_quadruple_interval (M : ZMod N → ℤ → ℂ) + (hM : ∀ h x, m h x = M h x.val) (hm : ∀ h x, ‖m h x‖ ≤ 1) + (a h k : ZMod N) (h₁ : h ∈ H) (h₂ : h - a ∈ H) (h₃ : k ∈ H) (h₄ : k - a ∈ H) + {ρ : ℝ} (hρ : 0 < ρ) (hcorr : ρ ≤ additiveQuadrupleCorrelation U.extension a h k) : + ∃ (branch : Bool) (c len : ℕ), 0 < len ∧ c + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + ρ / 20 ≤ ‖𝔼 n ∈ Finset.Ico (c : ℤ) (c + len), + fourPointProduct (U.integerProduct M ⟨h, h₁⟩) (U.integerProduct M ⟨h - a, h₂⟩) + (U.integerProduct M ⟨k, h₃⟩) (U.integerProduct M ⟨k - a, h₄⟩) + (cyclicBranchOffset a branch) n‖ ∧ + ρ / (20 * Real.exp (4 * p)) ≤ (len : ℝ) / N := by + apply exists_fourPoint_integer_interval _ _ _ _ a hρ (Real.exp_pos _) + · intro x + simp only [fourPointProduct, U.integerProduct_val M hM, norm_mul, norm_star] + calc + _ ≤ Real.exp p * Real.exp p * Real.exp p * Real.exp p := + mul_le_mul (mul_le_mul (mul_le_mul (U.product_norm hm _ _) (U.product_norm hm _ _) + (norm_nonneg _) (Real.exp_nonneg _)) (U.product_norm hm _ _) + (norm_nonneg _) (by positivity)) (U.product_norm hm _ _) (norm_nonneg _) (by positivity) + _ = _ := by rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add]; congr 1; ring + · rwa [← U.extension_quadruple_integer M hM a h k h₁ h₂ h₃ h₄] + +theorem integerProduct_fourPoint_factorization (A B : ZMod N → ℤ → ℂ) + (h₁ h₂ h₃ h₄ : H) (a n : ℤ) : + fourPointProduct (U.integerProduct (fun h x => A h x * B h x) h₁) + (U.integerProduct (fun h x => A h x * B h x) h₂) + (U.integerProduct (fun h x => A h x * B h x) h₃) + (U.integerProduct (fun h x => A h x * B h x) h₄) a n = + fourPointProduct (A h₁) (A h₂) (A h₃) (A h₄) a n * + fourPointProduct (B h₁) (B h₂) (B h₃) (B h₄) a n * + fourPointProduct (U.integerLower h₁) (U.integerLower h₂) + (U.integerLower h₃) (U.integerLower h₄) a n := by + simp only [fourPointProduct, integerProduct, star_mul] + ring + +theorem exists_integer_quadruple_interval_budget (M : ZMod N → ℤ → ℂ) + (hM : ∀ h x, m h x = M h x.val) (hm : ∀ h x, ‖m h x‖ ≤ 1) + (a h k : ZMod N) (h₁ : h ∈ H) (h₂ : h - a ∈ H) (h₃ : k ∈ H) (h₄ : k - a ∈ H) + {b : ℝ} (hcorr : Real.exp (-b) ≤ additiveQuadrupleCorrelation U.extension a h k) : + ∃ (branch : Bool) (c len : ℕ), 0 < len ∧ c + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + Real.exp (-(b + 4 * p + 5)) ≤ ‖𝔼 n ∈ Finset.Ico (c : ℤ) (c + len), + fourPointProduct (U.integerProduct M ⟨h, h₁⟩) (U.integerProduct M ⟨h - a, h₂⟩) + (U.integerProduct M ⟨k, h₃⟩) (U.integerProduct M ⟨k - a, h₄⟩) + (cyclicBranchOffset a branch) n‖ ∧ + Real.exp (-(b + 4 * p + 5)) ≤ (len : ℝ) / N := by + have hp : 0 ≤ p := (Nat.cast_nonneg (U ⟨h, h₁⟩).dim).trans (U ⟨h, h₁⟩).complexity.1.1 + have h20 : (20 : ℝ) ≤ Real.exp 5 := + (by norm_num : (20 : ℝ) ≤ 2 ^ 5).trans (two_pow_le_exp_of_le 5 le_rfl) + have hfrac : Real.exp (-(b + 4 * p + 5)) ≤ Real.exp (-b) / (20 * Real.exp (4 * p)) := by + apply (le_div_iff₀ (by positivity : (0 : ℝ) < 20 * Real.exp (4 * p))).mpr + calc + _ ≤ Real.exp (-(b + 4 * p + 5)) * (Real.exp 5 * Real.exp (4 * p)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right h20 (Real.exp_nonneg _)) + (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hone : 1 ≤ Real.exp (4 * p) := Real.one_le_exp_iff.mpr (by positivity) + have hfrac' : Real.exp (-(b + 4 * p + 5)) ≤ Real.exp (-b) / 20 := + hfrac.trans (div_le_div_of_nonneg_left (Real.exp_nonneg _) (by norm_num) + (by nlinarith only [hone])) + obtain ⟨branch, c, len, hlen, hN, hshort, hc, hvol⟩ := U.exists_integer_quadruple_interval + M hM hm a h k h₁ h₂ h₃ h₄ (Real.exp_pos (-b)) hcorr + exact ⟨branch, c, len, hlen, hN, hshort, hfrac'.trans hc, hfrac.trans hvol⟩ + +end Erdos3.NativeCrossWitnesses + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +structure NativeIntegerQuadrupleWitness {s N : ℕ} [NeZero N] {p : ℝ} + {f₀ f₁ : ZMod N → ℂ} {m : ZMod N → ZMod N → ℂ} {H : Finset (ZMod N)} + (U : NativeCrossWitnesses s N p f₀ f₁ m H) (M : ZMod N → ℤ → ℂ) + (q : ℝ) (t : ZMod N × ZMod N × ZMod N) where + first_mem : t.2.1 ∈ H + second_mem : t.2.1 - t.1 ∈ H + third_mem : t.2.2 ∈ H + fourth_mem : t.2.2 - t.1 ∈ H + integer_relation : + -(t.2.1.val : ℤ) + (t.2.1 - t.1).val + t.2.2.val - (t.2.2 - t.1).val = 0 + cyclic_correlation : Real.exp (-q) ≤ additiveQuadrupleCorrelation U.extension t.1 t.2.1 t.2.2 + branch : Bool + start : ℕ + length : ℕ + length_pos : 0 < length + endpoint_le : start + length ≤ N + length_short : 2 * ((length : ℤ) - 1) < N + correlation : Real.exp (-q) ≤ ‖𝔼 n ∈ Finset.Ico (start : ℤ) (start + length), + fourPointProduct + (U.integerProduct M ⟨t.2.1, first_mem⟩) + (U.integerProduct M ⟨t.2.1 - t.1, second_mem⟩) + (U.integerProduct M ⟨t.2.2, third_mem⟩) + (U.integerProduct M ⟨t.2.2 - t.1, fourth_mem⟩) + (cyclicBranchOffset t.1 branch) n‖ + length_ratio : Real.exp (-q) ≤ (length : ℝ) / N + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +namespace NativeCorrelationStructure + +noncomputable def multilinearFactor {s r N : ℕ} [NeZero N] {p q : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f) + (V : NativeMultidegreeNilcharacter (fun _ : ReplicatedIndex (mixedCorrelationDegree s) => 1) q) + (k : Fin V.outputDim) (i : Fin W.family.outputDim) (h : ZMod N) (n : ℤ) : ℂ := + V.eval k (fun j => correlationInput (h.val : ℤ) n j.1) * W.family.eval i h n + +end NativeCorrelationStructure + +theorem exists_integer_multilinear_quadruples (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + ∃ V : NativeMultidegreeNilcharacter + (fun _ : ReplicatedIndex (mixedCorrelationDegree s) => 1) ((p + C) ^ C), + V.dim ≤ 2 ^ (s + 1) * W.mixed.dim ∧ + (∀ (e : ReplicatedPermutation (mixedCorrelationDegree s)) k x, + V.eval k (fun j => x ((replicatedPermutation (mixedCorrelationDegree s) e).symm j)) = + V.eval k x) ∧ + ∃ (k : Fin V.outputDim) (i : Fin W.family.outputDim) (weight : ZMod N → ℂ) + (H : Finset (ZMod N)), (∀ x, ‖weight x‖ ≤ 1) ∧ H ⊆ W.shifts ∧ H.Nonempty ∧ + CyclicShortShiftSet H ∧ + Real.exp (-((p + C) ^ C)) * Fintype.card (ZMod N) ≤ (H.card : ℝ) ∧ + ∃ U : NativeCrossWitnesses (s - 1) N ((p + C) ^ C) + (fun x => f x * star (weight x)) f + (fun h x => W.multilinearFactor V k i h x.val) H, + ∃ Q : Finset (ZMod N × ZMod N × ZMod N), Q.Nonempty ∧ + Real.exp (-((p + C) ^ C)) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ (Q.card : ℝ) ∧ + ∀ t ∈ Q, ∃ (h₁ : t.2.1 ∈ H) (h₂ : t.2.1 - t.1 ∈ H) + (h₃ : t.2.2 ∈ H) (h₄ : t.2.2 - t.1 ∈ H), + -(t.2.1.val : ℤ) + (t.2.1 - t.1).val + t.2.2.val - (t.2.2 - t.1).val = 0 ∧ + Real.exp (-((p + C) ^ C)) ≤ + additiveQuadrupleCorrelation U.extension t.1 t.2.1 t.2.2 ∧ + ∃ (branch : Bool) (c len : ℕ), 0 < len ∧ c + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + Real.exp (-((p + C) ^ C)) ≤ ‖𝔼 n ∈ Finset.Ico (c : ℤ) (c + len), + fourPointProduct + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.1, h₁⟩) + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.1 - t.1, h₂⟩) + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.2, h₃⟩) + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.2 - t.1, h₄⟩) + (cyclicBranchOffset t.1 branch) n‖ ∧ + Real.exp (-((p + C) ^ C)) ≤ (len : ℝ) / N := by + obtain ⟨a, _, hmulti⟩ := exists_multilinear_quadruples s + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (17 * (X + Polynomial.C a) ^ a + 20) + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf + have hp : 0 ≤ p := (Nat.cast_nonneg W.mixed.dim).trans W.mixed.complexity.1.1 + let q := (p + a) ^ a + have hq : 0 ≤ q := by dsimp [q]; positivity + have hcost : 17 * q + 20 ≤ (p + C) ^ C := by + simpa [X, q, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := by linarith only [hq, hcost] + have hHC : q + 1 ≤ (p + C) ^ C := by linarith only [hq, hcost] + have hQC : 13 * (q + 1) + 2 ≤ (p + C) ^ C := by linarith only [hq, hcost] + have hIC : 13 * (q + 1) + 2 + 4 * q + 5 ≤ (p + C) ^ C := by linarith only [hcost] + obtain ⟨V, hdim, hsymm, k, i, weight, H, hweight, hsub, hH, hdense, U, _⟩ := hmulti W hf + let M := W.multilinearFactor V k i + have hm (h x : ZMod N) : ‖M h x.val‖ ≤ 1 := by + dsimp only [M, NativeCorrelationStructure.multilinearFactor] + rw [norm_mul] + exact (mul_le_of_le_one_left (norm_nonneg _) (V.norm_eval k _)).trans + (W.family.norm_eval i h (x.val : ℤ)) + have hf₀ (x : ZMod N) : ‖f x * star (weight x)‖ ≤ 1 := by + rw [norm_mul, norm_star] + exact (mul_le_of_le_one_left (norm_nonneg _) (hf x)).trans (hweight x) + obtain ⟨S, hSH, hS, hshort, hSsize, Q, hQ, hQsize, hquad⟩ := + U.exists_short_quadruples hH hf₀ hf hm hdense + refine ⟨V.mono hqC, hdim, hsymm, k, i, weight, S, hweight, + fun x hx => hsub (hSH hx), hS, hshort, ?_, (U.restrict hSH).mono hqC, Q, hQ, ?_, ?_⟩ + · exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hHC)) + (Nat.cast_nonneg _)).trans hSsize + · exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hQC)) + (by positivity)).trans hQsize + · intro t ht + obtain ⟨h₁, h₂, h₃, h₄, hrel, hc⟩ := hquad t ht + obtain ⟨branch, c, len, hlen, hN, hlenShort, hcor, hvol⟩ := + U.exists_integer_quadruple_interval_budget M (fun _ _ => rfl) hm + t.1 t.2.1 t.2.2 (hSH h₁) (hSH h₂) (hSH h₃) (hSH h₄) hc + refine ⟨h₁, h₂, h₃, h₄, hrel, ?_, branch, c, len, hlen, hN, hlenShort, ?_, ?_⟩ + · change Real.exp (-((p + C) ^ C)) ≤ + additiveQuadrupleCorrelation (U.restrict hSH).extension t.1 t.2.1 t.2.2 + rw [U.restrict_quadruple hSH t.1 t.2.1 t.2.2 h₁ h₂ h₃ h₄] + exact (Real.exp_le_exp.mpr (neg_le_neg hQC)).trans hc + · change Real.exp (-((p + C) ^ C)) ≤ ‖𝔼 n ∈ Finset.Ico (c : ℤ) (c + len), + fourPointProduct (U.integerProduct M ⟨t.2.1, hSH h₁⟩) + (U.integerProduct M ⟨t.2.1 - t.1, hSH h₂⟩) + (U.integerProduct M ⟨t.2.2, hSH h₃⟩) + (U.integerProduct M ⟨t.2.2 - t.1, hSH h₄⟩) (cyclicBranchOffset t.1 branch) n‖ + exact (Real.exp_le_exp.mpr (neg_le_neg hIC)).trans hcor + · exact (Real.exp_le_exp.mpr (neg_le_neg hIC)).trans hvol + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_integer_multilinear_quadruples_with_equivalence (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + ∃ V : NativeMultidegreeNilcharacter + (fun _ : ReplicatedIndex (mixedCorrelationDegree s) => 1) ((p + C) ^ C), + V.dim ≤ 2 ^ (s + 1) * W.mixed.dim ∧ + (∀ (e : ReplicatedPermutation (mixedCorrelationDegree s)) k x, + V.eval k (fun j => x ((replicatedPermutation (mixedCorrelationDegree s) e).symm j)) = + V.eval k x) ∧ + NativeIntegerVectorEquivalence s ((p + C) ^ C) W.mixed.eval + (fun k x => V.eval k (fun j => x j.1)) ∧ + ∃ (k : Fin V.outputDim) (i : Fin W.family.outputDim) (weight : ZMod N → ℂ) + (H : Finset (ZMod N)), (∀ x, ‖weight x‖ ≤ 1) ∧ H ⊆ W.shifts ∧ H.Nonempty ∧ + CyclicShortShiftSet H ∧ + Real.exp (-((p + C) ^ C)) * Fintype.card (ZMod N) ≤ (H.card : ℝ) ∧ + ∃ U : NativeCrossWitnesses (s - 1) N ((p + C) ^ C) + (fun x => f x * star (weight x)) f + (fun h x => W.multilinearFactor V k i h x.val) H, + ∃ Q : Finset (ZMod N × ZMod N × ZMod N), Q.Nonempty ∧ + Real.exp (-((p + C) ^ C)) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ (Q.card : ℝ) ∧ + ∀ t ∈ Q, ∃ (h₁ : t.2.1 ∈ H) (h₂ : t.2.1 - t.1 ∈ H) + (h₃ : t.2.2 ∈ H) (h₄ : t.2.2 - t.1 ∈ H), + -(t.2.1.val : ℤ) + (t.2.1 - t.1).val + t.2.2.val - (t.2.2 - t.1).val = 0 ∧ + Real.exp (-((p + C) ^ C)) ≤ + additiveQuadrupleCorrelation U.extension t.1 t.2.1 t.2.2 ∧ + ∃ (branch : Bool) (c len : ℕ), 0 < len ∧ c + len ≤ N ∧ + 2 * ((len : ℤ) - 1) < N ∧ + Real.exp (-((p + C) ^ C)) ≤ ‖𝔼 n ∈ Finset.Ico (c : ℤ) (c + len), + fourPointProduct + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.1, h₁⟩) + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.1 - t.1, h₂⟩) + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.2, h₃⟩) + (U.integerProduct (W.multilinearFactor V k i) ⟨t.2.2 - t.1, h₄⟩) + (cyclicBranchOffset t.1 branch) n‖ ∧ + Real.exp (-((p + C) ^ C)) ≤ (len : ℝ) / N := by + obtain ⟨a, _, hmulti⟩ := exists_multilinear_quadruples_with_equivalence s + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (17 * (X + Polynomial.C a) ^ a + 20) + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf + have hp : 0 ≤ p := (Nat.cast_nonneg W.mixed.dim).trans W.mixed.complexity.1.1 + let q := (p + a) ^ a + have hq : 0 ≤ q := by dsimp [q]; positivity + have hcost : 17 * q + 20 ≤ (p + C) ^ C := by + simpa [X, q, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := by linarith only [hq, hcost] + have hHC : q + 1 ≤ (p + C) ^ C := by linarith only [hq, hcost] + have hQC : 13 * (q + 1) + 2 ≤ (p + C) ^ C := by linarith only [hq, hcost] + have hIC : 13 * (q + 1) + 2 + 4 * q + 5 ≤ (p + C) ^ C := by linarith only [hcost] + obtain ⟨V, hdim, hsymm, E, k, i, weight, H, hweight, hsub, hH, hdense, U, _⟩ := hmulti W hf + let M := W.multilinearFactor V k i + have hm (h x : ZMod N) : ‖M h x.val‖ ≤ 1 := by + dsimp only [M, NativeCorrelationStructure.multilinearFactor] + rw [norm_mul] + exact (mul_le_of_le_one_left (norm_nonneg _) (V.norm_eval k _)).trans + (W.family.norm_eval i h (x.val : ℤ)) + have hf₀ (x : ZMod N) : ‖f x * star (weight x)‖ ≤ 1 := by + rw [norm_mul, norm_star] + exact (mul_le_of_le_one_left (norm_nonneg _) (hf x)).trans (hweight x) + obtain ⟨S, hSH, hS, hshort, hSsize, Q, hQ, hQsize, hquad⟩ := + U.exists_short_quadruples hH hf₀ hf hm hdense + refine ⟨V.mono hqC, hdim, hsymm, E.mono hqC, k, i, weight, S, hweight, + fun x hx => hsub (hSH hx), hS, hshort, ?_, (U.restrict hSH).mono hqC, Q, hQ, ?_, ?_⟩ + · exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hHC)) + (Nat.cast_nonneg _)).trans hSsize + · exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hQC)) + (by positivity)).trans hQsize + · intro t ht + obtain ⟨h₁, h₂, h₃, h₄, hrel, hc⟩ := hquad t ht + obtain ⟨branch, c, len, hlen, hN, hlenShort, hcor, hvol⟩ := + U.exists_integer_quadruple_interval_budget M (fun _ _ => rfl) hm + t.1 t.2.1 t.2.2 (hSH h₁) (hSH h₂) (hSH h₃) (hSH h₄) hc + refine ⟨h₁, h₂, h₃, h₄, hrel, ?_, branch, c, len, hlen, hN, hlenShort, ?_, ?_⟩ + · change Real.exp (-((p + C) ^ C)) ≤ + additiveQuadrupleCorrelation (U.restrict hSH).extension t.1 t.2.1 t.2.2 + rw [U.restrict_quadruple hSH t.1 t.2.1 t.2.2 h₁ h₂ h₃ h₄] + exact (Real.exp_le_exp.mpr (neg_le_neg hQC)).trans hc + · change Real.exp (-((p + C) ^ C)) ≤ ‖𝔼 n ∈ Finset.Ico (c : ℤ) (c + len), + fourPointProduct (U.integerProduct M ⟨t.2.1, hSH h₁⟩) + (U.integerProduct M ⟨t.2.1 - t.1, hSH h₂⟩) + (U.integerProduct M ⟨t.2.2, hSH h₃⟩) + (U.integerProduct M ⟨t.2.2 - t.1, hSH h₄⟩) (cyclicBranchOffset t.1 branch) n‖ + exact (Real.exp_le_exp.mpr (neg_le_neg hIC)).trans hcor + · exact (Real.exp_le_exp.mpr (neg_le_neg hIC)).trans hvol + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeSampleVerticalAffineExpansion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeSampleVerticalAffineExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..a52557fc0a1022d5c48e9038f778503adfbc3ed5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeSampleVerticalAffineExpansion.lean @@ -0,0 +1,204 @@ +import OAI.Combinatorics.Progressions.Estimates.SampledNativeModel + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +attribute [local instance] NativeSampleModel.lie NativeSampleModel.algebra + NativeSampleModel.topology NativeSampleModel.topologicalAdd + NativeSampleModel.continuousSMul NativeSampleModel.hausdorff + +namespace NativeSampleModel + +variable {σ X Y Ω : Type*} [Fintype Y] {degree : ℕ} {p : ℝ} + {sample : X → σ → ℤ} {f : X → ℂ} + +noncomputable def affineRestrictionTest + (native : NativeSampleModel (fun _ : σ => 1) degree p sample f) + (A : σ → Y → ℤ) (b : σ → ℤ) : native.model.Niltest (fun _ : Y => 1) := + native.test.affinePullback A b + +theorem affineRestrictionTest_eval + (native : NativeSampleModel (fun _ : σ => 1) degree p sample f) + (physical : (Y → ℤ) → X) (A : σ → Y → ℤ) (b : σ → ℤ) + (hsample : ∀ t, sample (physical t) = integerAffineMap A b t) + (t : Y → ℤ) : + (native.affineRestrictionTest A b).eval t = f (physical t) := by + rw [affineRestrictionTest, native.test.eval_affinePullback, ← hsample t, + ← native.eval] + +theorem exists_affineRestriction_family + (native : NativeSampleModel (fun _ : σ => 1) degree p sample f) + (physical : Ω → (Y → ℤ) → X) (A : Ω → σ → Y → ℤ) (b : Ω → σ → ℤ) + (hsample : ∀ a t, sample (physical a t) = integerAffineMap (A a) (b a) t) : + ∃ tests : Ω → native.model.Niltest (fun _ : Y => 1), + ∀ a, (tests a).observable = native.test.observable ∧ + (tests a).normBound = native.test.normBound ∧ + (tests a).lipBound = native.test.lipBound ∧ + (tests a).normBound ≤ 1 ∧ (tests a).ComplexityLE p ∧ + ∀ t, (tests a).eval t = f (physical a t) := by + refine ⟨fun a => native.affineRestrictionTest (A a) (b a), ?_⟩ + intro a + refine ⟨rfl, rfl, rfl, native.norm, ?_, ?_⟩ + · exact (native.test.affinePullback_complexityLE (A a) (b a) p).mpr native.complexity + · exact native.affineRestrictionTest_eval (physical a) (A a) (b a) (hsample a) + +end NativeSampleModel + +namespace BooleanCubeKernel + +theorem jointIntegerPhysicalSite_eq_integerAffineMap {K I : Type*} [Fintype K] + (root : K → ℤ) (z : (I → ℤ) × (Option K × I → ℤ)) : + jointIntegerPhysicalSite root z = + integerAffineMap (fun i j => z.2 (some j, i)) + (fun i => z.1 i + z.2 (none, i)) root := by + funext i + simp only [jointIntegerPhysicalSite, Pi.add_apply, integerPhysicalSite, + integerAffineMap, mul_comm, add_assoc] + +end BooleanCubeKernel + +namespace NativeSampleModel + +theorem exists_jointPhysicalRestriction_family + {K I Ω : Type*} [Fintype K] {degree : ℕ} {p : ℝ} {f : (I → ℤ) → ℂ} + (native : NativeSampleModel (fun _ : I => 1) degree p id f) + (z : Ω → (I → ℤ) × (Option K × I → ℤ)) : + ∃ tests : Ω → native.model.Niltest (fun _ : K => 1), + ∀ a, (tests a).observable = native.test.observable ∧ + (tests a).normBound = native.test.normBound ∧ + (tests a).lipBound = native.test.lipBound ∧ + (tests a).normBound ≤ 1 ∧ (tests a).ComplexityLE p ∧ + ∀ t, (tests a).eval t = f (BooleanCubeKernel.jointIntegerPhysicalSite t (z a)) := by + exact native.exists_affineRestriction_family + (fun a t => BooleanCubeKernel.jointIntegerPhysicalSite t (z a)) + (fun a i j => (z a).2 (some j, i)) + (fun a i => (z a).1 i + (z a).2 (none, i)) + (fun a t => BooleanCubeKernel.jointIntegerPhysicalSite_eq_integerAffineMap t (z a)) + +end NativeSampleModel + +end Erdos3 + +end + +section + +namespace Erdos3.NativeSampleModel + +open CircleFourier +open scoped TensorProduct BigOperators + +attribute [local instance] NativeSampleModel.lie NativeSampleModel.algebra + NativeSampleModel.topology NativeSampleModel.topologicalAdd + NativeSampleModel.continuousSMul NativeSampleModel.hausdorff + +namespace VerticalExpansion + +variable {σ X Y : Type*} [Fintype Y] {degree : ℕ} {p q rho : ℝ} + {sample : X → σ → ℤ} {f : X → ℂ} + {native : NativeSampleModel (fun _ : σ => 1) degree p sample f} + (E : native.VerticalExpansion q rho) + +noncomputable def affineComponent (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) : + native.model.Niltest (fun _ : Y => 1) := + (E.component i).affinePullback A b + +@[simp] theorem affineComponent_observable (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) : + (E.affineComponent A b i).observable = (E.component i).observable := rfl + +theorem affineComponent_orbit (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) : + (E.affineComponent A b i).orbit = (native.test.affinePullback A b).orbit := by + change native.model.filtration.realification.polynomialOrbitSubstitute _ _ + (E.component i).orbit = + native.model.filtration.realification.polynomialOrbitSubstitute _ _ native.test.orbit + rw [E.orbit_eq] + +@[simp] theorem affineComponent_normBound (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) : + (E.affineComponent A b i).normBound = native.test.normBound := E.norm_eq i + +@[simp] theorem affineComponent_lipBound (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) : + (E.affineComponent A b i).lipBound = native.test.lipBound := E.lip_eq i + +theorem affineComponent_complexity (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) : + (E.affineComponent A b i).ComplexityLE p := E.complexity i + +theorem affineComponent_normBound_le (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) : + (E.affineComponent A b i).normBound ≤ 1 := E.normBound_le i + +theorem affineComponent_vertical (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) + (z : native.model.RealGroup) + (hz : z ∈ native.model.filtration.realification.subgroup degree) + (x : native.model.Space) : + (E.affineComponent A b i).observable (z • x) = + character ((realifyFunctional (E.frequency i) z.coord : ℝ) : CircleFourier.Circle) * + (E.affineComponent A b i).observable x := E.vertical i z hz x + +theorem affineComponent_integral (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) + (hi : ∃ x, (E.affineComponent A b i).observable x ≠ 0) + (z : native.model.RealGroup) + (hz : z ∈ native.model.filtration.realification.subgroup degree) + (hΓ : z ∈ native.model.realLattice) : + ∃ n : ℤ, realifyFunctional (E.frequency i) z.coord = n := E.integral i hi z hz hΓ + +theorem affineComponent_preserves_character (A : σ → Y → ℤ) (b : σ → ℤ) + (z : native.model.RealGroup) (c : ℂ) + (hchar : ∀ x, native.test.observable (z • x) = c * native.test.observable x) + (i : E.I) (x : native.model.Space) : + (E.affineComponent A b i).observable (z • x) = + c * (E.affineComponent A b i).observable x := E.preserves_character z c hchar i x + +@[simp] theorem affineComponent_eval (A : σ → Y → ℤ) (b : σ → ℤ) (i : E.I) + (t : Y → ℤ) : + (E.affineComponent A b i).eval t = (E.component i).eval (integerAffineMap A b t) := + (E.component i).eval_affinePullback A b t + +theorem affineComponent_eval_error (A : σ → Y → ℤ) (b : σ → ℤ) (t : Y → ℤ) : + ‖(∑ i, (E.affineComponent A b i).eval t) - + (native.test.affinePullback A b).eval t‖ ≤ rho := by + simpa only [affineComponent_eval, RationalFilteredNilmanifold.Niltest.eval_affinePullback] + using E.eval_error (integerAffineMap A b t) + +theorem affineComponent_sample_error (physical : (Y → ℤ) → X) + (A : σ → Y → ℤ) (b : σ → ℤ) + (hsample : ∀ t, sample (physical t) = integerAffineMap A b t) (t : Y → ℤ) : + ‖(∑ i, (E.affineComponent A b i).eval t) - f (physical t)‖ ≤ rho := by + simpa only [affineComponent_eval, ← hsample t] using E.sample_error (physical t) + +theorem affineComponent_norm_eval_le (A : σ → Y → ℤ) (b : σ → ℤ) + (i : E.I) (t : Y → ℤ) : ‖(E.affineComponent A b i).eval t‖ ≤ 1 := by + rw [E.affineComponent_eval] + exact E.norm_eval_le i _ + +section JointPhysical + +variable {K I : Type*} [Fintype K] {g : (I → ℤ) → ℂ} + {jointNative : NativeSampleModel (fun _ : I => 1) degree p id g} + (Ejoint : jointNative.VerticalExpansion q rho) + +noncomputable def jointPhysicalComponent + (z : (I → ℤ) × (Option K × I → ℤ)) (i : Ejoint.I) : + jointNative.model.Niltest (fun _ : K => 1) := + Ejoint.affineComponent (fun a k => z.2 (some k, a)) + (fun a => z.1 a + z.2 (none, a)) i + +theorem jointPhysicalComponent_error + (z : (I → ℤ) × (Option K × I → ℤ)) (t : K → ℤ) : + ‖(∑ i, (Ejoint.jointPhysicalComponent z i).eval t) - + g (BooleanCubeKernel.jointIntegerPhysicalSite t z)‖ ≤ rho := + Ejoint.affineComponent_sample_error + (fun t => BooleanCubeKernel.jointIntegerPhysicalSite t z) + (fun a k => z.2 (some k, a)) (fun a => z.1 a + z.2 (none, a)) + (fun t => BooleanCubeKernel.jointIntegerPhysicalSite_eq_integerAffineMap t z) t + +end JointPhysical +end VerticalExpansion +end Erdos3.NativeSampleModel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NativeSquarefreeLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NativeSquarefreeLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb0eeaa1ddc6b64d5be68ea3a787c2caec9603ea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NativeSquarefreeLattice.lean @@ -0,0 +1,40 @@ +import OAI.Combinatorics.Progressions.Sampling.NativeSquarefreeGrids + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +variable {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) + +def SquarefreeGridStable (p : ℝ) (B : ℕ) : Prop := + ∀ x ∈ coordinateGridModule (M.squarefreeBasis p) B, + ∀ y ∈ coordinateGridModule (M.squarefreeBasis p) B, + lieBCH (Fintype.card (ReplicatedIndex bound)) x y ∈ coordinateGridModule (M.squarefreeBasis p) B + +noncomputable def squarefreeLattice (p : ℝ) (B : ℕ) (hstable : M.SquarefreeGridStable p B) : + Subgroup (M.filtration.squarefreeOrdinaryFiltration (fun j : ReplicatedIndex bound => j.1)).Group := + coordinateGridBCHSubgroup (M.squarefreeBasis p) B + (M.filtration.squarefreeOrdinaryFiltration (fun j : ReplicatedIndex bound => j.1)).lowerCentralSeries_eq_bot + hstable + +theorem squarefreeLattice_coordinates (p : ℝ) (B : ℕ) (hstable : M.SquarefreeGridStable p B) : + bchSubgroupCoordinates (M.squarefreeBasis p) (M.squarefreeLattice p B hstable) = scaledIntegerGrid B := + coordinateGridBCHSubgroup_coordinates _ _ _ hstable + +theorem squarefreeLattice_permute (p : ℝ) (B : ℕ) (hstable : M.SquarefreeGridStable p B) + (e : Equiv.Perm (ReplicatedIndex bound)) (he : ∀ j, (e j).1 = j.1) + (g : (M.filtration.squarefreeOrdinaryFiltration (fun j : ReplicatedIndex bound => j.1)).Group) : + NilpotentLieBCHGroup.map + (M.filtration.squarefreeBlockPermute (fun j : ReplicatedIndex bound => j.1) e he).toLieHom g ∈ + M.squarefreeLattice p B hstable ↔ g ∈ M.squarefreeLattice p B hstable := + M.squarefreeGrid_permute_iff p e he B g.coord + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NaturalScaleIntegerWindow.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NaturalScaleIntegerWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..da3f69f892b5b6c97f0c62d0dc6945e18c52bc3d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NaturalScaleIntegerWindow.lean @@ -0,0 +1,285 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι G : Type*} [Fintype ι] [DecidableEq ι] [AddCommGroup G] + +noncomputable def centeredIntegerBox (R : ι → ℕ) : Finset (ι → ℤ) := + Fintype.piFinset (fun i => Finset.Icc (-(R i : ℤ)) (R i : ℤ)) + +@[simp] theorem mem_centeredIntegerBox (R : ι → ℕ) (x : ι → ℤ) : + x ∈ centeredIntegerBox R ↔ ∀ i, |x i| ≤ (R i : ℤ) := by + simp only [centeredIntegerBox, Fintype.mem_piFinset, Finset.mem_Icc, abs_le] + +@[simp] theorem card_centeredIntegerBox (R : ι → ℕ) : + (centeredIntegerBox R).card = ∏ i, (2 * R i + 1) := by + rw [centeredIntegerBox, Fintype.card_piFinset] + apply Finset.prod_congr rfl + intro i _ + rw [Int.card_Icc] + omega + +theorem card_doubled_centeredIntegerBox_le (R : ι → ℕ) : + (centeredIntegerBox (fun i => 2 * R i)).card ≤ + 2 ^ Fintype.card ι * (centeredIntegerBox R).card := by + rw [card_centeredIntegerBox, card_centeredIntegerBox] + calc + (∏ i, (2 * (2 * R i) + 1)) ≤ ∏ i, (2 * (2 * R i + 1)) := by + gcongr with i + omega + _ = _ := by rw [Finset.prod_mul_distrib]; simp + +omit [Fintype ι] [DecidableEq ι] in +theorem card_mul_le_of_kernel_translates (φ : (ι → ℤ) →+ G) + (S X : Finset (ι → ℤ)) (k : ℕ) (v : ι → ℤ) (hv : v ≠ 0) + (hker : φ v = 0) (hinj : Set.InjOn φ (S : Set _)) + (hsub : ∀ x ∈ S, ∀ j < k, x + j • v ∈ X) : S.card * k ≤ X.card := by + classical + rw [← Finset.card_range k, ← Finset.card_product] + apply Finset.card_le_card_of_injOn (fun z : (ι → ℤ) × ℕ => z.1 + z.2 • v) + · intro z hz + exact hsub z.1 (Finset.mem_product.mp hz).1 z.2 + (Finset.mem_range.mp (Finset.mem_product.mp hz).2) + · intro x hx y hy hxy + change x.1 + x.2 • v = y.1 + y.2 • v at hxy + have hφ : φ x.1 = φ y.1 := by + have h := congrArg φ hxy + simpa only [map_add, map_nsmul, hker, nsmul_zero, add_zero] using h + have hbase : x.1 = y.1 := hinj (Finset.mem_product.mp hx).1 + (Finset.mem_product.mp hy).1 hφ + apply Prod.ext hbase + have hmul : x.2 • v = y.2 • v := by + rw [hbase] at hxy + exact add_left_cancel hxy + have hnonzero : ¬ ∀ i, v i = 0 := fun h => hv (funext h) + obtain ⟨i, hi⟩ := not_forall.mp hnonzero + have hiEq := congrFun hmul i + simp only [Pi.smul_apply, nsmul_eq_mul] at hiEq + exact_mod_cast mul_right_cancel₀ hi hiEq + +theorem kernel_eq_zero_of_dense_integer_box (φ : (ι → ℤ) →+ G) + (S : Finset (ι → ℤ)) (R : ι → ℕ) (k : ℕ) + (hS : S ⊆ centeredIntegerBox R) (hinj : Set.InjOn φ (S : Set _)) + (hlarge : (centeredIntegerBox (fun i => 2 * R i)).card < S.card * k) + (v : ι → ℤ) (hker : φ v = 0) (hshort : ∀ i, (k : ℤ) * |v i| ≤ (R i : ℤ)) : + v = 0 := by + by_contra hv + apply (not_le_of_gt hlarge) + apply card_mul_le_of_kernel_translates φ S (centeredIntegerBox (fun i => 2 * R i)) k v hv hker hinj + intro x hx j hj + apply (mem_centeredIntegerBox _ _).mpr + intro i + have hxi := (mem_centeredIntegerBox R x).mp (hS hx) i + have hjk : (j : ℤ) ≤ k := by exact_mod_cast hj.le + have hbound : |x i + (j : ℤ) * v i| ≤ 2 * (R i : ℤ) := by + calc + _ ≤ |x i| + |(j : ℤ) * v i| := abs_add_le _ _ + _ = |x i| + (j : ℤ) * |v i| := by + rw [abs_mul, abs_of_nonneg (Int.natCast_nonneg j)] + _ ≤ (R i : ℤ) + (k : ℤ) * |v i| := + add_le_add hxi (mul_le_mul_of_nonneg_right hjk (abs_nonneg _)) + _ ≤ 2 * (R i : ℤ) := by linarith only [hshort i] + change |x i + j • v i| ≤ ((2 * R i : ℕ) : ℤ) + simpa only [nsmul_eq_mul, Nat.cast_mul, Nat.cast_ofNat] using hbound + +theorem injOn_small_integer_box_of_dense_subset (φ : (ι → ℤ) →+ G) + (S : Finset (ι → ℤ)) (R r : ι → ℕ) (k : ℕ) + (hS : S ⊆ centeredIntegerBox R) (hinj : Set.InjOn φ (S : Set _)) + (hlarge : (centeredIntegerBox (fun i => 2 * R i)).card < S.card * k) + (hscale : ∀ i, 2 * k * r i ≤ R i) : + Set.InjOn φ (centeredIntegerBox r : Set _) := by + intro x hx y hy hxy + apply sub_eq_zero.mp + apply kernel_eq_zero_of_dense_integer_box φ S R k hS hinj hlarge (x - y) + · rw [map_sub, hxy, sub_self] + · intro i + have hx' := (mem_centeredIntegerBox r x).mp hx i + have hy' := (mem_centeredIntegerBox r y).mp hy i + have hscale' : 2 * (k : ℤ) * (r i : ℤ) ≤ R i := by exact_mod_cast hscale i + calc + (k : ℤ) * |(x - y) i| ≤ (k : ℤ) * (|x i| + |y i|) := + mul_le_mul_of_nonneg_left (abs_sub _ _) (Int.natCast_nonneg k) + _ ≤ (k : ℤ) * ((r i : ℤ) + (r i : ℤ)) := + mul_le_mul_of_nonneg_left (add_le_add hx' hy') (Int.natCast_nonneg k) + _ = 2 * (k : ℤ) * (r i : ℤ) := by ring + _ ≤ (R i : ℤ) := hscale' + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem integerSites_card_le {K S : Type*} [Fintype K] [Fintype S] + (site : S → K → ℤ) (hsite : Function.Injective site) (R : ℕ) + (hbound : ∀ s k, |site s k| ≤ (R : ℤ)) : + Fintype.card S ≤ (2*R+1)^Fintype.card K := by + classical + let f : S → ↥(centeredIntegerBox (fun _ : K => R)) := + fun s => ⟨site s, (mem_centeredIntegerBox _ _).mpr (hbound s)⟩ + have hf : Function.Injective f := fun s t h => hsite (congrArg Subtype.val h) + simpa only [Fintype.card_coe, card_centeredIntegerBox, Finset.prod_const, + Finset.card_univ] using Fintype.card_le_of_injective f hf + +theorem integerSites_card_le_exp {K S : Type*} [Fintype K] [Fintype S] + (site : S → K → ℤ) (hsite : Function.Injective site) {P : ℝ} (hP : 0 ≤ P) + (hK : (Fintype.card K : ℝ) ≤ P) + (hbound : ∀ s k, |(site s k : ℝ)| ≤ Real.exp P) : + (Fintype.card S : ℝ) ≤ Real.exp (P*(P+5)) := by + have hcard := integerSites_card_le site hsite ⌈Real.exp P⌉₊ (fun s k => by + exact_mod_cast (hbound s k).trans (Nat.le_ceil (Real.exp P))) + have hceil := (Nat.ceil_lt_add_one (Real.exp_pos P).le).le + have h1 : 1 ≤ Real.exp P := Real.one_le_exp_iff.mpr hP + have h5 : (5 : ℝ) ≤ Real.exp 5 := by linarith [Real.add_one_le_exp (5 : ℝ)] + have hbase : (2*⌈Real.exp P⌉₊+1 : ℝ) ≤ Real.exp (P+5) := by + calc + _ ≤ 5*Real.exp P := by linarith + _ ≤ Real.exp P*Real.exp 5 := by nlinarith [Real.exp_pos P] + _ = _ := (Real.exp_add P 5).symm + calc + _ ≤ ((2*⌈Real.exp P⌉₊+1 : ℕ) : ℝ)^Fintype.card K := by exact_mod_cast hcard + _ ≤ (Real.exp (P+5))^Fintype.card K := + pow_le_pow_left₀ (Nat.cast_nonneg _) (by simpa only [Nat.cast_add, + Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] using hbase) _ + _ = Real.exp ((Fintype.card K : ℝ)*(P+5)) := (Real.exp_nat_mul _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hK (by linarith)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem injOn_shrunk_integer_box_of_distinct_points + {r : ℕ} {G : Type*} [AddCommGroup G] (J : Finset G) (hJ : J.Nonempty) + (R : Fin r → ℕ) (η : (Fin r → ℤ) →+ G) (a : G) + (hrepr : ∀ h ∈ J, ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = a + η x) : + let k := (2 ^ r * ∏ i, (2 * R i + 1)) / J.card + 1 + Set.InjOn η (centeredIntegerBox (fun i => R i / (2 * k)) : Set _) := by + intro k + classical + have hall (h : {h // h ∈ J}) : ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ h.val = a + η x := + hrepr h.val h.property + choose x hx heq using hall + have hηx : Function.Injective (η ∘ x) := by + intro h h' hh + apply Subtype.ext + rw [heq h, heq h'] + exact congrArg (fun z => a + z) hh + have hxinj : Function.Injective x := by + intro h h' hh + exact hηx (congrArg η hh) + let S := Finset.univ.image x + have hS : S ⊆ centeredIntegerBox R := by + intro z hz + obtain ⟨h, _, rfl⟩ := Finset.mem_image.mp hz + exact (mem_centeredIntegerBox R (x h)).mpr (hx h) + have hScard : S.card = J.card := by + rw [show S.card = (Finset.univ.image x).card from rfl, + Finset.card_image_of_injective _ hxinj, Finset.card_univ, Fintype.card_coe] + have hinj : Set.InjOn η (S : Set _) := by + intro z hz w hw hzw + obtain ⟨h, _, rfl⟩ := Finset.mem_image.mp hz + obtain ⟨h', _, rfl⟩ := Finset.mem_image.mp hw + exact congrArg x (hηx hzw) + apply injOn_small_integer_box_of_dense_subset η S R (fun i => R i / (2 * k)) k hS hinj + · apply (card_doubled_centeredIntegerBox_le R).trans_lt + rw [card_centeredIntegerBox, Fintype.card_fin, hScard] + exact Nat.lt_mul_div_succ (2 ^ r * ∏ i, (2 * R i + 1)) hJ.card_pos + · intro i + exact Nat.mul_div_le (R i) (2 * k) + +theorem injOn_shrunk_integer_box_of_distinct_residues + {r N : ℕ} [NeZero N] (J : Finset (ZMod N)) (hJ : J.Nonempty) + (R : Fin r → ℕ) (η : (Fin r → ℤ) →+ ℤ) (a : ℤ) + (hrepr : ∀ h ∈ J, ∃ x : Fin r → ℤ, + (∀ i, |x i| ≤ (R i : ℤ)) ∧ (h.val : ℤ) = a + η x) : + let k := (2 ^ r * ∏ i, (2 * R i + 1)) / J.card + 1 + Set.InjOn ((Int.castAddHom (ZMod N)).comp η) + (centeredIntegerBox (fun i => R i / (2 * k)) : Set _) := by + apply injOn_shrunk_integer_box_of_distinct_points J hJ R + ((Int.castAddHom (ZMod N)).comp η) (a : ZMod N) + intro h hh + obtain ⟨x, hx, heq⟩ := hrepr h hh + refine ⟨x, hx, ?_⟩ + change h = (a : ZMod N) + (η x : ZMod N) + simpa only [Int.cast_add, Int.cast_natCast, ZMod.natCast_zmod_val] using + congrArg (fun z : ℤ => (z : ZMod N)) heq + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def naturalScaleIntegerWindow (J : Type*) [Fintype J] (H : ℝ) (N : ℕ) : + Finset (J → ℤ) := centeredIntegerBox (fun _ : J => ⌈H * (N : ℝ)⌉₊) + +theorem mem_naturalScaleIntegerWindow_of_bound {J : Type*} [Fintype J] + (H : ℝ) (N : ℕ) (z : J → ℤ) (hz : ∀ j, |(z j : ℝ)| ≤ H * N) : + z ∈ naturalScaleIntegerWindow J H N := by + apply (mem_centeredIntegerBox _ _).mpr + intro j + exact_mod_cast (hz j).trans (Nat.le_ceil (H * (N : ℝ))) + +theorem naturalScaleIntegerWindow_card_le (J : Type*) [Fintype J] + {H : ℝ} (hH : 0 ≤ H) {N : ℕ} (hN : 0 < N) : + ((naturalScaleIntegerWindow J H N).card : ℝ) ≤ + (2 * H + 3) ^ Fintype.card J * (N : ℝ) ^ Fintype.card J := by + have hceil := Nat.ceil_lt_add_one (mul_nonneg hH (Nat.cast_nonneg N)) + have hN1 : (1 : ℝ) ≤ N := by exact_mod_cast hN + have hb : 2 * (⌈H * (N : ℝ)⌉₊ : ℝ) + 1 ≤ (2 * H + 3) * N := by nlinarith + have he : ((naturalScaleIntegerWindow J H N).card : ℝ) = + (2 * (⌈H * (N : ℝ)⌉₊ : ℝ) + 1) ^ Fintype.card J := by + simp only [naturalScaleIntegerWindow, card_centeredIntegerBox, Finset.prod_const, + Finset.card_univ, Nat.cast_pow, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] + rw [he] + exact (pow_le_pow_left₀ (by positivity) hb _).trans_eq (mul_pow _ _ _) + +noncomputable def naturalScaleProductWindow {A : Type*} [Fintype A] + (J : A → Type*) [∀ a, Fintype (J a)] (H : A → ℝ) (N : A → ℕ) : + Finset (∀ a, J a → ℤ) := + Fintype.piFinset (fun a => naturalScaleIntegerWindow (J a) (H a) (N a)) + +theorem mem_naturalScaleProductWindow_iff {A : Type*} [Fintype A] + (J : A → Type*) [∀ a, Fintype (J a)] (H : A → ℝ) (N : A → ℕ) + (z : ∀ a, J a → ℤ) : + z ∈ naturalScaleProductWindow J H N ↔ ∀ a, z a ∈ naturalScaleIntegerWindow (J a) (H a) (N a) := by + simp only [naturalScaleProductWindow, Fintype.mem_piFinset] + +theorem naturalScaleProductWindow_card_le {A : Type*} [Fintype A] + (J : A → Type*) [∀ a, Fintype (J a)] (H : A → ℝ) (N : A → ℕ) + (hH : ∀ a, 0 ≤ H a) (hN : ∀ a, 0 < N a) : + ((naturalScaleProductWindow J H N).card : ℝ) ≤ + (∏ a, (2 * H a + 3) ^ Fintype.card (J a)) * + ∏ a, (N a : ℝ) ^ Fintype.card (J a) := by + simp only [naturalScaleProductWindow, Fintype.card_piFinset, Nat.cast_prod] + rw [← Finset.prod_mul_distrib] + exact Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) + (fun a _ => naturalScaleIntegerWindow_card_le (J a) (hH a) (hN a)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NearIntegerMultiples.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NearIntegerMultiples.lean new file mode 100644 index 0000000000000000000000000000000000000000..da60d82607b2780344d9fa78d58a9d3237531546 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NearIntegerMultiples.lean @@ -0,0 +1,199 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonDenominatorMultiples +import OAI.Combinatorics.Progressions.Polynomial.AffinePhaseBias + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +def NearInteger (ε x : ℝ) : Prop := ∃ m : ℤ, |x-m| ≤ ε + +noncomputable def nearIntegerDensity {X : Type*} [Fintype X] (a : X → ℝ) (ε : ℝ) : ℝ := + 𝔼 x, if NearInteger ε (a x) then (1 : ℝ) else 0 + +theorem nearIntegerDensity_eq_card {X : Type*} [Fintype X] (a : X → ℝ) (ε : ℝ) : + nearIntegerDensity a ε = + ((Finset.univ.filter (fun x => NearInteger ε (a x))).card : ℝ)/Fintype.card X := by + simp [nearIntegerDensity, Fintype.expect_eq_sum_div_card] + +theorem nearIntegerDensity_le_one {X : Type*} [Fintype X] [Nonempty X] + (a : X → ℝ) (ε : ℝ) : nearIntegerDensity a ε ≤ 1 := by + rw [nearIntegerDensity_eq_card] + apply (div_le_one (by exact_mod_cast Fintype.card_pos : (0 : ℝ) < Fintype.card X)).mpr + exact_mod_cast (Finset.card_filter_le Finset.univ (fun x => NearInteger ε (a x))) + +theorem card_div_le_nearIntegerDensity {X : Type*} [Fintype X] + (a : X → ℝ) (ε : ℝ) (S : Finset X) (hS : ∀ x ∈ S, NearInteger ε (a x)) : + (S.card : ℝ)/Fintype.card X ≤ nearIntegerDensity a ε := by + rw [nearIntegerDensity_eq_card] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact_mod_cast (Finset.card_le_card (show S ⊆ Finset.univ.filter (fun x => NearInteger ε (a x)) from + fun x hx => Finset.mem_filter.mpr ⟨Finset.mem_univ x, hS x hx⟩)) + +theorem exists_constant_denominator_fiber {X : Type*} (S : Finset X) (q : X → ℕ) + {K : ℕ} (hK : 0 < K) (hq : ∀ x ∈ S, 0 < q x ∧ q x ≤ K) + {μ : ℝ} (hsize : (K : ℝ)*μ ≤ S.card) : + ∃ q₀ : ℕ, 0 < q₀ ∧ q₀ ≤ K ∧ ∃ E : Finset X, + E ⊆ S ∧ μ ≤ E.card ∧ ∀ x ∈ E, q x = q₀ := by + have hmap : ∀ x ∈ S, q x ∈ Finset.Icc 1 K := by + intro x hx + exact Finset.mem_Icc.mpr ⟨(hq x hx).1, (hq x hx).2⟩ + obtain ⟨q₀, hq₀, hlarge⟩ := Finset.exists_le_card_fiber_of_nsmul_le_card_of_maps_to + hmap (show (Finset.Icc 1 K).Nonempty from ⟨1, Finset.mem_Icc.mpr ⟨le_rfl, hK⟩⟩) + (by simpa only [Nat.card_Icc, Nat.add_sub_cancel, nsmul_eq_mul] using hsize) + refine ⟨q₀, (Finset.mem_Icc.mp hq₀).1, (Finset.mem_Icc.mp hq₀).2, + S.filter (fun x => q x = q₀), Finset.filter_subset _ _, hlarge, ?_⟩ + intro x hx + exact (Finset.mem_filter.mp hx).2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical +open CircleFourier + +theorem nearIntegerDensity_product {X Y : Type*} [Fintype X] [Fintype Y] + (f : X → Y → ℝ) (ε : ℝ) : + nearIntegerDensity (fun p : X × Y => f p.1 p.2) ε = + 𝔼 x, nearIntegerDensity (f x) ε := by + unfold nearIntegerDensity + exact Finset.expect_product' _ _ (fun x y => if NearInteger ε (f x y) then (1 : ℝ) else 0) + +theorem nearIntegerDensity_of_geometric_mean {X : Type*} [Fintype X] [Nonempty X] + (f : X → ℝ) {M : ℕ} (hM : 0 < M) {a : ℝ} (ha : 0 < a) + (hbias : a ≤ 𝔼 x, ‖geometricCharacterMean M (f x : CircleFourier.Circle)‖) : + a/2 ≤ nearIntegerDensity f (1/((M : ℝ)*a)) := by + obtain ⟨S, hS, hgood⟩ := exists_dense_level_set + (fun x => ‖geometricCharacterMean M (f x : CircleFourier.Circle)‖) ha.le + (fun x => norm_geometricCharacterMean_le_one M hM _) hbias + have hX : (0 : ℝ) < Fintype.card X := by exact_mod_cast Fintype.card_pos + apply ((le_div_iff₀ hX).mpr hS).trans + apply card_div_le_nearIntegerDensity _ _ S + intro x hx + have hnear := integerDistance_le_of_geometric_mean hM (f x : CircleFourier.Circle) + (by linarith : 0 < a/2) (hgood x hx) + refine ⟨round (f x), ?_⟩ + rw [← integerDistance_coe] + apply hnear.trans_eq + congr 1 + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem nearIntegerDensity_comp_injective {X Y : Type*} + [Fintype X] [Nonempty X] [Fintype Y] [Nonempty Y] + (a : Y → ℝ) (ε : ℝ) (f : X → Y) (hf : Function.Injective f) : + (Fintype.card X : ℝ)*nearIntegerDensity (fun x => a (f x)) ε ≤ + (Fintype.card Y : ℝ)*nearIntegerDensity a ε := by + let S := Finset.univ.filter (fun x => NearInteger ε (a (f x))) + let T := Finset.univ.filter (fun y => NearInteger ε (a y)) + have hST : S.image f ⊆ T := by + intro y hy + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hy + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hx).2⟩ + have hcard : (S.card : ℝ) ≤ T.card := by + exact_mod_cast (Finset.card_image_of_injective S hf ▸ Finset.card_le_card hST) + have hX : (Fintype.card X : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + have hY : (Fintype.card Y : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + simpa only [nearIntegerDensity_eq_card, S, T, mul_div_cancel₀ _ hX, + mul_div_cancel₀ _ hY] using hcard + +theorem nearIntegerDensity_fiber_injections {X Y Z : Type*} + [Fintype X] [Nonempty X] [Fintype Y] [Nonempty Y] + [Fintype Z] [Nonempty Z] + (a : Y → ℝ) (ε : ℝ) (f : Z → X → Y) (hf : ∀ z, Function.Injective (f z)) + {η : ℝ} (hdensity : η ≤ 𝔼 z, nearIntegerDensity (fun x => a (f z x)) ε) : + η * Fintype.card X / Fintype.card Y ≤ nearIntegerDensity a ε := by + have hY : (0 : ℝ) < Fintype.card Y := by exact_mod_cast Fintype.card_pos + apply (div_le_iff₀ hY).mpr + have hp := Finset.expect_le_expect (fun z (_ : z ∈ (Finset.univ : Finset Z)) => + nearIntegerDensity_comp_injective a ε (f z) (hf z)) + rw [← Finset.mul_expect, Fintype.expect_const] at hp + have hm := mul_le_mul_of_nonneg_left hdensity (Nat.cast_nonneg (Fintype.card X)) + nlinarith only [hm, hp] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem nearInteger_multiples {X : Type*} [Fintype X] [Nonempty X] + (v : X → ℤ) (hv : Function.Injective v) (A H : ℕ) (hA : 1 ≤ A) + (hH : 4*A ≤ H) (hcard : H ≤ Fintype.card X) (hbound : ∀ x, |v x| ≤ (H : ℤ)) + {θ ε : ℝ} (hε : 0 ≤ ε) (hsmall : ε ≤ 1/(64*(A : ℝ)^2)) + (hdensity : 1/(A : ℝ) ≤ nearIntegerDensity (fun x => (v x : ℝ)*θ) ε) : + ∃ q : ℕ, 0 < q ∧ q ≤ 4*A ∧ NearInteger (96*(A : ℝ)^2*ε/H) ((q : ℝ)*θ) := by + have hAp : (0 : ℝ) < A := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hA) + have hHp : 0 < H := by omega + have hHr : (0 : ℝ) < H := Nat.cast_pos.mpr hHp + let S := Finset.univ.filter (fun x => NearInteger ε ((v x : ℝ)*θ)) + let D := S.image v + have hDcard : D.card = S.card := Finset.card_image_of_injective S hv + have hs : (1/(A : ℝ))*H ≤ (D.card : ℝ) := by + have hX : (0 : ℝ) < Fintype.card X := by exact_mod_cast Fintype.card_pos + have hden : 1/(A : ℝ) ≤ (S.card : ℝ)/Fintype.card X := by + simpa only [nearIntegerDensity_eq_card] using hdensity + rw [hDcard] + exact (mul_le_mul_of_nonneg_left (by exact_mod_cast hcard) (by positivity)).trans + ((le_div_iff₀ hX).mp hden) + have hnear : ∀ n ∈ D, NearInteger ε ((n : ℝ)*θ) := by + intro n hn + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hn + exact (Finset.mem_filter.mp hx).2 + let p : ℤ → ℤ := fun n => if hn : NearInteger ε ((n : ℝ)*θ) then hn.choose else 0 + have hp : ∀ n ∈ D, |(n : ℝ)*θ-p n| ≤ ε := by + intro n hn + dsimp only [p] + rw [dite_eq_left (hnear n hn)] + exact (hnear n hn).choose_spec + have hρQ : (4 : ℝ) ≤ (1/(A : ℝ))*(4*A : ℕ) := by + push_cast + field_simp + norm_num + have hρH : (4 : ℝ) ≤ (1/(A : ℝ))*H := by + calc + _ ≤ (1/(A : ℝ))*(4*A : ℕ) := hρQ + _ ≤ _ := mul_le_mul_of_nonneg_left (Nat.cast_le.mpr hH) (by positivity) + have hsmall' : 16*((4*A : ℕ) : ℝ)*ε ≤ 1/(A : ℝ) := by + calc + _ ≤ 16*((4*A : ℕ) : ℝ)*(1/(64*(A : ℝ)^2)) := by gcongr + _ = _ := by push_cast; field_simp; ring + have hsmall'' : 16*(((4*A : ℕ) : ℝ)*ε) ≤ 1/(A : ℝ) := by linarith [hsmall'] + have hρone : 1/(A : ℝ) ≤ 1 := (div_le_one hAp).mpr (by exact_mod_cast hA) + have hcap : ((4*A : ℕ) : ℝ)*ε ≤ 1 := by + have hz : 0 ≤ ((4*A : ℕ) : ℝ)*ε := by positivity + linarith + obtain ⟨q, hq, hqA, m, hm⟩ := many_multiples_rational_approximation D p hHp (by omega) + (by positivity : 0 < 1/(A : ℝ)) hε hρQ hρH hsmall'' hcap hs + (fun n hn => by obtain ⟨x, _, rfl⟩ := Finset.mem_image.mp hn; exact hbound x) hp + refine ⟨q, hq, hqA, m, hm.trans_eq ?_⟩ + push_cast + field_simp + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedIntegerBoxZeroCube.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedIntegerBoxZeroCube.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b49f3d27fe55a3866ef3caa81349bd9d57bf090 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedIntegerBoxZeroCube.lean @@ -0,0 +1,148 @@ +import OAI.Combinatorics.Progressions.Estimates.SampledCommonSlice + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +def integerBoxCubeProductEquiv {I : Type*} [Fintype I] [DecidableEq I] (N : I → ℕ) (q : ℕ) : + SupportedCube q (integerBox N : Set (I → ℤ)) ≃ + (∀ i, SupportedCube q (Set.Ico (0 : ℤ) (N i : ℤ))) where + toFun c i := ⟨(fun j => c.val.1 j i, c.val.2 i), by + intro ω + have h := (mem_integerBox N _).mp (c.property ω) i + simpa only [Set.mem_Ico, Pi.add_apply, cubeShift, Finset.sum_apply, ite_apply, Pi.zero_apply] using h⟩ + invFun c := ⟨(fun j i => (c i).val.1 j, fun i => (c i).val.2), by + intro ω + apply (mem_integerBox N _).mpr + intro i + have h := (c i).property ω + simpa only [Set.mem_Ico, Pi.add_apply, cubeShift, Finset.sum_apply, ite_apply, Pi.zero_apply] using h⟩ + left_inv c := by apply Subtype.ext; rfl + right_inv c := by funext i; apply Subtype.ext; rfl + +theorem integerBoxCubeCount_eq_product {I : Type*} [Fintype I] [DecidableEq I] (N : I → ℕ) (q : ℕ) : + integerBoxCubeCount N q = ∏ i, Nat.card (SupportedCube q (Set.Ico (0 : ℤ) (N i : ℤ))) := by + classical + rw [integerBoxCubeCount, Nat.card_congr (integerBoxCubeProductEquiv N q)] + simp only [Nat.card_eq_fintype_card, Fintype.card_pi] + +theorem integerScalarCubeWeights_supported_complexMean (q L : ℕ) (hL : 0 < L) + (f : ((Fin q → ℤ) × ℤ) → ℂ) : + (integerScalarCubeWeights (Fin q) L hL).complexMean + (fun x => f (fun i => (x (some i) : ℤ), (x none : ℤ))) = + 𝔼 p : SupportedCube q (Set.Ico (0 : ℤ) (L : ℤ)), f p.val := by + apply Complex.ext + · simpa only [FiniteProbabilityWeights.complexMean_re, expect_re] using + integerScalarCubeWeights_supported_mean q L hL (fun p => (f p).re) + · have h := integerScalarCubeWeights_supported_mean q L hL (fun p => (f p).im) + simpa only [FiniteProbabilityWeights.complexMean, FiniteProbabilityWeights.mean, + Complex.im_sum, Complex.mul_im, Complex.ofReal_re, Complex.ofReal_im, + zero_mul, add_zero, expect_im] using h + +theorem FiniteProbabilityWeights.pi_uniform_complexMean + {I : Type*} [Fintype I] [DecidableEq I] {A : I → Type*} + [∀ i, Fintype (A i)] [∀ i, Nonempty (A i)] (f : (∀ i, A i) → ℂ) : + (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (A i))).complexMean f = + 𝔼 x, f x := by + change (∑ x : ∀ i, A i, ((∏ i, (Fintype.card (A i) : ℝ)⁻¹ : ℝ) : ℂ) * f x) = _ + have hcard : (∏ i, (Fintype.card (A i) : ℝ)⁻¹) = + (Fintype.card (∀ i, A i) : ℝ)⁻¹ := by + rw [Finset.prod_inv_distrib] + simp only [Fintype.card_pi, Nat.cast_prod] + rw [hcard] + simp only [Complex.ofReal_inv, Complex.ofReal_natCast, + ← Finset.mul_sum, Fintype.expect_eq_sum_div_card, div_eq_mul_inv] + exact mul_comm _ _ + +theorem integerScalarCubeProduct_complexMean {I : Type*} [Fintype I] [DecidableEq I] (N : I → ℕ) + (hN : ∀ i, 0 < N i) (q : ℕ) + (f : ((Fin q → I → ℤ) × (I → ℤ)) → ℂ) : + (FiniteProbabilityWeights.pi (fun i => integerScalarCubeWeights (Fin q) (N i) (hN i))).complexMean + (fun c => f (fun j i => (c i (some j) : ℤ), fun i => (c i none : ℤ))) = + 𝔼 c : SupportedCube q (integerBox N : Set (I → ℤ)), f c.val := by + let : ∀ i, Nonempty (SupportedCube q (Set.Ico (0 : ℤ) (N i : ℤ))) := fun i => + ⟨⟨(0, 0), by + intro ω + simpa [cubeShift] using (show (0 : ℤ) < N i by exact_mod_cast hN i)⟩⟩ + let law := fun i => FiniteProbabilityWeights.uniform + (SupportedCube q (Set.Ico (0 : ℤ) (N i : ℤ))) + have hcoordinate (i : I) (g : ((Fin q → ℤ) × ℤ) → ℂ) : + (integerScalarCubeWeights (Fin q) (N i) (hN i)).complexMean + (fun c => g (fun j => (c (some j) : ℤ), (c none : ℤ))) = + (law i).complexMean (fun c => g c.val) := by + rw [FiniteProbabilityWeights.uniform_complexMean] + exact integerScalarCubeWeights_supported_complexMean q (N i) (hN i) g + calc + _ = (FiniteProbabilityWeights.pi law).complexMean + (fun c => f (fun j i => (c i).val.1 j, fun i => (c i).val.2)) := + FiniteProbabilityWeights.complexMean_pi_transport_fintype + (fun i => integerScalarCubeWeights (Fin q) (N i) (hN i)) law + (fun _ c => (fun j => (c (some j) : ℤ), (c none : ℤ))) + (fun _ c => c.val) hcoordinate + (fun c => f (fun j i => (c i).1 j, fun i => (c i).2)) + _ = 𝔼 c : (∀ i, SupportedCube q (Set.Ico (0 : ℤ) (N i : ℤ))), + f (fun j i => (c i).val.1 j, fun i => (c i).val.2) := + FiniteProbabilityWeights.pi_uniform_complexMean _ + _ = (𝔼 c : SupportedCube q (integerBox N : Set (I → ℤ)), f c.val) := by + exact (Fintype.expect_equiv (integerBoxCubeProductEquiv N q) + (fun c => f c.val) + (fun c => f (fun j i => (c i).val.1 j, fun i => (c i).val.2)) + (fun _ => rfl)).symm + +theorem normalizedSupportedCubeSum_eq_scalarProduct {I : Type*} [Fintype I] [DecidableEq I] (N : I → ℕ) + (hN : ∀ i, 0 < N i) (q : ℕ) (F : (Fin q → Bool) → (I → ℤ) → ℂ) : + normalizedSupportedCubeSum q (integerBox N) F = + (FiniteProbabilityWeights.pi (fun i => integerScalarCubeWeights (Fin q) (N i) (hN i))).complexMean + (fun c => mixedCubeProduct F (fun j i => (c i (some j) : ℤ)) (fun i => (c i none : ℤ))) := by + rw [integerScalarCubeProduct_complexMean N hN q (fun c => mixedCubeProduct F c.1 c.2)] + simp only [normalizedSupportedCubeSum, supportedCubeSum, + Fintype.expect_eq_sum_div_card, Nat.card_eq_fintype_card] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerScalarCubeWeights_zero_product_complexMean + {X : Type*} [Fintype X] [DecidableEq X] + (N : X → ℕ) (hN : ∀ i, 0 < N i) (f : (X → ℤ) → ℂ) : + (FiniteProbabilityWeights.pi + (fun i => integerScalarCubeWeights Empty (N i) (hN i))).complexMean + (fun z => f (fun i => (z i none : ℤ))) = + 𝔼 u ∈ integerBox N, f u := by + let : ∀ i, Nonempty (Finset.Ico (0 : ℤ) (N i : ℤ)) := fun i => + ⟨⟨0, Finset.mem_Ico.mpr ⟨le_rfl, by exact_mod_cast hN i⟩⟩⟩ + calc + _ = (FiniteProbabilityWeights.pi + (fun i => intervalUniformWeights 0 (N i : ℤ) + (by exact_mod_cast hN i))).complexMean + (fun z => f (fun i => (z i : ℤ))) := + FiniteProbabilityWeights.complexMean_pi_transport_fintype + (fun i => integerScalarCubeWeights Empty (N i) (hN i)) + (fun i => intervalUniformWeights 0 (N i : ℤ) (by exact_mod_cast hN i)) + (fun _ z => (z none : ℤ)) (fun _ z => (z : ℤ)) + (fun i g => integerScalarCubeWeights_zero_complexMean Empty (N i) (hN i) g) f + _ = 𝔼 z : (∀ i, Finset.Ico (0 : ℤ) (N i : ℤ)), + f (fun i => (z i : ℤ)) := by + exact FiniteProbabilityWeights.pi_uniform_complexMean _ + _ = 𝔼 z : integerBox N, f z.val := + Fintype.expect_equiv (finiteBoxPointsEquiv (fun i => Finset.Ico (0 : ℤ) (N i : ℤ))) + _ _ (fun _ => rfl) + _ = _ := by + simp only [Finset.expect_eq_sum_div_card, Finset.card_univ, + Fintype.card_coe, Finset.sum_coe_sort] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedIntegerDual.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedIntegerDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..83f87d88e8519dfda5876bfe5fb1e450794d14a6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedIntegerDual.lean @@ -0,0 +1,517 @@ +import OAI.Combinatorics.Progressions.Linear.BooleanCubeCoordinateFrame +import OAI.Combinatorics.Progressions.Linear.RealKernelJetInverse + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped Classical + +variable {α K R V : Type*} [Fintype α] [DecidableEq α] [CommRing R] + [AddCommGroup V] [Module R V] + +omit [DecidableEq α] in +theorem frameProjection_form_homogeneous (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) (hq : ∀ i, (q i).IsHomogeneous 1) (f : Form α K) : + (frameProjection root difference q (formPolynomial f)).IsHomogeneous 1 := by + cases f with + | coordinate v => + simpa only [frameProjection, formPolynomial, aeval_X] using + frameCoordinate_homogeneous root difference q hq v + | difference i => + simpa only [frameProjection, formPolynomial, map_sub, aeval_X, frameCoordinate] using + (hq i).sub (isHomogeneous_X R none) + +theorem frameLift_siteEvaluation (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) + (hq : ∀ i s, eval (affineSite root difference s) (q i) = if i ∈ s then 1 else 0) + (P : MvPolynomial (Option K) R) : + siteEvaluation (frameLift root difference P) = fun s => eval (affineSite root difference s) P := by + funext s + change eval (site s) (frameLift root difference P) = _ + rw [← frameProjection_eval root difference q hq, frameProjection_lift] + +theorem exists_affine_vanishing_product + (root : K → R) (difference : α → K → R) (q : α → MvPolynomial (Option K) R) + (hlinear : ∀ i, (q i).IsHomogeneous 1) + (hdual : ∀ i s, eval (affineSite root difference s) (q i) = if i ∈ s then 1 else 0) + (Λ : MvPolynomial (Option K) R →ₗ[R] V) (h : ℕ) + (hnonfactor : ¬ ∃ L : (Finset α → R) →ₗ[R] V, + ∀ P, P.IsHomogeneous h → Λ P = L (fun s => eval (affineSite root difference s) P)) : + ∃ forms : List (MvPolynomial (Option K) R), forms.length = h ∧ + (∀ Q ∈ forms, Q.IsHomogeneous 1 ∧ ∃ f : Form α K, + Q = frameProjection root difference q (formPolynomial f)) ∧ + (∀ s : Finset α, eval (affineSite root difference s) forms.prod = 0) ∧ Λ forms.prod ≠ 0 := by + let E := frameProjection root difference q + let Λ' := Λ.comp E.toLinearMap + have hnonfactor' : ¬ ∃ L : (Finset α → R) →ₗ[R] V, + ∀ P, P.IsHomogeneous h → Λ' P = L (siteEvaluation P) := by + rintro ⟨L, hL⟩ + apply hnonfactor + refine ⟨L, ?_⟩ + intro P hP + have he := hL (frameLift root difference P) (frameLift_homogeneous root difference hP) + change Λ (frameProjection root difference q (frameLift root difference P)) = _ at he + rw [frameProjection_lift, frameLift_siteEvaluation root difference q hdual] at he + exact he + obtain ⟨l, hl, hz, hΛ⟩ := exists_vanishing_product_of_nonfactor Λ' h hnonfactor' + have hprod : (l.map (fun f => E (formPolynomial f))).prod = E (formProduct l) := by + simp only [formProduct, map_list_prod, List.map_map, Function.comp_def] + refine ⟨l.map (fun f => E (formPolynomial f)), ?_, ?_, ?_, ?_⟩ + · simpa only [List.length_map] using hl + · intro Q hQ + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hQ + exact ⟨frameProjection_form_homogeneous root difference q hlinear f, f, rfl⟩ + · intro s + rw [hprod] + exact (frameProjection_eval root difference q hdual s (formProduct l)).trans (hz s) + · rw [hprod] + exact hΛ + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators + +noncomputable def homogeneousDual {I K R : Type*} [Fintype I] [CommRing R] + (root : K → R) (selection : I → K) (n : I → R) : MvPolynomial (Option K) R := + ∑ j, C (n j) * (X (some (selection j)) - C (root (selection j)) * X none) + +theorem homogeneousDual_homogeneous {I K R : Type*} [Fintype I] [CommRing R] + (root : K → R) (selection : I → K) (n : I → R) : + (homogeneousDual root selection n).IsHomogeneous 1 := by + exact IsHomogeneous.sum _ _ _ (fun j _ => + ((isHomogeneous_X R _).sub ((isHomogeneous_X R _).C_mul (root (selection j)))).C_mul (n j)) + +theorem homogeneousDual_eval {α I K R : Type*} [Fintype I] [CommRing R] + (root : K → R) (difference : α → K → R) (selection : I → K) (n : I → R) + (s : Finset α) : + eval (affineSite root difference s) (homogeneousDual root selection n) = + ∑ i ∈ s, ∑ j, n j * difference i (selection j) := by + simp only [homogeneousDual, map_sum, map_mul, map_sub, eval_C, eval_X, + affineSite, mul_one, add_sub_cancel_left, Finset.mul_sum] + exact Finset.sum_comm + +theorem homogeneousDual_boolean {α I K R : Type*} [DecidableEq α] [Fintype I] [CommRing R] + (root : K → R) (difference : α → K → R) (selection : I → K) (n : α → I → R) + (hdual : ∀ i r, (∑ j, n i j * difference r (selection j)) = if i = r then 1 else 0) + (i : α) (s : Finset α) : + eval (affineSite root difference s) (homogeneousDual root selection (n i)) = + if i ∈ s then 1 else 0 := by + rw [homogeneousDual_eval] + simp only [hdual, Finset.sum_ite_eq] + +noncomputable def pivotDual {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) (i : α) : + MvPolynomial (Option K) ℝ := + homogeneousDual root selection (fun j => (realDifferencePivot difference selection)⁻¹ j i) + +theorem pivotDual_boolean {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (hd : (realDifferencePivot difference selection).det ≠ 0) (i : α) (s : Finset α) : + eval (affineSite root difference s) (pivotDual root difference selection i) = if i ∈ s then 1 else 0 := + homogeneousDual_boolean root difference selection _ + (realDifferencePivot_inverse_dual difference selection hd) i s + +theorem pivotDual_homogeneous {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) (i : α) : + (pivotDual root difference selection i).IsHomogeneous 1 := + homogeneousDual_homogeneous root selection _ + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators Classical + +theorem homogeneousDual_mass {I K : Type*} [Fintype I] + (root : K → ℝ) (selection : I → K) (n : I → ℝ) {H N : ℝ} + (hN : 0 ≤ N) (hroot : ∀ j, |root (selection j)| ≤ H) (hn : ∀ j, |n j| ≤ N) : + realPolynomialMass (homogeneousDual root selection n) ≤ (Fintype.card I : ℝ) * (N * (1 + H)) := by + apply (realPolynomialMass_sum_le _ _).trans + calc + _ ≤ ∑ _j : I, N * (1 + H) := by + apply Finset.sum_le_sum + intro j _ + have hr : realPolynomialMass (C (root (selection j)) * X (none : Option K)) ≤ H := by + exact (realPolynomialMass_C_mul_le (root (selection j)) (X (none : Option K))).trans + (by simpa only [realPolynomialMass_X, mul_one] using hroot j) + have hs : realPolynomialMass (X (some (selection j)) - C (root (selection j)) * X none) ≤ 1 + H := by + exact (realPolynomialMass_sub_le _ _).trans (by rw [realPolynomialMass_X]; linarith) + exact (realPolynomialMass_C_mul_le _ _).trans + (mul_le_mul (hn j) hs (realPolynomialMass_nonneg _) hN) + _ = _ := by simp + +def formMassBound (q : ℕ) (H D Q : ℝ) : ℝ := 2 + H + ((q : ℝ) * D + 1) * Q + +theorem frameCoordinate_mass {α K : Type*} [Fintype α] + (root : K → ℝ) (difference : α → K → ℝ) (q : α → MvPolynomial (Option K) ℝ) + {H D Q : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hQ : 0 ≤ Q) + (hroot : ∀ k, |root k| ≤ H) (hdiff : ∀ i k, |difference i k| ≤ D) + (hq : ∀ i, realPolynomialMass (q i) ≤ Q) (v : Variable α K) : + realPolynomialMass (frameCoordinate root difference q v) ≤ formMassBound (Fintype.card α) H D Q := by + have hnonneg : 0 ≤ (Fintype.card α : ℝ) * D * Q := mul_nonneg (mul_nonneg (Nat.cast_nonneg _) hD) hQ + cases v with + | none => + simp only [frameCoordinate, realPolynomialMass_X, formMassBound] + nlinarith + | some v => + cases v with + | inl i => + apply (hq i).trans + unfold formMassBound + nlinarith + | inr k => + have hr : realPolynomialMass (C (root k) * X (none : Option K)) ≤ H := by + exact (realPolynomialMass_C_mul_le _ _).trans (by simpa only [realPolynomialMass_X, mul_one] using hroot k) + have hs : realPolynomialMass (∑ i, C (difference i k) * q i) ≤ (Fintype.card α : ℝ) * (D * Q) := by + apply (realPolynomialMass_sum_le _ _).trans + calc + _ ≤ ∑ _i : α, D * Q := by + apply Finset.sum_le_sum + intro i _ + exact (realPolynomialMass_C_mul_le _ _).trans + (mul_le_mul (hdiff i k) (hq i) (realPolynomialMass_nonneg _) hD) + _ = _ := by simp + have ht := realPolynomialMass_sub_le + (X (some k) - C (root k) * X none) (∑ i, C (difference i k) * q i) + have hu := realPolynomialMass_sub_le (X (some k)) (C (root k) * X none) + rw [realPolynomialMass_X] at hu + change realPolynomialMass (X (some k) - C (root k) * X none - ∑ i, C (difference i k) * q i) ≤ _ + unfold formMassBound + nlinarith + +theorem frameProjection_form_mass {α K : Type*} [Fintype α] + (root : K → ℝ) (difference : α → K → ℝ) (q : α → MvPolynomial (Option K) ℝ) + {H D Q : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hQ : 0 ≤ Q) + (hroot : ∀ k, |root k| ≤ H) (hdiff : ∀ i k, |difference i k| ≤ D) + (hq : ∀ i, realPolynomialMass (q i) ≤ Q) (f : Form α K) : + realPolynomialMass (frameProjection root difference q (formPolynomial f)) ≤ + formMassBound (Fintype.card α) H D Q := by + cases f with + | coordinate v => + simpa only [frameProjection, formPolynomial, aeval_X] using + frameCoordinate_mass root difference q hH hD hQ hroot hdiff hq v + | difference i => + simp only [frameProjection, formPolynomial, map_sub, aeval_X, frameCoordinate] + have hs := realPolynomialMass_sub_le (q i) (X (none : Option K)) + rw [realPolynomialMass_X] at hs + have hnonneg : 0 ≤ (Fintype.card α : ℝ) * D * Q := mul_nonneg (mul_nonneg (Nat.cast_nonneg _) hD) hQ + have hi := hq i + unfold formMassBound + nlinarith + +theorem pivotDual_mass {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + {H D κ : ℝ} (hD : 0 ≤ D) (hκ : 0 < κ) + (hroot : ∀ j, |root (selection j)| ≤ H) (hdiff : ∀ i j, |difference i (selection j)| ≤ D) + (hdet : κ ≤ |(realDifferencePivot difference selection).det|) (i : α) : + realPolynomialMass (pivotDual root difference selection i) ≤ + (Fintype.card α : ℝ) * + ((((Fintype.card α).factorial : ℝ) * D ^ (Fintype.card α - 1) / κ) * (1 + H)) := by + apply homogeneousDual_mass root selection _ (by positivity) hroot + intro j + exact matrix_inverse_entry_abs_le (realDifferencePivot difference selection) hdiff hκ hdet j i + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators Classical + +noncomputable def scaledFrameForm {α K R : Type*} [Fintype α] [CommRing R] + (root : K → R) (difference : α → K → R) (a : R) + (numerator : α → MvPolynomial (Option K) R) : Form α K → MvPolynomial (Option K) R + | .coordinate none => C a * X none + | .coordinate (some (.inl i)) => numerator i + | .coordinate (some (.inr k)) => + C a * (X (some k) - C (root k) * X none) - ∑ i, C (difference i k) * numerator i + | .difference i => numerator i - C a * X none + +theorem scaledFrameForm_homogeneous {α K R : Type*} [Fintype α] [CommRing R] + (root : K → R) (difference : α → K → R) (a : R) + (numerator : α → MvPolynomial (Option K) R) + (hn : ∀ i, (numerator i).IsHomogeneous 1) (f : Form α K) : + (scaledFrameForm root difference a numerator f).IsHomogeneous 1 := by + cases f with + | coordinate v => + cases v with + | none => exact (isHomogeneous_X R _).C_mul a + | some v => + cases v with + | inl i => exact hn i + | inr k => + apply (((isHomogeneous_X R _).sub ((isHomogeneous_X R _).C_mul (root k))).C_mul a).sub + exact IsHomogeneous.sum _ _ _ (fun i _ => (hn i).C_mul (difference i k)) + | difference i => exact (hn i).sub ((isHomogeneous_X R _).C_mul a) + +theorem scaledFrameForm_map {α K R S : Type*} [Fintype α] [CommRing R] [CommRing S] + (ρ : R →+* S) (root : K → R) (difference : α → K → R) (a : R) + (numerator : α → MvPolynomial (Option K) R) (q : α → MvPolynomial (Option K) S) + (hn : ∀ i, map ρ (numerator i) = C (ρ a) * q i) (f : Form α K) : + map ρ (scaledFrameForm root difference a numerator f) = + C (ρ a) * frameProjection (fun k => ρ (root k)) (fun i k => ρ (difference i k)) q (formPolynomial f) := by + cases f with + | coordinate v => + cases v with + | none => simp [scaledFrameForm, frameProjection, formPolynomial, frameCoordinate] + | some v => + cases v with + | inl i => simpa only [scaledFrameForm, frameProjection, formPolynomial, aeval_X, frameCoordinate] using hn i + | inr k => + have hs : (∑ i, C (ρ (difference i k)) * (C (ρ a) * q i)) = + C (ρ a) * ∑ i, C (ρ (difference i k)) * q i := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + simp only [scaledFrameForm, map_sub, map_mul, map_sum, map_C, map_X, hn, + frameProjection, formPolynomial, aeval_X, frameCoordinate] + rw [hs] + ring + | difference i => + simp only [scaledFrameForm, map_sub, map_mul, map_C, map_X, hn, + frameProjection, formPolynomial, aeval_X, frameCoordinate] + ring + +theorem affineSite_map {α K R S : Type*} [CommRing R] [CommRing S] + (ρ : R →+* S) (root : K → R) (difference : α → K → R) (s : Finset α) : + affineSite (fun k => ρ (root k)) (fun i k => ρ (difference i k)) s = ρ ∘ affineSite root difference s := by + funext v + cases v <;> simp [affineSite] + +theorem affineSite_eval_map {α K R S : Type*} [CommRing R] [CommRing S] + (ρ : R →+* S) (root : K → R) (difference : α → K → R) (s : Finset α) + (P : MvPolynomial (Option K) R) : + eval (affineSite (fun k => ρ (root k)) (fun i k => ρ (difference i k)) s) (map ρ P) = + ρ (eval (affineSite root difference s) P) := by + rw [affineSite_map] + exact (map_eval ρ _ P).symm + +theorem scaledFrameProduct_map {α K R S : Type*} [Fintype α] [CommRing R] [CommRing S] + (ρ : R →+* S) (root : K → R) (difference : α → K → R) (a : R) + (numerator : α → MvPolynomial (Option K) R) (q : α → MvPolynomial (Option K) S) + (hn : ∀ i, map ρ (numerator i) = C (ρ a) * q i) (l : List (Form α K)) : + map ρ ((l.map (scaledFrameForm root difference a numerator)).prod) = + C ((ρ a) ^ l.length) * + frameProjection (fun k => ρ (root k)) (fun i k => ρ (difference i k)) q (formProduct l) := by + induction l with + | nil => simp [formProduct_nil] + | cons f l ih => + simp only [List.map_cons, List.prod_cons, map_mul, scaledFrameForm_map ρ root difference a numerator q hn, + ih, List.length_cons, pow_succ, map_mul, formProduct_cons] + ring + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators Classical + +variable {α K V : Type*} [Fintype α] [DecidableEq α] + [AddCommGroup V] [Module ℝ V] + +theorem exists_bounded_vanishing_product + (root : K → ℝ) (difference : α → K → ℝ) (q : α → MvPolynomial (Option K) ℝ) + (hlinear : ∀ i, (q i).IsHomogeneous 1) + (hdual : ∀ i s, eval (affineSite root difference s) (q i) = if i ∈ s then 1 else 0) + {H D Q : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hQ : 0 ≤ Q) + (hroot : ∀ k, |root k| ≤ H) (hdiff : ∀ i k, |difference i k| ≤ D) + (hq : ∀ i, realPolynomialMass (q i) ≤ Q) + (Λ : MvPolynomial (Option K) ℝ →ₗ[ℝ] V) (h : ℕ) + (hnonfactor : ¬ ∃ L : (Finset α → ℝ) →ₗ[ℝ] V, + ∀ P, P.IsHomogeneous h → Λ P = L (fun s => eval (affineSite root difference s) P)) : + ∃ forms : List (MvPolynomial (Option K) ℝ), forms.length = h ∧ + (∀ P ∈ forms, P.IsHomogeneous 1 ∧ realPolynomialMass P ≤ formMassBound (Fintype.card α) H D Q) ∧ + (∀ s : Finset α, ∃ P ∈ forms, eval (affineSite root difference s) P = 0) ∧ Λ forms.prod ≠ 0 := by + obtain ⟨forms, hlen, hforms, hz, hΛ⟩ := + exists_affine_vanishing_product root difference q hlinear hdual Λ h hnonfactor + refine ⟨forms, hlen, ?_, ?_, hΛ⟩ + · intro P hP + obtain ⟨hhom, f, rfl⟩ := hforms P hP + exact ⟨hhom, frameProjection_form_mass root difference q hH hD hQ hroot hdiff hq f⟩ + · intro s + have hp : (forms.map (fun P => eval (affineSite root difference s) P)).prod = 0 := by + simpa only [map_list_prod] using hz s + exact List.mem_map.mp (List.prod_eq_zero_iff.mp hp) + +theorem exists_pivot_vanishing_product + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + {H D κ : ℝ} (hH : 0 ≤ H) (hD : 0 ≤ D) (hκ : 0 < κ) + (hroot : ∀ k, |root k| ≤ H) (hdiff : ∀ i k, |difference i k| ≤ D) + (hdet : κ ≤ |(realDifferencePivot difference selection).det|) + (Λ : MvPolynomial (Option K) ℝ →ₗ[ℝ] V) (h : ℕ) + (hnonfactor : ¬ ∃ L : (Finset α → ℝ) →ₗ[ℝ] V, + ∀ P, P.IsHomogeneous h → Λ P = L (fun s => eval (affineSite root difference s) P)) : + let Q := (Fintype.card α : ℝ) * + ((((Fintype.card α).factorial : ℝ) * D ^ (Fintype.card α - 1) / κ) * (1 + H)) + ∃ forms : List (MvPolynomial (Option K) ℝ), forms.length = h ∧ + (∀ P ∈ forms, P.IsHomogeneous 1 ∧ realPolynomialMass P ≤ formMassBound (Fintype.card α) H D Q) ∧ + (∀ s : Finset α, ∃ P ∈ forms, eval (affineSite root difference s) P = 0) ∧ Λ forms.prod ≠ 0 := by + intro Q + have hd : (realDifferencePivot difference selection).det ≠ 0 := by + intro he + rw [he, abs_zero] at hdet + linarith + apply exists_bounded_vanishing_product root difference (pivotDual root difference selection) + (pivotDual_homogeneous root difference selection) (pivotDual_boolean root difference selection hd) + hH hD (show 0 ≤ Q by dsimp [Q]; positivity) hroot hdiff _ Λ h hnonfactor + intro i + exact pivotDual_mass root difference selection hD hκ + (fun j => hroot (selection j)) (fun i j => hdiff i (selection j)) hdet i + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators + +def integerDifferencePivot {α K : Type*} (difference : α → K → ℤ) (selection : α → K) : + Matrix α α ℤ := fun i j => difference i (selection j) + +theorem integerDifferencePivot_adjugate_dual {α K : Type*} [Fintype α] [DecidableEq α] + (difference : α → K → ℤ) (selection : α → K) (i s : α) : + (∑ j, (integerDifferencePivot difference selection).adjugate j i * difference s (selection j)) = + if i = s then (integerDifferencePivot difference selection).det else 0 := by + have he := congrFun (congrFun (Matrix.mul_adjugate (integerDifferencePivot difference selection)) s) i + simpa only [Matrix.mul_apply, Matrix.smul_apply, smul_eq_mul, Matrix.one_apply, + mul_ite, ite_mul, mul_one, one_mul, mul_zero, zero_mul, integerDifferencePivot, mul_comm, eq_comm] using he + +noncomputable def integerPivotNumerator {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℤ) (difference : α → K → ℤ) (selection : α → K) (i : α) : + MvPolynomial (Option K) ℤ := + homogeneousDual root selection (fun j => (integerDifferencePivot difference selection).adjugate j i) + +theorem integerPivotNumerator_homogeneous {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℤ) (difference : α → K → ℤ) (selection : α → K) (i : α) : + (integerPivotNumerator root difference selection i).IsHomogeneous 1 := + homogeneousDual_homogeneous root selection _ + +theorem integerPivotNumerator_eval {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℤ) (difference : α → K → ℤ) (selection : α → K) (i : α) (s : Finset α) : + eval (affineSite root difference s) (integerPivotNumerator root difference selection i) = + if i ∈ s then (integerDifferencePivot difference selection).det else 0 := by + rw [integerPivotNumerator, homogeneousDual_eval] + simp only [integerDifferencePivot_adjugate_dual, Finset.sum_ite_eq] + +theorem integerDifferencePivot_det_cast {α K : Type*} [Fintype α] [DecidableEq α] + (difference : α → K → ℤ) (selection : α → K) : + ((integerDifferencePivot difference selection).det : ℝ) = + (realDifferencePivot (fun i k => (difference i k : ℝ)) selection).det := + (Int.castRingHom ℝ).map_det _ + +theorem integerDifferencePivot_adjugate_cast {α K : Type*} [Fintype α] [DecidableEq α] + (difference : α → K → ℤ) (selection : α → K) (i j : α) : + ((integerDifferencePivot difference selection).adjugate i j : ℝ) = + (realDifferencePivot (fun i k => (difference i k : ℝ)) selection).adjugate i j := by + exact congrFun (congrFun ((Int.castRingHom ℝ).map_adjugate (integerDifferencePivot difference selection)) i) j + +theorem integerDifferencePivot_det_bound {α K : Type*} [Fintype α] [DecidableEq α] + (difference : α → K → ℤ) (selection : α → K) {D : ℝ} + (hdiff : ∀ i j, |(difference i (selection j) : ℝ)| ≤ D) : + |((integerDifferencePivot difference selection).det : ℝ)| ≤ + (Fintype.card α).factorial * D ^ Fintype.card α := by + rw [integerDifferencePivot_det_cast] + exact matrix_det_abs_le_uniform_bound _ hdiff + +theorem integerDifferencePivot_adjugate_bound {α K : Type*} [Fintype α] [DecidableEq α] + (difference : α → K → ℤ) (selection : α → K) {D : ℝ} + (hdiff : ∀ i j, |(difference i (selection j) : ℝ)| ≤ D) (i j : α) : + |((integerDifferencePivot difference selection).adjugate i j : ℝ)| ≤ + (Fintype.card α).factorial * D ^ (Fintype.card α - 1) := by + rw [integerDifferencePivot_adjugate_cast] + exact matrix_adjugate_entry_abs_le _ hdiff i j + +theorem homogeneousDual_map {I K R S : Type*} [Fintype I] [CommRing R] [CommRing S] + (ρ : R →+* S) (root : K → R) (selection : I → K) (n : I → R) : + map ρ (homogeneousDual root selection n) = + homogeneousDual (fun k => ρ (root k)) selection (fun i => ρ (n i)) := by + simp only [homogeneousDual, map_sum, map_mul, map_sub, map_C, map_X] + +theorem integerPivotNumerator_mass {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℤ) (difference : α → K → ℤ) (selection : α → K) {H D : ℝ} (hD : 0 ≤ D) + (hroot : ∀ j, |(root (selection j) : ℝ)| ≤ H) + (hdiff : ∀ i j, |(difference i (selection j) : ℝ)| ≤ D) (i : α) : + realPolynomialMass (map (Int.castRingHom ℝ) (integerPivotNumerator root difference selection i)) ≤ + (Fintype.card α : ℝ) * + (((Fintype.card α).factorial * D ^ (Fintype.card α - 1)) * (1 + H)) := by + rw [integerPivotNumerator, homogeneousDual_map] + apply homogeneousDual_mass _ selection _ (by positivity) hroot + intro j + exact integerDifferencePivot_adjugate_bound difference selection hdiff j i + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped Classical + +noncomputable def normalizedIntegerDual {α K : Type*} (a : ℤ) + (numerator : α → MvPolynomial (Option K) ℤ) (i : α) : MvPolynomial (Option K) ℝ := + (a : ℝ)⁻¹ • map (Int.castRingHom ℝ) (numerator i) + +theorem normalizedIntegerDual_clear {α K : Type*} (a : ℤ) (ha : a ≠ 0) + (numerator : α → MvPolynomial (Option K) ℤ) (i : α) : + map (Int.castRingHom ℝ) (numerator i) = C (a : ℝ) * normalizedIntegerDual a numerator i := by + have ha' : (a : ℝ) ≠ 0 := by exact_mod_cast ha + rw [← smul_eq_C_mul, normalizedIntegerDual, smul_smul, mul_inv_cancel₀ ha', one_smul] + +theorem normalizedIntegerDual_homogeneous {α K : Type*} (a : ℤ) + (numerator : α → MvPolynomial (Option K) ℤ) + (hn : ∀ i, (numerator i).IsHomogeneous 1) (i : α) : + (normalizedIntegerDual a numerator i).IsHomogeneous 1 := by + simpa only [normalizedIntegerDual, smul_eq_C_mul] using + ((hn i).map (Int.castRingHom ℝ)).C_mul (a : ℝ)⁻¹ + +theorem normalizedIntegerDual_boolean {α K : Type*} [DecidableEq α] + (root : K → ℤ) (difference : α → K → ℤ) (a : ℤ) (ha : a ≠ 0) + (numerator : α → MvPolynomial (Option K) ℤ) + (hn : ∀ i s, eval (affineSite root difference s) (numerator i) = if i ∈ s then a else 0) + (i : α) (s : Finset α) : + eval (affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) + (normalizedIntegerDual a numerator i) = if i ∈ s then 1 else 0 := by + have ha' : (a : ℝ) ≠ 0 := by exact_mod_cast ha + have he := affineSite_eval_map (Int.castRingHom ℝ) root difference s (numerator i) + simp only [Int.coe_castRingHom] at he + rw [normalizedIntegerDual, smul_eval, he, hn] + by_cases hi : i ∈ s <;> simp [hi, ha'] + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedLatticeSheet.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedLatticeSheet.lean new file mode 100644 index 0000000000000000000000000000000000000000..94b77ca88e6dc7eef874d431abd93f3cc46d2c80 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedLatticeSheet.lean @@ -0,0 +1,639 @@ +import Mathlib.Analysis.InnerProductSpace.Projection.Basic +import Mathlib.GroupTheory.QuotientGroup.Defs +import Mathlib.LinearAlgebra.Basis.Submodule +import Mathlib.Tactic +import OAI.Combinatorics.Progressions.Estimates.GaussianScaledShortVectorBound +import OAI.Combinatorics.Progressions.Estimates.IntegralHyperplaneCorrection +import OAI.Combinatorics.Progressions.Geometry.EmptyLayerChartBounds +import OAI.Combinatorics.Progressions.Geometry.SignedSplitCoordinates +import OAI.Combinatorics.Progressions.Linear.BasisSurjectionSection + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule + +variable {I E : Type*} [Fintype I] [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def latticeBasisEquiv (Λ : Submodule ℤ E) (b : Basis I ℝ E) + (hb : span ℤ (Set.range b) = Λ) : (I → ℤ) ≃ Λ := + (b.restrictScalars ℤ).equivFun.symm.toEquiv.trans + (LinearEquiv.ofEq _ _ hb).toEquiv + +theorem latticeBasisEquiv_coordinates (Λ : Submodule ℤ E) (b : Basis I ℝ E) + (hb : span ℤ (Set.range b) = Λ) (z : I → ℤ) (i : I) : + b.equivFun (latticeBasisEquiv Λ b hb z).val i = (z i : ℝ) := by + change b.repr (((b.restrictScalars ℤ).equivFun.symm z) : E) i = _ + have h := b.restrictScalars_repr_apply ℤ ((b.restrictScalars ℤ).equivFun.symm z) i + change (algebraMap ℤ ℝ) + ((b.restrictScalars ℤ).equivFun ((b.restrictScalars ℤ).equivFun.symm z) i) = _ at h + rw [LinearEquiv.apply_symm_apply] at h + simpa using h.symm + +theorem latticeBasisEquiv_synthesis (Λ : Submodule ℤ E) (b : Basis I ℝ E) + (hb : span ℤ (Set.range b) = Λ) (z : I → ℤ) : + (latticeBasisEquiv Λ b hb z).val = b.equivFun.symm (fun i => (z i : ℝ)) := by + apply b.equivFun.injective + rw [LinearEquiv.apply_symm_apply] + funext i + exact latticeBasisEquiv_coordinates Λ b hb z i + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + +theorem exists_primitive_lattice_normal (Λ : Submodule ℤ E) + (hspan : Submodule.span ℝ (Λ : Set E) = ⊤) (ξ : E) (hξ : ξ ≠ 0) + (hint : ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ)) : + ∃ (m : ℤ) (ζ w : E), m ≠ 0 ∧ ξ = (m : ℝ) • ζ ∧ ζ ≠ 0 ∧ ‖ζ‖ ≤ ‖ξ‖ ∧ + (∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ζ x = (n : ℝ)) ∧ w ∈ Λ ∧ inner ℝ ζ w = 1 := by + have hf : normalFunctional ξ ≠ 0 := by + intro hz + have he := congrArg (fun f : E →ₗ[ℝ] ℝ => f ξ) hz + change inner ℝ ξ ξ = 0 at he + rw [real_inner_self_eq_norm_sq] at he + have hn : 0 < ‖ξ‖ := norm_pos_iff.mpr hξ + nlinarith + obtain ⟨m, g, w, hm, hfg, hgint, hwΛ, hwg, _⟩ := + exists_primitive_lattice_functional Λ (normalFunctional ξ) hspan hint hf + let ζ := (m : ℝ)⁻¹ • ξ + have hmR : (m : ℝ) ≠ 0 := by exact_mod_cast hm + have hg (x : E) : inner ℝ ζ x = g x := by + have he := congrArg (fun f : E →ₗ[ℝ] ℝ => f x) hfg + change inner ℝ ξ x = (m : ℝ) * g x at he + simp only [ζ, real_inner_smul_left, he] + field_simp + have hsplit : ξ = (m : ℝ) • ζ := by + simp only [ζ, smul_smul, mul_inv_cancel₀ hmR, one_smul] + refine ⟨m, ζ, w, hm, hsplit, smul_ne_zero (inv_ne_zero hmR) hξ, ?_, ?_, hwΛ, ?_⟩ + · have ha : (1 : ℝ) ≤ |(m : ℝ)| := by + have hmpos : (0 : ℤ) < |m| := abs_pos.mpr hm + have hma : (1 : ℤ) ≤ |m| := by omega + exact_mod_cast hma + have hnorm : ‖ζ‖ = ‖ξ‖ / |(m : ℝ)| := by + simp only [ζ, norm_smul, Real.norm_eq_abs, abs_inv, div_eq_mul_inv, mul_comm] + rw [hnorm] + apply (div_le_iff₀ (lt_of_lt_of_le zero_lt_one ha)).mpr + exact le_mul_of_one_le_right (norm_nonneg _) ha + · intro x hx + rw [hg] + exact hgint x hx + · rw [hg] + exact hwg + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + +noncomputable def euclideanDualLattice (Λ : Submodule ℤ E) : Submodule ℤ E := + LinearMap.BilinForm.dualSubmodule (innerₗ E) Λ + +theorem mem_euclideanDualLattice (Λ : Submodule ℤ E) (ξ : E) : + ξ ∈ euclideanDualLattice Λ ↔ ∀ x ∈ Λ, ∃ n : ℤ, inner ℝ ξ x = (n : ℝ) := by + simp only [euclideanDualLattice, LinearMap.BilinForm.mem_dualSubmodule, + Submodule.mem_one, innerₗ_apply_apply] + exact forall_congr' (fun _ => forall_congr' (fun _ => exists_congr (fun _ => eq_comm))) + +theorem realInner_nondegenerate : (innerₗ E).Nondegenerate := by + constructor + · intro x hx + exact inner_self_eq_zero.mp (hx x) + · intro x hx + exact inner_self_eq_zero.mp (hx x) + +variable [FiniteDimensional ℝ E] + +theorem euclideanDualLattice_eq_span_dualBasis (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] : + euclideanDualLattice Λ = Submodule.span ℤ (Set.range + (LinearMap.BilinForm.dualBasis (innerₗ E) realInner_nondegenerate + ((Module.Free.chooseBasis ℤ Λ).ofZLatticeBasis ℝ Λ))) := by + have h := LinearMap.BilinForm.dualSubmodule_span_of_basis (R := ℤ) (innerₗ E) realInner_nondegenerate + ((Module.Free.chooseBasis ℤ Λ).ofZLatticeBasis ℝ Λ) + simpa only [euclideanDualLattice, Module.Basis.ofZLatticeBasis_span] using h + +instance euclideanDualLattice_discrete (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] : DiscreteTopology (euclideanDualLattice Λ) := by + rw [euclideanDualLattice_eq_span_dualBasis Λ] + infer_instance + +instance euclideanDualLattice_isZLattice (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] : IsZLattice ℝ (euclideanDualLattice Λ) := by + constructor + rw [euclideanDualLattice_eq_span_dualBasis Λ] + exact IsZLattice.span_top (K := ℝ) + +theorem euclideanDualLattice_involutive (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] : euclideanDualLattice (euclideanDualLattice Λ) = Λ := by + have hsymm : LinearMap.BilinForm.IsSymm (innerₗ E) := ⟨fun _ _ => real_inner_comm _ _⟩ + have h := LinearMap.BilinForm.dualSubmodule_dualSubmodule_of_basis (R := ℤ) (innerₗ E) + realInner_nondegenerate hsymm ((Module.Free.chooseBasis ℤ Λ).ofZLatticeBasis ℝ Λ) + simpa only [euclideanDualLattice, Module.Basis.ofZLatticeBasis_span] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + +theorem exists_bounded_primitive_lattice_normal (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (ξ : E) (hξ : ξ ≠ 0) (hξdual : ξ ∈ euclideanDualLattice Λ) : + ∃ (m : ℤ) (ζ w : E), m ≠ 0 ∧ ξ = (m : ℝ) • ζ ∧ ζ ≠ 0 ∧ ‖ζ‖ ≤ ‖ξ‖ ∧ + ζ ∈ euclideanDualLattice Λ ∧ w ∈ Λ ∧ inner ℝ ζ w = 1 ∧ + |(m : ℝ)| ≤ Real.exp Real.pi * ‖ξ‖ * latticeGaussianMass (euclideanDualLattice Λ) 1 0 := by + obtain ⟨m, ζ, w, hm, hsplit, hζ, hnorm, hint, hwΛ, hw⟩ := + exists_primitive_lattice_normal Λ (IsZLattice.span_top (K := ℝ)) ξ hξ + ((mem_euclideanDualLattice Λ ξ).mp hξdual) + have hζdual := (mem_euclideanDualLattice Λ ζ).mpr hint + exact ⟨m, ζ, w, hm, hsplit, hζ, hnorm, hζdual, hwΛ, hw, + latticeGaussianMass_controls_integer_factor (euclideanDualLattice Λ) ξ ζ hζdual hζ m hsplit⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Submodule Set + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +noncomputable def latticeSection (Λ : Submodule ℤ E) (W : Submodule ℝ E) : + Submodule ℤ W := ZLattice.comap ℝ Λ W.subtype + +instance latticeSection_discrete (Λ : Submodule ℤ E) [DiscreteTopology Λ] + (W : Submodule ℝ E) : DiscreteTopology (latticeSection Λ W) := + ZLattice.comap_discreteTopology ℝ Λ continuous_subtype_val Subtype.val_injective + +noncomputable def orthogonalLatticeImage (Λ : Submodule ℤ E) (W : Submodule ℝ E) : + Submodule ℤ W := Λ.map (W.orthogonalProjectionOnto.toLinearMap.restrictScalars ℤ) + +theorem orthogonalLatticeImage_le_dual_section (Λ : Submodule ℤ E) + (W : Submodule ℝ E) : + orthogonalLatticeImage Λ W ≤ euclideanDualLattice (latticeSection (euclideanDualLattice Λ) W) := by + rintro _ ⟨x, hx, rfl⟩ + apply (mem_euclideanDualLattice _ _).mpr + intro y hy + have hy' : (y : E) ∈ euclideanDualLattice Λ := hy + obtain ⟨n, hn⟩ := (mem_euclideanDualLattice Λ y.val).mp hy' x hx + refine ⟨n, ?_⟩ + change inner ℝ (W.orthogonalProjectionOnto x) y = (n : ℝ) + rw [Submodule.inner_orthogonalProjectionOnto_eq_of_mem_right, real_inner_comm] + exact hn + +theorem orthogonalLatticeImage_discrete (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (W : Submodule ℝ E) + [IsZLattice ℝ (latticeSection (euclideanDualLattice Λ) W)] : + DiscreteTopology (orthogonalLatticeImage Λ W) := by + have hdis : DiscreteTopology (euclideanDualLattice (latticeSection (euclideanDualLattice Λ) W)) := + euclideanDualLattice_discrete _ + have hd : IsDiscrete (euclideanDualLattice (latticeSection (euclideanDualLattice Λ) W) : Set W) := + SetLike.isDiscrete_iff_discreteTopology.mpr hdis + exact isDiscrete_iff_discreteTopology.mp (hd.mono (orthogonalLatticeImage_le_dual_section Λ W)) + +theorem orthogonalLatticeImage_full (Λ : Submodule ℤ E) [DiscreteTopology Λ] + [IsZLattice ℝ Λ] (W : Submodule ℝ E) [DiscreteTopology (orthogonalLatticeImage Λ W)] : + IsZLattice ℝ (orthogonalLatticeImage Λ W) := by + constructor + change span ℝ (W.orthogonalProjectionOnto.toLinearMap '' (Λ : Set E)) = ⊤ + rw [Submodule.span_image, IsZLattice.span_top, Submodule.map_top] + apply LinearMap.range_eq_top.mpr + intro w + refine ⟨w.val, ?_⟩ + apply Subtype.ext + exact W.starProjection_eq_self_iff.mpr w.property + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable (ι : Type*) [Fintype ι] + +noncomputable def standardEuclideanLattice : Submodule ℤ (EuclideanSpace ℝ ι) := + Submodule.span ℤ (Set.range (EuclideanSpace.basisFun ι ℝ).toBasis) + +instance standardEuclideanLattice_discrete : DiscreteTopology (standardEuclideanLattice ι) := + inferInstanceAs (DiscreteTopology (Submodule.span ℤ (Set.range (EuclideanSpace.basisFun ι ℝ).toBasis))) + +instance standardEuclideanLattice_full : IsZLattice ℝ (standardEuclideanLattice ι) := + inferInstanceAs (IsZLattice ℝ (Submodule.span ℤ (Set.range (EuclideanSpace.basisFun ι ℝ).toBasis))) + +theorem mem_standardEuclideanLattice (x : EuclideanSpace ℝ ι) : + x ∈ standardEuclideanLattice ι ↔ ∀ i, ∃ n : ℤ, (n : ℝ) = x i := by + change x ∈ Submodule.span ℤ (Set.range (EuclideanSpace.basisFun ι ℝ).toBasis) ↔ _ + rw [(EuclideanSpace.basisFun ι ℝ).toBasis.mem_span_iff_repr_mem ℤ x] + simp only [OrthonormalBasis.coe_toBasis_repr_apply, EuclideanSpace.basisFun_repr] + rfl + +noncomputable def standardEuclideanPoint (z : ι → ℤ) : standardEuclideanLattice ι := + ⟨WithLp.toLp 2 (fun i => (z i : ℝ)), (mem_standardEuclideanLattice ι _).mpr (fun i => ⟨z i, rfl⟩)⟩ + +@[simp] +theorem standardEuclideanPoint_apply (z : ι → ℤ) (i : ι) : + (standardEuclideanPoint ι z : EuclideanSpace ℝ ι) i = (z i : ℝ) := rfl + +theorem standardEuclideanPoint_bijective : Function.Bijective (standardEuclideanPoint ι) := by + constructor + · intro z w h + funext i + have hi := congrArg (fun x : standardEuclideanLattice ι => (x : EuclideanSpace ℝ ι) i) h + exact Int.cast_injective (α := ℝ) hi + · intro x + choose z hz using (mem_standardEuclideanLattice ι (x : EuclideanSpace ℝ ι)).mp x.property + refine ⟨z, ?_⟩ + apply Subtype.ext + ext i + exact hz i + +noncomputable def standardEuclideanEquiv : (ι → ℤ) ≃ standardEuclideanLattice ι := + Equiv.ofBijective (standardEuclideanPoint ι) (standardEuclideanPoint_bijective ι) + +theorem standardEuclideanLattice_self_dual : + euclideanDualLattice (standardEuclideanLattice ι) = standardEuclideanLattice ι := by + ext x + rw [mem_euclideanDualLattice, mem_standardEuclideanLattice] + constructor + · intro hx i + have hi : EuclideanSpace.basisFun ι ℝ i ∈ standardEuclideanLattice ι := + Submodule.subset_span ⟨i, rfl⟩ + obtain ⟨n, hn⟩ := hx _ hi + exact ⟨n, by simpa only [EuclideanSpace.inner_basisFun_real] using hn.symm⟩ + · intro hx y hy + choose a ha using hx + choose b hb using (mem_standardEuclideanLattice ι y).mp hy + refine ⟨∑ i, a i * b i, ?_⟩ + simp only [PiLp.inner_apply, RCLike.inner_apply, conj_trivial] + simp only [Int.cast_sum, Int.cast_mul, ha, hb] + apply Finset.sum_congr rfl + intro i _ + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +noncomputable def orthogonalLatticeProjection (Λ : Submodule ℤ E) (W : Submodule ℝ E) : + Λ →ₗ[ℤ] orthogonalLatticeImage Λ W := + ((W.orthogonalProjectionOnto.toLinearMap.restrictScalars ℤ).comp Λ.subtype).codRestrict + (orthogonalLatticeImage Λ W) (fun x => ⟨x.val, x.property, rfl⟩) + +theorem orthogonalLatticeProjection_surjective (Λ : Submodule ℤ E) (W : Submodule ℝ E) : + Function.Surjective (orthogonalLatticeProjection Λ W) := by + rintro ⟨y, x, hx, hxy⟩ + exact ⟨⟨x, hx⟩, Subtype.ext hxy⟩ + +noncomputable def orthogonalLatticeKernelEquiv (Λ : Submodule ℤ E) (W : Submodule ℝ E) : + latticeSection Λ Wᗮ ≃ₗ[ℤ] LinearMap.ker (orthogonalLatticeProjection Λ W) where + toFun x := ⟨⟨x.val.val, x.property⟩, Subtype.ext + (W.orthogonalProjectionOnto_eq_zero_iff.mpr x.val.property)⟩ + invFun x := ⟨⟨x.val.val, W.orthogonalProjectionOnto_eq_zero_iff.mp + (congrArg Subtype.val (show orthogonalLatticeProjection Λ W x.val = 0 from x.property))⟩, + x.val.property⟩ + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl + +theorem exists_orthogonal_lattice_split_basis {I J : Type*} + (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bK : Basis I ℤ (latticeSection Λ Wᗮ)) (bP : Basis J ℤ (orthogonalLatticeImage Λ W)) : + ∃ b : Basis (I ⊕ J) ℤ Λ, + (∀ i, (b (Sum.inl i) : E) = (bK i).val.val) ∧ + (∀ j, W.orthogonalProjectionOnto (b (Sum.inr j) : E) = (bP j).val) := by + let : Free ℤ (orthogonalLatticeImage Λ W) := Free.of_basis bP + obtain ⟨b, hK, hP⟩ := exists_basis_of_surjection (orthogonalLatticeProjection Λ W) + (orthogonalLatticeProjection_surjective Λ W) (bK.map (orthogonalLatticeKernelEquiv Λ W)) bP + refine ⟨b, ?_, ?_⟩ + · intro i + rw [hK] + rfl + · intro j + exact congrArg Subtype.val (hP j) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule + +variable {I E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def integerBasisOfReal (Λ : Submodule ℤ E) (b : Basis I ℝ E) + (hb : span ℤ (Set.range b) = Λ) : Basis I ℤ Λ := + (b.restrictScalars ℤ).map (LinearEquiv.ofEq _ _ hb) + +theorem integerBasisOfReal_apply (Λ : Submodule ℤ E) (b : Basis I ℝ E) + (hb : span ℤ (Set.range b) = Λ) (i : I) : (integerBasisOfReal Λ b hb i).val = b i := by + simp only [integerBasisOfReal, Basis.map_apply, LinearEquiv.coe_ofEq_apply, + Basis.restrictScalars_apply] + +theorem integerBasisOfReal_synthesis [Fintype I] (Λ : Submodule ℤ E) (b : Basis I ℝ E) + (hb : span ℤ (Set.range b) = Λ) (z : I → ℤ) : + ((integerBasisOfReal Λ b hb).equivFun.symm z).val = + b.equivFun.symm (fun i => (z i : ℝ)) := by + simp only [integerBasisOfReal, Basis.map_equivFun, LinearEquiv.trans_symm, + LinearEquiv.symm_symm, LinearEquiv.trans_apply, LinearEquiv.coe_ofEq_apply] + exact latticeBasisEquiv_synthesis (span ℤ (Set.range b)) b rfl z + +noncomputable def standardEuclideanLinearEquiv (J : Type*) [Fintype J] : + (J → ℤ) ≃ₗ[ℤ] standardEuclideanLattice J := + ((EuclideanSpace.basisFun J ℝ).toBasis.restrictScalars ℤ).equivFun.symm + +theorem standardEuclideanLinearEquiv_apply (J : Type*) [Fintype J] (z : J → ℤ) (i : J) : + (standardEuclideanLinearEquiv J z).val i = (z i : ℝ) := by + have h := latticeBasisEquiv_coordinates (standardEuclideanLattice J) + (EuclideanSpace.basisFun J ℝ).toBasis rfl z i + have he : (latticeBasisEquiv (standardEuclideanLattice J) + (EuclideanSpace.basisFun J ℝ).toBasis rfl z).val = + (standardEuclideanLinearEquiv J z).val := rfl + rw [he] at h + simpa only [Basis.equivFun_apply, OrthonormalBasis.coe_toBasis_repr_apply, + EuclideanSpace.basisFun_repr] using h + +theorem standardEuclideanLinearEquiv_eq_point (J : Type*) [Fintype J] (z : J → ℤ) : + standardEuclideanLinearEquiv J z = standardEuclideanPoint J z := by + apply Subtype.ext + ext i + exact standardEuclideanLinearEquiv_apply J z i + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable (J : Type*) [Fintype J] + +def standardLatticeSmallBox : Set (EuclideanSpace ℝ J) := + {x | ∀ i, |x i| < 1 / 2} + +theorem standardLatticeSmallBox_isOpen : IsOpen (standardLatticeSmallBox J) := by + unfold standardLatticeSmallBox + simp only [Set.ofPred_forall] + apply isOpen_iInter_of_finite + intro i + exact isOpen_lt (by fun_prop) continuous_const + +theorem standardLatticeSmallBox_separates + {x y : EuclideanSpace ℝ J} (hx : x ∈ standardLatticeSmallBox J) + (hy : y ∈ standardLatticeSmallBox J) (hxy : x - y ∈ standardEuclideanLattice J) : x = y := by + ext i + obtain ⟨n, hn⟩ := (mem_standardEuclideanLattice J (x - y)).mp hxy i + change (n : ℝ) = x i - y i at hn + have hxi := abs_lt.mp (hx i) + have hyi := abs_lt.mp (hy i) + have hnlo : (-1 : ℝ) < n := by linarith + have hnhi : (n : ℝ) < 1 := by linarith + have hnlo' : (-1 : ℤ) < n := by exact_mod_cast hnlo + have hnhi' : n < (1 : ℤ) := by exact_mod_cast hnhi + have hn0 : n = 0 := by omega + exact sub_eq_zero.mp (by simpa only [hn0, Int.cast_zero] using hn.symm) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {E I J : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +noncomputable def orthogonalSectionKernelEquiv (Λ : Submodule ℤ E) (W : Submodule ℝ E) : + latticeSection Λ W ≃ₗ[ℤ] LinearMap.ker (orthogonalLatticeProjection Λ Wᗮ) where + toFun x := ⟨⟨x.val.val, x.property⟩, + Subtype.ext (W.orthogonalProjectionOnto_orthogonal_apply_eq_zero x.val.property)⟩ + invFun x := ⟨⟨x.val.val, by + have h := Wᗮ.orthogonalProjectionOnto_eq_zero_iff.mp + (congrArg Subtype.val (show orthogonalLatticeProjection Λ Wᗮ x.val = 0 from x.property)) + change x.val.val ∈ Wᗮᗮ at h + rwa [W.orthogonal_orthogonal] at h⟩, x.val.property⟩ + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl + +noncomputable def latticeLiftSection (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) : + orthogonalLatticeImage Λ Wᗮ →ₗ[ℤ] Λ := + basisSurjectionSection (orthogonalLatticeProjection Λ Wᗮ) + (orthogonalLatticeProjection_surjective Λ Wᗮ) bP + +theorem latticeLiftSection_rightInverse (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) (x : orthogonalLatticeImage Λ Wᗮ) : + orthogonalLatticeProjection Λ Wᗮ (latticeLiftSection Λ W bP x) = x := + basisSurjectionSection_rightInverse _ _ _ _ + +variable [Fintype I] [Fintype J] + +noncomputable def latticeIntegerLift (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) : (J → ℤ) →ₗ[ℤ] Λ := + (latticeLiftSection Λ W bP).comp bP.equivFun.symm.toLinearMap + +theorem latticeIntegerLift_projection (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) (z : J → ℤ) : + Wᗮ.orthogonalProjectionOnto (latticeIntegerLift Λ W bP z).val = (bP.equivFun.symm z).val := + congrArg Subtype.val (latticeLiftSection_rightInverse Λ W bP (bP.equivFun.symm z)) + +noncomputable def latticeSignedCoordinates (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bW : Basis I ℤ (latticeSection Λ W)) (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) : + Λ ≃ₗ[ℤ] (J → ℤ) × (I → ℤ) := + signedSplitCoordinates (orthogonalLatticeProjection Λ Wᗮ) (latticeLiftSection Λ W bP) + (latticeLiftSection_rightInverse Λ W bP) (bW.map (orthogonalSectionKernelEquiv Λ W)) bP + +theorem latticeSignedCoordinates_fst (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bW : Basis I ℤ (latticeSection Λ W)) (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) (x : Λ) : + (latticeSignedCoordinates Λ W bW bP x).1 = + -(bP.equivFun (orthogonalLatticeProjection Λ Wᗮ x)) := rfl + +theorem latticeSignedCoordinates_symm_apply (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bW : Basis I ℤ (latticeSection Λ W)) (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) + (z : J → ℤ) (w : I → ℤ) : + ((latticeSignedCoordinates Λ W bW bP).symm (z, w)).val = + (bW.equivFun.symm w).val.val - (latticeIntegerLift Λ W bP z).val := by + rw [latticeSignedCoordinates, signedSplitCoordinates_symm_apply] + simp only [Submodule.coe_sub, Basis.map_equivFun, LinearEquiv.trans_symm, + LinearEquiv.symm_symm, LinearEquiv.trans_apply] + rfl + +theorem latticeSignedCoordinates_reconstruction (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (bW : Basis I ℤ (latticeSection Λ W)) (bP : Basis J ℤ (orthogonalLatticeImage Λ Wᗮ)) (x : Λ) : + x.val + (latticeIntegerLift Λ W bP (latticeSignedCoordinates Λ W bW bP x).1).val = + (bW.equivFun.symm (latticeSignedCoordinates Λ W bW bP x).2).val.val := by + have h := latticeSignedCoordinates_symm_apply Λ W bW bP + (latticeSignedCoordinates Λ W bW bP x).1 (latticeSignedCoordinates Λ W bW bP x).2 + change ((latticeSignedCoordinates Λ W bW bP).symm (latticeSignedCoordinates Λ W bW bP x)).val = _ at h + rw [LinearEquiv.symm_apply_apply] at h + exact eq_sub_iff_add_eq.mp h + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +noncomputable def projectedLatticeLift (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (z : orthogonalLatticeImage Λ Wᗮ) : Λ := + (orthogonalLatticeProjection_surjective Λ Wᗮ z).choose + +theorem projectedLatticeLift_projection (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (z : orthogonalLatticeImage Λ Wᗮ) : + Wᗮ.orthogonalProjectionOnto (projectedLatticeLift Λ W z).val = z.val := + congrArg Subtype.val (orthogonalLatticeProjection_surjective Λ Wᗮ z).choose_spec + +noncomputable def latticeSheetPoint (W : Submodule ℝ E) (z : Wᗮ) (u : W) : E := + u.val + z.val + +theorem latticeSheetPoint_projection (W : Submodule ℝ E) (z : Wᗮ) (u : W) : + W.orthogonalProjectionOnto (latticeSheetPoint W z u) = u := by + change W.orthogonalProjectionOnto (u.val + z.val) = u + rw [map_add, W.orthogonalProjectionOnto_apply_of_mem_orthogonal z.property, add_zero] + exact Subtype.ext (W.starProjection_eq_self_iff.mpr u.property) + +theorem latticeSheetPoint_projection_orthogonal (W : Submodule ℝ E) (z : Wᗮ) (u : W) : + Wᗮ.orthogonalProjectionOnto (latticeSheetPoint W z u) = z := by + change Wᗮ.orthogonalProjectionOnto (u.val + z.val) = z + rw [map_add, W.orthogonalProjectionOnto_orthogonal_apply_eq_zero u.property, zero_add] + exact Subtype.ext (Wᗮ.starProjection_eq_self_iff.mpr z.property) + +noncomputable def projectedLatticeShift (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (z : orthogonalLatticeImage Λ Wᗮ) : W := + W.orthogonalProjectionOnto (projectedLatticeLift Λ W z).val + +noncomputable def latticeSheetQuotient (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (z : orthogonalLatticeImage Λ Wᗮ) (u : W) : W ⧸ (latticeSection Λ W).toAddSubgroup := + QuotientAddGroup.mk (u - projectedLatticeShift Λ W z) + +theorem latticeSheetPoint_reconstruction (Λ : Submodule ℤ E) (W : Submodule ℝ E) + (z : orthogonalLatticeImage Λ Wᗮ) (u : W) : + latticeSheetPoint W z.val u = + (u - projectedLatticeShift Λ W z).val + (projectedLatticeLift Λ W z).val := by + have hs := W.starProjection_add_starProjection_orthogonal (projectedLatticeLift Λ W z).val + change (projectedLatticeShift Λ W z).val + + (Wᗮ.orthogonalProjectionOnto (projectedLatticeLift Λ W z).val).val = _ at hs + rw [projectedLatticeLift_projection] at hs + change u.val + z.val.val = (u.val - (projectedLatticeShift Λ W z).val) + _ + calc + _ = (u.val - (projectedLatticeShift Λ W z).val) + + ((projectedLatticeShift Λ W z).val + z.val.val) := by abel + _ = _ := by rw [hs] + +theorem latticeSheetPoint_sub_mem_of_quotient_eq (Λ : Submodule ℤ E) (W : Submodule ℝ E) + {z w : orthogonalLatticeImage Λ Wᗮ} {u v : W} + (h : latticeSheetQuotient Λ W z u = latticeSheetQuotient Λ W w v) : + latticeSheetPoint W z.val u - latticeSheetPoint W w.val v ∈ Λ := by + have hm := QuotientAddGroup.eq_iff_sub_mem.mp h + change ((u - projectedLatticeShift Λ W z) - (v - projectedLatticeShift Λ W w)).val ∈ Λ at hm + have hl := Λ.sub_mem (projectedLatticeLift Λ W z).property (projectedLatticeLift Λ W w).property + rw [latticeSheetPoint_reconstruction, latticeSheetPoint_reconstruction] + convert Λ.add_mem hm hl using 1 + simp only [Submodule.coe_sub] + abel + +theorem latticeSheetQuotient_injective_on_region (Λ : Submodule ℤ E) (W : Submodule ℝ E) + {Ω : Set E} + (hΩ : ∀ x ∈ Ω, ∀ y ∈ Ω, x - y ∈ Λ → x = y) + {z w : orthogonalLatticeImage Λ Wᗮ} {u v : W} + (hu : latticeSheetPoint W z.val u ∈ Ω) (hv : latticeSheetPoint W w.val v ∈ Ω) + (h : latticeSheetQuotient Λ W z u = latticeSheetQuotient Λ W w v) : z = w ∧ u = v := by + have he := hΩ _ hu _ hv (latticeSheetPoint_sub_mem_of_quotient_eq Λ W h) + constructor + · apply Subtype.ext + simpa only [latticeSheetPoint_projection_orthogonal] using + congrArg Wᗮ.orthogonalProjectionOnto he + · simpa only [latticeSheetPoint_projection] using congrArg W.orthogonalProjectionOnto he + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule +open MeasureTheory + +theorem normalizedLatticeSheet_point {E : Type*} {n : ℕ} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + (W : Submodule ℝ E) (Λ : Submodule ℤ Wᗮ) (b : Basis (Fin n) ℝ Wᗮ) + (hb : span ℤ (Set.range b) = Λ) (z : Fin n → ℤ) (u : W) : + latticeSheetPoint W (latticeBasisEquiv Λ b hb z).val u = + (normalizedOrthogonalChart W b).symm (u, fun i => (z i : ℝ) / (basisAxisScale b i : ℝ)) := by + apply (normalizedOrthogonalChart W b).injective + rw [ContinuousLinearEquiv.apply_symm_apply, normalizedOrthogonalChart_apply, + latticeSheetPoint_projection, latticeSheetPoint_projection_orthogonal] + refine Prod.ext rfl ?_ + funext i + change b.equivFun (latticeBasisEquiv Λ b hb z).val i / (basisAxisScale b i : ℝ) = + (z i : ℝ) / (basisAxisScale b i : ℝ) + rw [latticeBasisEquiv_coordinates] + +theorem normalizedLatticeSheet_tsum_volume {E : Type*} {n : ℕ} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + (W : Submodule ℝ E) (Λ : Submodule ℤ Wᗮ) (b : Basis (Fin n) ℝ Wᗮ) + (hb : span ℤ (Set.range b) = Λ) (Ω : Set E) : + (∑' z : Λ, volume {u : W | latticeSheetPoint W z.val u ∈ Ω}) = + ∑' z : Fin n → ℤ, volume {u : W | + (normalizedOrthogonalChart W b).symm + (u, fun i => (z i : ℝ) / (basisAxisScale b i : ℝ)) ∈ Ω} := by + have h := (latticeBasisEquiv Λ b hb).tsum_eq + (fun z => volume {u : W | latticeSheetPoint W z.val u ∈ Ω}) + simp_rw [normalizedLatticeSheet_point W Λ b hb] at h + exact h.symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedMarkedLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedMarkedLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..40889f8599d48b66c9269b849f4110761f6d779a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedMarkedLattice.lean @@ -0,0 +1,218 @@ +import OAI.Combinatorics.Progressions.Estimates.MarkedPureEvaluation + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup + +theorem exists_exact_source_lattice_cover {L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t d e : ℕ} + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M t e) + (φ : L →ₗ⁅ℚ⁆ M) {p : ℝ} (hp : 0 ≤ p) + (hD : D.GeometryComplexityLE p) (hE : E.GeometryComplexityLE p) + (hentries : ∀ i j, rationalLogHeight (E.basis.repr (φ (D.basis j)) i) ≤ p) : + let Λ := D.lattice ⊓ E.lattice.comap (mapOfSteps + (hL := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ) + ∃ (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N), + (N : ℝ) ≤ Real.exp ((p + 2) ^ 5) ∧ + (D.withLattice Λ N hN hin hout).GeometryComplexityLE ((p + 2) ^ 5) := by + classical + let A := LinearMap.toMatrix D.basis E.basis φ.toLinearMap + let N := D.grid * (E.grid * matrixDenominator A) + let Λ := D.lattice ⊓ E.lattice.comap (mapOfSteps + (hL := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ) + have hN : 0 < N := Nat.mul_pos D.grid_pos (Nat.mul_pos E.grid_pos (matrixDenominator_pos A)) + have hDN : D.grid ∣ N := dvd_mul_right _ _ + have hEN : E.grid * matrixDenominator A ∣ N := dvd_mul_left _ _ + have hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ := by + intro x hx + change (⟨D.basis.equivFun.symm x⟩ : D.filtration.Group) ∈ D.lattice ∧ + (⟨φ (D.basis.equivFun.symm x)⟩ : E.filtration.Group) ∈ E.lattice + refine ⟨D.inner_grid (scaledIntegerGrid_subset_of_dvd hDN hx), ?_⟩ + apply (bchSubgroupCoordinates_repr E.basis E.lattice _).mp + apply E.inner_grid + apply linearMap_mem_scaledGrid D.basis E.basis φ.toLinearMap hEN + simpa only [LinearEquiv.apply_symm_apply] using hx + have hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N := by + intro x hx + exact denominatorGrid_subset_of_dvd hDN (D.outer_grid hx.1) + have hA : (matrixDenominator A : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + apply matrixDenominator_le_exp_power A hp 1 + (by simpa only [Fintype.card_fin] using hE.1) + (by simpa only [Fintype.card_fin] using hD.1) + intro i j + dsimp only [A] + rw [LinearMap.toMatrix_apply] + exact ((rationalLogHeight_le_iff _ p).mp (hentries i j)).2.trans + (Real.exp_le_exp.mpr (by simp only [pow_one]; linarith)) + have hNbound : (N : ℝ) ≤ Real.exp ((p + 2) ^ 5) := by + have h := mul_le_mul hD.2.1 (mul_le_mul hE.2.1 hA (Nat.cast_nonneg _) (Real.exp_nonneg _)) + (by positivity) (Real.exp_nonneg _) + have h' : (N : ℝ) ≤ Real.exp (p + (p + (p + 2) ^ 3)) := by + simpa only [N, Nat.cast_mul, ← Real.exp_add] using h + apply h'.trans (Real.exp_le_exp.mpr ?_) + have hp3 : p ≤ (p + 2) ^ 3 := le_power_budget hp (by decide) + calc + p + (p + (p + 2) ^ 3) ≤ 3 * (p + 2) ^ 3 := by linarith + _ ≤ (p + 2) ^ 2 * (p + 2) ^ 3 := + mul_le_mul_of_nonneg_right (by nlinarith) (by positivity) + _ = (p + 2) ^ 5 := by ring + exact ⟨N, hN, hin, hout, hNbound, + D.withLattice_geometry Λ N hN hin hout hD (le_power_budget hp (by decide)) hNbound⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup + +namespace RationalFilteredNilmanifold.MultidegreeStructure + +variable {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + +noncomputable def withLattice (M : D.MultidegreeStructure bound) + (Λ : Subgroup D.filtration.Group) (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N) : + (D.withLattice Λ N hN hin hout).MultidegreeStructure bound where + filtration := M.filtration + ordinary := M.ordinary + basis := M.basis + +theorem withLattice_complexity (M : D.MultidegreeStructure bound) + (Λ : Subgroup D.filtration.Group) (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N) + {p P : ℝ} (hM : M.ComplexityLE p) (hpP : p ≤ P) + (hD : (D.withLattice Λ N hN hin hout).GeometryComplexityLE P) : + (M.withLattice Λ N hN hin hout).ComplexityLE P := + ⟨hD, fun a j k => (hM.2 a j k).trans hpP⟩ + +end RationalFilteredNilmanifold.MultidegreeStructure + +theorem exists_marked_evaluation_lattice (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {r t d e u : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (D : RationalFilteredNilmanifold (MarkedShiftQuotient F v w marked t) (s + 1) d) + (M : D.MultidegreeStructure (mixedCorrelationDegree s)) + (J : LieIdeal ℚ L) (hJ : markedLieSpan v w marked 0 2 0 ≤ J.toSubmodule) + (E : RationalFilteredNilmanifold (L ⧸ J) u e) {p : ℝ}, + 0 ≤ p → M.ComplexityLE p → E.GeometryComplexityLE p → (t : ℝ) ≤ p → + (∀ i j, rationalLogHeight + (E.basis.repr (markedBaseEvaluation F v w marked t J hJ 0 (D.basis j)) i) ≤ p) → + (∀ i j, rationalLogHeight (markedQuotientPhase F v w marked t (D.basis j) i) ≤ p) → + ∃ (B : ℕ) (Λ : Subgroup D.filtration.Group) (hB : 0 < B) + (hin : scaledIntegerGrid B ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid B), + (B : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ Λ ≤ D.lattice ∧ + bchSubgroupCoordinates D.basis Λ = scaledIntegerGrid B ∧ + (M.withLattice Λ B hB hin hout).ComplexityLE ((p + C) ^ C) ∧ + (∀ z : D.filtration.Group, z ∈ Λ → + (⟨markedBaseEvaluation F v w marked t J hJ 0 z.coord⟩ : E.filtration.Group) ∈ E.lattice) ∧ + (∀ z : D.filtration.Group, z ∈ Λ → + IntegralVector (markedQuotientPhase F v w marked t z.coord)) ∧ + ∀ z : D.RealGroup, z ∈ (D.withLattice Λ B hB hin hout).realLattice → + (⟨(markedBaseEvaluation F v w marked t J hJ 0).baseChange ℝ z.coord⟩ : E.RealGroup) ∈ + E.realLattice := by + obtain ⟨C, hC, hcover⟩ := RationalFilteredNilmanifold.exists_native_linear_target_cover (s + 1) + refine ⟨C, hC, ?_⟩ + intro I L _ _ r t d e u F v w marked D M J hJ E p hp hM hE ht hφ hψ + have hC1 : (1 : ℝ) ≤ C := by exact_mod_cast (show 1 ≤ C by omega) + have hpC : p ≤ (p + C) ^ C := by + calc + p ≤ p + C := le_add_of_nonneg_right (Nat.cast_nonneg _) + _ = (p + C) ^ 1 := (pow_one _).symm + _ ≤ _ := pow_le_pow_right₀ (by linarith) (by omega : 1 ≤ C) + obtain ⟨B, Λ, hB, hin, hout, hbound, hΛ, hcoords, hgeom, hmap, hphase⟩ := + hcover D E (markedBaseEvaluation F v w marked t J hJ 0) + (markedQuotientPhase F v w marked t).toLinearMap hp hM.1 hE ht hφ hψ + refine ⟨B, Λ, hB, hin, hout, hbound, hΛ, hcoords, + M.withLattice_complexity Λ B hB hin hout hM hpC hgeom, hmap, hphase, ?_⟩ + exact (D.withLattice Λ B hB hin hout).linearMap_real_lattice E + (markedBaseEvaluation F v w marked t J hJ 0) hmap + +end Erdos3 + +end + +section + +namespace Erdos3 + +open NilpotentLieBCHGroup + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r d : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) (t : ℕ) + (D : RationalFilteredNilmanifold (MarkedShiftQuotient F v w marked t) (s + 1) d) (m : ℕ) + +noncomputable def normalizedMarkedLattice : Subgroup D.filtration.Group := + D.lattice ⊓ (RationalTorus.nilmanifold t).lattice.comap + (mapOfSteps (hL := D.filtration.lowerCentralSeries_eq_bot) + (hM := (RationalTorus.nilmanifold t).filtration.lowerCentralSeries_eq_bot) + (normalizedMarkedPhase F v w marked t m)) + +theorem normalizedMarkedLattice_le : normalizedMarkedLattice F v w marked t D m ≤ D.lattice := + inf_le_left + +theorem normalizedMarkedLattice_integral (z : D.filtration.Group) + (hz : z ∈ normalizedMarkedLattice F v w marked t D m) : + IntegralVector (normalizedMarkedPhase F v w marked t m z.coord) := hz.2 + +theorem normalizedMarkedLattice_direction (hm : 0 < m) (a : Fin t → ℤ) + (ha : (⟨(m : ℚ) • markedQuotientDirection F v w marked t (fun i => (a i : ℚ))⟩ : + D.filtration.Group) ∈ D.lattice) : + (⟨(m : ℚ) • markedQuotientDirection F v w marked t (fun i => (a i : ℚ))⟩ : + D.filtration.Group) ∈ normalizedMarkedLattice F v w marked t D m := by + refine ⟨ha, ?_⟩ + change IntegralVector (normalizedMarkedPhase F v w marked t m + ((m : ℚ) • markedQuotientDirection F v w marked t (fun i => (a i : ℚ)))) + rw [normalizedMarkedPhase_scaled_direction F v w marked t m hm] + exact ⟨a, fun _ => rfl⟩ + +theorem exists_normalizedMarkedLattice_model + (M : D.MultidegreeStructure (mixedCorrelationDegree s)) {p : ℝ} + (hp : 0 ≤ p) (hM : M.ComplexityLE p) (ht : (t : ℝ) ≤ p) (hm : 0 < m) + (hmp : (m : ℝ) ≤ Real.exp p) + (hcoords : ∀ i j, rationalLogHeight (markedQuotientPhase F v w marked t (D.basis j) i) ≤ p) : + ∃ (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis (normalizedMarkedLattice F v w marked t D m)) + (hout : bchSubgroupCoordinates D.basis (normalizedMarkedLattice F v w marked t D m) ⊆ denominatorGrid N), + (N : ℝ) ≤ Real.exp ((2 * p + 3) ^ 5) ∧ + (M.withLattice (normalizedMarkedLattice F v w marked t D m) N hN hin hout).ComplexityLE + ((2 * p + 3) ^ 5) := by + have hpP : p ≤ 2 * p + 1 := by linarith + have hP : 0 ≤ 2 * p + 1 := hp.trans hpP + have hentries (i j) : rationalLogHeight ((RationalTorus.nilmanifold t).basis.repr + (normalizedMarkedPhase F v w marked t m (D.basis j)) i) ≤ 2 * p + 1 := by + change rationalLogHeight ((RationalTorus.basis t).repr + (normalizedMarkedPhase F v w marked t m (D.basis j)) i) ≤ _ + rw [RationalTorus.basis_repr] + exact normalizedMarkedPhase_height F v w marked t m hm hp hmp (D.basis j) i (hcoords i j) + obtain ⟨N, hN, hin, hout, hNbound, hgeom⟩ := D.exists_exact_source_lattice_cover + (RationalTorus.nilmanifold t) (normalizedMarkedPhase F v w marked t m) hP + (hM.1.mono D hpP) (RationalTorus.nilmanifold_geometry t hP (ht.trans hpP)) hentries + have heq : 2 * p + 1 + 2 = 2 * p + 3 := by ring + rw [heq] at hNbound hgeom + have hpQ : p ≤ (2 * p + 3) ^ 5 := hpP.trans (by + simpa only [heq] using le_power_budget hP (by decide : 1 ≤ 5)) + exact ⟨N, hN, hin, hout, hNbound, + M.withLattice_complexity (normalizedMarkedLattice F v w marked t D m) + N hN hin hout hM hpQ hgeom⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedResidueBlockCells.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedResidueBlockCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba506f4e2e141f6cc84169f20592c7e75f2ccbdd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedResidueBlockCells.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.Progressions.Lattices.ResidueSliceNormalizedCell + +namespace OAI + +section + +namespace Erdos3 + +namespace ResidueBoxSlice + +theorem exists_affine_normalized_cell_of_width {ι : Type*} {N : ι → ℕ} {q Q : ℕ} + (A : ResidueBoxSlice N q) + (origin : ι → ℝ) (step : ℝ) (hstep : 0 ≤ step) + (T : ι → ℝ) (hT : ∀ i, 0 < T i) (hQ : 0 < Q) + (hparent : ∀ i n, n < N i → |origin i + step * n| ≤ T i) + (hwidth : ∀ i, step * q * A.length i ≤ 2 * T i / Q) : + ∃ z : ι → Fin (Q + 1), ∀ j : ∀ i, Fin (A.length i), ∀ i, + |origin i + step * (A.point j i).val - normalizedRealBoxGrid T Q z i| ≤ + T i * (2 / Q) := by + classical + by_cases hlen : ∀ i, 0 < A.length i + · exact A.exists_affine_normalized_cell hlen origin step hstep T hT hQ hparent hwidth + · push Not at hlen + obtain ⟨i, hi⟩ := hlen + refine ⟨fun _ => ⟨0, Nat.succ_pos _⟩, ?_⟩ + intro j + have hj := (j i).isLt + omega + +end ResidueBoxSlice + +theorem normalized_residue_block_cell {ι : Type*} (N : ι → ℕ) (q Q : ℕ) + (H : ι → ℕ) (hq : 0 < q) (hQ : 0 < Q) (hH : ∀ i, 0 < H i) + (hwidth : ∀ i, (q : ℝ) * H i ≤ (N i : ℝ) / Q) + (origin : ι → ℝ) (step : ℝ) (hstep : 0 ≤ step) + (T : ι → ℝ) (hT : ∀ i, 0 < T i) + (hparent : ∀ i n, n < N i → |origin i + step * n| ≤ T i) + (hparentwidth : ∀ i, step * N i ≤ 2 * T i) + (a : ∀ i, (FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)).Label) : + ∃ z : ι → Fin (Q + 1), + ∀ j : ∀ i, Fin ((ResidueBoxSlice.ofBlocks H hq hH a).length i), ∀ i, + |origin i + step * ((ResidueBoxSlice.ofBlocks H hq hH a).point j i).val - + normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q) := by + apply ResidueBoxSlice.exists_affine_normalized_cell_of_width _ origin step hstep T hT hQ hparent + intro i + have hlen : ((ResidueBoxSlice.ofBlocks H hq hH a).length i : ℝ) ≤ H i := by + exact_mod_cast truncatedProgressionLength_le (N i) (progressionBlockStart (a i)) q (H i) + calc + _ ≤ step * q * H i := mul_le_mul_of_nonneg_left hlen (by positivity) + _ = step * ((q : ℝ) * H i) := by ring + _ ≤ step * ((N i : ℝ) / Q) := mul_le_mul_of_nonneg_left (hwidth i) hstep + _ = (step * N i) / Q := by ring + _ ≤ 2 * T i / Q := div_le_div_of_nonneg_right (hparentwidth i) (Nat.cast_nonneg _) + +theorem exists_normalized_residue_block_cells {ι : Type*} (N : ι → ℕ) (q Q : ℕ) + (hq : 0 < q) (hQ : 0 < Q) + (origin : ι → ℝ) (step : ℝ) (hstep : 0 ≤ step) + (T : ι → ℝ) (hT : ∀ i, 0 < T i) + (hparent : ∀ i n, n < N i → |origin i + step * n| ≤ T i) + (hparentwidth : ∀ i, step * N i ≤ 2 * T i) + (hlarge : ∀ i, 2 * (q : ℝ) ≤ (1 / (Q : ℝ)) * N i) : + ∃ (H : ι → ℕ) (hH : ∀ i, 0 < H i), + (∀ i, q * H i ≤ N i) ∧ + (∀ i, (q : ℝ) * H i ≤ (N i : ℝ) / Q) ∧ + (∀ i, (N i : ℝ) / (2 * q * Q) ≤ H i) ∧ + ∀ a : ∀ i, (FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)).Label, + ∃ z : ι → Fin (Q + 1), + ∀ j : ∀ i, Fin ((ResidueBoxSlice.ofBlocks H hq hH a).length i), ∀ i, + |origin i + step * ((ResidueBoxSlice.ofBlocks H hq hH a).point j i).val - + normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q) := by + have hQr : (0 : ℝ) < Q := Nat.cast_pos.mpr hQ + have hρ : (0 : ℝ) < 1 / Q := by positivity + have hρ1 : (1 : ℝ) / Q ≤ 1 := (div_le_one hQr).mpr (by exact_mod_cast hQ) + obtain ⟨H, hH, hfit, hwidth, hlower⟩ := exists_box_block_mesh N q hq hρ hρ1 hlarge + have hwidth' (i) : (q : ℝ) * H i ≤ (N i : ℝ) / Q := by + calc + _ ≤ (1 / (Q : ℝ)) * N i := hwidth i + _ = _ := by ring + refine ⟨H, hH, hfit, hwidth', ?_, ?_⟩ + · intro i + have he : (1 / (Q : ℝ)) * N i / (2 * q) = (N i : ℝ) / (2 * q * Q) := by ring + rw [← he] + exact hlower i + · exact normalized_residue_block_cell N q Q H hq hQ hH hwidth' + origin step hstep T hT hparent hparentwidth + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedResidueSpatialHaarBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedResidueSpatialHaarBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..7006c07d5ce463c6a93ddd5adc6709ad5a5e4096 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedResidueSpatialHaarBudget.lean @@ -0,0 +1,281 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalSingleSiteCommonCover +import OAI.Combinatorics.Progressions.Lattices.OriginalKernelResidueRetained + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +private theorem variableLengthZeroCube_pi_residue_disintegration + {G : Type*} [Fintype G] [DecidableEq G] + (L : G → ℕ) (q : ℕ) [NeZero q] (hL : ∀ g, 0 < L g) (hq : 0 < q) (hqL : ∀ g, q ≤ L g) + (test : (G → ZMod q) → (∀ g, IntegerScalarCubeBox Empty (L g)) → ℂ) : + (FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun x => test (fun g => ((x g none : ℤ) : ZMod q)) x) = + (FiniteProbabilityWeights.pi (fun g : G => + (integerScalarCubeWeights Empty (L g) (hL g)).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)))).complexMean (fun r => + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL g))).complexMean (test r)) := by + rw [FiniteProbabilityWeights.pi_complexMean_disintegrate + (fun g : G => integerScalarCubeWeights Empty (L g) (hL g)) + (fun _ x => ((x none : ℤ) : ZMod q)) + (fun g r => integerScalarCubeWeights_empty_residue_mass_pos (L g) q (hL g) hq (hqL g) r) test] + apply congrArg (FiniteProbabilityWeights.pi (fun g : G => + (integerScalarCubeWeights Empty (L g) (hL g)).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)))).complexMean + funext r + apply congrArg (fun p : FiniteProbabilityWeights (∀ g, IntegerScalarCubeBox Empty (L g)) => + p.complexMean (test r)) + apply congrArg FiniteProbabilityWeights.pi + funext g + exact integerScalarCubeWeights_empty_residue_condition (L g) q (hL g) hq (hqL g) (r g) + +theorem variableLengthZeroCube_pi_uniform_residue_error + {G : Type*} [Fintype G] [DecidableEq G] + (L : G → ℕ) (q : ℕ) [NeZero q] (hL : ∀ g, 0 < L g) (hq : 0 < q) (hqL : ∀ g, q ≤ L g) + (test : (G → ZMod q) → (∀ g, IntegerScalarCubeBox Empty (L g)) → ℂ) + (hbound : ∀ r x, ‖test r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun x => test (fun g => ((x g none : ℤ) : ZMod q)) x) - + 𝔼 r : G → ZMod q, + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL g))).complexMean (test r)‖ ≤ + ∑ g, (q : ℝ) / L g := by + let μ := fun g => (integerScalarCubeWeights Empty (L g) (hL g)).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)) + let ν := FiniteProbabilityWeights.uniform (ZMod q) + let F (r : G → ZMod q) := + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL g))).complexMean (test r) + have hF (r : G → ZMod q) : ‖F r‖ ≤ 1 := by + apply (FiniteProbabilityWeights.norm_complexMean_le_mean_norm _ _).trans + exact (FiniteProbabilityWeights.mean_mono _ (hbound r)).trans_eq + (FiniteProbabilityWeights.mean_const _ 1) + rw [variableLengthZeroCube_pi_residue_disintegration L q hL hq hqL test, + ← FiniteProbabilityWeights.pi_uniform_complexMean] + exact (FiniteProbabilityWeights.norm_complexMean_sub_le_weight_l1 + (FiniteProbabilityWeights.pi (fun g : G => μ g)) + (FiniteProbabilityWeights.pi (fun _ : G => ν)) F hF).trans + ((FiniteProbabilityWeights.pi_weight_l1_le_sum (fun g : G => μ g) (fun _ : G => ν)).trans + (Finset.sum_le_sum (fun g _ => integerScalarCubeWeights_empty_residue_l1 (L g) q (hL g)))) + +theorem variableLengthZeroCube_residue_slow_quadrature + {G : Type*} [Fintype G] [DecidableEq G] + (L : G → ℕ) (q : ℕ) [NeZero q] + (hL : ∀ g, 0 < L g) (hq : 0 < q) (hqL : ∀ g, q ≤ L g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / L g) < + volume.real (scalarCubeDomain Empty)) + (F : (G → ZMod q) → (G → Option Empty → ℝ) → ℂ) + {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r)) + (hbound : ∀ r x, ‖F r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun z => F (fun g => ((z g none : ℤ) : ZMod q)) + (fun g i => (z g i : ℝ) / L g)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K)) * + (∑ g, (q : ℝ) / L g) := by + let test := fun (r : G → ZMod q) (z : ∀ g, IntegerScalarCubeBox Empty (L g)) => + F r (fun g i => (z g i : ℝ) / L g) + let law := fun (r : G → ZMod q) => FiniteProbabilityWeights.pi + (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) (by simpa using hqL g)) + let e : ℝ := 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K) * (∑ g, (q : ℝ) / L g) + have hcond (r : G → ZMod q) : + ‖(law r).complexMean (test r) - ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by + simpa only [law, test, e, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] using + scalarCubeResidueWeights_pi_complex_riemann L (fun _ => q) hL + (fun (_ : G) (_ : Option Empty) => q) (fun g _ => r g) (fun _ _ => hq) + (fun _ _ => le_rfl) (fun g => by simpa using hqL g) + hsmall (F r) (hF r) zero_le_one (hbound r) + have hmix := variableLengthZeroCube_pi_uniform_residue_error L q hL hq hqL + test (fun r _ => hbound r _) + have havg : ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by + rw [← Finset.expect_sub_distrib] + apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun r _ => hcond r)).trans_eq (by simp) + calc + _ ≤ ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun z => test (fun g => ((z g none : ℤ) : ZMod q)) z) - + 𝔼 r : G → ZMod q, (law r).complexMean (test r)‖ + + ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ := + norm_sub_le_norm_sub_add_norm_sub _ _ _ + _ ≤ (∑ g, (q : ℝ) / L g) + e := add_le_add hmix havg + _ = _ := by dsimp only [e]; ring + +theorem integerBox_residue_spatial_riemann + {X : Type*} [Fintype X] [DecidableEq X] + (N : X → ℕ) (q : ℕ) [NeZero q] + (hN : ∀ i, 0 < N i) (hqN : ∀ i, q ≤ N i) + (hsmall : ∀ i, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / N i) < 1) + (H : (X → ZMod q) → (X → ℝ) → ℂ) {L : ℝ≥0} + (hH : ∀ r, LipschitzWith L (H r)) (hbound : ∀ r x, ‖H r x‖ ≤ 1) : + ‖(𝔼 u ∈ integerBox N, H (fun i => (u i : ZMod q)) + (fun i => (u i : ℝ) / N i)) - + 𝔼 r : X → ZMod q, ∫ x, H r x ∂unitBoxMeasure X‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + L)) * + ∑ i, (q : ℝ) / N i := by + let F := fun (r : X → ZMod q) (x : X → Option Empty → ℝ) => H r (fun i => x i none) + have hproject : LipschitzWith 1 + (fun x : X → Option Empty → ℝ => fun i => x i none) := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro i + exact (dist_le_pi_dist (x i) (y i) none).trans (dist_le_pi_dist x y i) + have hF (r) : LipschitzWith L (F r) := by + simpa only [mul_one, Function.comp_def, F] using (hH r).comp hproject + have he := variableLengthZeroCube_residue_slow_quadrature N q hN (NeZero.pos q) hqN + (fun i => by simpa only [Measure.real, scalarCubeDomain_empty_volume, + ENNReal.toReal_one] using hsmall i) F hF (fun r _ => hbound r _) + have hid (r : X → ZMod q) : + (∫ x, F r x ∂scalarCubeProductMeasure X Empty) = ∫ x, H r x ∂unitBoxMeasure X := by + rw [← scalarCubeProductMeasure_empty_map X] + exact (integral_map + (by fun_prop : Measurable (fun x : X → Option Empty → ℝ => fun i => x i none)).aemeasurable + (hH r).continuous.measurable.aestronglyMeasurable).symm + simp_rw [hid] at he + have hmean := integerScalarCubeWeights_zero_product_complexMean N hN + (fun u => H (fun i => (u i : ZMod q)) (fun i => (u i : ℝ) / N i)) + simpa only [F, hmean, Measure.real, scalarCubeDomain_empty_volume, + ENNReal.toReal_one, div_one] using he + +namespace VectorPolynomial.NormalizedPolynomialTwist + +theorem integerBox_frozenSingleSiteHaarReference_riemann + {X : Type*} [Fintype X] [DecidableEq X] + {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) + (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + {periodCap coverCap : ℝ} {L : ℝ≥0} + (W : NormalizedPolynomialTwist X (Σ j, J j) periodCap coverCap L) [NeZero W.modulus] + (N : X → ℕ) (hN : ∀ i, 0 < N i) (hqN : ∀ i, W.modulus ≤ N i) + (hsmall : ∀ i, scalarCubeGridBoundaryConstant Empty * ((W.modulus : ℝ) / N i) < 1) : + ‖(𝔼 u ∈ integerBox N, W.frozenSingleSiteHaarReference U ν + (fun i => (u i : ZMod W.modulus)) (fun i => (u i : ℝ) / N i)) - + 𝔼 r : X → ZMod W.modulus, ∫ x, W.frozenSingleSiteHaarReference U ν r x + ∂unitBoxMeasure X‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + L)) * + ∑ i, (W.modulus : ℝ) / N i := by + exact integerBox_residue_spatial_riemann N W.modulus hN hqN hsmall + (W.frozenSingleSiteHaarReference U ν) + (W.frozenSingleSiteHaarReference_lipschitz U ν) + (W.norm_frozenSingleSiteHaarReference_le U ν) + +end VectorPolynomial.NormalizedPolynomialTwist +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical NNReal + +theorem normalizedResidueSpatial_budget + {X : Type*} [Fintype X] [DecidableEq X] + (N : X → ℕ) (q : ℕ) (K : ℝ≥0) {P E : ℝ} + (hP : 0 ≤ P) (hE : 0 ≤ E) + (hdim : (Fintype.card X : ℝ) ≤ P) + (hq : (q : ℝ) ≤ Real.exp P) (hK : (K : ℝ) ≤ Real.exp P) + (hN : ∀ i, Real.exp (3 * P + E + 20) ≤ (N i : ℝ)) : + (∀ i, 0 < N i) ∧ (∀ i, q ≤ N i) ∧ + (∀ i, scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / N i) < 1) ∧ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + (K : ℝ))) * + (∑ i, (q : ℝ) / N i) ≤ Real.exp (-E) := by + have hNp (i : X) : (0 : ℝ) < N i := (Real.exp_pos _).trans_le (hN i) + have hqN (i : X) : (q : ℝ) ≤ N i := + hq.trans ((Real.exp_le_exp.mpr (by linarith)).trans (hN i)) + have hmesh (i : X) : (q : ℝ) / N i ≤ Real.exp (-2 * P - E - 20) := by + calc + _ ≤ Real.exp P / Real.exp (3 * P + E + 20) := + div_le_div₀ (Real.exp_nonneg _) hq (Real.exp_pos _) (hN i) + _ = _ := by rw [← Real.exp_sub]; congr 1; ring + have hC : scalarCubeGridBoundaryConstant Empty = 4 := by + norm_num [scalarCubeGridBoundaryConstant] + have hexpP : 1 ≤ Real.exp P := (Real.add_one_le_exp P).trans' (by linarith) + have hpref : 1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty + (K : ℝ)) ≤ + 19 * Real.exp P := by rw [hC]; linarith + have hdimexp : (Fintype.card X : ℝ) ≤ Real.exp P := + hdim.trans (by linarith only [Real.add_one_le_exp P]) + have hsum : (∑ i, (q : ℝ) / N i) ≤ + Real.exp P * Real.exp (-2 * P - E - 20) := by + calc + _ ≤ ∑ _i : X, Real.exp (-2 * P - E - 20) := Finset.sum_le_sum (fun i _ => hmesh i) + _ = (Fintype.card X : ℝ) * Real.exp (-2 * P - E - 20) := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right hdimexp (Real.exp_nonneg _) + refine ⟨fun i => by exact_mod_cast hNp i, fun i => by exact_mod_cast hqN i, ?_, ?_⟩ + · intro i + rw [hC] + calc + 4 * ((q : ℝ) / N i) ≤ 4 * Real.exp (-2 * P - E - 20) := by gcongr; exact hmesh i + _ ≤ 4 * Real.exp (-20) := by gcongr; linarith + _ < 1 := by + rw [Real.exp_neg, ← div_eq_mul_inv, div_lt_one (Real.exp_pos _)] + linarith only [Real.add_one_le_exp 20] + · calc + _ ≤ (19 * Real.exp P) * (Real.exp P * Real.exp (-2 * P - E - 20)) := + mul_le_mul hpref hsum (Finset.sum_nonneg (fun _ _ => div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _))) + (by positivity) + _ = 19 * Real.exp (-E - 20) := by + rw [mul_assoc, ← Real.exp_add, ← Real.exp_add] + congr 2 + ring + _ ≤ Real.exp (-E) := by + rw [Real.exp_sub, ← mul_div_assoc, div_le_iff₀ (Real.exp_pos _)] + exact mul_le_mul_of_nonneg_right (by linarith only [Real.add_one_le_exp 20]) + (Real.exp_nonneg (-E)) |>.trans_eq (mul_comm _ _) + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial.NormalizedPolynomialTwist + +open MeasureTheory +open scoped BigOperators Classical NNReal + +theorem integerBox_frozenSingleSiteHaarReference_riemann_budget + {X : Type*} [Fintype X] [DecidableEq X] + {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) + (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + {periodCap coverCap : ℝ} {L : ℝ≥0} + (W : NormalizedPolynomialTwist X (Σ j, J j) periodCap coverCap L) [NeZero W.modulus] + {P E : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hX : (Fintype.card X : ℝ) ≤ P) + (hL : (L : ℝ) ≤ Real.exp P) (hmod : (W.modulus : ℝ) ≤ Real.exp P) + (N : X → ℕ) (hsize : ∀ i, Real.exp (3 * P + E + 20) ≤ (N i : ℝ)) : + ‖(𝔼 u ∈ integerBox N, W.frozenSingleSiteHaarReference U ν + (fun i => (u i : ZMod W.modulus)) (fun i => (u i : ℝ) / N i)) - + 𝔼 r : X → ZMod W.modulus, ∫ x, W.frozenSingleSiteHaarReference U ν r x + ∂unitBoxMeasure X‖ ≤ Real.exp (-E) := by + obtain ⟨hN, hqN, hsmall, herror⟩ := + normalizedResidueSpatial_budget N W.modulus L hP hE hX hmod hL hsize + exact (W.integerBox_frozenSingleSiteHaarReference_riemann U ν N hN hqN hsmall).trans herror + +end Erdos3.VectorPolynomial.NormalizedPolynomialTwist + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedTwistAffineCells.lean b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedTwistAffineCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..67c0ea35d810f3449601ccdd6381a6db7c399056 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/NormalizedTwistAffineCells.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalSingleSiteCommonCover + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial.NormalizedPolynomialTwist + +open BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {K X : Type*} [Fintype K] [Fintype X] +variable {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable {periodCap coverCap : ℝ} {L : ℝ≥0} + +theorem integerPhysicalSite_local_parameter_dist + (N : X → ℕ) (P : K → ℕ) (hP : ∀ k, 0 < P k) + (frame : Option K × X → ℤ) (u v : K → ℤ) + (C : K → ℝ) (hC : ∀ k, 0 ≤ C k) {η : ℝ} (hη : 0 ≤ η) + (hslope : ∀ k x, |(frame (some k, x) : ℝ) / N x| * P k ≤ C k) + (hcell : ∀ k, |(u k : ℝ) / P k - (v k : ℝ) / P k| ≤ η) : + dist (fun x => (integerPhysicalSite u frame x : ℝ) / N x) + (fun x => (integerPhysicalSite v frame x : ℝ) / N x) ≤ η * ∑ k, C k := by + apply (dist_pi_le_iff (mul_nonneg hη (Finset.sum_nonneg (fun k _ => hC k)))).mpr + intro x + rw [Real.dist_eq] + have heq : (integerPhysicalSite u frame x : ℝ) / N x - + (integerPhysicalSite v frame x : ℝ) / N x = + ∑ k, ((u k : ℝ) / P k - (v k : ℝ) / P k) * + ((frame (some k, x) : ℝ) / N x) * P k := by + simp only [integerPhysicalSite, Int.cast_add, Int.cast_sum, Int.cast_mul, add_div, + Finset.sum_div] + rw [add_sub_add_left_eq_sub, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro k _ + have hk : (P k : ℝ) ≠ 0 := by exact_mod_cast (hP k).ne' + field_simp + rw [heq] + calc + _ ≤ ∑ k, |((u k : ℝ) / P k - (v k : ℝ) / P k) * + ((frame (some k, x) : ℝ) / N x) * P k| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ k, η * C k := by + apply Finset.sum_le_sum + intro k _ + simp only [abs_mul, abs_of_nonneg (Nat.cast_nonneg (P k) : (0 : ℝ) ≤ _), mul_assoc] + exact mul_le_mul (hcell k) (hslope k x) (by positivity) hη + _ = _ := (Finset.mul_sum _ _ _).symm + +omit [Fintype X] in + +theorem integerPhysicalSite_residue_of_parameter_residue + (q : ℕ) (frame : Option K × X → ℤ) (u v : K → ℤ) + (hcell : ∀ k, (u k : ZMod q) = (v k : ZMod q)) : + (fun x => (integerPhysicalSite u frame x : ZMod q)) = + (fun x => (integerPhysicalSite v frame x : ZMod q)) := by + funext x + simp only [integerPhysicalSite, Int.cast_add, Int.cast_sum, Int.cast_mul, hcell] + +theorem eval_local_parameter_freezing [IsEmpty (Σ j, J j)] + (W : NormalizedPolynomialTwist X (Σ j, J j) periodCap coverCap L) + (N : X → ℕ) (P : K → ℕ) (hP : ∀ k, 0 < P k) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (frame : Option K × X → ℤ) (u v : K → ℤ) + (C : K → ℝ) (hC : ∀ k, 0 ≤ C k) {η : ℝ} (hη : 0 ≤ η) + (hslope : ∀ k x, |(frame (some k, x) : ℝ) / N x| * P k ≤ C k) + (hcell : ∀ k, |(u k : ℝ) / P k - (v k : ℝ) / P k| ≤ η) + (hres : ∀ k, (u k : ZMod W.modulus) = (v k : ZMod W.modulus)) : + ‖W.eval N poly (integerPhysicalSite u frame) - + W.eval N poly (integerPhysicalSite v frame)‖ ≤ (L : ℝ) * η * ∑ k, C k := by + have hu : physicalGridFactorInput W.cover poly + (fun x => (integerPhysicalSite u frame x : ℝ)) = 0 := Subsingleton.elim _ _ + have hv : physicalGridFactorInput W.cover poly + (fun x => (integerPhysicalSite v frame x : ℝ)) = 0 := Subsingleton.elim _ _ + have hres' := integerPhysicalSite_residue_of_parameter_residue W.modulus frame u v hres + have he := W.frozenTorus_spatial_error + (fun x => (integerPhysicalSite v frame x : ZMod W.modulus)) + (fun x => (integerPhysicalSite u frame x : ℝ) / N x) + (fun x => (integerPhysicalSite v frame x : ℝ) / N x) 0 + simp only [eval, hu, hv, hres'] + refine he.trans ?_ + exact (mul_le_mul_of_nonneg_left + (integerPhysicalSite_local_parameter_dist N P hP frame u v C hC hη hslope hcell) + L.coe_nonneg).trans_eq (by ring) + +theorem correlation_after_freezing {T : Type*} [Fintype T] + (μ : FiniteProbabilityWeights T) (twist signal : T → ℂ) (c : ℂ) + (hc : ‖c‖ ≤ 1) (hsignal : ∀ t, ‖signal t‖ ≤ 1) + {ε δ : ℝ} (hfreeze : ∀ t, μ.weight t ≠ 0 → ‖twist t - c‖ ≤ ε) + (hbias : δ ≤ ‖μ.complexMean (fun t => star (twist t) * signal t)‖) : + δ - ε ≤ ‖μ.complexMean signal‖ := by + have he := μ.norm_complexMean_sub_le + (fun t => star (twist t) * signal t) (fun t => star c * signal t) + (fun _ => ε) (fun t ht => by + rw [← sub_mul, ← star_sub, norm_mul, norm_star] + exact (mul_le_mul (hfreeze t ht) (hsignal t) (norm_nonneg _) (by + exact (norm_nonneg _).trans (hfreeze t ht))).trans_eq (mul_one _)) + rw [μ.mean_const] at he + have hconst : μ.complexMean (fun t => star c * signal t) = star c * μ.complexMean signal := by + simp only [FiniteProbabilityWeights.complexMean, Finset.mul_sum] + congr 1 + funext t + ring + have hb : ‖μ.complexMean (fun t => star c * signal t)‖ ≤ ‖μ.complexMean signal‖ := by + rw [hconst, norm_mul, norm_star] + exact (mul_le_mul_of_nonneg_right hc (norm_nonneg _)).trans_eq (one_mul _) + have ht := norm_le_norm_sub_add + (μ.complexMean (fun t => star (twist t) * signal t)) + (μ.complexMean (fun t => star c * signal t)) + linarith + +end Erdos3.VectorPolynomial.NormalizedPolynomialTwist + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/OriginalKernelResidueRetained.lean b/lean/OAI/Combinatorics/Progressions/Lattices/OriginalKernelResidueRetained.lean new file mode 100644 index 0000000000000000000000000000000000000000..29349e52ea80d645f279cd10405ee5b64ff707ae --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/OriginalKernelResidueRetained.lean @@ -0,0 +1,796 @@ +import Mathlib.MeasureTheory.Integral.Prod +import OAI.Combinatorics.Progressions.Estimates.FiniteProductWeightL1 +import OAI.Combinatorics.Progressions.Geometry.PrincipalCoefficientPositiveSupport +import OAI.Combinatorics.Progressions.Linear.KernelProductFiber + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem intervalUniformWeights_residue_weight (a b : ℤ) (hab : a < b) + (q : ℕ) [NeZero q] (v : ℤ) : + ((intervalUniformWeights a b hab).fiberLaw + (fun x => ((x : ℤ) : ZMod q))).weight (v : ZMod q) = + ((Finset.filter (fun x => x ≡ v [ZMOD (q : ℤ)]) + (Finset.Ico a b)).card : ℝ) / ((b - a : ℤ) : ℝ) := by + simp only [FiniteProbabilityWeights.fiberLaw, FiniteProbabilityWeights.fiberMean] + simp only [ZMod.intCast_eq_intCast_iff] + rw [intervalUniformWeights_mean] + exact @integerInterval_indicator_expect a b hab.le + (fun x : ℤ => x ≡ v [ZMOD (q : ℤ)]) (fun _ => Int.instDecidableModEq) + +theorem intervalUniformWeights_residue_weight_error (a b : ℤ) (hab : a < b) + (q : ℕ) [NeZero q] (r : ZMod q) : + |((intervalUniformWeights a b hab).fiberLaw + (fun x => ((x : ℤ) : ZMod q))).weight r - 1 / (q : ℝ)| ≤ + 1 / ((b - a : ℤ) : ℝ) := by + have hL : (0 : ℝ) < ((b - a : ℤ) : ℝ) := by exact_mod_cast sub_pos.mpr hab + have hq : (0 : ℤ) < q := by exact_mod_cast NeZero.pos q + have hr : (((r.val : ℕ) : ℤ) : ZMod q) = r := by simp + rw [← hr, intervalUniformWeights_residue_weight] + have hc := scalarResidue_card_absolute_error a b q r.val hab.le hq + have heq : + ((Finset.filter (fun x => x ≡ (r.val : ℤ) [ZMOD (q : ℤ)]) + (Finset.Ico a b)).card : ℝ) / ((b - a : ℤ) : ℝ) - 1 / (q : ℝ) = + (((Finset.filter (fun x => x ≡ (r.val : ℤ) [ZMOD (q : ℤ)]) + (Finset.Ico a b)).card : ℝ) - ((b - a : ℤ) : ℝ) / (q : ℝ)) / + ((b - a : ℤ) : ℝ) := by + field_simp + rw [heq, abs_div, abs_of_pos hL] + exact div_le_div_of_nonneg_right (by simpa only [Int.cast_natCast] using hc) hL.le + +theorem intervalUniformWeights_residue_l1_error (a b : ℤ) (hab : a < b) + (q : ℕ) [NeZero q] : + (∑ r : ZMod q, |((intervalUniformWeights a b hab).fiberLaw + (fun x => ((x : ℤ) : ZMod q))).weight r - 1 / (q : ℝ)|) ≤ + (q : ℝ) / ((b - a : ℤ) : ℝ) := by + calc + _ ≤ ∑ _r : ZMod q, 1 / ((b - a : ℤ) : ℝ) := by + exact Finset.sum_le_sum (fun r _ => intervalUniformWeights_residue_weight_error a b hab q r) + _ = _ := by simp [ZMod.card, div_eq_mul_inv] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +theorem scalarCubeResidueWeights_pi_complex_riemann {G I : Type*} + [Fintype G] [DecidableEq G] [Fintype I] [DecidableEq I] + (L M : G → ℕ) (hL : ∀ g, 0 < L g) (m : G → Option I → ℕ) + (r : ∀ g i, ZMod (m g i)) (hm : ∀ g i, 0 < m g i) + (hmM : ∀ g i, m g i ≤ M g) + (hsize : ∀ g, (Fintype.card I + 1) * M g ≤ L g) + (hsmall : ∀ g, scalarCubeGridBoundaryConstant I * ((M g : ℝ) / L g) < + volume.real (scalarCubeDomain I)) + (φ : (G → Option I → ℝ) → ℂ) {K : ℝ≥0} {B : ℝ} + (hφ : LipschitzWith K φ) (hB : 0 ≤ B) (hb : ∀ x, ‖φ x‖ ≤ B) : + ‖(FiniteProbabilityWeights.pi (fun g => scalarCubeResidueWeights I (L g) (M g) (hL g) + (m g) (r g) (hm g) (hmM g) (hsize g))).complexMean + (fun z => φ (fun g i => (z g i : ℝ) / L g)) - + ∫ x, φ x ∂scalarCubeProductMeasure G I‖ ≤ + 2 * (2 * B * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + K) * + ∑ g, (M g : ℝ) / L g := by + have hreLip : LipschitzWith K (fun x => (φ x).re) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [Real.dist_eq, ← Complex.sub_re] + exact (Complex.abs_re_le_norm _).trans + (by simpa only [dist_eq_norm] using hφ.dist_le_mul x y) + have himLip : LipschitzWith K (fun x => (φ x).im) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [Real.dist_eq, ← Complex.sub_im] + exact (Complex.abs_im_le_norm _).trans + (by simpa only [dist_eq_norm] using hφ.dist_le_mul x y) + have hre := scalarCubeResidueWeights_pi_riemann L M hL m r hm hmM hsize hsmall + (fun x => (φ x).re) hreLip hB + (fun x => (Complex.abs_re_le_norm _).trans (hb x)) + have him := scalarCubeResidueWeights_pi_riemann L M hL m r hm hmM hsize hsmall + (fun x => (φ x).im) himLip hB + (fun x => (Complex.abs_im_le_norm _).trans (hb x)) + have hi : Integrable φ (scalarCubeProductMeasure G I) := + Integrable.mono' (integrable_const B) hφ.continuous.measurable.aestronglyMeasurable + (Filter.Eventually.of_forall hb) + have hire : (∫ x, φ x ∂scalarCubeProductMeasure G I).re = + ∫ x, (φ x).re ∂scalarCubeProductMeasure G I := by + simpa only [RCLike.re_eq_complex_re] using (integral_re hi).symm + have hiim : (∫ x, φ x ∂scalarCubeProductMeasure G I).im = + ∫ x, (φ x).im ∂scalarCubeProductMeasure G I := by + simpa only [RCLike.im_eq_complex_im] using (integral_im hi).symm + apply (Complex.norm_le_abs_re_add_abs_im _).trans + have h := add_le_add hre him + simpa only [Complex.sub_re, Complex.sub_im, FiniteProbabilityWeights.complexMean_re, + FiniteProbabilityWeights.complexMean_im, hire, hiim, ← two_mul, mul_assoc] using h + +variable {G I : Type*} [Fintype G] [DecidableEq G] [Fintype I] [DecidableEq I] + +theorem kernelResidue_joint_complex_riemann (L q : ℕ) (hL : 0 < L) (hq : 0 < q) + (r : G → Option I → ZMod q) + (hsize : (Fintype.card I + 1) * q ≤ L) + (hsmall : scalarCubeGridBoundaryConstant I * ((q : ℝ) / L) < + volume.real (scalarCubeDomain I)) + (F : (G → Option I → ZMod q) → (G → Option I → ℝ) → ℂ) + {K : ℝ≥0} {B : ℝ} (hF : LipschitzWith K (F r)) + (hB : 0 ≤ B) (hbound : ∀ x, ‖F r x‖ ≤ B) : + ‖(FiniteProbabilityWeights.pi (fun g => scalarCubeResidueWeights I L q hL + (fun _ => q) (r g) (fun _ => hq) (fun _ => le_rfl) hsize)).complexMean + (fun z => F (fun g i => ((z g i : ℤ) : ZMod q)) + (fun g i => (z g i : ℝ) / L)) - + ∫ x, F r x ∂scalarCubeProductMeasure G I‖ ≤ + 2 * (2 * B * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + K) * + (Fintype.card G * ((q : ℝ) / L)) := by + have he := (FiniteProbabilityWeights.pi (fun g => scalarCubeResidueWeights I L q hL + (fun _ => q) (r g) (fun _ => hq) (fun _ => le_rfl) hsize)).complexMean_congr_support + (f := fun z => F (fun g i => ((z g i : ℤ) : ZMod q)) (fun g i => (z g i : ℝ) / L)) + (g := fun z => F r (fun g i => (z g i : ℝ) / L)) (by + intro z hz + have hr := scalarCubeResiduePi_support (fun _ : G => L) (fun _ => q) (fun _ => hL) + (fun _ _ => q) r (fun _ _ => hq) (fun _ _ => le_rfl) (fun _ => hsize) z hz + rw [show (fun g i => ((z g i : ℤ) : ZMod q)) = r from funext (fun g => funext (hr g))]) + rw [he] + simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using + scalarCubeResidueWeights_pi_complex_riemann (fun _ : G => L) (fun _ => q) (fun _ => hL) + (fun _ _ => q) r (fun _ _ => hq) (fun _ _ => le_rfl) (fun _ => hsize) + (fun _ => hsmall) (F r) hF hB hbound + +theorem kernelResidue_polynomial_complex_riemann (L q : ℕ) (hL : 0 < L) (hq : 0 < q) + (r : G → Option I → ZMod q) + (hsize : (Fintype.card I + 1) * q ≤ L) + (hsmall : scalarCubeGridBoundaryConstant I * ((q : ℝ) / L) < + volume.real (scalarCubeDomain I)) + {Out : Type*} (poly : Out → MvPolynomial (G × Option I) ℤ) + (φ : (Out → ZMod q) → (G → Option I → ℝ) → ℂ) + {K : ℝ≥0} {B : ℝ} (hφ : ∀ v, LipschitzWith K (φ v)) + (hB : 0 ≤ B) (hbound : ∀ v x, ‖φ v x‖ ≤ B) : + ‖(FiniteProbabilityWeights.pi (fun g => scalarCubeResidueWeights I L q hL + (fun _ => q) (r g) (fun _ => hq) (fun _ => le_rfl) hsize)).complexMean + (fun z => φ (fun o => ((MvPolynomial.eval (fun a => (z a.1 a.2 : ℤ)) (poly o) : ℤ) : ZMod q)) + (fun g i => (z g i : ℝ) / L)) - + ∫ x, φ (fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (fun a => r a.1 a.2) (poly o)) x ∂scalarCubeProductMeasure G I‖ ≤ + 2 * (2 * B * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + K) * + (Fintype.card G * ((q : ℝ) / L)) := by + let F := fun (v : G → Option I → ZMod q) => + φ (fun o => MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) + (fun a => v a.1 a.2) (poly o)) + have h := kernelResidue_joint_complex_riemann L q hL hq r hsize hsmall + F (hφ _) hB (hbound _) + have heval (p : MvPolynomial (G × Option I) ℤ) (v : G × Option I → ℤ) : + ((MvPolynomial.eval v p : ℤ) : ZMod q) = + MvPolynomial.eval₂ (Int.castRingHom (ZMod q)) (fun a => (v a : ZMod q)) p := + integerPolynomial_eval_residue p q v + simpa only [F, heval] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +variable {K T γ : ℝ} (hK : 0 < K) (hT : 0 < T) (hγ : 0 < γ) +variable (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ (γ / 2) * (K / T)) +variable (q : ℕ) (hq : 0 < q) (r : ZMod q) +variable (hlength : scalarCubeNormalizationThreshold Empty q 32 + (256 * probabilityProfileLipschitz) ≤ principalIntervalLength K T γ) + +include hK hT hγ hlarge in +theorem principalCoefficientResidue_normalizer_lower : + let hs := scalarCubeNormalizationThreshold_spec Empty hlength + 1 / 2 ≤ (scalarCubeResidueWeights Empty (principalIntervalLength K T γ) q hs.1 + (fun _ => q) (fun _ => r) (fun _ => hq) (fun _ => le_rfl) hs.2.1).mean + (fun z => principalIntervalWeight K T γ + (fun i => (z i : ℝ) / principalIntervalLength K T γ)) := by + let L := principalIntervalLength K T γ + let w := principalIntervalWeight K T γ + have hs := scalarCubeNormalizationThreshold_spec Empty hlength + have hw := principalIntervalWeight_range hK hT hγ hlarge + have hLip := principalIntervalWeight_lipschitz hK hT hγ hlarge + have ht : (q : ℝ) * scalarCubeRiemannAllowance Empty 16 + (128 * probabilityProfileLipschitz) / (1 / 4) ≤ L := by + convert hs.2.2.2 using 1 + simp only [scalarCubeRiemannAllowance, NNReal.coe_mul, NNReal.coe_ofNat] + ring + have hb (x) : ‖w x‖ ≤ (16 : ℝ) := by + rw [Real.norm_of_nonneg (hw x).1] + exact (hw x).2 + have hr := scalarCubeResidueWeights_riemann_of_length Empty L q hs.1 + (fun _ => q) (fun _ => r) (fun _ => hq) (fun _ => le_rfl) hs.2.1 w hLip + (by norm_num : (0 : ℝ) ≤ 16) hb (by norm_num : (0 : ℝ) < 1 / 4) + hs.2.2.1 ht + have h1 := scalarCubeResidueWeights_riemann_of_length Empty L q hs.1 + (fun _ => 1) (fun _ => 0) (fun _ => by norm_num) (fun _ => hq) hs.2.1 w hLip + (by norm_num : (0 : ℝ) ≤ 16) hb (by norm_num : (0 : ℝ) < 1 / 4) + hs.2.2.1 ht + have hn : (scalarCubeResidueWeights Empty L q hs.1 (fun _ => 1) (fun _ => 0) + (fun _ => by norm_num) (fun _ => hq) hs.2.1).mean + (fun z => w (fun i => (z i : ℝ) / L)) = 1 := + (principalNormalizedSource hK hT hγ hlarge).normalized + rw [hn] at h1 + have h1' := (abs_le.mp h1).2 + have hr' := (abs_le.mp hr).1 + dsimp only + linarith + +noncomputable def principalCoefficientResidueSource : NormalizedScalarCubeSource Empty := + normalizedScalarCubeSourceOfWeight Empty (principalIntervalLength K T γ) q + (scalarCubeNormalizationThreshold_spec Empty hlength).1 (fun _ => q) (fun _ => r) + (fun _ => hq) (fun _ => le_rfl) + (scalarCubeNormalizationThreshold_spec Empty hlength).2.1 + (principalIntervalWeight K T γ) 16 (128 * probabilityProfileLipschitz) (by norm_num) + (principalIntervalWeight_range hK hT hγ hlarge) + (principalIntervalWeight_lipschitz hK hT hγ hlarge) + (principalCoefficientResidue_normalizer_lower hK hT hγ hlarge q hq r hlength) + +theorem principalCoefficientResidueSource_primitive (A : ℝ≥0) : + ScalarCubePrimitiveBudget + (principalCoefficientResidueSource hK hT hγ hlarge q hq r hlength) A + (scalarCubePrimitiveEnvelope Empty A 32 (256 * probabilityProfileLipschitz) q) := by + apply scalarCubePrimitiveBudget_of_raw_bounds _ A 32 (256 * probabilityProfileLipschitz) q + · exact le_rfl + · norm_num [principalCoefficientResidueSource, normalizedScalarCubeSourceOfWeight] + · change 2 * (128 * probabilityProfileLipschitz) ≤ 256 * probabilityProfileLipschitz + simp only [← mul_assoc] + norm_num + +private theorem weights_ext {X : Type*} [Fintype X] {p q : FiniteProbabilityWeights X} + (h : ∀ x, p.weight x = q.weight x) : p = q := by + cases p + cases q + congr 1 + exact funext h + +private theorem residue_one_eq_uniform (L : ℕ) (hL : 0 < L) (hsize : 1 ≤ L) : + scalarCubeResidueWeights Empty L 1 hL (fun _ => 1) (fun _ => 0) + (fun _ => by norm_num) (fun _ => le_rfl) (by simpa using hsize) = + integerScalarCubeWeights Empty L hL := by + classical + let p := integerScalarCubeWeights Empty L hL + have hr : scalarCubeResidueSet Empty L (fun _ => 1) (fun _ => 0) = Finset.univ := by + apply Finset.eq_univ_iff_forall.mpr + intro z + apply (mem_scalarCubeResidueSet L (fun _ => 1) (fun _ => 0) z).mpr + intro i + exact Subsingleton.elim _ _ + have hm : p.mass Finset.univ = 1 := p.total + apply weights_ext + intro z + change (p.condition _ _).weight z = p.weight z + simp only [FiniteProbabilityWeights.condition, hr, Finset.mem_univ, ite_true, hm, div_one] + +private theorem principalSource_baseLaw : + (principalNormalizedSource hK hT hγ hlarge).baseLaw = + integerScalarCubeWeights Empty (principalIntervalLength K T γ) + (principalIntervalLength_pos hK hT hγ) := + residue_one_eq_uniform _ _ (Nat.succ_le_iff.mpr (principalIntervalLength_pos hK hT hγ)) + +private theorem reweight_mass_eq {X : Type*} [Fintype X] [DecidableEq X] + (p : FiniteProbabilityWeights X) (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (hn : p.mean w = 1) (G : Finset X) (hG : 0 < p.mass G) : + (p.reweight w hw hn).mass G = p.mass G * (p.condition G hG).mean w := by + rw [FiniteProbabilityWeights.mass_mul_condition_mean] + simp [FiniteProbabilityWeights.mass, FiniteProbabilityWeights.mean, + FiniteProbabilityWeights.reweight, mul_ite] + +private theorem reweight_condition_weight {X : Type*} [Fintype X] [DecidableEq X] + (p : FiniteProbabilityWeights X) (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (hn : p.mean w = 1) (G : Finset X) (hG : 0 < p.mass G) + (hGw : 0 < (p.reweight w hw hn).mass G) (z : X) : + (p.condition G hG).weight z * (w z / (p.condition G hG).mean w) = + ((p.reweight w hw hn).condition G hGw).weight z := by + simp only [FiniteProbabilityWeights.condition] + rw [reweight_mass_eq p w hw hn G hG] + by_cases hz : z ∈ G + · simp only [hz, ite_true, FiniteProbabilityWeights.reweight] + change p.weight z / p.mass G * (w z / (p.condition G hG).mean w) = + (p.weight z * w z) / (p.mass G * (p.condition G hG).mean w) + ring + · simp only [hz, ite_false, zero_div, zero_mul] + +include hq hlength in +theorem principalCoefficientResidue_mass_pos : + 0 < (principalNormalizedSource hK hT hγ hlarge).source.mass + (scalarCubeResidueSet Empty (principalIntervalLength K T γ) + (fun _ => q) (fun _ => r)) := by + let s := principalNormalizedSource hK hT hγ hlarge + let G := scalarCubeResidueSet Empty (principalIntervalLength K T γ) + (fun _ => q) (fun _ => r) + have hs := scalarCubeNormalizationThreshold_spec Empty hlength + have hG := scalarCubeResidue_mass_pos Empty (principalIntervalLength K T γ) q hs.1 + (fun _ => q) (fun _ => r) (fun _ => hq) (fun _ => le_rfl) hs.2.1 + have hGb : 0 < s.baseLaw.mass G := by + rw [principalSource_baseLaw] + exact hG + have he := reweight_mass_eq s.baseLaw _ (fun z => (s.weight_range _).1) s.normalized G hGb + change s.source.mass G = _ at he + rw [he] + apply mul_pos hGb + have hz := principalCoefficientResidue_normalizer_lower hK hT hγ hlarge q hq r hlength + have hz' : 1 / 2 ≤ (s.baseLaw.condition G hGb).mean + (fun z => s.weight (fun i => (z i : ℝ) / s.length)) := by + simp only [s, principalSource_baseLaw] + exact hz + linarith + +theorem principalCoefficientResidueSource_law : + (principalCoefficientResidueSource hK hT hγ hlarge q hq r hlength).source = + (principalNormalizedSource hK hT hγ hlarge).source.condition + (scalarCubeResidueSet Empty (principalIntervalLength K T γ) + (fun _ => q) (fun _ => r)) + (principalCoefficientResidue_mass_pos hK hT hγ hlarge q hq r hlength) := by + classical + let s := principalNormalizedSource hK hT hγ hlarge + let G := scalarCubeResidueSet Empty (principalIntervalLength K T γ) + (fun _ => q) (fun _ => r) + have hs := scalarCubeNormalizationThreshold_spec Empty hlength + have hG := scalarCubeResidue_mass_pos Empty (principalIntervalLength K T γ) q hs.1 + (fun _ => q) (fun _ => r) (fun _ => hq) (fun _ => le_rfl) hs.2.1 + have hGb : 0 < s.baseLaw.mass G := by + rw [principalSource_baseLaw] + exact hG + let w := fun z : IntegerScalarCubeBox Empty s.length => + s.weight (fun i => (z i : ℝ) / s.length) + have hp : scalarCubeResidueWeights Empty (principalIntervalLength K T γ) q hs.1 + (fun _ => q) (fun _ => r) (fun _ => hq) (fun _ => le_rfl) hs.2.1 = + s.baseLaw.condition G hGb := by + simp only [s, principalSource_baseLaw] + rfl + apply weights_ext (X := IntegerScalarCubeBox Empty (principalIntervalLength K T γ)) + intro z + have hsour : + (principalCoefficientResidueSource hK hT hγ hlarge q hq r hlength).source.weight z = + (scalarCubeResidueWeights Empty (principalIntervalLength K T γ) q hs.1 + (fun _ => q) (fun _ => r) (fun _ => hq) (fun _ => le_rfl) hs.2.1).weight z * + (w z / (scalarCubeResidueWeights Empty (principalIntervalLength K T γ) q hs.1 + (fun _ => q) (fun _ => r) (fun _ => hq) (fun _ => le_rfl) hs.2.1).mean w) := rfl + rw [hsour, hp] + exact reweight_condition_weight s.baseLaw w (fun z => (s.weight_range _).1) s.normalized G hGb + (principalCoefficientResidue_mass_pos hK hT hγ hlarge q hq r hlength) z + +theorem principalCoefficientResidueSource_positive_support + (z : IntegerScalarCubeBox Empty + (principalCoefficientResidueSource hK hT hγ hlarge q hq r hlength).length) + (hz : (principalCoefficientResidueSource hK hT hγ hlarge q hq r hlength).source.weight z ≠ 0) : + ((principalCoefficientResidueSource hK hT hγ hlarge q hq r hlength).length : ℝ) / 4 ≤ + (z none : ℝ) := by + apply principalNormalizedSource_positive_support hK hT hγ hlarge z + rw [principalCoefficientResidueSource_law] at hz + intro he + apply hz + simp [FiniteProbabilityWeights.condition, he] + +open scoped Classical + +theorem scalarCubeResidueSet_empty_eq_filter (L q : ℕ) (r : ZMod q) : + scalarCubeResidueSet Empty L (fun _ => q) (fun _ => r) = + Finset.univ.filter (fun z : IntegerScalarCubeBox Empty L => ((z none : ℤ) : ZMod q) = r) := by + ext z + simp only [mem_scalarCubeResidueSet, Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · exact fun h => h none + · intro h i + cases i with + | none => exact h + | some e => exact e.elim + +include hq hlength in +theorem principalCoefficientResidue_mass_pos_filter : + 0 < (principalNormalizedSource hK hT hγ hlarge).source.mass + (Finset.filter (α := IntegerScalarCubeBox Empty (principalIntervalLength K T γ)) + (fun z => + ((z none : ℤ) : ZMod q) = r) Finset.univ) := by + have hf : Finset.filter (α := IntegerScalarCubeBox Empty (principalIntervalLength K T γ)) + (fun z => + ((z none : ℤ) : ZMod q) = r) Finset.univ = + scalarCubeResidueSet Empty (principalIntervalLength K T γ) (fun _ => q) (fun _ => r) := by + ext z + simp only [Finset.mem_filter, Finset.mem_univ, true_and, mem_scalarCubeResidueSet] + constructor + · intro h a + cases a with + | none => exact h + | some a => exact a.elim + · exact fun h => h none + rw [hf] + exact principalCoefficientResidue_mass_pos hK hT hγ hlarge q hq r hlength + +theorem principalCoefficientResidueSource_law_filter : + (principalCoefficientResidueSource hK hT hγ hlarge q hq r hlength).source = + (principalNormalizedSource hK hT hγ hlarge).source.condition + (Finset.filter (α := IntegerScalarCubeBox Empty (principalIntervalLength K T γ)) + (fun z => + ((z none : ℤ) : ZMod q) = r) Finset.univ) + (principalCoefficientResidue_mass_pos_filter hK hT hγ hlarge q hq r hlength) := by + have hf : Finset.filter (α := IntegerScalarCubeBox Empty (principalIntervalLength K T γ)) + (fun z => + ((z none : ℤ) : ZMod q) = r) Finset.univ = + scalarCubeResidueSet Empty (principalIntervalLength K T γ) (fun _ => q) (fun _ => r) := by + ext z + simp only [Finset.mem_filter, Finset.mem_univ, true_and, mem_scalarCubeResidueSet] + constructor + · intro h a + cases a with + | none => exact h + | some a => exact a.elim + · exact fun h => h none + simpa only [hf] using principalCoefficientResidueSource_law hK hT hγ hlarge q hq r hlength + +namespace VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) (j : Fin m) (i : Fin (n j)) +variable (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) +variable (hlong : scalarCubeNormalizationThreshold Empty q 32 + (256 * probabilityProfileLipschitz) ≤ + (allocatedPrincipalNormalizedSource B U basis hR S j i hactive).length) + +noncomputable def allocatedPrincipalCoefficientResidueSource : NormalizedScalarCubeSource Empty := + principalCoefficientResidueSource + (K := (basisAxisScale (basis j) i : ℝ)) (T := (S.value : ℝ) ^ (j.val + 1)) + (γ := principalProfileSize (R j) (Finset.card (layerIntegerPrincipalSlots (G := G) B j i))) + (by exact_mod_cast basisAxisScale_pos (basis j) i) + (pow_pos (by exact_mod_cast S.positive) _) + (principalProfileSize_pos (hR j) _) + (integerAxisPrincipal_width (Nat.zero_lt_succ _) S.positive + (principalProfileSize_pos (hR j) _) (S.gap j i hactive)) q hq r hlong + +include hq hlong in +theorem allocatedPrincipalCoefficientResidue_mass_pos : + 0 < (allocatedPrincipalNormalizedSource B U basis hR S j i hactive).source.mass + (Finset.univ.filter (fun z => ((z none : ℤ) : ZMod q) = r)) := + principalCoefficientResidue_mass_pos_filter _ _ _ _ q hq r hlong + +theorem allocatedPrincipalCoefficientResidueSource_law : + (allocatedPrincipalCoefficientResidueSource q hq r B U basis hR S j i hactive hlong).source = + (allocatedPrincipalNormalizedSource B U basis hR S j i hactive).source.condition + (Finset.univ.filter (fun z => ((z none : ℤ) : ZMod q) = r)) + (allocatedPrincipalCoefficientResidue_mass_pos q hq r B U basis hR S j i hactive hlong) := + principalCoefficientResidueSource_law_filter _ _ _ _ q hq r hlong + +theorem allocatedPrincipalCoefficientResidueSource_primitive (A : ℝ≥0) : + ScalarCubePrimitiveBudget + (allocatedPrincipalCoefficientResidueSource q hq r B U basis hR S j i hactive hlong) A + (scalarCubePrimitiveEnvelope Empty A 32 (256 * probabilityProfileLipschitz) q) := + principalCoefficientResidueSource_primitive _ _ _ _ q hq r hlong A + +theorem allocatedPrincipalCoefficientResidueSource_positive_support + (z : IntegerScalarCubeBox Empty + (allocatedPrincipalCoefficientResidueSource q hq r B U basis hR S j i hactive hlong).length) + (hz : (allocatedPrincipalCoefficientResidueSource q hq r B U basis hR S j i hactive hlong).source.weight z ≠ 0) : + ((allocatedPrincipalCoefficientResidueSource q hq r B U basis hR S j i hactive hlong).length : ℝ) / 4 ≤ + (z none : ℝ) := + principalCoefficientResidueSource_positive_support _ _ _ _ q hq r hlong z hz + +end VectorPolynomial + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerScalarCubeWeights_empty_residue_law (L q : ℕ) (hL : 0 < L) + [NeZero q] : + (integerScalarCubeWeights Empty L hL).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)) = + (intervalUniformWeights 0 (L : ℤ) (by exact_mod_cast hL)).fiberLaw + (fun x => (x.val : ZMod q)) := by + apply FiniteProbabilityWeights.ext_weight + funext r + simpa only [FiniteProbabilityWeights.fiberLaw, FiniteProbabilityWeights.fiberMean] using + integerScalarCubeWeights_zero_mean Empty L hL + (fun z => if (z : ZMod q) = r then 1 else 0) + +theorem integerScalarCubeWeights_empty_residue_mass_pos + (L q : ℕ) (hL : 0 < L) (hq : 0 < q) (hqL : q ≤ L) (r : ZMod q) : + 0 < (integerScalarCubeWeights Empty L hL).mass + (Finset.univ.filter (fun x => ((x none : ℤ) : ZMod q) = r)) := by + rw [← scalarCubeResidueSet_empty_eq_filter] + exact scalarCubeResidue_mass_pos Empty L q hL (fun _ => q) (fun _ => r) + (fun _ => hq) (fun _ => le_rfl) (by simpa using hqL) + +theorem integerScalarCubeWeights_empty_residue_condition + (L q : ℕ) (hL : 0 < L) (hq : 0 < q) (hqL : q ≤ L) (r : ZMod q) : + (integerScalarCubeWeights Empty L hL).condition + (Finset.univ.filter (fun x => ((x none : ℤ) : ZMod q) = r)) + (integerScalarCubeWeights_empty_residue_mass_pos L q hL hq hqL r) = + scalarCubeResidueWeights Empty L q hL (fun _ => q) (fun _ => r) + (fun _ => hq) (fun _ => le_rfl) (by simpa using hqL) := by + unfold scalarCubeResidueWeights + congr 1 + exact (scalarCubeResidueSet_empty_eq_filter L q r).symm + +theorem integerScalarCubeWeights_empty_residue_l1 + (L q : ℕ) (hL : 0 < L) [NeZero q] : + (∑ r : ZMod q, + |((integerScalarCubeWeights Empty L hL).fiberLaw + (fun x => ((x none : ℤ) : ZMod q))).weight r - + (FiniteProbabilityWeights.uniform (ZMod q)).weight r|) ≤ (q : ℝ) / L := by + rw [integerScalarCubeWeights_empty_residue_law] + simpa only [FiniteProbabilityWeights.uniform, ZMod.card, one_div, Int.cast_sub, + Int.cast_natCast, Int.cast_zero, sub_zero] using + intervalUniformWeights_residue_l1_error 0 L (by exact_mod_cast hL) q + +theorem integerScalarCubeWeights_empty_pi_residue_disintegration + {G : Type*} [Fintype G] [DecidableEq G] + (L q : ℕ) [NeZero q] (hL : 0 < L) (hq : 0 < q) (hqL : q ≤ L) + (test : (G → ZMod q) → (G → IntegerScalarCubeBox Empty L) → ℂ) : + (FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty L hL)).complexMean + (fun x => test (fun g => ((x g none : ℤ) : ZMod q)) x) = + (FiniteProbabilityWeights.pi (fun _ : G => + (integerScalarCubeWeights Empty L hL).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)))).complexMean (fun r => + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty L q hL + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL))).complexMean (test r)) := by + rw [FiniteProbabilityWeights.pi_complexMean_disintegrate + (fun _ : G => integerScalarCubeWeights Empty L hL) + (fun _ x => ((x none : ℤ) : ZMod q)) + (fun _ r => integerScalarCubeWeights_empty_residue_mass_pos L q hL hq hqL r) test] + apply congrArg (FiniteProbabilityWeights.pi (fun _ : G => + (integerScalarCubeWeights Empty L hL).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)))).complexMean + funext r + apply congrArg (fun p : FiniteProbabilityWeights (G → IntegerScalarCubeBox Empty L) => + p.complexMean (test r)) + apply congrArg FiniteProbabilityWeights.pi + funext g + exact integerScalarCubeWeights_empty_residue_condition L q hL hq hqL (r g) + +theorem integerScalarCubeWeights_empty_pi_uniform_residue_error + {G : Type*} [Fintype G] [DecidableEq G] + (L q : ℕ) [NeZero q] (hL : 0 < L) (hq : 0 < q) (hqL : q ≤ L) + (test : (G → ZMod q) → (G → IntegerScalarCubeBox Empty L) → ℂ) + (hbound : ∀ r x, ‖test r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty L hL)).complexMean + (fun x => test (fun g => ((x g none : ℤ) : ZMod q)) x) - + 𝔼 r : G → ZMod q, + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty L q hL + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL))).complexMean (test r)‖ ≤ + (Fintype.card G : ℝ) * ((q : ℝ) / L) := by + let μ := (integerScalarCubeWeights Empty L hL).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)) + let ν := FiniteProbabilityWeights.uniform (ZMod q) + let F (r : G → ZMod q) := + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty L q hL + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL))).complexMean (test r) + have hF (r : G → ZMod q) : ‖F r‖ ≤ 1 := by + apply (FiniteProbabilityWeights.norm_complexMean_le_mean_norm _ _).trans + exact (FiniteProbabilityWeights.mean_mono _ (hbound r)).trans_eq + (FiniteProbabilityWeights.mean_const _ 1) + rw [integerScalarCubeWeights_empty_pi_residue_disintegration L q hL hq hqL test, + ← FiniteProbabilityWeights.pi_uniform_complexMean] + exact (FiniteProbabilityWeights.norm_complexMean_sub_le_weight_l1 + (FiniteProbabilityWeights.pi (fun _ : G => μ)) + (FiniteProbabilityWeights.pi (fun _ : G => ν)) F hF).trans + ((FiniteProbabilityWeights.pi_weight_l1_le_sum (fun _ : G => μ) (fun _ : G => ν)).trans + ((Finset.sum_le_sum (fun _ _ => integerScalarCubeWeights_empty_residue_l1 L q hL)).trans_eq + (by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +variable {G : Type*} [Fintype G] [DecidableEq G] + +theorem originalKernel_residue_slow_quadrature (L q : ℕ) [NeZero q] + (hL : 0 < L) (hq : 0 < q) (hqL : q ≤ L) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / L) < + volume.real (scalarCubeDomain Empty)) + (F : (G → ZMod q) → (G → Option Empty → ℝ) → ℂ) + {K : ℝ≥0} (hF : ∀ r, LipschitzWith K (F r)) + (hbound : ∀ r x, ‖F r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty L hL)).complexMean + (fun z => F (fun g => ((z g none : ℤ) : ZMod q)) + (fun g i => (z g i : ℝ) / L)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K)) * + (Fintype.card G * ((q : ℝ) / L)) := by + let test := fun (r : G → ZMod q) (z : G → IntegerScalarCubeBox Empty L) => + F r (fun g i => (z g i : ℝ) / L) + let law := fun (r : G → ZMod q) => FiniteProbabilityWeights.pi + (fun g : G => scalarCubeResidueWeights Empty L q hL + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) (by simpa using hqL)) + let e : ℝ := 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K) * (Fintype.card G * ((q : ℝ) / L)) + have hcond (r : G → ZMod q) : + ‖(law r).complexMean (test r) - ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by + simpa only [law, test, e, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] using + scalarCubeResidueWeights_pi_complex_riemann (fun _ : G => L) (fun _ => q) (fun _ => hL) + (fun (_ : G) (_ : Option Empty) => q) (fun g _ => r g) (fun _ _ => hq) + (fun _ _ => le_rfl) (fun _ => by simpa using hqL) + (fun _ => hsmall) (F r) (hF r) zero_le_one (hbound r) + have hmix := integerScalarCubeWeights_empty_pi_uniform_residue_error L q hL hq hqL + test (fun r z => hbound r _) + have havg : ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ ≤ e := by + rw [← Finset.expect_sub_distrib] + apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun r _ => hcond r)).trans_eq (by simp) + calc + _ ≤ ‖(FiniteProbabilityWeights.pi (fun _ : G => integerScalarCubeWeights Empty L hL)).complexMean + (fun z => test (fun g => ((z g none : ℤ) : ZMod q)) z) - + 𝔼 r : G → ZMod q, (law r).complexMean (test r)‖ + + ‖(𝔼 r : G → ZMod q, (law r).complexMean (test r)) - + 𝔼 r : G → ZMod q, ∫ x, F r x ∂scalarCubeProductMeasure G Empty‖ := + norm_sub_le_norm_sub_add_norm_sub _ _ _ + _ ≤ (Fintype.card G * ((q : ℝ) / L)) + e := add_le_add hmix havg + _ = _ := by dsimp only [e]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem integerScalarCubeWeights_empty_pi_residue_disintegration_varying + {G : Type*} [Fintype G] [DecidableEq G] + (L : G → ℕ) (q : ℕ) [NeZero q] (hL : ∀ g, 0 < L g) (hq : 0 < q) (hqL : ∀ g, q ≤ L g) + (test : (G → ZMod q) → (∀ g, IntegerScalarCubeBox Empty (L g)) → ℂ) : + (FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun x => test (fun g => ((x g none : ℤ) : ZMod q)) x) = + (FiniteProbabilityWeights.pi (fun g : G => + (integerScalarCubeWeights Empty (L g) (hL g)).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)))).complexMean (fun r => + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL g))).complexMean (test r)) := by + rw [FiniteProbabilityWeights.pi_complexMean_disintegrate + (fun g : G => integerScalarCubeWeights Empty (L g) (hL g)) + (fun _ x => ((x none : ℤ) : ZMod q)) + (fun g r => integerScalarCubeWeights_empty_residue_mass_pos (L g) q (hL g) hq (hqL g) r) test] + apply congrArg (FiniteProbabilityWeights.pi (fun g : G => + (integerScalarCubeWeights Empty (L g) (hL g)).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)))).complexMean + funext r + apply congrArg (fun p : FiniteProbabilityWeights (∀ g, IntegerScalarCubeBox Empty (L g)) => + p.complexMean (test r)) + apply congrArg FiniteProbabilityWeights.pi + funext g + exact integerScalarCubeWeights_empty_residue_condition (L g) q (hL g) hq (hqL g) (r g) + +theorem integerScalarCubeWeights_empty_pi_uniform_residue_error_varying + {G : Type*} [Fintype G] [DecidableEq G] + (L : G → ℕ) (q : ℕ) [NeZero q] (hL : ∀ g, 0 < L g) (hq : 0 < q) (hqL : ∀ g, q ≤ L g) + (test : (G → ZMod q) → (∀ g, IntegerScalarCubeBox Empty (L g)) → ℂ) + (hbound : ∀ r x, ‖test r x‖ ≤ 1) : + ‖(FiniteProbabilityWeights.pi (fun g : G => integerScalarCubeWeights Empty (L g) (hL g))).complexMean + (fun x => test (fun g => ((x g none : ℤ) : ZMod q)) x) - + 𝔼 r : G → ZMod q, + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL g))).complexMean (test r)‖ ≤ + ∑ g, (q : ℝ) / L g := by + let μ := fun g => (integerScalarCubeWeights Empty (L g) (hL g)).fiberLaw + (fun x => ((x none : ℤ) : ZMod q)) + let ν := FiniteProbabilityWeights.uniform (ZMod q) + let F (r : G → ZMod q) := + (FiniteProbabilityWeights.pi (fun g : G => scalarCubeResidueWeights Empty (L g) q (hL g) + (fun _ => q) (fun _ => r g) (fun _ => hq) (fun _ => le_rfl) + (by simpa using hqL g))).complexMean (test r) + have hF (r : G → ZMod q) : ‖F r‖ ≤ 1 := by + apply (FiniteProbabilityWeights.norm_complexMean_le_mean_norm _ _).trans + exact (FiniteProbabilityWeights.mean_mono _ (hbound r)).trans_eq + (FiniteProbabilityWeights.mean_const _ 1) + rw [integerScalarCubeWeights_empty_pi_residue_disintegration_varying L q hL hq hqL test, + ← FiniteProbabilityWeights.pi_uniform_complexMean] + exact (FiniteProbabilityWeights.norm_complexMean_sub_le_weight_l1 + (FiniteProbabilityWeights.pi (fun g : G => μ g)) + (FiniteProbabilityWeights.pi (fun _ : G => ν)) F hF).trans + ((FiniteProbabilityWeights.pi_weight_l1_le_sum (fun g : G => μ g) (fun _ : G => ν)).trans + (Finset.sum_le_sum (fun g _ => integerScalarCubeWeights_empty_residue_l1 (L g) q (hL g)))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical NNReal + +theorem originalKernel_residue_slow_retained_quadrature + {G Z : Type*} [Fintype G] [DecidableEq G] [MeasurableSpace Z] + (μ : Measure Z) [IsProbabilityMeasure μ] + (L q : ℕ) [NeZero q] (hL : 0 < L) (hq : 0 < q) (hqL : q ≤ L) + (hsmall : scalarCubeGridBoundaryConstant Empty * ((q : ℝ) / L) < + volume.real (scalarCubeDomain Empty)) + (F : Z → (G → ZMod q) → (G → Option Empty → ℝ) → ℂ) + (hMeas : ∀ r, Measurable (fun zx : Z × (G → Option Empty → ℝ) => F zx.1 r zx.2)) + {K : ℝ≥0} (hLip : ∀ z r, LipschitzWith K (F z r)) + (hbound : ∀ z r x, ‖F z r x‖ ≤ 1) : + ‖(∫ z, (FiniteProbabilityWeights.pi + (fun _ : G => integerScalarCubeWeights Empty L hL)).complexMean + (fun y => F z (fun g => ((y g none : ℤ) : ZMod q)) + (fun g i => (y g i : ℝ) / L)) ∂μ) - + ∫ z, 𝔼 r : G → ZMod q, + ∫ x, F z r x ∂scalarCubeProductMeasure G Empty ∂μ‖ ≤ + (1 + 2 * (2 * scalarCubeGridBoundaryConstant Empty / + volume.real (scalarCubeDomain Empty) + K)) * + (Fintype.card G * ((q : ℝ) / L)) := by + let p := FiniteProbabilityWeights.pi + (fun _ : G => integerScalarCubeWeights Empty L hL) + let a (z : Z) := p.complexMean + (fun y => F z (fun g => ((y g none : ℤ) : ZMod q)) + (fun g i => (y g i : ℝ) / L)) + let b (z : Z) := 𝔼 r : G → ZMod q, + ∫ x, F z r x ∂scalarCubeProductMeasure G Empty + have haMeas : Measurable a := by + unfold a FiniteProbabilityWeights.complexMean + apply Finset.measurable_sum + intro y _ + exact measurable_const.mul ((hMeas _).comp (measurable_id.prodMk measurable_const)) + have haBound (z : Z) : ‖a z‖ ≤ 1 := by + apply (p.norm_complexMean_le_mean_norm _).trans + exact (p.mean_mono (fun y => hbound z _ _)).trans_eq (p.mean_const 1) + have haInt : Integrable a μ := + (integrable_const (1 : ℝ)).mono' haMeas.aestronglyMeasurable (ae_of_all μ haBound) + have hiMeas (r : G → ZMod q) : + StronglyMeasurable (fun z => ∫ x, F z r x ∂scalarCubeProductMeasure G Empty) := + (hMeas r).stronglyMeasurable.integral_prod_right' + have hiBound (z : Z) (r : G → ZMod q) : + ‖∫ x, F z r x ∂scalarCubeProductMeasure G Empty‖ ≤ 1 := by + simpa only [probReal_univ, mul_one] using + norm_integral_le_of_norm_le_const + (ae_of_all (scalarCubeProductMeasure G Empty) (hbound z r)) + have hbMeas : Measurable b := by + unfold b + simp only [Fintype.expect_eq_sum_div_card] + apply Measurable.div_const + exact Finset.measurable_sum _ (fun r _ => (hiMeas r).measurable) + have hbBound (z : Z) : ‖b z‖ ≤ 1 := by + apply (RCLike.norm_expect_le (K := ℂ)).trans + exact (Finset.expect_le_expect (fun r _ => hiBound z r)).trans_eq (by simp) + have hbInt : Integrable b μ := + (integrable_const (1 : ℝ)).mono' hbMeas.aestronglyMeasurable (ae_of_all μ hbBound) + change ‖(∫ z, a z ∂μ) - ∫ z, b z ∂μ‖ ≤ _ + rw [← integral_sub haInt hbInt] + have he := ae_of_all μ (fun z => + originalKernel_residue_slow_quadrature L q hL hq hqL hsmall + (F z) (hLip z) (hbound z)) + simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const he + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ParametricFullResidueCoveredExtension.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ParametricFullResidueCoveredExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b75e6166dbbf37e165c7ef39193e289593b6f11 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ParametricFullResidueCoveredExtension.lean @@ -0,0 +1,240 @@ +import OAI.Combinatorics.Progressions.Estimates.LayeredCoverSiteExtension + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule +open scoped Classical NNReal Matrix + +theorem exists_normalized_full_residue_map + {D E : Type*} [Fintype D] [Fintype E] {n : ℕ} + (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis E ℤ (latticeSection (standardEuclideanLattice D) W)) + (b : Basis (Fin n) ℝ Wᗮ) + (hb : span ℤ (Set.range b) = projectedIntegerLattice W) (q : ℕ) [NeZero q] : + ∃ r : (D → ZMod q) → (Fin n ⊕ E → ZMod q), + ∀ (z : Fin n → ℤ) (w : E → ℤ), + r (fun i => (latticeDeckInteger W bW b hb z w i : ZMod q)) = + Sum.elim (fun i => (z i : ZMod q)) (fun i => (w i : ZMod q)) := by + obtain ⟨A, _hA, hres⟩ := standardLatticeCoordinates_residue W bW b hb q + refine ⟨fun a => integerResidueMatrix A q *ᵥ a, ?_⟩ + intro z w + change integerResidueMatrix A q *ᵥ + integerResidueMap D q (latticeDeckInteger W bW b hb z w) = _ + rw [← hres, latticeDeckInteger_coordinates] + funext i + cases i <;> rfl + +theorem exists_layered_full_residue_extension + {M : Type*} [Fintype M] {D E : M → Type*} + [∀ j, Fintype (D j)] [∀ j, DecidableEq (D j)] [∀ j, Fintype (E j)] {n : M → ℕ} + (W : ∀ j, Submodule ℝ (EuclideanSpace ℝ (D j))) + (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (D j)) (W j))) + (b : ∀ j, Basis (Fin (n j)) ℝ (W j)ᗮ) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (W j)) + (q : ℕ) [NeZero q] + (f : (∀ j, Fin (n j) ⊕ E j → ZMod q) → ((Σ j, D j) → ℝ) → ℂ) + (L B : ℝ≥0) (hf : ∀ a, LipschitzWith L (f a)) (hbound : ∀ a v, ‖f a v‖ ≤ B) : + ∃ g : ((Σ j, D j) → UnitAddCircle) → ℂ, + LipschitzWith (2 * max (L * q) (4 * B * q)) g ∧ (∀ y, ‖g y‖ ≤ 2 * B) ∧ + ∀ (x : ∀ j, W j × (Fin (n j) → ℤ)) (w : ∀ j, E j → ℤ), + (∀ j i, |normalizedLatticePoint (W j) (b j) (x j) i| ≤ 1 / 4) → + g (fun a => (((normalizedLatticeRepresentative (W a.1) (b a.1) (hb a.1) (x a.1) + + ((bW a.1).equivFun.symm (w a.1)).val).val a.2 / q : ℝ) : UnitAddCircle)) = + f (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => (w j i : ZMod q))) + (fun a => normalizedLatticePoint (W a.1) (b a.1) (x a.1) a.2) := by + choose r hr using (fun j => exists_normalized_full_residue_map (W j) (bW j) (b j) (hb j) q) + let label : ((Σ j, D j) → ZMod q) → (∀ j, Fin (n j) ⊕ E j → ZMod q) := + fun a j => r j (fun i => a ⟨j, i⟩) + obtain ⟨g, hg, hgb, hvalue⟩ := exists_integer_quarter_cover_extension q + (fun a v => f (label a) v) L B (fun a => hf (label a)) (fun a v => hbound (label a) v) + refine ⟨g, hg, hgb, ?_⟩ + intro x w hx + let β : (Σ j, D j) → ℤ := fun a => + latticeDeckInteger (W a.1) (bW a.1) (b a.1) (hb a.1) (x a.1).2 (w a.1) a.2 + let v : (Σ j, D j) → ℝ := fun a => normalizedLatticePoint (W a.1) (b a.1) (x a.1) a.2 + have hlabel : label (fun a => (β a : ZMod q)) = + fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => (w j i : ZMod q)) := by + funext j + exact hr j (x j).2 (w j) + have h := hvalue β v (fun a => hx a.1 a.2) + rw [hlabel] at h + have hpoint : (fun a => ((((β a : ℝ) + v a) / q : ℝ) : UnitAddCircle)) = + fun a => (((normalizedLatticeRepresentative (W a.1) (b a.1) (hb a.1) (x a.1) + + ((bW a.1).equivFun.symm (w a.1)).val).val a.2 / q : ℝ) : UnitAddCircle) := by + funext a + have he := congrArg (fun z : EuclideanSpace ℝ (D a.1) => z a.2) + (normalizedDeckPoint_identity (W a.1) (bW a.1) (b a.1) (hb a.1) (x a.1) (w a.1)) + change (normalizedLatticeRepresentative (W a.1) (b a.1) (hb a.1) (x a.1) + + ((bW a.1).equivFun.symm (w a.1)).val).val a.2 = v a + (β a : ℝ) at he + rw [he, add_comm (β a : ℝ)] + simpa only [hpoint] using h + +end Erdos3 + +end + +section + +namespace Erdos3 +open Module Submodule +open scoped Classical NNReal + +theorem intCast_eq_residue_val_of_dvd {q d : ℕ} [NeZero d] + (hqd : q ∣ d) (z : ℤ) (r : ZMod d) (hz : (z : ZMod d) = r) : + (z : ZMod q) = (r.val : ZMod q) := by + rw [← Int.cast_natCast] + apply (ZMod.intCast_eq_intCast_iff z (r.val : ℤ) q).mpr + apply Int.ModEq.of_dvd (Int.natCast_dvd_natCast.mpr hqd) + apply (ZMod.intCast_eq_intCast_iff z (r.val : ℤ) d).mp + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using hz + +theorem exists_layered_full_residue_covered_extension + {M : Type*} [Fintype M] {D E : M → Type*} + [∀ j, Fintype (D j)] [∀ j, DecidableEq (D j)] [∀ j, Fintype (E j)] {n : M → ℕ} + (W : ∀ j, Submodule ℝ (EuclideanSpace ℝ (D j))) + (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (D j)) (W j))) + (b : ∀ j, Basis (Fin (n j)) ℝ (W j)ᗮ) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (W j)) + (q d : ℕ) [NeZero q] [NeZero d] (hqd : q ∣ d) + (f : (∀ j, Fin (n j) ⊕ E j → ZMod q) → ((Σ j, D j) → ℝ) → ℂ) + (L B : ℝ≥0) (hf : ∀ a, LipschitzWith L (f a)) (hbound : ∀ a v, ‖f a v‖ ≤ B) : + ∃ g : ((Σ j, D j) → UnitAddCircle) → ℂ, + LipschitzWith (2 * max (L * q) (4 * B * q)) g ∧ (∀ y, ‖g y‖ ≤ 2 * B) ∧ + ∀ (u : ∀ j, W j) (x : ∀ j, W j × (Fin (n j) → ℤ)) (r : ∀ j, E j → ZMod d), + (∀ j, (QuotientAddGroup.mk ((d : ℝ)⁻¹ • u j) : W j ⧸ + (latticeSection (standardEuclideanLattice (D j)) (W j)).toAddSubgroup) = + normalizedCoveredChart (W j) (b j) (hb j) (bW j) d (x j, r j)) → + (∀ j i, |normalizedLatticePoint (W j) (b j) (x j) i| ≤ 1 / 4) → + g (fun a => (((u a.1).val a.2 / q : ℝ) : UnitAddCircle)) = + f (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => ((r j i).val : ZMod q))) + (fun a => normalizedLatticePoint (W a.1) (b a.1) (x a.1) a.2) := by + obtain ⟨g, hg, hgb, hvalue⟩ := exists_layered_full_residue_extension W bW b hb q f L B hf hbound + refine ⟨g, hg, hgb, ?_⟩ + intro u x r hu hx + choose w hw hr using (fun j => + exists_covered_representative_offset (W j) (bW j) (b j) (hb j) d + ((d : ℝ)⁻¹ • u j) (x j) (r j) (hu j)) + have hd : (d : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne d) + simp only [smul_smul, mul_inv_cancel₀ hd, one_smul] at hw + have he : (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => (w j i : ZMod q))) = + (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => ((r j i).val : ZMod q))) := by + funext j i + cases i with + | inl i => rfl + | inr i => exact intCast_eq_residue_val_of_dvd hqd (w j i) (r j i) (congrFun (hr j) i) + simpa only [hw, he] using hvalue x w hx + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule +open scoped Classical NNReal Matrix + +theorem exists_parametric_layered_full_residue_extension + {Y : Type*} [PseudoMetricSpace Y] + {M : Type*} [Fintype M] {D E : M → Type*} + [∀ j, Fintype (D j)] [∀ j, DecidableEq (D j)] [∀ j, Fintype (E j)] {n : M → ℕ} + (W : ∀ j, Submodule ℝ (EuclideanSpace ℝ (D j))) + (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (D j)) (W j))) + (b : ∀ j, Basis (Fin (n j)) ℝ (W j)ᗮ) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (W j)) + (q : ℕ) [NeZero q] + (f : (∀ j, Fin (n j) ⊕ E j → ZMod q) → Y × ((Σ j, D j) → ℝ) → ℂ) + (L B : ℝ≥0) (hf : ∀ a, LipschitzWith L (f a)) (hbound : ∀ a v, ‖f a v‖ ≤ B) : + ∃ g : Y × ((Σ j, D j) → UnitAddCircle) → ℂ, + LipschitzWith (2 * max (L * max 1 (q : ℝ≥0)) (4 * B * q)) g ∧ (∀ y, ‖g y‖ ≤ 2 * B) ∧ + ∀ (y : Y) (x : ∀ j, W j × (Fin (n j) → ℤ)) (w : ∀ j, E j → ℤ), + (∀ j i, |normalizedLatticePoint (W j) (b j) (x j) i| ≤ 1 / 4) → + g (y, fun a => (((normalizedLatticeRepresentative (W a.1) (b a.1) (hb a.1) (x a.1) + + ((bW a.1).equivFun.symm (w a.1)).val).val a.2 / q : ℝ) : UnitAddCircle)) = + f (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => (w j i : ZMod q))) + (y, fun a => normalizedLatticePoint (W a.1) (b a.1) (x a.1) a.2) := by + choose r hr using (fun j => exists_normalized_full_residue_map (W j) (bW j) (b j) (hb j) q) + let label : ((Σ j, D j) → ZMod q) → (∀ j, Fin (n j) ⊕ E j → ZMod q) := + fun a j => r j (fun i => a ⟨j, i⟩) + obtain ⟨g, hg, hgb, hvalue⟩ := exists_parametric_integer_quarter_cover_extension q + (fun a v => f (label a) v) L B (fun a => hf (label a)) (fun a v => hbound (label a) v) + refine ⟨g, hg, hgb, ?_⟩ + intro y x w hx + let β : (Σ j, D j) → ℤ := fun a => + latticeDeckInteger (W a.1) (bW a.1) (b a.1) (hb a.1) (x a.1).2 (w a.1) a.2 + let v : (Σ j, D j) → ℝ := fun a => normalizedLatticePoint (W a.1) (b a.1) (x a.1) a.2 + have hlabel : label (fun a => (β a : ZMod q)) = + fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => (w j i : ZMod q)) := by + funext j + exact hr j (x j).2 (w j) + have h := hvalue β y v (fun a => hx a.1 a.2) + rw [hlabel] at h + have hpoint : (fun a => ((((β a : ℝ) + v a) / q : ℝ) : UnitAddCircle)) = + fun a => (((normalizedLatticeRepresentative (W a.1) (b a.1) (hb a.1) (x a.1) + + ((bW a.1).equivFun.symm (w a.1)).val).val a.2 / q : ℝ) : UnitAddCircle) := by + funext a + have he := congrArg (fun z : EuclideanSpace ℝ (D a.1) => z a.2) + (normalizedDeckPoint_identity (W a.1) (bW a.1) (b a.1) (hb a.1) (x a.1) (w a.1)) + change (normalizedLatticeRepresentative (W a.1) (b a.1) (hb a.1) (x a.1) + + ((bW a.1).equivFun.symm (w a.1)).val).val a.2 = v a + (β a : ℝ) at he + rw [he, add_comm (β a : ℝ)] + simpa only [hpoint] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule +open scoped Classical NNReal + +theorem exists_parametric_layered_full_residue_covered_extension + {Y : Type*} [PseudoMetricSpace Y] + {M : Type*} [Fintype M] {D E : M → Type*} + [∀ j, Fintype (D j)] [∀ j, DecidableEq (D j)] [∀ j, Fintype (E j)] {n : M → ℕ} + (W : ∀ j, Submodule ℝ (EuclideanSpace ℝ (D j))) + (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (D j)) (W j))) + (b : ∀ j, Basis (Fin (n j)) ℝ (W j)ᗮ) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (W j)) + (q d : ℕ) [NeZero q] [NeZero d] (hqd : q ∣ d) + (f : (∀ j, Fin (n j) ⊕ E j → ZMod q) → Y × ((Σ j, D j) → ℝ) → ℂ) + (L B : ℝ≥0) (hf : ∀ a, LipschitzWith L (f a)) (hbound : ∀ a v, ‖f a v‖ ≤ B) : + ∃ g : Y × ((Σ j, D j) → UnitAddCircle) → ℂ, + LipschitzWith (2 * max (L * max 1 (q : ℝ≥0)) (4 * B * q)) g ∧ (∀ y, ‖g y‖ ≤ 2 * B) ∧ + ∀ (y : Y) (u : ∀ j, W j) (x : ∀ j, W j × (Fin (n j) → ℤ)) (r : ∀ j, E j → ZMod d), + (∀ j, (QuotientAddGroup.mk ((d : ℝ)⁻¹ • u j) : W j ⧸ + (latticeSection (standardEuclideanLattice (D j)) (W j)).toAddSubgroup) = + normalizedCoveredChart (W j) (b j) (hb j) (bW j) d (x j, r j)) → + (∀ j i, |normalizedLatticePoint (W j) (b j) (x j) i| ≤ 1 / 4) → + g (y, fun a => (((u a.1).val a.2 / q : ℝ) : UnitAddCircle)) = + f (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => ((r j i).val : ZMod q))) + (y, fun a => normalizedLatticePoint (W a.1) (b a.1) (x a.1) a.2) := by + obtain ⟨g, hg, hgb, hvalue⟩ := exists_parametric_layered_full_residue_extension W bW b hb q f L B hf hbound + refine ⟨g, hg, hgb, ?_⟩ + intro y u x r hu hx + choose w hw hr using (fun j => + exists_covered_representative_offset (W j) (bW j) (b j) (hb j) d + ((d : ℝ)⁻¹ • u j) (x j) (r j) (hu j)) + have hd : (d : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne d) + simp only [smul_smul, mul_inv_cancel₀ hd, one_smul] at hw + have he : (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => (w j i : ZMod q))) = + (fun j => Sum.elim (fun i => ((x j).2 i : ZMod q)) (fun i => ((r j i).val : ZMod q))) := by + funext j i + cases i with + | inl i => rfl + | inr i => exact intCast_eq_residue_val_of_dvd hqd (w j i) (r j i) (congrFun (hr j) i) + simpa only [hw, he] using hvalue y x w hx + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PartitionedAffineLogEnvelope.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PartitionedAffineLogEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2983a0a7d23868b02d6e6440d5f3a0b1c54788e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PartitionedAffineLogEnvelope.lean @@ -0,0 +1,857 @@ +import OAI.Combinatorics.Progressions.Estimates.RetainedSlicedCoefficientSource +import OAI.Combinatorics.Progressions.Estimates.UniformProfileRadiusLog + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators NNReal + +noncomputable def canonicalAffineMinorLog (O α : Type*) [Fintype O] [Fintype α] + (h : ℕ) (P E F : ℝ) : ℝ := + canonicalBooleanMinorLog O α h P E + + (cubeMinorVariableCount O α h * cubeMinorDegree O h : ℕ) * + (cubeMinorVariableCount O α h : ℝ) * F + + theorem canonicalAffineMinorLog_nonneg (O α : Type*) [Fintype O] [Fintype α] + (h : ℕ) {P E F : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : + 0 ≤ canonicalAffineMinorLog O α h P E F := + add_nonneg (canonicalBooleanMinorLog_nonneg O α h hP hE) (by positivity) + + theorem canonicalAffineCubeMinorThreshold_inverse_le_exp (O α : Type*) + [Fintype O] [Nonempty O] [Fintype α] [DecidableEq α] + (h : ℕ) (hh : 0 < h) {c₀ δ η P E F : ℝ} + (hc₀ : 0 < c₀) (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) + (hP : 0 ≤ P) (hE : 0 ≤ E) + (hcP : c₀⁻¹ ≤ Real.exp P) (hηE : η⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) : + (canonicalAffineCubeMinorThreshold O α h c₀ δ η)⁻¹ ≤ Real.exp (canonicalAffineMinorLog O α h P E F) := by + have hkpos := canonicalAffineCubeMinorThreshold_pos O α hh hc₀ hδ hη + have hbasepos := canonicalCubeMinorThreshold_pos Unit O α hh hc₀ hη + have hbase : (canonicalCubeMinorThreshold Unit O α h c₀ η)⁻¹ ≤ + Real.exp (canonicalBooleanMinorLog O α h P E) := by + simpa only [Fintype.card_unique, canonicalBooleanMinorLog] using + canonicalCubeMinorThreshold_inverse_le_exp Unit O α h hh hc₀ hη hP hE hcP hηE + have hsame : canonicalAffineCubeMinorThreshold O α h c₀ 1 η = + canonicalCubeMinorThreshold Unit O α h c₀ η := by + simp only [canonicalAffineCubeMinorThreshold, canonicalCubeMinorThreshold, + affineCubeMinorThreshold, cubeMinorThreshold, inv_one, one_pow, mul_one] + have hlbase := Real.log_le_log (inv_pos.mpr hbasepos) hbase + rw [Real.log_exp] at hlbase + have hlδ := Real.log_le_log (inv_pos.mpr hδ) hδF + rw [Real.log_exp] at hlδ + have he := canonicalAffineCubeMinorThreshold_log_inv_relative O α hh hc₀ hδ hδone hη + rw [hsame] at he + have hb : Real.log (canonicalAffineCubeMinorThreshold O α h c₀ δ η)⁻¹ ≤ + canonicalAffineMinorLog O α h P E F := by + apply he.trans + exact add_le_add hlbase (mul_le_mul_of_nonneg_left hlδ (by positivity)) + simpa only [Real.exp_log (inv_pos.mpr hkpos)] using Real.exp_le_exp.mpr hb + +noncomputable def jointAffineInverseLog {D α : Type*} [Fintype D] [Fintype α] + {O : D → Type*} [∀ d, Fintype (O d)] (h : D → ℕ) (P E F : ℝ) : ℝ := + Fintype.card D + ∑ d, (F + productMinorInverseLog (Fintype.card (O d)) (Fintype.card α) (h d) P + (canonicalAffineMinorLog (O d) α (h d) P E F)) + + theorem jointAffineInverseLog_nonneg {D α : Type*} [Fintype D] [Fintype α] + {O : D → Type*} [∀ d, Fintype (O d)] (h : D → ℕ) {P E F : ℝ} + (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : + 0 ≤ jointAffineInverseLog (O := O) (α := α) h P E F := by + apply add_nonneg (Nat.cast_nonneg _) + apply Finset.sum_nonneg + intro d _ + have hk := canonicalAffineMinorLog_nonneg (O d) α (h d) hP hE hF + unfold productMinorInverseLog productMinorEntryLog + positivity + + theorem jointAffineBooleanInverseBudget_le_exp {D α : Type*} + [Fintype D] [Fintype α] [DecidableEq α] + {O : D → Type*} [∀ d, Fintype (O d)] [∀ d, Nonempty (O d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (c₀ C η : D → ℝ) + (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) (hη : ∀ d, 0 < η d) + {δ P E F : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hcP : ∀ d, (c₀ d)⁻¹ ≤ Real.exp P) (hCP : ∀ d, C d ≤ Real.exp P) + (hηE : ∀ d, (η d)⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) : + (jointAffineBooleanInverseBudget (O := O) (α := α) h C + (fun d => canonicalAffineCubeMinorThreshold (O d) α (h d) (c₀ d) δ (η d)) δ : ℝ) ≤ + Real.exp (jointAffineInverseLog (O := O) (α := α) h P E F) := by + unfold jointAffineBooleanInverseBudget jointAffineInverseLog + rw [NNReal.coe_sum] + apply sum_le_exp_card_add_sum + · intro d + have hk := canonicalAffineMinorLog_nonneg (O d) α (h d) hP hE hF + unfold productMinorInverseLog productMinorEntryLog + positivity + · intro d + apply coe_toNNReal_le_exp + have hb := productMinorInverseBound_le_exp (Fintype.card (O d)) (Fintype.card α) (h d) (hC d) + (canonicalAffineCubeMinorThreshold_pos (O d) α (hh d) (hc₀ d) hδ (hη d)) (hCP d) + (canonicalAffineCubeMinorThreshold_inverse_le_exp (O d) α (h d) (hh d) + (hc₀ d) hδ hδone (hη d) hP hE (hcP d) (hηE d) hδF) + calc + _ ≤ Real.exp F * Real.exp _ := mul_le_mul hδF hb + (productMinorInverseBound_nonneg _ _ _ (hC d) zero_le_one + (canonicalAffineCubeMinorThreshold_pos (O d) α (hh d) (hc₀ d) hδ (hη d)).le) + (Real.exp_pos F).le + _ = _ := (Real.exp_add _ _).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +noncomputable def affineBooleanAxisWeightLog (B O α : Type*) [Fintype B] [Fintype O] [Fintype α] + (h : ℕ) (P E F : ℝ) : ℝ := + (scalarCubeDerivativeLog (Fintype.card α) P+2*Fintype.card (B × Fin h)+E+1)+ + (Fintype.card (BlockParameter B (Fin h) α)+P+canonicalAffineMinorLog O α h P E F+ + productMinorDeterminantLog (Fintype.card (BlockParameter B (Fin h) α)) + (Fintype.card O) (Fintype.card α) h P)+1 + +noncomputable def jointAffineBooleanWeightLog {D α : Type*} [Fintype D] [Fintype α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + (h : D → ℕ) (P E F : ℝ) : ℝ := + Fintype.card D + ∑ d, affineBooleanAxisWeightLog (B d) (O d) α (h d) P E F + +noncomputable def affineBooleanAxisWeightCost (B O α : Type*) [Fintype B] [Fintype O] + [Fintype α] [DecidableEq α] (h : ℕ) (C : ℝ) (A T : ℝ≥0) (c₀ δ η : ℝ) : ℝ := + (∑ _i : B × Fin h, ((2*2^Fintype.card α : ℕ) : ℝ)*((Fintype.card α : ℝ)+1)^2*T/ + scalarCubeProductBoundaryRadius (B × Fin h) α (η/2))+ + (Fintype.card (BlockParameter B (Fin h) α) : ℝ)* + ((A : ℝ)/canonicalAffineCubeMinorThreshold O α h c₀ δ η* + productMinorDeterminantDerivativeBound (Fintype.card (BlockParameter B (Fin h) α)) + (Fintype.card O) (Fintype.card α) h C 1) + +theorem affineBooleanAxisWeightLog_nonneg (B O α : Type*) [Fintype B] [Fintype O] [Fintype α] + (h : ℕ) {P E F : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : 0 ≤ affineBooleanAxisWeightLog B O α h P E F := by + have hk := canonicalAffineMinorLog_nonneg O α h hP hE hF + unfold affineBooleanAxisWeightLog scalarCubeDerivativeLog scalarCubeBoundaryLog + productMinorDeterminantLog productMinorPartialLog productMinorEntryLog + positivity + +theorem affineBooleanAxisWeightCost_le_exp (B O α : Type*) [Fintype B] [Fintype O] [Nonempty O] + [Fintype α] [DecidableEq α] (h : ℕ) (hh : 0 < h) {C c₀ δ η P E F : ℝ} + (hC : 0 ≤ C) (hc₀ : 0 < c₀) (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hCP : C ≤ Real.exp P) (hcP : c₀⁻¹ ≤ Real.exp P) (hηE : η⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) + (A T : ℝ≥0) (hAP : (A : ℝ) ≤ Real.exp P) (hTP : (T : ℝ) ≤ Real.exp P) : + affineBooleanAxisWeightCost B O α h C A T c₀ δ η ≤ Real.exp (affineBooleanAxisWeightLog B O α h P E F) := by + let n := Fintype.card (BlockParameter B (Fin h) α) + let k := Fintype.card (B × Fin h) + let b := scalarCubeDerivativeLog (Fintype.card α) P+2*k+E+1 + let m := (n : ℝ)+P+canonicalAffineMinorLog O α h P E F+ + productMinorDeterminantLog n (Fintype.card O) (Fintype.card α) h P + have h2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hhη : (η/2)⁻¹ ≤ Real.exp (E+1) := by + calc + _ = 2*η⁻¹ := by rw [inv_div, div_eq_mul_inv] + _ ≤ Real.exp 1*Real.exp E := by gcongr + _ = _ := by rw [← Real.exp_add, add_comm] + have hk : (k : ℝ)+1 ≤ Real.exp k := Real.add_one_le_exp _ + have hd := scalarCubeProductDerivativeConstant_le_exp α T hTP + have hd0 : 0 ≤ scalarCubeProductDerivativeConstant α T := by + unfold scalarCubeProductDerivativeConstant + have := (scalarCubeBoundaryConstant_pos α).le + positivity + have hb : (∑ _i : B × Fin h, ((2*2^Fintype.card α : ℕ) : ℝ)*((Fintype.card α : ℝ)+1)^2*T/ + scalarCubeProductBoundaryRadius (B × Fin h) α (η/2)) ≤ Real.exp b := by + apply (scalarCubeProductBoundaryRadius_derivative (B × Fin h) α T (half_pos hη)).trans + rw [div_eq_mul_inv] + calc + _ ≤ Real.exp (scalarCubeDerivativeLog (Fintype.card α) P)*(Real.exp k)^2*Real.exp (E+1) := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add]; congr 1; dsimp [b]; ring + have hκ : (canonicalAffineCubeMinorThreshold O α h c₀ δ η)⁻¹ ≤ + Real.exp (canonicalAffineMinorLog O α h P E F) := by + simpa using + canonicalAffineCubeMinorThreshold_inverse_le_exp O α h hh hc₀ hδ hδone hη hP hE hcP hηE hδF + have hκ0 := canonicalAffineCubeMinorThreshold_pos O α hh hc₀ hδ hη + have hdet := productMinorDeterminantDerivativeBound_le_exp n (Fintype.card O) (Fintype.card α) h hC hP hCP + have hdet0 := productMinorDeterminantDerivativeBound_nonneg n (Fintype.card O) (Fintype.card α) h hC zero_le_one + have hn : (n : ℝ) ≤ Real.exp n := by linarith [Real.add_one_le_exp (n : ℝ)] + have hm : (n : ℝ)*((A : ℝ)/canonicalAffineCubeMinorThreshold O α h c₀ δ η* + productMinorDeterminantDerivativeBound n (Fintype.card O) (Fintype.card α) h C 1) ≤ Real.exp m := by + rw [div_eq_mul_inv] + calc + _ ≤ Real.exp n*(Real.exp P*Real.exp (canonicalAffineMinorLog O α h P E F)* + Real.exp (productMinorDeterminantLog n (Fintype.card O) (Fintype.card α) h P)) := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add]; congr 1; dsimp [m]; ring + have hb0 : 0 ≤ b := by dsimp [b, scalarCubeDerivativeLog, scalarCubeBoundaryLog]; positivity + have hm0 : 0 ≤ m := by + have := canonicalAffineMinorLog_nonneg O α h hP hE hF + dsimp [m, productMinorDeterminantLog, productMinorPartialLog, productMinorEntryLog] + positivity + exact add_le_exp_add_one hb0 hm0 hb hm + +theorem jointAffineBooleanWeightLog_nonneg {D α : Type*} [Fintype D] [Fintype α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + (h : D → ℕ) {P E F : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : + 0 ≤ jointAffineBooleanWeightLog (B := B) (O := O) (α := α) h P E F := + add_nonneg (Nat.cast_nonneg _) (Finset.sum_nonneg (fun d _ => affineBooleanAxisWeightLog_nonneg (B d) (O d) α (h d) hP hE hF)) + +theorem jointAffineBooleanWeightBudget_canonical_le_exp {D α : Type*} + [Fintype D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, Nonempty (O d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (c₀ C η : D → ℝ) + (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) (hη : ∀ d, 0 < η d) + {δ P E F : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hcP : ∀ d, (c₀ d)⁻¹ ≤ Real.exp P) (hCP : ∀ d, C d ≤ Real.exp P) + (hηE : ∀ d, (η d)⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) (A T : ℝ≥0) + (hAP : (A : ℝ) ≤ Real.exp P) (hTP : (T : ℝ) ≤ Real.exp P) : + jointBooleanWeightBudget (B := B) (O := O) (α := α) h C A T + (fun d _ => scalarCubeProductBoundaryRadius (B d × Fin (h d)) α (η d/2)) + (fun d => canonicalAffineCubeMinorThreshold (O d) α (h d) (c₀ d) δ (η d)) ≤ + Real.exp (jointAffineBooleanWeightLog (B := B) (O := O) (α := α) h P E F) := by + change (∑ d, affineBooleanAxisWeightCost (B d) (O d) α (h d) (C d) A T (c₀ d) δ (η d)) ≤ + Real.exp ((Fintype.card D : ℝ)+∑ d, affineBooleanAxisWeightLog (B d) (O d) α (h d) P E F) + exact sum_le_exp_card_add_sum + (fun d => affineBooleanAxisWeightCost (B d) (O d) α (h d) (C d) A T (c₀ d) δ (η d)) + (fun d => affineBooleanAxisWeightLog (B d) (O d) α (h d) P E F) + (fun d => affineBooleanAxisWeightLog_nonneg (B d) (O d) α (h d) hP hE hF) + (fun d => affineBooleanAxisWeightCost_le_exp (B d) (O d) α (h d) (hh d) + (hC d) (hc₀ d) hδ hδone (hη d) hP hE hF (hCP d) (hcP d) (hηE d) hδF A T hAP hTP) + +end Erdos3 + +end + +section + +namespace Erdos3 + +section Definitions +variable {A : Type*} [Semiring A] +def affineMinorVariableEnvelope (D : A) : A := D * (D * (D + 1)) +def affineMinorDegreeEnvelope (D : A) : A := 1 + D * D +def affineMinorConstantEnvelope (D : A) : A := + D * D * (D + 1)^2 + 3 * affineMinorVariableEnvelope D + + (affineMinorDegreeEnvelope D + 1) + + affineMinorDegreeEnvelope D * (8 + (affineMinorDegreeEnvelope D + 1)) +def affineMinorLogEnvelope (D P E F : A) : A := + affineMinorVariableEnvelope D * affineMinorDegreeEnvelope D + D * P + 2 + + affineMinorVariableEnvelope D * affineMinorDegreeEnvelope D * + (affineMinorConstantEnvelope D + 1 + E + 2) + + affineMinorVariableEnvelope D * affineMinorDegreeEnvelope D * affineMinorVariableEnvelope D * F +end Definitions + + theorem affineMinorVariableEnvelope_nonneg {D : ℝ} (hD : 0 ≤ D) : + 0 ≤ affineMinorVariableEnvelope D := by unfold affineMinorVariableEnvelope; positivity + theorem affineMinorDegreeEnvelope_nonneg {D : ℝ} (hD : 0 ≤ D) : + 0 ≤ affineMinorDegreeEnvelope D := by unfold affineMinorDegreeEnvelope; positivity + theorem affineMinorConstantEnvelope_nonneg {D : ℝ} (hD : 0 ≤ D) : + 0 ≤ affineMinorConstantEnvelope D := by + have := affineMinorVariableEnvelope_nonneg hD + have := affineMinorDegreeEnvelope_nonneg hD + unfold affineMinorConstantEnvelope + positivity + theorem affineMinorLogEnvelope_nonneg {D P E F : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : + 0 ≤ affineMinorLogEnvelope D P E F := by + have := affineMinorVariableEnvelope_nonneg hD + have := affineMinorDegreeEnvelope_nonneg hD + have := affineMinorConstantEnvelope_nonneg hD + unfold affineMinorLogEnvelope + positivity + + theorem cubeMinor_counts_le_envelope (O α : Type*) [Fintype O] [Fintype α] + (h : ℕ) {D : ℝ} (hD : 0 ≤ D) + (hO : (Fintype.card O : ℝ) ≤ D) (hα : (Fintype.card α : ℝ) ≤ D) (hh : (h : ℝ) ≤ D) : + (cubeMinorVariableCount O α h : ℝ) ≤ affineMinorVariableEnvelope D ∧ + (cubeMinorDegree O h : ℝ) ≤ affineMinorDegreeEnvelope D := by + constructor + · simp only [cubeMinorVariableCount, Nat.cast_mul, Nat.cast_add, Nat.cast_one, + affineMinorVariableEnvelope] + gcongr + · have hs : ((h - 1 : ℕ) : ℝ) ≤ D := (Nat.cast_le.mpr (Nat.sub_le _ _)).trans hh + simp only [cubeMinorDegree, Nat.cast_max, Nat.cast_one, Nat.cast_mul, affineMinorDegreeEnvelope] + apply max_le + · nlinarith [sq_nonneg D] + · exact (mul_le_mul hO hs (Nat.cast_nonneg _) hD).trans (by linarith) + + theorem canonicalAffineMinorLog_le_envelope (O α : Type*) [Fintype O] [Fintype α] + (h : ℕ) {D P E F : ℝ} (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hO : (Fintype.card O : ℝ) ≤ D) (hα : (Fintype.card α : ℝ) ≤ D) (hh : (h : ℝ) ≤ D) : + canonicalAffineMinorLog O α h P E F ≤ affineMinorLogEnvelope D P E F := by + obtain ⟨hN, hd⟩ := cubeMinor_counts_le_envelope O α h hD hO hα hh + have hN0 := affineMinorVariableEnvelope_nonneg hD + have hd0 := affineMinorDegreeEnvelope_nonneg hD + have hC0 := affineMinorConstantEnvelope_nonneg hD + have hC : cubeMinorConstantLog (Fintype.card O) (Fintype.card α) h + (cubeMinorVariableCount O α h) (cubeMinorDegree O h) ≤ affineMinorConstantEnvelope D := by + unfold cubeMinorConstantLog affineMinorConstantEnvelope + gcongr + have hCold : 0 ≤ cubeMinorConstantLog (Fintype.card O) (Fintype.card α) h + (cubeMinorVariableCount O α h) (cubeMinorDegree O h) := by + unfold cubeMinorConstantLog + positivity + unfold canonicalAffineMinorLog canonicalBooleanMinorLog cubeMinorThresholdLog cubeMinorScaleLog + affineMinorLogEnvelope + push_cast + gcongr + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped NNReal + +variable {D α : Type*} [Fintype D] [Fintype α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + +noncomputable def jointAffineTranslationLog (h : D → ℕ) (P E F : ℝ) : ℝ := + Fintype.card (Σ d, O d) + Fintype.card (JointBlockParameter B h α) + + 3 * jointAffineInverseLog (O := O) (α := α) h P E F + + jointBooleanDerivativeLog (B := B) (O := O) (α := α) h P + + jointAffineBooleanWeightLog (B := B) (O := O) (α := α) h P E F + 1 + +noncomputable def jointAffinePerturbationLog (h : D → ℕ) (P E F : ℝ) : ℝ := + Fintype.card (JointBlockParameter B h α) + + 3 * jointAffineInverseLog (O := O) (α := α) h P E F + + jointBooleanDerivativeLog (B := B) (O := O) (α := α) h P + + jointAffineBooleanWeightLog (B := B) (O := O) (α := α) h P E F + 6 + + theorem jointAffineDivergence_le_exp [DecidableEq D] [DecidableEq α] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (c₀ C η : D → ℝ) + (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) (hη : ∀ d, 0 < η d) + {δ P E F : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hcP : ∀ d, (c₀ d)⁻¹ ≤ Real.exp P) (hCP : ∀ d, C d ≤ Real.exp P) + (hηE : ∀ d, (η d)⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) (A T : ℝ≥0) + (hAP : (A : ℝ) ≤ Real.exp P) (hTP : (T : ℝ) ≤ Real.exp P) : + let r := fun d (_ : B d × Fin (h d)) => scalarCubeProductBoundaryRadius (B d × Fin (h d)) α (η d / 2) + let κ := fun d => canonicalAffineCubeMinorThreshold (O d) α (h d) (c₀ d) δ (η d) + let K := jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ + let H := jointBooleanDerivativeBudget (B := B) (O := O) (α := α) h C + (jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H : ℝ) ≤ + Real.exp (jointAffineTranslationLog (B := B) (O := O) (α := α) h P E F) ∧ + jointAffineBooleanErrorBudget (O := O) (α := α) h C κ A T r δ ≤ + Real.exp (jointAffinePerturbationLog (B := B) (O := O) (α := α) h P E F) := by + intro r κ K H + have hK := jointAffineBooleanInverseBudget_le_exp (O := O) (α := α) + h hh c₀ C η hc₀ hC hη hδ hδone hP hE hF hcP hCP hηE hδF + have hH := jointBooleanDerivativeBudget_le_exp (B := B) (O := O) (α := α) h C hC hP hCP + have hS := jointAffineBooleanWeightBudget_canonical_le_exp (B := B) (O := O) (α := α) + h hh c₀ C η hc₀ hC hη hδ hδone hP hE hF hcP hCP hηE hδF A T hAP hTP + have hS0 := jointBooleanWeightBudget_nonneg (B := B) (O := O) (α := α) h C hC A T r + (fun d _ => (scalarCubeProductBoundaryRadius_pos (B d × Fin (h d)) α (half_pos (hη d))).le) + κ (fun d => (canonicalAffineCubeMinorThreshold_pos (O d) α (hh d) (hc₀ d) hδ (hη d)).le) + have hKL := jointAffineInverseLog_nonneg (O := O) (α := α) h hP hE hF + have hHL := jointBooleanDerivativeLog_nonneg (B := B) (O := O) (α := α) h hP + have hSL := jointAffineBooleanWeightLog_nonneg (B := B) (O := O) (α := α) h hP hE hF + constructor + · have he := translationDivergence_le_exp (Fintype.card (Σ d, O d)) + (Fintype.card (JointBlockParameter B h α)) K.coe_nonneg H.coe_nonneg hS0 + hKL hHL hSL hK hH hS + simpa only [jointAffineTranslationLog, Nat.cast_add, jointAffineBooleanTranslationBudget, NNReal.coe_mul, NNReal.coe_add, + NNReal.coe_natCast, NNReal.coe_pow, Real.coe_toNNReal _ hS0] using he + · exact perturbationDivergence_le_exp (Fintype.card (JointBlockParameter B h α)) + K.coe_nonneg H.coe_nonneg hS0 hKL hHL hSL hK hH hS + +end Erdos3 + +end + +section + +namespace Erdos3 + +section Definitions +variable {A : Type*} [Semiring A] +def affineInverseAxisEnvelope (D P E F : A) : A := + F + (D + D^2 + D * (P + D + D * D) + affineMinorLogEnvelope D P E F) + +def affineDerivativeAxisEnvelope (D P : A) : A := + affineMinorVariableEnvelope D + D + (P + 2 * D + D * D) + +def affineWeightAxisEnvelope (D P E F : A) : A := + (P + 3 * D + 1 + ((D + 1)^2 + 2 * D + 2) + 2 * (D * D) + E + 1) + + (affineMinorVariableEnvelope D + P + affineMinorLogEnvelope D P E F + + (affineMinorVariableEnvelope D + D^2 + D + (P + 2 * D + D * D) + + D * (P + D + D * D + 1))) + 1 +end Definitions + + theorem affineInverseAxisEnvelope_nonneg {D P E F : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : + 0 ≤ affineInverseAxisEnvelope D P E F := by + have := affineMinorLogEnvelope_nonneg hD hP hE hF + unfold affineInverseAxisEnvelope + positivity + theorem affineDerivativeAxisEnvelope_nonneg {D P : ℝ} (hD : 0 ≤ D) (hP : 0 ≤ P) : + 0 ≤ affineDerivativeAxisEnvelope D P := by + have := affineMinorVariableEnvelope_nonneg hD + unfold affineDerivativeAxisEnvelope + positivity + theorem affineWeightAxisEnvelope_nonneg {D P E F : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : + 0 ≤ affineWeightAxisEnvelope D P E F := by + have := affineMinorLogEnvelope_nonneg hD hP hE hF + have := affineMinorVariableEnvelope_nonneg hD + unfold affineWeightAxisEnvelope + positivity + + theorem affineBlockParameter_card_le (B α : Type*) [Fintype B] [Fintype α] + (h : ℕ) {D : ℝ} (hD : 0 ≤ D) + (hB : (Fintype.card B : ℝ) ≤ D) (hα : (Fintype.card α : ℝ) ≤ D) (hh : (h : ℝ) ≤ D) : + (Fintype.card (BlockParameter B (Fin h) α) : ℝ) ≤ affineMinorVariableEnvelope D := by + simp only [BlockParameter, Fintype.card_prod, Fintype.card_fin, Fintype.card_option, + Nat.cast_mul, Nat.cast_add, Nat.cast_one, affineMinorVariableEnvelope] + gcongr + + theorem affineInverseAxisLog_le_envelope (O α : Type*) [Fintype O] [Fintype α] + (h : ℕ) {D P E F : ℝ} (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hO : (Fintype.card O : ℝ) ≤ D) (hα : (Fintype.card α : ℝ) ≤ D) (hh : (h : ℝ) ≤ D) : + F + productMinorInverseLog (Fintype.card O) (Fintype.card α) h P + (canonicalAffineMinorLog O α h P E F) ≤ affineInverseAxisEnvelope D P E F := by + have hminor := canonicalAffineMinorLog_le_envelope O α h hD hP hE hF hO hα hh + have hj : ((Fintype.card O - 1 : ℕ) : ℝ) ≤ D := (Nat.cast_le.mpr (Nat.sub_le _ _)).trans hO + unfold productMinorInverseLog productMinorEntryLog affineInverseAxisEnvelope + gcongr + + theorem affineDerivativeAxisLog_le_envelope (B O α : Type*) [Fintype B] [Fintype O] [Fintype α] + (h : ℕ) {D P : ℝ} (hD : 0 ≤ D) + (hB : (Fintype.card B : ℝ) ≤ D) (hO : (Fintype.card O : ℝ) ≤ D) + (hα : (Fintype.card α : ℝ) ≤ D) (hh : (h : ℝ) ≤ D) : + productMinorDerivativeLog (Fintype.card (BlockParameter B (Fin h) α)) + (Fintype.card O) (Fintype.card α) h P ≤ affineDerivativeAxisEnvelope D P := by + have hn := affineBlockParameter_card_le B α h hD hB hα hh + unfold productMinorDerivativeLog productMinorPartialLog affineDerivativeAxisEnvelope + gcongr + + theorem affineWeightAxisLog_le_envelope (B O α : Type*) [Fintype B] [Fintype O] [Fintype α] + (h : ℕ) {D P E F : ℝ} (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hB : (Fintype.card B : ℝ) ≤ D) (hO : (Fintype.card O : ℝ) ≤ D) + (hα : (Fintype.card α : ℝ) ≤ D) (hh : (h : ℝ) ≤ D) : + affineBooleanAxisWeightLog B O α h P E F ≤ affineWeightAxisEnvelope D P E F := by + have hn := affineBlockParameter_card_le B α h hD hB hα hh + have hminor := canonicalAffineMinorLog_le_envelope O α h hD hP hE hF hO hα hh + have hbh : (Fintype.card (B × Fin h) : ℝ) ≤ D * D := by + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul] + exact mul_le_mul hB hh (Nat.cast_nonneg _) hD + unfold affineBooleanAxisWeightLog affineWeightAxisEnvelope scalarCubeDerivativeLog scalarCubeBoundaryLog + productMinorDeterminantLog productMinorPartialLog productMinorEntryLog + gcongr + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped NNReal + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + +noncomputable def jointAffineSourceInputLog (h : D → ℕ) (P E F : ℝ) : ℝ := + jointAffineTranslationLog (B := B) (O := O) (α := α) h P E F + + jointAffinePerturbationLog (B := B) (O := O) (α := α) h P E F + + jointAffineInverseLog (O := O) (α := α) h P E F + Fintype.card (Σ d, O d) + E + 4 + + theorem jointAffineSourceScales_log_bounds (h : D → ℕ) (hh : ∀ d, 0 < h d) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (A T : ℝ≥0) {δ ε P E F : ℝ} + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hcP : ∀ d, (c₀ d)⁻¹ ≤ Real.exp P) (hCP : ∀ d, C d ≤ Real.exp P) + (hAP : (A : ℝ) ≤ Real.exp P) (hTP : (T : ℝ) ≤ Real.exp P) + (hηE : (ε / (12 * ((Fintype.card D : ℝ) + 1)))⁻¹ ≤ Real.exp E) + (hεE : (ε / 3)⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) : + let Qlog := jointAffineSourceInputLog (B := B) (O := O) (α := α) h P E F + 0 ≤ Qlog ∧ + (jointAffineSourceRadius (B := B) (O := O) (α := α) h c₀ C A T δ ε)⁻¹ ≤ Real.exp (2 * Qlog + 2) ∧ + Real.log (jointAffineSourceTolerance (B := B) (O := O) (α := α) h c₀ C A T δ ε)⁻¹ ≤ + Real.log 16 + 6 * Qlog := by + intro Qlog + let η : D → ℝ := fun _ => ε / (12 * ((Fintype.card D : ℝ) + 1)) + have hη : ∀ d, 0 < η d := fun _ => div_pos hε (by positivity) + let r := jointAffineSourceBoundaryRadius (B := B) (α := α) h ε + let κ := jointAffineSourceMinorThreshold (O := O) (α := α) h c₀ δ ε + let K := jointAffineBooleanInverseBudget (O := O) (α := α) h C κ δ + let H := jointBooleanDerivativeBudget (B := B) (O := O) (α := α) h C + let Q := jointAffineBooleanErrorBudget (O := O) (α := α) h C κ A T r δ + let L := jointAffineBooleanTranslationBudget (O := O) (α := α) C A T r κ K H + have hdiv := jointAffineDivergence_le_exp (B := B) (O := O) (α := α) h hh c₀ C η hc₀ hC hη + hδ hδone hP hE hF hcP hCP (fun _ => hηE) hδF A T hAP hTP + have hk := jointAffineBooleanInverseBudget_le_exp (O := O) (α := α) h hh c₀ C η hc₀ hC hη + hδ hδone hP hE hF hcP hCP (fun _ => hηE) hδF + have hKL := jointAffineInverseLog_nonneg (O := O) (α := α) h hP hE hF + have hHL := jointBooleanDerivativeLog_nonneg (B := B) (O := O) (α := α) h hP + have hSL := jointAffineBooleanWeightLog_nonneg (B := B) (O := O) (α := α) h hP hE hF + have hLL : 0 ≤ jointAffineTranslationLog (B := B) (O := O) (α := α) h P E F := by + unfold jointAffineTranslationLog + positivity + have hQL : 0 ≤ jointAffinePerturbationLog (B := B) (O := O) (α := α) h P E F := by + unfold jointAffinePerturbationLog + positivity + have hQlog : 0 ≤ Qlog := by dsimp [Qlog, jointAffineSourceInputLog]; positivity + have hLlog : jointAffineTranslationLog (B := B) (O := O) (α := α) h P E F ≤ Qlog := by + dsimp [Qlog, jointAffineSourceInputLog]; linarith [Nat.cast_nonneg (α := ℝ) (Fintype.card (Σ d, O d))] + have hKlog : jointAffineInverseLog (O := O) (α := α) h P E F + 1 ≤ Qlog := by + dsimp [Qlog, jointAffineSourceInputLog]; linarith [Nat.cast_nonneg (α := ℝ) (Fintype.card (Σ d, O d))] + have hQlog' : jointAffinePerturbationLog (B := B) (O := O) (α := α) h P E F + 1 ≤ Qlog := by + dsimp [Qlog, jointAffineSourceInputLog]; linarith [Nat.cast_nonneg (α := ℝ) (Fintype.card (Σ d, O d))] + have hElog : E ≤ Qlog := by + dsimp [Qlog, jointAffineSourceInputLog]; linarith [Nat.cast_nonneg (α := ℝ) (Fintype.card (Σ d, O d))] + have hnlog : (Fintype.card (Σ d, O d) : ℝ) ≤ Qlog := by + dsimp [Qlog, jointAffineSourceInputLog]; linarith + have honeLog : 1 ≤ Qlog := by + dsimp [Qlog, jointAffineSourceInputLog]; linarith [Nat.cast_nonneg (α := ℝ) (Fintype.card (Σ d, O d))] + have hLexp : (L : ℝ) ≤ Real.exp Qlog := hdiv.1.trans (Real.exp_le_exp.mpr hLlog) + have hKexp : 1 + (K : ℝ) ≤ Real.exp Qlog := + (one_add_le_exp_succ hKL hk).trans (Real.exp_le_exp.mpr hKlog) + have hQexp : 1 + Q ≤ Real.exp Qlog := + (one_add_le_exp_succ hQL hdiv.2).trans (Real.exp_le_exp.mpr hQlog') + have hτexp : (ε / 3)⁻¹ ≤ Real.exp Qlog := hεE.trans (Real.exp_le_exp.mpr hElog) + have hS0 := jointBooleanWeightBudget_nonneg (B := B) (O := O) (α := α) h C hC A T r + (fun d _ => (scalarCubeProductBoundaryRadius_pos _ _ (half_pos (hη d))).le) + κ (fun d => (canonicalAffineCubeMinorThreshold_pos (O d) α (hh d) (hc₀ d) hδ (hη d)).le) + have hQ : 0 ≤ Q := by dsimp [Q, jointAffineBooleanErrorBudget]; positivity + refine ⟨hQlog, ?_, ?_⟩ + · have hε' : 0 < 2 * ε / 3 := by positivity + have hε'exp : (2 * ε / 3)⁻¹ ≤ Real.exp Qlog := + (inv_anti₀ (by positivity : 0 < ε / 3) (by linarith : ε / 3 ≤ 2 * ε / 3)).trans hτexp + have he := regularizationRadius_inverse_le_exp L.coe_nonneg hε' hQlog hLexp hε'exp + have heq : jointAffineSourceRadius (B := B) (O := O) (α := α) h c₀ C A T δ ε = + regularizationRadius L (2 * ε / 3) := by + change min 1 (ε / (3 * (1 + (L : ℝ)))) = min 1 ((2 * ε / 3) / (2 * (1 + (L : ℝ)))) + congr 1 + field_simp + rwa [heq] + · exact polynomialPerturbationScale_log_inv_le K.coe_nonneg zero_le_one hQ + (by positivity : 0 < ε / 3) hQlog (Fintype.card (Σ d, O d)) hKexp + ((by linarith [Real.add_one_le_exp (1 : ℝ)] : (1 : ℝ) + 1 ≤ Real.exp 1).trans + (Real.exp_le_exp.mpr honeLog)) hQexp + ((Real.add_one_le_exp _).trans (Real.exp_le_exp.mpr hnlog)) hτexp + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped NNReal + +variable {D α Z : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] + [Fintype Z] [DecidableEq Z] + {B O : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] + [∀ d, DecidableEq (B d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + +omit [DecidableEq D] [∀ index, DecidableEq (B index)] [∀ index, DecidableEq (O index)] in + theorem jointAffineSourceTolerance_pos (h : D → ℕ) (hh : ∀ d, 0 < h d) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (A T : ℝ≥0) {δ ε : ℝ} (hδ : 0 < δ) (hε : 0 < ε) : + 0 < jointAffineSourceTolerance (B := B) (O := O) (α := α) h c₀ C A T δ ε := by + let η : D → ℝ := fun _ => ε / (12 * ((Fintype.card D : ℝ) + 1)) + have hη : ∀ d, 0 < η d := fun _ => div_pos hε (by positivity) + let r := jointAffineSourceBoundaryRadius (B := B) (α := α) h ε + let κ := jointAffineSourceMinorThreshold (O := O) (α := α) h c₀ δ ε + have hS0 := jointBooleanWeightBudget_nonneg (B := B) (O := O) (α := α) h C hC A T r + (fun d _ => (scalarCubeProductBoundaryRadius_pos _ _ (half_pos (hη d))).le) + κ (fun d => (canonicalAffineCubeMinorThreshold_pos (O d) α (hh d) (hc₀ d) hδ (hη d)).le) + have hQ : 0 ≤ jointAffineBooleanErrorBudget (O := O) (α := α) h C κ A T r δ := by + unfold jointAffineBooleanErrorBudget + positivity + exact (polynomialPerturbationScale_spec (NNReal.coe_nonneg _) zero_le_one hQ + (by positivity : 0 < ε / 3) (Fintype.card (Σ d, O d))).1 + +omit [DecidableEq Z] in + theorem jointAffineCoefficientTolerance_log_bound (h : D → ℕ) (hh : ∀ d, 0 < h d) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (A T : ℝ≥0) (degree : ℕ) {Csum Wsum δ ε P E F : ℝ} + (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) (hCsumP : Csum ≤ Real.exp P) (hWsumP : Wsum ≤ Real.exp P) + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hcP : ∀ d, (c₀ d)⁻¹ ≤ Real.exp P) (hCP : ∀ d, C d ≤ Real.exp P) + (hAP : (A : ℝ) ≤ Real.exp P) (hTP : (T : ℝ) ≤ Real.exp P) + (hηE : (ε / (12 * ((Fintype.card D : ℝ) + 1)))⁻¹ ≤ Real.exp E) + (hεE : (ε / 3)⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) : + Real.log (jointAffineCoefficientTolerance (Z := Z) (B := B) (O := O) (α := α) + h c₀ C A T degree Csum Wsum δ ε)⁻¹ ≤ + Real.log 16 + 6 * jointAffineSourceInputLog (B := B) (O := O) (α := α) h P E F + + booleanToleranceC2Log (B := B) (α := α) Z h degree P + 1 := by + let t := jointAffineSourceTolerance (B := B) (O := O) (α := α) h c₀ C A T δ ε + let M := booleanToleranceC2 (B := B) (α := α) Z h degree Csum Wsum + have ht : 0 < t := jointAffineSourceTolerance_pos h hh c₀ C hc₀ hC A T hδ hε + have hM : 0 ≤ M := polynomialC2BoxBudget_nonneg _ _ + (add_nonneg (booleanJetMassBudget_nonneg _ _ hCsum) (booleanJetMassBudget_nonneg _ _ hWsum)) + have hraw := (jointAffineSourceScales_log_bounds (B := B) (O := O) (α := α) h hh c₀ C hc₀ hC A T hδ hδone hε hP hE hF + hcP hCP hAP hTP hηE hεE hδF).2.2 + have hMexp := booleanToleranceC2_le_exp (B := B) (α := α) Z h degree hCsum hWsum hP hCsumP hWsumP + have hMlog := Real.log_le_log (by positivity : 0 < 1 + M) + (one_add_le_exp_succ (booleanToleranceC2Log_nonneg (B := B) (α := α) Z h degree hP) hMexp) + rw [Real.log_exp] at hMlog + change Real.log (t / (1 + M))⁻¹ ≤ _ + rw [inv_div, div_eq_mul_inv, Real.log_mul (by positivity : (1 + M : ℝ) ≠ 0) (inv_ne_zero ht.ne')] + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +section Definitions +variable {A : Type*} [Semiring A] +def jointAffineInverseEnvelope (D P E F : A) : A := D + D * affineInverseAxisEnvelope D P E F +def jointAffineDerivativeEnvelope (D P : A) : A := D + D * affineDerivativeAxisEnvelope D P +def jointAffineWeightEnvelope (D P E F : A) : A := D + D * affineWeightAxisEnvelope D P E F +def jointAffineSourceEnvelope (D P E F : A) : A := + let out := D * D + let param := D * affineMinorVariableEnvelope D + let inv := jointAffineInverseEnvelope D P E F + let deriv := jointAffineDerivativeEnvelope D P + let weight := jointAffineWeightEnvelope D P E F + (out + param + 3 * inv + deriv + weight + 1) + + (param + 3 * inv + deriv + weight + 6) + inv + out + E + 4 +end Definitions + + theorem affineLog_sum_le {ι : Type*} [Fintype ι] (f : ι → ℝ) {D C : ℝ} + (hD : (Fintype.card ι : ℝ) ≤ D) (hC : 0 ≤ C) (hf : ∀ i, f i ≤ C) : + (∑ i, f i) ≤ D * C := by + calc + _ ≤ ∑ _i : ι, C := Finset.sum_le_sum (fun i _ => hf i) + _ = Fintype.card ι * C := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right hD hC + +variable {ι α : Type*} [Fintype ι] [Fintype α] + {B O : ι → Type*} [∀ i, Fintype (B i)] [∀ i, Fintype (O i)] + + theorem jointAffineSourceInputLog_le_envelope (h : ι → ℕ) {D P E F : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) + (haxes : (Fintype.card ι : ℝ) ≤ D) (hα : (Fintype.card α : ℝ) ≤ D) + (hB : ∀ i, (Fintype.card (B i) : ℝ) ≤ D) + (hO : ∀ i, (Fintype.card (O i) : ℝ) ≤ D) (hh : ∀ i, (h i : ℝ) ≤ D) : + jointAffineSourceInputLog (B := B) (O := O) (α := α) h P E F ≤ jointAffineSourceEnvelope D P E F := by + have hInv : jointAffineInverseLog (O := O) (α := α) h P E F ≤ jointAffineInverseEnvelope D P E F := by + apply add_le_add haxes + exact affineLog_sum_le _ haxes (affineInverseAxisEnvelope_nonneg hD hP hE hF) + (fun i => affineInverseAxisLog_le_envelope (O i) α (h i) hD hP hE hF (hO i) hα (hh i)) + have hDer : jointBooleanDerivativeLog (B := B) (O := O) (α := α) h P ≤ jointAffineDerivativeEnvelope D P := by + apply add_le_add haxes + exact affineLog_sum_le _ haxes (affineDerivativeAxisEnvelope_nonneg hD hP) + (fun i => affineDerivativeAxisLog_le_envelope (B i) (O i) α (h i) hD (hB i) (hO i) hα (hh i)) + have hWeight : jointAffineBooleanWeightLog (B := B) (O := O) (α := α) h P E F ≤ jointAffineWeightEnvelope D P E F := by + apply add_le_add haxes + exact affineLog_sum_le _ haxes (affineWeightAxisEnvelope_nonneg hD hP hE hF) + (fun i => affineWeightAxisLog_le_envelope (B i) (O i) α (h i) hD hP hE hF (hB i) (hO i) hα (hh i)) + have hOut : (Fintype.card (Σ i, O i) : ℝ) ≤ D * D := by + simp only [Fintype.card_sigma, Nat.cast_sum] + exact affineLog_sum_le _ haxes hD hO + have hParam : (Fintype.card (JointBlockParameter B h α) : ℝ) ≤ D * affineMinorVariableEnvelope D := by + simp only [JointBlockParameter, Fintype.card_sigma, Nat.cast_sum] + exact affineLog_sum_le _ haxes (affineMinorVariableEnvelope_nonneg hD) + (fun i => affineBlockParameter_card_le (B i) α (h i) hD (hB i) hα (hh i)) + unfold jointAffineSourceInputLog jointAffineTranslationLog jointAffinePerturbationLog jointAffineSourceEnvelope + push_cast + gcongr + + theorem jointAffineSourceEnvelope_nonneg {D P E F : ℝ} + (hD : 0 ≤ D) (hP : 0 ≤ P) (hE : 0 ≤ E) (hF : 0 ≤ F) : + 0 ≤ jointAffineSourceEnvelope D P E F := by + have := affineMinorVariableEnvelope_nonneg hD + have := affineInverseAxisEnvelope_nonneg hD hP hE hF + have := affineDerivativeAxisEnvelope_nonneg hD hP + have := affineWeightAxisEnvelope_nonneg hD hP hE hF + unfold jointAffineSourceEnvelope jointAffineInverseEnvelope jointAffineDerivativeEnvelope jointAffineWeightEnvelope + positivity + + theorem jointAffineSourceEnvelope_mono {D P P' E E' F F' : ℝ} + (hD : 0 ≤ D) (hP : P ≤ P') (hE : E ≤ E') (hF : F ≤ F') : + jointAffineSourceEnvelope D P E F ≤ jointAffineSourceEnvelope D P' E' F' := by + dsimp only [jointAffineSourceEnvelope, jointAffineInverseEnvelope, jointAffineDerivativeEnvelope, jointAffineWeightEnvelope, + affineInverseAxisEnvelope, affineDerivativeAxisEnvelope, affineWeightAxisEnvelope, affineMinorLogEnvelope, + affineMinorVariableEnvelope, affineMinorDegreeEnvelope] + gcongr + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped NNReal Classical + +variable {D G Z α : Type*} [Fintype D] [Fintype G] [Fintype Z] [Fintype α] [DecidableEq α] + {B : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ) (P : D → Prop) [DecidablePred P] + {O : {d // ¬P d} → Type*} [∀ d, Fintype (O d)] + +noncomputable def partitionedAffineSourceRadius (A T : ℝ≥0) (δ E : ℝ) : ℝ := + jointAffineSourceRadius (B := fun d : {d // ¬P d} => B d.val) (O := O) (α := α) + (fun d => h d.val) (fun d => unitProfilePrincipalSize (B := B) d.val) + (fun d => 2 * unitProfilePrincipalSize (B := B) d.val) A T δ E + +noncomputable def partitionedAffineSourceTolerance (A T : ℝ≥0) (degree : ℕ) (δ E : ℝ) : ℝ := + jointAffineCoefficientTolerance (Z := PartitionedProfileNoiseIndex G Z α B h P) + (B := fun d : {d // ¬P d} => B d.val) (O := O) (α := α) + (fun d => h d.val) (fun d => unitProfilePrincipalSize (B := B) d.val) + (fun d => 2 * unitProfilePrincipalSize (B := B) d.val) A T degree 1 1 δ E + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped NNReal BigOperators Classical + + theorem affineDividedAccuracy_bounds (d : ℕ) {ε E : ℝ} (hε : 0 < ε) + (hεE : ε⁻¹ ≤ Real.exp E) : + (ε / (12 * ((d : ℝ) + 1)))⁻¹ ≤ Real.exp (E + d + 4) ∧ + (ε / 3)⁻¹ ≤ Real.exp (E + d + 4) := by + have h2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have h12 : (12 : ℝ) ≤ Real.exp 4 := by + calc + _ ≤ (2 : ℝ) ^ 4 := by norm_num + _ ≤ (Real.exp 1) ^ 4 := by gcongr + _ = _ := by rw [← Real.exp_nat_mul]; norm_num + constructor + · rw [inv_div, div_eq_mul_inv] + calc + _ ≤ (Real.exp 4 * Real.exp d) * Real.exp E := by + gcongr + exact Real.add_one_le_exp _ + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + · rw [inv_div, div_eq_mul_inv] + calc + _ ≤ Real.exp 2 * Real.exp E := by + gcongr + linarith [Real.add_one_le_exp (2 : ℝ)] + _ = Real.exp (2 + E) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by linarith [Nat.cast_nonneg (α := ℝ) d]) + +variable {D G Z α : Type*} [Fintype D] [Fintype G] [Fintype Z] [Fintype α] [DecidableEq α] + {B : D → Type*} [∀ d, Fintype (B d)] (h : D → ℕ) (P : D → Prop) [DecidablePred P] + {O : {d // ¬P d} → Type*} [∀ d, Fintype (O d)] [∀ d, Nonempty (O d)] + + theorem partitionedAffineSource_scales_log_bounds (hh : ∀ d, 0 < h d) + (A T : ℝ≥0) (degree : ℕ) {δ ε E F : ℝ} + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : 0 < ε) (hE : 0 ≤ E) (hF : 0 ≤ F) + (hεE : ε⁻¹ ≤ Real.exp E) (hδF : δ⁻¹ ≤ Real.exp F) : + let Clog := unitProfileCoefficientLog (B := B) A T + let Elog := E + Fintype.card {d // ¬P d} + 4 + let Qlog := jointAffineSourceInputLog (B := fun d : {d // ¬P d} => B d.val) + (O := O) (α := α) (fun d => h d.val) Clog Elog F + (partitionedAffineSourceRadius (B := B) (O := O) (α := α) h P A T δ ε)⁻¹ ≤ Real.exp (2 * Qlog + 2) ∧ + Real.log (partitionedAffineSourceTolerance (G := G) (Z := Z) (B := B) (O := O) (α := α) + h P A T degree δ ε)⁻¹ ≤ Real.log 16 + 6 * Qlog + + booleanToleranceC2Log (B := fun d : {d // ¬P d} => B d.val) (α := α) + (PartitionedProfileNoiseIndex G Z α B h P) (fun d => h d.val) degree Clog + 1 := by + intro Clog Elog Qlog + have hC := unitProfileCoefficientLog_bounds (B := B) A T + have hClog : 0 ≤ Clog := unitProfileCoefficientLog_nonneg (B := B) A T + have hElog : 0 ≤ Elog := by dsimp [Elog]; positivity + have hacc := affineDividedAccuracy_bounds (Fintype.card {d // ¬P d}) hε hεE + have hlow (d : {d // ¬P d}) := unitProfilePrincipalSize_pos (B := B) d.val + have hupp (d : {d // ¬P d}) : 0 ≤ 2 * unitProfilePrincipalSize (B := B) d.val := + mul_nonneg (by norm_num) (hlow d).le + have hraw := jointAffineSourceScales_log_bounds (B := fun d : {d // ¬P d} => B d.val) + (O := O) (α := α) (fun d => h d.val) (fun d => hh d.val) + (fun d => unitProfilePrincipalSize (B := B) d.val) (fun d => 2 * unitProfilePrincipalSize (B := B) d.val) + hlow hupp A T hδ hδone hε hClog hElog hF + (fun d => hC.1 d.val) (fun d => hC.2.1 d.val) hC.2.2.1 hC.2.2.2 hacc.1 hacc.2 hδF + refine ⟨hraw.2.1, ?_⟩ + exact jointAffineCoefficientTolerance_log_bound (Z := PartitionedProfileNoiseIndex G Z α B h P) + (B := fun d : {d // ¬P d} => B d.val) (O := O) (α := α) + (fun d => h d.val) (fun d => hh d.val) + (fun d => unitProfilePrincipalSize (B := B) d.val) (fun d => 2 * unitProfilePrincipalSize (B := B) d.val) + hlow hupp A T degree zero_le_one zero_le_one (Real.one_le_exp hClog) (Real.one_le_exp hClog) + hδ hδone hε hClog hElog hF (fun d => hC.1 d.val) (fun d => hC.2.1 d.val) + hC.2.2.1 hC.2.2.2 hacc.1 hacc.2 hδF + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators NNReal Classical + +section Definitions +variable {A : Type*} [Semiring A] +def affineProfileCoefficientEnvelope (D A₀ T₀ : A) : A := D * D + A₀ + T₀ + 7 +def affineProfileInputEnvelope (D A₀ T₀ E F : A) : A := + jointAffineSourceEnvelope D (affineProfileCoefficientEnvelope D A₀ T₀) (E + D + 4) F + +def affineProfileToleranceEnvelope (degree : ℕ) (D N A₀ T₀ E F : A) : A := + 16 + 6 * affineProfileInputEnvelope D A₀ T₀ E F + + (3 * N * (degree + 2 : ℕ) + + (2 * (D + affineProfileCoefficientEnvelope D A₀ T₀ + degree * D) + 1)) + 1 +end Definitions + +variable {ι G Z α : Type*} [Fintype ι] [Fintype G] [Fintype Z] [Fintype α] [DecidableEq α] + {B O : ι → Type*} [∀ i, Fintype (B i)] [∀ i, Fintype (O i)] + +omit [DecidableEq α] in + theorem partitionedAffineInputLog_le_envelope (h : ι → ℕ) (partition : ι → Prop) + (A T : ℝ≥0) {D E F : ℝ} (hD : 0 ≤ D) + (haxes : (Fintype.card ι : ℝ) ≤ D) (hα : (Fintype.card α : ℝ) ≤ D) + (hB : ∀ i, (Fintype.card (B i) : ℝ) ≤ D) + (hO : ∀ i, (Fintype.card (O i) : ℝ) ≤ D) (hh : ∀ i, (h i : ℝ) ≤ D) + (hE : 0 ≤ E) (hF : 0 ≤ F) : + jointAffineSourceInputLog (B := fun i : {i // ¬partition i} => B i.val) + (O := fun i : {i // ¬partition i} => O i.val) (α := α) (fun i => h i.val) + (unitProfileCoefficientLog (B := B) A T) (E + Fintype.card {i // ¬partition i} + 4) F ≤ + affineProfileInputEnvelope D (A : ℝ) (T : ℝ) E F := by + have ha : (Fintype.card {i // ¬partition i} : ℝ) ≤ D := + (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans haxes + have hC : unitProfileCoefficientLog (B := B) A T ≤ affineProfileCoefficientEnvelope D (A : ℝ) (T : ℝ) := by + unfold unitProfileCoefficientLog affineProfileCoefficientEnvelope + gcongr + exact affineLog_sum_le _ haxes hD hB + have hb := jointAffineSourceInputLog_le_envelope (B := fun i : {i // ¬partition i} => B i.val) + (O := fun i : {i // ¬partition i} => O i.val) (α := α) (fun i => h i.val) + (E := E + Fintype.card {i // ¬partition i} + 4) hD (unitProfileCoefficientLog_nonneg (B := B) A T) (by positivity) hF ha hα + (fun i => hB i.val) (fun i => hO i.val) (fun i => hh i.val) + exact hb.trans (jointAffineSourceEnvelope_mono (E' := E + D + 4) hD hC (by linarith) le_rfl) + +omit [DecidableEq α] in + theorem partitionedAffineToleranceLog_le_envelope (h : ι → ℕ) (partition : ι → Prop) + (A T : ℝ≥0) (degree : ℕ) {D N E F : ℝ} (hD : 0 ≤ D) + (haxes : (Fintype.card ι : ℝ) ≤ D) (hα : (Fintype.card α : ℝ) ≤ D) + (hB : ∀ i, (Fintype.card (B i) : ℝ) ≤ D) + (hO : ∀ i, (Fintype.card (O i) : ℝ) ≤ D) (hh : ∀ i, (h i : ℝ) ≤ D) + (hE : 0 ≤ E) (hF : 0 ≤ F) + (hN : (Fintype.card (PolynomialParameter (Z ⊕ (Σ i, SamplerCoefficientSlot G B h i)) + (JointBlockParameter B h α)) : ℝ) ≤ N) : + let P := unitProfileCoefficientLog (B := B) A T + let Q := jointAffineSourceInputLog (B := fun i : {i // ¬partition i} => B i.val) + (O := fun i : {i // ¬partition i} => O i.val) (α := α) (fun i => h i.val) + P (E + Fintype.card {i // ¬partition i} + 4) F + Real.log 16 + 6 * Q + + booleanToleranceC2Log (B := fun i : {i // ¬partition i} => B i.val) (α := α) + (PartitionedProfileNoiseIndex G Z α B h partition) (fun i => h i.val) degree P + 1 ≤ + affineProfileToleranceEnvelope degree D N (A : ℝ) (T : ℝ) E F := by + intro P Q + have hQ := partitionedAffineInputLog_le_envelope (B := B) (O := O) (α := α) + h partition A T hD haxes hα hB hO hh hE hF + have hC : P ≤ affineProfileCoefficientEnvelope D (A : ℝ) (T : ℝ) := by + unfold P unitProfileCoefficientLog affineProfileCoefficientEnvelope + gcongr + exact affineLog_sum_le _ haxes hD hB + have hlog : Real.log 16 ≤ (16 : ℝ) := Real.log_le_self (by norm_num) + have hc2 : booleanToleranceC2Log (B := fun i : {i // ¬partition i} => B i.val) (α := α) + (PartitionedProfileNoiseIndex G Z α B h partition) (fun i => h i.val) degree P ≤ + 3 * N * (degree + 2 : ℕ) + + (2 * (D + affineProfileCoefficientEnvelope D (A : ℝ) (T : ℝ) + degree * D) + 1) := by + unfold booleanToleranceC2Log booleanJetMassLog + rw [partitionedPolynomialParameter_card] + gcongr + exact add_le_add (add_le_add (add_le_add hlog (mul_le_mul_of_nonneg_left hQ (by norm_num))) hc2) le_rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalResidueOffsetShift.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalResidueOffsetShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..0179df14b913437c50dce1419fa7506553f24117 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalResidueOffsetShift.lean @@ -0,0 +1,534 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalAmbientVolumeRatio +import OAI.Combinatorics.Progressions.Lattices.SelectedResidueRefinementMean + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +def physicalCubeResidueCoordinates {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (z : Option K × X → ℤ) : + X → (Unit ⊕ α) → ℤ := + fun x i => physicalCubeRootDifferences root D base residue x i + + (modulus x : ℤ) * physicalCubeRootDifferences root D 0 z x i + +theorem physicalCubeRootDifferences_residue {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (z : Option K × X → ℤ) : + physicalCubeRootDifferences root D base (residueLatticeArray residue modulus z) = + physicalCubeResidueCoordinates root D base residue modulus z := by + funext x i + have hoff : physicalCubeOffset (0 : X → ℤ) x i = 0 := by cases i <;> rfl + simp only [physicalCubeResidueCoordinates, physicalCubeRootDifferences, + residueLatticeArray, hoff, zero_add, mul_add, Finset.sum_add_distrib, Finset.mul_sum] + rw [← add_assoc] + congr 1 + apply Finset.sum_congr rfl + intro k _ + ring + +noncomputable def physicalCubeResidueLaw {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) : PMF (X → (Unit ⊕ α) → ℤ) := + (residueSmoothIndexPMF residue modulus hmodulus V hV hZ).map + (physicalCubeResidueCoordinates root D base residue modulus) + +theorem physicalCubeResidueLaw_eq_map {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) : + (residueSmoothPMF residue modulus hmodulus V hV hZ).map + (physicalCubeRootDifferences root D base) = + physicalCubeResidueLaw root D base residue modulus hmodulus V hV hZ := by + rw [residueSmoothPMF, PMF.map_comp] + congr 1 + funext z + exact physicalCubeRootDifferences_residue root D base residue modulus z + +theorem physicalCubeResidueLaw_expectation {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) : + (∑' z, ((residueSmoothPMF residue modulus hmodulus V hV hZ z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) = + ∑' z, ((residueSmoothIndexPMF residue modulus hmodulus V hV hZ z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base residue modulus z) := by + rw [residueSmoothPMF_expectation] + simp_rw [physicalCubeRootDifferences_residue] + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory +open scoped BigOperators Matrix + +def physicalCubeIndexCoordinates {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (z : Option K × X → ℤ) : X → (Unit ⊕ α) → ℤ := + fun x => physicalCubeCoefficient root D *ᵥ (fun k => z (k, x)) + +def physicalResidueReconstruct {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) + (v : X → (Unit ⊕ α) → ℤ) : X → (Unit ⊕ α) → ℤ := + fun x i => physicalCubeRootDifferences root D base residue x i + (modulus x : ℤ) * v x i + +theorem physicalCubeResidueCoordinates_index {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (z : Option K × X → ℤ) : + physicalCubeResidueCoordinates root D base residue modulus z = + physicalResidueReconstruct root D base residue modulus (physicalCubeIndexCoordinates root D z) := by + funext x i + have hzero : physicalCubeOffset (0 : X → ℤ) x i = 0 := by cases i <;> rfl + simp only [physicalCubeResidueCoordinates, physicalResidueReconstruct, + physicalCubeIndexCoordinates, physicalCubeRootDifferences, hzero, zero_add, + Matrix.mulVec, dotProduct] + +theorem physicalResidue_index_test_error {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) + (proxy : (X → (Unit ⊕ α) → ℤ) → ℝ) (hg : Integrable proxy Measure.count) + {ε B : ℝ} (hB : 0 ≤ B) + (he : (∫ v, |(((residueSmoothIndexPMF residue modulus hmodulus V hV hZ).map + (physicalCubeIndexCoordinates root D)) v).toReal - proxy v| ∂Measure.count) ≤ ε) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) (hφ : ∀ v, ‖φ v‖ ≤ B) : + ‖(∑' z, ((residueSmoothPMF residue modulus hmodulus V hV hZ z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) - + ∫ v, (proxy v : ℂ) * φ (physicalResidueReconstruct root D base residue modulus v) + ∂Measure.count‖ ≤ B * ε := by + rw [physicalCubeResidueLaw_expectation] + simp_rw [physicalCubeResidueCoordinates_index] + exact pmf_image_count_test_error (residueSmoothIndexPMF residue modulus hmodulus V hV hZ) + (physicalCubeIndexCoordinates root D) proxy hg hB he + (fun v => φ (physicalResidueReconstruct root D base residue modulus v)) (fun v => hφ _) + +theorem selectedResidue_physical_index_test_error {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (T : Finset (ColumnResiduePattern (Option K) X modulus)) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) + (proxy : T → (X → (Unit ⊕ α) → ℤ) → ℝ) (hg : ∀ r, Integrable (proxy r) Measure.count) + (ε : T → ℝ) {B : ℝ} (hB : 0 ≤ B) + (he : ∀ r : T, (∫ v, |(((residueSmoothIndexPMF + (boundedColumnResidueRepresentative modulus r.val) modulus hmodulus V hV (hc r)).map + (physicalCubeIndexCoordinates root D)) v).toReal - proxy r v| ∂Measure.count) ≤ ε r) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) (hφ : ∀ v, ‖φ v‖ ≤ B) : + ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) - + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∫ v, (proxy r v : ℂ) * φ (physicalResidueReconstruct root D base + (boundedColumnResidueRepresentative modulus r.val) modulus v) ∂Measure.count‖ ≤ + B * ∑ r : T, selectedResidueCellWeight modulus T V r * ε r := by + have h := selectedResidue_bounded_mixture_error modulus hmodulus T V hV hZ hc + (fun z => φ (physicalCubeRootDifferences root D base z)) + (fun r => ∫ v, (proxy r v : ℂ) * φ (physicalResidueReconstruct root D base + (boundedColumnResidueRepresentative modulus r.val) modulus v) ∂Measure.count) + (fun r => B * ε r) (fun r => physicalResidue_index_test_error root D base _ modulus hmodulus + V hV (hc r) (proxy r) (hg r) hB (he r) φ hφ) + convert h using 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro r _ + ring + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Matrix + +def physicalResidueCoordinateMap {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (x : X) + (z : Option K → ℤ) (i : Unit ⊕ α) : ℤ := + physicalCubeRootDifferences root D base residue x i + + (modulus x : ℤ) * (physicalCubeCoefficient root D *ᵥ z) i + +theorem physicalCubeResidueCoordinates_grouped {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) : + physicalCubeResidueCoordinates root D base residue modulus = + (fun z x => physicalResidueCoordinateMap root D base residue modulus x (z x)) ∘ + spatialCoordinateArrayEquiv (Option K) X := by + funext z x i + unfold physicalCubeResidueCoordinates physicalResidueCoordinateMap + congr 1 + have hzero : physicalCubeOffset (0 : X → ℤ) x i = 0 := by cases i <;> rfl + simp only [physicalCubeRootDifferences, hzero, zero_add, Matrix.mulVec, dotProduct, + spatialCoordinateArrayEquiv, Equiv.coe_fn_mk] + +noncomputable def physicalResidueCoordinateLaw {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (x : X) : PMF ((Unit ⊕ α) → ℤ) := + (shiftedSmoothProductPMF + (fun k => residueProfileCenter residue modulus (k, x)) + (fun k => residueProfileWidth modulus V (k, x)) + (fun k => residueProfileWidth_pos modulus V hmodulus hV (k, x)) + (shiftedSmoothProductMass_slice_pos _ _ (residueProfileWidth_pos modulus V hmodulus hV) hZ x)).map + (physicalResidueCoordinateMap root D base residue modulus x) + +theorem physicalCubeResidueLaw_product {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) : + physicalCubeResidueLaw root D base residue modulus hmodulus V hV hZ = + dependentProductPMF (physicalResidueCoordinateLaw root D base residue modulus hmodulus V hV hZ) := by + unfold physicalCubeResidueLaw residueSmoothIndexPMF + rw [physicalCubeResidueCoordinates_grouped, ← PMF.map_comp, + shiftedSmoothProductPMF_grouped, + dependentProductPMF_map] + rfl + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +theorem physicalSelectedResidue_recenter_test {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (q : X → ℕ) (hq : ∀ x, 0 < q x) (T : Finset (ColumnResiduePattern (Option K) X q)) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hmass : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hlarge : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {B Z : ℝ} + (hB : 0 ≤ B) (hφ : ∀ v, ‖φ v‖ ≤ B) (hZ : 0 < Z) : + ‖(∑' z, ((selectedResidueSmoothPMF q T V hV hmass z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) / (Z : ℂ) - + (∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base (boundedColumnResidueRepresentative q r.val) q z)) / + (Z : ℂ)‖ ≤ + (B * (24 * (probabilityProfileLipschitz : ℝ) * ∑ z : Option K × X, (q z.2 : ℝ) / V z)) / Z := by + have h := selectedResidueSmoothPMF_recenter_test q hq T V hV hmass hlarge + (fun z => φ (physicalCubeRootDifferences root D base z)) hB (fun z => hφ _) + simp_rw [physicalCubeRootDifferences_residue] at h + rw [← sub_div, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hZ] + exact div_le_div_of_nonneg_right h hZ.le + +theorem trimmedSpatial_residue_width_lower {K X : Type*} {W τ ρ : ℝ} + (hW : 0 ≤ W) (hρ : 0 ≤ ρ) (N q : X → ℕ) (hq : ∀ x, 0 < q x) + (hsize : ∀ x, 8 * (1 + W) * (q x : ℝ) * ρ ≤ τ * (N x : ℝ)) + (z : Option K × X) : + ρ ≤ residueProfileWidth q (trimmedSpatialWidths W τ N) z := by + have h := trimmedSpatial_scale_lower hW hρ N q z.2 (hq z.2) (hsize z.2) + have he := congrFun (trimmedSpatial_residue_scale (K := K) W τ N q z.2) z.1 + rw [he] + cases z.1 + · exact h.1 + · exact h.2 + +theorem physicalSelectedResidue_trimmed_recenter {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (q N : X → ℕ) (hq : ∀ x, 0 < q x) (hN : ∀ x, 0 < N x) + (T : Finset (ColumnResiduePattern (Option K) X q)) + {W τ ρ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) + (hρ : 8 * (probabilityProfileLipschitz : ℝ) ≤ ρ) + (hsize : ∀ x, 8 * (1 + W) * (q x : ℝ) * ρ ≤ τ * (N x : ℝ)) + (hmass : 0 < ∑' z, selectedResidueSmoothWeight q T (trimmedSpatialWidths W τ N) z) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {B Z : ℝ} + (hB : 0 ≤ B) (hφ : ∀ v, ‖φ v‖ ≤ B) (hZ : 0 < Z) : + let V := trimmedSpatialWidths (K := K) W τ N + let hV := trimmedSpatialWidths_pos (K := K) hW hτ N hN + ‖(∑' z, ((selectedResidueSmoothPMF q T V hV hmass z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) / (Z : ℂ) - + (∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base (boundedColumnResidueRepresentative q r.val) q z)) / + (Z : ℂ)‖ ≤ + (B * (24 * (probabilityProfileLipschitz : ℝ) * Fintype.card (Option K × X) / ρ)) / Z := by + intro V hV + have hρ0 : 0 < ρ := by linarith [probabilityProfileLipschitz_one_le] + have hw (z : Option K × X) : ρ ≤ residueProfileWidth q V z := + trimmedSpatial_residue_width_lower hW hρ0.le N q hq hsize z + have hratio (z : Option K × X) : (q z.2 : ℝ) / V z ≤ 1 / ρ := by + have hq0 : (0 : ℝ) < q z.2 := by exact_mod_cast hq z.2 + have h := (le_div_iff₀ hq0).mp (hw z) + apply (div_le_div_iff₀ (hV z) hρ0).mpr + linarith + have hsum : (∑ z : Option K × X, (q z.2 : ℝ) / V z) ≤ Fintype.card (Option K × X) / ρ := by + apply (Finset.sum_le_sum (fun z _ => hratio z)).trans_eq + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one_div] + apply (physicalSelectedResidue_recenter_test root D base q hq T V hV hmass + (fun z => hρ.trans (hw z)) φ hB hφ hZ).trans + apply div_le_div_of_nonneg_right _ hZ.le + apply mul_le_mul_of_nonneg_left _ hB + simpa only [mul_div_assoc] using mul_le_mul_of_nonneg_left hsum + (show 0 ≤ 24 * (probabilityProfileLipschitz : ℝ) by positivity) + +noncomputable def physicalRecenteringScale (K X : Type*) [Fintype K] [Fintype X] + (B ε : ℝ) : ℝ := + 8 * (probabilityProfileLipschitz : ℝ) + + 2 * (B * (24 * (probabilityProfileLipschitz : ℝ) * Fintype.card (Option K × X))) / ε + +theorem physicalSelectedResidue_prescribed_recenter {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (q N : X → ℕ) (hq : ∀ x, 0 < q x) (hN : ∀ x, 0 < N x) + (T : Finset (ColumnResiduePattern (Option K) X q)) (hT : T.Nonempty) + {W τ B ε : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hB : 0 ≤ B) (hε : 0 < ε) + (hsize : ∀ x, 8 * (1 + W) * (q x : ℝ) * physicalRecenteringScale K X B ε ≤ τ * (N x : ℝ)) : + let V := trimmedSpatialWidths (K := K) W τ N + let hV := trimmedSpatialWidths_pos (K := K) hW hτ N hN + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q T V z, + ∀ (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) (_hφ : ∀ v, ‖φ v‖ ≤ B) + {Z : ℝ} (_hZ : 0 < Z) (_hZi : Z⁻¹ ≤ 2), + ‖(∑' z, ((selectedResidueSmoothPMF q T V hV hmass z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) / (Z : ℂ) - + (∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base (boundedColumnResidueRepresentative q r.val) q z)) / + (Z : ℂ)‖ ≤ ε := by + intro V hV + let C := B * (24 * (probabilityProfileLipschitz : ℝ) * Fintype.card (Option K × X)) + let ρ := physicalRecenteringScale K X B ε + have hC : 0 ≤ C := by dsimp only [C]; positivity + have hρ8 : 8 * (probabilityProfileLipschitz : ℝ) ≤ ρ := by + dsimp only [ρ, physicalRecenteringScale] + exact le_add_of_nonneg_right (div_nonneg (mul_nonneg (by norm_num) hC) hε.le) + have hρ0 : 0 < ρ := by linarith [probabilityProfileLipschitz_one_le] + have hw (z : Option K × X) : 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z := + hρ8.trans (trimmedSpatial_residue_width_lower hW hρ0.le N q hq hsize z) + have hc (r : T) : 0 < ∑' z, residueSmoothWeight (columnResidueRepresentative q r.val) q V z := by + rw [← residueSmoothWeight_mass _ q hq V hV] + exact shiftedSmoothProductMass_pos_of_large _ _ hw + have hmass := selectedResidueSmoothWeight_mass_pos q T hT V hV hc + refine ⟨hmass, ?_⟩ + intro φ hφ Z hZ hZi + apply (physicalSelectedResidue_trimmed_recenter root D base q N hq hN T hW hτ hρ8 hsize + hmass φ hB hφ hZ).trans + have hpart : 2 * C / ε ≤ ρ := by + dsimp only [ρ, physicalRecenteringScale, C] + exact le_add_of_nonneg_left (by positivity) + have hbudget : 2 * C / ρ ≤ ε := by + apply (div_le_iff₀ hρ0).mpr + simpa only [mul_comm ρ ε] using (div_le_iff₀ hε).mp hpart + calc + _ = (C / ρ) * Z⁻¹ := by dsimp only [C]; ring + _ ≤ (C / ρ) * 2 := mul_le_mul_of_nonneg_left hZi (div_nonneg hC hρ0.le) + _ = 2 * C / ρ := by ring + _ ≤ ε := hbudget + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +def physicalResidueReconstruction {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (v : X → (Unit ⊕ α) → ℤ) : + X → (Unit ⊕ α) → ℤ := + fun d i => physicalCubeRootDifferences root D base residue d i + (q d : ℤ) * v d i + +theorem physicalResidueReconstruction_centered {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (z : Option K × X → ℤ) : + physicalResidueReconstruction root D base residue q (centeredPhysicalCubeMap root D z) = + physicalCubeResidueCoordinates root D base residue q z := by + rw [centeredPhysicalCubeMap_eq] + rfl + +theorem smoothPhysicalResidue_finite_expectation {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) + (Q : Option K × X → ℝ) (hQ : ∀ z, 0 < Q z) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) : + (∑' z, ((smoothProductPMF Q hQ z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base residue q z)) = + ∑ v ∈ centeredPhysicalCubeWindow root D Q, + (((smoothProductPMF Q hQ).map (centeredPhysicalCubeMap root D) v).toReal : ℂ) * + φ (physicalResidueReconstruction root D base residue q v) := by + classical + have h := pmf_image_finite_expectation (smoothProductPMF Q hQ) + (rectangularWeightIndices 0 Q 1) (smoothProductPMF_toReal_zero_off Q hQ) + (centeredPhysicalCubeMap root D) (centeredPhysicalCubeWindow root D Q) + (centeredPhysicalCubeMap_mem_window root D Q) + (fun v => φ (physicalResidueReconstruction root D base residue q v)) + simpa only [physicalResidueReconstruction_centered] using h + +theorem smoothPhysicalResidue_site_error {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) + (Q : Option K × X → ℝ) (hQ : ∀ z, 0 < Q z) + (ψ φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {A E : ℝ} (hA : 0 < A) + (he : ∀ v ∈ centeredPhysicalCubeWindow root D Q, + ‖((A * (((smoothProductPMF Q hQ).map (centeredPhysicalCubeMap root D)) v).toReal : ℝ) : ℂ) - + ψ v‖ ≤ E) : + ‖(∑' z, ((smoothProductPMF Q hQ z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base residue q z)) - + ∑ v ∈ centeredPhysicalCubeWindow root D Q, + (ψ v / (A : ℂ)) * φ (physicalResidueReconstruction root D base residue q v)‖ ≤ + (E / A) * ∑ v ∈ centeredPhysicalCubeWindow root D Q, + ‖φ (physicalResidueReconstruction root D base residue q v)‖ := by + classical + have h := pmf_image_finite_test_error (smoothProductPMF Q hQ) + (rectangularWeightIndices 0 Q 1) (smoothProductPMF_toReal_zero_off Q hQ) + (centeredPhysicalCubeMap root D) (centeredPhysicalCubeWindow root D Q) + (centeredPhysicalCubeMap_mem_window root D Q) ψ + (fun v => φ (physicalResidueReconstruction root D base residue q v)) hA he + simpa only [physicalResidueReconstruction_centered] using h + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +theorem physicalSelectedResidue_width_recenter {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (q : X → ℕ) (hq : ∀ x, 0 < q x) (T : Finset (ColumnResiduePattern (Option K) X q)) + (V : Option K × X → ℝ) (hV : ∀ z, 0 < V z) + (hmass : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + {ρ : ℝ} (hρ : 8 * (probabilityProfileLipschitz : ℝ) ≤ ρ) + (hwidth : ∀ z, ρ ≤ residueProfileWidth q V z) + (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) {B Z : ℝ} + (hB : 0 ≤ B) (hφ : ∀ v, ‖φ v‖ ≤ B) (hZ : 0 < Z) : + ‖(∑' z, ((selectedResidueSmoothPMF q T V hV hmass z).toReal : ℂ) * + φ (physicalCubeRootDifferences root D base z)) / (Z : ℂ) - + (∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * + φ (physicalCubeResidueCoordinates root D base (boundedColumnResidueRepresentative q r.val) q z)) / + (Z : ℂ)‖ ≤ + (B * (24 * (probabilityProfileLipschitz : ℝ) * Fintype.card (Option K × X) / ρ)) / Z := by + have hρ0 : 0 < ρ := by linarith [probabilityProfileLipschitz_one_le] + have hratio (z : Option K × X) : (q z.2 : ℝ) / V z ≤ 1 / ρ := by + have hq0 : (0 : ℝ) < q z.2 := by exact_mod_cast hq z.2 + have h := (le_div_iff₀ hq0).mp (hwidth z) + apply (div_le_div_iff₀ (hV z) hρ0).mpr + linarith + have hsum : (∑ z : Option K × X, (q z.2 : ℝ) / V z) ≤ Fintype.card (Option K × X) / ρ := by + apply (Finset.sum_le_sum (fun z _ => hratio z)).trans_eq + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one_div] + apply (physicalSelectedResidue_recenter_test root D base q hq T V hV hmass + (fun z => hρ.trans (hwidth z)) φ hB hφ hZ).trans + apply div_le_div_of_nonneg_right _ hZ.le + apply mul_le_mul_of_nonneg_left _ hB + simpa only [mul_div_assoc] using mul_le_mul_of_nonneg_left hsum + (show 0 ≤ 24 * (probabilityProfileLipschitz : ℝ) by positivity) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Matrix + +def physicalResidueOffsetShift {K X α : Type*} [Fintype K] + (root root₀ : K → ℤ) (D D₀ : Matrix α K ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) : X → (Unit ⊕ α) → ℤ := + fun d => residueMatrixShift (physicalCubeCoefficient root D) (physicalCubeCoefficient root₀ D₀) + (q d) (fun k => r (k, d)) + +theorem physicalResidueOffsetShift_mem {K X α : Type*} [Fintype K] [Fintype α] + (root root₀ : K → ℤ) (D D₀ : Matrix α K ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ d, 0 < q d) (m : ℕ) + (hres : ∀ d, integerResidueMatrix (physicalCubeCoefficient root D) (q d * m) = + integerResidueMatrix (physicalCubeCoefficient root₀ D₀) (q d * m)) (d : X) : + physicalResidueOffsetShift root root₀ D D₀ r q d ∈ integerScalarLattice (Unit ⊕ α) (m : ℤ) := + (residueMatrixShift_spec _ _ (q d) m (hq d) (hres d) (fun k => r (k, d))).2 + +theorem physicalResidueReconstruction_offset_shift {K X α : Type*} [Fintype K] [Fintype α] + (root root₀ : K → ℤ) (D D₀ : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ d, 0 < q d) (m : ℕ) + (hres : ∀ d, integerResidueMatrix (physicalCubeCoefficient root D) (q d * m) = + integerResidueMatrix (physicalCubeCoefficient root₀ D₀) (q d * m)) + (v : X → (Unit ⊕ α) → ℤ) : + physicalResidueReconstruction root D base r q v = + physicalResidueReconstruction root₀ D₀ base r q + (v + physicalResidueOffsetShift root root₀ D D₀ r q) := by + funext d i + have hs := (residueMatrixShift_spec _ _ (q d) m (hq d) (hres d) (fun k => r (k, d))).1 i + change (q d : ℤ) * physicalResidueOffsetShift root root₀ D D₀ r q d i = _ at hs + change physicalCubeOffset base d i + + (physicalCubeCoefficient root D *ᵥ (fun k => r (k, d))) i + (q d : ℤ) * v d i = + physicalCubeOffset base d i + + (physicalCubeCoefficient root₀ D₀ *ᵥ (fun k => r (k, d))) i + + (q d : ℤ) * (v d i + physicalResidueOffsetShift root root₀ D D₀ r q d i) + rw [mul_add, hs, Matrix.sub_mulVec, Pi.sub_apply] + ring + +theorem physicalResidueOffsetShift_bound {K X α : Type*} [Fintype K] [Fintype α] + (root root₀ : K → ℤ) (D D₀ : Matrix α K ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ d, 0 < q d) (m : ℕ) + (hres : ∀ d, integerResidueMatrix (physicalCubeCoefficient root D) (q d * m) = + integerResidueMatrix (physicalCubeCoefficient root₀ D₀) (q d * m)) + (hr : ∀ k d, |(r (k, d) : ℝ)| ≤ q d) (d : X) (i : Unit ⊕ α) : + |(physicalResidueOffsetShift root root₀ D D₀ r q d i : ℝ)| ≤ + ∑ k, |((physicalCubeCoefficient root D i k - physicalCubeCoefficient root₀ D₀ i k : ℤ) : ℝ)| := + residueMatrixShift_bound _ _ (q d) m (hq d) (hres d) (fun k => r (k, d)) (fun k => hr k d) i + +theorem physicalResidue_test_reference_offset {K X α : Type*} [Fintype K] [Fintype α] + (root root₀ : K → ℤ) (D D₀ : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ d, 0 < q d) (m : ℕ) + (hres : ∀ d, integerResidueMatrix (physicalCubeCoefficient root D) (q d * m) = + integerResidueMatrix (physicalCubeCoefficient root₀ D₀) (q d * m)) + (mass : (X → (Unit ⊕ α) → ℤ) → ℝ) (φ : (X → (Unit ⊕ α) → ℤ) → ℂ) : + (∑' v, (mass v : ℂ) * φ (physicalResidueReconstruction root D base r q v)) = + ∑' v, (mass (v - physicalResidueOffsetShift root root₀ D D₀ r q) : ℂ) * + φ (physicalResidueReconstruction root₀ D₀ base r q v) := by + simp_rw [physicalResidueReconstruction_offset_shift root root₀ D D₀ base r q hq m hres] + have h := (Equiv.addRight (physicalResidueOffsetShift root root₀ D D₀ r q)).tsum_eq + (fun v => (mass (v - physicalResidueOffsetShift root root₀ D D₀ r q) : ℂ) * + φ (physicalResidueReconstruction root₀ D₀ base r q v)) + simpa using h + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalResidueWindowSiteMask.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalResidueWindowSiteMask.lean new file mode 100644 index 0000000000000000000000000000000000000000..194ef753b1d3656b623abeabd18f3381748ebf6c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalResidueWindowSiteMask.lean @@ -0,0 +1,113 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalCubeWindowReindex + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel +open scoped BigOperators Classical + +variable {K X α : Type*} [Fintype K] [Fintype X] [Fintype α] +variable (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) +variable (residue : Option K × X → ℤ) (q : X → ℕ) (H : X → ℝ) (radius : ℝ) + +noncomputable def physicalResidueWindowSiteMask (s : Finset α) (u : X → ℤ) : ℂ := + starVertexSiteFactor (fun i v => if ∀ x, + |(((v x - physicalCubeVertexValue (physicalCubeRootDifferences root D base residue) + (spatialStarVertex i) x) / (q x : ℤ) : ℤ) : ℝ)| ≤ H x * radius then 1 else 0) s u + +theorem physicalResidueWindowSiteMask_bound (s : Finset α) (u : X → ℤ) : + ‖physicalResidueWindowSiteMask root D base residue q H radius s u‖ ≤ 1 := by + apply starVertexSiteFactor_bound + intro i v + split_ifs <;> norm_num + +theorem physicalResidueWindowSiteMask_prod_reconstruction + (hq : ∀ x, 0 < q x) (v : X → (Unit ⊕ α) → ℤ) : + (∏ s, physicalResidueWindowSiteMask root D base residue q H radius s + (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s)) = + if v ∈ spatialWindow H radius then 1 else 0 := by + simp only [physicalResidueWindowSiteMask, starVertexSiteFactor_prod] + have he (i : Unit ⊕ α) (x : X) : + ((physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) + (spatialStarVertex i) x - physicalCubeVertexValue (physicalCubeRootDifferences root D base residue) + (spatialStarVertex i) x) / (q x : ℤ)) = spatialStar (v x) i := by + rw [physicalCubeVertexValue_residueReconstruction, add_sub_cancel_left, + Int.mul_ediv_cancel_left _ (by exact_mod_cast (hq x).ne'), physicalCubeVertexValue_star] + simp only [he] + by_cases hv : v ∈ spatialWindow H radius + · rw [ite_eq_left hv] + apply Finset.prod_eq_one + intro i _ + exact ite_eq_left (fun x => (mem_spatialWindow_iff H radius v).mp hv x i) + · rw [ite_eq_right hv] + have hn : ¬ ∀ i x, |((spatialStar (v x) i : ℤ) : ℝ)| ≤ H x * radius := by + intro h + exact hv ((mem_spatialWindow_iff H radius v).mpr (fun x i => h i x)) + push Not at hn + obtain ⟨i, x, hx⟩ := hn + apply Finset.prod_eq_zero (Finset.mem_univ i) + exact ite_eq_right (fun h => (not_le_of_gt hx) (h x)) + +variable [DecidableEq X] + +theorem physicalResidueWindow_masked_sum_eq_box_sum + {dim : ℕ} (D : Matrix (Fin dim) K ℤ) (N : X → ℕ) (hq : ∀ x, 0 < q x) + (f : Finset (Fin dim) → (X → ℤ) → ℂ) + (hbox : ∀ u, (∏ s, f s (physicalCubeVertexValue u s)) ≠ 0 → + ∀ s, physicalCubeVertexValue u s ∈ integerBox N) + (hresidue : ∀ u, (∏ s, f s (physicalCubeVertexValue u s)) ≠ 0 → + u ∈ Set.range (physicalResidueReconstruction root D base residue q)) : + (∑ v ∈ spatialWindow H radius, + ∏ s, f s (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s)) = + ∑ u ∈ physicalIntegerBoxCubes N dim, + ∏ s, physicalResidueWindowSiteMask root D base residue q H radius s (physicalCubeVertexValue u s) * + f s (physicalCubeVertexValue u s) := by + let mask := physicalResidueWindowSiteMask root D base residue q H radius + let φ := fun u => ∏ s, mask s (physicalCubeVertexValue u s) * f s (physicalCubeVertexValue u s) + have hnonzero (u) (hu : φ u ≠ 0) : (∏ s, f s (physicalCubeVertexValue u s)) ≠ 0 := by + dsimp only [φ] at hu + rw [Finset.prod_mul_distrib] at hu + exact (mul_ne_zero_iff.mp hu).2 + have hpull (v) : φ (physicalResidueReconstruction root D base residue q v) = + (if v ∈ spatialWindow H radius then 1 else 0) * + ∏ s, f s (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s) := by + dsimp only [φ, mask] + rw [Finset.prod_mul_distrib, physicalResidueWindowSiteMask_prod_reconstruction root D base residue q H radius hq] + calc + _ = ∑ v ∈ spatialWindow H radius, φ (physicalResidueReconstruction root D base residue q v) := by + apply Finset.sum_congr rfl + intro v hv + rw [hpull, ite_eq_left hv, one_mul] + _ = _ := physicalResidueWindow_sum_eq_box_sum root D base residue q N hq (spatialWindow H radius) φ + (fun v _ hv => hbox _ (hnonzero _ hv)) + (fun v hv => by rw [hpull, ite_eq_right hv, zero_mul]) + (fun u hu => hresidue u (hnonzero u hu)) + +theorem physicalResidueWindow_norm_le_cube_mean + {dim : ℕ} (D : Matrix (Fin dim) K ℤ) (N : X → ℕ) (hq : ∀ x, 0 < q x) + (f : Finset (Fin dim) → (X → ℤ) → ℂ) + (hbox : ∀ u, (∏ s, f s (physicalCubeVertexValue u s)) ≠ 0 → + ∀ s, physicalCubeVertexValue u s ∈ integerBox N) + (hresidue : ∀ u, (∏ s, f s (physicalCubeVertexValue u s)) ≠ 0 → + u ∈ Set.range (physicalResidueReconstruction root D base residue q)) + {volume C : ℝ} (hvolume : 0 < volume) + (hratio : (integerBoxCubeCount N dim : ℝ) / volume ≤ C) : + ‖(∑ v ∈ spatialWindow H radius, + ∏ s, f s (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s)) / + (volume : ℂ)‖ ≤ + C * ‖𝔼 cube : SupportedCube dim (integerBox N : Set (X → ℤ)), + let u := (physicalCubeParametersEquiv X dim).symm cube.val + ∏ s, physicalResidueWindowSiteMask root D base residue q H radius s (physicalCubeVertexValue u s) * + f s (physicalCubeVertexValue u s)‖ := by + rw [physicalResidueWindow_masked_sum_eq_box_sum root base residue q H radius D N hq f hbox hresidue, + physicalIntegerBoxCubes_sum_eq_count_mul_mean] + rw [norm_div, norm_mul, Complex.norm_natCast, Complex.norm_real, Real.norm_of_nonneg hvolume.le] + rw [mul_div_right_comm] + exact mul_le_mul_of_nonneg_right hratio (norm_nonneg _) + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalSpatialResidueSupport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalSpatialResidueSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..44ae78e7169b583ae6fa19c673118687aee4bf42 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalSpatialResidueSupport.lean @@ -0,0 +1,515 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedReferenceJetWindow + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residueSiteIndicator_affine {m : ℕ} [NeZero m] (q : ℕ) (hq : 0 < q) + (offset : ℤ) (a : ZMod m) (z : ℤ) : + residueSiteIndicator (m := q * m) + ((offset + (q : ℤ) * (a.val : ℤ) : ℤ) : ZMod (q * m)) + (offset + (q : ℤ) * z) = residueSiteIndicator a z := by + have hqz : (q : ℤ) ≠ 0 := by exact_mod_cast hq.ne' + have hval : ((a.val : ℤ) : ZMod m) = a := by simp + have heq : + ((offset + (q : ℤ) * z : ℤ) : ZMod (q * m)) = + ((offset + (q : ℤ) * (a.val : ℤ) : ℤ) : ZMod (q * m)) ↔ + (z : ZMod m) = a := by + calc + _ ↔ ((q * m : ℕ) : ℤ) ∣ + (offset + (q : ℤ) * (a.val : ℤ)) - (offset + (q : ℤ) * z) := + ZMod.intCast_eq_intCast_iff_dvd_sub _ _ _ + _ ↔ (m : ℤ) ∣ (a.val : ℤ) - z := by + rw [Nat.cast_mul, show + (offset + (q : ℤ) * (a.val : ℤ)) - (offset + (q : ℤ) * z) = + (q : ℤ) * ((a.val : ℤ) - z) by ring, mul_dvd_mul_iff_left hqz] + _ ↔ (z : ZMod m) = ((a.val : ℤ) : ZMod m) := + (ZMod.intCast_eq_intCast_iff_dvd_sub _ _ _).symm + _ ↔ (z : ZMod m) = a := by rw [hval] + unfold residueSiteIndicator + simp only [heq] + +noncomputable def affineResidueIntervalSiteWeight (b r H : ℝ) (q : ℕ) + (offset : ℤ) {m : ℕ} (a : ZMod m) (k : Fin (intervalSiteCount b r)) (u : ℤ) : ℝ := + residueSiteIndicator (m := q * m) + ((offset + (q : ℤ) * (a.val : ℤ) : ℤ) : ZMod (q * m)) u * + intervalSiteWeight b r k (((u : ℝ) - offset) / ((q : ℝ) * H)) + +theorem affineResidueIntervalSiteWeight_range (b H : ℝ) {r : ℝ} (hr : 0 < r) + (q : ℕ) (offset : ℤ) {m : ℕ} (a : ZMod m) + (k : Fin (intervalSiteCount b r)) (u : ℤ) : + 0 ≤ affineResidueIntervalSiteWeight b r H q offset a k u ∧ + affineResidueIntervalSiteWeight b r H q offset a k u ≤ 1 := by + have ha := residueSiteIndicator_range + (m := q * m) ((offset + (q : ℤ) * (a.val : ℤ) : ℤ) : ZMod (q * m)) u + have hk := intervalSiteWeight_range b hr k (((u : ℝ) - offset) / ((q : ℝ) * H)) + exact ⟨mul_nonneg ha.1 hk.1, + (mul_le_mul ha.2 hk.2 hk.1 zero_le_one).trans_eq (one_mul 1)⟩ + +theorem affineResidueIntervalSiteWeight_pullback (b r H : ℝ) (q : ℕ) (hq : 0 < q) + (offset : ℤ) {m : ℕ} [NeZero m] (a : ZMod m) + (k : Fin (intervalSiteCount b r)) (z : ℤ) : + affineResidueIntervalSiteWeight b r H q offset a k (offset + (q : ℤ) * z) = + residueIntervalSiteWeight b r H a k z := by + have hqR : (q : ℝ) ≠ 0 := by exact_mod_cast hq.ne' + unfold affineResidueIntervalSiteWeight residueIntervalSiteWeight + rw [residueSiteIndicator_affine q hq] + congr 2 + push_cast + rw [add_sub_cancel_left, mul_div_mul_left _ _ hqR] + +noncomputable def affineVectorResidueSiteWeight {X : Type*} [Fintype X] + (b r : ℝ) (H : X → ℝ) (q : X → ℕ) (offset : X → ℤ) + {m : ℕ} (a : X → ZMod m) (k : X → Fin (intervalSiteCount b r)) (u : X → ℤ) : ℂ := + ∏ x, (affineResidueIntervalSiteWeight b r (H x) (q x) (offset x) (a x) (k x) (u x) : ℂ) + +theorem affineVectorResidueSiteWeight_bound {X : Type*} [Fintype X] + (b : ℝ) {r : ℝ} (hr : 0 < r) (H : X → ℝ) (q : X → ℕ) (offset : X → ℤ) + {m : ℕ} (a : X → ZMod m) (k : X → Fin (intervalSiteCount b r)) (u : X → ℤ) : + ‖affineVectorResidueSiteWeight b r H q offset a k u‖ ≤ 1 := by + rw [affineVectorResidueSiteWeight, norm_prod] + apply Finset.prod_le_one₀ (fun _ _ => norm_nonneg _) + intro x _ + have h := affineResidueIntervalSiteWeight_range b (H x) hr (q x) (offset x) (a x) (k x) (u x) + simpa only [Complex.norm_real, Real.norm_of_nonneg h.1] using h.2 + +theorem affineVectorResidueSiteWeight_pullback {X : Type*} [Fintype X] + (b r : ℝ) (H : X → ℝ) (q : X → ℕ) (hq : ∀ x, 0 < q x) (offset : X → ℤ) + {m : ℕ} [NeZero m] (a : X → ZMod m) (k : X → Fin (intervalSiteCount b r)) + (z : X → ℤ) : + affineVectorResidueSiteWeight b r H q offset a k (fun x => offset x + (q x : ℤ) * z x) = + vectorResidueSiteWeight b r H a k z := by + unfold affineVectorResidueSiteWeight vectorResidueSiteWeight + apply Finset.prod_congr rfl + intro x _ + rw [affineResidueIntervalSiteWeight_pullback b r (H x) (q x) (hq x)] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +theorem affineVectorResidueSiteWeight_factorization {X : Type*} [Fintype X] + (b r : ℝ) (H : X → ℝ) (q : X → ℕ) (offset : X → ℤ) + {m : ℕ} (a : X → ZMod m) (k : X → Fin (intervalSiteCount b r)) (u : X → ℤ) : + affineVectorResidueSiteWeight b r H q offset a k u = + (∏ x, (residueSiteIndicator (m := q x * m) + ((offset x + (q x : ℤ) * ((a x).val : ℤ) : ℤ) : ZMod (q x * m)) (u x) : ℂ)) * + vectorIntervalSiteWeight b r k (fun x => ((u x : ℝ) - offset x) / ((q x : ℝ) * H x)) := by + simp only [affineVectorResidueSiteWeight, affineResidueIntervalSiteWeight, + vectorIntervalSiteWeight, Complex.ofReal_mul, Finset.prod_mul_distrib] + +theorem vectorIntervalSiteWeight_affine_lipschitz {X : Type*} [Fintype X] + (b : ℝ) {r : ℝ≥0} (hr : 0 < r) (k : X → Fin (intervalSiteCount b r)) + (slope shift : X → ℝ) {L : ℝ≥0} (hslope : ∀ x, |slope x| ≤ L) : + LipschitzWith ((Fintype.card X * ((2 * intervalSiteCount b r + 1) / r)) * L) + (fun y : X → ℝ => vectorIntervalSiteWeight b r k (fun x => slope x * y x + shift x)) := by + have haffine : LipschitzWith L (fun y : X → ℝ => fun x => slope x * y x + shift x) := by + apply LipschitzWith.of_dist_le_mul + intro y z + apply (dist_pi_le_iff (mul_nonneg L.coe_nonneg dist_nonneg)).mpr + intro x + calc + dist (slope x * y x + shift x) (slope x * z x + shift x) = + |slope x| * dist (y x) (z x) := by + simp only [Real.dist_eq] + rw [show slope x * y x + shift x - (slope x * z x + shift x) = + slope x * (y x - z x) by ring, abs_mul] + _ ≤ (L : ℝ) * dist y z := + mul_le_mul (hslope x) (dist_le_pi_dist y z x) dist_nonneg L.coe_nonneg + exact (vectorIntervalSiteWeight_lipschitz b hr k).comp haffine + +theorem affineVectorInterval_normalized_lipschitz {X : Type*} [Fintype X] + (b : ℝ) {r : ℝ≥0} (hr : 0 < r) (k : X → Fin (intervalSiteCount b r)) + (H N : X → ℝ) (q : X → ℕ) (offset : X → ℤ) + {L : ℝ≥0} (hscale : ∀ x, |N x / ((q x : ℝ) * H x)| ≤ L) : + LipschitzWith ((Fintype.card X * ((2 * intervalSiteCount b r + 1) / r)) * L) + (fun y : X → ℝ => vectorIntervalSiteWeight b r k + (fun x => (N x * y x - offset x) / ((q x : ℝ) * H x))) := by + have h := vectorIntervalSiteWeight_affine_lipschitz b hr k + (fun x => N x / ((q x : ℝ) * H x)) + (fun x => -(offset x : ℝ) / ((q x : ℝ) * H x)) hscale + convert h using 1 + funext y + congr 1 + funext x + ring + +end Erdos3 + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +theorem physicalCubeVertexValue_residueReconstruction {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) + (v : X → (Unit ⊕ α) → ℤ) (s : Finset α) (x : X) : + physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s x = + physicalCubeVertexValue (physicalCubeRootDifferences root D base residue) s x + + (q x : ℤ) * physicalCubeVertexValue v s x := by + simp only [physicalCubeVertexValue, physicalResidueReconstruction, + Finset.sum_add_distrib, ← Finset.mul_sum] + ring + +noncomputable def physicalResidueStarFactor {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (b r : ℝ) (H : X → ℝ) + {m : ℕ} (t : X → SpatialSiteLabel α m b r) (i : Unit ⊕ α) (u : X → ℤ) : ℂ := + affineVectorResidueSiteWeight b r H q + (physicalCubeVertexValue (physicalCubeRootDifferences root D base residue) (spatialStarVertex i)) + (fun x => (t x).1 i) (fun x => (t x).2 i) u + +noncomputable def physicalResidueSpatialSiteFactor {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (b r : ℝ) (H : X → ℝ) + {m : ℕ} (t : X → SpatialSiteLabel α m b r) (s : Finset α) (u : X → ℤ) : ℂ := + starVertexSiteFactor (physicalResidueStarFactor root D base residue q b r H t) s u + +theorem physicalResidueSpatialSiteFactor_bound {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (b : ℝ) {r : ℝ} (hr : 0 < r) + (H : X → ℝ) {m : ℕ} (t : X → SpatialSiteLabel α m b r) + (s : Finset α) (u : X → ℤ) : + ‖physicalResidueSpatialSiteFactor root D base residue q b r H t s u‖ ≤ 1 := by + apply starVertexSiteFactor_bound + intro i y + exact affineVectorResidueSiteWeight_bound b hr H q _ _ _ y + +theorem physicalResidueStarFactor_pullback {K X α : Type*} [Fintype K] [Fintype X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (b r : ℝ) (H : X → ℝ) {m : ℕ} [NeZero m] + (t : X → SpatialSiteLabel α m b r) (i : Unit ⊕ α) + (v : X → (Unit ⊕ α) → ℤ) : + physicalResidueStarFactor root D base residue q b r H t i + (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) + (spatialStarVertex i)) = + vectorResidueSiteWeight b r H (fun x => (t x).1 i) (fun x => (t x).2 i) + (fun x => spatialStar (v x) i) := by + unfold physicalResidueStarFactor + have hvertex : + physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) + (spatialStarVertex i) = + fun x => physicalCubeVertexValue (physicalCubeRootDifferences root D base residue) + (spatialStarVertex i) x + (q x : ℤ) * spatialStar (v x) i := by + funext x + rw [physicalCubeVertexValue_residueReconstruction, physicalCubeVertexValue_star v i] + rw [hvertex] + exact affineVectorResidueSiteWeight_pullback b r H q hq _ _ _ _ + +theorem physicalResidueSpatialSiteFactor_prod {K X α : Type*} + [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (b r : ℝ) (H : X → ℝ) {m : ℕ} [NeZero m] + (t : X → SpatialSiteLabel α m b r) (v : X → (Unit ⊕ α) → ℤ) : + (∏ s, physicalResidueSpatialSiteFactor root D base residue q b r H t s + (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s)) = + ∏ i, vectorResidueSiteWeight b r H (fun x => (t x).1 i) (fun x => (t x).2 i) + (fun x => spatialStar (v x) i) := by + unfold physicalResidueSpatialSiteFactor + rw [starVertexSiteFactor_prod] + apply Finset.prod_congr rfl + intro i _ + exact physicalResidueStarFactor_pullback root D base residue q hq b r H t i v + +theorem physicalResidue_spatialSiteExpansion {K X J : Type*} {dim : ℕ} + [Fintype K] [Fintype X] [DecidableEq X] [Fintype J] + (root : K → ℤ) (D : Matrix (Fin dim) K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (A : Matrix (Unit ⊕ Fin dim) (Unit ⊕ Fin dim) ℤ) + (B : X → Matrix (Unit ⊕ Fin dim) J ℤ) (m : ℕ) [NeZero m] + (f : X → ((Unit ⊕ Fin dim) → ℝ) → ℝ) (H : X → ℝ) (b r : ℝ) + (v : X → (Unit ⊕ Fin dim) → ℤ) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) : + (∏ x, spatialSiteApprox A (B x) m (f x) (H x) b r (v x)) * + physicalCubeSiteTest test (physicalResidueReconstruction root D base residue q v) = + ∑ t : X → SpatialSiteLabel (Fin dim) m b r, + (∏ x, spatialSiteCoefficient A (B x) m (f x) b r (t x)) * + ∏ s, test s (fun x => + (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s x : ℝ)) * + physicalResidueSpatialSiteFactor root D base residue q b r H t s + (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s) := by + rw [vectorSpatialSiteExpansion, Finset.sum_mul] + apply Finset.sum_congr rfl + intro t _ + rw [mul_assoc, Finset.prod_mul_distrib, + physicalResidueSpatialSiteFactor_prod root D base residue q hq] + congr 1 + exact mul_comm _ _ + +theorem exists_physicalResidue_spatialSiteExpansion {K X J : Type*} {dim : ℕ} + [Fintype K] [Fintype X] [DecidableEq X] [Fintype J] + (root : K → ℤ) (D : Matrix (Fin dim) K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (A : Matrix (Unit ⊕ Fin dim) (Unit ⊕ Fin dim) ℤ) + (B : X → Matrix (Unit ⊕ Fin dim) J ℤ) (m : ℕ) [NeZero m] + (f : X → ((Unit ⊕ Fin dim) → ℝ) → ℝ) (H : X → ℝ) (b : ℝ) {r : ℝ} (hr : 0 < r) + {G C : ℝ} (hindex : ∀ x, ((pivotFullImage A (B x)).toAddSubgroup.index : ℝ) ≤ G) + (hf : ∀ x y, |f x y| ≤ C) : + ∃ coefficient : (X → SpatialSiteLabel (Fin dim) m b r) → ℂ, + ∃ twist : (X → SpatialSiteLabel (Fin dim) m b r) → Finset (Fin dim) → (X → ℤ) → ℂ, + (∑ t, ‖coefficient t‖) ≤ + ((m : ℝ)^Fintype.card (Unit ⊕ Fin dim) * + (intervalSiteCount b r : ℝ)^Fintype.card (Unit ⊕ Fin dim) * (G * C))^Fintype.card X ∧ + (∀ t s u, ‖twist t s u‖ ≤ 1) ∧ + ∀ (v : X → (Unit ⊕ Fin dim) → ℤ) (test : Finset (Fin dim) → (X → ℝ) → ℂ), + (∏ x, spatialSiteApprox A (B x) m (f x) (H x) b r (v x)) * + physicalCubeSiteTest test (physicalResidueReconstruction root D base residue q v) = + ∑ t, coefficient t * ∏ s, + test s (fun x => + (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s x : ℝ)) * + twist t s (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s) := by + refine ⟨fun t => ∏ x, spatialSiteCoefficient A (B x) m (f x) b r (t x), + physicalResidueSpatialSiteFactor root D base residue q b r H, ?_, ?_, ?_⟩ + · exact vectorSpatialSiteCoefficient_sum_bound A B m f b r hindex hf + · intro t s u + exact physicalResidueSpatialSiteFactor_bound root D base residue q b hr H t s u + · intro v test + exact physicalResidue_spatialSiteExpansion root D base residue q hq A B m f H b r v test + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators NNReal + +theorem exists_physicalResidue_coarseSiteExpansion {K X J : Type*} {dim : ℕ} + [Fintype K] [Fintype X] [DecidableEq X] [Fintype J] + (root : K → ℤ) (D : Matrix (Fin dim) K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (A : Matrix (Unit ⊕ Fin dim) (Unit ⊕ Fin dim) ℤ) + (B : X → Matrix (Unit ⊕ Fin dim) J ℤ) (m : ℕ) [NeZero m] + (hp : ∀ x, integerScalarLattice (Unit ⊕ Fin dim) (m : ℤ) ≤ pivotFullImage A (B x)) + (f : X → ((Unit ⊕ Fin dim) → ℝ) → ℝ) {Lip : ℝ≥0} + (hf : ∀ x, LipschitzWith Lip (f x)) + (H : X → ℝ) {G C b coarse : ℝ} (hG : 0 ≤ G) (hC : 0 ≤ C) + (hindex : ∀ x, ((pivotFullImage A (B x)).toAddSubgroup.index : ℝ) ≤ G) + (hcap : ∀ x y, |f x y| ≤ C) (hb : 0 < b) (hcoarse : 0 < coarse) : + ∃ coefficient : (X → SpatialSiteLabel (Fin dim) m b coarse) → ℂ, + ∃ twist : (X → SpatialSiteLabel (Fin dim) m b coarse) → Finset (Fin dim) → (X → ℤ) → ℂ, + (∑ t, ‖coefficient t‖) ≤ + ((m : ℝ)^Fintype.card (Unit ⊕ Fin dim) * + (intervalSiteCount b coarse : ℝ)^Fintype.card (Unit ⊕ Fin dim) * (G * C))^Fintype.card X ∧ + (∀ t s u, ‖twist t s u‖ ≤ 1) ∧ + ∀ (fine : ℝ), 0 < fine → fine ≤ coarse → + ∀ (v : X → (Unit ⊕ Fin dim) → ℤ), + (∀ x i, |((spatialStar (v x) i : ℤ) : ℝ) / H x| ≤ b) → + ∀ (test : Finset (Fin dim) → (X → ℝ) → ℂ), (∀ s u, ‖test s u‖ ≤ 1) → + ‖(∏ x, spatialSiteApprox A (B x) m (f x) (H x) b fine (v x)) * + physicalCubeSiteTest test (physicalResidueReconstruction root D base residue q v) - + ∑ t, coefficient t * ∏ s, + test s (fun x => + (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s x : ℝ)) * + twist t s (physicalCubeVertexValue (physicalResidueReconstruction root D base residue q v) s)‖ ≤ + Fintype.card X * (8 * G * Lip * coarse) * (1 + G * C)^Fintype.card X := by + obtain ⟨coefficient, twist, hcoeff, htwist, hexact⟩ := + exists_physicalResidue_spatialSiteExpansion root D base residue q hq A B m f H b hcoarse hindex hcap + refine ⟨coefficient, twist, hcoeff, htwist, ?_⟩ + intro fine hfine hle v hv test htest + rw [← hexact v test, ← sub_mul, norm_mul] + have herror := vectorSpatialSiteApprox_remesh A B m hp f hf H hG hC hindex hcap hb + hfine hcoarse v hv + have htest' := physicalCubeSiteTest_norm_le test htest + (physicalResidueReconstruction root D base residue q v) + calc + _ ≤ Fintype.card X * (4 * G * Lip * (fine + coarse)) * (1 + G * C)^Fintype.card X := + (mul_le_mul herror htest' (norm_nonneg _) (by positivity)).trans_eq (mul_one _) + _ ≤ Fintype.card X * (4 * G * Lip * (coarse + coarse)) * (1 + G * C)^Fintype.card X := by + gcongr + _ = _ := by ring + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Classical + +def physicalResidueQuotient {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (u : X → (Unit ⊕ α) → ℤ) : + X → (Unit ⊕ α) → ℤ := + fun x i => (u x i - physicalCubeRootDifferences root D base r x i) / (q x : ℤ) + +theorem physicalResidueQuotient_reconstruction {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (v : X → (Unit ⊕ α) → ℤ) : + physicalResidueQuotient root D base r q + (physicalResidueReconstruction root D base r q v) = v := by + funext x i + have hn : (q x : ℤ) ≠ 0 := by exact_mod_cast (hq x).ne' + simp only [physicalResidueQuotient, physicalResidueReconstruction, + add_sub_cancel_left, Int.mul_ediv_cancel_left _ hn] + +theorem physicalResidueReconstruction_quotient {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (u : X → (Unit ⊕ α) → ℤ) + (hu : ∀ x i, (u x i : ZMod (q x)) = + (physicalCubeRootDifferences root D base r x i : ZMod (q x))) : + physicalResidueReconstruction root D base r q + (physicalResidueQuotient root D base r q u) = u := by + funext x i + have hd := (ZMod.intCast_eq_intCast_iff_dvd_sub + (physicalCubeRootDifferences root D base r x i) (u x i) (q x)).mp (hu x i).symm + simp only [physicalResidueReconstruction, physicalResidueQuotient, + Int.mul_ediv_cancel' hd, add_sub_cancel] + +theorem physicalResidueReconstruction_mem_range_iff {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (u : X → (Unit ⊕ α) → ℤ) : + u ∈ Set.range (physicalResidueReconstruction root D base r q) ↔ + ∀ x i, (u x i : ZMod (q x)) = + (physicalCubeRootDifferences root D base r x i : ZMod (q x)) := by + constructor + · rintro ⟨v, rfl⟩ x i + simp [physicalResidueReconstruction] + · intro hu + exact ⟨physicalResidueQuotient root D base r q u, + physicalResidueReconstruction_quotient root D base r q u hu⟩ + +theorem physicalResidueReconstruction_mem_range_star_iff {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (u : X → (Unit ⊕ α) → ℤ) : + u ∈ Set.range (physicalResidueReconstruction root D base r q) ↔ + ∀ x i, ((spatialStar (u x) i : ℤ) : ZMod (q x)) = + ((spatialStar (physicalCubeRootDifferences root D base r x) i : ℤ) : ZMod (q x)) := by + rw [physicalResidueReconstruction_mem_range_iff] + constructor + · intro hu x i + cases i with + | inl i => cases i; exact hu x (.inl ()) + | inr i => simpa only [spatialStar, Sum.elim_inr, Int.cast_add] using + congrArg₂ (· + ·) (hu x (.inl ())) (hu x (.inr i)) + · intro hu x i + have hr := hu x (.inl ()) + change (u x (.inl ()) : ZMod (q x)) = + (physicalCubeRootDifferences root D base r x (.inl ()) : ZMod (q x)) at hr + cases i with + | inl i => cases i; exact hr + | inr i => + have hi := hu x (.inr i) + simp only [spatialStar, Sum.elim_inr, Int.cast_add, hr] at hi + exact add_left_cancel hi + +theorem physicalResidueReconstruction_mem_range_sites_iff {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (u : X → (Unit ⊕ α) → ℤ) : + u ∈ Set.range (physicalResidueReconstruction root D base r q) ↔ + ∀ (s : Finset α) x, (physicalCubeVertexValue u s x : ZMod (q x)) = + (physicalCubeVertexValue (physicalCubeRootDifferences root D base r) s x : ZMod (q x)) := by + constructor + · rintro ⟨v, rfl⟩ s x + simp [physicalCubeVertexValue_residueReconstruction] + · intro hu + apply (physicalResidueReconstruction_mem_range_star_iff root D base r q u).mpr + intro x i + simpa only [physicalCubeVertexValue_star] using hu (spatialStarVertex i) x + +theorem physicalResidueReconstruction_mem_image_iff {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (r : Option K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (window : Finset (X → (Unit ⊕ α) → ℤ)) (u : X → (Unit ⊕ α) → ℤ) : + u ∈ window.image (physicalResidueReconstruction root D base r q) ↔ + (∀ x i, (u x i : ZMod (q x)) = + (physicalCubeRootDifferences root D base r x i : ZMod (q x))) ∧ + physicalResidueQuotient root D base r q u ∈ window := by + classical + constructor + · intro hu + obtain ⟨v, hv, rfl⟩ := Finset.mem_image.mp hu + refine ⟨(physicalResidueReconstruction_mem_range_iff root D base r q _).mp ⟨v, rfl⟩, ?_⟩ + simpa only [physicalResidueQuotient_reconstruction root D base r q hq] using hv + · rintro ⟨hu, hw⟩ + exact Finset.mem_image.mpr ⟨physicalResidueQuotient root D base r q u, hw, + physicalResidueReconstruction_quotient root D base r q u hu⟩ + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Classical + +theorem affineResidueIntervalSiteWeight_nonzero_residue + (b r H : ℝ) (q : ℕ) (offset : ℤ) {m : ℕ} (a : ZMod m) + (k : Fin (intervalSiteCount b r)) (u : ℤ) + (hu : affineResidueIntervalSiteWeight b r H q offset a k u ≠ 0) : + (u : ZMod q) = (offset : ZMod q) := by + have he : (u : ZMod (q * m)) = + ((offset + (q : ℤ) * (a.val : ℤ) : ℤ) : ZMod (q * m)) := by + by_contra h + exact hu (by simp only [affineResidueIntervalSiteWeight, residueSiteIndicator, ite_eq_right h, zero_mul]) + have hd := (ZMod.intCast_eq_intCast_iff_dvd_sub u + (offset + (q : ℤ) * (a.val : ℤ)) (q * m)).mp he + have hq : (q : ℤ) ∣ ((q * m : ℕ) : ℤ) := by + rw [Nat.cast_mul] + exact dvd_mul_right _ _ + have hs := (hq.trans hd).sub (dvd_mul_right (q : ℤ) (a.val : ℤ)) + have heq : (offset + (q : ℤ) * (a.val : ℤ) - u) - (q : ℤ) * (a.val : ℤ) = + offset - u := by ring + rw [heq] at hs + exact (ZMod.intCast_eq_intCast_iff_dvd_sub u offset q).mpr hs + +theorem affineVectorResidueSiteWeight_nonzero_residue {X : Type*} [Fintype X] + (b r : ℝ) (H : X → ℝ) (q : X → ℕ) (offset : X → ℤ) + {m : ℕ} (a : X → ZMod m) (k : X → Fin (intervalSiteCount b r)) (u : X → ℤ) + (hu : affineVectorResidueSiteWeight b r H q offset a k u ≠ 0) : + ∀ x, (u x : ZMod (q x)) = (offset x : ZMod (q x)) := by + intro x + have hx := (Finset.prod_ne_zero_iff.mp hu) x (Finset.mem_univ x) + apply affineResidueIntervalSiteWeight_nonzero_residue b r (H x) (q x) + (offset x) (a x) (k x) (u x) + intro hz + exact hx (by simp only [hz, Complex.ofReal_zero]) + +theorem physicalResidueSpatialSiteFactor_prod_nonzero_mem_range + {K X α : Type*} [Fintype K] [Fintype X] [Fintype α] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (residue : Option K × X → ℤ) (q : X → ℕ) (b r : ℝ) (H : X → ℝ) + {m : ℕ} (t : X → SpatialSiteLabel α m b r) (u : X → (Unit ⊕ α) → ℤ) + (hu : (∏ s, physicalResidueSpatialSiteFactor root D base residue q b r H t s + (physicalCubeVertexValue u s)) ≠ 0) : + u ∈ Set.range (physicalResidueReconstruction root D base residue q) := by + simp only [physicalResidueSpatialSiteFactor, starVertexSiteFactor_prod] at hu + apply (physicalResidueReconstruction_mem_range_star_iff root D base residue q u).mpr + intro x i + have hi := (Finset.prod_ne_zero_iff.mp hu) i (Finset.mem_univ i) + have hx := affineVectorResidueSiteWeight_nonzero_residue b r H q + (physicalCubeVertexValue (physicalCubeRootDifferences root D base residue) (spatialStarVertex i)) + (fun x => (t x).1 i) (fun x => (t x).2 i) + (physicalCubeVertexValue u (spatialStarVertex i)) hi x + simpa only [physicalCubeVertexValue_star] using hx + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalSubboxResidueSlice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalSubboxResidueSlice.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa3977b82a5fb5e16af9f399c48fb4dedea7edf9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PhysicalSubboxResidueSlice.lean @@ -0,0 +1,784 @@ +import OAI.Combinatorics.Progressions.Estimates.CubeTranslation +import OAI.Combinatorics.Progressions.Estimates.CyclicCutNeighborhood +import OAI.Combinatorics.Progressions.Estimates.PhysicalSliceCost +import OAI.Combinatorics.Progressions.Estimates.WeightedOverlapCorrelation +import OAI.Combinatorics.Progressions.Lattices.BoxResiduePartition +import OAI.Combinatorics.Progressions.Lattices.ResidueSliceNormalizedCell + +namespace OAI + +section + +open scoped BigOperators + +namespace Erdos3 + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def integerBox (T : ι → ℕ) : Finset (ι → ℤ) := + Fintype.piFinset (fun i ↦ Finset.Ico (0 : ℤ) (T i)) + +@[simp] theorem mem_integerBox (T : ι → ℕ) (x : ι → ℤ) : + x ∈ integerBox T ↔ ∀ i, 0 ≤ x i ∧ x i < T i := by + simp [integerBox, Fintype.mem_piFinset] + +abbrev BoxAmbient (T : ι → ℕ) := ∀ i, ZMod (4 * T i) + +def boxReduction (T : ι → ℕ) : (ι → ℤ) →+ BoxAmbient T where + toFun x i := x i + map_zero' := by funext i; simp + map_add' x y := by funext i; simp + +omit [Fintype ι] [DecidableEq ι] in +@[simp] theorem boxReduction_apply (T : ι → ℕ) (x : ι → ℤ) (i : ι) : + boxReduction T x i = (x i : ZMod (4 * T i)) := rfl + +omit [Fintype ι] [DecidableEq ι] in +theorem int_eq_of_zmod_eq_of_bounds {m : ℕ} {a b : ℤ} + (ha : 0 ≤ a ∧ a < m) (hb : 0 ≤ b ∧ b < m) (he : (a : ZMod m) = (b : ZMod m)) : + a = b := by + have hm := (ZMod.intCast_eq_intCast_iff' a b m).mp he + simpa only [Int.emod_eq_of_lt ha.1 ha.2, Int.emod_eq_of_lt hb.1 hb.2] using hm + +theorem boxReduction_reflectsPairSums (T : ι → ℕ) : + ReflectsPairSums (boxReduction T) (integerBox T : Set (ι → ℤ)) := by + intro a ha b hb c hc d hd he + have ha' := (mem_integerBox T a).mp ha + have hb' := (mem_integerBox T b).mp hb + have hc' := (mem_integerBox T c).mp hc + have hd' := (mem_integerBox T d).mp hd + funext i + change a i + b i = c i + d i + apply int_eq_of_zmod_eq_of_bounds (m := 4 * T i) + · have h1 := ha' i + have h2 := hb' i + constructor <;> push_cast <;> omega + · have h1 := hc' i + have h2 := hd' i + constructor <;> push_cast <;> omega + · have hi := congrFun he i + simpa only [Pi.add_apply, boxReduction_apply, Int.cast_add] using hi + +theorem boxReduction_injOn (T : ι → ℕ) : + Set.InjOn (boxReduction T) (integerBox T : Set (ι → ℤ)) := + (boxReduction_reflectsPairSums T).injOn + +noncomputable def integerBoxCubeEquiv (T : ι → ℕ) (j : ℕ) : + SupportedCube j (integerBox T : Set (ι → ℤ)) ≃ + SupportedCube j (boxReduction T '' (integerBox T : Set (ι → ℤ))) := + supportedCubeEquiv (boxReduction_reflectsPairSums T) j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem integerBox_expect_eq_zmod {ι : Type*} [Fintype ι] [DecidableEq ι] + (N : ℕ) [NeZero N] (f : (ι → ℤ) → ℂ) : + (𝔼 x ∈ integerBox (fun _ : ι => N), f x) = + 𝔼 t : ι → ZMod N, f (fun i => ((t i).val : ℤ)) := by + symm + apply Finset.expect_bij (fun t _ i => ((t i).val : ℤ)) + · intro t _ + rw [mem_integerBox] + exact fun i => ⟨Int.natCast_nonneg _, by exact_mod_cast (t i).val_lt⟩ + · intro t _ + rfl + · intro t _ u _ h + funext i + apply ZMod.val_injective N + exact_mod_cast congrFun h i + · intro x hx + have hx' := (mem_integerBox (fun _ : ι => N) x).mp hx + refine ⟨(fun i => (x i : ZMod N)), Finset.mem_univ _, ?_⟩ + funext i + rw [ZMod.val_intCast, Int.emod_eq_of_lt (hx' i).1 (hx' i).2] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem integerBox_subtype_mean_eq_fin {X : Type*} [Fintype X] [DecidableEq X] + (N : X → ℕ) (F : (X → ℤ) → ℝ) : + (𝔼 u : ↥(integerBox N), F u.val) = + (𝔼 u : (∀ i, Fin (N i)), F (fun i => ((u i).val : ℤ))) := by + classical + symm + let lift : (∀ i, Fin (N i)) → ↥(integerBox N) := fun u => + ⟨(fun i => ((u i).val : ℤ)), (mem_integerBox N _).mpr (fun i => + ⟨by positivity, by exact_mod_cast (u i).isLt⟩)⟩ + apply Finset.expect_nbij lift + · intro u _ + exact Finset.mem_univ _ + · intro u _ + rfl + · intro u _ v _ huv + funext i + apply Fin.ext + have h := congrFun (congrArg Subtype.val huv) i + change ((u i).val : ℤ) = ((v i).val : ℤ) at h + exact_mod_cast h + · intro u _ + have hu := (mem_integerBox N u.val).mp u.property + let v : ∀ i, Fin (N i) := fun i => ⟨(u.val i).toNat, by + have hi := hu i + omega⟩ + refine ⟨v, Finset.mem_univ _, ?_⟩ + apply Subtype.ext + funext i + exact Int.toNat_of_nonneg (hu i).1 + +end Erdos3 + +end + +section + +namespace Erdos3 + +def integerCyclicMap (N : ℕ) : ℤ →+ ZMod N := Int.castAddHom (ZMod N) + +theorem integerInterval_reflectsPairSums (N : ℕ) (a b : ℤ) + (hdiam : 2 * (b - a - 1) < (N : ℤ)) : + ReflectsPairSums (integerCyclicMap N) (Finset.Ico a b : Set ℤ) := by + intro x hx y hy z hz t ht he + have hx' := Finset.mem_Ico.mp hx + have hy' := Finset.mem_Ico.mp hy + have hz' := Finset.mem_Ico.mp hz + have ht' := Finset.mem_Ico.mp ht + have hxy : 0 ≤ x + y - 2 * a ∧ x + y - 2 * a < N := by omega + have hzt : 0 ≤ z + t - 2 * a ∧ z + t - 2 * a < N := by omega + have he' : ((x + y - 2 * a : ℤ) : ZMod N) = ((z + t - 2 * a : ℤ) : ZMod N) := by + change (x : ZMod N) + y = (z : ZMod N) + t at he + push_cast + exact congrArg (fun v : ZMod N => v - 2 * (a : ZMod N)) he + have hh := int_eq_of_zmod_eq_of_bounds hxy hzt he' + omega + +theorem integerInterval_image_cyclicInterval (N : ℕ) (a : ℤ) (L : ℕ) : + (Finset.Ico a (a + L)).image (integerCyclicMap N) = cyclicInterval (a : ZMod N) L := by + ext x + constructor + · intro hx + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hx + have hy' := Finset.mem_Ico.mp hy + refine Finset.mem_image.mpr ⟨(y - a).toNat, Finset.mem_range.mpr ?_, ?_⟩ + · omega + · change (a : ZMod N) + ((y - a).toNat : ZMod N) = (y : ZMod N) + have he : (((y - a).toNat : ℕ) : ℤ) = y - a := Int.toNat_of_nonneg (by omega) + rw [← Int.cast_natCast, he] + push_cast + ring + · intro hx + obtain ⟨k, hk, rfl⟩ := Finset.mem_image.mp hx + refine Finset.mem_image.mpr ⟨a + k, Finset.mem_Ico.mpr ?_, ?_⟩ + · have hk' := Finset.mem_range.mp hk + omega + · change ((a + k : ℤ) : ZMod N) = (a : ZMod N) + k + push_cast + rfl + +end Erdos3 + +end + +section + +open scoped BigOperators + +namespace Erdos3 + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def integerBoxCubeCount (T : ι → ℕ) (j : ℕ) : ℕ := + Nat.card (SupportedCube j (integerBox T : Set (ι → ℤ))) + +noncomputable def integerBoxGowersNorm (T : ι → ℕ) (j : ℕ) (f : (ι → ℤ) → ℂ) : ℝ := + finiteSupportGowersNorm j (integerBox T) f + +variable (T : ι → ℕ) [∀ i, NeZero (T i)] + +theorem integerBox_nonempty : (integerBox T).Nonempty := by + refine ⟨0, (mem_integerBox T 0).mpr ?_⟩ + intro i + change 0 ≤ (0 : ℤ) ∧ (0 : ℤ) < T i + exact ⟨le_rfl, by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne (T i))⟩ + +theorem integerBoxCubeCount_eq_groupCubeCount (j : ℕ) : + integerBoxCubeCount T j = groupCubeCount j ((integerBox T).image (boxReduction T)) := + card_supportedCube_image (boxReduction_reflectsPairSums T) j + +theorem integerBoxCubeCount_pos (j : ℕ) : 0 < integerBoxCubeCount T j := by + rw [integerBoxCubeCount_eq_groupCubeCount] + exact groupCubeCount_pos j ((integerBox_nonempty T).image (boxReduction T)) + +theorem integerBoxGowersNorm_one (j : ℕ) : + integerBoxGowersNorm T j (fun _ ↦ 1) = 1 := + finiteSupportGowersNorm_one j (integerBox_nonempty T) + +theorem integerBoxGowersNorm_eq_restricted (j : ℕ) (f : (ι → ℤ) → ℂ) : + integerBoxGowersNorm T (j + 1) f = + restrictedGowersNorm (j + 1) ((integerBox T).image (boxReduction T)) + (imageExtension (boxReduction T) (integerBox T) f) := + finiteSupportGowersNorm_eq_restricted (boxReduction_reflectsPairSums T) j f + +theorem integerBoxGowersNorm_ambient_comparison (j : ℕ) (f : (ι → ℤ) → ℂ) : + gowersNorm (j + 1) (imageExtension (boxReduction T) (integerBox T) f) ^ (2 ^ (j + 1)) = + ((integerBoxCubeCount T (j + 1) : ℝ) / (Fintype.card (BoxAmbient T) : ℝ) ^ (j + 2)) * + integerBoxGowersNorm T (j + 1) f ^ (2 ^ (j + 1)) := + finiteSupportGowersNorm_ambient_comparison (boxReduction_reflectsPairSums T) j f + +theorem integerBoxGowersNorm_add (j : ℕ) (f g : (ι → ℤ) → ℂ) : + integerBoxGowersNorm T (j + 1) (fun x ↦ f x + g x) ≤ + integerBoxGowersNorm T (j + 1) f + integerBoxGowersNorm T (j + 1) g := + finiteSupportGowersNorm_add_of_embedding (boxReduction_reflectsPairSums T) j f g + +theorem integerBoxGowersNorm_degree_one (f : (ι → ℤ) → ℂ) : + integerBoxGowersNorm T 1 f = ‖𝔼 x ∈ integerBox T, f x‖ := + finiteSupportGowersNorm_degree_one_of_embedding (boxReduction_reflectsPairSums T) + (integerBox_nonempty T) f + +theorem integerBoxGowersNorm_pow_tsum (j : ℕ) (f : (ι → ℤ) → ℂ) : + integerBoxGowersNorm T (j + 1) f ^ (2 ^ (j + 1)) = + (∑' p : (Fin (j + 1) → (ι → ℤ)) × (ι → ℤ), + mixedCubeProduct (fun _ ↦ restrictTo (integerBox T) f) p.1 p.2).re / + integerBoxCubeCount T (j + 1) := by + rw [integerBoxGowersNorm_eq_restricted, + restrictedGowersNorm_imageExtension_pow (boxReduction_reflectsPairSums T), + supportedCubeSum_eq_tsum] + rfl + +theorem integerBox_mixed_cauchy_schwarz (j : ℕ) + (F : (Fin (j + 1) → Bool) → (ι → ℤ) → ℂ) : + ‖supportedCubeSum (j + 1) (integerBox T : Set (ι → ℤ)) F‖ / + integerBoxCubeCount T (j + 1) ≤ + ∏ ω, integerBoxGowersNorm T (j + 1) (F ω) := + norm_supportedCubeSum_le_of_embedding (boxReduction_reflectsPairSums T) j F + +end Erdos3 + +end + +section + +open scoped BigOperators + +namespace Erdos3 + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem card_integerBox (T : ι → ℕ) : (integerBox T).card = ∏ i, T i := by + simp [integerBox] + +def smallCubeSide (T : ι → ℕ) (j : ℕ) (i : ι) : ℕ := (T i - 1) / (j + 1) + 1 + +variable (T : ι → ℕ) [∀ i, NeZero (T i)] + +theorem small_increments_supported (j : ℕ) (x : ι → ℤ) + (hx : x ∈ integerBox (smallCubeSide T j)) (ds : Fin j → (ι → ℤ)) + (hds : ∀ k, ds k ∈ integerBox (smallCubeSide T j)) (ω : Fin j → Bool) : + x + cubeShift ds ω ∈ integerBox T := by + apply (mem_integerBox T _).mpr + intro i + let m := (T i - 1) / (j + 1) + have hxi : 0 ≤ x i ∧ x i ≤ (m : ℤ) := by + have h := (mem_integerBox _ _).mp hx i + change 0 ≤ x i ∧ x i < ((m + 1 : ℕ) : ℤ) at h + push_cast at h + omega + have hdi (k : Fin j) : 0 ≤ ds k i ∧ ds k i ≤ (m : ℤ) := by + have h := (mem_integerBox _ _).mp (hds k) i + change 0 ≤ ds k i ∧ ds k i < ((m + 1 : ℕ) : ℤ) at h + push_cast at h + omega + have hlo : 0 ≤ ∑ k, if ω k then ds k i else (0 : ℤ) := by + apply Finset.sum_nonneg + intro k hk + split_ifs + · exact (hdi k).1 + · exact le_rfl + have hhi : (∑ k, if ω k then ds k i else (0 : ℤ)) ≤ (j : ℤ) * m := by + calc + _ ≤ ∑ _k : Fin j, (m : ℤ) := by + apply Finset.sum_le_sum + intro k hk + split_ifs + · exact (hdi k).2 + · exact Int.natCast_nonneg _ + _ = _ := by simp + have hm : ((j : ℤ) + 1) * (m : ℤ) < T i := by + have hmul := Nat.mul_div_le (T i - 1) (j + 1) + have hT := Nat.pos_of_ne_zero (NeZero.ne (T i)) + have hlt : (j + 1) * m < T i := hmul.trans_lt (Nat.sub_lt hT (by omega)) + exact_mod_cast hlt + simp only [Pi.add_apply, cubeShift, Finset.sum_apply, ite_apply, Pi.zero_apply] + constructor <;> nlinarith [hxi.1, hxi.2] + +noncomputable def smallBoxCubeMap (j : ℕ) : + ((Fin j → integerBox (smallCubeSide T j)) × integerBox (smallCubeSide T j)) → + SupportedCube j (integerBox T : Set (ι → ℤ)) := + fun p ↦ ⟨(fun k ↦ (p.1 k).val, p.2.val), + small_increments_supported T j p.2.val p.2.property + (fun k ↦ (p.1 k).val) (fun k ↦ (p.1 k).property)⟩ + +theorem smallBoxCubeMap_injective (j : ℕ) : Function.Injective (smallBoxCubeMap T j) := by + intro p q he + apply Prod.ext + · funext k + apply Subtype.ext + exact congrArg (fun r ↦ r.val.1 k) he + · apply Subtype.ext + exact congrArg (fun r ↦ r.val.2) he + +theorem small_box_card_pow_le_cubeCount (j : ℕ) : + (integerBox (smallCubeSide T j)).card ^ (j + 1) ≤ integerBoxCubeCount T j := by + have h := Nat.card_le_card_of_injective (smallBoxCubeMap T j) (smallBoxCubeMap_injective T j) + change Nat.card ((Fin j → integerBox (smallCubeSide T j)) × integerBox (smallCubeSide T j)) ≤ + integerBoxCubeCount T j at h + simpa only [Nat.card_eq_fintype_card, Fintype.card_prod, Fintype.card_fun, + Fintype.card_coe, Fintype.card_fin, pow_succ] using h + +theorem card_integerBox_le_small_box (j : ℕ) : + (integerBox T).card ≤ (j + 1) ^ Fintype.card ι * (integerBox (smallCubeSide T j)).card := by + have hi (i : ι) : T i ≤ (j + 1) * smallCubeSide T j i := by + have h := Nat.lt_mul_div_succ (T i - 1) (Nat.succ_pos j) + change T i - 1 < (j + 1) * ((T i - 1) / (j + 1) + 1) at h + have hT := Nat.pos_of_ne_zero (NeZero.ne (T i)) + change T i ≤ (j + 1) * ((T i - 1) / (j + 1) + 1) + omega + calc + _ = ∏ i, T i := card_integerBox T + _ ≤ ∏ i, (j + 1) * smallCubeSide T j i := + Finset.prod_le_prod₀ (fun _ _ ↦ Nat.zero_le _) (fun i _ ↦ hi i) + _ = _ := by rw [Finset.prod_mul_distrib, Finset.prod_const]; simp [card_integerBox] + +theorem integerBoxCubeCount_lower (j : ℕ) : + (integerBox T).card ^ (j + 1) ≤ + (j + 1) ^ (Fintype.card ι * (j + 1)) * integerBoxCubeCount T j := by + have h := Nat.pow_le_pow_left (card_integerBox_le_small_box T j) (j + 1) + rw [mul_pow, ← pow_mul] at h + exact h.trans (Nat.mul_le_mul_left _ (small_box_card_pow_le_cubeCount T j)) + +omit [∀ i, NeZero (T i)] in +theorem integerBoxCubeCount_upper (j : ℕ) : + integerBoxCubeCount T j ≤ (integerBox T).card ^ (j + 1) := + card_supportedCube_le j (integerBox T) + +theorem integerBoxCubeCount_bounds (j : ℕ) : + ((1 : ℝ) / ((j : ℝ) + 1) ^ (j + 1)) ^ Fintype.card ι * + ((integerBox T).card : ℝ) ^ (j + 1) ≤ integerBoxCubeCount T j ∧ + (integerBoxCubeCount T j : ℝ) ≤ ((integerBox T).card : ℝ) ^ (j + 1) := by + constructor + · have h : ((integerBox T).card : ℝ) ^ (j + 1) ≤ + (((j + 1 : ℕ) : ℝ) ^ (Fintype.card ι * (j + 1))) * integerBoxCubeCount T j := by + exact_mod_cast integerBoxCubeCount_lower T j + have he : ((1 : ℝ) / ((j : ℝ) + 1) ^ (j + 1)) ^ Fintype.card ι * + ((integerBox T).card : ℝ) ^ (j + 1) = + ((integerBox T).card : ℝ) ^ (j + 1) / + ((j : ℝ) + 1) ^ (Fintype.card ι * (j + 1)) := by + rw [div_pow, one_pow, ← pow_mul, Nat.mul_comm (j + 1) (Fintype.card ι)] + ring + rw [he] + apply (div_le_iff₀ (pow_pos (by positivity : 0 < (j : ℝ) + 1) _)).mpr + simpa only [Nat.cast_add, Nat.cast_one, mul_comm] using h + · exact_mod_cast integerBoxCubeCount_upper T j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def integerBoxTestExtension {X : Type*} (N : X → ℕ) + (test : (X → ℝ) → ℂ) (y : X → ℝ) : ℂ := + if ∀ x, 0 ≤ y x ∧ y x < (N x : ℝ) then test y else 0 + +theorem integerBoxTestExtension_integer {X : Type*} [Fintype X] [DecidableEq X] + (N : X → ℕ) (test : (X → ℝ) → ℂ) (u : X → ℤ) : + integerBoxTestExtension N test (fun x => (u x : ℝ)) = + if u ∈ integerBox N then test (fun x => (u x : ℝ)) else 0 := by + have hc : (∀ x, 0 ≤ (u x : ℝ) ∧ (u x : ℝ) < (N x : ℝ)) ↔ u ∈ integerBox N := by + rw [mem_integerBox] + constructor + · intro h x + exact_mod_cast h x + · intro h x + exact_mod_cast h x + simp only [integerBoxTestExtension, hc] + +theorem integerBoxTestExtension_norm_le_one {X : Type*} (N : X → ℕ) + (test : (X → ℝ) → ℂ) (htest : ∀ y, ‖test y‖ ≤ 1) (y : X → ℝ) : + ‖integerBoxTestExtension N test y‖ ≤ 1 := by + unfold integerBoxTestExtension + split_ifs + · exact htest y + · simp + +theorem integerBoxTestExtension_of_mem {X : Type*} [Fintype X] [DecidableEq X] + (N : X → ℕ) (test : (X → ℝ) → ℂ) (u : X → ℤ) (hu : u ∈ integerBox N) : + integerBoxTestExtension N test (fun x => (u x : ℝ)) = test (fun x => (u x : ℝ)) := by + rw [integerBoxTestExtension_integer, ite_eq_left hu] + +theorem integerBoxTestExtension_of_not_mem {X : Type*} [Fintype X] [DecidableEq X] + (N : X → ℕ) (test : (X → ℝ) → ℂ) (u : X → ℤ) (hu : u ∉ integerBox N) : + integerBoxTestExtension N test (fun x => (u x : ℝ)) = 0 := by + rw [integerBoxTestExtension_integer, ite_eq_right hu] + +end Erdos3 + +end + +section + +open scoped BigOperators + +namespace Erdos3 + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def translatedIntegerBox (a : ι → ℤ) (T : ι → ℕ) : Finset (ι → ℤ) := + translateSupport a (integerBox T) + +theorem mem_translatedIntegerBox (a : ι → ℤ) (T : ι → ℕ) (x : ι → ℤ) : + x ∈ translatedIntegerBox a T ↔ ∀ i, a i ≤ x i ∧ x i < a i + T i := by + rw [translatedIntegerBox, mem_translateSupport, mem_integerBox] + apply forall_congr' + intro i + change (0 ≤ x i - a i ∧ x i - a i < T i) ↔ _ + omega + +variable (T : ι → ℕ) [∀ i, NeZero (T i)] + +theorem translatedIntegerBox_nonempty (a : ι → ℤ) : (translatedIntegerBox a T).Nonempty := + (integerBox_nonempty T).image (fun x ↦ a + x) + +omit [∀ i, NeZero (T i)] in +theorem translatedIntegerBox_reflectsPairSums (a : ι → ℤ) : + ReflectsPairSums (boxReduction T) (translatedIntegerBox a T : Set (ι → ℤ)) := + (boxReduction_reflectsPairSums T).translate a + +omit [∀ i, NeZero (T i)] in +theorem translatedIntegerBox_norm_eq (a : ι → ℤ) (j : ℕ) (f : (ι → ℤ) → ℂ) : + finiteSupportGowersNorm j (translatedIntegerBox a T) f = + integerBoxGowersNorm T j (fun x ↦ f (a + x)) := + finiteSupportGowersNorm_translate j (integerBox T) a f + +theorem translatedIntegerBox_norm_degree_one (a : ι → ℤ) (f : (ι → ℤ) → ℂ) : + finiteSupportGowersNorm 1 (translatedIntegerBox a T) f = + ‖𝔼 x ∈ translatedIntegerBox a T, f x‖ := + finiteSupportGowersNorm_degree_one_of_embedding (translatedIntegerBox_reflectsPairSums T a) + (translatedIntegerBox_nonempty T a) f + +theorem translatedIntegerBox_cubeCount_bounds (a : ι → ℤ) (j : ℕ) : + ((1 : ℝ) / ((j : ℝ) + 1) ^ (j + 1)) ^ Fintype.card ι * + ((translatedIntegerBox a T).card : ℝ) ^ (j + 1) ≤ + Nat.card (SupportedCube j (translatedIntegerBox a T : Set (ι → ℤ))) ∧ + (Nat.card (SupportedCube j (translatedIntegerBox a T : Set (ι → ℤ))) : ℝ) ≤ + ((translatedIntegerBox a T).card : ℝ) ^ (j + 1) := by + simpa only [translatedIntegerBox, card_translateSupport, card_supportedCube_translate, + integerBoxCubeCount] using integerBoxCubeCount_bounds T j + +theorem integerBox_weighted_derivative (a : ι → ℤ) (j : ℕ) (f : (ι → ℤ) → ℂ) : + (Nat.card (SupportedCube (j + 2) (translatedIntegerBox a T : Set (ι → ℤ))) : ℝ) * + finiteSupportGowersNorm (j + 2) (translatedIntegerBox a T) f ^ (2 ^ (j + 2)) = + ∑ h ∈ cubeDifferenceSupport (translatedIntegerBox a T), + (Nat.card (SupportedCube (j + 1) + (derivativeSupport (translatedIntegerBox a T) h : Set (ι → ℤ))) : ℝ) * + finiteSupportGowersNorm (j + 1) (derivativeSupport (translatedIntegerBox a T) h) + (multiplicativeDerivative f h) ^ (2 ^ (j + 1)) := + finiteSupportGowersNorm_derivative_mul_count (translatedIntegerBox_reflectsPairSums T a) + (translatedIntegerBox_nonempty T a) j f + +theorem integerBox_sum_derivative_weights (a : ι → ℤ) (j : ℕ) : + (∑ h ∈ cubeDifferenceSupport (translatedIntegerBox a T), + (Nat.card (SupportedCube j (derivativeSupport (translatedIntegerBox a T) h : Set (ι → ℤ))) : ℝ) / + Nat.card (SupportedCube (j + 1) (translatedIntegerBox a T : Set (ι → ℤ)))) = 1 := + sum_supportedCube_weights j (translatedIntegerBox_nonempty T a) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] + +noncomputable def trimmedIntegerBox (N R : I → ℕ) : Finset (I → ℤ) := + (integerBox (fun i => N i - 2 * R i)).image (fun x => (fun i => (R i : ℤ)) + x) + +theorem card_trimmedIntegerBox (N R : I → ℕ) : + (trimmedIntegerBox N R).card = ∏ i, (N i - 2 * R i) := by + rw [trimmedIntegerBox, Finset.card_image_of_injective _ (fun _ _ h => add_left_cancel h), + card_integerBox] + +theorem trimmedIntegerBox_nonempty (N R : I → ℕ) (hR : ∀ i, 2 * R i < N i) : + (trimmedIntegerBox N R).Nonempty := by + apply Finset.Nonempty.image + refine ⟨0, (mem_integerBox _ _).mpr ?_⟩ + intro i + have h : 0 < N i - 2 * R i := Nat.sub_pos_of_lt (hR i) + simpa using h + +theorem trimmedIntegerBox_add_mem (N R : I → ℕ) (hR : ∀ i, 2 * R i ≤ N i) + {x : I → ℤ} (hx : x ∈ trimmedIntegerBox N R) (y : I → ℤ) + (hy : ∀ i, |y i| ≤ (R i : ℤ)) : x + y ∈ integerBox N := by + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx + apply (mem_integerBox N _).mpr + intro i + have hi := (mem_integerBox _ _).mp ha i + have hyi := abs_le.mp (hy i) + have hRi := hR i + simp only [Pi.add_apply] + omega + +theorem trimmedIntegerBox_card_deficit (N R : I → ℕ) + (hN : ∀ i, 0 < N i) (hR : ∀ i, 2 * R i ≤ N i) : + 1 - ((trimmedIntegerBox N R).card : ℝ) / (integerBox N).card ≤ + ∑ i, 2 * (R i : ℝ) / N i := by + have hNR (i : I) : 0 < (N i : ℝ) := by exact_mod_cast hN i + have he (i : I) : 2 * (R i : ℝ) / N i ∈ Set.Icc (0 : ℝ) 1 := by + constructor + · positivity + · apply (div_le_one (hNR i)).mpr + exact_mod_cast hR i + have hi (i : I) : 1 - 2 * (R i : ℝ) / N i = ((N i - 2 * R i : ℕ) : ℝ) / N i := by + rw [Nat.cast_sub (hR i)] + push_cast + field_simp [ne_of_gt (hNR i)] + have hp := one_sub_sum_le_positive_prod Finset.univ + (fun i => ((N i - 2 * R i : ℕ) : ℝ) / N i) (fun i => 2 * (R i : ℝ) / N i) + (fun i _ => by positivity) (fun i _ => he i) (fun i _ => (hi i).le) + rw [card_trimmedIntegerBox, card_integerBox, Nat.cast_prod, Nat.cast_prod, + ← Finset.prod_div_distrib] + linarith + +end Erdos3 + +end + +section + +open scoped BigOperators + +namespace Erdos3 + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem derivativeSupport_translatedIntegerBox (a : ι → ℤ) (T : ι → ℕ) (h : ι → ℤ) : + derivativeSupport (translatedIntegerBox a T) h = + translatedIntegerBox (fun i => a i + max 0 (-h i)) (fun i => ((T i : ℤ) - |h i|).toNat) := by + ext x + simp only [derivativeSupport, Finset.mem_filter, mem_translatedIntegerBox, Pi.add_apply, + ← forall_and] + apply forall_congr' + intro i + by_cases hi : 0 ≤ h i + · rw [abs_of_nonneg hi, max_eq_left (by omega : -h i ≤ 0)] + omega + · rw [abs_of_neg (by omega : h i < 0), max_eq_right (by omega : 0 ≤ -h i)] + omega + +theorem box_overlap_length_pos (a : ι → ℤ) (T : ι → ℕ) {h : ι → ℤ} + (hh : h ∈ cubeDifferenceSupport (translatedIntegerBox a T)) (i : ι) : + 0 < ((T i : ℤ) - |h i|).toNat := by + obtain ⟨x, hx⟩ := (mem_cubeDifferenceSupport _ h).mp hh + obtain ⟨hx, hxh⟩ := Finset.mem_filter.mp hx + have hx' := (mem_translatedIntegerBox a T x).mp hx i + have hxh' := (mem_translatedIntegerBox a T (x + h)).mp hxh i + simp only [Pi.add_apply] at hxh' + by_cases hi : 0 ≤ h i + · rw [abs_of_nonneg hi] + omega + · rw [abs_of_neg (by omega : h i < 0)] + omega + +theorem box_differenceSupport_subset (a : ι → ℤ) (T : ι → ℕ) : + cubeDifferenceSupport (translatedIntegerBox a T) ⊆ + translatedIntegerBox (fun i => -(T i : ℤ)) (fun i => 2 * T i) := by + intro h hh + obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hh + obtain ⟨hx, hy⟩ := Finset.mem_product.mp hp + apply (mem_translatedIntegerBox _ _ _).mpr + intro i + have hx' := (mem_translatedIntegerBox a T p.1).mp hx i + have hy' := (mem_translatedIntegerBox a T p.2).mp hy i + simp only [Pi.sub_apply, Nat.cast_mul, Nat.cast_ofNat] + omega + +theorem card_box_differenceSupport_le (a : ι → ℤ) (T : ι → ℕ) : + (cubeDifferenceSupport (translatedIntegerBox a T)).card ≤ + 2 ^ Fintype.card ι * (translatedIntegerBox a T).card := by + apply (Finset.card_le_card (box_differenceSupport_subset a T)).trans_eq + simp only [translatedIntegerBox, card_translateSupport, card_integerBox, + Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def translatedIntegerBoxEquivPi {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (N : I → ℕ) : + ↥(translatedIntegerBox a N) ≃ ∀ i, ↥(Finset.Ico (a i) (a i + N i)) := by + let e : ↥(translatedIntegerBox a N) ≃ + {x : I → ℤ // ∀ i, x i ∈ Finset.Ico (a i) (a i + N i)} := + Equiv.subtypeEquivRight (fun x => by simp only [mem_translatedIntegerBox, Finset.mem_Ico]) + exact e.trans Equiv.subtypePiEquivPi + +@[simp] theorem translatedIntegerBoxEquivPi_val {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (N : I → ℕ) (x : ↥(translatedIntegerBox a N)) (i : I) : + ((translatedIntegerBoxEquivPi a N x) i).val = x.val i := rfl + +noncomputable def integerResidueBoxEquiv {I : Type*} [Fintype I] [DecidableEq I] + (a b r v : I → ℤ) (hr : ∀ i, 0 < r i) : + ↥(translatedIntegerBox (fun i => residueIndexLower (a i) (r i) (v i)) + (fun i => residueIndexLength (a i) (b i) (r i) (v i))) ≃ IntegerResidueBox a b r v := + (translatedIntegerBoxEquivPi _ _).trans + (Equiv.piCongrRight fun i => residueIntervalEquiv (a i) (b i) (r i) (v i) (hr i)) + +@[simp] theorem integerResidueBoxEquiv_val {I : Type*} [Fintype I] [DecidableEq I] + (a b r v : I → ℤ) (hr : ∀ i, 0 < r i) + (x : ↥(translatedIntegerBox (fun i => residueIndexLower (a i) (r i) (v i)) + (fun i => residueIndexLength (a i) (b i) (r i) (v i)))) (i : I) : + ((integerResidueBoxEquiv a b r v hr x) i).val = v i + r i * x.val i := rfl + +theorem integerResidueBox_expect {I : Type*} [Fintype I] [DecidableEq I] + (a b r v : I → ℤ) (hr : ∀ i, 0 < r i) (f : (I → ℤ) → ℂ) : + (𝔼 x : IntegerResidueBox a b r v, f (fun i => (x i).val)) = + 𝔼 x ∈ translatedIntegerBox (fun i => residueIndexLower (a i) (r i) (v i)) + (fun i => residueIndexLength (a i) (b i) (r i) (v i)), f (fun i => v i + r i * x i) := by + let B := translatedIntegerBox (fun i => residueIndexLower (a i) (r i) (v i)) + (fun i => residueIndexLength (a i) (b i) (r i) (v i)) + have h := Fintype.expect_equiv (integerResidueBoxEquiv a b r v hr) + (fun x => f (fun i => v i + r i * x.val i)) + (fun x => f (fun i => (x i).val)) (fun _ => rfl) + let g : (I → ℤ) → ℂ := fun x => f (fun i => v i + r i * x i) + have hcoe : (𝔼 x : ↥B, g x.val) = 𝔼 x ∈ B, g x := by + rw [Fintype.expect_eq_sum_div_card, Finset.expect_eq_sum_div_card, Fintype.card_coe, + Finset.sum_coe_sort] + exact h.symm.trans hcoe + +theorem integerResidueBox_lengths_pos {I : Type*} (a b r v : I → ℤ) + (hr : ∀ i, 0 < r i) (hbox : Nonempty (IntegerResidueBox a b r v)) : + ∀ i, 0 < residueIndexLength (a i) (b i) (r i) (v i) := by + obtain ⟨x⟩ := hbox + intro i + rw [residueIndexLength_eq_card (a i) (b i) (r i) (v i) (hr i)] + exact Finset.card_pos.mpr ⟨(x i).val, (x i).property⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +private noncomputable def physicalResidueCoordinateEquiv + (lo hi a : ℤ) (M : ℕ) (hM : 0 < M) : + Fin (residueIndexLength lo hi M a) ≃ + ↥(Finset.filter (fun x => x ≡ a [ZMOD (M : ℤ)]) (Finset.Ico lo hi)) := + (integerIntervalEquivFin (residueIndexLower lo M a) + (residueIndexLength lo hi M a)).symm.trans + (residueIntervalEquiv lo hi M a (Nat.cast_pos.mpr hM)) + +private theorem physicalResidueCoordinateEquiv_val + (lo hi a : ℤ) (M : ℕ) (hM : 0 < M) + (j : Fin (residueIndexLength lo hi M a)) : + (physicalResidueCoordinateEquiv lo hi a M hM j).val = + a + M * (residueIndexLower lo M a + j.val) := rfl + +namespace ResidueBoxSlice + +variable {X : Type*} (N H : X → ℕ) (lo a : X → ℤ) (M : ℕ) + (hM : 0 < M) (hbox : PhysicalSubbox (fun _ => 0) N lo H) + (hne : ∀ i, 0 < residueIndexLength (lo i) (lo i + H i) M (a i)) + +include hM hbox hne in +private theorem physicalResidue_start_nonneg (i : X) : + 0 ≤ a i + M * residueIndexLower (lo i) M (a i) := by + have hx := (physicalResidueCoordinateEquiv (lo i) (lo i + H i) (a i) M hM + ⟨0, hne i⟩).property + have hlow := (Finset.mem_Ico.mp (Finset.mem_filter.mp hx).1).1 + rw [physicalResidueCoordinateEquiv_val] at hlow + have hboxlow := (hbox i).1 + simpa only [Nat.cast_zero, add_zero] using hboxlow.trans hlow + +noncomputable def ofPhysicalResidue : ResidueBoxSlice N M where + start i := (a i + M * residueIndexLower (lo i) M (a i)).toNat + length i := residueIndexLength (lo i) (lo i + H i) M (a i) + inside i j hj := by + have hx := (physicalResidueCoordinateEquiv (lo i) (lo i + H i) (a i) M hM + ⟨j, hj⟩).property + have hhigh := (Finset.mem_Ico.mp (Finset.mem_filter.mp hx).1).2 + rw [physicalResidueCoordinateEquiv_val] at hhigh + have hboxhigh := (hbox i).2 + have hstart := physicalResidue_start_nonneg N H lo a M hM hbox hne i + have hlt : ((a i + M * residueIndexLower (lo i) M (a i)).toNat : ℤ) + + (M : ℤ) * j < N i := by + rw [Int.toNat_of_nonneg hstart] + nlinarith + exact_mod_cast hlt + +@[simp] theorem ofPhysicalResidue_length (i : X) : + (ofPhysicalResidue N H lo a M hM hbox hne).length i = + residueIndexLength (lo i) (lo i + H i) M (a i) := rfl + +@[simp] theorem ofPhysicalResidue_start (i : X) : + (ofPhysicalResidue N H lo a M hM hbox hne).start i = + (a i + M * residueIndexLower (lo i) M (a i)).toNat := rfl + +theorem ofPhysicalResidue_length_pos (i : X) : + 0 < (ofPhysicalResidue N H lo a M hM hbox hne).length i := hne i + +theorem ofPhysicalResidue_point_int + (j : ∀ i, Fin ((ofPhysicalResidue N H lo a M hM hbox hne).length i)) (i : X) : + (((ofPhysicalResidue N H lo a M hM hbox hne).point j i).val : ℤ) = + a i + M * (residueIndexLower (lo i) M (a i) + (j i).val) := by + change (((a i + M * residueIndexLower (lo i) M (a i)).toNat + M * (j i).val : ℕ) : ℤ) = _ + rw [Nat.cast_add, Nat.cast_mul, + Int.toNat_of_nonneg (physicalResidue_start_nonneg N H lo a M hM hbox hne i)] + ring + +noncomputable def ofPhysicalResidueEquiv : + (∀ i, Fin ((ofPhysicalResidue N H lo a M hM hbox hne).length i)) ≃ + IntegerResidueBox lo (fun i => lo i + H i) (fun _ => (M : ℤ)) a := + Equiv.piCongrRight fun i => + physicalResidueCoordinateEquiv (lo i) (lo i + H i) (a i) M hM + +@[simp] theorem ofPhysicalResidueEquiv_val + (j : ∀ i, Fin ((ofPhysicalResidue N H lo a M hM hbox hne).length i)) (i : X) : + ((ofPhysicalResidueEquiv N H lo a M hM hbox hne j) i).val = + (((ofPhysicalResidue N H lo a M hM hbox hne).point j i).val : ℤ) := by + rw [ofPhysicalResidue_point_int] + rfl + +end ResidueBoxSlice +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PositiveIntegerPeriodization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PositiveIntegerPeriodization.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb6b3564946809d43a5477ea64387330081820a7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PositiveIntegerPeriodization.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.Progressions.Estimates.SeparatedPositiveSum +import OAI.Combinatorics.Progressions.Polynomial.IntegerPolynomialActiveProfileSupport + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +variable {D : Type*} [Fintype D] + +noncomputable def positiveIntegerPeriodization (H : (D → ℝ) → ℝ) (x : D → ℝ) : ℝ := + ∑' n : D → ℤ, H (fun i => x i + (n i : ℝ)) + +omit [Fintype D] in +theorem integer_shifts_small_box_injective (x : D → ℝ) (n m : D → ℤ) + (hn : ∀ i, |x i + (n i : ℝ)| < 1/2) (hm : ∀ i, |x i + (m i : ℝ)| < 1/2) : n = m := by + have he := small_coordinate_lift_unique x (fun i => x i + (n i : ℝ)) + (fun i => x i + (m i : ℝ)) hn hm + (fun i => ⟨-n i, by push_cast; ring⟩) (fun i => ⟨-m i, by push_cast; ring⟩) + funext i + apply Int.cast_injective (α := ℝ) + have hi := congrFun he i + linarith + +omit [Fintype D] in +theorem positiveIntegerPeriodization_periodic (H : (D → ℝ) → ℝ) (x : D → ℝ) (m : D → ℤ) : + positiveIntegerPeriodization H (fun i => x i + (m i : ℝ)) = positiveIntegerPeriodization H x := by + unfold positiveIntegerPeriodization + have h := (Equiv.addRight m).tsum_eq (fun n : D → ℤ => H (fun i => x i + (n i : ℝ))) + convert h using 1 + apply tsum_congr + intro n + congr 1 + funext i + change x i + (m i : ℝ) + (n i : ℝ) = x i + ((n i + m i : ℤ) : ℝ) + push_cast + ring + +omit [Fintype D] in +theorem positiveIntegerPeriodization_local (H : (D → ℝ) → ℝ) + (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) (x : D → ℝ) (hx : ∀ i, |x i| < 1/2) : + positiveIntegerPeriodization H x = H x := by + unfold positiveIntegerPeriodization + rw [tsum_eq_single (0 : D → ℤ)] + · simp + · intro n hn + by_contra hnonzero + apply hn + exact integer_shifts_small_box_injective x n 0 (hs _ hnonzero) (by simpa using hx) + +theorem positiveIntegerPeriodization_lipschitz (H : (D → ℝ) → ℝ) {L : ℝ≥0} + (hH : LipschitzWith L H) (h0 : ∀ x, 0 ≤ H x) + (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) : + LipschitzWith L (positiveIntegerPeriodization H) := by + apply separated_tsum_lipschitz + · intro n + apply LipschitzWith.of_dist_le_mul + intro x y + have h := hH.dist_le_mul (x + fun i => (n i : ℝ)) (y + fun i => (n i : ℝ)) + rw [dist_add_right] at h + exact h + · intro n x + exact h0 _ + · intro x n m hn hm + exact integer_shifts_small_box_injective x n m (hs _ hn) (hs _ hm) + +omit [Fintype D] in +theorem positiveIntegerPeriodization_range (H : (D → ℝ) → ℝ) {B : ℝ} (hB : 0 ≤ B) + (hH : ∀ x, 0 ≤ H x ∧ H x ≤ B) + (hs : ∀ x, H x ≠ 0 → ∀ i, |x i| < 1/2) (x : D → ℝ) : + 0 ≤ positiveIntegerPeriodization H x ∧ positiveIntegerPeriodization H x ≤ B := by + refine ⟨tsum_nonneg (fun n => (hH _).1), ?_⟩ + by_cases hx : ∃ n : D → ℤ, H (fun i => x i + (n i : ℝ)) ≠ 0 + · obtain ⟨n, hn⟩ := hx + have he : positiveIntegerPeriodization H x = H (fun i => x i + (n i : ℝ)) := by + apply tsum_eq_single n + intro m hm + by_contra hnonzero + exact hm (integer_shifts_small_box_injective x m n (hs _ hnonzero) (hs _ hn)) + rw [he] + exact (hH _).2 + · have hz : ∀ n : D → ℤ, H (fun i => x i + (n i : ℝ)) = 0 := + fun n => not_ne_iff.mp (fun hn => hx ⟨n, hn⟩) + simp only [positiveIntegerPeriodization, hz, tsum_zero] + exact hB + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PositivePartitionIntegerExpansion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PositivePartitionIntegerExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..94957f5caa2b73489e55694e7d41390a98903fe7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PositivePartitionIntegerExpansion.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.Progressions.Estimates.PositiveWeightedExpansion + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_positive_weighted_integer_expansion : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ : Type} [Fintype σ] {s N : ℕ} [NeZero N] + {p : ℝ} {f : (σ → ℤ) → ℂ} + (_E : NativeIntegerExpansion (fun _ : σ => 1) s p f), + 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → ∀ w : σ → ZMod N → ℝ, + (∀ i, PositiveCyclicNiltest.{0} s N p (w i)) → + ∃ g : (σ → ℤ) → ℂ, + Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s ((p + C) ^ C) g) ∧ + ∀ x : σ → ZMod N, g (fun i => ((x i).val : ℤ)) = + (∏ i, (w i (x i) : ℂ)) * f (fun i => ((x i).val : ℤ)) := by + obtain ⟨A, _, hprod⟩ := exists_productNiltestBudget_bound + obtain ⟨B, _, hmul⟩ := NativeIntegerExpansion.exists_mul_budget + let X : Polynomial ℕ := Polynomial.X + let Y := X + (X + 2) ^ 2 + 3 + let Q := (Y + Polynomial.C A) ^ A + X + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((Q + Polynomial.C B) ^ B) + refine ⟨C, hC, ?_⟩ + intro σ _ s N _ p f E hp hσ w hw + have hp' : 0 ≤ raisedNiltestBudget p := hp.trans (le_raisedNiltestBudget p) + let q := (raisedNiltestBudget p + A) ^ A + p + 2 + have hpower : 0 ≤ (raisedNiltestBudget p + A) ^ A := by positivity + have hq : 0 ≤ q := by dsimp only [q]; positivity + have hpq : p ≤ q := by dsimp only [q]; linarith only [hpower] + have hweight : productNiltestBudget (raisedNiltestBudget p) ≤ q := + (hprod _ hp').trans (by dsimp only [q]; linarith only [hp]) + have hqC : (q + B) ^ B ≤ (p + C) ^ C := by + simpa [Q, Y, X, q, raisedNiltestBudget, Polynomial.eval₂_pow] using hbudget p hp + obtain ⟨g, ⟨W⟩, he⟩ := exists_positive_coordinate_product hp hσ hw + obtain ⟨G⟩ := hmul hq (W.mono hweight) (E.mono hpq) + refine ⟨fun x => g x * f x, ⟨G.mono hqC⟩, ?_⟩ + intro x + exact congrArg (fun z : ℂ => z * f (fun i => ((x i).val : ℤ))) (he x) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_positive_partition_integer_expansion : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ : Type} {I J : Type*} [Fintype σ] [Fintype I] + {s N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → + (Fintype.card I : ℝ) ≤ Real.exp p → + ∀ (w : I → σ → ZMod N → ℝ) (v : I → J → (σ → ℤ) → ℂ), + (∀ i k, PositiveCyclicNiltest.{0} s N p (w i k)) → + (∀ i j, Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s p (v i j))) → + ∃ F : J → (σ → ℤ) → ℂ, + (∀ j, Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s ((p + C) ^ C) (F j))) ∧ + ∀ j (x : σ → ZMod N), F j (fun k => ((x k).val : ℤ)) = + ∑ i, ((∏ k, w i k (x k) : ℝ) : ℂ) * v i j (fun k => ((x k).val : ℤ)) := by + obtain ⟨A, _, hweighted⟩ := exists_positive_weighted_integer_expansion + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((X + Polynomial.C A) ^ A + X) + refine ⟨C, hC, ?_⟩ + intro σ I J _ _ s N _ p hp hσ hI w v hw hv + classical + have hfamily (i : I) (j : J) : ∃ g : (σ → ℤ) → ℂ, + Nonempty (NativeIntegerExpansion (fun _ : σ => 1) s ((p + A) ^ A) g) ∧ + ∀ x : σ → ZMod N, g (fun k => ((x k).val : ℤ)) = + ((∏ k, w i k (x k) : ℝ) : ℂ) * v i j (fun k => ((x k).val : ℤ)) := by + obtain ⟨g, hg, he⟩ := hweighted (Classical.choice (hv i j)) hp hσ (w i) (hw i) + exact ⟨g, hg, fun x => by simpa only [Complex.ofReal_prod] using he x⟩ + choose g hg he using hfamily + let F := fun (j : J) (x : σ → ℤ) => ∑ i, g i j x + have hcost : (p + A) ^ A + p ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + refine ⟨F, ?_, ?_⟩ + · intro j + have hc : (∑ _i : I, ‖(1 : ℂ)‖) ≤ Real.exp p := by simpa using hI + exact ⟨by simpa only [F, one_mul] using + ((NativeIntegerExpansion.weightedSum (fun i => Classical.choice (hg i j)) + (fun _ => 1) hp hI hc).mono hcost)⟩ + · intro j x + exact Finset.sum_congr rfl (fun i _ => he i j x) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PreparedAffineDensityEighthRemainder.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PreparedAffineDensityEighthRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbec95a2e4b0bd6ba9617126ce225eec0e186b88 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PreparedAffineDensityEighthRemainder.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.Progressions.Estimates.PreparedFiniteNestedSourceRelativeInitializerBounds + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule + +variable {m : ℕ} {G V : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) (hσ1 : ∀ j, σ j ≤ 1) +variable (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + +include hσ1 hC hchart + +theorem allocatedAffineDensity_eighth_integer_remainder_of_earlyRadius + {Pchart Bstruct : ℝ} + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (hbudget : ∀ C' : Fin m → ℝ, (∀ j, 0 ≤ C' j) → + (∀ j, C' j ≤ Real.exp Bstruct) → + ∀ j, C' j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + (hchartBound : ∀ j, C j ≤ Real.exp Pchart) + (hallow : Pchart + 1 ≤ Bstruct) + (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (hp : ∀ j, DegreeLE (1 : V → ℕ) (j.val + 1) (p j)) + (center : ∀ j, U j) + (frame : Option (LayerSamplerVariables G I n B) → V → ℝ) + (hframe : allocatedAffineDensity B U b hb o hR hσ S p hm center frame ≠ 0) : + ∃ β : ∀ j, J j → MvPolynomial (LayerSamplerVariables G I n B) ℤ, + (∀ j i, (β j i).totalDegree ≤ j.val + 1) ∧ + ∀ (x : LayerSamplerVariables G I n B → ℝ), (∀ v, |x v| ≤ layerSamplerBox B U b S v) → + ∀ j i, + |eval (fun v => frame none v + ∑ k, frame (some k) v * x k) (p j) i - (center j).val i - + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β j i))| ≤ 1 / 8 := by + have heighth := preparedEarlyRadius_eighth_of_universal hbudget C hC hchartBound hallow + have hsmall (j : Fin m) : C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4 := + (heighth j).trans (by norm_num) + obtain ⟨β, hβ, hremainder⟩ := allocatedAffineDensity_small_integer_remainder + B U b o hR hσ S hσ1 C hC hchart hb hsmall p hm hp center frame hframe + refine ⟨β, hβ, ?_⟩ + intro x hx j i + exact (hremainder x hx j i).trans (by simpa only [mul_assoc] using heighth j) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PreparedIntegerRemainder.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PreparedIntegerRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..af470cf2df2619773fa48ee2d6991ef45b99f9df --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PreparedIntegerRemainder.lean @@ -0,0 +1,124 @@ +import OAI.Combinatorics.Progressions.Polynomial.PreparedPolynomialIdentity + +namespace OAI + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial +open scoped BigOperators TensorProduct + +variable {X J : Type} [Fintype J] [DecidableEq J] {m : ℕ} +variable (L : RankPreparationFamily X J m) + +noncomputable def integerRemainder (ip : J → MvPolynomial X ℤ) + (β : ∀ u, (L u).Coord → MvPolynomial X ℤ) : J → MvPolynomial X ℤ := + ip + ∑ u, coordinateCopySum (L u).label (β u) + +omit [Fintype J] in +theorem integerRemainder_degree (ip : J → MvPolynomial X ℤ) + (hip : ∀ j, (ip j).totalDegree ≤ m) (β : ∀ u, (L u).Coord → MvPolynomial X ℤ) + (hβ : ∀ u i, (β u i).totalDegree ≤ u.val + 1) (j : J) : + (L.integerRemainder ip β j).totalDegree ≤ m := by + apply (MvPolynomial.totalDegree_add _ _).trans + apply max_le (hip j) + rw [Finset.sum_apply] + apply MvPolynomial.totalDegree_finsetSum_le + intro u _ + exact (coordinateCopySum_polynomial_degree (L u).label (β u) (hβ u) j).trans + (Nat.succ_le_of_lt u.isLt) + +omit [Fintype J] in +theorem integerRemainder_eval (ip : J → MvPolynomial X ℤ) + (β : ∀ u, (L u).Coord → MvPolynomial X ℤ) (x : X → ℝ) (j : J) : + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j)) = + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (ip j)) + + ∑ u, coordinateCopySum (L u).label + (fun i => MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β u i))) j := by + let f : MvPolynomial X ℤ →+* ℝ := + (MvPolynomial.eval x).comp (MvPolynomial.map (Int.castRingHom ℝ)) + change f (ip j + (∑ u, coordinateCopySum (L u).label (β u)) j) = _ + rw [Finset.sum_apply, map_add, map_sum] + congr 1 + apply Finset.sum_congr rfl + intro u _ + exact coordinateCopySum_map (L u).label f (β u) j + +theorem integerRemainder_bound + (P E : VectorPolynomial X ℝ (J → ℝ)) (ip : J → MvPolynomial X ℤ) (c : J → ℝ) + (hP : P = L.polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + E) + (β : ∀ u, (L u).Coord → MvPolynomial X ℤ) (center : ∀ u, (L u).Coord → ℝ) + (ε : Fin m → ℝ) (hε : ∀ u, 0 ≤ ε u) {δ : ℝ} (Ω : Set (X → ℝ)) + (hsmall : ∀ x ∈ Ω, ∀ u i, |eval x (L u).poly i - center u i - + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β u i))| ≤ ε u) + (herr : ∀ x ∈ Ω, ∀ j, |eval x E j| ≤ δ) : + ∀ x ∈ Ω, ∀ j, + |eval x P j - MvPolynomial.eval x + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j)) - + (c j + ∑ u, coordinateCopySum (L u).label (center u) j)| ≤ + (∑ u, (Fintype.card (L u).Coord : ℝ) * ε u) + δ := by + intro x hx j + let r : ∀ u, (L u).Coord → ℝ := fun u i => eval x (L u).poly i - center u i - + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β u i)) + have heq : eval x P j - MvPolynomial.eval x + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j)) - + (c j + ∑ u, coordinateCopySum (L u).label (center u) j) = + (∑ u, coordinateCopySum (L u).label (r u) j) + eval x E j := by + rw [hP, map_add, map_add, map_add, polynomial_eval, integerCoordinates_eval_real, + integerRemainder_eval] + simp only [Pi.add_apply, eval_tmul, map_one, one_smul] + have hr (u) : r u = eval x (L u).poly - center u - + (fun i => MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β u i))) := rfl + simp only [hr, map_sub, Pi.sub_apply, Finset.sum_sub_distrib, value, + RankPreparationLayer.value, Finset.sum_apply] + ring + rw [heq] + apply (abs_add_le _ _).trans + apply add_le_add _ (herr x hx j) + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro u _ + exact coordinateCopySum_abs_le (L u).label (hε u) (hsmall x hx u) j + +theorem integerRemainder_oscillation + (P E : VectorPolynomial X ℝ (J → ℝ)) (ip : J → MvPolynomial X ℤ) (c : J → ℝ) + (hP : P = L.polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + E) + (β : ∀ u, (L u).Coord → MvPolynomial X ℤ) (center : ∀ u, (L u).Coord → ℝ) + (ε : Fin m → ℝ) (hε : ∀ u, 0 ≤ ε u) {δ : ℝ} (hδ : 0 ≤ δ) (Ω : Set (X → ℝ)) + (hsmall : ∀ x ∈ Ω, ∀ u i, |eval x (L u).poly i - center u i - + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β u i))| ≤ ε u) + (herr : ∀ x ∈ Ω, ∀ j, |eval x E j| ≤ δ) (x₀ : X → ℝ) (hx₀ : x₀ ∈ Ω) : + ∀ x ∈ Ω, + ‖(eval x P - fun j => MvPolynomial.eval x + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j))) - + (eval x₀ P - fun j => MvPolynomial.eval x₀ + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j)))‖ ≤ + 2 * ((∑ u, (Fintype.card (L u).Coord : ℝ) * ε u) + δ) := by + intro x hx + have hsum : 0 ≤ ∑ u, (Fintype.card (L u).Coord : ℝ) * ε u := + Finset.sum_nonneg (fun u _ => mul_nonneg (Nat.cast_nonneg _) (hε u)) + apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr + intro j + rw [Real.norm_eq_abs] + let a := c j + ∑ u, coordinateCopySum (L u).label (center u) j + have hxBound := L.integerRemainder_bound P E ip c hP β center ε hε Ω hsmall herr x hx j + have h₀Bound := L.integerRemainder_bound P E ip c hP β center ε hε Ω hsmall herr x₀ hx₀ j + have heq : ((eval x P - fun j => MvPolynomial.eval x + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j))) - + (eval x₀ P - fun j => MvPolynomial.eval x₀ + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j)))) j = + (eval x P j - MvPolynomial.eval x + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j)) - a) - + (eval x₀ P j - MvPolynomial.eval x₀ + (MvPolynomial.map (Int.castRingHom ℝ) (L.integerRemainder ip β j)) - a) := by + simp only [Pi.sub_apply] + ring + rw [heq] + exact (abs_sub _ _).trans (by linarith) + +end Erdos3.RankPreparationFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PrimeCoordinateCells.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PrimeCoordinateCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..d22cdecfef382de9038a567c30a7f538ebe7bb67 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PrimeCoordinateCells.lean @@ -0,0 +1,600 @@ +import Mathlib.Data.Int.ModEq +import Mathlib.Data.Nat.Factorization.Basic +import Mathlib.Data.Nat.GCD.BigOperators +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Dynamics.NormalizedCoreBudget +import OAI.Combinatorics.Progressions.Estimates.UniformPhysicalVisitBounds +import OAI.Combinatorics.Progressions.Lattices.AffinePrimitiveLogBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def periodPrimeCoordinates {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (M : ℕ) : Finset ι := by + classical + exact Finset.univ.filter (fun i => prime i ∣ M) + +@[simp] theorem mem_periodPrimeCoordinates {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (M : ℕ) (i : ι) : + i ∈ periodPrimeCoordinates prime M ↔ prime i ∣ M := by + classical + simp [periodPrimeCoordinates] + +theorem periodPrimeCoordinates_card_pow_le {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + {M : ℕ} (hM : 0 < M) : 2 ^ (periodPrimeCoordinates prime M).card ≤ M := by + classical + let A := periodPrimeCoordinates prime M + have hsub : A.image prime ⊆ M.primeFactors := by + intro p hp + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp hp + exact Nat.mem_primeFactors.mpr ⟨hprime i, (mem_periodPrimeCoordinates prime M i).mp hi, hM.ne'⟩ + have hcard : A.card ≤ M.primeFactors.card := by + rw [← Finset.card_image_of_injective A hinj] + exact Finset.card_le_card hsub + calc + 2 ^ A.card ≤ 2 ^ M.primeFactors.card := Nat.pow_le_pow_right (by norm_num) hcard + _ = ∏ _p ∈ M.primeFactors, 2 := by simp + _ ≤ ∏ p ∈ M.primeFactors, p := Finset.prod_le_prod fun p hp => (Nat.mem_primeFactors.mp hp).1.two_le + _ ≤ M := Nat.le_of_dvd hM (Nat.prod_primeFactors_dvd M) + +theorem periodPrimeCoordinates_card_log_le {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + {M : ℕ} (hM : 0 < M) : + (periodPrimeCoordinates prime M).card * Real.log 2 ≤ Real.log M := by + have hpow : (2 : ℝ) ^ (periodPrimeCoordinates prime M).card ≤ M := by + exact_mod_cast periodPrimeCoordinates_card_pow_le prime hprime hinj hM + simpa only [Real.log_pow] using Real.log_le_log (by positivity) hpow + +theorem periodPrimeCoordinates_card_le {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + {M : ℕ} (hM : 0 < M) {B : ℝ} (hMB : (M : ℝ) ≤ Real.exp B) : + ((periodPrimeCoordinates prime M).card : ℝ) ≤ 2 * B := by + have h := (periodPrimeCoordinates_card_log_le prime hprime hinj hM).trans + ((Real.log_le_iff_le_exp (by exact_mod_cast hM)).mpr hMB) + have hlog : (1 : ℝ) / 2 ≤ Real.log 2 := by + have ht := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at ht ⊢ + linarith + have hc : (0 : ℝ) ≤ (periodPrimeCoordinates prime M).card := Nat.cast_nonneg _ + nlinarith + +theorem periodPrimeCoordinates_pending_coprime {ι : Type*} [Fintype ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (M : ℕ) (J : Finset ι) + (hJ : Disjoint J (periodPrimeCoordinates prime M)) : + Nat.Coprime (∏ i ∈ J, prime i ^ power i) M := by + classical + apply Nat.coprime_prod_left_iff.mpr + intro i hi + apply Nat.Coprime.pow_left + apply (hprime i).coprime_iff_not_dvd.mpr + intro hd + exact Finset.disjoint_left.mp hJ hi ((mem_periodPrimeCoordinates prime M i).mpr hd) + +theorem periodPrimeCoordinates_pending_mul_coprime {ι : Type*} [Fintype ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (M d : ℕ) (J : Finset ι) + (hJ : Disjoint J (periodPrimeCoordinates prime M)) + (hd : Nat.Coprime (∏ i ∈ J, prime i ^ power i) d) : + Nat.Coprime (∏ i ∈ J, prime i ^ power i) (M * d) := + (periodPrimeCoordinates_pending_coprime prime power hprime M J hJ).mul_right hd + +theorem disjoint_prime_power_products_coprime {ι : Type*} [Fintype ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + (A B : Finset ι) (hAB : Disjoint A B) : + Nat.Coprime (∏ i ∈ A, prime i ^ power i) (∏ j ∈ B, prime j ^ power j) := by + classical + apply Nat.coprime_prod_left_iff.mpr + intro i hi + apply Nat.coprime_prod_right_iff.mpr + intro j hj + apply Nat.Coprime.pow + apply (Nat.coprime_primes (hprime i) (hprime j)).mpr + intro heq + have hij := hinj heq + exact Finset.disjoint_left.mp hAB hi (hij.symm ▸ hj) + +theorem periodPrimeCoordinates_unfixed_coprime {ι : Type*} [Fintype ι] [DecidableEq ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + (M : ℕ) (K J : Finset ι) + (hJ : Disjoint J (K ∪ periodPrimeCoordinates prime M)) : + Nat.Coprime (∏ i ∈ J, prime i ^ power i) ((∏ i ∈ K, prime i ^ power i) * M) := by + have hJK : Disjoint J K := hJ.mono_right Finset.subset_union_left + have hJM : Disjoint J (periodPrimeCoordinates prime M) := hJ.mono_right Finset.subset_union_right + exact (disjoint_prime_power_products_coprime prime power hprime hinj J K hJK).mul_right + (periodPrimeCoordinates_pending_coprime prime power hprime M J hJM) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem selectedPrimePowers_pairwise_coprime {ι : Type*} + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) : + Pairwise (fun i j => (prime i ^ power i).Coprime (prime j ^ power j)) := by + intro i j hij + apply Nat.Coprime.pow + apply (Nat.coprime_primes (hprime i) (hprime j)).mpr + intro heq + exact hij (hinj heq) + +theorem modEq_selected_prod_iff {ι : Type*} [DecidableEq ι] + (q : ι → ℕ) (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (a b : ℤ) : + a ≡ b [ZMOD ((∏ i ∈ I, q i : ℕ) : ℤ)] ↔ ∀ i ∈ I, a ≡ b [ZMOD (q i : ℤ)] := by + induction I using Finset.induction_on with + | empty => simp [Int.ModEq] + | @insert i I hi ih => + have hc : (q i).Coprime (∏ j ∈ I, q j) := by + apply Nat.coprime_prod_right_iff.mpr + intro j hj + apply hcop + intro heq + subst j + exact hi hj + have hci : Int.natAbs (q i : ℤ) |>.Coprime (Int.natAbs ((∏ j ∈ I, q j : ℕ) : ℤ)) := by + simpa only [Int.natAbs_natCast] using hc + rw [Finset.prod_insert hi, Nat.cast_mul, ← Int.modEq_and_modEq_iff_modEq_mul hci, ih] + simp only [Finset.mem_insert, forall_eq_or_imp] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem periodPrimeCoordinates_modulus_dvd_product {ι : Type*} [Fintype ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (m : ℕ) + (hm : m ∣ ∏ i, prime i ^ power i) : + m ∣ ∏ i ∈ periodPrimeCoordinates prime m, prime i ^ power i := by + let I := periodPrimeCoordinates prime m + have hc := (periodPrimeCoordinates_pending_coprime prime power hprime m Iᶜ + (Finset.disjoint_left.mpr (fun _ hi hI => (Finset.mem_compl.mp hi) hI))).symm + apply hc.dvd_of_dvd_mul_right + rw [Finset.prod_mul_prod_compl] + exact hm + +theorem periodPrimeCoordinates_card_le_of_le_pow {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + {m b : ℕ} (hm : 0 < m) (hmb : m ≤ 2 ^ b) : + (periodPrimeCoordinates prime m).card ≤ b := by + exact (Nat.pow_le_pow_iff_right (by decide : 1 < 2)).mp + ((periodPrimeCoordinates_card_pow_le prime hprime hinj hm).trans hmb) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem initialResiduePrimeMask_bounds {ι : Type*} [Fintype ι] [DecidableEq ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + (M : ℕ) (hM : 0 < M) (p : ℝ) (hp : 0 ≤ p) (hMp : (M : ℝ) ≤ Real.exp p) + (hqp : ∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p) + (mandatory : Finset ι) (hmandatory : (mandatory.card : ℝ) ≤ p) : + let K := mandatory ∪ periodPrimeCoordinates prime M + (K.card : ℝ) ≤ 3 * p ∧ + ((M.lcm (∏ i ∈ K, prime i ^ power i) : ℕ) : ℝ) ≤ Real.exp (p + 3 * p ^ 2) := by + dsimp only + let K := mandatory ∪ periodPrimeCoordinates prime M + have hperiod := periodPrimeCoordinates_card_le prime hprime hinj hM hMp + have hcardNat := Finset.card_union_le mandatory (periodPrimeCoordinates prime M) + have hcard : (K.card : ℝ) ≤ 3 * p := by + have hcardReal : (K.card : ℝ) ≤ mandatory.card + (periodPrimeCoordinates prime M).card := by + exact_mod_cast hcardNat + linarith + refine ⟨hcard, ?_⟩ + have hprod : ((∏ i ∈ K, prime i ^ power i : ℕ) : ℝ) ≤ Real.exp (3 * p ^ 2) := by + rw [Nat.cast_prod] + calc + (∏ i ∈ K, ((prime i ^ power i : ℕ) : ℝ)) ≤ ∏ _i ∈ K, Real.exp p := + Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun i _ => hqp i) + _ = Real.exp ((K.card : ℝ) * p) := by rw [Finset.prod_const, Real.exp_nat_mul] + _ ≤ Real.exp (3 * p ^ 2) := by + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_right hcard hp] + have hprodpos : 0 < ∏ i ∈ K, prime i ^ power i := + Finset.prod_pos (fun i _ => pow_pos (hprime i).pos _) + have hlcm : ((M.lcm (∏ i ∈ K, prime i ^ power i) : ℕ) : ℝ) ≤ + (M : ℝ) * ((∏ i ∈ K, prime i ^ power i : ℕ) : ℝ) := by + exact_mod_cast Nat.le_of_dvd (Nat.mul_pos hM hprodpos) (Nat.lcm_dvd_mul M _) + calc + _ ≤ (M : ℝ) * ((∏ i ∈ K, prime i ^ power i : ℕ) : ℝ) := hlcm + _ ≤ Real.exp p * Real.exp (3 * p ^ 2) := mul_le_mul hMp hprod (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = Real.exp (p + 3 * p ^ 2) := (Real.exp_add _ _).symm + +theorem initialResidueCombined_coprime {ι : Type*} [Fintype ι] [DecidableEq ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + (M : ℕ) (K : Finset ι) (hcovered : periodPrimeCoordinates prime M ⊆ K) + (j : ι) (hj : j ∉ K) : + (M.lcm (∏ i ∈ K, prime i ^ power i)).Coprime (prime j ^ power j) := by + have hM : M.Coprime (prime j ^ power j) := by + apply Nat.Coprime.pow_right + apply Nat.Coprime.symm + apply (hprime j).coprime_iff_not_dvd.mpr + intro hd + exact hj (hcovered ((mem_periodPrimeCoordinates prime M j).mpr hd)) + have hK : (∏ i ∈ K, prime i ^ power i).Coprime (prime j ^ power j) := by + apply Nat.coprime_prod_left_iff.mpr + intro i hi + apply selectedPrimePowers_pairwise_coprime prime power hprime hinj + intro heq + exact hj (heq ▸ hi) + exact Nat.Coprime.of_dvd_left (Nat.lcm_dvd_mul M _) (Nat.coprime_mul_iff_left.mpr ⟨hM, hK⟩) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def affineComparisonPrimeThreshold (ξ P : ℝ) : ℝ := + (P + 2) ^ (4 + CyclicCrootSisask.spectralIterations ξ 18) + +noncomputable def affineComparisonContraction (ξ P : ℝ) : ℝ := + (affineComparisonPrimeThreshold ξ P)⁻¹ + +theorem affineComparisonContraction_bounds {ξ P : ℝ} (hξ : 0 < ξ) (hP : 0 ≤ P) : + 0 < affineComparisonContraction ξ P ∧ affineComparisonContraction ξ P ≤ 1 / 2 ∧ + affineComparisonContraction ξ P * (8 * (1 + 2) * (P + 2)) ^ 2 * (16 * (P + 2)) ^ 2 ≤ ξ / 16 := by + have ht : 2 ≤ P + 2 := by linarith + have hthreshold : 2 ≤ affineComparisonPrimeThreshold ξ P := by + unfold affineComparisonPrimeThreshold + calc + 2 ≤ P + 2 := ht + _ = (P + 2) ^ 1 := (pow_one _).symm + _ ≤ _ := pow_le_pow_right₀ (by linarith) (by omega) + have hp : 0 < affineComparisonPrimeThreshold ξ P := by linarith + refine ⟨inv_pos.mpr hp, ?_, ?_⟩ + · simpa only [affineComparisonContraction, one_div] using + one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 2) hthreshold + · have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hc : (147456 : ℝ) ≤ Real.exp 18 := by + calc + 147456 ≤ (2 : ℝ) ^ 18 := by norm_num + _ ≤ (Real.exp 1) ^ 18 := pow_le_pow_left₀ (by norm_num) htwo 18 + _ = _ := by rw [← Real.exp_nat_mul]; norm_num + exact low_level_after_power_cutoff (d := 4) hξ ht (by norm_num) hc + (by ring_nf; exact le_rfl) le_rfl le_rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +noncomputable def affineMandatoryPrimes {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (ξ P : ℝ) : Finset ι := + Finset.univ.filter (fun i => (prime i : ℝ) ≤ affineComparisonPrimeThreshold ξ P) + +theorem mem_affineMandatoryPrimes {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (ξ P : ℝ) (i : ι) : + i ∈ affineMandatoryPrimes prime ξ P ↔ (prime i : ℝ) ≤ affineComparisonPrimeThreshold ξ P := by + simp only [affineMandatoryPrimes, Finset.mem_filter, Finset.mem_univ, true_and] + +theorem affineMandatoryPrimes_outside_inverse {ι : Type*} [Fintype ι] + (prime : ι → ℕ) {ξ P : ℝ} (hP : 0 ≤ P) (K : Finset ι) + (hK : affineMandatoryPrimes prime ξ P ⊆ K) (i : ι) (hi : i ∉ K) : + (prime i : ℝ)⁻¹ ≤ affineComparisonContraction ξ P := by + have ht : 0 < affineComparisonPrimeThreshold ξ P := by unfold affineComparisonPrimeThreshold; positivity + have hp : affineComparisonPrimeThreshold ξ P ≤ (prime i : ℝ) := by + apply le_of_lt + apply lt_of_not_ge + intro h + exact hi (hK ((mem_affineMandatoryPrimes prime ξ P i).mpr h)) + simpa only [affineComparisonContraction, one_div] using one_div_le_one_div_of_le ht hp + +theorem affineMandatoryPrimes_card_le {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hinj : Function.Injective prime) (ξ P : ℝ) (hP : 0 ≤ P) : + ((affineMandatoryPrimes prime ξ P).card : ℝ) ≤ affineComparisonPrimeThreshold ξ P + 2 := by + let n := ⌈affineComparisonPrimeThreshold ξ P⌉₊ + have hsub : (affineMandatoryPrimes prime ξ P).image prime ⊆ Finset.range (n + 1) := by + intro a ha + obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp ha + have hle : (prime i : ℝ) ≤ (n : ℝ) := + ((mem_affineMandatoryPrimes prime ξ P i).mp hi).trans (Nat.le_ceil _) + have hn : prime i ≤ n := by exact_mod_cast hle + exact Finset.mem_range.mpr (by omega) + have hc : (affineMandatoryPrimes prime ξ P).card ≤ n + 1 := by + calc + _ = ((affineMandatoryPrimes prime ξ P).image prime).card := (Finset.card_image_of_injective _ hinj).symm + _ ≤ (Finset.range (n + 1)).card := Finset.card_le_card hsub + _ = _ := Finset.card_range _ + have ht : 0 ≤ affineComparisonPrimeThreshold ξ P := by unfold affineComparisonPrimeThreshold; positivity + have hn := Nat.ceil_lt_add_one ht + have hc' : ((affineMandatoryPrimes prime ξ P).card : ℝ) ≤ (n : ℝ) + 1 := by exact_mod_cast hc + change (n : ℝ) < affineComparisonPrimeThreshold ξ P + 1 at hn + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +noncomputable def affineInitialPrimeMask {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (ξ P : ℝ) (sourceM siteM : ℕ) : Finset ι := + (affineMandatoryPrimes prime ξ P ∪ periodPrimeCoordinates prime sourceM) ∪ + periodPrimeCoordinates prime siteM + +theorem affineInitialPrimeMask_contains {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (ξ P : ℝ) (sourceM siteM : ℕ) : + affineMandatoryPrimes prime ξ P ⊆ affineInitialPrimeMask prime ξ P sourceM siteM ∧ + periodPrimeCoordinates prime sourceM ⊆ affineInitialPrimeMask prime ξ P sourceM siteM ∧ + periodPrimeCoordinates prime siteM ⊆ affineInitialPrimeMask prime ξ P sourceM siteM := by + exact ⟨Finset.subset_union_left.trans Finset.subset_union_left, + Finset.subset_union_right.trans Finset.subset_union_left, Finset.subset_union_right⟩ + +theorem affineInitialPrimeMask_card_le {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + {ξ P sourceLog siteLog : ℝ} {sourceM siteM : ℕ} + (hP : 0 ≤ P) (hsourceM : 0 < sourceM) (hsiteM : 0 < siteM) + (hsource : (sourceM : ℝ) ≤ Real.exp sourceLog) (hsite : (siteM : ℝ) ≤ Real.exp siteLog) : + ((affineInitialPrimeMask prime ξ P sourceM siteM).card : ℝ) ≤ + affineComparisonPrimeThreshold ξ P + 2 + 2 * sourceLog + 2 * siteLog := by + have hmandatory := affineMandatoryPrimes_card_le prime hinj ξ P hP + have hs := periodPrimeCoordinates_card_le prime hprime hinj hsourceM hsource + have ht := periodPrimeCoordinates_card_le prime hprime hinj hsiteM hsite + have hcard : (affineInitialPrimeMask prime ξ P sourceM siteM).card ≤ + (affineMandatoryPrimes prime ξ P).card + (periodPrimeCoordinates prime sourceM).card + + (periodPrimeCoordinates prime siteM).card := by + exact (Finset.card_union_le _ _).trans + (Nat.add_le_add_right (Finset.card_union_le _ _) _) + have hcard' : ((affineInitialPrimeMask prime ξ P sourceM siteM).card : ℝ) ≤ + ((affineMandatoryPrimes prime ξ P).card : ℝ) + ((periodPrimeCoordinates prime sourceM).card : ℝ) + + ((periodPrimeCoordinates prime siteM).card : ℝ) := by exact_mod_cast hcard + linarith + +theorem affineInitialPrimeMask_outside_coprime {ι : Type*} [Fintype ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) + {ξ P : ℝ} {sourceM siteM : ℕ} (K : Finset ι) + (hK : affineInitialPrimeMask prime ξ P sourceM siteM ⊆ K) + (i : ι) (hi : i ∉ K) : + sourceM.Coprime (prime i ^ power i) ∧ siteM.Coprime (prime i ^ power i) := by + have hcontains := affineInitialPrimeMask_contains prime ξ P sourceM siteM + have hcop (M : ℕ) (hM : periodPrimeCoordinates prime M ⊆ K) : M.Coprime (prime i ^ power i) := by + apply Nat.Coprime.pow_right + apply Nat.Coprime.symm + apply (hprime i).coprime_iff_not_dvd.mpr + intro hd + exact hi (hM ((mem_periodPrimeCoordinates prime M i).mpr hd)) + exact ⟨hcop sourceM (hcontains.2.1.trans hK), hcop siteM (hcontains.2.2.trans hK)⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +noncomputable def affineSamplerPrimeMask {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (ξ P : ℝ) (sourceM siteM D : ℕ) : Finset ι := + affineInitialPrimeMask prime ξ P sourceM siteM ∪ periodPrimeCoordinates prime D + +theorem affineSamplerPrimeMask_contains {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (ξ P : ℝ) (sourceM siteM D : ℕ) : + affineInitialPrimeMask prime ξ P sourceM siteM ⊆ + affineSamplerPrimeMask prime ξ P sourceM siteM D ∧ + periodPrimeCoordinates prime D ⊆ affineSamplerPrimeMask prime ξ P sourceM siteM D := + ⟨Finset.subset_union_left, Finset.subset_union_right⟩ + +theorem affineSamplerPrimeMask_card_le {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + {ξ P sourceLog siteLog parameterLog : ℝ} {sourceM siteM D : ℕ} + (hP : 0 ≤ P) (hsourceM : 0 < sourceM) (hsiteM : 0 < siteM) (hD : 0 < D) + (hsource : (sourceM : ℝ) ≤ Real.exp sourceLog) (hsite : (siteM : ℝ) ≤ Real.exp siteLog) + (hparameter : (D : ℝ) ≤ Real.exp parameterLog) : + ((affineSamplerPrimeMask prime ξ P sourceM siteM D).card : ℝ) ≤ + affineComparisonPrimeThreshold ξ P + 2 + 2 * sourceLog + 2 * siteLog + 2 * parameterLog := by + have hbase := affineInitialPrimeMask_card_le (ξ := ξ) prime hprime hinj hP hsourceM hsiteM hsource hsite + have hp := periodPrimeCoordinates_card_le prime hprime hinj hD hparameter + have hcard : ((affineSamplerPrimeMask prime ξ P sourceM siteM D).card : ℝ) ≤ + ((affineInitialPrimeMask prime ξ P sourceM siteM).card : ℝ) + + ((periodPrimeCoordinates prime D).card : ℝ) := by + exact_mod_cast Finset.card_union_le (affineInitialPrimeMask prime ξ P sourceM siteM) (periodPrimeCoordinates prime D) + linarith + +theorem affineSamplerPrimeMask_outside {ι : Type*} [Fintype ι] + (prime power : ι → ℕ) (hprime : ∀ i, (prime i).Prime) + {ξ P : ℝ} {sourceM siteM D : ℕ} (hP : 0 ≤ P) (K : Finset ι) + (hK : affineSamplerPrimeMask prime ξ P sourceM siteM D ⊆ K) + (i : ι) (hi : i ∉ K) : + sourceM.Coprime (prime i ^ power i) ∧ siteM.Coprime (prime i ^ power i) ∧ + D.Coprime (prime i ^ power i) ∧ (prime i : ℝ)⁻¹ ≤ affineComparisonContraction ξ P := by + have hcontains := affineSamplerPrimeMask_contains prime ξ P sourceM siteM D + have hbase := affineInitialPrimeMask_outside_coprime prime power hprime K (hcontains.1.trans hK) i hi + have hD : D.Coprime (prime i ^ power i) := by + apply Nat.Coprime.pow_right + apply Nat.Coprime.symm + apply (hprime i).coprime_iff_not_dvd.mpr + intro hd + exact hi (hK (hcontains.2 ((mem_periodPrimeCoordinates prime D i).mpr hd))) + have hmandatory := (affineInitialPrimeMask_contains prime ξ P sourceM siteM).1.trans (hcontains.1.trans hK) + exact ⟨hbase.1, hbase.2, hD, affineMandatoryPrimes_outside_inverse prime hP K hmandatory i hi⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def affineReferencePower (epsilon : ℝ) : ℕ := + 4 + CyclicCrootSisask.spectralIterations (epsilon / (2 + epsilon)) 18 + +noncomputable def affineReferenceInput (epsilon U : ℝ) : ℝ := + (affinePrimitiveLogBudget U + 2) ^ affineReferencePower epsilon + + affinePrimitiveLogBudget U + 3 * U + 10 + +theorem affineReferenceInput_bounds (epsilon : ℝ) {U : ℝ} (hU : 0 ≤ U) : + 2 ≤ affineReferenceInput epsilon U ∧ U ≤ affineReferenceInput epsilon U ∧ + affinePrimitiveLogBudget U ≤ affineReferenceInput epsilon U := by + have hpow : 0 ≤ (affinePrimitiveLogBudget U + 2) ^ affineReferencePower epsilon := + pow_nonneg (by unfold affinePrimitiveLogBudget; positivity) _ + unfold affineReferenceInput affinePrimitiveLogBudget at * + constructor + · linarith + constructor <;> linarith + +theorem affineReferenceInput_le_envelope (epsilon : ℝ) {U : ℝ} (hU : 0 ≤ U) : + affineReferenceInput epsilon U ≤ (20 * (U + 3)) ^ (affineReferencePower epsilon + 1) := by + let B := 20 * (U + 3) + have hB : 2 ≤ B := by dsimp only [B]; linarith + have hk : 1 ≤ affineReferencePower epsilon := by unfold affineReferencePower; omega + have hp := pow_le_pow_left₀ (by unfold affinePrimitiveLogBudget; positivity : + 0 ≤ affinePrimitiveLogBudget U + 2) + (by dsimp only [B]; unfold affinePrimitiveLogBudget; linarith : affinePrimitiveLogBudget U + 2 ≤ B) + (affineReferencePower epsilon) + have hBpow : B ≤ B ^ affineReferencePower epsilon := by + simpa only [pow_one] using pow_le_pow_right₀ (by linarith : 1 ≤ B) hk + have htail : affinePrimitiveLogBudget U + 3 * U + 10 ≤ B := by + dsimp only [B]; unfold affinePrimitiveLogBudget; linarith + have hn : 0 ≤ B ^ affineReferencePower epsilon := pow_nonneg (by linarith) _ + change _ ≤ B ^ (affineReferencePower epsilon + 1) + rw [pow_succ] + unfold affineReferenceInput + nlinarith + +theorem affineReferenceInput_mask_and_depth {ι : Type*} [Fintype ι] + (prime : ι → ℕ) (hprime : ∀ i, (prime i).Prime) (hinj : Function.Injective prime) + (D : ℕ) (hD : 0 < D) {epsilon L T C U : ℝ} + (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) (hU : 0 ≤ U) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) + (hLU : L ≤ U) (hTU : T ≤ U) (hCU : C ≤ U) + (hepsInv : epsilon⁻¹ ≤ Real.exp U) (hDU : (D : ℝ) ≤ Real.exp U) : + ((affineSamplerPrimeMask prime (epsilon / (2 + epsilon)) + (affineComparisonScale epsilon L T C) 1 1 D).card : ℝ) ≤ affineReferenceInput epsilon U ∧ + ((affineRemovalDepth T + affineComparisonTail epsilon L T : ℕ) : ℝ) ≤ affineReferenceInput epsilon U ∧ + T + 4 ≤ affineReferenceInput epsilon U := by + have hprim := affineComparisonPrimitive_bounds hepsilon hepsilon1 hU hL hT hC hLU hTU hCU hepsInv + have hs := (affineComparisonScale_bounds (ε := epsilon) hL hT hC).1 + have hm := affineSamplerPrimeMask_card_le (ξ := epsilon / (2 + epsilon)) prime hprime hinj hs + (by norm_num : 0 < (1 : ℕ)) (by norm_num : 0 < (1 : ℕ)) hD + (by simp : ((1 : ℕ) : ℝ) ≤ Real.exp 0) (by simp : ((1 : ℕ) : ℝ) ≤ Real.exp 0) hDU + have hthreshold : affineComparisonPrimeThreshold (epsilon / (2 + epsilon)) + (affineComparisonScale epsilon L T C) ≤ + (affinePrimitiveLogBudget U + 2) ^ affineReferencePower epsilon := by + exact pow_le_pow_left₀ (by linarith) (by linarith [hprim.2.1]) _ + have hbudget := affineReferenceInput_bounds epsilon hU + refine ⟨?_, hprim.1.trans hbudget.2.2, ?_⟩ + · unfold affineReferenceInput + norm_num at hm + linarith [affinePrimitiveLogBudget_nonneg hU] + · have hpow : 0 ≤ (affinePrimitiveLogBudget U + 2) ^ affineReferencePower epsilon := + pow_nonneg (by unfold affinePrimitiveLogBudget; positivity) _ + unfold affineReferenceInput affinePrimitiveLogBudget at * + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def primeCoordinateCell {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + Finset (σ → ℤ) := by + classical + exact (translatedIntegerBox lo N).filter (fun z => ∀ i ∈ I, (fun j => (z j : ZMod (q i))) = x i) + +@[simp] theorem mem_primeCoordinateCell {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) (z : σ → ℤ) : + z ∈ primeCoordinateCell lo N q I x ↔ + z ∈ translatedIntegerBox lo N ∧ ∀ i ∈ I, (fun j => (z j : ZMod (q i))) = x i := by + classical + simp only [primeCoordinateCell, Finset.mem_filter] + +theorem primeCoordinateCell_anchor {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (u : σ → ℤ) (hu : u ∈ primeCoordinateCell lo N q I x) : + primeCoordinateCell lo N q I x = primeCoordinateCell lo N q I (fun i j => (u j : ZMod (q i))) := by + ext z + simp only [mem_primeCoordinateCell] at hu ⊢ + constructor + · rintro ⟨hz, heq⟩ + exact ⟨hz, fun i hi => (heq i hi).trans (hu.2 i hi).symm⟩ + · rintro ⟨hz, heq⟩ + exact ⟨hz, fun i hi => (heq i hi).trans (hu.2 i hi)⟩ + +theorem mem_primeCoordinateCell_anchor {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (I : Finset ι) (u z : σ → ℤ) : + z ∈ primeCoordinateCell lo N q I (fun i j => (u j : ZMod (q i))) ↔ + z ∈ translatedIntegerBox lo N ∧ ∀ j, z j ≡ u j [ZMOD ((∏ i ∈ I, q i : ℕ) : ℤ)] := by + rw [mem_primeCoordinateCell] + constructor + · rintro ⟨hz, heq⟩ + refine ⟨hz, ?_⟩ + intro j + apply (modEq_selected_prod_iff q hcop I (z j) (u j)).mpr + intro i hi + exact (ZMod.intCast_eq_intCast_iff (z j) (u j) (q i)).mp (congrFun (heq i hi) j) + · rintro ⟨hz, hmod⟩ + refine ⟨hz, ?_⟩ + intro i hi + funext j + exact (ZMod.intCast_eq_intCast_iff (z j) (u j) (q i)).mpr + ((modEq_selected_prod_iff q hcop I (z j) (u j)).mp (hmod j) i hi) + +noncomputable def primeCoordinateCellEquiv {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (I : Finset ι) (u : σ → ℤ) : + primeCoordinateCell lo N q I (fun i j => (u j : ZMod (q i))) ≃ + IntegerResidueBox lo (fun j => lo j + N j) (fun _ => ((∏ i ∈ I, q i : ℕ) : ℤ)) u where + toFun z := fun j => ⟨z.val j, Finset.mem_filter.mpr ⟨Finset.mem_Ico.mpr + ((mem_translatedIntegerBox lo N z.val).mp ((mem_primeCoordinateCell_anchor lo N q hcop I u z.val).mp z.property).1 j), + ((mem_primeCoordinateCell_anchor lo N q hcop I u z.val).mp z.property).2 j⟩⟩ + invFun z := ⟨fun j => (z j).val, (mem_primeCoordinateCell_anchor lo N q hcop I u _).mpr + ⟨(mem_translatedIntegerBox lo N _).mpr (fun j => Finset.mem_Ico.mp (Finset.mem_filter.mp (z j).property).1), + fun j => (Finset.mem_filter.mp (z j).property).2⟩⟩ + left_inv z := by apply Subtype.ext; rfl + right_inv z := by funext j; apply Subtype.ext; rfl + +theorem primeCoordinateCell_mean {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (I : Finset ι) (u : σ → ℤ) + (f : (σ → ℤ) → ℂ) : + (𝔼 z : primeCoordinateCell lo N q I (fun i j => (u j : ZMod (q i))), f z.val) = + physicalResidueMean f lo N (∏ i ∈ I, q i) u := by + exact Fintype.expect_equiv (primeCoordinateCellEquiv lo N q hcop I u) _ _ (fun _ => rfl) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PrimeFamilyCutoff.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PrimeFamilyCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8e04f6ade0c1a8639802912eee674ba909d4c70 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PrimeFamilyCutoff.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.Progressions.Polynomial.GlobalAffineDegreeChoice + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def adaptiveAffineCountLog (A sourceDim siteDim : ℕ) + (ε L T C modLog : ℝ) : ℝ := + (A : ℝ) * (affineComparisonScale ε L T C + + (sourceDim : ℝ) * modLog + (siteDim : ℝ) * modLog + 1) + +noncomputable def adaptiveAffineShell (A sourceDim siteDim : ℕ) + (ε L T C totalShell modLog : ℝ) : ℝ := + totalShell * Real.exp (-adaptiveAffineCountLog A sourceDim siteDim ε L T C modLog) + +noncomputable def adaptiveAffineCutoff (A sourceDim siteDim : ℕ) + (ε L T C totalShell modLog : ℝ) : ℕ := + affineGlobalComparisonDegree A sourceDim siteDim ε L T C + (adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog) modLog 0 + +noncomputable def adaptiveAffineSideLog (A sourceDim siteDim : ℕ) + (ε L T C totalShell modLog dimLog : ℝ) : ℝ := + modLog * A + affineComparisonLengthLog + (adaptiveAffineCutoff A sourceDim siteDim ε L T C totalShell modLog) + ε L T C modLog dimLog + 2 + +theorem adaptiveAffineCountLog_nonneg (A sourceDim siteDim : ℕ) + {ε L T C modLog : ℝ} (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) (hmodLog : 0 ≤ modLog) : + 0 ≤ adaptiveAffineCountLog A sourceDim siteDim ε L T C modLog := by + have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1 + unfold adaptiveAffineCountLog + positivity + +theorem adaptiveAffineShell_pos (A sourceDim siteDim : ℕ) + (ε L T C modLog : ℝ) {totalShell : ℝ} (h : 0 < totalShell) : + 0 < adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog := + mul_pos h (Real.exp_pos _) + +theorem adaptiveAffineShell_allocation (A sourceDim siteDim : ℕ) + (ε L T C totalShell modLog : ℝ) : + Real.exp (adaptiveAffineCountLog A sourceDim siteDim ε L T C modLog) * + adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog = totalShell := by + unfold adaptiveAffineShell + rw [mul_left_comm, ← Real.exp_add] + simp + +theorem adaptiveAffineShell_le (A sourceDim siteDim : ℕ) + {ε L T C totalShell modLog : ℝ} (hL : 0 ≤ L) (hT : 0 ≤ T) (hC : 0 ≤ C) + (hmodLog : 0 ≤ modLog) (h : 0 ≤ totalShell) : + adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog ≤ totalShell := by + have hexp := Real.exp_le_one_iff.mpr (neg_nonpos.mpr + (adaptiveAffineCountLog_nonneg (ε := ε) A sourceDim siteDim hL hT hC hmodLog)) + exact (mul_le_mul_of_nonneg_left hexp h).trans_eq (mul_one totalShell) + +theorem adaptiveAffineShell_log (A sourceDim siteDim : ℕ) + (ε L T C modLog : ℝ) {totalShell : ℝ} (h : 0 < totalShell) : + Real.log (adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog) = + Real.log totalShell - adaptiveAffineCountLog A sourceDim siteDim ε L T C modLog := by + rw [adaptiveAffineShell, Real.log_mul h.ne' (Real.exp_pos _).ne', Real.log_exp] + rfl + +theorem adaptiveAffineCutoff_bounds (A sourceDim siteDim : ℕ) + (ε L T C totalShell modLog : ℝ) : + A + affineComparisonDegree sourceDim siteDim ε L T C + (adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog) modLog ≤ + adaptiveAffineCutoff A sourceDim siteDim ε L T C totalShell modLog ∧ + A + CyclicCrootSisask.spectralIterations + (adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog) + ((A : ℝ) * ((sourceDim : ℝ) * modLog + (siteDim : ℝ) * modLog + 1) + 4) ≤ + adaptiveAffineCutoff A sourceDim siteDim ε L T C totalShell modLog := by + have h := affineGlobalComparisonDegree_bounds A sourceDim siteDim ε L T C + (adaptiveAffineShell A sourceDim siteDim ε L T C totalShell modLog) modLog 0 le_rfl + exact ⟨h.1, h.2.1⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem boundedPrimeFamily_log_bounds (Q : ℕ) {P : ℝ} (hQ : (Q : ℝ) ≤ Real.exp P) : + (Fintype.card (BoundedPrime Q) : ℝ) ≤ Real.exp P ∧ + ∀ p : BoundedPrime Q, (boundedPrimePower Q p : ℝ) ≤ Real.exp P := by + exact ⟨(Nat.cast_le.mpr (boundedPrime_card_le Q)).trans hQ, + fun p => (Nat.cast_le.mpr (boundedPrimePower_le Q p)).trans hQ⟩ + +theorem nat_le_two_pow_of_le_exp {Q b : ℕ} {P : ℝ} + (hQ : (Q : ℝ) ≤ Real.exp P) (hPb : 2 * P ≤ (b : ℝ)) : Q ≤ 2 ^ b := by + have hlog : (1 : ℝ) / 2 ≤ Real.log 2 := by + have h := Real.one_sub_inv_le_log_of_pos (by norm_num : (0 : ℝ) < 2) + norm_num at h ⊢ + exact h + have hb : (0 : ℝ) ≤ b := Nat.cast_nonneg b + have hP : P ≤ (b : ℝ) * Real.log 2 := by nlinarith + have he : Real.exp P ≤ (2 : ℝ) ^ b := by + calc + _ ≤ Real.exp ((b : ℝ) * Real.log 2) := Real.exp_le_exp.mpr hP + _ = _ := by rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + exact_mod_cast hQ.trans he + +theorem ceil_power_dominates_twice {p : ℝ} {E : ℕ} (hp : 2 ≤ p) (hE : 2 ≤ E) : + 2 * p ≤ (⌈(p + 2) ^ E⌉₊ : ℝ) := by + have hpow : (p + 2) ^ 2 ≤ (p + 2) ^ E := pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) hE + have hbase : 2 * p ≤ (p + 2) ^ 2 := by nlinarith [sq_nonneg p] + exact (hbase.trans hpow).trans (Nat.le_ceil _) + +theorem adaptiveAffineCutoff_captures_moduli {Q E : ℕ} {p modLog : ℝ} + (hp : 2 ≤ p) (hE : 2 ≤ E) (hmodLog : modLog ≤ p) (hQ : (Q : ℝ) ≤ Real.exp modLog) + (sourceDim siteDim : ℕ) (ε L T C totalShell : ℝ) : + Q ≤ 2 ^ adaptiveAffineCutoff ⌈(p + 2) ^ E⌉₊ sourceDim siteDim ε L T C totalShell modLog := by + have h := (adaptiveAffineCutoff_bounds ⌈(p + 2) ^ E⌉₊ sourceDim siteDim ε L T C totalShell modLog).1 + have hA : ⌈(p + 2) ^ E⌉₊ ≤ adaptiveAffineCutoff ⌈(p + 2) ^ E⌉₊ sourceDim siteDim ε L T C totalShell modLog := by omega + have hAreal : (⌈(p + 2) ^ E⌉₊ : ℝ) ≤ + (adaptiveAffineCutoff ⌈(p + 2) ^ E⌉₊ sourceDim siteDim ε L T C totalShell modLog : ℝ) := by exact_mod_cast hA + apply nat_le_two_pow_of_le_exp hQ + have hpow := ceil_power_dominates_twice hp hE + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PrimeStabilityTree.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PrimeStabilityTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..018de7ac1a234f4b3352560ff5711df8eff6e71f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PrimeStabilityTree.lean @@ -0,0 +1,427 @@ +import OAI.Combinatorics.Progressions.Dynamics.BudgetedPhysicalStackPeriods +import OAI.Combinatorics.Progressions.Geometry.CoordinateTreeBatch +import OAI.Combinatorics.Progressions.Lattices.AffineSampleAlphabet + +namespace OAI + +section + +namespace Erdos3 + +open PhysicalEpochStack +open scoped BigOperators + +universe u v w + +structure PrimeStabilityContext (ι : Type w) (σ : Type u) [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (s bound : ℕ) where + parameters : PhysicalStabilityParameters.{u, v} s + base : PhysicalEpochSource.{u, v} σ s bound + baseline : base.model.Niltest (fun _ : σ => 1) + orbit : baseline.orbit = base.fixedMap.orbit + positive : baseline.UnitIntervalValued + complexity : baseline.ComplexityLE base.incomingBudget + recordCap : ℝ + recordCap_nonneg : 0 ≤ recordCap + record_le_cap : base.recordBudget ≤ recordCap + inflation : (base.incomingBudget + 2) ^ parameters.A ≤ base.recordBudget + record_two : 2 ≤ base.recordBudget + gap : ℝ + gap_pos : 0 < gap + gap_le_one : gap ≤ 1 + gap_inverse : gap⁻¹ ≤ Real.exp base.incomingBudget + prime : ι → ℕ + power : ι → ℕ + prime_prime : ∀ i, (prime i).Prime + prime_injective : Function.Injective prime + primeBudget : ℝ + primeBudget_nonneg : 0 ≤ primeBudget + prime_bound : ∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp primeBudget + witnessSize : ℕ + mandatory : Finset ι + +namespace PrimeStabilityContext + +variable {ι : Type w} {σ : Type u} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {s bound : ℕ} + +def moduli (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (i : ι) : ℕ := + ctx.prime i ^ ctx.power i + +def workBudget (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) : ℝ := + physicalEpochBudget ctx.parameters.A ctx.parameters.C ctx.recordCap s + +noncomputable def periodCap (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) : ℕ := + ⌈2 * ((s : ℝ) * ctx.workBudget)⌉₊ + +noncomputable def stepCost (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) : ℕ := + ctx.periodCap + ctx.witnessSize + +noncomputable def allowance (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) : ℕ := + ctx.mandatory.card + ctx.stepCost * (bound + 1) ^ s + +noncomputable def HasLargeSides (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) : Prop := + ∀ i, Real.exp (ctx.primeBudget * ctx.allowance + 5 * ctx.workBudget + + 2 * (ctx.workBudget + 2) ^ ctx.parameters.Kf + 16) ≤ (ctx.base.sides i : ℝ) + +noncomputable def Good (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) + (I : Finset ι) (x : ∀ i, σ → ZMod (ctx.moduli i)) : Prop := + PrimeCoordinateStable ctx.baseline.eval ctx.base.lower ctx.base.sides ctx.moduli ctx.witnessSize ctx.gap I x + +structure State (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) + (I : Finset ι) (x : ∀ i, σ → ZMod (ctx.moduli i)) where + anchor : σ → ℤ + anchor_mem : anchor ∈ primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli I x + stack : PhysicalEpochStack ctx.base + scheduled : ScheduledAt ctx.parameters.A ctx.parameters.C ctx.recordCap 0 stack + aligned : AlignedAt (∏ i ∈ I, ctx.moduli i) anchor stack + room : I.card + ctx.stepCost * (epochStackRank bound stack.dimensions + 1) ≤ ctx.allowance + +noncomputable def State.rank {ctx : PrimeStabilityContext.{u, v, w} ι σ s bound} + {I : Finset ι} {x : ∀ i, σ → ZMod (ctx.moduli i)} (state : ctx.State I x) : ℕ := + epochStackRank bound state.stack.dimensions + +theorem moduli_pos (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (i : ι) : 0 < ctx.moduli i := + pow_pos (ctx.prime_prime i).pos _ + +theorem moduli_coprime (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) : + Pairwise (fun i j => (ctx.moduli i).Coprime (ctx.moduli j)) := + selectedPrimePowers_pairwise_coprime ctx.prime ctx.power ctx.prime_prime ctx.prime_injective + +theorem workBudget_nonneg (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) : 0 ≤ ctx.workBudget := + physicalEpochBudget_nonneg ctx.parameters.A ctx.parameters.C ctx.recordCap_nonneg s + +end PrimeStabilityContext + +end Erdos3 + +end + +section + +namespace Erdos3.PrimeStabilityContext + +open PhysicalEpochStack +open scoped BigOperators + +universe u v w + +variable {ι : Type w} {σ : Type u} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {s bound : ℕ} + +theorem product_pos (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (I : Finset ι) : + 0 < ∏ i ∈ I, ctx.moduli i := Finset.prod_pos (fun i _ => ctx.moduli_pos i) + +theorem product_le_exp_card (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (I : Finset ι) : + ((∏ i ∈ I, ctx.moduli i : ℕ) : ℝ) ≤ Real.exp (ctx.primeBudget * I.card) := by + rw [Nat.cast_prod] + calc + (∏ i ∈ I, (ctx.moduli i : ℝ)) ≤ ∏ _i ∈ I, Real.exp ctx.primeBudget := + Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun i _ => ctx.prime_bound i) + _ = Real.exp ((I.card : ℝ) * ctx.primeBudget) := by rw [Finset.prod_const, Real.exp_nat_mul] + _ = Real.exp (ctx.primeBudget * I.card) := by rw [mul_comm] + +theorem node_width (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (hlarge : ctx.HasLargeSides) + (I : Finset ι) (hcard : I.card ≤ ctx.allowance) (j : σ) : + ((∏ i ∈ I, ctx.moduli i : ℕ) : ℝ) * + Real.exp (5 * ctx.workBudget + 2 * (ctx.workBudget + 2) ^ ctx.parameters.Kf + 16) ≤ (ctx.base.sides j : ℝ) := by + have hcardR : (I.card : ℝ) ≤ ctx.allowance := by exact_mod_cast hcard + have hprod : ((∏ i ∈ I, ctx.moduli i : ℕ) : ℝ) ≤ Real.exp (ctx.primeBudget * ctx.allowance) := + (ctx.product_le_exp_card I).trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hcardR ctx.primeBudget_nonneg)) + calc + _ ≤ Real.exp (ctx.primeBudget * ctx.allowance) * + Real.exp (5 * ctx.workBudget + 2 * (ctx.workBudget + 2) ^ ctx.parameters.Kf + 16) := + mul_le_mul_of_nonneg_right hprod (Real.exp_nonneg _) + _ = Real.exp (ctx.primeBudget * ctx.allowance + 5 * ctx.workBudget + + 2 * (ctx.workBudget + 2) ^ ctx.parameters.Kf + 16) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ (ctx.base.sides j : ℝ) := hlarge j + +theorem construction_width (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (hlarge : ctx.HasLargeSides) + (I : Finset ι) (hcard : I.card ≤ ctx.allowance) (j : σ) : + Real.exp ctx.workBudget ≤ (ctx.base.sides j : ℝ) / (∏ i ∈ I, ctx.moduli i : ℕ) := by + have hp : (0 : ℝ) < ((∏ i ∈ I, ctx.moduli i : ℕ) : ℝ) := by exact_mod_cast ctx.product_pos I + have hU := ctx.workBudget_nonneg + have hpow : 0 ≤ (ctx.workBudget + 2) ^ ctx.parameters.Kf := by positivity + apply (le_div_iff₀ hp).mpr + calc + _ = ((∏ i ∈ I, ctx.moduli i : ℕ) : ℝ) * Real.exp ctx.workBudget := mul_comm _ _ + _ ≤ ((∏ i ∈ I, ctx.moduli i : ℕ) : ℝ) * + Real.exp (5 * ctx.workBudget + 2 * (ctx.workBudget + 2) ^ ctx.parameters.Kf + 16) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) hp.le + _ ≤ (ctx.base.sides j : ℝ) := ctx.node_width hlarge I hcard j + +variable {ctx : PrimeStabilityContext.{u, v, w} ι σ s bound} + {I : Finset ι} {x : ∀ i, σ → ZMod (ctx.moduli i)} + +noncomputable def State.periodBatch (state : ctx.State I x) : Finset ι := + periodPrimeCoordinates ctx.prime state.stack.periods.prod \ I + +theorem State.periodBatch_disjoint (state : ctx.State I x) : Disjoint I state.periodBatch := by + apply Finset.disjoint_left.mpr + intro i hi hp + exact (Finset.mem_sdiff.mp hp).2 hi + +theorem State.periodBatch_card (state : ctx.State I x) : state.periodBatch.card ≤ ctx.periodCap := by + have hb : BudgetedAt ctx.parameters.A ctx.workBudget ctx.parameters.C state.stack := by + simpa only [Nat.zero_add, workBudget] using + state.scheduled.budgeted ctx.parameters.A_pos (by linarith [ctx.parameters.C_ge_two]) ctx.recordCap_nonneg + have hcard := hb.new_period_exclusions_card_le ctx.prime ctx.prime_prime ctx.prime_injective I + have hceil : 2 * ((s : ℝ) * ctx.workBudget) ≤ (ctx.periodCap : ℝ) := Nat.le_ceil _ + exact_mod_cast hcard.trans hceil + +theorem State.periods_covered (state : ctx.State I x) : + periodPrimeCoordinates ctx.prime state.stack.periods.prod ⊆ I ∪ state.periodBatch := by + intro i hi + by_cases hI : i ∈ I + · exact Finset.mem_union_left _ hI + · exact Finset.mem_union_right _ (Finset.mem_sdiff.mpr ⟨hi, hI⟩) + +theorem State.one_step_room (state : ctx.State I x) : I.card + ctx.stepCost ≤ ctx.allowance := by + have hmul : ctx.stepCost ≤ ctx.stepCost * (state.rank + 1) := by + have h := Nat.mul_le_mul_left ctx.stepCost (show 1 ≤ state.rank + 1 by omega) + simpa only [Nat.mul_one] using h + have hroom : I.card + ctx.stepCost * (state.rank + 1) ≤ ctx.allowance := state.room + omega + +theorem State.room_of_smaller_rank (state : ctx.State I x) (J : Finset ι) (rank : ℕ) + (hcard : J.card ≤ I.card + ctx.stepCost) (hrank : rank < state.rank) : + J.card + ctx.stepCost * (rank + 1) ≤ ctx.allowance := by + have hmul := Nat.mul_le_mul_left ctx.stepCost (Nat.succ_le_of_lt hrank) + have hroom : I.card + ctx.stepCost * (state.rank + 1) ≤ ctx.allowance := state.room + nlinarith + +theorem State.aligned_refinement (state : ctx.State I x) {J : Finset ι} + {y : ∀ i, σ → ZMod (ctx.moduli i)} (hIJ : I ⊆ J) (hxy : ∀ i ∈ I, y i = x i) + (u : σ → ℤ) (hu : u ∈ primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli J y) : + AlignedAt (∏ i ∈ J, ctx.moduli i) u state.stack := by + apply state.aligned.refine (Finset.prod_dvd_prod_of_subset I J ctx.moduli hIJ) + have hmem := primeCoordinateCell_mono ctx.base.lower ctx.base.sides ctx.moduli hIJ hxy hu + rw [primeCoordinateCell_anchor ctx.base.lower ctx.base.sides ctx.moduli I x state.anchor state.anchor_mem] at hmem + exact ((mem_primeCoordinateCell_anchor ctx.base.lower ctx.base.sides ctx.moduli ctx.moduli_coprime I state.anchor u).mp hmem).2 + +end Erdos3.PrimeStabilityContext + +end + +section + +namespace Erdos3.PrimeStabilityContext + +open PhysicalEpochStack +open scoped BigOperators + +universe u v w + +variable {ι : Type w} {σ : Type u} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {s bound : ℕ} {ctx : PrimeStabilityContext.{u, v, w} ι σ s bound} + {I : Finset ι} {x : ∀ i, σ → ZMod (ctx.moduli i)} + +theorem State.repair_cell (state : ctx.State I x) (hlarge : ctx.HasLargeSides) + (L J : Finset ι) (hIL : I ⊆ L) (hLJ : Disjoint L J) + (hperiods : periodPrimeCoordinates ctx.prime state.stack.periods.prod ⊆ L) + (hcard : (L ∪ J).card ≤ I.card + ctx.stepCost) + (y z : ∀ i, σ → ZMod (ctx.moduli i)) + (hy : ∀ i ∈ I, y i = x i) (hz : ∀ i ∈ L, z i = y i) + (u v : σ → ℤ) + (hu : u ∈ primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli L y) + (hv : v ∈ primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli (L ∪ J) z) + (hgap : ctx.gap ≤ ‖primeCoordinateMean ctx.baseline.eval ctx.base.lower ctx.base.sides ctx.moduli L y - + primeCoordinateMean ctx.baseline.eval ctx.base.lower ctx.base.sides ctx.moduli (L ∪ J) z‖) + (target : ∀ i, σ → ZMod (ctx.moduli i)) (htarget : ∀ i ∈ L, target i = y i) + (anchor : σ → ℤ) + (hanchor : anchor ∈ primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli (L ∪ J) target) : + ∃ next : ctx.State (L ∪ J) target, next.rank < state.rank := by + have halign := state.aligned_refinement hIL hy u hu + obtain ⟨c, hc, hcu, _⟩ := exists_prime_cell_physical_comparison ctx.base ctx.baseline ctx.orbit + ctx.positive ctx.complexity ctx.moduli ctx.moduli_pos ctx.moduli_coprime L J hLJ y z hz u v hu hv + ctx.gap_pos ctx.gap_le_one ctx.gap_inverse ctx.record_two hgap + have hdisjoint : Disjoint J (L ∪ periodPrimeCoordinates ctx.prime state.stack.periods.prod) := + hLJ.symm.mono_right (Finset.union_subset (Finset.Subset.refl _) hperiods) + have hcop := state.stack.pending_coprime_selected_periods ctx.prime ctx.power ctx.prime_prime + ctx.prime_injective L J hdisjoint + have hcardD : (L ∪ J).card ≤ ctx.allowance := hcard.trans state.one_step_room + have hsource : ∀ j, (((∏ i ∈ L, ctx.moduli i) * (∏ i ∈ J, ctx.moduli i) : ℕ) : ℝ) * + Real.exp (5 * ctx.workBudget + 2 * (ctx.workBudget + 2) ^ ctx.parameters.Kf + 16) ≤ (ctx.base.sides j : ℝ) := by + intro j + simpa only [Finset.prod_union hLJ] using ctx.node_width hlarge (L ∪ J) hcardD j + have hinside := (mem_translatedIntegerBox ctx.base.lower ctx.base.sides anchor).mp + ((mem_primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli (L ∪ J) target anchor).mp hanchor).1 + have hanchorOld := primeCoordinateCell_mono ctx.base.lower ctx.base.sides ctx.moduli + Finset.subset_union_left htarget hanchor + rw [primeCoordinateCell_anchor ctx.base.lower ctx.base.sides ctx.moduli L y u hu] at hanchorOld + have hcompat := ((mem_primeCoordinateCell_anchor ctx.base.lower ctx.base.sides ctx.moduli + ctx.moduli_coprime L u anchor).mp hanchorOld).2 + obtain ⟨nextStack, hevent, hnextAlign, hnextSchedule⟩ := ctx.parameters.event ctx.recordCap 0 u + state.stack c ctx.recordCap_nonneg (by omega) state.scheduled halign hc + (fun i => by rw [hcu]) (by simpa only [Nat.mul_one, moduli] using hcop) + (by simpa only [Nat.zero_add, workBudget] using hsource) anchor hinside hcompat + have hnextAlign' : AlignedAt (∏ i ∈ L ∪ J, ctx.moduli i) anchor nextStack := by + simpa only [Finset.prod_union hLJ] using hnextAlign + have hdrop : epochStackRank bound nextStack.dimensions < state.rank := hevent.rank_lt + let next : ctx.State (L ∪ J) target := { + anchor := anchor + anchor_mem := hanchor + stack := nextStack + scheduled := hnextSchedule + aligned := hnextAlign' + room := state.room_of_smaller_rank (L ∪ J) _ hcard hdrop } + exact ⟨next, hdrop⟩ + +end Erdos3.PrimeStabilityContext + +end + +section + +namespace Erdos3.PrimeStabilityContext + +open PhysicalEpochStack CoordinateDecisionTree + +universe u v w + +variable {ι : Type w} {σ : Type u} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {s bound : ℕ} {ctx : PrimeStabilityContext.{u, v, w} ι σ s bound} + {I : Finset ι} {x : ∀ i, σ → ZMod (ctx.moduli i)} + +theorem State.local_tree (state : ctx.State I x) (hlarge : ctx.HasLargeSides) : + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (ctx.moduli i)), + Valid (fun J y => ctx.Good J y ∨ ∃ next : ctx.State J y, next.rank < state.rank) + I x tree ctx.stepCost := by + classical + let Post := fun (J : Finset ι) (y : ∀ i, σ → ZMod (ctx.moduli i)) => + ctx.Good J y ∨ ∃ next : ctx.State J y, next.rank < state.rank + let batch := state.periodBatch + have hbatchCard : batch.card ≤ ctx.periodCap := state.periodBatch_card + have afterPeriods : ∀ y : ∀ i, σ → ZMod (ctx.moduli i), (∀ i ∈ I, y i = x i) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (ctx.moduli i)), + Valid Post (I ∪ batch) y tree ctx.witnessSize := by + intro y hy + let L := I ∪ batch + by_cases hgood : ctx.Good L y + · exact ⟨.leaf, .leaf (Or.inl hgood)⟩ + · have hnonempty : (primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli L y).Nonempty := by + by_contra hempty + exact hgood (primeCoordinateStable_of_empty ctx.baseline.eval ctx.base.lower ctx.base.sides + ctx.moduli ctx.witnessSize ctx.gap L y hempty) + obtain ⟨u, hu⟩ := hnonempty + have hbad := hgood + change ¬ PrimeCoordinateStable ctx.baseline.eval ctx.base.lower ctx.base.sides ctx.moduli + ctx.witnessSize ctx.gap L y at hbad + unfold PrimeCoordinateStable at hbad + push Not at hbad + obtain ⟨J, hLJ, hJ, z, hzy, hznonempty, hgap⟩ := hbad + obtain ⟨v, hv⟩ := hznonempty + have hcard : (L ∪ J).card ≤ I.card + ctx.stepCost := by + have hL : L.card ≤ I.card + batch.card := Finset.card_union_le I batch + have hLJcard : (L ∪ J).card ≤ L.card + J.card := Finset.card_union_le L J + change (L ∪ J).card ≤ I.card + (ctx.periodCap + ctx.witnessSize) + omega + have hperiods : periodPrimeCoordinates ctx.prime state.stack.periods.prod ⊆ L := state.periods_covered + have afterWitness : ∀ target : ∀ i, σ → ZMod (ctx.moduli i), (∀ i ∈ L, target i = y i) → + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (ctx.moduli i)), + Valid Post (L ∪ J) target tree 0 := by + intro target htarget + by_cases hnonempty : (primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli (L ∪ J) target).Nonempty + · obtain ⟨anchor, hanchor⟩ := hnonempty + obtain ⟨next, hnext⟩ := state.repair_cell hlarge L J Finset.subset_union_left hLJ hperiods hcard + y z hy hzy u v hu hv hgap.le target htarget anchor hanchor + exact ⟨.leaf, .leaf (Or.inr ⟨next, hnext⟩)⟩ + · exact ⟨.leaf, .leaf (Or.inl (primeCoordinateStable_of_empty ctx.baseline.eval ctx.base.lower + ctx.base.sides ctx.moduli ctx.witnessSize ctx.gap (L ∪ J) target hnonempty))⟩ + obtain ⟨tree, htree⟩ := exists_query_batch Post J 0 L y hLJ afterWitness + exact ⟨tree, htree.mono (by omega)⟩ + obtain ⟨tree, htree⟩ := exists_query_batch Post batch ctx.witnessSize I x state.periodBatch_disjoint afterPeriods + exact ⟨tree, htree.mono (by change batch.card + ctx.witnessSize ≤ ctx.periodCap + ctx.witnessSize; omega)⟩ + +end Erdos3.PrimeStabilityContext + +end + +section + +namespace Erdos3.PrimeStabilityContext + +open PhysicalEpochStack CoordinateDecisionTree +open scoped BigOperators + +universe u v w + +variable {ι : Type w} {σ : Type u} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {s bound : ℕ} + +theorem State.stable_tree {ctx : PrimeStabilityContext.{u, v, w} ι σ s bound} + {I : Finset ι} {x : ∀ i, σ → ZMod (ctx.moduli i)} (state : ctx.State I x) (hlarge : ctx.HasLargeSides) : + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (ctx.moduli i)), + Valid ctx.Good I x tree (ctx.stepCost * (state.rank + 1)) := + exists_of_rank_decreasing_step (fun I x => ctx.State I x) (fun _ _ state => state.rank) + ctx.Good ctx.stepCost (fun _ _ state => state.local_tree hlarge) I x state + +theorem exists_stable_tree (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (hlarge : ctx.HasLargeSides) : + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (ctx.moduli i)), + Valid (fun I x => ctx.mandatory ⊆ I ∧ ctx.Good I x) ∅ (fun _ _ => 0) tree ctx.allowance := by + classical + let Final := fun (I : Finset ι) (x : ∀ i, σ → ZMod (ctx.moduli i)) => ctx.mandatory ⊆ I ∧ ctx.Good I x + let depth := ctx.stepCost * (bound + 1) ^ s + have afterMandatory : ∀ y : ∀ i, σ → ZMod (ctx.moduli i), + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (ctx.moduli i)), + Valid Final ctx.mandatory y tree depth := by + intro y + by_cases hnonempty : (primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli ctx.mandatory y).Nonempty + · obtain ⟨anchor, hanchor⟩ := hnonempty + have hinside := (mem_translatedIntegerBox ctx.base.lower ctx.base.sides anchor).mp + ((mem_primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli ctx.mandatory y anchor).mp hanchor).1 + have hmandatory : ctx.mandatory.card ≤ ctx.allowance := by + change ctx.mandatory.card ≤ ctx.mandatory.card + _ + omega + have hnorm : ∀ i, Real.exp (physicalEpochBudget ctx.parameters.A ctx.parameters.C ctx.recordCap (0 + s)) ≤ + (ctx.base.sides i : ℝ) / (∏ j ∈ ctx.mandatory, ctx.moduli j : ℕ) := by + intro i + simpa only [Nat.zero_add, workBudget] using ctx.construction_width hlarge ctx.mandatory hmandatory i + obtain ⟨stack, _, _, halign, hschedule⟩ := + exists_scheduled_physical_epoch_stack ctx.parameters.A ctx.parameters.C s ctx.parameters.A_pos + (by linarith [ctx.parameters.C_ge_two]) (@PhysicalStabilityParameters.frames _ ctx.parameters) + ctx.recordCap ctx.recordCap_nonneg s le_rfl 0 ctx.base (PhysicalEpochRecords.empty ctx.base) + (∏ i ∈ ctx.mandatory, ctx.moduli i) (ctx.product_pos ctx.mandatory) anchor hinside + (by simp [PhysicalEpochRecords.empty]) ctx.record_le_cap ctx.inflation hnorm + have hrank : epochStackRank bound stack.dimensions + 1 ≤ (bound + 1) ^ s := by + have h := epochStackRank_lt bound stack.dimensions stack.dimensions_bounded + rw [stack.dimensions_length] at h + omega + have hroom : ctx.mandatory.card + ctx.stepCost * (epochStackRank bound stack.dimensions + 1) ≤ ctx.allowance := + Nat.add_le_add_left (Nat.mul_le_mul_left ctx.stepCost hrank) _ + let initial : ctx.State ctx.mandatory y := ⟨anchor, hanchor, stack, hschedule, halign, hroom⟩ + obtain ⟨tree, htree⟩ := initial.stable_tree hlarge + exact ⟨tree, (htree.preserve_subset (Finset.Subset.refl _)).mono (Nat.mul_le_mul_left ctx.stepCost hrank)⟩ + · exact ⟨.leaf, .leaf ⟨Finset.Subset.refl _, primeCoordinateStable_of_empty ctx.baseline.eval + ctx.base.lower ctx.base.sides ctx.moduli ctx.witnessSize ctx.gap ctx.mandatory y hnonempty⟩⟩ + obtain ⟨tree, htree⟩ := exists_query_batch Final ctx.mandatory depth ∅ (fun _ _ => 0) + (Finset.disjoint_empty_left _) (fun y _ => by simpa only [Finset.empty_union] using afterMandatory y) + exact ⟨tree, htree⟩ + +theorem exists_covering_stable_tree (ctx : PrimeStabilityContext.{u, v, w} ι σ s bound) (hlarge : ctx.HasLargeSides) : + ∃ tree : CoordinateDecisionTree ι (fun i => σ → ZMod (ctx.moduli i)), + Valid (fun I x => ctx.mandatory ⊆ I ∧ ctx.Good I x) ∅ (fun _ _ => 0) tree ctx.allowance ∧ + ∀ z ∈ translatedIntegerBox ctx.base.lower ctx.base.sides, + let leaf := trace tree ∅ (fun _ _ => 0) (fun i j => (z j : ZMod (ctx.moduli i))) + z ∈ primeCoordinateCell ctx.base.lower ctx.base.sides ctx.moduli leaf.1 leaf.2 ∧ + ctx.mandatory ⊆ leaf.1 ∧ ctx.Good leaf.1 leaf.2 ∧ leaf.1.card ≤ ctx.allowance := by + obtain ⟨tree, htree⟩ := ctx.exists_stable_tree hlarge + refine ⟨tree, htree, ?_⟩ + intro z hz + let input := fun i j => (z j : ZMod (ctx.moduli i)) + have hagree := trace_agrees tree ∅ (fun _ _ => 0) input (by simp) + have hgood := htree.trace_good input + have hcard := htree.trace_card_le input + refine ⟨(mem_primeCoordinateCell _ _ _ _ _ _).mpr ⟨hz, ?_⟩, hgood.1, hgood.2, ?_⟩ + · intro i hi + exact (hagree i hi).symm + · simpa only [Finset.card_empty, Nat.zero_add] using hcard + +end Erdos3.PrimeStabilityContext + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalIntegerInterpolation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalIntegerInterpolation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cba2dcb2a89aec210f6e2f6c7dbd0658d8486763 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalIntegerInterpolation.lean @@ -0,0 +1,52 @@ +import OAI.Combinatorics.Progressions.Probability.PrincipalCoefficientLaw + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def principalIntegerInterpolation (K T γ x : ℝ) : ℝ := + T * normalizedIntegerInterpolation (K / T) (3 * γ / 2) (γ / 2) (T*x) + +theorem principalIntegerInterpolation_grid (K T γ : ℝ) (hK : 0 < K) (hT : 0 < T) + (hγ : 0 < γ) (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ (γ / 2) * (K / T)) (k : ℤ) : + principalIntegerInterpolation K T γ ((k : ℝ) / K) = + K * (principalIntegerPMF K T γ hK hT hγ hlarge k).toReal := by + unfold principalIntegerInterpolation principalIntegerPMF + rw [show T*((k : ℝ)/K) = (k : ℝ)/(K/T) by field_simp, + normalizedIntegerInterpolation_grid _ _ _ (div_pos hK hT) (by positivity) hlarge] + field_simp + +theorem principalIntegerInterpolation_range (K T γ : ℝ) (hK : 0 < K) (hT : 0 < T) + (hγ : 0 < γ) (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ (γ / 2) * (K / T)) (x : ℝ) : + 0 ≤ principalIntegerInterpolation K T γ x ∧ principalIntegerInterpolation K T γ x ≤ 4*T/γ := by + have h := normalizedIntegerInterpolation_range (K/T) (3*γ/2) (γ/2) + (div_pos hK hT) (by positivity) hlarge (T*x) + refine ⟨mul_nonneg hT.le h.1, ?_⟩ + exact (mul_le_mul_of_nonneg_left h.2 hT.le).trans_eq (by ring) + +theorem principalIntegerInterpolation_difference (K T γ : ℝ) (hK : 0 < K) (hT : 0 < T) + (hγ : 0 < γ) (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ (γ / 2) * (K / T)) (x y : ℝ) : + |principalIntegerInterpolation K T γ x - principalIntegerInterpolation K T γ y| ≤ + (8 * (probabilityProfileLipschitz : ℝ) * T^2 / γ^2) * |x-y| := by + have h := normalizedIntegerInterpolation_difference (K/T) (3*γ/2) (γ/2) + (div_pos hK hT) (by positivity) hlarge (T*x) (T*y) + rw [← mul_sub, abs_mul, abs_of_pos hT] at h + unfold principalIntegerInterpolation + rw [← mul_sub, abs_mul, abs_of_pos hT] + exact (mul_le_mul_of_nonneg_left h hT.le).trans_eq (by ring) + +theorem principalIntegerInterpolation_spec (K T γ : ℝ) (hK : 0 < K) (hT : 0 < T) + (hγ : 0 < γ) (hlarge : 8 * (probabilityProfileLipschitz : ℝ) ≤ (γ / 2) * (K / T)) : + IsIntegerMassInterpolation K (principalIntegerPMF K T γ hK hT hγ hlarge) + (4*T/γ) (8 * (probabilityProfileLipschitz : ℝ) * T^2 / γ^2) (principalIntegerInterpolation K T γ) := + ⟨principalIntegerInterpolation_grid K T γ hK hT hγ hlarge, + principalIntegerInterpolation_range K T γ hK hT hγ hlarge, + principalIntegerInterpolation_difference K T γ hK hT hγ hlarge⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalJoinedResidues.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalJoinedResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..871314b8f6ef8e8677cf354a4dcc0c2900be16a0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalJoinedResidues.lean @@ -0,0 +1,39 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedEnormousProfiles + +namespace OAI + +section + +namespace Erdos3 + +variable {D α : Type*} {B : D → Type*} {h : D → ℕ} + +def principalAxisResidueJoin (P : D → Prop) [DecidablePred P] + {L : PrincipalTupleIndex B h → ℕ} (u : PrincipalAxisTuples (α := α) P L) (m : ℕ) + (r : PrincipalTupleIndex (fun d : {d // ¬P d} => B d.val) (fun d => h d.val) → Option α → ZMod m) : + PrincipalTupleIndex B h → Option α → ZMod m := + fun j i => if hp : P j.1 then ((u ⟨⟨j.1, hp⟩, j.2⟩ i : ℤ) : ZMod m) + else r ⟨⟨j.1, hp⟩, j.2⟩ i + +theorem principalResidueLabel_join (P : D → Prop) [DecidablePred P] + {L : PrincipalTupleIndex B h → ℕ} (u : PrincipalAxisTuples (α := α) P L) + (v : PrincipalAxisTuples (α := α) (fun d => ¬P d) L) (m : ℕ) : + principalResidueLabel m (principalAxisJoin P u v) = + principalAxisResidueJoin P u m (principalResidueLabel m v) := by + funext j i + by_cases hp : P j.1 <;> + simp only [principalResidueLabel, principalAxisJoin, principalAxisResidueJoin, hp, ↓reduceDIte] + +theorem principalSpatialColumns_join_residue {N : Type*} (P : D → Prop) [DecidablePred P] + {L : PrincipalTupleIndex B h → ℕ} (u : PrincipalAxisTuples (α := α) P L) + (v : PrincipalAxisTuples (α := α) (fun d => ¬P d) L) (m : ℕ) + (c : N → ℤ) (index : N → PrincipalTupleIndex B h) : + integerResidueMatrix (principalSpatialColumns c index (principalAxisJoin P u v)) m = + principalSpatialResidueColumns m c index (principalAxisResidueJoin P u m (principalResidueLabel m v)) := by + rw [principalSpatialColumns_residue, principalResidueLabel_join] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalResidueMixture.lean b/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalResidueMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..a34ee80c1372a3d617f40d7c11e855292db98b2d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/PrincipalResidueMixture.lean @@ -0,0 +1,230 @@ +import OAI.Combinatorics.Progressions.Estimates.CoefficientRowReindex + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def integerMappedCubeTuple {Z X K α : Type*} + (input : K → Option α → Z ⊕ X) (z : Z → ℤ) (x : X → ℤ) : Finset α → K → ℤ := + integerAffineCube (fun k => Sum.elim z x (input k none)) + (fun i k => Sum.elim z x (input k (some i))) + +theorem integerMappedCubeTuple_residue {Z X K α : Type*} + (input : K → Option α → Z ⊕ X) (z : Z → ℤ) (x y : X → ℤ) (m : ℕ) + (hxy : integerResidueMap X m x = integerResidueMap X m y) (t : Finset α) : + integerResidueMap K m (integerMappedCubeTuple input z x t) = + integerResidueMap K m (integerMappedCubeTuple input z y t) := by + apply integerAffineCube_residue_eq + · funext k + change ((Sum.elim z x (input k none) : ℤ) : ZMod m) = + ((Sum.elim z y (input k none) : ℤ) : ZMod m) + cases input k none with + | inl j => rfl + | inr j => exact congrFun hxy j + · funext i k + change ((Sum.elim z x (input k (some i)) : ℤ) : ZMod m) = + ((Sum.elim z y (input k (some i)) : ℤ) : ZMod m) + cases input k (some i) with + | inl j => rfl + | inr j => exact congrFun hxy j + +noncomputable def integerMappedJetMatrix {Z X K α I N : Type*} [DecidableEq α] + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℤ) + (rows : I → Finset α) (x : X → ℤ) : Matrix I N ℤ := + integerJetMatrix (fun n => MvPolynomial.monomial (e n) 1) (integerMappedCubeTuple input z x) rows + +theorem integerMappedJetMatrix_residue {Z X K α I N : Type*} [DecidableEq α] + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℤ) + (rows : I → Finset α) (x y : X → ℤ) (m : ℕ) + (hxy : integerResidueMap X m x = integerResidueMap X m y) : + integerResidueMatrix (integerMappedJetMatrix e input z rows x) m = + integerResidueMatrix (integerMappedJetMatrix e input z rows y) m := + monomialCoefficientMatrix_residue_eq e _ _ rows m (integerMappedCubeTuple_residue input z x y m hxy) + +theorem integerMappedCubeTuple_normalized {Z X K α : Type*} [Fintype α] [DecidableEq α] + (input : K → Option α → Z ⊕ X) (z : Z → ℤ) (x : X → ℤ) + (zr : Z → ℝ) (xr : X → ℝ) (T : K → ℝ) + (hn : ∀ k a, ((Sum.elim z x (input k a) : ℤ) : ℝ)/T k = Sum.elim zr xr (input k a)) + (t : Finset α) (k : K) : + (integerMappedCubeTuple input z x t k : ℝ)/T k = normalizedCubeTuple input zr xr t k := by + exact (normalizedCubeTuple_eq_integerAffineCube input zr xr + (fun k => Sum.elim z x (input k none)) (fun i k => Sum.elim z x (input k (some i))) T + (fun k => (hn k none).symm) (fun i k => (hn k (some i)).symm) t k).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem integerMappedCubeTuple_residue_both {Z X K α : Type*} + (input : K → Option α → Z ⊕ X) (z w : Z → ℤ) (x y : X → ℤ) (q : ℕ) + (hzw : integerResidueMap Z q z = integerResidueMap Z q w) + (hxy : integerResidueMap X q x = integerResidueMap X q y) (t : Finset α) : + integerResidueMap K q (integerMappedCubeTuple input z x t) = + integerResidueMap K q (integerMappedCubeTuple input w y t) := by + apply integerAffineCube_residue_eq + · funext k + change ((Sum.elim z x (input k none) : ℤ) : ZMod q) = + ((Sum.elim w y (input k none) : ℤ) : ZMod q) + cases input k none with + | inl j => exact congrFun hzw j + | inr j => exact congrFun hxy j + · funext i k + change ((Sum.elim z x (input k (some i)) : ℤ) : ZMod q) = + ((Sum.elim w y (input k (some i)) : ℤ) : ZMod q) + cases input k (some i) with + | inl j => exact congrFun hzw j + | inr j => exact congrFun hxy j + +theorem integerMappedJetMatrix_residue_both {Z X K α I N : Type*} [DecidableEq α] + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) + (z w : Z → ℤ) (rows : I → Finset α) (x y : X → ℤ) (q : ℕ) + (hzw : integerResidueMap Z q z = integerResidueMap Z q w) + (hxy : integerResidueMap X q x = integerResidueMap X q y) : + integerResidueMatrix (integerMappedJetMatrix e input z rows x) q = + integerResidueMatrix (integerMappedJetMatrix e input w rows y) q := + monomialCoefficientMatrix_residue_eq e _ _ rows q + (integerMappedCubeTuple_residue_both input z w x y q hzw hxy) + +end Erdos3 + +end + +section + +namespace Erdos3 + +abbrev PrincipalIntegerTuples {D : Type*} (B : D → Type*) (h : D → ℕ) (α : Type*) + (L : PrincipalTupleIndex B h → ℕ) := ∀ j, IntegerScalarCubeBox α (L j) + +def principalTupleIntegers {D α : Type*} {B : D → Type*} {h : D → ℕ} + {L : PrincipalTupleIndex B h → ℕ} (y : PrincipalIntegerTuples B h α L) : + JointBlockParameter B h α → ℤ := + fun a => (y ⟨a.1, a.2.1, a.2.2.1⟩ a.2.2.2 : ℤ) + +noncomputable def principalTupleNormalized {D α : Type*} {B : D → Type*} {h : D → ℕ} + (L : PrincipalTupleIndex B h → ℕ) (y : PrincipalIntegerTuples B h α L) : + JointBlockParameter B h α → ℝ := + fun a => (principalTupleIntegers y a : ℝ)/L ⟨a.1, a.2.1, a.2.2.1⟩ + +def principalTupleResidues {D α : Type*} {B : D → Type*} {h : D → ℕ} {m : ℕ} + (r : PrincipalTupleIndex B h → Option α → ZMod m) : JointBlockParameter B h α → ZMod m := + fun a => r ⟨a.1, a.2.1, a.2.2.1⟩ a.2.2.2 + +noncomputable def principalResidueWeights {D α : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) + (m : ℕ) (hm : 0 < m) (r : PrincipalTupleIndex B h → Option α → ZMod m) + (hsize : ∀ j, (Fintype.card α+1)*m ≤ L j) : FiniteProbabilityWeights (PrincipalIntegerTuples B h α L) := + FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights α (L j) m (hL j) + (fun _ => m) (r j) (fun _ => hm) (fun _ => le_rfl) (hsize j)) + +theorem principalResidueWeights_support {D α : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) + (m : ℕ) (hm : 0 < m) (r : PrincipalTupleIndex B h → Option α → ZMod m) + (hsize : ∀ j, (Fintype.card α+1)*m ≤ L j) (y : PrincipalIntegerTuples B h α L) + (hy : (principalResidueWeights B h L hL m hm r hsize).weight y ≠ 0) : + integerResidueMap (JointBlockParameter B h α) m (principalTupleIntegers y) = principalTupleResidues r := by + have hr := scalarCubeResiduePi_support L (fun _ => m) hL (fun _ _ => m) r + (fun _ _ => hm) (fun _ _ => le_rfl) hsize y hy + funext a + exact hr ⟨a.1, a.2.1, a.2.2.1⟩ a.2.2.2 + +theorem principalResidueWeights_matrix {Z K D α I N : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) + (m : ℕ) (hm : 0 < m) (r : PrincipalTupleIndex B h → Option α → ZMod m) + (hsize : ∀ j, (Fintype.card α+1)*m ≤ L j) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ JointBlockParameter B h α) + (z : Z → ℤ) (rows : I → Finset α) (ref : JointBlockParameter B h α → ℤ) + (href : integerResidueMap _ m ref = principalTupleResidues r) + (y : PrincipalIntegerTuples B h α L) + (hy : (principalResidueWeights B h L hL m hm r hsize).weight y ≠ 0) : + integerResidueMatrix (integerMappedJetMatrix e input z rows (principalTupleIntegers y)) m = + integerResidueMatrix (integerMappedJetMatrix e input z rows ref) m := by + apply integerMappedJetMatrix_residue + exact (principalResidueWeights_support B h L hL m hm r hsize y hy).trans href.symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def principalTupleWeights {D α : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) : + FiniteProbabilityWeights (PrincipalIntegerTuples B h α L) := + FiniteProbabilityWeights.pi (fun j => integerScalarCubeWeights α (L j) (hL j)) + +def principalResidueLabel {D α : Type*} {B : D → Type*} {h : D → ℕ} + {L : PrincipalTupleIndex B h → ℕ} (m : ℕ) (y : PrincipalIntegerTuples B h α L) : + PrincipalTupleIndex B h → Option α → ZMod m := fun j i => ((y j i : ℤ) : ZMod m) + +theorem principalResidueCell_eq {D α : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (m : ℕ) + (r : PrincipalTupleIndex B h → Option α → ZMod m) : + Finset.univ.filter (fun y : PrincipalIntegerTuples B h α L => principalResidueLabel m y = r) = + FiniteProbabilityWeights.piRestrictionSet + (fun j => scalarCubeResidueSet α (L j) (fun _ => m) (r j)) := by + classical + ext y + simp only [Finset.mem_filter, Finset.mem_univ, true_and, + FiniteProbabilityWeights.mem_piRestrictionSet, mem_scalarCubeResidueSet] + exact ⟨fun he j i => congrFun (congrFun he j) i, fun he => funext (fun j => funext (he j))⟩ + +theorem principalResidueCell_mass_pos {D α : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) (m : ℕ) (hm : 0 < m) + (r : PrincipalTupleIndex B h → Option α → ZMod m) + (hsize : ∀ j, (Fintype.card α+1)*m ≤ L j) : + 0 < (principalTupleWeights (α := α) B h L hL).mass + (Finset.univ.filter (fun y => principalResidueLabel m y = r)) := by + rw [principalResidueCell_eq] + exact FiniteProbabilityWeights.piRestriction_mass_pos _ _ + (fun j => scalarCubeResidue_mass_pos α (L j) m (hL j) (fun _ => m) (r j) + (fun _ => hm) (fun _ => le_rfl) (hsize j)) + +theorem principalResidueWeights_eq_condition {D α : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) (m : ℕ) (hm : 0 < m) + (r : PrincipalTupleIndex B h → Option α → ZMod m) + (hsize : ∀ j, (Fintype.card α+1)*m ≤ L j) : + principalResidueWeights B h L hL m hm r hsize = + (principalTupleWeights (α := α) B h L hL).condition + (Finset.univ.filter (fun y => principalResidueLabel m y = r)) + (principalResidueCell_mass_pos B h L hL m hm r hsize) := by + classical + simp only [principalResidueCell_eq] + exact scalarCubeResiduePi_condition L (fun _ => m) hL (fun _ _ => m) r + (fun _ _ => hm) (fun _ _ => le_rfl) hsize + +theorem principalResidue_fiberMean {D α : Type*} [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) (m : ℕ) (hm : 0 < m) + (r : PrincipalTupleIndex B h → Option α → ZMod m) + (hsize : ∀ j, (Fintype.card α+1)*m ≤ L j) (f : PrincipalIntegerTuples B h α L → ℝ) : + (principalTupleWeights (α := α) B h L hL).fiberMean (principalResidueLabel m) r f = + (principalTupleWeights (α := α) B h L hL).mass + (Finset.univ.filter (fun y => principalResidueLabel m y = r)) * + (principalResidueWeights B h L hL m hm r hsize).mean f := by + classical + rw [principalResidueWeights_eq_condition] + exact FiniteProbabilityWeights.fiberMean_eq_mass_mul_condition _ _ _ _ _ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ProductResidueCutoff.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ProductResidueCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae8d1c9989c983a6f6a8afff40c1a3777d1f843b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ProductResidueCutoff.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Lattices.ScalarResidueInteriorCell + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem scalarCubeResidueProductCutoff_loss {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (L M : J → ℕ) (hL : ∀ j, 0 < L j) (m : J → Option I → ℕ) + (res : ∀ j i, ZMod (m j i)) (hm : ∀ j i, 0 < m j i) + (hmM : ∀ j i, m j i ≤ M j) (hsize : ∀ j, (Fintype.card I + 1) * M j ≤ L j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant I * ((M j : ℝ) / L j) < + volume.real (scalarCubeDomain I)) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + (r : J → ℝ≥0) (hr : ∀ j, 0 < r j) : + (FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights I (L j) (M j) + (hL j) (m j) (res j) (hm j) (hmM j) (hsize j))).mean + (fun z => 1 - scalarCubeProductCutoff I (fun j => (r j : ℝ)) + (fun j i => (z j i : ℝ) / L j)) ≤ + ∑ j, scalarCubeResidueCutoffBudget I A (r j) (L j) (M j) := by + let q : ∀ j, FiniteProbabilityWeights (IntegerScalarCubeBox I (L j)) := + fun j => scalarCubeResidueWeights I (L j) (M j) + (hL j) (m j) (res j) (hm j) (hmM j) (hsize j) + let b : ∀ j, IntegerScalarCubeBox I (L j) → ℝ := fun j z => + inequalityBoundaryCutoff (fun _ : Bool × Finset I => (r j : ℝ)) + scalarCubeFace (fun i => (z i : ℝ) / L j) + have hloss := FiniteProbabilityWeights.pi_cutoff_loss q b + (fun _ _ => inequalityBoundaryCutoff_range _ _ _) + change (FiniteProbabilityWeights.pi q).mean (fun z => 1 - ∏ j, b j (z j)) ≤ _ + apply hloss.trans + exact Finset.sum_le_sum (fun j _ => scalarCubeResidueCutoff_loss I (L j) (M j) + (hL j) (m j) (res j) (hm j) (hmM j) (hsize j) (hsmall j) A hA (hr j)) + +theorem scalarCubeResidueProductCutoff_bias {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (L M : J → ℕ) (hL : ∀ j, 0 < L j) (m : J → Option I → ℕ) + (res : ∀ j i, ZMod (m j i)) (hm : ∀ j i, 0 < m j i) + (hmM : ∀ j i, m j i ≤ M j) (hsize : ∀ j, (Fintype.card I + 1) * M j ≤ L j) + (hsmall : ∀ j, scalarCubeGridBoundaryConstant I * ((M j : ℝ) / L j) < + volume.real (scalarCubeDomain I)) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + (r : J → ℝ≥0) (hr : ∀ j, 0 < r j) + (F : (∀ j, IntegerScalarCubeBox I (L j)) → ℂ) (hF : ∀ z, ‖F z‖ ≤ 1) + {ζ : ℝ} (hbias : ζ ≤ ‖(FiniteProbabilityWeights.pi (fun j => + scalarCubeResidueWeights I (L j) (M j) (hL j) (m j) (res j) + (hm j) (hmM j) (hsize j))).complexMean F‖) : + ζ - (∑ j, scalarCubeResidueCutoffBudget I A (r j) (L j) (M j)) ≤ + ‖(FiniteProbabilityWeights.pi (fun j => scalarCubeResidueWeights I (L j) (M j) + (hL j) (m j) (res j) (hm j) (hmM j) (hsize j))).complexMean + (fun z => (scalarCubeProductCutoff I (fun j => (r j : ℝ)) + (fun j i => (z j i : ℝ) / L j) : ℂ) * F z)‖ := + FiniteProbabilityWeights.cutoff_bias_lower _ _ F + (fun _ => scalarCubeProductCutoff_range _ _) hF hbias + (scalarCubeResidueProductCutoff_loss L M hL m res hm hmM hsize hsmall A hA r hr) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ProductiveAbsoluteCRTPatches.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ProductiveAbsoluteCRTPatches.lean new file mode 100644 index 0000000000000000000000000000000000000000..f01367ec2f01d02b1b64ba309642ef4209df18fe --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ProductiveAbsoluteCRTPatches.lean @@ -0,0 +1,242 @@ +import Mathlib.LinearAlgebra.Matrix.ToLin +import OAI.Combinatorics.Progressions.Polynomial.AbsoluteCRTPolynomialPatch + +namespace OAI + +section + +namespace Erdos3 + +namespace IntegerVectorAPFree + +variable {I J : Type*} {k : ℕ} + +theorem mono {A B : Set (I → ℤ)} (hA : IntegerVectorAPFree A k) (hBA : B ⊆ A) : + IntegerVectorAPFree B k := by + intro a d hd + obtain ⟨i, hi⟩ := hA a d hd + exact ⟨i, fun h => hi (hBA h)⟩ + +theorem affine_preimage {A : Set (J → ℤ)} (hA : IntegerVectorAPFree A k) + (hk : 2 ≤ k) (L : (I → ℤ) →+ (J → ℤ)) (b : J → ℤ) + (domain : Set (I → ℤ)) + (hinj : Set.InjOn (fun x => b + L x) domain) : + IntegerVectorAPFree (domain ∩ (fun x => b + L x) ⁻¹' A) k := by + intro a d hd + by_contra! h + have ha : a ∈ domain := by simpa using (h ⟨0, by omega⟩).1 + have had : a + d ∈ domain := by simpa using (h ⟨1, by omega⟩).1 + have hLd : L d ≠ 0 := by + intro hzero + have he : b + L (a + d) = b + L a := by simp [hzero] + have he' : a + d = a := hinj had ha he + apply hd + exact add_left_cancel (show a + d = a + 0 by simpa using he') + obtain ⟨i, hi⟩ := hA (b + L a) (L d) hLd + apply hi + have hp := (h i).2 + simpa only [Set.mem_preimage, map_add, map_zsmul, add_assoc] using hp + +end IntegerVectorAPFree + +namespace BooleanCubeKernel + +theorem joint_sample_progression_free {K X : Type*} [Fintype K] + {A : Set (X → ℤ)} {k : ℕ} (hA : IntegerVectorAPFree A k) (hk : 2 ≤ k) + (z : (X → ℤ) × (Option K × X → ℤ)) (domain : Set (K → ℤ)) + (hinj : Set.InjOn (fun x => jointIntegerPhysicalSite x z) domain) : + IntegerVectorAPFree (domain ∩ (fun x => jointIntegerPhysicalSite x z) ⁻¹' A) k := by + classical + let L : (K → ℤ) →+ (X → ℤ) := + (Matrix.of (fun i j => z.2 (some j,i))).mulVecLin.toAddMonoidHom + let b : X → ℤ := fun i => z.1 i + z.2 (none,i) + have he (x : K → ℤ) : jointIntegerPhysicalSite x z = b + L x := by + funext i + change z.1 i + (z.2 (none,i) + ∑ j, x j * z.2 (some j,i)) = + (z.1 i + z.2 (none,i)) + ∑ j, z.2 (some j,i) * x j + rw [← add_assoc] + congr 1 + apply Finset.sum_congr rfl + intro j _ + ring + have h := hA.affine_preimage hk L b domain (by simpa only [he] using hinj) + simpa only [he] using h + +end BooleanCubeKernel +end Erdos3 + +end + +section + +namespace Erdos3 + +namespace IntegerVectorAPFree + +theorem affine_residue_support {K X : Type*} {k : ℕ} + (f : (X → ℤ) → ℝ) (hfree : IntegerVectorAPFree (Function.support f) k) + (hk : 2 ≤ k) (N : K → ℕ) (L : (K → ℤ) →+ (X → ℤ)) (b : X → ℤ) + (hinj : Function.Injective (fun u => b + L (residueBoxIntegerPoint N u))) : + IntegerVectorAPFree + (residueBoxIntegerPoint N '' + Function.support (fun u => f (b + L (residueBoxIntegerPoint N u)))) k := by + have hi : Set.InjOn (fun x => b + L x) (Set.range (residueBoxIntegerPoint N)) := by + intro x hx y hy hxy + obtain ⟨u, rfl⟩ := hx + obtain ⟨v, rfl⟩ := hy + exact congrArg (residueBoxIntegerPoint N) (hinj hxy) + apply (hfree.affine_preimage hk L b (Set.range (residueBoxIntegerPoint N)) hi).mono + rintro x ⟨u, hu, rfl⟩ + exact ⟨⟨u, rfl⟩, hu⟩ + +end IntegerVectorAPFree + +namespace BooleanCubeKernel + +theorem joint_residue_sample_progression_free {K X : Type*} [Fintype K] {k : ℕ} + (f : (X → ℤ) → ℝ) (hfree : IntegerVectorAPFree (Function.support f) k) + (hk : 2 ≤ k) (N : K → ℕ) + (z : (X → ℤ) × (Option K × X → ℤ)) + (hinj : Function.Injective + (fun u => jointIntegerPhysicalSite (residueBoxIntegerPoint N u) z)) : + IntegerVectorAPFree + (residueBoxIntegerPoint N '' Function.support + (fun u => f (jointIntegerPhysicalSite (residueBoxIntegerPoint N u) z))) k := by + have hi : Set.InjOn (fun x => jointIntegerPhysicalSite x z) + (Set.range (residueBoxIntegerPoint N)) := by + intro x hx y hy hxy + obtain ⟨u, rfl⟩ := hx + obtain ⟨v, rfl⟩ := hy + exact congrArg (residueBoxIntegerPoint N) (hinj hxy) + apply (joint_sample_progression_free hfree hk z + (Set.range (residueBoxIntegerPoint N)) hi).mono + rintro x ⟨u, hu, rfl⟩ + exact ⟨⟨u, rfl⟩, hu⟩ + +end BooleanCubeKernel +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem PolynomialPatch.positive_score_target_lt_one {σ Ω : Type*} [Fintype Ω] + {s d : ℕ} (P : PolynomialPatch σ s d) (t : Ω → σ → ℝ) (f : Ω → ℝ) + (hf : ∀ x, f x ≤ 1) {b : ℝ} + (hscore : 0 < 𝔼 x, (f x - b) * P.value (t x)) : b < 1 := by + by_contra h + have hb : 1 ≤ b := le_of_not_gt h + have hnonpos : (𝔼 x, (f x - b) * P.value (t x)) ≤ 0 := by + calc + _ ≤ 𝔼 _x : Ω, (0 : ℝ) := Finset.expect_le_expect + (fun x _ => mul_nonpos_of_nonpos_of_nonneg + (by linarith [hf x]) (P.value_mem_Icc _).1) + _ = 0 := by simp + exact (not_lt_of_ge hnonpos) hscore + +theorem exists_absolute_crt_threshold_rule {J : Type*} [Fintype J] [DecidableEq J] + [Nonempty J] (k : ℕ) (hk : 3 ≤ k) : + ∃ C : ℕ, 2 ≤ C ∧ ∃ xi : ℝ, 0 < xi ∧ + ∀ {p a : ℝ}, 2 ≤ p → Real.exp (-p) ≤ a → + ∀ (N : J → ℕ) [∀ j, NeZero (N j)] [NeZero (∏ j, N j)], + (∀ j, (N j).Prime) → Function.Injective N → + (∀ j, Real.exp ((p + 2) ^ C) ≤ N j) → + ∀ f : ((j : J) → ZMod (N j)) → ℝ, + (∀ x, f x ∈ Set.Icc (0 : ℝ) 1) → a ≤ (𝔼 x, f x) → + IntegerVectorAPFree (residueBoxIntegerPoint N '' Function.support f) k → + (1 + xi) * a < 1 ∧ ∃ d : ℕ, ∃ P : PolynomialPatch J (k - 2) d, + (d : ℝ) ≤ (p + 2) ^ C ∧ + (P.kernel.lip : ℝ) + 1 ≤ Real.exp ((p + 2) ^ C) ∧ + Real.exp (-((p + 2) ^ C)) ≤ + (𝔼 x, (f x - (1 + xi) * a) * P.value (fun j => ((x j).val : ℝ))) := by + obtain ⟨C, hC, xi, hxi, hpatch⟩ := exists_absolute_crt_patch (J := J) k hk + refine ⟨C, hC, xi, hxi, ?_⟩ + intro p a hp ha N _ _ hprime hinj hsize f hf hmean hfree + let alpha := 𝔼 x, f x + have halpha : 0 < alpha := (Real.exp_pos (-p)).trans_le (ha.trans hmean) + have hlog : Real.log (1 / alpha) ≤ p := by + rw [one_div, Real.log_inv] + have h := Real.log_le_log (Real.exp_pos (-p)) (ha.trans hmean) + rw [Real.log_exp] at h + linarith + obtain ⟨d, P, hcost, hscore⟩ := hpatch N hprime hinj f halpha hp hlog hsize hf rfl hfree + have hlognonneg : 0 ≤ Real.log (2 + (P.kernel.lip : ℝ)) := + Real.log_nonneg (by linarith [P.kernel.lip.coe_nonneg]) + have hlip : Real.log (2 + (P.kernel.lip : ℝ)) ≤ (p + 2) ^ C := by + linarith [Nat.cast_nonneg (α := ℝ) d] + have hscore' : Real.exp (-((p + 2) ^ C)) ≤ + (𝔼 x, (f x - (1 + xi) * a) * P.value (fun j => ((x j).val : ℝ))) := by + apply hscore.trans + apply Finset.expect_le_expect + intro x _ + apply mul_le_mul_of_nonneg_right _ (P.value_mem_Icc _).1 + have h := mul_le_mul_of_nonneg_left hmean (show 0 ≤ 1 + xi by linarith) + dsimp only [alpha] at * + linarith + refine ⟨P.positive_score_target_lt_one _ f (fun x => (hf x).2) + ((Real.exp_pos _).trans_le hscore'), d, P, by linarith, ?_, hscore'⟩ + · have h := Real.exp_le_exp.mpr hlip + rw [Real.exp_log (by positivity : 0 < 2 + (P.kernel.lip : ℝ))] at h + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem exists_productive_absolute_crt_patches + {J : Type*} [Fintype J] [DecidableEq J] [Nonempty J] (k : ℕ) (hk : 3 ≤ k) : + ∃ C : ℕ, 2 ≤ C ∧ ∃ xi : ℝ, 0 < xi ∧ + ∀ {H X : Type*} [Fintype H] (productive : Finset H), productive.Nonempty → + ∀ {p a : ℝ}, 2 ≤ p → Real.exp (-p) ≤ a → + ∀ (N : J → ℕ) [∀ j, NeZero (N j)] [NeZero (∏ j, N j)], + (∀ j, (N j).Prime) → Function.Injective N → + (∀ j, Real.exp ((p + 2) ^ C) ≤ N j) → + ∀ (f : (X → ℤ) → ℝ) (z : H → (X → ℤ) × (Option J × X → ℤ)), + (∀ x, f x ∈ Set.Icc (0 : ℝ) 1) → + IntegerVectorAPFree (Function.support f) k → + (∀ h ∈ productive, Function.Injective + (fun u => BooleanCubeKernel.jointIntegerPhysicalSite (residueBoxIntegerPoint N u) (z h))) → + (∀ h ∈ productive, a ≤ 𝔼 u, + f (BooleanCubeKernel.jointIntegerPhysicalSite (residueBoxIntegerPoint N u) (z h))) → + (1 + xi) * a < 1 ∧ + ∃ (d : H → ℕ) (patch : ∀ h : H, PolynomialPatch J (k - 2) (d h)), + (∀ h : H, + (d h : ℝ) ≤ (p + 2) ^ C ∧ + ((patch h).kernel.lip : ℝ) + 1 ≤ Real.exp ((p + 2) ^ C)) ∧ + ∀ h ∈ productive, Real.exp (-((p + 2) ^ C)) ≤ + 𝔼 u, (f (BooleanCubeKernel.jointIntegerPhysicalSite (residueBoxIntegerPoint N u) (z h)) - + (1 + xi) * a) * (patch h).value (fun j => ((u j).val : ℝ)) := by + obtain ⟨C, hC, xi, hxi, habsolute⟩ := exists_absolute_crt_threshold_rule (J := J) k hk + refine ⟨C, hC, xi, hxi, ?_⟩ + intro H X _ productive hne p a hp ha N _ _ hprime hinj hsize f z hf hfree hzinj hmean + have hpatch (h : productive) := habsolute hp ha N hprime hinj hsize + (fun u => f (BooleanCubeKernel.jointIntegerPhysicalSite (residueBoxIntegerPoint N u) (z h))) + (fun _ => hf _) (hmean h h.property) + (BooleanCubeKernel.joint_residue_sample_progression_free f hfree (by omega) N (z h) + (hzinj h h.property)) + obtain ⟨h0, hh0⟩ := hne + refine ⟨(hpatch ⟨h0,hh0⟩).1, ?_⟩ + choose d patch hcost using fun h => (hpatch h).2 + let chosen (h : H) : productive := if hh : h ∈ productive then ⟨h,hh⟩ else ⟨h0,hh0⟩ + refine ⟨fun h => d (chosen h), fun h => patch (chosen h), + fun h => ⟨(hcost (chosen h)).1, (hcost (chosen h)).2.1⟩, ?_⟩ + intro h hh + have hchosen : chosen h = ⟨h,hh⟩ := by simp [chosen, hh] + dsimp only + rw [hchosen] + exact (hcost ⟨h,hh⟩).2.2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ProjectedLatticeSheetCover.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ProjectedLatticeSheetCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..c54322d6bbb49383fe5c350ee9f9abceae633175 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ProjectedLatticeSheetCover.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Lattices.NormalizedLatticeSheet + +namespace OAI + +section + +namespace Erdos3 + +open Set + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +def latticeSmallLiftRegion (Λ : Submodule ℤ E) (W : Submodule ℝ E) (Ω : Set E) : + Set (W ⧸ (latticeSection Λ W).toAddSubgroup) := + {q | ∃ y ∈ Ω, ∃ u : W, QuotientAddGroup.mk u = q ∧ y - u.val ∈ Λ} + +theorem latticeSmallLiftRegion_eq_sheets (Λ : Submodule ℤ E) (W : Submodule ℝ E) (Ω : Set E) : + latticeSmallLiftRegion Λ W Ω = ⋃ z : orthogonalLatticeImage Λ Wᗮ, + latticeSheetQuotient Λ W z '' {u | latticeSheetPoint W z.val u ∈ Ω} := by + ext q + constructor + · rintro ⟨y, hy, u, hu, hyu⟩ + let z : orthogonalLatticeImage Λ Wᗮ := ⟨Wᗮ.orthogonalProjectionOnto y, + y - u.val, hyu, by + change Wᗮ.orthogonalProjectionOnto (y - u.val) = Wᗮ.orthogonalProjectionOnto y + rw [map_sub, W.orthogonalProjectionOnto_orthogonal_apply_eq_zero u.property, sub_zero]⟩ + let v := W.orthogonalProjectionOnto y + have hp : latticeSheetPoint W z.val v = y := + W.starProjection_add_starProjection_orthogonal y + refine mem_iUnion.mpr ⟨z, v, ?_, ?_⟩ + · change latticeSheetPoint W z.val v ∈ Ω + rwa [hp] + · apply Eq.trans _ hu + apply QuotientAddGroup.eq_iff_sub_mem.mpr + change ((v - projectedLatticeShift Λ W z) - u).val ∈ Λ + have hr := latticeSheetPoint_reconstruction Λ W z v + rw [hp] at hr + have hs : ((v - projectedLatticeShift Λ W z) - u).val = + (y - u.val) - (projectedLatticeLift Λ W z).val := by + rw [hr] + simp only [Submodule.coe_sub] + abel + rw [hs] + exact Λ.sub_mem hyu (projectedLatticeLift Λ W z).property + · intro hq + obtain ⟨z, v, hv, he⟩ := mem_iUnion.mp hq + refine ⟨latticeSheetPoint W z.val v, hv, v - projectedLatticeShift Λ W z, he, ?_⟩ + rw [latticeSheetPoint_reconstruction] + simpa only [add_sub_cancel_left] using (projectedLatticeLift Λ W z).property + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ProperAffineBoxRestriction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ProperAffineBoxRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..62157bf026bf14d1e34517f8fd270da956b22bba --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ProperAffineBoxRestriction.lean @@ -0,0 +1,133 @@ +import OAI.Combinatorics.Progressions.Geometry.DenseRealBoxCell +import OAI.Combinatorics.Progressions.Lattices.NaturalScaleIntegerWindow + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def centeredScalarBlock (R k : ℕ) (x : ℤ) : ℕ := + (x + (R : ℤ)).toNat / (2 * (R / (2 * k)) + 1) + +def centeredScalarCenter (R k c : ℕ) : ℤ := + (c : ℤ) * (2 * (R / (2 * k) : ℕ) + 1) - R + (R / (2 * k) : ℕ) + +theorem centeredScalarBlock_lt (R k : ℕ) (hk : 0 < k) (x : ℤ) + (hx : |x| ≤ (R : ℤ)) : centeredScalarBlock R k x < 4 * k := by + have htwo : 0 < 2 * k := by omega + have hR := Nat.lt_mul_div_succ R htwo + have ht : (x + (R : ℤ)).toNat ≤ 2 * R := by + have h := abs_le.mp hx + omega + have hku : 0 ≤ k * (R / (2 * k)) := Nat.zero_le _ + have hcover : 2 * R < 4 * k * (2 * (R / (2 * k)) + 1) := by + nlinarith only [hR, hku] + apply (Nat.div_lt_iff_lt_mul (by omega : 0 < 2 * (R / (2 * k)) + 1)).mpr + exact ht.trans_lt hcover + +theorem centeredScalarCenter_offset (R k : ℕ) (x : ℤ) + (hx : |x| ≤ (R : ℤ)) : + |x - centeredScalarCenter R k (centeredScalarBlock R k x)| ≤ (R / (2 * k) : ℕ) := by + let t := (x + (R : ℤ)).toNat + let L := 2 * (R / (2 * k)) + 1 + have ht : (t : ℤ) = x + R := by + apply Int.toNat_of_nonneg + have h := abs_le.mp hx + omega + have hmod : t % L < L := Nat.mod_lt t (by dsimp [L]; omega) + have hrem : ((t % L : ℕ) : ℤ) + (L : ℤ) * (t / L : ℕ) = x + R := by + rw [← ht] + exact_mod_cast Nat.mod_add_div t L + have hcancel : x - centeredScalarCenter R k (centeredScalarBlock R k x) = + (t % L : ℕ) - (R / (2 * k) : ℕ) := by + unfold centeredScalarCenter centeredScalarBlock + change x - ((t / L : ℕ) * (2 * ((R / (2 * k) : ℕ) : ℤ) + 1) - R + + ((R / (2 * k) : ℕ) : ℤ)) = ((t % L : ℕ) : ℤ) - ((R / (2 * k) : ℕ) : ℤ) + have hL : (L : ℤ) = 2 * ((R / (2 * k) : ℕ) : ℤ) + 1 := by + simp only [L, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_one] + rw [hL] at hrem + nlinarith only [hrem] + have hmod' : ((t % L : ℕ) : ℤ) ≤ 2 * ((R / (2 * k) : ℕ) : ℤ) := by + have h : t % L ≤ 2 * (R / (2 * k)) := Nat.le_of_lt_succ hmod + exact_mod_cast h + rw [hcancel, abs_le] + constructor <;> linarith only [hmod', Int.natCast_nonneg (t % L)] + +theorem exists_dense_centered_box_block {ι α : Type*} [Fintype ι] + (S : Finset α) (hS : S.Nonempty) (x : α → ι → ℤ) (R : ι → ℕ) + (k : ℕ) (hk : 0 < k) (hbound : ∀ a ∈ S, ∀ i, |x a i| ≤ (R i : ℤ)) : + ∃ T ⊆ S, T.Nonempty ∧ S.card ≤ (4 * k) ^ Fintype.card ι * T.card ∧ + ∃ c : ι → ℤ, ∀ a ∈ T, ∀ i, |x a i - c i| ≤ (R i / (2 * k) : ℕ) := by + classical + have hfour : 0 < 4 * k := by omega + let : NeZero (4 * k) := ⟨hfour.ne'⟩ + let label (a : α) (i : ι) : Fin (4 * k) := + ⟨centeredScalarBlock (R i) k (x a i) % (4 * k), Nat.mod_lt _ hfour⟩ + obtain ⟨b, hT, hsize⟩ := FreimanModel.exists_nonempty_large_fiber S hS label + let T := S.filter fun a => label a = b + refine ⟨T, Finset.filter_subset _ _, hT, ?_, + (fun i => centeredScalarCenter (R i) k (b i).val), ?_⟩ + · simpa only [Fintype.card_fun, Fintype.card_fin] using hsize + · intro a ha i + have hmem := (Finset.mem_filter.mp ha).1 + have heq := congrArg Fin.val (congrFun (Finset.mem_filter.mp ha).2 i) + have hlt := centeredScalarBlock_lt (R i) k hk (x a i) (hbound a hmem i) + change centeredScalarBlock (R i) k (x a i) % (4 * k) = (b i).val at heq + rw [Nat.mod_eq_of_lt hlt] at heq + change |x a i - centeredScalarCenter (R i) k (b i).val| ≤ (R i / (2 * k) : ℕ) + rw [← heq] + exact centeredScalarCenter_offset (R i) k (x a i) (hbound a hmem i) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_dense_proper_coordinate_restriction + {r : ℕ} {G : Type*} [AddCommGroup G] (J : Finset G) (hJ : J.Nonempty) + (R : Fin r → ℕ) (η : (Fin r → ℤ) →+ G) (a : G) + (x : {h // h ∈ J} → Fin r → ℤ) + (hx : ∀ h i, |x h i| ≤ (R i : ℤ)) + (hrepr : ∀ h, h.val = a + η (x h)) : + let k := (2 ^ r * ∏ i, (2 * R i + 1)) / J.card + 1 + ∃ (T : Finset G) (hTJ : T ⊆ J), T.Nonempty ∧ + J.card ≤ (4 * k) ^ r * T.card ∧ + ∃ c : Fin r → ℤ, + Set.InjOn η (centeredIntegerBox (fun i => R i / (2 * k)) : Set _) ∧ + ∀ h : {h // h ∈ T}, ∀ i, + |x ⟨h.val, hTJ h.property⟩ i - c i| ≤ (R i / (2 * k) : ℕ) := by + intro k + classical + let : Nonempty {h // h ∈ J} := ⟨⟨hJ.choose, hJ.choose_spec⟩⟩ + have hk : 0 < k := Nat.succ_pos _ + have hproper := injOn_shrunk_integer_box_of_distinct_points J hJ R η a + (fun h hh => ⟨x ⟨h, hh⟩, hx ⟨h, hh⟩, hrepr ⟨h, hh⟩⟩) + obtain ⟨U, _hUuniv, hU, hsize, c, hsmall⟩ := + exists_dense_centered_box_block (Finset.univ : Finset {h // h ∈ J}) + Finset.univ_nonempty x R k hk (fun h _ => hx h) + let T := U.image Subtype.val + have hTJ : T ⊆ J := by + intro h hh + obtain ⟨h', _, rfl⟩ := Finset.mem_image.mp hh + exact h'.property + have hcard : T.card = U.card := Finset.card_image_of_injective _ Subtype.val_injective + refine ⟨T, hTJ, hU.image _, ?_, c, hproper, ?_⟩ + · simpa only [Finset.card_univ, Fintype.card_coe, Fintype.card_fin, hcard] using hsize + · intro h i + obtain ⟨h', hh', heq⟩ := Finset.mem_image.mp h.property + have hident : h' = ⟨h.val, hTJ h.property⟩ := Subtype.ext heq + simpa only [hident] using hsmall h' hh' i + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/QuadraticMarkedAffine.lean b/lean/OAI/Combinatorics/Progressions/Lattices/QuadraticMarkedAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..22a52c91d0a9359409c5a64d5b4977d4dac6985e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/QuadraticMarkedAffine.lean @@ -0,0 +1,136 @@ +import OAI.Combinatorics.Progressions.Estimates.CoveredInducedCorrelationFamily + +namespace OAI + +section + +namespace Erdos3.QuadraticMarked + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct BigOperators + +noncomputable def seedVector (a : ℝ) : ℝ ⊗[ℚ] Seed := a ⊗ₜ[ℚ] generators 0 + +theorem seedVector_mem (a : ℝ) : + seedVector a ∈ (markedLieSpan generators weights marked 1 1 1).baseChange ℝ := by + apply Submodule.tmul_mem_baseChange_of_mem + simpa only [weights, marked, Bool.true_eq, ite_true] using + markedLieSpan_leaf generators weights marked (0 : Fin 1) + +noncomputable def affineCoefficient (t : ℕ) (a : ℝ) (b : Fin t → ℝ) : + (markedPolynomialLayer (σ := Fin t) generators weights marked 1 0 1).baseChange ℝ := + ⟨realAffinePolynomial (seedVector a) (fun i => seedVector (b i)), + realAffinePolynomial_mem_marked generators weights marked + (Submodule.baseChange_mono ℝ + (markedLieSpan_antitone generators weights marked le_rfl (by omega) le_rfl) + (seedVector_mem a)) (fun i => seedVector_mem (b i))⟩ + +noncomputable def sourceLift (t : ℕ) (a : ℝ) (b : Fin t → ℝ) : + ℝ ⊗[ℚ] markedShiftSubalgebra filtration generators weights marked t := + realMarkedPolynomialLift filtration generators weights marked weight_pos generator_mem t 1 0 1 + (affineCoefficient t a b) + +noncomputable def projectedLift (t : ℕ) (a : ℝ) (b : Fin t → ℝ) : ℝ ⊗[ℚ] Algebra t := + (lieQuotientMap (markedShiftSecondIdeal filtration generators weights marked t)).toLinearMap.baseChange ℝ + (sourceLift t a b) + +theorem sourceLift_eval (t : ℕ) (a : ℝ) (b : Fin t → ℝ) (u : Fin t → ℚ) : + (markedShiftEval filtration generators weights marked t u).baseChange ℝ (sourceLift t a b) = + seedVector a + ∑ i, (u i : ℝ) • seedVector (b i) := by + apply (realMarkedPolynomialLift_eval filtration generators weights marked weight_pos generator_mem + t 1 0 1 (affineCoefficient t a b) u).trans + simpa only [affineCoefficient, ← Rat.cast_smul_eq_qsmul ℝ] using + realAffinePolynomial_eval (seedVector a) (fun i => seedVector (b i)) u + +theorem projectedLift_mem (t : ℕ) (a : ℝ) (b : Fin t → ℝ) : + projectedLift t a b ∈ (multidegree t).realification.layer (correlationInput 0 1) := + realMarkedPolynomialLift_quotient_mem filtration generators weights marked weight_pos generator_mem + t 1 0 1 (affineCoefficient t a b) + +theorem projectedLift_pure (t : ℕ) (a : ℝ) (b : Fin t → ℝ) : + projectedLift t a b ∈ + (markedQuotientPolynomialAlgebra filtration generators weights marked t).toSubmodule.baseChange ℝ := by + change projectedLift t a b ∈ + (LinearMap.ker (markedQuotientPhase filtration generators weights marked t).toLinearMap).baseChange ℝ + rw [realification_ker, LinearMap.mem_ker] + change (markedQuotientPhase filtration generators weights marked t).toLinearMap.baseChange ℝ + ((lieQuotientMap (markedShiftSecondIdeal filtration generators weights marked t)).toLinearMap.baseChange ℝ + (sourceLift t a b)) = 0 + rw [markedQuotientPhase_real_map] + exact realMarkedPolynomialLift_phase filtration generators weights marked weight_pos generator_mem + t 1 0 1 (by decide) (affineCoefficient t a b) + +theorem projectedLift_phase (t m : ℕ) (a : ℝ) (b : Fin t → ℝ) : + torusPhaseLinear (phase t m) (projectedLift t a b) = 0 := + normalizedMarkedPhase_real_pure filtration generators weights marked t m _ + (projectedLift_pure t a b) + +noncomputable def seedCoordinate (η : RationalTorus.BottomQuotient 1 →ₗ[ℚ] ℚ) : + (ℝ ⊗[ℚ] Seed) →ₗ[ℝ] ℝ := + (realifyFunctional η).comp ((lieQuotientMap (⊥ : LieIdeal ℚ Seed)).toLinearMap.baseChange ℝ) + +theorem seedCoordinate_seedVector (η : RationalTorus.BottomQuotient 1 →ₗ[ℚ] ℚ) + (hη : ∀ x : Seed, η (lieQuotientMap (⊥ : LieIdeal ℚ Seed) x) = x 0) (a : ℝ) : + seedCoordinate η (seedVector a) = a := by + have he : generators (0 : Fin 1) (0 : Fin 1) = 1 := by + change (Pi.basisFun ℚ (Fin 1)) 0 0 = 1 + simp + simp only [seedCoordinate, seedVector, LinearMap.comp_apply, LinearMap.baseChange_tmul, + realifyFunctional_tmul] + change a * ((η (lieQuotientMap (⊥ : LieIdeal ℚ Seed) (generators 0))) : ℝ) = a + rw [hη, he, Rat.cast_one, mul_one] + +theorem sourceLift_shift_coordinate (η : RationalTorus.BottomQuotient 1 →ₗ[ℚ] ℚ) + (hη : ∀ x : Seed, η (lieQuotientMap (⊥ : LieIdeal ℚ Seed) x) = x 0) + (t : ℕ) (a : ℝ) (b u : Fin t → ℝ) : + seedCoordinate η ((markedShiftEval filtration generators weights marked t 0).baseChange ℝ + (realMarkedAffineShift filtration generators weights marked weight_pos generator_mem t u + (sourceLift t a b))) = a + ∑ i, u i * b i := by + rw [realMarkedAffineShift_eval_affine filtration generators weights marked weight_pos generator_mem + t u (sourceLift t a b) (seedVector a) (fun i => seedVector (b i)) (sourceLift_eval t a b)] + simp only [map_add, map_sum, map_smul, seedCoordinate_seedVector η hη, smul_eq_mul] + +theorem shiftedLift_coordinate (η : RationalTorus.BottomQuotient 1 →ₗ[ℚ] ℚ) + (hη : ∀ x : Seed, η (lieQuotientMap (⊥ : LieIdeal ℚ Seed) x) = x 0) + (t : ℕ) (a : ℝ) (b u : Fin t → ℝ) : + realifyFunctional η ((evaluation t).baseChange ℝ + ((lieQuotientMap (markedShiftSecondIdeal filtration generators weights marked t)).toLinearMap.baseChange ℝ + (realMarkedAffineShift filtration generators weights marked weight_pos generator_mem t u + (sourceLift t a b)))) = a + ∑ i, u i * b i := by + rw [evaluation, markedBaseEvaluation_real_map] + exact sourceLift_shift_coordinate η hη t a b u + +noncomputable def pureOrbit (t : ℕ) (a : ℝ) (b : Fin t → ℝ) : + (multidegree t).realification.PolynomialOrbit := + (multidegree t).realification.polynomialOrbitOfLog + (monomial (correlationExponent 0 1) (projectedLift t a b)) (by + apply (multidegree t).realification.monomial_mem_adaptedSubmodule + simpa only [correlationExponent_apply] using projectedLift_mem t a b) + +theorem pureOrbit_eval (t : ℕ) (a : ℝ) (b : Fin t → ℝ) (h n : ℤ) : + ((multidegree t).realification.polynomialOrbitEval (correlationInput h n) (pureOrbit t a b)).coord = + (n : ℝ) • projectedLift t a b := by + change eval (fun i => ((correlationInput h n i : ℤ) : ℚ)) + (monomial (correlationExponent 0 1) (projectedLift t a b)) = _ + rw [eval_correlation_monomial] + change ((h : ℚ) ^ 0 * (n : ℚ) ^ 1) • projectedLift t a b = _ + rw [pow_zero, pow_one, one_mul] + simpa only [Rat.cast_intCast] using + (Rat.cast_smul_eq_qsmul ℝ (n : ℚ) (projectedLift t a b)).symm + +theorem pureOrbit_phase (t m : ℕ) (a : ℝ) (b : Fin t → ℝ) (h n : ℤ) : + torusPhaseLinear (phase t m) + ((multidegree t).realification.polynomialOrbitEval (correlationInput h n) (pureOrbit t a b)).coord = 0 := by + rw [pureOrbit_eval, map_smul, projectedLift_phase, smul_zero] + +theorem pureOrbit_at_zero (t : ℕ) (a : ℝ) (b : Fin t → ℝ) (h : ℤ) : + (multidegree t).realification.polynomialOrbitEval (correlationInput h 0) (pureOrbit t a b) = 1 := by + apply NilpotentLieBCHGroup.ext + rw [pureOrbit_eval] + simp + +end Erdos3.QuadraticMarked + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/QuantitativeEarlyAffineCoveredSource.lean b/lean/OAI/Combinatorics/Progressions/Lattices/QuantitativeEarlyAffineCoveredSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd9fc3932e49f6e3bb0bb7d3b12c8ca171ee46f9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/QuantitativeEarlyAffineCoveredSource.lean @@ -0,0 +1,44 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineWholeProfileComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +universe uJ uQ +open scoped ContDiff NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Nonempty (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) + + theorem exists_quantitative_early_affine_covered_source + (hrows : ∀ j, Function.Injective (rows j)) (hcard : ∀ j o, (rows j o).card ≤ j.val + 1) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (block : ∀ a : LayerSamplerAxis I n, O a.1 → B a) (hblock : ∀ a, Function.Injective (block a)) + {δ η E F : ℝ} (hδ : 0 < δ) (hδone : δ ≤ 1) (hη : 0 < η) + (hE : 0 ≤ E) (hF : 0 ≤ F) (hηE : η⁻¹ ≤ Real.exp E) (hδF : (δ / 2)⁻¹ ≤ Real.exp F) : + ∃ ρ : (LayerSamplerAxis I n → Prop) → ℝ≥0, + (∀ P, 0 < ρ P ∧ ρ P ≤ 1 ∧ + (ρ P : ℝ)⁻¹ ≤ Real.exp (allocatedAffineRadiusLog (O := O) (α := α) B A T E F)) ∧ + ∃ t : ℝ, 0 < t ∧ ∃ htone : t ≤ 1, + Real.log t⁻¹ ≤ allocatedAffineToleranceLog (G := G) (O := O) (α := α) B A T E F ∧ + AllocatedAffineCoveredComparison.{uJ, uQ, _, _, _, _, _} (G := G) B rows δ η ρ t htone := by + obtain ⟨ρ, hρ, t, ht, htone, hlog, hs⟩ := + exists_quantitative_early_affine_reference_source (G := G) B rows hrows hcard + ψ hψ hrange hzero hone A T hLip hTransition block hblock hδ hδone hη hE hF hηE hδF + refine ⟨ρ, hρ, t, ht, htone, hlog, ?_⟩ + apply allocatedAffineCoveredComparison_of_coefficient B rows hδ ρ + (fun P => (hρ P).1) (fun P => (hρ P).2.1) t htone + exact allocatedAffineCoefficientComparison_of_reference B rows hrows hcard hδ ρ + (fun P => (hρ P).1) (fun P => (hρ P).2.1) t htone hs + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/QuantitativeRealSubgroupLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/QuantitativeRealSubgroupLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..78476934489c408a9f2fdfab763608f3942d59d5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/QuantitativeRealSubgroupLattice.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalRealSubgroup + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem exists_realification_subgroup_basis_and_lattice + {ι η L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + (e : Basis ι ℚ L) (K : LieSubalgebra ℚ L) (v : η → K) + (hspan : Submodule.span ℚ (Set.range v) = ⊤) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) {H l : ℕ} (hHpos : 1 ≤ H) (hlpos : 0 < l) + (hv : ∀ i j, RationalHeightLE (e.repr (v i : L) j) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hl : (l : ℝ) ≤ Real.exp p) : + ∃ b : Basis (Fin (finrank ℚ K)) ℚ K, ∃ N : ℕ, + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + (∀ i j, RationalHeightLE (e.repr (b i : L) j) H) ∧ + (∀ i j k, ((lieStructureConstants b i j k).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 11) ∧ + ((lieStructureConstants b i j k).den : ℝ) ≤ Real.exp ((p + 2) ^ 11)) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.map + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)) ∧ + bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.map + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)) ⊆ denominatorGrid N ∧ + CompactSpace (NilpotentLieBCHGroup.realificationSubgroup (hnil := hnil) K ⧸ + (Γ.map NilpotentLieBCHGroup.realificationHom).comap + (NilpotentLieBCHGroup.realificationSubgroup (hnil := hnil) K).subtype) := by + obtain ⟨b, N, hN, hNb, hb, hbr, hin, hout⟩ := + exists_subalgebra_basis_and_grid e K v hspan Γ hHpos hlpos hv hc hinner houter hp hd hH hl + exact ⟨b, N, hN, hNb, hb, hbr, hin, hout, + NilpotentLieBCHGroup.compactSpace_realificationSubgroup_quotient K b Γ N hN hin hout⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/QuarticIntegerTranslation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/QuarticIntegerTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f74de7faaeb8ae4526ecada1763e523dcc37675 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/QuarticIntegerTranslation.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.QuarticSurvivorMultilinearization + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + +theorem exists_quartic_integer_translation_equivalence : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ} + (W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) p) + (a b : QuarticReplicatedIndex → ℤ), + NativeIntegerVectorEquivalence 3 ((p + C) ^ C) + (fun i x => W.eval i (x + a)) (fun i x => W.eval i (x + b)) := by + obtain ⟨C, hC, htranslate⟩ := + UnitVerticalObservable.exists_integer_translation_equivalence_budget 3 + refine ⟨C, hC, ?_⟩ + intro p W a b + have hp : 0 ≤ p := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + let U : W.model.UnitVerticalObservable + (W.model.filtration.realification.subgroup (∑ _ : QuarticReplicatedIndex, 1)) + (Fin W.outputDim) p := + { W.vertical with + vertical := fun i z hz x => W.vertical.vertical i z (W.multi.realSubgroup_top.symm ▸ hz) x + integral := fun z hz hL => W.vertical.integral z (W.multi.realSubgroup_top.symm ▸ hz) hL } + have hI : (Fintype.card (Fin W.outputDim) : ℝ) ≤ Real.exp p := by + simpa only [Fintype.card_fin] using W.output_bound + have E := htranslate W.model U (W.multi.orbitToOrdinary W.orbit) hp W.complexity.1 hI a b + have heval (i : Fin W.outputDim) (x : QuarticReplicatedIndex → ℤ) : + U.observable i (QuotientGroup.mk + (W.model.filtration.realification.polynomialOrbitEval (fun _ => 1) x + (W.multi.orbitToOrdinary W.orbit))) = W.eval i x := by + rw [W.multi.orbitToOrdinary_eval] + rfl + have hl : (fun i x => U.observable i (QuotientGroup.mk + (W.model.filtration.realification.polynomialOrbitEval (fun _ => 1) (x + a) + (W.multi.orbitToOrdinary W.orbit)))) = (fun i x => W.eval i (x + a)) := by + funext i x + exact heval i (x + a) + have hr : (fun i x => U.observable i (QuotientGroup.mk + (W.model.filtration.realification.polynomialOrbitEval (fun _ => 1) (x + b) + (W.multi.orbitToOrdinary W.orbit)))) = (fun i x => W.eval i (x + b)) := by + funext i x + exact heval i (x + b) + exact (congrArg₂ (fun f g : Fin W.outputDim → (QuarticReplicatedIndex → ℤ) → ℂ => + NativeIntegerVectorEquivalence 3 ((p + C) ^ C) f g) hl hr).mp E + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RandomAffinePair.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RandomAffinePair.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2705bf67e38d7d97ffd63a500e891f0184c9d02 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RandomAffinePair.lean @@ -0,0 +1,163 @@ +import OAI.Combinatorics.Progressions.Estimates.FourProductSmoothing + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory + +theorem unitScalarMeasure_reflection (f : ℝ → ℝ) : + (∫ u, f (1 - u) ∂unitScalarMeasure) = ∫ u, f u ∂unitScalarMeasure := by + change (∫ u in Set.Ioc (0 : ℝ) 1, f (1 - u)) = ∫ u in Set.Ioc (0 : ℝ) 1, f u + rw [← intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1), + ← intervalIntegral.integral_of_le (by norm_num : (0 : ℝ) ≤ 1), + intervalIntegral.integral_comp_sub_left f 1] + norm_num + +theorem uniform_signed_slope_normalize (a : ℝ) (f : ℝ → ℝ) : + (∫ u, f (a * u) ∂unitScalarMeasure) = + ∫ u, f (min 0 a + |a| * u) ∂unitScalarMeasure := by + by_cases ha : 0 ≤ a + · simp only [min_eq_left ha, abs_of_nonneg ha, zero_add] + · have ha' : a < 0 := lt_of_not_ge ha + calc + (∫ u, f (a * u) ∂unitScalarMeasure) = + ∫ u, f (a * (1 - u)) ∂unitScalarMeasure := (unitScalarMeasure_reflection _).symm + _ = ∫ u, f (min 0 a + |a| * u) ∂unitScalarMeasure := by + apply integral_congr_ae + filter_upwards [] with u + congr 1 + rw [min_eq_right ha'.le, abs_of_neg ha'] + ring + +theorem uniform_two_affine_normalize (a b c : ℝ) (φ : ℝ → ℝ) : + (∫ u, ∫ v, φ (c + a * u + b * v) ∂unitScalarMeasure ∂unitScalarMeasure) = + ∫ u, ∫ v, φ (c + min 0 a + min 0 b + (|a| * u + |b| * v)) + ∂unitScalarMeasure ∂unitScalarMeasure := by + have ha := uniform_signed_slope_normalize a + (fun x => ∫ v, φ (c + x + b * v) ∂unitScalarMeasure) + apply ha.trans + apply integral_congr_ae + filter_upwards [] with u + have hb := uniform_signed_slope_normalize b (fun y => φ (c + (min 0 a + |a| * u) + y)) + apply hb.trans + apply integral_congr_ae + filter_upwards [] with v + congr 1 + ring + +theorem uniform_two_affine_sort (a b c : ℝ) (φ : ℝ → ℝ) (hφ : Measurable φ) + {C : ℝ} (hbound : ∀ x, ‖φ x‖ ≤ C) : + (∫ u, ∫ v, φ (c + min 0 a + min 0 b + min |a| |b| * u + max |a| |b| * v) + ∂unitScalarMeasure ∂unitScalarMeasure) = + ∫ u, ∫ v, φ (c + a * u + b * v) ∂unitScalarMeasure ∂unitScalarMeasure := by + have h := uniform_two_term_sum_sort |a| |b| + (fun z => φ (c + min 0 a + min 0 b + z)) + (hφ.comp (measurable_const.add measurable_id)) (fun z => hbound _) + have hn := uniform_two_affine_normalize a b c φ + simpa only [add_assoc] using h.trans hn.symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +variable {T : Type*} [MeasurableSpace T] + +noncomputable def affinePairWidth (a b : T → ℝ) (p : T × ℝ) : ℝ := max |a p.1| |b p.1| + +noncomputable def affinePairShift (a b c : T → ℝ) (p : T × ℝ) : ℝ := + c p.1 + min 0 (a p.1) + min 0 (b p.1) + min |a p.1| |b p.1| * p.2 + +theorem affinePairWidth_measurable {a b : T → ℝ} (ha : Measurable a) (hb : Measurable b) : + Measurable (affinePairWidth a b) := (ha.abs.max hb.abs).comp measurable_fst + +theorem affinePairShift_measurable {a b c : T → ℝ} + (ha : Measurable a) (hb : Measurable b) (hc : Measurable c) : + Measurable (affinePairShift a b c) := by + unfold affinePairShift + fun_prop + +noncomputable def affinePairDensity (μ : Measure T) (a b c : T → ℝ) : ℝ → ℝ := + randomIntervalDensity (μ.prod unitScalarMeasure) (affinePairWidth a b) (affinePairShift a b c) + +theorem affinePairDensity_measurable (μ : Measure T) [SFinite μ] {a b c : T → ℝ} + (ha : Measurable a) (hb : Measurable b) (hc : Measurable c) : + Measurable (affinePairDensity μ a b c) := + randomIntervalDensity_measurable _ _ _ (affinePairWidth_measurable ha hb) + (affinePairShift_measurable ha hb hc) + +theorem affinePairWidth_inverse_integral (μ : Measure T) [SFinite μ] (a b : T → ℝ) : + (∫ p, (affinePairWidth a b p)⁻¹ ∂μ.prod unitScalarMeasure) = + ∫ t, (max |a t| |b t|)⁻¹ ∂μ := by + unfold affinePairWidth + rw [integral_fun_fst (fun t => (max |a t| |b t|)⁻¹), probReal_univ, one_smul] + +theorem affinePairDensity_cap (μ : Measure T) [IsProbabilityMeasure μ] {a b c : T → ℝ} + (ha : Measurable a) (hb : Measurable b) (hc : Measurable c) + (hpos : ∀ᵐ t ∂μ, 0 < max |a t| |b t|) + (hi : Integrable (fun t => (max |a t| |b t|)⁻¹) μ) (x : ℝ) : + affinePairDensity μ a b c x ∈ Set.Icc (0 : ℝ) (∫ t, (max |a t| |b t|)⁻¹ ∂μ) := by + have h := randomIntervalDensity_cap (μ.prod unitScalarMeasure) _ _ + (affinePairWidth_measurable ha hb) (affinePairShift_measurable ha hb hc) + (Measure.quasiMeasurePreserving_fst.ae hpos) (hi.comp_fst unitScalarMeasure) x + rw [affinePairWidth_inverse_integral] at h + exact h + +theorem affinePairDensity_probability_density (μ : Measure T) [IsProbabilityMeasure μ] + {a b c : T → ℝ} (ha : Measurable a) (hb : Measurable b) (hc : Measurable c) + (hpos : ∀ᵐ t ∂μ, 0 < max |a t| |b t|) : + (∀ x, 0 ≤ affinePairDensity μ a b c x) ∧ Integrable (affinePairDensity μ a b c) ∧ + (∫ x, affinePairDensity μ a b c x) = 1 := + randomIntervalDensity_probability_density _ _ _ (affinePairWidth_measurable ha hb) + (affinePairShift_measurable ha hb hc) (Measure.quasiMeasurePreserving_fst.ae hpos) + +theorem affinePairDensity_translation_l1 (μ : Measure T) [IsProbabilityMeasure μ] + {a b c : T → ℝ} (ha : Measurable a) (hb : Measurable b) (hc : Measurable c) + (hpos : ∀ᵐ t ∂μ, 0 < max |a t| |b t|) + (hi : Integrable (fun t => (max |a t| |b t|)⁻¹) μ) (x y : ℝ) : + (∫ u, |affinePairDensity μ a b c (u + x) - affinePairDensity μ a b c (u + y)|) ≤ + 2 * (∫ t, (max |a t| |b t|)⁻¹ ∂μ) * |x - y| := by + have h := randomIntervalDensity_translation_l1 (μ.prod unitScalarMeasure) _ _ + (affinePairWidth_measurable ha hb) (affinePairShift_measurable ha hb hc) + (Measure.quasiMeasurePreserving_fst.ae hpos) (hi.comp_fst unitScalarMeasure) x y + rw [affinePairWidth_inverse_integral] at h + exact h + +theorem affinePairDensity_test_integral (μ : Measure T) [IsProbabilityMeasure μ] + {a b c : T → ℝ} (ha : Measurable a) (hb : Measurable b) (hc : Measurable c) + (hpos : ∀ᵐ t ∂μ, 0 < max |a t| |b t|) (φ : ℝ → ℝ) (hφ : Measurable φ) + {C : ℝ} (hbound : ∀ x, ‖φ x‖ ≤ C) : + (∫ x, affinePairDensity μ a b c x * φ x) = + ∫ t, ∫ u, ∫ v, φ (c t + a t * u + b t * v) + ∂unitScalarMeasure ∂unitScalarMeasure ∂μ := by + have h := randomIntervalDensity_test_integral (μ.prod unitScalarMeasure) _ _ + (affinePairWidth_measurable ha hb) (affinePairShift_measurable ha hb hc) + (Measure.quasiMeasurePreserving_fst.ae hpos) φ hφ hbound + apply h.trans + have hm : Measurable (fun p : (T × ℝ) × ℝ => + φ (affinePairShift a b c p.1 + affinePairWidth a b p.1 * p.2)) := + hφ.comp (((affinePairShift_measurable ha hb hc).comp measurable_fst).add + (((affinePairWidth_measurable ha hb).comp measurable_fst).mul measurable_snd)) + have hi : Integrable (fun p : (T × ℝ) × ℝ => + φ (affinePairShift a b c p.1 + affinePairWidth a b p.1 * p.2)) + ((μ.prod unitScalarMeasure).prod unitScalarMeasure) := + (integrable_const C).mono' hm.aestronglyMeasurable + (Filter.Eventually.of_forall (fun p => hbound _)) + rw [integral_prod _ hi.integral_prod_left] + apply integral_congr_ae + filter_upwards [] with t + exact uniform_two_affine_sort (a t) (b t) (c t) φ hφ hbound + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RationalForecastResidueMass.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RationalForecastResidueMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..94d1f98700cd52a5ff850f948608cb9d27be8eff --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RationalForecastResidueMass.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.Progressions.Sampling.RationalForecastCoefficientPeriod + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {A I J : Type*} [Fintype A] [DecidableEq A] [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] + +local instance characterOrderNeZero (N : ℕ) [NeZero N] + (χ : AddChar (J → ZMod N) ℂ) : NeZero (orderOf χ) := + ⟨(isOfFinOrder_of_finite χ).orderOf_pos.ne'⟩ + +omit [Fintype I] [DecidableEq I] in + +theorem integerLongPolynomial_characteristic_residue_representative + (poly : J → MvPolynomial (A ⊕ I) ℤ) (N : ℕ) [NeZero N] + (p : FiniteProbabilityWeights (A → ZMod N)) + (χ : AddChar (J → ZMod N) ℂ) (v : I → ℤ) : + finiteImageCharacteristic p + (fun t j => (integerLongPolynomialOutput poly v N t j : ZMod N)) χ = + finiteImageCharacteristic p + (fun t j => (integerLongPolynomialOutput poly + (fun i => (((v i : ZMod (orderOf χ)).val : ℕ) : ℤ)) N t j : ZMod N)) χ := by + apply integerLongPolynomial_characteristic_inactive_congr + intro i + simp only [Int.cast_natCast, ZMod.natCast_zmod_val] + +theorem integerLongPolynomial_characteristic_inactive_split + {Ω Z : Type*} [Fintype Ω] + (inactive : FiniteProbabilityWeights Ω) (gridPoint : Ω → Z) + (v : Ω → I → ℤ) (poly : J → MvPolynomial (A ⊕ I) ℤ) + (N : ℕ) [NeZero N] (p : FiniteProbabilityWeights (A → ZMod N)) + (χ : AddChar (J → ZMod N) ℂ) (z : Z) : + inactive.complexMean (fun i => if gridPoint i = z then + finiteImageCharacteristic p + (fun t j => (integerLongPolynomialOutput poly (v i) N t j : ZMod N)) χ else 0) = + ∑ r : I → ZMod (orderOf χ), + (inactive.fiberMean (fun i j => (v i j : ZMod (orderOf χ))) r + (fun i => if gridPoint i = z then 1 else 0) : ℂ) * + finiteImageCharacteristic p + (fun t j => (integerLongPolynomialOutput poly + (fun i => ((r i).val : ℤ)) N t j : ZMod N)) χ := by + let : NeZero (orderOf χ) := ⟨(isOfFinOrder_of_finite χ).orderOf_pos.ne'⟩ + have h := inactive.complexMean_fiber_factor + (fun i j => (v i j : ZMod (orderOf χ))) + (fun i => if gridPoint i = z then 1 else 0) + (fun r => finiteImageCharacteristic p + (fun t j => (integerLongPolynomialOutput poly + (fun i => ((r i).val : ℤ)) N t j : ZMod N)) χ) + rw [← h] + congr 1 + funext i + by_cases hi : gridPoint i = z + · simp only [hi, ite_true, Complex.ofReal_one, one_mul] + exact integerLongPolynomial_characteristic_residue_representative poly N p χ (v i) + · simp only [hi, ite_false, Complex.ofReal_zero, zero_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem inactiveResidueCoefficient_mass_le + {Ω Z R : Type*} [Fintype Ω] [Fintype R] + (p : FiniteProbabilityWeights Ω) (gridPoint : Ω → Z) (residue : Ω → R) + (a : R → ℂ) (ha : ∀ r, ‖a r‖ ≤ 1) (z : Z) : + (∑ r, ‖(p.fiberMean residue r (fun i => if gridPoint i = z then 1 else 0) : ℂ) * a r‖) ≤ + p.fiberMean gridPoint z (fun _ => 1) := by + have hnonneg (r : R) : + 0 ≤ p.fiberMean residue r (fun i => if gridPoint i = z then 1 else 0) := + p.fiberMean_nonneg residue r _ (fun _ => by split_ifs <;> norm_num) + calc + _ ≤ ∑ r, p.fiberMean residue r (fun i => if gridPoint i = z then 1 else 0) := by + apply Finset.sum_le_sum + intro r _ + rw [norm_mul, Complex.norm_real, Real.norm_of_nonneg (hnonneg r)] + simpa only [mul_one] using mul_le_mul_of_nonneg_left (ha r) (hnonneg r) + _ = _ := p.sum_fiberMean residue _ + +theorem rationalInactiveResidueCoefficient_mass_le + {Ω A I J Z : Type*} [Fintype Ω] [Fintype A] [DecidableEq A] + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (inactive : FiniteProbabilityWeights Ω) (gridPoint : Ω → Z) (v : Ω → I → ℤ) + (poly : J → MvPolynomial (A ⊕ I) ℤ) (N q : ℕ) [NeZero N] [NeZero q] + (p : FiniteProbabilityWeights (A → ZMod N)) (χ : AddChar (J → ZMod N) ℂ) (z : Z) : + (∑ r : I → ZMod q, + ‖(inactive.fiberMean (fun i j => (v i j : ZMod q)) r + (fun i => if gridPoint i = z then 1 else 0) : ℂ) * + finiteImageCharacteristic p + (fun t j => (integerLongPolynomialOutput poly (fun i => ((r i).val : ℤ)) N t j : ZMod N)) χ‖) + ≤ inactive.fiberMean gridPoint z (fun _ => 1) := by + apply inactiveResidueCoefficient_mass_le + intro r + exact finiteImageCharacteristic_norm_le_one p _ χ + +theorem rationalForecast_order_residue_term_count + {I J : Type*} [Fintype I] [Fintype J] [DecidableEq J] + (N : ℕ) [NeZero N] (T : ℕ) : + (∑ χ ∈ Finset.univ.filter (fun χ : AddChar (J → ZMod N) ℂ => orderOf χ ≤ T), + (orderOf χ) ^ Fintype.card I) ≤ T ^ (Fintype.card J + Fintype.card I + 1) := by + let S := Finset.univ.filter (fun χ : AddChar (J → ZMod N) ℂ => orderOf χ ≤ T) + have hcount : S.card ≤ T ^ (Fintype.card J + 1) := + finiteCharacter_boundedOrder_card_le (integerResidueTuple N) + (integerResidueTuple_surjective N) T + calc + _ ≤ ∑ _χ ∈ S, T ^ Fintype.card I := by + apply Finset.sum_le_sum + intro χ hχ + exact Nat.pow_le_pow_left (Finset.mem_filter.mp hχ).2 _ + _ = S.card * T ^ Fintype.card I := by simp + _ ≤ T ^ (Fintype.card J + 1) * T ^ Fintype.card I := + Nat.mul_le_mul_right _ hcount + _ = _ := by rw [← pow_add]; congr 1; omega + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RationalInactiveLatticeContraction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RationalInactiveLatticeContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..56c047f23437a37e80dc99b81750021f5b5e7df2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RationalInactiveLatticeContraction.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalInactivePartialReference + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {I A Z O K : Type*} [Fintype I] [Fintype A] [Fintype O] [DecidableEq O] + +theorem rationalInactiveForecast_lattice_tsum_test + (inactive : FiniteProbabilityWeights I) (active : I → FiniteProbabilityWeights A) + (gridPoint : I → Z) (Y : I → A → O → ℤ) (N : ℕ) [NeZero N] + {gridVolume : ℝ} (hV : gridVolume ≠ 0) + (G : K → ℂ) (sK : Finset K) (hG : ∀ k ∉ sK, G k = 0) + (b : K → O → ZMod N) (test : Z → K → ℂ) : + (∑' z, ∑' k, G k * + ((rationalInactiveForecast inactive active gridPoint Y N gridVolume z (b k) / + gridVolume : ℝ) : ℂ) * test z k) = + inactive.complexMean (fun i => ∑' k, + G k * (rationalOutputDensity (active i) (Y i) N (b k) : ℂ) * + test (gridPoint i) k) := by + let grid := Finset.univ.image gridPoint + have hz (z : Z) (hz : z ∉ grid) (k : K) : + rationalInactiveForecast inactive active gridPoint Y N gridVolume z (b k) = 0 := + rationalInactiveForecast_zero_off_image inactive active gridPoint Y N gridVolume z hz (b k) + rw [tsum_eq_sum (s := grid) (fun z h => by simp only [hz z h, zero_div, + Complex.ofReal_zero, mul_zero, zero_mul, tsum_zero])] + have hk (z : Z) : (∑' k, G k * + ((rationalInactiveForecast inactive active gridPoint Y N gridVolume z (b k) / + gridVolume : ℝ) : ℂ) * test z k) = + ∑ k ∈ sK, G k * + ((rationalInactiveForecast inactive active gridPoint Y N gridVolume z (b k) / + gridVolume : ℝ) : ℂ) * test z k := + tsum_eq_sum (fun k h => by rw [hG k h, zero_mul, zero_mul]) + simp_rw [hk] + rw [Finset.sum_comm] + have hzsum (k : K) : + (∑ z ∈ grid, G k * + ((rationalInactiveForecast inactive active gridPoint Y N gridVolume z (b k) / + gridVolume : ℝ) : ℂ) * test z k) = + G k * inactive.complexMean (fun i => + (rationalOutputDensity (active i) (Y i) N (b k) : ℂ) * test (gridPoint i) k) := by + rw [← rationalInactiveForecast_pointwise_tsum_test inactive active gridPoint Y N hV + (b k) (fun z => test z k)] + rw [tsum_eq_sum (s := grid) (fun z h => by simp only [hz z h k, zero_div, + Complex.ofReal_zero, zero_mul])] + simp only [Finset.mul_sum, mul_assoc] + simp_rw [hzsum] + have hi (i : I) : (∑' k, G k * + (rationalOutputDensity (active i) (Y i) N (b k) : ℂ) * test (gridPoint i) k) = + ∑ k ∈ sK, G k * + (rationalOutputDensity (active i) (Y i) N (b k) : ℂ) * test (gridPoint i) k := + tsum_eq_sum (fun k h => by rw [hG k h, zero_mul, zero_mul]) + simp_rw [hi, FiniteProbabilityWeights.complexMean, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro k _ + ring + +theorem rationalInactiveForecast_lattice_tsum_test_div + (inactive : FiniteProbabilityWeights I) (active : I → FiniteProbabilityWeights A) + (gridPoint : I → Z) (Y : I → A → O → ℤ) (N : ℕ) [NeZero N] + {gridVolume : ℝ} (hV : gridVolume ≠ 0) + (G : K → ℂ) (sK : Finset K) (hG : ∀ k ∉ sK, G k = 0) + (b : K → O → ZMod N) (test : Z → K → ℂ) (v : ℂ) : + (∑' z, ∑' k, G k * + ((rationalInactiveForecast inactive active gridPoint Y N gridVolume z (b k) / + gridVolume : ℝ) : ℂ) * test z k) / v = + inactive.complexMean (fun i => (∑' k, + G k * (rationalOutputDensity (active i) (Y i) N (b k) : ℂ) * + test (gridPoint i) k) / v) := by + rw [rationalInactiveForecast_lattice_tsum_test inactive active gridPoint Y N hV G sK hG b test] + simp only [FiniteProbabilityWeights.complexMean, Finset.sum_div, mul_div_assoc] + +theorem rationalInactiveForecast_compactGrid_tsum_test_div {J : Type*} [Fintype J] + (inactive : FiniteProbabilityWeights I) (active : I → FiniteProbabilityWeights A) + (gridPoint : I → Z) (Y : I → A → O → ℤ) (N : ℕ) [NeZero N] + {gridVolume : ℝ} (hV : gridVolume ≠ 0) + (g : (J → ℝ) → ℝ) (center scale : J → ℝ) + (hscale : ∀ j, 0 < scale j) (R : ℝ) + (hsupport : ∀ x, R < ‖x‖ → g x = 0) + (b : (J → ℤ) → O → ZMod N) (test : Z → (J → ℤ) → ℂ) : + (∑' z, ∑' k : J → ℤ, + (g (fun j => ((k j : ℝ) - center j) / scale j) : ℂ) * + ((rationalInactiveForecast inactive active gridPoint Y N gridVolume z (b k) / + gridVolume : ℝ) : ℂ) * test z k) / ((∏ j, scale j : ℝ) : ℂ) = + inactive.complexMean (fun i => (∑' k : J → ℤ, + (g (fun j => ((k j : ℝ) - center j) / scale j) : ℂ) * + (rationalOutputDensity (active i) (Y i) N (b k) : ℂ) * + test (gridPoint i) k) / ((∏ j, scale j : ℝ) : ℂ)) := by + apply rationalInactiveForecast_lattice_tsum_test_div inactive active gridPoint Y N hV + _ (rectangularWeightIndices center scale R) _ b test + intro k hk + have h := rectangularWeight_zero_off_indices g center scale hscale hsupport k hk + unfold rectangularWeight rectangularLatticePoint at h + rw [h, Complex.ofReal_zero] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RationalLatticeFunctional.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RationalLatticeFunctional.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6852e9986726e46c5b6b3ac6a3bdd02b1c1c53e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RationalLatticeFunctional.lean @@ -0,0 +1,26 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeCentralSeed + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +theorem realLattice_functional_integral (η : L →ₗ[ℚ] ℚ) + (hη : ∀ g : D.filtration.Group, g ∈ D.lattice → ∃ n : ℤ, η g.coord = n) + (z : D.RealGroup) (hz : z ∈ D.realLattice) : + ∃ n : ℤ, realifyFunctional η z.coord = n := by + obtain ⟨g, hg, rfl⟩ := hz + obtain ⟨n, hn⟩ := hη g hg + refine ⟨n, ?_⟩ + change realifyFunctional η ((1 : ℝ) ⊗ₜ[ℚ] g.coord) = _ + rw [realifyFunctional_tmul, one_mul, hn, Rat.cast_intCast] + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RealMarkedAffineShift.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RealMarkedAffineShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..434a8c445132e9fb7f390f6da7a16ffff7790479 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RealMarkedAffineShift.lean @@ -0,0 +1,101 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonMarkedMultidegree + +namespace OAI + +section + +namespace Erdos3 + +open NilpotentLieBCHGroup +open scoped BigOperators TensorProduct + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (hw : ∀ i, 0 < w i) (hv : ∀ i, v i ∈ F.layer (w i) 1) (t : ℕ) + +noncomputable def realMarkedAffineShift (a : Fin t → ℝ) : + (ℝ ⊗[ℚ] markedShiftSubalgebra F v w marked t) →ₗ[ℝ] + (ℝ ⊗[ℚ] markedShiftSubalgebra F v w marked t) := + LinearMap.id + ∑ i, a i • + ((markedShiftTranslate F v w marked hw hv t (Pi.single i 1)).baseChange ℝ - LinearMap.id) + +theorem realMarkedAffineShift_apply (a : Fin t → ℝ) + (p : ℝ ⊗[ℚ] markedShiftSubalgebra F v w marked t) : + realMarkedAffineShift F v w marked hw hv t a p = + p + ∑ i, a i • + ((markedShiftTranslate F v w marked hw hv t (Pi.single i 1)).baseChange ℝ p - p) := by + simp only [realMarkedAffineShift, LinearMap.add_apply, LinearMap.sum_apply, + LinearMap.smul_apply, LinearMap.sub_apply, LinearMap.id_apply] + +theorem realMarkedAffineShift_quotient (a : Fin t → ℝ) + (p : ℝ ⊗[ℚ] markedShiftSubalgebra F v w marked t) : + (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap.baseChange ℝ + (realMarkedAffineShift F v w marked hw hv t a p) = + (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap.baseChange ℝ p + + ⁅realMarkedParameterDirection F v w marked t a, + (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap.baseChange ℝ p⁆ := by + let q := (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap.baseChange ℝ + have hb : ⁅realMarkedParameterDirection F v w marked t a, q p⁆ = + ∑ i, a i • ⁅realMarkedDirection F v w marked t (Pi.single i 1), q p⁆ := by + apply (congrArg (fun z : ℝ ⊗[ℚ] MarkedShiftQuotient F v w marked t => ⁅z, q p⁆) + (realMarkedParameterDirection_apply F v w marked t a)).trans + apply (sum_lie Finset.univ + (fun i => a i • realMarkedDirection F v w marked t (Pi.single i 1)) (q p)).trans + apply Finset.sum_congr rfl + intro i _ + exact smul_lie (R := ℝ) (a i) (realMarkedDirection F v w marked t (Pi.single i 1)) (q p) + calc + q (realMarkedAffineShift F v w marked hw hv t a p) = q p + + ∑ i, a i • (q ((markedShiftTranslate F v w marked hw hv t (Pi.single i 1)).baseChange ℝ p) - q p) := by + rw [realMarkedAffineShift_apply F v w marked hw hv t a p] + simp only [map_add, map_sum, map_smul, map_sub] + _ = q p + ∑ i, a i • ⁅realMarkedDirection F v w marked t (Pi.single i 1), q p⁆ := by + apply congrArg (q p + ·) + apply Finset.sum_congr rfl + intro i _ + have he := (realMarkedTranslate_quotient F v w marked hw hv t (Pi.single i 1) p).trans + (realMarkedTranslate_first_order F v w marked hw hv t (Pi.single i 1) (q p)) + rw [he, add_sub_cancel_left] + _ = _ := congrArg (q p + ·) hb.symm + +theorem realMarkedAffineShift_conjugation (hs : 1 ≤ s) (a : Fin t → ℝ) + (p : ℝ ⊗[ℚ] markedShiftSubalgebra F v w marked t) : + conjugationCoord (realMarkedParameterElement F v w marked hw hv t a) + ((lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap.baseChange ℝ p) = + (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap.baseChange ℝ + (realMarkedAffineShift F v w marked hw hv t a p) := + (realMarkedParameterElement_conjugation F v w marked hw hv t hs a _).trans + (realMarkedAffineShift_quotient F v w marked hw hv t a p).symm + +theorem realMarkedAffineShift_eval (a : Fin t → ℝ) + (p : ℝ ⊗[ℚ] markedShiftSubalgebra F v w marked t) : + (markedShiftEval F v w marked t 0).baseChange ℝ + (realMarkedAffineShift F v w marked hw hv t a p) = + (markedShiftEval F v w marked t 0).baseChange ℝ p + + ∑ i, a i • ((markedShiftEval F v w marked t (Pi.single i 1)).baseChange ℝ p - + (markedShiftEval F v w marked t 0).baseChange ℝ p) := by + rw [realMarkedAffineShift_apply, map_add, map_sum] + apply congrArg ((markedShiftEval F v w marked t 0).baseChange ℝ p + ·) + apply Finset.sum_congr rfl + intro i _ + rw [map_smul, map_sub, realMarkedShiftEval_translate, zero_add] + +theorem realMarkedAffineShift_eval_affine (a : Fin t → ℝ) + (p : ℝ ⊗[ℚ] markedShiftSubalgebra F v w marked t) + (x : ℝ ⊗[ℚ] L) (y : Fin t → ℝ ⊗[ℚ] L) + (hp : ∀ b : Fin t → ℚ, (markedShiftEval F v w marked t b).baseChange ℝ p = + x + ∑ i, (b i : ℝ) • y i) : + (markedShiftEval F v w marked t 0).baseChange ℝ + (realMarkedAffineShift F v w marked hw hv t a p) = x + ∑ i, a i • y i := by + have h0 : (markedShiftEval F v w marked t 0).baseChange ℝ p = x := by + simpa only [Pi.zero_apply, Rat.cast_zero, zero_smul, Finset.sum_const_zero, add_zero] using hp 0 + have hi (i : Fin t) : (markedShiftEval F v w marked t (Pi.single i 1)).baseChange ℝ p = x + y i := by + simpa [Pi.single_apply, apply_ite] using hp (Pi.single i 1) + rw [realMarkedAffineShift_eval, h0] + simp only [hi, add_sub_cancel_left] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RealSpanIntegerDefiningRows.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RealSpanIntegerDefiningRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..78e3fbb1d539743ce4ff96bf211d4ff35674596e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RealSpanIntegerDefiningRows.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Linear.QuotientProjectionCoordinates + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +def realSpanIntegerRowBound (n m H : ℕ) : ℕ := + imageDefiningHeight n m H ^ (m * m) * imageDefiningHeight n m H + +theorem exists_real_span_integer_defining_matrix {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℚ) {H : ℕ} (hH : 1 ≤ H) + (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ C : Matrix ι ι ℤ, + (∀ i j, |(C i j : ℝ)| ≤ + (realSpanIntegerRowBound (Fintype.card κ) (Fintype.card ι) H : ℝ)) ∧ + LinearMap.ker (Matrix.mulVecLin (fun i j => (C i j : ℝ))) = + LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) := by + classical + obtain ⟨Q, hQ, hker⟩ := exists_real_span_defining_matrix A hH hA + have hcast (i j : ι) : + (clearedMatrix Q i j : ℝ) = (matrixDenominator Q : ℝ) * (Q i j : ℝ) := by + have h := congrFun (congrFun (clearedMatrix_cast Q) i) j + change (clearedMatrix Q i j : ℚ) = (matrixDenominator Q : ℚ) * Q i j at h + exact_mod_cast h + refine ⟨clearedMatrix Q, ?_, ?_⟩ + · intro i j + rw [hcast, abs_mul, abs_of_nonneg (Nat.cast_nonneg _)] + have hd := Nat.cast_le (α := ℝ).mpr (matrixDenominator_le Q hQ) + have hentry := (hQ i j).abs_real_le + exact (mul_le_mul hd hentry (abs_nonneg _) (Nat.cast_nonneg _)).trans_eq + (by simp only [realSpanIntegerRowBound, Nat.cast_mul]) + · have hden : (matrixDenominator Q : ℝ) ≠ 0 := + (Nat.cast_pos.mpr (matrixDenominator_pos Q)).ne' + have hmatrix : Matrix.of (fun i j => (clearedMatrix Q i j : ℝ)) = + (matrixDenominator Q : ℝ) • Matrix.of (fun i j => (Q i j : ℝ)) := by + ext i j + exact hcast i j + calc + LinearMap.ker (Matrix.mulVecLin (fun i j => (clearedMatrix Q i j : ℝ))) = + LinearMap.ker (Matrix.mulVecLin (fun i j => (Q i j : ℝ))) := by + ext x + change (Matrix.of (fun i j => (clearedMatrix Q i j : ℝ)) *ᵥ x = 0) ↔ + (Matrix.of (fun i j => (Q i j : ℝ)) *ᵥ x = 0) + rw [hmatrix, Matrix.smul_mulVec] + simp [hden] + _ = _ := hker + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RealSymbolAffine.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RealSymbolAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..1afd820fe74376c824d622a001379b335d8589ed --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RealSymbolAffine.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.Progressions.Estimates.SymbolFastMembership + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) (w : σ → ℕ) + +theorem realSymbolOfPolynomial_translate (hw : ∀ i, 0 < w i) (h : σ → ℚ) + (p : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (hp : F.realification.Adapted w p) : + F.realSymbolOfPolynomial b ω hF w (translate h p) = F.realSymbolOfPolynomial b ω hF w p := by + let q : F.realification.adaptedLieSubalgebra w := + ⟨p, (F.realification.mem_adaptedSubmodule w p).mpr hp⟩ + let q' : F.realification.adaptedLieSubalgebra w := + ⟨translate h p, (F.realification.mem_adaptedSubmodule w _).mpr + (F.realification.adapted_translate w hw h hp)⟩ + exact (F.realSymbolOfPolynomial_eq_iff_symbolMap_eq b ω hF w q' q).mpr + (F.realification.polynomialSymbolMap_translate w hw h q) + +theorem realSymbolOfPolynomial_affine (hw : ∀ i, 0 < w i) (h : σ → ℚ) (r : ℚ) + (p : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (hp : F.realification.Adapted w p) : + F.realSymbolOfPolynomial b ω hF w (weightedDilation w r (translate h p)) = + F.realPolynomialSymbolDilation w r (F.realSymbolOfPolynomial b ω hF w p) := by + rw [F.realSymbolOfPolynomial_dilation, F.realSymbolOfPolynomial_translate b ω hF w hw h p hp] + +theorem realGradedSymbolPolynomial_dilation_coefficient (r : ℚ) + (x : F.RealPolynomialSymbol w) (α : σ →₀ ℕ) : + coefficients (F.realGradedSymbolPolynomial b ω hF w (F.realPolynomialSymbolDilation w r x)) α = + (r : ℝ) ^ Finsupp.weight w α • coefficients (F.realGradedSymbolPolynomial b ω hF w x) α := by + apply ((F.associatedGradedBasis b ω hF).baseChange ℝ).repr.injective + ext i + rw [map_smul, Finsupp.smul_apply] + by_cases h : Finsupp.weight w α = ω i + · rw [F.realGradedSymbolPolynomial_coordinate b ω hF w _ ⟨(α, i), h⟩, + F.realGradedSymbolPolynomial_coordinate b ω hF w _ ⟨(α, i), h⟩, + F.realPolynomialSymbolDilation_repr] + rfl + · rw [F.realGradedSymbolPolynomial_coordinate_of_ne b ω hF w _ α i h, + F.realGradedSymbolPolynomial_coordinate_of_ne b ω hF w _ α i h, smul_zero] + +theorem realSymbolDilation_mem_pointwise (U : LieSubalgebra ℚ F.AssociatedGraded) + (r : ℚ) (x : F.RealPolynomialSymbol w) + (hx : x ∈ realificationLieSubalgebra (F.symbolPointwiseSubalgebra b ω hF w U)) : + F.realPolynomialSymbolDilation w r x ∈ + realificationLieSubalgebra (F.symbolPointwiseSubalgebra b ω hF w U) := by + apply (F.mem_real_symbolPointwiseSubalgebra_iff_coefficients b ω hF w U _).mpr + intro α + rw [F.realGradedSymbolPolynomial_dilation_coefficient] + exact (realificationLieSubalgebra U).smul_mem _ + ((F.mem_real_symbolPointwiseSubalgebra_iff_coefficients b ω hF w U x).mp hx α) + +theorem realSymbolDilation_mem_pointwise_iff (U : LieSubalgebra ℚ F.AssociatedGraded) + (r : ℚ) (hr : r ≠ 0) (x : F.RealPolynomialSymbol w) : + F.realPolynomialSymbolDilation w r x ∈ + realificationLieSubalgebra (F.symbolPointwiseSubalgebra b ω hF w U) ↔ + x ∈ realificationLieSubalgebra (F.symbolPointwiseSubalgebra b ω hF w U) := by + constructor + · intro hx + have h := F.realSymbolDilation_mem_pointwise b ω hF w U r⁻¹ _ hx + simpa only [← F.realPolynomialSymbolDilation_mul, inv_mul_cancel₀ hr, + F.realPolynomialSymbolDilation_one] using h + · exact F.realSymbolDilation_mem_pointwise b ω hF w U r x + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RealifiedFiltrationLattices.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RealifiedFiltrationLattices.lean new file mode 100644 index 0000000000000000000000000000000000000000..53d55105a5605fa073f8cbb45f148f05f3e76257 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RealifiedFiltrationLattices.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalRealSubgroup + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem realification_subgroup_eq_realificationSubgroup (i : ℕ) : + F.realification.subgroup i = + NilpotentLieBCHGroup.realificationSubgroup (hnil := F.lowerCentralSeries_eq_bot) + (F.layerIdeal i).toLieSubalgebra := by + ext g + rfl + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem realification_layer_lattice_closed_discrete (e : Basis ι ℚ L) + (Γ : Subgroup F.Group) (l : ℕ) (hl : 0 < l) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) (i : ℕ) : + let Λ := (Γ.map NilpotentLieBCHGroup.realificationHom).comap (F.realification.subgroup i).subtype + IsClosed (Λ : Set (F.realification.subgroup i)) ∧ IsDiscrete (Λ : Set (F.realification.subgroup i)) := by + rw [F.realification_subgroup_eq_realificationSubgroup] + exact NilpotentLieBCHGroup.realificationSubgroup_lattice_closed_discrete e + (F.layerIdeal i).toLieSubalgebra Γ l hl houter + +omit [T2Space (ℝ ⊗[ℚ] L)] in +theorem realification_layer_lattice_cocompact (e : Basis ι ℚ L) + (Γ : Subgroup F.Group) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) (i : ℕ) : + CompactSpace (F.realification.subgroup i ⧸ + (Γ.map NilpotentLieBCHGroup.realificationHom).comap (F.realification.subgroup i).subtype) := by + rw [F.realification_subgroup_eq_realificationSubgroup] + exact NilpotentLieBCHGroup.realificationSubgroup_lattice_cocompact e + (F.layerIdeal i).toLieSubalgebra Γ l hl hinner houter + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RealifiedSubgroupLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RealifiedSubgroupLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4358d1c2921f96eadb935929a8b0a72d4181b52 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RealifiedSubgroupLattice.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.Progressions.Estimates.ContinuousCosetMap +import OAI.Combinatorics.Progressions.Estimates.PetalComparisonTree + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def realificationSubgroupHom (K : LieSubalgebra ℚ L) : + NilpotentLieBCHGroup (ℝ ⊗[ℚ] K) s + (realification_lowerCentralSeries_eq_bot (lie_subalgebra_lowerCentralSeries_eq_bot hnil K)) →* + realificationSubgroup (hnil := hnil) K := + (realificationMap (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) + (hM := hnil) K.incl).codRestrict _ (realificationMap_incl_mem (hnil := hnil) K) + +theorem realificationSubgroupHom_injective (K : LieSubalgebra ℚ L) : + Function.Injective (realificationSubgroupHom (hnil := hnil) K) := by + intro x y hxy + exact realificationMap_incl_injective K (congrArg Subtype.val hxy) + +theorem realificationSubgroupHom_surjective (K : LieSubalgebra ℚ L) : + Function.Surjective (realificationSubgroupHom (hnil := hnil) K) := by + intro g + have hg : g.1 ∈ (realificationMap + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) (hM := hnil) K.incl).range := by + rw [realificationMap_incl_range] + exact g.2 + obtain ⟨x, hx⟩ := hg + exact ⟨x, Subtype.ext hx⟩ + +theorem realificationSubgroupHom_lattice_comap (K : LieSubalgebra ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) : + ((Γ.map realificationHom).comap (realificationSubgroup (hnil := hnil) K).subtype).comap + (realificationSubgroupHom (hnil := hnil) K) = + (Γ.comap (map (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)).map + (realificationHom (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K)) := + realification_subgroup_comap_incl K Γ + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +omit [T2Space (ℝ ⊗[ℚ] L)] in +theorem continuous_realificationSubgroupHom (K : LieSubalgebra ℚ L) + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] [FiniteDimensional ℚ K] : + Continuous (realificationSubgroupHom (hnil := hnil) K) := by + have hlinear : Continuous (realificationLieHom K.incl) := + (realificationLieHom K.incl).toLinearMap.continuous_of_finiteDimensional + have hgroup : Continuous (realificationMap + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) (hM := hnil) K.incl) := + continuous_map_of_continuous (realLieHomToRat (realificationLieHom K.incl)) hlinear + exact hgroup.subtype_mk _ + +omit [T2Space (ℝ ⊗[ℚ] L)] in +theorem compactSpace_realificationSubgroup_quotient {κ : Type*} [Fintype κ] + (K : LieSubalgebra ℚ L) (b : Basis κ ℚ K) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (N : ℕ) (hN : 0 < N) + (hinner : scaledIntegerGrid N ⊆ bchSubgroupCoordinates b + (Γ.comap (map (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl))) + (houter : bchSubgroupCoordinates b + (Γ.comap (map (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)) ⊆ denominatorGrid N) : + CompactSpace (realificationSubgroup (hnil := hnil) K ⧸ + (Γ.map realificationHom).comap (realificationSubgroup (hnil := hnil) K).subtype) := by + let ΓK := Γ.comap (map (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl) + obtain ⟨τ, hA, hS, hT, _, _, _, _, _⟩ := exists_realification_topology_of_grid b ΓK N hN houter + let : TopologicalSpace (ℝ ⊗[ℚ] K) := τ + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] K) := hA + let : ContinuousSMul ℝ (ℝ ⊗[ℚ] K) := hS + let : T2Space (ℝ ⊗[ℚ] K) := hT + let : FiniteDimensional ℚ K := b.finiteDimensional_of_finite + let Λ := (Γ.map realificationHom).comap (realificationSubgroup (hnil := hnil) K).subtype + let : CompactSpace (_ ⧸ Λ.comap (realificationSubgroupHom (hnil := hnil) K)) := by + change CompactSpace (_ ⧸ ((Γ.map realificationHom).comap + (realificationSubgroup (hnil := hnil) K).subtype).comap (realificationSubgroupHom (hnil := hnil) K)) + rw [realificationSubgroupHom_lattice_comap] + exact compactSpace_realification_quotient b ΓK N hN hinner + exact compactSpace_quotient_of_surjective_hom Λ (realificationSubgroupHom K) + (continuous_realificationSubgroupHom K) (realificationSubgroupHom_surjective K) + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RecoveredLatticeMatrixInvariance.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RecoveredLatticeMatrixInvariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7c9c01c87029ae65d310f383050bb04f0dd1500 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RecoveredLatticeMatrixInvariance.lean @@ -0,0 +1,233 @@ +import OAI.Combinatorics.Progressions.Estimates.AveragedModeledPatchTransfer +import OAI.Combinatorics.Progressions.Geometry.CoefficientDeckChartRecovery + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule + +variable {D I E : Type*} [Fintype D] [Fintype I] [Fintype E] {n : ℕ} +variable (W : Submodule ℝ (EuclideanSpace ℝ D)) +variable (bW : Basis E ℤ (latticeSection (standardEuclideanLattice D) W)) +variable (b : Basis (Fin n) ℝ Wᗮ) +variable (hb : span ℤ (Set.range b) = projectedIntegerLattice W) + +noncomputable def recoveredIntegerTransverse : (D → ℤ) →ₗ[ℤ] (Fin n → ℤ) where + toFun β i := standardLatticeCoordinates W bW b hb β (Sum.inl i) + map_add' β γ := by ext i; simp only [map_add, Pi.add_apply] + map_smul' q β := by ext i; simp only [map_smul, Pi.smul_apply, RingHom.id_apply] + +noncomputable def recoveredIntegerDeck : (D → ℤ) →ₗ[ℤ] (E → ℤ) where + toFun β i := standardLatticeCoordinates W bW b hb β (Sum.inr i) + map_add' β γ := by ext i; simp only [map_add, Pi.add_apply] + map_smul' q β := by ext i; simp only [map_smul, Pi.smul_apply, RingHom.id_apply] + +theorem recoveredIntegerTransverse_projection (β : D → ℤ) : + Wᗮ.orthogonalProjectionOnto (standardEuclideanPoint D β).val = + -b.equivFun.symm (fun i => (recoveredIntegerTransverse W bW b hb β i : ℝ)) := + standardLatticeCoordinates_projection W bW b hb β + +theorem recoveredIntegerTransverse_normalized (β : D → ℤ) (i : Fin n) : + (normalizedOrthogonalChart W b (standardEuclideanPoint D β).val).2 i = + -(recoveredIntegerTransverse W bW b hb β i : ℝ) / basisAxisScale b i := by + rw [normalizedOrthogonalChart_apply, recoveredIntegerTransverse_projection W bW b hb β, + map_neg, LinearEquiv.apply_symm_apply] + rfl + +theorem recoveredIntegerDeck_reconstruction (β : D → ℤ) : + (standardEuclideanPoint D β).val + + (standardLatticeIntegerLift W b hb (recoveredIntegerTransverse W bW b hb β)).val = + (bW.equivFun.symm (recoveredIntegerDeck W bW b hb β)).val.val := + standardLatticeCoordinates_reconstruction W bW b hb β + +theorem recoveredIntegerTransverse_of_mem (ℓ : D → ℤ) + (hℓ : (standardEuclideanPoint D ℓ).val ∈ W) : + recoveredIntegerTransverse W bW b hb ℓ = 0 := by + have hp := recoveredIntegerTransverse_projection W bW b hb ℓ + rw [W.orthogonalProjectionOnto_orthogonal_apply_eq_zero hℓ] at hp + have hz : (fun i => (recoveredIntegerTransverse W bW b hb ℓ i : ℝ)) = 0 := by + apply b.equivFun.symm.injective + simpa only [map_zero] using neg_eq_zero.mp hp.symm + funext i + have hi := congrFun hz i + simp only [Pi.zero_apply] at hi ⊢ + exact_mod_cast hi + +theorem recoveredIntegerDeck_of_mem (ℓ : D → ℤ) + (hℓ : (standardEuclideanPoint D ℓ).val ∈ W) : + recoveredIntegerDeck W bW b hb ℓ = + bW.equivFun ⟨⟨(standardEuclideanPoint D ℓ).val, hℓ⟩, + (standardEuclideanPoint D ℓ).property⟩ := by + have hr := recoveredIntegerDeck_reconstruction W bW b hb ℓ + rw [recoveredIntegerTransverse_of_mem W bW b hb ℓ hℓ, map_zero, + Submodule.coe_zero, add_zero] at hr + apply bW.equivFun.symm.injective + rw [LinearEquiv.symm_apply_apply] + apply Subtype.ext + apply Subtype.ext + exact hr.symm + +theorem recoveredIntegerTransverse_add_retained (β ℓ : D → ℤ) (q : ℤ) + (hℓ : (standardEuclideanPoint D ℓ).val ∈ W) : + recoveredIntegerTransverse W bW b hb (β + q • ℓ) = + recoveredIntegerTransverse W bW b hb β := by + rw [map_add, map_zsmul, recoveredIntegerTransverse_of_mem W bW b hb ℓ hℓ, + smul_zero, add_zero] + +theorem recoveredIntegerDeck_add_retained (β ℓ : D → ℤ) (q : ℤ) + (hℓ : (standardEuclideanPoint D ℓ).val ∈ W) : + recoveredIntegerDeck W bW b hb (β + q • ℓ) = + recoveredIntegerDeck W bW b hb β + + q • bW.equivFun ⟨⟨(standardEuclideanPoint D ℓ).val, hℓ⟩, + (standardEuclideanPoint D ℓ).property⟩ := by + rw [map_add, map_zsmul, recoveredIntegerDeck_of_mem W bW b hb ℓ hℓ] + +variable (o : OrthonormalBasis I ℝ W) + +noncomputable def recoveredMixedCoordinates (y : EuclideanSpace ℝ D) (β : D → ℤ) : + (I → ℝ) × (Fin n → ℤ) := + ((mixedRealCoordinates W b o y).1, recoveredIntegerTransverse W bW b hb β) + +theorem recoveredMixedCoordinates_add (y y' : EuclideanSpace ℝ D) (β β' : D → ℤ) : + recoveredMixedCoordinates W bW b hb o (y + y') (β + β') = + recoveredMixedCoordinates W bW b hb o y β + + recoveredMixedCoordinates W bW b hb o y' β' := by + simp only [recoveredMixedCoordinates, map_add, Prod.fst_add, Prod.mk_add_mk] + +theorem recoveredMixedCoordinates_zsmul (q : ℤ) (y : EuclideanSpace ℝ D) (β : D → ℤ) : + recoveredMixedCoordinates W bW b hb o (q • y) (q • β) = + q • recoveredMixedCoordinates W bW b hb o y β := by + simp only [recoveredMixedCoordinates, map_zsmul, Prod.smul_fst, Prod.smul_mk] + +theorem recoveredMixedCoordinates_add_retained (y : EuclideanSpace ℝ D) + (β ℓ : D → ℤ) (q : ℤ) (hℓ : (standardEuclideanPoint D ℓ).val ∈ W) : + recoveredMixedCoordinates W bW b hb o y (β + q • ℓ) = + recoveredMixedCoordinates W bW b hb o y β := by + unfold recoveredMixedCoordinates + rw [recoveredIntegerTransverse_add_retained W bW b hb β ℓ q hℓ] + +theorem recoveredMixedCoordinates_real (y : EuclideanSpace ℝ D) (β : D → ℤ) + (hy : y + (standardEuclideanPoint D β).val ∈ W) : + mixedRealCoordinates W b o y = + ((recoveredMixedCoordinates W bW b hb o y β).1, + fun i => ((recoveredMixedCoordinates W bW b hb o y β).2 i : ℝ) / + basisAxisScale b i) := by + refine Prod.ext (by rfl) ?_ + have hp := W.orthogonalProjectionOnto_orthogonal_apply_eq_zero hy + rw [map_add, recoveredIntegerTransverse_projection W bW b hb β] at hp + have hp' := eq_of_sub_eq_zero (show Wᗮ.orthogonalProjectionOnto y - + b.equivFun.symm (fun i => (recoveredIntegerTransverse W bW b hb β i : ℝ)) = 0 by + simpa only [sub_eq_add_neg] using hp) + funext i + change (normalizedOrthogonalChart W b y).2 i = _ + rw [normalizedOrthogonalChart_apply, hp', LinearEquiv.apply_symm_apply] + rfl + +theorem recoveredMixedCoordinates_point (y : EuclideanSpace ℝ D) (β : D → ℤ) + (hy : y + (standardEuclideanPoint D β).val ∈ W) : + normalizedLatticePoint W b + (orthonormalMixedChart o (recoveredMixedCoordinates W bW b hb o y β)) = y := by + rw [← mixedRealPoint_integer] + rw [← recoveredMixedCoordinates_real W bW b hb o y β hy] + exact mixedRealPoint_coordinates W b o y + +theorem recoveredMixedCoordinates_deck (y : EuclideanSpace ℝ D) (β : D → ℤ) + (hy : y + (standardEuclideanPoint D β).val ∈ W) : + normalizedLatticeRepresentative W b hb + (orthonormalMixedChart o (recoveredMixedCoordinates W bW b hb o y β)) + + (bW.equivFun.symm (recoveredIntegerDeck W bW b hb β)).val = + ⟨y + (standardEuclideanPoint D β).val, hy⟩ := by + apply Subtype.ext + rw [normalizedDeckPoint_identity, + recoveredMixedCoordinates_point W bW b hb o y β hy] + congr 3 + apply (standardLatticeCoordinates W bW b hb).injective + rw [latticeDeckInteger_coordinates] + funext i + cases i <;> rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule + +theorem recoveredIntegerLift_linear_residue {T : Type*} {d a : ℕ} + (f : (Fin d → ℤ) →ₗ[ℤ] (T → ℤ)) + (M : Fin d → Fin a → ℤ) (N : ℕ) [NeZero N] + (hM : ∀ i j, (N : ℤ) ∣ M i j) (β : Fin d → ℤ) (k : Fin a → ℤ) : + integerResidueMap T N (f (recoveredIntegerLift M β k)) = + integerResidueMap T N (f β) := by + obtain ⟨A, _, hA⟩ := exists_bounded_integerMap_residue_matrix f N + rw [hA, hA] + congr 1 + exact recoveredIntegerLift_residue M N hM β k + +variable {m d a : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] + +def layerIntegerRestriction (e : Fin d ≃ Sigma J) (j : Fin m) : + (Fin d → ℤ) →ₗ[ℤ] (J j → ℤ) where + toFun β i := β (e.symm ⟨j, i⟩) + map_add' _ _ := rfl + map_smul' _ _ := rfl + +def recoveredLayeredIntegerLift (e : Fin d ≃ Sigma J) + (M : Fin d → Fin a → ℤ) (β : Sigma J → ℤ) (k : Fin a → ℤ) : Sigma J → ℤ := + fun i => recoveredIntegerLift M (fun i => β (e i)) k (e.symm i) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] {n : Fin m → ℕ} +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + +theorem recoveredIntegerTransverse_layer_matrix + (e : Fin d ≃ Sigma J) (M : Fin d → Fin a → ℤ) + (hcol : ∀ j t, (standardEuclideanPoint (J j) + (fun i => M (e.symm ⟨j, i⟩) t)).val ∈ euclideanSubspace (U j)) + (β : Sigma J → ℤ) (k : Fin a → ℤ) (j : Fin m) : + recoveredIntegerTransverse (euclideanSubspace (U j)) (bW j) (b j) (hb j) + (fun i => recoveredLayeredIntegerLift e M β k ⟨j, i⟩) = + recoveredIntegerTransverse (euclideanSubspace (U j)) (bW j) (b j) (hb j) + (fun i => β ⟨j, i⟩) := by + let π : (Fin d → ℤ) →+ (Fin (n j) → ℤ) := + (recoveredIntegerTransverse (euclideanSubspace (U j)) (bW j) (b j) (hb j)).toAddMonoidHom.comp + (layerIntegerRestriction e j).toAddMonoidHom + have hπ (t : Fin a) : π (fun i => M i t) = 0 := + recoveredIntegerTransverse_of_mem (euclideanSubspace (U j)) (bW j) (b j) (hb j) + (fun i => M (e.symm ⟨j, i⟩) t) (hcol j t) + have h := recoveredIntegerLift_projection M π hπ (fun i => β (e i)) k + simpa only [π, AddMonoidHom.comp_apply, LinearMap.toAddMonoidHom_coe, + layerIntegerRestriction, LinearMap.coe_mk, AddHom.coe_mk, Equiv.apply_symm_apply, + recoveredLayeredIntegerLift] using h + +theorem standardLatticeCoordinates_layer_matrix_residue + (e : Fin d ≃ Sigma J) (M : Fin d → Fin a → ℤ) (N : ℕ) [NeZero N] + (hdiv : ∀ i t, (N : ℤ) ∣ M i t) + (β : Sigma J → ℤ) (k : Fin a → ℤ) (j : Fin m) : + integerResidueMap (Fin (n j) ⊕ E j) N + (standardLatticeCoordinates (euclideanSubspace (U j)) (bW j) (b j) (hb j) + (fun i => recoveredLayeredIntegerLift e M β k ⟨j, i⟩)) = + integerResidueMap (Fin (n j) ⊕ E j) N + (standardLatticeCoordinates (euclideanSubspace (U j)) (bW j) (b j) (hb j) + (fun i => β ⟨j, i⟩)) := by + let f := (standardLatticeCoordinates (euclideanSubspace (U j)) + (bW j) (b j) (hb j)).toLinearMap.comp (layerIntegerRestriction e j) + have h := recoveredIntegerLift_linear_residue f M N hdiv (fun i => β (e i)) k + simpa only [f, LinearMap.comp_apply, LinearEquiv.coe_coe, + layerIntegerRestriction, LinearMap.coe_mk, AddHom.coe_mk, Equiv.apply_symm_apply, + recoveredLayeredIntegerLift] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RectangularLatticeCells.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RectangularLatticeCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5b24e42b037fb06edd72c0ce4befae37708e446 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RectangularLatticeCells.lean @@ -0,0 +1,172 @@ +import Mathlib.Data.Fintype.Pi +import Mathlib.MeasureTheory.Function.Floor +import Mathlib.MeasureTheory.Integral.Bochner.Set +import Mathlib.MeasureTheory.Measure.Lebesgue.Basic +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory + +noncomputable def latticeSample (a S x : ℝ) : ℝ := (⌊a + S * x⌋ - a) / S + +def latticeSamplingCell (a S : ℝ) (k : ℤ) : Set ℝ := + Set.Ico (((k : ℝ) - a) / S) (((k : ℝ) + 1 - a) / S) + +theorem latticeSamplingCell_measurable (a S : ℝ) (k : ℤ) : + MeasurableSet (latticeSamplingCell a S k) := measurableSet_Ico + +theorem latticeSamplingCell_iff {a S x : ℝ} (hS : 0 < S) (k : ℤ) : + x ∈ latticeSamplingCell a S k ↔ ⌊a + S * x⌋ = k := by + rw [Int.floor_eq_iff] + change (((k : ℝ) - a) / S ≤ x ∧ x < ((k : ℝ) + 1 - a) / S) ↔ _ + rw [div_le_iff₀ hS, lt_div_iff₀ hS] + constructor <;> rintro ⟨h₁, h₂⟩ <;> constructor <;> nlinarith + +theorem latticeSamplingCell_volume {a S : ℝ} (hS : 0 < S) (k : ℤ) : + volume.real (latticeSamplingCell a S k) = 1 / S := by + rw [measureReal_def, latticeSamplingCell, Real.volume_Ico] + have he : (((k : ℝ) + 1 - a) / S - ((k : ℝ) - a) / S) = 1 / S := by ring + rw [he, ENNReal.toReal_ofReal (div_nonneg zero_le_one hS.le)] + +theorem latticeSample_error {a S : ℝ} (hS : 0 < S) (x : ℝ) : + |latticeSample a S x - x| ≤ 1 / S := by + have hlo := Int.floor_le (a + S * x) + have hhi := Int.lt_floor_add_one (a + S * x) + have he : latticeSample a S x - x = + (((⌊a + S * x⌋ : ℤ) : ℝ) - (a + S * x)) / S := by + unfold latticeSample + field_simp + ring + rw [he, abs_div, abs_of_pos hS] + apply div_le_div_of_nonneg_right _ hS.le + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +theorem latticeSample_measurable (a S : ℝ) : Measurable (latticeSample a S) := by + unfold latticeSample + fun_prop + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +noncomputable def finiteLatticeHistogram (s : Finset ℤ) (w : ℤ → ℝ) (a S x : ℝ) : ℝ := + ∑ k ∈ s, (latticeSamplingCell a S k).indicator (fun _ => w k) x + +theorem latticeSamplingCell_indicator_integrable (a S : ℝ) (k : ℤ) (v : ℝ) : + Integrable ((latticeSamplingCell a S k).indicator (fun _ => v)) := by + apply (integrable_indicator_iff (latticeSamplingCell_measurable a S k)).mpr + exact integrableOn_const (by simp [latticeSamplingCell, Real.volume_Ico]) + +theorem finiteLatticeHistogram_integrable (s : Finset ℤ) (w : ℤ → ℝ) (a S : ℝ) : + Integrable (finiteLatticeHistogram s w a S) := by + apply integrable_finsetSum + intro k _ + exact latticeSamplingCell_indicator_integrable a S k (w k) + +theorem finiteLatticeHistogram_integral (s : Finset ℤ) (w : ℤ → ℝ) (a : ℝ) + {S : ℝ} (hS : 0 < S) : + (∫ x, finiteLatticeHistogram s w a S x) = (∑ k ∈ s, w k) / S := by + unfold finiteLatticeHistogram + rw [integral_finsetSum] + · simp only [integral_indicator_const _ (latticeSamplingCell_measurable a S _), + latticeSamplingCell_volume hS, smul_eq_mul, one_div] + rw [← Finset.mul_sum] + ring + · intro k _ + exact latticeSamplingCell_indicator_integrable a S k (w k) + +theorem finiteLatticeHistogram_eq_floor (s : Finset ℤ) (w : ℤ → ℝ) + (hw : ∀ k, k ∉ s → w k = 0) (a : ℝ) {S : ℝ} (hS : 0 < S) (x : ℝ) : + finiteLatticeHistogram s w a S x = w ⌊a + S * x⌋ := by + classical + unfold finiteLatticeHistogram + rw [Finset.sum_eq_single ⌊a + S * x⌋] + · exact Set.indicator_of_mem ((latticeSamplingCell_iff hS _).mpr rfl) _ + · intro k _ hne + apply Set.indicator_of_notMem + intro hk + exact hne ((latticeSamplingCell_iff hS k).mp hk).symm + · intro hn + rw [hw _ hn] + simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +variable {J : Type*} [Fintype J] + +noncomputable def rectangularLatticePoint (a S : J → ℝ) (k : J → ℤ) : J → ℝ := + fun j => ((k j : ℝ) - a j) / S j + +noncomputable def rectangularLatticeRound (a S x : J → ℝ) : J → ℤ := + fun j => ⌊a j + S j * x j⌋ + +noncomputable def rectangularLatticeSample (a S x : J → ℝ) : J → ℝ := + rectangularLatticePoint a S (rectangularLatticeRound a S x) + +def rectangularLatticeCell (a S : J → ℝ) (k : J → ℤ) : Set (J → ℝ) := + Set.univ.pi fun j => latticeSamplingCell (a j) (S j) (k j) + +theorem rectangularLatticeCell_measurable (a S : J → ℝ) (k : J → ℤ) : + MeasurableSet (rectangularLatticeCell a S k) := + MeasurableSet.univ_pi fun j => latticeSamplingCell_measurable (a j) (S j) (k j) + +omit [Fintype J] in +theorem rectangularLatticeCell_iff (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (x : J → ℝ) (k : J → ℤ) : + x ∈ rectangularLatticeCell a S k ↔ rectangularLatticeRound a S x = k := by + simp only [rectangularLatticeCell, Set.mem_univ_pi, rectangularLatticeRound, + funext_iff, latticeSamplingCell_iff (hS _)] + +theorem rectangularLatticeCell_volume (a S : J → ℝ) (hS : ∀ j, 0 < S j) (k : J → ℤ) : + volume.real (rectangularLatticeCell a S k) = (∏ j, S j)⁻¹ := by + rw [measureReal_def, rectangularLatticeCell, volume_pi_pi, ENNReal.toReal_prod] + change (∏ j, volume.real (latticeSamplingCell (a j) (S j) (k j))) = _ + simp only [latticeSamplingCell_volume (hS _), one_div, Finset.prod_inv_distrib] + +theorem rectangularLatticeCell_volume_ne_top (a S : J → ℝ) (k : J → ℤ) : + volume (rectangularLatticeCell a S k) ≠ ⊤ := by + rw [rectangularLatticeCell, volume_pi_pi] + apply ENNReal.prod_ne_top + intro j _ + simp only [latticeSamplingCell, Real.volume_Ico, ne_eq, ENNReal.ofReal_ne_top, not_false_eq_true] + +theorem rectangularLatticeSample_error (a S : J → ℝ) (hS : ∀ j, 0 < S j) + {δ : ℝ} (hδ : 0 ≤ δ) (hmesh : ∀ j, 1 / S j ≤ δ) (x : J → ℝ) : + ‖rectangularLatticeSample a S x - x‖ ≤ δ := by + apply (pi_norm_le_iff_of_nonneg hδ).mpr + intro j + exact (latticeSample_error (hS j) (x j)).trans (hmesh j) + +omit [Fintype J] in +theorem rectangularLatticeSample_measurable (a S : J → ℝ) : + Measurable (rectangularLatticeSample a S) := by + apply Measurable.of_eval + intro j + exact (latticeSample_measurable (a j) (S j)).comp (measurable_pi_apply j) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ReducedLatticeBasis.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ReducedLatticeBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3370f4ccdb04e0590332ca37e4498b520e41cec --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ReducedLatticeBasis.lean @@ -0,0 +1,292 @@ +import OAI.Combinatorics.Progressions.Linear.ProjectedBasisSpan + +namespace OAI + +section + +namespace Erdos3.BohrLattice.MinkowskiSecondBox + +open scoped BigOperators Matrix +open Erdos3.BohrLattice.BoxCertificate Set Module Submodule + +theorem exists_integral_spanning_product_certificate : + ∀ {n : ℕ} (b : Basis (Fin n) ℝ (Fin n → ℝ)), + ∃ C : SuccessiveProductCertificate + (span ℤ (Set.range b)).toAddSubgroup (fun _ ↦ 1) + (minkowskiSecondConstant n * |(Matrix.of b).det|), + span ℤ (Set.range C.point) = span ℤ (Set.range b) := by + intro n + induction n with + | zero => + intro b + refine ⟨{ + scale := fun i ↦ Fin.elim0 i + point := fun i ↦ Fin.elim0 i + scale_nonneg := fun i ↦ Fin.elim0 i + point_mem := fun i ↦ Fin.elim0 i + independent := linearIndependent_empty_type + mem_scaledBox := fun i ↦ Fin.elim0 i + product_le := ?_ }, ?_⟩ + · simp [minkowskiSecondConstant] + · simp + | succ n ih => + intro b + classical + let L : Submodule ℤ (Fin (n + 1) → ℝ) := span ℤ (Set.range b) + obtain ⟨v, hvL, hv0, hvmin⟩ := exists_shortest_nonzero_of_basis b + let vL : L := ⟨v, hvL⟩ + have hvL0 : vL ≠ 0 := by + intro h + apply hv0 + exact congrArg Subtype.val h + have hμpos : ∀ x : L, x ≠ 0 → 0 < ‖(x : Fin (n + 1) → ℝ)‖ := by + intro x hx + exact norm_pos_iff.mpr (by + intro h + apply hx + exact Subtype.ext h) + have hμhom : ∀ (c : ℤ), 0 < c → ∀ x : L, + ‖((c • x : L) : Fin (n + 1) → ℝ)‖ = + (c : ℝ) * ‖(x : Fin (n + 1) → ℝ)‖ := by + intro c hc x + have hcast : (((c • x : L) : Fin (n + 1) → ℝ)) = + (c : ℝ) • (x : Fin (n + 1) → ℝ) := by + ext i + simp + rw [hcast] + rw [norm_smul, Real.norm_eq_abs, abs_of_pos] + exact_mod_cast hc + have hμmin : ∀ x : L, x ≠ 0 → + ‖(vL : Fin (n + 1) → ℝ)‖ ≤ ‖(x : Fin (n + 1) → ℝ)‖ := by + intro x hx + exact hvmin x x.property (by + intro h + apply hx + exact Subtype.ext h) + obtain ⟨-, Bz, hBz0⟩ := + Erdos3.BohrLattice.PrimitiveExtension.shortest_zspan_vector_primitive_and_extends + (Nat.succ_pos n) b vL hvL0 + (fun x : L ↦ ‖(x : Fin (n + 1) → ℝ)‖) hμpos hμhom hμmin + let b' : Basis (Fin (n + 1)) ℝ (Fin (n + 1) → ℝ) := + Bz.ofZLatticeBasis ℝ L + have hb'0 : b' 0 = v := by + rw [show b' 0 = ((Bz 0 : L) : Fin (n + 1) → ℝ) by + exact Basis.ofZLatticeBasis_apply ℝ L Bz 0] + exact congrArg Subtype.val (by simpa using hBz0) + have hb'span : span ℤ (Set.range b') = L := by + exact Bz.ofZLatticeBasis_span ℝ L + let M : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ := (Matrix.of b')ᵀ + have hMdet : M.det ≠ 0 := by + have hbdet : (Pi.basisFun ℝ (Fin (n + 1))).det b' ≠ 0 := + (AlternatingMap.map_basis_ne_zero_iff b' + (Pi.basisFun ℝ (Fin (n + 1))).det).mpr + (Pi.basisFun ℝ (Fin (n + 1))).det_ne_zero + rw [Pi.basisFun_det_apply] at hbdet + simpa [M] using hbdet + obtain ⟨h, hh⟩ := exists_abs_apply_eq_norm v + have hvh : v h ≠ 0 := by + intro hz + have : ‖v‖ = 0 := by simpa [hz] using hh.symm + exact hv0 (norm_eq_zero.mp this) + have hMh0 : M h 0 ≠ 0 := by + simpa [M, Matrix.of_apply, hb'0] using hvh + let Q : Matrix (Fin n) (Fin n) ℝ := projectedTail h M + have hQdet : Q.det ≠ 0 := projectedTail_det_ne_zero h M hMdet hMh0 + let qB : Basis (Fin n) ℝ (Fin n → ℝ) := projectedTailBasis h M hMdet hMh0 + obtain ⟨cq, hcqspan⟩ := ih qB + have hQpoint : ∀ j, ∃ z : Fin n → ℤ, + Matrix.mulVec Q (intCastVec z) = cq.point j := by + intro j + have hm := cq.point_mem j + change cq.point j ∈ span ℤ (Set.range qB) at hm + rw [Submodule.mem_span_range_iff_exists_fun] at hm + obtain ⟨z, hz⟩ := hm + refine ⟨z, ?_⟩ + rw [← hz] + ext i + simp [Q, qB, Matrix.mulVec, dotProduct, intCastVec, mul_comm] + choose z hz using hQpoint + let raw : Fin n → Fin (n + 1) → ℝ := fun j ↦ rawTailLift M (z j) + let a : Fin n → ℤ := fun j ↦ -roundedCoefficient (raw j h / v h) + let lift : Fin n → Fin (n + 1) → ℝ := + fun j ↦ raw j + (a j) • v + let scale : Fin (n + 1) → ℝ := Fin.cons ‖v‖ (fun j ↦ 2 * cq.scale j) + let point : Fin (n + 1) → Fin (n + 1) → ℝ := Fin.cons v lift + have hraw_eq : ∀ j, raw j = ∑ k, (z j k) • b' k.succ := by + intro j + ext i + simp [raw, rawTailLift, M, Matrix.mulVec, dotProduct, intCastVec, + Fin.sum_univ_succ, mul_comm] + have hrawL : ∀ j, raw j ∈ L := by + intro j + rw [hraw_eq] + rw [← hb'span] + apply sum_mem + intro k hk + exact smul_mem _ _ (subset_span (Set.mem_range_self k.succ)) + have hliftL : ∀ j, lift j ∈ L := by + intro j + change raw j + (a j) • v ∈ L + exact add_mem (hrawL j) (smul_mem L (a j) hvL) + have hcol0 : (fun i ↦ M i 0) = v := by + funext i + simp [M, Matrix.of_apply, hb'0] + have hproj_raw : ∀ j, deleteProjection h v (raw j) = cq.point j := by + intro j + rw [← hcol0] + rw [deleteProjection_rawTailLift] + exact hz j + have hproj_lift : ∀ j, deleteProjection h v (lift j) = cq.point j := by + intro j + change deleteProjection h v (raw j + (a j) • v) = cq.point j + have hcast : (a j) • v = (a j : ℝ) • v := by + ext i + simp + rw [hcast, deleteProjection_add_smul h v (raw j) (a j : ℝ) hvh] + exact hproj_raw j + have hqnorm : ∀ j, ‖cq.point j‖ ≤ cq.scale j := by + intro j + apply (mem_realBox_const_iff_norm_le (cq.scale_nonneg j) _).mp + rw [← realBox_smul_one_eq_const] + exact cq.mem_scaledBox j + have ha : ∀ j, |raw j h / v h + (a j : ℝ)| ≤ (1 : ℝ) / 2 := by + intro j + simpa [a, sub_eq_add_neg] using + abs_sub_roundedCoefficient_le_half (raw j h / v h) + have hlift_upper : ∀ j, ‖lift j‖ ≤ cq.scale j + ‖v‖ / 2 := by + intro j + have hcast : (a j) • v = (a j : ℝ) • v := by + ext i + simp + change ‖raw j + (a j) • v‖ ≤ cq.scale j + ‖v‖ / 2 + rw [hcast] + exact reducedLift_apply_le h v (raw j) (cq.scale j) (a j : ℝ) + hh hvh (ha j) ((congrArg norm (hproj_raw j)).le.trans (hqnorm j)) + have hlift0 : ∀ j, lift j ≠ 0 := by + intro j hj + apply cq.independent.ne_zero j + rw [← hproj_lift j, hj] + ext i + simp [deleteProjection] + have hshortlift : ∀ j, ‖v‖ ≤ ‖lift j‖ := by + intro j + exact hvmin (lift j) (hliftL j) (hlift0 j) + have hliftnorm : ∀ j, ‖lift j‖ ≤ 2 * cq.scale j := by + intro j + have hu := hlift_upper j + have hs := hshortlift j + linarith + have hind : LinearIndependent ℝ point := by + rw [Fintype.linearIndependent_iff] + intro g hg i + have hprojrel : ∑ j, g j.succ • cq.point j = 0 := by + have hm := congrArg (deleteProjectionLinear h v) hg + rw [map_sum] at hm + rw [Fin.sum_univ_succ] at hm + simp only [point, Fin.cons_zero, Fin.cons_succ] at hm + rw [map_smul, deleteProjectionLinear_apply, + deleteProjection_self h v hvh, smul_zero, zero_add] at hm + simp only [map_smul, deleteProjectionLinear_apply, map_zero] at hm + simp_rw [hproj_lift] at hm + exact hm + have htail : ∀ j : Fin n, g j.succ = 0 := + (Fintype.linearIndependent_iff.mp cq.independent) _ hprojrel + refine Fin.cases ?_ htail i + rw [Fin.sum_univ_succ] at hg + simp only [point, Fin.cons_zero, Fin.cons_succ] at hg + simp_rw [htail] at hg + simp only [zero_smul, Finset.sum_const_zero, add_zero] at hg + exact (smul_eq_zero.mp hg).resolve_right hv0 + have hqdet : |(Matrix.of qB).det| = |Q.det| := by + have hmat : Matrix.of qB = Qᵀ := by + ext i j + simp [qB, Q, Matrix.of_apply, Matrix.col] + rw [hmat, Matrix.det_transpose] + have hMabs : |M.det| = |(Matrix.of b).det| := by + have hchange := abs_det_zspan_basis_eq b Bz + have hmat : Matrix.of (((↑) : L → (Fin (n + 1) → ℝ)) ∘ Bz) = + Matrix.of b' := by + ext i j + simp [b', Matrix.of_apply] + rw [hmat] at hchange + simpa [M] using hchange + have hfactor : |(Matrix.of b).det| = ‖v‖ * |Q.det| := by + rw [← hMabs] + have hd := abs_det_eq_abs_pivot_mul_abs_det_projectedTail h M hMh0 + have hentry : M h 0 = v h := congrFun hcol0 h + rw [hentry, hh] at hd + simpa [Q] using hd + have hspan : span ℤ (Set.range point) = L := by + have hz : deleteProjectionLinear h v (b' 0) = 0 := by + rw [hb'0, deleteProjectionLinear_apply, deleteProjection_self h v hvh] + have ht : ∀ j, deleteProjectionLinear h v (b' j.succ) = qB j := by + intro j + ext i + simp [qB, projectedTail, M, deleteProjection, hb'0] + have hw : ∀ j, lift j ∈ span ℤ (Set.range b') := by + intro j + rw [hb'span] + exact hliftL j + have hs : span ℤ (Set.range (fun j => deleteProjectionLinear h v (lift j))) = + span ℤ (Set.range qB) := by + simpa only [deleteProjectionLinear_apply, hproj_lift] using hcqspan + have hhspan := span_fin_cons_of_projected_span b' qB + (deleteProjectionLinear h v) hz ht lift hw hs + simpa only [hb'0, hb'span] using hhspan + refine ⟨{ + scale := scale + point := point + scale_nonneg := ?_ + point_mem := ?_ + independent := hind + mem_scaledBox := ?_ + product_le := ?_ }, hspan⟩ + · intro i + refine Fin.cases (norm_nonneg v) (fun j ↦ ?_) i + exact mul_nonneg (by norm_num) (cq.scale_nonneg j) + · intro i + refine Fin.cases hvL (fun j ↦ hliftL j) i + · intro i + refine Fin.cases ?_ (fun j ↦ ?_) i + · rw [realBox_smul_one_eq_const] + apply (mem_realBox_const_iff_norm_le (norm_nonneg v) v).mpr + simp + · have hm := (mem_realBox_const_iff_norm_le + (mul_nonneg (by norm_num) (cq.scale_nonneg j)) (lift j)).mpr + (hliftnorm j) + rw [realBox_smul_one_eq_const] + simpa [scale, point] using hm + · have hcq : ∏ j, cq.scale j ≤ minkowskiSecondConstant n * |Q.det| := by + simpa [hqdet] using cq.product_le + calc + ∏ i, scale i = ‖v‖ * ((2 : ℝ) ^ n * ∏ j, cq.scale j) := by + simp [scale, Fin.prod_univ_succ, Finset.prod_mul_distrib, + Finset.prod_const] + _ ≤ ‖v‖ * ((2 : ℝ) ^ n * + (minkowskiSecondConstant n * |Q.det|)) := by + gcongr + _ = minkowskiSecondConstant (n + 1) * |(Matrix.of b).det| := by + rw [minkowskiSecondConstant_succ, hfactor] + ring + +theorem exists_same_lattice_basis_norm_product_le {n : ℕ} + (b : Basis (Fin n) ℝ (Fin n → ℝ)) : + ∃ c : Basis (Fin n) ℝ (Fin n → ℝ), + span ℤ (Set.range c) = span ℤ (Set.range b) ∧ + (∏ i, ‖c i‖) ≤ minkowskiSecondConstant n * |(Matrix.of b).det| := by + obtain ⟨C, hspan⟩ := exists_integral_spanning_product_certificate b + let c := basisOfLinearIndependentOfCardEqFinrank' C.point C.independent (by simp) + have hc : ∀ i, c i = C.point i := by intro i; simp [c] + refine ⟨c, ?_, ?_⟩ + · simpa only [show (c : Fin n → Fin n → ℝ) = C.point from funext hc] using hspan + · apply le_trans (b := ∏ i, C.scale i) _ C.product_le + apply Finset.prod_le_prod₀ (fun i _ => norm_nonneg _) (fun i _ => ?_) + rw [hc] + apply (mem_realBox_const_iff_norm_le (C.scale_nonneg i) _).mp + simpa only [realBox_smul_one_eq_const] using C.mem_scaledBox i + +end Erdos3.BohrLattice.MinkowskiSecondBox + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RefilteredMarkedLatticeMap.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RefilteredMarkedLatticeMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..a06a983b920d84de63cdce745651a82bba8a2197 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RefilteredMarkedLatticeMap.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.Progressions.Estimates.StrongRefiltrationReconstruction + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open NilpotentLieBCHGroup + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +noncomputable def gradedRefiltrationInclusionHom (W : LieSubalgebra ℚ F.AssociatedGraded) : + (F.gradedRefiltration W).Group →* F.Group := + mapOfSteps (F.gradedRefiltrationSubalgebra W).incl + +noncomputable def gradedRefiltrationMarkedHom (W : LieSubalgebra ℚ F.AssociatedGraded) : + (F.gradedRefiltration W).Group →* + (G.gradedRefiltration (W.map (F.associatedGradedMap G φ hφ))).Group := + mapOfSteps (F.gradedRefiltrationMap G φ hφ W) + +theorem gradedRefiltrationMarkedHom_inclusion (W : LieSubalgebra ℚ F.AssociatedGraded) + (g : (F.gradedRefiltration W).Group) : + G.gradedRefiltrationInclusionHom (W.map (F.associatedGradedMap G φ hφ)) + (F.gradedRefiltrationMarkedHom G φ hφ W g) = + mapOfSteps (hL := F.lowerCentralSeries_eq_bot) (hM := G.lowerCentralSeries_eq_bot) φ + (F.gradedRefiltrationInclusionHom W g) := rfl + +theorem gradedRefiltrationMarkedHom_lattice (W : LieSubalgebra ℚ F.AssociatedGraded) + (Γ : Subgroup F.Group) (Λ : Subgroup G.Group) + (hφL : Γ ≤ Λ.comap (mapOfSteps + (hL := F.lowerCentralSeries_eq_bot) (hM := G.lowerCentralSeries_eq_bot) φ)) : + Γ.comap (F.gradedRefiltrationInclusionHom W) ≤ + (Λ.comap (G.gradedRefiltrationInclusionHom + (W.map (F.associatedGradedMap G φ hφ)))).comap + (F.gradedRefiltrationMarkedHom G φ hφ W) := by + intro g hg + change G.gradedRefiltrationInclusionHom (W.map (F.associatedGradedMap G φ hφ)) + (F.gradedRefiltrationMarkedHom G φ hφ W g) ∈ Λ + rw [F.gradedRefiltrationMarkedHom_inclusion G φ hφ W g] + exact hφL hg + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RefilteredResidueExpansionSpec.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RefilteredResidueExpansionSpec.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2fa1ef0a37eb51270a85f0121938bb27eb97af3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RefilteredResidueExpansionSpec.lean @@ -0,0 +1,321 @@ +import OAI.Combinatorics.Progressions.Estimates.LowerRefilteredCyclicExpansion +import OAI.Combinatorics.Progressions.Linear.NativeMarkedKernelRepresentatives + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_residue_class_lattice_factors {σ G : Type*} [Group G] + (Γ : Subgroup G) (f : (σ → ℤ) → G) (M : ℕ) (P : G → Prop) + (hperiod : ∀ x y : σ → ℤ, (∀ j, (M : ℤ) ∣ x j - y j) → + ((QuotientGroup.mk (f x) : G ⧸ Γ) = QuotientGroup.mk (f y)) ∧ + ((QuotientGroup.mk (f x)⁻¹ : G ⧸ Γ) = QuotientGroup.mk (f y)⁻¹)) + (hrep : ∀ x : σ → ℤ, + (∃ r : G, P r ∧ ∃ γ ∈ Γ, f x = r * γ) ∧ + (∃ r : G, P r ∧ ∃ γ ∈ Γ, f x = γ * r)) : + ∃ rR rL : (σ → ZMod M) → G, + (∀ c, P (rR c) ∧ P (rL c)) ∧ + ∀ x : σ → ℤ, + (∃ γ ∈ Γ, f x = rR (fun j => (x j : ZMod M)) * γ) ∧ + (∃ γ ∈ Γ, f x = γ * rL (fun j => (x j : ZMod M))) := by + classical + let lift : (σ → ZMod M) → σ → ℤ := fun c j => Classical.choose (ZMod.intCast_surjective (c j)) + have hlift (c : σ → ZMod M) (j : σ) : (lift c j : ZMod M) = c j := + Classical.choose_spec (ZMod.intCast_surjective (c j)) + choose rR hrR γR hγR heqR using fun c => (hrep (lift c)).1 + choose rL hrL γL hγL heqL using fun c => (hrep (lift c)).2 + refine ⟨rR, rL, fun c => ⟨hrR c, hrL c⟩, ?_⟩ + intro x + let c := fun j => (x j : ZMod M) + have hxy (j : σ) : (M : ℤ) ∣ x j - lift c j := + (ZMod.intCast_eq_intCast_iff_dvd_sub (lift c j) (x j) M).mp (hlift c j) + have h := hperiod x (lift c) hxy + have hR : (QuotientGroup.mk (f x) : G ⧸ Γ) = QuotientGroup.mk (rR c) := by + apply h.1.trans + rw [heqR c] + exact QuotientGroup.mk_mul_of_mem _ (hγR c) + have hL : (QuotientGroup.mk (f x)⁻¹ : G ⧸ Γ) = QuotientGroup.mk (rL c)⁻¹ := by + apply h.2.trans + rw [heqL c, mul_inv_rev] + exact QuotientGroup.mk_mul_of_mem _ (Γ.inv_mem (hγL c)) + constructor + · refine ⟨(rR c)⁻¹ * f x, QuotientGroup.eq.mp hR.symm, ?_⟩ + change f x = rR c * ((rR c)⁻¹ * f x) + group + · have hmem : rL c * (f x)⁻¹ ∈ Γ := by + simpa only [inv_inv] using QuotientGroup.eq.mp hL.symm + refine ⟨f x * (rL c)⁻¹, ?_, ?_⟩ + · simpa only [mul_inv_rev, inv_inv] using Γ.inv_mem hmem + · change f x = (f x * (rL c)⁻¹) * rL c + group + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_residue_class_right_lattice_factors {σ G : Type*} [Group G] + (Γ : Subgroup G) (f : (σ → ℤ) → G) (M : ℕ) (P : G → Prop) + (hperiod : ∀ x y : σ → ℤ, (∀ j, (M : ℤ) ∣ x j - y j) → + (QuotientGroup.mk (f x) : G ⧸ Γ) = QuotientGroup.mk (f y)) + (hrep : ∀ x : σ → ℤ, ∃ r : G, P r ∧ ∃ γ ∈ Γ, f x = r * γ) : + ∃ r : (σ → ZMod M) → G, + (∀ c, P (r c)) ∧ + ∀ x : σ → ℤ, ∃ γ ∈ Γ, + f x = r (fun j => (x j : ZMod M)) * γ := by + classical + let lift : (σ → ZMod M) → σ → ℤ := + fun c j => Classical.choose (ZMod.intCast_surjective (c j)) + have hlift (c : σ → ZMod M) (j : σ) : (lift c j : ZMod M) = c j := + Classical.choose_spec (ZMod.intCast_surjective (c j)) + choose r hr γ hγ heq using fun c => hrep (lift c) + refine ⟨r, hr, ?_⟩ + intro x + let c := fun j => (x j : ZMod M) + have hxy (j : σ) : (M : ℤ) ∣ x j - lift c j := + (ZMod.intCast_eq_intCast_iff_dvd_sub (lift c j) (x j) M).mp (hlift c j) + have hR : (QuotientGroup.mk (f x) : G ⧸ Γ) = QuotientGroup.mk (r c) := by + apply (hperiod x (lift c) hxy).trans + rw [heq c] + exact QuotientGroup.mk_mul_of_mem _ (hγ c) + refine ⟨(r c)⁻¹ * f x, QuotientGroup.eq.mp hR.symm, ?_⟩ + change f x = r c * ((r c)⁻¹ * f x) + group + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +theorem exists_native_residue_representatives (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) (w : σ → ℕ), + (∀ i, 0 < w i) → ∀ (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (Fintype.card σ : ℝ) ≤ p → ∀ (q : ℕ), 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ M m : ℕ, 0 < M ∧ 0 < m ∧ + (M : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∀ g : (D.filtration.realification.adaptedPolynomialFiltration w).Group, + D.filtration.PolynomialRationalGrid D.basis w q g → + ∃ rR rL : (σ → ZMod M) → D.RealGroup, + (∀ c, (∀ i, |(D.basis.baseChange ℝ).repr (rR c).coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (D.basis.baseChange ℝ).equivFun (rR c).coord ∈ realDenominatorGrid m ∧ + (∀ i, |(D.basis.baseChange ℝ).repr (rL c).coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (D.basis.baseChange ℝ).equivFun (rL c).coord ∈ realDenominatorGrid m) ∧ + ∀ x : σ → ℤ, + (∃ γ ∈ D.realLattice, + D.filtration.adaptedPolynomialRealValueHom w (fun j => (x j : ℝ)) g = + rR (fun j => (x j : ZMod M)) * γ) ∧ + (∃ γ ∈ D.realLattice, + D.filtration.adaptedPolynomialRealValueHom w (fun j => (x j : ℝ)) g = + γ * rL (fun j => (x j : ZMod M))) := by + obtain ⟨a, _, hperiod⟩ := exists_native_rational_period s + obtain ⟨b, _, hrep⟩ := exists_native_rational_representatives s + let P : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + (Polynomial.X + Polynomial.C b) ^ b + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ _ _ _ d D w hw p hp hD hσ q hq hqp + obtain ⟨M, hM, hMb, hper⟩ := hperiod D w hw p hp hD hσ q hq hqp + obtain ⟨m, hm, hmb, hreps⟩ := hrep D p hp hD q hq hqp + have hsum : (p + a) ^ a + (p + b) ^ b ≤ (p + C) ^ C := by + simpa [P, Polynomial.eval₂_pow] using hbudget p hp + have haC : (p + a) ^ a ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (add_nonneg hp (Nat.cast_nonneg b)) _)).trans hsum + have hbC : (p + b) ^ b ≤ (p + C) ^ C := + (le_add_of_nonneg_left (pow_nonneg (add_nonneg hp (Nat.cast_nonneg a)) _)).trans hsum + refine ⟨M, m, hM, hm, hMb.trans (Real.exp_le_exp.mpr haC), hmb.trans (Real.exp_le_exp.mpr hbC), ?_⟩ + intro g hg + let f := fun x : σ → ℤ => D.filtration.adaptedPolynomialRealValueHom w (fun j => (x j : ℝ)) g + let A := fun r : D.RealGroup => + (∀ i, |(D.basis.baseChange ℝ).repr r.coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (D.basis.baseChange ℝ).equivFun r.coord ∈ realDenominatorGrid m + have hf (x : σ → ℤ) : + (∃ r : D.RealGroup, A r ∧ ∃ γ ∈ D.realLattice, f x = r * γ) ∧ + (∃ r : D.RealGroup, A r ∧ ∃ γ ∈ D.realLattice, f x = γ * r) := by + obtain ⟨⟨rR, hR, hRgrid, γR, hγR, heqR⟩, ⟨rL, hL, hLgrid, γL, hγL, heqL⟩⟩ := + hreps (f x) (D.filtration.polynomialRationalGrid_value D.basis w q g hg x) + exact ⟨⟨rR, ⟨fun i => (hR i).trans (Real.exp_le_exp.mpr hbC), hRgrid⟩, γR, hγR, heqR⟩, + ⟨rL, ⟨fun i => (hL i).trans (Real.exp_le_exp.mpr hbC), hLgrid⟩, γL, hγL, heqL⟩⟩ + obtain ⟨rR, rL, hA, heq⟩ := exists_residue_class_lattice_factors D.realLattice f M A (hper g hg) hf + exact ⟨rR, rL, fun c => ⟨(hA c).1.1, (hA c).1.2, (hA c).2.1, (hA c).2.2⟩, heq⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +theorem exists_native_marked_kernel_residue_representatives (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ κ L T : Type*} [Fintype σ] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d t : ℕ} (D : RationalFilteredNilmanifold L s d) + (F : NilpotentLieFiltration T t) (c : Basis κ ℚ T) (φ : L →ₗ⁅ℚ⁆ T) + (w : σ → ℕ), (∀ i, 0 < w i) → ∀ p : ℝ, + 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card σ : ℝ) ≤ p → + (Fintype.card κ : ℝ) ≤ p → + (∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p) → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ M m : ℕ, 0 < M ∧ 0 < m ∧ + (M : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∀ g : (D.filtration.realification.adaptedPolynomialFiltration w).Group, + D.filtration.PolynomialRationalGrid D.basis w q g → + (∀ x : σ → ℤ, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ + (D.filtration.adaptedPolynomialRealValueHom w (fun j => (x j : ℝ)) g) = 1) → + ∃ r : (σ → ZMod M) → D.RealGroup, + (∀ a, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ (r a) = 1 ∧ + (∀ i, |(D.basis.baseChange ℝ).repr (r a).coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (D.basis.baseChange ℝ).equivFun (r a).coord ∈ realDenominatorGrid m) ∧ + ∀ x : σ → ℤ, ∃ γ ∈ D.realLattice, + D.filtration.adaptedPolynomialRealValueHom w (fun j => (x j : ℝ)) g = + r (fun j => (x j : ZMod M)) * γ := by + obtain ⟨a, _, hperiod⟩ := exists_native_rational_period s + obtain ⟨b, _, hrep⟩ := exists_native_marked_kernel_representatives s + let P : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + + (Polynomial.X + Polynomial.C b) ^ b + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ κ L T _ _ _ _ _ _ _ _ _ _ d t D F c φ w hw p hp hD hσ hκ hφ q hq hqp + obtain ⟨M, hM, hMb, hper⟩ := hperiod D w hw p hp hD hσ q hq hqp + obtain ⟨m, hm, hmb, hreps⟩ := hrep D c φ p hp hD hκ hφ q hq hqp + have hsum : (p + a) ^ a + (p + b) ^ b ≤ (p + C) ^ C := by + simpa [P, Polynomial.eval₂_pow] using hbudget p hp + have haC : (p + a) ^ a ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (add_nonneg hp (Nat.cast_nonneg b)) _)).trans hsum + have hbC : (p + b) ^ b ≤ (p + C) ^ C := + (le_add_of_nonneg_left (pow_nonneg (add_nonneg hp (Nat.cast_nonneg a)) _)).trans hsum + refine ⟨M, m, hM, hm, hMb.trans (Real.exp_le_exp.mpr haC), + hmb.trans (Real.exp_le_exp.mpr hbC), ?_⟩ + intro g hg hmark + let f := fun x : σ → ℤ => D.filtration.adaptedPolynomialRealValueHom w (fun j => (x j : ℝ)) g + let A := fun r : D.RealGroup => + realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ r = 1 ∧ + (∀ i, |(D.basis.baseChange ℝ).repr r.coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (D.basis.baseChange ℝ).equivFun r.coord ∈ realDenominatorGrid m + have hf (x : σ → ℤ) : ∃ r : D.RealGroup, A r ∧ ∃ γ ∈ D.realLattice, f x = r * γ := by + have hxK := (mem_realificationSubgroup_ker_iff + (hM := F.lowerCentralSeries_eq_bot) φ (f x)).mpr (hmark x) + obtain ⟨r, hrK, hr, hrgrid, γ, hγ, hfac⟩ := hreps (f x) hxK + (D.filtration.polynomialRationalGrid_value D.basis w q g hg x) + refine ⟨r, ⟨?_, fun i => (hr i).trans (Real.exp_le_exp.mpr hbC), hrgrid⟩, γ, hγ, hfac⟩ + exact (mem_realificationSubgroup_ker_iff (hM := F.lowerCentralSeries_eq_bot) φ r).mp hrK + obtain ⟨r, hr, hfac⟩ := exists_residue_class_right_lattice_factors D.realLattice f M A + (fun x y hxy => (hper g hg x y hxy).1) hf + exact ⟨r, hr, hfac⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +universe u + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct BigOperators NNReal + +variable {ι : Type u} [Fintype ι] [DecidableEq ι] {L : ι → Type u} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) (s + 1) (d i)) (a : ι) + (W : LieSubalgebra ℚ (pi D).filtration.AssociatedGraded) {e n : ℕ} + (E : RationalFilteredNilmanifold ((pi D).filtration.gradedRefiltrationSubalgebra W) (s + 1) e) + (Q : RationalFilteredNilmanifold + (((pi D).filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n) + [TopologicalSpace (ℝ ⊗[ℚ] L a)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L a)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L a)] [T2Space (ℝ ⊗[ℚ] L a)] + +noncomputable def RefilteredResidueExpansionSpec + (p : ℝ) (q r P : ℕ) (cost : ℝ) : Prop := + let H := (pi D).filtration.gradedRefiltrationSubalgebra W + let I₀ := {i : ι // i ≠ a} + let Z₀ := pi (fun i : I₀ => D i.val) + letI := moduleTopology ℝ (ℝ ⊗[ℚ] (H ⧸ E.filtration.layerIdeal (s + 1))) + letI := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (H ⧸ E.filtration.layerIdeal (s + 1))) + letI := realification_moduleTopology_t2 Q.basis + letI := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i : I₀, L i.val)) + letI := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (∀ i : I₀, L i.val)) + letI := realification_moduleTopology_t2 Z₀.basis + ∃ Q' : RationalFilteredNilmanifold (H ⧸ E.filtration.layerIdeal (s + 1)) s n, + Q'.filtration = Q.filtration ∧ Q'.basis = Q.basis ∧ Q'.lattice ≤ Q.lattice ∧ + Q'.GeometryComplexityLE cost ∧ + ∃ Z : RationalFilteredNilmanifold (∀ i : I₀, L i.val) (s + 1) + (Fintype.card (Σ i : I₀, Fin (d i.val))), + Z.filtration = Z₀.filtration ∧ Z.basis = Z₀.basis ∧ Z.lattice ≤ Z₀.lattice ∧ + Z.GeometryComplexityLE cost ∧ + letI := Z.metricSpace + let w := fun _ : Unit => 1 + let φ := realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := (D a).filtration.lowerCentralSeries_eq_bot) (refilteredComponentMap D W a) + let ψ := realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := Z.filtration.lowerCentralSeries_eq_bot) + (liePiMap (fun i : I₀ => refilteredComponentMap D W i.val)) + ∀ {J₀ : Type u} (freq : J₀ → ∀ i, L i →ₗ[ℚ] ℚ), + (∀ j x, x ∈ (pi D).filtration.realGradedRefiltrationLayer W (s + 1) → + realifyFunctional (piFrequency (freq j)) x = 0) → + ∀ (N : ℕ) [NeZero N] {I J : Type u} [Fintype I] [Fintype J] + (A : I → ZMod N → ℝ) (B : J → ZMod N → ℝ) (label : I → ZMod P) {ρ η : ℝ}, + 0 < ρ → 0 ≤ η → + (∀ i x, 0 ≤ A i x) → (∀ j x, 0 ≤ B j x) → + (∀ x, ∑ i, A i x = 1) → (∀ x, ∑ j, B j x = 1) → + (∀ i x, 0 < A i x → (x.val : ZMod P) = label i) → + (∀ i x y, 0 < A i x → 0 < A i y → + dist (ZMod.toAddCircle x) (ZMod.toAddCircle y) ≤ ρ) → + ∀ (S : ZMod N → (D a).Niltest w), + (∀ h, (S h).ComplexityLE p) → (∀ h, (S h).UnitIntervalValued) → + (∀ h z, z ∈ (D a).filtration.realification.subgroup (s + 1) → + (∀ j, realifyFunctional (freq j a) z.coord = 0) → + ∀ x, (S h).observable (z • x) = (S h).observable x) → + ∀ (slow middle rat : ZMod N → ((D a).filtration.realification.adaptedPolynomialFiltration w).Group) + (κ : ZMod N → (D a).RealGroup) + (g : ZMod N → E.filtration.realification.PolynomialOrbit w), + (∀ h, κ h ∈ (D a).realLattice) → + (∀ h, slow h * middle h * rat h * (D a).filtration.realification.adaptedConstantGroupHom w (κ h) = + ⟨⟨(S h).orbit.log, (S h).orbit.property⟩⟩) → + (∀ h, (D a).filtration.PolynomialSlowBound (D a).basis w + (fun _ => (N : ℝ)) (Real.exp ((p + 2) ^ r)) (slow h)) → + (∀ h, (D a).filtration.PolynomialRationalGrid (D a).basis w q (rat h)) → + (∀ h x, (D a).filtration.adaptedPolynomialRealValueHom w (fun i => (x i : ℝ)) (middle h) = + φ (E.filtration.realification.polynomialOrbitEval w x (g h))) → + (∀ i j h x y, x ∉ cyclicWrapExceptional h ρ → y ∉ cyclicWrapExceptional h ρ → + 0 < A i x * B j (x + h) → 0 < A i y * B j (y + h) → + dist (QuotientGroup.mk (ψ (E.filtration.realification.polynomialOrbitEval w + (fun _ => (x.val : ℤ)) (g h))) : Z.Space) + (QuotientGroup.mk (ψ (E.filtration.realification.polynomialOrbitEval w + (fun _ => (y.val : ℤ)) (g h)))) ≤ η) → + ∃ U : I → J → ZMod N → Q'.Niltest w, + (∀ i j h, (U i j h).UnitIntervalValued) ∧ + (∀ i j h, (U i j h).ComplexityLE (cost + 2)) ∧ + (∀ i j h, (¬∃ x, x ∉ cyclicWrapExceptional h ρ ∧ 0 < A i x * B j (x + h)) → + ∀ x, (U i j h).eval x = 0) ∧ + ∃ err : ZMod N → ZMod N → ℝ, + (∀ h x, ((S h).evalCyclic N (fun _ => x)).re = + (∑ i, ∑ j, A i x * B j (x + h) * ((U i j h).evalCyclic N (fun _ => x)).re) + err h x) ∧ + ∀ h, (𝔼 x, |err h x|) ≤ Real.exp cost * (ρ + η) + 6 * ρ + 3 / N + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RegularizedAffineComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RegularizedAffineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8e0f7913d169f3a4c2bf4e5fc50fbfd37f3f00f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RegularizedAffineComparison.lean @@ -0,0 +1,736 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformRegularizedProfileComparison +import OAI.Combinatorics.Progressions.Polynomial.RawAffinePolynomialJet + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem nonprincipalDilation_width_pos {C B K : Type*} [Fintype C] [Fintype B] + (e : C → K →₀ ℕ) (principal : B → K →₀ ℕ) {t : ℝ} (ht : 0 < t) + (w : C → ℝ) (hw : ∀ j, 0 < w j) (j : C) : + 0 < nonprincipalDilation e principal t j*w j := + mul_pos (nonprincipalDilation_pos e principal ht j) (hw j) + +theorem nonprincipalDilation_width_lower {C B K : Type*} [Fintype C] [Fintype B] + (e : C → K →₀ ℕ) (principal : B → K →₀ ℕ) {t δ : ℝ} + (ht : 0 ≤ t) (ht1 : t ≤ 1) (w : C → ℝ) (hw : ∀ j, 0 ≤ w j) + (hδ : ∀ j, δ ≤ w j) (j : C) : + t*δ ≤ nonprincipalDilation e principal t j*w j := + (mul_le_mul_of_nonneg_left (hδ j) ht).trans + (mul_le_mul_of_nonneg_right (nonprincipalDilation_lower e principal ht1 j) (hw j)) + +theorem nonprincipalDilation_profile_support {C B K : Type*} [Fintype C] [Fintype B] + (e : C → K →₀ ℕ) (principal : B → K →₀ ℕ) {t R : ℝ} (ht : 0 < t) (ht1 : t ≤ 1) + (c w : C → ℝ) (hw : ∀ j, 0 ≤ w j) (hsupport : ∀ j, |c j|+w j ≤ R) (j : C) : + |nonprincipalDilation e principal t j*c j| + nonprincipalDilation e principal t j*w j ≤ R := by + rw [abs_mul, abs_of_pos (nonprincipalDilation_pos e principal ht j), ← mul_add] + exact (mul_le_of_le_one_left (add_nonneg (abs_nonneg _) (hw j)) + (nonprincipalDilation_le_one e principal ht1 j)).trans (hsupport j) + +theorem affineAllowance_nonprincipal_sum_le {C B K : Type*} [Fintype C] [Fintype B] + (e : C → K →₀ ℕ) (principal : B → K →₀ ℕ) (c w : C → ℝ) : + (∑ j ∈ nonprincipalCoefficientSlots e principal, |affineCoefficientAllowance (c j) (w j)|) ≤ + ∑ j, affineCoefficientAllowance (c j) (w j) := by + simp only [abs_of_pos (affineCoefficientAllowance_pos _ _)] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) + (fun j _ _ => (affineCoefficientAllowance_pos (c j) (w j)).le) + +theorem affinePrincipal_sum_le {C B : Type*} [Fintype B] + (index : B → C) (c w r : C → ℝ) (hr : ∀ j, |r j| ≤ 1) : + (∑ b, |c (index b)+w (index b)*r (index b)|) ≤ ∑ b, (|c (index b)|+|w (index b)|) := + Finset.sum_le_sum (fun b _ => affineParameter_abs_upper _ _ _ (hr (index b))) + +theorem affineConstantCoefficient_measurable {Ω C K : Type*} [MeasurableSpace Ω] [Fintype C] + (e : C → K →₀ ℕ) (c w : C → ℝ) (r : Ω → C → ℝ) + (hr : ∀ j, Measurable (fun ω => r ω j)) : + Measurable (fun ω => (monomialArrayPolynomial e (fun j => c j+w j*r ω j)).coeff 0) := by + classical + simp only [monomialArrayPolynomial, MvPolynomial.coeff_sum, MvPolynomial.coeff_monomial] + apply Finset.measurable_sum + intro j _ + split_ifs <;> fun_prop + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def canonicalAffineRawArray {D G α : Type*} [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (Q : D → ℝ) (T : SamplerTupleIndex G B h → ℝ) (c w r : ∀ d, C d → ℝ) + (sets : ∀ d, O d → Finset α) (tuple : Finset α → SamplerTupleIndex G B h → ℝ) : + (Σ d, O d) → ℝ := + let p := fun d => scaledAffinePolynomial (e d) (Q d) T (c d) (w d) (r d) + rawProductArrayJet h sets + (fun d => fixedNonprincipalExponents (monomialExponentSet (e d)) (canonicalPrincipalExponent h d)) + (fun _ m => m) (fun d b v => .inr ⟨d, b, v⟩) + (fun d b => (p d).coeff (canonicalPrincipalExponent h d b)) + (fun d m => (p d).coeff m) (fun d => (p d).coeff 0) Q tuple + +theorem canonicalAffineRawArray_eq {D G α : Type*} [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (Q : D → ℝ) (T : SamplerTupleIndex G B h → ℝ) (c w r : ∀ d, C d → ℝ) + (sets : ∀ d, O d → Finset α) (tuple : Finset α → SamplerTupleIndex G B h → ℝ) : + canonicalAffineRawArray h e Q T c w r sets tuple = + fun o => rawAffinePolynomialJet (e o.1) (Q o.1) T tuple (sets o.1) (c o.1) (w o.1) (r o.1) o.2 := by + funext o + exact canonicalRawJet_of_support h hh + (fun d => scaledAffinePolynomial (e d) (Q d) T (c d) (w d) (r d)) + (fun d => monomialExponentSet (e d)) + (fun d => scaledAffinePolynomial_support (e d) (Q d) T (c d) (w d) (r d)) sets Q tuple o + +theorem scaledAffinePolynomial_principal_coefficient {D G : Type*} + {B C : D → Type*} [∀ d, Fintype (C d)] + (h : D → ℕ) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → C d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (Q : D → ℝ) (T : SamplerTupleIndex G B h → ℝ) (c w r : ∀ d, C d → ℝ) (d : D) (b : B d) : + (scaledAffinePolynomial (e d) (Q d) T (c d) (w d) (r d)).coeff (canonicalPrincipalExponent h d b) = + scaledPrincipalCoefficient h Q T (fun d b v => .inr ⟨d, b, v⟩) + (fun d b => c d (index d b)+w d (index d b)*r d (index d b)) d b := by + rw [← hindex d b, scaledAffinePolynomial_coeff (e d) (he d), hindex d b, + monomialScale_canonicalPrincipal] + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem canonicalAffineRawArray_eq_jointUnitMap {D G Z α : Type*} [Fintype D] + [Fintype α] [DecidableEq α] {B O J N : D → Type*} + [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (sets : ∀ d, O d → Finset α) + (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) (T : SamplerTupleIndex G B h → ℝ) + (hT : ∀ k, T k ≠ 0) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (extra : G → Option α → Z) (z : Z → ℝ) (x : JointBlockParameter B h α → ℝ) + (hkernel : ∀ d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) z x) (sets d)) + (c w r : ∀ d, J d ⊕ N d → ℝ) : + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + canonicalAffineRawArray h (fun d => Sum.elim (eK d) (eN d)) Q T c w r sets + (rawCanonicalCubeTuple extra T z (jointCubeScale h (fun i => T (.inr i)) x)) = + fun o => jointAffineJetUnitMap s E F eN (canonicalTupleInput extra) z sets c w x r o.1 o.2 := by + dsimp only + rw [canonicalAffineRawArray_eq h hh] + funext o + exact congrFun (rawAffinePolynomialJet_eq_affine (M o.1) (s o.1) (hM o.1) (S o.1) (hS o.1) (hQ o.1) + (eK o.1) (eN o.1) (canonicalTupleInput extra) z (sets o.1) x (hkernel o.1) T hT + (rawCanonicalCubeTuple extra T z (jointCubeScale h (fun i => T (.inr i)) x)) + (fun t k => rawCanonicalCubeTuple_rescale extra T z x t k) (c o.1) (w o.1) (r o.1)) o.2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem canonicalAffineRawArray_normalized {D G Z α : Type*} [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (Q : D → ℝ) (T : SamplerTupleIndex G B h → ℝ) + (hQ : ∀ d, Q d ≠ 0) (hT : ∀ k, T k ≠ 0) + (c w r : ∀ d, C d → ℝ) (sets : ∀ d, O d → Finset α) + (extra : G → Option α → Z) (z : Z → ℝ) (x : JointBlockParameter B h α → ℝ) : + canonicalAffineRawArray h e Q T c w r sets + (rawCanonicalCubeTuple extra T z (jointCubeScale h (fun i => T (.inr i)) x)) = + fun o => booleanCoefficient (fun vertex => + MvPolynomial.eval (normalizedCubeTuple (canonicalTupleInput extra) z x vertex) + (monomialArrayPolynomial (e o.1) (fun j => c o.1 j+w o.1 j*r o.1 j))) (sets o.1 o.2) := by + rw [canonicalAffineRawArray_eq h hh] + funext o + unfold rawAffinePolynomialJet scaledAffinePolynomial + have ht : rawCanonicalCubeTuple extra T z (jointCubeScale h (fun i => T (.inr i)) x) = + fun vertex k => T k*normalizedCubeTuple (canonicalTupleInput extra) z x vertex k := + funext (fun vertex => funext (fun k => rawCanonicalCubeTuple_rescale extra T z x vertex k)) + rw [ht] + exact monomialArrayPolynomial_jet_rescale (e o.1) _ T _ (Q o.1) (hQ o.1) hT _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem canonicalAffineRawArray_joint_law {D G Z α : Type*} [Fintype D] + [Fintype α] [DecidableEq α] {B O J N : D → Type*} + [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (sets : ∀ d, O d → Finset α) + (M : ∀ d, Matrix (O d) (J d) ℤ) (s : ∀ d, O d ↪ J d) + (hM : ∀ d, ((M d).submatrix id (s d)).det ≠ 0) + (S : ∀ d, J d → ℝ) (hS : ∀ d j, 0 < S d j) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) (T : SamplerTupleIndex G B h → ℝ) + (hT : ∀ k, T k ≠ 0) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (extra : G → Option α → Z) (z : Z → ℝ) (x : JointBlockParameter B h α → ℝ) + (hkernel : ∀ d, normalizedIntegerColumns (M d) (S d) (fun _ => Q d) = + realJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) + (normalizedCubeTuple (canonicalTupleInput extra) z x) (sets d)) + (c w : ∀ d, J d ⊕ N d → ℝ) (hw : ∀ d j, 0 < w d j) + (R : D → ℝ≥0) (hsupport : ∀ d j, |c d j|+w d j ≤ R d) : + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + (jointUnitCoefficientSource J N).map + (fun r => sigmaAxisCoordinates O (canonicalAffineRawArray h (fun d => Sum.elim (eK d) (eN d)) + Q T c w r sets (rawCanonicalCubeTuple extra T z (jointCubeScale h (fun i => T (.inr i)) x)))) = + realDensityMeasure volume (jointAffineJetDensity s E F eN (canonicalTupleInput extra) z sets c w x) := by + dsimp only + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hM d) + (fun j => S d (s d j)) (fun _ => Q d) (fun j => hS d (s d j)) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + calc + _ = (jointUnitCoefficientSource J N).map + (jointAffineJetUnitMap s E F eN (canonicalTupleInput extra) z sets c w x) := by + congr 1 + funext r + exact congrArg (sigmaAxisCoordinates O) + (canonicalAffineRawArray_eq_jointUnitMap h hh sets M s hM S hS Q hQ T hT eK eN extra z x hkernel c w r) + _ = _ := jointAffineJetDensity_unit_law s E F eN (canonicalTupleInput extra) z sets c w hw R hsupport x + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem rawCanonicalJet_eq_smallAffineArray {D G Z α : Type*} [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → C d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w r : ∀ d, C d → ℝ) (sets : ∀ d, O d → Finset α) + (extra : G → Option α → Z) (Q : D → ℝ) (T : SamplerTupleIndex G B h → ℝ) + (hQ : ∀ d, Q d ≠ 0) (hT : ∀ k, T k ≠ 0) + (t : ℝ) (z : Z → ℝ) (x : JointBlockParameter B h α → ℝ) : + rawCanonicalJet h (fun d b => c d (index d b)+w d (index d b)*r d (index d b)) sets + (fun d => nonprincipalCoefficientSlots (e d) (canonicalPrincipalExponent h d)) + (fun d j => affineCoefficientAllowance (c d j) (w d j)) e + affineAuxiliaryCoefficient (affineAuxiliaryExtra extra) Q T + (fun d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r d j)).coeff 0) + t (affineAuxiliaryVariables c w z r) (jointCubeScale h (fun i => T (.inr i)) x) = + canonicalAffineRawArray h e Q T + (fun d j => nonprincipalDilation (e d) (canonicalPrincipalExponent h d) t j*c d j) + (fun d j => nonprincipalDilation (e d) (canonicalPrincipalExponent h d) t j*w d j) + r sets (rawCanonicalCubeTuple extra T z (jointCubeScale h (fun i => T (.inr i)) x)) := by + rw [rawCanonicalJet_normalized_polynomial h _ sets _ _ e _ _ Q T _ hQ hT, + canonicalAffineRawArray_normalized h hh e Q T hQ hT] + funext o + congr 1 + funext vertex + rw [rawProductArrayPolynomial_affine_auxiliary h hh e he index hindex] + have hv : normalizedCubeTuple (canonicalTupleInput (affineAuxiliaryExtra (C := C) extra)) + (affineAuxiliaryVariables c w z r) x vertex = + normalizedCubeTuple (canonicalTupleInput extra) z x vertex := + funext (fun k => normalizedCubeTuple_affineAuxiliary h extra c w z r x vertex k) + rw [hv] + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def smallAffineSourceOutput {Ω D G Z α : Type*} [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (c w : ∀ d, C d → ℝ) (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ) (t : ℝ) + (z : Ω → Z → ℝ) (r : Ω → ∀ d, C d → ℝ) + (p : Ω × (JointBlockParameter B h α → ℝ)) : (Σ d, O d) → ℝ := + canonicalAffineRawArray h e (Q p.1) scale + (fun d j => nonprincipalDilation (e d) (canonicalPrincipalExponent h d) t j*c d j) + (fun d j => nonprincipalDilation (e d) (canonicalPrincipalExponent h d) t j*w d j) + (r p.1) sets (rawCanonicalCubeTuple extra scale (z p.1) p.2) + +theorem rawSourceOutput_eq_smallAffineSource {Ω D G Z α : Type*} [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → C d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, C d → ℝ) (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ) + (hQ : ∀ a d, Q a d ≠ 0) (hscale : ∀ k, scale k ≠ 0) + (t : ℝ) (z : Ω → Z → ℝ) (r : Ω → ∀ d, C d → ℝ) : + rawSourceOutput h (fun a d b => c d (index d b)+w d (index d b)*r a d (index d b)) sets + (fun d => nonprincipalCoefficientSlots (e d) (canonicalPrincipalExponent h d)) + (fun d j => affineCoefficientAllowance (c d j) (w d j)) e + affineAuxiliaryCoefficient (affineAuxiliaryExtra extra) Q scale + (fun a d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r a d j)).coeff 0) + t (fun a => affineAuxiliaryVariables c w (z a) (r a)) = + smallAffineSourceOutput h e c w sets extra Q scale t z r := by + let E := jointCubeScaleHomeomorph (α := α) h (fun i => scale (.inr i)) (fun i => hscale (.inr i)) + funext p + rcases E.surjective p.2 with ⟨x, hx⟩ + have hp : p = (p.1, jointCubeScale h (fun i => scale (.inr i)) x) := Prod.ext rfl hx.symm + rw [hp] + exact rawCanonicalJet_eq_smallAffineArray h hh e he index hindex c w (r p.1) sets extra + (Q p.1) scale (hQ p.1) hscale t (z p.1) x + +theorem smallAffineSourceOutput_measurable {Ω D G Z α : Type*} [MeasurableSpace Ω] + [Fintype D] [Fintype Z] [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → C d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, C d → ℝ) (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ) + (hQ : ∀ a d, Q a d ≠ 0) (hscale : ∀ k, scale k ≠ 0) (t : ℝ) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (r : Ω → ∀ d, C d → ℝ) (hr : ∀ d j, Measurable (fun a => r a d j)) : + Measurable (smallAffineSourceOutput h e c w sets extra Q scale t z r) := by + rw [← rawSourceOutput_eq_smallAffineSource h hh e he index hindex c w sets extra Q scale hQ hscale] + apply rawSourceOutput_measurable + · intro d b + exact measurable_const.add (measurable_const.mul (hr d (index d b))) + · exact hQ + · exact hscale + · intro d + exact affineConstantCoefficient_measurable (e d) (c d) (w d) (fun a => r a d) (hr d) + · exact affineAuxiliaryVariables_measurable c w z r hz hr + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +noncomputable def regularizedAffineIdealDensity {D G α : Type*} + [Fintype D] [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → C d) (c w : ∀ d, C d → ℝ) + (sets : ∀ d, O d → Finset α) (δ : ℝ≥0) (r : ∀ d, C d → ℝ) : ((Σ d, O d) → ℝ) → ℝ := + regularizedImageDensity (jointBooleanSource h) + (fun x => booleanConstantJet sets + (fun d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r d j)).coeff 0) + + jointBooleanSampler h (fun d b => c d (index d b)+w d (index d b)*r d (index d b)) sets x) δ + +theorem regularizedAffineIdealDensity_probability {D G α : Type*} + [Fintype D] [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → C d) (c w : ∀ d, C d → ℝ) + (sets : ∀ d, O d → Finset α) (δ : ℝ≥0) (hδ : 0 < δ) (r : ∀ d, C d → ℝ) : + (∀ x, 0 ≤ regularizedAffineIdealDensity h e index c w sets δ r x) ∧ + Integrable (regularizedAffineIdealDensity h e index c w sets δ r) ∧ + (∫ x, regularizedAffineIdealDensity h e index c w sets δ r x) = 1 := + regularizedImageDensity_probability (jointBooleanSource h) _ + (measurable_const.add (jointBooleanSampler_contDiff h _ sets).continuous.measurable) δ hδ + +theorem regularizedAffineIdealDensity_bounds {D G α : Type*} + [Fintype D] [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → C d) (c w : ∀ d, C d → ℝ) + (sets : ∀ d, O d → Finset α) (δ : ℝ≥0) (hδ : 0 < δ) (r : ∀ d, C d → ℝ) : + (∀ x, regularizedAffineIdealDensity h e index c w sets δ r x ∈ + Set.Icc (0 : ℝ) (δ⁻¹ ^ Fintype.card (Σ d, O d) : ℝ≥0)) ∧ + LipschitzWith (affineProductProfileLip (Σ d, O d) δ) + (regularizedAffineIdealDensity h e index c w sets δ r) := + regularizedImageDensity_bounds (jointBooleanSource h) _ + (measurable_const.add (jointBooleanSampler_contDiff h _ sets).continuous.measurable) δ hδ + +theorem regularizedAffineIdealDensity_measurable_comp {Ω D G α : Type*} [MeasurableSpace Ω] + [Fintype D] [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (index : ∀ d, B d → C d) (c w : ∀ d, C d → ℝ) + (sets : ∀ d, O d → Finset α) (δ : ℝ≥0) + (r : Ω → ∀ d, C d → ℝ) (hr : ∀ d j, Measurable (fun a => r a d j)) + (v : Ω → (Σ d, O d) → ℝ) (hv : Measurable v) : + Measurable (fun a => regularizedAffineIdealDensity h e index c w sets δ (r a) (v a)) := by + let : IsProbabilityMeasure (jointBooleanSource (B := B) (α := α) h) := jointBooleanSource_probability h + let U := fun p : Ω × (JointBlockParameter B h α → ℝ) => + booleanConstantJet sets + (fun d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r p.1 d j)).coeff 0) + + jointBooleanSampler h (fun d b => c d (index d b)+w d (index d b)*r p.1 d (index d b)) sets p.2 + have hb := booleanConstantJet_measurable_comp (Ω := Ω) sets + (fun a d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r a d j)).coeff 0) + (fun d => affineConstantCoefficient_measurable (e d) (c d) (w d) (fun a => r a d) (hr d)) + have hU : Measurable U := (hb.comp measurable_fst).add + (jointBooleanSampler_measurable_frozen (Ω := Ω) h sets + (fun a d b => c d (index d b)+w d (index d b)*r a d (index d b)) + (fun d b => measurable_const.add (measurable_const.mul (hr d (index d b))))) + have hm : Measurable (fun p : Ω × (JointBlockParameter B h α → ℝ) => + affineProductProfile (U p) (fun _ => (δ : ℝ)) (v p.1)) := + affineProductProfile_measurable_center U (fun p => v p.1) (fun _ => (δ : ℝ)) + (fun i => (measurable_pi_apply i).comp hU) + (fun i => (measurable_pi_apply i).comp (hv.comp measurable_fst)) + exact hm.stronglyMeasurable.integral_prod_right'.measurable + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem smallAffineSourceOutput_zero_rescale {Ω D G Z α : Type*} [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → C d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, C d → ℝ) (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ) + (hQ : ∀ a d, Q a d ≠ 0) (hscale : ∀ k, scale k ≠ 0) + (z : Ω → Z → ℝ) (r : Ω → ∀ d, C d → ℝ) (a : Ω) (x : JointBlockParameter B h α → ℝ) : + smallAffineSourceOutput h e c w sets extra Q scale 0 z r + (a, jointCubeScale h (fun i => scale (.inr i)) x) = + booleanConstantJet sets + (fun d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r a d j)).coeff 0) + + jointBooleanSampler h (fun d b => c d (index d b)+w d (index d b)*r a d (index d b)) sets x := by + rw [← rawSourceOutput_eq_smallAffineSource h hh e he index hindex c w sets extra Q scale hQ hscale] + unfold rawSourceOutput + rw [rawCanonicalJet_rescale] + exact canonicalScaledProductArrayJet_zero h _ sets _ _ e _ _ (Q a) scale _ (hQ a) hscale _ x + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff NNReal BigOperators + +theorem exists_small_affine_source_tolerance_with_scale + {Ω D G Z α Y : Type*} [MeasurableSpace Ω] [MeasurableSpace Y] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + [∀ d, Fintype (J d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → J d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d → ℝ) (r : Ω → ∀ d, J d → ℝ) + (hr : ∀ d j, Measurable (fun a => r a d j)) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (e d j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) : + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = booleanPerturbationScale (B := B) (O := O) (α := α) (AffineAuxiliaryIndex Z J) h c₀ C A T degree Csum Wsum ε ∧ + ∀ (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ), + (∀ a d, Q a d ≠ 0) → (∀ k, 0 < scale k) → + ∀ μ : Measure Ω, IsProbabilityMeasure μ → + (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → + (∀ᵐ a ∂μ, ∀ d j, |r a d j| ≤ 1) → + ∀ P : Ω × ((Σ d, O d) → ℝ) → Y, Measurable P → + ∀ φ : Y → ℝ, Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + |(∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale 0 z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))) - + ∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale t z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))| ≤ ε := by + classical + have hprincipal : ∀ d b, Measurable (fun a => c d (index d b)+w d (index d b)*r a d (index d b)) := + fun d b => measurable_const.add (measurable_const.mul (hr d (index d b))) + have hweights (d) : (∑ j ∈ nonprincipalCoefficientSlots (e d) (canonicalPrincipalExponent h d), + |affineCoefficientAllowance (c d j) (w d j)|) ≤ Wsum := + (affineAllowance_nonprincipal_sum_le (e d) (canonicalPrincipalExponent h d) (c d) (w d)).trans (hwsum d) + obtain ⟨t, ht, ht1, heq, hcomp⟩ := exists_raw_source_tolerance_with_scale (Y := Y) + (fun a d b => c d (index d b)+w d (index d b)*r a d (index d b)) hprincipal + (fun a => affineAuxiliaryVariables c w (z a) (r a)) (affineAuxiliaryVariables_measurable c w z r hz hr) + sets hsets h hh hcard block hblock c₀ C hc₀ hC ψ hψ hrange hzero hone A T hLip hTransition + (fun d => nonprincipalCoefficientSlots (e d) (canonicalPrincipalExponent h d)) + (fun d j => affineCoefficientAllowance (c d j) (w d j)) e affineAuxiliaryCoefficient + (affineAuxiliaryExtra extra) hdegree (fun d j _ => htaildegree d j) hCsum hWsum hweights hε + refine ⟨t, ht, ht1, heq, ?_⟩ + intro Q scale hQ hscale μ hμ hzb hrb P hP φ hφ hbound + have haux : ∀ᵐ a ∂μ, ∀ j, |affineAuxiliaryVariables c w (z a) (r a) j| ≤ 1 := by + filter_upwards [hzb, hrb] with a ha hR + exact affineAuxiliaryVariables_abs_le c w (z a) (r a) ha hR + have hlower : ∀ᵐ a ∂μ, ∀ d o, + c₀ d ≤ |c d (index d (block d o))+w d (index d (block d o))*r a d (index d (block d o))| := by + filter_upwards [hrb] with a ha d o + exact (hclow d o).trans (affineParameter_abs_lower _ _ _ (ha d _)) + have hupper : ∀ᵐ a ∂μ, ∀ d o, + |c d (index d (block d o))+w d (index d (block d o))*r a d (index d (block d o))| ≤ C d := by + filter_upwards [hrb] with a ha d o + exact (affineParameter_abs_upper _ _ _ (ha d _)).trans (hcup d o) + have hsum : ∀ᵐ a ∂μ, ∀ d, + (∑ b, |c d (index d b)+w d (index d b)*r a d (index d b)|) ≤ Csum := by + filter_upwards [hrb] with a ha d + exact (affinePrincipal_sum_le (index d) (c d) (w d) (r a d) (ha d)).trans (hcsum d) + have hcst : ∀ d, Measurable (fun a => + (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r a d j)).coeff 0) := + fun d => affineConstantCoefficient_measurable (e d) (c d) (w d) (fun a => r a d) (hr d) + have hresult := hcomp Q scale + (fun a d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r a d j)).coeff 0) + hQ hscale hcst μ hμ haux hlower hupper hsum P hP φ hφ hbound + rw [rawSourceOutput_eq_smallAffineSource h hh e he index hindex c w sets extra Q scale hQ + (fun k => (hscale k).ne') 0 z r, + rawSourceOutput_eq_smallAffineSource h hh e he index hindex c w sets extra Q scale hQ + (fun k => (hscale k).ne') t z r] at hresult + exact hresult + +theorem exists_small_affine_source_tolerance + {Ω D G Z α Y : Type*} [MeasurableSpace Ω] [MeasurableSpace Y] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] + [∀ d, Fintype (J d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → J d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d → ℝ) (r : Ω → ∀ d, J d → ℝ) + (hr : ∀ d j, Measurable (fun a => r a d j)) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (e d j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) : + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ∀ (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ), + (∀ a d, Q a d ≠ 0) → (∀ k, 0 < scale k) → + ∀ μ : Measure Ω, IsProbabilityMeasure μ → + (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → + (∀ᵐ a ∂μ, ∀ d j, |r a d j| ≤ 1) → + ∀ P : Ω × ((Σ d, O d) → ℝ) → Y, Measurable P → + ∀ φ : Y → ℝ, Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + |(∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale 0 z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))) - + ∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale t z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))| ≤ ε := by + obtain ⟨t, hpos, hone, _, herr⟩ := exists_small_affine_source_tolerance_with_scale (Y := Y) h hh e he index hindex c w r hr z hz sets hsets hcard block hblock + c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A T hLip hTransition extra + hdegree htaildegree hCsum hWsum hcsum hwsum hε + exact ⟨t, hpos, hone, herr⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +theorem smallAffineSourceOutput_zero_integral {Ω D G Z α : Type*} [MeasurableSpace Ω] + [Fintype D] [Fintype α] [DecidableEq α] + {B O C : D → Type*} [∀ d, Fintype (B d)] [∀ d, Fintype (C d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, C d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → C d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, C d → ℝ) (sets : ∀ d, O d → Finset α) (extra : G → Option α → Z) + (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ) + (hQ : ∀ a d, Q a d ≠ 0) (hscale : ∀ k, 0 < scale k) + (z : Ω → Z → ℝ) (r : Ω → ∀ d, C d → ℝ) (μ : Measure Ω) [SFinite μ] + (φ : Ω × ((Σ d, O d) → ℝ) → ℝ) : + (∫ p, φ (p.1, smallAffineSourceOutput h e c w sets extra Q scale 0 z r p) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))) = + ∫ p, φ (p.1, booleanConstantJet sets + (fun d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r p.1 d j)).coeff 0) + + jointBooleanSampler h (fun d b => c d (index d b)+w d (index d b)*r p.1 d (index d b)) sets p.2) + ∂μ.prod (jointBooleanSource h) := by + rw [scaledJointCubeSource_prod_integral h _ (fun i => hscale (.inr i))] + simp_rw [smallAffineSourceOutput_zero_rescale h hh e he index hindex c w sets extra Q scale hQ + (fun k => (hscale k).ne') z r] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ContDiff NNReal BigOperators + +theorem exists_regularized_affine_comparison_with_parameters + {Ω D G Z α Y : Type*} [MeasurableSpace Ω] [MeasurableSpace Y] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] [∀ d, Fintype (J d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → J d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d → ℝ) (r : Ω → ∀ d, J d → ℝ) + (hr : ∀ d j, Measurable (fun a => r a d j)) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (e d j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) : + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ) = booleanRegularizationRadius (B := B) (O := O) (α := α) h c₀ C A T (ε/2) ∧ + ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + t = booleanPerturbationScale (B := B) (O := O) (α := α) (AffineAuxiliaryIndex Z J) h c₀ C A T degree Csum Wsum (ε/2) ∧ + ∀ (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ), + (∀ a d, Q a d ≠ 0) → (∀ k, 0 < scale k) → + ∀ μ : Measure Ω, IsProbabilityMeasure μ → + (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → (∀ᵐ a ∂μ, ∀ d j, |r a d j| ≤ 1) → + ∀ P : Ω × ((Σ d, O d) → ℝ) → Y, Measurable P → + ∀ φ : Y → ℝ, Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + |(∫ p, regularizedAffineIdealDensity h e index c w sets δ (r p.1) p.2*φ (P p) ∂μ.prod volume) - + ∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale t z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))| ≤ ε := by + obtain ⟨δ, hδ, hδ1, hδeq, hreg⟩ := exists_retained_boolean_regularization_with_radius (Ω := Ω) h hh sets hsets hcard block hblock + c₀ C hc₀ hC ψ hψ hrange hzero hone A T hLip hTransition (half_pos hε) + obtain ⟨t, ht, ht1, hteq, hraw⟩ := exists_small_affine_source_tolerance_with_scale (Y := Y) h hh e he index hindex c w r hr z hz + sets hsets hcard block hblock c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A T hLip hTransition + extra hdegree htaildegree hCsum hWsum hcsum hwsum (half_pos hε) + refine ⟨δ, hδ, hδ1, hδeq, t, ht, ht1, hteq, ?_⟩ + intro Q scale hQ hscale μ hμ hzb hrb P hP φ hφ hbound + let : IsProbabilityMeasure μ := hμ + let cp := fun a d b => c d (index d b)+w d (index d b)*r a d (index d b) + let b := fun a => booleanConstantJet sets + (fun d => (monomialArrayPolynomial (e d) (fun j => c d j+w d j*r a d j)).coeff 0) + have hcp : ∀ d j, Measurable (fun a => cp a d j) := + fun d j => measurable_const.add (measurable_const.mul (hr d (index d j))) + have hb : Measurable b := booleanConstantJet_measurable_comp sets _ + (fun d => affineConstantCoefficient_measurable (e d) (c d) (w d) (fun a => r a d) (hr d)) + have hgood : ∀ᵐ a ∂μ, (∀ d o, c₀ d ≤ |cp a d (block d o)|) ∧ (∀ d o, |cp a d (block d o)| ≤ C d) := by + filter_upwards [hrb] with a ha + exact ⟨fun d o => (hclow d o).trans (affineParameter_abs_lower _ _ _ (ha d _)), + fun d o => (affineParameter_abs_upper _ _ _ (ha d _)).trans (hcup d o)⟩ + have hreg' := hreg cp b hcp hb μ hμ hgood (fun p => φ (P p)) (hφ.comp hP) (fun p => hbound (P p)) + have hideal := smallAffineSourceOutput_zero_integral h hh e he index hindex c w sets extra Q scale + hQ hscale z r μ (fun p => φ (P p)) + change (∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale 0 z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))) = + (∫ p, φ (P (p.1, b p.1+jointBooleanSampler h (cp p.1) sets p.2)) ∂μ.prod (jointBooleanSource h)) at hideal + rw [← hideal] at hreg' + have hraw' := hraw Q scale hQ hscale μ hμ hzb hrb P hP φ hφ hbound + have htri := abs_sub_le + (∫ p, regularizedAffineIdealDensity h e index c w sets δ (r p.1) p.2*φ (P p) ∂μ.prod volume) + (∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale 0 z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))) + (∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale t z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))) + change |(∫ p, regularizedAffineIdealDensity h e index c w sets δ (r p.1) p.2*φ (P p) ∂μ.prod volume) - + (∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale 0 z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i))))| ≤ ε/2 at hreg' + linarith + +theorem exists_regularized_affine_comparison + {Ω D G Z α Y : Type*} [MeasurableSpace Ω] [MeasurableSpace Y] + [Fintype D] [DecidableEq D] [Fintype Z] [DecidableEq Z] [Fintype α] [DecidableEq α] + {B O J : D → Type*} [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] + [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] [∀ d, Nonempty (O d)] [∀ d, Fintype (J d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (e : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (he : ∀ d, Function.Injective (e d)) (index : ∀ d, B d → J d) + (hindex : ∀ d b, e d (index d b) = canonicalPrincipalExponent h d b) + (c w : ∀ d, J d → ℝ) (r : Ω → ∀ d, J d → ℝ) + (hr : ∀ d j, Measurable (fun a => r a d j)) + (z : Ω → Z → ℝ) (hz : ∀ j, Measurable (fun a => z a j)) + (sets : ∀ d, O d → Finset α) (hsets : ∀ d, Function.Injective (sets d)) + (hcard : ∀ d o, (sets d o).card ≤ h d) + (block : ∀ d, O d → B d) (hblock : ∀ d, Function.Injective (block d)) + (c₀ C : D → ℝ) (hc₀ : ∀ d, 0 < c₀ d) (hC : ∀ d, 0 ≤ C d) + (hclow : ∀ d o, c₀ d ≤ |c d (index d (block d o))|-|w d (index d (block d o))|) + (hcup : ∀ d o, |c d (index d (block d o))|+|w d (index d (block d o))| ≤ C d) + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + (extra : G → Option α → Z) {degree : ℕ} (hdegree : ∀ d, h d ≤ degree) + (htaildegree : ∀ d j, (e d j).sum (fun _ n => n) ≤ degree) + {Csum Wsum : ℝ} (hCsum : 0 ≤ Csum) (hWsum : 0 ≤ Wsum) + (hcsum : ∀ d, (∑ b, (|c d (index d b)|+|w d (index d b)|)) ≤ Csum) + (hwsum : ∀ d, (∑ j, affineCoefficientAllowance (c d j) (w d j)) ≤ Wsum) + {ε : ℝ} (hε : 0 < ε) : + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ ∃ t : ℝ, 0 < t ∧ t ≤ 1 ∧ + ∀ (Q : Ω → D → ℝ) (scale : SamplerTupleIndex G B h → ℝ), + (∀ a d, Q a d ≠ 0) → (∀ k, 0 < scale k) → + ∀ μ : Measure Ω, IsProbabilityMeasure μ → + (∀ᵐ a ∂μ, ∀ j, |z a j| ≤ 1) → (∀ᵐ a ∂μ, ∀ d j, |r a d j| ≤ 1) → + ∀ P : Ω × ((Σ d, O d) → ℝ) → Y, Measurable P → + ∀ φ : Y → ℝ, Measurable φ → (∀ y, ‖φ y‖ ≤ 1) → + |(∫ p, regularizedAffineIdealDensity h e index c w sets δ (r p.1) p.2*φ (P p) ∂μ.prod volume) - + ∫ p, φ (P (p.1, smallAffineSourceOutput h e c w sets extra Q scale t z r p)) + ∂μ.prod (scaledJointCubeSource h (fun i => scale (.inr i)))| ≤ ε := by + obtain ⟨δ, hδ, hδ1, _, t, ht, ht1, _, herr⟩ := exists_regularized_affine_comparison_with_parameters (Ω := Ω) (Y := Y) h hh e he index hindex c w r hr z hz sets hsets hcard block hblock + c₀ C hc₀ hC hclow hcup ψ hψ hrange hzero hone A T hLip hTransition extra + hdegree htaildegree hCsum hWsum hcsum hwsum hε + exact ⟨δ, hδ, hδ1, t, ht, ht1, herr⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RelativePhysicalResiduePatch.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RelativePhysicalResiduePatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..56d27be59b3867a1761c394ce927d13823ed1262 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RelativePhysicalResiduePatch.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformPhysicalVisitBounds + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators + +variable {X : Type*} [Fintype X] [decX : DecidableEq X] + +theorem physicalResidue_reparamPatch_score {s d : ℕ} + (N H : X → ℕ) (lo a : X → ℤ) (M : ℕ) (hM : 0 < M) + (hbox : PhysicalSubbox (fun _ => 0) N lo H) + (hlen : ∀ i, 0 < residueIndexLength (lo i) (lo i + H i) M (a i)) + (f : (X → ℤ) → ℝ) (target : ℝ) (A : PolynomialPatch X s d) : + let S := ResidueBoxSlice.ofPhysicalResidue N H lo a M hM hbox hlen + relativePatchSliceScore S f target (S.reparamPatch A) = + (physicalResidueMean (fun x => + (((f x - target) * A.value (fun i => (x i : ℝ)) : ℝ) : ℂ)) lo H M a).re := by + classical + have hdec : decX = (fun a b => Classical.propDecidable (a = b)) := Subsingleton.elim _ _ + subst decX + intro S + let e := ResidueBoxSlice.ofPhysicalResidueEquiv N H lo a M hM hbox hlen + have he (t : ∀ i, Fin (S.length i)) (i : X) : + (e t i).val = ((S.point t i).val : ℤ) := + ResidueBoxSlice.ofPhysicalResidueEquiv_val N H lo a M hM hbox hlen t i + calc + _ = 𝔼 t : ∀ i, Fin (S.length i), + (f (fun i => ((S.point t i).val : ℤ)) - target) * + A.value (fun i => ((S.point t i).val : ℝ)) := by + unfold relativePatchSliceScore + apply Finset.expect_congr rfl + intro t _ + rw [ResidueBoxSlice.reparamPatch_value] + _ = 𝔼 x : IntegerResidueBox lo (fun i => lo i + H i) (fun _ => (M : ℤ)) a, + (f (fun i => (x i).val) - target) * + A.value (fun i => ((x i).val : ℝ)) := by + apply Fintype.expect_equiv e + intro t + simp only [he, Int.cast_natCast] + _ = _ := by + simp only [physicalResidueMean, Finset.expect_eq_sum_div_card, + ← Complex.ofReal_sum, ← Complex.ofReal_natCast, ← Complex.ofReal_div, + Complex.ofReal_re] + +theorem relativePatchSliceConclusion_of_physicalResidueMean {s d : ℕ} + (N : X → ℕ) (f : (X → ℤ) → ℝ) (A : PolynomialPatch X s d) + (lo : X → ℤ) (H : X → ℕ) (M : ℕ) (a : X → ℤ) (target cost : ℝ) + (hM : 0 < M) (hbox : PhysicalSubbox (fun _ => 0) N lo H) + (hlen : ∀ i, 0 < residueIndexLength (lo i) (lo i + H i) M (a i)) + (hcost : ResidueSliceLogCostLE N lo H M a cost) + (hcomplexity : relativePatchComplexity A ≤ cost) + (hscore : Real.exp (-cost) ≤ (physicalResidueMean (fun x => + (((f x - target) * A.value (fun i => (x i : ℝ)) : ℝ) : ℂ)) lo H M a).re) : + RelativePatchSliceConclusion s N f target d cost := by + let S := ResidueBoxSlice.ofPhysicalResidue N H lo a M hM hbox hlen + refine ⟨M, hM, S, d, S.reparamPatch A, hcost, le_rfl, hcomplexity, ?_⟩ + rw [physicalResidue_reparamPatch_score N H lo a M hM hbox hlen f target A] + exact hscore + +theorem relativePatchSliceConclusion_of_nonempty_physicalResidueMean {s d : ℕ} + (N : X → ℕ) (f : (X → ℤ) → ℝ) (A : PolynomialPatch X s d) + (lo : X → ℤ) (H : X → ℕ) (M : ℕ) (a : X → ℤ) (target cost : ℝ) + (hM : 0 < M) (hbox : PhysicalSubbox (fun _ => 0) N lo H) + (hne : Nonempty (IntegerResidueBox lo (fun i => lo i + H i) (fun _ => (M : ℤ)) a)) + (hcost : ResidueSliceLogCostLE N lo H M a cost) + (hcomplexity : relativePatchComplexity A ≤ cost) + (hscore : Real.exp (-cost) ≤ (physicalResidueMean (fun x => + (((f x - target) * A.value (fun i => (x i : ℝ)) : ℝ) : ℂ)) lo H M a).re) : + RelativePatchSliceConclusion s N f target d cost := by + obtain ⟨x⟩ := hne + have hlen i : 0 < residueIndexLength (lo i) (lo i + H i) M (a i) := by + rw [residueIndexLength_eq_card _ _ _ _ (Nat.cast_pos.mpr hM)] + exact Finset.card_pos.mpr ⟨(x i).val, (x i).property⟩ + exact relativePatchSliceConclusion_of_physicalResidueMean N f A lo H M a target cost + hM hbox hlen hcost hcomplexity hscore + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RelativeSliceAffineThreeFactorLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RelativeSliceAffineThreeFactorLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..5418d41fc9ad803b2989b63a1ea45c2b9059824b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RelativeSliceAffineThreeFactorLaw.lean @@ -0,0 +1,578 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedEnormousProfiles +import OAI.Combinatorics.Progressions.Estimates.FiniteFiberPMF +import OAI.Combinatorics.Progressions.Geometry.UniformDependentSubtypeCoordinates +import OAI.Combinatorics.Progressions.Geometry.UniformDependentSumCoordinates +import OAI.Combinatorics.Progressions.Probability.RelativeSliceFiniteLaw +import OAI.Combinatorics.Progressions.Probability.RelativeSliceParameterCellLaw + +namespace OAI + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators + +variable {X : Type*} [Fintype X] [DecidableEq X] +variable {keep : X → Prop} [DecidablePred keep] {N : X → ℕ} {q : ℕ} + +def fiberParameterLength + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) (i : X) : ℕ := + if hi : keep i then S.length ⟨i, hi⟩ else 1 + +def fiberParameterStart + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (fixed : {x // ¬keep x} → ℤ) (i : X) : ℤ := + if hi : keep i then (S.start ⟨i, hi⟩ : ℤ) else fixed ⟨i, hi⟩ + +def fiberParameterStride (i : X) : ℕ := if keep i then q else 0 + +omit [Fintype X] [DecidableEq X] in +theorem fiberParameterLength_pos + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (i : X) : 0 < S.fiberParameterLength i := by + unfold fiberParameterLength + split + · exact hlen _ + · exact Nat.zero_lt_one + +omit [Fintype X] [DecidableEq X] in +theorem fiberParameterLength_of_keep + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (i : X) (hi : keep i) : S.fiberParameterLength i = S.length ⟨i, hi⟩ := by + simp only [fiberParameterLength, dite_eq_left hi] + +omit [Fintype X] [DecidableEq X] in +theorem fiberParameterLength_of_not_keep + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (i : X) (hi : ¬keep i) : S.fiberParameterLength i = 1 := by + simp only [fiberParameterLength, dite_eq_right hi] + +def fiberFullParameters + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (u : ∀ k, Fin (S.length k)) (i : X) : Fin (S.fiberParameterLength i) := + ⟨if hi : keep i then (u ⟨i, hi⟩).val else 0, by + by_cases hi : keep i + · simpa only [fiberParameterLength, dite_eq_left hi] using (u ⟨i, hi⟩).isLt + · simp only [fiberParameterLength, dite_eq_right hi, Nat.zero_lt_one]⟩ + +def fiberKeptParameters + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (v : ∀ i, Fin (S.fiberParameterLength i)) (k : {x // keep x}) : Fin (S.length k) := + ⟨(v k.val).val, by + simpa only [fiberParameterLength, dite_eq_left k.property] using (v k.val).isLt⟩ + +def fiberFullParameterEquiv + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) : + (∀ k, Fin (S.length k)) ≃ (∀ i, Fin (S.fiberParameterLength i)) where + toFun := S.fiberFullParameters + invFun := S.fiberKeptParameters + left_inv u := by + funext k + apply Fin.ext + simp only [fiberKeptParameters, fiberFullParameters, dite_eq_left k.property] + right_inv v := by + funext i + apply Fin.ext + by_cases hi : keep i + · simp only [fiberFullParameters, fiberKeptParameters, dite_eq_left hi] + · have hv : (v i).val < 1 := by + simpa only [fiberParameterLength, dite_eq_right hi] using (v i).isLt + simp only [fiberFullParameters, dite_eq_right hi] + omega + +def fiberAffineIntegerPoint + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (fixed : {x // ¬keep x} → ℤ) (v : ∀ i, Fin (S.fiberParameterLength i)) : X → ℤ := + fun i => S.fiberParameterStart fixed i + + (fiberParameterStride (keep := keep) (q := q) i : ℤ) * (v i).val + +omit [Fintype X] [DecidableEq X] in +theorem fiberAffineIntegerPoint_eq + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (fixed : {x // ¬keep x} → ℤ) (v : ∀ i, Fin (S.fiberParameterLength i)) : + S.fiberAffineIntegerPoint fixed v = S.fiberIntegerPoint fixed (S.fiberKeptParameters v) := by + funext i + by_cases hi : keep i + · simp only [fiberAffineIntegerPoint, fiberParameterStart, fiberParameterStride, + fiberIntegerPoint, finiteSplitPoint, dite_eq_left hi, ite_eq_left hi, + point, fiberKeptParameters, Nat.cast_add, Nat.cast_mul] + · simp only [fiberAffineIntegerPoint, fiberParameterStart, fiberParameterStride, + fiberIntegerPoint, finiteSplitPoint, dite_eq_right hi, ite_eq_right hi, + Nat.cast_zero, zero_mul, add_zero] + +def fiberAffinePointInBox + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (v : ∀ i, Fin (S.fiberParameterLength i)) : integerBox N := + ⟨S.fiberAffineIntegerPoint fixed v, by + rw [fiberAffineIntegerPoint_eq] + exact S.fiberIntegerPoint_mem_integerBox fixed hfixed _⟩ + +theorem fiberSliceLaw_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (test : integerBox N → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean test = + 𝔼 u, test (S.fiberPointInBox fixed hfixed u) := by + let : ∀ k, Nonempty (Fin (S.length k)) := fun k => ⟨⟨0, hlen k⟩⟩ + exact FiniteProbabilityWeights.uniform_finitePushforward_complexMean _ _ + +theorem fiberSliceLaw_affine_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (test : integerBox N → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean test = + 𝔼 v : (∀ i, Fin (S.fiberParameterLength i)), test (S.fiberAffinePointInBox fixed hfixed v) := by + rw [fiberSliceLaw_complexMean] + apply Fintype.expect_equiv S.fiberFullParameterEquiv + intro u + congr 1 + apply Subtype.ext + change S.fiberIntegerPoint fixed u = + S.fiberAffineIntegerPoint fixed (S.fiberFullParameterEquiv u) + rw [fiberAffineIntegerPoint_eq] + exact congrArg (S.fiberIntegerPoint fixed) (S.fiberFullParameterEquiv.left_inv u).symm + +noncomputable def fiberAffineLaw + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) : + FiniteProbabilityWeights (integerBox N) := by + letI : ∀ i, Nonempty (Fin (S.fiberParameterLength i)) := + fun i => ⟨⟨0, S.fiberParameterLength_pos hlen i⟩⟩ + exact (FiniteProbabilityWeights.uniform (∀ i, Fin (S.fiberParameterLength i))).finitePushforward + (S.fiberAffinePointInBox fixed hfixed) + +theorem fiberAffineLaw_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (test : integerBox N → ℂ) : + (S.fiberAffineLaw hlen fixed hfixed).complexMean test = + 𝔼 v : (∀ i, Fin (S.fiberParameterLength i)), test (S.fiberAffinePointInBox fixed hfixed v) := by + let : ∀ i, Nonempty (Fin (S.fiberParameterLength i)) := + fun i => ⟨⟨0, S.fiberParameterLength_pos hlen i⟩⟩ + exact FiniteProbabilityWeights.uniform_finitePushforward_complexMean _ _ + +private theorem weights_eq_of_complexMean {Ω : Type*} [Fintype Ω] + (p r : FiniteProbabilityWeights Ω) + (hmean : ∀ test, p.complexMean test = r.complexMean test) : p = r := by + classical + have hw (x : Ω) : p.weight x = r.weight x := by + apply Complex.ofReal_injective + have h := hmean (fun y => if y = x then 1 else 0) + simpa only [FiniteProbabilityWeights.complexMean, mul_ite, mul_one, mul_zero, + Finset.sum_ite_eq', Finset.mem_univ, ite_true] using h + cases p + cases r + congr + exact funext hw + +theorem fiberSliceLaw_eq_affineLaw + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) : + S.fiberSliceLaw hlen fixed hfixed = S.fiberAffineLaw hlen fixed hfixed := by + apply weights_eq_of_complexMean + intro test + rw [fiberSliceLaw_affine_complexMean, fiberAffineLaw_complexMean] + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {D : Type*} [Fintype D] [DecidableEq D] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] (h : D → ℕ) +variable (L H step : PrincipalTupleIndex B h → ℕ) (start : PrincipalTupleIndex B h → ℤ) +variable (hinside : ∀ j (t : Fin (H j)), + 0 ≤ start j + (step j : ℤ) * t.val ∧ start j + (step j : ℤ) * t.val < L j) + +def principalAffineIntervalPoint (t : ∀ j, Fin (H j)) : PrincipalIntegerTuples B h Empty L := + fun j _ => ⟨start j + (step j : ℤ) * (t j).val, Finset.mem_Ico.mpr + ⟨(neg_nonpos.mpr (Int.natCast_nonneg _)).trans (hinside j (t j)).1, (hinside j (t j)).2⟩⟩ + +omit [Fintype D] [DecidableEq D] [∀ index, Fintype (B index)] + [∀ index, DecidableEq (B index)] in +@[simp] theorem principalAffineIntervalPoint_value (t : ∀ j, Fin (H j)) + (j : PrincipalTupleIndex B h) (a : Option Empty) : + (principalAffineIntervalPoint B h L H step start hinside t j a : ℤ) = + start j + (step j : ℤ) * (t j).val := rfl + +omit [Fintype D] [DecidableEq D] [∀ index, Fintype (B index)] + [∀ index, DecidableEq (B index)] in +theorem principalAffineIntervalPoint_cube (t : ∀ j, Fin (H j)) + (j : PrincipalTupleIndex B h) : + IntegerScalarCube (L j) + (fun a => (principalAffineIntervalPoint B h L H step start hinside t j a : ℤ)) := by + intro row + have he : row = ∅ := Subsingleton.elim _ _ + simpa only [he, integerScalarCubeValue, Finset.sum_empty, add_zero, + principalAffineIntervalPoint_value] using hinside j (t j) + +variable (hH : ∀ j, 0 < H j) + +noncomputable def principalAffineIntervalLaw : FiniteProbabilityWeights (PrincipalIntegerTuples B h Empty L) := by + letI : ∀ j, Nonempty (Fin (H j)) := fun j => ⟨⟨0, hH j⟩⟩ + exact (FiniteProbabilityWeights.uniform (∀ j, Fin (H j))).finitePushforward + (principalAffineIntervalPoint B h L H step start hinside) + +theorem principalAffineIntervalLaw_mean (f : PrincipalIntegerTuples B h Empty L → ℝ) : + (principalAffineIntervalLaw B h L H step start hinside hH).mean f = + 𝔼 t : (∀ j, Fin (H j)), f (principalAffineIntervalPoint B h L H step start hinside t) := by + let : ∀ j, Nonempty (Fin (H j)) := fun j => ⟨⟨0, hH j⟩⟩ + exact FiniteProbabilityWeights.uniform_finitePushforward_mean _ _ + +theorem principalAffineIntervalLaw_complexMean (f : PrincipalIntegerTuples B h Empty L → ℂ) : + (principalAffineIntervalLaw B h L H step start hinside hH).complexMean f = + 𝔼 t : (∀ j, Fin (H j)), f (principalAffineIntervalPoint B h L H step start hinside t) := by + let : ∀ j, Nonempty (Fin (H j)) := fun j => ⟨⟨0, hH j⟩⟩ + exact FiniteProbabilityWeights.uniform_finitePushforward_complexMean _ _ + +theorem principalAffineIntervalLaw_support + (y : PrincipalIntegerTuples B h Empty L) + (hy : (principalAffineIntervalLaw B h L H step start hinside hH).weight y ≠ 0) : + ∃ t : ∀ j, Fin (H j), principalAffineIntervalPoint B h L H step start hinside t = y := by + let : ∀ j, Nonempty (Fin (H j)) := fun j => ⟨⟨0, hH j⟩⟩ + by_contra hn + apply hy + unfold principalAffineIntervalLaw FiniteProbabilityWeights.finitePushforward + apply Finset.sum_eq_zero + intro t _ + exact ite_eq_right (fun ht => hn ⟨t, ht⟩) + +theorem principalAffineIntervalLaw_cube_support + (y : PrincipalIntegerTuples B h Empty L) + (hy : (principalAffineIntervalLaw B h L H step start hinside hH).weight y ≠ 0) + (j : PrincipalTupleIndex B h) : + IntegerScalarCube (L j) (fun a => (y j a : ℤ)) := by + obtain ⟨t, rfl⟩ := principalAffineIntervalLaw_support B h L H step start hinside hH y hy + exact principalAffineIntervalPoint_cube B h L H step start hinside t j + +theorem principalAffineIntervalLaw_coordinate_support + (y : PrincipalIntegerTuples B h Empty L) + (hy : (principalAffineIntervalLaw B h L H step start hinside hH).weight y ≠ 0) + (j : PrincipalTupleIndex B h) (a : Option Empty) : + (y j a : ℤ) ∈ integerProgressionSupport (start j) (step j : ℤ) (H j) := by + obtain ⟨t, rfl⟩ := principalAffineIntervalLaw_support B h L H step start hinside hH y hy + rw [principalAffineIntervalPoint_value, integerProgressionSupport, mem_translateSupport] + apply Finset.mem_image.mpr + refine ⟨((t j).val : ℤ), Finset.mem_Ico.mpr ⟨Int.natCast_nonneg _, by exact_mod_cast (t j).isLt⟩, ?_⟩ + change (step j : ℤ) * (t j).val = _ + ring + +noncomputable def principalAffineIntervalAxisLaw (P : D → Prop) : + FiniteProbabilityWeights (PrincipalAxisTuples (α := Empty) P L) := + (principalAffineIntervalLaw B h L H step start hinside hH).finitePushforward + (principalAxisRestrict P) + +theorem principalAffineIntervalAxisLaw_complexMean (P : D → Prop) + (f : PrincipalAxisTuples (α := Empty) P L → ℂ) : + (principalAffineIntervalAxisLaw B h L H step start hinside hH P).complexMean f = + 𝔼 t : (∀ j, Fin (H j)), + f (principalAxisRestrict P (principalAffineIntervalPoint B h L H step start hinside t)) := by + rw [principalAffineIntervalAxisLaw, FiniteProbabilityWeights.complexMean_finitePushforward, + principalAffineIntervalLaw_complexMean] + +theorem principalAffineIntervalAxisLaw_mass_one (P : D → Prop) : + ∑ u, (principalAffineIntervalAxisLaw B h L H step start hinside hH P).weight u = 1 := + (principalAffineIntervalAxisLaw B h L H step start hinside hH P).total + +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +variable {X : Type*} [Fintype X] [DecidableEq X] +variable {keep : X → Prop} [DecidablePred keep] {N : X → ℕ} {q : ℕ} + +theorem fiberParameter_inside + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (i : X) (t : Fin (S.fiberParameterLength i)) : + 0 ≤ S.fiberParameterStart fixed i + + (fiberParameterStride (keep := keep) (q := q) i : ℤ) * t.val ∧ + S.fiberParameterStart fixed i + + (fiberParameterStride (keep := keep) (q := q) i : ℤ) * t.val < N i := by + let zero : ∀ j, Fin (S.fiberParameterLength j) := + fun j => ⟨0, S.fiberParameterLength_pos hlen j⟩ + let v := Function.update zero i t + have hv := (mem_integerBox N _).mp (S.fiberAffinePointInBox fixed hfixed v).property i + simpa only [fiberAffinePointInBox, fiberAffineIntegerPoint, v, Function.update_self] using hv + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators + +variable {G P : Type*} [Fintype G] [Fintype P] [DecidableEq G] [DecidableEq P] +variable {keep : G ⊕ P → Prop} [DecidablePred keep] {N : G ⊕ P → ℕ} {q : ℕ} + +theorem fiberSliceLaw_affine_sum_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (test : integerBox N → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean test = + 𝔼 g : (∀ i, Fin (S.fiberParameterLength (Sum.inl i))), + 𝔼 p : (∀ j, Fin (S.fiberParameterLength (Sum.inr j))), + test (S.fiberAffinePointInBox fixed hfixed (Sum.rec g p)) := by + rw [fiberSliceLaw_affine_complexMean] + exact uniformDependentFin_expect S.fiberParameterLength _ + +theorem fiberSliceLaw_affine_sum_value_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (test : (G ⊕ P → ℤ) → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean (fun x => test x.val) = + 𝔼 g : (∀ i, Fin (S.fiberParameterLength (Sum.inl i))), + 𝔼 p : (∀ j, Fin (S.fiberParameterLength (Sum.inr j))), + test (Sum.elim + (fun i => S.fiberParameterStart fixed (Sum.inl i) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inl i) : ℤ) * (g i).val) + (fun j => S.fiberParameterStart fixed (Sum.inr j) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inr j) : ℤ) * (p j).val)) := by + rw [fiberSliceLaw_affine_sum_complexMean] + apply Finset.expect_congr rfl + intro g _ + apply Finset.expect_congr rfl + intro p _ + congr 1 + funext k + cases k <;> rfl + +theorem fiberSliceLaw_kernel_principal_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (hkernel : ∀ i, keep (Sum.inl i)) (test : (G ⊕ P → ℤ) → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean (fun x => test x.val) = + 𝔼 g : (∀ i, Fin (S.fiberParameterLength (Sum.inl i))), + 𝔼 p : (∀ j, Fin (S.fiberParameterLength (Sum.inr j))), + test (Sum.elim + (fun i => (S.start ⟨Sum.inl i, hkernel i⟩ : ℤ) + (q : ℤ) * (g i).val) + (fun j => S.fiberParameterStart fixed (Sum.inr j) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inr j) : ℤ) * (p j).val)) := by + rw [fiberSliceLaw_affine_sum_value_complexMean] + apply Finset.expect_congr rfl + intro g _ + apply Finset.expect_congr rfl + intro p _ + congr 2 + funext i + simp only [fiberParameterStart, fiberParameterStride, dite_eq_left (hkernel i), + ite_eq_left (hkernel i)] + +def fiberKernelParameterEquiv + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hkernel : ∀ i, keep (Sum.inl i)) : + (∀ i, Fin (S.fiberParameterLength (Sum.inl i))) ≃ + (∀ i, Fin (S.length ⟨Sum.inl i, hkernel i⟩)) where + toFun g i := ⟨(g i).val, by + simpa only [fiberParameterLength, dite_eq_left (hkernel i)] using (g i).isLt⟩ + invFun g i := ⟨(g i).val, by + simpa only [fiberParameterLength, dite_eq_left (hkernel i)] using (g i).isLt⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem fiberSliceLaw_kernel_principal_intervals_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (hkernel : ∀ i, keep (Sum.inl i)) (test : (G ⊕ P → ℤ) → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean (fun x => test x.val) = + 𝔼 g : (∀ i, Fin (S.length ⟨Sum.inl i, hkernel i⟩)), + 𝔼 p : (∀ j, Fin (S.fiberParameterLength (Sum.inr j))), + test (Sum.elim + (fun i => (S.start ⟨Sum.inl i, hkernel i⟩ : ℤ) + (q : ℤ) * (g i).val) + (fun j => S.fiberParameterStart fixed (Sum.inr j) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inr j) : ℤ) * (p j).val)) := by + rw [fiberSliceLaw_kernel_principal_complexMean S hlen fixed hfixed hkernel] + apply Fintype.expect_equiv (S.fiberKernelParameterEquiv hkernel) + intro g + rfl + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {D : Type*} [Fintype D] [DecidableEq D] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) + +def principalZeroTupleFromIntegerBox (z : integerBox L) : + PrincipalIntegerTuples B h Empty L := + fun j _ => ⟨z.val j, Finset.mem_Ico.mpr + ⟨(neg_nonpos.mpr (Int.natCast_nonneg _)).trans ((mem_integerBox L z.val).mp z.property j).1, + ((mem_integerBox L z.val).mp z.property j).2⟩⟩ + +@[simp] theorem principalZeroTupleFromIntegerBox_value (z : integerBox L) + (j : PrincipalTupleIndex B h) (a : Option Empty) : + (principalZeroTupleFromIntegerBox B h L z j a : ℤ) = z.val j := rfl + +variable {keep : PrincipalTupleIndex B h → Prop} [DecidablePred keep] {q : ℕ} +variable (S : ResidueBoxSlice (fun j : {j // keep j} => L j.val) q) +variable (hlen : ∀ j, 0 < S.length j) +variable (fixed : {j // ¬keep j} → ℤ) +variable (hfixed : ∀ j, 0 ≤ fixed j ∧ fixed j < (L j.val : ℤ)) + +noncomputable def principalFiberSliceLaw : FiniteProbabilityWeights (PrincipalIntegerTuples B h Empty L) := + (S.fiberSliceLaw hlen fixed hfixed).finitePushforward (principalZeroTupleFromIntegerBox B h L) + +theorem principalFiberSliceLaw_complexMean (f : PrincipalIntegerTuples B h Empty L → ℂ) : + (principalFiberSliceLaw B h L S hlen fixed hfixed).complexMean f = + 𝔼 t : (∀ j, Fin (S.fiberParameterLength j)), + f (principalZeroTupleFromIntegerBox B h L (S.fiberAffinePointInBox fixed hfixed t)) := by + rw [principalFiberSliceLaw, FiniteProbabilityWeights.complexMean_finitePushforward, + ResidueBoxSlice.fiberSliceLaw_affine_complexMean] + +theorem principalZeroTupleFromIntegerBox_affinePoint + (hinside : ∀ j (t : Fin (S.fiberParameterLength j)), + 0 ≤ S.fiberParameterStart fixed j + + (ResidueBoxSlice.fiberParameterStride (keep := keep) (q := q) j : ℤ) * t.val ∧ + S.fiberParameterStart fixed j + + (ResidueBoxSlice.fiberParameterStride (keep := keep) (q := q) j : ℤ) * t.val < L j) + (t : ∀ j, Fin (S.fiberParameterLength j)) : + principalZeroTupleFromIntegerBox B h L (S.fiberAffinePointInBox fixed hfixed t) = + principalAffineIntervalPoint B h L S.fiberParameterLength + (ResidueBoxSlice.fiberParameterStride (keep := keep) (q := q)) + (S.fiberParameterStart fixed) hinside t := by + funext j a + apply Subtype.ext + rfl + +theorem principalFiberSliceLaw_eq_affine : + principalFiberSliceLaw B h L S hlen fixed hfixed = + principalAffineIntervalLaw B h L S.fiberParameterLength + (ResidueBoxSlice.fiberParameterStride (keep := keep) (q := q)) + (S.fiberParameterStart fixed) (S.fiberParameter_inside hlen fixed hfixed) (S.fiberParameterLength_pos hlen) := by + have hm (f : PrincipalIntegerTuples B h Empty L → ℂ) : + (principalFiberSliceLaw B h L S hlen fixed hfixed).complexMean f = + (principalAffineIntervalLaw B h L S.fiberParameterLength + (ResidueBoxSlice.fiberParameterStride (keep := keep) (q := q)) + (S.fiberParameterStart fixed) (S.fiberParameter_inside hlen fixed hfixed) (S.fiberParameterLength_pos hlen)).complexMean f := by + rw [principalFiberSliceLaw_complexMean, principalAffineIntervalLaw_complexMean] + apply Finset.expect_congr rfl + intro t _ + rw [principalZeroTupleFromIntegerBox_affinePoint B h L S fixed hfixed (S.fiberParameter_inside hlen fixed hfixed)] + have hw (z : PrincipalIntegerTuples B h Empty L) := + congrArg Complex.re (hm (fun y => if y = z then 1 else 0)) + simp only [FiniteProbabilityWeights.complexMean_re, apply_ite, Complex.one_re, + Complex.zero_re, FiniteProbabilityWeights.mean, mul_one, mul_zero, + Finset.sum_ite_eq', Finset.mem_univ, ite_true] at hw + cases hp : principalFiberSliceLaw B h L S hlen fixed hfixed + cases hr : principalAffineIntervalLaw B h L S.fiberParameterLength + (ResidueBoxSlice.fiberParameterStride (keep := keep) (q := q)) + (S.fiberParameterStart fixed) (S.fiberParameter_inside hlen fixed hfixed) + (S.fiberParameterLength_pos hlen) + simp only [hp, hr] at hw + congr + exact funext hw + +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators + +variable {G P : Type*} [Fintype G] [Fintype P] [DecidableEq G] [DecidableEq P] +variable {keep : G ⊕ P → Prop} [DecidablePred keep] {N : G ⊕ P → ℕ} {q : ℕ} + +def fiberKernelActiveShortPoint + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (fixed : {x // ¬keep x} → ℤ) (hkernel : ∀ i, keep (Sum.inl i)) + (active : P → Prop) [DecidablePred active] + (g : ∀ i, Fin (S.length ⟨Sum.inl i, hkernel i⟩)) + (a : ∀ j : {p // active p}, Fin (S.fiberParameterLength (Sum.inr j.val))) + (s : ∀ j : {p // ¬active p}, Fin (S.fiberParameterLength (Sum.inr j.val))) : + G ⊕ P → ℤ := + Sum.elim + (fun i => (S.start ⟨Sum.inl i, hkernel i⟩ : ℤ) + (q : ℤ) * (g i).val) + (finiteSplitPoint active + (fun j => S.fiberParameterStart fixed (Sum.inr j.val) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inr j.val) : ℤ) * (a j).val) + (fun j => S.fiberParameterStart fixed (Sum.inr j.val) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inr j.val) : ℤ) * (s j).val)) + +theorem fiberSliceLaw_kernel_active_short_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (hkernel : ∀ i, keep (Sum.inl i)) + (active : P → Prop) [DecidablePred active] (test : (G ⊕ P → ℤ) → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean (fun x => test x.val) = + 𝔼 g : (∀ i, Fin (S.length ⟨Sum.inl i, hkernel i⟩)), + 𝔼 a : (∀ j : {p // active p}, Fin (S.fiberParameterLength (Sum.inr j.val))), + 𝔼 s : (∀ j : {p // ¬active p}, Fin (S.fiberParameterLength (Sum.inr j.val))), + test (S.fiberKernelActiveShortPoint fixed hkernel active g a s) := by + rw [fiberSliceLaw_kernel_principal_intervals_complexMean S hlen fixed hfixed hkernel] + apply Finset.expect_congr rfl + intro g _ + rw [uniformDependentFinSubtype_expect active] + apply Finset.expect_congr rfl + intro a _ + apply Finset.expect_congr rfl + intro s _ + congr 1 + funext k + cases k with + | inl i => rfl + | inr j => + by_cases hj : active j <;> + simp only [fiberKernelActiveShortPoint, Sum.elim_inr, finiteSplitPoint, + Equiv.piEquivPiSubtypeProd, Equiv.coe_fn_symm_mk, hj, dite_true, dite_false] + +theorem fiberSliceLaw_short_kernel_active_complexMean + (S : ResidueBoxSlice (fun k : {x // keep x} => N k.val) q) + (hlen : ∀ k, 0 < S.length k) (fixed : {x // ¬keep x} → ℤ) + (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < (N k.val : ℤ)) + (hkernel : ∀ i, keep (Sum.inl i)) + (active : P → Prop) [DecidablePred active] (test : (G ⊕ P → ℤ) → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean (fun x => test x.val) = + 𝔼 s : (∀ j : {p // ¬active p}, Fin (S.fiberParameterLength (Sum.inr j.val))), + 𝔼 g : (∀ i, Fin (S.length ⟨Sum.inl i, hkernel i⟩)), + 𝔼 a : (∀ j : {p // active p}, Fin (S.fiberParameterLength (Sum.inr j.val))), + test (S.fiberKernelActiveShortPoint fixed hkernel active g a s) := by + rw [fiberSliceLaw_kernel_active_short_complexMean S hlen fixed hfixed hkernel active] + calc + _ = 𝔼 g : (∀ i, Fin (S.length ⟨Sum.inl i, hkernel i⟩)), + 𝔼 s : (∀ j : {p // ¬active p}, Fin (S.fiberParameterLength (Sum.inr j.val))), + 𝔼 a : (∀ j : {p // active p}, Fin (S.fiberParameterLength (Sum.inr j.val))), + test (S.fiberKernelActiveShortPoint fixed hkernel active g a s) := by + apply Finset.expect_congr rfl + intro g _ + exact Finset.expect_comm _ _ _ + _ = _ := Finset.expect_comm _ _ _ + +end Erdos3.ResidueBoxSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueAffineProfileLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueAffineProfileLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..65e0565321e5df306bb7ebdefcd7eff00aa54a0e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueAffineProfileLaw.lean @@ -0,0 +1,146 @@ +import OAI.Combinatorics.Progressions.Geometry.PhysicalSpatialScales + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Matrix + +noncomputable def shiftedUnitProfile {I : Type*} [Fintype I] (a S : I → ℝ) : (I → ℝ) → ℝ := + affineProductProfile (fun i => a i / S i) (fun _ => 1) + +theorem shiftedUnitProfile_nonneg {I : Type*} [Fintype I] (a S : I → ℝ) (x : I → ℝ) : + 0 ≤ shiftedUnitProfile a S x := + affineProductProfile_nonneg _ _ (fun _ => zero_lt_one) x + +theorem shiftedUnitProfile_weight {I : Type*} [Fintype I] (a S : I → ℝ) (z : I → ℤ) : + coefficientWeight (shiftedUnitProfile a S) S z = rectangularWeight (smoothProductProfile I) a S z := by + simp only [coefficientWeight, shiftedUnitProfile, affineProductProfile_eq, profileWidthFactor, + inv_one, Finset.prod_const_one, one_mul, div_one, rectangularWeight] + congr 1 + funext i + exact (sub_div (z i : ℝ) (a i) (S i)).symm + +theorem shiftedUnitProfile_mass {I : Type*} [Fintype I] (a S : I → ℝ) : + coefficientWeightSum (shiftedUnitProfile a S) S = shiftedSmoothProductMass a S := by + unfold coefficientWeightSum shiftedSmoothProductMass + simp_rw [shiftedUnitProfile_weight] + +theorem shiftedUnitProfile_integral {I : Type*} [Fintype I] (a S : I → ℝ) : + (∫ x, shiftedUnitProfile a S x) = 1 := + affineProductProfile_integral _ _ (fun _ => zero_lt_one) + +theorem shiftedUnitProfile_lipschitz {I : Type*} [Fintype I] (a S : I → ℝ) : + LipschitzWith (affineProductProfileLip I 1) (shiftedUnitProfile a S) := + affineProductProfile_lipschitz _ _ zero_lt_one (fun _ => le_rfl) + +theorem shiftedUnitProfile_cap {I : Type*} [Fintype I] (a S : I → ℝ) (x : I → ℝ) : + ‖shiftedUnitProfile a S x‖ ≤ 1 := by + simpa only [shiftedUnitProfile, inv_one, one_pow] using + affineProductProfile_cap (fun i => a i / S i) (fun _ => 1) zero_lt_one (fun _ => le_rfl) x + +theorem shiftedUnitProfile_support {I : Type*} [Fintype I] + (a S : I → ℝ) (hS : ∀ i, 0 < S i) (ha : ∀ i, |a i| ≤ S i) : + ∀ x, 2 < ‖x‖ → shiftedUnitProfile a S x = 0 := by + apply affineProductProfile_zero_outside _ _ (fun _ => zero_lt_one) (by norm_num) + intro i + have h : |a i / S i| ≤ 1 := by + rw [abs_div, abs_of_pos (hS i)] + exact (div_le_one (hS i)).mpr (ha i) + linarith + +theorem coefficientPMF_shiftedUnitProfile {I : Type*} [Fintype I] + (a S : I → ℝ) (hS : ∀ i, 0 < S i) {r : ℝ} + (hsupport : ∀ x, r < ‖x‖ → shiftedUnitProfile a S x = 0) + (hZ : 0 < shiftedSmoothProductMass a S) : + coefficientPMF (shiftedUnitProfile a S) (shiftedUnitProfile_nonneg a S) S hS hsupport + (by rw [shiftedUnitProfile_mass]; exact hZ) = + shiftedSmoothProductPMF a S hS hZ := by + ext z + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + rw [coefficientPMF_apply, shiftedSmoothProductPMF_toReal, shiftedUnitProfile_weight, shiftedUnitProfile_mass] + +theorem shiftedUnitProfile_residue {K X : Type*} [Fintype K] [Fintype X] + (residue : K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) : + shiftedUnitProfile (residueProfileCenter residue modulus) (residueProfileWidth modulus V) = + affineProductProfile (fun z => -(residue z : ℝ) / V z) (fun _ => 1) := by + unfold shiftedUnitProfile + congr 1 + funext z + have hq : (modulus z.2 : ℝ) ≠ 0 := by exact_mod_cast (hmodulus z.2).ne' + unfold residueProfileCenter residueProfileWidth + field_simp [(hV z).ne'] + +theorem residueSmoothIndexPMF_affine {K X : Type*} [Fintype K] [Fintype X] + (residue : K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (ha : ∀ z, |residueProfileCenter residue modulus z| ≤ residueProfileWidth modulus V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) (residueProfileWidth modulus V)) : + residueSmoothIndexPMF residue modulus hmodulus V hV hZ = + coefficientPMF (shiftedUnitProfile (residueProfileCenter residue modulus) (residueProfileWidth modulus V)) + (shiftedUnitProfile_nonneg _ _) (residueProfileWidth modulus V) + (residueProfileWidth_pos modulus V hmodulus hV) + (shiftedUnitProfile_support _ _ (residueProfileWidth_pos modulus V hmodulus hV) ha) + (by rw [shiftedUnitProfile_mass]; exact hZ) := + (coefficientPMF_shiftedUnitProfile _ _ (residueProfileWidth_pos modulus V hmodulus hV) + (shiftedUnitProfile_support _ _ (residueProfileWidth_pos modulus V hmodulus hV) ha) hZ).symm + +theorem residueProfileCenter_le_width {K X : Type*} + (residue : K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : K × X → ℝ) (hresidue : ∀ z, |(residue z : ℝ)| ≤ V z) (z : K × X) : + |residueProfileCenter residue modulus z| ≤ residueProfileWidth modulus V z := by + have hq : (0 : ℝ) < modulus z.2 := by exact_mod_cast hmodulus z.2 + simp only [residueProfileCenter, residueProfileWidth, abs_div, abs_neg, abs_of_pos hq] + exact div_le_div_of_nonneg_right (hresidue z) hq.le + +namespace BooleanCubeKernel + +theorem physicalCube_shifted_comparison {α K : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [DecidableEq K] + (root : K → ℤ) (D : Matrix α K ℤ) (s : α ↪ K) {A R L κ ρ C : ℝ} {B : ℕ} + (hA : 0 < A) (hR : 0 < R) (hL : 0 < L) (hκ : 0 < κ) (hρ : 0 < ρ) + (hC : 1 ≤ C) (hρA : ρ ≤ A) (hρR : ρ ≤ R) + (hr : ∀ k, |(root k : ℝ)| * R ≤ A) (hD : ∀ i k, |(D i k : ℝ)| ≤ L) + (hrC : ∀ k, |(root k : ℝ)| ≤ C) (hDC : ∀ i k, |(D i k : ℝ)| ≤ C) + (hminor : κ ≤ |(Matrix.of (fun i j => (D i (s j) : ℝ) / L)).det|) + (hperiod : HasBoundedScalarPeriod D.mulVecLin.range B) + (a : Option K → ℝ) (ha : ∀ k, |a k| ≤ physicalSpatialInputScale K A R k) + (hmesh : physicalSpatialMeshCost s C 2 (affineProductProfileLip (Option K) 1) ≤ ρ) : + let hp := (physicalCube_pivot_control root D s hA hR hL hκ hr hD hminor).1 + ∃ hZ : 0 < shiftedSmoothProductMass a (physicalSpatialInputScale K A R), ∀ v, + |(∏ i, physicalSpatialOutputScale α A R L i) * + (((shiftedSmoothProductPMF a (physicalSpatialInputScale K A R) + (physicalSpatialInputScale_pos K hA hR) hZ).map + (fun z => physicalCubeCoefficient root D *ᵥ z)) v).toReal - + coefficientImageMask (physicalCubeCoefficient root D) (physicalSpatialOutputScale α A R L) + (selectedCoefficientDensity (physicalCubeCoefficient root D) (physicalCubePivotIndex s) hp + (physicalSpatialInputScale K A R) (physicalSpatialOutputScale α A R L) + (physicalSpatialInputScale_pos K hA hR) (physicalSpatialOutputScale_pos α hA hR hL) + (shiftedUnitProfile a (physicalSpatialInputScale K A R))) v| ≤ + physicalSpatialErrorConstant s B κ C 2 1 (affineProductProfileLip (Option K) 1) / ρ := by + let S := physicalSpatialInputScale K A R + have hS : ∀ k, 0 < S k := physicalSpatialInputScale_pos K hA hR + have hs := shiftedUnitProfile_support a S hS ha + obtain ⟨hZ, he⟩ := physicalCube_full_comparison root D s hA hR hL hκ hρ hC hρA hρR + hr hD hrC hDC hminor hperiod (shiftedUnitProfile a S) (shiftedUnitProfile_nonneg a S) + (shiftedUnitProfile_lipschitz a S) (by norm_num) zero_le_one hs + (shiftedUnitProfile_integral a S) (shiftedUnitProfile_cap a S) hmesh + have hZ' : 0 < shiftedSmoothProductMass a S := by + rwa [shiftedUnitProfile_mass] at hZ + refine ⟨hZ', ?_⟩ + have heq : coefficientPMF (shiftedUnitProfile a S) (shiftedUnitProfile_nonneg a S) S hS hs hZ = + shiftedSmoothProductPMF a S hS hZ' := coefficientPMF_shiftedUnitProfile a S hS hs hZ' + dsimp only [S] at he heq + simpa only [coefficientImagePMF, heq] using he + +end BooleanCubeKernel + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBaselineBounds.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBaselineBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..32bc67e9de029b17bbb05aae11a8ce300ed6edd0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBaselineBounds.lean @@ -0,0 +1,26 @@ +import OAI.Combinatorics.Progressions.Estimates.StableRetainedAtom + +namespace OAI + +section + +namespace Erdos3 + +theorem residuePrimeCoordinateMean_re_le_one {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (g : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) + (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) : + (residuePrimeCoordinateMean g lo N M a q K base).re ≤ 1 := by + have ha : ∀ z ∈ translatedIntegerBox lo N, |(g z).re| ≤ 1 := by + intro z hz + rw [abs_of_nonneg (hg z hz).1] + exact (hg z hz).2 + have h := residuePrimeCoordinateRealMean_bound (fun z => (g z).re) lo N M a q K base 1 zero_le_one ha + rw [← residuePrimeCoordinateMean_re] at h + exact (le_abs_self _).trans h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBlockLongSideBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBlockLongSideBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..d978153257d3cefe2f203afd23fc6e537ce164d9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBlockLongSideBudget.lean @@ -0,0 +1,40 @@ +import OAI.Combinatorics.Progressions.Geometry.BoxBlockBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem residueBlock_long_side_budget {θ : ℝ} {N q Q H : ℕ} + (hθ : 0 < θ) (hN : 0 < N) (hq : 0 < q) (hQ : 0 < Q) + (hH : (N : ℝ) / (2 * q * Q) ≤ H) (n : ℕ) : + θ * N / (4 * q * Q * (n + 1 : ℝ)) ≤ θ * H / (2 * (n + 1 : ℝ)) ∧ + 0 < θ * H / (2 * (n + 1 : ℝ)) := by + have hNr : (0 : ℝ) < N := by exact_mod_cast hN + have hqr : (0 : ℝ) < q := by exact_mod_cast hq + have hQr : (0 : ℝ) < Q := by exact_mod_cast hQ + have hHr : (0 : ℝ) < H := (by positivity : 0 < (N : ℝ) / (2 * q * Q)).trans_le hH + refine ⟨?_, by positivity⟩ + calc + _ = (θ / (2 * (n + 1 : ℝ))) * ((N : ℝ) / (2 * q * Q)) := by + field_simp + ring + _ ≤ (θ / (2 * (n + 1 : ℝ))) * H := + mul_le_mul_of_nonneg_left hH (by positivity) + _ = _ := by ring + +theorem residueBlock_long_side_budget_of_inverse_mesh {θ : ℝ} {N q Q H : ℕ} + (hθ : 0 < θ) (hN : 0 < N) (hq : 0 < q) (hQ : 0 < Q) + (hH : (1 / (Q : ℝ)) * N / (2 * q) ≤ H) (n : ℕ) : + θ * N / (4 * q * Q * (n + 1 : ℝ)) ≤ θ * H / (2 * (n + 1 : ℝ)) ∧ + 0 < θ * H / (2 * (n + 1 : ℝ)) := by + apply residueBlock_long_side_budget hθ hN hq hQ _ n + convert hH using 1 + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBoxSliceCoordinateDisintegration.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBoxSliceCoordinateDisintegration.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e94ffb58a91392e38f8b56119cd71bfdbc6e9e3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBoxSliceCoordinateDisintegration.lean @@ -0,0 +1,766 @@ +import Mathlib.Logic.Equiv.Prod +import OAI.Combinatorics.Progressions.Estimates.NestedProgressionReindex +import OAI.Combinatorics.Progressions.Geometry.SampledCommonBox + +namespace OAI + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators + +variable {U : Type*} {N : U → ℕ} {q : ℕ} + +def integerPoint (A : ResidueBoxSlice N q) (j : ∀ i, Fin (A.length i)) : U → ℤ := + fun i => ((A.point j i).val : ℤ) + +theorem integerPoint_eq (A : ResidueBoxSlice N q) (j : ∀ i, Fin (A.length i)) : + A.integerPoint j = commonStridePoint (fun i => (A.start i : ℤ)) q + (fun i => ((j i).val : ℤ)) := by + funext i + simp only [integerPoint, point, commonStridePoint, Nat.cast_add, Nat.cast_mul] + +@[simp] theorem commonStrideIndex_integerPoint (A : ResidueBoxSlice N q) (hq : 0 < q) + (j : ∀ i, Fin (A.length i)) : + commonStrideIndex (fun i => (A.start i : ℤ)) q (A.integerPoint j) = + (fun i => ((j i).val : ℤ)) := by + rw [integerPoint_eq, commonStrideIndex_point _ hq] + +theorem integerPoint_injective (A : ResidueBoxSlice N q) (hq : 0 < q) : + Function.Injective A.integerPoint := by + intro j k h + have hi := congrArg (commonStrideIndex (fun i => (A.start i : ℤ)) q) h + rw [A.commonStrideIndex_integerPoint hq, A.commonStrideIndex_integerPoint hq] at hi + funext i + apply Fin.ext + exact_mod_cast congrFun hi i + +variable [Fintype U] [DecidableEq U] + +noncomputable def integerPoints (A : ResidueBoxSlice N q) : Finset (U → ℤ) := + Finset.univ.image A.integerPoint + +theorem integerPoints_eq_commonStrideBox (A : ResidueBoxSlice N q) : + A.integerPoints = commonStrideBox (fun i => (A.start i : ℤ)) q A.length := by + classical + rw [commonStrideBox_eq_image] + ext x + constructor + · intro hx + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hx + refine Finset.mem_image.mpr ⟨fun i => ((j i).val : ℤ), ?_, (A.integerPoint_eq j).symm⟩ + exact (mem_integerBox _ _).mpr (fun i => ⟨by positivity, by exact_mod_cast (j i).isLt⟩) + · intro hx + obtain ⟨z, hz, rfl⟩ := Finset.mem_image.mp hx + have hz' := (mem_integerBox _ _).mp hz + let j : ∀ i, Fin (A.length i) := fun i => ⟨(z i).toNat, by + have hzi := hz' i + omega⟩ + refine Finset.mem_image.mpr ⟨j, Finset.mem_univ _, ?_⟩ + rw [A.integerPoint_eq] + congr 1 + funext i + exact Int.toNat_of_nonneg (hz' i).1 + +omit [Fintype U] [DecidableEq U] in +theorem progression_inside (A : ResidueBoxSlice N q) (i : U) : + integerProgressionSupport (A.start i : ℤ) q (A.length i) ⊆ + Finset.Ico (0 : ℤ) (N i) := by + intro y hy + obtain ⟨j, hj0, hjlt, rfl⟩ := (mem_integerProgressionSupport_iff_parameter _ _ _ _).mp hy + have hj : j.toNat < A.length i := by omega + have hinside := A.inside i j.toNat hj + have he : (j.toNat : ℤ) = j := Int.toNat_of_nonneg hj0 + apply Finset.mem_Ico.mpr + constructor + · positivity + · rw [← he] + exact_mod_cast hinside + +theorem isDenseCommonStrideBox (A : ResidueBoxSlice N q) (hq : 0 < q) + {ρ : ℝ} (hρ : 0 < ρ) (hA : ∀ i, 0 < A.length i) + (hlength : ∀ i, ρ * N i ≤ 4 * q * A.length i) : + IsDenseCommonStrideBox N (Real.log (4 * (q : ℝ) / ρ)) A.integerPoints := by + refine ⟨fun i => (A.start i : ℤ), q, A.length, hq, hA, + A.progression_inside, ?_, A.integerPoints_eq_commonStrideBox⟩ + intro i + rw [Real.exp_neg, Real.exp_log (by positivity : 0 < 4 * (q : ℝ) / ρ), inv_div] + rw [div_mul_eq_mul_div] + apply (div_le_iff₀ (by positivity : 0 < 4 * (q : ℝ))).mpr + nlinarith [hlength i] + +theorem densityCost_nonneg (hq : 0 < q) {ρ : ℝ} (hρ : 0 < ρ) (hρone : ρ ≤ 1) : + 0 ≤ Real.log (4 * (q : ℝ) / ρ) := by + apply Real.log_nonneg + apply (le_div_iff₀ hρ).mpr + have hqone : (1 : ℝ) ≤ q := by exact_mod_cast hq + linarith + +theorem expect_integerPoints (A : ResidueBoxSlice N q) (hq : 0 < q) + {V : Type*} [AddCommMonoid V] [Module ℚ≥0 V] (f : (U → ℤ) → V) : + (𝔼 x ∈ A.integerPoints, f x) = + (𝔼 j : (∀ i, Fin (A.length i)), f (A.integerPoint j)) := by + exact Finset.expect_image (A.integerPoint_injective hq).injOn + +end Erdos3.ResidueBoxSlice + +namespace Erdos3 + +theorem IsDenseCommonStrideBox.mono {U : Type*} [Fintype U] [DecidableEq U] + {N : U → ℕ} {p p' : ℝ} {A : Finset (U → ℤ)} + (hA : IsDenseCommonStrideBox N p A) (hpp' : p ≤ p') : + IsDenseCommonStrideBox N p' A := by + obtain ⟨c, m, H, hm, hH, hinside, hlength, heq⟩ := hA + refine ⟨c, m, H, hm, hH, hinside, ?_, heq⟩ + intro i + exact (mul_le_mul_of_nonneg_right + (Real.exp_le_exp.mpr (neg_le_neg hpp')) (Nat.cast_nonneg (N i))).trans (hlength i) + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [DecidableEq I] + +theorem commonStrideBox_axis_card (c : I → ℤ) (m : ℕ) (H : I → ℕ) + (hm : 0 < m) (hH : ∀ i, 0 < H i) (i : I) : + ((commonStrideBox c m H).image (fun x => x i)).card = H i := by + classical + have hnonempty (j : I) : (integerProgressionSupport (c j) m (H j)).Nonempty := by + apply Finset.card_pos.mp + rw [card_integerProgressionSupport _ _ _ hm] + exact hH j + have hproject := Fintype.eval_image_piFinset + (fun j => integerProgressionSupport (c j) m (H j)) i (fun j _ => hnonempty j) + exact (congrArg Finset.card hproject).trans (card_integerProgressionSupport _ _ _ hm) + +namespace ResidueBoxSlice + +variable {N : I → ℕ} {q : ℕ} + +theorem length_pos_of_integerPoints_nonempty (A : ResidueBoxSlice N q) + (hA : A.integerPoints.Nonempty) (i : I) : 0 < A.length i := by + classical + obtain ⟨x, hx⟩ := hA + obtain ⟨j, _, _⟩ := Finset.mem_image.mp hx + exact lt_of_le_of_lt (Nat.zero_le ((j i).val)) (j i).isLt + +theorem length_pos_of_dense (A : ResidueBoxSlice N q) {c : ℝ} + (hA : IsDenseCommonStrideBox N c A.integerPoints) (i : I) : + 0 < A.length i := + A.length_pos_of_integerPoints_nonempty hA.nonempty i + +theorem length_lower_of_dense (A : ResidueBoxSlice N q) (hq : 0 < q) {c : ℝ} + (hA : IsDenseCommonStrideBox N c A.integerPoints) (i : I) : + Real.exp (-c) * (N i : ℝ) ≤ (A.length i : ℝ) := by + have hlength := A.length_pos_of_dense hA + obtain ⟨start, m, H, hm, hH, _, hdense, heq⟩ := hA + have hcard := congrArg + (fun s : Finset (I → ℤ) => (s.image (fun x => x i)).card) heq + rw [A.integerPoints_eq_commonStrideBox, + commonStrideBox_axis_card _ _ _ hq hlength, + commonStrideBox_axis_card _ _ _ hm hH] at hcard + rw [hcard] + exact hdense i + +end ResidueBoxSlice +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {I : Type*} {P N : I → ℕ} {q : ℕ} + +namespace ResidueBoxSlice + +def enlargeBox (S : ResidueBoxSlice P q) (N : I → ℕ) + (hPN : ∀ i, P i ≤ N i) : ResidueBoxSlice N q where + start := S.start + length := S.length + inside i j hj := (S.inside i j hj).trans_le (hPN i) + +@[simp] theorem enlargeBox_start (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) : (S.enlargeBox N hPN).start = S.start := rfl + +@[simp] theorem enlargeBox_length (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) : (S.enlargeBox N hPN).length = S.length := rfl + +@[simp] theorem enlargeBox_integerPoint (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) (u : ∀ i, Fin (S.length i)) : + (S.enlargeBox N hPN).integerPoint u = S.integerPoint u := rfl + +variable [Fintype I] [DecidableEq I] + +@[simp] theorem enlargeBox_integerPoints (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) : + (S.enlargeBox N hPN).integerPoints = S.integerPoints := rfl + +theorem expect_enlargeBox (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) {V : Type*} [AddCommMonoid V] [Module ℚ≥0 V] + (f : (I → ℤ) → V) : + (𝔼 x ∈ (S.enlargeBox N hPN).integerPoints, f x) = + 𝔼 x ∈ S.integerPoints, f x := rfl + +end ResidueBoxSlice + +variable [Fintype I] [DecidableEq I] + +def integerBoxInclusion (hPN : ∀ i, P i ≤ N i) : integerBox P → integerBox N := + fun x => ⟨x.val, (mem_integerBox N x.val).mpr (fun i => + ⟨((mem_integerBox P x.val).mp x.property i).1, + (((mem_integerBox P x.val).mp x.property i).2).trans_le + (by exact_mod_cast hPN i)⟩)⟩ + +@[simp] theorem integerBoxInclusion_val (hPN : ∀ i, P i ≤ N i) + (x : integerBox P) : (integerBoxInclusion hPN x).val = x.val := rfl + +theorem IsDenseCommonStrideBox.enlargeBox {c extra : ℝ} {A : Finset (I → ℤ)} + (hA : IsDenseCommonStrideBox P c A) (hPN : ∀ i, P i ≤ N i) + (hside : ∀ i, Real.exp (-extra) * (N i : ℝ) ≤ (P i : ℝ)) : + IsDenseCommonStrideBox N (c + extra) A := by + obtain ⟨start, m, H, hm, hH, hinside, hlength, heq⟩ := hA + refine ⟨start, m, H, hm, hH, ?_, ?_, heq⟩ + · intro i x hx + have h := Finset.mem_Ico.mp (hinside i hx) + exact Finset.mem_Ico.mpr ⟨h.1, h.2.trans_le (by exact_mod_cast hPN i)⟩ + · intro i + calc + Real.exp (-(c + extra)) * (N i : ℝ) = + Real.exp (-c) * (Real.exp (-extra) * (N i : ℝ)) := by + rw [neg_add, Real.exp_add, mul_assoc] + _ ≤ Real.exp (-c) * (P i : ℝ) := + mul_le_mul_of_nonneg_left (hside i) (Real.exp_pos _).le + _ ≤ (H i : ℝ) := hlength i + +namespace ResidueBoxSlice + +theorem enlargeBox_dense (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) {c extra : ℝ} + (hS : IsDenseCommonStrideBox P c S.integerPoints) + (hside : ∀ i, Real.exp (-extra) * (N i : ℝ) ≤ (P i : ℝ)) : + IsDenseCommonStrideBox N (c + extra) (S.enlargeBox N hPN).integerPoints := + hS.enlargeBox hPN hside + +omit [Fintype I] [DecidableEq I] in +theorem enlargeBox_length_lower (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) {c extra : ℝ} + (hlength : ∀ i, Real.exp (-c) * (P i : ℝ) ≤ (S.length i : ℝ)) + (hside : ∀ i, Real.exp (-extra) * (N i : ℝ) ≤ (P i : ℝ)) (i : I) : + Real.exp (-(c + extra)) * (N i : ℝ) ≤ ((S.enlargeBox N hPN).length i : ℝ) := by + calc + Real.exp (-(c + extra)) * (N i : ℝ) = + Real.exp (-c) * (Real.exp (-extra) * (N i : ℝ)) := by + rw [neg_add, Real.exp_add, mul_assoc] + _ ≤ Real.exp (-c) * (P i : ℝ) := + mul_le_mul_of_nonneg_left (hside i) (Real.exp_pos _).le + _ ≤ ((S.enlargeBox N hPN).length i : ℝ) := hlength i + +@[simp] theorem enlargeBox_fullSlicePointInIntegerBox (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) (u : ∀ i, Fin (S.length i)) : + (S.enlargeBox N hPN).fullSlicePointInIntegerBox u = + integerBoxInclusion hPN (S.fullSlicePointInIntegerBox u) := rfl + +theorem enlargeBox_fullSliceLaw_mean (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) (hlen : ∀ i, 0 < S.length i) + (f : integerBox N → ℝ) : + ((S.enlargeBox N hPN).fullSliceLaw hlen).mean f = + (S.fullSliceLaw hlen).mean (fun x => f (integerBoxInclusion hPN x)) := by + exact ((S.enlargeBox N hPN).fullSliceLaw_mean hlen f).trans + (S.fullSliceLaw_mean hlen (fun x => f (integerBoxInclusion hPN x))).symm + +theorem enlargeBox_fullSliceLaw_mean_ambient (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) (hlen : ∀ i, 0 < S.length i) + (f : (I → ℤ) → ℝ) : + ((S.enlargeBox N hPN).fullSliceLaw hlen).mean (fun x => f x.val) = + (S.fullSliceLaw hlen).mean (fun x => f x.val) := + S.enlargeBox_fullSliceLaw_mean hPN hlen (fun x => f x.val) + +theorem enlargeBox_fullSliceLaw (S : ResidueBoxSlice P q) + (hPN : ∀ i, P i ≤ N i) (hlen : ∀ i, 0 < S.length i) : + (S.enlargeBox N hPN).fullSliceLaw hlen = + (S.fullSliceLaw hlen).finitePushforward (integerBoxInclusion hPN) := by + have ext_weight {p p' : FiniteProbabilityWeights (integerBox N)} + (h : p.weight = p'.weight) : p = p' := by + cases p + cases p' + cases h + rfl + apply ext_weight + funext x + have hm := (S.enlargeBox_fullSliceLaw_mean hPN hlen + (fun y => if y = x then 1 else 0)).trans + (FiniteProbabilityWeights.mean_finitePushforward (S.fullSliceLaw hlen) + (integerBoxInclusion hPN) (fun y => if y = x then 1 else 0)).symm + simpa [FiniteProbabilityWeights.mean] using hm + +end ResidueBoxSlice + +omit [DecidableEq I] in + +theorem RelativePatchSliceConclusion.enlargeBox {s rankBound : ℕ} + {f : (I → ℤ) → ℝ} {target c extra : ℝ} + (h : RelativePatchSliceConclusion s P f target rankBound c) + (hPN : ∀ i, P i ≤ N i) + (hside : ∀ i, Real.exp (-extra) * (N i : ℝ) ≤ (P i : ℝ)) + (hextra : 0 ≤ extra) : + RelativePatchSliceConclusion s N f target rankBound (c + extra) := by + obtain ⟨q, hq, S, d, Q, hlength, hd, hcost, hscore⟩ := h + refine ⟨q, hq, S.enlargeBox N hPN, d, Q, + S.enlargeBox_length_lower hPN hlength hside, hd, ?_, ?_⟩ + · exact hcost.trans (le_add_of_nonneg_right hextra) + · exact (Real.exp_le_exp.mpr (neg_le_neg (le_add_of_nonneg_right hextra))).trans hscore + +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators + +variable {U : Type*} [Fintype U] [DecidableEq U] {N : U → ℕ} {q : ℕ} + +noncomputable def finiteSites (A : ResidueBoxSlice N q) : Finset (∀ i, Fin (N i)) := + Finset.univ.image A.point + +theorem finiteSites_image_integerCast (A : ResidueBoxSlice N q) : + A.finiteSites.image (fun t i => ((t i).val : ℤ)) = A.integerPoints := by + classical + simp only [finiteSites, integerPoints, Finset.image_image] + rfl + +omit [Fintype U] [DecidableEq U] in + +theorem finiteBox_integerCast_injective : + Function.Injective (fun t : (∀ i, Fin (N i)) => fun i => ((t i).val : ℤ)) := by + intro t u h + funext i + apply Fin.ext + exact Int.ofNat_inj.mp (congrFun h i) + +theorem expect_finiteSites (A : ResidueBoxSlice N q) + {V : Type*} [AddCommMonoid V] [Module ℚ≥0 V] (f : (U → ℤ) → V) : + (𝔼 t ∈ A.finiteSites, f (fun i => ((t i).val : ℤ))) = + 𝔼 x ∈ A.integerPoints, f x := by + classical + rw [← A.finiteSites_image_integerCast] + exact (Finset.expect_image finiteBox_integerCast_injective.injOn).symm + +theorem finiteSites_nonempty (A : ResidueBoxSlice N q) + (hA : ∀ i, 0 < A.length i) : A.finiteSites.Nonempty := by + classical + let j : ∀ i, Fin (A.length i) := fun i => ⟨0, hA i⟩ + exact ⟨A.point j, Finset.mem_image.mpr ⟨j, Finset.mem_univ _, rfl⟩⟩ + +theorem finiteSites_nonempty_of_integerPoints (A : ResidueBoxSlice N q) + (h : A.integerPoints.Nonempty) : A.finiteSites.Nonempty := by + classical + rw [← A.finiteSites_image_integerCast, Finset.image_nonempty] at h + exact h + +theorem finiteSites_dense (A : ResidueBoxSlice N q) {p : ℝ} + (h : IsDenseCommonStrideBox N p A.integerPoints) : + IsDenseCommonStrideBox N p + (A.finiteSites.image (fun t i => ((t i).val : ℤ))) := by + classical + rw [A.finiteSites_image_integerCast] + exact h + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators Classical + +variable {I V : Type*} {N : I → ℕ} {q : ℕ} + +def comap (A : ResidueBoxSlice N q) (e : V → I) : + ResidueBoxSlice (fun v => N (e v)) q where + start v := A.start (e v) + length v := A.length (e v) + inside v j hj := A.inside (e v) j hj + +def coordinateProjection (A : ResidueBoxSlice N q) (keep : I → Prop) : + ResidueBoxSlice (fun i : {i // keep i} => N i) q := + A.comap Subtype.val + +variable [Fintype I] [DecidableEq I] + +theorem comap_isDenseCommonStrideBox [Fintype V] [DecidableEq V] + (A : ResidueBoxSlice N q) (hq : 0 < q) {c : ℝ} + (hA : IsDenseCommonStrideBox N c A.integerPoints) (e : V → I) : + IsDenseCommonStrideBox (fun v => N (e v)) c (A.comap e).integerPoints := by + refine ⟨fun v => ((A.comap e).start v : ℤ), q, (A.comap e).length, + hq, ?_, (A.comap e).progression_inside, ?_, + (A.comap e).integerPoints_eq_commonStrideBox⟩ + · intro v + exact A.length_pos_of_dense hA (e v) + · intro v + exact A.length_lower_of_dense hq hA (e v) + +theorem coordinateProjection_isDenseCommonStrideBox + (A : ResidueBoxSlice N q) (hq : 0 < q) {c : ℝ} + (hA : IsDenseCommonStrideBox N c A.integerPoints) (keep : I → Prop) : + IsDenseCommonStrideBox (fun i : {i // keep i} => N i) c + (A.coordinateProjection keep).integerPoints := + A.comap_isDenseCommonStrideBox hq hA Subtype.val + +theorem mem_integerPoints_iff (A : ResidueBoxSlice N q) (x : I → ℤ) : + x ∈ A.integerPoints ↔ + ∀ i, x i ∈ integerProgressionSupport (A.start i : ℤ) q (A.length i) := by + rw [A.integerPoints_eq_commonStrideBox] + exact Fintype.mem_piFinset + +theorem finiteSplitPoint_mem_integerPoints + (A : ResidueBoxSlice N q) (keep : I → Prop) + (fixed : {i // ¬keep i} → ℤ) + (hfixed : ∀ i : {i // ¬keep i}, + fixed i ∈ integerProgressionSupport (A.start i : ℤ) q (A.length i)) + {x : {i // keep i} → ℤ} (hx : x ∈ (A.coordinateProjection keep).integerPoints) : + finiteSplitPoint keep x fixed ∈ A.integerPoints := by + apply (A.mem_integerPoints_iff _).mpr + have hx' := ((A.coordinateProjection keep).mem_integerPoints_iff x).mp hx + intro i + by_cases hi : keep i + · simpa only [finiteSplitPoint, dite_eq_left hi, coordinateProjection, comap] using hx' ⟨i, hi⟩ + · simpa only [finiteSplitPoint, dite_eq_right hi] using hfixed ⟨i, hi⟩ + +theorem exists_coordinate_fiber_score + (A : ResidueBoxSlice N q) (hq : 0 < q) (hlength : ∀ i, 0 < A.length i) + (keep : I → Prop) (score : (I → ℤ) → ℝ) {a : ℝ} + (hmean : a ≤ 𝔼 x ∈ A.integerPoints, score x) : + ∃ fixed : {i // ¬keep i} → ℤ, + (∀ i : {i // ¬keep i}, + fixed i ∈ integerProgressionSupport (A.start i : ℤ) q (A.length i)) ∧ + (∀ x ∈ (A.coordinateProjection keep).integerPoints, + finiteSplitPoint keep x fixed ∈ A.integerPoints) ∧ + a ≤ 𝔼 x ∈ (A.coordinateProjection keep).integerPoints, + score (finiteSplitPoint keep x fixed) := by + let e := Equiv.piEquivPiSubtypeProd keep (fun i => Fin (A.length i)) + let : ∀ i, Nonempty (Fin (A.length i)) := fun i => ⟨⟨0, hlength i⟩⟩ + let fixedOf (v : ∀ i : {i // ¬keep i}, Fin (A.length i)) : {i // ¬keep i} → ℤ := + fun i => ((A.start i + q * (v i).val : ℕ) : ℤ) + have hsplit : (𝔼 j : (∀ i, Fin (A.length i)), score (A.integerPoint j)) = + 𝔼 v : (∀ i : {i // ¬keep i}, Fin (A.length i)), + 𝔼 u : (∀ i : {i // keep i}, Fin (A.length i)), + score (finiteSplitPoint keep ((A.coordinateProjection keep).integerPoint u) + (fixedOf v)) := by + calc + _ = 𝔼 uv : (∀ i : {i // keep i}, Fin (A.length i)) × + (∀ i : {i // ¬keep i}, Fin (A.length i)), + score (finiteSplitPoint keep ((A.coordinateProjection keep).integerPoint uv.1) + (fixedOf uv.2)) := by + apply Fintype.expect_equiv e + intro j + congr 1 + funext i + by_cases hi : keep i <;> + simp [e, integerPoint, point, coordinateProjection, comap, fixedOf, + finiteSplitPoint, hi, Equiv.piEquivPiSubtypeProd] + _ = _ := by + rw [← Finset.univ_product_univ, Finset.expect_product, Finset.expect_comm] + rw [A.expect_integerPoints hq score, hsplit] at hmean + obtain ⟨v, _, hv⟩ := Finset.exists_le_of_le_expect Finset.univ_nonempty hmean + have hfixed (i : {i // ¬keep i}) : + fixedOf v i ∈ integerProgressionSupport (A.start i : ℤ) q (A.length i) := by + simpa only [fixedOf, Nat.cast_add, Nat.cast_mul] using + integerProgressionSupport_point (A.start i : ℤ) q (A.length i) hq + (v i).val (v i).isLt + refine ⟨fixedOf v, hfixed, ?_, ?_⟩ + · intro x hx + exact A.finiteSplitPoint_mem_integerPoints keep (fixedOf v) hfixed hx + · rw [(A.coordinateProjection keep).expect_integerPoints hq] + exact hv + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators Classical + +variable {K : Type*} (oldKeep keep : K → Prop) + +def axisInclusion (hsub : ∀ i, keep i → oldKeep i) (i : {i // keep i}) : + {i // oldKeep i} := + ⟨i.val, hsub i.val i.property⟩ + +noncomputable def axisInsertion + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) + (u : {i // keep i} → ℤ) : {i // oldKeep i} → ℤ := + fun i => if hi : keep i.val then u ⟨i.val, hi⟩ else fixed ⟨i, hi⟩ + +@[simp] theorem axisInsertion_kept (hsub : ∀ i, keep i → oldKeep i) + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) + (u : {i // keep i} → ℤ) (i : {i // keep i}) : + axisInsertion oldKeep keep fixed u (axisInclusion oldKeep keep hsub i) = u i := by + simp [axisInsertion, axisInclusion, i.property] + +theorem axisInsertion_injective (hsub : ∀ i, keep i → oldKeep i) + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) : + Function.Injective (axisInsertion oldKeep keep fixed) := by + intro x y h + funext i + simpa only [axisInsertion_kept] using + congrFun h (axisInclusion oldKeep keep hsub i) + +variable {oldKeep keep} {N : K → ℕ} {q oldq : ℕ} + +noncomputable def extendAxes + (S : ResidueBoxSlice (fun i : {i // keep i} => N i.val) q) + (A : ResidueBoxSlice (fun i : {i // oldKeep i} => N i.val) oldq) + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) + (hfixed : ∀ i, fixed i ∈ integerProgressionSupport + (A.start i.val : ℤ) oldq (A.length i.val)) : + ResidueBoxSlice (fun i : {i // oldKeep i} => N i.val) q where + start i := if hi : keep i.val then S.start ⟨i.val, hi⟩ else (fixed ⟨i, hi⟩).toNat + length i := if hi : keep i.val then S.length ⟨i.val, hi⟩ else 1 + inside i j hj := by + by_cases hi : keep i.val + · simpa only [dite_eq_left hi] using + S.inside ⟨i.val, hi⟩ j (by simpa only [dite_eq_left hi] using hj) + · have hj0 : j = 0 := by + simpa only [dite_eq_right hi, Nat.lt_one_iff] using hj + have hf := Finset.mem_Ico.mp (A.progression_inside i (hfixed ⟨i, hi⟩)) + simpa only [dite_eq_right hi, hj0, mul_zero, add_zero] using + (show (fixed ⟨i, hi⟩).toNat < N i.val by omega) + +attribute [local irreducible] integerProgressionSupport + +variable [Fintype K] + +theorem extendAxes_integerPoints + (S : ResidueBoxSlice (fun i : {i // keep i} => N i.val) q) + (A : ResidueBoxSlice (fun i : {i // oldKeep i} => N i.val) oldq) + (hsub : ∀ i, keep i → oldKeep i) + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) + (hfixed : ∀ i, fixed i ∈ integerProgressionSupport + (A.start i.val : ℤ) oldq (A.length i.val)) : + (@extendAxes K oldKeep keep N q oldq S A fixed hfixed).integerPoints = + S.integerPoints.image (axisInsertion oldKeep keep fixed) := by + classical + ext x + constructor + · intro hx + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hx + let t : ∀ i : {i // keep i}, Fin (S.length i) := fun i => + ⟨(j (axisInclusion oldKeep keep hsub i)).val, by + simpa [extendAxes, axisInclusion, i.property] using + (j (axisInclusion oldKeep keep hsub i)).isLt⟩ + refine Finset.mem_image.mpr ⟨S.integerPoint t, + Finset.mem_image.mpr ⟨t, Finset.mem_univ _, rfl⟩, ?_⟩ + funext i + by_cases hi : keep i.val + · simp [axisInsertion, integerPoint, point, extendAxes, hi, t, axisInclusion] + · have hj0 : (j i).val = 0 := by + have := (j i).isLt + simpa only [extendAxes, dite_eq_right hi, Nat.lt_one_iff] using this + have hf := (Finset.mem_Ico.mp (A.progression_inside i (hfixed ⟨i, hi⟩))).1 + simp [axisInsertion, integerPoint, point, extendAxes, hi, hj0, + Int.toNat_of_nonneg hf] + · intro hx + obtain ⟨y, hy, rfl⟩ := Finset.mem_image.mp hx + obtain ⟨t, _, rfl⟩ := Finset.mem_image.mp hy + let j : ∀ i, Fin ((@extendAxes K oldKeep keep N q oldq S A fixed hfixed).length i) := fun i => + if hi : keep i.val then + ⟨(t ⟨i.val, hi⟩).val, by + simp only [extendAxes, dite_eq_left hi] + exact (t ⟨i.val, hi⟩).isLt⟩ + else ⟨0, by simp [extendAxes, hi]⟩ + refine Finset.mem_image.mpr ⟨j, Finset.mem_univ _, ?_⟩ + funext i + by_cases hi : keep i.val + · simp [axisInsertion, integerPoint, point, extendAxes, hi, j] + · have hf := (Finset.mem_Ico.mp (A.progression_inside i (hfixed ⟨i, hi⟩))).1 + simp [axisInsertion, integerPoint, point, extendAxes, hi, j, + Int.toNat_of_nonneg hf] + +theorem expect_extendAxes + (S : ResidueBoxSlice (fun i : {i // keep i} => N i.val) q) + (A : ResidueBoxSlice (fun i : {i // oldKeep i} => N i.val) oldq) + (hsub : ∀ i, keep i → oldKeep i) + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) + (hfixed : ∀ i, fixed i ∈ integerProgressionSupport + (A.start i.val : ℤ) oldq (A.length i.val)) + {W : Type*} [AddCommMonoid W] [Module ℚ≥0 W] + (f : ({i // oldKeep i} → ℤ) → W) : + (𝔼 x ∈ (@extendAxes K oldKeep keep N q oldq S A fixed hfixed).integerPoints, f x) = + 𝔼 x ∈ S.integerPoints, f (axisInsertion oldKeep keep fixed x) := by + rw [S.extendAxes_integerPoints (N := N) A hsub fixed hfixed] + exact Finset.expect_image (axisInsertion_injective oldKeep keep hsub fixed).injOn + +theorem extendAxes_dense + (S : ResidueBoxSlice (fun i : {i // keep i} => N i.val) q) + (A : ResidueBoxSlice (fun i : {i // oldKeep i} => N i.val) oldq) + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) + (hfixed : ∀ i, fixed i ∈ integerProgressionSupport + (A.start i.val : ℤ) oldq (A.length i.val)) + (hq : 0 < q) {outCost shortCost : ℝ} + (hS : IsDenseCommonStrideBox (fun i : {i // keep i} => N i.val) + outCost S.integerPoints) + (hshort : ∀ i : {i // oldKeep i}, ¬keep i.val → + (N i.val : ℝ) ≤ Real.exp shortCost) : + IsDenseCommonStrideBox (fun i : {i // oldKeep i} => N i.val) + (max outCost shortCost) (@extendAxes K oldKeep keep N q oldq S A fixed hfixed).integerPoints := by + let T := @extendAxes K oldKeep keep N q oldq S A fixed hfixed + refine ⟨fun i => (T.start i : ℤ), q, T.length, hq, ?_, + T.progression_inside, ?_, T.integerPoints_eq_commonStrideBox⟩ + · intro i + by_cases hi : keep i.val + · simpa only [T, extendAxes, dite_eq_left hi] using S.length_pos_of_dense hS ⟨i.val, hi⟩ + · simp [T, extendAxes, hi] + · intro i + by_cases hi : keep i.val + · calc + _ ≤ Real.exp (-outCost) * (N i.val : ℝ) := + mul_le_mul_of_nonneg_right + (Real.exp_le_exp.mpr (neg_le_neg (le_max_left _ _))) (Nat.cast_nonneg _) + _ ≤ T.length i := by + simpa only [T, extendAxes, dite_eq_left hi] using + S.length_lower_of_dense hq hS ⟨i.val, hi⟩ + · simp only [T, extendAxes, dite_eq_right hi, Nat.cast_one] + calc + _ ≤ Real.exp (-shortCost) * (N i.val : ℝ) := + mul_le_mul_of_nonneg_right + (Real.exp_le_exp.mpr (neg_le_neg (le_max_right _ _))) (Nat.cast_nonneg _) + _ ≤ Real.exp (-shortCost) * Real.exp shortCost := + mul_le_mul_of_nonneg_left (hshort i hi) (Real.exp_pos _).le + _ = 1 := by rw [← Real.exp_add, neg_add_cancel, Real.exp_zero] + +theorem extendAxes_subset + (S : ResidueBoxSlice (fun i : {i // keep i} => N i.val) q) + (A : ResidueBoxSlice (fun i : {i // oldKeep i} => N i.val) oldq) + (hsub : ∀ i, keep i → oldKeep i) + (fixed : {i : {i // oldKeep i} // ¬keep i.val} → ℤ) + (hfixed : ∀ i, fixed i ∈ integerProgressionSupport + (A.start i.val : ℤ) oldq (A.length i.val)) + (hS : S.integerPoints ⊆ + (A.comap (axisInclusion oldKeep keep hsub)).integerPoints) : + (@extendAxes K oldKeep keep N q oldq S A fixed hfixed).integerPoints ⊆ A.integerPoints := by + rw [S.extendAxes_integerPoints (N := N) A hsub fixed hfixed] + intro x hx + obtain ⟨u, hu, rfl⟩ := Finset.mem_image.mp hx + apply (A.mem_integerPoints_iff _).mpr + have hu' := ((A.comap (axisInclusion oldKeep keep hsub)).mem_integerPoints_iff _).mp (hS hu) + intro i + by_cases hi : keep i.val + · simpa only [axisInsertion, dite_eq_left hi, comap, axisInclusion] using hu' ⟨i.val, hi⟩ + · simpa only [axisInsertion, dite_eq_right hi] using hfixed ⟨i, hi⟩ + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators Classical + +variable {I : Type*} [Fintype I] [DecidableEq I] {N : I → ℕ} {q : ℕ} + +theorem coordinate_complexMean + (A : ResidueBoxSlice N q) (hq : 0 < q) (hlength : ∀ i, 0 < A.length i) + (keep : I → Prop) (f : (I → ℤ) → ℂ) : + (𝔼 x ∈ A.integerPoints, f x) = + 𝔼 v : (∀ i : {i // ¬keep i}, Fin (A.length i)), + 𝔼 u ∈ (A.coordinateProjection keep).integerPoints, + f (finiteSplitPoint keep u + (fun i => ((A.start i + q * (v i).val : ℕ) : ℤ))) := by + let e := Equiv.piEquivPiSubtypeProd keep (fun i => Fin (A.length i)) + let : ∀ i, Nonempty (Fin (A.length i)) := fun i => ⟨⟨0, hlength i⟩⟩ + let fixedOf (v : ∀ i : {i // ¬keep i}, Fin (A.length i)) : {i // ¬keep i} → ℤ := + fun i => ((A.start i + q * (v i).val : ℕ) : ℤ) + have hsplit : (𝔼 j : (∀ i, Fin (A.length i)), f (A.integerPoint j)) = + 𝔼 v : (∀ i : {i // ¬keep i}, Fin (A.length i)), + 𝔼 u : (∀ i : {i // keep i}, Fin (A.length i)), + f (finiteSplitPoint keep ((A.coordinateProjection keep).integerPoint u) + (fixedOf v)) := by + calc + _ = 𝔼 uv : (∀ i : {i // keep i}, Fin (A.length i)) × + (∀ i : {i // ¬keep i}, Fin (A.length i)), + f (finiteSplitPoint keep ((A.coordinateProjection keep).integerPoint uv.1) + (fixedOf uv.2)) := by + apply Fintype.expect_equiv e + intro j + congr 1 + funext i + by_cases hi : keep i <;> + simp [e, integerPoint, point, coordinateProjection, comap, fixedOf, + finiteSplitPoint, hi, Equiv.piEquivPiSubtypeProd] + _ = _ := by + rw [← Finset.univ_product_univ, Finset.expect_product, Finset.expect_comm] + rw [A.expect_integerPoints hq f, hsplit] + apply Finset.expect_congr rfl + intro v _ + exact ((A.coordinateProjection keep).expect_integerPoints hq + (fun u => f (finiteSplitPoint keep u (fixedOf v)))).symm + +theorem exists_coordinate_fiber_norm + (A : ResidueBoxSlice N q) (hq : 0 < q) (hlength : ∀ i, 0 < A.length i) + (keep : I → Prop) (f : (I → ℤ) → ℂ) : + ∃ fixed : {i // ¬keep i} → ℤ, + (∀ i : {i // ¬keep i}, + fixed i ∈ integerProgressionSupport (A.start i : ℤ) q (A.length i)) ∧ + (∀ x ∈ (A.coordinateProjection keep).integerPoints, + finiteSplitPoint keep x fixed ∈ A.integerPoints) ∧ + ‖𝔼 x ∈ A.integerPoints, f x‖ ≤ + ‖𝔼 u ∈ (A.coordinateProjection keep).integerPoints, + f (finiteSplitPoint keep u fixed)‖ := by + let : ∀ i, Nonempty (Fin (A.length i)) := fun i => ⟨⟨0, hlength i⟩⟩ + let fixedOf (v : ∀ i : {i // ¬keep i}, Fin (A.length i)) : {i // ¬keep i} → ℤ := + fun i => ((A.start i + q * (v i).val : ℕ) : ℤ) + have hmean : ‖𝔼 x ∈ A.integerPoints, f x‖ ≤ + 𝔼 v : (∀ i : {i // ¬keep i}, Fin (A.length i)), + ‖𝔼 u ∈ (A.coordinateProjection keep).integerPoints, + f (finiteSplitPoint keep u (fixedOf v))‖ := by + rw [A.coordinate_complexMean hq hlength keep f] + exact RCLike.norm_expect_le (K := ℂ) + obtain ⟨v, _, hv⟩ := Finset.exists_le_of_le_expect Finset.univ_nonempty hmean + have hfixed (i : {i // ¬keep i}) : + fixedOf v i ∈ integerProgressionSupport (A.start i : ℤ) q (A.length i) := by + simpa only [fixedOf, Nat.cast_add, Nat.cast_mul] using + integerProgressionSupport_point (A.start i : ℤ) q (A.length i) hq + (v i).val (v i).isLt + exact ⟨fixedOf v, hfixed, + fun _ hx => A.finiteSplitPoint_mem_integerPoints keep (fixedOf v) hfixed hx, hv⟩ + +theorem exists_coordinate_fiber_correlation + (A : ResidueBoxSlice N q) (hq : 0 < q) (hlength : ∀ i, 0 < A.length i) + (keep : I → Prop) (f : (I → ℤ) → ℂ) {δ : ℝ} + (hmean : δ ≤ ‖𝔼 x ∈ A.integerPoints, f x‖) : + ∃ fixed : {i // ¬keep i} → ℤ, + (∀ i : {i // ¬keep i}, + fixed i ∈ integerProgressionSupport (A.start i : ℤ) q (A.length i)) ∧ + (∀ x ∈ (A.coordinateProjection keep).integerPoints, + finiteSplitPoint keep x fixed ∈ A.integerPoints) ∧ + δ ≤ ‖𝔼 u ∈ (A.coordinateProjection keep).integerPoints, + f (finiteSplitPoint keep u fixed)‖ := by + obtain ⟨fixed, hfixed, hinside, hnorm⟩ := + A.exists_coordinate_fiber_norm hq hlength keep f + exact ⟨fixed, hfixed, hinside, hmean.trans hnorm⟩ + +end Erdos3.ResidueBoxSlice + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBoxSliceSubtypeSites.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBoxSliceSubtypeSites.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fd75dbbbb22e8141980b5a82f2c2d1d6c21f9fd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueBoxSliceSubtypeSites.lean @@ -0,0 +1,115 @@ +import OAI.Combinatorics.Progressions.Estimates.LocalMajorSliceSites + +namespace OAI + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {N : I → ℕ} {q : ℕ} + +theorem integerPoints_subset_integerBox (A : ResidueBoxSlice N q) : + A.integerPoints ⊆ integerBox N := by + classical + intro x hx + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hx + apply (mem_integerBox N _).mpr + intro i + change 0 ≤ ((A.point j i).val : ℤ) ∧ ((A.point j i).val : ℤ) < (N i : ℤ) + exact ⟨Int.natCast_nonneg _, by exact_mod_cast (A.point j i).isLt⟩ + +noncomputable def subtypeSites (A : ResidueBoxSlice N q) : Finset ↥(integerBox N) := by + classical + exact Finset.univ.filter (fun x => x.val ∈ A.integerPoints) + +@[simp] theorem mem_subtypeSites (A : ResidueBoxSlice N q) (x : integerBox N) : + x ∈ A.subtypeSites ↔ x.val ∈ A.integerPoints := by + classical + simp only [subtypeSites, Finset.mem_filter, Finset.mem_univ, true_and] + +theorem subtypeSites_image_val (A : ResidueBoxSlice N q) : + A.subtypeSites.image Subtype.val = A.integerPoints := by + classical + ext x + constructor + · intro hx + obtain ⟨t, ht, rfl⟩ := Finset.mem_image.mp hx + exact (A.mem_subtypeSites t).mp ht + · intro hx + exact Finset.mem_image.mpr ⟨⟨x, A.integerPoints_subset_integerBox hx⟩, + (A.mem_subtypeSites _).mpr hx, rfl⟩ + +theorem expect_subtypeSites (A : ResidueBoxSlice N q) + {V : Type*} [AddCommMonoid V] [Module ℚ≥0 V] (f : (I → ℤ) → V) : + (𝔼 t ∈ A.subtypeSites, f t.val) = 𝔼 x ∈ A.integerPoints, f x := by + classical + rw [← A.subtypeSites_image_val] + exact (Finset.expect_image Subtype.val_injective.injOn).symm + +theorem subtypeSites_nonempty_of_integerPoints (A : ResidueBoxSlice N q) + (h : A.integerPoints.Nonempty) : A.subtypeSites.Nonempty := by + classical + rw [← A.subtypeSites_image_val, Finset.image_nonempty] at h + exact h + +theorem subtypeSites_nonempty (A : ResidueBoxSlice N q) (hA : ∀ i, 0 < A.length i) : + A.subtypeSites.Nonempty := by + classical + apply A.subtypeSites_nonempty_of_integerPoints + let j : ∀ i, Fin (A.length i) := fun i => ⟨0, hA i⟩ + exact ⟨A.integerPoint j, Finset.mem_image.mpr ⟨j, Finset.mem_univ _, rfl⟩⟩ + +theorem subtypeSites_dense (A : ResidueBoxSlice N q) {cost : ℝ} + (h : IsDenseCommonStrideBox N cost A.integerPoints) : + IsDenseCommonStrideBox N cost (A.subtypeSites.image Subtype.val) := by + classical + rw [A.subtypeSites_image_val] + exact h + +end Erdos3.ResidueBoxSlice + +namespace Erdos3 + +open scoped BigOperators TensorProduct + +theorem productive_localMajorSubtypeSlice_mass_le_sampledSliceSeminorm + {Ω I X L : Type*} [Fintype Ω] [Fintype I] [DecidableEq I] + [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {J : Ω → Type*} (D : RationalFilteredNilmanifold L s d) + (law : FiniteProbabilityWeights Ω) (good : Finset Ω) + (N : I → ℕ) (hN : ∀ i, 0 < N i) + (q : ∀ z, J z → ℕ) (A : ∀ z j, ResidueBoxSlice N (q z j)) + (tests : ∀ z, J z → D.Niltest (fun _ : I => 1)) + (physical : Ω → ↥(integerBox N) → X) (signal : X → ℂ) (cost : ℝ) + (hdense : ∀ z j, IsDenseCommonStrideBox N cost (A z j).integerPoints) + (hcap : ∀ z j, ((tests z j).normBound : ℝ) ≤ 1) + (hcorr : ∀ z ∈ good, ∃ j : J z, + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ (A z j).subtypeSites, + signal (physical z x) * star ((tests z j).eval + (commonStrideIndex (fun i => ((A z j).start i : ℤ)) (q z j) x.val))‖) : + (9 / 10 : ℝ) * law.mass good ≤ sampledSliceSeminorm law physical + (fun z j => (A z j).subtypeSites) + (fun z j x => star ((tests z j).eval + (commonStrideIndex (fun i => ((A z j).start i : ℤ)) (q z j) x.val))) signal := by + classical + let : Nonempty ↥(integerBox N) := ⟨⟨fun _ => 0, (mem_integerBox N _).mpr + (fun i => ⟨le_rfl, by exact_mod_cast hN i⟩)⟩⟩ + apply productive_mass_mul_le_sampledSliceSeminorm law good physical + (fun z j => (A z j).subtypeSites) + (fun z j x => star ((tests z j).eval + (commonStrideIndex (fun i => ((A z j).start i : ℤ)) (q z j) x.val))) + (fun z j => (A z j).subtypeSites_nonempty_of_integerPoints (hdense z j).nonempty) + _ signal (9 / 10) hcorr + intro z j x + simpa only [norm_star] using ((tests z j).norm_eval_le + (commonStrideIndex (fun i => ((A z j).start i : ℤ)) (q z j) x.val)).trans (hcap z j) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCellNormLengths.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCellNormLengths.lean new file mode 100644 index 0000000000000000000000000000000000000000..10b13486b884e9edebaf409fd467e0f142e90f1f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCellNormLengths.lean @@ -0,0 +1,428 @@ +import OAI.Combinatorics.Progressions.Estimates.StableReferenceMean +import OAI.Combinatorics.Progressions.Lattices.AffineResidueAccuracy +import OAI.Combinatorics.Progressions.Polynomial.CappedSectionLowDegree + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι σ : Type*} [Fintype ι] [LinearOrder ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (moduli : ι → ℕ) [∀ i, NeZero (moduli i)] + (f : (σ → ℤ) → ℝ) (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z ∧ f z ≤ 1) + +include hf + +theorem residuePrimeDensity_scaled_section_low_degree {scale cap η P : ℝ} + (hscale : 0 < scale) (hcap : 0 ≤ cap) (hinv : scale⁻¹ ≤ cap) + {r q k : ℕ} (hq : 2 ≤ q) (heven : Even q) (A : Finset ι) + (hAr : A.card ≤ r) (hk : k ≤ r - A.card) (z : ∀ i, σ → ZMod (moduli i)) + (hη : 0 ≤ η) (hrP : (r : ℝ) ≤ P) (hlog : Real.log (2 + cap) ≤ P) + (hPq : P ≤ (q : ℝ)) (hqP : (q : ℝ) ≤ P + 2) + (hsmall : η ≤ (1 / 2) * (((2 : ℝ) ^ (r + 1) * (2 + (Fintype.card ι : ℝ)) ^ r * (2 + cap)) ^ q)⁻¹) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) moduli) + (residuePrimeCoordinateDensity lo N M a hne moduli (fun _ => 1)) η (r * (q + 1))) + (hbound : ProductBoundedMarginals (primeCoordinateReference (σ := σ) moduli) + (normalizedResiduePrimeDensity lo N M a hne moduli f scale) 1 r) : + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) moduli) (Finset.univ.powersetCard k) + (fun y => scale⁻¹ * productSectionAverage (primeCoordinateReference (σ := σ) moduli) A A z + (residuePrimeCoordinateDensity lo N M a hne moduli f) y)) ≤ (16 * (P + 2)) ^ (2 * k) := by + let := hne + have hphys : ∀ z : IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a, + 0 ≤ f (fun j => (z j).val) ∧ f (fun j => (z j).val) ≤ 1 := by + intro z + apply hf + apply (mem_translatedIntegerBox lo N _).mpr + intro j + exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (z j).property).1) + exact observedProductDensity_scaled_section_low_degree (primeCoordinateReference (σ := σ) moduli) + (FiniteProbabilityWeights.uniform (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (fun z => primeCoordinateObservation moduli (fun j => (z j).val)) (fun z => f (fun j => (z j).val)) + hphys hscale hcap hinv hq heven A A le_rfl hAr hk z + (Finset.prod_pos (fun i _ => primeCoordinateReference_weight_pos moduli i (z i))).ne' + hη hrP hlog hPq hqP hsmall hclose hbound + +theorem residuePrimeDensity_scaled_section_norm {scale cap η : ℝ} + (hscale : 0 < scale) (hinv : scale⁻¹ ≤ cap) (A : Finset ι) (z : ∀ i, σ → ZMod (moduli i)) + (hη0 : 0 ≤ η) (hη1 : η ≤ 1) (D : Finset (Finset ι)) {b : ℕ} + (hcard : ∀ S ∈ D, S.card ≤ b) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) moduli) + (residuePrimeCoordinateDensity lo N M a hne moduli (fun _ => 1)) η (2 * b + A.card)) + (herr : 2 * η * (D.card : ℝ) ^ 2 * (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ 1) : + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) moduli) D + (fun y => scale⁻¹ * productSectionAverage (primeCoordinateReference (σ := σ) moduli) A A z + (residuePrimeCoordinateDensity lo N M a hne moduli f) y)) ≤ 3 * cap := by + let := hne + have hphys : ∀ z : IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a, + 0 ≤ f (fun j => (z j).val) ∧ f (fun j => (z j).val) ≤ 1 := by + intro z + apply hf + apply (mem_translatedIntegerBox lo N _).mpr + intro j + exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (z j).property).1) + exact observedProductDensity_scaled_section_norm (primeCoordinateReference (σ := σ) moduli) + (FiniteProbabilityWeights.uniform (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (fun z => primeCoordinateObservation moduli (fun j => (z j).val)) (fun z => f (fun j => (z j).val)) + hphys hscale hinv A A le_rfl z + (Finset.prod_pos (fun i _ => primeCoordinateReference_weight_pos moduli i (z i))).ne' + hη0 hη1 D hcard hclose herr + +theorem residuePrimeDensity_section_norm_le_three (A : Finset ι) (z : ∀ i, σ → ZMod (moduli i)) + {η : ℝ} (hη0 : 0 ≤ η) (hη1 : η ≤ 1) (D : Finset (Finset ι)) {b : ℕ} + (hcard : ∀ S ∈ D, S.card ≤ b) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) moduli) + (residuePrimeCoordinateDensity lo N M a hne moduli (fun _ => 1)) η (2 * b + A.card)) + (herr : 2 * η * (D.card : ℝ) ^ 2 * (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ 1) : + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) moduli) D + (productSectionAverage (primeCoordinateReference (σ := σ) moduli) A A z + (residuePrimeCoordinateDensity lo N M a hne moduli f))) ≤ 3 := by + let := hne + have hphys : ∀ z : IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a, + 0 ≤ f (fun j => (z j).val) ∧ f (fun j => (z j).val) ≤ 1 := by + intro z + apply hf + apply (mem_translatedIntegerBox lo N _).mpr + intro j + exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (z j).property).1) + exact observedProductDensity_section_norm_le_three (primeCoordinateReference (σ := σ) moduli) + (FiniteProbabilityWeights.uniform (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (fun z => primeCoordinateObservation moduli (fun j => (z j).val)) (fun z => f (fun j => (z j).val)) + hphys A A le_rfl z + (Finset.prod_pos (fun i _ => primeCoordinateReference_weight_pos moduli i (z i))).ne' + hη0 hη1 D hcard hclose herr + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem productSectionAverage_empty_fixed {ι : Type*} [Fintype ι] [DecidableEq ι] + {X : ι → Type*} [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + (z : ∀ i, X i) (f : (∀ i, X i) → ℝ) : productSectionAverage μ ∅ ∅ z f = f := by + funext x + have hm (u v : ∀ i, X i) : productCoordinateMix (∅ : Finset ι) u v = v := by + funext i + simp [productCoordinateMix] + simp only [productSectionAverage, hm] + exact (FiniteProbabilityWeights.pi μ).mean_const _ + +theorem residuePrimeDensity_norm_le_three {ι σ : Type*} + [Fintype ι] [LinearOrder ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (f : (σ → ℤ) → ℝ) + (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z ∧ f z ≤ 1) + {η : ℝ} (hη0 : 0 ≤ η) (hη1 : η ≤ 1) (D : Finset (Finset ι)) {b : ℕ} + (hcard : ∀ S ∈ D, S.card ≤ b) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1)) η (2 * b)) + (herr : 2 * η * (D.card : ℝ) ^ 2 * (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ 1) : + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) q) D + (residuePrimeCoordinateDensity lo N M a hne q f)) ≤ 3 := by + have h := residuePrimeDensity_section_norm_le_three lo N M a hne q f hf ∅ (fun _ _ => 0) + hη0 hη1 D hcard (by simpa only [Finset.card_empty, add_zero] using hclose) herr + rw [productSectionAverage_empty_fixed] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residuePrimeCoordinateMassRatio_nonneg {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (q : ι → ℕ) [∀ i, NeZero (q i)] (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + 0 ≤ residuePrimeCoordinateMassRatio lo N M a q I x := by + rw [residuePrimeCoordinateMassRatio_eq_count] + positivity + +theorem residuePrimeCoordinateMassRatio_outside {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (S : Finset {i // i ∉ K}) (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) : + residuePrimeCoordinateMassRatio lo N M a q (K ∪ S.image Subtype.val) x = + residuePrimeCoordinateMassRatio lo N M a q K base * + residuePrimeCoordinateMassRatio lo N (M.lcm (∏ i ∈ K, q i)) (fun j => (u.val j).val) + (fun i : {i // i ∉ K} => q i.val) S (fun i => x i.val) := by + classical + have hdis : Disjoint K (S.image Subtype.val) := by + apply Finset.disjoint_left.mpr + intro i hi hj + obtain ⟨j, _, heq⟩ := Finset.mem_image.mp hj + exact j.property (heq ▸ hi) + have hprod : (∏ i ∈ K ∪ S.image Subtype.val, q i) = + (∏ i ∈ K, q i) * (∏ i ∈ S, q i.val) := by + rw [Finset.prod_union hdis, Finset.prod_image] + intro i _ j _ hij + exact Subtype.ext hij + have hc := Fintype.card_congr (residuePrimeCoordinateOutsideEquiv lo N M a q hpair K base u S x hx) + have hb := Fintype.card_congr (residuePrimeCoordinateCell_lcmEquiv lo N M a q hpair K base u) + let : Nonempty (ResiduePrimeCoordinateCell lo N M a q K base) := ⟨u⟩ + let : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a) := ⟨u.val⟩ + have hK : (Fintype.card (ResiduePrimeCoordinateCell lo N M a q K base) : ℝ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero (α := ResiduePrimeCoordinateCell lo N M a q K base) + have hB : (Fintype.card (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a) : ℝ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero (α := IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a) + rw [residuePrimeCoordinateMassRatio_eq_count, residuePrimeCoordinateMassRatio_eq_count, + residuePrimeCoordinateMassRatio_eq_count, hprod, Nat.cast_mul, mul_pow, hc, ← hb] + field_simp + +theorem residuePrimeCoordinateDensity_conditional_outside {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (f : (σ → ℤ) → ℝ) (S : Finset {i // i ∉ K}) + (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) : + productConditionalMean (primeCoordinateReference (σ := σ) q) (K ∪ S.image Subtype.val) + (residuePrimeCoordinateDensity lo N M a hne q f) x = + residuePrimeCoordinateMassRatio lo N M a q K base * + productConditionalMean (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) S + (residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) (fun j => (u.val j).val) + (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f) (fun i => x i.val) := by + have hm := Fintype.expect_equiv (residuePrimeCoordinateOutsideEquiv lo N M a q hpair K base u S x hx) + (fun z => f (fun j => (z.val j).val)) (fun z => f (fun j => (z.val j).val)) (fun _ => rfl) + rw [residuePrimeCoordinateDensity_conditional, residuePrimeCoordinateDensity_conditional, + residuePrimeCoordinateMassRatio_outside lo N M a q hpair K base u S x hx, hm, mul_assoc] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem retained_residue_marginals_of_lengths {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + [∀ i, NeZero (q i)] (hM : 0 < M) (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) (hcop : ∀ i ∉ K, M.Coprime (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (R : ℕ) (B C D η : ℝ) (hB : 0 ≤ B) (hη : η ≤ 1) (herror : Real.exp (-D) ≤ η) + (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp B) + (hdim : (Fintype.card σ : ℝ) ≤ Real.exp C) + (hlength : ∀ k, Real.exp (B * R + D + C + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) : + ProductMarginalsClose (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) (fun k => (u.val k).val) + (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) (fun _ => 1)) η R ∧ + ∀ S : Finset {i // i ∉ K}, S.card ≤ R → + 2 * (∑ k, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val)) ≤ η := by + have hQ : 0 < M.lcm (∏ i ∈ K, q i) := + Nat.pos_of_ne_zero (Nat.lcm_ne_zero hM.ne' + (Finset.prod_pos (fun i _ => Nat.pos_of_ne_zero (NeZero.ne (q i)))).ne') + have hQcop : ∀ i : {i // i ∉ K}, (M.lcm (∏ k ∈ K, q k)).Coprime (q i.val) := + fun i => selectedCombined_coprime_outside q hpair M K hcop i.val i.property + have hpair' : Pairwise (fun i k : {i // i ∉ K} => (q i.val).Coprime (q k.val)) := + fun i k hik => hpair (fun heq => hik (Subtype.ext heq)) + have hne := residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u + have hmods := fun i : {i // i ∉ K} => hmoduli i.val i.property + refine ⟨?_, ?_⟩ + · exact residuePrimeDensity_close_of_lengths (ι := {i // i ∉ K}) (σ := σ) + lo N (M.lcm (∏ i ∈ K, q i)) (fun k => (u.val k).val) hne + (fun i : {i // i ∉ K} => q i.val) hQ hQcop hpair' + R B C D η hB hη herror hmods hdim hlength + · intro S hS + exact (primeCoordinate_error_le_exp (fun i : {i // i ∉ K} => q i.val) + (fun k => residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val)) + R B C D hB hmods hdim hlength S hS).trans herror + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def residueCellOutsideDensity {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + [∀ i, NeZero (q i)] (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) (f : (σ → ℤ) → ℝ) : + (∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) → ℝ := + observedProductDensity (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (@FiniteProbabilityWeights.uniform (ResiduePrimeCoordinateCell lo N M a q K base) _ ⟨u⟩) + (fun z => primeCoordinateObservation (fun i : {i // i ∉ K} => q i.val) (fun k => (z.val k).val)) + (fun z => f (fun k => (z.val k).val)) + +theorem residueCellOutsideDensity_lcm {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + [∀ i, NeZero (q i)] (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) (f : (σ → ℤ) → ℝ) : + residueCellOutsideDensity lo N M a q K base u f = + residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) (fun k => (u.val k).val) + (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f := by + let : Nonempty (ResiduePrimeCoordinateCell lo N M a q K base) := ⟨u⟩ + let := residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u + exact uniform_observedProductDensity_source_equiv + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (residuePrimeCoordinateCell_lcmEquiv lo N M a q hpair K base u) + (fun z => primeCoordinateObservation (fun i : {i // i ∉ K} => q i.val) (fun k => (z k).val)) + (fun z => f (fun k => (z k).val)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem PrimeRefinementUpperBound.reference_density_upper {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} + [∀ i, NeZero (q i)] {r : ℕ} {level ε δ : ℝ} {K : Finset ι} + {base : ∀ i, σ → ZMod (q i)} + (hupper : PrimeRefinementUpperBound h g lo N M a q r level ε δ K base) + (hM : 0 < M) (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (hcop : ∀ i ∉ K, M.Coprime (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (C : ℝ) (hC : 0 ≤ C) (hh : ∀ z ∈ translatedIntegerBox lo N, |(h z).re| ≤ C) + (S : Finset {i // i ∉ K}) (hS : S.card ≤ r) + (x : ∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) + (hsmall : (∑ j, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) (M.lcm (∏ i ∈ K, q i)) ((u.val j).val)) < 1 / 2) : + productConditionalMean (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) S + (residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) (fun j => (u.val j).val) + (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) (fun z => (h z).re)) x ≤ + level * (residuePrimeCoordinateMean g lo N M a q K base).re + ε + level * δ + + (2 * ∑ j, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) (M.lcm (∏ i ∈ K, q i)) ((u.val j).val)) * C := by + have hQ : 0 < M.lcm (∏ i ∈ K, q i) := + Nat.pos_of_ne_zero (Nat.lcm_ne_zero hM.ne' + (Finset.prod_pos (fun i _ => Nat.pos_of_ne_zero (NeZero.ne (q i)))).ne') + have hQcop : ∀ i : {i // i ∉ K}, (M.lcm (∏ k ∈ K, q k)).Coprime (q i.val) := + fun i => selectedCombined_coprime_outside q hpair M K hcop i.val i.property + have hpair' : Pairwise (fun i j : {i // i ∉ K} => (q i.val).Coprime (q j.val)) := + fun i j hij => hpair (fun heq => hij (Subtype.ext heq)) + have hbase := residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u + have hne := residuePrimeCoordinateCell_nonempty_of_small lo N (M.lcm (∏ i ∈ K, q i)) + (fun j => (u.val j).val) hbase (fun i : {i // i ∉ K} => q i.val) hQ hQcop hpair' S x hsmall + have hu := hupper.outside hpair u S hS x hne + have he := residuePrimeCoordinateDensity_conditional_error lo N (M.lcm (∏ i ∈ K, q i)) + (fun j => (u.val j).val) hbase (fun i : {i // i ∉ K} => q i.val) hQ hQcop hpair' + (fun z => (h z).re) C hC hh S x hsmall.le + rw [← residuePrimeCoordinateMean_re] at he + have he' := (abs_le.mp he).2 + linarith + +theorem PrimeRefinementUpperBound.reference_conditioned_upper {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} + [∀ i, NeZero (q i)] {r : ℕ} {level ε δ : ℝ} {K : Finset ι} + {base : ∀ i, σ → ZMod (q i)} + (hupper : PrimeRefinementUpperBound h g lo N M a q r level ε δ K base) + (hM : 0 < M) (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (hcop : ∀ i ∉ K, M.Coprime (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (C : ℝ) (hC : 0 ≤ C) (hh : ∀ z ∈ translatedIntegerBox lo N, |(h z).re| ≤ C) + (S : Finset {i // i ∉ K}) (hS : S.card ≤ r) + (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) + (hsmall : (∑ j, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) (M.lcm (∏ i ∈ K, q i)) ((u.val j).val)) < 1 / 2) : + productConditionalMean (primeCoordinateReference (σ := σ) q) (K ∪ S.image Subtype.val) + (residuePrimeCoordinateDensity lo N M a ⟨u.val⟩ q (fun z => (h z).re)) x ≤ + residuePrimeCoordinateMassRatio lo N M a q K base * + (level * (residuePrimeCoordinateMean g lo N M a q K base).re + ε + level * δ + + (2 * ∑ j, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) (M.lcm (∏ i ∈ K, q i)) ((u.val j).val)) * C) := by + rw [residuePrimeCoordinateDensity_conditional_outside lo N M a ⟨u.val⟩ q hpair K base u + (fun z => (h z).re) S x hx] + exact mul_le_mul_of_nonneg_left + (hupper.reference_density_upper hM hpair hcop u C hC hh S hS (fun i => x i.val) hsmall) + (residuePrimeCoordinateMassRatio_nonneg lo N M a q K base) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residueCellOutsideDensity_norm_of_lengths {ι σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) [∀ i, NeZero (q i)] + (hM : 0 < M) (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) (hcop : ∀ i ∉ K, M.Coprime (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) (f : (σ → ℤ) → ℝ) + (hf : ∀ z : ResiduePrimeCoordinateCell lo N M a q K base, + 0 ≤ f (fun k => (z.val k).val) ∧ f (fun k => (z.val k).val) ≤ 1) + (B : ℕ) (P modLog dimLog : ℝ) (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hmoduli : ∀ i ∉ K, (q i : ℝ) ≤ Real.exp modLog) + (hdim : (Fintype.card σ : ℝ) ≤ Real.exp dimLog) + (hlength : ∀ k, Real.exp (modLog * (2 * B : ℕ) + affineComparisonAccuracyLog B P 0 0 + dimLog + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val) : ℝ)) : + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (lowDegreeCoordinateSets {i // i ∉ K} B) (residueCellOutsideDensity lo N M a q K base u f)) ≤ 3 := by + let η := affineComparisonAccuracy B P 0 0 + let μ := primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) + let p := @FiniteProbabilityWeights.uniform (ResiduePrimeCoordinateCell lo N M a q K base) _ ⟨u⟩ + let F := fun z : ResiduePrimeCoordinateCell lo N M a q K base => + primeCoordinateObservation (fun i : {i // i ∉ K} => q i.val) (fun k => (z.val k).val) + have he := affineComparisonAccuracy_bounds (level := 1) (L := 0) (T := 0) B hP (by norm_num) (by norm_num) (by norm_num) + have hcount' : (Fintype.card {i // i ∉ K} : ℝ) ≤ Real.exp P := + (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans hcount + have hgram : 2 * η * ((lowDegreeCoordinateSets {i // i ∉ K} B).card : ℝ) ^ 2 * + (4 : ℝ) ^ B * (1 + η) ^ 2 ≤ 1 := by + simpa only [neg_zero, Real.exp_zero] using + affineComparisonAccuracy_gram (ι := {i // i ∉ K}) (L := 0) (T := 0) B hP (by norm_num) (by norm_num) hcount' + have hbase0 := retained_residue_marginals_of_lengths (ι := ι) (σ := σ) + lo N M a q hM hpair K base hcop u (2 * B) modLog dimLog (affineComparisonAccuracyLog B P 0 0) η + have herror : Real.exp (-affineComparisonAccuracyLog B P 0 0) ≤ η := by + unfold η affineComparisonAccuracy + exact le_rfl + have hbase := (hbase0 hmodLog he.2.1.le herror hmoduli hdim hlength).1 + have hclose : ProductMarginalsClose μ (residueCellOutsideDensity lo N M a q K base u (fun _ => 1)) η (2 * B) := by + rw [residueCellOutsideDensity_lcm lo N M a q hpair K base u] + exact hbase + change ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η (2 * B) at hclose + have hz : (FiniteProbabilityWeights.pi μ).weight (fun _ _ => 0) ≠ 0 := + (Finset.prod_pos (fun i _ => primeCoordinateReference_weight_pos (fun i : {i // i ∉ K} => q i.val) i (fun _ => 0))).ne' + have hn := observedProductDensity_section_norm_le_three μ p F (fun z => f (fun k => (z.val k).val)) hf + ∅ ∅ (Finset.Subset.refl ∅) (fun _ _ => 0) hz he.1.le he.2.1.le + (lowDegreeCoordinateSets {i // i ∉ K} B) (fun S hS => (mem_lowDegreeCoordinateSets _ _ S).mp hS) + (by simpa only [Finset.card_empty, add_zero] using hclose) hgram + rw [productSectionAverage_empty_fixed] at hn + exact hn + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCellPairCancellation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCellPairCancellation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3d57d24cd6bbfab6c48ebb6f524b61813f23a50 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCellPairCancellation.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.Progressions.Probability.ObservedProductDensity + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residue_cell_pair_cancellation {A B R : Type*} [Fintype A] [Fintype B] + [Fintype R] [Nonempty R] (p : FiniteProbabilityWeights A) (q : FiniteProbabilityWeights B) + (e : A → R → ℝ) (d : B → R → ℝ) (Phi : A → B → R → ℝ) + {delta gamma L : ℝ} (hdelta : 0 ≤ delta) (hL : 0 ≤ L) + (he : ∀ a r, |e a r| ≤ delta / Fintype.card R) + (hd : ∀ b r, |d b r| ≤ gamma / Fintype.card R) + (hPhi : ∀ a b r, |Phi a b r| ≤ L) : + |(Fintype.card R : ℝ) * ∑ r, p.mean (fun a => q.mean (fun b => Phi a b r * e a r * d b r))| ≤ + L * delta * gamma := by + let K : ℝ := Fintype.card R + have hK : 0 < K := by dsimp only [K]; exact_mod_cast Fintype.card_pos + have hterm (a : A) (b : B) (r : R) : |Phi a b r * e a r * d b r| ≤ + L * (delta / K) * (gamma / K) := by + rw [abs_mul, abs_mul] + exact mul_le_mul (mul_le_mul (hPhi a b r) (he a r) (abs_nonneg _) hL) + (hd b r) (abs_nonneg _) (mul_nonneg hL (div_nonneg hdelta hK.le)) + have hmean (r : R) : |p.mean (fun a => q.mean (fun b => Phi a b r * e a r * d b r))| ≤ + L * (delta / K) * (gamma / K) := by + apply p.abs_mean_le_on_support + intro a _ + apply q.abs_mean_le_on_support + intro b _ + exact hterm a b r + change |K * ∑ r, p.mean (fun a => q.mean (fun b => Phi a b r * e a r * d b r))| ≤ _ + rw [abs_mul, abs_of_pos hK] + calc + _ ≤ K * ∑ r, |p.mean (fun a => q.mean (fun b => Phi a b r * e a r * d b r))| := + mul_le_mul_of_nonneg_left (Finset.abs_sum_le_sum_abs _ _) hK.le + _ ≤ K * ∑ _r : R, L * (delta / K) * (gamma / K) := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun r _ => hmean r)) hK.le + _ = L * delta * gamma := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + change K * (K * (L * (delta / K) * (gamma / K))) = _ + field_simp [hK.ne'] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCoefficientFamily.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCoefficientFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..898ba0586799bfc345dc3555414d8076e6ded0d3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCoefficientFamily.lean @@ -0,0 +1,319 @@ +import OAI.Combinatorics.Progressions.Dynamics.JointPivotProfileBudget +import OAI.Combinatorics.Progressions.Linear.KernelCoefficientDensity +import OAI.Combinatorics.Progressions.Sampling.CoefficientGridRate + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def coefficientLogAllowance (j d : ℕ) (b : ℝ) : ℝ := + 2*(j : ℝ)^2 + (2*j+4)*b + (j+2*d)*(b+4) + 4 + +theorem coefficientMeshConstant_le_exp (j d : ℕ) {R C b : ℝ} (K : ℝ≥0) + (hb : 0 ≤ b) (hR0 : 0 ≤ R) (hC0 : 0 ≤ C) + (hR : R ≤ Real.exp b) (hC : C ≤ Real.exp b) (hK : (K : ℝ) ≤ Real.exp b) : + 2 * (1 + (2*R+2)^(j+d) * K) * (j.factorial * C^j) ≤ + Real.exp (coefficientLogAllowance j d b) := by + have hone : 1 ≤ Real.exp b := Real.one_le_exp_iff.mpr hb + have hfour : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have hbox : 2*R+2 ≤ Real.exp (b+4) := by + rw [Real.exp_add] + nlinarith [mul_le_mul_of_nonneg_left hfour (Real.exp_pos b).le] + let Q := ((j : ℝ)+d)*(b+4)+b + have hQ : 0 ≤ Q := by dsimp [Q]; positivity + have hterm : (2*R+2)^(j+d) * K ≤ Real.exp Q := by + calc + _ ≤ (Real.exp (b+4))^(j+d) * Real.exp b := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add]; simp only [Q, Nat.cast_add] + have hD : (j.factorial : ℝ)*C^j ≤ Real.exp ((j : ℝ)^2+j*b) := by + calc + _ ≤ Real.exp ((j : ℝ)^2)*(Real.exp b)^j := by gcongr; exact factorial_le_exp_sq j + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add] + have hfront : 2 * (1 + (2*R+2)^(j+d) * K) ≤ Real.exp (Q+4) := by + calc + _ ≤ 4*Real.exp Q := by linarith [Real.one_le_exp_iff.mpr hQ] + _ ≤ Real.exp Q * Real.exp 4 := by nlinarith [Real.exp_pos Q] + _ = _ := (Real.exp_add _ _).symm + calc + _ ≤ Real.exp (Q+4)*Real.exp ((j : ℝ)^2+j*b) := + mul_le_mul hfront hD (by positivity) (Real.exp_pos _).le + _ = Real.exp (Q+4+((j : ℝ)^2+j*b)) := (Real.exp_add _ _).symm + _ ≤ _ := by + apply Real.exp_le_exp.mpr + dsimp only [Q, coefficientLogAllowance] + nlinarith [sq_nonneg (j : ℝ), + mul_nonneg (show (0 : ℝ) ≤ j+3 by positivity) hb, + mul_nonneg (show (0 : ℝ) ≤ d by positivity) (show 0 ≤ b+4 by positivity)] + +theorem enormousCoefficient_tolerance_arithmetic {D H ε : ℝ} + (hD : 0 ≤ D) (hH : 0 < H) (hε : 0 < ε) + (hlarge : D * (1 + ε⁻¹) ≤ H) : D ≤ H ∧ D / H ≤ ε := by + have hmul : 0 ≤ D * ε⁻¹ := by positivity + constructor + · nlinarith + · apply (div_le_iff₀ hH).mpr + have h := mul_le_mul_of_nonneg_right hlarge hε.le + have he : D * (1+ε⁻¹) * ε = D*ε+D := by + field_simp + rw [he] at h + nlinarith [mul_nonneg hD hε.le] + +theorem affineCoefficientImage_tolerance {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (s : I ↪ J) (S : J → ℝ) (hS : ∀ j, 0 < S j) + {H L C U G : ℝ} (h : ℕ) (ctrl : CoefficientFiberControl A s S H L h C U G) + (hL : 0 < L) (hH : 0 < H) (hC0 : 0 ≤ C) (hU0 : 0 ≤ U) (hG0 : 0 ≤ G) + (c w : J → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w j) {R : ℝ} (hR0 : 0 ≤ R) (hsupport : ∀ j, |c j| + w j ≤ R) + {b t ε : ℝ} (hb : 0 ≤ b) (ht : 0 ≤ t) (hε : 0 < ε) + (hG : G ≤ Real.exp b) (hU : U ≤ Real.exp b) (hC : C ≤ Real.exp b) (hR : R ≤ Real.exp b) + (hi : (δ : ℝ)⁻¹ ≤ Real.exp t) + (hlarge : Real.exp (coefficientLogAllowance (Fintype.card I) (Fintype.card (UnselectedColumn s)) + (affineCoefficientCommonBudget (Fintype.card J) (Fintype.card (UnselectedColumn s)) b t)) * + (1+ε⁻¹) * L^(h*(Fintype.card I+1)) ≤ H) : + ∃ hZ : 0 < coefficientWeightSum (affineProductProfile c w) S, ∀ v, + |H ^ Fintype.card I * + (coefficientImagePMF A (affineProductProfile c w) (affineProductProfile_nonneg c w hw) + S hS (affineProductProfile_zero_outside c w hw hR0 hsupport) hZ v).toReal - + coefficientImageMask A (fun _ => H) + (selectedCoefficientDensity A s ctrl.det_ne_zero S (fun _ => H) hS (fun _ => hH) + (affineProductProfile c w)) v| ≤ ε := by + let j := Fintype.card I + let d := Fintype.card (UnselectedColumn s) + let B := affineCoefficientCommonBudget (Fintype.card J) d b t + let E := coefficientLogAllowance j d B + have hB : 0 ≤ B := affineCoefficientCommonBudget_nonneg _ _ hb ht + have hbounds := affineCoefficientCommonBudget_bounds (Fintype.card J) d hb ht + have hbB : Real.exp b ≤ Real.exp B := Real.exp_le_exp.mpr hbounds.1 + have hK : (affineProductProfileLip J δ : ℝ) ≤ Real.exp B := + (affineProductProfileLip_le_exp J hi).trans (Real.exp_le_exp.mpr hbounds.2.1) + have hmesh := coefficientMeshConstant_le_exp j d (affineProductProfileLip J δ) + hB hR0 hC0 (hR.trans hbB) (hC.trans hbB) hK + have herror := affineCoefficientConstants_le_exp j d J hδ hb ht hi hG0 hU0 hC0 hR0 hG hU hC hR + have hscale : (Real.exp E * L^(h*(j+1))) * (1+ε⁻¹) ≤ H := by + calc + _ = Real.exp E * (1+ε⁻¹) * L^(h*(j+1)) := by ring + _ ≤ H := hlarge + have harith := enormousCoefficient_tolerance_arithmetic (by positivity) hH hε hscale + have hready : 2 * (1+(2*R+2)^(j+d)*affineProductProfileLip J δ) * (j.factorial*C^j) * + L^(h*(j+1)) ≤ H := + (mul_le_mul_of_nonneg_right hmesh (by positivity)).trans harith.1 + obtain ⟨hZ, herr⟩ := affineCoefficientImage_enormous_error A s S hS h ctrl hL hH hC0 c w hw + hδ hwidth hR0 hsupport hready + refine ⟨hZ, fun v => (herr v).trans ?_⟩ + exact (div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right herror (by positivity)) hH.le).trans harith.2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def coefficientReplacementScale {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (b t ε L : ℝ) (h : ℕ) : ℝ := + Real.exp (coefficientLogAllowance (Fintype.card I) (Fintype.card (UnselectedColumn s)) + (affineCoefficientCommonBudget (Fintype.card J) (Fintype.card (UnselectedColumn s)) b t)) * + (1+ε⁻¹) * L^(h*(Fintype.card I+1)) + +theorem affineCoefficientImage_residue_tolerance {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) (C : Matrix I N ℤ) + (S : J → ℝ) (T : N → ℝ) (hS : ∀ j, 0 < S j) (hT : ∀ n, 0 < T n) + {H L B U G : ℝ} (h : ℕ) + (ctrl : CoefficientFiberControl (Matrix.fromCols A C) (s.trans Function.Embedding.inl) + (Sum.elim S T) H L h B U G) + (hL : 0 < L) (hH : 0 < H) (hB0 : 0 ≤ B) (hU0 : 0 ≤ U) (hG0 : 0 ≤ G) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w j) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + {b t ε : ℝ} (hb : 0 ≤ b) (ht : 0 ≤ t) (hε : 0 < ε) + (hG : G ≤ Real.exp b) (hU : U ≤ Real.exp b) (hB : B ≤ Real.exp b) (hR : (R : ℝ) ≤ Real.exp b) + (hi : (δ : ℝ)⁻¹ ≤ Real.exp t) + (hlarge : coefficientReplacementScale (J := J ⊕ N) (s.trans Function.Embedding.inl) b t ε L h ≤ H) + (m : ℕ) (r : Matrix I N (ZMod m)) + (hperiod : integerScalarLattice I (m : ℤ) ≤ A.mulVecLin.range) (hr : integerResidueMatrix C m = r) : + ∃ hZ : 0 < coefficientWeightSum (affineProductProfile c w) (Sum.elim S T), ∀ v, + |H ^ Fintype.card I * + (coefficientImagePMF (Matrix.fromCols A C) (affineProductProfile c w) + (affineProductProfile_nonneg c w hw) (Sum.elim S T) (Sum.rec hS hT) + (affineProductProfile_zero_outside c w hw R.coe_nonneg hsupport) hZ v).toReal - + coefficientResidueMultiplier A r v * + kernelCoefficientDensity A s hA S (fun _ => H) hS (fun _ => hH) C T c w + (fun i => (v i : ℝ)/H)| ≤ ε := by + obtain ⟨hZ, herr⟩ := affineCoefficientImage_tolerance (Matrix.fromCols A C) + (s.trans Function.Embedding.inl) (Sum.elim S T) (Sum.rec hS hT) h ctrl hL hH hB0 hU0 hG0 + c w hw hδ hwidth R.coe_nonneg hsupport hb ht hε hG hU hB hR hi hlarge + refine ⟨hZ, fun v => ?_⟩ + have he := herr v + rw [coefficientImageMask_eq_multiplier, + selectedCoefficientDensity_eq_kernel A s hA S (fun _ => H) hS (fun _ => hH) C T hT + ctrl.det_ne_zero c w hδ hwidth R hsupport, + coefficientImageMultiplier_eq_residue A C m r hperiod hr] at he + exact he + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +noncomputable def coefficientGridReplacementScale {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (C R b t ε L : ℝ) (h : ℕ) : ℝ := + coefficientReplacementScale s b t + (ε / coefficientGridBoxFactor (Fintype.card I) (Fintype.card J) C R) L h + +theorem coefficientGridReplacementScale_eq {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (C R b t ε L : ℝ) (h : ℕ) : + coefficientGridReplacementScale s C R b t ε L h = + Real.exp (coefficientLogAllowance (Fintype.card I) (Fintype.card (UnselectedColumn s)) + (affineCoefficientCommonBudget (Fintype.card J) (Fintype.card (UnselectedColumn s)) b t)) * + (1 + coefficientGridBoxFactor (Fintype.card I) (Fintype.card J) C R / ε) * + L ^ (h * (Fintype.card I + 1)) := by + simp only [coefficientGridReplacementScale, coefficientReplacementScale, inv_div] + +theorem affineCoefficientGrid_tolerance {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (s : I ↪ J) (S : J → ℝ) (hS : ∀ j, 0 < S j) + {H L C U G : ℝ} (h : ℕ) (ctrl : CoefficientFiberControl A s S H L h C U G) + (hL : 0 < L) (hH : 0 < H) (hH1 : 1 ≤ H) (hC0 : 0 ≤ C) (hU0 : 0 ≤ U) (hG0 : 0 ≤ G) + (c w : J → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w j) {R : ℝ} (hR0 : 0 ≤ R) + (hsupport : ∀ j, |c j| + w j ≤ R) + {b t ε : ℝ} (hb : 0 ≤ b) (ht : 0 ≤ t) (hε : 0 < ε) + (hG : G ≤ Real.exp b) (hU : U ≤ Real.exp b) (hC : C ≤ Real.exp b) (hR : R ≤ Real.exp b) + (hi : (δ : ℝ)⁻¹ ≤ Real.exp t) + (hlarge : coefficientGridReplacementScale s C R b t ε L h ≤ H) : + ∃ hZ : 0 < coefficientWeightSum (affineProductProfile c w) S, + (∫ v, |(coefficientImagePMF A (affineProductProfile c w) (affineProductProfile_nonneg c w hw) + S hS (affineProductProfile_zero_outside c w hw hR0 hsupport) hZ v).toReal - + coefficientGridProxy A s ctrl.det_ne_zero S (fun _ => H) hS (fun _ => hH) + (affineProductProfile c w) v| ∂Measure.count) ≤ ε := by + have hbox := coefficientGridBoxFactor_pos (Fintype.card I) (Fintype.card J) hC0 hR0 + obtain ⟨hZ, he⟩ := affineCoefficientImage_tolerance A s S hS h ctrl hL hH hC0 hU0 hG0 + c w hw hδ hwidth hR0 hsupport hb ht (div_pos hε hbox) hG hU hC hR hi hlarge + refine ⟨hZ, (coefficientImage_l1_of_control A s S hS h ctrl hH hH1 hC0 + (affineProductProfile c w) (affineProductProfile_nonneg c w hw) hR0 + (affineProductProfile_zero_outside c w hw hR0 hsupport) hZ he).trans_eq ?_⟩ + field_simp [hbox.ne'] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem affineCoefficientImage_residue_average {Ω I J N : Type*} [Fintype Ω] + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (p : FiniteProbabilityWeights Ω) + (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) (C : Ω → Matrix I N ℤ) + (S : J → ℝ) (T : N → ℝ) (hS : ∀ j, 0 < S j) (hT : ∀ n, 0 < T n) + {H L B U G : ℝ} (h : ℕ) + (ctrl : ∀ ω, p.weight ω ≠ 0 → CoefficientFiberControl (Matrix.fromCols A (C ω)) + (s.trans Function.Embedding.inl) (Sum.elim S T) H L h B U G) + (hL : 0 < L) (hH : 0 < H) (hB0 : 0 ≤ B) (hU0 : 0 ≤ U) (hG0 : 0 ≤ G) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w j) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + {b t ε η : ℝ} (hb : 0 ≤ b) (ht : 0 ≤ t) (hε : 0 < ε) (hη : 0 ≤ η) + (hG : G ≤ Real.exp b) (hU : U ≤ Real.exp b) (hB : B ≤ Real.exp b) (hR : (R : ℝ) ≤ Real.exp b) + (hi : (δ : ℝ)⁻¹ ≤ Real.exp t) + (hlarge : coefficientReplacementScale (J := J ⊕ N) (s.trans Function.Embedding.inl) b t ε L h ≤ H) + (m : ℕ) (r : Matrix I N (ZMod m)) + (hperiod : integerScalarLattice I (m : ℤ) ≤ A.mulVecLin.range) + (hr : ∀ ω, p.weight ω ≠ 0 → integerResidueMatrix (C ω) m = r) + (target : (I → ℝ) → ℝ) + (hquad : ∀ v : I → ℤ, + |p.mean (fun ω => kernelCoefficientDensity A s hA S (fun _ => H) hS (fun _ => hH) + (C ω) T c w (fun i => (v i : ℝ)/H)) - target (fun i => (v i : ℝ)/H)| ≤ η) : + ∃ hZ : 0 < coefficientWeightSum (affineProductProfile c w) (Sum.elim S T), ∀ v, + |p.mean (fun ω => H ^ Fintype.card I * + (coefficientImagePMF (Matrix.fromCols A (C ω)) (affineProductProfile c w) + (affineProductProfile_nonneg c w hw) (Sum.elim S T) (Sum.rec hS hT) + (affineProductProfile_zero_outside c w hw R.coe_nonneg hsupport) hZ v).toReal) - + coefficientResidueMultiplier A r v * target (fun i => (v i : ℝ)/H)| ≤ ε+G*η := by + obtain ⟨ω₀, hω₀⟩ := finiteProbability_exists_nonzero_weight p + obtain ⟨hZ, _⟩ := affineCoefficientImage_residue_tolerance A s hA (C ω₀) S T hS hT h (ctrl ω₀ hω₀) + hL hH hB0 hU0 hG0 c w hw hδ hwidth R hsupport hb ht hε hG hU hB hR hi hlarge + m r hperiod (hr ω₀ hω₀) + refine ⟨hZ, fun v => ?_⟩ + have hmask := coefficientResidueMultiplier_bounds A (C ω₀) m r hperiod (hr ω₀ hω₀) + (ctrl ω₀ hω₀).index_bound v + apply finiteMean_masked_comparison_of_support p _ _ hmask.1 hmask.2 hη _ (hquad v) + intro ω hω + obtain ⟨_, herr⟩ := affineCoefficientImage_residue_tolerance A s hA (C ω) S T hS hT h (ctrl ω hω) + hL hH hB0 hU0 hG0 c w hw hδ hwidth R hsupport hb ht hε hG hU hB hR hi hlarge + m r hperiod (hr ω hω) + exact herr v + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem affineCoefficientImage_residue_family {Ω I J N : Type*} [Fintype Ω] + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (p : FiniteProbabilityWeights Ω) + (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) (C : Ω → Matrix I N ℤ) + (S : J → ℝ) (T : N → ℝ) (hS : ∀ j, 0 < S j) (hT : ∀ n, 0 < T n) + {H L B U G : ℝ} (h : ℕ) + (ctrl : ∀ ω, p.weight ω ≠ 0 → CoefficientFiberControl (Matrix.fromCols A (C ω)) + (s.trans Function.Embedding.inl) (Sum.elim S T) H L h B U G) + (hL : 0 < L) (hH : 0 < H) (hB0 : 0 ≤ B) (hU0 : 0 ≤ U) (hG0 : 0 ≤ G) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) {δ : ℝ≥0} (hδ : 0 < δ) + (hwidth : ∀ j, (δ : ℝ) ≤ w j) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) + {b t ε : ℝ} (hb : 0 ≤ b) (ht : 0 ≤ t) (hε : 0 < ε) + (hG : G ≤ Real.exp b) (hU : U ≤ Real.exp b) (hB : B ≤ Real.exp b) (hR : (R : ℝ) ≤ Real.exp b) + (hi : (δ : ℝ)⁻¹ ≤ Real.exp t) + (hlarge : coefficientReplacementScale (J := J ⊕ N) (s.trans Function.Embedding.inl) b t ε L h ≤ H) + (m : ℕ) (r : Matrix I N (ZMod m)) + (hperiod : integerScalarLattice I (m : ℤ) ≤ A.mulVecLin.range) + (hr : ∀ ω, p.weight ω ≠ 0 → integerResidueMatrix (C ω) m = r) : + ∃ hZ : 0 < coefficientWeightSum (affineProductProfile c w) (Sum.elim S T), + (∀ v, 0 ≤ coefficientResidueMultiplier A r v ∧ coefficientResidueMultiplier A r v ≤ G) ∧ + ∀ ω, p.weight ω ≠ 0 → ∀ v, + |H ^ Fintype.card I * + (coefficientImagePMF (Matrix.fromCols A (C ω)) (affineProductProfile c w) + (affineProductProfile_nonneg c w hw) (Sum.elim S T) (Sum.rec hS hT) + (affineProductProfile_zero_outside c w hw R.coe_nonneg hsupport) hZ v).toReal - + coefficientResidueMultiplier A r v * + kernelCoefficientDensity A s hA S (fun _ => H) hS (fun _ => hH) + (C ω) T c w (fun i => (v i : ℝ)/H)| ≤ ε := by + obtain ⟨ω₀, hω₀⟩ := finiteProbability_exists_nonzero_weight p + obtain ⟨hZ, _⟩ := affineCoefficientImage_residue_tolerance A s hA (C ω₀) S T hS hT h (ctrl ω₀ hω₀) + hL hH hB0 hU0 hG0 c w hw hδ hwidth R hsupport hb ht hε hG hU hB hR hi hlarge + m r hperiod (hr ω₀ hω₀) + refine ⟨hZ, ?_, ?_⟩ + · exact coefficientResidueMultiplier_bounds A (C ω₀) m r hperiod (hr ω₀ hω₀) + (ctrl ω₀ hω₀).index_bound + · intro ω hω v + obtain ⟨_, herr⟩ := affineCoefficientImage_residue_tolerance A s hA (C ω) S T hS hT h (ctrl ω hω) + hL hH hB0 hU0 hG0 c w hw hδ hwidth R hsupport hb ht hε hG hU hB hR hi hlarge + m r hperiod (hr ω hω) + exact herr v + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCutoffLengthBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCutoffLengthBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cc46d5c9142a8842400a5e0dcc28b3a99fc562e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueCutoffLengthBudget.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.Progressions.Dynamics.ScalarCubeProductRiemannBudget + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +noncomputable def scalarCubeCutoffDerivativeNumerator (I : Type*) [Fintype I] + (A : ℝ≥0) : ℝ := + (2 * 2 ^ Fintype.card I : ℕ) * ((A : ℝ) * ((Fintype.card I : ℝ) + 1)) + +theorem scalarCubeCutoffLipschitzConstant_eq (I : Type*) [Fintype I] (A r : ℝ≥0) : + (scalarCubeCutoffLipschitzConstant I A r : ℝ) = + scalarCubeCutoffDerivativeNumerator I A / r := by + simp only [scalarCubeCutoffLipschitzConstant, scalarCubeCutoffDerivativeNumerator, + NNReal.coe_mul, NNReal.coe_div, NNReal.coe_natCast, NNReal.coe_add, NNReal.coe_one] + ring + +theorem scalarCubeResidueCutoffBudget_le_inverse_radius (I : Type*) + [Fintype I] [DecidableEq I] (A : ℝ≥0) {r : ℝ≥0} (hr : 0 < r) (hr1 : r ≤ 1) + (L M : ℕ) : + scalarCubeResidueCutoffBudget I A r L M ≤ scalarCubeBoundaryConstant I * r + + (2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + + scalarCubeCutoffDerivativeNumerator I A) * M / (r * L) := by + have hD : 0 ≤ 2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) := + div_nonneg (by positivity [scalarCubeGridBoundaryConstant_pos I]) + (scalarCubeDomain_volumeReal_pos I).le + have hr' : (0 : ℝ) < r := hr + have hr1' : (r : ℝ) ≤ 1 := hr1 + have hscale : 2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) ≤ + (2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I)) / r := by + exact (le_div_iff₀ hr').mpr (mul_le_of_le_one_right hD hr1') + unfold scalarCubeResidueCutoffBudget + rw [scalarCubeCutoffLipschitzConstant_eq] + apply add_le_add le_rfl + calc + _ ≤ ((2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I)) / r + + scalarCubeCutoffDerivativeNumerator I A / r) * ((M : ℝ) / L) := + mul_le_mul_of_nonneg_right (add_le_add hscale le_rfl) (by positivity) + _ = _ := by ring + +theorem scalarCubeResidueCutoffBudget_le_of_length (I : Type*) + [Fintype I] [DecidableEq I] (A : ℝ≥0) {r : ℝ≥0} (hr : 0 < r) (hr1 : r ≤ 1) + {L M : ℕ} (hL : 0 < L) {η : ℝ} (hη : 0 < η) + (hradius : scalarCubeBoundaryConstant I * r ≤ η / 2) + (hlength : 2 * + (2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + + scalarCubeCutoffDerivativeNumerator I A) * M / (r * η) ≤ L) : + scalarCubeResidueCutoffBudget I A r L M ≤ η := by + have hr' : (0 : ℝ) < r := hr + have hL' : (0 : ℝ) < L := by exact_mod_cast hL + have h := (div_le_iff₀ (mul_pos hr' hη)).mp hlength + have hmesh : + (2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + + scalarCubeCutoffDerivativeNumerator I A) * M / (r * L) ≤ η / 2 := by + apply (div_le_iff₀ (mul_pos hr' hL')).mpr + nlinarith + exact (scalarCubeResidueCutoffBudget_le_inverse_radius I A hr hr1 L M).trans + (by linarith) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueEventOrAnchoredChild.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueEventOrAnchoredChild.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2984e24016e909e1013fdd7314f48ac4d1fac1a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueEventOrAnchoredChild.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.Progressions.Estimates.AdaptedAnchoredComparison + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup NilpotentLieFiltration RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +theorem exists_residue_event_or_anchored_child (s : ℕ) (hs : 1 ≤ s) : + ∃ B : ℕ, 2 ≤ B ∧ ∀ {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {d t e : ℕ} + (D : RationalFilteredNilmanifold L s d) (V : RationalFilteredNilmanifold K t e) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p q rho : ℝ), 0 ≤ p → p ≤ q → (Fintype.card σ : ℝ) ≤ q → + verticalDecompositionBudget p ≤ q → 0 < rho → rho⁻¹ ≤ Real.exp p → + ∀ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (b : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1)) + (q₀ P C a : ℕ) (hP : 0 < P) (cost : ℝ), + FixedResidueDescent D W V (fun _ : σ => 1) b child p q₀ P hP C a cost → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (E R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (κ : D.RealGroup), κ ∈ D.realLattice → + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨T.orbit.log, T.orbit.property⟩⟩ → + D.filtration.PolynomialRationalGrid D.basis (fun _ : σ => 1) q₀ R → + ∀ A : σ → ℝ, (∀ i, 0 < A i) → + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) A (Real.exp ((p + 2) ^ a)) E → + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (_hM : 0 < M) (u v : σ → ℤ) (J : σ → ℕ), + (∀ i, 0 < J i) → ∀ _hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)], + (∀ i, (M * (M * P)).Coprime (J i)) → + (∀ i, ((M * J i : ℕ) : ℝ) * (Real.exp ((q + B) ^ B) + 1) ≤ (N i : ℝ)) → + ∀ Δ ε δ : ℝ, 0 < δ → δ ≤ 1 → ε < 1 / 2 → + 2 * (2 * rho + Real.exp (verticalDecompositionBudget p - q)) ≤ Δ / 2 → + 8 * ε + 2 * (Real.exp ((p + 2) ^ C) * δ) ≤ Δ / 4 → + (∀ i, 8 ≤ δ * (N i : ℝ)) → + (∀ i, (u i : ℝ) - (M : ℝ) * A i ≤ (lo i : ℝ) ∧ + (lo i : ℝ) + (N i : ℝ) ≤ (u i : ℝ) + (M : ℝ) * A i) → + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ δ * ε / 8 → + Δ ≤ ‖residuePairMean T.eval lo N M u v J false - residuePairMean T.eval lo N M u v J true‖ → + ResiduePairDimensionDrop D ω hF T W lo N M u v J ((q + B) ^ B) ∨ + AnchoredChildResidueComparison V child cost (Δ / 4) δ lo N M P u v J := by + obtain ⟨B, hB, hstep⟩ := exists_residue_event_or_child_descent s hs + refine ⟨B, hB, ?_⟩ + intro σ L K _ _ _ _ _ _ _ _ _ _ _ _ _ _ d t e D V ω hF p q rho hp hpq hσ hfreq hrho hrhop + W b child q₀ P C a hP cost hdesc T hunit hT E R κ hκ hprod hgrid A hA hE + lo N M hM u v J hJ hv hcop hsteplarge Δ ε δ hδ hδone hε hprojection hfreezing + hlarge hphysical hcount hgap + rcases hstep D V ω hF p q rho hp hpq hσ hfreq hrho hrhop W b child q₀ P C a hP cost + hdesc T hunit hT E R κ hκ hprod hgrid A hA hE lo N M hM u v J hJ hv hcop hsteplarge + Δ ε δ hδ hδone hε hprojection hfreezing hlarge hphysical hcount hgap with hevent | hchild + · exact Or.inl hevent + · obtain ⟨H, hH, hHN, hlower, hupper, k, hk₀, hk₁, U, hU, hunitU, hcostU, hgapU⟩ := hchild + exact Or.inr (anchored_child_comparison_of_piece V child cost (Δ / 4) δ lo N H hH hHN + hlower hupper M P hM hP u v J hv hcop k hk₀ hk₁ U hU hunitU hcostU hgapU) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueEventOrDescent.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueEventOrDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..417913c6f8068e8a832960a0033f9e54ea24d87e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueEventOrDescent.lean @@ -0,0 +1,571 @@ +import OAI.Combinatorics.Progressions.Estimates.AuxiliaryCellMeans +import OAI.Combinatorics.Progressions.Estimates.TranslatedStabilityStep +import OAI.Combinatorics.Progressions.Lattices.HalfResidueDescent + +namespace OAI + +section + +namespace Erdos3 + +open Module CircleFourier NilpotentLieFiltration +open scoped TensorProduct BigOperators + +theorem exists_affine_stability_step (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ τ L : Type*} [Fintype τ] [DecidableEq τ] + [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p q rho : ℝ), 0 ≤ p → p ≤ q → (Fintype.card τ : ℝ) ≤ q → + verticalDecompositionBudget p ≤ q → 0 < rho → rho⁻¹ ≤ Real.exp p → + ∀ (T : D.Niltest (fun _ : σ => 1)), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (V : LieSubalgebra ℚ D.filtration.AssociatedGraded) + {β : Type*} (A : β → σ → τ → ℤ) (b : β → σ → ℤ) + (origin : β → τ → ℤ) (lengths : β → τ → ℕ), + (∀ a i, 0 < lengths a i) → + (∀ a i, Real.exp ((q + C) ^ C) ≤ (lengths a i : ℝ)) → + (∃ (a : β) (l : ℕ) (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (u : Fin d → D.filtration.AssociatedGraded), + 0 < l ∧ (l : ℝ) ≤ Real.exp ((q + C) ^ C) ∧ + Submodule.span ℚ (Set.range u) = U.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω U.toSubmodule ∧ + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (u i) j) ≤ + (q + C) ^ C) ∧ + finrank ℚ ↥(V ⊓ U) < finrank ℚ V ∧ + D.filtration.SymbolFactorizationIn D.basis ω hF (fun i => (lengths a i : ℝ)) + ((T.affinePullback (A a) (b a)).symbol D.basis ω hF) ((q + C) ^ C) l U) ∨ + (∃ S : D.Niltest (fun _ : σ => 1), + S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ (D.filtration.gradedRefiltrationLayer V s).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + ∀ a, ‖(𝔼 x ∈ translatedIntegerBox (origin a) (lengths a), + (T.affinePullback (A a) (b a)).eval x) - + (𝔼 x ∈ translatedIntegerBox (origin a) (lengths a), + (S.affinePullback (A a) (b a)).eval x)‖ ≤ + 2 * rho + Real.exp (verticalDecompositionBudget p - q)) := by + classical + obtain ⟨C, hC, hstep⟩ := exists_translated_step_drop s hs + refine ⟨C, hC, ?_⟩ + intro σ τ L _ _ _ _ d _ _ _ _ D ω hF p q rho hp hpq hτ hfreq hrho hrhop + T hunit hTc V β A b origin lengths hlength hlarge + obtain ⟨J, inst, eta, U, hcard, hheight, hU, hvertical, _, _, happrox, _⟩ := + T.exists_controlled_vertical_decomposition hp hTc rho hrho hrhop + let := inst + let K := D.filtration.gradedRefiltrationLayer V s + by_cases hevent : ∃ (j : J) (a : β), + Real.exp (-q) < ‖𝔼 x ∈ translatedIntegerBox (origin a) (lengths a), + ((U j).affinePullback (A a) (b a)).eval x‖ ∧ ∃ v ∈ K, eta j v ≠ 0 + · left + obtain ⟨j, a, hbias, hnonzero⟩ := hevent + have hfactor := hstep D ω hF q (hp.trans hpq) hτ ((U j).affinePullback (A a) (b a)) + ((hU j).1.mono hpq) (eta j) (fun i => (hheight j i).trans hfreq) (hvertical j) + (origin a) (lengths a) (hlength a) (hlarge a) hbias.le + have horbit := (U j).affinePullback_orbit_eq_of_orbit_eq T (hU j).2 (A a) (b a) + have hsymbol := ((U j).affinePullback (A a) (b a)).symbol_eq_of_orbit_eq + (T.affinePullback (A a) (b a)) horbit D.basis ω hF + rw [hsymbol] at hfactor + obtain ⟨l, W, u, hl, hlp, hspan, hgraded, hheightW, _hkill, hdim, hfixed⟩ := + ControlledSymbolFactorization.exists_dimension_drop D.filtration D.basis ω hF hfactor V hnonzero + exact ⟨a, l, W, u, hl, hlp, hspan, hgraded, hheightW, hdim, hfixed⟩ + · right + have hkill : ∀ j, (∃ a, Real.exp (-q) < + ‖𝔼 x ∈ translatedIntegerBox (origin a) (lengths a), + ((U j).affinePullback (A a) (b a)).eval x‖) → + ∀ v ∈ K, eta j v = 0 := by + intro j ⟨a, ha⟩ v hv + by_contra hne + exact hevent ⟨j, a, ha, v, hv, hne⟩ + have hboxes (a : β) : (translatedIntegerBox (origin a) (lengths a)).Nonempty := by + refine ⟨origin a, (mem_translatedIntegerBox (origin a) (lengths a) (origin a)).mpr ?_⟩ + intro i + have hi := hlength a i + exact ⟨le_rfl, by omega⟩ + obtain ⟨S, hS, hSc, hSo, hinv, herr⟩ := T.exists_affine_finset_kernel_projection_family + hunit hTc K (D.filtration.gradedRefiltrationLayer_le V s) eta U (fun j => (hU j).2) + hvertical A b (fun a => translatedIntegerBox (origin a) (lengths a)) hboxes + (fun _ => Real.exp (-q)) hrho.le (fun _ => (Real.exp_pos _).le) + (fun x => by simpa only [norm_sub_rev] using happrox x) hkill + refine ⟨S, hS, hSc, hSo, hinv, ?_⟩ + intro a + apply (herr a).trans + apply add_le_add le_rfl + calc + (Fintype.card J : ℝ) * Real.exp (-q) ≤ + Real.exp (verticalDecompositionBudget p) * Real.exp (-q) := + mul_le_mul_of_nonneg_right hcard (Real.exp_pos _).le + _ = Real.exp (verticalDecompositionBudget p - q) := by rw [← Real.exp_add, sub_eq_add_neg] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module CircleFourier NilpotentLieFiltration +open scoped TensorProduct BigOperators + +theorem exists_residue_law_stability_step (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p q rho : ℝ), 0 ≤ p → p ≤ q → (Fintype.card σ : ℝ) ≤ q → + verticalDecompositionBudget p ≤ q → 0 < rho → rho⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (V : LieSubalgebra ℚ D.filtration.AssociatedGraded) {β : Type*} + (lo hi : β → σ → ℤ) (M : β → ℕ) (u v : β → σ → ℤ) (J : β → σ → ℕ), + (∀ a, 0 < M a) → (∀ a i, 0 < J a i) → + (∀ a i, v a i ≡ u a i [ZMOD (M a : ℤ)]) → + (∀ a i, ((M a * J a i : ℕ) : ℝ) * (Real.exp ((q + C) ^ C) + 1) ≤ + ((hi a i - lo a i : ℤ) : ℝ)) → + let lawMean : D.Niltest (fun _ : σ => 1) → β → ℂ := fun F a => + 𝔼 x : IntegerResidueBox (lo a) (hi a) (fun i => (M a * J a i : ℕ)) (v a), + residueBoxStrideValue F.eval (u a) (M a) x + (∃ (a : β) (l : ℕ) (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (z : Fin d → D.filtration.AssociatedGraded), + 0 < l ∧ (l : ℝ) ≤ Real.exp ((q + C) ^ C) ∧ + Submodule.span ℚ (Set.range z) = U.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω U.toSubmodule ∧ + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (z i) j) ≤ + (q + C) ^ C) ∧ + finrank ℚ ↥(V ⊓ U) < finrank ℚ V ∧ + D.filtration.SymbolFactorizationIn D.basis ω hF + (fun i => (residueIndexLength (lo a i) (hi a i) (M a * J a i : ℕ) (v a i) : ℝ)) + ((T.affinePullback (residueStepMatrix (J a)) (commonStrideIndex (u a) (M a) (v a))).symbol + D.basis ω hF) ((q + C) ^ C) l U) ∨ + (∃ S : D.Niltest (fun _ : σ => 1), + S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ D.filtration.realGradedRefiltrationLayer V s → + ∀ x, S.observable (z • x) = S.observable x) ∧ + (∀ a, ‖lawMean T a - lawMean S a‖ ≤ + 2 * rho + Real.exp (verticalDecompositionBudget p - q)) ∧ + ∀ a b, ‖lawMean T a - lawMean T b‖ - + 2 * (2 * rho + Real.exp (verticalDecompositionBudget p - q)) ≤ + ‖lawMean S a - lawMean S b‖) := by + obtain ⟨C, hC, hstep⟩ := exists_affine_stability_step s hs + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ d _ _ _ _ D ω hF p q rho hp hpq hσ hfreq hrho hrhop + T hunit hT V β lo hi M u v J hM hJ hv hlarge lawMean + have hcounts : ∀ a i, Real.exp ((q + C) ^ C) ≤ + (residueIndexLength (lo a i) (hi a i) (M a * J a i : ℕ) (v a i) : ℝ) := by + intro a i + exact residueIndexLength_ge_of_width (lo a i) (hi a i) (M a * J a i : ℕ) (v a i) + (by exact_mod_cast Nat.mul_pos (hM a) (hJ a i)) _ (Real.exp_nonneg _) (by + simpa only [Int.cast_natCast] using hlarge a i) + have hpositive : ∀ a i, 0 < residueIndexLength (lo a i) (hi a i) (M a * J a i : ℕ) (v a i) := by + intro a i + have h := (Real.exp_pos _).trans_le (hcounts a i) + exact_mod_cast h + let origin : β → σ → ℤ := fun a i => residueIndexLower (lo a i) (M a * J a i : ℕ) (v a i) + let lengths : β → σ → ℕ := fun a i => residueIndexLength (lo a i) (hi a i) (M a * J a i : ℕ) (v a i) + rcases hstep D ω hF p q rho hp hpq hσ hfreq hrho hrhop T hunit hT V + (fun a => residueStepMatrix (J a)) (fun a => commonStrideIndex (u a) (M a) (v a)) + origin lengths hpositive hcounts with hevent | hprojection + · exact Or.inl hevent + · obtain ⟨S, hS, hSc, hSo, hinvariant, hmeans⟩ := hprojection + have hm : ∀ a, ‖lawMean T a - lawMean S a‖ ≤ + 2 * rho + Real.exp (verticalDecompositionBudget p - q) := by + intro a + dsimp only [lawMean] + rw [T.residueBoxStride_mean (lo a) (hi a) (M a) (hM a) (u a) (v a) (J a) (hJ a) (hv a), + S.residueBoxStride_mean (lo a) (hi a) (M a) (hM a) (u a) (v a) (J a) (hJ a) (hv a)] + exact hmeans a + refine Or.inr ⟨S, hS, hSc, hSo, hinvariant, hm, ?_⟩ + intro a b + have h₁ := norm_sub_le_norm_sub_add_norm_sub (lawMean T a) (lawMean S a) (lawMean T b) + have h₂ := norm_sub_le_norm_sub_add_norm_sub (lawMean S a) (lawMean S b) (lawMean T b) + rw [norm_sub_rev (lawMean S b) (lawMean T b)] at h₂ + linarith [hm a, hm b] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration +open scoped TensorProduct BigOperators + +def residuePairStep {I : Type*} (J : I → ℕ) (flag : Bool) : I → ℕ := + if flag then J else fun _ => 1 + +def residuePairValue {I : Type*} (u v : I → ℤ) (flag : Bool) : I → ℤ := + if flag then v else u + +noncomputable def residuePairMean {I : Type*} [Fintype I] [DecidableEq I] + (f : (I → ℤ) → ℂ) (lo : I → ℤ) (N : I → ℕ) (M : ℕ) (u v : I → ℤ) + (J : I → ℕ) (flag : Bool) : ℂ := + 𝔼 x : IntegerResidueBox lo (fun i => lo i + N i) + (fun i => (M * residuePairStep J flag i : ℕ)) (residuePairValue u v flag), + residueBoxStrideValue f u M x + +@[simp] theorem residuePairMean_false {I : Type*} [Fintype I] [DecidableEq I] + (f : (I → ℤ) → ℂ) (lo : I → ℤ) (N : I → ℕ) (M : ℕ) (u v : I → ℤ) (J : I → ℕ) : + residuePairMean f lo N M u v J false = + 𝔼 x : IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) u, + residueBoxStrideValue f u M x := by + exact congrArg + (fun r : I → ℤ => 𝔼 x : IntegerResidueBox lo (fun i => lo i + N i) r u, + residueBoxStrideValue f u M x) + (show (fun _ : I => ((M * 1 : ℕ) : ℤ)) = (fun _ => (M : ℤ)) by + funext i + rw [Nat.mul_one]) + +@[simp] theorem residuePairMean_true {I : Type*} [Fintype I] [DecidableEq I] + (f : (I → ℤ) → ℂ) (lo : I → ℤ) (N : I → ℕ) (M : ℕ) (u v : I → ℤ) (J : I → ℕ) : + residuePairMean f lo N M u v J true = + 𝔼 x : IntegerResidueBox lo (fun i => lo i + N i) (fun i => (M * J i : ℕ)) v, + residueBoxStrideValue f u M x := rfl + +noncomputable def ResiduePairDimensionDrop {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (T : D.Niltest (fun _ : σ => 1)) (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (u v : σ → ℤ) (J : σ → ℕ) (B : ℝ) : Prop := + ∃ (flag : Bool) (l : ℕ) (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (z : Fin d → D.filtration.AssociatedGraded), + 0 < l ∧ (l : ℝ) ≤ Real.exp B ∧ + Submodule.span ℚ (Set.range z) = U.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω U.toSubmodule ∧ + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (z i) j) ≤ B) ∧ + finrank ℚ ↥(W ⊓ U) < finrank ℚ W ∧ + D.filtration.SymbolFactorizationIn D.basis ω hF + (fun i => (residueIndexLength (lo i) (lo i + N i) (M * residuePairStep J flag i : ℕ) + (residuePairValue u v flag i) : ℝ)) + ((T.affinePullback (residueStepMatrix (residuePairStep J flag)) + (commonStrideIndex u M (residuePairValue u v flag))).symbol D.basis ω hF) B l U + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +theorem auxiliary_piece_residue_pair {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} (T : D.Niltest (fun _ : σ => 1)) + (lo : σ → ℤ) (N : σ → ℕ) (cells : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i k, (cells i).step k = 1) (hpos : ∀ i k, 0 < (cells i).length k) + (M P : ℕ) (hM : 0 < M) (hP : 0 < P) (u v : σ → ℤ) (J : σ → ℕ) + (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) (hcop : ∀ i, (M * (M * P)).Coprime (J i)) + (k : AuxiliaryBoxLabels cells (fun _ => M) (fun _ => M * P) u) + (hk₀ : 0 < (partitionCell (baseAuxiliaryBoxCell lo N cells (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u) k).card) + (hk₁ : 0 < (partitionCell (refinedAuxiliaryBoxCell lo N cells (fun _ => M) (fun _ => M * P) J + (fun _ => Nat.mul_pos hM hP) u v hv) k).card) : + let Q := Nat.lcm M (M * P) + let w : σ → ℤ := fun i => (k i).2.baseValue + let z : σ → ℤ := fun i => (k i).2.refinedValue (hcop i) (v i) + let lo' : σ → ℤ := fun i => intervalCellLower (lo i) (cells i) (k i).1 + let N' : σ → ℕ := fun i => (cells i).length (k i).1 + let S := T.scalarAffinePullback (Q / M : ℕ) (fun i => (commonStrideIndex u M w i : ℚ)) + (∀ i, z i ≡ w i [ZMOD (Q : ℤ)]) ∧ + Nonempty (IntegerResidueBox lo' (fun i => lo' i + N' i) (fun _ => (Q : ℤ)) w) ∧ + Nonempty (IntegerResidueBox lo' (fun i => lo' i + N' i) (fun i => (Q * J i : ℕ)) z) ∧ + (𝔼 x ∈ partitionCell (baseAuxiliaryBoxCell lo N cells (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u) k, residueBoxStrideValue T.eval u M x) = + residuePairMean S.eval lo' N' Q w z J false ∧ + (𝔼 x ∈ partitionCell (refinedAuxiliaryBoxCell lo N cells (fun _ => M) (fun _ => M * P) J + (fun _ => Nat.mul_pos hM hP) u v hv) k, residueBoxStrideValue T.eval u M x) = + residuePairMean S.eval lo' N' Q w z J true := by + intro Q w z lo' N' S + have hw : ∀ i, w i ≡ u i [ZMOD (M : ℤ)] := fun i => (k i).2.baseValue_spec.1 + have hz : ∀ i, z i ≡ w i [ZMOD (Q : ℤ)] := by + intro i + have h := (k i).2.refinedValue_spec (hcop i) (v i) + exact ((k i).2.baseConstraint_iff (z i)).mp ⟨h.1, h.2.1⟩ + have hMQ : M ∣ Q := Nat.dvd_lcm_left M (M * P) + refine ⟨hz, ?_, ?_, ?_, ?_⟩ + · obtain ⟨x, hx⟩ := Finset.card_pos.mp hk₀ + exact ⟨boxAuxiliaryCellEquiv lo N cells hstep hpos (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u (fun _ => (M : ℤ)) u (fun _ _ hx => hx) k + (fun _ => (Q : ℤ)) w (fun i => (k i).2.baseConstraint_iff) ⟨x, hx⟩⟩ + · obtain ⟨x, hx⟩ := Finset.card_pos.mp hk₁ + exact ⟨boxAuxiliaryCellEquiv lo N cells hstep hpos (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u (fun i => (M * J i : ℕ)) v + (fun i => refinedResidue_implies_base M (J i) (u i) (v i) (hv i)) k + (fun i => (Q * J i : ℕ)) z (fun i => (k i).2.refinedConstraint_iff (hcop i) (v i) (hv i)) ⟨x, hx⟩⟩ + · rw [residuePairMean_false] + exact (baseAuxiliaryBoxCell_expect lo N cells hstep hpos (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u k (fun y => T.eval (commonStrideIndex u M y))).trans + (T.residueBoxStride_rebase lo' (fun i => lo' i + N' i) (fun _ => (Q : ℤ)) w u w + hM hMQ hw (fun _ _ hx => hx)) + · rw [residuePairMean_true] + exact (refinedAuxiliaryBoxCell_expect lo N cells hstep hpos (fun _ => M) (fun _ => M * P) J + (fun _ => Nat.mul_pos hM hP) u v hv hcop k (fun y => T.eval (commonStrideIndex u M y))).trans + (T.residueBoxStride_rebase lo' (fun i => lo' i + N' i) (fun i => (Q * J i : ℕ)) z u w + hM hMQ hw (fun i => refinedResidue_implies_base Q (J i) (w i) (z i) (hz i))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration +open scoped TensorProduct + +theorem residuePairStep_const {σ : Type*} (J : ℕ) (flag : Bool) : + residuePairStep (fun _ : σ => J) flag = fun _ => if flag then J else 1 := by + cases flag <;> rfl + +namespace RationalFilteredNilmanifold.Niltest + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} + +theorem residue_scalar_composed_symbol (T : D.Niltest (fun _ : σ => 1)) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (r : ℚ) (h : σ → ℚ) (J : ℕ) (shift : σ → ℤ) : + ((T.scalarAffinePullback r h).affinePullback (residueStepMatrix (fun _ : σ => J)) shift).symbol + D.basis ω hF = + (T.scalarAffinePullback (r * J) (fun i => r * (shift i : ℚ) + h i)).symbol D.basis ω hF := by + rw [(T.scalarAffinePullback r h).residue_scalar_affine_symbol ω hF J shift] + exact ((T.scalarAffinePullback r h).scalarAffinePullback (J : ℚ) (fun i => (shift i : ℚ))).symbol_eq_of_orbit_eq + (T.scalarAffinePullback (r * J) (fun i => r * (shift i : ℚ) + h i)) + (T.scalarAffinePullback_comp_orbit r (J : ℚ) h (fun i => (shift i : ℚ))) D.basis ω hF + +end RationalFilteredNilmanifold.Niltest + +theorem ResiduePairDimensionDrop.scalar_record {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (T : D.Niltest (fun _ : σ => 1)) (r : ℚ) (h : σ → ℚ) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (lo : σ → ℤ) (N : σ → ℕ) (M J : ℕ) (u v : σ → ℤ) (B : ℝ) + (hevent : ResiduePairDimensionDrop D ω hF (T.scalarAffinePullback r h) W lo N M u v + (fun _ => J) B) : + ∃ (flag : Bool) (l : ℕ) (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (z : Fin d → D.filtration.AssociatedGraded), + 0 < l ∧ (l : ℝ) ≤ Real.exp B ∧ + Submodule.span ℚ (Set.range z) = U.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω U.toSubmodule ∧ + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (z i) j) ≤ B) ∧ + finrank ℚ ↥(W ⊓ U) < finrank ℚ W ∧ + D.filtration.SymbolFactorizationIn D.basis ω hF + (fun i => (residueIndexLength (lo i) (lo i + N i) (M * (if flag then J else 1) : ℕ) + (residuePairValue u v flag i) : ℝ)) + ((T.scalarAffinePullback (r * (if flag then J else 1 : ℕ)) + (fun i => r * (commonStrideIndex u M (residuePairValue u v flag) i : ℚ) + h i)).symbol + D.basis ω hF) B l U := by + obtain ⟨flag, l, U, z, hl, hlB, hz, hgraded, hheight, hdrop, hfactor⟩ := hevent + rw [residuePairStep_const] at hfactor + rw [T.residue_scalar_composed_symbol] at hfactor + exact ⟨flag, l, U, z, hl, hlB, hz, hgraded, hheight, hdrop, hfactor⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration +open scoped TensorProduct BigOperators + +theorem exists_residue_pair_stability_step (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p q rho : ℝ), 0 ≤ p → p ≤ q → (Fintype.card σ : ℝ) ≤ q → + verticalDecompositionBudget p ≤ q → 0 < rho → rho⁻¹ ≤ Real.exp p → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) (lo : σ → ℤ) (N : σ → ℕ) + (M : ℕ) (u v : σ → ℤ) (J : σ → ℕ), + 0 < M → (∀ i, 0 < J i) → (∀ i, v i ≡ u i [ZMOD (M : ℤ)]) → + (∀ i, ((M * J i : ℕ) : ℝ) * (Real.exp ((q + C) ^ C) + 1) ≤ (N i : ℝ)) → + let eta := 2 * rho + Real.exp (verticalDecompositionBudget p - q) + ResiduePairDimensionDrop D ω hF T W lo N M u v J ((q + C) ^ C) ∨ + ∃ S : D.Niltest (fun _ : σ => 1), + S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ D.filtration.realGradedRefiltrationLayer W s → + ∀ x, S.observable (z • x) = S.observable x) ∧ + (∀ flag, ‖residuePairMean T.eval lo N M u v J flag - + residuePairMean S.eval lo N M u v J flag‖ ≤ eta) ∧ + ‖residuePairMean T.eval lo N M u v J false - residuePairMean T.eval lo N M u v J true‖ - + 2 * eta ≤ + ‖residuePairMean S.eval lo N M u v J false - residuePairMean S.eval lo N M u v J true‖ := by + obtain ⟨C, hC, hstep⟩ := exists_residue_law_stability_step s hs + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ d _ _ _ _ D ω hF p q rho hp hpq hσ hfreq hrho hrhop + T hunit hT W lo N M u v J hM hJ hv hlarge eta + have hpositive : ∀ flag i, 0 < residuePairStep J flag i := by + intro flag i + cases flag + · exact Nat.zero_lt_one + · exact hJ i + have hcompat : ∀ flag i, residuePairValue u v flag i ≡ u i [ZMOD (M : ℤ)] := by + intro flag i + cases flag + · exact Int.ModEq.refl (u i) + · exact hv i + have hwidth : ∀ flag i, ((M * residuePairStep J flag i : ℕ) : ℝ) * + (Real.exp ((q + C) ^ C) + 1) ≤ ((lo i + N i - lo i : ℤ) : ℝ) := by + intro flag i + simp only [add_sub_cancel_left, Int.cast_natCast] + cases flag + · change ((M * 1 : ℕ) : ℝ) * (Real.exp ((q + C) ^ C) + 1) ≤ (N i : ℝ) + rw [Nat.mul_one] + have hm : (M : ℝ) ≤ (M * J i : ℕ) := by exact_mod_cast Nat.le_mul_of_pos_right M (hJ i) + exact (mul_le_mul_of_nonneg_right hm (by positivity)).trans (hlarge i) + · exact hlarge i + rcases hstep D ω hF p q rho hp hpq hσ hfreq hrho hrhop T hunit hT W + (fun _ : Bool => lo) (fun _ i => lo i + N i) (fun _ => M) (fun _ => u) + (residuePairValue u v) (residuePairStep J) (fun _ => hM) hpositive hcompat hwidth with hevent | hprojection + · exact Or.inl hevent + · obtain ⟨S, hS, hSc, hSo, hinvariant, hmeans, hgap⟩ := hprojection + exact Or.inr ⟨S, hS, hSc, hSo, hinvariant, hmeans, hgap false true⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration +open scoped TensorProduct + +theorem ResiduePairDimensionDrop.of_orbit_eq {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (T S : D.Niltest (fun _ : σ => 1)) (hTS : T.orbit = S.orbit) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (u v : σ → ℤ) (J : σ → ℕ) (B : ℝ) + (hevent : ResiduePairDimensionDrop D ω hF T W lo N M u v J B) : + ResiduePairDimensionDrop D ω hF S W lo N M u v J B := by + obtain ⟨flag, l, U, z, hl, hlB, hz, hgraded, hheight, hdrop, hfactor⟩ := hevent + have horbit := T.affinePullback_orbit_eq_of_orbit_eq S hTS + (residueStepMatrix (residuePairStep J flag)) (commonStrideIndex u M (residuePairValue u v flag)) + have hsymbol := (T.affinePullback (residueStepMatrix (residuePairStep J flag)) + (commonStrideIndex u M (residuePairValue u v flag))).symbol_eq_of_orbit_eq + (S.affinePullback (residueStepMatrix (residuePairStep J flag)) + (commonStrideIndex u M (residuePairValue u v flag))) horbit D.basis ω hF + rw [hsymbol] at hfactor + exact ⟨flag, l, U, z, hl, hlB, hz, hgraded, hheight, hdrop, hfactor⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup NilpotentLieFiltration RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +theorem exists_residue_event_or_child_descent (s : ℕ) (hs : 1 ≤ s) : + ∃ B : ℕ, 2 ≤ B ∧ ∀ {σ L K : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] {d t e : ℕ} + (D : RationalFilteredNilmanifold L s d) (V : RationalFilteredNilmanifold K t e) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p q rho : ℝ), 0 ≤ p → p ≤ q → (Fintype.card σ : ℝ) ≤ q → + verticalDecompositionBudget p ≤ q → 0 < rho → rho⁻¹ ≤ Real.exp p → + ∀ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (b : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1)) + (q₀ P C a : ℕ) (hP : 0 < P) (cost : ℝ), + FixedResidueDescent D W V (fun _ : σ => 1) b child p q₀ P hP C a cost → + ∀ T : D.Niltest (fun _ : σ => 1), T.UnitIntervalValued → T.ComplexityLE p → + ∀ (E R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (κ : D.RealGroup), κ ∈ D.realLattice → + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨T.orbit.log, T.orbit.property⟩⟩ → + D.filtration.PolynomialRationalGrid D.basis (fun _ : σ => 1) q₀ R → + ∀ A : σ → ℝ, (∀ i, 0 < A i) → + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) A (Real.exp ((p + 2) ^ a)) E → + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (hM : 0 < M) (u v : σ → ℤ) (J : σ → ℕ), + (∀ i, 0 < J i) → ∀ hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)], + (∀ i, (M * (M * P)).Coprime (J i)) → + (∀ i, ((M * J i : ℕ) : ℝ) * (Real.exp ((q + B) ^ B) + 1) ≤ (N i : ℝ)) → + ∀ Δ ε δ : ℝ, 0 < δ → δ ≤ 1 → ε < 1 / 2 → + 2 * (2 * rho + Real.exp (verticalDecompositionBudget p - q)) ≤ Δ / 2 → + 8 * ε + 2 * (Real.exp ((p + 2) ^ C) * δ) ≤ Δ / 4 → + (∀ i, 8 ≤ δ * (N i : ℝ)) → + (∀ i, (u i : ℝ) - (M : ℝ) * A i ≤ (lo i : ℝ) ∧ + (lo i : ℝ) + (N i : ℝ) ≤ (u i : ℝ) + (M : ℝ) * A i) → + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ δ * ε / 8 → + Δ ≤ ‖residuePairMean T.eval lo N M u v J false - residuePairMean T.eval lo N M u v J true‖ → + ResiduePairDimensionDrop D ω hF T W lo N M u v J ((q + B) ^ B) ∨ + ∃ (H : σ → ℕ) (hH : ∀ i, 0 < H i) (hHN : ∀ i, H i ≤ N i), + (∀ i, δ * (N i : ℝ) / 8 ≤ (H i : ℝ)) ∧ + (∀ i, (H i : ℝ) ≤ δ * (N i : ℝ) / 4) ∧ + let Q := comparableBoxPartitions N H hH hHN + let c₀ := baseAuxiliaryBoxCell lo N Q (fun _ => M) (fun _ => M * P) + (fun _ => Nat.mul_pos hM hP) u + let c₁ := refinedAuxiliaryBoxCell lo N Q (fun _ => M) (fun _ => M * P) J + (fun _ => Nat.mul_pos hM hP) u v hv + ∃ k : AuxiliaryBoxLabels Q (fun _ => M) (fun _ => M * P) u, + 0 < (partitionCell c₀ k).card ∧ 0 < (partitionCell c₁ k).card ∧ + ∃ U : V.Niltest (fun _ : σ => 1), + U.orbit = child ∧ U.UnitIntervalValued ∧ U.ComplexityLE cost ∧ + Δ / 4 ≤ ‖(𝔼 x ∈ partitionCell c₀ k, residueBoxStrideValue U.eval u M x) - + (𝔼 x ∈ partitionCell c₁ k, residueBoxStrideValue U.eval u M x)‖ := by + obtain ⟨B, hB, hstep⟩ := exists_residue_pair_stability_step s hs + refine ⟨B, hB, ?_⟩ + intro σ L K _ _ _ _ _ _ _ _ _ _ _ _ _ _ d t e D V ω hF p q rho hp hpq hσ hfreq hrho hrhop + W b child q₀ P C a hP cost hdesc T hunit hT E R κ hκ hprod hgrid A hA hE + lo N M hM u v J hJ hv hcop hsteplarge Δ ε δ hδ hδone hε hprojection hfreezing + hlarge hphysical hcount hgap + rcases hstep D ω hF p q rho hp hpq hσ hfreq hrho hrhop T hunit hT W lo N M u v J + hM hJ hv hsteplarge with hevent | hprojected + · exact Or.inl hevent + · obtain ⟨S, hunitS, hS, hSo, hinvariant, _, hSgap⟩ := hprojected + have hprodS : E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨S.orbit.log, S.orbit.property⟩⟩ := by + simpa only [hSo] using hprod + have hgapS : Δ / 2 ≤ + ‖residuePairMean S.eval lo N M u v J false - residuePairMean S.eval lo N M u v J true‖ := by + linarith + simp only [residuePairMean_false, residuePairMean_true] at hgapS + have hresult := hdesc.half_discrepancy S hS hunitS hinvariant E R κ hκ hprodS hgrid A hA hE + M hM lo N u v J hJ hv hcop (Δ / 2) ε δ hδ hδone hε + (by nlinarith : 8 * ε + 2 * (Real.exp ((p + 2) ^ C) * δ) ≤ (Δ / 2) / 2) + hlarge hphysical hcount hgapS + right + simpa only [show (Δ / 2) / 2 = Δ / 4 by ring] using hresult + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueGoodKernelBound.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueGoodKernelBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..b07501dc7d4e5030a5bef3b0bb9a2727389df1be --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueGoodKernelBound.lean @@ -0,0 +1,41 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedKernelPrimitiveBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_residue_good_scalar_kernel_bound (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) : + ∃ s : I ↪ J, ∀ (M : ℕ), 0 < M → ∀ η : ℝ, 0 < η → ∃ B L₀ : ℕ, + 0 < B ∧ ∃ hsize : (Fintype.card I + 1) * M ≤ L₀, + ∀ (L : ℕ) (hL : 0 < L) (hlarge : L₀ ≤ L) + (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i)) + (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M), + (FiniteProbabilityWeights.pi (fun j => + scalarCubeResidueWeights I L M hL (m j) (r j) (hm j) (hmM j) + (hsize.trans hlarge))).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (B : ℝ)) B x) ≤ η := by + obtain ⟨s, hs⟩ := exists_uniform_good_scalar_kernel_bound I J hJ + refine ⟨s, fun M hM η hη => ?_⟩ + let C := (scalarCubeResidueDensityCap I M) ^ Fintype.card J + have hC : 0 < C := pow_pos (scalarCubeResidueDensityCap_pos I M hM) _ + obtain ⟨B, L₁, hB, hL₁, hprob⟩ := hs (η / C) (div_pos hη hC) + refine ⟨B, max L₁ ((Fintype.card I + 1) * M), hB, Nat.le_max_right _ _, ?_⟩ + intro L hL hlarge m r hm hmM + have hsize : (Fintype.card I + 1) * M ≤ L := (Nat.le_max_right _ _).trans hlarge + calc + _ ≤ C * (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (B : ℝ)) B x) := + scalarCubeResidue_pi_eventProbability_le I J L M hL m r hm hmM hsize _ + _ ≤ C * (η / C) := mul_le_mul_of_nonneg_left + (hprob L hL ((Nat.le_max_left _ _).trans hlarge)) hC.le + _ = η := by field_simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueIntervalFactors.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueIntervalFactors.lean new file mode 100644 index 0000000000000000000000000000000000000000..df8855ba7b3db22967306911c785c81f90dedbeb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueIntervalFactors.lean @@ -0,0 +1,58 @@ +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Estimates.NativeBoundedVariablePatchExpansion + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def residueSiteIndicator {m : ℕ} (r : ZMod m) (u : ℤ) : ℝ := + if (u : ZMod m) = r then 1 else 0 + +theorem residueSiteIndicator_range {m : ℕ} (r : ZMod m) (u : ℤ) : + 0 ≤ residueSiteIndicator r u ∧ residueSiteIndicator r u ≤ 1 := by + unfold residueSiteIndicator + split_ifs <;> norm_num + +theorem prod_residueSiteIndicator {S : Type*} [Fintype S] (m : ℕ) + (r : S → ZMod m) (u : S → ℤ) : + (∏ i, residueSiteIndicator (r i) (u i)) = if (fun i => (u i : ZMod m)) = r then 1 else 0 := by + classical + by_cases h : (fun i => (u i : ZMod m)) = r + · simp only [h, ite_true] + apply Finset.prod_eq_one + intro i _ + simp only [residueSiteIndicator, congrFun h i, ite_true] + · rw [ite_eq_right h] + have hn : ∃ i, (u i : ZMod m) ≠ r i := not_forall.mp (fun hi => h (funext hi)) + obtain ⟨i, hi⟩ := hn + exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [residueSiteIndicator, hi]) + +noncomputable def residueIntervalSiteWeight (B r H : ℝ) {m : ℕ} + (a : ZMod m) (k : Fin (intervalSiteCount B r)) (u : ℤ) : ℝ := + residueSiteIndicator a u * intervalSiteWeight B r k ((u : ℝ) / H) + +theorem residueIntervalSiteWeight_range (B H : ℝ) {r : ℝ} (hr : 0 < r) {m : ℕ} + (a : ZMod m) (k : Fin (intervalSiteCount B r)) (u : ℤ) : + 0 ≤ residueIntervalSiteWeight B r H a k u ∧ residueIntervalSiteWeight B r H a k u ≤ 1 := by + obtain ⟨ha0, ha1⟩ := residueSiteIndicator_range a u + obtain ⟨hw0, hw1⟩ := intervalSiteWeight_range B hr k ((u : ℝ) / H) + exact ⟨mul_nonneg ha0 hw0, (mul_le_mul ha1 hw1 hw0 zero_le_one).trans_eq (one_mul 1)⟩ + +theorem prod_residueIntervalSiteWeight {S : Type*} [Fintype S] (B r H : ℝ) (m : ℕ) + (a : S → ZMod m) (k : S → Fin (intervalSiteCount B r)) (u : S → ℤ) : + (∏ i, residueIntervalSiteWeight B r H (a i) (k i) (u i)) = + (if (fun i => (u i : ZMod m)) = a then 1 else 0) * + intervalTensorWeight B r k (fun i => (u i : ℝ) / H) := by + classical + simp only [residueIntervalSiteWeight, Finset.prod_mul_distrib, prod_residueSiteIndicator, + intervalTensorWeight] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueLinearPointCap.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueLinearPointCap.lean new file mode 100644 index 0000000000000000000000000000000000000000..aee20e24fb823556cf64de7dd967ca9a24d4b682 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueLinearPointCap.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.Progressions.Geometry.CoordinateProductCap +import OAI.Combinatorics.Progressions.Geometry.UnconditionedSpatialWidthBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def integerArrayLinearForm {D : Type*} [Fintype D] (c z : D → ℤ) : ℤ := ∑ d, c d * z d + +theorem integerArrayLinearForm_affine_join {D : Type*} [Fintype D] [DecidableEq D] + (c a q : D → ℤ) (j : D) (tail : {d : D // d ≠ j} → ℤ) (x : ℤ) : + integerArrayLinearForm c (fun d => a d + q d * coordinateJoin j tail x d) = + c j * (a j + q j * x) + ∑ d : {d : D // d ≠ j}, c d.val * (a d.val + q d.val * tail d) := by + rw [integerArrayLinearForm, Fintype.sum_eq_add_sum_subtype_ne _ j] + simp only [coordinateJoin_pivot, coordinateJoin_other] + +theorem integerArrayLinearForm_pivot_injective {D : Type*} [Fintype D] [DecidableEq D] + (c a q : D → ℤ) (j : D) (hc : c j ≠ 0) (hq : q j ≠ 0) + (tail : {d : D // d ≠ j} → ℤ) : + Function.Injective (fun x => integerArrayLinearForm c + (fun d => a d + q d * coordinateJoin j tail x d)) := by + intro x y h + simp only [integerArrayLinearForm_affine_join] at h + exact mul_left_cancel₀ hq (add_left_cancel (mul_left_cancel₀ hc (add_right_cancel h))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residueSmoothPMF_linear_cap {K I : Type*} [Fintype K] [Fintype I] + (c residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ i, 0 < modulus i) + (W : K × I → ℝ) (hW : ∀ z, 0 < W z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) (residueProfileWidth modulus W)) + (j : K × I) (hc : c j ≠ 0) + (hscale : 8*(probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth modulus W j) (y : ℤ) : + ((residueSmoothPMF residue modulus hmodulus W hW hZ).map (integerArrayLinearForm c) y).toReal ≤ + 2*(modulus j.2 : ℝ)/W j := by + rw [residueSmoothPMF, PMF.map_comp, residueSmoothIndexPMF] + have hq : (modulus j.2 : ℤ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (hmodulus j.2)) + have h := shiftedSmoothProductPMF_coordinate_cap (residueProfileCenter residue modulus) + (residueProfileWidth modulus W) (residueProfileWidth_pos modulus W hmodulus hW) hZ j + (integerArrayLinearForm c ∘ residueLatticeArray residue modulus) + (integerArrayLinearForm_pivot_injective c residue (fun d => (modulus d.2 : ℤ)) j hc hq) + hscale y + simpa only [residueProfileWidth, div_div_eq_mul_div] using h + +theorem selectedResidueSmoothPMF_linear_cap {K I : Type*} [Fintype K] [Fintype I] + (c : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ i, 0 < modulus i) + (T : Finset (ColumnResiduePattern K I modulus)) (hT : T.Nonempty) + (W : K × I → ℝ) (hW : ∀ z, 0 < W z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T W z) + (hscale : ∀ z, 8*(probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth modulus W z) + (j : K × I) (hc : c j ≠ 0) (y : ℤ) : + ((selectedResidueSmoothPMF modulus T W hW hZ).map (integerArrayLinearForm c) y).toReal ≤ + 2*(modulus j.2 : ℝ)/W j := by + have hcell (r : T) : 0 < shiftedSmoothProductMass + (residueProfileCenter (columnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus W) := shiftedSmoothProductMass_pos_of_scales _ _ hscale + obtain ⟨_, h⟩ := selectedResidueSmoothPMF_bound_of_cells (ε := 2*(modulus j.2 : ℝ)/W j) + modulus hmodulus T hT W hW hcell + (fun z => if integerArrayLinearForm c z = y then (1 : ℂ) else 0) + (by + intro r + exact (pmf_point_indicator_norm _ (integerArrayLinearForm c) y).trans_le + (residueSmoothPMF_linear_cap c (columnResidueRepresentative modulus r.val) + modulus hmodulus W hW (hcell r) j hc (hscale j) y)) + exact (pmf_point_indicator_norm _ (integerArrayLinearForm c) y).symm.trans_le h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResiduePhysicalCap.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResiduePhysicalCap.lean new file mode 100644 index 0000000000000000000000000000000000000000..7053ea84efa6423be1f2b0790d8a0a542a52b5ea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResiduePhysicalCap.lean @@ -0,0 +1,31 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalBaseInjection + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +theorem residueSmoothPMF_physical_cap {K I : Type*} [Fintype K] [Fintype I] + (root : K → ℤ) (residue : Option K × I → ℤ) + (modulus : I → ℕ) (hmodulus : ∀ i, 0 < modulus i) + (W : Option K × I → ℝ) (hW : ∀ z, 0 < W z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) (residueProfileWidth modulus W)) + (hbase : ∀ i, 8*(probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth modulus W (none,i)) + (y : I → ℝ) : + ((residueSmoothPMF residue modulus hmodulus W hW hZ).map (physicalAffineSite root) y).toReal ≤ + ∏ i, 2*(modulus i : ℝ)/W (none,i) := by + rw [residueSmoothPMF, PMF.map_comp, residueSmoothIndexPMF] + have h := shiftedSmoothProductPMF_base_cap (residueProfileCenter residue modulus) + (residueProfileWidth modulus W) (residueProfileWidth_pos modulus W hmodulus hW) hZ + (physicalAffineSite root ∘ residueLatticeArray residue modulus) + (physicalAffineSite_residue_base_injective root residue modulus hmodulus) hbase y + simpa only [residueProfileWidth, div_div_eq_mul_div] using h + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResiduePrimeDensityError.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResiduePrimeDensityError.lean new file mode 100644 index 0000000000000000000000000000000000000000..af5d88776d6b10bab79be75f0a1dce20fafd9d13 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResiduePrimeDensityError.lean @@ -0,0 +1,619 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteProductCellMean +import OAI.Combinatorics.Progressions.Estimates.ProductReferenceFiber +import OAI.Combinatorics.Progressions.Estimates.UniformRestrictedMean +import OAI.Combinatorics.Progressions.Lattices.CoprimeResiduePhysicalStability +import OAI.Combinatorics.Progressions.Polynomial.FiniteMarginalLowDegree + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_prime_coordinate_integer_anchor {ι σ : Type*} [DecidableEq ι] + (q : ι → ℕ) [∀ i, NeZero (q i)] + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + ∃ u : σ → ℤ, ∀ i ∈ I, (fun j => (u j : ZMod (q i))) = x i := by + classical + induction I using Finset.induction_on with + | empty => exact ⟨fun _ => 0, by simp⟩ + | @insert i I hi ih => + obtain ⟨v, hv⟩ := ih + have hc : (q i).Coprime (∏ k ∈ I, q k) := by + apply Nat.coprime_prod_right_iff.mpr + intro k hk + apply hcop + intro heq + exact hi (heq ▸ hk) + have hu : ∀ j : σ, ∃ u : ℤ, + u ≡ ((x i j).val : ℤ) [ZMOD (q i : ℤ)] ∧ u ≡ v j [ZMOD ((∏ k ∈ I, q k : ℕ) : ℤ)] := by + intro j + exact exists_integer_coprime_residues hc (x i j).val (v j) + choose u hu using hu + refine ⟨u, ?_⟩ + intro k hk + rcases Finset.mem_insert.mp hk with hki | hk + · subst k + funext j + have h := (ZMod.intCast_eq_intCast_iff (u j) ((x i j).val : ℤ) (q i)).mpr (hu j).1 + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using h + · funext j + have hd : (q k : ℤ) ∣ ((∏ l ∈ I, q l : ℕ) : ℤ) := by + exact_mod_cast Finset.dvd_prod_of_mem q hk + have h := (ZMod.intCast_eq_intCast_iff (u j) (v j) (q k)).mpr ((hu j).2.of_dvd hd) + exact h.trans (congrFun (hv k hk) j) + +theorem primeCoordinateCell_eq_integer_anchor {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) (I : Finset ι) + (x : ∀ i, σ → ZMod (q i)) (u : σ → ℤ) + (hu : ∀ i ∈ I, (fun j => (u j : ZMod (q i))) = x i) : + primeCoordinateCell lo N q I x = + primeCoordinateCell lo N q I (fun i j => (u j : ZMod (q i))) := by + ext z + simp only [mem_primeCoordinateCell] + constructor + · rintro ⟨hz, hx⟩ + exact ⟨hz, fun i hi => (hx i hi).trans (hu i hi).symm⟩ + · rintro ⟨hz, hx⟩ + exact ⟨hz, fun i hi => (hx i hi).trans (hu i hi)⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def primeCoordinateMassRatio {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) [∀ i, NeZero (q i)] + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : ℝ := + ((primeCoordinateCell lo N q I x).card : ℝ) / (translatedIntegerBox lo N).card / + productFiberMass (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).weight I x + +theorem primeCoordinate_weighted_fiber {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (f : (σ → ℤ) → ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + (FiniteProbabilityWeights.uniformFinset (translatedIntegerBox lo N) hbox).mean + (fun z => f z.val * productFiberIndicator I x (primeCoordinateObservation q z.val)) = + ((primeCoordinateCell lo N q I x).card : ℝ) / (translatedIntegerBox lo N).card * + (𝔼 z : primeCoordinateCell lo N q I x, f z.val) := by + classical + let P : (σ → ℤ) → Prop := fun z => ∀ i ∈ I, (fun j => (z j : ZMod (q i))) = x i + have hcell : primeCoordinateCell lo N q I x = (translatedIntegerBox lo N).filter P := by + ext z + simp only [mem_primeCoordinateCell, Finset.mem_filter, P] + rw [hcell] + calc + _ = (FiniteProbabilityWeights.uniformFinset (translatedIntegerBox lo N) hbox).mean + (fun z => if P z.val then f z.val else 0) := by + congr 1 + funext z + have ho : primeCoordinateObservation q z.val = + (fun i j => (z.val j : ZMod (q i))) := rfl + rw [ho] + by_cases hp : P z.val + · change (∀ i ∈ I, (fun j => (z.val j : ZMod (q i))) = x i) at hp + dsimp only [productFiberIndicator, P] + rw [ite_eq_left hp, ite_eq_left hp, mul_one] + · change ¬ (∀ i ∈ I, (fun j => (z.val j : ZMod (q i))) = x i) at hp + dsimp only [productFiberIndicator, P] + rw [ite_eq_right hp, ite_eq_right hp, mul_zero] + _ = _ := uniformFinset_restricted_mean (translatedIntegerBox lo N) hbox P f + +theorem primeCoordinateDensity_conditional {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (f : (σ → ℤ) → ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + productConditionalMean (primeCoordinateReference (σ := σ) q) I + (primeCoordinateDensity lo N hbox q f) x = + primeCoordinateMassRatio lo N q I x * (𝔼 z : primeCoordinateCell lo N q I x, f z.val) := by + unfold primeCoordinateDensity + rw [observedProductDensity_conditional _ (primeCoordinateReference_weight_pos q)] + rw [primeCoordinate_weighted_fiber lo N hbox q f I x] + unfold primeCoordinateMassRatio + ring + +theorem primeCoordinateReference_fiber {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (q : ι → ℕ) [∀ i, NeZero (q i)] + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + productFiberMass (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).weight I x = + (((∏ i ∈ I, q i : ℕ) : ℝ) ^ Fintype.card σ)⁻¹ := by + change productFiberMass (FiniteProbabilityWeights.pi + (fun i => FiniteProbabilityWeights.uniform (σ → ZMod (q i)))).weight I x = _ + rw [productFiberMass_uniform] + simp only [Fintype.card_fun, ZMod.card, Nat.cast_pow, Nat.cast_prod, + Finset.prod_inv_distrib, Finset.prod_pow] + +theorem primeCoordinateMassRatio_eq_count {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) [∀ i, NeZero (q i)] + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + primeCoordinateMassRatio lo N q I x = + ((∏ i ∈ I, q i : ℕ) : ℝ) ^ Fintype.card σ * + (primeCoordinateCell lo N q I x).card / (translatedIntegerBox lo N).card := by + rw [primeCoordinateMassRatio, primeCoordinateReference_fiber, div_inv_eq_mul] + ring + +theorem primeCoordinateDensity_conditional_one {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + productConditionalMean (primeCoordinateReference (σ := σ) q) I + (primeCoordinateDensity lo N hbox q (fun _ => 1)) x = primeCoordinateMassRatio lo N q I x := by + classical + rw [primeCoordinateDensity_conditional] + by_cases hne : (primeCoordinateCell lo N q I x).Nonempty + · let : Nonempty (primeCoordinateCell lo N q I x) := hne.to_subtype + rw [Fintype.expect_const, mul_one] + · have hempty : primeCoordinateCell lo N q I x = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne + simp only [primeCoordinateMassRatio, hempty, Finset.card_empty, Nat.cast_zero, zero_div, zero_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem primeCoordinateCell_card_residue {ι σ : Type*} [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (I : Finset ι) + (x : ∀ i, σ → ZMod (q i)) (u : σ → ℤ) + (hu : ∀ i ∈ I, (fun j => (u j : ZMod (q i))) = x i) : + (primeCoordinateCell lo N q I x).card = + rectangularResidueCount lo (fun j => lo j + N j) (fun _ => ((∏ i ∈ I, q i : ℕ) : ℤ)) u := by + rw [primeCoordinateCell_eq_integer_anchor lo N q I x u hu] + have hc := Fintype.card_congr (primeCoordinateCellEquiv lo N q hcop I u) + rw [Fintype.card_coe] at hc + exact hc.trans (rectangularResidueCount_eq_card _ _ _ _).symm + +theorem primeCoordinateMassRatio_close {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (hN : ∀ j, 0 < N j) + (q : ι → ℕ) [∀ i, NeZero (q i)] + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (I : Finset ι) + (x : ∀ i, σ → ZMod (q i)) + (hsmall : (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j) ≤ 1 / 2) : + |primeCoordinateMassRatio lo N q I x - 1| ≤ + 2 * ∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j := by + obtain ⟨u, hu⟩ := exists_prime_coordinate_integer_anchor q hcop I x + have hM : 0 < ∏ i ∈ I, q i := Finset.prod_pos (fun i _ => Nat.pos_of_ne_zero (NeZero.ne (q i))) + have herr := rectangularResidueCount_relative_error lo (fun j => lo j + N j) + (fun _ => ((∏ i ∈ I, q i : ℕ) : ℤ)) u + (fun j => by have hj := hN j; omega) (fun _ => Nat.cast_pos.mpr hM) + (by simpa only [add_sub_cancel_left, Int.cast_natCast] using hsmall) + have hcell := primeCoordinateCell_card_residue lo N q hcop I x u hu + have hvolume : integerRectangleVolume lo (fun j => lo j + N j) = + ((translatedIntegerBox lo N).card : ℝ) := by + simp only [integerRectangleVolume, add_sub_cancel_left, Int.cast_natCast, + translatedIntegerBox, card_translateSupport, card_integerBox, Nat.cast_prod] + rw [hvolume, ← hcell] at herr + simp only [Finset.prod_const, Finset.card_univ, add_sub_cancel_left, Int.cast_natCast] at herr + have hV : (0 : ℝ) < (translatedIntegerBox lo N).card := by + simp only [translatedIntegerBox, card_translateSupport, card_integerBox, Nat.cast_prod] + exact Finset.prod_pos (fun j _ => Nat.cast_pos.mpr (hN j)) + rw [primeCoordinateMassRatio_eq_count] + calc + _ = |((∏ i ∈ I, q i : ℕ) : ℝ) ^ Fintype.card σ * (primeCoordinateCell lo N q I x).card - + (translatedIntegerBox lo N).card| / (translatedIntegerBox lo N).card := by + rw [← abs_of_pos hV, ← abs_div] + congr 1 + rw [abs_of_pos hV] + field_simp + _ ≤ _ := (div_le_iff₀ hV).mpr herr + +theorem primeCoordinateDensity_productMarginalsClose {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (hN : ∀ j, 0 < N j) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (r : ℕ) (η : ℝ) + (hsmall : ∀ I : Finset ι, I.card ≤ r → (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j) ≤ 1 / 2) + (herror : ∀ I : Finset ι, I.card ≤ r → 2 * (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j) ≤ η) : + ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (primeCoordinateDensity lo N hbox q (fun _ => 1)) η r := by + intro I hI x _ + rw [primeCoordinateDensity_conditional_one] + exact (primeCoordinateMassRatio_close lo N hN q hcop I x (hsmall I hI)).trans (herror I hI) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def residuePrimeCoordinateLaw {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] : FiniteProbabilityWeights (∀ i, σ → ZMod (q i)) := by + let := hne + exact (FiniteProbabilityWeights.uniform + (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)).fiberLaw + (fun z => primeCoordinateObservation q (fun j => (z j).val)) + +noncomputable def residuePrimeCoordinateDensity {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (f : (σ → ℤ) → ℝ) : (∀ i, σ → ZMod (q i)) → ℝ := by + let := hne + exact observedProductDensity (primeCoordinateReference (σ := σ) q) + (FiniteProbabilityWeights.uniform + (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (fun z => primeCoordinateObservation q (fun j => (z j).val)) (fun z => f (fun j => (z j).val)) + +noncomputable def residuePrimeCoordinateMassRatio {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (q : ι → ℕ) [∀ i, NeZero (q i)] (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : ℝ := + (Fintype.card (ResiduePrimeCoordinateCell lo N M a q I x) : ℝ) / + Fintype.card (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a) / + productFiberMass (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).weight I x + +theorem residuePrimeCoordinateDensity_conditional {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (f : (σ → ℤ) → ℝ) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + productConditionalMean (primeCoordinateReference (σ := σ) q) I + (residuePrimeCoordinateDensity lo N M a hne q f) x = + residuePrimeCoordinateMassRatio lo N M a q I x * + (𝔼 z : ResiduePrimeCoordinateCell lo N M a q I x, f (fun j => (z.val j).val)) := by + let := hne + exact uniform_observedProductDensity_conditional + (Ω := IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a) + (primeCoordinateReference (σ := σ) q) + (primeCoordinateReference_weight_pos q) + (fun z => primeCoordinateObservation q (fun j => (z j).val)) (fun z => f (fun j => (z j).val)) I x + +theorem residuePrimeCoordinateMassRatio_eq_count {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (q : ι → ℕ) [∀ i, NeZero (q i)] (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + residuePrimeCoordinateMassRatio lo N M a q I x = + ((∏ i ∈ I, q i : ℕ) : ℝ) ^ Fintype.card σ * + Fintype.card (ResiduePrimeCoordinateCell lo N M a q I x) / + Fintype.card (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a) := by + rw [residuePrimeCoordinateMassRatio, primeCoordinateReference_fiber, div_inv_eq_mul] + ring + +theorem residuePrimeCoordinateDensity_conditional_one {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + productConditionalMean (primeCoordinateReference (σ := σ) q) I + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1)) x = + residuePrimeCoordinateMassRatio lo N M a q I x := by + classical + rw [residuePrimeCoordinateDensity_conditional] + by_cases hc : Nonempty (ResiduePrimeCoordinateCell lo N M a q I x) + · let := hc + rw [Fintype.expect_const, mul_one] + · have hempty : IsEmpty (ResiduePrimeCoordinateCell lo N M a q I x) := not_nonempty_iff.mp hc + let := hempty + simp only [residuePrimeCoordinateMassRatio, Fintype.card_of_isEmpty, Nat.cast_zero, + zero_div, zero_mul] + +theorem residuePrimeCoordinateDensity_one {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (x : ∀ i, σ → ZMod (q i)) : + residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1) x = + (residuePrimeCoordinateLaw lo N M a hne q).weight x / + (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := σ) q)).weight x := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem primeCoordinateMean_re {ι σ : Type*} [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) + (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + (primeCoordinateMean f lo N q I x).re = 𝔼 z : primeCoordinateCell lo N q I x, (f z.val).re := by + simp only [primeCoordinateMean, Fintype.expect_eq_sum_div_card, Complex.div_natCast_re, Complex.re_sum] + +theorem primeCoordinateRealMean_bound {ι σ : Type*} [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (f : (σ → ℤ) → ℝ) (lo : σ → ℤ) (N : σ → ℕ) + (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (C : ℝ) (hC : 0 ≤ C) (hf : ∀ z ∈ translatedIntegerBox lo N, |f z| ≤ C) : + |𝔼 z : primeCoordinateCell lo N q I x, f z.val| ≤ C := by + classical + by_cases hne : (primeCoordinateCell lo N q I x).Nonempty + · let : Nonempty (primeCoordinateCell lo N q I x) := hne.to_subtype + rw [← FiniteProbabilityWeights.uniform_mean] + apply FiniteProbabilityWeights.abs_mean_le_on_support + intro z _ + exact hf z.val ((mem_primeCoordinateCell lo N q I x z.val).mp z.property).1 + · have hempty : primeCoordinateCell lo N q I x = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne + simp only [hempty, Fintype.expect_eq_sum_div_card, Fintype.card_coe, Finset.card_empty, + Nat.cast_zero, div_zero, abs_zero] + exact hC + +theorem primeCoordinateDensity_conditional_error {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (hN : ∀ j, 0 < N j) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (f : (σ → ℤ) → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hf : ∀ z ∈ translatedIntegerBox lo N, |f z| ≤ C) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (hsmall : (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j) ≤ 1 / 2) : + |productConditionalMean (primeCoordinateReference (σ := σ) q) I + (primeCoordinateDensity lo N hbox q f) x - (𝔼 z : primeCoordinateCell lo N q I x, f z.val)| ≤ + (2 * ∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j) * C := by + rw [primeCoordinateDensity_conditional] + rw [← sub_one_mul, abs_mul] + exact mul_le_mul (primeCoordinateMassRatio_close lo N hN q hcop I x hsmall) + (primeCoordinateRealMean_bound f lo N q I x C hC hf) (abs_nonneg _) (by positivity) + +theorem primeCoordinateDensity_sectionMarginalsClose {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (hN : ∀ j, 0 < N j) + (hbox : (translatedIntegerBox lo N).Nonempty) (q : ι → ℕ) [∀ i, NeZero (q i)] + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (r : ℕ) (η : ℝ) + (hsmall : ∀ I : Finset ι, I.card ≤ r → (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j) ≤ 1 / 2) + (herror : ∀ I : Finset ι, I.card ≤ r → 2 * (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / N j) ≤ η) + (T A : Finset ι) (hAT : A ⊆ T) (hAr : A.card ≤ r) (z : ∀ i, σ → ZMod (q i)) : + ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (productSectionAverage (primeCoordinateReference (σ := σ) q) T A z + (primeCoordinateDensity lo N hbox q (fun _ => 1))) η (r - A.card) := by + apply ProductMarginalsClose.section (primeCoordinateReference (σ := σ) q) + (primeCoordinateDensity_productMarginalsClose lo N hN hbox q hcop r η hsmall herror) + T A hAT hAr z + exact (Finset.prod_pos (fun i _ => primeCoordinateReference_weight_pos q i (z i))).ne' + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def normalizedResiduePrimeDensity {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (f : (σ → ℤ) → ℝ) (scale : ℝ) + (x : ∀ i, σ → ZMod (q i)) : ℝ := + scale⁻¹ * residuePrimeCoordinateDensity lo N M a hne q f x + +theorem normalizedResiduePrimeDensity_low_degree {ι σ : Type*} [Fintype ι] [LinearOrder ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (moduli : ι → ℕ) [∀ i, NeZero (moduli i)] (f : (σ → ℤ) → ℝ) + (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z ∧ f z ≤ 1) + (scale : ℝ) (hscale : 0 < scale) {cap η P : ℝ} (hcap : 0 ≤ cap) (hinv : scale⁻¹ ≤ cap) + {k r q : ℕ} (hkr : k ≤ r) (hq : 2 ≤ q) (heven : Even q) (hη : 0 ≤ η) + (hrP : (r : ℝ) ≤ P) (hlog : Real.log (2 + cap) ≤ P) + (hPq : P ≤ (q : ℝ)) (hqP : (q : ℝ) ≤ P + 2) + (hsmall : η ≤ (1 / 2) * (((2 : ℝ) ^ (r + 1) * (2 + (Fintype.card ι : ℝ)) ^ r * (2 + cap)) ^ q)⁻¹) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) moduli) + (residuePrimeCoordinateDensity lo N M a hne moduli (fun _ => 1)) η (r * (q + 1))) + (hbound : ProductBoundedMarginals (primeCoordinateReference (σ := σ) moduli) + (normalizedResiduePrimeDensity lo N M a hne moduli f scale) 1 r) : + Real.sqrt (productANOVAEnergy (primeCoordinateReference (σ := σ) moduli) + (Finset.univ.powersetCard k) (normalizedResiduePrimeDensity lo N M a hne moduli f scale)) ≤ + (16 * (P + 2)) ^ (2 * k) := by + let := hne + apply normalizedObservedDensity_low_degree (primeCoordinateReference (σ := σ) moduli) + (FiniteProbabilityWeights.uniform + (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (fun z => primeCoordinateObservation moduli (fun j => (z j).val)) + (fun z => f (fun j => (z j).val)) _ scale hscale hcap hinv hkr hq heven hη + hrP hlog hPq hqP hsmall hclose hbound + intro z + apply hf + apply (mem_translatedIntegerBox lo N _).mpr + intro j + exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (z j).property).1) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι σ : Type*} [Fintype ι] [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] + +theorem residuePrimeCoordinateMassRatio_close_of_marginals {eta : ℝ} {A : ℕ} + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1)) eta A) + (K : Finset ι) (hK : K.card ≤ A) (base : ∀ i, σ → ZMod (q i)) : + |residuePrimeCoordinateMassRatio lo N M a q K base - 1| ≤ eta := by + have h := hclose K hK base + (Finset.prod_pos (fun i _ => primeCoordinateReference_weight_pos q i (base i))).ne' + rwa [residuePrimeCoordinateDensity_conditional_one] at h + +theorem residuePrimeCoordinateCell_nonempty_of_marginals {eta : ℝ} {A : ℕ} + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1)) eta A) + (heta : eta < 1) (K : Finset ι) (hK : K.card ≤ A) (base : ∀ i, σ → ZMod (q i)) : + Nonempty (ResiduePrimeCoordinateCell lo N M a q K base) := by + classical + by_contra hempty + let : IsEmpty (ResiduePrimeCoordinateCell lo N M a q K base) := not_nonempty_iff.mp hempty + have h := residuePrimeCoordinateMassRatio_close_of_marginals lo N M a hne q hclose K hK base + simp only [residuePrimeCoordinateMassRatio, Fintype.card_of_isEmpty, Nat.cast_zero, + zero_div, zero_sub, abs_neg, abs_one] at h + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residuePrimeCoordinateMassRatio_affine {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + residuePrimeCoordinateMassRatio lo N M a q I + (fun i => affineResidueCoordinateEquiv M (q i) a (hcop i) (x i)) = + primeCoordinateMassRatio (fun j => residueIndexLower (lo j) M (a j)) + (fun j => residueIndexLength (lo j) (lo j + N j) M (a j)) q I x := by + have hc := Fintype.card_congr (residuePrimeCoordinateCellEquiv lo N M a q hM hcop I x) + have hb := Fintype.card_congr (integerResidueBoxEquiv lo (fun j => lo j + N j) + (fun _ => (M : ℤ)) a (fun _ => Nat.cast_pos.mpr hM)) + rw [Fintype.card_coe] at hc hb + rw [residuePrimeCoordinateMassRatio_eq_count, primeCoordinateMassRatio_eq_count, ← hc, ← hb] + +theorem residuePrimeCoordinateMassRatio_close {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (hsmall : (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) ≤ 1 / 2) : + |residuePrimeCoordinateMassRatio lo N M a q I x - 1| ≤ + 2 * ∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j) := by + let inv : ∀ i, σ → ZMod (q i) := + fun i => (affineResidueCoordinateEquiv M (q i) a (hcop i)).symm (x i) + have hx : (fun i => affineResidueCoordinateEquiv M (q i) a (hcop i) (inv i)) = x := by + funext i + exact Equiv.apply_symm_apply _ _ + have hlength := integerResidueBox_lengths_pos lo (fun j => lo j + N j) + (fun _ => (M : ℤ)) a (fun _ => Nat.cast_pos.mpr hM) hne + rw [← hx, residuePrimeCoordinateMassRatio_affine lo N M a q hM hcop I inv] + exact primeCoordinateMassRatio_close _ _ hlength q hpair I inv hsmall + +theorem residuePrimeCoordinateCell_nonempty_of_small {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (hsmall : (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) < 1 / 2) : + Nonempty (ResiduePrimeCoordinateCell lo N M a q I x) := by + classical + by_contra hc + let : IsEmpty (ResiduePrimeCoordinateCell lo N M a q I x) := not_nonempty_iff.mp hc + have he := residuePrimeCoordinateMassRatio_close lo N M a hne q hM hcop hpair I x hsmall.le + simp only [residuePrimeCoordinateMassRatio, Fintype.card_of_isEmpty, Nat.cast_zero, + zero_div, zero_sub, abs_neg, abs_one] at he + linarith + +theorem residuePrimeCoordinateDensity_productMarginalsClose {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) (r : ℕ) (η : ℝ) + (hsmall : ∀ I : Finset ι, I.card ≤ r → (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) ≤ 1 / 2) + (herror : ∀ I : Finset ι, I.card ≤ r → 2 * (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) ≤ η) : + ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1)) η r := by + intro I hI x _ + rw [residuePrimeCoordinateDensity_conditional_one] + exact (residuePrimeCoordinateMassRatio_close lo N M a hne q hM hcop hpair I x + (hsmall I hI)).trans (herror I hI) + +theorem residuePrimeCoordinateDensity_sectionMarginalsClose {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) (r : ℕ) (η : ℝ) + (hsmall : ∀ I : Finset ι, I.card ≤ r → (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) ≤ 1 / 2) + (herror : ∀ I : Finset ι, I.card ≤ r → 2 * (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) ≤ η) + (T A : Finset ι) (hAT : A ⊆ T) (hAr : A.card ≤ r) (z : ∀ i, σ → ZMod (q i)) : + ProductMarginalsClose (primeCoordinateReference (σ := σ) q) + (productSectionAverage (primeCoordinateReference (σ := σ) q) T A z + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1))) η (r - A.card) := by + apply ProductMarginalsClose.section (primeCoordinateReference (σ := σ) q) + (residuePrimeCoordinateDensity_productMarginalsClose lo N M a hne q hM hcop hpair r η hsmall herror) + T A hAT hAr z + exact (Finset.prod_pos (fun i _ => primeCoordinateReference_weight_pos q i (z i))).ne' + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residuePrimeCoordinateMean_re {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) + (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + (residuePrimeCoordinateMean f lo N M a q I x).re = + 𝔼 z : ResiduePrimeCoordinateCell lo N M a q I x, (f (fun j => (z.val j).val)).re := by + simp only [residuePrimeCoordinateMean, Fintype.expect_eq_sum_div_card, + Complex.div_natCast_re, Complex.re_sum] + congr 3 <;> exact Subsingleton.elim _ _ + +theorem residuePrimeCoordinateRealMean_bound {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (f : (σ → ℤ) → ℝ) (lo : σ → ℤ) (N : σ → ℕ) + (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (C : ℝ) (hC : 0 ≤ C) (hf : ∀ z ∈ translatedIntegerBox lo N, |f z| ≤ C) : + |𝔼 z : ResiduePrimeCoordinateCell lo N M a q I x, f (fun j => (z.val j).val)| ≤ C := by + classical + by_cases hne : Nonempty (ResiduePrimeCoordinateCell lo N M a q I x) + · let := hne + rw [← FiniteProbabilityWeights.uniform_mean] + apply FiniteProbabilityWeights.abs_mean_le_on_support + intro z _ + apply hf + apply (mem_translatedIntegerBox lo N _).mpr + intro j + exact Finset.mem_Ico.mp ((Finset.mem_filter.mp (z.val j).property).1) + · let : IsEmpty (ResiduePrimeCoordinateCell lo N M a q I x) := not_nonempty_iff.mp hne + simp only [Fintype.expect_eq_sum_div_card, Fintype.card_of_isEmpty, Nat.cast_zero, + div_zero, abs_zero] + exact hC + +theorem residuePrimeCoordinateDensity_conditional_error {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (hM : 0 < M) (hcop : ∀ i, M.Coprime (q i)) + (hpair : Pairwise (fun i j => (q i).Coprime (q j))) + (f : (σ → ℤ) → ℝ) (C : ℝ) (hC : 0 ≤ C) + (hf : ∀ z ∈ translatedIntegerBox lo N, |f z| ≤ C) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (hsmall : (∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) ≤ 1 / 2) : + |productConditionalMean (primeCoordinateReference (σ := σ) q) I + (residuePrimeCoordinateDensity lo N M a hne q f) x - + (𝔼 z : ResiduePrimeCoordinateCell lo N M a q I x, f (fun j => (z.val j).val))| ≤ + (2 * ∑ j, ((∏ i ∈ I, q i : ℕ) : ℝ) / + residueIndexLength (lo j) (lo j + N j) M (a j)) * C := by + rw [residuePrimeCoordinateDensity_conditional, ← sub_one_mul, abs_mul] + exact mul_le_mul (residuePrimeCoordinateMassRatio_close lo N M a hne q hM hcop hpair I x hsmall) + (residuePrimeCoordinateRealMean_bound f lo N M a q I x C hC hf) (abs_nonneg _) (by positivity) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueQuarterExtension.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueQuarterExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c0de9156c137e74260f63566ffe57221430340e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueQuarterExtension.lean @@ -0,0 +1,70 @@ +import OAI.Combinatorics.Progressions.Estimates.SeparatedLabelExtension +import OAI.Combinatorics.Progressions.Fourier.ParametricQuarterTorusExtension + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal Classical + +variable {A : Type*} [Fintype A] (q : A → ℕ) [∀ a, NeZero (q a)] + +noncomputable def residueTuplePoint (r : ∀ a, ZMod (q a)) : A → AddCircle (1 : ℝ) := + fun a => ZMod.toAddCircle (r a) + +theorem residueTuplePoint_separated (D : ℝ≥0) (hD : ∀ a, (q a : ℝ) ≤ D) + {r s : ∀ a, ZMod (q a)} (hrs : r ≠ s) : + (1 : ℝ) ≤ D * dist (residueTuplePoint q r) (residueTuplePoint q s) := by + obtain ⟨a, ha⟩ := not_forall.mp (fun h : ∀ a, r a = s a => hrs (funext h)) + have h := CircleFourier.one_le_mul_dist_toAddCircle ha + exact h.trans ((mul_le_mul_of_nonneg_right (hD a) dist_nonneg).trans + (mul_le_mul_of_nonneg_left (dist_le_pi_dist (residueTuplePoint q r) (residueTuplePoint q s) a) D.coe_nonneg)) + +theorem exists_residue_tuple_extension {X : Type*} [PseudoMetricSpace X] + (D L B : ℝ≥0) (hD : ∀ a, (q a : ℝ) ≤ D) + (f : (∀ a, ZMod (q a)) → X → ℂ) + (hf : ∀ r, LipschitzWith L (f r)) (hb : ∀ r x, ‖f r x‖ ≤ B) : + ∃ g : (A → AddCircle (1 : ℝ)) × X → ℂ, + LipschitzWith (2 * max L (2 * B * D)) g ∧ + (∀ r x, g (residueTuplePoint q r, x) = f r x) ∧ ∀ z, ‖g z‖ ≤ 2 * B := + exists_bounded_extension_on_separated_labels (residueTuplePoint q) D L B + (fun _ _ h => residueTuplePoint_separated q D hD h) f hf hb + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem exists_residue_quarter_extension {A D : Type*} [Fintype A] [Fintype D] + (q : A → ℕ) [∀ a, NeZero (q a)] (V L : ℝ≥0) (hV : ∀ a, (q a : ℝ) ≤ V) + (f : (∀ a, ZMod (q a)) → (D → ℝ) → ℂ) + (hf : ∀ r, LipschitzWith L (f r)) (hb : ∀ r x, ‖f r x‖ ≤ 1) : + ∃ g : (A → AddCircle (1 : ℝ)) × (D → AddCircle (1 : ℝ)) → ℂ, + LipschitzWith (4 * max L (2 * V)) g ∧ (∀ z, ‖g z‖ ≤ 4) ∧ + ∀ r (v : D → ℝ), (∀ i, |v i| ≤ 1 / 4) → + g (residueTuplePoint q r, fun i => (v i : AddCircle (1 : ℝ))) = f r v := by + obtain ⟨F, hF, hFeq, hFb⟩ := exists_residue_tuple_extension q V L 1 hV f hf hb + have hF' : LipschitzWith (2 * max L (2 * V)) F := by simpa only [mul_one] using hF + have hFb' : ∀ z, ‖F z‖ ≤ (2 : ℝ≥0) := by simpa using hFb + obtain ⟨g, hg, hgb, hgeq⟩ := exists_parametric_quarter_torus_extension F + (2 * max L (2 * V)) 2 hF' hFb' + refine ⟨g, ?_, ?_, ?_⟩ + · convert hg using 1 + ring + · convert hgb using 1 + norm_num + · intro r v hv + exact (hgeq (residueTuplePoint q r) v hv).trans (hFeq r v) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueRefinedPeriod.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueRefinedPeriod.lean new file mode 100644 index 0000000000000000000000000000000000000000..88cb7b753bdf3a18c89b721e560179e8ba7569d5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueRefinedPeriod.lean @@ -0,0 +1,708 @@ +import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Data.Matrix.ColumnRowPartitioned +import Mathlib.Data.ZMod.Basic +import Mathlib.LinearAlgebra.FreeModule.Finite.CardQuotient +import Mathlib.LinearAlgebra.Matrix.Adjugate +import Mathlib.LinearAlgebra.Matrix.Nondegenerate +import Mathlib.LinearAlgebra.Matrix.ToLin +import Mathlib.Tactic +import Mathlib.Topology.Algebra.InfiniteSum.ENNReal + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +theorem integerMatrixImage_index {I : Type*} [Fintype I] [DecidableEq I] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) : + A.mulVecLin.range.toAddSubgroup.index = A.det.natAbs := by + let e := LinearEquiv.ofInjective A.mulVecLin (Matrix.mulVec_injective_of_det_ne_zero hA) + have h := Submodule.natAbs_det_equiv A.mulVecLin.range e + have he : A.mulVecLin.range.subtype.comp e.toLinearMap = A.mulVecLin := by + ext x i + rfl + change (LinearMap.det (A.mulVecLin.range.subtype.comp e.toLinearMap)).natAbs = _ at h + rw [he] at h + rw [← Matrix.toLin'_apply', LinearMap.det_toLin'] at h + exact h.symm + +theorem integerMatrixImage_det_smul {I : Type*} [Fintype I] [DecidableEq I] + (A : Matrix I I ℤ) (y : I → ℤ) : A.det • y ∈ A.mulVecLin.range := by + refine ⟨A.adjugate *ᵥ y, ?_⟩ + change A *ᵥ (A.adjugate *ᵥ y) = A.det • y + rw [Matrix.mulVec_mulVec, Matrix.mul_adjugate, Matrix.smul_mulVec, Matrix.one_mulVec] + +theorem integerMatrixImage_multiple_smul {I : Type*} [Fintype I] [DecidableEq I] + (A : Matrix I I ℤ) {m : ℤ} (hm : A.det ∣ m) (y : I → ℤ) : + m • y ∈ A.mulVecLin.range := by + obtain ⟨r, rfl⟩ := hm + simpa only [smul_smul, mul_comm] using + A.mulVecLin.range.smul_mem r (integerMatrixImage_det_smul A y) + +theorem integerMatrixImage_natAbs_smul {I : Type*} [Fintype I] [DecidableEq I] + (A : Matrix I I ℤ) (y : I → ℤ) : (A.det.natAbs : ℤ) • y ∈ A.mulVecLin.range := + integerMatrixImage_multiple_smul A Int.dvd_natAbs_self y + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +def pivotFreeLattice {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) : Submodule ℤ (J → ℤ) := + A.mulVecLin.range.comap B.mulVecLin + +def pivotFullImage {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) : Submodule ℤ (I → ℤ) := + A.mulVecLin.range ⊔ B.mulVecLin.range + +def pivotFreeAdmissible {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (v : I → ℤ) (y : J → ℤ) : Prop := + v - B *ᵥ y ∈ A.mulVecLin.range + +theorem pivotFreeAdmissible_iff {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (v : I → ℤ) (y : J → ℤ) : + pivotFreeAdmissible A B v y ↔ ∃ x : I → ℤ, A *ᵥ x + B *ᵥ y = v := by + constructor + · rintro ⟨x, hx⟩ + exact ⟨x, (eq_sub_iff_add_eq).mp hx⟩ + · rintro ⟨x, hx⟩ + exact ⟨x, (eq_sub_iff_add_eq).mpr hx⟩ + +theorem pivotFreeAdmissible_coset {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (v : I → ℤ) + {y₀ : J → ℤ} (hy₀ : pivotFreeAdmissible A B v y₀) (y : J → ℤ) : + pivotFreeAdmissible A B v y ↔ y - y₀ ∈ pivotFreeLattice A B := by + change v - B *ᵥ y ∈ A.mulVecLin.range ↔ B *ᵥ (y - y₀) ∈ A.mulVecLin.range + rw [Matrix.mulVec_sub] + constructor + · intro hy + convert A.mulVecLin.range.sub_mem hy₀ hy using 1 + abel + · intro hy + convert A.mulVecLin.range.sub_mem hy₀ hy using 1 + abel + +theorem pivotFullImage_iff {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (v : I → ℤ) : + v ∈ pivotFullImage A B ↔ ∃ x : I → ℤ, ∃ y : J → ℤ, A *ᵥ x + B *ᵥ y = v := by + rw [pivotFullImage, Submodule.mem_sup] + constructor + · rintro ⟨a, ⟨x, rfl⟩, b, ⟨y, rfl⟩, he⟩ + exact ⟨x, y, he⟩ + · rintro ⟨x, y, he⟩ + exact ⟨A *ᵥ x, ⟨x, rfl⟩, B *ᵥ y, ⟨y, rfl⟩, he⟩ + +noncomputable def pivotIntegerFiberEquiv {I J : Type*} [Fintype I] [DecidableEq I] + [Fintype J] (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) (v : I → ℤ) : + {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v} ≃ + {y : J → ℤ // pivotFreeAdmissible A B v y} where + toFun p := ⟨p.val.2, (pivotFreeAdmissible_iff A B v p.val.2).mpr ⟨p.val.1, p.property⟩⟩ + invFun y := ⟨⟨(pivotFreeAdmissible_iff A B v y.val).mp y.property |>.choose, y.val⟩, + (pivotFreeAdmissible_iff A B v y.val).mp y.property |>.choose_spec⟩ + left_inv p := by + apply Subtype.ext + apply Prod.ext + · apply Matrix.mulVec_injective_of_det_ne_zero hA + have h := (pivotFreeAdmissible_iff A B v p.val.2).mp + ((pivotFreeAdmissible_iff A B v p.val.2).mpr ⟨p.val.1, p.property⟩) |>.choose_spec + exact add_right_cancel (h.trans p.property.symm) + · rfl + right_inv _ := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem pivotFreeLattice_index_mul {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) : + (pivotFreeLattice A B).toAddSubgroup.index * (pivotFullImage A B).toAddSubgroup.index = + A.det.natAbs := by + rw [← integerMatrixImage_index A hA] + unfold pivotFreeLattice pivotFullImage + rw [Submodule.sup_toAddSubgroup] + change (A.mulVecLin.range.toAddSubgroup.comap B.mulVecLin.toAddMonoidHom).index * + (A.mulVecLin.range.toAddSubgroup ⊔ B.mulVecLin.toAddMonoidHom.range).index = _ + rw [AddSubgroup.index_comap] + rw [← AddSubgroup.relIndex_sup_left] + exact AddSubgroup.relIndex_mul_index le_sup_left + +def integerScalarLattice (J : Type*) [Fintype J] (m : ℤ) : Submodule ℤ (J → ℤ) := + (m • (LinearMap.id : (J → ℤ) →ₗ[ℤ] (J → ℤ))).range + +theorem integerScalarLattice_mem {J : Type*} [Fintype J] (m : ℤ) (y : J → ℤ) : + y ∈ integerScalarLattice J m ↔ ∃ z : J → ℤ, m • z = y := Iff.rfl + +theorem integerScalarLattice_index {J : Type*} [Fintype J] [DecidableEq J] + {m : ℤ} (hm : m ≠ 0) : + (integerScalarLattice J m).toAddSubgroup.index = m.natAbs ^ Fintype.card J := by + have hM : (m • (1 : Matrix J J ℤ)).det ≠ 0 := by + simp only [Matrix.det_smul, Matrix.det_one, mul_one] + exact pow_ne_zero _ hm + have hi := integerMatrixImage_index (m • (1 : Matrix J J ℤ)) hM + have he : (m • (1 : Matrix J J ℤ)).mulVecLin = m • LinearMap.id := by + apply LinearMap.ext + intro x + change (m • (1 : Matrix J J ℤ)) *ᵥ x = m • x + rw [Matrix.smul_mulVec, Matrix.one_mulVec] + rw [he, Matrix.det_smul, Matrix.det_one, mul_one, Int.natAbs_pow] at hi + exact hi + +theorem integerScalarLattice_le_pivotFreeLattice {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) {m : ℤ} (hm : A.det ∣ m) : + integerScalarLattice J m ≤ pivotFreeLattice A B := by + rintro y ⟨z, rfl⟩ + change B *ᵥ (m • z) ∈ A.mulVecLin.range + rw [Matrix.mulVec_smul] + exact integerMatrixImage_multiple_smul A hm (B *ᵥ z) + +theorem pivot_residue_index_identity {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + {m : ℤ} (hm : m ≠ 0) (hdiv : A.det ∣ m) : + (integerScalarLattice J m).toAddSubgroup.relIndex (pivotFreeLattice A B).toAddSubgroup * + A.det.natAbs = m.natAbs ^ Fintype.card J * (pivotFullImage A B).toAddSubgroup.index := by + have hsub : (integerScalarLattice J m).toAddSubgroup ≤ (pivotFreeLattice A B).toAddSubgroup := + integerScalarLattice_le_pivotFreeLattice A B hdiv + have hr := AddSubgroup.relIndex_mul_index hsub + rw [integerScalarLattice_index hm] at hr + rw [← pivotFreeLattice_index_mul A hA B, ← mul_assoc, hr] + +end Erdos3 + +end + +section + +namespace Erdos3 + +def integerLatticeResidue {J : Type*} [Fintype J] + (L : Submodule ℤ (J → ℤ)) (m : ℤ) := + L.toAddSubgroup ⧸ (integerScalarLattice J m).toAddSubgroup.addSubgroupOf L.toAddSubgroup + +@[instance_reducible] noncomputable def integerLatticeResidueFintype {J : Type*} + [Fintype J] [DecidableEq J] + (L : Submodule ℤ (J → ℤ)) {m : ℤ} (hm : m ≠ 0) : + Fintype (integerLatticeResidue L m) := by + let : (integerScalarLattice J m).toAddSubgroup.FiniteIndex := + ⟨by rw [integerScalarLattice_index hm]; exact pow_ne_zero _ (Int.natAbs_ne_zero.mpr hm)⟩ + unfold integerLatticeResidue + exact Fintype.ofFinite _ + +theorem integerLatticeResidue_card {J : Type*} [Fintype J] + (L : Submodule ℤ (J → ℤ)) (m : ℤ) : + Nat.card (integerLatticeResidue L m) = + (integerScalarLattice J m).toAddSubgroup.relIndex L.toAddSubgroup := rfl + +noncomputable def integerScalarPeriodEquiv {J : Type*} [Fintype J] + (L : Submodule ℤ (J → ℤ)) {m : ℤ} (hm : m ≠ 0) + (hL : integerScalarLattice J m ≤ L) : + (J → ℤ) ≃ (integerScalarLattice J m).toAddSubgroup.addSubgroupOf L.toAddSubgroup where + toFun z := ⟨⟨m • z, hL ⟨z, rfl⟩⟩, ⟨z, rfl⟩⟩ + invFun z := z.property.choose + left_inv z := by + funext j + apply mul_left_cancel₀ hm + exact congrFun (Exists.choose_spec (show ∃ w : J → ℤ, m • w = m • z from ⟨z, rfl⟩)) j + right_inv z := by + apply Subtype.ext + apply Subtype.ext + exact z.property.choose_spec + +theorem integerScalarPeriodEquiv_apply {J : Type*} [Fintype J] + (L : Submodule ℤ (J → ℤ)) {m : ℤ} (hm : m ≠ 0) + (hL : integerScalarLattice J m ≤ L) (z : J → ℤ) : + (((integerScalarPeriodEquiv L hm hL z).val).val) = m • z := rfl + +noncomputable def additiveResidueEquiv {G : Type*} [AddCommGroup G] + (H : AddSubgroup G) : G ≃ (G ⧸ H) × H where + toFun x := ⟨(x : G ⧸ H), ⟨x - Quotient.out (x : G ⧸ H), + QuotientAddGroup.eq_iff_sub_mem.mp (Quotient.out_eq' _).symm⟩⟩ + invFun p := p.1.out + p.2.val + left_inv x := by simp + right_inv := by + rintro ⟨r, n⟩ + have h : ((r.out + n.val : G) : G ⧸ H) = r := by + calc + _ = (r.out : G ⧸ H) := QuotientAddGroup.eq_iff_sub_mem.mpr (by simp) + _ = r := Quotient.out_eq' r + apply Prod.ext + · exact h + · apply Subtype.ext + change r.out + n.val - Quotient.out ((r.out + n.val : G) : G ⧸ H) = n.val + rw [h] + simp + +noncomputable def integerLatticeResidueEquiv {J : Type*} [Fintype J] + (L : Submodule ℤ (J → ℤ)) {m : ℤ} (hm : m ≠ 0) + (hL : integerScalarLattice J m ≤ L) : + L ≃ integerLatticeResidue L m × (J → ℤ) := + (additiveResidueEquiv _).trans + (Equiv.prodCongr (Equiv.refl _) (integerScalarPeriodEquiv L hm hL).symm) + +theorem integerLatticeResidueEquiv_symm_apply {J : Type*} [Fintype J] + (L : Submodule ℤ (J → ℤ)) {m : ℤ} (hm : m ≠ 0) + (hL : integerScalarLattice J m ≤ L) (r : integerLatticeResidue L m) (z : J → ℤ) : + ((integerLatticeResidueEquiv L hm hL).symm (r, z)).val = r.out.val + m • z := by + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +def integerResidueMap (I : Type*) (m : ℕ) : (I → ℤ) →ₗ[ℤ] (I → ZMod m) where + toFun v i := v i + map_add' v w := by ext i; simp + map_smul' r v := by ext i; simp + +theorem integerResidueMap_apply {I : Type*} (m : ℕ) (v : I → ℤ) (i : I) : + integerResidueMap I m v i = (v i : ZMod m) := rfl + +theorem integerResidueMap_surjective (I : Type*) (m : ℕ) : + Function.Surjective (integerResidueMap I m) := by + intro v + choose z hz using fun i => ZMod.intCast_surjective (v i) + exact ⟨z, funext hz⟩ + +theorem integerResidueMap_ker (I : Type*) [Fintype I] (m : ℕ) : + LinearMap.ker (integerResidueMap I m) = integerScalarLattice I (m : ℤ) := by + ext v + rw [LinearMap.mem_ker, integerScalarLattice_mem] + constructor + · intro hv + have hd : ∀ i, (m : ℤ) ∣ v i := fun i => + (ZMod.intCast_zmod_eq_zero_iff_dvd (v i) m).mp (congrFun hv i) + choose z hz using hd + exact ⟨z, funext fun i => (hz i).symm⟩ + · rintro ⟨z, rfl⟩ + ext i + change (((m : ℤ) * z i : ℤ) : ZMod m) = 0 + simp + +theorem integerResidueMap_eq_iff {I : Type*} (m : ℕ) (v w : I → ℤ) : + integerResidueMap I m v = integerResidueMap I m w ↔ + ∀ i, v i % (m : ℤ) = w i % (m : ℤ) := by + constructor + · intro h i + exact (ZMod.intCast_eq_intCast_iff' (v i) (w i) m).mp (congrFun h i) + · intro h + exact funext fun i => (ZMod.intCast_eq_intCast_iff' (v i) (w i) m).mpr (h i) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix ENNReal + +def pivotAdmissibleLatticeEquiv {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (v : I → ℤ) + (y₀ : J → ℤ) (hy₀ : pivotFreeAdmissible A B v y₀) : + {y : J → ℤ // pivotFreeAdmissible A B v y} ≃ pivotFreeLattice A B where + toFun y := ⟨y.val - y₀, (pivotFreeAdmissible_coset A B v hy₀ y.val).mp y.property⟩ + invFun z := ⟨y₀ + z.val, (pivotFreeAdmissible_coset A B v hy₀ _).mpr (by + simpa only [add_sub_cancel_left] using z.property)⟩ + left_inv y := by apply Subtype.ext; simp + right_inv z := by apply Subtype.ext; simp + +noncomputable def pivotFiberGridEquiv {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) (v : I → ℤ) + (y₀ : J → ℤ) (hy₀ : pivotFreeAdmissible A B v y₀) + {m : ℤ} (hm : m ≠ 0) (hdiv : A.det ∣ m) : + {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v} ≃ + integerLatticeResidue (pivotFreeLattice A B) m × (J → ℤ) := + (pivotIntegerFiberEquiv A hA B v).trans ((pivotAdmissibleLatticeEquiv A B v y₀ hy₀).trans + (integerLatticeResidueEquiv (pivotFreeLattice A B) hm + (integerScalarLattice_le_pivotFreeLattice A B hdiv))) + +theorem pivotFiberGridEquiv_free {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) (v : I → ℤ) + (y₀ : J → ℤ) (hy₀ : pivotFreeAdmissible A B v y₀) + {m : ℤ} (hm : m ≠ 0) (hdiv : A.det ∣ m) + (r : integerLatticeResidue (pivotFreeLattice A B) m) (z : J → ℤ) : + ((pivotFiberGridEquiv A hA B v y₀ hy₀ hm hdiv).symm (r, z)).val.2 = + y₀ + r.out.val + m • z := by + change y₀ + ((integerLatticeResidueEquiv (pivotFreeLattice A B) hm + (integerScalarLattice_le_pivotFreeLattice A B hdiv)).symm (r, z)).val = _ + rw [integerLatticeResidueEquiv_symm_apply, add_assoc] + +theorem pivotFiberGrid_card_mul {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + {m : ℤ} (hm : m ≠ 0) (hdiv : A.det ∣ m) : + Nat.card (integerLatticeResidue (pivotFreeLattice A B) m) * A.det.natAbs = + m.natAbs ^ Fintype.card J * (pivotFullImage A B).toAddSubgroup.index := + pivot_residue_index_identity A hA B hm hdiv + +theorem pivotFiberGrid_tsum {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) (v : I → ℤ) + (y₀ : J → ℤ) (hy₀ : pivotFreeAdmissible A B v y₀) + {m : ℤ} (hm : m ≠ 0) (hdiv : A.det ∣ m) + (w : (I → ℤ) × (J → ℤ) → ℝ≥0∞) : + letI := integerLatticeResidueFintype (pivotFreeLattice A B) hm + (∑' p : {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v}, w p.val) = + ∑ r : integerLatticeResidue (pivotFreeLattice A B) m, + ∑' z : J → ℤ, w ((pivotFiberGridEquiv A hA B v y₀ hy₀ hm hdiv).symm (r, z)).val := by + let := integerLatticeResidueFintype (pivotFreeLattice A B) hm + rw [← (pivotFiberGridEquiv A hA B v y₀ hy₀ hm hdiv).symm.tsum_eq (fun p => w p.val), + ENNReal.tsum_prod', tsum_fintype] + +theorem pivotFiberGrid_tsum_real {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) (v : I → ℤ) + (y₀ : J → ℤ) (hy₀ : pivotFreeAdmissible A B v y₀) + {m : ℤ} (hm : m ≠ 0) (hdiv : A.det ∣ m) + (w : (I → ℤ) × (J → ℤ) → ℝ) + (hw : Summable (fun p : {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v} => w p.val)) : + letI := integerLatticeResidueFintype (pivotFreeLattice A B) hm + (∑' p : {p : (I → ℤ) × (J → ℤ) // A *ᵥ p.1 + B *ᵥ p.2 = v}, w p.val) = + ∑ r : integerLatticeResidue (pivotFreeLattice A B) m, + ∑' z : J → ℤ, w ((pivotFiberGridEquiv A hA B v y₀ hy₀ hm hdiv).symm (r, z)).val := by + let := integerLatticeResidueFintype (pivotFreeLattice A B) hm + have hs : Summable (fun p : integerLatticeResidue (pivotFreeLattice A B) m × (J → ℤ) => + w ((pivotFiberGridEquiv A hA B v y₀ hy₀ hm hdiv).symm p).val) := + hw.comp_injective (pivotFiberGridEquiv A hA B v y₀ hy₀ hm hdiv).symm.injective + rw [← (pivotFiberGridEquiv A hA B v y₀ hy₀ hm hdiv).symm.tsum_eq (fun p => w p.val), + hs.tsum_prod, tsum_fintype] + +end Erdos3 + +end + +section + +namespace Erdos3 + +def residueLatticeImage {I : Type*} (L : Submodule ℤ (I → ℤ)) (m : ℕ) : + Submodule ℤ (I → ZMod m) := L.map (integerResidueMap I m) + +theorem residueLatticeImage_comap {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + (residueLatticeImage L m).comap (integerResidueMap I m) = L := by + apply Submodule.comap_map_eq_self + rwa [integerResidueMap_ker] + +theorem residueLatticeImage_mem_iff {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) (hperiod : integerScalarLattice I (m : ℤ) ≤ L) + (v : I → ℤ) : v ∈ L ↔ integerResidueMap I m v ∈ residueLatticeImage L m := by + change v ∈ L ↔ v ∈ (residueLatticeImage L m).comap (integerResidueMap I m) + rw [residueLatticeImage_comap L m hperiod] + +theorem residueLatticeImage_determines_lattice {I : Type*} [Fintype I] + (L K : Submodule ℤ (I → ℤ)) (m : ℕ) + (hL : integerScalarLattice I (m : ℤ) ≤ L) (hK : integerScalarLattice I (m : ℤ) ≤ K) + (h : residueLatticeImage L m = residueLatticeImage K m) : L = K := by + rw [← residueLatticeImage_comap L m hL, ← residueLatticeImage_comap K m hK, h] + +theorem residueLatticeImage_index {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + (residueLatticeImage L m).toAddSubgroup.index = L.toAddSubgroup.index := by + have hk : (integerResidueMap I m).toAddMonoidHom.ker ≤ L.toAddSubgroup := by + change (LinearMap.ker (integerResidueMap I m)).toAddSubgroup ≤ L.toAddSubgroup + rw [integerResidueMap_ker] + exact hperiod + have h := L.toAddSubgroup.index_map_eq (integerResidueMap_surjective I m) hk + change (L.toAddSubgroup.map (integerResidueMap I m).toAddMonoidHom).index = _ + exact h + +theorem residueLatticeImage_card_mul_index {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + Nat.card (residueLatticeImage L m) * L.toAddSubgroup.index = m ^ Fintype.card I := by + classical + have h := (residueLatticeImage L m).toAddSubgroup.card_mul_index + rw [residueLatticeImage_index L m hperiod] at h + change Nat.card (residueLatticeImage L m) * L.toAddSubgroup.index = Nat.card (I → ZMod m) at h + have heq : Nat.card (I → ZMod m) = m ^ Fintype.card I := by + rw [Nat.card_eq_fintype_card, Fintype.card_fun, ZMod.card] + exact h.trans heq + +theorem residueLatticeImage_index_eq_div {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + L.toAddSubgroup.index = m ^ Fintype.card I / Nat.card (residueLatticeImage L m) := by + rw [← residueLatticeImage_card_mul_index L m hperiod, + Nat.mul_div_cancel_left _ (Nat.card_pos (α := residueLatticeImage L m))] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +def integerResidueMatrix {I J : Type*} (A : Matrix I J ℤ) (m : ℕ) : Matrix I J (ZMod m) := + A.map (Int.castRingHom (ZMod m)) + +theorem integerResidueMap_mulVec {I J : Type*} [Fintype J] + (A : Matrix I J ℤ) (m : ℕ) (x : J → ℤ) : + integerResidueMap I m (A *ᵥ x) = integerResidueMatrix A m *ᵥ integerResidueMap J m x := by + funext i + exact (Int.castRingHom (ZMod m)).map_mulVec A x i + +theorem integerMatrixResidue_mem {I J : Type*} [Fintype J] + (A : Matrix I J ℤ) (m : ℕ) (v : I → ZMod m) : + v ∈ residueLatticeImage A.mulVecLin.range m ↔ + ∃ x : J → ZMod m, integerResidueMatrix A m *ᵥ x = v := by + constructor + · rintro ⟨y, ⟨x, rfl⟩, hy⟩ + exact ⟨integerResidueMap J m x, (integerResidueMap_mulVec A m x).symm.trans hy⟩ + · rintro ⟨x, hx⟩ + obtain ⟨z, hz⟩ := integerResidueMap_surjective J m x + refine ⟨A *ᵥ z, ⟨z, rfl⟩, ?_⟩ + rw [integerResidueMap_mulVec, hz, hx] + +theorem integerMatrixResidue_image_eq {I J : Type*} [Fintype J] + (A : Matrix I J ℤ) (m : ℕ) : + residueLatticeImage A.mulVecLin.range m = + (integerResidueMatrix A m).mulVecLin.range.restrictScalars ℤ := by + ext v + exact integerMatrixResidue_mem A m v + +theorem integerMatrixImage_residue_iff {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I J ℤ) (m : ℕ) + (hperiod : integerScalarLattice I (m : ℤ) ≤ A.mulVecLin.range) (v : I → ℤ) : + v ∈ A.mulVecLin.range ↔ + ∃ x : J → ZMod m, integerResidueMatrix A m *ᵥ x = integerResidueMap I m v := by + rw [residueLatticeImage_mem_iff A.mulVecLin.range m hperiod, integerMatrixResidue_mem] + +theorem integerMatrixImage_eq_of_residueMatrix {I J : Type*} [Fintype I] [Fintype J] + (A B : Matrix I J ℤ) (m : ℕ) + (hA : integerScalarLattice I (m : ℤ) ≤ A.mulVecLin.range) + (hB : integerScalarLattice I (m : ℤ) ≤ B.mulVecLin.range) + (hAB : integerResidueMatrix A m = integerResidueMatrix B m) : + A.mulVecLin.range = B.mulVecLin.range := by + apply residueLatticeImage_determines_lattice _ _ m hA hB + rw [integerMatrixResidue_image_eq, integerMatrixResidue_image_eq, hAB] + +theorem integerResidueMatrix_eq_of_mod {I J : Type*} (A B : Matrix I J ℤ) (m : ℕ) + (hAB : ∀ i j, A i j % (m : ℤ) = B i j % (m : ℤ)) : + integerResidueMatrix A m = integerResidueMatrix B m := by + ext i j + exact (ZMod.intCast_eq_intCast_iff' (A i j) (B i j) m).mpr (hAB i j) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residueLatticeImage_index_le {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + L.toAddSubgroup.index ≤ m ^ Fintype.card I := by + have h := residueLatticeImage_card_mul_index L m hperiod + have hpos := Nat.card_pos (α := residueLatticeImage L m) + nlinarith + +theorem residueLatticeImage_real_index {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + (L.toAddSubgroup.index : ℝ) = (m : ℝ) ^ Fintype.card I / + (Nat.card (residueLatticeImage L m) : ℝ) := by + have hpos : (0 : ℝ) < Nat.card (residueLatticeImage L m) := by + exact_mod_cast Nat.card_pos (α := residueLatticeImage L m) + apply (eq_div_iff hpos.ne').mpr + rw [mul_comm] + exact_mod_cast residueLatticeImage_card_mul_index L m hperiod + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +def reducedIntegerMatrix {I J : Type*} (A : Matrix I J ℤ) (M : ℕ) : Matrix I J ℤ := + fun i j => A i j % (M : ℤ) + +theorem reducedIntegerMatrix_bounds {I J : Type*} (A : Matrix I J ℤ) + (M : ℕ) [NeZero M] (i : I) (j : J) : + 0 ≤ reducedIntegerMatrix A M i j ∧ reducedIntegerMatrix A M i j < M := by + have hM : (0 : ℤ) < M := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne M) + exact ⟨Int.emod_nonneg _ hM.ne', Int.emod_lt_of_pos _ hM⟩ + +theorem integerResidueMatrix_reduced {I J : Type*} (A : Matrix I J ℤ) (M : ℕ) : + integerResidueMatrix (reducedIntegerMatrix A M) M = integerResidueMatrix A M := by + apply integerResidueMatrix_eq_of_mod + intro i j + exact Int.emod_emod _ _ + +theorem reducedIntegerMatrix_residue {I J : Type*} [Fintype J] + (A : Matrix I J ℤ) (M : ℕ) (x : J → ℤ) : + integerResidueMap I M (A *ᵥ x) = + integerResidueMatrix (reducedIntegerMatrix A M) M *ᵥ integerResidueMap J M x := by + rw [integerResidueMatrix_reduced] + exact integerResidueMap_mulVec A M x + +theorem exists_bounded_integerMap_residue_matrix {I J : Type*} [Fintype J] [DecidableEq J] + (f : (J → ℤ) →ₗ[ℤ] (I → ℤ)) (M : ℕ) [NeZero M] : + ∃ A : Matrix I J ℤ, + (∀ i j, 0 ≤ A i j ∧ A i j < M) ∧ + ∀ x, integerResidueMap I M (f x) = integerResidueMatrix A M *ᵥ integerResidueMap J M x := by + refine ⟨reducedIntegerMatrix (LinearMap.toMatrix' f) M, reducedIntegerMatrix_bounds _ M, ?_⟩ + intro x + rw [← LinearMap.toMatrix'_mulVec f x] + exact reducedIntegerMatrix_residue _ M x + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem integerResidueMatrix_eq_iff_dvd_sub {I J : Type*} + (C D : Matrix I J ℤ) (m : ℕ) : + integerResidueMatrix C m = integerResidueMatrix D m ↔ + ∀ i j, (m : ℤ) ∣ C i j - D i j := by + constructor + · intro h i j + apply (ZMod.intCast_zmod_eq_zero_iff_dvd (C i j - D i j) m).mp + rw [Int.cast_sub] + exact sub_eq_zero.mpr (congrFun (congrFun h i) j) + · intro h + ext i j + change (C i j : ZMod m) = (D i j : ZMod m) + apply sub_eq_zero.mp + have hz := (ZMod.intCast_zmod_eq_zero_iff_dvd (C i j - D i j) m).mpr (h i j) + simpa only [Int.cast_sub] using hz + +theorem integerResidueMatrix_reduce {I J : Type*} (C D : Matrix I J ℤ) + {m n : ℕ} (hmn : m ∣ n) (h : integerResidueMatrix C n = integerResidueMatrix D n) : + integerResidueMatrix C m = integerResidueMatrix D m := by + apply (integerResidueMatrix_eq_iff_dvd_sub C D m).mpr + have hd : (m : ℤ) ∣ (n : ℤ) := by exact_mod_cast hmn + exact fun i j => hd.trans ((integerResidueMatrix_eq_iff_dvd_sub C D n).mp h i j) + +def residueMatrixShift {I J : Type*} [Fintype J] + (C D : Matrix I J ℤ) (q : ℕ) (r : J → ℤ) : I → ℤ := + fun i => ((C - D) *ᵥ r) i / (q : ℤ) + +theorem residueMatrixShift_spec {I J : Type*} [Fintype I] [Fintype J] + (C D : Matrix I J ℤ) (q m : ℕ) (hq : 0 < q) + (h : integerResidueMatrix C (q * m) = integerResidueMatrix D (q * m)) (r : J → ℤ) : + (∀ i, (q : ℤ) * residueMatrixShift C D q r i = ((C - D) *ᵥ r) i) ∧ + residueMatrixShift C D q r ∈ integerScalarLattice I (m : ℤ) := by + classical + have hd (i) (j) : (q : ℤ) * (m : ℤ) ∣ C i j - D i j := by + simpa only [Nat.cast_mul] using (integerResidueMatrix_eq_iff_dvd_sub C D (q * m)).mp h i j + choose Z hZ using hd + let t : I → ℤ := fun i => ∑ j, Z i j * r j + have he (i) : ((C - D) *ᵥ r) i = (q : ℤ) * ((m : ℤ) * t i) := by + change (∑ j, (C i j - D i j) * r j) = _ + simp_rw [hZ] + dsimp only [t] + rw [Finset.mul_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + have hq0 : (q : ℤ) ≠ 0 := by exact_mod_cast hq.ne' + have hs (i) : residueMatrixShift C D q r i = (m : ℤ) * t i := by + unfold residueMatrixShift + rw [he, Int.mul_ediv_cancel_left _ hq0] + refine ⟨fun i => by rw [hs, he], ?_⟩ + refine ⟨t, ?_⟩ + funext i + exact (hs i).symm + +theorem residueMatrixShift_bound {I J : Type*} [Fintype I] [Fintype J] + (C D : Matrix I J ℤ) (q m : ℕ) (hq : 0 < q) + (h : integerResidueMatrix C (q * m) = integerResidueMatrix D (q * m)) + (r : J → ℤ) (hr : ∀ j, |(r j : ℝ)| ≤ q) (i : I) : + |(residueMatrixShift C D q r i : ℝ)| ≤ ∑ j, |((C i j - D i j : ℤ) : ℝ)| := by + have hqR : (0 : ℝ) < q := by exact_mod_cast hq + have he := (residueMatrixShift_spec C D q m hq h r).1 i + have heR : (q : ℝ) * (residueMatrixShift C D q r i : ℝ) = (((C - D) *ᵥ r) i : ℝ) := by + exact_mod_cast he + have hm : (q : ℝ) * |(residueMatrixShift C D q r i : ℝ)| = + |∑ j, ((C i j - D i j : ℤ) : ℝ) * (r j : ℝ)| := by + rw [← abs_of_nonneg (Nat.cast_nonneg q : (0 : ℝ) ≤ q), ← abs_mul, heR] + simp only [Matrix.mulVec, dotProduct, Matrix.sub_apply, Int.cast_sum, Int.cast_mul] + apply (mul_le_mul_iff_right₀ hqR).mp + rw [hm] + calc + _ ≤ ∑ j, |((C i j - D i j : ℤ) : ℝ) * (r j : ℝ)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ j, |((C i j - D i j : ℤ) : ℝ)| * (q : ℝ) := + Finset.sum_le_sum (fun j _ => by rw [abs_mul]; exact mul_le_mul_of_nonneg_left (hr j) (abs_nonneg _)) + _ = _ := (Finset.sum_mul _ _ _).symm.trans (mul_comm _ _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def residueRefinedPeriod {X : Type*} [Fintype X] (m : ℕ) (q : X → ℕ) : ℕ := + m * ∏ d, q d + +theorem residueRefinedPeriod_pos {X : Type*} [Fintype X] + {m : ℕ} (hm : 0 < m) (q : X → ℕ) (hq : ∀ d, 0 < q d) : + 0 < residueRefinedPeriod m q := + Nat.mul_pos hm (Finset.prod_pos (fun d _ => hq d)) + +theorem stride_mul_dvd_residueRefinedPeriod {X : Type*} [Fintype X] + (m : ℕ) (q : X → ℕ) (d : X) : q d * m ∣ residueRefinedPeriod m q := by + classical + obtain ⟨a, ha⟩ := Finset.dvd_prod_of_mem q (Finset.mem_univ d) + refine ⟨a, ?_⟩ + unfold residueRefinedPeriod + rw [ha] + ring + +theorem residueRefinedPeriod_exp_bound {X : Type*} [Fintype X] + (m : ℕ) (q : X → ℕ) {P R : ℝ} + (hm : (m : ℝ) ≤ Real.exp P) (hq : ∀ d, (q d : ℝ) ≤ Real.exp R) : + (residueRefinedPeriod m q : ℝ) ≤ Real.exp (P + Fintype.card X * R) := by + have hprod : (∏ d, (q d : ℝ)) ≤ Real.exp R ^ Fintype.card X := by + calc + _ ≤ ∏ _d : X, Real.exp R := + Finset.prod_le_prod₀ (fun direction _ => Nat.cast_nonneg (q direction)) + (fun direction _ => hq direction) + _ = _ := by simp only [Finset.prod_const, Finset.card_univ] + have h := mul_le_mul hm hprod (Finset.prod_nonneg (fun d _ => Nat.cast_nonneg (q d))) (Real.exp_pos P).le + simpa only [residueRefinedPeriod, Nat.cast_mul, Nat.cast_prod, Real.exp_add, Real.exp_nat_mul] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueRefinementBudgets.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueRefinementBudgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e285156b0b50370ecd86894a5c4ce77d08a068b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueRefinementBudgets.lean @@ -0,0 +1,243 @@ +import OAI.Combinatorics.Progressions.Estimates.RetainedSliceAverages + +namespace OAI + +section + +namespace Erdos3.FiniteCoefficientSlice + +open scoped BigOperators Classical + +def residuePattern (s : FiniteCoefficientSlice) (n : ℕ) (x : s.Domain) : ZMod n := x.val + +noncomputable def residueLabels (s : FiniteCoefficientSlice) (n : ℕ) : Finset (ZMod n) := + Finset.univ.image (s.residuePattern n) + +abbrev ResidueLabel (s : FiniteCoefficientSlice) (n : ℕ) := ↥(s.residueLabels n) + +noncomputable def residueLabelMap (s : FiniteCoefficientSlice) (n : ℕ) (x : s.Domain) : + s.ResidueLabel n := ⟨s.residuePattern n x, Finset.mem_image.mpr ⟨x, Finset.mem_univ x, rfl⟩⟩ + +def refineResidues (s : FiniteCoefficientSlice) (n : ℕ) (r : s.ResidueLabel n) : + FiniteCoefficientSlice where + length := s.length + offset := s.offset + stride := s.stride + modulus := n + residue := r.val + +theorem refineResidues_old_residue (s : FiniteCoefficientSlice) (n : ℕ) + (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) (x : (s.refineResidues n r).Domain) : + (x.val : ZMod s.modulus) = s.residue := by + obtain ⟨y, _, hy⟩ := Finset.mem_image.mp r.property + have hnew : (x.val : ZMod n) = (y.val : ZMod n) := + (Finset.mem_filter.mp x.property).2.trans hy.symm + have hold := congrArg (ZMod.castHom hdvd (ZMod s.modulus)) hnew + simp only [map_intCast] at hold + exact hold.trans (Finset.mem_filter.mp y.property).2 + +def refineResiduesEmbedding (s : FiniteCoefficientSlice) (n : ℕ) (hdvd : s.modulus ∣ n) + (r : s.ResidueLabel n) : (s.refineResidues n r).Domain ↪ s.Domain where + toFun x := ⟨x.val, Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp x.property).1, + s.refineResidues_old_residue n hdvd r x⟩⟩ + inj' := by + intro x y h + exact Subtype.ext (congrArg (fun z : s.Domain => z.val) h) + +theorem refineResiduesEmbedding_value (s : FiniteCoefficientSlice) (n : ℕ) + (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) (x : (s.refineResidues n r).Domain) : + s.value (s.refineResiduesEmbedding n hdvd r x) = (s.refineResidues n r).value x := rfl + +theorem refineResiduesEmbedding_range (s : FiniteCoefficientSlice) (n : ℕ) + (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) : + finiteEmbeddingRange (s.refineResiduesEmbedding n hdvd r) = + Finset.univ.filter (fun x => s.residueLabelMap n x = r) := by + apply Finset.ext + intro x + constructor + · intro hx + obtain ⟨y, _, hy⟩ := Finset.mem_map.mp hx + subst x + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, + Subtype.ext (Finset.mem_filter.mp y.property).2⟩ + · intro hx + have he := congrArg Subtype.val (Finset.mem_filter.mp hx).2 + let y : (s.refineResidues n r).Domain := ⟨x.val, + Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp x.property).1, he⟩⟩ + exact Finset.mem_map.mpr ⟨y, Finset.mem_univ y, Subtype.ext rfl⟩ + +theorem residueLabels_card_le (s : FiniteCoefficientSlice) (n : ℕ) [NeZero n] : + (s.residueLabels n).card ≤ n := by + simpa only [ZMod.card] using (Finset.card_le_univ (s.residueLabels n)) + +theorem residueLabelMap_value_mod (s : FiniteCoefficientSlice) (n M : ℕ) (hM : M ∣ n) + (x : s.Domain) : + (s.value x : ZMod M) = (s.offset : ZMod M) + (s.stride : ZMod M) * + ZMod.castHom hM (ZMod M) (s.residueLabelMap n x).val := by + change ((s.offset + s.stride * x.val : ℤ) : ZMod M) = + (s.offset : ZMod M) + (s.stride : ZMod M) * ZMod.castHom hM (ZMod M) (x.val : ZMod n) + simp only [Int.cast_add, Int.cast_mul, map_intCast] + +theorem refineResidues_mass_pos (s : FiniteCoefficientSlice) [Nonempty s.Domain] + (n : ℕ) (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) : + 0 < (FiniteProbabilityWeights.uniform s.Domain).mass + (finiteEmbeddingRange (s.refineResiduesEmbedding n hdvd r)) := by + rw [s.refineResiduesEmbedding_range, FiniteProbabilityWeights.uniform_mass] + apply div_pos + · obtain ⟨y, _, hy⟩ := Finset.mem_image.mp r.property + have hn : (Finset.univ.filter (fun x => s.residueLabelMap n x = r)).Nonempty := + ⟨y, Finset.mem_filter.mpr ⟨Finset.mem_univ y, Subtype.ext hy⟩⟩ + exact_mod_cast Finset.card_pos.mpr hn + · exact_mod_cast Fintype.card_pos (α := s.Domain) + +theorem retained_refineResidues_mean_ge (s : FiniteCoefficientSlice) [Nonempty s.Domain] + (n : ℕ) (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) (w : ℤ → ℝ) (η : ℝ) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers + (s.residueLabelMap n) (fun x => w (s.value x)) η) : + η ≤ 𝔼 x : (s.refineResidues n r).Domain, w ((s.refineResidues n r).value x) := by + refine FiniteProbabilityWeights.retained_embedding_mean_ge + (s.residueLabelMap n) (fun x => w (s.value x)) η r + (s.refineResiduesEmbedding n hdvd r) hr ?_ (s.refineResidues_mass_pos n hdvd r) + apply (s.refineResiduesEmbedding_range n hdvd r).trans + ext x + simp only [Finset.mem_filter] + +end Erdos3.FiniteCoefficientSlice + +end + +section + +namespace Erdos3.FiniteCubeSlice + +open scoped BigOperators Classical + +def residuePattern {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) + (x : s.Domain) : ∀ i, ZMod (n i) := fun i => (s.coordinates x i : ZMod (n i)) + +noncomputable def residueLabels {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) : + Finset (∀ i, ZMod (n i)) := Finset.univ.image (s.residuePattern n) + +abbrev ResidueLabel {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) := + ↥(s.residueLabels n) + +noncomputable def residueLabelMap {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) + (x : s.Domain) : s.ResidueLabel n := + ⟨s.residuePattern n x, Finset.mem_image.mpr ⟨x, Finset.mem_univ x, rfl⟩⟩ + +def refineResidues {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) + (r : s.ResidueLabel n) : FiniteCubeSlice q where + length := s.length + root := s.root + modulus := n + residue := r.val + +theorem refineResidues_old_residue {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) + (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (x : (s.refineResidues n r).Domain) (i : Option (Fin q)) : + (supportedCubeCoordinates x.val.val i : ZMod (s.modulus i)) = s.residue i := by + obtain ⟨y, _, hy⟩ := Finset.mem_image.mp r.property + have hnew : (supportedCubeCoordinates x.val.val i : ZMod (n i)) = + (s.coordinates y i : ZMod (n i)) := (x.property i).trans (congrFun hy i).symm + have hold := congrArg (ZMod.castHom (hdvd i) (ZMod (s.modulus i))) hnew + simp only [map_intCast] at hold + exact hold.trans (y.property i) + +def refineResiduesEmbedding {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) + (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) : + (s.refineResidues n r).Domain ↪ s.Domain where + toFun x := ⟨x.val, s.refineResidues_old_residue n hdvd r x⟩ + inj' := by + intro x y h + exact Subtype.ext (congrArg (fun z : s.Domain => z.val) h) + +theorem refineResiduesEmbedding_coordinates {q : ℕ} (s : FiniteCubeSlice q) + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (x : (s.refineResidues n r).Domain) : + s.coordinates (s.refineResiduesEmbedding n hdvd r x) = (s.refineResidues n r).coordinates x := rfl + +theorem refineResiduesEmbedding_range {q : ℕ} (s : FiniteCubeSlice q) + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) : + finiteEmbeddingRange (s.refineResiduesEmbedding n hdvd r) = + Finset.univ.filter (fun x => s.residueLabelMap n x = r) := by + apply Finset.ext + intro x + constructor + · intro hx + obtain ⟨y, _, hy⟩ := Finset.mem_map.mp hx + subst x + refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩ + apply Subtype.ext + funext i + exact y.property i + · intro hx + have he := congrArg Subtype.val (Finset.mem_filter.mp hx).2 + let y : (s.refineResidues n r).Domain := ⟨x.val, fun i => congrFun he i⟩ + exact Finset.mem_map.mpr ⟨y, Finset.mem_univ y, Subtype.ext rfl⟩ + +theorem residueLabels_card_le {q : ℕ} (s : FiniteCubeSlice q) (n : Option (Fin q) → ℕ) + [∀ i, NeZero (n i)] : (s.residueLabels n).card ≤ ∏ i, n i := by + calc + _ ≤ Fintype.card (∀ i, ZMod (n i)) := Finset.card_le_univ _ + _ = _ := by simp only [Fintype.card_pi, ZMod.card] + +theorem refineResidues_mass_pos {q : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) : + 0 < (FiniteProbabilityWeights.uniform s.Domain).mass + (finiteEmbeddingRange (s.refineResiduesEmbedding n hdvd r)) := by + rw [s.refineResiduesEmbedding_range, FiniteProbabilityWeights.uniform_mass] + apply div_pos + · obtain ⟨y, _, hy⟩ := Finset.mem_image.mp r.property + have hn : (Finset.univ.filter (fun x => s.residueLabelMap n x = r)).Nonempty := + ⟨y, Finset.mem_filter.mpr ⟨Finset.mem_univ y, Subtype.ext hy⟩⟩ + exact_mod_cast Finset.card_pos.mpr hn + · exact_mod_cast Fintype.card_pos (α := s.Domain) + +theorem retained_refineResidues_mean_ge {q : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (w : (Option (Fin q) → ℤ) → ℝ) (η : ℝ) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers + (s.residueLabelMap n) (fun x => w (s.coordinates x)) η) : + η ≤ 𝔼 x : (s.refineResidues n r).Domain, w ((s.refineResidues n r).coordinates x) := by + refine FiniteProbabilityWeights.retained_embedding_mean_ge + (s.residueLabelMap n) (fun x => w (s.coordinates x)) η r + (s.refineResiduesEmbedding n hdvd r) hr ?_ (s.refineResidues_mass_pos n hdvd r) + apply (s.refineResiduesEmbedding_range n hdvd r).trans + ext x + simp only [Finset.mem_filter] + +end Erdos3.FiniteCubeSlice + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem FiniteCubeSlice.residueLabels_card_le_uniform {q : ℕ} (s : FiniteCubeSlice q) + (n : Option (Fin q) → ℕ) [∀ i, NeZero (n i)] (B : ℕ) (hn : ∀ i, n i ≤ B) : + (s.residueLabels n).card ≤ B ^ (q + 1) := by + calc + _ ≤ ∏ i, n i := s.residueLabels_card_le n + _ ≤ ∏ _i : Option (Fin q), B := Finset.prod_le_prod (fun i _ => hn i) + _ = _ := by simp + +theorem FiniteCubeSlice.residueLabels_product_card_le {q : ℕ} (s : FiniteCubeSlice q) + (B M : ℕ) (hm : ∀ i, 0 < s.modulus i) (hM : 0 < M) (hmB : ∀ i, s.modulus i ≤ B) : + (s.residueLabels (fun i => s.modulus i * M)).card ≤ (B * M) ^ (q + 1) := by + let : ∀ i, NeZero (s.modulus i * M) := fun i => ⟨(Nat.mul_pos (hm i) hM).ne'⟩ + exact s.residueLabels_card_le_uniform _ (B * M) (fun i => Nat.mul_le_mul_right M (hmB i)) + +theorem FiniteCoefficientSlice.residueLabels_product_card_le (s : FiniteCoefficientSlice) + (B M : ℕ) (hm : 0 < s.modulus) (hM : 0 < M) (hmB : s.modulus ≤ B) : + (s.residueLabels (s.modulus * M)).card ≤ B * M := by + let : NeZero (s.modulus * M) := ⟨(Nat.mul_pos hm hM).ne'⟩ + exact (s.residueLabels_card_le _).trans (Nat.mul_le_mul_right M hmB) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceCountingCost.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceCountingCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..68286a1290681cfb00ba87dd6f8b4f4f2ffe8a05 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceCountingCost.lean @@ -0,0 +1,475 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Data.Int.CardIntervalMod +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +theorem scalarResidue_card_mul_le (a b r v : ℤ) (hab : a ≤ b) (hr : 0 < r) : + ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℤ) * r ≤ b - a + r := by + have hrQ : (0 : ℚ) < r := by exact_mod_cast hr + have hc := Int.Ico_filter_modEq_card a b hr v + have hcQ := congrArg (fun n : ℤ => (n : ℚ)) hc + simp only [Int.cast_natCast, Int.cast_max, Int.cast_sub, Int.cast_zero] at hcQ + have hn : (0 : ℚ) ≤ ((b - a : ℤ) : ℚ) / r := + div_nonneg (by exact_mod_cast sub_nonneg.mpr hab) hrQ.le + have hbound : ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℚ) ≤ + ((b - a : ℤ) : ℚ) / r + 1 := by + rw [hcQ] + apply max_le + · have hx := Int.ceil_lt_add_one (((b : ℚ) - v) / r) + have hy := Int.le_ceil (((a : ℚ) - v) / r) + have heq : ((b : ℚ) - v) / r - ((a : ℚ) - v) / r = ((b - a : ℤ) : ℚ) / r := by + push_cast + ring + linarith + · linarith + have hm := mul_le_mul_of_nonneg_right hbound hrQ.le + have heq : (((b - a : ℤ) : ℚ) / r + 1) * r = (b - a : ℤ) + (r : ℚ) := by + field_simp + rw [heq] at hm + exact_mod_cast hm + +theorem scalarResidue_card_real_le (a b r v : ℤ) (hab : a ≤ b) (hr : 0 < r) : + ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℝ) ≤ + ((b - a : ℤ) : ℝ) / r + 1 := by + have hrR : (0 : ℝ) < r := by exact_mod_cast hr + have h := scalarResidue_card_mul_le a b r v hab hr + have hR : ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℝ) * r ≤ + ((b - a : ℤ) : ℝ) + r := by exact_mod_cast h + have heq : ((b - a : ℤ) : ℝ) + r = (((b - a : ℤ) : ℝ) / r + 1) * r := by + field_simp + rw [heq] at hR + exact (mul_le_mul_iff_left₀ hrR).mp hR + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem scalarResidue_card_mul_ge (a b r v : ℤ) (hr : 0 < r) : + b - a - r ≤ ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℤ) * r := by + have hrQ : (0 : ℚ) < r := by exact_mod_cast hr + have hc := congrArg (fun n : ℤ => (n : ℚ)) (Int.Ico_filter_modEq_card a b hr v) + simp only [Int.cast_natCast, Int.cast_max, Int.cast_sub, Int.cast_zero] at hc + have hbound : ((b - a : ℤ) : ℚ) / r - 1 ≤ + ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℚ) := by + rw [hc] + apply le_trans _ (le_max_left _ _) + have hx := Int.le_ceil (((b : ℚ) - v) / r) + have hy := Int.ceil_lt_add_one (((a : ℚ) - v) / r) + have heq : ((b : ℚ) - v) / r - ((a : ℚ) - v) / r = ((b - a : ℤ) : ℚ) / r := by + push_cast + ring + linarith + have hm := mul_le_mul_of_nonneg_right hbound hrQ.le + have heq : (((b - a : ℤ) : ℚ) / r - 1) * r = ((b - a - r : ℤ) : ℚ) := by + push_cast + field_simp + rw [heq] at hm + exact_mod_cast hm + +theorem scalarResidue_card_absolute_error (a b r v : ℤ) (hab : a ≤ b) (hr : 0 < r) : + |((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℝ) - + ((b - a : ℤ) : ℝ) / r| ≤ 1 := by + have hu := scalarResidue_card_real_le a b r v hab hr + have hl : ((b - a - r : ℤ) : ℝ) ≤ + ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℝ) * r := by + exact_mod_cast scalarResidue_card_mul_ge a b r v hr + have hrR : (0 : ℝ) < r := by exact_mod_cast hr + have heq : (((b - a : ℤ) : ℝ) / r - 1) * r = ((b - a - r : ℤ) : ℝ) := by + push_cast + field_simp + rw [← heq] at hl + have hlow := (mul_le_mul_iff_left₀ hrR).mp hl + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +theorem scalarResidue_relative_count_error (a b r v : ℤ) (hab : a < b) (hr : 0 < r) : + |((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℝ) * r / + ((b - a : ℤ) : ℝ) - 1| ≤ (r : ℝ) / ((b - a : ℤ) : ℝ) := by + have hL : (0 : ℝ) < ((b - a : ℤ) : ℝ) := by exact_mod_cast sub_pos.mpr hab + have hrR : (0 : ℝ) < r := by exact_mod_cast hr + have h := scalarResidue_card_absolute_error a b r v hab.le hr + have heq : ((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℝ) * r / + ((b - a : ℤ) : ℝ) - 1 = + (((Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card : ℝ) - + ((b - a : ℤ) : ℝ) / r) * ((r : ℝ) / ((b - a : ℤ) : ℝ)) := by + field_simp + rw [heq, abs_mul, abs_of_pos (div_pos hrR hL)] + simpa only [one_mul] using mul_le_mul_of_nonneg_right h (div_nonneg hrR.le hL.le) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residue_constraints_iff_lcm {M d : ℕ} {u v c : ℤ} + (hM : c ≡ u [ZMOD (M : ℤ)]) (hd : c ≡ v [ZMOD (d : ℤ)]) (x : ℤ) : + (x ≡ u [ZMOD (M : ℤ)] ∧ x ≡ v [ZMOD (d : ℤ)]) ↔ + x ≡ c [ZMOD (Nat.lcm M d : ℤ)] := by + have hlcm : (M : ℤ).lcm (d : ℤ) = Nat.lcm M d := by simp [Int.lcm_def] + rw [← hlcm, ← Int.modEq_and_modEq_iff_modEq_lcm] + exact ⟨fun h => ⟨h.1.trans hM.symm, h.2.trans hd.symm⟩, + fun h => ⟨h.1.trans hM, h.2.trans hd⟩⟩ + +theorem exists_integer_coprime_residues {M d : ℕ} (hcop : M.Coprime d) (u v : ℤ) : + ∃ c : ℤ, c ≡ u [ZMOD (M : ℤ)] ∧ c ≡ v [ZMOD (d : ℤ)] := by + have hbez : (M : ℤ) * Nat.gcdA M d + (d : ℤ) * Nat.gcdB M d = 1 := by + simpa only [hcop.gcd_eq_one, Nat.cast_one] using (Nat.gcd_eq_gcd_ab M d).symm + let c := u * ((d : ℤ) * Nat.gcdB M d) + v * ((M : ℤ) * Nat.gcdA M d) + refine ⟨c, Int.modEq_iff_dvd.mpr ?_, Int.modEq_iff_dvd.mpr ?_⟩ + · refine ⟨(u - v) * Nat.gcdA M d, ?_⟩ + calc + u - c = u * ((M : ℤ) * Nat.gcdA M d + (d : ℤ) * Nat.gcdB M d) - c := by rw [hbez, mul_one] + _ = (M : ℤ) * ((u - v) * Nat.gcdA M d) := by dsimp [c]; ring + · refine ⟨(v - u) * Nat.gcdB M d, ?_⟩ + calc + v - c = v * ((M : ℤ) * Nat.gcdA M d + (d : ℤ) * Nat.gcdB M d) - c := by rw [hbez, mul_one] + _ = (d : ℤ) * ((v - u) * Nat.gcdB M d) := by dsimp [c]; ring + +theorem coprime_refinement_preserves_compatibility {M d J : ℕ} + (hcop : (M * d).Coprime J) (u v w : ℤ) : + (∃ c : ℤ, c ≡ u [ZMOD (M : ℤ)] ∧ c ≡ v [ZMOD (d : ℤ)]) ↔ + ∃ c : ℤ, c ≡ u [ZMOD (M : ℤ)] ∧ c ≡ v [ZMOD (d : ℤ)] ∧ c ≡ w [ZMOD (J : ℤ)] := by + constructor + · rintro ⟨c, hM, hd⟩ + have hL : (Nat.lcm M d).Coprime J := hcop.of_dvd_left (Nat.lcm_dvd_mul M d) + obtain ⟨t, ht, htJ⟩ := exists_integer_coprime_residues hL c w + obtain ⟨htM, htd⟩ := (residue_constraints_iff_lcm hM hd t).mpr ht + exact ⟨t, htM, htd, htJ⟩ + · rintro ⟨c, hM, hd, _⟩ + exact ⟨c, hM, hd⟩ + +theorem refined_residue_constraints_iff {M d J : ℕ} (hcop : (M * d).Coprime J) + {u v w c : ℤ} (hM : c ≡ u [ZMOD (M : ℤ)]) (hd : c ≡ v [ZMOD (d : ℤ)]) + (hJ : c ≡ w [ZMOD (J : ℤ)]) (x : ℤ) : + (x ≡ u [ZMOD (M : ℤ)] ∧ x ≡ v [ZMOD (d : ℤ)] ∧ x ≡ w [ZMOD (J : ℤ)]) ↔ + x ≡ c [ZMOD (Nat.lcm M d * J : ℤ)] := by + have hL : (Nat.lcm M d).Coprime J := hcop.of_dvd_left (Nat.lcm_dvd_mul M d) + rw [← and_assoc, residue_constraints_iff_lcm hM hd x, + residue_constraints_iff_lcm (Int.ModEq.refl c) hJ x, hL.lcm_eq_mul] + simp only [Nat.cast_mul] + +theorem compatible_residue_count_error (a b : ℤ) (hab : a ≤ b) {M d : ℕ} + (hMpos : 0 < M) (hdpos : 0 < d) {u v c : ℤ} + (hM : c ≡ u [ZMOD (M : ℤ)]) (hd : c ≡ v [ZMOD (d : ℤ)]) : + |((Finset.filter (fun x => x ≡ u [ZMOD (M : ℤ)] ∧ x ≡ v [ZMOD (d : ℤ)]) + (Finset.Ico a b)).card : ℝ) - ((b - a : ℤ) : ℝ) / Nat.lcm M d| ≤ 1 := by + have hp : (0 : ℤ) < Nat.lcm M d := by + exact_mod_cast Nat.pos_of_ne_zero (Nat.lcm_ne_zero hMpos.ne' hdpos.ne') + have heq : Finset.filter (fun x : ℤ => x ≡ u [ZMOD (M : ℤ)] ∧ x ≡ v [ZMOD (d : ℤ)]) (Finset.Ico a b) = + Finset.filter (fun x : ℤ => x ≡ c [ZMOD (Nat.lcm M d : ℤ)]) (Finset.Ico a b) := by + ext x + simp only [Finset.mem_filter, residue_constraints_iff_lcm hM hd x] + rw [heq] + exact scalarResidue_card_absolute_error a b (Nat.lcm M d) c hab hp + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def residueIndexLower (a r v : ℤ) : ℤ := + ⌈((a : ℚ) - (v : ℚ)) / (r : ℚ)⌉ + +noncomputable def residueIndexLength (a b r v : ℤ) : ℕ := + (residueIndexLower b r v - residueIndexLower a r v).toNat + +def residueAffineEmbedding (r v : ℤ) (hr : r ≠ 0) : ℤ ↪ ℤ where + toFun k := v + r * k + inj' _ _ h := mul_left_cancel₀ hr (add_left_cancel h) + +theorem residueIndexInterval_eq (a b r v : ℤ) : + Finset.Ico (residueIndexLower a r v) (residueIndexLower b r v) = + Finset.Ico (residueIndexLower a r v) (residueIndexLower a r v + residueIndexLength a b r v) := by + ext x + simp only [Finset.mem_Ico, residueIndexLength] + omega + +theorem residueInterval_eq_map (a b r v : ℤ) (hr : 0 < r) : + Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b) = + (Finset.Ico (residueIndexLower a r v) (residueIndexLower a r v + residueIndexLength a b r v)).map + (residueAffineEmbedding r v hr.ne') := by + rw [Int.Ico_filter_modEq_eq, Int.Ico_filter_dvd_eq (a - v) (b - v) hr, Finset.map_map] + simp only [Int.cast_sub] + change (Finset.Ico (residueIndexLower a r v) (residueIndexLower b r v)).map _ = _ + rw [residueIndexInterval_eq] + congr 1 + ext k + change k * r + v = v + r * k + ring + +noncomputable def residueIntervalEquiv (a b r v : ℤ) (hr : 0 < r) : + ↥(Finset.Ico (residueIndexLower a r v) (residueIndexLower a r v + residueIndexLength a b r v)) ≃ + ↥(Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)) := by + let f : ↥(Finset.Ico (residueIndexLower a r v) + (residueIndexLower a r v + residueIndexLength a b r v)) → + ↥(Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)) := fun x => + ⟨v + r * x.val, by + rw [residueInterval_eq_map a b r v hr] + exact Finset.mem_map.mpr ⟨x.val, x.property, rfl⟩⟩ + apply Equiv.ofBijective f + constructor + · intro x y h + apply Subtype.ext + exact (residueAffineEmbedding r v hr.ne').injective (congrArg Subtype.val h) + · intro y + let yy : ℤ := y.val + have hy : yy ∈ Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b) := y.property + rw [residueInterval_eq_map a b r v hr] at hy + obtain ⟨x, hx, hxy⟩ := Finset.mem_map.mp hy + exact ⟨⟨x, hx⟩, Subtype.ext hxy⟩ + +@[simp] theorem residueIntervalEquiv_val (a b r v : ℤ) (hr : 0 < r) + (x : ↥(Finset.Ico (residueIndexLower a r v) + (residueIndexLower a r v + residueIndexLength a b r v))) : + (residueIntervalEquiv a b r v hr x).val = v + r * x.val := rfl + +theorem residueIndexLength_eq_card (a b r v : ℤ) (hr : 0 < r) : + residueIndexLength a b r v = + (Finset.filter (fun x => x ≡ v [ZMOD r]) (Finset.Ico a b)).card := by + rw [residueInterval_eq_map a b r v hr, Finset.card_map, Int.card_Ico] + omega + +theorem residueIndexLength_absolute_error (a b r v : ℤ) (hab : a ≤ b) (hr : 0 < r) : + |(residueIndexLength a b r v : ℝ) - ((b - a : ℤ) : ℝ) / (r : ℝ)| ≤ 1 := by + rw [residueIndexLength_eq_card a b r v hr] + exact scalarResidue_card_absolute_error a b r v hab hr + +end Erdos3 + +end + +section + +namespace Erdos3 + +def integerResidueLabel (d : ℕ) (hd : 0 < d) (x : ℤ) : Fin d := + ⟨(x % (d : ℤ)).toNat, by + have hlo := Int.emod_nonneg x (show (d : ℤ) ≠ 0 by exact_mod_cast hd.ne') + have hhi := Int.emod_lt_of_pos x (show (0 : ℤ) < d by exact_mod_cast hd) + omega⟩ + +theorem integerResidueLabel_val (d : ℕ) (hd : 0 < d) (x : ℤ) : + ((integerResidueLabel d hd x).val : ℤ) = x % (d : ℤ) := by + have hlo := Int.emod_nonneg x (show (d : ℤ) ≠ 0 by exact_mod_cast hd.ne') + exact Int.toNat_of_nonneg hlo + +theorem integerResidueLabel_eq_iff (d : ℕ) (hd : 0 < d) (x : ℤ) (v : Fin d) : + integerResidueLabel d hd x = v ↔ x ≡ (v.val : ℤ) [ZMOD (d : ℤ)] := by + have hv : (v.val : ℤ) % (d : ℤ) = v.val := Int.emod_eq_of_lt + (Int.natCast_nonneg _) (by exact_mod_cast v.isLt) + have hx := integerResidueLabel_val d hd x + rw [Int.ModEq, hv, Fin.ext_iff] + omega + +abbrev CompatibleAuxResidue (M d : ℕ) (u : ℤ) := + {v : Fin d // ∃ c : ℤ, c ≡ u [ZMOD (M : ℤ)] ∧ c ≡ (v.val : ℤ) [ZMOD (d : ℤ)]} + +noncomputable instance compatibleAuxResidueFintype (M d : ℕ) (u : ℤ) : + Fintype (CompatibleAuxResidue M d u) := Fintype.ofFinite _ + +def compatibleAuxResidueOfPoint (M d : ℕ) (hd : 0 < d) (u x : ℤ) + (hx : x ≡ u [ZMOD (M : ℤ)]) : CompatibleAuxResidue M d u := + ⟨integerResidueLabel d hd x, x, hx, (integerResidueLabel_eq_iff d hd x _).mp rfl⟩ + +theorem compatibleAuxResidueOfPoint_eq_iff (M d : ℕ) (hd : 0 < d) (u x : ℤ) + (hx : x ≡ u [ZMOD (M : ℤ)]) (v : CompatibleAuxResidue M d u) : + compatibleAuxResidueOfPoint M d hd u x hx = v ↔ + x ≡ (v.val.val : ℤ) [ZMOD (d : ℤ)] := by + rw [Subtype.ext_iff] + exact integerResidueLabel_eq_iff d hd x v.val + +theorem compatibleAuxResidue_nonempty (M d : ℕ) (hd : 0 < d) (u : ℤ) : + Nonempty (CompatibleAuxResidue M d u) := + ⟨compatibleAuxResidueOfPoint M d hd u u (Int.ModEq.refl u)⟩ + +noncomputable def CompatibleAuxResidue.baseValue {M d : ℕ} {u : ℤ} + (v : CompatibleAuxResidue M d u) : ℤ := Classical.choose v.property + +theorem CompatibleAuxResidue.baseValue_spec {M d : ℕ} {u : ℤ} + (v : CompatibleAuxResidue M d u) : + v.baseValue ≡ u [ZMOD (M : ℤ)] ∧ + v.baseValue ≡ (v.val.val : ℤ) [ZMOD (d : ℤ)] := Classical.choose_spec v.property + +noncomputable def CompatibleAuxResidue.refinedValue {M d J : ℕ} {u : ℤ} + (v : CompatibleAuxResidue M d u) (hcop : (M * d).Coprime J) (w : ℤ) : ℤ := + Classical.choose ((coprime_refinement_preserves_compatibility hcop u v.val.val w).mp v.property) + +theorem CompatibleAuxResidue.refinedValue_spec {M d J : ℕ} {u : ℤ} + (v : CompatibleAuxResidue M d u) (hcop : (M * d).Coprime J) (w : ℤ) : + v.refinedValue hcop w ≡ u [ZMOD (M : ℤ)] ∧ + v.refinedValue hcop w ≡ (v.val.val : ℤ) [ZMOD (d : ℤ)] ∧ + v.refinedValue hcop w ≡ w [ZMOD (J : ℤ)] := + Classical.choose_spec ((coprime_refinement_preserves_compatibility hcop u v.val.val w).mp v.property) + +theorem CompatibleAuxResidue.baseConstraint_iff {M d : ℕ} {u : ℤ} + (v : CompatibleAuxResidue M d u) (x : ℤ) : + (x ≡ u [ZMOD (M : ℤ)] ∧ x ≡ (v.val.val : ℤ) [ZMOD (d : ℤ)]) ↔ + x ≡ v.baseValue [ZMOD (Nat.lcm M d : ℤ)] := + residue_constraints_iff_lcm v.baseValue_spec.1 v.baseValue_spec.2 x + +theorem refinement_modEq_iff {M J : ℕ} (hcop : M.Coprime J) {u w : ℤ} + (hw : w ≡ u [ZMOD (M : ℤ)]) (x : ℤ) : + x ≡ w [ZMOD (M * J : ℕ)] ↔ + (x ≡ u [ZMOD (M : ℤ)] ∧ x ≡ w [ZMOD (J : ℤ)]) := by + simpa only [hcop.lcm_eq_mul] using + (residue_constraints_iff_lcm hw (show w ≡ w [ZMOD (J : ℤ)] from Int.ModEq.refl w) x).symm + +theorem CompatibleAuxResidue.refinedConstraint_iff {M d J : ℕ} {u : ℤ} + (v : CompatibleAuxResidue M d u) (hcop : (M * d).Coprime J) + (w : ℤ) (hw : w ≡ u [ZMOD (M : ℤ)]) (x : ℤ) : + (x ≡ w [ZMOD (M * J : ℕ)] ∧ x ≡ (v.val.val : ℤ) [ZMOD (d : ℤ)]) ↔ + x ≡ v.refinedValue hcop w [ZMOD (Nat.lcm M d * J : ℕ)] := by + have hMJ : M.Coprime J := hcop.of_dvd_left (dvd_mul_right M d) + rw [refinement_modEq_iff hMJ hw x] + have hc := v.refinedValue_spec hcop w + exact (and_assoc.trans (and_congr_right fun _ => and_comm)).trans + (refined_residue_constraints_iff hcop hc.1 hc.2.1 hc.2.2 x) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residueIndexLength_ge_of_width (a b r v : ℤ) (hr : 0 < r) + (B : ℝ) (hB : 0 ≤ B) (hwidth : (r : ℝ) * (B + 1) ≤ ((b - a : ℤ) : ℝ)) : + B ≤ (residueIndexLength a b r v : ℝ) := by + have hr' : (0 : ℝ) < r := by exact_mod_cast hr + have hwidthpos : (0 : ℝ) < ((b - a : ℤ) : ℝ) := + (mul_pos hr' (by linarith : 0 < B + 1)).trans_le hwidth + have hab : a ≤ b := by + have h : (0 : ℤ) ≤ b - a := by exact_mod_cast hwidthpos.le + omega + have hlower := (abs_le.mp (residueIndexLength_absolute_error a b r v hab hr)).1 + have hratio : B + 1 ≤ ((b - a : ℤ) : ℝ) / (r : ℝ) := + (le_div_iff₀ hr').mpr (by simpa only [mul_comm] using hwidth) + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residueIndexLength_half_width (a v : ℤ) (N r : ℕ) (hr : 0 < r) + (hwidth : 2 * (r : ℝ) ≤ (N : ℝ)) : + 0 < residueIndexLength a (a + N) r v ∧ + (N : ℝ) / 2 ≤ (r : ℝ) * (residueIndexLength a (a + N) r v : ℝ) := by + have hrz : (0 : ℤ) < r := by exact_mod_cast hr + have hrr : (0 : ℝ) < r := by exact_mod_cast hr + have hlength := residueIndexLength_ge_of_width a (a + N) r v hrz 1 (by norm_num) + (by simpa only [add_sub_cancel_left, Int.cast_natCast] using (show (r : ℝ) * (1 + 1) ≤ (N : ℝ) by linarith)) + have herror := residueIndexLength_absolute_error a (a + N) r v (by omega) hrz + simp only [add_sub_cancel_left, Int.cast_natCast] at herror + have hlo := (abs_le.mp herror).1 + have hmul := mul_le_mul_of_nonneg_left hlo hrr.le + have hdiv : (r : ℝ) * ((N : ℝ) / r) = (N : ℝ) := by field_simp + refine ⟨?_, ?_⟩ + · exact_mod_cast (show (0 : ℝ) < (residueIndexLength a (a + N) r v : ℝ) by linarith) + · nlinarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residueIndexLength_large_of_exp (lo a : ℤ) (N M : ℕ) (P B : ℝ) + (hM : 0 < M) (hB : 0 ≤ B) (hmodulus : (M : ℝ) ≤ Real.exp P) + (hside : Real.exp (P + B + 2) ≤ (N : ℝ)) : + Real.exp B ≤ (residueIndexLength lo (lo + N) M a : ℝ) := by + have hMreal : (0 : ℝ) < M := Nat.cast_pos.mpr hM + have hBexp : 1 ≤ Real.exp B := Real.one_le_exp hB + have htwo : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hproduct : 2 * (M : ℝ) * Real.exp B ≤ Real.exp (P + B + 2) := by + rw [Real.exp_add, Real.exp_add] + calc + 2 * (M : ℝ) * Real.exp B ≤ 2 * Real.exp P * Real.exp B := by + gcongr + _ ≤ Real.exp P * Real.exp B * Real.exp 2 := by + have hm := mul_le_mul_of_nonneg_left htwo + (mul_nonneg (Real.exp_pos P).le (Real.exp_pos B).le) + nlinarith + have hwidth : 2 * (M : ℝ) ≤ (N : ℝ) := by + have hm := mul_le_mul_of_nonneg_left hBexp (show 0 ≤ 2 * (M : ℝ) by positivity) + nlinarith [hproduct.trans hside] + have hlength := (residueIndexLength_half_width lo a N M hM hwidth).2 + apply le_of_mul_le_mul_left (a := (M : ℝ)) _ hMreal + nlinarith [hproduct.trans hside] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residueIndexLength_le_width (lo a : ℤ) (N M : ℕ) (hM : 0 < M) : + residueIndexLength lo (lo + N) M a ≤ N := by + rw [residueIndexLength_eq_card lo (lo + N) M a (Nat.cast_pos.mpr hM)] + have h := Finset.card_filter_le (Finset.Ico lo (lo + N)) (fun z => z ≡ a [ZMOD (M : ℤ)]) + simpa only [Int.card_Ico, add_sub_cancel_left, Int.toNat_natCast] using h + +theorem residue_slice_counting_cost (lo a : ℤ) (H N M : ℕ) (p : ℝ) + (hM : 0 < M) (hNH : N ≤ H) (hH : Real.exp (p + 2) ≤ (H : ℝ)) + (hcount : Real.exp (-p) * (H : ℝ) ≤ (residueIndexLength lo (lo + N) M a : ℝ)) : + (M : ℝ) ≤ Real.exp (p + 2) ∧ Real.exp (-p) * (H : ℝ) ≤ (N : ℝ) := by + have hMreal : (0 : ℝ) < M := Nat.cast_pos.mpr hM + have hHreal : (0 : ℝ) < H := (Real.exp_pos (p + 2)).trans_le hH + have htwo : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hinv : Real.exp (-p) * Real.exp p = 1 := by rw [← Real.exp_add]; simp + have hsmall : 2 ≤ Real.exp (-p) * (H : ℝ) := by + calc + 2 ≤ Real.exp 2 := htwo + _ = Real.exp (-p) * Real.exp (p + 2) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp (-p) * (H : ℝ) := mul_le_mul_of_nonneg_left hH (Real.exp_pos _).le + have herror := (abs_le.mp (residueIndexLength_absolute_error lo (lo + N) M a + (by omega) (Nat.cast_pos.mpr hM))).2 + simp only [add_sub_cancel_left, Int.cast_natCast] at herror + have hNHreal : (N : ℝ) ≤ H := by exact_mod_cast hNH + have hquotient : Real.exp (-p) * (H : ℝ) / 2 ≤ (H : ℝ) / M := by + have hquot := div_le_div_of_nonneg_right hNHreal hMreal.le + linarith + have hmul : Real.exp (-p) * (H : ℝ) / 2 * (M : ℝ) ≤ H := + (le_div_iff₀ hMreal).mp hquotient + have hfactor : Real.exp (-p) * (M : ℝ) ≤ 2 := by + apply le_of_mul_le_mul_right (a := (H : ℝ)) _ hHreal + nlinarith [hmul] + have hbound : (M : ℝ) ≤ 2 * Real.exp p := by + have h := mul_le_mul_of_nonneg_right hfactor (Real.exp_pos p).le + calc + (M : ℝ) = (Real.exp (-p) * (M : ℝ)) * Real.exp p := by nlinarith [hinv] + _ ≤ 2 * Real.exp p := h + refine ⟨?_, ?_⟩ + · calc + (M : ℝ) ≤ 2 * Real.exp p := hbound + _ ≤ Real.exp 2 * Real.exp p := mul_le_mul_of_nonneg_right htwo (Real.exp_pos p).le + _ = Real.exp (p + 2) := by rw [← Real.exp_add, add_comm] + · exact hcount.trans (by exact_mod_cast residueIndexLength_le_width lo a N M hM) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceNormalizedCell.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceNormalizedCell.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d5170a7fb265593f77d7c77cde4c4efa3624498 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceNormalizedCell.lean @@ -0,0 +1,445 @@ +import Mathlib.Tactic +import OAI.Combinatorics.Progressions.Geometry.BoxBlockBudget +import OAI.Combinatorics.Progressions.Polynomial.PolynomialPatchProductBudget +import OAI.Combinatorics.Progressions.Sampling.NormalizedRealBoxHalfGrid + +namespace OAI + +section + +namespace Erdos3 + +structure ResidueBoxSlice {ι : Type*} (N : ι → ℕ) (q : ℕ) where + start : ι → ℕ + length : ι → ℕ + inside : ∀ i j, j < length i → start i + q * j < N i + +namespace ResidueBoxSlice + +variable {ι : Type*} {N : ι → ℕ} {q : ℕ} + +def point (A : ResidueBoxSlice N q) (j : ∀ i, Fin (A.length i)) : ∀ i, Fin (N i) := + fun i => ⟨A.start i + q * (j i).val, A.inside i _ (j i).isLt⟩ + +noncomputable def center (A : ResidueBoxSlice N q) : ι → ℝ := + fun i => (A.start i : ℝ) / N i + +theorem point_residue (A : ResidueBoxSlice N q) (j : ∀ i, Fin (A.length i)) (i : ι) : + (A.point j i).val % q = A.start i % q := by + simp [point, Nat.add_mod] + +noncomputable abbrev ofBlocks (H : ι → ℕ) (hq : 0 < q) (hH : ∀ i, 0 < H i) + (a : ∀ i, (FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)).Label) : + ResidueBoxSlice N q where + start i := (FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)).start (a i) + length i := (FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)).length (a i) + inside i _j hj := (FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)).point_lt (a i) hj + +theorem ofBlocks_point (H : ι → ℕ) (hq : 0 < q) (hH : ∀ i, 0 < H i) + (a : ∀ i, (FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)).Label) + (j : ∀ i, Fin ((ofBlocks H hq hH a).length i)) : + (ofBlocks H hq hH a).point j = + BoxProgressionPartition.point (fun i => FiniteProgressionPartition.blocks (N i) q (H i) hq (hH i)) a j := by + funext i + apply Fin.ext + rfl + +end ResidueBoxSlice +end Erdos3 + +end + +section + +namespace Erdos3 + +namespace FiniteProgressionPartition + +theorem entireResidue_length_ge {N q H : ℕ} (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) (i : (blocks N q (N + 1) hq (Nat.succ_pos N)).Label) : + H ≤ (blocks N q (N + 1) hq (Nat.succ_pos N)).length i := by + have hdiv : N / q / (N + 1) = 0 := + Nat.div_eq_of_lt ((Nat.div_le_self N q).trans_lt (Nat.lt_succ_self N)) + have hi : i.2.val = 0 := by + have hi := i.2.isLt + omega + have hHN : H ≤ N := (Nat.le_mul_of_pos_left H hq).trans hfit + have hlast : i.1.val + q * (H - 1) < N := by + calc + _ < q + q * (H - 1) := Nat.add_lt_add_right i.1.isLt _ + _ = q * ((H - 1) + 1) := by ring + _ = q * H := by rw [Nat.sub_add_cancel hH] + _ ≤ N := hfit + have hlen : H - 1 < truncatedProgressionLength N (progressionBlockStart i) q (N + 1) := by + apply (lt_truncatedProgressionLength_iff hq).mpr + refine ⟨by omega, ?_⟩ + simpa only [progressionBlockStart, hi, Nat.mul_zero, Nat.add_zero] using hlast + change H ≤ truncatedProgressionLength N (progressionBlockStart i) q (N + 1) + omega + +noncomputable def comparableResidues (N q H : ℕ) (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) : FiniteProgressionPartition N := + (blocks N q (N + 1) hq (Nat.succ_pos N)).bind + (fun i => mergedIntervals _ H hH (entireResidue_length_ge hq hH hfit i)) + +theorem comparableResidues_step (N q H : ℕ) (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) (i : (comparableResidues N q H hq hH hfit).Label) : + (comparableResidues N q H hq hH hfit).step i = q := by + change q * 1 = q + exact mul_one q + +theorem comparableResidues_length (N q H : ℕ) (hq : 0 < q) (hH : 0 < H) + (hfit : q * H ≤ N) (i : (comparableResidues N q H hq hH hfit).Label) : + H ≤ (comparableResidues N q H hq hH hfit).length i ∧ + (comparableResidues N q H hq hH hfit).length i < 2 * H := + mergedIntervals_length_bounds _ H hH (entireResidue_length_ge hq hH hfit i.1) i.2 + +end FiniteProgressionPartition + +open scoped BigOperators + +theorem exists_partition_cell_average {Ω K : Type*} + [Fintype Ω] [Nonempty Ω] [Fintype K] (cell : Ω → K) (f : Ω → ℝ) : + ∃ k, (partitionCell cell k).Nonempty ∧ + (𝔼 x, f x) ≤ 𝔼 x ∈ partitionCell cell k, f x := by + classical + by_contra! hnone + have hstrict (k : K) (hk : (partitionCell cell k).Nonempty) : + (∑ x ∈ partitionCell cell k, f x) < (partitionCell cell k).card * (𝔼 x, f x) := by + have hcard : (0 : ℝ) < (partitionCell cell k).card := by exact_mod_cast hk.card_pos + have h := mul_lt_mul_of_pos_left (hnone k hk) hcard + rwa [Finset.card_mul_expect] at h + have hle (k : K) : (∑ x ∈ partitionCell cell k, f x) ≤ + (partitionCell cell k).card * (𝔼 x, f x) := by + by_cases hk : (partitionCell cell k).Nonempty + · exact (hstrict k hk).le + · simp [Finset.not_nonempty_iff_eq_empty.mp hk] + obtain ⟨x₀⟩ := ‹Nonempty Ω› + have hk : (partitionCell cell (cell x₀)).Nonempty := + ⟨x₀, (mem_partitionCell cell (cell x₀) x₀).mpr rfl⟩ + have hsum := Finset.sum_lt_sum (fun k (_ : k ∈ (Finset.univ : Finset K)) => hle k) + ⟨cell x₀, Finset.mem_univ _, hstrict _ hk⟩ + rw [sum_partitionCell, ← Finset.sum_mul, card_partitionCell_sum, + Fintype.expect_eq_sum_div_card] at hsum + have hcard : (Fintype.card Ω : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + rw [mul_div_cancel₀ _ hcard] at hsum + exact lt_irrefl _ hsum + +theorem exists_comparable_residueBoxSlice {I : Type*} [Fintype I] [DecidableEq I] + (N H : I → ℕ) {q : ℕ} (hq : 0 < q) (hH : ∀ i, 0 < H i) + (hfit : ∀ i, q * H i ≤ N i) (f : (∀ i, Fin (N i)) → ℝ) : + ∃ A : ResidueBoxSlice N q, + (∀ i, H i ≤ A.length i ∧ A.length i < 2 * H i) ∧ + (𝔼 x, f x) ≤ 𝔼 j : (∀ i, Fin (A.length i)), f (A.point j) := by + classical + let P := fun i => FiniteProgressionPartition.comparableResidues (N i) q (H i) hq (hH i) (hfit i) + let : ∀ i, NeZero (N i) := fun i => ⟨ne_of_gt ((Nat.mul_pos hq (hH i)).trans_le (hfit i))⟩ + obtain ⟨k, _, hk⟩ := exists_partition_cell_average (BoxProgressionPartition.cell P) f + let A : ResidueBoxSlice N q := { + start := fun i => (P i).start (k i) + length := fun i => (P i).length (k i) + inside := fun i j hj => by + have hp := (P i).point_lt (k i) hj + rwa [FiniteProgressionPartition.comparableResidues_step] at hp } + refine ⟨A, ?_, ?_⟩ + · intro i + exact FiniteProgressionPartition.comparableResidues_length (N i) q (H i) hq (hH i) (hfit i) (k i) + · rw [BoxProgressionPartition.expect_cell] at hk + convert hk using 1 + apply Finset.expect_congr rfl + intro j _ + congr 1 + ext i + simp only [ResidueBoxSlice.point, BoxProgressionPartition.point_val, + FiniteProgressionPartition.comparableResidues_step, A, P] + +theorem exists_narrow_residueBoxSlice {I : Type*} [Fintype I] [DecidableEq I] + (N : I → ℕ) {q : ℕ} (hq : 0 < q) {ρ : ℝ} (_hρ : 0 < ρ) (hρ1 : ρ ≤ 1) + (hlarge : ∀ i, 4 * (q : ℝ) ≤ ρ * N i) (f : (∀ i, Fin (N i)) → ℝ) : + ∃ A : ResidueBoxSlice N q, + (∀ i, 0 < A.length i ∧ ρ * N i ≤ 4 * q * A.length i ∧ + (q : ℝ) * A.length i ≤ ρ * N i) ∧ + (𝔼 x, f x) ≤ 𝔼 j : (∀ i, Fin (A.length i)), f (A.point j) := by + let H : I → ℕ := fun i => ⌊ρ * N i / (2 * q)⌋₊ + have hqR : (0 : ℝ) < q := by exact_mod_cast hq + have htwoq : (0 : ℝ) < 2 * q := by positivity + have harg (i : I) : 2 ≤ ρ * N i / (2 * q) := + (le_div_iff₀ htwoq).mpr (by nlinarith [hlarge i]) + have hH (i : I) : 0 < H i := Nat.floor_pos.mpr (by linarith [harg i]) + have hupper (i : I) : (H i : ℝ) * (2 * q) ≤ ρ * N i := + (le_div_iff₀ htwoq).mp (Nat.floor_le (by linarith [harg i])) + have hlower (i : I) : ρ * N i ≤ 4 * q * H i := by + have hn : ρ * N i / (2 * q) < (H i : ℝ) + 1 := Nat.lt_floor_add_one _ + have hh : 1 ≤ (H i : ℝ) := by exact_mod_cast hH i + have hquot : ρ * N i / (2 * q) ≤ 2 * H i := by linarith + have hm := (div_le_iff₀ htwoq).mp hquot + nlinarith + have hfit (i : I) : q * H i ≤ N i := by + have hn : ρ * (N i : ℝ) ≤ N i := mul_le_of_le_one_left (Nat.cast_nonneg _) hρ1 + have hm : (q : ℝ) * H i ≤ N i := by + nlinarith [hupper i, mul_nonneg (Nat.cast_nonneg (α := ℝ) q) (Nat.cast_nonneg (α := ℝ) (H i))] + exact_mod_cast hm + obtain ⟨A, hA, hscore⟩ := exists_comparable_residueBoxSlice N H hq hH hfit f + refine ⟨A, ?_, hscore⟩ + intro i + have hlow : (H i : ℝ) ≤ A.length i := by exact_mod_cast (hA i).1 + have hhigh : (A.length i : ℝ) < 2 * H i := by exact_mod_cast (hA i).2 + refine ⟨(hH i).trans_le (hA i).1, ?_, ?_⟩ + · exact (hlower i).trans (mul_le_mul_of_nonneg_left hlow (by positivity)) + · have hm := mul_le_mul_of_nonneg_left hhigh.le hqR.le + nlinarith [hupper i] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem denseResidueMeshInterval (b len M : ℕ) (hM : 0 < M) (hlen : 2 * M < len) : + let lo := b / M + 1 + let hi := (b + len) / M + lo < hi ∧ b ≤ M * lo ∧ M * hi ≤ b + len ∧ + len - (M * hi - M * lo) ≤ 2 * M := by + dsimp only + have hb := Nat.mod_add_div b M + have he := Nat.mod_add_div (b + len) M + have hbm := Nat.mod_lt b hM + have hem := Nat.mod_lt (b + len) hM + have hstart : b < M * (b / M + 1) := by nlinarith + have hstartUpper : M * (b / M + 1) ≤ b + M := by + rw [Nat.mul_add, Nat.mul_one] + omega + have hend : M * ((b + len) / M) ≤ b + len := by omega + have hendLower : b + len < M * ((b + len) / M) + M := by omega + have hlt : b / M + 1 < (b + len) / M := by nlinarith + refine ⟨hlt, hstart.le, hend, ?_⟩ + have hmul : M * (b / M + 1) ≤ M * ((b + len) / M) := + Nat.mul_le_mul_left M hlt.le + omega + +theorem denseResidueMeshInterval_code_bound (b len M K : ℕ) + (hM : 0 < M) (hlen : 2 * M < len) (hbox : b + len ≤ K * M) : + b / M + 1 ≤ K ∧ (b + len) / M ≤ K := by + have h := denseResidueMeshInterval b len M hM hlen + dsimp only at h + have hhi : (b + len) / M ≤ K := by nlinarith [h.2.2.1] + exact ⟨h.1.le.trans hhi, hhi⟩ + +namespace ResidueBoxSlice +variable {X : Type*} {N : X → ℕ} {q : ℕ} + +theorem residueIndex_endpoint_le (S : ResidueBoxSlice N q) (hq : 0 < q) + (hlen : ∀ i, 0 < S.length i) (i : X) : + S.start i / q + S.length i ≤ N i := by + have hi := S.inside i (S.length i - 1) (by have := hlen i; omega) + have hmul : S.length i - 1 ≤ q * (S.length i - 1) := by nlinarith + have hdiv : S.start i / q ≤ S.start i := Nat.div_le_self _ _ + omega + +def meshRounded (S : ResidueBoxSlice N q) (_hq : 0 < q) (M : ℕ) + (hM : 0 < M) (hlen : ∀ i, 2 * M < S.length i) : ResidueBoxSlice N q where + start i := S.start i % q + q * (M * (S.start i / q / M + 1)) + length i := M * ((S.start i / q + S.length i) / M) - M * (S.start i / q / M + 1) + inside i j hj := by + have h := denseResidueMeshInterval (S.start i / q) (S.length i) M hM (hlen i) + dsimp only at h + let offset := M * (S.start i / q / M + 1) - S.start i / q + have ho : offset + j < S.length i := by dsimp [offset]; omega + have he := S.inside i (offset + j) ho + have hmod := Nat.mod_add_div (S.start i) q + have hstart := h.2.1 + have hoff : offset + S.start i / q = M * (S.start i / q / M + 1) := by + dsimp [offset] + omega + nlinarith + +theorem meshRounded_length_pos (S : ResidueBoxSlice N q) (hq : 0 < q) (M : ℕ) + (hM : 0 < M) (hlen : ∀ i, 2 * M < S.length i) (i : X) : + 0 < (S.meshRounded hq M hM hlen).length i := by + have h := (denseResidueMeshInterval (S.start i / q) (S.length i) M hM (hlen i)).1 + change 0 < M * ((S.start i / q + S.length i) / M) - M * (S.start i / q / M + 1) + have := Nat.mul_lt_mul_of_pos_left h hM + omega + +theorem meshRounded_contained (S : ResidueBoxSlice N q) (hq : 0 < q) (M : ℕ) + (hM : 0 < M) (hlen : ∀ i, 2 * M < S.length i) : + ∃ offset : X → ℕ, + (∀ i, (S.meshRounded hq M hM hlen).start i = S.start i + q * offset i) ∧ + (∀ i, offset i + (S.meshRounded hq M hM hlen).length i ≤ S.length i) ∧ + ∀ i, S.length i - (S.meshRounded hq M hM hlen).length i ≤ 2 * M := by + refine ⟨fun i => M * (S.start i / q / M + 1) - S.start i / q, ?_, ?_, ?_⟩ + · intro i + have h := (denseResidueMeshInterval (S.start i / q) (S.length i) M hM (hlen i)).2.1 + have he : M * (S.start i / q / M + 1) - S.start i / q + S.start i / q = + M * (S.start i / q / M + 1) := by omega + have hmod := Nat.mod_add_div (S.start i) q + change _ + _ * _ = _ + _ * _ + nlinarith + · intro i + have h := denseResidueMeshInterval (S.start i / q) (S.length i) M hM (hlen i) + dsimp only at h + dsimp only [meshRounded] + have hstart := h.2.1 + have hend := h.2.2.1 + have hmul := Nat.mul_le_mul_left M h.1.le + omega + · intro i + exact (denseResidueMeshInterval (S.start i / q) (S.length i) M hM (hlen i)).2.2.2 + +end ResidueBoxSlice +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators + +variable {ι : Type*} {N : ι → ℕ} {q : ℕ} + +theorem log_side_loss (A : ResidueBoxSlice N q) (hN : ∀ i, 0 < N i) + {η : ℝ} (hη : 0 < η) (hlength : ∀ i, η * N i ≤ (A.length i : ℝ)) (i : ι) : + Real.log (N i) - Real.log (A.length i) ≤ -Real.log η := by + have hNi : (0 : ℝ) < N i := by exact_mod_cast hN i + have h := Real.log_le_log (mul_pos hη hNi) (hlength i) + rw [Real.log_mul hη.ne' hNi.ne'] at h + linarith + +theorem log_volume_loss [Fintype ι] (A : ResidueBoxSlice N q) (hN : ∀ i, 0 < N i) + {η : ℝ} (hη : 0 < η) (hlength : ∀ i, η * N i ≤ (A.length i : ℝ)) : + (∑ i, Real.log (N i)) - ∑ i, Real.log (A.length i) ≤ + (Fintype.card ι : ℝ) * (-Real.log η) := by + have h := Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset ι)) => A.log_side_loss hN hη hlength i) + simpa only [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using h + +theorem spatial_freezing_log_side_loss [Fintype ι] (A : ResidueBoxSlice N q) + (hN : ∀ i, 0 < N i) (hq : 0 < q) {θ ρ : ℝ} (hθ : 0 < θ) (hρ : 0 < ρ) + (hlength : ∀ i, θ * ρ * N i / (4 * q * (Fintype.card ι + 1)) ≤ (A.length i : ℝ)) (i : ι) : + Real.log (N i) - Real.log (A.length i) ≤ + Real.log (4 * q * ((Fintype.card ι : ℝ) + 1)) - Real.log θ - Real.log ρ := by + have hqR : (0 : ℝ) < q := by exact_mod_cast hq + have hden : (0 : ℝ) < 4 * q * ((Fintype.card ι : ℝ) + 1) := by positivity + have h := A.log_side_loss hN (div_pos (mul_pos hθ hρ) hden) + (fun i => by simpa only [div_mul_eq_mul_div] using hlength i) i + rw [Real.log_div (mul_pos hθ hρ).ne' hden.ne', Real.log_mul hθ.ne' hρ.ne'] at h + linarith + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open MvPolynomial + +variable {ι : Type*} {N : ι → ℕ} {q s d : ℕ} + +noncomputable def parameters (A : ResidueBoxSlice N q) (i : ι) : MvPolynomial ι ℝ := + C (A.start i : ℝ) + (q : ℝ) • X i + +theorem parameters_degree (A : ResidueBoxSlice N q) (i : ι) : + A.parameters i ∈ weightedSupportLE (fun _ : ι => 1) 1 := + (weightedSupportLE _ _).add_mem (weightedSupportLE_C _ _ _) + ((weightedSupportLE _ _).smul_mem _ (weightedSupportLE_X _ i)) + +noncomputable def reparamPatch (A : ResidueBoxSlice N q) (P : PolynomialPatch ι s d) : + PolynomialPatch ι s d := P.reparam A.parameters A.parameters_degree + +@[simp] theorem reparamPatch_kernel (A : ResidueBoxSlice N q) (P : PolynomialPatch ι s d) : + (A.reparamPatch P).kernel = P.kernel := rfl + +theorem reparamPatch_value (A : ResidueBoxSlice N q) (P : PolynomialPatch ι s d) + (j : ∀ i, Fin (A.length i)) : + (A.reparamPatch P).value (fun i => ((j i).val : ℝ)) = + P.value (fun i => ((A.point j i).val : ℝ)) := by + rw [reparamPatch, PolynomialPatch.reparam_value] + congr 1 + funext i + simp [parameters, point] + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3 + +theorem exists_normalized_cell_of_coordinate_intervals {ι : Type*} + (T lo hi : ι → ℝ) (hT : ∀ i, 0 < T i) {Q : ℕ} (hQ : 0 < Q) + (hlo : ∀ i, |lo i| ≤ T i) (hhi : ∀ i, |hi i| ≤ T i) + (hwidth : ∀ i, hi i - lo i ≤ 2 * T i / Q) : + ∃ a : ι → Fin (Q + 1), ∀ v : ι → ℝ, + (∀ i, lo i ≤ v i ∧ v i ≤ hi i) → + ∀ i, |v i - normalizedRealBoxGrid T Q a i| ≤ T i * (2 / Q) := by + let mid := fun i => (lo i + hi i) / 2 + have hm (i) : |mid i| ≤ T i := by + apply abs_le.mpr + have hl := abs_le.mp (hlo i) + have hh := abs_le.mp (hhi i) + dsimp only [mid] + constructor <;> linarith + obtain ⟨a, ha⟩ := exists_normalizedRealBoxGrid_half_cell T hT hQ mid hm + refine ⟨a, ?_⟩ + intro v hv i + have hd : |v i - mid i| ≤ T i / Q := by + apply abs_le.mpr + have hw := hwidth i + rw [mul_div_assoc] at hw + have hh := hv i + dsimp only [mid] + constructor <;> linarith + calc + _ ≤ |v i - mid i| + |mid i - normalizedRealBoxGrid T Q a i| := abs_sub_le _ _ _ + _ ≤ T i / Q + T i / Q := add_le_add hd (ha i) + _ = T i * (2 / Q) := by ring + +namespace ResidueBoxSlice + +theorem exists_affine_normalized_cell {ι : Type*} {N : ι → ℕ} {q Q : ℕ} + (A : ResidueBoxSlice N q) (hlen : ∀ i, 0 < A.length i) + (origin : ι → ℝ) (step : ℝ) (hstep : 0 ≤ step) + (T : ι → ℝ) (hT : ∀ i, 0 < T i) (hQ : 0 < Q) + (hparent : ∀ i n, n < N i → |origin i + step * n| ≤ T i) + (hwidth : ∀ i, step * q * A.length i ≤ 2 * T i / Q) : + ∃ a : ι → Fin (Q + 1), ∀ j : ∀ i, Fin (A.length i), ∀ i, + |origin i + step * (A.point j i).val - normalizedRealBoxGrid T Q a i| ≤ + T i * (2 / Q) := by + let lo := fun i => origin i + step * A.start i + let hi := fun i => origin i + step * (A.start i + q * (A.length i - 1) : ℕ) + have hlo (i) : |lo i| ≤ T i := by + apply hparent i (A.start i) + simpa only [Nat.mul_zero, Nat.add_zero] using A.inside i 0 (hlen i) + have hhi (i) : |hi i| ≤ T i := + hparent i _ (A.inside i _ (Nat.sub_lt (hlen i) (by decide))) + have hw (i) : hi i - lo i ≤ 2 * T i / Q := by + have hs : step * (q : ℝ) * (A.length i - 1 : ℕ) ≤ step * q * A.length i := + mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (Nat.sub_le _ _)) (by positivity) + dsimp only [hi, lo] + push_cast + nlinarith [hwidth i] + obtain ⟨a, ha⟩ := exists_normalized_cell_of_coordinate_intervals T lo hi hT hQ hlo hhi hw + refine ⟨a, fun j => ha (fun i => origin i + step * (A.point j i).val) ?_⟩ + intro i + have hj : (j i).val ≤ A.length i - 1 := by have := (j i).isLt; omega + have hs := mul_le_mul_of_nonneg_left (Nat.cast_le.mpr hj : ((j i).val : ℝ) ≤ _) + (show 0 ≤ step * (q : ℝ) by positivity) + dsimp only [lo, hi, point] + push_cast + constructor + · have hn : 0 ≤ step * (q : ℝ) * ((j i).val : ℝ) := by positivity + nlinarith + · nlinarith + +end ResidueBoxSlice +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceUpperFailure.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceUpperFailure.lean new file mode 100644 index 0000000000000000000000000000000000000000..208a400e06af9abc15b24f9e38cb73efcb9a17c7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSliceUpperFailure.lean @@ -0,0 +1,538 @@ +import OAI.Combinatorics.Progressions.Estimates.SlicedSourceAccuracy +import OAI.Combinatorics.Progressions.Geometry.CoordinateTreeOutside +import OAI.Combinatorics.Progressions.Lattices.ResiduePrimeDensityError + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def affineStabilityTolerance (T : ℝ) : ℝ := Real.exp (-(T + 4)) + +noncomputable def affineIncrementTolerance (L T : ℝ) : ℝ := Real.exp (-(L + T + 4)) + +theorem affineComparisonTolerance_bounds {L T level : ℝ} + (hT : 0 ≤ T) (hlower : Real.exp (-L) ≤ level) : + 0 < Real.exp (-T) ∧ Real.exp (-T) ≤ 1 ∧ + (Real.exp (-T))⁻¹ ≤ Real.exp T ∧ 0 < level ∧ + 0 < affineStabilityTolerance T ∧ affineStabilityTolerance T ≤ Real.exp (-T) / 8 ∧ + 0 < affineIncrementTolerance L T ∧ affineIncrementTolerance L T ≤ level * Real.exp (-T) / 8 := by + refine ⟨Real.exp_pos _, Real.exp_le_one_iff.mpr (by linarith), ?_, + (Real.exp_pos _).trans_le hlower, Real.exp_pos _, ?_, Real.exp_pos _, ?_⟩ + · simp only [Real.exp_neg, inv_inv, le_refl] + · exact exp_neg_le_exp_neg_div_eight le_rfl + · calc + affineIncrementTolerance L T ≤ Real.exp (-(L + T)) / 8 := exp_neg_le_exp_neg_div_eight le_rfl + _ ≤ level * Real.exp (-T) / 8 := by + rw [neg_add, Real.exp_add] + exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right hlower (Real.exp_pos _).le) (by norm_num) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem modEq_nat_lcm_iff (m n : ℕ) (a b : ℤ) : + a ≡ b [ZMOD (m.lcm n : ℤ)] ↔ a ≡ b [ZMOD (m : ℤ)] ∧ a ≡ b [ZMOD (n : ℤ)] := by + constructor + · intro h + exact ⟨h.of_dvd (by exact_mod_cast Nat.dvd_lcm_left m n), + h.of_dvd (by exact_mod_cast Nat.dvd_lcm_right m n)⟩ + · rintro ⟨hm, hn⟩ + exact Int.modEq_iff_dvd.mpr (Int.coe_lcm_dvd hm.dvd hn.dvd) + +theorem residuePrimeCoordinate_constraints_lcm {ι σ : Type*} [DecidableEq ι] + (M : ℕ) (a u z : σ → ℤ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (huM : ∀ j, u j ≡ a j [ZMOD (M : ℤ)]) + (hux : ∀ i ∈ I, (fun j => (u j : ZMod (q i))) = x i) : + ((∀ j, z j ≡ a j [ZMOD (M : ℤ)]) ∧ + (∀ i ∈ I, (fun j => (z j : ZMod (q i))) = x i)) ↔ + ∀ j, z j ≡ u j [ZMOD (M.lcm (∏ i ∈ I, q i) : ℤ)] := by + constructor + · rintro ⟨hzM, hzx⟩ j + apply (modEq_nat_lcm_iff M (∏ i ∈ I, q i) (z j) (u j)).mpr + refine ⟨(hzM j).trans (huM j).symm, ?_⟩ + apply (modEq_selected_prod_iff q hcop I (z j) (u j)).mpr + intro i hi + apply (ZMod.intCast_eq_intCast_iff (z j) (u j) (q i)).mp + exact congrFun ((hzx i hi).trans (hux i hi).symm) j + · intro hz + have hparts := fun j => (modEq_nat_lcm_iff M (∏ i ∈ I, q i) (z j) (u j)).mp (hz j) + refine ⟨fun j => (hparts j).1.trans (huM j), ?_⟩ + intro i hi + calc + (fun j => (z j : ZMod (q i))) = (fun j => (u j : ZMod (q i))) := by + funext j + exact (ZMod.intCast_eq_intCast_iff (z j) (u j) (q i)).mpr + ((modEq_selected_prod_iff q hcop I (z j) (u j)).mp (hparts j).2 i hi) + _ = x i := hux i hi + +noncomputable def residuePrimeCoordinateCell_lcmEquiv {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) (u : ResiduePrimeCoordinateCell lo N M a q I x) : + ResiduePrimeCoordinateCell lo N M a q I x ≃ + IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M.lcm (∏ i ∈ I, q i) : ℤ)) + (fun j => (u.val j).val) := by + let uv := fun j => (u.val j).val + have huM : ∀ j, uv j ≡ a j [ZMOD (M : ℤ)] := + fun j => (Finset.mem_filter.mp (u.val j).property).2 + have hc := fun z => residuePrimeCoordinate_constraints_lcm M a uv z q hcop I x huM u.property + exact { + toFun := fun z j => ⟨(z.val j).val, Finset.mem_filter.mpr + ⟨(Finset.mem_filter.mp (z.val j).property).1, + (hc _).mp ⟨fun k => (Finset.mem_filter.mp (z.val k).property).2, z.property⟩ j⟩⟩ + invFun := fun z => ⟨fun j => ⟨(z j).val, Finset.mem_filter.mpr + ⟨(Finset.mem_filter.mp (z j).property).1, + ((hc _).mpr (fun k => (Finset.mem_filter.mp (z k).property).2)).1 j⟩⟩, + ((hc _).mpr (fun k => (Finset.mem_filter.mp (z k).property).2)).2⟩ + left_inv := fun z => by apply Subtype.ext; funext j; apply Subtype.ext; rfl + right_inv := fun z => by funext j; apply Subtype.ext; rfl } + +theorem residuePrimeCoordinateMean_lcm {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) (u : ResiduePrimeCoordinateCell lo N M a q I x) : + residuePrimeCoordinateMean f lo N M a q I x = + physicalResidueMean f lo N (M.lcm (∏ i ∈ I, q i)) (fun j => (u.val j).val) := by + classical + exact Fintype.expect_equiv (residuePrimeCoordinateCell_lcmEquiv lo N M a q hcop I x u) + _ _ (fun _ => rfl) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem primeCoordinateProduct_le_exp {ι : Type*} [DecidableEq ι] + (q : ι → ℕ) (I : Finset ι) (p : ℝ) (hq : ∀ i, (q i : ℝ) ≤ Real.exp p) : + ((∏ i ∈ I, q i : ℕ) : ℝ) ≤ Real.exp (p * I.card) := by + rw [Nat.cast_prod] + calc + (∏ i ∈ I, (q i : ℝ)) ≤ ∏ _i ∈ I, Real.exp p := + Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun i _ => hq i) + _ = Real.exp ((I.card : ℝ) * p) := by rw [Finset.prod_const, Real.exp_nat_mul] + _ = Real.exp (p * I.card) := by rw [mul_comm] + +theorem residuePrimeModulus_le_exp {ι : Type*} [DecidableEq ι] + (q : ι → ℕ) (hqpos : ∀ i, 0 < q i) (I : Finset ι) (M : ℕ) (hM : 0 < M) + (A B D : ℝ) (hB : 0 ≤ B) (hmodulus : (M : ℝ) ≤ Real.exp A) + (hq : ∀ i, (q i : ℝ) ≤ Real.exp B) (hcard : (I.card : ℝ) ≤ D) : + ((M.lcm (∏ i ∈ I, q i) : ℕ) : ℝ) ≤ Real.exp (A + B * D) := by + have hp := primeCoordinateProduct_le_exp q I B hq + have hp' := hp.trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hcard hB)) + have hprodpos : 0 < ∏ i ∈ I, q i := Finset.prod_pos (fun i _ => hqpos i) + have hlcm : ((M.lcm (∏ i ∈ I, q i) : ℕ) : ℝ) ≤ (M : ℝ) * ((∏ i ∈ I, q i : ℕ) : ℝ) := by + exact_mod_cast Nat.le_of_dvd (Nat.mul_pos hM hprodpos) (Nat.lcm_dvd_mul M _) + calc + _ ≤ (M : ℝ) * ((∏ i ∈ I, q i : ℕ) : ℝ) := hlcm + _ ≤ Real.exp A * Real.exp (B * D) := mul_le_mul hmodulus hp' (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = Real.exp (A + B * D) := (Real.exp_add _ _).symm + +theorem residuePrimeCell_log_cost {ι σ : Type*} [DecidableEq ι] + (H N : σ → ℕ) (lo u : σ → ℤ) (M : ℕ) (hM : 0 < M) + (q : ι → ℕ) (hqpos : ∀ i, 0 < q i) (I : Finset ι) (A B C D : ℝ) + (hB : 0 ≤ B) (hmodulus : (M : ℝ) ≤ Real.exp A) (hq : ∀ i, (q i : ℝ) ≤ Real.exp B) + (hcard : (I.card : ℝ) ≤ D) (hwidth : ∀ j, Real.exp (-C) * (H j : ℝ) ≤ (N j : ℝ)) + (hlarge : ∀ j, Real.exp (C + (A + B * D) + 2) ≤ (H j : ℝ)) : + ResidueSliceLogCostLE H lo N (M.lcm (∏ i ∈ I, q i)) u (C + (A + B * D) + 2) := by + have hpositive : 0 < M.lcm (∏ i ∈ I, q i) := by + exact Nat.pos_of_ne_zero (Nat.lcm_ne_zero hM.ne' (Finset.prod_pos (fun i _ => hqpos i)).ne') + apply residueSliceLogCostLE_of_bounds H N lo u _ C (A + B * D) hpositive + (residuePrimeModulus_le_exp q hqpos I M hM A B D hB hmodulus hq hcard) hwidth + intro j + calc + Real.exp (A + B * D + 2) = Real.exp (-C) * Real.exp (C + (A + B * D) + 2) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ Real.exp (-C) * (H j : ℝ) := mul_le_mul_of_nonneg_left (hlarge j) (Real.exp_pos _).le + _ ≤ (N j : ℝ) := hwidth j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def residuePrimeCoordinateOutsideEquiv {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (S : Finset {i // i ∉ K}) (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) : + ResiduePrimeCoordinateCell lo N M a q (K ∪ S.image Subtype.val) x ≃ + ResiduePrimeCoordinateCell lo N (M.lcm (∏ i ∈ K, q i)) (fun j => (u.val j).val) + (fun i : {i // i ∉ K} => q i.val) S (fun i => x i.val) := by + let uv := fun j => (u.val j).val + have huM : ∀ j, uv j ≡ a j [ZMOD (M : ℤ)] := + fun j => (Finset.mem_filter.mp (u.val j).property).2 + have hux : ∀ i ∈ K, (fun j => (uv j : ZMod (q i))) = x i := + fun i hi => (u.property i hi).trans (hx i hi).symm + have hc := fun z => residuePrimeCoordinate_constraints_lcm M a uv z q hcop K x huM hux + exact { + toFun := fun z => ⟨fun j => ⟨(z.val j).val, Finset.mem_filter.mpr + ⟨(Finset.mem_filter.mp (z.val j).property).1, + (hc _).mp ⟨fun k => (Finset.mem_filter.mp (z.val k).property).2, + fun i hi => z.property i (Finset.mem_union_left _ hi)⟩ j⟩⟩, + fun i hi => z.property i.val (Finset.mem_union_right K (Finset.mem_image.mpr ⟨i, hi, rfl⟩))⟩ + invFun := fun z => ⟨fun j => ⟨(z.val j).val, Finset.mem_filter.mpr + ⟨(Finset.mem_filter.mp (z.val j).property).1, + ((hc _).mpr (fun k => (Finset.mem_filter.mp (z.val k).property).2)).1 j⟩⟩, by + intro i hi + rcases Finset.mem_union.mp hi with hi | hi + · exact ((hc _).mpr (fun k => (Finset.mem_filter.mp (z.val k).property).2)).2 i hi + · obtain ⟨j, hj, rfl⟩ := Finset.mem_image.mp hi + exact z.property j hj⟩ + left_inv := fun z => by apply Subtype.ext; funext j; apply Subtype.ext; rfl + right_inv := fun z => by apply Subtype.ext; funext j; apply Subtype.ext; rfl } + +theorem residuePrimeCoordinateMean_outside {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (S : Finset {i // i ∉ K}) (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) : + residuePrimeCoordinateMean f lo N M a q (K ∪ S.image Subtype.val) x = + residuePrimeCoordinateMean f lo N (M.lcm (∏ i ∈ K, q i)) (fun j => (u.val j).val) + (fun i : {i // i ∉ K} => q i.val) S (fun i => x i.val) := by + classical + exact Fintype.expect_equiv (residuePrimeCoordinateOutsideEquiv lo N M a q hcop K base u S x hx) + _ _ (fun _ => rfl) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def ResidueSliceUpperComparison {σ : Type*} [Fintype σ] [DecidableEq σ] + (h g : (σ → ℤ) → ℂ) (parent : σ → ℤ) (H : σ → ℕ) (P level ε : ℝ) : Prop := + ∀ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (u : σ → ℤ), 0 < M → + PhysicalSubbox parent H lo N → ResidueSliceLogCostLE H lo N M u P → + (physicalResidueMean h lo N M u).re ≤ level * (physicalResidueMean g lo N M u).re + ε + +theorem ResidueSliceUpperComparison.on_prime_cell {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {parent lo a : σ → ℤ} {H N : σ → ℕ} {P level ε : ℝ} + (hupper : ResidueSliceUpperComparison h g parent H P level ε) + (hbox : PhysicalSubbox parent H lo N) (M : ℕ) (hM : 0 < M) + (q : ι → ℕ) (hqpos : ∀ i, 0 < q i) (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) + (hcost : ∀ u : σ → ℤ, ResidueSliceLogCostLE H lo N (M.lcm (∏ i ∈ I, q i)) u P) + (hne : Nonempty (ResiduePrimeCoordinateCell lo N M a q I x)) : + (residuePrimeCoordinateMean h lo N M a q I x).re ≤ + level * (residuePrimeCoordinateMean g lo N M a q I x).re + ε := by + obtain ⟨u⟩ := hne + have hpositive : 0 < M.lcm (∏ i ∈ I, q i) := + Nat.pos_of_ne_zero (Nat.lcm_ne_zero hM.ne' (Finset.prod_pos (fun i _ => hqpos i)).ne') + have hslice := hupper lo N _ (fun j => (u.val j).val) hpositive hbox (hcost _) + rw [residuePrimeCoordinateMean_lcm h lo N M a q hcop I x u, + residuePrimeCoordinateMean_lcm g lo N M a q hcop I x u] + exact hslice + +theorem ResiduePrimeCoordinateStable.refinement_upper_bound {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} + {r : ℕ} {δ level ε : ℝ} {I : Finset ι} {x : ∀ i, σ → ZMod (q i)} + (hstable : ResiduePrimeCoordinateStable g lo N M a q r δ I x) (hlevel : 0 ≤ level) + (J : Finset ι) (hIJ : Disjoint I J) (hJ : J.card ≤ r) + (y : ∀ i, σ → ZMod (q i)) (hxy : ∀ i ∈ I, y i = x i) + (hne : Nonempty (ResiduePrimeCoordinateCell lo N M a q (I ∪ J) y)) + (hupper : (residuePrimeCoordinateMean h lo N M a q (I ∪ J) y).re ≤ + level * (residuePrimeCoordinateMean g lo N M a q (I ∪ J) y).re + ε) : + (residuePrimeCoordinateMean h lo N M a q (I ∪ J) y).re ≤ + level * (residuePrimeCoordinateMean g lo N M a q I x).re + ε + level * δ := by + have hs := hstable J hIJ hJ y hxy hne + have hr := (Complex.abs_re_le_norm (residuePrimeCoordinateMean g lo N M a q I x - + residuePrimeCoordinateMean g lo N M a q (I ∪ J) y)).trans hs + rw [Complex.sub_re] at hr + have hmean : (residuePrimeCoordinateMean g lo N M a q (I ∪ J) y).re ≤ + (residuePrimeCoordinateMean g lo N M a q I x).re + δ := by + have hh := (abs_le.mp hr).1 + linarith + have hscaled := mul_le_mul_of_nonneg_left hmean hlevel + nlinarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem ResiduePrimeCoordinateStable.of_outside {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (r : ℕ) (δ : ℝ) (S : Finset {i // i ∉ K}) + (x : ∀ i, σ → ZMod (q i)) (hx : ∀ i ∈ K, x i = base i) + (hstable : ResiduePrimeCoordinateStable f lo N (M.lcm (∏ i ∈ K, q i)) + (fun j => (u.val j).val) (fun i : {i // i ∉ K} => q i.val) r δ S (fun i => x i.val)) : + ResiduePrimeCoordinateStable f lo N M a q r δ (K ∪ S.image Subtype.val) x := by + classical + intro J hdisjoint hcard y hagree hnonempty + let J' : Finset {i // i ∉ K} := J.subtype (fun i => i ∉ K) + have hout : ∀ i ∈ J, i ∉ K := by + intro i hi hK + exact Finset.disjoint_left.mp hdisjoint (Finset.mem_union_left _ hK) hi + have himage : J'.image Subtype.val = J := by + ext i + constructor + · intro hi + obtain ⟨j, hj, rfl⟩ := Finset.mem_image.mp hi + exact Finset.mem_subtype.mp hj + · intro hi + exact Finset.mem_image.mpr ⟨⟨i, hout i hi⟩, Finset.mem_subtype.mpr hi, rfl⟩ + have hcard' : J'.card ≤ r := by + have heq : J'.card = J.card := by + rw [← himage, Finset.card_image_of_injective J' Subtype.val_injective] + exact heq ▸ hcard + have hdisjoint' : Disjoint S J' := by + apply Finset.disjoint_left.mpr + intro i hi hj + exact Finset.disjoint_left.mp hdisjoint + (Finset.mem_union_right K (Finset.mem_image.mpr ⟨i, hi, rfl⟩)) (Finset.mem_subtype.mp hj) + have hbasey : ∀ i ∈ K, y i = base i := + fun i hi => (hagree i (Finset.mem_union_left _ hi)).trans (hx i hi) + have hunion : (K ∪ S.image Subtype.val) ∪ J = K ∪ (S ∪ J').image Subtype.val := by + rw [Finset.image_union, himage, Finset.union_assoc] + have hnonempty' : Nonempty (ResiduePrimeCoordinateCell lo N (M.lcm (∏ i ∈ K, q i)) + (fun j => (u.val j).val) (fun i : {i // i ∉ K} => q i.val) (S ∪ J') (fun i => y i.val)) := by + rw [hunion] at hnonempty + obtain ⟨z⟩ := hnonempty + exact ⟨residuePrimeCoordinateOutsideEquiv lo N M a q hcop K base u (S ∪ J') y hbasey z⟩ + rw [residuePrimeCoordinateMean_outside f lo N M a q hcop K base u S x hx, hunion, + residuePrimeCoordinateMean_outside f lo N M a q hcop K base u (S ∪ J') y hbasey] + apply hstable J' hdisjoint' hcard' (fun i => y i.val) _ hnonempty' + intro i hi + exact hagree i.val (Finset.mem_union_right K (Finset.mem_image.mpr ⟨i, hi, rfl⟩)) + +theorem ResiduePrimeCoordinateStable.lift_outside {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) + (K : Finset ι) (base : ∀ i, σ → ZMod (q i)) + (u : ResiduePrimeCoordinateCell lo N M a q K base) + (r : ℕ) (δ : ℝ) (S : Finset {i // i ∉ K}) + (x : ∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) + (hstable : ResiduePrimeCoordinateStable f lo N (M.lcm (∏ i ∈ K, q i)) + (fun j => (u.val j).val) (fun i : {i // i ∉ K} => q i.val) r δ S x) : + ResiduePrimeCoordinateStable f lo N M a q r δ (K ∪ S.image Subtype.val) + (CoordinateDecisionTree.outsideAssignment K base x) := by + apply ResiduePrimeCoordinateStable.of_outside f lo N M a q hcop K base u r δ S + (CoordinateDecisionTree.outsideAssignment K base x) + · intro i hi + simp only [CoordinateDecisionTree.outsideAssignment, hi, dite_true] + · have heq : (fun i : {i // i ∉ K} => + CoordinateDecisionTree.outsideAssignment K base x i.val) = x := by + funext i + simp only [CoordinateDecisionTree.outsideAssignment, i.property, dite_false] + rw [heq] + exact hstable + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem primeCoordinate_error_le_exp {ι σ : Type*} [DecidableEq ι] [Fintype σ] + (moduli : ι → ℕ) (L : σ → ℕ) (R : ℕ) (B C D : ℝ) (hB : 0 ≤ B) + (hmoduli : ∀ i, (moduli i : ℝ) ≤ Real.exp B) + (hdim : (Fintype.card σ : ℝ) ≤ Real.exp C) + (hlength : ∀ k, Real.exp (B * R + D + C + 1) ≤ (L k : ℝ)) + (S : Finset ι) (hS : S.card ≤ R) : + 2 * (∑ k, ((∏ i ∈ S, moduli i : ℕ) : ℝ) / L k) ≤ Real.exp (-D) := by + have hprod : ((∏ i ∈ S, moduli i : ℕ) : ℝ) ≤ Real.exp (B * R) := + (primeCoordinateProduct_le_exp moduli S B hmoduli).trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left (Nat.cast_le.mpr hS) hB)) + have hterm (k : σ) : ((∏ i ∈ S, moduli i : ℕ) : ℝ) / L k ≤ Real.exp (-D - C - 1) := by + have hL : (0 : ℝ) < L k := (Real.exp_pos _).trans_le (hlength k) + apply (div_le_iff₀ hL).mpr + calc + _ ≤ Real.exp (B * R) := hprod + _ = Real.exp (-D - C - 1) * Real.exp (B * R + D + C + 1) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (hlength k) (Real.exp_pos _).le + have hs := Finset.sum_le_sum (fun k (_ : k ∈ (Finset.univ : Finset σ)) => hterm k) + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] at hs + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ ≤ 2 * ((Fintype.card σ : ℝ) * Real.exp (-D - C - 1)) := mul_le_mul_of_nonneg_left hs (by norm_num) + _ ≤ Real.exp 1 * (Real.exp C * Real.exp (-D - C - 1)) := + mul_le_mul htwo (mul_le_mul_of_nonneg_right hdim (Real.exp_pos _).le) + (by positivity) (Real.exp_pos _).le + _ = Real.exp (-D) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +theorem residuePrimeDensity_close_of_lengths {ι σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (moduli : ι → ℕ) [∀ i, NeZero (moduli i)] (hM : 0 < M) + (hcop : ∀ i, M.Coprime (moduli i)) (hpair : Pairwise (fun i l => (moduli i).Coprime (moduli l))) + (R : ℕ) (B C D η : ℝ) (hB : 0 ≤ B) (hη : η ≤ 1) (herror : Real.exp (-D) ≤ η) + (hmoduli : ∀ i, (moduli i : ℝ) ≤ Real.exp B) (hdim : (Fintype.card σ : ℝ) ≤ Real.exp C) + (hlength : ∀ k, Real.exp (B * R + D + C + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) M (a k) : ℝ)) : + ProductMarginalsClose (primeCoordinateReference (σ := σ) moduli) + (residuePrimeCoordinateDensity lo N M a hne moduli (fun _ => 1)) η R := by + have herr (S : Finset ι) (hS : S.card ≤ R) := + (primeCoordinate_error_le_exp moduli (fun k => residueIndexLength (lo k) (lo k + N k) M (a k)) + R B C D hB hmoduli hdim hlength S hS).trans herror + apply residuePrimeCoordinateDensity_productMarginalsClose lo N M a hne moduli hM hcop hpair R η + · intro S hS + have he := herr S hS + linarith + · exact herr + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem ResidueSliceUpperComparison.restrict_budget_and_error {I : Type*} + [Fintype I] [DecidableEq I] {h g : (I → ℤ) → ℂ} {lo : I → ℤ} {N : I → ℕ} + {originalBudget referenceBudget level originalError referenceError : ℝ} + (hupper : ResidueSliceUpperComparison h g lo N originalBudget level originalError) + (hbudget : referenceBudget ≤ originalBudget) (herror : originalError ≤ referenceError) : + ResidueSliceUpperComparison h g lo N referenceBudget level referenceError := by + intro cellLo cellN M a hM hsub hcost + exact (hupper cellLo cellN M a hM hsub (hcost.mono hbudget)).trans (by linarith) + +theorem ResidueSliceUpperComparison.from_exponential_budget {I : Type*} + [Fintype I] [DecidableEq I] {h g : (I → ℤ) → ℂ} {lo : I → ℤ} {N : I → ℕ} + {originalBudget referenceBudget level densityLog tail : ℝ} + (hupper : ResidueSliceUpperComparison h g lo N originalBudget level (Real.exp (-originalBudget))) + (hbudget : referenceBudget ≤ originalBudget) (hprecision : densityLog + tail + 4 ≤ originalBudget) : + ResidueSliceUpperComparison h g lo N referenceBudget level (affineIncrementTolerance densityLog tail) := by + exact hupper.restrict_budget_and_error hbudget (Real.exp_le_exp.mpr (by linarith)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem not_residueSliceUpperComparison_iff_exists_residue_slice + {σ : Type*} [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {parent : σ → ℤ} {H : σ → ℕ} {P level ε : ℝ} : + ¬ ResidueSliceUpperComparison h g parent H P level ε ↔ + ∃ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (u : σ → ℤ), + 0 < M ∧ PhysicalSubbox parent H lo N ∧ ResidueSliceLogCostLE H lo N M u P ∧ + ε < (physicalResidueMean h lo N M u).re - + level * (physicalResidueMean g lo N M u).re := by + classical + simp only [ResidueSliceUpperComparison, not_forall, not_le] + constructor + · rintro ⟨lo, N, M, u, hM, hbox, hcost, hscore⟩ + exact ⟨lo, N, M, u, hM, hbox, hcost, by linarith⟩ + · rintro ⟨lo, N, M, u, hM, hbox, hcost, hscore⟩ + exact ⟨lo, N, M, u, hM, hbox, hcost, by linarith⟩ + +theorem exists_residue_slice_of_not_upper + {σ : Type*} [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {parent : σ → ℤ} {H : σ → ℕ} {P level ε : ℝ} + (hfailure : ¬ ResidueSliceUpperComparison h g parent H P level ε) : + ∃ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (u : σ → ℤ), + 0 < M ∧ PhysicalSubbox parent H lo N ∧ ResidueSliceLogCostLE H lo N M u P ∧ + ε < (physicalResidueMean h lo N M u).re - + level * (physicalResidueMean g lo N M u).re := + not_residueSliceUpperComparison_iff_exists_residue_slice.mp hfailure + +theorem ResidueSliceLogCostLE.lengths_pos {σ : Type*} + {H N : σ → ℕ} {lo u : σ → ℤ} {M : ℕ} {P : ℝ} + (hcost : ResidueSliceLogCostLE H lo N M u P) (hH : ∀ j, 0 < H j) : + ∀ j, 0 < residueIndexLength (lo j) (lo j + N j) M (u j) := by + intro j + have hp : (0 : ℝ) < Real.exp (-P) * (H j : ℝ) := + mul_pos (Real.exp_pos _) (Nat.cast_pos.mpr (hH j)) + exact Nat.cast_pos.mp (hp.trans_le (hcost j)) + +theorem ResidueSliceLogCostLE.nonempty {σ : Type*} + {H N : σ → ℕ} {lo u : σ → ℤ} {M : ℕ} {P : ℝ} + (hcost : ResidueSliceLogCostLE H lo N M u P) (hH : ∀ j, 0 < H j) (hM : 0 < M) : + Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) u) := by + classical + have hpos := hcost.lengths_pos hH + have hne (j : σ) : Nonempty ↥(Finset.filter (fun x => x ≡ u j [ZMOD (M : ℤ)]) + (Finset.Ico (lo j) (lo j + N j))) := by + have hj := hpos j + rw [residueIndexLength_eq_card _ _ _ _ (Nat.cast_pos.mpr hM)] at hj + obtain ⟨x, hx⟩ := Finset.card_pos.mp hj + exact ⟨⟨x, hx⟩⟩ + exact ⟨fun j => Classical.choice (hne j)⟩ + +theorem exists_nonempty_residue_slice_of_not_upper + {σ : Type*} [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {parent : σ → ℤ} {H : σ → ℕ} {P level ε : ℝ} + (hε : 0 ≤ ε) (hfailure : ¬ ResidueSliceUpperComparison h g parent H P level ε) : + ∃ (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (u : σ → ℤ), + 0 < M ∧ PhysicalSubbox parent H lo N ∧ ResidueSliceLogCostLE H lo N M u P ∧ + Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) u) ∧ + (∀ j, 0 < residueIndexLength (lo j) (lo j + N j) M (u j)) ∧ + ε < (physicalResidueMean h lo N M u).re - + level * (physicalResidueMean g lo N M u).re := by + classical + obtain ⟨lo, N, M, u, hM, hbox, hcost, hscore⟩ := exists_residue_slice_of_not_upper hfailure + have hne : Nonempty (IntegerResidueBox lo (fun j => lo j + N j) (fun _ => (M : ℤ)) u) := by + by_contra hempty + have := not_nonempty_iff.mp hempty + have hh : physicalResidueMean h lo N M u = 0 := by simp [physicalResidueMean] + have hg : physicalResidueMean g lo N M u = 0 := by simp [physicalResidueMean] + rw [hh, hg] at hscore + simp only [Complex.zero_re, mul_zero, sub_zero] at hscore + exact (not_lt_of_ge hε) hscore + refine ⟨lo, N, M, u, hM, hbox, hcost, hne, ?_, hscore⟩ + exact integerResidueBox_lengths_pos _ _ _ _ (fun _ => Nat.cast_pos.mpr hM) hne + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSpatialSiteExpansion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSpatialSiteExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..9259fae94192e34839b985ce3a0994e661877c0e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSpatialSiteExpansion.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.Progressions.Geometry.SpatialSiteShift + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal BigOperators + +theorem residueSpatialWeight_site_error {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] + (A : Matrix (Unit ⊕ I) (Unit ⊕ I) ℤ) (B : Matrix (Unit ⊕ I) J ℤ) + (m : ℕ) [NeZero m] + (hp : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ pivotFullImage A B) + (f : ((Unit ⊕ I) → ℝ) → ℝ) {K : ℝ≥0} (hf : LipschitzWith K f) + (H : ℝ) {r : ℝ} (hr : 0 < r) (a : Matrix (Unit ⊕ I) N (ZMod m)) + (v : (Unit ⊕ I) → ℤ) (hv : ∀ i, |((spatialStar v i : ℤ) : ℝ) / H| ≤ 1) : + ‖(residueSpatialWeight A B (fun _ => H) f a v : ℂ) - + spatialSiteApprox A (Matrix.fromCols B (liftResidueMatrix a)) m f H 1 r v‖ ≤ + 4 * (m : ℝ)^Fintype.card (Unit ⊕ I) * K * r := by + have hpfull : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ + pivotFullImage A (Matrix.fromCols B (liftResidueMatrix a)) := by + rw [pivotFullImage_split] + exact hp.trans le_sup_left + have hi : ((pivotFullImage A (Matrix.fromCols B (liftResidueMatrix a))).toAddSubgroup.index : ℝ) ≤ + (m : ℝ)^Fintype.card (Unit ⊕ I) := by + exact_mod_cast residueLatticeImage_index_le _ m hpfull + exact spatialSiteApprox_error _ _ m hpfull f hf hi zero_lt_one hr H v hv + +theorem residueSpatialWeight_site_family {I J N X : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] [DecidableEq N] [Fintype X] + (A : Matrix (Unit ⊕ I) (Unit ⊕ I) ℤ) (B : Matrix (Unit ⊕ I) J ℤ) + (m : ℕ) [NeZero m] + (hp : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ pivotFullImage A B) + (f : ((Unit ⊕ I) → ℝ) → ℝ) {K : ℝ≥0} (hf : LipschitzWith K f) + (H : ℝ) {ε : ℝ} (hε : 0 < ε) + (p : FiniteProbabilityWeights X) (F : X → Matrix (Unit ⊕ I) N (ZMod m)) + (t : Finset ((Unit ⊕ I) → ℤ)) (D : X → ((Unit ⊕ I) → ℤ) → ℝ) + (φ : ((Unit ⊕ I) → ℤ) → ℂ) (hD : ∀ x v, 0 ≤ D x v) + (hφ : ∀ v ∈ t, ‖φ v‖ ≤ 1) + (ht : ∀ v ∈ t, ∀ i, |((spatialStar v i : ℤ) : ℝ) / H| ≤ 1) : + let r := spatialSiteRadius ((m : ℝ)^Fintype.card (Unit ⊕ I)) K ε + ‖(∑ a, 𝔼 v ∈ t, (p.fiberMean F a (fun x => D x v) : ℂ) * + (residueSpatialWeight A B (fun _ => H) f a v : ℂ) * φ v) - + (∑ a, 𝔼 v ∈ t, (p.fiberMean F a (fun x => D x v) : ℂ) * + spatialSiteApprox A (Matrix.fromCols B (liftResidueMatrix a)) m f H 1 r v * φ v)‖ ≤ + ε * p.mean (fun x => 𝔼 v ∈ t, D x v) := by + have hG : 0 ≤ (m : ℝ)^Fintype.card (Unit ⊕ I) := by positivity + have hr := spatialSiteRadius_pos hG K.coe_nonneg hε + apply norm_fiber_site_replacement p F t D _ _ φ hD hφ + intro a v hv + exact (residueSpatialWeight_site_error A B m hp f hf H hr a v (ht v hv)).trans + (spatialSiteRadius_error hG K.coe_nonneg hε.le) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSpectralDecomposition.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSpectralDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ba13dffe36f9c64d58846369f612993af2f8285 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueSpectralDecomposition.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.Progressions.Estimates.SpectralCylinderDecomposition +import OAI.Combinatorics.Progressions.Polynomial.StableSiteLowDegree + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_residue_spectral_decomposition {ι σ : Type*} [Fintype ι] [LinearOrder ι] + [Fintype σ] [DecidableEq σ] (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (moduli : ι → ℕ) [∀ i, NeZero (moduli i)] (hM : 0 < M) + (hcop : ∀ i, M.Coprime (moduli i)) + (hpair : Pairwise (fun i l => (moduli i).Coprime (moduli l))) + (K τ η P : ℝ) (j r q A : ℕ) (hK : 1 ≤ K) (hτ : 0 < τ) (hη0 : 0 ≤ η) (hη1 : η ≤ 1) + (hq : 2 ≤ q) (heven : Even q) (hrP : (r : ℝ) ≤ P) (hlog : Real.log (2 + τ⁻¹) ≤ P) + (hPq : P ≤ (q : ℝ)) (hqP : (q : ℝ) ≤ P + 2) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hηsmall : η ≤ (1 / 2) * Real.exp (-((P + 3) ^ 3))) + (hA : 1 ≤ A) (halphabet : ∀ i, moduli i ^ Fintype.card σ ≤ A) + (hcut : 2 ≤ τ * K ^ (j + 1)) + (B C D : ℝ) (hB : 0 ≤ B) (herror : Real.exp (-D) ≤ η) + (hmoduli : ∀ i, (moduli i : ℝ) ≤ Real.exp B) (hdim : (Fintype.card σ : ℝ) ≤ Real.exp C) + (hlength : ∀ k, Real.exp (B * (j + r * (q + 1) : ℕ) + D + C + 1) ≤ + (residueIndexLength (lo k) (lo k + N k) M (a k) : ℝ)) + (w : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a → ℝ) + (hw0 : ∀ z, 0 ≤ w z) (hw1 : ∀ z, w z ≤ 1) : + let μ := primeCoordinateReference (σ := σ) moduli + let p := @FiniteProbabilityWeights.uniform + (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a) _ hne + let F := fun z : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a => + primeCoordinateObservation moduli (fun k => (z k).val) + ∃ (v : IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a → ℝ) + (cs : List (ProductCylinder (fun i => σ → ZMod (moduli i)))), + CylinderRemovalChain μ (fun _ _ => 0) p F K τ j r w v cs ∧ cs.Nodup ∧ + cs.length ≤ (∑ k ∈ Finset.range (j + r + 1), (Fintype.card ι).choose k) * A ^ (j + r) ∧ + (removedCylinderWeights F w cs).Pairwise (fun f g => ∀ z, f z = 0 ∨ g z = 0) ∧ + (∀ z, w z = ((removedCylinderWeights F w cs).map (fun f => f z)).sum + v z) ∧ + (∀ f ∈ removedCylinderWeights F w cs, ∀ z, 0 ≤ f z ∧ f z ≤ 1) ∧ + p.mean v ≤ τ ∧ (∀ z, 0 ≤ v z ∧ v z ≤ 1) ∧ + (∀ cf ∈ cs.zip (removedCylinderWeights F w cs), ∀ k : ℕ, k ≤ r → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) + (ProductCylinder.normalizedSection μ (fun _ _ => 0) (observedProductDensity μ p F cf.2) cf.1)) ≤ + (8 * (1 + K) * (P + 2)) ^ (2 * k)) := by + let := hne + have hP : 0 ≤ P := (Nat.cast_nonneg r).trans hrP + have hMcap : τ⁻¹ ≤ Real.exp P := by + have hh := Real.le_exp_of_log_le hlog + linarith + have hbudget := approxMoment_small_of_exponential (Fintype.card ι) r q (τ⁻¹) P hP + (inv_nonneg.mpr hτ.le) hcount hMcap hrP hqP hηsmall + have hbase := residuePrimeDensity_close_of_lengths lo N M a hne moduli hM hcop hpair + (j + r * (q + 1)) B C D η hB hη1 herror hmoduli hdim hlength + exact exists_spectral_cylinder_decomposition (primeCoordinateReference (σ := σ) moduli) + (primeCoordinateReference_weight_pos moduli) (fun _ _ => 0) + (FiniteProbabilityWeights.uniform (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (M : ℤ)) a)) + (fun z => primeCoordinateObservation moduli (fun k => (z k).val)) + K τ η P j r q A hK hτ hη0 hη1 hq heven hrP hlog hPq hqP hbudget hA + (fun i => by simpa only [Fintype.card_fun, ZMod.card] using halphabet i) + hcut hbase w hw0 hw1 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueStableBoxCongruence.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueStableBoxCongruence.lean new file mode 100644 index 0000000000000000000000000000000000000000..e33fd99a2e01587187fe796c2fdf913e664b4967 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueStableBoxCongruence.lean @@ -0,0 +1,42 @@ +import OAI.Combinatorics.Progressions.Lattices.AffineSampleAlphabet + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residuePrimeCoordinateMean_congr_on_box {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (f g : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (hfg : ∀ z ∈ translatedIntegerBox lo N, f z = g z) + (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : + residuePrimeCoordinateMean f lo N M a q I x = residuePrimeCoordinateMean g lo N M a q I x := by + classical + unfold residuePrimeCoordinateMean + apply Finset.expect_congr rfl + intro z _ + apply hfg + apply (mem_translatedIntegerBox lo N _).mpr + intro j + exact Finset.mem_Ico.mp (Finset.mem_filter.mp (z.val j).property).1 + +theorem ResiduePrimeCoordinateStable.congr_on_box {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {f g : (σ → ℤ) → ℂ} {lo : σ → ℤ} {N : σ → ℕ} {M : ℕ} {a : σ → ℤ} {q : ι → ℕ} + {r : ℕ} {δ : ℝ} {I : Finset ι} {x : ∀ i, σ → ZMod (q i)} + (h : ResiduePrimeCoordinateStable f lo N M a q r δ I x) + (hfg : ∀ z ∈ translatedIntegerBox lo N, f z = g z) : + ResiduePrimeCoordinateStable g lo N M a q r δ I x := by + intro J hIJ hJ y hxy hnonempty + rw [← residuePrimeCoordinateMean_congr_on_box f g lo N M a q hfg I x, + ← residuePrimeCoordinateMean_congr_on_box f g lo N M a q hfg (I ∪ J) y] + exact h J hIJ hJ y hxy hnonempty + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ResidueStrideRebase.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueStrideRebase.lean new file mode 100644 index 0000000000000000000000000000000000000000..2230bd498f2231186555791a2b12225eae3a8729 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ResidueStrideRebase.lean @@ -0,0 +1,541 @@ +import OAI.Combinatorics.Progressions.Estimates.AuxiliaryStrideGeometry +import OAI.Combinatorics.Progressions.Nilpotent.NiltestAffineProjection + +namespace OAI + +section + +namespace Erdos3 + +theorem residueTransitionNumerator_pos {M₀ M₁ : ℕ} (hM₁ : 0 < M₁) (hdiv : M₀ ∣ M₁) : + 0 < M₁ / M₀ := by + apply Nat.pos_of_ne_zero + intro hz + have heq := Nat.mul_div_cancel' hdiv + rw [hz, mul_zero] at heq + exact hM₁.ne' heq.symm + +theorem residueTransition_scale {M₀ M₁ d : ℕ} (hdiv : M₀ ∣ M₁) (hd : 0 < d) : + ((M₀ : ℚ) * d) * (((M₁ / M₀ : ℕ) : ℚ) / d) = M₁ := by + have heq : (M₀ : ℚ) * (M₁ / M₀ : ℕ) = M₁ := by + exact_mod_cast Nat.mul_div_cancel' hdiv + have hdq : (d : ℚ) ≠ 0 := by exact_mod_cast hd.ne' + calc + _ = (M₀ : ℚ) * (M₁ / M₀ : ℕ) := by + field_simp [hdq] + _ = M₁ := heq + +theorem residueTransition_shift {M₀ d : ℕ} (hM₀ : 0 < M₀) (hd : 0 < d) (a₀ a₁ : ℚ) : + ((M₀ : ℚ) * d) * ((a₁ - a₀) / ((M₀ : ℚ) * d)) + a₀ = a₁ := by + have hstep : (M₀ : ℚ) * d ≠ 0 := by positivity + field_simp [hstep] + ring + +theorem residueTransition_physical {M₀ M₁ d : ℕ} + (hM₀ : 0 < M₀) (hd : 0 < d) (hdiv : M₀ ∣ M₁) + {ρ W S A : ℝ} (hρ : 0 ≤ ρ) + (hold : ρ * W ≤ ((M₀ : ℝ) * d) * S) (hcurrent : (M₁ : ℝ) * A ≤ W) : + ρ * (|((((M₁ / M₀ : ℕ) : ℚ) / d : ℚ) : ℝ)| * A) ≤ S := by + have hstep : 0 < (M₀ : ℝ) * d := by positivity + have hscale : ((M₀ : ℝ) * d) * ((((M₁ / M₀ : ℕ) : ℚ) / d : ℚ) : ℝ) = M₁ := by + exact_mod_cast residueTransition_scale hdiv hd + have hr : 0 ≤ ((((M₁ / M₀ : ℕ) : ℚ) / d : ℚ) : ℝ) := by positivity + apply (mul_le_mul_iff_right₀ hstep).mp + calc + ((M₀ : ℝ) * d) * (ρ * (|((((M₁ / M₀ : ℕ) : ℚ) / d : ℚ) : ℝ)| * A)) = + ρ * ((((M₀ : ℝ) * d) * ((((M₁ / M₀ : ℕ) : ℚ) / d : ℚ) : ℝ)) * A) := by + rw [abs_of_nonneg hr] + ring + _ = ρ * ((M₁ : ℝ) * A) := by rw [hscale] + _ ≤ ρ * W := mul_le_mul_of_nonneg_left hcurrent hρ + _ ≤ ((M₀ : ℝ) * d) * S := hold + +theorem residueTransition_denominator_bound {n d : ℕ} {B : ℝ} + (hn : (n : ℝ) ≤ Real.exp B) (hd : (d : ℝ) ≤ Real.exp B) (s : ℕ) : + ((n * d ^ s : ℕ) : ℝ) ≤ Real.exp (((s : ℝ) + 1) * B) := by + push_cast + calc + (n : ℝ) * (d : ℝ) ^ s ≤ Real.exp B * Real.exp B ^ s := + mul_le_mul hn (pow_le_pow_left₀ (Nat.cast_nonneg _) hd s) + (pow_nonneg (Nat.cast_nonneg _) _) (Real.exp_nonneg _) + _ = Real.exp (((s : ℝ) + 1) * B) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +def residueBoxStrideValue {I : Type*} {a b r v : I → ℤ} + (f : (I → ℤ) → ℂ) (u : I → ℤ) (M : ℕ) (x : IntegerResidueBox a b r v) : ℂ := + f (commonStrideIndex u M (fun i => (x i).val)) + +theorem integerInterval_abs_sub_le (a u x : ℤ) (N : ℕ) + (hx : x ∈ Finset.Ico a (a + N)) : + |(x : ℝ) - (u : ℝ)| ≤ |(a : ℝ) - (u : ℝ)| + (N : ℝ) := by + have hlo : (a : ℝ) ≤ x := by exact_mod_cast (Finset.mem_Ico.mp hx).1 + have hhi : (x : ℝ) < (a : ℝ) + N := by exact_mod_cast (Finset.mem_Ico.mp hx).2 + have htri := abs_sub_le (x : ℝ) a u + rw [abs_of_nonneg (sub_nonneg.mpr hlo)] at htri + linarith + +theorem residueBox_stride_bound {I : Type*} (a : I → ℤ) (N : I → ℕ) + (M : ℕ) (hM : 0 < M) (u r b : I → ℤ) + (hbase : ∀ i (x : ℤ), x ≡ b i [ZMOD r i] → x ≡ u i [ZMOD (M : ℤ)]) + (A : I → ℝ) + (hphysical : ∀ i, (u i : ℝ) - (M : ℝ) * A i ≤ (a i : ℝ) ∧ + (a i : ℝ) + (N i : ℝ) ≤ (u i : ℝ) + (M : ℝ) * A i) + (x : IntegerResidueBox a (fun i => a i + N i) r b) : + ∀ i, |(commonStrideIndex u M (fun j => (x j).val) i : ℝ)| ≤ A i := by + apply commonStrideIndex_bound u hM _ + (fun i => hbase i (x i).val (Finset.mem_filter.mp (x i).property).2) A + intro i + have hx := Finset.mem_Ico.mp (Finset.mem_filter.mp (x i).property).1 + have hlo : (a i : ℝ) ≤ (x i).val := by exact_mod_cast hx.1 + have hhi : ((x i).val : ℝ) < (a i : ℝ) + (N i : ℝ) := by exact_mod_cast hx.2 + exact abs_le.mpr ⟨by linarith [(hphysical i).1], by linarith [(hphysical i).2]⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct + +def residueStepMatrix {I : Type*} [DecidableEq I] (J : I → ℕ) : I → I → ℤ := + fun i j => if i = j then (J i : ℤ) else 0 + +theorem integerAffineMap_residueStepMatrix {I : Type*} [Fintype I] [DecidableEq I] + (a : I → ℤ) (J : I → ℕ) (x : I → ℤ) : + integerAffineMap (residueStepMatrix J) a x = fun i => a i + (J i : ℤ) * x i := + integerAffineMap_diagonal a (fun i => (J i : ℤ)) x + +theorem commonStrideIndex_residue_affine {I : Type*} (u v : I → ℤ) {M : ℕ} (hM : 0 < M) + (J : I → ℕ) (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) (x : I → ℤ) : + commonStrideIndex u M (fun i => v i + ((M * J i : ℕ) : ℤ) * x i) = + fun i => commonStrideIndex u M v i + (J i : ℤ) * x i := by + have heq : commonStridePoint u M (fun i => commonStrideIndex u M v i + (J i : ℤ) * x i) = + (fun i => v i + ((M * J i : ℕ) : ℤ) * x i) := by + funext i + have hbase := congrFun (commonStridePoint_index_of_modEq u M v hv) i + change u i + (M : ℤ) * commonStrideIndex u M v i = v i at hbase + change u i + (M : ℤ) * (commonStrideIndex u M v i + (J i : ℤ) * x i) = _ + calc + _ = (u i + (M : ℤ) * commonStrideIndex u M v i) + ((M * J i : ℕ) : ℤ) * x i := by + push_cast + ring + _ = _ := by rw [hbase] + rw [← heq, commonStrideIndex_point u hM] + +theorem residueBoxStride_expect {I : Type*} [Fintype I] [DecidableEq I] + (a b : I → ℤ) (M : ℕ) (hM : 0 < M) (u v : I → ℤ) (J : I → ℕ) + (hJ : ∀ i, 0 < J i) (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) (f : (I → ℤ) → ℂ) : + (𝔼 x : IntegerResidueBox a b (fun i => (M * J i : ℕ)) v, residueBoxStrideValue f u M x) = + 𝔼 x ∈ translatedIntegerBox + (fun i => residueIndexLower (a i) (M * J i : ℕ) (v i)) + (fun i => residueIndexLength (a i) (b i) (M * J i : ℕ) (v i)), + f (fun i => commonStrideIndex u M v i + (J i : ℤ) * x i) := by + change (𝔼 x : IntegerResidueBox a b (fun i => (M * J i : ℕ)) v, + f (commonStrideIndex u M (fun i => (x i).val))) = _ + rw [integerResidueBox_expect a b (fun i => (M * J i : ℕ)) v + (fun i => by exact_mod_cast Nat.mul_pos hM (hJ i)) (fun y => f (commonStrideIndex u M y))] + apply Finset.expect_congr rfl + intro x _ + exact congrArg f (commonStrideIndex_residue_affine u v hM J hv x) + +namespace RationalFilteredNilmanifold.Niltest + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} + +theorem residueBoxStride_mean (T : D.Niltest (fun _ : σ => 1)) + (a b : σ → ℤ) (M : ℕ) (hM : 0 < M) (u v : σ → ℤ) (J : σ → ℕ) + (hJ : ∀ i, 0 < J i) (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) : + (𝔼 x : IntegerResidueBox a b (fun i => (M * J i : ℕ)) v, residueBoxStrideValue T.eval u M x) = + 𝔼 x ∈ translatedIntegerBox + (fun i => residueIndexLower (a i) (M * J i : ℕ) (v i)) + (fun i => residueIndexLength (a i) (b i) (M * J i : ℕ) (v i)), + (T.affinePullback (residueStepMatrix J) (commonStrideIndex u M v)).eval x := by + rw [residueBoxStride_expect a b M hM u v J hJ hv] + apply Finset.expect_congr rfl + intro x _ + rw [eval_affinePullback, integerAffineMap_residueStepMatrix] + +end RationalFilteredNilmanifold.Niltest + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem scalarAffinePolynomial_comp {σ : Type*} (r₀ r₁ : ℚ) (h₀ h₁ : σ → ℚ) (i : σ) : + MvPolynomial.aeval (scalarAffinePolynomial r₁ h₁) (scalarAffinePolynomial r₀ h₀ i) = + scalarAffinePolynomial (r₀ * r₁) (fun j => r₀ * h₁ j + h₀ j) i := by + simp only [scalarAffinePolynomial, map_add, map_mul, MvPolynomial.aeval_C, + MvPolynomial.aeval_X, MvPolynomial.algebraMap_eq] + ring + +namespace RationalFilteredNilmanifold.Niltest + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +theorem scalarAffinePullback_comp_orbit (T : D.Niltest (fun _ : σ => 1)) + (r₀ r₁ : ℚ) (h₀ h₁ : σ → ℚ) : + ((T.scalarAffinePullback r₀ h₀).scalarAffinePullback r₁ h₁).orbit = + (T.scalarAffinePullback (r₀ * r₁) (fun i => r₀ * h₁ i + h₀ i)).orbit := by + apply Subtype.ext + apply NilpotentLieBCHGroup.ext + change VectorPolynomial.substitute (scalarAffinePolynomial r₁ h₁) + (VectorPolynomial.substitute (scalarAffinePolynomial r₀ h₀) T.orbit.log) = + VectorPolynomial.substitute (scalarAffinePolynomial (r₀ * r₁) (fun i => r₀ * h₁ i + h₀ i)) + T.orbit.log + rw [VectorPolynomial.substitute_comp] + simp only [scalarAffinePolynomial_comp] + +theorem scalarAffinePullback_comp_orbit_of_eq (T : D.Niltest (fun _ : σ => 1)) + (r₀ r₁ a : ℚ) (h₀ h₁ shift : σ → ℚ) (hr : r₀ * a = r₁) + (hh : ∀ i, r₀ * shift i + h₀ i = h₁ i) : + ((T.scalarAffinePullback r₀ h₀).scalarAffinePullback a shift).orbit = + (T.scalarAffinePullback r₁ h₁).orbit := by + rw [T.scalarAffinePullback_comp_orbit, hr, funext hh] + +theorem scalarAffinePullback_transition_orbit (T : D.Niltest (fun _ : σ => 1)) + (r₀ r₁ : ℚ) (h₀ h₁ : σ → ℚ) (hr₀ : r₀ ≠ 0) : + ((T.scalarAffinePullback r₀ h₀).scalarAffinePullback (r₁ / r₀) + (fun i => (h₁ i - h₀ i) / r₀)).orbit = (T.scalarAffinePullback r₁ h₁).orbit := by + apply T.scalarAffinePullback_comp_orbit_of_eq + · field_simp + · intro i + field_simp + ring + +theorem scalarAffinePullback_transition_factorization (T : D.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (r₀ r₁ : ℚ) (h₀ h₁ shift : σ → ℚ) {S H : σ → ℝ} {p q : ℝ} {M : ℕ} + {U : LieSubalgebra ℚ D.filtration.AssociatedGraded} + (h : D.filtration.SymbolFactorizationIn b ω hF S + ((T.scalarAffinePullback r₀ h₀).symbol b ω hF) p M U) + (a : ℤ) (m : ℕ) (ha : a ≠ 0) (hm : 0 < m) + (hr : r₀ * ((a : ℚ) / m) = r₁) (hh : ∀ i, r₀ * shift i + h₀ i = h₁ i) + (hS : ∀ i, 0 < S i) (hH : ∀ i, 0 < H i) (hq : 0 ≤ q) + (hphysical : ∀ i, Real.exp (-q) * (|(((a : ℚ) / m : ℚ) : ℝ)| * H i) ≤ S i) : + D.filtration.SymbolFactorizationIn b ω hF H + ((T.scalarAffinePullback r₁ h₁).symbol b ω hF) (p + (s : ℝ) * q) (M * m ^ s) U := by + have htransport := (T.scalarAffinePullback r₀ h₀).scalarAffinePullback_factorization + b ω hF h a m ha hm shift hS hH hq hphysical + have horbit := T.scalarAffinePullback_comp_orbit_of_eq r₀ r₁ ((a : ℚ) / m) h₀ h₁ shift hr hh + have hsymbol := + ((T.scalarAffinePullback r₀ h₀).scalarAffinePullback ((a : ℚ) / m) shift).symbol_eq_of_orbit_eq + (T.scalarAffinePullback r₁ h₁) horbit b ω hF + rwa [hsymbol] at htransport + +end RationalFilteredNilmanifold.Niltest +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem residue_refinement_offset_identity {σ : Type*} + (u v : σ → ℤ) (M : ℕ) (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) (i : σ) : + (M : ℚ) * (commonStrideIndex u M v i : ℚ) + (u i : ℚ) = (v i : ℚ) := by + have h := congrFun (commonStridePoint_index_of_modEq u M v hv) i + change u i + (M : ℤ) * commonStrideIndex u M v i = v i at h + exact_mod_cast (show (M : ℤ) * commonStrideIndex u M v i + u i = v i by omega) + +theorem commonStrideIndex_of_refinement {σ : Type*} + (u v : σ → ℤ) {M N : ℕ} (hM : 0 < M) (hMN : M ∣ N) + (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) (x : σ → ℤ) : + commonStrideIndex u M (commonStridePoint v N x) = + fun i => ((N / M : ℕ) : ℤ) * x i + commonStrideIndex u M v i := by + change commonStrideIndex u M (fun i => v i + (N : ℤ) * x i) = _ + have h := commonStrideIndex_residue_affine u v hM (fun _ : σ => N / M) hv x + simpa only [Nat.mul_div_cancel' hMN, add_comm] using h + +theorem residue_refinement_parameter_bounds {σ : Type*} + (u v : σ → ℤ) {M N : ℕ} (hM : 0 < M) (hMN : M ∣ N) + (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) (A B : σ → ℝ) + (hoffset : ∀ i, |(v i : ℝ) - (u i : ℝ)| ≤ (M : ℝ) * A i) + (hspan : ∀ i, (N : ℝ) * B i ≤ (M : ℝ) * A i) : + (∀ i, |(commonStrideIndex u M v i : ℝ)| ≤ A i) ∧ + (∀ i, |((N / M : ℕ) : ℝ)| * B i ≤ A i) := by + have hMr : 0 < (M : ℝ) := by exact_mod_cast hM + have hscale : (M : ℝ) * (N / M : ℕ) = N := by exact_mod_cast Nat.mul_div_cancel' hMN + constructor + · intro i + have hshift : (M : ℝ) * (commonStrideIndex u M v i : ℝ) = (v i : ℝ) - (u i : ℝ) := by + have h := residue_refinement_offset_identity u v M hv i + have hh : (M : ℝ) * (commonStrideIndex u M v i : ℝ) + (u i : ℝ) = (v i : ℝ) := by + exact_mod_cast h + linarith + apply (mul_le_mul_iff_right₀ hMr).mp + calc + (M : ℝ) * |(commonStrideIndex u M v i : ℝ)| = + |(M : ℝ) * (commonStrideIndex u M v i : ℝ)| := by rw [abs_mul, abs_of_pos hMr] + _ = |(v i : ℝ) - (u i : ℝ)| := by rw [hshift] + _ ≤ (M : ℝ) * A i := hoffset i + · intro i + apply (mul_le_mul_iff_right₀ hMr).mp + calc + (M : ℝ) * (|((N / M : ℕ) : ℝ)| * B i) = ((M : ℝ) * (N / M : ℕ)) * B i := by + rw [abs_of_nonneg (Nat.cast_nonneg _)]; ring + _ = (N : ℝ) * B i := by rw [hscale] + _ ≤ (M : ℝ) * A i := hspan i + +namespace RationalFilteredNilmanifold.Niltest + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +theorem scalarAffinePullback_refinement_orbit (T : D.Niltest (fun _ : σ => 1)) + (u v : σ → ℤ) {M N : ℕ} (hMN : M ∣ N) + (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) : + ((T.scalarAffinePullback (M : ℚ) (fun i => (u i : ℚ))).scalarAffinePullback + (N / M : ℕ) (fun i => (commonStrideIndex u M v i : ℚ))).orbit = + (T.scalarAffinePullback (N : ℚ) (fun i => (v i : ℚ))).orbit := by + apply T.scalarAffinePullback_comp_orbit_of_eq + · exact_mod_cast Nat.mul_div_cancel' hMN + · exact residue_refinement_offset_identity u v M hv + +end RationalFilteredNilmanifold.Niltest + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +theorem integerAffinePolynomial_residue_scalar {σ : Type*} [Fintype σ] [DecidableEq σ] + (J : ℕ) (shift : σ → ℤ) : + integerAffinePolynomial (residueStepMatrix (fun _ : σ => J)) shift = + scalarAffinePolynomial (J : ℚ) (fun i => (shift i : ℚ)) := by + funext i + simp [integerAffinePolynomial, residueStepMatrix, scalarAffinePolynomial, apply_ite, ite_mul] + +namespace RationalFilteredNilmanifold.Niltest + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} + +theorem residue_scalar_affine_orbit (T : D.Niltest (fun _ : σ => 1)) + (J : ℕ) (shift : σ → ℤ) : + (T.affinePullback (residueStepMatrix (fun _ : σ => J)) shift).orbit = + (T.scalarAffinePullback (J : ℚ) (fun i => (shift i : ℚ))).orbit := by + apply Subtype.ext + apply NilpotentLieBCHGroup.ext + change VectorPolynomial.substitute (integerAffinePolynomial (residueStepMatrix (fun _ : σ => J)) shift) + T.orbit.log = VectorPolynomial.substitute (scalarAffinePolynomial (J : ℚ) + (fun i => (shift i : ℚ))) T.orbit.log + rw [integerAffinePolynomial_residue_scalar] + +theorem residue_scalar_affine_symbol (T : D.Niltest (fun _ : σ => 1)) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (J : ℕ) (shift : σ → ℤ) : + (T.affinePullback (residueStepMatrix (fun _ : σ => J)) shift).symbol D.basis ω hF = + (T.scalarAffinePullback (J : ℚ) (fun i => (shift i : ℚ))).symbol D.basis ω hF := + (T.affinePullback (residueStepMatrix (fun _ : σ => J)) shift).symbol_eq_of_orbit_eq + (T.scalarAffinePullback (J : ℚ) (fun i => (shift i : ℚ))) + (T.residue_scalar_affine_orbit J shift) D.basis ω hF + +end RationalFilteredNilmanifold.Niltest + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s e : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s e} + +theorem scalarAffinePullback_residue_factorization (T : D.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + {M₀ M₁ d n : ℕ} (hM₀ : 0 < M₀) (hM₁ : 0 < M₁) (hd : 0 < d) (hdiv : M₀ ∣ M₁) + (h₀ h₁ : σ → ℚ) {S A W : σ → ℝ} {p q : ℝ} + {U : LieSubalgebra ℚ D.filtration.AssociatedGraded} + (h : D.filtration.SymbolFactorizationIn b ω hF S + ((T.scalarAffinePullback ((M₀ : ℚ) * d) h₀).symbol b ω hF) p n U) + (hS : ∀ i, 0 < S i) (hA : ∀ i, 0 < A i) (hq : 0 ≤ q) + (hold : ∀ i, Real.exp (-q) * W i ≤ ((M₀ : ℝ) * d) * S i) + (hcurrent : ∀ i, (M₁ : ℝ) * A i ≤ W i) : + D.filtration.SymbolFactorizationIn b ω hF A + ((T.scalarAffinePullback (M₁ : ℚ) h₁).symbol b ω hF) + (p + (s : ℝ) * q) (n * d ^ s) U := by + let a : ℤ := (M₁ / M₀ : ℕ) + have ha : a ≠ 0 := by + dsimp only [a] + exact_mod_cast (residueTransitionNumerator_pos hM₁ hdiv).ne' + apply T.scalarAffinePullback_transition_factorization b ω hF + ((M₀ : ℚ) * d) (M₁ : ℚ) h₀ h₁ (fun i => (h₁ i - h₀ i) / ((M₀ : ℚ) * d)) + h a d ha hd + · simpa only [a, Int.cast_natCast] using residueTransition_scale hdiv hd + · intro i + exact residueTransition_shift hM₀ hd (h₀ i) (h₁ i) + · exact hS + · exact hA + · exact hq + · intro i + simpa only [a, Int.cast_natCast] using + residueTransition_physical hM₀ hd hdiv (Real.exp_nonneg (-q)) (hold i) (hcurrent i) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +theorem physical_box_anchor_bounds {σ : Type*} + (lo lo' u v : σ → ℤ) (N N' : σ → ℕ) + (hu : ∀ i, lo i ≤ u i ∧ u i < lo i + N i) + (hsub : ∀ i, lo i ≤ lo' i ∧ lo' i + N' i ≤ lo i + N i) + (hv : ∀ i, lo' i ≤ v i ∧ v i < lo' i + N' i) : + (∀ i, |(v i : ℝ) - (u i : ℝ)| ≤ (N i : ℝ)) ∧ + (∀ i, N' i ≤ N i) := by + constructor + · intro i + have hleft : -(N i : ℤ) ≤ v i - u i := by + have := hu i + have := hsub i + have := hv i + omega + have hright : v i - u i ≤ (N i : ℤ) := by + have := hu i + have := hsub i + have := hv i + omega + exact abs_le.mpr ⟨by exact_mod_cast hleft, by exact_mod_cast hright⟩ + · intro i + have := hsub i + omega + +theorem anchored_residue_refinement_bounds {σ : Type*} + (lo lo' u v : σ → ℤ) (N N' : σ → ℕ) {M M' : ℕ} + (hM : 0 < M) (hM' : 0 < M') (hdiv : M ∣ M') + (hcompat : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) + (hu : ∀ i, lo i ≤ u i ∧ u i < lo i + N i) + (hsub : ∀ i, lo i ≤ lo' i ∧ lo' i + N' i ≤ lo i + N i) + (hv : ∀ i, lo' i ≤ v i ∧ v i < lo' i + N' i) + (hN' : ∀ i, 0 < N' i) : + let A : σ → ℝ := fun i => (N i : ℝ) / M + let B : σ → ℝ := fun i => (N' i : ℝ) / M' + (∀ i, 0 < B i) ∧ + (∀ i, |(commonStrideIndex u M v i : ℝ)| ≤ A i) ∧ + (∀ i, |((M' / M : ℕ) : ℝ)| * B i ≤ A i) ∧ + (∀ i, (v i : ℝ) - (M' : ℝ) * B i ≤ (lo' i : ℝ) ∧ + (lo' i : ℝ) + (N' i : ℝ) ≤ (v i : ℝ) + (M' : ℝ) * B i) := by + intro A B + have hMr : (0 : ℝ) < M := by exact_mod_cast hM + have hM'r : (0 : ℝ) < M' := by exact_mod_cast hM' + have hmul : ∀ i, (M : ℝ) * A i = (N i : ℝ) := by + intro i + dsimp only [A] + field_simp + have hmul' : ∀ i, (M' : ℝ) * B i = (N' i : ℝ) := by + intro i + dsimp only [B] + field_simp + obtain ⟨hoffset, hlength⟩ := physical_box_anchor_bounds lo lo' u v N N' hu hsub hv + have hparams := residue_refinement_parameter_bounds u v hM hdiv hcompat A B + (fun i => by simpa only [hmul] using hoffset i) + (fun i => by simpa only [hmul, hmul'] using (show (N' i : ℝ) ≤ (N i : ℝ) by exact_mod_cast hlength i)) + refine ⟨fun i => div_pos (by exact_mod_cast hN' i) hM'r, hparams.1, hparams.2, ?_⟩ + intro i + rw [hmul'] + have hlow : (lo' i : ℝ) ≤ (v i : ℝ) := by exact_mod_cast (hv i).1 + have hhigh : (v i : ℝ) < (lo' i : ℝ) + (N' i : ℝ) := by exact_mod_cast (hv i).2 + constructor <;> linarith + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct BigOperators + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +theorem eval_commonStride_rebase (T : D.Niltest (fun _ : σ => 1)) + (u v : σ → ℤ) {M N : ℕ} (hM : 0 < M) (hMN : M ∣ N) + (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) (x : σ → ℤ) + (hx : ∀ i, x i ≡ v i [ZMOD (N : ℤ)]) : + T.eval (commonStrideIndex u M x) = + (T.scalarAffinePullback (N / M : ℕ) (fun i => (commonStrideIndex u M v i : ℚ))).eval + (commonStrideIndex v N x) := by + have hindex := commonStrideIndex_of_refinement u v hM hMN hv (commonStrideIndex v N x) + rw [commonStridePoint_index_of_modEq v N x hx] at hindex + have heval := T.scalarAffinePullback_eval_integer ((N / M : ℕ) : ℤ) + (commonStrideIndex u M v) (commonStrideIndex v N x) + calc + T.eval (commonStrideIndex u M x) = + T.eval (fun i => ((N / M : ℕ) : ℤ) * commonStrideIndex v N x i + commonStrideIndex u M v i) := + congrArg T.eval hindex + _ = _ := by simpa only [Int.cast_natCast] using heval.symm + +theorem residueBoxStride_rebase [Fintype σ] [DecidableEq σ] + (T : D.Niltest (fun _ : σ => 1)) (lo hi r z u v : σ → ℤ) + {M N : ℕ} (hM : 0 < M) (hMN : M ∣ N) + (hv : ∀ i, v i ≡ u i [ZMOD (M : ℤ)]) + (hz : ∀ i (x : ℤ), x ≡ z i [ZMOD r i] → x ≡ v i [ZMOD (N : ℤ)]) : + (𝔼 x : IntegerResidueBox lo hi r z, residueBoxStrideValue T.eval u M x) = + 𝔼 x : IntegerResidueBox lo hi r z, + residueBoxStrideValue + (T.scalarAffinePullback (N / M : ℕ) (fun i => (commonStrideIndex u M v i : ℚ))).eval v N x := by + apply Finset.expect_congr rfl + intro x _ + exact T.eval_commonStride_rebase u v hM hMN hv (fun i => (x i).val) + (fun i => hz i (x i).val (Finset.mem_filter.mp (x i).property).2) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RetainedAffineCommonCover.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedAffineCommonCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac7f8499f1f0644774e7ff9ad8b96d49c6efe136 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedAffineCommonCover.lean @@ -0,0 +1,770 @@ +import OAI.Combinatorics.Progressions.Dynamics.CubeModeUniformBudget +import OAI.Combinatorics.Progressions.Dynamics.ModeAmplitudeErrorBudget +import OAI.Combinatorics.Progressions.Estimates.BoundedCommonSiteResidual +import OAI.Combinatorics.Progressions.Polynomial.FixedKernelPolynomialCover + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def modeResidueSideThreshold (m d : ℕ) (D S ρ ε : ℝ) : ℝ := + modeRemovalSideThreshold m d D S ρ ε + S / (ρ * modeRemovalMesh d) + +theorem modeResidueSideThreshold_bounds (m d : ℕ) {D S ρ ε : ℝ} + (hD : 0 ≤ D) (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) : + modeRemovalSideThreshold m d D S ρ ε ≤ modeResidueSideThreshold m d D S ρ ε ∧ + S / modeRemovalMesh d ≤ ρ * modeResidueSideThreshold m d D S ρ ε := by + have hδ := modeRemovalMesh_pos d + have hb := (modeRemovalSideThreshold_bounds m d hD hS hρ hε).1 + constructor + · exact le_add_of_nonneg_right (by positivity) + · have hle : S / (ρ * modeRemovalMesh d) ≤ modeResidueSideThreshold m d D S ρ ε := + le_add_of_nonneg_left hb.le + have he : ρ * (S / (ρ * modeRemovalMesh d)) = S / modeRemovalMesh d := by + field_simp + rw [← he] + exact mul_le_mul_of_nonneg_left hle hρ.le + +theorem modeResidueWidth_mesh (m d : ℕ) {D S ρ ε H V : ℝ} {M : ℕ} + (hD : 0 ≤ D) (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) + (hM : 0 < M) (hMS : (M : ℝ) ≤ S) + (hH : modeResidueSideThreshold m d D S ρ ε ≤ H) + (hV : 0 < V) (hwidth : ρ * H ≤ V) : + 1 ≤ V / M ∧ 1 / (V / M) ≤ modeRemovalMesh d := by + have hm : (0 : ℝ) < M := by exact_mod_cast hM + have hδ := modeRemovalMesh_pos d + have hu : (M : ℝ) / modeRemovalMesh d ≤ V := + (div_le_div_of_nonneg_right hMS hδ.le).trans + (((modeResidueSideThreshold_bounds m d hD hS hρ hε).2.trans + (mul_le_mul_of_nonneg_left hH hρ.le)).trans hwidth) + apply modeRemovalMesh_of_width d (div_pos hV hm) + apply (le_div_iff₀ hm).mpr + calc + (1 / modeRemovalMesh d) * M = (M : ℝ) / modeRemovalMesh d := by ring + _ ≤ V := hu + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem selectedResidueSmoothWeight_pos_of_threshold {K I : Type*} [Fintype K] [Fintype I] + (m : ℕ) {D S ρ ε : ℝ} (hD : 0 ≤ D) (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) + (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) (hbound : ∀ j, (modulus j : ℝ) ≤ S) + (H : I → ℝ) + (hsize : ∀ j, modeResidueSideThreshold m (Fintype.card (K × I)) D S ρ ε ≤ H j) + (G : Finset (ColumnResiduePattern K I modulus)) (hG : G.Nonempty) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) (hwidth : ∀ z, ρ * H z.2 ≤ V z) : + 0 < ∑' x, selectedResidueSmoothWeight modulus G V x := by + let d := Fintype.card (K × I) + have hv z : 1 ≤ residueProfileWidth modulus V z ∧ + 1 / residueProfileWidth modulus V z ≤ modeRemovalMesh d := + modeResidueWidth_mesh m d hD hS hρ hε (hmodulus z.2) (hbound z.2) + (hsize z.2) (hV z) (hwidth z) + apply selectedResidueSmoothWeight_mass_pos modulus G hG V hV + intro r + rw [← residueSmoothWeight_mass _ modulus hmodulus V hV] + have hlower := shiftedSmoothProductMass_lower + (residueProfileCenter (columnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V) (residueProfileWidth_pos modulus V hmodulus hV) + (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) (fun z => (hv z).2) (modeRemovalMesh_small d) + exact (div_pos (Finset.prod_pos (fun z _ => residueProfileWidth_pos modulus V hmodulus hV z)) + (by norm_num)).trans_le hlower + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Polynomial + +theorem exists_mode_residue_threshold_exp_budget (m : ℕ) : + ∃ K : ℕ, 2 ≤ K ∧ ∀ (n d : ℕ) (P F D S ρ ε : ℝ), + 0 ≤ P → (n : ℝ) ≤ P → (d : ℝ) ≤ P → + 0 ≤ F → F ≤ Real.exp P → 0 ≤ D → D ≤ Real.exp P → + 0 ≤ S → S ≤ Real.exp P → 0 < ρ → 1 / ρ ≤ Real.exp P → + 0 < ε → 1 / ε ≤ Real.exp P → + modeResidueSideThreshold m d D S ρ ε ≤ Real.exp ((P + K) ^ K) ∧ + modeRemovalRankThreshold m n d F D S ρ ε ≤ Real.exp ((P + K) ^ K) := by + obtain ⟨K₀, _, hbase⟩ := exists_mode_threshold_exp_budget m + obtain ⟨K, hK, hpoly⟩ := exists_natPolynomial_eval_budget + ((X + C K₀) ^ K₀ + (2 * X + modeProfileLogPolynomial + 3) + 1) + refine ⟨K, hK, ?_⟩ + intro n d P F D S ρ ε hP hn hd hF hFP hD hDP hS hSP hρ hρP hε hεP + obtain ⟨hs, hr⟩ := hbase n d P F D S ρ ε hP hn hd hF hFP hD hDP hS hSP hρ hρP hε hεP + have hprof := modeProfileLog_nonneg hP + have hδ := modeRemovalMesh_pos d + have he : S / (ρ * modeRemovalMesh d) ≤ Real.exp (2 * P + modeProfileLog P + 3) := by + calc + _ = S * (1 / ρ) * (1 / modeRemovalMesh d) := by ring + _ ≤ Real.exp P * Real.exp P * Real.exp (modeProfileLog P + 3) := by + gcongr + exact modeRemovalMesh_inv_le_exp d hP hd + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hp : (P + K₀) ^ K₀ + (2 * P + modeProfileLog P + 3) + 1 ≤ (P + K) ^ K := by + simpa [Polynomial.eval₂_pow, modeProfileLogPolynomial_eval] using hpoly P hP + have hb0 : 0 ≤ (P + K₀) ^ K₀ := by positivity + constructor + · exact (add_le_exp_add_one hb0 (by linarith) hs he).trans (Real.exp_le_exp.mpr hp) + · exact hr.trans (Real.exp_le_exp.mpr (by linarith)) + +end Erdos3 + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open Polynomial + +theorem exists_cube_residue_threshold_exp_budget (m q : ℕ) : + ∃ K : ℕ, 2 ≤ K ∧ ∀ (n d : ℕ) (P F L S ρ ε : ℝ), + 0 ≤ P → (n : ℝ) ≤ P → (d : ℝ) ≤ P → + 0 ≤ F → F ≤ Real.exp P → 0 ≤ L → L ≤ Real.exp P → + 0 ≤ S → S ≤ Real.exp P → 0 < ρ → 1 / ρ ≤ Real.exp P → + 0 < ε → 1 / ε ≤ Real.exp P → + modeResidueSideThreshold m d (cubeModePolynomialBudget q L) S ρ ε ≤ Real.exp ((P + K) ^ K) ∧ + modeRemovalRankThreshold m n d F (cubeModePolynomialBudget q L) S ρ ε ≤ Real.exp ((P + K) ^ K) := by + obtain ⟨K₀, _, hbase⟩ := exists_cube_mode_threshold_exp_budget m q + obtain ⟨K, hK, hpoly⟩ := exists_natPolynomial_eval_budget + ((X + C K₀) ^ K₀ + (2 * X + modeProfileLogPolynomial + 3) + 1) + refine ⟨K, hK, ?_⟩ + intro n d P F L S ρ ε hP hn hd hF hFP hL hLP hS hSP hρ hρP hε hεP + obtain ⟨hs, hr⟩ := hbase n d P F L S ρ ε hP hn hd hF hFP hL hLP hS hSP hρ hρP hε hεP + have hprof := modeProfileLog_nonneg hP + have hδ := modeRemovalMesh_pos d + have he : S / (ρ * modeRemovalMesh d) ≤ Real.exp (2 * P + modeProfileLog P + 3) := by + calc + _ = S * (1 / ρ) * (1 / modeRemovalMesh d) := by ring + _ ≤ Real.exp P * Real.exp P * Real.exp (modeProfileLog P + 3) := by + gcongr + exact modeRemovalMesh_inv_le_exp d hP hd + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hp : (P + K₀) ^ K₀ + (2 * P + modeProfileLog P + 3) + 1 ≤ (P + K) ^ K := by + simpa [Polynomial.eval₂_pow, modeProfileLogPolynomial_eval] using hpoly P hP + have hb0 : 0 ≤ (P + K₀) ^ K₀ := by positivity + constructor + · exact (add_le_exp_add_one hb0 (by linarith) hs he).trans (Real.exp_le_exp.mpr hp) + · exact hr.trans (Real.exp_le_exp.mpr (by linarith)) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem affine_cube_residue_removal_at_error {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (hsize : ∀ k, modeResidueSideThreshold m (Fintype.card (Option K × I)) + (cubeModePolynomialBudget q L) S ρ ε ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : modeRemovalRankThreshold m (Fintype.card I) (Fintype.card (Option K × I)) + C (cubeModePolynomialBudget q L) S ρ ε ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) : + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ ε := by + classical + let d := Fintype.card (Option K × I) + let D := cubeModePolynomialBudget q L + let T := modeRemovalShrink m d D ρ ε + let B := finiteLayerBiasBudget m (modeRemovalBias m ε) + have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le + have hT : 0 < T := lt_of_lt_of_le zero_lt_one (modeRemovalShrink_one_le m d hD hρ hε) + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m (modeRemovalBias_pos m hε) + have hside := modeRemovalSideThreshold_bounds m d hD hS hρ hε + have hsizeBase k : modeRemovalSideThreshold m d D S ρ ε ≤ H k := + (modeResidueSideThreshold_bounds m d hD hS hρ hε).1.trans (hsize k) + have hH k : 0 < H k := hside.1.trans_le (hsizeBase k) + have hsize' k : (stride k : ℝ) * T * (B + 1) ≤ H k := by + calc + _ ≤ S * T * (B + 1) := by gcongr; exact hstride k + _ ≤ H k := hside.2.1.trans (hsizeBase k) + have hv z : 1 ≤ residueProfileWidth stride V z ∧ + 1 / residueProfileWidth stride V z ≤ modeRemovalMesh d := + modeResidueWidth_mesh m d hD hS hρ hε (hs z.2) (hstride z.2) (hsize z.2) (hV z) (hwidth z) + have hmass := shiftedSmoothProductMass_lower (residueProfileCenter residue stride) + (residueProfileWidth stride V) (residueProfileWidth_pos stride V hs hV) + (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) (fun z => (hv z).2) (modeRemovalMesh_small d) + have hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V) := + (div_pos (Finset.prod_pos (fun z _ => residueProfileWidth_pos stride V hs hV z)) (by norm_num)).trans_le hmass + refine ⟨hZ, ?_⟩ + have hout := affine_cube_residue_removal_of_widths U root difference hlin hL hC hsite frequency hbound hbad + p hp hm stride hs (modeRemovalBias_pos m hε) hT hS hstride H hH hsize' hrank hR + Q hQ test htest residue V hV hZ (fun z => (hv z).1) (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) + (fun z => (hv z).2) (modeRemovalMesh_small d) hρ (modeRemovalRadius_pos d hε).le hwidth + (modeRemovalShrink_move m d hρ hε) (modeRemovalBeta_pos hε).le (fun i => modeRemovalBias_le i hε) + exact hout.trans (modeRemovalError_bound d hε) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem anchored_affine_cube_residue_removal_at_error {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m q : ℕ} + (anchor : Option K × I → ℤ) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (hL : 0 ≤ L) (hC : 0 ≤ C) + (hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (hsize : ∀ k, modeResidueSideThreshold m (Fintype.card (Option K × I)) + (cubeModePolynomialBudget q L) S ρ ε ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : modeRemovalRankThreshold m (Fintype.card I) (Fintype.card (Option K × I)) + C (cubeModePolynomialBudget q L) S ρ ε ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) : + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => ((anchor + residueLatticeArray residue stride z) (k, j) : ℝ))‖ ≤ ε := by + classical + let d := Fintype.card (Option K × I) + let D := cubeModePolynomialBudget q L + let T := modeRemovalShrink m d D ρ ε + let B := finiteLayerBiasBudget m (modeRemovalBias m ε) + have hD : 0 ≤ D := (cubeModePolynomialBudget_pos q hL).le + have hT : 0 < T := lt_of_lt_of_le zero_lt_one (modeRemovalShrink_one_le m d hD hρ hε) + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m (modeRemovalBias_pos m hε) + have hside := modeRemovalSideThreshold_bounds m d hD hS hρ hε + have hsizeBase k : modeRemovalSideThreshold m d D S ρ ε ≤ H k := + (modeResidueSideThreshold_bounds m d hD hS hρ hε).1.trans (hsize k) + have hH k : 0 < H k := hside.1.trans_le (hsizeBase k) + have hsize' k : (stride k : ℝ) * T * (B + 1) ≤ H k := by + calc + _ ≤ S * T * (B + 1) := by gcongr; exact hstride k + _ ≤ H k := hside.2.1.trans (hsizeBase k) + have hv z : 1 ≤ residueProfileWidth stride V z ∧ + 1 / residueProfileWidth stride V z ≤ modeRemovalMesh d := + modeResidueWidth_mesh m d hD hS hρ hε (hs z.2) (hstride z.2) (hsize z.2) (hV z) (hwidth z) + have hmass := shiftedSmoothProductMass_lower (residueProfileCenter residue stride) + (residueProfileWidth stride V) (residueProfileWidth_pos stride V hs hV) + (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) (fun z => (hv z).2) (modeRemovalMesh_small d) + have hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V) := + (div_pos (Finset.prod_pos (fun z _ => residueProfileWidth_pos stride V hs hV z)) (by norm_num)).trans_le hmass + refine ⟨hZ, ?_⟩ + have hout := anchored_affine_cube_residue_removal_of_widths anchor U root difference hlin hL hC hsite frequency hbound hbad + p hp hm stride hs (modeRemovalBias_pos m hε) hT hS hstride H hH hsize' hrank hR + Q hQ test htest residue V hV hZ (fun z => (hv z).1) (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) + (fun z => (hv z).2) (modeRemovalMesh_small d) hρ (modeRemovalRadius_pos d hε).le hwidth + (modeRemovalShrink_move m d hρ hε) (modeRemovalBeta_pos hε).le (fun i => modeRemovalBias_le i hε) + exact hout.trans (modeRemovalError_bound d hε) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal + +theorem affine_coefficient_amplitude_residue_removal_at_error {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + {C : ℝ} (hC : 0 ≤ C) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (hbad : ∃ i : Fin m, ∃ P, Homogeneous (i.val + 1) P ∧ + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) + (map (U i).subtype P) ≠ 0) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (hS : 0 ≤ S) (hρ : 0 < ρ) (hε : 0 < ε) + (hstride : ∀ k, (stride k : ℝ) ≤ S) + (F : (Option K × I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) + {Lip : ℝ≥0} (hLip : LipschitzWith Lip F) + (H : I → ℝ) + (hsize : ∀ k, modeResidueSideThreshold m (Fintype.card (Option K × I)) + 1 S ρ (modeAmplitudeAccuracy Lip ε) ≤ H k) + (hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (hR : modeRemovalRankThreshold m (Fintype.card I) (Fintype.card (Option K × I)) + C 1 S ρ (modeAmplitudeAccuracy Lip ε) ≤ R) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hwidth : ∀ z, ρ * H z.2 ≤ V z) : + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride hs V hV hZ z).toReal : ℂ) * + (F (fun t => (residueLatticeArray residue stride z t : ℝ) / V t) * + layeredCoefficientCharacter + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ)))‖ ≤ ε := by + classical + let ε₀ := modeAmplitudeAccuracy (Lip : ℝ) ε + have hε₀ : 0 < ε₀ := modeAmplitudeAccuracy_pos Lip.coe_nonneg hε + let d := Fintype.card (Option K × I) + let D : ℝ := 1 + let T := modeRemovalShrink m d D ρ ε₀ + let B := finiteLayerBiasBudget m (modeRemovalBias m ε₀) + have hD : 0 ≤ D := zero_le_one + have hT : 0 < T := lt_of_lt_of_le zero_lt_one (modeRemovalShrink_one_le m d hD hρ hε₀) + have hB : 1 ≤ B := finiteLayerBiasBudget_one_le m (modeRemovalBias_pos m hε₀) + have hside := modeRemovalSideThreshold_bounds m d hD hS hρ hε₀ + have hsizeBase k : modeRemovalSideThreshold m d D S ρ ε₀ ≤ H k := + (modeResidueSideThreshold_bounds m d hD hS hρ hε₀).1.trans (hsize k) + have hH k : 0 < H k := hside.1.trans_le (hsizeBase k) + have hsize' k : (stride k : ℝ) * T * (B + 1) ≤ H k := by + calc + _ ≤ S * T * (B + 1) := by gcongr; exact hstride k + _ ≤ H k := hside.2.1.trans (hsizeBase k) + have hv z : 1 ≤ residueProfileWidth stride V z ∧ + 1 / residueProfileWidth stride V z ≤ modeRemovalMesh d := + modeResidueWidth_mesh m d hD hS hρ hε₀ (hs z.2) (hstride z.2) (hsize z.2) (hV z) (hwidth z) + have hmass := shiftedSmoothProductMass_lower (residueProfileCenter residue stride) + (residueProfileWidth stride V) (residueProfileWidth_pos stride V hs hV) + (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) (fun z => (hv z).2) (modeRemovalMesh_small d) + have hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V) := + (div_pos (Finset.prod_pos (fun z _ => residueProfileWidth_pos stride V hs hV z)) (by norm_num)).trans_le hmass + refine ⟨hZ, ?_⟩ + have hout := affine_coefficient_residue_removal_of_widths_lipschitz_amplitude U hC frequency hbound hbad + p hp hm stride hs (modeRemovalBias_pos m hε₀) hT hS hstride H hH hsize' hrank hR + residue V hV hZ (fun z => (hv z).1) (modeRemovalMesh_pos d).le (modeRemovalMesh_le_one d) + (fun z => (hv z).2) (modeRemovalMesh_small d) hρ (modeRemovalRadius_pos d hε₀).le hwidth + (modeRemovalShrink_move m d hρ hε₀) (modeRemovalBeta_pos hε₀).le (fun i => modeRemovalBias_le i hε₀) F hF hLip + exact hout.trans (modeAmplitudeError_bound d Lip.coe_nonneg hε) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_affine_cube_residue_uniform_removal (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothIndexPMF residue stride _hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (residueLatticeArray residue stride z (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hbudget⟩ := exists_cube_residue_threshold_exp_budget m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ P hP hn hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest residue V hV hwidth + obtain ⟨hside, hrankBudget⟩ := hbudget (Fintype.card I) (Fintype.card (Option K × I)) + P C L S ρ ε hP hn hd hC hCP hL hLP hS hSP hρ hρP hε hεP + exact affine_cube_residue_removal_at_error U root difference hlin hL hC hsite frequency hbound hbad + p hp hm stride hs hS hρ hε hstride H (fun k => hside.trans (hsize k)) hrank + (hrankBudget.trans hR) Q hQ test htest residue V hV hwidth + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_affine_cube_ambient_residue_removal (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (residue : Option K × I → ℤ) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V), + ‖∑' z : Option K × I → ℤ, ((residueSmoothPMF residue stride _hs V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hremove⟩ := exists_affine_cube_residue_uniform_removal m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ P hP hn hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest residue V hV hwidth + obtain ⟨hZ, hrem⟩ := hremove hP hn hd U root difference hlin hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest residue V hV hwidth + refine ⟨hZ, ?_⟩ + rw [residueSmoothPMF_expectation] + exact hrem + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators + +theorem exists_affine_cube_congruence_removal (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {P : ℝ} (_hP : 0 ≤ P) (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (_hlin : LinearIndependent ℝ (fun i k => (difference i k : ℝ))) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hbad : ∃ i, ¬∃ M : (Finset (Fin q) → U i) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (i.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency i d a : ℝ))) (map (U i).subtype P) = + M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P)) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (_hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + layeredModeTestedPhase + (fun j => affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ)))) + p Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ))‖ ≤ ε := by + obtain ⟨A, hA, hremove⟩ := exists_affine_cube_ambient_residue_removal m q + refine ⟨A, hA, ?_⟩ + intro I K _ _ _ J _ P hP hn hd U root difference hlin L C hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth + have hh (r : G) := hremove hP hn hd U root difference hlin hL hC hLP hCP + hsite frequency hbound hbad p hp hm stride hs hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest (columnResidueRepresentative stride r.val) V hV hwidth + choose hZ hrem using hh + exact selectedResidueSmoothPMF_bound_of_cells stride hs G hG V hV hZ _ hrem + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +def affineCubeModeFactors {K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : Prop := + ∀ j, ∃ M : (Finset (Fin q) → U j) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (j.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))) + (map (U j).subtype P) = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P) + +theorem not_affineCubeModeFactors_iff {K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : + ¬affineCubeModeFactors U root difference frequency ↔ + ∃ j, ¬∃ M : (Finset (Fin q) → U j) →ₗ[ℝ] ℝ, + ∀ P, Homogeneous (j.val + 1) P → + affineModeLift (coefficientFunctional (fun d a => (frequency j d a : ℝ))) + (map (U j).subtype P) = M (VectorPolynomial.siteEvaluation + (fun s => affineSite (fun k => (root k : ℝ)) (fun r k => (difference r k : ℝ)) s) P) := by + classical + simp only [affineCubeModeFactors, not_forall] + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +theorem affineCubeModeFactors_bounded {K : Type*} [Fintype K] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (hf : affineCubeModeFactors U root difference frequency) (j : Fin m) : + ∃ M : (Finset (Fin q) → U j) →ₗ[ℝ] ℝ, + ∀ p : VectorPolynomial K ℝ (U j), DegreeLE (1 : K → ℕ) (j.val + 1) p → + coefficientFunctional (fun d a => (frequency j d a : ℝ)) (map (U j).subtype p) = + M (VectorPolynomial.siteEvaluation (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p) := by + obtain ⟨M, hM⟩ := hf j + refine ⟨M, homogeneous_factorization_to_bounded_site (U j) (j.val + 1) + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) + (fun d a => (frequency j d a : ℝ)) M ?_⟩ + have hsite : (fun s (k : Option K) => k.elim (1 : ℝ) + (fun t => ((affineSite root difference s (some t) : ℤ) : ℝ))) = + (fun s => affineSite (fun k => (root k : ℝ)) (fun i k => (difference i k : ℝ)) s) := by + funext s k + cases k <;> simp [affineSite, Int.cast_sum] + simpa only [hsite] using hM + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +theorem exists_retained_affine_layer_cover : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K] {m q : ℕ} + (j : Fin m) (root : K → ℤ) (difference : Fin q → K → ℤ) + {H : ℕ} (_hH : 1 ≤ H) + (_hE : ∀ s d, RationalHeightLE + (boundedSiteMatrix (j.val + 1) (fun s k => affineSite root difference s (some k)) s d : ℚ) H) + {P : ℝ} (_hP : 0 ≤ P) + (_hD : (Fintype.card (BoundedCoefficientExponent K (j.val + 1)) : ℝ) ≤ P) + (_hS : (Fintype.card (Finset (Fin q)) : ℝ) ≤ P) (_hHP : (H : ℝ) ≤ Real.exp P), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {J : Fin m → Type*} [∀ i, Fintype (J i)] + (U : ∀ i, Submodule ℝ (J i → ℝ)) (frequency : ∀ i, (K →₀ ℕ) → J i → ℤ) + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (_hfrequency : ∀ d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hretained : affineCubeModeFactors U root difference frequency), + ∃ b : Matrix (Finset (Fin q)) (J j) ℤ, + (∀ s a, |(b s a : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ p : VectorPolynomial K ℝ (U j), DegreeLE (1 : K → ℕ) (j.val + 1) p → + CircleFourier.character + (coefficientFunctional (fun d a => (frequency j d a : ℝ)) (map (U j).subtype p) : CircleFourier.Circle) = + subspaceArrayCharacter (U j) b + (QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j)) + ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p)) := by + obtain ⟨A, hA, hcover⟩ := exists_polynomial_site_cover + refine ⟨A, hA, ?_⟩ + intro K _ m q j root difference H hH hE P hP hD hS hHP + obtain ⟨D, hDpos, hDP, hrows⟩ := hcover (j.val + 1) + (fun s k => affineSite root difference s (some k)) hH hE hP hD hS hHP + refine ⟨D, hDpos, hDP, ?_⟩ + intro J _ U frequency C hC hCP hfrequency hretained + obtain ⟨M, hM⟩ := affineCubeModeFactors_bounded U root difference frequency hretained j + exact hrows (U j) (frequency j) hC hCP hfrequency M hM + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial Polynomial +open scoped BigOperators Classical + +theorem exists_retained_affine_common_cover (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K : Type*} [Fintype K] {q : ℕ} + (root : K → ℤ) (difference : Fin q → K → ℤ) + {H : ℕ} (_hH : 1 ≤ H) + (_hE : ∀ (j : Fin m) s d, RationalHeightLE + (boundedSiteMatrix (j.val + 1) (fun s k => affineSite root difference s (some k)) s d : ℚ) H) + {P : ℝ} (_hP : 0 ≤ P) + (_hD : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent K (j.val + 1)) : ℝ) ≤ P) + (_hS : (Fintype.card (Finset (Fin q)) : ℝ) ≤ P) (_hHP : (H : ℝ) ≤ Real.exp P), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {J : Fin m → Type*} [∀ i, Fintype (J i)] + (U : ∀ i, Submodule ℝ (J i → ℝ)) (frequency : ∀ i, (K →₀ ℕ) → J i → ℤ) + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (_hfrequency : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hretained : affineCubeModeFactors U root difference frequency), + ∃ b : ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ j s a, |(b j s a : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (j : Fin m) (p : VectorPolynomial K ℝ (U j)), DegreeLE (1 : K → ℕ) (j.val + 1) p → + CircleFourier.character + (coefficientFunctional (fun d a => (frequency j d a : ℝ)) (map (U j).subtype p) : CircleFourier.Circle) = + subspaceArrayCharacter (U j) (b j) + (QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j)) + ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p)) := by + obtain ⟨A₀, _, hcover⟩ := exists_retained_affine_layer_cover + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget (C (m + 1) * (X + C A₀) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro K _ q root difference H hH hE P hP hD hS hHP + choose D hDpos hDP hrows using fun j : Fin m => + hcover j root difference hH (hE j) hP (hD j) hS hHP + have hB : 0 ≤ (P + A₀) ^ A₀ := by positivity + have hbud : ((m : ℝ) + 1) * (P + A₀) ^ A₀ ≤ (P + A) ^ A := by + simpa [Polynomial.eval₂_pow] using hbudget P hP + have hprod : (((∏ j, D j) : ℕ) : ℝ) ≤ Real.exp ((m : ℝ) * (P + A₀) ^ A₀) := by + rw [Nat.cast_prod] + calc + _ ≤ ∏ _j : Fin m, Real.exp ((P + A₀) ^ A₀) := + Finset.prod_le_prod₀ (fun j _ => Nat.cast_nonneg _) (fun j _ => hDP j) + _ = _ := by + rw [Finset.prod_const, Finset.card_univ, Fintype.card_fin, ← Real.exp_nat_mul] + refine ⟨∏ j, D j, Finset.prod_pos (fun j _ => hDpos j), + hprod.trans (Real.exp_le_exp.mpr (by nlinarith)), ?_⟩ + intro J _ U frequency C hC hCP hfrequency hretained + choose b hb hchar using fun j => hrows j U frequency hC hCP (hfrequency j) hretained + refine ⟨(fun j s a => (complementaryPeriod D j : ℤ) * b j s a), ?_, ?_⟩ + · intro j s a + rw [Int.cast_mul, Int.cast_natCast, abs_mul, + abs_of_nonneg (show (0 : ℝ) ≤ complementaryPeriod D j from Nat.cast_nonneg _)] + calc + _ ≤ (complementaryPeriod D j : ℝ) * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_left (hb j s a) (Nat.cast_nonneg _) + _ ≤ (((∏ i, D i) : ℕ) : ℝ) * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (complementaryPeriod_le_product D hDpos j)) + (Real.exp_pos _).le + _ ≤ Real.exp ((m : ℝ) * (P + A₀) ^ A₀) * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_right hprod (Real.exp_pos _).le + _ = Real.exp (((m : ℝ) + 1) * (P + A₀) ^ A₀) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp ((P + A) ^ A) := Real.exp_le_exp.mpr hbud + · intro j p hp + exact (hchar j p hp).trans (subspaceArrayCharacter_common_period D hDpos j (U j) (b j) + (VectorPolynomial.siteEvaluation (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p)).symm + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RetainedAffineResidueEpoch.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedAffineResidueEpoch.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce7b0ef392d8e4a358c849d8b94013cbecfc09dd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedAffineResidueEpoch.lean @@ -0,0 +1,293 @@ +import OAI.Combinatorics.Progressions.Lattices.FixedAffineResidueDescent +import OAI.Combinatorics.Progressions.Polynomial.RetainedPhysicalLowerDegree + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct BigOperators NNReal + +theorem exists_fixed_child_affine_residue_descent (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d), + ∀ p : ℝ, 0 ≤ p → D.GeometryComplexityLE p → + (Fintype.card σ : ℝ) ≤ p → ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ (P : ℕ) (hP : 0 < P), (P : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + ∀ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) {e n : ℕ} + (E : RationalFilteredNilmanifold (D.filtration.gradedRefiltrationSubalgebra W) (s + 1) e) + (Q : RationalFilteredNilmanifold + ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n) + (_hEF : E.filtration = D.filtration.gradedRefiltration W) + (_hQF : Q.filtration = E.filtration.quotientTop) + (b : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group), + (∀ α, coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α ∈ + D.filtration.realGradedRefiltrationLayer W (Finsupp.weight (fun _ => 1) α)) → + coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 → + ∀ cost : ℝ, 0 ≤ cost → SingleRefilteredRecoveryFamily D W E Q p q C cost → + let H := D.filtration.gradedRefiltrationSubalgebra W + let N := H ⧸ E.filtration.layerIdeal (s + 1) + let := moduleTopology ℝ (ℝ ⊗[ℚ] N) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] N) + let := realification_moduleTopology_t2 Q.basis + let T := Q.raiseStep (Nat.le_succ s) + ∃ Λ : Subgroup T.filtration.Group, Λ ≤ T.lattice ∧ + (Λ.subgroupOf T.lattice).Characteristic ∧ (Λ.subgroupOf T.lattice).Normal ∧ + (Λ.subgroupOf T.lattice).FiniteIndex ∧ (Λ.relIndex T.lattice : ℝ) ≤ Real.exp cost ∧ + ∃ (B : ℕ) (hB : 0 < B) + (hin : scaledIntegerGrid B ⊆ bchSubgroupCoordinates Q.basis Λ) + (hout : bchSubgroupCoordinates Q.basis Λ ⊆ denominatorGrid B), + let V := Q.loweredCover (Nat.le_succ s) Λ B hB hin hout + V.filtration = Q.filtration ∧ V.lattice ≤ Q.lattice ∧ V.GeometryComplexityLE cost ∧ + ∃ child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1), + DegreeLE (fun _ => 1) s child.log ∧ + FixedAffineResidueDescent D W V b child p q P hP C a (cost + 4) := by + obtain ⟨C, hC, hfreezing⟩ := Niltest.exists_auxiliary_frozen_discrepancy (s + 1) a + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ _ _ _ _ d D p hp hD hσ q hq hqp + obtain ⟨P, hP, hPb, hfreeze⟩ := hfreezing D (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) + p hp hD hσ q hq hqp + refine ⟨P, hP, hPb, ?_⟩ + intro W e n E Q hEF hQF b hb hb0 cost hcost hfamily H N _ _ _ T + obtain ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex, B, hB, hin, hout, hVF, hVL, hV, + child, hdegree, hrealize⟩ := + SingleRefilteredRecoveryFamily.exists_fixed_child D W E Q hEF hQF + (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) b hb hb0 hcost hfamily + let V := Q.loweredCover (Nat.le_succ s) Λ B hB hin hout + refine ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex, B, hB, hin, hout, hVF, hVL, hV, + child, hdegree, ?_⟩ + intro scale shift S hS hunit hinvariant slow rational κ hκ hprod hgrid A hA hslow M hM lo length width + hwidth hwidthN u v J hJ hv hcop δ ε hδ hε hsize hphysical hsmall cells c₀ c₁ F G + let middle := D.filtration.realification.scalarAffineAdaptedHom (scale : ℚ) (fun i => (shift i : ℚ)) b + obtain ⟨k, hk₀, hk₁, l₀, r₀, hl₀, hr₀, hgap⟩ := + hfreeze S hS hunit slow middle rational κ hκ hprod hgrid A hA hslow + M hM lo length width hwidth hwidthN u v J hJ hv hcop δ ε hδ hε hsize hphysical hsmall + have hℓ : (S.lipBound : ℝ) ≤ Real.exp p := by + linarith [S.observable_budget hS, S.normBound.coe_nonneg] + have hreal := (hrealize l₀ r₀ hl₀ hr₀ S.observable S.lipBound hℓ S.lipschitz hunit hinvariant).scalarAffine scale shift + have heq : (fun x : σ → ℤ => S.observable (QuotientGroup.mk + (l₀ * D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) + (fun i => (x i : ℝ)) middle * r₀))) = + (fun x : σ → ℤ => S.observable (QuotientGroup.mk + (l₀ * D.filtration.adaptedPolynomialRealValueHom (fun _ : σ => 1) + (fun i => ((scale * x i + shift i : ℤ) : ℝ)) b * r₀))) := by + funext x + exact congrArg (fun z : D.RealGroup => S.observable (QuotientGroup.mk (l₀ * z * r₀))) + (D.filtration.scalarAffineAdaptedHom_value_integer (scale : ℚ) + (fun i => (shift i : ℚ)) x (fun i => scale * x i + shift i) + (fun i => by push_cast; ring) b) + rw [← heq] at hreal + obtain ⟨U, hU, hunitU, hcostU, hgapU⟩ := hreal.transfer_discrepancy + (partitionCell c₀ k) (partitionCell c₁ k) + (fun x => commonStrideIndex u M (fun i => (x i).val)) + (fun x => commonStrideIndex u M (fun i => (x i).val)) hgap + exact ⟨k, hk₀, hk₁, U, hU, hunitU, hcostU, hgapU⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module VectorPolynomial +open scoped TensorProduct + +noncomputable def HasFixedAffineResidueChild {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (b : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group) + (p : ℝ) (q P : ℕ) (hP : 0 < P) (C a : ℕ) (cost : ℝ) : Prop := + ∃ E : RationalFilteredNilmanifold (D.filtration.gradedRefiltrationSubalgebra W) (s + 1) + (finrank ℚ (D.filtration.gradedRefiltrationSubalgebra W)), + E.filtration = D.filtration.gradedRefiltration W ∧ + ∃ (n : ℕ) (_hn : n ≤ d) + (Q : RationalFilteredNilmanifold + ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n), + Q.filtration = E.filtration.quotientTop ∧ + let H := D.filtration.gradedRefiltrationSubalgebra W + let N := H ⧸ E.filtration.layerIdeal (s + 1) + let := moduleTopology ℝ (ℝ ⊗[ℚ] N) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] N) + let := realification_moduleTopology_t2 Q.basis + ∃ V : RationalFilteredNilmanifold N s n, + V.filtration = Q.filtration ∧ V.lattice ≤ Q.lattice ∧ V.GeometryComplexityLE cost ∧ + ∃ child : V.filtration.realification.PolynomialOrbit (fun _ : σ => 1), + DegreeLE (fun _ => 1) s child.log ∧ + FixedAffineResidueDescent D W V b child p q P hP C a cost + +theorem exists_controlled_affine_residue_child (s a : ℕ) : + ∃ C K : ℕ, 2 ≤ C ∧ 2 ≤ K ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card σ : ℝ) ≤ p → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ (P : ℕ) (hP : 0 < P), (P : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + ∀ (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (v : Fin d → D.filtration.AssociatedGraded), + Submodule.span ℚ (Set.range v) = W.toSubmodule → + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (v i) j) ≤ p) → + ∀ b : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group, + (∀ α, coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α ∈ + D.filtration.realGradedRefiltrationLayer W (Finsupp.weight (fun _ => 1) α)) → + coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 → + ∃ cost : ℝ, 0 ≤ cost ∧ cost ≤ (p + 2) ^ K ∧ + HasFixedAffineResidueChild D W b p q P hP C a cost := by + obtain ⟨C, hC, hchild⟩ := exists_fixed_child_affine_residue_descent s a + obtain ⟨R, _, hmodels⟩ := exists_controlled_single_refiltered_reconstruction s C + let B : Polynomial ℕ := (Polynomial.X + Polynomial.C R) ^ R + 4 + obtain ⟨K, hK, hbudget⟩ := exists_natPolynomial_fixed_power_budget B + refine ⟨C, K, hC, hK, ?_⟩ + intro σ L _ _ _ _ d _ _ _ _ D ω hF p hp hD hσ q hq hqp + obtain ⟨P, hP, hPb, hdesc⟩ := hchild D p hp hD hσ q hq hqp + refine ⟨P, hP, hPb, ?_⟩ + intro W v hspan hv b hb hb0 + have hd : (Fintype.card (Fin d) : ℝ) ≤ p := by simpa only [Fintype.card_fin] using hD.1 + obtain ⟨E, hEF, _, _, n, hn, Q, hQF, _, _, hfamily⟩ := + hmodels D ω hF W v hspan hp hD hd hv q hq hqp + have hcost0 : 0 ≤ (p + R) ^ R := by positivity + have hcost : (p + R) ^ R + 4 ≤ (p + 2) ^ K := by + simpa [B, Polynomial.eval₂_pow] using hbudget p hp + have hnD : n ≤ d := by + have hh := lie_subalgebra_finrank_le D.basis (D.filtration.gradedRefiltrationSubalgebra W) + simpa only [Fintype.card_fin] using hn.trans hh + have hfixed := hdesc W E Q hEF hQF b hb hb0 ((p + R) ^ R) hcost0 hfamily + refine ⟨(p + R) ^ R + 4, by positivity, hcost, E, hEF, n, hnD, Q, hQF, ?_⟩ + intro H N _ _ _ + obtain ⟨Λ, _, _, _, _, _, B₀, hB₀, hin, hout, hVF, hVL, hV, child, hdegree, hresidue⟩ := hfixed + let V := Q.loweredCover (Nat.le_succ s) Λ B₀ hB₀ hin hout + exact ⟨V, hVF, hVL, hV.mono V (by linarith), child, hdegree, hresidue⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration VectorPolynomial RationalFilteredNilmanifold +open scoped TensorProduct + +noncomputable def RetainedAffineResidueEpoch {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (T : D.Niltest (fun _ : σ => 1)) (A : σ → ℝ) (p cost : ℝ) (C : ℕ) : Prop := + ∃ (v : Fin d → D.filtration.AssociatedGraded) (q P : ℕ) (hP : 0 < P) + (κ : D.RealGroup) + (E b R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group), + Submodule.span ℚ (Set.range v) = W.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω W.toSubmodule ∧ + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (v i) j) ≤ p) ∧ + 0 < q ∧ (q : ℝ) ≤ Real.exp p ∧ (P : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ κ ∈ D.realLattice ∧ + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) κ = + ⟨⟨T.orbit.log, T.orbit.property⟩⟩ ∧ + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) A (Real.exp (p + 2)) E ∧ + (∀ B : σ → ℝ, (∀ i, 0 < B i) → ∀ (r : ℚ) (h : σ → ℚ), + (∀ i, |(h i : ℝ)| ≤ A i) → (∀ i, |(r : ℝ)| * B i ≤ A i) → + D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) B (Real.exp (p + 2)) + (D.filtration.realification.scalarAffineAdaptedHom r h E)) ∧ + D.filtration.PolynomialRationalGrid D.basis (fun _ : σ => 1) q R ∧ + coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 ∧ + coefficients (R.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 ∧ + (∀ α, coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α ∈ + D.filtration.realGradedRefiltrationLayer W (Finsupp.weight (fun _ => 1) α)) ∧ + HasFixedAffineResidueChild D W b p q P hP C 1 cost + +theorem exists_retained_affine_residue_epoch (s : ℕ) : + ∃ C K : ℕ, 2 ≤ C ∧ 2 ≤ K ∧ ∀ {σ J L : Type*} [Fintype σ] [DecidableEq σ] [Fintype J] + [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (U : J → LieSubalgebra ℚ D.filtration.AssociatedGraded) + (v : J → Fin d → D.filtration.AssociatedGraded) (n aux oldModulus : J → ℕ) + (M : ℕ) (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (Fintype.card σ : ℝ) ≤ p → (Fintype.card J : ℝ) ≤ p → + (∀ j, Submodule.span ℚ (Set.range (v j)) = (U j).toSubmodule) → + (∀ j, BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω (U j).toSubmodule) → + (∀ j i k, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (v j i) k) ≤ p) → + (∀ j, 0 < n j) → (∀ j, 0 < aux j) → (∀ j, 0 < oldModulus j) → 0 < M → + (∀ j, oldModulus j ∣ M) → (∀ j, (n j : ℝ) ≤ Real.exp p) → + (∀ j, (aux j : ℝ) ≤ Real.exp p) → + ∀ W A : σ → ℝ, (∀ i, Real.exp ((p + 2) ^ K) ≤ A i) → + ∀ (T : D.Niltest (fun _ : σ => 1)) (shift : σ → ℚ) + (oldShift : J → σ → ℚ) (oldSides : J → σ → ℝ), + (∀ j i, 0 < oldSides j i) → (∀ i, (M : ℝ) * A i ≤ W i) → + (∀ j i, Real.exp (-p) * W i ≤ ((oldModulus j : ℝ) * aux j) * oldSides j i) → + (∀ j, D.filtration.SymbolFactorizationIn D.basis ω hF (oldSides j) + ((T.scalarAffinePullback ((oldModulus j : ℚ) * aux j) (oldShift j)).symbol D.basis ω hF) + p (n j) (U j)) → + ∃ work cost : ℝ, p + 16 ≤ work ∧ work ≤ (p + 2) ^ K ∧ 0 ≤ cost ∧ cost ≤ (p + 2) ^ K ∧ + RetainedAffineResidueEpoch D ω hF (⨅ j, U j) (T.scalarAffinePullback (M : ℚ) shift) A work cost C := by + obtain ⟨F, hFmin, hnormalize⟩ := exists_retained_physical_lower_degree_factorization s + obtain ⟨S, _, hslow⟩ := exists_scalarAffine_slow_bound (s + 1) ((F + 1) * F) + obtain ⟨C, D₀, hC, _, hchild⟩ := exists_controlled_affine_residue_child s 1 + let Q : Polynomial ℕ := Polynomial.X + (Polynomial.X + Polynomial.C F) ^ F + + (Polynomial.X + Polynomial.C S) ^ S + 16 + let R : Polynomial ℕ := (Polynomial.X + Polynomial.C F) ^ F + Q + (Q + 2) ^ D₀ + obtain ⟨K, hK, hbudget⟩ := exists_natPolynomial_fixed_power_budget R + refine ⟨C, K, hC, hK, ?_⟩ + intro σ J L _ _ _ _ _ d _ _ _ _ D ω hF U v n aux oldModulus M p hp hD hσ hJ + hv hgraded hheight hn haux hOld hM hdiv hnp hauxp W A hA T shift oldShift oldSides + hSides hcurrent hphysical hold + let work := p + (p + F) ^ F + (p + S) ^ S + 16 + have hF0 : 0 ≤ (p + F) ^ F := by positivity + have hS0 : 0 ≤ (p + S) ^ S := by positivity + have hpwork16 : p + 16 ≤ work := by dsimp only [work]; linarith + have hpwork : p ≤ work := by linarith + have hwork0 : 0 ≤ work := hp.trans hpwork + have hFwork : (p + F) ^ F ≤ work := by dsimp only [work]; linarith + have hSwork : (p + S) ^ S ≤ work := by dsimp only [work]; linarith + have htotal : (p + F) ^ F + work + (work + 2) ^ D₀ ≤ (p + 2) ^ K := by + simpa [R, Q, work, Polynomial.eval₂_pow] using hbudget p hp + have hpower0 : 0 ≤ (work + 2) ^ D₀ := by positivity + have hFbound : (p + F) ^ F ≤ (p + 2) ^ K := by linarith + have hworkbound : work ≤ (p + 2) ^ K := by linarith + have hchildbound : (work + 2) ^ D₀ ≤ (p + 2) ^ K := by linarith + have hApos : ∀ i, 0 < A i := fun i => (Real.exp_pos _).trans_le (hA i) + obtain ⟨v₀, m, κ, E, b, R₀, hv₀, hWgraded, hvheight, hm, hmp, _, hκ, hprod, + hE, hR, hb0, hR0, hcoeff, _, _⟩ := + hnormalize D ω hF U v n aux oldModulus M p hp hD hσ hJ hv hgraded hheight + hn haux hOld hM hdiv hnp hauxp W A + (fun i => (Real.exp_le_exp.mpr hFbound).trans (hA i)) + T shift oldShift oldSides hSides hcurrent hphysical hold + have hmpwork : (m : ℝ) ≤ Real.exp work := hmp.trans (Real.exp_le_exp.mpr hFwork) + obtain ⟨P, hP, hPb, hconstruct⟩ := hchild D ω hF work hwork0 (hD.mono D hpwork) + (hσ.trans hpwork) m hm hmpwork + obtain ⟨cost, hcost0, hcost, hfixed⟩ := hconstruct (⨅ j, U j) v₀ hv₀ + (fun i j => (hvheight i j).trans hFwork) b hcoeff hb0 + have hEcoeff := D.filtration.polynomialSlowBound_mono D.basis (fun _ : σ => 1) A hApos + (Real.exp_le_exp.mpr (shifted_power_le_fixed_base hp F hFmin)) E hE + refine ⟨work, cost, hpwork16, hworkbound, hcost0, hcost.trans hchildbound, + v₀, m, P, hP, κ, E, b, R₀, hv₀, hWgraded, fun i j => (hvheight i j).trans hFwork, + hm, hmpwork, hPb, hκ, hprod, ?_, ?_, hR, hb0, hR0, hcoeff, hfixed⟩ + · exact D.filtration.polynomialSlowBound_mono D.basis (fun _ : σ => 1) A hApos + (Real.exp_le_exp.mpr (by linarith)) E hE + · intro B hB r h hh hr + have hpull := hslow D.filtration D.basis p hp hσ A B hApos hB E hEcoeff r h hh hr + exact D.filtration.polynomialSlowBound_mono D.basis (fun _ : σ => 1) B hB + (Real.exp_le_exp.mpr (by linarith)) _ hpull + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RetainedLatticeNormalization.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedLatticeNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b14c1b55d9a545f47936e8ba652e78eeaf0dc4b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedLatticeNormalization.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeSlowConstantProduct +import OAI.Combinatorics.Progressions.Estimates.RetainedRefiltering +import OAI.Combinatorics.Progressions.Polynomial.PrescribedFastPolynomialFactorization + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration VectorPolynomial +open scoped TensorProduct + +theorem exists_retained_lattice_normalization (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ J L : Type*} [Fintype σ] [Fintype J] + [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (w : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ w i})) + (U : J → LieSubalgebra ℚ D.filtration.AssociatedGraded) + (v : J → Fin d → D.filtration.AssociatedGraded) (n : J → ℕ) + (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (Fintype.card σ : ℝ) ≤ p → (Fintype.card J : ℝ) ≤ p → + (∀ j, Submodule.span ℚ (Set.range (v j)) = (U j).toSubmodule) → + (∀ j, BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis w hF) w (U j).toSubmodule) → + (∀ j i k, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis w hF).repr (v j i) k) ≤ p) → + (∀ j, 0 < n j) → (∀ j, (n j : ℝ) ≤ Real.exp p) → + ∀ A : σ → ℝ, (∀ i, Real.exp ((p + C) ^ C) ≤ A i) → + ∀ g : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group, + (∀ j, D.filtration.SymbolFactorizationIn D.basis w hF A + (D.filtration.realPolynomialSymbolHom D.basis w hF (fun _ => 1) g) p (n j) (U j)) → + ∃ (v₀ : Fin d → D.filtration.AssociatedGraded) (m : ℕ) (κ : D.RealGroup) + (E b R : (D.filtration.realification.adaptedPolynomialFiltration (fun _ : σ => 1)).Group), + Submodule.span ℚ (Set.range v₀) = (⨅ j, U j).toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis w hF) w (⨅ j, U j).toSubmodule ∧ + (∀ i k, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis w hF).repr (v₀ i) k) ≤ + (p + C) ^ C) ∧ + 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ (∀ j, n j ∣ m) ∧ κ ∈ D.realLattice ∧ + E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) κ = g ∧ + (∀ α i, |(D.basis.baseChange ℝ).repr + (coefficients (E.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α) i| ≤ + Real.exp ((p + C) ^ C) / monomialScale A α) ∧ + ((fun z : (σ →₀ ℕ) × Fin d => (D.basis.baseChange ℝ).repr + (coefficients (R.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) z.1) z.2) ∈ realDenominatorGrid m) ∧ + coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 ∧ + coefficients (R.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 = 0 ∧ + (∀ α, coefficients (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) α ∈ + D.filtration.realGradedRefiltrationLayer (⨅ j, U j) (Finsupp.weight (fun _ => 1) α)) ∧ + (∀ t : σ → ℝ, eval₂ t (b.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) ∈ + realificationLieSubalgebra (D.filtration.gradedRefiltrationSubalgebra (⨅ j, U j))) := by + obtain ⟨c, _, hnormalize⟩ := exists_native_polynomial_normalization s + obtain ⟨k, _, hcommon⟩ := exists_retained_refiltered_factorization s + obtain ⟨l, _, hleft⟩ := exists_native_slow_left_constant_bound s + let N : Polynomial ℕ := (Polynomial.X + Polynomial.C c) ^ c + let F : Polynomial ℕ := (Polynomial.X + 2) ^ k + let H : Polynomial ℕ := ((Polynomial.X + 2) ^ 2 + 2) ^ 63 + 1 + let Q : Polynomial ℕ := Polynomial.X + N + F + let P : Polynomial ℕ := F + H + (Q + Polynomial.C l) ^ l + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ J L _ _ _ _ d _ _ _ D w hF U v n p hp hD hσ hJ hv hU hvheight hn hnp A hA g hfactor + let q := p + (p + c) ^ c + (p + 2) ^ k + have hn0 : 0 ≤ (p + c) ^ c := by positivity + have hf0 : 0 ≤ (p + 2) ^ k := by positivity + have hh0 : 0 ≤ ((p + 2) ^ 2 + 2) ^ 63 + 1 := by positivity + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have hnq : (p + c) ^ c ≤ q := by dsimp [q]; linarith + have hfq : (p + 2) ^ k ≤ q := by dsimp [q]; linarith + have hb : (p + 2) ^ k + (((p + 2) ^ 2 + 2) ^ 63 + 1) + (q + l) ^ l ≤ (p + C) ^ C := by + simpa [P, Q, N, F, H, q, Polynomial.eval₂_pow] using hbudget p hp + have hl0 : 0 ≤ (q + l) ^ l := by positivity + have hfC : (p + 2) ^ k ≤ (p + C) ^ C := by linarith + have hhC : ((p + 2) ^ 2 + 2) ^ 63 + 1 ≤ (p + C) ^ C := by linarith + have hlC : (q + l) ^ l ≤ (p + C) ^ C := by linarith + have hApos : ∀ i, 0 < A i := fun i => (Real.exp_pos _).trans_le (hA i) + obtain ⟨a, κ, g₀, ha, hκ, hnormalizeEq, hg₀zero, hsymbol⟩ := + hnormalize D w hF (fun _ : σ => 1) p hp hD g + have hfactor₀ : ∀ j, D.filtration.SymbolFactorizationIn D.basis w hF A + (D.filtration.realPolynomialSymbolHom D.basis w hF (fun _ => 1) g₀) p (n j) (U j) := by + intro j + rw [hsymbol] + exact hfactor j + obtain ⟨v₀, m, e₀, b, R, hv₀, hW, hheight, hm, hmp, hnm, hebr, + hmid, he, hR, _, hR0, hb0, hvalues⟩ := + hcommon D.filtration D.basis w hF U v n p hp + (by simpa only [Fintype.card_fin] using hD.1) hσ hJ (fun i j k => hD.2.2.1 i j k) + hv hU hvheight hn hnp A (fun i => (Real.exp_le_exp.mpr hfC).trans (hA i)) g₀ hfactor₀ + let E := D.filtration.realification.adaptedConstantGroupHom (fun _ : σ => 1) a * e₀ + have hE : D.filtration.PolynomialSlowBound D.basis (fun _ : σ => 1) A + (Real.exp ((p + C) ^ C)) E := by + have hsmall := hleft D w hF q hq (RationalFilteredNilmanifold.GeometryComplexityLE.mono D hD hpq) + (hσ.trans hpq) A hApos a (fun i => (ha i).trans (Real.exp_le_exp.mpr hnq)) e₀ + (D.filtration.polynomialSlowBound_mono D.basis (fun _ => 1) A hApos (Real.exp_le_exp.mpr hfq) e₀ he) + exact D.filtration.polynomialSlowBound_mono D.basis (fun _ => 1) A hApos + (Real.exp_le_exp.mpr hlC) E hsmall + have hprod : E * b * R * D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) κ = g := by + calc + _ = D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) a * + (e₀ * b * R) * D.filtration.realification.adaptedConstantGroupHom (fun _ => 1) κ := by + simp only [E, mul_assoc] + _ = g := by rw [hebr]; exact hnormalizeEq + let e := Fintype.equivFin (Fin d) + have hrange : Set.range (fun i => v₀ (e i)) = Set.range v₀ := by + ext x + constructor + · rintro ⟨i, rfl⟩ + exact ⟨e i, rfl⟩ + · rintro ⟨i, rfl⟩ + obtain ⟨j, hj⟩ := e.surjective i + exact ⟨j, congrArg v₀ hj⟩ + have hv' : Submodule.span ℚ (Set.range (fun i => v₀ (e i))) = (⨅ j, U j).toSubmodule := by + rw [hrange] + exact hv₀ + refine ⟨(fun i => v₀ (e i)), m, κ, E, b, R, hv', hW, + (fun i j => (hheight (e i) j).trans hhC), hm, + hmp.trans (Real.exp_le_exp.mpr hfC), hnm, hκ, hprod, hE, hR, + hb0.trans hg₀zero, hR0, ?_, hvalues hg₀zero⟩ + exact (D.filtration.real_symbol_values_iff_refiltration_coefficients D.basis w hF + (fun _ => 1) (⨅ j, U j) b.coord).mp hmid + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RetainedPhysicalCRT.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedPhysicalCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e1cb815e95f441d43edf246678a3ec297c23c25 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedPhysicalCRT.lean @@ -0,0 +1,895 @@ +import Mathlib.Algebra.Group.Units.Equiv +import Mathlib.Data.ZMod.QuotientRing +import OAI.Combinatorics.Progressions.Estimates.ObservedMarginalTesting +import OAI.Combinatorics.Progressions.Geometry.CoordinateLeafCount +import OAI.Combinatorics.Progressions.Probability.CouplingOneSidedTruncation + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {J I : Type*} [Fintype J] [Fintype I] {q : ℕ} [NeZero q] + +noncomputable def affineSampleKernel (z : Option J × I → ZMod q) : FiniteProbabilityWeights (I → ZMod q) := + residueAffineKernel (q := q) (affineSampleAlphabetEquiv z) + +theorem affineSampleKernel_mean (z : Option J × I → ZMod q) (f : (I → ZMod q) → ℝ) : + (affineSampleKernel z).mean f = + 𝔼 t : J → ZMod q, f (fun i => z (none, i) + ∑ j, t j * z (some j, i)) := by + rw [affineSampleKernel, residueAffineKernel_mean] + unfold residueColumnRealAverage + apply Finset.expect_congr rfl + intro t _ + change f ((fun i => z (none, i)) + ∑ j, t j • (fun i => z (some j, i))) = _ + congr 1 + funext i + simp only [Pi.add_apply, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + +theorem affineSampleKernel_preserves_mean (f : (I → ZMod q) → ℝ) : + (FiniteProbabilityWeights.uniform (Option J × I → ZMod q)).mean + (fun z => (affineSampleKernel z).mean f) = (FiniteProbabilityWeights.uniform (I → ZMod q)).mean f := by + unfold affineSampleKernel + rw [affineSampleAlphabet_mean + (fun z : (J → I → ZMod q) × (I → ZMod q) => (residueAffineKernel (q := q) z).mean f)] + exact residueAffineKernel_preserves_mean f + +noncomputable def affineSampleCoupling : + FiniteProbabilityCoupling (FiniteProbabilityWeights.uniform (Option J × I → ZMod q)) + (FiniteProbabilityWeights.uniform (I → ZMod q)) := + FiniteProbabilityCoupling.ofKernel _ _ affineSampleKernel affineSampleKernel_preserves_mean + +theorem affineSampleKernel_centered_sq {p a : ℕ} (hp : p.Prime) (hq : q = p ^ a) + (f : (I → ZMod q) → ℝ) (hf : (FiniteProbabilityWeights.uniform (I → ZMod q)).mean f = 0) : + (FiniteProbabilityWeights.uniform (Option J × I → ZMod q)).mean + (fun z => (affineSampleKernel z).mean f ^ 2) ≤ + (p : ℝ)⁻¹ ^ Fintype.card J * (FiniteProbabilityWeights.uniform (I → ZMod q)).mean (fun x => f x ^ 2) := by + unfold affineSampleKernel + rw [affineSampleAlphabet_mean + (fun z : (J → I → ZMod q) × (I → ZMod q) => (residueAffineKernel (q := q) z).mean f ^ 2)] + have hcard : Fintype.card (I → ZMod q) = p ^ (a * Fintype.card I) := by simp [hq, pow_mul] + exact residueAffineKernel_centered_sq hp hcard f hf + +omit [Fintype I] in +theorem affinePrimeCoordinateObservation_site {ι : Type*} (qs : ι → ℕ) [∀ i, NeZero (qs i)] + (t : J → ℤ) (z : Option J × I → ℤ) (i : ι) : + primeCoordinateObservation qs (BooleanCubeKernel.integerPhysicalSite t z) i = + (affinePrimeCoordinateObservation qs z i).2 + + residueColumnMap (q := qs i) (affinePrimeCoordinateObservation qs z i).1 (fun j => (t j : ZMod (qs i))) := by + funext k + simp only [primeCoordinateObservation, BooleanCubeKernel.integerPhysicalSite, Int.cast_add, + Int.cast_sum, Int.cast_mul, affinePrimeCoordinateObservation_apply, Pi.add_apply, + residueColumnMap, AddMonoidHom.coe_mk, ZeroHom.coe_mk, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {J I : Type*} [Fintype J] [Fintype I] {q : ℕ} [NeZero q] + +theorem affineSampleFixedParameter_mean (t : J → ZMod q) (f : (I → ZMod q) → ℝ) : + (FiniteProbabilityWeights.uniform (Option J × I → ZMod q)).mean + (fun z => f ((affineSampleAlphabetEquiv z).2 + + residueColumnMap (q := q) (affineSampleAlphabetEquiv z).1 t)) = + (FiniteProbabilityWeights.uniform (I → ZMod q)).mean f := by + rw [affineSampleAlphabet_mean + (fun z : (J → I → ZMod q) × (I → ZMod q) => f (z.2 + residueColumnMap (q := q) z.1 t))] + rw [residueAffineSource, FiniteProbabilityWeights.mean_prod] + have hs (V : J → I → ZMod q) : + (FiniteProbabilityWeights.uniform (I → ZMod q)).mean + (fun x => f (x + residueColumnMap (q := q) V t)) = + (FiniteProbabilityWeights.uniform (I → ZMod q)).mean f := + FiniteProbabilityWeights.uniform_mean_equiv (Equiv.addRight (residueColumnMap (q := q) V t)) f + simp only [hs, FiniteProbabilityWeights.mean_const] + +noncomputable def affineSampleParameterKernel (π : FiniteProbabilityWeights (J → ZMod q)) + (z : Option J × I → ZMod q) : FiniteProbabilityWeights (I → ZMod q) := + π.fiberLaw (fun t => (affineSampleAlphabetEquiv z).2 + + residueColumnMap (q := q) (affineSampleAlphabetEquiv z).1 t) + +theorem affineSampleParameterKernel_mean (π : FiniteProbabilityWeights (J → ZMod q)) + (z : Option J × I → ZMod q) (f : (I → ZMod q) → ℝ) : + (affineSampleParameterKernel π z).mean f = + π.mean (fun t => f ((affineSampleAlphabetEquiv z).2 + + residueColumnMap (q := q) (affineSampleAlphabetEquiv z).1 t)) := + π.fiberLaw_mean _ f + +theorem affineSampleParameterKernel_preserves_mean (π : FiniteProbabilityWeights (J → ZMod q)) + (f : (I → ZMod q) → ℝ) : + (FiniteProbabilityWeights.uniform (Option J × I → ZMod q)).mean + (fun z => (affineSampleParameterKernel π z).mean f) = + (FiniteProbabilityWeights.uniform (I → ZMod q)).mean f := by + simp only [affineSampleParameterKernel_mean] + rw [FiniteProbabilityWeights.mean_comm] + simp only [affineSampleFixedParameter_mean, FiniteProbabilityWeights.mean_const] + +noncomputable def affineSampleParameterCoupling (π : FiniteProbabilityWeights (J → ZMod q)) : + FiniteProbabilityCoupling (FiniteProbabilityWeights.uniform (Option J × I → ZMod q)) + (FiniteProbabilityWeights.uniform (I → ZMod q)) := + FiniteProbabilityCoupling.ofKernel _ _ (affineSampleParameterKernel π) + (affineSampleParameterKernel_preserves_mean π) + +theorem affineSampleParameterKernel_uniform (z : Option J × I → ZMod q) : + affineSampleParameterKernel (FiniteProbabilityWeights.uniform (J → ZMod q)) z = affineSampleKernel z := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +theorem inverse_prime_power_le_square {p ell : ℕ} {κ : ℝ} + (hp : p.Prime) (hell : 2 ≤ ell) (_hκ : 0 ≤ κ) (hlarge : (p : ℝ)⁻¹ ≤ κ) : + (p : ℝ)⁻¹ ^ ell ≤ κ ^ 2 := by + have hp1 : (1 : ℝ) ≤ p := by exact_mod_cast hp.one_le + have hi1 : (p : ℝ)⁻¹ ≤ 1 := by + simpa only [one_div, inv_one] using one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1) hp1 + exact (pow_le_pow_of_le_one (inv_nonneg.mpr (Nat.cast_nonneg p)) hi1 hell).trans + (pow_le_pow_left₀ (inv_nonneg.mpr (Nat.cast_nonneg p)) hlarge 2) + +theorem affineSampleKernel_centered_sq_of_inverse_le {J I : Type*} [Fintype J] [Fintype I] + {q p a : ℕ} [NeZero q] {κ : ℝ} (hp : p.Prime) (hq : q = p ^ a) + (hJ : 2 ≤ Fintype.card J) (hκ : 0 ≤ κ) (hlarge : (p : ℝ)⁻¹ ≤ κ) + (f : (I → ZMod q) → ℝ) (hf : (FiniteProbabilityWeights.uniform (I → ZMod q)).mean f = 0) : + (FiniteProbabilityWeights.uniform (Option J × I → ZMod q)).mean + (fun z => (affineSampleKernel z).mean f ^ 2) ≤ + κ ^ 2 * (FiniteProbabilityWeights.uniform (I → ZMod q)).mean (fun y => f y ^ 2) := by + exact (affineSampleKernel_centered_sq hp hq f hf).trans + (mul_le_mul_of_nonneg_right (inverse_prime_power_le_square hp hJ hκ hlarge) + ((FiniteProbabilityWeights.uniform (I → ZMod q)).mean_nonneg (fun _ => sq_nonneg _))) + +theorem residue_function_alphabet_card_le_exp {I : Type*} [Fintype I] {q : ℕ} [NeZero q] + {B : ℝ} (hq : (q : ℝ) ≤ Real.exp B) : + (Fintype.card (I → ZMod q) : ℝ) ≤ Real.exp ((Fintype.card I : ℝ) * B) := by + simp only [Fintype.card_fun, ZMod.card, Nat.cast_pow] + exact (pow_le_pow_left₀ (Nat.cast_nonneg q) hq _).trans_eq (Real.exp_nat_mul _ _).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +noncomputable def affineSampleProductCoupling {ι J σ : Type*} [Fintype J] [Fintype σ] + (q : ι → ℕ) [∀ i, NeZero (q i)] : + ∀ i, FiniteProbabilityCoupling + (primeCoordinateReference (σ := Option J × σ) q i) + (primeCoordinateReference (σ := σ) q i) := + fun i => affineSampleCoupling (J := J) (I := σ) (q := q i) + +noncomputable def affineResidueTruncatedPairing {ι J σ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype J] [Fintype σ] (q : ι → ℕ) [∀ i, NeZero (q i)] + (D : Finset (Finset ι)) (w : (∀ i, Option J × σ → ZMod (q i)) → ℝ) + (f : (∀ i, σ → ZMod (q i)) → ℝ) : ℝ := + productTruncatedPairing (affineSampleProductCoupling (J := J) (σ := σ) q) D w f + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {J : Type*} [Fintype J] {q : ℕ} [NeZero q] + +noncomputable def affinePeriodParameterLaw (D : ℕ) (a : J → ℤ) : + FiniteProbabilityWeights (J → ZMod q) := + (FiniteProbabilityWeights.uniform (J → ZMod q)).fiberLaw + (fun s j => (a j : ZMod q) + (D : ZMod q) * s j) + +theorem affinePeriodParameterLaw_mean (D : ℕ) (a : J → ℤ) + (f : (J → ZMod q) → ℝ) : + (affinePeriodParameterLaw D a).mean f = + (FiniteProbabilityWeights.uniform (J → ZMod q)).mean + (fun s => f (fun j => (a j : ZMod q) + (D : ZMod q) * s j)) := + FiniteProbabilityWeights.fiberLaw_mean _ _ _ + +theorem affinePeriodParameterLaw_uniform (D : ℕ) (a : J → ℤ) (hD : D.Coprime q) : + affinePeriodParameterLaw (q := q) D a = + FiniteProbabilityWeights.uniform (J → ZMod q) := by + let e : (J → ZMod q) ≃ (J → ZMod q) := + Equiv.piCongrRight (fun j => (ZMod.unitOfCoprime D hD).mulLeft.trans + (Equiv.addLeft (a j : ZMod q))) + have hm (f : (J → ZMod q) → ℝ) : + (affinePeriodParameterLaw D a).mean f = + (FiniteProbabilityWeights.uniform (J → ZMod q)).mean f := by + rw [affinePeriodParameterLaw_mean] + exact FiniteProbabilityWeights.uniform_mean_equiv e f + apply FiniteProbabilityWeights.eq_of_weight_eq + intro x + have h := hm (fun y => if y = x then (1 : ℝ) else 0) + simpa only [FiniteProbabilityWeights.mean, mul_ite, mul_one, mul_zero, + Finset.sum_ite_eq', Finset.mem_univ, ite_true] using h + +omit [Fintype J] [NeZero q] in +theorem affinePeriodParameterLaw_integer (D : ℕ) (a s : J → ℤ) : + (fun j => ((a j + (D : ℤ) * s j : ℤ) : ZMod q)) = + (fun j => (a j : ZMod q) + (D : ZMod q) * (s j : ZMod q)) := by + funext j + push_cast + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +theorem affineSampleParameterKernel_centered_bound {ι J I : Type*} + [DecidableEq ι] [Fintype J] [Fintype I] + (p q a : ι → ℕ) [∀ i, NeZero (q i)] + (hp : ∀ i, (p i).Prime) (hq : ∀ i, q i = p i ^ a i) (A : Finset ι) + (π : ∀ i, FiniteProbabilityWeights (J → ZMod (q i))) + (hπ : ∀ i ∉ A, π i = FiniteProbabilityWeights.uniform (J → ZMod (q i))) + (i : ι) (f : (I → ZMod (q i)) → ℝ) + (hf : (FiniteProbabilityWeights.uniform (I → ZMod (q i))).mean f = 0) : + (FiniteProbabilityWeights.uniform (Option J × I → ZMod (q i))).mean + (fun z => (affineSampleParameterKernel (π i) z).mean f ^ 2) ≤ + (if i ∈ A then 1 else (p i : ℝ)⁻¹ ^ Fintype.card J) * + (FiniteProbabilityWeights.uniform (I → ZMod (q i))).mean (fun x => f x ^ 2) := by + by_cases hi : i ∈ A + · rw [ite_eq_left hi, one_mul] + exact finiteKernel_contraction_sq _ _ _ (affineSampleParameterKernel_preserves_mean (π i)) f + · rw [ite_eq_right hi, hπ i hi] + simp only [affineSampleParameterKernel_uniform] + exact affineSampleKernel_centered_sq (hp i) (hq i) f hf + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem affine_leaf_source_assignments_card_le_exp {ι J σ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype σ] + (q : ι → ℕ) [∀ i, NeZero (q i)] + {Good : Finset ι → (∀ i, σ → ZMod (q i)) → Prop} + {tree : CoordinateDecisionTree ι (fun i => σ → ZMod (q i))} + {I : Finset ι} {base : ∀ i, σ → ZMod (q i)} {d A : ℕ} + (h : CoordinateDecisionTree.Valid Good I base tree d) (hA : I.card + d ≤ A) + {P modLog : ℝ} (hP : 0 ≤ P) (hmodLog : 0 ≤ modLog) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) : + ((CoordinateDecisionTree.leafSourceAssignments (fun i => Option J × σ → ZMod (q i)) tree I base).card : ℝ) ≤ + Real.exp ((A : ℝ) * (P + (Fintype.card (Option J × σ) : ℝ) * modLog + + (Fintype.card σ : ℝ) * modLog + 1)) := by + exact h.leafSourceAssignments_card_le_exp (fun i => Option J × σ → ZMod (q i)) hA hP + (by positivity) (by positivity) hcount + (fun i => by simpa only [Fintype.card_fun, ZMod.card] using + residue_function_alphabet_card_le_exp (I := Option J × σ) (q := q i) (hmoduli i)) + (fun i => residue_function_alphabet_card_le_exp (I := σ) (q := q i) (hmoduli i)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι J σ : Type*} [Fintype J] [Fintype σ] + (q : ι → ℕ) [∀ i, NeZero (q i)] + +noncomputable def affineParameterProductCoupling + (π : ∀ i, FiniteProbabilityWeights (J → ZMod (q i))) : + ∀ i, FiniteProbabilityCoupling + (primeCoordinateReference (σ := Option J × σ) q i) + (primeCoordinateReference (σ := σ) q i) := + fun i => affineSampleParameterCoupling (π i) + +theorem affineSampleParameterCoupling_uniform {q : ℕ} [NeZero q] : + affineSampleParameterCoupling (I := σ) (FiniteProbabilityWeights.uniform (J → ZMod q)) = + affineSampleCoupling := rfl + +theorem affineSampleParameterKernel_sq (i : ι) + (π : FiniteProbabilityWeights (J → ZMod (q i))) (f : (σ → ZMod (q i)) → ℝ) : + (primeCoordinateReference (σ := Option J × σ) q i).mean + (fun z => (affineSampleParameterKernel π z).mean f ^ 2) ≤ + (primeCoordinateReference (σ := σ) q i).mean (fun y => f y ^ 2) := by + calc + _ ≤ (primeCoordinateReference (σ := Option J × σ) q i).mean + (fun z => (affineSampleParameterKernel π z).mean (fun y => f y ^ 2)) := + FiniteProbabilityWeights.mean_mono _ (fun z => (affineSampleParameterKernel π z).mean_square_le f) + _ = _ := affineSampleParameterKernel_preserves_mean π (fun y => f y ^ 2) + +variable [Fintype ι] [DecidableEq ι] + +theorem affineParameterProductCoupling_pairing + (π : ∀ i, FiniteProbabilityWeights (J → ZMod (q i))) + (w : (∀ i, Option J × σ → ZMod (q i)) → ℝ) + (f : (∀ i, σ → ZMod (q i)) → ℝ) : + productCouplingPairing (affineParameterProductCoupling (σ := σ) q π) w f = + (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := Option J × σ) q)).mean + (fun z => w z * (FiniteProbabilityWeights.pi π).mean + (fun t => f (fun i => (affineSampleAlphabetEquiv (z i)).2 + + residueColumnMap (q := q i) (affineSampleAlphabetEquiv (z i)).1 (t i)))) := by + change (FiniteProbabilityWeights.pi (fun i => + (primeCoordinateReference (σ := Option J × σ) q i).joint (affineSampleParameterKernel (π i)))).mean + (fun z => w (fun i => (z i).1) * f (fun i => (z i).2)) = _ + rw [productJoint_mean (primeCoordinateReference (σ := Option J × σ) q) + (fun i => affineSampleParameterKernel (π i)) (fun x y => w x * f y)] + simp only [FiniteProbabilityWeights.mean_const_mul] + congr 1 + funext z + congr 1 + exact (productMean_coordinate_transport π + (fun i => affineSampleParameterKernel (π i) (z i)) + (fun i t => (affineSampleAlphabetEquiv (z i)).2 + + residueColumnMap (q := q i) (affineSampleAlphabetEquiv (z i)).1 t) + (fun i g => (affineSampleParameterKernel_mean (π i) (z i) g).symm) f).symm + +omit [Fintype ι] [DecidableEq ι] in +theorem affineParameterProductCoupling_outside + (π : ∀ i, FiniteProbabilityWeights (J → ZMod (q i))) (K : Finset ι) + (hπ : ∀ i ∉ K, π i = FiniteProbabilityWeights.uniform (J → ZMod (q i))) : + (fun i : {i // i ∉ K} => affineParameterProductCoupling (σ := σ) q π i.val) = + affineSampleProductCoupling (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) := by + funext i + change affineSampleParameterCoupling (π i.val) = affineSampleCoupling + rw [hπ i.val i.property] + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι J : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] + (q : ι → ℕ) [∀ i, NeZero (q i)] [NeZero (∏ i, q i)] + (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + +noncomputable def affineParameterCRTequiv : + (J → ZMod (∏ i, q i)) ≃ (∀ i, J → ZMod (q i)) := + (Equiv.piCongrRight (fun _ : J => (ZMod.prodEquivPi q hpair).toEquiv)).trans + (Equiv.piComm (fun (_ : J) i => ZMod (q i))) + +omit [DecidableEq ι] [Fintype J] [∀ i, NeZero (q i)] [NeZero (∏ i, q i)] in +theorem affineParameterCRTequiv_apply (s : J → ZMod (∏ i, q i)) (i : ι) (j : J) : + affineParameterCRTequiv q hpair s i j = + (ZMod.castHom (Finset.dvd_prod_of_mem q (Finset.mem_univ i)) (ZMod (q i))) (s j) := + ZMod.prodEquivPi_apply q hpair (s j) i + +theorem affineParameterCRT_mean (f : (∀ i, J → ZMod (q i)) → ℝ) : + (FiniteProbabilityWeights.uniform (J → ZMod (∏ i, q i))).mean + (fun s => f (affineParameterCRTequiv q hpair s)) = + (FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (J → ZMod (q i)))).mean f := by + rw [FiniteProbabilityWeights.uniform_mean_equiv (affineParameterCRTequiv q hpair) f] + have hweight : FiniteProbabilityWeights.uniform (∀ i, J → ZMod (q i)) = + FiniteProbabilityWeights.pi (fun i => FiniteProbabilityWeights.uniform (J → ZMod (q i))) := by + apply FiniteProbabilityWeights.eq_of_weight_eq + intro x + change (Fintype.card (∀ i, J → ZMod (q i)) : ℝ)⁻¹ = + ∏ i, (Fintype.card (J → ZMod (q i)) : ℝ)⁻¹ + rw [Fintype.card_pi, Nat.cast_prod, Finset.prod_inv_distrib] + rw [hweight] + +theorem affinePeriodParameterLaw_CRT (D : ℕ) (a : J → ℤ) + (f : (∀ i, J → ZMod (q i)) → ℝ) : + (FiniteProbabilityWeights.uniform (J → ZMod (∏ i, q i))).mean + (fun s => f (fun i j => (a j : ZMod (q i)) + + (D : ZMod (q i)) * affineParameterCRTequiv q hpair s i j)) = + (FiniteProbabilityWeights.pi (fun i => affinePeriodParameterLaw (q := q i) D a)).mean f := by + rw [affineParameterCRT_mean q hpair + (fun s => f (fun i j => (a j : ZMod (q i)) + (D : ZMod (q i)) * s i j))] + exact productMean_coordinate_transport + (fun i => FiniteProbabilityWeights.uniform (J → ZMod (q i))) + (fun i => affinePeriodParameterLaw (q := q i) D a) + (fun i s j => (a j : ZMod (q i)) + (D : ZMod (q i)) * s j) + (fun i g => (affinePeriodParameterLaw_mean D a g).symm) f + +omit [DecidableEq ι] [Fintype J] [∀ i, NeZero (q i)] in +theorem affineParameterCRTequiv_integer (s : J → ZMod (∏ i, q i)) (i : ι) (j : J) : + affineParameterCRTequiv q hpair s i j = ((s j).val : ZMod (q i)) := by + rw [affineParameterCRTequiv_apply] + have h := map_natCast (ZMod.castHom (Finset.dvd_prod_of_mem q (Finset.mem_univ i)) (ZMod (q i))) (s j).val + simpa only [ZMod.natCast_zmod_val] using h + +include hpair in +theorem affinePeriodParameterLaw_CRT_integer (D : ℕ) (a : J → ℤ) + (f : (∀ i, J → ZMod (q i)) → ℝ) : + (FiniteProbabilityWeights.uniform (J → ZMod (∏ i, q i))).mean + (fun s => f (fun i j => ((a j + (D : ℤ) * (s j).val : ℤ) : ZMod (q i)))) = + (FiniteProbabilityWeights.pi (fun i => affinePeriodParameterLaw (q := q i) D a)).mean f := by + simpa only [Int.cast_add, Int.cast_mul, Int.cast_natCast, affineParameterCRTequiv_integer] + using affinePeriodParameterLaw_CRT q hpair D a f + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι J σ : Type*} [Fintype J] [Fintype σ] + (q : ι → ℕ) [∀ i, NeZero (q i)] + +noncomputable def affinePeriodProductCoupling (D : ℕ) (a : J → ℤ) : + ∀ i, FiniteProbabilityCoupling + (primeCoordinateReference (σ := Option J × σ) q i) + (primeCoordinateReference (σ := σ) q i) := + affineParameterProductCoupling q (fun i => affinePeriodParameterLaw (q := q i) D a) + +theorem affinePeriodProductCoupling_outside (D : ℕ) (a : J → ℤ) (K : Finset ι) + (hD : ∀ i ∉ K, D.Coprime (q i)) : + (fun i : {i // i ∉ K} => affinePeriodProductCoupling (σ := σ) q D a i.val) = + affineSampleProductCoupling (J := J) (σ := σ) (fun i : {i // i ∉ K} => q i.val) := + affineParameterProductCoupling_outside q _ K + (fun i hi => affinePeriodParameterLaw_uniform D a (hD i hi)) + +variable [Fintype ι] [DecidableEq ι] + +theorem affinePeriodProductCoupling_pairing (D : ℕ) (a : J → ℤ) + (w : (∀ i, Option J × σ → ZMod (q i)) → ℝ) + (f : (∀ i, σ → ZMod (q i)) → ℝ) : + productCouplingPairing (affinePeriodProductCoupling (σ := σ) q D a) w f = + (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := Option J × σ) q)).mean + (fun z => w z * (FiniteProbabilityWeights.pi + (fun i => FiniteProbabilityWeights.uniform (J → ZMod (q i)))).mean + (fun s => f (fun i => (affineSampleAlphabetEquiv (z i)).2 + + residueColumnMap (q := q i) (affineSampleAlphabetEquiv (z i)).1 + (fun j => (a j : ZMod (q i)) + (D : ZMod (q i)) * s i j)))) := by + rw [affinePeriodProductCoupling, affineParameterProductCoupling_pairing] + congr 1 + funext z + congr 1 + exact (productMean_coordinate_transport + (fun i => FiniteProbabilityWeights.uniform (J → ZMod (q i))) + (fun i => affinePeriodParameterLaw (q := q i) D a) + (fun i s j => (a j : ZMod (q i)) + (D : ZMod (q i)) * s j) + (fun i g => (affinePeriodParameterLaw_mean D a g).symm) _).symm + +omit [Fintype ι] in +theorem affinePeriodParameterKernel_centered_sq + (D : ℕ) (a : J → ℤ) (K : Finset ι) (prime power : ι → ℕ) + (hprime : ∀ i, (prime i).Prime) (hpower : ∀ i, q i = prime i ^ power i) + (hD : ∀ i ∉ K, D.Coprime (q i)) + {κ : ℝ} (hκ : 0 ≤ κ) (hJ : 2 ≤ Fintype.card J) + (hlarge : ∀ i ∉ K, (prime i : ℝ)⁻¹ ≤ κ) + (i : ι) (f : (σ → ZMod (q i)) → ℝ) + (hf : (primeCoordinateReference (σ := σ) q i).mean f = 0) : + (primeCoordinateReference (σ := Option J × σ) q i).mean + (fun z => (affineSampleParameterKernel (affinePeriodParameterLaw D a) z).mean f ^ 2) ≤ + (if i ∈ K then 1 else κ ^ 2) * + (primeCoordinateReference (σ := σ) q i).mean (fun y => f y ^ 2) := by + by_cases hi : i ∈ K + · rw [ite_eq_left hi, one_mul] + exact affineSampleParameterKernel_sq q i _ f + · rw [ite_eq_right hi, affinePeriodParameterLaw_uniform D a (hD i hi)] + exact affineSampleKernel_centered_sq_of_inverse_le (hprime i) (hpower i) hJ hκ (hlarge i hi) f hf + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι J I : Type*} [Fintype J] [Fintype I] + (q : ι → ℕ) [∀ i, NeZero (q i)] + +noncomputable def affinePeriodResidueSample (D : ℕ) (a : J → ℤ) + (z : ∀ i, Option J × I → ZMod (q i)) (s : ∀ i, J → ZMod (q i)) : + ∀ i, I → ZMod (q i) := + fun i => (affineSampleAlphabetEquiv (z i)).2 + + residueColumnMap (q := q i) (affineSampleAlphabetEquiv (z i)).1 + (fun j => (a j : ZMod (q i)) + (D : ZMod (q i)) * s i j) + +omit [Fintype I] [∀ i, NeZero (q i)] in +theorem affinePeriodResidueSample_integer (D : ℕ) (a t : J → ℤ) + (z : Option J × I → ℤ) : + primeCoordinateObservation q (smoothAffineSample (fun j => a j + (D : ℤ) * t j) z) = + affinePeriodResidueSample q D a (primeCoordinateObservation q z) (primeCoordinateObservation q t) := by + funext i k + simp [primeCoordinateObservation, smoothAffineSample, affinePeriodResidueSample, + affineSampleAlphabetEquiv, residueColumnMap] + rfl + +omit [Fintype I] [∀ i, NeZero (q i)] in +theorem affinePeriodResidueSample_depends (D : ℕ) (a : J → ℤ) + (z : ∀ i, Option J × I → ZMod (q i)) (S : Finset ι) + (f : (∀ i, I → ZMod (q i)) → ℝ) (hf : ProductDependsOn S f) : + ProductDependsOn S (fun s => f (affinePeriodResidueSample q D a z s)) := by + intro s t hst + apply hf + intro i hi + dsimp only [affinePeriodResidueSample] + rw [hst i hi] + +variable [Fintype ι] [DecidableEq ι] + +theorem affinePeriodProductCoupling_observed {Ω : Type*} [Fintype Ω] + (p : FiniteProbabilityWeights Ω) (F : Ω → ∀ i, Option J × I → ZMod (q i)) + (D : ℕ) (a : J → ℤ) (w : Ω → ℝ) (f : (∀ i, I → ZMod (q i)) → ℝ) : + productCouplingPairing (affinePeriodProductCoupling (σ := I) q D a) + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) p F w) f = + p.mean (fun z => w z * (FiniteProbabilityWeights.pi + (primeCoordinateReference (σ := J) q)).mean + (fun s => f (affinePeriodResidueSample q D a (F z) s))) := by + rw [affinePeriodProductCoupling_pairing] + exact observedProductDensity_test (primeCoordinateReference (σ := Option J × I) q) p F + (primeCoordinateReference_weight_pos q) w _ + +theorem affinePeriodTruncatedPairing_observed {Ω : Type*} [Fintype Ω] + (p : FiniteProbabilityWeights Ω) (F : Ω → ∀ i, Option J × I → ZMod (q i)) + (D : ℕ) (a : J → ℤ) (supports : Finset (Finset ι)) + (w : Ω → ℝ) (f : (∀ i, I → ZMod (q i)) → ℝ) : + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) supports + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) p F w) f = + p.mean (fun z => w z * (FiniteProbabilityWeights.pi + (primeCoordinateReference (σ := J) q)).mean + (fun s => productANOVATruncation (primeCoordinateReference (σ := I) q) supports f + (affinePeriodResidueSample q D a (F z) s))) := by + rw [← productCouplingPairing_truncation_right] + exact affinePeriodProductCoupling_observed q p F D a w _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι J σ : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] [Fintype σ] + (q : ι → ℕ) [∀ i, NeZero (q i)] [NeZero (∏ i, q i)] + (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + +include hpair in +theorem affinePeriodProductCoupling_pairing_CRT (D : ℕ) (a : J → ℤ) + (w : (∀ i, Option J × σ → ZMod (q i)) → ℝ) + (f : (∀ i, σ → ZMod (q i)) → ℝ) : + productCouplingPairing (affinePeriodProductCoupling (σ := σ) q D a) w f = + (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := Option J × σ) q)).mean + (fun z => w z * (FiniteProbabilityWeights.uniform (J → ZMod (∏ i, q i))).mean + (fun s => f (fun i => (affineSampleAlphabetEquiv (z i)).2 + + residueColumnMap (q := q i) (affineSampleAlphabetEquiv (z i)).1 + (fun j => ((a j + (D : ℤ) * (s j).val : ℤ) : ZMod (q i)))))) := by + rw [affinePeriodProductCoupling, affineParameterProductCoupling_pairing] + congr 1 + funext z + congr 1 + exact (affinePeriodParameterLaw_CRT_integer q hpair D a _).symm + +omit [Fintype σ] in +include hpair in +theorem affinePeriodParameterLaw_physical_site (D : ℕ) (a : J → ℤ) + (z : Option J × σ → ℤ) (f : (∀ i, σ → ZMod (q i)) → ℝ) : + (FiniteProbabilityWeights.pi (fun i => affinePeriodParameterLaw (q := q i) D a)).mean + (fun t => f (fun i => (affinePrimeCoordinateObservation q z i).2 + + residueColumnMap (q := q i) (affinePrimeCoordinateObservation q z i).1 (t i))) = + (FiniteProbabilityWeights.uniform (J → ZMod (∏ i, q i))).mean + (fun s => f (primeCoordinateObservation q + (BooleanCubeKernel.integerPhysicalSite (fun j => a j + (D : ℤ) * (s j).val) z))) := by + rw [← affinePeriodParameterLaw_CRT_integer q hpair D a] + congr 1 + funext s + apply congrArg f + funext i + exact (affinePrimeCoordinateObservation_site q (fun j => a j + (D : ℤ) * (s j).val) z i).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι J I Ω Θ : Type*} [Fintype ι] [DecidableEq ι] + [Fintype J] [Fintype I] [Fintype Ω] [Fintype Θ] + (q : ι → ℕ) [∀ i, NeZero (q i)] + +theorem affinePeriodTruncatedPairing_comparison + (p : FiniteProbabilityWeights Ω) (r : FiniteProbabilityWeights Θ) + (F : Ω → ∀ i, Option J × I → ZMod (q i)) (G : Θ → ∀ i, J → ZMod (q i)) + (D : ℕ) (a : J → ℤ) (supports : Finset (Finset ι)) + (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z ∧ w z ≤ 1) + (f : (∀ i, I → ZMod (q i)) → ℝ) {b : ℕ} {eta C : ℝ} (heta : 0 ≤ eta) + (hcard : ∀ S ∈ supports, S.card ≤ b) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := J) q) + (observedProductDensity (primeCoordinateReference (σ := J) q) r G (fun _ => 1)) eta b) + (hcap : ∀ S ∈ supports, ∀ x, |productANOVA (primeCoordinateReference (σ := I) q) S f x| ≤ C) : + |p.mean (fun z => w z * r.mean (fun t => + productANOVATruncation (primeCoordinateReference (σ := I) q) supports f + (affinePeriodResidueSample q D a (F z) (G t)))) - + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) supports + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) p F w) f| ≤ + eta * supports.card * C := by + rw [affinePeriodTruncatedPairing_observed, ← p.mean_sub] + apply p.abs_mean_le_on_support + intro z _ + have he := observedProductDensity_family_test_error (primeCoordinateReference (σ := J) q) + r G (primeCoordinateReference_weight_pos q) supports + (fun S s => productANOVA (primeCoordinateReference (σ := I) q) S f + (affinePeriodResidueSample q D a (F z) s)) heta hcard + (fun S _ => affinePeriodResidueSample_depends q D a (F z) S _ + (productANOVA_depends (primeCoordinateReference (σ := I) q) S f)) + hclose (fun S hS x => hcap S hS (affinePeriodResidueSample q D a (F z) x)) + change |r.mean (fun t => productANOVATruncation (primeCoordinateReference (σ := I) q) supports f + (affinePeriodResidueSample q D a (F z) (G t))) - + (FiniteProbabilityWeights.pi (primeCoordinateReference (σ := J) q)).mean + (fun s => productANOVATruncation (primeCoordinateReference (σ := I) q) supports f + (affinePeriodResidueSample q D a (F z) s))| ≤ _ at he + rw [← mul_sub, abs_mul, abs_of_nonneg (hw z).1] + exact (mul_le_mul (hw z).2 he (abs_nonneg _) zero_le_one).trans_eq (one_mul _) + +theorem affinePeriodTruncation_sample_comparison + (p : FiniteProbabilityWeights Ω) (r : FiniteProbabilityWeights Θ) + (source : Ω → Option J × I → ℤ) (index : Θ → J → ℤ) + (D : ℕ) (a : J → ℤ) (supports : Finset (Finset ι)) + (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z ∧ w z ≤ 1) + (f : (∀ i, I → ZMod (q i)) → ℝ) {b : ℕ} {eta C : ℝ} (heta : 0 ≤ eta) + (hcard : ∀ S ∈ supports, S.card ≤ b) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := J) q) + (observedProductDensity (primeCoordinateReference (σ := J) q) r + (fun t => primeCoordinateObservation q (index t)) (fun _ => 1)) eta b) + (hcap : ∀ S ∈ supports, ∀ x, |productANOVA (primeCoordinateReference (σ := I) q) S f x| ≤ C) : + |p.mean (fun z => w z * r.mean (fun t => + productANOVATruncation (primeCoordinateReference (σ := I) q) supports f + (primeCoordinateObservation q + (smoothAffineSample (fun j => a j + (D : ℤ) * index t j) (source z))))) - + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) supports + (observedProductDensity (primeCoordinateReference (σ := Option J × I) q) p + (fun z => primeCoordinateObservation q (source z)) w) f| ≤ + eta * supports.card * C := by + simp only [affinePeriodResidueSample_integer] + exact affinePeriodTruncatedPairing_comparison q p r + (fun z => primeCoordinateObservation q (source z)) + (fun t => primeCoordinateObservation q (index t)) D a supports w hw f heta hcard hclose hcap + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residuePrimeCoordinateDensity_component_cap {ι I : Type*} + [Fintype ι] [DecidableEq ι] [Fintype I] [DecidableEq I] + (lo : I → ℤ) (N : I → ℕ) (M : ℕ) (a : I → ℤ) + (hne : Nonempty (IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) a)) + (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ) (f : (I → ℤ) → ℝ) + (hf : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z ∧ f z ≤ 1) + {eta : ℝ} (heta : 0 ≤ eta) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := I) q) + (residuePrimeCoordinateDensity lo N M a hne q (fun _ => 1)) eta b) + (S : Finset ι) (hS : S.card ≤ b) (x : ∀ i, I → ZMod (q i)) : + |productANOVA (primeCoordinateReference (σ := I) q) S + (residuePrimeCoordinateDensity lo N M a hne q f) x| ≤ (2 : ℝ) ^ b * (1 + eta) := by + let := hne + have hw (z : IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) a) : + 0 ≤ f (fun i => (z i).val) ∧ f (fun i => (z i).val) ≤ 1 := by + apply hf + apply (mem_translatedIntegerBox lo N _).mpr + intro i + exact Finset.mem_Ico.mp (Finset.mem_filter.mp (z i).property).1 + have h := observedProductDensity_component_cap (primeCoordinateReference (σ := I) q) + (FiniteProbabilityWeights.uniform + (IntegerResidueBox lo (fun i => lo i + N i) (fun _ => (M : ℤ)) a)) + (fun z => primeCoordinateObservation q (fun i => (z i).val)) + (primeCoordinateReference_weight_pos q) (fun z => f (fun i => (z i).val)) + zero_le_one heta hw hclose S hS x + simpa only [mul_one, residuePrimeCoordinateDensity] using h + +variable {ι J I : Type*} [Fintype ι] [DecidableEq ι] [Fintype J] + [Fintype I] + (q : ι → ℕ) [∀ i, NeZero (q i)] + (sourceLo : Option J × I → ℤ) (sourceN : Option J × I → ℕ) + (sourceHne : Nonempty (IntegerResidueBox sourceLo (fun i => sourceLo i + sourceN i) + (fun _ => 1) (fun _ => 0))) + (paramLo : J → ℤ) (paramN : J → ℕ) + (paramHne : Nonempty (IntegerResidueBox paramLo (fun j => paramLo j + paramN j) + (fun _ => 1) (fun _ => 0))) + (siteLo : I → ℤ) (siteN : I → ℕ) + (siteHne : Nonempty (IntegerResidueBox siteLo (fun i => siteLo i + siteN i) + (fun _ => 1) (fun _ => 0))) + (D : ℕ) (a : J → ℤ) (b : ℕ) (w : (Option J × I → ℤ) → ℝ) (f : (I → ℤ) → ℝ) + +noncomputable def residueAffineTruncationError : ℝ := + |(𝔼 z : IntegerResidueBox sourceLo (fun i => sourceLo i + sourceN i) (fun _ => 1) (fun _ => 0), + w (fun i => (z i).val) * + (𝔼 t : IntegerResidueBox paramLo (fun j => paramLo j + paramN j) (fun _ => 1) (fun _ => 0), + residuePhysicalTruncation siteLo siteN 1 (fun _ => 0) siteHne q b f + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) - + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b) + (residuePrimeCoordinateDensity sourceLo sourceN 1 (fun _ => 0) sourceHne q w) + (residuePrimeCoordinateDensity siteLo siteN 1 (fun _ => 0) siteHne q f)| + +theorem residueAffineTruncation_comparison + (hw : ∀ z ∈ translatedIntegerBox sourceLo sourceN, 0 ≤ w z ∧ w z ≤ 1) + (hf : ∀ z ∈ translatedIntegerBox siteLo siteN, 0 ≤ f z ∧ f z ≤ 1) + {etaParam etaSite : ℝ} (hparam : 0 ≤ etaParam) (hsite : 0 ≤ etaSite) + (hcloseParam : ProductMarginalsClose (primeCoordinateReference (σ := J) q) + (residuePrimeCoordinateDensity paramLo paramN 1 (fun _ => 0) paramHne q (fun _ => 1)) etaParam b) + (hcloseSite : ProductMarginalsClose (primeCoordinateReference (σ := I) q) + (residuePrimeCoordinateDensity siteLo siteN 1 (fun _ => 0) siteHne q (fun _ => 1)) etaSite b) : + residueAffineTruncationError q sourceLo sourceN sourceHne paramLo paramN + siteLo siteN siteHne D a b w f ≤ etaParam * residueTruncationCap ι b etaSite := by + let := sourceHne + let := paramHne + have hw' (z : IntegerResidueBox sourceLo (fun i => sourceLo i + sourceN i) (fun _ => 1) (fun _ => 0)) : + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1 := by + apply hw + apply (mem_translatedIntegerBox sourceLo sourceN _).mpr + intro i + exact Finset.mem_Ico.mp (Finset.mem_filter.mp (z i).property).1 + have h := affinePeriodTruncation_sample_comparison q + (FiniteProbabilityWeights.uniform + (IntegerResidueBox sourceLo (fun i => sourceLo i + sourceN i) (fun _ => 1) (fun _ => 0))) + (FiniteProbabilityWeights.uniform + (IntegerResidueBox paramLo (fun j => paramLo j + paramN j) (fun _ => 1) (fun _ => 0))) + (fun z i => (z i).val) (fun t j => (t j).val) D a (lowDegreeCoordinateSets ι b) + (fun z => w (fun i => (z i).val)) hw' + (residuePrimeCoordinateDensity siteLo siteN 1 (fun _ => 0) siteHne q f) + hparam (fun S hS => (mem_lowDegreeCoordinateSets ι b S).mp hS) hcloseParam + (fun S hS x => residuePrimeCoordinateDensity_component_cap siteLo siteN 1 (fun _ => 0) + siteHne q b f hf hsite hcloseSite S ((mem_lowDegreeCoordinateSets ι b S).mp hS) x) + convert h using 1 <;> + simp only [residueAffineTruncationError, residuePhysicalTruncation, residuePrimeCoordinateDensity, + FiniteProbabilityWeights.uniform_mean, residueTruncationCap, mul_assoc] + congr 1 + +include paramHne in +theorem residueAffineTruncation_comparison_of_lengths + (hw : ∀ z ∈ translatedIntegerBox sourceLo sourceN, 0 ≤ w z ∧ w z ≤ 1) + (hf : ∀ z ∈ translatedIntegerBox siteLo siteN, 0 ≤ f z ∧ f z ≤ 1) + (hpair : Pairwise (fun i l => (q i).Coprime (q l))) + (modLog dimLog accLog etaParam etaSite : ℝ) + (hmodLog : 0 ≤ modLog) (hparam : etaParam ≤ 1) (hsite : 0 ≤ etaSite) + (haccuracy : Real.exp (-accLog) ≤ etaParam) + (hmoduli : ∀ i, (q i : ℝ) ≤ Real.exp modLog) + (hdim : (Fintype.card J : ℝ) ≤ Real.exp dimLog) + (hlength : ∀ j, Real.exp (modLog * b + accLog + dimLog + 1) ≤ + (residueIndexLength (paramLo j) (paramLo j + paramN j) 1 0 : ℝ)) + (hcloseSite : ProductMarginalsClose (primeCoordinateReference (σ := I) q) + (residuePrimeCoordinateDensity siteLo siteN 1 (fun _ => 0) siteHne q (fun _ => 1)) etaSite b) : + residueAffineTruncationError q sourceLo sourceN sourceHne paramLo paramN + siteLo siteN siteHne D a b w f ≤ etaParam * residueTruncationCap ι b etaSite := by + have hc := residuePrimeDensity_close_of_lengths paramLo paramN 1 (fun _ => 0) paramHne q + (by decide) (fun i => Nat.coprime_one_left (q i)) hpair b modLog dimLog accLog etaParam + hmodLog hparam haccuracy hmoduli hdim hlength + exact residueAffineTruncation_comparison q sourceLo sourceN sourceHne paramLo paramN paramHne + siteLo siteN siteHne D a b w f hw hf ((Real.exp_pos _).le.trans haccuracy) hsite hc hcloseSite + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {ι I : Type*} [Fintype ι] [DecidableEq ι] [Fintype I] + +theorem physicalBoxTruncation_of_classify_some (lo : I → ℤ) (N : I → ℕ) + (P : ∀ i, FiniteProgressionPartition (N i)) (hpos : ∀ i c, 0 < (P i).length c) + (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ) (f : (I → ℤ) → ℝ) + (x : I → ℤ) (c : ∀ i, (P i).Label) (hx : physicalBoxClassify lo N P x = some c) : + physicalBoxTruncation lo N P hpos q b f x = + residuePhysicalTruncation (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hpos c) q b f x := by + by_cases h : x ∈ translatedIntegerBox lo N + · simp only [physicalBoxClassify, dite_eq_left h, Option.some.injEq] at hx + simp only [physicalBoxTruncation, dite_eq_left h] + rw [hx] + · simp only [physicalBoxClassify, dite_eq_right h] at hx + cases hx + +theorem physicalBoxTruncation_of_classify_none (lo : I → ℤ) (N : I → ℕ) + (P : ∀ i, FiniteProgressionPartition (N i)) (hpos : ∀ i c, 0 < (P i).length c) + (q : ι → ℕ) [∀ i, NeZero (q i)] (b : ℕ) (f : (I → ℤ) → ℝ) + (x : I → ℤ) (hx : physicalBoxClassify lo N P x = none) : + physicalBoxTruncation lo N P hpos q b f x = 0 := by + by_cases h : x ∈ translatedIntegerBox lo N + · simp only [physicalBoxClassify, dite_eq_left h] at hx + cases hx + · simp only [physicalBoxTruncation, dite_eq_right h] + +theorem retained_physical_truncation_crt {J : Type*} [Fintype J] + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i c, (P i).step c = 1) (hpos : ∀ i c, 0 < (P i).length c) + (c : ∀ i, (P i).Label) (q : ι → ℕ) [∀ i, NeZero (q i)] + (sourceLo : Option J × I → ℤ) (sourceN : Option J × I → ℕ) + (sourceHne : Nonempty (IntegerResidueBox sourceLo (fun i => sourceLo i + sourceN i) + (fun _ => 1) (fun _ => 0))) + (paramLo : J → ℤ) (paramN : J → ℕ) + (paramHne : Nonempty (IntegerResidueBox paramLo (fun j => paramLo j + paramN j) + (fun _ => 1) (fun _ => 0))) + (D : ℕ) (a : J → ℤ) (b : ℕ) (w : (Option J × I → ℤ) → ℝ) (f : (I → ℤ) → ℝ) + (hw : ∀ z ∈ translatedIntegerBox sourceLo sourceN, 0 ≤ w z ∧ w z ≤ 1) + (hf : ∀ x ∈ translatedIntegerBox lo N, 0 ≤ f x ∧ f x ≤ 1) + (hretained : ∀ z ∈ translatedIntegerBox sourceLo sourceN, + ∀ t ∈ translatedIntegerBox paramLo paramN, + physicalBoxClassify lo N P (smoothAffineSample (fun j => a j + (D : ℤ) * t j) z) = some c) + {etaParam etaSite : ℝ} (hparam : 0 ≤ etaParam) (hsite : 0 ≤ etaSite) + (hcloseParam : ProductMarginalsClose (primeCoordinateReference (σ := J) q) + (residuePrimeCoordinateDensity paramLo paramN 1 (fun _ => 0) paramHne q (fun _ => 1)) etaParam b) + (hcloseSite : ProductMarginalsClose (primeCoordinateReference (σ := I) q) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hpos c) + q (fun _ => 1)) etaSite b) : + |(𝔼 z : IntegerResidueBox sourceLo (fun i => sourceLo i + sourceN i) (fun _ => 1) (fun _ => 0), + w (fun i => (z i).val) * + (𝔼 t : IntegerResidueBox paramLo (fun j => paramLo j + paramN j) (fun _ => 1) (fun _ => 0), + physicalBoxTruncation lo N P hpos q b f + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) - + productTruncatedPairing (affinePeriodProductCoupling (σ := I) q D a) (lowDegreeCoordinateSets ι b) + (residuePrimeCoordinateDensity sourceLo sourceN 1 (fun _ => 0) sourceHne q w) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hpos c) q f)| ≤ + etaParam * residueTruncationCap ι b etaSite := by + have he (z : IntegerResidueBox sourceLo (fun i => sourceLo i + sourceN i) (fun _ => 1) (fun _ => 0)) + (t : IntegerResidueBox paramLo (fun j => paramLo j + paramN j) (fun _ => 1) (fun _ => 0)) : + physicalBoxTruncation lo N P hpos q b f + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)) = + residuePhysicalTruncation (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hpos c) q b f + (smoothAffineSample (fun j => a j + (D : ℤ) * (t j).val) (fun i => (z i).val)) := by + apply physicalBoxTruncation_of_classify_some + apply hretained + · exact (mem_translatedIntegerBox _ _ _).mpr + (fun i => Finset.mem_Ico.mp (Finset.mem_filter.mp (z i).property).1) + · exact (mem_translatedIntegerBox _ _ _).mpr + (fun j => Finset.mem_Ico.mp (Finset.mem_filter.mp (t j).property).1) + simp_rw [he] + exact residueAffineTruncation_comparison q sourceLo sourceN sourceHne paramLo paramN paramHne + (fun i => intervalCellLower (lo i) (P i) (c i)) (fun i => (P i).length (c i)) + (physicalBoxCell_nonempty lo N P hpos c) D a b w f hw + (fun x hx => hf x (physicalBoxCell_subset lo N P hstep hpos c hx)) + hparam hsite hcloseParam hcloseSite + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RetainedResidueModelLaws.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedResidueModelLaws.lean new file mode 100644 index 0000000000000000000000000000000000000000..71bc133e58396489ebe054eb4894ed4a5e0f4409 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedResidueModelLaws.lean @@ -0,0 +1,140 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativeRetainedCubeSource + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +noncomputable def retainedCubeResidueModel {q M : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (hn : ∀ i, 0 < n i) (hnM : ∀ i, n i ≤ M) (w : (Option (Fin q) → ℝ) → ℝ) + (B T η : ℝ≥0) (hη : 0 < η) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hcut : scalarCubeNormalizationThreshold (Fin q) M (B / η) (T / η) ≤ s.length) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => translatedCubeWeight s.length s.root w (s.coordinates x)) η) : + SmoothCubeSlice q M (B / (η / 2)) (T / (η / 2)) := by + apply retainedSmoothCubeSlice s.length s.root n (shiftScalarCubeResidues s.root n r.val) + hn hnM w B T η hη hw hLip hcut + have hres := shiftScalarCubeResidues_neg_cancel (-s.root) n r.val + simp only [neg_neg] at hres + rw [hres] + exact s.retained_refineResidues_mean_ge n hdvd r (translatedCubeWeight s.length s.root w) η hr + +theorem retainedCubeResidueModel_finiteSlice {q M : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (hn : ∀ i, 0 < n i) (hnM : ∀ i, n i ≤ M) (w : (Option (Fin q) → ℝ) → ℝ) + (B T η : ℝ≥0) (hη : 0 < η) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hcut : scalarCubeNormalizationThreshold (Fin q) M (B / η) (T / η) ≤ s.length) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => translatedCubeWeight s.length s.root w (s.coordinates x)) η) : + (retainedCubeResidueModel s n hdvd r hn hnM w B T η hη hw hLip hcut hr).finiteSlice = + s.refineResidues n r := by + change (⟨s.length, s.root, n, + shiftScalarCubeResidues (-s.root) n (shiftScalarCubeResidues s.root n r.val)⟩ : FiniteCubeSlice q) = _ + have hres := shiftScalarCubeResidues_neg_cancel (-s.root) n r.val + simp only [neg_neg] at hres + rw [hres] + rfl + +noncomputable def retainedCoefficientResidueModel {M : ℕ} (s : FiniteCoefficientSlice) + [Nonempty s.Domain] (n : ℕ) (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) + (hn : 0 < n) (hnM : n ≤ M) (w : (Option Empty → ℝ) → ℝ) + (B T η : ℝ≥0) (hη : 0 < η) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hcut : scalarCubeNormalizationThreshold Empty M (B / η) (T / η) ≤ s.length) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => w (fun _ => (x.val : ℝ) / s.length)) η) : + SmoothCoefficientSlice M (B / (η / 2)) (T / (η / 2)) := by + apply retainedSmoothCoefficientSlice s.length n r.val hn hnM w B T η hη hw hLip hcut + refine FiniteProbabilityWeights.retained_embedding_mean_ge + (s.residueLabelMap n) (fun x => w (fun _ => (x.val : ℝ) / s.length)) η r + (s.refineResiduesEmbedding n hdvd r) hr ?_ (s.refineResidues_mass_pos n hdvd r) + apply (s.refineResiduesEmbedding_range n hdvd r).trans + ext x + simp only [Finset.mem_filter] + +theorem retainedCoefficientResidueModel_finiteSlice {M : ℕ} (s : FiniteCoefficientSlice) + [Nonempty s.Domain] (n : ℕ) (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) + (hn : 0 < n) (hnM : n ≤ M) (w : (Option Empty → ℝ) → ℝ) + (B T η : ℝ≥0) (hη : 0 < η) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hcut : scalarCubeNormalizationThreshold Empty M (B / η) (T / η) ≤ s.length) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => w (fun _ => (x.val : ℝ) / s.length)) η) : + (retainedCoefficientResidueModel s n hdvd r hn hnM w B T η hη hw hLip hcut hr).finiteSlice + s.offset s.stride = s.refineResidues n r := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators NNReal Classical + +theorem integral_pos_of_normalized_div {X : Type*} [MeasurableSpace X] (μ : Measure X) + (w : X → ℝ) (hw : ∀ x, 0 ≤ w x) + (hnorm : (∫ x, w x / ∫ y, w y ∂μ ∂μ) = 1) : 0 < ∫ x, w x ∂μ := by + apply lt_of_le_of_ne (integral_nonneg hw) + intro hz + rw [← hz] at hnorm + simp at hnorm + +theorem retainedCubeResidueModel_law {q M : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (hn : ∀ i, 0 < n i) (hnM : ∀ i, n i ≤ M) (w : (Option (Fin q) → ℝ) → ℝ) + (B T η : ℝ≥0) (hη : 0 < η) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hcut : scalarCubeNormalizationThreshold (Fin q) M (B / η) (T / η) ≤ s.length) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => translatedCubeWeight s.length s.root w (s.coordinates x)) η) : + let t := retainedCubeResidueModel s n hdvd r hn hnM w B T η hη hw hLip hcut hr + let v : t.Domain → ℝ := fun x => translatedCubeWeight s.length s.root w (t.finiteSlice.coordinates x) + ∀ hv : 0 < ∑ x, v x, ∃ ht : 0 < ∑ x, t.sliceWeight x, + t.law ht = FiniteProbabilityWeights.ofPositiveWeights v (fun _ => (hw _).1) hv := by + dsimp only + intro hv + let t := retainedCubeResidueModel s n hdvd r hn hnM w B T η hη hw hLip hcut hr + have hI : 0 < ∫ x, w x ∂scalarCubeMeasure (Fin q) := + integral_pos_of_normalized_div _ w (fun x => (hw x).1) t.weight_integral + have ht : 0 < ∑ x, t.sliceWeight x := by + change 0 < ∑ x : t.Domain, + translatedCubeWeight s.length s.root w (t.finiteSlice.coordinates x) / + ∫ y, w y ∂scalarCubeMeasure (Fin q) + rw [← Finset.sum_div] + exact div_pos hv hI + refine ⟨ht, ?_⟩ + exact FiniteProbabilityWeights.ofPositiveWeights_div _ _ hv hI + +theorem retainedCoefficientResidueModel_law {M : ℕ} (s : FiniteCoefficientSlice) + [Nonempty s.Domain] (n : ℕ) (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) + (hn : 0 < n) (hnM : n ≤ M) (w : (Option Empty → ℝ) → ℝ) + (B T η : ℝ≥0) (hη : 0 < η) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hcut : scalarCubeNormalizationThreshold Empty M (B / η) (T / η) ≤ s.length) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => w (fun _ => (x.val : ℝ) / s.length)) η) : + let t := retainedCoefficientResidueModel s n hdvd r hn hnM w B T η hη hw hLip hcut hr + let v : t.Domain → ℝ := fun x => w (fun _ => (x.val : ℝ) / s.length) + ∀ hv : 0 < ∑ x, v x, ∃ ht : 0 < ∑ x, t.sliceWeight x, + t.law ht = FiniteProbabilityWeights.ofPositiveWeights v (fun _ => (hw _).1) hv := by + dsimp only + intro hv + let t := retainedCoefficientResidueModel s n hdvd r hn hnM w B T η hη hw hLip hcut hr + have hI : 0 < ∫ x, w x ∂scalarCubeMeasure Empty := + integral_pos_of_normalized_div _ w (fun x => (hw x).1) t.weight_integral + have ht : 0 < ∑ x, t.sliceWeight x := by + change 0 < ∑ x : t.Domain, + w (fun _ => (x.val : ℝ) / s.length) / ∫ y, w y ∂scalarCubeMeasure Empty + rw [← Finset.sum_div] + exact div_pos hv hI + refine ⟨ht, ?_⟩ + exact FiniteProbabilityWeights.ofPositiveWeights_div _ _ hv hI + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RetainedResidueSources.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedResidueSources.lean new file mode 100644 index 0000000000000000000000000000000000000000..52533d406d9da1ea94c8521acf21441addb69c08 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RetainedResidueSources.lean @@ -0,0 +1,109 @@ +import OAI.Combinatorics.Progressions.Estimates.RetainedCoefficientSlice +import OAI.Combinatorics.Progressions.Probability.RefinedSliceLaws + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +noncomputable def retainedCubeSliceOfFinite {q M : ℕ} (s : FiniteCubeSlice q) + (hm : ∀ i, 0 < s.modulus i) (hmM : ∀ i, s.modulus i ≤ M) + (w : (Option (Fin q) → ℝ) → ℝ) (B T η : ℝ≥0) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hmean : (η : ℝ) ≤ 𝔼 x : s.Domain, translatedCubeWeight s.length s.root w (s.coordinates x)) : + RetainedCubeSlice q M B T η := by + refine { + length := s.length, root := s.root, modulus := s.modulus + residue := shiftScalarCubeResidues s.root s.modulus s.residue + modulus_pos := hm, modulus_le := hmM + weight := w, weight_range := hw, weight_lipschitz := hLip, mean_lower := ?_ } + have hres := shiftScalarCubeResidues_neg_cancel (-s.root) s.modulus s.residue + simp only [neg_neg] at hres + rw [hres] + exact hmean + +theorem retainedCubeSliceOfFinite_finiteSlice {q M : ℕ} (s : FiniteCubeSlice q) + (hm : ∀ i, 0 < s.modulus i) (hmM : ∀ i, s.modulus i ≤ M) + (w : (Option (Fin q) → ℝ) → ℝ) (B T η : ℝ≥0) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hmean : (η : ℝ) ≤ 𝔼 x : s.Domain, translatedCubeWeight s.length s.root w (s.coordinates x)) : + (retainedCubeSliceOfFinite s hm hmM w B T η hw hLip hmean).finiteSlice = s := by + change (⟨s.length, s.root, s.modulus, + shiftScalarCubeResidues (-s.root) s.modulus + (shiftScalarCubeResidues s.root s.modulus s.residue)⟩ : FiniteCubeSlice q) = s + have hres := shiftScalarCubeResidues_neg_cancel (-s.root) s.modulus s.residue + simp only [neg_neg] at hres + rw [hres] + +noncomputable def retainedCubeSliceOfResidue {q M : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (hn : ∀ i, 0 < n i) (hnM : ∀ i, n i ≤ M) (w : (Option (Fin q) → ℝ) → ℝ) + (B T η : ℝ≥0) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => translatedCubeWeight s.length s.root w (s.coordinates x)) η) : + RetainedCubeSlice q M B T η := + retainedCubeSliceOfFinite (s.refineResidues n r) hn hnM w B T η hw hLip + (s.retained_refineResidues_mean_ge n hdvd r (translatedCubeWeight s.length s.root w) η hr) + +theorem retainedCubeSliceOfResidue_finiteSlice {q M : ℕ} (s : FiniteCubeSlice q) [Nonempty s.Domain] + (n : Option (Fin q) → ℕ) (hdvd : ∀ i, s.modulus i ∣ n i) (r : s.ResidueLabel n) + (hn : ∀ i, 0 < n i) (hnM : ∀ i, n i ≤ M) (w : (Option (Fin q) → ℝ) → ℝ) + (B T η : ℝ≥0) (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => translatedCubeWeight s.length s.root w (s.coordinates x)) η) : + (retainedCubeSliceOfResidue s n hdvd r hn hnM w B T η hw hLip hr).finiteSlice = + s.refineResidues n r := + retainedCubeSliceOfFinite_finiteSlice _ _ _ _ _ _ _ _ _ _ + +noncomputable def retainedCoefficientSliceOfFinite {M : ℕ} (s : FiniteCoefficientSlice) + (hm : 0 < s.modulus) (hmM : s.modulus ≤ M) (w : (Option Empty → ℝ) → ℝ) (B T η : ℝ≥0) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hmean : (η : ℝ) ≤ 𝔼 x : s.Domain, w (fun _ => (x.val : ℝ) / s.length)) : + RetainedCoefficientSlice M B T η where + length := s.length + modulus := s.modulus + residue := s.residue + modulus_pos := hm + modulus_le := hmM + weight := w + weight_range := hw + weight_lipschitz := hLip + mean_lower := hmean + +theorem retainedCoefficientSliceOfFinite_finiteSlice {M : ℕ} (s : FiniteCoefficientSlice) + (hm : 0 < s.modulus) (hmM : s.modulus ≤ M) (w : (Option Empty → ℝ) → ℝ) (B T η : ℝ≥0) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hmean : (η : ℝ) ≤ 𝔼 x : s.Domain, w (fun _ => (x.val : ℝ) / s.length)) : + (retainedCoefficientSliceOfFinite s hm hmM w B T η hw hLip hmean).finiteSlice s.offset s.stride = s := rfl + +noncomputable def retainedCoefficientSliceOfResidue {M : ℕ} (s : FiniteCoefficientSlice) [Nonempty s.Domain] + (n : ℕ) (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) (hn : 0 < n) (hnM : n ≤ M) + (w : (Option Empty → ℝ) → ℝ) (B T η : ℝ≥0) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => w (fun _ => (x.val : ℝ) / s.length)) η) : RetainedCoefficientSlice M B T η := by + apply retainedCoefficientSliceOfFinite (s.refineResidues n r) hn hnM w B T η hw hLip + refine FiniteProbabilityWeights.retained_embedding_mean_ge + (s.residueLabelMap n) (fun x => w (fun _ => (x.val : ℝ) / s.length)) η r + (s.refineResiduesEmbedding n hdvd r) hr ?_ (s.refineResidues_mass_pos n hdvd r) + apply (s.refineResiduesEmbedding_range n hdvd r).trans + ext x + simp only [Finset.mem_filter] + +theorem retainedCoefficientSliceOfResidue_finiteSlice {M : ℕ} (s : FiniteCoefficientSlice) [Nonempty s.Domain] + (n : ℕ) (hdvd : s.modulus ∣ n) (r : s.ResidueLabel n) (hn : 0 < n) (hnM : n ≤ M) + (w : (Option Empty → ℝ) → ℝ) (B T η : ℝ≥0) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + (hr : r ∉ (FiniteProbabilityWeights.uniform s.Domain).lowWeightFibers (s.residueLabelMap n) + (fun x => w (fun _ => (x.val : ℝ) / s.length)) η) : + (retainedCoefficientSliceOfResidue s n hdvd r hn hnM w B T η hw hLip hr).finiteSlice s.offset s.stride = + s.refineResidues n r := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/RoundedAffineLifts.lean b/lean/OAI/Combinatorics/Progressions/Lattices/RoundedAffineLifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..c52d3b95ae9fcc51d5c8d3e231dade579b6e7aad --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/RoundedAffineLifts.lean @@ -0,0 +1,345 @@ +import Mathlib.Algebra.Order.Round +import OAI.Combinatorics.Progressions.Estimates.QuantitativeNoninjectivity +import OAI.Combinatorics.Progressions.Polynomial.AffinePolynomialLiftData +import OAI.Combinatorics.Progressions.Polynomial.AllocatedPolynomialQuarter + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators + +def jointIntegerFrame {K I : Type*} + (z : (I → ℤ) × (Option K × I → ℤ)) : Option K → I → ℤ := + fun k i => match k with + | none => z.1 i + z.2 (none,i) + | some k => z.2 (some k,i) + +theorem integerAffineMap_jointIntegerFrame {K I : Type*} [Fintype K] + (z : (I → ℤ) × (Option K × I → ℤ)) (root : K → ℤ) : + integerAffineMap (fun i k => jointIntegerFrame z (some k) i) (jointIntegerFrame z none) root = + jointIntegerPhysicalSite root z := by + funext i + simp only [integerAffineMap, jointIntegerFrame, jointIntegerPhysicalSite, + integerPhysicalSite, Pi.add_apply] + rw [add_assoc] + congr 2 + apply Finset.sum_congr rfl + intro k _ + exact mul_comm _ _ + +end Erdos3.BooleanCubeKernel + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators + +theorem AffinePolynomialLiftProperties.joint_frame {K V : Type*} [Fintype K] + {m : ℕ} {J : Fin m → Type*} + {p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)} {center : ∀ j, J j → ℝ} + {T : K → ℝ} (a : V → ℤ) (z : Option K × V → ℤ) + {Y : ∀ j, J j → MvPolynomial K ℝ} {β : ∀ j, J j → MvPolynomial K ℤ} + (h : AffinePolynomialLiftProperties (fun j => translate (fun v => (a v : ℝ)) (p j)) + center (fun k v => (z (k,v) : ℝ)) T Y β) : + AffinePolynomialLiftProperties p center (fun k v => (jointIntegerFrame (a,z) k v : ℝ)) T Y β := by + obtain ⟨hY, hβ, hcoeff, hbox, heq⟩ := h + refine ⟨hY, hβ, hcoeff, hbox, ?_⟩ + intro j i x + have he := heq j i x + rw [eval_translate] at he + have hx : + (fun v => (z (none,v) : ℝ) + ∑ k, (z (some k,v) : ℝ) * x k + (a v : ℝ)) = + (fun v => (jointIntegerFrame (a,z) none v : ℝ) + + ∑ k, (jointIntegerFrame (a,z) (some k) v : ℝ) * x k) := by + funext v + simp only [jointIntegerFrame, Int.cast_add] + ring + rwa [hx] at he + +theorem HasAffinePolynomialLifts.joint_frame {K V : Type*} [Fintype K] + {m : ℕ} {J : Fin m → Type*} + {p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)} {center : ∀ j, J j → ℝ} + {T : K → ℝ} (a : V → ℤ) (z : Option K × V → ℤ) + (h : HasAffinePolynomialLifts (fun j => translate (fun v => (a v : ℝ)) (p j)) + center (fun k v => (z (k,v) : ℝ)) T) : + HasAffinePolynomialLifts p center (fun k v => (jointIntegerFrame (a,z) k v : ℝ)) T := by + obtain ⟨Y, β, hYβ⟩ := h + exact ⟨Y, β, hYβ.joint_frame a z⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule + +variable {m : ℕ} {G V : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (p j) d ∈ U j) (center : ∀ j, U j) + +noncomputable def allocatedAffineDensity + (frame : Option (LayerSamplerVariables G I n B) → V → ℝ) : ℝ := + allocatedCoefficientDensity B U b hb o hR hσ S (centeredAffineCoefficientTorus U p hm center frame) + +theorem allocatedAffineDensity_lifts + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + (hp : ∀ j, DegreeLE (1 : V → ℕ) (j.val + 1) (p j)) + (frame : Option (LayerSamplerVariables G I n B) → V → ℝ) + (hframe : allocatedAffineDensity B U b hb o hR hσ S p hm center frame ≠ 0) : + HasAffinePolynomialLifts p (fun j => (center j).val) frame (layerSamplerBox B U b S) := by + obtain ⟨Y, β, heq, hY, hβ, hcoeff, hbox⟩ := + allocatedCoefficientDensity_polynomial_decomposition B U b hb o hR hσ S hσ1 C hC hchart hsmall + (centeredAffineCoefficientArray U p hm center frame) hframe + refine ⟨Y, β, hY, hβ, hcoeff, hbox, ?_⟩ + intro j i x + rw [← coefficientRowPolynomial_centered_affine_eval U p hm hp center frame j i x, heq j i, map_add] + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +theorem allocatedAffineDensity_nonneg (frame : Option (LayerSamplerVariables G I n B) → V → ℝ) : + 0 ≤ allocatedAffineDensity B U b hb o hR hσ S p hm center frame := + canonicalCoefficientDensity_nonneg U b hb o (allocatedLayerCenters B U b S) + (allocatedLayerWidths B U b S) (allocatedLayerIntegerPMFs B U b hR hσ S) + (allocatedLayerWidths_pos B U b hR hσ S) _ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory + +variable {m : ℕ} {G V : Type*} [Fintype G] [Fintype V] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (p j) d ∈ U j) (center : ∀ j, U j) + +noncomputable def allocatedAffineSpatialDensity + (frame : Option (LayerSamplerVariables G I n B) × V → ℤ) : ℝ := + allocatedAffineDensity B U b hb o hR hσ S p hm center (fun k v => (frame (k, v) : ℝ)) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +omit [Fintype V] in +theorem allocatedAffineSpatialDensity_nonneg (frame : Option (LayerSamplerVariables G I n B) × V → ℤ) : + 0 ≤ allocatedAffineSpatialDensity B U b hb o hR hσ S p hm center frame := + allocatedAffineDensity_nonneg B U b hb o hR hσ S p hm center _ + +variable (modulus : V → ℕ) +variable (Γ : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) V modulus)) +variable (width : Option (LayerSamplerVariables G I n B) × V → ℝ) (hwidth : ∀ z, 0 < width z) +variable (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus Γ width x) +variable (hD : 0 < selectedResidueDensityMass modulus Γ width + (allocatedAffineSpatialDensity B U b hb o hR hσ S p hm center)) + +noncomputable def allocatedAffineSpatialPMF : PMF (Option (LayerSamplerVariables G I n B) × V → ℤ) := + selectedResidueDensityPMF modulus Γ width hwidth hZ + (allocatedAffineSpatialDensity B U b hb o hR hσ S p hm center) + (allocatedAffineSpatialDensity_nonneg B U b hb o hR hσ S p hm center) hD + +theorem allocatedAffineSpatialPMF_toReal (frame : Option (LayerSamplerVariables G I n B) × V → ℤ) : + (allocatedAffineSpatialPMF B U b hb o hR hσ S p hm center modulus Γ width hwidth hZ hD frame).toReal = + (selectedResidueSmoothPMF modulus Γ width hwidth hZ frame).toReal * + allocatedAffineSpatialDensity B U b hb o hR hσ S p hm center frame / + selectedResidueDensityMass modulus Γ width + (allocatedAffineSpatialDensity B U b hb o hR hσ S p hm center) := + selectedResidueDensityPMF_toReal modulus Γ width hwidth hZ _ _ hD frame + +variable (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hsmall : ∀ j, C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) +variable (hp : ∀ j, DegreeLE (1 : V → ℕ) (j.val + 1) (p j)) + +include hσ1 C hC hchart hsmall hp + +theorem allocatedAffineSpatialPMF_support_lifts + (frame : Option (LayerSamplerVariables G I n B) × V → ℤ) + (hframe : frame ∈ (allocatedAffineSpatialPMF B U b hb o hR hσ S p hm center + modulus Γ width hwidth hZ hD).support) : + HasAffinePolynomialLifts p (fun j => (center j).val) + (fun k v => (frame (k, v) : ℝ)) (layerSamplerBox B U b S) := by + have hn : (allocatedAffineSpatialPMF B U b hb o hR hσ S p hm center + modulus Γ width hwidth hZ hD frame).toReal ≠ 0 := + (ENNReal.toReal_pos ((PMF.mem_support_iff _ _).mp hframe) (PMF.apply_ne_top _ _)).ne' + have hd : allocatedAffineSpatialDensity B U b hb o hR hσ S p hm center frame ≠ 0 := by + intro hz + apply hn + rw [allocatedAffineSpatialPMF_toReal, hz, mul_zero, zero_div] + exact allocatedAffineDensity_lifts B U b hb o hR hσ S p hm center hσ1 C hC hchart hsmall hp _ hd + +theorem allocatedAffineSpatialPMF_ae_lifts : + ∀ᵐ frame ∂(allocatedAffineSpatialPMF B U b hb o hR hσ S p hm center + modulus Γ width hwidth hZ hD).toMeasure, + HasAffinePolynomialLifts p (fun j => (center j).val) + (fun k v => (frame (k, v) : ℝ)) (layerSamplerBox B U b S) := by + apply (pmf_support_ae _).mono + intro frame hframe + exact allocatedAffineSpatialPMF_support_lifts B U b hb o hR hσ S p hm center + modulus Γ width hwidth hZ hD hσ1 C hC hchart hsmall hp frame hframe + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel + +def HasQuarterAffinePolynomialLifts {K V : Type*} [Fintype K] {m : ℕ} {J : Fin m → Type*} + (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) (center : ∀ j, J j → ℝ) + (frame : Option K → V → ℝ) (T : K → ℝ) : Prop := + ∃ Y β, AffinePolynomialLiftProperties p center frame T Y β ∧ + ∀ j (x : K → ℝ), (∀ v, |x v| ≤ T v) → ∀ i, |MvPolynomial.eval x (Y j i)| < 1/4 + +theorem HasQuarterAffinePolynomialLifts.to_hasAffinePolynomialLifts + {K V : Type*} [Fintype K] {m : ℕ} {J : Fin m → Type*} + {p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)} {center : ∀ j, J j → ℝ} + {frame : Option K → V → ℝ} {T : K → ℝ} + (h : HasQuarterAffinePolynomialLifts p center frame T) : + HasAffinePolynomialLifts p center frame T := by + obtain ⟨Y, β, hYβ, _⟩ := h + exact ⟨Y, β, hYβ⟩ + +theorem HasQuarterAffinePolynomialLifts.joint_frame {K V : Type*} [Fintype K] + {m : ℕ} {J : Fin m → Type*} + {p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)} {center : ∀ j, J j → ℝ} + {T : K → ℝ} (a : V → ℤ) (z : Option K × V → ℤ) + (h : HasQuarterAffinePolynomialLifts (fun j => translate (fun v => (a v : ℝ)) (p j)) + center (fun k v => (z (k,v) : ℝ)) T) : + HasQuarterAffinePolynomialLifts p center (fun k v => (jointIntegerFrame (a,z) k v : ℝ)) T := by + obtain ⟨Y, β, hYβ, hquarter⟩ := h + exact ⟨Y, β, hYβ.joint_frame a z, hquarter⟩ + +variable {m : ℕ} {G V : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (p j) d ∈ U j) (center : ∀ j, U j) + +theorem allocatedAffineDensity_quarter_lifts + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + (hp : ∀ j, DegreeLE (1 : V → ℕ) (j.val + 1) (p j)) + (frame : Option (LayerSamplerVariables G I n B) → V → ℝ) + (hframe : allocatedAffineDensity B U b hb o hR hσ S p hm center frame ≠ 0) : + HasQuarterAffinePolynomialLifts p (fun j => (center j).val) frame (layerSamplerBox B U b S) := by + obtain ⟨Y, β, heq, hY, hβ, hcoeff, hquarter⟩ := + allocatedCoefficientDensity_quarter_decomposition B U b hR hσ S hσ1 o C hC hchart hsmall hb + (centeredAffineCoefficientArray U p hm center frame) hframe + refine ⟨Y, β, ⟨hY, hβ, hcoeff, ?_, ?_⟩, hquarter⟩ + · intro j x hx i + exact (hquarter j x hx i).trans (by norm_num) + · intro j i x + rw [← coefficientRowPolynomial_centered_affine_eval U p hm hp center frame j i x, heq j i, map_add] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel + +variable {K V : Type*} [Fintype K] {m : ℕ} {J : Fin m → Type*} + +noncomputable def roundedPolynomialIntegerLift + (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) (center : ∀ j, J j → ℝ) + (u : V → ℤ) (j : Fin m) (i : J j) : ℤ := + round (eval (fun v => (u v : ℝ)) (p j) i - center j i) + +noncomputable def roundedPolynomialSmallLift + (p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)) (center : ∀ j, J j → ℝ) + (u : V → ℤ) (j : Fin m) (i : J j) : ℝ := + eval (fun v => (u v : ℝ)) (p j) i - center j i - roundedPolynomialIntegerLift p center u j i + +theorem AffinePolynomialLiftProperties.rounded_evaluation + {p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)} {center : ∀ j, J j → ℝ} + {frame : Option K → V → ℤ} {T : K → ℝ} + {Y : ∀ j, J j → MvPolynomial K ℝ} {β : ∀ j, J j → MvPolynomial K ℤ} + (h : AffinePolynomialLiftProperties p center (fun k v => (frame k v : ℝ)) T Y β) + (x : K → ℤ) (hx : ∀ k, |(x k : ℝ)| ≤ T k) (j : Fin m) : + let u := integerAffineMap (fun v k => frame (some k) v) (frame none) x + (fun i => MvPolynomial.eval (fun k => (x k : ℝ)) (Y j i)) = roundedPolynomialSmallLift p center u j ∧ + (fun i => MvPolynomial.eval x (β j i)) = roundedPolynomialIntegerLift p center u j := by + let u := integerAffineMap (fun v k => frame (some k) v) (frame none) x + have he (i : J j) := h.integer_evaluation j i x + have hr (i : J j) : roundedPolynomialIntegerLift p center u j i = MvPolynomial.eval x (β j i) := by + apply round_eq_iff.mpr + have hy := abs_lt.mp (h.2.2.2.1 j (fun k => (x k : ℝ)) hx i) + constructor <;> linarith [he i] + constructor + · funext i + change MvPolynomial.eval (fun k => (x k : ℝ)) (Y j i) = + eval (fun v => (u v : ℝ)) (p j) i - center j i - roundedPolynomialIntegerLift p center u j i + rw [hr i] + linarith [he i] + · exact funext (fun i => (hr i).symm) + +theorem HasQuarterAffinePolynomialLifts.rounded_joint + {p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)} {center : ∀ j, J j → ℝ} + (z : (V → ℤ) × (Option K × V → ℤ)) {T : K → ℝ} + (h : HasQuarterAffinePolynomialLifts p center (fun k v => (jointIntegerFrame z k v : ℝ)) T) : + ∃ Y β, AffinePolynomialLiftProperties p center (fun k v => (jointIntegerFrame z k v : ℝ)) T Y β ∧ + (∀ j (x : K → ℝ), (∀ k, |x k| ≤ T k) → ∀ i, |MvPolynomial.eval x (Y j i)| < 1/4) ∧ + ∀ x : K → ℤ, (∀ k, |(x k : ℝ)| ≤ T k) → ∀ j, + (fun i => MvPolynomial.eval (fun k => (x k : ℝ)) (Y j i)) = + roundedPolynomialSmallLift p center (jointIntegerPhysicalSite x z) j ∧ + (fun i => MvPolynomial.eval x (β j i)) = + roundedPolynomialIntegerLift p center (jointIntegerPhysicalSite x z) j := by + obtain ⟨Y, β, hYβ, hquarter⟩ := h + refine ⟨Y, β, hYβ, hquarter, ?_⟩ + intro x hx j + simpa only [integerAffineMap_jointIntegerFrame] using hYβ.rounded_evaluation x hx j + +theorem HasQuarterAffinePolynomialLifts.rounded_joint_residue + {p : ∀ j, VectorPolynomial V ℝ (J j → ℝ)} {center : ∀ j, J j → ℝ} + (z : (V → ℤ) × (Option K × V → ℤ)) {T : K → ℝ} + (h : HasQuarterAffinePolynomialLifts p center (fun k v => (jointIntegerFrame z k v : ℝ)) T) + (q : ℕ) (x x' : K → ℤ) (hx : ∀ k, |(x k : ℝ)| ≤ T k) (hx' : ∀ k, |(x' k : ℝ)| ≤ T k) + (hmod : integerResidueMap K q x = integerResidueMap K q x') (j : Fin m) (i : J j) : + (roundedPolynomialIntegerLift p center (jointIntegerPhysicalSite x z) j i : ZMod q) = + (roundedPolynomialIntegerLift p center (jointIntegerPhysicalSite x' z) j i : ZMod q) := by + obtain ⟨Y, β, _, _, heval⟩ := h.rounded_joint z + rw [← congrFun (heval x hx j).2 i, ← congrFun (heval x' hx' j).2 i] + exact integerPolynomial_eval_congr (β j i) q hmod + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ScalarCubeLatticeGeometry.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarCubeLatticeGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0a9d96fb94fd3902e48e5f99d78dcd3b2ca09ad --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarCubeLatticeGeometry.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.Progressions.Estimates.ScalarCubeFaceSlab + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem scalarCubeValue_formula {I : Type*} [Fintype I] [DecidableEq I] + (x : Option I → ℝ) (t : Finset I) : + scalarCubeValue x t = x none + ∑ i ∈ t, x (some i) := by + simp [scalarCubeValue, Fintype.sum_option, booleanFeature, ite_mul] + +theorem scalarCubeValue_sub_bound {I : Type*} [Fintype I] [DecidableEq I] + (x y : Option I → ℝ) {δ : ℝ} (hδ : 0 ≤ δ) (he : ‖x-y‖ ≤ δ) (t : Finset I) : + |scalarCubeValue x t - scalarCubeValue y t| ≤ (Fintype.card I + 1 : ℝ)*δ := by + have hi (i : Option I) : |x i-y i| ≤ δ := (norm_le_pi_norm (x-y) i).trans he + have hsum : |∑ i ∈ t, (x (some i)-y (some i))| ≤ (t.card : ℝ)*δ := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + simpa only [Finset.sum_const, nsmul_eq_mul] using Finset.sum_le_sum (fun i (_ : i ∈ t) => hi (some i)) + have hcard : (t.card : ℝ) ≤ Fintype.card I := by exact_mod_cast t.card_le_univ + have hid : scalarCubeValue x t - scalarCubeValue y t = + (x none-y none) + ∑ i ∈ t, (x (some i)-y (some i)) := by + simp only [scalarCubeValue_formula, Finset.sum_sub_distrib] + ring + rw [hid] + exact (abs_add_le _ _).trans ((add_le_add (hi none) hsum).trans (by nlinarith)) + +theorem scalarCubeIndicator_disagreement {I : Type*} [Fintype I] [DecidableEq I] + (x y : Option I → ℝ) {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (he : ‖y-x‖ ≤ δ) + (hne : scalarCubeIndicator I y ≠ scalarCubeIndicator I x) : + ∃ i : Bool × Finset I, x ∈ scalarCubeFaceSlab i ((Fintype.card I + 1 : ℝ)*δ) := by + have hv (t : Finset I) := scalarCubeValue_sub_bound y x hδ he t + have hxnorm (hy : y ∈ halfOpenScalarCubeDomain I) : ‖x‖ ≤ 2 := by + have ht : ‖x‖ ≤ ‖y-x‖ + ‖y‖ := by + calc + ‖x‖ = ‖-(y-x)+y‖ := by congr 1; abel + _ ≤ ‖-(y-x)‖ + ‖y‖ := norm_add_le _ _ + _ = _ := by rw [norm_neg] + linarith [halfOpenScalarCubeDomain_norm_le hy] + by_cases hx : x ∈ halfOpenScalarCubeDomain I + · have hy : y ∉ halfOpenScalarCubeDomain I := by + intro hy + exact hne (by simp only [scalarCubeIndicator, hx, hy, ite_true]) + obtain ⟨t, ht⟩ := not_forall.mp hy + have hbox : x ∈ Metric.closedBall 0 2 := by + simpa only [Metric.mem_closedBall, dist_zero_right] using + (halfOpenScalarCubeDomain_norm_le hx).trans (by norm_num : (1 : ℝ) ≤ 2) + have hxval := hx t + have hdiff := abs_le.mp (hv t) + by_cases hlo : scalarCubeValue y t < 0 + · refine ⟨(false,t), hbox, ?_⟩ + change |scalarCubeValue x t| ≤ _ + rw [abs_of_nonneg hxval.1] + linarith [hxval.1, hxval.2, hdiff.1, hdiff.2] + · have hhi : 1 ≤ scalarCubeValue y t := by + by_contra! hn + exact ht ⟨le_of_not_gt hlo, hn⟩ + refine ⟨(true,t), hbox, ?_⟩ + change |1-scalarCubeValue x t| ≤ _ + rw [abs_of_nonneg (by linarith [hxval.2])] + linarith [hxval.1, hxval.2, hdiff.1, hdiff.2] + · have hy : y ∈ halfOpenScalarCubeDomain I := by + by_contra hy + exact hne (by simp only [scalarCubeIndicator, hx, hy, ite_false]) + obtain ⟨t, ht⟩ := not_forall.mp hx + have hbox : x ∈ Metric.closedBall 0 2 := by + simpa only [Metric.mem_closedBall, dist_zero_right] using hxnorm hy + have hyval := hy t + have hdiff := abs_le.mp (hv t) + by_cases hlo : scalarCubeValue x t < 0 + · refine ⟨(false,t), hbox, ?_⟩ + change |scalarCubeValue x t| ≤ _ + rw [abs_of_neg hlo] + linarith [hyval.1, hyval.2, hdiff.1, hdiff.2] + · have hhi : 1 ≤ scalarCubeValue x t := by + by_contra! hn + exact ht ⟨le_of_not_gt hlo, hn⟩ + refine ⟨(true,t), hbox, ?_⟩ + change |1-scalarCubeValue x t| ≤ _ + rw [abs_of_nonpos (by linarith)] + linarith [hyval.1, hyval.2, hdiff.1, hdiff.2] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ScalarEndpointLatePrimeCommonSide.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarEndpointLatePrimeCommonSide.lean new file mode 100644 index 0000000000000000000000000000000000000000..16337bae2fc61f8c43da1083af73b1dbd9e3aa1b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarEndpointLatePrimeCommonSide.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.Progressions.Dynamics.ScalarBaseAllowancePowerBudget +import OAI.Combinatorics.Progressions.Dynamics.ScalarEndpointScalePowerBudget +import OAI.Combinatorics.Progressions.Estimates.UnconditionedCommonSideScalarRatioBounds + +namespace OAI + +section + +namespace Erdos3 +open scoped Classical BigOperators + +theorem exists_scalarEndpoint_late_prime_common_side + (n scalarE scalarC scalarF inputPower earlyExponent : ℕ) + (hn : 2 ≤ n) (hE : 2 ≤ scalarE) (hC : 2 ≤ scalarC) (_hF : 2 ≤ scalarF) + (hInput : max 1 earlyExponent ≤ inputPower) : + ∃ latePower : ℕ, 2 ≤ latePower ∧ ∃ sizePower : ℕ, 2 ≤ sizePower ∧ + ∀ {p : ℝ}, 2 ≤ p → + let b := (p + 2) ^ inputPower + let scalarInput := (b + 2) ^ scalarE + let ratio := unconditionedCommonSideScalarRatio n + let t := (8 * ((ratio * n : ℕ) + 1 : ℝ) * (scalarInput + 1) + 2) ^ scalarC + p ≤ t ∧ (p + 2) ^ earlyExponent ≤ t ∧ + (scalarInput + scalarF) ^ scalarF ≤ (p + 2) ^ sizePower ∧ + ∃ (P : Fin n → ℕ) (hprime : ∀ j, (P j).Prime) (S : ℕ), + S = unconditionedCommonSide P ∧ 0 < S ∧ + Function.Injective P ∧ (∀ i j, P i ≤ 2 ^ (n + 1) * P j) ∧ + (∀ j, Real.exp p ≤ (P j : ℝ) ∧ P j ≤ S) ∧ + (∀ j, Real.exp t ≤ (P j : ℝ) ∧ (P j : ℝ) ≤ Real.exp (t + (n : ℝ) + 2)) ∧ + (∀ j, (S : ℝ) / (P j : ℝ) ≤ Real.exp (unconditionedCommonSideExtra n)) ∧ + Real.exp t ≤ (S : ℝ) ∧ (S : ℝ) ≤ (ratio : ℝ) * Real.exp t ∧ + (S : ℝ) ≤ Real.exp ((p + 2) ^ latePower) ∧ + ∀ nX : ℕ, (nX : ℝ) ≤ p → + let : ∀ j, NeZero (P j) := fun j => ⟨(hprime j).ne_zero⟩ + unconditionedSpatialWidthCutoff ((n : ℝ) * (S : ℝ)) + (unconditionedSpatialTrimFraction nX (Real.exp (-p))) + (unconditionedCollisionWidth P (Real.exp (-p))) ≤ Real.exp ((p + 2) ^ sizePower) := by + let ratio := unconditionedCommonSideScalarRatio n + obtain ⟨A, _, hChoose⟩ := exists_unconditioned_late_prime_common_side_budget n + obtain ⟨latePower, hLate, hScale⟩ := + exists_scalarEndpointScale_power_budget n ratio scalarE scalarC inputPower earlyExponent hE hC hInput + obtain ⟨sizePower, hSize, hCutoff⟩ := + exists_scalarLatePrimeCutoff_composite_power_budget n ratio scalarE scalarC scalarF A inputPower + refine ⟨latePower, hLate, sizePower, hSize, ?_⟩ + intro p hp b scalarInput ratio' t + have hScale' := hScale p hp + change p ≤ t ∧ (p + 2) ^ earlyExponent ≤ t ∧ + (ratio' : ℝ) * Real.exp t ≤ Real.exp ((p + 2) ^ latePower) at hScale' + have hCutoff' := hCutoff p hp + change (scalarInput + scalarF) ^ scalarF ≤ (p + 2) ^ sizePower ∧ + (t + 2) ^ A ≤ (p + 2) ^ sizePower at hCutoff' + refine ⟨hScale'.1, hScale'.2.1, hCutoff'.1, ?_⟩ + obtain ⟨P, hprime, S, hinj, hcompare, hrange, hearly, hS, hSpos, hleS, + _, _, hWidth⟩ := hChoose p t hp hScale'.1 + have hSeq : S = unconditionedCommonSide P := hS + have ht0 : 0 ≤ t := (by linarith : 0 ≤ p).trans hScale'.1 + have hSup : (S : ℝ) ≤ (ratio' : ℝ) * Real.exp t := by + rw [hSeq] + exact unconditionedCommonSide_scalar_bound_of_range P ht0 (fun j => (hrange j).2) + have hSlo : Real.exp t ≤ (S : ℝ) := + (hrange (⟨0, by omega⟩ : Fin n)).1.trans + (Nat.cast_le.mpr (hleS (⟨0, by omega⟩ : Fin n))) + refine ⟨P, hprime, S, hSeq, hSpos, hinj, hcompare, + (fun j => ⟨hearly j, hleS j⟩), hrange, ?_, hSlo, hSup, + hSup.trans hScale'.2.2, ?_⟩ + · intro j + apply (div_le_iff₀ (Nat.cast_pos.mpr (hprime j).pos)).mpr + rw [hSeq] + exact unconditionedCommonSide_le_exp_extra_mul P (fun j => (hprime j).pos) hcompare j + · intro nX hnX + let : ∀ j, NeZero (P j) := fun j => ⟨(hprime j).ne_zero⟩ + exact (hWidth nX hnX).trans (Real.exp_le_exp.mpr hCutoff'.2) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ScalarLatePrimeCutoffPowerBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarLatePrimeCutoffPowerBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..d86d8a37445bd29b415a46928f89899b0b52d4c6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarLatePrimeCutoffPowerBudget.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialShearParameterBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_scalarLatePrimeCutoff_power_budget (d r E C F A : ℕ) : + ∃ G : ℕ, 2 ≤ G ∧ ∀ b : ℝ, 0 ≤ b → + let p := (b + 2) ^ E + let target := 8 * ((r * d : ℕ) + 1 : ℝ) * (p + 1) + let t := (target + 2) ^ C + (p + F) ^ F ≤ (b + 2) ^ G ∧ (t + 2) ^ A ≤ (b + 2) ^ G := by + let Pscalar : Polynomial ℕ := ((Polynomial.X + 2) ^ E + Polynomial.C F) ^ F + let Psample : Polynomial ℕ := + ((Polynomial.C (8 * (r * d + 1)) * ((Polynomial.X + 2) ^ E + 1) + 2) ^ C + 2) ^ A + obtain ⟨G, hG, hbound⟩ := exists_natPolynomial_fixed_power_budget (Pscalar + Psample) + refine ⟨G, hG, ?_⟩ + intro b hb p target t + have hsum : (p + F) ^ F + (t + 2) ^ A ≤ (b + 2) ^ G := by + simpa [Pscalar, Psample, p, target, t, Polynomial.eval₂_pow] using hbound b hb + have hscalar : 0 ≤ (p + F) ^ F := by dsimp only [p]; positivity + have hsample : 0 ≤ (t + 2) ^ A := by dsimp only [t, target, p]; positivity + exact ⟨(le_add_of_nonneg_right hsample).trans hsum, + (le_add_of_nonneg_left hscalar).trans hsum⟩ + +theorem exists_scalarLatePrimeCutoff_composite_power_budget (d r E C F A H : ℕ) : + ∃ G : ℕ, 2 ≤ G ∧ ∀ p : ℝ, 2 ≤ p → + let b := (p + 2) ^ H + let scalarInput := (b + 2) ^ E + let target := 8 * ((r * d : ℕ) + 1 : ℝ) * (scalarInput + 1) + let t := (target + 2) ^ C + (scalarInput + F) ^ F ≤ (p + 2) ^ G ∧ (t + 2) ^ A ≤ (p + 2) ^ G := by + obtain ⟨G, hG, hbudget⟩ := exists_scalarLatePrimeCutoff_power_budget d r E C F A + refine ⟨(H + 1) * G, by nlinarith, ?_⟩ + intro p hp b scalarInput target t + have hbase : 1 ≤ p + 2 := by linarith + have hb : 1 ≤ b := one_le_pow₀ hbase + have hshift : b + 2 ≤ (p + 2) ^ (H + 1) := by + rw [pow_succ'] + change b + 2 ≤ (p + 2) * b + nlinarith + have hcompose : (b + 2) ^ G ≤ (p + 2) ^ ((H + 1) * G) := by + calc + _ ≤ ((p + 2) ^ (H + 1)) ^ G := pow_le_pow_left₀ (by linarith) hshift G + _ = _ := (pow_mul _ _ _).symm + have h := hbudget b (by linarith) + exact ⟨h.1.trans hcompose, h.2.trans hcompose⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ScalarResidueInteriorCell.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarResidueInteriorCell.lean new file mode 100644 index 0000000000000000000000000000000000000000..4838cdcdcc76bb8d0eee01222afd408eec8aba09 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ScalarResidueInteriorCell.lean @@ -0,0 +1,719 @@ +import Mathlib.Data.Int.Interval +import OAI.Combinatorics.Progressions.Estimates.RepresentativeWindowPatch +import OAI.Combinatorics.Progressions.Sampling.FixedPathSlicedGridMeshBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def paddedIntegerPoint {I : Type*} (L P : ℕ) (x : I → Fin P) : I → ℤ := + fun i => (x i).val - L + +theorem paddedIntegerPoint_injective {I : Type*} (L P : ℕ) : + Function.Injective (paddedIntegerPoint (I := I) L P) := by + intro x y h + funext i + apply Fin.ext + have hi := congrFun h i + dsimp only [paddedIntegerPoint] at hi + omega + +theorem paddedIntegerPoint_covers {I : Type*} {L P : ℕ} (hP : 2 * L ≤ P) + (k : I → ℤ) (hk : ∀ i, -(L : ℤ) ≤ k i ∧ k i < L) : + ∃ x : I → Fin P, paddedIntegerPoint L P x = k := by + let x : I → Fin P := fun i => ⟨(k i + L).toNat, by + have := hk i + omega⟩ + refine ⟨x, ?_⟩ + funext i + have := hk i + dsimp only [paddedIntegerPoint, x] + omega + +theorem sum_eq_sum_of_cover_and_support {X Y V : Type*} [Fintype X] + [DecidableEq Y] [AddCommMonoid V] (S : Finset Y) (e : X → Y) + (he : Function.Injective e) (hcover : ∀ y ∈ S, ∃ x, e x = y) + (F : Y → V) (hsupport : ∀ y, y ∉ S → F y = 0) : + (∑ y ∈ S, F y) = ∑ x, F (e x) := by + classical + have hsub : S ⊆ Finset.univ.image e := by + intro y hy + obtain ⟨x, hx⟩ := hcover y hy + exact Finset.mem_image.mpr ⟨x, Finset.mem_univ x, hx⟩ + calc + _ = ∑ y ∈ Finset.univ.image e, F y := + Finset.sum_subset hsub (fun y _ hy => hsupport y hy) + _ = _ := Finset.sum_image (fun _ _ _ _ h => he h) + +theorem expect_eq_card_ratio_mul_expect {X Y : Type*} [Fintype X] [Nonempty X] + [DecidableEq Y] (S : Finset Y) (e : X → Y) (he : Function.Injective e) + (hcover : ∀ y ∈ S, ∃ x, e x = y) (F : Y → ℂ) + (hsupport : ∀ y, y ∉ S → F y = 0) : + (𝔼 y ∈ S, F y) = ((Fintype.card X : ℂ) / S.card) * 𝔼 x, F (e x) := by + have hc : (Fintype.card X : ℂ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + rw [Finset.expect_eq_sum_div_card, Fintype.expect_eq_sum_div_card, + sum_eq_sum_of_cover_and_support S e he hcover F hsupport] + field_simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def residueCellLength (δ : ℝ) (L M : ℕ) : ℕ := ⌊δ * L / M⌋₊ + +def residueCellCount (L N : ℕ) : ℕ := 2 * L / N + 1 + +theorem residueCellCount_pos (L N : ℕ) : 0 < residueCellCount L N := by + exact Nat.succ_pos _ + +theorem residueCellCount_padding {L N : ℕ} (hN : 0 < N) (hNL : N ≤ L) : + 2 * L ≤ residueCellCount L N * N ∧ residueCellCount L N * N ≤ 3 * L := by + have hdiv := Nat.div_add_mod (2 * L) N + have hmod := Nat.mod_lt (2 * L) hN + unfold residueCellCount + constructor + · calc + 2 * L = N * (2 * L / N) + 2 * L % N := hdiv.symm + _ ≤ N * (2 * L / N) + N := Nat.add_le_add_left hmod.le _ + _ = (2 * L / N + 1) * N := by ring + · have hprod : N * (2 * L / N) ≤ 2 * L := by omega + calc + (2 * L / N + 1) * N = N * (2 * L / N) + N := by ring + _ ≤ 2 * L + N := Nat.add_le_add_right hprod _ + _ ≤ 3 * L := by omega + +theorem residueCellLength_bounds {δ : ℝ} {L M : ℕ} + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hL : 0 < L) (hM : 0 < M) + (hlarge : 2 * (M : ℝ) ≤ δ * L) : + 0 < residueCellLength δ L M ∧ residueCellLength δ L M ≤ L ∧ + δ * L / (2 * M) ≤ (residueCellLength δ L M : ℝ) ∧ + (M : ℝ) / L * residueCellLength δ L M ≤ δ := by + have hL' : (0 : ℝ) < L := by exact_mod_cast hL + have hM' : (0 : ℝ) < M := by exact_mod_cast hM + have hM1 : (1 : ℝ) ≤ M := by exact_mod_cast hM + have hx0 : 0 ≤ δ * L / M := by positivity + have hx2 : 2 ≤ δ * L / M := (le_div_iff₀ hM').mpr hlarge + have hfloor := Nat.floor_le hx0 + have hceil := Nat.lt_floor_add_one (δ * L / M) + have hpos : 0 < residueCellLength δ L M := by + unfold residueCellLength + apply Nat.floor_pos.mpr + linarith + have hxL : δ * L / M ≤ L := by + apply (div_le_iff₀ hM').mpr + nlinarith + have hNL : residueCellLength δ L M ≤ L := by + exact_mod_cast hfloor.trans hxL + refine ⟨hpos, hNL, ?_, ?_⟩ + · change δ * L / (2 * M) ≤ (⌊δ * L / M⌋₊ : ℝ) + have he : δ * L / (2 * M) = (δ * L / M) / 2 := by ring + rw [he] + have hp : (1 : ℝ) ≤ ⌊δ * L / M⌋₊ := by exact_mod_cast hpos + linarith + · have hmul := (le_div_iff₀ hM').mp hfloor + change (M : ℝ) / L * (⌊δ * L / M⌋₊ : ℝ) ≤ δ + rw [div_mul_eq_mul_div] + apply (div_le_iff₀ hL').mpr + nlinarith + +theorem residueCellLength_stride_mesh {δ : ℝ} {L M : ℕ} + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hL : 0 < L) (hM : 0 < M) + (hlarge : 2 * (M : ℝ) ≤ δ * L) {m : ℕ} (hm : m ≤ M) : + |(m : ℝ) / L| * residueCellLength δ L M ≤ δ := by + rw [abs_of_nonneg (by positivity : 0 ≤ (m : ℝ) / L)] + apply le_trans _ (residueCellLength_bounds hδ hδ1 hL hM hlarge).2.2.2 + exact mul_le_mul_of_nonneg_right + (div_le_div_of_nonneg_right (by exact_mod_cast hm) (by positivity)) (by positivity) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def scalarResidueGridPoint {I : Type*} (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (k : Option I → ℤ) : Option I → ℤ := fun i => (r i).val + (m i : ℤ)*k i + +noncomputable def scalarResidueGridOffset {I : Type*} (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) : Option I → ℝ := + fun i => -((r i).val : ℝ) / m i + +noncomputable def scalarResidueGridScale {I : Type*} (L : ℕ) (m : Option I → ℕ) : Option I → ℝ := + fun i => (L : ℝ) / m i + +theorem scalarResidueGridScale_pos {I : Type*} {L : ℕ} (hL : 0 < L) + (m : Option I → ℕ) (hm : ∀ i, 0 < m i) (i : Option I) : 0 < scalarResidueGridScale L m i := by + unfold scalarResidueGridScale + exact div_pos (by exact_mod_cast hL) (by exact_mod_cast hm i) + +theorem scalarResidueGrid_normalized {I : Type*} [Fintype I] {L : ℕ} (hL : 0 < L) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) (k : Option I → ℤ) : + rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) k = + fun i => (scalarResidueGridPoint m r k i : ℝ) / L := by + funext i + have hmi : (m i : ℝ) ≠ 0 := by exact_mod_cast (hm i).ne' + simp only [rectangularLatticePoint, scalarResidueGridOffset, scalarResidueGridScale, + scalarResidueGridPoint, Int.cast_add, Int.cast_natCast, Int.cast_mul] + field_simp + ring + +theorem integerScalarCube_iff_normalized {I : Type*} [Fintype I] [DecidableEq I] + {L : ℕ} (hL : 0 < L) (z : Option I → ℤ) : + IntegerScalarCube L z ↔ (fun i => (z i : ℝ) / L) ∈ halfOpenScalarCubeDomain I := by + have hLp : (0 : ℝ) < L := by exact_mod_cast hL + have he (t : Finset I) : scalarCubeValue (fun i => (z i : ℝ) / L) t = (integerScalarCubeValue z t : ℝ) / L := by + simp only [scalarCubeValue_formula, integerScalarCubeValue, Int.cast_add, Int.cast_sum, add_div, Finset.sum_div] + constructor + · intro hz t + rw [he] + constructor + · exact div_nonneg (by exact_mod_cast (hz t).1) hLp.le + · exact (div_lt_one hLp).mpr (by exact_mod_cast (hz t).2) + · intro hz t + have ht := hz t + rw [he] at ht + constructor + · have hh : (0 : ℝ) ≤ (integerScalarCubeValue z t : ℝ) := by + simpa only [zero_mul] using (le_div_iff₀ hLp).mp ht.1 + exact_mod_cast hh + · exact_mod_cast (div_lt_one hLp).mp ht.2 + +theorem scalarResidueGridPoint_residue {I : Type*} (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (k : Option I → ℤ) (i : Option I) : + (scalarResidueGridPoint m r k i : ZMod (m i)) = r i := by + let : NeZero (m i) := ⟨(hm i).ne'⟩ + simp [scalarResidueGridPoint] + +theorem scalarResidueGridPoint_injective {I : Type*} (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) : Function.Injective (scalarResidueGridPoint m r) := by + intro k l h + funext i + have hh := congrFun h i + have hmi : (m i : ℤ) ≠ 0 := by exact_mod_cast (hm i).ne' + exact mul_left_cancel₀ hmi (add_left_cancel hh) + +theorem scalarResidueGridPoint_surjective {I : Type*} (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (z : Option I → ℤ) + (hz : ∀ i, (z i : ZMod (m i)) = r i) : ∃ k, scalarResidueGridPoint m r k = z := by + have hi (i : Option I) : ∃ k : ℤ, z i = (r i).val + (m i : ℤ)*k := by + let : NeZero (m i) := ⟨(hm i).ne'⟩ + have he : (((r i).val : ℤ) : ZMod (m i)) = (z i : ZMod (m i)) := by simpa using (hz i).symm + obtain ⟨k,hk⟩ := (ZMod.intCast_eq_intCast_iff_dvd_sub ((r i).val : ℤ) (z i) (m i)).mp he + exact ⟨k, by linarith⟩ + choose k hk using hi + exact ⟨k, funext (fun i => (hk i).symm)⟩ + +noncomputable def scalarCubeResidueGridEquiv (I : Type*) [Fintype I] [DecidableEq I] + (L : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) : + ↥(scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m)) ≃ + ↥((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r) := by + let F : ↥(scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m)) → + ↥((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r) := fun k => by + have hk := (mem_scalarCubeGridSet _ _ (scalarResidueGridScale_pos hL m hm) k.val).mp k.property + rw [scalarResidueGrid_normalized hL m r hm] at hk + have hc := (integerScalarCube_iff_normalized hL _).mpr hk + let z : IntegerScalarCubeBox I L := fun i => ⟨scalarResidueGridPoint m r k.val i, + Finset.mem_Ico.mpr ⟨(integerScalarCube_coordinates hc i).1.le, (integerScalarCube_coordinates hc i).2⟩⟩ + exact ⟨z, Finset.mem_inter.mpr ⟨(mem_integerScalarCubeSet L z).mpr hc, + (mem_scalarCubeResidueSet L m r z).mpr (scalarResidueGridPoint_residue m r hm k.val)⟩⟩ + apply Equiv.ofBijective F + constructor + · intro k l h + apply Subtype.ext + apply scalarResidueGridPoint_injective m r hm + exact funext (fun i => congrArg (fun z : ↥((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r) => + (z.val i : ℤ)) h) + · intro z + obtain ⟨k,hk⟩ := scalarResidueGridPoint_surjective m r hm (fun i => (z.val i : ℤ)) + ((mem_scalarCubeResidueSet L m r z.val).mp (Finset.mem_inter.mp z.property).2) + have hc := (mem_integerScalarCubeSet L z.val).mp (Finset.mem_inter.mp z.property).1 + have hmem : k ∈ scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m) := by + rw [mem_scalarCubeGridSet _ _ (scalarResidueGridScale_pos hL m hm), scalarResidueGrid_normalized hL m r hm, hk] + exact (integerScalarCube_iff_normalized hL _).mp hc + refine ⟨⟨k,hmem⟩, ?_⟩ + apply Subtype.ext + funext i + apply Subtype.ext + exact congrFun hk i + +theorem scalarCubeResidueGridEquiv_apply (I : Type*) [Fintype I] [DecidableEq I] + (L : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (k : ↥(scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m))) (i : Option I) : + (((scalarCubeResidueGridEquiv I L hL m r hm k).val i : ℤ)) = scalarResidueGridPoint m r k.val i := rfl + +theorem scalarCubeResidueWeights_grid_mean (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I + 1)*M ≤ L) + (φ : (Option I → ℝ) → ℝ) : + (scalarCubeResidueWeights I L M hL m r hm hmM hsize).mean + (fun z => φ (fun i => (z i : ℝ) / L)) = + 𝔼 k ∈ scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m), + φ (rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) k) := by + rw [scalarCubeResidueWeights_mean] + let e := scalarCubeResidueGridEquiv I L hL m r hm + have he (k : ↥(scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m))) : + rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) k.val = + fun i => ((e k).val i : ℝ) / L := by + rw [scalarResidueGrid_normalized hL m r hm] + funext i + rfl + calc + _ = 𝔼 k : ↥(scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m)), + φ (rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) k.val) := by + symm + exact Fintype.expect_equiv e _ _ (fun k => congrArg φ (he k)) + _ = _ := by + rw [Fintype.expect_eq_sum_div_card, Finset.expect_eq_sum_div_card, Fintype.card_coe] + congr 1 + exact Finset.sum_coe_sort _ (fun k => + φ (rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) k)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem FiniteProbabilityWeights.complexMean_im {X : Type*} [Fintype X] + (p : FiniteProbabilityWeights X) (F : X → ℂ) : + (p.complexMean F).im = p.mean (fun x => (F x).im) := by + simp [complexMean, mean, Complex.mul_im] + +theorem scalarCubeResidueWeights_grid_complexMean (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I + 1)*M ≤ L) + (F : (Option I → ℝ) → ℂ) : + (scalarCubeResidueWeights I L M hL m r hm hmM hsize).complexMean + (fun z => F (fun i => (z i : ℝ) / L)) = + 𝔼 k ∈ scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m), + F (rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) k) := by + apply Complex.ext + · rw [FiniteProbabilityWeights.complexMean_re, Complex.re_expect] + exact scalarCubeResidueWeights_grid_mean I L M hL m r hm hmM hsize (fun x => (F x).re) + · rw [FiniteProbabilityWeights.complexMean_im, Complex.im_expect] + exact scalarCubeResidueWeights_grid_mean I L M hL m r hm hmM hsize (fun x => (F x).im) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residue_index_bounds {L m : ℕ} (hm : 0 < m) (r : ZMod m) (k : ℤ) + (hk : -(L : ℤ) < (r.val : ℤ) + m * k ∧ (r.val : ℤ) + m * k < L) : + -(L : ℤ) ≤ k ∧ k < L := by + let : NeZero m := ⟨hm.ne'⟩ + have hm' : (1 : ℤ) ≤ m := by exact_mod_cast hm + have hr : (r.val : ℤ) < m := by exact_mod_cast ZMod.val_lt r + have hr0 : (0 : ℤ) ≤ r.val := by positivity + constructor + · by_contra! h + have hmul := mul_le_mul_of_nonneg_left (show k ≤ -(L : ℤ) - 1 by omega) (by positivity : (0 : ℤ) ≤ m) + have hsize := mul_le_mul_of_nonneg_right hm' (by positivity : (0 : ℤ) ≤ L) + nlinarith [hk.1] + · by_contra! h + have hmul := mul_le_mul_of_nonneg_left h (by positivity : (0 : ℤ) ≤ m) + have hsize := mul_le_mul_of_nonneg_right hm' (by positivity : (0 : ℤ) ≤ L) + nlinarith [hk.2] + +theorem scalarCubeResidueGrid_index_bounds {I : Type*} [Fintype I] [DecidableEq I] + {L : ℕ} (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (k : Option I → ℤ) + (hk : k ∈ scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m)) : + ∀ i, -(L : ℤ) ≤ k i ∧ k i < L := by + have hx := (mem_scalarCubeGridSet _ _ (scalarResidueGridScale_pos hL m hm) k).mp hk + rw [scalarResidueGrid_normalized hL m r hm] at hx + have hc := (integerScalarCube_iff_normalized hL _).mpr hx + intro i + exact residue_index_bounds (hm i) (r i) (k i) (integerScalarCube_coordinates hc i) + +theorem scalarCubeResidueGrid_padded_cover {I : Type*} [Fintype I] [DecidableEq I] + {L P : ℕ} (hL : 0 < L) (hP : 2 * L ≤ P) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (k : Option I → ℤ) + (hk : k ∈ scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m)) : + ∃ x : Option I → Fin P, paddedIntegerPoint L P x = k := + paddedIntegerPoint_covers hP k (scalarCubeResidueGrid_index_bounds hL m r hm k hk) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem scalarCubeResidueWeights_riemann (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I + 1)*M ≤ L) + (hsmall : scalarCubeGridBoundaryConstant I * ((M : ℝ)/L) < volume.real (scalarCubeDomain I)) + (φ : (Option I → ℝ) → ℝ) {K : ℝ≥0} {B : ℝ} + (hφ : LipschitzWith K φ) (hB : 0 ≤ B) (hb : ∀ x, ‖φ x‖ ≤ B) : + |(scalarCubeResidueWeights I L M hL m r hm hmM hsize).mean + (fun z => φ (fun i => (z i : ℝ) / L)) - ∫ x, φ x ∂scalarCubeMeasure I| ≤ + (2 * B * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + K) * ((M : ℝ)/L) := by + rw [scalarCubeResidueWeights_grid_mean] + have hLp : (0 : ℝ) < L := by exact_mod_cast hL + have hML : M ≤ L := by nlinarith + have hδ : (0 : ℝ) ≤ (M : ℝ)/L := by positivity + have hδ1 : (M : ℝ)/L ≤ 1 := (div_le_one hLp).mpr (by exact_mod_cast hML) + have hS := scalarResidueGridScale_pos hL m hm + have hmesh (i : Option I) : 1 / scalarResidueGridScale L m i ≤ (M : ℝ)/L := by + simp only [scalarResidueGridScale, one_div_div] + exact div_le_div_of_nonneg_right (by exact_mod_cast hmM i) hLp.le + have hpos := scalarCubeGridHistogram_mass_pos I (scalarResidueGridOffset m r) _ hS hδ hδ1 hmesh hsmall + exact (scalarCubeGrid_comparison I _ _ hS hδ hδ1 hmesh hpos φ hφ hB hb).trans_eq (by ring) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def paddedResidueOffset {I : Type*} (L : ℕ) (m : Option I → ℕ) + (r : ∀ i, ZMod (m i)) : Option I → ℝ := + fun i => ((r i).val - (m i : ℝ) * L) / L + +noncomputable def paddedResidueStep {I : Type*} (L : ℕ) (m : Option I → ℕ) : Option I → ℝ := + fun i => (m i : ℝ) / L + +theorem paddedResidueCoordinates_eq {I : Type*} [Fintype I] {L P : ℕ} (hL : 0 < L) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (x : Option I → Fin P) : + rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) + (paddedIntegerPoint L P x) = + fun i => paddedResidueOffset L m r i + paddedResidueStep L m i * (x i).val := by + rw [scalarResidueGrid_normalized hL m r hm] + funext i + simp only [scalarResidueGridPoint, paddedIntegerPoint, paddedResidueOffset, + paddedResidueStep, Int.cast_add, Int.cast_mul, Int.cast_sub, Int.cast_natCast] + ring + +theorem scalarCubeResidueGrid_card (I : Type*) [Fintype I] [DecidableEq I] + {L : ℕ} (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) : + (scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m)).card = + ((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r).card := by + simpa only [Fintype.card_coe] using Fintype.card_congr (scalarCubeResidueGridEquiv I L hL m r hm) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +noncomputable def scalarCubeResidueCutoffBudget (I : Type*) [Fintype I] [DecidableEq I] + (A r : ℝ≥0) (L M : ℕ) : ℝ := + scalarCubeBoundaryConstant I * r + + (2 * scalarCubeGridBoundaryConstant I / volume.real (scalarCubeDomain I) + + scalarCubeCutoffLipschitzConstant I A r) * ((M : ℝ) / L) + +theorem scalarCubeResidueCutoff_loss (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) + (hsmall : scalarCubeGridBoundaryConstant I * ((M : ℝ) / L) < + volume.real (scalarCubeDomain I)) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + {r : ℝ≥0} (hr : 0 < r) : + (scalarCubeResidueWeights I L M hL m res hm hmM hsize).mean + (fun z => 1 - inequalityBoundaryCutoff (fun _ : Bool × Finset I => (r : ℝ)) + scalarCubeFace (fun i => (z i : ℝ) / L)) ≤ + scalarCubeResidueCutoffBudget I A r L M := by + let b := inequalityBoundaryCutoff (fun _ : Bool × Finset I => (r : ℝ)) scalarCubeFace + have hLip : LipschitzWith (scalarCubeCutoffLipschitzConstant I A r) + (fun x => 1 - b x) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [Real.dist_eq, show (1 - b x) - (1 - b y) = b y - b x by ring, abs_sub_comm] + exact (scalarCubeBoundaryCutoff_lipschitz I A hA hr).dist_le_mul x y + have hbound (x : Option I → ℝ) : ‖1 - b x‖ ≤ 1 := by + have h := inequalityBoundaryCutoff_range (fun _ : Bool × Finset I => (r : ℝ)) scalarCubeFace x + rw [Real.norm_eq_abs, abs_of_nonneg (sub_nonneg.mpr h.2)] + linarith [h.1] + have hquad := scalarCubeResidueWeights_riemann I L M hL m res hm hmM hsize hsmall + (fun x => 1 - b x) hLip zero_le_one hbound + have hcont := scalarCubeBoundaryCutoff_mass_loss I (show (0 : ℝ) < r from hr) + have hu := (le_abs_self _).trans hquad + dsimp only [scalarCubeResidueCutoffBudget] + dsimp only [b] at hu + linarith + +theorem scalarCubeResidueCutoff_bias (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) + (hsmall : scalarCubeGridBoundaryConstant I * ((M : ℝ) / L) < + volume.real (scalarCubeDomain I)) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) + {r : ℝ≥0} (hr : 0 < r) (F : IntegerScalarCubeBox I L → ℂ) + (hF : ∀ z, ‖F z‖ ≤ 1) {ζ : ℝ} + (hbias : ζ ≤ ‖(scalarCubeResidueWeights I L M hL m res hm hmM hsize).complexMean F‖) : + ζ - scalarCubeResidueCutoffBudget I A r L M ≤ + ‖(scalarCubeResidueWeights I L M hL m res hm hmM hsize).complexMean + (fun z => (inequalityBoundaryCutoff (fun _ : Bool × Finset I => (r : ℝ)) + scalarCubeFace (fun i => (z i : ℝ) / L) : ℂ) * F z)‖ := + FiniteProbabilityWeights.cutoff_bias_lower _ _ F + (fun _ => inequalityBoundaryCutoff_range _ _ _) hF hbias + (scalarCubeResidueCutoff_loss I L M hL m res hm hmM hsize hsmall A hA hr) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def paddedResidueDensityFactor (I : Type*) [Fintype I] (L P : ℕ) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) : ℝ := + (P : ℝ) ^ (Fintype.card I + 1) / + ((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r).card + +noncomputable def paddedResidueDensityCap (I : Type*) [Fintype I] (M : ℕ) : ℝ := + 2 ^ (Fintype.card I + 1) * scalarCubeResidueDensityCap I M + +theorem scalarCubeResidue_card_pos (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) : + 0 < ((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r).card := by + have hcap := scalarCubeResidueDensityCap_pos I M ((hm none).trans_le (hmM none)) + have h := scalarCubeResidueReference_mass_lower I L M hL m r hm hmM hsize + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + rw [integerScalarCubeReference, FiniteProbabilityWeights.uniform_mass] at h + by_contra! hz + have hzero : ((integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r).card = 0 := by omega + rw [hzero, Nat.cast_zero, zero_div] at h + exact (not_le_of_gt (inv_pos.mpr hcap)) h + +theorem paddedResidueDensityFactor_pos (I : Type*) [Fintype I] [DecidableEq I] + (L M P : ℕ) (hL : 0 < L) (hP : 0 < P) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I + 1) * M ≤ L) : + 0 < paddedResidueDensityFactor I L P m r := by + apply div_pos (pow_pos (by exact_mod_cast hP) _) + exact_mod_cast scalarCubeResidue_card_pos I L M hL m r hm hmM hsize + +theorem paddedResidueDensityFactor_le (I : Type*) [Fintype I] [DecidableEq I] + (L M P : ℕ) (hL : 0 < L) (hP : P ≤ 4 * L) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I + 1) * M ≤ L) : + paddedResidueDensityFactor I L P m r ≤ paddedResidueDensityCap I M := by + let S := (integerScalarCubeSet I L) ∩ scalarCubeResidueSet I L m r + have hS : (0 : ℝ) < S.card := by + exact_mod_cast scalarCubeResidue_card_pos I L M hL m r hm hmM hsize + have hcap := scalarCubeResidueDensityCap_pos I M ((hm none).trans_le (hmM none)) + have hbase : (0 : ℝ) < (2 * (L : ℝ)) ^ (Fintype.card I + 1) := by positivity + have h := scalarCubeResidueReference_mass_lower I L M hL m r hm hmM hsize + let : Nonempty (IntegerScalarCubeBox I L) := ⟨integerScalarCubeBoxZero I L hL⟩ + rw [integerScalarCubeReference, FiniteProbabilityWeights.uniform_mass, + integerScalarCubeBox_card] at h + push_cast at h + have hmass : (2 * (L : ℝ)) ^ (Fintype.card I + 1) ≤ + S.card * scalarCubeResidueDensityCap I M := by + have hh : 1 / scalarCubeResidueDensityCap I M ≤ + (S.card : ℝ) / (2 * (L : ℝ)) ^ (Fintype.card I + 1) := by + simpa only [one_div, S] using h + simpa only [one_mul] using (div_le_div_iff₀ hcap hbase).mp hh + apply (div_le_iff₀ hS).mpr + calc + (P : ℝ) ^ (Fintype.card I + 1) ≤ (2 * (2 * (L : ℝ))) ^ (Fintype.card I + 1) := + pow_le_pow_left₀ (Nat.cast_nonneg P) + (by exact_mod_cast (show P ≤ 2 * (2 * L) by omega)) _ + _ = 2 ^ (Fintype.card I + 1) * (2 * (L : ℝ)) ^ (Fintype.card I + 1) := mul_pow _ _ _ + _ ≤ 2 ^ (Fintype.card I + 1) * (S.card * scalarCubeResidueDensityCap I M) := + mul_le_mul_of_nonneg_left hmass (by positivity) + _ = paddedResidueDensityCap I M * S.card := by unfold paddedResidueDensityCap; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem scalarCubeResidueWeights_padded_mean (I : Type*) [Fintype I] [DecidableEq I] + (L M P : ℕ) (hL : 0 < L) (hP : 2 * L ≤ P) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I + 1) * M ≤ L) + (w : (Option I → ℝ) → ℝ) (hw : Function.support w ⊆ halfOpenScalarCubeDomain I) + (F : (Option I → ℝ) → ℂ) : + (scalarCubeResidueWeights I L M hL m r hm hmM hsize).complexMean + (fun z => (w (fun i => (z i : ℝ) / L) : ℂ) * F (fun i => (z i : ℝ) / L)) = + 𝔼 x : Option I → Fin P, + ((paddedResidueDensityFactor I L P m r * + w (fun i => paddedResidueOffset L m r i + paddedResidueStep L m i * (x i).val) : ℝ) : ℂ) * + F (fun i => paddedResidueOffset L m r i + paddedResidueStep L m i * (x i).val) := by + have hPpos : 0 < P := by omega + let : Nonempty (Fin P) := ⟨⟨0, hPpos⟩⟩ + let S := scalarCubeGridSet I (scalarResidueGridOffset m r) (scalarResidueGridScale L m) + let f := fun k => (w (rectangularLatticePoint (scalarResidueGridOffset m r) + (scalarResidueGridScale L m) k) : ℂ) * + F (rectangularLatticePoint (scalarResidueGridOffset m r) (scalarResidueGridScale L m) k) + have hsupport (k) (hk : k ∉ S) : f k = 0 := by + have hz : w (rectangularLatticePoint (scalarResidueGridOffset m r) + (scalarResidueGridScale L m) k) = 0 := by + by_contra h + exact hk ((mem_scalarCubeGridSet _ _ (scalarResidueGridScale_pos hL m hm) k).mpr (hw h)) + simp only [f, hz, Complex.ofReal_zero, zero_mul] + rw [scalarCubeResidueWeights_grid_complexMean I L M hL m r hm hmM hsize + (fun y => (w y : ℂ) * F y)] + change (𝔼 k ∈ S, f k) = _ + rw [expect_eq_card_ratio_mul_expect S (paddedIntegerPoint L P) + (paddedIntegerPoint_injective L P) + (scalarCubeResidueGrid_padded_cover hL hP m r hm) f hsupport] + have hfactor : (Fintype.card (Option I → Fin P) : ℂ) / S.card = + (paddedResidueDensityFactor I L P m r : ℂ) := by + simp only [Fintype.card_fun, Fintype.card_option, Fintype.card_fin, S, + scalarCubeResidueGrid_card I hL m r hm, paddedResidueDensityFactor, + Nat.cast_pow, Complex.ofReal_div, Complex.ofReal_pow, Complex.ofReal_natCast] + rw [hfactor, Finset.mul_expect] + apply Finset.expect_congr rfl + intro x _ + dsimp only [f] + rw [paddedResidueCoordinates_eq hL m r hm x, Complex.ofReal_mul, mul_assoc] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem scalarCubeResidueWeights_padded_bias (I : Type*) [Fintype I] [DecidableEq I] + (L M P : ℕ) (hL : 0 < L) (hP : 2 * L ≤ P) (hPupper : P ≤ 4 * L) + (m : Option I → ℕ) (r : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (hmM : ∀ i, m i ≤ M) (hsize : (Fintype.card I + 1) * M ≤ L) + (w : (Option I → ℝ) → ℝ) (hw : Function.support w ⊆ halfOpenScalarCubeDomain I) + (F : (Option I → ℝ) → ℂ) {ζ : ℝ} + (hbias : ζ ≤ ‖(scalarCubeResidueWeights I L M hL m r hm hmM hsize).complexMean + (fun z => (w (fun i => (z i : ℝ) / L) : ℂ) * F (fun i => (z i : ℝ) / L))‖) : + ζ / paddedResidueDensityCap I M ≤ + ‖𝔼 x : Option I → Fin P, + (w (fun i => paddedResidueOffset L m r i + paddedResidueStep L m i * (x i).val) : ℂ) * + F (fun i => paddedResidueOffset L m r i + paddedResidueStep L m i * (x i).val)‖ := by + have hcap : 0 < paddedResidueDensityCap I M := by + unfold paddedResidueDensityCap + exact mul_pos (by positivity) + (scalarCubeResidueDensityCap_pos I M ((hm none).trans_le (hmM none))) + have hfactor := paddedResidueDensityFactor_pos I L M P hL (by omega) m r hm hmM hsize + have hle := paddedResidueDensityFactor_le I L M P hL hPupper m r hm hmM hsize + have hlaw := scalarCubeResidueWeights_padded_mean I L M P hL hP m r hm hmM hsize w hw F + simp only [Complex.ofReal_mul, mul_assoc, ← Finset.mul_expect] at hlaw + rw [hlaw, norm_mul, Complex.norm_real, Real.norm_of_nonneg hfactor.le] at hbias + apply (div_le_iff₀ hcap).mpr + exact hbias.trans ((mul_le_mul_of_nonneg_right hle (norm_nonneg _)).trans_eq (mul_comm _ _)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators NNReal + +theorem scalarCubeResidue_exists_interior_cell (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) + (hsmall : scalarCubeGridBoundaryConstant I * ((M : ℝ) / L) < + volume.real (scalarCubeDomain I)) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {r : ℝ≥0} (hr : 0 < r) + {δ η ζ : ℝ} (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hη : 0 < η) + (hlarge : 2 * (M : ℝ) ≤ δ * L) + (hmargin : ((Fintype.card I : ℝ) + 1) * δ < r) + (herror : scalarCubeResidueCutoffBudget I A r L M + + paddedResidueDensityCap I M * (scalarCubeCutoffLipschitzConstant I A r * δ + η) ≤ ζ) + (F : (Option I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) + (hbias : ζ ≤ ‖(scalarCubeResidueWeights I L M hL m res hm hmM hsize).complexMean + (fun z => F (fun i => (z i : ℝ) / L))‖) : + ∃ N K : ℕ, 0 < N ∧ N ≤ L ∧ δ * L / (2 * M) ≤ (N : ℝ) ∧ 0 < K ∧ + ∃ k : Option I → Fin K, + (∀ t : Option I → Fin N, + (fun i => progressionCellCorner (fun _ => N) (paddedResidueOffset L m res) + (paddedResidueStep L m) k i + paddedResidueStep L m i * (t i).val) ∈ scalarCubeDomain I) ∧ + η ≤ ‖𝔼 t : Option I → Fin N, + F (fun i => progressionCellCorner (fun _ => N) (paddedResidueOffset L m res) + (paddedResidueStep L m) k i + paddedResidueStep L m i * (t i).val)‖ := by + let N := residueCellLength δ L M + let K := residueCellCount L N + have hM : 0 < M := (hm none).trans_le (hmM none) + have hN := residueCellLength_bounds hδ hδ1 hL hM hlarge + have hK : 0 < K := residueCellCount_pos L N + have hP : 2 * L ≤ K * N ∧ K * N ≤ 3 * L := residueCellCount_padding hN.1 hN.2.1 + let b := inequalityBoundaryCutoff (fun _ : Bool × Finset I => (r : ℝ)) scalarCubeFace + let Q := scalarCubeCutoffLipschitzConstant I A r + let B := paddedResidueDensityCap I M + have hB : 0 < B := by + exact mul_pos (by positivity) (scalarCubeResidueDensityCap_pos I M hM) + have hb : Function.support b ⊆ halfOpenScalarCubeDomain I := by + intro x hx + exact scalarCubeDomain_subset_halfOpen I + (scalarCubeBoundaryCutoff_tsupport_domain I (show (0 : ℝ) < r from hr) (subset_closure hx)) + have hcut := scalarCubeResidueCutoff_bias I L M hL m res hm hmM hsize hsmall A hA hr + (fun z => F (fun i => (z i : ℝ) / L)) (fun z => hF _) hbias + have hpad := scalarCubeResidueWeights_padded_bias I L M (K * N) hL hP.1 + (by omega) m res hm hmM hsize b hb F hcut + have hthreshold : Q * δ + η ≤ (ζ - scalarCubeResidueCutoffBudget I A r L M) / B := by + apply (le_div_iff₀ hB).mpr + dsimp only [Q, B] + nlinarith + have hpad' := hthreshold.trans hpad + obtain ⟨k, hinside, hphase⟩ := exists_interior_progression_cell + (fun _ : Option I => K) (fun _ => N) (fun _ => hK) (fun _ => hN.1) + (paddedResidueOffset L m res) (paddedResidueStep L m) b (scalarCubeDomain I) + (scalarCubeBoundaryCutoff_lipschitz I A hA hr) hδ.le zero_lt_one + (show (Q : ℝ) * δ < Q * δ + η by linarith) + (fun i => residueCellLength_stride_mesh hδ hδ1 hL hM hlarge (hmM i)) + (fun x => inequalityBoundaryCutoff_range _ _ x) + (scalarCube_cutoff_safe (show (0 : ℝ) < r from hr) hmargin b Set.Subset.rfl) + (fun x => F (fun i => paddedResidueOffset L m res i + paddedResidueStep L m i * (x i).val)) + (fun x => hF _) hpad' + refine ⟨N, K, hN.1, hN.2.1, hN.2.2.1, hK, k, hinside, ?_⟩ + have he (t : Option I → Fin N) := finiteRectangleRefinement_affine + (fun _ : Option I => K) (fun _ => N) (paddedResidueOffset L m res) (paddedResidueStep L m) k t + simp only [he, Q, add_sub_cancel_left, div_one] at hphase + exact hphase + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ScaledLatticeCovolume.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ScaledLatticeCovolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..118a33cecc1c185d28f29ca4058b1dedf217268d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ScaledLatticeCovolume.lean @@ -0,0 +1,450 @@ +import Mathlib.Algebra.Module.ZLattice.Basic +import OAI.Combinatorics.Progressions.Estimates.OrthogonalSection +import OAI.Combinatorics.Progressions.Estimates.ScaledSectionGram +import OAI.Combinatorics.Progressions.Lattices.LatticeCoordinateLifts +import OAI.Combinatorics.Progressions.Lattices.LatticeSheetHaar + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +theorem rational_vector_mem_span_integer_points {κ : Type*} [Fintype κ] + (U : Submodule ℝ (κ → ℝ)) (q : κ → ℚ) (hq : (fun i => (q i : ℝ)) ∈ U) : + (fun i => (q i : ℝ)) ∈ Submodule.span ℝ + {x : κ → ℝ | x ∈ realIntegerGrid ∧ x ∈ U} := by + classical + let D := arrayDenominator q + let z := clearedArray q + have hD : (D : ℝ) ≠ 0 := by exact_mod_cast (arrayDenominator_pos q).ne' + have he : (fun i => (z i : ℝ)) = (D : ℝ) • (fun i => (q i : ℝ)) := by + funext i + change (clearedArray q i : ℝ) = (arrayDenominator q : ℝ) * (q i : ℝ) + exact_mod_cast clearedArray_cast q i + have hz : (fun i => (z i : ℝ)) ∈ U := by rw [he]; exact U.smul_mem _ hq + have hs : (fun i => (z i : ℝ)) ∈ Submodule.span ℝ + {x : κ → ℝ | x ∈ realIntegerGrid ∧ x ∈ U} := Submodule.subset_span ⟨⟨z, rfl⟩, hz⟩ + have hinv := (Submodule.span ℝ {x : κ → ℝ | x ∈ realIntegerGrid ∧ x ∈ U}).smul_mem + (D : ℝ)⁻¹ hs + simpa only [he, smul_smul, inv_mul_cancel₀ hD, one_smul] using hinv + +theorem exists_rational_matrix_height {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℚ) : ∃ H : ℕ, 1 ≤ H ∧ ∀ i j, RationalHeightLE (A i j) H := by + classical + let H := max 1 (Finset.univ.sup fun ij : ι × κ => max (A ij.1 ij.2).num.natAbs (A ij.1 ij.2).den) + refine ⟨H, le_max_left _ _, ?_⟩ + intro i j + have hmax : max (A i j).num.natAbs (A i j).den ≤ H := + (Finset.le_sup (f := fun ij : ι × κ => max (A ij.1 ij.2).num.natAbs (A ij.1 ij.2).den) + (Finset.mem_univ (i, j))).trans (le_max_right _ _) + exact ⟨(le_max_left _ _).trans hmax, (le_max_right _ _).trans hmax⟩ + +theorem real_rational_kernel_eq_span_integer {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℚ) : + LinearMap.ker (Matrix.mulVecLin (fun i j => (A i j : ℝ))) = + Submodule.span ℝ {x : κ → ℝ | x ∈ realIntegerGrid ∧ + x ∈ LinearMap.ker (Matrix.mulVecLin (fun i j => (A i j : ℝ)))} := by + classical + obtain ⟨H, hH, hA⟩ := exists_rational_matrix_height A + obtain ⟨S, hS, _⟩ := exists_bounded_rational_image_section A hH hA + let Ar : Matrix ι κ ℝ := fun i j => (A i j : ℝ) + let Sr : Matrix κ ι ℝ := fun i j => (S i j : ℝ) + let P : Matrix κ κ ℚ := 1 - S * A + let Pr : Matrix κ κ ℝ := fun i j => (P i j : ℝ) + have hSr : Ar * Sr * Ar = Ar := real_matrix_image_section A S hS + have hPr : Pr = (1 : Matrix κ κ ℝ) - Sr * Ar := by + ext i j + change (P i j : ℝ) = (if i = j then 1 else 0) - ∑ k, (S i k : ℝ) * (A k j : ℝ) + by_cases hij : i = j <;> simp [P, Matrix.sub_apply, Matrix.mul_apply, hij] + have hzero : Ar * (1 - Sr * Ar) = 0 := by + rw [Matrix.mul_sub, Matrix.mul_one, ← Matrix.mul_assoc, hSr, sub_self] + have hrange : LinearMap.range ((1 - Sr * Ar).mulVecLin) = LinearMap.ker Ar.mulVecLin := by + ext x + constructor + · rintro ⟨y, rfl⟩ + change Ar *ᵥ ((1 - Sr * Ar) *ᵥ y) = 0 + rw [Matrix.mulVec_mulVec, hzero, Matrix.zero_mulVec] + · intro hx + change Ar *ᵥ x = 0 at hx + refine ⟨x, ?_⟩ + change (1 - Sr * Ar) *ᵥ x = x + rw [Matrix.sub_mulVec, Matrix.one_mulVec, ← Matrix.mulVec_mulVec, + hx, Matrix.mulVec_zero, sub_zero] + have hspan : Submodule.span ℝ (Set.range Pr.col) = LinearMap.ker Ar.mulVecLin := by + rw [← Matrix.range_mulVecLin, hPr] + exact hrange + apply le_antisymm + · change LinearMap.ker Ar.mulVecLin ≤ _ + calc + LinearMap.ker Ar.mulVecLin = Submodule.span ℝ (Set.range Pr.col) := hspan.symm + _ ≤ _ := by + apply Submodule.span_le.mpr + rintro x ⟨j, rfl⟩ + apply rational_vector_mem_span_integer_points _ (P.col j) + exact hspan ▸ (Submodule.subset_span ⟨j, rfl⟩) + · exact Submodule.span_le.mpr (fun _ hx => hx.2) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +theorem kernel_eq_span_integer_inter_of_basis + {E ι κ : Type*} [AddCommGroup E] [Module ℝ E] [Fintype ι] [Fintype κ] + (b : Basis κ ℝ E) (Λ : Submodule ℤ E) (hb : Submodule.span ℤ (Set.range b) = Λ) + (π : E →ₗ[ℝ] (ι → ℝ)) (hπ : ∀ j, π (b j) ∈ realIntegerGrid) : + LinearMap.ker π = Submodule.span ℝ {x : E | x ∈ Λ ∧ π x = 0} := by + classical + choose z hz using hπ + let A : Matrix ι κ ℚ := fun i j => (z j i : ℚ) + let Ar : Matrix ι κ ℝ := fun i j => (A i j : ℝ) + let f : (κ → ℝ) →ₗ[ℝ] E := b.equivFun.symm.toLinearMap + have hA (y : κ → ℝ) : π (b.equivFun.symm y) = Ar *ᵥ y := by + funext i + rw [b.equivFun_symm_apply, map_sum] + simp only [map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul, Matrix.mulVec, dotProduct] + apply Finset.sum_congr rfl + intro j _ + have hj : (z j i : ℝ) = π (b j) i := congrFun (hz j) i + rw [← hj] + simp only [Ar, A, Rat.cast_intCast, mul_comm] + have hmap : (LinearMap.ker Ar.mulVecLin).map f ≤ + Submodule.span ℝ {x : E | x ∈ Λ ∧ π x = 0} := by + change (LinearMap.ker (Matrix.mulVecLin (fun i j => (A i j : ℝ)))).map f ≤ _ + rw [real_rational_kernel_eq_span_integer, Submodule.map_span] + apply Submodule.span_le.mpr + rintro x ⟨y, ⟨⟨a, ha⟩, hy⟩, rfl⟩ + apply Submodule.subset_span + constructor + · rw [← hb, b.mem_span_iff_repr_mem ℤ] + intro j + refine ⟨a j, ?_⟩ + change (a j : ℝ) = b.equivFun (b.equivFun.symm y) j + rw [LinearEquiv.apply_symm_apply] + exact congrFun ha j + · change π (b.equivFun.symm y) = 0 + rw [hA] + exact hy + apply le_antisymm + · intro x hx + apply hmap + refine ⟨b.equivFun x, ?_, b.equivFun.symm_apply_apply x⟩ + change Ar *ᵥ b.equivFun x = 0 + rw [← hA, LinearEquiv.symm_apply_apply] + exact hx + · apply Submodule.span_le.mpr + intro x hx + exact hx.2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [FiniteDimensional ℝ E] [Fintype ι] + (Λ : Submodule ℤ E) (π : E →ₗ[ℝ] (ι → ℝ)) + +noncomputable def latticeKernel : Submodule ℤ (LinearMap.ker π) := + ZLattice.comap ℝ Λ (LinearMap.ker π).subtype + +instance latticeKernel_discrete [DiscreteTopology Λ] : DiscreteTopology (latticeKernel Λ π) := + ZLattice.comap_discreteTopology ℝ Λ continuous_subtype_val Subtype.val_injective + +theorem kernel_eq_span_lattice_inter [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (hπ : ∀ x ∈ Λ, π x ∈ realIntegerGrid) : + LinearMap.ker π = Submodule.span ℝ {x : E | x ∈ Λ ∧ π x = 0} := by + let b := (Free.chooseBasis ℤ Λ).ofZLatticeBasis ℝ Λ + exact kernel_eq_span_integer_inter_of_basis b Λ + ((Free.chooseBasis ℤ Λ).ofZLatticeBasis_span ℝ) + π (fun j => hπ _ (by + simpa only [b, Basis.ofZLatticeBasis_apply] using ((Free.chooseBasis ℤ Λ) j).property)) + +theorem latticeKernel_full [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (hπ : ∀ x ∈ Λ, π x ∈ realIntegerGrid) : IsZLattice ℝ (latticeKernel Λ π) := by + constructor + apply (Submodule.map_injective_of_injective (LinearMap.ker π).injective_subtype) + rw [Submodule.map_top, Submodule.range_subtype, Submodule.map_span] + refine Eq.trans ?_ (kernel_eq_span_lattice_inter Λ π hπ).symm + apply congrArg (Submodule.span ℝ) + ext x + constructor + · rintro ⟨y, hy, rfl⟩ + exact ⟨hy, y.property⟩ + · rintro ⟨hx, hzero⟩ + exact ⟨⟨x, hzero⟩, hx, rfl⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (Λ : Submodule ℤ E) (π : E →ₗ[ℝ] (ι → ℝ)) + +def latticeImageProjection : Λ →ₗ[ℤ] latticeImage Λ π := + ((π.restrictScalars ℤ).comp Λ.subtype).codRestrict (latticeImage Λ π) + (fun x => ⟨x.val, x.property, rfl⟩) + +theorem latticeImageProjection_apply (x : Λ) : + (latticeImageProjection Λ π x).val = π x.val := rfl + +theorem latticeImageProjection_surjective : Function.Surjective (latticeImageProjection Λ π) := by + rintro ⟨y, x, hx, hxy⟩ + exact ⟨⟨x, hx⟩, Subtype.ext hxy⟩ + +noncomputable def latticeKernelEquiv : + latticeKernel Λ π ≃ₗ[ℤ] LinearMap.ker (latticeImageProjection Λ π) where + toFun x := ⟨⟨x.val.val, x.property⟩, Subtype.ext x.val.property⟩ + invFun x := ⟨⟨x.val.val, congrArg Subtype.val + (show latticeImageProjection Λ π x.val = 0 from x.property)⟩, x.val.property⟩ + left_inv _x := rfl + right_inv _x := rfl + map_add' _x _y := rfl + map_smul' _a _x := rfl + +theorem latticeKernelEquiv_apply (x : latticeKernel Λ π) : + ((latticeKernelEquiv Λ π x).val : E) = x.val.val := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_lattice_split_basis + {E ι α β : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (Λ : Submodule ℤ E) (π : E →ₗ[ℝ] (ι → ℝ)) + (bK : Basis α ℤ (latticeKernel Λ π)) (bI : Basis β ℤ (latticeImage Λ π)) : + ∃ b : Basis (α ⊕ β) ℤ Λ, + (∀ i, (b (Sum.inl i) : E) = (bK i).val.val) ∧ + (∀ j, π (b (Sum.inr j) : E) = (bI j).val) := by + let : Free ℤ (latticeImage Λ π) := Free.of_basis bI + obtain ⟨b, hbK, hbI⟩ := exists_basis_of_surjection (latticeImageProjection Λ π) + (latticeImageProjection_surjective Λ π) (bK.map (latticeKernelEquiv Λ π)) bI + refine ⟨b, ?_, ?_⟩ + · intro i + rw [hbK] + rfl + · intro j + exact congrArg Subtype.val (hbI j) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_lattice_basis_covolume_factor + {E ι α β : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [Fintype ι] [Fintype α] [Fintype β] [DecidableEq β] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (π : E →ₗ[ℝ] (ι → ℝ)) [IsZLattice ℝ (latticeKernel Λ π)] + (bK : Basis α ℤ (latticeKernel Λ π)) (bI : Basis β ℤ (latticeImage Λ π)) : + ∃ b : Basis (α ⊕ β) ℤ Λ, + (∀ i, (b (Sum.inl i) : E) = (bK i).val.val) ∧ + (∀ j, π (b (Sum.inr j) : E) = (bI j).val) ∧ + ZLattice.covolume Λ ^ 2 = ZLattice.covolume (latticeKernel Λ π) ^ 2 * + (Matrix.gram ℝ (fun j : β => (b (Sum.inr j) : E) - + (LinearMap.ker π).starProjection (b (Sum.inr j) : E))).det := by + classical + obtain ⟨b, hbK, hbI⟩ := exists_lattice_split_basis Λ π bK bI + refine ⟨b, hbK, hbI, ?_⟩ + let bR := b.ofZLatticeBasis ℝ Λ + let bKR := bK.ofZLatticeBasis ℝ (latticeKernel Λ π) + have hval (i : α) : bR (Sum.inl i) = (bKR i : E) := by + simpa only [bR, bKR, Basis.ofZLatticeBasis_apply] using hbK i + have hspan : Submodule.span ℝ (Set.range (fun i : α => bR (Sum.inl i))) = + LinearMap.ker π := by + rw [show (fun i : α => bR (Sum.inl i)) = (fun i : α => (bKR i : E)) from funext hval] + change Submodule.span ℝ (Set.range ((LinearMap.ker π).subtype ∘ bKR)) = _ + rw [Set.range_comp, ← Submodule.map_span, bKR.span_eq, + Submodule.map_top, Submodule.range_subtype] + have hkernelGram : (Matrix.gram ℝ (fun i : α => bR (Sum.inl i))).det = + ZLattice.covolume (latticeKernel Λ π) ^ 2 := by + have he : Matrix.gram ℝ (fun i : α => bR (Sum.inl i)) = Matrix.gram ℝ bKR := by + ext i j + simp only [Matrix.gram_apply, hval] + rfl + rw [he] + exact (lattice_covolume_sq_eq_gram (latticeKernel Λ π) bK).symm + have hblock := gram_det_orthogonal_block bR + dsimp only at hblock + rw [hspan, hkernelGram] at hblock + rw [lattice_covolume_sq_eq_gram Λ b] + simpa only [bR, Basis.ofZLatticeBasis_apply] using hblock + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_lattice_index_covolume_factor + {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [Fintype ι] [DecidableEq ι] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (π : E →ₗ[ℝ] (ι → ℝ)) + (hinteger : ∀ x ∈ Λ, π x ∈ realIntegerGrid) (hsurj : Function.Surjective π) : + ∃ L : (ι → ℝ) →ₗ[ℝ] E, + (∀ y, π (L y) = y) ∧ + (∀ x, L (π x) = x - (LinearMap.ker π).starProjection x) ∧ + ZLattice.covolume Λ ^ 2 = + ZLattice.covolume (latticeKernel Λ π) ^ 2 * + ((latticeImage Λ π).toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup : ℝ) ^ 2 * + (Matrix.gram ℝ (fun i : ι => L (Pi.basisFun ℝ ι i))).det := by + classical + let H := latticeImage Λ π + let K := latticeKernel Λ π + let : DiscreteTopology H := latticeImage_discrete Λ π hinteger + let : IsZLattice ℝ H := latticeImage_full Λ π hsurj + let : IsZLattice ℝ K := latticeKernel_full Λ π hinteger + let bK := Free.chooseBasis ℤ K + let bI := IsZLattice.basis H + let B := bI.ofZLatticeBasis ℝ H + obtain ⟨L, hright, hsection⟩ := exists_orthogonal_section π hsurj + have hL : Function.Injective L := by + intro x y hxy + have h := congrArg π hxy + simpa only [hright] using h + obtain ⟨b, _, hbI, hcov⟩ := exists_lattice_basis_covolume_factor Λ π bK bI + have hw (j : ι) : (b (Sum.inr j) : E) - + (LinearMap.ker π).starProjection (b (Sum.inr j) : E) = L (B j) := by + rw [← hsection] + apply congrArg L + simpa only [B, Basis.ofZLatticeBasis_apply] using hbI j + have hcov' : ZLattice.covolume Λ ^ 2 = ZLattice.covolume K ^ 2 * + (Matrix.gram ℝ (fun j : ι => L (B j))).det := by + simpa only [hw] using hcov + have hgram := gram_det_injective_map_basis L hL (Pi.basisFun ℝ ι) B + have hB : (B : ι → (ι → ℝ)) = fun j => (bI j).val := by + funext j + exact bI.ofZLatticeBasis_apply ℝ H j + have hdet : |(Pi.basisFun ℝ ι).det B| = + ((latticeImage Λ π).toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup : ℝ) := by + rw [Pi.basisFun_det_apply, hB] + exact (ZLattice.covolume_eq_det H bI).symm.trans + (integer_lattice_covolume_eq_index H (latticeImage_le_integer Λ π hinteger)) + have hsq := congrArg (fun t : ℝ => t ^ 2) hdet + rw [sq_abs] at hsq + refine ⟨L, hright, hsection, ?_⟩ + rw [hgram, hsq] at hcov' + simpa only [mul_assoc] using hcov' + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_lattice_covolume_identity + {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [Fintype ι] [DecidableEq ι] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (π : E →ₗ[ℝ] (ι → ℝ)) + (hinteger : ∀ x ∈ Λ, π x ∈ realIntegerGrid) (hsurj : Function.Surjective π) : + ∃ L : (ι → ℝ) →ₗ[ℝ] E, + (∀ y, π (L y) = y) ∧ + (∀ x, L (π x) = x - (LinearMap.ker π).starProjection x) ∧ + ZLattice.covolume Λ = ZLattice.covolume (latticeKernel Λ π) * + ((latticeImage Λ π).toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup : ℝ) * + Real.sqrt (Matrix.gram ℝ (fun i : ι => L (Pi.basisFun ℝ ι i))).det := by + let : IsZLattice ℝ (latticeKernel Λ π) := latticeKernel_full Λ π hinteger + obtain ⟨L, hright, hsection, hsq⟩ := exists_lattice_index_covolume_factor Λ π hinteger hsurj + refine ⟨L, hright, hsection, ?_⟩ + have h := congrArg Real.sqrt hsq + rw [Real.sqrt_sq (ZLattice.covolume_pos Λ MeasureTheory.volume).le] at h + rw [Real.sqrt_mul (mul_nonneg (sq_nonneg _) (sq_nonneg _)), + Real.sqrt_mul (sq_nonneg _), + Real.sqrt_sq (ZLattice.covolume_pos (latticeKernel Λ π) MeasureTheory.volume).le, + Real.sqrt_sq (Nat.cast_nonneg _)] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_scaled_lattice_covolume_identity + {E ι : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + [Fintype ι] [DecidableEq ι] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + (π : E →ₗ[ℝ] (ι → ℝ)) + (hinteger : ∀ x ∈ Λ, π x ∈ realIntegerGrid) (hsurj : Function.Surjective π) + (T : ι → ℝ) (hT : ∀ i, 0 < T i) : + ∃ G : (ι → ℝ) →ₗ[ℝ] E, + (∀ y, π (G y) = fun i => T i * y i) ∧ + (∀ x, G (fun i => π x i / T i) = x - (LinearMap.ker π).starProjection x) ∧ + ZLattice.covolume Λ = ZLattice.covolume (latticeKernel Λ π) * + (((latticeImage Λ π).toAddSubgroup.relIndex integerCoordinateLattice.toAddSubgroup : ℝ) / + ∏ i, T i) * + Real.sqrt (Matrix.gram ℝ (fun i : ι => G (Pi.basisFun ℝ ι i))).det := by + obtain ⟨L, hright, hsection, hcov⟩ := exists_lattice_covolume_identity Λ π hinteger hsurj + let D := coordinateScaleEquiv T (fun i => (hT i).ne') + let G := L.comp D.toLinearMap + have hL : Function.Injective L := by + intro x y hxy + have h := congrArg π hxy + simpa only [hright] using h + have hscale := scaled_section_gram_sqrt L hL T hT + have hprod : 0 < ∏ i, T i := Finset.prod_pos (fun i _ => hT i) + have hroot : Real.sqrt (Matrix.gram ℝ (fun i : ι => L (Pi.basisFun ℝ ι i))).det = + Real.sqrt (Matrix.gram ℝ (fun i : ι => G (Pi.basisFun ℝ ι i))).det / ∏ i, T i := by + apply (eq_div_iff hprod.ne').mpr + dsimp only [G, D, LinearMap.comp_apply, LinearEquiv.coe_coe] + rw [hscale] + ring + refine ⟨G, ?_, ?_, ?_⟩ + · intro y + exact hright (D y) + · intro x + change L (D (D.symm (π x))) = x - (LinearMap.ker π).starProjection x + rw [LinearEquiv.apply_symm_apply] + exact hsection x + · rw [hroot] at hcov + rw [hcov] + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ScoredCRTWindowPatch.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ScoredCRTWindowPatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..58313b793d2580401f025c163406f73bd23a9272 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ScoredCRTWindowPatch.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialPatchComposition +import OAI.Combinatorics.Progressions.Polynomial.ScoredCyclicPolynomialPatch + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +universe u + +theorem exists_scored_windowed_crt_patch (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {J : Type*} [Fintype J] [DecidableEq J] + (N : J → ℕ) [∀ j, NeZero (N j)] [NeZero (∏ j, N j)] + (hN : Pairwise (fun i j => Nat.Coprime (N i) (N j))) + (T : ZMod (∏ j, N j) → ℝ) (w : RepresentativeWindow) + (a : ((j : J) → ZMod (N j)) → ℝ) {p : ℝ}, + 0 ≤ p → PositiveCyclicNiltest.{u} s (∏ j, N j) p T → + Real.log (2 + (w.lip : ℝ)) ≤ p → + Real.exp (-p) ≤ (𝔼 x, (a x * T ((ZMod.prodEquivPi N hN).symm x)) * + w.value ((((ZMod.prodEquivPi N hN).symm x).val : ℝ) / (∏ j, N j : ℕ))) → + ∃ d : ℕ, ∃ P : PolynomialPatch J s d, + (d : ℝ) + Real.log (2 + (P.kernel.lip : ℝ)) ≤ (p + 2) ^ C ∧ + Real.exp (-((p + 2) ^ C)) ≤ (𝔼 x, a x * P.value (fun j => ((x j).val : ℝ))) := by + obtain ⟨A, _, hconvert⟩ := exists_scored_cyclic_patch.{u} s + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + ((Polynomial.X + 2) ^ A + Polynomial.X + 1) + refine ⟨C, hC, ?_⟩ + intro J _ _ N _ _ hN T w a p hp hT hw hscore + let b := fun x : (j : J) → ZMod (N j) => + a x * w.value ((((ZMod.prodEquivPi N hN).symm x).val : ℝ) / (∏ j, N j : ℕ)) + have hscore' : Real.exp (-p) ≤ (𝔼 x, b x * T ((ZMod.prodEquivPi N hN).symm x)) := by + have heq : (𝔼 x, b x * T ((ZMod.prodEquivPi N hN).symm x)) = + (𝔼 x, (a x * T ((ZMod.prodEquivPi N hN).symm x)) * + w.value ((((ZMod.prodEquivPi N hN).symm x).val : ℝ) / (∏ j, N j : ℕ))) := by + apply Finset.expect_congr rfl + intro x _ + dsimp only [b] + ring + rw [heq] + exact hscore + obtain ⟨d, Q, hQ, hscoreQ⟩ := hconvert T b (ZMod.prodEquivPi N hN).symm hp hT hscore' + let P := w.composeCRTPatch N hN s hs Q + have hcost : ((1 + d : ℕ) : ℝ) + Real.log (2 + (P.kernel.lip : ℝ)) ≤ + (p + 2) ^ A + p + 1 := w.composeCRTPatch_cost N hN s hs Q hQ hw + have hb : (p + 2) ^ A + p + 1 ≤ (p + 2) ^ C := by + simpa [Polynomial.eval₂_pow] using hbudget p hp + have hsame : (𝔼 x, a x * P.value (fun j => ((x j).val : ℝ))) = + (𝔼 x, b x * Q.value (fun _ => (((ZMod.prodEquivPi N hN).symm x).val : ℝ))) := by + apply Finset.expect_congr rfl + intro x _ + rw [show P.value (fun j => ((x j).val : ℝ)) = _ from + w.composeCRTPatch_value_residues N hN s hs Q x] + dsimp only [b] + ring + refine ⟨1 + d, P, hcost.trans hb, ?_⟩ + rw [hsame] + exact (Real.exp_le_exp.mpr (neg_le_neg (show (p + 2) ^ A ≤ (p + 2) ^ C by linarith))).trans hscoreQ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueApproximation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc44544b0e27cd0c164b4b6ab8051e7e3cc98c68 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueApproximation.lean @@ -0,0 +1,808 @@ +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Estimates.RowShiftTopSymbol +import OAI.Combinatorics.Progressions.Estimates.ShiftedSmoothProductAmplitudeTransfer +import OAI.Combinatorics.Progressions.Estimates.ShiftedSmoothSelectedMarginal +import OAI.Combinatorics.Progressions.Geometry.FiniteSupportApproximation + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def integerRowShift {K I : Type*} {h : ℕ} {N : I → ℕ} + (rows : Fin h → K → ℤ) (s : I → ℕ) (x : Fin h → ∀ j, Fin (N j)) : K × I → ℤ := + fun z => ∑ i, rows i z.1 * ((s z.2 : ℤ) * (x i z.2).val) + +theorem integerRowShift_real {K I : Type*} {h : ℕ} {N : I → ℕ} + (rows : Fin h → K → ℤ) (s : I → ℕ) (x : Fin h → ∀ j, Fin (N j)) + (b : K × I → ℤ) (k : K) (j : I) : + (((b + integerRowShift rows s x) (k, j) : ℤ) : ℝ) = + rowShiftedTuple (fun k j => (b (k, j) : ℝ)) rows + (fun (y : ∀ j, Fin (N j)) j => (s j : ℝ) * ((y j).val : ℝ)) x k j := by + simp [integerRowShift, rowShiftedTuple, Finset.sum_apply, zsmul_eq_mul] + +theorem integerRowShift_bound {K I : Type*} {h : ℕ} {N : I → ℕ} + (rows : Fin h → K → ℤ) (s : I → ℕ) (x : Fin h → ∀ j, Fin (N j)) + {C : ℝ} (hC : 0 ≤ C) (hrows : ∀ i k, |(rows i k : ℝ)| ≤ C) (z : K × I) : + |(integerRowShift rows s x z : ℝ)| ≤ (h : ℝ) * C * ((s z.2 : ℝ) * (N z.2 : ℝ)) := by + simp only [integerRowShift, Int.cast_sum, Int.cast_mul, Int.cast_natCast] + calc + |∑ i, (rows i z.1 : ℝ) * ((s z.2 : ℝ) * ((x i z.2).val : ℝ))| ≤ + ∑ i, |(rows i z.1 : ℝ) * ((s z.2 : ℝ) * ((x i z.2).val : ℝ))| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : Fin h, C * ((s z.2 : ℝ) * (N z.2 : ℝ)) := by + apply Finset.sum_le_sum + intro i _ + rw [abs_mul, abs_of_nonneg (mul_nonneg (Nat.cast_nonneg (s z.2)) + (Nat.cast_nonneg (x i z.2).val) : (0 : ℝ) ≤ (s z.2 : ℝ) * ((x i z.2).val : ℝ))] + have hx : ((x i z.2).val : ℝ) ≤ (N z.2 : ℝ) := by exact_mod_cast (x i z.2).isLt.le + exact mul_le_mul (hrows i z.1) + (mul_le_mul_of_nonneg_left hx (Nat.cast_nonneg _)) (by positivity) hC + _ = _ := by simp; ring + +theorem integerRowShift_normalized_bound {K I : Type*} [Fintype K] [Fintype I] + {h : ℕ} {N : I → ℕ} (rows : Fin h → K → ℤ) (s : I → ℕ) + (x : Fin h → ∀ j, Fin (N j)) (S : K × I → ℝ) (hS : ∀ z, 0 < S z) + {C ε : ℝ} (hC : 0 ≤ C) (hrows : ∀ i k, |(rows i k : ℝ)| ≤ C) (hε : 0 ≤ ε) + (hscale : ∀ z, (h : ℝ) * C * ((s z.2 : ℝ) * (N z.2 : ℝ)) ≤ ε * S z) : + ‖rectangularLatticePoint 0 S (integerRowShift rows s x)‖ ≤ ε := by + rw [rectangularLatticePoint_zero_origin] + apply (pi_norm_le_iff_of_nonneg hε).mpr + intro z + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hS z)] + apply (div_le_iff₀ (hS z)).mpr + exact (integerRowShift_bound rows s x hC hrows z).trans (hscale z) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def residueLatticeArray {K I : Type*} (residue : K × I → ℤ) (modulus : I → ℕ) + (x : K × I → ℤ) : K × I → ℤ := + fun z => residue z + (modulus z.2 : ℤ) * x z + +noncomputable def residueProfileCenter {K I : Type*} + (residue : K × I → ℤ) (modulus : I → ℕ) : K × I → ℝ := + fun z => -(residue z : ℝ) / modulus z.2 + +noncomputable def residueProfileWidth {K I : Type*} + (modulus : I → ℕ) (V : K × I → ℝ) : K × I → ℝ := fun z => V z / modulus z.2 + +theorem residueProfileWidth_pos {K I : Type*} (modulus : I → ℕ) (V : K × I → ℝ) + (hmodulus : ∀ j, 0 < modulus j) (hV : ∀ z, 0 < V z) (z : K × I) : + 0 < residueProfileWidth modulus V z := + div_pos (hV z) (by exact_mod_cast hmodulus z.2) + +theorem residueLatticeArray_rowShift {K I : Type*} {h : ℕ} {N : I → ℕ} + (residue : K × I → ℤ) (modulus : I → ℕ) (rows : Fin h → K → ℤ) + (u : Fin h → ∀ j, Fin (N j)) (x : K × I → ℤ) (k : K) (j : I) : + ((residueLatticeArray residue modulus (x + integerRowShift rows (fun _ => 1) u) (k, j) : ℤ) : ℝ) = + rowShiftedTuple (fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ)) rows + (fun (y : ∀ j, Fin (N j)) j => (modulus j : ℝ) * ((y j).val : ℝ)) u k j := by + simp only [residueLatticeArray, integerRowShift, rowShiftedTuple, Pi.add_apply, + Int.cast_add, Int.cast_mul, Int.cast_sum, Int.cast_natCast, Nat.cast_one, one_mul, + Finset.sum_apply, zsmul_eq_mul] + rw [mul_add, Finset.mul_sum, ← add_assoc] + congr 1 + apply Finset.sum_congr rfl + intro i _ + simp only [Pi.mul_apply, Pi.intCast_apply] + ring + +theorem residueRowShift_normalized_bound {K I : Type*} [Fintype K] [Fintype I] + {h : ℕ} {N : I → ℕ} (rows : Fin h → K → ℤ) (modulus : I → ℕ) + (hmodulus : ∀ j, 0 < modulus j) (u : Fin h → ∀ j, Fin (N j)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + {C r : ℝ} (hC : 0 ≤ C) (hrows : ∀ i k, |(rows i k : ℝ)| ≤ C) (hr : 0 ≤ r) + (hmove : ∀ z, (h : ℝ) * C * ((modulus z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) : + ‖rectangularLatticePoint 0 (residueProfileWidth modulus V) + (integerRowShift rows (fun _ => 1) u)‖ ≤ r := by + apply integerRowShift_normalized_bound rows (fun _ => 1) u _ + (residueProfileWidth_pos modulus V hmodulus hV) hC hrows hr + intro z + have hm : (0 : ℝ) < modulus z.2 := by exact_mod_cast hmodulus z.2 + simp only [Nat.cast_one, one_mul, residueProfileWidth] + rw [← mul_div_assoc, le_div_iff₀ hm] + calc + (h : ℝ) * C * (N z.2 : ℝ) * (modulus z.2 : ℝ) = + (h : ℝ) * C * ((modulus z.2 : ℝ) * (N z.2 : ℝ)) := by ring + _ ≤ r * V z := hmove z + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residueProfile_point {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) (x : K × I → ℤ) : + rectangularLatticePoint (residueProfileCenter residue modulus) (residueProfileWidth modulus V) x = + fun z => (residueLatticeArray residue modulus x z : ℝ) / V z := by + funext z + have hm : (0 : ℝ) < modulus z.2 := by exact_mod_cast hmodulus z.2 + simp only [rectangularLatticePoint, residueProfileCenter, residueProfileWidth, + residueLatticeArray, Int.cast_add, Int.cast_mul, Int.cast_natCast] + field_simp [hm.ne', (hV z).ne'] + ring + +noncomputable def residueSmoothIndexPMF {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) : PMF (K × I → ℤ) := + shiftedSmoothProductPMF (residueProfileCenter residue modulus) (residueProfileWidth modulus V) + (residueProfileWidth_pos modulus V hmodulus hV) hZ + +theorem residueSmoothIndexPMF_toReal {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (x : K × I → ℤ) : + (residueSmoothIndexPMF residue modulus hmodulus V hV hZ x).toReal = + smoothProductProfile (K × I) (fun z => (residueLatticeArray residue modulus x z : ℝ) / V z) / + ∑' y, smoothProductProfile (K × I) + (fun z => (residueLatticeArray residue modulus y z : ℝ) / V z) := by + simp only [residueSmoothIndexPMF, shiftedSmoothProductPMF_toReal, shiftedSmoothProductMass, + rectangularWeight, residueProfile_point residue modulus hmodulus V hV] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residueLatticeArray_injective {K I : Type*} + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) : + Function.Injective (residueLatticeArray residue modulus) := by + intro x y he + funext z + have hm : (modulus z.2 : ℤ) ≠ 0 := by exact_mod_cast (hmodulus z.2).ne' + exact mul_left_cancel₀ hm (add_left_cancel (congrFun he z)) + +theorem residueLatticeArray_range {K I : Type*} + (residue : K × I → ℤ) (modulus : I → ℕ) (y : K × I → ℤ) : + y ∈ Set.range (residueLatticeArray residue modulus) ↔ + ∀ z, (modulus z.2 : ℤ) ∣ y z - residue z := by + constructor + · rintro ⟨x, rfl⟩ z + exact ⟨x z, by simp only [residueLatticeArray, add_sub_cancel_left]⟩ + · intro h + classical + refine ⟨fun z => (h z).choose, ?_⟩ + funext z + have hz := (h z).choose_spec + change residue z + (modulus z.2 : ℤ) * (h z).choose = y z + omega + +noncomputable def residueSmoothPMF {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) : PMF (K × I → ℤ) := + (residueSmoothIndexPMF residue modulus hmodulus V hV hZ).map + (residueLatticeArray residue modulus) + +theorem residueSmoothPMF_at {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (x : K × I → ℤ) : + (residueSmoothPMF residue modulus hmodulus V hV hZ + (residueLatticeArray residue modulus x)).toReal = + smoothProductProfile (K × I) (fun z => (residueLatticeArray residue modulus x z : ℝ) / V z) / + ∑' y, smoothProductProfile (K × I) + (fun z => (residueLatticeArray residue modulus y z : ℝ) / V z) := by + rw [residueSmoothPMF, pmf_map_injective_at _ _ (residueLatticeArray_injective residue modulus hmodulus)] + exact residueSmoothIndexPMF_toReal residue modulus hmodulus V hV hZ x + +theorem residueSmoothPMF_zero_off {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (y : K × I → ℤ) + (hy : ¬∀ z, (modulus z.2 : ℤ) ∣ y z - residue z) : + residueSmoothPMF residue modulus hmodulus V hV hZ y = 0 := by + exact pmf_map_zero_off_range _ _ y (by rwa [residueLatticeArray_range]) + +theorem residueSmoothPMF_expectation {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (φ : (K × I → ℤ) → ℂ) : + (∑' y, ((residueSmoothPMF residue modulus hmodulus V hV hZ y).toReal : ℂ) * φ y) = + ∑' x, ((residueSmoothIndexPMF residue modulus hmodulus V hV hZ x).toReal : ℂ) * + φ (residueLatticeArray residue modulus x) := + pmf_map_injective_expectation _ _ (residueLatticeArray_injective residue modulus hmodulus) φ + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def residueSmoothScalarPMFs {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) : K × I → PMF ℤ := + fun z => shiftedSmoothCoefficientPMF + (residueProfileCenter residue modulus z) (residueProfileWidth modulus V z) + (residueProfileWidth_pos modulus V hmodulus hV z) + (shiftedSmoothProductMass_coordinate_pos + (residueProfileCenter residue modulus) (residueProfileWidth modulus V) + (residueProfileWidth_pos modulus V hmodulus hV) hZ z) + +theorem residueSmoothIndexPMF_eq_independent {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) : + residueSmoothIndexPMF residue modulus hmodulus V hV hZ = + independentProductPMF (residueSmoothScalarPMFs residue modulus hmodulus V hV hZ) := + shiftedSmoothProductPMF_eq_independent + (residueProfileCenter residue modulus) (residueProfileWidth modulus V) + (residueProfileWidth_pos modulus V hmodulus hV) hZ + +theorem residueSmoothIndexPMF_selected_marginal {A K I : Type*} + [Fintype A] [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (e : A ↪ K × I) : + (residueSmoothIndexPMF residue modulus hmodulus V hV hZ).map + (fun x a => x (e a)) = + independentProductPMF + (fun a => residueSmoothScalarPMFs residue modulus hmodulus V hV hZ (e a)) := by + rw [residueSmoothIndexPMF_eq_independent] + exact independentProductPMF_marginal _ e e.injective + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem residue_smooth_row_shift_transfer {K I : Type*} + [Fintype K] [Fintype I] [DecidableEq I] {h : ℕ} + (N modulus : I → ℕ) (hN : ∀ j, 0 < N j) (hmodulus : ∀ j, 0 < modulus j) + (rows : Fin h → K → ℤ) (residue : K × I → ℤ) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth modulus V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hmesh : ∀ z, 1 / residueProfileWidth modulus V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (K × I) * + ((Fintype.card (K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {C r B : ℝ} (hC : 0 ≤ C) (hrows : ∀ i k, |(rows i k : ℝ)| ≤ C) (hr : 0 ≤ r) + (hmove : ∀ z, (h : ℝ) * C * ((modulus z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (Φ : (K → I → ℝ) → ℂ) (hΦ : ∀ b, ‖Φ b‖ ≤ 1) + (hlocal : ∀ b : K → I → ℝ, + ‖𝔼 x : Fin h → ∀ j, Fin (N j), + Φ (rowShiftedTuple b rows + (fun (y : ∀ j, Fin (N j)) j => (modulus j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ B) : + ‖∑' x, ((residueSmoothIndexPMF residue modulus hmodulus V hV hZ x).toReal : ℂ) * + Φ (fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (K × I) * + ((Fintype.card (K × I) : ℝ) * probabilityProfileLipschitz) * r + B := by + let : ∀ j, Nonempty (Fin (N j)) := fun j => ⟨⟨0, hN j⟩⟩ + apply shiftedSmoothProductPMF_shift_transfer (residueProfileCenter residue modulus) + (residueProfileWidth modulus V) (residueProfileWidth_pos modulus V hmodulus hV) + hZ hV1 hδ hδ1 hmesh hsmall (integerRowShift (N := N) rows (fun _ => 1)) + (fun x => residueRowShift_normalized_bound rows modulus hmodulus x V hV hC hrows hr hmove) + (fun x => Φ (fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ))) (fun _ => hΦ _) + intro x + simpa only [residueLatticeArray_rowShift] using + hlocal (fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical NNReal + +theorem residue_smooth_row_shift_transfer_lipschitz_amplitude {K I : Type*} + [Fintype K] [Fintype I] [DecidableEq I] {h : ℕ} + (N modulus : I → ℕ) (hN : ∀ j, 0 < N j) (hmodulus : ∀ j, 0 < modulus j) + (rows : Fin h → K → ℤ) (residue : K × I → ℤ) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth modulus V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hmesh : ∀ z, 1 / residueProfileWidth modulus V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (K × I) * + ((Fintype.card (K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {C r B : ℝ} (hC : 0 ≤ C) (hrows : ∀ i k, |(rows i k : ℝ)| ≤ C) (hr : 0 ≤ r) + (hmove : ∀ z, (h : ℝ) * C * ((modulus z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (Φ : (K → I → ℝ) → ℂ) (hΦ : ∀ b, ‖Φ b‖ ≤ 1) + (hlocal : ∀ b : K → I → ℝ, + ‖𝔼 x : Fin h → ∀ j, Fin (N j), + Φ (rowShiftedTuple b rows + (fun (y : ∀ j, Fin (N j)) j => (modulus j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ B) + (F : (K × I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) + {Lip : ℝ≥0} (hLip : LipschitzWith Lip F) : + ‖∑' x, ((residueSmoothIndexPMF residue modulus hmodulus V hV hZ x).toReal : ℂ) * + (F (fun z => (residueLatticeArray residue modulus x z : ℝ) / V z) * + Φ (fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ)))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (K × I) * + ((Fintype.card (K × I) : ℝ) * probabilityProfileLipschitz) * r + (Lip : ℝ) * r + B := by + let : ∀ j, Nonempty (Fin (N j)) := fun j => ⟨⟨0, hN j⟩⟩ + have ht := shiftedSmoothProductPMF_shift_transfer_lipschitz_amplitude + (residueProfileCenter residue modulus) + (residueProfileWidth modulus V) (residueProfileWidth_pos modulus V hmodulus hV) + hZ hV1 hδ hδ1 hmesh hsmall (integerRowShift (N := N) rows (fun _ => 1)) + (fun x => residueRowShift_normalized_bound rows modulus hmodulus x V hV hC hrows hr hmove) + (fun x => Φ (fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ))) + (fun _ => hΦ _) (fun x => by + simpa only [residueLatticeArray_rowShift] using + hlocal (fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ))) F hF hLip + simpa only [residueSmoothIndexPMF, residueProfile_point residue modulus hmodulus V hV] + using ht + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def residueSmoothWeight {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (V : K × I → ℝ) (y : K × I → ℤ) : ℝ := by + classical + exact if ∀ z, (modulus z.2 : ℤ) ∣ y z - residue z then + smoothProductProfile (K × I) (fun z => (y z : ℝ) / V z) else 0 + +theorem residueSmoothWeight_at {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (V : K × I → ℝ) (x : K × I → ℤ) : + residueSmoothWeight residue modulus V (residueLatticeArray residue modulus x) = + smoothProductProfile (K × I) (fun z => (residueLatticeArray residue modulus x z : ℝ) / V z) := by + have hc := (residueLatticeArray_range residue modulus _).mp ⟨x, rfl⟩ + simp [residueSmoothWeight, hc] + +theorem residueSmoothWeight_mass {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) : + shiftedSmoothProductMass (residueProfileCenter residue modulus) (residueProfileWidth modulus V) = + ∑' y, residueSmoothWeight residue modulus V y := by + have hs : Function.support (residueSmoothWeight residue modulus V) ⊆ + Set.range (residueLatticeArray residue modulus) := by + intro y hy + apply (residueLatticeArray_range residue modulus y).mpr + by_contra hn + exact hy (by simp only [residueSmoothWeight, hn, ite_false]) + have he := (residueLatticeArray_injective residue modulus hmodulus).tsum_eq hs + simpa only [shiftedSmoothProductMass, rectangularWeight, + residueProfile_point residue modulus hmodulus V hV, residueSmoothWeight_at] using he + +theorem residueSmoothPMF_conditional_weight {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) (y : K × I → ℤ) : + (residueSmoothPMF residue modulus hmodulus V hV hZ y).toReal = + residueSmoothWeight residue modulus V y / ∑' z, residueSmoothWeight residue modulus V z := by + classical + by_cases hc : ∀ z, (modulus z.2 : ℤ) ∣ y z - residue z + · obtain ⟨x, rfl⟩ := (residueLatticeArray_range residue modulus y).mpr hc + rw [residueSmoothWeight_at, ← residueSmoothWeight_mass residue modulus hmodulus V hV] + have he := residueSmoothPMF_at residue modulus hmodulus V hV hZ x + simpa only [shiftedSmoothProductMass, rectangularWeight, + residueProfile_point residue modulus hmodulus V hV] using he + · simp only [residueSmoothPMF_zero_off residue modulus hmodulus V hV hZ y hc, + ENNReal.toReal_zero, residueSmoothWeight, hc, ite_false, zero_div] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem rowShiftedTuple_add_base {h : ℕ} {K X V : Type*} [AddCommGroup V] + (origin base : K → V) (rows : Fin h → K → ℤ) (shift : X → V) + (x : Fin h → X) : + rowShiftedTuple (origin + base) rows shift x = + origin + rowShiftedTuple base rows shift x := by + funext k + simp only [rowShiftedTuple, Pi.add_apply, add_assoc] + +theorem anchored_residue_smooth_row_shift_transfer {K I : Type*} + [Fintype K] [Fintype I] [DecidableEq I] {h : ℕ} + (origin : K → I → ℝ) + (N modulus : I → ℕ) (hN : ∀ j, 0 < N j) (hmodulus : ∀ j, 0 < modulus j) + (rows : Fin h → K → ℤ) (residue : K × I → ℤ) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue modulus) + (residueProfileWidth modulus V)) + (hV1 : ∀ z, 1 ≤ residueProfileWidth modulus V z) + {δ : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (hmesh : ∀ z, 1 / residueProfileWidth modulus V z ≤ δ) + (hsmall : (4 : ℝ) ^ Fintype.card (K × I) * + ((Fintype.card (K × I) : ℝ) * probabilityProfileLipschitz) * δ ≤ 1 / 2) + {C r B : ℝ} (hC : 0 ≤ C) (hrows : ∀ i k, |(rows i k : ℝ)| ≤ C) (hr : 0 ≤ r) + (hmove : ∀ z, (h : ℝ) * C * ((modulus z.2 : ℝ) * (N z.2 : ℝ)) ≤ r * V z) + (Φ : (K → I → ℝ) → ℂ) (hΦ : ∀ b, ‖Φ b‖ ≤ 1) + (hlocal : ∀ b : K → I → ℝ, + ‖𝔼 x : Fin h → ∀ j, Fin (N j), + Φ (rowShiftedTuple b rows + (fun (y : ∀ j, Fin (N j)) j => (modulus j : ℝ) * ((y j).val : ℝ)) x)‖ ≤ B) : + ‖∑' x, ((residueSmoothIndexPMF residue modulus hmodulus V hV hZ x).toReal : ℂ) * + Φ (origin + fun k j => (residueLatticeArray residue modulus x (k, j) : ℝ))‖ ≤ + 4 * (3 : ℝ) ^ Fintype.card (K × I) * + ((Fintype.card (K × I) : ℝ) * probabilityProfileLipschitz) * r + B := by + apply residue_smooth_row_shift_transfer N modulus hN hmodulus rows residue V hV hZ hV1 + hδ hδ1 hmesh hsmall hC hrows hr hmove (fun b => Φ (origin + b)) (fun b => hΦ _) + intro base + simpa only [rowShiftedTuple_add_base] using hlocal (origin + base) + +end Erdos3 + +end + +section + +namespace Erdos3 + +abbrev ColumnResiduePattern (K I : Type*) (modulus : I → ℕ) := + ∀ z : K × I, ZMod (modulus z.2) + +def columnResiduePattern {K I : Type*} (modulus : I → ℕ) (x : K × I → ℤ) : + ColumnResiduePattern K I modulus := fun z => x z + +noncomputable def columnResidueRepresentative {K I : Type*} (modulus : I → ℕ) + (r : ColumnResiduePattern K I modulus) : K × I → ℤ := + fun z => (ZMod.intCast_surjective (r z)).choose + +theorem columnResidueRepresentative_cast {K I : Type*} (modulus : I → ℕ) + (r : ColumnResiduePattern K I modulus) (z : K × I) : + (columnResidueRepresentative modulus r z : ZMod (modulus z.2)) = r z := + (ZMod.intCast_surjective (r z)).choose_spec + +theorem columnResiduePattern_eq_iff {K I : Type*} (modulus : I → ℕ) + (r : ColumnResiduePattern K I modulus) (x : K × I → ℤ) : + columnResiduePattern modulus x = r ↔ + ∀ z, (modulus z.2 : ℤ) ∣ x z - columnResidueRepresentative modulus r z := by + constructor + · intro he z + apply (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mp + rw [Int.cast_sub, columnResidueRepresentative_cast] + exact sub_eq_zero.mpr (congrFun he z) + · intro h + funext z + have hz := (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mpr (h z) + rw [Int.cast_sub, columnResidueRepresentative_cast, sub_eq_zero] at hz + exact hz + +theorem residueSmoothWeight_eq_pattern {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (r : ColumnResiduePattern K I modulus) + (V : K × I → ℝ) (x : K × I → ℤ) : + residueSmoothWeight (columnResidueRepresentative modulus r) modulus V x = + if columnResiduePattern modulus x = r then + smoothProductProfile (K × I) (fun z => (x z : ℝ) / V z) else 0 := by + classical + simp only [residueSmoothWeight, ← columnResiduePattern_eq_iff] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem integerArrayFrame_add {K I : Type*} (anchor z : K × I → ℤ) : + (fun k i => ((anchor + z) (k,i) : ℝ)) = + (fun k i => (anchor (k,i) : ℝ)) + (fun k i => (z (k,i) : ℝ)) := by + funext k i + simp only [Pi.add_apply, Int.cast_add] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem residueSmoothWeight_congr {K X : Type*} [Fintype K] [Fintype X] + (r s : K × X → ℤ) (modulus : X → ℕ) (V : K × X → ℝ) + (hrs : ∀ z, (modulus z.2 : ℤ) ∣ s z - r z) : + residueSmoothWeight r modulus V = residueSmoothWeight s modulus V := by + funext y + have he : (∀ z, (modulus z.2 : ℤ) ∣ y z - r z) ↔ + ∀ z, (modulus z.2 : ℤ) ∣ y z - s z := by + constructor + · intro h z + have hid : y z - s z = (y z - r z) - (s z - r z) := by ring + rw [hid] + exact dvd_sub (h z) (hrs z) + · intro h z + have hid : y z - r z = (y z - s z) + (s z - r z) := by ring + rw [hid] + exact dvd_add (h z) (hrs z) + simp only [residueSmoothWeight, he] + +theorem residueSmoothMass_congr {K X : Type*} [Fintype K] [Fintype X] + (r s : K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hrs : ∀ z, (modulus z.2 : ℤ) ∣ s z - r z) : + shiftedSmoothProductMass (residueProfileCenter r modulus) (residueProfileWidth modulus V) = + shiftedSmoothProductMass (residueProfileCenter s modulus) (residueProfileWidth modulus V) := by + rw [residueSmoothWeight_mass r modulus hmodulus V hV, + residueSmoothWeight_mass s modulus hmodulus V hV, residueSmoothWeight_congr r s modulus V hrs] + +theorem residueSmoothPMF_congr {K X : Type*} [Fintype K] [Fintype X] + (r s : K × X → ℤ) (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hrs : ∀ z, (modulus z.2 : ℤ) ∣ s z - r z) + (hr : 0 < shiftedSmoothProductMass (residueProfileCenter r modulus) (residueProfileWidth modulus V)) + (hs : 0 < shiftedSmoothProductMass (residueProfileCenter s modulus) (residueProfileWidth modulus V)) : + residueSmoothPMF r modulus hmodulus V hV hr = residueSmoothPMF s modulus hmodulus V hV hs := by + ext y + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + simp only [residueSmoothPMF_conditional_weight, residueSmoothWeight_congr r s modulus V hrs] + +noncomputable def boundedColumnResidueRepresentative {K X : Type*} (modulus : X → ℕ) + (r : ColumnResiduePattern K X modulus) : K × X → ℤ := + fun z => columnResidueRepresentative modulus r z % (modulus z.2 : ℤ) + +theorem boundedColumnResidueRepresentative_congr {K X : Type*} (modulus : X → ℕ) + (r : ColumnResiduePattern K X modulus) (z : K × X) : + (modulus z.2 : ℤ) ∣ boundedColumnResidueRepresentative modulus r z - columnResidueRepresentative modulus r z := by + refine ⟨-(columnResidueRepresentative modulus r z / (modulus z.2 : ℤ)), ?_⟩ + have h := Int.emod_add_mul_ediv (columnResidueRepresentative modulus r z) (modulus z.2 : ℤ) + unfold boundedColumnResidueRepresentative + nlinarith + +theorem boundedColumnResidueRepresentative_bounds {K X : Type*} (modulus : X → ℕ) + (hmodulus : ∀ x, 0 < modulus x) (r : ColumnResiduePattern K X modulus) (z : K × X) : + 0 ≤ boundedColumnResidueRepresentative modulus r z ∧ + boundedColumnResidueRepresentative modulus r z < (modulus z.2 : ℤ) := by + have hq : (0 : ℤ) < modulus z.2 := by exact_mod_cast hmodulus z.2 + exact ⟨Int.emod_nonneg _ hq.ne', Int.emod_lt_of_pos _ hq⟩ + +theorem residueSmoothPMF_bounded {K X : Type*} [Fintype K] [Fintype X] + (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) (r : ColumnResiduePattern K X modulus) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hr : 0 < shiftedSmoothProductMass + (residueProfileCenter (columnResidueRepresentative modulus r) modulus) (residueProfileWidth modulus V)) : + ∃ hb : 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r) modulus) (residueProfileWidth modulus V), + residueSmoothPMF (columnResidueRepresentative modulus r) modulus hmodulus V hV hr = + residueSmoothPMF (boundedColumnResidueRepresentative modulus r) modulus hmodulus V hV hb := by + have he := residueSmoothMass_congr _ _ modulus hmodulus V hV (boundedColumnResidueRepresentative_congr modulus r) + refine ⟨he ▸ hr, residueSmoothPMF_congr _ _ modulus hmodulus V hV + (boundedColumnResidueRepresentative_congr modulus r) hr _⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def selectedResidueSmoothWeight {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (x : K × I → ℤ) : ℝ := + if columnResiduePattern modulus x ∈ G then + smoothProductProfile (K × I) (fun z => (x z : ℝ) / V z) else 0 + +theorem selectedResidueSmoothWeight_eq_sum {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (x : K × I → ℤ) : + selectedResidueSmoothWeight modulus G V x = + ∑ r : G, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V x := by + symm + calc + _ = ∑ r ∈ G, residueSmoothWeight (columnResidueRepresentative modulus r) modulus V x := + Finset.sum_coe_sort G (fun r => residueSmoothWeight (columnResidueRepresentative modulus r) modulus V x) + _ = _ := by + simp only [residueSmoothWeight_eq_pattern, Finset.sum_ite_eq, selectedResidueSmoothWeight] + +theorem residueSmoothWeight_zero_off {K I : Type*} [Fintype K] [Fintype I] + (residue : K × I → ℤ) (modulus : I → ℕ) (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (x : K × I → ℤ) (hx : x ∉ rectangularWeightIndices 0 V 1) : + residueSmoothWeight residue modulus V x = 0 := by + have hz := rectangularWeight_zero_off_indices (smoothProductProfile (K × I)) 0 V hV + (smoothProductProfile_zero_outside (K × I)) x hx + simp only [rectangularWeight, rectangularLatticePoint_zero_origin] at hz + simp only [residueSmoothWeight, hz, ite_self] + +theorem selectedResidueSmoothWeight_nonneg {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (x : K × I → ℤ) : 0 ≤ selectedResidueSmoothWeight modulus G V x := by + unfold selectedResidueSmoothWeight + split + · exact (smoothProductProfile_range (K × I) _).1 + · exact le_rfl + +theorem selectedResidueSmoothWeight_zero_off {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (x : K × I → ℤ) (hx : x ∉ rectangularWeightIndices 0 V 1) : + selectedResidueSmoothWeight modulus G V x = 0 := by + rw [selectedResidueSmoothWeight_eq_sum] + simp only [residueSmoothWeight_zero_off _ _ V hV x hx, Finset.sum_const_zero] + +theorem selectedResidueSmoothWeight_mass {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) : + (∑' x, selectedResidueSmoothWeight modulus G V x) = + ∑ r : G, ∑' x, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V x := by + simp_rw [selectedResidueSmoothWeight_eq_sum] + exact finite_supported_weight_sum_tsum _ (rectangularWeightIndices 0 V 1) + (fun r => residueSmoothWeight_zero_off _ modulus V hV) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem selectedResidueSmoothWeight_summable {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) : Summable (selectedResidueSmoothWeight modulus G V) := + (hasSum_sum_of_ne_finset_zero (selectedResidueSmoothWeight_zero_off modulus G V hV)).summable + +theorem selectedResidueSmoothWeight_mass_pos {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) (hG : G.Nonempty) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hc : ∀ r : G, 0 < ∑' x, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V x) : + 0 < ∑' x, selectedResidueSmoothWeight modulus G V x := by + obtain ⟨r, hr⟩ := hG + rw [selectedResidueSmoothWeight_mass modulus G V hV] + exact (hc ⟨r, hr⟩).trans_le + (Finset.single_le_sum (fun s _ => (hc s).le) (Finset.mem_univ (⟨r, hr⟩ : G))) + +noncomputable def selectedResidueSmoothPMF {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) : PMF (K × I → ℤ) := + realWeightPMF (selectedResidueSmoothWeight modulus G V) + (selectedResidueSmoothWeight_nonneg modulus G V) + (selectedResidueSmoothWeight_summable modulus G V hV) hZ + +theorem selectedResidueSmoothPMF_toReal {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) (x : K × I → ℤ) : + (selectedResidueSmoothPMF modulus G V hV hZ x).toReal = + selectedResidueSmoothWeight modulus G V x / ∑' y, selectedResidueSmoothWeight modulus G V y := + realWeightPMF_apply _ _ _ _ x + +theorem selectedResidueSmoothPMF_mixture {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (G : Finset (ColumnResiduePattern K I modulus)) (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (hc : ∀ r : G, 0 < shiftedSmoothProductMass + (residueProfileCenter (columnResidueRepresentative modulus r.val) modulus) (residueProfileWidth modulus V)) + (φ : (K × I → ℤ) → ℂ) : + (∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * φ x) = + ∑ r : G, (((∑' y, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V y) / + (∑' y, selectedResidueSmoothWeight modulus G V y) : ℝ) : ℂ) * + (∑' x, ((residueSmoothPMF (columnResidueRepresentative modulus r.val) modulus hmodulus V hV (hc r) x).toReal : ℂ) * φ x) := by + have hcell (r : G) : 0 < ∑' x, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V x := by + rw [← residueSmoothWeight_mass _ modulus hmodulus V hV] + exact hc r + have ht := selectedResidueSmoothWeight_mass modulus G V hV + have htotal : 0 < ∑ r : G, ∑' x, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V x := by + rwa [← ht] + simp_rw [selectedResidueSmoothPMF_toReal, residueSmoothPMF_conditional_weight, ht, + selectedResidueSmoothWeight_eq_sum] + exact finite_supported_normalized_mixture _ (rectangularWeightIndices 0 V 1) + (fun r => residueSmoothWeight_zero_off _ modulus V hV) hcell htotal φ + +theorem selectedResidueSmoothPMF_bound_of_cells {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (hmodulus : ∀ j, 0 < modulus j) + (G : Finset (ColumnResiduePattern K I modulus)) (hG : G.Nonempty) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hc : ∀ r : G, 0 < shiftedSmoothProductMass + (residueProfileCenter (columnResidueRepresentative modulus r.val) modulus) (residueProfileWidth modulus V)) + (φ : (K × I → ℤ) → ℂ) {ε : ℝ} + (hφ : ∀ r : G, + ‖∑' x, ((residueSmoothPMF (columnResidueRepresentative modulus r.val) modulus hmodulus V hV (hc r) x).toReal : ℂ) * φ x‖ ≤ ε) : + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x, + ‖∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * φ x‖ ≤ ε := by + have hcell (r : G) : 0 < ∑' x, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V x := by + rw [← residueSmoothWeight_mass _ modulus hmodulus V hV] + exact hc r + have hZ := selectedResidueSmoothWeight_mass_pos modulus G hG V hV hcell + have ht := selectedResidueSmoothWeight_mass modulus G V hV + have htotal : 0 < ∑ r : G, ∑' x, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V x := by + rwa [← ht] + refine ⟨hZ, ?_⟩ + simp_rw [selectedResidueSmoothPMF_toReal, ht, selectedResidueSmoothWeight_eq_sum] + apply finite_supported_normalized_mixture_bound _ (rectangularWeightIndices 0 V 1) + (fun r => residueSmoothWeight_zero_off _ modulus V hV) hcell htotal φ + intro r + simpa only [residueSmoothPMF_conditional_weight] using hφ r + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem selectedResidueSmoothPMF_approximation {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (w f g : (K × I → ℤ) → ℂ) {η : ℝ} (hη : 0 ≤ η) + (hw : ∀ x ∈ rectangularWeightIndices 0 V 1, ‖w x‖ ≤ 1) + (he : ∀ x ∈ rectangularWeightIndices 0 V 1, ‖f x - g x‖ ≤ η) : + ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * f x)) - + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * g x)‖ ≤ η := by + simp_rw [selectedResidueSmoothPMF_toReal] + exact normalized_finite_weight_approximation _ (rectangularWeightIndices 0 V 1) + (selectedResidueSmoothWeight_nonneg modulus G V) + (selectedResidueSmoothWeight_zero_off modulus G V hV) hZ w f g hη hw he + +theorem selectedResidueSmoothPMF_projection_approximation {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (w f f₀ g₀ g : (K × I → ℤ) → ℂ) {η ε : ℝ} (hη : 0 ≤ η) + (hw : ∀ x ∈ rectangularWeightIndices 0 V 1, ‖w x‖ ≤ 1) + (hf : ∀ x ∈ rectangularWeightIndices 0 V 1, ‖f x - f₀ x‖ ≤ η) + (hg : ∀ x ∈ rectangularWeightIndices 0 V 1, ‖g₀ x - g x‖ ≤ η) + (hproject : ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * f₀ x)) - + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * g₀ x)‖ ≤ ε) : + ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * f x)) - + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * g x)‖ ≤ 2 * η + ε := by + have hfirst := selectedResidueSmoothPMF_approximation modulus G V hV hZ w f f₀ hη hw hf + have hlast := selectedResidueSmoothPMF_approximation modulus G V hV hZ w g₀ g hη hw hg + let E (a : (K × I → ℤ) → ℂ) := + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * a x) + have htri := norm_sub_le_norm_sub_add_norm_sub (E f) (E f₀) (E g) + have htri' := norm_sub_le_norm_sub_add_norm_sub (E f₀) (E g₀) (E g) + change ‖E f - E f₀‖ ≤ η at hfirst + change ‖E g₀ - E g‖ ≤ η at hlast + change ‖E f₀ - E g₀‖ ≤ ε at hproject + change ‖E f - E g‖ ≤ 2 * η + ε + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueCenterMix.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueCenterMix.lean new file mode 100644 index 0000000000000000000000000000000000000000..43d6d537afd1e72fa6626a979a9a60d6e69fea74 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueCenterMix.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.Progressions.Probability.IntervalDivisorProbability + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory + +theorem selectedResidueDensityPMF_normalizedDensityTest {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (T : Finset (ColumnResiduePattern K I modulus)) + (W : K × I → ℝ) (hW : ∀ z, 0 < W z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T W z) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ z, 0 ≤ D z) + (hD : 0 < selectedResidueDensityMass modulus T W D) (f : (K × I → ℤ) → ℂ) : + (∑' z, ((selectedResidueDensityPMF modulus T W hW hZ D hD0 hD z).toReal : ℂ)*f z) = + (selectedResidueFiniteLaw modulus T W hW hZ).normalizedDensityTest + (fun z => D z.val) (fun z => f z.val) := by + rw [selectedResidueDensityPMF_complexMean, FiniteProbabilityWeights.normalizedDensityTest, + selectedResidueFiniteLaw_densityMass, + selectedResidueFiniteLaw_complexMean modulus T W hW hZ (fun z => (D z : ℂ)*f z)] + +theorem selectedResidue_center_mixture_compare {C K I : Type*} [MeasurableSpace C] + [Fintype K] [Fintype I] (μ : Measure C) [IsProbabilityMeasure μ] + (modulus : I → ℕ) (T : Finset (ColumnResiduePattern K I modulus)) + (W : K × I → ℝ) (hW : ∀ z, 0 < W z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T W z) + (D : C → (K × I → ℤ) → ℝ) (hDm : ∀ z, Measurable (fun c => D c z)) + (hD0 : ∀ c z, 0 ≤ D c z) (hD : ∀ c, 0 < selectedResidueDensityMass modulus T W (D c)) + (F : C → (K × I → ℤ) → ℝ) (hF : ∀ z, Integrable (fun c => F c z) μ) + (hFmass : ∀ z, (∫ c, F c z ∂μ) = 1) + (f : (K × I → ℤ) → ℂ) (hf : ∀ z, ‖f z‖ ≤ 1) {ε : ℝ} + (herror : ∀ c, + ‖(∑' z, ((selectedResidueDensityPMF modulus T W hW hZ (D c) (hD0 c) (hD c) z).toReal : ℂ)*f z) - + (∑' z, ((selectedResidueSmoothPMF modulus T W hW hZ z).toReal : ℂ)*(f z*(F c z : ℂ)))‖ ≤ ε) : + ‖(∫ c, ∑' z, ((selectedResidueDensityPMF modulus T W hW hZ (D c) (hD0 c) (hD c) z).toReal : ℂ)*f z ∂μ) - + (∑' z, ((selectedResidueSmoothPMF modulus T W hW hZ z).toReal : ℂ)*f z)‖ ≤ ε := by + simp_rw [selectedResidueDensityPMF_normalizedDensityTest] + rw [← selectedResidueFiniteLaw_complexMean modulus T W hW hZ f] + apply FiniteProbabilityWeights.integral_normalizedDensityTest_compare + (selectedResidueFiniteLaw modulus T W hW hZ) μ + (fun c z => D c z.val) (fun z => hDm z.val) (fun c z => hD0 c z.val) + (fun c => by rw [selectedResidueFiniteLaw_densityMass]; exact hD c) + (fun c z => F c z.val) (fun z => hF z.val) (fun z => hFmass z.val) + (fun z => f z.val) (fun z => hf z.val) + intro c + have h := herror c + rw [selectedResidueDensityPMF_normalizedDensityTest, + ← selectedResidueFiniteLaw_complexMean modulus T W hW hZ (fun z => f z*(F c z : ℂ))] at h + exact h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueConstantMean.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueConstantMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..183569ad0ca0dcdc24de3d0bc2e82e4c08de3ff1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueConstantMean.lean @@ -0,0 +1,52 @@ +import OAI.Combinatorics.Progressions.Lattices.SelectedResidueApproximation + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem selectedResidueSmoothPMF_discard_error {K I J : Type*} + [Fintype K] [Fintype I] [Fintype J] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (w : (K × I → ℤ) → ℂ) (c : J → ℂ) (u : J → (K × I → ℤ) → ℂ) + (keep : J → Prop) [DecidablePred keep] {C τ : ℝ} + (hc : (∑ j, ‖c j‖) ≤ C) (hτ : 0 ≤ τ) + (hdiscard : ∀ j, ¬keep j → + ‖∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * u j x)‖ ≤ τ) : + ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (w x * ∑ j, c j * u j x)) - + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * + (w x * ∑ j, if keep j then c j * u j x else 0)‖ ≤ C * τ := by + simp_rw [selectedResidueSmoothPMF_toReal] at hdiscard ⊢ + exact normalized_finite_weight_discard_error _ (rectangularWeightIndices 0 V 1) + (selectedResidueSmoothWeight_nonneg modulus G V) + (selectedResidueSmoothWeight_zero_off modulus G V hV) hZ w c u keep hc hτ hdiscard + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem selectedResidueSmoothPMF_const {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) (c : ℂ) : + (∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * c) = c := by + simp_rw [selectedResidueSmoothPMF_toReal] + rw [← finiteSupportProbability_complexMean _ (rectangularWeightIndices 0 V 1) + (selectedResidueSmoothWeight_nonneg modulus G V) + (selectedResidueSmoothWeight_zero_off modulus G V hV) hZ (fun _ => c)] + exact FiniteProbabilityWeights.complexMean_const _ c + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueCutoffDomination.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueCutoffDomination.lean new file mode 100644 index 0000000000000000000000000000000000000000..aead7f4c13a5a9d4792f96535827b1918665fa6f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueCutoffDomination.lean @@ -0,0 +1,118 @@ +import OAI.Combinatorics.Progressions.Geometry.SelectedCenteredJointSupport +import OAI.Combinatorics.Progressions.Probability.MixedSelectedCoefficientProbability + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {K I : Type*} [Fintype K] [Fintype I] +variable (q : I → ℕ) (T : Finset (ColumnResiduePattern K I q)) +variable (V : K × I → ℝ) + +theorem selectedResidueSmoothWeight_normalized_norm_le (z : K × I → ℤ) + (hz : selectedResidueSmoothWeight q T V z ≠ 0) : + ‖fun t => (z t : ℝ) / V t‖ ≤ 1 := by + by_contra! hn + have hp := smoothProductProfile_zero_outside (K × I) (fun t => (z t : ℝ) / V t) hn + exact hz (by simp [selectedResidueSmoothWeight, hp]) + +theorem selectedResidueSmoothPMF_normalized_norm_le_of_pos (hV : ∀ t, 0 < V t) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) (z : K × I → ℤ) + (hz : 0 < (selectedResidueSmoothPMF q T V hV hZ z).toReal) : + ‖fun t => (z t : ℝ) / V t‖ ≤ 1 := by + apply selectedResidueSmoothWeight_normalized_norm_le q T V z + intro he + rw [selectedResidueSmoothPMF_toReal, he, zero_div] at hz + exact (lt_irrefl 0) hz + +theorem selectedResidueFiniteLaw_normalized_norm_le (hV : ∀ t, 0 < V t) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (z : rectangularWeightIndices 0 V 1) + (hz : 0 < (selectedResidueFiniteLaw q T V hV hZ).weight z) : + ‖fun t => (z.val t : ℝ) / V t‖ ≤ 1 := by + apply selectedResidueSmoothWeight_normalized_norm_le q T V z.val + intro he + change 0 < selectedResidueSmoothWeight q T V z.val / + (∑' x, selectedResidueSmoothWeight q T V x) at hz + rw [he, zero_div] at hz + exact (lt_irrefl 0) hz + +theorem selectedJointFiniteLaw_normalized_norm_le {A : Type*} + (bases : Finset A) (hbases : bases.Nonempty) (hV : ∀ t, 0 < V t) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (D : A → (K × I → ℤ) → ℝ) (hD0 : ∀ a z, 0 ≤ D a z) + (hD : 0 < selectedJointDensityMass bases q T V D) + (z : bases × rectangularWeightIndices 0 V 1) + (hz : 0 < (selectedJointFiniteLaw bases hbases q T V hV hZ D hD0 hD).weight z) : + ‖fun t => (z.2.val t : ℝ) / V t‖ ≤ 1 := by + apply selectedResidueSmoothWeight_normalized_norm_le q T V z.2.val + intro he + rw [selectedJointFiniteLaw_weight, selectedResidueSmoothPMF_toReal, he, zero_div, + mul_zero, zero_mul, zero_div] at hz + exact (lt_irrefl 0) hz + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +namespace FiniteProbabilityWeights + +theorem mean_mono_positive_support {X : Type*} [Fintype X] + (p : FiniteProbabilityWeights X) {f g : X → ℝ} + (h : ∀ x, 0 < p.weight x → f x ≤ g x) : p.mean f ≤ p.mean g := by + apply Finset.sum_le_sum + intro x _ + by_cases hx : 0 < p.weight x + · exact mul_le_mul_of_nonneg_left (h x hx) (p.nonneg x) + · have hz : p.weight x = 0 := le_antisymm (le_of_not_gt hx) (p.nonneg x) + simp only [hz, zero_mul, le_refl] + +end FiniteProbabilityWeights + +variable {K I : Type*} [Fintype K] [Fintype I] +variable (q : I → ℕ) (T : Finset (ColumnResiduePattern K I q)) +variable (V : K × I → ℝ) (hV : ∀ t, 0 < V t) +variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + +theorem selectedResidueFiniteLaw_event_eq_map_true (bad : (K × I → ℤ) → Prop) : + (selectedResidueFiniteLaw q T V hV hZ).eventProbability (fun z => bad z.val) = + (((selectedResidueSmoothPMF q T V hV hZ).map (fun z => decide (bad z))) true).toReal := by + have hoff (z : K × I → ℤ) (hz : z ∉ rectangularWeightIndices 0 V 1) : + (selectedResidueSmoothPMF q T V hV hZ z).toReal = 0 := by + rw [selectedResidueSmoothPMF_toReal, selectedResidueSmoothWeight_zero_off q T V hV z hz, zero_div] + calc + _ = (FiniteProbabilityWeights.ofSupportedPMF (selectedResidueSmoothPMF q T V hV hZ) + (rectangularWeightIndices 0 V 1) hoff).eventProbability (fun z => bad z.val) := by + unfold FiniteProbabilityWeights.eventProbability FiniteProbabilityWeights.mean + apply Finset.sum_congr rfl + intro z _ + change selectedResidueSmoothWeight q T V z.val / _ * _ = + (selectedResidueSmoothPMF q T V hV hZ z.val).toReal * _ + rw [selectedResidueSmoothPMF_toReal] + _ = _ := supportedPMF_event_eq_map_true _ _ hoff bad + +theorem selectedResidueFiniteLaw_cutoff_le_event + (F : (K × I → ℝ) → ℝ) (bad : (K × I → ℤ) → Prop) + (hF : ∀ z : K × I → ℤ, ‖fun t => (z t : ℝ) / V t‖ ≤ 1 → + F (fun t => (z t : ℝ) / V t) ≤ if bad z then 1 else 0) : + (selectedResidueFiniteLaw q T V hV hZ).mean + (fun z => F (fun t => (z.val t : ℝ) / V t)) ≤ + (((selectedResidueSmoothPMF q T V hV hZ).map (fun z => decide (bad z))) true).toReal := by + rw [← selectedResidueFiniteLaw_event_eq_map_true] + apply FiniteProbabilityWeights.mean_mono_positive_support + intro z hz + exact hF z.val (selectedResidueFiniteLaw_normalized_norm_le q T V hV hZ z hz) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueL1Surrogate.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueL1Surrogate.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1cf0ee12d21e7c389ace2196be758d05a6af5b3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueL1Surrogate.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.Progressions.Lattices.SmoothResidueWindowMass +import OAI.Combinatorics.Progressions.Sampling.L1SamplingSurrogate + +namespace OAI + +section + +namespace Erdos3 +open MeasureTheory +open scoped Classical BigOperators NNReal + +theorem selectedResidueDensityMass_l1_surrogate + {X : Type*} [MeasurableSpace X] (μ : Measure X) [IsProbabilityMeasure μ] + {K I : Type*} [Fintype K] [Fintype I] + (stride : I → ℕ) (cells : Finset (ColumnResiduePattern K I stride)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells V z) + (s : (K × I → ℤ) → X) (f ideal g : X → ℂ) + (hf : Measurable f) (hi : Measurable ideal) (hg : Measurable g) + {Cf Cg : ℝ} (hfb : ∀ x, ‖f x‖ ≤ Cf) (hgb : ∀ x, ‖g x‖ ≤ Cg) + {E δ ε : ℝ} (happrox : ∀ x, ‖ideal x - g x‖ ≤ δ) + (hmass : (∫ x, ‖f x - ideal x‖ ∂μ) ≤ E) + (hsample : selectedResidueDensityMass stride cells V + (fun z => ‖f (s z) - g (s z)‖) ≤ (∫ x, ‖f x - g x‖ ∂μ) + ε) : + selectedResidueDensityMass stride cells V + (fun z => ‖f (s z) - ideal (s z)‖) ≤ E + 2 * δ + ε := by + let ν := (selectedResidueSmoothPMF stride cells V hV hZ).toMeasure + have hib (x) : ‖ideal x‖ ≤ δ + Cg := by + calc + _ ≤ ‖ideal x - g x‖ + ‖g x‖ := norm_le_norm_sub_add _ _ + _ ≤ _ := add_le_add (happrox x) (hgb x) + have hfi : Integrable f μ := Integrable.of_bound hf.aestronglyMeasurable Cf (Filter.Eventually.of_forall hfb) + have hii : Integrable ideal μ := Integrable.of_bound hi.aestronglyMeasurable (δ + Cg) (Filter.Eventually.of_forall hib) + have hgi : Integrable g μ := Integrable.of_bound hg.aestronglyMeasurable Cg (Filter.Eventually.of_forall hgb) + have hfs : Integrable (fun z => f (s z)) ν := Integrable.of_bound + (measurable_of_countable _).aestronglyMeasurable Cf (Filter.Eventually.of_forall (fun z => hfb _)) + have his : Integrable (fun z => ideal (s z)) ν := Integrable.of_bound + (measurable_of_countable _).aestronglyMeasurable (δ + Cg) (Filter.Eventually.of_forall (fun z => hib _)) + have hgs : Integrable (fun z => g (s z)) ν := Integrable.of_bound + (measurable_of_countable _).aestronglyMeasurable Cg (Filter.Eventually.of_forall (fun z => hgb _)) + have hs' : (∫ z, ‖f (s z) - g (s z)‖ ∂ν) ≤ (∫ x, ‖f x - g x‖ ∂μ) + ε := by + exact (selectedResidueDensityMass_integral stride cells V hV hZ _ (hfs.sub hgs).norm).symm.trans_le hsample + exact (selectedResidueDensityMass_integral stride cells V hV hZ _ (hfs.sub his).norm).trans_le + (l1_sampling_via_uniform_surrogate μ ν s f ideal g hfi hii hgi hfs his hgs happrox hmass hs') + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueMaskedTest.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueMaskedTest.lean new file mode 100644 index 0000000000000000000000000000000000000000..553ca08a4f103547f1143f9f1133b372dcde3899 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueMaskedTest.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedJointMaskedDensityComparison + +namespace OAI + +section + +namespace Erdos3 + +theorem selectedResidueDensityPMF_mean_congr_density + {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (f g : (K × I → ℤ) → ℂ) + (hfg : ∀ x, (D x : ℂ) * f x = (D x : ℂ) * g x) : + (∑' x, ((selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal : ℂ) * f x) = + ∑' x, ((selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal : ℂ) * g x := by + rw [selectedResidueDensityPMF_complexMean, selectedResidueDensityPMF_complexMean] + simp_rw [hfg] + +theorem selectedResidueDensityPMF_masked_test + {K I Y : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D A : Y → ℝ) (hA : ∀ y, 0 ≤ A y) (hAD : ∀ y, A y ≤ D y) + (sample : (K × I → ℤ) → Y) + (hD : 0 < selectedResidueDensityMass modulus G V (fun x => D (sample x))) + (test : (K × I → ℤ) → ℂ) + (hmask : ∀ x, (D (sample x) : ℂ) * test x = (A (sample x) : ℂ)) : + (∑' x, ((selectedResidueDensityPMF modulus G V hV hZ (fun x => D (sample x)) + (fun x => (hA (sample x)).trans (hAD (sample x))) hD x).toReal : ℂ) * test x) = + ∑' x, ((selectedResidueDensityPMF modulus G V hV hZ (fun x => D (sample x)) + (fun x => (hA (sample x)).trans (hAD (sample x))) hD x).toReal : ℂ) * + dominatedDensityRatio D A (sample x) := by + apply selectedResidueDensityPMF_mean_congr_density + intro x + rw [hmask x, dominatedDensityRatio_mul D A hA hAD] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueRefinementMean.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueRefinementMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee8daf615a350d4f9bb071b6cec00a5839627e5d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueRefinementMean.lean @@ -0,0 +1,499 @@ +import OAI.Combinatorics.Progressions.Estimates.ShiftedProductTestError + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {K X : Type*} [Fintype K] [Fintype X] + +noncomputable def selectedResidueCellWeight (modulus : X → ℕ) + (T : Finset (ColumnResiduePattern K X modulus)) (V : K × X → ℝ) (r : T) : ℝ := + (∑' z, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V z) / + (∑' z, selectedResidueSmoothWeight modulus T V z) + +theorem selectedResidueCellWeight_nonneg (modulus : X → ℕ) + (T : Finset (ColumnResiduePattern K X modulus)) (V : K × X → ℝ) (r : T) : + 0 ≤ selectedResidueCellWeight modulus T V r := by + apply div_nonneg + · apply tsum_nonneg + intro z + unfold residueSmoothWeight + split + · exact (smoothProductProfile_range (K × X) _).1 + · exact le_rfl + · exact tsum_nonneg (selectedResidueSmoothWeight_nonneg modulus T V) + +theorem selectedResidueCellWeight_sum (modulus : X → ℕ) + (T : Finset (ColumnResiduePattern K X modulus)) (V : K × X → ℝ) + (hV : ∀ z, 0 < V z) (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) : + (∑ r : T, selectedResidueCellWeight modulus T V r) = 1 := by + simp only [selectedResidueCellWeight, ← Finset.sum_div] + rw [← selectedResidueSmoothWeight_mass modulus T V hV, div_self hZ.ne'] + +theorem selectedResidueSmoothPMF_bounded_mixture (modulus : X → ℕ) + (hmodulus : ∀ x, 0 < modulus x) (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) (φ : (K × X → ℤ) → ℂ) : + (∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * φ z) = + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∑' z, ((residueSmoothPMF (boundedColumnResidueRepresentative modulus r.val) + modulus hmodulus V hV (hc r) z).toReal : ℂ) * φ z := by + have hm (r : T) := residueSmoothMass_congr _ _ modulus hmodulus V hV + (boundedColumnResidueRepresentative_congr modulus r.val) + have ho (r : T) : 0 < shiftedSmoothProductMass + (residueProfileCenter (columnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V) := by rw [hm r]; exact hc r + rw [selectedResidueSmoothPMF_mixture modulus hmodulus T V hV hZ ho] + apply Finset.sum_congr rfl + intro r _ + rw [residueSmoothPMF_congr _ _ modulus hmodulus V hV + (boundedColumnResidueRepresentative_congr modulus r.val) (ho r) (hc r)] + rfl + +theorem selectedResidue_bounded_mixture_error (modulus : X → ℕ) + (hmodulus : ∀ x, 0 < modulus x) (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) (φ : (K × X → ℤ) → ℂ) + (target : T → ℂ) (ε : T → ℝ) + (he : ∀ r : T, ‖(∑' z, ((residueSmoothPMF (boundedColumnResidueRepresentative modulus r.val) + modulus hmodulus V hV (hc r) z).toReal : ℂ) * φ z) - target r‖ ≤ ε r) : + ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * φ z) - + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * target r‖ ≤ + ∑ r : T, selectedResidueCellWeight modulus T V r * ε r := by + rw [selectedResidueSmoothPMF_bounded_mixture modulus hmodulus T V hV hZ hc φ, + ← Finset.sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro r _ + rw [← mul_sub, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (selectedResidueCellWeight_nonneg modulus T V r)] + exact mul_le_mul_of_nonneg_left (he r) (selectedResidueCellWeight_nonneg modulus T V r) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residueProfile_center_ratio {K X : Type*} + (r : K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) (z : K × X) : + |residueProfileCenter r q z| / residueProfileWidth q V z = |(r z : ℝ)| / V z := by + have hq0 : (0 : ℝ) < q z.2 := by exact_mod_cast hq z.2 + simp only [residueProfileCenter, residueProfileWidth, abs_div, abs_neg, abs_of_pos hq0] + field_simp [hq0.ne', (hV z).ne'] + +theorem residueSmoothIndexPMF_recenter_test {K X : Type*} [Fintype K] [Fintype X] + (r : K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hc : 0 < shiftedSmoothProductMass (residueProfileCenter r q) (residueProfileWidth q V)) + (hlarge : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + (φ : (K × X → ℤ) → ℂ) {B : ℝ} (hB : 0 ≤ B) (hφ : ∀ z, ‖φ z‖ ≤ B) : + ‖(∑' z, ((residueSmoothIndexPMF r q hq V hV hc z).toReal : ℂ) * φ z) - + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * φ z‖ ≤ + B * (24 * (probabilityProfileLipschitz : ℝ) * ∑ z, |(r z : ℝ)| / V z) := by + have h := shiftedSmoothProductPMF_recenter_test (residueProfileCenter r q) + (residueProfileWidth q V) (residueProfileWidth_pos q V hq hV) hc hlarge φ hB hφ + simpa only [residueSmoothIndexPMF, residueProfile_center_ratio r q hq V hV] using h + +theorem residueSmoothPMF_recenter_test {K X : Type*} [Fintype K] [Fintype X] + (r : K × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hc : 0 < shiftedSmoothProductMass (residueProfileCenter r q) (residueProfileWidth q V)) + (hlarge : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + (φ : (K × X → ℤ) → ℂ) {B : ℝ} (hB : 0 ≤ B) (hφ : ∀ z, ‖φ z‖ ≤ B) : + ‖(∑' z, ((residueSmoothPMF r q hq V hV hc z).toReal : ℂ) * φ z) - + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * φ (residueLatticeArray r q z)‖ ≤ + B * (24 * (probabilityProfileLipschitz : ℝ) * ∑ z, |(r z : ℝ)| / V z) := by + rw [residueSmoothPMF_expectation] + exact residueSmoothIndexPMF_recenter_test r q hq V hV hc hlarge + (fun z => φ (residueLatticeArray r q z)) hB (fun z => hφ _) + +theorem boundedResidueSmoothPMF_recenter_test {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) (r : ColumnResiduePattern K X q) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hc : 0 < shiftedSmoothProductMass (residueProfileCenter (boundedColumnResidueRepresentative q r) q) + (residueProfileWidth q V)) + (hlarge : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + (φ : (K × X → ℤ) → ℂ) {B : ℝ} (hB : 0 ≤ B) (hφ : ∀ z, ‖φ z‖ ≤ B) : + ‖(∑' z, ((residueSmoothPMF (boundedColumnResidueRepresentative q r) q hq V hV hc z).toReal : ℂ) * φ z) - + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * + φ (residueLatticeArray (boundedColumnResidueRepresentative q r) q z)‖ ≤ + B * (24 * (probabilityProfileLipschitz : ℝ) * ∑ z : K × X, (q z.2 : ℝ) / V z) := by + apply (residueSmoothPMF_recenter_test (boundedColumnResidueRepresentative q r) q hq V hV hc + hlarge φ hB hφ).trans + apply mul_le_mul_of_nonneg_left _ hB + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Finset.sum_le_sum + intro z _ + have hr := boundedColumnResidueRepresentative_bounds q hq r z + have hr0 : (0 : ℝ) ≤ boundedColumnResidueRepresentative q r z := by exact_mod_cast hr.1 + apply div_le_div_of_nonneg_right _ (hV z).le + rw [abs_of_nonneg hr0] + exact_mod_cast hr.2.le + +theorem selectedResidueSmoothPMF_recenter_test {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) (T : Finset (ColumnResiduePattern K X q)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hlarge : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + (φ : (K × X → ℤ) → ℂ) {B : ℝ} (hB : 0 ≤ B) (hφ : ∀ z, ‖φ z‖ ≤ B) : + ‖(∑' z, ((selectedResidueSmoothPMF q T V hV hZ z).toReal : ℂ) * φ z) - + ∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' z, ((smoothProductPMF (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) z).toReal : ℂ) * + φ (residueLatticeArray (boundedColumnResidueRepresentative q r.val) q z)‖ ≤ + B * (24 * (probabilityProfileLipschitz : ℝ) * ∑ z : K × X, (q z.2 : ℝ) / V z) := by + have hc (r : T) := shiftedSmoothProductMass_pos_of_large + (residueProfileCenter (boundedColumnResidueRepresentative q r.val) q) (residueProfileWidth q V) hlarge + have h := selectedResidue_bounded_mixture_error q hq T V hV hZ hc φ _ + (fun _ => B * (24 * (probabilityProfileLipschitz : ℝ) * ∑ z : K × X, (q z.2 : ℝ) / V z)) + (fun r => boundedResidueSmoothPMF_recenter_test q hq r.val V hV (hc r) hlarge φ hB hφ) + simpa only [← Finset.sum_mul, selectedResidueCellWeight_sum q T V hV hZ, one_mul] using h + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {K X Y : Type*} [Fintype K] [Fintype X] + +theorem selectedResidueSmoothPMF_bind_toReal_mixture + (q : X → ℕ) (hq : ∀ x, 0 < q x) + (T : Finset (ColumnResiduePattern K X q)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative q r.val) q) + (residueProfileWidth q V)) + (F : (K × X → ℤ) → PMF Y) (y : Y) : + (((selectedResidueSmoothPMF q T V hV hZ).bind F) y).toReal = + ∑ r : T, selectedResidueCellWeight q T V r * + (((residueSmoothPMF (boundedColumnResidueRepresentative q r.val) + q hq V hV (hc r)).bind F) y).toReal := by + apply Complex.ofReal_injective + simp only [pmf_bind_toReal, Complex.ofReal_tsum, Complex.ofReal_sum, Complex.ofReal_mul] + exact selectedResidueSmoothPMF_bounded_mixture q hq T V hV hZ hc + (fun z => ((F z y).toReal : ℂ)) + +theorem selectedResidueSmoothPMF_bind_le_of_cells + (q : X → ℕ) (hq : ∀ x, 0 < q x) + (T : Finset (ColumnResiduePattern K X q)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative q r.val) q) + (residueProfileWidth q V)) + (F : (K × X → ℤ) → PMF Y) (y : Y) (δ : ℝ) + (hbound : ∀ r : T, (((residueSmoothPMF (boundedColumnResidueRepresentative q r.val) + q hq V hV (hc r)).bind F) y).toReal ≤ δ) : + (((selectedResidueSmoothPMF q T V hV hZ).bind F) y).toReal ≤ δ := by + rw [selectedResidueSmoothPMF_bind_toReal_mixture q hq T V hV hZ hc F y] + calc + _ ≤ ∑ r : T, selectedResidueCellWeight q T V r * δ := + Finset.sum_le_sum (fun r _ => mul_le_mul_of_nonneg_left (hbound r) + (selectedResidueCellWeight_nonneg q T V r)) + _ = δ := by rw [← Finset.sum_mul, selectedResidueCellWeight_sum q T V hV hZ, one_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {K X : Type*} [Fintype K] [Fintype X] + +theorem selectedResidueDensityMass_bounded_mixture + (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) (D : (K × X → ℤ) → ℝ) : + selectedResidueDensityMass modulus T V D = + ∑ r : T, selectedResidueCellWeight modulus T V r * + ∑' z, (residueSmoothPMF (boundedColumnResidueRepresentative modulus r.val) + modulus hmodulus V hV (hc r) z).toReal * D z := by + apply Complex.ofReal_injective + rw [selectedResidueDensityMass_complex modulus T V hV hZ D] + simp only [Complex.ofReal_sum, Complex.ofReal_mul, Complex.ofReal_tsum] + exact selectedResidueSmoothPMF_bounded_mixture modulus hmodulus T V hV hZ hc + (fun z => (D z : ℂ)) + +theorem selectedResidueDensityNumerator_bounded_mixture + (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) + (D : (K × X → ℤ) → ℝ) (φ : (K × X → ℤ) → ℂ) : + (∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + ((D z : ℂ) * φ z)) = + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∑' z, ((residueSmoothPMF (boundedColumnResidueRepresentative modulus r.val) + modulus hmodulus V hV (hc r) z).toReal : ℂ) * ((D z : ℂ) * φ z) := + selectedResidueSmoothPMF_bounded_mixture modulus hmodulus T V hV hZ hc + (fun z => (D z : ℂ) * φ z) + +theorem selectedResidueDensityPMF_bounded_mixture_ratio + (modulus : X → ℕ) (hmodulus : ∀ x, 0 < modulus x) + (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative modulus r.val) modulus) + (residueProfileWidth modulus V)) + (D : (K × X → ℤ) → ℝ) (hD0 : ∀ z, 0 ≤ D z) + (hD : 0 < selectedResidueDensityMass modulus T V D) + (φ : (K × X → ℤ) → ℂ) : + (∑' z, ((selectedResidueDensityPMF modulus T V hV hZ D hD0 hD z).toReal : ℂ) * φ z) = + (∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∑' z, ((residueSmoothPMF (boundedColumnResidueRepresentative modulus r.val) + modulus hmodulus V hV (hc r) z).toReal : ℂ) * ((D z : ℂ) * φ z)) / + ((∑ r : T, selectedResidueCellWeight modulus T V r * + ∑' z, (residueSmoothPMF (boundedColumnResidueRepresentative modulus r.val) + modulus hmodulus V hV (hc r) z).toReal * D z : ℝ) : ℂ) := by + rw [selectedResidueDensityPMF_complexMean, + selectedResidueDensityNumerator_bounded_mixture modulus hmodulus T V hV hZ hc, + selectedResidueDensityMass_bounded_mixture modulus hmodulus T V hV hZ hc] + +theorem selectedResidueSmoothWeight_singleton + (modulus : X → ℕ) (r : ColumnResiduePattern K X modulus) + (V : K × X → ℝ) (z : K × X → ℤ) : + selectedResidueSmoothWeight modulus {r} V z = + residueSmoothWeight (columnResidueRepresentative modulus r) modulus V z := by + simp only [selectedResidueSmoothWeight, Finset.mem_singleton, residueSmoothWeight_eq_pattern] + +theorem selectedResidueSmoothWeight_mass_pos_of_singletons + (modulus : X → ℕ) (T : Finset (ColumnResiduePattern K X modulus)) + (hT : T.Nonempty) (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hcellZ : ∀ r : T, 0 < ∑' z, selectedResidueSmoothWeight modulus {r.val} V z) : + 0 < ∑' z, selectedResidueSmoothWeight modulus T V z := by + apply selectedResidueSmoothWeight_mass_pos modulus T hT V hV + intro r + simpa only [selectedResidueSmoothWeight_singleton] using hcellZ r + +theorem selectedResidueSmoothPMF_singleton_mixture + (modulus : X → ℕ) (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hcellZ : ∀ r : T, 0 < ∑' z, selectedResidueSmoothWeight modulus {r.val} V z) + (φ : (K × X → ℤ) → ℂ) : + (∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * φ z) = + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∑' z, ((selectedResidueSmoothPMF modulus {r.val} V hV (hcellZ r) z).toReal : ℂ) * φ z := by + have hcell (r : T) : + 0 < ∑' z, residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V z := by + simpa only [selectedResidueSmoothWeight_singleton] using hcellZ r + have ht := selectedResidueSmoothWeight_mass modulus T V hV + have htotal : 0 < ∑ r : T, ∑' z, + residueSmoothWeight (columnResidueRepresentative modulus r.val) modulus V z := by + rwa [← ht] + simp only [selectedResidueSmoothPMF_toReal] + simp only [selectedResidueSmoothWeight_singleton, selectedResidueCellWeight] + simp only [ht] + simp only [selectedResidueSmoothWeight_eq_sum] + exact finite_supported_normalized_mixture _ (rectangularWeightIndices 0 V 1) + (fun r => residueSmoothWeight_zero_off _ modulus V hV) hcell htotal φ + +theorem selectedResidueDensityMass_singleton_mixture + (modulus : X → ℕ) (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hcellZ : ∀ r : T, 0 < ∑' z, selectedResidueSmoothWeight modulus {r.val} V z) + (D : (K × X → ℤ) → ℝ) : + selectedResidueDensityMass modulus T V D = + ∑ r : T, selectedResidueCellWeight modulus T V r * + selectedResidueDensityMass modulus {r.val} V D := by + apply Complex.ofReal_injective + rw [selectedResidueDensityMass_complex modulus T V hV hZ D] + simp only [Complex.ofReal_sum, Complex.ofReal_mul] + simp_rw [selectedResidueDensityMass_complex modulus _ V hV (hcellZ _) D] + exact selectedResidueSmoothPMF_singleton_mixture modulus T V hV hZ hcellZ + (fun z => (D z : ℂ)) + +theorem selectedResidueDensityNumerator_singleton_mixture + (modulus : X → ℕ) (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hcellZ : ∀ r : T, 0 < ∑' z, selectedResidueSmoothWeight modulus {r.val} V z) + (D : (K × X → ℤ) → ℝ) (φ : (K × X → ℤ) → ℂ) : + (∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + ((D z : ℂ) * φ z)) = + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∑' z, ((selectedResidueSmoothPMF modulus {r.val} V hV (hcellZ r) z).toReal : ℂ) * + ((D z : ℂ) * φ z) := + selectedResidueSmoothPMF_singleton_mixture modulus T V hV hZ hcellZ + (fun z => (D z : ℂ) * φ z) + +theorem selectedResidueDensityPMF_singleton_mixture_ratio + (modulus : X → ℕ) (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hcellZ : ∀ r : T, 0 < ∑' z, selectedResidueSmoothWeight modulus {r.val} V z) + (D : (K × X → ℤ) → ℝ) (hD0 : ∀ z, 0 ≤ D z) + (hD : 0 < selectedResidueDensityMass modulus T V D) + (φ : (K × X → ℤ) → ℂ) : + (∑' z, ((selectedResidueDensityPMF modulus T V hV hZ D hD0 hD z).toReal : ℂ) * φ z) = + (∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * + ∑' z, ((selectedResidueSmoothPMF modulus {r.val} V hV (hcellZ r) z).toReal : ℂ) * + ((D z : ℂ) * φ z)) / + ((∑ r : T, selectedResidueCellWeight modulus T V r * + selectedResidueDensityMass modulus {r.val} V D : ℝ) : ℂ) := by + rw [selectedResidueDensityPMF_complexMean, + selectedResidueDensityNumerator_singleton_mixture modulus T V hV hZ hcellZ, + selectedResidueDensityMass_singleton_mixture modulus T V hV hZ hcellZ] + +theorem selectedResidueDensityPMF_singleton_mixture_error + (modulus : X → ℕ) (T : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (hcellZ : ∀ r : T, 0 < ∑' z, selectedResidueSmoothWeight modulus {r.val} V z) + (D : (K × X → ℤ) → ℝ) (hD0 : ∀ z, 0 ≤ D z) + (hD : 0 < selectedResidueDensityMass modulus T V D) + (φ : (K × X → ℤ) → ℂ) (target : T → ℂ) {E γ : ℝ} + (hγ : γ ≤ 1 / 2) + (hraw : ∀ r : T, + ‖(∑' z, ((selectedResidueSmoothPMF modulus {r.val} V hV (hcellZ r) z).toReal : ℂ) * + ((D z : ℂ) * φ z)) - target r‖ ≤ E) + (hmass : ∀ r : T, |selectedResidueDensityMass modulus {r.val} V D - 1| ≤ γ) + (htarget : ∀ r : T, ‖target r‖ ≤ 1) : + ‖(∑' z, ((selectedResidueDensityPMF modulus T V hV hZ D hD0 hD z).toReal : ℂ) * φ z) - + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * target r‖ ≤ 2 * E + 2 * γ := by + have hweights := selectedResidueCellWeight_sum modulus T V hV hZ + have hnonneg := selectedResidueCellWeight_nonneg modulus T V + have hmass_global : |selectedResidueDensityMass modulus T V D - 1| ≤ γ := by + have heq : selectedResidueDensityMass modulus T V D - 1 = + ∑ r : T, selectedResidueCellWeight modulus T V r * + (selectedResidueDensityMass modulus {r.val} V D - 1) := by + simp only [mul_sub, mul_one, Finset.sum_sub_distrib, hweights] + rw [selectedResidueDensityMass_singleton_mixture modulus T V hV hZ hcellZ] + rw [heq] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ r : T, selectedResidueCellWeight modulus T V r * γ := by + apply Finset.sum_le_sum + intro r _ + rw [abs_mul, abs_of_nonneg (hnonneg r)] + exact mul_le_mul_of_nonneg_left (hmass r) (hnonneg r) + _ = γ := by rw [← Finset.sum_mul, hweights, one_mul] + have hlower : 1 / 2 ≤ selectedResidueDensityMass modulus T V D := by + have := (abs_le.mp hmass_global).1 + linarith + have hraw_global : + ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + ((D z : ℂ) * φ z)) - + ∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * target r‖ ≤ E := by + rw [selectedResidueDensityNumerator_singleton_mixture modulus T V hV hZ hcellZ, + ← Finset.sum_sub_distrib] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ r : T, selectedResidueCellWeight modulus T V r * E := by + apply Finset.sum_le_sum + intro r _ + rw [← mul_sub, norm_mul, Complex.norm_real, Real.norm_of_nonneg (hnonneg r)] + exact mul_le_mul_of_nonneg_left (hraw r) (hnonneg r) + _ = E := by rw [← Finset.sum_mul, hweights, one_mul] + have htarget_global : + ‖∑ r : T, (selectedResidueCellWeight modulus T V r : ℂ) * target r‖ ≤ 1 := by + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ r : T, selectedResidueCellWeight modulus T V r * 1 := by + apply Finset.sum_le_sum + intro r _ + rw [norm_mul, Complex.norm_real, Real.norm_of_nonneg (hnonneg r)] + exact mul_le_mul_of_nonneg_left (htarget r) (hnonneg r) + _ = 1 := by simpa only [mul_one] using hweights + simpa only [mul_one] using selectedResidueDensityPMF_error modulus T V hV hZ D hD0 hD φ + hlower hraw_global hmass_global htarget_global + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem selectedResidueSmoothPMF_singleton_residue_mean + {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (r : ColumnResiduePattern K I modulus) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus {r} V z) + (F : ColumnResiduePattern K I modulus → ℂ) : + (∑' z, ((selectedResidueSmoothPMF modulus {r} V hV hZ z).toReal : ℂ) * + F (columnResiduePattern modulus z)) = F r := by + have hp : (∑' z, (selectedResidueSmoothPMF modulus {r} V hV hZ z).toReal) = 1 := by + rw [← ENNReal.tsum_toReal_eq (fun z => PMF.apply_ne_top _ z), PMF.tsum_coe, + ENNReal.toReal_one] + calc + _ = ∑' z, ((selectedResidueSmoothPMF modulus {r} V hV hZ z).toReal : ℂ) * F r := by + apply tsum_congr + intro z + by_cases hz : columnResiduePattern modulus z = r + · rw [hz] + · simp only [selectedResidueSmoothPMF_toReal, selectedResidueSmoothWeight, + Finset.mem_singleton, hz, ite_false, zero_div, Complex.ofReal_zero, zero_mul] + _ = (∑' z, ((selectedResidueSmoothPMF modulus {r} V hV hZ z).toReal : ℂ)) * F r := + tsum_mul_right + _ = F r := by rw [← Complex.ofReal_tsum, hp, Complex.ofReal_one, one_mul] + +theorem selectedResidueRefinement_weighted_mean + {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus G V z) + (hcellZ : ∀ r : selectedResidueRefinement modulus refined hdiv G, + 0 < ∑' z, selectedResidueSmoothWeight refined {r.val} V z) + (F : ColumnResiduePattern K I refined → ℂ) : + (∑ r : selectedResidueRefinement modulus refined hdiv G, + (selectedResidueCellWeight refined (selectedResidueRefinement modulus refined hdiv G) V r : ℂ) * + F r.val) = + ∑' z, ((selectedResidueSmoothPMF modulus G V hV hZ z).toReal : ℂ) * + F (columnResiduePattern refined z) := by + have hZref : 0 < ∑' z, selectedResidueSmoothWeight refined + (selectedResidueRefinement modulus refined hdiv G) V z := by + rw [selectedResidueSmoothMass_refinement] + exact hZ + have h := selectedResidueSmoothPMF_singleton_mixture refined + (selectedResidueRefinement modulus refined hdiv G) V hV hZref hcellZ + (fun z => F (columnResiduePattern refined z)) + rw [selectedResidueSmoothPMF_refinement modulus refined hdiv G V hV hZ hZref] at h + simp only [selectedResidueSmoothPMF_singleton_residue_mean] at h + exact h.symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueScalarReindex.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueScalarReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..915683cdce47cf8582a713e44a120f0bccb4a0f5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SelectedResidueScalarReindex.lean @@ -0,0 +1,40 @@ +import OAI.Combinatorics.Progressions.Estimates.UnconditionedSmoothSlopeCap + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {K I K' I' : Type*} [Fintype K] [Fintype I] [Fintype K'] [Fintype I'] + +theorem selectedResidueSmoothWeight_one_reindex + (e : (K × I) ≃ (K' × I')) (W : K × I → ℝ) (W' : K' × I' → ℝ) + (hW : ∀ i, W' (e i) = W i) (z : K × I → ℤ) : + selectedResidueSmoothWeight (fun _ : I' => 1) {0} W' (z ∘ e.symm) = + selectedResidueSmoothWeight (fun _ : I => 1) {0} W z := by + simp only [selectedResidueSmoothWeight_one, rectangularWeight, + rectangularLatticePoint_zero_origin, smoothProductProfile] + symm + apply Fintype.prod_equiv e + intro i + simp only [Function.comp_apply, e.symm_apply_apply, hW] + +theorem selectedResidueSmoothMass_one_reindex + (e : (K × I) ≃ (K' × I')) (W : K × I → ℝ) (W' : K' × I' → ℝ) + (hW : ∀ i, W' (e i) = W i) : + (∑' z, selectedResidueSmoothWeight (fun _ : I' => 1) {0} W' z) = + ∑' z, selectedResidueSmoothWeight (fun _ : I => 1) {0} W z := by + let E : (K × I → ℤ) ≃ (K' × I' → ℤ) := Equiv.arrowCongr e (Equiv.refl ℤ) + calc + _ = ∑' z, selectedResidueSmoothWeight (fun _ : I' => 1) {0} W' (E z) := + (E.tsum_eq _).symm + _ = _ := tsum_congr (fun z => selectedResidueSmoothWeight_one_reindex e W W' hW z) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SharedFreeAffineBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SharedFreeAffineBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd48d6f77db0e0ac1ee3ac309ca99e3c24a4a148 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SharedFreeAffineBudget.lean @@ -0,0 +1,529 @@ +import OAI.Combinatorics.Progressions.Dynamics.SharedFreeRecoveryBudget +import OAI.Combinatorics.Progressions.Estimates.LocalizedSiftingAlmostPeriods +import OAI.Combinatorics.Progressions.Probability.RoundedModelDensityBudget + +namespace OAI + +section + +namespace Erdos3 + +open CyclicCrootSisask + +noncomputable def affineRecoveryLogLoss (P : ℝ) (n : ℕ) : ℝ := + quarticBogolyubovProgressionConstant * (roundedModelLogBudget P n + 1) ^ 8 + + (P + 13 * n) + 16 * ((n : ℝ) + 3) + +theorem exp_neg_affineRecoveryLogLoss_card_le (P : ℝ) (n a b : ℕ) + (h : Real.exp (-(quarticBogolyubovProgressionConstant * + (roundedModelLogBudget P n + 1) ^ 8)) * + ((2 ^ 4 : ℝ)⁻¹ * (Real.exp (P + 13 * n))⁻¹ * a) ≤ + 16 ^ (n + 2) * (b : ℝ)) : + Real.exp (-affineRecoveryLogLoss P n) * a ≤ (b : ℝ) := by + let C := quarticBogolyubovProgressionConstant * (roundedModelLogBudget P n + 1) ^ 8 + let E := P + 13 * n + let L := 16 * ((n : ℝ) + 3) + have hmain : Real.exp (-(C + E)) * a ≤ (16 : ℝ) ^ (n + 3) * b := by + calc + _ = 16 * (Real.exp (-C) * ((2 ^ 4 : ℝ)⁻¹ * (Real.exp E)⁻¹ * a)) := by + simp only [neg_add, Real.exp_add, Real.exp_neg] + norm_num + ring + _ ≤ 16 * (16 ^ (n + 2) * (b : ℝ)) := mul_le_mul_of_nonneg_left h (by norm_num) + _ = _ := by rw [show n + 3 = n + 2 + 1 by omega, pow_succ]; ring + have h16 : (16 : ℝ) ^ (n + 3) ≤ Real.exp L := by + calc + _ ≤ (Real.exp 16) ^ (n + 3) := + pow_le_pow_left₀ (by norm_num) (by linarith [Real.add_one_le_exp (16 : ℝ)]) _ + _ = _ := by + rw [← Real.exp_nat_mul] + congr 1 + dsimp [L] + push_cast + ring + calc + _ = Real.exp (-L) * (Real.exp (-(C + E)) * a) := by + change Real.exp (-(C + E + L)) * a = _ + rw [show -(C + E + L) = -L + -(C + E) by ring, Real.exp_add, mul_assoc] + _ ≤ Real.exp (-L) * ((16 : ℝ) ^ (n + 3) * b) := + mul_le_mul_of_nonneg_left hmain (Real.exp_pos _).le + _ ≤ Real.exp (-L) * (Real.exp L * b) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right h16 (Nat.cast_nonneg _)) + (Real.exp_pos _).le + _ = _ := by rw [← mul_assoc, ← Real.exp_add, neg_add_cancel, Real.exp_zero, one_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open CyclicCrootSisask + +noncomputable def properAffineRankBound (P : ℝ) (n : ℕ) : ℝ := + 2 + quarticBogolyubovConstant * (roundedModelLogBudget P n + 1) ^ 4 + +noncomputable def properAffineVolumeLog (P : ℝ) (n : ℕ) : ℝ := + 2 + 16 * (44 + 6 * max P 0 + 94 * n) + +noncomputable def properAffineScaleLog (P : ℝ) (n : ℕ) : ℝ := + 2 * properAffineRankBound P n + properAffineVolumeLog P n + affineRecoveryLogLoss P n + 2 + +noncomputable def properAffineRecoveryLogLoss (P : ℝ) (n : ℕ) : ℝ := + affineRecoveryLogLoss P n + (4 + properAffineScaleLog P n) * properAffineRankBound P n + +theorem affineBoxScale_le_exp {r V A B : ℕ} {R D S : ℝ} + (hB : 0 < B) (hR : 0 ≤ R) (hD : 0 ≤ D) (hS : 0 ≤ S) + (hr : (r : ℝ) ≤ R) (hV : (V : ℝ) ≤ Real.exp D * A) + (hdense : Real.exp (-S) * A ≤ (B : ℝ)) : + ((2 ^ r * V / B + 1 : ℕ) : ℝ) ≤ Real.exp (2 * R + D + S + 2) := by + have hquot : ((2 ^ r * V / B + 1 : ℕ) : ℝ) * B ≤ (2 : ℝ) ^ r * V + B := by + have h : (2 ^ r * V / B + 1) * B ≤ 2 ^ r * V + B := by + calc + _ = (2 ^ r * V / B) * B + B := by ring + _ ≤ _ := Nat.add_le_add_right (Nat.div_mul_le_self _ _) _ + exact_mod_cast h + have htwo : (2 : ℝ) ^ r ≤ Real.exp (2 * R) := by + calc + _ ≤ (Real.exp 2) ^ r := pow_le_pow_left₀ (by norm_num) + (by linarith [Real.add_one_le_exp (2 : ℝ)]) _ + _ = Real.exp (2 * (r : ℝ)) := by rw [← Real.exp_nat_mul]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by linarith only [hr]) + have hA : (A : ℝ) ≤ Real.exp S * B := by + calc + _ = Real.exp S * (Real.exp (-S) * A) := by + rw [← mul_assoc, ← Real.exp_add, add_neg_cancel, Real.exp_zero, one_mul] + _ ≤ _ := mul_le_mul_of_nonneg_left hdense (Real.exp_pos _).le + have hprod : (2 : ℝ) ^ r * V ≤ Real.exp (2 * R + D + S) * B := by + calc + _ ≤ Real.exp (2 * R) * (Real.exp D * A) := by gcongr + _ ≤ Real.exp (2 * R) * (Real.exp D * (Real.exp S * B)) := by gcongr + _ = _ := by simp only [Real.exp_add]; ring + have hplus : Real.exp (2 * R + D + S) + 1 ≤ Real.exp (2 * R + D + S + 2) := by + have hone : 1 ≤ Real.exp (2 * R + D + S) := Real.one_le_exp_iff.mpr (by linarith) + calc + _ ≤ 2 * Real.exp (2 * R + D + S) := by linarith only [hone] + _ ≤ Real.exp 2 * Real.exp (2 * R + D + S) := by + gcongr + linarith [Real.add_one_le_exp (2 : ℝ)] + _ = _ := by rw [← Real.exp_add]; congr 1; ring + apply (mul_le_mul_iff_left₀ (by exact_mod_cast hB : (0 : ℝ) < B)).mp + calc + _ ≤ (2 : ℝ) ^ r * V + B := hquot + _ ≤ Real.exp (2 * R + D + S) * B + B := add_le_add hprod (le_refl (B : ℝ)) + _ = (Real.exp (2 * R + D + S) + 1) * B := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hplus (Nat.cast_nonneg _) + +theorem affineBoxCellCount_le_exp {r k : ℕ} {R T : ℝ} + (hT : 0 ≤ T) (hr : (r : ℝ) ≤ R) (hk : (k : ℝ) ≤ Real.exp T) : + ((4 * k) ^ r : ℕ) ≤ Real.exp ((4 + T) * R) := by + have hbase : (4 : ℝ) * k ≤ Real.exp (4 + T) := by + calc + _ ≤ Real.exp 4 * Real.exp T := by + gcongr + linarith [Real.add_one_le_exp (4 : ℝ)] + _ = _ := (Real.exp_add _ _).symm + calc + (((4 * k) ^ r : ℕ) : ℝ) = ((4 : ℝ) * k) ^ r := by push_cast; rfl + _ ≤ (Real.exp (4 + T)) ^ r := pow_le_pow_left₀ (by positivity) hbase _ + _ = Real.exp ((4 + T) * (r : ℝ)) := by rw [← Real.exp_nat_mul]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hr (by linarith)) + +theorem properAffineVolume_bound (P : ℝ) (n : ℕ) : + 2 * ((2 ^ 14 : ℝ) * (Real.exp (P + 13 * n)) ^ 6 * 16 ^ (n + 1)) ^ 16 ≤ + Real.exp (properAffineVolumeLog P n) := by + calc + _ ≤ Real.exp 2 * (Real.exp (44 + 6 * max P 0 + 94 * n)) ^ 16 := by + gcongr + · linarith [Real.add_one_le_exp (2 : ℝ)] + · exact roundedModelScale_le_exp P n + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + +theorem properAffineSelection_bounds {P : ℝ} (hP : 0 ≤ P) (n r V A B C : ℕ) + (hB : 0 < B) (hr : (r : ℝ) ≤ properAffineRankBound P n) + (hV : (V : ℝ) ≤ + 2 * ((2 ^ 14 : ℝ) * (Real.exp (P + 13 * n)) ^ 6 * 16 ^ (n + 1)) ^ 16 * A) + (hdense : Real.exp (-affineRecoveryLogLoss P n) * A ≤ (B : ℝ)) + (hcell : B ≤ (4 * (2 ^ r * V / B + 1)) ^ r * C) : + ((2 ^ r * V / B + 1 : ℕ) : ℝ) ≤ Real.exp (properAffineScaleLog P n) ∧ + Real.exp (-properAffineRecoveryLogLoss P n) * A ≤ (C : ℝ) := by + have hR : 0 ≤ properAffineRankBound P n := by + have hc := quarticBogolyubovConstant_pos.le + unfold properAffineRankBound + positivity + have hD : 0 ≤ properAffineVolumeLog P n := by unfold properAffineVolumeLog; positivity + have hS : 0 ≤ affineRecoveryLogLoss P n := by + have hc := quarticBogolyubovProgressionConstant_pos.le + unfold affineRecoveryLogLoss + positivity + have hT : 0 ≤ properAffineScaleLog P n := by unfold properAffineScaleLog; positivity + have hV' : (V : ℝ) ≤ Real.exp (properAffineVolumeLog P n) * A := + hV.trans (mul_le_mul_of_nonneg_right (properAffineVolume_bound P n) (Nat.cast_nonneg _)) + have hk := affineBoxScale_le_exp hB hR hD hS hr hV' hdense + have hcount := affineBoxCellCount_le_exp hT hr hk + refine ⟨hk, ?_⟩ + have hcellR : (B : ℝ) ≤ ((4 * (2 ^ r * V / B + 1)) ^ r : ℕ) * (C : ℝ) := by + exact_mod_cast hcell + have hBC : (B : ℝ) ≤ Real.exp ((4 + properAffineScaleLog P n) * properAffineRankBound P n) * C := + hcellR.trans (mul_le_mul_of_nonneg_right hcount (Nat.cast_nonneg _)) + let T := (4 + properAffineScaleLog P n) * properAffineRankBound P n + calc + _ = Real.exp (-T) * (Real.exp (-affineRecoveryLogLoss P n) * A) := by + unfold properAffineRecoveryLogLoss + rw [← mul_assoc, ← Real.exp_add] + congr 1 + congr 1 + dsimp [T] + ring + _ ≤ Real.exp (-T) * (Real.exp T * C) := + mul_le_mul_of_nonneg_left (hdense.trans hBC) (Real.exp_pos _).le + _ = _ := by rw [← mul_assoc, ← Real.exp_add, neg_add_cancel, Real.exp_zero, one_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open CyclicCrootSisask + +theorem exists_quadratic_affine_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + let P := 1024 * (p + 1) + P + properAffineRecoveryLogLoss P 1 ≤ (p + C) ^ C ∧ + properAffineRankBound P 1 ≤ (p + C) ^ C ∧ P ≤ (p + C) ^ C := by + let c := ⌈max quarticBogolyubovProgressionConstant quarticBogolyubovConstant⌉₊ + have hc₀ : quarticBogolyubovProgressionConstant ≤ (c : ℝ) := + (le_max_left _ _).trans (Nat.le_ceil _) + have hc₁ : quarticBogolyubovConstant ≤ (c : ℝ) := + (le_max_right _ _).trans (Nat.le_ceil _) + let PB : Polynomial ℕ := 1024 * (Polynomial.X + 1) + let PZ : Polynomial ℕ := 736 + 96 * PB + 1504 + let PR : Polynomial ℕ := 2 + Polynomial.C c * (PZ + 1) ^ 4 + let PA : Polynomial ℕ := Polynomial.C c * (PZ + 1) ^ 8 + (PB + 13) + 64 + let PV : Polynomial ℕ := 2 + 16 * (44 + 6 * PB + 94) + let PT : Polynomial ℕ := 2 * PR + PV + PA + 2 + let PL : Polynomial ℕ := PA + (4 + PT) * PR + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget (PB + PL + PR) + refine ⟨C, hC, ?_⟩ + intro p hp B + let Z := 736 + 96 * B + 1504 + let R := 2 + (c : ℝ) * (Z + 1) ^ 4 + let A := (c : ℝ) * (Z + 1) ^ 8 + (B + 13) + 64 + let V := 2 + 16 * (44 + 6 * B + 94) + let T := 2 * R + V + A + 2 + have hB : 0 ≤ B := by dsimp [B]; positivity + have hZ : 0 ≤ Z := by dsimp [Z]; positivity + have hR : 0 ≤ R := by dsimp [R]; positivity + have hA : 0 ≤ A := by dsimp [A]; positivity + have hV : 0 ≤ V := by dsimp [V]; positivity + have hT : 0 ≤ T := by dsimp [T]; positivity + have hz : roundedModelLogBudget B 1 = Z := by + simp [roundedModelLogBudget, max_eq_left hB, Z] + have hrank : properAffineRankBound B 1 ≤ R := by + unfold properAffineRankBound + rw [hz] + dsimp [R] + gcongr + have hloss : affineRecoveryLogLoss B 1 ≤ A := by + unfold affineRecoveryLogLoss + rw [hz] + dsimp [A] + norm_num + gcongr + have hvolume : properAffineVolumeLog B 1 = V := by + simp [properAffineVolumeLog, max_eq_left hB, V] + have hscale : properAffineScaleLog B 1 ≤ T := by + unfold properAffineScaleLog + rw [hvolume] + dsimp [T] + linarith + have hrank0 : 0 ≤ properAffineRankBound B 1 := by + have hc := quarticBogolyubovConstant_pos.le + unfold properAffineRankBound + positivity + have hproper : properAffineRecoveryLogLoss B 1 ≤ A + (4 + T) * R := by + unfold properAffineRecoveryLogLoss + exact add_le_add hloss (mul_le_mul (by linarith) hrank hrank0 (by linarith)) + have htotal : B + (A + (4 + T) * R) + R ≤ (p + C) ^ C := by + simpa [PB, PL, PR, PA, PZ, PV, PT, B, Z, R, A, V, T, Polynomial.eval₂_pow] + using hbound p hp + have hproper0 : 0 ≤ A + (4 + T) * R := by positivity + exact ⟨by linarith, by linarith, by linarith⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open CyclicCrootSisask + +theorem exists_sharedFreeProperAffineSelection_bound (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → ∀ n : ℕ, (n : ℝ) ≤ 4 * (s : ℝ) * p → + properAffineRecoveryLogLoss ((p + 2) ^ 3 + 2 * p) n ≤ (p + C) ^ C ∧ + properAffineScaleLog ((p + 2) ^ 3 + 2 * p) n ≤ (p + C) ^ C ∧ + properAffineRankBound ((p + 2) ^ 3 + 2 * p) n ≤ (p + C) ^ C := by + let c := ⌈max quarticBogolyubovProgressionConstant quarticBogolyubovConstant⌉₊ + have hc₀ : quarticBogolyubovProgressionConstant ≤ (c : ℝ) := + (le_max_left _ _).trans (Nat.le_ceil _) + have hc₁ : quarticBogolyubovConstant ≤ (c : ℝ) := + (le_max_right _ _).trans (Nat.le_ceil _) + let PB : Polynomial ℕ := (Polynomial.X + 2) ^ 3 + 2 * Polynomial.X + let PD : Polynomial ℕ := 4 * Polynomial.C s * Polynomial.X + let PZ : Polynomial ℕ := 736 + 96 * PB + 1504 * PD + let PR : Polynomial ℕ := 2 + Polynomial.C c * (PZ + 1) ^ 4 + let PA : Polynomial ℕ := Polynomial.C c * (PZ + 1) ^ 8 + (PB + 13 * PD) + 16 * (PD + 3) + let PV : Polynomial ℕ := 2 + 16 * (44 + 6 * PB + 94 * PD) + let PT : Polynomial ℕ := 2 * PR + PV + PA + 2 + let PL : Polynomial ℕ := PA + (4 + PT) * PR + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget (PL + PT + PR) + refine ⟨C, hC, ?_⟩ + intro p hp n hn + let B := (p + 2) ^ 3 + 2 * p + let D := 4 * (s : ℝ) * p + let Z := 736 + 96 * B + 1504 * D + let R := 2 + (c : ℝ) * (Z + 1) ^ 4 + let A := (c : ℝ) * (Z + 1) ^ 8 + (B + 13 * D) + 16 * (D + 3) + let V := 2 + 16 * (44 + 6 * B + 94 * D) + let T := 2 * R + V + A + 2 + have hB : 0 ≤ B := by dsimp [B]; positivity + have hD : 0 ≤ D := by dsimp [D]; positivity + have hZ : 0 ≤ Z := by dsimp [Z]; positivity + have hR : 0 ≤ R := by dsimp [R]; positivity + have hA : 0 ≤ A := by dsimp [A]; positivity + have hV : 0 ≤ V := by dsimp [V]; positivity + have hT : 0 ≤ T := by dsimp [T]; positivity + have hz : roundedModelLogBudget B n ≤ Z := by + unfold roundedModelLogBudget + rw [max_eq_left hB] + dsimp [Z] + gcongr + have hz0 : 0 ≤ roundedModelLogBudget B n + 1 := by + linarith [roundedModelLogBudget_nonneg B n] + have hrank : properAffineRankBound B n ≤ R := by + unfold properAffineRankBound + dsimp [R] + gcongr + have hloss : affineRecoveryLogLoss B n ≤ A := by + unfold affineRecoveryLogLoss + dsimp [A] + gcongr + have hvolume : properAffineVolumeLog B n ≤ V := by + unfold properAffineVolumeLog + rw [max_eq_left hB] + dsimp [V] + gcongr + have hscale : properAffineScaleLog B n ≤ T := by + unfold properAffineScaleLog + dsimp [T] + linarith only [hrank, hloss, hvolume] + have hrank0 : 0 ≤ properAffineRankBound B n := by + have hc := quarticBogolyubovConstant_pos.le + unfold properAffineRankBound + positivity + have hloss0 : 0 ≤ affineRecoveryLogLoss B n := by + have hc := quarticBogolyubovProgressionConstant_pos.le + unfold affineRecoveryLogLoss + positivity + have hscale0 : 0 ≤ properAffineScaleLog B n := by + unfold properAffineScaleLog properAffineVolumeLog + positivity + have hproper : properAffineRecoveryLogLoss B n ≤ A + (4 + T) * R := by + unfold properAffineRecoveryLogLoss + exact add_le_add hloss (mul_le_mul (by linarith only [hscale]) hrank hrank0 + (by linarith only [hT])) + have heval : (PL + PT + PR).eval₂ (Nat.castRingHom ℝ) p = A + (4 + T) * R + T + R := by + simp [PL, PT, PV, PA, PR, PZ, PD, PB, B, D, Z, R, A, V, T, Polynomial.eval₂_pow] + have htotal := hbound p hp + rw [heval] at htotal + have hproper0 : 0 ≤ A + (4 + T) * R := by positivity + exact ⟨hproper.trans (by linarith only [htotal, hT, hR]), + hscale.trans (by linarith only [htotal, hproper0, hR]), + hrank.trans (by linarith only [htotal, hproper0, hT])⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open CyclicCrootSisask + +theorem exists_sharedFreeAffineSelection_bound (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → ∀ n : ℕ, (n : ℝ) ≤ 4 * (s : ℝ) * p → + affineRecoveryLogLoss ((p + 2) ^ 3 + 2 * p) n ≤ (p + C) ^ C ∧ + 2 + quarticBogolyubovConstant * + (roundedModelLogBudget ((p + 2) ^ 3 + 2 * p) n + 1) ^ 4 ≤ (p + C) ^ C := by + let C₀ := ⌈max quarticBogolyubovProgressionConstant quarticBogolyubovConstant⌉₊ + have hC₀ : quarticBogolyubovProgressionConstant ≤ (C₀ : ℝ) := + (le_max_left _ _).trans (Nat.le_ceil _) + have hC₁ : quarticBogolyubovConstant ≤ (C₀ : ℝ) := + (le_max_right _ _).trans (Nat.le_ceil _) + let PB : Polynomial ℕ := (Polynomial.X + 2) ^ 3 + 2 * Polynomial.X + let PD : Polynomial ℕ := 4 * Polynomial.C s * Polynomial.X + let PZ : Polynomial ℕ := 736 + 96 * PB + 1504 * PD + let T : Polynomial ℕ := Polynomial.C C₀ * (PZ + 1) ^ 8 + + (PB + 13 * PD) + 16 * (PD + 3) + (2 + Polynomial.C C₀ * (PZ + 1) ^ 4) + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget T + refine ⟨C, hC, ?_⟩ + intro p hp n hn + let B := (p + 2) ^ 3 + 2 * p + let D := 4 * (s : ℝ) * p + let U := 736 + 96 * B + 1504 * D + have hB : 0 ≤ B := by dsimp [B]; positivity + have hD : 0 ≤ D := by dsimp [D]; positivity + have hU : 0 ≤ U := by dsimp [U]; positivity + have hz : roundedModelLogBudget B n ≤ U := by + unfold roundedModelLogBudget + rw [max_eq_left hB] + dsimp [U] + gcongr + have hz0 : 0 ≤ roundedModelLogBudget B n + 1 := by + linarith [roundedModelLogBudget_nonneg B n] + have hcost : affineRecoveryLogLoss B n ≤ + (C₀ : ℝ) * (U + 1) ^ 8 + (B + 13 * D) + 16 * (D + 3) := by + unfold affineRecoveryLogLoss + gcongr + have hrank : 2 + quarticBogolyubovConstant * (roundedModelLogBudget B n + 1) ^ 4 ≤ + 2 + (C₀ : ℝ) * (U + 1) ^ 4 := by gcongr + have heval : T.eval₂ (Nat.castRingHom ℝ) p = + (C₀ : ℝ) * (U + 1) ^ 8 + (B + 13 * D) + 16 * (D + 3) + + (2 + (C₀ : ℝ) * (U + 1) ^ 4) := by + simp [T, PZ, PD, PB, B, D, U, Polynomial.eval₂_pow] + have htotal := hbound p hp + rw [heval] at htotal + have hcost0 : 0 ≤ (C₀ : ℝ) * (U + 1) ^ 8 + (B + 13 * D) + 16 * (D + 3) := by + positivity + have hrank0 : 0 ≤ 2 + (C₀ : ℝ) * (U + 1) ^ 4 := by positivity + constructor <;> linarith + +theorem exists_sharedFreeAffineUniform_bound (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ q p : ℝ, 0 ≤ q → q ≤ p → 0 ≤ p → + ∀ n : ℕ, (n : ℝ) ≤ 4 * (s : ℝ) * p → + sharedFreeRecoveryThreshold s q p ≤ (p + C) ^ C ∧ + affineRecoveryLogLoss ((p + 2) ^ 3 + 2 * p) n ≤ (p + C) ^ C ∧ + 2 + quarticBogolyubovConstant * + (roundedModelLogBudget ((p + 2) ^ 3 + 2 * p) n + 1) ^ 4 ≤ (p + C) ^ C := by + obtain ⟨C₁, hC₁, hthreshold⟩ := exists_sharedFreeRecoveryThreshold_bound s + obtain ⟨C₂, hC₂, hselection⟩ := exists_sharedFreeAffineSelection_bound s + let C := C₁ + C₂ + have hC : 2 ≤ C := by dsimp [C]; omega + refine ⟨C, hC, ?_⟩ + intro q p hq hqp hp n hn + have hshift (c : ℕ) (hc : c ≤ C) : (p + c) ^ c ≤ (p + C) ^ C := by + have hcR : (c : ℝ) ≤ C := by exact_mod_cast hc + have hCR : (2 : ℝ) ≤ C := by exact_mod_cast hC + exact (pow_le_pow_left₀ (by positivity) (by linarith : p + c ≤ p + C) c).trans + (pow_le_pow_right₀ (by linarith : 1 ≤ p + C) hc) + have h₁ := hshift C₁ (by dsimp [C]; omega) + have h₂ := hshift C₂ (by dsimp [C]; omega) + have hs := hselection p hp n hn + exact ⟨(hthreshold q p hq hqp hp).trans h₁, hs.1.trans h₂, hs.2.trans h₂⟩ + +noncomputable def sharedFreeAffineConstant (s : ℕ) : ℕ := + (exists_sharedFreeAffineUniform_bound s).choose + + (exists_sharedFreeProperAffineSelection_bound s).choose + +theorem sharedFreeAffineConstant_two_le (s : ℕ) : 2 ≤ sharedFreeAffineConstant s := by + have h := (exists_sharedFreeAffineUniform_bound s).choose_spec.1 + unfold sharedFreeAffineConstant + omega + +theorem sharedFreeAffineConstant_shift_bound (s : ℕ) {p : ℝ} (hp : 0 ≤ p) + (c : ℕ) (hc : c ≤ sharedFreeAffineConstant s) : + (p + c) ^ c ≤ (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s := by + have hcR : (c : ℝ) ≤ sharedFreeAffineConstant s := by exact_mod_cast hc + have hCR : (2 : ℝ) ≤ sharedFreeAffineConstant s := by + exact_mod_cast sharedFreeAffineConstant_two_le s + exact (pow_le_pow_left₀ (by positivity) + (by linarith : p + c ≤ p + sharedFreeAffineConstant s) c).trans + (pow_le_pow_right₀ (by linarith : 1 ≤ p + sharedFreeAffineConstant s) hc) + +theorem sharedFreeAffineConstant_spec (s : ℕ) : + 2 ≤ sharedFreeAffineConstant s ∧ + ∀ q p : ℝ, 0 ≤ q → q ≤ p → 0 ≤ p → + ∀ n : ℕ, (n : ℝ) ≤ 4 * (s : ℝ) * p → + sharedFreeRecoveryThreshold s q p ≤ (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s ∧ + affineRecoveryLogLoss ((p + 2) ^ 3 + 2 * p) n ≤ + (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s ∧ + 2 + quarticBogolyubovConstant * + (roundedModelLogBudget ((p + 2) ^ 3 + 2 * p) n + 1) ^ 4 ≤ + (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s := by + refine ⟨sharedFreeAffineConstant_two_le s, ?_⟩ + intro q p hq hqp hp n hn + have h := (exists_sharedFreeAffineUniform_bound s).choose_spec.2 q p hq hqp hp n hn + have hb := sharedFreeAffineConstant_shift_bound s hp + (exists_sharedFreeAffineUniform_bound s).choose (by unfold sharedFreeAffineConstant; omega) + exact ⟨h.1.trans hb, h.2.1.trans hb, h.2.2.trans hb⟩ + +theorem sharedFreeAffineConstant_proper_spec (s : ℕ) {p : ℝ} (hp : 0 ≤ p) + (n : ℕ) (hn : (n : ℝ) ≤ 4 * (s : ℝ) * p) : + properAffineRecoveryLogLoss ((p + 2) ^ 3 + 2 * p) n ≤ + (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s ∧ + properAffineScaleLog ((p + 2) ^ 3 + 2 * p) n ≤ + (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s ∧ + properAffineRankBound ((p + 2) ^ 3 + 2 * p) n ≤ + (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s := by + have h := (exists_sharedFreeProperAffineSelection_bound s).choose_spec.2 p hp n hn + have hb := sharedFreeAffineConstant_shift_bound s hp + (exists_sharedFreeProperAffineSelection_bound s).choose (by unfold sharedFreeAffineConstant; omega) + exact ⟨h.1.trans hb, h.2.1.trans hb, h.2.2.trans hb⟩ + +theorem sharedFreeRecoveryThreshold_coefficient_bounds (s : ℕ) {q p : ℝ} + (hq : 0 ≤ q) (hp : 0 ≤ p) : + let A := sharedFreeEquationInputBudget s q p + let z := 8 * sharedRefinementInputBudget s p + 1 + (A + 2) ^ 4 ≤ sharedFreeRecoveryThreshold s q p ∧ + 2 * (Real.exp ((A + 2) ^ 3) * + (Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z))) ≤ + Real.exp (sharedFreeRecoveryThreshold s q p) := by + intro A z + have hb := sharedFreeEquationInputBudget_bounds s hq hp + have hA : 0 ≤ A := hb.1 + have hz : 0 ≤ z := by + have hi := (sharedRefinementInputBudget_bounds s hp).2.2.1 + dsimp [z] + linarith + have hbudget : z + ((z + 2) ^ 3 + (z + 2) ^ 36) ≤ A := hb.2.2.2 + have hT : (A + 2) ^ 5 ≤ sharedFreeRecoveryThreshold s q p := le_max_right _ _ + refine ⟨(pow_le_pow_right₀ (by linarith : 1 ≤ A + 2) (by decide : 4 ≤ 5)).trans hT, ?_⟩ + have hzA : z ≤ A := by + have h3 : 0 ≤ (z + 2) ^ 3 := by positivity + have h36 : 0 ≤ (z + 2) ^ 36 := by positivity + linarith + have h18 : (z + 2) ^ 18 ≤ (z + 2) ^ 36 := + pow_le_pow_right₀ (by linarith) (by decide) + have hwA : (z + 2) ^ 3 + (z + 2) ^ 18 + z ≤ A := by linarith + have hsum : Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z) ≤ + 2 * Real.exp A := by + linarith [Real.exp_le_exp.mpr hzA, Real.exp_le_exp.mpr hwA] + have hpoly : (A + 2) ^ 3 + A + 4 ≤ (A + 2) ^ 5 := by + have hh : 0 ≤ A ^ 5 + 10 * A ^ 4 + 39 * A ^ 3 + 74 * A ^ 2 + 67 * A + 20 := by + positivity + nlinarith + calc + _ ≤ 2 * (Real.exp ((A + 2) ^ 3) * (2 * Real.exp A)) := by gcongr + _ = 4 * Real.exp ((A + 2) ^ 3 + A) := by rw [Real.exp_add]; ring + _ ≤ Real.exp 4 * Real.exp ((A + 2) ^ 3 + A) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + linarith [Real.add_one_le_exp (4 : ℝ)] + _ = Real.exp ((A + 2) ^ 3 + A + 4) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp ((A + 2) ^ 5) := Real.exp_le_exp.mpr hpoly + _ ≤ _ := Real.exp_le_exp.mpr hT + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SharedFreeAffineOrbitFamily.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SharedFreeAffineOrbitFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..462574a9f89ad6e70db8fc5a86a02ea04e8bccee --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SharedFreeAffineOrbitFamily.lean @@ -0,0 +1,533 @@ +import OAI.Combinatorics.Progressions.Estimates.FreeCoefficientCorrectionControl +import OAI.Combinatorics.Progressions.Estimates.SharedFreeComparisonLift +import OAI.Combinatorics.Progressions.Polynomial.DegreewiseAffineRecovery +import OAI.Combinatorics.Progressions.Polynomial.DegreewiseProperAffineRecovery + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct BigOperators + +theorem affine_petal_decomposition + {μ ι V : Type*} [Fintype μ] [Fintype ι] [AddCommGroup V] [Module ℚ V] + (b : Basis μ ℚ V) (U : Submodule ℚ V) (K : Submodule ℚ (Fin 4 → V)) + (ℓ : (Fin 4 → V) →ₗ[ℚ] (ι → ℚ)) (hker : LinearMap.ker ℓ = K) + (σ : (ι → ℝ) →ₗ[ℝ] (ℝ ⊗[ℚ] V)) + (hσU : ∀ y, σ y ∈ U.baseChange ℝ) + (hσ : ∀ w ∈ U.baseChange ℝ, + realifyCoordinateMap (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0)) + (σ (realifyCoordinateMap (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0)) w)) = + realifyCoordinateMap (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0)) w) + {C : ℝ} (hC : 0 ≤ C) (hbound : ∀ y, ‖(b.baseChange ℝ).equivFun (σ y)‖ ≤ C * ‖y‖) + {l m : ℕ} (hgrid : ∀ y ∈ realDenominatorGrid l, + (b.baseChange ℝ).equivFun (σ y) ∈ realDenominatorGrid m) + {r : ℕ} (α : ι → ℝ) (β : Fin r → ι → ℝ) (x : Fin r → ℤ) + (w : ℝ ⊗[ℚ] V) (hw : w ∈ U.baseChange ℝ) (q : ι → ℝ) + (hq : q ∈ realDenominatorGrid l) {ε : ℝ} + (he : ‖realifyCoordinateMap (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0)) w - + (α + ∑ j, (x j : ℝ) • β j) - q‖ ≤ ε) : + ∃ E Q P : ℝ ⊗[ℚ] V, E ∈ U.baseChange ℝ ∧ Q ∈ U.baseChange ℝ ∧ + P ∈ (fourPetalSpace U K).baseChange ℝ ∧ + w = (σ α + ∑ j, (x j : ℝ) • σ (β j)) + E + Q + P ∧ + ‖(b.baseChange ℝ).equivFun E‖ ≤ C * ε ∧ + (b.baseChange ℝ).equivFun Q ∈ realDenominatorGrid m := by + let φ := ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0) + let a := realifyCoordinateMap φ w + let e := a - (α + ∑ j, (x j : ℝ) • β j) - q + let P := w - σ a + have hPU : P ∈ U.baseChange ℝ := (U.baseChange ℝ).sub_mem hw (hσU a) + have hzero : realifyCoordinateMap φ P = 0 := by + change realifyCoordinateMap φ (w - σ a) = 0 + rw [map_sub, hσ w hw, sub_self] + have hP : P ∈ (fourPetalSpace U K).baseChange ℝ := by + apply (mem_real_petal_annihilator_iff U K ℓ hker P).mpr + refine ⟨hPU, fun j => ?_⟩ + exact congrFun hzero j + refine ⟨σ e, σ q, P, hσU e, hσU q, hP, ?_, ?_, hgrid q hq⟩ + · dsimp [P, e] + simp only [map_sub, map_add, map_sum, map_smul] + abel + · exact (hbound e).trans (mul_le_mul_of_nonneg_left he hC) + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module VectorPolynomial CyclicCrootSisask +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q) + (F : FreeCoordinateFrame E.basis Q) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ} + {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'} + (D' : R'.CommonData P') + +include F + +theorem exists_shared_free_affine_recovery + (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P') + (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hsplit : ∀ h, g h = ξ * v h) + (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ + (D.commonFreeSpan d).baseChange ℝ) + (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) + (hN : Real.exp ((P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s) ≤ (N : ℝ)) : + let B := (P' + 2) ^ 3 + 2 * P' + let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + ∃ D₁ : R'.CommonData B, D₁.quadruples ⊆ D'.quadruples ∧ D₁.spaces = D'.spaces ∧ + ∃ (n : Fin s → ℕ) + (ℓ : ∀ d : Fin s, (Fin 4 → D.CoefficientFreeLieAlgebra) →ₗ[ℚ] (Fin (n d) → ℚ)) + (m : Fin s → ℕ), + (∀ d, n d ≤ 4 * finrank ℚ D.CoefficientFreeLieAlgebra ∧ + Function.Surjective (ℓ d) ∧ LinearMap.ker (ℓ d) = + fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩) ∧ + (∀ k i j, rationalLogHeight (ℓ d (LinearMap.single ℚ + (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) k (E.basis i)) j) ≤ + fourRefinementAnnihilatorBudget (Q + coefficientFourHeightBudget P')) ∧ + 0 < m d ∧ (m d : ℝ) ≤ Real.exp Λ) ∧ + let a := fun h (d : Fin s) => realifyCoordinateMap + ((ℓ d).comp (LinearMap.single ℚ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) + (coefficients (v h).log (Finsupp.single () (d.val + 1))) + let n₀ := Fintype.card (Σ d : Fin s, Fin (n d)) + (n₀ : ℝ) ≤ 4 * (s : ℝ) * P' ∧ + ∃ J ⊆ H', J.Nonempty ∧ + Real.exp (-Λ) * H'.card ≤ (J.card : ℝ) ∧ + ∃ (r₀ : ℕ) (R₀ : Fin r₀ → ℕ) (η : (Fin r₀ → ℤ) →+ ZMod N) + (h₀ : ZMod N) (α : ∀ d, Fin (n d) → ℝ) (β : Fin r₀ → ∀ d, Fin (n d) → ℝ), + (r₀ : ℝ) ≤ Λ ∧ Set.InjOn η {x | ∀ j, |x j| ≤ (R₀ j : ℤ)} ∧ + (∀ d i, α d i ∈ Set.Ico (0 : ℝ) (1 / m d)) ∧ + (∀ j d i, β j d i ∈ Set.Ico (0 : ℝ) (1 / m d)) ∧ + ∀ h ∈ J, ∃ x : Fin r₀ → ℤ, + (∀ j, |x j| ≤ (R₀ j : ℤ)) ∧ h = h₀ + η x ∧ + ∀ d, ∃ q ∈ realDenominatorGrid (m d), + ‖a h d - (α d + ∑ j, (x j : ℝ) • β j d) - q‖ ≤ + Real.exp Λ / (N : ℝ) ^ (d.val + 1) := by + intro B Λ + classical + have hB : 0 ≤ B := by dsimp only [B]; positivity + let z₀ := 8 * sharedRefinementInputBudget s P' + 1 + let A := sharedFreeEquationInputBudget s Q P' + have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1 + have hbudget₀ := (sharedFreeAffineConstant_spec s).2 Q P' hQ hQP' hP' 0 + (by simpa only [Nat.cast_zero] using + mul_nonneg (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) (Nat.cast_nonneg s)) hP') + have hcut := sharedFreeRecoveryThreshold_spec s hQ hP' N + ((Real.exp_le_exp.mpr hbudget₀.1).trans hN) + have hcoeff := sharedFreeRecoveryThreshold_coefficient_bounds s hQ hP' + obtain ⟨D₁, hsub, hspaces, hblocks⟩ := + D.exists_controlled_shared_free_equations E T hbQ hT F V g hg D' + hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hcut.1 + choose n hn ℓ hsurj hker hheight m hm hmA hnear using hblocks + have hdenom (d : Fin s) : (m d : ℝ) ≤ Real.exp Λ := + (hmA d).trans (Real.exp_le_exp.mpr (hcoeff.1.trans hbudget₀.1)) + have hnum : 2 * (Real.exp ((A + 2) ^ 3) * + (Real.exp z₀ + Real.exp ((z₀ + 2) ^ 3 + (z₀ + 2) ^ 18 + z₀))) ≤ Real.exp Λ := + hcoeff.2.trans (Real.exp_le_exp.mpr hbudget₀.1) + let a := fun h (d : Fin s) => realifyCoordinateMap + ((ℓ d).comp (LinearMap.single ℚ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) + (coefficients (v h).log (Finsupp.single () (d.val + 1))) + let c := fun d : Fin s => realifyCoordinateMap ((ℓ d).comp (fourDiagonalMap (R := ℚ))) + (coefficients ξ.log (Finsupp.single () (d.val + 1))) + let ε := fun d : Fin s => Real.exp ((A + 2) ^ 3) * + ((Real.exp z₀ + Real.exp ((z₀ + 2) ^ 3 + (z₀ + 2) ^ 18 + z₀)) / (N : ℝ) ^ (d.val + 1)) + have hNpos : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + have hε : ∀ d, 0 < ε d := by intro d; dsimp [ε]; positivity + have hsmall : ∀ d, 2 * (m d : ℝ) * ε d ≤ 1 := by + intro d + exact hcut.2 (m d) (d.val + 1) (by omega) (hmA d) + have hnear' : ∀ t ∈ D₁.quadruples, ∀ d, ∃ q ∈ realDenominatorGrid (m d), + ‖c d + (a (rankQuadrupleParameters t 1) d + a (rankQuadrupleParameters t 2) d - + a (rankQuadrupleParameters t 0) d - a (rankQuadrupleParameters t 3) d) - q‖ ≤ ε d := by + intro t ht d + simpa only [a, c, ε, monomialScale, Finsupp.prod_single_index, pow_zero] using hnear d t ht + have hdim : (Fintype.card (Σ d : Fin s, Fin (n d)) : ℝ) ≤ 4 * (s : ℝ) * P' := by + rw [Fintype.card_sigma, Nat.cast_sum] + simp only [Fintype.card_fin] + calc + (∑ d : Fin s, (n d : ℝ)) ≤ ∑ _d : Fin s, 4 * P' := by + apply Finset.sum_le_sum + intro d _hd + have hnR := (Nat.cast_le (α := ℝ)).mpr (hn d) + simp only [Nat.cast_mul, Nat.cast_ofNat] at hnR + exact hnR.trans (mul_le_mul_of_nonneg_left (hT.1.1.trans hQP') (by norm_num)) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + ring + refine ⟨D₁, hsub, hspaces, n, ℓ, m, ?_, hdim, ?_⟩ + · intro d + exact ⟨hn d, hsurj d, hker d, hheight d, hm d, hdenom d⟩ + · obtain ⟨J, hJH, hJ, hsize, r₀, R₀, η, h₀, α, β, hrank, hproper, hα, hβ, hrepr⟩ := + D₁.degreewise_proper_affine_recovery hB a c m hm ε hε hsmall hnear' + have hbudget := sharedFreeAffineConstant_proper_spec s hP' _ hdim + refine ⟨J, hJH, hJ, ?_, r₀, R₀, η, h₀, α, β, hrank.trans hbudget.2.2, hproper, hα, hβ, ?_⟩ + · exact (mul_le_mul_of_nonneg_right + (Real.exp_le_exp.mpr (neg_le_neg hbudget.1)) (Nat.cast_nonneg _)).trans hsize + · intro h hh + obtain ⟨x, hx, hspace, herr⟩ := hrepr h hh + refine ⟨x, hx, hspace, ?_⟩ + intro d + obtain ⟨q, hq, he⟩ := herr d + refine ⟨q, hq, he.trans ?_⟩ + simpa only [ε, mul_div_assoc] using + div_le_div_of_nonneg_right hnum (pow_nonneg (Nat.cast_nonneg N) (d.val + 1)) + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3 + +noncomputable def sharedFreePetalLiftInput (s : ℕ) (q p : ℝ) : ℝ := + 4 * p + fourRefinementAnnihilatorBudget (q + coefficientFourHeightBudget p) + + (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + +noncomputable def sharedFreePetalLiftBudget (s : ℕ) (q p : ℝ) : ℝ := + let t := (sharedFreePetalLiftInput s q p + 2) ^ 4 + 1 + (t + 2) ^ 3 + (t + 2) ^ 36 + (p + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + +end Erdos3 + +namespace Erdos3.NativeRankRelation.CommonData + +open Module VectorPolynomial CyclicCrootSisask +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q) + (F : FreeCoordinateFrame E.basis Q) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ} + {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'} + (D' : R'.CommonData P') + +include F + +theorem exists_shared_free_affine_petal + (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P') + (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hsplit : ∀ h, g h = ξ * v h) + (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ + (D.commonFreeSpan d).baseChange ℝ) + (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) + (hN : Real.exp ((P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s) ≤ (N : ℝ)) : + let B := (P' + 2) ^ 3 + 2 * P' + let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + let L := sharedFreePetalLiftBudget s Q P' + ∃ D₁ : R'.CommonData B, D₁.quadruples ⊆ D'.quadruples ∧ D₁.spaces = D'.spaces ∧ + ∃ J ⊆ H', J.Nonempty ∧ Real.exp (-Λ) * H'.card ≤ (J.card : ℝ) ∧ + ∃ (r₀ : ℕ) (R₀ : Fin r₀ → ℕ) (η : (Fin r₀ → ℤ) →+ ZMod N) (h₀ : ZMod N) + (m : Fin s → ℕ) (α : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + (β : Fin r₀ → Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra), + (r₀ : ℝ) ≤ Λ ∧ Set.InjOn η {x | ∀ j, |x j| ≤ (R₀ j : ℤ)} ∧ (∀ d, 0 < m d ∧ (m d : ℝ) ≤ Real.exp L) ∧ + (∀ d, α d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + ‖(E.basis.baseChange ℝ).equivFun (α d)‖ ≤ Real.exp L) ∧ + (∀ j d, β j d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + ‖(E.basis.baseChange ℝ).equivFun (β j d)‖ ≤ Real.exp L) ∧ + ∀ h ∈ J, ∃ x : Fin r₀ → ℤ, + (∀ j, |x j| ≤ (R₀ j : ℤ)) ∧ h = h₀ + η x ∧ + ∀ d, ∃ e q u : ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra, + e ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + q ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + u ∈ (fourPetalSpace (D.dependentFreeSpan d) + (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ ∧ + coefficients (v h).log (Finsupp.single () (d.val + 1)) = + (α d + ∑ j, (x j : ℝ) • β j d) + e + q + u ∧ + ‖(E.basis.baseChange ℝ).equivFun e‖ ≤ Real.exp L / (N : ℝ) ^ (d.val + 1) ∧ + (E.basis.baseChange ℝ).equivFun q ∈ realDenominatorGrid (m d) := by + intro B Λ L + classical + obtain ⟨D₁, hsub, hspaces, n, ℓ, l, hdata, _hdim, J, hJH, hJ, hcard, + r₀, R₀, η, h₀, α, β, hrank, hproper, hα, hβ, hrepr⟩ := + D.exists_shared_free_affine_recovery E T hbQ hT F V g hg D' + hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hN + let A := sharedFreePetalLiftInput s Q P' + let t := (A + 2) ^ 4 + 1 + let C := (t + 2) ^ 3 + (t + 2) ^ 18 + have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1 + have hΛ : 0 ≤ Λ := by dsimp [Λ]; positivity + have ha : 0 ≤ fourRefinementAnnihilatorBudget (Q + coefficientFourHeightBudget P') := + fourRefinementAnnihilatorBudget_nonneg (add_nonneg hQ (coefficientFourHeightBudget_nonneg hP')) + have hA : 0 ≤ A := by dsimp [A, sharedFreePetalLiftInput]; positivity + have h4A : 4 * P' ≤ A := by dsimp [A, sharedFreePetalLiftInput]; linarith + have hPA : P' ≤ A := by linarith + have hQA : Q ≤ A := hQP'.trans hPA + have hΛA : Λ ≤ A := by dsimp [A, sharedFreePetalLiftInput]; linarith + have haA : fourRefinementAnnihilatorBudget (Q + coefficientFourHeightBudget P') ≤ A := by + dsimp [A, sharedFreePetalLiftInput] + linarith + have hsections (d : Fin s) : + ∃ (σ : (Fin (n d) → ℝ) →ₗ[ℝ] (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)) (m : ℕ), + 0 < m ∧ (m : ℝ) ≤ Real.exp ((t + 2) ^ 3 + (t + 2) ^ 36) ∧ + (∀ y, σ y ∈ (D.dependentFreeSpan d).baseChange ℝ) ∧ + (∀ w ∈ (D.dependentFreeSpan d).baseChange ℝ, + realifyCoordinateMap ((ℓ d).comp (LinearMap.single ℚ + (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) + (σ (realifyCoordinateMap ((ℓ d).comp (LinearMap.single ℚ + (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) w)) = + realifyCoordinateMap ((ℓ d).comp (LinearMap.single ℚ + (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) w) ∧ + (∀ y, ‖(E.basis.baseChange ℝ).equivFun (σ y)‖ ≤ Real.exp C * ‖y‖) ∧ + ∀ y ∈ realDenominatorGrid (l d), + (E.basis.baseChange ℝ).equivFun (σ y) ∈ realDenominatorGrid m := by + obtain ⟨c, hc⟩ := D.exists_dependentFreeSpan_basis E.basis F (by omega) d + obtain ⟨hn, _hsurj, _hker, hheight, hl, hlΛ⟩ := hdata d + have hcspan : Submodule.span ℚ (Set.range (fun j => (c j : D.CoefficientFreeLieAlgebra))) = + D.dependentFreeSpan d := by + change Submodule.span ℚ (Set.range ((D.dependentFreeSpan d).subtype ∘ c)) = _ + rw [Set.range_comp, ← Submodule.map_span, c.span_eq, Submodule.map_top, Submodule.range_subtype] + apply exists_logHeight_subspace_image_section E.basis (D.dependentFreeSpan d) + (fun j => (c j : D.CoefficientFreeLieAlgebra)) hcspan + ((ℓ d).comp (LinearMap.single ℚ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra) 0)) + (l d) hl hA + · simpa only [Fintype.card_fin] using (hT.1.1.trans hQP').trans hPA + · have hnR := (Nat.cast_le (α := ℝ)).mpr hn + simp only [Nat.cast_mul, Nat.cast_ofNat] at hnR + have hdim := mul_le_mul_of_nonneg_left (hT.1.1.trans hQP') (by norm_num : (0 : ℝ) ≤ 4) + simpa only [Fintype.card_fin] using hnR.trans (hdim.trans h4A) + · have hcR : (finrank ℚ (D.dependentFreeSpan d) : ℝ) ≤ + finrank ℚ D.CoefficientFreeLieAlgebra := by + exact_mod_cast Submodule.finrank_le (D.dependentFreeSpan d) + simpa only [Fintype.card_fin] using hcR.trans ((hT.1.1.trans hQP').trans hPA) + · intro j i + exact (hc j i).trans hQA + · intro i j + exact (hheight 0 i j).trans haA + · exact hlΛ.trans (Real.exp_le_exp.mpr hΛA) + choose σ m hm hmb hσU hσfix hσnorm hσgrid using hsections + have ht : 0 ≤ t := by dsimp [t]; positivity + have h18 : (t + 2) ^ 18 ≤ (t + 2) ^ 36 := pow_le_pow_right₀ (by linarith) (by decide) + have hL : L = (t + 2) ^ 3 + (t + 2) ^ 36 + Λ := rfl + have hCL : C + Λ ≤ L := by dsimp [C]; rw [hL]; linarith + have hCL' : C ≤ L := (le_add_of_nonneg_right hΛ).trans hCL + have hunit (d : Fin s) (y : Fin (n d) → ℝ) + (hy : ∀ i, y i ∈ Set.Ico (0 : ℝ) (1 / l d)) : ‖y‖ ≤ 1 := by + have hl : 0 < l d := (hdata d).2.2.2.2.1 + have hlR : (0 : ℝ) < l d := by exact_mod_cast hl + have hl1 : (1 : ℝ) ≤ l d := by exact_mod_cast hl + apply (pi_norm_le_iff_of_nonneg (by norm_num : (0 : ℝ) ≤ 1)).mpr + intro i + rw [Real.norm_eq_abs, abs_of_nonneg (hy i).1] + exact (hy i).2.le.trans ((div_le_one hlR).mpr hl1) + have hσunit (d : Fin s) (y : Fin (n d) → ℝ) + (hy : ∀ i, y i ∈ Set.Ico (0 : ℝ) (1 / l d)) : + ‖(E.basis.baseChange ℝ).equivFun (σ d y)‖ ≤ Real.exp L := by + calc + _ ≤ Real.exp C * ‖y‖ := hσnorm d y + _ ≤ Real.exp C * 1 := mul_le_mul_of_nonneg_left (hunit d y hy) (Real.exp_pos _).le + _ ≤ _ := by rw [mul_one]; exact Real.exp_le_exp.mpr hCL' + refine ⟨D₁, hsub, hspaces, J, hJH, hJ, hcard, r₀, R₀, η, h₀, m, + (fun d => σ d (α d)), (fun j d => σ d (β j d)), hrank, hproper, ?_, ?_, ?_, ?_⟩ + · intro d + exact ⟨hm d, (hmb d).trans (Real.exp_le_exp.mpr (by rw [hL]; linarith))⟩ + · intro d + exact ⟨hσU d _, hσunit d _ (hα d)⟩ + · intro j d + exact ⟨hσU d _, hσunit d _ (hβ j d)⟩ + · intro h hh + obtain ⟨x, hx, hspace, herr⟩ := hrepr h hh + refine ⟨x, hx, hspace, ?_⟩ + intro d + obtain ⟨q, hq, he⟩ := herr d + obtain ⟨e, q', u, heU, hqU, hu, heq, hbound, hgrid⟩ := + affine_petal_decomposition E.basis (D.dependentFreeSpan d) _ (ℓ d) (hdata d).2.2.1 + (σ d) (hσU d) (hσfix d) (Real.exp_pos _).le (hσnorm d) (hσgrid d) + (α d) (fun j => β j d) x (coefficients (v h).log (Finsupp.single () (d.val + 1))) + (hv h d) q hq he + refine ⟨e, q', u, heU, hqU, hu, heq, hbound.trans ?_, hgrid⟩ + calc + Real.exp C * (Real.exp Λ / (N : ℝ) ^ (d.val + 1)) = + Real.exp (C + Λ) / (N : ℝ) ^ (d.val + 1) := by rw [← mul_div_assoc, ← Real.exp_add] + _ ≤ _ := div_le_div_of_nonneg_right (Real.exp_le_exp.mpr hCL) (by positivity) + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module VectorPolynomial CyclicCrootSisask +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q) + (F : FreeCoordinateFrame E.basis Q) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ} + {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'} + (D' : R'.CommonData P') + +include F + +theorem exists_shared_free_affine_orbit_family + (hTfil : T.filtration = D.coefficientFreeFiltration) + (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P') + (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hsplit : ∀ h, g h = ξ * v h) + (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ + (D.commonFreeSpan d).baseChange ℝ) + (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) + (hN : Real.exp ((P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s) ≤ (N : ℝ)) : + let B := (P' + 2) ^ 3 + 2 * P' + let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + let L := sharedFreePetalLiftBudget s Q P' + ∃ D₁ : R'.CommonData B, D₁.quadruples ⊆ D'.quadruples ∧ D₁.spaces = D'.spaces ∧ + ∃ J ⊆ H', J.Nonempty ∧ Real.exp (-Λ) * H'.card ≤ (J.card : ℝ) ∧ + ∃ (r₀ : ℕ) (R₀ : Fin r₀ → ℕ) (η : (Fin r₀ → ℤ) →+ ZMod N) (h₀ : ZMod N) + (m : ℕ) (α : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + (β : Fin r₀ → Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra), + (r₀ : ℝ) ≤ Λ ∧ Set.InjOn η {x | ∀ j, |x j| ≤ (R₀ j : ℤ)} ∧ 0 < m ∧ (m : ℝ) ≤ Real.exp ((s : ℝ) * L) ∧ + (∀ d, α d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + ‖(E.basis.baseChange ℝ).equivFun (α d)‖ ≤ Real.exp L) ∧ + (∀ j d, β j d ∈ (D.dependentFreeSpan d).baseChange ℝ ∧ + ‖(E.basis.baseChange ℝ).equivFun (β j d)‖ ≤ Real.exp L) ∧ + ∀ h ∈ J, ∃ x : Fin r₀ → ℤ, + (∀ j, |x j| ≤ (R₀ j : ℤ)) ∧ h = h₀ + η x ∧ + ∃ A ε ρ U : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1), + A.log = positiveUnivariate (fun d => α d + ∑ j, (x j : ℝ) • β j d) ∧ + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 A = 1 ∧ + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 ε = 1 ∧ + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 ρ = 1 ∧ + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 U = 1 ∧ + CoefficientBound (E.basis.baseChange ℝ) (fun _ : Unit => (N : ℝ)) (Real.exp L) ε.log ∧ + CoefficientGrid (E.basis.baseChange ℝ) m ρ.log ∧ + ∀ d : Fin s, + coefficients U.log (Finsupp.single () (d.val + 1)) ∈ + (fourPetalSpace (D.dependentFreeSpan d) + (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩))).baseChange ℝ ∧ + coefficients (v h).log (Finsupp.single () (d.val + 1)) = + coefficients A.log (Finsupp.single () (d.val + 1)) + + coefficients ε.log (Finsupp.single () (d.val + 1)) + + coefficients ρ.log (Finsupp.single () (d.val + 1)) + + coefficients U.log (Finsupp.single () (d.val + 1)) := by + intro B Λ L + classical + obtain ⟨D₁, hsub, hspaces, J, hJH, hJ, hcard, r₀, R₀, η, h₀, l, α, β, + hrank, hproper, hl, hα, hβ, hrepr⟩ := + D.exists_shared_free_affine_petal E T hbQ hT F V g hg D' + hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hN + let m := ∏ d, l d + have hm : 0 < m := Finset.prod_pos (fun d _ => (hl d).1) + have hdiv (d : Fin s) : l d ∣ m := Finset.dvd_prod_of_mem l (Finset.mem_univ d) + have hmb : (m : ℝ) ≤ Real.exp ((s : ℝ) * L) := by + change ((∏ d, l d : ℕ) : ℝ) ≤ _ + rw [Nat.cast_prod] + calc + _ ≤ ∏ _d : Fin s, Real.exp L := + Finset.prod_le_prod₀ (fun d _ => Nat.cast_nonneg (l d)) (fun d _ => (hl d).2) + _ = _ := by rw [Finset.prod_const, Finset.card_univ, Fintype.card_fin, Real.exp_nat_mul] + refine ⟨D₁, hsub, hspaces, J, hJH, hJ, hcard, r₀, R₀, η, h₀, m, α, β, + hrank, hproper, hm, hmb, hα, hβ, ?_⟩ + intro h hh + obtain ⟨x, hx, hspace, hcoeff⟩ := hrepr h hh + choose e q u he hq hu heq herr hgrid using hcoeff + have hdep (d : Fin s) := + Submodule.baseChange_mono ℝ (D.dependentFreeSpan_le_coefficientFreeSpan d) + have ha (d : Fin s) : α d + ∑ j, (x j : ℝ) • β j d ∈ + (D.coefficientFreeSpan d).baseChange ℝ := by + apply hdep d + exact Submodule.add_mem _ (hα d).1 + (Submodule.sum_mem _ (fun j _ => Submodule.smul_mem _ _ (hβ j d).1)) + have huC (d : Fin s) : u d ∈ (D.coefficientFreeSpan d).baseChange ℝ := + hdep d (Submodule.baseChange_mono ℝ inf_le_left (hu d)) + obtain ⟨A, hA, hA0⟩ := D.exists_native_freeCoefficientPolynomialOrbit E T hTfil _ ha + obtain ⟨ε, hε, hε0⟩ := D.exists_native_freeCoefficientPolynomialOrbit E T hTfil e + (fun d => hdep d (he d)) + obtain ⟨ρ, hρ, hρ0⟩ := D.exists_native_freeCoefficientPolynomialOrbit E T hTfil q + (fun d => hdep d (hq d)) + obtain ⟨U, hU, hU0⟩ := D.exists_native_freeCoefficientPolynomialOrbit E T hTfil u huC + refine ⟨x, hx, hspace, A, ε, ρ, U, hA, hA0, hε0, hρ0, hU0, ?_, ?_, ?_⟩ + · rw [hε] + apply positiveUnivariate_coefficientBound (E.basis.baseChange ℝ) e + (fun _ : Unit => (N : ℝ)) (fun _ => by exact_mod_cast NeZero.pos N) (Real.exp_pos L).le + intro d + simpa only [monomialScale, Finsupp.prod_single_index, pow_zero] using herr d + · rw [hρ] + apply positiveUnivariate_coefficientGrid + exact fun d => realDenominatorGrid_subset_of_dvd (hl d).1 (hdiv d) (hgrid d) + · intro d + rw [hA, hε, hρ, hU, positiveUnivariate_coefficient, positiveUnivariate_coefficient, + positiveUnivariate_coefficient, positiveUnivariate_coefficient] + exact ⟨hu d, heq d⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ShiftedResidueSiteComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ShiftedResidueSiteComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2a030cab8c149a96ab24a297fcc9f65f76c8ce7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ShiftedResidueSiteComparison.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Lattices.PhysicalResidueOffsetShift + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +theorem refinedResidue_shifted_site_error {D I J N : Type*} + [Fintype D] [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] + (A : Matrix (Unit ⊕ I) (Unit ⊕ I) ℤ) (B : Matrix (Unit ⊕ I) J ℤ) + (C R : D → Matrix (Unit ⊕ I) N ℤ) + (m : ℕ) [NeZero m] + (hp : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ pivotFullImage A B) + (q : D → ℕ) (hq : ∀ d, 0 < q d) (residue : D → N → ℤ) + (hresidue : ∀ d j, |(residue d j : ℝ)| ≤ q d) + (hCR : ∀ d, integerResidueMatrix (C d) (q d * m) = integerResidueMatrix (R d) (q d * m)) + (f : D → ((Unit ⊕ I) → ℝ) → ℝ) {K : ℝ≥0} (hf : ∀ d, LipschitzWith K (f d)) + (H : D → ℝ) (hH : ∀ d, 0 < H d) + (mass : D → ((Unit ⊕ I) → ℤ) → ℝ) + {G cap E δ b r : ℝ} (hG : 0 ≤ G) (hcap0 : 0 ≤ cap) (hE : 0 ≤ E) (hδ : 0 ≤ δ) + (hb : 0 < b) (hr : 0 < r) + (hi : ∀ d, ((pivotFullImage A (Matrix.fromCols B (R d))).toAddSubgroup.index : ℝ) ≤ G) + (hcap : ∀ d v, |f d v| ≤ cap) + (hmass : ∀ d v, |mass d v - + maskedIntegerImageDensity A (Matrix.fromCols B (C d)) (fun _ => H d) (f d) v| ≤ E) + (hmove : ∀ d i, (∑ j, |((C d i j - R d i j : ℤ) : ℝ)|) ≤ δ * H d) + (v : D → (Unit ⊕ I) → ℤ) + (hv : ∀ d i, |((spatialStar (v d) i : ℤ) : ℝ) / H d| ≤ b) : + let shift := fun d => residueMatrixShift (C d) (R d) (q d) (residue d) + let E' := E + G * K * δ + ‖((∏ d, mass d (v d - shift d) : ℝ) : ℂ) - + ∏ d, spatialSiteApprox A (Matrix.fromCols B (R d)) m (f d) (H d) b r (v d)‖ ≤ + Fintype.card D * (E' + 4 * G * K * r) * (1 + G * cap + E') ^ Fintype.card D := by + intro shift E' + have hpfull (d) : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ + pivotFullImage A (Matrix.fromCols B (R d)) := by + rw [pivotFullImage_split] + exact hp.trans le_sup_left + have hshift (d) : shift d ∈ integerScalarLattice (Unit ⊕ I) (m : ℤ) := + (residueMatrixShift_spec (C d) (R d) (q d) m (hq d) (hCR d) (residue d)).2 + have hnorm (d) : ‖fun i => ((-shift d) i : ℝ) / H d‖ ≤ δ := by + apply (pi_norm_le_iff_of_nonneg hδ).mpr + intro i + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hH d)] + rw [Pi.neg_apply, Int.cast_neg, abs_neg, div_le_iff₀ (hH d)] + exact (residueMatrixShift_bound (C d) (R d) (q d) m (hq d) (hCR d) + (residue d) (hresidue d) i).trans (hmove d i) + have hmass' (d) (w : (Unit ⊕ I) → ℤ) : + |mass d (w - shift d) - + maskedIntegerImageDensity A (Matrix.fromCols B (R d)) (fun _ => H d) (f d) w| ≤ E' := by + have hmod : integerResidueMatrix (C d) m = integerResidueMatrix (R d) m := + integerResidueMatrix_reduce (C d) (R d) (Nat.dvd_mul_left m (q d)) (hCR d) + have h := shiftedMass_residueMask_error A B (C d) (R d) m hp hmod + (fun _ => H d) (f d) (hf d) (-shift d) + ((integerScalarLattice (Unit ⊕ I) (m : ℤ)).neg_mem (hshift d)) (hi d) (mass d) (hmass d) w + calc + _ ≤ E + G * K * ‖fun i => ((-shift d) i : ℝ) / H d‖ := by + simpa only [sub_eq_add_neg] using h + _ ≤ E' := add_le_add le_rfl (mul_le_mul_of_nonneg_left (hnorm d) + (mul_nonneg hG K.coe_nonneg)) + have hE' : 0 ≤ E' := by dsimp only [E']; positivity + exact vectorSpatialSiteApprox_error A (fun d => Matrix.fromCols B (R d)) m hpfull f hf H + (fun d w => mass d (w - shift d)) hG hcap0 hE' hb hr hi hcap hmass' v hv + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ShortIntegerCubeBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ShortIntegerCubeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..aeddae0db771d025f2125b13d4b15ce304f4a98b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ShortIntegerCubeBudget.lean @@ -0,0 +1,375 @@ +import OAI.Combinatorics.Progressions.Fourier.FourierLawTransport +import OAI.Combinatorics.Progressions.Polynomial.CommonPolynomialScale + +namespace OAI + +section + +namespace Erdos3 + +theorem natCeil_le_exp_succ {x P : ℝ} (hx : 0 ≤ x) (hP : 0 ≤ P) + (h : x ≤ Real.exp P) : (⌈x⌉₊ : ℝ) ≤ Real.exp (P+1) := by + apply (Nat.ceil_lt_add_one hx).le.trans + simpa only [add_comm x 1] using one_add_le_exp_succ hP h + +theorem natFinsetSup_cast_le {I : Type*} (s : Finset I) (f : I → ℕ) + {P : ℝ} (hP : 0 ≤ P) (hf : ∀ i ∈ s, (f i : ℝ) ≤ P) : + ((s.sup f : ℕ) : ℝ) ≤ P := by + apply (Nat.le_floor_iff hP).mp + exact Finset.sup_le_iff.mpr (fun i hi => (Nat.le_floor_iff hP).mpr (hf i hi)) + +theorem integerPolynomialInitialScale_exp_bound {ε P Q : ℝ} + (hε : 0 < ε) (hP : 0 ≤ P) (hQ : 0 ≤ Q) + (hA : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hεQ : ε⁻¹ ≤ Real.exp Q) : + (integerPolynomialInitialScale ε : ℝ) ≤ Real.exp (P+Q+17) := by + have h8 : (8 : ℝ) ≤ Real.exp 16 := by linarith [Real.add_one_le_exp (16 : ℝ)] + have hx : 8 * (probabilityProfileLipschitz : ℝ) / ε ≤ Real.exp (P+Q+16) := by + rw [div_eq_mul_inv] + calc + _ ≤ Real.exp 16 * Real.exp P * Real.exp Q := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hc := natCeil_le_exp_succ (by positivity) (by positivity) hx + rw [show P+Q+16+1 = P+Q+17 by ring] at hc + simp only [integerPolynomialInitialScale, Nat.cast_max, Nat.cast_one] + exact max_le (Real.one_le_exp (by positivity)) hc + +theorem principalSamplingGapRatio_exp_bound {γ P Q : ℝ} + (hγ : 0 < γ) (hP : 0 ≤ P) (hQ : 0 ≤ Q) + (hA : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hγQ : γ⁻¹ ≤ Real.exp Q) : + (principalSamplingGapRatio γ : ℝ) ≤ Real.exp (P+Q+17) := by + have h16 : (16 : ℝ) ≤ Real.exp 16 := by linarith [Real.add_one_le_exp (16 : ℝ)] + have hx : 16 * (probabilityProfileLipschitz : ℝ) / γ ≤ Real.exp (P+Q+16) := by + rw [div_eq_mul_inv] + calc + _ ≤ Real.exp 16 * Real.exp P * Real.exp Q := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hmax := max_le (Real.one_le_exp (by positivity : 0 ≤ P+Q+16)) hx + have hc := natCeil_le_exp_succ (le_trans zero_le_one (le_max_left _ _)) + (by positivity) hmax + simpa only [principalSamplingGapRatio, show P+Q+16+1 = P+Q+17 by ring] using hc + +theorem commonPolynomialGapRatio_exp_bound {I : Type*} [Fintype I] + (γ : I → ℝ) {P Q : ℝ} (hγ : ∀ i, 0 < γ i) (hP : 0 ≤ P) (hQ : 0 ≤ Q) + (hA : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hγQ : ∀ i, (γ i)⁻¹ ≤ Real.exp Q) : + (commonPolynomialGapRatio γ : ℝ) ≤ Real.exp (P+Q+17) := by + simp only [commonPolynomialGapRatio, Nat.cast_max, Nat.cast_one] + refine max_le (Real.one_le_exp (by positivity)) ?_ + apply natFinsetSup_cast_le _ _ (Real.exp_nonneg _) + exact fun i _ => principalSamplingGapRatio_exp_bound (hγ i) hP hQ hA (hγQ i) + +theorem commonPolynomialInitialScale_exp_bound {I : Type*} [Fintype I] + (ε : I → ℝ) (L₀ : ℕ) {P Q : ℝ} (hε : ∀ i, 0 < ε i) (hP : 0 ≤ P) (hQ : 0 ≤ Q) + (hA : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hεQ : ∀ i, (ε i)⁻¹ ≤ Real.exp Q) (hL₀ : (L₀ : ℝ) ≤ Real.exp P) : + (commonPolynomialInitialScale L₀ ε : ℝ) ≤ Real.exp (P+Q+17) := by + simp only [commonPolynomialInitialScale, Nat.cast_max, Nat.cast_one] + refine max_le (hL₀.trans (Real.exp_le_exp.mpr (by linarith))) + (max_le (Real.one_le_exp (by positivity)) ?_) + apply natFinsetSup_cast_le _ _ (Real.exp_nonneg _) + exact fun i _ => integerPolynomialInitialScale_exp_bound (hε i) hP hQ hA (hεQ i) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def integerAxisShortBound (h T : ℕ) (γ : ℝ) : ℕ := + 2*inactiveDenominator γ*(2*T)^h + +theorem integerAxisSideLength_inactive_of_short {h K L T : ℕ} {γ : ℝ} + (hTL : T ≤ L) (hshort : integerAxisSideLength h K L γ < T) : + K ≤ L^h ∧ integerAxisSideLength h K L γ = inactiveSideLength h K (inactiveDenominator γ) := by + have ha : ¬ L^h < K := by + intro ha + have hside : integerAxisSideLength h K L γ = L := by simp [integerAxisSideLength, ha] + rw [hside] at hshort + omega + exact ⟨Nat.le_of_not_gt ha, by simp [integerAxisSideLength, ha]⟩ + +theorem integerAxisSideLength_short_scale {h K L T : ℕ} {γ : ℝ} + (hh : 0 < h) (hT : 0 < T) (hTL : T ≤ L) + (hshort : integerAxisSideLength h K L γ < T) : + K ≤ integerAxisShortBound h T γ := by + obtain ⟨_, heq⟩ := integerAxisSideLength_inactive_of_short hTL hshort + rw [heq] at hshort + let q := inactiveDenominator γ + have hq : 0 < q := inactiveDenominator_pos γ + change K ≤ 2*q*(2*T)^h + by_cases hlarge : 2*q ≤ K + · calc + K ≤ q*2^h*inactiveSideLength h K q^h := (inactiveSideLength_lower_power hh hq hlarge).le + _ ≤ q*2^h*T^h := Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hshort.le h) + _ = q*(2*T)^h := by rw [mul_pow]; ring + _ ≤ 2*q*(2*T)^h := Nat.mul_le_mul_right _ (by omega) + · have hp : 0 < (2*T)^h := pow_pos (by omega) h + exact (Nat.le_of_lt (Nat.lt_of_not_ge hlarge)).trans (Nat.le_mul_of_pos_right _ hp) + +theorem integerAxisSideLength_long_or_bounded {h K L T : ℕ} {γ : ℝ} + (hh : 0 < h) (hT : 0 < T) (hTL : T ≤ L) : + T ≤ integerAxisSideLength h K L γ ∨ K ≤ integerAxisShortBound h T γ := by + by_cases hs : T ≤ integerAxisSideLength h K L γ + · exact Or.inl hs + · exact Or.inr (integerAxisSideLength_short_scale hh hT hTL (Nat.lt_of_not_ge hs)) + +theorem inactiveDenominator_le_exp {γ p : ℝ} (hγ : 0 < γ) (hp : 0 ≤ p) + (hγp : γ⁻¹ ≤ Real.exp p) : + (inactiveDenominator γ : ℝ) ≤ Real.exp (p+1) := by + simp only [inactiveDenominator, Nat.cast_max, Nat.cast_one] + exact max_le (Real.one_le_exp_iff.mpr (by linarith)) + (natCeil_le_exp_succ (by positivity) hp hγp) + +theorem integerAxisShortBound_le_exp (h T : ℕ) {γ p t : ℝ} + (hγ : 0 < γ) (hp : 0 ≤ p) (hγp : γ⁻¹ ≤ Real.exp p) (hT : (T : ℝ) ≤ Real.exp t) : + (integerAxisShortBound h T γ : ℝ) ≤ Real.exp (p+2+h*(t+1)) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hq := inactiveDenominator_le_exp hγ hp hγp + have hbase : (2*T : ℝ) ≤ Real.exp (t+1) := by + calc + _ ≤ Real.exp 1*Real.exp t := mul_le_mul htwo hT (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add, add_comm] + simp only [integerAxisShortBound, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_pow] + calc + _ ≤ Real.exp 1*Real.exp (p+1)*(Real.exp (t+1))^h := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add]; congr 1; ring + +theorem integerAxisPrincipalPMF_pure_of_short {h K L T : ℕ} + (hh : 0 < h) (hK : 0 < K) (hL : 0 < L) {γ : ℝ} (hγ : 0 < γ) + (hgap : L^h < K → (principalSamplingGapRatio γ*L)^h ≤ K) + (hTL : T ≤ L) (hshort : integerAxisSideLength h K L γ < T) : + integerAxisPrincipalPMF h K L hh hK hL γ hγ hgap = + PMF.pure (inactivePrincipalCoefficient K (inactiveDenominator γ)) := + integerAxisPrincipalPMF_inactive hh hK hL hγ hgap + (integerAxisSideLength_inactive_of_short hTL hshort).1 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def shortIntegerImageAxis {X J : Type} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : (J → ℤ) → X → J → ℤ) (Q : ℕ) + {h K L T : ℕ} [NeZero K] {γ : ℝ} (hh : 0 < h) (hT : 0 < T) (hTL : T ≤ L) + (hshort : integerAxisSideLength h K L γ < T) + (hY : ∀ center x, p.weight x ≠ 0 → ∀ j, + |(Y center x j : ℝ)-center j| ≤ (Q : ℝ)*K) : IntegerFourierAxis := + boundedIntegerFourierAxis p Y K Q ((2*Q+1)*integerAxisShortBound h T γ) + (Nat.mul_le_mul_left _ (integerAxisSideLength_short_scale hh hT hTL hshort)) hY + +theorem shortIntegerImageAxis_exact {X J : Type} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : (J → ℤ) → X → J → ℤ) (Q : ℕ) + {h K L T : ℕ} [NeZero K] {γ : ℝ} (hh : 0 < h) (hT : 0 < T) (hTL : T ≤ L) + (hshort : integerAxisSideLength h K L γ < T) + (hY : ∀ center x, p.weight x ≠ 0 → ∀ j, + |(Y center x j : ℝ)-center j| ≤ (Q : ℝ)*K) : + let A := shortIntegerImageAxis p Y Q hh hT hTL hshort hY + A.law = p ∧ A.image = Y ∧ A.scale = K ∧ A.countExponent = 0 ∧ + ∀ ε, A.residualBound ε = 0 := ⟨rfl, rfl, rfl, rfl, fun _ => rfl⟩ + +theorem shortIntegerImageAllowance_le_exp (h T Q : ℕ) {γ u t r : ℝ} + (hγ : 0 < γ) (hu : 0 ≤ u) (hγu : γ⁻¹ ≤ Real.exp u) + (hTt : (T : ℝ) ≤ Real.exp t) (hr : 0 ≤ r) (hQr : (Q : ℝ) ≤ Real.exp r) : + (((2*Q+1)*integerAxisShortBound h T γ : ℕ) : ℝ) ≤ + Real.exp (r+u+4+h*(t+1)) := by + have h1 : 1 ≤ Real.exp r := Real.one_le_exp_iff.mpr hr + have h3 : (3 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hfactor : (2*Q+1 : ℝ) ≤ Real.exp (r+2) := by + calc + _ ≤ 3*Real.exp r := by linarith + _ ≤ Real.exp 2*Real.exp r := mul_le_mul_of_nonneg_right h3 (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add, add_comm] + push_cast + calc + _ ≤ Real.exp (r+2)*Real.exp (u+2+h*(t+1)) := + mul_le_mul hfactor (integerAxisShortBound_le_exp h T hγ hu hγu hTt) + (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem shortIntegerImageAxis_log_bounds {X J : Type} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : (J → ℤ) → X → J → ℤ) (Q : ℕ) + {h K L T : ℕ} [NeZero K] {γ : ℝ} (hh : 0 < h) (hT : 0 < T) (hTL : T ≤ L) + (hshort : integerAxisSideLength h K L γ < T) + (hY : ∀ center x, p.weight x ≠ 0 → ∀ j, + |(Y center x j : ℝ)-center j| ≤ (Q : ℝ)*K) + {u t r : ℝ} (hγ : 0 < γ) (hu : 0 ≤ u) (hγu : γ⁻¹ ≤ Real.exp u) + (hTt : (T : ℝ) ≤ Real.exp t) (hr : 0 ≤ r) (hQr : (Q : ℝ) ≤ Real.exp r) : + let A := shortIntegerImageAxis p Y Q hh hT hTL hshort hY + let V := r+u+4+h*(t+1) + (A.period : ℝ) ≤ Real.exp V ∧ + A.countConstant ≤ Real.exp (Fintype.card J*V) ∧ + A.coefficientCap ≤ Real.exp (Fintype.card J*V) ∧ + ∀ ε, A.denominatorBound ε ≤ Real.exp V := by + let B := (2*Q+1)*integerAxisShortBound h T γ + let V := r+u+4+h*(t+1) + have hB : (B : ℝ) ≤ Real.exp V := shortIntegerImageAllowance_le_exp h T Q hγ hu hγu hTt hr hQr + have hcap : (B : ℝ)^Fintype.card J ≤ Real.exp (Fintype.card J*V) := by + simpa only [Real.exp_nat_mul] using pow_le_pow_left₀ (Nat.cast_nonneg B) hB (Fintype.card J) + refine ⟨?_, hcap, hcap, fun _ => hB⟩ + change (((2*Q+1)*K : ℕ) : ℝ) ≤ _ + apply le_trans _ hB + exact_mod_cast Nat.mul_le_mul_left (2*Q+1) (integerAxisSideLength_short_scale hh hT hTL hshort) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem shortIntegerAxis_block_volume {b g q K L T : ℕ} {γ : ℝ} + (hg : 0 < g) (hK : 0 < K) (hTL : T ≤ L) + (hshort : integerAxisSideLength g K L γ < T) + (s : Fin b → Fin g → FiniteCubeSlice q) + (hlen : ∀ a j, (s a j).length ≤ integerAxisSideLength g K L γ) (a : Fin b) : + |(inactivePrincipalCoefficient K (inactiveDenominator γ) : ℝ)| * + ∏ j, ((s a j).length : ℝ) ≤ (1/(inactiveDenominator γ : ℝ))*K := by + have heq := (integerAxisSideLength_inactive_of_short hTL hshort).2 + have hp : (∏ j, ((s a j).length : ℝ)) ≤ + (inactiveSideLength g K (inactiveDenominator γ) : ℝ)^g := by + calc + _ ≤ ∏ _j : Fin g, (inactiveSideLength g K (inactiveDenominator γ) : ℝ) := by + apply Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) + intro j _ + exact_mod_cast (hlen a j).trans_eq heq + _ = _ := by simp + have hb := inactivePrincipal_scaled_upper hg hK (inactiveDenominator_pos γ) + have hKr : (0 : ℝ) < K := by exact_mod_cast hK + exact (mul_le_mul_of_nonneg_left hp (abs_nonneg _)).trans ((div_le_iff₀ hKr).mp hb) + +noncomputable def shortIntegerCubeFourierAxis {b g q K L T : ℕ} [NeZero K] {γ : ℝ} + (hg : 0 < g) (hT : 0 < T) (hTL : T ≤ L) + (hshort : integerAxisSideLength g K L γ < T) + (s : Fin b → Fin g → FiniteCubeSlice q) + (w : CubeSliceBlockDomain s Unit → ℝ) (hw : ∀ x, 0 ≤ w x) (hmass : 0 < ∑ x, w x) + (hlen : ∀ a j, (s a j).length ≤ integerAxisSideLength g K L γ) + {O : ℝ} (hO : 0 ≤ O) (hroot : ∀ a j, |((s a j).root : ℝ)| ≤ O*(s a j).length) + (J : Finset (Finset (Fin q))) (hJ : ∀ S ∈ J, S.card ≤ g) : IntegerFourierAxis := + boundedCubeSliceFourierAxis s w hw hmass + (fun _ _ => inactivePrincipalCoefficient K (inactiveDenominator γ)) + (fun _ => |(inactivePrincipalCoefficient K (inactiveDenominator γ) : ℝ)|) + hO (fun _ _ => le_rfl) hroot + (shortIntegerAxis_block_volume hg (Nat.pos_of_ne_zero (NeZero.ne K)) hTL hshort s hlen) J hJ + (integerAxisShortBound g T γ) (integerAxisSideLength_short_scale hg hT hTL hshort) + +theorem shortIntegerCubeFourierAxis_exact {b g q K L T : ℕ} [NeZero K] {γ : ℝ} + (hg : 0 < g) (hT : 0 < T) (hTL : T ≤ L) + (hshort : integerAxisSideLength g K L γ < T) + (s : Fin b → Fin g → FiniteCubeSlice q) + (w : CubeSliceBlockDomain s Unit → ℝ) (hw : ∀ x, 0 ≤ w x) (hmass : 0 < ∑ x, w x) + (hlen : ∀ a j, (s a j).length ≤ integerAxisSideLength g K L γ) + {O : ℝ} (hO : 0 ≤ O) (hroot : ∀ a j, |((s a j).root : ℝ)| ≤ O*(s a j).length) + (J : Finset (Finset (Fin q))) (hJ : ∀ S ∈ J, S.card ≤ g) : + let A := shortIntegerCubeFourierAxis hg hT hTL hshort s w hw hmass hlen hO hroot J hJ + A.scale = K ∧ A.law = cubeSliceBlockWeights s w hw hmass ∧ + A.image = cubeSliceBlockSum s (fun _ _ => inactivePrincipalCoefficient K (inactiveDenominator γ)) J ∧ + A.countExponent = 0 ∧ ∀ ε, A.residualBound ε = 0 := + ⟨rfl, rfl, rfl, rfl, fun _ => rfl⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem shortIntegerCubeRadius_le_exp (b g q : ℕ) (γ : ℝ) {O o : ℝ} + (hO : 0 ≤ O) (ho : 0 ≤ o) (hOo : O ≤ Real.exp o) : + (⌈blockJetScaleBound q g b ((O+1)^g*(1/(inactiveDenominator γ : ℝ)))⌉₊ : ℝ) ≤ + Real.exp (b+g*(q+o+2)+1) := by + have hqpos : (0 : ℝ) < inactiveDenominator γ := by exact_mod_cast inactiveDenominator_pos γ + have hqone : (1 : ℝ) ≤ inactiveDenominator γ := by exact_mod_cast inactiveDenominator_pos γ + have hq : 1/(inactiveDenominator γ : ℝ) ≤ 1 := (div_le_one hqpos).mpr hqone + have hb : (b : ℝ) ≤ Real.exp b := by linarith [Real.add_one_le_exp (b : ℝ)] + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hdim : ((q+1 : ℕ) : ℝ) ≤ Real.exp q := by + simpa only [Nat.cast_add, Nat.cast_one] using Real.add_one_le_exp (q : ℝ) + have hO1 : O+1 ≤ Real.exp (o+1) := by + simpa only [add_comm O 1] using one_add_le_exp_succ ho hOo + have hraw : blockJetScaleBound q g b ((O+1)^g*(1/(inactiveDenominator γ : ℝ))) ≤ + Real.exp (b+g*(q+o+2)) := by + unfold blockJetScaleBound + calc + _ ≤ Real.exp b*(Real.exp 1)^g*(Real.exp q)^g*((Real.exp (o+1))^g*1) := by gcongr + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_nat_mul, ← Real.exp_nat_mul] + simp only [mul_one, ← Real.exp_add] + congr 1 + ring + exact natCeil_le_exp_succ (by unfold blockJetScaleBound; positivity) (by positivity) hraw + +noncomputable def shortIntegerFourierLog (b g q : ℕ) (p t o : ℝ) : ℝ := + b+g*(q+o+t+3)+p+5 + +theorem shortIntegerFourierAllowance_le_exp (b g q T : ℕ) {γ O p t o : ℝ} + (hγ : 0 < γ) (hp : 0 ≤ p) (hγp : γ⁻¹ ≤ Real.exp p) (hT : (T : ℝ) ≤ Real.exp t) + (hO : 0 ≤ O) (ho : 0 ≤ o) (hOo : O ≤ Real.exp o) : + (((2*⌈blockJetScaleBound q g b ((O+1)^g*(1/(inactiveDenominator γ : ℝ)))⌉₊+1)* + integerAxisShortBound g T γ : ℕ) : ℝ) ≤ Real.exp (shortIntegerFourierLog b g q p t o) := by + let Q := ⌈blockJetScaleBound q g b ((O+1)^g*(1/(inactiveDenominator γ : ℝ)))⌉₊ + let r : ℝ := b+g*(q+o+2)+1 + have hQ : (Q : ℝ) ≤ Real.exp r := shortIntegerCubeRadius_le_exp b g q γ hO ho hOo + have h1 : 1 ≤ Real.exp r := Real.one_le_exp_iff.mpr (by dsimp [r]; positivity) + have h3 : (3 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hfactor : (2*Q+1 : ℝ) ≤ Real.exp (r+2) := by + calc + _ ≤ 3*Real.exp r := by linarith + _ ≤ Real.exp 2*Real.exp r := mul_le_mul_of_nonneg_right h3 (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add, add_comm] + have hK := integerAxisShortBound_le_exp g T hγ hp hγp hT + change (((2*Q+1)*integerAxisShortBound g T γ : ℕ) : ℝ) ≤ _ + push_cast + calc + _ ≤ Real.exp (r+2)*Real.exp (p+2+g*(t+1)) := + mul_le_mul hfactor hK (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; dsimp [r, shortIntegerFourierLog]; ring + +theorem shortIntegerCubeFourierAxis_log_bounds {b g q K L T : ℕ} [NeZero K] {γ : ℝ} + (hg : 0 < g) (hT : 0 < T) (hTL : T ≤ L) + (hshort : integerAxisSideLength g K L γ < T) + (s : Fin b → Fin g → FiniteCubeSlice q) + (w : CubeSliceBlockDomain s Unit → ℝ) (hw : ∀ x, 0 ≤ w x) (hmass : 0 < ∑ x, w x) + (hlen : ∀ a j, (s a j).length ≤ integerAxisSideLength g K L γ) + {O : ℝ} (hO : 0 ≤ O) (hroot : ∀ a j, |((s a j).root : ℝ)| ≤ O*(s a j).length) + (J : Finset (Finset (Fin q))) (hJ : ∀ S ∈ J, S.card ≤ g) + {p t o : ℝ} (hγ : 0 < γ) (hp : 0 ≤ p) (hγp : γ⁻¹ ≤ Real.exp p) + (hTt : (T : ℝ) ≤ Real.exp t) (ho : 0 ≤ o) (hOo : O ≤ Real.exp o) : + let A := shortIntegerCubeFourierAxis hg hT hTL hshort s w hw hmass hlen hO hroot J hJ + let V := shortIntegerFourierLog b g q p t o + (A.period : ℝ) ≤ Real.exp V ∧ + A.countConstant ≤ Real.exp (J.card*V) ∧ A.coefficientCap ≤ Real.exp (J.card*V) ∧ + ∀ ε, A.denominatorBound ε ≤ Real.exp V := by + let Q := ⌈blockJetScaleBound q g b ((O+1)^g*(1/(inactiveDenominator γ : ℝ)))⌉₊ + let B := (2*Q+1)*integerAxisShortBound g T γ + let V := shortIntegerFourierLog b g q p t o + have hB : (B : ℝ) ≤ Real.exp V := + shortIntegerFourierAllowance_le_exp b g q T hγ hp hγp hTt hO ho hOo + have hcap : (B : ℝ)^Fintype.card J ≤ Real.exp (J.card*V) := by + calc + _ ≤ (Real.exp V)^Fintype.card J := pow_le_pow_left₀ (Nat.cast_nonneg B) hB _ + _ = _ := by rw [← Real.exp_nat_mul, Fintype.card_coe] + refine ⟨?_, hcap, hcap, fun _ => hB⟩ + change (((2*Q+1)*K : ℕ) : ℝ) ≤ _ + apply le_trans _ hB + exact_mod_cast Nat.mul_le_mul_left (2*Q+1) (integerAxisSideLength_short_scale hg hT hTL hshort) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/ShortIntegerDifference.lean b/lean/OAI/Combinatorics/Progressions/Lattices/ShortIntegerDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..03137a2df911c49896dd4fbe98bb9d52ac9c034a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/ShortIntegerDifference.lean @@ -0,0 +1,47 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_short_integer_difference (D : Finset ℤ) {H Q : ℕ} (hQ : 0 < Q) + (hD : ∀ h ∈ D, |h| ≤ (H : ℤ)) (hcard : 2 * H / Q + 1 < D.card) : + ∃ x ∈ D, ∃ y ∈ D, x < y ∧ y - x < (Q : ℤ) := by + let f : ℤ → ℤ := fun h => (h + (H : ℤ)) / (Q : ℤ) + let B := Finset.Icc (0 : ℤ) ((2 * H / Q : ℕ) : ℤ) + have hQ' : (0 : ℤ) < Q := by exact_mod_cast hQ + have hmap : ∀ h ∈ D, f h ∈ B := by + intro h hh + have hd := abs_le.mp (hD h hh) + simp only [B, f, Finset.mem_Icc] + constructor + · exact Int.ediv_nonneg (by omega) hQ'.le + · have hl : h + (H : ℤ) ≤ ((2 * H : ℕ) : ℤ) := by omega + exact_mod_cast Int.ediv_le_ediv hQ' hl + have hB : B.card = 2 * H / Q + 1 := by + simp only [B, Int.card_Icc, sub_zero] + norm_cast + obtain ⟨x, hx, y, hy, hxy, heq⟩ := Finset.exists_ne_map_eq_of_card_lt_of_maps_to + (by rwa [hB] : B.card < D.card) hmap + have hdif : |x - y| < (Q : ℤ) := by + have hxrem := Int.emod_nonneg (x + (H : ℤ)) (by omega : (Q : ℤ) ≠ 0) + have hyrem := Int.emod_nonneg (y + (H : ℤ)) (by omega : (Q : ℤ) ≠ 0) + have hxlt := Int.emod_lt_of_pos (x + (H : ℤ)) hQ' + have hylt := Int.emod_lt_of_pos (y + (H : ℤ)) hQ' + have hxdiv := Int.emod_add_ediv_mul (x + (H : ℤ)) (Q : ℤ) + have hydiv := Int.emod_add_ediv_mul (y + (H : ℤ)) (Q : ℤ) + change (x + (H : ℤ)) / Q = (y + (H : ℤ)) / Q at heq + rw [heq] at hxdiv + rw [abs_lt] + constructor <;> omega + rcases lt_or_gt_of_ne hxy with hxy | hxy + · exact ⟨x, hx, y, hy, hxy, by have := abs_lt.mp hdif; omega⟩ + · exact ⟨y, hy, x, hx, hxy, by have := abs_lt.mp hdif; omega⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SlowResidueRecovery.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SlowResidueRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7f503abdb1bb7e5ae06e2bb478a9c15f4b7ac4c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SlowResidueRecovery.lean @@ -0,0 +1,232 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeSquareRecovery +import OAI.Combinatorics.Progressions.Estimates.SlowInverseControl + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +theorem exists_uniform_residue_recovery (s k : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L M : Type*} [Fintype σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] {d e : ℕ} + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M s e) + (φ : L →ₗ⁅ℚ⁆ M) (w : σ → ℕ), (∀ i, 0 < w i) → ∀ {p : ℝ}, + 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → D.GeometryComplexityLE p → E.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (E.basis.repr (φ (D.basis j)) i) ≤ p) → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ P m : ℕ, 0 < P ∧ 0 < m ∧ + (P : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ Λ : Subgroup D.filtration.Group, Λ ≤ D.lattice ∧ + (Λ.subgroupOf D.lattice).Characteristic ∧ (Λ.subgroupOf D.lattice).Normal ∧ + (Λ.subgroupOf D.lattice).FiniteIndex ∧ (Λ.relIndex D.lattice : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N), + let Q := D.withLattice Λ N hN hin hout + Q.GeometryComplexityLE ((p + C) ^ C) ∧ + letI := rightMetricSpace (hnil := E.filtration.realification.lowerCentralSeries_eq_bot) + (E.basis.baseChange ℝ) + letI := Q.metricSpace + letI := E.metricSpace + let ψ := realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ + ∀ R : (E.filtration.realification.adaptedPolynomialFiltration w).Group, + E.filtration.PolynomialRationalGrid E.basis w q R → + ∃ z : (σ → ZMod P) → E.RealGroup, + (∀ c, (∀ i, |(E.basis.baseChange ℝ).repr (z c).coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (E.basis.baseChange ℝ).equivFun (z c).coord ∈ realDenominatorGrid m) ∧ + ∀ κ : D.RealGroup, κ ∈ D.realLattice → + ∀ a b r f : (σ → ℤ) → D.RealGroup, + (∀ x, a x * b x * r x * κ = f x) → + (∀ x, ψ (r x) = E.filtration.adaptedPolynomialRealValueHom w + (fun i => (x i : ℝ)) R) → + (∀ x, (QuotientGroup.mk (ψ (b x)) : E.Space) = + QuotientGroup.mk ((ψ (a x))⁻¹ * ψ (f x) * (ψ κ)⁻¹ * + (z (fun i => (x i : ZMod P)))⁻¹)) ∧ + ∀ x y, (fun i => (x i : ZMod P)) = (fun i => (y i : ZMod P)) → + (∀ i, |(E.basis.baseChange ℝ).repr ((ψ (a x))⁻¹).coord i| ≤ + Real.exp ((p + 2) ^ k)) → + dist (QuotientGroup.mk (ψ (b x)) : E.Space) (QuotientGroup.mk (ψ (b y))) ≤ + Real.exp ((p + C) ^ C) * dist (QuotientGroup.mk (f x) : Q.Space) + (QuotientGroup.mk (f y)) + dist (ψ (a x))⁻¹ (ψ (a y))⁻¹ := by + obtain ⟨A, _, hresidue⟩ := exists_native_residue_representatives s + obtain ⟨B, _, hrecovery⟩ := exists_uniform_left_class_recovery s k + let X : Polynomial ℕ := Polynomial.X + let T := X + (X + Polynomial.C A) ^ A + let U := T + (T + Polynomial.C B) ^ B + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget U + refine ⟨C, hC, ?_⟩ + intro σ L M _ _ _ _ _ _ _ _ _ _ _ _ _ d e D E φ w hw p hp hσ hD hE hφ q hq hqp + obtain ⟨P, m, hP, hm, hPb, hmb, hrepresentatives⟩ := hresidue E w hw p hp hE hσ q hq hqp + let t := p + (p + A) ^ A + have hpt : p ≤ t := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have ht : 0 ≤ t := hp.trans hpt + have hAt : (p + A) ^ A ≤ t := le_add_of_nonneg_left hp + obtain ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex, N, hN, hin, hout, hQ, hmetric⟩ := + hrecovery D E φ ht (hD.mono D hpt) (hE.mono E hpt) (fun i j => (hφ i j).trans hpt) + m hm (hmb.trans (Real.exp_le_exp.mpr hAt)) + let Q := D.withLattice Λ N hN hin hout + let ψ := realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ + have hsum : t + (t + B) ^ B ≤ (p + C) ^ C := by + simpa [U, T, X, t, Polynomial.eval₂_pow] using hbudget p hp + have htC : t ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (by positivity) _)).trans hsum + have hcost : (t + B) ^ B ≤ (p + C) ^ C := (le_add_of_nonneg_left ht).trans hsum + refine ⟨P, m, hP, hm, hPb.trans (Real.exp_le_exp.mpr (hAt.trans htC)), + hmb.trans (Real.exp_le_exp.mpr (hAt.trans htC)), Λ, hΛ, hchar, hnormal, hfinite, + hindex.trans (Real.exp_le_exp.mpr hcost), N, hN, hin, hout, hQ.mono Q hcost, ?_⟩ + let := rightMetricSpace (hnil := E.filtration.realification.lowerCentralSeries_eq_bot) (E.basis.baseChange ℝ) + let := Q.metricSpace + let := E.metricSpace + dsimp only + intro R hR + obtain ⟨_, z, hz, hclasses⟩ := hrepresentatives R hR + refine ⟨z, fun c => ⟨fun i => ((hz c).2.2.1 i).trans + (Real.exp_le_exp.mpr (hAt.trans htC)), (hz c).2.2.2⟩, ?_⟩ + intro κ hκ a b r f hfactor hvalue + have hleft (x : σ → ℤ) : ∃ γ ∈ E.realLattice, ψ (r x) = γ * z (fun i => (x i : ZMod P)) := by + obtain ⟨γ, hγ, heq⟩ := (hclasses x).2 + exact ⟨γ, hγ, (hvalue x).trans heq⟩ + refine ⟨?_, ?_⟩ + · intro x + obtain ⟨γ, hγ, heq⟩ := hleft x + exact recover_mapped_middle_coset_of_left_class ψ E.realLattice + (a x) (b x) (r x) κ (f x) _ γ (hfactor x) hγ heq + · intro x y hxy ha + have hy : ∃ γ ∈ E.realLattice, ψ (r y) = γ * z (fun i => (x i : ZMod P)) := by + rw [hxy] + exact hleft y + have ha' : ∀ i, |(E.basis.baseChange ℝ).repr ((ψ (a x))⁻¹).coord i| ≤ Real.exp ((t + 2) ^ k) := + fun i => (ha i).trans (Real.exp_le_exp.mpr (pow_le_pow_left₀ (by linarith) (by linarith) k)) + have hdist := hmetric κ hκ (z (fun i => (x i : ZMod P))) ((hz _).2.2.2) + (a x) (a y) (b x) (b y) (r x) (r y) (f x) (f y) (hfactor x) (hfactor y) (hleft x) hy ha' + exact hdist.trans (add_le_add + (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hcost) dist_nonneg) le_rfl) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +theorem exists_slow_residue_recovery (s k : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L M : Type*} [Fintype σ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] {d e : ℕ} + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M s e) + (φ : L →ₗ⁅ℚ⁆ M) (w : σ → ℕ), (∀ i, 0 < w i) → ∀ {p : ℝ}, + 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → D.GeometryComplexityLE p → E.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (E.basis.repr (φ (D.basis j)) i) ≤ p) → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ P m : ℕ, 0 < P ∧ 0 < m ∧ + (P : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ Λ : Subgroup D.filtration.Group, Λ ≤ D.lattice ∧ + (Λ.subgroupOf D.lattice).Characteristic ∧ (Λ.subgroupOf D.lattice).Normal ∧ + (Λ.subgroupOf D.lattice).FiniteIndex ∧ (Λ.relIndex D.lattice : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N), + let Q := D.withLattice Λ N hN hin hout + Q.GeometryComplexityLE ((p + C) ^ C) ∧ + letI := Q.metricSpace + letI := E.metricSpace + let ψ := realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ + ∀ R : (E.filtration.realification.adaptedPolynomialFiltration w).Group, + E.filtration.PolynomialRationalGrid E.basis w q R → + ∃ z : (σ → ZMod P) → E.RealGroup, + (∀ c, (∀ i, |(E.basis.baseChange ℝ).repr (z c).coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (E.basis.baseChange ℝ).equivFun (z c).coord ∈ realDenominatorGrid m) ∧ + ∀ κ : D.RealGroup, κ ∈ D.realLattice → + ∀ a b r f : (σ → ℤ) → D.RealGroup, + (∀ x, a x * b x * r x * κ = f x) → + (∀ x, ψ (r x) = E.filtration.adaptedPolynomialRealValueHom w + (fun i => (x i : ℝ)) R) → + (∀ x, (QuotientGroup.mk (ψ (b x)) : E.Space) = + QuotientGroup.mk ((ψ (a x))⁻¹ * ψ (f x) * (ψ κ)⁻¹ * + (z (fun i => (x i : ZMod P)))⁻¹)) ∧ + ∀ (T : σ → ℝ), (∀ i, 0 < T i) → + ∀ S : (E.filtration.realification.adaptedPolynomialFiltration w).Group, + E.filtration.PolynomialSlowBound E.basis w T (Real.exp ((p + 2) ^ k)) S → + (∀ x, ψ (a x) = E.filtration.adaptedPolynomialRealValueHom w + (fun i => (x i : ℝ)) S) → + ∀ x y, (fun i => (x i : ZMod P)) = (fun i => (y i : ZMod P)) → + ∀ δ : ℝ, 0 ≤ δ → + (∀ i, |(x i : ℝ)| ≤ T i) → (∀ i, |(y i : ℝ)| ≤ T i) → + (∀ i, |(x i : ℝ) - (y i : ℝ)| ≤ T i * δ) → + dist (QuotientGroup.mk (ψ (b x)) : E.Space) (QuotientGroup.mk (ψ (b y))) ≤ + Real.exp ((p + C) ^ C) * + (dist (QuotientGroup.mk (f x) : Q.Space) (QuotientGroup.mk (f y)) + δ) := by + obtain ⟨A, _, hslow⟩ := exists_slow_inverse_control s k + obtain ⟨B, _, hresidue⟩ := exists_uniform_residue_recovery s A + let X : Polynomial ℕ := Polynomial.X + let U := (X + Polynomial.C B) ^ B + (X + 2) ^ A + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget U + refine ⟨C, hC, ?_⟩ + intro σ L M _ _ _ _ _ _ _ _ _ _ _ _ _ d e D E φ w hw p hp hσ hD hE hφ q hq hqp + obtain ⟨P, m, hP, hm, hPb, hmb, Λ, hΛ, hchar, hnormal, hfinite, hindex, + N, hN, hin, hout, hQ, hrecover⟩ := hresidue D E φ w hw hp hσ hD hE hφ q hq hqp + let Q := D.withLattice Λ N hN hin hout + let ψ := realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ + have hsum : (p + B) ^ B + (p + 2) ^ A ≤ (p + C) ^ C := by + simpa [U, X, Polynomial.eval₂_pow] using hbudget p hp + have hBC : (p + B) ^ B ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (by positivity) _)).trans hsum + have hAC : (p + 2) ^ A ≤ (p + C) ^ C := + (le_add_of_nonneg_left (pow_nonneg (by positivity) _)).trans hsum + refine ⟨P, m, hP, hm, hPb.trans (Real.exp_le_exp.mpr hBC), hmb.trans (Real.exp_le_exp.mpr hBC), + Λ, hΛ, hchar, hnormal, hfinite, hindex.trans (Real.exp_le_exp.mpr hBC), + N, hN, hin, hout, hQ.mono Q hBC, ?_⟩ + let := rightMetricSpace (hnil := E.filtration.realification.lowerCentralSeries_eq_bot) (E.basis.baseChange ℝ) + let := Q.metricSpace + let := E.metricSpace + dsimp only + intro R hR + obtain ⟨z, hz, heval⟩ := hrecover R hR + refine ⟨z, fun c => ⟨fun i => ((hz c).1 i).trans (Real.exp_le_exp.mpr hBC), (hz c).2⟩, ?_⟩ + intro κ hκ a b r f hfactor hvalue + obtain ⟨hexact, hmove⟩ := heval κ hκ a b r f hfactor hvalue + refine ⟨hexact, ?_⟩ + intro T hT S hS hslowvalue x y hxy δ hδ hx hy hdelta + obtain ⟨hcoords, hdist⟩ := hslow E w hw p hp hE hσ T hT S hS + have hleft : ∀ i, |(E.basis.baseChange ℝ).repr ((ψ (a x))⁻¹).coord i| ≤ Real.exp ((p + 2) ^ A) := by + rw [hslowvalue x] + exact hcoords (fun i => (x i : ℝ)) hx + have hinverse : dist (ψ (a x))⁻¹ (ψ (a y))⁻¹ ≤ Real.exp ((p + 2) ^ A) * δ := by + rw [hslowvalue x, hslowvalue y] + exact hdist _ _ δ hδ hx hy hdelta + apply (hmove x y hxy hleft).trans + calc + _ ≤ Real.exp ((p + B) ^ B) * + dist (QuotientGroup.mk (f x) : Q.Space) (QuotientGroup.mk (f y)) + + Real.exp ((p + 2) ^ A) * δ := add_le_add le_rfl hinverse + _ ≤ Real.exp ((p + C) ^ C) * + dist (QuotientGroup.mk (f x) : Q.Space) (QuotientGroup.mk (f y)) + + Real.exp ((p + C) ^ C) * δ := + add_le_add (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hBC) dist_nonneg) + (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr hAC) hδ) + _ = _ := (mul_add _ _ _).symm + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SmoothAffinePairLaw.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothAffinePairLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..31ea31ebce3f29505799a01c4c02d934a2d1dd47 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothAffinePairLaw.lean @@ -0,0 +1,718 @@ +import OAI.Combinatorics.Progressions.Estimates.PrimitiveExtension +import OAI.Combinatorics.Progressions.Geometry.NormalizedSpatialReplacement +import OAI.Combinatorics.Progressions.Geometry.SpatialStarCoordinates +import OAI.Combinatorics.Progressions.Sampling.SmoothSplitSampling + +namespace OAI + + +namespace Erdos3 + +open scoped BigOperators Matrix Classical + +def affinePairMatrix {J : Type*} (t u : J → ℤ) : Matrix (Fin 2) (Option J) ℤ := + fun i c => match c with + | none => 1 + | some j => ![t j, u j] i + +theorem affinePairMatrix_mulVec {J : Type*} [Fintype J] (t u : J → ℤ) + (w : Option J → ℤ) : + affinePairMatrix t u *ᵥ w = + ![w none + ∑ j, t j * w (some j), w none + ∑ j, u j * w (some j)] := by + ext i + fin_cases i <;> simp [affinePairMatrix, Matrix.mulVec, dotProduct, Fintype.sum_option] + +def affinePairImage {J : Type*} [Fintype J] (t u : J → ℤ) : Submodule ℤ (Fin 2 → ℤ) := + (affinePairMatrix t u).mulVecLin.range + +theorem mem_affinePairImage_iff {J : Type*} [Fintype J] (t u : J → ℤ) (v : Fin 2 → ℤ) : + v ∈ affinePairImage t u ↔ ∃ x : ℤ, ∃ V : J → ℤ, + x + ∑ j, t j * V j = v 0 ∧ x + ∑ j, u j * V j = v 1 := by + constructor + · rintro ⟨w, hw⟩ + change affinePairMatrix t u *ᵥ w = v at hw + rw [affinePairMatrix_mulVec] at hw + exact ⟨w none, (fun j => w (some j)), congrFun hw 0, congrFun hw 1⟩ + · rintro ⟨x, V, h0, h1⟩ + refine ⟨(fun c => Option.elim c x V), ?_⟩ + change affinePairMatrix t u *ᵥ (fun c => Option.elim c x V) = v + rw [affinePairMatrix_mulVec] + ext i + fin_cases i + · exact h0 + · exact h1 + +theorem affinePairImage_iff_content_dvd {J : Type*} [Fintype J] + (t u : J → ℤ) (v : Fin 2 → ℤ) : + v ∈ affinePairImage t u ↔ BohrLattice.Primitive.content (fun j => u j - t j) ∣ v 1 - v 0 := by + rw [mem_affinePairImage_iff] + constructor + · rintro ⟨x, V, h0, h1⟩ + have he : v 1 - v 0 = ∑ j, (u j - t j) * V j := by + rw [← h0, ← h1] + simp only [sub_mul, Finset.sum_sub_distrib] + ring + rw [he] + exact Finset.dvd_sum (fun j _ => dvd_mul_of_dvd_left + (BohrLattice.Primitive.content_dvd (fun j => u j - t j) j) (V j)) + · rintro ⟨c, hc⟩ + obtain ⟨b, hb⟩ := BohrLattice.Primitive.exists_bezout_finset Finset.univ (fun j => u j - t j) + have hb' : ∑ j, b j * (u j - t j) = BohrLattice.Primitive.content (fun j => u j - t j) := hb + have he : (∑ j, u j * (c * b j)) - (∑ j, t j * (c * b j)) = + BohrLattice.Primitive.content (fun j => u j - t j) * c := by + calc + _ = ∑ j, (u j * (c * b j) - t j * (c * b j)) := by rw [Finset.sum_sub_distrib] + _ = c * ∑ j, b j * (u j - t j) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + _ = _ := by rw [hb']; ring + refine ⟨v 0 - ∑ j, t j * (c * b j), (fun j => c * b j), ?_, ?_⟩ + · ring + · linarith + +end Erdos3 + + +namespace Erdos3 + +open scoped Matrix + +def pairDifferenceMod (m : ℕ) : (Fin 2 → ℤ) →+ ZMod m where + toFun v := ((v 1 - v 0 : ℤ) : ZMod m) + map_zero' := by simp + map_add' x y := by simp only [Pi.add_apply, Int.cast_sub, Int.cast_add]; ring + +theorem pairDifferenceMod_surjective (m : ℕ) : Function.Surjective (pairDifferenceMod m) := by + intro r + obtain ⟨z, hz⟩ := ZMod.intCast_surjective r + refine ⟨![0, z], ?_⟩ + simpa [pairDifferenceMod] using hz + +theorem pairDifferenceMod_ker (m : ℕ) (v : Fin 2 → ℤ) : + v ∈ (pairDifferenceMod m).ker ↔ (m : ℤ) ∣ v 1 - v 0 := by + change (((v 1 - v 0 : ℤ) : ZMod m) = 0) ↔ _ + exact ZMod.intCast_zmod_eq_zero_iff_dvd _ _ + +theorem affinePairImage_eq_congruence_kernel {J : Type*} [Fintype J] (t u : J → ℤ) : + (affinePairImage t u).toAddSubgroup = + (pairDifferenceMod (BohrLattice.Primitive.content (fun j => u j - t j)).natAbs).ker := by + ext v + rw [Submodule.mem_toAddSubgroup, affinePairImage_iff_content_dvd, pairDifferenceMod_ker, + Int.natAbs_dvd] + +theorem pairDifferenceMod_index (m : ℕ) : (pairDifferenceMod m).ker.index = m := by + rw [AddSubgroup.index_ker, + AddMonoidHom.range_eq_top.mpr (pairDifferenceMod_surjective m)] + simpa only [Nat.card_zmod] using + (Nat.card_congr (AddSubgroup.topEquiv : (⊤ : AddSubgroup (ZMod m)) ≃+ ZMod m).toEquiv) + +theorem affinePairImage_index {J : Type*} [Fintype J] (t u : J → ℤ) : + (affinePairImage t u).toAddSubgroup.index = + (BohrLattice.Primitive.content (fun j => u j - t j)).natAbs := by + rw [affinePairImage_eq_congruence_kernel, pairDifferenceMod_index] + +end Erdos3 + + +namespace Erdos3 + +open scoped Matrix + +theorem integerResidueMatrix_fromCols {I J N : Type*} + (B : Matrix I J ℤ) (C : Matrix I N ℤ) (m : ℕ) : + integerResidueMatrix (Matrix.fromCols B C) m = + Matrix.fromCols (integerResidueMatrix B m) (integerResidueMatrix C m) := by + ext i k + cases k <;> rfl + +theorem integerMatrix_fromCols_range {I J N : Type*} [Fintype J] [Fintype N] + (B : Matrix I J ℤ) (C : Matrix I N ℤ) : + (Matrix.fromCols B C).mulVecLin.range = B.mulVecLin.range ⊔ C.mulVecLin.range := by + ext v + rw [Submodule.mem_sup] + constructor + · rintro ⟨x, hx⟩ + refine ⟨B *ᵥ (fun j => x (.inl j)), ⟨_, rfl⟩, + C *ᵥ (fun n => x (.inr n)), ⟨_, rfl⟩, ?_⟩ + exact (Matrix.fromCols_mulVec B C x).symm.trans hx + · rintro ⟨b, ⟨x, rfl⟩, c, ⟨y, rfl⟩, h⟩ + refine ⟨Sum.elim x y, ?_⟩ + change Matrix.fromCols B C *ᵥ Sum.elim x y = v + rw [Matrix.fromCols_mulVec_sumElim] + exact h + +theorem pivotFullImage_eq_range {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) : + pivotFullImage A B = (Matrix.fromCols A B).mulVecLin.range := + (integerMatrix_fromCols_range A B).symm + +theorem pivotFullImage_split {I J N : Type*} [Fintype I] [Fintype J] [Fintype N] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C : Matrix I N ℤ) : + pivotFullImage A (Matrix.fromCols B C) = pivotFullImage A B ⊔ C.mulVecLin.range := by + unfold pivotFullImage + rw [integerMatrix_fromCols_range, sup_assoc] + +theorem pivotFullImage_eq_of_kernel_residues {I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C D : Matrix I N ℤ) (m : ℕ) + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) + (hCD : integerResidueMatrix C m = integerResidueMatrix D m) : + pivotFullImage A (Matrix.fromCols B C) = pivotFullImage A (Matrix.fromCols B D) := by + have hc : integerScalarLattice I (m : ℤ) ≤ (Matrix.fromCols A (Matrix.fromCols B C)).mulVecLin.range := by + rw [← pivotFullImage_eq_range, pivotFullImage_split] + exact hperiod.trans le_sup_left + have hd : integerScalarLattice I (m : ℤ) ≤ (Matrix.fromCols A (Matrix.fromCols B D)).mulVecLin.range := by + rw [← pivotFullImage_eq_range, pivotFullImage_split] + exact hperiod.trans le_sup_left + rw [pivotFullImage_eq_range, pivotFullImage_eq_range] + apply integerMatrixImage_eq_of_residueMatrix _ _ m hc hd + simp only [integerResidueMatrix_fromCols, hCD] + +theorem maskedIntegerImageDensity_eq_of_kernel_residues {I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C D : Matrix I N ℤ) (m : ℕ) + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) + (hCD : integerResidueMatrix C m = integerResidueMatrix D m) + (P : I → ℝ) (f : (I → ℝ) → ℝ) : + maskedIntegerImageDensity A (Matrix.fromCols B C) P f = + maskedIntegerImageDensity A (Matrix.fromCols B D) P f := by + classical + funext v + have h := pivotFullImage_eq_of_kernel_residues A B C D m hperiod hCD + exact congrArg (fun L : Submodule ℤ (I → ℤ) => + if v ∈ L then (L.toAddSubgroup.index : ℝ) * f (fun i => (v i : ℝ) / P i) else 0) h + +end Erdos3 + + +namespace Erdos3 + +open scoped Matrix Classical + +def affinePairPivot {J : Type*} (t u : J → ℤ) (k : J) : Matrix (Fin 2) (Fin 2) ℤ := + !![1, t k; 1, u k] + +def affinePairFree {J : Type*} (t u : J → ℤ) (k : J) : + Matrix (Fin 2) {j : J // j ≠ k} ℤ := fun i j => ![t j.val, u j.val] i + +def affinePairColumnEquiv {J : Type*} [DecidableEq J] (k : J) : + (Fin 2 ⊕ {j : J // j ≠ k}) ≃ Option J where + toFun c := match c with + | Sum.inl i => if i = 0 then none else some k + | Sum.inr j => some j.val + invFun c := match c with + | none => Sum.inl 0 + | some j => if h : j = k then Sum.inl 1 else Sum.inr ⟨j, h⟩ + left_inv c := by + rcases c with i | j + · fin_cases i <;> simp + · simp [j.property] + right_inv c := by + cases c with + | none => rfl + | some j => by_cases h : j = k <;> simp [h] + +theorem affinePairPivot_det {J : Type*} (t u : J → ℤ) (k : J) : + (affinePairPivot t u k).det = u k - t k := by + simp [affinePairPivot, Matrix.det_fin_two] + +theorem affinePairPivot_columns {J : Type*} [DecidableEq J] (t u : J → ℤ) (k : J) : + Matrix.fromCols (affinePairPivot t u k) (affinePairFree t u k) = + (affinePairMatrix t u).submatrix id (affinePairColumnEquiv k) := by + ext i c + rcases c with j | j + · fin_cases i <;> fin_cases j <;> + simp [affinePairPivot, affinePairMatrix, affinePairColumnEquiv, Matrix.submatrix] + · rfl + +theorem affinePairPivot_image {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) : + pivotFullImage (affinePairPivot t u k) (affinePairFree t u k) = affinePairImage t u := by + rw [pivotFullImage_eq_range, affinePairPivot_columns] + ext v + constructor + · rintro ⟨w, hw⟩ + refine ⟨w ∘ (affinePairColumnEquiv k).symm, ?_⟩ + change (affinePairMatrix t u).submatrix id (affinePairColumnEquiv k) *ᵥ w = v at hw + rw [Matrix.submatrix_mulVec_equiv] at hw + change affinePairMatrix t u *ᵥ (w ∘ (affinePairColumnEquiv k).symm) = v + simpa only [Function.comp_id] using hw + · rintro ⟨w, hw⟩ + change affinePairMatrix t u *ᵥ w = v at hw + refine ⟨w ∘ affinePairColumnEquiv k, ?_⟩ + change (affinePairMatrix t u).submatrix id (affinePairColumnEquiv k) *ᵥ + (w ∘ affinePairColumnEquiv k) = v + rw [Matrix.submatrix_mulVec_equiv] + simpa only [Function.comp_def, Equiv.apply_symm_apply, id_eq] using hw + +theorem affinePairPivot_index {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) : + (pivotFullImage (affinePairPivot t u k) (affinePairFree t u k)).toAddSubgroup.index = + (BohrLattice.Primitive.content (fun j => u j - t j)).natAbs := by + rw [affinePairPivot_image, affinePairImage_index] + +end Erdos3 + + +namespace Erdos3 + +open scoped Classical + +noncomputable def latticeStarMask {I : Type*} + (L : Submodule ℤ ((Unit ⊕ I) → ℤ)) (m : ℕ) (a : (Unit ⊕ I) → ZMod m) : ℂ := by + classical + exact if spatialUnstar a ∈ residueLatticeImage L m then (L.toAddSubgroup.index : ℂ) else 0 + +theorem latticeStarMask_bound {I : Type*} (L : Submodule ℤ ((Unit ⊕ I) → ℤ)) (m : ℕ) + {G : ℝ} (hindex : (L.toAddSubgroup.index : ℝ) ≤ G) (a : (Unit ⊕ I) → ZMod m) : + ‖latticeStarMask L m a‖ ≤ G := by + classical + unfold latticeStarMask + split_ifs + · simpa using hindex + · simpa using (Nat.cast_nonneg L.toAddSubgroup.index).trans hindex + +theorem latticeStarMask_eval {I : Type*} [Fintype I] + (L : Submodule ℤ ((Unit ⊕ I) → ℤ)) (m : ℕ) + (hperiod : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ L) (v : (Unit ⊕ I) → ℤ) : + latticeStarMask L m (fun i => ((spatialStar v i : ℤ) : ZMod m)) = + if v ∈ L then (L.toAddSubgroup.index : ℂ) else 0 := by + classical + simp only [latticeStarMask, spatialUnstar_residue_star, ← residueLatticeImage_mem_iff L m hperiod] + +theorem maskedIntegerImageDensity_star {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix (Unit ⊕ I) (Unit ⊕ I) ℤ) (B : Matrix (Unit ⊕ I) J ℤ) (m : ℕ) + (hperiod : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ pivotFullImage A B) + (H : ℝ) (f : ((Unit ⊕ I) → ℝ) → ℝ) (v : (Unit ⊕ I) → ℤ) : + (maskedIntegerImageDensity A B (fun _ => H) f v : ℂ) = + latticeStarMask (pivotFullImage A B) m (fun i => ((spatialStar v i : ℤ) : ZMod m)) * + (f (spatialUnstar (fun i => ((spatialStar v i : ℤ) : ℝ) / H)) : ℂ) := by + classical + rw [latticeStarMask_eval _ _ hperiod, spatialUnstar_scaled_star] + by_cases hv : v ∈ pivotFullImage A B + · simp only [maskedIntegerImageDensity, hv, ite_true, Complex.ofReal_mul, Complex.ofReal_natCast] + · simp only [maskedIntegerImageDensity, hv, ite_false, Complex.ofReal_zero, zero_mul] + +end Erdos3 + + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def liftResidueMatrix {I N : Type*} {m : ℕ} (r : Matrix I N (ZMod m)) : Matrix I N ℤ := + fun i n => (ZMod.intCast_surjective (r i n)).choose + +theorem liftResidueMatrix_residue {I N : Type*} {m : ℕ} (r : Matrix I N (ZMod m)) : + integerResidueMatrix (liftResidueMatrix r) m = r := by + ext i n + exact (ZMod.intCast_surjective (r i n)).choose_spec + +noncomputable def residueSpatialWeight {I J N : Type*} [Fintype I] [Fintype J] [Fintype N] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (P : I → ℝ) (f : (I → ℝ) → ℝ) + {m : ℕ} (r : Matrix I N (ZMod m)) : (I → ℤ) → ℝ := + maskedIntegerImageDensity A (Matrix.fromCols B (liftResidueMatrix r)) P f + +theorem maskedIntegerImageDensity_eq_residueWeight {I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C : Matrix I N ℤ) + (P : I → ℝ) (f : (I → ℝ) → ℝ) (m : ℕ) + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) : + maskedIntegerImageDensity A (Matrix.fromCols B C) P f = + residueSpatialWeight A B P f (integerResidueMatrix C m) := by + apply maskedIntegerImageDensity_eq_of_kernel_residues A B C _ m hperiod + rw [liftResidueMatrix_residue] + +theorem residueSpatialWeight_factor_average {X I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (s : Finset X) (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C : X → Matrix I N ℤ) + (P : I → ℝ) (f : (I → ℝ) → ℝ) (m : ℕ) (r : Matrix I N (ZMod m)) + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) + (hresidue : ∀ x ∈ s, integerResidueMatrix (C x) m = r) + (D : X → ℝ) (v : I → ℤ) : + (𝔼 x ∈ s, maskedIntegerImageDensity A (Matrix.fromCols B (C x)) P f v * D x) = + residueSpatialWeight A B P f r v * (𝔼 x ∈ s, D x) := by + rw [Finset.mul_expect] + apply Finset.expect_congr rfl + intro x hx + rw [maskedIntegerImageDensity_eq_residueWeight A B (C x) P f m hperiod, hresidue x hx] + +end Erdos3 + + +namespace Erdos3 + +open scoped Matrix + +noncomputable def affinePairScale (H L : ℝ) : Fin 2 → ℝ := ![H, H / L] + +theorem affinePairScale_pos {H L : ℝ} (hH : 0 < H) (hL : 0 < L) : + ∀ i, 0 < affinePairScale H L i := by + intro i + fin_cases i + · exact hH + · exact div_pos hH hL + +theorem normalized_affinePairPivot {J : Type*} (t u : J → ℤ) (k : J) + {H L : ℝ} (hH : H ≠ 0) (hL : L ≠ 0) : + normalizedIntegerPivot (affinePairPivot t u k) (affinePairScale H L) (fun _ => H) = + !![1, (t k : ℝ) / L; 1, (u k : ℝ) / L] := by + ext i j + rw [normalizedIntegerPivot_entry] + fin_cases i <;> fin_cases j <;> simp [affinePairPivot, affinePairScale, hH] <;> field_simp + +theorem normalized_affinePairFree {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) {H L : ℝ} (hH : H ≠ 0) (hL : L ≠ 0) : + normalizedIntegerColumns (affinePairFree t u k) (fun _ => H / L) (fun _ => H) = + (fun i j => ![(t j.val : ℝ) / L, (u j.val : ℝ) / L] i) := by + ext i j + fin_cases i <;> + simp [normalizedIntegerColumns, Matrix.mul_diagonal, Matrix.diagonal_mul, affinePairFree] <;> + field_simp + +theorem normalized_affinePairPivot_det {J : Type*} (t u : J → ℤ) (k : J) + {H L : ℝ} (hH : H ≠ 0) (hL : L ≠ 0) : + (normalizedIntegerPivot (affinePairPivot t u k) (affinePairScale H L) (fun _ => H)).det = + ((u k - t k : ℤ) : ℝ) / L := by + rw [normalized_affinePairPivot t u k hH hL] + simp [Matrix.det_fin_two, sub_div] + +theorem normalized_affinePairPivot_inverse {J : Type*} (t u : J → ℤ) (k : J) + {H L C κ : ℝ} (hH : H ≠ 0) (hL : L ≠ 0) (hC : 1 ≤ C) (hκ : 0 < κ) + (ht : |(t k : ℝ) / L| ≤ C) (hu : |(u k : ℝ) / L| ≤ C) + (hgap : κ ≤ |((u k - t k : ℤ) : ℝ) / L|) : + ‖(matrixSupCLM (normalizedIntegerPivot (affinePairPivot t u k) + (affinePairScale H L) (fun _ => H))).inverse‖ ≤ 4 * C / κ := by + have hentry : ∀ i j, |normalizedIntegerPivot (affinePairPivot t u k) + (affinePairScale H L) (fun _ => H) i j| ≤ C := by + rw [normalized_affinePairPivot t u k hH hL] + intro i j + fin_cases i <;> fin_cases j + · simpa using hC + · exact ht + · simpa using hC + · exact hu + have hd : κ ≤ |(normalizedIntegerPivot (affinePairPivot t u k) + (affinePairScale H L) (fun _ => H)).det| := by + rwa [normalized_affinePairPivot_det t u k hH hL] + have h := (matrixSupCLM_inverse_norm_le _ (zero_le_one.trans hC) hentry hκ hd).2 + norm_num [mul_div_assoc, ← mul_assoc] at h + simpa only [mul_div_assoc] using h + +theorem normalized_affinePairFree_norm {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) {H L C : ℝ} (hH : H ≠ 0) (hL : L ≠ 0) (hC : 0 ≤ C) + (ht : ∀ j, |(t j : ℝ) / L| ≤ C) (hu : ∀ j, |(u j : ℝ) / L| ≤ C) : + ‖matrixSupCLM (normalizedIntegerColumns (affinePairFree t u k) + (fun _ => H / L) (fun _ => H))‖ ≤ (Fintype.card J : ℝ) * C := by + apply (matrixSupCLM_norm_le _ hC ?_).trans + (mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (Fintype.card_subtype_le _)) hC) + rw [normalized_affinePairFree t u k hH hL] + intro i j + fin_cases i + · exact ht j.val + · exact hu j.val + +end Erdos3 + + +namespace Erdos3 + +open scoped BigOperators + +theorem residueSpatialWeight_average_functional {X I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (s : Finset X) (outputs : Finset (I → ℤ)) + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C : X → Matrix I N ℤ) + (P : I → ℝ) (f : (I → ℝ) → ℝ) (m : ℕ) (r : Matrix I N (ZMod m)) + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) + (hresidue : ∀ x ∈ s, integerResidueMatrix (C x) m = r) + (D : X → (I → ℤ) → ℝ) (φ : (I → ℤ) → ℂ) : + (𝔼 x ∈ s, 𝔼 v ∈ outputs, + ((D x v * maskedIntegerImageDensity A (Matrix.fromCols B (C x)) P f v : ℝ) : ℂ) * φ v) = + (𝔼 v ∈ outputs, ((residueSpatialWeight A B P f r v * (𝔼 x ∈ s, D x v) : ℝ) : ℂ) * φ v) := by + rw [Finset.expect_comm] + apply Finset.expect_congr rfl + intro v _ + rw [← Finset.expect_mul] + congr 1 + have hcast := map_expect (algebraMap ℝ ℂ) + (fun x => D x v * maskedIntegerImageDensity A (Matrix.fromCols B (C x)) P f v) s + simp only [Complex.coe_algebraMap] at hcast + rw [← hcast] + congr 1 + have h := residueSpatialWeight_factor_average s A B C P f m r hperiod hresidue (fun x => D x v) v + convert h using 1 + apply Finset.expect_congr rfl + intro x _ + ring + +theorem residueSpatialWeight_average_comparison {X I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (s : Finset X) (outputs : Finset (I → ℤ)) + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C : X → Matrix I N ℤ) + (P : I → ℝ) (f : (I → ℝ) → ℝ) (m : ℕ) (r : Matrix I N (ZMod m)) + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) + (hresidue : ∀ x ∈ s, integerResidueMatrix (C x) m = r) + (mass D : X → (I → ℤ) → ℝ) (φ : (I → ℤ) → ℂ) {ε : ℝ} + (hD : ∀ x ∈ s, ∀ v ∈ outputs, 0 ≤ D x v) + (hφ : ∀ v ∈ outputs, ‖φ v‖ ≤ 1) + (herror : ∀ x ∈ s, ∀ v ∈ outputs, + |mass x v - maskedIntegerImageDensity A (Matrix.fromCols B (C x)) P f v| ≤ ε) : + ‖(𝔼 x ∈ s, 𝔼 v ∈ outputs, ((D x v * mass x v : ℝ) : ℂ) * φ v) - + (𝔼 v ∈ outputs, ((residueSpatialWeight A B P f r v * (𝔼 x ∈ s, D x v) : ℝ) : ℂ) * φ v)‖ ≤ + ε * (𝔼 x ∈ s, 𝔼 v ∈ outputs, D x v) := by + classical + rw [← residueSpatialWeight_average_functional s outputs A B C P f m r hperiod hresidue D φ] + have h := norm_weighted_density_mean_sub_le (s.product outputs) + (fun p => D p.1 p.2) (fun p => mass p.1 p.2) + (fun p => maskedIntegerImageDensity A (Matrix.fromCols B (C p.1)) P f p.2) + (fun p => φ p.2) + (fun p hp => hD p.1 (Finset.mem_product.mp hp).1 p.2 (Finset.mem_product.mp hp).2) + (fun p hp => hφ p.2 (Finset.mem_product.mp hp).2) + (fun p hp => herror p.1 (Finset.mem_product.mp hp).1 p.2 (Finset.mem_product.mp hp).2) + simp only [Finset.product_eq_sprod, Finset.expect_product] at h + exact h + +end Erdos3 + + +namespace Erdos3 + +open scoped BigOperators + +theorem weightedResidueSpatial_mixture_functional {X I J N : Type*} + [Fintype X] [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] [DecidableEq N] + (p : FiniteProbabilityWeights X) (outputs : Finset (I → ℤ)) + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C : X → Matrix I N ℤ) + (P : I → ℝ) (f : (I → ℝ) → ℝ) (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) + (D : X → (I → ℤ) → ℝ) (φ : (I → ℤ) → ℂ) : + p.complexMean (fun x => 𝔼 v ∈ outputs, + ((D x v * maskedIntegerImageDensity A (Matrix.fromCols B (C x)) P f v : ℝ) : ℂ) * φ v) = + ∑ r : Matrix I N (ZMod m), 𝔼 v ∈ outputs, + ((p.fiberMean (fun x => integerResidueMatrix (C x) m) r (fun x => D x v) * + residueSpatialWeight A B P f r v : ℝ) : ℂ) * φ v := by + classical + calc + _ = 𝔼 v ∈ outputs, ∑ r : Matrix I N (ZMod m), + ((p.fiberMean (fun x => integerResidueMatrix (C x) m) r (fun x => D x v) * + residueSpatialWeight A B P f r v : ℝ) : ℂ) * φ v := by + rw [p.complexMean_finset_expect] + apply Finset.expect_congr rfl + intro v _ + simp_rw [maskedIntegerImageDensity_eq_residueWeight A B _ P f m hperiod] + simpa only [Complex.ofReal_mul, mul_assoc] using + p.complexMean_fiber_factor (fun x => integerResidueMatrix (C x) m) (fun x => D x v) + (fun r => (residueSpatialWeight A B P f r v : ℂ) * φ v) + _ = _ := Finset.expect_sum_comm _ _ _ + +theorem weightedResidueSpatial_mixture_comparison {X I J N : Type*} + [Fintype X] [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] [DecidableEq N] + (p : FiniteProbabilityWeights X) (outputs : Finset (I → ℤ)) + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (C : X → Matrix I N ℤ) + (P : I → ℝ) (f : (I → ℝ) → ℝ) (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ pivotFullImage A B) + (mass D : X → (I → ℤ) → ℝ) (φ : (I → ℤ) → ℂ) {ε : ℝ} + (hD : ∀ x, p.weight x ≠ 0 → ∀ v ∈ outputs, 0 ≤ D x v) + (hφ : ∀ v ∈ outputs, ‖φ v‖ ≤ 1) + (herror : ∀ x, p.weight x ≠ 0 → ∀ v ∈ outputs, + |mass x v - maskedIntegerImageDensity A (Matrix.fromCols B (C x)) P f v| ≤ ε) : + ‖p.complexMean (fun x => 𝔼 v ∈ outputs, ((D x v * mass x v : ℝ) : ℂ) * φ v) - + ∑ r : Matrix I N (ZMod m), 𝔼 v ∈ outputs, + ((p.fiberMean (fun x => integerResidueMatrix (C x) m) r (fun x => D x v) * + residueSpatialWeight A B P f r v : ℝ) : ℂ) * φ v‖ ≤ + ε * p.mean (fun x => 𝔼 v ∈ outputs, D x v) := by + rw [← weightedResidueSpatial_mixture_functional p outputs A B C P f m hperiod D φ] + apply (p.norm_complexMean_sub_le _ _ (fun x => ε * (𝔼 v ∈ outputs, D x v)) ?_).trans_eq + (p.mean_const_mul ε _) + intro x hx + exact norm_weighted_density_mean_sub_le outputs (D x) (mass x) _ φ + (hD x hx) hφ (herror x hx) + +end Erdos3 + + +namespace Erdos3 + +open MeasureTheory +open scoped Matrix NNReal BigOperators + +theorem affinePair_mesh_bound {d : ℤ} (hd : d ≠ 0) {H L δ : ℝ} + (hH : 0 < H) (hL : 1 ≤ L) (hmesh : (d.natAbs : ℝ) * L / H ≤ δ) : + (∀ i, 1 / affinePairScale H L i ≤ δ) ∧ (d.natAbs : ℝ) / (H / L) ≤ δ := by + have hL0 : 0 < L := zero_lt_one.trans_le hL + have hd1 : (1 : ℝ) ≤ d.natAbs := by + exact_mod_cast (Nat.one_le_iff_ne_zero.mpr (Int.natAbs_ne_zero.mpr hd)) + constructor + · intro i + fin_cases i + · change 1 / H ≤ δ + apply (div_le_div_of_nonneg_right (show (1 : ℝ) ≤ d.natAbs * L by nlinarith) hH.le).trans hmesh + · change 1 / (H / L) ≤ δ + have he : 1 / (H / L) = L / H := by field_simp + rw [he] + exact (div_le_div_of_nonneg_right (show L ≤ (d.natAbs : ℝ) * L by nlinarith) hH.le).trans hmesh + · have he : (d.natAbs : ℝ) / (H / L) = (d.natAbs : ℝ) * L / H := by field_simp + rwa [he] + +noncomputable def affinePairRowDensity {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) (H L : ℝ) (hH : 0 < H) (hL : 0 < L) + (f : ({j : J // j ≠ k} → ℝ) × (Fin 2 → ℝ) → ℝ) : (Fin 2 → ℝ) → ℝ := + normalizedFiberDensity (affinePairPivot t u k) (by rwa [affinePairPivot_det]) + (affinePairFree t u k) (affinePairScale H L) (fun _ => H) (fun _ => H / L) + (affinePairScale_pos hH hL) (fun _ => hH) f + +theorem affinePair_probability_error {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) (v : Fin 2 → ℤ) + (hcong : BohrLattice.Primitive.content (fun j => u j - t j) ∣ v 1 - v 0) + {H L C κ R F δ : ℝ} (Q : ℕ) (K : ℝ≥0) + (hH : 0 < H) (hL : 1 ≤ L) (hC : 1 ≤ C) (hκ : 0 < κ) + (hR : 0 ≤ R) (hF : 0 ≤ F) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (ht : ∀ j, |(t j : ℝ) / L| ≤ C) (hu : ∀ j, |(u j : ℝ) / L| ≤ C) + (hgap : κ ≤ |((u k - t k : ℤ) : ℝ) / L|) + (hQ : (BohrLattice.Primitive.content (fun j => u j - t j)).natAbs ≤ Q) + (hmesh : ((u k - t k).natAbs : ℝ) * L / H ≤ δ) + (f : ({j : J // j ≠ k} → ℝ) × (Fin 2 → ℝ) → ℝ) + (hf0 : ∀ z, 0 ≤ f z) (hf : LipschitzWith K f) + (hsupport : ∀ z, R < ‖z‖ → f z = 0) (hmass : (∫ z, f z) = 1) + (hsmall : (2 * R + 2) ^ (2 + Fintype.card {j : J // j ≠ k}) * K * δ ≤ 1 / 2) + (hbound : ∀ z, ‖f z‖ ≤ F) : + ∃ hM : 0 < scaledInputMass f (affinePairScale H L) (fun _ => H / L), + |H ^ 2 * (integerImagePMF (affinePairPivot t u k) (affinePairFree t u k) f hf0 + (affinePairScale H L) (fun _ => H / L) + (affinePairScale_pos hH (zero_lt_one.trans_le hL)) + (fun _ => div_pos hH (zero_lt_one.trans_le hL)) hsupport hM v).toReal - + ((BohrLattice.Primitive.content (fun j => u j - t j)).natAbs : ℝ) * + affinePairRowDensity t u k hne H L hH (zero_lt_one.trans_le hL) f + (fun i => (v i : ℝ) / H)| ≤ + normalizedFiberErrorConstant 2 (Fintype.card {j : J // j ≠ k}) Q + (4 * C / κ) ((Fintype.card J : ℝ) * C) R F K * δ := by + have hL0 : 0 < L := zero_lt_one.trans_le hL + have hA : (affinePairPivot t u k).det ≠ 0 := by rwa [affinePairPivot_det] + have hv : v ∈ pivotFullImage (affinePairPivot t u k) (affinePairFree t u k) := by + rwa [affinePairPivot_image, affinePairImage_iff_content_dvd] + have hm : (0 : ℤ) < (u k - t k).natAbs := by + exact_mod_cast Int.natAbs_pos.mpr hne + have hdiv : (affinePairPivot t u k).det ∣ ((u k - t k).natAbs : ℤ) := by + rw [affinePairPivot_det] + exact Int.dvd_natAbs_self + have hmeshes := affinePair_mesh_bound hne hH hL hmesh + have hi : ((pivotFullImage (affinePairPivot t u k) (affinePairFree t u k)).toAddSubgroup.index : ℝ) ≤ Q := by + rw [affinePairPivot_index] + exact_mod_cast hQ + have hinv : ‖(normalizedPivotEquiv (affinePairPivot t u k) hA + (affinePairScale H L) (fun _ => H) (affinePairScale_pos hH hL0) (fun _ => hH)).symm.toContinuousLinearMap‖ ≤ + 4 * C / κ := by + rw [normalizedPivotEquiv_inverse_eq] + exact normalized_affinePairPivot_inverse t u k hH.ne' hL0.ne' hC hκ (ht k) (hu k) hgap + have hcol := normalized_affinePairFree_norm t u k hH.ne' hL0.ne' (zero_le_one.trans hC) ht hu + have h := normalizedIntegerFiber_uniform_error (affinePairPivot t u k) hA (affinePairFree t u k) + (m := ((u k - t k).natAbs : ℤ)) v hv hm hdiv (affinePairScale H L) (fun _ => H) (fun _ => H / L) + (affinePairScale_pos hH hL0) (fun _ => hH) (fun _ => div_pos hH hL0) + f hf hR hδ hδ1 hF hmeshes.1 (fun _ => by + rw [Int.cast_natCast] + exact hmeshes.2) + hsupport hmass (by simpa only [Fintype.card_fin] using hsmall) hbound hi hinv hcol + obtain ⟨hM, he⟩ := h + refine ⟨hM, ?_⟩ + rw [normalizedIntegerFiberOutputMass_pmf _ _ f hf0 _ _ _ (affinePairScale_pos hH hL0) + (fun _ => div_pos hH hL0) hsupport hM v, affinePairPivot_index] at he + simpa only [Fin.prod_univ_two, Fintype.card_fin, pow_two, affinePairRowDensity] using he + +theorem affinePair_probability_law {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) + {H L C κ R F δ : ℝ} (Q : ℕ) (K : ℝ≥0) + (hH : 0 < H) (hL : 1 ≤ L) (hC : 1 ≤ C) (hκ : 0 < κ) + (hR : 0 ≤ R) (hF : 0 ≤ F) (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (ht : ∀ j, |(t j : ℝ) / L| ≤ C) (hu : ∀ j, |(u j : ℝ) / L| ≤ C) + (hgap : κ ≤ |((u k - t k : ℤ) : ℝ) / L|) + (hQ : (BohrLattice.Primitive.content (fun j => u j - t j)).natAbs ≤ Q) + (hmesh : ((u k - t k).natAbs : ℝ) * L / H ≤ δ) + (f : ({j : J // j ≠ k} → ℝ) × (Fin 2 → ℝ) → ℝ) + (hf0 : ∀ z, 0 ≤ f z) (hf : LipschitzWith K f) + (hsupport : ∀ z, R < ‖z‖ → f z = 0) (hmass : (∫ z, f z) = 1) + (hsmall : (2 * R + 2) ^ (2 + Fintype.card {j : J // j ≠ k}) * K * δ ≤ 1 / 2) + (hbound : ∀ z, ‖f z‖ ≤ F) : + ∃ hM : 0 < scaledInputMass f (affinePairScale H L) (fun _ => H / L), ∀ v, + |H ^ 2 * (integerImagePMF (affinePairPivot t u k) (affinePairFree t u k) f hf0 + (affinePairScale H L) (fun _ => H / L) + (affinePairScale_pos hH (zero_lt_one.trans_le hL)) + (fun _ => div_pos hH (zero_lt_one.trans_le hL)) hsupport hM v).toReal - + (if BohrLattice.Primitive.content (fun j => u j - t j) ∣ v 1 - v 0 then + ((BohrLattice.Primitive.content (fun j => u j - t j)).natAbs : ℝ) * + affinePairRowDensity t u k hne H L hH (zero_lt_one.trans_le hL) f + (fun i => (v i : ℝ) / H) else 0)| ≤ + normalizedFiberErrorConstant 2 (Fintype.card {j : J // j ≠ k}) Q + (4 * C / κ) ((Fintype.card J : ℝ) * C) R F K * δ := by + classical + obtain ⟨hM, hzero⟩ := affinePair_probability_error t u k hne 0 (by simp) Q K + hH hL hC hκ hR hF hδ hδ1 ht hu hgap hQ hmesh f hf0 hf hsupport hmass hsmall hbound + refine ⟨hM, fun v => ?_⟩ + by_cases hc : BohrLattice.Primitive.content (fun j => u j - t j) ∣ v 1 - v 0 + · obtain ⟨hM', hv⟩ := affinePair_probability_error t u k hne v hc Q K + hH hL hC hκ hR hF hδ hδ1 ht hu hgap hQ hmesh f hf0 hf hsupport hmass hsmall hbound + simpa only [hc, ite_true] using hv + · have hnot : v ∉ pivotFullImage (affinePairPivot t u k) (affinePairFree t u k) := by + simpa only [affinePairPivot_image, affinePairImage_iff_content_dvd] using hc + have hz := integerImagePMF_zero_off_image (affinePairPivot t u k) (affinePairFree t u k) + f hf0 (affinePairScale H L) (fun _ => H / L) + (affinePairScale_pos hH (zero_lt_one.trans_le hL)) + (fun _ => div_pos hH (zero_lt_one.trans_le hL)) hsupport hM v hnot + simp only [hc, ite_false, hz, ENNReal.toReal_zero, mul_zero, sub_self, abs_zero] + exact (abs_nonneg _).trans hzero + +end Erdos3 + + +namespace Erdos3 + +open scoped NNReal Matrix + +noncomputable def smoothPairRowLipschitz {J : Type*} [Fintype J] [DecidableEq J] (k : J) : ℝ≥0 := + ((Fintype.card {j : J // j ≠ k} + 2 : ℕ) : ℝ≥0) * probabilityProfileLipschitz + +theorem smooth_affinePair_probability_law {J : Type*} [Fintype J] [DecidableEq J] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) + {H L C κ δ : ℝ} (Q : ℕ) (hH : 0 < H) (hL : 1 ≤ L) (hC : 1 ≤ C) (hκ : 0 < κ) + (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) + (ht : ∀ j, |(t j : ℝ) / L| ≤ C) (hu : ∀ j, |(u j : ℝ) / L| ≤ C) + (hgap : κ ≤ |((u k - t k : ℤ) : ℝ) / L|) + (hQ : (BohrLattice.Primitive.content (fun j => u j - t j)).natAbs ≤ Q) + (hmesh : ((u k - t k).natAbs : ℝ) * L / H ≤ δ) + (hsmall : (4 : ℝ) ^ (2 + Fintype.card {j : J // j ≠ k}) * + smoothPairRowLipschitz k * δ ≤ 1 / 2) : + let f := splitSmoothProductProfile {j : J // j ≠ k} (Fin 2) + ∃ hM : 0 < scaledInputMass f (affinePairScale H L) (fun _ => H / L), ∀ v, + |H ^ 2 * (integerImagePMF (affinePairPivot t u k) (affinePairFree t u k) f + (fun z => (splitSmoothProductProfile_range _ _ z).1) + (affinePairScale H L) (fun _ => H / L) + (affinePairScale_pos hH (zero_lt_one.trans_le hL)) + (fun _ => div_pos hH (zero_lt_one.trans_le hL)) + (splitSmoothProductProfile_zero_outside _ _) hM v).toReal - + (if BohrLattice.Primitive.content (fun j => u j - t j) ∣ v 1 - v 0 then + ((BohrLattice.Primitive.content (fun j => u j - t j)).natAbs : ℝ) * + affinePairRowDensity t u k hne H L hH (zero_lt_one.trans_le hL) f + (fun i => (v i : ℝ) / H) else 0)| ≤ + normalizedFiberErrorConstant 2 (Fintype.card {j : J // j ≠ k}) Q + (4 * C / κ) ((Fintype.card J : ℝ) * C) 1 1 (smoothPairRowLipschitz k) * δ := by + dsimp only + have hLip : LipschitzWith (smoothPairRowLipschitz k) + (splitSmoothProductProfile {j : J // j ≠ k} (Fin 2)) := by + simpa only [smoothPairRowLipschitz, Fintype.card_fin] using + splitSmoothProductProfile_lipschitz {j : J // j ≠ k} (Fin 2) + have hbound (z : ({j : J // j ≠ k} → ℝ) × (Fin 2 → ℝ)) : + ‖splitSmoothProductProfile {j : J // j ≠ k} (Fin 2) z‖ ≤ 1 := by + rw [Real.norm_eq_abs, abs_of_nonneg (splitSmoothProductProfile_range _ _ z).1] + exact (splitSmoothProductProfile_range _ _ z).2 + exact affinePair_probability_law t u k hne Q (smoothPairRowLipschitz k) + hH hL hC hκ (by norm_num) (by norm_num) hδ hδ1 ht hu hgap hQ hmesh + (splitSmoothProductProfile {j : J // j ≠ k} (Fin 2)) + (fun z => (splitSmoothProductProfile_range _ _ z).1) hLip + (splitSmoothProductProfile_zero_outside _ _) (splitSmoothProductProfile_integral _ _) + (by simpa only [show 2 * (1 : ℝ) + 2 = 4 by norm_num] using hsmall) hbound + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SmoothBadPrimeProduct.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothBadPrimeProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..6114dbe4307d5c000582f18c7bcf55e17627b18c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothBadPrimeProduct.lean @@ -0,0 +1,598 @@ +import Mathlib.Data.ZMod.Basic +import Mathlib.Data.ZMod.QuotientRing +import Mathlib.Probability.Distributions.Uniform +import OAI.Combinatorics.Progressions.Estimates.FiniteProductWeightL1 +import OAI.Combinatorics.Progressions.Lattices.StrideSelectedResidueBadProduct + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +noncomputable def coefficientCRTEquiv {L J : Type*} [Fintype L] + (q : L → ℕ) (hq : Pairwise (fun l k => (q l).Coprime (q k))) : + (J → ZMod (∏ l, q l)) ≃+ (∀ l, J → ZMod (q l)) where + toFun x l j := ZMod.prodEquivPi q hq (x j) l + invFun y j := (ZMod.prodEquivPi q hq).symm (fun l => y l j) + left_inv x := by funext j; exact (ZMod.prodEquivPi q hq).symm_apply_apply (x j) + right_inv y := by + funext l j + exact congrFun ((ZMod.prodEquivPi q hq).apply_symm_apply (fun l => y l j)) l + map_add' x y := by + funext l j + exact congrFun (map_add (ZMod.prodEquivPi q hq) (x j) (y j)) l + +theorem coefficientCRTEquiv_apply {L J : Type*} [Fintype L] + (q : L → ℕ) (hq : Pairwise (fun l k => (q l).Coprime (q k))) + (x : J → ZMod (∏ l, q l)) (l : L) (j : J) : + coefficientCRTEquiv q hq x l j = + ZMod.castHom (Finset.dvd_prod_of_mem q (Finset.mem_univ l)) (ZMod (q l)) (x j) := + ZMod.prodEquivPi_apply q hq (x j) l + +theorem coefficientCRTEquiv_intCast {L J : Type*} [Fintype L] + (q : L → ℕ) (hq : Pairwise (fun l k => (q l).Coprime (q k))) (z : J → ℤ) : + coefficientCRTEquiv q hq (fun j => (z j : ZMod (∏ l, q l))) = + (fun l j => (z j : ZMod (q l))) := by + funext l j + rw [coefficientCRTEquiv_apply, map_intCast] + +private theorem uniform_map_equiv {X Y : Type*} [Fintype X] [Nonempty X] + [Fintype Y] [Nonempty Y] (e : X ≃ Y) : + (PMF.uniformOfFintype X).map e = PMF.uniformOfFintype Y := by + ext y + obtain ⟨x, rfl⟩ := e.surjective y + rw [pmf_map_injective_at _ _ e.injective] + simp only [PMF.uniformOfFintype_apply, Fintype.card_congr e] + +theorem dependentProductPMF_uniform {L : Type*} [Fintype L] {X : L → Type*} + [∀ l, Fintype (X l)] [∀ l, Nonempty (X l)] + [∀ l, MeasurableSpace (X l)] [∀ l, MeasurableSingletonClass (X l)] : + dependentProductPMF (fun l => PMF.uniformOfFintype (X l)) = + PMF.uniformOfFintype (∀ l, X l) := by + ext x + simp only [dependentProductPMF_apply, PMF.uniformOfFintype_apply, + Fintype.card_pi, Nat.cast_prod] + exact (ENNReal.prod_inv_distrib (fun _ _ _ _ _ => Or.inr (by simp))).symm + +theorem uniform_coefficientCRT_map {L J : Type*} [Fintype L] [Fintype J] + (q : L → ℕ) [∀ l, NeZero (q l)] [NeZero (∏ l, q l)] + (hq : Pairwise (fun l k => (q l).Coprime (q k))) : + (PMF.uniformOfFintype (J → ZMod (∏ l, q l))).map (coefficientCRTEquiv q hq) = + dependentProductPMF (fun l => PMF.uniformOfFintype (J → ZMod (q l))) := by + rw [dependentProductPMF_uniform] + exact uniform_map_equiv (coefficientCRTEquiv q hq).toEquiv + +theorem selectedPrimePower_coprime (S : Finset ℕ) (a : ℕ → ℕ) + (hprime : ∀ p ∈ S, Nat.Prime p) : + Pairwise (fun p q : S => (p.val ^ a p).Coprime (q.val ^ a q)) := by + intro p q hpq + exact Nat.coprime_pow_primes _ _ (hprime p p.property) (hprime q q.property) + (fun h => hpq (Subtype.ext h)) + +theorem selectedPrimePower_nonzero (S : Finset ℕ) (a : ℕ → ℕ) + (hprime : ∀ p ∈ S, Nat.Prime p) : + (∀ p : S, p.val ^ a p ≠ 0) ∧ (∏ p : S, p.val ^ a p) ≠ 0 := by + have hp (p : S) : p.val ^ a p ≠ 0 := pow_ne_zero _ (hprime p p.property).ne_zero + exact ⟨hp, Finset.prod_ne_zero_iff.mpr (fun p _ => hp p)⟩ + +theorem uniform_selectedPrimePowerCRT_map (S : Finset ℕ) (a : ℕ → ℕ) + (hprime : ∀ p ∈ S, Nat.Prime p) (J : Type*) [Fintype J] : + let : ∀ p : S, NeZero (p.val ^ a p) := fun p => + ⟨(selectedPrimePower_nonzero S a hprime).1 p⟩ + let : NeZero (∏ p : S, p.val ^ a p) := ⟨(selectedPrimePower_nonzero S a hprime).2⟩ + (PMF.uniformOfFintype (J → ZMod (∏ p : S, p.val ^ a p))).map + (coefficientCRTEquiv (fun p : S => p.val ^ a p) (selectedPrimePower_coprime S a hprime)) = + dependentProductPMF (fun p : S => PMF.uniformOfFintype (J → ZMod (p.val ^ a p))) := by + let : ∀ p : S, NeZero (p.val ^ a p) := fun p => + ⟨(selectedPrimePower_nonzero S a hprime).1 p⟩ + let : NeZero (∏ p : S, p.val ^ a p) := ⟨(selectedPrimePower_nonzero S a hprime).2⟩ + exact uniform_coefficientCRT_map _ _ + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem shiftedSmoothCoefficientPMF_residue_apply (a S : ℝ) (hS : 0 < S) + (hZ : 0 < shiftedSmoothSampleSum a S) (M : ℕ) [NeZero M] (r : ZMod M) : + ((shiftedSmoothCoefficientPMF a S hS hZ).map (fun k : ℤ => (k : ZMod M)) r).toReal = + shiftedSmoothSampleSum ((a - r.val) / M) (S / M) / shiftedSmoothSampleSum a S := by + have hM : (M : ℤ) ≠ 0 := by exact_mod_cast NeZero.ne M + have hMr : (M : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne M + have hinj : Function.Injective (fun k : ℤ => (r.val : ℤ) + M * k) := by + intro j k h + exact mul_left_cancel₀ hM (add_left_cancel h) + rw [pmf_map_toReal_indicator] + have he := hinj.tsum_eq (f := fun z : ℤ => + (shiftedSmoothCoefficientPMF a S hS hZ z).toReal * + (if (z : ZMod M) = r then 1 else 0)) (by + intro z hz + have hz' : (z : ZMod M) = r := by + by_contra hn + simp only [Function.mem_support, hn, ite_false, mul_zero, ne_eq, not_true_eq_false] at hz + obtain ⟨k, hk⟩ := (ZMod.intCast_eq_iff M z r).mp hz' + exact ⟨k, hk.symm⟩) + rw [← he] + simp only [Int.cast_add, Int.cast_mul, Int.cast_natCast, ZMod.natCast_self, + zero_mul, add_zero, ZMod.natCast_zmod_val, ite_true, mul_one, + shiftedSmoothCoefficientPMF_apply] + rw [tsum_div_const] + congr 1 + unfold shiftedSmoothSampleSum + apply tsum_congr + intro k + congr 1 + field_simp + ring + +theorem shiftedSmoothSampleSum_sub_width_abs_le (a : ℝ) {S : ℝ} (hS : 1 ≤ S) : + |shiftedSmoothSampleSum a S - S| ≤ 4 * (probabilityProfileLipschitz : ℝ) := by + have hS0 : 0 < S := lt_of_lt_of_le zero_lt_one hS + have he := shiftedSmoothSampleSum_error a hS + have he' : |shiftedSmoothSampleSum a S - S| / S ≤ + 4 * (probabilityProfileLipschitz : ℝ) / S := by + calc + _ = |(shiftedSmoothSampleSum a S - S) / S| := by rw [abs_div, abs_of_pos hS0] + _ = |shiftedSmoothSampleSum a S / S - 1| := by rw [sub_div, div_self hS0.ne'] + _ ≤ _ := he + exact (div_le_div_iff_of_pos_right hS0).mp he' + +theorem shiftedSmoothCoefficientPMF_residue_error (a S : ℝ) (hS : 0 < S) + (hZ : 0 < shiftedSmoothSampleSum a S) (M : ℕ) [NeZero M] + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S) (r : ZMod M) : + |((shiftedSmoothCoefficientPMF a S hS hZ).map (fun k : ℤ => (k : ZMod M)) r).toReal - + 1 / (M : ℝ)| ≤ 16 * (probabilityProfileLipschitz : ℝ) / S := by + have hM1 : (1 : ℝ) ≤ M := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr (NeZero.ne M) + have hM : (0 : ℝ) < M := lt_of_lt_of_le zero_lt_one hM1 + have hL1 : (1 : ℝ) ≤ probabilityProfileLipschitz := probabilityProfileLipschitz_one_le + have hL : (0 : ℝ) ≤ probabilityProfileLipschitz := NNReal.coe_nonneg _ + have hbase : 8 * (probabilityProfileLipschitz : ℝ) ≤ S := by + have := mul_le_mul_of_nonneg_left hM1 (show 0 ≤ 8 * (probabilityProfileLipschitz : ℝ) by positivity) + nlinarith only [this, hlarge] + have hSM : 1 ≤ S / M := by + apply (le_div_iff₀ hM).mpr + nlinarith only [hlarge, mul_le_mul_of_nonneg_right hL1 hM.le] + have hmain := shiftedSmoothSampleSum_sub_width_abs_le a (show 1 ≤ S by linarith) + have hprog := shiftedSmoothSampleSum_sub_width_abs_le ((a - r.val) / M) hSM + have hmainDiv : |S / M - shiftedSmoothSampleSum a S / M| ≤ + 4 * (probabilityProfileLipschitz : ℝ) := by + rw [← sub_div, abs_div, abs_of_pos hM, abs_sub_comm] + exact (div_le_iff₀ hM).mpr (hmain.trans (by nlinarith only [mul_le_mul_of_nonneg_left hM1 (show 0 ≤ 4 * (probabilityProfileLipschitz : ℝ) by positivity)])) + have hnum : |shiftedSmoothSampleSum ((a - r.val) / M) (S / M) - + shiftedSmoothSampleSum a S / M| ≤ 8 * (probabilityProfileLipschitz : ℝ) := by + have h := abs_sub_le (shiftedSmoothSampleSum ((a - r.val) / M) (S / M)) + (S / M) (shiftedSmoothSampleSum a S / M) + linarith + rw [shiftedSmoothCoefficientPMF_residue_apply] + have heq : shiftedSmoothSampleSum ((a - r.val) / M) (S / M) / shiftedSmoothSampleSum a S - + 1 / (M : ℝ) = + (shiftedSmoothSampleSum ((a - r.val) / M) (S / M) - shiftedSmoothSampleSum a S / M) / + shiftedSmoothSampleSum a S := by field_simp + rw [heq, abs_div, abs_of_pos hZ] + apply (div_le_iff₀ hZ).mpr + apply hnum.trans + have hlo := (shiftedSmoothSampleSum_bounds a hbase).1 + calc + _ = (16 * (probabilityProfileLipschitz : ℝ) / S) * (S / 2) := by field_simp; norm_num + _ ≤ _ := mul_le_mul_of_nonneg_left hlo (by positivity) + +theorem shiftedSmoothCoefficientPMF_residue_l1 (a S : ℝ) (hS : 0 < S) + (hZ : 0 < shiftedSmoothSampleSum a S) (M : ℕ) [NeZero M] + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S) : + (∑ r : ZMod M, + |((shiftedSmoothCoefficientPMF a S hS hZ).map (fun k : ℤ => (k : ZMod M)) r).toReal - + 1 / (M : ℝ)|) ≤ 16 * (probabilityProfileLipschitz : ℝ) * M / S := by + calc + _ ≤ ∑ _r : ZMod M, 16 * (probabilityProfileLipschitz : ℝ) / S := + Finset.sum_le_sum (fun r _ => shiftedSmoothCoefficientPMF_residue_error a S hS hZ M hlarge r) + _ = _ := by rw [Finset.sum_const, Finset.card_univ, ZMod.card, nsmul_eq_mul]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +open FiniteProbabilityWeights + +noncomputable def smoothCoefficientResidueWeights (a S : ℝ) (hS : 0 < S) + (hZ : 0 < shiftedSmoothSampleSum a S) (M : ℕ) [NeZero M] : + FiniteProbabilityWeights (ZMod M) := + ofPMF ((shiftedSmoothCoefficientPMF a S hS hZ).map (fun k : ℤ => (k : ZMod M))) + +theorem smoothCoefficientProduct_residue_event_error {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : ∀ j, 0 < shiftedSmoothSampleSum (a j) (S j)) + (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (E : (J → ZMod M) → Prop) : + |(pi (fun j => smoothCoefficientResidueWeights (a j) (S j) (hS j) (hZ j) M)).eventProbability E - + (uniform (J → ZMod M)).eventProbability E| ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + have h := abs_eventProbability_pi_sub_le_sum + (fun j => smoothCoefficientResidueWeights (a j) (S j) (hS j) (hZ j) M) + (fun _ : J => uniform (ZMod M)) E + have hu : (pi (fun _ : J => uniform (ZMod M))).eventProbability E = + (uniform (J → ZMod M)).eventProbability E := by + unfold eventProbability mean + apply Finset.sum_congr rfl + intro x _ + rw [pi_uniform_weight] + rw [hu] at h + apply h.trans + apply Finset.sum_le_sum + intro j _ + simpa only [smoothCoefficientResidueWeights, ofPMF_weight, uniform, ZMod.card, one_div] using + shiftedSmoothCoefficientPMF_residue_l1 (a j) (S j) (hS j) (hZ j) M (hlarge j) + +theorem smoothCoefficientProduct_residue_event_error_of_width {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : ∀ j, 0 < shiftedSmoothSampleSum (a j) (S j)) + {B W η : ℝ} (hB : 0 ≤ B) (hW : 0 < W) + (hwidth : ∀ j, W ≤ S j) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) * B ≤ W) + (herror : (Fintype.card J : ℝ) * (16 * (probabilityProfileLipschitz : ℝ) * B / W) ≤ η) + (M : ℕ) [NeZero M] (hM : (M : ℝ) ≤ B) + (E : (J → ZMod M) → Prop) : + |(pi (fun j => smoothCoefficientResidueWeights (a j) (S j) (hS j) (hZ j) M)).eventProbability E - + (uniform (J → ZMod M)).eventProbability E| ≤ η := by + have hscale (j) : 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j := + ((mul_le_mul_of_nonneg_left hM (by positivity)).trans hlarge).trans (hwidth j) + apply (smoothCoefficientProduct_residue_event_error a S hS hZ M hscale E).trans + calc + _ ≤ ∑ _j : J, 16 * (probabilityProfileLipschitz : ℝ) * B / W := by + apply Finset.sum_le_sum + intro j _ + exact div_le_div₀ (by positivity) (mul_le_mul_of_nonneg_left hM (by positivity)) + hW (hwidth j) + _ ≤ η := by simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using herror + +theorem shiftedSmoothProductPMF_residue_weight {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) (M : ℕ) [NeZero M] + (r : J → ZMod M) : + (ofPMF ((shiftedSmoothProductPMF a S hS hZ).map + (fun x j => (x j : ZMod M)))).weight r = + (pi (fun j => smoothCoefficientResidueWeights (a j) (S j) (hS j) + (shiftedSmoothProductMass_coordinate_pos a S hS hZ j) M)).weight r := by + rw [ofPMF_weight, shiftedSmoothProductPMF_eq_independent] + change ((dependentProductPMF _).map _ r).toReal = _ + rw [dependentProductPMF_map, dependentProductPMF_apply, ENNReal.toReal_prod] + rfl + +theorem shiftedSmoothProductPMF_residue_event_error {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (E : (J → ZMod M) → Prop) : + |(ofPMF ((shiftedSmoothProductPMF a S hS hZ).map + (fun x j => (x j : ZMod M)))).eventProbability E - + (uniform (J → ZMod M)).eventProbability E| ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + have h := smoothCoefficientProduct_residue_event_error a S hS + (shiftedSmoothProductMass_coordinate_pos a S hS hZ) M hlarge E + simpa only [eventProbability, mean, shiftedSmoothProductPMF_residue_weight] using h + +theorem shiftedSmoothProductPMF_residue_l1 {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) : + (∑ r, |(ofPMF ((shiftedSmoothProductPMF a S hS hZ).map + (fun x j => (x j : ZMod M)))).weight r - + (uniform (J → ZMod M)).weight r|) ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + let hz := shiftedSmoothProductMass_coordinate_pos a S hS hZ + have h := pi_weight_l1_le_sum + (fun j => smoothCoefficientResidueWeights (a j) (S j) (hS j) (hz j) M) + (fun _ : J => uniform (ZMod M)) + simp only [pi_uniform_weight] at h + simp only [shiftedSmoothProductPMF_residue_weight] + apply h.trans + apply Finset.sum_le_sum + intro j _ + simpa only [smoothCoefficientResidueWeights, ofPMF_weight, uniform, ZMod.card, one_div] using + shiftedSmoothCoefficientPMF_residue_l1 (a j) (S j) (hS j) (hz j) M (hlarge j) + +theorem shiftedSmoothProductPMF_residue_complexMean_error {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (f : (J → ZMod M) → ℂ) (hf : ∀ r, ‖f r‖ ≤ 1) : + ‖(ofPMF ((shiftedSmoothProductPMF a S hS hZ).map + (fun x j => (x j : ZMod M)))).complexMean f - + (uniform (J → ZMod M)).complexMean f‖ ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := + (norm_complexMean_sub_le_weight_l1 _ _ f hf).trans + (shiftedSmoothProductPMF_residue_l1 a S hS hZ M hlarge) + +theorem shiftedSmoothProductPMF_residue_transfer {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (w : FiniteProbabilityWeights (J → ZMod M)) (E : (J → ZMod M) → Prop) + {ε K : ℝ} + (hcompare : w.eventProbability E ≤ + (ofPMF ((shiftedSmoothProductPMF a S hS hZ).map + (fun x j => (x j : ZMod M)))).eventProbability E + ε) + (huniform : (uniform (J → ZMod M)).eventProbability E ≤ K) : + w.eventProbability E ≤ K + ε + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + have h := (abs_le.mp (shiftedSmoothProductPMF_residue_event_error a S hS hZ M hlarge E)).2 + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical +open FiniteProbabilityWeights + +theorem shiftedSmoothProductFiniteWeights_residue_complexMean_error + {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (f : (J → ZMod M) → ℂ) (hf : ∀ r, ‖f r‖ ≤ 1) : + ‖(shiftedSmoothProductFiniteWeights a S hS hZ).complexMean + (fun x => f (fun j => (x.val j : ZMod M))) - + (uniform (J → ZMod M)).complexMean f‖ ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + rw [shiftedSmoothProductFiniteWeights_map_complexMean a S hS hZ + (fun x j => (x j : ZMod M)) f] + exact shiftedSmoothProductPMF_residue_complexMean_error a S hS hZ M hlarge f hf + +theorem shiftedSmoothProductFiniteWeights_residue_event_error + {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) (M : ℕ) [NeZero M] + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j) + (E : (J → ZMod M) → Prop) : + |(shiftedSmoothProductFiniteWeights a S hS hZ).eventProbability + (fun x => E (fun j => (x.val j : ZMod M))) - + (uniform (J → ZMod M)).eventProbability E| ≤ + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j := by + rw [shiftedSmoothProductFiniteWeights_map_event a S hS hZ + (fun x j => (x j : ZMod M)) E] + exact shiftedSmoothProductPMF_residue_event_error a S hS hZ M hlarge E + +private theorem residue_error_sum_le_of_width {J : Type*} [Fintype J] + (S : J → ℝ) {B W η : ℝ} (hB : 0 ≤ B) (hW : 0 < W) + (hwidth : ∀ j, W ≤ S j) + (herror : (Fintype.card J : ℝ) * + (16 * (probabilityProfileLipschitz : ℝ) * B / W) ≤ η) + (M : ℕ) (hM : (M : ℝ) ≤ B) : + (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * M / S j) ≤ η := by + calc + _ ≤ ∑ _j : J, 16 * (probabilityProfileLipschitz : ℝ) * B / W := by + apply Finset.sum_le_sum + intro j _ + exact div_le_div₀ (by positivity) (mul_le_mul_of_nonneg_left hM (by positivity)) + hW (hwidth j) + _ ≤ η := by simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using herror + +theorem shiftedSmoothProductFiniteWeights_residue_complexMean_error_of_width + {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) + {B W η : ℝ} (hB : 0 ≤ B) (hW : 0 < W) + (hwidth : ∀ j, W ≤ S j) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) * B ≤ W) + (herror : (Fintype.card J : ℝ) * + (16 * (probabilityProfileLipschitz : ℝ) * B / W) ≤ η) + (M : ℕ) [NeZero M] (hM : (M : ℝ) ≤ B) + (f : (J → ZMod M) → ℂ) (hf : ∀ r, ‖f r‖ ≤ 1) : + ‖(shiftedSmoothProductFiniteWeights a S hS hZ).complexMean + (fun x => f (fun j => (x.val j : ZMod M))) - + (uniform (J → ZMod M)).complexMean f‖ ≤ η := by + have hscale (j) : 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j := + ((mul_le_mul_of_nonneg_left hM (by positivity)).trans hlarge).trans (hwidth j) + exact (shiftedSmoothProductFiniteWeights_residue_complexMean_error a S hS hZ M hscale f hf).trans + (residue_error_sum_le_of_width S hB hW hwidth herror M hM) + +theorem shiftedSmoothProductFiniteWeights_residue_event_error_of_width + {J : Type*} [Fintype J] + (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) + {B W η : ℝ} (hB : 0 ≤ B) (hW : 0 < W) + (hwidth : ∀ j, W ≤ S j) + (hlarge : 8 * (probabilityProfileLipschitz : ℝ) * B ≤ W) + (herror : (Fintype.card J : ℝ) * + (16 * (probabilityProfileLipschitz : ℝ) * B / W) ≤ η) + (M : ℕ) [NeZero M] (hM : (M : ℝ) ≤ B) + (E : (J → ZMod M) → Prop) : + |(shiftedSmoothProductFiniteWeights a S hS hZ).eventProbability + (fun x => E (fun j => (x.val j : ZMod M))) - + (uniform (J → ZMod M)).eventProbability E| ≤ η := by + have hscale (j) : 8 * (probabilityProfileLipschitz : ℝ) * M ≤ S j := + ((mul_le_mul_of_nonneg_left hM (by positivity)).trans hlarge).trans (hwidth j) + exact (shiftedSmoothProductFiniteWeights_residue_event_error a S hS hZ M hscale E).trans + (residue_error_sum_le_of_width S hB hW hwidth herror M hM) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +open FiniteProbabilityWeights + +theorem uniform_coefficientCRT_event {L J : Type*} [Fintype L] [Fintype J] + (q : L → ℕ) [∀ l, NeZero (q l)] [NeZero (∏ l, q l)] + (hq : Pairwise (fun l k => (q l).Coprime (q k))) + (E : ∀ l, (J → ZMod (q l)) → Prop) : + (uniform (J → ZMod (∏ l, q l))).eventProbability + (fun y => ∀ l, E l (coefficientCRTEquiv q hq y l)) = + ∏ l, (uniform (J → ZMod (q l))).eventProbability (E l) := by + have h := uniform_mean_surjective_hom (coefficientCRTEquiv q hq).toAddMonoidHom + (coefficientCRTEquiv q hq).surjective + (fun y => @ite ℝ (∀ l, E l (y l)) (Classical.propDecidable _) 1 0) + have hevent : (uniform (J → ZMod (∏ l, q l))).eventProbability + (fun y => ∀ l, E l (coefficientCRTEquiv q hq y l)) = + (uniform (∀ l, J → ZMod (q l))).eventProbability (fun y => ∀ l, E l (y l)) := by + simp only [eventProbability, AddEquiv.coe_toAddMonoidHom] at h ⊢ + convert h using 1 + unfold mean + apply Finset.sum_congr rfl + intro x _ + congr 1 + rw [hevent] + have hpi : (uniform (∀ l, J → ZMod (q l))).eventProbability (fun y => ∀ l, E l (y l)) = + (pi (fun l => uniform (J → ZMod (q l)))).eventProbability (fun y => ∀ l, E l (y l)) := by + unfold eventProbability mean + apply Finset.sum_congr rfl + intro y _ + rw [pi_uniform_weight] + rw [hpi, eventProbability_pi] + +theorem shiftedSmoothProductFiniteWeights_primePower_event + {J : Type*} [Fintype J] (center width : J → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (S : Finset ℕ) (a : ℕ → ℕ) (hprime : ∀ p ∈ S, Nat.Prime p) + [∀ p : S, NeZero (p.val ^ a p)] + (E : ∀ p : S, (J → ZMod (p.val ^ a p)) → Prop) + (hprob : ∀ p : S, (uniform (J → ZMod (p.val ^ a p))).eventProbability (E p) ≤ + 1 / ((p.val ^ a p : ℕ) : ℝ) ^ 10) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (∏ p : S, p.val ^ a p) ≤ width j) : + (shiftedSmoothProductFiniteWeights center width hwidth hZ).eventProbability + (fun x => ∀ p : S, E p (fun j => (x.val j : ZMod (p.val ^ a p)))) ≤ + 1 / ((∏ p : S, p.val ^ a p : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : S, p.val ^ a p) / width j := by + let : NeZero (∏ p : S, p.val ^ a p) := ⟨(selectedPrimePower_nonzero S a hprime).2⟩ + let q : S → ℕ := fun p => p.val ^ a p + let hq := selectedPrimePower_coprime S a hprime + let F : (J → ZMod (∏ p : S, q p)) → Prop := + fun y => ∀ p : S, E p (coefficientCRTEquiv q hq y p) + have htransfer := shiftedSmoothProductPMF_residue_event_error + center width hwidth hZ (∏ p : S, q p) hlarge F + have hactual := shiftedSmoothProductFiniteWeights_map_event center width hwidth hZ + (fun x j => (x j : ZMod (∏ p : S, q p))) F + have hF (x : J → ℤ) : F (fun j => (x j : ZMod (∏ p : S, q p))) = + (∀ p : S, E p (fun j => (x j : ZMod (p.val ^ a p)))) := by + simp only [F, coefficientCRTEquiv_intCast, q] + simp only [hF] at hactual + rw [← hactual] at htransfer + have huniform : (uniform (J → ZMod (∏ p : S, q p))).eventProbability F ≤ + 1 / ((∏ p : S, p.val ^ a p : ℕ) : ℝ) ^ 10 := by + rw [uniform_coefficientCRT_event q hq E] + calc + _ ≤ ∏ p : S, 1 / ((p.val ^ a p : ℕ) : ℝ) ^ 10 := + Finset.prod_le_prod₀ (fun p _ => (uniform _).eventProbability_nonneg (E p)) (fun p _ => hprob p) + _ = _ := by + simp only [one_div, ← Finset.prod_inv_distrib, ← Finset.prod_pow, Nat.cast_prod] + have hupper := (abs_le.mp htransfer).2 + dsimp only [q] at hupper huniform + linarith only [hupper, huniform] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +open FiniteProbabilityWeights + +def smoothResiduePrimeBad {J : Type*} (P : Finset ℕ) + (E : ∀ p : P, ∀ a : ℕ, (J → ZMod (p.val ^ a)) → Prop) + (p a : ℕ) (x : J → ℤ) : Prop := + ∃ hp : p ∈ P, E ⟨p, hp⟩ a (fun j => (x j : ZMod (p ^ a))) + +theorem smoothResidue_badPrimeProduct_probability {J : Type*} [Fintype J] + (center width : J → ℝ) (hwidth : ∀ j, 0 < width j) + (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (E : ∀ p : P, ∀ a : ℕ, (J → ZMod (p.val ^ a)) → Prop) + {Qs Q R : ℕ} (hprime : ∀ p ∈ P, p.Prime) + (hQs : 2 ≤ Qs) (hQ : 1 ≤ Q) (hR : 0 < R) + (hdepth : ∀ p ∈ P, p ^ A p ≤ Q) + (hprob : ∀ (p : P) a, 0 < a → a ≤ A p → Qs ≤ p.val ^ a → + (uniform (J → ZMod (p.val ^ a))).eventProbability (E p a) ≤ + 1 / ((p.val ^ a : ℕ) : ℝ) ^ 10) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) ≤ width j) + {η : ℝ} (hη : 0 ≤ η) + (herror : (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (max Q (R ^ 2) : ℕ) / width j) ≤ η) : + (shiftedSmoothProductFiniteWeights center width hwidth hZ).eventProbability + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => smoothResiduePrimeBad P E p a x.val) p x) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + apply largestBadPrimeProduct_probability_bounded _ P A _ hprime hQs hQ hR hdepth hη + intro T hTP a ha hd + let (p : T) : NeZero (p.val ^ a p) := ⟨pow_ne_zero _ (hprime p (hTP p.property)).ne_zero⟩ + let F (p : T) := E ⟨p.val, hTP p.property⟩ (a p) + have hprod : (∏ p : T, p.val ^ a p) = ∏ p ∈ T, p ^ a p := + Finset.prod_coe_sort T (fun p => p ^ a p) + have hd' : (∏ p : T, p.val ^ a p) ≤ max Q (R ^ 2) := by + rw [hprod] + exact hd + have hs (j) : 8 * (probabilityProfileLipschitz : ℝ) * (∏ p : T, p.val ^ a p) ≤ width j := + (mul_le_mul_of_nonneg_left (by exact_mod_cast hd') (by positivity)).trans (hlarge j) + have h := shiftedSmoothProductFiniteWeights_primePower_event center width hwidth hZ T a + (fun p hp => hprime p (hTP hp)) F + (fun p => hprob ⟨p.val, hTP p.property⟩ (a p) (ha p p.property).1 + (ha p p.property).2.1 (ha p p.property).2.2) hs + have hevents : (fun x : rectangularWeightIndices center width 1 => + ∀ p ∈ T, smoothResiduePrimeBad P E p (a p) x.val) = + (fun x => ∀ p : T, F p (fun j => (x.val j : ZMod (p.val ^ a p)))) := by + funext x + apply propext + constructor + · intro hx p + obtain ⟨hp, he⟩ := hx p p.property + exact he + · intro hx p hp + exact ⟨hTP hp, hx ⟨p, hp⟩⟩ + rw [hevents] + have herr : (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (∏ p : T, p.val ^ a p) / width j) ≤ η := by + apply le_trans (Finset.sum_le_sum (fun j _ => ?_)) herror + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left (by exact_mod_cast hd') (by positivity)) (hwidth j).le + rw [hprod] at h herr + exact h.trans (add_le_add le_rfl herr) + +theorem exists_early_smoothResidue_badPrimeProduct_cutoff (Qs : ℕ) (hQs : 2 ≤ Qs) + {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ (J : Type*) [Fintype J] + (center width : J → ℝ) (hwidth : ∀ j, 0 < width j) + (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (E : ∀ p : P, ∀ a : ℕ, (J → ZMod (p.val ^ a)) → Prop) (Q : ℕ), + (∀ p ∈ P, p.Prime) → 1 ≤ Q → (∀ p ∈ P, p ^ A p ≤ Q) → + (∀ (p : P) a, 0 < a → a ≤ A p → Qs ≤ p.val ^ a → + (uniform (J → ZMod (p.val ^ a))).eventProbability (E p a) ≤ + 1 / ((p.val ^ a : ℕ) : ℝ) ^ 10) → + (∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) ≤ width j) → + (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) / width j) ≤ + δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2)) → + (shiftedSmoothProductFiniteWeights center width hwidth hZ).eventProbability + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => smoothResiduePrimeBad P E p a x.val) p x) ≤ δ := by + obtain ⟨R, hR, hradius⟩ := exists_early_badPrime_radius hδ + refine ⟨R, hR, ?_⟩ + intro J _ center width hwidth hZ P A _ E Q hprime hQ hdepth hprob hlarge herror + exact (smoothResidue_badPrimeProduct_probability center width hwidth hZ P A E hprime hQs hQ hR + hdepth hprob hlarge (hradius Q hQ).1.le herror).trans (hradius Q hQ).2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SmoothIntegerImage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothIntegerImage.lean new file mode 100644 index 0000000000000000000000000000000000000000..52a1741bcfa8424b3462b0ba357a9955718b4ed8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothIntegerImage.lean @@ -0,0 +1,48 @@ +import Mathlib.Data.Matrix.ColumnRowPartitioned +import OAI.Combinatorics.Progressions.Estimates.SmoothProfileReindexing + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +noncomputable def smoothMatrixImagePMF {O J : Type*} [Fintype J] + (A : Matrix O J ℤ) (S : J → ℝ) (hS : ∀ j, 0 < S j) : PMF (O → ℤ) := + (smoothProductPMF S hS).map (fun z => A *ᵥ z) + +noncomputable def smoothIntegerImagePMF {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (S : I → ℝ) (T : J → ℝ) + (hS : ∀ i, 0 < S i) (hT : ∀ j, 0 < T j) : PMF (I → ℤ) := + integerImagePMF A B (smoothSplitProfile J I) + (fun p => (smoothSplitProfile_range J I p).1) S T hS hT + (smoothSplitProfile_zero_outside J I) (smoothSplit_mass_pos S T hS hT) + +theorem smoothIntegerImagePMF_eq_matrix {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I I ℤ) (B : Matrix I J ℤ) (S : I → ℝ) (T : J → ℝ) + (hS : ∀ i, 0 < S i) (hT : ∀ j, 0 < T j) : + smoothIntegerImagePMF A B S T hS hT = + smoothMatrixImagePMF (Matrix.fromCols A B) (Sum.elim S T) (fun k => Sum.rec hS hT k) := by + unfold smoothIntegerImagePMF integerImagePMF smoothMatrixImagePMF + rw [← smoothSplit_inputPMF_join S T hS hT, PMF.map_comp] + congr 1 + funext p + simp only [Function.comp_def, Matrix.fromCols_mulVec, Sum.elim_inl, Sum.elim_inr] + +theorem smoothMatrixImagePMF_reindex {O I J : Type*} [Fintype I] [Fintype J] + (A : Matrix O J ℤ) (e : I ≃ J) (S : J → ℝ) (hS : ∀ j, 0 < S j) : + smoothMatrixImagePMF (A.submatrix id e) (S ∘ e) (fun i => hS (e i)) = + smoothMatrixImagePMF A S hS := by + unfold smoothMatrixImagePMF + rw [← smoothProductPMF_reindex e S hS, PMF.map_comp] + congr 1 + funext z + exact Matrix.submatrix_mulVec_equiv A z id e + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SmoothIntegerTranslation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothIntegerTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e131f97ccd4bf10f81556a6d3f8cde6006d403b8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothIntegerTranslation.lean @@ -0,0 +1,271 @@ +import OAI.Combinatorics.Progressions.Estimates.ShiftedSmoothSelectedMarginal +import OAI.Combinatorics.Progressions.Lattices.SmoothAffinePairLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +def smoothAffineSample {K I : Type*} [Fintype K] (t : K → ℤ) + (z : Option K × I → ℤ) : I → ℤ := + fun i => z (none, i) + ∑ k, t k * z (some k, i) + +theorem smoothAffineSample_base_injective {K I : Type*} [Fintype K] + (t : K → ℤ) (tail : K × I → ℤ) : + Function.Injective (fun base => smoothAffineSample t (baseArrayJoin tail base)) := by + intro b c h + funext i + have hi := congrFun h i + change b i + (∑ k, t k * tail (k, i)) = c i + (∑ k, t k * tail (k, i)) at hi + exact add_right_cancel hi + +theorem smoothAffineSample_point_cap {K I : Type*} [Fintype K] [Fintype I] + (a S : Option K × I → ℝ) (hS : ∀ z, 0 < S z) (hZ : 0 < shiftedSmoothProductMass a S) + (hbase : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ S (none, i)) + (t : K → ℤ) (y : I → ℤ) : + ((shiftedSmoothProductPMF a S hS hZ).map (smoothAffineSample t) y).toReal ≤ + ∏ i, 2 / S (none, i) := + shiftedSmoothProductPMF_base_cap a S hS hZ (smoothAffineSample t) + (smoothAffineSample_base_injective t) hbase y + +theorem smoothAffineSample_energy {K I : Type*} [Fintype K] [Fintype I] + (a S : Option K × I → ℝ) (hS : ∀ z, 0 < S z) (hZ : 0 < shiftedSmoothProductMass a S) + (hbase : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ S (none, i)) + (t : K → ℤ) (T : Finset (I → ℤ)) (e : (I → ℤ) → ℝ) (he : ∀ y ∉ T, e y = 0) : + (∑' z, (shiftedSmoothProductPMF a S hS hZ z).toReal * e (smoothAffineSample t z) ^ 2) ≤ + (∏ i, 2 / S (none, i)) * ∑ y ∈ T, e y ^ 2 := + pmf_image_energy_of_point_cap (shiftedSmoothProductPMF a S hS hZ) + (rectangularWeightIndices a S 1) (shiftedSmoothProductPMF_toReal_zero_off a S hS hZ) + (smoothAffineSample t) T e he (smoothAffineSample_point_cap a S hS hZ hbase t) + +theorem smoothAffineSample_energy_of_sum_bound {K I : Type*} [Fintype K] [Fintype I] + (a S : Option K × I → ℝ) (hS : ∀ z, 0 < S z) (hZ : 0 < shiftedSmoothProductMass a S) + (hbase : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ S (none, i)) + (t : K → ℤ) (T : Finset (I → ℤ)) (e : (I → ℤ) → ℝ) (he : ∀ y ∉ T, e y = 0) + {E : ℝ} (henergy : (∑ y ∈ T, e y ^ 2) ≤ E * T.card) : + (∑' z, (shiftedSmoothProductPMF a S hS hZ z).toReal * e (smoothAffineSample t z) ^ 2) ≤ + (∏ i, 2 / S (none, i)) * (E * T.card) := by + exact (smoothAffineSample_energy a S hS hZ hbase t T e he).trans + (mul_le_mul_of_nonneg_left henergy (Finset.prod_nonneg (fun i _ => div_nonneg (by norm_num) (hS (none, i)).le))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem smoothAffineSample_variation {J I : Type*} [Fintype J] + (t u : J → ℤ) (z w : Option J × I → ℤ) (i : I) + {T V r0 rV rt : ℝ} (hT : 0 ≤ T) (hV : 0 ≤ V) + (ht : ∀ j, |(t j : ℝ)| ≤ T) + (hw : ∀ j, |(w (some j, i) : ℝ)| ≤ V) + (hbase : |(z (none, i) : ℝ) - w (none, i)| ≤ r0) + (hdir : ∀ j, |(z (some j, i) : ℝ) - w (some j, i)| ≤ rV) + (hparam : ∀ j, |(t j : ℝ) - u j| ≤ rt) : + |(smoothAffineSample t z i : ℝ) - smoothAffineSample u w i| ≤ + r0 + (Fintype.card J : ℝ) * (T * rV + V * rt) := by + have hid : (smoothAffineSample t z i : ℝ) - smoothAffineSample u w i = + ((z (none, i) : ℝ) - w (none, i)) + + ∑ j, ((t j : ℝ) * z (some j, i) - (u j : ℝ) * w (some j, i)) := by + simp only [smoothAffineSample, Int.cast_add, Int.cast_sum, Int.cast_mul, Finset.sum_sub_distrib] + ring + have hterm (j : J) : |(t j : ℝ) * z (some j, i) - (u j : ℝ) * w (some j, i)| ≤ T * rV + V * rt := by + calc + _ = |(t j : ℝ) * ((z (some j, i) : ℝ) - w (some j, i)) + + (w (some j, i) : ℝ) * ((t j : ℝ) - u j)| := by congr 1; ring + _ ≤ |(t j : ℝ) * ((z (some j, i) : ℝ) - w (some j, i))| + + |(w (some j, i) : ℝ) * ((t j : ℝ) - u j)| := abs_add_le _ _ + _ ≤ T * rV + V * rt := by + rw [abs_mul, abs_mul] + exact add_le_add (mul_le_mul (ht j) (hdir j) (abs_nonneg _) hT) + (mul_le_mul (hw j) (hparam j) (abs_nonneg _) hV) + rw [hid] + calc + _ ≤ |(z (none, i) : ℝ) - w (none, i)| + + |∑ j, ((t j : ℝ) * z (some j, i) - (u j : ℝ) * w (some j, i))| := abs_add_le _ _ + _ ≤ r0 + ∑ j, |(t j : ℝ) * z (some j, i) - (u j : ℝ) * w (some j, i)| := + add_le_add hbase (Finset.abs_sum_le_sum_abs _ _) + _ ≤ r0 + ∑ _j : J, (T * rV + V * rt) := + add_le_add le_rfl (Finset.sum_le_sum (fun j _ => hterm j)) + _ = _ := by rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + +theorem smoothAffineSample_scaled_variation {J I : Type*} [Fintype J] + (t u : J → ℤ) (z w : Option J × I → ℤ) (i : I) + {L H C B delta : ℝ} (hL : 0 < L) (hH : 0 ≤ H) (hC : 0 ≤ C) (hB : 0 ≤ B) + (ht : ∀ j, |(t j : ℝ)| ≤ C * L) + (hw : ∀ j, |(w (some j, i) : ℝ)| ≤ B * H / L) + (hbase : |(z (none, i) : ℝ) - w (none, i)| ≤ delta * H) + (hdir : ∀ j, |(z (some j, i) : ℝ) - w (some j, i)| ≤ delta * H / L) + (hparam : ∀ j, |(t j : ℝ) - u j| ≤ delta * L) : + |(smoothAffineSample t z i : ℝ) - smoothAffineSample u w i| ≤ + delta * H * (1 + (Fintype.card J : ℝ) * (C + B)) := by + apply (smoothAffineSample_variation t u z w i (by positivity) (by positivity) ht hw hbase hdir hparam).trans_eq + field_simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem shiftedSmoothRowMass_pos {J I : Type*} [Fintype J] [Fintype I] + (a S : J × I → ℝ) (hS : ∀ x, 0 < S x) (hZ : 0 < shiftedSmoothProductMass a S) (i : I) : + 0 < shiftedSmoothProductMass (fun j => a (j, i)) (fun j => S (j, i)) := by + rw [shiftedSmoothProductMass_eq_prod _ _ (fun j => hS (j, i))] + exact Finset.prod_pos (fun j _ => shiftedSmoothProductMass_coordinate_pos a S hS hZ (j, i)) + +theorem shiftedSmoothProductPMF_rows {J I : Type*} [Fintype J] [Fintype I] + (a S : J × I → ℝ) (hS : ∀ x, 0 < S x) (hZ : 0 < shiftedSmoothProductMass a S) : + (shiftedSmoothProductPMF a S hS hZ).map independentArrayRows = + independentProductPMF (fun i => shiftedSmoothProductPMF + (fun j => a (j, i)) (fun j => S (j, i)) (fun j => hS (j, i)) + (shiftedSmoothRowMass_pos a S hS hZ i)) := by + rw [shiftedSmoothProductPMF_eq_independent, independentProductPMF_rows] + congr 1 + funext i + exact (shiftedSmoothProductPMF_eq_independent _ _ _ _).symm + +def smoothAffinePairRows {K I : Type*} [Fintype K] + (t u : K → ℤ) (z : Option K × I → ℤ) : I → Fin 2 → ℤ := + fun i => affinePairMatrix t u *ᵥ independentArrayRows z i + +theorem smoothAffinePairRows_apply {K I : Type*} [Fintype K] + (t u : K → ℤ) (z : Option K × I → ℤ) (i : I) : + smoothAffinePairRows t u z i = ![smoothAffineSample t z i, smoothAffineSample u z i] := by + rw [smoothAffinePairRows, affinePairMatrix_mulVec] + rfl + +theorem shiftedSmoothAffinePairRows_law {K I : Type*} [Fintype K] [Fintype I] + (a S : Option K × I → ℝ) (hS : ∀ x, 0 < S x) (hZ : 0 < shiftedSmoothProductMass a S) + (t u : K → ℤ) : + (shiftedSmoothProductPMF a S hS hZ).map (smoothAffinePairRows t u) = + independentProductPMF (fun i => + (shiftedSmoothProductPMF (fun j => a (j, i)) (fun j => S (j, i)) + (fun j => hS (j, i)) (shiftedSmoothRowMass_pos a S hS hZ i)).map + (fun z => affinePairMatrix t u *ᵥ z)) := by + have h := congrArg (fun p : PMF (I → Option K → ℤ) => + p.map (fun rows i => affinePairMatrix t u *ᵥ rows i)) + (shiftedSmoothProductPMF_rows a S hS hZ) + rw [PMF.map_comp, independentProductPMF_map] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem smoothAffinePairRows_congruence {J I : Type*} [Fintype J] + (t u : J → ℤ) (z : Option J × I → ℤ) (i : I) : + BohrLattice.Primitive.content (fun j => u j - t j) ∣ + smoothAffinePairRows t u z i 1 - smoothAffinePairRows t u z i 0 := by + apply (affinePairImage_iff_content_dvd t u _).mp + exact ⟨independentArrayRows z i, rfl⟩ + +theorem affinePairPMF_zero_off_congruence {J I : Type*} [Fintype J] + (p : PMF (Option J × I → ℤ)) (t u : J → ℤ) (v : I → Fin 2 → ℤ) + (hv : ¬ ∀ i, BohrLattice.Primitive.content (fun j => u j - t j) ∣ v i 1 - v i 0) : + p.map (smoothAffinePairRows t u) v = 0 := by + apply pmf_map_zero_off_range + rintro ⟨z, rfl⟩ + exact hv (smoothAffinePairRows_congruence t u z) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem shiftedSmoothSampleSum_integer (b : ℤ) (S : ℝ) : + shiftedSmoothSampleSum (b : ℝ) S = smoothSampleSum S := by + have h := (Equiv.addRight b).tsum_eq + (fun k : ℤ => smoothProbabilityProfile (((k : ℝ) - b) / S)) + simpa only [Equiv.coe_addRight, Int.cast_add, add_sub_cancel_right, + shiftedSmoothSampleSum, smoothSampleSum] using h.symm + +theorem shiftedSmoothProductMass_integer_pos {I : Type*} [Fintype I] + (b : I → ℤ) (S : I → ℝ) (hS : ∀ i, 0 < S i) : + 0 < shiftedSmoothProductMass (fun i => (b i : ℝ)) S := by + rw [shiftedSmoothProductMass_eq_prod _ _ hS] + simp_rw [shiftedSmoothSampleSum_integer] + exact Finset.prod_pos (fun i _ => smoothSampleSum_pos (hS i)) + +theorem shiftedSmoothCoefficientPMF_integer (b : ℤ) (S : ℝ) (hS : 0 < S) + (hZ : 0 < shiftedSmoothSampleSum (b : ℝ) S) : + shiftedSmoothCoefficientPMF (b : ℝ) S hS hZ = + (smoothCoefficientPMF S hS).map (fun z => z + b) := by + ext z + have hmap := pmf_map_injective_at (smoothCoefficientPMF S hS) (fun z => z + b) + (fun _ _ h => add_right_cancel h) (z - b) + rw [sub_add_cancel] at hmap + rw [hmap] + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + rw [shiftedSmoothCoefficientPMF_apply, smoothCoefficientPMF_apply, shiftedSmoothSampleSum_integer] + simp only [Int.cast_sub] + +theorem shiftedSmoothProductPMF_integer {I : Type*} [Fintype I] + (b : I → ℤ) (S : I → ℝ) (hS : ∀ i, 0 < S i) + (hZ : 0 < shiftedSmoothProductMass (fun i => (b i : ℝ)) S) : + shiftedSmoothProductPMF (fun i => (b i : ℝ)) S hS hZ = + (smoothProductPMF S hS).map (fun z => z + b) := by + change _ = (smoothProductPMF S hS).map (fun z i => z i + b i) + rw [shiftedSmoothProductPMF_eq_independent, smoothProductPMF_eq_independent, + independentProductPMF_map (fun i => smoothCoefficientPMF (S i) (hS i)) (fun i z => z + b i)] + congr 1 + funext i + exact shiftedSmoothCoefficientPMF_integer (b i) (S i) (hS i) _ + +theorem smoothAffinePairRows_add {K I : Type*} [Fintype K] + (t u : K → ℤ) (z b : Option K × I → ℤ) : + smoothAffinePairRows t u (z + b) = smoothAffinePairRows t u z + smoothAffinePairRows t u b := by + funext i + change affinePairMatrix t u *ᵥ (independentArrayRows z i + independentArrayRows b i) = _ + exact Matrix.mulVec_add _ _ _ + +theorem shiftedSmoothAffinePairRows_integer {K I : Type*} [Fintype K] [Fintype I] + (b : Option K × I → ℤ) (S : Option K × I → ℝ) (hS : ∀ i, 0 < S i) + (hZ : 0 < shiftedSmoothProductMass (fun i => (b i : ℝ)) S) (t u : K → ℤ) : + (shiftedSmoothProductPMF (fun i => (b i : ℝ)) S hS hZ).map (smoothAffinePairRows t u) = + ((smoothProductPMF S hS).map (smoothAffinePairRows t u)).map + (fun v => v + smoothAffinePairRows t u b) := by + rw [shiftedSmoothProductPMF_integer, PMF.map_comp, PMF.map_comp] + congr 1 + funext z + exact smoothAffinePairRows_add t u z b + +theorem shiftedSmoothAffinePairRows_integer_apply {K I : Type*} [Fintype K] [Fintype I] + (b : Option K × I → ℤ) (S : Option K × I → ℝ) (hS : ∀ i, 0 < S i) + (hZ : 0 < shiftedSmoothProductMass (fun i => (b i : ℝ)) S) (t u : K → ℤ) + (v : I → Fin 2 → ℤ) : + ((shiftedSmoothProductPMF (fun i => (b i : ℝ)) S hS hZ).map (smoothAffinePairRows t u)) v = + ((smoothProductPMF S hS).map (smoothAffinePairRows t u)) (v - smoothAffinePairRows t u b) := by + rw [shiftedSmoothAffinePairRows_integer] + have h := pmf_map_injective_at ((smoothProductPMF S hS).map (smoothAffinePairRows t u)) + (fun v => v + smoothAffinePairRows t u b) (fun _ _ h => add_right_cancel h) + (v - smoothAffinePairRows t u b) + simpa only [sub_add_cancel] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SmoothResidueWindowMass.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothResidueWindowMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..a18b16ca60e763a51b9920f770d6cae7d7fa4d00 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothResidueWindowMass.lean @@ -0,0 +1,498 @@ +import Mathlib.Probability.ProbabilityMassFunction.Integrals +import OAI.Combinatorics.Progressions.Estimates.ComplexNormalizationError +import OAI.Combinatorics.Progressions.Estimates.LowWeightFibers +import OAI.Combinatorics.Progressions.Lattices.SelectedResidueApproximation +import OAI.Combinatorics.Progressions.Probability.PMFPointMassMixture + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def selectedResidueDensityMass {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (D : (K × I → ℤ) → ℝ) : ℝ := + finiteDensityMass (selectedResidueSmoothWeight modulus G V) D + +theorem selectedResidueDensityMass_complex {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) (D : (K × I → ℤ) → ℝ) : + (selectedResidueDensityMass modulus G V D : ℂ) = + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * (D x : ℂ) := by + simp only [selectedResidueDensityMass, finiteDensityMass_complex, selectedResidueSmoothPMF_toReal] + +noncomputable def selectedResidueDensityPMF {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) : PMF (K × I → ℤ) := + finiteDensityTiltPMF _ (rectangularWeightIndices 0 V 1) + (selectedResidueSmoothWeight_nonneg modulus G V) + (selectedResidueSmoothWeight_zero_off modulus G V hV) hZ D hD0 hD + +theorem selectedResidueDensityPMF_toReal {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) (x : K × I → ℤ) : + (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal = + (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * D x / + selectedResidueDensityMass modulus G V D := by + unfold selectedResidueDensityMass at hD ⊢ + simp only [selectedResidueDensityPMF, finiteDensityTiltPMF_toReal, selectedResidueSmoothPMF_toReal] + +theorem selectedResidueDensityPMF_complexMean {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) (f : (K × I → ℤ) → ℂ) : + (∑' x, ((selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal : ℂ) * f x) = + (∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * ((D x : ℂ) * f x)) / + (selectedResidueDensityMass modulus G V D : ℂ) := by + unfold selectedResidueDensityMass at hD ⊢ + simp only [selectedResidueDensityPMF, finiteDensityTiltPMF_complexMean, + selectedResidueSmoothPMF_toReal] + +theorem selectedResidueDensityPMF_error {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) (f : (K × I → ℤ) → ℂ) + {a : ℂ} {E ε B : ℝ} (hlower : 1 / 2 ≤ selectedResidueDensityMass modulus G V D) + (herror : ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * + ((D x : ℂ) * f x)) - a‖ ≤ E) + (hmass : |selectedResidueDensityMass modulus G V D - 1| ≤ ε) (hcap : ‖a‖ ≤ B) : + ‖(∑' x, ((selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal : ℂ) * f x) - a‖ ≤ + 2 * E + 2 * B * ε := by + rw [selectedResidueDensityPMF_complexMean] + exact complex_normalization_error hlower herror hmass hcap + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory + +theorem selectedResidueDensityMass_integral {K I : Type*} [Fintype K] [Fintype I] + (stride : I → ℕ) (cells : Finset (ColumnResiduePattern K I stride)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight stride cells V x) + (f : (K × I → ℤ) → ℝ) + (hf : Integrable f (selectedResidueSmoothPMF stride cells V hV hZ).toMeasure) : + selectedResidueDensityMass stride cells V f = + ∫ x, f x ∂(selectedResidueSmoothPMF stride cells V hV hZ).toMeasure := by + apply Complex.ofReal_injective + rw [selectedResidueDensityMass_complex stride cells V hV hZ, + ← integral_complex_ofReal, PMF.integral_eq_tsum _ _ hf.ofReal] + simp only [Complex.real_smul] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem selectedResidueDensityPMF_zero_off {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (x : K × I → ℤ) (hx : x ∉ rectangularWeightIndices 0 V 1) : + (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal = 0 := by + rw [selectedResidueDensityPMF_toReal, selectedResidueSmoothPMF_toReal, + selectedResidueSmoothWeight_zero_off modulus G V hV x hx] + simp + +theorem selectedResidueDensityPMF_zero_of_density_zero {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (x : K × I → ℤ) (hx : D x = 0) : + (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal = 0 := by + rw [selectedResidueDensityPMF_toReal, hx, mul_zero, zero_div] + +theorem selectedResidueDensityPMF_domination {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (hlower : 1 / 2 ≤ selectedResidueDensityMass modulus G V D) + {B : ℝ} (hbound : ∀ x, D x ≤ B) (x : K × I → ℤ) : + (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal ≤ + 2 * B * (selectedResidueSmoothPMF modulus G V hV hZ x).toReal := by + rw [selectedResidueDensityPMF_toReal, mul_div_assoc] + have hb := (normalized_weight_range D (fun y => ⟨hD0 y, hbound y⟩) hlower x).2 + have h := mul_le_mul_of_nonneg_left hb + (ENNReal.toReal_nonneg : 0 ≤ (selectedResidueSmoothPMF modulus G V hV hZ x).toReal) + simpa only [mul_comm] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def selectedResidueFiniteLaw {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) : + FiniteProbabilityWeights (rectangularWeightIndices 0 V 1) := + finiteSupportProbability (selectedResidueSmoothWeight modulus G V) (rectangularWeightIndices 0 V 1) + (selectedResidueSmoothWeight_nonneg modulus G V) + (selectedResidueSmoothWeight_zero_off modulus G V hV) hZ + +theorem selectedResidueFiniteLaw_complexMean {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) (f : (K × I → ℤ) → ℂ) : + (selectedResidueFiniteLaw modulus G V hV hZ).complexMean (fun x => f x.val) = + ∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * f x := by + simp only [selectedResidueFiniteLaw, finiteSupportProbability_complexMean, selectedResidueSmoothPMF_toReal] + +theorem selectedResidueFiniteLaw_mean {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) (f : (K × I → ℤ) → ℝ) : + (selectedResidueFiniteLaw modulus G V hV hZ).mean (fun x => f x.val) = + ∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * f x := by + apply Complex.ofReal_injective + have h := selectedResidueFiniteLaw_complexMean modulus G V hV hZ (fun x => (f x : ℂ)) + rw [FiniteProbabilityWeights.complexMean_ofReal] at h + simpa only [Complex.ofReal_tsum, Complex.ofReal_mul] using h + +theorem selectedResidueFiniteLaw_densityMass {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) (D : (K × I → ℤ) → ℝ) : + (selectedResidueFiniteLaw modulus G V hV hZ).mean (fun x => D x.val) = + selectedResidueDensityMass modulus G V D := by + rw [selectedResidueFiniteLaw_mean] + simp only [selectedResidueSmoothPMF_toReal, selectedResidueDensityMass, finiteDensityMass] + +theorem selectedResidueDensityPMF_mean {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) (f : (K × I → ℤ) → ℝ) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * f x) = + (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (D x * f x)) / + selectedResidueDensityMass modulus G V D := by + simp only [selectedResidueDensityPMF_toReal, div_mul_eq_mul_div, mul_assoc, tsum_div_const] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +def columnResidueReduction {K I : Type*} (modulus refined : I → ℕ) + (hdiv : ∀ i, modulus i ∣ refined i) + (r : ColumnResiduePattern K I refined) : ColumnResiduePattern K I modulus := + fun z => ZMod.castHom (hdiv z.2) (ZMod (modulus z.2)) (r z) + +@[simp] theorem columnResidueReduction_pattern {K I : Type*} (modulus refined : I → ℕ) + (hdiv : ∀ i, modulus i ∣ refined i) (x : K × I → ℤ) : + columnResidueReduction modulus refined hdiv (columnResiduePattern refined x) = + columnResiduePattern modulus x := by + funext z + exact map_intCast (ZMod.castHom (hdiv z.2) (ZMod (modulus z.2))) (x z) + +noncomputable def selectedResidueRefinement {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) : + Finset (ColumnResiduePattern K I refined) := + Finset.univ.filter (fun r => columnResidueReduction modulus refined hdiv r ∈ G) + +@[simp] theorem mem_selectedResidueRefinement {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (r : ColumnResiduePattern K I refined) : + r ∈ selectedResidueRefinement modulus refined hdiv G ↔ + columnResidueReduction modulus refined hdiv r ∈ G := by + simp only [selectedResidueRefinement, Finset.mem_filter, Finset.mem_univ, true_and] + +theorem selectedResidueSmoothWeight_refinement {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (x : K × I → ℤ) : + selectedResidueSmoothWeight refined (selectedResidueRefinement modulus refined hdiv G) V x = + selectedResidueSmoothWeight modulus G V x := by + simp only [selectedResidueSmoothWeight, mem_selectedResidueRefinement, + columnResidueReduction_pattern] + +theorem selectedResidueSmoothMass_refinement {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) : + (∑' x, selectedResidueSmoothWeight refined (selectedResidueRefinement modulus refined hdiv G) V x) = + ∑' x, selectedResidueSmoothWeight modulus G V x := by + simp only [selectedResidueSmoothWeight_refinement] + +theorem selectedResidueSmoothPMF_refinement {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (hZ' : 0 < ∑' x, selectedResidueSmoothWeight refined + (selectedResidueRefinement modulus refined hdiv G) V x) : + selectedResidueSmoothPMF refined (selectedResidueRefinement modulus refined hdiv G) V hV hZ' = + selectedResidueSmoothPMF modulus G V hV hZ := by + ext x + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + simp only [selectedResidueSmoothPMF_toReal, selectedResidueSmoothWeight_refinement] + +theorem selectedResidueRefinement_nonempty {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (hG : G.Nonempty) : (selectedResidueRefinement modulus refined hdiv G).Nonempty := by + obtain ⟨r, hr⟩ := hG + refine ⟨columnResiduePattern refined (columnResidueRepresentative modulus r), ?_⟩ + rw [mem_selectedResidueRefinement, columnResidueReduction_pattern] + have hrep : columnResiduePattern modulus (columnResidueRepresentative modulus r) = r := by + funext z + exact columnResidueRepresentative_cast modulus r z + rwa [hrep] + +noncomputable def selectedResidueExtraRefinement {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) [∀ i, NeZero (modulus i)] (q : ℕ) [NeZero q] + (G : Finset (ColumnResiduePattern K I modulus)) : + Finset (ColumnResiduePattern K I (fun i => modulus i * q)) := + selectedResidueRefinement modulus (fun i => modulus i * q) (fun i => dvd_mul_right (modulus i) q) G + +def refinedColumnExtraResidue {K I : Type*} (modulus : I → ℕ) (q : ℕ) + (r : ColumnResiduePattern K I (fun i => modulus i * q)) : K × I → ZMod q := + columnResidueReduction (fun _ => q) (fun i => modulus i * q) + (fun i => dvd_mul_left q (modulus i)) r + +theorem refinedColumnExtraResidue_of_pattern {K I : Type*} (modulus : I → ℕ) (q : ℕ) + (r : ColumnResiduePattern K I (fun i => modulus i * q)) (x : K × I → ℤ) + (hx : columnResiduePattern (fun i => modulus i * q) x = r) : + (fun z => (x z : ZMod q)) = refinedColumnExtraResidue modulus q r := by + rw [← hx, refinedColumnExtraResidue, columnResidueReduction_pattern] + rfl + +theorem refinedResidueLatticeArray_extraResidue {K I : Type*} (modulus : I → ℕ) (q : ℕ) + (r : ColumnResiduePattern K I (fun i => modulus i * q)) (x : K × I → ℤ) : + (fun z => (residueLatticeArray (columnResidueRepresentative (fun i => modulus i * q) r) + (fun i => modulus i * q) x z : ZMod q)) = refinedColumnExtraResidue modulus q r := by + apply refinedColumnExtraResidue_of_pattern + funext z + simp only [columnResiduePattern, residueLatticeArray, Int.cast_add, Int.cast_mul, + Int.cast_natCast, ZMod.natCast_self, zero_mul, add_zero, + columnResidueRepresentative_cast] + +theorem selectedResidueDensityMass_refinement {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (D : (K × I → ℤ) → ℝ) : + selectedResidueDensityMass refined (selectedResidueRefinement modulus refined hdiv G) V D = + selectedResidueDensityMass modulus G V D := by + simp only [selectedResidueDensityMass, finiteDensityMass, selectedResidueSmoothWeight_refinement] + +theorem selectedResidueDensityPMF_refinement {K I : Type*} [Fintype K] [Fintype I] + (modulus refined : I → ℕ) [∀ i, NeZero (refined i)] + (hdiv : ∀ i, modulus i ∣ refined i) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (hZ' : 0 < ∑' x, selectedResidueSmoothWeight refined + (selectedResidueRefinement modulus refined hdiv G) V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (hD' : 0 < selectedResidueDensityMass refined + (selectedResidueRefinement modulus refined hdiv G) V D) : + selectedResidueDensityPMF refined (selectedResidueRefinement modulus refined hdiv G) V hV hZ' + D hD0 hD' = selectedResidueDensityPMF modulus G V hV hZ D hD0 hD := by + ext x + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + simp only [selectedResidueDensityPMF_toReal, selectedResidueDensityMass_refinement, + selectedResidueSmoothPMF_toReal, selectedResidueSmoothWeight_refinement] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem selectedResidueDensityPMF_raw_error {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (f : (K × I → ℤ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) + {a : ℂ} {η γ : ℝ} + (htest : ‖(∑' x, ((selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal : ℂ) * f x) - a‖ ≤ η) + (hmass : |selectedResidueDensityMass modulus G V D - 1| ≤ γ) : + ‖(∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * ((D x : ℂ) * f x)) - a‖ ≤ η + γ := by + let p := selectedResidueDensityPMF modulus G V hV hZ D hD0 hD + let b : ℂ := ∑' x, ((p x).toReal : ℂ) * f x + have hb : ‖b‖ ≤ 1 := by + have hh := pmf_complex_average_error p f (fun _ => 0) hf + (fun _ => by simp : ∀ x, ‖(0 : ℂ)‖ ≤ (0 : ℝ)) (by simpa using hf) + simpa only [mul_zero, tsum_zero, sub_zero, b] using hh + have heq := selectedResidueDensityPMF_complexMean modulus G V hV hZ D hD0 hD f + have hmassc : (selectedResidueDensityMass modulus G V D : ℂ) ≠ 0 := by exact_mod_cast hD.ne' + have hraw : (∑' x, ((selectedResidueSmoothPMF modulus G V hV hZ x).toReal : ℂ) * ((D x : ℂ) * f x)) = + (selectedResidueDensityMass modulus G V D : ℂ) * b := by + dsimp only [b, p] + rw [heq, mul_div_cancel₀ _ hmassc] + rw [hraw] + have hstep : ‖(selectedResidueDensityMass modulus G V D : ℂ) * b - b‖ ≤ γ := by + rw [← sub_one_mul, norm_mul, ← Complex.ofReal_one, ← Complex.ofReal_sub, + Complex.norm_real, Real.norm_eq_abs] + exact (mul_le_mul_of_nonneg_left hb (abs_nonneg _)).trans (by simpa using hmass) + have ht := norm_sub_le_norm_sub_add_norm_sub + ((selectedResidueDensityMass modulus G V D : ℂ) * b) b a + exact ht.trans (by linarith) + +theorem selectedResidueDensityPMF_singleton_complexMean_congr {K I : Type*} + [Fintype K] [Fintype I] (modulus : I → ℕ) (r : ColumnResiduePattern K I modulus) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus {r} V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus {r} V D) + (f g : (K × I → ℤ) → ℂ) + (heq : ∀ x, columnResiduePattern modulus x = r → f x = g x) : + (∑' x, ((selectedResidueDensityPMF modulus {r} V hV hZ D hD0 hD x).toReal : ℂ) * f x) = + ∑' x, ((selectedResidueDensityPMF modulus {r} V hV hZ D hD0 hD x).toReal : ℂ) * g x := by + apply tsum_congr + intro x + by_cases hx : columnResiduePattern modulus x = r + · rw [heq x hx] + · have hz : (selectedResidueDensityPMF modulus {r} V hV hZ D hD0 hD x).toReal = 0 := by + rw [selectedResidueDensityPMF_toReal, selectedResidueSmoothPMF_toReal] + simp [selectedResidueSmoothWeight, hx] + simp [hz] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem smoothProbabilityProfile_plateau (x : ℝ) (hx : |x| ≤ 1 / 2) : + smoothProbabilityProfile x = smoothProbabilityProfile 0 := by + have hx' : probabilityProfileBump x = 1 := probabilityProfileBump.one_of_mem_closedBall + (by simpa [probabilityProfileBump, Real.dist_eq] using hx) + have h0 : probabilityProfileBump 0 = 1 := probabilityProfileBump.one_of_mem_closedBall + (by simp [probabilityProfileBump]) + simp only [smoothProbabilityProfile, ContDiffBump.normed_def, hx', h0] + +theorem selectedResidueSmoothWeight_plateau {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (cells : Finset (ColumnResiduePattern K X q)) (V : K × X → ℝ) + (z : K × X → ℤ) (hz : columnResiduePattern q z ∈ cells) + (hsmall : ∀ i, |(z i : ℝ) / V i| ≤ 1 / 2) : + selectedResidueSmoothWeight q cells V z = + (smoothProbabilityProfile 0) ^ Fintype.card (K × X) := by + classical + simp only [selectedResidueSmoothWeight, hz, ite_true] + unfold smoothProductProfile + calc + _ = ∏ _i : K × X, smoothProbabilityProfile 0 := + Finset.prod_congr rfl (fun i _ => smoothProbabilityProfile_plateau _ (hsmall i)) + _ = _ := by simp + +theorem selectedResidueDensityMass_window_bound {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (cells : Finset (ColumnResiduePattern K X q)) + (V : K × X → ℝ) (hV : ∀ i, 0 < V i) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q cells V z) + (D : (K × X → ℤ) → ℝ) (hD : ∀ z, 0 ≤ D z) + (window : Finset (K × X → ℤ)) + (hresidue : ∀ z ∈ window, columnResiduePattern q z ∈ cells) + (hsmall : ∀ z ∈ window, ∀ i, |(z i : ℝ) / V i| ≤ 1 / 2) : + (∑ z ∈ window, D z) ≤ + ((∑' z, selectedResidueSmoothWeight q cells V z) / + (smoothProbabilityProfile 0) ^ Fintype.card (K × X)) * + selectedResidueDensityMass q cells V D := by + apply finiteDensityMass_sum_le_of_weight_lower (selectedResidueSmoothWeight q cells V) D + (rectangularWeightIndices 0 V 1) window (selectedResidueSmoothWeight_nonneg q cells V) + (selectedResidueSmoothWeight_zero_off q cells V hV) hD hZ + (pow_pos smoothProbabilityProfile_pos_zero _) + intro z hz + exact (selectedResidueSmoothWeight_plateau q cells V z (hresidue z hz) (hsmall z hz)).ge + +theorem selectedResidueSmoothWeight_singleton_mass_upper {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) (r : ColumnResiduePattern K X q) + (V : K × X → ℝ) (hV : ∀ i, 0 < V i) + (hscale : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V i) : + (∑' z, selectedResidueSmoothWeight q {r} V z) ≤ + (3 / 2 : ℝ) ^ Fintype.card (K × X) * ∏ i, residueProfileWidth q V i := by + classical + have he : selectedResidueSmoothWeight q {r} V = + residueSmoothWeight (columnResidueRepresentative q r) q V := by + funext z + simp only [selectedResidueSmoothWeight, residueSmoothWeight_eq_pattern, Finset.mem_singleton] + rw [he, ← residueSmoothWeight_mass _ q hq V hV, + shiftedSmoothProductMass_eq_prod _ _ (residueProfileWidth_pos q V hq hV)] + calc + _ ≤ ∏ i : K × X, 3 * residueProfileWidth q V i / 2 := by + apply Finset.prod_le_prod₀ + · intro i _ + exact tsum_nonneg (fun _ => (smoothProbabilityProfile_range _).1) + · intro i _ + exact (shiftedSmoothSampleSum_bounds _ (hscale i)).2 + _ = _ := by + simp_rw [show ∀ i : K × X, 3 * residueProfileWidth q V i / 2 = + (3 / 2 : ℝ) * residueProfileWidth q V i by intro i; ring] + rw [Finset.prod_mul_distrib] + simp only [Finset.prod_const, Finset.card_univ] + +theorem selectedResidueDensityMass_singleton_window_bound {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) (r : ColumnResiduePattern K X q) + (V : K × X → ℝ) (hV : ∀ i, 0 < V i) + (hscale : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V i) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q {r} V z) + (D : (K × X → ℤ) → ℝ) (hD : ∀ z, 0 ≤ D z) + (window : Finset (K × X → ℤ)) + (hresidue : ∀ z ∈ window, columnResiduePattern q z = r) + (hsmall : ∀ z ∈ window, ∀ i, |(z i : ℝ) / V i| ≤ 1 / 2) : + (∑ z ∈ window, D z) ≤ + ((3 / 2 : ℝ) ^ Fintype.card (K × X) * (∏ i, residueProfileWidth q V i) / + (smoothProbabilityProfile 0) ^ Fintype.card (K × X)) * + selectedResidueDensityMass q {r} V D := by + classical + have hm : 0 ≤ selectedResidueDensityMass q {r} V D := by + apply tsum_nonneg + intro z + exact mul_nonneg (div_nonneg (selectedResidueSmoothWeight_nonneg q {r} V z) hZ.le) (hD z) + apply (selectedResidueDensityMass_window_bound q {r} V hV hZ D hD window + (fun z hz => Finset.mem_singleton.mpr (hresidue z hz)) hsmall).trans + apply mul_le_mul_of_nonneg_right _ hm + exact div_le_div_of_nonneg_right (selectedResidueSmoothWeight_singleton_mass_upper q hq r V hV hscale) + (pow_pos smoothProbabilityProfile_pos_zero _).le + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SmoothSpatialResidueMixture.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothSpatialResidueMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a46abcb1e00898c1d354b8493f728f6c8d6a42a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SmoothSpatialResidueMixture.lean @@ -0,0 +1,54 @@ +import OAI.Combinatorics.Progressions.Linear.SmoothSpatialKernelRegularity + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem smoothSpatial_residue_mixture {I J N X : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + [Fintype N] [DecidableEq N] [Fintype X] + {L B : ℕ} {H ρ ξ : ℝ} + (s : I ↪ J) (x : J → IntegerScalarCubeBox I L) (root : J → ℤ) + (hB : 0 < B) (hL : 0 < L) (hH : 0 < H) + (hx : GoodScalarKernelTuple s (1 / (B : ℝ)) B x) (hroot : ∀ j, |root j| ≤ (L : ℤ)) + (m : ℕ) [NeZero m] + (hperiod : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s)) + (p : FiniteProbabilityWeights X) (C : X → Matrix (Unit ⊕ I) N ℤ) + (Q : N → ℝ) (hQ : ∀ j, 0 < Q j) (hξ0 : 0 ≤ ξ) (hξ1 : ξ ≤ 1) + (hC : ∀ y, p.weight y ≠ 0 → ∀ i j, |(C y i j : ℝ)| * Q j ≤ ξ * H) + (hρ : 0 < ρ) (hscale : ρ ≤ H / L) (hscaleQ : ∀ j, ρ ≤ Q j) + (hlarge : smoothSpatialMeshThreshold I J N L ≤ ρ) + (outputs : Finset ((Unit ⊕ I) → ℤ)) (D : X → ((Unit ⊕ I) → ℤ) → ℝ) + (φ : ((Unit ⊕ I) → ℤ) → ℂ) + (hD : ∀ y, p.weight y ≠ 0 → ∀ v ∈ outputs, 0 ≤ D y v) + (hφ : ∀ v ∈ outputs, ‖φ v‖ ≤ 1) : + let A := selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s + let A' := selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s + let hA := goodScalarKernelTuple_spatial_det_ne_zero s x root + (one_div_pos.mpr (by exact_mod_cast hB)) hx + let f := smoothSpatialKernelDensity s root (scalarCubeDifferenceMatrix x) hA + H L hH (by exact_mod_cast hL) + ‖p.complexMean (fun y => 𝔼 v ∈ outputs, + ((D y v * ((∏ _i : Unit ⊕ I, H) * + (smoothSpatialOutputLaw root (scalarCubeDifferenceMatrix x) (C y) H L Q hH + (by exact_mod_cast hL) hQ v).toReal) : ℝ) : ℂ) * φ v) - + ∑ r : Matrix (Unit ⊕ I) N (ZMod m), 𝔼 v ∈ outputs, + ((p.fiberMean (fun y => integerResidueMatrix (C y) m) r (fun y => D y v) * + residueSpatialWeight A A' (fun _ => H) f r v : ℝ) : ℂ) * φ v‖ ≤ + smoothSpatialError N s B L ρ ξ * p.mean (fun y => 𝔼 v ∈ outputs, D y v) := by + apply weightedResidueSpatial_mixture_comparison p outputs _ _ C _ _ m hperiod _ D φ hD hφ + intro y hy v _ + exact smoothSpatial_original_error s x root hB hL hH hx hroot (C y) Q hQ hξ0 hξ1 + (hC y hy) hρ hscale hscaleQ hlarge v + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SourceLatticeCover.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SourceLatticeCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..85c242926fea2868d7ed751e929f6887a1ada598 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SourceLatticeCover.lean @@ -0,0 +1,258 @@ +import OAI.Combinatorics.Progressions.Linear.RationalTaggedSpanProjection + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup + +noncomputable def withLattice {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) (Λ : Subgroup D.filtration.Group) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N) : + RationalFilteredNilmanifold L s d := + { D with lattice := Λ, grid := N, grid_pos := hN, inner_grid := hin, outer_grid := hout } + +theorem withLattice_geometry {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) (Λ : Subgroup D.filtration.Group) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N) + {p q : ℝ} (hD : D.GeometryComplexityLE p) (hpq : p ≤ q) (hNb : (N : ℝ) ≤ Real.exp q) : + (D.withLattice Λ N hN hin hout).GeometryComplexityLE q := + ⟨hD.1.trans hpq, hNb, fun i j k => (hD.2.2.1 i j k).trans hpq, + fun i j k => (hD.2.2.2 i j k).trans hpq⟩ + +theorem exists_native_image_cover (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {d e : ℕ} + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M s e) + (φ : L →ₗ⁅ℚ⁆ M) {p : ℝ}, 0 ≤ p → D.GeometryComplexityLE p → E.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (E.basis.repr (φ (D.basis j)) i) ≤ p) → + ∃ Λ : Subgroup E.filtration.Group, + Λ ≤ E.lattice ∧ (Λ.subgroupOf E.lattice).Characteristic ∧ + (Λ.subgroupOf E.lattice).Normal ∧ (Λ.subgroupOf E.lattice).FiniteIndex ∧ + (Λ.relIndex E.lattice : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates E.basis Λ) + (hout : bchSubgroupCoordinates E.basis Λ ⊆ denominatorGrid N), + (E.withLattice Λ N hN hin hout).GeometryComplexityLE ((p + C) ^ C) ∧ + Λ.map realificationHom ⊓ + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ).range ≤ + (D.lattice.map realificationHom).map + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ) := by + obtain ⟨c, _, hbudget⟩ := exists_image_cover_reconstruction_budget (bchIntegralDenominatorBound s) 0 + let P : Polynomial ℕ := Polynomial.X + 1 + (Polynomial.X + 1 + Polynomial.C c) ^ c + obtain ⟨C, hC, hfinal⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro L M _ _ _ _ d e D E φ p hp hD hE hφ + let t := p + 1 + have ht : 0 ≤ t := add_nonneg hp zero_le_one + have hpt : p ≤ t := le_add_of_nonneg_right zero_le_one + let H := ⌈Real.exp p⌉₊ + have hH : 1 ≤ H := one_le_ceil_exp p + have hHt : (H : ℝ) ≤ Real.exp t := ceil_exp_le_exp_add_one hp + have hdt : (Fintype.card (Fin d) : ℝ) ≤ t := by simpa only [Fintype.card_fin] using hD.1.trans hpt + have het : (Fintype.card (Fin e) : ℝ) ≤ t := by simpa only [Fintype.card_fin] using hE.1.trans hpt + have hlt : (D.grid : ℝ) ≤ Real.exp t := hD.2.1.trans (Real.exp_le_exp.mpr hpt) + have hmt : (E.grid : ℝ) ≤ Real.exp t := hE.2.1.trans (Real.exp_le_exp.mpr hpt) + obtain ⟨A, Λ, hA, hAb, hΛ, hchar, hnormal, hfinite, hindex, hin, hout, hcover⟩ := + E.filtration.exists_image_lattice_cover D.basis E.basis φ D.lattice E.lattice + D.grid E.grid H D.grid_pos E.grid_pos hH D.inner_grid E.inner_grid E.outer_grid + (fun i j => rationalHeightLE_ceil_exp (hφ i j)) + (fun i j k => rationalHeightLE_ceil_exp (hE.2.2.1 i j k)) + let a := imageLatticeLogBudget (bchIntegralDenominatorBound s) t + have ha : 0 ≤ a := imageLatticeLogBudget_nonneg _ ht + have hAt : (A : ℝ) ≤ Real.exp a := + (Nat.cast_le.mpr hAb).trans (imageLatticeBound_le_exp _ _ _ H D.grid E.grid ht hdt het hHt hlt hmt) + have hprod : ((E.grid * A : ℕ) : ℝ) ≤ Real.exp (t + a) := by + rw [Nat.cast_mul, Real.exp_add] + exact mul_le_mul hmt hAt (Nat.cast_nonneg _) (Real.exp_pos _).le + have hN : 0 < (E.grid * A) * E.grid := Nat.mul_pos (Nat.mul_pos E.grid_pos hA) E.grid_pos + have hNg : (((E.grid * A) * E.grid : ℕ) : ℝ) ≤ Real.exp (2 * t + a) := by + calc + _ = ((E.grid * A : ℕ) : ℝ) * (E.grid : ℝ) := Nat.cast_mul _ _ + _ ≤ Real.exp (t + a) * Real.exp t := mul_le_mul hprod hmt (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hidx : (Λ.relIndex E.lattice : ℝ) ≤ Real.exp (t * (t + a)) := by + apply (Nat.cast_le.mpr hindex).trans + rw [Nat.cast_pow] + apply (pow_le_pow_left₀ (Nat.cast_nonneg _) hprod _).trans + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right het (add_nonneg ht ha) + obtain ⟨hq, hi, _⟩ := hbudget t ht + have hsum : t + (t + c) ^ c ≤ (p + C) ^ C := by + simpa [P, t, Polynomial.eval₂_pow] using hfinal p hp + have hcC : (t + c) ^ c ≤ (p + C) ^ C := (le_add_of_nonneg_left ht).trans hsum + have htC : t ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (add_nonneg ht (Nat.cast_nonneg _)) _)).trans hsum + refine ⟨Λ, hΛ, hchar, hnormal, hfinite, + hidx.trans (Real.exp_le_exp.mpr (hi.trans hcC)), (E.grid * A) * E.grid, hN, hin, hout, ?_, hcover⟩ + exact E.withLattice_geometry Λ _ hN hin hout hE (hpt.trans htC) + (hNg.trans (Real.exp_le_exp.mpr (hq.trans hcC))) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s t d : ℕ} + (D : RationalFilteredNilmanifold L s d) (hst : s ≤ t) + (Λ : Subgroup (D.raiseStep hst).filtration.Group) + +noncomputable def lowerCoverLattice : Subgroup D.filtration.Group := + Λ.map (changeStep (D.raiseStep hst).filtration.lowerCentralSeries_eq_bot + D.filtration.lowerCentralSeries_eq_bot).toMonoidHom + +theorem lowerCoverLattice_coordinates : + bchSubgroupCoordinates D.basis (D.lowerCoverLattice hst Λ) = + bchSubgroupCoordinates D.basis Λ := + bchSubgroupCoordinates_changeStep _ _ D.basis Λ + +theorem lowerCoverLattice_forward : + D.lowerCoverLattice hst Λ ≤ Λ.comap + (mapOfSteps (hL := D.filtration.lowerCentralSeries_eq_bot) + (hM := (D.raiseStep hst).filtration.lowerCentralSeries_eq_bot) + (LieHom.id : L →ₗ⁅ℚ⁆ L)) := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Subgroup.mem_map.mp hx + exact hy + +theorem lowerCoverLattice_backward : + Λ ≤ (D.lowerCoverLattice hst Λ).comap + (mapOfSteps (hL := (D.raiseStep hst).filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L)) := by + intro x hx + exact Subgroup.mem_map.mpr ⟨x, hx, rfl⟩ + +theorem lowerCoverLattice_le (hΛ : Λ ≤ (D.raiseStep hst).lattice) : + D.lowerCoverLattice hst Λ ≤ D.lattice := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Subgroup.mem_map.mp hx + exact D.raiseStep_lattice_back hst (hΛ hy) + +variable (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N) + +noncomputable def loweredCover : RationalFilteredNilmanifold L s d := + D.withLattice (D.lowerCoverLattice hst Λ) N hN + (by rw [D.lowerCoverLattice_coordinates]; exact hin) + (by rw [D.lowerCoverLattice_coordinates]; exact hout) + +theorem loweredCover_filtration : (D.loweredCover hst Λ N hN hin hout).filtration = D.filtration := rfl + +theorem loweredCover_geometry {p q : ℝ} (hD : D.GeometryComplexityLE p) + (hpq : p ≤ q) (hNb : (N : ℝ) ≤ Real.exp q) : + (D.loweredCover hst Λ N hN hin hout).GeometryComplexityLE q := + D.withLattice_geometry _ _ _ _ _ hD hpq hNb + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup +open scoped Matrix + +theorem bchSubgroupCoordinates_comap_ofSteps + {ι κ L M : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s t : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + (b : Basis ι ℚ L) (e : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + (Γ : Subgroup (NilpotentLieBCHGroup M t hM)) : + bchSubgroupCoordinates b (Γ.comap (mapOfSteps (hL := hL) φ)) = + (LinearMap.toMatrix b e φ.toLinearMap).mulVec ⁻¹' bchSubgroupCoordinates e Γ := by + ext x + change ((⟨φ (b.equivFun.symm x)⟩ : NilpotentLieBCHGroup M t hM) ∈ Γ) ↔ + ((⟨e.equivFun.symm (LinearMap.toMatrix b e φ.toLinearMap *ᵥ x)⟩ : + NilpotentLieBCHGroup M t hM) ∈ Γ) + rw [basisMatrix_mulVec, LinearEquiv.symm_apply_apply] + rfl + +namespace RationalFilteredNilmanifold + +theorem exists_native_source_cover : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t d e : ℕ} + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M t e) + (φ : L →ₗ⁅ℚ⁆ M) {p : ℝ}, 0 ≤ p → D.GeometryComplexityLE p → E.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (E.basis.repr (φ (D.basis j)) i) ≤ p) → + ∃ Λ : Subgroup D.filtration.Group, + Λ ≤ D.lattice ∧ (Λ.subgroupOf D.lattice).Characteristic ∧ + (Λ.subgroupOf D.lattice).Normal ∧ (Λ.subgroupOf D.lattice).FiniteIndex ∧ + (Λ.relIndex D.lattice : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid N), + (D.withLattice Λ N hN hin hout).GeometryComplexityLE ((p + C) ^ C) ∧ + Λ ≤ E.lattice.comap (mapOfSteps (hL := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ) := by + let X : Polynomial ℕ := Polynomial.X + let R := X + (X + 2) ^ 3 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (R + 2 * R ^ 2 + (R + 2) ^ 2) + refine ⟨C, hC, ?_⟩ + intro L M _ _ _ _ s t d e D E φ p hp hD hE hφ + classical + let A := LinearMap.toMatrix D.basis E.basis φ.toLinearMap + have hAb : (matrixDenominator A : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + apply matrixDenominator_le_exp_power A hp 1 + (by simpa only [Fintype.card_fin] using hE.1) + (by simpa only [Fintype.card_fin] using hD.1) + intro i j + have h := ((rationalLogHeight_le_iff _ p).mp (hφ i j)).2 + dsimp only [A] + rw [LinearMap.toMatrix_apply] + exact h.trans (Real.exp_le_exp.mpr (by simp only [pow_one]; linarith)) + let N₀ := E.grid * matrixDenominator A + let Λ₀ := E.lattice.comap (mapOfSteps (hL := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ) + have hN₀ : 0 < N₀ := Nat.mul_pos E.grid_pos (matrixDenominator_pos A) + have hgrid : scaledIntegerGrid N₀ ⊆ bchSubgroupCoordinates D.basis Λ₀ := by + rw [bchSubgroupCoordinates_comap_ofSteps + (hL := D.filtration.lowerCentralSeries_eq_bot) D.basis E.basis φ E.lattice] + intro x hx + exact E.inner_grid (matrix_mulVec_fine_grid A E.grid hx) + let r := p + (p + 2) ^ 3 + have hpr : p ≤ r := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have hr : 0 ≤ r := hp.trans hpr + have hN₀b : (N₀ : ℝ) ≤ Real.exp r := by + rw [show (N₀ : ℝ) = (E.grid : ℝ) * matrixDenominator A by exact Nat.cast_mul _ _] + exact (mul_le_mul hE.2.1 hAb (Nat.cast_nonneg _) (Real.exp_pos _).le).trans_eq + (Real.exp_add _ _).symm + obtain ⟨Λ, htarget, hΛ, hchar, hnormal, hfinite, hindex, N, hN, hNb, hin, hout⟩ := + D.filtration.exists_normal_cover_exp_quadratic D.basis D.lattice Λ₀ + D.grid N₀ D.grid_pos hN₀ D.inner_grid D.outer_grid hgrid hr + (by simpa only [Fintype.card_fin] using hD.1.trans hpr) + (hD.2.1.trans (Real.exp_le_exp.mpr hpr)) hN₀b + have htotal : r + 2 * r ^ 2 + (r + 2) ^ 2 ≤ (p + C) ^ C := by + simpa [X, R, r, Polynomial.eval₂_pow] using hbudget p hp + have hrC : r ≤ (p + C) ^ C := by nlinarith [sq_nonneg r, sq_nonneg (r + 2)] + have hiC : 2 * r ^ 2 ≤ (p + C) ^ C := by nlinarith [sq_nonneg (r + 2)] + have hgC : (r + 2) ^ 2 ≤ (p + C) ^ C := by nlinarith [sq_nonneg r] + exact ⟨Λ, hΛ, hchar, hnormal, hfinite, hindex.trans (Real.exp_le_exp.mpr hiC), + N, hN, hin, hout, + D.withLattice_geometry Λ N hN hin hout hD (hpr.trans hrC) + (hNb.trans (Real.exp_le_exp.mpr hgC)), htarget⟩ + +end RationalFilteredNilmanifold +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SpatialAffineFullMass.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SpatialAffineFullMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6742c0b39dec8072f43b658c26dccad67e6e8ef --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SpatialAffineFullMass.lean @@ -0,0 +1,363 @@ +import OAI.Combinatorics.Progressions.Estimates.PreparedLayerFreezing +import OAI.Combinatorics.Progressions.Estimates.VectorRealSubstitutionBound +import OAI.Combinatorics.Progressions.Polynomial.PreparedPolynomialPullback + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {K X R : Type*} [Fintype K] [CommRing R] [Nontrivial R] + +noncomputable def affineFramePolynomial (frame : Option K → X → R) (i : X) : MvPolynomial K R := + MvPolynomial.C (frame none i) + ∑ k, MvPolynomial.C (frame (some k) i) * MvPolynomial.X k + +theorem affineFramePolynomial_degree (frame : Option K → X → R) (i : X) : + (affineFramePolynomial frame i).totalDegree ≤ 1 := by + apply (MvPolynomial.totalDegree_add _ _).trans + apply max_le (by simp) + apply MvPolynomial.totalDegree_finsetSum_le + intro k _ + exact (MvPolynomial.totalDegree_mul _ _).trans (by + simp only [MvPolynomial.totalDegree_C, MvPolynomial.totalDegree_X, zero_add, le_refl]) + +theorem affineFramePolynomial_support (frame : Option K → X → R) (i : X) : + affineFramePolynomial frame i ∈ weightedSupportLE (fun _ : K => 1) 1 := by + apply (mem_weightedSupportLE_iff _ _ _).mpr + change (affineFramePolynomial frame i).weightedTotalDegree 1 ≤ 1 + rw [MvPolynomial.weightedTotalDegree_one] + exact affineFramePolynomial_degree frame i + +omit [Nontrivial R] in +@[simp] theorem affineFramePolynomial_eval (frame : Option K → X → R) (y : K → R) (i : X) : + MvPolynomial.aeval y (affineFramePolynomial frame i) = + frame none i + ∑ k, frame (some k) i * y k := by + simp [affineFramePolynomial] + +omit [Nontrivial R] in +theorem affineFramePolynomial_map {S : Type*} [CommRing S] [Nontrivial S] (φ : R →+* S) + (frame : Option K → X → R) (i : X) : + MvPolynomial.map φ (affineFramePolynomial frame i) = + affineFramePolynomial (fun k i => φ (frame k i)) i := by + simp [affineFramePolynomial] + +end Erdos3 + +end + +section + +namespace Erdos3.PolynomialPatch.LowestLayerModel + +open VectorPolynomial MvPolynomial +open scoped BigOperators TensorProduct + +variable {X K : Type} [Fintype K] {s D E m : ℕ} {A : PolynomialPatch X s (D + E)} + +theorem exists_freeze_prepared_affine (F : A.LowestLayerModel m) + (L : RankPreparationFamily X (Fin D) m) + (ip : Fin D → MvPolynomial X ℤ) (hip : ∀ i, (ip i).totalDegree ≤ m) + (c : Fin D → ℝ) (err : VectorPolynomial X ℝ (Fin D → ℝ)) + (hprepare : VectorPolynomial.ofCoordinates (Pi.basisFun ℝ (Fin D)) F.normalizedOrigin = + L.polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + err) + (frame : Option K → X → ℤ) + (β : ∀ u, (L u).Coord → MvPolynomial K ℤ) + (hβ : ∀ u i, (β u i).totalDegree ≤ u.val + 1) + (center : ∀ u, (L u).Coord → ℝ) (ε : Fin m → ℝ) (hε : ∀ u, 0 ≤ ε u) + {δ : ℝ} (hδ : 0 ≤ δ) (Ω : Set (K → ℝ)) + (hinteger : ∀ x ∈ Ω, ∃ z : K → ℤ, x = fun i => (z i : ℝ)) + (hsmall : ∀ x ∈ Ω, ∀ u i, + |VectorPolynomial.eval (fun v => (frame none v : ℝ) + ∑ k, (frame (some k) v : ℝ) * x k) + (L u).poly i - center u i - + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β u i))| ≤ ε u) + (herr : ∀ x ∈ Ω, ∀ i, + |VectorPolynomial.eval (fun v => (frame none v : ℝ) + ∑ k, (frame (some k) v : ℝ) * x k) + err i| ≤ δ) + (x₀ : K → ℝ) (hx₀ : x₀ ∈ Ω) (bref : Fin (D + E) → ℤ) + (href : A.kernel.value ((A.form.slots + (fun v => (frame none v : ℝ) + ∑ k, (frame (some k) v : ℝ) * x₀ k)).residual bref) ≠ 0) + (hbudget : (D : ℝ) * (2 * ((∑ u, (Fintype.card (L u).Coord : ℝ) * ε u) + δ)) < 1 / 12) : + ∃ A' : PolynomialPatch K s E, + A'.kernel.lip = A.kernel.lip ∧ + (∀ i, A'.weight i = A.weight (i.natAdd D)) ∧ + ∀ x ∈ Ω, dist (A.value + (fun v => (frame none v : ℝ) + ∑ k, (frame (some k) v : ℝ) * x k)) (A'.value x) ≤ + A.kernel.lip * ((D : ℝ) * (2 * ((∑ u, (Fintype.card (L u).Coord : ℝ) * ε u) + δ))) := by + let fi := affineFramePolynomial frame + let f := affineFramePolynomial (fun k v => (frame k v : ℝ)) + have hf : ∀ v, f v ∈ weightedSupportLE (fun _ : K => 1) 1 := + affineFramePolynomial_support _ + have hmap : (fun v => MvPolynomial.map (Int.castRingHom ℝ) (fi v)) = f := + funext (affineFramePolynomial_map (Int.castRingHom ℝ) frame) + let L' := L.pullback f + let ip' := fun i => MvPolynomial.aeval fi (ip i) + have hip' : ∀ i, (ip' i).totalDegree ≤ m := by + intro i + exact (aeval_polynomial_totalDegree_le (ip i) fi (hip i) (affineFramePolynomial_degree frame)).trans_eq + (Nat.mul_one m) + have hpull : VectorPolynomial.ofCoordinates (Pi.basisFun ℝ (Fin D)) (F.reparam f hf).normalizedOrigin = + L'.polynomial + integerCoordinates ip' + (1 ⊗ₜ[ℝ] c) + substitute f err := by + have he := L.pullback_identity + (VectorPolynomial.ofCoordinates (Pi.basisFun ℝ (Fin D)) F.normalizedOrigin) err ip c hprepare fi + dsimp only at he + rw [hmap, substitute_ofCoordinates] at he + have hn : (F.reparam f hf).normalizedOrigin = + fun i => MvPolynomial.aeval f (F.normalizedOrigin i) := + funext (reparam_normalizedOrigin F f hf) + rw [hn] + exact he + have href' : (A.reparam f hf).kernel.value + (((A.reparam f hf).form.slots x₀).residual bref) ≠ 0 := by + change A.kernel.value (((A.form.reparam f hf).slots x₀).residual bref) ≠ 0 + rw [PolynomialSlots.reparam_slots] + simpa only [f, affineFramePolynomial_eval] using href + obtain ⟨A', hLip, hweight, hval⟩ := (F.reparam f hf).exists_freeze_prepared L' ip' hip' c + (substitute f err) hpull β hβ center ε hε hδ Ω hinteger + (by + intro x hx u i + change |VectorPolynomial.eval x (substitute f (L u).poly) i - center u i - + MvPolynomial.eval x (MvPolynomial.map (Int.castRingHom ℝ) (β u i))| ≤ ε u + rw [eval_substitute] + simpa only [f, affineFramePolynomial_eval] using hsmall x hx u i) + (by simpa only [eval_substitute, f, affineFramePolynomial_eval] using herr) + x₀ hx₀ bref href' hbudget + refine ⟨A', hLip, hweight, ?_⟩ + intro x hx + have hv := hval x hx + rw [PolynomialPatch.reparam_value] at hv + change dist (A.value (fun v => MvPolynomial.aeval x (f v))) (A'.value x) ≤ + A.kernel.lip * ((D : ℝ) * (2 * ((∑ u, (Fintype.card (L u).Coord : ℝ) * ε u) + δ))) at hv + simpa only [f, affineFramePolynomial_eval] using hv + +end Erdos3.PolynomialPatch.LowestLayerModel + +end + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct +open VectorPolynomial + +namespace RankPreparationLayer + +variable {I J K : Type} + +theorem pullback_value [DecidableEq J] (L : RankPreparationLayer I J) + (f : I → MvPolynomial K ℝ) (x : K → ℝ) : + (L.pullback f).value x = L.value (fun i => MvPolynomial.aeval (R := ℝ) x (f i)) := + congrArg (coordinateCopySum L.label) (eval_substitute f x L.poly) + +end RankPreparationLayer + +namespace RankPreparationFamily + +variable {I J K : Type} {s : ℕ} + +@[simp] theorem pullback_potential (L : RankPreparationFamily I J s) + (f : I → MvPolynomial K ℝ) : (L.pullback f).potential = L.potential := rfl + +theorem pullback_value [DecidableEq J] (L : RankPreparationFamily I J s) + (f : I → MvPolynomial K ℝ) (x : K → ℝ) : + (L.pullback f).value x = L.value (fun i => MvPolynomial.aeval (R := ℝ) x (f i)) := by + apply Finset.sum_congr rfl + intro i _ + exact (L i).pullback_value f x + +theorem Sized.pullback {L : RankPreparationFamily I J s} {D t : ℕ} + (h : L.Sized D t) (f : I → MvPolynomial K ℝ) : (L.pullback f).Sized D t := h + +theorem PreparedHeights.pullback {L : RankPreparationFamily I J s} {p : ℝ} {R : ℕ} + (hL : L.PreparedHeights p R) (f : I → MvPolynomial K ℝ) + (hf : ∀ i, (f i).totalDegree ≤ 1) : (L.pullback f).PreparedHeights p R := + fun i => (hL i).pullback f hf + +end RankPreparationFamily + +theorem prepared_polynomial_identity_pullback {I J K : Type} [Fintype J] [DecidableEq J] + {s : ℕ} (P : VectorPolynomial I ℝ (J → ℝ)) (L : RankPreparationFamily I J s) + (ip : J → MvPolynomial I ℤ) (c : J → ℝ) (E : VectorPolynomial I ℝ (J → ℝ)) + (hid : P = L.polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + E) + (f : I → MvPolynomial K ℝ) : + substitute f P = (L.pullback f).polynomial + substitute f (integerCoordinates ip) + + (1 ⊗ₜ[ℝ] c) + substitute f E := by + rw [hid, map_add, map_add, map_add, substitute_tmul, map_one, + RankPreparationFamily.pullback_polynomial] + +theorem affineFramePolynomial_eq_parameter {I K : Type*} [Fintype K] + (frame : Option K → I → ℝ) : + affineFramePolynomial frame = affineParameterSubstitution frame := by + funext i + rfl + +theorem integer_affineFramePolynomial_map {I K : Type*} [Fintype K] + (frame : Option K → I → ℤ) : + (fun i => MvPolynomial.map (Int.castRingHom ℝ) (affineFramePolynomial frame i)) = + affineParameterSubstitution (fun k i => (frame k i : ℝ)) := by + funext i + exact affineFramePolynomial_map (Int.castRingHom ℝ) frame i + +theorem integer_affineFramePolynomial_aeval_degree {I K : Type*} [Fintype K] + (frame : Option K → I → ℤ) (p : MvPolynomial I ℤ) {d : ℕ} + (hp : p.totalDegree ≤ d) : + (MvPolynomial.aeval (affineFramePolynomial frame) p).totalDegree ≤ d := by + exact (aeval_polynomial_totalDegree_le p (affineFramePolynomial frame) hp + (affineFramePolynomial_degree frame)).trans_eq (Nat.mul_one d) + +theorem RankPreparationFamily.pullback_affine_identity {I J K : Type} + [Fintype J] [DecidableEq J] [Fintype K] {s : ℕ} + (L : RankPreparationFamily I J s) (P E : VectorPolynomial I ℝ (J → ℝ)) + (ip : J → MvPolynomial I ℤ) (c : J → ℝ) + (hid : P = L.polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + E) + (frame : Option K → I → ℤ) : + let f := affineParameterSubstitution (fun k i => (frame k i : ℝ)) + substitute f P = (L.pullback f).polynomial + + integerCoordinates (fun j => MvPolynomial.aeval (affineFramePolynomial frame) (ip j)) + + (1 ⊗ₜ[ℝ] c) + substitute f E := by + dsimp only + have h := L.pullback_identity P E ip c hid (affineFramePolynomial frame) + dsimp only at h + rw [integer_affineFramePolynomial_map] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators + +variable {K X : Type*} [Fintype K] + +theorem affineFramePolynomial_top_one (frame : Option K → X → ℝ) (x : X) : + homogeneousComponent 1 (affineFramePolynomial frame x) = + ∑ k, C (frame (some k) x) * MvPolynomial.X k := by + rw [affineFramePolynomial, map_add, + homogeneousComponent_eq_zero 1 (C (frame none x)) (by simp), zero_add, + map_sum] + apply Finset.sum_congr rfl + intro k _ + rw [homogeneousComponent_C_mul, + homogeneousComponent_eq_self (isHomogeneous_X ℝ k)] + +theorem scaleMvPolynomialAxes_affineFrame_top_one + (frame : Option K → X → ℝ) (T : K → ℝ) (x : X) : + scaleMvPolynomialAxes T (homogeneousComponent 1 (affineFramePolynomial frame x)) = + ∑ k, C (frame (some k) x * T k) * MvPolynomial.X k := by + apply MvPolynomial.funext + intro y + rw [scaleMvPolynomialAxes_eval, affineFramePolynomial_top_one] + simp only [eval_sum, map_mul, eval_C, eval_X] + apply Finset.sum_congr rfl + intro k _ + ring + +theorem scaleMvPolynomialAxes_C_mul {ι : Type*} + (T : ι → ℝ) (c : ℝ) (p : MvPolynomial ι ℝ) : + scaleMvPolynomialAxes T (C c * p) = C c * scaleMvPolynomialAxes T p := by + apply MvPolynomial.funext + intro y + simp only [scaleMvPolynomialAxes_eval, map_mul, eval_C] + +theorem spatialAffineTop_mass_le + (frame : Option K → X → ℝ) (T : K → ℝ) (hT : ∀ k, 0 ≤ T k) (x : X) : + realPolynomialMass + (scaleMvPolynomialAxes T (homogeneousComponent 1 (affineFramePolynomial frame x))) ≤ + ∑ k, |frame (some k) x| * T k := by + rw [scaleMvPolynomialAxes_affineFrame_top_one] + apply (realPolynomialMass_sum_le _ _).trans + apply Finset.sum_le_sum + intro k _ + have h := realPolynomialMass_C_mul_le (frame (some k) x * T k) (MvPolynomial.X k) + simpa only [realPolynomialMass_X, mul_one, abs_mul, abs_of_nonneg (hT k)] using h + +theorem spatialAffineTop_inv_mul_mass_le + (frame : Option K → X → ℝ) (T : K → ℝ) (hT : ∀ k, 0 ≤ T k) + (x : X) (N : ℝ) (hN : 0 < N) : + realPolynomialMass (C N⁻¹ * + scaleMvPolynomialAxes T (homogeneousComponent 1 (affineFramePolynomial frame x))) ≤ + N⁻¹ * ∑ k, |frame (some k) x| * T k := by + apply (realPolynomialMass_C_mul_le _ _).trans + rw [abs_of_pos (inv_pos.mpr hN)] + exact mul_le_mul_of_nonneg_left (spatialAffineTop_mass_le frame T hT x) + (inv_nonneg.mpr hN.le) + +theorem spatialAffineTop_scaled_inv_mul_mass_le + (frame : Option K → X → ℝ) (T : K → ℝ) (hT : ∀ k, 0 ≤ T k) + (x : X) (N : ℝ) (hN : 0 < N) : + realPolynomialMass (scaleMvPolynomialAxes T + (C N⁻¹ * homogeneousComponent 1 (affineFramePolynomial frame x))) ≤ + N⁻¹ * ∑ k, |frame (some k) x| * T k := by + rw [scaleMvPolynomialAxes_C_mul] + exact spatialAffineTop_inv_mul_mass_le frame T hT x N hN + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators + +variable {K X : Type*} [Fintype K] + +theorem scaleMvPolynomialAxes_affineFrame_eq_const_add_top + (frame : Option K → X → ℝ) (T : K → ℝ) (x : X) : + scaleMvPolynomialAxes T (affineFramePolynomial frame x) = + C (frame none x) + + scaleMvPolynomialAxes T + (homogeneousComponent 1 (affineFramePolynomial frame x)) := by + apply MvPolynomial.funext + intro y + rw [affineFramePolynomial_top_one] + simp only [scaleMvPolynomialAxes_eval, affineFramePolynomial, + map_add, eval_C, eval_sum, map_mul, eval_X] + +theorem spatialAffineFull_mass_le + (frame : Option K → X → ℝ) (T : K → ℝ) (hT : ∀ k, 0 ≤ T k) (x : X) : + realPolynomialMass (scaleMvPolynomialAxes T (affineFramePolynomial frame x)) ≤ + |frame none x| + ∑ k, |frame (some k) x| * T k := by + rw [scaleMvPolynomialAxes_affineFrame_eq_const_add_top] + exact (realPolynomialMass_add_le _ _).trans + (add_le_add (le_of_eq (realPolynomialMass_C _)) + (spatialAffineTop_mass_le frame T hT x)) + +theorem spatialAffineFull_inv_mul_mass_le + (frame : Option K → X → ℝ) (T : K → ℝ) (hT : ∀ k, 0 ≤ T k) + (x : X) (N : ℝ) (hN : 0 < N) : + realPolynomialMass (C N⁻¹ * + scaleMvPolynomialAxes T (affineFramePolynomial frame x)) ≤ + |frame none x| / N + N⁻¹ * ∑ k, |frame (some k) x| * T k := by + apply (realPolynomialMass_C_mul_le _ _).trans + rw [abs_of_pos (inv_pos.mpr hN)] + calc + _ ≤ N⁻¹ * (|frame none x| + ∑ k, |frame (some k) x| * T k) := + mul_le_mul_of_nonneg_left (spatialAffineFull_mass_le frame T hT x) + (inv_nonneg.mpr hN.le) + _ = _ := by ring + +theorem spatialAffineFull_scaled_inv_mul_mass_le + (frame : Option K → X → ℝ) (T : K → ℝ) (hT : ∀ k, 0 ≤ T k) + (x : X) (N : ℝ) (hN : 0 < N) : + realPolynomialMass (scaleMvPolynomialAxes T + (C N⁻¹ * affineFramePolynomial frame x)) ≤ + |frame none x| / N + N⁻¹ * ∑ k, |frame (some k) x| * T k := by + rw [scaleMvPolynomialAxes_C_mul] + exact spatialAffineFull_inv_mul_mass_le frame T hT x N hN + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SpatialResidueMass.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SpatialResidueMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ffc98da92b7b4d1c1ce7f1f8a4796aa8792116f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SpatialResidueMass.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.Progressions.Geometry.PrincipalSpatialSiteComparison +import OAI.Combinatorics.Progressions.Geometry.SupportedMeanBounds + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem residueSpatialSite_norm_le {D I J N : Type*} + [Fintype D] [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] + (A : Matrix (Unit ⊕ I) (Unit ⊕ I) ℤ) (B : Matrix (Unit ⊕ I) J ℤ) + (m : ℕ) [NeZero m] + (hp : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ pivotFullImage A B) + (f : D → ((Unit ⊕ I) → ℝ) → ℝ) (H : D → ℝ) + {b r C : ℝ} (hb : 0 < b) (hr : 0 < r) (_hC : 0 ≤ C) (hf : ∀ d y, |f d y| ≤ C) + (residue : D → Matrix (Unit ⊕ I) N (ZMod m)) (v : D → (Unit ⊕ I) → ℤ) + (hv : ∀ d i, |((spatialStar (v d) i : ℤ) : ℝ)/H d| ≤ b) : + ‖∏ d, spatialSiteApprox A (Matrix.fromCols B (liftResidueMatrix (residue d))) m (f d) (H d) b r (v d)‖ ≤ + ((m : ℝ)^Fintype.card (Unit ⊕ I)*C)^Fintype.card D := by + have hfull (d : D) : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ + pivotFullImage A (Matrix.fromCols B (liftResidueMatrix (residue d))) := by + rw [pivotFullImage_split] + exact hp.trans le_sup_left + have hi (d : D) : + ((pivotFullImage A (Matrix.fromCols B (liftResidueMatrix (residue d)))).toAddSubgroup.index : ℝ) ≤ + (m : ℝ)^Fintype.card (Unit ⊕ I) := by + exact_mod_cast residueLatticeImage_index_le _ m (hfull d) + calc + _ ≤ ∏ d, ‖spatialSiteApprox A (Matrix.fromCols B (liftResidueMatrix (residue d))) m (f d) (H d) b r (v d)‖ := + (norm_prod _ _).le + _ ≤ ∏ _d : D, (m : ℝ)^Fintype.card (Unit ⊕ I)*C := + Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun d _ => + spatialSiteApprox_norm_le A _ m (f d) (H d) hb hr (hi d) (hf d) (v d) (hv d)) + _ = _ := by simp + +theorem residueSpatialSite_mean_norm_le {R V D I J N : Type*} + [Fintype R] [Fintype D] [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] + (p : FiniteProbabilityWeights R) (t : Finset V) (out : V → D → (Unit ⊕ I) → ℤ) + (A : Matrix (Unit ⊕ I) (Unit ⊕ I) ℤ) (B : Matrix (Unit ⊕ I) J ℤ) + (m : ℕ) [NeZero m] + (hp : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ pivotFullImage A B) + (f : D → ((Unit ⊕ I) → ℝ) → ℝ) (H : D → ℝ) + {b r C : ℝ} (hb : 0 < b) (hr : 0 < r) (hC : 0 ≤ C) (hf : ∀ d y, |f d y| ≤ C) + (residue : R → D → Matrix (Unit ⊕ I) N (ZMod m)) + (hv : ∀ v ∈ t, ∀ d i, |((spatialStar (out v d) i : ℤ) : ℝ)/H d| ≤ b) : + p.mean (fun a => 𝔼 v ∈ t, + ‖∏ d, spatialSiteApprox A (Matrix.fromCols B (liftResidueMatrix (residue a d))) + m (f d) (H d) b r (out v d)‖) ≤ ((m : ℝ)^Fintype.card (Unit ⊕ I)*C)^Fintype.card D := by + apply finiteMean_le_of_support + intro a _ + apply finite_expect_le_of_nonneg_bound t _ (by positivity) + intro v hvt + exact residueSpatialSite_norm_le A B m hp f H hb hr hC hf (residue a) (out v) (hv v hvt) + +theorem smoothSpatialSite_mean_norm_le {R V D I J N : Type*} + [Fintype R] [Fintype D] [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + [Fintype N] {L M : ℕ} (s : I ↪ J) (x : J → IntegerScalarCubeBox I L) (root : J → ℤ) + (hM : 0 < M) (hL : 0 < L) (hx : GoodScalarKernelTuple s (1/(M : ℝ)) M x) + (hroot : ∀ j, |root j| ≤ (L : ℤ)) (m : ℕ) [NeZero m] + (hp : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s)) + (H : D → ℝ) (hH : ∀ d, 0 < H d) {b r : ℝ} (hb : 0 < b) (hr : 0 < r) + (p : FiniteProbabilityWeights R) (t : Finset V) (out : V → D → (Unit ⊕ I) → ℤ) + (residue : R → D → Matrix (Unit ⊕ I) N (ZMod m)) + (hv : ∀ v ∈ t, ∀ d i, |((spatialStar (out v d) i : ℤ) : ℝ)/H d| ≤ b) : + let A := selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s + let B := selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s + let hA := goodScalarKernelTuple_spatial_det_ne_zero s x root + (one_div_pos.mpr (by exact_mod_cast hM)) hx + let f := fun d => smoothSpatialKernelDensity s root (scalarCubeDifferenceMatrix x) hA + (H d) L (hH d) (by exact_mod_cast hL) + p.mean (fun a => 𝔼 v ∈ t, + ‖∏ d, spatialSiteApprox A (Matrix.fromCols B (liftResidueMatrix (residue a d))) + m (f d) (H d) b r (out v d)‖) ≤ + ((m : ℝ)^Fintype.card (Unit ⊕ I)*smoothSpatialDensityCap s M)^Fintype.card D := by + dsimp only + exact residueSpatialSite_mean_norm_le p t out _ _ m hp _ H hb hr + (smoothSpatialDensityCap_nonneg s M) + (fun d => (smoothSpatialKernelDensity_bounds s x root hM hL (hH d) hx hroot).1) residue hv + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SpatialSiteResidueIdentity.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SpatialSiteResidueIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec352a33d2e3b511a02bbfd4b6d9cfa914a4df5e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SpatialSiteResidueIdentity.lean @@ -0,0 +1,25 @@ +import OAI.Combinatorics.Progressions.Geometry.SpatialSiteShift + +namespace OAI + +section + +namespace Erdos3 + +theorem spatialSiteApprox_eq_residue {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype N] + (A : Matrix (Unit ⊕ I) (Unit ⊕ I) ℤ) (B : Matrix (Unit ⊕ I) J ℤ) + (C : Matrix (Unit ⊕ I) N ℤ) (m : ℕ) [NeZero m] + (hp : integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ pivotFullImage A B) + (f : ((Unit ⊕ I) → ℝ) → ℝ) (H b r : ℝ) : + spatialSiteApprox A (Matrix.fromCols B C) m f H b r = + spatialSiteApprox A (Matrix.fromCols B (liftResidueMatrix (integerResidueMatrix C m))) m f H b r := by + funext v + unfold spatialSiteApprox + rw [pivotFullImage_eq_of_kernel_residues A B C _ m hp (by rw [liftResidueMatrix_residue])] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/StablePrimeUpperComparison.lean b/lean/OAI/Combinatorics/Progressions/Lattices/StablePrimeUpperComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f7a192b19d9e48acce95f85fafeb284322909ec --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/StablePrimeUpperComparison.lean @@ -0,0 +1,45 @@ +import OAI.Combinatorics.Progressions.Lattices.ResidueSliceUpperFailure + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def PrimeRefinementUpperBound {ι σ : Type*} [DecidableEq ι] [Fintype σ] [DecidableEq σ] + (h g : (σ → ℤ) → ℂ) (lo : σ → ℤ) (N : σ → ℕ) (M : ℕ) (a : σ → ℤ) (q : ι → ℕ) + (r : ℕ) (level ε δ : ℝ) (I : Finset ι) (x : ∀ i, σ → ZMod (q i)) : Prop := + ∀ J : Finset ι, Disjoint I J → J.card ≤ r → ∀ y : ∀ i, σ → ZMod (q i), + (∀ i ∈ I, y i = x i) → Nonempty (ResiduePrimeCoordinateCell lo N M a q (I ∪ J) y) → + (residuePrimeCoordinateMean h lo N M a q (I ∪ J) y).re ≤ + level * (residuePrimeCoordinateMean g lo N M a q I x).re + ε + level * δ + +theorem CoordinateDecisionTree.Valid.with_slice_upper_comparison {ι σ : Type*} + [DecidableEq ι] [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {parent lo a : σ → ℤ} {H N : σ → ℕ} {M : ℕ} {q : ι → ℕ} + {r : ℕ} {δ P level ε : ℝ} {mandatory I : Finset ι} {x : ∀ i, σ → ZMod (q i)} + {tree : CoordinateDecisionTree ι (fun i => σ → ZMod (q i))} {d : ℕ} + (htree : CoordinateDecisionTree.Valid + (fun A z => mandatory ⊆ A ∧ ResiduePrimeCoordinateStable g lo N M a q r δ A z ∧ + ∀ J : Finset ι, J.card ≤ r → ∀ u : σ → ℤ, + ResidueSliceLogCostLE H lo N (M.lcm (∏ i ∈ A ∪ J, q i)) u P) I x tree d) + (hupper : ResidueSliceUpperComparison h g parent H P level ε) + (hbox : PhysicalSubbox parent H lo N) (hM : 0 < M) (hqpos : ∀ i, 0 < q i) + (hcop : Pairwise (fun i j => (q i).Coprime (q j))) (hlevel : 0 ≤ level) : + CoordinateDecisionTree.Valid + (fun A z => mandatory ⊆ A ∧ ResiduePrimeCoordinateStable g lo N M a q r δ A z ∧ + PrimeRefinementUpperBound h g lo N M a q r level ε δ A z) I x tree d := by + apply htree.map + intro A z hz + refine ⟨hz.1, hz.2.1, ?_⟩ + intro J hAJ hJ y hzy hne + apply hz.2.1.refinement_upper_bound hlevel J hAJ hJ y hzy hne + exact hupper.on_prime_cell hbox M hM q hqpos hcop (A ∪ J) y (hz.2.2 J hJ) hne + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/StableResidueKernelTotal.lean b/lean/OAI/Combinatorics/Progressions/Lattices/StableResidueKernelTotal.lean new file mode 100644 index 0000000000000000000000000000000000000000..20cadd54edbf97be0d60655b56e8143a478d06e1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/StableResidueKernelTotal.lean @@ -0,0 +1,128 @@ +import OAI.Combinatorics.Progressions.Dynamics.CylinderShellCountBudget +import OAI.Combinatorics.Progressions.Estimates.CylinderUniformSections +import OAI.Combinatorics.Progressions.Estimates.StableSiteSectionLengths +import OAI.Combinatorics.Progressions.Linear.KernelCylinderTotal + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem stable_residue_kernel_total {Ω ι σ : Type*} + [Fintype Ω] + [Fintype ι] [LinearOrder ι] [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} + [∀ i, NeZero (q i)] {j r b moment : ℕ} {level inc δ η τ L T P : ℝ} {K : Finset ι} + {base : ∀ i, σ → ZMod (q i)} + {X : {i // i ∉ K} → Type*} [∀ i, Fintype (X i)] [∀ i, DecidableEq (X i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (p : FiniteProbabilityWeights Ω) + (F : Ω → ∀ i, X i) (sourceBase : ∀ i, X i) + (siteBase : ∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) + {regK κ ε ξ shell Q : ℝ} {w rem : Ω → ℝ} {cs : List (ProductCylinder X)} + (hchain : CylinderRemovalChain μ sourceBase p F regK τ j r w rem cs) + (hμ : ∀ i x, 0 < (μ i).weight x) (hregK : 1 ≤ regK) + (hw : ∀ z, 0 ≤ w z ∧ w z ≤ 1) (hrem : ∀ z, 0 ≤ rem z ∧ rem z ≤ 1) (hmass : p.mean rem ≤ τ) + (hstable : ResiduePrimeCoordinateStable g lo N M a q (j + r) δ K base) + (hupper : PrimeRefinementUpperBound h g lo N M a q (j + r) level inc δ K base) + (hM : 0 < M) (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (hcop : ∀ i ∉ K, M.Coprime (q i)) (u : ResiduePrimeCoordinateCell lo N M a q K base) + (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + (hlevel : 0 < level) (hτ : 0 < τ) (hδ : δ ≤ τ / 8) (hinc : inc ≤ level * τ / 8) + (hη0 : 0 ≤ η) (hη : η < 1) (hητ : η ≤ τ / 8) (hηlevel : η ≤ level * τ / 8) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hlower : Real.exp (-L) ≤ level) (hτinv : τ⁻¹ ≤ Real.exp T) + (hlog : L + T + 2 ≤ P) (hrP : ((j + r : ℕ) : ℝ) ≤ P) + (hmoment : 2 ≤ moment) (heven : Even moment) (hPq : P ≤ (moment : ℝ)) (hqP : (moment : ℝ) ≤ P + 2) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hηsmall : η ≤ (1 / 2) * Real.exp (-((P + 3) ^ 3))) + (herror : ∀ S : Finset {i // i ∉ K}, S.card ≤ j + r → + 2 * (∑ k, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val)) ≤ η) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) (fun k => (u.val k).val) + (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) (fun _ => 1)) η + (max ((j + r) * (moment + 1)) (2 * b + j))) + (hgram : 2 * η * ((lowDegreeCoordinateSets {i // i ∉ K} b).card : ℝ) ^ 2 * + (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ 1) + (hsourceclose : ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η + (max ((j + r) * (moment + 1)) (2 * b + j))) + (hresGram : 2 * η * ((lowDegreeCoordinateSets {i // i ∉ K} b).card : ℝ) ^ 2 * + (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ τ) + (kernel : ∀ i : {i // i ∉ K}, X i → FiniteProbabilityWeights (σ → ZMod (q i.val))) + (C : {i // i ∉ K} → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i : {i // i ∉ K}, ∀ f : (σ → ZMod (q i.val)) → ℝ, + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) i).mean f = 0 → + (μ i).mean (fun x => (kernel i x).mean f ^ 2) ≤ C i * + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) i).mean (fun y => f y ^ 2)) + (hK : ∀ i : {i // i ∉ K}, ∀ f : (σ → ZMod (q i.val)) → ℝ, (μ i).mean (fun x => (kernel i x).mean f) = + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) i).mean f) + (hε : 0 ≤ ε) (hξ : 0 < ξ) (hξ1 : ξ ≤ 1) (hslack : ξ * (2 + ε) ≤ ε) + (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hcap : ∀ i, C i ≤ κ ^ 2) + (hlow : κ * (8 * (1 + regK) * (P + 2)) ^ 2 * (16 * (P + 2)) ^ 2 ≤ ξ / 16) + (hrtail : CyclicCrootSisask.spectralIterations ξ (L + 2 * T + 4) ≤ r) (hrb : j + r ≤ b) + (hshell : 0 < shell) (hb : j + CyclicCrootSisask.spectralIterations shell Q ≤ b) + (hbudget : ((cs.zip (removedCylinderWeights F w cs)).map (fun cf => + (Fintype.card (∀ i : cf.1.1, σ → ZMod (q i.val.val)) : ℝ) * + (cf.1.mass μ sourceBase (observedProductDensity μ p F cf.2) * level * + ((residuePrimeCoordinateMean g lo N M a q K base).re + τ) * (6 + 2 * ε) * + (2 : ℝ) ^ cf.1.1.card * (3 * τ⁻¹) * (3 * Real.exp (L + T))))).sum ≤ Real.exp Q) : + let density := fun f => residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f + let ν := primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (kernel i) (hK i) + productTruncatedPairing c (lowDegreeCoordinateSets {i // i ∉ K} b) (observedProductDensity μ p F w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * τ + shell / 16 + Real.sqrt (3 * τ) * (3 + (1 + ε) * level * 3) := by + dsimp only + let ν := primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) + have hsite := stable_site_uniform_sections hstable hupper hM hpair hcop u hg hh hlevel hτ hδ hinc + hη0 hη hητ hηlevel hL hT hlower hτinv hlog hrP hmoment heven hPq hqP hcount hηsmall herror hclose hgram + have hv := residuePrimeCoordinateMean_re_nonneg g lo N M a q K base (fun z hz => (hg z hz).1) + have hP : 0 ≤ P := (Nat.cast_nonneg (j + r)).trans hrP + have hrP' : (r : ℝ) ≤ P := by + have h : (r : ℝ) ≤ ((j + r : ℕ) : ℝ) := by exact_mod_cast Nat.le_add_left r j + exact h.trans hrP + have hlog' : Real.log (2 + τ⁻¹) ≤ P := + (log_two_add_le_of_le_exp (inv_nonneg.mpr hτ.le) hT hτinv).trans (by linarith) + have houtside : (Fintype.card {i // i ∉ K} : ℝ) ≤ Real.exp P := + (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans hcount + have hsampleSmall := approxMoment_small_of_exponential (Fintype.card {i // i ∉ K}) r moment τ⁻¹ P + hP (inv_nonneg.mpr hτ.le) houtside (hτinv.trans (Real.exp_le_exp.mpr (by linarith))) hrP' hqP hηsmall + have horder : j + r * (moment + 1) ≤ (j + r) * (moment + 1) := by nlinarith + have hsample := hchain.uniform_section_bounds hμ hregK hτ hη0 hη.le hmoment heven hrP' hlog' hPq hqP + hsampleSmall (ProductMarginalsClose.mono μ hsourceclose + (max_le (horder.trans (le_max_left _ _)) (le_max_right _ _))) hgram hw + have hne := residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u + have hHnorm := residuePrimeDensity_norm_le_three lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) hne (fun i : {i // i ∉ K} => q i.val) (fun z => (h z).re) hh + hη0 hη.le (lowDegreeCoordinateSets {i // i ∉ K} b) + (fun S hS => (mem_lowDegreeCoordinateSets _ b S).mp hS) + (ProductMarginalsClose.mono ν hclose (by omega)) hgram + have hGnorm := residuePrimeDensity_norm_le_three lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) hne (fun i : {i // i ∉ K} => q i.val) (fun z => (g z).re) hg + hη0 hη.le (lowDegreeCoordinateSets {i // i ∉ K} b) + (fun S hS => (mem_lowDegreeCoordinateSets _ b S).mp hS) + (ProductMarginalsClose.mono ν hclose (by omega)) hgram + apply CylinderRemovalChain.kernel_total_pairing_le μ ν kernel C hC hbound hK hchain hμ siteBase + (fun z => (hw z).2) hrem hmass (by positivity) (by positivity) hv hτ hlevel hε hξ hξ1 hslack + hκ0 hκhalf hcap hlow (uniform_section_norm_product_le_exp hτ hτinv) hrtail hrb hη0 + (ProductMarginalsClose.mono μ hsourceclose (by omega)) hresGram + _ _ hHnorm hGnorm hshell hb hbudget + intro cf hcf + obtain ⟨hwl, hwn⟩ := hsample cf hcf + refine ⟨fun k _ hk => hwl k hk, hwn, ?_⟩ + intro z + obtain ⟨hHm, hGm, hhl, hgl, hhn, hgn⟩ := hsite cf.1.1 (hchain.removed_size_mass cf hcf).1 + (productSubtypePoint cf.1.1 z siteBase) + exact ⟨hHm, hGm, fun k _ hk => hhl k hk, fun k _ hk => hgl k hk, hhn, hgn⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/StandardLatticeCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Lattices/StandardLatticeCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ff52588cec1b4d1b2a3d21e440bda235eef440a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/StandardLatticeCoordinates.lean @@ -0,0 +1,402 @@ +import OAI.Combinatorics.Progressions.Estimates.IntegralOrthogonalSection +import OAI.Combinatorics.Progressions.Estimates.JointRationalSpaceGenerators +import OAI.Combinatorics.Progressions.Fourier.CommonCoveredSiteCharacter +import OAI.Combinatorics.Progressions.Lattices.EuclideanShortLatticeBasis + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule + +variable {J : Type*} [Fintype J] + +noncomputable def projectedIntegerLattice (W : Submodule ℝ (EuclideanSpace ℝ J)) : + Submodule ℤ Wᗮ := orthogonalLatticeImage (standardEuclideanLattice J) Wᗮ + +noncomputable def projectedIntegerGenerator (W : Submodule ℝ (EuclideanSpace ℝ J)) (i : J) : Wᗮ := + Wᗮ.orthogonalProjectionOnto (EuclideanSpace.basisFun J ℝ i) + +theorem projectedIntegerGenerator_mem (W : Submodule ℝ (EuclideanSpace ℝ J)) (i : J) : + projectedIntegerGenerator W i ∈ projectedIntegerLattice W := by + refine ⟨EuclideanSpace.basisFun J ℝ i, ?_, rfl⟩ + exact subset_span (Set.mem_range_self i) + +theorem projectedIntegerGenerator_norm_le (W : Submodule ℝ (EuclideanSpace ℝ J)) (i : J) : + ‖projectedIntegerGenerator W i‖ ≤ 1 := by + have h := Wᗮ.norm_orthogonalProjectionOnto_apply_le (EuclideanSpace.basisFun J ℝ i) + simpa only [projectedIntegerGenerator, OrthonormalBasis.norm_eq_one] using h + +theorem projectedIntegerGenerator_span (W : Submodule ℝ (EuclideanSpace ℝ J)) : + span ℝ (Set.range (projectedIntegerGenerator W)) = ⊤ := by + change span ℝ (Set.range (Wᗮ.orthogonalProjectionOnto.toLinearMap ∘ + (EuclideanSpace.basisFun J ℝ).toBasis)) = ⊤ + rw [Set.range_comp, ← Submodule.map_span, Basis.span_eq, Submodule.map_top] + apply LinearMap.range_eq_top.mpr + intro w + refine ⟨w.val, ?_⟩ + apply Subtype.ext + exact Wᗮ.starProjection_eq_self_iff.mpr w.property + +theorem projectedIntegerGenerator_integer_span (W : Submodule ℝ (EuclideanSpace ℝ J)) : + span ℤ (Set.range (projectedIntegerGenerator W)) = projectedIntegerLattice W := by + rw [projectedIntegerLattice, orthogonalLatticeImage, standardEuclideanLattice, + Submodule.map_span, ← Set.range_comp] + rfl + +theorem standardLatticeSection_full_of_integral_span (W : Submodule ℝ (EuclideanSpace ℝ J)) + (hspan : span ℝ {x : W | ∀ i, ∃ n : ℤ, x.val i = n} = ⊤) : + IsZLattice ℝ (latticeSection (standardEuclideanLattice J) W) := by + constructor + convert hspan using 1 + congr 1 + ext x + change (x.val ∈ standardEuclideanLattice J) ↔ _ + rw [mem_standardEuclideanLattice] + simp only [Set.mem_ofPred_eq, eq_comm] + +instance projectedIntegerLattice_discrete (W : Submodule ℝ (EuclideanSpace ℝ J)) + [IsZLattice ℝ (latticeSection (standardEuclideanLattice J) W)] : + DiscreteTopology (projectedIntegerLattice W) := by + let : IsZLattice ℝ (latticeSection (standardEuclideanLattice J) Wᗮ) := + latticeSection_orthogonal_full (standardEuclideanLattice J) + (by rw [standardEuclideanLattice_self_dual]) W + let : IsZLattice ℝ (latticeSection (euclideanDualLattice (standardEuclideanLattice J)) Wᗮ) := by + constructor + change span ℝ {x : Wᗮ | x.val ∈ euclideanDualLattice (standardEuclideanLattice J)} = ⊤ + rw [standardEuclideanLattice_self_dual] + exact IsZLattice.span_top (K := ℝ) (L := latticeSection (standardEuclideanLattice J) Wᗮ) + exact orthogonalLatticeImage_discrete (standardEuclideanLattice J) Wᗮ + +instance projectedIntegerLattice_full (W : Submodule ℝ (EuclideanSpace ℝ J)) + [IsZLattice ℝ (latticeSection (standardEuclideanLattice J) W)] : + IsZLattice ℝ (projectedIntegerLattice W) := by + let : DiscreteTopology (orthogonalLatticeImage (standardEuclideanLattice J) Wᗮ) := + projectedIntegerLattice_discrete W + exact orthogonalLatticeImage_full (standardEuclideanLattice J) Wᗮ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule MeasureTheory + +theorem standardEuclideanLattice_covolume (J : Type*) [Fintype J] : + ZLattice.covolume (standardEuclideanLattice J) = 1 := by + classical + let b := EuclideanSpace.basisFun J ℝ + have hg : Matrix.gram ℝ b.toBasis = 1 := + Matrix.gram_eq_one_iff_orthonormal.mpr b.orthonormal + have hs := zspan_covolume_sq_eq_det_gram_fintype b.toBasis + rw [hg, Matrix.det_one] at hs + have hp := ZLattice.covolume_pos (standardEuclideanLattice J) volume + change ZLattice.covolume (standardEuclideanLattice J) ^ 2 = 1 at hs + nlinarith + +theorem projectedIntegerLattice_covolume {J : Type*} [Fintype J] + (W : Submodule ℝ (EuclideanSpace ℝ J)) + [IsZLattice ℝ (latticeSection (standardEuclideanLattice J) W)] : + ZLattice.covolume (latticeSection (standardEuclideanLattice J) W) * + ZLattice.covolume (projectedIntegerLattice W) = 1 := by + have hW : Wᗮᗮ = W := W.orthogonal_orthogonal + let : DiscreteTopology (orthogonalLatticeImage (standardEuclideanLattice J) Wᗮ) := + projectedIntegerLattice_discrete W + let : IsZLattice ℝ (orthogonalLatticeImage (standardEuclideanLattice J) Wᗮ) := + projectedIntegerLattice_full W + let : IsZLattice ℝ (latticeSection (standardEuclideanLattice J) Wᗮᗮ) := + (congrArg (fun V : Submodule ℝ (EuclideanSpace ℝ J) => + IsZLattice ℝ (latticeSection (standardEuclideanLattice J) V)) hW).mpr inferInstance + have h := orthogonalLattice_covolume (standardEuclideanLattice J) Wᗮ + have hc := congrArg (fun V : Submodule ℝ (EuclideanSpace ℝ J) => + ZLattice.covolume (latticeSection (standardEuclideanLattice J) V)) hW + rw [hc, standardEuclideanLattice_covolume] at h + exact h.symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule +open scoped Matrix NNReal + +variable {J R I : Type*} [Fintype J] [Fintype R] + +noncomputable def rationalKernelAxisBound (Q : Matrix R J ℚ) (H : ℕ) : ℝ := + (matrixDenominator Q : ℝ) * (((Fintype.card J : ℝ) + 1) * ((H : ℝ) + 1)) + +theorem projectedIntegerLattice_norm_inv_le_of_rational_kernel + (Q : Matrix R J ℚ) (W : Submodule ℝ (J → ℝ)) + (hW : LinearMap.ker (Matrix.mulVecLin (fun r j => (Q r j : ℝ))) = W) + {H : ℕ} (hQ : ∀ r j, RationalHeightLE (Q r j) H) + {z : (euclideanSubspace W)ᗮ} + (hz : z ∈ projectedIntegerLattice (euclideanSubspace W)) (hne : z ≠ 0) : + ‖z‖⁻¹ ≤ rationalKernelAxisBound Q H := by + classical + obtain ⟨x, hx, hxz⟩ := hz + change (euclideanSubspace W)ᗮ.orthogonalProjectionOnto x = z at hxz + let y : EuclideanSpace ℝ J := x - z.val + have hy : y ∈ euclideanSubspace W := by + have h := (euclideanSubspace W)ᗮ.sub_starProjection_mem_orthogonal x + rw [Submodule.orthogonal_orthogonal] at h + simpa only [Submodule.starProjection_apply, hxz] using h + have hQy : (fun r j => (Q r j : ℝ)) *ᵥ WithLp.ofLp y = 0 := by + change WithLp.ofLp y ∈ W at hy + rw [← hW] at hy + exact hy + have hxgrid : WithLp.ofLp x ∈ realDenominatorGrid 1 := by + choose a ha using (mem_standardEuclideanLattice J x).mp hx + refine ⟨a, ?_⟩ + ext j + simpa only [Pi.smul_apply, Nat.cast_one, one_smul] using ha j + have hQx : (fun r j => (Q r j : ℝ)) *ᵥ WithLp.ofLp x ≠ 0 := by + intro hzero + have hxW : x ∈ euclideanSubspace W := by + change WithLp.ofLp x ∈ W + rw [← hW] + exact hzero + have hproj : (euclideanSubspace W)ᗮ.orthogonalProjectionOnto x = 0 := + Submodule.orthogonalProjectionOnto_eq_zero_iff.mpr + ((euclideanSubspace W).le_orthogonal_orthogonal hxW) + exact hne (hxz.symm.trans hproj) + have hsep : 1 ≤ rationalKernelAxisBound Q H * + dist (WithLp.ofLp x) (WithLp.ofLp y) := by + by_contra! hsmall + apply hQx + apply rational_matrix_kernel_separation Q (H : ℝ≥0) + (fun r j => (hQ r j).abs_real_le) 1 (by decide) + (WithLp.ofLp x) (WithLp.ofLp y) hxgrid hQy + simpa only [Nat.mul_one, rationalKernelAxisBound, NNReal.coe_natCast] using hsmall + have hdist : dist (WithLp.ofLp x) (WithLp.ofLp y) ≤ ‖z‖ := by + rw [dist_eq_norm] + have he : WithLp.ofLp x - WithLp.ofLp y = WithLp.ofLp z.val := by + ext j + change x j - (x j - z.val j) = z.val j + ring + rw [he] + exact (pi_norm_le_iff_of_nonneg (norm_nonneg z)).mpr + (fun j => PiLp.norm_apply_le z.val j) + have hbound : 1 ≤ rationalKernelAxisBound Q H * ‖z‖ := + hsep.trans (mul_le_mul_of_nonneg_left hdist (by + unfold rationalKernelAxisBound + positivity)) + exact (inv_le_iff_one_le_mul₀ (norm_pos_iff.mpr hne)).mpr hbound + +theorem basisAxisScale_le_of_rational_kernel + (Q : Matrix R J ℚ) (W : Submodule ℝ (J → ℝ)) + (hW : LinearMap.ker (Matrix.mulVecLin (fun r j => (Q r j : ℝ))) = W) + {H : ℕ} (hQ : ∀ r j, RationalHeightLE (Q r j) H) + (b : Basis I ℝ (euclideanSubspace W)ᗮ) + (hb : span ℤ (Set.range b) = projectedIntegerLattice (euclideanSubspace W)) + (i : I) : + basisAxisScale b i ≤ ⌈rationalKernelAxisBound Q H⌉₊ := by + apply Nat.ceil_mono + apply projectedIntegerLattice_norm_inv_le_of_rational_kernel Q W hW hQ + · rw [← hb] + exact subset_span (Set.mem_range_self i) + · exact b.ne_zero i + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule +open scoped BigOperators Matrix + +theorem exists_bounded_integral_span_of_rational_range + {J C : Type*} [Fintype J] [Fintype C] + (B : Matrix J C ℚ) (W : Submodule ℝ (J → ℝ)) + (hW : LinearMap.range (Matrix.of (fun i j => (B i j : ℝ))).mulVecLin = W) + {H : ℕ} (hB : ∀ i j, RationalHeightLE (B i j) H) : + ∃ v : C → euclideanSubspace W, + span ℝ (Set.range v) = ⊤ ∧ + (∀ j, v j ∈ latticeSection (standardEuclideanLattice J) (euclideanSubspace W)) ∧ + ∀ j, ‖v j‖ ≤ (Fintype.card J : ℝ) * H ^ (Fintype.card J * Fintype.card C) := by + classical + obtain ⟨D, hD, _, z, hz, hzH⟩ := + exists_bounded_integer_array (fun ij : J × C => B ij.1 ij.2) (fun ij => hB ij.1 ij.2) + have hDr : (D : ℝ) ≠ 0 := by exact_mod_cast hD.ne' + have hzr (i : J) (j : C) : (z (i, j) : ℝ) = (D : ℝ) * (B i j : ℝ) := by + exact_mod_cast hz (i, j) + have hcol (j : C) : (fun i => (B i j : ℝ)) ∈ W := by + rw [← hW, Matrix.range_mulVecLin] + exact subset_span ⟨j, rfl⟩ + have hmem (j : C) : WithLp.toLp 2 (fun i => (z (i, j) : ℝ)) ∈ euclideanSubspace W := by + change (fun i => (z (i, j) : ℝ)) ∈ W + have he : (fun i => (z (i, j) : ℝ)) = (D : ℝ) • (fun i => (B i j : ℝ)) := + funext (fun i => hzr i j) + rw [he] + exact W.smul_mem (D : ℝ) (hcol j) + let v : C → euclideanSubspace W := fun j => ⟨WithLp.toLp 2 (fun i => (z (i, j) : ℝ)), hmem j⟩ + refine ⟨v, ?_, ?_, ?_⟩ + · apply top_unique + intro x _ + have hx : WithLp.ofLp x.val ∈ W := x.property + obtain ⟨y, hy⟩ := hW.ge hx + have heq : x = ∑ j, (y j / D) • v j := by + apply Subtype.ext + ext i + have hi := congrFun hy i + change (∑ j, (B i j : ℝ) * y j) = x.val i at hi + simp only [v, Submodule.coe_sum, Submodule.coe_smul, WithLp.ofLp_sum, + WithLp.ofLp_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + rw [← hi] + apply Finset.sum_congr rfl + intro j _ + rw [hzr] + field_simp + rw [heq] + exact sum_mem (fun j _ => smul_mem _ _ (subset_span ⟨j, rfl⟩)) + · intro j + change (v j).val ∈ standardEuclideanLattice J + exact (mem_standardEuclideanLattice J _).mpr (fun i => ⟨z (i, j), rfl⟩) + · intro j + calc + ‖v j‖ ≤ ∑ i, |(z (i, j) : ℝ)| := euclidean_norm_le_sum_abs (v j).val + _ ≤ ∑ _ : J, (H : ℝ) ^ (Fintype.card J * Fintype.card C) := by + apply Finset.sum_le_sum + intro i _ + have hb := hzH (i, j) + rw [Fintype.card_prod] at hb + have hr : |z (i, j)| ≤ (H ^ (Fintype.card J * Fintype.card C) : ℕ) := by + simpa only [Int.natCast_natAbs] using (Int.ofNat_le.mpr hb) + exact_mod_cast hr + _ = _ := by simp + +theorem rationalRangeLattice_full + {J C : Type*} [Fintype J] [Fintype C] + (B : Matrix J C ℚ) (W : Submodule ℝ (J → ℝ)) + (hW : LinearMap.range (Matrix.of (fun i j => (B i j : ℝ))).mulVecLin = W) + {H : ℕ} (hB : ∀ i j, RationalHeightLE (B i j) H) : + IsZLattice ℝ (latticeSection (standardEuclideanLattice J) (euclideanSubspace W)) := by + obtain ⟨v, hv, hmem, _⟩ := exists_bounded_integral_span_of_rational_range B W hW hB + constructor + apply top_unique + rw [← hv] + apply span_mono + rintro _ ⟨j, rfl⟩ + exact hmem j + +theorem jointRationalSpaceLattice_full + {J C V : Type*} [Fintype J] [Fintype C] [Fintype V] + (B : Matrix J C ℚ) (A : Matrix V J ℚ) {H R : ℕ} + (hH : 1 ≤ H) (hR : 1 ≤ R) + (hB : ∀ i j, RationalHeightLE (B i j) H) (hA : ∀ v j, RationalHeightLE (A v j) R) : + IsZLattice ℝ (latticeSection (standardEuclideanLattice J) + (euclideanSubspace (VectorPolynomial.jointRationalSpace B A))) := by + obtain ⟨P, hP, hW⟩ := VectorPolynomial.exists_jointRationalSpace_generators B A hH hR hB hA + exact rationalRangeLattice_full P _ hW hP + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule BohrLattice.MinkowskiSecondBox +open scoped BigOperators + +theorem exists_short_projected_integer_basis {J : Type*} [Fintype J] + (W : Submodule ℝ (EuclideanSpace ℝ J)) + [IsZLattice ℝ (latticeSection (standardEuclideanLattice J) W)] : + let n := finrank ℝ Wᗮ + ∃ b : Basis (Fin n) ℝ Wᗮ, + span ℤ (Set.range b) = projectedIntegerLattice W ∧ + (∏ i, ‖b i‖) ≤ (n : ℝ) ^ n * minkowskiSecondConstant n * + ZLattice.covolume (projectedIntegerLattice W) ∧ + ∀ i, ‖b i‖ ≤ (n : ℝ) * n.factorial * minkowskiSecondConstant n := by + simpa only [mul_one] using exists_short_euclidean_lattice_basis + (projectedIntegerLattice W) (stdOrthonormalBasis ℝ Wᗮ) (projectedIntegerGenerator W) + (projectedIntegerGenerator_span W) (projectedIntegerGenerator_mem W) + (projectedIntegerGenerator_norm_le W) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule +open scoped Matrix + +variable {D I J : Type*} [Fintype D] [Fintype I] [Fintype J] + +noncomputable def standardLatticeIntegerLift (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) : + (J → ℤ) →ₗ[ℤ] standardEuclideanLattice D := + latticeIntegerLift (standardEuclideanLattice D) W + (integerBasisOfReal (projectedIntegerLattice W) bP hP) + +theorem standardLatticeIntegerLift_projection (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) (z : J → ℤ) : + Wᗮ.orthogonalProjectionOnto (standardLatticeIntegerLift W bP hP z).val = + bP.equivFun.symm (fun j => (z j : ℝ)) := by + have h := latticeIntegerLift_projection (standardEuclideanLattice D) W + (integerBasisOfReal (projectedIntegerLattice W) bP hP) z + exact h.trans (integerBasisOfReal_synthesis (projectedIntegerLattice W) bP hP z) + +noncomputable def standardLatticeCoordinates (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) : + (D → ℤ) ≃ₗ[ℤ] (J ⊕ I → ℤ) := + (standardEuclideanLinearEquiv D).trans + ((latticeSignedCoordinates (standardEuclideanLattice D) W bW + (integerBasisOfReal (projectedIntegerLattice W) bP hP)).trans + (LinearEquiv.sumArrowLequivProdArrow J I ℤ ℤ).symm) + +theorem standardLatticeCoordinates_reconstruction (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) (β : D → ℤ) : + (standardEuclideanPoint D β).val + + (standardLatticeIntegerLift W bP hP + (fun j => standardLatticeCoordinates W bW bP hP β (Sum.inl j))).val = + (bW.equivFun.symm (fun i => standardLatticeCoordinates W bW bP hP β (Sum.inr i))).val.val := by + rw [← standardEuclideanLinearEquiv_eq_point] + exact latticeSignedCoordinates_reconstruction (standardEuclideanLattice D) W bW + (integerBasisOfReal (projectedIntegerLattice W) bP hP) (standardEuclideanLinearEquiv D β) + +theorem standardLatticeCoordinates_projection (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) (β : D → ℤ) : + Wᗮ.orthogonalProjectionOnto (standardEuclideanPoint D β).val = + -bP.equivFun.symm (fun j => (standardLatticeCoordinates W bW bP hP β (Sum.inl j) : ℝ)) := by + have h := congrArg Wᗮ.orthogonalProjectionOnto + (standardLatticeCoordinates_reconstruction W bW bP hP β) + rw [map_add, standardLatticeIntegerLift_projection, + W.orthogonalProjectionOnto_orthogonal_apply_eq_zero + (bW.equivFun.symm (fun i => standardLatticeCoordinates W bW bP hP β (Sum.inr i))).val.property] at h + exact eq_neg_of_add_eq_zero_left h + +theorem standardLatticeCoordinates_residue [DecidableEq D] + (W : Submodule ℝ (EuclideanSpace ℝ D)) + (bW : Basis I ℤ (latticeSection (standardEuclideanLattice D) W)) + (bP : Basis J ℝ Wᗮ) (hP : span ℤ (Set.range bP) = projectedIntegerLattice W) + (M : ℕ) [NeZero M] : + ∃ A : Matrix (J ⊕ I) D ℤ, + (∀ i j, 0 ≤ A i j ∧ A i j < M) ∧ + ∀ β, integerResidueMap (J ⊕ I) M (standardLatticeCoordinates W bW bP hP β) = + integerResidueMatrix A M *ᵥ integerResidueMap D M β := + exists_bounded_integerMap_residue_matrix (standardLatticeCoordinates W bW bP hP).toLinearMap M + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/StandardLatticeGaussianBound.lean b/lean/OAI/Combinatorics/Progressions/Lattices/StandardLatticeGaussianBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..25761704704d3ed569b36b2cb291e16a4f12dc3d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/StandardLatticeGaussianBound.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.Progressions.Fourier.LatticeGaussianMeanFourier +import OAI.Combinatorics.Progressions.Lattices.IntegerGaussianGeometric +import OAI.Combinatorics.Progressions.Probability.FiniteProductMassBound + +namespace OAI + +section + +namespace Erdos3 + +variable (ι : Type*) [Fintype ι] + +theorem standardLatticeGaussian_mass_bound {t : ℝ} (ht : 0 < t) : + latticeGaussianMass (standardEuclideanLattice ι) t⁻¹ 0 ≤ (1 + 2 * t) ^ Fintype.card ι := by + classical + have hpoint (z : ι → ℤ) : + Real.exp (-Real.pi * t⁻¹ * ‖(0 : EuclideanSpace ℝ ι) - + (standardEuclideanEquiv ι z : EuclideanSpace ℝ ι)‖ ^ 2) = + ∏ i, Real.exp (-Real.pi / t * (z i : ℝ) ^ 2) := by + change Real.exp (-Real.pi * t⁻¹ * ‖(0 : EuclideanSpace ℝ ι) - + (standardEuclideanPoint ι z : EuclideanSpace ℝ ι)‖ ^ 2) = _ + rw [zero_sub, norm_neg, EuclideanSpace.real_norm_sq_eq, Finset.mul_sum, Real.exp_sum] + simp only [standardEuclideanPoint_apply, div_eq_mul_inv] + unfold latticeGaussianMass + rw [← (standardEuclideanEquiv ι).tsum_eq] + simp_rw [hpoint] + apply Real.tsum_le_of_sum_le + · intro z + exact Finset.prod_nonneg fun i _ => (Real.exp_pos _).le + · intro s + exact finite_product_mass_bound (fun n : ℤ => Real.exp (-Real.pi / t * (n : ℝ) ^ 2)) + (fun _ => (Real.exp_pos _).le) (integer_gaussian_sum_bound ht) s + +theorem standardLatticeGaussian_origin_bound {t : ℝ} (ht : 0 < t) : + normalizedLatticeGaussian (standardEuclideanLattice ι) t 0 ≤ (1 + 2 * t) ^ Fintype.card ι := by + rw [normalizedLatticeGaussian_zero_eq_dual _ ht, standardEuclideanLattice_self_dual] + exact standardLatticeGaussian_mass_bound ι ht + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/StrideSelectedResidueBadProduct.lean b/lean/OAI/Combinatorics/Progressions/Lattices/StrideSelectedResidueBadProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..536a7912fc1d5c8bbba46e0960d8704be73b3a93 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/StrideSelectedResidueBadProduct.lean @@ -0,0 +1,836 @@ +import Mathlib.Data.Nat.Factorization.Basic +import OAI.Combinatorics.Progressions.Estimates.ReweightedFiberDomination +import OAI.Combinatorics.Progressions.Polynomial.CRTPolynomialChargeBound +import OAI.Combinatorics.Progressions.Probability.FiniteProductWitnessProbability + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem badPrimeModulusEvent_probability {Ω : Type*} [Fintype Ω] + (w : FiniteProbabilityWeights Ω) (S : Finset ℕ) (A : ℕ → ℕ) (Qs : ℕ) + (bad : ℕ → ℕ → Ω → Prop) {η : ℝ} (hη : 0 ≤ η) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + w.eventProbability (fun x => ∀ p ∈ T, bad p (a p) x) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + η) + {d : ℕ} (hd : 0 < d) : + w.eventProbability (badPrimeModulusEvent S A Qs bad d) ≤ 1 / (d : ℝ) ^ 10 + η := by + by_cases hvalid : ∀ p ∈ d.primeFactors, p ∈ S ∧ 0 < d.factorization p ∧ + d.factorization p ≤ A p ∧ Qs ≤ p ^ d.factorization p + · have h := hjoint d.primeFactors (fun p hp => (hvalid p hp).1) d.factorization + (fun p hp => (hvalid p hp).2) + rw [← Nat.prod_primeFactors_pow_factorization hd.ne'] at h + exact (w.eventProbability_mono _ _ (fun _ hx => hx.2)).trans h + · rw [w.eventProbability_false _ (fun _ hx => hvalid hx.1)] + positivity + +theorem badPrimeModulusEvent_probability_bounded {Ω : Type*} [Fintype Ω] + (w : FiniteProbabilityWeights Ω) (S : Finset ℕ) (A : ℕ → ℕ) (Qs B : ℕ) + (bad : ℕ → ℕ → Ω → Prop) {η : ℝ} (hη : 0 ≤ η) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + (∏ p ∈ T, p ^ a p) ≤ B → + w.eventProbability (fun x => ∀ p ∈ T, bad p (a p) x) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + η) + {d : ℕ} (hd : 0 < d) (hdB : d ≤ B) : + w.eventProbability (badPrimeModulusEvent S A Qs bad d) ≤ 1 / (d : ℝ) ^ 10 + η := by + by_cases hvalid : ∀ p ∈ d.primeFactors, p ∈ S ∧ 0 < d.factorization p ∧ + d.factorization p ≤ A p ∧ Qs ≤ p ^ d.factorization p + · have hprod := Nat.prod_primeFactors_pow_factorization hd.ne' + have h := hjoint d.primeFactors (fun p hp => (hvalid p hp).1) d.factorization + (fun p hp => (hvalid p hp).2) (hprod ▸ hdB) + rw [← hprod] at h + exact (w.eventProbability_mono _ _ (fun _ hx => hx.2)).trans h + · rw [w.eventProbability_false _ (fun _ hx => hvalid hx.1)] + positivity + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem independent_badPrime_joint_probability + (S : Finset ℕ) {Ω : S → Type*} [∀ p, Fintype (Ω p)] + (w : ∀ p, FiniteProbabilityWeights (Ω p)) + (localBad : ∀ p, ℕ → Ω p → Prop) + (bad : ℕ → ℕ → (∀ p, Ω p) → Prop) + (hlocal : ∀ (p : S) a x, bad p a x ↔ localBad p a (x p)) + (T : Finset ℕ) (hTS : T ⊆ S) (a : ℕ → ℕ) + (hprob : ∀ (p : S), p.val ∈ T → + (w p).eventProbability (localBad p (a p)) ≤ 1 / ((p.val ^ a p : ℕ) : ℝ) ^ 10) : + (FiniteProbabilityWeights.pi w).eventProbability + (fun x => ∀ p ∈ T, bad p (a p) x) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 := by + classical + have hprod := FiniteProbabilityWeights.eventProbability_pi w + (fun p y => p.val ∈ T → localBad p (a p) y) + have hmono := (FiniteProbabilityWeights.pi w).eventProbability_mono + (fun x => ∀ p ∈ T, bad p (a p) x) + (fun x => ∀ p : S, p.val ∈ T → localBad p (a p) (x p)) + (fun x hx p hp => (hlocal p (a p) x).mp (hx p hp)) + rw [hprod] at hmono + calc + _ ≤ ∏ p : S, (w p).eventProbability + (fun y => p.val ∈ T → localBad p (a p) y) := hmono + _ ≤ ∏ p : S, if p.val ∈ T then 1 / ((p.val ^ a p : ℕ) : ℝ) ^ 10 else 1 := by + apply Finset.prod_le_prod₀ + · intro p _ + exact (w p).eventProbability_nonneg _ + · intro p _ + by_cases hp : p.val ∈ T + · simpa only [hp, true_implies, ite_true] using hprob p hp + · simp only [hp, false_implies, ite_false, FiniteProbabilityWeights.eventProbability, + ite_true, FiniteProbabilityWeights.mean_const, le_refl] + _ = ∏ p ∈ S, if p ∈ T then 1 / ((p ^ a p : ℕ) : ℝ) ^ 10 else 1 := + Finset.prod_coe_sort S (fun p => if p ∈ T then 1 / ((p ^ a p : ℕ) : ℝ) ^ 10 else 1) + _ = ∏ p ∈ T, 1 / ((p ^ a p : ℕ) : ℝ) ^ 10 := by + rw [← Finset.prod_subset hTS (fun p _ hp => ite_eq_right hp)] + exact Finset.prod_congr rfl (fun p hp => ite_eq_left hp) + _ = _ := by + simp only [one_div, ← Finset.prod_inv_distrib, ← Finset.prod_pow, Nat.cast_prod] + +theorem independent_badPrimeModulusEvent_probability + (S : Finset ℕ) {Ω : S → Type*} [∀ p, Fintype (Ω p)] + (w : ∀ p, FiniteProbabilityWeights (Ω p)) + (localBad : ∀ p, ℕ → Ω p → Prop) + (bad : ℕ → ℕ → (∀ p, Ω p) → Prop) + (hlocal : ∀ (p : S) a x, bad p a x ↔ localBad p a (x p)) + (A : ℕ → ℕ) (Qs : ℕ) + (hprob : ∀ (p : S) a, 0 < a → a ≤ A p → Qs ≤ p.val ^ a → + (w p).eventProbability (localBad p a) ≤ 1 / ((p.val ^ a : ℕ) : ℝ) ^ 10) + {d : ℕ} (hd : 0 < d) : + (FiniteProbabilityWeights.pi w).eventProbability + (badPrimeModulusEvent S A Qs bad d) ≤ 1 / (d : ℝ) ^ 10 := by + have h := badPrimeModulusEvent_probability (FiniteProbabilityWeights.pi w) S A Qs bad + (η := 0) le_rfl (fun T hTS a ha => ?_) hd + · simpa only [add_zero] using h + · simpa only [add_zero] using independent_badPrime_joint_probability S w localBad bad hlocal T hTS a + (fun p hp => hprob p (a p) (ha p hp).1 (ha p hp).2.1 (ha p hp).2.2) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem largestBadPrimeProduct_probability {Ω : Type*} [Fintype Ω] + (w : FiniteProbabilityWeights Ω) (S : Finset ℕ) (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) {Qs Q R : ℕ} + (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) (hQ : 1 ≤ Q) (hR : 0 < R) + (hdepth : ∀ p ∈ S, p ^ A p ≤ Q) {η : ℝ} (hη : 0 ≤ η) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + w.eventProbability (fun x => ∀ p ∈ T, bad p (a p) x) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + η) : + w.eventProbability (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + let f := fun x p => if Qs ≤ p ^ largestTestedBadDepth A bad p x then + p ^ largestTestedBadDepth A bad p x else 1 + let E := badPrimeModulusEvent S A Qs bad + have hfactor (x p) (hp : p ∈ S) : f x p ≤ Q := by + dsimp only [f] + split_ifs + · exact (Nat.pow_le_pow_right (hprime p hp).pos (largestTestedBadDepth_le A bad p x)).trans + (hdepth p hp) + · exact hQ + have hsingle (x p) (hp : p ∈ S) (_hlarge : R < f x p) : E (f x p) x := by + simpa only [Finset.prod_singleton] using + largestBadPrime_subproduct_modulus_event S {p} A bad x hQs hprime + (Finset.singleton_subset_iff.mpr hp) + have hcomposite (x T) (hTS : T ⊆ S) (_hlo : R < ∏ p ∈ T, f x p) + (_hhi : (∏ p ∈ T, f x p) ≤ R ^ 2) : E (∏ p ∈ T, f x p) x := + largestBadPrime_subproduct_modulus_event S T A bad x hQs hprime hTS + have hprob (d : ℕ) (hd : R < d) : w.eventProbability (E d) ≤ 1 / (d : ℝ) ^ 10 + η := + badPrimeModulusEvent_probability w S A Qs bad hη hjoint (hR.trans hd) + have hwitness := finite_product_witness_probability w S f E E hR hfactor hsingle hcomposite hη + (fun _ hd => hprob _ (Finset.mem_Ioc.mp hd).1) + (fun _ hd => hprob _ (Finset.mem_Ioc.mp hd).1) + apply (w.eventProbability_mono _ _ ?_).trans hwitness + intro x hx + have hcorrection := prime_power_small_correction S (fun p => largestTestedBadDepth A bad p x) hprime hQs + change R < ∏ p ∈ S, f x p + by_contra h + have hle : (∏ p ∈ S, f x p) ≤ R := Nat.le_of_not_gt h + have hupper := hcorrection.trans (Nat.mul_le_mul_left (smallPrimePowerCorrection Qs) hle) + exact (Nat.not_lt_of_ge hupper) hx + +theorem largestBadPrimeProduct_probability_exact {Ω : Type*} [Fintype Ω] + (w : FiniteProbabilityWeights Ω) (S : Finset ℕ) (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) {Qs Q R : ℕ} + (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) (hQ : 1 ≤ Q) (hR : 0 < R) + (hdepth : ∀ p ∈ S, p ^ A p ≤ Q) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + w.eventProbability (fun x => ∀ p ∈ T, bad p (a p) x) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10) : + w.eventProbability (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x) ≤ 2 / (9 * (R : ℝ) ^ 9) := by + simpa only [add_zero, mul_zero] using + largestBadPrimeProduct_probability w S A bad hprime hQs hQ hR hdepth + (η := 0) le_rfl (by intro T hT a ha; simpa only [add_zero] using hjoint T hT a ha) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +def primeArrayBad (S : Finset ℕ) {Ω : S → Type*} + (localBad : ∀ p, ℕ → Ω p → Prop) (p a : ℕ) (x : ∀ p, Ω p) : Prop := + ∃ hp : p ∈ S, localBad ⟨p, hp⟩ a (x ⟨p, hp⟩) + +theorem primeArrayBad_iff (S : Finset ℕ) {Ω : S → Type*} + (localBad : ∀ p, ℕ → Ω p → Prop) (p : S) (a : ℕ) (x : ∀ p, Ω p) : + primeArrayBad S localBad p a x ↔ localBad p a (x p) := by + constructor + · rintro ⟨hp, hbad⟩ + exact hbad + · intro hbad + exact ⟨p.property, hbad⟩ + +theorem independent_largestBadPrimeProduct_probability + (S : Finset ℕ) {Ω : S → Type*} [∀ p, Fintype (Ω p)] + (w : ∀ p, FiniteProbabilityWeights (Ω p)) + (localBad : ∀ p, ℕ → Ω p → Prop) (A : ℕ → ℕ) {Qs Q R : ℕ} + (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) (hQ : 1 ≤ Q) (hR : 0 < R) + (hdepth : ∀ p ∈ S, p ^ A p ≤ Q) + (hprob : ∀ (p : S) a, 0 < a → a ≤ A p → Qs ≤ p.val ^ a → + (w p).eventProbability (localBad p a) ≤ 1 / ((p.val ^ a : ℕ) : ℝ) ^ 10) : + (FiniteProbabilityWeights.pi w).eventProbability (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A (primeArrayBad S localBad) p x) ≤ + 2 / (9 * (R : ℝ) ^ 9) := by + apply largestBadPrimeProduct_probability_exact (FiniteProbabilityWeights.pi w) S A + (primeArrayBad S localBad) hprime hQs hQ hR hdepth + intro T hTS a ha + exact independent_badPrime_joint_probability S w localBad (primeArrayBad S localBad) + (primeArrayBad_iff S localBad) T hTS a + (fun p hp => hprob p (a p) (ha p hp).1 (ha p hp).2.1 (ha p hp).2.2) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem largestBadPrimeProduct_probability_bounded {Ω : Type*} [Fintype Ω] + (w : FiniteProbabilityWeights Ω) (S : Finset ℕ) (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) {Qs Q R : ℕ} + (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) (hQ : 1 ≤ Q) (hR : 0 < R) + (hdepth : ∀ p ∈ S, p ^ A p ≤ Q) {η : ℝ} (hη : 0 ≤ η) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + (∏ p ∈ T, p ^ a p) ≤ max Q (R ^ 2) → + w.eventProbability (fun x => ∀ p ∈ T, bad p (a p) x) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + η) : + w.eventProbability (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + let f := fun x p => if Qs ≤ p ^ largestTestedBadDepth A bad p x then + p ^ largestTestedBadDepth A bad p x else 1 + let E := badPrimeModulusEvent S A Qs bad + have hfactor (x p) (hp : p ∈ S) : f x p ≤ Q := by + dsimp only [f] + split_ifs + · exact (Nat.pow_le_pow_right (hprime p hp).pos (largestTestedBadDepth_le A bad p x)).trans + (hdepth p hp) + · exact hQ + have hsingle (x p) (hp : p ∈ S) (_hlarge : R < f x p) : E (f x p) x := by + simpa only [Finset.prod_singleton] using + largestBadPrime_subproduct_modulus_event S {p} A bad x hQs hprime + (Finset.singleton_subset_iff.mpr hp) + have hcomposite (x T) (hTS : T ⊆ S) (_hlo : R < ∏ p ∈ T, f x p) + (_hhi : (∏ p ∈ T, f x p) ≤ R ^ 2) : E (∏ p ∈ T, f x p) x := + largestBadPrime_subproduct_modulus_event S T A bad x hQs hprime hTS + have hprob (d : ℕ) (hd : R < d) (hdB : d ≤ max Q (R ^ 2)) : w.eventProbability (E d) ≤ 1 / (d : ℝ) ^ 10 + η := + badPrimeModulusEvent_probability_bounded w S A Qs (max Q (R ^ 2)) bad hη hjoint (hR.trans hd) hdB + have hwitness := finite_product_witness_probability w S f E E hR hfactor hsingle hcomposite hη + (fun _ hd => hprob _ (Finset.mem_Ioc.mp hd).1 + ((Finset.mem_Ioc.mp hd).2.trans (le_max_left _ _))) + (fun _ hd => hprob _ (Finset.mem_Ioc.mp hd).1 + ((Finset.mem_Ioc.mp hd).2.trans (le_max_right _ _))) + apply (w.eventProbability_mono _ _ ?_).trans hwitness + intro x hx + have hcorrection := prime_power_small_correction S (fun p => largestTestedBadDepth A bad p x) hprime hQs + change R < ∏ p ∈ S, f x p + by_contra h + have hle : (∏ p ∈ S, f x p) ≤ R := Nat.le_of_not_gt h + have hupper := hcorrection.trans (Nat.mul_le_mul_left (smallPrimePowerCorrection Qs) hle) + exact (Nat.not_lt_of_ge hupper) hx + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem exists_early_badPrime_radius {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ Q : ℕ, 1 ≤ Q → + 0 < δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2)) ∧ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * + (δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2))) ≤ δ := by + obtain ⟨R, hR⟩ := exists_nat_gt (max 1 (4 / (9 * δ))) + have hR1 : (1 : ℝ) < R := (le_max_left _ _).trans_lt hR + have hR0 : (0 : ℝ) < R := lt_trans zero_lt_one hR1 + have hRp : (R : ℝ) ≤ (R : ℝ) ^ 9 := by + calc + _ = (R : ℝ) ^ 1 := (pow_one _).symm + _ ≤ _ := pow_le_pow_right₀ hR1.le (by omega) + have hbound : 4 ≤ 9 * δ * (R : ℝ) := by + have hb := (le_max_right _ _).trans_lt hR + have hh := (div_lt_iff₀ (by positivity : 0 < 9 * δ)).mp hb + nlinarith + have htail : 2 / (9 * (R : ℝ) ^ 9) ≤ δ / 2 := by + apply (div_le_iff₀ (by positivity : 0 < 9 * (R : ℝ) ^ 9)).mpr + have := mul_le_mul_of_nonneg_left hRp (by positivity : 0 ≤ 9 * δ) + nlinarith + refine ⟨R, by exact_mod_cast hR0, ?_⟩ + intro Q hQ + have hQ0 : (0 : ℝ) < Q := by exact_mod_cast hQ + have hden : 0 < (Q : ℝ) + (R : ℝ) ^ 2 := by positivity + refine ⟨by positivity, ?_⟩ + have heq : ((Q : ℝ) + (R : ℝ) ^ 2) * + (δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2))) = δ / 2 := by + field_simp + rw [heq] + linarith + +theorem exists_early_badPrimeProduct_cutoff (Qs : ℕ) (hQs : 2 ≤ Qs) + {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ (Ω : Type*) [Fintype Ω] + (w : FiniteProbabilityWeights Ω) (S : Finset ℕ) (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) (Q : ℕ), + (∀ p ∈ S, p.Prime) → 1 ≤ Q → (∀ p ∈ S, p ^ A p ≤ Q) → + (∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + (∏ p ∈ T, p ^ a p) ≤ max Q (R ^ 2) → + w.eventProbability (fun x => ∀ p ∈ T, bad p (a p) x) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + + δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2))) → + w.eventProbability (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x) ≤ δ := by + obtain ⟨R, hR, hbound⟩ := exists_early_badPrime_radius hδ + refine ⟨R, hR, ?_⟩ + intro Ω _ w S A bad Q hprime hQ hdepth hjoint + exact (largestBadPrimeProduct_probability_bounded w S A bad hprime hQs hQ hR hdepth + (hbound Q hQ).1.le hjoint).trans (hbound Q hQ).2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def quantitativeBadPrimeRadius (E : ℝ) : ℕ := ⌈4 * Real.exp E⌉₊ + 1 + +theorem quantitativeBadPrimeRadius_bounds {E : ℝ} (hE : 0 ≤ E) : + 0 < quantitativeBadPrimeRadius E ∧ + (quantitativeBadPrimeRadius E : ℝ) ≤ Real.exp (E + 3) ∧ + 2 / (9 * (quantitativeBadPrimeRadius E : ℝ) ^ 9) ≤ Real.exp (-E) / 2 := by + let R := quantitativeBadPrimeRadius E + have hR : 0 < R := Nat.succ_pos _ + have hexp : 1 ≤ Real.exp E := Real.one_le_exp hE + have hlo : 4 * Real.exp E ≤ (R : ℝ) := by + have hc := Nat.le_ceil (4 * Real.exp E) + dsimp [R, quantitativeBadPrimeRadius] + push_cast + linarith + have hhi : (R : ℝ) ≤ 4 * Real.exp E + 2 := by + have hc := Nat.ceil_lt_add_one (by positivity : 0 ≤ 4 * Real.exp E) + dsimp [R, quantitativeBadPrimeRadius] + push_cast + linarith + have hexp3 : (6 : ℝ) ≤ Real.exp 3 := by + have h1 : (2 : ℝ) ≤ Real.exp 1 := by + have := Real.add_one_le_exp (1 : ℝ) + linarith + have h2 : (4 : ℝ) ≤ Real.exp 1 * Real.exp 1 := by nlinarith + have h3 : (8 : ℝ) ≤ Real.exp 1 * Real.exp 1 * Real.exp 1 := by nlinarith + have he : Real.exp 3 = Real.exp 1 * Real.exp 1 * Real.exp 1 := by + rw [← Real.exp_add, ← Real.exp_add] + norm_num + rw [he] + linarith + have hbudget : (R : ℝ) ≤ Real.exp (E + 3) := by + rw [Real.exp_add] + have := mul_le_mul_of_nonneg_left hexp3 (Real.exp_pos E).le + nlinarith + have hR1 : (1 : ℝ) ≤ R := by exact_mod_cast hR + have hRp : (R : ℝ) ≤ (R : ℝ) ^ 9 := by + calc + _ = (R : ℝ) ^ 1 := (pow_one _).symm + _ ≤ _ := pow_le_pow_right₀ hR1 (by omega) + have hprod : 4 ≤ Real.exp (-E) * (R : ℝ) := by + have hh := mul_le_mul_of_nonneg_left hlo (Real.exp_pos (-E)).le + have he : Real.exp (-E) * Real.exp E = 1 := by rw [← Real.exp_add]; simp + nlinarith + have htail : 2 / (9 * (R : ℝ) ^ 9) ≤ Real.exp (-E) / 2 := by + apply (div_le_iff₀ (by positivity : 0 < 9 * (R : ℝ) ^ 9)).mpr + have hh := mul_le_mul_of_nonneg_left hRp (Real.exp_pos (-E)).le + nlinarith + exact ⟨hR, hbudget, htail⟩ + +theorem quantitativeBadPrimeRadius_error {E : ℝ} (hE : 0 ≤ E) (Q : ℕ) (hQ : 1 ≤ Q) : + let R := quantitativeBadPrimeRadius E + 0 < Real.exp (-E) / (2 * ((Q : ℝ) + (R : ℝ) ^ 2)) ∧ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * + (Real.exp (-E) / (2 * ((Q : ℝ) + (R : ℝ) ^ 2))) ≤ Real.exp (-E) := by + dsimp only + have hQ0 : (0 : ℝ) < Q := by exact_mod_cast hQ + have hden : 0 < (Q : ℝ) + (quantitativeBadPrimeRadius E : ℝ) ^ 2 := by positivity + refine ⟨by positivity, ?_⟩ + have heq : ((Q : ℝ) + (quantitativeBadPrimeRadius E : ℝ) ^ 2) * + (Real.exp (-E) / (2 * ((Q : ℝ) + (quantitativeBadPrimeRadius E : ℝ) ^ 2))) = + Real.exp (-E) / 2 := by field_simp + rw [heq] + linarith [(quantitativeBadPrimeRadius_bounds hE).2.2] + +theorem quantitativeBadPrimeRadius_witness_budget {E V : ℝ} + (hE : 0 ≤ E) (hV : 0 ≤ V) (Q : ℕ) (hQ : (Q : ℝ) ≤ Real.exp V) : + let R := quantitativeBadPrimeRadius E + (max Q (R ^ 2) : ℕ) ≤ Real.exp (V + 2 * E + 6) ∧ + 1 / (Real.exp (-E) / (2 * ((Q : ℝ) + (R : ℝ) ^ 2))) ≤ + Real.exp (V + 3 * E + 8) := by + dsimp only + let R := quantitativeBadPrimeRadius E + have hR := (quantitativeBadPrimeRadius_bounds hE).2.1 + have hR2 : (R : ℝ) ^ 2 ≤ Real.exp (2 * E + 6) := by + have hh := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ R) hR 2 + have he : (Real.exp (E + 3)) ^ 2 = Real.exp (2 * E + 6) := by + rw [← Real.exp_nat_mul] + congr 1 + ring + exact hh.trans_eq he + have hQbig : (Q : ℝ) ≤ Real.exp (V + 2 * E + 6) := + hQ.trans (Real.exp_le_exp.mpr (by linarith)) + have hRbig : (R : ℝ) ^ 2 ≤ Real.exp (V + 2 * E + 6) := + hR2.trans (Real.exp_le_exp.mpr (by linarith)) + constructor + · rw [Nat.cast_max, Nat.cast_pow] + exact max_le hQbig hRbig + · have hne : Real.exp (-E) ≠ 0 := ne_of_gt (Real.exp_pos _) + have hrec : 1 / (Real.exp (-E) / (2 * ((Q : ℝ) + (R : ℝ) ^ 2))) = + 2 * ((Q : ℝ) + (R : ℝ) ^ 2) * Real.exp E := by + rw [one_div_div, Real.exp_neg, div_inv_eq_mul] + rw [hrec] + have h4 : (4 : ℝ) ≤ Real.exp 2 := by + have h1 : (2 : ℝ) ≤ Real.exp 1 := by + have := Real.add_one_le_exp (1 : ℝ) + linarith + have he : Real.exp 2 = Real.exp 1 * Real.exp 1 := by + rw [← Real.exp_add] + norm_num + rw [he] + nlinarith + calc + _ ≤ 4 * Real.exp (V + 2 * E + 6) * Real.exp E := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos E).le + linarith + _ ≤ Real.exp 2 * Real.exp (V + 2 * E + 6) * Real.exp E := by + gcongr + _ = Real.exp (V + 3 * E + 8) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +noncomputable def selectedResidueTiltedFiniteLaw {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) : + FiniteProbabilityWeights (rectangularWeightIndices 0 V 1) := + (selectedResidueFiniteLaw modulus G V hV hZ).reweightPositive (fun x => D x.val) + (fun x => hD0 x.val) (by rw [selectedResidueFiniteLaw_densityMass]; exact hD) + +theorem selectedResidueTiltedFiniteLaw_mean {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) (f : (K × I → ℤ) → ℝ) : + (selectedResidueTiltedFiniteLaw modulus G V hV hZ D hD0 hD).mean (fun x => f x.val) = + ∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * f x := by + rw [selectedResidueTiltedFiniteLaw, FiniteProbabilityWeights.reweightPositive_mean, + selectedResidueFiniteLaw_densityMass, + selectedResidueFiniteLaw_mean modulus G V hV hZ (fun x => D x * f x), + selectedResidueDensityPMF_mean] + +theorem selectedResidue_fiber_excess_le {K I Y : Type*} [Fintype K] [Fintype I] [Fintype Y] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) (F : (K × I → ℤ) → Y) + {C ε : ℝ} + (he : ∀ S : Finset Y, + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * (if F x ∈ S then 1 else 0)) ≤ + C * (∑' x, (selectedResidueSmoothPMF modulus G V hV hZ x).toReal * (if F x ∈ S then 1 else 0)) + ε) : + ((selectedResidueFiniteLaw modulus G V hV hZ).fiberLaw (fun x => F x.val)).excessMass + ((selectedResidueTiltedFiniteLaw modulus G V hV hZ D hD0 hD).fiberLaw (fun x => F x.val)) C ≤ ε := by + apply FiniteProbabilityWeights.excessMass_le_of_mass_le + intro S + rw [FiniteProbabilityWeights.fiberLaw_mass_indicator, FiniteProbabilityWeights.fiberLaw_mass_indicator, + selectedResidueTiltedFiniteLaw_mean modulus G V hV hZ D hD0 hD (fun x => if F x ∈ S then 1 else 0), + selectedResidueFiniteLaw_mean modulus G V hV hZ (fun x => if F x ∈ S then 1 else 0)] + exact he S + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + +theorem selectedResidueTiltedFiniteLaw_event (E : (K × I → ℤ) → Prop) : + (selectedResidueTiltedFiniteLaw modulus G V hV hZ D hD0 hD).eventProbability + (fun x => E x.val) = + ∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if E x then 1 else 0) := by + exact selectedResidueTiltedFiniteLaw_mean modulus G V hV hZ D hD0 hD + (fun x => if E x then 1 else 0) + +theorem selectedResidueDensityPMF_badPrimeProduct_probability + (S : Finset ℕ) (A : ℕ → ℕ) (bad : ℕ → ℕ → (K × I → ℤ) → Prop) + {Qs Q R : ℕ} (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) + (hQ : 1 ≤ Q) (hR : 0 < R) (hdepth : ∀ p ∈ S, p ^ A p ≤ Q) + {η : ℝ} (hη : 0 ≤ η) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + (∏ p ∈ T, p ^ a p) ≤ max Q (R ^ 2) → + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if ∀ p ∈ T, bad p (a p) x then 1 else 0)) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + η) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x then 1 else 0)) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + have h := largestBadPrimeProduct_probability_bounded + (selectedResidueTiltedFiniteLaw modulus G V hV hZ D hD0 hD) S A + (fun p a x => bad p a x.val) hprime hQs hQ hR hdepth hη + (fun T hT a ha hbound => by + rw [selectedResidueTiltedFiniteLaw_event modulus G V hV hZ D hD0 hD + (fun x => ∀ p ∈ T, bad p (a p) x)] + convert hjoint T hT a ha hbound using 1 + apply tsum_congr + intro x + by_cases hx : ∀ p ∈ T, bad p (a p) x <;> simp [hx]) + change (selectedResidueTiltedFiniteLaw modulus G V hV hZ D hD0 hD).eventProbability + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x.val) ≤ _ at h + rw [selectedResidueTiltedFiniteLaw_event modulus G V hV hZ D hD0 hD + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x)] at h + convert h using 1 + apply tsum_congr + intro x + by_cases hx : smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x <;> simp [hx] + +theorem exists_early_selectedResidueDensityPMF_badPrimeProduct_cutoff + (Qs : ℕ) (hQs : 2 ≤ Qs) {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ (K I : Type*) [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (S : Finset ℕ) (A : ℕ → ℕ) (bad : ℕ → ℕ → (K × I → ℤ) → Prop) (Q : ℕ), + (∀ p ∈ S, p.Prime) → 1 ≤ Q → (∀ p ∈ S, p ^ A p ≤ Q) → + (∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p) → + (∏ p ∈ T, p ^ a p) ≤ max Q (R ^ 2) → + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if ∀ p ∈ T, bad p (a p) x then 1 else 0)) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + + δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2))) → + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x then 1 else 0)) ≤ δ := by + obtain ⟨R, hR, hbound⟩ := exists_early_badPrime_radius hδ + refine ⟨R, hR, ?_⟩ + intro K I _ _ modulus G V hV hZ D hD0 hD S A bad Q hprime hQ hdepth hjoint + exact (selectedResidueDensityPMF_badPrimeProduct_probability modulus G V hV hZ D hD0 hD + S A bad hprime hQs hQ hR hdepth (hbound Q hQ).1.le hjoint).trans (hbound Q hQ).2 + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +def prescribedDeepBad {Ω : Type*} (b : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) (p a : ℕ) (x : Ω) : Prop := b p < a ∧ bad p a x + +theorem largestTestedBadDepth_le_prescribed_max {Ω : Type*} + (A b : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) (p : ℕ) (x : Ω) : + largestTestedBadDepth A bad p x ≤ + max (b p) (largestTestedBadDepth A (prescribedDeepBad b bad) p x) := by + apply Finset.sup_le + intro a ha + obtain ⟨ha, hbad⟩ := Finset.mem_filter.mp ha + by_cases h : b p < a + · exact (Finset.le_sup (f := id) (Finset.mem_filter.mpr ⟨ha, h, hbad⟩)).trans + (le_max_right _ _) + · exact (Nat.le_of_not_gt h).trans (le_max_left _ _) + +theorem largestBadPrimeProduct_le_prescribed {Ω : Type*} + (S : Finset ℕ) (A b : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) + (hprime : ∀ p ∈ S, p.Prime) (x : Ω) : + (∏ p ∈ S, p ^ largestTestedBadDepth A bad p x) ≤ + (∏ p ∈ S, p ^ b p) * + ∏ p ∈ S, p ^ largestTestedBadDepth A (prescribedDeepBad b bad) p x := by + rw [← Finset.prod_mul_distrib] + apply Finset.prod_le_prod + intro p hp + rw [← pow_add] + exact Nat.pow_le_pow_right (hprime p hp).pos + ((largestTestedBadDepth_le_prescribed_max A b bad p x).trans (by omega)) + +theorem selectedResidueDensityPMF_prescribed_badPrimeProduct + {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (S : Finset ℕ) (A b : ℕ → ℕ) (bad : ℕ → ℕ → (K × I → ℤ) → Prop) + {Qs Q R : ℕ} (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) + (hQ : 1 ≤ Q) (hR : 0 < R) (hdepth : ∀ p ∈ S, p ^ A p ≤ Q) + {η : ℝ} (hη : 0 ≤ η) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p ∧ b p < a p) → + (∏ p ∈ T, p ^ a p) ≤ max Q (R ^ 2) → + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if ∀ p ∈ T, bad p (a p) x then 1 else 0)) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + η) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if (∏ p ∈ S, p ^ b p) * (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x then 1 else 0)) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + let w := selectedResidueTiltedFiniteLaw modulus G V hV hZ D hD0 hD + have ht := selectedResidueDensityPMF_badPrimeProduct_probability modulus G V hV hZ D hD0 hD + S A (prescribedDeepBad b bad) hprime hQs hQ hR hdepth hη + (fun T hT a ha hbound => by + by_cases hb : ∀ p ∈ T, b p < a p + · have hh := hjoint T hT a (fun p hp => ⟨(ha p hp).1, (ha p hp).2.1, + (ha p hp).2.2, hb p hp⟩) hbound + convert hh using 1 + apply tsum_congr + intro x + have he : (∀ p ∈ T, prescribedDeepBad b bad p (a p) x) ↔ + ∀ p ∈ T, bad p (a p) x := by + simp only [prescribedDeepBad] + exact ⟨fun h p hp => (h p hp).2, fun h p hp => ⟨hb p hp, h p hp⟩⟩ + simp only [he] + · have he (x : K × I → ℤ) : ¬ ∀ p ∈ T, prescribedDeepBad b bad p (a p) x := + fun h => hb (fun p hp => (h p hp).1) + simp only [he, ite_false, mul_zero, tsum_zero] + positivity) + have hmono := w.eventProbability_mono + (fun x => (∏ p ∈ S, p ^ b p) * (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x.val) + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A (prescribedDeepBad b bad) p x.val) + (fun x hx => by + by_contra h + have hh := Nat.mul_le_mul_left (∏ p ∈ S, p ^ b p) (Nat.le_of_not_gt h) + exact (not_lt_of_ge ((largestBadPrimeProduct_le_prescribed S A b bad hprime x.val).trans hh)) hx) + dsimp only [w] at hmono + rw [selectedResidueTiltedFiniteLaw_event modulus G V hV hZ D hD0 hD + (fun x => (∏ p ∈ S, p ^ b p) * (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x), + selectedResidueTiltedFiniteLaw_event modulus G V hV hZ D hD0 hD + (fun x => smallPrimePowerCorrection Qs * R < + ∏ p ∈ S, p ^ largestTestedBadDepth A (prescribedDeepBad b bad) p x)] at hmono + refine le_trans ?_ ht + convert hmono using 1 <;> first | rfl | (apply tsum_congr; intro x; split_ifs <;> rfl) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem selected_factorization_product_dvd (S : Finset ℕ) (n : ℕ) : + (∏ p ∈ S, p ^ n.factorization p) ∣ n := by + by_cases hn : n = 0 + · simp [hn] + have he : (∏ p ∈ S ∩ n.factorization.support, p ^ n.factorization p) = + ∏ p ∈ S, p ^ n.factorization p := by + apply Finset.prod_subset Finset.inter_subset_left + intro p hp hnot + have hzero : n.factorization p = 0 := by + apply Finsupp.notMem_support_iff.mp + exact fun hs => hnot (Finset.mem_inter.mpr ⟨hp, hs⟩) + simp [hzero] + rw [← he] + exact (Finset.prod_dvd_prod_of_subset (S ∩ n.factorization.support) + n.factorization.support (fun p => p ^ n.factorization p) Finset.inter_subset_right).trans + (dvd_of_eq (Nat.prod_factorization_pow_eq_self hn)) + +theorem selected_double_factorization_product_dvd (S : Finset ℕ) (n : ℕ) : + (∏ p ∈ S, p ^ (2 * n.factorization p)) ∣ n ^ 2 := by + simp_rw [Nat.mul_comm 2, pow_mul] + rw [Finset.prod_pow] + exact pow_dvd_pow_of_dvd (selected_factorization_product_dvd S n) 2 + +theorem selected_double_factorization_product_le (S : Finset ℕ) {n : ℕ} + (hn : 0 < n) : + (∏ p ∈ S, p ^ (2 * n.factorization p)) ≤ n ^ 2 := + Nat.le_of_dvd (pow_pos hn 2) (selected_double_factorization_product_dvd S n) + +theorem largestBadPrimeProduct_le_stride_sq {Ω : Type*} + (S : Finset ℕ) (A : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) + (hprime : ∀ p ∈ S, p.Prime) {stride : ℕ} (hstride : 0 < stride) (x : Ω) : + (∏ p ∈ S, p ^ largestTestedBadDepth A bad p x) ≤ + stride ^ 2 * ∏ p ∈ S, p ^ largestTestedBadDepth A + (prescribedDeepBad (fun p => 2 * stride.factorization p) bad) p x := by + exact (largestBadPrimeProduct_le_prescribed S A + (fun p => 2 * stride.factorization p) bad hprime x).trans + (Nat.mul_le_mul_right _ (selected_double_factorization_product_le S hstride)) + +theorem crtPolynomialCharge_le_of_deep_bad_product {Ω : Type*} + (S : Finset ℕ) (A e : ℕ → ℕ) (bad : ℕ → ℕ → Ω → Prop) + (hprime : ∀ p ∈ S, p.Prime) {stride : ℕ} (hstride : 0 < stride) + (x : Ω) (s : ℕ) {C : ℝ} (hC : 0 ≤ C) {R : ℕ} + (hdeep : (∏ p ∈ S, p ^ largestTestedBadDepth A + (prescribedDeepBad (fun p => 2 * stride.factorization p) bad) p x) ≤ R) : + crtPolynomialCharge (fun p : S => p.val) + (fun p => largestTestedBadDepth A bad p.val x) (fun p => e p.val) s C ≤ + (((stride ^ 2 * R) * ∏ p : S, p.val ^ e p.val : ℕ) : ℝ) ^ + (modularRankDecayExponent s C * modularRankChargeFactor s) := by + apply crtPolynomialCharge_le_of_bad_product _ _ _ s hC + rw [← Finset.prod_subtype S (fun _ => Iff.rfl) + (fun p : ℕ => p ^ largestTestedBadDepth A bad p x)] + exact (largestBadPrimeProduct_le_stride_sq S A bad hprime hstride x).trans + (Nat.mul_le_mul_left (stride ^ 2) hdeep) + +theorem column_stride_factorization_le_product {X : Type*} [Fintype X] + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) (x : X) (p : ℕ) : + (stride x).factorization p ≤ (∏ x, stride x).factorization p := by + have hprod : (∏ x, stride x) ≠ 0 := + Finset.prod_ne_zero_iff.mpr (fun x _ => (hstride x).ne') + exact (Nat.factorization_le_iff_dvd (hstride x).ne' hprod).mpr + (Finset.dvd_prod_of_mem stride (Finset.mem_univ x)) p + +theorem column_stride_depth_lt_of_product_stride {X : Type*} [Fintype X] + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) {p a : ℕ} + (ha : 2 * (∏ x, stride x).factorization p < a) (x : X) : + 2 * (stride x).factorization p < a := + (Nat.mul_le_mul_left 2 (column_stride_factorization_le_product stride hstride x p)).trans_lt ha + +theorem column_stride_depth_le_of_product_stride {X : Type*} [Fintype X] + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) {p a : ℕ} + (ha : 2 * (∏ x, stride x).factorization p < a) (x : X) : + 2 * (stride x).factorization p ≤ a := + (column_stride_depth_lt_of_product_stride stride hstride ha x).le + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem selectedResidueDensityPMF_stride_badPrimeProduct + {K I : Type*} [Fintype K] [Fintype I] + (modulus : I → ℕ) (G : Finset (ColumnResiduePattern K I modulus)) + (V : K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' x, selectedResidueSmoothWeight modulus G V x) + (D : (K × I → ℤ) → ℝ) (hD0 : ∀ x, 0 ≤ D x) + (hD : 0 < selectedResidueDensityMass modulus G V D) + (S : Finset ℕ) (A : ℕ → ℕ) (bad : ℕ → ℕ → (K × I → ℤ) → Prop) + {stride Qs Q R : ℕ} (hstride : 0 < stride) + (hprime : ∀ p ∈ S, p.Prime) (hQs : 2 ≤ Qs) + (hQ : 1 ≤ Q) (hR : 0 < R) (hdepth : ∀ p ∈ S, p ^ A p ≤ Q) + {η : ℝ} (hη : 0 ≤ η) + (hjoint : ∀ (T : Finset ℕ), T ⊆ S → ∀ a : ℕ → ℕ, + (∀ p ∈ T, 0 < a p ∧ a p ≤ A p ∧ Qs ≤ p ^ a p ∧ + 2 * stride.factorization p < a p) → + (∏ p ∈ T, p ^ a p) ≤ max Q (R ^ 2) → + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if ∀ p ∈ T, bad p (a p) x then 1 else 0)) ≤ + 1 / ((∏ p ∈ T, p ^ a p : ℕ) : ℝ) ^ 10 + η) : + (∑' x, (selectedResidueDensityPMF modulus G V hV hZ D hD0 hD x).toReal * + (if stride ^ 2 * (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x then 1 else 0)) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + have hprescribed := selectedResidueDensityPMF_prescribed_badPrimeProduct + modulus G V hV hZ D hD0 hD S A (fun p => 2 * stride.factorization p) bad + hprime hQs hQ hR hdepth hη hjoint + let w := selectedResidueTiltedFiniteLaw modulus G V hV hZ D hD0 hD + have hmono := w.eventProbability_mono + (fun x => stride ^ 2 * (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x.val) + (fun x => (∏ p ∈ S, p ^ (2 * stride.factorization p)) * + (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x.val) + (fun _ hx => (Nat.mul_le_mul_right _ + (selected_double_factorization_product_le S hstride)).trans_lt hx) + dsimp only [w] at hmono + rw [selectedResidueTiltedFiniteLaw_event modulus G V hV hZ D hD0 hD + (fun x => stride ^ 2 * (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x), + selectedResidueTiltedFiniteLaw_event modulus G V hV hZ D hD0 hD + (fun x => (∏ p ∈ S, p ^ (2 * stride.factorization p)) * + (smallPrimePowerCorrection Qs * R) < + ∏ p ∈ S, p ^ largestTestedBadDepth A bad p x)] at hmono + refine le_trans ?_ hprescribed + convert hmono using 1 <;> first | rfl | (apply tsum_congr; intro x; split_ifs <;> rfl) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/SupportedQuotientLatticeFaithful.lean b/lean/OAI/Combinatorics/Progressions/Lattices/SupportedQuotientLatticeFaithful.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c1d165ed2d4f28ac30175396feb3e4cf718359e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/SupportedQuotientLatticeFaithful.lean @@ -0,0 +1,148 @@ +import OAI.Combinatorics.Progressions.Estimates.CosetPairInjective +import OAI.Combinatorics.Progressions.Geometry.RealSupportedQuotientCoordinates +import OAI.Combinatorics.Progressions.Sampling.SupportedQuotientExactGrid + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem mem_realification_integral_lattice_iff (b : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (N : ℕ) + (hgrid : bchSubgroupCoordinates b Γ = scaledIntegerGrid N) + (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) : + g ∈ Γ.map realificationHom ↔ + ∃ z : ι → ℤ, ∀ i, (b.baseChange ℝ).repr g.coord i = (N : ℝ) * (z i : ℝ) := by + constructor + · intro hg + obtain ⟨a, ha, rfl⟩ := Subgroup.mem_map.mp hg + have hc := (bchSubgroupCoordinates_repr b Γ a).mpr ha + rw [hgrid] at hc + obtain ⟨z, hz⟩ := hc + refine ⟨z, fun i => ?_⟩ + rw [← Basis.equivFun_apply, realificationHom_coordinates] + have hi := congrFun hz i + change b.repr a.coord i = (N : ℚ) * (z i : ℚ) at hi + change (b.repr a.coord i : ℝ) = _ + rw [hi] + push_cast + rfl + · rintro ⟨z, hz⟩ + let a : NilpotentLieBCHGroup L s hnil := + ⟨b.equivFun.symm (fun i => (N : ℚ) * (z i : ℚ))⟩ + have ha : a ∈ Γ := by + apply (bchSubgroupCoordinates_repr b Γ a).mp + rw [hgrid] + change b.equivFun (b.equivFun.symm _) ∈ scaledIntegerGrid N + rw [LinearEquiv.apply_symm_apply] + exact ⟨z, rfl⟩ + refine Subgroup.mem_map.mpr ⟨a, ha, ?_⟩ + apply NilpotentLieBCHGroup.ext + apply (b.baseChange ℝ).equivFun.injective + rw [realificationHom_coordinates] + funext i + change (b.equivFun (b.equivFun.symm _) i : ℝ) = _ + rw [LinearEquiv.apply_symm_apply] + push_cast + exact (hz i).symm + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype ι] {s t u : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) + (I : LieIdeal ℚ L) (hI : F.layer (t + 1) ≤ I.toSubmodule) + (S : Set ι) [DecidablePred (· ∈ S)] + (hspan : I.toSubmodule = Submodule.span ℚ (b '' S)) + +include hspan in +theorem realQuotientStep_integral_coordinates (Γ : Subgroup F.Group) (N : ℕ) + (hgrid : bchSubgroupCoordinates b Γ = scaledIntegerGrid N) + (g : F.realification.Group) + (hg : F.realQuotientStepHom I hI g ∈ + (Γ.map (F.quotientStepHom I hI)).map realificationHom) : + ∃ z : {i // i ∉ S} → ℤ, ∀ i : {i // i ∉ S}, + (b.baseChange ℝ).repr g.coord i = (N : ℝ) * (z i : ℝ) := by + let bq : Basis {i // i ∉ S} ℚ (L ⧸ I) := supportedQuotientBasis b I.toSubmodule S hspan + have hq : bchSubgroupCoordinates bq (Γ.map (F.quotientStepHom I hI)) = scaledIntegerGrid N := + F.quotientStep_exact_grid_supported b I hI S hspan Γ N hgrid + obtain ⟨z, hz⟩ := (mem_realification_integral_lattice_iff (L := L ⧸ I) + (hnil := (F.quotientLie I hI).lowerCentralSeries_eq_bot) bq + (Γ.map (F.quotientStepHom I hI)) N hq (F.realQuotientStepHom I hI g)).mp hg + refine ⟨z, fun i => ?_⟩ + have hi := hz i + change ((supportedQuotientBasis b I.toSubmodule S hspan).baseChange ℝ).repr + (I.toSubmodule.mkQ.baseChange ℝ g.coord) i = _ at hi + rwa [realSupportedQuotientBasis_repr_mk] at hi + +theorem realQuotientStep_lattice_le (Γ : Subgroup F.Group) : + Γ.map realificationHom ≤ + ((Γ.map (F.quotientStepHom I hI)).map realificationHom).comap + (F.realQuotientStepHom I hI) := by + rw [F.realQuotientStepHom_lattice] + exact Subgroup.le_comap_map (F.realQuotientStepHom I hI) (Γ.map realificationHom) + +noncomputable def realQuotientCosetMap (Γ : Subgroup F.Group) : + (F.realification.Group ⧸ Γ.map realificationHom) → + ((F.quotientLie I hI).realification.Group ⧸ + (Γ.map (F.quotientStepHom I hI)).map realificationHom) := + cosetMap _ _ (F.realQuotientStepHom I hI) (F.realQuotientStep_lattice_le I hI Γ) + +include hspan in +theorem realQuotientPair_lattice_detect + (J : LieIdeal ℚ L) (hJ : F.layer (u + 1) ≤ J.toSubmodule) + (T : Set ι) [DecidablePred (· ∈ T)] + (hspanT : J.toSubmodule = Submodule.span ℚ (b '' T)) + (hcover : ∀ i : ι, i ∉ S ∨ i ∉ T) + (Γ : Subgroup F.Group) (N : ℕ) + (hgrid : bchSubgroupCoordinates b Γ = scaledIntegerGrid N) + (g : F.realification.Group) + (hgI : F.realQuotientStepHom I hI g ∈ + (Γ.map (F.quotientStepHom I hI)).map realificationHom) + (hgJ : F.realQuotientStepHom J hJ g ∈ + (Γ.map (F.quotientStepHom J hJ)).map realificationHom) : + g ∈ Γ.map realificationHom := by + classical + obtain ⟨zI, hzI⟩ := F.realQuotientStep_integral_coordinates b I hI S hspan Γ N hgrid g hgI + obtain ⟨zJ, hzJ⟩ := F.realQuotientStep_integral_coordinates b J hJ T hspanT Γ N hgrid g hgJ + apply (mem_realification_integral_lattice_iff b Γ N hgrid g).mpr + let z : ι → ℤ := fun i => if hi : i ∉ S then zI ⟨i, hi⟩ + else zJ ⟨i, (hcover i).resolve_left hi⟩ + refine ⟨z, fun i => ?_⟩ + by_cases hi : i ∉ S + · simpa only [z, dite_eq_left hi] using hzI ⟨i, hi⟩ + · simpa only [z, dite_eq_right hi] using hzJ ⟨i, (hcover i).resolve_left hi⟩ + +include hspan in +theorem realQuotientCosetPair_injective + (J : LieIdeal ℚ L) (hJ : F.layer (u + 1) ≤ J.toSubmodule) + (T : Set ι) [DecidablePred (· ∈ T)] + (hspanT : J.toSubmodule = Submodule.span ℚ (b '' T)) + (hcover : ∀ i : ι, i ∉ S ∨ i ∉ T) + (Γ : Subgroup F.Group) (N : ℕ) + (hgrid : bchSubgroupCoordinates b Γ = scaledIntegerGrid N) : + Function.Injective (fun x => + (F.realQuotientCosetMap I hI Γ x, F.realQuotientCosetMap J hJ Γ x)) := + cosetPairMap_injective _ _ _ _ _ _ _ + (F.realQuotientPair_lattice_detect b I hI S hspan J hJ T hspanT hcover Γ N hgrid) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/TopInvariantIntegerExpansion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/TopInvariantIntegerExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..347c66ac5a5000ad69891799be5a4b615b0a4c6f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/TopInvariantIntegerExpansion.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformFrozenDescent + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +theorem exists_topInvariant_integer_expansion (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type} {σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) {w : σ → ℕ} + (T : D.Niltest w) {p : ℝ}, 0 ≤ p → T.ComplexityLE p → + (∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = T.observable x) → + Nonempty (NativeIntegerExpansion w s ((p + C) ^ C) T.eval) := by + obtain ⟨a, _, hdescent⟩ := exists_topInvariant_niltest_budget s + let X : Polynomial ℕ := Polynomial.X + let R := (X + 3) ^ 11 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((R + Polynomial.C a) ^ a) + refine ⟨C, hC, ?_⟩ + intro L σ _ _ _ _ _ _ d D w T p hp hT hinv + let q := (p + 3) ^ 11 + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + apply (show p ≤ p + 3 by linarith).trans + simpa only [pow_one] using pow_le_pow_right₀ + (by linarith : (1 : ℝ) ≤ p + 3) (by decide : 1 ≤ 11) + obtain ⟨n, _, Q, hQF, hQL, hQ, he, _⟩ := D.exists_controlled_top_quotient hp hT.1 + have heq : ∀ i j, rationalLogHeight (Q.basis.repr + (lieQuotientMap (D.filtration.layerIdeal (s + 1)) (D.basis j)) i) ≤ q := by + intro i j + apply (he j i).trans + exact pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + 3) (by decide : 5 ≤ 11) + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ D.filtration.layerIdeal (s + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ D.filtration.layerIdeal (s + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (L ⧸ D.filtration.layerIdeal (s + 1))) := + realification_moduleTopology_t2 Q.basis + obtain ⟨S, _, _, hS, hSe⟩ := hdescent D Q hQF hQL T q hq (hT.mono hpq) hQ heq hinv + have hfinal : (q + a) ^ a ≤ (p + C) ^ C := by + simpa [X, R, q, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨NativeIntegerExpansion.ofTest S (hS.mono hfinal) (fun x => (hSe x).symm)⟩ + +noncomputable def topInvariantIntegerExponent (s : ℕ) : ℕ := + (exists_topInvariant_integer_expansion.{0} s).choose + +theorem topInvariant_integer_expansion {L σ : Type} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) {w : σ → ℕ} + (T : D.Niltest w) {p : ℝ} (hp : 0 ≤ p) (hT : T.ComplexityLE p) + (hinv : ∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = T.observable x) : + Nonempty (NativeIntegerExpansion w s + ((p + topInvariantIntegerExponent s) ^ topInvariantIntegerExponent s) T.eval) := + (exists_topInvariant_integer_expansion s).choose_spec.2 D T hp hT hinv + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/TranslationIntegerReduction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/TranslationIntegerReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..35b8cb6602827aa03df726ead2eb894cae55dabc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/TranslationIntegerReduction.lean @@ -0,0 +1,128 @@ +import Mathlib.Algebra.Order.Floor.Ring +import OAI.Combinatorics.Progressions.Geometry.TopSupportSubstitution +import OAI.Combinatorics.Progressions.Polynomial.PolynomialTranslationActionCompatibility + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators + +variable {B : Type*} + +noncomputable def integerFloorPolynomial (P : MvPolynomial B ℝ) : MvPolynomial B ℤ := + ∑ α ∈ P.support, monomial α ⌊P.coeff α⌋ + +@[simp] theorem coeff_integerFloorPolynomial (P : MvPolynomial B ℝ) (α : B →₀ ℕ) : + (integerFloorPolynomial P).coeff α = ⌊P.coeff α⌋ := by + classical + by_cases hα : α ∈ P.support + · simp [integerFloorPolynomial, coeff_monomial, hα] + · have hzero : P.coeff α = 0 := by + by_contra hn + exact hα (mem_support_iff.mpr hn) + simp [integerFloorPolynomial, coeff_monomial, hα, hzero] + +theorem integerFloorPolynomial_support_subset (P : MvPolynomial B ℝ) : + (integerFloorPolynomial P).support ⊆ P.support := by + intro α hα + rw [mem_support_iff, coeff_integerFloorPolynomial] at hα + apply mem_support_iff.mpr + intro hz + exact hα (by rw [hz, Int.floor_zero]) + +theorem integerFloorPolynomial_mem_weightedSupportLT (w : B → ℕ) (d : ℕ) + {P : MvPolynomial B ℝ} (hP : P ∈ weightedSupportLT w d) : + integerFloorPolynomial P ∈ weightedSupportLT w d := + fun _ hα => hP (integerFloorPolynomial_support_subset P hα) + +theorem polynomialTranslate_mem_weightedSupportLT {R : Type*} [CommRing R] + (h : B → R) (w : B → ℕ) (d : ℕ) + {P : MvPolynomial B R} (hP : P ∈ weightedSupportLT w d) : + polynomialTranslate h P ∈ weightedSupportLT w d := by + exact weightedSupportLT_aeval w w (fun i => X i + C (h i)) + (fun i => (weightedSupportLE w (w i)).add_mem + (weightedSupportLE_X w i) (weightedSupportLE_C w (w i) (h i))) hP + +namespace PolynomialTranslationGroupOver + +noncomputable def integerReduction (g : PolynomialTranslationGroupOver ℝ B) : + PolynomialTranslationGroupOver ℤ B where + base i := -⌊g.base i⌋ + polynomial := -integerFloorPolynomial + (polynomialTranslate (fun i => (⌊g.base i⌋ : ℝ)) g.polynomial) + +@[simp] theorem integerReduction_base (g : PolynomialTranslationGroupOver ℝ B) (i : B) : + (integerReduction g).base i = -⌊g.base i⌋ := rfl + +theorem integerReduction_product_base (g : PolynomialTranslationGroupOver ℝ B) (i : B) : + (g * map (Int.castRingHom ℝ) (integerReduction g)).base i = Int.fract (g.base i) := by + change g.base i + ((-⌊g.base i⌋ : ℤ) : ℝ) = _ + rw [Int.cast_neg] + rfl + +theorem integerReduction_product_polynomial (g : PolynomialTranslationGroupOver ℝ B) : + (g * map (Int.castRingHom ℝ) (integerReduction g)).polynomial = + let P := polynomialTranslate (fun i => (⌊g.base i⌋ : ℝ)) g.polynomial + P - MvPolynomial.map (Int.castRingHom ℝ) (integerFloorPolynomial P) := by + simp only [polynomial_mul, map_polynomial, integerReduction, map_neg, sub_eq_add_neg] + congr 1 + change polynomialTranslate (fun i => -((-⌊g.base i⌋ : ℤ) : ℝ)) g.polynomial = _ + simp only [Int.cast_neg, neg_neg] + +theorem integerReduction_product_coefficient + (g : PolynomialTranslationGroupOver ℝ B) (α : B →₀ ℕ) : + (g * map (Int.castRingHom ℝ) (integerReduction g)).polynomial.coeff α = + Int.fract ((polynomialTranslate (fun i => (⌊g.base i⌋ : ℝ)) g.polynomial).coeff α) := by + rw [integerReduction_product_polynomial] + simp only [coeff_sub, coeff_map, coeff_integerFloorPolynomial] + rfl + +theorem integerReduction_product_bounds (g : PolynomialTranslationGroupOver ℝ B) : + (∀ i, 0 ≤ (g * map (Int.castRingHom ℝ) (integerReduction g)).base i ∧ + (g * map (Int.castRingHom ℝ) (integerReduction g)).base i < 1) ∧ + ∀ α, 0 ≤ (g * map (Int.castRingHom ℝ) (integerReduction g)).polynomial.coeff α ∧ + (g * map (Int.castRingHom ℝ) (integerReduction g)).polynomial.coeff α < 1 := by + constructor + · intro i + rw [integerReduction_product_base] + exact ⟨Int.fract_nonneg _, Int.fract_lt_one _⟩ + · intro α + rw [integerReduction_product_coefficient] + exact ⟨Int.fract_nonneg _, Int.fract_lt_one _⟩ + +theorem integerReduction_weightedSupportLT (g : PolynomialTranslationGroupOver ℝ B) + (w : B → ℕ) (d : ℕ) (hg : g.polynomial ∈ weightedSupportLT w d) : + (integerReduction g).polynomial ∈ weightedSupportLT w d ∧ + (g * map (Int.castRingHom ℝ) (integerReduction g)).polynomial ∈ weightedSupportLT w d := by + let P := polynomialTranslate (fun i => (⌊g.base i⌋ : ℝ)) g.polynomial + have hP : P ∈ weightedSupportLT w d := polynomialTranslate_mem_weightedSupportLT _ w d hg + have hfloor := integerFloorPolynomial_mem_weightedSupportLT w d hP + refine ⟨(weightedSupportLT w d).neg_mem hfloor, ?_⟩ + rw [integerReduction_product_polynomial] + apply (weightedSupportLT w d).sub_mem hP + intro α hα + exact hfloor (MvPolynomial.support_map_subset (Int.castRingHom ℝ) _ hα) + +theorem exists_integer_reduction (g : PolynomialTranslationGroupOver ℝ B) + (w : B → ℕ) (d : ℕ) (hg : g.polynomial ∈ weightedSupportLT w d) : + ∃ γ : PolynomialTranslationGroupOver ℤ B, + (∀ i, 0 ≤ (g * map (Int.castRingHom ℝ) γ).base i ∧ + (g * map (Int.castRingHom ℝ) γ).base i < 1) ∧ + (∀ α, 0 ≤ (g * map (Int.castRingHom ℝ) γ).polynomial.coeff α ∧ + (g * map (Int.castRingHom ℝ) γ).polynomial.coeff α < 1) ∧ + γ.polynomial ∈ weightedSupportLT w d ∧ + (g * map (Int.castRingHom ℝ) γ).polynomial ∈ weightedSupportLT w d := + ⟨integerReduction g, (integerReduction_product_bounds g).1, + (integerReduction_product_bounds g).2, integerReduction_weightedSupportLT g w d hg⟩ + +end PolynomialTranslationGroupOver + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/TriangularAffineReset.lean b/lean/OAI/Combinatorics/Progressions/Lattices/TriangularAffineReset.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a00970a7683f46dca2e04d1fdb02d40e0e9c157 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/TriangularAffineReset.lean @@ -0,0 +1,348 @@ +import OAI.Combinatorics.Progressions.Estimates.SeparatedPositiveSum +import OAI.Combinatorics.Progressions.Fourier.AffineTorusDensityIncrement +import OAI.Combinatorics.Progressions.Polynomial.LowestPolynomialLayer + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {d : ℕ} + +theorem earlierSlotMatrix_apply_lt {R : Type*} [CommRing R] + (m : (i : Fin d) → Fin i.val → R) (i j : Fin d) (hji : j < i) : + earlierSlotMatrix m i j = m i ⟨j.val, hji⟩ := by + classical + unfold earlierSlotMatrix + rw [Finset.sum_eq_single (⟨j.val, hji⟩ : Fin i.val)] + · simp [earlierSlot] + · intro k _ hk + apply ite_eq_right + intro heq + apply hk + exact Fin.ext (congrArg (fun t : Fin d => t.val) heq) + · simp + +theorem unitLower_mulVec {R : Type*} [CommRing R] + (T : Matrix (Fin d) (Fin d) R) (htri : T.IsLowerTriangular) + (hdiag : ∀ i, T i i = 1) (v : Fin d → R) (i : Fin d) : + T.mulVec v i = v i + ∑ k : Fin i.val, T i (earlierSlot i k) * v (earlierSlot i k) := by + classical + have hT : T = 1 + earlierSlotMatrix (fun i k => T i (earlierSlot i k)) := by + ext a b + by_cases hba : b < a + · rw [Matrix.add_apply, Matrix.one_apply_ne hba.ne.symm, + earlierSlotMatrix_apply_lt _ a b hba, zero_add] + rfl + · rw [Matrix.add_apply, earlierSlotMatrix_strict _ a b (le_of_not_gt hba), add_zero] + by_cases hab : a = b + · subst b + simp [hdiag] + · have hablt : a < b := lt_of_le_of_ne (le_of_not_gt hba) hab + rw [htri hablt, Matrix.one_apply_ne hab] + conv_lhs => + rw [hT, Matrix.add_mulVec, Matrix.one_mulVec, Pi.add_apply, earlierSlotMatrix_mulVec] + +noncomputable def reducedLatticeColumn (T : Matrix (Fin d) (Fin d) ℝ) + (j i : Fin d) : ℤ := + if i < j then 0 else if i = j then 1 else + -round (∑ k : Fin i.val, + T i (earlierSlot i k) * (reducedLatticeColumn T j (earlierSlot i k) : ℝ)) +termination_by i.val +decreasing_by exact k.isLt + +noncomputable def triangularReductionMatrix (T : Matrix (Fin d) (Fin d) ℝ) : + Matrix (Fin d) (Fin d) ℤ := fun i j => reducedLatticeColumn T j i + +theorem triangularReductionMatrix_above (T : Matrix (Fin d) (Fin d) ℝ) + (i j : Fin d) (hij : i < j) : triangularReductionMatrix T i j = 0 := by + unfold triangularReductionMatrix + rw [reducedLatticeColumn] + simp only [ite_eq_left hij] + +theorem triangularReductionMatrix_diag (T : Matrix (Fin d) (Fin d) ℝ) + (i : Fin d) : triangularReductionMatrix T i i = 1 := by + unfold triangularReductionMatrix + rw [reducedLatticeColumn] + simp + +theorem triangularReductionMatrix_det (T : Matrix (Fin d) (Fin d) ℝ) : + (triangularReductionMatrix T).det = 1 := by + rw [Matrix.det_of_isLowerTriangular _ (triangularReductionMatrix_above T)] + exact Finset.prod_eq_one (fun i _ => triangularReductionMatrix_diag T i) + +noncomputable def reducedTriangularMatrix (T : Matrix (Fin d) (Fin d) ℝ) : + Matrix (Fin d) (Fin d) ℝ := + T * (triangularReductionMatrix T).map (Int.castRingHom ℝ) + +theorem reducedTriangularMatrix_entry (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) (i j : Fin d) : + reducedTriangularMatrix T i j = (triangularReductionMatrix T i j : ℝ) + + ∑ k : Fin i.val, T i (earlierSlot i k) * + (triangularReductionMatrix T (earlierSlot i k) j : ℝ) := by + exact unitLower_mulVec T htri hdiag (fun k => (triangularReductionMatrix T k j : ℝ)) i + +theorem reducedTriangularMatrix_above (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) (i j : Fin d) + (hij : i < j) : reducedTriangularMatrix T i j = 0 := by + rw [reducedTriangularMatrix_entry T htri hdiag, + triangularReductionMatrix_above T i j hij, Int.cast_zero, zero_add] + apply Finset.sum_eq_zero + intro k _ + rw [triangularReductionMatrix_above T (earlierSlot i k) j + (lt_trans (show earlierSlot i k < i from k.isLt) hij), Int.cast_zero, mul_zero] + +theorem reducedTriangularMatrix_diag (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) (i : Fin d) : + reducedTriangularMatrix T i i = 1 := by + rw [reducedTriangularMatrix_entry T htri hdiag, triangularReductionMatrix_diag, + Int.cast_one] + have hz : (∑ k : Fin i.val, T i (earlierSlot i k) * + (triangularReductionMatrix T (earlierSlot i k) i : ℝ)) = 0 := by + apply Finset.sum_eq_zero + intro k _ + rw [triangularReductionMatrix_above T (earlierSlot i k) i k.isLt, + Int.cast_zero, mul_zero] + rw [hz, add_zero] + +theorem reducedTriangularMatrix_lower_bound (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) (i j : Fin d) + (hji : j < i) : |reducedTriangularMatrix T i j| ≤ 1 / 2 := by + rw [reducedTriangularMatrix_entry T htri hdiag] + have hu : triangularReductionMatrix T i j = + -round (∑ k : Fin i.val, T i (earlierSlot i k) * + (triangularReductionMatrix T (earlierSlot i k) j : ℝ)) := by + unfold triangularReductionMatrix + rw [reducedLatticeColumn] + simp only [ite_eq_right (not_lt_of_ge hji.le), ite_eq_right hji.ne.symm] + rw [hu, Int.cast_neg, neg_add_eq_sub] + exact abs_sub_round _ + +theorem reducedTriangularMatrix_bound (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) (i j : Fin d) : + |reducedTriangularMatrix T i j| ≤ 1 := by + rcases lt_trichotomy i j with h | h | h + · simp [reducedTriangularMatrix_above T htri hdiag i j h] + · subst j + simp [reducedTriangularMatrix_diag T htri hdiag] + · exact (reducedTriangularMatrix_lower_bound T htri hdiag i j h).trans (by norm_num) + +noncomputable def integerMatrixEquiv (U : Matrix (Fin d) (Fin d) ℤ) + (hU : IsUnit U.det) : (Fin d → ℤ) ≃ (Fin d → ℤ) where + toFun := U.mulVec + invFun := U⁻¹.mulVec + left_inv z := by rw [Matrix.mulVec_mulVec, Matrix.nonsing_inv_mul _ hU, Matrix.one_mulVec] + right_inv z := by rw [Matrix.mulVec_mulVec, Matrix.mul_nonsing_inv _ hU, Matrix.one_mulVec] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal BigOperators + +variable {d : ℕ} + +theorem one_sub_unitLower_strict (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) + (i j : Fin d) (hij : i ≤ j) : (1 - T) i j = 0 := by + rcases eq_or_lt_of_le hij with h | h + · subst j + simp [Matrix.sub_apply, hdiag] + · simp [Matrix.sub_apply, htri h, Matrix.one_apply_ne h.ne] + +noncomputable def TriangularSlots.unitLowerBlock (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) (x : Fin d → ℝ) : + TriangularSlots d := + TriangularSlots.affineBlock (1 - T) (one_sub_unitLower_strict T htri hdiag) x + +theorem TriangularSlots.unitLowerBlock_residual (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) + (x : Fin d → ℝ) (b : Fin d → ℤ) : + (unitLowerBlock T htri hdiag x).residual b = T.mulVec ((fun i => (b i : ℝ)) - x) := by + rw [unitLowerBlock, affineBlock_residual] + have hT : (1 : Matrix (Fin d) (Fin d) ℝ) - (1 - T) = T := by abel + rw [hT] + +noncomputable def triangularLatticeValue (T : Matrix (Fin d) (Fin d) ℝ) + (Φ : PatchKernel d) (x : Fin d → ℝ) : ℝ := + ∑' b : Fin d → ℤ, Φ.value (T.mulVec ((fun i => (b i : ℝ)) - x)) + +theorem triangularLatticeValue_eq_patchValue (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) + (Φ : PatchKernel d) (x : Fin d → ℝ) : + triangularLatticeValue T Φ x = (TriangularSlots.unitLowerBlock T htri hdiag x).patchValue Φ := by + simp only [triangularLatticeValue, TriangularSlots.patchValue, + TriangularSlots.unitLowerBlock_residual] + +theorem triangularLatticeValue_mem_Icc (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) + (Φ : PatchKernel d) (x : Fin d → ℝ) : + triangularLatticeValue T Φ x ∈ Set.Icc (0 : ℝ) 1 := by + rw [triangularLatticeValue_eq_patchValue T htri hdiag] + exact TriangularSlots.patchValue_mem_Icc _ _ + +theorem bounded_matrix_mulVec_lipschitz (T : Matrix (Fin d) (Fin d) ℝ) + (hT : ∀ i j, |T i j| ≤ 1) : LipschitzWith (d : ℝ≥0) T.mulVec := by + apply LipschitzWith.of_dist_le_mul + intro x y + change dist (T.mulVec x) (T.mulVec y) ≤ (d : ℝ) * dist x y + apply (dist_pi_le_iff (mul_nonneg (Nat.cast_nonneg d) dist_nonneg)).mpr + intro i + simp only [Real.dist_eq, Matrix.mulVec, dotProduct] + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j, |T i j * x j - T i j * y j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : Fin d, dist x y := by + apply Finset.sum_le_sum + intro j _ + rw [← mul_sub, abs_mul] + have hj : |x j - y j| ≤ dist x y := by + simpa only [Real.dist_eq] using dist_le_pi_dist x y j + exact (mul_le_mul (hT i j) hj (abs_nonneg _) zero_le_one).trans_eq (one_mul _) + _ = (d : ℝ) * dist x y := by simp + +theorem triangularLatticeValue_lipschitz (T : Matrix (Fin d) (Fin d) ℝ) + (htri : T.IsLowerTriangular) (hdiag : ∀ i, T i i = 1) + (hT : ∀ i j, |T i j| ≤ 1) (Φ : PatchKernel d) : + LipschitzWith (Φ.lip * d) (triangularLatticeValue T Φ) := by + apply separated_tsum_lipschitz + · intro b + apply LipschitzWith.of_dist_le_mul + intro x y + calc + _ ≤ (Φ.lip : ℝ) * dist (T.mulVec ((fun i => (b i : ℝ)) - x)) + (T.mulVec ((fun i => (b i : ℝ)) - y)) := Φ.lipschitz.dist_le_mul _ _ + _ ≤ (Φ.lip : ℝ) * ((d : ℝ) * dist ((fun i => (b i : ℝ)) - x) + ((fun i => (b i : ℝ)) - y)) := mul_le_mul_of_nonneg_left + ((bounded_matrix_mulVec_lipschitz T hT).dist_le_mul _ _) Φ.lip.coe_nonneg + _ = _ := by rw [dist_sub_left, NNReal.coe_mul, NNReal.coe_natCast]; ring + · intro b x + exact Φ.nonneg _ + · intro x b c hb hc + apply (TriangularSlots.unitLowerBlock T htri hdiag x).contributing_unique Φ + · simpa only [TriangularSlots.unitLowerBlock_residual] using hb + · simpa only [TriangularSlots.unitLowerBlock_residual] using hc + +theorem triangularLatticeValue_integer_periodic (T : Matrix (Fin d) (Fin d) ℝ) + (Φ : PatchKernel d) (x : Fin d → ℝ) (m : Fin d → ℤ) : + triangularLatticeValue T Φ (fun i => x i + m i) = triangularLatticeValue T Φ x := by + unfold triangularLatticeValue + have heq := (Equiv.addRight m).tsum_eq + (fun b : Fin d → ℤ => Φ.value (T.mulVec + ((fun i => (b i : ℝ)) - (fun i => x i + m i)))) + refine heq.symm.trans (tsum_congr fun b => ?_) + apply congrArg (fun v => Φ.value (T.mulVec v)) + funext i + change ((b i + m i : ℤ) : ℝ) - (x i + m i) = (b i : ℝ) - x i + push_cast + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal BigOperators + +variable {d : ℕ} + +theorem integerMatrixEquiv_cast (U : Matrix (Fin d) (Fin d) ℤ) + (hU : IsUnit U.det) (z : Fin d → ℤ) : + (fun i => (integerMatrixEquiv U hU z i : ℝ)) = + (U.map (Int.castRingHom ℝ)).mulVec (fun i => (z i : ℝ)) := by + ext i + exact RingHom.map_mulVec (Int.castRingHom ℝ) U z i + +theorem integerMatrix_cast_mul_inv (U : Matrix (Fin d) (Fin d) ℤ) + (hU : IsUnit U.det) : + U.map (Int.castRingHom ℝ) * U⁻¹.map (Int.castRingHom ℝ) = 1 := by + rw [← Matrix.map_mul, Matrix.mul_nonsing_inv U hU] + exact Matrix.map_one _ (map_zero (Int.castRingHom ℝ)) (map_one (Int.castRingHom ℝ)) + +theorem integer_basis_change_residual (T : Matrix (Fin d) (Fin d) ℝ) + (U : Matrix (Fin d) (Fin d) ℤ) (hU : IsUnit U.det) + (x : Fin d → ℝ) (z : Fin d → ℤ) : + (T * U.map (Int.castRingHom ℝ)).mulVec + ((fun i => (z i : ℝ)) - (U⁻¹.map (Int.castRingHom ℝ)).mulVec x) = + T.mulVec ((fun i => (integerMatrixEquiv U hU z i : ℝ)) - x) := by + rw [← Matrix.mulVec_mulVec, Matrix.mulVec_sub, Matrix.mulVec_mulVec, + integerMatrix_cast_mul_inv U hU, Matrix.one_mulVec, integerMatrixEquiv_cast] + +theorem real_basis_change_residual (T : Matrix (Fin d) (Fin d) ℝ) + (U : Matrix (Fin d) (Fin d) ℤ) (hU : IsUnit U.det) (x y : Fin d → ℝ) : + T.mulVec (x - (U.map (Int.castRingHom ℝ)).mulVec y) = + (T * U.map (Int.castRingHom ℝ)).mulVec + ((U⁻¹.map (Int.castRingHom ℝ)).mulVec x - y) := by + conv_rhs => + rw [← Matrix.mulVec_mulVec, Matrix.mulVec_sub, Matrix.mulVec_mulVec, + integerMatrix_cast_mul_inv U hU, Matrix.one_mulVec] + +theorem triangularLatticeValue_change_basis (T : Matrix (Fin d) (Fin d) ℝ) + (U : Matrix (Fin d) (Fin d) ℤ) (hU : IsUnit U.det) + (Φ : PatchKernel d) (x : Fin d → ℝ) : + triangularLatticeValue T Φ x = + triangularLatticeValue (T * U.map (Int.castRingHom ℝ)) Φ + ((U⁻¹.map (Int.castRingHom ℝ)).mulVec x) := by + unfold triangularLatticeValue + have heq := (integerMatrixEquiv U hU).tsum_eq + (fun b : Fin d → ℤ => Φ.value (T.mulVec ((fun i => (b i : ℝ)) - x))) + refine heq.symm.trans (tsum_congr fun z => ?_) + exact congrArg Φ.value (integer_basis_change_residual T U hU x z).symm + +theorem matrix_mulVec_affine (V : Matrix (Fin d) (Fin d) ℝ) + (alpha beta : Fin d → ℝ) (t : ℝ) : + V.mulVec (fun i => t * alpha i + beta i) = + fun i => t * V.mulVec alpha i + V.mulVec beta i := by + change V.mulVec (t • alpha + beta) = t • V.mulVec alpha + V.mulVec beta + rw [Matrix.mulVec_add, Matrix.mulVec_smul] + +theorem triangular_affine_density_increment + (T : Matrix (Fin d) (Fin d) ℝ) (htri : T.IsLowerTriangular) + (hdiag : ∀ i, T i i = 1) (Φ : PatchKernel d) + {N H : ℕ} (hH : 0 < H) (hsize : H ^ (2 * d + 1) ≤ N) + (alpha beta : Fin d → ℝ) (f : ℕ → ℝ) + (hf : ∀ n < N, f n ∈ Set.Icc (0 : ℝ) 1) + {b σ : ℝ} (hb : b ∈ Set.Icc (0 : ℝ) 1) (hσ : 0 < σ) + (hsmall : 4 * ((Φ.lip : ℝ) * d) ≤ σ * H) + (hscore : σ ≤ 𝔼 n : Fin N, + (f n.val - b) * triangularLatticeValue T Φ + (fun i => (n.val : ℝ) * alpha i + beta i)) : + ∃ q a len : ℕ, 0 < q ∧ q ≤ H ^ (2 * d) ∧ + σ * H / 4 ≤ len ∧ len ≤ H ∧ (∀ j < len, a + q * j < N) ∧ + b < 𝔼 j : Fin len, f (a + q * j.val) := by + let U := triangularReductionMatrix T + let V := U⁻¹.map (Int.castRingHom ℝ) + let B := reducedTriangularMatrix T + have hU : IsUnit U.det := by rw [triangularReductionMatrix_det]; exact isUnit_one + have hBtri : B.IsLowerTriangular := reducedTriangularMatrix_above T htri hdiag + have hBdiag : ∀ i, B i i = 1 := reducedTriangularMatrix_diag T htri hdiag + have hBbound : ∀ i j, |B i j| ≤ 1 := reducedTriangularMatrix_bound T htri hdiag + have hvalue (t : ℝ) : triangularLatticeValue T Φ (fun i => t * alpha i + beta i) = + triangularLatticeValue B Φ (fun i => t * V.mulVec alpha i + V.mulVec beta i) := by + rw [triangularLatticeValue_change_basis T U hU Φ, matrix_mulVec_affine] + rfl + have hscore' : σ ≤ 𝔼 n : Fin N, (f n.val - b) * + triangularLatticeValue B Φ (fun i => (n.val : ℝ) * V.mulVec alpha i + V.mulVec beta i) := by + simpa only [hvalue] using hscore + simpa only [Fintype.card_fin] using affine_torus_density_increment hH + (by simpa only [Fintype.card_fin] using hsize) (V.mulVec alpha) (V.mulVec beta) f + (triangularLatticeValue_lipschitz B hBtri hBdiag hBbound Φ) + (triangularLatticeValue_integer_periodic B Φ) + (triangularLatticeValue_mem_Icc B hBtri hBdiag Φ) hf hb hσ + (by simpa only [NNReal.coe_mul, NNReal.coe_natCast] using hsmall) hscore' + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/TriangularIntegerLift.lean b/lean/OAI/Combinatorics/Progressions/Lattices/TriangularIntegerLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac451ea2fa716d373c0ed7efb50db0a6fd820c15 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/TriangularIntegerLift.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialPatchProductBudget +import OAI.Combinatorics.Progressions.Polynomial.SingleParameterPolynomial + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +namespace PolynomialSlots + +variable {d : ℕ} {w : Fin d → ℕ} + +noncomputable def liftCenter (A : PolynomialSlots Unit d w) (i : Fin d) + (I : Fin i.val → MvPolynomial Unit ℝ) : MvPolynomial Unit ℝ := + aeval (Sum.elim X I) (A.center i) + +theorem liftCenter_degree (A : PolynomialSlots Unit d w) (i : Fin d) + (I : Fin i.val → MvPolynomial Unit ℝ) + (hI : ∀ j, I j ∈ weightedSupportLE (fun _ : Unit => 1) (w (earlierSlot i j))) : + A.liftCenter i I ∈ weightedSupportLE (fun _ : Unit => 1) (w i) := by + apply weightedSupportLE_aeval (patchVariableWeight w i) (fun _ : Unit => 1) + · intro v + cases v with + | inl a => exact weightedSupportLE_X _ a + | inr j => exact hI j + · exact A.degree i + +theorem liftCenter_eval (A : PolynomialSlots Unit d w) (i : Fin d) + (I : Fin i.val → MvPolynomial Unit ℝ) (t : Unit → ℝ) (b : Fin d → ℤ) + (hI : ∀ j, aeval t (I j) = (b (earlierSlot i j) : ℝ)) : + aeval t (A.liftCenter i I) = (A.slots t).center (fun j => (b j : ℝ)) i := by + simp only [liftCenter, MvPolynomial.comp_aeval_apply, slots] + apply congrArg (fun f : Unit ⊕ Fin i.val → ℝ => aeval f (A.center i)) + funext v + cases v with + | inl a => simp + | inr j => exact hI j + +theorem exists_integer_lifts_of_small_residuals (A : PolynomialSlots Unit d w) + (g : ℕ → Fin d → ℤ) (z : Fin d → ℝ) {N : ℕ} {ε : ℝ} + (hsmall : ∀ i, (2 : ℝ) ^ (w i + 1) * ε < 1) + (happrox : ∀ n < N, ∀ i, + ‖(A.slots (fun _ => (n : ℝ))).residual (g n) i - z i‖ ≤ ε) : + ∃ I : Fin d → MvPolynomial Unit ℝ, + (∀ i, I i ∈ weightedSupportLE (fun _ : Unit => 1) (w i)) ∧ + (∀ i (n : ℕ), ∃ a : ℤ, aeval (fun _ => (n : ℝ)) (I i) = a) ∧ + ∀ n < N, ∀ i, aeval (fun _ => (n : ℝ)) (I i) = (g n i : ℝ) := by + classical + have hone : ∀ i : Fin d, ∃ Q : MvPolynomial Unit ℝ, + Q ∈ weightedSupportLE (fun _ : Unit => 1) (w i) ∧ + (∀ n : ℕ, ∃ a : ℤ, aeval (fun _ => (n : ℝ)) Q = a) ∧ + ∀ n < N, aeval (fun _ => (n : ℝ)) Q = (g n i : ℝ) := by + intro i + refine Fin.strong_induction_on (motive := fun i => ∃ Q : MvPolynomial Unit ℝ, + Q ∈ weightedSupportLE (fun _ : Unit => 1) (w i) ∧ + (∀ n : ℕ, ∃ a : ℤ, aeval (fun _ => (n : ℝ)) Q = a) ∧ + ∀ n < N, aeval (fun _ => (n : ℝ)) Q = (g n i : ℝ)) ?_ i + intro i ih + have hprev := fun j : Fin i.val => ih (earlierSlot i j) (show earlierSlot i j < i from j.isLt) + choose I hI hintI heqI using hprev + let P := A.liftCenter i I + C (z i) + have hP : P ∈ weightedSupportLE (fun _ : Unit => 1) (w i) := + (weightedSupportLE _ _).add_mem (A.liftCenter_degree i I hI) (weightedSupportLE_C _ _ _) + have hnear : ∀ n < N, ‖(g n i : ℝ) - aeval (fun _ => (n : ℝ)) P‖ ≤ ε := by + intro n hn + have heval := A.liftCenter_eval i I (fun _ => (n : ℝ)) (g n) + (fun j => heqI j n hn) + simpa only [P, map_add, aeval_C, Algebra.algebraMap_self, RingHom.id_apply, + heval, sub_add_eq_sub_sub, TriangularSlots.residual] using happrox n hn i + obtain ⟨Q, hQ, hint, heq, _⟩ := exists_singleParameter_integer_lift P + (fun n => g n i) hP (hsmall i) hnear + exact ⟨Q, hQ, hint, heq⟩ + choose I hI hint heq using hone + exact ⟨I, hI, hint, fun n hn i => heq i n hn⟩ + +end PolynomialSlots +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/TupleResidueConditioning.lean b/lean/OAI/Combinatorics/Progressions/Lattices/TupleResidueConditioning.lean new file mode 100644 index 0000000000000000000000000000000000000000..9963554d6c3cc25f3463a137ac5e1828fcf638df --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/TupleResidueConditioning.lean @@ -0,0 +1,143 @@ +import OAI.Combinatorics.Progressions.Estimates.IndependentFiniteConditioning +import OAI.Combinatorics.Progressions.Lattices.ResidueRefinedPeriod + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def tupleColumnMatrix {I J : Type*} {Ω : J → Type*} + (c : ∀ j, Ω j → I → ℤ) (x : ∀ j, Ω j) : Matrix I J ℤ := + Matrix.of (fun i j => c j (x j) i) + +noncomputable def columnResidueSet {I X : Type*} [Fintype X] + (c : X → I → ℤ) (m : ℕ) (r : I → ZMod m) : Finset X := by + classical + exact Finset.univ.filter (fun x => integerResidueMap I m (c x) = r) + +theorem mem_columnResidueSet {I X : Type*} [Fintype X] + (c : X → I → ℤ) (m : ℕ) (r : I → ZMod m) (x : X) : + x ∈ columnResidueSet c m r ↔ integerResidueMap I m (c x) = r := by + classical + simp only [columnResidueSet, Finset.mem_filter, Finset.mem_univ, true_and] + +theorem tupleColumnMatrix_residue_iff {I J : Type*} {Ω : J → Type*} [∀ j, Fintype (Ω j)] + (c : ∀ j, Ω j → I → ℤ) (m : ℕ) (r : Matrix I J (ZMod m)) (x : ∀ j, Ω j) : + integerResidueMatrix (tupleColumnMatrix c x) m = r ↔ + ∀ j, x j ∈ columnResidueSet (c j) m (fun i => r i j) := by + simp only [mem_columnResidueSet] + constructor + · intro h j + funext i + exact congrFun (congrFun h i) j + · intro h + ext i j + exact congrFun (h j) i + +theorem tupleColumnMatrix_residue_set {I J : Type*} [Fintype I] [Fintype J] [DecidableEq J] + {Ω : J → Type*} [∀ j, Fintype (Ω j)] [∀ j, DecidableEq (Ω j)] + (c : ∀ j, Ω j → I → ℤ) (m : ℕ) (r : Matrix I J (ZMod m)) : + Finset.univ.filter (fun x => integerResidueMatrix (tupleColumnMatrix c x) m = r) = + FiniteProbabilityWeights.piRestrictionSet (fun j => columnResidueSet (c j) m (fun i => r i j)) := by + classical + ext x + simp only [Finset.mem_filter, Finset.mem_univ, true_and, + FiniteProbabilityWeights.mem_piRestrictionSet, tupleColumnMatrix_residue_iff] + +theorem tupleColumnMatrix_residue_mass {I J : Type*} [Fintype J] [DecidableEq J] + {Ω : J → Type*} [∀ j, Fintype (Ω j)] [∀ j, DecidableEq (Ω j)] + (p : ∀ j, FiniteProbabilityWeights (Ω j)) (c : ∀ j, Ω j → I → ℤ) + (m : ℕ) (r : Matrix I J (ZMod m)) : + (FiniteProbabilityWeights.pi p).mass + (FiniteProbabilityWeights.piRestrictionSet (fun j => columnResidueSet (c j) m (fun i => r i j))) = + ∏ j, (p j).mass (columnResidueSet (c j) m (fun i => r i j)) := + FiniteProbabilityWeights.piRestriction_mass _ _ + +theorem tupleColumnMatrix_residue_condition {I J : Type*} [Fintype J] [DecidableEq J] + {Ω : J → Type*} [∀ j, Fintype (Ω j)] [∀ j, DecidableEq (Ω j)] + (p : ∀ j, FiniteProbabilityWeights (Ω j)) (c : ∀ j, Ω j → I → ℤ) + (m : ℕ) (r : Matrix I J (ZMod m)) + (hr : ∀ j, 0 < (p j).mass (columnResidueSet (c j) m (fun i => r i j))) : + FiniteProbabilityWeights.pi + (fun j => (p j).condition (columnResidueSet (c j) m (fun i => r i j)) (hr j)) = + (FiniteProbabilityWeights.pi p).condition + (FiniteProbabilityWeights.piRestrictionSet (fun j => columnResidueSet (c j) m (fun i => r i j))) + (FiniteProbabilityWeights.piRestriction_mass_pos p _ hr) := + FiniteProbabilityWeights.pi_condition _ _ _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem condition_weight_support {X : Type*} [Fintype X] [DecidableEq X] + (p : FiniteProbabilityWeights X) (G : Finset X) (hG : 0 < p.mass G) + (x : X) (hx : (p.condition G hG).weight x ≠ 0) : x ∈ G ∧ p.weight x ≠ 0 := by + have hm : x ∈ G := by + by_contra hn + exact hx (by simp [FiniteProbabilityWeights.condition, hn]) + refine ⟨hm, ?_⟩ + intro hz + exact hx (by simp [FiniteProbabilityWeights.condition, hz]) + +theorem piRestriction_positive_factors {J : Type*} [Fintype J] [DecidableEq J] + {Ω : J → Type*} [∀ j, Fintype (Ω j)] [∀ j, DecidableEq (Ω j)] + (p : ∀ j, FiniteProbabilityWeights (Ω j)) (G : ∀ j, Finset (Ω j)) + (h : 0 < (FiniteProbabilityWeights.pi p).mass (FiniteProbabilityWeights.piRestrictionSet G)) : + ∀ j, 0 < (p j).mass (G j) := by + intro j + by_contra hn + have hz : (p j).mass (G j) = 0 := le_antisymm (le_of_not_gt hn) ((p j).mass_nonneg _) + have hzero : (∏ j, (p j).mass (G j)) = 0 := Finset.prod_eq_zero (Finset.mem_univ j) hz + rw [FiniteProbabilityWeights.piRestriction_mass, hzero] at h + exact (lt_irrefl 0) h + +theorem tupleResidue_condition_independent {I J : Type*} [Fintype J] [DecidableEq J] + {Ω : J → Type*} [∀ j, Fintype (Ω j)] [∀ j, DecidableEq (Ω j)] + (p : ∀ j, FiniteProbabilityWeights (Ω j)) (c : ∀ j, Ω j → I → ℤ) + (m : ℕ) (r : Matrix I J (ZMod m)) + (h : 0 < (FiniteProbabilityWeights.pi p).mass + (FiniteProbabilityWeights.piRestrictionSet (fun j => columnResidueSet (c j) m (fun i => r i j)))) : + let hr := piRestriction_positive_factors p (fun j => columnResidueSet (c j) m (fun i => r i j)) h + (FiniteProbabilityWeights.pi p).condition + (FiniteProbabilityWeights.piRestrictionSet (fun j => columnResidueSet (c j) m (fun i => r i j))) h = + FiniteProbabilityWeights.pi + (fun j => (p j).condition (columnResidueSet (c j) m (fun i => r i j)) (hr j)) := by + exact (FiniteProbabilityWeights.pi_condition _ _ _).symm + +theorem tupleResidue_condition_support {I J : Type*} [Fintype J] [DecidableEq J] + {Ω : J → Type*} [∀ j, Fintype (Ω j)] [∀ j, DecidableEq (Ω j)] + (p : ∀ j, FiniteProbabilityWeights (Ω j)) (c : ∀ j, Ω j → I → ℤ) + (m : ℕ) (r : Matrix I J (ZMod m)) + (h : 0 < (FiniteProbabilityWeights.pi p).mass + (FiniteProbabilityWeights.piRestrictionSet (fun j => columnResidueSet (c j) m (fun i => r i j)))) + (x : ∀ j, Ω j) + (hx : ((FiniteProbabilityWeights.pi p).condition + (FiniteProbabilityWeights.piRestrictionSet (fun j => columnResidueSet (c j) m (fun i => r i j))) h).weight x ≠ 0) : + integerResidueMatrix (tupleColumnMatrix c x) m = r := by + apply (tupleColumnMatrix_residue_iff c m r x).mpr + exact (FiniteProbabilityWeights.mem_piRestrictionSet _ x).mp + (condition_weight_support _ _ h x hx).1 + +theorem spatialResiduePattern_card (I N : Type*) [Fintype I] [DecidableEq I] + [Fintype N] [DecidableEq N] (m : ℕ) [NeZero m] : + Fintype.card (Matrix (Unit ⊕ I) N (ZMod m)) = m ^ ((Fintype.card I + 1) * Fintype.card N) := by + rw [← Fintype.card_congr (Matrix.of : ((Unit ⊕ I) → N → ZMod m) ≃ Matrix (Unit ⊕ I) N (ZMod m))] + simp only [Fintype.card_fun, ZMod.card, Fintype.card_sum, Fintype.card_unit] + rw [← pow_mul] + congr 1 + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/UnconditionedLatePrimeBudget.lean b/lean/OAI/Combinatorics/Progressions/Lattices/UnconditionedLatePrimeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e905b9d72adb54a84c120250c250b7b2a576103 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/UnconditionedLatePrimeBudget.lean @@ -0,0 +1,130 @@ +import Mathlib.Analysis.SpecialFunctions.Exp +import OAI.Combinatorics.Progressions.Dynamics.UnconditionedWidthExponentialBudget +import OAI.Combinatorics.Progressions.Lattices.ComparableScalarPrimeParameters + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_unconditioned_prime_sides (n₀ : ℕ) {p : ℝ} (hp : 0 ≤ p) : + ∃ P : Fin n₀ → ℕ, (∀ i, (P i).Prime) ∧ Function.Injective P ∧ + (∀ i j, P i ≤ 2 ^ (n₀ + 1) * P j) ∧ + ∀ i, Real.exp p ≤ (P i : ℝ) ∧ (P i : ℝ) ≤ Real.exp (p + (n₀ : ℝ) + 2) := by + let t := ⌈Real.exp p⌉₊ + have hceil : Real.exp p ≤ (t : ℝ) := Nat.le_ceil _ + have ht : 0 < t := by exact_mod_cast (Real.exp_pos p).trans_le hceil + have he1 : (1 : ℝ) ≤ Real.exp p := Real.one_le_exp_iff.mpr hp + have htwo : (2 : ℝ) ≤ Real.exp 1 := by + have h := Real.add_one_le_exp (1 : ℝ) + linarith + have htR : (t : ℝ) ≤ Real.exp (p + 1) := by + calc + _ ≤ Real.exp p + 1 := (Nat.ceil_lt_add_one (Real.exp_nonneg p)).le + _ ≤ Real.exp p * 2 := by linarith + _ ≤ Real.exp p * Real.exp 1 := mul_le_mul_of_nonneg_left htwo (Real.exp_nonneg p) + _ = Real.exp (p + 1) := (Real.exp_add p 1).symm + have hpow : (2 : ℝ) ^ n₀ ≤ Real.exp (n₀ : ℝ) := by + calc + _ ≤ (Real.exp 1) ^ n₀ := pow_le_pow_left₀ (by norm_num) htwo n₀ + _ = _ := by rw [← Real.exp_nat_mul, mul_one] + obtain ⟨P, hmono, hP⟩ := exists_distinct_primes_dyadic n₀ t ht + have hlow (i : Fin n₀) : t < P i := + (Nat.le_mul_of_pos_left t (by positivity : 0 < 2 ^ i.val)).trans_lt (hP i).2.1 + have hhigh (i : Fin n₀) : P i ≤ 2 ^ n₀ * t := + (hP i).2.2.trans (Nat.mul_le_mul_right t + (Nat.pow_le_pow_right (by norm_num : 0 < 2) (Nat.succ_le_of_lt i.isLt))) + refine ⟨P, fun i => (hP i).1, hmono.injective, ?_, ?_⟩ + · intro i j + exact (hhigh i).trans (Nat.mul_le_mul + (Nat.pow_le_pow_right (by norm_num : 0 < 2) (Nat.le_succ n₀)) (hlow j).le) + · intro i + refine ⟨hceil.trans (Nat.cast_le.mpr (hlow i).le), ?_⟩ + calc + (P i : ℝ) ≤ (2 : ℝ) ^ n₀ * (t : ℝ) := by exact_mod_cast hhigh i + _ ≤ Real.exp (n₀ : ℝ) * Real.exp (p + 1) := + mul_le_mul hpow htR (Nat.cast_nonneg t) (Real.exp_nonneg _) + _ = Real.exp ((n₀ : ℝ) + (p + 1)) := (Real.exp_add _ _).symm + _ ≤ Real.exp (p + (n₀ : ℝ) + 2) := Real.exp_le_exp.mpr (by linarith) + +theorem exists_unconditioned_prime_side_budget (n₀ : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ p : ℝ, 2 ≤ p → + ∃ (P : Fin n₀ → ℕ) (hprime : ∀ i, (P i).Prime), + Function.Injective P ∧ (∀ i j, P i ≤ 2 ^ (n₀ + 1) * P j) ∧ + (∀ i, Real.exp p ≤ (P i : ℝ) ∧ (P i : ℝ) ≤ Real.exp (p + (n₀ : ℝ) + 2)) ∧ + ∀ d : ℕ, (d : ℝ) ≤ p → + let : ∀ i, NeZero (P i) := fun i => ⟨(hprime i).ne_zero⟩ + unconditionedSpatialWidthCutoff (unconditionedResidueSiteBound P) + (unconditionedSpatialTrimFraction d (Real.exp (-p))) + (unconditionedCollisionWidth P (Real.exp (-p))) ≤ Real.exp ((p + 2) ^ E) := by + obtain ⟨E, hE, hbudget⟩ := exists_unconditionedSpatialWidthCutoff_exp_budget n₀ + refine ⟨E, hE, ?_⟩ + intro p hp + obtain ⟨P, hprime, hinj, hcompare, hrange⟩ := + exists_unconditioned_prime_sides n₀ (by linarith : 0 ≤ p) + refine ⟨P, hprime, hinj, hcompare, hrange, ?_⟩ + intro d hd + let : ∀ i, NeZero (P i) := fun i => ⟨(hprime i).ne_zero⟩ + exact hbudget p hp d hd P (fun i => (hrange i).2) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem unconditionedSpatialWidthCutoff_antitone_surplus + {K : Type*} [Fintype K] [DecidableEq K] (P : K → ℕ) [∀ k, NeZero (P k)] + (d : ℕ) {σ₁ σ₂ : ℝ} (hσ₁ : 0 < σ₁) (hσ : σ₁ ≤ σ₂) : + unconditionedSpatialWidthCutoff (unconditionedResidueSiteBound P) + (unconditionedSpatialTrimFraction d σ₂) (unconditionedCollisionWidth P σ₂) ≤ + unconditionedSpatialWidthCutoff (unconditionedResidueSiteBound P) + (unconditionedSpatialTrimFraction d σ₁) (unconditionedCollisionWidth P σ₁) := by + have htrim : unconditionedSpatialTrimFraction d σ₁ ≤ unconditionedSpatialTrimFraction d σ₂ := + div_le_div_of_nonneg_right hσ (by positivity) + have htrimpos : 0 < unconditionedSpatialTrimFraction d σ₁ := by + unfold unconditionedSpatialTrimFraction + positivity + have hcollision : unconditionedCollisionWidth P σ₂ ≤ unconditionedCollisionWidth P σ₁ := + div_le_div_of_nonneg_left (by positivity) hσ₁ hσ + have hsite : 0 ≤ unconditionedResidueSiteBound P := + Finset.sum_nonneg (fun _ _ => Nat.cast_nonneg _) + unfold unconditionedSpatialWidthCutoff + apply max_le_max + · exact div_le_div_of_nonneg_left (by norm_num) htrimpos htrim + · apply (div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left (max_le_max_left _ hcollision) (by positivity)) + (htrimpos.le.trans htrim)).trans + exact div_le_div_of_nonneg_left (by positivity) htrimpos htrim + +theorem exists_unconditioned_late_prime_side_budget (n₀ : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ (p t : ℝ), 2 ≤ p → p ≤ t → + ∃ (P : Fin n₀ → ℕ) (hprime : ∀ i, (P i).Prime), + Function.Injective P ∧ (∀ i j, P i ≤ 2 ^ (n₀ + 1) * P j) ∧ + (∀ i, Real.exp t ≤ (P i : ℝ) ∧ (P i : ℝ) ≤ Real.exp (t + (n₀ : ℝ) + 2)) ∧ + (∀ i, Real.exp p ≤ (P i : ℝ)) ∧ + ∀ d : ℕ, (d : ℝ) ≤ p → + let : ∀ i, NeZero (P i) := fun i => ⟨(hprime i).ne_zero⟩ + unconditionedSpatialWidthCutoff (unconditionedResidueSiteBound P) + (unconditionedSpatialTrimFraction d (Real.exp (-p))) + (unconditionedCollisionWidth P (Real.exp (-p))) ≤ Real.exp ((t + 2) ^ E) := by + obtain ⟨E, hE, hbudget⟩ := exists_unconditioned_prime_side_budget n₀ + refine ⟨E, hE, ?_⟩ + intro p t hp hpt + obtain ⟨P, hprime, hinj, hcompare, hrange, hwidth⟩ := hbudget t (hp.trans hpt) + refine ⟨P, hprime, hinj, hcompare, hrange, + fun i => (Real.exp_le_exp.mpr hpt).trans (hrange i).1, ?_⟩ + intro d hd + let : ∀ i, NeZero (P i) := fun i => ⟨(hprime i).ne_zero⟩ + exact (unconditionedSpatialWidthCutoff_antitone_surplus P d (Real.exp_pos (-t)) + (Real.exp_le_exp.mpr (neg_le_neg hpt))).trans (hwidth d (hd.trans hpt)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/UniformBoxResidueMass.lean b/lean/OAI/Combinatorics/Progressions/Lattices/UniformBoxResidueMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fe8f98cdcfc0afc4cf1f5d1663ce41a32ca5cbb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/UniformBoxResidueMass.lean @@ -0,0 +1,338 @@ +import OAI.Combinatorics.Progressions.Geometry.PMFSupportedMean +import OAI.Combinatorics.Progressions.Lattices.AffineMeshRetention + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +def affinePairLocations {I : Type*} (v : I → Fin 2 → ℤ) : (I → ℤ) × (I → ℤ) := + (fun i => v i 0, fun i => v i 1) + +def affinePairRowsOfLocations {I : Type*} (xy : (I → ℤ) × (I → ℤ)) : I → Fin 2 → ℤ := + fun i => ![xy.1 i, xy.2 i] + +theorem affinePairLocations_rows {I : Type*} (xy : (I → ℤ) × (I → ℤ)) : + affinePairLocations (affinePairRowsOfLocations xy) = xy := rfl + +theorem affinePairRows_locations {I : Type*} (v : I → Fin 2 → ℤ) : + affinePairRowsOfLocations (affinePairLocations v) = v := by + funext i j + fin_cases j <;> rfl + +theorem affinePairLocations_injective {I : Type*} : + Function.Injective (affinePairLocations (I := I)) := by + intro x y h + have he := congrArg affinePairRowsOfLocations h + simpa only [affinePairRows_locations] using he + +theorem smoothAffinePairRows_locations {J I : Type*} [Fintype J] + (t u : J → ℤ) (z : Option J × I → ℤ) : + affinePairLocations (smoothAffinePairRows t u z) = (smoothAffineSample t z, smoothAffineSample u z) := by + apply Prod.ext + · funext i + change smoothAffinePairRows t u z i 0 = _ + rw [smoothAffinePairRows_apply] + rfl + · funext i + change smoothAffinePairRows t u z i 1 = _ + rw [smoothAffinePairRows_apply] + rfl + +theorem affinePair_joint_probability {J I : Type*} [Fintype J] + (p : PMF (Option J × I → ℤ)) (t u : J → ℤ) (x y : I → ℤ) : + p.map (fun z => (smoothAffineSample t z, smoothAffineSample u z)) (x, y) = + p.map (smoothAffinePairRows t u) (affinePairRowsOfLocations (x, y)) := by + have he : (p.map (smoothAffinePairRows t u)).map affinePairLocations = + p.map (fun z => (smoothAffineSample t z, smoothAffineSample u z)) := by + rw [PMF.map_comp] + congr 1 + funext z + exact smoothAffinePairRows_locations t u z + rw [← he] + have h := pmf_map_injective_at (p.map (smoothAffinePairRows t u)) affinePairLocations + affinePairLocations_injective (affinePairRowsOfLocations (x, y)) + simpa only [affinePairLocations_rows] using h + +theorem smoothSource_pair_correlation {J I : Type*} [Fintype J] [Fintype I] + (a S : Option J × I → ℝ) (hS : ∀ i, 0 < S i) (hZ : 0 < shiftedSmoothProductMass a S) + (t u : J → ℤ) (T U : Finset (I → ℤ)) (e d : (I → ℤ) → ℝ) + (he : ∀ x ∉ T, e x = 0) (hd : ∀ y ∉ U, d y = 0) : + (smoothSourceFiniteWeights a S hS hZ).mean + (fun z => e (smoothAffineSample t z.val) * d (smoothAffineSample u z.val)) = + ∑ x ∈ T, ∑ y ∈ U, + ((shiftedSmoothProductPMF a S hS hZ).map (smoothAffinePairRows t u) + (affinePairRowsOfLocations (x, y))).toReal * (e x * d y) := by + classical + rw [smoothSourceFiniteWeights_mean a S hS hZ + (fun z => e (smoothAffineSample t z) * d (smoothAffineSample u z))] + rw [pmf_pair_supported_real_mean (shiftedSmoothProductPMF a S hS hZ) + (rectangularWeightIndices a S 1) (shiftedSmoothProductPMF_toReal_zero_off a S hS hZ) + (smoothAffineSample t) (smoothAffineSample u) T U e d he hd] + simp_rw [affinePair_joint_probability] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def integerVectorResidue {I : Type*} (m : ℕ) (x : I → ℤ) : I → ZMod m := + fun i => (x i : ZMod m) + +theorem integerVectorResidue_eq_iff {I : Type*} (m : ℕ) (x y : I → ℤ) : + integerVectorResidue m x = integerVectorResidue m y ↔ ∀ i, (m : ℤ) ∣ y i - x i := by + simp only [funext_iff, integerVectorResidue, ZMod.intCast_eq_intCast_iff_dvd_sub] + +theorem integerVectorResidue_surjective {I : Type*} (m : ℕ) : + Function.Surjective (integerVectorResidue (I := I) m) := by + intro r + choose x hx using fun i => ZMod.intCast_surjective (r i) + exact ⟨x, funext hx⟩ + +theorem integerVectorResidue_card (I : Type*) [Fintype I] [DecidableEq I] (m : ℕ) [NeZero m] : + Fintype.card (I → ZMod m) = m ^ Fintype.card I := by simp + +def affinePairModulus {J : Type*} [Fintype J] (t u : J → ℤ) : ℕ := + (BohrLattice.Primitive.content (fun j => u j - t j)).natAbs + +theorem affinePairModulus_pos {J : Type*} [Fintype J] (t u : J → ℤ) (k : J) + (hne : u k - t k ≠ 0) : 0 < affinePairModulus t u := by + apply Int.natAbs_pos.mpr + apply BohrLattice.Primitive.content_ne_zero + intro h + exact hne (congrFun h k) + +theorem affinePairModulus_residue_iff {J I : Type*} [Fintype J] + (t u : J → ℤ) (x y : I → ℤ) : + integerVectorResidue (affinePairModulus t u) x = integerVectorResidue (affinePairModulus t u) y ↔ + ∀ i, BohrLattice.Primitive.content (fun j => u j - t j) ∣ y i - x i := by + rw [integerVectorResidue_eq_iff] + simp only [affinePairModulus, Int.natAbs_dvd] + +theorem affinePairPMF_zero_off_residue {J I : Type*} [Fintype J] + (p : PMF (Option J × I → ℤ)) (t u : J → ℤ) (x y : I → ℤ) + (hxy : integerVectorResidue (affinePairModulus t u) x ≠ + integerVectorResidue (affinePairModulus t u) y) : + p.map (smoothAffinePairRows t u) (affinePairRowsOfLocations (x, y)) = 0 := by + apply affinePairPMF_zero_off_congruence + intro h + apply hxy + apply (affinePairModulus_residue_iff t u x y).mpr + simpa only [affinePairRowsOfLocations, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.head_cons] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem integerBox_residue_fiberLaw_weight_eq_count + {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q] (v : I → ℤ) : + (((integerBoxUniformWeights lo hi hlen).fiberLaw + (fun x => integerVectorResidue q (fun i => (x i).val))).weight + (integerVectorResidue q v)) = + (rectangularResidueCount lo hi (fun _ => (q : ℤ)) v : ℝ) / + integerRectangleVolume lo hi := by + change (integerBoxUniformWeights lo hi hlen).eventProbability + (fun x => integerVectorResidue q (fun i => (x i).val) = integerVectorResidue q v) = _ + have heq : + (fun x : ∀ i, Finset.Ico (lo i) (hi i) => + integerVectorResidue q (fun i => (x i).val) = integerVectorResidue q v) = + (fun x => ∀ i, (x i : ℤ) ≡ v i [ZMOD (q : ℤ)]) := by + funext x + exact propext (by simp only [integerVectorResidue_eq_iff, Int.modEq_iff_dvd]) + rw [heq, integerBoxUniformWeights, + FiniteProbabilityWeights.eventProbability_pi + (fun i => intervalUniformWeights (lo i) (hi i) (hlen i)) + (fun i x => (x : ℤ) ≡ v i [ZMOD (q : ℤ)])] + have hprob (i : I) : + (intervalUniformWeights (lo i) (hi i) (hlen i)).eventProbability + (fun x => (x : ℤ) ≡ v i [ZMOD (q : ℤ)]) = + (integerResidueCount (lo i) (hi i) q (v i) : ℝ) / + ((hi i - lo i : ℤ) : ℝ) := by + unfold FiniteProbabilityWeights.eventProbability + rw [intervalUniformWeights_mean, + @integerInterval_indicator_expect (lo i) (hi i) (hlen i).le + (fun x : ℤ => x ≡ v i [ZMOD (q : ℤ)]) + (fun _ => Classical.propDecidable _)] + congr 2 + apply congrArg Finset.card + ext x + simp + simp_rw [hprob] + simp only [Finset.prod_div_distrib, rectangularResidueCount, Nat.cast_prod, + integerRectangleVolume] + +theorem integerBox_residue_fiberLaw_relative_error + {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (q : ℕ) [NeZero q] + (r : I → ZMod q) + (hsmall : (∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ)) ≤ 1 / 2) : + |(q : ℝ) ^ Fintype.card I * + (((integerBoxUniformWeights lo hi hlen).fiberLaw + (fun x => integerVectorResidue q (fun i => (x i).val))).weight r) - 1| ≤ + 2 * ∑ i, (q : ℝ) / ((hi i - lo i : ℤ) : ℝ) := by + obtain ⟨v, rfl⟩ := integerVectorResidue_surjective q r + rw [integerBox_residue_fiberLaw_weight_eq_count] + have hV : 0 < integerRectangleVolume lo hi := by + apply Finset.prod_pos + intro i _ + exact_mod_cast sub_pos.mpr (hlen i) + have hbound := rectangularResidueCount_relative_error lo hi (fun _ => (q : ℤ)) v + hlen (fun _ => by exact_mod_cast NeZero.pos q) (by simpa using hsmall) + simp only [Int.cast_natCast, Finset.prod_const, Finset.card_univ] at hbound + calc + _ = |((q : ℝ) ^ Fintype.card I * + (rectangularResidueCount lo hi (fun _ => (q : ℤ)) v : ℝ) - + integerRectangleVolume lo hi) / integerRectangleVolume lo hi| := by + congr 1 + field_simp + _ = |(q : ℝ) ^ Fintype.card I * + (rectangularResidueCount lo hi (fun _ => (q : ℤ)) v : ℝ) - + integerRectangleVolume lo hi| / integerRectangleVolume lo hi := by + rw [abs_div, abs_of_pos hV] + _ ≤ _ := (div_le_iff₀ hV).mpr hbound + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem affineInterval_normalized_cap (D : ℕ) (a lo hi x : ℤ) {L C : ℝ} + (hL : 0 < L) (hx : x ∈ Finset.Ico lo hi) + (hlow : |((a + (D : ℤ) * lo : ℤ) : ℝ) / L| ≤ C) + (hhigh : |((a + (D : ℤ) * hi : ℤ) : ℝ) / L| ≤ C) : + |((a + (D : ℤ) * x : ℤ) : ℝ) / L| ≤ C := by + have hx' := Finset.mem_Ico.mp hx + have hleft : ((a + (D : ℤ) * lo : ℤ) : ℝ) ≤ ((a + (D : ℤ) * x : ℤ) : ℝ) := by + exact_mod_cast add_le_add (le_refl a) (mul_le_mul_of_nonneg_left hx'.1 (Int.natCast_nonneg D)) + have hright : ((a + (D : ℤ) * x : ℤ) : ℝ) ≤ ((a + (D : ℤ) * hi : ℤ) : ℝ) := by + exact_mod_cast add_le_add (le_refl a) (mul_le_mul_of_nonneg_left hx'.2.le (Int.natCast_nonneg D)) + exact abs_le.mpr ⟨(abs_le.mp hlow).1.trans (div_le_div_of_nonneg_right hleft hL.le), + (div_le_div_of_nonneg_right hright hL.le).trans (abs_le.mp hhigh).2⟩ + +theorem normalized_pair_mesh_bound (x y : ℤ) {L H C δ : ℝ} + (hL : 0 < L) (hH : 0 < H) (hx : |(x : ℝ) / L| ≤ C) (hy : |(y : ℝ) / L| ≤ C) + (hmesh : 2 * C * L ^ 2 / H ≤ δ) : ((y - x).natAbs : ℝ) * L / H ≤ δ := by + have hx' : |(x : ℝ)| ≤ C * L := (div_le_iff₀ hL).mp (by simpa only [abs_div, abs_of_pos hL] using hx) + have hy' : |(y : ℝ)| ≤ C * L := (div_le_iff₀ hL).mp (by simpa only [abs_div, abs_of_pos hL] using hy) + have hd : ((y - x).natAbs : ℝ) ≤ 2 * C * L := by + rw [Nat.cast_natAbs, Int.cast_abs, Int.cast_sub] + exact (abs_sub _ _).trans (by linarith) + apply le_trans _ hmesh + apply (div_le_div_iff_of_pos_right hH).mpr + nlinarith [mul_le_mul_of_nonneg_right hd hL.le] + +theorem retained_affine_pair_geometry {J : Type*} [Fintype J] + (D Q r : ℕ) (a x y : J → ℤ) {L κ : ℝ} (hL : 0 < L) (hκ : 0 < κ) + (hgap : κ * L ≤ (D : ℝ) * (r + 1 : ℕ)) + (hgood : ¬ affineParameterBadPair D Q r a x y) : + affinePairModulus (fun j => a j + (D : ℤ) * x j) (fun j => a j + (D : ℤ) * y j) ≤ Q ∧ + ∃ k : J, (a k + (D : ℤ) * y k) - (a k + (D : ℤ) * x k) ≠ 0 ∧ + κ ≤ |(((a k + (D : ℤ) * y k) - (a k + (D : ℤ) * x k) : ℤ) : ℝ) / L| := by + constructor + · exact le_of_not_gt (fun h => hgood (Or.inl h)) + · have hnear : ¬ ∀ j, |y j - x j| ≤ (r : ℤ) := fun h => hgood (Or.inr h) + push Not at hnear + obtain ⟨k, hk⟩ := hnear + have hr : ((r + 1 : ℕ) : ℝ) ≤ |((y k - x k : ℤ) : ℝ)| := by + have h : (r + 1 : ℕ) ≤ |y k - x k| := by omega + exact_mod_cast h + have heq : (((a k + (D : ℤ) * y k) - (a k + (D : ℤ) * x k) : ℤ) : ℝ) = + (D : ℝ) * ((y k - x k : ℤ) : ℝ) := by push_cast; ring + have hbound : κ ≤ |(((a k + (D : ℤ) * y k) - (a k + (D : ℤ) * x k) : ℤ) : ℝ) / L| := by + rw [heq, abs_div, abs_mul, abs_of_nonneg (Nat.cast_nonneg D), abs_of_pos hL] + apply (le_div_iff₀ hL).mpr + exact hgap.trans (mul_le_mul_of_nonneg_left hr (Nat.cast_nonneg D)) + refine ⟨k, ?_, hbound⟩ + intro hz + rw [hz, Int.cast_zero, zero_div, abs_zero] at hbound + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem integer_box_residue_probability {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (m : ℕ) (hm : 0 < m) (r : I → ZMod m) : + (integerBoxUniformWeights lo hi hlen).eventProbability + (fun x => integerVectorResidue m (fun i => (x i).val) = r) ≤ + ∏ i, (1 / (m : ℝ) + 1 / ((hi i - lo i : ℤ) : ℝ)) := by + obtain ⟨v, hv⟩ := integerVectorResidue_surjective m r + have heq : (fun x : ∀ i, Finset.Ico (lo i) (hi i) => + integerVectorResidue m (fun i => (x i).val) = r) = + (fun x => ∀ i, (m : ℤ) ∣ (x i).val - v i) := by + funext x + apply propext + rw [← hv, eq_comm, integerVectorResidue_eq_iff] + rw [heq] + exact integer_box_divisor_probability lo hi hlen (m : ℤ) (by exact_mod_cast hm) v + +theorem integer_box_residue_probability_of_lengths {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) (m : ℕ) (hm : 0 < m) + (hwidth : ∀ i, (m : ℝ) ≤ ((hi i - lo i : ℤ) : ℝ)) (r : I → ZMod m) : + (integerBoxUniformWeights lo hi hlen).eventProbability + (fun x => integerVectorResidue m (fun i => (x i).val) = r) ≤ + (2 : ℝ) ^ Fintype.card I / (m : ℝ) ^ Fintype.card I := by + have hmR : (0 : ℝ) < m := by exact_mod_cast hm + apply (integer_box_residue_probability lo hi hlen m hm r).trans + calc + _ ≤ ∏ _i : I, 2 / (m : ℝ) := by + apply Finset.prod_le_prod₀ + · intro i _ + exact add_nonneg (one_div_nonneg.mpr hmR.le) + (one_div_nonneg.mpr (hmR.le.trans (hwidth i))) + · intro i _ + have h := one_div_le_one_div_of_le hmR (hwidth i) + calc + _ ≤ 1 / (m : ℝ) + 1 / (m : ℝ) := add_le_add le_rfl h + _ = _ := by ring + _ = _ := by simp only [Finset.prod_const, Finset.card_univ, div_pow] + +theorem uniform_interval_box_residue_bound {I : Type*} [Fintype I] [DecidableEq I] + (lo hi : I → ℤ) (hlen : ∀ i, lo i < hi i) + [Nonempty (Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)))] + (m : ℕ) (hm : 0 < m) (hwidth : ∀ i, (m : ℝ) ≤ ((hi i - lo i : ℤ) : ℝ)) + (r : I → ZMod m) : + (FiniteProbabilityWeights.uniform (Fintype.piFinset (fun i => Finset.Ico (lo i) (hi i)))).eventProbability + (fun x => integerVectorResidue m x.val = r) ≤ + (2 : ℝ) ^ Fintype.card I / (m : ℝ) ^ Fintype.card I := by + classical + have h := integer_box_residue_probability_of_lengths lo hi hlen m hm hwidth r + unfold FiniteProbabilityWeights.eventProbability at h ⊢ + rw [FiniteProbabilityWeights.uniform_mean] + rw [integerBoxUniformWeights_mean] at h + apply le_of_eq_of_le ?_ h + apply Fintype.expect_equiv (finiteBoxPointsEquiv (fun i => Finset.Ico (lo i) (hi i))).symm + intro x + split_ifs <;> first | rfl | contradiction + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/UniformDerivativeLatticeExtraction.lean b/lean/OAI/Combinatorics/Progressions/Lattices/UniformDerivativeLatticeExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..3eb27cc7aa95e79bce09f869a5f760a780f5a784 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/UniformDerivativeLatticeExtraction.lean @@ -0,0 +1,338 @@ +import Mathlib.LinearAlgebra.FiniteDimensional.Basic +import OAI.Combinatorics.Progressions.Estimates.DerivativeHorizontalLifts + +namespace OAI + +section + +namespace Erdos3 + +theorem derivative_covolume_budget_le_exp (d n : ℕ) (R δ p : ℝ) + (hp : 0 ≤ p) (hd : (d : ℝ) ≤ p) (hn : (n : ℝ) ≤ p) + (hR0 : 0 ≤ R) (hR : R ≤ Real.exp p) (hδ : 0 < δ) + (hδinv : δ⁻¹ ≤ Real.exp p) : + (((d : ℝ) + 2) * ((n : ℝ) * R)) ^ d / δ ≤ Real.exp (3 * p ^ 2 + 2 * p) := by + have hd2 : (d : ℝ) + 2 ≤ Real.exp (p + 1) := by + exact (by linarith : (d : ℝ) + 2 ≤ (p + 1) + 1).trans (Real.add_one_le_exp (p + 1)) + have hnexp : (n : ℝ) ≤ Real.exp p := + hn.trans ((show p ≤ p + 1 by linarith).trans (Real.add_one_le_exp p)) + have hbase : ((d : ℝ) + 2) * ((n : ℝ) * R) ≤ Real.exp (3 * p + 1) := by + calc + _ ≤ Real.exp (p + 1) * (Real.exp p * Real.exp p) := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + calc + _ ≤ Real.exp (3 * p + 1) ^ d * Real.exp p := by + rw [div_eq_mul_inv] + exact mul_le_mul (pow_le_pow_left₀ (by positivity) hbase d) hδinv + (inv_nonneg.mpr hδ.le) (by positivity) + _ = Real.exp ((d : ℝ) * (3 * p + 1) + p) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + _ ≤ Real.exp (3 * p ^ 2 + 2 * p) := by + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_right hd (by positivity : 0 ≤ 3 * p + 1)] + +theorem derivative_extended_budget_le_exp (k l : ℕ) (C p : ℝ) + (hp : 0 ≤ p) (hk : (k : ℝ) ≤ p) (hl : (l : ℝ) ≤ Real.exp p) + (hC : C ≤ Real.exp (3 * p ^ 2 + 2 * p)) : + C * (l : ℝ) ^ k ≤ Real.exp (4 * p ^ 2 + 2 * p) := by + calc + _ ≤ Real.exp (3 * p ^ 2 + 2 * p) * Real.exp p ^ k := by + exact mul_le_mul hC (pow_le_pow_left₀ (Nat.cast_nonneg l) hl k) + (pow_nonneg (Nat.cast_nonneg l) k) (Real.exp_nonneg _) + _ = Real.exp (3 * p ^ 2 + 2 * p + (k : ℝ) * p) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + _ ≤ Real.exp (4 * p ^ 2 + 2 * p) := by + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_right hk hp] + +theorem derivative_output_exponent_le {p : ℝ} (hp : 0 ≤ p) : + 4 * p ^ 2 + 4 * p + 1 ≤ (p + 2) ^ 3 := by + nlinarith [pow_nonneg hp 3] + +theorem derivative_output_budgets_le_exp (n k l : ℕ) (B p : ℝ) + (hp : 0 ≤ p) (hn : (n : ℝ) ≤ p) (hk : (k : ℝ) ≤ p) + (hl : (l : ℝ) ≤ Real.exp p) (hB : B ≤ Real.exp (4 * p ^ 2 + 2 * p)) : + B ≤ Real.exp ((p + 2) ^ 3) ∧ + (n : ℝ) * k * B ≤ Real.exp ((p + 2) ^ 3) ∧ + (l : ℝ) * B ≤ Real.exp ((p + 2) ^ 3) ∧ + (Nat.ceil B : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + have hne : (n : ℝ) ≤ Real.exp p := + hn.trans ((show p ≤ p + 1 by linarith).trans (Real.add_one_le_exp p)) + have hke : (k : ℝ) ≤ Real.exp p := + hk.trans ((show p ≤ p + 1 by linarith).trans (Real.add_one_le_exp p)) + have hpoly := derivative_output_exponent_le hp + have h0 : 4 * p ^ 2 + 2 * p ≤ (p + 2) ^ 3 := by linarith + have h1 : 4 * p ^ 2 + 3 * p ≤ (p + 2) ^ 3 := by linarith + have h2 : 4 * p ^ 2 + 4 * p ≤ (p + 2) ^ 3 := by linarith + have h3 : 4 * p ^ 2 + 2 * p + 1 ≤ (p + 2) ^ 3 := by linarith + refine ⟨hB.trans (Real.exp_le_exp.mpr h0), ?_, ?_, ?_⟩ + · calc + _ ≤ (n : ℝ) * k * Real.exp (4 * p ^ 2 + 2 * p) := by gcongr + _ ≤ Real.exp p * Real.exp p * Real.exp (4 * p ^ 2 + 2 * p) := by gcongr + _ = Real.exp (4 * p ^ 2 + 4 * p) := by + rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr h2 + · calc + _ ≤ (l : ℝ) * Real.exp (4 * p ^ 2 + 2 * p) := by gcongr + _ ≤ Real.exp p * Real.exp (4 * p ^ 2 + 2 * p) := by gcongr + _ = Real.exp (4 * p ^ 2 + 3 * p) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr h1 + · calc + (Nat.ceil B : ℝ) ≤ Nat.ceil (Real.exp (4 * p ^ 2 + 2 * p)) := by + exact_mod_cast Nat.ceil_mono hB + _ ≤ Real.exp (4 * p ^ 2 + 2 * p + 1) := ceil_exp_le_exp_add_one (by positivity) + _ ≤ _ := Real.exp_le_exp.mpr h3 + +theorem derivative_projection_budget_le_exp (n : ℕ) (R δ p : ℝ) + (hp : 0 ≤ p) (hn : (n : ℝ) ≤ p) (hR0 : 0 ≤ R) (hR : R ≤ Real.exp p) + (hδ : 0 < δ) (hδinv : δ⁻¹ ≤ Real.exp p) : + (3 * R) ^ (n - 1) / δ ≤ Real.exp ((p + 2) ^ 3) := by + have hthree : (3 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hbase : 3 * R ≤ Real.exp (p + 2) := by + calc + _ ≤ Real.exp 2 * Real.exp p := mul_le_mul hthree hR hR0 (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, add_comm] + have hn' : ((n - 1 : ℕ) : ℝ) ≤ p := + (Nat.cast_le.mpr (Nat.sub_le n 1)).trans hn + calc + _ ≤ Real.exp (p + 2) ^ (n - 1) * Real.exp p := by + rw [div_eq_mul_inv] + exact mul_le_mul (pow_le_pow_left₀ (by positivity) hbase _) hδinv + (inv_nonneg.mpr hδ.le) (by positivity) + _ = Real.exp (((n - 1 : ℕ) : ℝ) * (p + 2) + p) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + _ ≤ Real.exp (p ^ 2 + 3 * p) := by + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_right hn' (by positivity : 0 ≤ p + 2)] + _ ≤ Real.exp ((p + 2) ^ 3) := by + apply Real.exp_le_exp.mpr + nlinarith [derivative_output_exponent_le hp, sq_nonneg p] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem lattice_subspace_budgets_le_exp + {σ : Type*} [Fintype σ] {m : ℕ} + (Z : Submodule ℝ (EuclideanSpace ℝ (σ ⊕ Fin m))) (V : Submodule ℝ Z) + (l : ℕ) (R δ p : ℝ) (hp : 0 ≤ p) + (hdim : ((Fintype.card σ + Fintype.card (Fin m) : ℕ) : ℝ) ≤ p) + (hl : (l : ℝ) ≤ Real.exp p) (hR0 : 0 ≤ R) (hR : R ≤ Real.exp p) + (hδ : 0 < δ) (hδinv : δ⁻¹ ≤ Real.exp p) : + let n := Fintype.card σ + Fintype.card (Fin m) + let d := Module.finrank ℝ Z + let k := Module.finrank ℝ V + let C := (((d : ℝ) + 2) * ((n : ℝ) * R)) ^ d / δ + let B := C * (l : ℝ) ^ k + C * (l : ℝ) ^ m ≤ Real.exp ((p + 2) ^ 3) ∧ + B ≤ Real.exp ((p + 2) ^ 3) ∧ + (n : ℝ) * k * B ≤ Real.exp ((p + 2) ^ 3) ∧ + (l : ℝ) * B ≤ Real.exp ((p + 2) ^ 3) ∧ + (Nat.ceil B : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + let n := Fintype.card σ + Fintype.card (Fin m) + let d := Module.finrank ℝ Z + let k := Module.finrank ℝ V + let C := (((d : ℝ) + 2) * ((n : ℝ) * R)) ^ d / δ + let B := C * (l : ℝ) ^ k + have hdn : d ≤ n := by + simpa only [finrank_euclideanSpace, Fintype.card_sum] using Z.finrank_le + have hdp : (d : ℝ) ≤ p := (Nat.cast_le.mpr hdn).trans hdim + have hkp : (k : ℝ) ≤ p := (Nat.cast_le.mpr V.finrank_le).trans hdp + have hmp : (m : ℝ) ≤ p := by + have hmn : m ≤ n := by simp [n] + exact (Nat.cast_le.mpr hmn).trans hdim + have hC : C ≤ Real.exp (3 * p ^ 2 + 2 * p) := + derivative_covolume_budget_le_exp d n R δ p hp hdp hdim hR0 hR hδ hδinv + have hB : B ≤ Real.exp (4 * p ^ 2 + 2 * p) := + derivative_extended_budget_le_exp k l C p hp hkp hl hC + have hthreshold : C * (l : ℝ) ^ m ≤ Real.exp ((p + 2) ^ 3) := by + apply (derivative_extended_budget_le_exp m l C p hp hmp hl hC).trans + apply Real.exp_le_exp.mpr + have he := derivative_output_exponent_le hp + linarith + exact ⟨hthreshold, derivative_output_budgets_le_exp n k l B p hp hdim hkp hl hB⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem euclideanDerivative_lattice_extraction + {σ : Type*} [Fintype σ] [DecidableEq σ] {m : ℕ} + (T : σ → ℝ) (hT : ∀ i, 1 ≤ T i) + (scale : Fin m → ℝ) (hscale : ∀ j, 1 ≤ scale j) + (Y : (σ → ℝ) →ₗ[ℝ] (Fin m → ℝ)) + (A : (Fin m → ℝ) ≃ₗ[ℝ] (Fin m → ℝ)) + (hA : ∀ i j, i < j → (LinearMap.toMatrix' A.toLinearMap) i j = 0) + (hdiag : ∀ i, (LinearMap.toMatrix' A.toLinearMap) i i = 1) + (l : ℕ) (hl : 0 < l) (R δ : ℝ) (hR : 1 ≤ R) (hδ : 0 < δ) + (H : Finset (σ → ℤ)) (r : (σ → ℤ) → Fin m → ℝ) + (hr : ∀ h ∈ H, r h ∈ realDenominatorGrid l) + (hnorm : ∀ h ∈ H, + ‖derivativeGridPoint T scale Y (LinearMap.toMatrix' A.toLinearMap) h (r h)‖ ≤ R) + (hdense : δ * ∏ i, T i ≤ (H.card : ℝ)) + (hlarge : ∀ i, (3 * R) ^ (Fintype.card σ - 1) < δ * T i) + (a : ℕ) (ha : a ≤ m) (Tmin : ℝ) + (hscalehor : ∀ j, j.val < a → scale j = 1) + (hblock : ∀ i j, i.val < a → j.val < a → + (LinearMap.toMatrix' A.toLinearMap) i j = (1 : Matrix (Fin m) (Fin m) ℝ) i j) + (hfar : ∀ i, a ≤ i.val → Tmin ≤ scale i) : + let hT0 : ∀ i, T i ≠ 0 := fun i => (lt_of_lt_of_le zero_lt_one (hT i)).ne' + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let ρ := ((Fintype.card σ + Fintype.card (Fin m) : ℕ) : ℝ) * R + let Λ := euclideanDerivativeLattice T hT0 scale hs0 Y A l hl + let Z := shortVectorSpan Λ ρ + let π := (euclideanDerivativeShiftMap T hT0).comp Z.subtype + let V := LinearMap.ker π + let P := (euclideanHorizontalProjection a ha).comp (Z.subtype.comp V.subtype) + let k := Module.finrank ℝ V + let C := (((Module.finrank ℝ Z : ℝ) + 2) * ρ) ^ Module.finrank ℝ Z / δ + let B := C * (l : ℝ) ^ k + let N := (Fintype.card (σ ⊕ Fin m) : ℝ) * k * B + C * (l : ℝ) ^ m < Tmin → + ∃ lifts : RationalHorizontalLift k P ha A scale N (Nat.ceil B), + ∃ I : ℕ, 0 < I ∧ (I : ℝ) ≤ B ∧ + ∀ i, ∃ (s r' : Fin m → ℝ) (q : LinearMap.range P), + Y (Pi.basisFun ℝ σ i) = s + A r' + lifts.geometricLift q ∧ + r' ∈ realDenominatorGrid (l * I) ∧ + ‖(EuclideanSpace.equiv (Fin m) ℝ).symm (fun j => scale j * s j)‖ ≤ B / T i := by + let hT0 : ∀ i, T i ≠ 0 := fun i => (lt_of_lt_of_le zero_lt_one (hT i)).ne' + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let ρ := ((Fintype.card σ + Fintype.card (Fin m) : ℕ) : ℝ) * R + let Λ := euclideanDerivativeLattice T hT0 scale hs0 Y A l hl + let Z := shortVectorSpan Λ ρ + let π := (euclideanDerivativeShiftMap T hT0).comp Z.subtype + let V := LinearMap.ker π + let P := (euclideanHorizontalProjection a ha).comp (Z.subtype.comp V.subtype) + let k := Module.finrank ℝ V + let C := (((Module.finrank ℝ Z : ℝ) + 2) * ρ) ^ Module.finrank ℝ Z / δ + let B := C * (l : ℝ) ^ k + let N := (Fintype.card (σ ⊕ Fin m) : ℝ) * k * B + let I := (latticeImage (shortVectorLattice Λ ρ) π).toAddSubgroup.relIndex + integerCoordinateLattice.toAddSubgroup + change C * (l : ℝ) ^ m < Tmin → + ∃ lifts : RationalHorizontalLift k P ha A scale N (Nat.ceil B), + ∃ I : ℕ, 0 < I ∧ (I : ℝ) ≤ B ∧ + ∀ i, ∃ (s r' : Fin m → ℝ) (q : LinearMap.range P), + Y (Pi.basisFun ℝ σ i) = s + A r' + lifts.geometricLift q ∧ + r' ∈ realDenominatorGrid (l * I) ∧ + ‖(EuclideanSpace.equiv (Fin m) ℝ).symm (fun j => scale j * s j)‖ ≤ B / T i + intro hvertical + obtain ⟨hI, G, hG, _, hcov, hIB, hGB⟩ := euclideanDerivative_index_graph_bounds + T hT scale hscale Y A hA hdiag l hl R δ hR hδ H r hr hnorm hdense hlarge + obtain ⟨lifts, hrecovers⟩ := euclideanDerivative_horizontal_lifts T hT0 scale hscale + Y A hA hdiag l hl ρ a ha Tmin C hscalehor hblock hfar hvertical hcov + refine ⟨lifts, I, hI, hIB, ?_⟩ + have hGbasis (i) : ‖G (Pi.basisFun ℝ σ i)‖ ≤ B := + (euclidean_section_basis_norm_le_gram_sqrt Z G hG i).trans hGB + have hI_lifts (i) : ∃ v : Z, v.val ∈ Λ ∧ + euclideanDerivativeShiftMap T hT0 v.val = (I : ℝ) • Pi.basisFun ℝ σ i := by + obtain ⟨v, hv, hπv⟩ := latticeImage_basis_lifts (shortVectorLattice Λ ρ) π i + exact ⟨v, hv, hπv⟩ + exact indexed_derivative_decomposition (σ := σ) (m := m) (a := a) (k := k) + T hT0 (fun i => lt_of_lt_of_le zero_lt_one (hT i)) scale hs0 Y A l hl Z ha N B + (Nat.ceil B) lifts hrecovers G hG hGbasis I hI hI_lifts + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem euclideanDerivative_uniform_lattice_extraction + {σ : Type*} [Fintype σ] [DecidableEq σ] {m : ℕ} + (T : σ → ℝ) (hT : ∀ i, 1 ≤ T i) + (scale : Fin m → ℝ) (hscale : ∀ j, 1 ≤ scale j) + (Y : (σ → ℝ) →ₗ[ℝ] (Fin m → ℝ)) + (A : (Fin m → ℝ) ≃ₗ[ℝ] (Fin m → ℝ)) + (hA : ∀ i j, i < j → (LinearMap.toMatrix' A.toLinearMap) i j = 0) + (hdiag : ∀ i, (LinearMap.toMatrix' A.toLinearMap) i i = 1) + (l : ℕ) (hl : 0 < l) (R δ : ℝ) (hR : 1 ≤ R) (hδ : 0 < δ) + (H : Finset (σ → ℤ)) (r : (σ → ℤ) → Fin m → ℝ) + (hr : ∀ h ∈ H, r h ∈ realDenominatorGrid l) + (hnorm : ∀ h ∈ H, + ‖derivativeGridPoint T scale Y (LinearMap.toMatrix' A.toLinearMap) h (r h)‖ ≤ R) + (hdense : δ * ∏ i, T i ≤ (H.card : ℝ)) + (a : ℕ) (ha : a ≤ m) (Tmin : ℝ) + (hscalehor : ∀ j, j.val < a → scale j = 1) + (hblock : ∀ i j, i.val < a → j.val < a → + (LinearMap.toMatrix' A.toLinearMap) i j = (1 : Matrix (Fin m) (Fin m) ℝ) i j) + (hfar : ∀ i, a ≤ i.val → Tmin ≤ scale i) + (p : ℝ) (hp : 0 ≤ p) + (hdim : ((Fintype.card σ + Fintype.card (Fin m) : ℕ) : ℝ) ≤ p) + (hlcap : (l : ℝ) ≤ Real.exp p) (hRcap : R ≤ Real.exp p) + (hδcap : δ⁻¹ ≤ Real.exp p) + (hmin : Real.exp ((p + 2) ^ 3) < Tmin) (hside : ∀ i, Tmin ≤ T i) : + let hT0 : ∀ i, T i ≠ 0 := fun i => (lt_of_lt_of_le zero_lt_one (hT i)).ne' + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let ρ := ((Fintype.card σ + Fintype.card (Fin m) : ℕ) : ℝ) * R + let Λ := euclideanDerivativeLattice T hT0 scale hs0 Y A l hl + let Z := shortVectorSpan Λ ρ + let π := (euclideanDerivativeShiftMap T hT0).comp Z.subtype + let V := LinearMap.ker π + let P := (euclideanHorizontalProjection a ha).comp (Z.subtype.comp V.subtype) + let k := Module.finrank ℝ V + let C := (((Module.finrank ℝ Z : ℝ) + 2) * ρ) ^ Module.finrank ℝ Z / δ + let B := C * (l : ℝ) ^ k + let N := (Fintype.card (σ ⊕ Fin m) : ℝ) * k * B + let E := Real.exp ((p + 2) ^ 3) + ∃ lifts : RationalHorizontalLift k P ha A scale N (Nat.ceil B), + N ≤ E ∧ (Nat.ceil B : ℝ) ≤ E ∧ + ∃ I : ℕ, 0 < I ∧ ((l * I : ℕ) : ℝ) ≤ E ∧ + ∀ i, ∃ (s r' : Fin m → ℝ) (q : LinearMap.range P), + Y (Pi.basisFun ℝ σ i) = s + A r' + lifts.geometricLift q ∧ + r' ∈ realDenominatorGrid (l * I) ∧ + ‖(EuclideanSpace.equiv (Fin m) ℝ).symm (fun j => scale j * s j)‖ ≤ E / T i := by + let hT0 : ∀ i, T i ≠ 0 := fun i => (lt_of_lt_of_le zero_lt_one (hT i)).ne' + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let ρ := ((Fintype.card σ + Fintype.card (Fin m) : ℕ) : ℝ) * R + let Λ := euclideanDerivativeLattice T hT0 scale hs0 Y A l hl + let Z := shortVectorSpan Λ ρ + let π := (euclideanDerivativeShiftMap T hT0).comp Z.subtype + let V := LinearMap.ker π + let P := (euclideanHorizontalProjection a ha).comp (Z.subtype.comp V.subtype) + let k := Module.finrank ℝ V + let C := (((Module.finrank ℝ Z : ℝ) + 2) * ρ) ^ Module.finrank ℝ Z / δ + let B := C * (l : ℝ) ^ k + let N := (Fintype.card (σ ⊕ Fin m) : ℝ) * k * B + let E := Real.exp ((p + 2) ^ 3) + have hR0 : 0 ≤ R := zero_le_one.trans hR + obtain ⟨hthreshold, hBE, hNE, hlBE, hheight⟩ := + lattice_subspace_budgets_le_exp Z V l R δ p hp hdim hlcap hR0 hRcap hδ hδcap + have hN : N ≤ E := by + simpa only [N, Fintype.card_sum] using hNE + have hσ : (Fintype.card σ : ℝ) ≤ p := by + have hd : (Fintype.card σ : ℝ) + Fintype.card (Fin m) ≤ p := by exact_mod_cast hdim + linarith [Nat.cast_nonneg (α := ℝ) (Fintype.card (Fin m))] + have hprojection := derivative_projection_budget_le_exp (Fintype.card σ) R δ p + hp hσ hR0 hRcap hδ hδcap + have hlarge : ∀ i, (3 * R) ^ (Fintype.card σ - 1) < δ * T i := by + intro i + have hi := (div_lt_iff₀ hδ).mp (hprojection.trans_lt (hmin.trans_le (hside i))) + simpa only [mul_comm] using hi + have hvertical : C * (l : ℝ) ^ m < Tmin := hthreshold.trans_lt hmin + obtain ⟨lifts, I, hI, hIB, hdecomp⟩ := euclideanDerivative_lattice_extraction + T hT scale hscale Y A hA hdiag l hl R δ hR hδ H r hr hnorm hdense hlarge + a ha Tmin hscalehor hblock hfar hvertical + refine ⟨lifts, hN, hheight, I, hI, ?_, ?_⟩ + · rw [Nat.cast_mul] + exact (mul_le_mul_of_nonneg_left hIB (Nat.cast_nonneg l)).trans hlBE + · intro i + obtain ⟨s, r', q, heq, hr', hs⟩ := hdecomp i + refine ⟨s, r', q, heq, hr', ?_⟩ + exact hs.trans (div_le_div_of_nonneg_right hBE (zero_le_one.trans (hT i))) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/UniformExternalMarkedAffineSliceFreezingDictionary.lean b/lean/OAI/Combinatorics/Progressions/Lattices/UniformExternalMarkedAffineSliceFreezingDictionary.lean new file mode 100644 index 0000000000000000000000000000000000000000..9154c108930975a6a653f1da7c4cdd93b9028343 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/UniformExternalMarkedAffineSliceFreezingDictionary.lean @@ -0,0 +1,995 @@ +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Estimates.FiniteMarkedFreezingCellBound +import OAI.Combinatorics.Progressions.Sampling.NativeMarkedFreezingSliceScore + +namespace OAI + +section + +namespace Erdos3.ResidueBoxSlice + +variable {ι : Type*} {N : ι → ℕ} {q : ℕ} + +def affineIntegerPoint (A : ResidueBoxSlice N q) (origin : ι → ℤ) (step : ℕ) + (j : ∀ i, Fin (A.length i)) : ι → ℤ := + fun i => origin i + step * (A.point j i).val + +theorem affineIntegerPoint_residue (A : ResidueBoxSlice N q) + (origin : ι → ℤ) (step : ℕ) (j : ∀ i, Fin (A.length i)) : + (fun i => (A.affineIntegerPoint origin step j i : ZMod q)) = + fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q) := by + funext i + simp only [affineIntegerPoint, point, Nat.cast_add, Nat.cast_mul, Int.cast_add, Int.cast_mul, + Int.cast_natCast] + simp + +theorem exists_constant_freezing_pair {I J : Type*} + (A : ResidueBoxSlice N q) (hlen : ∀ i, 0 < A.length i) + (origin : ι → ℤ) (step : ℕ) (T : ι → ℝ) (hT : ∀ i, 0 < T i) + {Q : ℕ} (hQ : 0 < Q) + (hparent : ∀ i n, n < N i → |(origin i : ℝ) + step * n| ≤ T i) + (hwidth : ∀ i, (step : ℝ) * q * A.length i ≤ 2 * T i / Q) + (leftLabel : (ι → Fin (Q + 1)) → I) (rightLabel : (ι → ZMod q) → J) + (f : (ι → ℤ) → ℂ) (frozen : I → J → (ι → ℤ) → ℂ) {ε : ℝ} + (hfreeze : ∀ a (x : ι → ℤ), (∀ i, |(x i : ℝ)| ≤ T i) → + (∀ i, |(x i : ℝ) - normalizedRealBoxGrid T Q a i| ≤ T i * (2 / Q)) → + ‖f x - frozen (leftLabel a) (rightLabel (fun i => (x i : ZMod q))) x‖ ≤ ε) : + ∃ a : ι → Fin (Q + 1), + ∀ j : ∀ i, Fin (A.length i), + ‖f (A.affineIntegerPoint origin step j) - + frozen (leftLabel a) + (rightLabel (fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q))) + (A.affineIntegerPoint origin step j)‖ ≤ ε := by + obtain ⟨a, ha⟩ := A.exists_affine_normalized_cell hlen (fun i => (origin i : ℝ)) + (step : ℝ) (Nat.cast_nonneg _) T hT hQ hparent hwidth + refine ⟨a, fun j => ?_⟩ + have hbound (i) : |(A.affineIntegerPoint origin step j i : ℝ)| ≤ T i := by + simpa only [affineIntegerPoint, Int.cast_add, Int.cast_mul, Int.cast_natCast] using + hparent i (A.point j i).val (A.point j i).isLt + have hcell (i) : |(A.affineIntegerPoint origin step j i : ℝ) - + normalizedRealBoxGrid T Q a i| ≤ T i * (2 / Q) := by + simpa only [affineIntegerPoint, Int.cast_add, Int.cast_mul, Int.cast_natCast] using ha j i + simpa only [A.affineIntegerPoint_residue origin step j] using + hfreeze a (A.affineIntegerPoint origin step j) hbound hcell + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3 +open scoped BigOperators + +def affineParentIntegerPoint {ι : Type*} (N : ι → ℕ) + (origin : ι → ℤ) (step : ℕ) (x : ∀ i, Fin (N i)) : ι → ℤ := + fun i => origin i + step * (x i).val + +theorem exists_long_affine_residue_cell_frozen_score + {ι I J : Type*} [Fintype ι] [DecidableEq ι] (N : ι → ℕ) + (hN : ∀ i, 0 < N i) (q Q : ℕ) (hq : 0 < q) (hQ : 0 < Q) + (origin : ι → ℤ) (step : ℕ) (T : ι → ℝ) (hT : ∀ i, 0 < T i) + (hparent : ∀ i n, n < N i → |(origin i : ℝ) + step * n| ≤ T i) + (hparentwidth : ∀ i, (step : ℝ) * N i ≤ 2 * T i) + (hlarge : ∀ i, 2 * (q : ℝ) ≤ (1 / (Q : ℝ)) * N i) + (score : (ι → ℤ) → ℝ) (f : (ι → ℤ) → ℂ) + (frozen : I → J → (ι → ℤ) → ℂ) + (leftLabel : (ι → Fin (Q + 1)) → I) (rightLabel : (ι → ZMod q) → J) + {B τ ε θ S : ℝ} (hB : 0 ≤ B) (hτ : 0 ≤ τ) (hε : 0 ≤ ε) (hθ : 0 < θ) + (hscoreBound : ∀ x : ι → ℤ, (∀ i, |(x i : ℝ)| ≤ T i) → |score x| ≤ 1) + (hcap : ∀ x : ι → ℤ, (∀ i, |(x i : ℝ)| ≤ T i) → score x * (f x).re ≤ B) + (hfreeze : ∀ a (x : ι → ℤ), (∀ i, |(x i : ℝ)| ≤ T i) → + (∀ i, |(x i : ℝ) - normalizedRealBoxGrid T Q a i| ≤ T i * (2 / Q)) → + ‖f x - frozen (leftLabel a) (rightLabel (fun i => (x i : ZMod q))) x‖ ≤ ε) + (hscore : S ≤ 𝔼 x : (∀ i, Fin (N i)), + score (affineParentIntegerPoint N origin step x) * + (f (affineParentIntegerPoint N origin step x)).re) + (hbudget : τ + ε + B * θ < S) : + ∃ A : ResidueBoxSlice N q, (∀ i, 0 < A.length i) ∧ + (∀ i, θ * N i / (4 * q * Q * (Fintype.card ι + 1 : ℝ)) ≤ A.length i) ∧ + ∃ z : ι → Fin (Q + 1), + (∀ j : ∀ i, Fin (A.length i), + ‖f (A.affineIntegerPoint origin step j) - + frozen (leftLabel z) + (rightLabel (fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q))) + (A.affineIntegerPoint origin step j)‖ ≤ ε) ∧ + τ < 𝔼 j : (∀ i, Fin (A.length i)), + score (A.affineIntegerPoint origin step j) * + (frozen (leftLabel z) + (rightLabel (fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q))) + (A.affineIntegerPoint origin step j)).re := by + classical + let point := affineParentIntegerPoint N origin step + let residue := fun r : ι → ZMod q => fun i => (origin i : ZMod q) + (step : ZMod q) * r i + let V := fun r z x => (frozen (leftLabel z) (rightLabel (residue r)) (point x)).re + have hbound (x : ∀ i, Fin (N i)) (i) : |(point x i : ℝ)| ≤ T i := by + simpa only [point, affineParentIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast] using hparent i (x i).val (x i).isLt + have hclose (r : ι → ZMod q) (z : ι → Fin (Q + 1)) (x : ∀ i, Fin (N i)) + (hr : ∀ i, ((x i).val : ZMod q) = r i) + (hz : ∀ i, |(origin i : ℝ) + (step : ℝ) * (x i).val - + normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q)) : + dist (f (point x)).re (V r z x) ≤ ε := by + have hres : (fun i => (point x i : ZMod q)) = residue r := by + funext i + simp only [point, affineParentIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast, hr, residue] + have hcell (i) : |(point x i : ℝ) - normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q) := by + simpa only [point, affineParentIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast] using hz i + have hn := hfreeze z (point x) (hbound x) hcell + rw [hres] at hn + exact (show dist (f (point x)).re (V r z x) ≤ + ‖f (point x) - frozen (leftLabel z) (rightLabel (residue r)) (point x)‖ by + simpa only [Real.dist_eq, V, Complex.sub_re] using + Complex.abs_re_le_norm (f (point x) - + frozen (leftLabel z) (rightLabel (residue r)) (point x))).trans hn + obtain ⟨A, hlen, hlong, r, z, hr, hz, hs⟩ := exists_long_residue_cell_frozen_score + N hN q Q hq hQ (fun i => (origin i : ℝ)) (step : ℝ) (Nat.cast_nonneg _) + T hT hparent hparentwidth hlarge (fun x => score (point x)) (fun x => (f (point x)).re) + V hB hτ hε hθ (fun x => hscoreBound (point x) (hbound x)) + (fun x => hcap (point x) (hbound x)) hclose hscore hbudget + let jzero : ∀ i, Fin (A.length i) := fun i => ⟨0, hlen i⟩ + have hrstart : ∀ i, (A.start i : ZMod q) = r i := by + intro i + simpa only [ResidueBoxSlice.point, jzero, Nat.mul_zero, Nat.add_zero] using hr jzero i + have hresidue : residue r = + fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q) := by + funext i + simp only [residue, Int.cast_add, Int.cast_mul, Int.cast_natCast, hrstart] + refine ⟨A, hlen, hlong, z, ?_, ?_⟩ + · intro j + have hcell (i) : |(A.affineIntegerPoint origin step j i : ℝ) - + normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q) := by + simpa only [ResidueBoxSlice.affineIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast] using hz j i + have hn := hfreeze z (A.affineIntegerPoint origin step j) (hbound (A.point j)) hcell + simpa only [A.affineIntegerPoint_residue origin step j] using hn + · dsimp only [V] at hs + rw [hresidue] at hs + exact hs + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators + +theorem exists_long_affine_residue_cell_frozen_score_with_cell + {ι I J : Type*} [Fintype ι] [DecidableEq ι] (N : ι → ℕ) + (hN : ∀ i, 0 < N i) (q Q : ℕ) (hq : 0 < q) (hQ : 0 < Q) + (origin : ι → ℤ) (step : ℕ) (T : ι → ℝ) (hT : ∀ i, 0 < T i) + (hparent : ∀ i n, n < N i → |(origin i : ℝ) + step * n| ≤ T i) + (hparentwidth : ∀ i, (step : ℝ) * N i ≤ 2 * T i) + (hlarge : ∀ i, 2 * (q : ℝ) ≤ (1 / (Q : ℝ)) * N i) + (score : (ι → ℤ) → ℝ) (f : (ι → ℤ) → ℂ) + (frozen : I → J → (ι → ℤ) → ℂ) + (leftLabel : (ι → Fin (Q + 1)) → I) (rightLabel : (ι → ZMod q) → J) + {B τ ε θ S : ℝ} (hB : 0 ≤ B) (hτ : 0 ≤ τ) (hε : 0 ≤ ε) (hθ : 0 < θ) + (hscoreBound : ∀ x : ι → ℤ, (∀ i, |(x i : ℝ)| ≤ T i) → |score x| ≤ 1) + (hcap : ∀ x : ι → ℤ, (∀ i, |(x i : ℝ)| ≤ T i) → score x * (f x).re ≤ B) + (hfreeze : ∀ a (x : ι → ℤ), (∀ i, |(x i : ℝ)| ≤ T i) → + (∀ i, |(x i : ℝ) - normalizedRealBoxGrid T Q a i| ≤ T i * (2 / Q)) → + ‖f x - frozen (leftLabel a) (rightLabel (fun i => (x i : ZMod q))) x‖ ≤ ε) + (hscore : S ≤ 𝔼 x : (∀ i, Fin (N i)), + score (affineParentIntegerPoint N origin step x) * + (f (affineParentIntegerPoint N origin step x)).re) + (hbudget : τ + ε + B * θ < S) : + ∃ A : ResidueBoxSlice N q, (∀ i, 0 < A.length i) ∧ + (∀ i, θ * N i / (4 * q * Q * (Fintype.card ι + 1 : ℝ)) ≤ A.length i) ∧ + ∃ z : ι → Fin (Q + 1), + (∀ (j : ∀ i, Fin (A.length i)) i, + |(A.affineIntegerPoint origin step j i : ℝ) - + normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q)) ∧ + (∀ j : ∀ i, Fin (A.length i), + ‖f (A.affineIntegerPoint origin step j) - + frozen (leftLabel z) + (rightLabel (fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q))) + (A.affineIntegerPoint origin step j)‖ ≤ ε) ∧ + τ < 𝔼 j : (∀ i, Fin (A.length i)), + score (A.affineIntegerPoint origin step j) * + (frozen (leftLabel z) + (rightLabel (fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q))) + (A.affineIntegerPoint origin step j)).re := by + classical + let point := affineParentIntegerPoint N origin step + let residue := fun r : ι → ZMod q => fun i => (origin i : ZMod q) + (step : ZMod q) * r i + let V := fun r z x => (frozen (leftLabel z) (rightLabel (residue r)) (point x)).re + have hbound (x : ∀ i, Fin (N i)) (i) : |(point x i : ℝ)| ≤ T i := by + simpa only [point, affineParentIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast] using hparent i (x i).val (x i).isLt + have hclose (r : ι → ZMod q) (z : ι → Fin (Q + 1)) (x : ∀ i, Fin (N i)) + (hr : ∀ i, ((x i).val : ZMod q) = r i) + (hz : ∀ i, |(origin i : ℝ) + (step : ℝ) * (x i).val - + normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q)) : + dist (f (point x)).re (V r z x) ≤ ε := by + have hres : (fun i => (point x i : ZMod q)) = residue r := by + funext i + simp only [point, affineParentIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast, hr, residue] + have hcell (i) : |(point x i : ℝ) - normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q) := by + simpa only [point, affineParentIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast] using hz i + have hn := hfreeze z (point x) (hbound x) hcell + rw [hres] at hn + exact (show dist (f (point x)).re (V r z x) ≤ + ‖f (point x) - frozen (leftLabel z) (rightLabel (residue r)) (point x)‖ by + simpa only [Real.dist_eq, V, Complex.sub_re] using + Complex.abs_re_le_norm (f (point x) - + frozen (leftLabel z) (rightLabel (residue r)) (point x))).trans hn + obtain ⟨A, hlen, hlong, r, z, hr, hz, hs⟩ := exists_long_residue_cell_frozen_score + N hN q Q hq hQ (fun i => (origin i : ℝ)) (step : ℝ) (Nat.cast_nonneg _) + T hT hparent hparentwidth hlarge (fun x => score (point x)) (fun x => (f (point x)).re) + V hB hτ hε hθ (fun x => hscoreBound (point x) (hbound x)) + (fun x => hcap (point x) (hbound x)) hclose hscore hbudget + let jzero : ∀ i, Fin (A.length i) := fun i => ⟨0, hlen i⟩ + have hrstart : ∀ i, (A.start i : ZMod q) = r i := by + intro i + simpa only [ResidueBoxSlice.point, jzero, Nat.mul_zero, Nat.add_zero] using hr jzero i + have hresidue : residue r = + fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod q) := by + funext i + simp only [residue, Int.cast_add, Int.cast_mul, Int.cast_natCast, hrstart] + have hcell (j : ∀ i, Fin (A.length i)) (i) : + |(A.affineIntegerPoint origin step j i : ℝ) - + normalizedRealBoxGrid T Q z i| ≤ T i * (2 / Q) := by + simpa only [ResidueBoxSlice.affineIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast] using hz j i + refine ⟨A, hlen, hlong, z, hcell, ?_, ?_⟩ + · intro j + have hn := hfreeze z (A.affineIntegerPoint origin step j) (hbound (A.point j)) (hcell j) + simpa only [A.affineIntegerPoint_residue origin step j] using hn + · dsimp only [V] at hs + rw [hresidue] at hs + exact hs + +end Erdos3 + +end + +section + +namespace Erdos3.ResidueBoxSlice + +open scoped BigOperators Classical + +variable {I : Type*} {N : I → ℕ} {q r : ℕ} + +theorem composeSlice_integerPoint (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) (j : ∀ i, Fin (T.length i)) : + (S.composeSlice T).integerPoint j = S.integerPoint (T.point j) := by + unfold integerPoint + rw [S.composeSlice_point T] + +theorem composeSlice_integerPoint_affine (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) (j : ∀ i, Fin (T.length i)) : + (S.composeSlice T).integerPoint j = + T.affineIntegerPoint (fun i => (S.start i : ℤ)) q j := by + rw [S.composeSlice_integerPoint T] + funext i + simp only [integerPoint, point, affineIntegerPoint, Nat.cast_add, Nat.cast_mul] + +variable [Fintype I] [DecidableEq I] + +theorem composeSlice_integerPoints_eq_affine_image (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) : + (S.composeSlice T).integerPoints = + Finset.univ.image (T.affineIntegerPoint (fun i => (S.start i : ℤ)) q) := by + unfold integerPoints + apply Finset.image_congr + intro j _ + exact S.composeSlice_integerPoint_affine T j + +theorem composeSlice_integerPoints_eq_image (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) : + (S.composeSlice T).integerPoints = + T.integerPoints.image (commonStridePoint (fun i => (S.start i : ℤ)) q) := by + rw [composeSlice_integerPoints_eq_affine_image, integerPoints, Finset.image_image] + apply Finset.image_congr + intro j _ + rfl + +theorem composeSlice_integerPoints_subset (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) : + (S.composeSlice T).integerPoints ⊆ S.integerPoints := by + intro x hx + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hx + exact Finset.mem_image.mpr + ⟨T.point j, Finset.mem_univ _, (S.composeSlice_integerPoint T j).symm⟩ + +theorem expect_composeSlice_integerPoints (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) (hq : 0 < q) (hr : 0 < r) + {V : Type*} [AddCommMonoid V] [Module ℚ≥0 V] (f : (I → ℤ) → V) : + (𝔼 x ∈ (S.composeSlice T).integerPoints, f x) = + 𝔼 j : (∀ i, Fin (T.length i)), + f (T.affineIntegerPoint (fun i => (S.start i : ℤ)) q j) := by + rw [(S.composeSlice T).expect_integerPoints (Nat.mul_pos hq hr) f] + apply Finset.expect_congr rfl + intro j _ + exact congrArg f (S.composeSlice_integerPoint_affine T j) + +theorem composeSlice_isDenseCommonStrideBox (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) (hq : 0 < q) (hr : 0 < r) + {cost loss : ℝ} (hS : IsDenseCommonStrideBox N cost S.integerPoints) + (hT : ∀ i, (S.length i : ℝ) * Real.exp (-loss) ≤ (T.length i : ℝ)) : + IsDenseCommonStrideBox N (cost + loss) (S.composeSlice T).integerPoints := by + refine ⟨fun i => ((S.composeSlice T).start i : ℤ), q * r, + (S.composeSlice T).length, Nat.mul_pos hq hr, ?_, + (S.composeSlice T).progression_inside, ?_, + (S.composeSlice T).integerPoints_eq_commonStrideBox⟩ + · intro i + have hpos : (0 : ℝ) < T.length i := + (mul_pos (Nat.cast_pos.mpr (S.length_pos_of_dense hS i)) + (Real.exp_pos _)).trans_le (hT i) + exact_mod_cast hpos + · exact S.composeSlice_length_lower T (S.length_lower_of_dense hq hS) hT + +theorem composeSlice_isDenseCommonStrideBox_of_fraction (S : ResidueBoxSlice N q) + (T : ResidueBoxSlice S.length r) (hq : 0 < q) (hr : 0 < r) + {cost θ denominator : ℝ} (hS : IsDenseCommonStrideBox N cost S.integerPoints) + (hθ : 0 < θ) (hdenominator : 0 < denominator) + (hT : ∀ i, θ * S.length i / denominator ≤ (T.length i : ℝ)) : + IsDenseCommonStrideBox N (cost + Real.log (denominator / θ)) + (S.composeSlice T).integerPoints := by + apply S.composeSlice_isDenseCommonStrideBox T hq hr hS + intro i + simpa only [Real.exp_neg, Real.exp_log (div_pos hdenominator hθ), inv_div, + ← mul_div_assoc, mul_comm (S.length i : ℝ) θ] using hT i + +theorem refined_stride_le_twice_exp_cost (S : ResidueBoxSlice N q) (hq : 0 < q) + {cost loss : ℝ} (hS : IsDenseCommonStrideBox N cost S.integerPoints) + (i : I) (hlen : 2 ≤ S.length i) (hr : (r : ℝ) ≤ Real.exp loss) : + ((q * r : ℕ) : ℝ) ≤ 2 * Real.exp (cost + loss) := by + have hqbound := S.stride_le_twice_exp_cost i hlen (S.length_lower_of_dense hq hS i) + calc + _ = (q : ℝ) * r := Nat.cast_mul _ _ + _ ≤ (2 * Real.exp cost) * Real.exp loss := + mul_le_mul hqbound hr (Nat.cast_nonneg _) (by positivity) + _ = _ := by rw [Real.exp_add]; ring + +theorem refined_stride_le_exp_cost (S : ResidueBoxSlice N q) (hq : 0 < q) + {cost loss : ℝ} (hS : IsDenseCommonStrideBox N cost S.integerPoints) + (i : I) (hlen : 2 ≤ S.length i) (hr : (r : ℝ) ≤ Real.exp loss) : + ((q * r : ℕ) : ℝ) ≤ Real.exp (cost + loss + 1) := by + apply (S.refined_stride_le_twice_exp_cost hq hS i hlen hr).trans + rw [Real.exp_add (cost + loss) 1] + have htwo : (2 : ℝ) ≤ Real.exp 1 := by + simpa only [one_add_one_eq_two] using Real.add_one_le_exp (1 : ℝ) + calc + _ = Real.exp (cost + loss) * 2 := mul_comm _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left htwo (Real.exp_nonneg _) + +end Erdos3.ResidueBoxSlice + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal BigOperators + +noncomputable def Niltest.markedFrozenValue + {σ L T : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} {v : σ → ℕ} + (test : D.Niltest v) (F : NilpotentLieFiltration T t) (w : σ → ℕ) + (S : T →ₗ[ℚ] L) (hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j) + (EF RF : (F.realification.adaptedPolynomialFiltration w).Group) + (P : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (kE kR : D.RealGroup) (x : σ → ℤ) : ℂ := + test.observable (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (x i : ℝ)) (D.filtration.frozenMarkedLeft F w S hS EF kE * P * + D.filtration.frozenMarkedRight F w S hS RF kR))) + +def MarkedAffineSliceFreezing + {σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} (D : RationalFilteredNilmanifold L s d) + (F : NilpotentLieFiltration T t) (c : Basis κ ℚ T) (φ : L →ₗ⁅ℚ⁆ T) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j) + (w : σ → ℕ) (S : T →ₗ[ℚ] L) + (hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j) + (l : ℕ) (Tbox : σ → ℝ) (A ε B : ℝ) : Prop := + ∃ N Q M m n : ℕ, 0 < N ∧ 0 < Q ∧ (Q : ℝ) ≤ max 1 B ∧ 0 < M ∧ 0 < m ∧ 0 < n ∧ + (Fintype.card (Fin d → Fin (N + 1)) : ℝ) ≤ B ∧ + (Fintype.card (σ → Fin (Q + 1)) : ℝ) ≤ B ∧ + (M : ℝ) ≤ B ∧ (m : ℝ) ≤ B ∧ (n : ℝ) ≤ B ∧ + (Fintype.card ((Fin d → Fin (N + 1)) × Fin n) : ℝ) ≤ B ^ 2 ∧ + ∃ (left : (Fin d → Fin (N + 1)) → D.RealGroup) (right : Fin n → D.RealGroup), + (∀ j, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ (left j) = 1 ∧ + ∀ i, |(D.basis.baseChange ℝ).repr (left j).coord i| ≤ B) ∧ + (∀ j, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ (right j) = 1 ∧ + (∀ i, |(D.basis.baseChange ℝ).repr (right j).coord i| ≤ B) ∧ + (D.basis.baseChange ℝ).equivFun (right j).coord ∈ realDenominatorGrid m) ∧ + ∀ (E : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (EF : (F.realification.adaptedPolynomialFiltration w).Group) + (R : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (RF : (F.realification.adaptedPolynomialFiltration w).Group), + D.filtration.PolynomialSlowBound D.basis w Tbox A E → + F.PolynomialSlowBound c w Tbox A EF → + D.filtration.PolynomialRationalGrid D.basis w l R → + F.PolynomialRationalGrid c w l RF → + D.filtration.realPolynomialGroupMap F φ hφ w E = EF → + D.filtration.realPolynomialGroupMap F φ hφ w R = RF → + (∀ i j, + D.filtration.realPolynomialGroupMap F φ hφ w + (D.filtration.frozenMarkedLeft F w S hS EF (left i)) = EF ∧ + D.filtration.realPolynomialGroupMap F φ hφ w + (D.filtration.frozenMarkedRight F w S hS RF (right j)) = RF) ∧ + ∀ (test : D.Niltest w) + (g P : (D.filtration.realification.adaptedPolynomialFiltration w).Group), + E * P * R = g → + ∀ Nparent : σ → ℕ, (∀ i, 0 < Nparent i) → + ∀ (origin : σ → ℤ) (step : ℕ), + (∀ i v, v < Nparent i → |(origin i : ℝ) + step * v| ≤ Tbox i) → + (∀ i, (step : ℝ) * Nparent i ≤ 2 * Tbox i) → + (∀ i, 2 * (M : ℝ) ≤ (1 / (Q : ℝ)) * Nparent i) → + ∀ (score : (σ → ℤ) → ℝ) (Bscore τ θ Sscore : ℝ), + (test.normBound : ℝ) ≤ Bscore → 0 ≤ τ → 0 < θ → + (∀ x : σ → ℤ, (∀ i, |(x i : ℝ)| ≤ Tbox i) → |score x| ≤ 1) → + (Sscore ≤ 𝔼 x : (∀ i, Fin (Nparent i)), + score (affineParentIntegerPoint Nparent origin step x) * + (test.observable (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (affineParentIntegerPoint Nparent origin step x i : ℝ)) g))).re) → + τ + (test.lipBound : ℝ) * ε + Bscore * θ < Sscore → + ∃ A : ResidueBoxSlice Nparent M, (∀ i, 0 < A.length i) ∧ + (∀ i, θ * Nparent i / (4 * M * Q * (Fintype.card σ + 1 : ℝ)) ≤ A.length i) ∧ + ∃ i j, + (∀ x : ∀ i, Fin (A.length i), + ‖test.observable (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (A.affineIntegerPoint origin step x i : ℝ)) g)) - + test.markedFrozenValue F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)‖ ≤ (test.lipBound : ℝ) * ε) ∧ + τ < 𝔼 x : (∀ i, Fin (A.length i)), + score (A.affineIntegerPoint origin step x) * + (test.markedFrozenValue F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)).re + +theorem BoundedCellMarkedPolynomialFreezing.affine_slice + {σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {F : NilpotentLieFiltration T t} {c : Basis κ ℚ T} {φ : L →ₗ⁅ℚ⁆ T} + {hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j} + {w : σ → ℕ} {S : T →ₗ[ℚ] L} + {hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j} + {l : ℕ} {Tbox : σ → ℝ} {A ε B : ℝ} + (hfreeze : D.BoundedCellMarkedPolynomialFreezing F c φ hφ w S hS l Tbox A ε B) + (hT : ∀ i, 0 < Tbox i) (hε : 0 ≤ ε) : + D.MarkedAffineSliceFreezing F c φ hφ w S hS l Tbox A ε B := by + obtain ⟨N, Q, M, m, n, hN, hQ, hQb, hM, hm, hn, hNc, hQc, hMb, hmb, hnb, + hpair, left, right, hl, hr, hfreeze⟩ := hfreeze + refine ⟨N, Q, M, m, n, hN, hQ, hQb, hM, hm, hn, hNc, hQc, hMb, hmb, hnb, + hpair, left, right, hl, hr, ?_⟩ + intro E EF R RF hE hEF hR hRF hEproj hRproj + obtain ⟨leftLabel, rightLabel, hmarks, herror⟩ := hfreeze E EF R RF hE hEF hR hRF hEproj hRproj + refine ⟨hmarks, ?_⟩ + intro test g P hfac Nparent hNp origin step hparent hwidth hlarge score Bscore τ θ Sscore + hnorm hτ hθ hscoreBound hscore hbudget + let f : (σ → ℤ) → ℂ := fun x => test.observable (QuotientGroup.mk + (D.filtration.adaptedPolynomialRealValueHom w (fun i => (x i : ℝ)) g)) + let frozen := fun i j => test.markedFrozenValue F w S hS EF RF P (left i) (right j) + have hcap (x : σ → ℤ) (hx : ∀ i, |(x i : ℝ)| ≤ Tbox i) : score x * (f x).re ≤ Bscore := by + have hf : |(f x).re| ≤ test.normBound := + (Complex.abs_re_le_norm _).trans (test.norm_le _) + calc + _ ≤ |score x * (f x).re| := le_abs_self _ + _ = |score x| * |(f x).re| := abs_mul _ _ + _ ≤ 1 * (test.normBound : ℝ) := + mul_le_mul (hscoreBound x hx) hf (abs_nonneg _) (by norm_num) + _ ≤ Bscore := by simpa only [one_mul] using hnorm + have hclose (a) (x : σ → ℤ) (hx : ∀ i, |(x i : ℝ)| ≤ Tbox i) + (ha : ∀ i, |(x i : ℝ) - normalizedRealBoxGrid Tbox Q a i| ≤ Tbox i * (2 / Q)) : + ‖f x - frozen (leftLabel a) (rightLabel (fun i => (x i : ZMod M))) x‖ ≤ + (test.lipBound : ℝ) * ε := herror test g P hfac a x hx ha + obtain ⟨A, hlen, hlong, z, herr, hretained⟩ := exists_long_affine_residue_cell_frozen_score + Nparent hNp M Q hM hQ origin step Tbox hT hparent hwidth hlarge score f frozen + leftLabel rightLabel ((NNReal.coe_nonneg _).trans hnorm) hτ + (mul_nonneg (NNReal.coe_nonneg _) hε) hθ hscoreBound hcap hclose hscore hbudget + exact ⟨A, hlen, hlong, leftLabel z, + rightLabel (fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod M)), + herr, hretained⟩ + +theorem exists_uniform_marked_affine_slice_freezing (s a u : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d t : ℕ} (D : RationalFilteredNilmanifold L s d) + (F : NilpotentLieFiltration T t) (c : Basis κ ℚ T) + (ω : Fin d → ℕ) + (_hDlayers : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (τ : κ → ℕ) (_hFlayers : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + (φ : L →ₗ⁅ℚ⁆ T) (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j), + (∀ j, ∀ y ∈ F.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) → + ∀ w : σ → ℕ, (∀ i, 0 < w i) → ∀ p : ℝ, + 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card σ : ℝ) ≤ p → + (Fintype.card κ : ℝ) ≤ p → + (∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p) → + ∃ (S : T →ₗ[ℚ] L) (hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j), + Function.RightInverse S φ ∧ + (∀ i j, RationalHeightLE (D.basis.repr (S (c j)) i) + (rationalKernelHeight (Fintype.card κ) ⌈Real.exp p⌉₊)) ∧ + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∀ Tbox : σ → ℝ, (∀ i, 0 < Tbox i) → + D.MarkedAffineSliceFreezing F c φ hφ w S hS l Tbox + (Real.exp ((p + 2) ^ a)) (Real.exp (-((p + 2) ^ u))) + (Real.exp ((p + C) ^ C)) := by + obtain ⟨C, hC, hbase⟩ := exists_uniform_bounded_cell_marked_polynomial_freezing s a u + refine ⟨C, hC, ?_⟩ + intro σ κ L T _ _ _ _ _ _ _ _ _ _ _ d t D F c ω hDlayers τ hFlayers φ hφ hsurj + w hw p hp hD hσ hκ hφb + obtain ⟨S, hS, hright, hSb, hfreeze⟩ := hbase D F c ω hDlayers τ hFlayers φ hφ hsurj + w hw p hp hD hσ hκ hφb + exact ⟨S, hS, hright, hSb, fun l hl hlp Tbox hT => + (hfreeze l hl hlp Tbox hT).affine_slice hT (Real.exp_nonneg _)⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal BigOperators + +def ExternalMarkedAffineSliceFreezing + {X σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} (D : RationalFilteredNilmanifold L s d) + (F : NilpotentLieFiltration T t) (c : Basis κ ℚ T) (φ : L →ₗ⁅ℚ⁆ T) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j) + (w : σ → ℕ) (S : T →ₗ[ℚ] L) + (hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j) + (l : ℕ) (Tbox : σ → ℝ) (A ε B : ℝ) : Prop := + ∃ N Q M m n : ℕ, 0 < N ∧ 0 < Q ∧ (Q : ℝ) ≤ max 1 B ∧ 0 < M ∧ 0 < m ∧ 0 < n ∧ + (Fintype.card (Fin d → Fin (N + 1)) : ℝ) ≤ B ∧ + (Fintype.card (σ → Fin (Q + 1)) : ℝ) ≤ B ∧ + (M : ℝ) ≤ B ∧ (m : ℝ) ≤ B ∧ (n : ℝ) ≤ B ∧ + (Fintype.card ((Fin d → Fin (N + 1)) × Fin n) : ℝ) ≤ B ^ 2 ∧ + ∃ (left : (Fin d → Fin (N + 1)) → D.RealGroup) (right : Fin n → D.RealGroup), + (∀ j, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ (left j) = 1 ∧ + ∀ i, |(D.basis.baseChange ℝ).repr (left j).coord i| ≤ B) ∧ + (∀ j, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ (right j) = 1 ∧ + (∀ i, |(D.basis.baseChange ℝ).repr (right j).coord i| ≤ B) ∧ + (D.basis.baseChange ℝ).equivFun (right j).coord ∈ realDenominatorGrid m) ∧ + ∀ (E : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (EF : (F.realification.adaptedPolynomialFiltration w).Group) + (R : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (RF : (F.realification.adaptedPolynomialFiltration w).Group), + D.filtration.PolynomialSlowBound D.basis w Tbox A E → + F.PolynomialSlowBound c w Tbox A EF → + D.filtration.PolynomialRationalGrid D.basis w l R → + F.PolynomialRationalGrid c w l RF → + D.filtration.realPolynomialGroupMap F φ hφ w E = EF → + D.filtration.realPolynomialGroupMap F φ hφ w R = RF → + (∀ i j, + D.filtration.realPolynomialGroupMap F φ hφ w + (D.filtration.frozenMarkedLeft F w S hS EF (left i)) = EF ∧ + D.filtration.realPolynomialGroupMap F φ hφ w + (D.filtration.frozenMarkedRight F w S hS RF (right j)) = RF) ∧ + ∀ (tests : X → D.Niltest w) (physical : (σ → ℤ) → X) + (weight : (σ → ℤ) → ℂ) (Bweight Bobs Lip : ℝ), + 0 ≤ Bweight → 0 ≤ Bobs → 0 ≤ Lip → + (∀ x : σ → ℤ, (∀ i, |(x i : ℝ)| ≤ Tbox i) → ‖weight x‖ ≤ Bweight) → + (∀ z, ((tests z).normBound : ℝ) ≤ Bobs) → + (∀ z, ((tests z).lipBound : ℝ) ≤ Lip) → + ∀ (g P : (D.filtration.realification.adaptedPolynomialFiltration w).Group), + E * P * R = g → + ∀ Nparent : σ → ℕ, (∀ i, 0 < Nparent i) → + ∀ (origin : σ → ℤ) (step : ℕ), + (∀ i v, v < Nparent i → |(origin i : ℝ) + step * v| ≤ Tbox i) → + (∀ i, (step : ℝ) * Nparent i ≤ 2 * Tbox i) → + (∀ i, 2 * (M : ℝ) ≤ (1 / (Q : ℝ)) * Nparent i) → + ∀ τ θ Sscore : ℝ, 0 ≤ τ → 0 < θ → + (Sscore ≤ 𝔼 x : (∀ i, Fin (Nparent i)), + (weight (affineParentIntegerPoint Nparent origin step x) * + (tests (physical (affineParentIntegerPoint Nparent origin step x))).observable + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (affineParentIntegerPoint Nparent origin step x i : ℝ)) g))).re) → + τ + Bweight * (Lip * ε) + (Bweight * Bobs) * θ < Sscore → + ∃ A : ResidueBoxSlice Nparent M, (∀ i, 0 < A.length i) ∧ + (∀ i, θ * Nparent i / (4 * M * Q * (Fintype.card σ + 1 : ℝ)) ≤ A.length i) ∧ + ∃ i j, + (∀ x : ∀ i, Fin (A.length i), + ‖(tests (physical (A.affineIntegerPoint origin step x))).observable + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (A.affineIntegerPoint origin step x i : ℝ)) g)) - + (tests (physical (A.affineIntegerPoint origin step x))).markedFrozenValue + F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)‖ ≤ Lip * ε) ∧ + (∀ x : ∀ i, Fin (A.length i), + ‖weight (A.affineIntegerPoint origin step x) * + (tests (physical (A.affineIntegerPoint origin step x))).observable + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (A.affineIntegerPoint origin step x i : ℝ)) g)) - + weight (A.affineIntegerPoint origin step x) * + (tests (physical (A.affineIntegerPoint origin step x))).markedFrozenValue + F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)‖ ≤ Bweight * (Lip * ε)) ∧ + τ < 𝔼 x : (∀ i, Fin (A.length i)), + (weight (A.affineIntegerPoint origin step x) * + (tests (physical (A.affineIntegerPoint origin step x))).markedFrozenValue + F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)).re + +theorem BoundedCellMarkedPolynomialFreezing.external_affine_slice + {X σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {F : NilpotentLieFiltration T t} {c : Basis κ ℚ T} {φ : L →ₗ⁅ℚ⁆ T} + {hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j} + {w : σ → ℕ} {S : T →ₗ[ℚ] L} + {hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j} + {l : ℕ} {Tbox : σ → ℝ} {A ε B : ℝ} + (hfreeze : D.BoundedCellMarkedPolynomialFreezing F c φ hφ w S hS l Tbox A ε B) + (hT : ∀ i, 0 < Tbox i) (hε : 0 ≤ ε) : + D.ExternalMarkedAffineSliceFreezing (X := X) F c φ hφ w S hS l Tbox A ε B := by + obtain ⟨N, Q, M, m, n, hN, hQ, hQb, hM, hm, hn, hNc, hQc, hMb, hmb, hnb, + hpair, left, right, hl, hr, hfreeze⟩ := hfreeze + refine ⟨N, Q, M, m, n, hN, hQ, hQb, hM, hm, hn, hNc, hQc, hMb, hmb, hnb, + hpair, left, right, hl, hr, ?_⟩ + intro E EF R RF hE hEF hR hRF hEproj hRproj + obtain ⟨leftLabel, rightLabel, hmarks, herror⟩ := hfreeze E EF R RF hE hEF hR hRF hEproj hRproj + refine ⟨hmarks, ?_⟩ + intro tests physical weight Bweight Bobs Lip hBw hBo hLip hweight hnorm hlip + g P hfac Nparent hNp origin step hparent hwidth hlarge τ θ Sscore hτ hθ hscore hbudget + let observed : (σ → ℤ) → ℂ := fun x => (tests (physical x)).observable + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w (fun i => (x i : ℝ)) g)) + let frozen := fun i j x => (tests (physical x)).markedFrozenValue + F w S hS EF RF P (left i) (right j) x + let weighted := fun x => weight x * observed x + let weightedFrozen := fun i j x => weight x * frozen i j x + have hcap (x : σ → ℤ) (hx : ∀ i, |(x i : ℝ)| ≤ Tbox i) : + (1 : ℝ) * (weighted x).re ≤ Bweight * Bobs := by + have ho : ‖observed x‖ ≤ Bobs := ((tests (physical x)).norm_le _).trans (hnorm _) + calc + _ = (weighted x).re := one_mul _ + _ ≤ ‖weighted x‖ := (le_abs_self _).trans (Complex.abs_re_le_norm _) + _ = ‖weight x‖ * ‖observed x‖ := norm_mul _ _ + _ ≤ Bweight * Bobs := mul_le_mul (hweight x hx) ho (norm_nonneg _) hBw + have hpoint (a) (x : σ → ℤ) (hx : ∀ i, |(x i : ℝ)| ≤ Tbox i) + (ha : ∀ i, |(x i : ℝ) - normalizedRealBoxGrid Tbox Q a i| ≤ Tbox i * (2 / Q)) : + ‖observed x - frozen (leftLabel a) (rightLabel (fun i => (x i : ZMod M))) x‖ ≤ + Lip * ε := + (herror (tests (physical x)) g P hfac a x hx ha).trans + (mul_le_mul_of_nonneg_right (hlip _) hε) + have hclose (a) (x : σ → ℤ) (hx : ∀ i, |(x i : ℝ)| ≤ Tbox i) + (ha : ∀ i, |(x i : ℝ) - normalizedRealBoxGrid Tbox Q a i| ≤ Tbox i * (2 / Q)) : + ‖weighted x - weightedFrozen (leftLabel a) + (rightLabel (fun i => (x i : ZMod M))) x‖ ≤ Bweight * (Lip * ε) := by + change ‖weight x * observed x - weight x * frozen _ _ x‖ ≤ _ + rw [← mul_sub, norm_mul] + exact mul_le_mul (hweight x hx) (hpoint a x hx ha) (norm_nonneg _) hBw + obtain ⟨A, hlen, hlong, z, hcell, herr, hretained⟩ := + exists_long_affine_residue_cell_frozen_score_with_cell + Nparent hNp M Q hM hQ origin step Tbox hT hparent hwidth hlarge + (fun _ => (1 : ℝ)) weighted weightedFrozen leftLabel rightLabel + (mul_nonneg hBw hBo) hτ (mul_nonneg hBw (mul_nonneg hLip hε)) hθ + (fun _ _ => by norm_num) hcap hclose + (by simpa only [one_mul] using hscore) hbudget + refine ⟨A, hlen, hlong, leftLabel z, + rightLabel (fun i => ((origin i + (step : ℤ) * A.start i : ℤ) : ZMod M)), ?_, herr, ?_⟩ + · intro x + have hx (i) : |(A.affineIntegerPoint origin step x i : ℝ)| ≤ Tbox i := by + simpa only [ResidueBoxSlice.affineIntegerPoint, Int.cast_add, Int.cast_mul, + Int.cast_natCast] using hparent i (A.point x i).val (A.point x i).isLt + have hp := hpoint z (A.affineIntegerPoint origin step x) hx (hcell x) + simpa only [A.affineIntegerPoint_residue origin step x] using hp + · simpa only [one_mul] using hretained + +theorem exists_uniform_external_marked_affine_slice_freezing (s a u : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d t : ℕ} (D : RationalFilteredNilmanifold L s d) + (F : NilpotentLieFiltration T t) (c : Basis κ ℚ T) + (ω : Fin d → ℕ) + (_hDlayers : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (τ : κ → ℕ) (_hFlayers : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + (φ : L →ₗ⁅ℚ⁆ T) (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j), + (∀ j, ∀ y ∈ F.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) → + ∀ w : σ → ℕ, (∀ i, 0 < w i) → ∀ p : ℝ, + 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card σ : ℝ) ≤ p → + (Fintype.card κ : ℝ) ≤ p → + (∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p) → + ∃ (S : T →ₗ[ℚ] L) (hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j), + Function.RightInverse S φ ∧ + (∀ i j, RationalHeightLE (D.basis.repr (S (c j)) i) + (rationalKernelHeight (Fintype.card κ) ⌈Real.exp p⌉₊)) ∧ + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∀ Tbox : σ → ℝ, (∀ i, 0 < Tbox i) → + D.ExternalMarkedAffineSliceFreezing (X := X) F c φ hφ w S hS l Tbox + (Real.exp ((p + 2) ^ a)) (Real.exp (-((p + 2) ^ u))) + (Real.exp ((p + C) ^ C)) := by + obtain ⟨C, hC, hbase⟩ := exists_uniform_bounded_cell_marked_polynomial_freezing s a u + refine ⟨C, hC, ?_⟩ + intro X σ κ L T _ _ _ _ _ _ _ _ _ _ _ d t D F c ω hDlayers τ hFlayers φ hφ hsurj + w hw p hp hD hσ hκ hφb + obtain ⟨S, hS, hright, hSb, hfreeze⟩ := hbase D F c ω hDlayers τ hFlayers φ hφ hsurj + w hw p hp hD hσ hκ hφb + exact ⟨S, hS, hright, hSb, fun l hl hlp Tbox hT => + (hfreeze l hl hlp Tbox hT).external_affine_slice hT (Real.exp_nonneg _)⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal BigOperators + +namespace ExternalMarkedAffineSliceFreezing + +structure Dictionary + {X σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} (D : RationalFilteredNilmanifold L s d) + (F : NilpotentLieFiltration T t) (c : Basis κ ℚ T) (φ : L →ₗ⁅ℚ⁆ T) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j) + (w : σ → ℕ) (S : T →ₗ[ℚ] L) + (hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j) + (l : ℕ) (Tbox : σ → ℝ) (A ε B : ℝ) where + grid : ℕ + Q : ℕ + modulus : ℕ + denominator : ℕ + rightCount : ℕ + grid_pos : 0 < grid + Q_pos : 0 < Q + modulus_pos : 0 < modulus + denominator_pos : 0 < denominator + rightCount_pos : 0 < rightCount + Q_bound : (Q : ℝ) ≤ max 1 B + gridCard_bound : (Fintype.card (Fin d → Fin (grid + 1)) : ℝ) ≤ B + cellCard_bound : (Fintype.card (σ → Fin (Q + 1)) : ℝ) ≤ B + modulus_bound : (modulus : ℝ) ≤ B + denominator_bound : (denominator : ℝ) ≤ B + rightCount_bound : (rightCount : ℝ) ≤ B + pairCard_bound : (Fintype.card ((Fin d → Fin (grid + 1)) × Fin rightCount) : ℝ) ≤ B ^ 2 + left : (Fin d → Fin (grid + 1)) → D.RealGroup + right : Fin rightCount → D.RealGroup + left_bounds : ∀ j, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ (left j) = 1 ∧ + ∀ i, |(D.basis.baseChange ℝ).repr (left j).coord i| ≤ B + right_bounds : ∀ j, realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) φ (right j) = 1 ∧ + (∀ i, |(D.basis.baseChange ℝ).repr (right j).coord i| ≤ B) ∧ + (D.basis.baseChange ℝ).equivFun (right j).coord ∈ realDenominatorGrid denominator + select : ∀ (E : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (EF : (F.realification.adaptedPolynomialFiltration w).Group) + (R : (D.filtration.realification.adaptedPolynomialFiltration w).Group) + (RF : (F.realification.adaptedPolynomialFiltration w).Group), + D.filtration.PolynomialSlowBound D.basis w Tbox A E → + F.PolynomialSlowBound c w Tbox A EF → + D.filtration.PolynomialRationalGrid D.basis w l R → + F.PolynomialRationalGrid c w l RF → + D.filtration.realPolynomialGroupMap F φ hφ w E = EF → + D.filtration.realPolynomialGroupMap F φ hφ w R = RF → + (∀ i j, + D.filtration.realPolynomialGroupMap F φ hφ w + (D.filtration.frozenMarkedLeft F w S hS EF (left i)) = EF ∧ + D.filtration.realPolynomialGroupMap F φ hφ w + (D.filtration.frozenMarkedRight F w S hS RF (right j)) = RF) ∧ + ∀ (tests : X → D.Niltest w) (physical : (σ → ℤ) → X) + (weight : (σ → ℤ) → ℂ) (Bweight Bobs Lip : ℝ), + 0 ≤ Bweight → 0 ≤ Bobs → 0 ≤ Lip → + (∀ x : σ → ℤ, (∀ i, |(x i : ℝ)| ≤ Tbox i) → ‖weight x‖ ≤ Bweight) → + (∀ z, ((tests z).normBound : ℝ) ≤ Bobs) → + (∀ z, ((tests z).lipBound : ℝ) ≤ Lip) → + ∀ (g P : (D.filtration.realification.adaptedPolynomialFiltration w).Group), + E * P * R = g → + ∀ Nparent : σ → ℕ, (∀ i, 0 < Nparent i) → + ∀ (origin : σ → ℤ) (step : ℕ), + (∀ i v, v < Nparent i → |(origin i : ℝ) + step * v| ≤ Tbox i) → + (∀ i, (step : ℝ) * Nparent i ≤ 2 * Tbox i) → + (∀ i, 2 * (modulus : ℝ) ≤ (1 / (Q : ℝ)) * Nparent i) → + ∀ τ θ Sscore : ℝ, 0 ≤ τ → 0 < θ → + (Sscore ≤ 𝔼 x : (∀ i, Fin (Nparent i)), + (weight (affineParentIntegerPoint Nparent origin step x) * + (tests (physical (affineParentIntegerPoint Nparent origin step x))).observable + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (affineParentIntegerPoint Nparent origin step x i : ℝ)) g))).re) → + τ + Bweight * (Lip * ε) + (Bweight * Bobs) * θ < Sscore → + ∃ A : ResidueBoxSlice Nparent modulus, (∀ i, 0 < A.length i) ∧ + (∀ i, θ * Nparent i / (4 * modulus * Q * (Fintype.card σ + 1 : ℝ)) ≤ A.length i) ∧ + ∃ i j, + (∀ x : ∀ i, Fin (A.length i), + ‖(tests (physical (A.affineIntegerPoint origin step x))).observable + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (A.affineIntegerPoint origin step x i : ℝ)) g)) - + (tests (physical (A.affineIntegerPoint origin step x))).markedFrozenValue + F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)‖ ≤ Lip * ε) ∧ + (∀ x : ∀ i, Fin (A.length i), + ‖weight (A.affineIntegerPoint origin step x) * + (tests (physical (A.affineIntegerPoint origin step x))).observable + (QuotientGroup.mk (D.filtration.adaptedPolynomialRealValueHom w + (fun i => (A.affineIntegerPoint origin step x i : ℝ)) g)) - + weight (A.affineIntegerPoint origin step x) * + (tests (physical (A.affineIntegerPoint origin step x))).markedFrozenValue + F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)‖ ≤ Bweight * (Lip * ε)) ∧ + τ < 𝔼 x : (∀ i, Fin (A.length i)), + (weight (A.affineIntegerPoint origin step x) * + (tests (physical (A.affineIntegerPoint origin step x))).markedFrozenValue + F w S hS EF RF P (left i) (right j) + (A.affineIntegerPoint origin step x)).re + +theorem exists_dictionary + {X σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {F : NilpotentLieFiltration T t} {c : Basis κ ℚ T} {φ : L →ₗ⁅ℚ⁆ T} + {hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j} + {w : σ → ℕ} {S : T →ₗ[ℚ] L} + {hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j} + {l : ℕ} {Tbox : σ → ℝ} {A ε B : ℝ} + (hfreeze : D.ExternalMarkedAffineSliceFreezing (X := X) F c φ hφ w S hS l Tbox A ε B) : + Nonempty (Dictionary (X := X) D F c φ hφ w S hS l Tbox A ε B) := by + obtain ⟨grid, Q, modulus, denominator, rightCount, hgrid, hQ, hQbound, + hmodulus, hdenominator, hrightCount, hgridCard, hcellCard, hmodulusBound, + hdenominatorBound, hrightCountBound, hpairCard, left, right, hleft, hright, + hselect⟩ := hfreeze + exact ⟨⟨grid, Q, modulus, denominator, rightCount, hgrid, hQ, hmodulus, + hdenominator, hrightCount, hQbound, hgridCard, hcellCard, hmodulusBound, + hdenominatorBound, hrightCountBound, hpairCard, left, right, hleft, hright, + hselect⟩⟩ + +end ExternalMarkedAffineSliceFreezing + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.ExternalMarkedAffineSliceFreezing.Dictionary + +open Module +open scoped TensorProduct + +variable {X σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {F : NilpotentLieFiltration T t} {c : Basis κ ℚ T} {φ : L →ₗ⁅ℚ⁆ T} + {hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j} + {w : σ → ℕ} {S : T →ₗ[ℚ] L} + {hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j} + {l : ℕ} {Tbox : σ → ℝ} {A A' ε B : ℝ} + (dictionary : Dictionary (X := X) D F c φ hφ w S hS l Tbox A ε B) + +def mono_slow (hT : ∀ i, 0 < Tbox i) (hslow : A' ≤ A) : + Dictionary (X := X) D F c φ hφ w S hS l Tbox A' ε B where + grid := dictionary.grid + Q := dictionary.Q + modulus := dictionary.modulus + denominator := dictionary.denominator + rightCount := dictionary.rightCount + grid_pos := dictionary.grid_pos + Q_pos := dictionary.Q_pos + modulus_pos := dictionary.modulus_pos + denominator_pos := dictionary.denominator_pos + rightCount_pos := dictionary.rightCount_pos + Q_bound := dictionary.Q_bound + gridCard_bound := dictionary.gridCard_bound + cellCard_bound := dictionary.cellCard_bound + modulus_bound := dictionary.modulus_bound + denominator_bound := dictionary.denominator_bound + rightCount_bound := dictionary.rightCount_bound + pairCard_bound := dictionary.pairCard_bound + left := dictionary.left + right := dictionary.right + left_bounds := dictionary.left_bounds + right_bounds := dictionary.right_bounds + select := by + intro E EF R RF hE hEF + exact dictionary.select E EF R RF + (D.filtration.polynomialSlowBound_mono D.basis w Tbox hT hslow E hE) + (F.polynomialSlowBound_mono c w Tbox hT hslow EF hEF) + +variable (hT : ∀ i, 0 < Tbox i) (hslow : A' ≤ A) + +@[simp] theorem mono_slow_grid : + (dictionary.mono_slow hT hslow).grid = dictionary.grid := rfl + +@[simp] theorem mono_slow_Q : + (dictionary.mono_slow hT hslow).Q = dictionary.Q := rfl + +@[simp] theorem mono_slow_modulus : + (dictionary.mono_slow hT hslow).modulus = dictionary.modulus := rfl + +@[simp] theorem mono_slow_denominator : + (dictionary.mono_slow hT hslow).denominator = dictionary.denominator := rfl + +@[simp] theorem mono_slow_rightCount : + (dictionary.mono_slow hT hslow).rightCount = dictionary.rightCount := rfl + +@[simp] theorem mono_slow_left : + (dictionary.mono_slow hT hslow).left = dictionary.left := rfl + +@[simp] theorem mono_slow_right : + (dictionary.mono_slow hT hslow).right = dictionary.right := rfl + +end Erdos3.RationalFilteredNilmanifold.ExternalMarkedAffineSliceFreezing.Dictionary + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +theorem exists_uniform_external_marked_affine_slice_freezing_dictionary (s a u : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X σ κ L T : Type*} [Fintype σ] [DecidableEq σ] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing T] [LieAlgebra ℚ T] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d t : ℕ} (D : RationalFilteredNilmanifold L s d) + (F : NilpotentLieFiltration T t) (c : Basis κ ℚ T) + (ω : Fin d → ℕ) + (_hDlayers : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (τ : κ → ℕ) (_hFlayers : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + (φ : L →ₗ⁅ℚ⁆ T) (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ F.layer j), + (∀ j, ∀ y ∈ F.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) → + ∀ w : σ → ℕ, (∀ i, 0 < w i) → ∀ p : ℝ, + 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card σ : ℝ) ≤ p → + (Fintype.card κ : ℝ) ≤ p → + (∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p) → + ∃ (S : T →ₗ[ℚ] L) (hS : ∀ j, ∀ y ∈ F.layer j, S y ∈ D.filtration.layer j), + Function.RightInverse S φ ∧ + (∀ i j, RationalHeightLE (D.basis.repr (S (c j)) i) + (rationalKernelHeight (Fintype.card κ) ⌈Real.exp p⌉₊)) ∧ + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∀ Tbox : σ → ℝ, (∀ i, 0 < Tbox i) → + ∀ slow : ℝ, slow ≤ Real.exp ((p + 2) ^ a) → + Nonempty (ExternalMarkedAffineSliceFreezing.Dictionary (X := X) + D F c φ hφ w S hS l Tbox slow (Real.exp (-((p + 2) ^ u))) + (Real.exp ((p + C) ^ C))) := by + obtain ⟨C, hC, hbase⟩ := exists_uniform_external_marked_affine_slice_freezing s a u + refine ⟨C, hC, ?_⟩ + intro X σ κ L T _ _ _ _ _ _ _ _ _ _ _ d t D F c ω hDlayers τ hFlayers φ hφ hsurj + w hw p hp hD hσ hκ hφb + obtain ⟨S, hS, hright, hSb, hfreeze⟩ := hbase D F c ω hDlayers τ hFlayers φ hφ hsurj + w hw p hp hD hσ hκ hφb + refine ⟨S, hS, hright, hSb, ?_⟩ + intro l hl hlp Tbox hT slow hslow + obtain ⟨dictionary⟩ := (hfreeze l hl hlp Tbox hT).exists_dictionary + exact ⟨dictionary.mono_slow hT hslow⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/UniformResidueDescentParameters.lean b/lean/OAI/Combinatorics/Progressions/Lattices/UniformResidueDescentParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5388be0b7e6b22bd174a12d180a1283a142b780 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/UniformResidueDescentParameters.lean @@ -0,0 +1,58 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialResidueDescentSize + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_uniform_residue_descent_parameters (A B C : ℕ) : + ∃ K : ℕ, 2 ≤ K ∧ ∀ p : ℝ, 0 ≤ p → ∀ Δ : ℝ, + 0 < Δ → Δ ≤ 1 → Δ⁻¹ ≤ Real.exp p → + ∃ rho q ε δ : ℝ, + p + 16 ≤ q ∧ verticalDecompositionBudget (p + 16) ≤ q ∧ q ≤ (p + 2) ^ K ∧ + 0 < rho ∧ rho⁻¹ ≤ Real.exp (p + 16) ∧ + 0 < ε ∧ ε < 1 / 2 ∧ 0 < δ ∧ δ ≤ 1 ∧ + ε⁻¹ ≤ Real.exp ((p + 2) ^ K) ∧ δ⁻¹ ≤ Real.exp ((p + 2) ^ K) ∧ + 2 * (2 * rho + Real.exp (verticalDecompositionBudget (p + 16) - q)) ≤ Δ / 2 ∧ + 8 * ε + 2 * (Real.exp (((p + 16) + 2) ^ C) * δ) = Δ / 4 ∧ + ∀ {σ : Type*} [Fintype σ] (N : σ → ℕ) (M P : ℕ) (J : σ → ℕ), + (M : ℝ) ≤ Real.exp ((p + 2) ^ A) → (P : ℝ) ≤ Real.exp ((p + 2) ^ A) → + (∀ i, (J i : ℝ) ≤ Real.exp ((p + 2) ^ A)) → + (Fintype.card σ : ℝ) ≤ Real.exp ((p + 2) ^ A) → + (∀ i, Real.exp ((p + 2) ^ K) ≤ (N i : ℝ)) → + (∀ i, ((M * J i : ℕ) : ℝ) * (Real.exp ((q + B) ^ B) + 1) ≤ (N i : ℝ)) ∧ + (∀ i, 8 ≤ δ * (N i : ℝ)) ∧ + (∑ i, ((Nat.lcm M (M * P) * J i : ℕ) : ℝ) / (N i : ℝ)) ≤ δ * ε / 8 := by + obtain ⟨D, _, hprecision⟩ := exists_residue_event_descent_precision C + let R := max A D + obtain ⟨K₀, hK₀, hsize⟩ := exists_polynomial_residue_descent_size R B + let K := max R K₀ + refine ⟨K, hK₀.trans (le_max_right _ _), ?_⟩ + intro p hp Δ hΔ hΔone hΔinv + obtain ⟨rho, q, ε, δ, hpq, hfreq, hq, hrho, hrhop, hε, hεhalf, hδ, hδone, + hεbound, hδbound, hprojection, hfreezing⟩ := hprecision p hp Δ hΔ hΔone hΔinv + have hpbase : 1 ≤ p + 2 := by linarith + have hAR : (p + 2) ^ A ≤ (p + 2) ^ R := pow_le_pow_right₀ hpbase (le_max_left _ _) + have hDR : (p + 2) ^ D ≤ (p + 2) ^ R := pow_le_pow_right₀ hpbase (le_max_right _ _) + have hRK : (p + 2) ^ R ≤ (p + 2) ^ K := pow_le_pow_right₀ hpbase (le_max_left _ _) + have hK₀K : (p + 2) ^ K₀ ≤ (p + 2) ^ K := pow_le_pow_right₀ hpbase (le_max_right _ _) + have hDK : Real.exp ((p + 2) ^ D) ≤ Real.exp ((p + 2) ^ K) := + Real.exp_le_exp.mpr (hDR.trans hRK) + refine ⟨rho, q, ε, δ, hpq, hfreq, hq.trans (hDR.trans hRK), hrho, hrhop, + hε, hεhalf, hδ, hδone, hεbound.trans hDK, hδbound.trans hDK, hprojection, hfreezing, ?_⟩ + intro σ _ N M P J hM hP hJ hcard hN + have hExpAR := Real.exp_le_exp.mpr hAR + have hExpDR := Real.exp_le_exp.mpr hDR + exact hsize p q hp (by linarith) (hq.trans hDR) N M P J ε δ + (hM.trans hExpAR) (hP.trans hExpAR) (fun i => (hJ i).trans hExpAR) + (hcard.trans hExpAR) hε hδ (hεbound.trans hExpDR) (hδbound.trans hExpDR) + (fun i => (Real.exp_le_exp.mpr hK₀K).trans (hN i)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/UniformResidueSmallPeriod.lean b/lean/OAI/Combinatorics/Progressions/Lattices/UniformResidueSmallPeriod.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f2dee563007c6ebf1b18b19d0a6a0a22cc04ca7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/UniformResidueSmallPeriod.lean @@ -0,0 +1,225 @@ +import Mathlib.Probability.Distributions.Uniform +import OAI.Combinatorics.Progressions.Estimates.CoefficientRowReindex + +namespace OAI + + +namespace Erdos3 + +open scoped BigOperators Classical Matrix + +theorem uniformPMF_map_fiber {G H : Type*} [Fintype G] [Nonempty G] + [DecidableEq H] (f : G → H) (y : H) : + ((PMF.uniformOfFintype G).map f y).toReal = + ((Finset.univ.filter (fun x => f x = y)).card : ℝ) / Fintype.card G := by + classical + rw [pmf_map_toReal_indicator, tsum_fintype] + simp only [PMF.uniformOfFintype_apply, ENNReal.toReal_inv, ENNReal.toReal_natCast, + mul_ite, mul_one, mul_zero] + rw [← Finset.sum_filter] + simp only [Finset.sum_const, nsmul_eq_mul, div_eq_mul_inv] + +theorem uniformPMF_map_hom_image {G H : Type*} [AddCommGroup G] [AddCommGroup H] + [Fintype G] [Fintype H] (f : G →+ H) (y : H) : + ((PMF.uniformOfFintype G).map f y).toReal = + if y ∈ f.range then (Nat.card f.range : ℝ)⁻¹ else 0 := by + classical + rw [uniformPMF_map_fiber] + by_cases hy : y ∈ f.range + · simp only [hy, ite_true] + have he := AddMonoidHom.card_fiber_eq_of_mem_range f hy + (show (0 : H) ∈ Set.range f from ⟨0, f.map_zero⟩) + have hk : (Finset.univ.filter (fun x => f x = 0)).card = Fintype.card f.ker := by + simp [Fintype.card_subtype, AddMonoidHom.mem_ker] + have hc : Fintype.card f.ker * Fintype.card f.range = Fintype.card G := by + simpa only [AddSubgroup.index_ker, Nat.card_eq_fintype_card] using f.ker.card_mul_index + rw [he, hk, ← hc, Nat.cast_mul, Nat.card_eq_fintype_card] + have hkn : (Fintype.card f.ker : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + field_simp + · simp only [hy, ite_false] + have hz : Finset.univ.filter (fun x => f x = y) = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro x hx + exact hy ⟨x, (Finset.mem_filter.mp hx).2⟩ + simp [hz] + +theorem uniformPMF_map_hom_index {G H : Type*} [AddCommGroup G] [AddCommGroup H] + [Fintype G] [Fintype H] (f : G →+ H) (y : H) : + ((PMF.uniformOfFintype G).map f y).toReal = + (if y ∈ f.range then (f.range.index : ℝ) else 0) / Fintype.card H := by + classical + rw [uniformPMF_map_hom_image] + by_cases hy : y ∈ f.range + · simp only [hy, ite_true] + have hcard : (Nat.card f.range : ℝ) * f.range.index = Fintype.card H := by + have h := f.range.card_mul_index + rw [Nat.card_eq_fintype_card (α := H)] at h + exact_mod_cast h + have hn : (Nat.card f.range : ℝ) ≠ 0 := by exact_mod_cast Nat.card_pos.ne' + have hh : (Fintype.card H : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + apply (eq_div_iff hh).mpr + rw [← hcard, ← mul_assoc, inv_mul_cancel₀ hn, one_mul] + · simp [hy] + +theorem uniformResidueMatrix_image_mask {I J : Type*} [Fintype I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (d : ℕ) [NeZero d] + (hperiod : integerScalarLattice I (d : ℤ) ≤ A.mulVecLin.range) (v : I → ℤ) : + ((PMF.uniformOfFintype (J → ZMod d)).map + (fun x => integerResidueMatrix A d *ᵥ x) (integerResidueMap I d v)).toReal = + coefficientImageMultiplier A v / (d : ℝ) ^ Fintype.card I := by + classical + let f := (integerResidueMatrix A d).mulVecLin.toAddMonoidHom + have hr : f.range = (residueLatticeImage A.mulVecLin.range d).toAddSubgroup := by + ext y + exact (integerMatrixResidue_mem A d y).symm + have hm : integerResidueMap I d v ∈ f.range ↔ v ∈ A.mulVecLin.range := by + rw [hr] + exact (residueLatticeImage_mem_iff _ _ hperiod v).symm + have hi : f.range.index = A.mulVecLin.range.toAddSubgroup.index := by + rw [hr, residueLatticeImage_index _ _ hperiod] + change ((PMF.uniformOfFintype (J → ZMod d)).map f _).toReal = _ + rw [uniformPMF_map_hom_index] + simp only [hm, hi, coefficientImageMultiplier, Fintype.card_fun, ZMod.card, Nat.cast_pow] + +end Erdos3 + + +namespace Erdos3 + +open scoped BigOperators Classical Matrix + +theorem residueLatticeImage_index_le_period {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (d m : ℕ) [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ L) : + (residueLatticeImage L d).toAddSubgroup.index ≤ m ^ Fintype.card I := by + have hcard := residueLatticeImage_card_mul_index L m hperiod + have hn : L.toAddSubgroup.index ≠ 0 := by + intro h + rw [h, mul_zero] at hcard + exact pow_ne_zero _ (NeZero.ne m) hcard.symm + have hd := L.toAddSubgroup.index_map_dvd (f := (integerResidueMap I d).toAddMonoidHom) + (integerResidueMap_surjective I d) + exact (Nat.le_of_dvd (Nat.pos_of_ne_zero hn) hd).trans + (residueLatticeImage_index_le L m hperiod) + +theorem uniformResidueMatrix_density_bound {I J : Type*} [Fintype I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (d m : ℕ) [NeZero d] [NeZero m] + (hperiod : integerScalarLattice I (m : ℤ) ≤ A.mulVecLin.range) (r : I → ZMod d) : + (d : ℝ) ^ Fintype.card I * + (((PMF.uniformOfFintype (J → ZMod d)).map + (fun x => integerResidueMatrix A d *ᵥ x)) r).toReal ≤ (m : ℝ) ^ Fintype.card I := by + let f := (integerResidueMatrix A d).mulVecLin.toAddMonoidHom + have hr : f.range = (residueLatticeImage A.mulVecLin.range d).toAddSubgroup := by + ext y + exact (integerMatrixResidue_mem A d y).symm + have hi : (f.range.index : ℝ) ≤ (m : ℝ) ^ Fintype.card I := by + rw [hr] + exact_mod_cast residueLatticeImage_index_le_period A.mulVecLin.range d m hperiod + have hc : (Fintype.card (I → ZMod d) : ℝ) = (d : ℝ) ^ Fintype.card I := by + simp only [Fintype.card_fun, ZMod.card, Nat.cast_pow] + have hc0 : (Fintype.card (I → ZMod d) : ℝ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero + change (d : ℝ) ^ Fintype.card I * (((PMF.uniformOfFintype (J → ZMod d)).map f) r).toReal ≤ _ + rw [uniformPMF_map_hom_index, ← hc] + by_cases h : r ∈ f.range + · simp only [h, ite_true] + convert hi using 1 + field_simp + · simp only [h, ite_false, zero_div, mul_zero] + positivity + +theorem uniformResidueMatrix_family_density_bound {T : Type*} [Fintype T] + {I J B : T → Type*} [∀ t, Fintype (I t)] [∀ t, Fintype (J t)] + [∀ t, DecidableEq (J t)] [∀ t, Fintype (B t)] + (A : ∀ t, Matrix (I t) (J t) ℤ) (d period : ℕ) [NeZero d] [NeZero period] + (hperiod : ∀ t, integerScalarLattice (I t) (period : ℤ) ≤ (A t).mulVecLin.range) + (r : ∀ t, I t → B t → ZMod d) : + (∏ t, ∏ i : B t, (d : ℝ) ^ Fintype.card (I t) * + (((PMF.uniformOfFintype (J t → ZMod d)).map + (fun z => integerResidueMatrix (A t) d *ᵥ z)) (fun x => r t x i)).toReal) ≤ + ∏ t, ∏ _i : B t, (period : ℝ) ^ Fintype.card (I t) := by + apply Finset.prod_le_prod₀ + · intro t _ + positivity + · intro t _ + apply Finset.prod_le_prod₀ + · intro i _ + positivity + · intro i _ + exact uniformResidueMatrix_density_bound (A t) d period (hperiod t) (fun x => r t x i) + +end Erdos3 + + +namespace Erdos3 + +open scoped BigOperators Classical Matrix + +theorem uniformPMF_map_hom_toReal_eq_of_sub_mem {G H : Type*} + [AddCommGroup G] [AddCommGroup H] [Fintype G] [Fintype H] + (f : G →+ H) {x y : H} (hxy : x - y ∈ f.range) : + (((PMF.uniformOfFintype G).map f) x).toReal = + (((PMF.uniformOfFintype G).map f) y).toReal := by + have hmem : x ∈ f.range ↔ y ∈ f.range := by + constructor + · intro hx + simpa only [sub_sub_cancel] using f.range.sub_mem hx hxy + · intro hy + simpa only [sub_add_cancel] using f.range.add_mem hxy hy + simp only [uniformPMF_map_hom_image, hmem] + +theorem uniformResidueMatrix_toReal_eq_of_period {I J : Type*} + [Fintype I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (d period : ℕ) [NeZero d] + (hperiod : integerScalarLattice I (period : ℤ) ≤ A.mulVecLin.range) + (v w : I → ℤ) (hvw : integerResidueMap I period v = integerResidueMap I period w) : + (((PMF.uniformOfFintype (J → ZMod d)).map + (fun z => integerResidueMatrix A d *ᵥ z)) (integerResidueMap I d v)).toReal = + (((PMF.uniformOfFintype (J → ZMod d)).map + (fun z => integerResidueMatrix A d *ᵥ z)) (integerResidueMap I d w)).toReal := by + have hdiff : v - w ∈ A.mulVecLin.range := by + apply hperiod + rw [← integerResidueMap_ker, LinearMap.mem_ker, map_sub, hvw, sub_self] + have himage : integerResidueMap I d (v - w) ∈ residueLatticeImage A.mulVecLin.range d := + ⟨v - w, hdiff, rfl⟩ + obtain ⟨z, hz⟩ := (integerMatrixResidue_mem A d _).mp himage + apply uniformPMF_map_hom_toReal_eq_of_sub_mem (integerResidueMatrix A d).mulVecLin.toAddMonoidHom + exact ⟨z, hz.trans (map_sub (integerResidueMap I d) v w)⟩ + +noncomputable def uniformResidueSmallPeriodDensity {I J : Type*} + [Fintype I] [Fintype J] [DecidableEq J] (A : Matrix I J ℤ) (d period : ℕ) [NeZero d] + (r : I → ZMod period) : ℝ := + (d : ℝ) ^ Fintype.card I * + (((PMF.uniformOfFintype (J → ZMod d)).map + (fun z => integerResidueMatrix A d *ᵥ z)) + (fun i => ((r i).val : ZMod d))).toReal + +theorem uniformResidueSmallPeriodDensity_apply {I J : Type*} + [Fintype I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (d period : ℕ) [NeZero d] [NeZero period] + (hperiod : integerScalarLattice I (period : ℤ) ≤ A.mulVecLin.range) (v : I → ℤ) : + uniformResidueSmallPeriodDensity A d period (integerResidueMap I period v) = + (d : ℝ) ^ Fintype.card I * + (((PMF.uniformOfFintype (J → ZMod d)).map + (fun z => integerResidueMatrix A d *ᵥ z)) (integerResidueMap I d v)).toReal := by + unfold uniformResidueSmallPeriodDensity + congr 1 + have h := uniformResidueMatrix_toReal_eq_of_period A d period hperiod + (fun i => (((v i : ZMod period).val : ℕ) : ℤ)) v (by + ext i + simp only [integerResidueMap_apply, Int.cast_natCast, ZMod.natCast_zmod_val]) + simpa only [integerResidueMap, LinearMap.coe_mk, AddHom.coe_mk, Int.cast_natCast] using h + +theorem uniformResidueSmallPeriodDensity_bounds {I J : Type*} + [Fintype I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (d period : ℕ) [NeZero d] [NeZero period] + (hperiod : integerScalarLattice I (period : ℤ) ≤ A.mulVecLin.range) (r : I → ZMod period) : + 0 ≤ uniformResidueSmallPeriodDensity A d period r ∧ + uniformResidueSmallPeriodDensity A d period r ≤ (period : ℝ) ^ Fintype.card I := by + constructor + · exact mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) ENNReal.toReal_nonneg + · exact uniformResidueMatrix_density_bound A d period hperiod _ + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedCubeIntegerSupport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedCubeIntegerSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..c22af6ba792bd9ad4a4f682f50898fd980c53210 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedCubeIntegerSupport.lean @@ -0,0 +1,508 @@ +import OAI.Combinatorics.Progressions.Fourier.UniformSpectrumAbsoluteCap + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def integerGridMass {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (M : ℕ) (z : J → ℤ) : ℝ := + finiteImageMass p (fun x => integerGridResidue M (Y x)) (integerGridResidue M z) + +noncomputable def integerGridCoefficient {X J : Type*} [Fintype X] [Fintype J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (M : ℕ) [NeZero M] (k : J → Fin M) : ℂ := + p.complexMean (fun x => rectangularGridCharacter M k (Y x)) + +theorem integerGridMass_nonneg {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (M : ℕ) (z : J → ℤ) : + 0 ≤ integerGridMass p Y M z := + p.mean_nonneg (fun _ => by split_ifs <;> norm_num) + +theorem integerGridFourier_inversion {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (M : ℕ) [NeZero M] (z : J → ℤ) : + (∑ k : J → Fin M, integerGridCoefficient p Y M k * star (rectangularGridCharacter M k z)) = + (M : ℂ) ^ Fintype.card J * integerGridMass p Y M z := by + classical + calc + _ = ∑ x, (p.weight x : ℂ) * + (∑ k : J → Fin M, rectangularGridCharacter M k (Y x) * star (rectangularGridCharacter M k z)) := by + simp only [integerGridCoefficient, FiniteProbabilityWeights.complexMean, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro k _ + ring + _ = _ := by + simp only [rectangularGridCharacter_orthogonality, integerGridMass, finiteImageMass, + FiniteProbabilityWeights.mean, Complex.ofReal_sum, Complex.ofReal_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + by_cases hx : integerGridResidue M (Y x) = integerGridResidue M z <;> simp [hx, mul_comm] + +theorem independent_integerGridCoefficient {B J : Type*} [Fintype B] [DecidableEq B] [Fintype J] + {X : B → Type*} [∀ b, Fintype (X b)] (p : ∀ b, FiniteProbabilityWeights (X b)) + (Y : ∀ b, X b → J → ℤ) (shift : J → ℤ) (M : ℕ) [NeZero M] (k : J → Fin M) : + integerGridCoefficient (FiniteProbabilityWeights.pi p) (fun x => shift + ∑ b, Y b (x b)) M k = + rectangularGridCharacter M k shift * ∏ b, integerGridCoefficient (p b) (Y b) M k := by + simp only [integerGridCoefficient, rectangularGridCharacter_add, rectangularGridCharacter_fintype_sum] + rw [FiniteProbabilityWeights.complexMean_mul_left] + congr 1 + exact FiniteProbabilityWeights.complexMean_pi_product p + (fun b x => rectangularGridCharacter M k (Y b x)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def integerGridDensity {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (K M : ℕ) (z : J → ℤ) : ℝ := + (K : ℝ) ^ Fintype.card J * integerGridMass p Y M z + +theorem integerGridDensity_nonneg {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (K M : ℕ) (z : J → ℤ) : + 0 ≤ integerGridDensity p Y K M z := + mul_nonneg (by positivity) (integerGridMass_nonneg p Y M z) + +theorem integerGridDensity_fourier {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (K M : ℕ) [NeZero M] (z : J → ℤ) : + (integerGridDensity p Y K M z : ℂ) = + ((K : ℂ) / M) ^ Fintype.card J * + ∑ k : J → Fin M, integerGridCoefficient p Y M k * star (rectangularGridCharacter M k z) := by + have hM : (M : ℂ) ≠ 0 := by exact_mod_cast NeZero.ne M + rw [integerGridFourier_inversion, div_pow] + simp only [integerGridDensity, Complex.ofReal_mul, Complex.ofReal_pow, Complex.ofReal_natCast] + field_simp + +theorem integerGridDensity_truncation {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (K M : ℕ) [NeZero M] + (S : Finset (J → Fin M)) (z : J → ℤ) : + ‖(integerGridDensity p Y K M z : ℂ) - ((K : ℂ) / M) ^ Fintype.card J * + ∑ k ∈ S, integerGridCoefficient p Y M k * star (rectangularGridCharacter M k z)‖ ≤ + ((K : ℝ) / M) ^ Fintype.card J * spectrumTail S (fun k => ‖integerGridCoefficient p Y M k‖) := by + rw [integerGridDensity_fourier, ← mul_sub, norm_mul, norm_pow, norm_div, + Complex.norm_natCast, Complex.norm_natCast] + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact finite_series_truncation_le S _ _ + (fun k => by rw [norm_star, rectangularGridCharacter_norm]) + +theorem integerGridDensity_absolute_cap {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (K M : ℕ) [NeZero M] (z : J → ℤ) : + integerGridDensity p Y K M z ≤ ((K : ℝ) / M) ^ Fintype.card J * + ∑ k : J → Fin M, ‖integerGridCoefficient p Y M k‖ := by + have h := congrArg norm (integerGridDensity_fourier p Y K M z) + rw [Complex.norm_real, Real.norm_of_nonneg (integerGridDensity_nonneg p Y K M z), + norm_mul, norm_pow, norm_div, Complex.norm_natCast, Complex.norm_natCast] at h + rw [h] + exact mul_le_mul_of_nonneg_left + (finite_series_norm_le _ _ (fun k => by rw [norm_star, rectangularGridCharacter_norm])) (by positivity) + +theorem gridVolume_torus_factor {R K : ℕ} [NeZero R] [NeZero K] (j : ℕ) : + ((K : ℝ) / (R * K)) ^ j = ((R : ℝ) ^ j)⁻¹ := by + have hK : (K : ℝ) ≠ 0 := by exact_mod_cast NeZero.ne K + have he : (K : ℝ) / (R * K) = 1 / R := by field_simp + rw [he, one_div_pow, one_div] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem integerGridResidue_eq_iff_of_close {J : Type*} (M : ℕ) (y z : J → ℤ) + (hclose : ∀ j, |y j - z j| < (M : ℤ)) : + integerGridResidue M y = integerGridResidue M z ↔ y = z := by + constructor + · intro h + funext j + have hd : (M : ℤ) ∣ y j - z j := by + apply (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mp + rw [Int.cast_sub, show (y j : ZMod M) = (z j : ZMod M) from congrFun h j, sub_self] + have ha : (y j - z j).natAbs < (M : ℤ).natAbs := by + have hj := hclose j + rw [Int.abs_eq_natAbs] at hj + exact_mod_cast hj + exact sub_eq_zero.mp (Int.eq_zero_of_dvd_of_natAbs_lt_natAbs hd ha) + · rintro rfl + rfl + +theorem integerGridMass_eq_imageMass {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (M : ℕ) (z : J → ℤ) + (hclose : ∀ x, p.weight x ≠ 0 → ∀ j, |Y x j - z j| < (M : ℤ)) : + integerGridMass p Y M z = finiteImageMass p Y z := by + classical + unfold integerGridMass finiteImageMass FiniteProbabilityWeights.mean + apply Finset.sum_congr rfl + intro x _ + by_cases hx : p.weight x = 0 + · simp only [hx, zero_mul] + · simp only [integerGridResidue_eq_iff_of_close M (Y x) z (hclose x hx)] + +theorem integerGridMass_eq_imageMass_on_box {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (M : ℕ) (lower z : J → ℤ) + (hY : ∀ x, p.weight x ≠ 0 → ∀ j, lower j ≤ Y x j ∧ Y x j < lower j + M) + (hz : ∀ j, lower j ≤ z j ∧ z j < lower j + M) : + integerGridMass p Y M z = finiteImageMass p Y z := by + apply integerGridMass_eq_imageMass + intro x hx j + have hy := hY x hx j + have hz' := hz j + rw [abs_lt] + constructor <;> omega + +theorem integerGridDensity_eq_imageMass_on_box {X J : Type*} + [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (K M : ℕ) (lower z : J → ℤ) + (hY : ∀ x, p.weight x ≠ 0 → ∀ j, lower j ≤ Y x j ∧ Y x j < lower j + M) + (hz : ∀ j, lower j ≤ z j ∧ z j < lower j + M) : + integerGridDensity p Y K M z = (K : ℝ) ^ Fintype.card J * finiteImageMass p Y z := by + unfold integerGridDensity + rw [integerGridMass_eq_imageMass_on_box p Y M lower z hY hz] + +end Erdos3 + +end + +section + +namespace Erdos3 + +def intervalGridRepresentative (M : ℕ) (lower : ℤ) (r : ZMod M) : ℤ := + lower + ((r.val : ℤ) - lower) % M + +theorem intervalGridRepresentative_bounds {M : ℕ} (hM : 0 < M) (lower : ℤ) (r : ZMod M) : + lower ≤ intervalGridRepresentative M lower r ∧ intervalGridRepresentative M lower r < lower + M := by + have hM' : (0 : ℤ) < M := by exact_mod_cast hM + have hlo := Int.emod_nonneg ((r.val : ℤ) - lower) hM'.ne' + have hhi := Int.emod_lt_of_pos ((r.val : ℤ) - lower) hM' + unfold intervalGridRepresentative + omega + +theorem intervalGridRepresentative_residue (M : ℕ) [NeZero M] (lower : ℤ) (r : ZMod M) : + (intervalGridRepresentative M lower r : ZMod M) = r := by + simp only [intervalGridRepresentative, Int.cast_add, ZMod.intCast_mod, Int.cast_sub, + Int.cast_natCast, ZMod.natCast_zmod_val, add_sub_cancel] + +def rectangularGridRepresentative {J : Type*} (M : ℕ) (lower : J → ℤ) (r : J → ZMod M) : J → ℤ := + fun j => intervalGridRepresentative M (lower j) (r j) + +theorem rectangularGridRepresentative_bounds {J : Type*} {M : ℕ} (hM : 0 < M) + (lower : J → ℤ) (r : J → ZMod M) : + ∀ j, lower j ≤ rectangularGridRepresentative M lower r j ∧ + rectangularGridRepresentative M lower r j < lower j + M := + fun j => intervalGridRepresentative_bounds hM (lower j) (r j) + +theorem rectangularGridRepresentative_residue {J : Type*} (M : ℕ) [NeZero M] + (lower : J → ℤ) (r : J → ZMod M) : + integerGridResidue M (rectangularGridRepresentative M lower r) = r := by + funext j + exact intervalGridRepresentative_residue M (lower j) (r j) + +theorem rectangularGridRepresentative_eq {J : Type*} {M : ℕ} [NeZero M] + (lower z : J → ℤ) (hz : ∀ j, lower j ≤ z j ∧ z j < lower j + M) : + rectangularGridRepresentative M lower (integerGridResidue M z) = z := by + have hb := rectangularGridRepresentative_bounds (Nat.pos_of_ne_zero (NeZero.ne M)) lower + (integerGridResidue M z) + apply (integerGridResidue_eq_iff_of_close M _ z (fun j => ?_)).mp + (rectangularGridRepresentative_residue M lower _) + have h1 := hb j + have h2 := hz j + rw [abs_lt] + constructor <;> omega + +theorem integerGridMass_representative {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (M : ℕ) [NeZero M] + (lower : J → ℤ) (r : J → ZMod M) : + integerGridMass p Y M (rectangularGridRepresentative M lower r) = + finiteImageMass p (integerGridResidue M ∘ Y) r := by + simp only [integerGridMass, rectangularGridRepresentative_residue, Function.comp_def] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def integerBooleanBlockValue {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (t : Finset I) : ℤ := + ∏ g, ∑ r, (booleanFeature r t : ℤ) * x g r + +noncomputable def integerBooleanBlockJet {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (S : Finset I) : ℤ := + booleanCoefficient (integerBooleanBlockValue x) S + +theorem integerBooleanBlockValue_cast {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (t : Finset I) : + (integerBooleanBlockValue x t : ℝ) = booleanBlockValue (fun g r => (x g r : ℝ)) t := by + have hf (r : Option I) : ((booleanFeature r t : ℤ) : ℝ) = (booleanFeature r t : ℝ) := by + cases r with + | none => simp only [booleanFeature, Int.cast_one] + | some i => + by_cases hi : i ∈ t <;> simp only [booleanFeature, hi, ite_true, ite_false, Int.cast_one, Int.cast_zero] + simp only [integerBooleanBlockValue, booleanBlockValue, Int.cast_prod, Int.cast_sum, Int.cast_mul, hf] + +theorem integerBooleanBlockJet_cast {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (S : Finset I) : + (integerBooleanBlockJet x S : ℝ) = + booleanCoefficient (booleanBlockValue (fun g r => (x g r : ℝ))) S := by + have h := booleanCoefficient_map (Int.castRingHom ℝ) (integerBooleanBlockValue x) S + change (integerBooleanBlockJet x S : ℝ) = + booleanCoefficient (fun t => (integerBooleanBlockValue x t : ℝ)) S at h + simpa only [integerBooleanBlockValue_cast] using h + +theorem gridJetFrequency_pairing {I : Type*} [Fintype I] [DecidableEq I] + (M : ℕ) (J : Finset (Finset I)) (k : J → Fin M) (v : Finset I → ℝ) : + (∑ S, gridJetFrequency M J k S * v S) = ∑ S : J, (((k S).val : ℝ) / M) * v S := by + classical + calc + _ = ∑ S ∈ J, gridJetFrequency M J k S * v S := by + symm + apply Finset.sum_subset (Finset.subset_univ J) + intro S _ hS + simp only [gridJetFrequency, dite_eq_right hS, zero_mul] + _ = ∑ S : J, gridJetFrequency M J k S * v S := (Finset.sum_coe_sort J _).symm + _ = _ := Finset.sum_congr rfl (fun S _ => by rw [gridJetFrequency_apply]) + +theorem integerBooleanBlockJet_pairing {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (M : ℕ) (J : Finset (Finset I)) (k : J → Fin M) : + (∑ S : J, (((k S).val : ℝ) / M) * (integerBooleanBlockJet x S : ℝ)) = + booleanBlockPhase (gridJetFrequency M J k) (fun g r => (x g r : ℝ)) := by + simp only [integerBooleanBlockJet_cast, booleanBlockPhase, gridJetFrequency_pairing] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem integerBooleanBlockValue_bound {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (L : G → ℕ) (hx : ∀ g r, |x g r| ≤ (L g : ℤ)) (t : Finset I) : + |integerBooleanBlockValue x t| ≤ ∏ g, ((Fintype.card I + 1 : ℕ) : ℤ) * L g := by + classical + unfold integerBooleanBlockValue + rw [Finset.abs_prod] + apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro g _ + calc + _ ≤ ∑ r : Option I, |(booleanFeature r t : ℤ) * x g r| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _r : Option I, (L g : ℤ) := by + apply Finset.sum_le_sum + intro r _ + cases r with + | none => simpa only [booleanFeature, one_mul] using hx g none + | some i => + by_cases hi : i ∈ t + · simpa only [booleanFeature, hi, ite_true, one_mul] using hx g (some i) + · simp only [booleanFeature, hi, ite_false, zero_mul, abs_zero] + exact Nat.cast_nonneg _ + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_option, nsmul_eq_mul] + +theorem integerBooleanBlockJet_bound {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (L : G → ℕ) (hx : ∀ g r, |x g r| ≤ (L g : ℤ)) (S : Finset I) : + |integerBooleanBlockJet x S| ≤ (2 : ℤ) ^ S.card * + ∏ g, ((Fintype.card I + 1 : ℕ) : ℤ) * L g := by + classical + unfold integerBooleanBlockJet booleanCoefficient + calc + _ ≤ ∑ t ∈ S.powerset, |(-1 : ℤ) ^ (S \ t).card * integerBooleanBlockValue x t| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _t ∈ S.powerset, ∏ g, ((Fintype.card I + 1 : ℕ) : ℤ) * L g := by + apply Finset.sum_le_sum + intro t _ + simpa only [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] using + integerBooleanBlockValue_bound x L hx t + _ = _ := by + simp only [Finset.sum_const, Finset.card_powerset, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] + +theorem integerScalarCubeBox_coordinate_abs {I : Type*} {L : ℕ} + (x : IntegerScalarCubeBox I L) (r : Option I) : |(x r : ℤ)| ≤ L := by + have h := Finset.mem_Ico.mp (x r).property + rw [abs_le] + constructor <;> omega + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def weightedCubeIntegerSource {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) : + FiniteProbabilityWeights (∀ b j, IntegerScalarCubeBox I (s b j).length) := + FiniteProbabilityWeights.pi (fun b => FiniteProbabilityWeights.pi (fun j => (s b j).source)) + +noncomputable def weightedCubeIntegerJetSum {B : Type*} [Fintype B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) (J : Finset (Finset I)) (shift : J → ℤ) + (x : ∀ b j, IntegerScalarCubeBox I (s b j).length) : J → ℤ := + shift + ∑ b, fun S : J => integerBooleanBlockJet (fun j r => (x b j r : ℤ)) S + +theorem weightedCubeGridCoefficient_eq_image {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (s : Fin (n + 1) → NormalizedScalarCubeSource I) + (M : ℕ) [NeZero M] (J : Finset (Finset I)) (k : J → Fin M) : + integerGridCoefficient (FiniteProbabilityWeights.pi (fun j => (s j).source)) + (fun x (S : J) => integerBooleanBlockJet (fun j r => (x j r : ℤ)) S) M k = + weightedCubeGridCoefficient s M J k := by + unfold integerGridCoefficient weightedCubeGridCoefficient + congr 1 + funext x + rw [rectangularGridCharacter_eq, integerBooleanBlockJet_pairing] + +theorem weightedCubeIntegerJetSum_coefficient {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (M : ℕ) [NeZero M] (J : Finset (Finset I)) (shift : J → ℤ) (k : J → Fin M) : + integerGridCoefficient (weightedCubeIntegerSource s) (weightedCubeIntegerJetSum s J shift) M k = + rectangularGridCharacter M k shift * ∏ b, weightedCubeGridCoefficient (s b) M J k := by + have h := independent_integerGridCoefficient + (fun b => FiniteProbabilityWeights.pi (fun j => (s b j).source)) + (fun b x (S : J) => integerBooleanBlockJet (fun j r => (x j r : ℤ)) S) shift M k + unfold weightedCubeIntegerSource weightedCubeIntegerJetSum + simpa only [weightedCubeGridCoefficient_eq_image] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical +open CircleFourier + +noncomputable def weightedModerateIntegerSource {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I) : + FiniteProbabilityWeights (IntegerScalarCubeBox Empty c.length × + (∀ j, IntegerScalarCubeBox I (s j).length)) := + c.source.prod (FiniteProbabilityWeights.pi (fun j => (s j).source)) + +noncomputable def weightedModerateIntegerBlock {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I) + (J : Finset (Finset I)) (offset : ℤ) + (x : IntegerScalarCubeBox Empty c.length × (∀ j, IntegerScalarCubeBox I (s j).length)) : J → ℤ := + fun S => (offset + (x.1 none : ℤ)) * integerBooleanBlockJet (fun j r => (x.2 j r : ℤ)) S + +theorem integerBooleanBlockJet_scaled_pairing {G I : Type*} [Fintype G] [Fintype I] [DecidableEq I] + (x : G → Option I → ℤ) (M : ℕ) (J : Finset (Finset I)) (k : J → Fin M) (c : ℤ) : + (∑ S : J, (((k S).val : ℝ) / M) * ((c * integerBooleanBlockJet x S : ℤ) : ℝ)) = + (c : ℝ) * booleanBlockPhase (gridJetFrequency M J k) (fun j r => (x j r : ℝ)) := by + rw [← integerBooleanBlockJet_pairing x M J k, Finset.mul_sum] + apply Finset.sum_congr rfl + intro S _ + rw [Int.cast_mul] + ring + +theorem weightedModerateGridCoefficient_eq_image {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I) + (M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : ℤ) (k : J → Fin M) : + integerGridCoefficient (weightedModerateIntegerSource c s) (weightedModerateIntegerBlock c s J offset) M k = + weightedModerateGridCoefficient c s (offset : ℝ) M J k := by + unfold integerGridCoefficient weightedModerateIntegerSource + rw [FiniteProbabilityWeights.complexMean_prod] + change c.source.complexMean _ = c.source.complexMean _ + congr 1 + funext z + congr 1 + funext x + rw [rectangularGridCharacter_eq] + simp only [weightedModerateIntegerBlock, integerBooleanBlockJet_scaled_pairing, Int.cast_add] + +noncomputable def weightedModerateIntegerProductSource {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) : + FiniteProbabilityWeights (∀ b, IntegerScalarCubeBox Empty (c b).length × + (∀ j, IntegerScalarCubeBox I (s b j).length)) := + FiniteProbabilityWeights.pi (fun b => weightedModerateIntegerSource (c b) (s b)) + +noncomputable def weightedModerateIntegerJetSum {B : Type*} [Fintype B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) + (x : ∀ b, IntegerScalarCubeBox Empty (c b).length × (∀ j, IntegerScalarCubeBox I (s b j).length)) : J → ℤ := + shift + ∑ b, weightedModerateIntegerBlock (c b) (s b) J (offset b) (x b) + +theorem weightedModerateIntegerJetSum_coefficient {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (M : ℕ) [NeZero M] (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) (k : J → Fin M) : + integerGridCoefficient (weightedModerateIntegerProductSource c s) + (weightedModerateIntegerJetSum c s J offset shift) M k = + rectangularGridCharacter M k shift * ∏ b, weightedModerateGridCoefficient (c b) (s b) (offset b : ℝ) M J k := by + have h := independent_integerGridCoefficient (fun b => weightedModerateIntegerSource (c b) (s b)) + (fun b => weightedModerateIntegerBlock (c b) (s b) J (offset b)) shift M k + unfold weightedModerateIntegerProductSource weightedModerateIntegerJetSum + simpa only [weightedModerateGridCoefficient_eq_image] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def weightedCubeJetBound {B : Type*} [Fintype B] {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) (S : Finset I) : ℤ := + ∑ b, (2 : ℤ) ^ S.card * ∏ j, ((Fintype.card I + 1 : ℕ) : ℤ) * (s b j).length + +theorem weightedCubeIntegerJetSum_bound {B : Type*} [Fintype B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) (J : Finset (Finset I)) (shift : J → ℤ) + (x : ∀ b j, IntegerScalarCubeBox I (s b j).length) (S : J) : + |weightedCubeIntegerJetSum s J shift x S - shift S| ≤ weightedCubeJetBound s S := by + classical + simp only [weightedCubeIntegerJetSum, Pi.add_apply, Finset.sum_apply, add_sub_cancel_left] + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro b _ + exact integerBooleanBlockJet_bound _ (fun j => (s b j).length) + (fun j r => integerScalarCubeBox_coordinate_abs (x b j) r) S + +theorem weightedCubeIntegerGridMass_eq {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) (J : Finset (Finset I)) (shift z : J → ℤ) + (M : ℕ) (hM : ∀ S : J, 2 * weightedCubeJetBound s S < (M : ℤ)) + (hz : ∀ S : J, |z S - shift S| ≤ weightedCubeJetBound s S) : + integerGridMass (weightedCubeIntegerSource s) (weightedCubeIntegerJetSum s J shift) M z = + finiteImageMass (weightedCubeIntegerSource s) (weightedCubeIntegerJetSum s J shift) z := by + apply integerGridMass_eq_imageMass + intro x _ S + have hy := abs_le.mp (weightedCubeIntegerJetSum_bound s J shift x S) + have hz' := abs_le.mp (hz S) + have hM' := hM S + rw [abs_lt] + constructor <;> omega + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedIntegerGridDensityTail.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedIntegerGridDensityTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..8663feb8bb7f931ffa0345fde2d5ca49db254234 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedIntegerGridDensityTail.lean @@ -0,0 +1,38 @@ +import OAI.Combinatorics.Progressions.Fourier.PrincipalCoefficientResidueSpectrum + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem weighted_integerGridDensity_error_of_tail + {X O : Type*} [Fintype X] [Fintype O] [DecidableEq O] + (p : FiniteProbabilityWeights X) (Y : X → O → ℤ) (a : X → ℂ) + (K M : ℕ) [NeZero M] (cover : Finset (O → Fin M)) + {ε : ℝ} (htail : spectrumTail cover (fun k => + ‖p.complexMean (fun x => a x * rectangularGridCharacter M k (Y x))‖) ≤ ε) + (z : O → ℤ) : + ‖(K : ℂ) ^ Fintype.card O * p.complexMean + (fun x => if integerGridResidue M (Y x) = integerGridResidue M z then a x else 0) - + ((K : ℂ) / M) ^ Fintype.card O * ∑ k ∈ cover, + p.complexMean (fun x => a x * rectangularGridCharacter M k (Y x)) * + star (rectangularGridCharacter M k z)‖ ≤ + ((K : ℝ) / M) ^ Fintype.card O * ε := by + let ψ k := star (rectangularGridCharacter M k z) + have hψ k : ‖ψ k‖ ≤ 1 := by + simp only [ψ, norm_star, rectangularGridCharacter_norm, le_refl] + have hb := (finite_series_truncation_le cover + (fun k => p.complexMean (fun x => a x * rectangularGridCharacter M k (Y x))) + ψ hψ).trans htail + rw [weighted_integerGridDensity_fourier] + rw [← mul_sub, norm_mul, norm_pow, norm_div, Complex.norm_natCast, Complex.norm_natCast] + exact mul_le_mul_of_nonneg_left hb (by positivity) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedIntegerGridInversion.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedIntegerGridInversion.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d0e04de45251b4429bb24f3fee9b45cfbbbbec9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedIntegerGridInversion.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.Progressions.Fourier.FourierLawTransport + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def weightedIntegerGridCoefficient {X J : Type*} [Fintype X] [Fintype J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (w : X → ℂ) + (M : ℕ) [NeZero M] (k : J → Fin M) : ℂ := + p.complexMean (fun x => w x*rectangularGridCharacter M k (Y x)) + +theorem weightedIntegerGrid_inversion {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (w : X → ℂ) + (M : ℕ) [NeZero M] (z : J → ℤ) : + (∑ k : J → Fin M, weightedIntegerGridCoefficient p Y w M k * star (rectangularGridCharacter M k z)) = + (M : ℂ)^Fintype.card J * p.complexMean + (fun x => if integerGridResidue M (Y x) = integerGridResidue M z then w x else 0) := by + classical + calc + _ = ∑ x, (p.weight x : ℂ)*w x* + (∑ k : J → Fin M, rectangularGridCharacter M k (Y x)*star (rectangularGridCharacter M k z)) := by + simp only [weightedIntegerGridCoefficient, FiniteProbabilityWeights.complexMean, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro k _ + ring + _ = _ := by + simp only [rectangularGridCharacter_orthogonality, FiniteProbabilityWeights.complexMean, Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + by_cases hx : integerGridResidue M (Y x) = integerGridResidue M z + · simp only [hx, ite_true] + ring + · simp only [hx, ite_false, mul_zero] + +theorem weightedIntegerGrid_image_inversion {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (w : X → ℂ) + (M : ℕ) [NeZero M] (z : J → ℤ) + (hclose : ∀ x, p.weight x ≠ 0 → ∀ j, |Y x j-z j| < (M : ℤ)) : + (∑ k : J → Fin M, weightedIntegerGridCoefficient p Y w M k * star (rectangularGridCharacter M k z)) = + (M : ℂ)^Fintype.card J * p.complexMean (fun x => if Y x = z then w x else 0) := by + classical + rw [weightedIntegerGrid_inversion] + congr 1 + unfold FiniteProbabilityWeights.complexMean + apply Finset.sum_congr rfl + intro x _ + by_cases hx : p.weight x = 0 + · simp only [hx, Complex.ofReal_zero, zero_mul] + · simp only [integerGridResidue_eq_iff_of_close M (Y x) z (hclose x hx)] + +theorem weightedIntegerGrid_image_on_centered_box {X J : Type*} + [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (w : X → ℂ) + (M : ℕ) [NeZero M] (center z : J → ℤ) {Q K : ℕ} + (hM : M = (2*Q+1)*K) (hK : 0 < K) + (hY : ∀ x, p.weight x ≠ 0 → ∀ j, |(Y x j : ℝ)-center j| ≤ (Q : ℝ)*K) + (hz : centeredFundamentalBox Q K center z) : + (∑ k : J → Fin M, weightedIntegerGridCoefficient p Y w M k * star (rectangularGridCharacter M k z)) = + (M : ℂ)^Fintype.card J * p.complexMean (fun x => if Y x = z then w x else 0) := by + apply weightedIntegerGrid_image_inversion + intro x hx j + have hy := (centeredFundamentalBox_iff Q K center (Y x)).mp + (centeredFundamentalBox_of_support center (Y x) hK le_rfl (hY x hx)) j + have hz' := (centeredFundamentalBox_iff Q K center z).mp hz j + rw [hM, abs_lt] + constructor <;> omega + +theorem weightedIntegerGridCoefficient_norm_le_one {X J : Type*} [Fintype X] [Fintype J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (w : X → ℂ) + (hw : ∀ x, ‖w x‖ ≤ 1) (M : ℕ) [NeZero M] (k : J → Fin M) : + ‖weightedIntegerGridCoefficient p Y w M k‖ ≤ 1 := by + apply (p.norm_complexMean_le_mean_norm _).trans + calc + _ = p.mean (fun x => ‖w x‖) := by + simp only [norm_mul, rectangularGridCharacter_norm, mul_one] + _ ≤ p.mean (fun _ => 1) := p.mean_mono hw + _ = 1 := p.mean_const 1 + +theorem weightedIntegerGridCoefficient_mass {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (w : X → ℂ) + (hw : ∀ x, ‖w x‖ ≤ 1) (M : ℕ) [NeZero M] : + (∑ k : J → Fin M, ‖weightedIntegerGridCoefficient p Y w M k‖) ≤ (M : ℝ)^Fintype.card J := by + calc + _ ≤ ∑ _k : J → Fin M, (1 : ℝ) := Finset.sum_le_sum (fun k _ => + weightedIntegerGridCoefficient_norm_le_one p Y w hw M k) + _ = _ := by simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedModerateIntegerApproximation.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedModerateIntegerApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccdffa3206797877241f1e761db4d3bc4b9ca965 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedModerateIntegerApproximation.lean @@ -0,0 +1,190 @@ +import OAI.Combinatorics.Progressions.Estimates.WeightedCubePlateau +import OAI.Combinatorics.Progressions.Estimates.WeightedRetainedCoefficients + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +theorem weightedCube_integer_density_approximation {B I : Type*} + [Fintype B] [Nonempty B] [DecidableEq B] [Fintype I] [DecidableEq I] + {n K : ℕ} [NeZero K] (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V D E ε : ℝ} + (hU : 1 ≤ U) (hV : 0 ≤ V) (hD : 0 ≤ D) (hE : 0 ≤ E) (hε : 0 < ε) (hε1 : ε ≤ 1) + (h : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) + (hupper : ∀ b, (∏ j, ((s b j).length : ℝ)) ≤ V * K) + (hlower : ∀ b, (K : ℝ) ≤ D * ∏ j, ((s b j).length : ℝ)) + (p : ℕ) (hpower : ∀ b j, (K : ℝ) ≤ E * ((s b j).length : ℝ) ^ p) + (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n + 1) + (hB : uniformSpectrumBlockCount n J.card (p * J.card) ≤ Fintype.card B) : + let R := blockTorusFactor (Fintype.card I) (n + 1) (Fintype.card B) V + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + ∃ S : Finset (J → Fin (R * K)), + (S.card : ℝ) ≤ uniformSpectrumSizeConstant n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) / + ε ^ max (majorArcSpectrumExponent n J.card) (majorArcLengthExponent n * (p * J.card)) ∧ + (∑ k, ‖∏ b, weightedCubeGridCoefficient (s b) (R * K) J k‖) ≤ + uniformSpectrumAbsoluteCap n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ∧ + (∀ k ∈ S, ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ uniformCharacterDenominatorBound n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ζ ∧ + ∃ (a : J → ℤ) (ξ : J → ℝ), + (∀ T, |ξ T| ≤ 2 * majorArcCoverConstant n J.card U ((R : ℝ) * D) / ζ ^ majorArcCoverExponent n J.card) ∧ + ∀ T, ((k T).val : ℝ) / (R * K) = (a T : ℝ) / d + ξ T / K) ∧ + ∀ shift z : J → ℤ, + (∀ T, |(z T : ℝ) - shift T| ≤ blockJetScaleBound (Fintype.card I) (n + 1) (Fintype.card B) V * K) → + ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedCubeIntegerSource s) + (weightedCubeIntegerJetSum s J shift) z : ℝ) : ℂ) - + weightedCubeGridApproximation s K (R * K) J shift z S‖ ≤ ε := by + let R := blockTorusFactor (Fintype.card I) (n + 1) (Fintype.card B) V + have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K) + have hR : 0 < R := blockTorusFactor_pos _ _ _ _ + obtain ⟨m, hm, hmin, hsize⟩ := exists_scaled_grid_minimum + (fun x : B × Fin (n + 1) => (s x.1 x.2).length) + (fun x => (s x.1 x.2).length_pos) (R := R) p J.card (fun x => hpower x.1 x.2) + have hVD : 0 ≤ (R : ℝ) * D := by positivity + have hWE : 0 ≤ ((R : ℝ) * E) ^ J.card := by positivity + have hscale (b : B) : ((R * K : ℕ) : ℝ) / ∏ j, ((s b j).length : ℝ) ≤ (R : ℝ) * D := by + have hp : 0 < ∏ j, ((s b j).length : ℝ) := + Finset.prod_pos (fun j _ => by exact_mod_cast (s b j).length_pos) + simpa only [Nat.cast_mul] using scaled_grid_volume_bound (Nat.cast_nonneg R) hp (hlower b) + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + let S := uniformBlockSpectrumCover J (R * K) n U ((R : ℝ) * D) (m : ℝ) ζ + refine ⟨S, ?_, ?_, ?_, ?_⟩ + · simpa only [S, ζ, Fintype.card_coe] using uniformBlockSpectrumCover_polynomial_card + J (R * K) n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hε hε1 + (by simpa only [Fintype.card_coe] using hsize) + · exact weightedCube_uniform_absolute_cap s A hA hU hVD hWE (Nat.cast_nonneg m) h + (fun b j => by exact_mod_cast hmin (b, j)) (R * K) (p * J.card) (Nat.mul_pos hR hK) J hJ hB hsize hscale + · intro k hk + obtain ⟨hζ, hζ1, _⟩ := uniformBlockRetainedBias_spec n J.card (p * J.card) hU hWE hε + obtain ⟨d, hd, hdb, a, ξ, hξ, he⟩ := uniformBlockSpectrumCover_character (Nat.mul_pos hR hK) + n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hζ hζ1 + (by simpa only [Fintype.card_coe] using hsize) k hk + obtain ⟨ρ, hρ, hρe⟩ := grid_character_rescale hR k a ξ hξ (by simpa only [Nat.cast_mul] using he) + refine ⟨d, hd, ?_, a, ρ, ?_, hρe⟩ + · simpa only [Fintype.card_coe] using hdb + · simpa only [Fintype.card_coe] using hρ + · have hd := (weightedCube_uniform_grid_density s A hA hU hVD hWE (Nat.cast_nonneg m) hε h + (fun b j => by exact_mod_cast hmin (b, j)) K (R * K) (p * J.card) J hJ hB hsize hscale).2 + intro shift z hz + have he : integerGridDensity (weightedCubeIntegerSource s) (weightedCubeIntegerJetSum s J shift) + K (R * K) z = (K : ℝ) ^ J.card * finiteImageMass (weightedCubeIntegerSource s) + (weightedCubeIntegerJetSum s J shift) z := by + unfold integerGridDensity + rw [weightedCube_grid_mass_eq_torus s hV hK hupper J hJ shift z hz, Fintype.card_coe] + have ht := hd shift z + rw [he] at ht + apply ht.trans + have hf := grid_scale_factor_le_one R K J.card hR hK + have hh := mul_le_mul_of_nonneg_right hf hε.le + simpa only [Nat.cast_mul, one_mul] using hh + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +theorem weightedModerate_integer_density_approximation {B I : Type*} + [Fintype B] [Nonempty B] [DecidableEq B] [Fintype I] [DecidableEq I] + {n K : ℕ} [NeZero K] (c : B → NormalizedScalarCubeSource Empty) + (s : B → Fin n → NormalizedScalarCubeSource I) (offset : B → ℤ) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V D E ε : ℝ} + (hU : 1 ≤ U) (hV : 0 ≤ V) (hD : 0 ≤ D) (hE : 0 ≤ E) (hε : 0 < ε) (hε1 : ε ≤ 1) + (hc : ∀ b, ScalarCubePrimitiveBudget (c b) A U) + (h : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) + (hupper : ∀ b, (|(offset b : ℝ)| + (c b).length) * (∏ j, ((s b j).length : ℝ)) ≤ V * K) + (hlower : ∀ b, (K : ℝ) ≤ D * ((c b).length * ∏ j, ((s b j).length : ℝ))) + (p : ℕ) (hpower : ∀ b j, (K : ℝ) ≤ E * ((s b j).length : ℝ) ^ p) + (hcpower : ∀ b, (K : ℝ) ≤ E * ((c b).length : ℝ) ^ p) + (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n) + (hB : uniformSpectrumBlockCount n J.card (p * J.card) ≤ Fintype.card B) : + let R := blockTorusFactor (Fintype.card I) n (Fintype.card B) V + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + ∃ S : Finset (J → Fin (R * K)), + (S.card : ℝ) ≤ uniformSpectrumSizeConstant n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) / + ε ^ max (majorArcSpectrumExponent n J.card) (majorArcLengthExponent n * (p * J.card)) ∧ + (∑ k, ‖∏ b, weightedModerateGridCoefficient (c b) (s b) (offset b : ℝ) (R * K) J k‖) ≤ + uniformSpectrumAbsoluteCap n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ∧ + (∀ k ∈ S, ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ uniformCharacterDenominatorBound n J.card (p * J.card) + U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ζ ∧ + ∃ (a : J → ℤ) (ξ : J → ℝ), + (∀ T, |ξ T| ≤ 2 * majorArcCoverConstant n J.card U ((R : ℝ) * D) / ζ ^ majorArcCoverExponent n J.card) ∧ + ∀ T, ((k T).val : ℝ) / (R * K) = (a T : ℝ) / d + ξ T / K) ∧ + ∀ shift z : J → ℤ, + (∀ T, |(z T : ℝ) - shift T| ≤ blockJetScaleBound (Fintype.card I) n (Fintype.card B) V * K) → + ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedModerateIntegerProductSource c s) + (weightedModerateIntegerJetSum c s J offset shift) z : ℝ) : ℂ) - + weightedModerateGridApproximation c s K (R * K) J offset shift z S‖ ≤ ε := by + let R := blockTorusFactor (Fintype.card I) n (Fintype.card B) V + have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K) + have hR : 0 < R := blockTorusFactor_pos _ _ _ _ + let length (x : B × Option (Fin n)) : ℕ := x.2.elim (c x.1).length (fun j => (s x.1 j).length) + have hpos (x : B × Option (Fin n)) : 0 < length x := by + rcases x with ⟨b, _ | j⟩ + · exact (c b).length_pos + · exact (s b j).length_pos + have hpow (x : B × Option (Fin n)) : (K : ℝ) ≤ E * (length x : ℝ) ^ p := by + rcases x with ⟨b, _ | j⟩ + · exact hcpower b + · exact hpower b j + obtain ⟨m, hm, hmin, hsize⟩ := exists_scaled_grid_minimum length hpos (R := R) p J.card hpow + have hVD : 0 ≤ (R : ℝ) * D := by positivity + have hWE : 0 ≤ ((R : ℝ) * E) ^ J.card := by positivity + have hscale (b : B) : ((R * K : ℕ) : ℝ) / + ((((c b).modulus none : ℝ) * (c b).length) * ∏ j, ((s b j).length : ℝ)) ≤ (R : ℝ) * D := by + have hp : 0 < (((c b).modulus none : ℝ) * (c b).length) * ∏ j, ((s b j).length : ℝ) := by + apply mul_pos + · exact mul_pos (by exact_mod_cast (c b).modulus_pos none) (by exact_mod_cast (c b).length_pos) + · exact Finset.prod_pos (fun j _ => by exact_mod_cast (s b j).length_pos) + simpa only [Nat.cast_mul] using scaled_grid_volume_bound (Nat.cast_nonneg R) hp + (weightedModerate_physical_volume_lower (c b) (s b) hD (hlower b)) + let ζ := uniformBlockRetainedBias n J.card (p * J.card) U ((R : ℝ) * D) (((R : ℝ) * E) ^ J.card) ε + let S := uniformBlockSpectrumCover J (R * K) n U ((R : ℝ) * D) (m : ℝ) ζ + refine ⟨S, ?_, ?_, ?_, ?_⟩ + · simpa only [S, ζ, Fintype.card_coe] using uniformBlockSpectrumCover_polynomial_card + J (R * K) n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hε hε1 + (by simpa only [Fintype.card_coe] using hsize) + · exact weightedModerate_uniform_absolute_cap c s (fun b => (offset b : ℝ)) A hA hU hVD hWE + (Nat.cast_nonneg m) hc h (fun b => by exact_mod_cast hmin (b, none)) + (fun b j => by exact_mod_cast hmin (b, some j)) (R * K) (p * J.card) (Nat.mul_pos hR hK) + J hJ hB hsize hscale + · intro k hk + obtain ⟨hζ, hζ1, _⟩ := uniformBlockRetainedBias_spec n J.card (p * J.card) hU hWE hε + obtain ⟨d, hd, hdb, a, ξ, hξ, he⟩ := uniformBlockSpectrumCover_character (Nat.mul_pos hR hK) + n (p * J.card) hU hVD hWE (Nat.cast_nonneg m) hζ hζ1 + (by simpa only [Fintype.card_coe] using hsize) k hk + obtain ⟨ρ, hρ, hρe⟩ := grid_character_rescale hR k a ξ hξ (by simpa only [Nat.cast_mul] using he) + refine ⟨d, hd, ?_, a, ρ, ?_, hρe⟩ + · simpa only [Fintype.card_coe] using hdb + · simpa only [Fintype.card_coe] using hρ + · have hd := (weightedModerate_uniform_grid_density c s offset A hA hU hVD hWE (Nat.cast_nonneg m) + hε hc h (fun b => by exact_mod_cast hmin (b, none)) + (fun b j => by exact_mod_cast hmin (b, some j)) K (R * K) (p * J.card) J hJ hB hsize hscale).2 + intro shift z hz + have he : integerGridDensity (weightedModerateIntegerProductSource c s) + (weightedModerateIntegerJetSum c s J offset shift) K (R * K) z = + (K : ℝ) ^ J.card * finiteImageMass (weightedModerateIntegerProductSource c s) + (weightedModerateIntegerJetSum c s J offset shift) z := by + unfold integerGridDensity + rw [weightedModerate_grid_mass_eq_torus c s offset hV hK hupper J hJ shift z hz, Fintype.card_coe] + have ht := hd shift z + rw [he] at ht + apply ht.trans + have hf := grid_scale_factor_le_one R K J.card hR hK + have hh := mul_le_mul_of_nonneg_right hf hε.le + simpa only [Nat.cast_mul, one_mul] using hh + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedModerateIntegerSupport.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedModerateIntegerSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..4226c584cb557759acebf5ddbc31f792ccb3b1e7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedModerateIntegerSupport.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Lattices.WeightedCubeIntegerSupport + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def weightedModerateJetBound {B : Type*} [Fintype B] {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (offset : B → ℤ) (S : Finset I) : ℤ := + ∑ b, (|offset b| + (c b).length) * + ((2 : ℤ) ^ S.card * ∏ j, ((Fintype.card I + 1 : ℕ) : ℤ) * (s b j).length) + +theorem weightedModerateIntegerBlock_bound {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : NormalizedScalarCubeSource Empty) (s : Fin n → NormalizedScalarCubeSource I) + (J : Finset (Finset I)) (offset : ℤ) + (x : IntegerScalarCubeBox Empty c.length × (∀ j, IntegerScalarCubeBox I (s j).length)) (S : J) : + |weightedModerateIntegerBlock c s J offset x S| ≤ (|offset| + c.length) * + ((2 : ℤ) ^ S.val.card * ∏ j, ((Fintype.card I + 1 : ℕ) : ℤ) * (s j).length) := by + have hc : |offset + (x.1 none : ℤ)| ≤ |offset| + c.length := + (abs_add_le _ _).trans (add_le_add le_rfl (integerScalarCubeBox_coordinate_abs x.1 none)) + have hj := integerBooleanBlockJet_bound (fun j r => (x.2 j r : ℤ)) (fun j => (s j).length) + (fun j r => integerScalarCubeBox_coordinate_abs (x.2 j) r) S.val + unfold weightedModerateIntegerBlock + rw [abs_mul] + exact mul_le_mul hc hj (abs_nonneg _) (by positivity) + +theorem weightedModerateIntegerJetSum_bound {B : Type*} [Fintype B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (J : Finset (Finset I)) (offset : B → ℤ) (shift : J → ℤ) + (x : ∀ b, IntegerScalarCubeBox Empty (c b).length × (∀ j, IntegerScalarCubeBox I (s b j).length)) + (S : J) : |weightedModerateIntegerJetSum c s J offset shift x S - shift S| ≤ + weightedModerateJetBound c s offset S := by + classical + simp only [weightedModerateIntegerJetSum, Pi.add_apply, Finset.sum_apply, add_sub_cancel_left] + apply (Finset.abs_sum_le_sum_abs _ _).trans + exact Finset.sum_le_sum (fun b _ => weightedModerateIntegerBlock_bound (c b) (s b) J (offset b) (x b) S) + +theorem weightedModerateIntegerGridMass_eq {B : Type*} [Fintype B] [DecidableEq B] + {n : ℕ} {I : Type*} [Fintype I] [DecidableEq I] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (J : Finset (Finset I)) (offset : B → ℤ) (shift z : J → ℤ) (M : ℕ) + (hM : ∀ S : J, 2 * weightedModerateJetBound c s offset S < (M : ℤ)) + (hz : ∀ S : J, |z S - shift S| ≤ weightedModerateJetBound c s offset S) : + integerGridMass (weightedModerateIntegerProductSource c s) + (weightedModerateIntegerJetSum c s J offset shift) M z = + finiteImageMass (weightedModerateIntegerProductSource c s) + (weightedModerateIntegerJetSum c s J offset shift) z := by + apply integerGridMass_eq_imageMass + intro x _ S + have hy := abs_le.mp (weightedModerateIntegerJetSum_bound c s J offset shift x S) + have hz' := abs_le.mp (hz S) + have hM' := hM S + rw [abs_lt] + constructor <;> omega + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedScalarResidueCell.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedScalarResidueCell.lean new file mode 100644 index 0000000000000000000000000000000000000000..1232946450c0e86056cd0721aab5dac5abe2b5c2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedScalarResidueCell.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.Progressions.Lattices.ScalarResidueInteriorCell + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +noncomputable def residueCellPosition {I : Type*} (L N K : ℕ) + (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (k : Option I → Fin K) (t : Option I → Fin N) : Option I → ℝ := + fun i => progressionCellCorner (fun _ => N) (paddedResidueOffset L m res) + (paddedResidueStep L m) k i + paddedResidueStep L m i * (t i).val + +theorem scalarCubeResidue_supported_weight_cell (I : Type*) [Fintype I] [DecidableEq I] + (L M N K : ℕ) (hL : 0 < L) (hN : 0 < N) (hK : 0 < K) + (hcover : 2 * L ≤ K * N) (hupper : K * N ≤ 4 * L) + (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) + (w : (Option I → ℝ) → ℝ) {Q : ℝ≥0} (hLip : LipschitzWith Q w) + {δ η ζ B : ℝ} (hδ : 0 ≤ δ) (hη : 0 < η) (hB : 0 < B) + (hmesh : ∀ i, |paddedResidueStep L m i| * N ≤ δ) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) + (hsupport : Function.support w ⊆ halfOpenScalarCubeDomain I) + (hsafe : ∀ x, 0 < w x → ∀ y, dist y x ≤ δ → y ∈ scalarCubeDomain I) + (herror : paddedResidueDensityCap I M * (Q * δ + B * η) ≤ ζ) + (F : (Option I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) + (hbias : ζ ≤ ‖(scalarCubeResidueWeights I L M hL m res hm hmM hsize).complexMean + (fun z => (w (fun i => (z i : ℝ) / L) : ℂ) * F (fun i => (z i : ℝ) / L))‖) : + ∃ k : Option I → Fin K, + (∀ t : Option I → Fin N, residueCellPosition L N K m res k t ∈ scalarCubeDomain I) ∧ + η ≤ ‖𝔼 t : Option I → Fin N, F (residueCellPosition L N K m res k t)‖ := by + have hcap : 0 < paddedResidueDensityCap I M := by + exact mul_pos (by positivity) + (scalarCubeResidueDensityCap_pos I M ((hm none).trans_le (hmM none))) + have hpad := scalarCubeResidueWeights_padded_bias I L M (K * N) hL hcover hupper + m res hm hmM hsize w hsupport F hbias + have hthreshold : Q * δ + B * η ≤ ζ / paddedResidueDensityCap I M := by + apply (le_div_iff₀ hcap).mpr + nlinarith + have hpad' := hthreshold.trans hpad + obtain ⟨k, hinside, hphase⟩ := exists_interior_progression_cell + (fun _ : Option I => K) (fun _ => N) (fun _ => hK) (fun _ => hN) + (paddedResidueOffset L m res) (paddedResidueStep L m) w (scalarCubeDomain I) + hLip hδ hB (show (Q : ℝ) * δ < Q * δ + B * η by nlinarith) + hmesh hw hsafe + (fun x => F (fun i => paddedResidueOffset L m res i + paddedResidueStep L m i * (x i).val)) + (fun x => hF _) hpad' + refine ⟨k, hinside, ?_⟩ + have he (t : Option I → Fin N) := finiteRectangleRefinement_affine + (fun _ : Option I => K) (fun _ => N) (paddedResidueOffset L m res) (paddedResidueStep L m) k t + have hmean : + (𝔼 t : Option I → Fin N, F (fun i => paddedResidueOffset L m res i + + paddedResidueStep L m i * + (finiteRectangleRefinement (fun _ : Option I => K) (fun _ => N) (k, t) i).val)) = + 𝔼 t : Option I → Fin N, F (residueCellPosition L N K m res k t) := by + apply Finset.expect_congr rfl + intro t _ + exact congrArg F (he t) + rw [hmean] at hphase + simpa only [add_sub_cancel_left, mul_div_cancel_left₀ _ hB.ne'] using hphase + +end Erdos3 + +end + +section + +namespace Erdos3 + +def residueCellIntegerPoint {I : Type*} (L N K : ℕ) + (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (k : Option I → Fin K) (t : Option I → Fin N) : Option I → ℤ := + scalarResidueGridPoint m res (fun i => (N : ℤ) * (k i).val + (t i).val - L) + +theorem residueCellIntegerPoint_normalized {I : Type*} (L N K : ℕ) + (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (k : Option I → Fin K) (t : Option I → Fin N) : + (fun i => (residueCellIntegerPoint L N K m res k t i : ℝ) / L) = + residueCellPosition L N K m res k t := by + funext i + simp only [residueCellIntegerPoint, scalarResidueGridPoint, residueCellPosition, + progressionCellCorner, paddedResidueOffset, paddedResidueStep, + Int.cast_add, Int.cast_sub, Int.cast_mul, Int.cast_natCast, Nat.cast_mul] + ring + +theorem residueCellIntegerPoint_residue {I : Type*} (L N K : ℕ) + (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) (hm : ∀ i, 0 < m i) + (k : Option I → Fin K) (t : Option I → Fin N) (i : Option I) : + (residueCellIntegerPoint L N K m res k t i : ZMod (m i)) = res i := + scalarResidueGridPoint_residue m res hm _ i + +theorem residueCellIntegerPoint_is_cube {I : Type*} [Fintype I] [DecidableEq I] + {L N K : ℕ} (hL : 0 < L) (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (k : Option I → Fin K) (t : Option I → Fin N) + (ht : residueCellPosition L N K m res k t ∈ scalarCubeDomain I) : + IntegerScalarCube L (residueCellIntegerPoint L N K m res k t) := by + apply (integerScalarCube_iff_normalized hL _).mpr + rw [residueCellIntegerPoint_normalized] + exact scalarCubeDomain_subset_halfOpen I ht + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators NNReal + +theorem scalarCubeResidue_weighted_interior_cell (I : Type*) [Fintype I] [DecidableEq I] + (L M : ℕ) (hL : 0 < L) (m : Option I → ℕ) (res : ∀ i, ZMod (m i)) + (hm : ∀ i, 0 < m i) (hmM : ∀ i, m i ≤ M) + (hsize : (Fintype.card I + 1) * M ≤ L) + (hsmall : scalarCubeGridBoundaryConstant I * ((M : ℝ) / L) < + volume.real (scalarCubeDomain I)) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {r : ℝ≥0} (hr : 0 < r) + (w : (Option I → ℝ) → ℝ) {B T : ℝ≥0} (hB : 0 < B) + (hw : ∀ x, 0 ≤ w x ∧ w x ≤ B) (hLip : LipschitzWith T w) + {δ η ζ : ℝ} (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hη : 0 < η) + (hlarge : 2 * (M : ℝ) ≤ δ * L) + (hmargin : ((Fintype.card I : ℝ) + 1) * δ < r) + (herror : B * scalarCubeResidueCutoffBudget I A r L M + + paddedResidueDensityCap I M * + (((T : ℝ) + B * scalarCubeCutoffLipschitzConstant I A r) * δ + B * η) ≤ ζ) + (F : (Option I → ℝ) → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) + (hbias : ζ ≤ ‖(scalarCubeResidueWeights I L M hL m res hm hmM hsize).complexMean + (fun z => (w (fun i => (z i : ℝ) / L) : ℂ) * F (fun i => (z i : ℝ) / L))‖) : + let N := residueCellLength δ L M + let K := residueCellCount L N + ∃ k : Option I → Fin K, + (∀ t : Option I → Fin N, residueCellPosition L N K m res k t ∈ scalarCubeDomain I) ∧ + η ≤ ‖𝔼 t : Option I → Fin N, F (residueCellPosition L N K m res k t)‖ := by + let N := residueCellLength δ L M + let K := residueCellCount L N + have hM : 0 < M := (hm none).trans_le (hmM none) + have hN := residueCellLength_bounds hδ hδ1 hL hM hlarge + have hP : 2 * L ≤ K * N ∧ K * N ≤ 3 * L := residueCellCount_padding hN.1 hN.2.1 + let b := inequalityBoundaryCutoff (fun _ : Bool × Finset I => (r : ℝ)) scalarCubeFace + let g := fun x => w x * b x + have hb (x) : b x ∈ Set.Icc (0 : ℝ) 1 := inequalityBoundaryCutoff_range _ _ x + have hwabs (x) : |w x| ≤ B := by rw [abs_of_nonneg (hw x).1]; exact (hw x).2 + have hbabs (x) : |b x| ≤ 1 := by rw [abs_of_nonneg (hb x).1]; exact (hb x).2 + have hglip : LipschitzWith (T + B * scalarCubeCutoffLipschitzConstant I A r) g := + bounded_weight_cutoff_lipschitz w b hwabs hbabs hLip (scalarCubeBoundaryCutoff_lipschitz I A hA hr) + have hg (x) : 0 ≤ g x ∧ g x ≤ B := + ⟨mul_nonneg (hw x).1 (hb x).1, + (mul_le_of_le_one_right (hw x).1 (hb x).2).trans (hw x).2⟩ + have hsupport : Function.support g ⊆ halfOpenScalarCubeDomain I := by + intro x hx + exact scalarCubeDomain_subset_halfOpen I + (scalarCubeBoundaryCutoff_tsupport_domain I (show (0 : ℝ) < r from hr) + (tsupport_mul_subset_right (subset_closure hx))) + have hsafe := scalarCube_cutoff_safe (show (0 : ℝ) < r from hr) hmargin g tsupport_mul_subset_right + have hcut := FiniteProbabilityWeights.weighted_cutoff_bias_lower + (scalarCubeResidueWeights I L M hL m res hm hmM hsize) + (fun z => b (fun i => (z i : ℝ) / L)) (fun z => w (fun i => (z i : ℝ) / L)) + (fun z => F (fun i => (z i : ℝ) / L)) B.coe_nonneg + (fun z => hb _) (fun z => hwabs _) (fun z => hF _) hbias + (scalarCubeResidueCutoff_loss I L M hL m res hm hmM hsize hsmall A hA hr) + apply scalarCubeResidue_supported_weight_cell I L M N K hL hN.1 + (residueCellCount_pos L N) hP.1 (by omega) m res hm hmM hsize g hglip + hδ.le hη (show (0 : ℝ) < B from hB) + (fun i => residueCellLength_stride_mesh hδ hδ1 hL hM hlarge (hmM i)) + hg hsupport hsafe _ F hF hcut + simp only [NNReal.coe_add, NNReal.coe_mul] + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedSliceIntegerImage.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedSliceIntegerImage.lean new file mode 100644 index 0000000000000000000000000000000000000000..2cc4a477883228b66206e4500352b00527f50f94 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedSliceIntegerImage.lean @@ -0,0 +1,482 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteWeightedExpansion +import OAI.Combinatorics.Progressions.Fourier.AffineUniformSpectrum +import OAI.Combinatorics.Progressions.Probability.WeightedPlateauMixture +import OAI.Combinatorics.Progressions.Probability.WeightedSliceFamilyLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +noncomputable def integerGridApproximation {X J : Type*} [Fintype X] [Fintype J] [DecidableEq J] + (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) (K M : ℕ) [NeZero M] + (S : Finset (J → Fin M)) (z : J → ℤ) : ℂ := + ((K : ℂ) / M) ^ Fintype.card J * ∑ k ∈ S, integerGridCoefficient p Y M k * star (rectangularGridCharacter M k z) + +theorem affine_weightedCube_grid_density {B I : Type*} [Fintype B] [DecidableEq B] [Fintype I] [DecidableEq I] + {n : ℕ} (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V W L ε : ℝ} + (hU : 1 ≤ U) (hV : 0 ≤ V) (hW : 0 ≤ W) (hL : 0 ≤ L) (hε : 0 < ε) + (h : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) (hlen : ∀ b j, L ≤ (s b j).length) + (hv : ∀ b j i, 0 < v b j i) (hstride : ∀ b j i, ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U) + (K M t : ℕ) [NeZero M] (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n + 1) + (hB : uniformSpectrumBlockCount n J.card t ≤ Fintype.card B) + (hsize : (M : ℝ) ^ J.card ≤ W * L ^ t) (hscale : ∀ b, (M : ℝ) / ∏ j, ((s b j).length : ℝ) ≤ V) : + let ζ := uniformBlockRetainedBias n J.card t U V W ε + let S := uniformBlockSpectrumCover J M n U V L ζ + ∀ shift z, ‖(integerGridDensity (weightedCubeIntegerSource s) (affineWeightedCubeIntegerSum s u v J shift) + K M z : ℂ) - integerGridApproximation (weightedCubeIntegerSource s) (affineWeightedCubeIntegerSum s u v J shift) + K M S z‖ ≤ ((K : ℝ) / M) ^ J.card * ε := by + dsimp only + have ht := (affine_weightedCube_uniform_spectrum s (fun b j i => (u b j i : ℝ)) v A hA hU hV hW hL hε + h hlen hv hstride M t (Nat.pos_of_ne_zero (NeZero.ne M)) J hJ hB hsize hscale).1 + intro shift z + have he := integerGridDensity_truncation (weightedCubeIntegerSource s) + (affineWeightedCubeIntegerSum s u v J shift) K M + (uniformBlockSpectrumCover J M n U V L (uniformBlockRetainedBias n J.card t U V W ε)) z + have htail : spectrumTail (uniformBlockSpectrumCover J M n U V L + (uniformBlockRetainedBias n J.card t U V W ε)) + (fun k => ‖integerGridCoefficient (weightedCubeIntegerSource s) + (affineWeightedCubeIntegerSum s u v J shift) M k‖) ≤ ε := by + simpa only [affineWeightedCubeIntegerSum_coefficient, norm_mul, rectangularGridCharacter_norm, one_mul] using ht + simpa only [integerGridApproximation, Fintype.card_coe] using + he.trans (mul_le_mul_of_nonneg_left htail (by positivity)) + +theorem affine_weightedModerate_grid_density {B I : Type*} [Fintype B] [DecidableEq B] [Fintype I] [DecidableEq I] + {n : ℕ} (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (offset : B → ℤ) (stride : B → ℕ) (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V W L ε : ℝ} + (hU : 1 ≤ U) (hV : 0 ≤ V) (hW : 0 ≤ W) (hL : 0 ≤ L) (hε : 0 < ε) + (hc : ∀ b, ScalarCubePrimitiveBudget (c b) A U) (h : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) + (hclen : ∀ b, L ≤ (c b).length) (hlen : ∀ b j, L ≤ (s b j).length) + (ht : ∀ b, 0 < stride b) (hv : ∀ b j i, 0 < v b j i) + (hstride : ∀ b j i, ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U) + (hcoeff : ∀ b, ((stride b * (c b).modulus none : ℕ) : ℝ) ≤ U) + (K M t : ℕ) [NeZero M] (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n) + (hB : uniformSpectrumBlockCount n J.card t ≤ Fintype.card B) + (hsize : (M : ℝ) ^ J.card ≤ W * L ^ t) + (hscale : ∀ b, (M : ℝ) / ((((stride b * (c b).modulus none : ℕ) : ℝ) * (c b).length) * + ∏ j, ((s b j).length : ℝ)) ≤ V) : + let ζ := uniformBlockRetainedBias n J.card t U V W ε + let S := uniformBlockSpectrumCover J M n U V L ζ + ∀ shift z, ‖(integerGridDensity (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J shift) K M z : ℂ) - + integerGridApproximation (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J shift) K M S z‖ ≤ ((K : ℝ) / M) ^ J.card * ε := by + dsimp only + have htail := (affine_weightedModerate_uniform_spectrum c s (fun b => (offset b : ℝ)) stride + (fun b j i => (u b j i : ℝ)) v A hA hU hV hW hL hε hc h hclen hlen ht hv hstride hcoeff M t + (Nat.pos_of_ne_zero (NeZero.ne M)) J hJ hB hsize hscale).1 + intro shift z + have he := integerGridDensity_truncation (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J shift) K M + (uniformBlockSpectrumCover J M n U V L (uniformBlockRetainedBias n J.card t U V W ε)) z + have hb : spectrumTail (uniformBlockSpectrumCover J M n U V L + (uniformBlockRetainedBias n J.card t U V W ε)) + (fun k => ‖integerGridCoefficient (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J shift) M k‖) ≤ ε := by + simpa only [affineWeightedModerateIntegerSum_coefficient, norm_mul, rectangularGridCharacter_norm, one_mul] using htail + simpa only [integerGridApproximation, Fintype.card_coe] using + he.trans (mul_le_mul_of_nonneg_left hb (by positivity)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical + +variable {B I : Type*} [Fintype B] [DecidableEq B] [Fintype I] [DecidableEq I] +variable {n K M : ℕ} [NeZero M] +variable (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) +variable (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ) + +noncomputable def affineCubePlateauApproximation (K : ℕ) (H : ℝ) + (rows : Finset (Finset I)) (shift z : rows → ℤ) (F : Finset (rows → Fin M)) : ℂ := + (normalizedSupportPlateau H (fun t => ((z t : ℝ) - shift t) / K) : ℂ) * + integerGridApproximation (weightedCubeIntegerSource s) (affineWeightedCubeIntegerSum s u v rows shift) K M F z + +theorem affineCubePlateauApproximation_split + (hK : 0 < K) (H : ℝ) (rows : Finset (Finset I)) (shift z : rows → ℤ) + (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) : + affineCubePlateauApproximation s u v K H rows shift z F = + ((K : ℂ) / M) ^ rows.card * ∑ k ∈ F, + (∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k) * + (rationalGridPhase (D k) (a k) (integerGridResidue (D k) (shift - z)) * + plateauFourierMode H (fun t => -ω k t) (fun t => ((z t : ℝ) - shift t) / K)) := by + unfold affineCubePlateauApproximation integerGridApproximation + simp only [Fintype.card_coe, affineWeightedCubeIntegerSum_coefficient, Finset.mul_sum] + apply Finset.sum_congr rfl + intro k hk + rw [← plateau_grid_character_split H hK k (a k) (ω k) (hfreq k hk) shift z] + ring + +theorem affineCubePlateauMixture_expansion + {T : Type*} [Countable T] [MeasurableSpace T] [MeasurableSingletonClass T] + (p : PMF T) (hK : 0 < K) (H : ℝ) (rows : Finset (Finset I)) + (shift : T → rows → ℤ) (z : rows → ℤ) + (F : Finset (rows → Fin M)) (D : (rows → Fin M) → ℕ) [∀ k, NeZero (D k)] + (a : (rows → Fin M) → rows → ℤ) (ω : (rows → Fin M) → rows → ℝ) + (hfreq : ∀ k ∈ F, ∀ t, ((k t).val : ℝ) / M = (a k t : ℝ) / D k + ω k t / K) : + (∫ zeta, affineCubePlateauApproximation s u v K H rows (shift zeta) z F ∂p.toMeasure) = + ((K : ℂ) / M) ^ rows.card * ∑ k ∈ F, + (∏ b, affineWeightedCubeGridCoefficient (s b) (fun j i => (u b j i : ℝ)) (v b) M rows k) * + (star (rationalGridPhase (D k) (a k) (integerGridResidue (D k) z)) * + plateauModeMixture p H (D k) K (a k) (ω k) shift (fun t => (z t : ℝ) / K)) := by + simp_rw [affineCubePlateauApproximation_split s u v hK H rows _ z F D a ω hfreq] + rw [integral_const_mul, integral_finsetSum] + · congr 1 + apply Finset.sum_congr rfl + intro k _ + rw [integral_const_mul, plateauModeMixture_grid_factor] + · intro k _ + apply Integrable.const_mul + apply pmf_integrable_of_norm_le p _ (B := 1) + intro zeta + rw [norm_mul, rationalGridPhase_norm, one_mul] + exact plateauFourierMode_norm _ _ _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal Classical + +theorem affine_weightedCube_fundamental_approximation {B I : Type*} + [Fintype B] [DecidableEq B] [Fintype I] [DecidableEq I] {n K Q : ℕ} [NeZero K] + (s : B → Fin (n + 1) → NormalizedScalarCubeSource I) + (u : B → Fin (n + 1) → Option I → ℤ) (v : B → Fin (n + 1) → Option I → ℕ) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V W L ε : ℝ} + (hU : 1 ≤ U) (hV : 0 ≤ V) (hW : 0 ≤ W) (hL : 0 ≤ L) (hε : 0 < ε) + (h : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) (hlen : ∀ b j, L ≤ (s b j).length) + (hv : ∀ b j i, 0 < v b j i) (hstride : ∀ b j i, ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U) + (t : ℕ) (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n + 1) + (hQ : ∀ S : J, affineWeightedCubeJetBound s u v S ≤ (Q : ℤ) * K) + (hB : uniformSpectrumBlockCount n J.card t ≤ Fintype.card B) + (hsize : (((2 * Q + 1) * K : ℕ) : ℝ) ^ J.card ≤ W * L ^ t) + (hscale : ∀ b, (((2 * Q + 1) * K : ℕ) : ℝ) / ∏ j, ((s b j).length : ℝ) ≤ V) : + let ζ := uniformBlockRetainedBias n J.card t U V W ε + let S := uniformBlockSpectrumCover J ((2 * Q + 1) * K) n U V L ζ + ∀ center z : J → ℤ, centeredFundamentalBox Q K center z → + ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedCubeIntegerSource s) + (affineWeightedCubeIntegerSum s u v J center) z : ℝ) : ℂ) - + integerGridApproximation (weightedCubeIntegerSource s) + (affineWeightedCubeIntegerSum s u v J center) K ((2 * Q + 1) * K) S z‖ ≤ ε := by + dsimp only + have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K) + have hd := affine_weightedCube_grid_density s u v A hA hU hV hW hL hε h hlen hv hstride + K ((2 * Q + 1) * K) t J hJ hB hsize hscale + intro center z hz + have he : integerGridDensity (weightedCubeIntegerSource s) (affineWeightedCubeIntegerSum s u v J center) + K ((2 * Q + 1) * K) z = (K : ℝ) ^ J.card * finiteImageMass (weightedCubeIntegerSource s) + (affineWeightedCubeIntegerSum s u v J center) z := by + unfold integerGridDensity + rw [affineWeightedCube_mass_on_fundamental_box s u v hK J hQ center z hz, Fintype.card_coe] + have ht := hd center z + rw [he] at ht + apply ht.trans + have hf := mul_le_mul_of_nonneg_right (grid_scale_factor_le_one (2 * Q + 1) K J.card (by omega) hK) hε.le + simpa only [Nat.cast_mul, one_mul] using hf + +theorem affine_weightedModerate_fundamental_approximation {B I : Type*} + [Fintype B] [DecidableEq B] [Fintype I] [DecidableEq I] {n K Q : ℕ} [NeZero K] + (c : B → NormalizedScalarCubeSource Empty) (s : B → Fin n → NormalizedScalarCubeSource I) + (offset : B → ℤ) (stride : B → ℕ) (u : B → Fin n → Option I → ℤ) (v : B → Fin n → Option I → ℕ) + (A : ℝ≥0) (hA : LipschitzWith A Real.smoothTransition) {U V W L ε : ℝ} + (hU : 1 ≤ U) (hV : 0 ≤ V) (hW : 0 ≤ W) (hL : 0 ≤ L) (hε : 0 < ε) + (hc : ∀ b, ScalarCubePrimitiveBudget (c b) A U) (h : ∀ b j, ScalarCubePrimitiveBudget (s b j) A U) + (hclen : ∀ b, L ≤ (c b).length) (hlen : ∀ b j, L ≤ (s b j).length) + (ht : ∀ b, 0 < stride b) (hv : ∀ b j i, 0 < v b j i) + (hstride : ∀ b j i, ((v b j i * (s b j).modulus i : ℕ) : ℝ) ≤ U) + (hcoeff : ∀ b, ((stride b * (c b).modulus none : ℕ) : ℝ) ≤ U) + (t : ℕ) (J : Finset (Finset I)) (hJ : ∀ S ∈ J, S.card ≤ n) + (hQ : ∀ S : J, affineWeightedModerateJetBound c s offset stride u v S ≤ (Q : ℤ) * K) + (hB : uniformSpectrumBlockCount n J.card t ≤ Fintype.card B) + (hsize : (((2 * Q + 1) * K : ℕ) : ℝ) ^ J.card ≤ W * L ^ t) + (hscale : ∀ b, (((2 * Q + 1) * K : ℕ) : ℝ) / + ((((stride b * (c b).modulus none : ℕ) : ℝ) * (c b).length) * ∏ j, ((s b j).length : ℝ)) ≤ V) : + let ζ := uniformBlockRetainedBias n J.card t U V W ε + let S := uniformBlockSpectrumCover J ((2 * Q + 1) * K) n U V L ζ + ∀ center z : J → ℤ, centeredFundamentalBox Q K center z → + ‖(((K : ℝ) ^ J.card * finiteImageMass (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J center) z : ℝ) : ℂ) - + integerGridApproximation (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J center) + K ((2 * Q + 1) * K) S z‖ ≤ ε := by + dsimp only + have hK : 0 < K := Nat.pos_of_ne_zero (NeZero.ne K) + have hd := affine_weightedModerate_grid_density c s offset stride u v A hA hU hV hW hL hε + hc h hclen hlen ht hv hstride hcoeff K ((2 * Q + 1) * K) t J hJ hB hsize hscale + intro center z hz + have he : integerGridDensity (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J center) K ((2 * Q + 1) * K) z = + (K : ℝ) ^ J.card * finiteImageMass (weightedModerateIntegerProductSource c s) + (affineWeightedModerateIntegerSum c s offset stride u v J center) z := by + unfold integerGridDensity + rw [affineWeightedModerate_mass_on_fundamental_box c s offset stride u v hK J hQ center z hz, + Fintype.card_coe] + have he' := hd center z + rw [he] at he' + apply he'.trans + have hf := mul_le_mul_of_nonneg_right (grid_scale_factor_le_one (2 * Q + 1) K J.card (by omega) hK) hε.le + simpa only [Nat.cast_mul, one_mul] using hf + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def integerRetainedCoefficient {X J : Type*} [Fintype X] [Fintype J] + [DecidableEq J] (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) + (K M : ℕ) [NeZero M] (k : J → Fin M) : ℂ := + ((K : ℂ) / M) ^ Fintype.card J * integerGridCoefficient p Y M k + +theorem integerRetainedCoefficient_norm {X J : Type*} [Fintype X] [Fintype J] + [DecidableEq J] (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) + (K M : ℕ) [NeZero M] (k : J → Fin M) : + ‖integerRetainedCoefficient p Y K M k‖ = + ((K : ℝ) / M) ^ Fintype.card J * ‖integerGridCoefficient p Y M k‖ := by + simp only [integerRetainedCoefficient, norm_mul, norm_pow, norm_div, Complex.norm_natCast] + +theorem integerGridApproximation_eq_sum {X J : Type*} [Fintype X] [Fintype J] + [DecidableEq J] (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) + (K M : ℕ) [NeZero M] (S : Finset (J → Fin M)) (z : J → ℤ) : + integerGridApproximation p Y K M S z = + ∑ k ∈ S, integerRetainedCoefficient p Y K M k * star (rectangularGridCharacter M k z) := by + simp only [integerGridApproximation, integerRetainedCoefficient, Finset.mul_sum, mul_assoc] + +theorem integerRetainedCoefficient_mass {X J : Type*} [Fintype X] [Fintype J] + [DecidableEq J] (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) + (K M : ℕ) [NeZero M] (S : Finset (J → Fin M)) {C : ℝ} + (hC : (∑ k, ‖integerGridCoefficient p Y M k‖) ≤ C) : + (∑ k ∈ S, ‖integerRetainedCoefficient p Y K M k‖) ≤ ((K : ℝ) / M) ^ Fintype.card J * C := by + classical + simp only [integerRetainedCoefficient_norm, ← Finset.mul_sum] + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact (Finset.sum_le_univ_sum_of_nonneg (s := S) (fun _ => norm_nonneg _)).trans hC + +theorem integerRetainedCoefficient_mass_le {X J : Type*} [Fintype X] [Fintype J] + [DecidableEq J] (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) + (K M : ℕ) [NeZero M] (S : Finset (J → Fin M)) {C : ℝ} (hKM : K ≤ M) + (hC : (∑ k, ‖integerGridCoefficient p Y M k‖) ≤ C) : + (∑ k ∈ S, ‖integerRetainedCoefficient p Y K M k‖) ≤ C := by + have hM : (0 : ℝ) < M := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne M) + have hratio : (K : ℝ) / M ≤ 1 := (div_le_one hM).mpr (by exact_mod_cast hKM) + have hpow : ((K : ℝ) / M) ^ Fintype.card J ≤ 1 := pow_le_one₀ (by positivity) hratio + have hnonneg : 0 ≤ C := (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans hC + exact (integerRetainedCoefficient_mass p Y K M S hC).trans (mul_le_of_le_one_left hnonneg hpow) + +theorem integerGridApproximation_norm_le {X J : Type*} [Fintype X] [Fintype J] + [DecidableEq J] (p : FiniteProbabilityWeights X) (Y : X → J → ℤ) + (K M : ℕ) [NeZero M] (S : Finset (J → Fin M)) (z : J → ℤ) {C : ℝ} (hKM : K ≤ M) + (hC : (∑ k, ‖integerGridCoefficient p Y M k‖) ≤ C) : + ‖integerGridApproximation p Y K M S z‖ ≤ C := by + rw [integerGridApproximation_eq_sum] + exact retainedExpansion_norm_bound S (integerRetainedCoefficient p Y K M) + (fun k w => star (rectangularGridCharacter M k w)) z + (integerRetainedCoefficient_mass_le p Y K M S hKM hC) + (fun k _ => by rw [norm_star, rectangularGridCharacter_norm]) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def progressionCubeSources {b g : ℕ} (q : ℕ) + (m H : Fin b → Fin g → ℕ) (c : Fin b → Fin g → ℤ) + (hL : ∀ a j, 0 < m a j * H a j) (hm : ∀ a j, 0 < m a j) + (hsize : ∀ a j, (q + 1) * m a j ≤ m a j * H a j) : + Fin b → Fin g → NormalizedScalarCubeSource (Fin q) := + fun a j => normalizedProgressionCubeSource q (m a j) (H a j) (c a j) (hL a j) (hm a j) (hsize a j) + +noncomputable def progressionCubeBlockWeights {b g : ℕ} (q : ℕ) + (m H : Fin b → Fin g → ℕ) (c : Fin b → Fin g → ℤ) + (hL : ∀ a j, 0 < m a j * H a j) (hm : ∀ a j, 0 < m a j) : + FiniteProbabilityWeights (∀ a j, SupportedCube q (integerProgressionSupport (c a j) (m a j : ℤ) (H a j) : Set ℤ)) := + FiniteProbabilityWeights.pi (fun a => FiniteProbabilityWeights.pi (fun j => + uniformProgressionCubeWeights q (m a j) (H a j) (c a j) (hL a j) (hm a j))) + +noncomputable def progressionCubeIntegerSum {b g : ℕ} (q : ℕ) + (m H : Fin b → Fin g → ℕ) (c : Fin b → Fin g → ℤ) + (J : Finset (Finset (Fin q))) (center : J → ℤ) + (x : ∀ a j, SupportedCube q (integerProgressionSupport (c a j) (m a j : ℤ) (H a j) : Set ℤ)) : J → ℤ := + center + ∑ a, fun Z : J => integerBooleanBlockJet (fun j => supportedCubeCoordinates (x a j).val) Z + +theorem progressionCubeIntegerSum_mass {b n : ℕ} (q : ℕ) + (m H : Fin b → Fin (n + 1) → ℕ) (c : Fin b → Fin (n + 1) → ℤ) + (hL : ∀ a j, 0 < m a j * H a j) (hm : ∀ a j, 0 < m a j) + (hsize : ∀ a j, (q + 1) * m a j ≤ m a j * H a j) + (J : Finset (Finset (Fin q))) (center z : J → ℤ) : + finiteImageMass (weightedCubeIntegerSource (progressionCubeSources q m H c hL hm hsize)) + (affineWeightedCubeIntegerSum (progressionCubeSources q m H c hL hm hsize) + (fun a j => cubeRootOffset (c a j)) (fun _ _ _ => 1) J center) z = + finiteImageMass (progressionCubeBlockWeights q m H c hL hm) (progressionCubeIntegerSum q m H c J center) z := by + exact progressionCubeBlocks_imageMass q m H c hL hm hsize + (fun x => center + ∑ a, fun Z : J => integerBooleanBlockJet (x a) Z) z + +theorem progressionCubeIntegerSum_coefficient {b n : ℕ} (q : ℕ) + (m H : Fin b → Fin (n + 1) → ℕ) (c : Fin b → Fin (n + 1) → ℤ) + (hL : ∀ a j, 0 < m a j * H a j) (hm : ∀ a j, 0 < m a j) + (hsize : ∀ a j, (q + 1) * m a j ≤ m a j * H a j) + (J : Finset (Finset (Fin q))) (center : J → ℤ) (M : ℕ) [NeZero M] (k : J → Fin M) : + integerGridCoefficient (weightedCubeIntegerSource (progressionCubeSources q m H c hL hm hsize)) + (affineWeightedCubeIntegerSum (progressionCubeSources q m H c hL hm hsize) + (fun a j => cubeRootOffset (c a j)) (fun _ _ _ => 1) J center) M k = + integerGridCoefficient (progressionCubeBlockWeights q m H c hL hm) + (progressionCubeIntegerSum q m H c J center) M k := by + exact progressionCubeBlocks_complexMean q m H c hL hm hsize + (fun x => rectangularGridCharacter M k (center + ∑ a, fun Z : J => integerBooleanBlockJet (x a) Z)) + +theorem progressionCubeIntegerSum_approximation {b n : ℕ} (q : ℕ) + (m H : Fin b → Fin (n + 1) → ℕ) (c : Fin b → Fin (n + 1) → ℤ) + (hL : ∀ a j, 0 < m a j * H a j) (hm : ∀ a j, 0 < m a j) + (hsize : ∀ a j, (q + 1) * m a j ≤ m a j * H a j) + (J : Finset (Finset (Fin q))) (center z : J → ℤ) (K M : ℕ) [NeZero M] (S : Finset (J → Fin M)) : + integerGridApproximation (weightedCubeIntegerSource (progressionCubeSources q m H c hL hm hsize)) + (affineWeightedCubeIntegerSum (progressionCubeSources q m H c hL hm hsize) + (fun a j => cubeRootOffset (c a j)) (fun _ _ _ => 1) J center) K M S z = + integerGridApproximation (progressionCubeBlockWeights q m H c hL hm) + (progressionCubeIntegerSum q m H c J center) K M S z := by + unfold integerGridApproximation + simp only [progressionCubeIntegerSum_coefficient] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +noncomputable def weightedSliceIntegerSource {b g q : ℕ} + (s : Fin b → Fin g → NormalizedScalarCubeSource (Fin q)) (root : Fin b → Fin g → ℤ) : + FiniteProbabilityWeights (∀ a j, (s a j).SliceDomain (root a j)) := + FiniteProbabilityWeights.pi (fun a => FiniteProbabilityWeights.pi (fun j => (s a j).sliceWeights (root a j))) + +noncomputable def weightedSliceIntegerSum {b g q : ℕ} + (s : Fin b → Fin g → NormalizedScalarCubeSource (Fin q)) (root : Fin b → Fin g → ℤ) + (J : Finset (Finset (Fin q))) (center : J → ℤ) (x : ∀ a j, (s a j).SliceDomain (root a j)) : J → ℤ := + center + ∑ a, fun Z : J => integerBooleanBlockJet (fun j => supportedCubeCoordinates (x a j).val.val) Z + +theorem weightedSliceIntegerSum_complexMean {b n q : ℕ} + (s : Fin b → Fin (n + 1) → NormalizedScalarCubeSource (Fin q)) (root : Fin b → Fin (n + 1) → ℤ) + (J : Finset (Finset (Fin q))) (center : J → ℤ) (f : (J → ℤ) → ℂ) : + (weightedCubeIntegerSource s).complexMean (fun x => f (affineWeightedCubeIntegerSum s + (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center x)) = + (weightedSliceIntegerSource s root).complexMean (fun x => f (weightedSliceIntegerSum s root J center x)) := by + have he := weightedSliceBlocks_complexMean s root + (fun x => f (center + ∑ a, fun Z : J => integerBooleanBlockJet (x a) Z)) + unfold weightedCubeIntegerSource affineWeightedCubeIntegerSum affineWeightedCubeIntegerBlock + weightedSliceIntegerSource weightedSliceIntegerSum + simpa only [affineIntegerCubeCoordinates_root] using he + +theorem weightedSliceIntegerSum_mass {b n q : ℕ} + (s : Fin b → Fin (n + 1) → NormalizedScalarCubeSource (Fin q)) (root : Fin b → Fin (n + 1) → ℤ) + (J : Finset (Finset (Fin q))) (center z : J → ℤ) : + finiteImageMass (weightedCubeIntegerSource s) (affineWeightedCubeIntegerSum s + (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center) z = + finiteImageMass (weightedSliceIntegerSource s root) (weightedSliceIntegerSum s root J center) z := + finiteImageMass_eq_of_complexMean _ _ _ _ (weightedSliceIntegerSum_complexMean s root J center) z + +theorem weightedSliceIntegerSum_coefficient {b n q : ℕ} + (s : Fin b → Fin (n + 1) → NormalizedScalarCubeSource (Fin q)) (root : Fin b → Fin (n + 1) → ℤ) + (J : Finset (Finset (Fin q))) (center : J → ℤ) (M : ℕ) [NeZero M] (k : J → Fin M) : + integerGridCoefficient (weightedCubeIntegerSource s) (affineWeightedCubeIntegerSum s + (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center) M k = + integerGridCoefficient (weightedSliceIntegerSource s root) (weightedSliceIntegerSum s root J center) M k := + weightedSliceIntegerSum_complexMean s root J center (rectangularGridCharacter M k) + +theorem weightedSliceIntegerSum_approximation {b n q : ℕ} + (s : Fin b → Fin (n + 1) → NormalizedScalarCubeSource (Fin q)) (root : Fin b → Fin (n + 1) → ℤ) + (J : Finset (Finset (Fin q))) (center z : J → ℤ) (K M : ℕ) [NeZero M] (S : Finset (J → Fin M)) : + integerGridApproximation (weightedCubeIntegerSource s) (affineWeightedCubeIntegerSum s + (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center) K M S z = + integerGridApproximation (weightedSliceIntegerSource s root) (weightedSliceIntegerSum s root J center) K M S z := by + unfold integerGridApproximation + simp only [weightedSliceIntegerSum_coefficient] + +noncomputable def moderateSliceIntegerSource {b g q : ℕ} (c : Fin b → NormalizedScalarCubeSource Empty) + (s : Fin b → Fin g → NormalizedScalarCubeSource (Fin q)) (root : Fin b → Fin g → ℤ) : + FiniteProbabilityWeights (∀ a, (c a).CoefficientDomain × (∀ j, (s a j).SliceDomain (root a j))) := + FiniteProbabilityWeights.pi (fun a => moderateSliceWeights (c a) (s a) (root a)) + +noncomputable def moderateSliceIntegerSum {b g q : ℕ} (c : Fin b → NormalizedScalarCubeSource Empty) + (s : Fin b → Fin g → NormalizedScalarCubeSource (Fin q)) (offset : Fin b → ℤ) (stride : Fin b → ℕ) + (root : Fin b → Fin g → ℤ) (J : Finset (Finset (Fin q))) (center : J → ℤ) + (x : ∀ a, (c a).CoefficientDomain × (∀ j, (s a j).SliceDomain (root a j))) : J → ℤ := + center + ∑ a, fun Z : J => (offset a + (stride a : ℤ) * (x a).1) * + integerBooleanBlockJet (fun j => supportedCubeCoordinates ((x a).2 j).val.val) Z + +theorem moderateSliceIntegerSum_complexMean {b n q : ℕ} (c : Fin b → NormalizedScalarCubeSource Empty) + (s : Fin b → Fin n → NormalizedScalarCubeSource (Fin q)) (offset : Fin b → ℤ) (stride : Fin b → ℕ) + (root : Fin b → Fin n → ℤ) (J : Finset (Finset (Fin q))) (center : J → ℤ) (f : (J → ℤ) → ℂ) : + (weightedModerateIntegerProductSource c s).complexMean (fun x => f (affineWeightedModerateIntegerSum c s + offset stride (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center x)) = + (moderateSliceIntegerSource c s root).complexMean + (fun x => f (moderateSliceIntegerSum c s offset stride root J center x)) := by + have he := moderateSliceBlocks_complexMean c s root (fun x => f (center + ∑ a, + fun Z : J => (offset a + (stride a : ℤ) * (x a).1) * integerBooleanBlockJet (x a).2 Z)) + unfold weightedModerateIntegerProductSource weightedModerateIntegerSource + affineWeightedModerateIntegerSum affineWeightedModerateIntegerBlock moderateSliceIntegerSource moderateSliceIntegerSum + simpa only [affineIntegerCubeCoordinates_root] using he + +theorem moderateSliceIntegerSum_mass {b n q : ℕ} (c : Fin b → NormalizedScalarCubeSource Empty) + (s : Fin b → Fin n → NormalizedScalarCubeSource (Fin q)) (offset : Fin b → ℤ) (stride : Fin b → ℕ) + (root : Fin b → Fin n → ℤ) (J : Finset (Finset (Fin q))) (center z : J → ℤ) : + finiteImageMass (weightedModerateIntegerProductSource c s) (affineWeightedModerateIntegerSum c s offset stride + (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center) z = + finiteImageMass (moderateSliceIntegerSource c s root) (moderateSliceIntegerSum c s offset stride root J center) z := + finiteImageMass_eq_of_complexMean _ _ _ _ (moderateSliceIntegerSum_complexMean c s offset stride root J center) z + +theorem moderateSliceIntegerSum_coefficient {b n q : ℕ} (c : Fin b → NormalizedScalarCubeSource Empty) + (s : Fin b → Fin n → NormalizedScalarCubeSource (Fin q)) (offset : Fin b → ℤ) (stride : Fin b → ℕ) + (root : Fin b → Fin n → ℤ) (J : Finset (Finset (Fin q))) (center : J → ℤ) + (M : ℕ) [NeZero M] (k : J → Fin M) : + integerGridCoefficient (weightedModerateIntegerProductSource c s) (affineWeightedModerateIntegerSum c s offset stride + (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center) M k = + integerGridCoefficient (moderateSliceIntegerSource c s root) + (moderateSliceIntegerSum c s offset stride root J center) M k := + moderateSliceIntegerSum_complexMean c s offset stride root J center (rectangularGridCharacter M k) + +theorem moderateSliceIntegerSum_approximation {b n q : ℕ} (c : Fin b → NormalizedScalarCubeSource Empty) + (s : Fin b → Fin n → NormalizedScalarCubeSource (Fin q)) (offset : Fin b → ℤ) (stride : Fin b → ℕ) + (root : Fin b → Fin n → ℤ) (J : Finset (Finset (Fin q))) (center z : J → ℤ) + (K M : ℕ) [NeZero M] (S : Finset (J → Fin M)) : + integerGridApproximation (weightedModerateIntegerProductSource c s) (affineWeightedModerateIntegerSum c s offset stride + (fun a j => cubeRootOffset (root a j)) (fun _ _ _ => 1) J center) K M S z = + integerGridApproximation (moderateSliceIntegerSource c s root) + (moderateSliceIntegerSum c s offset stride root J center) K M S z := by + unfold integerGridApproximation + simp only [moderateSliceIntegerSum_coefficient] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationCentralLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationCentralLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..a934d195ae11b7151c4c4834ff5f5143b76be124 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationCentralLattice.lean @@ -0,0 +1,133 @@ +import OAI.Combinatorics.Progressions.Fourier.WeightedTranslationBufferedCentralFrequency +import OAI.Combinatorics.Progressions.Lattices.CentralLatticeQuotientAction + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial +variable {σ : Type*} [Fintype σ] + +noncomputable def centralRationalElement (w : σ → ℕ) (d : ℕ) (hd : 0 < d) + (q : ℚ) : weightedSubalgebra w d := + ⟨⟨0, C q⟩, ⟨by simp, (monomial_mem_restrictSupport ℚ).mpr + (Or.inl (by simpa using hd))⟩⟩ + +noncomputable def centralRationalLine (w : σ → ℕ) (d : ℕ) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) (q : ℚ) : (weightedFiltration w d hwd).Group := + ⟨centralRationalElement w d hd q⟩ + +@[simp] theorem bchTranslationHom_centralRationalLine (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) (hwd : ∀ i, w i ≤ d) (q : ℚ) : + bchTranslationHom w d hw hwd (centralRationalLine w d hd hwd q) = ⟨0, C q⟩ := by + change PolynomialTranslationGroup.exponentialElement 0 (C q) = _ + apply PolynomialTranslationGroup.ext + · rfl + · exact polynomialExponentialCoordinate_C 0 q + +theorem centralRationalLine_mem_lattice (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) (hwd : ∀ i, w i ≤ d) (n : ℤ) : + centralRationalLine w d hd hwd (n : ℚ) ∈ weightedTranslationLattice w d hwd := by + rw [weightedTranslationLattice_eq_integral_preimage w d hw hwd] + change bchTranslationHom w d hw hwd _ ∈ PolynomialTranslationGroup.integralGroup + rw [bchTranslationHom_centralRationalLine] + exact (PolynomialTranslationGroup.mem_integralGroup_iff _).mpr + ⟨fun _ => ⟨0, by simp⟩, integerCoefficientPolynomials_C n⟩ + +@[simp] theorem bchRealTranslationHom_realification_centralRationalLine + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) (q : ℚ) : + bchRealTranslationHom w d hwd (NilpotentLieBCHGroup.realificationHom + (centralRationalLine w d hd hwd q)) = ⟨0, C (q : ℝ)⟩ := by + rw [bchRealTranslationHom_rational w d hw hwd, bchTranslationHom_centralRationalLine] + apply PolynomialTranslationGroupOver.ext + · funext i + change algebraMap ℚ ℝ 0 = 0 + exact map_zero _ + · change MvPolynomial.map (algebraMap ℚ ℝ) (C q) = C (q : ℝ) + simp + +theorem realification_centralRationalLine_mem_realLattice + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] (n : ℤ) : + NilpotentLieBCHGroup.realificationHom (centralRationalLine w d hd hwd (n : ℚ)) ∈ + (weightedTranslationNilmanifold w d hw hwd).realLattice := + ⟨_, centralRationalLine_mem_lattice w d hw hd hwd n, rfl⟩ + +theorem centralRealLine_rat (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) (hwd : ∀ i, w i ≤ d) (q : ℚ) : + centralRealLine w d hw hd hwd (q : ℝ) = + NilpotentLieBCHGroup.realificationHom (centralRationalLine w d hd hwd q) := by + apply bchRealTranslationHom_injective w d hwd + rw [centralRealLine_map, bchRealTranslationHom_realification_centralRationalLine w d hw hd hwd q] + +theorem centralRealLine_int_mem_realLattice + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] (n : ℤ) : + centralRealLine w d hw hd hwd (n : ℝ) ∈ + (weightedTranslationNilmanifold w d hw hwd).realLattice := by + have h := realification_centralRationalLine_mem_realLattice w d hw hd hwd n + rw [← centralRealLine_rat] at h + simpa only [Rat.cast_intCast] using h + +theorem centralRealLine_mem_realLattice_iff + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] (t : ℝ) : + centralRealLine w d hw hd hwd t ∈ + (weightedTranslationNilmanifold w d hw hwd).realLattice ↔ + ∃ n : ℤ, t = (n : ℝ) := by + constructor + · rintro ⟨g, hg, he⟩ + have hgi : bchTranslationHom w d hw hwd g ∈ PolynomialTranslationGroup.integralGroup := by + have hg' : g ∈ weightedTranslationLattice w d hwd := hg + rw [weightedTranslationLattice_eq_integral_preimage w d hw hwd] at hg' + exact hg' + have hp := ((PolynomialTranslationGroup.mem_integralGroup_iff _).mp hgi).2 + obtain ⟨n, hn⟩ := (mem_integerCoefficientPolynomials_iff _).mp hp 0 + have he' := congrArg (bchRealTranslationHom w d hwd) he + rw [bchRealTranslationHom_rational w d hw hwd, centralRealLine_map] at he' + have hc := congrArg (fun x : PolynomialTranslationGroupOver ℝ σ => x.polynomial.coeff 0) he' + change (MvPolynomial.map (algebraMap ℚ ℝ) + (bchTranslationHom w d hw hwd g).polynomial).coeff 0 = (C t).coeff 0 at hc + rw [coeff_map, hn] at hc + exact ⟨n, by simpa using hc.symm⟩ + · rintro ⟨n, rfl⟩ + exact centralRealLine_int_mem_realLattice w d hw hd hwd n + +theorem centralRealLine_int_smul + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] (n : ℤ) + (x : (weightedTranslationNilmanifold w d hw hwd).Space) : + centralRealLine w d hw hd hwd (n : ℝ) • x = x := + central_lattice_smul_eq _ _ (centralRealLine_int_mem_realLattice w d hw hd hwd n) + (fun g => (centralRealLine_commute w d hw hd hwd n g).eq) x + +theorem centralRealLine_add_int_smul + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] (t : ℝ) (n : ℤ) + (x : (weightedTranslationNilmanifold w d hw hwd).Space) : + centralRealLine w d hw hd hwd (t + n) • x = centralRealLine w d hw hd hwd t • x := + central_lattice_int_add_smul_eq _ _ (centralRealLine_add w d hw hd hwd) + (centralRealLine_int_mem_realLattice w d hw hd hwd) + (fun n g => (centralRealLine_commute w d hw hd hwd n g).eq) t n x + +theorem centralRealLine_smul_eq_iff + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hd : 0 < d) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] (t : ℝ) + (x : (weightedTranslationNilmanifold w d hw hwd).Space) : + centralRealLine w d hw hd hwd t • x = x ↔ ∃ n : ℤ, t = (n : ℝ) := by + induction x using Quotient.inductionOn' with + | h g => + change (QuotientGroup.mk (centralRealLine w d hw hd hwd t * g) : + (weightedTranslationNilmanifold w d hw hwd).Space) = QuotientGroup.mk g ↔ _ + rw [(centralRealLine_commute w d hw hd hwd t g).eq, QuotientGroup.eq] + simpa only [mul_inv_rev, mul_assoc, inv_mul_cancel, mul_one, Subgroup.inv_mem_iff] using + centralRealLine_mem_realLattice_iff w d hw hd hwd t + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c1183210ddc8e42a5a47e76b72b60d73289c956 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationLattice.lean @@ -0,0 +1,63 @@ +import OAI.Combinatorics.Progressions.Geometry.WeightedTranslationIntegralCoordinates +import OAI.Combinatorics.Progressions.Polynomial.PolynomialTranslationIntegralAction + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial +variable {σ : Type*} [Fintype σ] + +noncomputable def weightedTranslationLattice (w : σ → ℕ) (d : ℕ) + (hwd : ∀ i, w i ≤ d) : Subgroup (weightedFiltration w d hwd).Group := + (integerWeightedLoweringSubgroup (shearWeight w d)).comap (weightedShearGroupHom w d hwd) + +@[simp] theorem mem_weightedTranslationLattice (w : σ → ℕ) (d : ℕ) + (hwd : ∀ i, w i ≤ d) (g : (weightedFiltration w d hwd).Group) : + g ∈ weightedTranslationLattice w d hwd ↔ + polynomialShearExpAut (weightedShearEmbedding w d g.coord) ∈ + integerWeightedLoweringSubgroup (shearWeight w d) := Iff.rfl + +theorem weightedTranslationLattice_eq_integral_preimage (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) : + weightedTranslationLattice w d hwd = + PolynomialTranslationGroup.integralGroup.comap (bchTranslationHom w d hw hwd) := + (bchTranslation_integral_comap w d hw hwd).symm + +variable (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] + +theorem weightedTranslationLattice_inner_grid : + scaledIntegerGrid d.factorial ⊆ + bchSubgroupCoordinates (weightedBasis w d hw) (weightedTranslationLattice w d hwd) := by + intro x hx + let X := (weightedBasis w d hw).equivFun.symm x + have hX : (weightedBasis w d hw).equivFun X ∈ scaledIntegerGrid d.factorial := by + simpa only [X,LinearEquiv.apply_symm_apply] using hx + have hI := weightedBasis_scaledGrid_normalize w d hw d.factorial (Nat.factorial_pos d) X hX + have he := polynomialShear_factorial_exp_integral d (shearWeight_le w d hwd) + ((d.factorial : ℚ)⁻¹ • weightedShearEmbedding w d X) hI + have hc : (d.factorial : ℚ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero d) + rw [smul_smul,mul_inv_cancel₀ hc,one_smul] at he + exact he + +theorem weightedTranslationLattice_outer_grid : + bchSubgroupCoordinates (weightedBasis w d hw) (weightedTranslationLattice w d hwd) ⊆ + denominatorGrid d.factorial := by + intro x hx + let X := (weightedBasis w d hw).equivFun.symm x + have hE : polynomialShearExpAut (weightedShearEmbedding w d X) ∈ + integerWeightedLoweringSubgroup (shearWeight w d) := hx + have hI (i : σ ⊕ Unit) := polynomialShear_factorial_log_integral d (shearWeight_le w d hwd) + (polynomialShearExpAut (weightedShearEmbedding w d X)) hE i + simp only [polynomialShearLog_exp] at hI + have h := (weightedBasis_denominatorGrid_iff w d hw d.factorial X).mpr hI + simpa only [X,LinearEquiv.apply_symm_apply] using h + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationResidueLattice.lean b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationResidueLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6501130f05e1d1957e81e8bc4fcbba8d6518cb8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Lattices/WeightedTranslationResidueLattice.lean @@ -0,0 +1,121 @@ +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Nilpotent.WeightedTranslationNilmanifold + +namespace OAI + +section + +namespace Erdos3 + +variable {B : Type*} + +noncomputable def integerTranslationResidueSubgroup (M : ℕ) : + Subgroup (PolynomialTranslationGroupOver ℤ B) where + carrier := {γ | ∀ i, (γ.base i : ZMod M) = 0} + one_mem' := by intro i; simp + mul_mem' := by + intro a b ha hb i + simp only [PolynomialTranslationGroupOver.base_mul, Pi.add_apply, Int.cast_add, + ha i, hb i, add_zero] + inv_mem' := by + intro a ha i + simp only [PolynomialTranslationGroupOver.base_inv, Pi.neg_apply, Int.cast_neg, + ha i, neg_zero] + +@[simp] theorem mem_integerTranslationResidueSubgroup (M : ℕ) + (γ : PolynomialTranslationGroupOver ℤ B) : + γ ∈ integerTranslationResidueSubgroup M ↔ ∀ i, (γ.base i : ZMod M) = 0 := Iff.rfl + +noncomputable def integerPolynomialTranslationResidueCover (M : ℕ) : + Subgroup (PolynomialTranslationGroupOver ℝ B) := + (integerTranslationResidueSubgroup (B := B) M).map + (PolynomialTranslationGroupOver.map (Int.castRingHom ℝ)) + +theorem integerPolynomialTranslationResidueCover_le (M : ℕ) : + integerPolynomialTranslationResidueCover (B := B) M ≤ integerPolynomialTranslationSubgroup := by + rintro g ⟨γ, _, rfl⟩ + exact ⟨γ, rfl⟩ + +theorem integerTranslationResidueSubgroup_of_multiple (M : ℕ) + (z : B → ℤ) (Q : MvPolynomial B ℤ) : + (⟨fun i => (M : ℤ) * z i, Q⟩ : PolynomialTranslationGroupOver ℤ B) ∈ + integerTranslationResidueSubgroup M := by + intro i + change (((M : ℤ) * z i : ℤ) : ZMod M) = 0 + simp + +end Erdos3 + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +variable {σ : Type*} [Fintype σ] + +noncomputable def weightedTranslationResidueLattice (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) (M : ℕ) : + Subgroup (weightedFiltration w d hwd).Group := + ((integerTranslationResidueSubgroup (B := σ) M).map PolynomialTranslationGroup.fromInteger).comap + (bchTranslationHom w d hw hwd) + +theorem weightedTranslationResidueLattice_le (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) (M : ℕ) : + weightedTranslationResidueLattice w d hw hwd M ≤ weightedTranslationLattice w d hwd := by + rw [weightedTranslationLattice_eq_integral_preimage w d hw hwd] + rintro g ⟨z, _, hz⟩ + exact ⟨z, hz⟩ + +omit [Fintype σ] in +private theorem integerTranslation_base_pow + (γ : PolynomialTranslationGroupOver ℤ σ) (n : ℕ) (i : σ) : + (γ ^ n).base i = (n : ℤ) * γ.base i := by + induction n with + | zero => simp + | succ n ih => + simp only [pow_succ, PolynomialTranslationGroupOver.base_mul, Pi.add_apply, ih, + Nat.cast_add, Nat.cast_one, add_mul, one_mul] + +theorem weightedTranslationResidueLattice_contains_power_cover + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) (M : ℕ) : + subgroupPowerCover (weightedTranslationLattice w d hwd) M ≤ + weightedTranslationResidueLattice w d hw hwd M := by + apply (subgroupPowerCover_le_iff _ _ M).mpr + intro g hg + rw [weightedTranslationLattice_eq_integral_preimage w d hw hwd] at hg + obtain ⟨γ, hγ⟩ := hg + refine ⟨γ ^ M, ?_, ?_⟩ + · intro i + rw [integerTranslation_base_pow] + simp + · rw [map_pow, map_pow, hγ] + +variable (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] + +theorem weightedTranslationResidueLattice_inner_grid (M : ℕ) : + scaledIntegerGrid (d.factorial * M) ⊆ + bchSubgroupCoordinates (weightedOrderedBasis w d hw) + (weightedTranslationResidueLattice w d hw hwd M) := by + have hinner := subgroupPowerCover_inner_grid (weightedOrderedBasis w d hw) + (weightedTranslationLattice w d hwd) d.factorial M (weightedOrderedBasis_inner_grid w d hw hwd) + intro x hx + apply weightedTranslationResidueLattice_contains_power_cover w d hw hwd M + apply hinner + simpa only [Nat.mul_comm] using hx + +theorem weightedTranslationResidueLattice_outer_grid (M : ℕ) : + bchSubgroupCoordinates (weightedOrderedBasis w d hw) + (weightedTranslationResidueLattice w d hw hwd M) ⊆ + denominatorGrid (d.factorial * M) := by + intro x hx + have h0 := weightedOrderedBasis_outer_grid w d hw hwd + (weightedTranslationResidueLattice_le w d hw hwd M hx) + simpa only [Nat.mul_comm] using denominator_grid_subset_mul d.factorial M h0 + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ANOVABootstrapInequality.lean b/lean/OAI/Combinatorics/Progressions/Linear/ANOVABootstrapInequality.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f8904a2c339637faa14c7de398cea96f003394e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ANOVABootstrapInequality.lean @@ -0,0 +1,22 @@ +import OAI.Combinatorics.Progressions.Results.Basic + +namespace OAI + +section + +namespace Erdos3 + +theorem anova_bootstrap_le {U D E : ℝ} (_hU : 0 ≤ U) (hD : 0 ≤ D) (hE : E ≤ D) + (h : U ^ 2 ≤ D * max U E) : U ≤ D := by + by_cases hUE : U ≤ E + · rw [max_eq_right hUE] at h + have hm := mul_le_mul_of_nonneg_left hE hD + nlinarith + · rw [max_eq_left (le_of_not_ge hUE)] at h + nlinarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ActualCandidateSlowProjectionMass.lean b/lean/OAI/Combinatorics/Progressions/Linear/ActualCandidateSlowProjectionMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..be4c3f283106602c7f3fe35e57b8d7b8b9f0fb35 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ActualCandidateSlowProjectionMass.lean @@ -0,0 +1,752 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateTaggedPairFamily +import OAI.Combinatorics.Progressions.Geometry.ActualCandidateSpatialCenter +import OAI.Combinatorics.Progressions.Lattices.CertifiedAffineCutoffCost +import OAI.Combinatorics.Progressions.Polynomial.FullTaggedProjectionPolynomial +import OAI.Combinatorics.Progressions.Probability.FullFrozenChartMass + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical Matrix + +variable {m : ℕ} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +theorem fullTaggedRealMatrixProjection_single + (P : ∀ j, Matrix (J j) (J j) ℚ) (j : Fin m) (a i : J j) : + fullTaggedRealMatrixProjection J P j (Pi.single a 1) i = (P j i a : ℝ) := + congrFun (Matrix.mulVec_single_one (Matrix.of fun s t => (P j s t : ℝ)) a) i + +theorem fullTaggedRealMatrixProjection_rowSum_le + (P : ∀ j, Matrix (J j) (J j) ℚ) {B : ℝ} + (hP : ∀ j i a, rationalLogHeight (P j i a) ≤ B) (j : Fin m) (i : J j) : + (∑ a : J j, |fullTaggedRealMatrixProjection J P j (Pi.single a 1) i|) ≤ + (Fintype.card (J j) : ℝ) * Real.exp B := by + calc + _ ≤ ∑ _a : J j, Real.exp B := by + apply Finset.sum_le_sum + intro a _ + rw [fullTaggedRealMatrixProjection_single] + exact (rational_abs_real_le_numerator (P j i a)).trans + ((rationalLogHeight_le_iff _ _).mp (hP j i a)).1 + _ = _ := by simp + +theorem fullTaggedRealMatrixProjection_slow_mass_row_le + (P : ∀ j, Matrix (J j) (J j) ℚ) {B d : ℝ} + (hP : ∀ j i a, rationalLogHeight (P j i a) ≤ B) + (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ d) (nVars : ℕ) + (j : Fin m) (i : J j) : + (∑ a : J j, |fullTaggedRealMatrixProjection J P j (Pi.single a 1) i|) * + (((m + 1 : ℕ) : ℝ) * ((nVars + 1 : ℕ) : ℝ) ^ m) ≤ + d * Real.exp B * (((m + 1 : ℕ) : ℝ) * ((nVars + 1 : ℕ) : ℝ) ^ m) := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact (fullTaggedRealMatrixProjection_rowSum_le J P hP j i).trans + (mul_le_mul_of_nonneg_right (hdim j) (Real.exp_nonneg B)) + +theorem fullTaggedRealMatrixProjection_slow_mass_row_le_exp + (P : ∀ j, Matrix (J j) (J j) ℚ) {B d L : ℝ} + (hP : ∀ j i a, rationalLogHeight (P j i a) ≤ B) + (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ d) (nVars : ℕ) + (hVars : ((nVars + 1 : ℕ) : ℝ) ≤ Real.exp L) + (j : Fin m) (i : J j) : + (∑ a : J j, |fullTaggedRealMatrixProjection J P j (Pi.single a 1) i|) * + (((m + 1 : ℕ) : ℝ) * ((nVars + 1 : ℕ) : ℝ) ^ m) ≤ + Real.exp (B + d + (m : ℝ) + (m : ℝ) * L) := by + have hrow : (∑ a : J j, |fullTaggedRealMatrixProjection J P j (Pi.single a 1) i|) ≤ + Real.exp d * Real.exp B := + (fullTaggedRealMatrixProjection_rowSum_le J P hP j i).trans + (mul_le_mul_of_nonneg_right + ((hdim j).trans (by linarith [Real.add_one_le_exp d])) (Real.exp_nonneg B)) + have hm : ((m + 1 : ℕ) : ℝ) ≤ Real.exp (m : ℝ) := by + simpa only [Nat.cast_add, Nat.cast_one] using Real.add_one_le_exp (m : ℝ) + have hv : (((nVars + 1 : ℕ) : ℝ) ^ m) ≤ Real.exp ((m : ℝ) * L) := by + rw [Real.exp_nat_mul] + exact pow_le_pow_left₀ (by positivity) hVars m + calc + _ ≤ (Real.exp d * Real.exp B) * (Real.exp (m : ℝ) * Real.exp ((m : ℝ) * L)) := + mul_le_mul hrow (mul_le_mul hm hv (by positivity) (Real.exp_nonneg _)) + (by positivity) (by positivity) + _ = _ := by + rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {X : Type*} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +noncomputable def fullTaggedCenteredCoordinates + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (a : Σ j, J j) : MvPolynomial X ℝ := + coordinate (LinearMap.proj a.2 : (J a.1 → ℝ) →ₗ[ℝ] ℝ).toAddMonoidHom (poly a.1) - + C (c a.1 a.2) + +noncomputable def fullTaggedSlowProjectionChart + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (z : X ⊕ (Σ j, J j)) : MvPolynomial (X ⊕ (Σ j, J j)) ℝ := + aeval (fullTaggedLinearMapChart J P) + (normalizedRealPolynomialChart N (fullTaggedCenteredCoordinates J poly c) z) + +@[simp] theorem fullTaggedSlowProjectionChart_inl + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) (x : X) : + fullTaggedSlowProjectionChart J P N poly c (Sum.inl x) = + C ((N x)⁻¹) * MvPolynomial.X (Sum.inl x) := by + simp [fullTaggedSlowProjectionChart, fullTaggedLinearMapChart] + +@[simp] theorem fullTaggedSlowProjectionChart_inr + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (j : Fin m) (i : J j) : + fullTaggedSlowProjectionChart J P N poly c (Sum.inr ⟨j, i⟩) = + fullTaggedLinearMapChart J P (Sum.inr ⟨j, i⟩) - + rename Sum.inl (fullTaggedCenteredCoordinates J poly c ⟨j, i⟩) := by + rw [fullTaggedSlowProjectionChart, normalizedRealPolynomialChart_inr, + map_sub, aeval_X, aeval_rename, rename_eq_aeval] + rfl + +omit [∀ j, Fintype (J j)] in +theorem fullTaggedCenteredCoordinates_support + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, J j → ℝ) (a : Σ j, J j) : + fullTaggedCenteredCoordinates J poly c a ∈ + weightedSupportLE (fun _ : X => 1) (a.1.val + 1) := by + apply (weightedSupportLE _ _).sub_mem ?_ (weightedSupportLE_C _ _ _) + apply (mem_weightedSupportLE_iff _ _ _).mpr + apply (scalar_weightedDegree_le_iff _ _ _).mpr + intro α hα + rw [coeff_coordinate, hp a.1 α hα, map_zero] + +omit [∀ j, Fintype (J j)] in +theorem fullTaggedCenteredCoordinates_top + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (c : ∀ j, J j → ℝ) (a : Σ j, J j) : + homogeneousComponent (a.1.val + 1) (fullTaggedCenteredCoordinates J poly c a) = + fullTaggedMajorTopCoordinates J poly a := by + have hc : homogeneousComponent (a.1.val + 1) (C (c a.1 a.2) : MvPolynomial X ℝ) = 0 := by + apply homogeneousComponent_eq_zero + simp + simp only [fullTaggedCenteredCoordinates, map_sub, hc, sub_zero, + fullTaggedMajorTopCoordinates] + +theorem fullTaggedSlowProjectionChart_support + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, J j → ℝ) (z : X ⊕ (Σ j, J j)) : + fullTaggedSlowProjectionChart J P N poly c z ∈ + weightedSupportLE (fullTaggedVariableWeight J) (fullTaggedVariableWeight J z) := by + cases z with + | inl x => + rw [fullTaggedSlowProjectionChart_inl, ← smul_eq_C_mul] + exact (weightedSupportLE _ _).smul_mem _ (weightedSupportLE_X _ _) + | inr a => + rw [fullTaggedSlowProjectionChart_inr] + apply (weightedSupportLE _ _).sub_mem + · intro α hα + exact (fullTaggedLinearMapChart_homogeneous J P (Sum.inr a) (mem_support_iff.mp hα)).le + · exact majorParameterRename_degree (fun _ : X => 1) (fun a : Σ j, J j => a.1.val + 1) + (fullTaggedCenteredCoordinates_support J poly hp c a) + +theorem fullTaggedSlowProjectionChart_top + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (z : X ⊕ (Σ j, J j)) : + weightedHomogeneousComponent (fullTaggedVariableWeight J) (fullTaggedVariableWeight J z) + (fullTaggedSlowProjectionChart J P N poly c z) = + aeval (fullTaggedLinearMapChart J P) + (normalizedRealPolynomialChart N (fullTaggedMajorTopCoordinates J poly) z) := by + rw [fullTaggedSlowProjectionChart, ← aeval_weightedHomogeneousComponent + (fullTaggedVariableWeight J) (fullTaggedVariableWeight J) _ + (fullTaggedLinearMapChart_homogeneous J P)] + congr 1 + cases z with + | inl x => + exact weightedHomogeneousComponent_eq_self + ((isWeightedHomogeneous_X (R := ℝ) (fullTaggedVariableWeight J) (Sum.inl x)).C_mul _) + | inr a => + rw [normalizedRealPolynomialChart_inr, normalizedRealPolynomialChart_inr, map_sub, + weightedHomogeneousComponent_eq_self + (isWeightedHomogeneous_X (R := ℝ) (fullTaggedVariableWeight J) (Sum.inr a))] + congr 1 + rw [rename_eq_aeval, ← aeval_weightedHomogeneousComponent (fun _ : X => 1) + (fullTaggedVariableWeight J) (MvPolynomial.X ∘ Sum.inl) + (fun x => isWeightedHomogeneous_X (R := ℝ) (fullTaggedVariableWeight J) (Sum.inl x))] + rw [← rename_eq_aeval] + exact congrArg (rename Sum.inl) (fullTaggedCenteredCoordinates_top J poly c a) + +end Erdos3.VectorPolynomial + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +theorem allocatedRecoveredIntegerFullChart_slowProjection_spatial + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℝ) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (x : X) : + aeval (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample)) + (fullTaggedSlowProjectionChart J P N poly (fun j => (c j).val) (Sum.inl x)) = + C ((N x)⁻¹) * + affineFramePolynomial (fun k z => (jointIntegerFrame (a, v) k z : ℝ)) x := by + rw [fullTaggedSlowProjectionChart_inl, map_mul, aeval_C, aeval_X] + change C ((N x)⁻¹) * MvPolynomial.map (Int.castRingHom ℝ) + (affineFramePolynomial (jointIntegerFrame (a, v)) x) = _ + rw [affineFramePolynomial_map] + rfl + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_slowProjection_tag + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (hP : ∀ j x, x ∈ U j → P j x = x) (N : X → ℝ) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (j : Fin m) (i : J j) : + aeval (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample)) + (fullTaggedSlowProjectionChart J P N poly (fun j => (c j).val) (Sum.inr ⟨j, i⟩)) = + -(∑ k : J j, P j (Pi.single k 1) i • + mixedLiftPolynomial (euclideanSubspace (U j)) (b j) (o j) Subtype.val (sample j) k) := by + rw [fullTaggedSlowProjectionChart_inr, map_sub, aeval_rename] + simp only [fullTaggedLinearMapChart, map_sum, map_smul, aeval_X] + exact sum_projection_remainder_eq (P j) (U j) (hP j) (poly j) (hm j) + (c j).val (c j).property _ _ _ + (fun k => h.integerFullChart_polynomial_remainder B U b hb o S hR hσ poly hm + hp c a v sample read j k) i + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical + +theorem normalizedMass_neg_linearCombination_le {K I : Type*} [Fintype I] + (T : K → ℝ) (a : I → ℝ) (p : I → MvPolynomial K ℝ) {M : ℝ} + (hp : ∀ i, realPolynomialMass (scaleMvPolynomialAxes T (p i)) ≤ M) : + realPolynomialMass (scaleMvPolynomialAxes T (-(∑ i, a i • p i))) ≤ + (∑ i, |a i|) * M := by + simp only [scaleMvPolynomialAxes_eq_aeval, map_neg, map_sum, map_smul, + normalizedPolynomialMass_neg] + apply (realPolynomialMass_sum_le _ _).trans + rw [Finset.sum_mul] + apply Finset.sum_le_sum + intro i _ + rw [realPolynomialMass_smul] + simpa only [scaleMvPolynomialAxes_eq_aeval] using + mul_le_mul_of_nonneg_left (hp i) (abs_nonneg (a i)) + +end Erdos3 + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +theorem allocatedRecoveredIntegerFullChart_slowProjection_spatial_mass + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℝ) + (hN : ∀ x, 0 < N x) (T : LayerSamplerVariables G I n B → ℝ) + (hT : ∀ k, 0 ≤ T k) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (x : X) : + realPolynomialMass (scaleMvPolynomialAxes T + (aeval (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample)) + (fullTaggedSlowProjectionChart J P N poly (fun j => (c j).val) (Sum.inl x)))) ≤ + |(jointIntegerFrame (a, v) none x : ℝ)| / N x + + (N x)⁻¹ * ∑ k, |(jointIntegerFrame (a, v) (some k) x : ℝ)| * T k := by + rw [allocatedRecoveredIntegerFullChart_slowProjection_spatial] + exact spatialAffineFull_scaled_inv_mul_mass_le _ T hT x (N x) (hN x) + +theorem allocatedRecoveredIntegerFullChart_slowProjection_spatial_mass_of_support + [Fintype X] + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (N : X → ℕ) (hN : ∀ x, 0 < N x) + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : ξ ≤ 1) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (hv : v ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths + (allocatedPhysicalRootBudget B U b S (fun _ => 0)) τ ξ N) 1) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (x : X) : + realPolynomialMass (scaleMvPolynomialAxes (layerSamplerBox B U b S) + (aeval (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample)) + (fullTaggedSlowProjectionChart J P (fun x => (N x : ℝ)) poly + (fun j => (c j).val) (Sum.inl x)))) ≤ + |(jointIntegerFrame (a, v) none x : ℝ)| / (N x : ℝ) + τ / 8 := by + have hT : ∀ k, 0 ≤ layerSamplerBox B U b S k := + fun k => (by norm_num : (0 : ℝ) ≤ 1).trans (layerSamplerBox_one_le B U b S k) + have hn : ∀ x, (0 : ℝ) < N x := fun x => by exact_mod_cast hN x + apply (allocatedRecoveredIntegerFullChart_slowProjection_spatial_mass B U b o poly hm P + (fun x => (N x : ℝ)) hn (layerSamplerBox B U b S) hT c a v sample x).trans + apply add_le_add le_rfl + have hsum := narrowSpatial_frame_slope_sum + (allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0)) hτ hξ N hN + (layerSamplerBox B U b S) hT (layerSamplerBox_sum_le_zero_root_budget B U b S) v hv x + change (N x : ℝ)⁻¹ * (∑ k, |(v (some k, x) : ℝ)| * layerSamplerBox B U b S k) ≤ _ + calc + _ ≤ (N x : ℝ)⁻¹ * (τ * (N x : ℝ) / 8) := + mul_le_mul_of_nonneg_left hsum (inv_nonneg.mpr (hn x).le) + _ = τ / 8 := by field_simp [(hn x).ne'] + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_slowProjection_tag_mass + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (hP : ∀ j x, x ∈ U j → P j x = x) (N : X → ℝ) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C j * ‖x‖) + (hsmall : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1) + (j : Fin m) (i : J j) : + realPolynomialMass (scaleMvPolynomialAxes (layerSamplerBox B U b S) + (aeval (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample)) + (fullTaggedSlowProjectionChart J P N poly (fun j => (c j).val) (Sum.inr ⟨j, i⟩)))) ≤ + (∑ k : J j, |P j (Pi.single k 1) i|) * + (((m + 1 : ℕ) : ℝ) * + ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ m) := by + rw [h.integerFullChart_slowProjection_tag B U b hb o S hR hσ poly hm P hP N + hp c a v sample read j i] + apply normalizedMass_neg_linearCombination_le + intro k + exact allocatedLayerSupported_normalized_mass_uniform B U b o hR hσ S hσ1 C hC hchart + hsmall j (sample j) (h.2.2.1 j).2 k + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_slowProjection_mass + [Fintype X] + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (hP : ∀ j x, x ∈ U j → P j x = x) + (N : X → ℕ) (hN : ∀ x, 0 < N x) + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : ξ ≤ 1) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (hv : v ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths + (allocatedPhysicalRootBudget B U b S (fun _ => 0)) τ ξ N) 1) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C j * ‖x‖) + (hsmall : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1) + (M : ℝ) + (hcenter : ∀ x, |(jointIntegerFrame (a, v) none x : ℝ)| / (N x : ℝ) + τ / 8 ≤ M) + (hrows : ∀ j i, (∑ k : J j, |P j (Pi.single k 1) i|) * + (((m + 1 : ℕ) : ℝ) * + ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ m) ≤ M) + (z : X ⊕ (Σ j, J j)) : + realPolynomialMass (scaleMvPolynomialAxes (layerSamplerBox B U b S) + (aeval (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample)) + (fullTaggedSlowProjectionChart J P (fun x => (N x : ℝ)) poly + (fun j => (c j).val) z))) ≤ M := by + cases z with + | inl x => + exact (allocatedRecoveredIntegerFullChart_slowProjection_spatial_mass_of_support B U b o S + poly hm P N hN hτ hξ c a v hv sample x).trans (hcenter x) + | inr z => + exact (h.integerFullChart_slowProjection_tag_mass B U b hb o S hR hσ poly hm P hP + (fun x => (N x : ℝ)) hp c a v sample read hσ1 C hC hchart hsmall z.1 z.2).trans + (hrows z.1 z.2) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) + +theorem AllocatedCenteredFramedRecoveredSampleAt.integerFullChart_frozen_slowProjection_mass + [Fintype X] + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (hP : ∀ j x, x ∈ U j → P j x = x) + (N : X → ℕ) (hN : ∀ x, 0 < N x) + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : ξ ≤ 1) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (hv : v ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths + (allocatedPhysicalRootBudget B U b S (fun _ => 0)) τ ξ N) 1) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (h : AllocatedCenteredFramedRecoveredSampleAt B U b hb o S hR hσ poly hm c a v sample read) + (hσ1 : ∀ j, σ j ≤ 1) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ C j * ‖x‖) + (hsmall : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1) + (M : ℝ) + (hcenter : ∀ x, |(jointIntegerFrame (a, v) none x : ℝ)| / (N x : ℝ) + τ / 8 ≤ M) + (hrows : ∀ j i, (∑ k : J j, |P j (Pi.single k 1) i|) * + (((m + 1 : ℕ) : ℝ) * + ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ m) ≤ M) + (keep : LayerSamplerVariables G I n B → Prop) + (fixed : {i // ¬keep i} → ℤ) + (hfixed : ∀ i, |(fixed i : ℝ)| ≤ layerSamplerBox B U b S i.val) + (z : X ⊕ (Σ j, J j)) : + realPolynomialMass (scaleMvPolynomialAxes (fun i : {i // keep i} => layerSamplerBox B U b S i.val) + (aeval (integerSampledRealChart + (allocatedFrozenIntegerFullChart B U b o poly hm c a v sample keep fixed)) + (fullTaggedSlowProjectionChart J P (fun x => (N x : ℝ)) poly + (fun j => (c j).val) z))) ≤ M := by + have hT : ∀ k, 0 < layerSamplerBox B U b S k := + fun k => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U b S k) + apply (normalizedMass_aeval_frozen_integer_chart_le + (allocatedRecoveredIntegerFullChart B U b o poly hm c a v sample) keep + (layerSamplerBox B U b S) hT fixed hfixed _).trans + exact h.integerFullChart_slowProjection_mass B U b hb o S hR hσ poly hm P hP N hN + hτ hξ hp c a v hv sample read hσ1 C hC hchart hsmall M hcenter hrows z + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped Classical + +variable {m : ℕ} {X : Type*} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +theorem fullTaggedSlowProjectionChart_physical_spatial + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℕ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X → ℤ) (a : X) : + MvPolynomial.eval (fun z => (fullTaggedPhysicalIntegerPoint J poly c x z : ℝ)) + (fullTaggedSlowProjectionChart J P (fun z => (N z : ℝ)) poly c (Sum.inl a)) = + (N a : ℝ)⁻¹ * (x a : ℝ) := by + simp [fullTaggedPhysicalIntegerPoint] + +theorem fullTaggedSlowProjectionChart_physical_spatial_abs_le_one [Fintype X] + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) (N : X → ℕ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X → ℤ) (hx : x ∈ integerBox N) (a : X) : + |MvPolynomial.eval (fun z => (fullTaggedPhysicalIntegerPoint J poly c x z : ℝ)) + (fullTaggedSlowProjectionChart J P (fun z => (N z : ℝ)) poly c (Sum.inl a))| ≤ 1 := by + rw [fullTaggedSlowProjectionChart_physical_spatial] + have ha := (mem_integerBox N x).mp hx a + have hx0 : (0 : ℝ) ≤ x a := by exact_mod_cast ha.1 + have hxN : (x a : ℝ) < N a := by exact_mod_cast ha.2 + have hN : (0 : ℝ) < N a := lt_of_le_of_lt hx0 hxN + rw [abs_of_nonneg (mul_nonneg (inv_nonneg.mpr hN.le) hx0), mul_comm, ← div_eq_mul_inv] + exact (div_le_one hN).mpr hxN.le + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {X : Type*} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +omit [∀ j, Fintype (J j)] in + +theorem fullTaggedCenteredCoordinates_eval + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (c : ∀ j, J j → ℝ) + (x : X → ℝ) (j : Fin m) (i : J j) : + MvPolynomial.eval x (fullTaggedCenteredCoordinates J poly c ⟨j, i⟩) = + eval x (poly j) i - c j i := by + have he : eval₂ x (poly j) = eval x (poly j) := by + simpa using eval₂_algebraMap (S := ℝ) x (poly j) + rw [fullTaggedCenteredCoordinates, map_sub, eval_C, ← coordinate_eval₂, he] + rfl + +theorem fullTaggedSlowProjectionChart_physical_tag + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (hP : ∀ j y, y ∈ U j → P j y = y) (N : X → ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j α, coefficients (poly j) α ∈ U j) + (c : ∀ j, U j) (x : X → ℤ) (j : Fin m) (i : J j) : + MvPolynomial.eval + (fun z => (fullTaggedPhysicalIntegerPoint J poly (fun j => (c j).val) x z : ℝ)) + (fullTaggedSlowProjectionChart J P N poly (fun j => (c j).val) (Sum.inr ⟨j, i⟩)) = + P j (fun a => (round (eval (fun z => (x z : ℝ)) (poly j) a - (c j).val a) : ℝ) - + (eval (fun z => (x z : ℝ)) (poly j) a - (c j).val a)) i := by + have hmem : eval (fun z => (x z : ℝ)) (poly j) - (c j).val ∈ U j := + (U j).sub_mem ((eval_mem_iff_coefficients (U j) (poly j)).mpr (hm j) _) (c j).property + rw [fullTaggedSlowProjectionChart_inr, map_sub, fullTaggedLinearMapChart_eval_tag, + MvPolynomial.eval_rename] + change P j (fun a => (round (eval (fun z => (x z : ℝ)) (poly j) a - (c j).val a) : ℝ)) i - + MvPolynomial.eval (fun z => (x z : ℝ)) + (fullTaggedCenteredCoordinates J poly (fun j => (c j).val) ⟨j, i⟩) = _ + rw [fullTaggedCenteredCoordinates_eval] + change _ = P j ((fun a => (round (eval (fun z => (x z : ℝ)) (poly j) a - (c j).val a) : ℝ)) - + (eval (fun z => (x z : ℝ)) (poly j) - (c j).val)) i + rw [map_sub, hP j _ hmem, Pi.sub_apply, Pi.sub_apply] + +theorem fullTaggedSlowProjectionChart_physical_tag_abs_le + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (hP : ∀ j y, y ∈ U j → P j y = y) (N : X → ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j α, coefficients (poly j) α ∈ U j) + (c : ∀ j, U j) (x : X → ℤ) (j : Fin m) (i : J j) : + |MvPolynomial.eval + (fun z => (fullTaggedPhysicalIntegerPoint J poly (fun j => (c j).val) x z : ℝ)) + (fullTaggedSlowProjectionChart J P N poly (fun j => (c j).val) (Sum.inr ⟨j, i⟩))| ≤ + ∑ a : J j, |P j (Pi.single a 1) i| := by + rw [fullTaggedSlowProjectionChart_physical_tag J U P hP N poly hm c x j i, + linearMap_pi_apply_eq_sum] + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro a _ + rw [abs_mul] + apply mul_le_of_le_one_right (abs_nonneg _) + rw [abs_sub_comm] + exact (abs_sub_round _).trans (by norm_num) + +theorem fullTaggedSlowProjectionChart_physical_abs_le [Fintype X] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (P : ∀ j, (J j → ℝ) →ₗ[ℝ] (J j → ℝ)) + (hP : ∀ j y, y ∈ U j → P j y = y) (N : X → ℕ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j α, coefficients (poly j) α ∈ U j) + (c : ∀ j, U j) (x : X → ℤ) (hx : x ∈ integerBox N) {M : ℝ} + (hrows : ∀ j i, (∑ a : J j, |P j (Pi.single a 1) i|) ≤ M) + (z : X ⊕ (Σ j, J j)) : + |MvPolynomial.eval + (fun v => (fullTaggedPhysicalIntegerPoint J poly (fun j => (c j).val) x v : ℝ)) + (fullTaggedSlowProjectionChart J P (fun v => (N v : ℝ)) poly (fun j => (c j).val) z)| ≤ + max 1 M := by + cases z with + | inl a => + exact (fullTaggedSlowProjectionChart_physical_spatial_abs_le_one + J P N poly (fun j => (c j).val) x hx a).trans (le_max_left _ _) + | inr a => + exact (fullTaggedSlowProjectionChart_physical_tag_abs_le + J U P hP (fun v => (N v : ℝ)) poly hm c x a.1 a.2).trans + ((hrows a.1 a.2).trans (le_max_right _ _)) + +theorem fullTaggedSlowProjectionChart_physical_abs_le_rational [Fintype X] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (Q : ∀ j, Matrix (J j) (J j) ℚ) + (hQ : ∀ j y, y ∈ U j → fullTaggedRealMatrixProjection J Q j y = y) + (N : X → ℕ) (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j α, coefficients (poly j) α ∈ U j) + (c : ∀ j, U j) (x : X → ℤ) (hx : x ∈ integerBox N) {H d : ℝ} + (hheight : ∀ j i a, rationalLogHeight (Q j i a) ≤ H) + (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ d) + (z : X ⊕ (Σ j, J j)) : + |MvPolynomial.eval + (fun v => (fullTaggedPhysicalIntegerPoint J poly (fun j => (c j).val) x v : ℝ)) + (fullTaggedSlowProjectionChart J (fullTaggedRealMatrixProjection J Q) + (fun v => (N v : ℝ)) poly (fun j => (c j).val) z)| ≤ max 1 (d * Real.exp H) := by + apply fullTaggedSlowProjectionChart_physical_abs_le J U + (fullTaggedRealMatrixProjection J Q) hQ N poly hm c x hx _ z + intro j i + exact (fullTaggedRealMatrixProjection_rowSum_le J Q hheight j i).trans + (mul_le_mul_of_nonneg_right (hdim j) (Real.exp_nonneg H)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +noncomputable def actualCandidateSlowProjectionMassBudget (m nVars : ℕ) (d H : ℝ) : ℝ := + 2 + d * Real.exp H * (((m + 1 : ℕ) : ℝ) * ((nVars + 1 : ℕ) : ℝ) ^ m) + +theorem actualCandidateSlowProjectionMassBudget_two_le (m nVars : ℕ) {d H : ℝ} + (hd : 0 ≤ d) : 2 ≤ actualCandidateSlowProjectionMassBudget m nVars d H := by + unfold actualCandidateSlowProjectionMassBudget + exact le_add_of_nonneg_right (by positivity) + +theorem actualCandidateSlowProjectionMassBudget_one_le (m nVars : ℕ) {d H : ℝ} + (hd : 0 ≤ d) : 1 ≤ actualCandidateSlowProjectionMassBudget m nVars d H := + (by norm_num : (1 : ℝ) ≤ 2).trans + (actualCandidateSlowProjectionMassBudget_two_le m nVars hd) + +theorem actualCandidateSlowProjectionMassBudget_max_le (m nVars : ℕ) {d H : ℝ} + (hd : 0 ≤ d) : + max 1 (d * Real.exp H) ≤ actualCandidateSlowProjectionMassBudget m nVars d H := by + apply max_le (actualCandidateSlowProjectionMassBudget_one_le m nVars hd) + have hm : (1 : ℝ) ≤ ((m + 1 : ℕ) : ℝ) := by exact_mod_cast Nat.succ_pos m + have hn : (1 : ℝ) ≤ ((nVars + 1 : ℕ) : ℝ) := by exact_mod_cast Nat.succ_pos nVars + have hfactor : (1 : ℝ) ≤ ((m + 1 : ℕ) : ℝ) * ((nVars + 1 : ℕ) : ℝ) ^ m := by + simpa only [one_mul] using mul_le_mul hm (one_le_pow₀ hn) (by norm_num) (by positivity) + have h := mul_le_mul_of_nonneg_left hfactor (mul_nonneg hd (Real.exp_nonneg H)) + unfold actualCandidateSlowProjectionMassBudget + rw [mul_one] at h + linarith + +end Erdos3 + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalLocalChart + +open _root_.MvPolynomial _root_.OAI.MvPolynomial + +variable {cost : ℝ} (C : AllocatedExternalLocalChart (E := E) A cost) + +theorem slowProjection_mass + (P : ∀ j, Matrix (J j) (J j) ℚ) + (hP : ∀ j x, x ∈ U j → fullTaggedRealMatrixProjection J P j x = x) + {d H : ℝ} (hd : 0 ≤ d) + (hheight : ∀ j i a, rationalLogHeight (P j i a) ≤ H) + (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ d) + (hτ1 : τ ≤ 1) (hξ1 : ξ ≤ 1) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hσ1 : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1) + (z : X ⊕ (Σ j, J j)) : + realPolynomialMass (scaleMvPolynomialAxes + (fun i : C.Variables => layerSamplerBox B U b S i.val) + (aeval (integerSampledRealChart C.integerChart) + (fullTaggedSlowProjectionChart J (fullTaggedRealMatrixProjection J P) + (fun x => (N x : ℝ)) poly (fun j => (C.centerLift j).val) z))) ≤ + actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) d H := by + have hv : C.path.2.val ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths + (allocatedPhysicalRootBudget B U b S (fun _ => 0)) τ ξ N) 1 := by + simpa only [allocatedExternalCandidateWidths, allocatedExternalCandidateRootBudget_eq] + using C.path.2.property + apply C.recovered.integerFullChart_frozen_slowProjection_mass B U b hb o S hR hσ poly hm + (fullTaggedRealMatrixProjection J P) hP N A.size_pos A.trim_pos hξ1 hp + C.centerLift C.path.1.val C.path.2.val hv C.sample C.read hσ1 Cgeo hCgeo hchart hsmall + (actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) d H) ?_ ?_ + C.keep C.fixed C.fixed_abs_le_box z + · intro x + exact (A.path_spatial_center_mass_le hτ1 C.path x).trans + (actualCandidateSlowProjectionMassBudget_two_le _ _ hd) + · intro j i + have hrow := fullTaggedRealMatrixProjection_slow_mass_row_le J P hheight hdim + (Fintype.card (LayerSamplerVariables G I n B)) j i + unfold actualCandidateSlowProjectionMassBudget + linarith + +theorem slowProjection_mass_sides + (P : ∀ j, Matrix (J j) (J j) ℚ) + (hP : ∀ j x, x ∈ U j → fullTaggedRealMatrixProjection J P j x = x) + {d H : ℝ} (hd : 0 ≤ d) + (hheight : ∀ j i a, rationalLogHeight (P j i a) ≤ H) + (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ d) + (hτ1 : τ ≤ 1) (hξ1 : ξ ≤ 1) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hσ1 : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1) + (z : X ⊕ (Σ j, J j)) : + realPolynomialMass (scaleMvPolynomialAxes (fun i : C.Variables => (A.sides i.val : ℝ)) + (aeval (integerSampledRealChart C.integerChart) + (fullTaggedSlowProjectionChart J (fullTaggedRealMatrixProjection J P) + (fun x => (N x : ℝ)) poly (fun j => (C.centerLift j).val) z))) ≤ + actualCandidateSlowProjectionMassBudget m + (Fintype.card (LayerSamplerVariables G I n B)) d H := by + have hT : (fun i : C.Variables => (A.sides i.val : ℝ)) = + (fun i : C.Variables => layerSamplerBox B U b S i.val) := by + funext i + exact (allocatedParameterBox_side_eq B U b S i.val).symm + rw [hT] + exact C.slowProjection_mass P hP hd hheight hdim hτ1 hξ1 hp hσ1 Cgeo hCgeo hchart hsmall z + +end AllocatedExternalLocalChart +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ActualFixedSpatialScaledRetainedKernelBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/ActualFixedSpatialScaledRetainedKernelBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..51884cf707c64754854a8d0b6063a1e9d0bb86ea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ActualFixedSpatialScaledRetainedKernelBounds.lean @@ -0,0 +1,120 @@ +import OAI.Combinatorics.Progressions.Geometry.ActualFixedSpatialRetainedPatchEndpoint + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type} [Fintype G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {X : Type} [Fintype X] [DecidableEq X] +variable {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] +variable (Dmod : ℕ) {Lrank : ℕ} +variable (spatial : Fin Lrank ↪ G) +variable (kernel : ∀ j : Fin m, Fin Lrank × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis + (allocatedShortAxis (I := I) U b S.value) j, Fin Lrank ↪ B ⟨j,a.val⟩) +variable {Tsp : Type} [Fintype Tsp] +variable (spatialEquiv : G ≃ X ⊕ (X ⊕ Tsp)) (Wsp Lsp : ℝ) +variable (physicalN : X → ℕ) (τ δslice P Pbad Ppres : ℝ) + +namespace ActualFixedSpatialSlicedForecastPath +variable {B U b S hR hσ Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres} +variable (slice : ActualFixedSpatialSlicedForecastPath (Eout := Eout) B U b S hR hσ + Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres) + +variable {A : Type} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (hB : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis U b S.value a}, + 4 ≤ Fintype.card (B a.val)) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Module.Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + +variable {d : ℕ} (e : Fin d ≃ Σ j, J j) + +private theorem lipschitzWith_nnreal_mul {Y : Type*} [PseudoMetricSpace Y] + {F : Y → ℝ} {L : ℝ≥0} (hF : LipschitzWith L F) (κ : ℝ≥0) : + LipschitzWith (κ * L) (fun y => (κ : ℝ) * F y) := by + apply LipschitzWith.of_dist_le_mul + intro x y + calc + dist ((κ : ℝ) * F x) ((κ : ℝ) * F y) = (κ : ℝ) * dist (F x) (F y) := by + simp only [Real.dist_eq, ← mul_sub, abs_mul, abs_of_nonneg κ.coe_nonneg] + _ ≤ (κ : ℝ) * ((L : ℝ) * dist x y) := + mul_le_mul_of_nonneg_left (hF.dist_le_mul x y) κ.coe_nonneg + _ = ((κ * L : ℝ≥0) : ℝ) * dist x y := by rw [NNReal.coe_mul, mul_assoc] + +variable (cutoff : ℕ) (κ : ℝ≥0) + +theorem scaledRetainedRecoveredG_mem_Icc {Dcap Rcap : ℝ≥0} + (hdensity : ∀ y, slice.density hB y ∈ Set.Icc (0 : ℝ) Dcap) + (hcap : ∀ residue β, + |slice.retainedRecoveredRationalFactor selected bW hb e cutoff residue β| ≤ Rcap) + (v : X → ℝ) (residue : X → ZMod (slice.path.referenceRetainedCRTModulus cutoff)) + (β : Fin d → ℤ) (y : Fin d → ℝ) : + slice.scaledRetainedRecoveredG selected hB o bW hb e cutoff κ v residue β y ∈ + Set.Icc (0 : ℝ) (κ * (Dcap * Rcap) : ℝ≥0) := by + have h := slice.retainedRecoveredG_mem_Icc selected hB o bW hb e cutoff hdensity hcap + v residue β y + refine ⟨mul_nonneg κ.coe_nonneg h.1, ?_⟩ + exact mul_le_mul_of_nonneg_left h.2 κ.coe_nonneg + +theorem scaledRetainedRecoveredG_spatial_lipschitz + (hτ : 0 < τ) {Dlip Rcap : ℝ≥0} + (hdensity : LipschitzWith Dlip (slice.density hB)) + (hcap : ∀ residue β, + |slice.retainedRecoveredRationalFactor selected bW hb e cutoff residue β| ≤ Rcap) + (residue : X → ZMod (slice.path.referenceRetainedCRTModulus cutoff)) + (β : Fin d → ℤ) (y : Fin d → ℝ) : + LipschitzWith (κ * (Rcap * (Dlip * ⟨8 / τ, by positivity⟩))) + (fun v => slice.scaledRetainedRecoveredG selected hB o bW hb e cutoff κ v residue β y) := + lipschitzWith_nnreal_mul + (slice.retainedRecoveredG_spatial_lipschitz selected hB o bW hb e cutoff hτ + hdensity hcap residue β y) κ + +theorem scaledRetainedRecoveredG_lift_lipschitz + (C : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + {Dlip Rcap : ℝ≥0} (hdensity : LipschitzWith Dlip (slice.density hB)) + (hcap : ∀ residue β, + |slice.retainedRecoveredRationalFactor selected bW hb e cutoff residue β| ≤ Rcap) + (v : X → ℝ) (residue : X → ZMod (slice.path.referenceRetainedCRTModulus cutoff)) + (β : Fin d → ℤ) : + LipschitzWith (κ * (Rcap * (Dlip * (K * ∑ j, C j * Fintype.card (J j))))) + (slice.scaledRetainedRecoveredG selected hB o bW hb e cutoff κ v residue β) := + lipschitzWith_nnreal_mul + (slice.retainedRecoveredG_lift_lipschitz selected hB o bW hb e cutoff C hC K hK + hdensity hcap v residue β) κ + +theorem scaledRetainedRecoveredG_recovered_invariant {r : ℕ} + (M : Fin d → Fin r → ℤ) + (hcol : ∀ j a, (standardEuclideanPoint (J j) + (fun i => M (e.symm ⟨j,i⟩) a)).val ∈ euclideanSubspace (U j)) + (hdiv : ∀ i a, (slice.path.referenceRetainedCRTModulus cutoff : ℤ) ∣ M i a) + (v : X → ℝ) (residue : X → ZMod (slice.path.referenceRetainedCRTModulus cutoff)) + (β : Fin d → ℤ) (k : Fin r → ℤ) : + slice.scaledRetainedRecoveredG selected hB o bW hb e cutoff κ v residue + (recoveredIntegerLift M β k) = + slice.scaledRetainedRecoveredG selected hB o bW hb e cutoff κ v residue β := by + funext y + exact congrArg (fun t : ℝ => (κ : ℝ) * t) + (congrFun (slice.retainedRecoveredG_recovered_invariant selected hB o bW hb e cutoff + M hcol hdiv v residue β k) y) + +end ActualFixedSpatialSlicedForecastPath +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ActualFixedSpatialSlicedRetainedKernelComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/ActualFixedSpatialSlicedRetainedKernelComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc951116d06b002f07dff9674ba8686584031ba1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ActualFixedSpatialSlicedRetainedKernelComparison.lean @@ -0,0 +1,576 @@ +import OAI.Combinatorics.Progressions.Geometry.ActualFixedSpatialRetainedModulusBudget +import OAI.Combinatorics.Progressions.Geometry.AllocatedExternalCandidateBufferedCoordinates +import OAI.Combinatorics.Progressions.Probability.ActualFixedSpatialSlicedNumericalDensity +import OAI.Combinatorics.Progressions.Sampling.ForecastLawCenteredRecoveredKernel + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type} [Fintype G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {X : Type} [Fintype X] [DecidableEq X] +variable {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] +variable (Dmod : ℕ) {Lrank : ℕ} +variable (spatial : Fin Lrank ↪ G) +variable (kernel : ∀ j : Fin m, Fin Lrank × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis + (allocatedShortAxis (I := I) U b S.value) j, Fin Lrank ↪ B ⟨j,a.val⟩) +variable {Tsp : Type} [Fintype Tsp] +variable (spatialEquiv : G ≃ X ⊕ (X ⊕ Tsp)) (Wsp Lsp : ℝ) +variable (physicalN : X → ℕ) (τ δslice P Pbad Ppres : ℝ) + +namespace ActualFixedSpatialSlicedForecastPath +variable {B U b S hR hσ Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres} +variable (slice : ActualFixedSpatialSlicedForecastPath (Eout := Eout) B U b S hR hσ + Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres) + +variable {A : Type} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (hB : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis U b S.value a}, + 4 ≤ Fintype.card (B a.val)) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Module.Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + +variable {d : ℕ} (e : Fin d ≃ Σ j, J j) + +noncomputable def recoveredG + (v : X → ℝ) (r : X → ZMod slice.path.referenceModulus) + (β : Fin d → ℤ) (y : Fin d → ℝ) : ℝ := by + letI : NeZero slice.path.referenceModulus := ⟨slice.path.referenceModulus_pos.ne'⟩ + exact forecastLawRecoveredKernel B U b S slice.principalLaw + (slice.density hB) selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceInputLaw) + (fun z t j => integerLongPolynomialOutput slice.path.referencePolynomial + (fun k => (z k.1 k.2 : ℤ)) slice.path.referenceModulus t j) + slice.path.referenceModulus (∏ a, (basisAxisScale (b (selected a).1) (selected a).2 : ℝ)) + slice.path.base physicalN τ o hb bW v r + (fun a => β (e.symm a)) (fun a => y (e.symm a)) + +theorem rawTarget_eq_recoveredG (κ : ℝ) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j q, coefficients (poly j) q ∈ U j) (u : X → ℤ) + (β : Fin d → ℤ) (y : Fin d → ℝ) + (hpoint : ∀ j i, y (e.symm ⟨j,i⟩) + (β (e.symm ⟨j,i⟩) : ℝ) = + eval (fun a => (u a : ℝ)) (poly j) i) + (hquarter : ∀ i, |y i| ≤ 1 / 4) : + slice.rawTarget selected hB o bW hb κ poly hm u = + (κ : ℂ) * (slice.recoveredG selected hB o bW hb e + (fun i => (u i : ℝ) / physicalN i) + (fun i => (u i : ZMod slice.path.referenceModulus)) β y : ℂ) := by + let : NeZero slice.path.referenceModulus := ⟨slice.path.referenceModulus_pos.ne'⟩ + apply congrArg (fun z : ℂ => (κ : ℂ) * z) + exact forecastLawDensityPhysicalTarget_eq_recoveredKernel B U b S slice.principalLaw + (slice.density hB) selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceInputLaw) + (fun z t j => integerLongPolynomialOutput slice.path.referencePolynomial + (fun k => (z k.1 k.2 : ℤ)) slice.path.referenceModulus t j) + slice.path.referenceModulus (∏ a, (basisAxisScale (b (selected a).1) (selected a).2 : ℝ)) + slice.path.base physicalN τ o hb bW poly hm u + (fun a => β (e.symm a)) (fun a => y (e.symm a)) hpoint + (fun a => hquarter (e.symm a)) + +theorem targetAt_eq_recoveredG + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j q, coefficients (poly j) q ∈ U j) (κ : ℝ) (u : X → ℤ) + (β : Fin d → ℤ) (y : Fin d → ℝ) + (hpoint : ∀ i, y i + (β i : ℝ) = + fullTaggedBufferedCoordinates e poly (fun j => (slice.path.center j).val) u i) + (hquarter : ∀ i, |y i| ≤ 1 / 4) : + slice.targetAt selected hB o bW hb poly hm κ u = + (κ : ℂ) * (slice.recoveredG selected hB o bW hb e + (fun i => (u i : ℝ) / physicalN i) + (fun i => (u i : ZMod slice.path.referenceModulus)) β y : ℂ) := by + rw [slice.targetAt_eq_rawTarget selected hB o bW hb poly hm κ u] + apply slice.rawTarget_eq_recoveredG selected hB o bW hb e κ + (slice.path.physicalPolynomial poly) (slice.path.physicalPolynomial_mem poly hm) u β y + ?_ hquarter + intro j i + have hp := hpoint (e.symm ⟨j, i⟩) + simp only [fullTaggedBufferedCoordinates] at hp + rw [e.apply_symm_apply] at hp + simpa only [ActualFixedSpatialForecastPath.physicalPolynomial, + eval_subtractConstant, Pi.sub_apply] using hp + +end ActualFixedSpatialSlicedForecastPath +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type} [Fintype G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {X : Type} [Fintype X] [DecidableEq X] +variable {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] +variable (Dmod : ℕ) {Lrank : ℕ} +variable (spatial : Fin Lrank ↪ G) +variable (kernel : ∀ j : Fin m, Fin Lrank × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis + (allocatedShortAxis (I := I) U b S.value) j, Fin Lrank ↪ B ⟨j,a.val⟩) +variable {Tsp : Type} [Fintype Tsp] +variable (spatialEquiv : G ≃ X ⊕ (X ⊕ Tsp)) (Wsp Lsp : ℝ) +variable (physicalN : X → ℕ) (τ δslice P Pbad Ppres : ℝ) + +namespace ActualFixedSpatialSlicedForecastPath +variable {B U b S hR hσ Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres} +variable (slice : ActualFixedSpatialSlicedForecastPath (Eout := Eout) B U b S hR hσ + Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres) + +variable {A : Type} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (hB : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis U b S.value a}, + 4 ≤ Fintype.card (B a.val)) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Module.Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + +variable {d : ℕ} (e : Fin d ≃ Σ j, J j) + +local instance fullReferenceNonzero : NeZero slice.path.referenceModulus := + ⟨slice.path.referenceModulus_pos.ne'⟩ +local instance retainedReferenceNonzero (cutoff : ℕ) : + NeZero (slice.path.referenceRetainedCRTModulus cutoff) := + ⟨by rw [slice.path.referenceRetainedCRTModulus_eq]; + exact (slice.path.referenceRetainedModulus_pos cutoff).ne'⟩ + +noncomputable def retainedRecoveredG (cutoff : ℕ) + (v : X → ℝ) (r : X → ZMod (slice.path.referenceRetainedCRTModulus cutoff)) + (β : Fin d → ℤ) (y : Fin d → ℝ) : ℝ := + forecastLawRecoveredKernel B U b S slice.principalLaw + (slice.density hB) selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) + (fun z t j => integerLongPolynomialOutput slice.path.referencePolynomial + (fun k => (z k.1 k.2 : ℤ)) (slice.path.referenceRetainedCRTModulus cutoff) t j) + (slice.path.referenceRetainedCRTModulus cutoff) + (∏ a, (basisAxisScale (b (selected a).1) (selected a).2 : ℝ)) + slice.path.base physicalN τ o hb bW v r + (fun a => β (e.symm a)) (fun a => y (e.symm a)) + +omit [Fintype Tsp] in +theorem retainedForecastOutput_reduce (cutoff : ℕ) + (r : X → ZMod slice.path.referenceModulus) (labels : ∀ j, Fin (n j) ⊕ Eout j → ℤ) : + (fun out => ZMod.castHom (slice.path.referenceRetainedCRTModulus_dvd cutoff) + (ZMod (slice.path.referenceRetainedCRTModulus cutoff)) + (forecastCongruenceOutput (allocatedShortAxis (I := I) U b S.value) r + (fun j i => (labels j i : ZMod slice.path.referenceModulus)) out)) = + forecastCongruenceOutput (allocatedShortAxis (I := I) U b S.value) + (fun i => ZMod.castHom (slice.path.referenceRetainedCRTModulus_dvd cutoff) + (ZMod (slice.path.referenceRetainedCRTModulus cutoff)) (r i)) + (fun j i => (labels j i : ZMod (slice.path.referenceRetainedCRTModulus cutoff))) := by + funext out + rcases out with ⟨j, x | i | a⟩ <;> + simp only [forecastCongruenceOutput, map_intCast] + +noncomputable def recoveredRationalFactor + (r : X → ZMod slice.path.referenceModulus) (β : Fin d → ℤ) : ℝ := + forecastLawRecoveredRationalFactor B U b S slice.principalLaw selected + slice.path.sample slice.path.commonTuple (fun _ => slice.path.referenceInputLaw) + (fun z t j => integerLongPolynomialOutput slice.path.referencePolynomial + (fun k => (z k.1 k.2 : ℤ)) slice.path.referenceModulus t j) + slice.path.referenceModulus (∏ a, (basisAxisScale (b (selected a).1) (selected a).2 : ℝ)) + hb bW r (fun a => β (e.symm a)) + +noncomputable def retainedRecoveredRationalFactor (cutoff : ℕ) + (r : X → ZMod (slice.path.referenceRetainedCRTModulus cutoff)) (β : Fin d → ℤ) : ℝ := + forecastLawRecoveredRationalFactor B U b S slice.principalLaw selected + slice.path.sample slice.path.commonTuple (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) + (fun z t j => integerLongPolynomialOutput slice.path.referencePolynomial + (fun k => (z k.1 k.2 : ℤ)) (slice.path.referenceRetainedCRTModulus cutoff) t j) + (slice.path.referenceRetainedCRTModulus cutoff) + (∏ a, (basisAxisScale (b (selected a).1) (selected a).2 : ℝ)) hb bW r + (fun a => β (e.symm a)) + +end ActualFixedSpatialSlicedForecastPath +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type} [Fintype G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {X : Type} [Fintype X] [DecidableEq X] +variable {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] +variable (Dmod : ℕ) {Lrank : ℕ} +variable (spatial : Fin Lrank ↪ G) +variable (kernel : ∀ j : Fin m, Fin Lrank × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis + (allocatedShortAxis (I := I) U b S.value) j, Fin Lrank ↪ B ⟨j,a.val⟩) +variable {Tsp : Type} [Fintype Tsp] +variable (spatialEquiv : G ≃ X ⊕ (X ⊕ Tsp)) (Wsp Lsp : ℝ) +variable (physicalN : X → ℕ) (τ δslice P Pbad Ppres : ℝ) + +namespace ActualFixedSpatialSlicedForecastPath +variable {B U b S hR hσ Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres} +variable (slice : ActualFixedSpatialSlicedForecastPath (Eout := Eout) B U b S hR hσ + Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres) + +variable {A : Type} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (hB : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis U b S.value a}, + 4 ≤ Fintype.card (B a.val)) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Module.Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + +variable {d : ℕ} (e : Fin d ≃ Σ j, J j) + +local instance retainedBoundsReferenceNonzero (cutoff : ℕ) : + NeZero (slice.path.referenceRetainedCRTModulus cutoff) := + ⟨(slice.path.referenceRetainedCRTModulus_pos cutoff).ne'⟩ + +local notation "Out" => Sigma (AllocatedCongruenceRankOutput X Eout + (allocatedShortAxis (I := I) U b S.value)) + +noncomputable def retainedRationalBudget (cutoff depth : ℕ) (Pgrid : ℝ) : ℝ := + let _ := slice + Pgrid + (Fintype.card Out : ℝ) * ((depth : ℝ) * + (Pbad + Ppres + ((cutoff + 1 : ℕ) : ℝ) * Real.log (cutoff + 1))) + +noncomputable def retainedRationalCap (cutoff depth : ℕ) (Pgrid : ℝ) : ℝ≥0 := + ⟨Real.exp (slice.retainedRationalBudget cutoff depth Pgrid), Real.exp_nonneg _⟩ + +variable (cutoff : ℕ) +local notation "q" => slice.path.referenceRetainedCRTModulus cutoff +local notation "vol" => (∏ a, (basisAxisScale (b (Sigma.fst (selected a))) (Sigma.snd (selected a)) : ℝ)) +local notation "grid" => forecastInactiveFixedOutput B U b S selected + (allocatedOriginalSampleInactiveCoefficients B selected slice.path.sample) slice.path.commonTuple +local notation "Y" => (fun z t j => integerLongPolynomialOutput slice.path.referencePolynomial + (fun k => (z (Prod.fst k) (Prod.snd k) : ℤ)) q t j) +local notation "rat" => forecastLawRecoveredRationalFactor B U b S slice.principalLaw selected + slice.path.sample slice.path.commonTuple (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) + Y q vol hb bW +local notation "centered" => forecastLawCenteredRecoveredKernel B U b S slice.principalLaw + (slice.density hB) selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) Y q vol + slice.path.base physicalN τ o hb bW e (fun _ => 0) + +omit [Fintype Tsp] in +theorem retainedRecoveredRationalFactor_nonneg + (r : X → ZMod q) (β : Fin d → ℤ) : + 0 ≤ slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β := + forecastLawRecoveredRationalFactor_nonneg B U b S slice.principalLaw selected + slice.path.sample slice.path.commonTuple (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) + Y q vol hb bW (Finset.prod_nonneg (fun _ _ => Nat.cast_nonneg _)) + r (fun a => β (e.symm a)) + +omit [Fintype Tsp] in +theorem retainedRecoveredRationalFactor_le_exp_of_modulus + (Pgrid Pmod : ℝ) + (hgrid : ∀ z : A → ℤ, vol * slice.principalLaw.fiberMean grid + (fun a _ => z a) (fun _ => 1) ≤ Real.exp Pgrid) + (hq : (q : ℝ) ≤ Real.exp Pmod) + (r : X → ZMod q) (β : Fin d → ℤ) : + slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β ≤ + Real.exp (Pgrid + (Fintype.card Out : ℝ) * Pmod) := + forecastLawRecoveredRationalFactor_le_exp_of_grid_modulus B U b S slice.principalLaw + selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) Y q vol hb bW + (Finset.prod_nonneg (fun _ _ => Nat.cast_nonneg _)) hgrid hq r + (fun a => β (e.symm a)) + +omit [Fintype Tsp] in +theorem retainedRecoveredRationalFactor_abs_le_exp_of_modulus + (Pgrid Pmod : ℝ) + (hgrid : ∀ z : A → ℤ, vol * slice.principalLaw.fiberMean grid + (fun a _ => z a) (fun _ => 1) ≤ Real.exp Pgrid) + (hq : (q : ℝ) ≤ Real.exp Pmod) + (r : X → ZMod q) (β : Fin d → ℤ) : + |slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β| ≤ + Real.exp (Pgrid + (Fintype.card Out : ℝ) * Pmod) := by + rw [abs_of_nonneg (slice.retainedRecoveredRationalFactor_nonneg selected bW hb e cutoff r β)] + exact slice.retainedRecoveredRationalFactor_le_exp_of_modulus selected bW hb e cutoff + Pgrid Pmod hgrid hq r β + +omit [Fintype Tsp] in +theorem retainedRecoveredRationalFactor_le_exp + (depth : ℕ) (hdepth : ∀ p : slice.path.primes, slice.path.exponent p.val ≤ depth) + (Pgrid : ℝ) + (hgrid : ∀ z : A → ℤ, vol * slice.principalLaw.fiberMean grid + (fun a _ => z a) (fun _ => 1) ≤ Real.exp Pgrid) + (r : X → ZMod q) (β : Fin d → ℤ) : + slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β ≤ + Real.exp (slice.retainedRationalBudget cutoff depth Pgrid) := by + have hmod : (q : ℝ) ≤ Real.exp ((depth : ℝ) * + (Pbad + Ppres + ((cutoff + 1 : ℕ) : ℝ) * Real.log (cutoff + 1))) := by + rw [slice.path.referenceRetainedCRTModulus_eq] + exact slice.path.referenceRetainedModulus_le_exp cutoff depth hdepth + exact slice.retainedRecoveredRationalFactor_le_exp_of_modulus selected bW hb e cutoff + Pgrid _ hgrid hmod r β + +omit [Fintype Tsp] in +theorem retainedRecoveredRationalFactor_abs_le_cap + (depth : ℕ) (hdepth : ∀ p : slice.path.primes, slice.path.exponent p.val ≤ depth) + (Pgrid : ℝ) + (hgrid : ∀ z : A → ℤ, vol * slice.principalLaw.fiberMean grid + (fun a _ => z a) (fun _ => 1) ≤ Real.exp Pgrid) + (r : X → ZMod q) (β : Fin d → ℤ) : + |slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β| ≤ + slice.retainedRationalCap cutoff depth Pgrid := by + rw [abs_of_nonneg (slice.retainedRecoveredRationalFactor_nonneg selected bW hb e cutoff r β)] + exact slice.retainedRecoveredRationalFactor_le_exp selected bW hb e cutoff depth hdepth Pgrid hgrid r β + +private theorem retainedRecoveredG_eq_centered : + slice.retainedRecoveredG selected hB o bW hb e cutoff = centered := by + funext v r β y + change forecastLawRecoveredKernel _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + (fun a => y (e.symm a)) = + forecastLawRecoveredKernel _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + (fun a => y (e.symm a) + 0) + simp only [add_zero] + +omit [Fintype Tsp] in +private theorem retainedRational_abs_le_layered {Rcap : ℝ≥0} + (hcap : ∀ r β, |slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β| ≤ Rcap) + (r : X → ZMod q) (β : (Σ j, J j) → ℤ) : |rat r β| ≤ Rcap := by + have h := hcap r (fun i => β (e i)) + simpa only [retainedRecoveredRationalFactor, Equiv.apply_symm_apply] using h + +theorem retainedRecoveredG_mem_Icc {Dcap Rcap : ℝ≥0} + (hdensity : ∀ y, slice.density hB y ∈ Set.Icc (0 : ℝ) Dcap) + (hcap : ∀ r β, |slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β| ≤ Rcap) + (v : X → ℝ) (r : X → ZMod q) (β : Fin d → ℤ) (y : Fin d → ℝ) : + slice.retainedRecoveredG selected hB o bW hb e cutoff v r β y ∈ + Set.Icc (0 : ℝ) (Dcap * Rcap : ℝ≥0) := by + rw [slice.retainedRecoveredG_eq_centered selected hB o bW hb e cutoff] + apply forecastLawCenteredRecoveredKernel_mem_Icc _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + hdensity (Finset.prod_nonneg (fun _ _ => Nat.cast_nonneg _)) + intro r β + exact (le_abs_self _).trans (slice.retainedRational_abs_le_layered selected bW hb e cutoff hcap r β) + +theorem retainedRecoveredG_lift_lipschitz + (C : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + {Dlip Rcap : ℝ≥0} (hdensity : LipschitzWith Dlip (slice.density hB)) + (hcap : ∀ r β, |slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β| ≤ Rcap) + (v : X → ℝ) (r : X → ZMod q) (β : Fin d → ℤ) : + LipschitzWith (Rcap * (Dlip * (K * ∑ j, C j * Fintype.card (J j)))) + (slice.retainedRecoveredG selected hB o bW hb e cutoff v r β) := by + rw [slice.retainedRecoveredG_eq_centered selected hB o bW hb e cutoff] + exact forecastLawCenteredRecoveredKernel_lift_lipschitz B U b S slice.principalLaw + (slice.density hB) selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) Y q vol + slice.path.base physicalN τ o hb bW e (fun _ => 0) hR C hC K hK hdensity + (slice.retainedRational_abs_le_layered selected bW hb e cutoff hcap) v r β + +theorem retainedRecoveredG_spatial_lipschitz + (hτ : 0 < τ) {Dlip Rcap : ℝ≥0} (hdensity : LipschitzWith Dlip (slice.density hB)) + (hcap : ∀ r β, |slice.retainedRecoveredRationalFactor selected bW hb e cutoff r β| ≤ Rcap) + (r : X → ZMod q) (β : Fin d → ℤ) (y : Fin d → ℝ) : + LipschitzWith (Rcap * (Dlip * ⟨8 / τ, by positivity⟩)) + (fun v => slice.retainedRecoveredG selected hB o bW hb e cutoff v r β y) := by + simp only [slice.retainedRecoveredG_eq_centered selected hB o bW hb e cutoff] + exact forecastLawCenteredRecoveredKernel_spatial_lipschitz B U b S slice.principalLaw + (slice.density hB) selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) Y q vol + slice.path.base physicalN τ o hb bW e (fun _ => 0) hτ hdensity + (slice.retainedRational_abs_le_layered selected bW hb e cutoff hcap) r β y + +theorem retainedRecoveredG_recovered_invariant {d' : ℕ} + (M : Fin d → Fin d' → ℤ) + (hcol : ∀ j a, (standardEuclideanPoint (J j) + (fun i => M (e.symm ⟨j,i⟩) a)).val ∈ euclideanSubspace (U j)) + (hdiv : ∀ i a, (q : ℤ) ∣ M i a) + (v : X → ℝ) (r : X → ZMod q) (β : Fin d → ℤ) (k : Fin d' → ℤ) : + slice.retainedRecoveredG selected hB o bW hb e cutoff v r (recoveredIntegerLift M β k) = + slice.retainedRecoveredG selected hB o bW hb e cutoff v r β := by + simp only [slice.retainedRecoveredG_eq_centered selected hB o bW hb e cutoff] + exact forecastLawCenteredRecoveredKernel_recovered_invariant B U b S slice.principalLaw + (slice.density hB) selected slice.path.sample slice.path.commonTuple + (fun _ => slice.path.referenceRetainedCRTInputLaw cutoff) Y q vol + slice.path.base physicalN τ o hb bW e (fun _ => 0) M hcol hdiv v r β k + +end ActualFixedSpatialSlicedForecastPath +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G : Type} [Fintype G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {X : Type} [Fintype X] [DecidableEq X] +variable {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] +variable (Dmod : ℕ) {Lrank : ℕ} +variable (spatial : Fin Lrank ↪ G) +variable (kernel : ∀ j : Fin m, Fin Lrank × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis + (allocatedShortAxis (I := I) U b S.value) j, Fin Lrank ↪ B ⟨j,a.val⟩) +variable {Tsp : Type} [Fintype Tsp] +variable (spatialEquiv : G ≃ X ⊕ (X ⊕ Tsp)) (Wsp Lsp : ℝ) +variable (physicalN : X → ℕ) (τ δslice P Pbad Ppres : ℝ) + +namespace ActualFixedSpatialSlicedForecastPath +variable {B U b S hR hσ Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres} +variable (slice : ActualFixedSpatialSlicedForecastPath (Eout := Eout) B U b S hR hσ + Dmod spatial kernel block spatialEquiv Wsp Lsp physicalN τ δslice P Pbad Ppres) + +variable {A : Type} [Fintype A] +variable (selected : A → Σ j : Fin m, Fin (n j)) +variable (hB : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis U b S.value a}, + 4 ≤ Fintype.card (B a.val)) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Module.Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + +variable {d : ℕ} (e : Fin d ≃ Σ j, J j) + +local instance : NeZero slice.path.referenceModulus := ⟨slice.path.referenceModulus_pos.ne'⟩ +local instance (cutoff : ℕ) : NeZero (slice.path.referenceRetainedCRTModulus cutoff) := + ⟨(slice.path.referenceRetainedCRTModulus_pos cutoff).ne'⟩ + +local notation "labels" => forecastRecoveredIntegerLabels U b hb bW +local notation "grid" => forecastInactiveFixedOutput B U b S selected + (allocatedOriginalSampleInactiveCoefficients B selected slice.path.sample) slice.path.commonTuple +local notation "vol" => (∏ a, (basisAxisScale (b (Sigma.fst (selected a))) (Sigma.snd (selected a)) : ℝ)) +local notation "raw" => (fun z : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty + (allocatedPrincipalSides B U b S) => + fun k : PrincipalTupleIndex B (layerSamplerDegree I n) × Option Empty => (z (Prod.fst k) (Prod.snd k) : ℤ)) +local notation "out" r:max β:max => forecastCongruenceOutput (allocatedShortAxis (I := I) U b S.value) r + (fun j i => (labels (fun a => β (e.symm a)) j i : ZMod slice.path.referenceModulus)) +local notation "gridAt" β:max => (fun a (_ : (Finset.univ : Finset (Finset Empty))) => + labels (fun a => β (e.symm a)) (Sigma.fst (selected a)) (Sum.inl (Sigma.snd (selected a)))) +local notation "reduced" cutoff:max r:max => (fun i => ZMod.castHom + (slice.path.referenceRetainedCRTModulus_dvd cutoff) + (ZMod (slice.path.referenceRetainedCRTModulus cutoff)) (r i)) + +omit [Fintype Tsp] in + +theorem retainedRecoveredRationalFactor_eq_reference (cutoff : ℕ) + (r : X → ZMod slice.path.referenceModulus) (β : Fin d → ℤ) : + slice.retainedRecoveredRationalFactor selected bW hb e cutoff (reduced cutoff r) β = + slice.path.retainedCRTReferenceForecast slice.principalLaw grid raw cutoff vol + (gridAt β) (out r β) := by + unfold retainedRecoveredRationalFactor forecastLawRecoveredRationalFactor + ActualFixedSpatialForecastPath.retainedCRTReferenceForecast + rw [slice.retainedForecastOutput_reduce cutoff r] + simp only [rationalInactiveForecast, rationalOutputDensity, ← Nat.card_eq_fintype_card] + +omit [Fintype Tsp] in + +theorem recoveredRationalFactor_retained_comparison + (hm : 0 < m) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (Eout j) + n j) ≤ Dmod) + (cutoff : ℕ) (hcutoff : 0 < cutoff) (hsmall : 2 / (cutoff : ℝ) ≤ 1 / 2) + {δ : ℝ} (hδ : 0 ≤ δ) (haccuracy : 4 / (cutoff : ℝ) ≤ δ) + (r : X → ZMod slice.path.referenceModulus) (β : Fin d → ℤ) : + (1 - δ) * slice.retainedRecoveredRationalFactor selected bW hb e cutoff (reduced cutoff r) β ≤ + slice.recoveredRationalFactor selected bW hb e r β ∧ + slice.recoveredRationalFactor selected bW hb e r β ≤ + (1 + δ) * slice.retainedRecoveredRationalFactor selected bW hb e cutoff (reduced cutoff r) β := by + rw [slice.retainedRecoveredRationalFactor_eq_reference selected bW hb e cutoff r β] + unfold recoveredRationalFactor forecastLawRecoveredRationalFactor + have h := slice.path.reference_inactive_goodPrimeDeletion_retainedCRT hm hD slice.principalLaw + grid raw cutoff hcutoff hsmall hδ haccuracy vol (by positivity) (gridAt β) (out r β) + dsimp only at h + simpa only [rationalInactiveForecast, rationalOutputDensity, ← Nat.card_eq_fintype_card] using h + +private theorem mul_relative_bounds {w f g δ : ℝ} (hw : 0 ≤ w) + (h : (1 - δ) * g ≤ f ∧ f ≤ (1 + δ) * g) : + (1 - δ) * (w * g) ≤ w * f ∧ w * f ≤ (1 + δ) * (w * g) := by + constructor + · calc + _ = w * ((1 - δ) * g) := by ring + _ ≤ w * f := mul_le_mul_of_nonneg_left h.1 hw + · calc + _ ≤ w * ((1 + δ) * g) := mul_le_mul_of_nonneg_left h.2 hw + _ = _ := by ring + +theorem recoveredG_retained_comparison + (hm : 0 < m) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (Eout j) + n j) ≤ Dmod) + (cutoff : ℕ) (hcutoff : 0 < cutoff) (hsmall : 2 / (cutoff : ℝ) ≤ 1 / 2) + {δ : ℝ} (hδ : 0 ≤ δ) (haccuracy : 4 / (cutoff : ℝ) ≤ δ) + (v : X → ℝ) (r : X → ZMod slice.path.referenceModulus) + (β : Fin d → ℤ) (y : Fin d → ℝ) : + (1 - δ) * slice.retainedRecoveredG selected hB o bW hb e cutoff v (reduced cutoff r) β y ≤ + slice.recoveredG selected hB o bW hb e v r β y ∧ + slice.recoveredG selected hB o bW hb e v r β y ≤ + (1 + δ) * slice.retainedRecoveredG selected hB o bW hb e cutoff v (reduced cutoff r) β y := by + exact mul_relative_bounds (slice.density_nonneg hB _) + (slice.recoveredRationalFactor_retained_comparison selected bW hb e hm hD cutoff hcutoff + hsmall hδ haccuracy r β) + +theorem recoveredG_retained_abs_sub_le + (hm : 0 < m) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (Eout j) + n j) ≤ Dmod) + (cutoff : ℕ) (hcutoff : 0 < cutoff) (hsmall : 2 / (cutoff : ℝ) ≤ 1 / 2) + {δ : ℝ} (hδ : 0 ≤ δ) (haccuracy : 4 / (cutoff : ℝ) ≤ δ) + (v : X → ℝ) (r : X → ZMod slice.path.referenceModulus) + (β : Fin d → ℤ) (y : Fin d → ℝ) : + |slice.recoveredG selected hB o bW hb e v r β y - + slice.retainedRecoveredG selected hB o bW hb e cutoff v (reduced cutoff r) β y| ≤ + δ * slice.retainedRecoveredG selected hB o bW hb e cutoff v (reduced cutoff r) β y := by + have h := slice.recoveredG_retained_comparison selected hB o bW hb e hm hD cutoff + hcutoff hsmall hδ haccuracy v r β y + apply abs_le.mpr + constructor + · nlinarith only [h.1] + · nlinarith only [h.2] + +theorem recoveredG_retained_comparison_scaled + (hm : 0 < m) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (Eout j) + n j) ≤ Dmod) + (cutoff : ℕ) (hcutoff : 0 < cutoff) (hsmall : 2 / (cutoff : ℝ) ≤ 1 / 2) + {δ : ℝ} (hδ : 0 ≤ δ) (haccuracy : 4 / (cutoff : ℝ) ≤ δ) + {κ : ℝ} (hκ : 0 ≤ κ) + (v : X → ℝ) (r : X → ZMod slice.path.referenceModulus) + (β : Fin d → ℤ) (y : Fin d → ℝ) : + (1 - δ) * (κ * slice.retainedRecoveredG selected hB o bW hb e cutoff v + (reduced cutoff r) β y) ≤ κ * slice.recoveredG selected hB o bW hb e v r β y ∧ + κ * slice.recoveredG selected hB o bW hb e v r β y ≤ + (1 + δ) * (κ * slice.retainedRecoveredG selected hB o bW hb e cutoff v + (reduced cutoff r) β y) := by + exact mul_relative_bounds hκ + (slice.recoveredG_retained_comparison selected hB o bW hb e hm hD cutoff + hcutoff hsmall hδ haccuracy v r β y) + +end ActualFixedSpatialSlicedForecastPath +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ActualMarkedSlowKernelCells.lean b/lean/OAI/Combinatorics/Progressions/Linear/ActualMarkedSlowKernelCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..142c625c2e0511faac0e03e29d7035ccaa3c7c0f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ActualMarkedSlowKernelCells.lean @@ -0,0 +1,532 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformParameterNet +import OAI.Combinatorics.Progressions.Polynomial.MarkedPolynomialSectionSlow +import OAI.Combinatorics.Progressions.Polynomial.PolynomialGridValues + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem exists_bounded_subgroup_net + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) {H : ℕ} + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (K : Subgroup (NilpotentLieBCHGroup L s hnil)) + (B : ℝ≥0) (hB : 1 ≤ B) {N : ℕ} (hN : 0 < N) : + let := rightMetricSpace (hnil := hnil) e + ∃ center : (ι → Fin (N + 1)) → NilpotentLieBCHGroup L s hnil, + (∀ j, center j ∈ K) ∧ + (∀ j i, |e.repr (center j).coord i| ≤ B) ∧ + ∀ g : NilpotentLieBCHGroup L s hnil, g ∈ K → + (∀ i, |e.repr g.coord i| ≤ B) → + ∃ j, dist g (center j) ≤ + bchBoxMetricConstant s (Fintype.card ι) H B * (4 * B / N) := by + classical + let := rightMetricSpace (hnil := hnil) e + let Ω := {g : NilpotentLieBCHGroup L s hnil // + g ∈ K ∧ ∀ i, |e.repr g.coord i| ≤ B} + have hBr : (1 : ℝ) ≤ B := hB + let : Nonempty Ω := ⟨⟨1, K.one_mem, by simp⟩⟩ + obtain ⟨code, rep, hrep⟩ := exists_uniform_parameter_net + (fun g : Ω => e.equivFun g.val.coord) (by positivity : (0 : ℝ) < B) + (fun g i => g.property.2 i) hN + refine ⟨fun j => (rep j).val, fun j => (rep j).property.1, + fun j i => (rep j).property.2 i, ?_⟩ + intro g hg hgb + let x : Ω := ⟨g, hg, hgb⟩ + refine ⟨code x, ?_⟩ + apply dist_le_bchBoxMetricConstant e c hstructure hc B hB (by positivity) + g (rep (code x)).val hgb (rep (code x)).property.2 + intro i + exact (show |e.repr g.coord i - e.repr (rep (code x)).val.coord i| ≤ + dist (e.equivFun x.val.coord) (e.equivFun (rep (code x)).val.coord) from + by simpa only [Real.dist_eq, Basis.equivFun_apply, x] using + dist_le_pi_dist (e.equivFun x.val.coord) + (e.equivFun (rep (code x)).val.coord) i).trans (hrep x) + +theorem exists_bounded_kernel_net {G : Type*} [Group G] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) {H : ℕ} + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (π : NilpotentLieBCHGroup L s hnil →* G) + (B : ℝ≥0) (hB : 1 ≤ B) {N : ℕ} (hN : 0 < N) : + let := rightMetricSpace (hnil := hnil) e + ∃ center : (ι → Fin (N + 1)) → NilpotentLieBCHGroup L s hnil, + (∀ j, π (center j) = 1) ∧ + (∀ j i, |e.repr (center j).coord i| ≤ B) ∧ + ∀ g : NilpotentLieBCHGroup L s hnil, π g = 1 → + (∀ i, |e.repr g.coord i| ≤ B) → + ∃ j, dist g (center j) ≤ + bchBoxMetricConstant s (Fintype.card ι) H B * (4 * B / N) := by + exact exists_bounded_subgroup_net e c hstructure hc π.ker B hB hN + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [DecidableEq ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem exists_bounded_kernel_net_with_budget {G : Type*} [Group G] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) {H : ℕ} + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (π : NilpotentLieBCHGroup L s hnil →* G) + (B : ℝ≥0) (hB : 1 ≤ B) {ε p : ℝ} (hε : 0 < ε) (hp : 0 ≤ p) + (hd : (Fintype.card ι : ℝ) ≤ p) (hBp : (B : ℝ) ≤ Real.exp p) + (hK : (bchBoxMetricConstant s (Fintype.card ι) H B : ℝ) ≤ Real.exp p) + (hεinv : 1 / ε ≤ Real.exp p) : + letI := rightMetricSpace (hnil := hnil) e + ∃ N : ℕ, 0 < N ∧ + (Fintype.card (ι → Fin (N + 1)) : ℝ) ≤ + Real.exp ((p + 1) * (3 * (p + 1) + 4)) ∧ + ∃ center : (ι → Fin (N + 1)) → NilpotentLieBCHGroup L s hnil, + (∀ j, π (center j) = 1) ∧ + (∀ j i, |e.repr (center j).coord i| ≤ B) ∧ + ∀ g : NilpotentLieBCHGroup L s hnil, π g = 1 → + (∀ i, |e.repr g.coord i| ≤ B) → + ∃ j, dist g (center j) ≤ ε := by + classical + let := rightMetricSpace (hnil := hnil) e + let K := bchBoxMetricConstant s (Fintype.card ι) H B + let N := boxCoverMeshCount (2 * B) K ε + have hN : 0 < N := boxCoverMeshCount_pos _ _ _ + have hexp : Real.exp p ≤ Real.exp (p + 1) := Real.exp_le_exp.mpr (by linarith) + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hBp' : 2 * (B : ℝ) ≤ Real.exp (p + 1) := by + rw [Real.exp_add] + exact (mul_le_mul_of_nonneg_left hBp (by norm_num)).trans + (by nlinarith [Real.exp_pos p]) + have hcard := boxCoverCount_dimension_bound (Fintype.card ι) K + (by positivity : 0 ≤ 2 * (B : ℝ)) hε (by linarith : 0 ≤ p + 1) + (by linarith : (Fintype.card ι : ℝ) ≤ p + 1) hBp' (hK.trans hexp) + (hεinv.trans hexp) + obtain ⟨center, hmark, hbound, hnet⟩ := + exists_bounded_kernel_net e c hstructure hc π B hB hN + refine ⟨N, hN, ?_, center, hmark, hbound, ?_⟩ + · simpa only [Fintype.card_fun, Fintype.card_fin] using hcard + · intro g hg hgb + obtain ⟨j, hj⟩ := hnet g hg hgb + refine ⟨j, hj.trans ?_⟩ + have hm := boxCoverMeshCount_error (B := 2 * (B : ℝ)) K hε + dsimp only [N, K] at * + simpa only [show (2 : ℝ) * (2 * B) = 4 * B by ring] using hm + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 +open scoped NNReal + +theorem exists_slow_kernel_net_geometry_budget (s r : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (d n H : ℕ) (p A : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (n : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + 0 ≤ A → A ≤ Real.exp ((p + 2) ^ r) → + ∃ B : ℝ≥0, 1 ≤ B ∧ + ((s : ℝ) + 1) * ((n : ℝ) + 1) ^ s * A ≤ B ∧ + (B : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (bchBoxMetricConstant s d H B : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (bchBoxMetricConstant s d H B : ℝ) * + (((s : ℝ) + 1) * ((n : ℝ) + 1) ^ s * A * n * s) ≤ + Real.exp ((p + C) ^ C) := by + let X : Polynomial ℕ := Polynomial.X + let P := Polynomial.C s * (X + 1) + (X + 2) ^ r + obtain ⟨a, _, hP⟩ := exists_natPolynomial_eval_budget P + obtain ⟨b, _, hbox⟩ := exists_bchBoxMetricConstant_exp_bound s a + let Q := (X + Polynomial.C a + Polynomial.C b) ^ b + P + X + Polynomial.C s + obtain ⟨C, hC, hQ⟩ := exists_natPolynomial_eval_budget Q + refine ⟨C, hC, ?_⟩ + intro d n H p A hp hd hn hH hA hAp + let q : ℝ := s * (p + 1) + (p + 2) ^ r + have hq : 0 ≤ q := by dsimp [q]; positivity + let B : ℝ≥0 := ⟨Real.exp q, (Real.exp_pos _).le⟩ + have hB : 1 ≤ B := Real.one_le_exp hq + have hn1 : (n : ℝ) + 1 ≤ Real.exp p := by linarith [Real.add_one_le_exp p] + have hAM : ((s : ℝ) + 1) * ((n : ℝ) + 1) ^ s * A ≤ Real.exp q := by + calc + _ ≤ Real.exp s * (Real.exp p) ^ s * Real.exp ((p + 2) ^ r) := + mul_le_mul (mul_le_mul (Real.add_one_le_exp (s : ℝ)) + (pow_le_pow_left₀ (by positivity) hn1 _) (by positivity) (Real.exp_pos _).le) + hAp hA (by positivity) + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add] + congr 1 + dsimp [q] + ring + have hpA : p ≤ p + a := le_add_of_nonneg_right (Nat.cast_nonneg _) + have hBa : (B : ℝ) ≤ Real.exp (((p + a) + 2) ^ a) := by + apply Real.exp_le_exp.mpr + have h' : q ≤ (p + a) ^ a := by simpa [P, X, q, Polynomial.eval₂_pow] using hP p hp + exact h'.trans (pow_le_pow_left₀ (by positivity) (by linarith) _) + have hBC : (bchBoxMetricConstant s d H B : ℝ) ≤ Real.exp ((p + a + b) ^ b) := + hbox d H B (p + a) (hp.trans hpA) (hd.trans hpA) + (hH.trans (Real.exp_le_exp.mpr hpA)) hBa + have hfinal : (p + a + b) ^ b + q + p + s ≤ (p + C) ^ C := by + simpa [Q, P, X, q, Polynomial.eval₂_pow] using hQ p hp + have hbase : 0 ≤ (p + a + b) ^ b := by positivity + have hnexp : (n : ℝ) ≤ Real.exp p := by linarith [Real.add_one_le_exp p] + have hsexp : (s : ℝ) ≤ Real.exp s := by linarith [Real.add_one_le_exp (s : ℝ)] + refine ⟨B, hB, hAM, Real.exp_le_exp.mpr (by linarith), + hBC.trans (Real.exp_le_exp.mpr (by linarith)), ?_⟩ + calc + _ ≤ Real.exp ((p + a + b) ^ b) * (Real.exp q * Real.exp p * Real.exp s) := by + apply mul_le_mul hBC + (mul_le_mul (mul_le_mul hAM hnexp (Nat.cast_nonneg _) (Real.exp_pos _).le) + hsexp (Nat.cast_nonneg _) (by positivity)) + (by positivity) (Real.exp_pos _).le + _ = Real.exp (((p + a + b) ^ b) + q + p + s) := by + rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := Real.exp_le_exp.mpr hfinal + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {σ ι L G : Type*} [Fintype σ] [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] [_root_.Group G] {s : ℕ} + +theorem exists_slow_kernel_freezing_net + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : σ → ℕ) + (hw : ∀ i, 0 < w i) (π : F.realification.Group →* G) + (H : ℕ) (hc : ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) + (T : σ → ℝ) (hT : ∀ i, 0 < T i) {A : ℝ} (hA : 0 ≤ A) + (B : ℝ≥0) (hB : 1 ≤ B) + (hAB : ((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * A ≤ B) + {N : ℕ} (hN : 0 < N) : + letI := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + ∃ center : (ι → Fin (N + 1)) → F.realification.Group, + (∀ j, π (center j) = 1) ∧ + (∀ j i, |(b.baseChange ℝ).repr (center j).coord i| ≤ B) ∧ + ∀ g : (F.realification.adaptedPolynomialFiltration w).Group, + F.PolynomialSlowBound b w T A g → + (∀ z, π (F.adaptedPolynomialRealValueHom w z g) = 1) → + ∀ z : σ → ℝ, (∀ i, |z i| ≤ T i) → + ∃ j, ∀ (v : σ → ℝ) (δ : ℝ), 0 ≤ δ → + (∀ i, |v i| ≤ T i) → (∀ i, |v i - z i| ≤ T i * δ) → + dist (F.adaptedPolynomialRealValueHom w v g) (center j) ≤ + bchBoxMetricConstant s (Fintype.card ι) H B * + ((((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * A * + Fintype.card σ * s) * δ + 4 * B / N) := by + let := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + obtain ⟨center, hmark, hbound, hnet⟩ := exists_bounded_kernel_net + (b.baseChange ℝ) (lieStructureConstants b) + (fun i j k => (realLieBasis_structure b i j k).symm) hc π B hB hN + refine ⟨center, hmark, hbound, ?_⟩ + intro g hg hker z hz + obtain ⟨j, hj⟩ := hnet (F.adaptedPolynomialRealValueHom w z g) (hker z) + (fun i => (F.polynomialSlowBound_value b w hw T hT hA g hg z hz i).trans hAB) + refine ⟨j, ?_⟩ + intro v δ hδ hv hvz + have hmove := F.polynomialSlowBound_dist_le b w hw H hc T hT hA hδ B hB hAB + g hg v z hv hz hvz + calc + _ ≤ dist (F.adaptedPolynomialRealValueHom w v g) + (F.adaptedPolynomialRealValueHom w z g) + + dist (F.adaptedPolynomialRealValueHom w z g) (center j) := dist_triangle _ _ _ + _ ≤ _ := by nlinarith [hmove, hj] + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {σ ι L G : Type*} [Fintype σ] [DecidableEq σ] [Fintype ι] [DecidableEq ι] + [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] [_root_.Group G] {s : ℕ} + +theorem exists_slow_kernel_cells + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : σ → ℕ) + (hw : ∀ i, 0 < w i) (π : F.realification.Group →* G) + (H : ℕ) (hc : ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) + (T : σ → ℝ) (hT : ∀ i, 0 < T i) {A : ℝ} (hA : 0 ≤ A) + (B : ℝ≥0) (hB : 1 ≤ B) + (hAB : ((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * A ≤ B) + {ε p : ℝ} (hε : 0 < ε) (hp : 0 ≤ p) + (hd : (Fintype.card ι : ℝ) ≤ p) (hn : (Fintype.card σ : ℝ) ≤ p) + (hBp : (B : ℝ) ≤ Real.exp p) + (hK : (bchBoxMetricConstant s (Fintype.card ι) H B : ℝ) ≤ Real.exp p) + (hmove : (bchBoxMetricConstant s (Fintype.card ι) H B : ℝ) * + (((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * A * Fintype.card σ * s) ≤ + Real.exp p) + (hεinv : 1 / ε ≤ Real.exp p) : + letI := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + ∃ N M : ℕ, 0 < N ∧ 0 < M ∧ + (Fintype.card (ι → Fin (N + 1)) : ℝ) ≤ Real.exp ((p + 2) * (3 * (p + 2) + 4)) ∧ + (Fintype.card (σ → Fin (M + 1)) : ℝ) ≤ Real.exp ((p + 1) * (3 * (p + 1) + 4)) ∧ + ∃ center : (ι → Fin (N + 1)) → F.realification.Group, + (∀ j, π (center j) = 1) ∧ + (∀ j i, |(b.baseChange ℝ).repr (center j).coord i| ≤ B) ∧ + ∀ g : (F.realification.adaptedPolynomialFiltration w).Group, + F.PolynomialSlowBound b w T A g → + (∀ z, π (F.adaptedPolynomialRealValueHom w z g) = 1) → + ∃ label : (σ → Fin (M + 1)) → (ι → Fin (N + 1)), + ∀ j (v : σ → ℝ), (∀ i, |v i| ≤ T i) → + (∀ i, |v i - normalizedRealBoxGrid T M j i| ≤ T i * (2 / M)) → + dist (F.adaptedPolynomialRealValueHom w v g) (center (label j)) ≤ ε := by + classical + let := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + have hhalf : 0 < ε / 2 := by positivity + have hexp : Real.exp p ≤ Real.exp (p + 1) := Real.exp_le_exp.mpr (by linarith) + have hinv : 1 / (ε / 2) ≤ Real.exp (p + 1) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ = 2 * (1 / ε) := by ring + _ ≤ 2 * Real.exp p := mul_le_mul_of_nonneg_left hεinv (by norm_num) + _ ≤ Real.exp 1 * Real.exp p := mul_le_mul_of_nonneg_right htwo (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, add_comm] + obtain ⟨N, hN, hNcard, center, hmark, hbound, hnet⟩ := + exists_bounded_kernel_net_with_budget (b.baseChange ℝ) (lieStructureConstants b) + (fun i j k => (realLieBasis_structure b i j k).symm) hc π B hB hhalf + (by linarith : 0 ≤ p + 1) (by linarith : (Fintype.card ι : ℝ) ≤ p + 1) + (hBp.trans hexp) (hK.trans hexp) hinv + let K : ℝ≥0 := ⟨(bchBoxMetricConstant s (Fintype.card ι) H B : ℝ) * + (((s : ℝ) + 1) * ((Fintype.card σ : ℝ) + 1) ^ s * A * Fintype.card σ * s), + by positivity⟩ + let M := boxCoverMeshCount 1 K (ε / 2) + have hM : 0 < M := boxCoverMeshCount_pos _ _ _ + have hMcard := boxCoverCount_dimension_bound (Fintype.card σ) K + (by norm_num : (0 : ℝ) ≤ 1) hhalf (by linarith : 0 ≤ p + 1) + (by linarith : (Fintype.card σ : ℝ) ≤ p + 1) + (Real.one_le_exp (by linarith)) (hmove.trans hexp) hinv + refine ⟨N, M, hN, hM, ?_, ?_, center, hmark, hbound, ?_⟩ + · simpa only [add_assoc, one_add_one_eq_two] using hNcard + · simpa only [Fintype.card_fun, Fintype.card_fin] using hMcard + · intro g hg hker + have hz (j : σ → Fin (M + 1)) (i : σ) : + |normalizedRealBoxGrid T M j i| ≤ T i := normalizedRealBoxGrid_bound T hT hM j i + choose label hlabel using fun j : σ → Fin (M + 1) => + hnet (F.adaptedPolynomialRealValueHom w (normalizedRealBoxGrid T M j) g) + (hker _) (fun i => + (F.polynomialSlowBound_value b w hw T hT hA g hg _ (hz j) i).trans hAB) + refine ⟨label, ?_⟩ + intro j v hv hvz + have hm := F.polynomialSlowBound_dist_le b w hw H hc T hT hA + (by positivity : (0 : ℝ) ≤ 2 / M) B hB hAB g hg v + (normalizedRealBoxGrid T M j) hv (hz j) hvz + have herr : dist (F.adaptedPolynomialRealValueHom w v g) + (F.adaptedPolynomialRealValueHom w (normalizedRealBoxGrid T M j) g) ≤ ε / 2 := by + apply hm.trans + have he := boxCoverMeshCount_error (B := (1 : ℝ)) K hhalf + change (K : ℝ) * (2 / (M : ℝ)) ≤ ε / 2 + simpa only [mul_one] using he + calc + _ ≤ dist (F.adaptedPolynomialRealValueHom w v g) + (F.adaptedPolynomialRealValueHom w (normalizedRealBoxGrid T M j) g) + + dist (F.adaptedPolynomialRealValueHom w (normalizedRealBoxGrid T M j) g) + (center (label j)) := dist_triangle _ _ _ + _ ≤ ε / 2 + ε / 2 := add_le_add herr (hlabel j) + _ = ε := by ring + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +theorem exists_uniform_slow_kernel_cells (s r : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ ι L G : Type*} + [Fintype σ] [DecidableEq σ] [Fintype ι] [DecidableEq ι] + [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] [_root_.Group G] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : σ → ℕ), + (∀ i, 0 < w i) → ∀ (π : F.realification.Group →* G) (H : ℕ) (p : ℝ), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (Fintype.card σ : ℝ) ≤ p → + (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) → + ∀ T : σ → ℝ, (∀ i, 0 < T i) → + letI := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + ∃ N M : ℕ, 0 < N ∧ 0 < M ∧ + (Fintype.card (ι → Fin (N + 1)) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (Fintype.card (σ → Fin (M + 1)) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ center : (ι → Fin (N + 1)) → F.realification.Group, + (∀ j, π (center j) = 1) ∧ + (∀ j i, |(b.baseChange ℝ).repr (center j).coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + ∀ g : (F.realification.adaptedPolynomialFiltration w).Group, + F.PolynomialSlowBound b w T (Real.exp ((p + 2) ^ r)) g → + (∀ z, π (F.adaptedPolynomialRealValueHom w z g) = 1) → + ∃ label : (σ → Fin (M + 1)) → (ι → Fin (N + 1)), + ∀ j (v : σ → ℝ), (∀ i, |v i| ≤ T i) → + (∀ i, |v i - normalizedRealBoxGrid T M j i| ≤ T i * (2 / M)) → + dist (F.adaptedPolynomialRealValueHom w v g) (center (label j)) ≤ + Real.exp (-((p + 2) ^ r)) := by + obtain ⟨a, ha, hgeometry⟩ := exists_slow_kernel_net_geometry_budget s r + let X : Polynomial ℕ := Polynomial.X + let Q := X + (X + Polynomial.C a) ^ a + (X + 2) ^ r + let P := Q + (Q + 2) * (3 * (Q + 2) + 4) + obtain ⟨C, hC, hP⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ ι L G _ _ _ _ _ _ _ _ _ _ _ F b w hw π H p hp hd hn hH hc T hT + let := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + obtain ⟨B, hB, hAB, hBcap, hK, hmove⟩ := hgeometry + (Fintype.card ι) (Fintype.card σ) H p (Real.exp ((p + 2) ^ r)) + hp hd hn hH (Real.exp_nonneg _) le_rfl + let q : ℝ := p + (p + a) ^ a + (p + 2) ^ r + have hq : 0 ≤ q := by dsimp [q]; positivity + have ha0 : 0 ≤ (p + a) ^ a := by positivity + have hr0 : 0 ≤ (p + 2) ^ r := by positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have haq : (p + a) ^ a ≤ q := by dsimp [q]; linarith + have hrq : (p + 2) ^ r ≤ q := by dsimp [q]; linarith + have hinv : 1 / Real.exp (-((p + 2) ^ r)) ≤ Real.exp q := by + rw [Real.exp_neg] + simpa only [one_div, inv_inv] using Real.exp_le_exp.mpr hrq + obtain ⟨N, M, hN, hM, hNcard, hMcard, center, hmark, hbound, hfreeze⟩ := + F.exists_slow_kernel_cells b w hw π H hc T hT (Real.exp_nonneg _) B hB hAB + (Real.exp_pos _) hq (hd.trans hpq) (hn.trans hpq) + (hBcap.trans (Real.exp_le_exp.mpr haq)) + (hK.trans (Real.exp_le_exp.mpr haq)) + (hmove.trans (Real.exp_le_exp.mpr haq)) hinv + have hbudget : q + (q + 2) * (3 * (q + 2) + 4) ≤ (p + C) ^ C := by + simpa [P, Q, X, q, Polynomial.eval₂_pow] using hP p hp + have hcard : (q + 2) * (3 * (q + 2) + 4) ≤ (p + C) ^ C := by linarith + have hqcap : q ≤ (p + C) ^ C := by + have : 0 ≤ (q + 2) * (3 * (q + 2) + 4) := by positivity + linarith + refine ⟨N, M, hN, hM, hNcard.trans (Real.exp_le_exp.mpr hcard), + hMcard.trans (Real.exp_le_exp.mpr ?_), center, hmark, ?_, hfreeze⟩ + · exact (show (q + 1) * (3 * (q + 1) + 4) ≤ (q + 2) * (3 * (q + 2) + 4) by + nlinarith).trans hcard + · intro j i + exact (hbound j i).trans (hBcap.trans (Real.exp_le_exp.mpr (haq.trans hqcap))) + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +theorem exists_actual_marked_slow_kernel_cells (s a u : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ ι κ L M : Type*} + [Fintype σ] [DecidableEq σ] [Fintype ι] [DecidableEq ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (b : Basis ι ℚ L) (c : Basis κ ℚ M) (ω : ι → ℕ), + (∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) → + ∀ (w : σ → ℕ), (∀ i, 0 < w i) → + ∀ (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + (S : M →ₗ[ℚ] L) (hS : ∀ j, ∀ y ∈ G.layer j, S y ∈ F.layer j), + Function.RightInverse S φ → + ∀ (H : ℕ) (p : ℝ), 1 ≤ H → 0 ≤ p → + (Fintype.card ι : ℝ) ≤ p → (Fintype.card κ : ℝ) ≤ p → + (Fintype.card σ : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) → + (∀ i j, |(b.repr (S (c j)) i : ℝ)| ≤ Real.exp ((p + 2) ^ a)) → + ∀ T : σ → ℝ, (∀ i, 0 < T i) → + letI := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + ∃ N Q : ℕ, 0 < N ∧ 0 < Q ∧ + (Fintype.card (ι → Fin (N + 1)) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (Fintype.card (σ → Fin (Q + 1)) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ center : (ι → Fin (N + 1)) → F.realification.Group, + (∀ j, realificationMap (hnil := F.lowerCentralSeries_eq_bot) + (hM := G.lowerCentralSeries_eq_bot) φ (center j) = 1) ∧ + (∀ j i, |(b.baseChange ℝ).repr (center j).coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + ∀ (E : (F.realification.adaptedPolynomialFiltration w).Group) + (EF : (G.realification.adaptedPolynomialFiltration w).Group), + F.PolynomialSlowBound b w T (Real.exp ((p + 2) ^ a)) E → + G.PolynomialSlowBound c w T (Real.exp ((p + 2) ^ a)) EF → + F.realPolynomialGroupMap G φ hφ w E = EF → + ∃ label : (σ → Fin (Q + 1)) → (ι → Fin (N + 1)), + ∀ j (v : σ → ℝ), (∀ i, |v i| ≤ T i) → + (∀ i, |v i - normalizedRealBoxGrid T Q j i| ≤ T i * (2 / Q)) → + dist (F.adaptedPolynomialRealValueHom w v + (E * (F.filteredRealPolynomialSection G w S hS EF)⁻¹)) + (center (label j)) ≤ Real.exp (-((p + 2) ^ u)) := by + obtain ⟨A, hA, hslow⟩ := exists_marked_polynomial_kernel_slow_bound s a + obtain ⟨B, hB, hnet⟩ := exists_uniform_slow_kernel_cells s (A + u) + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((Polynomial.X + Polynomial.C A + Polynomial.C B) ^ B) + refine ⟨C, hC, ?_⟩ + intro σ ι κ L M _ _ _ _ _ _ _ _ _ _ _ _ _ t F G b c ω hF w hw φ hφ S hS + hsection H p hH hp hι hκ hσ hHp hc hSbound T hT + let := rightMetricSpace (hnil := F.realification.lowerCentralSeries_eq_bot) (b.baseChange ℝ) + let π := realificationMap (hnil := F.lowerCentralSeries_eq_bot) + (hM := G.lowerCentralSeries_eq_bot) φ + have hpA : p ≤ p + A := le_add_of_nonneg_right (Nat.cast_nonneg _) + have hpA0 : 0 ≤ p + A := hp.trans hpA + obtain ⟨N, Q, hN, hQ, hNcard, hQcard, center, hmark, hcap, hfreeze⟩ := + hnet F b w hw π H (p + A) hpA0 (hι.trans hpA) (hσ.trans hpA) + (hHp.trans (Real.exp_le_exp.mpr hpA)) hc T hT + have hcost : (p + A + B) ^ B ≤ (p + C) ^ C := by + simpa [Polynomial.eval₂_pow] using hbudget p hp + refine ⟨N, Q, hN, hQ, hNcard.trans (Real.exp_le_exp.mpr hcost), + hQcard.trans (Real.exp_le_exp.mpr hcost), center, hmark, + fun j i => (hcap j i).trans (Real.exp_le_exp.mpr hcost), ?_⟩ + intro E EF hE hEF hproj + have hKE := (hslow F G b c ω hF w hw H p hH hp hι hκ hσ hHp hc S hS + (by simpa only [scalarExtension_basis_coordinates] using hSbound) T hT E EF hE hEF).1 + have hbound : (p + A) ^ A ≤ (p + A + 2) ^ (A + u) := + (pow_le_pow_left₀ hpA0 (by linarith : p + A ≤ p + A + 2) A).trans + (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + A + 2) (by omega)) + have hKEslow := F.polynomialSlowBound_mono b w T hT + (Real.exp_le_exp.mpr hbound) _ hKE + have hmap : F.realPolynomialGroupMap G φ hφ w + (E * (F.filteredRealPolynomialSection G w S hS EF)⁻¹) = 1 := by + rw [map_mul, map_inv, hproj, + F.realPolynomialGroupMap_filteredSection G w φ hφ S hS hsection EF, mul_inv_cancel] + have hker (v : σ → ℝ) : π (F.adaptedPolynomialRealValueHom w v + (E * (F.filteredRealPolynomialSection G w S hS EF)⁻¹)) = 1 := by + rw [← F.realPolynomialGroupMap_value G φ hφ w, hmap, map_one] + obtain ⟨label, hlabel⟩ := hfreeze _ hKEslow hker + refine ⟨label, ?_⟩ + intro j v hv hvj + apply (hlabel j v hv hvj).trans + apply Real.exp_le_exp.mpr + apply neg_le_neg + exact (pow_le_pow_left₀ (by linarith : (0 : ℝ) ≤ p + 2) + (by linarith : p + 2 ≤ p + A + 2) u).trans + (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + A + 2) (by omega)) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ActualOrdinaryPointwiseSpanning.lean b/lean/OAI/Combinatorics/Progressions/Linear/ActualOrdinaryPointwiseSpanning.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a7f9e60f46a7b65d62aa431bf85a5af6b7318a9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ActualOrdinaryPointwiseSpanning.lean @@ -0,0 +1,341 @@ +import OAI.Combinatorics.Progressions.Estimates.BoundedSubmoduleIntersection +import OAI.Combinatorics.Progressions.Estimates.StrongRefiltrationReconstruction + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι κ L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (f : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (f '' {i | j ≤ ν i})) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +theorem associatedGradedMap_basis_logHeight {p : ℝ} (hp : 0 ≤ p) + (hφH : ∀ i j, rationalLogHeight (f.repr (φ (e i)) j) ≤ p) (i : ι) (j : κ) : + rationalLogHeight ((G.associatedGradedBasis f ν hG).repr + (F.associatedGradedMap G φ hφ (F.associatedGradedBasis e ω hF i)) j) ≤ p := by + classical + rw [F.associatedGradedMap_basis_repr G e ω hF f ν hG φ hφ] + split_ifs + · exact hφH i j + · simpa [rationalLogHeight] using hp + +theorem exists_associatedGradedMap_comap_bounded_spanning [Fintype ι] [Fintype κ] + (U : LieSubalgebra ℚ G.AssociatedGraded) (v : κ → G.AssociatedGraded) + (hv : Submodule.span ℚ (Set.range v) = U.toSubmodule) + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hvH : ∀ a j, rationalLogHeight ((G.associatedGradedBasis f ν hG).repr (v a) j) ≤ p) + (hφH : ∀ i j, rationalLogHeight (f.repr (φ (e i)) j) ≤ p) : + ∃ u : ι → F.AssociatedGraded, + Submodule.span ℚ (Set.range u) = + (U.comap (F.associatedGradedMap G φ hφ)).toSubmodule ∧ + ∀ a i, rationalLogHeight ((F.associatedGradedBasis e ω hF).repr (u a) i) ≤ + preimageBasisBudget p + 1 := by + classical + let eA := F.associatedGradedBasis e ω hF + let fA := G.associatedGradedBasis f ν hG + let T := (F.associatedGradedMap G φ hφ).toLinearMap + let K := U.toSubmodule.comap T + have heH (a i : ι) : rationalLogHeight (eA.repr (eA a) i) ≤ p := by + rw [Basis.repr_self, Finsupp.single_apply] + split_ifs <;> simpa [rationalLogHeight] using hp + obtain ⟨b, hb⟩ := exists_preimage_basis_logHeight eA fA ⊤ U.toSubmodule T eA v + eA.span_eq hv hp hκ hι hκ heH hvH + (F.associatedGradedMap_basis_logHeight G e ω hF f ν hG φ hφ hp hφH) + have hspan : Submodule.span ℚ (Set.range (fun a => (b a : F.AssociatedGraded))) = K := by + change Submodule.span ℚ (Set.range ((⊤ ⊓ K).subtype ∘ b)) = K + rw [Set.range_comp, ← Submodule.map_span, b.span_eq, Submodule.map_top, + Submodule.range_subtype, top_inf_eq] + obtain ⟨z, hz, hzH⟩ := exists_bounded_submodule_ambient_spanning eA K + (fun a => (b a : F.AssociatedGraded)) hspan (one_le_ceil_exp (preimageBasisBudget p)) + (fun a i => rationalHeightLE_ceil_exp (hb a i)) + refine ⟨fun a => z (Fintype.equivFin ι a), ?_, fun a i => ?_⟩ + · change Submodule.span ℚ (Set.range (z ∘ Fintype.equivFin ι)) = K + rw [Set.range_comp, (Fintype.equivFin ι).surjective.range_eq, Set.image_univ] + exact hz + · exact rationalLogHeight_le_of_height (hzH _ i) + (ceil_exp_le_exp_add_one (preimageBasisBudget_nonneg hp)) + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι κ γ L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +noncomputable def gradedImageSpanningFamily (v : γ → F.AssociatedGraded) : + γ → G.AssociatedGraded := fun a => F.associatedGradedMap G φ hφ (v a) + +theorem gradedImageSpanningFamily_span (W : LieSubalgebra ℚ F.AssociatedGraded) + (v : γ → F.AssociatedGraded) (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) : + Submodule.span ℚ (Set.range (F.gradedImageSpanningFamily G φ hφ v)) = + (W.map (F.associatedGradedMap G φ hφ)).toSubmodule := by + change Submodule.span ℚ (Set.range ((F.associatedGradedMap G φ hφ).toLinearMap ∘ v)) = + W.toSubmodule.map (F.associatedGradedMap G φ hφ).toLinearMap + rw [Set.range_comp, ← Submodule.map_span, hv] + +variable (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (c : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + +theorem gradedImageSpanningFamily_logHeight [Fintype ι] + (v : γ → F.AssociatedGraded) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) + (hvH : ∀ a i, rationalLogHeight ((F.associatedGradedBasis e ω hF).repr (v a) i) ≤ p) + (hφH : ∀ i j, rationalLogHeight (c.repr (φ (e i)) j) ≤ p) (a : γ) (j : κ) : + rationalLogHeight ((G.associatedGradedBasis c ν hG).repr + (F.gradedImageSpanningFamily G φ hφ v a) j) ≤ (p + 2) ^ 4 := by + exact linearMap_coordinate_logHeight (F.associatedGradedBasis e ω hF) + (G.associatedGradedBasis c ν hG) (F.associatedGradedMap G φ hφ).toLinearMap hp hι + (F.associatedGradedMap_basis_logHeight G e ω hF c ν hG φ hφ hp hφH) (v a) (hvH a) j + +theorem gradedImage_bounded_spanning [Fintype ι] + (W : LieSubalgebra ℚ F.AssociatedGraded) (v : γ → F.AssociatedGraded) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) + (hW : BasisGradedSubmodule (F.associatedGradedBasis e ω hF) ω W.toSubmodule) + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hvH : ∀ a i, rationalLogHeight ((F.associatedGradedBasis e ω hF).repr (v a) i) ≤ p) + (hφH : ∀ i j, rationalLogHeight (c.repr (φ (e i)) j) ≤ p) : + Submodule.span ℚ (Set.range (F.gradedImageSpanningFamily G φ hφ v)) = + (W.map (F.associatedGradedMap G φ hφ)).toSubmodule ∧ + BasisGradedSubmodule (G.associatedGradedBasis c ν hG) ν + (W.map (F.associatedGradedMap G φ hφ)).toSubmodule ∧ + ∀ a j, rationalLogHeight ((G.associatedGradedBasis c ν hG).repr + (F.gradedImageSpanningFamily G φ hφ v a) j) ≤ (p + 2) ^ 4 := by + exact ⟨F.gradedImageSpanningFamily_span G φ hφ W v hv, + F.associatedGradedMap_image_graded G e ω hF c ν hG φ hφ W hW, + F.gradedImageSpanningFamily_logHeight G φ hφ e ω hF c ν hG v hp hι hvH hφH⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +theorem gradedImagePointwiseSpanning_heightBound {p : ℝ} (hp : 0 ≤ p) : + (⌈Real.exp ((p + 2) ^ 4)⌉₊ : ℝ) ≤ Real.exp ((p + 2) ^ 5) := by + apply (ceil_exp_le_exp_add_one (by positivity : 0 ≤ (p + 2) ^ 4)).trans + apply Real.exp_le_exp.mpr + have hpow : 1 ≤ (p + 2) ^ 4 := one_le_pow₀ (by linarith) + calc + (p + 2) ^ 4 + 1 ≤ (p + 2) ^ 4 + (p + 2) ^ 4 := by linarith only [hpow] + _ = (p + 2) ^ 4 * 2 := by ring + _ ≤ (p + 2) ^ 4 * (p + 2) := + mul_le_mul_of_nonneg_left (by linarith : 2 ≤ p + 2) (by positivity) + _ = (p + 2) ^ 5 := by ring + +theorem pointwiseSpanningIndex_card_le + {σ κ γ M : Type*} [Fintype σ] [Fintype κ] [Fintype γ] + [LieRing M] [LieAlgebra ℚ M] {t : ℕ} + (G : NilpotentLieFiltration M t) (c : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + (w : σ → ℕ) (hw : ∀ i, 0 < w i) [Fintype (SymbolBasisIndex w ν)] + {p : ℝ} (hp : 0 ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hγ : (Fintype.card γ : ℝ) ≤ p) (hσ : (Fintype.card σ : ℝ) ≤ p) : + (Fintype.card (SymbolBasisIndex w ν × γ) : ℝ) ≤ pointwiseFastSectionInput t p := + (G.pointwiseSymbolSpanning_section_counts (ξ := γ) G c ν hG c ν hG w hw + hp hκ hκ hγ hσ).1 + +variable {σ ι κ γ L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + (c : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + (w : σ → ℕ) + +noncomputable def gradedImagePointwiseSpanningFamily (v : γ → F.AssociatedGraded) : + SymbolBasisIndex w ν × γ → G.PolynomialSymbol w := + G.pointwiseSymbolSpanningFamily c ν hG w (F.gradedImageSpanningFamily G φ hφ v) + +variable (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +theorem gradedImagePointwiseSpanningFamily_span [Fintype (SymbolBasisIndex w ν)] + (W : LieSubalgebra ℚ F.AssociatedGraded) (v : γ → F.AssociatedGraded) + (hW : BasisGradedSubmodule (F.associatedGradedBasis e ω hF) ω W.toSubmodule) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) : + Submodule.span ℚ (Set.range + (F.gradedImagePointwiseSpanningFamily G φ hφ c ν hG w v)) = + (G.symbolPointwiseSubalgebra c ν hG w + (W.map (F.associatedGradedMap G φ hφ))).toSubmodule := by + exact G.pointwiseSymbolSpanningFamily_span c ν hG w + (W.map (F.associatedGradedMap G φ hφ)) + (F.associatedGradedMap_image_graded G e ω hF c ν hG φ hφ W hW) + (F.gradedImageSpanningFamily G φ hφ v) + (F.gradedImageSpanningFamily_span G φ hφ W v hv) + +theorem gradedImagePointwiseSpanningFamily_height [Fintype ι] + (v : γ → F.AssociatedGraded) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) + (hvH : ∀ a i, rationalLogHeight + ((F.associatedGradedBasis e ω hF).repr (v a) i) ≤ p) + (hφH : ∀ i j, rationalLogHeight (c.repr (φ (e i)) j) ≤ p) : + ∀ z i, RationalHeightLE ((G.polynomialSymbolBasis c ν hG w).repr + (F.gradedImagePointwiseSpanningFamily G φ hφ c ν hG w v z) i) + ⌈Real.exp ((p + 2) ^ 4)⌉₊ := by + exact G.pointwiseSymbolSpanningFamily_height c ν hG w + (F.gradedImageSpanningFamily G φ hφ v) (one_le_ceil_exp _) + (fun a j => rationalHeightLE_ceil_exp + (F.gradedImageSpanningFamily_logHeight G φ hφ e ω hF c ν hG v hp hι hvH hφH a j)) + +theorem gradedImagePointwiseSpanningFamily_controlled + [Fintype σ] [Fintype ι] [Fintype κ] [Fintype γ] + [Fintype (SymbolBasisIndex w ν)] + (W : LieSubalgebra ℚ F.AssociatedGraded) (v : γ → F.AssociatedGraded) + (hW : BasisGradedSubmodule (F.associatedGradedBasis e ω hF) ω W.toSubmodule) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) + (hw : ∀ i, 0 < w i) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hγ : (Fintype.card γ : ℝ) ≤ p) (hσ : (Fintype.card σ : ℝ) ≤ p) + (hvH : ∀ a i, rationalLogHeight + ((F.associatedGradedBasis e ω hF).repr (v a) i) ≤ p) + (hφH : ∀ i j, rationalLogHeight (c.repr (φ (e i)) j) ≤ p) : + Submodule.span ℚ (Set.range + (F.gradedImagePointwiseSpanningFamily G φ hφ c ν hG w v)) = + (G.symbolPointwiseSubalgebra c ν hG w + (W.map (F.associatedGradedMap G φ hφ))).toSubmodule ∧ + BasisGradedSubmodule (G.associatedGradedBasis c ν hG) ν + (W.map (F.associatedGradedMap G φ hφ)).toSubmodule ∧ + (∀ z i, RationalHeightLE ((G.polynomialSymbolBasis c ν hG w).repr + (F.gradedImagePointwiseSpanningFamily G φ hφ c ν hG w v z) i) + ⌈Real.exp ((p + 2) ^ 4)⌉₊) ∧ + (Fintype.card (SymbolBasisIndex w ν × γ) : ℝ) ≤ pointwiseFastSectionInput t p ∧ + 1 ≤ ⌈Real.exp ((p + 2) ^ 4)⌉₊ ∧ + (⌈Real.exp ((p + 2) ^ 4)⌉₊ : ℝ) ≤ Real.exp ((p + 2) ^ 5) := by + exact ⟨F.gradedImagePointwiseSpanningFamily_span G φ hφ c ν hG w e ω hF W v hW hv, + F.associatedGradedMap_image_graded G e ω hF c ν hG φ hφ W hW, + F.gradedImagePointwiseSpanningFamily_height G φ hφ c ν hG w e ω hF v hp hι hvH hφH, + G.pointwiseSpanningIndex_card_le c ν hG w hw hp hκ hγ hσ, + one_le_ceil_exp _, gradedImagePointwiseSpanning_heightBound hp⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +noncomputable def ordinaryImagePointwiseBudget (s t : ℕ) (p : ℝ) : ℝ := + pointwiseFastSectionInput s p + pointwiseFastSectionInput t p + (p + 2) ^ 5 + +private theorem sectionInput_nonneg (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ pointwiseFastSectionInput s p := by + unfold pointwiseFastSectionInput + positivity + +theorem ordinaryImagePointwiseBudget_source (s t : ℕ) {p : ℝ} (hp : 0 ≤ p) : + pointwiseFastSectionInput s p ≤ ordinaryImagePointwiseBudget s t p := by + have ht := sectionInput_nonneg t hp + have hh : 0 ≤ (p + 2) ^ 5 := by positivity + unfold ordinaryImagePointwiseBudget + linarith + +theorem ordinaryImagePointwiseBudget_target (s t : ℕ) {p : ℝ} (hp : 0 ≤ p) : + pointwiseFastSectionInput t p ≤ ordinaryImagePointwiseBudget s t p := by + have hs := sectionInput_nonneg s hp + have hh : 0 ≤ (p + 2) ^ 5 := by positivity + unfold ordinaryImagePointwiseBudget + linarith + +theorem ordinaryImagePointwiseBudget_height (s t : ℕ) {p : ℝ} (hp : 0 ≤ p) : + (p + 2) ^ 5 ≤ ordinaryImagePointwiseBudget s t p := by + have hs := sectionInput_nonneg s hp + have ht := sectionInput_nonneg t hp + unfold ordinaryImagePointwiseBudget + linarith + +theorem ordinaryImagePointwiseBudget_ge (s t : ℕ) {p : ℝ} (hp : 0 ≤ p) : + p ≤ ordinaryImagePointwiseBudget s t p := + (pointwiseFastSectionInput_ge s hp).trans (ordinaryImagePointwiseBudget_source s t hp) + +private theorem symbolCount_le_sectionInput (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + (p + (s + 3)) ^ (s + 3) ≤ pointwiseFastSectionInput s p := by + have h : 0 ≤ (p + (s + 3)) ^ (s + 3) := by positivity + unfold pointwiseFastSectionInput + nlinarith [sq_nonneg ((p + (s + 3)) ^ (s + 3))] + +variable {σ ι κ γ L M : Type*} [Fintype σ] [Fintype ι] [Fintype κ] [Fintype γ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (c : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + +theorem ordinaryGradedImagePointwiseSpanning_controlled + (W : LieSubalgebra ℚ F.AssociatedGraded) (v : γ → F.AssociatedGraded) + (hW : BasisGradedSubmodule (F.associatedGradedBasis b ω hF) ω W.toSubmodule) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) + {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hγ : (Fintype.card γ : ℝ) ≤ p) (hσ : (Fintype.card σ : ℝ) ≤ p) + (hvH : ∀ a i, rationalLogHeight + ((F.associatedGradedBasis b ω hF).repr (v a) i) ≤ p) + (hφH : ∀ i j, rationalLogHeight (c.repr (φ (b i)) j) ≤ p) : + let vg := F.gradedImagePointwiseSpanningFamily G φ hφ c ν hG (fun _ : σ => 1) v + Submodule.span ℚ (Set.range vg) = + (G.symbolPointwiseSubalgebra c ν hG (fun _ : σ => 1) + (W.map (F.associatedGradedMap G φ hφ))).toSubmodule ∧ + BasisGradedSubmodule (G.associatedGradedBasis c ν hG) ν + (W.map (F.associatedGradedMap G φ hφ)).toSubmodule ∧ + (∀ z i, RationalHeightLE ((G.polynomialSymbolBasis c ν hG (fun _ : σ => 1)).repr + (vg z) i) ⌈Real.exp ((p + 2) ^ 4)⌉₊) ∧ + (Nat.card (SymbolBasisIndex (fun _ : σ => 1) ω) : ℝ) ≤ ordinaryImagePointwiseBudget s t p ∧ + (Nat.card (SymbolBasisIndex (fun _ : σ => 1) ν) : ℝ) ≤ ordinaryImagePointwiseBudget s t p ∧ + (Nat.card (SymbolBasisIndex (fun _ : σ => 1) ν × γ) : ℝ) ≤ ordinaryImagePointwiseBudget s t p ∧ + 1 ≤ ⌈Real.exp ((p + 2) ^ 4)⌉₊ ∧ + (⌈Real.exp ((p + 2) ^ 4)⌉₊ : ℝ) ≤ Real.exp (ordinaryImagePointwiseBudget s t p) := by + let : Fintype (SymbolBasisIndex (fun _ : σ => 1) ω) := + F.ordinarySymbolBasisFintype b ω hF + let : Fintype (SymbolBasisIndex (fun _ : σ => 1) ν) := + G.ordinarySymbolBasisFintype c ν hG + obtain ⟨hspan, hgraded, hheight, hcount, hH, hHexp⟩ := + F.gradedImagePointwiseSpanningFamily_controlled G φ hφ c ν hG (fun _ : σ => 1) + b ω hF W v hW hv (fun _ => Nat.zero_lt_one) hp hι hκ hγ hσ hvH hφH + refine ⟨hspan, hgraded, hheight, ?_, ?_, ?_, hH, ?_⟩ + · have hsource := F.symbolBasisIndex_card_le_spanning_budget b ω hF + (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) hp hι hσ + simpa only [Nat.card_eq_fintype_card] using + (hsource.trans (symbolCount_le_sectionInput s hp)).trans + (ordinaryImagePointwiseBudget_source s t hp) + · have htarget := G.symbolBasisIndex_card_le_spanning_budget c ν hG + (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) hp hκ hσ + simpa only [Nat.card_eq_fintype_card] using + (htarget.trans (symbolCount_le_sectionInput t hp)).trans + (ordinaryImagePointwiseBudget_target s t hp) + · simpa only [Nat.card_eq_fintype_card] using + hcount.trans (ordinaryImagePointwiseBudget_target s t hp) + · exact hHexp.trans (Real.exp_le_exp.mpr (ordinaryImagePointwiseBudget_height s t hp)) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AdaptedBasisGeometry.lean b/lean/OAI/Combinatorics/Progressions/Linear/AdaptedBasisGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..2322d395cd9be6f1c5be2229162da6aca9eb0ab3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AdaptedBasisGeometry.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.Progressions.Linear.BoundedAdaptedBasis +import OAI.Combinatorics.Progressions.Nilpotent.BCHOuterGridChangeBasis + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {ι κ L : Type*} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + +theorem inverse_basis_entries_height (e : Basis ι ℚ L) (b : Basis κ ℚ L) + {H : ℕ} (hH : 1 ≤ H) (hb : ∀ j i, RationalHeightLE (e.repr (b j) i) H) : + ∀ i j, RationalHeightLE (b.repr (e i) j) (rationalSolveHeight (Fintype.card κ) H) := by + classical + let A := LinearMap.toMatrix b e (LinearMap.id : L →ₗ[ℚ] L) + let C := LinearMap.toMatrix e b (LinearMap.id : L →ₗ[ℚ] L) + have hA : ∀ i j, RationalHeightLE (A i j) H := by + intro i j + dsimp only [A] + rw [LinearMap.toMatrix_apply] + exact hb j i + have hli : LinearIndependent ℚ A.col := + Matrix.mulVec_injective_iff.mp (basisMatrix_injective b e LinearMap.id Function.injective_id) + obtain ⟨P, hPA, hPH⟩ := exists_bounded_rational_left_inverse A hli hH hA + have hAC : A * C = 1 := by + dsimp only [A, C] + rw [← LinearMap.toMatrix_comp, LinearMap.id_comp, LinearMap.toMatrix_id] + have hPC : P = C := by + calc + P = P * 1 := (Matrix.mul_one P).symm + _ = P * (A * C) := by rw [hAC] + _ = (P * A) * C := (Matrix.mul_assoc P A C).symm + _ = C := by rw [hPA, Matrix.one_mul] + intro i j + have h := hPH j i + rw [hPC] at h + simpa only [C, LinearMap.toMatrix_apply, LinearMap.id_apply] using h + +theorem basis_change_structure_height (e : Basis ι ℚ L) (b : Basis κ ℚ L) + {H : ℕ} (hH : 1 ≤ H) (hb : ∀ j i, RationalHeightLE (e.repr (b j) i) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) : + ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) + (rationalLieStructureHeight (Fintype.card ι) (max H (rationalSolveHeight (Fintype.card κ) H))) := by + classical + obtain ⟨_, _, _, h⟩ := exists_bounded_lie_embedding_retraction b e + (LieHom.id : L →ₗ⁅ℚ⁆ L) Function.injective_id hH hc (by + intro i j + rw [LinearMap.toMatrix_apply] + exact hb j i) + exact h + +theorem exists_basis_change_grid_exp_bound (e : Basis ι ℚ L) (b : Basis κ ℚ L) + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l) + (hb : ∀ j i, RationalHeightLE (e.repr (b j) i) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) (hr : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p) : + ∃ N : ℕ, 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b Γ ∧ + bchSubgroupCoordinates b Γ ⊆ denominatorGrid N := by + classical + have hid : NilpotentLieBCHGroup.map (hnil := hnil) (hM := hnil) + (LieHom.id : L →ₗ⁅ℚ⁆ L) = MonoidHom.id _ := by + ext g + rfl + simpa only [hid, Subgroup.comap_id] using exists_bchSubgroup_comap_grid_exp_bound + (hM := hnil) b e (LieHom.id : L →ₗ⁅ℚ⁆ L) Function.injective_id Γ hH hl + (by intro i j; rw [LinearMap.toMatrix_apply]; exact hb j i) + hinner houter hp hd hr hHp hlp + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} (F : NilpotentLieFiltration L s) (e : Basis ι ℚ L) + +theorem exists_adapted_basis_and_grid {η : Fin (s + 1) → Type*} + (v : ∀ i, η i → F.layer (i.val + 1)) + (hspan : ∀ i, Submodule.span ℚ (Set.range (v i)) = ⊤) + (Γ : Subgroup F.Group) {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l) + (hv : ∀ i j k, RationalHeightLE (e.repr (v i j : L) k) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p) : + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ) (N : ℕ), + Monotone w ∧ IsCentralLieBasis b ∧ + (∀ i, F.layer i = Submodule.span ℚ (b '' {j | i ≤ w j})) ∧ + (∀ j i, RationalHeightLE (e.repr (b j) i) H) ∧ + (∀ i j, RationalHeightLE (b.repr (e i) j) (rationalSolveHeight (finrank ℚ L) H)) ∧ + (∀ i j k, ((lieStructureConstants b i j k).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 11) ∧ + ((lieStructureConstants b i j k).den : ℝ) ≤ Real.exp ((p + 2) ^ 11)) ∧ + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b Γ ∧ + bchSubgroupCoordinates b Γ ⊆ denominatorGrid N := by + obtain ⟨b, w, hw, _, hcentral, hb, hlayer⟩ := F.exists_bounded_sorted_adapted_basis e v hspan hv + have hr : (Fintype.card (Fin (finrank ℚ L)) : ℝ) ≤ p := by + simpa only [Fintype.card_fin, finrank_eq_card_basis e] using hd + obtain ⟨N, hN, hNp, hin, hout⟩ := + exists_basis_change_grid_exp_bound e b Γ hH hl hb hinner houter hp hd hr hHp hlp + have hbinv := inverse_basis_entries_height e b hH hb + have hstructure := basis_change_structure_height e b hH hb hc + have hbudget := rationalLieStructureHeight_inverse_budget (Fintype.card ι) + (Fintype.card (Fin (finrank ℚ L))) H hp hd hr hHp + refine ⟨b, w, N, hw, hcentral, hlayer, hb, ?_, ?_, hN, hNp, hin, hout⟩ + · simpa only [Fintype.card_fin] using hbinv + · intro i j k + exact ⟨(Nat.cast_le.mpr (hstructure i j k).1).trans hbudget, + (Nat.cast_le.mpr (hstructure i j k).2).trans hbudget⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AdaptedRankCorrelation.lean b/lean/OAI/Combinatorics/Progressions/Linear/AdaptedRankCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ac762f4a0dcdc2ac8cf2031a3b8474088c73fd5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AdaptedRankCorrelation.lean @@ -0,0 +1,181 @@ +import OAI.Combinatorics.Progressions.Estimates.RebasedUnitVerticalObservable + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module +open scoped TensorProduct NNReal + +theorem exists_controlled_rank_rebase : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure r) {p : ℝ}, + 0 ≤ p → R.ComplexityLE p → ∃ (F : R.AdaptedData) (H : ℕ) + (_hH : ∀ i j, RationalHeightLE (D.basis.repr (F.basis i) j) H), + p ≤ (p + C) ^ C ∧ F.rank.ComplexityLE ((p + C) ^ C) ∧ + (∀ K : ℝ≥0, (K : ℝ) ≤ Real.exp p → + (K * coordinateLipschitzBound d (finrank ℚ L) H : ℝ) ≤ Real.exp ((p + C) ^ C)) ∧ + ∀ eta : L →ₗ[ℚ] ℚ, (∀ i, rationalLogHeight (eta (D.basis i)) ≤ p) → + ∀ j, rationalLogHeight (eta (F.basis j)) ≤ (p + C) ^ C := by + let X : Polynomial ℕ := Polynomial.X + let P := (X + 3) ^ 11 + X + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (P + (P + 2) ^ 2 + (X + 3) ^ 4 + X) + refine ⟨C, hC, ?_⟩ + intro L _ _ s d r _ _ _ _ D R p hp hR + obtain ⟨F, hF, hb, _⟩ := R.exists_rank_adapted_data hp hR + let H := ⌈Real.exp (p + 1)⌉₊ + have hH (i j) : RationalHeightLE (D.basis.repr (F.basis i) j) H := + rationalHeightLE_ceil_exp (hb i j) + let q := (p + 3) ^ 11 + p + 2 + have hpow : 0 ≤ (p + 3) ^ 11 := by positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have hfq : (p + 3) ^ 11 ≤ q := by dsimp [q]; linarith + have hq : 0 ≤ q := hp.trans hpq + have hHq : (H : ℝ) ≤ Real.exp q := + (ceil_exp_le_exp_add_one (by linarith : 0 ≤ p + 1)).trans + (Real.exp_le_exp.mpr (by dsimp [q]; linarith)) + have hcost : q + (q + 2) ^ 2 + (p + 3) ^ 4 + p ≤ (p + C) ^ C := by + simpa [P, X, q, Polynomial.eval₂_pow] using hbudget p hp + have hfreq0 : 0 ≤ (p + 3) ^ 4 := by positivity + have hcomp : q + (q + 2) ^ 2 ≤ (p + C) ^ C := by linarith + have hqC : q ≤ (p + C) ^ C := (le_add_of_nonneg_right (sq_nonneg _)).trans hcomp + have hfreq : (p + 3) ^ 4 ≤ (p + C) ^ C := by nlinarith [sq_nonneg (q + 2)] + have hgeom : F.model.GeometryComplexityLE q := hF.1.mono F.model hfq + refine ⟨F, H, hH, hpq.trans hqC, hF.mono F.rank (hfq.trans hqC), ?_, ?_⟩ + · intro K hK + have hcoord := coordinateLipschitzBound_le_exp d (finrank ℚ L) (H : ℝ≥0) hq + (hR.1.1.trans hpq) hgeom.1 hHq + calc + (K * coordinateLipschitzBound d (finrank ℚ L) H : ℝ) ≤ + Real.exp q * Real.exp ((q + 2) ^ 2) := + mul_le_mul (hK.trans (Real.exp_le_exp.mpr hpq)) hcoord (by positivity) (Real.exp_nonneg _) + _ = Real.exp (q + (q + 2) ^ 2) := (Real.exp_add _ _).symm + _ ≤ Real.exp ((p + C) ^ C) := Real.exp_le_exp.mpr hcomp + · intro eta heta j + have hdim : (Fintype.card (Fin d) : ℝ) ≤ p + 1 := by + simpa only [Fintype.card_fin] using hR.1.1.trans (show p ≤ p + 1 by linarith) + have hval := rational_functional_value_logHeight D.basis eta + (by linarith : 0 ≤ p + 1) hdim (fun i => (heta i).trans (by linarith : p ≤ p + 1)) + (F.basis j) (hb j) + apply le_trans _ hfreq + simpa only [show p + 1 + 2 = p + 3 by ring] using hval + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.NativeDegreeRankFamily + +open Module +open scoped NNReal + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +variable {s r : ℕ} {A : Type*} {p q : ℝ} (W : NativeDegreeRankFamily s r A p) + +def AdaptedCoordinates : Prop := IsCentralLieBasis W.model.basis ∧ + ∀ i j, ∃ c ≤ W.dim, W.rank.filtration.layer i j = basisTail W.model.basis c + +noncomputable def rebase (F : W.rank.AdaptedData) (H : ℕ) + (hH : ∀ i j, RationalHeightLE (W.model.basis.repr (F.basis i) j) H) + (hpq : p ≤ q) (hRank : F.rank.ComplexityLE q) + (hLip : (W.vertical.lipBound * coordinateLipschitzBound W.dim (finrank ℚ W.L) H : ℝ) ≤ Real.exp q) + (hFreq : ∀ i, rationalLogHeight (W.vertical.frequency (F.basis i)) ≤ q) : + NativeDegreeRankFamily s r A q where + L := W.L + dim := finrank ℚ W.L + model := F.model + rank := F.rank + complexity := hRank + orbit := W.orbit + normalized := W.normalized + outputDim := W.outputDim + output_pos := W.output_pos + output_bound := W.output_bound.trans (Real.exp_le_exp.mpr hpq) + vertical := W.vertical.rebase F.toAdaptedModelData H hH hLip hFreq + +theorem rebase_eval (F : W.rank.AdaptedData) (H : ℕ) + (hH : ∀ i j, RationalHeightLE (W.model.basis.repr (F.basis i) j) H) + (hpq : p ≤ q) (hRank : F.rank.ComplexityLE q) + (hLip : (W.vertical.lipBound * coordinateLipschitzBound W.dim (finrank ℚ W.L) H : ℝ) ≤ Real.exp q) + (hFreq : ∀ i, rationalLogHeight (W.vertical.frequency (F.basis i)) ≤ q) + (i : Fin W.outputDim) (a : A) (n : ℤ) : + (W.rebase F H hH hpq hRank hLip hFreq).eval i a n = W.eval i a n := rfl + +theorem rebase_adapted (F : W.rank.AdaptedData) (H : ℕ) + (hH : ∀ i j, RationalHeightLE (W.model.basis.repr (F.basis i) j) H) + (hpq : p ≤ q) (hRank : F.rank.ComplexityLE q) + (hLip : (W.vertical.lipBound * coordinateLipschitzBound W.dim (finrank ℚ W.L) H : ℝ) ≤ Real.exp q) + (hFreq : ∀ i, rationalLogHeight (W.vertical.frequency (F.basis i)) ≤ q) : + (W.rebase F H hH hpq hRank hLip hFreq).AdaptedCoordinates := + ⟨F.central, F.rank_layers⟩ + +end Erdos3.NativeDegreeRankFamily + +end + +section + +namespace Erdos3 + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +theorem exists_adapted_rank_family : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {s r : ℕ} {A : Type*} {p : ℝ} (W : NativeDegreeRankFamily s r A p), + ∃ (V : NativeDegreeRankFamily s r A ((p + C) ^ C)) (hdim : V.outputDim = W.outputDim), + V.AdaptedCoordinates ∧ + ∀ i a n, V.eval i a n = W.eval (Fin.cast hdim i) a n := by + obtain ⟨C, hC, hbase⟩ := RationalFilteredNilmanifold.DegreeRankStructure.exists_controlled_rank_rebase + refine ⟨C, hC, ?_⟩ + intro s r A p W + have hp : 0 ≤ p := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + obtain ⟨F, H, hH, hpq, hRank, hLip, hFreq⟩ := hbase W.rank hp W.complexity + let V := W.rebase F H hH hpq hRank (hLip W.vertical.lipBound W.vertical.lip_bound) + (hFreq W.vertical.frequency W.vertical.height) + refine ⟨V, rfl, ?_, ?_⟩ + · exact W.rebase_adapted F H hH hpq hRank _ _ + · intro i a n + rfl + +theorem exists_adapted_correlation_structure : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {s r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f), + ∃ V : NativeCorrelationStructure s r N ((p + C) ^ C) f, + V.family.AdaptedCoordinates ∧ V.shifts = W.shifts := by + obtain ⟨C, hC, hbase⟩ := RationalFilteredNilmanifold.DegreeRankStructure.exists_controlled_rank_rebase + refine ⟨C, hC, ?_⟩ + intro s r N _ p f W + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + obtain ⟨F, H, hH, hpq, hRank, hLip, hFreq⟩ := hbase W.family.rank hp W.family.complexity + let family := W.family.rebase F H hH hpq hRank + (hLip W.family.vertical.lipBound W.family.vertical.lip_bound) + (hFreq W.family.vertical.frequency W.family.vertical.height) + let V : NativeCorrelationStructure s r N ((p + C) ^ C) f := { + shifts := W.shifts + nonempty := W.nonempty + density := (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hpq)) + (Nat.cast_nonneg _)).trans W.density + mixed := W.mixed.mono hpq + family := family + correlation := by + intro h hh + obtain ⟨U⟩ := W.correlation h hh + exact ⟨U.mono hpq⟩ + } + exact ⟨V, W.family.rebase_adapted F H hH hpq hRank _ _, rfl⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedAveragedCoarseKernelComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedAveragedCoarseKernelComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..df41721a824bf1bcc231464398d545b137823d99 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedAveragedCoarseKernelComparison.lean @@ -0,0 +1,865 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedTestUniformCoarseJointComparison + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem character_root_power_cancel_le {a C : ℝ} (ha : 1 ≤ a) (hC : 0 ≤ C) + {n k : ℕ} (hn : 0 < n) (hk : n * (n + 2) ≤ k) : + a ^ n * (C / a ^ (1 / (n : ℝ))) ^ k ≤ C ^ k / a ^ 2 := by + have ha0 : 0 < a := by linarith + have hr0 : 0 < a ^ (1 / (n : ℝ)) := Real.rpow_pos_of_pos ha0 _ + have hr1 : 1 ≤ a ^ (1 / (n : ℝ)) := + Real.one_le_rpow ha (by positivity) + have hi1 : 1 / a ^ (1 / (n : ℝ)) ≤ 1 := by + apply (div_le_iff₀ hr0).mpr + simpa using hr1 + have hpow := pow_le_pow_of_le_one (le_of_lt (one_div_pos.mpr hr0)) hi1 hk + calc + _ = C ^ k * (a ^ n * (1 / a ^ (1 / (n : ℝ))) ^ k) := by + rw [div_eq_mul_one_div, mul_pow] + ring + _ ≤ C ^ k * (a ^ n * (1 / a ^ (1 / (n : ℝ))) ^ (n * (n + 2))) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hpow (pow_nonneg ha0.le _)) + (pow_nonneg hC _) + _ = C ^ k / a ^ 2 := by + rw [character_root_power_cancel a 1 ha0 n hn] + simp only [one_pow] + ring + +theorem finite_character_reciprocal_tail_of_le (B R n k : ℕ) + (hB : 0 < B) (hn : 0 < n) (hk : n * (n + 2) ≤ k) + (C : ℝ) (hC : 0 ≤ C) : + (∑ a : Fin R, if B < a.val + 1 then + ((a.val + 1 : ℕ) : ℝ) ^ n * + (C / ((a.val + 1 : ℕ) : ℝ) ^ (1 / (n : ℝ))) ^ k else 0) ≤ + C ^ k / (B : ℝ) := by + calc + _ ≤ C ^ k * ∑ a : Fin R, + if B < a.val + 1 then 1 / ((a.val + 1 : ℕ) : ℝ) ^ 2 else 0 := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro a _ + split_ifs with h + · simpa only [one_div, div_eq_mul_inv, one_mul] using + character_root_power_cancel_le (a := ((a.val + 1 : ℕ) : ℝ)) + (by exact_mod_cast Nat.succ_le_succ (Nat.zero_le a.val)) hC hn hk + · simp + _ ≤ C ^ k / (B : ℝ) := by + rw [div_eq_mul_one_div] + exact mul_le_mul_of_nonneg_left (finite_positiveOrder_reciprocal_tail B R hB) + (pow_nonneg hC _) + +theorem largeCokernel_reciprocal_probability_le_of_card_le {I J : Type*} + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + {Ω : J → Type*} [∀ j, Fintype (Ω j)] + (p : ∀ j, FiniteProbabilityWeights (Ω j)) (column : ∀ j, Ω j → I → ℤ) + (B R : ℕ) (hB : 0 < B) (C : ℝ) (hC : 0 ≤ C) + (hJ : Fintype.card I * (Fintype.card I + 2) ≤ Fintype.card J) + (hsingle : ∀ (a : ℕ), B < a → a ≤ R → ∀ χ : AddChar (I → ℤ) ℂ, + orderOf χ = a → ∀ j, (p j).eventProbability (fun x => χ (column j x) = 1) ≤ + C / (a : ℝ) ^ (1 / (Fintype.card I : ℝ))) : + (FiniteProbabilityWeights.pi p).eventProbability (largeCokernelEvent column B R) ≤ + C ^ Fintype.card J / (B : ℝ) := by + have h := largeCokernel_probability_le p column B R + (fun a => C / (a : ℝ) ^ (1 / (Fintype.card I : ℝ))) + (fun a => div_nonneg hC (Real.rpow_nonneg (Nat.cast_nonneg a) _)) hsingle + exact h.trans (finite_character_reciprocal_tail_of_le B R (Fintype.card I) (Fintype.card J) + hB Fintype.card_pos hJ C hC) + +theorem boxCokernel_probability_le_of_card_le {I J K : Type*} + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + [Fintype K] [DecidableEq K] + (e : I → K) (he : Function.Injective e) (lo hi : J → ℤ) (hlen : ∀ j, lo j < hi j) + (p : ∀ j, FiniteProbabilityWeights (K → Finset.Ico (lo j) (hi j))) + (B R : ℕ) (hB : 0 < B) (C D : ℝ) (hC : 0 ≤ C) (hD : 0 ≤ D) + (hJ : Fintype.card I * (Fintype.card I + 2) ≤ Fintype.card J) + (hw : ∀ j x, (p j).weight x ≤ + C * (Fintype.card (K → Finset.Ico (lo j) (hi j)) : ℝ)⁻¹) + (hscale : ∀ j, (R : ℝ) ^ (1 / (Fintype.card I : ℝ)) ≤ + D * ((hi j - lo j : ℤ) : ℝ)) : + (FiniteProbabilityWeights.pi p).eventProbability + (largeCokernelEvent (fun _j x i => (x (e i) : ℤ)) B R) ≤ + (C * (1 + D)) ^ Fintype.card J / (B : ℝ) := by + apply largeCokernel_reciprocal_probability_le_of_card_le p _ B R hB (C * (1 + D)) + (mul_nonneg hC (by positivity)) hJ + intro a haB haR χ hχ j + have ha : 0 < a := by omega + have hχpos : 0 < orderOf χ := by omega + have h := integerBox_character_probability_le e he (lo j) (hi j) (hlen j) + (p j) C hC (hw j) χ hχpos + rw [hχ] at h + apply h.trans + apply reciprocal_interval_error_absorb _ _ C D + (Real.rpow_pos_of_pos (by exact_mod_cast ha) _) (by exact_mod_cast sub_pos.mpr (hlen j)) hC + exact (Real.rpow_le_rpow (Nat.cast_nonneg a) (by exact_mod_cast haR) (by positivity)).trans + (hscale j) + +theorem scalarCube_largeCokernel_probability_le_of_card_le {I J : Type*} + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (L B : ℕ) (hL : 0 < L) (hsize : Fintype.card I + 1 ≤ L) (hB : 0 < B) + (hJ : Fintype.card I * (Fintype.card I + 2) ≤ Fintype.card J) : + (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (scalarCubeLargeCokernelEvent B) ≤ + (integerScalarCubeDensityCap I * (1 + ((Fintype.card I).factorial : ℝ))) ^ + Fintype.card J / (B : ℝ) := by + let R := (Fintype.card I).factorial * L ^ Fintype.card I + have hbound := boxCokernel_probability_le_of_card_le + (I := I) (J := J) (K := Option I) Option.some (Option.some_injective I) + (fun _ => -(L : ℤ)) (fun _ => (L : ℤ)) (fun _ => by omega) + (fun _ => integerScalarCubeWeights I L hL) B R hB + (integerScalarCubeDensityCap I) ((Fintype.card I).factorial : ℝ) + (integerScalarCubeDensityCap_pos I).le (Nat.cast_nonneg _) hJ + (fun _ x => integerScalarCubeWeights_weight_le I L hL hsize x) (fun _ => ?_) + · apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans hbound + intro x hx + apply nonzeroMinor_largeCokernelEvent _ x B L _ hx.1 hx.2 + intro i j + have h := Finset.mem_Ico.mp (x j (some i)).property + have ha : |(x j (some i) : ℤ)| ≤ (L : ℤ) := abs_le.mpr ⟨h.1, h.2.le⟩ + have hn : (((x j (some i) : ℤ).natAbs : ℕ) : ℤ) ≤ (L : ℤ) := by + simpa only [Int.natCast_natAbs] using ha + exact_mod_cast hn + · have h := nat_monomial_root_le (Fintype.card I) (Fintype.card I).factorial L + Fintype.card_pos (Nat.factorial_pos _) + apply h.trans + push_cast + nlinarith [show (0 : ℝ) ≤ (Fintype.card I).factorial from Nat.cast_nonneg _] + +theorem scalarKernel_explicit_probability_le_of_card_le (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card I * (Fintype.card I + 2) ≤ Fintype.card J) (s : I ↪ J) + {M D L : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) (hL : 0 < L) + (hlarge : scalarKernelCutoff I J M D η ≤ L) : + (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ)) + (scalarKernelCutoff I J M D η) x) ≤ scalarKernelAdjustedAccuracy I J M D η := by + let B := scalarKernelCutoff I J M D η + let κ := scalarKernelThreshold I J M D η + let ε := scalarKernelAdjustedAccuracy I J M D η + obtain ⟨hB, hsize, _, hinv, hmesh, htail⟩ := scalarKernelCutoff_bounds I J hM hD hη + have hB' : (0 : ℝ) < B := by exact_mod_cast hB + have hL' : (0 : ℝ) < L := by exact_mod_cast hL + have hκ : 0 < κ := scalarKernelThreshold_pos I J hM hD hη + have hε : 0 < ε := scalarKernelAdjustedAccuracy_pos I J hM hD hη + have hsizeL : Fintype.card I + 1 ≤ L := hsize.trans hlarge + have hsmall : 1 / (B : ℝ) ≤ κ := by + apply (div_le_iff₀ hB').mpr + have h := (div_le_iff₀ hκ).mp hinv + nlinarith + have hmeshL : coordinateDeterminantVariation I (Fin (Fintype.card (J × Option I))) / L ≤ κ := by + apply (div_le_iff₀ hL').mpr + have hBL : (scalarKernelCutoff I J M D η : ℝ) ≤ (L : ℝ) := by exact_mod_cast hlarge + have h := (div_le_iff₀ hκ).mp (hmesh.trans hBL) + nlinarith + have htailB : scalarKernelTailConstant I J / B ≤ ε / 2 := by + apply (div_le_iff₀ hB').mpr + have h := (div_le_iff₀ hε).mp htail + nlinarith + have hJpos : 0 < Fintype.card J := by + exact lt_of_lt_of_le (Nat.mul_pos Fintype.card_pos (by omega)) hJ + have hN : 0 < Fintype.card (J × Option I) := by + rw [Fintype.card_prod, Fintype.card_option] + exact Nat.mul_pos hJpos (by omega) + have hreal := discrete_minor_threshold_probability (Fintype.equivFin (J × Option I)) hN + s s.injective L hL hsizeL ε hε hmeshL + have hminor : (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => |normalizedScalarCubeMinor s x| ≤ 1 / (B : ℝ)) ≤ ε / 2 := by + apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans hreal + intro x hx + exact hx.trans hsmall + have hcoker := scalarCube_largeCokernel_probability_le_of_card_le (I := I) (J := J) L B hL hsizeL hB hJ + apply (scalarKernel_bad_event_le _ s (1 / (B : ℝ)) B (one_div_pos.mpr hB')).trans + exact (add_le_add hminor (hcoker.trans htailB)).trans_eq (by ring) + +theorem affineKernel_explicit_probability_le_of_card_le (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card I * (Fintype.card I + 2) ≤ Fintype.card J) (s : I ↪ J) + {M D L : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) (hL : 0 < L) + (hlarge : scalarKernelCutoff I J M D η ≤ L) (K : J → ℕ) + (hKL : ∀ j, K j ≤ L) (hDK : ∀ j, L ≤ D * K j) (c : J → ℤ) + (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i)) + (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M) : + (FiniteProbabilityWeights.pi (fun j => + affineScalarCubeWindowWeights I L (K j) M D (c j) hL (hKL j) (hDK j) + (m j) (r j) (hm j) (hmM j) (scalarKernelCutoff_window_size I J hM hD hη hlarge (hDK j)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ)) + (scalarKernelCutoff I J M D η) x) ≤ η := by + let C := scalarKernelConditioningConstant I J M D + have hC : 0 < C := scalarKernelConditioningConstant_pos I J hM hD + have h := scalarCubeWindow_pi_eventProbability_le I J L M D K hL hKL hDK m + (fun j => shiftScalarCubeResidues (c j) (m j) (r j)) hm hmM + (fun j => scalarKernelCutoff_window_size I J hM hD hη hlarge (hDK j)) + (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ)) + (scalarKernelCutoff I J M D η) x) + apply h.trans + calc + _ ≤ C * scalarKernelAdjustedAccuracy I J M D η := mul_le_mul_of_nonneg_left + (scalarKernel_explicit_probability_le_of_card_le I J hJ s hM hD hη hL hlarge) hC.le + _ = η := by + change C * (η / C) = η + field_simp + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem allocatedTupleEnvelope_ge_input (m : ℕ) {D p e : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (he : 0 ≤ e) : + p ≤ allocatedTupleEnvelope m D p e := by + have hd := allocatedDensityEnvelope_nonneg m hD hp + let R := (D + 1) ^ 2 + 4 * D + 3 + have hR : 0 ≤ R := by dsimp [R]; positivity + have hrest : 0 ≤ R + D + D + + (D * ((m * 2 ^ (m + 1) : ℕ) * p + allocatedDensityEnvelope m D p) + + R + D + allocatedDensityEnvelope m D p + 1) + (e + 2) + 1 := by positivity + have hmp : p ≤ ((m : ℝ) + 1) * p := by + nlinarith [mul_nonneg (Nat.cast_nonneg m) hp] + dsimp only [allocatedTupleEnvelope] + dsimp only [R] at hrest + linarith + +theorem allocatedPhysicalIdealLengthEnvelope_ge_input (m : ℕ) {D p e w E : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (he : 0 ≤ e) (hw : 0 ≤ w) (hE : 0 ≤ E) : + p ≤ allocatedPhysicalIdealLengthEnvelope m D p e w E := by + have hd := allocatedDensityEnvelope_nonneg m hD hp + have hi := kernelInverseEnvelope_nonneg hD hp + have ht := allocatedTestEnvelope_nonneg m hD hp (show 0 ≤ E + 3 by positivity) + have hf : 0 ≤ allocatedFrontEnvelope m D p + (allocatedAccuracyEnvelope m D p (allocatedTestEnvelope m D p (E + 3))) := by + dsimp only [allocatedFrontEnvelope, allocatedKernelEnvelope, allocatedAccuracyEnvelope] + positivity + have hmf : 0 ≤ (m : ℝ) * allocatedFrontEnvelope m D p + (allocatedAccuracyEnvelope m D p (allocatedTestEnvelope m D p (E + 3))) := + mul_nonneg (Nat.cast_nonneg _) hf + have htuple := allocatedTupleEnvelope_ge_input m hD hp ht + have hg := allocatedIdealGridEnvelope_nonneg m hD hp he + have hmesh : 0 ≤ E + D * w + allocatedIdealMeshEnvelope m D p e + 3 := by + unfold allocatedIdealMeshEnvelope + positivity + dsimp only [allocatedPhysicalIdealLengthEnvelope, allocatedTestLengthEnvelope, allocatedJointLengthEnvelope] + linarith + +theorem scalarKernelCutoff_le_allocatedPrimitive + (α G : Type*) [Fintype α] [Nonempty α] [Fintype G] + {q E T : ℝ} (hq : 0 ≤ q) (hE : 0 ≤ E) (hT : 0 ≤ T) + (hα : (Fintype.card α : ℝ) ≤ q) (hG : (Fintype.card G : ℝ) ≤ q) + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) + (hMT : (M : ℝ) ≤ Real.exp T) (hDq : (D : ℝ) ≤ Real.exp q) : + (scalarKernelCutoff α G M D (Real.exp (-(E + 1))) : ℝ) ≤ + Real.exp (allocatedKernelPrimitiveBudget q E T) := by + have hinput : 0 ≤ q + E + T + 1 := by positivity + have hMi := hMT.trans (Real.exp_le_exp.mpr (show T ≤ q + E + T + 1 by linarith)) + have hDi := hDq.trans (Real.exp_le_exp.mpr (show q ≤ q + E + T + 1 by linarith)) + have hη : (Real.exp (-(E + 1)))⁻¹ ≤ Real.exp (q + E + T + 1) := by + rw [Real.exp_neg, inv_inv] + exact Real.exp_le_exp.mpr (by linarith) + exact (scalarKernelCutoff_le_exp α G hM hD (Real.exp_pos _) hinput hMi hDi hη).trans + (Real.exp_le_exp.mpr (scalarKernelLogarithmicBudget_le_allocatedPrimitive α G hq hE hT hα hG)) + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +theorem allocatedIdealScale_ge_exp {D p e w E : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (he : 0 ≤ e) (hw : 0 ≤ w) (hE : 0 ≤ E) : + Real.exp p ≤ ((allocatedIdealScale (G := G) B U basis hR hσ D p e w E).value : ℝ) := + (Real.exp_le_exp.mpr (allocatedPhysicalIdealLengthEnvelope_ge_input m hD hp he hw hE)).trans + (allocatedIdealScale_lower B U basis hR hσ D p e w E) + +theorem allocatedIdealScale_kernel_cutoff {dim : ℕ} [Nonempty (Fin dim)] + {q Ebad T D p e w E : ℝ} + (hq : 0 ≤ q) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) + (hD : 0 ≤ D) (he : 0 ≤ e) (hw : 0 ≤ w) (hE : 0 ≤ E) + (hdim : (dim : ℝ) ≤ q) (hG : (Fintype.card G : ℝ) ≤ q) + (hbudget : allocatedKernelPrimitiveBudget q Ebad T ≤ p) + {M Dwin : ℕ} (hM : 0 < M) (hDwin : 0 < Dwin) + (hMT : (M : ℝ) ≤ Real.exp T) (hDq : (Dwin : ℝ) ≤ Real.exp q) : + let cutoff := scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(Ebad + 1))) + 0 < cutoff ∧ (cutoff : ℝ) ≤ Real.exp (allocatedKernelPrimitiveBudget q Ebad T) ∧ + cutoff ≤ (allocatedIdealScale (G := G) B U basis hR hσ D p e w E).value := by + have hp := (allocatedKernelPrimitiveBudget_bounds hq hEbad hT).1.trans hbudget + have hcut := scalarKernelCutoff_le_allocatedPrimitive (Fin dim) G hq hEbad hT + (by simpa only [Fintype.card_fin] using hdim) hG hM hDwin hMT hDq + refine ⟨(scalarKernelCutoff_bounds (Fin dim) G hM hDwin (Real.exp_pos _)).1, hcut, ?_⟩ + exact_mod_cast hcut.trans ((Real.exp_le_exp.mpr hbudget).trans + (allocatedIdealScale_ge_exp B U basis hR hσ hD hp he hw hE)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +theorem allocatedReferenceScale_affine_kernel_control + {dim : ℕ} [Nonempty (Fin dim)] {q E T D p e : ℝ} + (hq : 0 ≤ q) (hE : 0 ≤ E) (hT : 0 ≤ T) (hD : 0 ≤ D) (he : 0 ≤ e) + (hdim : (dim : ℝ) ≤ q) (hGp : (Fintype.card G : ℝ) ≤ q) + (hG : dim * (dim + 2) ≤ Fintype.card G) (selection : Fin dim ↪ G) + (hbudget : allocatedKernelPrimitiveBudget q E T ≤ p) + {M Dwin : ℕ} (hM : 0 < M) (hDwin : 0 < Dwin) + (hMT : (M : ℝ) ≤ Real.exp T) (hDq : (Dwin : ℝ) ≤ Real.exp q) : + let Psp := allocatedKernelPrimitiveBudget q E T + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * Psp + let error := allocatedReferenceIdealError m D Psp (E + 1) + let S := allocatedIdealScale (G := G) B U basis hR hσ D p e w error + let η := Real.exp (-(E + 1)) + let cutoff := scalarKernelCutoff (Fin dim) G M Dwin η + let Good := fun x : G → IntegerScalarCubeBox (Fin dim) S.value => + GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff x + 0 < cutoff ∧ (cutoff : ℝ) ≤ Real.exp Psp ∧ + ∃ hlarge : cutoff ≤ S.value, + ∀ (K : G → ℕ) (hKL : ∀ g, K g ≤ S.value) (hDK : ∀ g, S.value ≤ Dwin * K g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let law := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (K g) M Dwin (shift g) + S.positive (hKL g) (hDK g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin (Real.exp_pos _) hlarge (hDK g))) + law.eventProbability (fun x => ¬Good x) ≤ η ∧ + (∃ x, law.weight x ≠ 0 ∧ Good x) ∧ + ∀ (f : (G → IntegerScalarCubeBox (Fin dim) S.value) → ℂ) (g : ∀ x, Good x → ℂ), + (∀ x, ‖f x‖ ≤ 1) → (∀ x (hx : Good x), ‖f x - g x hx‖ ≤ η) → + ‖law.complexMean f - law.complexMean (fun x => if hx : Good x then g x hx else 0)‖ ≤ + Real.exp (-E) := by + intro Psp w error S η cutoff Good + have hPsp : 0 ≤ Psp := (allocatedKernelPrimitiveBudget_bounds hq hE hT).1 + have hw : 0 ≤ w := mul_nonneg (Nat.cast_nonneg _) hPsp + have herror : 0 ≤ error := allocatedReferenceIdealError_nonneg m hD hPsp (by linarith) + obtain ⟨hcutoff, hcutoffP, hlarge⟩ := allocatedIdealScale_kernel_cutoff B U basis hR hσ + hq hE hT hD he hw herror hdim hGp hbudget hM hDwin hMT hDq + refine ⟨hcutoff, hcutoffP, hlarge, ?_⟩ + intro K hKL hDK shift moduli residues hmoduli hmoduliM law + have hbad : law.eventProbability (fun x => ¬Good x) ≤ η := + affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hG) selection hM hDwin (Real.exp_pos _) S.positive + hlarge K hKL hDK shift moduli residues hmoduli hmoduliM + have hη : η < 1 := Real.exp_lt_one_iff.mpr (by linarith) + refine ⟨hbad, law.exists_supported_good_of_bad_lt_one Good (hbad.trans_lt hη), ?_⟩ + intro f g hf hgood + exact law.complexMean_goodPart_exp_error Good f g hbad hf hgood + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem allocatedNormalizedInitialLog_ge_input (m : ℕ) {p Pc E T : ℝ} + (hp : 0 ≤ p) (hPc : 0 ≤ Pc) (hE : 0 ≤ E) (hT : 0 ≤ T) : + p ≤ allocatedNormalizedInitialLog m p Pc E (T + 1) := by + have hD := (allocatedComparisonDimension_bounds m hp).1 + have he := allocatedCoefficientAccuracyLog_nonneg m hp (show 0 ≤ E + 3 by positivity) + have hJ := allocatedJointLengthEnvelope_nonneg m hD hPc he + dsimp only [allocatedCoefficientAccuracyLog] at hJ + have hprod := mul_nonneg hp hT + dsimp only [allocatedNormalizedInitialLog] + nlinarith + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +theorem allocatedPrimitiveNormalizedScale_ge_exp {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) : + Real.exp p ≤ ((allocatedPrimitiveNormalizedScale (G := G) B U b hR hσ p E (T + 1)).value : ℝ) := + (Real.exp_le_exp.mpr (allocatedNormalizedInitialLog_ge_input m hp + (allocatedComparisonDimension_bounds m hp).1 hE hT)).trans + (allocatedNormalizedScale_lower B U b hR hσ p (allocatedComparisonDimension m p) E (T + 1)) + +noncomputable def allocatedKernelScale (p E T : ℝ) : LayerSamplerScale (G := G) B U b R σ := + allocatedPrimitiveNormalizedScale B U b hR hσ (allocatedKernelPrimitiveBudget p E T) (E + 1) (T + 1) + +theorem allocatedKernelScale_cutoff {dim : ℕ} [Nonempty (Fin dim)] {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) + (hdim : (dim : ℝ) ≤ p) (hG : (Fintype.card G : ℝ) ≤ p) + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) + (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) : + (scalarKernelCutoff (Fin dim) G M D (Real.exp (-(E + 1))) : ℝ) ≤ + Real.exp (allocatedKernelPrimitiveBudget p E T) ∧ + scalarKernelCutoff (Fin dim) G M D (Real.exp (-(E + 1))) ≤ + (allocatedKernelScale (G := G) B U b hR hσ p E T).value := by + have hinput : 0 ≤ p + E + T + 1 := by positivity + have hMinput := hMT.trans (Real.exp_le_exp.mpr (show T ≤ p + E + T + 1 by linarith)) + have hDinput := hDp.trans (Real.exp_le_exp.mpr (show p ≤ p + E + T + 1 by linarith)) + have hηinput : (Real.exp (-(E + 1)))⁻¹ ≤ Real.exp (p + E + T + 1) := by + rw [Real.exp_neg, inv_inv] + exact Real.exp_le_exp.mpr (by linarith) + have hlog := scalarKernelLogarithmicBudget_le_allocatedPrimitive (Fin dim) G hp hE hT + (by simpa only [Fintype.card_fin] using hdim) hG + have hcut := (scalarKernelCutoff_le_exp (Fin dim) G hM hD (Real.exp_pos _) hinput + hMinput hDinput hηinput).trans (Real.exp_le_exp.mpr hlog) + refine ⟨hcut, ?_⟩ + exact_mod_cast hcut.trans (allocatedPrimitiveNormalizedScale_ge_exp B U b hR hσ + (allocatedKernelPrimitiveBudget_bounds hp hE hT).1 (show 0 ≤ E + 1 by positivity) hT) + +theorem allocatedKernelScale_affine_bad_probability [DecidableEq G] + {dim : ℕ} [Nonempty (Fin dim)] {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) + (hdim : (dim : ℝ) ≤ p) (hGp : (Fintype.card G : ℝ) ≤ p) + (hG : dim * (dim + 2) ≤ Fintype.card G) (selection : Fin dim ↪ G) + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) + (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) : + let S := allocatedKernelScale (G := G) B U b hR hσ p E T + let η := Real.exp (-(E + 1)) + let cutoff := scalarKernelCutoff (Fin dim) G M D η + let hlarge := (allocatedKernelScale_cutoff B U b hR hσ hp hE hT hdim hGp hM hD hMT hDp).2 + ∀ (K : G → ℕ) (hKL : ∀ g, K g ≤ S.value) (hDK : ∀ g, S.value ≤ D * K g) + (c : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + (FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (K g) M D (c g) S.positive (hKL g) (hDK g) + (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hD (Real.exp_pos _) hlarge (hDK g)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff x) ≤ η := by + intro S η cutoff hlarge K hKL hDK c moduli residues hmoduli hmoduliM + exact affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hG) selection hM hD (Real.exp_pos _) S.positive + hlarge K hKL hDK c moduli residues hmoduli hmoduliM + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +noncomputable def allocatedCoarseKernelScale (p E T : ℝ) : LayerSamplerScale (G := G) B U b R σ := + allocatedPrimitiveNormalizedScale B U b hR hσ (allocatedKernelPrimitiveBudget p E T) (E+2) (T+1) + +theorem allocatedCoarseKernelScale_cutoff {dim : ℕ} [Nonempty (Fin dim)] {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) + (hdim : (dim : ℝ) ≤ p) (hG : (Fintype.card G : ℝ) ≤ p) + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) + (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) : + (scalarKernelCutoff (Fin dim) G M D (Real.exp (-(E+1))) : ℝ) ≤ + Real.exp (allocatedKernelPrimitiveBudget p E T) ∧ + scalarKernelCutoff (Fin dim) G M D (Real.exp (-(E+1))) ≤ + (allocatedCoarseKernelScale (G := G) B U b hR hσ p E T).value := by + have hcut := (allocatedKernelScale_cutoff B U b hR hσ hp hE hT hdim hG hM hD hMT hDp).1 + refine ⟨hcut, ?_⟩ + exact_mod_cast hcut.trans (allocatedPrimitiveNormalizedScale_ge_exp B U b hR hσ + (allocatedKernelPrimitiveBudget_bounds hp hE hT).1 (show 0 ≤ E+2 by positivity) hT) + +theorem allocatedCoarseKernelScale_affine_bad_probability [DecidableEq G] + {dim : ℕ} [Nonempty (Fin dim)] {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) + (hdim : (dim : ℝ) ≤ p) (hGp : (Fintype.card G : ℝ) ≤ p) + (hG : dim * (dim + 2) ≤ Fintype.card G) (selection : Fin dim ↪ G) + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) + (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) : + let S := allocatedCoarseKernelScale (G := G) B U b hR hσ p E T + let η := Real.exp (-(E+1)) + let cutoff := scalarKernelCutoff (Fin dim) G M D η + let hlarge := (allocatedCoarseKernelScale_cutoff B U b hR hσ hp hE hT hdim hGp hM hD hMT hDp).2 + ∀ (K : G → ℕ) (hKL : ∀ g, K g ≤ S.value) (hDK : ∀ g, S.value ≤ D*K g) + (c : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + (FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (K g) M D (c g) S.positive (hKL g) (hDK g) + (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hD (Real.exp_pos _) hlarge (hDK g)))).eventProbability + (fun x => ¬GoodScalarKernelTuple selection (1/(cutoff : ℝ)) cutoff x) ≤ η := by + intro S η cutoff hlarge K hKL hDK c moduli residues hmoduli hmoduliM + exact affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hG) selection hM hD (Real.exp_pos _) S.positive + hlarge K hKL hDK c moduli residues hmoduli hmoduliM + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable {dim : ℕ} (X : Type*) [Fintype X] +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hmem : ∀ j e, coefficients (poly j) e ∈ U j) +variable (N : X → ℕ) (hN : ∀ t, 0 < N t) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (stride : X → ℕ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + +local notation "widths" => narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N +local notation "baseDensity" => allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem + +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (bases : Finset (X → ℤ)) (hbases : bases.Nonempty) +variable (htotal : 0 < selectedJointDensityMass bases stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem)) + +local notation "Z" => selectedJointDensityMass bases stride cells widths baseDensity +local notation "Kernel" => (G → IntegerScalarCubeBox (Fin dim) S.value) + +variable (μ : FiniteProbabilityWeights (G → IntegerScalarCubeBox (Fin dim) S.value)) +variable (selection : Fin dim ↪ G) (M : ℕ) +variable (test : (X → (Unit ⊕ Fin dim) → ℤ) → ℂ) (htest : ∀ v, ‖test v‖ ≤ 1) + +local notation "Good" => GoodScalarKernelTuple (L := S.value) selection (1 / (M : ℝ)) M +local notation "source" => (fun (x : Kernel) (base : X → ℤ) => + allocatedOriginalTupleSource B U b hR hσ S x X stride hb o N hN hW hτ hξ base cells hmass test Z poly hmem) + +include hbases htotal htest + +theorem allocatedOriginal_kernel_average : + let f : Kernel → (X → ℤ) → ℂ := source + ∀ (reference : ∀ x : Kernel, Good x → (X → ℤ) → ℂ) + {ε : ℝ}, 0 ≤ ε → + (∀ x (hx : Good x) base, base ∈ bases → ‖f x base - reference x hx base‖ ≤ ε) → + ‖μ.complexMean (fun x => 𝔼 base ∈ bases, f x base) - + μ.goodPartBaseMean bases Good reference‖ ≤ + ε + μ.eventProbability (fun x => ¬Good x) := by + intro f reference ε hε hcomparison + apply μ.complexMean_goodPart_base_comparison bases hbases Good f reference hε _ hcomparison + intro x + exact allocatedOriginalSource_base_average_bound B U b hb o hR hσ S X poly hmem N hN + hW hτ hξ stride cells hmass bases hbases htotal x test htest + +theorem allocatedOriginal_kernel_average_of_bad_bound : + let f : Kernel → (X → ℤ) → ℂ := source + ∀ (reference : ∀ x : Kernel, Good x → (X → ℤ) → ℂ) + {ε η : ℝ}, 0 ≤ ε → + (∀ x (hx : Good x) base, base ∈ bases → ‖f x base - reference x hx base‖ ≤ ε) → + μ.eventProbability (fun x => ¬Good x) ≤ η → + ‖μ.complexMean (fun x => 𝔼 base ∈ bases, f x base) - + μ.goodPartBaseMean bases Good reference‖ ≤ ε + η := by + intro f reference ε η hε hcomparison hbad + exact (allocatedOriginal_kernel_average B U b hb o hR hσ S X poly hmem N hN hW hτ hξ stride cells + hmass bases hbases htotal μ selection M test htest reference hε hcomparison).trans + (add_le_add le_rfl hbad) + +theorem allocatedOriginal_affine_kernel_average [Nonempty (Fin dim)] + (hG : dim * (dim + 2) ≤ Fintype.card G) + (modulusBound lengthFactor : ℕ) (hmodulusBound : 0 < modulusBound) (hlengthFactor : 0 < lengthFactor) + {η : ℝ} (hη : 0 < η) + (hlarge : scalarKernelCutoff (Fin dim) G modulusBound lengthFactor η ≤ S.value) + (K : G → ℕ) (hKL : ∀ g, K g ≤ S.value) (hDK : ∀ g, S.value ≤ lengthFactor * K g) + (c : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliBound : ∀ g i, moduli g i ≤ modulusBound) : + let cutoff := scalarKernelCutoff (Fin dim) G modulusBound lengthFactor η + let law := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (K g) modulusBound lengthFactor (c g) + S.positive (hKL g) (hDK g) (moduli g) (residues g) (hmoduli g) (hmoduliBound g) + (scalarKernelCutoff_window_size (Fin dim) G hmodulusBound hlengthFactor hη hlarge (hDK g))) + ∀ (reference : ∀ x : Kernel, GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff x → (X → ℤ) → ℂ) + {ε : ℝ}, 0 ≤ ε → + (∀ x (hx : GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff x) base, + base ∈ bases → ‖source x base - reference x hx base‖ ≤ ε) → + ‖law.complexMean (fun x => 𝔼 base ∈ bases, source x base) - + law.goodPartBaseMean bases (GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff) + reference‖ ≤ ε + η := by + intro cutoff law reference ε hε hcomparison + have hbad := affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hG) selection hmodulusBound hlengthFactor hη S.positive + hlarge K hKL hDK c moduli residues hmoduli hmoduliBound + exact allocatedOriginal_kernel_average_of_bad_bound B U b hb o hR hσ S X poly hmem N hN hW hτ hξ + stride cells hmass bases hbases htotal law selection cutoff test htest reference hε hcomparison hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory Polynomial +open scoped BigOperators Classical NNReal + +universe uX + +def allocatedAveragedCoarseKernelStatement (m dim : ℕ) : Prop := + ∃ A a : ℕ, 2 ≤ A ∧ 2 ≤ a ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + [Nonempty (Fin dim)] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ v, Fintype (B v)] [∀ v, DecidableEq (B v)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + {p Etarget T : ℝ} (_hp : 0 ≤ p) (_hE : 0 ≤ Etarget) (_hT : 0 ≤ T) + (_hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (_hn : ∀ j, (n j : ℝ) ≤ p) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (_hRup : ∀ j, R j ≤ Real.exp p) (_hRi : ∀ j, (R j)⁻¹ ≤ Real.exp p) + (_hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp p) (_hmsp : ((m + 2 : ℕ) : ℝ) ≤ p), + let E := Etarget + 1 + let Q := allocatedKernelPrimitiveBudget p E T + let S := allocatedCoarseKernelScale (G := G) B U b hR hσ p E T + let P := allocatedChosenScaleBudget m Q (E + 2) (T + 1) + let Pc := allocatedComparisonDimension m Q + let L₀ := allocatedNormalizedInitialScale m Q Pc (E + 2) (T + 1) + (S.value : ℝ) ≤ Real.exp ((p + Etarget + T + a)^a) ∧ + ∀ (M D : ℕ) (hM : 0 < M) (hD : 0 < D) + (_hMT : (M : ℝ) ≤ Real.exp T) (_hDp : (D : ℝ) ≤ Real.exp p) + (selection : Fin dim ↪ G) (_hdim : dim ≤ m + 1) + (_hG : dim * (dim + 2) ≤ Fintype.card G), + let η := Real.exp (-(E + 1)) + let cutoff := scalarKernelCutoff (Fin dim) G M D η + let hcutoff := (scalarKernelCutoff_bounds (Fin dim) G hM hD (Real.exp_pos (-(E + 1)))).1 + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (cutoff : ℝ)) cutoff + let GoodKernel := {x : G → IntegerScalarCubeBox (Fin dim) S.value // Good x} + ∃ hlarge : cutoff ≤ S.value, + (cutoff : ℝ) ≤ Real.exp Q ∧ + ∃ (degree : GoodKernel → ℕ) (hdegree : ∀ x, 0 < degree x), + (∀ x, (degree x : ℝ) ≤ Real.exp ((p + Etarget + T + a)^a)) ∧ + ∀ (K : G → ℕ) (hKL : ∀ g, K g ≤ S.value) (hDK : ∀ g, S.value ≤ D * K g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (K g) M D (shift g) S.positive + (hKL g) (hDK g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hD (Real.exp_pos _) hlarge (hDK g))) + ∀ [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp p) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp p) + {X : Type uX} [Fintype X] [DecidableEq X] (_hXp : (Fintype.card X : ℝ) ≤ p), + let O := fun j : Fin m => BoundedBooleanJet (Fin dim) (j.val + 1) + let rows := fun j => (Subtype.val : O j → Finset (Fin dim)) + let ξ₀ := normalizedTupleNarrowWidth X (PrincipalTupleIndex B (layerSamplerDegree I n)) + selection cutoff Q (E + 2) + let hξ := normalizedTupleNarrowWidth_pos X (PrincipalTupleIndex B (layerSamplerDegree I n)) + selection cutoff Q (E + 2) + let W : ℝ := Fintype.card (LayerSamplerVariables G I n B) * (S.value : ℝ) + let hW : 0 ≤ W := mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + let Pmass := allocatedUnifiedSamplingBudget m dim A P Q (E + 2) + ∀ (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U) (c : ∀ j, U j) + (_hc : coefficientConstantCenter U center = + -(QuotientAddGroup.mk' (coefficientIntegerLattice U) (constantCoefficientArray U (fun s => c s.1)))) + (N stride : X → ℕ) (_hs : ∀ t, 0 < stride t) {Rrank τ : ℝ} (hτ : 0 < τ), + let mesh := normalizedTupleRadius X selection cutoff Q (E + 2) + (Fintype.card (LayerSamplerVariables G I n B)) / 4 + ∀ (_hτp : 1 / τ ≤ Real.exp p) (_hstrideT : ∀ t, (stride t : ℝ) ≤ Real.exp T) + (_hsize : ∀ t, Real.exp ((p + Etarget + T + a)^a) ≤ (N t : ℝ)) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) Rrank (U j) (poly j)) + (_hRank : Real.exp ((p + Etarget + T + a)^a) ≤ Rrank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (_hcells : cells.Nonempty) (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty) + {Kcov : Fin m → Type*} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))), + let centeredPoly := fun j => subtractConstant (c j).val (poly j) + let centeredMem := fun j => coefficients_subtractConstant_mem (U j) (c j) (poly j) (hmem j) + let widths := narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ₀ N + let baseDensity := jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ poly hmem center + let Z := selectedJointDensityMass bases stride cells widths baseDensity + ∃ (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells widths z) + (hN : ∀ t, 0 < N t) (hZ : 0 < Z), + let hwidths := narrowTrimmedSpatialWidths_pos hW hτ hξ N hN + let whole := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let law := whole.prod (selectedJointFiniteLaw bases _hbases stride cells widths hwidths + hmass baseDensity (jointSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ poly hmem center) hZ) + (|Z - 1| ≤ Real.exp (-Pmass) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ Z⁻¹ ≤ 2) ∧ + ∃ reference : GoodKernel → (X → ℤ) → (Finset (Fin dim) → (X → ℝ) → ℂ) → ℂ, + (∀ x : GoodKernel, let : NeZero (degree x) := ⟨(hdegree x).ne'⟩ + ∀ base, allocatedRefinedSiteFunctional (τ := τ) (ξ := ξ₀) B U b hR hσ S x.val rows X + hcutoff selection x.property stride hb o bW (degree x) N hW mesh base cells + (physicalCubeEuclideanSample U (degree x) centeredPoly centeredMem) Z Pc (T + 1) (Real.exp (coefficientErrorVolumeLog Q + 4)) (reference x base)) ∧ + ∀ (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1), + ‖kernelLaw.complexMean (fun x => law.complexMean (fun z => + physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x z.1) + (allocatedPhysicalCubeDirections B U b S x z.1) z.2.1.val z.2.2.val))) - + kernelLaw.goodPartBaseMean bases Good + (fun x hx base => reference ⟨x, hx⟩ base test)‖ ≤ Real.exp (-Etarget) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +theorem allocatedAveragedCoarseKernelComparison (m dim : ℕ) : + allocatedAveragedCoarseKernelStatement m dim := by + obtain ⟨A, C, hA, _, hcomparison⟩ := allocatedTestUniformCoarseJointComparison m dim + obtain ⟨a₀, ha₀, hthreshold⟩ := exists_allocatedKernelThreshold_bound C + let a := a₀ + 2 + unfold allocatedAveragedCoarseKernelStatement + refine ⟨A, a, hA, by dsimp [a]; omega, ?_⟩ + intro G _ _ _ I _ _ n B _ _ J _ U b R σ hR hσ p Etarget T hp hEtarget hT + hvars hI hn hJ hRup hRi hσi hmsp E Q S P Pc L₀ + have hE : 0 ≤ E := by dsimp [E]; linarith + obtain ⟨hQ, hpQ, _, _, _⟩ := allocatedKernelPrimitiveBudget_bounds hp hE hT + have hexp := Real.exp_le_exp.mpr hpQ + have hwork : (p + E + T + a₀)^a₀ ≤ (p + Etarget + T + a)^a := by + have hbase : p + E + T + a₀ ≤ p + Etarget + T + a := by + dsimp [E, a] + push_cast + linarith + have hone : 1 ≤ p + Etarget + T + a := by + dsimp [a] + push_cast + linarith [Nat.cast_nonneg (α := ℝ) a₀] + exact (pow_le_pow_left₀ (by positivity) hbase a₀).trans + (pow_le_pow_right₀ hone (by dsimp [a]; omega)) + have hcut : (Q + E + (T + 1) + C)^C ≤ (p + Etarget + T + a)^a := by + have hstep : Q + E + (T + 1) + C ≤ Q + (E + 1) + (T + 1) + C := by linarith + exact (pow_le_pow_left₀ (by positivity) hstep C).trans + ((hthreshold hp hE hT).trans hwork) + obtain ⟨S', hS', hSbound, hkernel⟩ := hcomparison B U b hR hσ hQ hE + (show 0 ≤ T + 1 by positivity) (hvars.trans hpQ) + (fun j => (hI j).trans hpQ) (fun j => (hn j).trans hpQ) (fun j => (hJ j).trans hpQ) + (fun j => (hRup j).trans hexp) (fun j => (hRi j).trans hexp) + (fun j => (hσi j).trans hexp) (hmsp.trans hpQ) + have hS : S' = S := hS' + subst S' + refine ⟨hSbound.trans (Real.exp_le_exp.mpr hcut), ?_⟩ + intro M D hM hD hMT hDp selection hdim hG η cutoff hcutoff Good GoodKernel + have hdimP : (dim : ℝ) ≤ p := + (Nat.cast_le.mpr (by omega : dim ≤ m + 2)).trans hmsp + have hGp : (Fintype.card G : ℝ) ≤ p := + (Nat.cast_le.mpr (allocatedKernelVariables_card_le_variables (G := G) B)).trans hvars + obtain ⟨hcutoffQ, hlarge⟩ := allocatedCoarseKernelScale_cutoff B U b hR hσ + hp hE hT hdimP hGp hM hD hMT hDp + refine ⟨hlarge, hcutoffQ, ?_⟩ + have hforKernel (x : GoodKernel) := hkernel x.val hcutoff hcutoffQ selection x.property hdim + choose degree hdegree hdegreeBound hconstruct using hforKernel + refine ⟨degree, hdegree, fun x => (hdegreeBound x).trans (Real.exp_le_exp.mpr hcut), ?_⟩ + intro K hKL hDK shift moduli residues hmoduli hmoduliM kernelLaw + have hbad : kernelLaw.eventProbability (fun x => ¬Good x) ≤ η := + allocatedCoarseKernelScale_affine_bad_probability B U b hR hσ hp hE hT hdimP hGp hG + selection hM hD hMT hDp K hKL hDK shift moduli residues hmoduli hmoduliM + have hηlt : η < 1 := by + change Real.exp (-(E + 1)) < 1 + calc + _ < Real.exp 0 := Real.exp_lt_exp.mpr (by linarith) + _ = 1 := Real.exp_zero + have hexists : ∃ x : G → IntegerScalarCubeBox (Fin dim) S.value, Good x := by + by_contra! hnone + have hone : kernelLaw.eventProbability (fun x => ¬Good x) = 1 := by + simp only [FiniteProbabilityWeights.eventProbability, hnone, not_false_eq_true, + ite_true, FiniteProbabilityWeights.mean_const] + linarith + obtain ⟨x₀, hx₀⟩ := hexists + let x0 : GoodKernel := ⟨x₀, hx₀⟩ + intro _ _ _ _ _ hb o Cchart Vcap hC hV hσ1 Cinv hCinv hchart hsmall μ _ _ ν _ _ hCp hVp + let : ∀ x : GoodKernel, NeZero (degree x) := fun x => ⟨(hdegree x).ne'⟩ + have hg (x : GoodKernel) := hconstruct x hb o Cchart Vcap hC hV hσ1 Cinv hCinv hchart hsmall μ ν + choose g hgc hgb hgi hgm hglaw hgproj hdata using hg + intro X _ _ hXp O rows ξ₀ hξ W hW Pmass poly hpoly hmem center c hc N stride hs Rrank τ hτ + mesh hτp hstrideT hsize hrank hRank cells hcells bases hbases Kcov _ bW + centeredPoly centeredMem widths baseDensity Z + have hresults (x : GoodKernel) := hdata x + (fun j => (hCp j).trans hexp) (fun j => (hVp j).trans hexp) (hXp.trans hpQ) + poly hpoly hmem center c hc N stride hs hτ (hτp.trans hexp) + (fun t => (hstrideT t).trans (Real.exp_le_exp.mpr (by linarith : T ≤ T + 1))) + (fun t => (Real.exp_le_exp.mpr hcut).trans (hsize t)) hrank + ((Real.exp_le_exp.mpr hcut).trans hRank) cells hcells bases hbases bW + choose hmass hN hZ hnormal reference hrep herror using hresults + let law := (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).prod + (selectedJointFiniteLaw bases hbases stride cells widths + (narrowTrimmedSpatialWidths_pos hW hτ hξ N (hN x0)) (hmass x0) baseDensity + (jointSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ poly hmem center) (hZ x0)) + refine ⟨hmass x0, hN x0, hZ x0, hnormal x0, reference, hrep, ?_⟩ + intro test htest + have hunit (x : G → IntegerScalarCubeBox (Fin dim) S.value) : + ‖law.complexMean (fun z => physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x z.1) + (allocatedPhysicalCubeDirections B U b S x z.1) z.2.1.val z.2.2.val))‖ ≤ 1 := by + apply (law.norm_complexMean_le_mean_norm _).trans + exact (law.mean_mono (fun _ => physicalCubeSiteTest_norm_le test htest _)).trans_eq (law.mean_const 1) + have havg := kernelLaw.complexMean_goodPart_comparison Good + (fun x => law.complexMean (fun z => physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x z.1) + (allocatedPhysicalCubeDirections B U b S x z.1) z.2.1.val z.2.2.val))) + (fun x hx => 𝔼 base ∈ bases, reference ⟨x, hx⟩ base test) + (Real.exp_pos (-E)).le hunit (fun x hx => (herror ⟨x, hx⟩ test htest).2) + have hηsmall : η ≤ Real.exp (-E) := Real.exp_le_exp.mpr (by linarith : -(E + 1) ≤ -E) + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hsum : Real.exp (-E) + η ≤ Real.exp (-Etarget) := by + calc + _ ≤ 2 * Real.exp (-E) := by linarith + _ ≤ Real.exp 1 * Real.exp (-E) := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = Real.exp (-Etarget) := by + rw [← Real.exp_add] + congr 1 + dsimp [E] + ring + exact havg.trans ((add_le_add le_rfl hbad).trans hsum) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedAveragedKernelComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedAveragedKernelComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cb6f8082af7434f55d59930642c467cd9492851 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedAveragedKernelComparison.lean @@ -0,0 +1,253 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedAveragedCoarseKernelComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory Polynomial +open scoped BigOperators Classical NNReal + +universe uX + +def allocatedAveragedKernelStatement (m dim : ℕ) : Prop := + ∃ A a : ℕ, 2 ≤ A ∧ 2 ≤ a ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + [Nonempty (Fin dim)] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ v, Fintype (B v)] [∀ v, DecidableEq (B v)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + {p Etarget T : ℝ} (_hp : 0 ≤ p) (_hE : 0 ≤ Etarget) (_hT : 0 ≤ T) + (_hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (_hn : ∀ j, (n j : ℝ) ≤ p) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (_hRup : ∀ j, R j ≤ Real.exp p) (_hRi : ∀ j, (R j)⁻¹ ≤ Real.exp p) + (_hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp p) (_hmsp : ((m + 2 : ℕ) : ℝ) ≤ p), + let E := Etarget + 1 + let Q := allocatedKernelPrimitiveBudget p E T + let S := allocatedKernelScale (G := G) B U b hR hσ p E T + let P := allocatedChosenScaleBudget m Q (E + 1) (T + 1) + let Pc := allocatedComparisonDimension m Q + let L₀ := allocatedNormalizedInitialScale m Q Pc (E + 1) (T + 1) + (S.value : ℝ) ≤ Real.exp ((p + Etarget + T + a)^a) ∧ + ∀ (M D : ℕ) (hM : 0 < M) (hD : 0 < D) + (_hMT : (M : ℝ) ≤ Real.exp T) (_hDp : (D : ℝ) ≤ Real.exp p) + (selection : Fin dim ↪ G) (_hdim : dim ≤ m + 1) + (_hG : dim * (dim + 2) ≤ Fintype.card G), + let η := Real.exp (-(E + 1)) + let cutoff := scalarKernelCutoff (Fin dim) G M D η + let hcutoff := (scalarKernelCutoff_bounds (Fin dim) G hM hD (Real.exp_pos (-(E + 1)))).1 + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (cutoff : ℝ)) cutoff + let GoodKernel := {x : G → IntegerScalarCubeBox (Fin dim) S.value // Good x} + ∃ hlarge : cutoff ≤ S.value, + (cutoff : ℝ) ≤ Real.exp Q ∧ + ∃ (degree : GoodKernel → ℕ) (hdegree : ∀ x, 0 < degree x), + (∀ x, (degree x : ℝ) ≤ Real.exp ((p + Etarget + T + a)^a)) ∧ + ∀ (K : G → ℕ) (hKL : ∀ g, K g ≤ S.value) (hDK : ∀ g, S.value ≤ D * K g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + let kernelLaw := FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (K g) M D (shift g) S.positive + (hKL g) (hDK g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hD (Real.exp_pos _) hlarge (hDK g))) + ∀ [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp p) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp p) + {X : Type uX} [Fintype X] [DecidableEq X] (_hXp : (Fintype.card X : ℝ) ≤ p), + let O := fun j : Fin m => BoundedBooleanJet (Fin dim) (j.val + 1) + let rows := fun j => (Subtype.val : O j → Finset (Fin dim)) + let ξ₀ := normalizedTupleNarrowWidth X (PrincipalTupleIndex B (layerSamplerDegree I n)) + selection cutoff Q (E + 1) + let hξ := normalizedTupleNarrowWidth_pos X (PrincipalTupleIndex B (layerSamplerDegree I n)) + selection cutoff Q (E + 1) + let W : ℝ := Fintype.card (LayerSamplerVariables G I n B) * (S.value : ℝ) + let hW : 0 ≤ W := mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + let Pmass := allocatedUnifiedSamplingBudget m dim A P Q (E + 1) + ∀ (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U) (c : ∀ j, U j) + (_hc : coefficientConstantCenter U center = + -(QuotientAddGroup.mk' (coefficientIntegerLattice U) (constantCoefficientArray U (fun s => c s.1)))) + (N stride : X → ℕ) (_hs : ∀ t, 0 < stride t) {Rrank τ : ℝ} (hτ : 0 < τ), + let δ := normalizedTupleRadius X selection cutoff Q (E + 1) W + let mesh := δ / 4 + ∀ (_hτp : 1 / τ ≤ Real.exp p) (_hstrideT : ∀ t, (stride t : ℝ) ≤ Real.exp T) + (_hsize : ∀ t, Real.exp ((p + Etarget + T + a)^a) ≤ (N t : ℝ)) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) Rrank (U j) (poly j)) + (_hRank : Real.exp ((p + Etarget + T + a)^a) ≤ Rrank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (_hcells : cells.Nonempty) (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty) + {Kcov : Fin m → Type*} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))), + let centeredPoly := fun j => subtractConstant (c j).val (poly j) + let centeredMem := fun j => coefficients_subtractConstant_mem (U j) (c j) (poly j) (hmem j) + let widths := narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ₀ N + let baseDensity := jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ poly hmem center + let Z := selectedJointDensityMass bases stride cells widths baseDensity + ∃ (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells widths z) + (hN : ∀ t, 0 < N t) (hZ : 0 < Z), + let hwidths := narrowTrimmedSpatialWidths_pos hW hτ hξ N hN + let whole := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let law := whole.prod (selectedJointFiniteLaw bases _hbases stride cells widths hwidths + hmass baseDensity (jointSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ poly hmem center) hZ) + (|Z - 1| ≤ Real.exp (-Pmass) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ Z⁻¹ ≤ 2) ∧ + ∃ reference : GoodKernel → (X → ℤ) → ((X → (Unit ⊕ Fin dim) → ℤ) → ℂ) → ℂ, + (∀ x : GoodKernel, let : NeZero (degree x) := ⟨(hdegree x).ne'⟩ + ∀ base, allocatedRefinedReferenceFunctional (τ := τ) (ξ := ξ₀) B U b hR hσ S x.val rows X + hcutoff selection x.property stride hb o bW (degree x) N hW mesh base cells + (physicalCubeEuclideanSample U (degree x) centeredPoly centeredMem) Z Pc (T + 1) (reference x base)) ∧ + ∀ (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1), + ‖kernelLaw.complexMean (fun x => law.complexMean (fun z => + physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x z.1) + (allocatedPhysicalCubeDirections B U b S x z.1) z.2.1.val z.2.2.val))) - + kernelLaw.goodPartBaseMean bases Good + (fun x hx base => reference ⟨x, hx⟩ base (physicalCubeSiteTest test))‖ ≤ Real.exp (-Etarget) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +theorem allocatedAveragedKernelComparison (m dim : ℕ) : + allocatedAveragedKernelStatement m dim := by + obtain ⟨A, C, hA, _, hcomparison⟩ := allocatedTestUniformJointComparison m dim + obtain ⟨a₀, ha₀, hthreshold⟩ := exists_allocatedKernelThreshold_bound C + let a := a₀ + 2 + unfold allocatedAveragedKernelStatement + refine ⟨A, a, hA, by dsimp [a]; omega, ?_⟩ + intro G _ _ _ I _ _ n B _ _ J _ U b R σ hR hσ p Etarget T hp hEtarget hT + hvars hI hn hJ hRup hRi hσi hmsp E Q S P Pc L₀ + have hE : 0 ≤ E := by dsimp [E]; linarith + obtain ⟨hQ, hpQ, _, _, _⟩ := allocatedKernelPrimitiveBudget_bounds hp hE hT + have hexp := Real.exp_le_exp.mpr hpQ + have hwork : (p + E + T + a₀)^a₀ ≤ (p + Etarget + T + a)^a := by + have hbase : p + E + T + a₀ ≤ p + Etarget + T + a := by + dsimp [E, a] + push_cast + linarith + have hone : 1 ≤ p + Etarget + T + a := by + dsimp [a] + push_cast + linarith [Nat.cast_nonneg (α := ℝ) a₀] + exact (pow_le_pow_left₀ (by positivity) hbase a₀).trans + (pow_le_pow_right₀ hone (by dsimp [a]; omega)) + have hcut : (Q + E + (T + 1) + C)^C ≤ (p + Etarget + T + a)^a := by + have hstep : Q + E + (T + 1) + C ≤ Q + (E + 1) + (T + 1) + C := by linarith + exact (pow_le_pow_left₀ (by positivity) hstep C).trans + ((hthreshold hp hE hT).trans hwork) + obtain ⟨S', hS', hSbound, hkernel⟩ := hcomparison B U b hR hσ hQ hE + (show 0 ≤ T + 1 by positivity) (hvars.trans hpQ) + (fun j => (hI j).trans hpQ) (fun j => (hn j).trans hpQ) (fun j => (hJ j).trans hpQ) + (fun j => (hRup j).trans hexp) (fun j => (hRi j).trans hexp) + (fun j => (hσi j).trans hexp) (hmsp.trans hpQ) + have hS : S' = S := hS' + subst S' + refine ⟨hSbound.trans (Real.exp_le_exp.mpr hcut), ?_⟩ + intro M D hM hD hMT hDp selection hdim hG η cutoff hcutoff Good GoodKernel + have hdimP : (dim : ℝ) ≤ p := + (Nat.cast_le.mpr (by omega : dim ≤ m + 2)).trans hmsp + have hGp : (Fintype.card G : ℝ) ≤ p := + (Nat.cast_le.mpr (allocatedKernelVariables_card_le_variables (G := G) B)).trans hvars + obtain ⟨hcutoffQ, hlarge⟩ := allocatedKernelScale_cutoff B U b hR hσ + hp hE hT hdimP hGp hM hD hMT hDp + refine ⟨hlarge, hcutoffQ, ?_⟩ + have hforKernel (x : GoodKernel) := hkernel x.val hcutoff hcutoffQ selection x.property hdim + choose degree hdegree hdegreeBound hconstruct using hforKernel + refine ⟨degree, hdegree, fun x => (hdegreeBound x).trans (Real.exp_le_exp.mpr hcut), ?_⟩ + intro K hKL hDK shift moduli residues hmoduli hmoduliM kernelLaw + have hbad : kernelLaw.eventProbability (fun x => ¬Good x) ≤ η := + allocatedKernelScale_affine_bad_probability B U b hR hσ hp hE hT hdimP hGp hG + selection hM hD hMT hDp K hKL hDK shift moduli residues hmoduli hmoduliM + have hηlt : η < 1 := by + change Real.exp (-(E + 1)) < 1 + calc + _ < Real.exp 0 := Real.exp_lt_exp.mpr (by linarith) + _ = 1 := Real.exp_zero + have hexists : ∃ x : G → IntegerScalarCubeBox (Fin dim) S.value, Good x := by + by_contra! hnone + have hone : kernelLaw.eventProbability (fun x => ¬Good x) = 1 := by + simp only [FiniteProbabilityWeights.eventProbability, hnone, not_false_eq_true, + ite_true, FiniteProbabilityWeights.mean_const] + linarith + obtain ⟨x₀, hx₀⟩ := hexists + let x0 : GoodKernel := ⟨x₀, hx₀⟩ + intro _ _ _ _ _ hb o Cchart Vcap hC hV hσ1 Cinv hCinv hchart hsmall μ _ _ ν _ _ hCp hVp + let : ∀ x : GoodKernel, NeZero (degree x) := fun x => ⟨(hdegree x).ne'⟩ + have hg (x : GoodKernel) := hconstruct x hb o Cchart Vcap hC hV hσ1 Cinv hCinv hchart hsmall μ ν + choose g hgc hgb hgi hgm hglaw hgproj hdata using hg + intro X _ _ hXp O rows ξ₀ hξ W hW Pmass poly hpoly hmem center c hc N stride hs Rrank τ hτ + δ mesh hτp hstrideT hsize hrank hRank cells hcells bases hbases Kcov _ bW + centeredPoly centeredMem widths baseDensity Z + have hresults (x : GoodKernel) := hdata x + (fun j => (hCp j).trans hexp) (fun j => (hVp j).trans hexp) (hXp.trans hpQ) + poly hpoly hmem center c hc N stride hs hτ (hτp.trans hexp) + (fun t => (hstrideT t).trans (Real.exp_le_exp.mpr (by linarith : T ≤ T + 1))) + (fun t => (Real.exp_le_exp.mpr hcut).trans (hsize t)) hrank + ((Real.exp_le_exp.mpr hcut).trans hRank) cells hcells bases hbases bW + choose hmass hN hZ hnormal reference hrep herror using hresults + let law := (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S)).prod + (selectedJointFiniteLaw bases hbases stride cells widths + (narrowTrimmedSpatialWidths_pos hW hτ hξ N (hN x0)) (hmass x0) baseDensity + (jointSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ poly hmem center) (hZ x0)) + refine ⟨hmass x0, hN x0, hZ x0, hnormal x0, reference, hrep, ?_⟩ + intro test htest + have hunit (x : G → IntegerScalarCubeBox (Fin dim) S.value) : + ‖law.complexMean (fun z => physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x z.1) + (allocatedPhysicalCubeDirections B U b S x z.1) z.2.1.val z.2.2.val))‖ ≤ 1 := by + apply (law.norm_complexMean_le_mean_norm _).trans + exact (law.mean_mono (fun z => physicalCubeSiteTest_norm_le test htest _)).trans_eq (law.mean_const 1) + have havg := kernelLaw.complexMean_goodPart_comparison Good + (fun x => law.complexMean (fun z => physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x z.1) + (allocatedPhysicalCubeDirections B U b S x z.1) z.2.1.val z.2.2.val))) + (fun x hx => 𝔼 base ∈ bases, reference ⟨x, hx⟩ base (physicalCubeSiteTest test)) + (Real.exp_pos (-E)).le hunit (fun x hx => (herror ⟨x, hx⟩ test htest).2) + have hηsmall : η ≤ Real.exp (-E) := Real.exp_le_exp.mpr (by linarith : -(E + 1) ≤ -E) + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hsum : Real.exp (-E) + η ≤ Real.exp (-Etarget) := by + calc + _ ≤ 2 * Real.exp (-E) := by linarith + _ ≤ Real.exp 1 * Real.exp (-E) := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = Real.exp (-Etarget) := by + rw [← Real.exp_add] + congr 1 + dsimp [E] + ring + exact havg.trans ((add_le_add le_rfl hbad).trans hsum) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCanonicalProjectionBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCanonicalProjectionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa77536e17c3fa9c7b5edbf55cd2df79c8c2fca0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCanonicalProjectionBudget.lean @@ -0,0 +1,127 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedSourceNormalization + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal + +noncomputable def canonicalProjectionRowCost (m dim : ℕ) : ℕ := + Fintype.card (Finset (Fin dim)) * + ∑ j : Fin m, Fintype.card (BoundedBooleanJet (Fin dim) (j.val + 1)) + +noncomputable def allocatedCanonicalProjectionLog (m dim : ℕ) (P coverLog : ℝ) : ℝ := + allocatedFourierLogBudget m P + coverLog + canonicalProjectionRowCost m dim + +theorem exists_allocatedCanonicalProjection_budget (m dim : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ P coverLog : ℝ, 0 ≤ P → 0 ≤ coverLog → + allocatedCanonicalProjectionLog m dim P coverLog ≤ (P + coverLog + A) ^ A := by + obtain ⟨a, ha, hfourier⟩ := exists_allocatedFourierLogBudget_bound m + let polynomial : Polynomial ℕ := + (Polynomial.X + Polynomial.C a) ^ a + Polynomial.X + + Polynomial.C (canonicalProjectionRowCost m dim) + obtain ⟨A, hA, hbound⟩ := exists_natPolynomial_eval_budget polynomial + refine ⟨A, hA, ?_⟩ + intro P coverLog hP hcoverLog + have hpow : (P + a) ^ a ≤ (P + coverLog + a) ^ a := by + gcongr + linarith only [hcoverLog] + have hpoly := hbound (P + coverLog) (add_nonneg hP hcoverLog) + have hle : allocatedCanonicalProjectionLog m dim P coverLog ≤ + (P + coverLog + a) ^ a + (P + coverLog) + canonicalProjectionRowCost m dim := by + unfold allocatedCanonicalProjectionLog + linarith only [hfourier P hP, hpow, hP] + apply hle.trans + simpa [polynomial, Polynomial.eval₂_pow] using hpoly + +theorem exists_allocatedCanonicalProjection_composed_budget (m dim Acover : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ P : ℝ, 0 ≤ P → + let coverLog := (P + (dim + 2 : ℕ) + Acover) ^ Acover + let Aproj := Classical.choose (exists_allocatedCanonicalProjection_budget m dim) + coverLog ≤ (P + C) ^ C ∧ + (P + coverLog + Aproj) ^ Aproj ≤ (P + C) ^ C := by + let Aproj := Classical.choose (exists_allocatedCanonicalProjection_budget m dim) + let coverPolynomial : Polynomial ℕ := + (Polynomial.X + Polynomial.C (dim + 2) + Polynomial.C Acover) ^ Acover + let densityPolynomial : Polynomial ℕ := + (Polynomial.X + coverPolynomial + Polynomial.C Aproj) ^ Aproj + obtain ⟨C, hC, hbound⟩ := + exists_natPolynomial_eval_budget (coverPolynomial + densityPolynomial) + refine ⟨C, hC, ?_⟩ + intro P hP coverLog Aprojection + have hsum : coverLog + (P + coverLog + Aprojection) ^ Aprojection ≤ (P + C) ^ C := by + simpa [coverPolynomial, densityPolynomial, Polynomial.eval₂_pow, coverLog, + Aprojection, Aproj] using hbound P hP + have hcover : 0 ≤ coverLog := by dsimp [coverLog]; positivity + have hdensity : 0 ≤ (P + coverLog + Aprojection) ^ Aprojection := by positivity + exact ⟨(le_add_of_nonneg_right hdensity).trans hsum, + (le_add_of_nonneg_left hcover).trans hsum⟩ + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (C V : Fin m → ℝ≥0) + +theorem AllocatedSourceNumerics.canonical_projection_bounds + {P : ℝ} (h : AllocatedSourceNumerics B U b S C V P) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (dim : ℕ) {coverLog : ℝ} (hcoverLog : 0 ≤ coverLog) : + let A := Classical.choose (exists_allocatedCanonicalProjection_budget m dim) + let budget := (P + coverLog + A) ^ A + let cap := (allocatedAmbientFactorCap (G := G) B R σ S.value V : ℝ) ^ + Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) + let densityLip : ℝ≥0 := Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) * + allocatedAmbientFactorLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V * + allocatedAmbientFactorCap (G := G) B R σ S.value V ^ + Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) + let sectionLip : ℝ≥0 := Fintype.card (Finset (Fin dim)) * Real.toNNReal (Real.exp coverLog) + let reconstructionLip : ℝ≥0 := + ∑ j : Fin m, (Fintype.card (BoundedBooleanJet (Fin dim) (j.val + 1)) : ℝ≥0) + cap ≤ Real.exp budget ∧ + ((densityLip * sectionLip * reconstructionLip : ℝ≥0) : ℝ) ≤ Real.exp budget := by + intro A budget cap densityLip sectionLip reconstructionLip + have hinput := allocatedCoefficient_fourier_input_budget (J := J) B R σ S.value S.positive C V + h.nonneg h.degree h.variable_count hR hσ h.radius_inv h.width_inv h.coefficients + h.real_axes h.integer_axes h.ambient_axes h.profile h.length h.chart h.covolume + have hdensity : (densityLip : ℝ) ≤ Real.exp (allocatedFourierLogBudget m P) := + hinput.2.2.2 + have hpoly : allocatedCanonicalProjectionLog m dim P coverLog ≤ budget := + (Classical.choose_spec (exists_allocatedCanonicalProjection_budget m dim)).2 P coverLog + h.nonneg hcoverLog + have hfourier : allocatedFourierLogBudget m P ≤ + allocatedCanonicalProjectionLog m dim P coverLog := by + unfold allocatedCanonicalProjectionLog + exact (le_add_of_nonneg_right hcoverLog).trans + (le_add_of_nonneg_right (Nat.cast_nonneg _)) + have hrowCost : (canonicalProjectionRowCost m dim : ℝ) ≤ + Real.exp (canonicalProjectionRowCost m dim) := by + linarith only [Real.add_one_le_exp (canonicalProjectionRowCost m dim : ℝ)] + have hroweq : (sectionLip : ℝ) * reconstructionLip = + Real.exp coverLog * (canonicalProjectionRowCost m dim : ℝ) := by + simp only [sectionLip, reconstructionLip, canonicalProjectionRowCost, + NNReal.coe_mul, NNReal.coe_natCast, NNReal.coe_sum, Real.coe_toNNReal, + Real.exp_nonneg, Nat.cast_mul, Nat.cast_sum] + ring + refine ⟨hinput.2.2.1.trans (Real.exp_le_exp.mpr (hfourier.trans hpoly)), ?_⟩ + calc + _ = (densityLip : ℝ) * ((sectionLip : ℝ) * reconstructionLip) := by + simp only [NNReal.coe_mul, mul_assoc] + _ = (densityLip : ℝ) * (Real.exp coverLog * (canonicalProjectionRowCost m dim : ℝ)) := by rw [hroweq] + _ ≤ Real.exp (allocatedFourierLogBudget m P) * + (Real.exp coverLog * Real.exp (canonicalProjectionRowCost m dim)) := by + gcongr + _ = Real.exp (allocatedCanonicalProjectionLog m dim P coverLog) := by + simp only [allocatedCanonicalProjectionLog, Real.exp_add] + ring + _ ≤ _ := Real.exp_le_exp.mpr hpoly + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCanonicalSlicedConstructedProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCanonicalSlicedConstructedProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..95eaaad333fa0f6ce68813ceb884978f616bf238 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCanonicalSlicedConstructedProjection.lean @@ -0,0 +1,285 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRowsAmbientProjectedFamilyMultiple +import OAI.Combinatorics.Progressions.Estimates.AllocatedSlicedRowsProjectedSource + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal +universe uX + +def AllocatedSlicedSourceProjection {m q : ℕ} {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + (x : G → IntegerScalarCubeBox (Fin q) S.value) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C V : Fin m → ℝ≥0) + (d : ℕ) + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U b S) → + EuclideanJetLayers U (fun j => {t : Finset (Fin q) // t ∈ boundedBooleanJetRows (Fin q) (j.val + 1)}) → ℝ) + (Asample : ℕ) (P : ℝ) : Prop := + ∀ {W : ℝ}, 1 ≤ P → ∀ (_hm : (m : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W) + (_hWP : W ≤ Real.exp P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + {X : Type uX} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (N : X → ℕ) (hN : ∀ i, 0 < N i) (_hsize : ∀ d, Real.exp ((P + Asample) ^ Asample) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + Asample) ^ Asample) ≤ rank) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let widths := narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + let Z := selectedJointDensityMass bases stride T widths + (allocatedJointBaseDensity B U b hb o hR hσ S X p hm) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight stride T widths z, + (|Z - 1| ≤ Real.exp (-P) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (law : FiniteProbabilityWeights (PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U b S))) (signal : (X → ℤ) → ℂ), + (∀ v, ‖signal v‖ ≤ 1) → ∀ {κ : ℝ}, + κ ≤ (law.complexMean (fun y => allocatedSlicedTupleValue B U b hb o hR hσ S X p hm + N hN _hW _hτ _hξ stride T hmass bases x y signal)).re → + ∃ base ∈ bases, + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T widths + (narrowTrimmedSpatialWidths_pos _hW _hτ _hξ N hN) hmass z).toReal : ℂ) * + (physicalCubeSiteTest (integerSelfSiteTest q signal) (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) base z) * + (g y (physicalCubeRowSample U d (fun j => + (Subtype.val : {t : Finset (Fin q) // t ∈ boundedBooleanJetRows (Fin q) (j.val + 1)} → Finset (Fin q))) p hm + (physicalCubeRootDifferences (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) base z)) : ℂ)) + κ - Real.exp (-P) ≤ (law.complexMean projected / (Z : ℂ)).re + +theorem exists_allocated_sliced_constructed_projection (m q : ℕ) : + ∃ A Asample : ℕ, 2 ≤ A ∧ 2 ≤ Asample ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + (x : G → IntegerScalarCubeBox (Fin q) S.value) + {P : ℝ} (_hP : 0 ≤ P) (_hG : (Fintype.card G : ℝ) ≤ P) + (_hL : (S.value : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M), + ∀ (period : ℕ), 0 < period → (period : ℝ) ≤ Real.exp P → + ∃ d : ℕ, period ∣ d ∧ 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + (q + 2 : ℕ) + A) ^ A) ∧ + ∀ [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin q) U)] + [MeasurableSpace (CoefficientTorus (K := Fin q) U)] + [BorelSpace (CoefficientTorus (K := Fin q) U)] + (μrows : Measure (CoefficientTorus (K := Fin q) U)) + [μrows.IsAddLeftInvariant] [IsProbabilityMeasure μrows], + let density := allocatedCoefficientDensity B U b hb o hR hσ S + let cap := (allocatedAmbientFactorCap (G := G) B R σ S.value V : ℝ) ^ + Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) + let cover := quotientIntegerCover (coefficientIntegerLattice U) d + let ξ := Measure.pi (fun j => Measure.pi (fun _ : {s : Finset (Fin q) // s ∈ boundedBooleanJetRows (Fin q) (j.val + 1)} => ν j)) + let densityLip := Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) * + allocatedAmbientFactorLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V * + allocatedAmbientFactorCap (G := G) B R σ S.value V ^ + Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) + let sectionLip := (Fintype.card (Finset (Fin q)) : ℝ≥0) * + Real.toNNReal (Real.exp ((P + (q + 2 : ℕ) + A) ^ A)) + let reconstructionLip := ∑ j : Fin m, (Fintype.card (BoundedBooleanJet (Fin q) (j.val + 1)) : ℝ≥0) + let Row := fun j : Fin m => {s : Finset (Fin q) // s ∈ boundedBooleanJetRows (Fin q) (j.val + 1)} + let Tuple := PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U b S) + ∃ g : Tuple → EuclideanJetLayers U Row → ℝ, + (∀ y, Continuous (g y)) ∧ + (∀ y z, g y z ∈ Set.Icc (0 : ℝ) cap) ∧ + (∀ y, Integrable (g y) ξ) ∧ + (∀ y, (∫ z, g y z ∂ξ) = 1) ∧ + (∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) + (fun j => (Subtype.val : Row j → Finset (Fin q)))) = realDensityMeasure ξ (g y)) ∧ + (∀ y, physicalDensityProjection.{_, _, uX, 0} U (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) d density + (fun z => g y ((physicalRowsStandardEquiv U).symm z))) ∧ + (∀ y, ∃ F : (JetAmbientIndex Row J → UnitAddCircle) → ℂ, + LipschitzWith (densityLip * sectionLip * reconstructionLip) F ∧ + (∀ z, ‖F z‖ ≤ cap) ∧ + ∀ z, (g y z : ℂ) = F (coveredJetAmbientTorus U 1 z)) ∧ + (∀ law : FiniteProbabilityWeights Tuple, + ∃ F : (JetAmbientIndex Row J → UnitAddCircle) → ℂ, + LipschitzWith (densityLip * sectionLip * reconstructionLip) F ∧ + (∀ z, ‖F z‖ ≤ cap) ∧ + ∀ z, law.complexMean (fun y => (g y z : ℂ)) = F (coveredJetAmbientTorus U 1 z)) ∧ + AllocatedSlicedSourceProjection.{uX} B U b S x hb o hR hσ C V d g Asample P := by + obtain ⟨A, hA, hcover⟩ := exists_allocated_rows_ambient_projected_family_multiple m q + obtain ⟨An, hAn, hnorm⟩ := exists_allocated_narrow_normalization m + obtain ⟨Ap, hAp, hprojectSource⟩ := exists_allocated_sliced_rows_projected_source.{uX} m q + refine ⟨A, max An Ap, hA, hAn.trans (le_max_left _ _), ?_⟩ + intro G _ _ I _ n B _ J _ U b R σ S x P hP hG hL M hperiod period hp hpP + obtain ⟨d, hdiv, hd, hdb, hconstruct⟩ := hcover B U b S (fun _ => 0) x hP hG + (fun _ => by simpa using Real.exp_nonneg P) hL hperiod period hp hpP + refine ⟨d, hdiv, hd, hdb, ?_⟩ + intro _ _ _ _ _ _ hb o hR hσ C V hC hV hσ1 Cinv hCinv hchart hsmall μ _ _ ν _ _ + _ _ _ μrows _ _ density cap cover ξhaar densityLip sectionLip reconstructionLip Row Tuple + obtain ⟨g, hgc, hgb, hgi, hgm, hglaw, hprojection, hambient, hmean⟩ := + hconstruct hb o hR hσ C V hC hV hσ1 Cinv hCinv hchart hsmall μ ν μrows + refine ⟨g, hgc, hgb, hgi, hgm, hglaw, hprojection, hambient, hmean, ?_⟩ + unfold AllocatedSlicedSourceProjection + intro W hPone hmSize hK hW hroot hWP hRP hσP hcount hI hn hJ hAP hCP hVP + X _ _ hX hdim p hpoly hm stride hs hsP τ ξ hτ hτP hξ hξ1 hξP N hN hsize + rank hrank hRank T hT bases hbases widths Z + have hnCut := Real.exp_le_exp.mpr (shifted_power_self_mono hP (by omega : 1 ≤ An) + (le_max_left An Ap)) + have hpCut := Real.exp_le_exp.mpr (shifted_power_self_mono hP (by omega : 1 ≤ Ap) + (le_max_right An Ap)) + obtain ⟨hwidths, hmass, _, hglobal⟩ := hnorm B U b S hb o μ ν hR hσ hσ1 C V hC hV + Cinv hCinv hchart hsmall hP hmSize hK hX hdim hRP hσP hcount hI hn hJ hAP hL hCP hVP + p hpoly hm stride hs hsP hW hWP hτ hτP hξ hξ1 hξP N (fun i => hnCut.trans (hsize i)) + hrank (hnCut.trans hRank) T hT + have hnormal := hglobal bases hbases + change |Z - 1| ≤ Real.exp (-P) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ + 0 < Z ∧ Z⁻¹ ≤ 2 at hnormal + refine ⟨hmass, hnormal, ?_⟩ + intro law signal hsignal κ hsource + have hZi : Z⁻¹ ≤ Real.exp P := hnormal.2.2.2.trans + (by linarith [Real.add_one_le_exp P]) + exact hprojectSource B U b S x hb o hR hσ C V hC hV hσ1 Cinv hCinv hchart hsmall + hP hmSize hK hW hroot hWP hL hRP hσP hcount hI hn hJ hAP hCP hVP hperiod hX hdim + p hpoly hm stride hs hsP hτ hτP hξ hξ1 hξP N hN (fun i => hpCut.trans (hsize i)) + hrank (hpCut.trans hRank) signal hsignal T hT bases hbases d g hprojection hwidths hmass law + hnormal.2.2.1 hZi hsource + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal +universe uX + +theorem exists_allocated_canonical_constructed_projection (m q : ℕ) : + ∃ A Asample : ℕ, 2 ≤ A ∧ 2 ≤ Asample ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + (x : G → IntegerScalarCubeBox (Fin q) S.value) + {P : ℝ} (_hP : 0 ≤ P) (_hG : (Fintype.card G : ℝ) ≤ P) + (_hL : (S.value : ℝ) ≤ Real.exp P) + {M : ℕ} (selection : Fin q ↪ G) + (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) + {Pk : ℝ} (_hMk : (M : ℝ) ≤ Real.exp Pk) (_hPk : ((m + 1 : ℕ) : ℝ) * Pk ≤ P), + let period := kernelPeriodCandidate (m + 1) (goodKernelUniformCandidate selection x hx m) + + ∃ d : ℕ, period ∣ d ∧ 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + (q + 2 : ℕ) + A) ^ A) ∧ + ∀ [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin q) U)] + [MeasurableSpace (CoefficientTorus (K := Fin q) U)] + [BorelSpace (CoefficientTorus (K := Fin q) U)] + (μrows : Measure (CoefficientTorus (K := Fin q) U)) + [μrows.IsAddLeftInvariant] [IsProbabilityMeasure μrows], + let density := allocatedCoefficientDensity B U b hb o hR hσ S + let cap := (allocatedAmbientFactorCap (G := G) B R σ S.value V : ℝ) ^ + Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) + let cover := quotientIntegerCover (coefficientIntegerLattice U) d + let ξ := Measure.pi (fun j => Measure.pi (fun _ : {s : Finset (Fin q) // s ∈ boundedBooleanJetRows (Fin q) (j.val + 1)} => ν j)) + let densityLip := Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) * + allocatedAmbientFactorLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V * + allocatedAmbientFactorCap (G := G) B R σ S.value V ^ + Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) + let sectionLip := (Fintype.card (Finset (Fin q)) : ℝ≥0) * + Real.toNNReal (Real.exp ((P + (q + 2 : ℕ) + A) ^ A)) + let reconstructionLip := ∑ j : Fin m, (Fintype.card (BoundedBooleanJet (Fin q) (j.val + 1)) : ℝ≥0) + let Row := fun j : Fin m => {s : Finset (Fin q) // s ∈ boundedBooleanJetRows (Fin q) (j.val + 1)} + let Tuple := PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U b S) + ∃ g : Tuple → EuclideanJetLayers U Row → ℝ, + (∀ y, Continuous (g y)) ∧ + (∀ y z, g y z ∈ Set.Icc (0 : ℝ) cap) ∧ + (∀ y, Integrable (g y) ξ) ∧ + (∀ y, (∫ z, g y z ∂ξ) = 1) ∧ + (∀ y, (realDensityMeasure μ (fun z => density (cover z))).map + (euclideanCoefficientJetMap U (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) + (fun j => (Subtype.val : Row j → Finset (Fin q)))) = realDensityMeasure ξ (g y)) ∧ + (∀ y, physicalDensityProjection.{_, _, uX, 0} U (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) d density + (fun z => g y ((physicalRowsStandardEquiv U).symm z))) ∧ + (∀ y, ∃ F : (JetAmbientIndex Row J → UnitAddCircle) → ℂ, + LipschitzWith (densityLip * sectionLip * reconstructionLip) F ∧ + (∀ z, ‖F z‖ ≤ cap) ∧ + ∀ z, (g y z : ℂ) = F (coveredJetAmbientTorus U 1 z)) ∧ + (∀ law : FiniteProbabilityWeights Tuple, + ∃ F : (JetAmbientIndex Row J → UnitAddCircle) → ℂ, + LipschitzWith (densityLip * sectionLip * reconstructionLip) F ∧ + (∀ z, ‖F z‖ ≤ cap) ∧ + ∀ z, law.complexMean (fun y => (g y z : ℂ)) = F (coveredJetAmbientTorus U 1 z)) ∧ + AllocatedSlicedSourceProjection.{uX} B U b S x hb o hR hσ C V d g Asample P := by + obtain ⟨A, Asample, hA, hAsample, hconstruct⟩ := exists_allocated_sliced_constructed_projection.{uX} m q + refine ⟨A, Asample, hA, hAsample, ?_⟩ + intro G _ _ I _ n B _ J _ U b R σ S x P hP hG hL M selection hx Pk hMk hPk period + exact hconstruct B U b S x hP hG hL hx.2 period (kernelPeriodCandidate_pos _ _) + ((kernelPeriodCandidate_le_exp hMk _ _).trans (Real.exp_le_exp.mpr hPk)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCenteredMeasurableFramedBadTail.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCenteredMeasurableFramedBadTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cd5f5c7fd9abab2ba0f1c2626024e513e036bbe --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCenteredMeasurableFramedBadTail.lean @@ -0,0 +1,556 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedCenteredMeasurableBadTail + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + +def allocatedJointFrameRead {R : Type*} [Add R] (a : X → R) + (f : AllocatedActualCoefficientIndex G X I E n B → R) : + AllocatedActualCoefficientIndex G X I E n B → R + | .inl (none,x) => a x + f (.inl (none,x)) + | .inl (some k,x) => f (.inl (some k,x)) + | .inr k => f (.inr k) + +theorem allocatedJointFrameRead_noise (a : X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedReadNoise (allocatedJointFrameRead a f) = + fun t => BooleanCubeKernel.jointIntegerFrame (a, allocatedReadNoise f) t.1 t.2 := by + funext t + rcases t with ⟨k,x⟩ + cases k <;> rfl + +@[simp] theorem allocatedJointFrameRead_noise_some {R : Type*} [Add R] (a : X → R) + (f : AllocatedActualCoefficientIndex G X I E n B → R) + (k : LayerSamplerVariables G I n B) (x : X) : + allocatedReadNoise (allocatedJointFrameRead a f) (some k,x) = + allocatedReadNoise f (some k,x) := rfl + +@[simp] theorem allocatedJointFrameRead_deck {R : Type*} [Add R] (a : X → R) + (f : AllocatedActualCoefficientIndex G X I E n B → R) : + allocatedReadDeck (allocatedJointFrameRead a f) = allocatedReadDeck f := rfl + +@[simp] theorem allocatedJointFrameRead_projection {R : Type*} [Add R] (a : X → R) + (f : AllocatedActualCoefficientIndex G X I E n B → R) : + allocatedReadProjection (allocatedJointFrameRead a f) = allocatedReadProjection f := rfl + +theorem allocatedJointFrameRead_reduce (M : ℕ) (a : X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + (fun i => ((allocatedJointFrameRead a f i : ℤ) : ZMod M)) = + allocatedJointFrameRead (fun x => (a x : ZMod M)) (fun i => (f i : ZMod M)) := by + funext i + rcases i with ⟨k,x⟩ | k + · cases k + · exact Int.cast_add _ _ + · rfl + · rfl + +variable [Fintype G] [∀ j, Fintype (I j)] [∀ a, Fintype (B a)] + +theorem allocatedOriginalCongruenceTop_congr_slopes + (inactive : LayerSamplerAxis I n → Prop) (M : ℕ) + (f g : AllocatedActualCoefficientIndex G X I E n B → ZMod M) + (hnoise : ∀ (k : LayerSamplerVariables G I n B) (x : X), + allocatedReadNoise f (some k,x) = allocatedReadNoise g (some k,x)) + (hdeck : allocatedReadDeck f = allocatedReadDeck g) + (hinteger : ∀ (j : Fin m) (i : Fin (n j)), + allocatedReadProjection f ⟨j,Sum.inr i⟩ = allocatedReadProjection g ⟨j,Sum.inr i⟩) + (j : Fin m) (v : LayerSamplerVariables G I n B → ZMod M) + (o : AllocatedCongruenceRankOutput X E inactive j) : + allocatedOriginalTaggedTop inactive j (allocatedReadNoise f) (allocatedReadDeck f) + (fun a => allocatedReadProjection f ⟨j,a.val⟩) v + (allocatedCongruenceOutputEmbedding inactive j o) = + allocatedOriginalTaggedTop inactive j (allocatedReadNoise g) (allocatedReadDeck g) + (fun a => allocatedReadProjection g ⟨j,a.val⟩) v + (allocatedCongruenceOutputEmbedding inactive j o) := by + rcases o with x | i | a + · exact spatialRankPolynomial_conditioned_top_congr (allocatedLongEmbedding inactive) + (fun k => allocatedReadNoise f (k,x.val)) (fun k => allocatedReadNoise g (k,x.val)) + (fun k => hnoise k x.val) v v + · simp only [allocatedCongruenceOutputEmbedding_deck, allocatedOriginalTaggedTop, hdeck] + · simp only [allocatedCongruenceOutputEmbedding_integer, allocatedOriginalTaggedTop, hinteger] + +variable [Fintype X] [∀ j, Fintype (E j)] + +theorem allocatedResidueModulusBad_congr_slopes + (inactive : LayerSamplerAxis I n → Prop) (C : ℝ) (M : ℕ) [NeZero M] + (f g : AllocatedActualCoefficientIndex G X I E n B → ZMod M) + (hnoise : ∀ (k : LayerSamplerVariables G I n B) (x : X), + allocatedReadNoise f (some k,x) = allocatedReadNoise g (some k,x)) + (hdeck : allocatedReadDeck f = allocatedReadDeck g) + (hinteger : ∀ (j : Fin m) (i : Fin (n j)), + allocatedReadProjection f ⟨j,Sum.inr i⟩ = allocatedReadProjection g ⟨j,Sum.inr i⟩) : + allocatedResidueModulusBad inactive C M f = allocatedResidueModulusBad inactive C M g := by + unfold allocatedResidueModulusBad + simp only [allocatedOriginalCongruenceTop_congr_slopes inactive M f g hnoise hdeck hinteger] + +theorem allocatedActualModulusBad_jointFrame + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (M : ℕ) [NeZero M] (a : X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedActualModulusBad inactive spatial kernel block C M (allocatedJointFrameRead a f) = + allocatedActualModulusBad inactive spatial kernel block C M f := by + rw [allocatedActualModulusBad_eq_residue, allocatedActualModulusBad_eq_residue, + allocatedJointFrameRead_reduce] + exact allocatedResidueModulusBad_congr_slopes inactive C M _ _ (fun _ _ => rfl) rfl (fun _ _ => rfl) + +theorem allocatedJointFrameRead_rankBad + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) (p d : ℕ) + (a : X → ℤ) (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedCongruenceRankBad inactive + (allocatedReadNoise (allocatedJointFrameRead a f)) (allocatedReadDeck (allocatedJointFrameRead a f)) + (fun j b => allocatedReadProjection (allocatedJointFrameRead a f) ⟨j,b.val⟩) + spatial kernel block P C p d + (allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise (allocatedJointFrameRead a f)) (allocatedReadDeck (allocatedJointFrameRead a f)) + (fun j b => allocatedReadProjection (allocatedJointFrameRead a f) ⟨j,b.val⟩) + spatial kernel block) = + allocatedCongruenceRankBad inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j b => allocatedReadProjection f ⟨j,b.val⟩) spatial kernel block P C p d + (allocatedCongruenceIntegerSelectedCoefficients inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j b => allocatedReadProjection f ⟨j,b.val⟩) spatial kernel block) := by + unfold allocatedCongruenceRankBad smoothResiduePrimeBad + apply propext + apply exists_congr + intro hp + let : NeZero p := inferInstanceAs (NeZero (⟨p,hp⟩ : P).val) + exact (allocatedActualModulusBad_jointFrame inactive spatial kernel block C (p ^ d) a f).to_iff + +theorem allocatedJointFrameRead_badDepth + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) (C : ℝ) (p : ℕ) + (a : X → ℤ) (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedCongruenceBadDepth inactive + (allocatedReadNoise (allocatedJointFrameRead a f)) (allocatedReadDeck (allocatedJointFrameRead a f)) + (fun j b => allocatedReadProjection (allocatedJointFrameRead a f) ⟨j,b.val⟩) + spatial kernel block P A C p = + allocatedCongruenceBadDepth inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j b => allocatedReadProjection f ⟨j,b.val⟩) spatial kernel block P A C p := by + unfold allocatedCongruenceBadDepth largestTestedBadDepth + simp only [allocatedJointFrameRead_rankBad] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] +variable {I E : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +omit [Fintype G] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ a, Fintype (B a)] in + +theorem allocatedReplaceReadNoise_eq_jointFrame + (base : X → ℤ) (z : Option (LayerSamplerVariables G I n B) × X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (hf : allocatedReadNoise f = integerBaseTranslation base + z) : + allocatedReplaceReadNoise B z f = allocatedJointFrameRead (-base) f := by + funext i + rcases i with ⟨k,x⟩ | i + · have h := congrFun hf (k,x) + cases k with + | none => + change z (none,x) = -base x + f (.inl (none,x)) + change f (.inl (none,x)) = base x + z (none,x) at h + omega + | some k => + change z (some k,x) = f (.inl (some k,x)) + simpa only [allocatedReadNoise, Pi.add_apply, integerBaseTranslation, + baseArrayJoin, Pi.zero_apply, zero_add] using h.symm + · rfl + +variable [Fintype X] + +theorem allocatedReplaceReadNoise_modulusBad + (base : X → ℤ) (z : Option (LayerSamplerVariables G I n B) × X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (hf : allocatedReadNoise f = integerBaseTranslation base + z) + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,b.val⟩) + (C : ℝ) (M : ℕ) [NeZero M] : + allocatedActualModulusBad inactive spatial kernel block C M (allocatedReplaceReadNoise B z f) = + allocatedActualModulusBad inactive spatial kernel block C M f := by + rw [allocatedReplaceReadNoise_eq_jointFrame B base z f hf] + exact allocatedActualModulusBad_jointFrame inactive spatial kernel block C M (-base) f + +theorem allocatedReplaceReadNoise_primeBad + (base : X → ℤ) (z : Option (LayerSamplerVariables G I n B) × X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (hf : allocatedReadNoise f = integerBaseTranslation base + z) + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,b.val⟩) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) (p d : ℕ) : + allocatedActualPrimeBad inactive spatial kernel block P C p d (allocatedReplaceReadNoise B z f) = + allocatedActualPrimeBad inactive spatial kernel block P C p d f := by + rw [allocatedReplaceReadNoise_eq_jointFrame B base z f hf] + exact allocatedJointFrameRead_rankBad inactive spatial kernel block P C p d (-base) f + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical + +section BadDepth +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] +variable (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) + +theorem allocatedActualPrimeBad_jointFrame (p d : ℕ) (a : X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedActualPrimeBad inactive spatial kernel block P C p d (allocatedJointFrameRead a f) = + allocatedActualPrimeBad inactive spatial kernel block P C p d f := by + rw [allocatedActualPrimeBad_eq_rankBad, allocatedActualPrimeBad_eq_rankBad] + exact allocatedJointFrameRead_rankBad inactive spatial kernel block P C p d a f + +theorem allocatedActualPrimeBad_depth_jointFrame (A : ℕ → ℕ) (p : ℕ) (a : X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + largestTestedBadDepth A (allocatedActualPrimeBad inactive spatial kernel block P C) p + (allocatedJointFrameRead a f) = + largestTestedBadDepth A (allocatedActualPrimeBad inactive spatial kernel block P C) p f := by + rw [allocatedActualPrimeBad_depth, allocatedActualPrimeBad_depth] + exact allocatedJointFrameRead_badDepth inactive spatial kernel block P A C p a f + +theorem allocatedActualPrimeBad_product_jointFrame (A : ℕ → ℕ) (a : X → ℤ) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + (∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P C) p (allocatedJointFrameRead a f)) = + ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P C) p f := by + simp only [allocatedActualPrimeBad_depth_jointFrame] + +end BadDepth + +section RecoveredSample +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) +variable (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) +variable (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) +variable (C : ℝ) +variable {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} +variable {c : ∀ j, U j} {a : X → ℤ} +variable {sample : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n} +variable {read : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + AllocatedActualCoefficientIndex G X I E n B → ℤ} + +theorem AllocatedCenteredRecoveredSampleReadAt.jointFrame + (h : AllocatedCenteredRecoveredSampleReadAt B U bW b hb o S hR hσ poly hm + inactive spatial kernel block C center c a sample read) + (z : Option (LayerSamplerVariables G I n B) × X → ℤ) : + allocatedReadNoise (allocatedJointFrameRead a (read z)) = + (fun t => jointIntegerFrame (a,z) t.1 t.2) ∧ + allocatedReadDeck (allocatedJointFrameRead a (read z)) = allocatedReadDeck (read z) ∧ + allocatedReadProjection (allocatedJointFrameRead a (read z)) = allocatedReadProjection (read z) ∧ + (allocatedCenteredJointDensity B U b hb o hR hσ S poly hm center a z ≠ 0 → + canonicalCoefficientSample U b hb o (sample z) = + affineSampleCoefficientTorus U (fun j => subtractConstant (c j).val (poly j)) + (fun j => coefficients_subtractConstant_mem (U j) (c j) (poly j) (hm j)) + (fun k x => (jointIntegerFrame (a,z) k x : ℝ)) ∧ + (∀ j, mixedArrayInChart (euclideanSubspace (U j)) (b j) (o j) (sample z j) ∧ + mixedArraySupported (allocatedLayerCenters B U b S j) + (allocatedLayerWidths B U b S j) (allocatedLayerIntegerPMFs B U b hR hσ S j) (sample z j)) ∧ + (∀ d, |coefficientSamplerAmbientPoint U b o (sample z) d| < 1/2) ∧ + (∀ (j : Fin m) (i : Fin (n j)) + (e : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)), + allocatedReadProjection (allocatedJointFrameRead a (read z)) ⟨j, Sum.inr i⟩ e = + (sample z j).2 i e)) := by + refine ⟨?_, rfl, rfl, ?_⟩ + · rw [allocatedJointFrameRead_noise, (h z).1] + · intro hz + have hs := (h z).2 hz + refine ⟨?_, hs.2.1, hs.2.2.1, hs.2.2.2.1⟩ + exact hs.1.trans (affineSampleCoefficientTorus_joint_frame U + (fun j => subtractConstant (c j).val (poly j)) + (fun j => coefficients_subtractConstant_mem (U j) (c j) (poly j) (hm j)) a z) + +end RecoveredSample +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel +open scoped Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) +variable (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) +variable (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) +variable (C : ℝ) +variable {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} +variable {c : ∀ j, U j} {a : X → ℤ} +variable {sample : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n} +variable {read : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + AllocatedActualCoefficientIndex G X I E n B → ℤ} + +theorem AllocatedCenteredRecoveredSampleReadAt.centeredJointFrame_read + (h : AllocatedCenteredRecoveredSampleReadAt B U bW b hb o S hR hσ poly hm + inactive spatial kernel block C center c a sample read) + (z : Option (LayerSamplerVariables G I n B) × X → ℤ) : + allocatedReplaceReadNoise B z (allocatedJointFrameRead a (read z)) = read z := by + funext i + rcases i with i | i + · exact (congrFun (h z).1 i).symm + · rfl + +theorem AllocatedCenteredRecoveredSampleReadAt.centeredJointFrame_cover + (h : AllocatedCenteredRecoveredSampleReadAt B U bW b hb o S hR hσ poly hm + inactive spatial kernel block C center c a sample read) + (z : Option (LayerSamplerVariables G I n B) × X → ℤ) + (hz : allocatedCenteredJointDensity B U b hb o hR hσ S poly hm center a z ≠ 0) + (q : ℕ) [NeZero q] + (event : CoefficientChartResidues (LayerSamplerVariables G I n B) n E q → Prop) : + coefficientDeckChartEvent U bW b hb o q event + (affineCoefficientCoverSample U (fun j => subtractConstant (c j).val (poly j)) + (fun j => coefficients_subtractConstant_mem (U j) (c j) (poly j) (hm j)) q + (fun k x => (jointIntegerFrame (a,z) k x : ℝ))) ↔ + event (allocatedReadCoefficientChartResidues + (fun i => (allocatedReplaceReadNoise B z + (allocatedJointFrameRead a (read z)) i : ZMod q))) := by + have hs := ((h z).2 hz).2.2.2.2.1 q (NeZero.pos q) event + rw [h.centeredJointFrame_read B U bW b hb o S hR hσ poly hm + inactive spatial kernel block C z] + change coefficientDeckChartEvent U bW b hb o q event + (affineCoefficientCoverSample U + (fun j => translate (fun x => (a x : ℝ)) (subtractConstant (c j).val (poly j))) + (fun j => coefficients_translate_mem (U j) (fun x => (a x : ℝ)) + (subtractConstant (c j).val (poly j)) + (coefficients_subtractConstant_mem (U j) (c j) (poly j) (hm j))) q + (fun k x => (z (k,x) : ℝ))) ↔ + event (allocatedReadCoefficientChartResidues (fun i => (read z i : ZMod q))) at hs + rw [affineCoefficientCoverSample_joint_frame] at hs + exact hs + +theorem AllocatedCenteredRecoveredSampleReadAt.centeredJointFrame_recovery + (h : AllocatedCenteredRecoveredSampleReadAt B U bW b hb o S hR hσ poly hm + inactive spatial kernel block C center c a sample read) + (z : Option (LayerSamplerVariables G I n B) × X → ℤ) + (hz : allocatedCenteredJointDensity B U b hb o hR hσ S poly hm center a z ≠ 0) : + allocatedReadNoise (allocatedReplaceReadNoise B z + (allocatedJointFrameRead a (read z))) = z ∧ + canonicalCoefficientSample U b hb o (sample z) = + affineSampleCoefficientTorus U (fun j => subtractConstant (c j).val (poly j)) + (fun j => coefficients_subtractConstant_mem (U j) (c j) (poly j) (hm j)) + (fun k x => (jointIntegerFrame (a,z) k x : ℝ)) ∧ + (∀ j, mixedArrayInChart (euclideanSubspace (U j)) (b j) (o j) (sample z j) ∧ + mixedArraySupported (allocatedLayerCenters B U b S j) + (allocatedLayerWidths B U b S j) (allocatedLayerIntegerPMFs B U b hR hσ S j) + (sample z j)) ∧ + (∀ d, |coefficientSamplerAmbientPoint U b o (sample z) d| < 1/2) ∧ + (∀ (j : Fin m) (i : Fin (n j)) + (e : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)), + allocatedReadProjection (allocatedReplaceReadNoise B z + (allocatedJointFrameRead a (read z))) ⟨j, Sum.inr i⟩ e = (sample z j).2 i e) ∧ + (∀ (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ event : CoefficientChartResidues (LayerSamplerVariables G I n B) n E q → Prop, + coefficientDeckChartEvent U bW b hb o q event + (affineCoefficientCoverSample U (fun j => subtractConstant (c j).val (poly j)) + (fun j => coefficients_subtractConstant_mem (U j) (c j) (poly j) (hm j)) q + (fun k x => (jointIntegerFrame (a,z) k x : ℝ))) ↔ + event (allocatedReadCoefficientChartResidues + (fun i => (allocatedReplaceReadNoise B z + (allocatedJointFrameRead a (read z)) i : ZMod q)))) := by + have hs := (h.jointFrame B U bW b hb o S hR hσ poly hm + inactive spatial kernel block C z).2.2.2 hz + refine ⟨rfl, hs.1, hs.2.1, hs.2.2.1, hs.2.2.2, ?_⟩ + intro q hq + let : NeZero q := ⟨hq.ne'⟩ + exact h.centeredJointFrame_cover B U bW b hb o S hR hσ poly hm + inactive spatial kernel block C z hz q + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule MeasureTheory +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] {I E J : Fin m → Type*} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ j, Fintype (J j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ U j) +variable (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) +variable (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) +variable (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) +variable (rankC : ℝ) +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (c : CoefficientTorus (K := LayerSamplerVariables G I n B) U → ∀ j, U j) +variable (hc : Measurable c) +variable (sample : CoefficientTorus (K := LayerSamplerVariables G I n B) U → (X → ℤ) → + (Option (LayerSamplerVariables G I n B) × X → ℤ) → CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) +variable (read : CoefficientTorus (K := LayerSamplerVariables G I n B) U → (X → ℤ) → + (Option (LayerSamplerVariables G I n B) × X → ℤ) → AllocatedActualCoefficientIndex G X I E n B → ℤ) +variable (hread : ∀ center a, AllocatedCenteredRecoveredSampleReadAt B U bW b hb o S hR hσ poly hm + inactive spatial kernel block rankC center (c center) a (sample center a) (read center a)) +variable (stride : X → ℕ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) +variable (width : Option (LayerSamplerVariables G I n B) × X → ℝ) (hwidth : ∀ z, 0 < width z) +variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells width z) +variable (bases : Finset (X → ℤ)) (hbases : bases.Nonempty) +variable (hD : ∀ center, 0 < selectedJointDensityMass bases stride cells width + (allocatedCenteredJointDensity B U b hb o hR hσ S poly hm center)) +local notation "jointLaw" => (fun center => selectedJointFiniteLaw bases hbases stride cells width hwidth hZ + (allocatedCenteredJointDensity B U b hb o hR hσ S poly hm center) + (allocatedCenteredJointDensity_nonneg B U b hb o hR hσ S poly hm center) (hD center)) +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) [IsProbabilityMeasure μ] +variable (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) (cutoff : ℕ) + +omit [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] in +theorem allocatedCentered_joint_weight_measurable : ∀ x, Measurable (fun center => (jointLaw center).weight x) := + selectedJointFiniteLaw_weight_measurable bases hbases stride cells width hwidth hZ + (allocatedCenteredJointDensity B U b hb o hR hσ S poly hm) + (allocatedCenteredJointDensity_measurable_center B U b hb o hR hσ S poly hm) + (allocatedCenteredJointDensity_nonneg B U b hb o hR hσ S poly hm) hD + +omit [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] in +include hread in +theorem allocatedCentered_joint_positive_rankCertificate : ∀ center (x : bases × rectangularWeightIndices 0 width 1), + 0 < (jointLaw center).weight x → + AllocatedPhysicalRankReadCertificate B U bW b hb o + (allocatedCenteredConditionalPolynomial U poly (c center) x.1.val) + (allocatedCenteredConditionalPolynomial_mem U poly hm (c center) x.1.val) + inactive spatial kernel block rankC x.2.val (read center x.1.val x.2.val) := by + intro center x hx + have hdensity := (selectedJointFiniteLaw_support bases hbases stride cells width hwidth hZ + (allocatedCenteredJointDensity B U b hb o hR hσ S poly hm center) + (allocatedCenteredJointDensity_nonneg B U b hb o hR hσ S poly hm center) (hD center) x hx).2.ne' + exact ((hread center x.1.val x.2.val).2 hdensity).2.2.2.2.2 + +include hc hread in + +theorem exists_allocatedCentered_measurable_unframed_bad_tail + {ε : ℝ} (hbound : (centeredFiniteProbabilityMeasure μ jointLaw).real + {z | cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P rankC) p + (read z.1 z.2.1.val z.2.2.val)} ≤ ε) : + ∃ bad : Set (CoefficientTorus (K := LayerSamplerVariables G I n B) U × + (bases × rectangularWeightIndices 0 width 1)), + MeasurableSet bad ∧ (centeredFiniteProbabilityMeasure μ jointLaw).real bad ≤ ε ∧ + ∀ center x, 0 < (jointLaw center).weight x → + (cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P rankC) p + (read center x.1.val x.2.val) ↔ (center,x) ∈ bad) := by + have hweight := allocatedCentered_joint_weight_measurable B U b hb o S hR hσ poly hm + stride cells width hwidth hZ bases hbases hD + have hcertificate := allocatedCentered_joint_positive_rankCertificate B U bW b hb o S hR hσ poly hm + inactive spatial kernel block rankC c sample read hread stride cells width hwidth hZ bases hbases hD + obtain ⟨bad, hbad, hmassbad, heq, _⟩ := exists_allocatedCentered_badProduct_measurable_tail + (C := CoefficientTorus (K := LayerSamplerVariables G I n B) U) + (Ω := bases × rectangularWeightIndices 0 width 1) B U bW b hb o poly hm inactive spatial kernel block rankC c hc + (fun x => x.1.val) (fun x => x.2.val) jointLaw + (fun center x => read center x.1.val x.2.val) hcertificate P A cutoff μ hweight hbound + exact ⟨bad, hbad, hmassbad, heq⟩ + +include hc hread in + +theorem exists_allocatedCentered_measurable_framed_bad_tail + {ε : ℝ} (hbound : (centeredFiniteProbabilityMeasure μ jointLaw).real + {z | cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P rankC) p + (read z.1 z.2.1.val z.2.2.val)} ≤ ε) : + ∃ bad : Set (CoefficientTorus (K := LayerSamplerVariables G I n B) U × + (bases × rectangularWeightIndices 0 width 1)), + MeasurableSet bad ∧ (centeredFiniteProbabilityMeasure μ jointLaw).real bad ≤ ε ∧ + (∀ center x, 0 < (jointLaw center).weight x → + ((center,x) ∈ bad ↔ cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P rankC) p + (allocatedJointFrameRead x.1.val (read center x.1.val x.2.val)))) ∧ + ∀ᵐ z ∂centeredFiniteProbabilityMeasure μ jointLaw, + z ∈ bad ↔ cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P rankC) p + (allocatedJointFrameRead z.2.1.val (read z.1 z.2.1.val z.2.2.val)) := by + have hweight := allocatedCentered_joint_weight_measurable B U b hb o S hR hσ poly hm + stride cells width hwidth hZ bases hbases hD + obtain ⟨bad, hbad, hmassbad, heq⟩ := exists_allocatedCentered_measurable_unframed_bad_tail + B U bW b hb o S hR hσ poly hm inactive spatial kernel block rankC c hc sample read hread + stride cells width hwidth hZ bases hbases hD μ P A cutoff hbound + have hpositive : ∀ center x, 0 < (jointLaw center).weight x → + ((center,x) ∈ bad ↔ cutoff < ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedActualPrimeBad inactive spatial kernel block P rankC) p + (allocatedJointFrameRead x.1.val (read center x.1.val x.2.val))) := by + intro center x hx + rw [allocatedActualPrimeBad_product_jointFrame] + exact (heq center x hx).symm + refine ⟨bad, hbad, hmassbad, hpositive, ?_⟩ + exact (centeredFiniteProbabilityMeasure_ae_positive_weight μ jointLaw hweight).mono + (fun z hz => hpositive z.1 z.2 hz) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCenteredSpatialMatrixExceptional.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCenteredSpatialMatrixExceptional.lean new file mode 100644 index 0000000000000000000000000000000000000000..b470c6d7624b37b4786b57d85db4695bde726fcd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCenteredSpatialMatrixExceptional.lean @@ -0,0 +1,192 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedCenteredNarrowAmplitudeNormalization +import OAI.Combinatorics.Progressions.Estimates.CenteredFiniteNoiseEventBound +import OAI.Combinatorics.Progressions.Estimates.NormalizedDeterminantCutoff +import OAI.Combinatorics.Progressions.Geometry.SelectedJointSpatialCutoff + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +variable {B G P : Type*} [Fintype G] [Fintype P] {n : ℕ} +variable (hn : 0 < n) (e : Fin 2 × Fin n ↪ G) +variable (bases : Finset B) (hbases : bases.Nonempty) +variable (q : Fin n → ℕ) (hq : ∀ x, 0 < q x) +variable (T : Finset (ColumnResiduePattern (Option (G ⊕ P)) (Fin n) q)) +variable (V : Option (G ⊕ P) × Fin n → ℝ) (hV : ∀ z, 0 < V z) +variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) +variable (hscale : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) +variable {ηprior E : ℝ} (hpriorPos : 0 < ηprior) (hE : 0 ≤ E) (hpriorExp : ηprior⁻¹ ≤ Real.exp E) +variable (hwide : ∀ i, Real.exp (smoothMatrixBlockWidthLogBudget (2 * n * n) n 2 E) ≤ + spatialMatrixIndexWidth e q V i) +variable (D : B → (Option (G ⊕ P) × Fin n → ℤ) → ℝ) (hD0 : ∀ a z, 0 ≤ D a z) +variable (hD : 0 < selectedJointDensityMass bases q T V D) +local notation "κ" => spatialMatrixBlockThreshold n ηprior +local notation "cutoff" => spatialMatrixBlockCutoff (P := P) e κ + +include hn hq hscale hpriorPos hE hpriorExp hwide in + +theorem spatialMatrixBlock_joint_tilted_cutoff_bound + {ηnorm εtest : ℝ} + (hmass : ∀ a, |selectedResidueDensityMass q T V (D a) - 1| ≤ ηnorm) + (htest : ∀ a, + |(∑' z, (selectedResidueSmoothPMF q T V hV hZ z).toReal * + (cutoff (fun t => (z t : ℝ) / V t) * D a z)) - + ∑' z, (selectedResidueSmoothPMF q T V hV hZ z).toReal * + cutoff (fun t => (z t : ℝ) / V t)| ≤ εtest) : + (selectedJointFiniteLaw bases hbases q T V hV hZ D hD0 hD).mean + (fun z => if spatialMatrixBlockBad e V (κ / 2) z.2.val then (1 : ℝ) else 0) ≤ + ηprior / 2 + (ηnorm + εtest) := by + have hκ := spatialMatrixBlockThreshold_pos hn hpriorPos + have hprior := spatialMatrixBlock_bad_probability_of_exp_width hn e q hq T V hV hZ hscale + hpriorPos hE hpriorExp hwide + apply selectedJointFiniteLaw_spatial_cutoff_bound bases hbases q T V hV hZ D hD0 hD + cutoff (spatialMatrixBlockCutoff_range e κ) (spatialMatrixBlockBad e V (κ / 2)) + (spatialMatrixBlockBad e V κ) _ hprior hmass htest + intro z hz + apply spatialMatrixBlockCutoff_indicator_bounds e V hκ z + intro t + exact (norm_le_pi_norm (fun t => (z t : ℝ) / V t) t).trans hz + +include hn hq hscale hpriorPos hE hpriorExp hwide in + +theorem spatialMatrixBlock_joint_tilted_cutoff_bound_complex + {ηnorm εtest : ℝ} + (hmass : ∀ a, |selectedResidueDensityMass q T V (D a) - 1| ≤ ηnorm) + (htest : ∀ a, + ‖(∑' z, ((selectedResidueSmoothPMF q T V hV hZ z).toReal : ℂ) * + ((cutoff (fun t => (z t : ℝ) / V t) : ℂ) * (D a z : ℂ))) - + ∑' z, ((selectedResidueSmoothPMF q T V hV hZ z).toReal : ℂ) * + (cutoff (fun t => (z t : ℝ) / V t) : ℂ)‖ ≤ εtest) : + (selectedJointFiniteLaw bases hbases q T V hV hZ D hD0 hD).mean + (fun z => if spatialMatrixBlockBad e V (κ / 2) z.2.val then (1 : ℝ) else 0) ≤ + ηprior / 2 + (ηnorm + εtest) := by + apply spatialMatrixBlock_joint_tilted_cutoff_bound hn e bases hbases q hq T V hV hZ hscale + hpriorPos hE hpriorExp hwide D hD0 hD hmass + intro a + simpa only [← Complex.ofReal_mul, ← Complex.ofReal_tsum, ← Complex.ofReal_sub, + Complex.norm_real, Real.norm_eq_abs] using htest a + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +theorem exists_allocated_centered_spatial_matrix_exceptional (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {nX : ℕ} {G : Type*} [Fintype G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (_hσ1 : ∀ j, σ j ≤ 1) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ≤ V j) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + {P : ℝ} (_hP : 0 ≤ P) (_hmSize : (m : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hX : (nX : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × (Fin nX)) : ℝ) ≤ P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) (_hLP : (S.value : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (p : ∀ j, VectorPolynomial (Fin nX) ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : (Fin nX) → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : (Fin nX) → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {W τ ξ : ℝ} (_hW : 0 ≤ W) (_hWP : W ≤ Real.exp P) + (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (N : (Fin nX) → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) (Fin nX) stride)) (_hT : T.Nonempty), + let widths := narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + let density := allocatedCenteredJointDensity B U basis hb o hR hσ S p hm + ∀ (bases : Finset (Fin nX → ℤ)) (hbases : bases.Nonempty) + (hwidths : ∀ z, 0 < widths z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride T widths z) + (htotal : ∀ center, 0 < selectedJointDensityMass bases stride T widths (density center)) + (_hnX : 0 < nX) (e : Fin 2 × Fin nX ↪ G) + {ηprior Ewidth : ℝ}, 0 < ηprior → 0 ≤ Ewidth → ηprior⁻¹ ≤ Real.exp Ewidth → + (∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth stride widths z) → + (∀ i, Real.exp (smoothMatrixBlockWidthLogBudget (2 * nX * nX) nX 2 Ewidth) ≤ + spatialMatrixIndexWidth e stride widths i) → + 2 / spatialMatrixBlockThreshold nX ηprior * ((nX * nX.factorial : ℕ) : ℝ) ≤ Real.exp P → + let law := fun center => selectedJointFiniteLaw bases hbases stride T widths hwidths hZ + (density center) (allocatedCenteredJointDensity_nonneg B U basis hb o hR hσ S p hm center) + (htotal center) + (centeredFiniteProbabilityMeasure μ law).real + {z | spatialMatrixBlockBad e widths (spatialMatrixBlockThreshold nX ηprior / 2) z.2.2.val} ≤ + ηprior / 2 + 6 * positiveProjectionAccuracy P := by + obtain ⟨A, hA, hnormalization⟩ := exists_allocated_centered_narrow_amplitude_normalization m + refine ⟨A, hA, ?_⟩ + intro nX G _ I _ n B _ J _ U basis R σ S hb o _ _ _ _ μ _ _ ν _ _ + hR hσ hσ1 C V hC hV Cinv hCinv hchart hsmall P hP hmSize hK hX hdim + hRP hσP hcount hI hn hJ hAP hLP hCP hVP p hp hm stride hs hsP W τ ξ hW hWP hτ hτP hξ hξ1 hξP + N hsize rank hrank hRank T hT widths density bases hbases hwidths hZ htotal hnX e + ηprior Ewidth hpriorPos hEwidth hpriorExp hscale hwide hLipBudget law + obtain ⟨_, _, hraw, hmass⟩ := hnormalization B U basis S hb o μ ν hR hσ hσ1 C V hC hV + Cinv hCinv hchart hsmall hP hmSize hK (by simpa only [Fintype.card_fin] using hX) + hdim hRP hσP hcount hI hn hJ hAP hLP hCP hVP p hp hm stride hs hsP hW hWP + hτ hτP hξ hξ1 hξP N hsize hrank hRank T hT + let κ := spatialMatrixBlockThreshold nX ηprior + have hκ : 0 < κ := spatialMatrixBlockThreshold_pos hnX hpriorPos + let amplitude := fun x : Option (LayerSamplerVariables G I n B) × Fin nX → ℝ => + (spatialMatrixBlockCutoff e κ x : ℂ) + have hamp (x) : ‖amplitude x‖ ≤ 1 := by + rw [Complex.norm_real, Real.norm_of_nonneg (spatialMatrixBlockCutoff_range e κ x).1] + exact (spatialMatrixBlockCutoff_range e κ x).2 + have hlip := Complex.isometry_ofReal.lipschitzWith.comp (spatialMatrixBlockCutoff_lipschitz + (P := PrincipalTupleIndex B (layerSamplerDegree I n)) e hκ) + have hlip' : LipschitzWith (⟨2 / κ, by positivity⟩ * ((nX * nX.factorial : ℕ) : ℝ≥0)) + amplitude := by + simpa only [one_mul, Function.comp_def] using hlip + have hweight (z) : Measurable (fun center => (law center).weight z) := + allocatedCenteredJointFiniteLaw_weight_measurable B U basis hb o hR hσ S p hm + bases hbases stride T widths hwidths hZ htotal z + apply centeredFiniteProbabilityMeasure_noise_event_le μ law hweight + (fun z => spatialMatrixBlockBad e widths (κ / 2) z.2.val) + intro center + have h := spatialMatrixBlock_joint_tilted_cutoff_bound_complex hnX e bases hbases stride hs T + widths hwidths hZ hscale hpriorPos hEwidth hpriorExp hwide + (density center) (allocatedCenteredJointDensity_nonneg B U basis hb o hR hσ S p hm center) + (htotal center) (fun base => (hmass center base).1) + (fun base => hraw center base amplitude hamp hlip' + (by change 2 / κ * ((nX * nX.factorial : ℕ) : ℝ) ≤ Real.exp P + exact hLipBudget)) + exact h.trans_eq (by ring) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedChosenDensityProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedChosenDensityProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..f085a8644efa2517cda303857d8704a811461317 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedChosenDensityProjection.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedProjectedChosenComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +universe uX + +theorem exists_allocated_chosen_density_projection (m q : ℕ) : + ∃ a : ℕ, 2 ≤ a ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ v, Fintype (B v)] [∀ v, DecidableEq (B v)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + {p E T : ℝ} (_hp : 0 ≤ p) (_hE : 0 ≤ E) (_hT : 0 ≤ T) + (_hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (_hn : ∀ j, (n j : ℝ) ≤ p) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (_hRi : ∀ j, (R j)⁻¹ ≤ Real.exp p) (_hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp p) + (_hmsp : ((m + 2 : ℕ) : ℝ) ≤ p) + (S : LayerSamplerScale (G := G) B U b R σ) + (_hS : S = allocatedPrimitiveNormalizedScale B U b hR hσ p E T) + (x : G → IntegerScalarCubeBox (Fin q) S.value) + {M : ℕ} (_hM : 0 < M) (_hMp : (M : ℝ) ≤ Real.exp p) + (selection : Fin q ↪ G) (_hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) + (_hq : q ≤ m + 1) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin q) Cinv 1 j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp p) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp p) + {X : Type uX} [Fintype X] [DecidableEq X] (_hXp : (Fintype.card X : ℝ) ≤ p) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + (N stride : X → ℕ) (_hs : ∀ t, 0 < stride t) + {rank τ : ℝ} (_hτ : 0 < τ) (_hτp : 1 / τ ≤ Real.exp p) + (_hstrideT : ∀ t, (stride t : ℝ) ≤ Real.exp T) + (_hsize : ∀ t, Real.exp ((p + E + T + a) ^ a) ≤ (N t : ℝ)) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((p + E + T + a) ^ a) ≤ rank) + (base : X → ℤ) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (_hcells : cells.Nonempty) (D : ℕ) + (f : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U b S) → + EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ), + let density := allocatedCoefficientDensity B U b hb o hR hσ S + ∀ (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, 0} U + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) D density (f y)) + {Z : ℝ} (_hZ : 1 / 2 ≤ Z), + let W : ℝ := Fintype.card (LayerSamplerVariables G I n B) * S.value + let ξ := normalizedTupleNarrowWidth X (PrincipalTupleIndex B (layerSamplerDegree I n)) selection M p E + let widths := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + ∀ (hwidths : ∀ z, 0 < widths z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells widths z), + let law := principalTupleWeights (α := Fin q) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let source := fun y => ∑' z, + ((selectedResidueSmoothPMF stride cells widths hwidths hmass z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) base z) * + (density (affineSampleCoefficientTorus U + (fun j => translate (fun t => (base t : ℝ)) (poly j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (poly j) (hmem j)) + (fun k t => (z (k, t) : ℝ))) : ℂ)) + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride cells widths hwidths hmass z).toReal : ℂ) * + physicalCubePositiveTest U D poly hmem (f y) test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) base z) + ‖law.complexMean source / (Z : ℂ) - law.complexMean projected / (Z : ℂ)‖ ≤ Real.exp (-E) := by + obtain ⟨A₀, _, hprojection⟩ := exists_allocated_original_density_projection m q + obtain ⟨K, _, hthreshold⟩ := exists_allocatedUnifiedSamplingThreshold_bound m q 0 A₀ + obtain ⟨a, ha, hcut⟩ := exists_allocatedChosenThreshold_bound m 0 K + refine ⟨a, ha, ?_⟩ + intro G _ _ I _ _ n B _ _ J _ U b R σ hR hσ p E T hp hE hT hvars hI hn hJ hRi hσi hmsp + S hS x M hM hMp selection hx hq hb o C V hC hV hσ1 Cinv hCinv hchart hsmall hCp hVp + X _ _ hXp poly hpoly hmem N stride hs rank τ hτ hτp hstrideT hsize hrank hRank base test htest + cells hcells D f density hproject Z hZ W ξ widths hwidths hmass law source projected + let P := allocatedChosenScaleBudget m p E T + let Q := allocatedUnifiedSamplingBudget m q 0 P p E + obtain ⟨hP, hpP, _, hTP, hDP, hLogP⟩ := allocatedChosenScaleBudget_bounds m hp hE hT + obtain ⟨_, _, _, hQ, _, hwidth, hPplus, hpQ, hEQ, hnorm⟩ := + allocatedUnifiedSamplingBudget_bounds m q 0 hP hp hE + have hPQ : P ≤ Q := by linarith + have hpExp := Real.exp_le_exp.mpr hpQ + have hPExp := Real.exp_le_exp.mpr hPQ + have hL : (S.value : ℝ) ≤ Real.exp P := by + rw [hS] + exact (allocatedPrimitiveNormalizedScale_upper B U b hR hσ hp hE hT hvars hn hRi hσi).trans + (Real.exp_le_exp.mpr hLogP) + have hcount (j : Fin m) : + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Q := + (boundedCoefficientExponent_card_le_geometricSiteBudget m 0 + (Nat.succ_le_of_lt j.isLt) hp hvars).trans + ((allocatedComparisonDimension_bounds m hp).2.2.2.2.1.trans (hDP.trans hPQ)) + have hmQ : (m : ℝ) ≤ Q := by + have hmp : (m : ℝ) ≤ p := by push_cast at hmsp; linarith + exact hmp.trans hpQ + have hprofile : (probabilityProfileLipschitz : ℝ) ≤ Real.exp Q := by + obtain ⟨_, _, _, _, _, _, _, _, hprofile⟩ := allocatedComparisonDimension_bounds m hp + exact (probabilityProfileLipschitz_le_comparisonProfileBound.trans + (hprofile.trans (hDP.trans hPQ))).trans (by linarith [Real.add_one_le_exp Q]) + have hW : 0 ≤ W := mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + have hroot : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W := by + dsimp only [W, allocatedPhysicalRootBudget] + simp + have hWP : W ≤ Real.exp Q := by + calc + W ≤ Real.exp p * Real.exp P := + mul_le_mul (hvars.trans (by linarith [Real.add_one_le_exp p])) hL + (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = Real.exp (P + p) := by rw [← Real.exp_add, add_comm] + _ ≤ _ := Real.exp_le_exp.mpr hPplus + have hnormdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ Q := by + calc + _ = ((Fintype.card (LayerSamplerVariables G I n B) : ℝ) + 1) * Fintype.card X := by + simp only [Fintype.card_prod, Fintype.card_option, Nat.cast_mul, Nat.cast_add, Nat.cast_one] + _ ≤ (p + 1) * p := mul_le_mul (add_le_add hvars le_rfl) hXp (Nat.cast_nonneg _) (by positivity) + _ = p * (p + 1) := mul_comm _ _ + _ ≤ _ := hnorm + have hGp : (Fintype.card G : ℝ) ≤ p := + (Nat.cast_le.mpr (allocatedKernelVariables_card_le_variables (G := G) B)).trans hvars + have hNp : (Fintype.card (PrincipalTupleIndex B (layerSamplerDegree I n)) : ℝ) ≤ p := + (Nat.cast_le.mpr (allocatedPrincipalIndex_card_le_variables (G := G) B)).trans hvars + have hmsp' : ((m + 1 : ℕ) : ℝ) ≤ p := by push_cast at hmsp ⊢; linarith + have hqsp : ((q + 1 : ℕ) : ℝ) ≤ p := + (Nat.cast_le.mpr (by omega : q + 1 ≤ m + 2)).trans hmsp + have hqcard : (Fintype.card (Unit ⊕ Fin q) : ℝ) ≤ p := by + simpa only [Fintype.card_sum, Fintype.card_unit, Fintype.card_fin, Nat.add_comm 1] using hqsp + have hchoice := normalizedTupleSpatialChoices (N := PrincipalTupleIndex B (layerSamplerDegree I n)) + (X := X) (m := m) selection hM hp hE hmsp' hqsp hGp hXp hMp + have hlog := (normalizedTuple_log_envelopes X (PrincipalTupleIndex B (layerSamplerDegree I n)) + selection hp hE (le_refl (0 : ℝ)) hqcard hGp hNp hXp).1 + have hξQ : ξ⁻¹ ≤ Real.exp Q := + hchoice.2.2.1.trans (Real.exp_le_exp.mpr (hlog.trans hwidth)) + have hcutQ : (Q + A₀) ^ A₀ ≤ (p + E + T + a) ^ a := + (hthreshold hP hp hE).trans (hcut hp hE hT).2.2 + have hZpos : 0 < Z := by linarith + have hZi : Z⁻¹ ≤ (2 : ℝ) := by + have h := one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1 / 2) hZ + simpa only [one_div, inv_inv] using h + have htwo : (2 : ℝ) ≤ Real.exp Q := by + have hp2 : (2 : ℝ) ≤ p := by push_cast at hmsp; linarith [Nat.cast_nonneg (α := ℝ) m] + linarith [Real.add_one_le_exp Q] + have hsmallDensity := allocatedPhysicalChartRadius_density_small B (Fin q) Cinv R + hCinv (fun j => (hR j).le) hsmall + have he := hprojection B U b S (fun _ => 0) x hb o hR hσ C V hC hV hσ1 Cinv hCinv hchart + hsmallDensity hQ hmQ (hvars.trans hpQ) hW hroot hWP (hL.trans hPExp) + (fun j => (hRi j).trans hpExp) (fun j => (hσi j).trans hpExp) hcount + (fun j => (hI j).trans hpQ) (fun j => (hn j).trans hpQ) (fun j => (hJ j).trans hpQ) + hprofile (fun j => (hCp j).trans hpExp) (fun j => (hVp j).trans hpExp) hx.2 + (hXp.trans hpQ) hnormdim poly hpoly hmem base stride hs + (fun t => (hstrideT t).trans (Real.exp_le_exp.mpr (hTP.trans hPQ))) + hτ (by simpa only [one_div] using hτp.trans hpExp) hchoice.1 hchoice.2.1 hξQ + N (fun t => (Real.exp_le_exp.mpr hcutQ).trans (hsize t)) hrank + ((Real.exp_le_exp.mpr hcutQ).trans hRank) test htest cells hcells D f hproject + hZpos (hZi.trans htwo) hwidths hmass + exact he.trans (Real.exp_le_exp.mpr (neg_le_neg hEQ)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCommonKernelLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCommonKernelLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..369b9a71040f236b3d69a2f59bb459db02871876 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedCommonKernelLaw.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedCommonCover + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +theorem allocatedCommonScale_kernel_cutoff {dim : ℕ} [Nonempty (Fin dim)] + {p c P e E Ebad T : ℝ} + (hp : 0 ≤ p) (hc : 0 ≤ c) (hP : 0 ≤ P) (he : 0 ≤ e) (hE : 0 ≤ E) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) + (hdim : (dim : ℝ) ≤ p) (hG : (Fintype.card G : ℝ) ≤ p) + (hbudget : allocatedKernelPrimitiveBudget p Ebad T ≤ P) + {M Dwin : ℕ} (hM : 0 < M) (hDwin : 0 < Dwin) + (hMT : (M : ℝ) ≤ Real.exp T) (hDwinP : (Dwin : ℝ) ≤ Real.exp p) : + let cutoff := scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(Ebad + 1))) + 0 < cutoff ∧ (cutoff : ℝ) ≤ Real.exp P ∧ + cutoff ≤ (allocatedCommonScale (G := G) B U b hR hσ p c P e E).value := by + have hD := (allocatedComparisonDimension_bounds m hp).1 + have hPq := (allocatedCommonScaleNumeric_bounds m hp hc hP hE).2.2.2.1 + obtain ⟨hpos, hcut, hscale⟩ := allocatedIdealScale_kernel_cutoff B U b hR hσ + hp hEbad hT hD he (allocatedSiteKernelMaskLog_nonneg m hP) + (allocatedReferenceIdealError_nonneg m hD hP hE) hdim hG (hbudget.trans hPq) + hM hDwin hMT hDwinP + exact ⟨hpos, hcut.trans (Real.exp_le_exp.mpr hbudget), hscale⟩ + +theorem allocatedCommonScale_affine_bad_probability [DecidableEq G] + {dim : ℕ} [Nonempty (Fin dim)] {p c P e E Ebad T : ℝ} + (hp : 0 ≤ p) (hc : 0 ≤ c) (hP : 0 ≤ P) (he : 0 ≤ e) (hE : 0 ≤ E) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) + (hdim : (dim : ℝ) ≤ p) (hG : (Fintype.card G : ℝ) ≤ p) + (hcard : dim * (dim + 2) ≤ Fintype.card G) (selection : Fin dim ↪ G) + (hbudget : allocatedKernelPrimitiveBudget p Ebad T ≤ P) + (M Dwin : ℕ) (hM : 0 < M) (hDwin : 0 < Dwin) + (hMT : (M : ℝ) ≤ Real.exp T) (hDwinP : (Dwin : ℝ) ≤ Real.exp p) : + let S := allocatedCommonScale (G := G) B U b hR hσ p c P e E + let cutoff := scalarKernelCutoff (Fin dim) G M Dwin (Real.exp (-(Ebad + 1))) + let hlarge := (allocatedCommonScale_kernel_cutoff B U b hR hσ hp hc hP he hE hEbad hT + hdim hG hbudget hM hDwin hMT hDwinP).2.2 + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) (hDwindow : ∀ g, S.value ≤ Dwin * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + (FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M Dwin (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hDwin (Real.exp_pos _) hlarge (hDwindow g)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff x) ≤ Real.exp (-(Ebad + 1)) := by + intro S cutoff hlarge window hwindow hDwindow shift moduli residues hmoduli hmoduliM + exact affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hcard) selection hM hDwin (Real.exp_pos _) S.positive + hlarge window hwindow hDwindow shift moduli residues hmoduli hmoduliM + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedConstructedKernelMixture.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedConstructedKernelMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..c81fea4f7557ad173d5776affb5d9196f176e63f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedConstructedKernelMixture.lean @@ -0,0 +1,391 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedFixedCommonCover + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S + +def AllocatedGenuineKernelData (Psp E e pNum Pbase Qraw p₁ : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (L : ℝ≥0) (Cc : activeAxes → ℝ) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m p₁ w v) + (allocatedOriginalGeometryLog m Psp p₁ w v (E + 1)) + ∀ {Mk : ℕ} (hMk : 0 < Mk) (selection : Fin dim ↪ G) + (_hqDim : dim ≤ m + 1) (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (Qsite : ℝ≥0) + (_hQsite : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Qsite) + (Kcap : ℝ≥0) (_hKcap : ∀ j, (R j)⁻¹ ≤ Kcap) (_hσ1 : ∀ j, σ j ≤ 1) + (_hcoverSmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets Cinv j), + ∃ g : (x : GoodKernel) → (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + (∀ a, ((witnesses q r).expansion a).Term) → + Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ x q r k s, LipschitzWith (max (((Fintype.card activeAxes * L) * Qsite) * + (Kcap * ∑ j, C j * Fintype.card (J j)) * commonSitePeriod (witnesses q r).expansion k) + (4 * commonSitePeriod (witnesses q r).expansion k)) (g x q r k s) ∧ + ∀ z, ‖g x q r k s z‖ ≤ 1) ∧ + (∀ (_x : GoodKernel) q r, (∑ k, ‖coverSiteCoefficient (witnesses q r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + (∀ (_x : GoodKernel) q, allocatedResidueCoverCoefficientMass B U b S (q.val : ℕ) (witnesses q) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, Cc a) ∧ + ∀ + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((E + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp p₁ w v (E + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + ∀ (_hZ : 1 / 2 ≤ Z), + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedSupportedIdealCoverValue B U b hR hσ S (refined x) (witnesses (index x)) + hb o bW (d x) (g x (index x)) δ x.val poly hmem input r + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + ∀ (kernelLaw : FiniteProbabilityWeights Kernel) {η : ℝ}, + kernelLaw.eventProbability (fun x => ¬Good x) ≤ η → + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +local notation "activeAxes" => {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} +local notation "ig" => allocatedGridIntegerAxis B U b S + +theorem allocatedGenuineKernelData_of_cover + {Psp E e pNum Pbase Qraw p₁ : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val) + {L : ℝ≥0} {Cc : activeAxes → ℝ} + (hcover : AllocatedGenuineCoverData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc) : + AllocatedGenuineKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw p₁ hP δ A Kraw Ksite witnesses L Cc := by + unfold AllocatedGenuineKernelData + intro w v Pfinal Mk hMk selection hqDim hMkPsp Kernel Good GoodKernel + have hstart (x : GoodKernel) := hcover x.val hMk selection x.property hqDim hMkPsp + choose d hd hdb hstep using hstart + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + have hperiod (x : GoodKernel) := goodKernel_common_period selection x.val x.property + (m + 1) (by omega) (fun j : Fin m => j.val + 1) (fun j => by omega) + jetRows (fun _ => Subtype.val_injective) (fun _ a => a.property) + choose modulus hmodulus hmodulusSize hspatial hcoefficient using hperiod + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + have hsteps (x : GoodKernel) := hstep x (modulus x) (hmodulus x) + (hmodulusSize x) (hspatial x) (hcoefficient x) + choose pivots hA hinverse hfamily using hsteps + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp Cinv hCinv hchart hsmall + Qsite hQsite Kcap hKcap hσ1 hcoverSmall + have hgfam (x : GoodKernel) := hfamily x block hb o bW C V hC hV hCp hVp + Cinv hCinv hchart hsmall Qsite hQsite Kcap hKcap hσ1 hcoverSmall + choose g hg hcoeff hmassCover hcompare using hgfam + refine ⟨g, hg, hcoeff, hmassCover, ?_⟩ + intro μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z hZ H law + coverValue wholeReference reconstruct weight cover + have hZpos : 0 < Z := lt_of_lt_of_le (by norm_num) hZ + have hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z := + selectedJointDensityMass_smooth_mass_pos bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) hZpos + refine ⟨hmass, ?_⟩ + intro kernelLaw η hbad + have hpoint (x : GoodKernel) (base : X → ℤ) : + ‖allocatedOriginalTupleSource B U b hR hσ S x.val X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem - cover x base‖ ≤ Real.exp (-E) := by + obtain ⟨hRefined, hdiv, hRefinedBound, hsize, reference, residue, href, hresidue, hlocal⟩ := + hcompare x μ ν μsmall hXPsp q hq hqPsp + obtain ⟨hmass', hestimate⟩ := hlocal hτ hτP N hN hsizeN poly hpoly hmem hrank hRank + base cells hcells test htest Z hZ + exact hestimate + exact allocatedOriginal_kernel_average_of_bad_bound B U b hb o hR hσ S X poly hmem N hN + hW hτ hξ q cells hmass bases hbases hZpos kernelLaw selection Mk + (physicalCubeSiteTest test) (physicalCubeSiteTest_norm_le test htest) + (fun x hx base => cover ⟨x, hx⟩ base) (Real.exp_pos _).le + (fun x hx base _ => hpoint ⟨x, hx⟩ base) hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +universe uG uI uB uJ uQ uX + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped ContDiff BigOperators Classical NNReal + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) + +local notation "hLayer" => layerSamplerDegree I n + +def AllocatedCommonGenuineKernelAt (p Psp E e t : ℝ) (hP : 0 ≤ Psp) (δ : ℝ≥0) + (A T Kproj Kideal Ksite : ℕ) : Prop := + ∀ {c : ℝ}, 0 ≤ c → + ∀ {J : Fin m → Type uJ} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j), + (∀ j, σ j ≤ t) → (∀ j, R j ≤ 1) → + (∀ j, (R j)⁻¹ ≤ Real.exp c) → (∀ j, (σ j)⁻¹ ≤ Real.exp c) → + let Eraw := E + 1 + 4 + let Esite := allocatedOriginalCoverAccuracy Psp (E + 1) + let D := allocatedComparisonDimension m p + let pNum := allocatedCommonScaleNumeric m p c Psp Eraw + let S := allocatedCommonScale (G := G) B U b hR hσ p c Psp e Eraw + let p₁ := allocatedCommonRefinedSourceLog m p c Psp e Eraw Esite + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m p₁ e + let error := allocatedReferenceIdealError m D Psp Eraw + let lengthLog := allocatedIdealScaleLog m D pNum e w error + let gainLog := allocatedProfileGainLog m D Psp w + let Pbase := allocatedIdealSourceBudget m D pNum e w error + let lateLog := allocatedSpatialLateLog (G := G) B Pbase Pbase + let F := allocatedProfileFourierOutput (allocatedActualProfileInput m D pNum e gainLog lengthLog) + let Λ := allocatedSiteSpectrumLog m p₁ w v Esite + let L : ℝ≥0 := NNReal.mk (Real.exp (1 + 6 * Λ + 12)) (Real.exp_nonneg _) + 4 + let Cc := fun a : {a : {a // allocatedGridAxis (I := I) U b S.value a} // + allocatedActiveGrid B U b S a} => + allocatedGridPointCap B (canonicalScalarSourceEnvelope m (allocatedRefinedPeriodCutoff m Psp)) + (allocatedGridIntegerAxis B U b S a.val) + (rowSets (allocatedGridIntegerAxis B U b S a.val).1) * + Real.exp (Fintype.card (Finset (Fin dim)) * (4 * Λ + 8) + Λ) + ∃ witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (q.val : ℕ) r.val, + AllocatedPointwiseResidueCoverFamily.{uG,uI,uB,uJ,uQ,uX,0} + B U b hR hσ S (fun q : AllocatedRefinedPeriodIndex m Psp => (q.val : ℕ)) witnesses L Cc ∧ + AllocatedGenuineKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase (allocatedSourceSamplingBudget m dim A Pbase (E + 1) lateLog F) + p₁ hP δ A (max T (max Kproj Kideal)) Ksite witnesses L Cc + +theorem allocatedCommonGenuineCoverAt_kernel + {p P E e t : ℝ} (hP : 0 ≤ P) {δ : ℝ≥0} {A T Kproj Kideal Ksite : ℕ} + (hcover : AllocatedCommonGenuineCoverAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A T Kproj Kideal Ksite) : + AllocatedCommonGenuineKernelAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A T Kproj Kideal Ksite := by + unfold AllocatedCommonGenuineKernelAt + intro c hc J _ U b R σ hR hσ hσt hR1 hRi hσi + obtain ⟨witnesses, hFamily, hData⟩ := hcover hc U b hR hσ hσt hR1 hRi hσi + exact ⟨witnesses, hFamily, allocatedGenuineKernelData_of_cover B U b hR hσ _ hP witnesses hData⟩ + +def AllocatedRegularizedKernelMixture (p P E : ℝ) (hP : 0 ≤ P) (A T : ℝ≥0) (Ksite : ℕ) : Prop := + let D := allocatedComparisonDimension m p + let target := profileReferenceErrorLog P (E + 1 + 4) + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * P + let gainLog := allocatedProfileGainLog m D P w + let ε := physicalIdealErrorShare target gainLog + let e := physicalIdealSmoothingLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) hLayer A T target gainLog + let eTail := physicalIdealTailLog (B := B) (O := fun a : LayerSamplerAxis I n => jets a.1) + (α := Fin dim) G (G × Option (Fin dim)) hLayer A T m target gainLog + 0 ≤ e ∧ 0 ≤ eTail ∧ ∃ Kideal : ℕ, 2 ≤ Kideal ∧ + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ) = booleanRegularizationRadius (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T (ε / 2) ∧ (δ : ℝ)⁻¹ ≤ Real.exp e ∧ + let t := booleanMassPerturbationScale (B := B) + (O := fun a : LayerSamplerAxis I n => jets a.1) (α := Fin dim) + ((G × Option (Fin dim)) ⊕ (Σ a, SamplerCoefficientSlot G B hLayer a)) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T m 1 (ε / 2) + 0 < t ∧ t ≤ 1 ∧ t⁻¹ ≤ Real.exp eTail ∧ + ∃ A₀ T₀ Kproj : ℕ, 2 ≤ A₀ ∧ 2 ≤ T₀ ∧ 2 ≤ Kproj ∧ + AllocatedCommonGenuineKernelAt.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E e t hP δ A₀ T₀ Kproj Kideal Ksite + +theorem allocatedRegularizedCommonCover_kernel + {p P E : ℝ} (hP : 0 ≤ P) {A T : ℝ≥0} {Ksite : ℕ} + (hcover : AllocatedRegularizedCommonCover.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T Ksite) : + AllocatedRegularizedKernelMixture.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A T Ksite := by + unfold AllocatedRegularizedKernelMixture + intro D target w gainLog ε e eTail + obtain ⟨he, heTail, Kideal, hKideal, δ, hδ, hδ1, hδeq, hδe, ht, ht1, hti, + A₀, T₀, Kproj, hA₀, hT₀, hKproj, hraw, hgenuine⟩ := hcover + exact ⟨he, heTail, Kideal, hKideal, δ, hδ, hδ1, hδeq, hδe, ht, ht1, hti, + A₀, T₀, Kproj, hA₀, hT₀, hKproj, allocatedCommonGenuineCoverAt_kernel B hP hgenuine⟩ + +theorem exists_fixed_regularized_kernel_mixture : + ∃ A : ℝ≥0, 1 ≤ A ∧ ∀ m dim : ℕ, ∃ Ksite : ℕ, 2 ≤ Ksite ∧ + ∀ {G : Type uG} [Fintype G] [DecidableEq G] + {I : Fin m → Type uI} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type uB) [∀ a, Fintype (B a)] + {p P E : ℝ}, 0 ≤ p → ∀ hP : 0 ≤ P, 0 ≤ E → + dim ≤ m + 1 → ((m + 2 : ℕ) : ℝ) ≤ P → p ≤ P → + (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p → + (∀ j, (Fintype.card (I j) : ℝ) ≤ p) → (∀ j, (n j : ℝ) ≤ p) → + (∀ j i, siteSpectrumBlockCount m ≤ Fintype.card (B ⟨j, Sum.inr i⟩)) → + AllocatedRegularizedKernelMixture.{uG,uI,uB,uJ,uQ,uX} + (G := G) (dim := dim) B p P E hP A scalarSourceTransitionBound Ksite := by + obtain ⟨A, hA, hfixed⟩ := exists_fixed_regularized_common_cover.{uG,uI,uB,uJ,uQ,uX} + refine ⟨A, hA, ?_⟩ + intro m dim + obtain ⟨Ksite, hKsite, hfixed⟩ := hfixed m dim + refine ⟨Ksite, hKsite, ?_⟩ + intro G _ _ I _ n B _ p P E hp hP hE hdim hmP hpP hvars hI hn hBlocks + exact allocatedRegularizedCommonCover_kernel B hP (hfixed B hp hP hE hdim hmP hpP hvars hI hn hBlocks) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedErrorAmbientKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedErrorAmbientKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9df8e4bbc96cdd9c994e4786bbe7dbef517269b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedErrorAmbientKernel.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedErrorInterpolation + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {α : Type*} [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) + (allocatedPrincipalSides B U b S)) +variable (v : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S)) +variable (rows : ∀ j, O j → Finset α) + +noncomputable def allocatedErrorAmbientKernel (η A : ℝ≥0) (z : JetAmbientIndex O J → ℝ) : ℝ := + (η : ℝ) * A * + (∏ j, mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ^ Fintype.card (O j)) * + (smallBoxCutoff z * allocatedGridJetInterpolation B U b S hR hσ x u v rows + (allocatedGridAmbientCoordinates B U b S o z)) + +theorem allocatedErrorAmbientKernel_support (η A : ℝ≥0) (z : JetAmbientIndex O J → ℝ) + (hz : allocatedErrorAmbientKernel B U b S o hR hσ x u v rows η A z ≠ 0) : + ∀ i, |z i| < 1 / 2 := by + apply smallBoxCutoff_support z + intro he + exact hz (by simp only [allocatedErrorAmbientKernel, he, zero_mul, mul_zero]) + +theorem allocatedErrorAmbientKernel_quarter (η A : ℝ≥0) + (z : ∀ j, (I j → O j → ℝ) × (Fin (n j) → O j → ℤ)) + (hz : ∀ i, |mixedJetAmbientPoint U b o z i| ≤ 1 / 4) : + allocatedErrorAmbientKernel B U b S o hR hσ x u v rows η A (mixedJetAmbientPoint U b o z) = + (η : ℝ) * A * + (∏ j, mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ^ Fintype.card (O j)) * + allocatedGridJetInterpolation B U b S hR hσ x u v rows + (allocatedGridNormalizedRows B U b S (fun a => coefficientJetAxisEquiv O I n z a.val)) := by + rw [allocatedErrorAmbientKernel, smallBoxCutoff_one _ hz, one_mul, + allocatedGridAmbientCoordinates_point] + +theorem allocatedErrorAmbientKernel_bounds (η A : ℝ≥0) (C V : Fin m → ℝ≥0) + (hC : ∀ j w, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) w‖ ≤ C j * ‖w‖) + (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) : + let K : ℝ≥0 := (S.value : ℝ≥0) ^ (layerTailDegree m + 1) + let D := Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) + let N := Fintype.card {a // allocatedGridAxis (I := I) U b S.value a} + let M : ℝ≥0 := (K ^ D) ^ N + let L : ℝ≥0 := N * (D * (2 * K ^ 2) * K ^ D) * M + let W : ℝ≥0 := η * A * ∏ j, V j ^ Fintype.card (O j) + (∀ z, 0 ≤ allocatedErrorAmbientKernel B U b S o hR hσ x u v rows η A z ∧ + allocatedErrorAmbientKernel B U b S o hR hσ x u v rows η A z ≤ W * M) ∧ + LipschitzWith (W * (L * (∑ j, C j * Fintype.card (J j)) + M * 8)) + (allocatedErrorAmbientKernel B U b S o hR hσ x u v rows η A) := by + intro K D N M L W + let F := allocatedGridJetInterpolation B U b S hR hσ x u v rows + let c : ℝ := (η : ℝ) * A * + ∏ j, mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ^ Fintype.card (O j) + have hc0 : 0 ≤ c := mul_nonneg (mul_nonneg η.coe_nonneg A.coe_nonneg) + (Finset.prod_nonneg (fun j _ => pow_nonneg (hV j).1 _)) + have hc : c ≤ W := by + apply mul_le_mul_of_nonneg_left _ (mul_nonneg η.coe_nonneg A.coe_nonneg) + exact_mod_cast Finset.prod_le_prod₀ (fun j _ => pow_nonneg (hV j).1 _) + (fun j _ => pow_le_pow_left₀ (hV j).1 (hV j).2 _) + have hf := allocatedGridJetInterpolation_uniform_bounds B U b S hR hσ x u v rows + have hf0 (z) : 0 ≤ F z := (hf.1 z).1 + have hfcap (z) : |F z| ≤ (M : ℝ) := by + rw [abs_of_nonneg (hf0 z)] + simpa only [M, K, D, N, NNReal.coe_pow] using (hf.1 z).2 + have hfl : LipschitzWith (L * (∑ j, C j * Fintype.card (J j))) + (fun z => F (allocatedGridAmbientCoordinates B U b S o z)) := + hf.2.comp (allocatedGridAmbientCoordinates_lipschitz B U b S o C hC) + have hcut := smallBoxCutoff_mul_lipschitz _ hfl + (fun z => hfcap (allocatedGridAmbientCoordinates B U b S o z)) + have hcut0 (z : JetAmbientIndex O J → ℝ) : + 0 ≤ smallBoxCutoff z * F (allocatedGridAmbientCoordinates B U b S o z) := + mul_nonneg (smallBoxCutoff_range z).1 (hf0 _) + have hcutcap (z : JetAmbientIndex O J → ℝ) : + |smallBoxCutoff z * F (allocatedGridAmbientCoordinates B U b S o z)| ≤ (M : ℝ) := by + rw [abs_of_nonneg (hcut0 z)] + exact (mul_le_mul_of_nonneg_right (smallBoxCutoff_range z).2 (hf0 _)).trans + (by simpa only [one_mul, abs_of_nonneg (hf0 _)] using hfcap (allocatedGridAmbientCoordinates B U b S o z)) + refine ⟨fun z => ⟨mul_nonneg hc0 (hcut0 z), ?_⟩, ?_⟩ + · change c * (smallBoxCutoff z * F (allocatedGridAmbientCoordinates B U b S o z)) ≤ + (W : ℝ) * (M : ℝ) + exact mul_le_mul hc ((le_abs_self _).trans (hcutcap z)) (hcut0 z) W.coe_nonneg + · have h := lipschitz_real_mul_of_bounds (Bf := W) (Bg := M) (fun _ => c) + (fun z => smallBoxCutoff z * F (allocatedGridAmbientCoordinates B U b S o z)) + (LipschitzWith.const c) hcut (fun _ => by rwa [abs_of_nonneg hc0]) hcutcap + apply LipschitzWith.of_dist_le_mul + intro z w + change dist (c * (smallBoxCutoff z * F (allocatedGridAmbientCoordinates B U b S o z))) + (c * (smallBoxCutoff w * F (allocatedGridAmbientCoordinates B U b S o w))) ≤ _ + have hh := h.dist_le_mul z w + simpa only [mul_zero, add_zero] using hh + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedExternalCandidateCommonKeepPositiveKernelPreparation.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedExternalCandidateCommonKeepPositiveKernelPreparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d487abe566835a1d5d3eafae0ceaccc7b9e6dcc2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedExternalCandidateCommonKeepPositiveKernelPreparation.lean @@ -0,0 +1,585 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedExternalCandidatePrecenterPaths +import OAI.Combinatorics.Progressions.Linear.AllocatedExternalCandidateNormalizedKernelRestoration + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +structure PrecenterKernelSelection + {p q : ℝ} + {T : (X → ℤ) → D.Niltest (fullTaggedVariableWeight (X := X) J)} + (early : ExternalFamilyPrecenterProjectionData T p q) + (top : Submodule ℚ L) (htop : top ≤ D.filtration.layer s) + (hpos : 0 < A.law.mass P.productive) where + code : Fin (finrank ℚ top) → Option early.Freq + tests : (X → ℤ) → D.Niltest (fullTaggedVariableWeight (X := X) J) + test_bounds : ∀ x, (tests x).UnitIntervalValued ∧ (tests x).ComplexityLE q ∧ + (tests x).orbit = (T x).orbit + identity : ∀ x, tests x = (T x).kernelProjection (frequencyCodeKernel top early.eta code) + ((finiteFrequencyKernel_le top _ _).trans htop) + invariant : ∀ a (z : D.RealGroup), z.coord ∈ (frequencyCodeKernel top early.eta code).baseChange ℝ → + ∀ x, (tests a).observable (z • x) = (tests a).observable x + retained : Finset A.Path + subset : retained ⊆ P.productive + mass : A.law.mass P.productive * Real.exp (-q) ≤ A.law.mass retained + pivots : ∀ a ∈ retained, ∀ i f, code i = some f → Real.exp (-q) < + ‖(P.precenterChart hpos a).localLaw.complexMean (fun site => + weight (A.physical (P.precenterChart hpos a).path site) * + (early.U f (A.physical (P.precenterChart hpos a).path site)).observable + ((P.precenterCandidate hpos a).siteValue site))‖ + scores : ∀ a ∈ retained, Real.exp (-q) ≤ + (P.precenterCandidate hpos a).score (fun x => (tests x).observable) weight + +theorem exists_precenterKernelSelection + {p q : ℝ} + {T : (X → ℤ) → D.Niltest (fullTaggedVariableWeight (X := X) J)} + (early : ExternalFamilyPrecenterProjectionData T p q) + (top : Submodule ℚ L) (htop : top ≤ D.filtration.layer s) + (hpos : 0 < A.law.mass P.productive) + (hξ1 : ξ ≤ 1) + (hweight : ∀ x ∈ integerBox N, ‖weight x‖ ≤ Real.exp p) + (hscore : Real.exp (-p) ≤ scoreThreshold) + (hobservable : ∀ x, (T x).observable = observable x) : + Nonempty (P.PrecenterKernelSelection early top htop hpos) := by + obtain ⟨code, tests, retained, htests, hidentity, hinvariant, hsub, hmass, hlocal⟩ := + early.select top htop A.law P.productive + (fun a => (P.precenterChart hpos a).localLaw) + (fun a => A.physical (P.precenterChart hpos a).path) + (fun a => (P.precenterCandidate hpos a).siteValue) + (fun a site => weight (A.physical (P.precenterChart hpos a).path site)) + (fun a site => hweight _ (A.physical_mem_integerBox hξ1 _ _)) (by + intro a ha + have hs := hscore.trans (P.precenterCandidate_score hpos a) + rw [← (P.precenterCandidate hpos a).localLaw_score observable weight] at hs + simpa only [hobservable] using hs) + refine ⟨{ + code := code + tests := tests + test_bounds := htests + identity := hidentity + invariant := hinvariant + retained := retained + subset := hsub + mass := hmass + pivots := fun a ha => (hlocal a ha).1 + scores := ?_ }⟩ + intro a ha + exact ((hlocal a ha).2).trans_eq + ((P.precenterCandidate hpos a).localLaw_score (fun x => (tests x).observable) weight) + +namespace PrecenterKernelSelection +variable {P} {p q : ℝ} + {T : (X → ℤ) → D.Niltest (fullTaggedVariableWeight (X := X) J)} + {early : ExternalFamilyPrecenterProjectionData T p q} + {top : Submodule ℚ L} {htop : top ≤ D.filtration.layer s} + {hpos : 0 < A.law.mass P.productive} + (selected : P.PrecenterKernelSelection early top htop hpos) + +noncomputable def problem : + AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked + (fun x => (selected.tests x).observable) weight cost + (A.law.mass P.productive * Real.exp (-q)) (Real.exp (-q)) := + P.restrictObservable (fun x => (selected.tests x).observable) selected.retained selected.subset + selected.mass (fun a => by + rw [← P.precenterCandidate_score_mem_eq hpos a.val (selected.subset a.property)] + exact selected.scores a.val a.property) + +theorem positive_mass : 0 < A.law.mass selected.retained := + (mul_pos hpos (Real.exp_pos _)).trans_le selected.mass + +@[simp] theorem problem_productive : selected.problem.productive = selected.retained := rfl + +end PrecenterKernelSelection +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +noncomputable def positiveKernelPreparationExponent : ℕ := + Classical.choose (exists_externalFamilyPrecenterProjectionData.{0, 0, 0}) + +theorem positiveKernelPreparationExponent_ge_two : + 2 ≤ positiveKernelPreparationExponent := + (Classical.choose_spec (exists_externalFamilyPrecenterProjectionData.{0, 0, 0})).1 + +noncomputable def positiveKernelPreparationParameter (p : ℝ) : ℝ := + (p + 5) ^ positiveKernelPreparationExponent + +noncomputable def positiveKernelPreparationBinLog (p : ℝ) (e : ℕ) : ℝ := + (2 * p + positiveKernelPreparationParameter p + 5 + e) ^ e + +structure PositiveKernelPreparation (p : ℝ) (e : ℕ) where + positive_mass : 0 < A.law.mass P.productive + tests : (X → ℤ) → D.Niltest (fullTaggedVariableWeight (X := X) J) + tests_observable : ∀ x, (tests x).observable = observable x + tests_unit : ∀ x, (tests x).UnitIntervalValued + tests_complexity : ∀ x, (tests x).ComplexityLE (p + 3) + early : ExternalFamilyPrecenterProjectionData tests (p + 3) + (positiveKernelPreparationParameter p) + selected : P.PrecenterKernelSelection early + (D.filtration.layer s ⊓ LinearMap.ker φ.toLinearMap) inf_le_left positive_mass + binCount : ℕ + binCount_pos : 0 < binCount + representative : Fin binCount → integerBox N + net : ∀ x : integerBox N, ∃ i, ∀ y, + ‖(tests x.val).observable y - (tests (representative i).val).observable y‖ ≤ + Real.exp (-((p + 3) + positiveKernelPreparationParameter p + 2)) + binCard : (binCount : ℝ) ≤ Real.exp (positiveKernelPreparationBinLog p e) + +theorem exists_positiveKernelPreparation + (p : ℝ) (e : ℕ) (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) + (ℓ : ℝ≥0) (hℓ : (ℓ : ℝ) ≤ Real.exp p) + (hLip : ∀ x, letI := D.metricSpace; LipschitzWith ℓ (observable x)) + (hpositive : ∀ x y, (observable x y).im = 0 ∧ + 0 ≤ (observable x y).re ∧ (observable x y).re ≤ 1) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp p) + (hmass : Real.exp (-p) ≤ massThreshold) + (hscore : Real.exp (-p) ≤ scoreThreshold) + (hξ1 : ξ ≤ 1) + (hnet : ∀ η : ℝ, 0 < η → η ≤ 1 → ∃ count : ℕ, + (count : ℝ) ≤ Real.exp ((p + Real.log (1 / η) + e) ^ e) ∧ + ∃ centers : Fin count → integerBox N, + ∀ x ∈ integerBox N, ∃ i, ∀ y, + ‖observable x y - observable (centers i).val y‖ ≤ η) : + Nonempty (P.PositiveKernelPreparation p e) := by + classical + let := D.metricSpace + have hcap (x : X → ℤ) (y : D.Space) : ‖observable x y‖ ≤ 1 := by + simpa only [positiveClip_eq_self _ (hpositive x y)] using + norm_positiveClip_le_one (observable x y) + let tests (x : X → ℤ) : D.Niltest (fullTaggedVariableWeight (X := X) J) := + D.externalNetNiltest (observable x) ℓ (hcap x) (hLip x) 1 + have hunit (x : X → ℤ) : (tests x).UnitIntervalValued := hpositive x + have hcomplexity (x : X → ℤ) : (tests x).ComplexityLE (p + 3) := + D.externalNetNiltest_complexity (observable x) ℓ (hcap x) (hLip x) 1 hp hD hℓ + have hp3 : 0 ≤ p + 3 := by linarith + have hpp3 : p ≤ p + 3 := by linarith + obtain ⟨early⟩ := (Classical.choose_spec + (exists_externalFamilyPrecenterProjectionData.{0, 0, 0})).2 tests (p + 3) hp3 + (hD.mono D hpp3) hunit hcomplexity + have hq : positiveKernelPreparationParameter p = + (p + 3 + 2) ^ positiveKernelPreparationExponent := by + simp only [positiveKernelPreparationParameter, show p + 3 + 2 = p + 5 by ring] + change ExternalFamilyPrecenterProjectionData tests (p + 3) + ((p + 3 + 2) ^ positiveKernelPreparationExponent) at early + rw [← hq] at early + have hpos : 0 < A.law.mass P.productive := + (Real.exp_pos _).trans_le (hmass.trans P.mass) + obtain ⟨selected⟩ := P.exists_precenterKernelSelection early + (D.filtration.layer s ⊓ LinearMap.ker φ.toLinearMap) inf_le_left hpos hξ1 + (fun x _ => (hweight x).trans (Real.exp_le_exp.mpr hpp3)) + ((Real.exp_le_exp.mpr (neg_le_neg hpp3)).trans hscore) (fun _ => rfl) + let η := Real.exp (-((p + 3) + positiveKernelPreparationParameter p + 2)) + have hη : 0 < η := Real.exp_pos _ + have hq0 : 0 ≤ positiveKernelPreparationParameter p := by + unfold positiveKernelPreparationParameter + positivity + have hη1 : η ≤ 1 := Real.exp_le_one_iff.mpr (by linarith) + obtain ⟨count, hcount, centers, hcenters⟩ := hnet η hη hη1 + have hcountPos : 0 < count := by + have hzero : (0 : X → ℤ) ∈ integerBox N := by + apply (mem_integerBox N _).mpr + intro x + change (0 : ℤ) ≤ 0 ∧ (0 : ℤ) < (N x : ℤ) + exact ⟨le_rfl, by exact_mod_cast A.size_pos x⟩ + obtain ⟨i, _⟩ := hcenters 0 hzero + exact Nat.zero_lt_of_lt i.isLt + have hlog : Real.log (1 / η) = (p + 3) + positiveKernelPreparationParameter p + 2 := by + dsimp [η] + rw [one_div, ← Real.exp_neg, Real.log_exp] + ring + have hbin : (count : ℝ) ≤ Real.exp (positiveKernelPreparationBinLog p e) := by + rw [hlog] at hcount + convert hcount using 1 + unfold positiveKernelPreparationBinLog + congr 2 + ring + exact ⟨{ + positive_mass := hpos + tests := tests + tests_observable := fun _ => rfl + tests_unit := hunit + tests_complexity := hcomplexity + early := early + selected := selected + binCount := count + binCount_pos := hcountPos + representative := centers + net := fun x => hcenters x.val x.property + binCard := hbin }⟩ + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial.AllocatedExternalCandidateProblem + +theorem positiveKernelPreparationParameter_ge_input {p : ℝ} (hp : 0 ≤ p) : + p + 3 ≤ positiveKernelPreparationParameter p := by + have hC := positiveKernelPreparationExponent_ge_two + have hbase : 1 ≤ p + 5 := by linarith + have hself : p + 5 ≤ (p + 5) ^ positiveKernelPreparationExponent := by + simpa only [pow_one] using pow_le_pow_right₀ hbase + (by omega : 1 ≤ positiveKernelPreparationExponent) + unfold positiveKernelPreparationParameter + linarith + +theorem positiveKernelPreparationParameter_nonneg {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ positiveKernelPreparationParameter p := by + have := positiveKernelPreparationParameter_ge_input hp + linarith + +theorem positiveKernelPreparationBinLog_nonneg {p : ℝ} (hp : 0 ≤ p) (e : ℕ) : + 0 ≤ positiveKernelPreparationBinLog p e := by + have := positiveKernelPreparationParameter_nonneg hp + unfold positiveKernelPreparationBinLog + positivity + +noncomputable def positiveKernelResidualPrecisionParameter (p : ℝ) (e : ℕ) : ℝ := + positiveKernelPreparationParameter p + positiveKernelPreparationParameter p + + positiveKernelPreparationBinLog p e + 4 + +noncomputable def positiveKernelMarkovPrecisionParameter (p : ℝ) (e : ℕ) : ℝ := + (positiveKernelPreparationParameter p + positiveKernelPreparationBinLog p e) + + (2 * positiveKernelPreparationParameter p + positiveKernelPreparationBinLog p e + 4) + + (p + positiveKernelPreparationParameter p) + 2 + +theorem exists_positiveKernelPreparationParameters_bound (e : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + p + 3 ≤ (p + C) ^ C ∧ + positiveKernelPreparationParameter p ≤ (p + C) ^ C ∧ + positiveKernelPreparationBinLog p e ≤ (p + C) ^ C ∧ + positiveKernelResidualPrecisionParameter p e ≤ (p + C) ^ C ∧ + positiveKernelMarkovPrecisionParameter p e ≤ (p + C) ^ C := by + let q : Polynomial ℕ := (Polynomial.X + 5) ^ positiveKernelPreparationExponent + let bin : Polynomial ℕ := (2 * Polynomial.X + q + 5 + Polynomial.C e) ^ e + let residual : Polynomial ℕ := q + q + bin + 4 + let markov : Polynomial ℕ := (q + bin) + (2 * q + bin + 4) + (Polynomial.X + q) + 2 + let total : Polynomial ℕ := Polynomial.X + 3 + q + bin + residual + markov + obtain ⟨C, hC, hbound⟩ := Erdos3.exists_natPolynomial_eval_budget total + refine ⟨C, hC, ?_⟩ + intro p hp + have hq := positiveKernelPreparationParameter_nonneg hp + have hbin := positiveKernelPreparationBinLog_nonneg hp e + have hresidual : 0 ≤ positiveKernelResidualPrecisionParameter p e := by + unfold positiveKernelResidualPrecisionParameter + positivity + have hmarkov : 0 ≤ positiveKernelMarkovPrecisionParameter p e := by + unfold positiveKernelMarkovPrecisionParameter + positivity + have htotal : p + 3 + positiveKernelPreparationParameter p + + positiveKernelPreparationBinLog p e + positiveKernelResidualPrecisionParameter p e + + positiveKernelMarkovPrecisionParameter p e ≤ (p + C) ^ C := by + simpa [total, markov, residual, bin, q, positiveKernelPreparationParameter, + positiveKernelPreparationBinLog, positiveKernelResidualPrecisionParameter, + positiveKernelMarkovPrecisionParameter, Polynomial.eval₂_pow] using hbound p hp + constructor + · linarith + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +noncomputable def positiveKernelPreparationBudgetExponent (e : ℕ) : ℕ := + Classical.choose (exists_positiveKernelPreparationParameters_bound e) + +theorem positiveKernelPreparationBudgetExponent_ge_two (e : ℕ) : + 2 ≤ positiveKernelPreparationBudgetExponent e := + (Classical.choose_spec (exists_positiveKernelPreparationParameters_bound e)).1 + +theorem positiveKernelPreparationBudget_bounds (e : ℕ) {p : ℝ} (hp : 0 ≤ p) : + p + 3 ≤ (p + positiveKernelPreparationBudgetExponent e) ^ positiveKernelPreparationBudgetExponent e ∧ + positiveKernelPreparationParameter p ≤ + (p + positiveKernelPreparationBudgetExponent e) ^ positiveKernelPreparationBudgetExponent e ∧ + positiveKernelPreparationBinLog p e ≤ + (p + positiveKernelPreparationBudgetExponent e) ^ positiveKernelPreparationBudgetExponent e ∧ + positiveKernelResidualPrecisionParameter p e ≤ + (p + positiveKernelPreparationBudgetExponent e) ^ positiveKernelPreparationBudgetExponent e ∧ + positiveKernelMarkovPrecisionParameter p e ≤ + (p + positiveKernelPreparationBudgetExponent e) ^ positiveKernelPreparationBudgetExponent e := + (Classical.choose_spec (exists_positiveKernelPreparationParameters_bound e)).2 p hp + +end Erdos3.VectorPolynomial.AllocatedExternalCandidateProblem + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + {P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold} + +namespace PositiveKernelPreparation + +variable {p : ℝ} {e : ℕ} (prep : P.PositiveKernelPreparation p e) + +theorem conclusion_of_selected + {q : ℝ} (hq : 0 ≤ q) + (out : prep.selected.problem.Conclusion q (Real.exp (-q)) (Real.exp (-q))) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp q) + (hσone : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ + Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) : + Nonempty (P.Conclusion (3 * q + 2) (Real.exp (-(3 * q + 2))) + (Real.exp (-(3 * q + 2)))) := by + let top := D.filtration.layer s ⊓ LinearMap.ker φ.toLinearMap + let K := frequencyCodeKernel top prep.early.eta prep.selected.code + have hK : K ≤ D.filtration.layer s := + (finiteFrequencyKernel_le top _ _).trans inf_le_left + have hkernel : K ≤ LinearMap.ker φ.toLinearMap := + (finiteFrequencyKernel_le top _ _).trans inf_le_right + have hobservable : (fun x => (prep.selected.tests x).observable) = + (fun x => ((prep.tests x).kernelProjection K hK).observable) := by + funext x + exact congrArg (fun T => T.observable) (prep.selected.identity x) + have hscore : ∀ z : prep.selected.retained, + Real.exp (-positiveKernelPreparationParameter p) ≤ + (P.candidate ⟨z.val, prep.selected.subset z.property⟩).score + (fun x => ((prep.tests x).kernelProjection K hK).observable) weight := by + intro z + rw [← P.precenterCandidate_score_mem_eq prep.positive_mass z.val + (prep.selected.subset z.property)] + simpa only [prep.selected.identity] using prep.selected.scores z.val z.property + have transport (newObservable : (X → ℤ) → D.Space → ℂ) + (heq : (fun x => (prep.selected.tests x).observable) = newObservable) + (hnewScore : ∀ z : prep.selected.retained, + Real.exp (-positiveKernelPreparationParameter p) ≤ + (P.candidate ⟨z.val, prep.selected.subset z.property⟩).score newObservable weight) : + Nonempty ((P.restrictObservable newObservable prep.selected.retained + prep.selected.subset prep.selected.mass hnewScore).Conclusion q + (Real.exp (-q)) (Real.exp (-q))) := by + subst newObservable + exact ⟨out⟩ + obtain ⟨projectedOut⟩ := transport _ hobservable hscore + exact P.conclusion_of_kernel_projection_normalized prep.tests prep.tests_unit + prep.tests_observable K hK hkernel prep.selected.retained prep.selected.subset + prep.selected.mass hscore hq projectedOut hweight hσone Cgeo hCgeo hchart hsmall hpoly + +end PositiveKernelPreparation +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I E J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +structure CommonKeepPositiveKernelPreparation (p : ℝ) (e : ℕ) where + keep : LayerSamplerVariables G I n B → Prop + refinement : P.Refinement cost (massThreshold * Real.exp (-p)) scoreThreshold + hkeep : ∀ z : refinement.problem.productive, (refinement.problem.chart z).keep = keep + prep : (refinement.problem.withKeep keep hkeep).PositiveKernelPreparation (2 * p) e + +theorem exists_commonKeepPositiveKernelPreparation + (p : ℝ) (e : ℕ) (hp : 0 ≤ p) + (hvariables : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hD : D.GeometryComplexityLE p) + (ℓ : ℝ≥0) (hℓ : (ℓ : ℝ) ≤ Real.exp p) + (hLip : ∀ x, letI := D.metricSpace; LipschitzWith ℓ (observable x)) + (hpositive : ∀ x y, (observable x y).im = 0 ∧ + 0 ≤ (observable x y).re ∧ (observable x y).re ≤ 1) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp p) + (hmass : Real.exp (-p) ≤ massThreshold) + (hscore : Real.exp (-p) ≤ scoreThreshold) + (hξ1 : ξ ≤ 1) + (hnet : ∀ η : ℝ, 0 < η → η ≤ 1 → ∃ count : ℕ, + (count : ℝ) ≤ Real.exp ((p + Real.log (1 / η) + e) ^ e) ∧ + ∃ centers : Fin count → integerBox N, + ∀ x ∈ integerBox N, ∃ i, ∀ y, + ‖observable x y - observable (centers i).val y‖ ≤ η) : + Nonempty (P.CommonKeepPositiveKernelPreparation p e) := by + obtain ⟨keep, refinement, hkeep⟩ := P.exists_common_keep_refinement_exp + ((Real.exp_pos _).le.trans hmass) hvariables + have hp2 : p ≤ 2 * p := by linarith + have hmass2 : Real.exp (-(2 * p)) ≤ massThreshold * Real.exp (-p) := by + calc + Real.exp (-(2 * p)) = Real.exp (-p) * Real.exp (-p) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ massThreshold * Real.exp (-p) := + mul_le_mul_of_nonneg_right hmass (Real.exp_nonneg _) + have hnet2 : ∀ η : ℝ, 0 < η → η ≤ 1 → ∃ count : ℕ, + (count : ℝ) ≤ Real.exp ((2 * p + Real.log (1 / η) + e) ^ e) ∧ + ∃ centers : Fin count → integerBox N, + ∀ x ∈ integerBox N, ∃ i, ∀ y, + ‖observable x y - observable (centers i).val y‖ ≤ η := by + intro η hη hη1 + obtain ⟨count, hcount, centers, hcenters⟩ := hnet η hη hη1 + refine ⟨count, hcount.trans (Real.exp_le_exp.mpr ?_), centers, hcenters⟩ + have hlog : 0 ≤ Real.log (1 / η) := Real.log_nonneg ((one_le_div hη).mpr hη1) + exact pow_le_pow_left₀ (by positivity) (by linarith) e + obtain ⟨prep⟩ := (refinement.problem.withKeep keep hkeep).exists_positiveKernelPreparation + (2 * p) e (by positivity) (hD.mono D hp2) ℓ + (hℓ.trans (Real.exp_le_exp.mpr hp2)) hLip hpositive + (fun x => (hweight x).trans (Real.exp_le_exp.mpr hp2)) hmass2 + ((Real.exp_le_exp.mpr (neg_le_neg hp2)).trans hscore) hξ1 hnet2 + exact ⟨{ keep := keep, refinement := refinement, hkeep := hkeep, prep := prep }⟩ + +namespace CommonKeepPositiveKernelPreparation + +variable {P} {p : ℝ} {e : ℕ} (front : P.CommonKeepPositiveKernelPreparation p e) + +noncomputable def problem := front.refinement.problem.withKeep front.keep front.hkeep + +@[simp] theorem problem_keep (z : front.problem.productive) : + (front.problem.chart z).keep = front.keep := rfl + +theorem conclusion_of_selected + {q : ℝ} (hq : 0 ≤ q) + (out : front.prep.selected.problem.Conclusion q (Real.exp (-q)) (Real.exp (-q))) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp q) + (hσone : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ + Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) : + Nonempty (P.Conclusion (3 * q + 2) (Real.exp (-(3 * q + 2))) + (Real.exp (-(3 * q + 2)))) := by + obtain ⟨restored⟩ := front.prep.conclusion_of_selected hq out hweight + hσone Cgeo hCgeo hchart hsmall hpoly + exact ⟨front.refinement.conclusion + (front.refinement.problem.conclusion_of_withKeep front.keep front.hkeep restored)⟩ + +end CommonKeepPositiveKernelPreparation +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedExternalCandidateNormalizedKernelRestoration.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedExternalCandidateNormalizedKernelRestoration.lean new file mode 100644 index 0000000000000000000000000000000000000000..422fd3eeb9606fc5745afe69adb3132059819c31 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedExternalCandidateNormalizedKernelRestoration.lean @@ -0,0 +1,223 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedExternalCandidateExponentialFreezingBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateObservableRestriction + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +theorem conclusion_of_kernel_projection + (tests : (X → ℤ) → D.Niltest (fullTaggedVariableWeight (X := X) J)) + (htests : ∀ x, (tests x).UnitIntervalValued) + (hobs : ∀ x, (tests x).observable = observable x) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + (hkernel : K ≤ LinearMap.ker φ.toLinearMap) + (retained : Finset A.Path) (hsub : retained ⊆ P.productive) + {newMass newScore : ℝ} (hmass : newMass ≤ A.law.mass retained) + (hscore : ∀ z : retained, newScore ≤ + (P.candidate ⟨z.val,hsub z.property⟩).score + (fun x => ((tests x).kernelProjection K hK).observable) weight) + {outputCost outputMass outputScore Bweight : ℝ} + (out : (P.restrictObservable (fun x => ((tests x).kernelProjection K hK).observable) + retained hsub hmass hscore).Conclusion outputCost outputMass outputScore) + (hOutMass : 0 < outputMass) (hOutScore : 0 < outputScore) (hB : 0 < Bweight) + (hweight : ∀ x, ‖weight x‖ ≤ Bweight) + (hσone : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ)+1)*R j) ≤ 1/8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val+1) (poly j)) : + Nonempty (P.Conclusion outputCost (outputScore/(2*Bweight)*outputMass) (outputScore/2)) := by + let projected := P.restrictObservable (fun x => ((tests x).kernelProjection K hK).observable) + retained hsub hmass hscore + have hpos : 0 < A.law.mass out.retained := hOutMass.trans_le out.mass + have hne : out.retained.Nonempty := by + apply Finset.nonempty_of_ne_empty + intro he + simp [he, FiniteProbabilityWeights.mass] at hpos + obtain ⟨a₀,ha₀⟩ := hne + let localLaw (a : A.Path) : FiniteProbabilityWeights A.Site := + if ha : a ∈ out.retained then out.siteLaw ⟨a,ha⟩ else out.siteLaw ⟨a₀,ha₀⟩ + have hlaw (a : A.Path) (ha : a ∈ out.retained) : + localLaw a = out.siteLaw ⟨a,ha⟩ := by + simp only [localLaw, dite_eq_left ha] + have hprojected (a : A.Path) (ha : a ∈ out.retained) : + outputScore ≤ ((localLaw a).complexMean (fun site => + weight (A.physical a site) * + (((tests (A.physical a site)).kernelProjection K hK).withOrbit out.ambient).eval + (projected.physicalIntegerPoint (A.physical a site)))).re := by + rw [hlaw a ha] + exact out.siteLaw_score hσone Cgeo hCgeo hchart hsmall hpoly ⟨a,ha⟩ + obtain ⟨ambient,hmark,zshift,_hshift,_hcoord,_hshiftmark,_hobs,kept,hkept,_hkeptpos,hmassKept,hrestored⟩ := + RationalFilteredNilmanifold.Niltest.exists_external_kernelProjection_prescribed_marked_orbit + tests htests Fmark φ K hK hkernel out.ambient marked out.marked + A.law out.retained hpos localLaw A.physical + (fun a site => projected.physicalIntegerPoint (A.physical a site)) + (fun a site => weight (A.physical a site)) hB hOutScore + (fun a _ site => hweight (A.physical a site)) hprojected + refine ⟨{ + ambient := ambient + marked := hmark + retained := kept + subset := fun a ha => hsub (out.subset (hkept ha)) + mass := (mul_le_mul_of_nonneg_left out.mass (by positivity)).trans hmassKept + step := fun a => out.step ⟨a.val,hkept a.property⟩ + step_pos := fun a => out.step_pos ⟨a.val,hkept a.property⟩ + slice := fun a => out.slice ⟨a.val,hkept a.property⟩ + dense := fun a => out.dense ⟨a.val,hkept a.property⟩ + inside := fun a => out.inside ⟨a.val,hkept a.property⟩ + score := ?_ }⟩ + intro a + let old : out.retained := ⟨a.val,hkept a.property⟩ + have hs := hrestored a.val a.property + rw [hlaw a.val old.property] at hs + have he : ((out.siteLaw old).complexMean (fun site => + weight (A.physical a.val site) * ((tests (A.physical a.val site)).withOrbit ambient).eval + (projected.physicalIntegerPoint (A.physical a.val site)))).re = + P.ambientScore ambient ⟨a.val,hsub (out.subset old.property)⟩ + (out.slice old).integerPoints := by + change ((out.siteLaw old).complexMean (fun site => weight (A.physical a.val site) * + (tests (A.physical a.val site)).observable (P.ambientPhysicalValue ambient (A.physical a.val site)))).re = _ + simp_rw [hobs] + rw [P.ambientScore_eq_physical hσone Cgeo hCgeo hchart hsmall hpoly ambient + ⟨a.val,hsub (out.subset old.property)⟩ _ (out.inside old)] + exact congrArg Complex.re (out.siteLaw_complexMean_physical old (fun x => + weight x * observable x (P.ambientPhysicalValue ambient x))) + exact hs.trans_eq he + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +private theorem exp_neg_add_two_le_half (p : ℝ) : + Real.exp (-(p+2)) ≤ Real.exp (-p)/2 := by + have hlog : Real.log (2 : ℝ) ≤ 2 := + (Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2)).trans (by norm_num) + calc + _ ≤ Real.exp (-p-Real.log 2) := Real.exp_le_exp.mpr (by linarith only [hlog]) + _ = _ := by rw [Real.exp_sub, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + +theorem kernel_restoration_exp_budget {p : ℝ} (hp : 0 ≤ p) : + p ≤ 3*p+2 ∧ + Real.exp (-(3*p+2)) ≤ Real.exp (-p)/(2*Real.exp p)*Real.exp (-p) ∧ + Real.exp (-(3*p+2)) ≤ Real.exp (-p)/2 := by + have hmass : Real.exp (-p)/(2*Real.exp p)*Real.exp (-p) = Real.exp (-(3*p))/2 := by + rw [mul_comm (2 : ℝ) (Real.exp p), div_mul_eq_div_div, ← Real.exp_sub, + div_mul_eq_mul_div, ← Real.exp_add] + congr 2 + ring + refine ⟨by linarith only [hp], ?_, ?_⟩ + · rw [hmass] + exact exp_neg_add_two_le_half (3*p) + · exact (Real.exp_le_exp.mpr (by linarith only [hp] : -(3*p+2) ≤ -(p+2))).trans + (exp_neg_add_two_le_half p) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d t : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M t} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +namespace AllocatedExternalCandidateProblem +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + +theorem conclusion_of_kernel_projection_normalized + (tests : (X → ℤ) → D.Niltest (fullTaggedVariableWeight (X := X) J)) + (htests : ∀ x, (tests x).UnitIntervalValued) + (hobs : ∀ x, (tests x).observable = observable x) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + (hkernel : K ≤ LinearMap.ker φ.toLinearMap) + (retained : Finset A.Path) (hsub : retained ⊆ P.productive) + {newMass newScore : ℝ} (hmass : newMass ≤ A.law.mass retained) + (hscore : ∀ z : retained, newScore ≤ + (P.candidate ⟨z.val,hsub z.property⟩).score + (fun x => ((tests x).kernelProjection K hK).observable) weight) + {p : ℝ} (hp : 0 ≤ p) + (out : (P.restrictObservable (fun x => ((tests x).kernelProjection K hK).observable) + retained hsub hmass hscore).Conclusion p (Real.exp (-p)) (Real.exp (-p))) + (hweight : ∀ x, ‖weight x‖ ≤ Real.exp p) + (hσone : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ)+1)*R j) ≤ 1/8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val+1) (poly j)) : + Nonempty (P.Conclusion (3*p+2) (Real.exp (-(3*p+2))) (Real.exp (-(3*p+2)))) := by + obtain ⟨restored⟩ := P.conclusion_of_kernel_projection tests htests hobs K hK hkernel + retained hsub hmass hscore out (Real.exp_pos _) (Real.exp_pos _) (Real.exp_pos p) + hweight hσone Cgeo hCgeo hchart hsmall hpoly + obtain ⟨hcost, hmass', hscore'⟩ := kernel_restoration_exp_budget hp + exact ⟨restored.mono hcost hmass' hscore'⟩ + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedDensityProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedDensityProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..3365be13f2243545356fe45d226ac04dce657280 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedDensityProjection.lean @@ -0,0 +1,196 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedTrimmedVectorSite + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem trimmedSpatialWidths_antitone_budget {K X : Type*} {W W' τ : ℝ} + (hW : 0 ≤ W) (hWW' : W ≤ W') (hτ : 0 ≤ τ) (N : X → ℕ) + (z : Option K × X) : + trimmedSpatialWidths W' τ N z ≤ trimmedSpatialWidths W τ N z := by + rcases z with ⟨k, i⟩ + cases k with + | none => exact le_rfl + | some k => + dsimp only [trimmedSpatialWidths, centeredSpatialWidths] + gcongr + +theorem spatialWidthFraction_le_allocated_width {K X : Type*} {P W τ : ℝ} + (hP : 0 ≤ P) (hW : 0 ≤ W) (hWP : W ≤ Real.exp P) (hτ : 0 ≤ τ) + (N : X → ℕ) (z : Option K × X) : + spatialWidthFraction P τ * (N z.2 : ℝ) ≤ trimmedSpatialWidths W τ N z := by + exact (spatialWidthFraction_le_trimmed_width P hτ N z).trans + (trimmedSpatialWidths_antitone_budget hW + (hWP.trans (Real.exp_le_exp.mpr (by linarith))) hτ N z) + +namespace VectorPolynomial + +open BooleanCubeKernel + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable (c : LayerSamplerVariables G I n B → ℤ) + +theorem allocatedPhysicalRootBudget_constant_le (k : LayerSamplerVariables G I n B) : + |(c k : ℝ)| ≤ allocatedPhysicalRootBudget B U basis S c := by + classical + apply (Finset.single_le_sum (fun k _ => abs_nonneg (c k : ℝ)) (Finset.mem_univ k)).trans + exact le_add_of_nonneg_right (by positivity) + +theorem allocatedPhysicalCube_site_le_exp {q : ℕ} + (x : G → IntegerScalarCubeBox (Fin q) S.value) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) + (allocatedPrincipalSides B U basis S)) + {P : ℝ} (hroot : allocatedPhysicalRootBudget B U basis S c ≤ Real.exp P) + (hL : (S.value : ℝ) ≤ Real.exp P) (s : Finset (Fin q)) (k : LayerSamplerVariables G I n B) : + |((affineSite (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) s (some k) : ℤ) : ℝ)| ≤ + Real.exp (P + (q + 2 : ℕ)) := by + have hs : (s.card : ℝ) ≤ q := by + exact_mod_cast (show s.card ≤ q from by simpa only [Fintype.card_fin] using s.card_le_univ) + have hd (i) : |(allocatedPhysicalCubeDirections B U basis S x y i k : ℝ)| ≤ Real.exp P := + (allocatedPhysicalCube_directions_bound B U basis S x y i k).trans hL + have hr : |(allocatedPhysicalCubeRoot B U basis S c x y k : ℝ)| ≤ Real.exp P := + (allocatedPhysicalCube_root_budget B U basis S c x y k).trans hroot + have hsum : |∑ i ∈ s, (allocatedPhysicalCubeDirections B U basis S x y i k : ℝ)| ≤ + (q : ℝ) * Real.exp P := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _i ∈ s, Real.exp P := Finset.sum_le_sum (fun i _ => hd i) + _ = (s.card : ℝ) * Real.exp P := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right hs (Real.exp_nonneg P) + calc + _ ≤ Real.exp P + (q : ℝ) * Real.exp P := by + simp only [affineSite, Int.cast_add, Int.cast_sum] + exact (abs_add_le _ _).trans (add_le_add hr hsum) + _ ≤ Real.exp ((q : ℝ) + 2) * Real.exp P := by + have hq : (q : ℝ) + 1 ≤ Real.exp ((q : ℝ) + 2) := by + linarith [Real.add_one_le_exp ((q : ℝ) + 2)] + nlinarith [Real.exp_pos P] + _ = _ := by rw [← Real.exp_add]; congr 1; push_cast; ring + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Polynomial +open scoped BigOperators + +theorem exists_allocated_fixed_density_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + {P W : ℝ} (_hP : 0 ≤ P) (_hG : (Fintype.card G : ℝ) ≤ P) (_hW : 0 ≤ W) + (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ (y : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S)) + {X : Type*} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + {F : Type*} [Fintype F] + (frequency : F → ∀ j, (LayerSamplerVariables G I n B →₀ ℕ) → J j → ℤ) + (_hfrequency : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ Real.exp P), + ∃ b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ a j s t, |(b a j s t : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (coeff : F → ℂ) (_hcoeff : (∑ a, ‖coeff a‖) ≤ Real.exp P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ δ : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hδ : 0 < δ) (_hδP : δ⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty) + (density : CoefficientTorus (K := LayerSamplerVariables G I n B) U → ℝ) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ v, ‖(density v : ℂ) - coefficientTorusFourierSum U frequency coeff v‖ ≤ η), + let V := trimmedSpatialWidths (K := LayerSamplerVariables G I n B) W τ N + let root := allocatedPhysicalCubeRoot B U basis S c x y + let dirs := allocatedPhysicalCubeDirections B U basis S x y + let pa := fun j => translate (fun d => (base d : ℝ)) (p j) + let hma := fun j => coefficients_translate_mem (U j) (fun d => (base d : ℝ)) (p j) (hm j) + ∃ (hV : ∀ z, 0 < V z) (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride T V z), + ‖(∑' z, ((selectedResidueSmoothPMF stride T V hV hZ z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences root dirs base z) * + (density (affineSampleCoefficientTorus U pa hma (fun k d => (z (k, d) : ℝ))) : ℂ))) - + ∑' z, ((selectedResidueSmoothPMF stride T V hV hZ z).toReal : ℂ) * + physicalCubeCoveredTest U root dirs D p hm frequency b coeff test + (physicalCubeRootDifferences root dirs base z)‖ ≤ η + δ := by + obtain ⟨A₀, _, hprojection⟩ := exists_fixed_kernel_density_projection m q + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget ((4 * X + C (q + 130 + A₀)) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro G _ I _ n B _ J _ U basis R σ S c x P W hP hG hW hroot hWP hL M hperiod + let Q := spatialSamplingBudget P + (q + 2 : ℕ) + have hPQ : P ≤ Q := by + dsimp [Q, spatialSamplingBudget] + linarith [Nat.cast_nonneg (α := ℝ) (q + 2)] + have hQ : 0 ≤ Q := hP.trans hPQ + have hsiteQ : P + (q + 2 : ℕ) ≤ Q := by dsimp [Q, spatialSamplingBudget]; linarith + have hcost : (Q + A₀) ^ A₀ ≤ (P + A) ^ A := by + calc + _ = (4 * P + (q + 130 + A₀ : ℕ)) ^ A₀ := by + congr 1 + dsimp [Q, spatialSamplingBudget] + push_cast + ring + _ ≤ _ := by simpa [Polynomial.eval₂_pow] using hbudget P hP + have hExp := Real.exp_le_exp.mpr hPQ + obtain ⟨a, ha, _, hperiod⟩ := hperiod + obtain ⟨D, hD, hDP, hrows⟩ := hprojection (fun g => c (.inl g) + (x g none : ℤ)) + (fun i g => (x g (some i) : ℤ)) (a : ℤ) (by exact_mod_cast ha.ne') hperiod + hQ (hG.trans hPQ) (fun s g => + (kernelCubeBox_site_le_exp (fun g => c (.inl g)) x + (fun g => (allocatedPhysicalRootBudget_constant_le B U basis S c (.inl g)).trans (hroot.trans hWP)) + hL s g).trans (Real.exp_le_exp.mpr hsiteQ)) + refine ⟨D, hD, hDP.trans (Real.exp_le_exp.mpr hcost), ?_⟩ + intro y X _ _ hX hdim F _ frequency hfrequency + obtain ⟨b, hb, hproj⟩ := hrows (hX.trans hPQ) (hdim.trans hPQ) U + (allocatedPhysicalCubeRoot B U basis S c x y) (allocatedPhysicalCubeDirections B U basis S x y) + Sum.inl (fun _ => rfl) (fun _ _ => rfl) + (Real.exp_nonneg Q) (Real.exp_nonneg Q) le_rfl le_rfl + (fun s k => (allocatedPhysicalCube_site_le_exp B U basis S c x y (hroot.trans hWP) hL s k).trans + (Real.exp_le_exp.mpr hsiteQ)) frequency (fun a j d hd t => (hfrequency a j d hd t).trans hExp) + refine ⟨b, fun a j s t => (hb a j s t).trans (Real.exp_le_exp.mpr hcost), ?_⟩ + intro coeff hcoeff p hp hm base stride hs hsP τ δ hτ hτP hδ hδP N hsize rank hrank hRank + test htest T hT density η hη happrox + have hN (d) : 0 < N d := by exact_mod_cast (Real.exp_pos _).trans_le (hsize d) + have hV := trimmedSpatialWidths_pos (K := LayerSamplerVariables G I n B) hW hτ N hN + have hρP : 1 / spatialWidthFraction P τ ≤ Real.exp Q := + (spatialWidthFraction_inv_le hP hτ hτP).trans + (Real.exp_le_exp.mpr (le_add_of_nonneg_right (Nat.cast_nonneg _))) + obtain ⟨hZ, he⟩ := hproj coeff (Real.exp_nonneg Q) le_rfl (hcoeff.trans hExp) + p hp hm base stride hs (Real.exp_nonneg Q) le_rfl (spatialWidthFraction_pos P hτ) hδ + hρP (by simpa only [one_div] using hδP.trans hExp) (fun d => (hsP d).trans hExp) + (fun d => (N d : ℝ)) (fun d => (Real.exp_le_exp.mpr hcost).trans (hsize d)) hrank + ((Real.exp_le_exp.mpr hcost).trans hRank) test htest T hT + (trimmedSpatialWidths W τ N) hV (spatialWidthFraction_le_allocated_width hP hW hWP hτ.le N) + density hη happrox + exact ⟨hV, hZ, he⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedKernelCover.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedKernelCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..40a750fe535f77da1dfb978a742566a425638e76 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedKernelCover.lean @@ -0,0 +1,189 @@ +import OAI.Combinatorics.Progressions.Geometry.SpatialChoiceEnvelope +import OAI.Combinatorics.Progressions.Probability.PositiveDensityNormalization + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] +variable (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox α S.value) +variable (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α (allocatedPrincipalSides B U basis S)) + +noncomputable def allocatedPhysicalCubeRoot : LayerSamplerVariables G I n B → ℤ := + fun k => c k + Sum.elim (fun g => (x g none : ℤ)) (fun j => (y j none : ℤ)) k + +noncomputable def allocatedPhysicalCubeDirections : Matrix α (LayerSamplerVariables G I n B) ℤ := + fun i => Sum.elim (fun g => (x g (some i) : ℤ)) (fun j => (y j (some i) : ℤ)) + +theorem allocatedPhysicalCube_vertex (t : Finset α) : + integerAffineCube (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) t = + fun k => c k + Sum.elim + (fun g => integerScalarCubeValue (fun i => (x g i : ℤ)) t) + (fun j => integerScalarCubeValue (fun i => (y j i : ℤ)) t) k := by + funext k + cases k <;> simp only [integerAffineCube, allocatedPhysicalCubeRoot, + allocatedPhysicalCubeDirections, Sum.elim_inl, Sum.elim_inr, integerScalarCubeValue] <;> ring + +omit [Fintype α] in +theorem allocatedPhysicalCube_principal_columns (i : Unit ⊕ α) + (j : PrincipalTupleIndex B (layerSamplerDegree I n)) : + physicalCubeCoefficient (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) i (some (.inr j)) = + principalSpatialColumns (fun j => c (.inr j)) id y i j := by + cases i <;> rfl + +omit [Fintype α] in +theorem allocatedPhysicalCube_kernel_columns (i : Unit ⊕ α) (g : G) : + physicalCubeCoefficient (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) i (some (.inl g)) = + rootDifferenceMatrix (fun g => c (.inl g) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) i (.inr g) := by + cases i <;> rfl + +omit [Fintype α] in +theorem allocatedPhysicalCube_base_column (i : Unit ⊕ α) : + physicalCubeCoefficient (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) i none = + rootDifferenceMatrix (fun g => c (.inl g) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) i (.inl ()) := by + cases i with + | inl i => cases i; rfl + | inr i => rfl + +theorem allocatedPhysicalCube_physical_vertex {X : Type*} (base : X → ℤ) + (z : Option (LayerSamplerVariables G I n B) × X → ℤ) (a : X) (t : Finset α) : + physicalCubeRootDifferences (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z a (.inl ()) + + ∑ i ∈ t, physicalCubeRootDifferences (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z a (.inr i) = + jointIntegerPhysicalSite (fun k => c k + Sum.elim + (fun g => integerScalarCubeValue (fun i => (x g i : ℤ)) t) + (fun j => integerScalarCubeValue (fun i => (y j i : ℤ)) t) k) (base, z) a := by + rw [physicalCubeRootDifferences_vertex, allocatedPhysicalCube_vertex] + +omit [Fintype α] in +theorem allocatedPhysicalCube_join_columns + (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) + (v : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U basis S.value a) + (allocatedPrincipalSides B U basis S)) + (i : Unit ⊕ α) (j : PrincipalTupleIndex B (layerSamplerDegree I n)) : + physicalCubeCoefficient (allocatedPhysicalCubeRoot B U basis S c x + (principalAxisJoin (allocatedGridAxis (I := I) U basis S.value) u v)) + (allocatedPhysicalCubeDirections B U basis S x + (principalAxisJoin (allocatedGridAxis (I := I) U basis S.value) u v)) i (some (.inr j)) = + allocatedSpatialColumns B U basis S u (fun _ : Unit => fun j => c (.inr j)) + (fun _ : Unit => id) v () i j := by + exact allocatedPhysicalCube_principal_columns B U basis S c x _ i j + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem kernelCubeBox_site_le_exp {G : Type*} {q L : ℕ} + (c : G → ℤ) (x : G → IntegerScalarCubeBox (Fin q) L) {P : ℝ} + (hc : ∀ g, |(c g : ℝ)| ≤ Real.exp P) (hL : (L : ℝ) ≤ Real.exp P) + (s : Finset (Fin q)) (g : G) : + |((BooleanCubeKernel.affineSite (fun g => c g + (x g none : ℤ)) + (fun i g => (x g (some i) : ℤ)) s (some g) : ℤ) : ℝ)| ≤ Real.exp (P + (q + 2 : ℕ)) := by + have hx (i) : |((x g i : ℤ) : ℝ)| ≤ Real.exp P := by + have hi := Finset.mem_Ico.mp (x g i).property + have hl : |((x g i : ℤ) : ℝ)| ≤ L := by exact_mod_cast abs_le.mpr ⟨hi.1, hi.2.le⟩ + exact hl.trans hL + have hs : (s.card : ℝ) ≤ q := by + exact_mod_cast (show s.card ≤ q from by simpa only [Fintype.card_fin] using s.card_le_univ) + have hsum : |∑ i ∈ s, ((x g (some i) : ℤ) : ℝ)| ≤ (q : ℝ) * Real.exp P := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _i ∈ s, Real.exp P := Finset.sum_le_sum (fun i _ => hx (some i)) + _ = (s.card : ℝ) * Real.exp P := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right hs (Real.exp_nonneg P) + have hraw : |(c g : ℝ) + ((x g none : ℤ) : ℝ) + ∑ i ∈ s, ((x g (some i) : ℤ) : ℝ)| ≤ + ((q : ℝ) + 2) * Real.exp P := by + have h := (abs_add_le _ _).trans (add_le_add ((abs_add_le _ _).trans (add_le_add (hc g) (hx none))) hsum) + nlinarith + calc + _ = |(c g : ℝ) + ((x g none : ℤ) : ℝ) + ∑ i ∈ s, ((x g (some i) : ℤ) : ℝ)| := by + simp only [BooleanCubeKernel.affineSite, Int.cast_add, Int.cast_sum] + _ ≤ ((q : ℝ) + 2) * Real.exp P := hraw + _ ≤ Real.exp ((q : ℝ) + 2) * Real.exp P := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg P) + linarith [Real.add_one_le_exp ((q : ℝ) + 2)] + _ = _ := by rw [← Real.exp_add]; congr 1; push_cast; ring + +namespace VectorPolynomial + +open BooleanCubeKernel Polynomial + +theorem exists_allocated_fixed_kernel_cover (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + {P : ℝ} (_hP : 0 ≤ P) (_hG : (Fintype.card G : ℝ) ≤ P) + (_hc : ∀ g, |(c (.inl g) : ℝ)| ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ (y : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S)) + {F : Type*} [Fintype F] + (frequency : F → ∀ j, (LayerSamplerVariables G I n B →₀ ℕ) → J j → ℤ), + (∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ Real.exp P) → + ∃ b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ a j s t, |(b a j s t : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ {X : Type*} (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (coeff : F → ℂ) + (z : Option (LayerSamplerVariables G I n B) → X → ℝ), + affineCubeFourierProjection U (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) frequency p coeff z = + retainedSiteFourierSum U (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) frequency b coeff + (affineCoveredSiteSample U (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) D p hm z) := by + obtain ⟨A₀, _, hcover⟩ := exists_fixed_kernel_site_fourier_projection m q + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget ((X + C (q + 2 + A₀)) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro G _ I _ n B _ J _ U basis R σ S c x P hP hG hc hL M hperiod + let Q := P + (q + 2 : ℕ) + have hPQ : P ≤ Q := le_add_of_nonneg_right (Nat.cast_nonneg _) + have hQ : 0 ≤ Q := hP.trans hPQ + have hbound : (Q + A₀) ^ A₀ ≤ (P + A) ^ A := by + simpa [Q, Polynomial.eval₂_pow, Nat.cast_add, add_assoc] using hbudget P hP + obtain ⟨a, ha, _, hperiod⟩ := hperiod + obtain ⟨D, hD, hDP, hrows⟩ := hcover (fun g => c (.inl g) + (x g none : ℤ)) + (fun i g => (x g (some i) : ℤ)) (a : ℤ) (by exact_mod_cast ha.ne') hperiod hQ (hG.trans hPQ) + (kernelCubeBox_site_le_exp (fun g => c (.inl g)) x hc hL) + refine ⟨D, hD, hDP.trans (Real.exp_le_exp.mpr hbound), ?_⟩ + intro y F _ frequency hfrequency + obtain ⟨b, hb, he⟩ := hrows (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) Sum.inl (fun _ => rfl) (fun _ _ => rfl) U frequency + (fun a j d hd t => (hfrequency a j d hd t).trans (Real.exp_le_exp.mpr hPQ)) + exact ⟨b, fun a j s t => (hb a j s t).trans (Real.exp_le_exp.mpr hbound), he⟩ + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedKernelReplacement.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedKernelReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbf231b80426abdd68f252a9f1a0c02914ae3187 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedKernelReplacement.lean @@ -0,0 +1,601 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedIntegerKernelComparison +import OAI.Combinatorics.Progressions.Linear.KernelCoefficientLogBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem coefficientFiberControl_change_decidableEq {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] {d₁ d₂ : DecidableEq J} + {A : Matrix I J ℤ} {s : I ↪ J} {S : J → ℝ} {H L C U M : ℝ} {h : ℕ} + (hc : @CoefficientFiberControl I J _ _ _ d₁ A s S H L h C U M) : + @CoefficientFiberControl I J _ _ _ d₂ A s S H L h C U M := by + have hd : d₁ = d₂ := Subsingleton.elim _ _ + cases hd + exact hc + +def layerKernelIndexBound (m B : ℕ) : ℕ := B^(m*2^(m+1)) + +theorem layerKernelIndexBound_row {m B : ℕ} {α O : Type*} [Fintype α] [Fintype O] + (hB : 0 < B) (hq : Fintype.card α ≤ m+1) (rows : O → Finset α) + (hinj : Function.Injective rows) (j : Fin m) : + (B^(j.val+1))^Fintype.card O ≤ layerKernelIndexBound m B := by + have hc : Fintype.card O ≤ 2^(m+1) := by + have hr : Fintype.card O ≤ 2^Fintype.card α := by + simpa only [Fintype.card_finset] using Fintype.card_le_of_injective rows hinj + exact hr.trans (Nat.pow_le_pow_right (by decide : 0 < 2) hq) + rw [← pow_mul] + exact Nat.pow_le_pow_right hB (Nat.mul_le_mul (Nat.succ_le_of_lt j.isLt) hc) + +theorem layerKernelIndexBound_le_exp (m : ℕ) {B : ℕ} {p : ℝ} + (hB : (B : ℝ) ≤ Real.exp p) : + (layerKernelIndexBound m B : ℝ) ≤ Real.exp ((m*2^(m+1) : ℕ)*p) := by + unfold layerKernelIndexBound + rw [Nat.cast_pow, Real.exp_nat_mul] + exact pow_le_pow_left₀ (Nat.cast_nonneg _) hB _ + +noncomputable def fixedKernelInverseBound {α G O : Type*} + [Fintype α] [DecidableEq α] [Fintype G] [DecidableEq G] [Fintype O] [DecidableEq O] + {L : ℕ} (hL : 0 < L) (x : G → IntegerScalarCubeBox α L) (degree : ℕ) + (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent G degree) + (hA : ((scalarKernelIntegerJet x degree rows).submatrix id s).det ≠ 0) (κ : ℝ) : Prop := + ‖(scalarKernelFixedPivot hL x degree rows s hA).symm.toContinuousLinearMap‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card G) (Fintype.card O) degree κ + +namespace VectorPolynomial + +open scoped Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) + +theorem allocatedPartitionedInput_bound + (u : PrincipalAxisTuples (α := α) grid sides) + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) : + ∀ k a, |((Sum.elim + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (principalTupleIntegers v) (input k a) : ℤ) : ℝ) / layerSamplerBox B U basis S k| ≤ 1 := by + exact mappedPrincipal_normalized_bound + (fun a : {a // ¬grid a} => B a.val) (fun a => layerSamplerDegree I n a.val) + (principalAxisLength (fun a => ¬grid a) sides) + (fun d => allocatedPrincipalSides_pos B U basis S ⟨d.1.val, d.2⟩) input + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (Sum.elim (fun ga : G × Option α => ((x ga.1 ga.2 : ℤ) : ℝ)/S.value) + (principalTupleNormalized (principalAxisLength grid sides) u)) + (allocatedPartitionedInput_frozen_bound B U basis S x u) (layerSamplerBox B U basis S) v + (allocatedPartitionedInput_normalized B U basis S x u v) + +variable [DecidableEq G] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +theorem allocatedGoodKernel_controls {κ : ℝ} {M : ℕ} + (selection : α ↪ G) (hκ : 0 < κ) (hx : GoodScalarKernelTuple selection κ M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) : + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) κ) ∧ + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) j (i : Fin (n j)), + CoefficientFiberControl + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) (rows j)) + (allocatedNonkernelJetMatrix B U basis S x u rows j v)) + ((s j).trans Function.Embedding.inl) + (Sum.elim (kernelJetCoefficientScale G (j.val+1) S.value (basisAxisScale (basis j) i)) + (fun d => (basisAxisScale (basis j) i : ℝ) / + monomialScale (layerSamplerBox B U basis S) (allocatedNonkernelExponent B j d))) + (basisAxisScale (basis j) i) S.value (j.val+1) + (kernelJetEntryAllowance (Fintype.card α) (j.val+1)) + (kernelJetInverseAllowance (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) κ) + (layerKernelIndexBound m M) := by + have hM : 0 < M := by + obtain ⟨a, ha, haM, _⟩ := hx.2 + exact ha.trans_le haM + obtain ⟨s, hA, hi⟩ := goodKernel_fixed_pivots + S.positive selection hκ x hx (fun j : Fin m => j.val+1) rows hinj hrows + refine ⟨s, hA, hi, ?_⟩ + intro u v j i + have hH : (0 : ℝ) < basisAxisScale (basis j) i := Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) + have hcontrol := fixedKernel_mapped_control S.positive selection x hx (j.val+1) (rows j) + (hinj j) (hrows j) (s j) (hA j) (hi j) hH (allocatedNonkernelExponent B j) input + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (principalTupleIntegers v) (layerSamplerBox B U basis S) + (fun k => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S k)) + (layerSamplerBox_le B U basis S) (allocatedNonkernelExponent_degree B j) + (allocatedPartitionedInput_bound B U basis S x u v) + (show (((M^(j.val+1))^Fintype.card (O j) : ℕ) : ℝ) ≤ layerKernelIndexBound m M by + exact_mod_cast layerKernelIndexBound_row hM hq (rows j) (hinj j) j) + exact coefficientFiberControl_change_decidableEq hcontrol + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) + +variable [DecidableEq G] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +theorem allocatedFixedKernel_controls {κ : ℝ} {M : ℕ} + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection κ M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) + (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) κ) : + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) j (i : Fin (n j)), + CoefficientFiberControl + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) (rows j)) + (allocatedNonkernelJetMatrix B U basis S x u rows j v)) + ((s j).trans Function.Embedding.inl) + (Sum.elim (kernelJetCoefficientScale G (j.val+1) S.value (basisAxisScale (basis j) i)) + (fun d => (basisAxisScale (basis j) i : ℝ) / + monomialScale (layerSamplerBox B U basis S) (allocatedNonkernelExponent B j d))) + (basisAxisScale (basis j) i) S.value (j.val+1) + (kernelJetEntryAllowance (Fintype.card α) (j.val+1)) + (kernelJetInverseAllowance (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) κ) + (layerKernelIndexBound m M) := by + have hM : 0 < M := by + obtain ⟨a, ha, haM, _⟩ := hx.2 + exact ha.trans_le haM + intro u v j i + have hH : (0 : ℝ) < basisAxisScale (basis j) i := Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) + have hcontrol := fixedKernel_mapped_control S.positive selection x hx (j.val+1) (rows j) + (hinj j) (hrows j) (s j) (hA j) (hi j) hH (allocatedNonkernelExponent B j) input + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (principalTupleIntegers v) (layerSamplerBox B U basis S) + (fun k => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S k)) + (layerSamplerBox_le B U basis S) (allocatedNonkernelExponent_degree B j) + (allocatedPartitionedInput_bound B U basis S x u v) + (show (((M^(j.val+1))^Fintype.card (O j) : ℕ) : ℝ) ≤ layerKernelIndexBound m M by + exact_mod_cast layerKernelIndexBound_row hM hq (rows j) (hinj j) j) + exact coefficientFiberControl_change_decidableEq hcontrol + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +theorem layerKernelIndexBound_row_withCutoff (d : ℕ) + {m B : ℕ} {α O : Type*} [Fintype α] [Fintype O] + (hB : 0 < B) (hq : Fintype.card α ≤ d + 1) (rows : O → Finset α) + (hinj : Function.Injective rows) (j : Fin m) : + (B ^ (j.val + 1)) ^ Fintype.card O ≤ layerKernelIndexBound (max m d) B := by + let j' : Fin (max m d) := ⟨j.val, j.isLt.trans_le (le_max_left m d)⟩ + exact layerKernelIndexBound_row hB + (hq.trans (Nat.succ_le_succ (le_max_right m d))) rows hinj j' + +namespace VectorPolynomial + +open scoped Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable [DecidableEq G] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val + 1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) + +theorem allocatedGoodKernel_controls_withCutoff (d : ℕ) {κ : ℝ} {M : ℕ} + (selection : α ↪ G) (hκ : 0 < κ) (hx : GoodScalarKernelTuple selection κ M x) + (hq : Fintype.card α ≤ d + 1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val + 1) : + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) κ) ∧ + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) j (i : Fin (n j)), + CoefficientFiberControl + (Matrix.fromCols (scalarKernelIntegerJet x (j.val + 1) (rows j)) + (allocatedNonkernelJetMatrix B U basis S x u rows j v)) + ((s j).trans Function.Embedding.inl) + (Sum.elim (kernelJetCoefficientScale G (j.val + 1) S.value (basisAxisScale (basis j) i)) + (fun e => (basisAxisScale (basis j) i : ℝ) / + monomialScale (layerSamplerBox B U basis S) (allocatedNonkernelExponent B j e))) + (basisAxisScale (basis j) i) S.value (j.val + 1) + (kernelJetEntryAllowance (Fintype.card α) (j.val + 1)) + (kernelJetInverseAllowance (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) + (j.val + 1) κ) + (layerKernelIndexBound (max m d) M) := by + have hM : 0 < M := by + obtain ⟨a, ha, haM, _⟩ := hx.2 + exact ha.trans_le haM + obtain ⟨s, hA, hi⟩ := goodKernel_fixed_pivots + S.positive selection hκ x hx (fun j : Fin m => j.val + 1) rows hinj hrows + refine ⟨s, hA, hi, ?_⟩ + intro u v j i + have hH : (0 : ℝ) < basisAxisScale (basis j) i := Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) + have hcontrol := fixedKernel_mapped_control S.positive selection x hx (j.val + 1) (rows j) + (hinj j) (hrows j) (s j) (hA j) (hi j) hH (allocatedNonkernelExponent B j) input + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (principalTupleIntegers v) (layerSamplerBox B U basis S) + (fun k => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S k)) + (layerSamplerBox_le B U basis S) (allocatedNonkernelExponent_degree B j) + (allocatedPartitionedInput_bound B U basis S x u v) + (show (((M ^ (j.val + 1)) ^ Fintype.card (O j) : ℕ) : ℝ) ≤ + layerKernelIndexBound (max m d) M by + exact_mod_cast layerKernelIndexBound_row_withCutoff d hM hq (rows j) (hinj j) j) + exact coefficientFiberControl_change_decidableEq hcontrol + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] +variable (rows : ∀ j, O j → Finset α) + +theorem allocatedIntegerKernelMask_bound {M : ℕ} {κ : ℝ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection κ M x) + (hq : Fintype.card α ≤ m + 1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val + 1) + (j : Fin m) (modulus : ℕ) + (residue : Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + (z : O j → ℤ) : + 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus residue z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus residue z ≤ layerKernelIndexBound m M := by + unfold allocatedIntegerKernelMask coefficientResidueMultiplier + refine ⟨coefficientImageMultiplier_nonneg _ _, (coefficientImageMultiplier_le_index _ _).trans ?_⟩ + have hi := scalarKernelJet_extended_index selection x hx (j.val + 1) (rows j) + (hinj j) (hrows j) (liftResidueMatrix residue) + exact_mod_cast hi.trans (layerKernelIndexBound_row hM hq (rows j) (hinj j) j) + +theorem allocatedIntegerKernelMask_le_exp {M : ℕ} {κ p : ℝ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection κ M x) + (hq : Fintype.card α ≤ m + 1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val + 1) (hMp : (M : ℝ) ≤ Real.exp p) + (j : Fin m) (modulus : ℕ) + (residue : Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + (z : O j → ℤ) : + allocatedIntegerKernelMask B U basis S x rows j modulus residue z ≤ + Real.exp ((m * 2 ^ (m + 1) : ℕ) * p) := + (allocatedIntegerKernelMask_bound B U basis S x rows hM selection hx hq hinj hrows j modulus residue z).2.trans + (layerKernelIndexBound_le_exp m hMp) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +noncomputable def allocatedKernelLog (G α : Type*) [Fintype G] [Fintype α] + {m : ℕ} (O : Fin m → Type*) [∀ j, Fintype (O j)] (P : ℝ) : ℝ := + P + (m*2^(m+1) : ℕ)*P + (Fintype.card α : ℝ)*(m+1) + + ∑ j, kernelInverseLog (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) P + +theorem allocatedKernelLog_bounds (G α : Type*) [Fintype G] [Fintype α] + {m : ℕ} (O : Fin m → Type*) [∀ j, Fintype (O j)] {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ allocatedKernelLog G α O P ∧ P ≤ allocatedKernelLog G α O P ∧ + (m*2^(m+1) : ℕ)*P ≤ allocatedKernelLog G α O P ∧ + (Fintype.card α : ℝ)*(m+1) ≤ allocatedKernelLog G α O P ∧ + ∀ j, kernelInverseLog (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) P ≤ + allocatedKernelLog G α O P := by + have hi (j : Fin m) : 0 ≤ kernelInverseLog + (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) P := by + unfold kernelInverseLog + positivity + have hs := Finset.sum_nonneg (fun j (_ : j ∈ (Finset.univ : Finset (Fin m))) => hi j) + have hidx : 0 ≤ (m*2^(m+1) : ℕ)*(P : ℝ) := by positivity + have hentry : 0 ≤ (Fintype.card α : ℝ)*(m+1) := by positivity + unfold allocatedKernelLog + refine ⟨by positivity, by linarith, by linarith, by linarith, ?_⟩ + intro j + have hj := Finset.single_le_sum (fun k _ => hi k) (Finset.mem_univ j) + linarith + +theorem allocatedKernelLog_allowances (G α : Type*) [Fintype G] [Fintype α] + {m : ℕ} (O : Fin m → Type*) [∀ j, Fintype (O j)] {P : ℝ} {M : ℕ} + (hP : 0 ≤ P) (hM : 0 < M) (hMP : (M : ℝ) ≤ Real.exp P) : + (layerKernelIndexBound m M : ℝ) ≤ Real.exp (allocatedKernelLog G α O P) ∧ + ∀ j, kernelJetEntryAllowance (Fintype.card α) (j.val+1) ≤ Real.exp (allocatedKernelLog G α O P) ∧ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) + (1/(M : ℝ)) ≤ Real.exp (allocatedKernelLog G α O P) := by + have hb := allocatedKernelLog_bounds G α O hP + refine ⟨(layerKernelIndexBound_le_exp m hMP).trans (Real.exp_le_exp.mpr hb.2.2.1), ?_⟩ + intro j + constructor + · apply (kernelJetEntryAllowance_le_exp (Fintype.card α) (j.val+1)).trans + apply Real.exp_le_exp.mpr + apply le_trans _ hb.2.2.2.1 + gcongr + exact_mod_cast Nat.succ_le_of_lt j.isLt + · have hκ : 0 < 1/(M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + have hv := kernelJetInverseAllowance_le_exp (Fintype.card α) (Fintype.card G) + (Fintype.card (O j)) (j.val+1) hκ hP (by simpa only [one_div, inv_inv] using hMP) + exact hv.trans (Real.exp_le_exp.mpr (hb.2.2.2.2 j)) + +namespace VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +noncomputable def allocatedKernelReplacementLog (α : Type*) [Fintype α] + (O : Fin m → Type*) [∀ j, Fintype (O j)] (P e : ℝ) : ℝ := + ∑ j, coefficientFrontLog (Fintype.card (O j)) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) + (allocatedKernelLog G α O P) (4*(P+8)) e + +theorem allocatedKernelReplacementLog_front_le (α : Type*) [Fintype α] + (O : Fin m → Type*) [∀ j, Fintype (O j)] {P e : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (j : Fin m) : + coefficientFrontLog (Fintype.card (O j)) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) + (allocatedKernelLog G α O P) (4*(P+8)) e ≤ allocatedKernelReplacementLog (G := G) B α O P e := by + apply Finset.single_le_sum _ (Finset.mem_univ j) + intro k _ + exact coefficientFrontLog_nonneg _ _ (allocatedKernelLog_bounds G α O hP).1 (by positivity) he + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable [DecidableEq G] [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +theorem allocatedGoodKernel_replacement {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) : + ∃ (modulus : ℕ) (_hm : 0 < modulus), modulus ≤ M^(m+1) ∧ + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ α) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) ∧ + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (p : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides)) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + (∀ v, p.weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) → + ∀ j i (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i), + (∀ z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ≤ layerKernelIndexBound m M) ∧ + ∀ v, p.weight v ≠ 0 → ∀ z, + |(basisAxisScale (basis j) i : ℝ)^Fintype.card (O j) * + (allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i (hσ1 j) henormous z).toReal - + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z * + allocatedIntegerKernelDensity B U basis S j i x u (rows j) (s j) (hA j) + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (fun o => (z o : ℝ)/(basisAxisScale (basis j) i : ℝ))| ≤ ε := by + have hκ : 0 < 1/(M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + obtain ⟨modulus, hm, hmB, hspatial, hperiod⟩ := goodKernel_common_period selection x hx (m+1) + (Nat.succ_le_succ (Nat.zero_le m)) (fun j : Fin m => j.val+1) + (fun j => (Nat.succ_le_of_lt j.isLt).trans (Nat.le_succ _)) rows hinj hrows + obtain ⟨s, hA, hi, hcontrol⟩ := allocatedGoodKernel_controls B U basis S x rows selection hκ hx hq hinj hrows + refine ⟨modulus, hm, hmB, hspatial, hperiod, s, hA, hi, ?_⟩ + intro u p residue hr j i henormous + have hb := allocatedKernelLog_bounds G α O hP + have ha := allocatedKernelLog_allowances G α O hP hM hMP + have ht : 0 ≤ 4*(P+8) := by positivity + have hf := (Real.exp_le_exp.mpr (allocatedKernelReplacementLog_front_le (G := G) B α O hP he j)).trans hlarge + exact allocatedIntegerKernel_residue_family B U basis hR hσ S x u rows j i (s j) (hA j) (hσ1 j) + henormous p modulus (residue j) (hperiod j) (fun v hv => hr v hv j) + (kernelJetEntryAllowance_pos _ _).le (kernelJetInverseAllowance_nonneg _ _ _ _ hκ) + (Nat.cast_nonneg _) (fun v _ => hcontrol u v j i) + hb.1 ht hε ha.1 (ha.2 j).2 (ha.2 j).1 ((hRP j).trans (Real.exp_le_exp.mpr hb.2.1)) + (allocatedUnitProfileWidth_inverse_exp _ hP (hR j) (hσ j) (hRi j) (hσi j) (hcount j)) + (allocatedInteger_replacementScale_le B U basis S j i (rows j) (hinj j) hq (s j) + hb.1 ht he hε hεe hf henormous) + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) + +variable [DecidableEq G] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +theorem allocatedFixedKernel_controls_withCutoff (d : ℕ) {κ : ℝ} {M : ℕ} + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection κ M x) + (hq : Fintype.card α ≤ d+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) + (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) κ) : + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) j (i : Fin (n j)), + CoefficientFiberControl + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) (rows j)) + (allocatedNonkernelJetMatrix B U basis S x u rows j v)) + ((s j).trans Function.Embedding.inl) + (Sum.elim (kernelJetCoefficientScale G (j.val+1) S.value (basisAxisScale (basis j) i)) + (fun e => (basisAxisScale (basis j) i : ℝ) / + monomialScale (layerSamplerBox B U basis S) (allocatedNonkernelExponent B j e))) + (basisAxisScale (basis j) i) S.value (j.val+1) + (kernelJetEntryAllowance (Fintype.card α) (j.val+1)) + (kernelJetInverseAllowance (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) κ) + (layerKernelIndexBound (max m d) M) := by + have hM : 0 < M := by + obtain ⟨a, ha, haM, _⟩ := hx.2 + exact ha.trans_le haM + intro u v j i + have hH : (0 : ℝ) < basisAxisScale (basis j) i := Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) + have hcontrol := fixedKernel_mapped_control S.positive selection x hx (j.val+1) (rows j) + (hinj j) (hrows j) (s j) (hA j) (hi j) hH (allocatedNonkernelExponent B j) input + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (principalTupleIntegers v) (layerSamplerBox B U basis S) + (fun k => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S k)) + (layerSamplerBox_le B U basis S) (allocatedNonkernelExponent_degree B j) + (allocatedPartitionedInput_bound B U basis S x u v) + (show (((M^(j.val+1))^Fintype.card (O j) : ℕ) : ℝ) ≤ layerKernelIndexBound (max m d) M by + exact_mod_cast layerKernelIndexBound_row_withCutoff d hM hq (rows j) (hinj j) j) + exact coefficientFiberControl_change_decidableEq hcontrol + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable [DecidableEq G] [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +theorem allocatedFixedKernel_replacement {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) + (modulus : ℕ) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) + (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) : + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (p : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides)) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + (∀ v, p.weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) → + ∀ j i (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i), + (∀ z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ≤ layerKernelIndexBound m M) ∧ + ∀ v, p.weight v ≠ 0 → ∀ z, + |(basisAxisScale (basis j) i : ℝ)^Fintype.card (O j) * + (allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i (hσ1 j) henormous z).toReal - + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z * + allocatedIntegerKernelDensity B U basis S j i x u (rows j) (s j) (hA j) + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (fun o => (z o : ℝ)/(basisAxisScale (basis j) i : ℝ))| ≤ ε := by + have hκ : 0 < 1/(M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + have hcontrol := allocatedFixedKernel_controls B U basis S x rows selection hx hq hinj hrows s hA hi + intro u p residue hr j i henormous + have hb := allocatedKernelLog_bounds G α O hP + have ha := allocatedKernelLog_allowances G α O hP hM hMP + have ht : 0 ≤ 4*(P+8) := by positivity + have hf := (Real.exp_le_exp.mpr (allocatedKernelReplacementLog_front_le (G := G) B α O hP he j)).trans hlarge + exact allocatedIntegerKernel_residue_family B U basis hR hσ S x u rows j i (s j) (hA j) (hσ1 j) + henormous p modulus (residue j) (hperiod j) (fun v hv => hr v hv j) + (kernelJetEntryAllowance_pos _ _).le (kernelJetInverseAllowance_nonneg _ _ _ _ hκ) + (Nat.cast_nonneg _) (fun v _ => hcontrol u v j i) + hb.1 ht hε ha.1 (ha.2 j).2 (ha.2 j).1 ((hRP j).trans (Real.exp_le_exp.mpr hb.2.1)) + (allocatedUnitProfileWidth_inverse_exp _ hP (hR j) (hσ j) (hRi j) (hσi j) (hcount j)) + (allocatedInteger_replacementScale_le B U basis S j i (rows j) (hinj j) hq (s j) + hb.1 ht he hε hεe hf henormous) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedPathKernelFrameBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedPathKernelFrameBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb9d40a03682d6834f79b81b50faafaf4aef8bf5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFixedPathKernelFrameBounds.lean @@ -0,0 +1,62 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedFixedPathSlicedPhysicalDensityComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open BooleanCubeKernel +open scoped Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) +local notation "FullInput" => PrincipalTupleIndex B (layerSamplerDegree I n) + +theorem allocatedFixedPathKernel_card_mul_scale_le_budget : + (Fintype.card G : ℝ) * (S.value : ℝ) ≤ budget := by + rw [allocatedPhysicalRootBudget_zero] + apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) + exact Nat.cast_le.mpr (Fintype.card_le_of_injective + (Sum.inl : G → LayerSamplerVariables G I n B) Sum.inl_injective) + +theorem allocatedFixedPathKernelFrame_abs_le_one + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : 0 < ξ) + (box : X → ℕ) (hbox : ∀ x, 0 < box x) + (integerFrame : Option (LayerSamplerVariables G I n B) × X → ℤ) + (hframe : integerFrame ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths (G := G) (J := FullInput) budget τ ξ box) 1) + (a : Option G × X) : + |allocatedFixedPathKernelFrame B U basis S τ ξ box integerFrame a| ≤ 1 := by + have hnorm := rectangularWeightIndices_normalized_norm_le _ + (narrowTrimmedSpatialWidths_pos + (allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0)) hτ hξ box hbox) hframe + change |(integerFrame (canonicalZeroSpatialKernelEmbedding G FullInput X a) : ℝ) / + narrowTrimmedSpatialWidths (G := G) (J := FullInput) budget τ ξ box + (canonicalZeroSpatialKernelEmbedding G FullInput X a)| ≤ 1 + exact (Real.norm_eq_abs _).symm ▸ + (norm_le_pi_norm _ (canonicalZeroSpatialKernelEmbedding G FullInput X a)).trans hnorm + +theorem allocatedFixedPathKernelFrame_geometry + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : 0 < ξ) + (box : X → ℕ) (hbox : ∀ x, 0 < box x) + (integerFrame : Option (LayerSamplerVariables G I n B) × X → ℤ) + (hframe : integerFrame ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths (G := G) (J := FullInput) budget τ ξ box) 1) : + 0 ≤ budget ∧ 0 ≤ (S.value : ℝ) ∧ + (Fintype.card G : ℝ) * (S.value : ℝ) ≤ budget ∧ + ∀ a, |allocatedFixedPathKernelFrame B U basis S τ ξ box integerFrame a| ≤ 1 := + ⟨allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0), Nat.cast_nonneg _, + allocatedFixedPathKernel_card_mul_scale_le_budget B U basis S, + allocatedFixedPathKernelFrame_abs_le_one B U basis S hτ hξ box hbox integerFrame hframe⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFrozenTaggedTwistFixedBasisStepDrop.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFrozenTaggedTwistFixedBasisStepDrop.lean new file mode 100644 index 0000000000000000000000000000000000000000..37fd75a99bc60663ac39a1ded00672f446a63ced --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedFrozenTaggedTwistFixedBasisStepDrop.lean @@ -0,0 +1,213 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedFrozenTaggedTwistStepDrop +import OAI.Combinatorics.Progressions.Polynomial.PolynomialSymbolBasisIndependence + +namespace OAI + +universe u + +section + +namespace Erdos3 +open Module RationalFilteredNilmanifold BooleanCubeKernel +open VectorPolynomial +open scoped TensorProduct BigOperators NNReal + +theorem exists_native_twist_variation_slice_fixed_basis_step_drop (s : ℕ) (hs : 1 ≤ s) : + ∃ C A : ℕ, 2 ≤ C ∧ 2 ≤ A ∧ ∀ + {LG MG : Type u} [LieRing LG] [LieAlgebra ℚ LG] [LieRing MG] [LieAlgebra ℚ MG] + {d e : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] LG)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] LG)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] LG)] [T2Space (ℝ ⊗[ℚ] LG)] + [TopologicalSpace (ℝ ⊗[ℚ] MG)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] MG)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] MG)] [T2Space (ℝ ⊗[ℚ] MG)] + (D : RationalFilteredNilmanifold LG s d) (E : RationalFilteredNilmanifold MG s e) + {pGeo : ℝ} (_hpGeo : 0 ≤ pGeo) + (_hGeo : (pi (pairModels D E)).GeometryComplexityLE pGeo), + ∃ (c : Basis (Fin (finrank ℚ (PairAlgebra LG MG))) ℚ (PairAlgebra LG MG)) + (ν : Fin (finrank ℚ (PairAlgebra LG MG)) → ℕ) + (hC : ∀ k, (pi (pairModels D E)).filtration.layer k = + Submodule.span ℚ (c '' {i | k ≤ ν i})), + (∀ i j, rationalLogHeight ((pi (pairModels D E)).basis.repr (c i) j) ≤ pGeo + 1) ∧ + (∀ i j, rationalLogHeight (c.repr ((pi (pairModels D E)).basis i) j) ≤ (pGeo + 3) ^ 5) ∧ + ∀ {K : Type*} + [Fintype K] [DecidableEq K] [Nonempty K] + {P : K → ℕ} {q : ℕ} (S : ResidueBoxSlice P q) (_hq : 0 < q) + (hlen : ∀ k, 0 < S.length k) {p : ℝ} (_hp : 0 ≤ p) + (_hS : ∀ k, Real.exp (-p) * (P k : ℝ) ≤ S.length k) + (_hP : ∀ k, Real.exp ((p + 2 + C) ^ C + 7 * p + 22) ≤ (P k : ℝ)) + {M : ℕ} (_hM : 0 < M) (_hperiod : (M : ℝ) ≤ Real.exp p) + (twist : integerBox P → ℂ) (_htwist : ∀ t, ‖twist t‖ ≤ 1) + {variation : ℝ} (_hvariation_nonneg : 0 ≤ variation) + (_hvariation_bound : variation ≤ Real.exp p) + (_hvariation : ∀ u v : integerBox P, + (∀ k, (u.val k : ZMod M) = (v.val k : ZMod M)) → + ∀ δ : ℝ, 0 ≤ δ → + (∀ k, |(u.val k : ℝ) / P k - (v.val k : ℝ) / P k| ≤ δ) → + ‖twist u - twist v‖ ≤ variation * δ) + (V : D.Niltest (fun _ : K => 1)) (W : E.Niltest (fun _ : K => 1)) + (_hV : V.ComplexityLE p) (_hW : W.ComplexityLE p) (_hWnorm : W.normBound ≤ 1) + (η : LG →ₗ[ℚ] ℚ) (θ : MG →ₗ[ℚ] ℚ) + (_hηheight : ∀ i, rationalLogHeight (η (D.basis i)) ≤ p) + (_hθheight : ∀ i, rationalLogHeight (θ (E.basis i)) ≤ p) + (_hη : ∀ z, z ∈ D.filtration.realification.subgroup s → ∀ x, + V.observable (z • x) = CircleFourier.character + ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * V.observable x) + (_hθ : ∀ z, z ∈ E.filtration.realification.subgroup s → ∀ x, + W.observable (z • x) = CircleFourier.character + ((realifyFunctional θ z.coord : ℝ) : CircleFourier.Circle) * W.observable x) + (_hK : (Fintype.card K : ℝ) ≤ p) + (_hbias : Real.exp (-p) ≤ ‖(S.fullSliceLaw hlen).complexMean (fun t => + star (twist t) * + (V.eval t.val * W.eval t.val))‖), + (pi (pairModels D E)).filtration.ControlledSymbolFactorization c ν hC + (pairFrequency η θ) (fun k => (P k : ℝ)) + (pairOrbitSymbol D E V.orbit W.orbit c ν hC) + ((fixedAdaptedSymbolTransferInput pGeo + (pGeo + p + ((p + 2 + C) ^ C + (s : ℝ) * (9 * p + 23))) + A) ^ A) := by + obtain ⟨C, hC, hstep⟩ := exists_native_twist_variation_slice_step_drop s hs + obtain ⟨A, hA, hfixed⟩ := exists_fixed_adapted_symbol_factorization_basis s + refine ⟨C, A, hC, hA, ?_⟩ + intro LG MG _ _ _ _ d e _ _ _ _ _ _ _ _ D E pGeo hpGeo hGeo + obtain ⟨c, ν, N, hc, _, _, hforward, hinverse, _, _, _, _, _, htransfer⟩ := + hfixed (pi (pairModels D E)) hpGeo hGeo + refine ⟨c, ν, hc, hforward, hinverse, ?_⟩ + intro K _ _ _ P q S hq hlen p hp hS hP M hM hperiod twist htwist + variation hvariation_nonneg hvariation_bound hvariation + V W hV hW hWnorm η θ hηheight hθheight hη hθ hK hbias + obtain ⟨b, ω, hF, hb, hfactor⟩ := hstep S hq hlen hp hS hP hM hperiod + twist htwist hvariation_nonneg hvariation_bound hvariation + D E V W hV hW hWnorm η θ hηheight hθheight hη hθ hK hbias + let cost := (p + 2 + C) ^ C + (s : ℝ) * (9 * p + 23) + have hcost : 0 ≤ cost := by dsimp only [cost]; positivity + have hPpos (k : K) : (0 : ℝ) < P k := (Real.exp_pos _).trans_le (hP k) + have hqGeo : pGeo ≤ pGeo + p + cost := by linarith + have hqP : p ≤ pGeo + p + cost := by linarith + have hqCost : cost ≤ pGeo + p + cost := by linarith + have hbase : (p + 2 + C) ^ C ≤ cost := by + dsimp only [cost] + linarith [show 0 ≤ (s : ℝ) * (9 * p + 23) by positivity] + have htransferred := htransfer hqGeo (hK.trans hqP) b ω hF + (fun i j => (hb i j).trans (hbase.trans hqCost)) (fun k => (P k : ℝ)) hPpos + (pairFrequency η θ) (pairOrbitSymbol D E V.orbit W.orbit b ω hF) + (hfactor.mono (pi (pairModels D E)).filtration b ω hF hqCost hPpos) + rw [pairOrbitSymbol_basis_independent D E V.orbit W.orbit b ω hF c ν hc] at htransferred + exact htransferred + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel _root_.MvPolynomial _root_.OAI.MvPolynomial RationalFilteredNilmanifold +open scoped BigOperators NNReal Classical TensorProduct + +theorem exists_allocated_frozen_tagged_twist_fixed_basis_step_drop + (s : ℕ) (hs : 1 ≤ s) : + ∃ C A : ℕ, 2 ≤ C ∧ 2 ≤ A ∧ ∀ + {LG MG : Type u} [LieRing LG] [LieAlgebra ℚ LG] [LieRing MG] [LieAlgebra ℚ MG] + {d e : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] LG)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] LG)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] LG)] [T2Space (ℝ ⊗[ℚ] LG)] + [TopologicalSpace (ℝ ⊗[ℚ] MG)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] MG)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] MG)] [T2Space (ℝ ⊗[ℚ] MG)] + (D : RationalFilteredNilmanifold LG s d) (E : RationalFilteredNilmanifold MG s e) + {pGeo : ℝ} (_hpGeo : 0 ≤ pGeo) + (_hGeo : (pi (pairModels D E)).GeometryComplexityLE pGeo), + ∃ (bFixed : Basis (Fin (finrank ℚ (PairAlgebra LG MG))) ℚ (PairAlgebra LG MG)) + (ωFixed : Fin (finrank ℚ (PairAlgebra LG MG)) → ℕ) + (hFixed : ∀ k, (pi (pairModels D E)).filtration.layer k = + Submodule.span ℚ (bFixed '' {i | k ≤ ωFixed i})), + (∀ i j, rationalLogHeight ((pi (pairModels D E)).basis.repr (bFixed i) j) ≤ pGeo + 1) ∧ + (∀ i j, rationalLogHeight (bFixed.repr ((pi (pairModels D E)).basis i) j) ≤ (pGeo + 3) ^ 5) ∧ + ∀ {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] {I Deck J : Fin m → Type*} + [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ k, Fintype (B k)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + (hbtag : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U btag R σ) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (poly j) d ∈ U j) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (c : ∀ j, U j) (a : X → ℤ) (N : X → ℕ) (_hN : ∀ x, 0 < N x) + {τ ξ : ℝ} (_hτ : 0 < τ) (_hτ1 : τ ≤ 1) (_hξ : ξ ≤ 1) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (_hv : v ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths (allocatedPhysicalRootBudget B U btag S (fun _ => 0)) τ ξ N) 1) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I Deck n B → ℤ) + (_hread : AllocatedCenteredFramedRecoveredSampleAt B U btag hbtag o S hR hσ poly hm c a v sample read) + (_hσ1 : ∀ j, σ j ≤ 1) (Cgeo : Fin m → ℝ) (_hCgeo : ∀ j, 0 ≤ Cgeo j) + (_hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) + (_hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 / 8) + {periodCap coverCap : ℝ} {L : ℝ≥0} + (twist : NormalizedPolynomialTwist X (Σ j, J j) periodCap coverCap L) + {p : ℝ} (_hp : 0 ≤ p) + (_hperiod : ((twist.modulus * twist.cover : ℕ) : ℝ) ≤ Real.exp p) + (_hvariationBound : (L : ℝ) * (1 + (m : ℝ) * (((m + 1 : ℕ) : ℝ) * + ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ m)) ≤ Real.exp p) + (keep : LayerSamplerVariables G I n B → Prop) [Nonempty {i // keep i}] + (fixed : {i // ¬keep i} → ℤ) + (_hfixed : ∀ i, 0 ≤ fixed i ∧ fixed i < + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U btag S) i.val), + let P := fun i : {i // keep i} => + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U btag S) i.val + let β := allocatedFrozenIntegerFullChart B U btag o poly hm c a v sample keep fixed + ∀ {q : ℕ} (Q : ResidueBoxSlice P q) (_hq : 0 < q) + (hlen : ∀ i, 0 < Q.length i) + (_hQ : ∀ i, Real.exp (-p) * (P i : ℝ) ≤ Q.length i) + (_hP : ∀ i, Real.exp ((p + 2 + C) ^ C + 7 * p + 22) ≤ (P i : ℝ)) + (V : D.Niltest (fun _ : {i // keep i} => 1)) + (W : E.Niltest (fun _ : {i // keep i} => 1)) + (_hV : V.ComplexityLE p) (_hW : W.ComplexityLE p) (_hWnorm : W.normBound ≤ 1) + (η : LG →ₗ[ℚ] ℚ) (θ : MG →ₗ[ℚ] ℚ) + (_hηheight : ∀ i, rationalLogHeight (η (D.basis i)) ≤ p) + (_hθheight : ∀ i, rationalLogHeight (θ (E.basis i)) ≤ p) + (_hη : ∀ z, z ∈ D.filtration.realification.subgroup s → ∀ x, + V.observable (z • x) = CircleFourier.character + ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * V.observable x) + (_hθ : ∀ z, z ∈ E.filtration.realification.subgroup s → ∀ x, + W.observable (z • x) = CircleFourier.character + ((realifyFunctional θ z.coord : ℝ) : CircleFourier.Circle) * W.observable x) + (_hK : (Fintype.card {i // keep i} : ℝ) ≤ p) + (_hbias : Real.exp (-p) ≤ ‖(Q.fullSliceLaw hlen).complexMean (fun t => + star (twist.eval N poly (integerSampledSpatial β t.val)) * + (V.eval t.val * W.eval t.val))‖), + (pi (pairModels D E)).filtration.ControlledSymbolFactorization bFixed ωFixed hFixed + (pairFrequency η θ) (fun k => (P k : ℝ)) + (pairOrbitSymbol D E V.orbit W.orbit bFixed ωFixed hFixed) + ((fixedAdaptedSymbolTransferInput pGeo + (pGeo + p + ((p + 2 + C) ^ C + (s : ℝ) * (9 * p + 23))) + A) ^ A) := by + obtain ⟨C, A, hC, hA, hstep⟩ := + exists_native_twist_variation_slice_fixed_basis_step_drop s hs + refine ⟨C, A, hC, hA, ?_⟩ + intro LG MG _ _ _ _ d e _ _ _ _ _ _ _ _ D E pGeo hpGeo hGeo + obtain ⟨bFixed, ωFixed, hFixed, hforward, hinverse, hlocal⟩ := hstep D E hpGeo hGeo + refine ⟨bFixed, ωFixed, hFixed, hforward, hinverse, ?_⟩ + intro m G X _ _ I Deck J _ _ n B _ U btag hbtag o R σ S hR hσ poly hm hpoly + c a N hN τ ξ hτ hτ1 hξ v hv sample read hread hσ1 Cgeo hCgeo hchart hsmall + periodCap coverCap L twist p hp hperiod hvariationBound keep _ fixed hfixed + dsimp only + intro q Q hq hlen hQ hP V W hV hW hWnorm η θ hηheight hθheight hη hθ hK hbias + have hsmallOne : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * R j) ≤ 1 := + fun j => (hsmall j).trans (by norm_num) + apply hlocal Q hq hlen hp hQ hP (mul_pos twist.modulus_pos twist.cover_pos) + hperiod (fun t => twist.eval N poly (integerSampledSpatial + (allocatedFrozenIntegerFullChart B U btag o poly hm c a v sample keep fixed) t.val)) + (fun _ => twist.norm_eval_le N poly _) + (by positivity) hvariationBound ?_ + V W hV hW hWnorm η θ hηheight hθheight hη hθ hK hbias + intro x y hres δ hδ hcell + exact hread.frozen_twist_variation B U btag hbtag o S hR hσ poly hm hpoly + c a N hN hτ hτ1 hξ v hv sample read hσ1 Cgeo hCgeo hchart hsmallOne + twist keep fixed hfixed x y hres hδ hcell + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGenuineKernelBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGenuineKernelBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b7742fd20640866d922c719407e7dcafa3bf2ae --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGenuineKernelBudget.lean @@ -0,0 +1,44 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedFiniteIdealMaskBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +def allocatedGenuineKernelErrorLog {A : Type*} [Semiring A] (m : ℕ) (D P : A) : A := + D * ((m * 2 ^ (m + 1) : ℕ) * P) + D ^ 3 * ((m + 1 : ℕ) * P) + +theorem allocatedGenuineKernelErrorLog_nonneg (m : ℕ) {D P : ℝ} (hD : 0 ≤ D) (hP : 0 ≤ P) : + 0 ≤ allocatedGenuineKernelErrorLog m D P := by + unfold allocatedGenuineKernelErrorLog + positivity + +theorem allocatedGenuineKernelError_exp_bound {m : ℕ} + (I : Fin m → Type*) [∀ j, Fintype (I j)] (n : Fin m → ℕ) + (O K : Fin m → Type*) [∀ j, Fintype (O j)] [∀ j, Fintype (K j)] + {M period : ℕ} {D P : ℝ} (hD : 0 ≤ D) (hP : 0 ≤ P) + (hM : (M : ℝ) ≤ Real.exp P) (hperiod : period ≤ M ^ (m + 1)) + (hm : (m : ℝ) ≤ D) (haxes : (Fintype.card (LayerSamplerAxis I n) : ℝ) ≤ D) + (hO : ∀ j, (Fintype.card (O j) : ℝ) ≤ D) + (hK : ∀ j, (Fintype.card (K j) : ℝ) ≤ D) : + (layerKernelIndexBound m M : ℝ) ^ Fintype.card (LayerSamplerAxis I n) * + coefficientDeckPeriodCap O K period ≤ Real.exp (allocatedGenuineKernelErrorLog m D P) := by + have hindex := pow_le_exp_mul_of_le_exp (Nat.cast_nonneg (layerKernelIndexBound m M)) + (layerKernelIndexBound_le_exp m hM) (by positivity) _ haxes + have hperiodExp : (period : ℝ) ≤ Real.exp ((m + 1 : ℕ) * P) := by + calc + _ ≤ (M : ℝ) ^ (m + 1) := by exact_mod_cast hperiod + _ ≤ (Real.exp P) ^ (m + 1) := pow_le_pow_left₀ (Nat.cast_nonneg _) hM _ + _ = _ := (Real.exp_nat_mul _ _).symm + have hdeck := coefficientDeckPeriodCap_exp_bound O K period hD (by positivity) hm hO hK hperiodExp + exact (mul_le_mul hindex hdeck (coefficientDeckPeriodCap_nonneg O K period) + (Real.exp_pos _).le).trans_eq (Real.exp_add _ _).symm + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelCoveredComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelCoveredComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ad3925db2dc778f56da15b4e30172df04dd65ba --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelCoveredComparison.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedProfileDimensions +import OAI.Combinatorics.Progressions.Lattices.AllocatedCoveredResidueComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val + 1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) +variable (Q : Fin m → Type*) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides +local notation "source" => allocatedCoefficientSource B U b hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U b hR hσ S +local notation "reference" => allocatedLongJetReference B U b S O +local notation "scale" => (∏ a, allocatedLongJetOutputScale B U b S (O := O) a) +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +theorem allocatedGoodKernel_covered_comparison {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) + (hq : Fintype.card α ≤ m + 1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j t, (rows j t).card ≤ j.val + 1) (hσ1 : ∀ j, σ j ≤ 1) + {P E η : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hη : 0 < η) (hη1 : η ≤ 1) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + + 1 ≤ Real.exp P) + (hηE : η⁻¹ ≤ Real.exp E) + (hlarge : Real.exp (allocatedJointLengthLog (G := G) B α O P E) ≤ S.value) : + ∃ (period : ℕ) (hp : 0 < period), period ≤ M ^ (m + 1) ∧ + (∀ c : G → ℤ, integerScalarLattice (Unit ⊕ α) (period : ℤ) ≤ + pivotFullImage (selectedSpatialPivot c (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns c (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) ∧ + ∃ hsize : ∀ t, (Fintype.card α + 1) * period ≤ lengths t, + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (r : PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod period), + ∃ residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod period), + (∀ v, (allocatedLongResidueWeights B U b S period hp r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) period = residue j) ∧ + ∃ v₀ : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides, + principalResidueLabel period v₀ = r ∧ + ∀ F : AllocatedFrozenCoefficients B U b S × EuclideanJetLayers U O → ℂ, + Measurable F → (∀ p, ‖F p‖ ≤ 1) → + ‖(∫ p, (allocatedLongResidueWeights B U b S period hp r hsize).complexMean (fun v => + F (((allocatedCoefficientSplit B U b S) p.1).1, + euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u v)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u v)) rows + (canonicalCoefficientDeckSample U bW b hb o d (Nat.pos_of_ne_zero (NeZero.ne d)) p.1 p.2))) + ∂(source).prod (deck).toMeasure) - + ∫ a₀, ∫ z, + ((allocatedLongJetProxy B U b S x u rows s hA period residue z / scale : ℝ) : ℂ) * + allocatedCoveredFixedTest B U b S x u v₀ rows Q hb o bW d F a₀ z ∂reference ∂frozenSource‖ ≤ + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O P) + 1) ^ + Fintype.card (Σ a : LayerSamplerAxis I n, O (Sigma.fst a)) * η := by + obtain ⟨period, hp, hpM, hspatial, hperiod, s, hA, hi, hsize, hcompare⟩ := + allocatedGoodKernel_prescribed_comparison B U b hR hσ S x rows hM selection hx hq hinj hrows hσ1 + hP hE hη hη1 hMP hRP hRi hσi hcount hηE hlarge + refine ⟨period, hp, hpM, hspatial, hperiod, s, hA, hi, hsize, ?_⟩ + intro u r + obtain ⟨residue, hmatrix, he⟩ := hcompare u r + obtain ⟨v₀, hv₀, htest⟩ := exists_allocatedPhysicalCovered_residue_comparison B U b hR hσ S x u + rows Q hb o bW d s hA hσ1 period hp hperiod r hsize residue + hM hi hP hMP hRP hRi hσi hcount hη.le he + exact ⟨residue, hmatrix, v₀, hv₀, htest⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelHaarComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelHaarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..403db7ac0baa8d6cc216a7567f4d93e612e0738e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelHaarComparison.lean @@ -0,0 +1,290 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedCoveredHaarTransfer +import OAI.Combinatorics.Progressions.Estimates.AllocatedPrescribedCoveredComparison +import OAI.Combinatorics.Progressions.Estimates.CoveredJetSampleMeasurable +import OAI.Combinatorics.Progressions.Probability.AllocatedMassTupleComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val + 1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) +variable (Q : Fin m → Type*) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides +local notation "source" => allocatedCoefficientSource B U b hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U b hR hσ S +local notation "reference" => allocatedLongJetReference B U b S O +local notation "scale" => (∏ a, allocatedLongJetOutputScale B U b S (O := O) a) +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +local notation "FrozenTuples" => PrincipalAxisTuples (α := α) grid sides +local notation "LongTuples" => PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides +local notation "Labels" => (fun modulus : ℕ => + (PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) + (fun a => layerSamplerDegree I n (Subtype.val a)) → Option α → ZMod modulus)) +local notation "whole" => principalTupleWeights B (layerSamplerDegree I n) sides + (allocatedPrincipalSides_pos B U b S) +local notation "frozen" => allocatedFrozenTupleWeights (α := α) B U b S +local notation "long" => allocatedLongTupleWeights (α := α) B U b S + +theorem allocatedGoodKernel_covered_tuple_comparison {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) + (hq : Fintype.card α ≤ m + 1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j t, (rows j t).card ≤ j.val + 1) (hσ1 : ∀ j, σ j ≤ 1) + {P E η : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hη : 0 < η) (hη1 : η ≤ 1) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + + 1 ≤ Real.exp P) + (hηE : η⁻¹ ≤ Real.exp E) + (hlarge : Real.exp (allocatedJointLengthLog (G := G) B α O P + (allocatedJetTestLog (G := G) B α O P E)) ≤ S.value) : + ∃ (period : ℕ) (hp : 0 < period), period ≤ M ^ (m + 1) ∧ + (∀ c : G → ℤ, integerScalarLattice (Unit ⊕ α) (period : ℤ) ≤ + pivotFullImage (selectedSpatialPivot c (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns c (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) ∧ + ∃ hsize : ∀ t, (Fintype.card α + 1) * period ≤ lengths t, + letI : NeZero period := ⟨hp.ne'⟩ + ∃ (residue : FrozenTuples → Labels period → + ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod period)) + (v₀ : FrozenTuples → Labels period → LongTuples), + (∀ u r v, (allocatedLongResidueWeights B U b S period hp r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) period = residue u r j) ∧ + (∀ u r, principalResidueLabel period (v₀ u r) = r) ∧ + ∀ F : FrozenTuples → Labels period → + AllocatedFrozenCoefficients B U b S × EuclideanJetLayers U O → ℂ, + (∀ u r, Measurable (F u r)) → (∀ u r p, ‖F u r p‖ ≤ 1) → + ‖(∫ p, (whole).complexMean (fun y => + F (principalAxisRestrict grid y) + (principalResidueLabel period (principalAxisRestrict (fun a => ¬grid a) y)) + (((allocatedCoefficientSplit B U b S) p.1).1, + euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) rows + (canonicalCoefficientDeckSample U bW b hb o d (Nat.pos_of_ne_zero (NeZero.ne d)) p.1 p.2))) + ∂(source).prod (deck).toMeasure) - + (frozen).complexMean (fun u => ((long).fiberLaw (principalResidueLabel period)).complexMean + (fun r => ∫ a₀, ∫ z, + ((allocatedLongJetProxy B U b S x u rows s hA period (residue u r) z / scale : ℝ) : ℂ) * + allocatedCoveredFixedTest B U b S x u (v₀ u r) rows Q hb o bW d (F u r) a₀ z + ∂reference ∂frozenSource))‖ ≤ η := by + obtain ⟨period, hp, hpM, hspatial, hperiod, s, hA, hi, hsize, hcompare⟩ := + allocatedGoodKernel_prescribed_covered_comparison B U b hR hσ S x rows Q hb o bW d + hM selection hx hq hinj hrows hσ1 hP hE hη hη1 hMP hRP hRi hσi hcount hηE hlarge + let : NeZero period := ⟨hp.ne'⟩ + choose residue hmatrix v₀ hv₀ htest using hcompare + refine ⟨period, hp, hpM, hspatial, hperiod, s, hA, hi, hsize, + residue, v₀, hmatrix, hv₀, ?_⟩ + intro F hF hbound + let : IsProbabilityMeasure source := allocatedCoefficientSource_probability B U b hR hσ S + let f := fun (p : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n × + CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) => + F (principalAxisRestrict grid y) + (principalResidueLabel period (principalAxisRestrict (fun a => ¬grid a) y)) + (((allocatedCoefficientSplit B U b S) p.1).1, + euclideanCoefficientJetMap U (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) rows + (canonicalCoefficientDeckSample U bW b hb o d (Nat.pos_of_ne_zero (NeZero.ne d)) p.1 p.2)) + have hf (y) : Integrable (fun p => f p y) ((source).prod (deck).toMeasure) := by + apply Integrable.of_bound (C := 1) + · exact ((hF _ _).comp + ((((allocatedCoefficientSplit B U b S).measurable.comp measurable_fst).fst).prodMk + (canonicalCoefficientDeckSample_jet_measurable U o + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) rows b hb bW d))).aestronglyMeasurable + · exact ae_of_all _ (fun p => hbound _ _ _) + apply allocatedTuple_integral_comparison B U b S period hp hsize + ((source).prod (deck).toMeasure) f hf + intro u r + have he := htest u r (F u r) (hF u r) (hbound u r) + convert he using 2 + congr 1 + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro p + apply (allocatedLongResidueWeights B U b S period hp r hsize).complexMean_congr_support + intro v hv + dsimp only [f] + rw [principalAxisRestrict_join_left, principalAxisRestrict_join_right, + allocatedLongResidueWeights_support_label B U b S period hp r hsize v hv] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val + 1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) +variable (Q : Fin m → Type*) [∀ j, Fintype (Q j)] +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (Q j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides +local notation "source" => allocatedCoefficientSource B U b hR hσ S +local notation "frozenSource" => allocatedFrozenCoefficientSource B U b hR hσ S +local notation "reference" => allocatedLongJetReference B U b S O +local notation "scale" => (∏ a, allocatedLongJetOutputScale B U b S (O := O) a) +local notation "deck" => PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d) + +local notation "FrozenTuples" => PrincipalAxisTuples (α := α) grid sides +local notation "LongTuples" => PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides +local notation "Labels" => (fun modulus : ℕ => + (PrincipalTupleIndex (fun a : {a // ¬grid a} => B (Subtype.val a)) + (fun a => layerSamplerDegree I n (Subtype.val a)) → Option α → ZMod modulus)) +local notation "whole" => principalTupleWeights B (layerSamplerDegree I n) sides + (allocatedPrincipalSides_pos B U b S) +local notation "frozen" => allocatedFrozenTupleWeights (α := α) B U b S +local notation "long" => allocatedLongTupleWeights (α := α) B U b S + +local notation "density" => (fun a => allocatedCoefficientDensity B U b hb o hR hσ S + (quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d a)) +local notation "jetHaar" => Measure.pi (fun j => Measure.pi (fun _ : O j => ν j)) +local notation "physicalJet" => (fun y => euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U b S x y) rows) +local notation "sample" => (fun p : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n × + CoefficientDeckResidues (K := LayerSamplerVariables G I n B) Q d => + canonicalCoefficientDeckSample U bW b hb o d (Nat.pos_of_ne_zero (NeZero.ne d)) (Prod.fst p) (Prod.snd p)) + +theorem allocatedGoodKernel_haar_comparison {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) + (hq : Fintype.card α ≤ m + 1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j t, (rows j t).card ≤ j.val + 1) (hσ1 : ∀ j, σ j ≤ 1) + {P E η : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hη : 0 < η) (hη1 : η ≤ 1) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + + 1 ≤ Real.exp P) + (hηE : η⁻¹ ≤ Real.exp E) + (hlarge : Real.exp (allocatedJointLengthLog (G := G) B α O P + (allocatedJetTestLog (G := G) B α O P E)) ≤ S.value) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (hsmall : ∀ j, C j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) : + ∃ (period : ℕ) (hp : 0 < period), period ≤ M ^ (m + 1) ∧ + (∀ c : G → ℤ, integerScalarLattice (Unit ⊕ α) (period : ℤ) ≤ + pivotFullImage (selectedSpatialPivot c (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns c (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) ∧ + ∃ hsize : ∀ t, (Fintype.card α + 1) * period ≤ lengths t, + letI : NeZero period := ⟨hp.ne'⟩ + ∃ (residue : FrozenTuples → Labels period → + ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod period)) + (v₀ : FrozenTuples → Labels period → LongTuples), + (∀ u r v, (allocatedLongResidueWeights B U b S period hp r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) period = residue u r j) ∧ + (∀ u r, principalResidueLabel period (v₀ u r) = r) ∧ + ∀ F : FrozenTuples → Labels period → EuclideanJetLayers U O → ℂ, + (∀ u r, Measurable (F u r)) → (∀ u r z, ‖F u r z‖ ≤ 1) → + let test := fun (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) + (z : EuclideanJetLayers U O) => F (principalAxisRestrict grid y) + (principalResidueLabel period (principalAxisRestrict (fun a => ¬grid a) y)) z + let target := (frozen).complexMean (fun u => + ((long).fiberLaw (principalResidueLabel period)).complexMean + (fun r => ∫ a₀, ∫ z, + ((allocatedLongJetProxy B U b S x u rows s hA period (residue u r) z / scale : ℝ) : ℂ) * + allocatedCoveredFixedTest B U b S x u (v₀ u r) rows Q hb o bW d + (fun p => F u r p.2) a₀ z ∂reference ∂frozenSource)) + (‖(∫ a, (density a : ℂ) * (whole).complexMean (fun y => test y (physicalJet y a)) ∂μ) - + target‖ ≤ η) ∧ + ∀ g : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides → EuclideanJetLayers U O → ℝ, + (∀ y, Measurable (g y)) → (∀ y z, 0 ≤ g y z) → + (∀ y, (realDensityMeasure μ density).map (physicalJet y) = realDensityMeasure jetHaar (g y)) → + ‖(whole).complexMean (fun y => ∫ z, (g y z : ℂ) * test y z ∂jetHaar) - target‖ ≤ η := by + obtain ⟨period, hp, hpM, hspatial, hperiod, s, hA, hi, hsize, residue, v₀, hmatrix, hv₀, hcompare⟩ := + allocatedGoodKernel_covered_tuple_comparison B U b hR hσ S x rows Q hb o bW d + hM selection hx hq hinj hrows hσ1 hP hE hη hη1 hMP hRP hRi hσi hcount hηE hlarge + let : NeZero period := ⟨hp.ne'⟩ + refine ⟨period, hp, hpM, hspatial, hperiod, s, hA, hi, hsize, + residue, v₀, hmatrix, hv₀, ?_⟩ + intro F hF hbound test target + have hsource : ‖(∫ p, (whole).complexMean (fun y => test y (physicalJet y (sample p))) + ∂(source).prod (deck).toMeasure) - target‖ ≤ η := + hcompare (fun u r p => F u r p.2) (fun u r => (hF u r).comp measurable_snd) + (fun u r p => hbound u r p.2) + have htest (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) : + Measurable (test y) := hF _ _ + have hjet (y : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides) : + Measurable (physicalJet y) := + (euclideanCoefficientJetMap_continuous (K := LayerSamplerVariables G I n B) U _ _ rows).measurable + constructor + · have he := allocatedCoveredHaar_finite_mean B U b hb o hR hσ S Q bW d μ ν + hσ1 C hC hchart hsmall whole (fun y a => test y (physicalJet y a)) + (fun y => (htest y).comp (hjet y)) + rwa [he] at hsource + · intro g hg hg0 hlaw + have he := allocatedCoveredDensity_finite_mean B U b hb o hR hσ S Q bW d μ ν + hσ1 C hC hchart hsmall whole (fun y a => physicalJet y a) hjet jetHaar + g hg hg0 hlaw test htest (fun y z => hbound _ _ z) + rwa [he] at hsource + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..24f820cf30fd082f3c7c2c44d504b1fac3ec0f1e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealComparison.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedIdealComparisonAssembly + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +universe uCover uGeom + +open MeasureTheory +open scoped ContDiff NNReal Classical BigOperators + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {α : Type*} [Fintype α] [DecidableEq α] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] [∀ j, Nonempty (O j)] + +local notation "hLayer" => layerSamplerDegree I n + +theorem exists_allocated_goodKernel_ideal_comparison + (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hrange : ∀ t, ψ t ∈ Set.Icc (0 : ℝ) 1) + (hzero : ∀ t, |t| ≤ 1 → ψ t = 0) (hone : ∀ t, 2 ≤ |t| → ψ t = 1) + (A T : ℝ≥0) (hLip : LipschitzWith A ψ) (hTransition : LipschitzWith T Real.smoothTransition) + {D E p₀ : ℝ} (hdim : AllocatedComparisonDimensions (G := G) B α O D) + (hE : 0 ≤ E) (hp₀ : 0 ≤ p₀) : + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * p₀ + let ε : ℝ := physicalIdealErrorShare E (D * w) + let e : ℝ := physicalIdealSmoothingLog (B := B) (O := fun a : LayerSamplerAxis I n => O a.1) + (α := α) hLayer A T E (D * w) + ∃ δ : ℝ≥0, 0 < δ ∧ δ ≤ 1 ∧ + (δ : ℝ) = booleanRegularizationRadius (B := B) + (O := fun a : LayerSamplerAxis I n => O a.1) (α := α) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T (ε / 2) ∧ + let t : ℝ := booleanMassPerturbationScale (B := B) + (O := fun a : LayerSamplerAxis I n => O a.1) (α := α) + ((G × Option α) ⊕ (Σ a, SamplerCoefficientSlot G B hLayer a)) hLayer + (unitProfilePrincipalSize (B := B)) (fun a => 2 * unitProfilePrincipalSize (B := B) a) + A T m 1 (ε / 2) + 0 < t ∧ t ≤ 1 ∧ + AllocatedGoodKernelIdealAt.{uCover, _, _, _, _, _, uGeom} + (G := G) (α := α) (O := O) B D E p₀ e δ t := by + dsimp only + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * p₀ + have hw : 0 ≤ w := mul_nonneg (Nat.cast_nonneg _) hp₀ + have hDw : 0 ≤ D * w := mul_nonneg hdim.nonneg hw + let e := physicalIdealSmoothingLog (B := B) (O := fun a : LayerSamplerAxis I n => O a.1) + (α := α) hLayer A T E (D * w) + have he : 0 ≤ e := physicalIdealSmoothingLog_nonneg hLayer A T hE hDw + obtain ⟨δ, hδ, hδ1, hδeq, ht, ht1, hcompare⟩ := + exists_allocated_physical_ideal_comparison.{_, _, _, _, _, uGeom, uCover} + (G := G) (α := α) (O := O) B ψ hψ hrange hzero hone A T hLip hTransition + (physicalIdealErrorShare_pos E (D * w)) + have hδe : (δ : ℝ)⁻¹ ≤ Real.exp e := by + rw [hδeq] + exact physicalIdeal_smoothing_inverse_le_exp hLayer (fun _ => Nat.succ_pos _) + A T hE hDw + refine ⟨δ, hδ, hδ1, hδeq, ht, ht1, ?_⟩ + exact allocated_goodKernel_ideal_of_comparison B hdim hE hp₀ he hδe ht1 hcompare + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealCoverError.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealCoverError.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb89ed01d0b1e28a56c89e2789f2156a18a569d6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealCoverError.lean @@ -0,0 +1,163 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedScaledIdealCover + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m dim : ℕ} {G : Type uG} [Fintype G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => (rowSets j : Type)) +local notation "rows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +variable (M₀ : ℕ) +local notation "period" => kernelPeriodCandidate (m + 1) +local notation "P" => canonicalScalarSourceEnvelope m M₀ +local notation "L" => scalarSourceTransitionBound + +variable {p₀ p₁ w e E : ℝ} +local notation "δ" => allocatedSitePrimitiveTolerance m p₁ w (allocatedIdealProfileLog m p₁ e) E +local notation "Λ" => allocatedSiteSpectrumLog m p₁ w (allocatedIdealProfileLog m p₁ e) E +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "active" => allocatedActiveGrid B U b S +local notation "activeAxes" => {a : {a // grid a} // active a} +local notation "ig" => allocatedGridIntegerAxis B U b S +local notation "axisN" => allocatedGridNaturalScale B U b S + +variable (hsize : (Fintype.card (Fin dim) + 1) * M₀ ^ (m + 1) ≤ S.value) +variable (M : {a : {a // allocatedGridAxis (I := I) U b S.value a} // allocatedActiveGrid B U b S a} → ℕ) +variable [∀ a, NeZero (M a)] + +local notation "pointTolerance" => allocatedSitePointTolerance (G := G) B rowSets δ +local notation "torus" => (fun a : activeAxes => allocatedGridTorusFactor B (Fin dim) (ig (Subtype.val a))) +local notation "siteLip" => (NNReal.mk (Real.exp (1 + 6 * Λ + 12)) (Real.exp_nonneg _) + 4 : ℝ≥0) +local notation "coefficientCap" => (fun a : activeAxes => + allocatedGridPointCap B P (ig (Subtype.val a)) (rowSets (Sigma.fst (ig (Subtype.val a)))) * + Real.exp (Fintype.card (Finset (Fin dim)) * (4 * Λ + 8) + Λ)) + +include hsize in +theorem exists_allocated_good_kernel_ideal_cover_family + (hw : 0 ≤ w) (he : 0 ≤ e) (hE : 0 ≤ E) + (hdimSmall : dim ≤ m + 1) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p₁) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p₁) (hn₁ : ∀ j, (n j : ℝ) ≤ p₁) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ p₁) + (hp₀ : 0 ≤ p₀) (hcutoff : (M₀ : ℝ) ≤ Real.exp p₀) + (hSourceLog : canonicalScalarSourceLog m p₀ ≤ p₁) + (hmaskBudget : (m * 2 ^ (m + 1) : ℕ) * p₁ ≤ w) + (hS₁ : (S.value : ℝ) ≤ Real.exp p₁) + (hEbudget : E + 4 ≤ p₁) + (hgamma : ∀ a : activeAxes, principalProfileSize (R (ig a.val).1) + (Finset.card (layerIntegerPrincipalSlots (G := G) B (ig a.val).1 (ig a.val).2)) ≤ S.value) + (hM : ∀ a, M a = (torus) a * axisN a.val) + (hB : ∀ a : activeAxes, positiveModerateSpectrumBlockCount (ig a.val).1.val + (rowSets (ig a.val).1).card ((layerTailDegree m + 2) * (rowSets (ig a.val).1).card) ≤ + Fintype.card (B ⟨(ig a.val).1, Sum.inr (ig a.val).2⟩)) : + ∃ K : ℕ, 2 ≤ K ∧ + ∃ witnesses : (t : Fin M₀) → (r : AllocatedPositiveResidue (dim := dim) B U b S (period t)) → + AllocatedResidueSiteWitness (dim := dim) B U b S (period t) r.val, + (∀ t r, allocatedActiveSiteBounds B U b S rowSets P pointTolerance Λ M (witnesses t r).expansion) ∧ ∀ + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Q : Fin m → Type uQ} [∀ j, Fintype (Q j)] + (bW : ∀ j, Basis (Q j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCexp : ∀ j, (C j : ℝ) ≤ Real.exp p₁) (_hVexp : ∀ j, (V j : ℝ) ≤ Real.exp p₁) + (_hRi : ∀ j, (R j)⁻¹ ≤ Real.exp p₁) (_hσ1 : ∀ j, σ j ≤ 1) + (Qsite : ℝ≥0) (_hQsite : ∀ a : activeAxes, 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (ig a.val).1 (ig a.val).2) : ℝ) + 1) ≤ Qsite) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedIdealCoverRadius (G := G) B rowSets Cinv j), + ∃ g : (t : Fin M₀) → (r : AllocatedPositiveResidue (dim := dim) B U b S (period t)) → + (∀ a, ((witnesses t r).expansion a).Term) → Finset (Fin dim) → (((Σ j, J j) → UnitAddCircle) → ℂ), + (∀ t r k s, LipschitzWith (max (((Fintype.card activeAxes * siteLip) * Qsite) * + (Real.toNNReal (Real.exp p₁) * ∑ j, C j * Fintype.card (J j)) * commonSitePeriod (witnesses t r).expansion k) + (4 * commonSitePeriod (witnesses t r).expansion k)) (g t r k s) ∧ ∀ z, ‖g t r k s z‖ ≤ 1) ∧ + (∀ t r, (∑ k, ‖coverSiteCoefficient (witnesses t r).expansion k‖) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, (coefficientCap) a) ∧ + (∀ t, allocatedResidueCoverCoefficientMass B U b S (period t) (witnesses t) ≤ + (2 : ℝ) ^ Fintype.card (Finset (Fin dim)) * ∏ a, (coefficientCap) a) ∧ + ∀ (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (selection : Fin dim ↪ G) {κ : ℝ} + (_hx : GoodScalarKernelTuple selection κ M₀ x), + ∃ t : Fin M₀, + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ Fin dim) (period t : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (rowTypes j) (period t : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) ∧ + ∀ (τ : ℝ≥0), 0 < τ → τ ≤ 1 → (τ : ℝ)⁻¹ ≤ Real.exp e → ∀ + {X : Type uX} [Fintype X] [DecidableEq X] + {P₀ : ℝ} (_hP : 0 ≤ P₀) (_hn : (Fintype.card X : ℝ) ≤ P₀) + (_hdim : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P₀) + (_hbudget : allocatedSiteErrorFourierOutput m p₁ w (allocatedIdealProfileLog m p₁ e) ≤ P₀) + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hmp : ∀ j e, coefficients (p j) e ∈ U j) + (stride : X → ℕ) (_hs : ∀ x, 0 < stride x) + {R₁ S₀ ρ : ℝ} (_hS : 0 ≤ S₀) (_hSP : S₀ ≤ Real.exp P₀) (_hρ : 0 < ρ) + (_hρP : 1 / ρ ≤ Real.exp P₀) + (_hstride : ∀ x, (stride x : ℝ) ≤ S₀) + (H : X → ℝ) (_hsize : ∀ x, Real.exp ((P₀ + K) ^ K) ≤ H x) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R₁ (U j) (p j)) + (_hR : Real.exp ((P₀ + K) ^ K) ≤ R₁) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) (_hcells : cells.Nonempty) + (W : Option (Fin dim) × X → ℝ) (hW : ∀ z, 0 < W z) (_hwidth : ∀ z, ρ * H z.2 ≤ W z), + let f := allocatedPhysicalLongIdeal B U b hR S rowSets τ + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let error := fun z : Option (Fin dim) × X → ℤ => + law.complexMean (fun y₀ => + (allocatedWholeMaskedCoveredProfile (O := rowTypes) B U b hR hσ S x (rows) hb o bW d y₀ (period t) f + (physicalCubeRowSample U d (rows) p hmp (standardPhysicalCubeOutput z)) : ℂ)) - + (law.fiberLaw (principalResidueLabel (period t))).complexMean + (allocatedSupportedIdealCoverValue B U b hR hσ S (period t) (witnesses t) hb o bW d (g t) τ x p hmp + (standardPhysicalCubeOutput z)) + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells W z, + selectedResidueDensityMass stride cells W (fun z => ‖error z‖) ≤ Real.exp (-E) ∧ + ∀ φ : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖φ z‖ ≤ 1) → + ‖∑' z, ((selectedResidueSmoothPMF stride cells W hW hZ z).toReal : ℂ) * + (error z * φ z)‖ ≤ Real.exp (-E) := by + exact exists_cutoff_mask_good_kernel_ideal_cover_family + (B := B) (U := U) (b := b) (hR := hR) (hσ := hσ) (S := S) (M₀ := M₀) + (hsize := hsize) (M := M) (p₀ := p₀) (p₁ := p₁) (w := w) (e := e) (E := E) + hw he hE hdimSmall hvars hI hn₁ hJ hp₀ hcutoff hSourceLog + ((mul_le_mul_of_nonneg_left + ((canonicalScalarSourceLog_bounds m hp₀).2.trans hSourceLog) + (Nat.cast_nonneg (m * 2 ^ (m + 1)))).trans hmaskBudget) + hS₁ hEbudget hgamma hM hB + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealFamily.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..d34009c983a1a8676fe1c018cfcea2402992e747 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelIdealFamily.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRecenteredIdealError + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule +open scoped BigOperators Classical NNReal + +def allocatedFiniteIdealInputLog {A : Type*} [Semiring A] (m : ℕ) (D eδ eε : A) : A := + (8 * allocatedIdealCoverInputLog m D 0 + 14) + 2 * D + 2 + eδ + eε + +theorem allocatedFiniteIdealInputLog_bounds (m : ℕ) {D eδ eε : ℝ} + (hD : 0 ≤ D) (hδ : 0 ≤ eδ) (hε : 0 ≤ eε) : + let p := allocatedFiniteIdealInputLog m D eδ eε + 0 ≤ p ∧ (8 * allocatedIdealCoverInputLog m D 0 + 14) + 2 * D + 2 ≤ p ∧ + eδ ≤ p ∧ eε ≤ p := by + have hbase := (allocatedProductChartLog_bounds m hD (le_refl (0 : ℝ))).2.1 + dsimp only [allocatedFiniteIdealInputLog] + exact ⟨by linarith, by linarith, by linarith, by linarith⟩ + +variable {m dim : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (hR : ∀ j, 0 < R j) +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable {M : ℕ} (hM : 0 < M) (selection : Fin dim ↪ G) +variable (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {Kcov : Fin m → Type*} [∀ j, Fintype (Kcov j)] +variable (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (d : ℕ) [NeZero d] + +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "rowTypes" => (fun j : Fin m => {s : Finset (Fin dim) // s ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset (Fin dim))) +local notation "tuples" => PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S) + +variable {Dgeom cgeom : ℝ} +variable (hgeom : AllocatedComparisonDimensions (G := G) B (Fin dim) + (fun j : Fin m => (boundedBooleanJetRows (Fin dim) (Fin.val j + 1) : Type)) Dgeom) +variable (hcgeom : 0 ≤ cgeom) +variable (hIgeom : ∀ j, (Fintype.card (I j) : ℝ) ≤ Dgeom) (hngeom : ∀ j, (n j : ℝ) ≤ Dgeom) +variable (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hCgeom : ∀ j, C j ≤ Real.exp cgeom) +variable (hsmall : ∀ j, R j ≤ allocatedProductChartRadius m Dgeom cgeom) + +include hR hM hx hgeom hcgeom hIgeom hngeom hC hchart hCgeom hsmall in +theorem exists_good_kernel_finite_ideal_family (hdim : dim ≤ m + 1) + (δ : ℝ≥0) (hδ : 0 < δ) (hδ1 : δ ≤ 1) {ε eδ eε : ℝ} + (hε : 0 < ε) (heδ : 0 ≤ eδ) (heε : 0 ≤ eε) + (hδexp : (δ : ℝ)⁻¹ ≤ Real.exp eδ) (hεexp : ε⁻¹ ≤ Real.exp eε) : + ∃ t : Fin M, + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ Fin dim) (kernelPeriodCandidate (m + 1) t : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (rowTypes j) (kernelPeriodCandidate (m + 1) t : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) ∧ + ∀ q : ℕ, ∃ F : tuples → AllocatedFiniteIdealData (Fin dim) I n, + ∀ y₀, (F y₀).Bounds B U b S rowSets x y₀ q d (kernelPeriodCandidate (m + 1) t) + hb o bW hR δ ε (allocatedFiniteIdealInputLog m Dgeom eδ eε) (layerKernelIndexBound m M) := by + have hrows : ∀ j (s : rowTypes j), s.val.card ≤ j.val + 1 := + fun j s => (mem_boundedBooleanJetRows (j.val + 1) s.val).mp s.property + obtain ⟨t, hspatial, hperiod⟩ := goodKernel_periodFamily selection x hx (m + 1) (by omega) + (fun j : Fin m => j.val + 1) (fun j => by omega) rows (fun _ => Subtype.val_injective) hrows + refine ⟨t, hspatial, hperiod, ?_⟩ + intro q + obtain ⟨hp, hboxP, hδP, hεP⟩ := allocatedFiniteIdealInputLog_bounds m hgeom.nonneg heδ heε + have hbox := allocatedProductIdealSiteRadius_exp_bound B rowSets hgeom (le_refl (0 : ℝ)) + hIgeom hngeom (fun _ => 0) (fun _ => le_rfl) (fun _ => (Real.exp_pos 0).le) + have hbudget := allocatedProductChartRadius_recovery_budget B rowSets hgeom hcgeom + hIgeom hngeom C hC hCgeom (fun j => (hR j).le) hsmall + have hmaskOne : (1 : ℝ) ≤ layerKernelIndexBound m M := by + exact_mod_cast Nat.succ_le_of_lt (show 0 < layerKernelIndexBound m M from pow_pos hM _) + have hlocal (y₀ : tuples) : ∃ F : AllocatedFiniteIdealData (Fin dim) I n, + F.Bounds B U b S rowSets x y₀ q d (kernelPeriodCandidate (m + 1) t) + hb o bW hR δ ε (allocatedFiniteIdealInputLog m Dgeom eδ eε) (layerKernelIndexBound m M) := by + apply exists_allocated_finite_ideal_data B U b S rowSets x y₀ q d + (kernelPeriodCandidate (m + 1) t) hb o bW hR hperiod hmaskOne + (fun j z => allocatedIntegerKernelMask_bound B U b S x rows hM selection hx + (by simpa only [Fintype.card_fin] using hdim) (fun _ => Subtype.val_injective) hrows j q _ z) + C hC hchart hbudget δ hδ hδ1 hε hp + (hbox.trans (Real.exp_le_exp.mpr hboxP)) + (hεexp.trans (Real.exp_le_exp.mpr hεP)) (hδexp.trans (Real.exp_le_exp.mpr hδP)) + choose F hF using hlocal + exact ⟨F, hF⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelSpatialDensity.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelSpatialDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..46d7b9502a8189dc6923295be4c091d4f2671d5f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelSpatialDensity.lean @@ -0,0 +1,146 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedPrescribedSpatialData +import OAI.Combinatorics.Progressions.Probability.AllocatedSpatialLawDensity + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides + +theorem allocatedGoodKernel_prescribed_spatial_density {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P E η : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hη : 0 < η) (hη1 : η ≤ 1) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hηE : η⁻¹ ≤ Real.exp E) + (hlarge : Real.exp (allocatedJointLengthLog (G := G) B α O P E) ≤ S.value) : + ∃ (modulus : ℕ) (hm : 0 < modulus), + let : NeZero modulus := ⟨hm.ne'⟩ + modulus ≤ M^(m+1) ∧ + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ α) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) ∧ + ∃ hsize : ∀ d, (Fintype.card α+1)*modulus ≤ lengths d, + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (r : PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod modulus), + ∃ (reference : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + principalResidueLabel modulus reference = r ∧ + (∀ v, (allocatedLongResidueWeights B U b S modulus hm r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) modulus = residue j) ∧ + ∀ [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C : Fin m → ℝ) (_hC : ∀ j, 0 ≤ C j) + (_hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B α C 1 j) + {K : Fin m → Type*} [∀ j, Fintype (K j)] + (bW : ∀ j, Module.Basis (K j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (g : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides → EuclideanJetLayers U O → ℝ) + (_hg : ∀ w, Continuous (g w)) (_hg0 : ∀ w z, 0 ≤ g w z) + (_hlaw : ∀ w, (realDensityMeasure μ (fun z => allocatedCoefficientDensity B U b hb o hR hσ S + (quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d z))).map + (euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u w)) + (allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u w)) rows) = + realDensityMeasure (Measure.pi (fun j => Measure.pi (fun _ : O j => ν j))) (g w)) + {D N : Type*} [Fintype D] [Fintype N] [DecidableEq N] + (c : D → N → ℤ) (index : D → N → PrincipalTupleIndex B (layerSamplerDegree I n)) + (spatialRoot : G → ℤ) (_hroot : ∀ j, |spatialRoot j| ≤ (S.value : ℤ)) + (H : D → ℝ) (Q : D → N → ℝ) (hH : ∀ t, 0 < H t) (hQ : ∀ t j, 0 < Q t j) + {ρ ξ mesh : ℝ} (_hξ0 : 0 ≤ ξ) (_hξ1 : ξ ≤ 1) + (_hwidth : ∀ t j, ((|c t j| : ℤ)+(sides (index t j) : ℤ) : ℝ)*Q t j ≤ ξ*H t) + (_hρ : 0 < ρ) (_hscale : ∀ t, ρ ≤ H t/S.value) (_hscaleQ : ∀ t j, ρ ≤ Q t j) + (_hmeshSize : smoothSpatialMeshThreshold α G N S.value ≤ ρ) (_hmesh : 0 < mesh) + (tv : Finset (D → (Unit ⊕ α) → ℤ)) + (_htv : ∀ v ∈ tv, ∀ t i, |((spatialStar (v t) i : ℤ) : ℝ)/H t| ≤ 1) + (point : (D → (Unit ⊕ α) → ℤ) → EuclideanJetLayers U O) + (test : (D → (Unit ⊕ α) → ℤ) → ℂ) (_htest : ∀ v ∈ tv, ‖test v‖ ≤ 1) + (cap : (D → (Unit ⊕ α) → ℤ) → ℝ) + (_hcap : ∀ w, (allocatedLongResidueWeights B U b S modulus hm r hsize).weight w ≠ 0 → + ∀ v ∈ tv, g w (point v) ≤ cap v) + {Z : ℝ} (_hZ : 0 < Z), + let hSpatialPivot := goodScalarKernelTuple_spatial_det_ne_zero selection x spatialRoot + (one_div_pos.mpr (Nat.cast_pos.mpr hM)) hx + let spatialScale := (∏ t, ∏ _i : Unit ⊕ α, H t : ℝ) + let coefficientScale := ∏ a, allocatedLongJetOutputScale B U b S (O := O) a + let chart := mixedCoveredJetChart U o b hb bW d + let region := mixedCoveredJetRegion (O := O) (E := K) U o b d + (fun j _ => standardLatticeClosedQuarterBox (J j)) + let spatialProxy := fun v => allocatedSpatialProxy B U b S u c index x spatialRoot selection + hSpatialPivot H hH modulus r mesh v / (spatialScale : ℂ) + let δ := smoothVectorSpatialError D N selection M S.value modulus ρ ξ mesh / spatialScale + let proxy := restrictedChartDensity chart region 1 (fun z : MixedCoveredJetSource I O K n d => + allocatedCoveredFixedFactor B U b hR hσ S x u reference rows K d z.1 z.2 * + (allocatedLongJetProxy B U b S x u rows s hA modulus residue + (fun a => coefficientJetAxisEquiv O I n z.1 a.val) / coefficientScale)) + let error := restrictedChartDensity chart region 1 (fun z : MixedCoveredJetSource I O K n d => + allocatedCoveredFixedFactor B U b hR hσ S x u reference rows K d z.1 z.2 * (η / coefficientScale)) + ‖(allocatedLongResidueWeights B U b S modulus hm r hsize).complexMean + (fun w => ∑ v : tv, test v.val * + (((allocatedSpatialOutputLaw B U b S u c index x spatialRoot H Q hH hQ w v.val).toReal : ℂ) * + (g w (point v.val) : ℂ))) / (Z : ℂ) - + (∑ v : tv, test v.val * (spatialProxy v.val * (proxy (point v.val) : ℂ))) / (Z : ℂ)‖ ≤ + (∑ v : tv, (δ * cap v.val + ‖spatialProxy v.val‖ * error (point v.val))) / Z := by + obtain ⟨modulus, hm, hmod, hspatial, hperiod, s, hA, hi, hsize, hdata⟩ := + allocatedGoodKernel_prescribed_spatial_data B U b hR hσ S x rows hM selection hx + hq hinj hrows hσ1 hP hE hη hη1 hMP hRP hRi hσi hcount hηE hlarge + let : NeZero modulus := ⟨hm.ne'⟩ + refine ⟨modulus, hm, hmod, hspatial, hperiod, s, hA, hi, hsize, ?_⟩ + intro u r + obtain ⟨reference, residue, href, hr, hpoint⟩ := hdata u r + refine ⟨reference, residue, href, hr, ?_⟩ + intro _ _ _ _ hb o C hC hchart hsmall K _ bW d _ μ _ _ ν _ _ g hg hg0 hlaw + D N _ _ _ c index spatialRoot hroot H Q hH hQ ρ ξ mesh hξ0 hξ1 hwidth hρ hscale hscaleQ hmeshSize hmesh + tv htv point test htest cap hcap Z hZ hSpatialPivot + exact allocatedSpatialLaw_density_comparison B U b hR hσ S x u rows s hA + hb o hσ1 C hC hchart hsmall bW d μ ν g hg hg0 hlaw c index spatialRoot selection hSpatialPivot H Q hH hQ + hM hx hroot modulus hm (hspatial spatialRoot) r hsize reference href hperiod residue hpoint + hξ0 hξ1 hwidth hρ hscale hscaleQ hmeshSize hmesh tv htv point test htest cap hcap hZ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelTupleSpatialDensity.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelTupleSpatialDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..becadaac784b08fd2a72047cdbc48b5837fba585 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedGoodKernelTupleSpatialDensity.lean @@ -0,0 +1,156 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedMassTupleComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U b S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides + +local notation "whole" => principalTupleWeights (α := α) B (layerSamplerDegree I n) sides (allocatedPrincipalSides_pos B U b S) +local notation "frozen" => allocatedFrozenTupleWeights (α := α) B U b S +local notation "long" => allocatedLongTupleWeights (α := α) B U b S + +theorem allocatedGoodKernel_original_tuple_spatial_density {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P E η : ℝ} (hP : 0 ≤ P) (hE : 0 ≤ E) (hη : 0 < η) (hη1 : η ≤ 1) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hηE : η⁻¹ ≤ Real.exp E) + (hlarge : Real.exp (allocatedJointLengthLog (G := G) B α O P E) ≤ S.value) : + ∃ (modulus : ℕ) (hm : 0 < modulus), + let : NeZero modulus := ⟨hm.ne'⟩ + modulus ≤ M^(m+1) ∧ + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ α) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) ∧ + ∃ hsize : ∀ d, (Fintype.card α+1)*modulus ≤ lengths d, + ∃ (reference : PrincipalAxisTuples (α := α) grid sides → + (PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod modulus) → PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + (residue : PrincipalAxisTuples (α := α) grid sides → + (PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod modulus) → ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + (∀ u r, principalResidueLabel modulus (reference u r) = r) ∧ + (∀ u r v, (allocatedLongResidueWeights B U b S modulus hm r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x u rows j v) modulus = residue u r j) ∧ + ∀ [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C : Fin m → ℝ) (_hC : ∀ j, 0 ≤ C j) + (_hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B α C 1 j) + {K : Fin m → Type*} [∀ j, Fintype (K j)] + (bW : ∀ j, Module.Basis (K j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (d : ℕ) [NeZero d] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) α sides → EuclideanJetLayers U O → ℝ) + (_hg : ∀ w, Continuous (g w)) (_hg0 : ∀ w z, 0 ≤ g w z) + (_hlaw : ∀ w, (realDensityMeasure μ (fun z => allocatedCoefficientDensity B U b hb o hR hσ S + (quotientIntegerCover (coefficientIntegerLattice (K := LayerSamplerVariables G I n B) U) d z))).map + (euclideanCoefficientJetMap U + (allocatedPhysicalCubeRoot B U b S (fun _ => 0) x w) + (allocatedPhysicalCubeDirections B U b S x w) rows) = + realDensityMeasure (Measure.pi (fun j => Measure.pi (fun _ : O j => ν j))) (g w)) + {D N : Type*} [Fintype D] [Fintype N] [DecidableEq N] + (c : D → N → ℤ) (index : D → N → PrincipalTupleIndex B (layerSamplerDegree I n)) + (spatialRoot : G → ℤ) (_hroot : ∀ j, |spatialRoot j| ≤ (S.value : ℤ)) + (H : D → ℝ) (Q : D → N → ℝ) (hH : ∀ t, 0 < H t) (hQ : ∀ t j, 0 < Q t j) + {ρ ξ mesh : ℝ} (_hξ0 : 0 ≤ ξ) (_hξ1 : ξ ≤ 1) + (_hwidth : ∀ t j, ((|c t j| : ℤ)+(sides (index t j) : ℤ) : ℝ)*Q t j ≤ ξ*H t) + (_hρ : 0 < ρ) (_hscale : ∀ t, ρ ≤ H t/S.value) (_hscaleQ : ∀ t j, ρ ≤ Q t j) + (_hmeshSize : smoothSpatialMeshThreshold α G N S.value ≤ ρ) (_hmesh : 0 < mesh) + (tv : Finset (D → (Unit ⊕ α) → ℤ)) + (_htv : ∀ v ∈ tv, ∀ t i, |((spatialStar (v t) i : ℤ) : ℝ)/H t| ≤ 1) + (point : (D → (Unit ⊕ α) → ℤ) → EuclideanJetLayers U O) + (test : (D → (Unit ⊕ α) → ℤ) → ℂ) (_htest : ∀ v ∈ tv, ‖test v‖ ≤ 1) + (cap : (D → (Unit ⊕ α) → ℤ) → ℝ) + (_hcap : ∀ y v, v ∈ tv → g y (point v) ≤ cap v) + {Z : ℝ} (_hZ : 0 < Z), + let hSpatialPivot := goodScalarKernelTuple_spatial_det_ne_zero selection x spatialRoot + (one_div_pos.mpr (Nat.cast_pos.mpr hM)) hx + let spatialScale := (∏ t, ∏ _i : Unit ⊕ α, H t : ℝ) + let coefficientScale := ∏ a, allocatedLongJetOutputScale B U b S (O := O) a + let chart := mixedCoveredJetChart U o b hb bW d + let region := mixedCoveredJetRegion (O := O) (E := K) U o b d + (fun j _ => standardLatticeClosedQuarterBox (J j)) + let spatialProxy := fun u r v => allocatedSpatialProxy B U b S u c index x spatialRoot selection + hSpatialPivot H hH modulus r mesh v / (spatialScale : ℂ) + let δ := smoothVectorSpatialError D N selection M S.value modulus ρ ξ mesh / spatialScale + let proxy := fun u r => restrictedChartDensity chart region 1 (fun z : MixedCoveredJetSource I O K n d => + allocatedCoveredFixedFactor B U b hR hσ S x u (reference u r) rows K d z.1 z.2 * + (allocatedLongJetProxy B U b S x u rows s hA modulus (residue u r) + (fun a => coefficientJetAxisEquiv O I n z.1 a.val) / coefficientScale)) + let chartError := fun u r => restrictedChartDensity chart region 1 (fun z : MixedCoveredJetSource I O K n d => + allocatedCoveredFixedFactor B U b hR hσ S x u (reference u r) rows K d z.1 z.2 * (η / coefficientScale)) + let target := fun u r => ∑ v : tv, test v.val * (spatialProxy u r v.val * (proxy u r (point v.val) : ℂ)) + let budget := fun u r => (∑ v : tv, + (δ * cap v.val + ‖spatialProxy u r v.val‖ * chartError u r (point v.val))) / Z + ‖(whole).complexMean (fun y => ∑ v : tv, test v.val * + (((allocatedOriginalSpatialOutputLaw B U b S x spatialRoot c index H Q hH hQ y v.val).toReal : ℂ) * + (g y (point v.val) : ℂ))) / (Z : ℂ) - + ((frozen).complexMean (fun u => ((long).fiberLaw (principalResidueLabel modulus)).complexMean + (target u))) / (Z : ℂ)‖ ≤ + (frozen).mean (fun u => ((long).fiberLaw (principalResidueLabel modulus)).mean (budget u)) := by + classical + obtain ⟨modulus, hm, hdata⟩ := allocatedGoodKernel_prescribed_spatial_density B U b hR hσ S x rows + hM selection hx hq hinj hrows hσ1 hP hE hη hη1 hMP hRP hRi hσi hcount hηE hlarge + let : NeZero modulus := ⟨hm.ne'⟩ + rcases hdata with ⟨hmod, hspatial, hperiod, s, hA, hi, hsize, hcompare⟩ + choose reference residue href hr hcomparison using hcompare + refine ⟨modulus, hm, hmod, hspatial, hperiod, s, hA, hi, hsize, reference, residue, href, hr, ?_⟩ + intro _ _ _ _ hb o C hC hchart hsmall K _ bW d _ μ _ _ ν _ _ g hg hg0 hlaw + D N _ _ _ c index spatialRoot hroot H Q hH hQ ρ ξ mesh hξ0 hξ1 hwidth hρ hscale hscaleQ hmeshSize hmesh + tv htv point test htest cap hcap Z hZ hSpatialPivot spatialScale coefficientScale chart region + spatialProxy δ proxy chartError target budget + apply allocatedOriginalTuple_spatial_density_comparison B U b S modulus hm hsize x spatialRoot c index H Q hH hQ + (fun y v => g y (point v)) tv test target budget (Z : ℂ) + intro u r + exact hcomparison u r hb o C hC hchart hsmall bW d μ ν + (fun w => g (principalAxisJoin grid u w)) (fun w => hg (principalAxisJoin grid u w)) + (fun w => hg0 (principalAxisJoin grid u w)) (fun w => hlaw (principalAxisJoin grid u w)) + c index spatialRoot hroot H Q hH hQ hξ0 hξ1 hwidth hρ hscale hscaleQ hmeshSize hmesh + tv htv point test htest cap (fun w _ v hv => hcap (principalAxisJoin grid u w) v hv) hZ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedJointAmbientKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedJointAmbientKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa6699262d9c3d96b3173b6ac80df3bbf1e4c88b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedJointAmbientKernel.lean @@ -0,0 +1,149 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedAmbientLogBounds + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped BigOperators NNReal + +variable {K : Type*} [Fintype K] {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (c w : ∀ j : Fin m, I j → BoundedCoefficientExponent K (j.val + 1) → ℝ) +variable (f : ∀ j : Fin m, Fin (n j) → BoundedCoefficientExponent K (j.val + 1) → ℝ → ℝ) + +noncomputable def coefficientJointAmbientKernel (v : CoefficientAmbientIndex K J → ℝ) : ℝ := + ∏ s : CoefficientSlot K m, + canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => c s.1 i s.2) (fun i => w s.1 i s.2) (fun i => f s.1 i s.2) + (fun i => v ⟨s,i⟩) + +theorem coefficientJointAmbientKernel_support (v : CoefficientAmbientIndex K J → ℝ) + (hv : coefficientJointAmbientKernel U b o c w f v ≠ 0) : + ∀ i, |v i| < 1/2 := by + rintro ⟨s,i⟩ + exact canonicalAmbientKernel_support _ _ _ _ _ _ _ + ((Finset.prod_ne_zero_iff.mp hv) s (Finset.mem_univ s)) i + +theorem coefficientJointAmbientKernel_bounds {B L : ℝ≥0} (hB : 1 ≤ B) + (hcap : ∀ (s : CoefficientSlot K m) x, + 0 ≤ canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => c s.1 i s.2) (fun i => w s.1 i s.2) (fun i => f s.1 i s.2) x ∧ + canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => c s.1 i s.2) (fun i => w s.1 i s.2) (fun i => f s.1 i s.2) x ≤ B) + (hlip : ∀ s : CoefficientSlot K m, LipschitzWith L + (canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => c s.1 i s.2) (fun i => w s.1 i s.2) (fun i => f s.1 i s.2))) : + (∀ x, 0 ≤ coefficientJointAmbientKernel U b o c w f x ∧ + coefficientJointAmbientKernel U b o c w f x ≤ (B : ℝ)^Fintype.card (CoefficientSlot K m)) ∧ + LipschitzWith (Fintype.card (CoefficientSlot K m) * L * B^Fintype.card (CoefficientSlot K m)) + (coefficientJointAmbientKernel U b o c w f) := by + let H := fun (s : CoefficientSlot K m) (x : CoefficientAmbientIndex K J → ℝ) => + canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => c s.1 i s.2) (fun i => w s.1 i s.2) (fun i => f s.1 i s.2) + (fun i => x ⟨s,i⟩) + have hL : ∀ s, LipschitzWith L (H s) := by + intro s + apply LipschitzWith.of_dist_le_mul + intro x y + refine ((hlip s).dist_le_mul _ _).trans (mul_le_mul_of_nonneg_left ?_ L.coe_nonneg) + apply (dist_pi_le_iff dist_nonneg).mpr + intro i + exact dist_le_pi_dist x y ⟨s,i⟩ + obtain ⟨hbnd, hprod⟩ := bounded_lipschitz_real_prod H hB hL + (fun s x => by rw [abs_of_nonneg (hcap s _).1]; exact (hcap s _).2) + refine ⟨?_, hprod⟩ + intro x + have h0 : 0 ≤ coefficientJointAmbientKernel U b o c w f x := + Finset.prod_nonneg (fun s _ => (hcap s _).1) + exact ⟨h0, (le_abs_self _).trans (hbnd x)⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (C V : Fin m → ℝ≥0) +variable (hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) +variable (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + +noncomputable def allocatedCoefficientJointAmbientKernel + (x : CoefficientAmbientIndex (LayerSamplerVariables G I n B) J → ℝ) : ℝ := + coefficientJointAmbientKernel U b o (allocatedLayerCenters B U b S) + (allocatedLayerWidths B U b S) (allocatedLayerIntegerInterpolation B U b S) x + +include hC hV in +theorem allocatedAmbientKernelFactor_bounds (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (s : CoefficientSlot (LayerSamplerVariables G I n B) m) : + (∀ x, 0 ≤ canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => allocatedLayerCenters B U b S s.1 i s.2) + (fun i => allocatedLayerWidths B U b S s.1 i s.2) + (fun i => allocatedLayerIntegerInterpolation B U b S s.1 i s.2) x ∧ + canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => allocatedLayerCenters B U b S s.1 i s.2) + (fun i => allocatedLayerWidths B U b S s.1 i s.2) + (fun i => allocatedLayerIntegerInterpolation B U b S s.1 i s.2) x ≤ + allocatedAmbientFactorCap (G := G) B R σ S.value V) ∧ + LipschitzWith (allocatedAmbientFactorLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V) + (canonicalAmbientKernel (euclideanSubspace (U s.1)) (b s.1) (o s.1) + (fun i => allocatedLayerCenters B U b S s.1 i s.2) + (fun i => allocatedLayerWidths B U b S s.1 i s.2) + (fun i => allocatedLayerIntegerInterpolation B U b S s.1 i s.2)) := by + obtain ⟨hcap, hlip⟩ := allocatedLayerMixedInterpolation_bounds B U b S hR hσ s.1 s.2 + obtain ⟨ha, hl⟩ := canonicalAmbientKernel_bounds (euclideanSubspace (U s.1)) (b s.1) (o s.1) + _ _ _ hcap hlip (hC s.1) (hV s.1) + have hcaple : V s.1 * allocatedLayerMixedCap (G := G) B R σ S.value s.1 ≤ + allocatedAmbientFactorCap (G := G) B R σ S.value V := by + apply le_trans (Finset.single_le_sum + (f := fun j => V j * allocatedLayerMixedCap (G := G) B R σ S.value j) + (fun _ _ => zero_le) (Finset.mem_univ s.1)) + exact le_add_of_nonneg_left (by norm_num) + have hliple : allocatedAmbientLayerLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V s.1 ≤ + allocatedAmbientFactorLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V := by + unfold allocatedAmbientFactorLip + exact Finset.single_le_sum + (f := fun j => allocatedAmbientLayerLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V j) + (fun _ _ => zero_le) (Finset.mem_univ s.1) + refine ⟨fun x => ⟨(ha x).1, (ha x).2.trans ?_⟩, hl.weaken hliple⟩ + exact_mod_cast hcaple + +include hC hV in +theorem allocatedCoefficientJointAmbientKernel_bounds + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) : + let A := allocatedAmbientFactorCap (G := G) B R σ S.value V + let L := allocatedAmbientFactorLip (G := G) B R σ S.value (fun j => Fintype.card (J j)) C V + let N := Fintype.card (CoefficientSlot (LayerSamplerVariables G I n B) m) + (∀ x, 0 ≤ allocatedCoefficientJointAmbientKernel B U b S o x ∧ + allocatedCoefficientJointAmbientKernel B U b S o x ≤ (A : ℝ)^N) ∧ + LipschitzWith (N * L * A^N) (allocatedCoefficientJointAmbientKernel B U b S o) := by + have h := allocatedAmbientKernelFactor_bounds B U b S o C V hC hV hR hσ + exact coefficientJointAmbientKernel_bounds U b o _ _ _ + (allocatedAmbientFactorCap_one_le (G := G) B R σ S.value V) + (fun s x => (h s).1 x) (fun s => (h s).2) + +theorem allocatedCoefficientJointAmbientKernel_support + (x : CoefficientAmbientIndex (LayerSamplerVariables G I n B) J → ℝ) + (hx : allocatedCoefficientJointAmbientKernel B U b S o x ≠ 0) : + ∀ i, |x i| < 1/2 := coefficientJointAmbientKernel_support U b o _ _ _ x hx + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelIdealError.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelIdealError.lean new file mode 100644 index 0000000000000000000000000000000000000000..456b5b25b47b882235dea073a884ecafb96846bc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelIdealError.lean @@ -0,0 +1,58 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedIdealRefinedPointwise +import OAI.Combinatorics.Progressions.Sampling.AllocatedLongGridCoordinates + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] {O : Fin m → Type*} [∀ j, Fintype (O j)] + +theorem allocatedKernelIdeal_error_le {D p p₀ e E : ℝ} {δ : ℝ≥0} {M : ℕ} + (hdim : AllocatedComparisonDimensions (G := G) B α O D) + (hp : 0 ≤ p) (hp₀ : 0 ≤ p₀) (he : 0 ≤ e) + (hR : ∀ j, 0 ≤ R j) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp p) + (hδe : (δ : ℝ)⁻¹ ≤ Real.exp e) (hMP₀ : (M : ℝ) ≤ Real.exp p₀) : + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * p₀ + let Q := {q : (Σ a : {a // ¬allocatedGridAxis (I := I) U basis S.value a}, O a.val.1) // + allocatedLongIntegerCoordinate B U basis S q} + let select := allocatedLongIntegerSelect B U basis S (O := O) + let bound : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O p), (Real.exp_pos _).le⟩ + let Kp : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * bound * + bound ^ Fintype.card (LayerSamplerAxis I n) + let Ki : ℝ≥0 := ‖(∏ q : (Σ a : {a // ¬allocatedGridAxis (I := I) U basis S.value a}, O a.val.1), + R q.1.val.1)⁻¹‖₊ * + (affineProductProfileLip (Σ a : {a // ¬allocatedGridAxis (I := I) U basis S.value a}, O a.val.1) δ * + NNReal.mk (Real.exp p) (Real.exp_pos p).le) + let Ro := Real.toNNReal (max (Real.exp (allocatedJetSupportLog (G := G) B α O p)) + (Real.exp p * (partitionedIdealRadius α m + 1))) + (2 * Real.exp (allocatedJetSupportLog (G := G) B α O p) + 1) ^ + Fintype.card (Σ a : LayerSamplerAxis I n, O a.1) * + physicalIdealErrorShare E (allocatedIdealVolumeEnvelope m D p) + + (layerKernelIndexBound m M : ℝ) ^ Fintype.card (LayerSamplerAxis I n) * + (physicalIdealErrorShare E (D * w) + + (2 * (Ro : ℝ)) ^ Fintype.card (UnselectedColumn select) * + ((2 * (Ro : ℝ) + 2) ^ Fintype.card Q * ((Kp : ℝ) + Ki) * + physicalIdealErrorShare E (D * w + allocatedIdealMeshEnvelope m D p e))) ≤ + Real.exp (-E) := by + dsimp only + exact allocatedPhysicalIdeal_error_le B hdim (allocatedGridAxis (I := I) U basis S.value) + (allocatedLongIntegerSelect B U basis S (O := O)) R hR + (δ := δ) (p := p) (e := e) (E := E) + hp he (mul_nonneg (Nat.cast_nonneg _) hp₀) (Nat.cast_nonneg _) + hRi hδe (layerKernelIndexBound_le_exp m hMP₀) le_rfl le_rfl le_rfl + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelJointComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelJointComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cc8f8b46f2adb9bb295d2a286afcb84cedad60f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelJointComparison.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedDensityParameterBounds +import OAI.Combinatorics.Progressions.Sampling.PrincipalGridMixture + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides + +theorem allocatedGoodKernel_principal_comparison {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) : + let C : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), (Real.exp_pos _).le⟩ + let W : ℝ := layerKernelIndexBound m M + ∃ (modulus : ℕ) (hm : 0 < modulus), modulus ≤ M^(m+1) ∧ + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ α) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) ∧ + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (r : PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod modulus) + (hsize : ∀ d, (Fintype.card α+1)*modulus ≤ lengths d), + (∀ d, scalarCubeGridBoundaryConstant α * ((modulus : ℝ)/lengths d) < + volume.real (scalarCubeDomain α)) → + ∃ residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus), + (∀ v, (allocatedLongResidueWeights B U basis S modulus hm r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) ∧ + ∀ z : AllocatedLongJetRows B U basis S O, + |(allocatedLongResidueWeights B U basis S modulus hm r hsize).mean + (fun v => (∏ a, allocatedLongJetOutputScale B U basis S (O := O) a) * + allocatedLongJetDensity B U basis hR hσ S x u v rows s hA hσ1 z) - + (∏ a, allocatedLongJetMask B U basis S x rows modulus residue a (z a)) * + (∫ y, (∏ a, allocatedLongJetTarget B U basis S x u rows s hA y a (z a)) + ∂jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val))| ≤ + Fintype.card {a // ¬grid a} * ε * (1+W*C+ε)^Fintype.card {a // ¬grid a} + + W^Fintype.card {a // ¬grid a} * jointTupleQuadratureError (α := α) + (fun a : {a // ¬grid a} => B a.val) (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val) + (Fintype.card {a // ¬grid a}) C C lengths modulus := by + dsimp only + obtain ⟨modulus, hm, hmB, hspatial, hperiod, s, hA, hi, herr⟩ := + allocatedGoodKernel_replacement B U basis hR hσ S x rows hM selection hx hq hinj hrows hσ1 + hP he hε hMP hRP hRi hσi hcount hεe hlarge + refine ⟨modulus, hm, hmB, hspatial, hperiod, s, hA, hi, ?_⟩ + intro u r hsize hsmall + let residue := fun j => integerResidueMatrix + (integerMappedJetMatrix (allocatedNonkernelExponent B j) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (rows j) (principalResidueLift modulus r)) modulus + have hr : ∀ v, (allocatedLongResidueWeights B U basis S modulus hm r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j := by + intro v hv j + exact allocatedLongResidueWeights_matrix B U basis S modulus hm r hsize x u rows + (principalResidueLift modulus r) (principalResidueLift_spec modulus r) j v hv + have herror := herr u (allocatedLongResidueWeights B U basis S modulus hm r hsize) residue hr + obtain ⟨hC, hcap, hLip⟩ := allocatedLongJetTarget_exp_bounds B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount u hσ1 + have hW : (1 : ℝ) ≤ layerKernelIndexBound m M := by + exact_mod_cast Nat.succ_le_of_lt (show 0 < layerKernelIndexBound m M from pow_pos hM _) + refine ⟨residue, hr, ?_⟩ + intro z + exact allocatedLongJet_principal_comparison B U basis hR hσ S modulus hm r hsize x u rows s hA hσ1 + residue hsmall _ _ hC hW hε.le hcap hLip + (fun j i hj => (herror j i hj).1) (fun v hv j i hj z => (herror j i hj).2 v hv z) z + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelOutputRegularity.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelOutputRegularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..46fae4d2cdf269be8c30e42d8bb0cc2eb15e28ea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelOutputRegularity.lean @@ -0,0 +1,152 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedDensityParameterBounds + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j : Fin m, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {M : ℕ} (hM : 0 < M) +variable (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMP : (M : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) + +local notation "bound" => NNReal.mk (Real.exp (allocatedDensityLog (G := G) B α O P)) + (le_of_lt (Real.exp_pos _)) +local notation "radius" j => NNReal.mk (R j) (le_of_lt (hR j)) +local notation "delta" j => NNReal.mk + (allocatedUnitProfileWidth (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (Fin.val j + 1)))) + (le_of_lt (allocatedUnitProfileWidth_pos (hR j) (hσ j) _)) + +include hM hi hP hMP hRP hRi hσi hcount in +theorem allocatedKernelOutput_bounds (j : Fin m) {H : ℝ} (hH : 0 < H) : + let E := normalizedPivotEquiv _ (hA j) + (fun o => kernelJetCoefficientScale G (j.val + 1) S.value H (s j o)) (fun _ => H) + (fun o => kernelJetCoefficientScale_pos G (j.val + 1) (Nat.cast_pos.mpr S.positive) hH (s j o)) + (fun _ => hH) + pivotKernelCap (UnselectedColumn (s j)) E (radius j) + ((delta j)⁻¹ ^ Fintype.card (BoundedIntegerExponent G (j.val + 1))) ≤ bound ∧ + pivotKernelLip (UnselectedColumn (s j)) E (radius j) + (affineProductProfileLip (BoundedIntegerExponent G (j.val + 1)) (delta j)) ≤ bound := by + dsimp only + have hp' : 0 ≤ 4 * (P + 8) := by positivity + have hPP : Real.exp P ≤ Real.exp (4 * (P + 8)) := Real.exp_le_exp.mpr (by linarith) + have hb := allocatedDensityLog_bounds (G := G) B α O hP + have hf := fixedKernel_family_output_bound (N := AllocatedNonkernelCoefficient (G := G) B) + S.positive hM x (fun j : Fin m => j.val + 1) rows s hA hi + (fun j => delta j) (fun j => radius j) + (fun j => allocatedUnitProfileWidth_pos (hR j) (hσ j) _) hp' (hMP.trans hPP) + (fun j => (hRP j).trans hPP) + (fun j => allocatedUnitProfileWidth_inverse_exp _ hP (hR j) (hσ j) (hRi j) (hσi j) (hcount j)) + (fun _ => H) (fun _ => hH) + constructor + · exact (hf.2.1 j).trans (by exact_mod_cast Real.exp_le_exp.mpr hb.2.1) + · exact (hf.2.2.1 j).trans (by exact_mod_cast Real.exp_le_exp.mpr hb.2.1) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [dG : DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val + 1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val + 1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {M : ℕ} (hM : 0 < M) +variable (hi : ∀ j : Fin m, + fixedKernelInverseBound S.positive x (j.val + 1) (rows j) (s j) (hA j) (1 / (M : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMP : (M : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, (Fintype.card + (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) + 1 ≤ Real.exp P) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) + +local notation "grid" => allocatedGridAxis (I := I) U basis S.value +local notation "bound" => NNReal.mk (Real.exp (allocatedDensityLog (G := G) B α O P)) + (le_of_lt (Real.exp_pos _)) +local notation "input" => PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a) + +include hR hσ hM hi hP hMP hRP hRi hσi hcount + +theorem allocatedContinuousKernelDensity_output_bounds (hσ1 : ∀ j, σ j ≤ 1) + (j : Fin m) (i : I j) (y : input → ℝ) : + (∀ z, |allocatedContinuousKernelDensity B U basis S j i x u (rows j) (s j) (hA j) y z| ≤ bound) ∧ + LipschitzWith bound (allocatedContinuousKernelDensity B U basis S j i x u (rows j) (s j) (hA j) y) := by + cases Subsingleton.elim dG (Classical.decEq G) + refine ⟨fun z => (allocatedContinuousKernelDensity_exp_bounds B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount u hσ1 j i z).1 y, ?_⟩ + have hb := allocatedKernelOutput_bounds B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount j (H := 1) zero_lt_one + let reindex := allocatedKernelCoefficientEquiv (G := G) B j + let δ : ℝ≥0 := ⟨allocatedUnitProfileWidth (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1))), + (allocatedUnitProfileWidth_pos (hR j) (hσ j) _).le⟩ + have hδ : 0 < δ := allocatedUnitProfileWidth_pos (hR j) (hσ j) _ + unfold allocatedContinuousKernelDensity + exact (affineSelectedJetDensity_output_lipschitz (s j) _ _ _ _ _ _ _ _ + (fun t => allocatedContinuousProfileWidths_pos B hR hσ j i (reindex t)) hδ + (fun t => allocatedContinuousProfileWidths_floor B hR j i (reindex (.inl t))) + ⟨R j, (hR j).le⟩ + (fun t => allocatedContinuousProfile_bound B hR hσ j i (hσ1 j) (reindex t)) y).weaken hb.2 + +theorem allocatedIntegerKernelDensity_output_bounds (hσ1 : ∀ j, σ j ≤ 1) + (j : Fin m) (i : Fin (n j)) (y : input → ℝ) : + (∀ z, |allocatedIntegerKernelDensity B U basis S j i x u (rows j) (s j) (hA j) y z| ≤ bound) ∧ + LipschitzWith bound (allocatedIntegerKernelDensity B U basis S j i x u (rows j) (s j) (hA j) y) := by + cases Subsingleton.elim dG (Classical.decEq G) + refine ⟨fun z => (allocatedIntegerKernelDensity_exp_bounds B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount u hσ1 j i z).1 y, ?_⟩ + have hb := allocatedKernelOutput_bounds B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount j + (Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i)) + let reindex := allocatedKernelCoefficientEquiv (G := G) B j + let δ : ℝ≥0 := ⟨allocatedUnitProfileWidth (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1))), + (allocatedUnitProfileWidth_pos (hR j) (hσ j) _).le⟩ + have hδ : 0 < δ := allocatedUnitProfileWidth_pos (hR j) (hσ j) _ + unfold allocatedIntegerKernelDensity + exact (affineSelectedJetDensity_output_lipschitz (s j) _ _ _ _ _ _ _ _ + (fun t => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex t)) hδ + (fun t => allocatedIntegerProfileWidths_floor B hR j i (reindex (.inl t))) + ⟨R j, (hR j).le⟩ + (fun t => allocatedKernelProfile_bound B hR hσ j i (hσ1 j) (reindex t)) y).weaken hb.2 + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelPrimitiveBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelPrimitiveBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..c51c650ede61e9f3ac3dea37f05c11eb7e07972e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelPrimitiveBudget.lean @@ -0,0 +1,596 @@ +import OAI.Combinatorics.Progressions.Estimates.DiscreteMinorThreshold +import OAI.Combinatorics.Progressions.Estimates.FiniteEventUnion +import OAI.Combinatorics.Progressions.Estimates.ScalarCubeCokernelCutoff +import OAI.Combinatorics.Progressions.Linear.JointKernelCutoffBudget +import OAI.Combinatorics.Progressions.Linear.KernelBudgetEnvelope +import OAI.Combinatorics.Progressions.Linear.MatrixSupInverse + +namespace OAI + + +namespace Erdos3 + +def GoodScalarKernelTuple {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] + {L : ℕ} (s : I → J) (κ : ℝ) (B : ℕ) (x : J → IntegerScalarCubeBox I L) : Prop := + κ < |normalizedScalarCubeMinor s x| ∧ + HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range B + +theorem scalarKernel_bad_event_le {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] {L : ℕ} + (p : FiniteProbabilityWeights (J → IntegerScalarCubeBox I L)) + (s : I → J) (κ : ℝ) (B : ℕ) (hκ : 0 < κ) : + p.eventProbability (fun x => ¬ GoodScalarKernelTuple s κ B x) ≤ + p.eventProbability (fun x => |normalizedScalarCubeMinor s x| ≤ κ) + + p.eventProbability (scalarCubeLargeCokernelEvent B) := by + apply (p.eventProbability_mono _ + (fun x => |normalizedScalarCubeMinor s x| ≤ κ ∨ scalarCubeLargeCokernelEvent B x) ?_).trans + (p.eventProbability_or_le _ _) + intro x hx + by_cases hsmall : |normalizedScalarCubeMinor s x| ≤ κ + · exact Or.inl hsmall + · apply Or.inr + have hminor : ((scalarCubeDifferenceMatrix x).submatrix id s).det ≠ 0 := by + intro hz + apply hsmall + simpa only [normalizedScalarCubeMinor, hz, Int.cast_zero, zero_div, abs_zero] using hκ.le + have hp : ¬ HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range B := + fun hp => hx ⟨lt_of_not_ge hsmall, hp⟩ + exact (scalarCube_no_bounded_period_iff B x).mp ⟨⟨s, hminor⟩, hp⟩ + +theorem exists_uniform_good_scalar_kernel_tuples (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) : + ∃ s : I ↪ J, ∀ η : ℝ, 0 < η → ∃ (κ : ℝ) (B L₀ : ℕ), + 0 < κ ∧ 0 < B ∧ Fintype.card I + 1 ≤ L₀ ∧ ∀ (L : ℕ) (hL : 0 < L), L₀ ≤ L → + (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => ¬ GoodScalarKernelTuple s κ B x) ≤ η := by + classical + have hcard : Fintype.card I ≤ Fintype.card J := by rw [hJ]; nlinarith + obtain ⟨s⟩ := Function.Embedding.nonempty_of_card_le hcard + let : Nonempty J := ⟨s (Classical.choice (inferInstance : Nonempty I))⟩ + let N := Fintype.card (J × Option I) + let e : J × Option I ≃ Fin N := Fintype.equivFin _ + have hN : 0 < N := Fintype.card_pos + refine ⟨s, fun η hη => ?_⟩ + let κ := discreteScalarMinorThreshold I J N η + have hκ : 0 < κ := discreteScalarMinorThreshold_pos I J hN hη + obtain ⟨L₀, hsize, hreal⟩ := exists_discrete_minor_length I J e hN s s.injective η hη + obtain ⟨B, hB, hperiod⟩ := exists_scalarCube_cokernel_cutoff I J hJ (η / 2) (half_pos hη) + refine ⟨κ, B, L₀, hκ, hB, hsize, fun L hL hlarge => ?_⟩ + apply (scalarKernel_bad_event_le _ s κ B hκ).trans + have hr := hreal L hL hlarge + have hp : (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (scalarCubeLargeCokernelEvent B) ≤ η / 2 := by + have hevents : stridedScalarCubeLargeCokernelEvent (I := I) (J := J) (L := L) 1 (1 * B) = + scalarCubeLargeCokernelEvent B := by + funext x + simp only [stridedScalarCubeLargeCokernelEvent, scalarCubeLargeCokernelEvent, + Nat.cast_one, one_smul, one_mul] + have hp := hperiod L 1 hL (hsize.trans hlarge) Nat.zero_lt_one + rwa [hevents] at hp + exact (add_le_add hr hp).trans_eq (by ring) + + +noncomputable def scalarKernelConditioningConstant (I J : Type*) [Fintype I] [Fintype J] + (M D : ℕ) : ℝ := (scalarCubeResidueDensityCap I (M * D)) ^ Fintype.card J + +noncomputable def scalarKernelTailConstant (I J : Type*) [Fintype I] [Fintype J] : ℝ := + (integerScalarCubeDensityCap I * (1 + ((Fintype.card I).factorial : ℝ))) ^ Fintype.card J + +noncomputable def scalarKernelAdjustedAccuracy (I J : Type*) [Fintype I] [Fintype J] + (M D : ℕ) (η : ℝ) : ℝ := η / scalarKernelConditioningConstant I J M D + +noncomputable def scalarKernelThreshold (I J : Type*) [Fintype I] [Fintype J] + (M D : ℕ) (η : ℝ) : ℝ := + discreteScalarMinorThreshold I J (Fintype.card (J × Option I)) + (scalarKernelAdjustedAccuracy I J M D η) + +noncomputable def scalarKernelCutoff (I J : Type*) [Fintype I] [Fintype J] + (M D : ℕ) (η : ℝ) : ℕ := + jointKernelCutoff (Fintype.card I + 1) (D * ((Fintype.card I + 1) * M)) + (coordinateDeterminantVariation I (Fin (Fintype.card (J × Option I)))) + (scalarKernelTailConstant I J) (scalarKernelAdjustedAccuracy I J M D η) + (scalarKernelThreshold I J M D η) + +theorem scalarKernelConditioningConstant_pos (I J : Type*) [Fintype I] [Fintype J] + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) : 0 < scalarKernelConditioningConstant I J M D := + pow_pos (scalarCubeResidueDensityCap_pos I (M * D) (Nat.mul_pos hM hD)) _ + +theorem scalarKernelTailConstant_pos (I J : Type*) [Fintype I] [Fintype J] : + 0 < scalarKernelTailConstant I J := by + unfold scalarKernelTailConstant + exact pow_pos (mul_pos (integerScalarCubeDensityCap_pos I) (by positivity)) _ + +theorem scalarKernelAdjustedAccuracy_pos (I J : Type*) [Fintype I] [Fintype J] + {M D : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) : + 0 < scalarKernelAdjustedAccuracy I J M D η := + div_pos hη (scalarKernelConditioningConstant_pos I J hM hD) + +theorem scalarKernelThreshold_pos (I J : Type*) [Fintype I] [Fintype J] + {M D : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) : + 0 < scalarKernelThreshold I J M D η := by + unfold scalarKernelThreshold discreteScalarMinorThreshold + apply polynomialSublevelThreshold_pos + · apply mul_nonneg (pow_nonneg (integerScalarCubeDensityCap_pos I).le _) + unfold multivariateSublevelConstant + exact mul_nonneg (by positivity) (univariateSublevelConstant_pos _).le + · positivity + · exact scalarKernelAdjustedAccuracy_pos I J hM hD hη + +theorem scalarKernelCutoff_bounds (I J : Type*) [Fintype I] [Fintype J] + {M D : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) : + 0 < scalarKernelCutoff I J M D η ∧ + Fintype.card I + 1 ≤ scalarKernelCutoff I J M D η ∧ + D * ((Fintype.card I + 1) * M) ≤ scalarKernelCutoff I J M D η ∧ + 1 / scalarKernelThreshold I J M D η ≤ (scalarKernelCutoff I J M D η : ℝ) ∧ + coordinateDeterminantVariation I (Fin (Fintype.card (J × Option I))) / + scalarKernelThreshold I J M D η ≤ (scalarKernelCutoff I J M D η : ℝ) ∧ + 2 * scalarKernelTailConstant I J / scalarKernelAdjustedAccuracy I J M D η ≤ + (scalarKernelCutoff I J M D η : ℝ) := + jointKernelCutoff_bounds _ _ (coordinateDeterminantVariation_nonneg _ _) + (scalarKernelTailConstant_pos I J).le (scalarKernelAdjustedAccuracy_pos I J hM hD hη) + (scalarKernelThreshold_pos I J hM hD hη) + + +noncomputable def normalizedScalarCubePivot {I J : Type*} {L : ℕ} + (s : I → J) (x : J → IntegerScalarCubeBox I L) : Matrix I I ℝ := + fun i j => (x (s j) (some i) : ℤ) / (L : ℝ) + +theorem normalizedScalarCubePivot_det {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] {L : ℕ} + (s : I → J) (x : J → IntegerScalarCubeBox I L) : + (normalizedScalarCubePivot s x).det = normalizedScalarCubeMinor s x := by + let e := Fintype.equivFin (J × Option I) + have h := scalarCubeMinorPolynomial_grid_eval e s x + rw [scalarCubeMinorPolynomial, coordinateMatrixPolynomial_eval] at h + change Matrix.det (fun i j => ((x (s j) (some i) : ℤ) : ℝ) / (L : ℝ)) = _ + simpa only [scalarCubeGrid, e.symm_apply_apply] using h + +theorem normalizedScalarCubePivot_entry_bound {I J : Type*} {L : ℕ} + (hL : 0 < L) (s : I → J) (x : J → IntegerScalarCubeBox I L) (i j : I) : + |normalizedScalarCubePivot s x i j| ≤ 1 := by + have hL' : (0 : ℝ) < L := by exact_mod_cast hL + have hx := Finset.mem_Ico.mp (x (s j) (some i)).property + change |((x (s j) (some i) : ℤ) : ℝ) / (L : ℝ)| ≤ 1 + rw [abs_div, abs_of_pos hL'] + apply (div_le_one hL').mpr + exact_mod_cast abs_le.mpr ⟨hx.1, hx.2.le⟩ + +theorem goodScalarKernelTuple_pivot_inverse {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] {L : ℕ} + (hL : 0 < L) (s : I → J) (κ : ℝ) (B : ℕ) (hκ : 0 < κ) + (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple s κ B x) : + (matrixSupCLM (normalizedScalarCubePivot s x)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedScalarCubePivot s x)).inverse‖ ≤ + Fintype.card I * ((Fintype.card I).factorial : ℝ) / κ := by + have hd : κ ≤ |(normalizedScalarCubePivot s x).det| := by + rw [normalizedScalarCubePivot_det] + exact hx.1.le + have h := matrixSupCLM_inverse_norm_le (normalizedScalarCubePivot s x) zero_le_one + (normalizedScalarCubePivot_entry_bound hL s x) hκ hd + simpa only [one_pow, mul_one, mul_div_assoc] using h + + +theorem hasBoundedScalarPeriod_mono {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) {B B' : ℕ} (hB : B ≤ B') + (h : HasBoundedScalarPeriod L B) : HasBoundedScalarPeriod L B' := by + obtain ⟨a, ha, haB, hperiod⟩ := h + exact ⟨a, ha, haB.trans hB, hperiod⟩ + +theorem hasBoundedScalarPeriod_index_le {I : Type*} [Fintype I] + (L : Submodule ℤ (I → ℤ)) (B : ℕ) (h : HasBoundedScalarPeriod L B) : + L.toAddSubgroup.index ≤ B ^ Fintype.card I := by + obtain ⟨a, ha, haB, hperiod⟩ := h + let : NeZero a := ⟨ha.ne'⟩ + exact (residueLatticeImage_index_le L a hperiod).trans (Nat.pow_le_pow_left haB _) + +theorem goodScalarKernelTuple_mono {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] {L : ℕ} + (s : I → J) {κ κ' : ℝ} {B B' : ℕ} (hκ : κ' ≤ κ) (hB : B ≤ B') + (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple s κ B x) : + GoodScalarKernelTuple s κ' B' x := + ⟨hκ.trans_lt hx.1, hasBoundedScalarPeriod_mono _ hB hx.2⟩ + +theorem exists_uniform_good_scalar_kernel_bound (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) : + ∃ s : I ↪ J, ∀ η : ℝ, 0 < η → ∃ B L₀ : ℕ, + 0 < B ∧ Fintype.card I + 1 ≤ L₀ ∧ ∀ (L : ℕ) (hL : 0 < L), L₀ ≤ L → + (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (B : ℝ)) B x) ≤ η := by + obtain ⟨s, hs⟩ := exists_uniform_good_scalar_kernel_tuples I J hJ + refine ⟨s, fun η hη => ?_⟩ + obtain ⟨κ, B, L₀, hκ, hB, hL₀, hprob⟩ := hs η hη + obtain ⟨C, hC⟩ := exists_nat_gt (max 1 (1 / κ)) + let B' := max B C + have hBB' : B ≤ B' := Nat.le_max_left _ _ + have hB' : 0 < B' := hB.trans_le hBB' + have hbound : 1 / κ ≤ (B' : ℝ) := + ((le_max_right _ _).trans hC.le).trans (by exact_mod_cast Nat.le_max_right B C) + have hsmall : 1 / (B' : ℝ) ≤ κ := by + apply (div_le_iff₀ (by exact_mod_cast hB')).mpr + have h := (div_le_iff₀ hκ).mp hbound + nlinarith + refine ⟨B', L₀, hB', hL₀, fun L hL hlarge => ?_⟩ + apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans (hprob L hL hlarge) + intro x hx hold + exact hx (goodScalarKernelTuple_mono s hsmall hBB' x hold) + + +noncomputable def scalarKernelCutoffLogBudget (I J : Type*) [Fintype I] [Fintype J] (P : ℝ) : ℝ := + 2 * ((4 + 3 * ((Fintype.card (J × Option I) * Fintype.card I : ℕ) : ℝ)) * (P + 2)) + 8 + +theorem scalarKernelCutoff_le_exp_of_bounds (I J : Type*) [Fintype I] [Fintype J] + {M D : ℕ} {η P : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) (hP : 1 ≤ P) + (hnP : (Fintype.card I + 1 : ℝ) ≤ Real.exp P) + (hbP : (D * ((Fintype.card I + 1) * M) : ℕ) ≤ Real.exp P) + (hKP : coordinateDeterminantVariation I (Fin (Fintype.card (J × Option I))) ≤ Real.exp P) + (hTP : scalarKernelTailConstant I J ≤ Real.exp P) + (hεP : (scalarKernelAdjustedAccuracy I J M D η)⁻¹ ≤ Real.exp P) + (hCP : (integerScalarCubeDensityCap I) ^ Fintype.card J * + multivariateSublevelConstant (Fintype.card (J × Option I)) (Fintype.card I) ≤ Real.exp P) + (hSP : (Fintype.card I + 1 : ℝ) ^ Fintype.card (J × Option I) ≤ Real.exp P) : + (scalarKernelCutoff I J M D η : ℝ) ≤ Real.exp (scalarKernelCutoffLogBudget I J P) := by + let a : ℝ := ((Fintype.card (J × Option I) * Fintype.card I : ℕ) : ℝ) + let Q := (4 + 3 * a) * (P + 2) + have ha : 0 ≤ a := Nat.cast_nonneg _ + have hP0 : 0 ≤ P := zero_le_one.trans hP + have hPQ : P ≤ Q := by dsimp [Q]; nlinarith + have hQ : 0 ≤ Q := hP0.trans hPQ + have hκ := scalarKernelThreshold_pos I J hM hD hη + have hε := scalarKernelAdjustedAccuracy_pos I J hM hD hη + have hC : 0 ≤ (integerScalarCubeDensityCap I) ^ Fintype.card J * + multivariateSublevelConstant (Fintype.card (J × Option I)) (Fintype.card I) := by + apply mul_nonneg (pow_nonneg (integerScalarCubeDensityCap_pos I).le _) + unfold multivariateSublevelConstant + exact mul_nonneg (by positivity) (univariateSublevelConstant_pos _).le + have hS : 0 ≤ (Fintype.card I + 1 : ℝ) ^ Fintype.card (J × Option I) := by positivity + have h2 : (1 + 1 : ℝ) ≤ Real.exp P := by linarith [Real.add_one_le_exp P] + have ht := polynomialSublevelThreshold_log_budget + (Fintype.card (J × Option I) * Fintype.card I) 1 hC hS hε hP0 hCP hSP + (by simpa only [Nat.cast_one] using h2) hεP + have hlog : Real.log (scalarKernelThreshold I J M D η)⁻¹ ≤ + (1 + 3 * a) * P + 2 * Real.log 2 + a * Real.log 3 := ht + have hlog2 : Real.log 2 ≤ 2 := by linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2)] + have hlog3 : Real.log 3 ≤ 3 := by linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3)] + have hκQ : (scalarKernelThreshold I J M D η)⁻¹ ≤ Real.exp Q := by + apply (Real.log_le_iff_le_exp (inv_pos.mpr hκ)).mp + apply hlog.trans + have h3 := mul_le_mul_of_nonneg_left hlog3 ha + dsimp [Q] + nlinarith + have hexp : Real.exp P ≤ Real.exp Q := Real.exp_le_exp.mpr hPQ + exact jointKernelCutoff_le_exp _ _ (coordinateDeterminantVariation_nonneg _ _) + (scalarKernelTailConstant_pos I J).le hε hκ hQ + (by simpa only [Nat.cast_add, Nat.cast_one] using hnP.trans hexp) + (hbP.trans hexp) (hKP.trans hexp) (hTP.trans hexp) (hεP.trans hexp) hκQ + + +theorem univariateSublevelConstant_le_exp (q : ℕ) (hq : 0 < q) : + univariateSublevelConstant q ≤ Real.exp ((q + 1 : ℝ) + q * (8 + (q + 1 : ℝ))) := by + have hn : (q + 1 : ℝ) ≤ Real.exp (q + 1 : ℝ) := by + linarith [Real.add_one_le_exp (q + 1 : ℝ)] + have h8 : (8 : ℝ) ≤ Real.exp 8 := by linarith [Real.add_one_le_exp (8 : ℝ)] + have hbase : 1 ≤ (q + 1 : ℝ) * (8 * (q + 1 : ℝ)) ^ q := by + have hp : 1 ≤ (8 * (q + 1 : ℝ)) ^ q := one_le_pow₀ (by have := Nat.cast_nonneg q (α := ℝ); linarith) + have hq0 : (0 : ℝ) ≤ q := Nat.cast_nonneg _ + nlinarith + have hq1 : (1 : ℝ) ≤ q := by exact_mod_cast hq + have hi : (q : ℝ)⁻¹ ≤ 1 := inv_le_one_of_one_le₀ hq1 + have hm : 8 * (q + 1 : ℝ) ≤ Real.exp (8 + (q + 1 : ℝ)) := by + rw [Real.exp_add] + exact mul_le_mul h8 hn (by positivity) (Real.exp_pos _).le + calc + _ ≤ (q + 1 : ℝ) * (8 * (q + 1 : ℝ)) ^ q := by + simpa only [univariateSublevelConstant, Real.rpow_one] using + Real.rpow_le_rpow_of_exponent_le hbase hi + _ ≤ Real.exp (q + 1 : ℝ) * Real.exp (8 + (q + 1 : ℝ)) ^ q := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add] + +theorem multivariateSublevelConstant_le_exp (N q : ℕ) (hq : 0 < q) : + multivariateSublevelConstant N q ≤ + Real.exp (3 * (N : ℝ) + (q + 1 : ℝ) + q * (8 + (q + 1 : ℝ))) := by + have h2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hN : (N : ℝ) ≤ Real.exp N := by linarith [Real.add_one_le_exp (N : ℝ)] + have hu0 := (univariateSublevelConstant_pos q).le + have hu := univariateSublevelConstant_le_exp q hq + unfold multivariateSublevelConstant + calc + _ ≤ (Real.exp 2) ^ N * Real.exp N * + Real.exp ((q + 1 : ℝ) + q * (8 + (q + 1 : ℝ))) := by + gcongr + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +theorem integerScalarCubeDensityCap_le_exp (I : Type*) [Fintype I] : + integerScalarCubeDensityCap I ≤ + Real.exp ((Fintype.card I + 1 : ℝ) * (4 + (Fintype.card I + 1 : ℝ))) := by + have h4 : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have hn : (Fintype.card I + 1 : ℝ) ≤ Real.exp (Fintype.card I + 1 : ℝ) := by + linarith [Real.add_one_le_exp (Fintype.card I + 1 : ℝ)] + unfold integerScalarCubeDensityCap + push_cast + calc + _ ≤ (Real.exp 4 * Real.exp (Fintype.card I + 1 : ℝ)) ^ (Fintype.card I + 1) := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_nat_mul]; push_cast; rfl + +theorem scalarKernelTailConstant_le_exp (I J : Type*) [Fintype I] [Fintype J] : + scalarKernelTailConstant I J ≤ Real.exp ((Fintype.card J : ℝ) * + ((Fintype.card I + 1 : ℝ) * (4 + (Fintype.card I + 1 : ℝ)) + (Fintype.card I : ℝ)^2 + 1)) := by + have hf := factorial_le_exp_sq (Fintype.card I) + have hA0 := (integerScalarCubeDensityCap_pos I).le + have hA := integerScalarCubeDensityCap_le_exp I + have hE : 1 ≤ Real.exp ((Fintype.card I : ℝ)^2) := Real.one_le_exp_iff.mpr (sq_nonneg _) + have h2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hs : 1 + ((Fintype.card I).factorial : ℝ) ≤ Real.exp ((Fintype.card I : ℝ)^2 + 1) := by + rw [Real.exp_add] + nlinarith [mul_le_mul_of_nonneg_left h2 (Real.exp_pos ((Fintype.card I : ℝ)^2)).le] + unfold scalarKernelTailConstant + calc + _ ≤ (Real.exp ((Fintype.card I + 1 : ℝ) * (4 + (Fintype.card I + 1 : ℝ))) * + Real.exp ((Fintype.card I : ℝ)^2 + 1)) ^ Fintype.card J := by + gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_nat_mul]; congr 1; ring + +theorem coordinateDeterminantVariation_le_exp (I : Type*) [Fintype I] (N : ℕ) : + coordinateDeterminantVariation I (Fin N) ≤ + Real.exp ((N : ℝ) + (Fintype.card I : ℝ)^2 + Fintype.card I) := by + have hN : (N : ℝ) ≤ Real.exp N := by linarith [Real.add_one_le_exp (N : ℝ)] + have hq : (Fintype.card I : ℝ) ≤ Real.exp (Fintype.card I : ℝ) := by + linarith [Real.add_one_le_exp (Fintype.card I : ℝ)] + simp only [coordinateDeterminantVariation, Fintype.card_fin] + calc + _ ≤ Real.exp N * (Real.exp ((Fintype.card I : ℝ)^2) * Real.exp (Fintype.card I : ℝ)) := by + gcongr + exact factorial_le_exp_sq _ + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + + +theorem scalarKernel_explicit_probability_le (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) (s : I ↪ J) + {M D L : ℕ} {η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) (hL : 0 < L) + (hlarge : scalarKernelCutoff I J M D η ≤ L) : + (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (scalarKernelCutoff I J M D η : ℝ)) + (scalarKernelCutoff I J M D η) x) ≤ scalarKernelAdjustedAccuracy I J M D η := by + let B := scalarKernelCutoff I J M D η + let κ := scalarKernelThreshold I J M D η + let ε := scalarKernelAdjustedAccuracy I J M D η + obtain ⟨hB, hsize, _, hinv, hmesh, htail⟩ := scalarKernelCutoff_bounds I J hM hD hη + have hB' : (0 : ℝ) < B := by exact_mod_cast hB + have hL' : (0 : ℝ) < L := by exact_mod_cast hL + have hκ : 0 < κ := scalarKernelThreshold_pos I J hM hD hη + have hε : 0 < ε := scalarKernelAdjustedAccuracy_pos I J hM hD hη + have hsizeL : Fintype.card I + 1 ≤ L := hsize.trans hlarge + have hsmall : 1 / (B : ℝ) ≤ κ := by + apply (div_le_iff₀ hB').mpr + have h := (div_le_iff₀ hκ).mp hinv + nlinarith + have hmeshL : coordinateDeterminantVariation I (Fin (Fintype.card (J × Option I))) / L ≤ κ := by + apply (div_le_iff₀ hL').mpr + have hBL : (scalarKernelCutoff I J M D η : ℝ) ≤ (L : ℝ) := by exact_mod_cast hlarge + have h := (div_le_iff₀ hκ).mp (hmesh.trans hBL) + nlinarith + have htailB : scalarKernelTailConstant I J / B ≤ ε / 2 := by + apply (div_le_iff₀ hB').mpr + have h := (div_le_iff₀ hε).mp htail + nlinarith + have hJpos : 0 < Fintype.card J := by + rw [hJ] + exact Nat.mul_pos Fintype.card_pos (by omega) + have hN : 0 < Fintype.card (J × Option I) := by + rw [Fintype.card_prod, Fintype.card_option] + exact Nat.mul_pos hJpos (by omega) + have hreal := discrete_minor_threshold_probability (Fintype.equivFin (J × Option I)) hN + s s.injective L hL hsizeL ε hε hmeshL + have hminor : (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => |normalizedScalarCubeMinor s x| ≤ 1 / (B : ℝ)) ≤ ε / 2 := by + apply (FiniteProbabilityWeights.eventProbability_mono _ _ _ ?_).trans hreal + intro x hx + exact hx.trans hsmall + have hcoker := scalarCube_largeCokernel_probability_le (I := I) (J := J) L B hL hsizeL hB hJ + apply (scalarKernel_bad_event_le _ s (1 / (B : ℝ)) B (one_div_pos.mpr hB')).trans + exact (add_le_add hminor (hcoker.trans htailB)).trans_eq (by ring) + + +theorem scalarKernelConditioningConstant_le_exp (I J : Type*) [Fintype I] [Fintype J] + (M D : ℕ) {R : ℝ} (hM : (M : ℝ) ≤ Real.exp R) (hD : (D : ℝ) ≤ Real.exp R) : + scalarKernelConditioningConstant I J M D ≤ Real.exp ((Fintype.card J : ℝ) * + (Fintype.card I + 1 : ℝ) * (4 + (Fintype.card I + 1 : ℝ) + 2 * R)) := by + have h4 : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have hn : (Fintype.card I + 1 : ℝ) ≤ Real.exp (Fintype.card I + 1 : ℝ) := by + linarith [Real.add_one_le_exp (Fintype.card I + 1 : ℝ)] + have hbase : 4 * (Fintype.card I + 1 : ℝ) * ((M : ℝ) * D) ≤ + Real.exp (4 + (Fintype.card I + 1 : ℝ) + 2 * R) := by + calc + _ ≤ Real.exp 4 * Real.exp (Fintype.card I + 1 : ℝ) * (Real.exp R * Real.exp R) := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add]; congr 1; ring + unfold scalarKernelConditioningConstant scalarCubeResidueDensityCap + push_cast + calc + _ ≤ (Real.exp (4 + (Fintype.card I + 1 : ℝ) + 2 * R) ^ (Fintype.card I + 1)) ^ Fintype.card J := by + gcongr + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_nat_mul] + congr 1 + push_cast + ring + +theorem scalarKernelAdjustedAccuracy_inv_le_exp (I J : Type*) [Fintype I] [Fintype J] + (M D : ℕ) {R η : ℝ} (hη : 0 < η) (hM : (M : ℝ) ≤ Real.exp R) + (hD : (D : ℝ) ≤ Real.exp R) (hηR : η⁻¹ ≤ Real.exp R) : + (scalarKernelAdjustedAccuracy I J M D η)⁻¹ ≤ Real.exp ((Fintype.card J : ℝ) * + (Fintype.card I + 1 : ℝ) * (4 + (Fintype.card I + 1 : ℝ) + 2 * R) + R) := by + rw [scalarKernelAdjustedAccuracy, inv_div, div_eq_mul_inv, Real.exp_add] + exact mul_le_mul (scalarKernelConditioningConstant_le_exp I J M D hM hD) hηR + (inv_nonneg.mpr hη.le) (Real.exp_pos _).le + +theorem scalarKernelMinorConstant_le_exp (I J : Type*) [Fintype I] [Nonempty I] [Fintype J] (N : ℕ) : + (integerScalarCubeDensityCap I) ^ Fintype.card J * multivariateSublevelConstant N (Fintype.card I) ≤ + Real.exp ((Fintype.card J : ℝ) * ((Fintype.card I + 1 : ℝ) * (4 + (Fintype.card I + 1 : ℝ))) + + 3 * (N : ℝ) + (Fintype.card I + 1 : ℝ) + Fintype.card I * (8 + (Fintype.card I + 1 : ℝ))) := by + have hA := integerScalarCubeDensityCap_le_exp I + have hA0 := (integerScalarCubeDensityCap_pos I).le + have hC := multivariateSublevelConstant_le_exp N (Fintype.card I) Fintype.card_pos + have hC0 : 0 ≤ multivariateSublevelConstant N (Fintype.card I) := by + unfold multivariateSublevelConstant + exact mul_nonneg (by positivity) (univariateSublevelConstant_pos _).le + calc + _ ≤ Real.exp ((Fintype.card I + 1 : ℝ) * (4 + (Fintype.card I + 1 : ℝ))) ^ Fintype.card J * + Real.exp (3 * (N : ℝ) + (Fintype.card I + 1 : ℝ) + Fintype.card I * (8 + (Fintype.card I + 1 : ℝ))) := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add]; congr 1; ring + +theorem scalarKernelMinorScale_le_exp (I : Type*) [Fintype I] (N : ℕ) : + (Fintype.card I + 1 : ℝ) ^ N ≤ Real.exp ((N : ℝ) * (Fintype.card I + 1 : ℝ)) := by + have hn : (Fintype.card I + 1 : ℝ) ≤ Real.exp (Fintype.card I + 1 : ℝ) := by + linarith [Real.add_one_le_exp (Fintype.card I + 1 : ℝ)] + calc + _ ≤ Real.exp (Fintype.card I + 1 : ℝ) ^ N := by gcongr + _ = _ := (Real.exp_nat_mul _ _).symm + + +noncomputable def scalarKernelInputBudget (I J : Type*) [Fintype I] [Fintype J] (R : ℝ) : ℝ := + 16 * (10 + (Fintype.card I : ℝ) + Fintype.card J + Fintype.card (J × Option I) + R)^3 + +theorem scalarKernelInputBudget_bounds (I J : Type*) + [Fintype I] [Nonempty I] [Fintype J] (M D : ℕ) {R η : ℝ} + (hR : 0 ≤ R) (hη : 0 < η) (hM : (M : ℝ) ≤ Real.exp R) + (hD : (D : ℝ) ≤ Real.exp R) (hηR : η⁻¹ ≤ Real.exp R) : + 1 ≤ scalarKernelInputBudget I J R ∧ + (Fintype.card I + 1 : ℝ) ≤ Real.exp (scalarKernelInputBudget I J R) ∧ + (D * ((Fintype.card I + 1) * M) : ℕ) ≤ Real.exp (scalarKernelInputBudget I J R) ∧ + coordinateDeterminantVariation I (Fin (Fintype.card (J × Option I))) ≤ Real.exp (scalarKernelInputBudget I J R) ∧ + scalarKernelTailConstant I J ≤ Real.exp (scalarKernelInputBudget I J R) ∧ + (scalarKernelAdjustedAccuracy I J M D η)⁻¹ ≤ Real.exp (scalarKernelInputBudget I J R) ∧ + (integerScalarCubeDensityCap I)^Fintype.card J * + multivariateSublevelConstant (Fintype.card (J × Option I)) (Fintype.card I) ≤ + Real.exp (scalarKernelInputBudget I J R) ∧ + (Fintype.card I + 1 : ℝ)^Fintype.card (J × Option I) ≤ Real.exp (scalarKernelInputBudget I J R) := by + let Q : ℝ := 10 + (Fintype.card I : ℝ) + Fintype.card J + Fintype.card (J × Option I) + R + have hq0 : (0 : ℝ) ≤ Fintype.card I := Nat.cast_nonneg _ + have hj0 : (0 : ℝ) ≤ Fintype.card J := Nat.cast_nonneg _ + have hN0 : (0 : ℝ) ≤ Fintype.card (J × Option I) := Nat.cast_nonneg _ + obtain ⟨hP, hn, hb, hK, hT, hε, hC, hS⟩ := scalarKernel_polynomial_envelope (Q := Q) + hq0 hj0 hN0 hR (by dsimp [Q]; linarith) (by dsimp [Q]; linarith) + (by dsimp [Q]; linarith) (by dsimp [Q]; linarith) (by dsimp [Q]; linarith) + have hPE : 16 * Q^3 ≤ Real.exp (16 * Q^3) := by linarith [Real.add_one_le_exp (16 * Q^3)] + have hnE : (Fintype.card I + 1 : ℝ) ≤ Real.exp (Fintype.card I + 1 : ℝ) := by + linarith [Real.add_one_le_exp (Fintype.card I + 1 : ℝ)] + have hbE : ((D * ((Fintype.card I + 1) * M) : ℕ) : ℝ) ≤ + Real.exp (2 * R + (Fintype.card I + 1 : ℝ)) := by + push_cast + calc + _ ≤ Real.exp R * (Real.exp (Fintype.card I + 1 : ℝ) * Real.exp R) := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + refine ⟨hP, hn.trans hPE, hbE.trans (Real.exp_le_exp.mpr hb), ?_, ?_, ?_, ?_, ?_⟩ + · exact (coordinateDeterminantVariation_le_exp I _).trans (Real.exp_le_exp.mpr hK) + · exact (scalarKernelTailConstant_le_exp I J).trans (Real.exp_le_exp.mpr hT) + · exact (scalarKernelAdjustedAccuracy_inv_le_exp I J M D hη hM hD hηR).trans (Real.exp_le_exp.mpr hε) + · exact (scalarKernelMinorConstant_le_exp I J _).trans (Real.exp_le_exp.mpr hC) + · exact (scalarKernelMinorScale_le_exp I _).trans (Real.exp_le_exp.mpr hS) + + +noncomputable def scalarKernelLogarithmicBudget (I J : Type*) [Fintype I] [Fintype J] (R : ℝ) : ℝ := + scalarKernelCutoffLogBudget I J (scalarKernelInputBudget I J R) + +theorem scalarKernelCutoff_le_exp (I J : Type*) [Fintype I] [Nonempty I] [Fintype J] + {M D : ℕ} {R η : ℝ} (hM : 0 < M) (hD : 0 < D) (hη : 0 < η) (hR : 0 ≤ R) + (hMR : (M : ℝ) ≤ Real.exp R) (hDR : (D : ℝ) ≤ Real.exp R) (hηR : η⁻¹ ≤ Real.exp R) : + (scalarKernelCutoff I J M D η : ℝ) ≤ Real.exp (scalarKernelLogarithmicBudget I J R) := by + obtain ⟨hP, hn, hb, hK, hT, hε, hC, hS⟩ := scalarKernelInputBudget_bounds I J M D hR hη hMR hDR hηR + exact scalarKernelCutoff_le_exp_of_bounds I J hM hD hη hP hn hb hK hT hε hC hS + +theorem scalarKernelLogarithmicBudget_eq (I J : Type*) [Fintype I] [Fintype J] (R : ℝ) : + scalarKernelLogarithmicBudget I J R = + 2 * ((4 + 3 * ((Fintype.card J : ℝ) * (Fintype.card I + 1) * Fintype.card I)) * + (16 * (10 + (Fintype.card I : ℝ) + Fintype.card J + Fintype.card J * (Fintype.card I + 1) + R)^3 + 2)) + 8 := by + simp only [scalarKernelLogarithmicBudget, scalarKernelCutoffLogBudget, scalarKernelInputBudget, + Fintype.card_prod, Fintype.card_option, Nat.cast_mul, Nat.cast_add, Nat.cast_one] + +end Erdos3 + + +namespace Erdos3.VectorPolynomial + +noncomputable def allocatedKernelPrimitiveBudget {A : Type*} [Semiring A] + (p E T : A) : A := + let r := p + E + T + 1 + r + 2 * ((4 + 3 * (r * (r + 1) * r)) * + (16 * (10 + r + r + r * (r + 1) + r)^3 + 2)) + 8 + +theorem allocatedKernelPrimitiveBudget_bounds {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) : + let Q := allocatedKernelPrimitiveBudget p E T + 0 ≤ Q ∧ p ≤ Q ∧ E ≤ Q ∧ T ≤ Q ∧ p + E + T + 1 ≤ Q := by + have hr : 0 ≤ p + E + T + 1 := by positivity + have hrest : 0 ≤ 2 * ((4 + 3 * ((p + E + T + 1) * (p + E + T + 1 + 1) * + (p + E + T + 1))) * (16 * (10 + (p + E + T + 1) + (p + E + T + 1) + + (p + E + T + 1) * (p + E + T + 1 + 1) + (p + E + T + 1))^3 + 2)) := by positivity + dsimp only [allocatedKernelPrimitiveBudget] + constructor + · linarith + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +theorem allocatedKernelPrimitiveBudget_mono {p E T p' E' T' : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) + (hpp : p ≤ p') (hEE : E ≤ E') (hTT : T ≤ T') : + allocatedKernelPrimitiveBudget p E T ≤ allocatedKernelPrimitiveBudget p' E' T' := by + have hr : 0 ≤ p + E + T + 1 := by positivity + have hrr : p + E + T + 1 ≤ p' + E' + T' + 1 := by linarith + have hr' : 0 ≤ p' + E' + T' + 1 := hr.trans hrr + dsimp only [allocatedKernelPrimitiveBudget] + gcongr + +theorem scalarKernelLogarithmicBudget_le_allocatedPrimitive + (I G : Type*) [Fintype I] [Fintype G] {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) + (hI : (Fintype.card I : ℝ) ≤ p) (hG : (Fintype.card G : ℝ) ≤ p) : + scalarKernelLogarithmicBudget I G (p + E + T + 1) ≤ allocatedKernelPrimitiveBudget p E T := by + let r := p + E + T + 1 + have hr : 0 ≤ r := by dsimp [r]; positivity + have hIr : (Fintype.card I : ℝ) ≤ r := by dsimp [r]; linarith + have hGr : (Fintype.card G : ℝ) ≤ r := by dsimp [r]; linarith + rw [scalarKernelLogarithmicBudget_eq] + change 2 * ((4 + 3 * ((Fintype.card G : ℝ) * (Fintype.card I + 1) * Fintype.card I)) * + (16 * (10 + (Fintype.card I : ℝ) + Fintype.card G + Fintype.card G * (Fintype.card I + 1) + r)^3 + 2)) + 8 ≤ _ + have hcore : 2 * ((4 + 3 * ((Fintype.card G : ℝ) * (Fintype.card I + 1) * Fintype.card I)) * + (16 * (10 + (Fintype.card I : ℝ) + Fintype.card G + Fintype.card G * (Fintype.card I + 1) + r)^3 + 2)) ≤ + 2 * ((4 + 3 * (r * (r + 1) * r)) * (16 * (10 + r + r + r * (r + 1) + r)^3 + 2)) := by + gcongr + dsimp only [allocatedKernelPrimitiveBudget] + change _ ≤ r + 2 * ((4 + 3 * (r * (r + 1) * r)) * + (16 * (10 + r + r + r * (r + 1) + r)^3 + 2)) + 8 + linarith + +theorem exists_allocatedKernelThreshold_bound (A : ℕ) : + ∃ a : ℕ, 2 ≤ a ∧ ∀ {p E T : ℝ}, 0 ≤ p → 0 ≤ E → 0 ≤ T → + (allocatedKernelPrimitiveBudget p E T + (E + 1) + (T + 1) + A)^A ≤ + (p + E + T + a)^a := by + let poly : Polynomial ℕ := + (allocatedKernelPrimitiveBudget Polynomial.X Polynomial.X Polynomial.X + + (Polynomial.X + 1) + (Polynomial.X + 1) + (A : Polynomial ℕ))^A + obtain ⟨a, ha, hbound⟩ := exists_natPolynomial_eval_budget poly + refine ⟨a, ha, ?_⟩ + intro p E T hp hE hT + have hpq : p ≤ p + E + T := by linarith + have hEq : E ≤ p + E + T := by linarith + have hTq : T ≤ p + E + T := by linarith + have hQ := allocatedKernelPrimitiveBudget_mono hp hE hT hpq hEq hTq + have hbase : allocatedKernelPrimitiveBudget p E T + (E + 1) + (T + 1) + A ≤ + allocatedKernelPrimitiveBudget (p + E + T) (p + E + T) (p + E + T) + + (p + E + T + 1) + (p + E + T + 1) + A := by linarith + have hnonneg := (allocatedKernelPrimitiveBudget_bounds hp hE hT).1 + apply (pow_le_pow_left₀ (by positivity) hbase A).trans + simpa [poly, allocatedKernelPrimitiveBudget, Polynomial.eval₂_pow] using + hbound (p + E + T) (by positivity) + +end Erdos3.VectorPolynomial + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelReplacementWithCutoff.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelReplacementWithCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..0898cdd7442f77c169921b0fa961bd580d835004 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelReplacementWithCutoff.lean @@ -0,0 +1,232 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedFixedKernelReplacement + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +noncomputable def allocatedKernelLogWithCutoff (d : ℕ) (G α : Type*) [Fintype G] [Fintype α] + {m : ℕ} (O : Fin m → Type*) [∀ j, Fintype (O j)] (P : ℝ) : ℝ := + P + ((max m d)*2^((max m d)+1) : ℕ)*P + (Fintype.card α : ℝ)*(m+1) + + ∑ j, kernelInverseLog (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) P + +theorem allocatedKernelLogWithCutoff_bounds (d : ℕ) (G α : Type*) [Fintype G] [Fintype α] + {m : ℕ} (O : Fin m → Type*) [∀ j, Fintype (O j)] {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ allocatedKernelLogWithCutoff d G α O P ∧ P ≤ allocatedKernelLogWithCutoff d G α O P ∧ + ((max m d)*2^((max m d)+1) : ℕ)*P ≤ allocatedKernelLogWithCutoff d G α O P ∧ + (Fintype.card α : ℝ)*(m+1) ≤ allocatedKernelLogWithCutoff d G α O P ∧ + ∀ j, kernelInverseLog (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) P ≤ + allocatedKernelLogWithCutoff d G α O P := by + have hi (j : Fin m) : 0 ≤ kernelInverseLog + (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) P := by + unfold kernelInverseLog + positivity + have hs := Finset.sum_nonneg (fun j (_ : j ∈ (Finset.univ : Finset (Fin m))) => hi j) + have hidx : 0 ≤ ((max m d)*2^((max m d)+1) : ℕ)*(P : ℝ) := by positivity + have hentry : 0 ≤ (Fintype.card α : ℝ)*(m+1) := by positivity + unfold allocatedKernelLogWithCutoff + refine ⟨by positivity, by linarith, by linarith, by linarith, ?_⟩ + intro j + have hj := Finset.single_le_sum (fun k _ => hi k) (Finset.mem_univ j) + linarith + +theorem allocatedKernelLogWithCutoff_allowances (d : ℕ) (G α : Type*) [Fintype G] [Fintype α] + {m : ℕ} (O : Fin m → Type*) [∀ j, Fintype (O j)] {P : ℝ} {M : ℕ} + (hP : 0 ≤ P) (hM : 0 < M) (hMP : (M : ℝ) ≤ Real.exp P) : + (layerKernelIndexBound (max m d) M : ℝ) ≤ Real.exp (allocatedKernelLogWithCutoff d G α O P) ∧ + ∀ j, kernelJetEntryAllowance (Fintype.card α) (j.val+1) ≤ Real.exp (allocatedKernelLogWithCutoff d G α O P) ∧ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card G) (Fintype.card (O j)) (j.val+1) + (1/(M : ℝ)) ≤ Real.exp (allocatedKernelLogWithCutoff d G α O P) := by + have hb := allocatedKernelLogWithCutoff_bounds d G α O hP + refine ⟨(layerKernelIndexBound_le_exp (max m d) hMP).trans (Real.exp_le_exp.mpr hb.2.2.1), ?_⟩ + intro j + constructor + · apply (kernelJetEntryAllowance_le_exp (Fintype.card α) (j.val+1)).trans + apply Real.exp_le_exp.mpr + apply le_trans _ hb.2.2.2.1 + gcongr + exact_mod_cast Nat.succ_le_of_lt j.isLt + · have hκ : 0 < 1/(M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + have hv := kernelJetInverseAllowance_le_exp (Fintype.card α) (Fintype.card G) + (Fintype.card (O j)) (j.val+1) hκ hP (by simpa only [one_div, inv_inv] using hMP) + exact hv.trans (Real.exp_le_exp.mpr (hb.2.2.2.2 j)) + +namespace VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +noncomputable def allocatedKernelReplacementLogWithCutoff (d : ℕ) (α : Type*) [Fintype α] + (O : Fin m → Type*) [∀ j, Fintype (O j)] (P e : ℝ) : ℝ := + ∑ j, coefficientFrontLog (Fintype.card (O j)) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) + (allocatedKernelLogWithCutoff d G α O P) (4*(P+8)) e + +theorem allocatedKernelReplacementLogWithCutoff_front_le (d : ℕ) (α : Type*) [Fintype α] + (O : Fin m → Type*) [∀ j, Fintype (O j)] {P e : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (j : Fin m) : + coefficientFrontLog (Fintype.card (O j)) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) + (allocatedKernelLogWithCutoff d G α O P) (4*(P+8)) e ≤ allocatedKernelReplacementLogWithCutoff (G := G) B d α O P e := by + apply Finset.single_le_sum _ (Finset.mem_univ j) + intro k _ + exact coefficientFrontLog_nonneg _ _ (allocatedKernelLogWithCutoff_bounds d G α O hP).1 (by positivity) he + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable [DecidableEq G] [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +theorem allocatedFixedKernel_replacement_withCutoff (d : ℕ) + (hcutoff : AllocatedTailCutoffCompatible U basis S.value d) {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ d+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLogWithCutoff (G := G) B d α O P e) ≤ S.value) + (modulus : ℕ) + (hperiod : ∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) + (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) + (hi : ∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) : + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (p : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides)) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + (∀ v, p.weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) → + ∀ j i (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i), + (∀ z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ≤ layerKernelIndexBound (max m d) M) ∧ + ∀ v, p.weight v ≠ 0 → ∀ z, + |(basisAxisScale (basis j) i : ℝ)^Fintype.card (O j) * + (allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i (hσ1 j) henormous z).toReal - + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z * + allocatedIntegerKernelDensity B U basis S j i x u (rows j) (s j) (hA j) + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (fun o => (z o : ℝ)/(basisAxisScale (basis j) i : ℝ))| ≤ ε := by + have hκ : 0 < 1/(M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + have hcontrol := allocatedFixedKernel_controls_withCutoff B U basis S x rows d selection hx hq hinj hrows s hA hi + intro u p residue hr j i henormous + have hb := allocatedKernelLogWithCutoff_bounds d G α O hP + have ha := allocatedKernelLogWithCutoff_allowances d G α O hP hM hMP + have ht : 0 ≤ 4*(P+8) := by positivity + have hf := (Real.exp_le_exp.mpr (allocatedKernelReplacementLogWithCutoff_front_le (G := G) B d α O hP he j)).trans hlarge + exact allocatedIntegerKernel_residue_family B U basis hR hσ S x u rows j i (s j) (hA j) (hσ1 j) + henormous p modulus (residue j) (hperiod j) (fun v hv => hr v hv j) + (kernelJetEntryAllowance_pos _ _).le (kernelJetInverseAllowance_nonneg _ _ _ _ hκ) + (Nat.cast_nonneg _) (fun v _ => hcontrol u v j i) + hb.1 ht hε ha.1 (ha.2 j).2 (ha.2 j).1 ((hRP j).trans (Real.exp_le_exp.mpr hb.2.1)) + (allocatedUnitProfileWidth_inverse_exp _ hP (hR j) (hσ j) (hRi j) (hσi j) (hcount j)) + (allocatedInteger_replacementScale_le_withCutoff B U basis S d j i (rows j) (hinj j) hq (s j) + hb.1 ht he hε hεe hf (hcutoff j i henormous)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable [DecidableEq G] [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +theorem allocatedGoodKernel_replacement_withCutoff (d : ℕ) + (hcutoff : AllocatedTailCutoffCompatible U basis S.value d) {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ d+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLogWithCutoff (G := G) B d α O P e) ≤ S.value) : + ∃ (modulus : ℕ) (_hm : 0 < modulus), modulus ≤ M^(m+1) ∧ + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ α) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) ∧ + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (p : FiniteProbabilityWeights (PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides)) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + (∀ v, p.weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) → + ∀ j i (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i), + (∀ z, 0 ≤ allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z ≤ layerKernelIndexBound (max m d) M) ∧ + ∀ v, p.weight v ≠ 0 → ∀ z, + |(basisAxisScale (basis j) i : ℝ)^Fintype.card (O j) * + (allocatedIntegerKernelPMF B U basis hR hσ S x u v rows j i (hσ1 j) henormous z).toReal - + allocatedIntegerKernelMask B U basis S x rows j modulus (residue j) z * + allocatedIntegerKernelDensity B U basis S j i x u (rows j) (s j) (hA j) + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (fun o => (z o : ℝ)/(basisAxisScale (basis j) i : ℝ))| ≤ ε := by + have hκ : 0 < 1/(M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + obtain ⟨modulus, hm, hmB, hspatial, hperiod⟩ := goodKernel_common_period selection x hx (m+1) + (Nat.succ_le_succ (Nat.zero_le m)) (fun j : Fin m => j.val+1) + (fun j => (Nat.succ_le_of_lt j.isLt).trans (Nat.le_succ _)) rows hinj hrows + obtain ⟨s, hA, hi, _⟩ := allocatedGoodKernel_controls_withCutoff B U basis S x rows d + selection hκ hx hq hinj hrows + exact ⟨modulus, hm, hmB, hspatial, hperiod, s, hA, hi, + allocatedFixedKernel_replacement_withCutoff B U basis hR hσ S x rows d hcutoff hM + selection hx hq hinj hrows hσ1 hP he hε hMP hRP hRi hσi hcount hεe hlarge + modulus hperiod s hA hi⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelRootBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelRootBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..b617543ffae038b842f8b43d98c93e5b59cc1aa8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelRootBudget.lean @@ -0,0 +1,35 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedTrimmedVectorSite + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +theorem allocatedKernelRoot_le_budget (x : G → IntegerScalarCubeBox Empty S.value) (g : G) : + |((x g none : ℤ) : ℝ)| ≤ allocatedPhysicalRootBudget B U basis S (fun _ => 0) := by + let y : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty + (allocatedPrincipalSides B U basis S) := + fun j => integerScalarCubeBoxZero Empty (allocatedPrincipalSides B U basis S j) + (allocatedPrincipalSides_pos B U basis S j) + simpa only [allocatedPhysicalCubeRoot, Sum.elim_inl, zero_add] using + allocatedPhysicalCube_root_budget B U basis S (fun _ => 0) x y (.inl g) + +theorem allocatedKernelRoot_budget (x : G → IntegerScalarCubeBox Empty S.value) (g : G) : + |((x g none : ℤ) : ℝ)| ≤ 1 + allocatedPhysicalRootBudget B U basis S (fun _ => 0) := by + have hb := allocatedKernelRoot_le_budget B U basis S x g + linarith + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelScaleWithCutoff.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelScaleWithCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..26240f983cc09d40f594348ad0080700bde47356 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelScaleWithCutoff.lean @@ -0,0 +1,785 @@ +import OAI.Combinatorics.Progressions.Dynamics.CoefficientFrontBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedEnormousProfiles +import OAI.Combinatorics.Progressions.Lattices.AffineCoefficientReindex +import OAI.Combinatorics.Progressions.Lattices.JointAffineUnitSource + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix + +noncomputable def kernelExponentEmbedding (G X : Type*) (h : ℕ) : + BoundedIntegerExponent G h ↪ BoundedCoefficientExponent (G ⊕ X) h where + toFun d := ⟨d.val.embDomain Function.Embedding.inl, by + change (d.val.embDomain Function.Embedding.inl).sum (fun _ n => n) ≤ h + rw [Finsupp.sum_embDomain] + exact d.property⟩ + inj' := by + intro d e hde + exact Subtype.ext ((Finsupp.embDomain_injective Function.Embedding.inl) (congrArg Subtype.val hde)) + +abbrev NonkernelCoefficient (G X : Type*) (h : ℕ) := + UnselectedColumn (kernelExponentEmbedding G X h) + +noncomputable def kernelCoefficientEquiv (G X : Type*) [Fintype G] (h : ℕ) : + BoundedIntegerExponent G h ⊕ NonkernelCoefficient G X h ≃ BoundedCoefficientExponent (G ⊕ X) h := + selectedColumnEquiv (kernelExponentEmbedding G X h) + +theorem kernelCoefficientEquiv_inl (G X : Type*) [Fintype G] (h : ℕ) (d : BoundedIntegerExponent G h) : + kernelCoefficientEquiv G X h (.inl d) = kernelExponentEmbedding G X h d := rfl + +theorem kernelCoefficientEquiv_inr (G X : Type*) [Fintype G] (h : ℕ) (d : NonkernelCoefficient G X h) : + kernelCoefficientEquiv G X h (.inr d) = d.val := rfl + +theorem monomialScale_kernelExponent {G X : Type*} {h : ℕ} (T : G ⊕ X → ℝ) + (d : BoundedIntegerExponent G h) : + monomialScale T (kernelExponentEmbedding G X h d).val = + monomialScale (fun g => T (.inl g)) d.val := + Finsupp.prod_embDomain + +theorem kernelExponent_eval_monomial {G X : Type*} {h : ℕ} (x : G ⊕ X → ℤ) + (d : BoundedIntegerExponent G h) : + MvPolynomial.eval x (MvPolynomial.monomial (kernelExponentEmbedding G X h d).val 1) = + MvPolynomial.eval (fun g => x (.inl g)) (MvPolynomial.monomial d.val 1) := by + change MvPolynomial.eval x (MvPolynomial.monomial (d.val.embDomain Function.Embedding.inl) 1) = _ + simp only [MvPolynomial.eval_monomial, Finsupp.prod_embDomain] + rfl + +theorem integerMappedCubeTuple_kernel {G X Z Y α : Type*} + (input : G ⊕ X → Option α → Z ⊕ Y) (z : Z → ℤ) (y : Y → ℤ) + {L : ℕ} (x : G → IntegerScalarCubeBox α L) + (hfixed : ∀ g a, Sum.elim z y (input (.inl g) a) = (x g a : ℤ)) (t : Finset α) : + (fun g => integerMappedCubeTuple input z y t (.inl g)) = + integerAffineCube (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) t := by + funext g + simp only [integerMappedCubeTuple, integerAffineCube, hfixed, scalarCubeDifferenceMatrix, sampledColumnMatrix] + +theorem integerMappedJetMatrix_kernel {G X Z Y α O : Type*} [Fintype G] [DecidableEq α] + (h : ℕ) (input : G ⊕ X → Option α → Z ⊕ Y) (z : Z → ℤ) (y : Y → ℤ) + {L : ℕ} (x : G → IntegerScalarCubeBox α L) + (hfixed : ∀ g a, Sum.elim z y (input (.inl g) a) = (x g a : ℤ)) (rows : O → Finset α) : + (integerMappedJetMatrix (fun d : BoundedCoefficientExponent (G ⊕ X) h => d.val) + input z rows y).submatrix id (kernelExponentEmbedding G X h) = scalarKernelIntegerJet x h rows := by + ext o d + change booleanCoefficient (fun t => MvPolynomial.eval (integerMappedCubeTuple input z y t) + (MvPolynomial.monomial (kernelExponentEmbedding G X h d).val 1)) (rows o) = + booleanCoefficient (fun t => MvPolynomial.eval + (integerAffineCube (fun g => (x g none : ℤ)) (scalarCubeDifferenceMatrix x) t) + (MvPolynomial.monomial d.val 1)) (rows o) + apply congrArg (fun f : Finset α → ℤ => booleanCoefficient f (rows o)) + funext t + rw [kernelExponent_eval_monomial, integerMappedCubeTuple_kernel input z y x hfixed t] + +theorem integerMappedJetMatrix_kernel_split {G X Z Y α O : Type*} [Fintype G] [DecidableEq α] + (h : ℕ) (input : G ⊕ X → Option α → Z ⊕ Y) (z : Z → ℤ) (y : Y → ℤ) + {L : ℕ} (x : G → IntegerScalarCubeBox α L) + (hfixed : ∀ g a, Sum.elim z y (input (.inl g) a) = (x g a : ℤ)) (rows : O → Finset α) : + (integerMappedJetMatrix (fun d : BoundedCoefficientExponent (G ⊕ X) h => d.val) + input z rows y).submatrix id (kernelCoefficientEquiv G X h) = + Matrix.fromCols (scalarKernelIntegerJet x h rows) + (integerMappedJetMatrix (fun d : NonkernelCoefficient G X h => d.val.val) input z rows y) := by + ext o d + cases d with + | inl d => exact congrFun (congrFun (integerMappedJetMatrix_kernel h input z y x hfixed rows) o) d + | inr d => rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +theorem normalizedIntegerColumns_eq_of_instances {I J : Type*} + [Fintype I] [instI : DecidableEq I] [Fintype J] [instJ : DecidableEq J] + {dI : DecidableEq I} {dJ : DecidableEq J} + {M : Matrix I J ℤ} {T : J → ℝ} {P : I → ℝ} {A : Matrix I J ℝ} + (h : @normalizedIntegerColumns I J ‹Fintype I› dI ‹Fintype J› dJ M T P = A) : + @normalizedIntegerColumns I J ‹Fintype I› instI ‹Fintype J› instJ M T P = A := by + have hi : dI = instI := Subsingleton.elim _ _ + have hj : dJ = instJ := Subsingleton.elim _ _ + cases hi + cases hj + exact h + +theorem kernelExponent_eval_real {G X : Type*} {h : ℕ} (x : G ⊕ X → ℝ) + (d : BoundedIntegerExponent G h) : + MvPolynomial.eval x (MvPolynomial.monomial (kernelExponentEmbedding G X h d).val 1) = + MvPolynomial.eval (fun g => x (.inl g)) (MvPolynomial.monomial d.val 1) := by + change MvPolynomial.eval x (MvPolynomial.monomial (d.val.embDomain Function.Embedding.inl) 1) = _ + simp only [MvPolynomial.eval_monomial, Finsupp.prod_embDomain] + rfl + +theorem normalizedMappedKernelJet_eq {G X Z Y α O : Type*} + [Fintype G] [Fintype α] [DecidableEq α] [Fintype O] [DecidableEq O] + (h : ℕ) (input : G ⊕ X → Option α → Z ⊕ Y) (z : Z → ℝ) (y : Y → ℝ) + {L : ℕ} (x : G → IntegerScalarCubeBox α L) + (hfixed : ∀ g a, Sum.elim z y (input (.inl g) a) = (x g a : ℝ) / L) + (rows : O → Finset α) {H : ℝ} (hH : H ≠ 0) : + normalizedIntegerColumns (scalarKernelIntegerJet x h rows) + (kernelJetCoefficientScale G h L H) (fun _ => H) = + realJetMatrix (fun d => MvPolynomial.monomial (kernelExponentEmbedding G X h d).val 1) + (normalizedCubeTuple input z y) rows := by + have hc (t : Finset α) : (fun g => normalizedCubeTuple input z y t (.inl g)) = + realAffineCube (fun g => (x g none : ℝ) / L) + (fun a g => (x g (some a) : ℝ) / L) t := by + funext g + simp only [normalizedCubeTuple, hfixed, Fintype.sum_option, booleanFeature, + one_mul, ite_mul, zero_mul, Finset.sum_ite_mem, Finset.univ_inter, realAffineCube] + apply (normalizedScalarKernelJet_eq x h rows hH).trans + funext o d + change booleanCoefficient (fun t => MvPolynomial.eval + (realAffineCube (fun g => (x g none : ℝ) / L) (fun a g => (x g (some a) : ℝ) / L) t) + (MvPolynomial.monomial d.val 1)) (rows o) = _ + apply congrArg (fun f : Finset α → ℝ => booleanCoefficient f (rows o)) + funext t + rw [kernelExponent_eval_real, hc] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped Matrix NNReal + +theorem normalizedJoinedMatrix_affineJetUnitMap {Z X K α O J N : Type*} + [Fintype α] [DecidableEq α] [Fintype O] [DecidableEq O] + [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (A : Matrix O J ℤ) (C : Matrix O N ℤ) (s : O ↪ J) (hA : (A.submatrix id s).det ≠ 0) + (S : J → ℝ) (T : N → ℝ) (hS : ∀ j, 0 < S j) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : O → Finset α) (x : X → ℝ) + (hC : matrixSupCLM (normalizedIntegerColumns C T (fun _ => 1)) = + polynomialColumns (fun o n => normalizedJetColumn (e n) input z (rows o)) x) + (c w r : J ⊕ N → ℝ) : + normalizedIntegerColumns (Matrix.fromCols A C) (Sum.elim S T) (fun _ => 1) *ᵥ + (fun j => c j+w j*r j) = + affineJetUnitMap s + (normalizedPivotEquiv (A.submatrix id s) hA (fun j => S (s j)) (fun _ => 1) + (fun j => hS (s j)) (fun _ => zero_lt_one)) + (matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns A s) + (fun j => S j.val) (fun _ => 1))) e input z rows c w x r := by + let v : J ⊕ N → ℝ := fun j => c j+w j*r j + have hv : selectedSplitCoefficients s ((selectedSplitMeasurableEquiv s).symm v) = v := + (selectedSplitMeasurableEquiv s).apply_symm_apply v + have hm := selectedSplitCoefficients_normalized_matrix A C s hA S T (fun _ => 1) hS + (fun _ => zero_lt_one) ((selectedSplitMeasurableEquiv s).symm v) + rw [hv, hC] at hm + simpa only [v, selectedSplitMeasurableEquiv_symm_apply, splitFreeColumns_apply, + Sum.elim_inl, Sum.elim_inr, affineJetUnitMap, add_assoc] using hm + +theorem normalizedJoinedMatrix_affineDensity_law {Z X K α O J N : Type*} + [Fintype α] [DecidableEq α] [Fintype O] [DecidableEq O] + [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (A : Matrix O J ℤ) (C : Matrix O N ℤ) (s : O ↪ J) (hA : (A.submatrix id s).det ≠ 0) + (S : J → ℝ) (T : N → ℝ) (hS : ∀ j, 0 < S j) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : O → Finset α) (x : X → ℝ) + (hC : matrixSupCLM (normalizedIntegerColumns C T (fun _ => 1)) = + polynomialColumns (fun o n => normalizedJetColumn (e n) input z (rows o)) x) + (c w : J ⊕ N → ℝ) (hw : ∀ j, 0 < w j) (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) : + (unitCoefficientSource (J ⊕ N)).map (fun r => + normalizedIntegerColumns (Matrix.fromCols A C) (Sum.elim S T) (fun _ => 1) *ᵥ + (fun j => c j+w j*r j)) = + realDensityMeasure volume + (affineSelectedJetDensity s + (normalizedPivotEquiv (A.submatrix id s) hA (fun j => S (s j)) (fun _ => 1) + (fun j => hS (s j)) (fun _ => zero_lt_one)) + (matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns A s) + (fun j => S j.val) (fun _ => 1))) e input z rows c w x) := by + simp_rw [normalizedJoinedMatrix_affineJetUnitMap A C s hA S T hS e input z rows x hC] + exact affineSelectedJetDensity_unit_law s _ _ e input z rows c w hw R hsupport x + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped Matrix + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +abbrev AllocatedNonkernelCoefficient (j : Fin m) := + NonkernelCoefficient G (PrincipalTupleIndex B (layerSamplerDegree I n)) (j.val+1) + +noncomputable def allocatedKernelCoefficientEquiv (j : Fin m) : + BoundedIntegerExponent G (j.val+1) ⊕ AllocatedNonkernelCoefficient (G := G) B j ≃ + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) := + kernelCoefficientEquiv G (PrincipalTupleIndex B (layerSamplerDegree I n)) (j.val+1) + +def allocatedNonkernelExponent (j : Fin m) (d : AllocatedNonkernelCoefficient (G := G) B j) : + LayerSamplerVariables G I n B →₀ ℕ := d.val.val + +omit [Fintype G] [∀ j, Fintype (I j)] [∀ a, Fintype (B a)] in +theorem allocatedNonkernelExponent_degree (j : Fin m) (d : AllocatedNonkernelCoefficient (G := G) B j) : + (allocatedNonkernelExponent B j d).sum (fun _ r => r) ≤ j.val+1 := d.val.property + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +theorem allocatedKernelCoefficientScale (j : Fin m) (i : Fin (n j)) + (d : BoundedIntegerExponent G (j.val+1)) : + allocatedIntegerProfileScales B U basis S j i (allocatedKernelCoefficientEquiv B j (.inl d)) = + kernelJetCoefficientScale G (j.val+1) S.value (basisAxisScale (basis j) i) d := by + change (basisAxisScale (basis j) i : ℝ) / + monomialScale (layerSamplerBox B U basis S) + (kernelExponentEmbedding G (PrincipalTupleIndex B (layerSamplerDegree I n)) (j.val+1) d).val = _ + rw [monomialScale_kernelExponent] + rfl + +theorem allocatedKernelCoefficientScales_split (j : Fin m) (i : Fin (n j)) : + allocatedIntegerProfileScales B U basis S j i ∘ allocatedKernelCoefficientEquiv B j = + Sum.elim (kernelJetCoefficientScale G (j.val+1) S.value (basisAxisScale (basis j) i)) + (fun d => (basisAxisScale (basis j) i : ℝ) / + monomialScale (layerSamplerBox B U basis S) (allocatedNonkernelExponent B j d)) := by + funext d + cases d with + | inl d => exact allocatedKernelCoefficientScale B U basis S j i d + | inr d => rfl + +variable (j : Fin m) (i : Fin (n j)) (hσ1 : σ j ≤ 1) +variable (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) + +local notation "centers" => allocatedIntegerProfileCenters (G := G) B R j i +local notation "widths" => allocatedIntegerProfileWidths (G := G) B R σ j i +local notation "scales" => allocatedIntegerProfileScales B U basis S j i +local notation "reindex" => allocatedKernelCoefficientEquiv (G := G) B j + +include hR hσ hσ1 in +theorem allocatedKernelProfile_bound (d) : |centers d|+widths d ≤ R j := + (allocatedProfile_term_bound (layerIntegerPrincipalSlots B j i) (constantCoefficientSlot _ _) + (layerIntegerPrincipalSlots_not_constant B j i) (hR j) (hσ j) hσ1 d).trans (by linarith [hR j]) + +include hR hσ hσ1 henormous in +theorem allocatedKernelProfile_sum_pos : + 0 < coefficientWeightSum (affineProductProfile (centers ∘ reindex) (widths ∘ reindex)) (scales ∘ reindex) := by + rw [affineCoefficientWeightSum_reindex] + exact allocatedEnormous_profile_sum_pos B U basis hR hσ S j i hσ1 henormous + +theorem allocatedKernel_image_law {O : Type*} [Fintype O] + (A : Matrix O (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) ℤ) : + (allocatedCoefficientAxisLaw B U basis hR hσ S ⟨j, Sum.inr i⟩).map (fun a => A *ᵥ a) = + (coefficientImagePMF (A.submatrix id reindex) (affineProductProfile (centers ∘ reindex) (widths ∘ reindex)) + (affineProductProfile_nonneg _ _ (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d))) + (scales ∘ reindex) (fun d => allocatedIntegerProfileScales_pos B U basis S j i (reindex d)) + (affineProductProfile_zero_outside _ _ + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) (hR j).le + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d))) + (allocatedKernelProfile_sum_pos B U basis hR hσ S j i hσ1 henormous)).toMeasure := by + rw [allocatedEnormous_image_law B U basis hR hσ S j i hσ1 henormous] + have hlaw := coefficientImagePMF_affine_reindex A reindex centers widths scales + (allocatedIntegerProfileWidths_pos B hR hσ j i) (allocatedIntegerProfileScales_pos B U basis S j i) + (hR j).le (allocatedKernelProfile_bound B hR hσ j i hσ1) + (allocatedEnormous_profile_sum_pos B U basis hR hσ S j i hσ1 henormous) + exact congrArg PMF.toMeasure hlaw.symm + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) + +theorem allocatedKernelJet_split {α O : Type*} [DecidableEq α] + (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) grid → ℤ) + (v : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℤ) + (rows : O → Finset α) : + (integerMappedJetMatrix (fun d : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) => d.val) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) u) rows v).submatrix id reindex = + Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) rows) + (integerMappedJetMatrix (allocatedNonkernelExponent B j) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) u) rows v) := + integerMappedJetMatrix_kernel_split (j.val+1) _ _ _ x (fun _ _ => rfl) rows + +theorem allocatedKernelJet_full_image {α O : Type*} [DecidableEq α] + (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) grid → ℤ) + (v : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℤ) + (rows : O → Finset α) : + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) rows) + (integerMappedJetMatrix (allocatedNonkernelExponent B j) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) u) rows v)).mulVecLin.range = + (integerMappedJetMatrix (fun d : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) => d.val) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) u) rows v).mulVecLin.range := by + rw [← allocatedKernelJet_split B U basis S j x u v rows] + exact integerColumnEquiv_range _ reindex + +theorem allocatedKernelJet_image_law {α O : Type*} [DecidableEq α] [Fintype O] + (x : G → IntegerScalarCubeBox α S.value) + (u : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) grid → ℤ) + (v : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℤ) + (rows : O → Finset α) : + (allocatedCoefficientAxisLaw B U basis hR hσ S ⟨j, Sum.inr i⟩).map + (fun a => integerMappedJetMatrix + (fun d : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) => d.val) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) u) rows v *ᵥ a) = + (coefficientImagePMF + (Matrix.fromCols (scalarKernelIntegerJet x (j.val+1) rows) + (integerMappedJetMatrix (allocatedNonkernelExponent B j) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) u) rows v)) + (affineProductProfile (centers ∘ reindex) (widths ∘ reindex)) + (affineProductProfile_nonneg _ _ (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d))) + (scales ∘ reindex) (fun d => allocatedIntegerProfileScales_pos B U basis S j i (reindex d)) + (affineProductProfile_zero_outside _ _ + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) (hR j).le + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d))) + (allocatedKernelProfile_sum_pos B U basis hR hσ S j i hσ1 henormous)).toMeasure := by + have hlaw := allocatedKernel_image_law B U basis hR hσ S j i hσ1 henormous + (integerMappedJetMatrix + (fun d : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) => d.val) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) u) rows v) + rw [allocatedKernelJet_split B U basis S j x u v rows] at hlaw + exact hlaw + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + +noncomputable def allocatedContinuousProfileCenters (R : Fin m → ℝ) (j : Fin m) (i : I j) : + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) → ℝ := + coefficientProfileCenter (layerContinuousPrincipalSlots B j i) + (principalProfileSize (R j) (layerContinuousPrincipalSlots (G := G) B j i).card) + +noncomputable def allocatedContinuousProfileWidths (R σ : Fin m → ℝ) (j : Fin m) (i : I j) : + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) → ℝ := + coefficientProfileWidth (layerContinuousPrincipalSlots B j i) (constantCoefficientSlot _ _) + (R j/4) (principalProfileSize (R j) (layerContinuousPrincipalSlots (G := G) B j i).card) + (tailProfileSize (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)))) + +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) + +noncomputable def allocatedContinuousProfileScales (j : Fin m) : + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) → ℝ := + fun d => 1 / monomialScale (layerSamplerBox B U basis S) d.val + +theorem allocatedContinuousProfileScales_pos (j : Fin m) (d) : + 0 < allocatedContinuousProfileScales B U basis S j d := + one_div_pos.mpr (monomialScale_pos _ + (fun v => lt_of_lt_of_le zero_lt_one (layerSamplerBox_one_le B U basis S v)) d.val) + +include hR hσ in +theorem allocatedContinuousProfileWidths_pos (j : Fin m) (i : I j) (d) : + 0 < allocatedContinuousProfileWidths (G := G) B R σ j i d := + coefficientProfileWidth_pos _ _ (div_pos (hR j) (by norm_num)) + (principalProfileSize_pos (hR j) _) (tailProfileSize_pos (hR j) (hσ j) _) d + +include hR hσ in +theorem allocatedContinuousProfile_bound (j : Fin m) (i : I j) (hσ1 : σ j ≤ 1) (d) : + |allocatedContinuousProfileCenters (G := G) B R j i d| + + allocatedContinuousProfileWidths B R σ j i d ≤ R j := + (allocatedProfile_term_bound (layerContinuousPrincipalSlots B j i) (constantCoefficientSlot _ _) + (layerContinuousPrincipalSlots_not_constant B j i) (hR j) (hσ j) hσ1 d).trans (by linarith [hR j]) + +theorem allocatedLayerCenters_scale (j : Fin m) (i : I j) (d) : + allocatedLayerCenters B U basis S j i d = + allocatedContinuousProfileScales B U basis S j d * allocatedContinuousProfileCenters B R j i d := by + unfold allocatedLayerCenters allocatedArrayCenters allocatedContinuousProfileScales + allocatedContinuousProfileCenters + ring + +theorem allocatedLayerWidths_scale (j : Fin m) (i : I j) (d) : + allocatedLayerWidths B U basis S j i d = + allocatedContinuousProfileScales B U basis S j d * allocatedContinuousProfileWidths B R σ j i d := by + unfold allocatedLayerWidths allocatedArrayWidths allocatedContinuousProfileScales + allocatedContinuousProfileWidths + ring + +theorem allocatedContinuousProfileScales_split (j : Fin m) : + allocatedContinuousProfileScales B U basis S j ∘ allocatedKernelCoefficientEquiv B j = + Sum.elim (kernelJetCoefficientScale G (j.val+1) S.value 1) + (fun d => 1 / monomialScale (layerSamplerBox B U basis S) (allocatedNonkernelExponent B j d)) := by + funext d + cases d with + | inl d => + change 1 / monomialScale (layerSamplerBox B U basis S) + (kernelExponentEmbedding G (PrincipalTupleIndex B (layerSamplerDegree I n)) (j.val+1) d).val = _ + rw [monomialScale_kernelExponent] + rfl + | inr d => rfl + +variable (j : Fin m) (i : I j) + +local notation "centers" => allocatedContinuousProfileCenters (G := G) B R j i +local notation "widths" => allocatedContinuousProfileWidths (G := G) B R σ j i +local notation "scales" => allocatedContinuousProfileScales B U basis S j +local notation "reindex" => allocatedKernelCoefficientEquiv (G := G) B j + +theorem allocatedContinuous_reindexed_image_law {O : Type*} [Fintype O] [DecidableEq O] + (A : Matrix O (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) ℤ) : + (allocatedCoefficientAxisLaw B U basis hR hσ S ⟨j, Sum.inl i⟩).map + (fun a => A.map (Int.cast : ℤ → ℝ) *ᵥ a) = + (unitCoefficientSource (BoundedIntegerExponent G (j.val+1) ⊕ AllocatedNonkernelCoefficient B j)).map + (fun r => normalizedIntegerColumns (A.submatrix id reindex) (scales ∘ reindex) (fun _ => 1) *ᵥ + (fun d => centers (reindex d)+widths (reindex d)*r d)) := by + change (Measure.pi (fun d => affineCoefficientMeasure + (allocatedLayerCenters B U basis S j i d) (allocatedLayerWidths B U basis S j i d))).map _ = _ + simp_rw [allocatedLayerCenters_scale, allocatedLayerWidths_scale] + exact affineCoefficientProduct_scaled_image reindex A centers widths scales + (allocatedContinuousProfileWidths_pos B hR hσ j i) (allocatedContinuousProfileScales_pos B U basis S j) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +variable {α O : Type*} [Fintype α] [DecidableEq α] [Fintype O] [DecidableEq O] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent G (j.val+1)) +variable (hA : ((scalarKernelIntegerJet x (j.val+1) rows).submatrix id s).det ≠ 0) + +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) +local notation "fixedInteger" => Sum.elim + (fun ga : G × Option α => (x (Prod.fst ga) (Prod.snd ga) : ℤ)) (principalTupleIntegers u) +local notation "fixedReal" => Sum.elim + (fun ga : G × Option α => ((x (Prod.fst ga) (Prod.snd ga) : ℤ) : ℝ) / (S.value : ℝ)) + (principalTupleNormalized (principalAxisLength grid sides) u) +local notation "kernelScale" => kernelJetCoefficientScale G (j.val+1) (S.value : ℝ) 1 + +omit [Fintype α] [DecidableEq α] in +theorem allocatedPartitionedInput_normalized + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) + (k : LayerSamplerVariables G I n B) (a : Option α) : + ((Sum.elim fixedInteger (principalTupleIntegers v) (input k a) : ℤ) : ℝ) / + layerSamplerBox B U basis S k = + Sum.elim fixedReal (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (input k a) := by + have hbox : layerSamplerBox B U basis S = + Sum.elim (fun _ : G => (S.value : ℝ)) (fun d => (sides d : ℝ)) := by + funext k + cases k <;> rfl + rw [hbox] + exact partitionedPrincipalInput_normalized grid (fun g a => (g, a)) + (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) + (fun ga : G × Option α => ((x ga.1 ga.2 : ℤ) : ℝ) / (S.value : ℝ)) + (fun _ => (S.value : ℝ)) (fun _ _ => rfl) sides u v k a + +noncomputable def allocatedContinuousKernelDensity + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) : + (O → ℝ) → ℝ := + affineSelectedJetDensity s + (normalizedPivotEquiv ((scalarKernelIntegerJet x (j.val+1) rows).submatrix id s) hA + (fun o => kernelScale (s o)) (fun _ => 1) + (fun o => kernelJetCoefficientScale_pos G (j.val+1) (by exact_mod_cast S.positive) zero_lt_one (s o)) + (fun _ => zero_lt_one)) + (matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns (scalarKernelIntegerJet x (j.val+1) rows) s) + (fun d => kernelScale d.val) (fun _ => 1))) + (allocatedNonkernelExponent B j) input fixedReal rows (centers ∘ reindex) (widths ∘ reindex) y + +theorem allocatedContinuousKernel_image_law (hσ1 : σ j ≤ 1) + (v : PrincipalAxisTuples (α := α) (fun a => ¬grid a) sides) : + (allocatedCoefficientAxisLaw B U basis hR hσ S ⟨j, Sum.inl i⟩).map + (fun a => (integerMappedJetMatrix + (fun d : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1) => d.val) + input fixedInteger rows (principalTupleIntegers v)).map (Int.cast : ℤ → ℝ) *ᵥ a) = + realDensityMeasure volume + (allocatedContinuousKernelDensity B U basis S j i x u rows s hA + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v)) := by + rw [allocatedContinuous_reindexed_image_law B U basis hR hσ S j i, + allocatedKernelJet_split B U basis S j x (principalTupleIntegers u) (principalTupleIntegers v) rows, + allocatedContinuousProfileScales_split] + have hn := integerMappedCubeTuple_normalized input fixedInteger (principalTupleIntegers v) fixedReal + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) (layerSamplerBox B U basis S) + (allocatedPartitionedInput_normalized B U basis S x u v) + have hc := normalizedIntegerJetColumns_eq (allocatedNonkernelExponent B j) input fixedReal rows + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) + (integerMappedCubeTuple input fixedInteger (principalTupleIntegers v)) (layerSamplerBox B U basis S) + hn (H := 1) one_ne_zero + have hlaw := normalizedJoinedMatrix_affineDensity_law (scalarKernelIntegerJet x (j.val+1) rows) + (integerMappedJetMatrix (allocatedNonkernelExponent B j) input fixedInteger rows (principalTupleIntegers v)) + s hA kernelScale (fun d => 1 / monomialScale (layerSamplerBox B U basis S) (allocatedNonkernelExponent B j d)) + (kernelJetCoefficientScale_pos G (j.val+1) (by exact_mod_cast S.positive) zero_lt_one) + (allocatedNonkernelExponent B j) input fixedReal rows + (principalTupleNormalized (principalAxisLength (fun a => ¬grid a) sides) v) hc + (centers ∘ reindex) (widths ∘ reindex) + (fun d => allocatedContinuousProfileWidths_pos B hR hσ j i (reindex d)) + ⟨R j, (hR j).le⟩ (fun d => allocatedContinuousProfile_bound B hR hσ j i hσ1 (reindex d)) + refine Eq.trans ?_ hlaw + congr 1 + funext r + apply congrArg (fun M => M *ᵥ (fun d => centers (reindex d)+widths (reindex d)*r d)) + congr 1 + exact Subsingleton.elim _ _ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +theorem allocatedInteger_replacementScale_le {α O : Type*} [Fintype α] [Fintype O] + (j : Fin m) (i : Fin (n j)) (rows : O → Finset α) (hinj : Function.Injective rows) + (hq : Fintype.card α ≤ m+1) (s : O ↪ BoundedIntegerExponent G (j.val+1)) + {b t e ε : ℝ} (hb : 0 ≤ b) (ht : 0 ≤ t) (he : 0 ≤ e) (hε : 0 < ε) + (hεe : ε⁻¹ ≤ Real.exp e) + (hfront : Real.exp (coefficientFrontLog (Fintype.card O) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) b t e) ≤ S.value) + (henormous : S.value^(layerTailDegree m+1) < basisAxisScale (basis j) i) : + coefficientReplacementScale + (J := BoundedIntegerExponent G (j.val+1) ⊕ AllocatedNonkernelCoefficient (G := G) B j) + (s.trans Function.Embedding.inl) b t ε S.value (j.val+1) ≤ (basisAxisScale (basis j) i : ℝ) := by + have hcard := Fintype.card_congr (allocatedKernelCoefficientEquiv (G := G) B j) + have hf : Real.exp (coefficientFrontLog (Fintype.card O) + (Fintype.card (BoundedIntegerExponent G (j.val+1) ⊕ AllocatedNonkernelCoefficient (G := G) B j)) + b t e) ≤ S.value := by simpa only [hcard] using hfront + have hL : (1 : ℝ) ≤ S.value := by exact_mod_cast S.positive + have hd := layerTailDegree_row_bound rows hinj (Nat.succ_le_of_lt j.isLt) hq + apply (coefficientReplacementScale_le_power (s.trans Function.Embedding.inl) (j.val+1) + hb ht he hε (zero_le_one.trans hL) hεe hf).trans + calc + _ ≤ (S.value : ℝ)^(layerTailDegree m+1) := + pow_le_pow_right₀ hL (Nat.succ_le_of_lt hd) + _ ≤ (basisAxisScale (basis j) i : ℝ) := by exact_mod_cast henormous.le + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators Matrix Classical + +noncomputable def allocatedUnitProfileWidth (R σ : ℝ) (a : ℕ) : ℝ := + allocatedWidthFloor R σ 1 0 a + +theorem allocatedUnitProfileWidth_pos {R σ : ℝ} (hR : 0 < R) (hσ : 0 < σ) (a : ℕ) : + 0 < allocatedUnitProfileWidth R σ a := + allocatedWidthFloor_pos hR hσ zero_lt_one 0 a + +theorem allocatedUnitProfileWidth_le {J : Type*} [Fintype J] (P : Finset J) (j₀ : J) + {R σ : ℝ} (hR : 0 < R) (j : J) : + allocatedUnitProfileWidth R σ (Fintype.card J) ≤ + coefficientProfileWidth P j₀ (R/4) (principalProfileSize R P.card) + (tailProfileSize R σ (Fintype.card J)) j := by + have hp : principalProfileSize R (Fintype.card J) ≤ principalProfileSize R P.card := by + unfold principalProfileSize + apply div_le_div_of_nonneg_left hR.le (by positivity) + gcongr + exact_mod_cast P.card_le_univ + simp only [allocatedUnitProfileWidth, allocatedWidthFloor, pow_zero, div_one] + unfold coefficientProfileWidth + split_ifs + · exact min_le_left _ _ + · exact ((min_le_right _ _).trans (min_le_left _ _)).trans + (div_le_div_of_nonneg_right hp (by norm_num)) + · exact (min_le_right _ _).trans (min_le_right _ _) + +theorem allocatedUnitProfileWidth_inverse_exp (a : ℕ) {R σ P : ℝ} + (hP : 0 ≤ P) (hR : 0 < R) (hσ : 0 < σ) + (hRP : R⁻¹ ≤ Real.exp P) (hσP : σ⁻¹ ≤ Real.exp P) (haP : (a : ℝ)+1 ≤ Real.exp P) : + (allocatedUnitProfileWidth R σ a)⁻¹ ≤ Real.exp (4*(P+8)) := by + let X := Real.exp (P+8) + have hPX : Real.exp P ≤ X := Real.exp_le_exp.mpr (by linarith) + have hX : 8 ≤ X := by dsimp [X]; linarith [Real.add_one_le_exp (P+8)] + have hLX : ((1 : ℕ) : ℝ) ≤ X := by norm_num; linarith + have h := allocatedWidthFloor_inverse_power_bound 1 0 0 a le_rfl hR hσ hX + (hRP.trans hPX) (hσP.trans hPX) (haP.trans hPX) hLX + simpa only [allocatedUnitProfileWidth, X, ← Real.exp_nat_mul, Nat.zero_add, Nat.cast_ofNat] using h + +namespace VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable (j : Fin m) (i : I j) + +local notation "unitWidth" => allocatedUnitProfileWidth (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) + +include hR in +theorem allocatedContinuousProfileWidths_floor (d) : + unitWidth ≤ allocatedContinuousProfileWidths (G := G) B R σ j i d := + allocatedUnitProfileWidth_le _ _ (hR j) d + +local notation "centers" => allocatedContinuousProfileCenters (G := G) B R j i +local notation "widths" => allocatedContinuousProfileWidths (G := G) B R σ j i +local notation "reindex" => allocatedKernelCoefficientEquiv (G := G) B j +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S + +variable {α O : Type*} [Fintype α] [DecidableEq α] [Fintype O] [DecidableEq O] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent G (j.val+1)) +variable (hA : ((scalarKernelIntegerJet x (j.val+1) rows).submatrix id s).det ≠ 0) + +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) +local notation "fixedReal" => Sum.elim + (fun ga : G × Option α => ((x (Prod.fst ga) (Prod.snd ga) : ℤ) : ℝ) / (S.value : ℝ)) + (principalTupleNormalized (principalAxisLength grid sides) u) +local notation "kernelScale" => kernelJetCoefficientScale G (j.val+1) (S.value : ℝ) 1 +local notation "pivot" => normalizedPivotEquiv (Matrix.submatrix (scalarKernelIntegerJet x (j.val+1) rows) id s) hA + (fun o => kernelScale (s o)) (fun _ => 1) + (fun o => kernelJetCoefficientScale_pos G (j.val+1) + (Nat.cast_pos.mpr (LayerSamplerScale.positive S)) zero_lt_one (s o)) + (fun _ => zero_lt_one) +local notation "free" => matrixSupCLM (normalizedIntegerColumns + (remainingMatrixColumns (scalarKernelIntegerJet x (j.val+1) rows) s) + (fun d => kernelScale (Subtype.val d)) (fun _ => 1)) +local notation "radius" => NNReal.mk (R j) (le_of_lt (hR j)) +local notation "delta" => NNReal.mk unitWidth (le_of_lt (allocatedUnitProfileWidth_pos (hR j) (hσ j) _)) + +theorem allocatedPartitionedInput_frozen_bound (t) : |fixedReal t| ≤ 1 := by + apply partitionedPrincipalInput_frozen_bound grid _ _ sides (allocatedPrincipalSides_pos B U basis S) u t + intro ga + have h := (norm_le_pi_norm (fun a => ((x ga.1 a : ℤ) : ℝ)/(S.value : ℝ)) ga.2).trans + (integerScalarCubeBox_normalized_norm_le S.positive (x ga.1)) + simpa only [Real.norm_eq_abs] using h + +include hR hσ in +theorem allocatedContinuousKernelDensity_measurable (hσ1 : σ j ≤ 1) : + Measurable (Function.uncurry (allocatedContinuousKernelDensity B U basis S j i x u rows s hA)) := by + have hw (d) := allocatedContinuousProfileWidths_pos B hR hσ j i (reindex d) + have hb (d) := allocatedContinuousProfile_bound B hR hσ j i hσ1 (reindex d) + exact normalizedJetDensity_measurable pivot free (allocatedNonkernelExponent B j) input fixedReal rows + ((affineProductProfile_contDiff _ _).continuous.comp (selectedCoefficientEquiv_lipschitz s).continuous) + (affineProductProfile_contDiff _ _).continuous + (selectedCoefficientProfile_zero_outside s + (affineProductProfile_zero_outside _ _ (fun d => hw (.inl d)) (hR j).le (fun d => hb (.inl d)))) + (affineProductProfile_zero_outside _ _ (fun d => hw (.inr d)) (hR j).le (fun d => hb (.inr d))) + +include hR hσ in +theorem allocatedContinuousKernelDensity_probability_data (hσ1 : σ j ≤ 1) + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) : + (∀ v, 0 ≤ allocatedContinuousKernelDensity B U basis S j i x u rows s hA y v) ∧ + Integrable (allocatedContinuousKernelDensity B U basis S j i x u rows s hA y) ∧ + (∫ v, allocatedContinuousKernelDensity B U basis S j i x u rows s hA y v) = 1 := + affineSelectedJetDensity_probability_data s pivot free (allocatedNonkernelExponent B j) input fixedReal rows + (centers ∘ reindex) (widths ∘ reindex) + (fun d => allocatedContinuousProfileWidths_pos B hR hσ j i (reindex d)) radius + (fun d => allocatedContinuousProfile_bound B hR hσ j i hσ1 (reindex d)) y + +include hR hσ in +theorem allocatedContinuousKernelDensity_bounds (hσ1 : σ j ≤ 1) (v : O → ℝ) : + (∀ y, |allocatedContinuousKernelDensity B U basis S j i x u rows s hA y v| ≤ + pivotKernelCap (UnselectedColumn s) pivot radius + (delta⁻¹^Fintype.card (BoundedIntegerExponent G (j.val+1)))) ∧ + LipschitzOnWith + (pivotKernelLip (UnselectedColumn s) pivot radius + (affineProductProfileLip (BoundedIntegerExponent G (j.val+1)) delta) * + (Fintype.card (AllocatedNonkernelCoefficient (G := G) B j) * + polynomialBoxLip + (Fintype.card (PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) + (α := α) (fun a => ¬grid a))) (j.val+1) (normalizedJetMass α (j.val+1))) * radius) + (fun y => allocatedContinuousKernelDensity B U basis S j i x u rows s hA y v) + (Metric.closedBall 0 1) := by + have hδ : 0 < delta := allocatedUnitProfileWidth_pos (hR j) (hσ j) _ + have he := affineSelectedJetDensity_bounds s pivot free (allocatedNonkernelExponent B j) + input fixedReal (allocatedPartitionedInput_frozen_bound B U basis S x u) rows + (allocatedNonkernelExponent_degree B j) (centers ∘ reindex) (widths ∘ reindex) + (fun d => allocatedContinuousProfileWidths_pos B hR hσ j i (reindex d)) hδ + (fun d => allocatedContinuousProfileWidths_floor B hR j i (reindex (.inl d))) radius + (fun d => allocatedContinuousProfile_bound B hR hσ j i hσ1 (reindex d)) v + simpa only [allocatedContinuousKernelDensity, Real.norm_eq_abs] using he + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + +def AllocatedTailCutoffCompatible (L d : ℕ) : Prop := + ∀ j (i : Fin (n j)), L ^ (layerTailDegree m + 1) < basisAxisScale (basis j) i → + L ^ (layerTailDegree (max m d) + 1) < basisAxisScale (basis j) i + +theorem allocatedTailCutoffCompatible_of_le (L d : ℕ) (hd : d ≤ m) : + AllocatedTailCutoffCompatible U basis L d := by + unfold AllocatedTailCutoffCompatible + simpa only [max_eq_left hd] using + (fun j (i : Fin (n j)) (h : L ^ (layerTailDegree m + 1) < basisAxisScale (basis j) i) => h) + +theorem allocatedTailCutoffCompatible_of_moderate (L d : ℕ) + (hmoderate : ∀ j (i : Fin (n j)), basisAxisScale (basis j) i ≤ L ^ (layerTailDegree m + 1)) : + AllocatedTailCutoffCompatible U basis L d := by + intro j i h + exact False.elim (Nat.not_lt_of_ge (hmoderate j i) h) + +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +theorem allocatedInteger_replacementScale_le_withCutoff (d : ℕ) {α O : Type*} [Fintype α] [Fintype O] + (j : Fin m) (i : Fin (n j)) (rows : O → Finset α) (hinj : Function.Injective rows) + (hq : Fintype.card α ≤ d+1) (s : O ↪ BoundedIntegerExponent G (j.val+1)) + {b t e ε : ℝ} (hb : 0 ≤ b) (ht : 0 ≤ t) (he : 0 ≤ e) (hε : 0 < ε) + (hεe : ε⁻¹ ≤ Real.exp e) + (hfront : Real.exp (coefficientFrontLog (Fintype.card O) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1))) b t e) ≤ S.value) + (henormous : S.value^(layerTailDegree (max m d)+1) < basisAxisScale (basis j) i) : + coefficientReplacementScale + (J := BoundedIntegerExponent G (j.val+1) ⊕ AllocatedNonkernelCoefficient (G := G) B j) + (s.trans Function.Embedding.inl) b t ε S.value (j.val+1) ≤ (basisAxisScale (basis j) i : ℝ) := by + have hcard := Fintype.card_congr (allocatedKernelCoefficientEquiv (G := G) B j) + have hf : Real.exp (coefficientFrontLog (Fintype.card O) + (Fintype.card (BoundedIntegerExponent G (j.val+1) ⊕ AllocatedNonkernelCoefficient (G := G) B j)) + b t e) ≤ S.value := by simpa only [hcard] using hfront + have hL : (1 : ℝ) ≤ S.value := by exact_mod_cast S.positive + have hd := layerTailDegree_row_bound rows hinj + ((Nat.succ_le_of_lt j.isLt).trans (le_max_left m d)) + (hq.trans (Nat.succ_le_succ (le_max_right m d))) + apply (coefficientReplacementScale_le_power (s.trans Function.Embedding.inl) (j.val+1) + hb ht he hε (zero_le_one.trans hL) hεe hf).trans + calc + _ ≤ (S.value : ℝ)^(layerTailDegree (max m d)+1) := + pow_le_pow_right₀ hL (Nat.succ_le_of_lt hd) + _ ≤ (basisAxisScale (basis j) i : ℝ) := by exact_mod_cast henormous.le + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSiteMask.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSiteMask.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5faf394e4bdf03da921ac7ee4354fb6bd69fe75 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSiteMask.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedLongIntegralMass + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical BigOperators + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] +variable (rowSets : Fin m → Finset (Finset α)) + +local notation "rows" => (fun j : Fin m => {t : Finset α // t ∈ rowSets j}) +local notation "rowMap" => (fun j : Fin m => (Subtype.val : rows j → Finset α)) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rows I n grid + +noncomputable def allocatedKernelSiteLift (period : ℕ) + (r : Finset α → ∀ j, Fin (n j) → ZMod period) : AllocatedLongJetRows B U b S rows + | ⟨⟨_, .inl _⟩, _⟩ => fun _ => 0 + | ⟨⟨j, .inr i⟩, _⟩ => fun t => (booleanCoefficient (fun s => r s j i) t.val).val + +variable (x : G → IntegerScalarCubeBox α S.value) (modulus : ℕ) +variable (residue : ∀ j, Matrix {t : Finset α // t ∈ rowSets j} + (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) + +noncomputable def allocatedKernelSiteMask (period : ℕ) + (r : Finset α → ∀ j, Fin (n j) → ZMod period) : ℝ := + ∏ a, allocatedLongJetMask B U b S x rowMap modulus residue a + (allocatedKernelSiteLift B U b S rowSets period r a) + +variable {Q : Fin m → Type*} + +theorem allocatedKernelSiteMask_reconstructed (period : ℕ) [NeZero period] + (hperiod : ∀ j, integerScalarLattice (rows j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rowMap j)).mulVecLin.range) + (d : ℕ) (z : MixedCoveredJetSource I rows Q n d) : + allocatedKernelSiteMask B U b S rowSets x modulus residue period + (fun s j i => (((mixedCoveredRowsSiteValue rowSets d z s).1 j).2 i () : ZMod period)) = + ∏ a, allocatedLongJetMask B U b S x rowMap modulus residue a ((split z.1).2 a) := by + unfold allocatedKernelSiteMask + apply Finset.prod_congr rfl + intro a _ + rcases a with ⟨⟨j, i | i⟩, ha⟩ + · rfl + · change coefficientResidueMultiplier _ (residue j) _ = + coefficientResidueMultiplier _ (residue j) ((z.1 j).2 i) + apply coefficientResidueMultiplier_eq_of_output_residue _ _ period (hperiod j) + funext t + change (((booleanCoefficient (fun s => + (((mixedCoveredRowsSiteValue rowSets d z s).1 j).2 i () : ZMod period)) t.val).val : ℤ) : + ZMod period) = ((z.1 j).2 i t : ZMod period) + simp only [Int.cast_natCast, ZMod.natCast_zmod_val, mixedCoveredRowsSiteValue_integer] + have h := booleanCoefficient_map (Int.castRingHom (ZMod period)) + (integerBooleanSitesFromRows (rowSets j) ((z.1 j).2 i)) t.val + rw [integerBooleanSitesFromRows_coefficient_mem] at h + exact h.symm + +omit [Fintype α] in +theorem allocatedKernelSiteMask_bound (period : ℕ) + {C : ℝ} (hC : 1 ≤ C) + (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x rowMap j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U b S x rowMap j modulus (residue j) z ≤ C) + (r : Finset α → ∀ j, Fin (n j) → ZMod period) : + |allocatedKernelSiteMask B U b S rowSets x modulus residue period r| ≤ + C ^ Fintype.card (LayerSamplerAxis I n) := + allocatedLongJetMask_product_bound B U b S x rowMap modulus residue hC hm _ + +theorem allocatedLongProfileDensity_site_mask (period : ℕ) [NeZero period] + (hperiod : ∀ j, integerScalarLattice (rows j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rowMap j)).mulVecLin.range) + (d : ℕ) (f : ((Σ a : {a // ¬grid a}, rows a.val.1) → ℝ) → ℝ) + (z : MixedCoveredJetSource I rows Q n d) : + allocatedLongProfileDensity B U b S x rowMap modulus residue f ((split z.1).2) = + allocatedKernelSiteMask B U b S rowSets x modulus residue period + (fun s j i => (((mixedCoveredRowsSiteValue rowSets d z s).1 j).2 i () : ZMod period)) * + f (allocatedLongJetRealCoordinates B U b S ((split z.1).2)) / + (∏ a, allocatedLongJetOutputScale B U b S (O := rows) a) := by + rw [allocatedLongProfileDensity, + allocatedKernelSiteMask_reconstructed B U b S rowSets x modulus residue period hperiod d z] + +theorem allocatedKernelSiteMask_expansion (period : ℕ) [NeZero period] + (hperiod : ∀ j, integerScalarLattice (rows j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rowMap j)).mulVecLin.range) + (d : ℕ) {T : Type*} [Fintype T] (c : T → ℂ) + (f : T → Finset α → MixedCoveredJetSource I (fun _ => Unit) Q n d → ℂ) + (z : MixedCoveredJetSource I rows Q n d) : + ((∏ a, allocatedLongJetMask B U b S x rowMap modulus residue a ((split z.1).2 a) : ℝ) : ℂ) * + (∑ k, c k * ∏ s, f k s (mixedCoveredRowsSiteValue rowSets d z s)) = + ∑ r : Finset α → ∀ j, Fin (n j) → ZMod period, ∑ k, + ((allocatedKernelSiteMask B U b S rowSets x modulus residue period r : ℂ) * c k) * + ∏ s, maskedSiteFactor (fun _ v j i => ((v.1 j).2 i () : ZMod period)) r f k s + (mixedCoveredRowsSiteValue rowSets d z s) := by + rw [maskedSiteExpansion_identity, + allocatedKernelSiteMask_reconstructed B U b S rowSets x modulus residue period hperiod d z] + +theorem allocatedKernelSiteMask_coefficient_sum (period : ℕ) [NeZero period] + {C A : ℝ} (hC : 1 ≤ C) + (hm : ∀ j z, 0 ≤ allocatedIntegerKernelMask B U b S x rowMap j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U b S x rowMap j modulus (residue j) z ≤ C) + {T : Type*} [Fintype T] (c : T → ℂ) (hc : (∑ k, ‖c k‖) ≤ A) : + (∑ r : Finset α → ∀ j, Fin (n j) → ZMod period, ∑ k, + ‖(allocatedKernelSiteMask B U b S rowSets x modulus residue period r : ℂ) * c k‖) ≤ + (Fintype.card (∀ j, Fin (n j) → ZMod period) : ℝ) ^ Fintype.card (Finset α) * + C ^ Fintype.card (LayerSamplerAxis I n) * A := by + apply maskedSiteExpansion_coefficient_sum _ c (pow_nonneg (zero_le_one.trans hC) _) _ hc + intro r + rw [Complex.norm_real, Real.norm_eq_abs] + exact allocatedKernelSiteMask_bound B U b S rowSets x modulus residue period hC hm r + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSiteReferenceData.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSiteReferenceData.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5ee73e5b6e86e542d0ee6bd8577c9d324cccbd8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSiteReferenceData.lean @@ -0,0 +1,265 @@ +import OAI.Combinatorics.Progressions.Estimates.CanonicalSiteBlocks +import OAI.Combinatorics.Progressions.Lattices.AllocatedIdealResidueData + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +noncomputable def allocatedKernelSiteParameter {A : Type*} [Semiring A] + (p Ebad T : A) : A := allocatedKernelPrimitiveBudget p Ebad T + p ^ 2 + +theorem allocatedKernelSiteParameter_bounds {p Ebad T : ℝ} + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) : + let Q := allocatedKernelSiteParameter p Ebad T + 0 ≤ Q ∧ p ≤ Q ∧ allocatedKernelPrimitiveBudget p Ebad T ≤ Q ∧ p ^ 2 ≤ Q := by + have h := allocatedKernelPrimitiveBudget_bounds hp hEbad hT + dsimp only [allocatedKernelSiteParameter] + have hs := sq_nonneg p + exact ⟨by linarith [h.1], by linarith [h.2.1], by linarith, by linarith [h.1]⟩ + +theorem allocatedKernelSiteParameter_mono {p Ebad T p' Ebad' T' : ℝ} + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) + (hpp : p ≤ p') (hEE : Ebad ≤ Ebad') (hTT : T ≤ T') : + allocatedKernelSiteParameter p Ebad T ≤ allocatedKernelSiteParameter p' Ebad' T' := + add_le_add (allocatedKernelPrimitiveBudget_mono hp hEbad hT hpp hEE hTT) + (pow_le_pow_left₀ hp hpp 2) + +theorem allocatedKernelSiteParameter_refined_budget (m : ℕ) {dim : ℕ} + (hdim : dim ≤ m + 1) {p Ebad T : ℝ} + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) : + (m + 1 : ℕ) * allocatedKernelPrimitiveBudget p Ebad T + p ^ 2 + (dim + 1 : ℕ) ≤ + allocatedSiteScaleNumeric m (allocatedKernelSiteParameter p Ebad T) := by + have hQ := (allocatedKernelSiteParameter_bounds hp hEbad hT).1 + have hnum := (allocatedSiteScaleNumeric_bounds m hQ).2.2 + have hd : ((dim + 1 : ℕ) : ℝ) ≤ (m + 2 : ℕ) := by exact_mod_cast (show dim + 1 ≤ m + 2 by omega) + have hm : (1 : ℝ) ≤ (m + 1 : ℕ) := by exact_mod_cast (show 1 ≤ m + 1 by omega) + have hs := mul_le_mul_of_nonneg_right hm (sq_nonneg p) + dsimp only [allocatedKernelSiteParameter] at hnum ⊢ + nlinarith + +theorem allocatedSiteSourceLog_mono (m : ℕ) {p e E p' e' E' : ℝ} + (hp : 0 ≤ p) (he : 0 ≤ e) (hE : 0 ≤ E) + (hpp : p ≤ p') (hee : e ≤ e') (hEE : E ≤ E') : + allocatedSiteSourceLog m p e E ≤ allocatedSiteSourceLog m p' e' E' := by + have hD : allocatedComparisonDimension m p ≤ allocatedComparisonDimension m p' := by + unfold allocatedComparisonDimension + gcongr + have hN : allocatedSiteScaleNumeric m p ≤ allocatedSiteScaleNumeric m p' := by + unfold allocatedSiteScaleNumeric + gcongr + have hw : allocatedSiteKernelMaskLog m p ≤ allocatedSiteKernelMaskLog m p' := by + unfold allocatedSiteKernelMaskLog + gcongr + have hC : canonicalScalarSourceLog m p ≤ canonicalScalarSourceLog m p' := by + unfold canonicalScalarSourceLog + gcongr + have hL := allocatedIdealScaleLog_mono m (allocatedComparisonDimension_bounds m hp).1 + (allocatedSiteScaleNumeric_bounds m hp).1 he (allocatedSiteKernelMaskLog_nonneg m hp) hE + hD hN hee hw hEE + change allocatedSiteScaleLog m p e E ≤ allocatedSiteScaleLog m p' e' E' at hL + unfold allocatedSiteSourceLog + linarith + +theorem exists_allocatedKernelSiteSourceLog_bound (m : ℕ) : + ∃ a : ℕ, 2 ≤ a ∧ ∀ {p Ebad T e E : ℝ}, + 0 ≤ p → 0 ≤ Ebad → 0 ≤ T → 0 ≤ e → 0 ≤ E → + allocatedSiteSourceLog m (allocatedKernelSiteParameter p Ebad T) e E ≤ + (p + Ebad + T + e + E + a) ^ a := by + let poly : Polynomial ℕ := allocatedSiteSourceLog m + (allocatedKernelSiteParameter Polynomial.X Polynomial.X Polynomial.X) Polynomial.X Polynomial.X + obtain ⟨a, ha, hbound⟩ := exists_natPolynomial_eval_budget poly + refine ⟨a, ha, ?_⟩ + intro p Ebad T e E hp hEbad hT he hE + have hQ := allocatedKernelSiteParameter_mono hp hEbad hT + (show p ≤ p + Ebad + T + e + E by linarith) + (show Ebad ≤ p + Ebad + T + e + E by linarith) + (show T ≤ p + Ebad + T + e + E by linarith) + apply (allocatedSiteSourceLog_mono m (allocatedKernelSiteParameter_bounds hp hEbad hT).1 + he hE hQ (show e ≤ p + Ebad + T + e + E by linarith) + (show E ≤ p + Ebad + T + e + E by linarith)).trans + simpa [poly, allocatedKernelSiteParameter, allocatedKernelPrimitiveBudget, + allocatedSiteSourceLog, allocatedSiteScaleLog, allocatedSiteScaleNumeric, + allocatedSiteKernelMaskLog, canonicalScalarSourceLog, allocatedComparisonDimension, + allocatedIdealScaleLog, allocatedIdealScaleInput, allocatedPhysicalIdealLengthEnvelope, + allocatedTestLengthEnvelope, allocatedJointLengthEnvelope, allocatedTestEnvelope, + allocatedFrontEnvelope, allocatedAccuracyEnvelope, allocatedTupleEnvelope, + allocatedKernelEnvelope, allocatedIdealMeshEnvelope, allocatedIdealGridEnvelope, + allocatedIdealRadiusEnvelope, allocatedProxyLipEnvelope, allocatedIdealLipEnvelope, + allocatedSupportEnvelope, allocatedDensityEnvelope, kernelOutputEnvelope, + kernelGeometryEnvelope, kernelInverseEnvelope, Polynomial.eval₂_pow] using + hbound (p + Ebad + T + e + E) (by positivity) + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + +noncomputable def allocatedKernelSiteScale (p Ebad T e E : ℝ) : LayerSamplerScale (G := G) B U b R σ := + allocatedSiteScale B U b hR hσ (allocatedKernelSiteParameter p Ebad T) e E + +theorem allocatedKernelSiteScale_cutoff {dim : ℕ} [Nonempty (Fin dim)] {p Ebad T e E : ℝ} + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) (he : 0 ≤ e) (hE : 0 ≤ E) + (hdim : (dim : ℝ) ≤ p) (hG : (Fintype.card G : ℝ) ≤ p) + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) + (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) : + let cutoff := scalarKernelCutoff (Fin dim) G M D (Real.exp (-(Ebad + 1))) + 0 < cutoff ∧ (cutoff : ℝ) ≤ Real.exp (allocatedKernelPrimitiveBudget p Ebad T) ∧ + cutoff ≤ (allocatedKernelSiteScale (G := G) B U b hR hσ p Ebad T e E).value := by + have hQ := allocatedKernelSiteParameter_bounds hp hEbad hT + have hcut := scalarKernelCutoff_le_allocatedPrimitive (Fin dim) G hp hEbad hT + (by simpa only [Fintype.card_fin] using hdim) hG hM hD hMT hDp + refine ⟨(scalarKernelCutoff_bounds (Fin dim) G hM hD (Real.exp_pos _)).1, hcut, ?_⟩ + have hnum := (allocatedSiteScaleNumeric_bounds m hQ.1).2.1 + exact_mod_cast hcut.trans ((Real.exp_le_exp.mpr (hQ.2.2.1.trans hnum)).trans + (allocatedSiteScale_lower (G := G) B U b hR hσ hQ.1 he hE)) + +theorem allocatedKernelSiteScale_upper + {α : Type*} [Fintype α] {O : Fin m → Type*} [∀ j, Fintype (O j)] + (rows : ∀ j, O j → Finset α) + (hq : Fintype.card α ≤ m + 1) (hinj : ∀ j, Function.Injective (rows j)) + {p Ebad T e E : ℝ} + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) (he : 0 ≤ e) (hE : 0 ≤ E) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ p) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ p) (hn : ∀ j, (n j : ℝ) ≤ p) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp p) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp p) : + ((allocatedKernelSiteScale (G := G) B U b hR hσ p Ebad T e E).value : ℝ) ≤ + Real.exp (allocatedSiteScaleLog m (allocatedKernelSiteParameter p Ebad T) e E) := by + have hQ := allocatedKernelSiteParameter_bounds hp hEbad hT + exact allocatedSiteScale_upper (G := G) B U b hR hσ rows hq hinj hQ.1 he hE + (hvars.trans hQ.2.1) (fun j => (hI j).trans hQ.2.1) (fun j => (hn j).trans hQ.2.1) + (fun j => (hRi j).trans (Real.exp_le_exp.mpr hQ.2.1)) + (fun j => (hσi j).trans (Real.exp_le_exp.mpr hQ.2.1)) + +theorem allocatedKernelSiteScale_affine_bad_probability [DecidableEq G] + {dim : ℕ} [Nonempty (Fin dim)] {p Ebad T e E : ℝ} + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) (he : 0 ≤ e) (hE : 0 ≤ E) + (hdim : (dim : ℝ) ≤ p) (hGp : (Fintype.card G : ℝ) ≤ p) + (hG : dim * (dim + 2) ≤ Fintype.card G) (selection : Fin dim ↪ G) + {M D : ℕ} (hM : 0 < M) (hD : 0 < D) + (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) : + let S := allocatedKernelSiteScale (G := G) B U b hR hσ p Ebad T e E + let η := Real.exp (-(Ebad + 1)) + let cutoff := scalarKernelCutoff (Fin dim) G M D η + let hlarge := (allocatedKernelSiteScale_cutoff B U b hR hσ hp hEbad hT he hE hdim hGp hM hD hMT hDp).2.2 + ∀ (K : G → ℕ) (hKL : ∀ g, K g ≤ S.value) (hDK : ∀ g, S.value ≤ D * K g) + (c : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + (FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (K g) M D (c g) S.positive (hKL g) (hDK g) + (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hD (Real.exp_pos _) hlarge (hDK g)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff x) ≤ η := by + intro S η cutoff hlarge K hKL hDK c moduli residues hmoduli hmoduliM + exact affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hG) selection hM hD (Real.exp_pos _) S.positive + hlarge K hKL hDK c moduli residues hmoduli hmoduliM + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {dim : ℕ} [Nonempty (Fin dim)] {p Ebad T e E : ℝ} {M D : ℕ} + +local notation "siteScale" => allocatedKernelSiteScale (G := G) B U b hR hσ p Ebad T e E +local notation "cutoff" => scalarKernelCutoff (Fin dim) G M D (Real.exp (-(Ebad + 1))) +local notation "grid" => allocatedGridAxis (I := I) U b (LayerSamplerScale.value siteScale) +local notation "sides" => allocatedPrincipalSides B U b siteScale + +theorem allocatedKernelSiteScale_refined_window_size + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) (he : 0 ≤ e) (hE : 0 ≤ E) + (hdim : (dim : ℝ) ≤ p) (hGp : (Fintype.card G : ℝ) ≤ p) + (hM : 0 < M) (hD : 0 < D) (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) + (hdimSmall : dim ≤ m + 1) (a : Fin cutoff) + {X : Type*} [Fintype X] (hX : (Fintype.card X : ℝ) ≤ p) + (q : X → ℕ) (hq : ∀ x, (q x : ℝ) ≤ Real.exp p) : + ∀ ax, (Fintype.card (Fin dim) + 1) * residueRefinedPeriod (kernelPeriodCandidate (m + 1) a) q ≤ + principalAxisLength (fun ax => ¬grid ax) sides ax := by + have hc := (allocatedKernelSiteScale_cutoff B U b hR hσ hp hEbad hT he hE + hdim hGp hM hD hMT hDp).2.1 + have hperiod := kernelPeriodCandidate_le_exp hc (m + 1) a + have hrefined := residueRefinedPeriod_exp_bound (kernelPeriodCandidate (m + 1) a) q hperiod hq + have hdimExp : ((dim + 1 : ℕ) : ℝ) ≤ Real.exp (dim + 1 : ℕ) := by + linarith [Real.add_one_le_exp ((dim + 1 : ℕ) : ℝ)] + have hbudget := allocatedKernelSiteParameter_refined_budget m hdimSmall hp hEbad hT + have hprod := mul_le_mul_of_nonneg_right hX hp + have hcost : ((dim + 1 : ℕ) : ℝ) + + ((m + 1 : ℕ) * allocatedKernelPrimitiveBudget p Ebad T + Fintype.card X * p) ≤ + allocatedSiteScaleNumeric m (allocatedKernelSiteParameter p Ebad T) := by nlinarith + have hsize : ((dim + 1 : ℕ) : ℝ) * residueRefinedPeriod (kernelPeriodCandidate (m + 1) a) q ≤ + (LayerSamplerScale.value siteScale : ℝ) := by + calc + _ ≤ Real.exp (dim + 1 : ℕ) * + Real.exp ((m + 1 : ℕ) * allocatedKernelPrimitiveBudget p Ebad T + Fintype.card X * p) := + mul_le_mul hdimExp hrefined (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = Real.exp (((dim + 1 : ℕ) : ℝ) + + ((m + 1 : ℕ) * allocatedKernelPrimitiveBudget p Ebad T + Fintype.card X * p)) := + (Real.exp_add _ _).symm + _ ≤ Real.exp (allocatedSiteScaleNumeric m (allocatedKernelSiteParameter p Ebad T)) := + Real.exp_le_exp.mpr hcost + _ ≤ _ := allocatedSiteScale_lower (G := G) B U b hR hσ + (allocatedKernelSiteParameter_bounds hp hEbad hT).1 he hE + intro ax + rw [allocatedPrincipalSides_long_restricted] + simpa only [Fintype.card_fin] using + (show (dim + 1) * residueRefinedPeriod (kernelPeriodCandidate (m + 1) a) q ≤ + LayerSamplerScale.value siteScale by exact_mod_cast hsize) + +variable [∀ j, DecidableEq (I j)] [∀ ax, DecidableEq (B ax)] +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) + +theorem exists_allocatedKernelSiteScale_refined_residue_data + (hp : 0 ≤ p) (hEbad : 0 ≤ Ebad) (hT : 0 ≤ T) (he : 0 ≤ e) (hE : 0 ≤ E) + (hdim : (dim : ℝ) ≤ p) (hGp : (Fintype.card G : ℝ) ≤ p) + (hM : 0 < M) (hD : 0 < D) (hMT : (M : ℝ) ≤ Real.exp T) (hDp : (D : ℝ) ≤ Real.exp p) + (hdimSmall : dim ≤ m + 1) (a : Fin cutoff) + {X : Type*} [Fintype X] (hX : (Fintype.card X : ℝ) ≤ p) + (q : X → ℕ) (hq : ∀ x, 0 < q x) (hqp : ∀ x, (q x : ℝ) ≤ Real.exp p) + (x : G → IntegerScalarCubeBox (Fin dim) (LayerSamplerScale.value siteScale)) : + let modulus := kernelPeriodCandidate (m + 1) a + let refined := residueRefinedPeriod modulus q + ∃ (hRefined : 0 < refined) + (hsize : ∀ ax, (Fintype.card (Fin dim) + 1) * refined ≤ + principalAxisLength (fun ax => ¬grid ax) sides ax) + (reference : PrincipalAxisTuples (α := Fin dim) grid sides → + (PrincipalTupleIndex (fun ax : {ax // ¬grid ax} => B ax.val) + (fun ax => layerSamplerDegree I n ax.val) → Option (Fin dim) → ZMod refined) → + PrincipalAxisTuples (α := Fin dim) (fun ax => ¬grid ax) sides) + (residue : PrincipalAxisTuples (α := Fin dim) grid sides → + (PrincipalTupleIndex (fun ax : {ax // ¬grid ax} => B ax.val) + (fun ax => layerSamplerDegree I n ax.val) → Option (Fin dim) → ZMod refined) → + ∀ j, Matrix (jets j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)), + (∀ u r, principalResidueLabel refined (reference u r) = r) ∧ + (∀ u r v, (allocatedLongResidueWeights B U b siteScale refined hRefined r hsize).weight v ≠ 0 → + ∀ j, integerResidueMatrix (allocatedNonkernelJetMatrix B U b siteScale x u jetRows j v) modulus = + residue u r j) := by + intro modulus refined + have hRefined : 0 < refined := residueRefinedPeriod_pos (kernelPeriodCandidate_pos (m + 1) a) q hq + have hsize := allocatedKernelSiteScale_refined_window_size B U b hR hσ hp hEbad hT he hE + hdim hGp hM hD hMT hDp hdimSmall a hX q hqp + refine ⟨hRefined, hsize, ?_⟩ + exact allocated_refined_residue_data B U b siteScale x jetRows hRefined + ⟨∏ t, q t, rfl⟩ hsize + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSlowBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSlowBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d6c3a5ebf07a1bf03775ed44b926af271106856 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSlowBudget.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedTrimmedVectorSite + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) + +theorem allocatedKernelNormalizedSlope_nonneg : + 0 ≤ (S.value : ℝ) / (1 + budget) := + div_nonneg (Nat.cast_nonneg _) (by + have h := allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0) + linarith) + +theorem allocatedKernelSlowBudget_le_one : + (Fintype.card G : ℝ) * (S.value : ℝ) / (1 + budget) ≤ 1 := by + have hcard : Fintype.card G ≤ Fintype.card (LayerSamplerVariables G I n B) := + Fintype.card_le_of_injective (Sum.inl : G → LayerSamplerVariables G I n B) Sum.inl_injective + have hc : (Fintype.card G : ℝ) ≤ Fintype.card (LayerSamplerVariables G I n B) := + Nat.cast_le.mpr hcard + have hden : 0 < 1 + budget := by + have h := allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0) + linarith + apply (div_le_one hden).mpr + rw [allocatedPhysicalRootBudget_zero] + exact (mul_le_mul_of_nonneg_right hc (Nat.cast_nonneg _)).trans (le_add_of_nonneg_left zero_le_one) + +theorem allocatedKernelSlowBudget_abs_le_one : + (Fintype.card G : ℝ) * |(S.value : ℝ) / (1 + budget)| ≤ 1 := by + rw [abs_of_nonneg (allocatedKernelNormalizedSlope_nonneg B U basis S), ← mul_div_assoc] + exact allocatedKernelSlowBudget_le_one B U basis S + +theorem allocatedKernelSlowBudget_abs_bounds : + 0 ≤ (Fintype.card G : ℝ) * |(S.value : ℝ) / (1 + budget)| ∧ + (Fintype.card G : ℝ) * |(S.value : ℝ) / (1 + budget)| ≤ 1 := + ⟨mul_nonneg (Nat.cast_nonneg _) (abs_nonneg _), allocatedKernelSlowBudget_abs_le_one B U basis S⟩ + +theorem allocatedKernelSlowBudget_toNNReal_le_one : + Real.toNNReal ((Fintype.card G : ℝ) * |(S.value : ℝ) / (1 + budget)|) ≤ 1 := by + exact Real.toNNReal_le_one.mpr + (allocatedKernelSlowBudget_abs_le_one B U basis S) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSpatialScaleBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSpatialScaleBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2adfaa8e0ee53008fb809dc3cfec45d61bbce8bd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSpatialScaleBudget.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedTrimmedVectorSite + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +theorem allocatedKernelSpatialScale_inverse_exp {τ P : ℝ} + (hτ : 0 < τ) (hP : 0 ≤ P) + (hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (hτinv : τ⁻¹ ≤ Real.exp P) : + 8 * (1 + allocatedPhysicalRootBudget B U basis S (fun _ => 0)) / + ((S.value : ℝ) * τ) ≤ Real.exp (2 * P + 4) := by + have hratio := allocatedPhysicalRootBudget_zero_ratio B U basis S hP hvars + rw [(allocatedPrimitiveRootRatio_bounds hP).1] at hratio + have hS : (0 : ℝ) < S.value := Nat.cast_pos.mpr S.positive + have hW := allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0) + have hcount : P + 1 ≤ Real.exp P := Real.add_one_le_exp P + have h8 : (8 : ℝ) ≤ Real.exp 4 := by + have h2 := Real.add_one_le_exp (2 : ℝ) + have he : Real.exp (4 : ℝ) = Real.exp 2 * Real.exp 2 := by + rw [← Real.exp_add]; norm_num + rw [he]; nlinarith + calc + _ = 8 * ((1 + allocatedPhysicalRootBudget B U basis S (fun _ => 0)) / + (S.value : ℝ)) * τ⁻¹ := by ring + _ ≤ Real.exp 4 * Real.exp P * Real.exp P := by + apply mul_le_mul + · exact mul_le_mul h8 (hratio.trans hcount) (by positivity) (Real.exp_nonneg _) + · exact hτinv + · exact inv_nonneg.mpr hτ.le + · positivity + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSupport.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfc50749fb41bdeee9747f498efd5c08e7f96c49 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedKernelSupport.lean @@ -0,0 +1,193 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedJetSupportBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped NNReal Matrix Classical + +variable {m : ℕ} {G : Type*} [Fintype G] {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) (j : Fin m) +variable {α O : Type*} [Fintype α] [DecidableEq α] [Fintype O] [DecidableEq O] +variable (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) +variable (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent G (j.val+1)) +variable (hA : ((scalarKernelIntegerJet x (j.val+1) rows).submatrix id s).det ≠ 0) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "input" => partitionedPrincipalInput grid (fun g a => (g, a)) +local notation "fixed" => Sum.elim + (fun ga : G × Option α => ((x (Prod.fst ga) (Prod.snd ga) : ℤ) : ℝ)/(S.value : ℝ)) + (principalTupleNormalized (principalAxisLength grid sides) u) +local notation "radius" => NNReal.mk (R j) (le_of_lt (hR j)) +local notation "reindex" => allocatedKernelCoefficientEquiv (G := G) B j + +section Continuous + +variable (i : I j) +local notation "scale" => kernelJetCoefficientScale G (j.val+1) (S.value : ℝ) 1 +local notation "pivot" => normalizedPivotEquiv (Matrix.submatrix (scalarKernelIntegerJet x (j.val+1) rows) id s) hA + (fun o => scale (s o)) (fun _ => 1) + (fun o => kernelJetCoefficientScale_pos G (j.val+1) (Nat.cast_pos.mpr (LayerSamplerScale.positive S)) zero_lt_one (s o)) + (fun _ => zero_lt_one) +local notation "free" => matrixSupCLM (normalizedIntegerColumns + (remainingMatrixColumns (scalarKernelIntegerJet x (j.val+1) rows) s) + (fun d => scale (Subtype.val d)) (fun _ => 1)) + +include hσ in +theorem allocatedContinuousKernelDensity_support_data (hσ1 : σ j ≤ 1) + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) + (hy : ‖y‖ ≤ 1) (z : O → ℝ) + (hz : (normalizedJetOutputRadius α (AllocatedNonkernelCoefficient (G := G) B j) + pivot free (j.val+1) radius radius : ℝ) < ‖z‖) : + allocatedContinuousKernelDensity B U basis S j i x u rows s hA y z = 0 := by + have hs := affineSelectedJetDensity_output_support s pivot free (allocatedNonkernelExponent B j) + input fixed (allocatedPartitionedInput_frozen_bound B U basis S x u) rows + (allocatedNonkernelExponent_degree B j) + (allocatedContinuousProfileCenters (G := G) B R j i ∘ reindex) + (allocatedContinuousProfileWidths (G := G) B R σ j i ∘ reindex) + (fun d => allocatedContinuousProfileWidths_pos B hR hσ j i (reindex d)) radius + (fun d => allocatedContinuousProfile_bound B hR hσ j i hσ1 (reindex d)) y hy z hz + exact hs + +end Continuous + +section Integer + +variable (i : Fin (n j)) +local notation "height" => (basisAxisScale (basis j) i : ℝ) +local notation "heightPos" => Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) +local notation "scale" => kernelJetCoefficientScale G (j.val+1) (S.value : ℝ) height +local notation "pivot" => normalizedPivotEquiv (Matrix.submatrix (scalarKernelIntegerJet x (j.val+1) rows) id s) hA + (fun o => scale (s o)) (fun _ => height) + (fun o => kernelJetCoefficientScale_pos G (j.val+1) (Nat.cast_pos.mpr (LayerSamplerScale.positive S)) heightPos (s o)) + (fun _ => heightPos) +local notation "free" => matrixSupCLM (normalizedIntegerColumns + (remainingMatrixColumns (scalarKernelIntegerJet x (j.val+1) rows) s) + (fun d => scale (Subtype.val d)) (fun _ => height)) + +include hσ in +theorem allocatedIntegerKernelDensity_support_data (hσ1 : σ j ≤ 1) + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) + (hy : ‖y‖ ≤ 1) (z : O → ℝ) + (hz : (normalizedJetOutputRadius α (AllocatedNonkernelCoefficient (G := G) B j) + pivot free (j.val+1) radius radius : ℝ) < ‖z‖) : + allocatedIntegerKernelDensity B U basis S j i x u rows s hA y z = 0 := by + have hs := affineSelectedJetDensity_output_support s pivot free (allocatedNonkernelExponent B j) + input fixed (allocatedPartitionedInput_frozen_bound B U basis S x u) rows + (allocatedNonkernelExponent_degree B j) + (allocatedIntegerProfileCenters (G := G) B R j i ∘ reindex) + (allocatedIntegerProfileWidths (G := G) B R σ j i ∘ reindex) + (fun d => allocatedIntegerProfileWidths_pos B hR hσ j i (reindex d)) radius + (fun d => allocatedKernelProfile_bound B hR hσ j i hσ1 (reindex d)) y hy z hz + exact hs + +end Integer +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Matrix NNReal Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [dG : DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable (rows : ∀ j, O j → Finset α) +variable (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) +variable (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0) +variable {M : ℕ} (hM : 0 < M) +variable (hi : ∀ j : Fin m, + fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) +variable {P : ℝ} (hP : 0 ≤ P) (hMP : (M : ℝ) ≤ Real.exp P) +variable (hRP : ∀ j, R j ≤ Real.exp P) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) +variable (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) +variable (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "radius" j => NNReal.mk (R j) (le_of_lt (hR j)) +local notation "delta" j => NNReal.mk + (allocatedUnitProfileWidth (R j) (σ j) + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (Fin.val j+1)))) + (le_of_lt (allocatedUnitProfileWidth_pos (hR j) (hσ j) _)) +local notation "outputRadius" => Real.exp (allocatedJetSupportLog (G := G) B α O P) + +include hR hσ hM hi hP hMP hRP hRi hσi hcount + +theorem allocatedKernelRadius_bound (j : Fin m) {H : ℝ} (hH : 0 < H) : + let E := normalizedPivotEquiv _ (hA j) + (fun o => kernelJetCoefficientScale G (j.val+1) S.value H (s j o)) (fun _ => H) + (fun o => kernelJetCoefficientScale_pos G (j.val+1) (Nat.cast_pos.mpr S.positive) hH (s j o)) + (fun _ => hH) + let F := matrixSupCLM (normalizedIntegerColumns + (remainingMatrixColumns (scalarKernelIntegerJet x (j.val+1) (rows j)) (s j)) + (fun d => kernelJetCoefficientScale G (j.val+1) S.value H d.val) (fun _ => H)) + (normalizedJetOutputRadius α (AllocatedNonkernelCoefficient (G := G) B j) E F + (j.val+1) (radius j) (radius j) : ℝ) ≤ outputRadius := by + have hp' : 0 ≤ 4*(P+8) := by positivity + have hPP : Real.exp P ≤ Real.exp (4*(P+8)) := Real.exp_le_exp.mpr (by linarith) + have hf := fixedKernel_family_output_bound (N := AllocatedNonkernelCoefficient (G := G) B) + S.positive hM x (fun j : Fin m => j.val+1) rows s hA hi + (fun j => delta j) (fun j => radius j) + (fun j => allocatedUnitProfileWidth_pos (hR j) (hσ j) _) hp' (hMP.trans hPP) + (fun j => (hRP j).trans hPP) + (fun j => allocatedUnitProfileWidth_inverse_exp _ hP (hR j) (hσ j) (hRi j) (hσi j) (hcount j)) + (fun _ => H) (fun _ => hH) + have hlog := (allocatedDensityLog_bounds (G := G) B α O hP).2.1.trans + (allocatedJetSupportLog_bounds (G := G) B α O hP).2.1 + exact (NNReal.coe_le_coe.mpr (hf.2.2.2 j)).trans (Real.exp_le_exp.mpr hlog) + +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U basis S.value) + (allocatedPrincipalSides B U basis S)) + +theorem allocatedContinuousKernelDensity_zero_off_box (hσ1 : ∀ j, σ j ≤ 1) + (j : Fin m) (i : I j) + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) + (hy : ‖y‖ ≤ 1) (z : O j → ℝ) (hz : outputRadius < ‖z‖) : + allocatedContinuousKernelDensity B U basis S j i x u (rows j) (s j) (hA j) y z = 0 := by + cases Subsingleton.elim dG (Classical.decEq G) + have hr := allocatedKernelRadius_bound B U basis hR hσ S x rows s hA hM hi hP hMP hRP hRi hσi hcount j + (H := 1) zero_lt_one + have hz' := hr.trans_lt hz + exact allocatedContinuousKernelDensity_support_data B U basis hR hσ S j x u (rows j) (s j) (hA j) i + (hσ1 j) y hy z hz' + +theorem allocatedIntegerKernelDensity_zero_off_box (hσ1 : ∀ j, σ j ≤ 1) + (j : Fin m) (i : Fin (n j)) + (y : PrincipalAxisParameter (B := B) (h := layerSamplerDegree I n) (α := α) (fun a => ¬grid a) → ℝ) + (hy : ‖y‖ ≤ 1) (z : O j → ℤ) + (hz : z ∉ rectangularWeightIndices (fun _ => 0) (fun _ => (basisAxisScale (basis j) i : ℝ)) outputRadius) : + allocatedIntegerKernelDensity B U basis S j i x u (rows j) (s j) (hA j) y + (fun o => (z o : ℝ)/(basisAxisScale (basis j) i : ℝ)) = 0 := by + cases Subsingleton.elim dG (Classical.decEq G) + have hH : (0 : ℝ) < basisAxisScale (basis j) i := Nat.cast_pos.mpr (basisAxisScale_pos (basis j) i) + have hn : outputRadius < ‖fun o => (z o : ℝ)/(basisAxisScale (basis j) i : ℝ)‖ := + lt_of_not_ge (fun h => hz (mem_rectangularWeightIndices_zero_of_norm_le _ (fun _ => hH) z h)) + have hr := allocatedKernelRadius_bound B U basis hR hσ S x rows s hA hM hi hP hMP hRP hRi hσi hcount j hH + have hz' := hr.trans_lt hn + exact allocatedIntegerKernelDensity_support_data B U basis hR hσ S j x u (rows j) (s j) (hA j) i + (hσ1 j) y hy _ hz' + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankActualRead.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankActualRead.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab4c0644f1af18d5939516be18e0a76399c033de --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankActualRead.lean @@ -0,0 +1,164 @@ +import OAI.Combinatorics.Progressions.Polynomial.AllocatedModularRankTaggedPolynomials + +namespace OAI + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +theorem extend_selected_original {A K R : Type*} (slot : A → K) + (hinj : Function.Injective slot) (c : K → R) : + Function.extend slot (fun a => c (slot a)) c = c := by + funext k + by_cases hk : k ∈ Set.range slot + · obtain ⟨a,rfl⟩ := hk + exact hinj.extend_apply _ _ a + · exact Function.extend_apply' _ _ k hk + +namespace VectorPolynomial +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + [Fintype G] [∀ j, Fintype (I j)] [∀ a, Fintype (B a)] + {N L : ℕ} + +noncomputable def allocatedSelectedRankCoefficients + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) : + AllocatedTaggedRankOutput X E inactive j → Fin L → ZMod N + | .inl x, l => noise (spatialKernelRankSlot spatial l,x.val) + | .inr (.inl i), l => r j (kernelRankCoefficientSlot (layerSamplerDegree I n) kernel l) i + | .inr (.inr a), l => projection a + (canonicalPrincipalSubblockSlot (layerSamplerDegree I n) ⟨j,a.val⟩ (block a) l) + +noncomputable def allocatedOriginalTaggedTop + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) : + AllocatedTaggedRankOutput X E inactive j → + MvPolynomial (LayerSamplerLongVariables inactive G B) (ZMod N) + | .inl x => homogeneousComponent 1 + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (spatialRankPolynomial (fun d => noise (d,x.val)))) + | .inr (.inl i) => homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v (modularDeckPolynomial r j i)) + | .inr (.inr a) => homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) (projection a))) + +theorem allocatedTaggedRankPolynomial_original + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedTaggedRankOutput X E inactive j) : + allocatedTaggedRankPolynomial inactive j noise r projection spatial kernel block + (allocatedSelectedRankCoefficients inactive j noise r projection spatial kernel block) v o = + allocatedOriginalTaggedTop inactive j noise r projection v o := by + rcases o with x | i | a + · have hs : allocatedSelectedRankCoefficients inactive j noise r projection spatial kernel block + (.inl x) = fun l => noise (spatialKernelRankSlot spatial l,x.val) := by + funext l + rfl + simp only [allocatedTaggedRankPolynomial, allocatedOriginalTaggedTop, hs] + rw [extend_selected_original _ (spatialKernelRankSlot_injective spatial) (fun d => noise (d,x.val))] + · have hs : allocatedSelectedRankCoefficients inactive j noise r projection spatial kernel block + (.inr (.inl i)) = fun l => r j (kernelRankCoefficientSlot (layerSamplerDegree I n) kernel l) i := by + funext l + rfl + simp only [allocatedTaggedRankPolynomial, allocatedDegreeRankPolynomial, + allocatedOriginalTaggedTop, modularDeckPolynomial, resampleCoefficientDeckCoordinate_apply, hs] + rw [extend_selected_original _ (kernelRankCoefficientSlot_injective + (layerSamplerDegree I n) kernel (Nat.zero_lt_succ _)) (fun q => r j q i)] + · have hs : allocatedSelectedRankCoefficients inactive j noise r projection spatial kernel block + (.inr (.inr a)) = fun l => projection a + (canonicalPrincipalSubblockSlot (layerSamplerDegree I n) ⟨j,a.val⟩ (block a) l) := by + funext l + rfl + simp only [allocatedTaggedRankPolynomial, allocatedDegreeRankPolynomial, + allocatedOriginalTaggedTop, hs] + exact congrArg + (fun coefficients : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N => + homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) coefficients))) + (extend_selected_original _ (canonicalPrincipalSubblockSlot_injective + (G := G) (layerSamplerDegree I n) ⟨j,a.val⟩ (Nat.zero_lt_succ _) (block a)) (projection a)) + +theorem allocatedOriginalTaggedTop_eq_designated + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedTaggedRankOutput X E inactive j) : + allocatedOriginalTaggedTop inactive j noise r projection v o = + designatedVectorComponent (allocatedTaggedRankBlock inactive j spatial kernel block) + (allocatedTaggedRankResidual inactive j noise r projection spatial kernel block) + (allocatedSelectedRankCoefficients inactive j noise r projection spatial kernel block) o := by + rw [← allocatedTaggedRankPolynomial_original inactive j noise r projection spatial kernel block v o] + exact allocatedTaggedRankPolynomial_eq_designated inactive j noise r projection spatial kernel block _ v o + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + {N L : ℕ} + +theorem allocatedSelectedRankCoefficients_read + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (f : AllocatedActualCoefficientIndex G X I E n B → ZMod N) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedTaggedRankOutput X E inactive j) (l : Fin L) : + allocatedSelectedRankCoefficients inactive j (allocatedReadNoise f) (allocatedReadDeck f) + (fun a => allocatedReadProjection f ⟨j, a.val⟩) spatial (kernel j) (block j) o l = + f (allocatedActualCoefficientSlot inactive spatial kernel block ⟨j, o, l⟩) := by + rcases o with x | i | a <;> rfl + +theorem allocatedSelectedRankCoefficients_read_function + (inactive : LayerSamplerAxis I n → Prop) + (f : AllocatedActualCoefficientIndex G X I E n B → ZMod N) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) : + (fun t : AllocatedSelectedCoefficientIndex X E inactive L => + allocatedSelectedRankCoefficients inactive t.1 (allocatedReadNoise f) (allocatedReadDeck f) + (fun a => allocatedReadProjection f ⟨t.1, a.val⟩) spatial (kernel t.1) (block t.1) t.2.1 t.2.2) = + f ∘ allocatedActualCoefficientSlot inactive spatial kernel block := by + funext t + exact allocatedSelectedRankCoefficients_read inactive t.1 f spatial kernel block t.2.1 t.2.2 + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankActualRefreshBad.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankActualRefreshBad.lean new file mode 100644 index 0000000000000000000000000000000000000000..b123e609141f6f50eae1ddc5189e8bab1994f191 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankActualRefreshBad.lean @@ -0,0 +1,290 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedModularRankIntegerDecay + +namespace OAI + +section + +namespace Erdos3 + +theorem extend_restrict_disjoint_fiber {T A S K R : Type*} {U : T → Type*} + (full : (Σ t, U t) ↪ K) (slot : ∀ t, A ↪ U t) + (selected : S ↪ K) (reindex : T × A ≃ S) + (hselected : ∀ t a, selected (reindex (t,a)) = full ⟨t, slot t a⟩) + (f : K → R) (c : S → R) (t : T) (u : U t) : + Function.extend selected c f (full ⟨t,u⟩) = + Function.extend (slot t) (fun a => c (reindex (t,a))) + (fun z => f (full ⟨t,z⟩)) u := by + classical + by_cases hu : ∃ a, slot t a = u + · obtain ⟨a,rfl⟩ := hu + rw [← hselected t a, selected.injective.extend_apply, + (slot t).injective.extend_apply] + · rw [Function.extend_apply' _ _ _ hu] + apply Function.extend_apply' + rintro ⟨z,hz⟩ + obtain ⟨⟨s,a⟩,rfl⟩ := reindex.surjective z + rw [hselected] at hz + have htu := full.injective hz + have hst : s = t := congrArg Sigma.fst htu + subst s + have hlocal : slot t a = u := eq_of_heq (Sigma.mk.inj htu).2 + exact hu ⟨a,hlocal⟩ + +theorem map_extend_selected {A K R S : Type*} (slot : A ↪ K) + (map : R → S) (fixed : K → R) (fresh : A → R) (k : K) : + map (Function.extend slot fresh fixed k) = + Function.extend slot (fun a => map (fresh a)) (fun z => map (fixed z)) k := by + classical + by_cases hk : ∃ a, slot a = k + · obtain ⟨a,rfl⟩ := hk + rw [slot.injective.extend_apply, slot.injective.extend_apply] + · rw [Function.extend_apply' _ _ _ hk, Function.extend_apply' _ _ _ hk] + +end Erdos3 + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + +def allocatedCongruenceCoefficientReindex + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) : + ((Σ j : Fin m, AllocatedCongruenceRankOutput X E inactive j) × Fin L) ≃ + AllocatedCongruenceCoefficientIndex X E inactive L where + toFun k := ⟨k.1.1, k.1.2, k.2⟩ + invFun k := (⟨k.1,k.2.1⟩,k.2.2) + left_inv _ := rfl + right_inv _ := rfl + +theorem allocatedActualRefresh_component {R : Type*} + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → R) + (c : AllocatedCongruenceCoefficientIndex X E inactive L → R) + (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) + (q : AllocatedRankComponentCoefficient (G := G) (B := B) inactive j o) : + Function.extend (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + c f (allocatedRankComponentCoefficientEmbedding inactive ⟨⟨j,o⟩,q⟩) = + Function.extend (allocatedRankComponentSelectedEmbedding inactive spatial kernel block j o) + (fun l => c ⟨j,o,l⟩) + (fun z => f (allocatedRankComponentCoefficientEmbedding inactive ⟨⟨j,o⟩,z⟩)) q := by + exact extend_restrict_disjoint_fiber + (allocatedRankComponentCoefficientEmbedding inactive) + (fun t => allocatedRankComponentSelectedEmbedding inactive spatial kernel block t.1 t.2) + (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + (allocatedCongruenceCoefficientReindex inactive L) + (fun t l => (allocatedRankComponentCoefficientEmbedding_selected + inactive spatial kernel block t.1 t.2 l).symm) f c ⟨j,o⟩ q + +theorem allocatedActualRefresh_component_reduce + (N : ℕ) (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (c : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) + (q : AllocatedRankComponentCoefficient (G := G) (B := B) inactive j o) : + ((Function.extend (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + c f (allocatedRankComponentCoefficientEmbedding inactive ⟨⟨j,o⟩,q⟩) : ℤ) : ZMod N) = + Function.extend (allocatedRankComponentSelectedEmbedding inactive spatial kernel block j o) + (fun l => (c ⟨j,o,l⟩ : ZMod N)) + (fun z => (f (allocatedRankComponentCoefficientEmbedding inactive ⟨⟨j,o⟩,z⟩) : ZMod N)) q := by + rw [allocatedActualRefresh_component] + exact map_extend_selected + (allocatedRankComponentSelectedEmbedding inactive spatial kernel block j o) + (fun z : ℤ => (z : ZMod N)) _ _ q + +variable [Fintype G] [∀ j, Fintype (I j)] [∀ a, Fintype (B a)] + +theorem allocatedActualRefresh_original_congruence + (N : ℕ) (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (c : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + (j : Fin m) (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedCongruenceRankOutput X E inactive j) : + let refreshed := fun z => ((Function.extend + (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) c f z : ℤ) : ZMod N) + let fixed := fun z => (f z : ZMod N) + allocatedOriginalTaggedTop inactive j (allocatedReadNoise refreshed) (allocatedReadDeck refreshed) + (fun a => allocatedReadProjection refreshed ⟨j,a.val⟩) v + (allocatedCongruenceOutputEmbedding inactive j o) = + allocatedCongruenceRankPolynomial inactive j (allocatedReadNoise fixed) (allocatedReadDeck fixed) + (fun a => allocatedReadProjection fixed ⟨j,a.val⟩) spatial (kernel j) (block j) + (fun z l => (c ⟨j,z,l⟩ : ZMod N)) v o := by + dsimp only + let fresh : AllocatedCongruenceRankOutput X E inactive j → Fin L → ZMod N := + fun z l => (c ⟨j,z,l⟩ : ZMod N) + have hext (z : AllocatedCongruenceRankOutput X E inactive j) : + Function.extend (allocatedCongruenceOutputEmbedding inactive j) fresh (fun _ _ => 0) + (allocatedCongruenceOutputEmbedding inactive j z) = fresh z := + (allocatedCongruenceOutputEmbedding inactive j).injective.extend_apply _ _ z + rcases o with x | i | a + · have hx : Function.extend (allocatedCongruenceOutputEmbedding inactive j) fresh + (fun _ _ => 0) (.inl x) = fresh (.inl x) := hext (.inl x) + have hc := funext (allocatedActualRefresh_component_reduce N inactive spatial kernel block + f c j (.inl x)) + change homogeneousComponent 1 (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v (spatialRankPolynomial _)) = _ + unfold allocatedCongruenceRankPolynomial + change _ = homogeneousComponent 1 (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v (spatialRankPolynomial + (Function.extend (spatialKernelRankSlot spatial) + (Function.extend (allocatedCongruenceOutputEmbedding inactive j) fresh (fun _ _ => 0) + (.inl x)) _))) + rw [hx] + exact congrArg (fun coefficients => homogeneousComponent 1 + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v (spatialRankPolynomial coefficients))) hc + · have hi : Function.extend (allocatedCongruenceOutputEmbedding inactive j) fresh + (fun _ _ => 0) (.inr (.inl i)) = fresh (.inr (.inl i)) := hext (.inr (.inl i)) + have hc := funext (allocatedActualRefresh_component_reduce N inactive spatial kernel block + f c j (.inr (.inl i))) + unfold allocatedCongruenceRankPolynomial + simp only [allocatedCongruenceOutputEmbedding_deck, allocatedTaggedRankPolynomial, + allocatedDegreeRankPolynomial, allocatedOriginalTaggedTop, modularDeckPolynomial, + resampleCoefficientDeckCoordinate_apply] + change _ = homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) + (Function.extend (kernelRankCoefficientSlot (layerSamplerDegree I n) (kernel j)) + (Function.extend (allocatedCongruenceOutputEmbedding inactive j) fresh (fun _ _ => 0) + (.inr (.inl i))) _))) + rw [hi] + exact congrArg (fun coefficients => homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) coefficients))) hc + · have ha : Function.extend (allocatedCongruenceOutputEmbedding inactive j) fresh + (fun _ _ => 0) (.inr (.inr (allocatedCongruenceIntegerEmbedding inactive j a))) = + fresh (.inr (.inr a)) := hext (.inr (.inr a)) + have hc := funext (allocatedActualRefresh_component_reduce N inactive spatial kernel block + f c j (.inr (.inr a))) + unfold allocatedCongruenceRankPolynomial + simp only [allocatedCongruenceOutputEmbedding_integer, allocatedTaggedRankPolynomial, + allocatedDegreeRankPolynomial, allocatedOriginalTaggedTop] + change _ = homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) + (Function.extend (canonicalPrincipalSubblockSlot (layerSamplerDegree I n) + ⟨j,.inr a.val⟩ (block j (allocatedCongruenceIntegerEmbedding inactive j a))) + (Function.extend (allocatedCongruenceOutputEmbedding inactive j) fresh (fun _ _ => 0) + (.inr (.inr (allocatedCongruenceIntegerEmbedding inactive j a)))) _))) + rw [ha] + exact congrArg (fun coefficients => homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (j.val + 1) coefficients))) hc + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +variable (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (c : AllocatedCongruenceCoefficientIndex X E inactive L → ℤ) + +local notation "refreshed" => Function.extend + (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) c f +local notation "selected" => allocatedCongruenceIntegerSelectedCoefficients inactive + (allocatedReadNoise refreshed) (allocatedReadDeck refreshed) + (fun j a => allocatedReadProjection refreshed (Sigma.mk j (Subtype.val a))) spatial kernel block + +omit [Fintype X] [∀ j, Fintype (E j)] in + +theorem allocatedActualRefresh_rank_polynomial + (N : ℕ) (j : Fin m) (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedCongruenceRankOutput X E inactive j) : + allocatedCongruenceRankPolynomial inactive j + (fun q => ((allocatedReadNoise refreshed q : ℤ) : ZMod N)) + (fun j q i => ((allocatedReadDeck refreshed j q i : ℤ) : ZMod N)) + (fun a q => ((allocatedReadProjection refreshed ⟨j,a.val⟩ q : ℤ) : ZMod N)) + spatial (kernel j) (block j) (fun z l => (selected ⟨j,z,l⟩ : ZMod N)) v o = + allocatedCongruenceRankPolynomial inactive j + (fun q => ((allocatedReadNoise f q : ℤ) : ZMod N)) + (fun j q i => ((allocatedReadDeck f j q i : ℤ) : ZMod N)) + (fun a q => ((allocatedReadProjection f ⟨j,a.val⟩ q : ℤ) : ZMod N)) + spatial (kernel j) (block j) (fun z l => (c ⟨j,z,l⟩ : ZMod N)) v o := by + simp only [allocatedCongruenceIntegerSelectedCoefficients_reduce, + allocatedCongruenceRankPolynomial_original] + exact allocatedActualRefresh_original_congruence N inactive spatial kernel block f c j v o + +theorem allocatedActualRefresh_rank_probability + (N : ℕ) [NeZero N] (j : Fin m) (v : LayerSamplerVariables G I n B → ZMod N) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod N) : + allocatedCongruenceRankFailureProbability inactive j + (fun q => ((allocatedReadNoise refreshed q : ℤ) : ZMod N)) + (fun j q i => ((allocatedReadDeck refreshed j q i : ℤ) : ZMod N)) + (fun a q => ((allocatedReadProjection refreshed ⟨j,a.val⟩ q : ℤ) : ZMod N)) + spatial (kernel j) (block j) (fun z l => (selected ⟨j,z,l⟩ : ZMod N)) v w = + allocatedCongruenceRankFailureProbability inactive j + (fun q => ((allocatedReadNoise f q : ℤ) : ZMod N)) + (fun j q i => ((allocatedReadDeck f j q i : ℤ) : ZMod N)) + (fun a q => ((allocatedReadProjection f ⟨j,a.val⟩ q : ℤ) : ZMod N)) + spatial (kernel j) (block j) (fun z l => (c ⟨j,z,l⟩ : ZMod N)) v w := by + unfold allocatedCongruenceRankFailureProbability + simp only [allocatedActualRefresh_rank_polynomial] + +theorem allocatedActualRefresh_modulusBad + (C : ℝ) (N : ℕ) [NeZero N] : + allocatedCongruenceModulusBad inactive + (allocatedReadNoise refreshed) (allocatedReadDeck refreshed) + (fun j a => allocatedReadProjection refreshed ⟨j,a.val⟩) spatial kernel block + C N (fun z => (selected z : ZMod N)) = + allocatedCongruenceModulusBad inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j,a.val⟩) spatial kernel block + C N (fun z => (c z : ZMod N)) := by + unfold allocatedCongruenceModulusBad + simp only [allocatedActualRefresh_rank_probability] + +theorem allocatedActualRefresh_rankBad + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) (p a : ℕ) : + allocatedCongruenceRankBad inactive + (allocatedReadNoise refreshed) (allocatedReadDeck refreshed) + (fun j a => allocatedReadProjection refreshed ⟨j,a.val⟩) spatial kernel block + P C p a selected = + allocatedCongruenceRankBad inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j,a.val⟩) spatial kernel block P C p a c := by + unfold allocatedCongruenceRankBad smoothResiduePrimeBad + apply propext + apply exists_congr + intro hp + let : NeZero p := inferInstanceAs (NeZero (⟨p,hp⟩ : P).val) + exact (allocatedActualRefresh_modulusBad inactive spatial kernel block f c C (p ^ a)).to_iff + +theorem allocatedActualRefresh_badDepth + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) (C : ℝ) (p : ℕ) : + allocatedCongruenceBadDepth inactive + (allocatedReadNoise refreshed) (allocatedReadDeck refreshed) + (fun j a => allocatedReadProjection refreshed ⟨j,a.val⟩) spatial kernel block P A C p = + largestTestedBadDepth A + (allocatedCongruenceRankBad inactive + (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j,a.val⟩) spatial kernel block P C) p c := by + unfold allocatedCongruenceBadDepth largestTestedBadDepth + simp only [allocatedActualRefresh_rankBad] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankBadProduct.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankBadProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb82e8b28de0d94d83391e9efd9d21d23caf8552 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankBadProduct.lean @@ -0,0 +1,873 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankActualRead +import OAI.Combinatorics.Progressions.Linear.SmoothCoefficientRankBadProduct + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial VectorPolynomial +open scoped BigOperators Classical + +section RingMap + +variable {K L A R S : Type*} [CommRing R] [CommRing S] + +theorem homogeneousComponent_map_ringHom (f : R →+* S) (h : ℕ) (P : MvPolynomial K R) : + homogeneousComponent h (P.map f) = (homogeneousComponent h P).map f := by + ext a + simp only [coeff_homogeneousComponent, coeff_map] + split_ifs <;> simp only [map_zero] + +theorem modularBoundedCoefficientPolynomial_map [Fintype K] + (f : R →+* S) (h : ℕ) (c : BoundedCoefficientExponent K h → R) : + modularBoundedCoefficientPolynomial h (fun e => f (c e)) = + (modularBoundedCoefficientPolynomial h c).map f := by + simp only [modularBoundedCoefficientPolynomial, map_sum, MvPolynomial.map_monomial] + +theorem modularUnselectedCoefficientPolynomial_map [Fintype K] [Fintype A] + (f : R →+* S) (h : ℕ) (slot : A → BoundedCoefficientExponent K h) + (fixed : BoundedCoefficientExponent K h → R) : + modularUnselectedCoefficientPolynomial h slot (fun e => f (fixed e)) = + (modularUnselectedCoefficientPolynomial h slot fixed).map f := by + simp only [modularUnselectedCoefficientPolynomial, map_sum, MvPolynomial.map_monomial] + +theorem restrictedUnselectedTop_map [Fintype K] [Fintype A] + (f : R →+* S) (retained : L → K) (hinj : Function.Injective retained) + (h : ℕ) (slot : A → BoundedCoefficientExponent K h) + (fixed : BoundedCoefficientExponent K h → R) : + killCompl hinj (homogeneousComponent h + (modularUnselectedCoefficientPolynomial h slot (fun e => f (fixed e)))) = + (killCompl hinj (homogeneousComponent h + (modularUnselectedCoefficientPolynomial h slot fixed))).map f := by + rw [modularUnselectedCoefficientPolynomial_map, homogeneousComponent_map_ringHom, + killCompl_map] + +theorem restrictedMonomialSumTop_map {V : Type*} + (f : R →+* S) (retained : L → K) (hinj : Function.Injective retained) + (h : ℕ) (slots : Finset V) (exponent : V → K →₀ ℕ) (fixed : V → R) : + killCompl hinj (homogeneousComponent h + (∑ e ∈ slots, monomial (exponent e) (f (fixed e)))) = + (killCompl hinj (homogeneousComponent h + (∑ e ∈ slots, monomial (exponent e) (fixed e)))).map f := by + have hs : (∑ e ∈ slots, monomial (exponent e) (f (fixed e))) = + (∑ e ∈ slots, monomial (exponent e) (fixed e)).map f := by + simp only [map_sum, MvPolynomial.map_monomial] + rw [hs, homogeneousComponent_map_ringHom, killCompl_map] + +end RingMap + +section ActualResidual + +variable {D G R S : Type*} {B : D → Type*} [Fintype D] [Fintype G] + [∀ d, Fintype (B d)] [CommRing R] [CommRing S] + +theorem canonicalSelectedTopResidual_map (f : R →+* S) (h : D → ℕ) (d : D) + {J : ℕ} (block : Fin J ↪ B d) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d) → R) : + canonicalSelectedTopResidual h d block (fun e => f (fixed e)) = + (canonicalSelectedTopResidual h d block fixed).map f := by + unfold canonicalSelectedTopResidual + rw [modularUnselectedCoefficientPolynomial_map, homogeneousComponent_map_ringHom] + +theorem canonicalSelectedLongTopResidual_map (f : R →+* S) + (inactive : D → Prop) (h : D → ℕ) (d : {d // ¬ inactive d}) + {J : ℕ} (block : Fin J ↪ B d.val) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d.val) → R) : + canonicalSelectedLongTopResidual inactive h d block (fun e => f (fixed e)) = + (canonicalSelectedLongTopResidual inactive h d block fixed).map f := by + unfold canonicalSelectedLongTopResidual + rw [canonicalSelectedTopResidual_map, killCompl_map] + +theorem canonicalSelectedLongTopResidual_integer_reduce (N : ℕ) + (inactive : D → Prop) (h : D → ℕ) (d : {d // ¬ inactive d}) + {J : ℕ} (block : Fin J ↪ B d.val) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d.val) → ℤ) : + canonicalSelectedLongTopResidual inactive h d block (fun e => (fixed e : ZMod N)) = + (canonicalSelectedLongTopResidual inactive h d block fixed).map + (Int.castRingHom (ZMod N)) := + canonicalSelectedLongTopResidual_map (Int.castRingHom (ZMod N)) inactive h d block fixed + +end ActualResidual +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + [Fintype G] [∀ j, Fintype (I j)] [∀ a, Fintype (B a)] + {L : ℕ} + +noncomputable def allocatedTaggedRankIntegerResidual + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) : + AllocatedTaggedRankOutput X E inactive j → + MvPolynomial (LayerSamplerLongVariables inactive G B) ℤ + | .inl x => killCompl (allocatedLongEmbedding inactive).injective + (homogeneousComponent 1 + (∑ d ∈ Finset.univ.filter (fun d => d ∉ Set.range + (spatialKernelRankSlot (P := PrincipalTupleIndex B (layerSamplerDegree I n)) spatial)), + MvPolynomial.monomial (spatialRankExponent d) (noise (d,x.val)))) + | .inr (.inl i) => killCompl (allocatedLongEmbedding inactive).injective + (homogeneousComponent (j.val + 1) + (modularUnselectedCoefficientPolynomial (j.val + 1) + (kernelRankCoefficientSlot (layerSamplerDegree I n) kernel) (fun q => r j q i))) + | .inr (.inr a) => canonicalSelectedLongTopResidual inactive (layerSamplerDegree I n) + (allocatedDegreeLongAxis inactive j a) (block a) (projection a) + +theorem allocatedTaggedRankIntegerResidual_reduce + (N : ℕ) (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedTaggedRankOutput X E inactive j) : + (allocatedTaggedRankIntegerResidual inactive j noise r projection spatial kernel block o).map + (Int.castRingHom (ZMod N)) = + allocatedTaggedRankResidual inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) + (fun a q => (projection a q : ZMod N)) spatial kernel block o := by + cases o with + | inl x => + exact (restrictedMonomialSumTop_map (Int.castRingHom (ZMod N)) + (allocatedLongEmbedding inactive) (allocatedLongEmbedding inactive).injective 1 + (Finset.univ.filter (fun d => d ∉ Set.range + (spatialKernelRankSlot (P := PrincipalTupleIndex B (layerSamplerDegree I n)) spatial))) + spatialRankExponent (fun d => noise (d,x.val))).symm + | inr o => + cases o with + | inl i => + exact (restrictedUnselectedTop_map (Int.castRingHom (ZMod N)) + (allocatedLongEmbedding inactive) (allocatedLongEmbedding inactive).injective + (j.val + 1) (kernelRankCoefficientSlot (layerSamplerDegree I n) kernel) + (fun q => r j q i)).symm + | inr a => + exact (canonicalSelectedLongTopResidual_integer_reduce N inactive (layerSamplerDegree I n) + (allocatedDegreeLongAxis inactive j a) (block a) (projection a)).symm + +theorem allocatedTaggedRankPolynomial_eq_integer_designated + (N : ℕ) (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (c : AllocatedTaggedRankOutput X E inactive j → Fin L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedTaggedRankOutput X E inactive j) : + allocatedTaggedRankPolynomial inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun a q => (projection a q : ZMod N)) + spatial kernel block c v o = + designatedVectorComponent (allocatedTaggedRankBlock inactive j spatial kernel block) + (fun o => (allocatedTaggedRankIntegerResidual inactive j noise r projection + spatial kernel block o).map (Int.castRingHom (ZMod N))) c o := by + simp only [allocatedTaggedRankIntegerResidual_reduce, + allocatedTaggedRankPolynomial_eq_designated] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable def allocatedTaggedRankFailureProbability {N L : ℕ} [NeZero N] + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (c : AllocatedTaggedRankOutput X E inactive j → Fin L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) + (w : AllocatedTaggedRankOutput X E inactive j → ZMod N) : ℝ := + 𝔼 u : Fin j.val → LayerSamplerLongVariables inactive G B → ZMod N, + if polynomialLinearRow (polynomialIterDifference j.val + (∑ o, w o • allocatedTaggedRankPolynomial inactive j noise r projection + spatial kernel block c v o) u) = 0 then 1 else 0 + +theorem allocatedTaggedRankFailureProbability_eq_designated {N L : ℕ} [NeZero N] + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (c : AllocatedTaggedRankOutput X E inactive j → Fin L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) + (w : AllocatedTaggedRankOutput X E inactive j → ZMod N) : + allocatedTaggedRankFailureProbability inactive j noise r projection spatial kernel block c v w = + vectorDesignatedRankFailureProbability N j.val + (allocatedTaggedRankBlock inactive j spatial kernel block) + (allocatedTaggedRankResidual inactive j noise r projection spatial kernel block) w c := by + unfold allocatedTaggedRankFailureProbability vectorDesignatedRankFailureProbability + simp only [allocatedTaggedRankPolynomial_eq_designated] + +theorem allocatedTaggedRank_exceptional_probability {p a L D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod (p ^ a)) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E (p ^ a)) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod (p ^ a)) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (v : LayerSamplerVariables G I n B → ZMod (p ^ a)) + (hD : Fintype.card X + ∑ j : Fin m, + (Fintype.card (E j) + Fintype.card (I j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hq : max 2 ((m : ℝ) ^ (4 / modularRankSmallBallExponent m)) ≤ (p : ℝ) ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (FiniteProbabilityWeights.uniform + (∀ j : Fin m, AllocatedTaggedRankOutput X E inactive j → Fin L → ZMod (p ^ a))).eventProbability + (fun c => ∃ j : Fin m, ∃ w : AllocatedTaggedRankOutput X E inactive j → ZMod (p ^ a), + (∃ o, IsUnit (w o)) ∧ ((p : ℝ) ^ a) ^ (-C) < + allocatedTaggedRankFailureProbability inactive j noise r (projection j) + spatial (kernel j) (block j) (c j) v w) ≤ + ((p : ℝ) ^ a) ^ (-(10 : ℝ)) := by + have hcount (j : Fin m) : Fintype.card (AllocatedTaggedRankOutput X E inactive j) ≤ D := + (Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ j)).trans + ((allocatedTaggedRankOutput_sum_card_le (X := X) (E := E) hm inactive).trans hD) + have h := taggedVectorDesignatedRank_exceptional_probability + (T := Fin m) (A := Fin L) (I := LayerSamplerLongVariables inactive G B) + (B := AllocatedTaggedRankOutput X E inactive) (s := m) (m := D) hp ha + (fun j => j.val) (fun j => Nat.succ_le_of_lt j.isLt) (by simp only [Fintype.card_fin, le_refl]) hcount + (fun j => allocatedTaggedRankBlock inactive j spatial (kernel j) (block j)) + (fun j => allocatedTaggedRankResidual inactive j noise r (projection j) + spatial (kernel j) (block j)) + (fun j => allocatedTaggedRankBlock_card inactive j spatial (kernel j) (block j)) + (fun j => allocatedTaggedRankBlock_disjoint inactive j spatial (kernel j) (block j)) + hC hq (by simpa only [Fintype.card_fin] using hL) + simpa only [allocatedTaggedRankFailureProbability_eq_designated] using h + +theorem allocatedTaggedRank_exceptional_probability_uniform {p a L D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod (p ^ a)) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E (p ^ a)) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod (p ^ a)) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (hD : Fintype.card X + ∑ j : Fin m, + (Fintype.card (E j) + Fintype.card (I j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hq : max 2 ((m : ℝ) ^ (4 / modularRankSmallBallExponent m)) ≤ (p : ℝ) ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (FiniteProbabilityWeights.uniform + (∀ j : Fin m, AllocatedTaggedRankOutput X E inactive j → Fin L → ZMod (p ^ a))).eventProbability + (fun c => ∃ v : LayerSamplerVariables G I n B → ZMod (p ^ a), + ∃ j : Fin m, ∃ w : AllocatedTaggedRankOutput X E inactive j → ZMod (p ^ a), + (∃ o, IsUnit (w o)) ∧ ((p : ℝ) ^ a) ^ (-C) < + allocatedTaggedRankFailureProbability inactive j noise r (projection j) + spatial (kernel j) (block j) (c j) v w) ≤ + ((p : ℝ) ^ a) ^ (-(10 : ℝ)) := by + have h := allocatedTaggedRank_exceptional_probability hm hp ha inactive noise r projection + spatial kernel block (fun _ => 0) hD hC hq hL + apply le_trans ?_ h + apply FiniteProbabilityWeights.eventProbability_mono + intro c hc + obtain ⟨v, j, w, hw, hbad⟩ := hc + refine ⟨j, w, hw, ?_⟩ + simpa only [allocatedTaggedRankFailureProbability_eq_designated] using hbad + +noncomputable def allocatedCongruenceRankPolynomial {N L : ℕ} + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (c : AllocatedCongruenceRankOutput X E inactive j → Fin L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedCongruenceRankOutput X E inactive j) : + MvPolynomial (LayerSamplerLongVariables inactive G B) (ZMod N) := + allocatedTaggedRankPolynomial inactive j noise r projection spatial kernel block + (Function.extend (allocatedCongruenceOutputEmbedding inactive j) c (fun _ _ => 0)) v + (allocatedCongruenceOutputEmbedding inactive j o) + +omit [Fintype X] [∀ j, Fintype (E j)] in + +theorem allocatedCongruenceRankPolynomial_eq_actual {N L : ℕ} + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (c : AllocatedTaggedRankOutput X E inactive j → Fin L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedCongruenceRankOutput X E inactive j) : + allocatedCongruenceRankPolynomial inactive j noise r projection spatial kernel block + (fun o => c (allocatedCongruenceOutputEmbedding inactive j o)) v o = + allocatedTaggedRankPolynomial inactive j noise r projection spatial kernel block c v + (allocatedCongruenceOutputEmbedding inactive j o) := by + unfold allocatedCongruenceRankPolynomial + simp only [allocatedTaggedRankPolynomial_eq_designated, designatedVectorComponent, + (allocatedCongruenceOutputEmbedding (X := X) (E := E) inactive j).injective.extend_apply] + +noncomputable def allocatedCongruenceRankFailureProbability {N L : ℕ} [NeZero N] + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (c : AllocatedCongruenceRankOutput X E inactive j → Fin L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod N) : ℝ := + 𝔼 u : Fin j.val → LayerSamplerLongVariables inactive G B → ZMod N, + if polynomialLinearRow (polynomialIterDifference j.val + (∑ o, w o • allocatedCongruenceRankPolynomial inactive j noise r projection + spatial kernel block c v o) u) = 0 then 1 else 0 + +theorem allocatedCongruenceRankFailureProbability_eq_designated {N L : ℕ} [NeZero N] + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (c : AllocatedCongruenceRankOutput X E inactive j → Fin L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod N) : + allocatedCongruenceRankFailureProbability inactive j noise r projection spatial kernel block c v w = + vectorDesignatedRankFailureProbability N j.val + (fun o => allocatedTaggedRankBlock inactive j spatial kernel block + (allocatedCongruenceOutputEmbedding inactive j o)) + (fun o => allocatedTaggedRankResidual inactive j noise r projection spatial kernel block + (allocatedCongruenceOutputEmbedding inactive j o)) w c := by + unfold allocatedCongruenceRankFailureProbability vectorDesignatedRankFailureProbability + allocatedCongruenceRankPolynomial + simp only [allocatedTaggedRankPolynomial_eq_designated, designatedVectorComponent, + (allocatedCongruenceOutputEmbedding (X := X) (E := E) inactive j).injective.extend_apply] + +theorem allocatedCongruenceRank_exceptional_probability {p a L D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod (p ^ a)) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E (p ^ a)) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod (p ^ a)) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (v : LayerSamplerVariables G I n B → ZMod (p ^ a)) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hq : max 2 ((m : ℝ) ^ (4 / modularRankSmallBallExponent m)) ≤ (p : ℝ) ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (FiniteProbabilityWeights.uniform + (∀ j : Fin m, AllocatedCongruenceRankOutput X E inactive j → Fin L → ZMod (p ^ a))).eventProbability + (fun c => ∃ j : Fin m, ∃ w : AllocatedCongruenceRankOutput X E inactive j → ZMod (p ^ a), + (∃ o, IsUnit (w o)) ∧ ((p : ℝ) ^ a) ^ (-C) < + allocatedCongruenceRankFailureProbability inactive j noise r (projection j) + spatial (kernel j) (block j) (c j) v w) ≤ + ((p : ℝ) ^ a) ^ (-(10 : ℝ)) := by + have hcount (j : Fin m) : Fintype.card (AllocatedCongruenceRankOutput X E inactive j) ≤ D := + (Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ j)).trans + ((allocatedCongruenceRankOutput_sum_card_le (X := X) (E := E) hm inactive).trans hD) + have h := taggedVectorDesignatedRank_exceptional_probability + (T := Fin m) (A := Fin L) (I := LayerSamplerLongVariables inactive G B) + (B := AllocatedCongruenceRankOutput X E inactive) (s := m) (m := D) hp ha + (fun j => j.val) (fun j => Nat.succ_le_of_lt j.isLt) + (by simp only [Fintype.card_fin, le_refl]) hcount + (fun j o => allocatedTaggedRankBlock inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o)) + (fun j o => allocatedTaggedRankResidual inactive j noise r (projection j) + spatial (kernel j) (block j) (allocatedCongruenceOutputEmbedding inactive j o)) + (fun j o => allocatedTaggedRankBlock_card inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o)) + (fun j o => allocatedTaggedRankBlock_disjoint inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o)) + hC hq (by simpa only [Fintype.card_fin] using hL) + simpa only [allocatedCongruenceRankFailureProbability_eq_designated] using h + +theorem allocatedCongruenceRank_exceptional_probability_uniform {p a L D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod (p ^ a)) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E (p ^ a)) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod (p ^ a)) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hq : max 2 ((m : ℝ) ^ (4 / modularRankSmallBallExponent m)) ≤ (p : ℝ) ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (FiniteProbabilityWeights.uniform + (∀ j : Fin m, AllocatedCongruenceRankOutput X E inactive j → Fin L → ZMod (p ^ a))).eventProbability + (fun c => ∃ v : LayerSamplerVariables G I n B → ZMod (p ^ a), + ∃ j : Fin m, ∃ w : AllocatedCongruenceRankOutput X E inactive j → ZMod (p ^ a), + (∃ o, IsUnit (w o)) ∧ ((p : ℝ) ^ a) ^ (-C) < + allocatedCongruenceRankFailureProbability inactive j noise r (projection j) + spatial (kernel j) (block j) (c j) v w) ≤ + ((p : ℝ) ^ a) ^ (-(10 : ℝ)) := by + have h := allocatedCongruenceRank_exceptional_probability hm hp ha inactive noise r projection + spatial kernel block (fun _ => 0) hD hC hq hL + apply le_trans ?_ h + apply FiniteProbabilityWeights.eventProbability_mono + intro c hc + obtain ⟨v, j, w, hw, hbad⟩ := hc + refine ⟨j, w, hw, ?_⟩ + simpa only [allocatedCongruenceRankFailureProbability_eq_designated] using hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + +abbrev AllocatedCongruenceScalarIndex (X : Type*) (E : Fin m → Type*) + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) := + Σ j : Fin m, AllocatedCongruenceRankOutput X E inactive j × Fin L + +def allocatedCongruenceRankBlockFamily (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) : + ∀ j, AllocatedCongruenceRankOutput X E inactive j → Fin L → + Finset (LayerSamplerLongVariables inactive G B) := + fun j o => allocatedTaggedRankBlock inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o) + +variable [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable def allocatedCongruenceRankIntegerResidualFamily + (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) : + ∀ j, AllocatedCongruenceRankOutput X E inactive j → + MvPolynomial (LayerSamplerLongVariables inactive G B) ℤ := + fun j o => allocatedTaggedRankIntegerResidual inactive j noise r (projection j) + spatial (kernel j) (block j) (allocatedCongruenceOutputEmbedding inactive j o) + +variable (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + +local notation "rankS" => allocatedCongruenceRankBlockFamily (X := X) (E := E) inactive spatial kernel block +local notation "rankQ" => allocatedCongruenceRankIntegerResidualFamily inactive noise r projection spatial kernel block + +theorem allocatedCongruenceRankFailureProbability_eq_integer_model + (N : ℕ) [NeZero N] (x : AllocatedCongruenceScalarIndex X E inactive L → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) (j : Fin m) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod N) : + allocatedCongruenceRankFailureProbability inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun b q => (projection j b q : ZMod N)) + spatial (kernel j) (block j) (fun o l => x ⟨j, (o,l)⟩) v w = + vectorDesignatedRankFailureProbability N j.val (rankS j) + (fun o => (rankQ j o).map (Int.castRingHom (ZMod N))) w + (fun o l => x ⟨j, (o,l)⟩) := by + rw [allocatedCongruenceRankFailureProbability_eq_designated] + simp only [allocatedCongruenceRankIntegerResidualFamily, + allocatedTaggedRankIntegerResidual_reduce] + rfl + +def allocatedCongruenceModulusBad (C : ℝ) (N : ℕ) [NeZero N] + (x : AllocatedCongruenceScalarIndex X E inactive L → ZMod N) : Prop := + ∃ v : LayerSamplerVariables G I n B → ZMod N, ∃ j : Fin m, + ∃ w : AllocatedCongruenceRankOutput X E inactive j → ZMod N, + (∃ o, IsUnit (w o)) ∧ (N : ℝ) ^ (-C) < + allocatedCongruenceRankFailureProbability inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun b q => (projection j b q : ZMod N)) + spatial (kernel j) (block j) (fun o l => x ⟨j,(o,l)⟩) v w + +theorem allocatedCongruenceModulusBad_iff_scalarCoefficientBad + (C : ℝ) (N : ℕ) [NeZero N] + (x : AllocatedCongruenceScalarIndex X E inactive L → ZMod N) : + allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C N x ↔ + scalarCoefficientBad (fun j : Fin m => j.val) rankS rankQ C N x := by + unfold allocatedCongruenceModulusBad scalarCoefficientBad + simp only [allocatedCongruenceRankFailureProbability_eq_integer_model] + constructor + · rintro ⟨v, j, w, hw, hbad⟩ + exact ⟨j, w, hw, hbad⟩ + · rintro ⟨j, w, hw, hbad⟩ + exact ⟨fun _ => 0, j, w, hw, hbad⟩ + +def allocatedCongruenceRankBad (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) : + ℕ → ℕ → (AllocatedCongruenceScalarIndex X E inactive L → ℤ) → Prop := + smoothResiduePrimeBad P (fun p a => + allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C (p.val ^ a)) + +theorem allocatedCongruenceRankBad_eq_smoothCoefficientRankBad + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) : + allocatedCongruenceRankBad inactive noise r projection spatial kernel block P C = + smoothCoefficientRankBad P (fun j : Fin m => j.val) rankS rankQ C := by + funext p a x + apply propext + unfold allocatedCongruenceRankBad smoothCoefficientRankBad smoothResiduePrimeBad + apply exists_congr + intro hp + let : NeZero p := inferInstanceAs (NeZero (⟨p, hp⟩ : P).val) + exact allocatedCongruenceModulusBad_iff_scalarCoefficientBad + inactive noise r projection spatial kernel block C (p ^ a) _ + +theorem allocatedCongruenceModulusBad_good (C : ℝ) (N : ℕ) [NeZero N] + (x : AllocatedCongruenceScalarIndex X E inactive L → ZMod N) + (hgood : ¬ allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C N x) + (v : LayerSamplerVariables G I n B → ZMod N) (j : Fin m) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod N) (hw : ∃ o, IsUnit (w o)) : + allocatedCongruenceRankFailureProbability inactive j (fun q => (noise q : ZMod N)) + (fun j q i => (r j q i : ZMod N)) (fun b q => (projection j b q : ZMod N)) + spatial (kernel j) (block j) (fun o l => x ⟨j,(o,l)⟩) v w ≤ (N : ℝ) ^ (-C) := + le_of_not_gt (fun hbad => hgood ⟨v, j, w, hw, hbad⟩) + +theorem allocatedCongruenceRankBad_good + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) + (p : P) (a : ℕ) (x : AllocatedCongruenceScalarIndex X E inactive L → ℤ) + (hgood : ¬ allocatedCongruenceRankBad inactive noise r projection spatial kernel block + P C p.val a x) + (v : LayerSamplerVariables G I n B → ZMod (p.val ^ a)) (j : Fin m) + (w : AllocatedCongruenceRankOutput X E inactive j → ZMod (p.val ^ a)) + (hw : ∃ o, IsUnit (w o)) : + allocatedCongruenceRankFailureProbability inactive j (fun q => (noise q : ZMod (p.val ^ a))) + (fun j q i => (r j q i : ZMod (p.val ^ a))) + (fun b q => (projection j b q : ZMod (p.val ^ a))) + spatial (kernel j) (block j) (fun o l => (x ⟨j,(o,l)⟩ : ZMod (p.val ^ a))) v w ≤ + ((p.val ^ a : ℕ) : ℝ) ^ (-C) := by + have hmod : ¬ allocatedCongruenceModulusBad inactive noise r projection spatial kernel block + C (p.val ^ a) (fun i => (x i : ZMod (p.val ^ a))) := + fun hbad => hgood ⟨p.property, hbad⟩ + exact allocatedCongruenceModulusBad_good inactive noise r projection spatial kernel block C + (p.val ^ a) (fun i => (x i : ZMod (p.val ^ a))) hmod v j w hw + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + [Fintype G] [∀ j, Fintype (I j)] + [∀ a, Fintype (B a)] {N L : ℕ} + +theorem allocatedCongruenceRankPolynomial_original + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod N) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (projection : AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ZMod N) + (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (v : LayerSamplerVariables G I n B → ZMod N) + (o : AllocatedCongruenceRankOutput X E inactive j) : + allocatedCongruenceRankPolynomial inactive j noise r projection spatial kernel block + (fun z => allocatedSelectedRankCoefficients inactive j noise r projection spatial kernel block + (allocatedCongruenceOutputEmbedding inactive j z)) v o = + allocatedOriginalTaggedTop inactive j noise r projection v + (allocatedCongruenceOutputEmbedding inactive j o) := by + rw [allocatedCongruenceRankPolynomial, allocatedTaggedRankPolynomial_eq_designated, + allocatedOriginalTaggedTop_eq_designated inactive j noise r projection spatial kernel block] + simp only [designatedVectorComponent, + (allocatedCongruenceOutputEmbedding (X := X) (E := E) inactive j).injective.extend_apply] + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +private theorem uniform_eventProbability_le_instances (Y : Type*) (f g : Fintype Y) + [Nonempty Y] (A : Y → Prop) (r : ℝ) + (h : @FiniteProbabilityWeights.eventProbability Y f + (@FiniteProbabilityWeights.uniform Y f _) A ≤ r) : + @FiniteProbabilityWeights.eventProbability Y g + (@FiniteProbabilityWeights.uniform Y g _) A ≤ r := by + cases Subsingleton.elim f g + exact h + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable local instance congruenceScalarFintype + (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedCongruenceScalarIndex X E inactive L) := inferInstance + +noncomputable local instance congruenceScalarDecidableEq + (inactive : LayerSamplerAxis I n → Prop) : + DecidableEq (AllocatedCongruenceScalarIndex X E inactive L) := Classical.decEq _ + +variable (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + +local notation "rankS" => allocatedCongruenceRankBlockFamily (X := X) (E := E) inactive spatial kernel block +local notation "rankQ" => allocatedCongruenceRankIntegerResidualFamily inactive noise r projection spatial kernel block + +theorem allocatedCongruenceModulusBad_probability {p a D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hlarge : modularCoefficientPrimeThreshold m ≤ p ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (FiniteProbabilityWeights.uniform + (AllocatedCongruenceScalarIndex (I := I) (n := n) X E inactive L → ZMod (p ^ a))).eventProbability + (allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C (p ^ a)) ≤ + 1 / ((p ^ a : ℕ) : ℝ) ^ 10 := by + have hcount (j : Fin m) : Fintype.card (AllocatedCongruenceRankOutput X E inactive j) ≤ D := + (Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ j)).trans + ((allocatedCongruenceRankOutput_sum_card_le (X := X) (E := E) hm inactive).trans hD) + have h := scalarCoefficientBad_probability + (T := Fin m) (D := Fin L) (I := LayerSamplerLongVariables inactive G B) + (B := AllocatedCongruenceRankOutput X E inactive) (s := m) (m := D) hp ha + (fun j => j.val) (fun j => Nat.succ_le_of_lt j.isLt) + (by simp only [Fintype.card_fin, le_refl]) hcount rankS rankQ + (fun j o => allocatedTaggedRankBlock_card inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o)) + (fun j o => allocatedTaggedRankBlock_disjoint inactive j spatial (kernel j) (block j) + (allocatedCongruenceOutputEmbedding inactive j o)) + hC hlarge (by simpa only [Fintype.card_fin] using hL) + have heq : allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C (p ^ a) = + scalarCoefficientBad (fun j : Fin m => j.val) rankS rankQ C (p ^ a) := by + funext x + exact propext (allocatedCongruenceModulusBad_iff_scalarCoefficientBad + inactive noise r projection spatial kernel block C (p ^ a) x) + rw [heq] + exact uniform_eventProbability_le_instances _ _ _ _ _ h + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical +open FiniteProbabilityWeights + +private theorem mixed_uniform_eventProbability_le_instances (Y : Type*) (f g : Fintype Y) + [Nonempty Y] (F : Y → Prop) (r : ℝ) + (h : @eventProbability Y f (@uniform Y f _) F ≤ r) : + @eventProbability Y g (@uniform Y g _) F ≤ r := by + cases Subsingleton.elim f g + exact h + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable local instance badProductSmoothIndexFintype (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedSmoothRankCoefficientIndex X inactive L) := inferInstance +noncomputable local instance badProductDeckIndexFintype : + Fintype (AllocatedDeckRankCoefficientIndex E L) := inferInstance +noncomputable local instance badProductDeckIndexDecidableEq : + DecidableEq (AllocatedDeckRankCoefficientIndex E L) := Classical.decEq _ +noncomputable local instance badProductCongruenceIndexFintype (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedCongruenceCoefficientIndex X E inactive L) := inferInstance +noncomputable local instance badProductCongruenceIndexDecidableEq (inactive : LayerSamplerAxis I n → Prop) : + DecidableEq (AllocatedCongruenceCoefficientIndex X E inactive L) := Classical.decEq _ + +variable (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + +def allocatedMixedModulusBad (C : ℝ) (M : ℕ) [NeZero M] + (x : (AllocatedSmoothRankCoefficientIndex X inactive L ⊕ + AllocatedDeckRankCoefficientIndex E L) → ZMod M) : Prop := + allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C M + (allocatedMixedCoefficientEquiv inactive L (ZMod M) x) + +theorem allocatedMixedModulusBad_probability {p a D : ℕ} [NeZero p] + (hm : 0 < m) (hp : p.Prime) (ha : 0 < a) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hlarge : modularCoefficientPrimeThreshold m ≤ p ^ a) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) : + (uniform ((AllocatedSmoothRankCoefficientIndex X inactive L ⊕ + AllocatedDeckRankCoefficientIndex E L) → ZMod (p ^ a))).eventProbability + (allocatedMixedModulusBad inactive noise r projection spatial kernel block C (p ^ a)) ≤ + 1 / ((p ^ a : ℕ) : ℝ) ^ 10 := by + have he := allocatedMixedCoefficient_uniform_event (X := X) (E := E) inactive L (p ^ a) + (allocatedCongruenceModulusBad inactive noise r projection spatial kernel block C (p ^ a)) + have hs := allocatedCongruenceModulusBad_probability inactive noise r projection spatial kernel block + hm hp ha hD hC hlarge hL + have hb := he.le.trans (mixed_uniform_eventProbability_le_instances _ _ _ _ _ hs) + exact mixed_uniform_eventProbability_le_instances _ _ _ _ _ hb + +theorem allocatedMixedRankBad_eq {N : ℕ} [NeZero N] + (P : Finset ℕ) [∀ p : P, NeZero p.val] (C : ℝ) (p a : ℕ) + (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + mixedSmoothUniformResiduePrimeBad P + (fun p a => allocatedMixedModulusBad inactive noise r projection spatial kernel block C (p.val ^ a)) + p a (x,deck) = + allocatedCongruenceRankBad inactive noise r projection spatial kernel block P C p a + (allocatedMixedSelectedValues inactive x deck) := by + unfold mixedSmoothUniformResiduePrimeBad allocatedCongruenceRankBad smoothResiduePrimeBad + simp only [allocatedMixedModulusBad, allocatedMixedCoefficientEquiv_cast] + +theorem allocatedMixedRank_primePower_event {N D : ℕ} [NeZero N] + (hm : 0 < m) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ width j) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => ∀ p : P, allocatedCongruenceModulusBad inactive noise r projection spatial kernel block + C (p.val ^ A p.val) (fun j => + (allocatedMixedSelectedValues inactive x.1.val x.2 j : ZMod (p.val ^ A p.val)))) ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) / width j := by + have h := mixedSmoothUniform_primePower_event (N := N) center width hwidth hZ P A + hprime hcover + (fun p => allocatedMixedModulusBad inactive noise r projection spatial kernel block C (p.val ^ A p.val)) + (fun p => by + have ht := allocatedMixedModulusBad_probability inactive noise r projection spatial kernel block + hm (hprime p p.property) (hpositive p p.property) hD hC (hthreshold p p.property) hL + exact mixed_uniform_eventProbability_le_instances _ _ _ _ _ ht) + hlarge + simpa only [allocatedMixedModulusBad, allocatedMixedCoefficientEquiv_cast] using h + +theorem allocatedMixedRank_bad_product_probability {N D Q R : ℕ} [NeZero N] + (hm : 0 < m) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hQ : 1 ≤ Q) (hR : 0 < R) (hdepth : ∀ p ∈ P, p ^ A p ≤ Q) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) ≤ width j) + {η : ℝ} (hη : 0 ≤ η) + (herror : (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (max Q (R ^ 2) : ℕ) / width j) ≤ η) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => smallPrimePowerCorrection (modularCoefficientPrimeThreshold m) * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => allocatedCongruenceRankBad inactive noise r projection spatial kernel block P C + p a (allocatedMixedSelectedValues inactive x.1.val x.2)) p x) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + have h := mixedSmoothUniform_badPrimeProduct_probability (N := N) + center width hwidth hZ P A + (fun p a => allocatedMixedModulusBad inactive noise r projection spatial kernel block C (p.val ^ a)) + hprime hcover (modularCoefficientPrimeThreshold_two_le m) hQ hR hdepth + (fun p a ha _had hlarge => by + have ht := allocatedMixedModulusBad_probability + inactive noise r projection spatial kernel block hm (hprime p p.property) ha hD hC hlarge hL + exact mixed_uniform_eventProbability_le_instances _ _ _ _ _ ht) + hlarge hη herror + simpa only [allocatedMixedRankBad_eq] using h + +theorem exists_early_allocatedMixedRank_bad_product_cutoff {D : ℕ} + (hm : 0 < m) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ (Q N : ℕ) [NeZero N] + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width), + 1 ≤ Q → (∀ p ∈ P, p.Prime) → (∀ p ∈ P, p ^ A p ∣ N) → + (∀ p ∈ P, p ^ A p ≤ Q) → + (∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) ≤ width j) → + (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) / width j) ≤ + δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2)) → + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => smallPrimePowerCorrection (modularCoefficientPrimeThreshold m) * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => allocatedCongruenceRankBad inactive noise r projection spatial kernel block P C + p a (allocatedMixedSelectedValues inactive x.1.val x.2)) p x) ≤ δ := by + obtain ⟨R, hR, hradius⟩ := exists_early_badPrime_radius hδ + refine ⟨R, hR, ?_⟩ + intro Q N _ P A _ noise r projection center width hwidth hZ hQ hprime hcover hdepth hlarge herror + exact (allocatedMixedRank_bad_product_probability inactive noise r projection spatial kernel block + hm center width hwidth hZ P A hprime hcover hQ hR hdepth hD hC hL hlarge + (hradius Q hQ).1.le herror).trans (hradius Q hQ).2 + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankCongruenceOutput.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankCongruenceOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..b414d7b2dc1349e67a4e3e6a91a9d2635a2e13c0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankCongruenceOutput.lean @@ -0,0 +1,916 @@ +import Mathlib.Algebra.MvPolynomial.CommRing +import Mathlib.Data.Fintype.EquivFin +import OAI.Combinatorics.Progressions.Estimates.ModularMultilinearAmbientSublevel +import OAI.Combinatorics.Progressions.Sampling.ForecastPreparedScaleBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {D G : Type*} {B : D → Type*} + +def canonicalRankBlockEmbedding (h : D → ℕ) (d : D) (b : B d) : + Fin (h d) ↪ SamplerTupleIndex G B h where + toFun v := .inr ⟨d, b, v⟩ + inj' := by intro v w he; simpa only [Sum.inr.injEq, Sigma.mk.inj_iff, heq_eq_eq, + Prod.mk.injEq, true_and] using he + +def canonicalRankBlock (h : D → ℕ) (d : D) (b : B d) : + Finset (SamplerTupleIndex G B h) := + Finset.univ.map (canonicalRankBlockEmbedding h d b) + +theorem canonicalRankBlock_card (h : D → ℕ) (d : D) (b : B d) : + (canonicalRankBlock (G := G) h d b).card = h d := by + simp only [canonicalRankBlock, Finset.card_map, Finset.card_univ, Fintype.card_fin] + +theorem mem_canonicalRankBlock (h : D → ℕ) (d : D) (b : B d) + (k : SamplerTupleIndex G B h) : + k ∈ canonicalRankBlock h d b ↔ ∃ v : Fin (h d), k = .inr ⟨d, b, v⟩ := by + simp only [canonicalRankBlock, Finset.mem_map, Finset.mem_univ, true_and, + canonicalRankBlockEmbedding, eq_comm] + rfl + +theorem canonicalRankBlock_pairwise_disjoint (h : D → ℕ) : + Pairwise (fun a b : (Σ d, B d) => + Disjoint (canonicalRankBlock (G := G) h a.1 a.2) + (canonicalRankBlock h b.1 b.2)) := by + intro a b hab + apply Finset.disjoint_left.mpr + intro k hka hkb + obtain ⟨v, hv⟩ := (mem_canonicalRankBlock h a.1 a.2 k).mp hka + obtain ⟨w, hw⟩ := (mem_canonicalRankBlock h b.1 b.2 k).mp hkb + have he : (Sum.inr ⟨a.1, a.2, v⟩ : SamplerTupleIndex G B h) = .inr ⟨b.1, b.2, w⟩ := + hv.symm.trans hw + have hp := congrArg (fun t : SamplerTupleIndex G B h => + match t with + | .inl _ => none + | .inr t => some (⟨t.1, t.2.1⟩ : Σ d, B d)) he + exact hab (Option.some.inj hp) + +theorem canonicalRankBlock_disjoint (h : D → ℕ) (d : D) : + Pairwise (fun b c : B d => Disjoint (canonicalRankBlock (G := G) h d b) + (canonicalRankBlock h d c)) := by + intro b c hbc + apply canonicalRankBlock_pairwise_disjoint (G := G) h (i := ⟨d, b⟩) (j := ⟨d, c⟩) + intro he + apply hbc + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using he + +theorem principalCoefficientSlot_eq_block_sum (h : D → ℕ) (d : D) (b : B d) : + (principalCoefficientSlot (G := G) h d b).val = + ∑ k ∈ canonicalRankBlock h d b, Finsupp.single k 1 := by + simp only [principalCoefficientSlot, canonicalPrincipalExponent, productBlockExponent, + canonicalRankBlock, Finset.sum_map, canonicalRankBlockEmbedding] + rfl + +theorem principalCoefficientSlot_monomial {R : Type*} [CommSemiring R] + (h : D → ℕ) (d : D) (b : B d) (c : R) : + MvPolynomial.monomial (principalCoefficientSlot (G := G) h d b).val c = + MvPolynomial.C c * ∏ k ∈ canonicalRankBlock h d b, MvPolynomial.X k := by + rw [principalCoefficientSlot_eq_block_sum, MvPolynomial.monomial_sum_index] + rfl + +theorem principalCoefficientSlot_squarefree (h : D → ℕ) (d : D) (b : B d) : + SquarefreeExponent (principalCoefficientSlot (G := G) h d b).val := by + intro k + rw [principalCoefficientSlot_eq_block_sum, Finsupp.finsetSum_apply] + simp only [Finsupp.single_apply] + by_cases hk : k ∈ canonicalRankBlock (G := G) h d b + · simp only [Finset.sum_ite_eq', hk, ite_true, le_refl] + · simp only [Finset.sum_ite_eq', hk, ite_false, zero_le] + +theorem principalCoefficientSlot_eq_squarefree [Fintype G] [Fintype D] + [∀ d, Fintype (B d)] (h : D → ℕ) (d : D) (b : B d) : + (principalCoefficientSlot (G := G) h d b).val = + (SquarefreeIndex.ofFinset (canonicalRankBlock h d b)).val := by + ext k + rw [principalCoefficientSlot_eq_block_sum, Finsupp.finsetSum_apply, + SquarefreeIndex.ofFinset_apply] + simp only [Finsupp.single_apply, Finset.sum_ite_eq'] + +namespace VectorPolynomial + +variable {m : ℕ} {I : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +def allocatedRankBlockEmbedding (a : LayerSamplerAxis I n) (b : B a) : + Fin (a.1.val + 1) ↪ LayerSamplerVariables G I n B := + canonicalRankBlockEmbedding (layerSamplerDegree I n) a b + +def allocatedRankBlock (a : LayerSamplerAxis I n) (b : B a) : + Finset (LayerSamplerVariables G I n B) := + canonicalRankBlock (layerSamplerDegree I n) a b + +def allocatedRankSelected (a : LayerSamplerAxis I n) (b : B a) : + LayerSamplerVariables G I n B := + allocatedRankBlockEmbedding a b 0 + +theorem allocatedRankSelected_mem (a : LayerSamplerAxis I n) (b : B a) : + allocatedRankSelected (G := G) a b ∈ allocatedRankBlock a b := by + exact Finset.mem_map.mpr ⟨⟨0, Nat.zero_lt_succ _⟩, Finset.mem_univ _, rfl⟩ + +theorem allocatedRankBlock_pairwise_disjoint : + Pairwise (fun a b : (Σ a : LayerSamplerAxis I n, B a) => + Disjoint (allocatedRankBlock (G := G) a.1 a.2) + (allocatedRankBlock b.1 b.2)) := + canonicalRankBlock_pairwise_disjoint _ + +theorem allocatedRankBlock_card (a : LayerSamplerAxis I n) (b : B a) : + (allocatedRankBlock (G := G) a b).card = a.1.val + 1 := + canonicalRankBlock_card _ _ _ + +theorem allocatedRankBlock_disjoint (a : LayerSamplerAxis I n) : + Pairwise (fun b c : B a => Disjoint (allocatedRankBlock (G := G) a b) + (allocatedRankBlock a c)) := + canonicalRankBlock_disjoint _ _ + +theorem allocatedRankBlock_monomial {R : Type*} [CommSemiring R] + (a : LayerSamplerAxis I n) (b : B a) (c : R) : + MvPolynomial.monomial + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) a b).val c = + MvPolynomial.C c * ∏ k ∈ allocatedRankBlock a b, MvPolynomial.X k := + principalCoefficientSlot_monomial _ _ _ _ + +theorem allocatedRankBlock_monomial_smul {R : Type*} [CommSemiring R] + (a : LayerSamplerAxis I n) (b : B a) (c : R) : + MvPolynomial.monomial + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) a b).val c = + c • ∏ k ∈ allocatedRankBlock a b, MvPolynomial.X k := by + rw [allocatedRankBlock_monomial, MvPolynomial.smul_eq_C_mul] + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3 + +open VectorPolynomial +open scoped BigOperators Classical + +variable {D G A : Type*} {B : D → Type*} {h : ℕ} + +def kernelRankBlockEmbedding (degree : D → ℕ) (e : A × Fin h ↪ G) (a : A) : + Fin h ↪ SamplerTupleIndex G B degree where + toFun v := .inl (e (a, v)) + inj' := by + intro v w he + exact congrArg Prod.snd (e.injective (Sum.inl.inj he)) + +@[simp] theorem kernelRankBlockEmbedding_apply (degree : D → ℕ) + (e : A × Fin h ↪ G) (a : A) (v : Fin h) : + kernelRankBlockEmbedding (B := B) degree e a v = .inl (e (a, v)) := rfl + +def kernelRankBlock (degree : D → ℕ) (e : A × Fin h ↪ G) (a : A) : + Finset (SamplerTupleIndex G B degree) := + Finset.univ.map (kernelRankBlockEmbedding degree e a) + +theorem kernelRankBlock_eq_image (degree : D → ℕ) (e : A × Fin h ↪ G) (a : A) : + kernelRankBlock (B := B) degree e a = + Finset.univ.image (fun v : Fin h => (Sum.inl (e (a, v)) : SamplerTupleIndex G B degree)) := by + rw [kernelRankBlock, Finset.map_eq_image] + rfl + +theorem kernelRankBlock_card (degree : D → ℕ) (e : A × Fin h ↪ G) (a : A) : + (kernelRankBlock (B := B) degree e a).card = h := by + simp only [kernelRankBlock, Finset.card_map, Finset.card_univ, Fintype.card_fin] + +theorem mem_kernelRankBlock (degree : D → ℕ) (e : A × Fin h ↪ G) (a : A) + (k : SamplerTupleIndex G B degree) : + k ∈ kernelRankBlock degree e a ↔ ∃ v : Fin h, k = .inl (e (a, v)) := by + simp only [kernelRankBlock, Finset.mem_map, Finset.mem_univ, true_and, + kernelRankBlockEmbedding, eq_comm] + rfl + +theorem kernelRankBlock_pairwise_disjoint (degree : D → ℕ) (e : A × Fin h ↪ G) : + Pairwise (fun a b : A => Disjoint (kernelRankBlock (B := B) degree e a) + (kernelRankBlock degree e b)) := by + intro a b hab + apply Finset.disjoint_left.mpr + intro k hka hkb + obtain ⟨v, hv⟩ := (mem_kernelRankBlock degree e a k).mp hka + obtain ⟨w, hw⟩ := (mem_kernelRankBlock degree e b k).mp hkb + exact hab (congrArg Prod.fst (e.injective (Sum.inl.inj (hv.symm.trans hw)))) + +theorem kernelRankBlock_disjoint_canonicalRankBlock (degree : D → ℕ) + (e : A × Fin h ↪ G) (a : A) (d : D) (b : B d) : + Disjoint (kernelRankBlock degree e a) (canonicalRankBlock degree d b) := by + apply Finset.disjoint_left.mpr + intro k hk hp + obtain ⟨v, hv⟩ := (mem_kernelRankBlock degree e a k).mp hk + obtain ⟨w, hw⟩ := (mem_canonicalRankBlock degree d b k).mp hp + exact Sum.inl_ne_inr (hv.symm.trans hw) + +noncomputable def kernelRankCoefficientSlot (degree : D → ℕ) + (e : A × Fin h ↪ G) (a : A) : + BoundedCoefficientExponent (SamplerTupleIndex G B degree) h := + ⟨productBlockExponent (kernelRankBlockEmbedding degree e a), + (productBlockExponent_degree _).le⟩ + +theorem kernelRankCoefficientSlot_degree (degree : D → ℕ) + (e : A × Fin h ↪ G) (a : A) : + (kernelRankCoefficientSlot (B := B) degree e a).val.degree = h := + productBlockExponent_degree _ + +theorem kernelRankCoefficientSlot_eq_block_sum (degree : D → ℕ) + (e : A × Fin h ↪ G) (a : A) : + (kernelRankCoefficientSlot (B := B) degree e a).val = + ∑ k ∈ kernelRankBlock degree e a, Finsupp.single k 1 := by + simp only [kernelRankCoefficientSlot, productBlockExponent, kernelRankBlock, + Finset.sum_map] + +theorem kernelRankCoefficientSlot_apply (degree : D → ℕ) + (e : A × Fin h ↪ G) (a b : A) (v : Fin h) : + (kernelRankCoefficientSlot (B := B) degree e a).val (.inl (e (b, v))) = + if a = b then 1 else 0 := by + by_cases hab : a = b <;> + simp [kernelRankCoefficientSlot, productBlockExponent, + Finsupp.single_apply, e.injective.eq_iff, hab] + +theorem kernelRankCoefficientSlot_injective (degree : D → ℕ) + (e : A × Fin h ↪ G) (hh : 0 < h) : + Function.Injective (kernelRankCoefficientSlot (B := B) degree e) := by + intro a b he + have hv := congrArg (fun q : BoundedCoefficientExponent (SamplerTupleIndex G B degree) h => + q.val (.inl (e (b, ⟨0, hh⟩)))) he + rw [kernelRankCoefficientSlot_apply, kernelRankCoefficientSlot_apply] at hv + by_contra hab + simp [hab] at hv + +theorem kernelRankCoefficientSlot_monomial {R : Type*} [CommSemiring R] + (degree : D → ℕ) (e : A × Fin h ↪ G) (a : A) (c : R) : + MvPolynomial.monomial (kernelRankCoefficientSlot (B := B) degree e a).val c = + c • ∏ k ∈ kernelRankBlock degree e a, MvPolynomial.X k := by + rw [kernelRankCoefficientSlot_eq_block_sum, MvPolynomial.monomial_sum_index, + MvPolynomial.smul_eq_C_mul] + rfl + +theorem kernelRankCoefficientSlot_squarefree (degree : D → ℕ) + (e : A × Fin h ↪ G) (a : A) : + SquarefreeExponent (kernelRankCoefficientSlot (B := B) degree e a).val := by + intro k + rw [kernelRankCoefficientSlot_eq_block_sum, Finsupp.finsetSum_apply] + simp only [Finsupp.single_apply, Finset.sum_ite_eq'] + split_ifs <;> omega + +theorem kernelRankCoefficientSlot_eq_squarefree [Fintype G] [Fintype D] + [∀ d, Fintype (B d)] (degree : D → ℕ) (e : A × Fin h ↪ G) (a : A) : + (kernelRankCoefficientSlot (B := B) degree e a).val = + (SquarefreeIndex.ofFinset (kernelRankBlock degree e a)).val := by + ext k + rw [kernelRankCoefficientSlot_eq_block_sum, Finsupp.finsetSum_apply, + SquarefreeIndex.ofFinset_apply] + simp only [Finsupp.single_apply, Finset.sum_ite_eq'] + +theorem exists_kernelRankEmbedding [Fintype A] [Fintype G] + (hcap : Fintype.card A * h ≤ Fintype.card G) : Nonempty (A × Fin h ↪ G) := by + apply Function.Embedding.nonempty_of_card_le + simpa only [Fintype.card_prod, Fintype.card_fin] using hcap + +noncomputable def kernelRankEmbeddingOfCapacity [Fintype A] [Fintype G] + (hcap : Fintype.card A * h ≤ Fintype.card G) : A × Fin h ↪ G := + Classical.choice (exists_kernelRankEmbedding hcap) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators Classical + +variable {D G : Type*} {B : D → Type*} + +abbrev SamplerLongVariables (inactive : D → Prop) (G : Type*) (B : D → Type*) + (h : D → ℕ) := + SamplerTupleIndex G (fun d : {d // ¬ inactive d} => B d.val) (fun d => h d.val) + +def samplerLongEmbedding (inactive : D → Prop) (h : D → ℕ) : + SamplerLongVariables inactive G B h ↪ SamplerTupleIndex G B h := + Function.Embedding.sumMap (Function.Embedding.refl G) + (Function.Embedding.sigmaMap (Function.Embedding.subtype (fun d => ¬ inactive d)) + (fun _ => Function.Embedding.refl _)) + +@[simp] theorem samplerLongEmbedding_common (inactive : D → Prop) (h : D → ℕ) (g : G) : + samplerLongEmbedding (B := B) inactive h (.inl g) = .inl g := rfl + +@[simp] theorem samplerLongEmbedding_dedicated (inactive : D → Prop) (h : D → ℕ) + (d : {d // ¬ inactive d}) (b : B d.val) (v : Fin (h d.val)) : + samplerLongEmbedding (G := G) inactive h (.inr ⟨d, b, v⟩) = + .inr ⟨d.val, b, v⟩ := rfl + +theorem samplerLongEmbedding_common_mem_range (inactive : D → Prop) (h : D → ℕ) (g : G) : + (Sum.inl g : SamplerTupleIndex G B h) ∈ Set.range (samplerLongEmbedding inactive h) := + ⟨.inl g, rfl⟩ + +theorem samplerLongEmbedding_dedicated_mem_range (inactive : D → Prop) (h : D → ℕ) + (d : D) (b : B d) (v : Fin (h d)) : + (Sum.inr ⟨d, b, v⟩ : SamplerTupleIndex G B h) ∈ + Set.range (samplerLongEmbedding inactive h) ↔ ¬ inactive d := by + constructor + · rintro ⟨k, hk⟩ + rcases k with g | ⟨a, c, w⟩ + · simp only [samplerLongEmbedding_common, Sum.inl_ne_inr] at hk + · have he : a.val = d := congrArg Sigma.fst (Sum.inr.inj hk) + exact he ▸ a.property + · intro hd + exact ⟨.inr ⟨⟨d, hd⟩, b, v⟩, rfl⟩ + +theorem samplerLongEmbedding_block (inactive : D → Prop) (h : D → ℕ) + (d : {d // ¬ inactive d}) (b : B d.val) : + (canonicalRankBlock (G := G) (B := fun a : {a // ¬ inactive a} => B a.val) + (fun a => h a.val) d b).map (samplerLongEmbedding inactive h) = + canonicalRankBlock h d.val b := by + simp only [canonicalRankBlock, Finset.map_map] + congr 1 + +theorem samplerLongEmbedding_principalExponent (inactive : D → Prop) (h : D → ℕ) + (d : {d // ¬ inactive d}) (b : B d.val) : + ((principalCoefficientSlot (G := G) (B := fun a : {a // ¬ inactive a} => B a.val) + (fun a => h a.val) d b).val).mapDomain (samplerLongEmbedding inactive h) = + (principalCoefficientSlot h d.val b).val := by + simp only [principalCoefficientSlot, canonicalPrincipalExponent, productBlockExponent, + Finsupp.mapDomain_finsetSum, Finsupp.mapDomain_single, samplerLongEmbedding_dedicated] + +section TopPart + +variable {I J R : Type*} [CommRing R] + +theorem homogeneousComponent_killCompl (f : J → I) (hf : Function.Injective f) + (P : MvPolynomial I R) (r : ℕ) : + homogeneousComponent r (killCompl hf P) = killCompl hf (homogeneousComponent r P) := by + ext a + simp only [coeff_homogeneousComponent, coeff_killCompl, Finsupp.degree_mapDomain] + +theorem homogeneousComponent_polynomialTranslate_top (P : MvPolynomial I R) + (v : I → R) (r : ℕ) (hP : P.totalDegree ≤ r) : + homogeneousComponent r (polynomialTranslate v P) = homogeneousComponent r P := by + ext a + simp only [coeff_homogeneousComponent] + split_ifs with ha + · exact top_coeff_polynomialTranslate P v a (ha.symm ▸ hP) + · rfl + +theorem homogeneousComponent_restricted_translate_top (f : J → I) + (hf : Function.Injective f) (P : MvPolynomial I R) (v : I → R) + (r : ℕ) (hP : P.totalDegree ≤ r) : + homogeneousComponent r (killCompl hf (polynomialTranslate v P)) = + killCompl hf (homogeneousComponent r P) := by + rw [homogeneousComponent_killCompl, homogeneousComponent_polynomialTranslate_top P v r hP] + +theorem homogeneousComponent_conditionPolynomial_top (f : J → I) + (hf : Function.Injective f) (P : MvPolynomial I R) (v : I → R) + (r : ℕ) (hP : P.totalDegree ≤ r) : + homogeneousComponent r (conditionPolynomial f hf v P) = + killCompl hf (homogeneousComponent r P) := + homogeneousComponent_restricted_translate_top f hf P _ r hP + +end TopPart + +theorem samplerLong_principal_coefficient {R : Type*} [CommRing R] + (inactive : D → Prop) (h : D → ℕ) (d : {d // ¬ inactive d}) (b : B d.val) + (P : MvPolynomial (SamplerTupleIndex G B h) R) + (v : SamplerTupleIndex G B h → R) (hP : P.totalDegree ≤ h d.val) : + (conditionPolynomial (samplerLongEmbedding inactive h) + (samplerLongEmbedding inactive h).injective v P).coeff + (principalCoefficientSlot (G := G) (B := fun a : {a // ¬ inactive a} => B a.val) + (fun a => h a.val) d b).val = + P.coeff (principalCoefficientSlot h d.val b).val := by + rw [coeff_conditionPolynomial_top, samplerLongEmbedding_principalExponent] + simpa only [principalCoefficientSlot, canonicalPrincipalExponent_degree] using hP + +namespace VectorPolynomial + +variable {m : ℕ} {I : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +abbrev LayerSamplerLongVariables (inactive : LayerSamplerAxis I n → Prop) + (G : Type*) (B : LayerSamplerAxis I n → Type*) := + SamplerLongVariables inactive G B (layerSamplerDegree I n) + +def allocatedLongEmbedding (inactive : LayerSamplerAxis I n → Prop) : + LayerSamplerLongVariables inactive G B ↪ LayerSamplerVariables G I n B := + samplerLongEmbedding inactive (layerSamplerDegree I n) + +theorem allocatedLong_top_independent {R : Type*} [CommRing R] + (inactive : LayerSamplerAxis I n → Prop) + (P : MvPolynomial (LayerSamplerVariables G I n B) R) + (v : LayerSamplerVariables G I n B → R) (j : Fin m) + (hP : P.totalDegree ≤ j.val + 1) : + homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v P) = + killCompl (allocatedLongEmbedding inactive).injective + (homogeneousComponent (j.val + 1) P) := + homogeneousComponent_conditionPolynomial_top _ _ P v _ hP + +theorem allocatedLong_top_origin_independent {R : Type*} [CommRing R] + (inactive : LayerSamplerAxis I n → Prop) + (P : MvPolynomial (LayerSamplerVariables G I n B) R) + (origin : LayerSamplerVariables G I n B → R) (j : Fin m) + (hP : P.totalDegree ≤ j.val + 1) : + homogeneousComponent (j.val + 1) + (killCompl (allocatedLongEmbedding inactive).injective (polynomialTranslate origin P)) = + killCompl (allocatedLongEmbedding inactive).injective + (homogeneousComponent (j.val + 1) P) := + homogeneousComponent_restricted_translate_top _ _ P origin _ hP + +theorem allocatedLongEmbedding_block (inactive : LayerSamplerAxis I n → Prop) + (a : {a // ¬ inactive a}) (b : B a.val) : + (canonicalRankBlock (G := G) (B := fun c : {c // ¬ inactive c} => B c.val) + (fun c => c.val.1.val + 1) a b).map (allocatedLongEmbedding inactive) = + allocatedRankBlock a.val b := + samplerLongEmbedding_block inactive (layerSamplerDegree I n) a b + +theorem allocatedLong_principal_coefficient {R : Type*} [CommRing R] + (inactive : LayerSamplerAxis I n → Prop) (a : {a // ¬ inactive a}) (b : B a.val) + (P : MvPolynomial (LayerSamplerVariables G I n B) R) + (v : LayerSamplerVariables G I n B → R) (hP : P.totalDegree ≤ a.val.1.val + 1) : + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v P).coeff + (principalCoefficientSlot (G := G) (B := fun c : {c // ¬ inactive c} => B c.val) + (fun c => c.val.1.val + 1) a b).val = + P.coeff (principalCoefficientSlot (layerSamplerDegree I n) a.val b).val := + samplerLong_principal_coefficient inactive (layerSamplerDegree I n) a b P v hP + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +abbrev AllocatedDegreeActiveAxis (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) := + {a : I j ⊕ Fin (n j) // ¬ inactive ⟨j, a⟩} + +abbrev AllocatedDegreeRankOutput (E : Fin m → Type*) + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) := + E j ⊕ AllocatedDegreeActiveAxis inactive j + +def allocatedDegreeLongAxis (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + (a : AllocatedDegreeActiveAxis inactive j) : {a // ¬ inactive a} := + ⟨⟨j, a.val⟩, a.property⟩ + +def allocatedDegreeRankBlock (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) : + AllocatedDegreeRankOutput E inactive j → Fin L → + Finset (LayerSamplerLongVariables inactive G B) + | .inl _, l => kernelRankBlock (fun a : {a : LayerSamplerAxis I n // ¬ inactive a} => a.val.1.val + 1) kernel l + | .inr a, l => canonicalRankBlock (fun a : {a : LayerSamplerAxis I n // ¬ inactive a} => a.val.1.val + 1) + (allocatedDegreeLongAxis inactive j a) (block a l) + +theorem allocatedDegreeRankBlock_card (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedDegreeRankOutput E inactive j) (l : Fin L) : + (allocatedDegreeRankBlock (E := E) inactive j kernel block o l).card = j.val + 1 := by + cases o with + | inl e => exact kernelRankBlock_card _ _ _ + | inr a => exact canonicalRankBlock_card _ _ _ + +theorem allocatedDegreeRankBlock_disjoint (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedDegreeRankOutput E inactive j) : + Pairwise (fun l q => Disjoint (allocatedDegreeRankBlock (E := E) inactive j kernel block o l) + (allocatedDegreeRankBlock (E := E) inactive j kernel block o q)) := by + cases o with + | inl e => exact kernelRankBlock_pairwise_disjoint _ _ + | inr a => + intro l q hlq + exact canonicalRankBlock_disjoint _ _ ((block a).injective.ne hlq) + +def allocatedDegreeRankSelected (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) : + AllocatedDegreeRankOutput E inactive j → Fin L → LayerSamplerLongVariables inactive G B + | .inl _, l => .inl (kernel (l, 0)) + | .inr a, l => .inr ⟨allocatedDegreeLongAxis inactive j a, block a l, ⟨0, Nat.zero_lt_succ _⟩⟩ + +theorem allocatedDegreeRankSelected_mem (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedDegreeRankOutput E inactive j) (l : Fin L) : + allocatedDegreeRankSelected inactive j kernel block o l ∈ + allocatedDegreeRankBlock (E := E) inactive j kernel block o l := by + cases o with + | inl e => exact (mem_kernelRankBlock _ _ _ _).mpr ⟨0, rfl⟩ + | inr a => exact (mem_canonicalRankBlock _ _ _ _).mpr ⟨⟨0, Nat.zero_lt_succ _⟩, rfl⟩ + +theorem allocatedDegreeRankBlock_deck_projection_disjoint + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (e : E j) (a : AllocatedDegreeActiveAxis inactive j) (l q : Fin L) : + Disjoint (allocatedDegreeRankBlock (E := E) inactive j kernel block (.inl e) l) + (allocatedDegreeRankBlock (E := E) inactive j kernel block (.inr a) q) := + kernelRankBlock_disjoint_canonicalRankBlock _ _ _ _ _ + +theorem allocatedDegreeRankOutput_card_le [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) : + Fintype.card (AllocatedDegreeRankOutput E inactive j) ≤ + Fintype.card (E j) + Fintype.card (I j) + n j := by + change Fintype.card (E j ⊕ AllocatedDegreeActiveAxis inactive j) ≤ _ + rw [Fintype.card_sum, add_assoc] + apply Nat.add_le_add_left + exact (Fintype.card_subtype_le _).trans_eq (by + simp only [Fintype.card_sum, Fintype.card_fin]) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open MvPolynomial VectorPolynomial +open scoped BigOperators Classical + +variable {D G R : Type*} {B : D → Type*} [Fintype D] [Fintype G] + [∀ d, Fintype (B d)] [CommRing R] + +noncomputable def canonicalPrincipalSubblockSlot (h : D → ℕ) (d : D) {J : ℕ} + (block : Fin J ↪ B d) : + Fin J → BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d) := + fun j => principalCoefficientSlot h d (block j) + +omit [Fintype D] [Fintype G] [∀ d, Fintype (B d)] in +theorem canonicalPrincipalSubblockSlot_injective (h : D → ℕ) (d : D) (hd : 0 < h d) + {J : ℕ} (block : Fin J ↪ B d) : + Function.Injective (canonicalPrincipalSubblockSlot (G := G) h d block) := + (principalCoefficientSlot_injective h d hd).comp block.injective + +omit [Fintype D] [Fintype G] [∀ d, Fintype (B d)] in +theorem canonicalPrincipalSubblockSlot_degree (h : D → ℕ) (d : D) {J : ℕ} + (block : Fin J ↪ B d) (j : Fin J) : + (canonicalPrincipalSubblockSlot (G := G) h d block j).val.degree = h d := + canonicalPrincipalExponent_degree h d (block j) + +noncomputable def canonicalSelectedTopResidual (h : D → ℕ) (d : D) {J : ℕ} + (block : Fin J ↪ B d) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d) → R) : + MvPolynomial (SamplerTupleIndex G B h) R := + homogeneousComponent (h d) (modularUnselectedCoefficientPolynomial (h d) + (canonicalPrincipalSubblockSlot h d block) fixed) + +theorem canonicalBoundedCoefficient_selected_top (h : D → ℕ) (d : D) (hd : 0 < h d) + {J : ℕ} (block : Fin J ↪ B d) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d) → R) + (c : Fin J → R) : + homogeneousComponent (h d) (modularBoundedCoefficientPolynomial (h d) + (Function.extend (canonicalPrincipalSubblockSlot h d block) c fixed)) = + canonicalSelectedTopResidual h d block fixed + + ∑ j, c j • ∏ k ∈ canonicalRankBlock h d (block j), X k := by + rw [modularBoundedCoefficientPolynomial_selected_top (h d) _ + (canonicalPrincipalSubblockSlot_injective h d hd block) + (canonicalPrincipalSubblockSlot_degree h d block)] + congr 1 + apply Finset.sum_congr rfl + intro j _ + rw [canonicalPrincipalSubblockSlot, principalCoefficientSlot_monomial, smul_eq_C_mul] + +omit [Fintype D] [Fintype G] [∀ d, Fintype (B d)] in + +theorem samplerLong_killCompl_principal_monomial (inactive : D → Prop) (h : D → ℕ) + (d : {d // ¬ inactive d}) (b : B d.val) (c : R) : + killCompl (samplerLongEmbedding (G := G) inactive h).injective + (monomial (principalCoefficientSlot h d.val b).val c) = + c • ∏ k ∈ canonicalRankBlock (G := G) + (B := fun a : {a // ¬ inactive a} => B a.val) (fun a => h a.val) d b, X k := by + rw [← samplerLongEmbedding_principalExponent inactive h d b, + killCompl_monomial_mapDomain, principalCoefficientSlot_monomial, smul_eq_C_mul] + +noncomputable def canonicalSelectedLongTopResidual (inactive : D → Prop) (h : D → ℕ) + (d : {d // ¬ inactive d}) {J : ℕ} (block : Fin J ↪ B d.val) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d.val) → R) : + MvPolynomial (SamplerLongVariables inactive G B h) R := + killCompl (samplerLongEmbedding inactive h).injective + (canonicalSelectedTopResidual h d.val block fixed) + +theorem canonicalBoundedCoefficient_selected_long_top (inactive : D → Prop) (h : D → ℕ) + (d : {d // ¬ inactive d}) (hd : 0 < h d.val) {J : ℕ} (block : Fin J ↪ B d.val) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d.val) → R) + (c : Fin J → R) (v : SamplerTupleIndex G B h → R) : + homogeneousComponent (h d.val) + (conditionPolynomial (samplerLongEmbedding inactive h) + (samplerLongEmbedding inactive h).injective v + (modularBoundedCoefficientPolynomial (h d.val) + (Function.extend (canonicalPrincipalSubblockSlot h d.val block) c fixed))) = + canonicalSelectedLongTopResidual inactive h d block fixed + + ∑ j, c j • ∏ k ∈ canonicalRankBlock (G := G) + (B := fun a : {a // ¬ inactive a} => B a.val) + (fun a => h a.val) d (block j), X k := by + have hdegree : (modularBoundedCoefficientPolynomial (h d.val) + (Function.extend (canonicalPrincipalSubblockSlot h d.val block) c fixed)).totalDegree ≤ + h d.val := by + apply totalDegree_finsetSum_le + intro e _ + exact (totalDegree_monomial_le e.val _).trans e.property + rw [homogeneousComponent_conditionPolynomial_top _ _ _ v (h d.val) hdegree, + modularBoundedCoefficientPolynomial_selected_top (h d.val) _ + (canonicalPrincipalSubblockSlot_injective h d.val hd block) + (canonicalPrincipalSubblockSlot_degree h d.val block), map_add, map_sum] + change canonicalSelectedLongTopResidual inactive h d block fixed + _ = _ + congr 1 + apply Finset.sum_congr rfl + intro j _ + exact samplerLong_killCompl_principal_monomial inactive h d (block j) (c j) + +theorem canonicalBoundedInteger_selected_long_top (N : ℕ) (inactive : D → Prop) + (h : D → ℕ) (d : {d // ¬ inactive d}) (hd : 0 < h d.val) + {J : ℕ} (block : Fin J ↪ B d.val) + (fixed : BoundedCoefficientExponent (SamplerTupleIndex G B h) (h d.val) → ℤ) + (c : Fin J → ℤ) (v : SamplerTupleIndex G B h → ZMod N) : + homogeneousComponent (h d.val) + (conditionPolynomial (samplerLongEmbedding inactive h) + (samplerLongEmbedding inactive h).injective v + ((integerMonomialArrayPolynomial Subtype.val + (Function.extend (canonicalPrincipalSubblockSlot h d.val block) c fixed)).map + (Int.castRingHom (ZMod N)))) = + canonicalSelectedLongTopResidual inactive h d block (fun e => (fixed e : ZMod N)) + + ∑ j, (c j : ZMod N) • ∏ k ∈ canonicalRankBlock (G := G) + (B := fun a : {a // ¬ inactive a} => B a.val) + (fun a => h a.val) d (block j), X k := by + rw [← modularBoundedCoefficientPolynomial_integer_reduce] + have hi := canonicalPrincipalSubblockSlot_injective (G := G) h d.val hd block + have he : (fun e => ((Function.extend (canonicalPrincipalSubblockSlot h d.val block) + c fixed e : ℤ) : ZMod N)) = + Function.extend (canonicalPrincipalSubblockSlot h d.val block) + (fun j => (c j : ZMod N)) (fun e => (fixed e : ZMod N)) := by + funext e + by_cases he : e ∈ Set.range (canonicalPrincipalSubblockSlot (G := G) h d.val block) + · obtain ⟨j, rfl⟩ := he + simp only [hi.extend_apply] + · simp only [Function.extend_apply' _ _ _ he] + rw [he] + exact canonicalBoundedCoefficient_selected_long_top inactive h d hd block + (fun e => (fixed e : ZMod N)) (fun j => (c j : ZMod N)) v + +namespace VectorPolynomial + +variable {m : ℕ} {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + +theorem allocatedBoundedCoefficient_selected_long_top + (inactive : LayerSamplerAxis I n → Prop) (a : {a // ¬ inactive a}) + {J : ℕ} (block : Fin J ↪ B a.val) + (fixed : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (a.val.1.val + 1) → R) + (c : Fin J → R) (v : LayerSamplerVariables G I n B → R) : + homogeneousComponent (a.val.1.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularBoundedCoefficientPolynomial (a.val.1.val + 1) + (Function.extend (canonicalPrincipalSubblockSlot (layerSamplerDegree I n) a.val block) + c fixed))) = + canonicalSelectedLongTopResidual inactive (layerSamplerDegree I n) a block fixed + + ∑ j, c j • ∏ k ∈ canonicalRankBlock (G := G) + (B := fun b : {b // ¬ inactive b} => B b.val) + (fun b => b.val.1.val + 1) a (block j), X k := + canonicalBoundedCoefficient_selected_long_top inactive (layerSamplerDegree I n) a + (Nat.zero_lt_succ _) block fixed c v + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +abbrev SpatialDegreeOutput (X : Type*) (j : Fin m) := {_x : X // j.val = 0} + +abbrev AllocatedTaggedRankOutput (X : Type*) (E : Fin m → Type*) + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) := + SpatialDegreeOutput X j ⊕ AllocatedDegreeRankOutput E inactive j + +def allocatedSpatialRankBlock (inactive : LayerSamplerAxis I n → Prop) + {L : ℕ} (spatial : Fin L ↪ G) (l : Fin L) : + Finset (LayerSamplerLongVariables inactive G B) := + {.inl (spatial l)} + +def allocatedTaggedRankBlock (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) : + AllocatedTaggedRankOutput X E inactive j → Fin L → + Finset (LayerSamplerLongVariables inactive G B) + | .inl _, l => allocatedSpatialRankBlock inactive spatial l + | .inr o, l => allocatedDegreeRankBlock inactive j kernel block o l + +theorem allocatedTaggedRankBlock_card (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedTaggedRankOutput X E inactive j) (l : Fin L) : + (allocatedTaggedRankBlock inactive j spatial kernel block o l).card = j.val + 1 := by + cases o with + | inl x => simp only [allocatedTaggedRankBlock, allocatedSpatialRankBlock, + Finset.card_singleton, x.property, zero_add] + | inr o => exact allocatedDegreeRankBlock_card inactive j kernel block o l + +theorem allocatedTaggedRankBlock_disjoint (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedTaggedRankOutput X E inactive j) : + Pairwise (fun l q => Disjoint (allocatedTaggedRankBlock inactive j spatial kernel block o l) + (allocatedTaggedRankBlock inactive j spatial kernel block o q)) := by + cases o with + | inl x => + intro l q hlq + apply Finset.disjoint_singleton.mpr + exact fun he => hlq (spatial.injective (Sum.inl.inj he)) + | inr o => exact allocatedDegreeRankBlock_disjoint inactive j kernel block o + +def allocatedTaggedRankSelected (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) : + AllocatedTaggedRankOutput X E inactive j → Fin L → LayerSamplerLongVariables inactive G B + | .inl _, l => .inl (spatial l) + | .inr o, l => allocatedDegreeRankSelected inactive j kernel block o l + +theorem allocatedTaggedRankSelected_mem (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) + {L : ℕ} (spatial : Fin L ↪ G) (kernel : Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + (o : AllocatedTaggedRankOutput X E inactive j) (l : Fin L) : + allocatedTaggedRankSelected inactive j spatial kernel block o l ∈ + allocatedTaggedRankBlock inactive j spatial kernel block o l := by + cases o with + | inl x => exact Finset.mem_singleton_self _ + | inr o => exact allocatedDegreeRankSelected_mem inactive j kernel block o l + +theorem allocatedSpatialRankBlock_product {R : Type*} [CommSemiring R] + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) (l : Fin L) : + (∏ k ∈ allocatedSpatialRankBlock (B := B) inactive spatial l, + MvPolynomial.X k : MvPolynomial (LayerSamplerLongVariables inactive G B) R) = + MvPolynomial.X (.inl (spatial l)) := by + rw [allocatedSpatialRankBlock, Finset.prod_singleton] + +theorem spatialDegreeOutput_card [Fintype X] (j : Fin m) : + Fintype.card (SpatialDegreeOutput X j) = if j.val = 0 then Fintype.card X else 0 := by + rw [Fintype.card_subtype] + by_cases hj : j.val = 0 <;> simp only [hj, ite_true, ite_false, Finset.filter_true, + Finset.filter_false, Finset.card_univ, Finset.card_empty] + +theorem allocatedTaggedRankOutput_card_le [Fintype X] + [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) : + Fintype.card (AllocatedTaggedRankOutput X E inactive j) ≤ + Fintype.card X + (Fintype.card (E j) + Fintype.card (I j) + n j) := by + change Fintype.card (SpatialDegreeOutput X j ⊕ AllocatedDegreeRankOutput E inactive j) ≤ _ + rw [Fintype.card_sum] + exact Nat.add_le_add (Fintype.card_subtype_le _) (allocatedDegreeRankOutput_card_le (E := E) inactive j) + +theorem spatialDegreeOutput_sum_card [Fintype X] (hm : 0 < m) : + (∑ j : Fin m, Fintype.card (SpatialDegreeOutput X j)) = Fintype.card X := by + simp_rw [spatialDegreeOutput_card] + rw [Finset.sum_eq_single (⟨0, hm⟩ : Fin m)] + · rfl + · intro j _ hj + have hne : j.val ≠ 0 := fun he => hj (Fin.ext he) + simp only [hne, ite_false] + · simp only [Finset.mem_univ, not_true_eq_false, false_implies] + +theorem allocatedTaggedRankOutput_sum_card_le [Fintype X] + [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] (hm : 0 < m) + (inactive : LayerSamplerAxis I n → Prop) : + (∑ j : Fin m, Fintype.card (AllocatedTaggedRankOutput X E inactive j)) ≤ + Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + Fintype.card (I j) + n j) := by + simp only [AllocatedTaggedRankOutput, Fintype.card_sum, Finset.sum_add_distrib] + rw [spatialDegreeOutput_sum_card hm] + simpa only [AllocatedDegreeRankOutput, Fintype.card_sum, Finset.sum_add_distrib] using + Nat.add_le_add_left (Finset.sum_le_sum (s := Finset.univ) (fun j _ => + allocatedDegreeRankOutput_card_le (E := E) inactive j)) (Fintype.card X) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + +abbrev AllocatedCongruenceIntegerAxis (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) := + {i : Fin (n j) // ¬ inactive ⟨j, Sum.inr i⟩} + +abbrev AllocatedCongruenceRankOutput (X : Type*) (E : Fin m → Type*) + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) := + SpatialDegreeOutput X j ⊕ (E j ⊕ AllocatedCongruenceIntegerAxis inactive j) + +def allocatedCongruenceIntegerEmbedding (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) : + AllocatedCongruenceIntegerAxis inactive j ↪ AllocatedDegreeActiveAxis inactive j where + toFun i := ⟨Sum.inr i.val, i.property⟩ + inj' := by + intro i k he + apply Subtype.ext + exact Sum.inr.inj (congrArg Subtype.val he) + +def allocatedCongruenceOutputEmbedding (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) : + AllocatedCongruenceRankOutput X E inactive j ↪ AllocatedTaggedRankOutput X E inactive j := + Function.Embedding.sumMap (Function.Embedding.refl _) + (Function.Embedding.sumMap (Function.Embedding.refl _) + (allocatedCongruenceIntegerEmbedding inactive j)) + +@[simp] theorem allocatedCongruenceOutputEmbedding_spatial + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) (x : SpatialDegreeOutput X j) : + allocatedCongruenceOutputEmbedding (E := E) inactive j (.inl x) = .inl x := rfl + +@[simp] theorem allocatedCongruenceOutputEmbedding_deck + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) (e : E j) : + allocatedCongruenceOutputEmbedding (X := X) inactive j (.inr (.inl e)) = .inr (.inl e) := rfl + +@[simp] theorem allocatedCongruenceOutputEmbedding_integer + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) (i : AllocatedCongruenceIntegerAxis inactive j) : + allocatedCongruenceOutputEmbedding (X := X) (E := E) inactive j (.inr (.inr i)) = + .inr (.inr ⟨Sum.inr i.val, i.property⟩) := rfl + +theorem allocatedCongruenceRankOutput_card_le [Fintype X] [∀ j, Fintype (E j)] + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) : + Fintype.card (AllocatedCongruenceRankOutput X E inactive j) ≤ + Fintype.card (SpatialDegreeOutput X j) + (Fintype.card (E j) + n j) := by + change Fintype.card (SpatialDegreeOutput X j ⊕ + (E j ⊕ AllocatedCongruenceIntegerAxis inactive j)) ≤ _ + simp only [Fintype.card_sum] + apply Nat.add_le_add_left + apply Nat.add_le_add_left + simpa only [Fintype.card_fin] using Fintype.card_subtype_le + (fun i : Fin (n j) => ¬ inactive ⟨j, Sum.inr i⟩) + +theorem allocatedCongruenceRankOutput_sum_card_le [Fintype X] [∀ j, Fintype (E j)] + (hm : 0 < m) (inactive : LayerSamplerAxis I n → Prop) : + (∑ j : Fin m, Fintype.card (AllocatedCongruenceRankOutput X E inactive j)) ≤ + Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) := by + calc + _ ≤ ∑ j : Fin m, + (Fintype.card (SpatialDegreeOutput X j) + (Fintype.card (E j) + n j)) := + Finset.sum_le_sum (fun j _ => allocatedCongruenceRankOutput_card_le inactive j) + _ = _ := by rw [Finset.sum_add_distrib, spatialDegreeOutput_sum_card hm] + +theorem allocatedCongruenceRankOutput_sum_card_le_uniform [Fintype X] [∀ j, Fintype (E j)] + (hm : 0 < m) (inactive : LayerSamplerAxis I n → Prop) (M : ℕ) + (hM : ∀ j, Fintype.card (E j) + n j ≤ M) : + (∑ j : Fin m, Fintype.card (AllocatedCongruenceRankOutput X E inactive j)) ≤ + Fintype.card X + m * M := by + apply (allocatedCongruenceRankOutput_sum_card_le hm inactive).trans + apply Nat.add_le_add_left + simpa only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_id] using + Finset.sum_le_sum (s := Finset.univ) (fun j _ => hM j) + +theorem preparedCongruenceRankOutput_sum_card_le {X₀ J₀ : Type} + [Fintype X] [∀ j, Fintype (E j)] (prep : RankPreparationFamily X₀ J₀ m) + (hm : 0 < m) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) → Prop) + {M : ℕ} (hM : ∀ j, Fintype.card (prep j).Coord ≤ M) + (hE : ∀ j, Fintype.card (E j) ≤ Fintype.card (PreparedSamplerContinuous prep j)) : + (∑ j : Fin m, Fintype.card (AllocatedCongruenceRankOutput X E inactive j)) ≤ + Fintype.card X + m * M := by + apply allocatedCongruenceRankOutput_sum_card_le_uniform hm inactive M + intro j + calc + Fintype.card (E j) + preparedSamplerTransverse prep j ≤ + Fintype.card (PreparedSamplerContinuous prep j) + preparedSamplerTransverse prep j := + Nat.add_le_add_right (hE j) _ + _ = Fintype.card (prep j).Coord := preparedSampler_axis_card prep j + _ ≤ M := hM j + +theorem preparedCongruenceRankOutput_sum_card_fin_le {X₀ J₀ : Type} {nX : ℕ} + [∀ j, Fintype (E j)] (prep : RankPreparationFamily X₀ J₀ m) + (hm : 0 < m) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) → Prop) + {M : ℕ} (hM : ∀ j, Fintype.card (prep j).Coord ≤ M) + (hE : ∀ j, Fintype.card (E j) ≤ Fintype.card (PreparedSamplerContinuous prep j)) : + (∑ j : Fin m, Fintype.card (AllocatedCongruenceRankOutput (Fin nX) E inactive j)) ≤ + nX + m * M := by + simpa only [Fintype.card_fin] using + preparedCongruenceRankOutput_sum_card_le (X := Fin nX) prep hm inactive hM hE + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankFullProductLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankFullProductLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4ff3f209744f530f13b490e9f3bf4028627ac98 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankFullProductLaw.lean @@ -0,0 +1,453 @@ +import Mathlib.Probability.Distributions.Uniform +import OAI.Combinatorics.Progressions.Estimates.FiniteMixedArrayRefresh +import OAI.Combinatorics.Progressions.Estimates.IndependentProductPMFSum +import OAI.Combinatorics.Progressions.Lattices.AllocatedCoefficientIntegerMarginal +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankMixedUniform + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {G : Type*} [Fintype G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) (j : Fin m) (i : Fin (n j)) + +noncomputable def allocatedPrincipalRankCenter : ℝ := + (3 * principalProfileSize (R j) (layerIntegerPrincipalSlots (G := G) B j i).card / 2) * + ((basisAxisScale (basis j) i : ℝ) / (S.value : ℝ) ^ (j.val + 1)) + +noncomputable def allocatedPrincipalRankWidth : ℝ := + (principalProfileSize (R j) (layerIntegerPrincipalSlots (G := G) B j i).card / 2) * + ((basisAxisScale (basis j) i : ℝ) / (S.value : ℝ) ^ (j.val + 1)) + +include hR in + +theorem allocatedPrincipalRankWidth_pos : 0 < allocatedPrincipalRankWidth B U basis S j i := by + apply mul_pos (div_pos (principalProfileSize_pos (hR j) _) (by norm_num)) + exact div_pos (by exact_mod_cast basisAxisScale_pos (basis j) i) + (pow_pos (by exact_mod_cast S.positive) _) + +include hR in + +theorem allocatedPrincipalRankWidth_large + (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) : + 8 * (probabilityProfileLipschitz : ℝ) ≤ allocatedPrincipalRankWidth B U basis S j i := + integerAxisPrincipal_width (Nat.zero_lt_succ _) S.positive + (principalProfileSize_pos (hR j) _) (S.gap j i hactive) + +include hR in +theorem allocatedPrincipalRankMass_pos + (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) : + 0 < shiftedSmoothSampleSum (allocatedPrincipalRankCenter B U basis S j i) + (allocatedPrincipalRankWidth B U basis S j i) := + shiftedSmoothSampleSum_pos _ (allocatedPrincipalRankWidth_large B U basis hR S j i hactive) + +theorem allocatedLayerIntegerPMFs_principal_shiftedSmooth + (hactive : S.value ^ (j.val + 1) < basisAxisScale (basis j) i) + (b : B ⟨j, Sum.inr i⟩) : + allocatedLayerIntegerPMFs B U basis hR hσ S j i + (principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, Sum.inr i⟩ b) = + shiftedSmoothCoefficientPMF (allocatedPrincipalRankCenter B U basis S j i) + (allocatedPrincipalRankWidth B U basis S j i) + (allocatedPrincipalRankWidth_pos B U basis hR S j i) + (allocatedPrincipalRankMass_pos B U basis hR S j i hactive) := by + have h := allocatedPrincipalNormalizedSource_law B U basis hR hσ S j i hactive b + rw [allocatedPrincipalNormalizedSource, principalNormalizedSource_law] at h + exact h.symm + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + +abbrev AllocatedFullSmoothCoefficientIndex (G X : Type*) (I : Fin m → Type*) + (n : Fin m → ℕ) (B : LayerSamplerAxis I n → Type*) := + (Option (LayerSamplerVariables G I n B) × X) ⊕ + (Σ j : Fin m, BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) × Fin (n j)) + +abbrev AllocatedFullContinuousCoefficientIndex (G : Type*) (I : Fin m → Type*) + (n : Fin m → ℕ) (B : LayerSamplerAxis I n → Type*) := + Σ j : Fin m, BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) × I j + +def allocatedFullCoefficientSplit : + AllocatedActualCoefficientIndex G X I E n B ≃ + AllocatedFullSmoothCoefficientIndex G X I n B ⊕ + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E ⊕ + AllocatedFullContinuousCoefficientIndex G I n B) where + toFun t := match t with + | .inl x => .inl (.inl x) + | .inr (.inl d) => .inr (.inl d) + | .inr (.inr ⟨⟨j,.inl i⟩,q⟩) => .inr (.inr ⟨j,q,i⟩) + | .inr (.inr ⟨⟨j,.inr i⟩,q⟩) => .inl (.inr ⟨j,q,i⟩) + invFun t := match t with + | .inl (.inl x) => .inl x + | .inr (.inl d) => .inr (.inl d) + | .inr (.inr ⟨j,q,i⟩) => .inr (.inr ⟨⟨j,.inl i⟩,q⟩) + | .inl (.inr ⟨j,q,i⟩) => .inr (.inr ⟨⟨j,.inr i⟩,q⟩) + left_inv := by rintro (x | d | ⟨⟨j,(i | i)⟩,q⟩) <;> rfl + right_inv := by rintro ((x | ⟨j,q,i⟩) | d | ⟨j,q,i⟩) <;> rfl + +noncomputable def allocatedSmoothFullSlot + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) : + AllocatedSmoothRankCoefficientIndex X inactive L → AllocatedFullSmoothCoefficientIndex G X I n B + | ⟨_j,.inl x,l⟩ => .inl (some (.inl (spatial l)),x.val) + | ⟨j,.inr i,l⟩ => .inr ⟨j, + principalCoefficientSlot (layerSamplerDegree I n) ⟨j,.inr i.val⟩ + (block j ⟨.inr i.val,i.property⟩ l), i.val⟩ + +theorem allocatedSmoothFullSlot_injective + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) : + Function.Injective (allocatedSmoothFullSlot (X := X) inactive spatial block) := by + rintro ⟨j,(x | i),l⟩ ⟨k,(y | a),q⟩ he + · have hjk : j = k := Fin.ext (x.property.trans y.property.symm) + subst k + have hp := Sum.inl.inj he + have hl : l = q := spatial.injective + (Sum.inl.inj (Option.some.inj (congrArg Prod.fst hp))) + have hxy : x = y := Subtype.ext (congrArg Prod.snd hp) + subst q + subst y + rfl + · cases he + · cases he + · have hh := Sum.inr.inj he + have hjk : j = k := congrArg Sigma.fst hh + subst k + have hp := eq_of_heq (Sigma.mk.inj hh).2 + have hia : i = a := Subtype.ext (congrArg Prod.snd hp) + subst a + have hblocks := principalCoefficientSlot_injective (G := G) + (layerSamplerDegree I n) ⟨j,.inr i.val⟩ (Nat.zero_lt_succ _) (congrArg Prod.fst hp) + have hl : l = q := (block j ⟨.inr i.val,i.property⟩).injective hblocks + subst q + rfl + +noncomputable def allocatedSmoothFullEmbedding + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) : + AllocatedSmoothRankCoefficientIndex X inactive L ↪ AllocatedFullSmoothCoefficientIndex G X I n B := + ⟨allocatedSmoothFullSlot inactive spatial block, allocatedSmoothFullSlot_injective inactive spatial block⟩ + +noncomputable def allocatedDeckFullSlot (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) : + AllocatedDeckRankCoefficientIndex E L → CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E + | ⟨j,e,l⟩ => ⟨j,kernelRankCoefficientSlot (layerSamplerDegree I n) (kernel j) l,e⟩ + +theorem allocatedDeckFullSlot_injective (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) : + Function.Injective (allocatedDeckFullSlot (I := I) (E := E) (n := n) (B := B) kernel) := by + rintro ⟨j,e,l⟩ ⟨k,f,q⟩ he + have hjk : j = k := congrArg Sigma.fst he + subst k + have hp := eq_of_heq (Sigma.mk.inj he).2 + have hl : l = q := kernelRankCoefficientSlot_injective + (layerSamplerDegree I n) (kernel j) (Nat.zero_lt_succ _) (congrArg Prod.fst hp) + have hef : e = f := congrArg Prod.snd hp + subst q + subst f + rfl + +noncomputable def allocatedDeckFullEmbedding (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) : + AllocatedDeckRankCoefficientIndex E L ↪ CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E := + ⟨allocatedDeckFullSlot kernel, allocatedDeckFullSlot_injective kernel⟩ + +def allocatedMixedFullArray {R : Type*} + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → R) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → R) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → R) : + AllocatedActualCoefficientIndex G X I E n B → R := + Sum.elim smooth (Sum.elim deck continuous) ∘ allocatedFullCoefficientSplit + +@[simp] theorem allocatedMixedFullArray_noise {R : Type*} + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → R) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → R) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → R) (x) : + allocatedReadNoise (allocatedMixedFullArray smooth deck continuous) x = smooth (.inl x) := rfl + +@[simp] theorem allocatedMixedFullArray_deck {R : Type*} + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → R) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → R) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → R) (j) (q) (e) : + allocatedReadDeck (allocatedMixedFullArray smooth deck continuous) j q e = deck ⟨j,q,e⟩ := rfl + +@[simp] theorem allocatedMixedFullArray_integer {R : Type*} + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → R) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → R) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → R) (j) (q) (i) : + allocatedReadProjection (allocatedMixedFullArray smooth deck continuous) ⟨j,.inr i⟩ q = + smooth (.inr ⟨j,q,i⟩) := rfl + +@[simp] theorem allocatedMixedFullArray_continuous {R : Type*} + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → R) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → R) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → R) (j) (q) (i) : + allocatedReadProjection (allocatedMixedFullArray smooth deck continuous) ⟨j,.inl i⟩ q = + continuous ⟨j,q,i⟩ := rfl + +def allocatedReadFullSmooth {R : Type*} + (f : AllocatedActualCoefficientIndex G X I E n B → R) : + AllocatedFullSmoothCoefficientIndex G X I n B → R + | .inl x => allocatedReadNoise f x + | .inr ⟨j,q,i⟩ => allocatedReadProjection f ⟨j,.inr i⟩ q + +def allocatedReadFullDeck {R : Type*} + (f : AllocatedActualCoefficientIndex G X I E n B → R) : + CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → R := + fun ⟨j,q,e⟩ => allocatedReadDeck f j q e + +def allocatedReadFullContinuous {R : Type*} + (f : AllocatedActualCoefficientIndex G X I E n B → R) : + AllocatedFullContinuousCoefficientIndex G I n B → R := + fun ⟨j,q,i⟩ => allocatedReadProjection f ⟨j,.inl i⟩ q + +theorem allocatedMixedFullArray_read {R : Type*} + (f : AllocatedActualCoefficientIndex G X I E n B → R) : + allocatedMixedFullArray (allocatedReadFullSmooth f) (allocatedReadFullDeck f) + (allocatedReadFullContinuous f) = f := by + funext t + rcases t with x | d | ⟨⟨j,(i | i)⟩,q⟩ <;> rfl + +theorem allocatedMixedFullArray_reduce {N : ℕ} [NeZero N] + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) : + (fun t => ((allocatedMixedFullArray (R := ℤ) smooth (fun k => (deck k).val) continuous t : ℤ) : ZMod N)) = + allocatedMixedFullArray (fun k => (smooth k : ZMod N)) deck + (fun k => (continuous k : ZMod N)) := by + funext t + rcases t with x | d | ⟨⟨j,(i | i)⟩,q⟩ + · rfl + · change (((deck d).val : ℤ) : ZMod N) = deck d + simp only [Int.cast_natCast, ZMod.natCast_zmod_val] + · rfl + · rfl + +theorem allocatedFullCoefficientSplit_selected + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) + (s : AllocatedCongruenceCoefficientIndex X E inactive L) : + allocatedFullCoefficientSplit (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block s) = + mixedArrayEmbedding (allocatedSmoothFullEmbedding inactive spatial block) + (allocatedDeckFullEmbedding kernel) (allocatedCongruenceCoefficientSplit inactive L s) := by + rcases s with ⟨j,(x | e | i),l⟩ <;> rfl + +theorem allocatedMixedFullArray_refresh {R : Type*} + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) + (selectedSmooth : AllocatedSmoothRankCoefficientIndex X inactive L → R) + (selectedDeck : AllocatedDeckRankCoefficientIndex E L → R) + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → R) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → R) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → R) : + allocatedMixedFullArray + (Function.extend (allocatedSmoothFullEmbedding inactive spatial block) selectedSmooth smooth) + (Function.extend (allocatedDeckFullEmbedding kernel) selectedDeck deck) continuous = + Function.extend (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + (Sum.elim selectedSmooth selectedDeck ∘ allocatedCongruenceCoefficientSplit inactive L) + (allocatedMixedFullArray smooth deck continuous) := + mixedArray_extend_comp_equiv (allocatedSmoothFullEmbedding inactive spatial block) + (allocatedDeckFullEmbedding kernel) (allocatedCongruenceCoefficientSplit inactive L) + allocatedFullCoefficientSplit (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + (allocatedFullCoefficientSplit_selected inactive spatial kernel block) + selectedSmooth selectedDeck smooth deck continuous + +theorem allocatedMixedFullArray_refresh_selected {N : ℕ} + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) + (selectedSmooth : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (selectedDeck : AllocatedDeckRankCoefficientIndex E L → ZMod N) + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) : + allocatedMixedFullArray + (Function.extend (allocatedSmoothFullEmbedding inactive spatial block) selectedSmooth smooth) + (fun k => ((Function.extend (allocatedDeckFullEmbedding kernel) selectedDeck deck k).val : ℤ)) continuous = + Function.extend (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + (allocatedMixedSelectedValues inactive selectedSmooth selectedDeck) + (allocatedMixedFullArray smooth (fun k => (deck k).val) continuous) := by + have hdeck : (fun k => ((Function.extend (allocatedDeckFullEmbedding kernel) selectedDeck deck k).val : ℤ)) = + Function.extend (allocatedDeckFullEmbedding kernel) (fun k => ((selectedDeck k).val : ℤ)) (fun k => ((deck k).val : ℤ)) := by + funext k + exact Function.apply_extend (fun z : ZMod N => (z.val : ℤ)) _ _ _ + rw [hdeck] + exact allocatedMixedFullArray_refresh inactive spatial kernel block selectedSmooth + (fun k => (selectedDeck k).val) smooth (fun k => (deck k).val) continuous + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + +noncomputable def allocatedFullSmoothScalarPMF + (noisePMF : Option (LayerSamplerVariables G I n B) × X → PMF ℤ) : + AllocatedFullSmoothCoefficientIndex G X I n B → PMF ℤ + | .inl x => noisePMF x + | .inr ⟨j,q,i⟩ => allocatedLayerIntegerPMFs B U basis hR hσ S j i q + +variable (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j,a.val⟩) + (noiseCenter noiseWidth : Fin L → X → ℝ) + +noncomputable def allocatedSelectedSmoothCenter : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ + | ⟨_j,.inl x,l⟩ => noiseCenter l x.val + | ⟨j,.inr i,_l⟩ => allocatedPrincipalRankCenter B U basis S j i.val + +noncomputable def allocatedSelectedSmoothWidth : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ + | ⟨_j,.inl x,l⟩ => noiseWidth l x.val + | ⟨j,.inr i,_l⟩ => allocatedPrincipalRankWidth B U basis S j i.val + +include hR in +theorem allocatedSelectedSmoothWidth_pos (hnoise : ∀ l x, 0 < noiseWidth l x) + (a : AllocatedSmoothRankCoefficientIndex X inactive L) : + 0 < allocatedSelectedSmoothWidth B U basis S inactive noiseWidth a := by + rcases a with ⟨j,(x | i),l⟩ + · exact hnoise l x.val + · exact allocatedPrincipalRankWidth_pos B U basis hR S j i.val + +include hR in +theorem allocatedSelectedSmoothMass_pos + (hnoise : ∀ l x, 0 < shiftedSmoothSampleSum (noiseCenter l x) (noiseWidth l x)) + (hactive : ∀ j (i : AllocatedCongruenceIntegerAxis inactive j), + S.value ^ (j.val + 1) < basisAxisScale (basis j) i.val) + (a : AllocatedSmoothRankCoefficientIndex X inactive L) : + 0 < shiftedSmoothSampleSum (allocatedSelectedSmoothCenter B U basis S inactive noiseCenter a) + (allocatedSelectedSmoothWidth B U basis S inactive noiseWidth a) := by + rcases a with ⟨j,(x | i),l⟩ + · exact hnoise l x.val + · exact allocatedPrincipalRankMass_pos B U basis hR S j i.val (hactive j i) + +theorem allocatedFullSmoothScalarPMF_selected + (noisePMF : Option (LayerSamplerVariables G I n B) × X → PMF ℤ) + (hnoiseWidth : ∀ l x, 0 < noiseWidth l x) + (hnoiseMass : ∀ l x, 0 < shiftedSmoothSampleSum (noiseCenter l x) (noiseWidth l x)) + (hnoise : ∀ l x, noisePMF (some (.inl (spatial l)), x) = + shiftedSmoothCoefficientPMF (noiseCenter l x) (noiseWidth l x) + (hnoiseWidth l x) (hnoiseMass l x)) + (hactive : ∀ j (i : AllocatedCongruenceIntegerAxis inactive j), + S.value ^ (j.val + 1) < basisAxisScale (basis j) i.val) + (a : AllocatedSmoothRankCoefficientIndex X inactive L) : + allocatedFullSmoothScalarPMF B U basis hR hσ S noisePMF + (allocatedSmoothFullEmbedding inactive spatial block a) = + shiftedSmoothCoefficientPMF + (allocatedSelectedSmoothCenter B U basis S inactive noiseCenter a) + (allocatedSelectedSmoothWidth B U basis S inactive noiseWidth a) + (allocatedSelectedSmoothWidth_pos B U basis hR S inactive noiseWidth hnoiseWidth a) + (allocatedSelectedSmoothMass_pos B U basis hR S inactive noiseCenter noiseWidth + hnoiseMass hactive a) := by + rcases a with ⟨j,(x | i),l⟩ + · exact hnoise l x.val + · exact allocatedLayerIntegerPMFs_principal_shiftedSmooth B U basis hR hσ S j i.val + (hactive j i) (block j ⟨.inr i.val,i.property⟩ l) + +theorem allocatedGridPrincipalRank_active (j : Fin m) + (i : AllocatedCongruenceIntegerAxis (allocatedGridAxis (I := I) U basis S.value) j) : + S.value ^ (j.val + 1) < basisAxisScale (basis j) i.val := by + have hlarge : S.value ^ (layerTailDegree m + 1) < basisAxisScale (basis j) i.val := + Nat.lt_of_not_ge i.property + exact (Nat.pow_le_pow_right S.positive + ((layerDegree_le_tailDegree j).trans (Nat.le_succ _))).trans_lt hlarge + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +theorem allocatedFullSmoothProductPMF_factorization + {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + (noisePMF : Option (LayerSamplerVariables G I n B) × X → PMF ℤ) : + independentProductPMF (allocatedFullSmoothScalarPMF B U basis hR hσ S noisePMF) = + (independentProductPMF noisePMF).bind (fun noise => + (allocatedCoefficientIntegerPMF B U basis hR hσ S).map (Sum.elim noise)) := + independentProductPMF_sum (allocatedFullSmoothScalarPMF B U basis hR hσ S noisePMF) + +theorem coefficientDeckScalar_uniform_map {K : Type*} [Fintype K] + {m : ℕ} {E : Fin m → Type*} [∀ j, Fintype (E j)] + (N : ℕ) [NeZero N] : + (PMF.uniformOfFintype (CoefficientDeckResidues (K := K) E N)).map + (coefficientDeckScalarEquiv (K := K) (E := E) (N := N)) = + PMF.uniformOfFintype (CoefficientDeckScalarIndex K E → ZMod N) := by + let e := coefficientDeckScalarEquiv (K := K) (E := E) (N := N) + ext y + obtain ⟨x, rfl⟩ := e.surjective y + change (PMF.uniformOfFintype _).map e (e x) = _ + rw [pmf_map_injective_at _ _ e.injective] + simp only [PMF.uniformOfFintype_apply, Fintype.card_congr e] + +theorem coefficientDeckScalar_uniform_symm_map {K : Type*} [Fintype K] + {m : ℕ} {E : Fin m → Type*} [∀ j, Fintype (E j)] + (N : ℕ) [NeZero N] : + (PMF.uniformOfFintype (CoefficientDeckScalarIndex K E → ZMod N)).map + (coefficientDeckScalarEquiv (K := K) (E := E) (N := N)).symm = + PMF.uniformOfFintype (CoefficientDeckResidues (K := K) E N) := by + let e := (coefficientDeckScalarEquiv (K := K) (E := E) (N := N)).symm + ext y + obtain ⟨x, rfl⟩ := e.surjective y + change (PMF.uniformOfFintype _).map e (e x) = _ + rw [pmf_map_injective_at _ _ e.injective] + simp only [PMF.uniformOfFintype_apply, Fintype.card_congr e] + +theorem coefficientDeckScalar_uniform_test {K : Type*} + {m : ℕ} {E : Fin m → Type*} (N : ℕ) + [Fintype (CoefficientDeckResidues (K := K) E N)] + [Fintype (CoefficientDeckScalarIndex K E → ZMod N)] + {Y : Type*} (test : (CoefficientDeckScalarIndex K E → ZMod N) → Y) : + (PMF.uniformOfFintype (CoefficientDeckResidues (K := K) E N)).map + (fun deck => test (coefficientDeckScalarEquiv deck)) = + (PMF.uniformOfFintype (CoefficientDeckScalarIndex K E → ZMod N)).map test := by + let e := coefficientDeckScalarEquiv (K := K) (E := E) (N := N) + have he : (PMF.uniformOfFintype (CoefficientDeckResidues (K := K) E N)).map e = + PMF.uniformOfFintype (CoefficientDeckScalarIndex K E → ZMod N) := by + ext y + obtain ⟨x, rfl⟩ := e.surjective y + rw [pmf_map_injective_at _ _ e.injective] + simp only [PMF.uniformOfFintype_apply, Fintype.card_congr e] + have h := congrArg (fun p => p.map test) he + simpa only [PMF.map_comp, Function.comp_def] using h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankFullWitness.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankFullWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc8ecef8aa289c6f42ce5c2f190237ce758825e0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankFullWitness.lean @@ -0,0 +1,295 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedModularRankAffineFullWitness + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical +open FiniteProbabilityWeights + +private theorem largestBadDepth_pullback {Ω Ξ : Type*} (A : ℕ → ℕ) + (bad : ℕ → ℕ → Ω → Prop) (f : Ξ → Ω) (p : ℕ) (x : Ξ) : + largestTestedBadDepth A (fun p a x => bad p a (f x)) p x = + largestTestedBadDepth A bad p (f x) := rfl + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable local instance actualBadSmoothFintype (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedSmoothRankCoefficientIndex X inactive L) := inferInstance +noncomputable local instance actualBadDeckFintype : + Fintype (AllocatedDeckRankCoefficientIndex E L) := inferInstance +noncomputable local instance actualBadDeckDecidableEq : + DecidableEq (AllocatedDeckRankCoefficientIndex E L) := Classical.decEq _ + +variable (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (fixed : AllocatedActualCoefficientIndex G X I E n B → ℤ) + +noncomputable def allocatedMixedActualCoefficientSample {N : ℕ} + (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + AllocatedActualCoefficientIndex G X I E n B → ℤ := + Function.extend (allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block) + (allocatedMixedSelectedValues inactive x deck) fixed + +noncomputable def allocatedMixedActualBadProduct {N : ℕ} + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) (C : ℝ) + (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : ℕ := + let f := allocatedMixedActualCoefficientSample inactive spatial kernel block fixed x deck + ∏ p ∈ P, p ^ allocatedCongruenceBadDepth inactive (allocatedReadNoise f) (allocatedReadDeck f) + (fun j a => allocatedReadProjection f ⟨j,a.val⟩) spatial kernel block P A C p + +theorem allocatedMixedActualBadProduct_eq {N : ℕ} + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) (C : ℝ) + (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + allocatedMixedActualBadProduct inactive spatial kernel block fixed P A C x deck = + ∏ p ∈ P, p ^ largestTestedBadDepth A + (allocatedCongruenceRankBad inactive (allocatedReadNoise fixed) (allocatedReadDeck fixed) + (fun j a => allocatedReadProjection fixed ⟨j,a.val⟩) spatial kernel block P C) + p (allocatedMixedSelectedValues inactive x deck) := by + simp only [allocatedMixedActualBadProduct, allocatedMixedActualCoefficientSample, + allocatedActualRefresh_badDepth] + +theorem allocatedMixedActual_primePower_event {N D : ℕ} [NeZero N] + (hm : 0 < m) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ width j) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedActualCoefficientSample inactive spatial kernel block fixed x.1.val x.2)) ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) / width j := by + have h := allocatedMixedRank_primePower_event inactive + (allocatedReadNoise fixed) (allocatedReadDeck fixed) + (fun j a => allocatedReadProjection fixed ⟨j,a.val⟩) spatial kernel block hm + center width hwidth hZ P A hprime hcover hpositive hD hC hL hthreshold hlarge + simpa only [allocatedActualModulusBad, allocatedMixedActualCoefficientSample, + allocatedActualRefresh_modulusBad] using h + +theorem allocatedMixedActual_bad_product_probability {N D Q R : ℕ} [NeZero N] + (hm : 0 < m) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hQ : 1 ≤ Q) (hR : 0 < R) (hdepth : ∀ p ∈ P, p ^ A p ≤ Q) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) ≤ width j) + {η : ℝ} (hη : 0 ≤ η) + (herror : (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (max Q (R ^ 2) : ℕ) / width j) ≤ η) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => smallPrimePowerCorrection (modularCoefficientPrimeThreshold m) * R < + allocatedMixedActualBadProduct inactive spatial kernel block fixed P A C x.1.val x.2) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Q : ℝ) + (R : ℝ) ^ 2) * η := by + have h := allocatedMixedRank_bad_product_probability inactive + (allocatedReadNoise fixed) (allocatedReadDeck fixed) + (fun j a => allocatedReadProjection fixed ⟨j,a.val⟩) spatial kernel block hm + center width hwidth hZ P A hprime hcover hQ hR hdepth hD hC hL hlarge hη herror + simpa only [allocatedMixedActualBadProduct_eq, largestBadDepth_pullback] using h + +theorem exists_early_allocatedMixedActual_bad_product_cutoff {D : ℕ} + (hm : 0 < m) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ (Q N : ℕ) [NeZero N] + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (fixed : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width), + 1 ≤ Q → (∀ p ∈ P, p.Prime) → (∀ p ∈ P, p ^ A p ∣ N) → + (∀ p ∈ P, p ^ A p ≤ Q) → + (∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) ≤ width j) → + (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (max Q (R ^ 2) : ℕ) / width j) ≤ + δ / (2 * ((Q : ℝ) + (R : ℝ) ^ 2)) → + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun x => smallPrimePowerCorrection (modularCoefficientPrimeThreshold m) * R < + allocatedMixedActualBadProduct inactive spatial kernel block fixed P A C x.1.val x.2) ≤ δ := by + obtain ⟨R, hR, hradius⟩ := exists_early_badPrime_radius hδ + refine ⟨R, hR, ?_⟩ + intro Q N _ P A _ fixed center width hwidth hZ hQ hprime hcover hdepth hlarge herror + exact (allocatedMixedActual_bad_product_probability inactive spatial kernel block fixed hm + center width hwidth hZ P A hprime hcover hQ hR hdepth hD hC hL hlarge + (hradius Q hQ).1.le herror).trans (hradius Q hQ).2 + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical +open FiniteProbabilityWeights +attribute [local irreducible] allocatedActualModulusBad allocatedMixedFullArray independentProductPMF + +private theorem decide_eq_classical (p : Prop) [d : Decidable p] : + @decide p d = @decide p (Classical.propDecidable p) := by + cases Subsingleton.elim d (Classical.propDecidable p) + rfl + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +noncomputable local instance fullWitnessSmoothFintype : + Fintype (AllocatedFullSmoothCoefficientIndex G X I n B) := inferInstance +noncomputable local instance fullWitnessSmoothDecidableEq : + DecidableEq (AllocatedFullSmoothCoefficientIndex G X I n B) := Classical.decEq _ +noncomputable local instance fullWitnessSelectedSmoothDecidableEq (inactive : LayerSamplerAxis I n → Prop) : + DecidableEq (AllocatedSmoothRankCoefficientIndex X inactive L) := Classical.decEq _ +noncomputable local instance fullWitnessDeckFintype : + Fintype (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := inferInstance +noncomputable local instance fullWitnessDeckDecidableEq : + DecidableEq (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := Classical.decEq _ +noncomputable local instance fullWitnessSelectedSmoothFintype (inactive : LayerSamplerAxis I n → Prop) : + Fintype (AllocatedSmoothRankCoefficientIndex X inactive L) := inferInstance +noncomputable local instance fullWitnessSelectedDeckFintype : + Fintype (AllocatedDeckRankCoefficientIndex E L) := inferInstance +noncomputable local instance fullWitnessSelectedDeckDecidableEq : + DecidableEq (AllocatedDeckRankCoefficientIndex E L) := Classical.decEq _ + +theorem allocatedFullMixed_witness_iff + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (N : ℕ) [NeZero N] (hdiv : ∀ p : P, p.val ^ A p.val ∣ N) + (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) : + allocatedResiduePrimePowerWitness inactive C P A N hdiv + (allocatedMixedFullArray (fun i => (smooth i : ZMod N)) deck + (fun i => (continuous i : ZMod N))) ↔ + ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray smooth (fun i => (deck i).val) continuous) := by + rw [← allocatedMixedFullArray_reduce] + exact allocatedResiduePrimePowerWitness_iff_actual inactive spatial kernel block C P A N hdiv _ + +theorem allocatedFullMixed_primePower_event + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) + {N D : ℕ} [NeZero N] (hm : 0 < m) + (center width : AllocatedFullSmoothCoefficientIndex G X I n B → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ width (allocatedSmoothFullEmbedding inactive spatial block j)) : + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N))).eventProbability + (fun x => ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray x.1.val (fun i => (x.2 i).val) continuous)) ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j : AllocatedSmoothRankCoefficientIndex X inactive L, + 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / + width (allocatedSmoothFullEmbedding inactive spatial block j) := by + let e := allocatedSmoothFullEmbedding (X := X) inactive spatial block + let d := allocatedDeckFullEmbedding (E := E) (I := I) (n := n) (B := B) kernel + apply mixedSmoothUniform_refresh_event_probability_le e d center width hwidth hZ N + (fun x deck => ∀ p : P, + allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray x (fun i => (deck i).val) continuous)) + · exact add_nonneg (by positivity) (Finset.sum_nonneg (fun j _ => + div_nonneg (by positivity) (hwidth _).le)) + · intro fixed fixedDeck + have h := allocatedMixedActual_primePower_event inactive spatial kernel block + (allocatedMixedFullArray fixed (fun i => (fixedDeck i).val) continuous) hm + (fun i => center (e i)) (fun i => width (e i)) (fun i => hwidth (e i)) + (shiftedSmoothProductMass_restrict_pos e center width hwidth hZ) + P A hprime hcover hpositive hD hC hL hthreshold hlarge + simpa only [e, d, allocatedMixedFullArray_refresh_selected, + allocatedMixedActualCoefficientSample] using h + +theorem allocatedProductMixed_primePower_event + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) + (laws : AllocatedFullSmoothCoefficientIndex G X I n B → PMF ℤ) + {N D : ℕ} [NeZero N] (hm : 0 < m) + (center width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (hwidth : ∀ j, 0 < width j) (hZ : 0 < shiftedSmoothProductMass center width) + (hcoordinate : ∀ i, laws (allocatedSmoothFullEmbedding inactive spatial block i) = + shiftedSmoothCoefficientPMF (center i) (width i) (hwidth i) + (shiftedSmoothProductMass_coordinate_pos center width hwidth hZ i)) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ width j) : + (((independentProductPMF laws).bind + (fun x => (PMF.uniformOfFintype + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N)).map + (fun deck => decide (∀ p : P, + allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray x (fun i => (deck i).val) continuous))))) true).toReal ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / width j := by + let e := allocatedSmoothFullEmbedding (X := X) inactive spatial block + let d := allocatedDeckFullEmbedding (E := E) (I := I) (n := n) (B := B) kernel + let bad : (AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) → + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) → Prop := + fun x deck => ∀ p : P, + allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray x (fun i => (deck i).val) continuous) + let δ : ℝ := 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / width j + have hδ : 0 ≤ δ := add_nonneg (by positivity) + (Finset.sum_nonneg (fun j _ => div_nonneg (by positivity) (hwidth _).le)) + have hconditional : ∀ (fixed : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (fixedDeck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N), + ((shiftedSmoothProductFiniteWeights center width hwidth hZ).prod + (uniform (AllocatedDeckRankCoefficientIndex E L → ZMod N))).eventProbability + (fun z => bad (Function.extend e z.1.val fixed) (Function.extend d z.2 fixedDeck)) ≤ δ := by + intro fixed fixedDeck + have h := allocatedMixedActual_primePower_event inactive spatial kernel block + (allocatedMixedFullArray fixed (fun i => (fixedDeck i).val) continuous) hm + center width hwidth hZ P A hprime hcover hpositive hD hC hL hthreshold hlarge + simpa only [bad, e, d, δ, allocatedMixedFullArray_refresh_selected, + allocatedMixedActualCoefficientSample] using h + have h := independentProduct_uniform_smooth_selected_event_probability_le + e d laws center width hwidth hZ hcoordinate N bad hδ hconditional + simpa only [bad, δ, decide_eq_classical] using h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankMixedUniform.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankMixedUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..973e454cab47264668abbc2371e9733b1de20cbc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankMixedUniform.lean @@ -0,0 +1,971 @@ +import OAI.Combinatorics.Progressions.Linear.SpatialMatrixBlockWideProbability + +namespace OAI + +section + +namespace Erdos3 +open VectorPolynomial +open scoped BigOperators Matrix + +theorem modularBoundedCoefficientPolynomial_booleanCoefficient + {α K O : Type*} [DecidableEq α] [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (h N : ℕ) + (rows : O → Finset α) (c : BoundedCoefficientExponent K h → ZMod N) (t : O) : + booleanCoefficient (fun s => MvPolynomial.eval + (fun k => (integerAffineCube root D s k : ZMod N)) + (modularBoundedCoefficientPolynomial h c)) (rows t) = + ∑ e, (boundedCoefficientJetMatrix root D h rows t e : ZMod N) * c e := by + classical + simp only [modularBoundedCoefficientPolynomial, map_sum, MvPolynomial.eval_monomial] + rw [booleanCoefficient_sum] + apply Finset.sum_congr rfl + intro e _ + rw [booleanCoefficient_const_mul] + rw [mul_comm] + congr 1 + change booleanCoefficient (fun s => e.val.prod + (fun k n => (integerAffineCube root D s k : ZMod N) ^ n)) (rows t) = + ((booleanCoefficient (fun s => MvPolynomial.eval (integerAffineCube root D s) + (MvPolynomial.monomial e.val (1 : ℤ))) (rows t) : ℤ) : ZMod N) + rw [show ((booleanCoefficient (fun s => MvPolynomial.eval (integerAffineCube root D s) + (MvPolynomial.monomial e.val (1 : ℤ))) (rows t) : ℤ) : ZMod N) = + (Int.castRingHom (ZMod N)) (booleanCoefficient (fun s => + MvPolynomial.eval (integerAffineCube root D s) + (MvPolynomial.monomial e.val (1 : ℤ))) (rows t)) from rfl, + booleanCoefficient_map] + simp only [MvPolynomial.eval_monomial, one_mul, Finsupp.prod, + Int.coe_castRingHom, Int.cast_prod, Int.cast_pow] + +namespace VectorPolynomial + +theorem coefficientDeckJetMap_eq_booleanCoefficient + {α K : Type*} [DecidableEq α] [Fintype K] + {m : ℕ} {O B : Fin m → Type*} + (root : K → ℤ) (D : Matrix α K ℤ) (rows : ∀ j, O j → Finset α) + (N : ℕ) (r : CoefficientDeckResidues (K := K) B N) + (j : Fin m) (t : O j) (i : B j) : + coefficientDeckJetMap root D rows N r j t i = + booleanCoefficient (fun s => MvPolynomial.eval + (fun k => (integerAffineCube root D s k : ZMod N)) + (modularBoundedCoefficientPolynomial (j.val + 1) (fun e => r j e i))) + (rows j t) := by + rw [modularBoundedCoefficientPolynomial_booleanCoefficient] + change (∑ e, boundedCoefficientJetMatrix root D (j.val + 1) (rows j) t e • r j e) i = _ + simp only [Finset.sum_apply, zsmul_eq_mul, Pi.mul_apply, Pi.intCast_apply] + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial VectorPolynomial +open scoped BigOperators Classical + +namespace VectorPolynomial + +variable {K : Type*} [Fintype K] {m : ℕ} {E : Fin m → Type*} {N : ℕ} + +noncomputable def modularDeckPolynomial (r : CoefficientDeckResidues (K := K) E N) + (j : Fin m) (i : E j) : MvPolynomial K (ZMod N) := + modularBoundedCoefficientPolynomial (j.val + 1) (fun e => r j e i) + +theorem coefficientDeckJetMap_eq_modularDeckPolynomial + {α : Type*} [DecidableEq α] {O : Fin m → Type*} + (root : K → ℤ) (D : Matrix α K ℤ) (rows : ∀ j, O j → Finset α) + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) (t : O j) (i : E j) : + coefficientDeckJetMap root D rows N r j t i = + booleanCoefficient (fun s => MvPolynomial.eval + (fun k => (integerAffineCube root D s k : ZMod N)) (modularDeckPolynomial r j i)) + (rows j t) := + coefficientDeckJetMap_eq_booleanCoefficient root D rows N r j t i + +theorem modularDeckPolynomial_degree (r : CoefficientDeckResidues (K := K) E N) + (j : Fin m) (i : E j) : (modularDeckPolynomial r j i).totalDegree ≤ j.val + 1 := by + apply totalDegree_finsetSum_le + intro e _ + exact (totalDegree_monomial_le e.val (r j e i)).trans e.property + +noncomputable def resampleCoefficientDeckCoordinate {A : Type*} + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (c : A → ZMod N) : + CoefficientDeckResidues (K := K) E N := + Function.update r j (fun e => Function.update (r j e) i + (Function.extend slot c (fun e => r j e i) e)) + +omit [Fintype K] in +theorem resampleCoefficientDeckCoordinate_apply {A : Type*} + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (c : A → ZMod N) + (e : BoundedCoefficientExponent K (j.val + 1)) : + resampleCoefficientDeckCoordinate r j i slot c j e i = + Function.extend slot c (fun e => r j e i) e := by + simp only [resampleCoefficientDeckCoordinate, Function.update_self] + +omit [Fintype K] in +theorem resampleCoefficientDeckCoordinate_selected {A : Type*} + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (c : A → ZMod N) (a : A) : + resampleCoefficientDeckCoordinate r j i slot c j (slot a) i = c a := by + rw [resampleCoefficientDeckCoordinate_apply, hinj.extend_apply] + +theorem modularDeckPolynomial_resample_top {A : Type*} [Fintype A] + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (hdegree : ∀ a, (slot a).val.degree = j.val + 1) (c : A → ZMod N) : + homogeneousComponent (j.val + 1) + (modularDeckPolynomial (resampleCoefficientDeckCoordinate r j i slot c) j i) = + homogeneousComponent (j.val + 1) + (modularUnselectedCoefficientPolynomial (j.val + 1) slot (fun e => r j e i)) + + ∑ a, MvPolynomial.monomial (slot a).val (c a) := by + simp only [modularDeckPolynomial, resampleCoefficientDeckCoordinate_apply] + exact modularBoundedCoefficientPolynomial_selected_top _ slot hinj hdegree _ c + +end VectorPolynomial + +variable {D G A : Type*} {B : D → Type*} {h : ℕ} + +theorem samplerLongEmbedding_kernelExponent (inactive : D → Prop) (degree : D → ℕ) + (e : A × Fin h ↪ G) (a : A) : + ((kernelRankCoefficientSlot (G := G) + (B := fun d : {d // ¬ inactive d} => B d.val) (fun d => degree d.val) e a).val).mapDomain + (samplerLongEmbedding inactive degree) = + (kernelRankCoefficientSlot (B := B) degree e a).val := by + simp only [kernelRankCoefficientSlot, productBlockExponent, + Finsupp.mapDomain_finsetSum, Finsupp.mapDomain_single, + kernelRankBlockEmbedding_apply, samplerLongEmbedding_common] + +namespace VectorPolynomial + +variable {m : ℕ} {I : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {E : Fin m → Type*} + [Fintype G] [∀ j, Fintype (I j)] [∀ a, Fintype (B a)] [Fintype A] + {N : ℕ} + +theorem modularDeckPolynomial_kernel_resample_top + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (j : Fin m) (i : E j) (e : A × Fin (j.val + 1) ↪ G) (c : A → ZMod N) : + homogeneousComponent (j.val + 1) + (modularDeckPolynomial (resampleCoefficientDeckCoordinate r j i + (kernelRankCoefficientSlot (layerSamplerDegree I n) e) c) j i) = + homogeneousComponent (j.val + 1) + (modularUnselectedCoefficientPolynomial (j.val + 1) + (kernelRankCoefficientSlot (layerSamplerDegree I n) e) (fun q => r j q i)) + + ∑ a, c a • ∏ k ∈ kernelRankBlock (layerSamplerDegree I n) e a, X k := by + rw [modularDeckPolynomial_resample_top r j i _ + (kernelRankCoefficientSlot_injective _ e (Nat.zero_lt_succ _)) + (kernelRankCoefficientSlot_degree _ e)] + simp_rw [kernelRankCoefficientSlot_monomial] + +theorem modularDeckPolynomial_kernel_resample_long_top + (inactive : LayerSamplerAxis I n → Prop) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N) + (j : Fin m) (i : E j) (e : A × Fin (j.val + 1) ↪ G) (c : A → ZMod N) + (v : LayerSamplerVariables G I n B → ZMod N) : + homogeneousComponent (j.val + 1) + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (modularDeckPolynomial (resampleCoefficientDeckCoordinate r j i + (kernelRankCoefficientSlot (layerSamplerDegree I n) e) c) j i)) = + killCompl (allocatedLongEmbedding inactive).injective + (homogeneousComponent (j.val + 1) + (modularUnselectedCoefficientPolynomial (j.val + 1) + (kernelRankCoefficientSlot (layerSamplerDegree I n) e) (fun q => r j q i))) + + ∑ a, c a • ∏ k ∈ kernelRankBlock + (B := fun d : {d : LayerSamplerAxis I n // ¬ inactive d} => B d.val) + (fun d => layerSamplerDegree I n d.val) e a, X k := by + rw [homogeneousComponent_conditionPolynomial_top _ _ _ v _ + (modularDeckPolynomial_degree _ j i)] + rw [modularDeckPolynomial_resample_top r j i _ + (kernelRankCoefficientSlot_injective _ e (Nat.zero_lt_succ _)) + (kernelRankCoefficientSlot_degree _ e), map_add, map_sum] + congr 1 + apply Finset.sum_congr rfl + intro a _ + change killCompl (samplerLongEmbedding inactive (layerSamplerDegree I n)).injective + (MvPolynomial.monomial (kernelRankCoefficientSlot (layerSamplerDegree I n) e a).val (c a)) = _ + rw [← samplerLongEmbedding_kernelExponent inactive (layerSamplerDegree I n) e a, + killCompl_monomial_mapDomain, kernelRankCoefficientSlot_monomial] + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {K A : Type*} {m : ℕ} {E : Fin m → Type*} {N : ℕ} + +abbrev CoefficientDeckScalarIndex (K : Type*) (E : Fin m → Type*) := + Σ j : Fin m, BoundedCoefficientExponent K (j.val + 1) × E j + +def coefficientDeckScalarEquiv : + CoefficientDeckResidues (K := K) E N ≃ (CoefficientDeckScalarIndex K E → ZMod N) where + toFun r t := r t.1 t.2.1 t.2.2 + invFun f j e i := f ⟨j, e, i⟩ + left_inv _ := rfl + right_inv _ := rfl + +def coefficientDeckSelectedEmbedding (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) : + A ↪ CoefficientDeckScalarIndex K E where + toFun a := ⟨j, slot a, i⟩ + inj' := by + intro a b hab + have he : (slot a, i) = (slot b, i) := by + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using hab + exact hinj (congrArg Prod.fst he) + +theorem coefficientDeckScalarEquiv_resample + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (c : A → ZMod N) : + coefficientDeckScalarEquiv (resampleCoefficientDeckCoordinate r j i slot c) = + Function.extend (coefficientDeckSelectedEmbedding j i slot hinj) c + (coefficientDeckScalarEquiv r) := by + funext t + rcases t with ⟨q, e, k⟩ + by_cases hq : q = j + · subst q + by_cases hk : k = i + · subst k + by_cases he : e ∈ Set.range slot + · obtain ⟨a, rfl⟩ := he + change resampleCoefficientDeckCoordinate r j i slot c j (slot a) i = + Function.extend (coefficientDeckSelectedEmbedding j i slot hinj) c + (coefficientDeckScalarEquiv r) (coefficientDeckSelectedEmbedding j i slot hinj a) + rw [resampleCoefficientDeckCoordinate_selected r j i slot hinj, + (coefficientDeckSelectedEmbedding j i slot hinj).injective.extend_apply] + · have hn : (⟨j, e, i⟩ : CoefficientDeckScalarIndex K E) ∉ + Set.range (coefficientDeckSelectedEmbedding j i slot hinj) := by + rintro ⟨a, ha⟩ + have hp : (slot a, i) = (e, i) := by + change (⟨j, slot a, i⟩ : CoefficientDeckScalarIndex K E) = ⟨j, e, i⟩ at ha + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using ha + exact he ⟨a, congrArg Prod.fst hp⟩ + change resampleCoefficientDeckCoordinate r j i slot c j e i = _ + rw [resampleCoefficientDeckCoordinate_apply, Function.extend_apply' c _ e he, + Function.extend_apply' c _ _ hn] + rfl + · have hn : (⟨j, e, k⟩ : CoefficientDeckScalarIndex K E) ∉ + Set.range (coefficientDeckSelectedEmbedding j i slot hinj) := by + rintro ⟨a, ha⟩ + have hp : (slot a, i) = (e, k) := by + change (⟨j, slot a, i⟩ : CoefficientDeckScalarIndex K E) = ⟨j, e, k⟩ at ha + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using ha + exact hk (congrArg Prod.snd hp).symm + rw [Function.extend_apply' c _ _ hn] + change resampleCoefficientDeckCoordinate r j i slot c j e k = r j e k + simp [resampleCoefficientDeckCoordinate, hk] + · have hn : (⟨q, e, k⟩ : CoefficientDeckScalarIndex K E) ∉ + Set.range (coefficientDeckSelectedEmbedding j i slot hinj) := by + rintro ⟨a, ha⟩ + exact hq (congrArg Sigma.fst ha).symm + rw [Function.extend_apply' c _ _ hn] + change resampleCoefficientDeckCoordinate r j i slot c q e k = r q e k + simp [resampleCoefficientDeckCoordinate, hq] + +variable [Fintype K] [Fintype A] [∀ j, Fintype (E j)] [NeZero N] + +theorem expect_resampleCoefficientDeckCoordinate + (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (F : CoefficientDeckResidues (K := K) E N → ℝ) : + (𝔼 r : CoefficientDeckResidues (K := K) E N, + 𝔼 c : A → ZMod N, F (resampleCoefficientDeckCoordinate r j i slot c)) = 𝔼 r, F r := by + let e := coefficientDeckScalarEquiv (K := K) (E := E) (N := N) + let f := coefficientDeckSelectedEmbedding j i slot hinj + calc + _ = 𝔼 r : CoefficientDeckScalarIndex K E → ZMod N, + 𝔼 c : A → ZMod N, F (e.symm (Function.extend f c r)) := by + apply Fintype.expect_equiv e + intro r + apply Finset.expect_congr rfl + intro c _ + rw [← coefficientDeckScalarEquiv_resample r j i slot hinj c] + rfl + _ = 𝔼 r : CoefficientDeckScalarIndex K E → ZMod N, F (e.symm r) := + expect_coordinate_resampling f f.injective (fun r => F (e.symm r)) + _ = _ := by + apply Fintype.expect_equiv e.symm + intro r + rfl + +theorem expect_coefficientDeck_selected + (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (F : (A → ZMod N) → ℝ) : + (𝔼 r : CoefficientDeckResidues (K := K) E N, F (fun a => r j (slot a) i)) = + 𝔼 c : A → ZMod N, F c := by + rw [← expect_resampleCoefficientDeckCoordinate j i slot hinj + (fun r => F (fun a => r j (slot a) i))] + simp only [resampleCoefficientDeckCoordinate_selected _ _ _ slot hinj] + exact Fintype.expect_const _ + +theorem coefficientDeck_expect_le_of_resampling + (j : Fin m) (i : E j) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (F : CoefficientDeckResidues (K := K) E N → ℝ) {C : ℝ} + (hF : ∀ r, (𝔼 c : A → ZMod N, F (resampleCoefficientDeckCoordinate r j i slot c)) ≤ C) : + (𝔼 r : CoefficientDeckResidues (K := K) E N, F r) ≤ C := by + rw [← expect_resampleCoefficientDeckCoordinate j i slot hinj F] + calc + _ ≤ 𝔼 _r : CoefficientDeckResidues (K := K) E N, C := + Finset.expect_le_expect (fun r _ => hF r) + _ = C := Fintype.expect_const C + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +abbrev AllocatedProjectionCoefficientIndex (K : Type*) (I : Fin m → Type*) (n : Fin m → ℕ) := + Σ a : LayerSamplerAxis I n, BoundedCoefficientExponent K (a.1.val + 1) + +abbrev AllocatedActualCoefficientIndex (G X : Type*) (I E : Fin m → Type*) + (n : Fin m → ℕ) (B : LayerSamplerAxis I n → Type*) := + (Option (LayerSamplerVariables G I n B) × X) ⊕ + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E ⊕ + AllocatedProjectionCoefficientIndex (LayerSamplerVariables G I n B) I n) + +abbrev AllocatedSelectedCoefficientIndex (X : Type*) (E : Fin m → Type*) + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) := + Σ j : Fin m, AllocatedTaggedRankOutput X E inactive j × Fin L + +noncomputable def allocatedActualCoefficientSlot + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) : + AllocatedSelectedCoefficientIndex X E inactive L → AllocatedActualCoefficientIndex G X I E n B + | ⟨_j, .inl x, l⟩ => .inl (some (.inl (spatial l)), x.val) + | ⟨j, .inr (.inl i), l⟩ => .inr (.inl ⟨j, + kernelRankCoefficientSlot (layerSamplerDegree I n) (kernel j) l, i⟩) + | ⟨j, .inr (.inr a), l⟩ => .inr (.inr ⟨⟨j, a.val⟩, + principalCoefficientSlot (layerSamplerDegree I n) ⟨j, a.val⟩ (block j a l)⟩) + +theorem allocatedActualCoefficientSlot_injective + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) : + Function.Injective (allocatedActualCoefficientSlot (X := X) (E := E) inactive spatial kernel block) := by + rintro ⟨j, o, l⟩ ⟨k, p, q⟩ he + cases o with + | inl x => + cases p with + | inl y => + have hjk : j = k := Fin.ext (x.property.trans y.property.symm) + subst k + change Sum.inl (some (Sum.inl (spatial l)), x.val) = + Sum.inl (some (Sum.inl (spatial q)), y.val) at he + have hp := Sum.inl.inj he + have hl : l = q := spatial.injective + (Sum.inl.inj (Option.some.inj (congrArg Prod.fst hp))) + have hxy : x = y := Subtype.ext (congrArg Prod.snd hp) + subst q + subst y + rfl + | inr p => cases p <;> cases he + | inr o => + cases p with + | inl y => cases o <;> cases he + | inr p => + cases o with + | inl i => + cases p with + | inl t => + have hh := Sum.inl.inj (Sum.inr.inj he) + have hjk : j = k := congrArg Sigma.fst hh + subst k + have hp : (kernelRankCoefficientSlot (B := B) (layerSamplerDegree I n) (kernel j) l, i) = + (kernelRankCoefficientSlot (B := B) (layerSamplerDegree I n) (kernel j) q, t) := by + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using hh + have hl : l = q := kernelRankCoefficientSlot_injective + (layerSamplerDegree I n) (kernel j) (Nat.zero_lt_succ _) (congrArg Prod.fst hp) + have hit : i = t := congrArg Prod.snd hp + subst q + subst t + rfl + | inr a => cases he + | inr a => + cases p with + | inl t => cases he + | inr b => + have hh := Sum.inr.inj (Sum.inr.inj he) + have haxis : (⟨j, a.val⟩ : LayerSamplerAxis I n) = ⟨k, b.val⟩ := congrArg Sigma.fst hh + have hjk : j = k := congrArg Sigma.fst haxis + subst k + have hab : a = b := Subtype.ext (by + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using haxis) + subst b + have hslot : principalCoefficientSlot (G := G) (layerSamplerDegree I n) ⟨j, a.val⟩ + (block j a l) = principalCoefficientSlot (layerSamplerDegree I n) ⟨j, a.val⟩ + (block j a q) := by + exact eq_of_heq (Sigma.mk.inj hh).2 + have hblocks := principalCoefficientSlot_injective (G := G) + (layerSamplerDegree I n) ⟨j, a.val⟩ (Nat.zero_lt_succ _) hslot + have hl : l = q := (block j a).injective hblocks + subst q + rfl + +noncomputable def allocatedActualCoefficientEmbedding + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) : + AllocatedSelectedCoefficientIndex X E inactive L ↪ AllocatedActualCoefficientIndex G X I E n B := + ⟨allocatedActualCoefficientSlot inactive spatial kernel block, + allocatedActualCoefficientSlot_injective inactive spatial kernel block⟩ + +variable {R : Type*} + +def allocatedReadNoise (f : AllocatedActualCoefficientIndex G X I E n B → R) : + Option (LayerSamplerVariables G I n B) × X → R := + fun t => f (.inl t) + +def allocatedReadDeck (f : AllocatedActualCoefficientIndex G X I E n B → R) : + ∀ j : Fin m, BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → R := + fun j e i => f (.inr (.inl ⟨j, e, i⟩)) + +def allocatedReadProjection (f : AllocatedActualCoefficientIndex G X I E n B → R) : + ∀ a : LayerSamplerAxis I n, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (a.1.val + 1) → R := + fun a e => f (.inr (.inr ⟨a, e⟩)) + +def allocatedActualCoefficientEquiv (R : Type*) : + (AllocatedActualCoefficientIndex G X I E n B → R) ≃ + ((Option (LayerSamplerVariables G I n B) × X → R) × + (∀ j : Fin m, BoundedCoefficientExponent (LayerSamplerVariables G I n B) + (j.val + 1) → E j → R) × + (∀ a : LayerSamplerAxis I n, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (a.1.val + 1) → R)) where + toFun f := (allocatedReadNoise f, allocatedReadDeck f, allocatedReadProjection f) + invFun p t := match t with + | .inl t => p.1 t + | .inr (.inl ⟨j, e, i⟩) => p.2.1 j e i + | .inr (.inr ⟨a, e⟩) => p.2.2 a e + left_inv f := by + funext t + rcases t with t | t | t <;> rfl + right_inv p := rfl + +theorem allocatedActualCoefficientSlot_read_spatial + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → R) + (j : Fin m) (x : SpatialDegreeOutput X j) (l : Fin L) : + f (allocatedActualCoefficientSlot inactive spatial kernel block ⟨j, .inl x, l⟩) = + allocatedReadNoise f (some (.inl (spatial l)), x.val) := rfl + +theorem allocatedActualCoefficientSlot_read_deck + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → R) + (j : Fin m) (i : E j) (l : Fin L) : + f (allocatedActualCoefficientSlot inactive spatial kernel block ⟨j, .inr (.inl i), l⟩) = + allocatedReadDeck f j (kernelRankCoefficientSlot (layerSamplerDegree I n) (kernel j) l) i := rfl + +theorem allocatedActualCoefficientSlot_read_projection + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (f : AllocatedActualCoefficientIndex G X I E n B → R) + (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j) (l : Fin L) : + f (allocatedActualCoefficientSlot inactive spatial kernel block ⟨j, .inr (.inr a), l⟩) = + allocatedReadProjection f ⟨j, a.val⟩ + (principalCoefficientSlot (layerSamplerDegree I n) ⟨j, a.val⟩ (block j a l)) := rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {K A : Type*} {m : ℕ} {E : Fin m → Type*} {N : ℕ} + +noncomputable def resampleCoefficientDeckLayer + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (c : E j → A → ZMod N) : + CoefficientDeckResidues (K := K) E N := + Function.update r j (fun e i => Function.extend slot (c i) (fun e => r j e i) e) + +theorem resampleCoefficientDeckLayer_apply + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (c : E j → A → ZMod N) + (e : BoundedCoefficientExponent K (j.val + 1)) (i : E j) : + resampleCoefficientDeckLayer r j slot c j e i = + Function.extend slot (c i) (fun e => r j e i) e := by + simp only [resampleCoefficientDeckLayer, Function.update_self] + +theorem resampleCoefficientDeckLayer_selected + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (c : E j → A → ZMod N) (a : A) (i : E j) : + resampleCoefficientDeckLayer r j slot c j (slot a) i = c i a := by + rw [resampleCoefficientDeckLayer_apply, hinj.extend_apply] + +theorem modularDeckPolynomial_resampleLayer [Fintype K] + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (c : E j → A → ZMod N) + (i : E j) : + modularDeckPolynomial (resampleCoefficientDeckLayer r j slot c) j i = + modularDeckPolynomial (resampleCoefficientDeckCoordinate r j i slot (c i)) j i := by + simp only [modularDeckPolynomial, resampleCoefficientDeckLayer_apply, + resampleCoefficientDeckCoordinate_apply] + +theorem exists_coefficientDeck_layer_witness [Fintype K] + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (c : E j → A → ZMod N) : + ∃ r' : CoefficientDeckResidues (K := K) E N, ∀ i : E j, + modularDeckPolynomial r' j i = + modularDeckPolynomial (resampleCoefficientDeckCoordinate r j i slot (c i)) j i := + ⟨resampleCoefficientDeckLayer r j slot c, modularDeckPolynomial_resampleLayer r j slot c⟩ + +def coefficientDeckLayerSelectedEmbedding (j : Fin m) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) : + E j × A ↪ CoefficientDeckScalarIndex K E where + toFun p := ⟨j, slot p.2, p.1⟩ + inj' := by + intro a b hab + have hp : (slot a.2, a.1) = (slot b.2, b.1) := by + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using hab + exact Prod.ext (congrArg Prod.snd hp) (hinj (congrArg Prod.fst hp)) + +def coefficientDeckLayerFreshEquiv (j : Fin m) : + (E j → A → ZMod N) ≃ (E j × A → ZMod N) where + toFun c p := c p.1 p.2 + invFun c i a := c (i, a) + left_inv _ := rfl + right_inv _ := rfl + +theorem coefficientDeckScalarEquiv_resampleLayer + (r : CoefficientDeckResidues (K := K) E N) (j : Fin m) + (slot : A → BoundedCoefficientExponent K (j.val + 1)) (hinj : Function.Injective slot) + (c : E j → A → ZMod N) : + coefficientDeckScalarEquiv (resampleCoefficientDeckLayer r j slot c) = + Function.extend (coefficientDeckLayerSelectedEmbedding j slot hinj) + (coefficientDeckLayerFreshEquiv j c) (coefficientDeckScalarEquiv r) := by + funext t + rcases t with ⟨q, e, i⟩ + by_cases hq : q = j + · subst q + by_cases he : e ∈ Set.range slot + · obtain ⟨a, rfl⟩ := he + change resampleCoefficientDeckLayer r j slot c j (slot a) i = + Function.extend (coefficientDeckLayerSelectedEmbedding j slot hinj) + (coefficientDeckLayerFreshEquiv j c) (coefficientDeckScalarEquiv r) + (coefficientDeckLayerSelectedEmbedding j slot hinj (i, a)) + rw [resampleCoefficientDeckLayer_selected r j slot hinj, + (coefficientDeckLayerSelectedEmbedding j slot hinj).injective.extend_apply] + rfl + · have hn : (⟨j, e, i⟩ : CoefficientDeckScalarIndex K E) ∉ + Set.range (coefficientDeckLayerSelectedEmbedding j slot hinj) := by + rintro ⟨a, ha⟩ + have hp : (slot a.2, a.1) = (e, i) := by + change (⟨j, slot a.2, a.1⟩ : CoefficientDeckScalarIndex K E) = ⟨j, e, i⟩ at ha + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and] using ha + exact he ⟨a.2, congrArg Prod.fst hp⟩ + change resampleCoefficientDeckLayer r j slot c j e i = _ + rw [resampleCoefficientDeckLayer_apply, Function.extend_apply' (c i) _ e he, + Function.extend_apply' _ _ _ hn] + rfl + · have hn : (⟨q, e, i⟩ : CoefficientDeckScalarIndex K E) ∉ + Set.range (coefficientDeckLayerSelectedEmbedding j slot hinj) := by + rintro ⟨a, ha⟩ + exact hq (congrArg Sigma.fst ha).symm + rw [Function.extend_apply' _ _ _ hn] + change resampleCoefficientDeckLayer r j slot c q e i = r q e i + simp [resampleCoefficientDeckLayer, hq] + +variable [Fintype K] [Fintype A] [∀ j, Fintype (E j)] [NeZero N] + +theorem expect_resampleCoefficientDeckLayer + (j : Fin m) (slot : A → BoundedCoefficientExponent K (j.val + 1)) + (hinj : Function.Injective slot) (F : CoefficientDeckResidues (K := K) E N → ℝ) : + (𝔼 r : CoefficientDeckResidues (K := K) E N, + 𝔼 c : E j → A → ZMod N, F (resampleCoefficientDeckLayer r j slot c)) = 𝔼 r, F r := by + let e := coefficientDeckScalarEquiv (K := K) (E := E) (N := N) + let f := coefficientDeckLayerSelectedEmbedding (E := E) j slot hinj + let g := coefficientDeckLayerFreshEquiv (E := E) (A := A) (N := N) j + calc + _ = 𝔼 r : CoefficientDeckScalarIndex K E → ZMod N, + 𝔼 c : E j × A → ZMod N, F (e.symm (Function.extend f c r)) := by + apply Fintype.expect_equiv e + intro r + apply Fintype.expect_equiv g + intro c + rw [← coefficientDeckScalarEquiv_resampleLayer r j slot hinj c] + rfl + _ = 𝔼 r : CoefficientDeckScalarIndex K E → ZMod N, F (e.symm r) := + expect_coordinate_resampling f f.injective (fun r => F (e.symm r)) + _ = _ := by + apply Fintype.expect_equiv e.symm + intro r + rfl + +theorem expect_coefficientDeck_layer_selected + (j : Fin m) (slot : A → BoundedCoefficientExponent K (j.val + 1)) + (hinj : Function.Injective slot) (F : (E j → A → ZMod N) → ℝ) : + (𝔼 r : CoefficientDeckResidues (K := K) E N, F (fun i a => r j (slot a) i)) = + 𝔼 c : E j → A → ZMod N, F c := by + rw [← expect_resampleCoefficientDeckLayer j slot hinj (fun r => F (fun i a => r j (slot a) i))] + simp only [resampleCoefficientDeckLayer_selected _ _ slot hinj] + exact Fintype.expect_const _ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] {N L : ℕ} [NeZero N] + +noncomputable local instance selectedIndexFintype + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) : + Fintype (AllocatedSelectedCoefficientIndex X E inactive L) := inferInstance + +noncomputable local instance selectedIndexDecidableEq + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) : + DecidableEq (AllocatedSelectedCoefficientIndex X E inactive L) := Classical.decEq _ + +theorem expect_allocatedActualCoefficient_selected + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (F : (AllocatedSelectedCoefficientIndex X E inactive L → ZMod N) → ℝ) : + (𝔼 c : AllocatedActualCoefficientIndex G X I E n B → ZMod N, + F (c ∘ allocatedActualCoefficientSlot inactive spatial kernel block)) = + 𝔼 d : AllocatedSelectedCoefficientIndex X E inactive L → ZMod N, F d := by + exact uniform_expect_coordinate_pullback + (X := fun _ : AllocatedActualCoefficientIndex G X I E n B => ZMod N) + (allocatedActualCoefficientSlot inactive spatial kernel block) + (allocatedActualCoefficientSlot_injective inactive spatial kernel block) F + +theorem expect_allocatedActualCoefficient_resample + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (F : (AllocatedActualCoefficientIndex G X I E n B → ZMod N) → ℝ) : + (𝔼 c : AllocatedActualCoefficientIndex G X I E n B → ZMod N, + 𝔼 d : AllocatedSelectedCoefficientIndex X E inactive L → ZMod N, + F (Function.extend (allocatedActualCoefficientSlot inactive spatial kernel block) d c)) = + 𝔼 c : AllocatedActualCoefficientIndex G X I E n B → ZMod N, F c := + expect_coordinate_resampling (allocatedActualCoefficientSlot inactive spatial kernel block) + (allocatedActualCoefficientSlot_injective inactive spatial kernel block) F + +theorem expect_allocatedActualCoefficient_selected_subfamily {T : Type*} [Fintype T] + (inactive : LayerSamplerAxis I n → Prop) (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (e : T ↪ AllocatedSelectedCoefficientIndex X E inactive L) (F : (T → ZMod N) → ℝ) : + (𝔼 c : AllocatedActualCoefficientIndex G X I E n B → ZMod N, + F (fun t => c (allocatedActualCoefficientSlot inactive spatial kernel block (e t)))) = + 𝔼 d : T → ZMod N, F d := by + exact uniform_expect_coordinate_pullback + (X := fun _ : AllocatedActualCoefficientIndex G X I E n B => ZMod N) + (fun t => allocatedActualCoefficientSlot inactive spatial kernel block (e t)) + ((allocatedActualCoefficientSlot_injective inactive spatial kernel block).comp e.injective) F + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +abbrev AllocatedCongruenceCoefficientIndex (X : Type*) (E : Fin m → Type*) + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) := + Σ j : Fin m, AllocatedCongruenceRankOutput X E inactive j × Fin L + +abbrev AllocatedSmoothRankCoefficientIndex (X : Type*) + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) := + Σ j : Fin m, (SpatialDegreeOutput X j ⊕ AllocatedCongruenceIntegerAxis inactive j) × Fin L + +abbrev AllocatedDeckRankCoefficientIndex (E : Fin m → Type*) (L : ℕ) := + Σ j : Fin m, E j × Fin L + +def allocatedCongruenceCoefficientSplit (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) : + AllocatedCongruenceCoefficientIndex X E inactive L ≃ + AllocatedSmoothRankCoefficientIndex X inactive L ⊕ AllocatedDeckRankCoefficientIndex E L where + toFun k := match k with + | ⟨j,.inl x,l⟩ => .inl ⟨j,.inl x,l⟩ + | ⟨j,.inr (.inl e),l⟩ => .inr ⟨j,e,l⟩ + | ⟨j,.inr (.inr i),l⟩ => .inl ⟨j,.inr i,l⟩ + invFun k := match k with + | .inl ⟨j,.inl x,l⟩ => ⟨j,.inl x,l⟩ + | .inr ⟨j,e,l⟩ => ⟨j,.inr (.inl e),l⟩ + | .inl ⟨j,.inr i,l⟩ => ⟨j,.inr (.inr i),l⟩ + left_inv := by rintro ⟨j,(x | e | i),l⟩ <;> rfl + right_inv := by rintro (⟨j,(x | i),l⟩ | ⟨j,e,l⟩) <;> rfl + +def allocatedCongruenceCoefficientEmbedding (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) : + AllocatedCongruenceCoefficientIndex X E inactive L ↪ + AllocatedSelectedCoefficientIndex X E inactive L := + Function.Embedding.sigmaMap (Function.Embedding.refl _) + (fun j => Function.Embedding.prodMap (allocatedCongruenceOutputEmbedding inactive j) + (Function.Embedding.refl _)) + +noncomputable def allocatedCongruenceActualCoefficientEmbedding + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) : + AllocatedCongruenceCoefficientIndex X E inactive L ↪ AllocatedActualCoefficientIndex G X I E n B := + (allocatedCongruenceCoefficientEmbedding inactive L).trans + (allocatedActualCoefficientEmbedding inactive spatial kernel block) + +noncomputable def allocatedMixedSelectedValues (inactive : LayerSamplerAxis I n → Prop) + {L N : ℕ} (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + AllocatedCongruenceCoefficientIndex X E inactive L → ℤ := + Sum.elim x (fun j => (deck j).val) ∘ allocatedCongruenceCoefficientSplit inactive L + +theorem allocatedMixedSelectedValues_spatial (inactive : LayerSamplerAxis I n → Prop) + {L N : ℕ} (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) + (j : Fin m) (z : SpatialDegreeOutput X j) (l : Fin L) : + allocatedMixedSelectedValues inactive x deck ⟨j,.inl z,l⟩ = x ⟨j,.inl z,l⟩ := rfl + +theorem allocatedMixedSelectedValues_deck (inactive : LayerSamplerAxis I n → Prop) + {L N : ℕ} (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) + (j : Fin m) (e : E j) (l : Fin L) : + allocatedMixedSelectedValues inactive x deck ⟨j,.inr (.inl e),l⟩ = (deck ⟨j,e,l⟩).val := rfl + +theorem allocatedMixedSelectedValues_integer (inactive : LayerSamplerAxis I n → Prop) + {L N : ℕ} (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) + (j : Fin m) (i : AllocatedCongruenceIntegerAxis inactive j) (l : Fin L) : + allocatedMixedSelectedValues inactive x deck ⟨j,.inr (.inr i),l⟩ = x ⟨j,.inr i,l⟩ := rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +def AllocatedRankComponentCoefficient + (inactive : LayerSamplerAxis I n → Prop) (j : Fin m) : + AllocatedCongruenceRankOutput X E inactive j → Type _ + | .inl _ => Option (LayerSamplerVariables G I n B) + | .inr _ => BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) + +abbrev AllocatedRankComponentCoefficientIndex + (G X : Type*) (I E : Fin m → Type*) (n : Fin m → ℕ) + (B : LayerSamplerAxis I n → Type*) (inactive : LayerSamplerAxis I n → Prop) := + Σ t : (Σ j : Fin m, AllocatedCongruenceRankOutput X E inactive j), + AllocatedRankComponentCoefficient (G := G) (B := B) inactive t.1 t.2 + +def allocatedRankComponentCoefficientSlot + (inactive : LayerSamplerAxis I n → Prop) : + AllocatedRankComponentCoefficientIndex G X I E n B inactive → + AllocatedActualCoefficientIndex G X I E n B + | ⟨⟨_j, .inl x⟩, q⟩ => .inl (q, x.val) + | ⟨⟨j, .inr (.inl i)⟩, q⟩ => .inr (.inl ⟨j, q, i⟩) + | ⟨⟨j, .inr (.inr i)⟩, q⟩ => .inr (.inr ⟨⟨j, .inr i.val⟩, q⟩) + +theorem allocatedRankComponentCoefficientSlot_injective + (inactive : LayerSamplerAxis I n → Prop) : + Function.Injective + (allocatedRankComponentCoefficientSlot (G := G) (X := X) (E := E) (B := B) inactive) := by + rintro ⟨⟨j, o⟩, q⟩ ⟨⟨k, p⟩, r⟩ he + cases o with + | inl x => + cases p with + | inl y => + have hjk : j = k := Fin.ext (x.property.trans y.property.symm) + subst k + have hp : (q, x.val) = (r, y.val) := Sum.inl.inj he + have hxy : x = y := Subtype.ext (congrArg Prod.snd hp) + subst y + have hqr : q = r := congrArg Prod.fst hp + subst r + rfl + | inr p => cases p <;> cases he + | inr o => + cases p with + | inl y => cases o <;> cases he + | inr p => + cases o with + | inl i => + cases p with + | inl t => + have hh := Sum.inl.inj (Sum.inr.inj he) + have hjk : j = k := congrArg Sigma.fst hh + subst k + have hp : (q, i) = (r, t) := by + simpa only [Sigma.mk.inj_iff, heq_eq_eq, true_and, + AllocatedRankComponentCoefficient] using hh + have hit : i = t := congrArg Prod.snd hp + subst t + have hqr : q = r := congrArg Prod.fst hp + subst r + rfl + | inr a => cases he + | inr a => + cases p with + | inl t => cases he + | inr b => + have hh := Sum.inr.inj (Sum.inr.inj he) + have haxis : (⟨j, .inr a.val⟩ : LayerSamplerAxis I n) = ⟨k, .inr b.val⟩ := + congrArg Sigma.fst hh + have hjk : j = k := congrArg Sigma.fst haxis + subst k + have hab : a = b := Subtype.ext (by + apply Sum.inr.inj + exact eq_of_heq (Sigma.mk.inj haxis).2) + subst b + have hqr : q = r := eq_of_heq (Sigma.mk.inj hh).2 + subst r + rfl + +def allocatedRankComponentCoefficientEmbedding + (inactive : LayerSamplerAxis I n → Prop) : + AllocatedRankComponentCoefficientIndex G X I E n B inactive ↪ + AllocatedActualCoefficientIndex G X I E n B := + ⟨allocatedRankComponentCoefficientSlot inactive, + allocatedRankComponentCoefficientSlot_injective inactive⟩ + +noncomputable def allocatedRankComponentSelectedSlot + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (j : Fin m) : (o : AllocatedCongruenceRankOutput X E inactive j) → + Fin L → AllocatedRankComponentCoefficient (G := G) (B := B) inactive j o + | .inl _ => spatialKernelRankSlot spatial + | .inr (.inl _) => kernelRankCoefficientSlot (layerSamplerDegree I n) (kernel j) + | .inr (.inr i) => canonicalPrincipalSubblockSlot (layerSamplerDegree I n) + ⟨j, .inr i.val⟩ (block j (allocatedCongruenceIntegerEmbedding inactive j i)) + +theorem allocatedRankComponentSelectedSlot_injective + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) : + Function.Injective (allocatedRankComponentSelectedSlot inactive spatial kernel block j o) := by + rcases o with x | i | a + · exact spatialKernelRankSlot_injective spatial + · exact kernelRankCoefficientSlot_injective (layerSamplerDegree I n) (kernel j) + (Nat.zero_lt_succ _) + · exact canonicalPrincipalSubblockSlot_injective (layerSamplerDegree I n) + ⟨j, .inr a.val⟩ (Nat.zero_lt_succ _) + (block j (allocatedCongruenceIntegerEmbedding inactive j a)) + +noncomputable def allocatedRankComponentSelectedEmbedding + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) : + Fin L ↪ AllocatedRankComponentCoefficient (G := G) (B := B) inactive j o := + ⟨allocatedRankComponentSelectedSlot inactive spatial kernel block j o, + allocatedRankComponentSelectedSlot_injective inactive spatial kernel block j o⟩ + +theorem allocatedRankComponentCoefficientEmbedding_selected + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} (spatial : Fin L ↪ G) + (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ (j : Fin m) (a : AllocatedDegreeActiveAxis inactive j), Fin L ↪ B ⟨j, a.val⟩) + (j : Fin m) (o : AllocatedCongruenceRankOutput X E inactive j) (l : Fin L) : + allocatedRankComponentCoefficientEmbedding inactive + ⟨⟨j, o⟩, allocatedRankComponentSelectedEmbedding inactive spatial kernel block j o l⟩ = + allocatedCongruenceActualCoefficientEmbedding inactive spatial kernel block ⟨j, o, l⟩ := by + rcases o with x | i | a <;> rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + +def allocatedMixedCoefficientEquiv (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) + (R : Type*) [AddCommGroup R] : + ((AllocatedSmoothRankCoefficientIndex X inactive L ⊕ AllocatedDeckRankCoefficientIndex E L) → R) ≃+ + (AllocatedCongruenceCoefficientIndex X E inactive L → R) where + toFun f := f ∘ allocatedCongruenceCoefficientSplit inactive L + invFun f := f ∘ (allocatedCongruenceCoefficientSplit inactive L).symm + left_inv f := by funext j; simp only [Function.comp_apply, Equiv.apply_symm_apply] + right_inv f := by funext j; simp only [Function.comp_apply, Equiv.symm_apply_apply] + map_add' _ _ := rfl + +noncomputable local instance congruenceIndexFintype [Fintype X] [∀ j, Fintype (E j)] + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) : + Fintype (AllocatedCongruenceCoefficientIndex X E inactive L) := inferInstance + +noncomputable local instance congruenceIndexDecidableEq + (inactive : LayerSamplerAxis I n → Prop) (L : ℕ) : + DecidableEq (AllocatedCongruenceCoefficientIndex X E inactive L) := Classical.decEq _ + +theorem allocatedMixedCoefficient_uniform_event [Fintype X] [∀ j, Fintype (E j)] + (inactive : LayerSamplerAxis I n → Prop) (L M : ℕ) [NeZero M] + (F : (AllocatedCongruenceCoefficientIndex X E inactive L → ZMod M) → Prop) : + (FiniteProbabilityWeights.uniform + ((AllocatedSmoothRankCoefficientIndex X inactive L ⊕ AllocatedDeckRankCoefficientIndex E L) → ZMod M)).eventProbability + (fun f => F (allocatedMixedCoefficientEquiv inactive L (ZMod M) f)) = + (FiniteProbabilityWeights.uniform + (AllocatedCongruenceCoefficientIndex X E inactive L → ZMod M)).eventProbability F := by + exact uniform_mean_surjective_hom + (allocatedMixedCoefficientEquiv (X := X) (E := E) inactive L (ZMod M)).toAddMonoidHom + (allocatedMixedCoefficientEquiv (X := X) (E := E) inactive L (ZMod M)).surjective + (fun f => if F f then (1 : ℝ) else 0) + +theorem allocatedMixedCoefficientEquiv_cast (inactive : LayerSamplerAxis I n → Prop) + {L N : ℕ} [NeZero N] (M : ℕ) + (x : AllocatedSmoothRankCoefficientIndex X inactive L → ℤ) + (deck : AllocatedDeckRankCoefficientIndex E L → ZMod N) : + allocatedMixedCoefficientEquiv inactive L (ZMod M) + (Sum.elim (fun j => (x j : ZMod M)) (fun j => ZMod.cast (deck j))) = + fun j => (allocatedMixedSelectedValues inactive x deck j : ZMod M) := by + funext j + rcases j with ⟨j,(z | e | i),l⟩ + · rfl + · exact (ZMod.cast_eq_val _).trans (Int.cast_natCast _).symm + · rfl + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankPreparedBlocks.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankPreparedBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..91e60313a27d02c7953a3a06b2732bb8a9a3457a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankPreparedBlocks.lean @@ -0,0 +1,108 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankCongruenceOutput + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +def enlargedPreparedRankSpatialEmbedding (m Jalloc J : ℕ) (hJ : J ≤ Jalloc) : + Fin J ↪ EnlargedPreparedCommonKernel m Jalloc := + (Fin.castLEEmb (hJ.trans (by nlinarith : Jalloc ≤ (m + 1) * Jalloc))).trans + (Fin.natAddEmb ((m + 1) * (m + 3))) + +def enlargedPreparedRankKernelEmbedding (m Jalloc J : ℕ) (hJ : J ≤ Jalloc) (j : Fin m) : + Fin J × Fin (j.val + 1) ↪ EnlargedPreparedCommonKernel m Jalloc := + (finProdFinEquiv.toEmbedding.trans (Fin.castLEEmb (by + calc + J * (j.val + 1) ≤ Jalloc * (m + 1) := Nat.mul_le_mul hJ (by omega) + _ = (m + 1) * Jalloc := Nat.mul_comm _ _))).trans + (Fin.natAddEmb ((m + 1) * (m + 3))) + +theorem enlargedPreparedRankSpatialEmbedding_reserved (m Jalloc J : ℕ) + (hJ : J ≤ Jalloc) (l : Fin J) : + (m + 1) * (m + 3) ≤ (enlargedPreparedRankSpatialEmbedding m Jalloc J hJ l).val := by + change (m + 1) * (m + 3) ≤ (m + 1) * (m + 3) + l.val + exact Nat.le_add_right _ _ + +theorem enlargedPreparedRankKernelEmbedding_reserved (m Jalloc J : ℕ) + (hJ : J ≤ Jalloc) (j : Fin m) (l : Fin J × Fin (j.val + 1)) : + (m + 1) * (m + 3) ≤ (enlargedPreparedRankKernelEmbedding m Jalloc J hJ j l).val := by + change (m + 1) * (m + 3) ≤ (m + 1) * (m + 3) + (finProdFinEquiv l).val + exact Nat.le_add_right _ _ + +variable {X₀ J₀ : Type} {m : ℕ} (L : RankPreparationFamily X₀ J₀ m) + +noncomputable def enlargedPreparedRankPrincipalEmbedding (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (a : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L)) : + Fin J ↪ EnlargedPreparedCommonSamplerBlock L Jalloc a := + (Fin.castLEEmb hJ).trans (Fin.natAddEmb (preparedCommonBlockCount m a.1)) + +theorem enlargedPreparedRankPrincipalEmbedding_reserved (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (a : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L)) (l : Fin J) : + preparedCommonBlockCount m a.1 ≤ (enlargedPreparedRankPrincipalEmbedding L Jalloc J hJ a l).val := by + change preparedCommonBlockCount m a.1 ≤ preparedCommonBlockCount m a.1 + l.val + exact Nat.le_add_right _ _ + +theorem enlargedPreparedRank_embeddings (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L) → Prop) + (j : Fin m) : + ∃ _spatial : Fin J ↪ EnlargedPreparedCommonKernel m Jalloc, + ∃ _kernel : Fin J × Fin (j.val + 1) ↪ EnlargedPreparedCommonKernel m Jalloc, + Nonempty (∀ a : AllocatedDegreeActiveAxis inactive j, + Fin J ↪ EnlargedPreparedCommonSamplerBlock L Jalloc ⟨j, a.val⟩) := + ⟨enlargedPreparedRankSpatialEmbedding m Jalloc J hJ, + enlargedPreparedRankKernelEmbedding m Jalloc J hJ j, + ⟨fun a => enlargedPreparedRankPrincipalEmbedding L Jalloc J hJ ⟨j, a.val⟩⟩⟩ + +variable {E : Fin m → Type*} + +noncomputable def enlargedPreparedTaggedRankBlock (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L) → Prop) + (j : Fin m) : + AllocatedTaggedRankOutput X₀ E inactive j → Fin J → + Finset (LayerSamplerLongVariables inactive (EnlargedPreparedCommonKernel m Jalloc) + (EnlargedPreparedCommonSamplerBlock L Jalloc)) := + allocatedTaggedRankBlock inactive j + (enlargedPreparedRankSpatialEmbedding m Jalloc J hJ) + (enlargedPreparedRankKernelEmbedding m Jalloc J hJ j) + (fun a => enlargedPreparedRankPrincipalEmbedding L Jalloc J hJ ⟨j, a.val⟩) + +theorem enlargedPreparedTaggedRankBlock_card (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L) → Prop) + (j : Fin m) (o : AllocatedTaggedRankOutput X₀ E inactive j) (l : Fin J) : + (enlargedPreparedTaggedRankBlock L Jalloc J hJ inactive j o l).card = j.val + 1 := + allocatedTaggedRankBlock_card _ _ _ _ _ _ _ + +theorem enlargedPreparedTaggedRankBlock_disjoint (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L) → Prop) + (j : Fin m) (o : AllocatedTaggedRankOutput X₀ E inactive j) : + Pairwise (fun l q => Disjoint (enlargedPreparedTaggedRankBlock L Jalloc J hJ inactive j o l) + (enlargedPreparedTaggedRankBlock L Jalloc J hJ inactive j o q)) := + allocatedTaggedRankBlock_disjoint _ _ _ _ _ _ + +noncomputable def enlargedPreparedTaggedRankSelected (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L) → Prop) + (j : Fin m) : + AllocatedTaggedRankOutput X₀ E inactive j → Fin J → + LayerSamplerLongVariables inactive (EnlargedPreparedCommonKernel m Jalloc) + (EnlargedPreparedCommonSamplerBlock L Jalloc) := + allocatedTaggedRankSelected inactive j + (enlargedPreparedRankSpatialEmbedding m Jalloc J hJ) + (enlargedPreparedRankKernelEmbedding m Jalloc J hJ j) + (fun a => enlargedPreparedRankPrincipalEmbedding L Jalloc J hJ ⟨j, a.val⟩) + +theorem enlargedPreparedTaggedRankSelected_mem (Jalloc J : ℕ) (hJ : J ≤ Jalloc) + (inactive : LayerSamplerAxis (PreparedSamplerContinuous L) (preparedSamplerTransverse L) → Prop) + (j : Fin m) (o : AllocatedTaggedRankOutput X₀ E inactive j) (l : Fin J) : + enlargedPreparedTaggedRankSelected L Jalloc J hJ inactive j o l ∈ + enlargedPreparedTaggedRankBlock L Jalloc J hJ inactive j o l := + allocatedTaggedRankSelected_mem _ _ _ _ _ _ _ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankRationalDecay.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankRationalDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e6ff48622b2e16961c6df82ee8cf2d3b9c36f36 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankRationalDecay.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedModularRankIntegerDecay + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open MvPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +variable (inactive : LayerSamplerAxis I n → Prop) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (r : ∀ j : Fin m, + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (projection : ∀ j, AllocatedDegreeActiveAxis inactive j → + BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → ℤ) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, a.val⟩) + +theorem allocatedCongruence_crt_rational_decay_of_bad_product + (hm : 0 < m) (P : Finset ℕ) [∀ p : P, NeZero p.val] + (A e : ℕ → ℕ) (hp : ∀ p ∈ P, p.Prime) (C : ℝ) (hC : 0 ≤ C) (R : ℕ) + (hbad : (∏ p : P, p.val ^ allocatedCongruenceBadDepth + inactive noise r projection spatial kernel block P A C p.val) ≤ R) + (base : X → ℤ) (v : LayerSamplerVariables G I n B → ℤ) + (origin : ∀ p : P, LayerSamplerLongVariables inactive G B → ZMod (p.val ^ A p.val)) + (χ : AddChar (Sigma (AllocatedCongruenceRankOutput X E inactive) → + ZMod (∏ p : P, p.val ^ A p.val)) ℂ) : + letI : DecidableEq P := Classical.decEq _ + ‖finiteImageCharacteristic (crtPrimePowerPolynomialLaw (V := LayerSamplerLongVariables inactive G B) + (fun p : P => p.val) (fun p : P => A p.val)) + (fun x j => (crtPrimePowerIntegerPolynomialOutput (fun p : P => p.val) (fun p : P => A p.val) + (fun p : P => e p.val) + (primePower_crt_coprime (fun p : P => p.val) (fun p : P => A p.val) + (fun p => hp p.val p.property) Subtype.val_injective) + (fun j => allocatedCongruenceIntegerPolynomial inactive j base noise r (projection j) v) + origin x j : ZMod (∏ p : P, p.val ^ A p.val))) χ‖ ≤ + ((R * ∏ p : P, p.val ^ e p.val : ℕ) : ℝ) ^ + (modularRankDecayExponent m C * modularRankChargeFactor m) * + (orderOf χ : ℝ) ^ (-modularRankDecayExponent m C) := by + let : DecidableEq P := Classical.decEq _ + let b := allocatedCongruenceBadDepth inactive noise r projection spatial kernel block P A C + have h := crt_integer_polynomial_rational_characteristic_decay hm + (fun p : P => p.val) (fun p : P => A p.val) (fun p : P => b p.val) (fun p : P => e p.val) + (fun p => hp p.val p.property) Subtype.val_injective C hC + (fun j => allocatedCongruenceIntegerPolynomial inactive j base noise r (projection j) v) + (fun j o => allocatedCongruenceIntegerPolynomial_degree inactive j base noise r (projection j) v o) + (fun p a ha hA j w hw => + allocatedCongruenceIntegerPolynomial_rank_of_good inactive noise r projection spatial kernel block + P C p a (allocatedCongruence_largest_bad_depth_good inactive noise r projection spatial kernel block + P A C p a ha hA) base v j w hw) origin χ + exact h.trans (mul_le_mul_of_nonneg_right + (crtPolynomialCharge_le_of_bad_product (fun p : P => p.val) (fun p : P => b p.val) + (fun p : P => e p.val) m hC hbad) (Real.rpow_nonneg (Nat.cast_nonneg _) _)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankSmoothWidthBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankSmoothWidthBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..89bafa72068fe2549435cb30df70efef6fd71faf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankSmoothWidthBudget.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankMixedUniform + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m L : ℕ} {X : Type*} [Fintype X] + {I : Fin m → Type*} {n : Fin m → ℕ} + +theorem allocatedSmoothRankCoefficientIndex_card_le (hm : 0 < m) + (inactive : LayerSamplerAxis I n → Prop) : + Fintype.card (AllocatedSmoothRankCoefficientIndex X inactive L) ≤ + L * (Fintype.card X + ∑ j : Fin m, n j) := by + have hcount (j : Fin m) : Fintype.card (AllocatedCongruenceIntegerAxis inactive j) ≤ n j := by + simpa only [Fintype.card_fin] using Fintype.card_subtype_le + (fun i : Fin (n j) => ¬ inactive ⟨j, Sum.inr i⟩) + change Fintype.card (Σ j : Fin m, + (SpatialDegreeOutput X j ⊕ AllocatedCongruenceIntegerAxis inactive j) × Fin L) ≤ _ + simp only [Fintype.card_sigma, Fintype.card_prod, Fintype.card_sum, Fintype.card_fin] + calc + _ ≤ ∑ j : Fin m, (Fintype.card (SpatialDegreeOutput X j) + n j) * L := + Finset.sum_le_sum (fun j _ => Nat.mul_le_mul_right L (Nat.add_le_add_left (hcount j) _)) + _ = L * (Fintype.card X + ∑ j : Fin m, n j) := by + rw [← Finset.sum_mul, Finset.sum_add_distrib, spatialDegreeOutput_sum_card hm, Nat.mul_comm] + +theorem allocatedSmooth_discrepancy_le_card + (inactive : LayerSamplerAxis I n → Prop) + (width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (M : ℕ) {W : ℝ} (hW : 0 < W) (hwidth : ∀ i, W ≤ width i) : + (∑ i, 16 * (probabilityProfileLipschitz : ℝ) * M / width i) ≤ + Fintype.card (AllocatedSmoothRankCoefficientIndex X inactive L) * + (16 * (probabilityProfileLipschitz : ℝ) * M / W) := by + calc + _ ≤ ∑ _i : AllocatedSmoothRankCoefficientIndex X inactive L, + 16 * (probabilityProfileLipschitz : ℝ) * M / W := + Finset.sum_le_sum (fun i _ => div_le_div_of_nonneg_left (by positivity) hW (hwidth i)) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + +theorem allocatedSmooth_discrepancy_le_of_width_budget + (hm : 0 < m) (inactive : LayerSamplerAxis I n → Prop) + (width : AllocatedSmoothRankCoefficientIndex X inactive L → ℝ) + (M D : ℕ) (hD : Fintype.card X + ∑ j : Fin m, n j ≤ D) + {W η : ℝ} (hW : 0 < W) (hη : 0 < η) + (hwidth : ∀ i, W ≤ width i) + (hbudget : 16 * (probabilityProfileLipschitz : ℝ) * M * L * D / η ≤ W) : + (∑ i, 16 * (probabilityProfileLipschitz : ℝ) * M / width i) ≤ η := by + have hcount : Fintype.card (AllocatedSmoothRankCoefficientIndex X inactive L) ≤ L * D := + (allocatedSmoothRankCoefficientIndex_card_le (X := X) (L := L) hm inactive).trans + (Nat.mul_le_mul_left L hD) + have hcountR : (Fintype.card (AllocatedSmoothRankCoefficientIndex X inactive L) : ℝ) ≤ + (L : ℝ) * D := by exact_mod_cast hcount + have hfrac : 0 ≤ 16 * (probabilityProfileLipschitz : ℝ) * M / W := by positivity + have hbudget' : 16 * (probabilityProfileLipschitz : ℝ) * M * L * D ≤ η * W := by + have h := (div_le_iff₀ hη).mp hbudget + simpa only [mul_comm] using h + calc + _ ≤ Fintype.card (AllocatedSmoothRankCoefficientIndex X inactive L) * + (16 * (probabilityProfileLipschitz : ℝ) * M / W) := + allocatedSmooth_discrepancy_le_card inactive width M hW hwidth + _ ≤ ((L : ℝ) * D) * (16 * (probabilityProfileLipschitz : ℝ) * M / W) := + mul_le_mul_of_nonneg_right hcountR hfrac + _ = (16 * (probabilityProfileLipschitz : ℝ) * M * L * D) / W := by ring + _ ≤ η := (div_le_iff₀ hW).mpr hbudget' + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankUniformRow.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankUniformRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fc8198b58d1d3dff5ec17a3e4c184bda7724f24 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedModularRankUniformRow.lean @@ -0,0 +1,101 @@ +import OAI.Combinatorics.Progressions.Estimates.ModularDesignatedCoefficientMarkov + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators Classical + +noncomputable def coefficientPolynomialRankFailureProbability {E I : Type*} + [Fintype I] [DecidableEq I] (N n : ℕ) [NeZero N] + (P : (E → ZMod N) → MvPolynomial I (ZMod N)) (c : E → ZMod N) : ℝ := + 𝔼 u : Fin n → I → ZMod N, + if polynomialLinearRow (polynomialIterDifference n (P c) u) = 0 then 1 else 0 + +theorem coefficientPolynomialRankFailureProbability_nonneg {E I : Type*} + [Fintype I] [DecidableEq I] (N n : ℕ) [NeZero N] + (P : (E → ZMod N) → MvPolynomial I (ZMod N)) (c : E → ZMod N) : + 0 ≤ coefficientPolynomialRankFailureProbability N n P c := + Finset.expect_nonneg (fun _ _ => by split_ifs <;> norm_num) + +theorem coefficientPolynomialRankFailureProbability_expect_le + {E A I : Type*} [Fintype E] [Fintype A] [Fintype I] + [DecidableEq E] [DecidableEq A] [DecidableEq I] + {p a n : ℕ} [NeZero p] (hp : p.Prime) (ha : 0 < a) + (slot : A → E) (hinj : Function.Injective slot) + (S : A → Finset I) (hcard : ∀ b, (S b).card = n + 1) + (hdisjoint : Pairwise (fun b c => Disjoint (S b) (S c))) + (P Q : (E → ZMod (p ^ a)) → MvPolynomial I (ZMod (p ^ a))) + (unit : A → (ZMod (p ^ a))ˣ) + (hP : ∀ c d, P (Function.extend slot d c) = Q c + + ∑ b, ((unit b : ZMod (p ^ a)) * d b) • ∏ i ∈ S b, X i) : + (𝔼 c : E → ZMod (p ^ a), coefficientPolynomialRankFailureProbability (p ^ a) n P c) ≤ + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := by + have hconditional (c : E → ZMod (p ^ a)) : + (𝔼 d : A → ZMod (p ^ a), coefficientPolynomialRankFailureProbability (p ^ a) n P + (Function.extend slot d c)) ≤ + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := by + unfold coefficientPolynomialRankFailureProbability + simp_rw [hP c] + exact designatedPolynomial_expected_rank_failure_le hp ha S hcard hdisjoint (Q c) unit + rw [← expect_coordinate_resampling slot hinj + (coefficientPolynomialRankFailureProbability (p ^ a) n P)] + calc + _ ≤ 𝔼 _c : E → ZMod (p ^ a), + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := + Finset.expect_le_expect (fun c _ => hconditional c) + _ = _ := Fintype.expect_const _ + +theorem coefficientPolynomialRankFailureProbability_mean_le + {E A I : Type*} [Fintype E] [Fintype A] [Fintype I] + [DecidableEq E] [DecidableEq A] [DecidableEq I] + {p a n s : ℕ} [NeZero p] (hp : p.Prime) (ha : 0 < a) (hns : n + 1 ≤ s) + (slot : A → E) (hinj : Function.Injective slot) + (S : A → Finset I) (hcard : ∀ b, (S b).card = n + 1) + (hdisjoint : Pairwise (fun b c => Disjoint (S b) (S c))) + (P Q : (E → ZMod (p ^ a)) → MvPolynomial I (ZMod (p ^ a))) + (unit : A → (ZMod (p ^ a))ˣ) + (hP : ∀ c d, P (Function.extend slot d c) = Q c + + ∑ b, ((unit b : ZMod (p ^ a)) * d b) • ∏ i ∈ S b, X i) : + (FiniteProbabilityWeights.uniform (E → ZMod (p ^ a))).mean + (coefficientPolynomialRankFailureProbability (p ^ a) n P) ≤ + ((s : ℝ) * ((p : ℝ) ^ a) ^ (-modularRankSmallBallExponent s)) ^ Fintype.card A := by + rw [FiniteProbabilityWeights.uniform_mean] + apply (coefficientPolynomialRankFailureProbability_expect_le hp ha slot hinj S + hcard hdisjoint P Q unit hP).trans + apply pow_le_pow_left₀ (by positivity) + exact modularRank_tag_cost_le hns (by exact_mod_cast hp.one_lt.le) + +theorem coefficientPolynomialRankFailureProbability_markov + {E A I : Type*} [Fintype E] [Fintype A] [Fintype I] + [DecidableEq E] [DecidableEq A] [DecidableEq I] + {p a n s : ℕ} [NeZero p] (hp : p.Prime) (ha : 0 < a) (hns : n + 1 ≤ s) + (slot : A → E) (hinj : Function.Injective slot) + (S : A → Finset I) (hcard : ∀ b, (S b).card = n + 1) + (hdisjoint : Pairwise (fun b c => Disjoint (S b) (S c))) + (P Q : (E → ZMod (p ^ a)) → MvPolynomial I (ZMod (p ^ a))) + (unit : A → (ZMod (p ^ a))ˣ) + (hP : ∀ c d, P (Function.extend slot d c) = Q c + + ∑ b, ((unit b : ZMod (p ^ a)) * d b) • ∏ i ∈ S b, X i) (C : ℝ) : + (FiniteProbabilityWeights.uniform (E → ZMod (p ^ a))).eventProbability + (fun c => ((p : ℝ) ^ a) ^ (-C) < coefficientPolynomialRankFailureProbability + (p ^ a) n P c) ≤ + ((p : ℝ) ^ a) ^ C * + ((s : ℝ) * ((p : ℝ) ^ a) ^ (-modularRankSmallBallExponent s)) ^ Fintype.card A := by + have hq : 0 < (p : ℝ) ^ a := pow_pos (by exact_mod_cast hp.pos) _ + have h := finiteProbability_rank_markov + (FiniteProbabilityWeights.uniform (E → ZMod (p ^ a))) + (coefficientPolynomialRankFailureProbability (p ^ a) n P) + (coefficientPolynomialRankFailureProbability_nonneg (p ^ a) n P) (C := C) hq + exact h.trans (mul_le_mul_of_nonneg_left + (coefficientPolynomialRankFailureProbability_mean_le hp ha hns slot hinj S hcard hdisjoint + P Q unit hP) (Real.rpow_nonneg hq.le _)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalDensityProjectionLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalDensityProjectionLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4827f3084d75f98ff19dc7d6c49e3802c70b6d5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalDensityProjectionLaw.lean @@ -0,0 +1,138 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedOriginalSourceProjection + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +universe uX + +theorem exists_allocated_original_density_projection_law (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + {P W : ℝ} (_hP : 0 ≤ P) (_hm : (m : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + {X : Type uX} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty) + (D : ℕ) + (f : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ), + let density := allocatedCoefficientDensity B U basis hb o hR hσ S + ∀ (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, 0} U + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) D density (f y)) + {Z : ℝ} (_hZ : 0 < Z) (_hZi : Z⁻¹ ≤ Real.exp P), + let widths := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + ∀ (hwidths : ∀ z, 0 < widths z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride T widths z), + ∀ law : FiniteProbabilityWeights (PrincipalIntegerTuples B (layerSamplerDegree I n) + (Fin q) (allocatedPrincipalSides B U basis S)), + let source := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T widths hwidths hmass z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) * + (density (affineSampleCoefficientTorus U + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) : ℂ)) + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T widths hwidths hmass z).toReal : ℂ) * + physicalCubePositiveTest U D p hm (f y) test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) + ‖law.complexMean source / (Z : ℂ) - law.complexMean projected / (Z : ℂ)‖ ≤ Real.exp (-P) := by + obtain ⟨A₀, _, hprojection⟩ := exists_allocated_mixture_density_projection_law m q + obtain ⟨b, _, hbnd⟩ := exists_positiveComparisonDataBudget_bound m q + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget + (((Polynomial.X + Polynomial.C b) ^ b + Polynomial.C A₀) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ _ n B _ _ _ J _ U basis R σ S c x hb o hR hσ C V hC hV + hσ1 Cinv hCinv hchart hsmall P W hP hmSize hK hW hroot hWP hL hRP hσP hcount hI hn hJ + hAP hCP hVP M hperiod X _ _ hX hdim p hp hm base stride hs hsP τ ξ hτ hτP hξ hξ1 hξP + N hsize rank hrank hRank test htest T hT D f density hproject Z hZ hZi widths hwidths hmass + law source projected + let Q := positiveComparisonDataBudget m q P + obtain ⟨hQ, hPQ, haccQ, _, _⟩ := positiveComparisonDataBudget_bounds m q hP + have hExp := Real.exp_le_exp.mpr hPQ + have hcut : (Q + A₀) ^ A₀ ≤ (P + A) ^ A := by + calc + _ ≤ ((P + b) ^ b + A₀) ^ A₀ := + pow_le_pow_left₀ (add_nonneg hQ (Nat.cast_nonneg A₀)) + (add_le_add (hbnd P hP) le_rfl) A₀ + _ ≤ _ := by simpa [Polynomial.eval₂_pow] using hbudget P hP + obtain ⟨_, F, inst, frequency, coeff, hfreq, hcoeff, happ⟩ := + exists_allocated_positive_fourier_data B U basis hb o S C V hC hV q + hR hσ hσ1 Cinv hCinv hchart hsmall hP hmSize hK hRP hσP hcount hI hn hJ hAP hL hCP hVP + let _ := inst + have hη : 0 < positiveProjectionAccuracy P := Real.exp_pos _ + have hηQ : (positiveProjectionAccuracy P)⁻¹ ≤ Real.exp Q := by + simp only [positiveProjectionAccuracy, Real.exp_neg, inv_inv] + exact Real.exp_le_exp.mpr haccQ + have he := hprojection B U basis S c x hQ (hK.trans hPQ) hW hroot + (hWP.trans hExp) (hL.trans hExp) hperiod (hX.trans hPQ) (hdim.trans hPQ) + frequency hfreq coeff hcoeff p hp hm base stride hs (fun t => (hsP t).trans hExp) + hτ (hτP.trans hExp) hξ hξ1 (hξP.trans hExp) hη hηQ N + (fun t => (Real.exp_le_exp.mpr hcut).trans (hsize t)) hrank + ((Real.exp_le_exp.mpr hcut).trans hRank) test htest T hT density D f hproject hη.le happ hZ + hwidths hmass law + apply he.trans + calc + (2 * positiveProjectionAccuracy P + positiveProjectionAccuracy P) / Z = + 3 * positiveProjectionAccuracy P * Z⁻¹ := by ring + _ ≤ 3 * positiveProjectionAccuracy P * Real.exp P := + mul_le_mul_of_nonneg_left hZi (by positivity) + _ = 3 * Real.exp (-(P + 4)) := by + rw [mul_assoc, positiveProjectionAccuracy, ← Real.exp_add] + congr 2 + ring + _ ≤ Real.exp 4 * Real.exp (-(P + 4)) := + mul_le_mul_of_nonneg_right (by linarith [Real.add_one_le_exp (4 : ℝ)]) (Real.exp_nonneg _) + _ = Real.exp (-P) := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalProjectionBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalProjectionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..d67d904d419c3d27ee1f23061948472d795d4b94 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalProjectionBudget.lean @@ -0,0 +1,85 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedChosenScaleBudget +import OAI.Combinatorics.Progressions.Sampling.AllocatedUnifiedSamplingBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +noncomputable def allocatedOriginalProjectionBudget (m dim A : ℕ) (p E T : ℝ) : ℝ := + allocatedUnifiedSamplingBudget m dim A (allocatedChosenScaleBudget m p E T) p E + E + 3 + +theorem allocatedOriginalProjectionBudget_bounds (m dim A : ℕ) {p E T : ℝ} + (hp : 0 ≤ p) (hE : 0 ≤ E) (hT : 0 ≤ T) : + let P := allocatedChosenScaleBudget m p E T + let Q := allocatedUnifiedSamplingBudget m dim A P p E + let B := allocatedOriginalProjectionBudget m dim A p E T + 0 ≤ B ∧ Q ≤ B ∧ P ≤ B ∧ E + 3 ≤ B := by + have hP := (allocatedChosenScaleBudget_bounds m hp hE hT).1 + obtain ⟨_, _, _, hQ, _, _, hPQ, _, _, _⟩ := + allocatedUnifiedSamplingBudget_bounds m dim A hP hp hE + dsimp only [allocatedOriginalProjectionBudget] + exact ⟨by linarith, by linarith, by linarith, by linarith⟩ + +theorem exists_allocatedOriginalThreshold_bound (m dim A Kproj Ktuple : ℕ) (hKtuple : 1 ≤ Ktuple) : + ∃ a : ℕ, 2 ≤ a ∧ ∀ {p E T : ℝ}, 0 ≤ p → 0 ≤ E → 0 ≤ T → + (allocatedOriginalProjectionBudget m dim A p E T + Kproj) ^ Kproj ≤ + (p + E + T + a) ^ a ∧ + (p + E + T + Ktuple) ^ Ktuple ≤ (p + E + T + a) ^ a := by + obtain ⟨c, _, hshift⟩ := exists_natPolynomial_eval_budget + ((2 * Polynomial.X + 3 + Polynomial.C Kproj) ^ Kproj) + obtain ⟨b, _, hbudget⟩ := exists_allocatedUnifiedSamplingThreshold_bound m dim A c + obtain ⟨a₀, ha₀, hchosen⟩ := exists_allocatedChosenThreshold_bound m A b + refine ⟨max a₀ Ktuple, ha₀.trans (le_max_left _ _), ?_⟩ + intro p E T hp hE hT + let P := allocatedChosenScaleBudget m p E T + let Q := allocatedUnifiedSamplingBudget m dim A P p E + have hP : 0 ≤ P := (allocatedChosenScaleBudget_bounds m hp hE hT).1 + obtain ⟨_, _, _, hQ, _, _, _, _, hEQ, _⟩ := + allocatedUnifiedSamplingBudget_bounds m dim A hP hp hE + have hproj : (allocatedOriginalProjectionBudget m dim A p E T + Kproj) ^ Kproj ≤ + (Q + c) ^ c := by + calc + _ ≤ (2 * Q + 3 + Kproj) ^ Kproj := by + apply pow_le_pow_left₀ + (add_nonneg (allocatedOriginalProjectionBudget_bounds m dim A hp hE hT).1 (Nat.cast_nonneg _)) + dsimp [allocatedOriginalProjectionBudget, Q, P] at * + linarith + _ ≤ _ := by simpa [Polynomial.eval₂_pow] using hshift Q hQ + have hlarge := hchosen hp hE hT + have hu : 0 ≤ p + E + T := by positivity + exact ⟨(hproj.trans (hbudget hP hp hE)).trans + (hlarge.2.2.trans (shifted_power_self_mono hu (by omega) (le_max_left _ _))), + shifted_power_self_mono hu hKtuple (le_max_right _ _)⟩ + +theorem originalTupleProjectionPrecision_bound {E Z : ℝ} (hZ : 1 / 2 ≤ Z) : + (2 * Real.exp (-(E + 4)) + Real.exp (-(E + 4))) / Z + Real.exp (-(E + 1)) ≤ + Real.exp (-E) := by + have hZpos : 0 < Z := by linarith + have hη := (Real.exp_pos (-(E + 4))).le + have hfirst : (2 * Real.exp (-(E + 4)) + Real.exp (-(E + 4))) / Z ≤ + 6 * Real.exp (-(E + 4)) := by + apply (div_le_iff₀ hZpos).mpr + nlinarith + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hthree : (3 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hsix : (6 : ℝ) ≤ Real.exp 3 := by + calc + _ = (2 : ℝ) * 3 := by norm_num + _ ≤ Real.exp 1 * Real.exp 2 := mul_le_mul htwo hthree (by norm_num) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; norm_num + have hsmall : 6 * Real.exp (-(E + 4)) ≤ Real.exp (-(E + 1)) := by + calc + _ ≤ Real.exp 3 * Real.exp (-(E + 4)) := mul_le_mul_of_nonneg_right hsix hη + _ = _ := by rw [← Real.exp_add]; congr 1; ring + calc + _ ≤ 2 * Real.exp (-(E + 1)) := by linarith + _ ≤ Real.exp 1 * Real.exp (-(E + 1)) := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalSourceProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalSourceProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b135707879407efadaee008b115a9aa58226f8b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedOriginalSourceProjection.lean @@ -0,0 +1,655 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedCenteredJointSource +import OAI.Combinatorics.Progressions.Fourier.AllocatedPositiveFourierData +import OAI.Combinatorics.Progressions.Geometry.AllocatedPositiveSpatialComparison + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel + +def physicalDensityProjection.{uK, uJ, uX, uF} {K : Type uK} [Fintype K] {m q : ℕ} + {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (dirs : Fin q → K → ℤ) (d : ℕ) + (density : CoefficientTorus (K := K) U → ℝ) + (f : EuclideanJetLayers U (fun j => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) : Prop := + ∀ {X : Type uX} {F : Type uF} [Fintype F] + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (coeff : F → ℂ) {η : ℝ}, + (∀ z, ‖coefficientTorusFourierSum U frequency coeff z - (density z : ℂ)‖ ≤ η) → + ∀ (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (v : Option K → X → ℝ), + ‖affineCubeFourierProjection U root dirs frequency p coeff v - + (f (euclideanCoefficientJetMap U root (Matrix.of dirs) + (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q))) + (affineCoefficientCoverSample U p hm d v)) : ℂ)‖ ≤ η + +universe uK uJ uX uF + +theorem physicalDensityProjection_sample {K : Type uK} {X : Type uX} {F : Type uF} [Fintype K] [Fintype F] {m q : ℕ} + {J : Fin m → Type uJ} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (dirs : Fin q → K → ℤ) (d : ℕ) + (density : CoefficientTorus (K := K) U → ℝ) + (f : EuclideanJetLayers U (fun j => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) + (h : physicalDensityProjection.{uK, uJ, uX, uF} U root dirs d density f) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (coeff : F → ℂ) {η : ℝ} + (happrox : ∀ z, ‖coefficientTorusFourierSum U frequency coeff z - (density z : ℂ)‖ ≤ η) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j e, coefficients (p j) e ∈ U j) (base : X → ℤ) (z : Option K × X → ℤ) : + ‖affineCubeFourierProjection U root dirs frequency + (fun j => translate (fun i => (base i : ℝ)) (p j)) coeff (fun k i => (z (k,i) : ℝ)) - + (f (physicalCubeEuclideanSample U d p hm (physicalCubeRootDifferences root (Matrix.of dirs) base z)) : ℂ)‖ ≤ η := by + rw [← coefficientCoverSample_physicalJet U root dirs d p hp hm base z] + exact @h X F _ frequency coeff η happrox + (fun j => translate (fun i => (base i : ℝ)) (p j)) + (fun j => degreeLE_translate (1 : X → ℕ) (fun _ => by norm_num) _ (p j) (hp j)) + (fun j => coefficients_translate_mem (U j) (fun i => (base i : ℝ)) (p j) (hm j)) + (fun k i => (z (k,i) : ℝ)) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel MeasureTheory +open scoped BigOperators + +theorem exists_allocated_narrow_density_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + {P W : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S)) + {X : Type*} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + {F : Type*} [Fintype F] + (frequency : F → ∀ j, (LayerSamplerVariables G I n B →₀ ℕ) → J j → ℤ) + (_hfrequency : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ Real.exp P) + (coeff : F → ℂ) (_hcoeff : (∑ a, ‖coeff a‖) ≤ Real.exp P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ ε : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (_hε : 0 < ε) (_hεP : ε⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty) + (density : CoefficientTorus (K := LayerSamplerVariables G I n B) U → ℝ) + (D : ℕ) (f : EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ v, ‖(density v : ℂ) - coefficientTorusFourierSum U frequency coeff v‖ ≤ η) + {Z : ℝ} (_hZnorm : 0 < Z), + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + let root := allocatedPhysicalCubeRoot B U basis S c x y + let dirs := allocatedPhysicalCubeDirections B U basis S x y + let pa := fun j => translate (fun d => (base d : ℝ)) (p j) + let hma := fun j => coefficients_translate_mem (U j) (fun d => (base d : ℝ)) (p j) (hm j) + ∀ (_hpositive : ∀ z : Option (LayerSamplerVariables G I n B) × X → ℤ, + ‖affineCubeFourierProjection U root dirs frequency pa coeff (fun k d => (z (k, d) : ℝ)) - + (f (euclideanCoefficientJetMap U root dirs + (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q))) + (affineCoefficientCoverSample U pa hma D (fun k d => (z (k, d) : ℝ)))) : ℂ)‖ ≤ η), + ∃ (hV : ∀ z, 0 < V z) (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride T V z), + ‖(∑' z, ((selectedResidueSmoothPMF stride T V hV hZ z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences root dirs base z) * + (density (affineSampleCoefficientTorus U pa hma (fun k d => (z (k, d) : ℝ))) : ℂ))) / (Z : ℂ) - + (∑' z, ((selectedResidueSmoothPMF stride T V hV hZ z).toReal : ℂ) * + physicalCubePositiveTest U D p hm f test (physicalCubeRootDifferences root dirs base z)) / + (Z : ℂ)‖ ≤ (2 * η + ε) / Z := by + obtain ⟨A₀, _, hprojection⟩ := exists_affine_cube_fourier_projection m q + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget + ((8 * Polynomial.X + Polynomial.C (q + 130 + A₀)) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ n B _ _ J _ U basis R σ S c x P W hP hK hW hroot hWP hL M hperiod y + X _ _ hX hdim F _ frequency hfrequency coeff hcoeff p hp hm base stride hs hsP + τ ξ ε hτ hτP hξ hξ1 hξP hε hεP N hsize rank hrank hRank test htest T hT density D f η hη happrox Z hZnorm + V root dirs pa hma hpositive + let Q := spatialSamplingBudget (2 * P) + (q + 2 : ℕ) + have hP2 : 0 ≤ 2 * P := by positivity + have hPQ : P ≤ Q := by dsimp [Q, spatialSamplingBudget]; linarith [Nat.cast_nonneg (α := ℝ) (q + 2)] + have hQ : 0 ≤ Q := hP.trans hPQ + have hsiteQ : P + (q + 2 : ℕ) ≤ Q := by dsimp [Q, spatialSamplingBudget]; linarith + have heval : Q + A₀ = 8 * P + (q + 130 + A₀ : ℕ) := by + dsimp [Q, spatialSamplingBudget] + push_cast + ring + have hcost : (Q + A₀) ^ A₀ ≤ (P + A) ^ A := by + rw [heval] + simpa [Polynomial.eval₂_pow] using hbudget P hP + have hExp := Real.exp_le_exp.mpr hPQ + obtain ⟨a, ha, _, hperiod⟩ := hperiod + have hlin : LinearIndependent ℝ (fun i k => (dirs i k : ℝ)) := + linearIndependent_of_fixed_kernel_period (scalarCubeDifferenceMatrix x) dirs Sum.inl + (fun _ _ => rfl) (by exact_mod_cast ha.ne') hperiod + have hpa (j) : DegreeLE (1 : X → ℕ) (j.val + 1) (pa j) := + degreeLE_translate (1 : X → ℕ) (fun _ => by norm_num) _ (p j) (hp j) + have hra (j) : HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (pa j) := + (hasLayerSamplingRank_translate_iff (fun d => (base d : ℝ)) (j.val + 1) + (fun d => (N d : ℝ)) rank (U j) (p j) (hp j)).mpr (hrank j) + have hN (d) : 0 < N d := by exact_mod_cast (Real.exp_pos _).trans_le (hsize d) + have hV : ∀ z, 0 < V z := narrowTrimmedSpatialWidths_pos hW hτ hξ N hN + have hξτ : 0 < ξ * τ := mul_pos hξ hτ + have hξτP : (ξ * τ)⁻¹ ≤ Real.exp (2 * P) := by + rw [mul_inv_rev] + calc + _ ≤ Real.exp P * Real.exp P := mul_le_mul hτP hξP (inv_nonneg.mpr hξ.le) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add, ← two_mul] + have hρP : 1 / spatialWidthFraction (2 * P) (ξ * τ) ≤ Real.exp Q := + (spatialWidthFraction_inv_le hP2 hξτ hξτP).trans + (Real.exp_le_exp.mpr (le_add_of_nonneg_right (Nat.cast_nonneg _))) + have hwidth (z) : spatialWidthFraction (2 * P) (ξ * τ) * (N z.2 : ℝ) ≤ V z := + (spatialWidthFraction_le_allocated_width hP2 hW + (hWP.trans (Real.exp_le_exp.mpr (by linarith))) hξτ.le N z).trans + (narrowTrimmedSpatialWidths_lower hW hτ hξ1 N hN z) + obtain ⟨hZ, hraw⟩ := hprojection hQ (hX.trans hPQ) (hdim.trans hPQ) U root dirs hlin + (Real.exp_nonneg Q) (Real.exp_nonneg Q) le_rfl le_rfl + (fun s k => (allocatedPhysicalCube_site_le_exp B U basis S c x y (hroot.trans hWP) hL s k).trans + (Real.exp_le_exp.mpr hsiteQ)) frequency (fun a j d hd t => (hfrequency a j d hd t).trans hExp) + coeff (Real.exp_nonneg Q) le_rfl (hcoeff.trans hExp) pa hpa hma stride hs + (Real.exp_nonneg Q) le_rfl (spatialWidthFraction_pos (2 * P) hξτ) hε hρP + (by simpa only [one_div] using hεP.trans hExp) (fun d => (hsP d).trans hExp) + (fun d => (N d : ℝ)) (fun d => (Real.exp_le_exp.mpr hcost).trans (hsize d)) hra + ((Real.exp_le_exp.mpr hcost).trans hRank) 0 (by simp) + (fun s u => test s ((fun d => (base d : ℝ)) + u)) (fun s u => htest s _) + T hT V hV hwidth + have hweight (z : Option (LayerSamplerVariables G I n B) × X → ℤ) : + layeredSiteWeight 0 (fun s => affineSite root dirs s) + (fun s u => test s ((fun d => (base d : ℝ)) + u)) (fun k d => (z (k, d) : ℝ)) = + physicalCubeSiteTest test (physicalCubeRootDifferences root dirs base z) := + layeredSiteWeight_physicalCube root dirs base test z + have hdirs : Matrix.of dirs = dirs := rfl + have hfirst := selectedResidue_positive_density_projection_error U root dirs D p hp hm + frequency coeff test htest base stride T V hV hZ density f hη happrox hpositive + (by simpa only [hweight, hdirs, pa] using hraw) + refine ⟨hV, hZ, ?_⟩ + rw [← sub_div, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hZnorm] + exact div_le_div_of_nonneg_right hfirst hZnorm.le + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel MeasureTheory +open scoped BigOperators Classical + +universe uX uF + +theorem exists_allocated_mixture_density_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + {P W : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + {X : Type uX} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + {F : Type uF} [Fintype F] + (frequency : F → ∀ j, (LayerSamplerVariables G I n B →₀ ℕ) → J j → ℤ) + (_hfrequency : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ Real.exp P) + (coeff : F → ℂ) (_hcoeff : (∑ a, ‖coeff a‖) ≤ Real.exp P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ ε : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (_hε : 0 < ε) (_hεP : ε⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty) + (density : CoefficientTorus (K := LayerSamplerVariables G I n B) U → ℝ) + (D : ℕ) + (f : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) + (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, uF} U + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) D density (f y)) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ v, ‖(density v : ℂ) - coefficientTorusFourierSum U frequency coeff v‖ ≤ η) + {Z : ℝ} (_hZnorm : 0 < Z), + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + ∀ (hV : ∀ z, 0 < V z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride T V z), + let law := principalTupleWeights (α := Fin q) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) + let source := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) * + (density (affineSampleCoefficientTorus U + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) : ℂ)) + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + physicalCubePositiveTest U D p hm (f y) test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) + ‖law.complexMean source / (Z : ℂ) - law.complexMean projected / (Z : ℂ)‖ ≤ (2 * η + ε) / Z := by + obtain ⟨A, hA, hprojection⟩ := exists_allocated_narrow_density_projection m q + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ _ n B _ _ _ J _ U basis R σ S c x P W hP hK hW hroot hWP hL M hperiod + X _ _ hX hdim F _ frequency hfrequency coeff hcoeff p hp hm base stride hs hsP + τ ξ ε hτ hτP hξ hξ1 hξP hε hεP N hsize rank hrank hRank test htest T hT density D f + hproject η hη happrox Z hZnorm V hV hmass law source projected + have hpoint (y) : ‖source y / (Z : ℂ) - projected y / (Z : ℂ)‖ ≤ (2 * η + ε) / Z := by + obtain ⟨_, _, he⟩ := hprojection B U basis S c x hP hK hW hroot hWP hL hperiod y + hX hdim frequency hfrequency coeff hcoeff p hp hm base stride hs hsP + hτ hτP hξ hξ1 hξP hε hεP N hsize hrank hRank test htest T hT density D (f y) + hη happrox hZnorm + (fun z => (hproject y) frequency coeff + (fun v => by rw [norm_sub_rev]; exact happrox v) + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => degreeLE_translate (1 : X → ℕ) (fun _ => by norm_num) _ (p j) (hp j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) + exact he + have hmean := law.norm_complexMean_sub_le + (fun y => source y / (Z : ℂ)) (fun y => projected y / (Z : ℂ)) + (fun _ => (2 * η + ε) / Z) (fun y _ => hpoint y) + rw [law.mean_const] at hmean + simpa only [FiniteProbabilityWeights.complexMean, mul_div_assoc, Finset.sum_div] using hmean + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel MeasureTheory +open scoped BigOperators Classical + +universe uX uF + +theorem exists_allocated_mixture_density_projection_law (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + {P W : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + {X : Type uX} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + {F : Type uF} [Fintype F] + (frequency : F → ∀ j, (LayerSamplerVariables G I n B →₀ ℕ) → J j → ℤ) + (_hfrequency : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ Real.exp P) + (coeff : F → ℂ) (_hcoeff : (∑ a, ‖coeff a‖) ≤ Real.exp P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ ε : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (_hε : 0 < ε) (_hεP : ε⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty) + (density : CoefficientTorus (K := LayerSamplerVariables G I n B) U → ℝ) + (D : ℕ) + (f : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) + (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, uF} U + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) D density (f y)) + {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ v, ‖(density v : ℂ) - coefficientTorusFourierSum U frequency coeff v‖ ≤ η) + {Z : ℝ} (_hZnorm : 0 < Z), + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + ∀ (hV : ∀ z, 0 < V z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride T V z), + ∀ law : FiniteProbabilityWeights (PrincipalIntegerTuples B (layerSamplerDegree I n) + (Fin q) (allocatedPrincipalSides B U basis S)), + let source := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) * + (density (affineSampleCoefficientTorus U + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) : ℂ)) + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + physicalCubePositiveTest U D p hm (f y) test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) + ‖law.complexMean source / (Z : ℂ) - law.complexMean projected / (Z : ℂ)‖ ≤ (2 * η + ε) / Z := by + obtain ⟨A, hA, hprojection⟩ := exists_allocated_narrow_density_projection m q + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ _ n B _ _ _ J _ U basis R σ S c x P W hP hK hW hroot hWP hL M hperiod + X _ _ hX hdim F _ frequency hfrequency coeff hcoeff p hp hm base stride hs hsP + τ ξ ε hτ hτP hξ hξ1 hξP hε hεP N hsize rank hrank hRank test htest T hT density D f + hproject η hη happrox Z hZnorm V hV hmass law source projected + have hpoint (y) : ‖source y / (Z : ℂ) - projected y / (Z : ℂ)‖ ≤ (2 * η + ε) / Z := by + obtain ⟨_, _, he⟩ := hprojection B U basis S c x hP hK hW hroot hWP hL hperiod y + hX hdim frequency hfrequency coeff hcoeff p hp hm base stride hs hsP + hτ hτP hξ hξ1 hξP hε hεP N hsize hrank hRank test htest T hT density D (f y) + hη happrox hZnorm + (fun z => (hproject y) frequency coeff + (fun v => by rw [norm_sub_rev]; exact happrox v) + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => degreeLE_translate (1 : X → ℕ) (fun _ => by norm_num) _ (p j) (hp j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) + exact he + have hmean := law.norm_complexMean_sub_le + (fun y => source y / (Z : ℂ)) (fun y => projected y / (Z : ℂ)) + (fun _ => (2 * η + ε) / Z) (fun y _ => hpoint y) + rw [law.mean_const] at hmean + simpa only [FiniteProbabilityWeights.complexMean, mul_div_assoc, Finset.sum_div] using hmean + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +universe uX + +theorem exists_allocated_original_density_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + {P W : ℝ} (_hP : 0 ≤ P) (_hm : (m : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + {X : Type uX} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty) + (D : ℕ) + (f : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ), + let density := allocatedCoefficientDensity B U basis hb o hR hσ S + ∀ (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, 0} U + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) D density (f y)) + {Z : ℝ} (_hZ : 0 < Z) (_hZi : Z⁻¹ ≤ Real.exp P), + let widths := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + ∀ (hwidths : ∀ z, 0 < widths z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride T widths z), + let law := principalTupleWeights (α := Fin q) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) + let source := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T widths hwidths hmass z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) * + (density (affineSampleCoefficientTorus U + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) : ℂ)) + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T widths hwidths hmass z).toReal : ℂ) * + physicalCubePositiveTest U D p hm (f y) test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) + ‖law.complexMean source / (Z : ℂ) - law.complexMean projected / (Z : ℂ)‖ ≤ Real.exp (-P) := by + obtain ⟨A₀, _, hprojection⟩ := exists_allocated_mixture_density_projection m q + obtain ⟨b, _, hbnd⟩ := exists_positiveComparisonDataBudget_bound m q + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget + (((Polynomial.X + Polynomial.C b) ^ b + Polynomial.C A₀) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ _ n B _ _ _ J _ U basis R σ S c x hb o hR hσ C V hC hV + hσ1 Cinv hCinv hchart hsmall P W hP hmSize hK hW hroot hWP hL hRP hσP hcount hI hn hJ + hAP hCP hVP M hperiod X _ _ hX hdim p hp hm base stride hs hsP τ ξ hτ hτP hξ hξ1 hξP + N hsize rank hrank hRank test htest T hT D f density hproject Z hZ hZi widths hwidths hmass + law source projected + let Q := positiveComparisonDataBudget m q P + obtain ⟨hQ, hPQ, haccQ, _, _⟩ := positiveComparisonDataBudget_bounds m q hP + have hExp := Real.exp_le_exp.mpr hPQ + have hcut : (Q + A₀) ^ A₀ ≤ (P + A) ^ A := by + calc + _ ≤ ((P + b) ^ b + A₀) ^ A₀ := + pow_le_pow_left₀ (add_nonneg hQ (Nat.cast_nonneg A₀)) + (add_le_add (hbnd P hP) le_rfl) A₀ + _ ≤ _ := by simpa [Polynomial.eval₂_pow] using hbudget P hP + obtain ⟨_, F, inst, frequency, coeff, hfreq, hcoeff, happ⟩ := + exists_allocated_positive_fourier_data B U basis hb o S C V hC hV q + hR hσ hσ1 Cinv hCinv hchart hsmall hP hmSize hK hRP hσP hcount hI hn hJ hAP hL hCP hVP + let _ := inst + have hη : 0 < positiveProjectionAccuracy P := Real.exp_pos _ + have hηQ : (positiveProjectionAccuracy P)⁻¹ ≤ Real.exp Q := by + simp only [positiveProjectionAccuracy, Real.exp_neg, inv_inv] + exact Real.exp_le_exp.mpr haccQ + have he := hprojection B U basis S c x hQ (hK.trans hPQ) hW hroot + (hWP.trans hExp) (hL.trans hExp) hperiod (hX.trans hPQ) (hdim.trans hPQ) + frequency hfreq coeff hcoeff p hp hm base stride hs (fun t => (hsP t).trans hExp) + hτ (hτP.trans hExp) hξ hξ1 (hξP.trans hExp) hη hηQ N + (fun t => (Real.exp_le_exp.mpr hcut).trans (hsize t)) hrank + ((Real.exp_le_exp.mpr hcut).trans hRank) test htest T hT density D f hproject hη.le happ hZ + hwidths hmass + apply he.trans + calc + (2 * positiveProjectionAccuracy P + positiveProjectionAccuracy P) / Z = + 3 * positiveProjectionAccuracy P * Z⁻¹ := by ring + _ ≤ 3 * positiveProjectionAccuracy P * Real.exp P := + mul_le_mul_of_nonneg_left hZi (by positivity) + _ = 3 * Real.exp (-(P + 4)) := by + rw [mul_assoc, positiveProjectionAccuracy, ← Real.exp_add] + congr 2 + ring + _ ≤ Real.exp 4 * Real.exp (-(P + 4)) := + mul_le_mul_of_nonneg_right (by linarith [Real.add_one_le_exp (4 : ℝ)]) (Real.exp_nonneg _) + _ = Real.exp (-P) := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +universe uX + +variable {m dim : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) (d : ℕ) +variable (g : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S) → + EuclideanJetLayers U (fun j => BoundedBooleanJet (Fin dim) (j.val + 1)) → ℝ) + +def AllocatedOriginalSourceProjectionAt (P : ℝ) (K : ℕ) : Prop := + ∀ {Q : ℝ}, P ≤ Q → 1 ≤ Q → + ∀ {X : Type uX} [Fintype X] [DecidableEq X], + (Fintype.card X : ℝ) ≤ Q → + (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ Q → + ∀ (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + ∀ (hmem : ∀ j e, coefficients (poly j) e ∈ U j) (base : X → ℤ) + (stride : X → ℕ), (∀ t, 0 < stride t) → (∀ t, (stride t : ℝ) ≤ Real.exp Q) → + ∀ {W τ ξ : ℝ} (hW : 0 ≤ W), + allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W → W ≤ Real.exp Q → + ∀ (hτ : 0 < τ), τ⁻¹ ≤ Real.exp Q → + ∀ (hξ : 0 < ξ), ξ ≤ 1 → ξ⁻¹ ≤ Real.exp Q → + ∀ (N : X → ℕ) (hN : ∀ t, 0 < N t), + (∀ t, Real.exp ((Q + K) ^ K) ≤ (N t : ℝ)) → + ∀ {rank : ℝ}, + (∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) → + Real.exp ((Q + K) ^ K) ≤ rank → + ∀ (test : Finset (Fin dim) → (X → ℝ) → ℂ), (∀ s v, ‖test s v‖ ≤ 1) → + ∀ (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)), + cells.Nonempty → ∀ {Z : ℝ}, 1 / 2 ≤ Z → + ∀ (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z), + ‖allocatedOriginalTupleSource B U b hR hσ S x X stride hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem - + allocatedProjectedTupleSource B U b S x X stride g N hN hW hτ hξ base cells hmass + (physicalCubeEuclideanSample U d poly hmem) (physicalCubeSiteTest test) Z‖ ≤ Real.exp (-Q) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +universe uX + +theorem exists_allocated_original_source_projection (m dim : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (x : G → IntegerScalarCubeBox (Fin dim) S.value) + (hb : ∀ j, span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ≤ V j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + {P : ℝ} (_hP : 0 ≤ P) (_hm : (m : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hL : (S.value : ℝ) ≤ Real.exp P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + (d : ℕ) + (g : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U (fun j => BoundedBooleanJet (Fin dim) (j.val + 1)) → ℝ) + (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, 0} U + (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) + (allocatedPhysicalCubeDirections B U basis S x y) d + (allocatedCoefficientDensity B U basis hb o hR hσ S) (g y)), + AllocatedOriginalSourceProjectionAt.{uX} B U basis hR hσ S x hb o d g P A := by + obtain ⟨A, hA, hprojection⟩ := exists_allocated_original_density_projection m dim + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ _ n B _ _ _ J _ U b R σ S x hb o hR hσ C V hC hV + hσ1 Cinv hCinv hchart hsmall P hP hm hK hL hRP hσP hcount hI hn hJ hAP hCP hVP + M hperiod d g hproject + unfold AllocatedOriginalSourceProjectionAt + intro Q hPQ hQ1 X _ _ hX hdim poly hpoly hmem base stride hs hsQ W τ ξ hW hbudget hWQ + hτ hτQ hξ hξ1 hξQ N hN hsize rank hrank hRank test htest cells hcells Z hZ hmass + have hQ : 0 ≤ Q := hP.trans hPQ + have hExp := Real.exp_le_exp.mpr hPQ + have hZpos : 0 < Z := by linarith + have hZi : Z⁻¹ ≤ Real.exp Q := by + have hi := one_div_le_one_div_of_le (by norm_num : (0 : ℝ) < 1 / 2) hZ + have hi' : Z⁻¹ ≤ (2 : ℝ) := by simpa only [one_div, inv_inv] using hi + exact hi'.trans (by linarith [Real.add_one_le_exp Q]) + have h := hprojection B U b S (fun _ => 0) x hb o hR hσ C V hC hV hσ1 Cinv hCinv hchart + hsmall hQ (hm.trans hPQ) (hK.trans hPQ) hW hbudget hWQ (hL.trans hExp) + (fun j => (hRP j).trans hExp) (fun j => (hσP j).trans hExp) + (fun j => (hcount j).trans hPQ) (fun j => (hI j).trans hPQ) + (fun j => (hn j).trans hPQ) (fun j => (hJ j).trans hPQ) (hAP.trans hExp) + (fun j => (hCP j).trans hExp) (fun j => (hVP j).trans hExp) hperiod hX hdim + poly hpoly hmem base stride hs hsQ hτ hτQ hξ hξ1 hξQ N hsize hrank hRank + test htest cells hcells d g hproject hZpos hZi + (narrowTrimmedSpatialWidths_pos hW hτ hξ N hN) hmass + simpa only [allocatedOriginalTupleSource, allocatedProjectedTupleSource, physicalCubePositiveTest] using h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedPhysicalCertifiedRankWitnessLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedPhysicalCertifiedRankWitnessLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..705e922455e3f8b6a5fe67e5f47dbfce1d88c50f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedPhysicalCertifiedRankWitnessLaw.lean @@ -0,0 +1,157 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedPhysicalIntegerRankLaw + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type} [Fintype G] {I : Fin m → Type} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J E : Fin m → Type} [∀ j, Fintype (J j)] [∀ j, DecidableEq (J j)] [∀ j, Fintype (E j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + +variable (C V : Fin m → ℝ≥0) +variable (hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) +variable (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + +include bW hC hV in + +theorem exists_allocated_physical_certified_rank_witness_law + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (hσ1 : ∀ j, σ j ≤ 1) + (Cinv : Fin m → ℝ) (hCinv : ∀ j, 0 ≤ Cinv j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ Cinv j * ‖v‖) + (hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1/4) + (cap : ℕ) (hcap : 0 < cap) + {P δ : ℝ} (hP : 0 ≤ P) (hmP : (m : ℝ) ≤ P) + (hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ) ≤ P) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (hn : ∀ j, (n j : ℝ) ≤ P) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hLP : (S.value : ℝ) ≤ Real.exp P) + (hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (hcapP : (cap : ℝ) ≤ Real.exp P) (hδ : 0 < δ) (hδP : δ⁻¹ ≤ Real.exp P) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + {X : Type} [Fintype X] [DecidableEq X] + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j) + {Ps ε ρ Rs Smax : ℝ} (hPs : 0 ≤ Ps) (hX : (Fintype.card X : ℝ) ≤ Ps) + (hframe : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ Ps) + (hcapPs : (cap : ℝ) ≤ Real.exp Ps) + (hε : 0 < ε) (hρ : 0 < ρ) (hεPs : 1 / ε ≤ Real.exp Ps) (hρPs : 1 / ρ ≤ Real.exp Ps) + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (hSmax : 0 ≤ Smax) (hSmaxPs : Smax ≤ Real.exp Ps) (hstrideMax : ∀ x, ((stride x * cap : ℕ) : ℝ) ≤ Smax) + (H : X → ℝ) + (hsize : ∀ x, Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ H x) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H Rs (U j) (poly j)) + (hRs : Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ Rs) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (hcells : cells.Nonempty) + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) + (rankC : ℝ) + (width : Option (LayerSamplerVariables G I n B) × X → ℝ) (hwidth : ∀ z, 0 < width z) + (hwide : ∀ z, ρ * H z.2 ≤ width z) + (hfreqPs : (4 * allocatedFourierLogBudget m P + 2)^4 ≤ Ps) + (hmassPs : 4 * allocatedFourierLogBudget m P * (4 * allocatedFourierLogBudget m P + 2)^4 + + allocatedFourierLogBudget m P ≤ Ps) + (hsmallError : 2 * δ + ε ≤ 1 / 2) : + let Dphysical := fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => + allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k, x) : ℝ))) + ∃ hD0 : ∀ z, 0 ≤ Dphysical z, + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells width z, + ∃ hDpos : 0 < selectedResidueDensityMass stride cells width Dphysical, + ∃ read : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + AllocatedActualCoefficientIndex G X I E n B → ℤ, + (∀ z, allocatedReadNoise (read z) = z) ∧ + (∀ z, Dphysical z ≠ 0 → + ∀ (primes : Finset ℕ) (hprimes : ∀ p : primes, NeZero p.val), letI := hprimes + ∀ (depth : ℕ → ℕ) (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ hdiv : ∀ p : primes, p.val ^ depth p.val ∣ q, + coefficientDeckChartEvent U bW b hb o q + (allocatedChartResiduePrimePowerWitness inactive rankC primes depth q hdiv + (fun v => (z v : ZMod q))) + (affineCoefficientCoverSample U poly hm q (fun k x => (z (k,x) : ℝ))) ↔ + ∀ p : primes, allocatedActualModulusBad inactive spatial kernel block rankC + (p.val ^ depth p.val) (read z)) ∧ + |selectedResidueDensityMass stride cells width Dphysical - 1| ≤ 2 * δ + ε ∧ + 1 / 2 ≤ selectedResidueDensityMass stride cells width Dphysical ∧ + selectedResidueDensityMass stride cells width Dphysical ≤ 3 / 2 ∧ + ∀ (primes : Finset ℕ) (hprimes : ∀ p : primes, NeZero p.val), letI := hprimes + ∀ (depth : ℕ → ℕ) (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ (_hqcap : q ≤ cap) (_hdiv : ∀ p : primes, p.val ^ depth p.val ∣ q), + |(∑' z, (selectedResidueDensityPMF stride cells width hwidth hZ Dphysical hD0 hDpos z).toReal * + (if ∀ p : primes, allocatedActualModulusBad inactive spatial kernel block + rankC (p.val ^ depth p.val) (read z) then (1 : ℝ) else 0)) - + (((selectedResidueSmoothPMF stride cells width hwidth hZ).bind fun z => + (allocatedCoefficientIntegerPMF B U b hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q)).map + fun r => decide (∀ p : primes, allocatedActualModulusBad inactive spatial kernel block + rankC (p.val ^ depth p.val) (allocatedMixedFullArray (Sum.elim z a) + (fun ⟨j,e,i⟩ => ((r j e i).val : ℤ)) (fun _ => 0)))) true).toReal| ≤ + 12 * (2 * δ + ε) := by + dsimp only + let : NeZero cap := ⟨hcap.ne'⟩ + let emptyPrimes : Finset ℕ := ∅ + let : ∀ p : emptyPrimes, NeZero p.val := fun p => + False.elim (Finset.notMem_empty p.val p.property) + obtain ⟨hD0, hZ, hDpos, hmass, hlower, hupper, _⟩ := + exists_allocated_physical_rank_witness_comparison B U bW b hb o S C V hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall cap hcap hP hmP hK hRP hσP hcount hI hn hJ hAP hLP + hCP hVP hcapP hδ hδP μ ν poly hp hm hPs hX hframe hcapPs hε hρ hεPs hρPs stride hstride + hSmax hSmaxPs hstrideMax H hsize hrank hRs cells hcells inactive spatial kernel block + rankC emptyPrimes (fun _ => 0) (fun p => False.elim (Finset.notMem_empty p.val p.property)) + width hwidth hwide hfreqPs hmassPs hsmallError + obtain ⟨read, hread⟩ := exists_allocatedPhysical_integer_rank_read + B U bW b hb o S hR hσ poly hm inactive spatial kernel block rankC + refine ⟨hD0, hZ, hDpos, read, fun z => (hread z).1, + fun z hz => (hread z).2 hz, hmass, hlower, hupper, ?_⟩ + intro primes hprimes + let := hprimes + intro depth q hq + let : NeZero q := ⟨hq.ne'⟩ + intro hqcap hdiv + have hqP : (q : ℝ) ≤ Real.exp P := (Nat.cast_le.mpr hqcap).trans hcapP + have hqPs : (q : ℝ) ≤ Real.exp Ps := (Nat.cast_le.mpr hqcap).trans hcapPs + have hstrideq : ∀ x, ((stride x * q : ℕ) : ℝ) ≤ Smax := fun x => + (Nat.cast_le.mpr (Nat.mul_le_mul_left (stride x) hqcap)).trans (hstrideMax x) + obtain ⟨_, _, _, _, _, _, he⟩ := + exists_allocated_physical_rank_witness_comparison B U bW b hb o S C V hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall q hq hP hmP hK hRP hσP hcount hI hn hJ hAP hLP + hCP hVP hqP hδ hδP μ ν poly hp hm hPs hX hframe hqPs hε hρ hεPs hρPs stride hstride + hSmax hSmaxPs hstrideq H hsize hrank hRs cells hcells inactive spatial kernel block + rankC primes depth hdiv width hwidth hwide hfreqPs hmassPs hsmallError + have hevent := selectedResidueDensityPMF_event_congr_of_density_ne_zero + stride cells width hwidth hZ _ hD0 hDpos _ _ + (fun z hz => (hread z).2 hz primes hprimes depth q hq hdiv) + rw [hevent] at he + exact he + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedPhysicalRankWitnessLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedPhysicalRankWitnessLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cc7185b77844a8d13a14875b9f1e8b01b53acb7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedPhysicalRankWitnessLaw.lean @@ -0,0 +1,144 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedPhysicalIntegerRankLaw + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type} [Fintype G] {I : Fin m → Type} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J E : Fin m → Type} [∀ j, Fintype (J j)] [∀ j, DecidableEq (J j)] [∀ j, Fintype (E j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + +variable (C V : Fin m → ℝ≥0) +variable (hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) +variable (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + +include bW hC hV in + +theorem exists_allocated_physical_rank_witness_law + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (hσ1 : ∀ j, σ j ≤ 1) + (Cinv : Fin m → ℝ) (hCinv : ∀ j, 0 ≤ Cinv j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ Cinv j * ‖v‖) + (hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1/4) + (cap : ℕ) (hcap : 0 < cap) + {P δ : ℝ} (hP : 0 ≤ P) (hmP : (m : ℝ) ≤ P) + (hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ) ≤ P) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (hn : ∀ j, (n j : ℝ) ≤ P) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hLP : (S.value : ℝ) ≤ Real.exp P) + (hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (hcapP : (cap : ℝ) ≤ Real.exp P) (hδ : 0 < δ) (hδP : δ⁻¹ ≤ Real.exp P) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + {X : Type} [Fintype X] [DecidableEq X] + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j) + {Ps ε ρ Rs Smax : ℝ} (hPs : 0 ≤ Ps) (hX : (Fintype.card X : ℝ) ≤ Ps) + (hframe : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ Ps) + (hcapPs : (cap : ℝ) ≤ Real.exp Ps) + (hε : 0 < ε) (hρ : 0 < ρ) (hεPs : 1 / ε ≤ Real.exp Ps) (hρPs : 1 / ρ ≤ Real.exp Ps) + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (hSmax : 0 ≤ Smax) (hSmaxPs : Smax ≤ Real.exp Ps) (hstrideMax : ∀ x, ((stride x * cap : ℕ) : ℝ) ≤ Smax) + (H : X → ℝ) + (hsize : ∀ x, Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ H x) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H Rs (U j) (poly j)) + (hRs : Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ Rs) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (hcells : cells.Nonempty) + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) + (rankC : ℝ) + (width : Option (LayerSamplerVariables G I n B) × X → ℝ) (hwidth : ∀ z, 0 < width z) + (hwide : ∀ z, ρ * H z.2 ≤ width z) + (hfreqPs : (4 * allocatedFourierLogBudget m P + 2)^4 ≤ Ps) + (hmassPs : 4 * allocatedFourierLogBudget m P * (4 * allocatedFourierLogBudget m P + 2)^4 + + allocatedFourierLogBudget m P ≤ Ps) + (hsmallError : 2 * δ + ε ≤ 1 / 2) : + let Dphysical := fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => + allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k, x) : ℝ))) + ∃ hD0 : ∀ z, 0 ≤ Dphysical z, + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells width z, + ∃ hDpos : 0 < selectedResidueDensityMass stride cells width Dphysical, + ∃ read : (Option (LayerSamplerVariables G I n B) × X → ℤ) → + AllocatedActualCoefficientIndex G X I E n B → ℤ, + (∀ z, allocatedReadNoise (read z) = z) ∧ + |selectedResidueDensityMass stride cells width Dphysical - 1| ≤ 2 * δ + ε ∧ + 1 / 2 ≤ selectedResidueDensityMass stride cells width Dphysical ∧ + selectedResidueDensityMass stride cells width Dphysical ≤ 3 / 2 ∧ + ∀ (primes : Finset ℕ) (hprimes : ∀ p : primes, NeZero p.val), letI := hprimes + ∀ (depth : ℕ → ℕ) (q : ℕ) (hq : 0 < q), letI : NeZero q := ⟨hq.ne'⟩ + ∀ (_hqcap : q ≤ cap) (_hdiv : ∀ p : primes, p.val ^ depth p.val ∣ q), + |(∑' z, (selectedResidueDensityPMF stride cells width hwidth hZ Dphysical hD0 hDpos z).toReal * + (if ∀ p : primes, allocatedActualModulusBad inactive spatial kernel block + rankC (p.val ^ depth p.val) (read z) then (1 : ℝ) else 0)) - + (((selectedResidueSmoothPMF stride cells width hwidth hZ).bind fun z => + (allocatedCoefficientIntegerPMF B U b hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q)).map + fun r => decide (∀ p : primes, allocatedActualModulusBad inactive spatial kernel block + rankC (p.val ^ depth p.val) (allocatedMixedFullArray (Sum.elim z a) + (fun ⟨j,e,i⟩ => ((r j e i).val : ℤ)) (fun _ => 0)))) true).toReal| ≤ + 12 * (2 * δ + ε) := by + dsimp only + let : NeZero cap := ⟨hcap.ne'⟩ + let emptyPrimes : Finset ℕ := ∅ + let : ∀ p : emptyPrimes, NeZero p.val := fun p => + False.elim (Finset.notMem_empty p.val p.property) + obtain ⟨hD0, hZ, hDpos, hmass, hlower, hupper, _⟩ := + exists_allocated_physical_rank_witness_comparison B U bW b hb o S C V hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall cap hcap hP hmP hK hRP hσP hcount hI hn hJ hAP hLP + hCP hVP hcapP hδ hδP μ ν poly hp hm hPs hX hframe hcapPs hε hρ hεPs hρPs stride hstride + hSmax hSmaxPs hstrideMax H hsize hrank hRs cells hcells inactive spatial kernel block + rankC emptyPrimes (fun _ => 0) (fun p => False.elim (Finset.notMem_empty p.val p.property)) + width hwidth hwide hfreqPs hmassPs hsmallError + obtain ⟨read, hnoise, hread⟩ := exists_allocatedPhysical_integer_rank_law + B U bW b hb o S hR hσ poly hm inactive spatial kernel block rankC stride cells width hwidth + hZ hD0 hDpos + refine ⟨hD0, hZ, hDpos, read, hnoise, hmass, hlower, hupper, ?_⟩ + intro primes hprimes + let := hprimes + intro depth q hq + let : NeZero q := ⟨hq.ne'⟩ + intro hqcap hdiv + have hqP : (q : ℝ) ≤ Real.exp P := (Nat.cast_le.mpr hqcap).trans hcapP + have hqPs : (q : ℝ) ≤ Real.exp Ps := (Nat.cast_le.mpr hqcap).trans hcapPs + have hstrideq : ∀ x, ((stride x * q : ℕ) : ℝ) ≤ Smax := fun x => + (Nat.cast_le.mpr (Nat.mul_le_mul_left (stride x) hqcap)).trans (hstrideMax x) + obtain ⟨_, _, _, _, _, _, he⟩ := + exists_allocated_physical_rank_witness_comparison B U bW b hb o S C V hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall q hq hP hmP hK hRP hσP hcount hI hn hJ hAP hLP + hCP hVP hqP hδ hδP μ ν poly hp hm hPs hX hframe hqPs hε hρ hεPs hρPs stride hstride + hSmax hSmaxPs hstrideq H hsize hrank hRs cells hcells inactive spatial kernel block + rankC primes depth hdiv width hwidth hwide hfreqPs hmassPs hsmallError + rw [hread primes hprimes depth q hq hdiv] at he + exact he + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProbabilityProfileKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProbabilityProfileKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..d81027b3ac617136c4066a38c87243f4e86394e6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProbabilityProfileKernel.lean @@ -0,0 +1,265 @@ +import OAI.Combinatorics.Progressions.Fourier.AllocatedErrorStandardFourier +import OAI.Combinatorics.Progressions.Geometry.AllocatedAmbientSiteCoordinates +import OAI.Combinatorics.Progressions.Probability.AllocatedProbabilityMajorantMass + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "output" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) + +noncomputable def allocatedProfileErrorCap (A Cf Cg : ℝ≥0) (V : Fin m → ℝ≥0) : ℝ≥0 := + allocatedErrorKernelCap B U b S (O := O) 1 A V * (Cf + Cg) + +noncomputable def allocatedProfileErrorLip (A Cf Cg Kf Kg : ℝ≥0) (C V : Fin m → ℝ≥0) : ℝ≥0 := + allocatedErrorKernelCap B U b S (O := O) 1 A V * + ((Kf + Kg) * (∑ j, C j * Fintype.card (J j))) + + (Cf + Cg) * allocatedErrorKernelLip B U b S (O := O) 1 A C V + +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable {α : Type*} [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) (allocatedPrincipalSides B U b S)) +variable (v : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) (allocatedPrincipalSides B U b S)) +variable (rows : ∀ j, O j → Finset α) + +noncomputable def allocatedProfileErrorAmbientKernel (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) (z : JetAmbientIndex O J → ℝ) : ℝ := + allocatedErrorAmbientKernel B U b S o hR hσ x u v rows 1 A z * + |f (allocatedLongAmbientCoordinates B U b S o z) - g (allocatedLongAmbientCoordinates B U b S o z)| + +theorem allocatedProfileErrorAmbientKernel_support (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) (z : JetAmbientIndex O J → ℝ) + (hz : allocatedProfileErrorAmbientKernel B U b S o hR hσ x u v rows A f g z ≠ 0) : + ∀ i, |z i| < 1 / 2 := by + apply allocatedErrorAmbientKernel_support B U b S o hR hσ x u v rows 1 A z + intro he + exact hz (by simp only [allocatedProfileErrorAmbientKernel, he, zero_mul]) + +theorem allocatedProfileErrorAmbientKernel_bounds (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) {Cf Cg Kf Kg : ℝ≥0} + (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (hfb : ∀ z, |f z| ≤ Cf) (hgb : ∀ z, |g z| ≤ Cg) + (C V : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) : + (∀ z, 0 ≤ allocatedProfileErrorAmbientKernel B U b S o hR hσ x u v rows A f g z ∧ + allocatedProfileErrorAmbientKernel B U b S o hR hσ x u v rows A f g z ≤ + allocatedProfileErrorCap B U b S (O := O) A Cf Cg V) ∧ + LipschitzWith (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V) + (allocatedProfileErrorAmbientKernel B U b S o hR hσ x u v rows A f g) := by + have hb := allocatedErrorAmbientKernel_bounds B U b S o hR hσ x u v rows 1 A C V hC hV + have hd : LipschitzWith ((Kf + Kg) * (∑ j, C j * Fintype.card (J j))) + (fun z => |f (allocatedLongAmbientCoordinates B U b S o z) - + g (allocatedLongAmbientCoordinates B U b S o z)|) := by + simpa only [Real.norm_eq_abs, Function.comp_def, Pi.sub_apply, one_mul] using + ((lipschitzWith_one_norm.comp (hf.sub hg)).comp (allocatedLongAmbientCoordinates_lipschitz B U b S o C hC)) + have hdb (z : output → ℝ) : |f z - g z| ≤ (Cf + Cg : ℝ≥0) := + (abs_sub (f z) (g z)).trans (add_le_add (hfb z) (hgb z)) + refine ⟨fun z => ⟨mul_nonneg (hb.1 z).1 (abs_nonneg _), ?_⟩, ?_⟩ + · exact mul_le_mul (hb.1 z).2 (hdb _) (abs_nonneg _) (NNReal.coe_nonneg _) + · exact lipschitz_real_mul_of_bounds _ _ hb.2 hd + (fun z => by rw [abs_of_nonneg (hb.1 z).1]; exact (hb.1 z).2) + (fun z => by rw [abs_abs]; exact hdb _) + +noncomputable def allocatedProfileErrorTorusKernel (A : ℝ≥0) (f g : (output → ℝ) → ℝ) : + (JetAmbientIndex O J → UnitAddCircle) → ℝ := + smallBoxTorusKernel (allocatedProfileErrorAmbientKernel B U b S o hR hσ x u v rows A f g) + +noncomputable def allocatedProfileErrorMajorant (A : ℝ≥0) (f g : (output → ℝ) → ℝ) + (d : ℕ) (y : EuclideanJetLayers U O) : ℝ := + allocatedProfileErrorTorusKernel B U b S o hR hσ x u v rows A f g (coveredJetAmbientTorus U d y) + +theorem allocatedProfileErrorTorusKernel_bounds (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) {Cf Cg Kf Kg : ℝ≥0} + (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (hfb : ∀ z, |f z| ≤ Cf) (hgb : ∀ z, |g z| ≤ Cg) + (C V : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) : + (∀ z, 0 ≤ allocatedProfileErrorTorusKernel B U b S o hR hσ x u v rows A f g z ∧ + allocatedProfileErrorTorusKernel B U b S o hR hσ x u v rows A f g z ≤ + allocatedProfileErrorCap B U b S (O := O) A Cf Cg V) ∧ + LipschitzWith (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V) + (allocatedProfileErrorTorusKernel B U b S o hR hσ x u v rows A f g) := by + have h := allocatedProfileErrorAmbientKernel_bounds B U b S o hR hσ x u v rows A f g hf hg hfb hgb C V hC hV + exact ⟨smallBoxTorusKernel_range _ (NNReal.coe_nonneg _) h.1 + (allocatedProfileErrorAmbientKernel_support B U b S o hR hσ x u v rows A f g), + smallBoxTorusKernel_lipschitz _ h.2 (fun z => (h.1 z).1) + (allocatedProfileErrorAmbientKernel_support B U b S o hR hσ x u v rows A f g)⟩ + +theorem exists_allocated_profile_error_fourier (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) {Cf Cg Kf Kg : ℝ≥0} + (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (hfb : ∀ z, |f z| ≤ Cf) (hgb : ∀ z, |g z| ≤ Cg) + (C V : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + {δ P : ℝ} (hδ : 0 < δ) (hP : 0 ≤ P) + (hdim : (Fintype.card (JetAmbientIndex O J) : ℝ) ≤ P) + (hLip : (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V : ℝ) ≤ Real.exp P) + (hδP : δ⁻¹ ≤ Real.exp P) : + ∃ (F : Type) (inst : Fintype F), let _ : Fintype F := inst + ∃ (frequency : F → JetAmbientIndex O J → ℤ) (c : F → ℂ), + (Fintype.card F : ℝ) ≤ Real.exp (2 * P * (2 * P + 2) ^ 4) ∧ + (∀ a i, |(frequency a i : ℝ)| ≤ Real.exp ((2 * P + 2) ^ 4)) ∧ + (∑ a, ‖c a‖) ≤ Real.exp (2 * P * (2 * P + 2) ^ 4) * + allocatedProfileErrorCap B U b S (O := O) A Cf Cg V ∧ + ∀ y, ‖(allocatedProfileErrorTorusKernel B U b S o hR hσ x u v rows A f g y : ℂ) - + ∑ a, c a * ∏ i, CircleFourier.character (frequency a i • y i)‖ ≤ δ := by + have h := allocatedProfileErrorTorusKernel_bounds B U b S o hR hσ x u v rows A f g hf hg hfb hgb C V hC hV + have hl : LipschitzWith (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V) + (fun y => (allocatedProfileErrorTorusKernel B U b S o hR hσ x u v rows A f g y : ℂ)) := by + apply LipschitzWith.of_dist_le_mul + intro y z + rw [Complex.isometry_ofReal.dist_eq] + exact h.2.dist_le_mul y z + exact exists_ambient_torus_fourier_approximation _ _ _ hl + (fun y => by simpa only [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (h.1 y).1] using (h.1 y).2) + hδ hP hdim hLip hδP + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "output" => (Σ a : {a // ¬grid a}, O (Sigma.fst (Subtype.val a))) + +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (p : ∀ a : {a // allocatedGridAxis (I := I) U b S.value a}, PMF (CoefficientJetAxisRow O a.val)) + +noncomputable def allocatedProbabilityProfileAmbientKernel (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) (z : JetAmbientIndex O J → ℝ) : ℝ := + allocatedProbabilityAmbientKernel B U b S o p 1 A z * + |f (allocatedLongAmbientCoordinates B U b S o z) - g (allocatedLongAmbientCoordinates B U b S o z)| + +theorem allocatedProbabilityProfileAmbientKernel_support (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) (z : JetAmbientIndex O J → ℝ) + (hz : allocatedProbabilityProfileAmbientKernel B U b S o p A f g z ≠ 0) : + ∀ i, |z i| < 1 / 2 := by + apply allocatedProbabilityAmbientKernel_support B U b S o p 1 A z + intro he + exact hz (by simp only [allocatedProbabilityProfileAmbientKernel, he, zero_mul]) + +theorem allocatedProbabilityProfileAmbientKernel_bounds (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) {Cf Cg Kf Kg : ℝ≥0} + (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (hfb : ∀ z, |f z| ≤ Cf) (hgb : ∀ z, |g z| ≤ Cg) + (C V : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) : + (∀ z, 0 ≤ allocatedProbabilityProfileAmbientKernel B U b S o p A f g z ∧ + allocatedProbabilityProfileAmbientKernel B U b S o p A f g z ≤ + allocatedProfileErrorCap B U b S (O := O) A Cf Cg V) ∧ + LipschitzWith (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V) + (allocatedProbabilityProfileAmbientKernel B U b S o p A f g) := by + have hb := allocatedProbabilityAmbientKernel_bounds B U b S o p 1 A C V hC hV + have hd : LipschitzWith ((Kf + Kg) * (∑ j, C j * Fintype.card (J j))) + (fun z => |f (allocatedLongAmbientCoordinates B U b S o z) - + g (allocatedLongAmbientCoordinates B U b S o z)|) := by + simpa only [Real.norm_eq_abs, Function.comp_def, Pi.sub_apply, one_mul] using + ((lipschitzWith_one_norm.comp (hf.sub hg)).comp (allocatedLongAmbientCoordinates_lipschitz B U b S o C hC)) + have hdb (z : output → ℝ) : |f z - g z| ≤ (Cf + Cg : ℝ≥0) := + (abs_sub (f z) (g z)).trans (add_le_add (hfb z) (hgb z)) + refine ⟨fun z => ⟨mul_nonneg (hb.1 z).1 (abs_nonneg _), ?_⟩, ?_⟩ + · exact mul_le_mul (hb.1 z).2 (hdb _) (abs_nonneg _) (NNReal.coe_nonneg _) + · exact lipschitz_real_mul_of_bounds _ _ hb.2 hd + (fun z => by rw [abs_of_nonneg (hb.1 z).1]; exact (hb.1 z).2) + (fun z => by rw [abs_abs]; exact hdb _) + +noncomputable def allocatedProbabilityProfileTorusKernel (A : ℝ≥0) (f g : (output → ℝ) → ℝ) : + (JetAmbientIndex O J → UnitAddCircle) → ℝ := + smallBoxTorusKernel (allocatedProbabilityProfileAmbientKernel B U b S o p A f g) + +noncomputable def allocatedProbabilityProfileMajorant (A : ℝ≥0) (f g : (output → ℝ) → ℝ) + (d : ℕ) (y : EuclideanJetLayers U O) : ℝ := + allocatedProbabilityProfileTorusKernel B U b S o p A f g (coveredJetAmbientTorus U d y) + +theorem allocatedProbabilityProfileTorusKernel_bounds (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) {Cf Cg Kf Kg : ℝ≥0} + (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (hfb : ∀ z, |f z| ≤ Cf) (hgb : ∀ z, |g z| ≤ Cg) + (C V : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) : + (∀ z, 0 ≤ allocatedProbabilityProfileTorusKernel B U b S o p A f g z ∧ + allocatedProbabilityProfileTorusKernel B U b S o p A f g z ≤ + allocatedProfileErrorCap B U b S (O := O) A Cf Cg V) ∧ + LipschitzWith (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V) + (allocatedProbabilityProfileTorusKernel B U b S o p A f g) := by + have h := allocatedProbabilityProfileAmbientKernel_bounds B U b S o p A f g hf hg hfb hgb C V hC hV + exact ⟨smallBoxTorusKernel_range _ (NNReal.coe_nonneg _) h.1 + (allocatedProbabilityProfileAmbientKernel_support B U b S o p A f g), + smallBoxTorusKernel_lipschitz _ h.2 (fun z => (h.1 z).1) + (allocatedProbabilityProfileAmbientKernel_support B U b S o p A f g)⟩ + +theorem exists_allocated_probability_profile_fourier (A : ℝ≥0) + (f g : (output → ℝ) → ℝ) {Cf Cg Kf Kg : ℝ≥0} + (hf : LipschitzWith Kf f) (hg : LipschitzWith Kg g) + (hfb : ∀ z, |f z| ≤ Cf) (hgb : ∀ z, |g z| ≤ Cg) + (C V : Fin m → ℝ≥0) + (hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + {δ P : ℝ} (hδ : 0 < δ) (hP : 0 ≤ P) + (hdim : (Fintype.card (JetAmbientIndex O J) : ℝ) ≤ P) + (hLip : (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V : ℝ) ≤ Real.exp P) + (hδP : δ⁻¹ ≤ Real.exp P) : + ∃ (F : Type) (inst : Fintype F), let _ : Fintype F := inst + ∃ (frequency : F → JetAmbientIndex O J → ℤ) (c : F → ℂ), + (Fintype.card F : ℝ) ≤ Real.exp (2 * P * (2 * P + 2) ^ 4) ∧ + (∀ a i, |(frequency a i : ℝ)| ≤ Real.exp ((2 * P + 2) ^ 4)) ∧ + (∑ a, ‖c a‖) ≤ Real.exp (2 * P * (2 * P + 2) ^ 4) * + allocatedProfileErrorCap B U b S (O := O) A Cf Cg V ∧ + ∀ y, ‖(allocatedProbabilityProfileTorusKernel B U b S o p A f g y : ℂ) - + ∑ a, c a * ∏ i, CircleFourier.character (frequency a i • y i)‖ ≤ δ := by + have h := allocatedProbabilityProfileTorusKernel_bounds B U b S o p A f g hf hg hfb hgb C V hC hV + have hl : LipschitzWith (allocatedProfileErrorLip B U b S (O := O) A Cf Cg Kf Kg C V) + (fun y => (allocatedProbabilityProfileTorusKernel B U b S o p A f g y : ℂ)) := by + apply LipschitzWith.of_dist_le_mul + intro y z + rw [Complex.isometry_ofReal.dist_eq] + exact h.2.dist_le_mul y z + exact exists_ambient_torus_fourier_approximation _ _ _ hl + (fun y => by simpa only [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (h.1 y).1] using (h.1 y).2) + hδ hP hdim hLip hδP + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProductCoarseNormalizedKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProductCoarseNormalizedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2a0050a9d9ba2056a52ad10a83e49f589f47a17 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProductCoarseNormalizedKernel.lean @@ -0,0 +1,437 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedCoarseGenuineSource + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductCoarseKernelData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 2)) + ∀ {Mk : ℕ} (hMk : 0 < Mk) (selection : Fin dim ↪ G) + (_hqDim : dim ≤ m + 1) (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 2) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 2) + 2) + let mesh := fun x : GoodKernel => + allocatedProductCoarseMesh m X selection Mk (modulus x) Psp pAccuracy w v (E + 2) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + ∀ (_hZ : 1 / 2 ≤ Z), + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW (mesh x) base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + ∀ (kernelLaw : FiniteProbabilityWeights Kernel) {η : ℝ}, + kernelLaw.eventProbability (fun x => ¬Good x) ≤ η → + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +theorem allocatedProductCoarseKernelData_of_raw + {Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (hcover : AllocatedProductCoarseRawData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses) : + AllocatedProductCoarseKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses := by + unfold AllocatedProductCoarseKernelData + intro w v Pfinal Mk hMk selection hqDim hMkPsp Kernel Good GoodKernel + have hstart (x : GoodKernel) := hcover x.val hMk selection x.property hqDim hMkPsp + choose d hd hdb hstep using hstart + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + have hperiod (x : GoodKernel) := goodKernel_common_period selection x.val x.property + (m + 1) (by omega) (fun j : Fin m => j.val + 1) (fun j => by omega) + jetRows (fun _ => Subtype.val_injective) (fun _ a => a.property) + choose modulus hmodulus hmodulusSize hspatial hcoefficient using hperiod + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + have hsteps (x : GoodKernel) := hstep x (modulus x) (hmodulus x) + (hmodulusSize x) (hspatial x) (hcoefficient x) + choose pivots hA hinverse hfamily using hsteps + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z hZ H law + coverValue wholeReference reconstruct weight cover + have hZpos : 0 < Z := lt_of_lt_of_le (by norm_num) hZ + have hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z := + selectedJointDensityMass_smooth_mass_pos bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) hZpos + refine ⟨hmass, ?_⟩ + intro kernelLaw η hbad + have hpoint (x : GoodKernel) (base : X → ℤ) : + ‖allocatedOriginalTupleSource B U b hR hσ S x.val X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem - cover x base‖ ≤ Real.exp (-E) := by + obtain ⟨hRefined, hdiv, hRefinedBound, hsize, reference, residue, href, hresidue, hlocal⟩ := + hfamily x block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp + obtain ⟨hmass', hestimate⟩ := hlocal hτ hτP N hN hsizeN poly hpoly hmem hrank hRank + base cells hcells test htest Z hZ + exact hestimate + exact allocatedOriginal_kernel_average_of_bad_bound B U b hb o hR hσ S X poly hmem N hN + hW hτ hξ q cells hmass bases hbases hZpos kernelLaw selection Mk + (physicalCubeSiteTest test) (physicalCubeSiteTest_norm_le test htest) + (fun x hx base => cover ⟨x, hx⟩ base) (Real.exp_pos _).le + (fun x hx base _ => hpoint ⟨x, hx⟩ base) hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductCoarseNormalizedKernelData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 2)) + ∀ {Mk : ℕ} (hMk : 0 < Mk) (selection : Fin dim ↪ G) + (_hqDim : dim ≤ m + 1) (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 2) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 2) + 2) + let mesh := fun x : GoodKernel => + allocatedProductCoarseMesh m X selection Mk (modulus x) Psp pAccuracy w v (E + 2) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW (mesh x) base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (kernelLaw : FiniteProbabilityWeights Kernel) {η : ℝ}, + kernelLaw.eventProbability (fun x => ¬Good x) ≤ η → + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +theorem allocatedProductCoarseKernelData_normalized + {Psp E e pNum Pbase pAccuracy pSampling l F : ℝ} (hP : 0 ≤ Psp) (hE : 0 ≤ E) + (hPbase : Psp ≤ Pbase) (hpNum : pNum ≤ Pbase) + (hm : ((m + 1 : ℕ) : ℝ) ≤ Psp) (hdim : ((dim + 1 : ℕ) : ℝ) ≤ Psp) + (hG : (Fintype.card G : ℝ) ≤ Psp) (hl : Pbase ≤ l) (hF : 0 ≤ F) + (hnum : ∀ (_o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C V : Fin m → ℝ≥0), (∀ j, (C j : ℝ) ≤ Real.exp pNum) → + (∀ j, (V j : ℝ) ≤ Real.exp pNum) → AllocatedSourceNumerics B U b S C V Pbase) + {δ : ℝ≥0} {A Kraw Ksite Knorm : ℕ} + (hKraw : 1 ≤ Kraw) (hKsite : 1 ≤ Ksite) (hKnorm : 1 ≤ Knorm) + (hnorm : AllocatedSourceNarrowNormalization.{uG,uI,uB,uJ,uX} m Knorm) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) : + let Qraw := allocatedSourceSamplingBudget m dim A Pbase (E + 2) l F + AllocatedProductCoarseKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses → + AllocatedProductCoarseNormalizedKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw (max Ksite Knorm) witnesses := by + intro Qraw hKernel + have hPbase0 : 0 ≤ Pbase := hP.trans hPbase + have hEsource : 0 ≤ E + 2 := by linarith + have hQraw1 : 1 ≤ Qraw := + (allocatedSourceSamplingBudget_bounds m dim A hPbase0 hEsource (hPbase0.trans hl) hF).1 + have hQraw0 : 0 ≤ Qraw := zero_le_one.trans hQraw1 + unfold AllocatedProductCoarseNormalizedKernelData + intro w v Pfinal Mk hMk selection hqDim hMkPsp Kernel Good GoodKernel + have hFinal := sourceCoverParameter_bounds dim Kraw (pNum := pNum) (Qraw := Qraw) + (F := allocatedSiteErrorFourierOutput m pSampling w v) + (G := allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 2)) hP + have hFinal0 : 0 ≤ Pfinal := zero_le_one.trans hFinal.1 + have hRawPower : Qraw ≤ (Qraw + Kraw) ^ Kraw := by + have h := shifted_power_self_mono hQraw0 (le_refl 1) hKraw + simp only [Nat.cast_one, pow_one] at h + linarith + have hRawFinal : Qraw ≤ Pfinal := hRawPower.trans hFinal.2.2.2.2.1 + have hOldCut : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ + Real.exp ((Pfinal + (max Ksite Knorm : ℕ)) ^ max Ksite Knorm) := + Real.exp_le_exp.mpr (shifted_power_self_mono hFinal0 hKsite (le_max_left _ _)) + have hNormCut : Real.exp ((Qraw + Knorm) ^ Knorm) ≤ + Real.exp ((Pfinal + (max Ksite Knorm : ℕ)) ^ max Ksite Knorm) := by + apply Real.exp_le_exp.mpr + exact (pow_le_pow_left₀ (add_nonneg hQraw0 (Nat.cast_nonneg _)) + (add_le_add hRawFinal le_rfl) Knorm).trans + (shifted_power_self_mono hFinal0 hKnorm (le_max_right _ _)) + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hKernel⟩ := + hKernel hMk selection hqDim hMkPsp + let _ : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let _ : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z H law + coverValue wholeReference reconstruct weight cover + obtain ⟨_, hnormal⟩ := hnorm B U b S hb o μ ν hR hσ hσ1 C V hC hV Cinv hCinv hchart + hsmall A (hnum o C V hCp hVp) hP hEsource hPbase hm hdim hG hl hF + hXPsp selection hMk hMkPsp q hq hqPsp hτ (hτP.trans (Real.exp_le_exp.mpr hpNum)) + N (fun t => hNormCut.trans (hsizeN t)) poly hpoly hmem hrank (hNormCut.trans hRank) cells hcells + have hZ := hnormal bases hbases + obtain ⟨hmass, hcomparison⟩ := hKernel block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN + (fun t => hOldCut.trans (hsizeN t)) poly hpoly hmem hrank (hOldCut.trans hRank) + cells hcells test htest bases hbases hZ.2.1.1 + exact ⟨hmass, hZ, hcomparison⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProductNormalizedKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProductNormalizedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..61337bac98117fa7d860fe9d1d0c1a6c3164ed9b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedProductNormalizedKernel.lean @@ -0,0 +1,437 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedProductSeparatedRawData + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductKernelData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 1)) + ∀ {Mk : ℕ} (hMk : 0 < Mk) (selection : Fin dim ↪ G) + (_hqDim : dim ≤ m + 1) (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((E + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp pAccuracy w v (E + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + ∀ (_hZ : 1 / 2 ≤ Z), + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + ∀ (kernelLaw : FiniteProbabilityWeights Kernel) {η : ℝ}, + kernelLaw.eventProbability (fun x => ¬Good x) ≤ η → + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +theorem allocatedProductKernelData_of_raw + {Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ} (hP : 0 ≤ Psp) + {δ : ℝ≥0} {A Kraw Ksite : ℕ} + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) + (hcover : AllocatedProductSeparatedRawData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses) : + AllocatedProductKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses := by + unfold AllocatedProductKernelData + intro w v Pfinal Mk hMk selection hqDim hMkPsp Kernel Good GoodKernel + have hstart (x : GoodKernel) := hcover x.val hMk selection x.property hqDim hMkPsp + choose d hd hdb hstep using hstart + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + have hperiod (x : GoodKernel) := goodKernel_common_period selection x.val x.property + (m + 1) (by omega) (fun j : Fin m => j.val + 1) (fun j => by omega) + jetRows (fun _ => Subtype.val_injective) (fun _ a => a.property) + choose modulus hmodulus hmodulusSize hspatial hcoefficient using hperiod + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + have hsteps (x : GoodKernel) := hstep x (modulus x) (hmodulus x) + (hmodulusSize x) (hspatial x) (hcoefficient x) + choose pivots hA hinverse hfamily using hsteps + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z hZ H law + coverValue wholeReference reconstruct weight cover + have hZpos : 0 < Z := lt_of_lt_of_le (by norm_num) hZ + have hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z := + selectedJointDensityMass_smooth_mass_pos bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) hZpos + refine ⟨hmass, ?_⟩ + intro kernelLaw η hbad + have hpoint (x : GoodKernel) (base : X → ℤ) : + ‖allocatedOriginalTupleSource B U b hR hσ S x.val X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem - cover x base‖ ≤ Real.exp (-E) := by + obtain ⟨hRefined, hdiv, hRefinedBound, hsize, reference, residue, href, hresidue, hlocal⟩ := + hfamily x block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp + obtain ⟨hmass', hestimate⟩ := hlocal hτ hτP N hN hsizeN poly hpoly hmem hrank hRank + base cells hcells test htest Z hZ + exact hestimate + exact allocatedOriginal_kernel_average_of_bad_bound B U b hb o hR hσ S X poly hmem N hN + hW hτ hξ q cells hmass bases hbases hZpos kernelLaw selection Mk + (physicalCubeSiteTest test) (physicalCubeSiteTest_norm_le test htest) + (fun x hx base => cover ⟨x, hx⟩ base) (Real.exp_pos _).le + (fun x hx base _ => hpoint ⟨x, hx⟩ base) hbad + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +universe uG uI uB uJ uQ uX + +attribute [local instance 2000] fullBooleanRowSetFintype activeAmbientAxisDecidableEq + +variable {m dim : ℕ} {G : Type uG} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type uI} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type uB) +variable [∀ a, Fintype (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "jetRows" => (fun j : Fin m => (Subtype.val : jets j → Finset (Fin dim))) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin dim) (Fin.val j + 1)) +local notation "fullRows" => (fun j => (Subtype.val : rowSets j → Finset (Fin dim))) + +def AllocatedProductNormalizedKernelData (Psp E e pNum Pbase Qraw pAccuracy pSampling : ℝ) (hP : 0 ≤ Psp) + (δ : ℝ≥0) (A Kraw Ksite : ℕ) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) : Prop := + let w := allocatedSiteKernelMaskLog m Psp + let v := allocatedIdealProfileLog m pAccuracy e + let Pfinal := sourceCoverParameter dim Kraw Psp pNum Qraw + (allocatedSiteErrorFourierOutput m pSampling w v) + (allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 1)) + ∀ {Mk : ℕ} (hMk : 0 < Mk) (selection : Fin dim ↪ G) + (_hqDim : dim ≤ m + 1) (hMkPsp : (Mk : ℝ) ≤ Real.exp Psp), + let Kernel := G → IntegerScalarCubeBox (Fin dim) S.value + let Good := GoodScalarKernelTuple (L := S.value) selection (1 / (Mk : ℝ)) Mk + let GoodKernel := {x : Kernel // Good x} + ∃ (d : GoodKernel → ℕ) (hd : ∀ x, 0 < d x), + let : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + (∀ x, (d x : ℝ) ≤ Real.exp ((Pbase + A) ^ A)) ∧ + ∃ (modulus : GoodKernel → ℕ) (hmodulus : ∀ x, 0 < modulus x), + let : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + ∃ hmodulusSize : ∀ x, modulus x ≤ Mk ^ (m + 1), + (∀ (x : GoodKernel) (root : G → ℤ), integerScalarLattice (Unit ⊕ Fin dim) (modulus x : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x.val) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x.val) selection)) ∧ + (∀ (x : GoodKernel) j, integerScalarLattice (jets j) (modulus x : ℤ) ≤ + (scalarKernelIntegerJet x.val (j.val + 1) (jetRows j)).mulVecLin.range) ∧ + ∀ (_block : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, jets a.val.1 ↪ B a.val) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (SiteTorus (Finset (Fin dim)) U)] [BorelSpace (SiteTorus (Finset (Fin dim)) U)] + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {Kcov : Fin m → Type uQ} [∀ j, Fintype (Kcov j)] + (bW : ∀ j, Basis (Kcov j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (_hCp : ∀ j, (C j : ℝ) ≤ Real.exp pNum) (_hVp : ∀ j, (V j : ℝ) ≤ Real.exp pNum) + (_hCpAccuracy : ∀ j, (C j : ℝ) ≤ Real.exp pAccuracy) + (_hVpAccuracy : ∀ j, (V j : ℝ) ≤ Real.exp pAccuracy) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, R j ≤ allocatedPhysicalChartRadius (G := G) B (Fin dim) Cinv 1 j) + (_hσ1 : ∀ j, σ j ≤ 1) + (_hproductSmall : ∀ j, R j ≤ allocatedProductGridRadius (G := G) B rowSets Cinv j) + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + [CompactSpace (CoefficientTorus (K := Fin dim) U)] + [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] [BorelSpace (CoefficientTorus (K := Fin dim) U)] + (μsmall : Measure (CoefficientTorus (K := Fin dim) U)) [μsmall.IsAddLeftInvariant] [IsProbabilityMeasure μsmall] + {X : Type uX} [Fintype X] [DecidableEq X] + (hXPsp : (Fintype.card X : ℝ) ≤ Psp) + (q : X → ℕ) (hq : ∀ t, 0 < q t) (hqPsp : ∀ t, (q t : ℝ) ≤ Real.exp Psp), + let refined := fun x => residueRefinedPeriod (modulus x) q + let index := fun x => allocatedRefinedPeriodIndex m hP hMkPsp + (hmodulusSize x) + hXPsp (hmodulus x) q hq hqPsp + let : ∀ x, NeZero (refined x) := fun x => ⟨(residueRefinedPeriod_pos (hmodulus x) q hq).ne'⟩ + let W := allocatedPhysicalRootBudget B U b S (fun _ => 0) + let hW := allocatedPhysicalRootBudget_nonneg B U b S (fun _ => 0) + let indices := PrincipalTupleIndex B (layerSamplerDegree I n) + let ξ := normalizedTupleNarrowWidth X indices selection Mk Psp ((E + 1) + 2) + let hξ := normalizedTupleNarrowWidth_pos X indices selection Mk Psp ((E + 1) + 2) + let sourceMesh := normalizedTupleRadius X selection Mk Psp ((E + 1) + 2) W / 4 + let mesh := min sourceMesh (allocatedOriginalCoverMesh m Psp pAccuracy w v (E + 1)) + ∀ {τ : ℝ} (hτ : 0 < τ) (_hτP : 1 / τ ≤ Real.exp pNum) + (N : X → ℕ) (hN : ∀ t, 0 < N t) + (_hsize : ∀ t, Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ (N t : ℝ)) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + {rank : ℝ} + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun t => (N t : ℝ)) rank (U j) (poly j)) + (_hRank : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ rank) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) + (_hcells : cells.Nonempty) + (test : Finset (Fin dim) → (X → ℝ) → ℂ) (_htest : ∀ site v, ‖test site v‖ ≤ 1) + (bases : Finset (X → ℤ)) (_hbases : bases.Nonempty), + let V₀ := narrowTrimmedSpatialWidths (G := G) (J := indices) W τ ξ N + let Z := selectedJointDensityMass bases q cells V₀ + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem) + let H := trimmedSpatialRootScale τ N q + let law := principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + let coverValue := fun (x : GoodKernel) input r => + allocatedProductFullGridResidueProfile B U b hR hσ S (refined x) x.val hb o bW (d x) + (witnesses (index x)) δ r (physicalCubeRowSample (O := fun j => (rowSets j : Type)) + U (d x) fullRows poly hmem input) + let wholeReference := fun x => allocatedSupportedWholeReference (dim := dim) B U b S (refined x) + let reconstruct := fun (x : GoodKernel) base => + allocatedWholeResidueReconstruction B U b S X (modulus x) q (wholeReference x) x.val base + let weight := fun (x : GoodKernel) base => + allocatedRecenteredResidueWeight (τ := τ) B U b S X (modulus x) q (wholeReference x) x.val hMk selection x.property + N hW mesh base cells (physicalCubeSiteTest test) + let cover := fun (x : GoodKernel) base => + (law.fiberLaw (principalResidueLabel (refined x))).complexMean (fun r => + ∑ a : cells, (selectedResidueCellWeight q cells V₀ a : ℂ) * + ∑ z ∈ spatialWindow H 4, weight x base r a z * coverValue x (reconstruct x base r a.val z) r) / (Z : ℂ) + ∃ hmass : 0 < ∑' z, selectedResidueSmoothWeight q cells V₀ z, + (|Z - 1| ≤ Real.exp (-Qraw) ∧ Z ∈ Set.Icc (1 / 2 : ℝ) (3 / 2) ∧ 0 < Z ∧ Z⁻¹ ≤ 2) ∧ + ∀ (kernelLaw : FiniteProbabilityWeights Kernel) {η : ℝ}, + kernelLaw.eventProbability (fun x => ¬Good x) ≤ η → + ‖kernelLaw.complexMean (fun x => 𝔼 base ∈ bases, + allocatedOriginalTupleSource B U b hR hσ S x X q hb o N hN hW hτ hξ base cells hmass + (physicalCubeSiteTest test) Z poly hmem) - + kernelLaw.goodPartBaseMean bases Good (fun x hx base => cover ⟨x, hx⟩ base)‖ ≤ Real.exp (-E) + η + +theorem allocatedProductKernelData_normalized + {Psp E e pNum Pbase pAccuracy pSampling l F : ℝ} (hP : 0 ≤ Psp) (hE : 0 ≤ E) + (hPbase : Psp ≤ Pbase) (hpNum : pNum ≤ Pbase) + (hm : ((m + 1 : ℕ) : ℝ) ≤ Psp) (hdim : ((dim + 1 : ℕ) : ℝ) ≤ Psp) + (hG : (Fintype.card G : ℝ) ≤ Psp) (hl : Pbase ≤ l) (hF : 0 ≤ F) + (hnum : ∀ (_o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (C V : Fin m → ℝ≥0), (∀ j, (C j : ℝ) ≤ Real.exp pNum) → + (∀ j, (V j : ℝ) ≤ Real.exp pNum) → AllocatedSourceNumerics B U b S C V Pbase) + {δ : ℝ≥0} {A Kraw Ksite Knorm : ℕ} + (hKraw : 1 ≤ Kraw) (hKsite : 1 ≤ Ksite) (hKnorm : 1 ≤ Knorm) + (hnorm : AllocatedSourceNarrowNormalization.{uG,uI,uB,uJ,uX} m Knorm) + (witnesses : (q : AllocatedRefinedPeriodIndex m Psp) → + (r : AllocatedPositiveResidue (dim := dim) B U b S (q.val : ℕ)) → + AllocatedFullGridResidueWitness (dim := dim) B U b S (q.val : ℕ) r.val) : + let Qraw := allocatedSourceSamplingBudget m dim A Pbase (E + 1) l F + AllocatedProductKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw Ksite witnesses → + AllocatedProductNormalizedKernelData.{uG,uI,uB,uJ,uQ,uX} + B U b hR hσ S Psp E e pNum Pbase Qraw pAccuracy pSampling hP δ A Kraw (max Ksite Knorm) witnesses := by + intro Qraw hKernel + have hPbase0 : 0 ≤ Pbase := hP.trans hPbase + have hEsource : 0 ≤ E + 1 := by linarith + have hQraw1 : 1 ≤ Qraw := + (allocatedSourceSamplingBudget_bounds m dim A hPbase0 hEsource (hPbase0.trans hl) hF).1 + have hQraw0 : 0 ≤ Qraw := zero_le_one.trans hQraw1 + unfold AllocatedProductNormalizedKernelData + intro w v Pfinal Mk hMk selection hqDim hMkPsp Kernel Good GoodKernel + have hFinal := sourceCoverParameter_bounds dim Kraw (pNum := pNum) (Qraw := Qraw) + (F := allocatedSiteErrorFourierOutput m pSampling w v) + (G := allocatedSeparatedGeometryLog m Psp pAccuracy pSampling w v (E + 1)) hP + have hFinal0 : 0 ≤ Pfinal := zero_le_one.trans hFinal.1 + have hRawPower : Qraw ≤ (Qraw + Kraw) ^ Kraw := by + have h := shifted_power_self_mono hQraw0 (le_refl 1) hKraw + simp only [Nat.cast_one, pow_one] at h + linarith + have hRawFinal : Qraw ≤ Pfinal := hRawPower.trans hFinal.2.2.2.2.1 + have hOldCut : Real.exp ((Pfinal + Ksite) ^ Ksite) ≤ + Real.exp ((Pfinal + (max Ksite Knorm : ℕ)) ^ max Ksite Knorm) := + Real.exp_le_exp.mpr (shifted_power_self_mono hFinal0 hKsite (le_max_left _ _)) + have hNormCut : Real.exp ((Qraw + Knorm) ^ Knorm) ≤ + Real.exp ((Pfinal + (max Ksite Knorm : ℕ)) ^ max Ksite Knorm) := by + apply Real.exp_le_exp.mpr + exact (pow_le_pow_left₀ (add_nonneg hQraw0 (Nat.cast_nonneg _)) + (add_le_add hRawFinal le_rfl) Knorm).trans + (shifted_power_self_mono hFinal0 hKnorm (le_max_right _ _)) + obtain ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, hKernel⟩ := + hKernel hMk selection hqDim hMkPsp + let _ : ∀ x, NeZero (d x) := fun x => ⟨(hd x).ne'⟩ + let _ : ∀ x, NeZero (modulus x) := fun x => ⟨(hmodulus x).ne'⟩ + refine ⟨d, hd, hdb, modulus, hmodulus, hmodulusSize, hspatial, hcoefficient, ?_⟩ + intro block _ _ _ _ _ _ hb o Kcov _ bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy Cinv hCinv hchart hsmall + hσ1 hproductSmall μ _ _ ν _ _ _ _ _ μsmall _ _ X _ _ hXPsp q hq hqPsp refined index _ + W hW indices ξ hξ sourceMesh mesh τ hτ hτP N hN hsizeN poly hpoly hmem + rank hrank hRank cells hcells test htest bases hbases V₀ Z H law + coverValue wholeReference reconstruct weight cover + obtain ⟨_, hnormal⟩ := hnorm B U b S hb o μ ν hR hσ hσ1 C V hC hV Cinv hCinv hchart + hsmall A (hnum o C V hCp hVp) hP hEsource hPbase hm hdim hG hl hF + hXPsp selection hMk hMkPsp q hq hqPsp hτ (hτP.trans (Real.exp_le_exp.mpr hpNum)) + N (fun t => hNormCut.trans (hsizeN t)) poly hpoly hmem hrank (hNormCut.trans hRank) cells hcells + have hZ := hnormal bases hbases + obtain ⟨hmass, hcomparison⟩ := hKernel block hb o bW C V hC hV hCp hVp hCpAccuracy hVpAccuracy + Cinv hCinv hchart hsmall hσ1 hproductSmall μ ν μsmall hXPsp q hq hqPsp hτ hτP N hN + (fun t => hOldCut.trans (hsizeN t)) poly hpoly hmem hrank (hOldCut.trans hRank) + cells hcells test htest bases hbases hZ.2.1.1 + exact ⟨hmass, hZ, hcomparison⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedRecenteredRankL1Source.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedRecenteredRankL1Source.lean new file mode 100644 index 0000000000000000000000000000000000000000..3158f213c92a4f0d42d4e31518aadffc22b27e54 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedRecenteredRankL1Source.lean @@ -0,0 +1,228 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedRecenteredL1Source +import OAI.Combinatorics.Progressions.Estimates.PhysicalL1SourceAccuracy + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +universe uX uJ uO + +open BooleanCubeKernel MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type uJ} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "sides" => allocatedPrincipalSides B U b S +local notation "fullTuple" => PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) sides + +variable (X : Type uX) [Fintype X] [DecidableEq X] (modulus : ℕ) (q : X → ℕ) +variable (wholeReference : + (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod (residueRefinedPeriod modulus q)) → + PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin dim) (allocatedPrincipalSides B U b S)) + +local notation "refined" => residueRefinedPeriod modulus q +local notation "labels" => (PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod refined) + +variable (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable [NeZero modulus] {M : ℕ} (hM : 0 < M) (selection : Fin dim ↪ G) +variable (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) +variable (N : X → ℕ) {W τ ξ : ℝ} (hW : 0 ≤ W) (mesh : ℝ) (base : X → ℤ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X q)) +variable {O : Fin m → Type uO} [∀ j, Fintype (O j)] +variable (rows : ∀ j, O j → Finset (Fin dim)) +variable (hinj : ∀ j, Function.Injective (rows j)) (hcard : ∀ j a, (rows j a).card ≤ j.val + 1) +variable (cover : ℕ) (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) +variable (hm : ∀ j ex, coefficients (poly j) ex ∈ U j) +local notation "point" => physicalCubeRowSample U cover rows poly hm +variable (test : (X → (Unit ⊕ Fin dim) → ℤ) → ℂ) + +local notation "window" => spatialWindow (α := Fin dim) (trimmedSpatialRootScale τ N q) 4 + +variable [CompactSpace (CoefficientTorus (K := Fin dim) U)] +variable [MeasurableSpace (CoefficientTorus (K := Fin dim) U)] +variable [BorelSpace (CoefficientTorus (K := Fin dim) U)] +variable (μ : Measure (CoefficientTorus (K := Fin dim) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] +local notation "jetHaar" => Measure.pi (fun j => Measure.pi (fun _ : O j => ν j)) +include hinj hcard hp μ in +theorem allocatedRecenteredSelectedMean_rank_l1_source + (law : FiniteProbabilityWeights fullTuple) (r : labels) + (hlabel : ∀ y, law.weight y ≠ 0 → principalResidueLabel refined y = r) + (hwhole : principalResidueLabel refined (wholeReference r) = r) + (profile : fullTuple → EuclideanJetLayers U O → ℂ) + (ideal model : EuclideanJetLayers U O → ℂ) + (hq : ∀ t, 0 < q t) (hN : ∀ t, 0 < N t) (hτ : 0 < τ) + (hbudget : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W) (hmesh : 0 < mesh) + (hperiod : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection)) + (htest : ∀ w, ‖test w‖ ≤ 1) {κ δ ε : ℝ} + (hsource : κ ≤ (law.complexMean (allocatedRecenteredProfileTerm (τ := τ) (ξ := ξ) + B U b S X modulus q wholeReference x hM selection hx N hW mesh base cells point test profile)).re) + (f g : (JetAmbientIndex O J → UnitAddCircle) → ℂ) + (Lf Lg Cf Cg : ℝ≥0) (hf : LipschitzWith Lf f) (hg : LipschitzWith Lg g) + (hfb : ∀ z, ‖f z‖ ≤ Cf) (hgb : ∀ z, ‖g z‖ ≤ Cg) + (hactual : ∀ y, law.complexMean (fun a => profile a y) = f (coveredJetAmbientTorus U 1 y)) + (hi : Measurable ideal) {P Rrank S₀ η εsample δsur Eerror : ℝ} + (hP : 0 ≤ P) (hX : (Fintype.card X : ℝ) ≤ P) + (hframe : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P) + (hcover : 0 < cover) (hcoverP : (cover : ℝ) ≤ Real.exp P) + (hS₀ : 0 ≤ S₀) (hS₀P : S₀ ≤ Real.exp P) (hstride : ∀ i, (q i : ℝ) ≤ S₀) + (hτP : 1 / τ ≤ Real.exp P) (hεsample : 0 < εsample) (hεsampleP : 1 / εsample ≤ Real.exp P) + (hsize : ∀ i, Real.exp ((P + (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ^ (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ≤ (N i : ℝ)) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun i => (N i : ℝ)) Rrank (U j) (poly j)) + (hRrank : Real.exp ((P + (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ^ (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ≤ Rrank) + (hη : 0 < η) (hamb : (Fintype.card (CoefficientAmbientIndex (Fin dim) J) : ℝ) ≤ P) + (hLf : (Lf : ℝ) ≤ Real.exp P) (hLg : (Lg : ℝ) ≤ Real.exp P) + (hCf : (Cf : ℝ) ≤ Real.exp P) (hCg : (Cg : ℝ) ≤ Real.exp P) + (hjet : ((∑ j : Fin m, (Fintype.card (BoundedCoefficientExponent (Fin dim) (j.val + 1)) : ℝ≥0) : ℝ≥0) : ℝ) ≤ Real.exp P) + (hηP : η⁻¹ ≤ Real.exp P) + (happrox : ∀ y, ‖ideal y - g (coveredJetAmbientTorus U 1 y)‖ ≤ δsur) + (hmass : (∫ y, ‖f (coveredJetAmbientTorus U 1 y) - ideal y‖ ∂jetHaar) ≤ Eerror) + (hε : 0 ≤ ε) (htrunc : ∀ z, ‖ideal z - model z‖ ≤ ε) : + let root := allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (wholeReference r) + let D := allocatedPhysicalCubeDirections B U b S x (wholeReference r) + let H := trimmedSpatialRootScale τ N q + let T := trimmedSpatialSlopeScale W τ N q + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + let _V₁ := referenceJetEnvelopeWidths (q := dim) q H + let _A := (∏ t, ∏ i, physicalSpatialOutputScale (Fin dim) (H t) (T t) S.value i : ℝ) + let C := ((modulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (M : ℝ))) ^ Fintype.card X + let volumeFactor := (30 / smoothProbabilityProfile 0) ^ Fintype.card (Option (Fin dim) × X) * + (((1 + W) / S.value) ^ dim) ^ Fintype.card X + (∀ z, 0 < V z) → (0 < ∑' z, selectedResidueSmoothWeight q cells V z) → + (∀ t i, (∑ k, |(physicalCubeCoefficient root D i k : ℝ)|) ≤ H t) → + (∀ t, 8 * (probabilityProfileLipschitz : ℝ) ≤ 20 * H t) → + (∀ t, 1 ≤ H t) → + C * (volumeFactor * (Eerror + 2 * δsur + (2 * η + εsample)) + ((9 : ℝ) ^ Fintype.card (X × (Unit ⊕ Fin dim)) * + (((1 + W) / S.value) ^ dim) ^ Fintype.card X) * ε) ≤ δ → + κ - δ ≤ + (∑ t : cells × window, (selectedResidueCellWeight q cells V t.1 : ℂ) * + allocatedRecenteredResidueWeight (τ := τ) B U b S X modulus q wholeReference x hM selection hx + N hW mesh base cells test r t.1 t.2.val * + model (point (allocatedWholeResidueReconstruction B U b S X modulus q wholeReference x base r + t.1.val t.2.val))).re := by + intro root D H T V V₁ A C volumeFactor hV hZ hrowsize hprofile hH1 hcost + apply allocatedRecenteredSelectedMean_l1_source B U b S X modulus q wholeReference + x hM selection hx N hW mesh base cells point test law r hlabel hwhole profile ideal model + hq hN hτ hbudget hmesh hperiod htest hsource hε htrunc hV hZ hrowsize hprofile hH1 ?_ hcost + intro a + let target := columnResiduePattern q (standardPhysicalCubeFrame + (physicalCubeRootDifferences root D 0 (boundedColumnResidueRepresentative q a.val))) + have hwidth (z : Option (Fin dim) × X) : τ * (N z.2 : ℝ) ≤ V₁ z := by + change τ * (N z.2 : ℝ) ≤ referenceJetEnvelopeWidths q (trimmedSpatialRootScale τ N q) z + rw [referenceJetEnvelopeWidths_trimmed q N hq τ z] + nlinarith [mul_pos hτ (Nat.cast_pos.mpr (hN z.2))] + have hV₁ (z : Option (Fin dim) × X) : 0 < V₁ z := by + exact (mul_pos hτ (Nat.cast_pos.mpr (hN z.2))).trans_le (hwidth z) + have hsample := (Classical.choose_spec (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim)).2 + (I := X) (J := J) (O := O) + obtain ⟨hZa, he⟩ := hsample rows hinj hcard hP hX hframe U μ ν base poly hp hm cover hcover hcoverP + q hq hS₀ hS₀P hτ hεsample hτP hεsampleP hstride (fun i => (N i : ℝ)) hsize hrank hRrank + {target} (Finset.singleton_nonempty _) V₁ hV₁ hwidth f g Lf Lg Cf Cg hf hg hfb hgb + hη hamb hLf hLg hCf hCg hjet hηP ideal hi happrox hmass + refine ⟨hZa, ?_⟩ + simpa only [hactual] using he + +include hinj hcard hp μ in +theorem allocatedRecenteredSelectedMean_rank_l1_source_exp + (law : FiniteProbabilityWeights fullTuple) (r : labels) + (hlabel : ∀ y, law.weight y ≠ 0 → principalResidueLabel refined y = r) + (hwhole : principalResidueLabel refined (wholeReference r) = r) + (profile : fullTuple → EuclideanJetLayers U O → ℂ) + (ideal model : EuclideanJetLayers U O → ℂ) + (hq : ∀ t, 0 < q t) (hN : ∀ t, 0 < N t) (hτ : 0 < τ) + (hbudget : allocatedPhysicalRootBudget B U b S (fun _ => 0) ≤ W) (hmesh : 0 < mesh) + (hperiod : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) + (scalarCubeDifferenceMatrix x) selection)) + (htest : ∀ w, ‖test w‖ ≤ 1) {κ ε : ℝ} + (hsource : κ ≤ (law.complexMean (allocatedRecenteredProfileTerm (τ := τ) (ξ := ξ) + B U b S X modulus q wholeReference x hM selection hx N hW mesh base cells point test profile)).re) + (f g : (JetAmbientIndex O J → UnitAddCircle) → ℂ) + (Lf Lg Cf Cg : ℝ≥0) (hf : LipschitzWith Lf f) (hg : LipschitzWith Lg g) + (hfb : ∀ z, ‖f z‖ ≤ Cf) (hgb : ∀ z, ‖g z‖ ≤ Cg) + (hactual : ∀ y, law.complexMean (fun a => profile a y) = f (coveredJetAmbientTorus U 1 y)) + (hi : Measurable ideal) {P Rrank S₀ η εsample δsur Eerror : ℝ} + (hP : 0 ≤ P) (hX : (Fintype.card X : ℝ) ≤ P) + (hframe : (Fintype.card (Option (Fin dim) × X) : ℝ) ≤ P) + (hcover : 0 < cover) (hcoverP : (cover : ℝ) ≤ Real.exp P) + (hS₀ : 0 ≤ S₀) (hS₀P : S₀ ≤ Real.exp P) (hstride : ∀ i, (q i : ℝ) ≤ S₀) + (hτP : 1 / τ ≤ Real.exp P) (hεsample : 0 < εsample) (hεsampleP : 1 / εsample ≤ Real.exp P) + (hsize : ∀ i, Real.exp ((P + (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ^ (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ≤ (N i : ℝ)) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun i => (N i : ℝ)) Rrank (U j) (poly j)) + (hRrank : Real.exp ((P + (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ^ (Classical.choose (exists_translated_physical_jet_l1_perturbation.{uX,uJ,uO} m dim))) ≤ Rrank) + (hη : 0 < η) (hamb : (Fintype.card (CoefficientAmbientIndex (Fin dim) J) : ℝ) ≤ P) + (hLf : (Lf : ℝ) ≤ Real.exp P) (hLg : (Lg : ℝ) ≤ Real.exp P) + (hCf : (Cf : ℝ) ≤ Real.exp P) (hCg : (Cg : ℝ) ≤ Real.exp P) + (hjet : ((∑ j : Fin m, (Fintype.card (BoundedCoefficientExponent (Fin dim) (j.val + 1)) : ℝ≥0) : ℝ≥0) : ℝ) ≤ Real.exp P) + (hηP : η⁻¹ ≤ Real.exp P) + (happrox : ∀ y, ‖ideal y - g (coveredJetAmbientTorus U 1 y)‖ ≤ δsur) + (hmass : (∫ y, ‖f (coveredJetAmbientTorus U 1 y) - ideal y‖ ∂jetHaar) ≤ Eerror) + (hε : 0 ≤ ε) (htrunc : ∀ z, ‖ideal z - model z‖ ≤ ε) + {Pgeom Dgeom target : ℝ} (hPgeom : 0 ≤ Pgeom) + (hMP : (M : ℝ) ≤ Real.exp Pgeom) + (hperiodP : (modulus : ℝ) ≤ Real.exp (Pgeom ^ 2)) + (hdimP : ((dim + 1 : ℕ) : ℝ) ≤ Pgeom) (hGP : (Fintype.card G : ℝ) ≤ Pgeom) + (hXP : (Fintype.card X : ℝ) ≤ Pgeom) + (hDP : Dgeom ≤ Real.exp Pgeom) (hWL : W ≤ Dgeom * S.value) + (hEaccuracy : Eerror ≤ l1SourceAccuracy target (coefficientErrorSpatialLog Pgeom) 0) + (hδaccuracy : δsur ≤ l1SourceAccuracy target (coefficientErrorSpatialLog Pgeom) 0) + (hηaccuracy : η ≤ l1SourceAccuracy target (coefficientErrorSpatialLog Pgeom) 0) + (hsampleAccuracy : εsample ≤ l1SourceAccuracy target (coefficientErrorSpatialLog Pgeom) 0) + (htruncAccuracy : ε ≤ l1SourceAccuracy target (coefficientErrorSpatialLog Pgeom) 0) : + let root := allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (wholeReference r) + let D := allocatedPhysicalCubeDirections B U b S x (wholeReference r) + let H := trimmedSpatialRootScale τ N q + let T := trimmedSpatialSlopeScale W τ N q + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + let _V₁ := referenceJetEnvelopeWidths (q := dim) q H + let _A := (∏ t, ∏ i, physicalSpatialOutputScale (Fin dim) (H t) (T t) S.value i : ℝ) + let _C := ((modulus : ℝ) ^ Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (M : ℝ))) ^ Fintype.card X + let _volumeFactor := (30 / smoothProbabilityProfile 0) ^ Fintype.card (Option (Fin dim) × X) * + (((1 + W) / S.value) ^ dim) ^ Fintype.card X + (∀ z, 0 < V z) → (0 < ∑' z, selectedResidueSmoothWeight q cells V z) → + (∀ t i, (∑ k, |(physicalCubeCoefficient root D i k : ℝ)|) ≤ H t) → + (∀ t, 8 * (probabilityProfileLipschitz : ℝ) ≤ 20 * H t) → + (∀ t, 1 ≤ H t) → + κ - Real.exp (-target) ≤ + (∑ t : cells × window, (selectedResidueCellWeight q cells V t.1 : ℂ) * + allocatedRecenteredResidueWeight (τ := τ) B U b S X modulus q wholeReference x hM selection hx + N hW mesh base cells test r t.1 t.2.val * + model (point (allocatedWholeResidueReconstruction B U b S X modulus q wholeReference x base r + t.1.val t.2.val))).re := by + intro root D H T V V₁ A C volumeFactor hV hZ hrowsize hprofile hH1 + apply allocatedRecenteredSelectedMean_rank_l1_source B U b S X modulus q wholeReference + x hM selection hx N hW mesh base cells rows hinj hcard cover poly hp hm test μ ν + law r hlabel hwhole profile ideal model hq hN hτ hbudget hmesh hperiod htest hsource + f g Lf Lg Cf Cg hf hg hfb hgb hactual hi hP hX hframe hcover hcoverP + hS₀ hS₀P hstride hτP hεsample hεsampleP hsize hrank hRrank hη hamb hLf hLg hCf hCg + hjet hηP happrox hmass hε htrunc hV hZ hrowsize hprofile hH1 + exact physicalL1Source_error_le_exp dim X selection hPgeom hM hMP hperiodP hdimP hGP hXP + (Nat.one_le_cast.mpr S.positive) hW hDP hWL + hEaccuracy hδaccuracy hηaccuracy hsampleAccuracy htruncAccuracy + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedRefinedKernelComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedRefinedKernelComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..1606f5748735a1411754eb5bf360ccea3762e216 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedRefinedKernelComparison.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedDensityParameterBounds +import OAI.Combinatorics.Progressions.Sampling.PrincipalGridMixture + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory +open scoped BigOperators Matrix NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U basis R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, DecidableEq (O j)] +variable [∀ j : Fin m, DecidableEq (BoundedIntegerExponent G (j.val+1))] +variable [∀ j : Fin m, DecidableEq (AllocatedNonkernelCoefficient (G := G) B j)] +variable (rows : ∀ j, O j → Finset α) + +local notation "grid" => allocatedGridAxis (I := I) U basis (LayerSamplerScale.value S) +local notation "sides" => allocatedPrincipalSides B U basis S +local notation "lengths" => principalAxisLength (fun a => ¬grid a) sides + +theorem allocatedGoodKernel_refined_principal_comparison {M : ℕ} (hM : 0 < M) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection (1/(M : ℝ)) M x) + (hq : Fintype.card α ≤ m+1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j o, (rows j o).card ≤ j.val+1) (hσ1 : ∀ j, σ j ≤ 1) + {P e ε : ℝ} (hP : 0 ≤ P) (he : 0 ≤ e) (hε : 0 < ε) + (hMP : (M : ℝ) ≤ Real.exp P) (hRP : ∀ j, R j ≤ Real.exp P) + (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσi : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ)+1 ≤ Real.exp P) + (hεe : ε⁻¹ ≤ Real.exp e) + (hlarge : Real.exp (allocatedKernelReplacementLog (G := G) B α O P e) ≤ S.value) : + let C : ℝ≥0 := ⟨Real.exp (allocatedDensityLog (G := G) B α O P), (Real.exp_pos _).le⟩ + let W : ℝ := layerKernelIndexBound m M + ∃ (modulus : ℕ) (_hm : 0 < modulus), modulus ≤ M^(m+1) ∧ + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ α) (modulus : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ j, integerScalarLattice (O j) (modulus : ℤ) ≤ + (scalarKernelIntegerJet x (j.val+1) (rows j)).mulVecLin.range) ∧ + ∃ (s : ∀ j, O j ↪ BoundedIntegerExponent G (j.val+1)) + (hA : ∀ j, ((scalarKernelIntegerJet x (j.val+1) (rows j)).submatrix id (s j)).det ≠ 0), + (∀ j : Fin m, fixedKernelInverseBound S.positive x (j.val+1) (rows j) (s j) (hA j) (1/(M : ℝ))) ∧ + ∀ (refined : ℕ) (hRefined : 0 < refined), modulus ∣ refined → + ∀ (u : PrincipalAxisTuples (α := α) grid sides) + (r : PrincipalTupleIndex (fun a : {a // ¬grid a} => B a.val) + (fun a => layerSamplerDegree I n a.val) → Option α → ZMod refined) + (hsize : ∀ d, (Fintype.card α+1)*refined ≤ lengths d), + (∀ d, scalarCubeGridBoundaryConstant α * ((refined : ℝ)/lengths d) < + volume.real (scalarCubeDomain α)) → + ∃ residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus), + (∀ v, (allocatedLongResidueWeights B U basis S refined hRefined r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j) ∧ + ∀ z : AllocatedLongJetRows B U basis S O, + |(allocatedLongResidueWeights B U basis S refined hRefined r hsize).mean + (fun v => (∏ a, allocatedLongJetOutputScale B U basis S (O := O) a) * + allocatedLongJetDensity B U basis hR hσ S x u v rows s hA hσ1 z) - + (∏ a, allocatedLongJetMask B U basis S x rows modulus residue a (z a)) * + (∫ y, (∏ a, allocatedLongJetTarget B U basis S x u rows s hA y a (z a)) + ∂jointBooleanSource (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val))| ≤ + Fintype.card {a // ¬grid a} * ε * (1+W*C+ε)^Fintype.card {a // ¬grid a} + + W^Fintype.card {a // ¬grid a} * jointTupleQuadratureError (α := α) + (fun a : {a // ¬grid a} => B a.val) (fun a : {a // ¬grid a} => layerSamplerDegree I n a.val) + (Fintype.card {a // ¬grid a}) C C lengths refined := by + dsimp only + obtain ⟨modulus, hm, hmB, hspatial, hperiod, s, hA, hi, herr⟩ := + allocatedGoodKernel_replacement B U basis hR hσ S x rows hM selection hx hq hinj hrows hσ1 + hP he hε hMP hRP hRi hσi hcount hεe hlarge + refine ⟨modulus, hm, hmB, hspatial, hperiod, s, hA, hi, ?_⟩ + intro refined hRefined hdiv u r hsize hsmall + let residue := fun j => integerResidueMatrix + (integerMappedJetMatrix (allocatedNonkernelExponent B j) + (partitionedPrincipalInput grid (fun g a => (g, a))) + (Sum.elim (fun ga : G × Option α => (x ga.1 ga.2 : ℤ)) (principalTupleIntegers u)) + (rows j) (principalResidueLift refined r)) modulus + have hr : ∀ v, (allocatedLongResidueWeights B U basis S refined hRefined r hsize).weight v ≠ 0 → ∀ j, + integerResidueMatrix (allocatedNonkernelJetMatrix B U basis S x u rows j v) modulus = residue j := by + intro v hv j + apply integerResidueMatrix_reduce _ _ hdiv + exact allocatedLongResidueWeights_matrix B U basis S refined hRefined r hsize x u rows + (principalResidueLift refined r) (principalResidueLift_spec refined r) j v hv + have herror := herr u (allocatedLongResidueWeights B U basis S refined hRefined r hsize) residue hr + obtain ⟨hC, hcap, hLip⟩ := allocatedLongJetTarget_exp_bounds B U basis hR hσ S x rows s hA + hM hi hP hMP hRP hRi hσi hcount u hσ1 + have hW : (1 : ℝ) ≤ layerKernelIndexBound m M := by + exact_mod_cast Nat.succ_le_of_lt (show 0 < layerKernelIndexBound m M from pow_pos hM _) + refine ⟨residue, hr, ?_⟩ + intro z + exact allocatedLongJet_refined_principal_comparison B U basis hR hσ S refined hRefined r hsize x u rows s hA hσ1 + modulus residue hsmall _ _ hC hW hε.le hcap hLip + (fun j i hj => (herror j i hj).1) (fun v hv j i hj z => (herror j i hj).2 v hv z) z + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedShortRankWitnessWidth.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedShortRankWitnessWidth.lean new file mode 100644 index 0000000000000000000000000000000000000000..14c79bd18bbad579b046c8d668b2bcd0fddbc9f6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedShortRankWitnessWidth.lean @@ -0,0 +1,771 @@ +import OAI.Combinatorics.Progressions.Dynamics.PhysicalBadProductErrorBudget +import OAI.Combinatorics.Progressions.Geometry.AllocatedSpatialWitnessComparison +import OAI.Combinatorics.Progressions.Lattices.AllocatedModularRankAffineFullWitness +import OAI.Combinatorics.Progressions.Probability.AllocatedSpatialCoefficientReferenceLaw + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open scoped Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} + +def allocatedReadCoefficientChartResidues {M : ℕ} + (f : AllocatedActualCoefficientIndex G X I E n B → ZMod M) : + CoefficientChartResidues (LayerSamplerVariables G I n B) n E M := + fun j q => Sum.elim (fun i => allocatedReadProjection f ⟨j,Sum.inr i⟩ q) + (allocatedReadDeck f j q) + +def allocatedChartActualResidues {M : ℕ} + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod M) + (chart : CoefficientChartResidues (LayerSamplerVariables G I n B) n E M) : + AllocatedActualCoefficientIndex G X I E n B → ZMod M := + allocatedMixedFullArray + (Sum.elim noise (fun ⟨j,q,i⟩ => chart j q (Sum.inl i))) + (fun ⟨j,q,i⟩ => chart j q (Sum.inr i)) (fun _ => 0) + +@[simp] theorem allocatedChartActualResidues_noise {M : ℕ} + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod M) + (chart : CoefficientChartResidues (LayerSamplerVariables G I n B) n E M) : + allocatedReadNoise (allocatedChartActualResidues noise chart) = noise := rfl + +@[simp] theorem allocatedChartActualResidues_deck {M : ℕ} + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod M) + (chart : CoefficientChartResidues (LayerSamplerVariables G I n B) n E M) : + allocatedReadDeck (allocatedChartActualResidues noise chart) = + fun j q i => chart j q (Sum.inr i) := rfl + +@[simp] theorem allocatedChartActualResidues_integer {M : ℕ} + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod M) + (chart : CoefficientChartResidues (LayerSamplerVariables G I n B) n E M) + (j : Fin m) (i : Fin (n j)) : + allocatedReadProjection (allocatedChartActualResidues noise chart) ⟨j,Sum.inr i⟩ = + fun q => chart j q (Sum.inl i) := rfl + +variable [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +def allocatedChartResiduePrimePowerWitness + (inactive : LayerSamplerAxis I n → Prop) (C : ℝ) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (noise : Option (LayerSamplerVariables G I n B) × X → ZMod M) + (chart : CoefficientChartResidues (LayerSamplerVariables G I n B) n E M) : Prop := + allocatedResiduePrimePowerWitness inactive C P A M hdiv + (allocatedChartActualResidues noise chart) + +theorem allocatedChartResiduePrimePowerWitness_read + (inactive : LayerSamplerAxis I n → Prop) (C : ℝ) + (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (f : AllocatedActualCoefficientIndex G X I E n B → ZMod M) : + allocatedChartResiduePrimePowerWitness inactive C P A M hdiv + (allocatedReadNoise f) (allocatedReadCoefficientChartResidues f) = + allocatedResiduePrimePowerWitness inactive C P A M hdiv f := by + unfold allocatedChartResiduePrimePowerWitness + apply allocatedResiduePrimePowerWitness_congr_outputs + · rfl + · rfl + · intro j i + rfl + +theorem allocatedChartResiduePrimePowerWitness_iff_actual + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) : + allocatedChartResiduePrimePowerWitness inactive C P A M hdiv + (allocatedReadNoise (fun i => (f i : ZMod M))) + (allocatedReadCoefficientChartResidues (fun i => (f i : ZMod M))) ↔ + ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) f := by + rw [allocatedChartResiduePrimePowerWitness_read] + exact allocatedResiduePrimePowerWitness_iff_actual inactive spatial kernel block C P A M hdiv f + +omit [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] [∀ a, Fintype (B a)] in + +theorem allocatedReadCoefficientChartResidues_sampler + (M : ℕ) (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (x : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (hinteger : ∀ (j : Fin m) (i : Fin (n j)) + (q : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)), + allocatedReadProjection f ⟨j,Sum.inr i⟩ q = (x j).2 i q) : + allocatedReadCoefficientChartResidues (fun i => (f i : ZMod M)) = + coefficientSamplerChartResidues M x (fun j q i => ((allocatedReadDeck f j q i : ℤ) : ZMod M)) := by + funext j q i + cases i with + | inl i => exact congrArg (fun z : ℤ => (z : ZMod M)) (hinteger j i q) + | inr i => rfl + +theorem allocatedChartResiduePrimePowerWitness_sampler_iff_actual + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (f : AllocatedActualCoefficientIndex G X I E n B → ℤ) + (x : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (hinteger : ∀ (j : Fin m) (i : Fin (n j)) + (q : BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)), + allocatedReadProjection f ⟨j,Sum.inr i⟩ q = (x j).2 i q) : + allocatedChartResiduePrimePowerWitness inactive C P A M hdiv + (fun q => ((allocatedReadNoise f q : ℤ) : ZMod M)) + (coefficientSamplerChartResidues M x (fun j q i => ((allocatedReadDeck f j q i : ℤ) : ZMod M))) ↔ + ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) f := by + rw [← allocatedReadCoefficientChartResidues_sampler M f x hinteger] + exact allocatedChartResiduePrimePowerWitness_iff_actual inactive spatial kernel block C P A M hdiv f + +theorem allocatedChartResiduePrimePowerWitness_mixedArray_iff_actual + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j, b.val⟩) + (C : ℝ) (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (M : ℕ) (hdiv : ∀ p : P, p.val ^ A p.val ∣ M) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (x : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (deck : ∀ j, BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1) → E j → ℤ) + (continuous : AllocatedFullContinuousCoefficientIndex G I n B → ℤ) : + allocatedChartResiduePrimePowerWitness inactive C P A M hdiv + (fun q => (noise q : ZMod M)) + (coefficientSamplerChartResidues M x (fun j q i => (deck j q i : ZMod M))) ↔ + ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray + (Sum.elim noise (fun ⟨j,q,i⟩ => (x j).2 i q)) + (fun ⟨j,q,i⟩ => deck j q i) continuous) := by + exact allocatedChartResiduePrimePowerWitness_sampler_iff_actual + inactive spatial kernel block C P A M hdiv + (allocatedMixedFullArray + (Sum.elim noise (fun ⟨j,q,i⟩ => (x j).2 i q)) + (fun ⟨j,q,i⟩ => deck j q i) continuous) x (fun _ _ _ => rfl) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule MeasureTheory +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} {I E : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} {L : ℕ} +variable [Fintype G] [Fintype X] [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + [∀ a, Fintype (B a)] + +theorem allocatedChartResiduePrimePowerWitness_integerDeck_iff + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,b.val⟩) + (C : ℝ) (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (q : ℕ) [NeZero q] (hdiv : ∀ p : P, p.val ^ A p.val ∣ q) + (noise : Option (LayerSamplerVariables G I n B) × X → ℤ) + (a : CoefficientIntegerScalarIndex (LayerSamplerVariables G I n B) n → ℤ) + (r : CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q) : + allocatedChartResiduePrimePowerWitness inactive C P A q hdiv + (fun v => (noise v : ZMod q)) (coefficientIntegerDeckChartResidues q a r) ↔ + ∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (Sum.elim noise a) + (fun ⟨j,e,i⟩ => ((r j e i).val : ℤ)) (fun _ => 0)) := by + let f := allocatedMixedFullArray (Sum.elim noise a) + (fun ⟨j,e,i⟩ => ((r j e i).val : ℤ)) (fun _ => 0) + have hchart : allocatedReadCoefficientChartResidues (fun i => (f i : ZMod q)) = + coefficientIntegerDeckChartResidues q a r := by + funext j e i + cases i with + | inl i => rfl + | inr i => + change (((r j e i).val : ℤ) : ZMod q) = r j e i + simp only [Int.cast_natCast, ZMod.natCast_zmod_val] + have h := allocatedChartResiduePrimePowerWitness_iff_actual + inactive spatial kernel block C P A q hdiv f + rw [hchart] at h + exact h + +variable (B) {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U b R σ) + +theorem allocatedSpatialRankReferenceLaw + (inactive : LayerSamplerAxis I n → Prop) + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,b.val⟩) + (C : ℝ) (P : Finset ℕ) [∀ p : P, NeZero p.val] (A : ℕ → ℕ) + (q : ℕ) [NeZero q] (hdiv : ∀ p : P, p.val ^ A p.val ∣ q) + (noiseLaw : PMF (Option (LayerSamplerVariables G I n B) × X → ℤ)) : + (∑' z, (noiseLaw z).toReal * + ∫ a : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n × + CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q, + (if allocatedChartResiduePrimePowerWitness inactive C P A q hdiv + (fun v => (z v : ZMod q)) (coefficientSamplerChartResidues q a.1 a.2) + then (1 : ℝ) else 0) + ∂(allocatedCoefficientSource B U b hR hσ S).prod + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q)).toMeasure) = + ((noiseLaw.bind fun z => (allocatedCoefficientIntegerPMF B U b hR hσ S).bind + fun a => (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q)).map + fun r => decide (∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (Sum.elim z a) + (fun ⟨j,e,i⟩ => ((r j e i).val : ℤ)) (fun _ => 0)))) true).toReal := by + have h := allocatedSpatialCoefficientReferenceLaw B U b hR hσ S q noiseLaw + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q)) + (allocatedChartResiduePrimePowerWitness inactive C P A q hdiv) + simpa only [allocatedChartResiduePrimePowerWitness_integerDeck_iff + inactive spatial kernel block C P A q hdiv] using h + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + +noncomputable local instance spatialReferenceSmoothFintype : + Fintype (AllocatedFullSmoothCoefficientIndex G X I n B) := inferInstance +noncomputable local instance spatialReferenceDeckFintype : + Fintype (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := inferInstance +noncomputable local instance spatialReferenceDeckDecidableEq : + DecidableEq (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := Classical.decEq _ + +theorem allocatedSpatialRank_cell_bind_eq + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (residue : Option (LayerSamplerVariables G I n B) × X → ℤ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) (N : ℕ) [NeZero N] + {Y : Type*} + (test : (AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) → + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) → Y) : + ((residueSmoothPMF residue stride hstride V hV hZ).bind fun noise => + (allocatedCoefficientIntegerPMF B U basis hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N)).map + fun deck => test (Sum.elim noise a) (coefficientDeckScalarEquiv deck)) = + ((independentProductPMF (allocatedFullSmoothScalarPMF B U basis hR hσ S + (residueSmoothScalarPMFs residue stride hstride V hV hZ))).bind fun z => + (PMF.uniformOfFintype + (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N)).map + fun deck => test (allocatedFullSmoothAffine (fun x => (stride x : ℤ)) residue z) deck) := by + rw [allocatedFullSmoothProductPMF_factorization, PMF.bind_bind] + simp_rw [PMF.bind_map] + rw [residueSmoothPMF, residueSmoothIndexPMF_eq_independent, PMF.bind_map] + apply congrArg (PMF.bind _) + funext noise + apply congrArg (PMF.bind _) + funext a + simp only [Function.comp_apply] + have haff : Sum.elim (residueLatticeArray residue stride noise) a = + allocatedFullSmoothAffine (fun x => (stride x : ℤ)) residue (Sum.elim noise a) := by + funext t + cases t <;> rfl + rw [haff] + exact coefficientDeckScalar_uniform_test N + (test (allocatedFullSmoothAffine (fun x => (stride x : ℤ)) residue (Sum.elim noise a))) + +noncomputable def allocatedSpatialRankSelectedWidth {L : ℕ} + (spatial : Fin L ↪ G) (stride : X → ℕ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) : + AllocatedSmoothRankCoefficientIndex X (allocatedGridAxis (I := I) U basis S.value) L → ℝ := + allocatedSelectedSmoothWidth B U basis S (allocatedGridAxis (I := I) U basis S.value) + (fun l x => residueProfileWidth stride V (some (.inl (spatial l)),x)) + +theorem allocatedSpatialRank_cell_event {L N D : ℕ} [NeZero N] + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis + (allocatedGridAxis (I := I) U basis S.value) j, Fin L ↪ B ⟨j,b.val⟩) + (hm : 0 < m) (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (residue : Option (LayerSamplerVariables G I n B) × X → ℤ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hdeep : ∀ p ∈ P, ∀ x, 2 * (stride x).factorization p ≤ A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ allocatedSpatialRankSelectedWidth B U basis S spatial stride V j) : + (((residueSmoothPMF residue stride hstride V hV hZ).bind fun noise => + (allocatedCoefficientIntegerPMF B U basis hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N)).map + fun deck => decide (∀ p : P, allocatedActualModulusBad + (allocatedGridAxis (I := I) U basis S.value) spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (Sum.elim noise a) + (fun ⟨j,e,i⟩ => ((deck j e i).val : ℤ)) (fun _ => 0)))) true).toReal ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / + allocatedSpatialRankSelectedWidth B U basis S spatial stride V j := by + let inactive := allocatedGridAxis (I := I) U basis S.value + let noiseCenter : Fin L → X → ℝ := + fun l x => residueProfileCenter residue stride (some (.inl (spatial l)),x) + let noiseWidth : Fin L → X → ℝ := + fun l x => residueProfileWidth stride V (some (.inl (spatial l)),x) + let center := allocatedSelectedSmoothCenter B U basis S inactive noiseCenter + let width := allocatedSelectedSmoothWidth B U basis S inactive noiseWidth + let noisePMF := residueSmoothScalarPMFs residue stride hstride V hV hZ + let laws := allocatedFullSmoothScalarPMF B U basis hR hσ S noisePMF + have hnw : ∀ l x, 0 < noiseWidth l x := + fun l x => residueProfileWidth_pos stride V hstride hV _ + have hnm : ∀ l x, 0 < shiftedSmoothSampleSum (noiseCenter l x) (noiseWidth l x) := + fun l x => shiftedSmoothProductMass_coordinate_pos _ _ + (residueProfileWidth_pos stride V hstride hV) hZ _ + have hactive := allocatedGridPrincipalRank_active B U basis S + have hw : ∀ j, 0 < width j := + allocatedSelectedSmoothWidth_pos B U basis hR S inactive noiseWidth hnw + have hmasses : ∀ j, 0 < shiftedSmoothSampleSum (center j) (width j) := + allocatedSelectedSmoothMass_pos B U basis hR S inactive noiseCenter noiseWidth hnm hactive + have hz : 0 < shiftedSmoothProductMass center width := by + rw [shiftedSmoothProductMass_eq_prod _ _ hw] + exact Finset.prod_pos (fun j _ => hmasses j) + have hcoordinate : ∀ i, laws (allocatedSmoothFullEmbedding inactive spatial block i) = + shiftedSmoothCoefficientPMF (center i) (width i) (hw i) + (shiftedSmoothProductMass_coordinate_pos center width hw hz i) := by + intro i + exact allocatedFullSmoothScalarPMF_selected B U basis hR hσ S inactive spatial block + noiseCenter noiseWidth noisePMF hnw hnm (fun _ _ => rfl) hactive i + have h := allocatedAffineProductMixed_primePower_event inactive spatial kernel block + (fun _ => 0) stride hstride residue laws hm center width hw hz hcoordinate + P A hprime hcover hpositive hdeep hD hC hL hthreshold hlarge + let test := fun (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) => + decide (∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray smooth (fun t => ((deck t).val : ℤ)) (fun _ => 0))) + have he := allocatedSpatialRank_cell_bind_eq B U basis hR hσ S stride hstride residue V hV hZ N test + exact (congrArg (fun p : PMF Bool => (p true).toReal) he).trans_le h + +theorem allocatedSpatialRank_reference_event {L N D : ℕ} [NeZero N] + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis + (allocatedGridAxis (I := I) U basis S.value) j, Fin L ↪ B ⟨j,b.val⟩) + (hm : 0 < m) (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells V z) + (hscale : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth stride V z) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hdeep : ∀ p ∈ P, ∀ x, 2 * (stride x).factorization p ≤ A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ allocatedSpatialRankSelectedWidth B U basis S spatial stride V j) : + (((selectedResidueSmoothPMF stride cells V hV hZ).bind fun noise => + (allocatedCoefficientIntegerPMF B U basis hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N)).map + fun deck => decide (∀ p : P, allocatedActualModulusBad + (allocatedGridAxis (I := I) U basis S.value) spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (Sum.elim noise a) + (fun ⟨j,e,i⟩ => ((deck j e i).val : ℤ)) (fun _ => 0)))) true).toReal ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / + allocatedSpatialRankSelectedWidth B U basis S spatial stride V j := by + have hc (r : cells) : 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative stride r.val) stride) + (residueProfileWidth stride V) := by + rw [shiftedSmoothProductMass_eq_prod _ _ (residueProfileWidth_pos stride V hstride hV)] + exact Finset.prod_pos (fun z _ => shiftedSmoothSampleSum_pos _ (hscale z)) + apply selectedResidueSmoothPMF_bind_le_of_cells stride hstride cells V hV hZ hc + intro r + exact allocatedSpatialRank_cell_event B U basis hR hσ S spatial kernel block hm stride hstride + (boundedColumnResidueRepresentative stride r.val) V hV (hc r) P A hprime hcover hpositive + hdeep hD hC hL hthreshold hlarge + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule MeasureTheory +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type} [Fintype G] {I : Fin m → Type} [∀ j, Fintype (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J E : Fin m → Type} [∀ j, Fintype (J j)] [∀ j, DecidableEq (J j)] [∀ j, Fintype (E j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) + +variable (C V : Fin m → ℝ≥0) +variable (hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) +variable (hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + +include hC hV in + +theorem exists_allocated_physical_rank_witness_comparison + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (hσ1 : ∀ j, σ j ≤ 1) + (Cinv : Fin m → ℝ) (hCinv : ∀ j, 0 ≤ Cinv j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ Cinv j * ‖v‖) + (hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1/4) + (q : ℕ) [NeZero q] (hq : 0 < q) + {P δ : ℝ} (hP : 0 ≤ P) (hmP : (m : ℝ) ≤ P) + (hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val+1)) : ℝ) ≤ P) + (hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (hn : ∀ j, (n j : ℝ) ≤ P) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (hLP : (S.value : ℝ) ≤ Real.exp P) + (hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (hqP : (q : ℝ) ≤ Real.exp P) (hδ : 0 < δ) (hδP : δ⁻¹ ≤ Real.exp P) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + {X : Type} [Fintype X] [DecidableEq X] + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j) + {Ps ε ρ Rs Smax : ℝ} (hPs : 0 ≤ Ps) (hX : (Fintype.card X : ℝ) ≤ Ps) + (hframe : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ Ps) + (hqPs : (q : ℝ) ≤ Real.exp Ps) + (hε : 0 < ε) (hρ : 0 < ρ) (hεPs : 1 / ε ≤ Real.exp Ps) (hρPs : 1 / ρ ≤ Real.exp Ps) + (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (hSmax : 0 ≤ Smax) (hSmaxPs : Smax ≤ Real.exp Ps) (hstrideMax : ∀ x, ((stride x * q : ℕ) : ℝ) ≤ Smax) + (H : X → ℝ) + (hsize : ∀ x, Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ H x) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H Rs (U j) (poly j)) + (hRs : Real.exp ((Ps + allocatedMaskedTiltedConstant m) ^ allocatedMaskedTiltedConstant m) ≤ Rs) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (hcells : cells.Nonempty) + (inactive : LayerSamplerAxis I n → Prop) {L : ℕ} + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ a : AllocatedDegreeActiveAxis inactive j, Fin L ↪ B ⟨j,a.val⟩) + (rankC : ℝ) (primes : Finset ℕ) [∀ p : primes, NeZero p.val] (depth : ℕ → ℕ) + (hdiv : ∀ p : primes, p.val ^ depth p.val ∣ q) + (width : Option (LayerSamplerVariables G I n B) × X → ℝ) (hwidth : ∀ z, 0 < width z) + (hwide : ∀ z, ρ * H z.2 ≤ width z) + (hfreqPs : (4 * allocatedFourierLogBudget m P + 2)^4 ≤ Ps) + (hmassPs : 4 * allocatedFourierLogBudget m P * (4 * allocatedFourierLogBudget m P + 2)^4 + + allocatedFourierLogBudget m P ≤ Ps) + (hsmallError : 2 * δ + ε ≤ 1 / 2) : + let Dphysical := fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => + allocatedCoefficientDensity B U b hb o hR hσ S + (affineSampleCoefficientTorus U poly hm (fun k x => (z (k, x) : ℝ))) + let sample := fun z : Option (LayerSamplerVariables G I n B) × X → ℤ => + affineCoefficientCoverSample U poly hm q (fun k x => (z (k, x) : ℝ)) + ∃ hD0 : ∀ z, 0 ≤ Dphysical z, + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells width z, + ∃ hDpos : 0 < selectedResidueDensityMass stride cells width Dphysical, + |selectedResidueDensityMass stride cells width Dphysical - 1| ≤ 2 * δ + ε ∧ + 1 / 2 ≤ selectedResidueDensityMass stride cells width Dphysical ∧ + selectedResidueDensityMass stride cells width Dphysical ≤ 3 / 2 ∧ + |(∑' z, (selectedResidueDensityPMF stride cells width hwidth hZ Dphysical hD0 hDpos z).toReal * + (if coefficientDeckChartEvent U bW b hb o q (allocatedChartResiduePrimePowerWitness inactive rankC primes depth q hdiv + (fun v => (z v : ZMod q))) (sample z) then 1 else 0)) - + (((selectedResidueSmoothPMF stride cells width hwidth hZ).bind fun z => + (allocatedCoefficientIntegerPMF B U b hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E q)).map + fun r => decide (∀ p : primes, allocatedActualModulusBad inactive spatial kernel block + rankC (p.val ^ depth p.val) (allocatedMixedFullArray (Sum.elim z a) + (fun ⟨j,e,i⟩ => ((r j e i).val : ℤ)) (fun _ => 0)))) true).toReal| ≤ + 12 * (2 * δ + ε) := by + dsimp only + obtain ⟨hD0, hZ, hDpos, hmass, hlower, hupper, he⟩ := + exists_allocated_spatial_witness_comparison B U bW b hb o S C V hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall q hq hP hmP hK hRP hσP hcount hI hn hJ hAP hLP + hCP hVP hqP hδ hδP μ ν poly hp hm hPs hX hframe hqPs hε hρ hεPs hρPs stride hstride + hSmax hSmaxPs hstrideMax H hsize hrank hRs cells hcells + (allocatedChartResiduePrimePowerWitness inactive rankC primes depth q hdiv) + width hwidth hwide hfreqPs hmassPs hsmallError + have href := allocatedSpatialRankReferenceLaw (E := E) B U b hR hσ S inactive spatial kernel block + rankC primes depth q hdiv (selectedResidueSmoothPMF stride cells width hwidth hZ) + rw [href] at he + exact ⟨hD0, hZ, hDpos, hmass, hlower, hupper, he⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (E j)] + {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (S : LayerSamplerScale (G := G) B U basis R σ) + +noncomputable local instance shortSpatialReferenceSmoothFintype : + Fintype (AllocatedFullSmoothCoefficientIndex G X I n B) := inferInstance +noncomputable local instance shortSpatialReferenceDeckFintype : + Fintype (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := inferInstance +noncomputable local instance shortSpatialReferenceDeckDecidableEq : + DecidableEq (CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E) := Classical.decEq _ + +theorem allocatedShortPrincipalRank_active (j : Fin m) + (i : AllocatedCongruenceIntegerAxis (allocatedShortAxis (I := I) U basis S.value) j) : + S.value ^ (j.val + 1) < basisAxisScale (basis j) i.val := by + exact Nat.lt_of_not_ge i.property + +noncomputable def allocatedShortRankSelectedWidth {L : ℕ} + (spatial : Fin L ↪ G) (stride : X → ℕ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) : + AllocatedSmoothRankCoefficientIndex X (allocatedShortAxis (I := I) U basis S.value) L → ℝ := + allocatedSelectedSmoothWidth B U basis S (allocatedShortAxis (I := I) U basis S.value) + (fun l x => residueProfileWidth stride V (some (.inl (spatial l)),x)) + +theorem allocatedShortRank_cell_event {L N D : ℕ} [NeZero N] + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis + (allocatedShortAxis (I := I) U basis S.value) j, Fin L ↪ B ⟨j,b.val⟩) + (hm : 0 < m) (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (residue : Option (LayerSamplerVariables G I n B) × X → ℤ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue stride) + (residueProfileWidth stride V)) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hdeep : ∀ p ∈ P, ∀ x, 2 * (stride x).factorization p ≤ A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ allocatedShortRankSelectedWidth B U basis S spatial stride V j) : + (((residueSmoothPMF residue stride hstride V hV hZ).bind fun noise => + (allocatedCoefficientIntegerPMF B U basis hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N)).map + fun deck => decide (∀ p : P, allocatedActualModulusBad + (allocatedShortAxis (I := I) U basis S.value) spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (Sum.elim noise a) + (fun ⟨j,e,i⟩ => ((deck j e i).val : ℤ)) (fun _ => 0)))) true).toReal ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / + allocatedShortRankSelectedWidth B U basis S spatial stride V j := by + let inactive := allocatedShortAxis (I := I) U basis S.value + let noiseCenter : Fin L → X → ℝ := + fun l x => residueProfileCenter residue stride (some (.inl (spatial l)),x) + let noiseWidth : Fin L → X → ℝ := + fun l x => residueProfileWidth stride V (some (.inl (spatial l)),x) + let center := allocatedSelectedSmoothCenter B U basis S inactive noiseCenter + let width := allocatedSelectedSmoothWidth B U basis S inactive noiseWidth + let noisePMF := residueSmoothScalarPMFs residue stride hstride V hV hZ + let laws := allocatedFullSmoothScalarPMF B U basis hR hσ S noisePMF + have hnw : ∀ l x, 0 < noiseWidth l x := + fun l x => residueProfileWidth_pos stride V hstride hV _ + have hnm : ∀ l x, 0 < shiftedSmoothSampleSum (noiseCenter l x) (noiseWidth l x) := + fun l x => shiftedSmoothProductMass_coordinate_pos _ _ + (residueProfileWidth_pos stride V hstride hV) hZ _ + have hactive := allocatedShortPrincipalRank_active B U basis S + have hw : ∀ j, 0 < width j := + allocatedSelectedSmoothWidth_pos B U basis hR S inactive noiseWidth hnw + have hmasses : ∀ j, 0 < shiftedSmoothSampleSum (center j) (width j) := + allocatedSelectedSmoothMass_pos B U basis hR S inactive noiseCenter noiseWidth hnm hactive + have hz : 0 < shiftedSmoothProductMass center width := by + rw [shiftedSmoothProductMass_eq_prod _ _ hw] + exact Finset.prod_pos (fun j _ => hmasses j) + have hcoordinate : ∀ i, laws (allocatedSmoothFullEmbedding inactive spatial block i) = + shiftedSmoothCoefficientPMF (center i) (width i) (hw i) + (shiftedSmoothProductMass_coordinate_pos center width hw hz i) := by + intro i + exact allocatedFullSmoothScalarPMF_selected B U basis hR hσ S inactive spatial block + noiseCenter noiseWidth noisePMF hnw hnm (fun _ _ => rfl) hactive i + have h := allocatedAffineProductMixed_primePower_event inactive spatial kernel block + (fun _ => 0) stride hstride residue laws hm center width hw hz hcoordinate + P A hprime hcover hpositive hdeep hD hC hL hthreshold hlarge + let test := fun (smooth : AllocatedFullSmoothCoefficientIndex G X I n B → ℤ) + (deck : CoefficientDeckScalarIndex (LayerSamplerVariables G I n B) E → ZMod N) => + decide (∀ p : P, allocatedActualModulusBad inactive spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray smooth (fun t => ((deck t).val : ℤ)) (fun _ => 0))) + have he := allocatedSpatialRank_cell_bind_eq B U basis hR hσ S stride hstride residue V hV hZ N test + exact (congrArg (fun p : PMF Bool => (p true).toReal) he).trans_le h + +theorem allocatedShortRank_reference_event {L N D : ℕ} [NeZero N] + (spatial : Fin L ↪ G) (kernel : ∀ j : Fin m, Fin L × Fin (j.val + 1) ↪ G) + (block : ∀ j, ∀ b : AllocatedDegreeActiveAxis + (allocatedShortAxis (I := I) U basis S.value) j, Fin L ↪ B ⟨j,b.val⟩) + (hm : 0 < m) (stride : X → ℕ) (hstride : ∀ x, 0 < stride x) + (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells V z) + (hscale : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth stride V z) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) (hcover : ∀ p ∈ P, p ^ A p ∣ N) + (hpositive : ∀ p ∈ P, 0 < A p) + (hdeep : ∀ p ∈ P, ∀ x, 2 * (stride x).factorization p ≤ A p) + (hD : Fintype.card X + ∑ j : Fin m, (Fintype.card (E j) + n j) ≤ D) + {C : ℝ} (hC : 0 ≤ C) + (hL : ⌈2 * (C + D + 10) / modularRankSmallBallExponent m⌉₊ ≤ L) + (hthreshold : ∀ p ∈ P, modularCoefficientPrimeThreshold m ≤ p ^ A p) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (∏ p : P, p.val ^ A p.val) ≤ allocatedShortRankSelectedWidth B U basis S spatial stride V j) : + (((selectedResidueSmoothPMF stride cells V hV hZ).bind fun noise => + (allocatedCoefficientIntegerPMF B U basis hR hσ S).bind fun a => + (PMF.uniformOfFintype (CoefficientDeckResidues (K := LayerSamplerVariables G I n B) E N)).map + fun deck => decide (∀ p : P, allocatedActualModulusBad + (allocatedShortAxis (I := I) U basis S.value) spatial kernel block C (p.val ^ A p.val) + (allocatedMixedFullArray (Sum.elim noise a) + (fun ⟨j,e,i⟩ => ((deck j e i).val : ℤ)) (fun _ => 0)))) true).toReal ≤ + 1 / ((∏ p : P, p.val ^ A p.val : ℕ) : ℝ) ^ 10 + + ∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (∏ p : P, p.val ^ A p.val) / + allocatedShortRankSelectedWidth B U basis S spatial stride V j := by + have hc (r : cells) : 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative stride r.val) stride) + (residueProfileWidth stride V) := by + rw [shiftedSmoothProductMass_eq_prod _ _ (residueProfileWidth_pos stride V hstride hV)] + exact Finset.prod_pos (fun z _ => shiftedSmoothSampleSum_pos _ (hscale z)) + apply selectedResidueSmoothPMF_bind_le_of_cells stride hstride cells V hV hZ hc + intro r + exact allocatedShortRank_cell_event B U basis hR hσ S spatial kernel block hm stride hstride + (boundedColumnResidueRepresentative stride r.val) V hV (hc r) P A hprime hcover hpositive + hdeep hD hC hL hthreshold hlarge + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +omit [Fintype X] in + +theorem allocatedSpatialRankSelectedWidth_common_gap {L : ℕ} + (spatial : Fin L ↪ G) (stride : X → ℕ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) {W : ℝ} + (hprincipal : ∀ j i, S.value ^ (j.val + 1) < basisAxisScale (basis j) i → + 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + (layerSamplerGapWidth (G := G) B R ⟨j, i⟩ / 2) * + ((basisAxisScale (basis j) i : ℝ) / (S.value : ℝ) ^ (j.val + 1))) + (hspatial : ∀ l x, 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + residueProfileWidth stride V (some (.inl (spatial l)), x)) : + ∀ a, 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + allocatedSpatialRankSelectedWidth B U basis S spatial stride V a := by + rintro ⟨j, (x | i), l⟩ + · exact hspatial l x.val + · exact hprincipal j i.val (allocatedGridPrincipalRank_active B U basis S j i) + +theorem allocatedSpatialRankSelectedWidth_budget {L : ℕ} + (spatial : Fin L ↪ G) (stride : X → ℕ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) {cap W κ : ℝ} + (hcap : 0 < cap) (hκ : 0 < κ) (hcapW : cap ≤ W) + (hprincipal : ∀ j i, S.value ^ (j.val + 1) < basisAxisScale (basis j) i → + 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + (layerSamplerGapWidth (G := G) B R ⟨j, i⟩ / 2) * + ((basisAxisScale (basis j) i : ℝ) / (S.value : ℝ) ^ (j.val + 1))) + (hspatial : ∀ l x, 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + residueProfileWidth stride V (some (.inl (spatial l)), x)) + (hbudget : 2 * (Fintype.card (AllocatedSmoothRankCoefficientIndex X + (allocatedGridAxis (I := I) U basis S.value) L) : ℝ) * cap / κ ≤ W) : + (∀ a, 8 * (probabilityProfileLipschitz : ℝ) * cap ≤ + allocatedSpatialRankSelectedWidth B U basis S spatial stride V a) ∧ + (∑ a, 16 * (probabilityProfileLipschitz : ℝ) * cap / + allocatedSpatialRankSelectedWidth B U basis S spatial stride V a) ≤ κ := by + apply finite_residue_error_common_gap_budget + (allocatedSpatialRankSelectedWidth B U basis S spatial stride V) + (lt_of_lt_of_le zero_lt_one probabilityProfileLipschitz_one_le) hcap hκ hcapW + · exact allocatedSpatialRankSelectedWidth_common_gap B U basis S spatial stride V hprincipal hspatial + · exact hbudget + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +omit [Fintype X] in + +theorem allocatedShortRankSelectedWidth_common_gap {L : ℕ} + (spatial : Fin L ↪ G) (stride : X → ℕ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) {W : ℝ} + (hprincipal : ∀ j i, S.value ^ (j.val + 1) < basisAxisScale (basis j) i → + 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + (layerSamplerGapWidth (G := G) B R ⟨j, i⟩ / 2) * + ((basisAxisScale (basis j) i : ℝ) / (S.value : ℝ) ^ (j.val + 1))) + (hspatial : ∀ l x, 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + residueProfileWidth stride V (some (.inl (spatial l)), x)) : + ∀ a, 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + allocatedShortRankSelectedWidth B U basis S spatial stride V a := by + rintro ⟨j, (x | i), l⟩ + · exact hspatial l x.val + · exact hprincipal j i.val (allocatedShortPrincipalRank_active B U basis S j i) + +theorem allocatedShortRankSelectedWidth_budget {L : ℕ} + (spatial : Fin L ↪ G) (stride : X → ℕ) + (V : Option (LayerSamplerVariables G I n B) × X → ℝ) {cap W κ : ℝ} + (hcap : 0 < cap) (hκ : 0 < κ) (hcapW : cap ≤ W) + (hprincipal : ∀ j i, S.value ^ (j.val + 1) < basisAxisScale (basis j) i → + 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + (layerSamplerGapWidth (G := G) B R ⟨j, i⟩ / 2) * + ((basisAxisScale (basis j) i : ℝ) / (S.value : ℝ) ^ (j.val + 1))) + (hspatial : ∀ l x, 8 * (probabilityProfileLipschitz : ℝ) * W ≤ + residueProfileWidth stride V (some (.inl (spatial l)), x)) + (hbudget : 2 * (Fintype.card (AllocatedSmoothRankCoefficientIndex X + (allocatedShortAxis (I := I) U basis S.value) L) : ℝ) * cap / κ ≤ W) : + (∀ a, 8 * (probabilityProfileLipschitz : ℝ) * cap ≤ + allocatedShortRankSelectedWidth B U basis S spatial stride V a) ∧ + (∑ a, 16 * (probabilityProfileLipschitz : ℝ) * cap / + allocatedShortRankSelectedWidth B U basis S spatial stride V a) ≤ κ := by + apply finite_residue_error_common_gap_budget + (allocatedShortRankSelectedWidth B U basis S spatial stride V) + (lt_of_lt_of_le zero_lt_one probabilityProfileLipschitz_one_le) hcap hκ hcapW + · exact allocatedShortRankSelectedWidth_common_gap B U basis S spatial stride V hprincipal hspatial + · exact hbudget + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSiteEnvelopeKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSiteEnvelopeKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..987e6cd4133795092c9e5015bed1f5e09e1e5b7c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSiteEnvelopeKernel.lean @@ -0,0 +1,80 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedActualProfileControl +import OAI.Combinatorics.Progressions.Estimates.AllocatedSiteEnvelopeGain + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped Classical BigOperators NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {α : Type*} [Fintype α] [DecidableEq α] (x : G → IntegerScalarCubeBox α S.value) +variable (u : PrincipalAxisTuples (α := α) (allocatedGridAxis (I := I) U b S.value) + (allocatedPrincipalSides B U b S)) +variable (v : PrincipalAxisTuples (α := α) (fun a => ¬allocatedGridAxis (I := I) U b S.value a) + (allocatedPrincipalSides B U b S)) +variable {O : Fin m → Type*} [∀ j, Fintype (O j)] (rows : ∀ j, O j → Finset α) +variable {Q : Fin m → Type*} [∀ j, Fintype (Q j)] + +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "root" => allocatedPhysicalCubeRoot B U b S (fun _ => 0) x (principalAxisJoin grid u v) +local notation "dirs" => allocatedPhysicalCubeDirections B U b S x (principalAxisJoin grid u v) + +theorem allocatedSiteEnvelope_kernel_gain {D p : ℝ} + (h : AllocatedComparisonDimensions (G := G) B α O D) + (hQ : ∀ j, (Fintype.card (Q j) : ℝ) ≤ D) (hp : 0 ≤ p) + {M : ℕ} {κ : ℝ} (hM : 0 < M) (hMp : (M : ℝ) ≤ Real.exp p) + (selection : α ↪ G) (hx : GoodScalarKernelTuple selection κ M x) + (hq : Fintype.card α ≤ m + 1) (hinj : ∀ j, Function.Injective (rows j)) + (hrows : ∀ j z, (rows j z).card ≤ j.val + 1) + (period : ℕ) [NeZero period] + (hperiod : ∀ j, integerScalarLattice (O j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (rows j)).mulVecLin.range) + (hperiod_size : period ≤ M ^ (m + 1)) + (d : ℕ) [NeZero d] (modulus : ℕ) + (residue : ∀ j, Matrix (O j) (AllocatedNonkernelCoefficient (G := G) B j) (ZMod modulus)) : + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * p + let Cm : ℝ≥0 := ⟨Real.exp w, (Real.exp_pos w).le⟩ + let A : ℝ≥0 := Real.toNNReal (coefficientDeckPeriodCap O Q period) * + Cm ^ Fintype.card (LayerSamplerAxis I n) + (A : ℝ) ≤ Real.exp (allocatedSiteEnvelopeGain m D p) ∧ + ∀ (z : AllocatedLongJetRows B U b S O) (r : ∀ j, O j → Q j → ZMod d), + |∏ a, allocatedLongJetMask B U b S x rows modulus residue a (z a)| * + coefficientDeckJetDensity root dirs rows d r ≤ A := by + let w : ℝ := (m * 2 ^ (m + 1) : ℕ) * p + let Cm : ℝ≥0 := ⟨Real.exp w, (Real.exp_pos w).le⟩ + have hw : 0 ≤ w := mul_nonneg (Nat.cast_nonneg _) hp + have hCm : 1 ≤ (Cm : ℝ) := Real.one_le_exp_iff.mpr hw + have hm (j : Fin m) (z : O j → ℤ) : + 0 ≤ allocatedIntegerKernelMask B U b S x rows j modulus (residue j) z ∧ + allocatedIntegerKernelMask B U b S x rows j modulus (residue j) z ≤ Cm := + ⟨(allocatedIntegerKernelMask_bound B U b S x rows hM selection hx hq hinj hrows j modulus (residue j) z).1, + allocatedIntegerKernelMask_le_exp B U b S x rows hM selection hx hq hinj hrows hMp j modulus (residue j) z⟩ + constructor + · exact allocatedProfileGain_le_exp B h hQ M period hperiod_size Cm hp hw hMp le_rfl + · intro z r + have hphysical (j : Fin m) : integerScalarLattice (O j) (period : ℤ) ≤ + (boundedCoefficientJetMatrix root dirs (j.val + 1) (rows j)).mulVecLin.range := by + rw [← allocatedPartitionedJetMatrix_eq_physical B U b S x u v rows j] + exact (hperiod j).trans (allocatedPartitionedJetMatrix_kernel_range_le B U b S x u v rows j) + have hd := coefficientDeckJetDensity_period_bound root dirs rows d period hphysical r + have hmask := allocatedLongJetMask_product_bound B U b S x rows modulus residue hCm hm z + change _ ≤ ((Real.toNNReal (coefficientDeckPeriodCap O Q period) * + Cm ^ Fintype.card (LayerSamplerAxis I n) : ℝ≥0) : ℝ) + simp only [NNReal.coe_mul, NNReal.coe_pow, + Real.coe_toNNReal _ (coefficientDeckPeriodCap_nonneg O Q period)] + exact (mul_le_mul hmask hd (coefficientDeckJetDensity_nonneg root dirs rows d r) + (pow_nonneg Cm.coe_nonneg _)).trans_eq (mul_comm _ _) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSlicedDenseKernelSource.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSlicedDenseKernelSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b9dae712b865e42eeadae08dbe9caa4b9b171be --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSlicedDenseKernelSource.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedSlicedRowsProjectedSource + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} (X : Type*) [Fintype X] +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +variable (N : X → ℕ) (hN : ∀ t, 0 < N t) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (stride : X → ℕ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + +local notation "widths" => narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N +local notation "hwidths" => narrowTrimmedSpatialWidths_pos hW hτ hξ N hN +local notation "baseDensity" => allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem +local notation "whole" => principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (allocatedPrincipalSides_pos B U b S) + +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (bases : Finset (X → ℤ)) (hbases : bases.Nonempty) +variable (htotal : 0 < selectedJointDensityMass bases stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem)) + +local notation "sides" => Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U b S) +local notation "hSides" => (Sum.rec (fun _ : G => S.positive) (allocatedPrincipalSides_pos B U b S)) + +variable (H : LayerSamplerVariables G I n B → ℕ) (hH : ∀ k, 0 < H k) +variable (c : LayerSamplerVariables G I n B → ℤ) (step : ℕ) +variable (hsubset : ∀ k : LayerSamplerVariables G I n B, + integerProgressionSupport (c k) (step : ℤ) (H k) ⊆ + Finset.Ico (0 : ℤ) + ((Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U b S) k : ℕ) : ℤ)) + +local notation "kernelLaw" => containedProgressionCubeLaw (α := Fin dim) + (fun _ : G => S.value) (fun g => H (Sum.inl g)) (fun _ => step) (fun g => c (Sum.inl g)) + (fun _ => S.positive) (fun g => hH (Sum.inl g)) (fun g => hsubset (Sum.inl g)) +local notation "principalLaw" => containedProgressionCubeLaw (α := Fin dim) + (allocatedPrincipalSides B U b S) (fun j => H (Sum.inr j)) (fun _ => step) (fun j => c (Sum.inr j)) + (allocatedPrincipalSides_pos B U b S) (fun j => hH (Sum.inr j)) (fun j => hsubset (Sum.inr j)) + +include hbases htotal in +theorem allocatedSlicedCubeSource_good_kernel_dense_residue + [Nonempty (Fin dim)] + (selection : Fin dim ↪ G) (hG : dim * (dim + 2) ≤ Fintype.card G) + {F gain : ℝ} (hgain : 0 < gain) + (hkernel : scalarKernelCutoff (Fin dim) G 1 ⌈Real.exp F⌉₊ (gain / 2) ≤ S.value) + (hstep : 0 < step) (hcounts : ∀ g, Real.exp (-F) * S.value ≤ (H (Sum.inl g) : ℝ)) + (f : (X → ℤ) → ℂ) (hf : ∀ u, ‖f u‖ ≤ 1) + (hlarge : gain ≤ (allocatedSlicedCubeSource (dim := dim) B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases H hH c step f).re) + (q : (G → IntegerScalarCubeBox (Fin dim) S.value) → ℕ) [∀ x, NeZero (q x)] : + let Mk := scalarKernelCutoff (Fin dim) G 1 ⌈Real.exp F⌉₊ (gain / 2) + ∃ (x : G → IntegerScalarCubeBox (Fin dim) S.value), + 0 < (kernelLaw).weight x ∧ GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x ∧ + ∃ (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod (q x)) + (hr : 0 < (principalTupleWeights (α := Fin dim) B (layerSamplerDegree I n) + (fun j => H (Sum.inr j)) (fun j => hH (Sum.inr j))).mass + (Finset.univ.filter (fun y => principalResidueLabel (q x) y = r))), + gain / 2 ≤ ((containedSupportedProgressionLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) (fun j => H (Sum.inr j)) (fun _ => step) + (fun j => c (Sum.inr j)) (allocatedPrincipalSides_pos B U b S) + (fun j => hH (Sum.inr j)) (fun j => hsubset (Sum.inr j)) (q x) r hr).complexMean + (fun y => allocatedSlicedTupleValue B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases x y f)).re := by + intro Mk + have hD : 0 < ⌈Real.exp F⌉₊ := Nat.ceil_pos.mpr (Real.exp_pos F) + have hLH (g : G) : S.value ≤ ⌈Real.exp F⌉₊ * H (Sum.inl g) := by + have h := mul_le_mul_of_nonneg_left (hcounts g) (Real.exp_nonneg F) + have hl : (S.value : ℝ) ≤ Real.exp F * H (Sum.inl g) := by + simpa only [← mul_assoc, ← Real.exp_add, add_neg_cancel, Real.exp_zero, one_mul] using h + exact_mod_cast hl.trans (mul_le_mul_of_nonneg_right (Nat.le_ceil _) (Nat.cast_nonneg _)) + exact allocatedSlicedCubeSource_good_kernel_residue B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal H hH c step hsubset + selection hG hD (half_pos hgain) (half_pos hgain) hkernel hstep hLH f hf + (by simpa only [add_halves] using hlarge) q + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSpatialKernelShift.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSpatialKernelShift.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0ae5c53477496c6f0ec67f781bb092686fe6b87 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSpatialKernelShift.lean @@ -0,0 +1,92 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedLocalResidueReconstruction + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators Matrix NNReal + +variable {m : ℕ} {G : Type*} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type*) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +variable {dim : ℕ} (x : G → IntegerScalarCubeBox (Fin dim) S.value) +variable (X : Type*) [Fintype X] {M : ℕ} (hM : 0 < M) (selection : Fin dim ↪ G) +variable (hx : GoodScalarKernelTuple selection (1 / (M : ℝ)) M x) +variable (modulus : ℕ) [NeZero modulus] (H : X → ℝ) {W : ℝ} (hW : 0 ≤ W) (mesh : ℝ) + +omit [∀ j, DecidableEq (I j)] [∀ a, DecidableEq (B a)] in +theorem allocatedResidueSpatialKernel_shift + (Q : ℝ≥0) (hQ : 1 ≤ Q) (hratio : (1 + W) / (S.value : ℝ) ≤ Q) + (hroot : ∀ g, |((x g none : ℤ) : ℝ)| ≤ 1 + W) + (hperiod : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ + pivotFullImage + (selectedSpatialPivot (fun g => (0 : ℤ) + (x g none : ℤ)) (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns (fun g => (0 : ℤ) + (x g none : ℤ)) (scalarCubeDifferenceMatrix x) selection)) + (hH : ∀ t, 0 < H t) (hmesh : 0 < mesh) {ε : ℝ} (hε : 0 ≤ ε) + (r : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin dim) → ZMod modulus) + (v shift : X → (Unit ⊕ Fin dim) → ℤ) + (hshift : ∀ t, shift t ∈ integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ)) + (hsize : ∀ t, ‖fun i => (shift t i : ℝ) / H t‖ ≤ ε) + (hv : v ∈ spatialWindow H 4) (hvs : v + shift ∈ spatialWindow H 4) : + ‖allocatedResidueSpatialKernel B U b S x X hM selection hx modulus H hW mesh r (v + shift) - + allocatedResidueSpatialKernel B U b S x X hM selection hx modulus H hW mesh r v‖ ≤ + Fintype.card X * + ((modulus : ℝ)^Fintype.card (Unit ⊕ Fin dim) * + (anisotropicSpatialDensityLip selection (1 / (M : ℝ)) * Q) * (8 * mesh + ε)) * + (1 + (modulus : ℝ)^Fintype.card (Unit ⊕ Fin dim) * + anisotropicSpatialDensityCap selection (1 / (M : ℝ)))^Fintype.card X := by + let root := fun g => (0 : ℤ) + (x g none : ℤ) + let A := selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection + let C := Matrix.fromCols (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection) + (liftResidueMatrix (principalSpatialResidueColumns modulus (fun _ => (0 : ℤ)) id r)) + have hκ : 0 < 1 / (M : ℝ) := one_div_pos.mpr (Nat.cast_pos.mpr hM) + let hp := goodScalarKernelTuple_spatial_det_ne_zero selection x root hκ hx + let f := canonicalSpatialSiteDensity selection root (scalarCubeDifferenceMatrix x) hp W S.value + hW (Nat.cast_pos.mpr S.positive) + have hL1 : (1 : ℝ) ≤ S.value := by exact_mod_cast S.positive + have hroot' : ∀ g, |(root g : ℝ)| ≤ 1 + W := by + intro g + simpa only [root, zero_add] using hroot g + have hD : ∀ i g, |(scalarCubeDifferenceMatrix x i g : ℝ)| ≤ S.value := by + intro i g + have hg := Finset.mem_Ico.mp (x g (some i)).property + change |((x g (some i) : ℤ) : ℝ)| ≤ S.value + exact_mod_cast abs_le.mpr ⟨hg.1, hg.2.le⟩ + have hminor : 1 / (M : ℝ) ≤ + |(Matrix.of (fun i j => (scalarCubeDifferenceMatrix x i (selection j) : ℝ) / (S.value : ℝ))).det| := by + change 1 / (M : ℝ) ≤ |(normalizedScalarCubePivot selection x).det| + rw [normalizedScalarCubePivot_det] + exact hx.1.le + have hf := canonicalSpatialSiteDensity_lipschitz_ratio selection root (scalarCubeDifferenceMatrix x) + hp hW (Nat.cast_pos.mpr S.positive) hκ hroot' hD hminor hQ hratio + have hcap := (canonicalSpatialSiteDensity_bounds selection root (scalarCubeDifferenceMatrix x) + hp hW (Nat.cast_pos.mpr S.positive) hL1 hκ hroot' hD hminor).1 + have hfull : integerScalarLattice (Unit ⊕ Fin dim) (modulus : ℤ) ≤ pivotFullImage A C := by + dsimp only [A, C] + rw [pivotFullImage_split] + exact hperiod.trans le_sup_left + have hi : ((pivotFullImage A C).toAddSubgroup.index : ℝ) ≤ + (modulus : ℝ)^Fintype.card (Unit ⊕ Fin dim) := by + exact_mod_cast residueLatticeImage_index_le _ modulus hfull + have h := vectorSpatialSiteApprox_shift A (fun _ : X => C) modulus (fun _ => hfull) + (fun _ => f) (fun _ => hf) H (by positivity) + (anisotropicSpatialDensityCap_nonneg selection hκ.le) hε (fun _ => hi) (fun _ => hcap) + (by norm_num : (0 : ℝ) < 4) hmesh v shift (fun t => hfull (hshift t)) hsize + ((mem_spatialWindow_scaled_iff H hH 4 v).mp hv) + ((mem_spatialWindow_scaled_iff H hH 4 (v + shift)).mp hvs) + simpa only [allocatedResidueSpatialKernel, f, A, C, root, hp, Pi.add_apply, NNReal.coe_mul, + Real.coe_toNNReal _ (anisotropicSpatialDensityLip_nonneg selection hκ.le)] using h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSpatialProjectionBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSpatialProjectionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..372e1f727f5e8d16abe057615efc040a7ec65aa6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSpatialProjectionBudget.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedProfileDimensions + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +noncomputable def spatialProjectionBudget {T : Type*} [Semiring T] (q : ℕ) (P : T) : T := + let j : T := q + 1 + let b := j * (P + 2) + j ^ 2 + j + (P + 2) + 2 * (P + 1) + comparisonProfileBound + 2 + 2 * j ^ 2 + (2 * j + 4) * b + (j + 2 * (P + 1)) * (b + 4) + 4 + 4 * P + 12 + +theorem spatialProjectionBudget_nonneg (q : ℕ) {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ spatialProjectionBudget q P := by + unfold spatialProjectionBudget + positivity + +theorem physicalSpatialLogAllowance_le_projection_budget {K : Type*} [Fintype K] + {q : ℕ} (s : Fin q ↪ K) {P : ℝ} (hP : 0 ≤ P) (hK : (Fintype.card K : ℝ) ≤ P) : + physicalSpatialLogAllowance s (P + 2) + 4 * P + 12 ≤ spatialProjectionBudget q P := by + have hj : (Fintype.card (Unit ⊕ Fin q) : ℝ) = q + 1 := by simp [Nat.cast_add, add_comm] + have hn : (Fintype.card (Option K) : ℝ) ≤ P + 1 := by + simpa only [Fintype.card_option, Nat.cast_add, Nat.cast_one, add_comm] using add_le_add_right hK 1 + have hd : (Fintype.card (UnselectedColumn (physicalCubePivotIndex s)) : ℝ) ≤ P + 1 := + (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans hn + have hf : (probabilityProfileLipschitz : ℝ) ≤ comparisonProfileBound := by + apply (Nat.le_ceil _).trans + unfold comparisonProfileBound + push_cast + linarith + let b : ℝ := (q + 1) * (P + 2) + (q + 1) ^ 2 + (q + 1) + + (P + 2) + 2 * (P + 1) + comparisonProfileBound + 2 + have hb : physicalSpatialCommonBudget (Fintype.card (Unit ⊕ Fin q)) + (Fintype.card (UnselectedColumn (physicalCubePivotIndex s))) (Fintype.card (Option K)) (P + 2) ≤ b := by + unfold physicalSpatialCommonBudget affineProfileLogBound + rw [hj] + dsimp [b] + nlinarith + have hb0 : 0 ≤ physicalSpatialCommonBudget (Fintype.card (Unit ⊕ Fin q)) + (Fintype.card (UnselectedColumn (physicalCubePivotIndex s))) (Fintype.card (Option K)) (P + 2) := + (by linarith : 0 ≤ P + 2).trans (physicalSpatialCommonBudget_bounds _ _ _ (by linarith)).1 + unfold physicalSpatialLogAllowance coefficientLogAllowance spatialProjectionBudget + dsimp only + rw [hj] + change 2 * ((q : ℝ) + 1) ^ 2 + (2 * ((q : ℝ) + 1) + 4) * _ + + (((q : ℝ) + 1) + 2 * (Fintype.card (UnselectedColumn (physicalCubePivotIndex s)) : ℝ)) * + (_ + 4) + 4 + 4 * P + 12 ≤ _ + gcongr + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSupportedSlicedGoodKernelSource.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSupportedSlicedGoodKernelSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd56b5f188f413e123c51ab81fa2533f9d6e707d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedSupportedSlicedGoodKernelSource.lean @@ -0,0 +1,229 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedSupportedSlicedUniformPhysicalSource + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +private theorem goodKernelOneCubeAllRows (m : ℕ) : + ∀ (j : Fin m) (t : Finset (Fin 1)), t ∈ boundedBooleanJetRows (Fin 1) (j.val + 1) := by + intro j t + rw [boundedBooleanJetRows_oneCube (j.val + 1) (by omega)] + exact Finset.mem_univ t + +open MeasureTheory Module Submodule _root_.Set _root_.OAI.Set +open scoped BigOperators Classical NNReal +attribute [local instance] ScalarSiteExpansion.termFinite + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U b R σ) +local notation "rowSets" => (fun j : Fin m => boundedBooleanJetRows (Fin 1) (Fin.val j + 1)) + +local notation "rowTypes" => (fun j : Fin m => {t : Finset (Fin 1) // t ∈ rowSets j}) +local notation "rows" => (fun j => (Subtype.val : rowTypes j → Finset (Fin 1))) +local notation "grid" => allocatedGridAxis (I := I) U b S.value +local notation "split" => coefficientJetAxisSplit rowTypes I n grid +local notation "baseVolume" => (allocatedFullGridNaturalVolume B U b S rowSets * + coveredJetArrayScale (O := rowTypes) U * ∏ a, allocatedLongJetOutputScale B U b S (O := rowTypes) a) + +variable {E : Fin m → Type*} [∀ j, Fintype (E j)] +variable (q d period : ℕ) [NeZero d] [NeZero period] +variable (r : ℝ≥0) (hr : 0 < r) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (bW : ∀ j, Basis (E j) ℤ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) + +local notation "chart" => mixedCoveredJetChart U o b hb bW d +local notation "region" => mixedCoveredJetRegion (E := E) U o b d + (fun j (_ : rowTypes j) => standardLatticeClosedQuarterBox (J j)) +local notation "cutoff" => allocatedProductSiteCutoff B U b S rowSets o hb bW d r hr +local notation "inverseNormalizer" => ((allocatedProductIdealNormalizer B U b S rowSets : ℝ) : ℂ)⁻¹ + +variable (hR : ∀ j, 0 < R j) (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) +variable (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm v‖ ≤ C j * ‖v‖) +variable (hbudget : ∀ j : Fin m, ((boundedBooleanJetRows (Fin 1) (j.val + 1)).card + 1 : ℝ) * (Fintype.card (Finset (Fin 1)) * + (C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)))) ≤ 1 / 4) + +variable (hB : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, 4 ≤ Fintype.card (B a.val)) +variable (lower width : ∀ a : {a // ¬allocatedGridAxis (I := I) U b S.value a}, + B a.val × Fin (layerSamplerDegree I n a.val) → ℝ) + +variable (hσ : ∀ j, 0 < σ j) +variable (H step : PrincipalTupleIndex B (layerSamplerDegree I n) → ℕ) +variable (c : PrincipalTupleIndex B (layerSamplerDegree I n) → ℤ) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (allocatedPrincipalSides B U b S j : ℤ)) +variable (label : PrincipalTupleIndex B (layerSamplerDegree I n) → Option (Fin 1) → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := Fin 1) B (layerSamplerDegree I n) H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = label))) +local notation "gridLaw" => containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell grid +local notation "gridAxes" => {a // grid a} +local notation "ideal" => allocatedSlicedRowIdeal B U b S rowSets hR (goodKernelOneCubeAllRows m) hB lower width + +include hR hC hchart hbudget in +theorem exists_allocated_supported_sliced_good_kernel_source + (Cforward : Fin m → ℝ≥0) + (hforward : ∀ j v, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) v‖ ≤ Cforward j * ‖v‖) + (K : ℝ≥0) (hK : ∀ j, (R j)⁻¹ ≤ K) + (Qgrid : ℝ≥0) (hQgrid : ∀ a : {a // allocatedGridAxis (I := I) U b S.value a}, + 8 * ((Finset.card (layerIntegerPrincipalSlots (G := G) B + (allocatedGridIntegerAxis B U b S a).1 (allocatedGridIntegerAxis B U b S a).2) : ℝ) + 1) ≤ Qgrid) + (hq : 0 < q) {δg : ℝ} (hδg : 0 < δg) + (hdenseg : ∀ tg, δg * allocatedPrincipalSides B U b S tg ≤ (H tg : ℝ)) + (Tg : ℕ) (hQTg : (((Fintype.card (Fin 1) + 1) * q : ℕ) : ℝ) / δg ≤ Tg) + (hstep : ∀ tg, 0 < step tg) + (Ag : ℝ≥0) (hAg : LipschitzWith Ag Real.smoothTransition) (Pg : ℝ) (hPg : 1 ≤ Pg) + (hcP : scalarCubePrimitiveEnvelope Empty Ag 16 (128 * probabilityProfileLipschitz) 1 ≤ Pg) + (hsP : scalarCubePrimitiveEnvelope (Fin 1) Ag 1 0 q ≤ Pg) + (hstride : ∀ tg, ((step tg * q : ℕ) : ℝ) ≤ Pg) + (hBa : ∀ j i, positiveModerateSpectrumBlockCount j.val (rowSets j).card + ((layerTailDegree m + 1) * (rowSets j).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + (hBi : ∀ j i, uniformSpectrumBlockCount j.val (rowSets j).card + ((j.val + 1) * (rowSets j).card) ≤ Fintype.card (B ⟨j,Sum.inr i⟩)) + {Dg vg wg tg pg Eg εgrid : ℝ} + (hDg : 0 ≤ Dg) (hvg : 0 ≤ vg) (hwg : 0 ≤ wg) (htg : 0 ≤ tg) (hpg : 0 ≤ pg) (hEg : 0 ≤ Eg) + (hcube : (Fintype.card (Fin 1) : ℝ) ≤ Dg) (hdegree : ∀ j : Fin m, ((j.val + 1 : ℕ) : ℝ) ≤ Dg) + (hrowsD : ∀ j, ((rowSets j).card : ℝ) ≤ Dg) + (htail : ((layerTailDegree m + 1 : ℕ) : ℝ) ≤ Dg) + (hblocks : ∀ j i, (Fintype.card (B ⟨j, Sum.inr i⟩) : ℝ) ≤ Dg) + (hRv : ∀ j, R j ≤ Real.exp vg) (hRi : ∀ j, (R j)⁻¹ ≤ Real.exp vg) + (hδw : δg⁻¹ ≤ Real.exp wg) (hTg : (Tg : ℝ) ≤ Real.exp tg) + (hcoeff : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Real.exp vg) + (hPp₀ : Pg ≤ Real.exp pg) (haxes : (Fintype.card gridAxes : ℝ) ≤ Dg) + (hεgrid : 0 < εgrid) (hεgridEg : εgrid⁻¹ ≤ Real.exp Eg) (hσgrid : ∀ j, σ j ≤ 1) + (T : Fin m → ℝ) (hT : ∀ j, 0 ≤ T j) (h4 : ∀ j, 4 ≤ T j) + (hsource : ∀ j, (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) * + ((2 : ℝ) ^ Fintype.card (Fin 1) * ((Fintype.card (Fin 1) : ℝ) + 1) ^ (j.val + 1)) ≤ T j) + (hradius : ∀ j, (rowSets j).card * T j ≤ (r : ℝ)) (hσ1 : ∀ j, σ j ≤ 1) + (O : ℕ) (hO : Fintype.card (OneCubeActiveRow grid) ≤ O) + (hwidth : ∀ a p, |lower a p| + |width a p| ≤ 1) + {a δ P ε : ℝ} (ha : 0 < a) (hδ : 0 < δ) (hP : 0 ≤ P) + (haP : a⁻¹ ≤ Real.exp P) (hδP : δ⁻¹ ≤ Real.exp P) + {Pcap : ℝ} (hPcap : 0 ≤ Pcap) (haPcap : a⁻¹ ≤ Real.exp Pcap) (hδPcap : δ⁻¹ ≤ Real.exp Pcap) + (hprincipal : ∀ j : {a // ¬grid a}, a ≤ unitProfilePrincipalSize (B := B) j.val) + (hw : ∀ j p, δ ≤ width j p) (hl : ∀ j p, 0 ≤ lower j p) + (hε : 0 < ε) (hHP : (4 : ℝ) ≤ Real.exp P) (hεP : ε⁻¹ ≤ Real.exp P) : + let p := slicedGridGeometryLog Dg vg wg tg + pg + let L := fun j : Fin m => fun e : ℝ => slicedGridSiteLog j.val (rowSets j).card + ((layerTailDegree m + 1) * (rowSets j).card) ((j.val + 1) * (rowSets j).card) Dg p e + let Cp := ∑ j, (L j 0 + Dg * (vg + 1)) + let Eg' := uniformProductAccuracyLog Dg Cp Eg + Dg * (vg + 1) + 1 + let Op := ∑ j, (siteExponentialOutputLog (Fintype.card (Finset (Fin 1))) (L j Eg') + (Dg + 1) * (vg + 1)) + ∃ e : gridAxes → ScalarSiteExpansion.{0,0} (Finset (Fin 1)), + (∀ a, (e a).Bounds (Real.exp Op) (Real.exp Op) (Real.exp Op) + ⟨Real.exp Op, Real.exp_nonneg _⟩ (Real.exp (slicedGridGeometryLog Dg vg wg tg + (Dg + vg + 8)))) ∧ + ∀ (x : G → IntegerScalarCubeBox (Fin 1) S.value) + {Mk : ℕ} (_hMk : 0 < Mk) (selection : Fin 1 ↪ G) + (_hx : GoodScalarKernelTuple selection (1 / (Mk : ℝ)) Mk x), + ∃ candidate : Fin Mk, + let period := kernelPeriodCandidate (m + 1) candidate + (∀ root : G → ℤ, integerScalarLattice (Unit ⊕ Fin 1) (period : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + ∀ (y₀ : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin 1) (allocatedPrincipalSides B U b S)) + (d : ℕ) [NeZero d] (_hdiv : period ∣ d) (_hqperiod : period ∣ q) + (_hu₀ : (containedSupportedProgressionAxisLaw B (layerSamplerDegree I n) + (allocatedPrincipalSides B U b S) H step c (allocatedPrincipalSides_pos B U b S) hH hsubset q label hcell + (allocatedGridAxis (I := I) U b S.value)).weight (principalAxisRestrict (allocatedGridAxis (I := I) U b S.value) y₀) ≠ 0) + (_hy₀ : ∀ j, IntegerScalarCube (allocatedPrincipalSides B U b S j) (fun a => (y₀ j a : ℤ))), + let cutoffLip : ℝ≥0 := Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / 4 + let Q := slicedJointDensityLogBudget O m P + P + let A := Real.exp ((2 * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8) + Q) + let maskCap := (layerKernelIndexBound m Mk : ℝ) ^ Fintype.card (LayerSamplerAxis I n) * coefficientDeckPeriodCap rowTypes E period + ∃ k : ℕ, (k : ℝ) ≤ Real.exp (4 * Q + 8) ∧ + (Fintype.card (Finset (Fin 1) × LayerSamplerAxis I n → Fin k) : ℝ) ≤ + Real.exp ((2 * Fintype.card (LayerSamplerAxis I n) : ℕ) * (4 * Q + 8)) ∧ + ∃ (a : (Finset (Fin 1) × LayerSamplerAxis I n → Fin k) → ℂ) + (f : (Finset (Fin 1) × LayerSamplerAxis I n → Fin k) → Finset (Fin 1) → (LayerSamplerAxis I n → ℝ) → ℂ), + (∑ i, ‖a i‖) ≤ A ∧ + (∀ i s v, ‖f i s v‖ ≤ 1) ∧ + (∀ i s, LipschitzWith (⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) (f i s)) ∧ + (∀ i s v, (∃ j, (4 : ℝ) < |v j|) → f i s v = 0) ∧ + (∑ label : Finset (Fin 1) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)), ∑ i, + ‖allocatedProductMaskedIdealCoefficient B U b S rowSets x y₀ q d period a label i‖) ≤ + ‖inverseNormalizer‖ * ((Fintype.card ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period)) : ℝ) ^ Fintype.card (Finset (Fin 1)) * maskCap * A) ∧ + (∀ label i s y, + ‖allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s) y‖ ≤ 1) ∧ + (∀ label i s, Measurable (allocatedMaskedSiteChartFactor B U b S o hb bW d r hr period label (f i s))) ∧ + Measurable (allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖allocatedProductFullGridPrefactor B U b S rowSets d r hr x hb o bW q y₀ + (allocatedSlicedRowIdeal B U b S rowSets hR (goodKernelOneCubeAllRows m) hB lower width) y - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y‖ ≤ + ‖inverseNormalizer‖ * maskCap * ε) ∧ + (∀ y : EuclideanJetLayers U rowTypes, + ‖((gridLaw).mean (fun u => allocatedWholeMaskedCoveredProfile B U b hR hσ S x rows hb o bW d + (principalAxisJoin grid u (principalAxisRestrict (fun a => ¬grid a) y₀)) q ideal y) : ℂ) - + allocatedProductChartIdealApproximation B U b S rowSets x y₀ q d period r hr hb o bW a f y * + allocatedFullGridChartModel B U b S rowSets d hb o bW e y‖ ≤ + ‖inverseNormalizer‖ * maskCap * + (Real.exp (slicedJointDensityLogBudget O m Pcap) * εgrid + ε * ∏ _a : gridAxes, Real.exp Op)) ∧ + ∀ {X : Type*} (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (hm : ∀ j e, coefficients (poly j) e ∈ U j), + let Lcoord : ℝ≥0 := K * ∑ j, Cforward j * Fintype.card (J j) + let Llong : ℝ≥0 := (Fintype.card (LayerSamplerAxis I n) * normalizedSiteCutoffBound / (2 * r)) * Lcoord + + max ((⟨Real.exp (Fintype.card (LayerSamplerAxis I n) + 6 * Q + 12), Real.exp_nonneg _⟩ + cutoffLip) * Lcoord * (Mk ^ (m + 1) : ℝ≥0)) (4 * (Mk ^ (m + 1) : ℝ≥0)) + let Lprimitive : ℝ≥0 := ⟨Real.exp Op, Real.exp_nonneg Op⟩ + let Lgrid : ℝ≥0 := max ((((Fintype.card gridAxes : ℝ≥0) * Lprimitive) * Qgrid) * + Lcoord * Lprimitive ^ Fintype.card gridAxes) (4 * Lprimitive ^ Fintype.card gridAxes) + ∃ g : (Finset (Fin 1) → ((∀ j, Fin (n j) → ZMod period) × (∀ j, E j → ZMod period))) → + (Finset (Fin 1) × LayerSamplerAxis I n → Fin k) → (∀ a, (e a).Term) → Finset (Fin 1) → + (((JetAmbientIndex (fun _ : Fin m => Unit) J → UnitAddCircle) × ((Σ j, J j) → UnitAddCircle)) × + ((Σ j, J j) → UnitAddCircle)) → ℂ, + (∀ label i kg t, LipschitzWith (Llong + Lgrid) (g label i kg t)) ∧ + (∀ label i kg t z, ‖g label i kg t z‖ ≤ 1) ∧ + AllocatedModelPhysicalExpansionIdentity B U b S x y₀ q d period r hr hb o bW e a f poly hm g := by + intro p L Cp E' Op + obtain ⟨e, heb, he⟩ := exists_allocated_supported_sliced_uniform_physical_source + B U b S q r hr hb o bW hR C hC hchart hbudget hB lower width hσ H step c hH hsubset label hcell + Cforward hforward K hK Qgrid hQgrid hq hδg hdenseg Tg hQTg hstep Ag hAg Pg hPg hcP hsP + hstride hBa hBi hDg hvg hwg htg hpg hEg hcube hdegree hrowsD htail hblocks hRv hRi hδw hTg + hcoeff hPp₀ haxes hεgrid hεgridEg hσgrid T hT h4 hsource hradius hσ1 O hO hwidth ha hδ hP + haP hδP hPcap haPcap hδPcap hprincipal hw hl hε hHP hεP + refine ⟨e, heb, ?_⟩ + intro x Mk hMk selection hx + obtain ⟨candidate, hspatial, hperiodAll⟩ := + goodKernel_periodFamily_uniform_rows selection x hx (m + 1) (by omega) + refine ⟨candidate, hspatial, ?_⟩ + intro y₀ d hd hdiv hqperiod hu₀ hy₀ + let period := kernelPeriodCandidate (m + 1) candidate + have hperiod (j : Fin m) : integerScalarLattice (rowTypes j) (period : ℤ) ≤ + (scalarKernelIntegerJet x (j.val + 1) (Subtype.val : rowTypes j → Finset (Fin 1))).mulVecLin.range := + hperiodAll _ _ (by omega) _ Subtype.val_injective + (fun t => (mem_boundedBooleanJetRows (j.val + 1) t.val).mp t.property) + have hM : (1 : ℝ) ≤ (layerKernelIndexBound m Mk : ℝ) := by + exact_mod_cast (Nat.one_le_pow _ _ (by omega : 1 ≤ Mk)) + have hmask := fun j z => allocatedIntegerKernelMask_bound B U b S x rows hMk selection hx + (by simp) (fun _ => Subtype.val_injective) + (fun j t => (mem_boundedBooleanJetRows (j.val + 1) t.val).mp t.property) j q + (integerResidueMatrix (allocatedNonkernelJetMatrix B U b S x + (principalAxisRestrict grid y₀) rows j (principalAxisRestrict (fun a => ¬grid a) y₀)) q) z + have hqimage := fun j => (integerScalarLattice_le_of_nat_dvd hqperiod).trans (hperiod j) + obtain ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr, hphysical⟩ := + he x y₀ d period hdiv hperiod hM hmask hu₀ hqimage hy₀ + refine ⟨k, hk, hcard, a₀, f, ha₀, hf, hLf, hs, hc, hfn, hfm, hmeas, hlong, herr, ?_⟩ + intro X poly hp hm Lcoord Llong Lprimitive Lgrid + obtain ⟨g, hg, hgb, hidentity⟩ := hphysical poly hp hm + refine ⟨g, ?_, hgb, hidentity⟩ + intro label i kg t + apply (hg label i kg t).weaken + have hper : (period : ℝ≥0) ≤ (Mk ^ (m + 1) : ℝ≥0) := by + exact_mod_cast kernelPeriodCandidate_le (m + 1) candidate + apply add_le_add _ le_rfl + exact add_le_add le_rfl (max_le_max (mul_le_mul_of_nonneg_left hper zero_le) + (mul_le_mul_of_nonneg_left hper zero_le)) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedUniformMixtureProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedUniformMixtureProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cc8654ed01edf60ad8d324bb0586a603dc31c15 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedUniformMixtureProjection.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedOriginalSourceProjection + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel MeasureTheory +open scoped BigOperators Classical NNReal + +universe uX + +theorem exists_allocated_uniform_mixture_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + (hb : ∀ j, Submodule.span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C Vcap : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ≤ Vcap j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + {P W : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + (_hm : (m : ℝ) ≤ P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (Vcap j : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + {X : Type uX} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ ε : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (_hε : 0 < ε) (_hεP : ε⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty), + let density := allocatedCoefficientDensity B U basis hb o hR hσ S + ∀ (D : ℕ) + (f : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) + (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, 0} U + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) D density (f y)) + {η : ℝ} (_hη : 0 < η) (_hηP : η⁻¹ ≤ Real.exp P) + {Z : ℝ} (_hZnorm : 0 < Z), + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + ∀ (hV : ∀ z, 0 < V z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride T V z), + let law := principalTupleWeights (α := Fin q) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) + let source := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) * + (density (affineSampleCoefficientTorus U + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) : ℂ)) + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + physicalCubePositiveTest U D p hm (f y) test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) + ‖law.complexMean source / (Z : ℂ) - law.complexMean projected / (Z : ℂ)‖ ≤ (2 * η + ε) / Z := by + obtain ⟨A₀, _, hprojection⟩ := exists_allocated_mixture_density_projection m q + obtain ⟨b, _, hfourierBound⟩ := exists_allocatedFourierOutputBudget_bound m + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget + (((Polynomial.X + Polynomial.C b) ^ b + Polynomial.X + Polynomial.C A₀) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ _ n B _ _ _ J _ U basis R σ S c x hb o hR hσ C Vcap hC hV hσ1 + Cinv hCinv hchart hsmall P W hP hK hW hroot hWP hL hm₀ hRP hσP hcount hI hn hJ + hAP hCP hVP M hperiod X _ _ hX hdim p hp hm base stride hs hsP + τ ξ ε hτ hτP hξ hξ1 hξP hε hεP N hsize rank hrank hRank test htest T hT + density D f hproject η hη hηP Z hZnorm V hVpos hmass law source projected + let Q := allocatedFourierOutputBudget m P + P + have hlog := allocatedFourierLogBudget_nonneg m hP + have hF0 : 0 ≤ allocatedFourierOutputBudget m P := by + unfold allocatedFourierOutputBudget + positivity + have hPQ : P ≤ Q := le_add_of_nonneg_left hF0 + have hFQ : allocatedFourierOutputBudget m P ≤ Q := le_add_of_nonneg_right hP + have hQ : 0 ≤ Q := hP.trans hPQ + have hcost : (Q + A₀) ^ A₀ ≤ (P + A) ^ A := by + calc + _ ≤ ((P + b) ^ b + P + A₀) ^ A₀ := + pow_le_pow_left₀ (by positivity) (by dsimp [Q]; linarith [hfourierBound P hP]) A₀ + _ ≤ _ := by simpa [Polynomial.eval₂_pow] using hbudget P hP + obtain ⟨F, inst, frequency, coeff, _, hfrequency, hcoeff, happrox⟩ := + exists_allocated_coefficient_uniform_fourier B U basis hb o S C Vcap hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall hP hm₀ hK hRP hσP hcount hI hn hJ + hAP hL hCP hVP hη hηP + let _ := inst + have houtputs := allocatedFourierOutputBudget_dominates m hP + have he := Real.exp_le_exp.mpr hPQ + exact hprojection B U basis S c x hQ (hK.trans hPQ) hW hroot (hWP.trans he) (hL.trans he) + hperiod (hX.trans hPQ) (hdim.trans hPQ) frequency + (fun a j e he' t => (hfrequency a j e he' t).trans + (Real.exp_le_exp.mpr (houtputs.2.1.trans hFQ))) coeff + (hcoeff.trans (Real.exp_le_exp.mpr (houtputs.2.2.trans hFQ))) p hp hm base stride hs + (fun t => (hsP t).trans he) hτ (hτP.trans he) hξ hξ1 (hξP.trans he) + hε (hεP.trans he) N (fun t => (Real.exp_le_exp.mpr hcost).trans (hsize t)) hrank + ((Real.exp_le_exp.mpr hcost).trans hRank) test htest T hT density D f hproject + hη.le happrox hZnorm hVpos hmass + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AllocatedUniformMixtureProjectionLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedUniformMixtureProjectionLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..20769bb6bf38df837092ace9d857f369a4300b94 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AllocatedUniformMixtureProjectionLaw.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedOriginalSourceProjection + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel MeasureTheory +open scoped BigOperators Classical NNReal + +universe uX + +theorem exists_allocated_uniform_mixture_projection_law (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {G : Type*} [Fintype G] [DecidableEq G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] + [DecidableEq (LayerSamplerVariables G I n B)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + (c : LayerSamplerVariables G I n B → ℤ) (x : G → IntegerScalarCubeBox (Fin q) S.value) + (hb : ∀ j, Submodule.span ℤ (Set.range (basis j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (C Vcap : Fin m → ℝ≥0) + (_hC : ∀ j z, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j) z‖ ≤ C j * ‖z‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (basis j) ≤ Vcap j) + (_hσ1 : ∀ j, σ j ≤ 1) (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j z, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm z‖ ≤ Cinv j * ‖z‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ) + 1) * R j ≤ 1 / 4) + {P W : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P) + (_hW : 0 ≤ W) (_hbudget : allocatedPhysicalRootBudget B U basis S c ≤ W) + (_hWP : W ≤ Real.exp P) (_hL : (S.value : ℝ) ≤ Real.exp P) + (_hm : (m : ℝ) ≤ P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (_hcount : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (Vcap j : ℝ) ≤ Real.exp P) + {M : ℕ} (_hperiod : HasBoundedScalarPeriod (scalarCubeDifferenceMatrix x).mulVecLin.range M) + {X : Type uX} [Fintype X] [DecidableEq X] + (_hX : (Fintype.card X : ℝ) ≤ P) + (_hdim : (Fintype.card (Option (LayerSamplerVariables G I n B) × X) : ℝ) ≤ P) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : X → ℤ) + (stride : X → ℕ) (_hs : ∀ d, 0 < stride d) (_hsP : ∀ d, (stride d : ℝ) ≤ Real.exp P) + {τ ξ ε : ℝ} (_hτ : 0 < τ) (_hτP : τ⁻¹ ≤ Real.exp P) + (_hξ : 0 < ξ) (_hξ1 : ξ ≤ 1) (_hξP : ξ⁻¹ ≤ Real.exp P) + (_hε : 0 < ε) (_hεP : ε⁻¹ ≤ Real.exp P) + (N : X → ℕ) (_hsize : ∀ d, Real.exp ((P + A) ^ A) ≤ (N d : ℝ)) + {rank : ℝ} (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) (fun d => (N d : ℝ)) rank (U j) (p j)) + (_hRank : Real.exp ((P + A) ^ A) ≤ rank) + (test : Finset (Fin q) → (X → ℝ) → ℂ) (_htest : ∀ s v, ‖test s v‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) (_hT : T.Nonempty), + let density := allocatedCoefficientDensity B U basis hb o hR hσ S + ∀ (D : ℕ) + (f : PrincipalIntegerTuples B (layerSamplerDegree I n) (Fin q) (allocatedPrincipalSides B U basis S) → + EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) + (_hproject : ∀ y, physicalDensityProjection.{_, _, uX, 0} U + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) D density (f y)) + {η : ℝ} (_hη : 0 < η) (_hηP : η⁻¹ ≤ Real.exp P) + {Z : ℝ} (_hZnorm : 0 < Z), + let V := narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + ∀ (hV : ∀ z, 0 < V z) (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride T V z), + ∀ law : FiniteProbabilityWeights (PrincipalIntegerTuples B (layerSamplerDegree I n) + (Fin q) (allocatedPrincipalSides B U basis S)), + let source := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) * + (density (affineSampleCoefficientTorus U + (fun j => translate (fun t => (base t : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun t => (base t : ℝ)) (p j) (hm j)) + (fun k t => (z (k, t) : ℝ))) : ℂ)) + let projected := fun y => ∑' z, + ((selectedResidueSmoothPMF stride T V hV hmass z).toReal : ℂ) * + physicalCubePositiveTest U D p hm (f y) test (physicalCubeRootDifferences + (allocatedPhysicalCubeRoot B U basis S c x y) + (allocatedPhysicalCubeDirections B U basis S x y) base z) + ‖law.complexMean source / (Z : ℂ) - law.complexMean projected / (Z : ℂ)‖ ≤ (2 * η + ε) / Z := by + obtain ⟨A₀, _, hprojection⟩ := exists_allocated_mixture_density_projection_law m q + obtain ⟨b, _, hfourierBound⟩ := exists_allocatedFourierOutputBudget_bound m + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget + (((Polynomial.X + Polynomial.C b) ^ b + Polynomial.X + Polynomial.C A₀) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro G _ _ I _ _ n B _ _ _ J _ U basis R σ S c x hb o hR hσ C Vcap hC hV hσ1 + Cinv hCinv hchart hsmall P W hP hK hW hroot hWP hL hm₀ hRP hσP hcount hI hn hJ + hAP hCP hVP M hperiod X _ _ hX hdim p hp hm base stride hs hsP + τ ξ ε hτ hτP hξ hξ1 hξP hε hεP N hsize rank hrank hRank test htest T hT + density D f hproject η hη hηP Z hZnorm V hVpos hmass law source projected + let Q := allocatedFourierOutputBudget m P + P + have hlog := allocatedFourierLogBudget_nonneg m hP + have hF0 : 0 ≤ allocatedFourierOutputBudget m P := by + unfold allocatedFourierOutputBudget + positivity + have hPQ : P ≤ Q := le_add_of_nonneg_left hF0 + have hFQ : allocatedFourierOutputBudget m P ≤ Q := le_add_of_nonneg_right hP + have hQ : 0 ≤ Q := hP.trans hPQ + have hcost : (Q + A₀) ^ A₀ ≤ (P + A) ^ A := by + calc + _ ≤ ((P + b) ^ b + P + A₀) ^ A₀ := + pow_le_pow_left₀ (by positivity) (by dsimp [Q]; linarith [hfourierBound P hP]) A₀ + _ ≤ _ := by simpa [Polynomial.eval₂_pow] using hbudget P hP + obtain ⟨F, inst, frequency, coeff, _, hfrequency, hcoeff, happrox⟩ := + exists_allocated_coefficient_uniform_fourier B U basis hb o S C Vcap hC hV + hR hσ hσ1 Cinv hCinv hchart hsmall hP hm₀ hK hRP hσP hcount hI hn hJ + hAP hL hCP hVP hη hηP + let _ := inst + have houtputs := allocatedFourierOutputBudget_dominates m hP + have he := Real.exp_le_exp.mpr hPQ + exact hprojection B U basis S c x hQ (hK.trans hPQ) hW hroot (hWP.trans he) (hL.trans he) + hperiod (hX.trans hPQ) (hdim.trans hPQ) frequency + (fun a j e he' t => (hfrequency a j e he' t).trans + (Real.exp_le_exp.mpr (houtputs.2.1.trans hFQ))) coeff + (hcoeff.trans (Real.exp_le_exp.mpr (houtputs.2.2.trans hFQ))) p hp hm base stride hs + (fun t => (hsP t).trans he) hτ (hτP.trans he) hξ hξ1 (hξP.trans he) + hε (hεP.trans he) N (fun t => (Real.exp_le_exp.mpr hcost).trans (hsize t)) hrank + ((Real.exp_le_exp.mpr hcost).trans hRank) test htest T hT density D f hproject + hη.le happrox hZnorm hVpos hmass law + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AmplificationSourceRankBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/AmplificationSourceRankBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9411cf659917310c1e3f3040114770ae74e527e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AmplificationSourceRankBudget.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Estimates.AmplificationFinalCostGrowth + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +noncomputable def amplificationSourceRankLogConstant (b C : ℕ) (K : ℝ) : ℝ := + 1 + levelCoefficient K * Real.log b + C + +theorem amplificationSourceRankLogConstant_pos {b C : ℕ} {K : ℝ} + (hb : 1 ≤ b) (hK : 1 < K) : + 0 < amplificationSourceRankLogConstant b C K := by + have hb' : (1 : ℝ) ≤ b := by exact_mod_cast hb + have hprod := mul_nonneg (levelCoefficient_pos hK).le (Real.log_nonneg hb') + unfold amplificationSourceRankLogConstant + have := Nat.cast_nonneg (α := ℝ) C + linarith + +theorem log_linear_amplification_rank_le {b C d : ℕ} {K p : ℝ} + (hb : 1 ≤ b) (hK : 1 < K) (hp : 2 ≤ p) + (hd : d ≤ b ^ ⌊levelCoefficient K * Real.log p⌋₊ * ⌊(2 + p) ^ C⌋₊) : + Real.log ((d : ℝ) + 1) ≤ + amplificationSourceRankLogConstant b C K * Real.log (2 + p) := by + let j := ⌊levelCoefficient K * Real.log p⌋₊ + have hb' : (1 : ℝ) ≤ b := by exact_mod_cast hb + have hb0 : (0 : ℝ) < b := by linarith + have hbase : 1 ≤ (2 : ℝ) + p := by linarith + have hbase0 : 0 < (2 : ℝ) + p := by linarith + have hj : (j : ℝ) ≤ levelCoefficient K * Real.log p := + Nat.floor_le (mul_nonneg (levelCoefficient_pos hK).le (Real.log_nonneg (by linarith))) + have hfloor := Nat.floor_le (pow_nonneg hbase0.le C) + have hd' : (d : ℝ) ≤ (b : ℝ) ^ j * (2 + p) ^ C := by + have hcast : (d : ℝ) ≤ (b : ℝ) ^ j * (⌊(2 + p) ^ C⌋₊ : ℝ) := by + exact_mod_cast hd + exact hcast.trans (mul_le_mul_of_nonneg_left hfloor (pow_nonneg hb0.le _)) + have hone : 1 ≤ (b : ℝ) ^ j * (2 + p) ^ C := + one_le_mul_of_one_le_of_one_le (one_le_pow₀ hb') (one_le_pow₀ hbase) + have hlog := Real.log_le_log (by positivity : 0 < (d : ℝ) + 1) + (show (d : ℝ) + 1 ≤ 2 * ((b : ℝ) ^ j * (2 + p) ^ C) by linarith) + rw [Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) (by positivity), + Real.log_mul (by positivity) (by positivity), Real.log_pow, Real.log_pow] at hlog + have hjlog : (j : ℝ) * Real.log b ≤ + (levelCoefficient K * Real.log b) * Real.log (2 + p) := by + calc + (j : ℝ) * Real.log b ≤ (levelCoefficient K * Real.log p) * Real.log b := + mul_le_mul_of_nonneg_right hj (Real.log_nonneg hb') + _ = (levelCoefficient K * Real.log b) * Real.log p := by ring + _ ≤ (levelCoefficient K * Real.log b) * Real.log (2 + p) := + mul_le_mul_of_nonneg_left + (Real.log_le_log (by linarith : 0 < p) (by linarith)) + (mul_nonneg (levelCoefficient_pos hK).le (Real.log_nonneg hb')) + have htwo : Real.log 2 ≤ Real.log (2 + p) := + Real.log_le_log (by norm_num) (by linarith) + unfold amplificationSourceRankLogConstant + nlinarith + +theorem log_linear_amplification_rank_source {b C d : ℕ} {K p : ℝ} + (hb : 1 ≤ b) (hK : 1 < K) (hp : 2 ≤ p) + (hd : d ≤ b ^ ⌊levelCoefficient K * Real.log p⌋₊ * ⌊(2 + p) ^ C⌋₊) : + Real.log ((d : ℝ) + 1) ≤ amplificationSourceRankLogConstant b C K * + p ^ (levelCoefficient K * Real.log 1) * Real.log (2 + p) := by + simpa only [Real.log_one, mul_zero, Real.rpow_zero, mul_one] using + log_linear_amplification_rank_le hb hK hp hd + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AnchoredKernelInvariance.lean b/lean/OAI/Combinatorics/Progressions/Linear/AnchoredKernelInvariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..594c367d601f698cd2d16536791173993631a90f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AnchoredKernelInvariance.lean @@ -0,0 +1,125 @@ +import OAI.Combinatorics.Progressions.Estimates.PositiveShiftProductData + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +variable {ι J : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + +theorem refiltered_product_kernel_invariant (a : ι) + (W : LieSubalgebra ℚ (pi D).filtration.AssociatedGraded) + (eta : J → ∀ i, L i →ₗ[ℚ] ℚ) (S : (D a).Space → ℂ) + (hinvariant : ∀ z, z ∈ (D a).filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j a) z.coord = 0) → ∀ x, S (z • x) = S x) + (hfrequency : ∀ j x, x ∈ (pi D).filtration.realGradedRefiltrationLayer W s → + realifyFunctional (piFrequency (eta j)) x = 0) + (z : (pi D).RealGroup) (hz : z.coord ∈ (pi D).filtration.realGradedRefiltrationLayer W s) + (hkernel : ∀ i, i ≠ a → productProjectionHom D i z = 1) (x : (D a).Space) : + S (productProjectionHom D a z • x) = S x := by + have htop : z ∈ (pi D).filtration.realification.subgroup s := + (pi D).filtration.realGradedRefiltrationLayer_le W s hz + apply hinvariant _ (productProjectionHom_mem_layer D a s z htop) _ x + intro j + apply realify_component_zero_of_piFrequency_zero (eta j) a z.coord (hfrequency j z.coord hz) + intro i hi + have h := congrArg NilpotentLieBCHGroup.coord (hkernel i hi) + simpa only [productProjectionHom, NilpotentLieBCHGroup.realificationMap_coord, + NilpotentLieBCHGroup.coord_one] using h + +theorem refiltered_product_pullback_invariant (a : ι) + (W : LieSubalgebra ℚ (pi D).filtration.AssociatedGraded) + (eta : J → ∀ i, L i →ₗ[ℚ] ℚ) (S : (D a).Space → ℂ) + (hinvariant : ∀ z, z ∈ (D a).filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j a) z.coord = 0) → ∀ x, S (z • x) = S x) + (hfrequency : ∀ j x, x ∈ (pi D).filtration.realGradedRefiltrationLayer W s → + realifyFunctional (piFrequency (eta j)) x = 0) + (z : (pi D).RealGroup) (hz : z.coord ∈ (pi D).filtration.realGradedRefiltrationLayer W s) + (hkernel : ∀ i, i ≠ a → productProjectionHom D i z = 1) (x : (pi D).Space) : + S (productProjection D a (z • x)) = S (productProjection D a x) := by + rw [productProjection_smul] + exact refiltered_product_kernel_invariant D a W eta S hinvariant hfrequency z hz hkernel _ + +theorem refiltered_top_commutes + (W : LieSubalgebra ℚ (pi D).filtration.AssociatedGraded) + (z : (pi D).RealGroup) (hz : z.coord ∈ (pi D).filtration.realGradedRefiltrationLayer W s) + (g : (pi D).RealGroup) : Commute z g := + (pi D).filtration.realification.top_commutes z + ((pi D).filtration.realGradedRefiltrationLayer_le W s hz) g + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +variable {J : Type*} [Fintype J] {L : (Bool ⊕ (J × Bool)) → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : (Bool ⊕ (J × Bool)) → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (W : LieSubalgebra ℚ (pi D).filtration.AssociatedGraded) + (eta : J → L (.inl true) →ₗ[ℚ] ℚ) (theta : J → L (.inl false) →ₗ[ℚ] ℚ) + (alpha : ∀ j, L (.inr (j, true)) →ₗ[ℚ] ℚ) (beta : ∀ j, L (.inr (j, false)) →ₗ[ℚ] ℚ) + (hfrequency : ∀ j x, x ∈ (pi D).filtration.realGradedRefiltrationLayer W s → + realifyFunctional (piFrequency + (selectedOrbitFrequencies (anchoredFrequencyData eta theta alpha beta j) (anchoredInputs j))) x = 0) + +include hfrequency + +theorem anchored_kernel_frequency_zero + (z : (pi D).RealGroup) (hz : z.coord ∈ (pi D).filtration.realGradedRefiltrationLayer W s) + (hkernel : ∀ i, i ≠ .inl true → productProjectionHom D i z = 1) (j : J) : + realifyFunctional (eta j) (productProjectionHom D (.inl true) z).coord = 0 := by + have h := realify_component_zero_of_piFrequency_zero + (selectedOrbitFrequencies (anchoredFrequencyData eta theta alpha beta j) (anchoredInputs j)) + (.inl true) z.coord (hfrequency j z.coord hz) (fun i hi => by + have hk := congrArg NilpotentLieBCHGroup.coord (hkernel i hi) + simpa only [productProjectionHom, NilpotentLieBCHGroup.realificationMap_coord, + NilpotentLieBCHGroup.coord_one] using hk) + simpa [selectedOrbitFrequencies, anchoredFrequencyData, anchoredInputs, + productProjectionHom, NilpotentLieBCHGroup.realificationMap_coord] using h + +theorem anchored_kernel_observable_invariant + (S : (D (.inl true)).Space → ℂ) + (hinvariant : ∀ z, z ∈ (D (.inl true)).filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j) z.coord = 0) → ∀ x, S (z • x) = S x) + (z : (pi D).RealGroup) (hz : z.coord ∈ (pi D).filtration.realGradedRefiltrationLayer W s) + (hkernel : ∀ i, i ≠ .inl true → productProjectionHom D i z = 1) + (x : (D (.inl true)).Space) : + S (productProjectionHom D (.inl true) z • x) = S x := by + apply hinvariant _ (productProjectionHom_mem_layer D (.inl true) s z + ((pi D).filtration.realGradedRefiltrationLayer_le W s hz)) + exact anchored_kernel_frequency_zero D W eta theta alpha beta hfrequency z hz hkernel + +theorem anchored_frozen_observable_invariant + (S : (D (.inl true)).Space → ℂ) + (hinvariant : ∀ z, z ∈ (D (.inl true)).filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j) z.coord = 0) → ∀ x, S (z • x) = S x) + (E R b z : (pi D).RealGroup) + (hz : z.coord ∈ (pi D).filtration.realGradedRefiltrationLayer W s) + (hkernel : ∀ i, i ≠ .inl true → productProjectionHom D i z = 1) : + S (QuotientGroup.mk (productProjectionHom D (.inl true) (E * (z * b) * R))) = + S (QuotientGroup.mk (productProjectionHom D (.inl true) (E * b * R))) := by + have hcommute := refiltered_top_commutes D W z hz E + have heq : E * (z * b) * R = z * (E * b * R) := by + calc + E * (z * b) * R = (E * z) * b * R := by simp only [mul_assoc] + _ = (z * E) * b * R := by rw [hcommute.eq] + _ = z * (E * b * R) := by simp only [mul_assoc] + rw [heq, map_mul] + exact anchored_kernel_observable_invariant D W eta theta alpha beta hfrequency S hinvariant + z hz hkernel (QuotientGroup.mk (productProjectionHom D (.inl true) (E * b * R))) + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AnisotropicGoodKernelComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/AnisotropicGoodKernelComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a3ed1356f952d16fba2a9188a82f067fc96b215 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AnisotropicGoodKernelComparison.lean @@ -0,0 +1,181 @@ +import OAI.Combinatorics.Progressions.Geometry.AnisotropicSpatialCapBudget + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators NNReal + +noncomputable def anisotropicSpatialDetAllowance (I : Type*) [Fintype I] (C : ℝ) : ℝ := + (Fintype.card (Unit ⊕ I)).factorial * C ^ Fintype.card (Unit ⊕ I) + +noncomputable def anisotropicSpatialMeshThreshold {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (N : Type*) [Fintype N] (C : ℝ) : ℝ := + 2 * (1 + 4 ^ (Fintype.card (Unit ⊕ I) + Fintype.card (UnselectedColumn s ⊕ N)) * + ((Fintype.card (UnselectedColumn s ⊕ N) + Fintype.card (Unit ⊕ I) : ℝ) * probabilityProfileLipschitz)) * + anisotropicSpatialDetAllowance I C + +noncomputable def anisotropicSpatialError {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (N : Type*) [Fintype N] (B : ℕ) (κ C ρ ξ : ℝ) : ℝ := + normalizedFiberErrorConstant (Fintype.card (Unit ⊕ I)) (Fintype.card (UnselectedColumn s ⊕ N)) + ((B : ℝ) ^ (Fintype.card I + 1)) (physicalSpatialInverseBound I κ) + (Fintype.card (UnselectedColumn s ⊕ N)) 1 1 + ((Fintype.card (UnselectedColumn s ⊕ N) + Fintype.card (Unit ⊕ I)) * probabilityProfileLipschitz) * + anisotropicSpatialDetAllowance I C / ρ + + (B : ℝ) ^ (Fintype.card I + 1) * + (spatialKernelErrorConstant (Fintype.card (Unit ⊕ I)) (Fintype.card (UnselectedColumn s)) + (physicalSpatialInverseBound I κ) 1 + ((Fintype.card (UnselectedColumn s) + Fintype.card (Unit ⊕ I)) * probabilityProfileLipschitz) * + (Fintype.card N * ξ)) + +theorem anisotropicSpatial_original_error {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (root : J → ℤ) (D : Matrix I J ℤ) (s : I ↪ J) + (C : Matrix (Unit ⊕ I) N ℤ) (Q : N → ℝ) + {A R L κ C₀ ρ ξ : ℝ} {B : ℕ} + (hA : 0 < A) (hR : 0 < R) (hL : 0 < L) (hκ : 0 < κ) (hρ : 0 < ρ) + (hC₀ : 1 ≤ C₀) (hr : ∀ j, |(root j : ℝ)| * R ≤ A) + (hD : ∀ i j, |(D i j : ℝ)| ≤ L) + (hrC : ∀ j, |(root j : ℝ)| ≤ C₀) (hDC : ∀ i j, |(D i j : ℝ)| ≤ C₀) + (hminor : κ ≤ |(Matrix.of (fun i j => (D i (s j) : ℝ) / L)).det|) + (hperiod : HasBoundedScalarPeriod D.mulVecLin.range B) + (hQ : ∀ j, 0 < Q j) (hξ0 : 0 ≤ ξ) (hξ1 : ξ ≤ 1) + (hC : ∀ i j, |(C i j : ℝ)| * Q j ≤ ξ * physicalSpatialOutputScale I A R L i) + (hscaleA : ρ ≤ A) (hscaleR : ρ ≤ R) (hscaleQ : ∀ j, ρ ≤ Q j) + (hmesh : anisotropicSpatialMeshThreshold s N C₀ ≤ ρ) : + let hp := (anisotropicSpatialPivot_control root D s hA hR hL hκ hr hD hminor).1 + ∀ v, |(∏ i, physicalSpatialOutputScale I A R L i) * + (anisotropicSpatialOutputLaw root D C A R Q hA hR hQ v).toReal - + maskedIntegerImageDensity (selectedSpatialPivot root D s) + (Matrix.fromCols (selectedSpatialFreeColumns root D s) C) (physicalSpatialOutputScale I A R L) + (anisotropicSpatialKernelDensity s root D hp A R L hA hR hL) v| ≤ + anisotropicSpatialError s N B κ C₀ ρ ξ := by + intro hp + let M := selectedSpatialPivot root D s + let M' := selectedSpatialFreeColumns root D s + let S := anisotropicSpatialScale I A R + let P := physicalSpatialOutputScale I A R L + let lip : ℝ≥0 := (Fintype.card (UnselectedColumn s ⊕ N) + Fintype.card (Unit ⊕ I)) * probabilityProfileLipschitz + have hS := anisotropicSpatialScale_pos I hA hR + have hP := physicalSpatialOutputScale_pos I hA hR hL + have hFree : ∀ j, 0 < Sum.elim (fun _ : UnselectedColumn s => R) Q j := by + rintro (j | j) + · exact hR + · exact hQ j + have hscaleS : ∀ i, ρ ≤ S i := by + rintro (i | i) + · exact hscaleA + · exact hscaleR + have hscaleFree : ∀ j, ρ ≤ Sum.elim (fun _ : UnselectedColumn s => R) Q j := by + rintro (j | j) + · exact hscaleR + · exact hscaleQ j + have hcoeff : ∀ i j, |(M i j : ℝ)| ≤ C₀ * (1 : ℝ) ^ 0 := by + intro i j + have heq : M = (physicalCubeCoefficient root D).submatrix id (physicalCubePivotIndex s) := + (physicalCubeCoefficient_pivot root D s).symm + rw [heq] + simpa only [Matrix.submatrix_apply, id_eq, pow_zero, mul_one] using + physicalCube_coefficient_bound root D hC₀ hrC hDC i (physicalCubePivotIndex s j) + have hdet : (M.det.natAbs : ℝ) ≤ anisotropicSpatialDetAllowance I C₀ := by + simpa only [anisotropicSpatialDetAllowance, one_pow, mul_one] using + integerPivot_polynomial_period_bound M 0 hcoeff + have hm := enormousCoefficient_mesh_conditions (j := Fintype.card (Unit ⊕ I)) (h := 0) + (D := anisotropicSpatialDetAllowance I C₀) + (Z := 4 ^ (Fintype.card (Unit ⊕ I) + Fintype.card (UnselectedColumn s ⊕ N)) * (lip : ℝ)) + (L := 1) (H := ρ) (by unfold anisotropicSpatialDetAllowance; positivity) (by positivity) + (by norm_num) hρ (by + simpa only [anisotropicSpatialMeshThreshold, lip, NNReal.coe_mul, NNReal.coe_add, + NNReal.coe_natCast, one_pow, mul_one] using hmesh) + simp only [one_pow, mul_one, div_one] at hm + have hsmallMass : 4 ^ (Fintype.card (Unit ⊕ I) + Fintype.card (UnselectedColumn s ⊕ N)) * + (lip : ℝ) * ((M.det.natAbs : ℝ) / ρ) ≤ 1 / 2 := + (mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_right hdet hρ.le) (by positivity)).trans hm.2 + have hindex : ((pivotFullImage M (Matrix.fromCols M' C)).toAddSubgroup.index : ℝ) ≤ + (B : ℝ) ^ (Fintype.card I + 1) := by + exact_mod_cast selectedSpatial_extended_index root D s C hperiod + have hinv : ‖(normalizedPivotEquiv M hp S P hS hP).symm.toContinuousLinearMap‖ ≤ + physicalSpatialInverseBound I κ := by + rw [normalizedPivotEquiv_inverse_eq] + exact (anisotropicSpatialPivot_control root D s hA hR hL hκ hr hD hminor).2 + have hcol := anisotropicSpatial_free_norm_bound root D s C Q hA hR hL hξ1 + (fun j => (hQ j).le) hr hD hC + have hmove : ∀ n, smoothProductProfile N n ≠ 0 → + ‖matrixSupCLM (normalizedIntegerColumns C Q P) n‖ ≤ Fintype.card N * ξ := by + apply supported_column_displacement _ _ (smoothProductProfile_zero_outside N) + simpa only [mul_one] using normalizedIntegerColumns_variable_norm_bound C Q P hP hξ0 + (fun j => (hQ j).le) hC + have hfull : LipschitzWith lip + (splitFreeProfile (smoothSplitProfile (UnselectedColumn s) (Unit ⊕ I)) (smoothProductProfile N)) := by + rw [splitFreeProfile_smooth] + exact smoothSplitProfile_lipschitz _ _ + have hbound : ∀ p, ‖splitFreeProfile + (smoothSplitProfile (UnselectedColumn s) (Unit ⊕ I)) (smoothProductProfile N) p‖ ≤ 1 := by + rw [splitFreeProfile_smooth] + exact smoothSplitProfile_norm_le _ _ + obtain ⟨hM, hpoint, _⟩ := normalizedSpatial_probability_comparison M hp M' C S P + (fun _ : UnselectedColumn s => R) Q hS hP hFree + (smoothSplitProfile (UnselectedColumn s) (Unit ⊕ I)) (smoothProductProfile N) + (fun p => (smoothSplitProfile_range _ _ p).1) (fun n => (smoothProductProfile_range _ n).1) + (smoothSplitProfile_lipschitz _ _) (smoothProductProfile_contDiff N).continuous hfull + 0 zero_le_one (mul_nonneg (Nat.cast_nonneg _) hξ0) hρ zero_le_one hscaleS hscaleFree + (hdet.trans hm.1) hcoeff (smoothSplitProfile_zero_outside _ _) (smoothProductProfile_zero_outside N) + (smoothSplitProfile_integral _ _) (smoothProductProfile_integral N) + (by simpa only [max_self, show (2 : ℝ) * 1 + 2 = 4 by norm_num] using hsmallMass) + hbound hindex hinv hcol hmove + rw [← smoothSelectedSpatial_anisotropic_law root D s C hA hR Q hQ] + simpa only [splitFreeProfile_smooth, max_self, one_pow, mul_one, lip, M, M', S, P, + smoothIntegerImagePMF, anisotropicSpatialError, anisotropicSpatialDetAllowance, + anisotropicSpatialKernelDensity] using hpoint + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators + +theorem goodScalarKernelTuple_anisotropic_error {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + {L B : ℕ} (hL : 0 < L) (s : I ↪ J) (x : J → IntegerScalarCubeBox I L) + (root : J → ℤ) (C : Matrix (Unit ⊕ I) N ℤ) (Q : N → ℝ) + {A R κ C₀ ρ ξ : ℝ} (hA : 0 < A) (hR : 0 < R) (hκ : 0 < κ) (hρ : 0 < ρ) + (hx : GoodScalarKernelTuple s κ B x) (hC₀ : 1 ≤ C₀) (hLC : (L : ℝ) ≤ C₀) + (hr : ∀ j, |(root j : ℝ)| * R ≤ A) (hrC : ∀ j, |(root j : ℝ)| ≤ C₀) + (hQ : ∀ j, 0 < Q j) (hξ0 : 0 ≤ ξ) (hξ1 : ξ ≤ 1) + (hC : ∀ i j, |(C i j : ℝ)| * Q j ≤ ξ * physicalSpatialOutputScale I A R L i) + (hscaleA : ρ ≤ A) (hscaleR : ρ ≤ R) (hscaleQ : ∀ j, ρ ≤ Q j) + (hmesh : anisotropicSpatialMeshThreshold s N C₀ ≤ ρ) : + let hp := goodScalarKernelTuple_spatial_det_ne_zero s x root hκ hx + ∀ v, |(∏ i, physicalSpatialOutputScale I A R L i) * + (anisotropicSpatialOutputLaw root (scalarCubeDifferenceMatrix x) C A R Q hA hR hQ v).toReal - + maskedIntegerImageDensity (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s) + (Matrix.fromCols (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s) C) + (physicalSpatialOutputScale I A R L) + (anisotropicSpatialKernelDensity s root (scalarCubeDifferenceMatrix x) hp A R L + hA hR (Nat.cast_pos.mpr hL)) v| ≤ anisotropicSpatialError s N B κ C₀ ρ ξ := by + intro hp + have hD : ∀ i j, |(scalarCubeDifferenceMatrix x i j : ℝ)| ≤ L := by + intro i j + have hi := Finset.mem_Ico.mp (x j (some i)).property + exact_mod_cast (abs_le.mpr ⟨hi.1, hi.2.le⟩) + have hminor : κ ≤ |(Matrix.of (fun i j => (scalarCubeDifferenceMatrix x i (s j) : ℝ) / (L : ℝ))).det| := by + change κ ≤ |(normalizedScalarCubePivot s x).det| + rw [normalizedScalarCubePivot_det] + exact hx.1.le + exact anisotropicSpatial_original_error root (scalarCubeDifferenceMatrix x) s C Q + hA hR (Nat.cast_pos.mpr hL) hκ hρ hC₀ hr hD hrC (fun i j => (hD i j).trans hLC) + hminor hx.2 hQ hξ0 hξ1 hC hscaleA hscaleR hscaleQ hmesh + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AntisymmetricPairProjectionBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/AntisymmetricPairProjectionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..299ecbf529928a1ad86b5a7613f39411819ce092 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AntisymmetricPairProjectionBounds.lean @@ -0,0 +1,125 @@ +import OAI.Combinatorics.Progressions.Estimates.AntisymmetricPairVerticalModel + +namespace OAI + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold +open scoped BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +theorem exists_antisymmetric_pair_projection_control : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p q r : ℝ} + {W : NativeMultidegreeNilcharacter (mixedCorrelationDegree 1) p} + {N : ℕ} [NeZero N] {i j : Fin W.outputDim} + {V : NativeSampleCorrelation (fun _ : Fin 2 => 1) 1 q + Finset.univ (fun z : Fin 2 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.antisymmetricKernel i j ((z 0).val : ℤ) ((z 1).val : ℤ))} + (R : NativePolynomialOrbitFactors (pi V.antisymmetricPairModels) + V.antisymmetricPairPolynomial (piFrequency V.antisymmetricPairFrequencies) + (fun _ : Fin 2 => (N : ℝ)) r), 0 ≤ r → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + q + r + C) ^ C) ∧ + ∀ k : Fin 2, + W.model.filtration.PolynomialRationalGrid W.model.basis (fun _ : Fin 2 => 1) m + (V.antisymmetricPairPolynomialMap k R.rational) ∧ + W.model.filtration.PolynomialSlowBound W.model.basis (fun _ : Fin 2 => 1) + (fun _ => (N : ℝ)) (Real.exp ((p + q + r + C) ^ C)) + (V.antisymmetricPairPolynomialMap k R.slow) := by + obtain ⟨a, _, hcontrol⟩ := exists_native_orbit_coefficient_control + let X : Polynomial ℕ := Polynomial.X + let B := X + (X + (X + 2) ^ 2 + 3) + 4 + let T := (B + 2) ^ 2 + B + (B + (B ^ 2 + B + 3) ^ 2) + B ^ 2 + 4 + X + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((T + Polynomial.C a) ^ a) + refine ⟨C, hC, ?_⟩ + intro p q r W N _ i j V R hr + have hp : 0 ≤ p := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + have hq : 0 ≤ q := (Nat.cast_nonneg V.dim).trans V.complexity.1.1 + let u := p + q + r + let b := u + raisedNiltestBudget u + 4 + let t := productNiltestBudget b + u + 2 + have hu : 0 ≤ u := by dsimp [u]; positivity + have hpqu : p + q ≤ u := le_add_of_nonneg_right hr + have hb : 0 ≤ b := by dsimp [b, raisedNiltestBudget]; positivity + have hprod : 0 ≤ productNiltestBudget b := by + unfold productNiltestBudget productObservableLipBudget + positivity + have ht : 0 ≤ t := by dsimp [t]; positivity + have hrt : r ≤ t := by dsimp [t, u]; linarith + have hBt : antisymmetricPairBudget p q ≤ b := by + dsimp [antisymmetricPairBudget, b, raisedNiltestBudget] + gcongr + have hB0 : 0 ≤ antisymmetricPairBudget p q := + (by norm_num : (0 : ℝ) ≤ 4).trans V.antisymmetricPairBudget_four_le + have hprodmono : productNiltestBudget (antisymmetricPairBudget p q) ≤ productNiltestBudget b := by + unfold productNiltestBudget productObservableLipBudget + gcongr + have htest : productNiltestBudget (antisymmetricPairBudget p q) ≤ t := + hprodmono.trans (by dsimp [t]; linarith) + let D := pi V.antisymmetricPairModels + have hD : D.GeometryComplexityLE t := by + apply (pi_geometry V.antisymmetricPairModels hB0 + (by simpa using (show (3 : ℝ) ≤ antisymmetricPairBudget p q from + (by norm_num : (3 : ℝ) ≤ 4).trans V.antisymmetricPairBudget_four_le)) + (fun k => (V.antisymmetricPairTests_complexity k).1)).mono D + exact (productNiltestBudget_geometry hB0).trans htest + have hcost : (t + a) ^ a ≤ (p + q + r + C) ^ C := by + simpa [X, B, T, t, b, u, raisedNiltestBudget, productNiltestBudget, + productObservableLipBudget, Polynomial.eval₂_pow] using hbudget u hu + have hN : ∀ _k : Fin 2, (0 : ℝ) < N := fun _ => Nat.cast_pos.mpr (NeZero.pos N) + obtain ⟨m, hm, hmb, hrat, hslow⟩ := hcontrol (R.mono hrt hN) ht hD hN + refine ⟨m, hm, hmb.trans (Real.exp_le_exp.mpr hcost), ?_⟩ + intro k + have hs := NilpotentLieFiltration.realPolynomialGroupMap_slow D.basis W.model.basis + (V.antisymmetricPairProjection k) (V.antisymmetricPairCoordinateIndex k) + (V.antisymmetricPairProjection_repr k) D.filtration W.model.filtration + (V.antisymmetricPairProjection_layers k) (fun _ : Fin 2 => 1) + (fun _ => (N : ℝ)) (Real.exp ((t + a) ^ a)) R.slow hslow + exact ⟨NilpotentLieFiltration.realPolynomialGroupMap_rational D.basis W.model.basis + (V.antisymmetricPairProjection k) (V.antisymmetricPairCoordinateIndex k) + (V.antisymmetricPairProjection_repr k) D.filtration W.model.filtration + (V.antisymmetricPairProjection_layers k) (fun _ : Fin 2 => 1) m R.rational hrat, + W.model.filtration.polynomialSlowBound_mono W.model.basis (fun _ : Fin 2 => 1) + (fun _ => (N : ℝ)) hN (Real.exp_le_exp.mpr hcost) _ hs⟩ + +namespace NativePolynomialOrbitFactors + +variable {p q r : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (mixedCorrelationDegree 1) p} {i j : Fin W.outputDim} + {V : NativeSampleCorrelation (fun _ : Fin 2 => 1) 1 q + Finset.univ (fun z : Fin 2 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.antisymmetricKernel i j ((z 0).val : ℤ) ((z 1).val : ℤ))} + (R : NativePolynomialOrbitFactors (pi V.antisymmetricPairModels) + V.antisymmetricPairPolynomial (piFrequency V.antisymmetricPairFrequencies) + (fun _ : Fin 2 => (N : ℝ)) r) + +def HasPairProjectionControl (b : ℝ) : Prop := + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp b ∧ ∀ k : Fin 2, + W.model.filtration.PolynomialRationalGrid W.model.basis (fun _ : Fin 2 => 1) m + (V.antisymmetricPairPolynomialMap k R.rational) ∧ + W.model.filtration.PolynomialSlowBound W.model.basis (fun _ : Fin 2 => 1) + (fun _ => (N : ℝ)) (Real.exp b) (V.antisymmetricPairPolynomialMap k R.slow) + +theorem hasPairProjectionControl_mono {a b : ℝ} (h : R.HasPairProjectionControl a) (hab : a ≤ b) : + R.HasPairProjectionControl b := by + obtain ⟨m, hm, hmb, hproj⟩ := h + refine ⟨m, hm, hmb.trans (Real.exp_le_exp.mpr hab), ?_⟩ + intro k + exact ⟨(hproj k).1, W.model.filtration.polynomialSlowBound_mono W.model.basis + (fun _ : Fin 2 => 1) (fun _ => (N : ℝ)) (fun _ => by exact_mod_cast NeZero.pos N) + (Real.exp_le_exp.mpr hab) _ (hproj k).2⟩ + +end NativePolynomialOrbitFactors + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AntisymmetricPairProjections.lean b/lean/OAI/Combinatorics/Progressions/Linear/AntisymmetricPairProjections.lean new file mode 100644 index 0000000000000000000000000000000000000000..a47a0c2ce58325ff29daf5ccc16231a1b9252b4f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AntisymmetricPairProjections.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.Progressions.Polynomial.AntisymmetricPairPolynomial +import OAI.Combinatorics.Progressions.Polynomial.ProductPolynomialMaps + +namespace OAI + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +namespace NativeMultidegreeNilcharacter + +variable {p : ℝ} (W : NativeMultidegreeNilcharacter (mixedCorrelationDegree 1) p) + +noncomputable def pairComponentPolynomial (out : Fin W.outputDim) (a b : Fin 2) : + (W.model.filtration.realification.adaptedPolynomialFiltration (fun _ : Fin 2 => 1)).Group := + ⟨⟨(W.pairComponent out a b).orbit.log, (W.pairComponent out a b).orbit.property⟩⟩ + +theorem pairComponentPolynomial_out_eq (i j : Fin W.outputDim) (a b : Fin 2) : + W.pairComponentPolynomial i a b = W.pairComponentPolynomial j a b := rfl + +end NativeMultidegreeNilcharacter + +namespace NativeSampleCorrelation + +variable {p q : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (mixedCorrelationDegree 1) p} {i j : Fin W.outputDim} + (V : NativeSampleCorrelation (fun _ : Fin 2 => 1) 1 q + Finset.univ (fun z : Fin 2 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.antisymmetricKernel i j ((z 0).val : ℤ) ((z 1).val : ℤ))) + +theorem antisymmetricPairProjection_layers (k : Fin 2) (a : ℕ) + (x : V.AntisymmetricPairAlgebra) (hx : x ∈ (pi V.antisymmetricPairModels).filtration.layer a) : + V.antisymmetricPairProjection k x ∈ W.model.filtration.layer a := + (NilpotentLieFiltration.mem_pi_layer (fun l => (V.antisymmetricPairModels l).filtration) a x).mp hx (some k) + +noncomputable def antisymmetricPairPolynomialMap (k : Fin 2) : + ((pi V.antisymmetricPairModels).filtration.realification.adaptedPolynomialFiltration + (fun _ : Fin 2 => 1)).Group →* + (W.model.filtration.realification.adaptedPolynomialFiltration (fun _ : Fin 2 => 1)).Group := + (pi V.antisymmetricPairModels).filtration.realPolynomialGroupMap W.model.filtration + (V.antisymmetricPairProjection k) (V.antisymmetricPairProjection_layers k) (fun _ : Fin 2 => 1) + +theorem antisymmetricPairPolynomialMap_log (k : Fin 2) + (g : ((pi V.antisymmetricPairModels).filtration.realification.adaptedPolynomialFiltration + (fun _ : Fin 2 => 1)).Group) : + ((V.antisymmetricPairPolynomialMap k g).coord : VectorPolynomial (Fin 2) ℚ (ℝ ⊗[ℚ] W.L)) = + VectorPolynomial.map ((realificationLieHom (V.antisymmetricPairProjection k)).toLinearMap.restrictScalars ℚ) + (g.coord : VectorPolynomial (Fin 2) ℚ (ℝ ⊗[ℚ] V.AntisymmetricPairAlgebra)) := rfl + +theorem antisymmetricPairPolynomialMap_eq (k : Fin 2) (out : Fin W.outputDim) : + V.antisymmetricPairPolynomialMap k V.antisymmetricPairPolynomial = + W.pairComponentPolynomial out k k.rev := by + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + change VectorPolynomial.map ((realificationLieHom (liePiEval (some k))).toLinearMap.restrictScalars ℚ) + (NilpotentLieFiltration.piRealOrbit (fun l => (V.antisymmetricPairModels l).filtration) + (fun l => (V.antisymmetricPairTests l).orbit)).log = (W.pairComponent out k k.rev).orbit.log + rw [NilpotentLieFiltration.piRealOrbit_projection_log] + fin_cases k <;> rfl + +theorem antisymmetricPairPolynomialMap_constant (k : Fin 2) + (c : (pi V.antisymmetricPairModels).RealGroup) : + V.antisymmetricPairPolynomialMap k + ((pi V.antisymmetricPairModels).filtration.realification.adaptedConstantGroupHom + (fun _ : Fin 2 => 1) c) = + W.model.filtration.realification.adaptedConstantGroupHom (fun _ : Fin 2 => 1) + (productProjectionHom V.antisymmetricPairModels (some k) c) := + (pi V.antisymmetricPairModels).filtration.realPolynomialGroupMap_constant W.model.filtration + (V.antisymmetricPairProjection k) (V.antisymmetricPairProjection_layers k) (fun _ : Fin 2 => 1) c + +theorem antisymmetricPairProjection_lattice (k : Fin 2) + (c : (pi V.antisymmetricPairModels).RealGroup) (hc : c ∈ (pi V.antisymmetricPairModels).realLattice) : + productProjectionHom V.antisymmetricPairModels (some k) c ∈ W.model.realLattice := + NilpotentLieBCHGroup.realificationMap_subgroup _ _ _ + (productProjection_lattice V.antisymmetricPairModels (some k)) hc + +noncomputable def antisymmetricPairCoordinateIndex (k : Fin 2) (a : Fin W.dim) : + Fin (Fintype.card (Σ l : Option (Fin 2), Fin (optionDimension V.dim (fun _ : Fin 2 => W.dim) l))) := + Fintype.equivFin (Σ l : Option (Fin 2), Fin (optionDimension V.dim (fun _ : Fin 2 => W.dim) l)) ⟨some k, a⟩ + +theorem antisymmetricPairProjection_repr (k : Fin 2) (x : V.AntisymmetricPairAlgebra) (a : Fin W.dim) : + W.model.basis.repr (V.antisymmetricPairProjection k x) a = + (pi V.antisymmetricPairModels).basis.repr x (V.antisymmetricPairCoordinateIndex k a) := + productFinBasis_repr_component V.antisymmetricPairModels x (some k) a + +end NativeSampleCorrelation + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ApproxANOVAMomentScale.lean b/lean/OAI/Combinatorics/Progressions/Linear/ApproxANOVAMomentScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..5404afd50e3160c840f29c2697cde485c8566761 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ApproxANOVAMomentScale.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.Progressions.Results.Basic + +namespace OAI + +section + +namespace Erdos3 + +theorem anova_moment_coefficient {k : ℕ} (hk : 0 < k) {n R : ℝ} + (hn : 0 ≤ n) (h : 4 * n ≤ R ^ 2) : + Real.exp 1 * n ^ k ≤ R ^ (2 * k) := by + have he : Real.exp 1 ≤ (4 : ℝ) := Real.exp_one_lt_three.le.trans (by norm_num) + have hpow : (4 : ℝ) ≤ 4 ^ k := by + simpa only [pow_one] using pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 4) hk + calc + Real.exp 1 * n ^ k ≤ 4 ^ k * n ^ k := + mul_le_mul_of_nonneg_right (he.trans hpow) (pow_nonneg hn _) + _ = (4 * n) ^ k := (mul_pow _ _ _).symm + _ ≤ (R ^ 2) ^ k := pow_le_pow_left₀ (mul_nonneg (by norm_num) hn) h k + _ = R ^ (2 * k) := (pow_mul _ _ _).symm + +theorem anova_moment_scale {K p : ℝ} (hK : 1 ≤ K) (hp : 0 ≤ p) + {q k : ℕ} (hk : 0 < k) (hkP : (k : ℝ) ≤ p) (hqP : (q : ℝ) ≤ p + 2) : + Real.exp 1 * ((q * k : ℕ) : ℝ) ^ k ≤ (4 * (1 + K) * (p + 2)) ^ (2 * k) := by + apply anova_moment_coefficient hk (by positivity) + have hprod : ((q * k : ℕ) : ℝ) ≤ (p + 2) ^ 2 := by + rw [Nat.cast_mul] + have h := mul_le_mul hqP (show (k : ℝ) ≤ p + 2 by linarith) + (by positivity : 0 ≤ (k : ℝ)) (by linarith : 0 ≤ p + 2) + nlinarith + have hR : 2 * (p + 2) ≤ 4 * (1 + K) * (p + 2) := by nlinarith + nlinarith [sq_nonneg (4 * (1 + K) * (p + 2) - 2 * (p + 2))] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem approx_anova_moment_scale {K p : ℝ} (hK : 1 ≤ K) (hp : 0 ≤ p) + {q k : ℕ} (hk : 0 < k) (hkP : (k : ℝ) ≤ p) (hqP : (q : ℝ) ≤ p + 2) : + 2 * Real.exp 1 * ((q * k : ℕ) : ℝ) ^ k ≤ (8 * (1 + K) * (p + 2)) ^ (2 * k) := by + let D := 4 * (1 + K) * (p + 2) + have hD : 0 ≤ D := by dsimp [D]; positivity + have htwo : (2 : ℝ) ≤ 2 ^ (2 * k) := by + simpa only [pow_one] using pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) (by omega : 1 ≤ 2 * k) + calc + _ = 2 * (Real.exp 1 * ((q * k : ℕ) : ℝ) ^ k) := by ring + _ ≤ 2 * D ^ (2 * k) := mul_le_mul_of_nonneg_left (anova_moment_scale hK hp hk hkP hqP) (by norm_num) + _ ≤ 2 ^ (2 * k) * D ^ (2 * k) := mul_le_mul_of_nonneg_right htwo (pow_nonneg hD _) + _ = (2 * D) ^ (2 * k) := (mul_pow _ _ _).symm + _ = _ := by congr 1; dsimp [D]; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AssociatedGradedBasisIndependence.lean b/lean/OAI/Combinatorics/Progressions/Linear/AssociatedGradedBasisIndependence.lean new file mode 100644 index 0000000000000000000000000000000000000000..be33cf4c827a449ab8c4fca3f7ef75a9ea0b9ea6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AssociatedGradedBasisIndependence.lean @@ -0,0 +1,161 @@ +import OAI.Combinatorics.Progressions.Polynomial.RealCoordinatePolynomialSymbol + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +noncomputable def gradedPieceProjection (j : ℕ) : L →ₗ[ℚ] F.AssociatedGraded := + (F.associatedGradedBasis b ω hlayers).repr.symm.toLinearMap.comp + (b.repr.toLinearMap.comp (basisGradeProjection b ω j)) + +theorem gradedPieceProjection_coordinate (j : ℕ) (v : L) (i : ι) : + (F.associatedGradedBasis b ω hlayers).repr (F.gradedPieceProjection b ω hlayers j v) i = + if ω i = j then b.repr v i else 0 := by + simp only [gradedPieceProjection, LinearMap.comp_apply, LinearEquiv.coe_coe, + LinearEquiv.apply_symm_apply, basisGradeProjection_repr] + +theorem gradedPieceProjection_eq_pieceMap (j : ℕ) (v : F.layer j) : + F.gradedPieceProjection b ω hlayers j v = F.associatedGradedPieceMap j v := by + apply (F.associatedGradedBasis b ω hlayers).repr.injective + ext i + rw [F.gradedPieceProjection_coordinate, F.associatedGradedPieceMap_coordinate] + simp only [eq_comm] + +theorem gradedRefiltrationLayer_eq_inf_comap (U : LieSubalgebra ℚ F.AssociatedGraded) (j : ℕ) : + F.gradedRefiltrationLayer U j = + F.layer j ⊓ U.toSubmodule.comap (F.gradedPieceProjection b ω hlayers j) := by + ext v + rw [F.mem_gradedRefiltrationLayer, Submodule.mem_inf, Submodule.mem_comap] + constructor + · rintro ⟨hv, hU⟩ + exact ⟨hv, (F.gradedPieceProjection_eq_pieceMap b ω hlayers j ⟨v, hv⟩).symm ▸ hU⟩ + · rintro ⟨hv, hU⟩ + exact ⟨hv, F.gradedPieceProjection_eq_pieceMap b ω hlayers j ⟨v, hv⟩ ▸ hU⟩ + +theorem real_gradedPieceProjection_coordinate (j : ℕ) (v : ℝ ⊗[ℚ] L) (i : ι) : + ((F.associatedGradedBasis b ω hlayers).baseChange ℝ).repr + ((F.gradedPieceProjection b ω hlayers j).baseChange ℝ v) i = + if ω i = j then (b.baseChange ℝ).repr v i else 0 := by + induction v using TensorProduct.inductionOn with + | tmul a v => + rw [LinearMap.baseChange_tmul, Basis.baseChange_repr_tmul, + F.gradedPieceProjection_coordinate, Basis.baseChange_repr_tmul] + split_ifs <;> simp only [zero_smul] + | add v z hv hz => + simp only [map_add, Finsupp.add_apply, hv, hz] + split_ifs <;> simp only [add_zero] + +theorem realGradedSymbolPolynomial_coefficient_of_polynomial + (w : σ → ℕ) (p : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (α : σ →₀ ℕ) : + coefficients (F.realGradedSymbolPolynomial b ω hlayers w + (F.realSymbolOfPolynomial b ω hlayers w p)) α = + (F.gradedPieceProjection b ω hlayers (Finsupp.weight w α)).baseChange ℝ (coefficients p α) := by + apply ((F.associatedGradedBasis b ω hlayers).baseChange ℝ).repr.injective + ext i + rw [F.real_gradedPieceProjection_coordinate] + by_cases h : Finsupp.weight w α = ω i + · rw [ite_eq_left h.symm] + exact (F.realGradedSymbolPolynomial_coordinate b ω hlayers w _ ⟨(α, i), h⟩).trans + (F.realSymbolOfPolynomial_coordinate b ω hlayers w p ⟨(α, i), h⟩) + · rw [ite_eq_right (Ne.symm h)] + exact F.realGradedSymbolPolynomial_coordinate_of_ne b ω hlayers w _ α i h + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L ι κ : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hb : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem associatedGradedPieceMap_repr_symm (j : ℕ) (x : F.layer j) : + b.repr.symm ((F.associatedGradedBasis b ω hb).repr (F.associatedGradedPieceMap j x)) = + basisGradeProjection b ω j x.val := by + apply b.repr.injective + ext i + rw [b.repr.apply_symm_apply, F.associatedGradedPieceMap_coordinate, + basisGradeProjection_repr] + simp only [eq_comm] + +theorem associatedGradedBasis_repr_symm_eq_projection + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hc : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) (i : κ) : + b.repr.symm ((F.associatedGradedBasis b ω hb).repr + (F.associatedGradedBasis c ν hc i)) = basisGradeProjection b ω (ν i) (c i) := by + rw [← F.associatedGradedPieceMap_basis c ν hc (ν i) i le_rfl rfl] + exact F.associatedGradedPieceMap_repr_symm b ω hb (ν i) _ + +theorem associatedGradedBasis_repr_change + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hc : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) (i : κ) (k : ι) : + (F.associatedGradedBasis b ω hb).repr (F.associatedGradedBasis c ν hc i) k = + if ω k = ν i then b.repr (c i) k else 0 := by + have h := congrArg (fun x : L => b.repr x k) + (F.associatedGradedBasis_repr_symm_eq_projection b ω hb c ν hc i) + simpa only [b.repr.apply_symm_apply, basisGradeProjection_repr] using h + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hb : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem associatedGradedBasis_projection_pieceMap (r j : ℕ) (x : F.layer j) : + basisGradeProjection (F.associatedGradedBasis b ω hb) ω r (F.associatedGradedPieceMap j x) = + if j = r then F.associatedGradedPieceMap j x else 0 := by + classical + apply (F.associatedGradedBasis b ω hb).repr.injective + ext i + rw [basisGradeProjection_repr, F.associatedGradedPieceMap_coordinate] + split_ifs <;> simp_all only [F.associatedGradedPieceMap_coordinate, + map_zero, Finsupp.zero_apply, ite_true, ite_false, eq_comm, not_true_eq_false] + +theorem associatedGradedBasis_projection_independent + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hc : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) (r : ℕ) : + basisGradeProjection (F.associatedGradedBasis b ω hb) ω r = + basisGradeProjection (F.associatedGradedBasis c ν hc) ν r := by + apply (F.associatedGradedBasis b ω hb).ext + intro i + rw [← F.associatedGradedPieceMap_basis b ω hb (ω i) i le_rfl rfl, + F.associatedGradedBasis_projection_pieceMap b ω hb, + F.associatedGradedBasis_projection_pieceMap c ν hc] + +theorem associatedGradedBasis_gradedSubmodule_independent + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hc : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + (U : Submodule ℚ F.AssociatedGraded) : + BasisGradedSubmodule (F.associatedGradedBasis b ω hb) ω U ↔ + BasisGradedSubmodule (F.associatedGradedBasis c ν hc) ν U := by + unfold BasisGradedSubmodule + simp only [F.associatedGradedBasis_projection_independent b ω hb c ν hc] + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/AugmentedMatrixSection.lean b/lean/OAI/Combinatorics/Progressions/Linear/AugmentedMatrixSection.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ad4d456ffe353b52af3016bd6a332bc560e2ee0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/AugmentedMatrixSection.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Estimates.CocycleHorizontalNormalization + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +variable {ι κ μ R : Type*} [CommRing R] + +def constraintProjectionMatrix (Q : Matrix ι κ R) (P : Matrix μ κ R) : + Matrix (ι ⊕ μ) κ R := fun i j => Sum.elim (fun k => Q k j) (fun k => P k j) i + +def constraintProjectionInput (y : μ → R) : (ι ⊕ μ) → R := Sum.elim (fun _ => 0) y + +theorem constraintProjectionMatrix_mulVec [Fintype κ] + (Q : Matrix ι κ R) (P : Matrix μ κ R) (x : κ → R) : + constraintProjectionMatrix Q P *ᵥ x = Sum.elim (Q *ᵥ x) (P *ᵥ x) := by + funext i + cases i <;> rfl + +theorem mulVec_constraintProjectionInput [Fintype ι] [Fintype μ] + (S : Matrix κ (ι ⊕ μ) R) (y : μ → R) : + S *ᵥ constraintProjectionInput (ι := ι) y = (fun i j => S i (Sum.inr j)) *ᵥ y := by + funext i + simp [Matrix.mulVec, dotProduct, Fintype.sum_sum_type, constraintProjectionInput] + +theorem constraintProjectionInput_grid [Fintype ι] [Fintype μ] + (l : ℕ) (y : μ → ℝ) (hy : y ∈ realDenominatorGrid l) : + constraintProjectionInput (ι := ι) y ∈ realDenominatorGrid l := by + obtain ⟨z, hz⟩ := hy + refine ⟨Sum.elim (fun _ => (0 : ℤ)) z, ?_⟩ + funext i + cases i with + | inl i => simp [constraintProjectionInput] + | inr i => exact congrFun hz i + +theorem constraintProjectionInput_weighted {δ : Type*} + (r : ι → δ) (c : μ → δ) (W : δ → ℝ) (hW : ∀ d, 0 < W d) + {M : ℝ} (hM : 0 ≤ M) (y : μ → ℝ) (hy : ∀ i, |y i| ≤ M / W (c i)) : + ∀ i, |constraintProjectionInput (ι := ι) y i| ≤ M / W (Sum.elim r c i) := by + intro i + cases i with + | inl i => + change |(0 : ℝ)| ≤ M / W (r i) + rw [abs_zero] + exact div_nonneg hM (hW _).le + | inr i => exact hy i + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BalancedDualBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/BalancedDualBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..27cab9cd0b780a7c7992d464ddc0c442bdcf2518 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BalancedDualBounds.lean @@ -0,0 +1,57 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_complex_unit_phase (z : ℂ) : + ∃ a : ℂ, ‖a‖ = 1 ∧ a * z = (‖z‖ : ℂ) := by + by_cases hz : z = 0 + · subst z + exact ⟨1, by simp, by simp⟩ + have hn : ‖z‖ ≠ 0 := norm_ne_zero_iff.mpr hz + refine ⟨star z / (‖z‖ : ℂ), ?_, ?_⟩ + · simp [hn] + · calc + _ = (star z * z) / (‖z‖ : ℂ) := by ring + _ = ((‖z‖ ^ 2 : ℝ) : ℂ) / (‖z‖ : ℂ) := by + rw [mul_comm (star z) z] + change z * (starRingEnd ℂ) z / (‖z‖ : ℂ) = _ + rw [Complex.mul_conj, Complex.normSq_eq_norm_sq] + _ = _ := by + rw [Complex.ofReal_pow] + field_simp + +theorem norm_lt_of_re_lt_on_balanced {E : Type*} [AddCommGroup E] [Module ℂ E] + (f : E →ₗ[ℂ] ℂ) {S : Set E} (hS : Balanced ℂ S) {c : ℝ} + (hf : ∀ x ∈ S, (f x).re < c) : ∀ x ∈ S, ‖f x‖ < c := by + intro x hx + obtain ⟨a, ha, hphase⟩ := exists_complex_unit_phase (f x) + have h := hf (a • x) (hS.smul_mem ha.le hx) + simpa only [map_smul, smul_eq_mul, hphase, Complex.ofReal_re] using h + +theorem seminorm_dual_bound_of_ball {E : Type*} [AddCommGroup E] [Module ℂ E] + (X : Seminorm ℂ E) (f : E →ₗ[ℂ] ℂ) {tau : ℝ} (htau : 0 < tau) + (hball : ∀ v, X v ≤ tau → ‖f v‖ < 1) : ∀ v, tau * ‖f v‖ ≤ X v := by + intro v + by_contra h + have hv : X v < tau * ‖f v‖ := lt_of_not_ge h + have hnorm : 0 < ‖f v‖ := by nlinarith [apply_nonneg X v, norm_nonneg (f v)] + let a : ℂ := (‖f v‖⁻¹ : ℝ) + have ha : ‖a‖ = ‖f v‖⁻¹ := by + simp [a] + have hX : X (a • v) ≤ tau := by + rw [map_smul_eq_mul, ha, inv_mul_eq_div] + exact ((div_lt_iff₀ hnorm).mpr (by simpa only [mul_comm] using hv)).le + have hbad := hball (a • v) hX + have hbad' : (1 : ℝ) < 1 := by + simpa only [map_smul, norm_smul, ha, inv_mul_cancel₀ hnorm.ne'] using hbad + exact (lt_irrefl 1) hbad' + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BaseChangeCoordinateProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/BaseChangeCoordinateProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7b710ff10e4f2bf8d41ce5048bc407c085dbec4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BaseChangeCoordinateProjection.lean @@ -0,0 +1,49 @@ +import Mathlib.Algebra.Algebra.Rat +import Mathlib.Basic.Real.Basic +import Mathlib.LinearAlgebra.TensorProduct.Basis +import Mathlib.LinearAlgebra.TensorProduct.Map + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem baseChange_coordinate_eq + {V W ι κ : Type*} [AddCommGroup V] [Module ℚ V] [AddCommGroup W] [Module ℚ W] + (b : Basis ι ℚ V) (c : Basis κ ℚ W) (P : V →ₗ[ℚ] W) (r : κ → ι) + (hP : ∀ x i, c.repr (P x) i = b.repr x (r i)) + (x : ℝ ⊗[ℚ] V) (i : κ) : + (c.baseChange ℝ).repr (P.baseChange ℝ x) i = (b.baseChange ℝ).repr x (r i) := by + induction x using TensorProduct.inductionOn with + | add x y hx hy => simp only [map_add, Finsupp.add_apply, hx, hy] + | tmul t x => + rw [LinearMap.baseChange_tmul, Basis.baseChange_repr_tmul, + Basis.baseChange_repr_tmul, hP] + +theorem baseChange_coordinate_projector_repr + {V W ι : Type*} [AddCommGroup V] [Module ℚ V] [AddCommGroup W] [Module ℚ W] + (b : Basis ι ℚ V) (P : V →ₗ[ℚ] W) (S : W →ₗ[ℚ] V) + (p : ι → Prop) [DecidablePred p] + (hproj : ∀ x i, b.repr (S (P x)) i = if p i then b.repr x i else 0) + (x : ℝ ⊗[ℚ] V) (i : ι) : + (b.baseChange ℝ).repr (S.baseChange ℝ (P.baseChange ℝ x)) i = + if p i then (b.baseChange ℝ).repr x i else 0 := by + induction x using TensorProduct.inductionOn with + | add x y hx hy => + simp only [map_add, Finsupp.add_apply] at * + rw [hx, hy] + split_ifs <;> simp + | tmul r x => + rw [LinearMap.baseChange_tmul, LinearMap.baseChange_tmul, + Basis.baseChange_repr_tmul, Basis.baseChange_repr_tmul, hproj] + split_ifs <;> simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BasisAxisNormalization.lean b/lean/OAI/Combinatorics/Progressions/Linear/BasisAxisNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee7e5c76ffe3310f07325ff32c2cbac80a1462d4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BasisAxisNormalization.lean @@ -0,0 +1,76 @@ +import Mathlib.Algebra.Order.Floor.Ring +import Mathlib.Analysis.Normed.Module.Basic +import Mathlib.LinearAlgebra.Basis.SMul +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped BigOperators + +variable {I E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + +noncomputable def basisAxisScale (b : Basis I ℝ E) (i : I) : ℕ := ⌈‖b i‖⁻¹⌉₊ + +theorem basisAxisScale_pos (b : Basis I ℝ E) (i : I) : 0 < basisAxisScale b i := by + apply Nat.ceil_pos.mpr + exact inv_pos.mpr (norm_pos_iff.mpr (b.ne_zero i)) + +theorem basisAxisScale_eq_max (b : Basis I ℝ E) (i : I) : + basisAxisScale b i = max 1 ⌈‖b i‖⁻¹⌉₊ := by + exact (max_eq_right (basisAxisScale_pos b i)).symm + +theorem basisAxisScale_mul_norm (b : Basis I ℝ E) (i : I) : + 1 ≤ (basisAxisScale b i : ℝ) * ‖b i‖ ∧ + (basisAxisScale b i : ℝ) * ‖b i‖ < ‖b i‖ + 1 := by + have hpos : 0 < ‖b i‖ := norm_pos_iff.mpr (b.ne_zero i) + have hlo := mul_le_mul_of_nonneg_right (Nat.le_ceil ‖b i‖⁻¹) hpos.le + have hhi := mul_lt_mul_of_pos_right (Nat.ceil_lt_add_one (inv_nonneg.mpr hpos.le)) hpos + constructor + · simpa only [basisAxisScale, inv_mul_cancel₀ hpos.ne'] using hlo + · have he : (‖b i‖⁻¹ + 1) * ‖b i‖ = ‖b i‖ + 1 := by + rw [add_mul, inv_mul_cancel₀ hpos.ne', one_mul, add_comm] + simpa only [basisAxisScale, he] using hhi + +noncomputable def normalizedAxisBasis (b : Basis I ℝ E) : Basis I ℝ E := + b.unitsSMul (fun i => Units.mk0 (basisAxisScale b i : ℝ) + (Nat.cast_ne_zero.mpr (basisAxisScale_pos b i).ne')) + +theorem normalizedAxisBasis_apply (b : Basis I ℝ E) (i : I) : + normalizedAxisBasis b i = (basisAxisScale b i : ℝ) • b i := by + simp only [normalizedAxisBasis, Basis.unitsSMul_apply, Units.smul_def, Units.val_mk0] + +theorem normalizedAxisBasis_norm (b : Basis I ℝ E) (i : I) : + ‖normalizedAxisBasis b i‖ = (basisAxisScale b i : ℝ) * ‖b i‖ := by + rw [normalizedAxisBasis_apply, norm_smul, Real.norm_eq_abs, abs_of_nonneg (Nat.cast_nonneg _)] + +theorem normalizedAxisBasis_norm_bounds (b : Basis I ℝ E) {B : ℝ} + (hb : ∀ i, ‖b i‖ ≤ B) (i : I) : + 1 ≤ ‖normalizedAxisBasis b i‖ ∧ ‖normalizedAxisBasis b i‖ ≤ B + 1 := by + rw [normalizedAxisBasis_norm] + refine ⟨(basisAxisScale_mul_norm b i).1, ?_⟩ + have h := (basisAxisScale_mul_norm b i).2 + have hi := hb i + linarith + +variable [Fintype I] + +theorem normalizedAxisBasis_coordinates (b : Basis I ℝ E) (x : E) (i : I) : + (normalizedAxisBasis b).equivFun x i = b.equivFun x i / (basisAxisScale b i : ℝ) := by + simp only [normalizedAxisBasis, Basis.equivFun_apply, Basis.repr_unitsSMul, + Units.smul_def, Units.val_inv_eq_inv_val, Units.val_mk0, smul_eq_mul, div_eq_mul_inv] + exact mul_comm _ _ + +theorem normalizedAxisBasis_norm_product (b : Basis I ℝ E) : + (∏ i, ‖normalizedAxisBasis b i‖) = (∏ i, (basisAxisScale b i : ℝ)) * ∏ i, ‖b i‖ := by + simp only [normalizedAxisBasis_norm, Finset.prod_mul_distrib] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BasisCoordinateBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/BasisCoordinateBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..af461a2c076ec5878488fa581b4b5fb1f2d17768 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BasisCoordinateBounds.lean @@ -0,0 +1,37 @@ +import OAI.Combinatorics.Progressions.Geometry.CoordinateSupNorm +import OAI.Combinatorics.Progressions.Nilpotent.BCHConjugationLinear + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [AddCommGroup L] [Module ℝ L] [AddCommGroup M] [Module ℝ M] + +theorem basisCoordinateMap_apply_eq_sum (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : L →ₗ[ℝ] M) (v : ι → ℝ) (k : κ) : + basisCoordinateMap e f φ v k = ∑ i, f.repr (φ (e i)) k * v i := by + rw [basisCoordinateMap_apply, Basis.equivFun_symm_apply] + change f.repr (φ (∑ i, v i • e i)) k = _ + simp only [map_sum, map_smul, Finsupp.coe_finsetSum, Finset.sum_apply, + Finsupp.smul_apply, smul_eq_mul, mul_comm] + +theorem basisCoordinateMap_L2_bound (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : L →ₗ[ℝ] M) (B : ℝ) (hB : 0 ≤ B) + (hφ : ∀ k i, |f.repr (φ (e i)) k| ≤ B) (v : ι → ℝ) : + coordinateL2Norm (basisCoordinateMap e f φ v) ≤ + ((Fintype.card κ : ℝ) + Fintype.card ι + 1) * (B + 1) * coordinateL2Norm v := by + have heq : basisCoordinateMap e f φ v = fun k => ∑ i, f.repr (φ (e i)) k * v i := + funext (basisCoordinateMap_apply_eq_sum e f φ v) + rw [heq] + exact coordinateL2Norm_matrix_entry_bound (fun k i => f.repr (φ (e i)) k) B hB hφ v + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BasisFamilyLogHeight.lean b/lean/OAI/Combinatorics/Progressions/Linear/BasisFamilyLogHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..4540f07705010a27a2e48e59ac954f34243b6d47 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BasisFamilyLogHeight.lean @@ -0,0 +1,17 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalPowerHeight + +namespace OAI + +section + +namespace Erdos3 + +def BasisFamilyLogHeight {ι κ V : Type*} [AddCommGroup V] [Module ℚ V] + (b : Module.Basis ι ℚ V) (v : κ → V) (p : ℝ) : Prop := + ∀ i j, rationalLogHeight (b.repr (v i) j) ≤ p + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BasisGradedCoordinateBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/BasisGradedCoordinateBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..88e2570d22c2e135dfddb25044a7d001bea591c2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BasisGradedCoordinateBasis.lean @@ -0,0 +1,370 @@ +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Data.Finsupp.SMul +import Mathlib.LinearAlgebra.Basis.Basic +import Mathlib.LinearAlgebra.FiniteDimensional.Basic +import Mathlib.LinearAlgebra.LinearIndependent.Lemmas +import Mathlib.LinearAlgebra.Pi +import Mathlib.LinearAlgebra.Projection + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + +noncomputable def supportedSubmoduleBasis (b : Basis ι K V) (P : Submodule K V) (S : Set ι) + (hP : P = Submodule.span K (b '' S)) : Basis S K P := by + let c := Basis.span (b.linearIndependent.comp (fun i : S => (i : ι)) Subtype.val_injective) + have he : Submodule.span K (Set.range (fun i : S => b i)) = P := by + rw [hP] + congr 1 + ext x + simp + exact c.map (LinearEquiv.ofEq _ _ he) + +@[simp] theorem supportedSubmoduleBasis_coe (b : Basis ι K V) (P : Submodule K V) (S : Set ι) + (hP : P = Submodule.span K (b '' S)) (i : S) : + (supportedSubmoduleBasis b P S hP i : V) = b i := by + simp [supportedSubmoduleBasis, Basis.map_apply] + +theorem supportedSubmoduleBasis_repr (b : Basis ι K V) (P : Submodule K V) (S : Set ι) + (hP : P = Submodule.span K (b '' S)) (x : P) (i : S) : + (supportedSubmoduleBasis b P S hP).repr x i = b.repr (x : V) i := by + classical + let c := supportedSubmoduleBasis b P S hP + have he : c.coord i = (b.coord i).comp P.subtype := by + apply c.ext + intro j + simp [c, Basis.coord_apply, Finsupp.single_apply, Subtype.ext_iff] + change c.coord i x = b.coord i (x : V) + rw [he] + rfl + +theorem basis_mem_span_image_iff (b : Basis ι K V) (S : Set ι) (x : V) : + x ∈ Submodule.span K (b '' S) ↔ ∀ i, i ∉ S → b.repr x i = 0 := by + classical + rw [b.mem_span_image] + constructor + · intro h i hi + by_contra hne + exact hi (h (Finsupp.mem_support_iff.mpr hne)) + · intro h i hi + by_contra hnot + exact (Finsupp.mem_support_iff.mp hi) (h i hnot) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + +noncomputable def basisCoordinateProjection (b : Basis ι K V) (S : Set ι) : V →ₗ[K] V := by + classical + exact + { toFun := fun x => b.repr.symm ((b.repr x).filter (· ∈ S)) + map_add' := fun x y => by simp only [map_add, Finsupp.filter_add] + map_smul' := fun c x => by simp only [map_smul, Finsupp.filter_smul, RingHom.id_apply] } + +theorem basisCoordinateProjection_repr (b : Basis ι K V) (S : Set ι) + [DecidablePred (· ∈ S)] (x : V) (i : ι) : + b.repr (basisCoordinateProjection b S x) i = if i ∈ S then b.repr x i else 0 := by + classical + by_cases hi : i ∈ S <;> + simp [basisCoordinateProjection, hi] + +theorem basisCoordinateProjection_mem_span (b : Basis ι K V) (S : Set ι) (x : V) : + basisCoordinateProjection b S x ∈ Submodule.span K (b '' S) := by + classical + apply (basis_mem_span_image_iff b S _).mpr + intro i hi + simp only [basisCoordinateProjection_repr, hi, ↓reduceIte] + +theorem basisCoordinateProjection_eq_self (b : Basis ι K V) (S : Set ι) (x : V) + (hx : x ∈ Submodule.span K (b '' S)) : basisCoordinateProjection b S x = x := by + classical + apply b.repr.injective + ext i + rw [basisCoordinateProjection_repr] + split_ifs with hi + · rfl + · exact ((basis_mem_span_image_iff b S x).mp hx i hi).symm + +theorem basisCoordinateProjection_basis (b : Basis ι K V) (S : Set ι) + [DecidablePred (· ∈ S)] (i : ι) : + basisCoordinateProjection b S (b i) = if i ∈ S then b i else 0 := by + by_cases hi : i ∈ S + · rw [ite_eq_left hi] + exact basisCoordinateProjection_eq_self b S (b i) (Submodule.subset_span ⟨i, hi, rfl⟩) + · apply b.repr.injective + ext j + classical + by_cases hj : j ∈ S <;> by_cases hij : i = j <;> + simp_all [basisCoordinateProjection_repr] + +theorem basisCoordinateProjection_idempotent (b : Basis ι K V) (S : Set ι) (x : V) : + basisCoordinateProjection b S (basisCoordinateProjection b S x) = basisCoordinateProjection b S x := + basisCoordinateProjection_eq_self b S _ (basisCoordinateProjection_mem_span b S x) + +theorem basisCoordinateProjection_eq_zero_iff (b : Basis ι K V) (S : Set ι) (x : V) : + basisCoordinateProjection b S x = 0 ↔ x ∈ Submodule.span K (b '' Sᶜ) := by + classical + rw [basis_mem_span_image_iff] + constructor + · intro hx i hi + have hiS : i ∈ S := by simpa only [Set.mem_compl_iff, not_not] using hi + have h := congrArg (fun v => b.repr v i) hx + simpa only [basisCoordinateProjection_repr, hiS, ↓reduceIte, map_zero, Finsupp.zero_apply] using h + · intro hx + apply b.repr.injective + ext i + simp only [basisCoordinateProjection_repr, map_zero, Finsupp.zero_apply] + split_ifs with hi + · exact hx i (by simpa only [Set.mem_compl_iff, not_not] using hi) + · rfl + +theorem sub_basisCoordinateProjection_mem (b : Basis ι K V) (S : Set ι) (x : V) : + x - basisCoordinateProjection b S x ∈ Submodule.span K (b '' Sᶜ) := by + apply (basisCoordinateProjection_eq_zero_iff b S _).mp + rw [map_sub, basisCoordinateProjection_idempotent, sub_self] + +theorem basisCoordinateProjection_eq_iff (b : Basis ι K V) (S : Set ι) (x y : V) : + basisCoordinateProjection b S x = basisCoordinateProjection b S y ↔ + x - y ∈ Submodule.span K (b '' Sᶜ) := by + rw [← basisCoordinateProjection_eq_zero_iff, map_sub, sub_eq_zero] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + +theorem basis_isCompl_span_compl (b : Basis ι K V) (S : Set ι) : + IsCompl (Submodule.span K (b '' S)) (Submodule.span K (b '' Sᶜ)) := by + apply b.linearIndependent.isCompl_span_image + · exact b.span_eq + · exact isCompl_compl + +noncomputable def supportedQuotientBasis (b : Basis ι K V) (P : Submodule K V) (S : Set ι) + (hP : P = Submodule.span K (b '' S)) : Basis {i // i ∉ S} K (V ⧸ P) := + (supportedSubmoduleBasis b (Submodule.span K (b '' Sᶜ)) Sᶜ rfl).map + (P.quotientEquivOfIsCompl (Submodule.span K (b '' Sᶜ)) + (by rw [hP]; exact basis_isCompl_span_compl b S)).symm + +@[simp] theorem supportedQuotientBasis_apply (b : Basis ι K V) (P : Submodule K V) (S : Set ι) + (hP : P = Submodule.span K (b '' S)) (i : {i // i ∉ S}) : + supportedQuotientBasis b P S hP i = P.mkQ (b i) := by + change P.mkQ ((supportedSubmoduleBasis b (Submodule.span K (b '' Sᶜ)) Sᶜ rfl) i : V) = _ + exact congrArg P.mkQ (supportedSubmoduleBasis_coe b (Submodule.span K (b '' Sᶜ)) Sᶜ rfl i) + +theorem supportedQuotientBasis_repr_mk (b : Basis ι K V) (P : Submodule K V) (S : Set ι) + (hP : P = Submodule.span K (b '' S)) (x : V) (i : {i // i ∉ S}) : + (supportedQuotientBasis b P S hP).repr (P.mkQ x) i = b.repr x i := by + classical + have hker : P ≤ LinearMap.ker (b.coord i) := by + intro y hy + rw [hP, basis_mem_span_image_iff] at hy + exact hy i i.property + let f := P.liftQ (b.coord i) hker + have hf : (supportedQuotientBasis b P S hP).coord i = f := by + apply (supportedQuotientBasis b P S hP).ext + intro j + change (supportedQuotientBasis b P S hP).repr (supportedQuotientBasis b P S hP j) i = _ + rw [Basis.repr_self] + simp [f, Basis.coord_apply, Finsupp.single_apply, Subtype.ext_iff] + change (supportedQuotientBasis b P S hP).coord i (P.mkQ x) = _ + rw [hf] + rfl + +theorem supportedQuotientBasis_map_span (b : Basis ι K V) (P : Submodule K V) (S : Set ι) + (hP : P = Submodule.span K (b '' S)) (T : Set ι) : + (Submodule.span K (b '' T)).map P.mkQ = Submodule.span K + (supportedQuotientBasis b P S hP '' {i : {i // i ∉ S} | (i : ι) ∈ T}) := by + rw [Submodule.map_span, Set.image_image] + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨i, hi, rfl⟩ + by_cases hs : i ∈ S + · have hz : P.mkQ (b i) = 0 := (Submodule.Quotient.mk_eq_zero _).mpr (by + rw [hP] + exact Submodule.subset_span ⟨i, hs, rfl⟩) + change P.mkQ (b i) ∈ _ + rw [hz] + exact Submodule.zero_mem _ + · have h := Submodule.subset_span (R := K) + (show supportedQuotientBasis b P S hP ⟨i, hs⟩ ∈ + supportedQuotientBasis b P S hP '' {j : {i // i ∉ S} | (j : ι) ∈ T} from + ⟨⟨i, hs⟩, hi, rfl⟩) + simpa only [supportedQuotientBasis_apply] using h + · apply Submodule.span_le.mpr + rintro _ ⟨i, hi, rfl⟩ + rw [supportedQuotientBasis_apply] + exact Submodule.subset_span ⟨i.val, hi, rfl⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + +noncomputable def basisGradeProjection (b : Basis ι K V) (w : ι → ℕ) (j : ℕ) : V →ₗ[K] V := + basisCoordinateProjection b {i | w i = j} + +noncomputable def basisBelowProjection (b : Basis ι K V) (w : ι → ℕ) (j : ℕ) : V →ₗ[K] V := + basisCoordinateProjection b {i | w i < j} + +@[simp] theorem basisGradeProjection_repr (b : Basis ι K V) (w : ι → ℕ) (j : ℕ) (x : V) (i : ι) : + b.repr (basisGradeProjection b w j x) i = if w i = j then b.repr x i else 0 := + basisCoordinateProjection_repr b {i | w i = j} x i + +@[simp] theorem basisBelowProjection_repr (b : Basis ι K V) (w : ι → ℕ) (j : ℕ) (x : V) (i : ι) : + b.repr (basisBelowProjection b w j x) i = if w i < j then b.repr x i else 0 := + basisCoordinateProjection_repr b {i | w i < j} x i + +theorem basisBelowProjection_eq_sum_grades (b : Basis ι K V) (w : ι → ℕ) (j : ℕ) (x : V) : + basisBelowProjection b w j x = ∑ k ∈ Finset.range j, basisGradeProjection b w k x := by + apply b.repr.injective + ext i + simp [basisBelowProjection_repr, basisGradeProjection_repr] + +def BasisGradedSubmodule (b : Basis ι K V) (w : ι → ℕ) (U : Submodule K V) : Prop := + ∀ j x, x ∈ U → basisGradeProjection b w j x ∈ U + +theorem BasisGradedSubmodule.below_mem (b : Basis ι K V) (w : ι → ℕ) (U : Submodule K V) + (hU : BasisGradedSubmodule b w U) (j : ℕ) (x : V) (hx : x ∈ U) : + basisBelowProjection b w j x ∈ U := by + rw [basisBelowProjection_eq_sum_grades] + exact Submodule.sum_mem U (fun k _ => hU k x hx) + +theorem sub_basisBelowProjection_mem (b : Basis ι K V) (w : ι → ℕ) (j : ℕ) (x : V) : + x - basisBelowProjection b w j x ∈ Submodule.span K (b '' {i | j ≤ w i}) := by + simpa only [basisBelowProjection, Set.compl_ofPred, not_lt] using + sub_basisCoordinateProjection_mem b {i | w i < j} x + +theorem basisBelowProjection_eq_iff (b : Basis ι K V) (w : ι → ℕ) (j : ℕ) (x y : V) : + basisBelowProjection b w j x = basisBelowProjection b w j y ↔ + x - y ∈ Submodule.span K (b '' {i | j ≤ w i}) := by + simpa only [basisBelowProjection, Set.compl_ofPred, not_lt] using + basisCoordinateProjection_eq_iff b {i | w i < j} x y + +theorem BasisGradedSubmodule.below_mem_of_mem_sup (b : Basis ι K V) (w : ι → ℕ) (U : Submodule K V) + (hU : BasisGradedSubmodule b w U) (j : ℕ) (x : V) + (hx : x ∈ U ⊔ Submodule.span K (b '' {i | j ≤ w i})) : + basisBelowProjection b w j x ∈ U := by + obtain ⟨u, hu, v, hv, rfl⟩ := Submodule.mem_sup.mp hx + have hzero : basisBelowProjection b w j v = 0 := by + have h := (basisBelowProjection_eq_iff b w j v 0).mpr (by simpa only [sub_zero] using hv) + simpa only [map_zero] using h + rw [map_add, hzero, add_zero] + exact hU.below_mem b w U j u hu + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped BigOperators + +variable {σ : Type*} [Fintype σ] + +theorem basisGradeProjection_pi_apply (w : σ → ℕ) (j : ℕ) + (x : σ → ℚ) (i : σ) : + basisGradeProjection (Pi.basisFun ℚ σ) w j x i = + if w i = j then x i else 0 := by + simpa only [Pi.basisFun_repr] using + basisGradeProjection_repr (Pi.basisFun ℚ σ) w j x i + +theorem sum_basisGradeProjection_pi (w : σ → ℕ) (x : σ → ℚ) : + ∑ j ∈ Finset.univ.image w, basisGradeProjection (Pi.basisFun ℚ σ) w j x = x := by + classical + funext i + simp only [Finset.sum_apply, basisGradeProjection_pi_apply] + simp + +theorem basisGraded_homogeneous_span (w : σ → ℕ) (K : Submodule ℚ (σ → ℚ)) + (hK : BasisGradedSubmodule (Pi.basisFun ℚ σ) w K) : + ⊤ ≤ Submodule.span ℚ {x : K | ∃ j ∈ Set.range w, + ∀ i, j ≠ w i → x.val i = 0} := by + classical + intro x _ + let y (j : ℕ) : K := ⟨basisGradeProjection (Pi.basisFun ℚ σ) w j x.val, + hK j x.val x.property⟩ + have hsum : ∑ j ∈ Finset.univ.image w, y j = x := by + apply Subtype.ext + simpa only [Submodule.coe_sum] using sum_basisGradeProjection_pi w x.val + rw [← hsum] + apply Submodule.sum_mem + intro j hj + apply Submodule.subset_span + refine ⟨j, ?_, ?_⟩ + · obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hj + exact ⟨i, rfl⟩ + · intro i hi + exact (basisGradeProjection_pi_apply w j x.val i).trans (ite_eq_right (Ne.symm hi)) + +theorem exists_basisGraded_coordinate_basis (w : σ → ℕ) + (K : Submodule ℚ (σ → ℚ)) + (hK : BasisGradedSubmodule (Pi.basisFun ℚ σ) w K) : + ∃ (n : ℕ) (v : Fin n → ℕ) (b : Basis (Fin n) ℚ K), + (∀ j, v j ∈ Set.range w) ∧ + ∀ j i, v j ≠ w i → (b j).val i = 0 := by + classical + let S : Set K := {x | ∃ j ∈ Set.range w, ∀ i, j ≠ w i → x.val i = 0} + have hspan : ⊤ ≤ Submodule.span ℚ S := basisGraded_homogeneous_span w K hK + let B := Basis.ofSpan hspan + let := FiniteDimensional.fintypeBasisIndex B + let b := B.reindex (Fintype.equivFin _) + have hb : ∀ j, b j ∈ S := by + intro j + dsimp only [b] + rw [Basis.reindex_apply] + exact Basis.ofSpan_subset hspan ⟨_, rfl⟩ + choose v hv hcoord using hb + exact ⟨_, v, b, hv, hcoord⟩ + +theorem exists_basisGraded_coordinate_basis_bounded (w : σ → ℕ) + (K : Submodule ℚ (σ → ℚ)) + (hK : BasisGradedSubmodule (Pi.basisFun ℚ σ) w K) + {d : ℕ} (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) : + ∃ (n : ℕ) (v : Fin n → ℕ) (b : Basis (Fin n) ℚ K), + (∀ j, 0 < v j) ∧ (∀ j, v j ≤ d) ∧ + ∀ j i, v j ≠ w i → (b j).val i = 0 := by + obtain ⟨n, v, b, hv, hcoord⟩ := exists_basisGraded_coordinate_basis w K hK + refine ⟨n, v, b, ?_, ?_, hcoord⟩ + · intro j + obtain ⟨i, hi⟩ := hv j + simpa only [← hi] using hw i + · intro j + obtain ⟨i, hi⟩ := hv j + simpa only [← hi] using hwd i + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BasisImageSection.lean b/lean/OAI/Combinatorics/Progressions/Linear/BasisImageSection.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f05af7212da5934f93b59ef70fc5cda6abed102 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BasisImageSection.lean @@ -0,0 +1,144 @@ +import Mathlib.Algebra.Module.Submodule.Equiv +import Mathlib.Analysis.Normed.Module.Basic +import Mathlib.LinearAlgebra.Basis.Basic +import Mathlib.LinearAlgebra.Matrix.NonsingularInverse +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +theorem basis_projection_injective_of_minor {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] {k : ℕ} + (b : Module.Basis (Fin k) K E) (P : E →ₗ[K] (ι → K)) (p : Fin k → ι) + (hdet : (Matrix.of (fun i j => P (b j) (p i))).det ≠ 0) : Function.Injective P := by + let B := Matrix.of (fun i j => P (b j) (p i)) + have hB : IsUnit B := B.isUnit_iff_isUnit_det.mpr (isUnit_iff_ne_zero.mpr hdet) + apply LinearMap.ker_eq_bot.mp + apply le_antisymm _ bot_le + intro x hx + change x = 0 + have hxP : P x = 0 := hx + have hcoord : B *ᵥ (fun j => b.repr x j) = 0 := by + funext i + have hs := congrArg (fun y => P y (p i)) (b.sum_repr x) + simp only [map_sum, map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] at hs + change (∑ j, B i j * b.repr x j) = 0 + calc + _ = P x (p i) := by simpa only [B, Matrix.of_apply, mul_comm] using hs + _ = 0 := congrFun hxP (p i) + have hz : (fun j => b.repr x j) = 0 := Matrix.mulVec_injective_of_isUnit hB + (hcoord.trans (Matrix.mulVec_zero B).symm) + apply b.repr.injective + simp only [map_zero] + exact Finsupp.ext (fun j => congrFun hz j) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem basis_coordinate_matrix_mulVec {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] {k : ℕ} + (b : Module.Basis (Fin k) K E) (f : E →ₗ[K] (ι → K)) (x : E) : + Matrix.of (fun i j => f (b j) i) *ᵥ (fun j => b.repr x j) = f x := by + funext i + have hs := congrArg (fun y => f y i) (b.sum_repr x) + simp only [map_sum, map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] at hs + simpa only [Matrix.mulVec, dotProduct, Matrix.of_apply, mul_comm] using hs + +theorem basis_image_reconstruct_from_minor {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] {k : ℕ} + (b : Module.Basis (Fin k) K E) (f : E →ₗ[K] (ι → K)) (p : Fin k → ι) + (hp : (Matrix.of (fun i j => f (b j) (p i))).det ≠ 0) (x : E) : + let F := Matrix.of (fun i j => f (b j) i) + (F * (F.submatrix p id)⁻¹) *ᵥ (fun j => f x (p j)) = f x := by + let F := Matrix.of (fun i j => f (b j) i) + have hF : F *ᵥ (fun j => b.repr x j) = f x := basis_coordinate_matrix_mulVec b f x + have hsub : (F.submatrix p id) *ᵥ (fun j => b.repr x j) = fun j => f x (p j) := by + funext i + exact congrFun hF (p i) + have hp' : (F.submatrix p id).det ≠ 0 := hp + change (F * (F.submatrix p id)⁻¹) *ᵥ (fun j => f x (p j)) = f x + rw [← hsub, Matrix.mulVec_mulVec, Matrix.mul_assoc, + Matrix.nonsing_inv_mul (F.submatrix p id) (isUnit_iff_ne_zero.mpr hp'), Matrix.mul_one] + exact hF + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem basis_projection_coefficients {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] {k : ℕ} + (b : Module.Basis (Fin k) K E) (P : E →ₗ[K] (ι → K)) (p : Fin k → ι) + (hp : (Matrix.of (fun i j => P (b j) (p i))).det ≠ 0) (x : E) : + (Matrix.of (fun i j => P (b j) (p i)))⁻¹ *ᵥ (fun i => P x (p i)) = + fun j => b.repr x j := by + let H := Matrix.of (fun i j => P (b j) (p i)) + have he : H *ᵥ (fun j => b.repr x j) = fun i => P x (p i) := by + funext i + exact congrFun (basis_coordinate_matrix_mulVec b P x) (p i) + change H⁻¹ *ᵥ (fun i => P x (p i)) = _ + rw [← he, Matrix.mulVec_mulVec, + Matrix.nonsing_inv_mul H (isUnit_iff_ne_zero.mpr hp), Matrix.one_mulVec] + +theorem basis_map_from_projection_minor {K E ι κ : Type*} [Field K] + [AddCommGroup E] [Module K E] {k : ℕ} + (b : Module.Basis (Fin k) K E) (P : E →ₗ[K] (ι → K)) + (g : E →ₗ[K] (κ → K)) (p : Fin k → ι) + (hp : (Matrix.of (fun i j => P (b j) (p i))).det ≠ 0) (x : E) : + g x = (Matrix.of (fun i j => g (b j) i)) *ᵥ + ((Matrix.of (fun i j => P (b j) (p i)))⁻¹ *ᵥ (fun i => P x (p i))) := by + rw [basis_projection_coefficients b P p hp x] + exact (basis_coordinate_matrix_mulVec b g x).symm + +theorem exists_bounded_range_section {E F : Type*} + [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] + (P : E →ₗ[ℝ] F) (hP : Function.Injective P) (C : ℝ) + (hbound : ∀ x, ‖x‖ ≤ C * ‖P x‖) : + ∃ J : LinearMap.range P →ₗ[ℝ] E, + (∀ x, P (J x) = x.val) ∧ (∀ x, ‖J x‖ ≤ C * ‖x‖) := by + let e := LinearEquiv.ofInjective P hP + have he (x : LinearMap.range P) : P (e.symm x) = x.val := + congrArg Subtype.val (e.apply_symm_apply x) + refine ⟨e.symm.toLinearMap, he, ?_⟩ + intro x + calc + ‖e.symm x‖ ≤ C * ‖P (e.symm x)‖ := hbound _ + _ = C * ‖x‖ := by rw [he]; rfl + +theorem exists_normalized_basis_vector {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] {k : ℕ} + (b : Module.Basis (Fin k) K E) (g : E →ₗ[K] (ι → K)) + (B : Matrix ι (Fin k) K) (hB : ∀ i j, B i j = g (b j) i) + (N : Matrix (Fin k) (Fin k) K) (j : Fin k) : + ∃ v : E, g v = (B * N).col j := by + refine ⟨∑ t, N t j • b t, ?_⟩ + funext i + simp only [map_sum, map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + change (∑ t, N t j * g (b t) i) = ∑ t, B i t * N t j + apply Finset.sum_congr rfl + intro t _ + rw [hB, mul_comm] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BasisProjectionRealification.lean b/lean/OAI/Combinatorics/Progressions/Linear/BasisProjectionRealification.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0d3c71e13c20ead3c7c29fce7ea5305ca16ad7f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BasisProjectionRealification.lean @@ -0,0 +1,40 @@ +import OAI.Combinatorics.Progressions.Estimates.RealifiedMultidegree +import OAI.Combinatorics.Progressions.Linear.BasisGradedCoordinateBasis + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι V : Type*} [AddCommGroup V] [Module ℚ V] + +theorem basisCoordinateProjection_baseChange (b : Basis ι ℚ V) (S : Set ι) : + (basisCoordinateProjection b S).baseChange ℝ = basisCoordinateProjection (b.baseChange ℝ) S := by + classical + apply (b.baseChange ℝ).ext + intro i + rw [basisCoordinateProjection_basis, Basis.baseChange_apply, LinearMap.baseChange_tmul, + basisCoordinateProjection_basis] + split_ifs <;> simp only [TensorProduct.tmul_zero] + +theorem BasisGradedSubmodule.baseChange (b : Basis ι ℚ V) (w : ι → ℕ) (U : Submodule ℚ V) + (hU : BasisGradedSubmodule b w U) : BasisGradedSubmodule (b.baseChange ℝ) w (U.baseChange ℝ) := by + intro j x hx + have hstable : U.baseChange ℝ ≤ (U.baseChange ℝ).comap (basisGradeProjection (b.baseChange ℝ) w j) := by + conv_lhs => rw [Submodule.baseChange_eq_span] + apply Submodule.span_le.mpr + rintro _ ⟨u, hu, rfl⟩ + change basisCoordinateProjection (b.baseChange ℝ) {i | w i = j} ((1 : ℝ) ⊗ₜ[ℚ] u) ∈ U.baseChange ℝ + rw [← basisCoordinateProjection_baseChange, LinearMap.baseChange_tmul] + exact Submodule.tmul_mem_baseChange_of_mem 1 (hU j u hu) + exact hstable hx + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BasisSurjectionSection.lean b/lean/OAI/Combinatorics/Progressions/Linear/BasisSurjectionSection.lean new file mode 100644 index 0000000000000000000000000000000000000000..b323716739acf6e558c440be103e05cf8019f5d4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BasisSurjectionSection.lean @@ -0,0 +1,32 @@ +import Mathlib.LinearAlgebra.Basis.Defs + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {R E F I : Type*} [CommSemiring R] [AddCommMonoid E] [Module R E] + [AddCommMonoid F] [Module R F] + +noncomputable def basisSurjectionSection (q : E →ₗ[R] F) (hq : Function.Surjective q) + (b : Basis I R F) : F →ₗ[R] E := + b.constr R (fun i => (hq (b i)).choose) + +theorem basisSurjectionSection_rightInverse (q : E →ₗ[R] F) (hq : Function.Surjective q) + (b : Basis I R F) (x : F) : q (basisSurjectionSection q hq b x) = x := by + have he : q.comp (basisSurjectionSection q hq b) = LinearMap.id := by + apply b.ext + intro i + change q (b.constr R (fun j => (hq (b j)).choose) (b i)) = b i + rw [b.constr_basis] + exact (hq (b i)).choose_spec + exact LinearMap.congr_fun he x + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BiasedChosenBasisStepDrop.lean b/lean/OAI/Combinatorics/Progressions/Linear/BiasedChosenBasisStepDrop.lean new file mode 100644 index 0000000000000000000000000000000000000000..21cd23e951c9a09f2b0960a66f46faa0a1b50d46 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BiasedChosenBasisStepDrop.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.Progressions.Estimates.BiasedNativeTerminal + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration NilpotentLieBCHGroup VectorPolynomial CircleFourier +open scoped TensorProduct BigOperators + +universe uσ uL + +def BiasedChosenBasisStepDropSpec (s C : ℕ) : Prop := + ∀ (_hs : 1 ≤ s) {σ : Type uσ} {L : Type uL} + [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) + [TopologicalSpace (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + (p : ℝ) (_hp : 0 ≤ p) (T : D.Niltest (fun _ : σ => 1)) (_hT : T.ComplexityLE p), + ∃ (e : Basis (Fin (finrank ℚ L)) ℚ L) (ω : Fin (finrank ℚ L) → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates + (D.filtration.squareFinBasis e ω (hF 2)) (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates (D.filtration.squareFinBasis e ω (hF 2)) + (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid N), + (∀ i j, rationalLogHeight (D.basis.repr (e i) j) ≤ p + 1) ∧ + (D.filtration.squareFiltration.topQuotientModel + (D.filtration.squareFinBasis e ω (hF 2)) (squareFinWeight ω) + (D.filtration.squareFinBasis_layers e ω hF) + (D.filtration.squareLattice D.lattice) N hN hin hout).GeometryComplexityLE (squareGeometryBudget p) ∧ + ∀ (g : D.filtration.RealAdaptedPolynomialGroup (fun _ : σ => 1)), + D.filtration.nativePolynomialOrbit (fun _ => 1) g = T.orbit → + ∀ (η : L →ₗ[ℚ] ℚ), + (∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = character ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * + T.observable x) → + ∀ (origin : σ → ℤ) (lengths : σ → ℕ), (∀ i, 0 < lengths i) → + (Fintype.card σ : ℝ) ≤ p → + (∀ i, Real.exp ((p + C) ^ C) ≤ (lengths i : ℝ)) → + Real.exp (-p) ≤ ‖𝔼 x ∈ translatedIntegerBox origin lengths, T.eval x‖ → + D.filtration.ControlledSymbolFactorization e ω hF η (fun i => (lengths i : ℝ)) + (D.filtration.realPolynomialSymbolHom e ω hF (fun _ => 1) + (D.filtration.realAdaptedPolynomialGroupHom (fun _ => 1) g)) ((p + C) ^ C) + +theorem exists_biased_chosen_basis_step_drop (s c : ℕ) + (hI : TranslatedStepDropSpec.{uσ, uL} s c) : + ∃ C : ℕ, 2 ≤ C ∧ BiasedChosenBasisStepDropSpec.{uσ, uL} s C := by + obtain ⟨a, _, hfamily⟩ := exists_biased_native_terminal s c hI + obtain ⟨b, _, hcompose⟩ := exists_controlled_symbol_composition (s + 1) + let B : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + let Q : Polynomial ℕ := B + (Polynomial.X + 4) ^ 11 + Polynomial.X + 2 + let P : Polynomial ℕ := B + (Q + 1) + (Q + 1 + Polynomial.C b) ^ b + obtain ⟨C, hC, hfinal⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro hs σ L _ _ _ _ d _ _ _ _ D _ _ _ _ _ _ _ _ p hp T hT + let k : ℝ := (p + a) ^ a + let q : ℝ := k + (p + 4) ^ 11 + p + 2 + have hk : 0 ≤ k := by dsimp [k]; positivity + have h11 : 0 ≤ (p + 4) ^ 11 := by positivity + have hq : 0 ≤ q := by dsimp [q]; positivity + have hkq : k ≤ q := by dsimp [q]; linarith + have h11q : (p + 4) ^ 11 ≤ q := by dsimp [q]; linarith + have hpq : p ≤ q := by dsimp [q]; linarith + have hq1 : 0 ≤ q + 1 := by linarith + have hlast : 0 ≤ (q + 1 + b) ^ b := by positivity + have hbound : k + (q + 1) + (q + 1 + b) ^ b ≤ (p + C) ^ C := by + simpa [P, Q, B, k, q, Polynomial.eval₂_pow] using hfinal p hp + have hkC : k ≤ (p + C) ^ C := by linarith + have hbC : (q + 1 + b) ^ b ≤ (p + C) ^ C := by linarith + have hkq1 : k ≤ q + 1 := by linarith + have hpq1 : p ≤ q + 1 := by linarith + obtain ⟨e, ω, hF, N, hN, hin, hout, he, hgeometry, hconstruct⟩ := hfamily hs D p hp T hT + obtain ⟨hdim, _, hstructure⟩ := D.basis_geometry_of_forward_height e hp hT.1 he + refine ⟨e, ω, hF, N, hN, hin, hout, he, hgeometry, ?_⟩ + intro g hgOrbit η hvert origin lengths hlengths hσ hlarge hbias + have hTpos : ∀ i, 0 < (lengths i : ℝ) := fun i => by exact_mod_cast hlengths i + obtain ⟨l, W, A, M, R, hl, hlk, hprod, hA, hR, hterminal⟩ := + hconstruct g hgOrbit η hvert origin lengths hlengths hσ + (fun i => (Real.exp_le_exp.mpr hkC).trans (hlarge i)) hbias + let H := ⌈Real.exp q⌉₊ + have hH : 1 ≤ H := one_le_ceil_exp q + have hHp : (H : ℝ) ≤ Real.exp (q + 1) := ceil_exp_le_exp_add_one hq + have hc : ∀ i j k, RationalHeightLE (e.repr ⁅e i, e j⁆ k) H := + fun i j k => rationalHeightLE_ceil_exp ((hstructure i j k).trans h11q) + let φ : D.filtration.RealAdaptedPolynomialGroup (fun _ : σ => 1) →* + D.filtration.RealPolynomialSymbolGroup (fun _ : σ => 1) := + (D.filtration.realPolynomialSymbolHom e ω hF (fun _ => 1)).comp + (D.filtration.realAdaptedPolynomialGroupHom (fun _ => 1)) + have hinner : D.filtration.ControlledSymbolFactorization e ω hF η + (fun i => (lengths i : ℝ)) (φ M) (k + 1) := + SymbolTerminalFactorization.controlled D.filtration e ω hF W hk hTpos hterminal + have hinner' := ControlledSymbolFactorization.mono D.filtration e ω hF hinner + (show k + 1 ≤ q + 1 by linarith) hTpos + have houter : D.filtration.SymbolSlowBound e ω hF (fun _ => 1) + (fun i => (lengths i : ℝ)) (Real.exp (q + 1)) (φ A) := + D.filtration.symbolSlowBound_mono e ω hF (fun _ => 1) (fun i => (lengths i : ℝ)) hTpos + (Real.exp_le_exp.mpr hkq1) (φ A) + (D.filtration.native_symbol_slow e ω hF (fun _ => 1) (fun i => (lengths i : ℝ)) hTpos + (Real.exp_nonneg k) A hA) + have hrat : D.filtration.SymbolRationalGrid e ω hF (fun _ => 1) l (φ R) := + D.filtration.native_symbol_grid e ω hF (fun _ => 1) l R hR + have hfull := hcompose D.filtration e ω hF H (q + 1) hH hq1 + (hdim.trans hpq1) (hσ.trans hpq1) hHp hc (fun i => (lengths i : ℝ)) hTpos η + l hl (hlk.trans (Real.exp_le_exp.mpr hkq1)) (φ A) (φ M) (φ R) houter hrat hinner' + have heq : φ A * φ M * φ R = φ g := by + rw [← map_mul, ← map_mul, hprod] + rw [heq] at hfull + exact ControlledSymbolFactorization.mono D.filtration e ω hF hfull hbC hTpos + +theorem exists_stepTwo_chosen_basis_step_drop : + ∃ C : ℕ, 2 ≤ C ∧ BiasedChosenBasisStepDropSpec.{uσ, uL} 1 C := + exists_biased_chosen_basis_step_drop 1 4 translatedStepDropSpec_one + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BinaryLowerRankFamily.lean b/lean/OAI/Combinatorics/Progressions/Linear/BinaryLowerRankFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..63a44fe981c8cae94e1c4e2933d96ddf8bccefa3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BinaryLowerRankFamily.lean @@ -0,0 +1,601 @@ +import OAI.Combinatorics.Progressions.Estimates.UnitProductOrbitFamily +import OAI.Combinatorics.Progressions.Nilpotent.RankInvariantNiltestBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +structure NativeUnitRankFamily {σ : Type*} (w : σ → ℕ) (s r : ℕ) + (τ I : Type*) [Fintype I] (p : ℝ) where + L : Type + [lie : LieRing L] + [algebra : LieAlgebra ℚ L] + dim : ℕ + [topology : TopologicalSpace (ℝ ⊗[ℚ] L)] + [topologicalAdd : IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [continuousSMul : ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + [hausdorff : T2Space (ℝ ⊗[ℚ] L)] + model : RationalFilteredNilmanifold L s dim + rank : model.DegreeRankStructure r + complexity : rank.ComplexityLE p + test : I → model.Niltest w + test_norm : ∀ i, (test i).normBound = 1 + test_complexity : ∀ i, (test i).ComplexityLE p + unit : ∀ x, ∑ i, ‖(test i).observable x‖ ^ 2 = 1 + orbit : τ → model.filtration.realification.PolynomialOrbit w + normalized : ∀ t, model.filtration.realification.polynomialOrbitEval w 0 (orbit t) = 1 + +attribute [local instance] NativeUnitRankFamily.lie NativeUnitRankFamily.algebra + NativeUnitRankFamily.topology NativeUnitRankFamily.topologicalAdd + NativeUnitRankFamily.continuousSMul NativeUnitRankFamily.hausdorff + +namespace NativeUnitRankFamily + +variable {σ τ I : Type*} [Fintype I] {w : σ → ℕ} {s r : ℕ} {p q : ℝ} + (F : NativeUnitRankFamily w s r τ I p) + +noncomputable def eval (t : τ) (i : I) (x : σ → ℤ) : ℂ := + (F.test i).observable (QuotientGroup.mk + (F.model.filtration.realification.polynomialOrbitEval w x (F.orbit t))) + +theorem unit_eval (t : τ) (x : σ → ℤ) : ∑ i, ‖F.eval t i x‖ ^ 2 = 1 := + F.unit _ + +theorem norm_eval (t : τ) (i : I) (x : σ → ℤ) : ‖F.eval t i x‖ ≤ 1 := by + have h := (F.test i).norm_le (QuotientGroup.mk + (F.model.filtration.realification.polynomialOrbitEval w x (F.orbit t))) + rw [F.test_norm] at h + exact h + +noncomputable def mono (hpq : p ≤ q) : NativeUnitRankFamily w s r τ I q := + { F with + complexity := F.complexity.mono F.rank hpq + test_complexity := fun i => (F.test_complexity i).mono hpq } + +@[simp] theorem mono_eval (hpq : p ≤ q) (t : τ) (i : I) (x : σ → ℤ) : + (F.mono hpq).eval t i x = F.eval t i x := rfl + +end NativeUnitRankFamily + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +open scoped TensorProduct + +variable {L I : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype I] {s r d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} (T : D.DegreeRankStructure r) {p : ℝ} + (V : D.UnitVerticalObservable (T.realSubgroup s r) I p) + +theorem rank_invariant_of_frequency_zero + (hzero : ∀ x ∈ T.filtration.layer s r, V.frequency x = 0) + (z : D.RealGroup) (hz : z ∈ T.realSubgroup s r) (i : I) (x : D.Space) : + V.observable i (z • x) = V.observable i x := by + have hle : T.filtration.layer s r ≤ V.frequency.ker := hzero + have hr : realifyFunctional V.frequency z.coord = 0 := + (mem_realified_frequency_kernel_iff V.frequency z.coord).mp + (Submodule.baseChange_mono ℝ hle hz) + rw [V.vertical i z hz x, hr, AddCircle.coe_zero, CircleFourier.character_zero, one_mul] + +end Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal BigOperators + +section Coordinates + +variable {L I σ : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype I] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {T : Subgroup D.RealGroup} {p : ℝ} + (V : D.UnitVerticalObservable T I p) + +noncomputable def coordinateNiltest {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (i : I) : D.Niltest w where + orbit := g + observable := V.observable i + normBound := 1 + lipBound := V.lipBound + norm_le := V.norm i + lipschitz := V.lipschitz i + +theorem coordinateNiltest_complexity {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (i : I) + (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) : + (V.coordinateNiltest g i).ComplexityLE (p + 4) := by + refine ⟨hD.mono D (by linarith), ?_⟩ + change Real.log (2 + (1 : ℝ) + (V.lipBound : ℝ)) ≤ p + 4 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + calc + _ ≤ 4 * Real.exp p := by nlinarith [V.lip_bound, Real.one_le_exp hp] + _ ≤ Real.exp 4 * Real.exp p := mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (4 : ℝ)]) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, add_comm] + +end Coordinates + +theorem exists_lower_rank_family (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L I σ : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype I] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {r d : ℕ} (D : RationalFilteredNilmanifold L s d) (R : D.DegreeRankStructure (r + 1)) + {p : ℝ} (V : D.UnitVerticalObservable (R.realSubgroup s (r + 1)) I p) + {w : σ → ℕ} (g : D.filtration.realification.PolynomialOrbit w), + 0 ≤ p → R.ComplexityLE p → + (∀ x ∈ R.filtration.layer s (r + 1), V.frequency x = 0) → + ∃ n : ℕ, n ≤ d ∧ + ∃ Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n, + ∃ U : Q.DegreeRankStructure r, + ∃ hQF : Q.filtration = D.filtration.quotientLie + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal, + U.filtration = R.filtration.quotientRank r (Nat.le_of_succ_le R.filtration.rank_le_degree) ∧ + Q.lattice = D.lattice.map (D.filtration.quotientStepHom + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal) ∧ + U.ComplexityLE ((p + C) ^ C) ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 Q.basis + ∃ S : I → Q.Niltest w, + (∀ i, (S i).orbit = R.rankQuotientOrbit Q hQF g) ∧ + (∀ i, (S i).normBound = 1) ∧ + (∀ i, (S i).ComplexityLE ((p + C) ^ C)) ∧ + (∀ y : Q.Space, ∑ i, ‖(S i).observable y‖ ^ 2 = 1) ∧ + (∀ i x, (S i).observable (QuotientGroup.mk + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) + (lieQuotientMap (R.filtration.layerIdeal s (r + 1))) x)) = + V.observable i (QuotientGroup.mk x)) ∧ + ∀ i x, (S i).eval x = V.observable i + (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x g))) := by + obtain ⟨a, _, hdescent⟩ := DegreeRankStructure.exists_rankInvariant_niltest_budget s + let X : Polynomial ℕ := Polynomial.X + let P := (X + 7) ^ 11 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((P + Polynomial.C a) ^ a + P) + refine ⟨C, hC, ?_⟩ + intro L I σ _ _ _ _ _ _ _ r d D R p V w g hp hR hzero + let q := (p + 7) ^ 11 + have hq : 0 ≤ q := by dsimp only [q]; positivity + have hp4q : p + 4 ≤ q := by + apply (show p + 4 ≤ p + 7 by linarith).trans + exact (pow_one (p + 7)).symm.le.trans + (pow_le_pow_right₀ (by linarith) (by decide : 1 ≤ 11)) + have hbudget' : (q + a) ^ a + q ≤ (p + C) ^ C := by + simpa [q, P, X, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := + (le_add_of_nonneg_left (by positivity : 0 ≤ (q + a) ^ a)).trans hbudget' + have haC : (q + a) ^ a ≤ (p + C) ^ C := (le_add_of_nonneg_right hq).trans hbudget' + obtain ⟨n, hn, Q, U, hU, hQF, hQL, hUc, he⟩ := R.exists_controlled_lower_rank_quotient hp hR + have h11 : (p + 3) ^ 11 ≤ q := pow_le_pow_left₀ (by positivity) (by linarith) 11 + have h5 : (p + 3) ^ 5 ≤ q := + (pow_le_pow_right₀ (by linarith : 1 ≤ p + 3) (by decide : 5 ≤ 11)).trans h11 + have hUq : U.ComplexityLE q := hUc.mono U h11 + refine ⟨n, hn, Q, U, hQF, hU, hQL, hUq.mono U hqC, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + have htests := fun i => hdescent R Q hQF hQL (V.coordinateNiltest g i) q hq + ((V.coordinateNiltest_complexity g i hp hR.1).mono hp4q) hUq.1 + (fun i j => (he j i).trans h5) + (fun z hz x => V.rank_invariant_of_frequency_zero R hzero z hz i x) + choose S hSo hSn hSc hSp hSe using htests + refine ⟨S, hSo, hSn, (fun i => (hSc i).mono haC), ?_, hSp, hSe⟩ + intro y + induction y using Quotient.inductionOn with + | h y => + obtain ⟨x, hx⟩ := D.filtration.realQuotientStepHom_surjective + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal y + have heq : realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) + (lieQuotientMap (R.filtration.layerIdeal s (r + 1))) x = y := hx + rw [← heq] + simpa only [hSp, coordinateNiltest] using V.unit (QuotientGroup.mk x) + +end Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct BigOperators + +def HasLowerRankUnitFamily {L I σ : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype I] + {s r d : ℕ} (D : RationalFilteredNilmanifold L s d) (R : D.DegreeRankStructure (r + 1)) + (v : I → D.Space → ℂ) {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (p : ℝ) : Prop := + ∃ n : ℕ, n ≤ d ∧ + ∃ Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n, + ∃ U : Q.DegreeRankStructure r, U.ComplexityLE p ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 Q.basis + ∃ a : Q.filtration.realification.PolynomialOrbit w, + ∃ K : I → Q.Niltest w, + (∀ i, (K i).orbit = a) ∧ (∀ i, (K i).normBound = 1) ∧ + (∀ i, (K i).ComplexityLE p) ∧ + (∀ y : Q.Space, ∑ i, ‖(K i).observable y‖ ^ 2 = 1) ∧ + ∀ i x, (K i).eval x = v i + (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x g))) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +open NilpotentLieBCHGroup +open scoped TensorProduct BigOperators + +universe u v t + +theorem uniform_lower_rank_family {L : Type u} {I : Type v} {σ : Type t} + [LieRing L] [LieAlgebra ℚ L] [Fintype I] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s r d : ℕ} (D : RationalFilteredNilmanifold L s d) + (R : D.DegreeRankStructure (r + 1)) {p : ℝ} + (V : D.UnitVerticalObservable (R.realSubgroup s (r + 1)) I p) + (w : σ → ℕ) (hp : 0 ≤ p) (hR : R.ComplexityLE p) + (hzero : ∀ x ∈ R.filtration.layer s (r + 1), V.frequency x = 0) : + let C := (exists_lower_rank_family.{u, v, t} s).choose + ∃ n : ℕ, n ≤ d ∧ + ∃ Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n, + ∃ U : Q.DegreeRankStructure r, + ∃ hQF : Q.filtration = D.filtration.quotientLie + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal, + U.filtration = R.filtration.quotientRank r + (Nat.le_of_succ_le R.filtration.rank_le_degree) ∧ + Q.lattice = D.lattice.map (D.filtration.quotientStepHom + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal) ∧ + U.ComplexityLE ((p + C) ^ C) ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 Q.basis + ∃ S : I → Q.Niltest w, + (∀ i, (S i).normBound = 1) ∧ + (∀ i, (S i).ComplexityLE ((p + C) ^ C)) ∧ + (∀ y : Q.Space, ∑ i, ‖(S i).observable y‖ ^ 2 = 1) ∧ + (∀ i x, (S i).observable (QuotientGroup.mk + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) + (lieQuotientMap (R.filtration.layerIdeal s (r + 1))) x)) = + V.observable i (QuotientGroup.mk x)) ∧ + ∀ (g : D.filtration.realification.PolynomialOrbit w) i x, + ((S i).withOrbit (R.rankQuotientOrbit Q hQF g)).eval x = + V.observable i + (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x g))) := by + dsimp only + obtain ⟨n, hn, Q, U, hQF, hUF, hQL, hUc, hS⟩ := + (exists_lower_rank_family.{u, v, t} s).choose_spec.2 D R V + (1 : D.filtration.realification.PolynomialOrbit w) hp hR hzero + refine ⟨n, hn, Q, U, hQF, hUF, hQL, hUc, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + obtain ⟨S, _, hSn, hSc, hSu, hSp, _⟩ := hS + refine ⟨S, hSn, hSc, hSu, hSp, ?_⟩ + intro g i x + rw [Niltest.withOrbit_eval, R.rankQuotientOrbit_eval Q hQF] + exact hSp i _ + +end Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct BigOperators + +def HasUniformLowerRankUnitFamily {L I σ : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype I] + {s r d : ℕ} (D : RationalFilteredNilmanifold L s d) (R : D.DegreeRankStructure (r + 1)) + (v : I → D.Space → ℂ) (w : σ → ℕ) (p : ℝ) : Prop := + ∃ n : ℕ, n ≤ d ∧ + ∃ Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n, + ∃ U : Q.DegreeRankStructure r, U.ComplexityLE p ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 Q.basis + ∃ K : I → Q.Niltest w, + (∀ i, (K i).normBound = 1) ∧ (∀ i, (K i).ComplexityLE p) ∧ + (∀ y : Q.Space, ∑ i, ‖(K i).observable y‖ ^ 2 = 1) ∧ + ∃ a : D.filtration.realification.PolynomialOrbit w → + Q.filtration.realification.PolynomialOrbit w, + (∀ g, D.filtration.realification.polynomialOrbitEval w 0 g = 1 → + Q.filtration.realification.polynomialOrbitEval w 0 (a g) = 1) ∧ + ∀ g i x, ((K i).withOrbit (a g)).eval x = v i + (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x g))) + +theorem HasUniformLowerRankUnitFamily.atOrbit {L I σ : Type*} + [LieRing L] [LieAlgebra ℚ L] [Fintype I] {s r d : ℕ} + {D : RationalFilteredNilmanifold L s d} {R : D.DegreeRankStructure (r + 1)} + {v : I → D.Space → ℂ} {w : σ → ℕ} {p : ℝ} + (h : D.HasUniformLowerRankUnitFamily R v w p) + (g : D.filtration.realification.PolynomialOrbit w) : + D.HasLowerRankUnitFamily R v g p := by + obtain ⟨n, hn, Q, U, hUc, hK⟩ := h + refine ⟨n, hn, Q, U, hUc, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + obtain ⟨K, hKn, hKc, hKu, a, _, hKe⟩ := hK + exact ⟨a g, (fun i => (K i).withOrbit (a g)), (fun _ => rfl), hKn, + (fun i => ((K i).withOrbit_complexity (a g) p).mpr (hKc i)), hKu, hKe g⟩ + +universe u v t + +theorem UnitVerticalObservable.hasUniformLowerRankUnitFamily + {L : Type u} {I : Type v} {σ : Type t} + [LieRing L] [LieAlgebra ℚ L] [Fintype I] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s r d : ℕ} (D : RationalFilteredNilmanifold L s d) + (R : D.DegreeRankStructure (r + 1)) {p : ℝ} + (V : D.UnitVerticalObservable (R.realSubgroup s (r + 1)) I p) + (w : σ → ℕ) (hp : 0 ≤ p) (hR : R.ComplexityLE p) + (hzero : ∀ x ∈ R.filtration.layer s (r + 1), V.frequency x = 0) : + let C := (UnitVerticalObservable.exists_lower_rank_family.{u, v, t} s).choose + D.HasUniformLowerRankUnitFamily R V.observable w ((p + C) ^ C) := by + obtain ⟨n, hn, Q, U, hQF, _, _, hUc, hK⟩ := + UnitVerticalObservable.uniform_lower_rank_family D R V w hp hR hzero + refine ⟨n, hn, Q, U, hUc, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + obtain ⟨K, hKn, hKc, hKu, _, hKe⟩ := hK + refine ⟨K, hKn, hKc, hKu, R.rankQuotientOrbit Q hQF, ?_, hKe⟩ + intro g hg + rw [R.rankQuotientOrbit_eval Q hQF, hg] + exact map_one _ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct BigOperators + +def HasLowerRankOrbitFamily {L I σ τ : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype I] + {s r d : ℕ} (D : RationalFilteredNilmanifold L s d) (R : D.DegreeRankStructure (r + 1)) + (w : σ → ℕ) (f : τ → I → (σ → ℤ) → ℂ) (p : ℝ) : Prop := + ∃ n : ℕ, n ≤ d ∧ + ∃ Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n, + ∃ U : Q.DegreeRankStructure r, U.ComplexityLE p ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 Q.basis + ∃ K : I → Q.Niltest w, + (∀ i, (K i).normBound = 1) ∧ (∀ i, (K i).ComplexityLE p) ∧ + (∀ y : Q.Space, ∑ i, ‖(K i).observable y‖ ^ 2 = 1) ∧ + ∃ a : τ → Q.filtration.realification.PolynomialOrbit w, + (∀ t, Q.filtration.realification.polynomialOrbitEval w 0 (a t) = 1) ∧ + ∀ t i x, ((K i).withOrbit (a t)).eval x = f t i x) + +theorem HasUniformLowerRankUnitFamily.realizeFamily {L I σ τ : Type*} + [LieRing L] [LieAlgebra ℚ L] [Fintype I] {s r d : ℕ} + {D : RationalFilteredNilmanifold L s d} {R : D.DegreeRankStructure (r + 1)} + {v : I → D.Space → ℂ} {w : σ → ℕ} {p : ℝ} + (h : D.HasUniformLowerRankUnitFamily R v w p) + (f : τ → I → (σ → ℤ) → ℂ) + (hf : ∀ t, ∃ g : D.filtration.realification.PolynomialOrbit w, + D.filtration.realification.polynomialOrbitEval w 0 g = 1 ∧ + ∀ i x, v i (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval w x g)) = f t i x) : + D.HasLowerRankOrbitFamily R w f p := by + classical + choose b hb0 hb using hf + obtain ⟨n, hn, Q, U, hUc, hK⟩ := h + refine ⟨n, hn, Q, U, hUc, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + obtain ⟨K, hKn, hKc, hKu, a, ha0, hKe⟩ := hK + exact ⟨K, hKn, hKc, hKu, (fun t => a (b t)), + (fun t => ha0 (b t) (hb0 t)), + fun t i x => (hKe (b t) i x).trans (hb t i x)⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module +open scoped TensorProduct BigOperators + +theorem HasLowerRankOrbitFamily.mono {L I σ τ : Type*} + [LieRing L] [LieAlgebra ℚ L] [Fintype I] {s r d : ℕ} + {D : RationalFilteredNilmanifold L s d} {R : D.DegreeRankStructure (r + 1)} + {w : σ → ℕ} {f : τ → I → (σ → ℤ) → ℂ} {p q : ℝ} + (h : D.HasLowerRankOrbitFamily R w f p) (hpq : p ≤ q) : + D.HasLowerRankOrbitFamily R w f q := by + obtain ⟨n, hn, Q, U, hUc, hK⟩ := h + refine ⟨n, hn, Q, U, hUc.mono U hpq, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + obtain ⟨K, hKn, hKc, hKu, a, ha0, hKe⟩ := hK + exact ⟨K, hKn, (fun i => (hKc i).mono hpq), hKu, a, ha0, hKe⟩ + +theorem exists_lower_rank_product_family {ι σ τ : Type*} + [Fintype ι] [DecidableEq ι] [Nonempty ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {I : ι → Type*} [∀ i, Fintype (I i)] + {s r : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (R : ∀ i, (D i).DegreeRankStructure (r + 1)) + (w : σ → ℕ) (f : ∀ i, τ → I i → (σ → ℤ) → ℂ) {p : ℝ} + (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (h : ∀ i, (D i).HasLowerRankOrbitFamily (R i) w (f i) p) : + ∃ n : ι → ℕ, (∀ i, n i ≤ d i) ∧ + ∃ Q : ∀ i, RationalFilteredNilmanifold (L i ⧸ (R i).filtration.layerIdeal s (r + 1)) s (n i), + ∃ U : ∀ i, (Q i).DegreeRankStructure r, + (piRank Q U).ComplexityLE (productNiltestBudget p) ∧ + (letI : ∀ i, TopologicalSpace (ℝ ⊗[ℚ] (L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + fun _ => moduleTopology ℝ _ + letI : ∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] (L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + fun _ => IsModuleTopology.isTopologicalAddGroup ℝ _ + letI : ∀ i, T2Space (ℝ ⊗[ℚ] (L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + fun i => realification_moduleTopology_t2 (Q i).basis + letI := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i ⧸ (R i).filtration.layerIdeal s (r + 1))) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 (pi Q).basis + ∃ K : (∀ i, I i) → (pi Q).Niltest w, + (∀ j, (K j).normBound = 1) ∧ + (∀ j, (K j).ComplexityLE (productNiltestBudget p)) ∧ + (∀ x, ∑ j, ‖(K j).observable x‖ ^ 2 = 1) ∧ + ∃ a : τ → (pi Q).filtration.realification.PolynomialOrbit w, + (∀ t, (pi Q).filtration.realification.polynomialOrbitEval w 0 (a t) = 1) ∧ + ∀ t j x, ((K j).withOrbit (a t)).eval x = ∏ i, f i t (j i) x) := by + classical + choose n hn Q U hUc hK using h + refine ⟨n, hn, Q, U, + (piRank_complexity Q U hp hι hUc).mono _ (productNiltestBudget_geometry hp), ?_⟩ + let : ∀ i, TopologicalSpace (ℝ ⊗[ℚ] (L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + fun _ => moduleTopology ℝ _ + let : ∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] (L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + fun _ => IsModuleTopology.isTopologicalAddGroup ℝ _ + let : ∀ i, T2Space (ℝ ⊗[ℚ] (L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + fun i => realification_moduleTopology_t2 (Q i).basis + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i ⧸ (R i).filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i ⧸ (R i).filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 (pi Q).basis + choose K hKn hKc hKu a ha0 hKe using hK + obtain ⟨_, V, hVn, hVc, hVu, hVa, hVe⟩ := exists_normalized_product_unit_family Q K U hp hι hUc + (fun i j => (hKn i j).le) hKc hKu (fun t i => a i t) (fun t i => ha0 i t) + refine ⟨V, hVn, hVc, hVu, + (fun t => NilpotentLieFiltration.piRealOrbit (fun i => (Q i).filtration) (fun i => a i t)), + hVa, ?_⟩ + intro t j x + rw [hVe] + exact Finset.prod_congr rfl (fun i _ => hKe i t (j i) x) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module +open scoped TensorProduct BigOperators + +theorem exists_binary_lower_rank_unit_family + {σ τ : Type*} {I J L₀ L₁ : Type} [Fintype I] [Fintype J] + [LieRing L₀] [LieAlgebra ℚ L₀] [LieRing L₁] [LieAlgebra ℚ L₁] + {s r d₀ d₁ : ℕ} (D₀ : RationalFilteredNilmanifold L₀ s d₀) + (D₁ : RationalFilteredNilmanifold L₁ s d₁) + (R₀ : D₀.DegreeRankStructure (r + 1)) (R₁ : D₁.DegreeRankStructure (r + 1)) + (w : σ → ℕ) (f₀ : τ → I → (σ → ℤ) → ℂ) (f₁ : τ → J → (σ → ℤ) → ℂ) + {p : ℝ} (hp : 2 ≤ p) + (h₀ : D₀.HasLowerRankOrbitFamily R₀ w f₀ p) + (h₁ : D₁.HasLowerRankOrbitFamily R₁ w f₁ p) : + ∃ F : NativeUnitRankFamily w s r τ (I × J) (productNiltestBudget p), + F.dim ≤ d₀ + d₁ ∧ ∀ t ij x, F.eval t ij x = f₀ t ij.1 x * f₁ t ij.2 x := by + classical + let D := optionFactors D₀ (fun _ : Unit => D₁) + let R : ∀ i : Option Unit, (D i).DegreeRankStructure (r + 1) + | none => R₀ + | some _ => R₁ + let K : Option Unit → Type + | none => I + | some _ => J + let : ∀ i, Fintype (K i) := fun i => match i with + | none => inferInstanceAs (Fintype I) + | some _ => inferInstanceAs (Fintype J) + let f : ∀ i, τ → K i → (σ → ℤ) → ℂ + | none => f₀ + | some _ => f₁ + have h : ∀ i, (D i).HasLowerRankOrbitFamily (R i) w (f i) p := fun i => by + match i with + | none => exact h₀ + | some _ => exact h₁ + obtain ⟨n, hn, Q, U, hU, hfamily⟩ := exists_lower_rank_product_family D R w f + (by linarith) (by simpa using hp) h + let L (i : Option Unit) := + optionLieSpace L₀ (fun _ : Unit => L₁) i ⧸ (R i).filtration.layerIdeal s (r + 1) + let : ∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i) := fun _ => moduleTopology ℝ _ + let : ∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i) := + fun _ => IsModuleTopology.isTopologicalAddGroup ℝ _ + let : ∀ i, T2Space (ℝ ⊗[ℚ] L i) := fun i => realification_moduleTopology_t2 (Q i).basis + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i)) := IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 (pi Q).basis + obtain ⟨V, hVn, hVc, hVu, a, ha, he⟩ := hfamily + let e : (∀ i, K i) ≃ I × J := { + toFun := fun k => (k none, k (some ())) + invFun := fun ij i => match i with + | none => ij.1 + | some _ => ij.2 + left_inv := by + intro k + funext i + rcases i with _ | ⟨⟩ <;> rfl + right_inv := fun _ => rfl + } + let F : NativeUnitRankFamily w s r τ (I × J) (productNiltestBudget p) := { + L := ∀ i, L i + dim := Fintype.card (Σ i : Option Unit, Fin (n i)) + model := pi Q + rank := piRank Q U + complexity := hU + test := fun ij => V (e.symm ij) + test_norm := fun ij => hVn (e.symm ij) + test_complexity := fun ij => hVc (e.symm ij) + unit := fun x => (e.symm.sum_comp (fun k => ‖(V k).observable x‖ ^ 2)).trans (hVu x) + orbit := a + normalized := ha + } + refine ⟨F, ?_, ?_⟩ + · change Fintype.card (Σ i : Option Unit, Fin (n i)) ≤ d₀ + d₁ + simp only [Fintype.card_sigma, Fintype.card_fin] + rw [Fintype.sum_option, Fintype.sum_unique] + exact Nat.add_le_add (hn none) (hn (some ())) + · intro t ij x + have hprod := he t (e.symm ij) x + rw [Fintype.prod_option, Fintype.prod_unique] at hprod + exact hprod + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BooleanCubeCoordinateFrame.lean b/lean/OAI/Combinatorics/Progressions/Linear/BooleanCubeCoordinateFrame.lean new file mode 100644 index 0000000000000000000000000000000000000000..127c57bfa85374ff0e3be359311ae792b9561ab0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BooleanCubeCoordinateFrame.lean @@ -0,0 +1,117 @@ +import OAI.Combinatorics.Progressions.Estimates.BooleanCubeModeWitness + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MvPolynomial +open scoped BigOperators Classical + +variable {α K R : Type*} [Fintype α] [DecidableEq α] [CommRing R] + +noncomputable def affineSite (root : K → R) (difference : α → K → R) + (s : Finset α) : Option K → R + | none => 1 + | some k => root k + ∑ i ∈ s, difference i k + +noncomputable def frameCoordinate (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) : Variable α K → MvPolynomial (Option K) R + | none => X none + | some (.inl i) => q i + | some (.inr k) => X (some k) - C (root k) * X none - ∑ i, C (difference i k) * q i + +noncomputable def liftCoordinate (root : K → R) (difference : α → K → R) : + Option K → MvPolynomial (Variable α K) R + | none => X none + | some k => C (root k) * X none + ∑ i, C (difference i k) * X (some (.inl i)) + X (some (.inr k)) + +noncomputable def frameProjection (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) : + MvPolynomial (Variable α K) R →ₐ[R] MvPolynomial (Option K) R := + aeval (frameCoordinate root difference q) + +noncomputable def frameLift (root : K → R) (difference : α → K → R) : + MvPolynomial (Option K) R →ₐ[R] MvPolynomial (Variable α K) R := + aeval (liftCoordinate root difference) + +omit [DecidableEq α] in +theorem frameProjection_lift (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) (P : MvPolynomial (Option K) R) : + frameProjection root difference q (frameLift root difference P) = P := by + have he : (frameProjection root difference q).comp (frameLift root difference) = AlgHom.id R _ := by + apply algHom_ext + intro v + cases v with + | none => simp [frameProjection, frameLift, liftCoordinate, frameCoordinate] + | some k => + simp only [AlgHom.comp_apply, frameLift, aeval_X, liftCoordinate, frameProjection, + map_add, map_sum, map_mul, aeval_C, algebraMap_eq, aeval_X, frameCoordinate, AlgHom.id_apply] + ring + exact AlgHom.congr_fun he P + +omit [DecidableEq α] in +theorem liftCoordinate_homogeneous (root : K → R) (difference : α → K → R) (v : Option K) : + (liftCoordinate root difference v).IsHomogeneous 1 := by + cases v with + | none => exact isHomogeneous_X R _ + | some k => + have hs : (∑ i, C (difference i k) * X (some (.inl i)) : + MvPolynomial (Variable α K) R).IsHomogeneous 1 := + IsHomogeneous.sum _ _ _ (fun i _ => (isHomogeneous_X R _).C_mul (difference i k)) + exact (((isHomogeneous_X R _).C_mul (root k)).add hs).add (isHomogeneous_X R _) + +omit [DecidableEq α] in +theorem frameLift_homogeneous (root : K → R) (difference : α → K → R) + {P : MvPolynomial (Option K) R} {h : ℕ} (hP : P.IsHomogeneous h) : + (frameLift root difference P).IsHomogeneous h := by + simpa only [frameLift, Nat.one_mul] using + hP.aeval (liftCoordinate root difference) (liftCoordinate_homogeneous root difference) + +omit [DecidableEq α] in +theorem frameCoordinate_homogeneous (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) (hq : ∀ i, (q i).IsHomogeneous 1) (v : Variable α K) : + (frameCoordinate root difference q v).IsHomogeneous 1 := by + cases v with + | none => exact isHomogeneous_X R _ + | some v => + cases v with + | inl i => exact hq i + | inr k => + apply ((isHomogeneous_X R _).sub ((isHomogeneous_X R _).C_mul (root k))).sub + exact IsHomogeneous.sum _ _ _ (fun i _ => (hq i).C_mul (difference i k)) + +theorem frameCoordinate_eval (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) + (hq : ∀ i s, eval (affineSite root difference s) (q i) = if i ∈ s then 1 else 0) + (s : Finset α) (v : Variable α K) : + eval (affineSite root difference s) (frameCoordinate root difference q v) = site s v := by + cases v with + | none => simp [frameCoordinate, affineSite, site] + | some v => + cases v with + | inl i => exact hq i s + | inr k => + simp only [frameCoordinate, map_sub, map_mul, map_sum, eval_X, eval_C, affineSite, + hq, mul_one, mul_ite, mul_zero, site] + simp + +theorem frameProjection_eval (root : K → R) (difference : α → K → R) + (q : α → MvPolynomial (Option K) R) + (hq : ∀ i s, eval (affineSite root difference s) (q i) = if i ∈ s then 1 else 0) + (s : Finset α) (P : MvPolynomial (Variable α K) R) : + eval (affineSite root difference s) (frameProjection root difference q P) = eval (site s) P := by + have he : (aeval (affineSite root difference s)).comp (frameProjection root difference q) = + aeval (site (β := K) s) := by + apply algHom_ext + intro v + simpa only [AlgHom.comp_apply, frameProjection, aeval_X, aeval_eq_eval] using + frameCoordinate_eval root difference q hq s v + exact AlgHom.congr_fun he P + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BooleanJetMatrixFactor.lean b/lean/OAI/Combinatorics/Progressions/Linear/BooleanJetMatrixFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a9c01de09879b22101df9b1a9a0a2c0119aca2e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BooleanJetMatrixFactor.lean @@ -0,0 +1,123 @@ +import OAI.Combinatorics.Progressions.Polynomial.BoundedArrayPolynomial + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators Classical + +def boundedSiteMatrix {K S : Type*} (h : ℕ) (site : S → K → ℤ) : + Matrix S (BoundedCoefficientExponent K h) ℤ := + fun s d => d.val.prod (fun k n => site s k ^ n) + +theorem siteEvaluation_boundedArrayPolynomial {K S W : Type*} [Fintype K] + [AddCommGroup W] [Module ℝ W] (h : ℕ) (site : S → K → ℤ) + (x : BoundedCoefficientExponent K h → W) : + siteEvaluation (fun s k => (site s k : ℝ)) (boundedArrayPolynomial h x) = + matrixModuleAction (fun s d => (boundedSiteMatrix h site s d : ℝ)) x := by + funext s + change eval (fun k => (site s k : ℝ)) (boundedArrayPolynomial h x) = + ∑ d : BoundedCoefficientExponent K h, (boundedSiteMatrix h site s d : ℝ) • x d + simp only [boundedArrayPolynomial, map_sum, eval_monomial, + boundedSiteMatrix, Finsupp.prod, Int.cast_prod, Int.cast_pow] + +theorem siteEvaluation_bounded_coefficients {K S W : Type*} [Fintype K] + [AddCommGroup W] [Module ℝ W] {h : ℕ} (site : S → K → ℤ) + (p : VectorPolynomial K ℝ W) (hp : DegreeLE (1 : K → ℕ) h p) : + siteEvaluation (fun s k => (site s k : ℝ)) p = + matrixModuleAction (fun s d => (boundedSiteMatrix h site s d : ℝ)) + (fun d => coefficients p d.val) := by + rw [← boundedArrayPolynomial_reconstruct p hp, siteEvaluation_boundedArrayPolynomial] + simp only [boundedArrayPolynomial_coeff] + +theorem bounded_site_factorization_to_array {K S J : Type*} [Fintype K] [Fintype J] + (U : Submodule ℝ (J → ℝ)) (h : ℕ) (site : S → K → ℤ) + (frequency : (K →₀ ℕ) → J → ℝ) (M : (S → U) →ₗ[ℝ] ℝ) + (hf : ∀ p : VectorPolynomial K ℝ U, DegreeLE (1 : K → ℕ) h p → + coefficientFunctional frequency (map U.subtype p) = M (siteEvaluation (fun s k => (site s k : ℝ)) p)) : + ∀ x, subspaceArrayFunctional U (fun d : BoundedCoefficientExponent K h => frequency d.val) x = + M (matrixModuleAction (fun s d => (boundedSiteMatrix h site s d : ℝ)) x) := by + intro x + have he := hf (boundedArrayPolynomial h x) (boundedArrayPolynomial_degreeLE h x) + rwa [coefficientFunctional_boundedArrayPolynomial, siteEvaluation_boundedArrayPolynomial] at he + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +noncomputable def booleanJetExtractionMatrix {α O : Type*} [DecidableEq α] + (rows : O → Finset α) : Matrix O (Finset α) ℤ := + fun o t => if t ⊆ rows o then (-1 : ℤ) ^ (rows o \ t).card else 0 + +theorem booleanJetExtractionMatrix_mulVec {α O : Type*} [Fintype α] [DecidableEq α] + (rows : O → Finset α) (f : Finset α → ℤ) (o : O) : + (booleanJetExtractionMatrix rows *ᵥ f) o = booleanCoefficient f (rows o) := by + classical + change (∑ t, (if t ⊆ rows o then (-1 : ℤ) ^ (rows o \ t).card else 0) * f t) = _ + simp only [ite_mul, zero_mul, ← Finset.sum_filter] + have hsets : Finset.univ.filter (fun t : Finset α => t ⊆ rows o) = (rows o).powerset := by + ext t + simp + rw [hsets] + rfl + +def boundedCoefficientIntegerExponentEquiv (K : Type*) (h : ℕ) : + VectorPolynomial.BoundedCoefficientExponent K h ≃ BoundedIntegerExponent K h where + toFun e := ⟨e.val, e.property⟩ + invFun e := ⟨e.val, e.property⟩ + left_inv _ := rfl + right_inv _ := rfl + +noncomputable def boundedCoefficientJetMatrix {α K O : Type*} [DecidableEq α] [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (h : ℕ) (rows : O → Finset α) : + Matrix O (VectorPolynomial.BoundedCoefficientExponent K h) ℤ := + fun o e => boundedDegreeIntegerJetMatrix root D h rows o + (boundedCoefficientIntegerExponentEquiv K h e) + +theorem booleanJetExtractionMatrix_mul_boundedSite {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (h : ℕ) (rows : O → Finset α) : + booleanJetExtractionMatrix rows * + VectorPolynomial.boundedSiteMatrix h (integerAffineCube root D) = + boundedCoefficientJetMatrix root D h rows := by + ext o e + change (booleanJetExtractionMatrix rows *ᵥ + (fun t => VectorPolynomial.boundedSiteMatrix h (integerAffineCube root D) t e)) o = _ + rw [booleanJetExtractionMatrix_mulVec] + change booleanCoefficient _ (rows o) = booleanCoefficient _ (rows o) + congr 1 + funext t + simp [VectorPolynomial.boundedSiteMatrix, MvPolynomial.eval_monomial, Finsupp.prod, + boundedCoefficientIntegerExponentEquiv] + +theorem boundedCoefficientJetMatrix_period {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] + (root : K → ℤ) (D : Matrix α K ℤ) (a : ℤ) + (hperiod : integerScalarLattice α a ≤ D.mulVecLin.range) + (h : ℕ) (rows : O → Finset α) (hinj : Function.Injective rows) + (hdegree : ∀ o, (rows o).card ≤ h) : + integerScalarLattice O (a ^ h) ≤ (boundedCoefficientJetMatrix root D h rows).mulVecLin.range := by + intro y hy + obtain ⟨x, hx⟩ := boundedDegreeIntegerJetMatrix_period root D a hperiod h rows hinj hdegree hy + let e := boundedCoefficientIntegerExponentEquiv K h + refine ⟨fun d => x (e d), ?_⟩ + ext o + change (∑ d, boundedCoefficientJetMatrix root D h rows o d * x (e d)) = y o + calc + _ = ∑ d, boundedDegreeIntegerJetMatrix root D h rows o d * x d := + Fintype.sum_equiv e _ _ (fun _ => rfl) + _ = y o := congrFun hx o + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BoundedAdaptedBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/BoundedAdaptedBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..85f7771599c56d371f108dce6f70c29de1ad1903 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BoundedAdaptedBasis.lean @@ -0,0 +1,539 @@ +import Mathlib.LinearAlgebra.Basis.Basic +import Mathlib.Order.Interval.Finset.Fin +import OAI.Combinatorics.Progressions.Estimates.RealifiedMultidegree +import OAI.Combinatorics.Progressions.Linear.SpanningFlagSelection +import OAI.Combinatorics.Progressions.Linear.WeightedFlagBasis + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +theorem span_inter_eq_of_spanning_family {η : Type*} (P : Submodule K V) + (v : η → P) (hspan : Submodule.span K (Set.range v) = ⊤) + (S : Set V) (hv : ∀ i, (v i : V) ∈ S) : + Submodule.span K (S ∩ (P : Set V)) = P := by + apply le_antisymm + · exact Submodule.span_le.mpr (fun _ hx => hx.2) + · have hmap := congrArg (Submodule.map P.subtype) hspan + rw [Submodule.map_span, Submodule.map_top, Submodule.range_subtype] at hmap + conv_lhs => rw [← hmap] + apply Submodule.span_mono + rintro x ⟨_, ⟨i, rfl⟩, rfl⟩ + exact ⟨hv i, (v i).property⟩ + +theorem exists_sorted_flag_basis_from_spanning_set [FiniteDimensional K V] {n : ℕ} + (P : Fin n → Submodule K V) (hP : Antitone P) (S : Set V) + (hS : Submodule.span K S = ⊤) + (hspan : ∀ i, Submodule.span K (S ∩ (P i : Set V)) = P i) : + ∃ (e : Basis (Fin (finrank K V)) K V) (w : Fin (finrank K V) → ℕ), + Monotone w ∧ (∀ j, w j ≤ n) ∧ (∀ j, e j ∈ S) ∧ + ∀ i, P i = Submodule.span K (e '' {j | i.val < w j}) := by + classical + obtain ⟨B, hBS, hBli, hBspan, T, hT, hTB, hTspan⟩ := + exists_nested_independent_spanning_sets n P S hP hspan + have hsp : ⊤ ≤ Submodule.span K (Set.range ((↑) : B → V)) := by + simp only [Subtype.range_coe_subtype, Set.ofPred_mem_eq, hBspan, hS, le_refl] + let b : Basis B K V := Basis.mk hBli.linearIndependent_restrict hsp + let : Finite B := Module.Finite.finite_basis b + let : Fintype B := Fintype.ofFinite B + let ρ : B ≃ Fin (finrank K V) := Fintype.equivFinOfCardEq (finrank_eq_card_basis b).symm + let u : Fin (finrank K V) → ℕ := fun j => nestedSupportWeight T (ρ.symm j).val + let σ := Tuple.sort u + let e := b.reindex (ρ.trans σ.symm) + let w : Fin (finrank K V) → ℕ := fun j => u (σ j) + have he (j : Fin (finrank K V)) : e j = (ρ.symm (σ j)).val := by + simp [e, b, Basis.reindex_apply] + refine ⟨e, w, Tuple.monotone_sort u, fun j => nestedSupportWeight_le T _, ?_, ?_⟩ + · intro j + rw [he] + exact hBS (ρ.symm (σ j)).property + · intro i + rw [← hTspan i] + congr 1 + ext x + constructor + · intro hx + let k : B := ⟨x, hTB i hx⟩ + refine ⟨σ.symm (ρ k), ?_, ?_⟩ + · simpa only [Set.mem_ofPred_eq, w, u, Equiv.apply_symm_apply, + Equiv.symm_apply_apply] using (mem_nestedSupport_iff T hT i x).mp hx + · simp only [he, Equiv.apply_symm_apply, Equiv.symm_apply_apply, k] + · rintro ⟨j, hj, rfl⟩ + rw [he] + exact (mem_nestedSupport_iff T hT i _).mpr hj + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + +def basisTail (e : Basis (Fin d) ℚ L) (i : ℕ) : Submodule ℚ L where + carrier := {x | ∀ j : Fin d, j.val < i → e.repr x j = 0} + zero_mem' := by simp + add_mem' hx hy := by + intro j hj + simp only [map_add, Finsupp.add_apply, hx j hj, hy j hj, zero_add] + smul_mem' c x hx := by + intro j hj + simp only [map_smul, Finsupp.smul_apply, hx j hj, smul_zero] + +theorem basisTail_antitone (e : Basis (Fin d) ℚ L) : Antitone (basisTail e) := + fun _ _ hij _ hx k hk => hx k (lt_of_lt_of_le hk hij) + +theorem basisTail_zero (e : Basis (Fin d) ℚ L) : basisTail e 0 = ⊤ := by + apply top_unique + intro x _ j hj + omega + +theorem basisTail_terminal (e : Basis (Fin d) ℚ L) : basisTail e d = ⊥ := by + apply bot_unique + intro x hx + change x = 0 + apply e.repr.injective + ext j + simpa only [map_zero, Finsupp.zero_apply] using hx j j.isLt + +theorem basisTail_eq_span (e : Basis (Fin d) ℚ L) (i : ℕ) : + basisTail e i = Submodule.span ℚ (e '' {j : Fin d | i ≤ j.val}) := by + ext x + rw [e.mem_span_image] + constructor + · intro hx j hj + by_contra h + exact (Finsupp.mem_support_iff.mp hj) (hx j (Nat.lt_of_not_ge h)) + · intro hx j hj + by_contra h + exact (not_le_of_gt hj) (hx (Finsupp.mem_support_iff.mpr h)) + +theorem basis_mem_tail (e : Basis (Fin d) ℚ L) (j : Fin d) {i : ℕ} (hij : i ≤ j.val) : + e j ∈ basisTail e i := by + rw [basisTail_eq_span] + exact Submodule.subset_span ⟨j, hij, rfl⟩ + +theorem mem_basisTail_succ_iff (e : Basis (Fin d) ℚ L) (j : Fin d) (x : L) : + x ∈ basisTail e (j.val + 1) ↔ x ∈ basisTail e j.val ∧ e.repr x j = 0 := by + constructor + · intro hx + exact ⟨basisTail_antitone e (Nat.le_succ j.val) hx, hx j (Nat.lt_succ_self j.val)⟩ + · rintro ⟨hx, hj⟩ k hk + by_cases hkj : k = j + · simpa only [hkj] using hj + · apply hx k + have hne : k.val ≠ j.val := fun h => hkj (Fin.ext h) + omega + +theorem sub_coordinate_mem_tail (e : Basis (Fin d) ℚ L) (j : Fin d) {x : L} + (hx : x ∈ basisTail e j.val) : + x - e.repr x j • e j ∈ basisTail e (j.val + 1) := by + classical + intro k hk + by_cases hkj : k = j + · subst k + simp + · have hlt : k.val < j.val := by + have hne : k.val ≠ j.val := fun h => hkj (Fin.ext h) + omega + simp only [map_sub, Finsupp.sub_apply, map_smul, Finsupp.smul_apply, + hx k hlt, Basis.repr_self, Finsupp.single_eq_of_ne hkj, smul_zero, sub_zero] + +def IsCentralLieBasis (e : Basis (Fin d) ℚ L) : Prop := + ∀ (j : Fin d) (a : L), ⁅a, e j⁆ ∈ basisTail e (j.val + 1) + +namespace IsCentralLieBasis + +variable {e : Basis (Fin d) ℚ L} (he : IsCentralLieBasis e) +include he + +theorem lie_mem_tail_succ (i : ℕ) (a : L) {b : L} (hb : b ∈ basisTail e i) : + ⁅a, b⁆ ∈ basisTail e (i + 1) := by + classical + rw [← e.sum_repr b, lie_sum] + apply Submodule.sum_mem + intro j _ + rw [lie_smul] + by_cases hj : j.val < i + · rw [hb j hj, zero_smul] + exact (basisTail e (i + 1)).zero_mem + · exact (basisTail e (i + 1)).smul_mem _ + (basisTail_antitone e (Nat.add_le_add_right (Nat.le_of_not_gt hj) 1) (he j a)) + +def tailIdeal (i : ℕ) : LieIdeal ℚ L := + { basisTail e i with + lie_mem := by + intro a b hb + exact basisTail_antitone e (Nat.le_succ i) (he.lie_mem_tail_succ i a hb) } + +theorem coordinate_lie_eq_zero (i j k : Fin d) (hkj : k.val ≤ j.val) : + e.repr ⁅e i, e j⁆ k = 0 := he j (e i) k (Nat.lt_succ_of_le hkj) + +end IsCentralLieBasis + +theorem centralLieBasis_of_sorted_filtration {s : ℕ} (F : NilpotentLieFiltration L s) + (e : Basis (Fin d) ℚ L) (w : Fin d → ℕ) (hw : Monotone w) + (hlayer : ∀ i, F.layer i = Submodule.span ℚ (e '' {j | i ≤ w j})) : + IsCentralLieBasis e := by + intro j a + have ha : a ∈ F.layer 1 := by simp [F.one_eq_top] + have hj : e j ∈ F.layer (w j) := by + rw [hlayer] + exact Submodule.subset_span ⟨j, by simp, rfl⟩ + have hbr := F.lie_mem ha hj + rw [hlayer] at hbr + rw [basisTail_eq_span] + apply Submodule.span_mono (Set.image_mono ?_) hbr + intro k hk + change j.val + 1 ≤ k.val + change 1 + w j ≤ w k at hk + by_contra h + have hkj : k ≤ j := by change k.val ≤ j.val; omega + have hweight := hw hkj + omega + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d n : ℕ} + +theorem finite_flag_weight_le (P : ℕ → Submodule ℚ L) (e : Basis (Fin d) ℚ L) + (w : Fin d → ℕ) (hn : P n = ⊥) + (hspan : P n = Submodule.span ℚ (e '' {j | n < w j})) (j : Fin d) : w j ≤ n := by + by_contra h + have hj : e j ∈ P n := by + rw [hspan] + exact Submodule.subset_span ⟨j, Nat.lt_of_not_ge h, rfl⟩ + rw [hn] at hj + exact e.ne_zero j (by simpa only [Submodule.mem_bot] using hj) + +theorem centralLieBasis_of_finite_flag (P : ℕ → Submodule ℚ L) + (e : Basis (Fin d) ℚ L) (w : Fin d → ℕ) + (hzero : P 0 = ⊤) (hterminal : P n = ⊥) + (hstep : ∀ i, ∀ {x y : L}, y ∈ P i → ⁅x, y⁆ ∈ P (i + 1)) + (hw : Monotone w) + (hspan : ∀ i : Fin (n + 1), P i.val = Submodule.span ℚ (e '' {j | i.val < w j})) : + IsCentralLieBasis e := by + intro j a + have hjn : w j ≤ n := finite_flag_weight_le P e w hterminal (hspan ⟨n, by omega⟩) j + have hbr : ⁅a, e j⁆ ∈ P (w j) := by + cases hweight : w j with + | zero => simp only [hzero, Submodule.mem_top] + | succ k => + apply hstep k + rw [hspan ⟨k, by omega⟩] + exact Submodule.subset_span ⟨j, by change k < w j; omega, rfl⟩ + rw [hspan ⟨w j, by omega⟩] at hbr + rw [basisTail_eq_span] + apply Submodule.span_mono (Set.image_mono ?_) hbr + intro k hk + change j.val + 1 ≤ k.val + change w j < w k at hk + by_contra h + have hkj : k ≤ j := by change k.val ≤ j.val; omega + exact (not_lt_of_ge (hw hkj)) hk + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] [FiniteDimensional ℚ L] + {s : ℕ} (F : NilpotentLieFiltration L s) + +include F + +omit [FiniteDimensional ℚ L] in +theorem layer_eq_span_of_weighted_flag {d : ℕ} (e : Basis (Fin d) ℚ L) (w : Fin d → ℕ) + (hbound : ∀ j, w j ≤ s + 1) + (hlayer : ∀ i : Fin (s + 1), + F.layer (i.val + 1) = Submodule.span ℚ (e '' {j | i.val < w j})) : + ∀ i, F.layer i = Submodule.span ℚ (e '' {j | i ≤ w j}) := by + intro i + cases i with + | zero => + have hzero : F.layer 0 = ⊤ := by + apply top_unique + rw [← F.one_eq_top] + exact F.antitone (by omega) + simp only [hzero, Nat.zero_le, Set.ofPred_true, Set.image_univ, e.span_eq] + | succ i => + by_cases hi : i < s + 1 + · simpa only [Nat.succ_le_iff] using hlayer ⟨i, hi⟩ + · have htail : F.layer (i + 1) = ⊥ := by + apply bot_unique + simpa only [F.terminal] using F.antitone (show s + 1 ≤ i + 1 by omega) + have hempty : {j | i + 1 ≤ w j} = (∅ : Set (Fin d)) := by + ext j + simp only [Set.mem_ofPred_eq, Set.mem_empty_iff_false, iff_false] + have := hbound j + omega + rw [htail, hempty, Set.image_empty, Submodule.span_empty] + +theorem exists_sorted_adapted_basis : + ∃ (e : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ), + Monotone w ∧ (∀ j, w j ≤ s + 1) ∧ + ∀ i, F.layer i = Submodule.span ℚ (e '' {j | i ≤ w j}) := by + let P : Fin (s + 1) → Submodule ℚ L := fun i => F.layer (i.val + 1) + have hP : Antitone P := fun i j hij => F.antitone (Nat.add_le_add_right hij 1) + obtain ⟨e, w, hw, hbound, hlayer⟩ := exists_sorted_weighted_flag_basis P hP + exact ⟨e, w, hw, hbound, F.layer_eq_span_of_weighted_flag e w hbound hlayer⟩ + +theorem exists_central_basis : + ∃ e : Basis (Fin (finrank ℚ L)) ℚ L, IsCentralLieBasis e := by + obtain ⟨e, w, hw, _, hlayer⟩ := F.exists_sorted_adapted_basis + exact ⟨e, centralLieBasis_of_sorted_filtration F e w hw hlayer⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3 + +open Module + +noncomputable def weightCut {d : ℕ} (w : Fin d → ℕ) (k : ℕ) : ℕ := by + classical + exact (Finset.univ.filter (fun j => w j ≤ k)).card + +theorem weightCut_le {d : ℕ} (w : Fin d → ℕ) (k : ℕ) : weightCut w k ≤ d := by + classical + simpa only [weightCut, Finset.card_univ, Fintype.card_fin] using + (Finset.card_filter_le (s := (Finset.univ : Finset (Fin d))) (p := fun j => w j ≤ k)) + +theorem weight_gt_iff_cut_le {d : ℕ} (w : Fin d → ℕ) (hw : Monotone w) (k : ℕ) (j : Fin d) : + k < w j ↔ weightCut w k ≤ j.val := by + classical + let A := Finset.univ.filter (fun i => w i ≤ k) + constructor + · intro hj + have hA : A ⊆ Finset.Iio j := by + intro i hi + apply Finset.mem_Iio.mpr + have hiw : w i ≤ k := (Finset.mem_filter.mp hi).2 + by_contra h + have := hw (le_of_not_gt h) + omega + have hcard := Finset.card_le_card hA + simpa only [A, Fin.card_Iio, weightCut] using hcard + · intro hj + by_contra h + have hjw : w j ≤ k := le_of_not_gt h + have hA : Finset.Iic j ⊆ A := by + intro i hi + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (hw (Finset.mem_Iic.mp hi)).trans hjw⟩ + have hcard := Finset.card_le_card hA + rw [Fin.card_Iic] at hcard + change j.val + 1 ≤ weightCut w k at hcard + omega + +theorem span_weight_gt_eq_basisTail {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + (b : Basis (Fin d) ℚ L) (w : Fin d → ℕ) (hw : Monotone w) (k : ℕ) : + Submodule.span ℚ (b '' {j | k < w j}) = basisTail b (weightCut w k) := by + rw [basisTail_eq_span] + apply congrArg (Submodule.span ℚ) + apply congrArg (fun S : Set (Fin d) => b '' S) + ext j + exact weight_gt_iff_cut_le w hw k j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℝ L] {d : ℕ} + +def realBasisTail (e : Basis (Fin d) ℝ L) (i : ℕ) : Submodule ℝ L where + carrier := {x | ∀ j : Fin d, j.val < i → e.repr x j = 0} + zero_mem' := by simp + add_mem' hx hy := by + intro j hj + simp only [map_add, Finsupp.add_apply, hx j hj, hy j hj, zero_add] + smul_mem' c x hx := by + intro j hj + simp only [map_smul, Finsupp.smul_apply, hx j hj, smul_zero] + +theorem realBasisTail_antitone (e : Basis (Fin d) ℝ L) : Antitone (realBasisTail e) := + fun _ _ hij _ hx k hk => hx k (lt_of_lt_of_le hk hij) + +theorem realBasisTail_zero (e : Basis (Fin d) ℝ L) : realBasisTail e 0 = ⊤ := by + apply top_unique + intro x _ j hj + omega + +theorem realBasisTail_terminal (e : Basis (Fin d) ℝ L) : realBasisTail e d = ⊥ := by + apply bot_unique + intro x hx + change x = 0 + apply e.repr.injective + ext j + simpa only [map_zero, Finsupp.zero_apply] using hx j j.isLt + +theorem realBasisTail_eq_span (e : Basis (Fin d) ℝ L) (i : ℕ) : + realBasisTail e i = Submodule.span ℝ (e '' {j : Fin d | i ≤ j.val}) := by + ext x + rw [e.mem_span_image] + constructor + · intro hx j hj + by_contra h + exact (Finsupp.mem_support_iff.mp hj) (hx j (Nat.lt_of_not_ge h)) + · intro hx j hj + by_contra h + exact (not_le_of_gt hj) (hx (Finsupp.mem_support_iff.mpr h)) + +theorem real_basis_mem_tail (e : Basis (Fin d) ℝ L) (j : Fin d) {i : ℕ} (hij : i ≤ j.val) : + e j ∈ realBasisTail e i := by + rw [realBasisTail_eq_span] + exact Submodule.subset_span ⟨j, hij, rfl⟩ + +theorem mem_realBasisTail_succ_iff (e : Basis (Fin d) ℝ L) (j : Fin d) (x : L) : + x ∈ realBasisTail e (j.val + 1) ↔ x ∈ realBasisTail e j.val ∧ e.repr x j = 0 := by + constructor + · intro hx + exact ⟨realBasisTail_antitone e (Nat.le_succ j.val) hx, hx j (Nat.lt_succ_self j.val)⟩ + · rintro ⟨hx, hj⟩ k hk + by_cases hkj : k = j + · simpa only [hkj] using hj + · apply hx k + have hne : k.val ≠ j.val := fun h => hkj (Fin.ext h) + omega + +theorem real_sub_coordinate_mem_tail (e : Basis (Fin d) ℝ L) (j : Fin d) {x : L} + (hx : x ∈ realBasisTail e j.val) : + x - e.repr x j • e j ∈ realBasisTail e (j.val + 1) := by + classical + intro k hk + by_cases hkj : k = j + · subst k + simp + · have hlt : k.val < j.val := by + have hne : k.val ≠ j.val := fun h => hkj (Fin.ext h) + omega + simp only [map_sub, Finsupp.sub_apply, map_smul, Finsupp.smul_apply, + hx k hlt, Basis.repr_self, Finsupp.single_eq_of_ne hkj, smul_zero, sub_zero] + +def IsRealCentralLieBasis (e : Basis (Fin d) ℝ L) : Prop := + ∀ (j : Fin d) (a : L), ⁅a, e j⁆ ∈ realBasisTail e (j.val + 1) + +namespace IsRealCentralLieBasis + +variable {e : Basis (Fin d) ℝ L} (he : IsRealCentralLieBasis e) +include he + +theorem lie_mem_tail_succ (i : ℕ) (a : L) {b : L} (hb : b ∈ realBasisTail e i) : + ⁅a, b⁆ ∈ realBasisTail e (i + 1) := by + classical + rw [← e.sum_repr b, lie_sum] + apply Submodule.sum_mem + intro j _ + rw [lie_smul] + by_cases hj : j.val < i + · rw [hb j hj, zero_smul] + exact (realBasisTail e (i + 1)).zero_mem + · exact (realBasisTail e (i + 1)).smul_mem _ + (realBasisTail_antitone e (Nat.add_le_add_right (Nat.le_of_not_gt hj) 1) (he j a)) + +noncomputable def tailIdeal [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] (i : ℕ) : LieIdeal ℚ L := + { (realBasisTail e i).restrictScalars ℚ with + lie_mem := by + intro a b hb + exact realBasisTail_antitone e (Nat.le_succ i) (he.lie_mem_tail_succ i a hb) } + +theorem coordinate_lie_eq_zero (i j k : Fin d) (hkj : k.val ≤ j.val) : + e.repr ⁅e i, e j⁆ k = 0 := he j (e i) k (Nat.lt_succ_of_le hkj) + +end IsRealCentralLieBasis + +end Erdos3 + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + +theorem IsCentralLieBasis.real_baseChange {e : Basis (Fin d) ℚ L} + (he : IsCentralLieBasis e) : IsRealCentralLieBasis (e.baseChange ℝ) := by + intro j a + induction a using TensorProduct.inductionOn with + | tmul r a => + intro k hk + simp only [Basis.baseChange_apply, LieAlgebra.ExtendScalars.bracket_tmul, + mul_one, Basis.baseChange_repr_tmul, he j a k hk, zero_smul] + | add a b ha hb => + rw [add_lie] + exact (realBasisTail (e.baseChange ℝ) (j.val + 1)).add_mem ha hb + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} (F : NilpotentLieFiltration L s) (e : Basis ι ℚ L) + +theorem exists_bounded_sorted_adapted_basis {η : Fin (s + 1) → Type*} + (v : ∀ i, η i → F.layer (i.val + 1)) + (hspan : ∀ i, Submodule.span ℚ (Set.range (v i)) = ⊤) {H : ℕ} + (hv : ∀ i j k, RationalHeightLE (e.repr (v i j : L) k) H) : + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ), + Monotone w ∧ (∀ j, w j ≤ s + 1) ∧ IsCentralLieBasis b ∧ + (∀ j k, RationalHeightLE (e.repr (b j) k) H) ∧ + ∀ i, F.layer i = Submodule.span ℚ (b '' {j | i ≤ w j}) := by + let : FiniteDimensional ℚ L := e.finiteDimensional_of_finite + let S : Set L := {x | ∀ k, RationalHeightLE (e.repr x k) H} + let P : Fin (s + 1) → Submodule ℚ L := fun i => F.layer (i.val + 1) + have hP : Antitone P := fun i j hij => F.antitone (Nat.add_le_add_right hij 1) + have hSP (i : Fin (s + 1)) : Submodule.span ℚ (S ∩ (P i : Set L)) = P i := + span_inter_eq_of_spanning_family (P i) (v i) (hspan i) S (hv i) + have hS : Submodule.span ℚ S = ⊤ := by + apply top_unique + calc + ⊤ = P 0 := F.one_eq_top.symm + _ = Submodule.span ℚ (S ∩ (P 0 : Set L)) := (hSP 0).symm + _ ≤ Submodule.span ℚ S := Submodule.span_mono Set.inter_subset_left + obtain ⟨b, w, hw, hbound, hbS, hbP⟩ := + exists_sorted_flag_basis_from_spanning_set P hP S hS hSP + have hlayer := F.layer_eq_span_of_weighted_flag b w hbound hbP + exact ⟨b, w, hw, hbound, centralLieBasis_of_sorted_filtration F b w hw hlayer, hbS, hlayer⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BoundedRankIntegralModel.lean b/lean/OAI/Combinatorics/Progressions/Linear/BoundedRankIntegralModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..a60ef28f527cd729bb25f25730049f34afc51558 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BoundedRankIntegralModel.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.Progressions.Nilpotent.FreeDegreeRankNilmanifold + +namespace OAI + +section + +namespace Erdos3.DegreeRankLieFiltration + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r d : ℕ} + (F : DegreeRankLieFiltration L s r) (e : Basis (Fin d) ℚ L) + (b : ∀ i : Fin (s + 1), Basis (Fin (finrank ℚ (F.associatedDegree.layer (i.val + 1)))) + ℚ (F.associatedDegree.layer (i.val + 1))) + (c : ∀ i j : Fin (s + 1), Basis (Fin (finrank ℚ (F.layer i.val j.val))) + ℚ (F.layer i.val j.val)) + (B : ℕ) (hB : 0 < B) + (hstable : ∀ x ∈ coordinateGridModule e B, ∀ y ∈ coordinateGridModule e B, + lieBCH s x y ∈ coordinateGridModule e B) + +noncomputable def boundedRankIntegralModel : RationalFilteredNilmanifold L s d where + filtration := F.associatedDegree + basis := e + layerBasis := b + lattice := coordinateGridBCHSubgroup e B F.associatedDegree.lowerCentralSeries_eq_bot hstable + grid := B + grid_pos := hB + inner_grid := by rw [coordinateGridBCHSubgroup_coordinates] + outer_grid := by + rw [coordinateGridBCHSubgroup_coordinates] + exact scaledIntegerGrid_le_denominatorGrid B B + +noncomputable def boundedRankIntegralStructure : + (F.boundedRankIntegralModel e b B hB hstable).DegreeRankStructure r where + filtration := F + associated := rfl + basis := c + +theorem boundedRankIntegralModel_coordinates : + bchSubgroupCoordinates (F.boundedRankIntegralModel e b B hB hstable).basis + (F.boundedRankIntegralModel e b B hB hstable).lattice = scaledIntegerGrid B := + coordinateGridBCHSubgroup_coordinates e B F.associatedDegree.lowerCentralSeries_eq_bot hstable + +theorem boundedRankIntegralStructure_complexity {H : ℕ} + (hb : ∀ i a j, RationalHeightLE (e.repr (b i a).val j) H) + (hc : ∀ i j a k, RationalHeightLE (e.repr (c i j a).val k) H) + (hbracket : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + {p : ℝ} (hd : (d : ℝ) ≤ p) (hgrid : (B : ℝ) ≤ Real.exp p) + (hheight : (H : ℝ) ≤ Real.exp p) : + (F.boundedRankIntegralStructure e b c B hB hstable).ComplexityLE p := + ⟨⟨hd, hgrid, fun i j k => rationalLogHeight_le_of_height (hbracket i j k) hheight, + fun i a j => rationalLogHeight_le_of_height (hb i a j) hheight⟩, + fun i j a k => rationalLogHeight_le_of_height (hc i j a k) hheight⟩ + +omit B hB hstable in +theorem exists_bounded_rank_integral_model {H : ℕ} + (hb : ∀ i a j, RationalHeightLE (e.repr (b i a).val j) H) + (hc : ∀ i j a k, RationalHeightLE (e.repr (c i j a).val k) H) + (hbracket : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (l : ℕ) (hl : 0 < l) : + ∃ B : ℕ, 0 < B ∧ l ∣ B ∧ B ≤ bchIntegralDenominatorBound s * H ^ (d ^ 3) * l ∧ + ∃ D : RationalFilteredNilmanifold L s d, ∃ T : D.DegreeRankStructure r, + T.filtration = F ∧ D.basis = e ∧ D.grid = B ∧ + bchSubgroupCoordinates D.basis D.lattice = scaledIntegerGrid B ∧ + ∀ p : ℝ, (d : ℝ) ≤ p → (B : ℝ) ≤ Real.exp p → (H : ℝ) ≤ Real.exp p → T.ComplexityLE p := by + obtain ⟨B, hB, hdiv, hbound, hstable⟩ := + exists_bch_stable_integral_grid e F.associatedDegree.lowerCentralSeries_eq_bot l hl hbracket + exact ⟨B, hB, hdiv, by simpa only [Fintype.card_fin] using hbound, + F.boundedRankIntegralModel e b B hB hstable, + F.boundedRankIntegralStructure e b c B hB hstable, rfl, rfl, rfl, + F.boundedRankIntegralModel_coordinates e b B hB hstable, + fun _ hd hg hh => F.boundedRankIntegralStructure_complexity e b c B hB hstable + hb hc hbracket hd hg hh⟩ + +omit B hB hstable in +theorem exists_bounded_rank_integral_model_with_frequency {H : ℕ} + (hb : ∀ i a j, RationalHeightLE (e.repr (b i a).val j) H) + (hc : ∀ i j a k, RationalHeightLE (e.repr (c i j a).val k) H) + (hbracket : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (ξ : L →ₗ[ℚ] ℚ) (hξ : ∀ i, RationalHeightLE (ξ (e i)) H) + (l : ℕ) (hl : 0 < l) : + ∃ B : ℕ, 0 < B ∧ l ∣ B ∧ + B ≤ bchIntegralDenominatorBound s * H ^ (d ^ 3) * (l * H ^ d) ∧ + ∃ D : RationalFilteredNilmanifold L s d, ∃ T : D.DegreeRankStructure r, + T.filtration = F ∧ D.basis = e ∧ D.grid = B ∧ + bchSubgroupCoordinates D.basis D.lattice = scaledIntegerGrid B ∧ + (∀ z : D.filtration.Group, z ∈ D.lattice → ∃ n : ℤ, ξ z.coord = n) ∧ + ∀ p : ℝ, (d : ℝ) ≤ p → (B : ℝ) ≤ Real.exp p → (H : ℝ) ≤ Real.exp p → T.ComplexityLE p := by + classical + let k := arrayDenominator (fun i => ξ (e i)) + have hk : 0 < k := arrayDenominator_pos _ + have hkH : k ≤ H ^ d := by + simpa only [Fintype.card_fin] using arrayDenominator_le (fun i => ξ (e i)) (fun i => (hξ i).2) + obtain ⟨B, hB, hdiv, hbound, D, T, hTF, hDe, hDB, hcoords, hcomplex⟩ := + F.exists_bounded_rank_integral_model e b c hb hc hbracket (l * k) (Nat.mul_pos hl hk) + refine ⟨B, hB, (dvd_mul_right l k).trans hdiv, + hbound.trans (Nat.mul_le_mul_left _ (Nat.mul_le_mul_left l hkH)), + D, T, hTF, hDe, hDB, hcoords, ?_, hcomplex⟩ + intro z hz + have hgrid : D.basis.equivFun z.coord ∈ scaledIntegerGrid B := by + rw [← hcoords] + change (⟨D.basis.equivFun.symm (D.basis.equivFun z.coord)⟩ : D.filtration.Group) ∈ D.lattice + simpa only [LinearEquiv.symm_apply_apply] using hz + rw [hDe] at hgrid + exact coordinateGrid_functional_integral e ξ k B ((dvd_mul_left k l).trans hdiv) + (fun i => ⟨clearedArray (fun j => ξ (e j)) i, (clearedArray_cast _ i).symm⟩) hgrid + +end Erdos3.DegreeRankLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BoundedSpanningPadding.lean b/lean/OAI/Combinatorics/Progressions/Linear/BoundedSpanningPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bb05c9c8d0ce62f21b92223c4f6d5f0d3ce7c9c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BoundedSpanningPadding.lean @@ -0,0 +1,63 @@ +import OAI.Combinatorics.Progressions.Estimates.BoundedSubmoduleIntersection + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι η L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (K : LieSubalgebra ℚ L) + +theorem exists_bounded_ambient_spanning (v : η → K) + (hspan : Submodule.span ℚ (Set.range v) = ⊤) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ a i, RationalHeightLE (e.repr (v a : L) i) H) : + ∃ w : Fin (Fintype.card ι) → L, + Submodule.span ℚ (Set.range w) = K.toSubmodule ∧ + ∀ a i, RationalHeightLE (e.repr (w a) i) H := by + classical + obtain ⟨b, hb⟩ := exists_bounded_lie_subalgebra_basis e K v hspan hv + have hr := lie_subalgebra_finrank_le e K + let w : Fin (Fintype.card ι) → L := fun a => + if ha : a.val < Module.finrank ℚ K then (b ⟨a.val, ha⟩ : L) else 0 + have hw (i : Fin (Module.finrank ℚ K)) : + w ⟨i.val, lt_of_lt_of_le i.isLt hr⟩ = (b i : L) := by + simp only [w, dite_eq_left i.isLt] + refine ⟨w, ?_, ?_⟩ + · apply le_antisymm + · apply Submodule.span_le.mpr + rintro x ⟨a, rfl⟩ + dsimp only [w] + split_ifs with ha + · exact (b ⟨a.val, ha⟩).property + · exact K.zero_mem + · have htop : (⊤ : Submodule ℚ K) ≤ + (Submodule.span ℚ (Set.range w)).comap K.incl.toLinearMap := by + rw [← b.span_eq] + apply Submodule.span_le.mpr + rintro y ⟨i, rfl⟩ + change (b i : L) ∈ Submodule.span ℚ (Set.range w) + rw [← hw i] + exact Submodule.subset_span ⟨_, rfl⟩ + intro x hx + exact htop (show (⟨x, hx⟩ : K) ∈ (⊤ : Submodule ℚ K) by trivial) + · intro a i + dsimp only [w] + split_ifs with ha + · exact hb ⟨a.val, ha⟩ i + · simpa only [map_zero, Finsupp.zero_apply] using rationalHeightLE_zero hH + +theorem bounded_spanning_mem_heightBoundedLieSubalgebras (v : η → K) + (hspan : Submodule.span ℚ (Set.range v) = ⊤) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ a i, RationalHeightLE (e.repr (v a : L) i) H) : + K ∈ heightBoundedLieSubalgebras e (Fintype.card ι) H := by + obtain ⟨w, hw, hh⟩ := exists_bounded_ambient_spanning e K v hspan hH hv + exact (mem_heightBoundedSubspaces e (Fintype.card ι) H K.toSubmodule).mpr ⟨w, hw, hh⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BudgetedProjectionAccuracy.lean b/lean/OAI/Combinatorics/Progressions/Linear/BudgetedProjectionAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f18ee8a1a58d30039e0b84add9b648ad40300e0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BudgetedProjectionAccuracy.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.Progressions.Sampling.BudgetedGridProjection + +namespace OAI + +section + +namespace Erdos3.IntegerFourierBudget + +open scoped BigOperators Classical + +theorem controls_coefficientCap_nonneg {X J : Type*} [Fintype X] [Fintype J] + (B : IntegerFourierBudget) (p : FiniteProbabilityWeights X) + (Y : (J → ℤ) → X → J → ℤ) (K M : ℕ) [NeZero M] (hmodel : B.Controls p Y K M) : + 0 ≤ B.coefficientCap := by + obtain ⟨_, _, hcap, _⟩ := hmodel 1 (by norm_num) le_rfl + exact (Finset.sum_nonneg (fun _ _ => norm_nonneg _)).trans (hcap (fun _ => 0)) + +theorem projected_approximation_at_error {X J H G : Type*} + [Fintype X] [Fintype J] [AddCommGroup H] [Fintype H] [Fintype G] + (B : IntegerFourierBudget) (p : FiniteProbabilityWeights X) + (Y : (J → ℤ) → X → J → ℤ) (K M : ℕ) [NeZero M] (hKM : K ≤ M) + (hmodel : B.Controls p Y K M) (q : FiniteProbabilityWeights G) + (ι : H →+ (J → ZMod M)) (w : G → ℂ) (path : G → J → ℤ) + {W δ : ℝ} (hδ : 0 < δ) (hw : q.mean (fun x => ‖w x‖) ≤ W) + (hdiscard : ∀ k, B.RationalMode K M (projectionApproxTolerance W δ) k → + (rectangularResidueMode M k).compAddMonoidHom ι ≠ 1 → + ‖q.complexMean (fun x => w x * star (rectangularGridCharacter M k (path x)))‖ ≤ + projectionModeTolerance B.coefficientCap δ) : + ∃ S : Finset (J → Fin M), + (S.card : ℝ) ≤ B.countConstant / (projectionApproxTolerance W δ) ^ B.countExponent ∧ + (∀ center, (∑ k, ‖integerGridCoefficient p (Y center) M k‖) ≤ B.coefficientCap) ∧ + (∀ k ∈ S, B.RationalMode K M (projectionApproxTolerance W δ) k) ∧ + ∀ center, (∀ x, q.weight x ≠ 0 → centeredFundamentalBox B.radius K center (path x)) → + ‖q.complexMean (fun x => w x * + (((K : ℝ) ^ Fintype.card J * finiteImageMass p (Y center) (path x) : ℝ) : ℂ)) - + q.complexMean (fun x => w x * finiteCosetAverage ι (residueGridApproximation p (Y center) K M S) + (integerGridResidue M (path x)))‖ ≤ δ := by + have hW : 0 ≤ W := (q.mean_nonneg (fun x => norm_nonneg (w x))).trans hw + have hs := projectionErrorBudget_spec hW (B.controls_coefficientCap_nonneg p Y K M hmodel) hδ + obtain ⟨S, hcount, hcap, hchar, herr⟩ := B.projected_approximation p Y K M hKM hmodel q ι w path + hs.1 hs.2.1 hs.2.2.1.le hw hdiscard + exact ⟨S, hcount, hcap, hchar, fun center hpath => (herr center hpath).trans hs.2.2.2⟩ + +end Erdos3.IntegerFourierBudget + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BufferedCoordinateProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/BufferedCoordinateProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..22e077b622bb712696e5b8a12b7379a981b9788d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BufferedCoordinateProjection.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Geometry.NormalizedCoordinateCutoff +import OAI.Combinatorics.Progressions.Linear.CoordinateZeroProjection + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +variable {D : Type*} [Fintype D] (P : D → Prop) [DecidablePred P] +variable (r : ℝ≥0) (hr : 0 < r) (f : (D → ℝ) → ℂ) + +noncomputable def bufferedCoordinateProjection (z : D → ℝ) : ℂ := + (normalizedCoordinateCutoff D r hr z : ℂ) * f (coordinateZeroProjection P z) + +theorem bufferedCoordinateProjection_norm_le (hf : ∀ z, ‖f z‖ ≤ 1) (z : D → ℝ) : + ‖bufferedCoordinateProjection P r hr f z‖ ≤ 1 := by + have hc := (normalizedCoordinateCutoff_spec D r hr).2.2.1 z + rw [bufferedCoordinateProjection, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg hc.1] + exact (mul_le_mul hc.2 (hf _) (norm_nonneg _) zero_le_one).trans_eq (one_mul 1) + +theorem bufferedCoordinateProjection_lipschitz {L : ℝ≥0} + (hf : LipschitzWith L f) (hf1 : ∀ z, ‖f z‖ ≤ 1) : + LipschitzWith (L + Fintype.card D * normalizedSiteCutoffBound / (2 * r)) + (bufferedCoordinateProjection P r hr f) := by + have hc := normalizedCoordinateCutoff_spec D r hr + have hcLip : LipschitzWith (Fintype.card D * normalizedSiteCutoffBound / (2 * r)) + (fun z => (normalizedCoordinateCutoff D r hr z : ℂ)) := by + apply LipschitzWith.of_dist_le_mul + intro z w + rw [Complex.isometry_ofReal.dist_eq] + exact hc.2.2.2.2.2.dist_le_mul z w + have hc1 (z : D → ℝ) : ‖(normalizedCoordinateCutoff D r hr z : ℂ)‖ ≤ (1 : ℝ≥0) := by + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hc.2.2.1 z).1] + exact (hc.2.2.1 z).2 + have h := lipschitz_mul_of_bounds _ _ hcLip (hf.comp (coordinateZeroProjection_lipschitz P)) + (Bf := 1) (Bg := 1) hc1 (fun z => hf1 (coordinateZeroProjection P z)) + apply LipschitzWith.of_dist_le_mul + intro z w + simpa only [bufferedCoordinateProjection, Function.comp_def, one_mul, mul_one] using h.dist_le_mul z w + +theorem bufferedCoordinateProjection_hasCompactSupport : + HasCompactSupport (bufferedCoordinateProjection P r hr f) := by + have hc : HasCompactSupport (fun z => (normalizedCoordinateCutoff D r hr z : ℂ)) := + (normalizedCoordinateCutoff_spec D r hr).2.1.comp_left Complex.ofReal_zero + exact hc.mul_right + +theorem bufferedCoordinateProjection_eq (z : D → ℝ) (hz : ∀ d, |z d| ≤ (r : ℝ)) : + bufferedCoordinateProjection P r hr f z = f (coordinateZeroProjection P z) := by + rw [bufferedCoordinateProjection, (normalizedCoordinateCutoff_spec D r hr).2.2.2.1 z hz, + Complex.ofReal_one, one_mul] + +theorem bufferedCoordinateProjection_nonzero_box (z : D → ℝ) + (hz : bufferedCoordinateProjection P r hr f z ≠ 0) : ∀ d, |z d| ≤ 2 * (r : ℝ) := by + apply (normalizedCoordinateCutoff_spec D r hr).2.2.2.2.1 z + intro hc + apply hz + rw [bufferedCoordinateProjection, hc, Complex.ofReal_zero, zero_mul] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/BufferedKernelFamily.lean b/lean/OAI/Combinatorics/Progressions/Linear/BufferedKernelFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ee4d71130e91811a91cc462fc6ce586d7c58e9d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/BufferedKernelFamily.lean @@ -0,0 +1,41 @@ +import OAI.Combinatorics.Progressions.Lattices.BufferedIntegerLift + +namespace OAI + +section + +namespace Erdos3.PatchKernel + +theorem buffered_family_lift_value_eq {m : ℕ} (Ψ : (Fin m → ℤ) → PatchKernel m) + (x : Fin m → ℝ) (β γ : Fin m → ℤ) + (hβ : ∀ i, |x i - (β i : ℝ)| ≤ 1 / 2) + (hmatch : (Ψ β).value (fun i => x i - (β i : ℝ)) ≠ 0 → γ = β) + (f : (Fin m → ℤ) → ℝ) : + (Ψ γ).value (fun i => x i - (γ i : ℝ)) * f γ = + (Ψ β).value (fun i => x i - (β i : ℝ)) * f β := by + by_cases h : (Ψ β).value (fun i => x i - (β i : ℝ)) = 0 + · have hzero : (Ψ γ).value (fun i => x i - (γ i : ℝ)) = 0 := by + by_contra hγ + have heq := (Ψ γ).buffered_lift_unique x β γ hβ hγ + exact hγ (by simpa only [heq] using h) + rw [hzero, h, zero_mul, zero_mul] + · rw [hmatch h] + +theorem buffered_family_sum_eq_nearest {m : ℕ} (Ψ : (Fin m → ℤ) → PatchKernel m) + (x : Fin m → ℝ) (f : (Fin m → ℤ) → ℝ) : + (∑' β, (Ψ β).value (fun i => x i - (β i : ℝ)) * f β) = + (Ψ (nearestIntegerLift x)).value (fun i => x i - (nearestIntegerLift x i : ℝ)) * + f (nearestIntegerLift x) := by + classical + apply tsum_eq_single (nearestIntegerLift x) + intro γ hγ + have hzero : (Ψ γ).value (fun i => x i - (γ i : ℝ)) = 0 := by + by_contra hn + exact hγ ((Ψ γ).buffered_lift_unique x _ γ (nearestIntegerLift_close x) hn) + rw [hzero, zero_mul] + +end Erdos3.PatchKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CanonicalAmbientKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalAmbientKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..a91c4619588cd427d6d93dafca7e9932f4c7aeca --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalAmbientKernel.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.Progressions.Estimates.EmptyLayerDetectionGeometry +import OAI.Combinatorics.Progressions.Geometry.NormalizedChartLift +import OAI.Combinatorics.Progressions.Geometry.SmallBoxCutoff + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule MeasureTheory +open scoped NNReal + +variable {D I : Type*} [Fintype D] [Fintype I] {n : ℕ} +variable (W : Submodule ℝ (EuclideanSpace ℝ D)) (b : Basis (Fin n) ℝ Wᗮ) +variable (hb : span ℤ (Set.range b) = projectedIntegerLattice W) (o : OrthonormalBasis I ℝ W) + +noncomputable def canonicalAmbientKernel (c w : I → ℝ) (f : Fin n → ℝ → ℝ) + (v : D → ℝ) : ℝ := + smallBoxCutoff v * mixedAmbientInterpolation W b o c w f v + +theorem canonicalAmbientKernel_support (c w : I → ℝ) (f : Fin n → ℝ → ℝ) + (v : D → ℝ) (hv : canonicalAmbientKernel W b o c w f v ≠ 0) : + ∀ i, |v i| < 1/2 := + smallBoxCutoff_support v (left_ne_zero_of_mul hv) + +theorem canonicalAmbientKernel_eq_of_lift (c w : I → ℝ) (f : Fin n → ℝ → ℝ) + (p : Fin n → PMF ℤ) + (hf : ∀ i (k : ℤ), f i ((k : ℝ) / basisAxisScale b i) = basisAxisScale b i * (p i k).toReal) + (hs : ∀ x, mixedCoefficientDensity c w p x ≠ 0 → ∀ d, + |normalizedLatticePoint W b (orthonormalMixedChart o x) d| ≤ 1/4) + (u : W) (v : D → ℝ) + (hv : u.val - (EuclideanSpace.equiv D ℝ).symm v ∈ standardEuclideanLattice D) + (hsmall : ∀ d, |v d| < 1/2) : + canonicalAmbientKernel W b o c w f v = canonicalMixedDensity W b hb o c w p + (QuotientAddGroup.mk' (latticeSection (standardEuclideanLattice D) W).toAddSubgroup u) := by + obtain ⟨y, hy, hq⟩ := exists_normalized_chart_lift W b hb u _ hv + let x := (orthonormalMixedChart o).symm y + have hx : normalizedLatticePoint W b (orthonormalMixedChart o x) = + (EuclideanSpace.equiv D ℝ).symm v := by + simpa only [x, MeasurableEquiv.apply_symm_apply] using hy + have hqx : normalizedLatticeQuotient W b hb (orthonormalMixedChart o x) = + QuotientAddGroup.mk' (latticeSection (standardEuclideanLattice D) W).toAddSubgroup u := by + simpa only [x, MeasurableEquiv.apply_symm_apply] using hq + have hgrid : mixedAmbientInterpolation W b o c w f v = + ZLattice.covolume (latticeSection (standardEuclideanLattice D) W) * + mixedCoefficientDensity c w p x := by + simpa only [Prod.mk.eta, hx, ContinuousLinearEquiv.apply_symm_apply] using + mixedAmbientInterpolation_grid W b o c w f p hf x.1 x.2 + have hd : canonicalMixedDensity W b hb o c w p + (QuotientAddGroup.mk' (latticeSection (standardEuclideanLattice D) W).toAddSubgroup u) = + ZLattice.covolume (latticeSection (standardEuclideanLattice D) W) * + mixedCoefficientDensity c w p x := by + rw [← hqx] + apply canonicalMixedDensity_apply W b hb o + rw [hx] + exact hsmall + rw [canonicalAmbientKernel, hgrid, hd] + by_cases hzero : mixedCoefficientDensity c w p x = 0 + · rw [hzero, mul_zero, mul_zero] + · have hquarter : ∀ d, |v d| ≤ 1/4 := by + have hh := hs x hzero + rw [hx] at hh + exact hh + rw [smallBoxCutoff_one v hquarter, one_mul] + +theorem canonicalAmbientKernel_bounds (c w : I → ℝ) (f : Fin n → ℝ → ℝ) + {M J C V : ℝ≥0} + (hM : ∀ x, 0 ≤ mixedDensityInterpolation c w f x ∧ mixedDensityInterpolation c w f x ≤ M) + (hJ : LipschitzWith J (mixedDensityInterpolation c w f)) + (hC : ∀ x, ‖normalizedOrthogonalChart W b x‖ ≤ C * ‖x‖) + (hV : 0 ≤ mixedDensityCovolumeRatio W b ∧ mixedDensityCovolumeRatio W b ≤ V) : + (∀ x, 0 ≤ canonicalAmbientKernel W b o c w f x ∧ + canonicalAmbientKernel W b o c w f x ≤ V * M) ∧ + LipschitzWith (V * (J * (C * Fintype.card D)) + (V * M) * 8) + (canonicalAmbientKernel W b o c w f) := by + obtain ⟨hcap, hlip⟩ := mixedAmbientInterpolation_bounds W b o c w f hM hJ hC hV + refine ⟨?_, smallBoxCutoff_mul_lipschitz _ hlip ?_⟩ + · intro x + refine ⟨mul_nonneg (smallBoxCutoff_range x).1 (hcap x).1, ?_⟩ + exact (mul_le_mul_of_nonneg_right (smallBoxCutoff_range x).2 (hcap x).1).trans + (by simpa only [one_mul] using (hcap x).2) + · intro x + rw [abs_of_nonneg (hcap x).1] + exact (hcap x).2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CanonicalJointFrameGeometry.lean b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalJointFrameGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..a96c2276f061c6209dc50c705883c6a3b10f5546 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalJointFrameGeometry.lean @@ -0,0 +1,322 @@ +import OAI.Combinatorics.Progressions.Lattices.RoundedAffineLifts +import OAI.Combinatorics.Progressions.Probability.AnisotropicSmoothPairLaw + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel +open scoped Classical + +noncomputable def jointFrameSourceLo {K I : Type*} (width : Option K × I → ℝ) : + Option K × I → ℤ := + fun t => match t.1 with + | none => 0 + | some _ => -⌈width t⌉ + +noncomputable def jointFrameSourceHi {K I : Type*} (N : I → ℕ) + (width : Option K × I → ℝ) : Option K × I → ℤ := + fun t => match t.1 with + | none => N t.2 + | some _ => ⌈width t⌉ + 1 + +theorem jointFrameSource_nonempty {K I : Type*} (N : I → ℕ) + (hN : ∀ i, 0 < N i) (width : Option K × I → ℝ) (hw : ∀ t, 0 ≤ width t) : + ∀ t, jointFrameSourceLo width t < jointFrameSourceHi N width t := by + rintro ⟨_ | k, i⟩ + · simpa [jointFrameSourceLo, jointFrameSourceHi] using hN i + · have hc : (0 : ℤ) ≤ ⌈width (some k,i)⌉ := Int.ceil_nonneg (hw _) + dsimp [jointFrameSourceLo, jointFrameSourceHi] + omega + +theorem jointIntegerFrame_mem_sourceBox {K I : Type*} [Fintype K] [Fintype I] + [DecidableEq I] (N margin : I → ℕ) (hmargin : ∀ i, 2 * margin i ≤ N i) + (width : Option K × I → ℝ) (hroot : ∀ i, width (none,i) ≤ (margin i : ℝ)) + (z : trimmedIntegerBox N margin × rectangularWeightIndices 0 width 1) : + ∀ t, jointIntegerFrame (z.1.val,z.2.val) t.1 t.2 ∈ + Finset.Ico (jointFrameSourceLo width t) (jointFrameSourceHi N width t) := by + have hb := rectangularWeightIndices_zero_bound width z.2.property + have hconstant : (fun i => z.1.val i + z.2.val (none,i)) ∈ integerBox N := by + apply trimmedIntegerBox_add_mem N margin hmargin z.1.property + intro i + have h := (hb (none,i)).trans (hroot i) + exact_mod_cast h + rintro ⟨_ | k, i⟩ + · simpa only [jointIntegerFrame, jointFrameSourceLo, jointFrameSourceHi, + Finset.mem_Ico] using (mem_integerBox N _).mp hconstant i + · have hbound : |z.2.val (some k,i)| ≤ ⌈width (some k,i)⌉ := by + exact_mod_cast (hb (some k,i)).trans (Int.le_ceil _) + have hparts := abs_le.mp hbound + simp only [jointIntegerFrame, jointFrameSourceLo, jointFrameSourceHi, Finset.mem_Ico] + omega + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped Classical + +theorem jointFrameSource_window_bounds {K I : Type*} [Fintype K] [Fintype I] + (N : I → ℕ) (width : Option K × I → ℝ) {L : ℝ} (hL : 0 < L) + (hwide : ∀ k i, 1 ≤ width (some k, i)) + (hsmall : ∀ k i, 3 * width (some k, i) ≤ (N i : ℝ) / L) : + (∀ z ∈ Fintype.piFinset (fun t => + Finset.Ico (jointFrameSourceLo width t) (jointFrameSourceHi N width t)), + ∀ t, |(z t : ℝ)| ≤ smoothPairCoefficientScale (2 * (N t.2 : ℝ)) L t.1 / 2) ∧ + (∀ k i, |(jointFrameSourceLo width (some k, i) : ℝ)| ≤ 2 * (N i : ℝ) / L) ∧ + (∀ k i, |(jointFrameSourceHi N width (some k, i) : ℝ)| ≤ 2 * (N i : ℝ) / L) := by + have hceil0 (k : K) (i : I) : (0 : ℝ) ≤ (⌈width (some k, i)⌉ : ℤ) := by + exact_mod_cast Int.ceil_nonneg (zero_le_one.trans (hwide k i)) + have hceil (k : K) (i : I) : + (⌈width (some k, i)⌉ : ℝ) + 1 ≤ (N i : ℝ) / L := by + have hc := Int.ceil_lt_add_one (width (some k, i)) + have hw := hwide k i + have hs := hsmall k i + linarith + have hdouble (i : I) : (N i : ℝ) / L ≤ 2 * (N i : ℝ) / L := by + apply div_le_div_of_nonneg_right _ hL.le + nlinarith [Nat.cast_nonneg (N i) (α := ℝ)] + refine ⟨?_, ?_, ?_⟩ + · intro z hz t + have ht := Finset.mem_Ico.mp (Fintype.mem_piFinset.mp hz t) + rcases t with ⟨_ | k, i⟩ + · simp only [jointFrameSourceLo, jointFrameSourceHi] at ht + have hz0 : (0 : ℝ) ≤ z (none, i) := by exact_mod_cast ht.1 + have hzN : (z (none, i) : ℝ) < N i := by exact_mod_cast ht.2 + simpa only [smoothPairCoefficientScale, mul_div_cancel_left₀ _ (by norm_num : (2 : ℝ) ≠ 0), + abs_of_nonneg hz0] using hzN.le + · have hlo : -(⌈width (some k, i)⌉ : ℝ) ≤ z (some k, i) := by + exact_mod_cast ht.1 + have hhi : (z (some k, i) : ℝ) < (⌈width (some k, i)⌉ : ℝ) + 1 := by + exact_mod_cast ht.2 + have hzbound : |(z (some k, i) : ℝ)| ≤ (N i : ℝ) / L := by + apply abs_le.mpr + constructor <;> linarith [hceil k i] + have hscale : smoothPairCoefficientScale (2 * (N i : ℝ)) L (some k) / 2 = + (N i : ℝ) / L := by + dsimp [smoothPairCoefficientScale] + ring + rwa [hscale] + · intro k i + simp only [jointFrameSourceLo, Int.cast_neg, abs_neg, + abs_of_nonneg (hceil0 k i)] + exact (by linarith [hceil k i] : (⌈width (some k, i)⌉ : ℝ) ≤ (N i : ℝ) / L).trans + (hdouble i) + · intro k i + simp only [jointFrameSourceHi, Int.cast_add, Int.cast_one, + abs_of_nonneg (add_nonneg (hceil0 k i) zero_le_one)] + exact (hceil k i).trans (hdouble i) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel +open scoped BigOperators Classical + +private theorem jointFrame_slope_side_cap {W : ℝ} (hW : 1 ≤ W) : + 0 ≤ (2 * (⌈W⌉ : ℝ) + 1) * (2 / W) ∧ + (2 * (⌈W⌉ : ℝ) + 1) * (2 / W) ≤ 10 := by + have hW0 : 0 < W := by linarith + have hceil0 : (0 : ℝ) ≤ (⌈W⌉ : ℤ) := by exact_mod_cast Int.ceil_nonneg hW0.le + constructor + · positivity + · rw [← mul_div_assoc] + apply (div_le_iff₀ hW0).mpr + have hc := Int.ceil_lt_add_one W + nlinarith + +theorem jointFrameSource_volume_cap_le {K I : Type*} [Fintype K] [Fintype I] + (N margin : I → ℕ) (hmargin : ∀ i, 2 * margin i < N i) + (hloss : (∑ i, 2 * (margin i : ℝ) / N i) ≤ 1/2) + (width : Option K × I → ℝ) (hwidth : ∀ t : K × I, 1 ≤ width (some t.1,t.2)) : + (∏ t, ((jointFrameSourceHi N width t - jointFrameSourceLo width t : ℤ) : ℝ)) * + (((trimmedIntegerBox N margin).card : ℝ)⁻¹ * + ∏ t : K × I, 2 / width (some t.1,t.2)) ≤ 2 * 10 ^ Fintype.card (K × I) := by + have hvolume : + (∏ t, ((jointFrameSourceHi N width t - jointFrameSourceLo width t : ℤ) : ℝ)) = + (∏ i, (N i : ℝ)) * + ∏ t : K × I, (2 * (⌈width (some t.1,t.2)⌉ : ℝ) + 1) := by + rw [Fintype.prod_prod_type, Fintype.prod_option] + simp only [jointFrameSourceHi, jointFrameSourceLo, sub_zero, Int.cast_natCast, + Int.cast_sub, Int.cast_add, Int.cast_neg, Int.cast_one] + rw [Fintype.prod_prod_type] + congr 1 + apply Finset.prod_congr rfl + intro k _ + apply Finset.prod_congr rfl + intro i _ + ring + have hproduct : + (∏ t : K × I, (2 * (⌈width (some t.1,t.2)⌉ : ℝ) + 1) * + (2 / width (some t.1,t.2))) ≤ 10 ^ Fintype.card (K × I) := by + calc + _ ≤ ∏ _t : K × I, (10 : ℝ) := + Finset.prod_le_prod₀ (fun t _ => (jointFrame_slope_side_cap (hwidth t)).1) + (fun t _ => (jointFrame_slope_side_cap (hwidth t)).2) + _ = _ := by simp + calc + _ = (((integerBox N).card : ℝ) / (trimmedIntegerBox N margin).card) * + ∏ t : K × I, (2 * (⌈width (some t.1,t.2)⌉ : ℝ) + 1) * + (2 / width (some t.1,t.2)) := by + rw [hvolume, card_integerBox, Nat.cast_prod, Finset.prod_mul_distrib, div_eq_mul_inv] + ring + _ ≤ 2 * 10 ^ Fintype.card (K × I) := + mul_le_mul (trimmedIntegerBox_card_ratio_le_two N margin hmargin hloss) hproduct + (Finset.prod_nonneg (fun t _ => (jointFrame_slope_side_cap (hwidth t)).1)) + (by norm_num) + +theorem jointFrameSource_volume_exp_bound (d : ℕ) {p : ℝ} + (hp : 4 * ((d : ℝ) + 1) ≤ p) : + 2 * (10 : ℝ)^d ≤ Real.exp p := by + have h2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have h16 : (16 : ℝ) ≤ Real.exp 4 := by + have hpow := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) h2 4 + norm_num [← Real.exp_nat_mul] at hpow ⊢ + exact hpow + calc + _ ≤ Real.exp 4 * (Real.exp 4)^d := by + gcongr <;> linarith + _ = Real.exp (4 * ((d : ℝ) + 1)) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := Real.exp_le_exp.mpr hp + +theorem jointFrameSource_volume_cap_le_exp {K I : Type*} [Fintype K] [Fintype I] + (N margin : I → ℕ) (hmargin : ∀ i, 2 * margin i < N i) + (hloss : (∑ i, 2 * (margin i : ℝ) / N i) ≤ 1/2) + (width : Option K × I → ℝ) (hwidth : ∀ t : K × I, 1 ≤ width (some t.1,t.2)) + {p : ℝ} (hp : 4 * ((Fintype.card (K × I) : ℝ) + 1) ≤ p) : + (∏ t, ((jointFrameSourceHi N width t - jointFrameSourceLo width t : ℤ) : ℝ)) * + (((trimmedIntegerBox N margin).card : ℝ)⁻¹ * + ∏ t : K × I, 2 / width (some t.1,t.2)) ≤ Real.exp p := + (jointFrameSource_volume_cap_le N margin hmargin hloss width hwidth).trans + (jointFrameSource_volume_exp_bound _ hp) + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel +open scoped BigOperators Classical + +noncomputable def canonicalJointFrameWindowConstant (d : ℕ) (τ : ℝ) : ℝ := + 16 * (2 * (d : ℝ) + 1) / τ + +theorem canonicalJointFrameWindowConstant_two_le (d : ℕ) {τ : ℝ} + (hτ : 0 < τ) (hτ1 : τ ≤ 1) : + 2 ≤ canonicalJointFrameWindowConstant d τ := by + unfold canonicalJointFrameWindowConstant + apply (le_div_iff₀ hτ).mpr + have hd : (0 : ℝ) ≤ d := Nat.cast_nonneg _ + nlinarith + +theorem canonicalJointFrame_slope_small {K I : Type*} (N : I → ℕ) + {L Wsite τ : ℝ} (hL : 1 ≤ L) (hW : L ≤ Wsite) (_hτ : 0 < τ) (hτ1 : τ ≤ 1) + (k : K) (i : I) : + 3 * trimmedSpatialWidths Wsite τ N (some k,i) ≤ (N i : ℝ) / L := by + have hLp : 0 < L := lt_of_lt_of_le zero_lt_one hL + have hden : 0 < 8 * (1 + Wsite) := by linarith + have hc : 3 * τ * L ≤ 8 * (1 + Wsite) := by + have hh := mul_le_mul_of_nonneg_right hτ1 hLp.le + nlinarith + have hN : (0 : ℝ) ≤ N i := Nat.cast_nonneg _ + have hmul := mul_le_mul_of_nonneg_right hc hN + dsimp only [trimmedSpatialWidths, centeredSpatialWidths] + rw [le_div_iff₀ hLp] + have hdiv : (3 * τ * L * (N i : ℝ)) / (8 * (1 + Wsite)) ≤ (N i : ℝ) := + (div_le_iff₀ hden).mpr (by simpa only [mul_comm] using hmul) + calc + _ = (3 * τ * L * (N i : ℝ)) / (8 * (1 + Wsite)) := by ring + _ ≤ (N i : ℝ) := hdiv + +theorem canonicalJointFrame_slope_scale (d : ℕ) (N : ℕ) + {L Wsite τ : ℝ} (hL : 1 ≤ L) (hW0 : 0 ≤ Wsite) + (hW : Wsite ≤ 2 * (d : ℝ) * L) (hτ : 0 < τ) : + 2 * (N : ℝ) / L ≤ canonicalJointFrameWindowConstant d τ * + (τ * ((N : ℝ) / (8 * (1 + Wsite)))) := by + have hLp : 0 < L := lt_of_lt_of_le zero_lt_one hL + have hden : 0 < 1 + Wsite := by linarith + have hc : 1 + Wsite ≤ (2 * (d : ℝ) + 1) * L := by nlinarith + have hN : (0 : ℝ) ≤ N := Nat.cast_nonneg _ + have hmul := mul_le_mul_of_nonneg_left hc (show 0 ≤ 2 * (N : ℝ) by positivity) + have he : canonicalJointFrameWindowConstant d τ * + (τ * ((N : ℝ) / (8 * (1 + Wsite)))) = + 2 * (2 * (d : ℝ) + 1) * (N : ℝ) / (1 + Wsite) := by + unfold canonicalJointFrameWindowConstant + field_simp [hτ.ne', hden.ne'] + ring + rw [he] + apply (div_le_div_iff₀ hLp hden).mpr + nlinarith + +theorem canonicalJointFrame_source_scale {K I : Type*} (d : ℕ) (N : I → ℕ) + {L Wsite τ : ℝ} (hL : 1 ≤ L) (hW0 : 0 ≤ Wsite) + (hW : Wsite ≤ 2 * (d : ℝ) * L) (hτ : 0 < τ) (hτ1 : τ ≤ 1) + (t : Option K × I) : + smoothPairCoefficientScale (2 * (N t.2 : ℝ)) L t.1 ≤ + canonicalJointFrameWindowConstant d τ * + ((jointFrameSourceHi N (trimmedSpatialWidths Wsite τ N) t - + jointFrameSourceLo (trimmedSpatialWidths Wsite τ N) t : ℤ) : ℝ) := by + have hK := canonicalJointFrameWindowConstant_two_le d hτ hτ1 + rcases t with ⟨_ | k,i⟩ + · simpa only [smoothPairCoefficientScale, jointFrameSourceHi, jointFrameSourceLo, + sub_zero, Int.cast_natCast] using + mul_le_mul_of_nonneg_right hK (Nat.cast_nonneg (α := ℝ) (N i)) + · have hs := canonicalJointFrame_slope_scale d (N i) hL hW0 hW hτ + have hw : 0 ≤ trimmedSpatialWidths Wsite τ N (some k,i) := by + dsimp only [trimmedSpatialWidths, centeredSpatialWidths] + positivity + have hc := Int.le_ceil (trimmedSpatialWidths Wsite τ N (some k,i)) + have hlen : trimmedSpatialWidths Wsite τ N (some k,i) ≤ + ((jointFrameSourceHi N (trimmedSpatialWidths Wsite τ N) (some k,i) - + jointFrameSourceLo (trimmedSpatialWidths Wsite τ N) (some k,i) : ℤ) : ℝ) := by + dsimp only [jointFrameSourceHi, jointFrameSourceLo] + push_cast + linarith + have hlen' : τ * ((N i : ℝ) / (8 * (1 + Wsite))) ≤ + ((jointFrameSourceHi N (trimmedSpatialWidths Wsite τ N) (some k,i) - + jointFrameSourceLo (trimmedSpatialWidths Wsite τ N) (some k,i) : ℤ) : ℝ) := by + simpa only [trimmedSpatialWidths, centeredSpatialWidths, one_mul] using hlen + exact hs.trans (mul_le_mul_of_nonneg_left hlen' (by linarith)) + +theorem canonicalJointFrame_source_geometry {K I : Type*} [Fintype K] [Fintype I] + (d : ℕ) (N : I → ℕ) {L Wsite τ : ℝ} + (hL : 1 ≤ L) (hWL : L ≤ Wsite) (hW : Wsite ≤ 2 * (d : ℝ) * L) + (hτ : 0 < τ) (hτ1 : τ ≤ 1) + (hwide : ∀ i, 1 ≤ τ * ((N i : ℝ) / (8 * (1 + Wsite)))) : + let width := trimmedSpatialWidths (K := K) Wsite τ N + (∀ t, smoothPairCoefficientScale (2 * (N t.2 : ℝ)) L t.1 ≤ + canonicalJointFrameWindowConstant d τ * + ((jointFrameSourceHi N width t - jointFrameSourceLo width t : ℤ) : ℝ)) ∧ + (∀ z ∈ Fintype.piFinset (fun t => Finset.Ico (jointFrameSourceLo width t) + (jointFrameSourceHi N width t)), ∀ t, + |(z t : ℝ) - (0 : ℤ)| ≤ smoothPairCoefficientScale (2 * (N t.2 : ℝ)) L t.1 / 2) ∧ + (∀ k i, |(jointFrameSourceLo width (some k,i) : ℝ)| ≤ 2 * (N i : ℝ) / L) ∧ + (∀ k i, |(jointFrameSourceHi N width (some k,i) : ℝ)| ≤ 2 * (N i : ℝ) / L) := by + intro width + have hW0 : 0 ≤ Wsite := by linarith + have hwidth : ∀ k i, 1 ≤ width (some k,i) := by + intro k i + simpa only [width, trimmedSpatialWidths, centeredSpatialWidths, one_mul] using hwide i + have hsmall : ∀ k i, 3 * width (some k,i) ≤ (N i : ℝ) / L := + canonicalJointFrame_slope_small N hL hWL hτ hτ1 + obtain ⟨hwindow, hlo, hhi⟩ := jointFrameSource_window_bounds N width + (lt_of_lt_of_le zero_lt_one hL) hwidth hsmall + refine ⟨canonicalJointFrame_source_scale d N hL hW0 hW hτ hτ1, ?_, hlo, hhi⟩ + simpa only [Int.cast_zero, sub_zero] using hwindow + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CanonicalKernelSlowParameter.lean b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalKernelSlowParameter.lean new file mode 100644 index 0000000000000000000000000000000000000000..398af07468c7cfdce4d1fbda1ef20884b630ca74 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalKernelSlowParameter.lean @@ -0,0 +1,132 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedNarrowSpatialCanonicalComparison + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators NNReal Classical + +variable {X G : Type*} [Fintype X] [Fintype G] + +noncomputable def canonicalKernelSlowMap (a : ℝ) (t : G → ℝ) + (u : Option G × X → ℝ) (i : Σ _ : X, Unit ⊕ Empty) : ℝ := + u (none, i.1) + a * ∑ g, t g * u (some g, i.1) + +omit [Fintype X] in +theorem canonicalKernelSlowMap_measurable (a : ℝ) (t : G → ℝ) : + Measurable (canonicalKernelSlowMap (X := X) a t) := by + unfold canonicalKernelSlowMap + fun_prop + +theorem canonicalKernelSlowMap_parameter_lipschitz (a : ℝ) + (u : Option G × X → ℝ) (hu : ‖u‖ ≤ 1) : + LipschitzWith ⟨(Fintype.card G : ℝ) * |a|, by positivity⟩ + (fun t => canonicalKernelSlowMap (X := X) a t u) := by + apply LipschitzWith.of_dist_le_mul + intro t v + apply (dist_pi_le_iff (mul_nonneg (NNReal.coe_nonneg _) dist_nonneg)).mpr + intro i + rw [Real.dist_eq] + change |(u (none, i.1) + a * ∑ g, t g * u (some g, i.1)) - + (u (none, i.1) + a * ∑ g, v g * u (some g, i.1))| ≤ _ + have he : (u (none, i.1) + a * ∑ g, t g * u (some g, i.1)) - + (u (none, i.1) + a * ∑ g, v g * u (some g, i.1)) = + a * ∑ g, (t g - v g) * u (some g, i.1) := by + simp_rw [sub_mul, Finset.sum_sub_distrib] + ring + rw [he, abs_mul] + have hs : |∑ g, (t g - v g) * u (some g, i.1)| ≤ + (Fintype.card G : ℝ) * dist t v := by + calc + _ ≤ ∑ g, |(t g - v g) * u (some g, i.1)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _g : G, dist t v := by + apply Finset.sum_le_sum + intro g _ + rw [abs_mul] + have ht : |t g - v g| ≤ dist t v := + (Real.dist_eq _ _).symm ▸ dist_le_pi_dist t v g + have hu' : |u (some g, i.1)| ≤ 1 := + (le_trans (norm_le_pi_norm u _) hu) + exact (mul_le_mul ht hu' (abs_nonneg _) dist_nonneg).trans_eq (mul_one _) + _ = _ := by simp + calc + _ ≤ |a| * ((Fintype.card G : ℝ) * dist t v) := + mul_le_mul_of_nonneg_left hs (abs_nonneg _) + _ = _ := by change _ = ((Fintype.card G : ℝ) * |a|) * dist t v; ring + +omit [Fintype X] in +theorem canonicalKernelSlowMap_eq [DecidableEq G] + (s : Empty ↪ G) (root : G → ℤ) (D : Matrix Empty G ℤ) + (W L S : ℝ) (hW : 0 ≤ W) (hS : S ≠ 0) : + canonicalKernelSlowMap (X := X) (S / (1 + W)) (fun g => (root g : ℝ) / S) = + canonicalZeroSpatialInputMap s root D W L := by + funext u i + rcases i with ⟨x, a⟩ + cases a with + | inr e => exact Empty.elim e + | inl a => + cases a + rw [canonicalZeroSpatialInputMap_apply s root D W L hW] + unfold canonicalKernelSlowMap + congr 1 + rw [Finset.mul_sum, Finset.sum_div] + apply Finset.sum_congr rfl + intro g _ + field_simp + +noncomputable def canonicalKernelSlowExpectation (a : ℝ) + (φ : ((Σ _ : X, Unit ⊕ Empty) → ℝ) → ℂ) (t : G → ℝ) : ℂ := + ∫ u, φ (canonicalKernelSlowMap a t u) ∂unitCoefficientSource (Option G × X) + +theorem canonicalKernelSlowExpectation_norm_le (a : ℝ) + (φ : ((Σ _ : X, Unit ⊕ Empty) → ℝ) → ℂ) (hφ : ∀ y, ‖φ y‖ ≤ 1) + (t : G → ℝ) : ‖canonicalKernelSlowExpectation a φ t‖ ≤ 1 := by + unfold canonicalKernelSlowExpectation + simpa only [probReal_univ, mul_one] using + norm_integral_le_of_norm_le_const (μ := unitCoefficientSource (Option G × X)) + (Filter.Eventually.of_forall (fun u => hφ (canonicalKernelSlowMap a t u))) + +theorem canonicalKernelSlowExpectation_lipschitz (a : ℝ) + (φ : ((Σ _ : X, Unit ⊕ Empty) → ℝ) → ℂ) + {K : ℝ≥0} (hLip : LipschitzWith K φ) (hφ : ∀ y, ‖φ y‖ ≤ 1) : + LipschitzWith (K * ⟨(Fintype.card G : ℝ) * |a|, by positivity⟩) + (canonicalKernelSlowExpectation (G := G) a φ) := by + have hi (t : G → ℝ) : Integrable + (fun u => φ (canonicalKernelSlowMap a t u)) + (unitCoefficientSource (Option G × X)) := + ⟨(hLip.continuous.measurable.comp (canonicalKernelSlowMap_measurable a t)).aestronglyMeasurable, + HasFiniteIntegral.of_bounded (Filter.Eventually.of_forall (fun u => hφ _))⟩ + apply LipschitzWith.of_dist_le_mul + intro t v + rw [dist_eq_norm] + unfold canonicalKernelSlowExpectation + rw [← integral_sub (hi t) (hi v)] + have he : ∀ᵐ u ∂unitCoefficientSource (Option G × X), + ‖φ (canonicalKernelSlowMap a t u) - φ (canonicalKernelSlowMap a v u)‖ ≤ + (K * ⟨(Fintype.card G : ℝ) * |a|, by positivity⟩ : ℝ≥0) * dist t v := by + filter_upwards [unitCoefficientSource_norm_le (Option G × X)] with u hu + simpa only [Function.comp_apply, dist_eq_norm] using + ((hLip.comp (canonicalKernelSlowMap_parameter_lipschitz a u hu)).dist_le_mul t v) + simpa only [probReal_univ, mul_one] using norm_integral_le_of_norm_le_const he + +theorem canonicalKernelSlowExpectation_eq [DecidableEq G] + (s : Empty ↪ G) (root : G → ℤ) (D : Matrix Empty G ℤ) + (W L S : ℝ) (hW : 0 ≤ W) (hS : S ≠ 0) + (φ : ((Σ _ : X, Unit ⊕ Empty) → ℝ) → ℂ) (hφ : Measurable φ) : + canonicalKernelSlowExpectation (S / (1 + W)) φ (fun g => (root g : ℝ) / S) = + ∫ y, φ y ∂canonicalZeroSpatialLaw s root D W L := by + unfold canonicalKernelSlowExpectation + rw [canonicalKernelSlowMap_eq s root D W L S hW hS, + ← canonicalZeroSpatialInputMap_law s root D W L, + integral_map (canonicalZeroSpatialInputMap_measurable s root D W L).aemeasurable + hφ.aestronglyMeasurable] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CanonicalRankCompatibility.lean b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalRankCompatibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d4802947e17e0dddbdb0661027e7f133f4c3bcd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CanonicalRankCompatibility.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.Progressions.Nilpotent.DegreeRankBCH +import OAI.Combinatorics.Progressions.Polynomial.AdaptedPolynomialSubstitution + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + +theorem eq_of_layer_eq {F G : NilpotentLieFiltration L s} (h : F.layer = G.layer) : F = G := by + cases F + cases G + cases h + rfl + +variable (F : NilpotentLieFiltration L s) + +theorem canonicalDegreeRank_associatedDegree_eq : F.canonicalDegreeRank.associatedDegree = F := + eq_of_layer_eq (funext F.canonicalDegreeRank_associatedDegree_layer) + +theorem canonicalDegreeRank_subgroup (d i : ℕ) : + F.canonicalDegreeRank.subgroup d i = F.rankSubgroup d i := by + ext x + rfl + +noncomputable def orbitEquivOfEq {G : NilpotentLieFiltration L s} (h : F = G) + {σ : Type*} (w : σ → ℕ) : F.PolynomialOrbit w ≃* G.PolynomialOrbit w := by + subst G + exact MulEquiv.refl _ + +theorem orbitEquivOfEq_eval {G : NilpotentLieFiltration L s} (h : F = G) + {σ : Type*} (w : σ → ℕ) (g : F.PolynomialOrbit w) (x : σ → ℤ) : + G.polynomialOrbitEval w x (F.orbitEquivOfEq h w g) = F.polynomialOrbitEval w x g := by + subst G + rfl + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CentralBasisPowerCover.lean b/lean/OAI/Combinatorics/Progressions/Linear/CentralBasisPowerCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..21213453407d4a09f3cf3935d9dcbbbb545fcbe1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CentralBasisPowerCover.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Lattices.LatticeOrderedGenerators + +namespace OAI + +section + +namespace Erdos3.IsCentralLieBasis + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d s : ℕ} + {e : Basis (Fin d) ℚ L} (he : IsCentralLieBasis e) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + +include he + +theorem subgroupPowerCover_index_le (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) (m : ℕ) (hm : 0 < m) : + ((subgroupPowerCover Γ m).subgroupOf Γ).FiniteIndex ∧ + (subgroupPowerCover Γ m).relIndex Γ ≤ m ^ d := by + obtain ⟨a, ha⟩ := he.exists_surjective_orderedZpowProduct hnil Γ l hl hgrid + have h := powerSubgroup_index_le_of_ordered_generators a ha m hm + simpa only [Subgroup.relIndex, subgroupPowerCover_subgroupOf] using h + +theorem powerCover_of_central_basis + (Λ₀ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l m₀ m : ℕ) + (hl : 0 < l) (hm : 0 < m) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (htarget : scaledIntegerGrid m₀ ⊆ bchSubgroupCoordinates e Λ₀) + (hdiv : l * m₀ ∣ m) : + subgroupPowerCover Γ m ≤ Λ₀ ∧ subgroupPowerCover Γ m ≤ Γ ∧ + ((subgroupPowerCover Γ m).subgroupOf Γ).Characteristic ∧ + ((subgroupPowerCover Γ m).subgroupOf Γ).Normal ∧ + ((subgroupPowerCover Γ m).subgroupOf Γ).FiniteIndex ∧ + (subgroupPowerCover Γ m).relIndex Γ ≤ m ^ d ∧ + scaledIntegerGrid (m * l) ⊆ bchSubgroupCoordinates e (subgroupPowerCover Γ m) ∧ + bchSubgroupCoordinates e (subgroupPowerCover Γ m) ⊆ denominatorGrid (m * l) := by + obtain ⟨hfinite, hindex⟩ := he.subgroupPowerCover_index_le hnil Γ l hl houter m hm + exact ⟨subgroupPowerCover_le_of_grid e Γ Λ₀ l m₀ m houter htarget hdiv, + subgroupPowerCover_le Γ m, inferInstance, inferInstance, hfinite, hindex, + subgroupPowerCover_grid e Γ l m hinner houter⟩ + +end Erdos3.IsCentralLieBasis + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CertifiedChartBasisBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/CertifiedChartBasisBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..3bc5829ece31f585a9d05fa0b92f56bdadd3407f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CertifiedChartBasisBudget.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.Progressions.Dynamics.LieSubalgebraRepresentativeBudget +import OAI.Combinatorics.Progressions.Linear.RationalTagConstraintChartBasis + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module + +private theorem certifiedChartMatrix_budget {ι κ : Type*} + [Fintype ι] [Fintype κ] (matrix : Matrix ι κ ℚ) + {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hheight : ∀ i j, rationalLogHeight (matrix i j) ≤ ((p + 2) ^ 2 + 2) ^ 63) : + (∀ i j, |(matrix i j : ℝ)| ≤ Real.exp (((p + 2) ^ 2 + 2) ^ 63)) ∧ + 0 < matrixDenominator matrix ∧ + (matrixDenominator matrix : ℝ) ≤ Real.exp ((p + 2) ^ 254) ∧ + ∀ i j, ∃ z : ℤ, (z : ℝ) = (matrixDenominator matrix : ℝ) * (matrix i j : ℝ) := by + have hcost : ((p + 2) ^ 2 + 2) ^ 63 ≤ (p + 2) ^ 252 := by + simpa using shifted_power_budget_le hp 2 63 + refine ⟨fun i j => (rational_abs_real_le_numerator (matrix i j)).trans + ((rationalLogHeight_le_iff _ _).mp (hheight i j)).1, + matrixDenominator_pos matrix, ?_, ?_⟩ + · apply matrixDenominator_le_exp_power matrix hp 252 hι hκ + intro i j + exact ((rationalLogHeight_le_iff _ _).mp (hheight i j)).2.trans + (Real.exp_le_exp.mpr hcost) + · intro i j + obtain ⟨z, hz⟩ := matrixDenominator_mul_entry_real_integral matrix i j + exact ⟨z, hz.symm⟩ + +theorem RationalTaggedConstraintCertificate.exists_certified_chart_basis_budget + {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] {X : Type*} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p : ℝ} {Cblocks : ℕ} + (hcert : RationalTaggedConstraintCertificate J Set.univ K p Cblocks) + (hp : 0 ≤ p) (hdim : (Fintype.card (Σ j, J j) : ℝ) ≤ p) + (hblocks : (Cblocks : ℝ) ≤ p) : + ∃ (n : Fin m → ℕ) (Ktag : Submodule ℝ ((Σ j, J j) → ℝ)) + (b : Basis (Σ j, Fin (n j)) ℝ Ktag) + (matrix : (Σ j, Fin (n j)) → (Σ j, J j) → ℚ) (d : ℕ), + (∀ j, n j ≤ Fintype.card (J j)) ∧ + Fintype.card (Σ j, Fin (n j)) ≤ Fintype.card (Σ j, J j) ∧ + (∀ a x, (b a : (Σ j, J j) → ℝ) x = (matrix a x : ℝ)) ∧ + (∀ a x, x.1 ≠ a.1 → matrix a x = 0) ∧ + (∀ a x, rationalLogHeight (matrix a x) ≤ ((p + 2) ^ 2 + 2) ^ 63) ∧ + (∀ a x, RationalHeightLE (matrix a x) ⌈Real.exp (((p + 2) ^ 2 + 2) ^ 63)⌉₊) ∧ + (∀ a x, |(b a : (Σ j, J j) → ℝ) x| ≤ Real.exp (((p + 2) ^ 2 + 2) ^ 63)) ∧ + d = matrixDenominator matrix ∧ 0 < d ∧ + (d : ℝ) ≤ Real.exp ((p + 2) ^ 254) ∧ + (∀ a x, ∃ z : ℤ, (z : ℝ) = (d : ℝ) * (b a : (Σ j, J j) → ℝ) x) ∧ + K = {point | (fun x => point (Sum.inr x)) ∈ Ktag} ∧ + ∀ (U : ∀ j, Submodule ℝ (J j → ℝ)), + (∀ point, (∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ U j) → point ∈ K) → + ∀ v : (Σ j, J j) → ℝ, (∀ j, (fun i => v ⟨j, i⟩) ∈ U j) → v ∈ Ktag := by + classical + have hdimTag (j : Fin m) : (Fintype.card (J j) : ℝ) ≤ p := by + have hcard : Fintype.card (J j) ≤ Fintype.card (Σ j, J j) := + Fintype.card_le_of_injective (fun i => (⟨j, i⟩ : Σ j, J j)) sigma_mk_injective + exact (Nat.cast_le.mpr hcard).trans hdim + obtain ⟨n, Ktag, b, matrix, hn, hentry, hofftag, hheight, hK, hret⟩ := + hcert.exists_bounded_chart_tag_basis hp hdimTag hblocks + have hcard : Fintype.card (Σ j, Fin (n j)) ≤ Fintype.card (Σ j, J j) := by + simp only [Fintype.card_sigma, Fintype.card_fin] + exact Finset.sum_le_sum (fun j _ => hn j) + obtain ⟨habs, hdpos, hdbound, hgrid⟩ := certifiedChartMatrix_budget matrix hp + ((Nat.cast_le.mpr hcard).trans hdim) hdim hheight + refine ⟨n, Ktag, b, matrix, matrixDenominator matrix, hn, hcard, hentry, + hofftag, hheight, fun a x => rationalHeightLE_ceil_exp (hheight a x), + ?_, rfl, hdpos, hdbound, ?_, hK, hret⟩ + · intro a x + rw [hentry] + exact habs a x + · intro a x + rw [hentry] + exact hgrid a x + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ChosenBasisGeometryBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/ChosenBasisGeometryBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..eae244dfc8bfb77f1bf3a8aeebb593f5ed0fad81 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ChosenBasisGeometryBounds.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalPowerHeight + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +theorem basis_geometry_of_forward_height {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s d : ℕ} (D : RationalFilteredNilmanifold L s d) (b : Basis ι ℚ L) + {p : ℝ} (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) + (hb : ∀ i j, rationalLogHeight (D.basis.repr (b i) j) ≤ p + 1) : + (Fintype.card ι : ℝ) ≤ p ∧ + (∀ i j, rationalLogHeight (b.repr (D.basis i) j) ≤ (p + 4) ^ 5) ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ (p + 4) ^ 11) := by + have hdim : (Fintype.card ι : ℝ) ≤ p := by + rw [← finrank_eq_card_basis b, finrank_eq_card_basis D.basis, Fintype.card_fin] + exact hD.1 + let H := ⌈Real.exp (p + 1)⌉₊ + have hH : 1 ≤ H := one_le_ceil_exp (p + 1) + have hHp : (H : ℝ) ≤ Real.exp (p + 2) := by + simpa only [show p + 1 + 1 = p + 2 by ring] using ceil_exp_le_exp_add_one (by linarith : 0 ≤ p + 1) + have hentries : ∀ i j, RationalHeightLE (D.basis.repr (b i) j) H := + fun i j => rationalHeightLE_ceil_exp (hb i j) + have hstructure : ∀ i j k, RationalHeightLE (lieStructureConstants D.basis i j k) H := + fun i j k => rationalHeightLE_ceil_exp ((hD.2.2.1 i j k).trans (by linarith)) + have hp2 : 0 ≤ p + 2 := by linarith + have hdim2 : (Fintype.card ι : ℝ) ≤ p + 2 := hdim.trans (by linarith) + have hd2 : (Fintype.card (Fin d) : ℝ) ≤ p + 2 := by + simpa only [Fintype.card_fin] using hD.1.trans (show p ≤ p + 2 by linarith) + have hinverse : (rationalSolveHeight (Fintype.card ι) H : ℝ) ≤ Real.exp ((p + 4) ^ 5) := by + simpa only [show p + 2 + 2 = p + 4 by ring] using + rationalSolveHeight_le_budget (Fintype.card ι) H hp2 hdim2 hHp + have hbracket : (rationalLieStructureHeight (Fintype.card (Fin d)) + (max H (rationalSolveHeight (Fintype.card ι) H)) : ℝ) ≤ Real.exp ((p + 4) ^ 11) := by + simpa only [show p + 2 + 2 = p + 4 by ring] using + rationalLieStructureHeight_inverse_budget (Fintype.card (Fin d)) (Fintype.card ι) H hp2 hd2 hdim2 hHp + exact ⟨hdim, + fun i j => rationalLogHeight_le_of_height (inverse_basis_entries_height D.basis b hH hentries i j) hinverse, + fun i j k => rationalLogHeight_le_of_height + (basis_change_structure_height D.basis b hH hentries hstructure i j k) hbracket⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CircleFejerKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/CircleFejerKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cfcf347b7fd667d9eb1a96c4de6eb47ecb0ddb4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CircleFejerKernel.lean @@ -0,0 +1,332 @@ +import OAI.Combinatorics.Progressions.Fourier.RectangularGridCharacter + +namespace OAI + +section + +open scoped BigOperators ComplexConjugate ENNReal Real +open Finset Function MeasureTheory Set + +namespace Erdos3.CircleFourier + +noncomputable section + +def fejerPairFrequency {N : ℕ} (p : Fin N × Fin N) : ℤ := + (p.1.val : ℤ) - p.2.val + +def fejerFrequencies (N : ℕ) : Finset ℤ := by + classical + exact (Finset.univ : Finset (Fin N × Fin N)).image fejerPairFrequency + +def fejerCoefficient (N : ℕ) (h : ℤ) : ℝ := by + classical + exact ((Finset.univ.filter fun p : Fin N × Fin N => + fejerPairFrequency p = h).card : ℝ) / N + +def fejerPolynomial (N : ℕ) (x : Circle) : ℝ := + (∑ h ∈ fejerFrequencies N, + (fejerCoefficient N h : ℂ) * character (h • x)).re + +private lemma fejer_grouped (N : ℕ) (x : Circle) : + ∑ h ∈ fejerFrequencies N, + (∑ p ∈ (Finset.univ.filter fun p : Fin N × Fin N => + fejerPairFrequency p = h), character (fejerPairFrequency p • x)) = + ∑ p : Fin N × Fin N, character (fejerPairFrequency p • x) := by + classical + rw [Finset.sum_fiberwise_eq_sum_filter] + rw [Finset.filter_eq_self.2] + intro p hp + simp only [fejerFrequencies, Finset.mem_image] + exact ⟨p, Finset.mem_univ _, rfl⟩ + +private lemma fejer_pair_sum_eq (N : ℕ) (x : Circle) : + ∑ p : Fin N × Fin N, character (fejerPairFrequency p • x) = + (∑ j : Fin N, character ((j.val : ℤ) • x)) * + (∑ k : Fin N, character ((-(k.val : ℤ)) • x)) := by + calc + _ = ∑ j : Fin N, ∑ k : Fin N, + character (fejerPairFrequency (j, k) • x) := by + exact Fintype.sum_prod_type (γ := ℂ) + (fun p : Fin N × Fin N => character (fejerPairFrequency p • x)) + _ = _ := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro j hj + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro k hk + rw [← character_add] + congr 2 + simp only [fejerPairFrequency, sub_eq_add_neg, add_smul] + +private lemma fejer_neg_sum_eq_conj (N : ℕ) (x : Circle) : + (∑ k : Fin N, character ((-(k.val : ℤ)) • x)) = + star (∑ k : Fin N, character ((k.val : ℤ) • x)) := by + change (∑ k : Fin N, character ((-(k.val : ℤ)) • x)) = + (starRingEnd ℂ) (∑ k : Fin N, character ((k.val : ℤ) • x)) + rw [map_sum] + apply Finset.sum_congr rfl + intro k hk + change AddCircle.toCircle ((-(k.val : ℤ)) • x) = + (starRingEnd ℂ) (AddCircle.toCircle ((k.val : ℤ) • x)) + rw [neg_smul, AddCircle.toCircle_neg] + exact _root_.Circle.coe_inv_eq_conj _ + +private lemma fejer_fin_sum_eq_geo (N : ℕ) (x : Circle) : + (∑ k : Fin N, character ((k.val : ℤ) • x)) = + geometricCharacterSum N x := by + rw [geometricCharacterSum_eq_sum_fin] + apply Finset.sum_congr rfl + intro k hk + rw [natCast_zsmul] + +private lemma fejer_pair_sum_eq_norm_sq (N : ℕ) (x : Circle) : + ∑ p : Fin N × Fin N, character (fejerPairFrequency p • x) = + (‖geometricCharacterSum N x‖ ^ 2 : ℝ) := by + rw [fejer_pair_sum_eq, fejer_neg_sum_eq_conj, fejer_fin_sum_eq_geo] + change geometricCharacterSum N x * + (starRingEnd ℂ) (geometricCharacterSum N x) = _ + rw [Complex.mul_conj] + norm_cast + exact Complex.sq_norm _ |>.symm + +lemma complex_fejerPolynomial_eq (N : ℕ) (x : Circle) : + ∑ h ∈ fejerFrequencies N, + (fejerCoefficient N h : ℂ) * character (h • x) = + ((‖geometricCharacterSum N x‖ ^ 2 / N : ℝ) : ℂ) := by + classical + rw [Complex.ofReal_div] + push_cast + have hpair := fejer_pair_sum_eq_norm_sq N x + rw [← Complex.ofReal_pow, ← hpair, ← fejer_grouped N x, Finset.sum_div] + apply Finset.sum_congr rfl + intro h hh + rw [fejerCoefficient, Complex.ofReal_div] + push_cast + rw [div_mul_eq_mul_div] + congr 1 + calc + (#{p : Fin N × Fin N | fejerPairFrequency p = h} : ℂ) * + character (h • x) = + ∑ p with fejerPairFrequency p = h, character (h • x) := by + rw [Finset.sum_const, nsmul_eq_mul] + _ = ∑ p with fejerPairFrequency p = h, + character (fejerPairFrequency p • x) := by + apply Finset.sum_congr rfl + intro p hp + rw [(Finset.mem_filter.mp hp).2] + +lemma fejerPolynomial_eq (N : ℕ) (x : Circle) : + fejerPolynomial N x = ‖geometricCharacterSum N x‖ ^ 2 / N := by + have h := congrArg Complex.re (complex_fejerPolynomial_eq N x) + simpa only [fejerPolynomial, Complex.ofReal_re] using h + +lemma fejerPolynomial_nonneg (N : ℕ) (x : Circle) : + 0 ≤ fejerPolynomial N x := by + rw [fejerPolynomial_eq] + positivity + +lemma fejerPolynomial_le_of_distance {N : ℕ} (hN : 0 < N) + {η : ℝ} (hη : 0 < η) {x : Circle} (hx : η ≤ integerDistance x) : + fejerPolynomial N x ≤ 1 / (4 * N * η ^ 2) := by + rw [fejerPolynomial_eq] + have hgeom := + two_mul_integerDistance_mul_norm_geometricCharacterSum_le_one N x + have hnorm := norm_nonneg (geometricCharacterSum N x) + have hdist := integerDistance_nonneg x + have hbound : 2 * η * ‖geometricCharacterSum N x‖ ≤ 1 := by nlinarith + have hsquare : 4 * η ^ 2 * ‖geometricCharacterSum N x‖ ^ 2 ≤ 1 := by + have hs := mul_self_le_mul_self (mul_nonneg (by positivity) hnorm) hbound + nlinarith + have hn2 : ‖geometricCharacterSum N x‖ ^ 2 ≤ 1 / (4 * η ^ 2) := by + rw [le_div_iff₀ (by positivity : (0 : ℝ) < 4 * η ^ 2)] + nlinarith + calc + ‖geometricCharacterSum N x‖ ^ 2 / (N : ℝ) ≤ + (1 / (4 * η ^ 2)) / N := by gcongr + _ = 1 / (4 * N * η ^ 2) := by field_simp + +private lemma integral_character (h : ℤ) : + ∫ x : Circle, character (h • x) ∂circleHaar = if h = 0 then 1 else 0 := by + by_cases hh : h = 0 + · subst h + simp + · simp only [hh, ↓reduceIte] + exact integral_eq_zero_of_add_right_eq_neg (μ := circleHaar) + (fourier_add_half_inv_index hh (by norm_num)) + +lemma integral_fejerPolynomial {N : ℕ} (hN : 0 < N) : + ∫ x : Circle, fejerPolynomial N x ∂circleHaar = 1 := by + simp_rw [fejerPolynomial] + have hterm : ∀ h ∈ fejerFrequencies N, + Integrable (fun x : Circle => + (fejerCoefficient N h : ℂ) * character (h • x)) circleHaar := by + intro h hh + apply Integrable.const_mul + apply Integrable.of_bound (fourier h).continuous.aestronglyMeasurable 1 + exact ae_of_all _ fun x => (norm_character (h • x)).le + have hint : Integrable (fun x : Circle => + ∑ h ∈ fejerFrequencies N, + (fejerCoefficient N h : ℂ) * character (h • x)) circleHaar := by + have hi := integrable_finsetSum' (fejerFrequencies N) hterm + have heq : (∑ h ∈ fejerFrequencies N, + fun x : Circle => (fejerCoefficient N h : ℂ) * character (h • x)) = + fun x : Circle => ∑ h ∈ fejerFrequencies N, + (fejerCoefficient N h : ℂ) * character (h • x) := by + funext x + exact Finset.sum_apply x (fejerFrequencies N) _ + rw [← heq] + exact hi + calc + (∫ x : Circle, (∑ h ∈ fejerFrequencies N, + (fejerCoefficient N h : ℂ) * character (h • x)).re ∂circleHaar) = + (∫ x : Circle, ∑ h ∈ fejerFrequencies N, + (fejerCoefficient N h : ℂ) * character (h • x) ∂circleHaar).re := + integral_re hint + _ = 1 := by + rw [integral_finsetSum (fejerFrequencies N) hterm] + simp_rw [integral_const_mul, integral_character] + rw [Finset.sum_eq_single 0] + · rw [ite_eq_left rfl, mul_one] + unfold fejerCoefficient fejerPairFrequency + have hdiag : (Finset.univ.filter fun p : Fin N × Fin N => + (p.1.val : ℤ) - p.2.val = 0).card = N := by + rw [show (Finset.univ.filter fun p : Fin N × Fin N => + (p.1.val : ℤ) - p.2.val = 0) = + Finset.univ.image (fun j : Fin N => (j, j)) by + ext p + simp only [Finset.mem_filter, Finset.mem_univ, true_and, + Finset.mem_image] + constructor + · intro hp + have : p.1 = p.2 := by + apply Fin.ext + omega + exact ⟨p.1, by ext <;> simp [this]⟩ + · rintro ⟨j, -, rfl⟩ + simp] + calc + (Finset.univ.image (fun j : Fin N => (j, j))).card = + (Finset.univ : Finset (Fin N)).card := + Finset.card_image_of_injective _ fun i j h => by + simpa using congrArg Prod.fst h + _ = N := by simp + rw [hdiag, div_self (Nat.cast_ne_zero.mpr (Nat.ne_of_gt hN))] + norm_num + · intro h hh hne + rw [ite_eq_right hne, mul_zero] + · intro hz + exfalso + apply hz + unfold fejerFrequencies + apply Finset.mem_image.2 + exact ⟨(⟨0, hN⟩, ⟨0, hN⟩), Finset.mem_univ _, + by simp [fejerPairFrequency]⟩ + +private lemma fejer_fiber_card_le (N : ℕ) (h : ℤ) : + (Finset.univ.filter fun p : Fin N × Fin N => + fejerPairFrequency p = h).card ≤ N := by + let s := Finset.univ.filter fun p : Fin N × Fin N => fejerPairFrequency p = h + calc + s.card ≤ (Finset.univ : Finset (Fin N)).card := by + apply Finset.card_le_card_of_injOn Prod.fst + · intro p hp + exact Finset.mem_univ _ + · intro p hp q hq hpq + apply Prod.ext hpq + apply Fin.ext + have hpf := (Finset.mem_filter.mp hp).2 + have hqf := (Finset.mem_filter.mp hq).2 + unfold fejerPairFrequency at hpf hqf + omega + _ = N := by simp + +lemma fejerCoefficient_nonneg (N : ℕ) (h : ℤ) : + 0 ≤ fejerCoefficient N h := by + unfold fejerCoefficient + positivity + +lemma fejerCoefficient_le_one {N : ℕ} (hN : 0 < N) (h : ℤ) : + fejerCoefficient N h ≤ 1 := by + unfold fejerCoefficient + rw [div_le_one (Nat.cast_pos.mpr hN)] + exact_mod_cast fejer_fiber_card_le N h + +lemma continuous_fejerPolynomial (N : ℕ) : Continuous (fejerPolynomial N) := by + rw [show fejerPolynomial N = fun x => + ‖geometricCharacterSum N x‖ ^ 2 / N by + funext x + exact fejerPolynomial_eq N x] + apply Continuous.div_const + apply Continuous.pow + apply Continuous.norm + unfold geometricCharacterSum + apply continuous_finsetSum + intro n hn + unfold character + exact continuous_subtype_val.comp + (AddCircle.continuous_toCircle.comp (continuous_nsmul n)) + +lemma norm_geometricCharacterSum_le_card (N : ℕ) (x : Circle) : + ‖geometricCharacterSum N x‖ ≤ N := by + unfold geometricCharacterSum + calc + ‖∑ n ∈ range N, character (n • x)‖ ≤ + ∑ n ∈ range N, ‖character (n • x)‖ := norm_sum_le _ _ + _ = N := by simp + +lemma fejerPolynomial_le_card (N : ℕ) (x : Circle) : + fejerPolynomial N x ≤ N := by + rw [fejerPolynomial_eq] + by_cases hN : N = 0 + · simp [hN] + · rw [div_le_iff₀ (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hN))] + have h := norm_geometricCharacterSum_le_card N x + simpa [pow_two] using mul_self_le_mul_self (norm_nonneg _) h + +lemma integrable_fejerPolynomial_comp_sub (N : ℕ) (x : Circle) : + Integrable (fun y : Circle => fejerPolynomial N (x - y)) circleHaar := by + apply Integrable.of_bound + ((continuous_fejerPolynomial N).comp + (continuous_const.sub continuous_id)).aestronglyMeasurable N + exact ae_of_all _ fun y => by + change |fejerPolynomial N (x - y)| ≤ (N : ℝ) + rw [abs_of_nonneg (fejerPolynomial_nonneg N _)] + exact fejerPolynomial_le_card N _ + +lemma fejerPolynomial_neg (N : ℕ) (x : Circle) : + fejerPolynomial N (-x) = fejerPolynomial N x := by + rw [fejerPolynomial_eq, fejerPolynomial_eq] + congr 2 + unfold geometricCharacterSum + calc + ‖∑ n ∈ range N, character (n • -x)‖ = + ‖star (∑ n ∈ range N, character (n • x))‖ := by + congr 1 + change _ = (starRingEnd ℂ) _ + rw [map_sum] + apply Finset.sum_congr rfl + intro n hn + rw [smul_neg, character_neg] + rfl + _ = _ := Complex.norm_conj _ + +lemma integral_fejerPolynomial_comp_sub {N : ℕ} (hN : 0 < N) (x : Circle) : + ∫ y : Circle, fejerPolynomial N (x - y) ∂circleHaar = 1 := by + calc + ∫ y : Circle, fejerPolynomial N (x - y) ∂circleHaar = + ∫ y : Circle, fejerPolynomial N (y-x) ∂circleHaar := by + apply integral_congr_ae + filter_upwards [] with y + rw [show x-y = -(y-x) by abel, fejerPolynomial_neg] + _ = ∫ y : Circle, fejerPolynomial N y ∂circleHaar := by + simpa only [sub_eq_add_neg] using + integral_add_right_eq_self (fejerPolynomial N) (-x) + _ = 1 := integral_fejerPolynomial hN + +end +end Erdos3.CircleFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CoefficientCoverKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/CoefficientCoverKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..25ebcebe1ff5371fe6647f4659a87fc9e593a2f3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CoefficientCoverKernel.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Geometry.CoefficientAmbientCoordinates + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +variable {K : Type*} {m : ℕ} {J : Fin m → Type*} +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) + +noncomputable def coefficientAmbientHom : + CoefficientTorus (K := K) U →+ (CoefficientAmbientIndex K J → UnitAddCircle) where + toFun := coefficientAmbientTorus U + map_zero' := by + funext t + simp [coefficientAmbientTorus] + map_add' x y := by + funext t + simp [coefficientAmbientTorus, map_add] + +theorem coefficientAmbientTorus_injective : + Function.Injective (coefficientAmbientTorus (K := K) U) := by + intro x y h + obtain ⟨a, rfl⟩ := QuotientAddGroup.mk'_surjective (coefficientIntegerLattice U) x + obtain ⟨b, rfl⟩ := QuotientAddGroup.mk'_surjective (coefficientIntegerLattice U) y + apply QuotientAddGroup.eq_iff_sub_mem.mpr + intro s i + have he : ((a s).val i : UnitAddCircle) = ((b s).val i : UnitAddCircle) := congrFun h ⟨s, i⟩ + have hz : (((a s).val i - (b s).val i : ℝ) : UnitAddCircle) = 0 := by + rw [AddCircle.coe_sub, he, sub_self] + obtain ⟨z, hz⟩ := (AddCircle.coe_eq_zero_iff (1 : ℝ)).mp hz + exact ⟨z, by simpa using hz.symm⟩ + +variable [Fintype K] [∀ j, Fintype (J j)] + +theorem coefficientCoverKernel_finite (d : ℕ) (hd : 0 < d) : + Finite (quotientIntegerCover (coefficientIntegerLattice (K := K) U) d).ker := by + let T := {z : UnitAddCircle // d • z = 0} + let : Fintype T := (AddCircle.finite_torsion (1 : ℝ) hd).fintype + let f : (quotientIntegerCover (coefficientIntegerLattice (K := K) U) d).ker → + CoefficientAmbientIndex K J → T := fun x i => + ⟨coefficientAmbientHom U x.val i, by + change (d • coefficientAmbientHom U x.val) i = 0 + rw [← map_nsmul] + have hx : d • x.val = 0 := x.property + rw [hx, map_zero] + rfl⟩ + apply Finite.of_injective f + intro x y hxy + apply Subtype.ext + apply coefficientAmbientTorus_injective U + funext i + exact congrArg Subtype.val (congrFun hxy i) + +@[instance_reducible] +noncomputable def coefficientCoverKernelFintype (d : ℕ) (hd : 0 < d) : + Fintype (quotientIntegerCover (coefficientIntegerLattice (K := K) U) d).ker := by + let : Finite (quotientIntegerCover (coefficientIntegerLattice (K := K) U) d).ker := + coefficientCoverKernel_finite U d hd + exact Fintype.ofFinite _ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CoefficientJointAmbientKernelChart.lean b/lean/OAI/Combinatorics/Progressions/Linear/CoefficientJointAmbientKernelChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..bde17c02a07ec1b9cd34a30ed9ba397d999fa5f2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CoefficientJointAmbientKernelChart.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Fourier.StandardJetFourier + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule +open scoped BigOperators NNReal + +variable {K : Type*} [Fintype K] {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + +omit [Fintype K] in +theorem coefficientAmbientTorus_canonicalSample (x : CoefficientSamplerArrays (K := K) I n) : + coefficientAmbientTorus U (canonicalCoefficientSample U b hb o x) = + fun a => (coefficientSamplerAmbientPoint U b o x a : UnitAddCircle) := by + funext a + rcases a with ⟨⟨j, e⟩, i⟩ + have he : coefficientCoordinateTorus U (canonicalCoefficientSample U b hb o x) ⟨j, e⟩ = + euclideanSubspaceTorusEquiv (U j) + (mixedArrayQuotient (euclideanSubspace (U j)) (b j) (hb j) (o j) (x j) e) := by + apply (euclideanSubspaceTorusEquiv (U j)).symm.injective + rw [← euclideanCoefficientEquiv_apply, canonicalCoefficientSample, + AddEquiv.apply_symm_apply, AddEquiv.symm_apply_apply] + change subspaceAmbientTorus (U j) + (coefficientCoordinateTorus U (canonicalCoefficientSample U b hb o x) ⟨j, e⟩) i = _ + rw [he] + exact euclideanAmbientTorus_normalized (U j) (b j) (hb j) + (orthonormalMixedChart (o j) + (mixedArrayRegroup (I j) (Fin (n j)) (BoundedCoefficientExponent K (j.val + 1)) (x j) e)) i + +variable (c w : ∀ j : Fin m, I j → BoundedCoefficientExponent K (j.val + 1) → ℝ) +variable (f : ∀ j : Fin m, Fin (n j) → BoundedCoefficientExponent K (j.val + 1) → ℝ → ℝ) +variable (p : ∀ j : Fin m, Fin (n j) → BoundedCoefficientExponent K (j.val + 1) → PMF ℤ) + +theorem coefficientJointAmbientKernel_chart + (hf : ∀ j i d (k : ℤ), f j i d ((k : ℝ) / basisAxisScale (b j) i) = + basisAxisScale (b j) i * (p j i d k).toReal) + (hs : ∀ j d x, mixedCoefficientDensity (fun i => c j i d) (fun i => w j i d) + (fun i => p j i d) x ≠ 0 → ∀ a, + |normalizedLatticePoint (euclideanSubspace (U j)) (b j) (orthonormalMixedChart (o j) x) a| ≤ 1/4) + (x : CoefficientSamplerArrays (K := K) I n) + (hx : ∀ a, |coefficientSamplerAmbientPoint U b o x a| < 1/2) : + coefficientJointAmbientKernel U b o c w f (coefficientSamplerAmbientPoint U b o x) = + canonicalCoefficientDensity U b hb o c w p (canonicalCoefficientSample U b hb o x) := by + rw [← coefficientJointAmbientKernel_canonical U b o c w f hb p hf hs, + coefficientAmbientTorus_canonicalSample] + exact (smallBoxTorusKernel_local _ (coefficientJointAmbientKernel_support U b o c w f) _ hx).symm + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CoefficientModeRankContradiction.lean b/lean/OAI/Combinatorics/Progressions/Linear/CoefficientModeRankContradiction.lean new file mode 100644 index 0000000000000000000000000000000000000000..604404c309c2dff534d43df815e990c4af075ea9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CoefficientModeRankContradiction.lean @@ -0,0 +1,52 @@ +import OAI.Combinatorics.Progressions.Estimates.CoefficientModeRationalDecomposition + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open CircleFourier +open scoped BigOperators Classical + +theorem coefficientMode_paired_bias_lt_of_rank {I K J : Type*} + [Fintype I] [DecidableEq I] [Fintype K] [Fintype J] {n : ℕ} + (frequency : (K →₀ ℕ) → J → ℤ) (a : Fin (n + 1) → K → ℤ) + (p : VectorPolynomial I ℝ (J → ℝ)) (hp : Homogeneous (n + 1) p) + (W : Submodule ℝ (J → ℝ)) (N s : I → ℕ) (hs : ∀ k, 0 < s k) + {ζ R B : ℝ} (hζ : 0 < ζ) (hN : ∀ k, multiaffineBiasBudget n ζ ≤ N k) + (H : I → ℝ) (hH : ∀ k, 0 < H k) {A : ℝ} (hA : 0 ≤ A) + (hscale : ∀ k, H k ≤ A * ((s k : ℝ) * (N k : ℝ))) + (hrank : HasLayerSamplingRank (n + 1) H R W p) + (hrow : ∀ j, |(integerContractedRow frequency (∏ i, rowPolynomial (a i)) j : ℝ)| ≤ B) + (hrowBudget : ((n + 1).factorial : ℝ) * B ≤ R) + (hnonzero : ∃ w : W, + (∑ j, (integerContractedRow frequency (∏ i, rowPolynomial (a i)) j : ℝ) * w.val j) ≠ 0) + (hdenom : (∏ j : Fin (n + 1) → I, + (multiaffineBiasBudget n ζ * ∏ i, (s (j i) : ℝ))) ≤ R) + (hcoeff : (Fintype.card I : ℝ) ^ (n + 1) * (A ^ (n + 1) * multiaffineBiasBudget n ζ) ≤ R) : + ‖𝔼 x : Fin (n + 1) → ∀ k, Fin (N k), + 𝔼 y : Fin (n + 1) → ∀ k, Fin (N k), + character ((polynomialTopSymbol (n + 1) (coefficientModePolynomial + (coefficientFunctional (fun d j => (frequency d j : ℝ))) p) + (fun i z => (a i z.1 : ℝ) * + ((s z.2 : ℝ) * ((x i z.2).val : ℝ) - (s z.2 : ℝ) * ((y i z.2).val : ℝ))) : ℝ) : + CircleFourier.Circle)‖ < ζ := by + by_contra hn + obtain ⟨D, hD, hDb, E, Q, heq, he⟩ := coefficientMode_integer_row_decomposition + frequency a p hp N s hs hζ hN H hH hA hscale (le_of_not_gt hn) + have ha (j : J) : |(factorialContractedRow frequency a j : ℝ)| ≤ R := + (factorialContractedRow_bound frequency a hrow j).trans hrowBudget + obtain ⟨w, hw⟩ := hnonzero + apply hrank.not_approximation hp (factorialContractedRow frequency a) ha + ⟨w, factorialContractedRow_nonzero frequency a w.val hw⟩ + apply polynomialRationalApproximation_of_decomposition _ R _ E Q D hD + (hDb.trans hdenom) heq + intro α + exact (he α).trans (div_le_div_of_nonneg_right hcoeff (monomialScale_pos _ hH α).le) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CommonCoefficientBasisBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/CommonCoefficientBasisBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c117e78569fdb85453abd66144ab84d4d24d743 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CommonCoefficientBasisBudget.lean @@ -0,0 +1,29 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonFreeSunflower + +namespace OAI + +section + +namespace Erdos3 + +theorem coefficientSpaceBasisBudget_bound : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → coefficientSpaceBasisBudget p ≤ (p + C) ^ C := by + let S (x : Polynomial ℕ) := x + x * ((x + 2) ^ 7 + x) + let B (x : Polynomial ℕ) := S (x + (x + (x + 3) ^ 7 + 2) ^ 4 + 1) + let D (x : Polynomial ℕ) := B (x + S (4 * x + 1)) + let R : Polynomial ℕ := ((Polynomial.X + 1 + (Polynomial.X + 3) ^ 7 + 2) ^ 9 + + Polynomial.X + 4) ^ 4 + let H : Polynomial ℕ := Polynomial.X + Polynomial.X * (R + 1 + (Polynomial.X + 3) ^ 7) + let A : Polynomial ℕ := Polynomial.X + 4 * Polynomial.X + H + (Polynomial.X + 3) ^ 7 + 1 + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget (B (A + (A + 2) ^ 4 + D A)) + refine ⟨C, hC, fun p hp => ?_⟩ + have h := hbound p hp + simpa [S, B, D, R, H, A, coefficientSpaceBasisBudget, coefficientSpaceInputBudget, + dependentCoordinateBudget, preimageBasisBudget, sparseGeneratorBudget, + horizontalCoordinateBudget, refiltrationCoordinateBudget, Polynomial.eval₂_pow] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CommonFreeSpanBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/CommonFreeSpanBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..fca36b197240366beddf35a5d6bad861df6cc43d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CommonFreeSpanBounds.lean @@ -0,0 +1,420 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonFreeSunflower +import OAI.Combinatorics.Progressions.Nilpotent.FreeDegreeRankNilmanifold + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {X : Type*} [Fintype X] {s r : ℕ} {w : X → ℕ} {hw : ∀ x, 0 < w x} + +structure FreeCoordinateFrame + (b : Basis (Fin (finrank ℚ (FreeDegreeRankLieAlgebra X s r w hw))) ℚ + (FreeDegreeRankLieAlgebra X s r w hw)) (p : ℝ) where + tree_height : ∀ x ∈ FreeNilpotentLieAlgebra.treeGenerators X s, ∀ i, + rationalLogHeight (b.repr (FreeDegreeRankLieAlgebra.projection X s r w hw x) i) ≤ p + sourceBasis : Basis (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) ℚ + (FreeNilpotentLieAlgebra X s) + sourceBasis_trees : ∀ i, sourceBasis i ∈ FreeNilpotentLieAlgebra.treeGenerators X s + sourceDimension : (finrank ℚ (FreeNilpotentLieAlgebra X s) : ℝ) ≤ p + sectionMatrix : Matrix (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) + (Fin (finrank ℚ (FreeDegreeRankLieAlgebra X s r w hw))) ℚ + section_right_inverse : LinearMap.toMatrix sourceBasis b + (FreeDegreeRankLieAlgebra.projection X s r w hw).toLinearMap * sectionMatrix = 1 + section_height : ∀ i j, rationalLogHeight (sectionMatrix i j) ≤ p + +namespace FreeCoordinateFrame + +variable {b : Basis (Fin (finrank ℚ (FreeDegreeRankLieAlgebra X s r w hw))) ℚ + (FreeDegreeRankLieAlgebra X s r w hw)} {p q : ℝ} + +def mono (F : FreeCoordinateFrame b p) (hpq : p ≤ q) : FreeCoordinateFrame b q where + tree_height x hx i := (F.tree_height x hx i).trans hpq + sourceBasis := F.sourceBasis + sourceBasis_trees := F.sourceBasis_trees + sourceDimension := F.sourceDimension.trans hpq + sectionMatrix := F.sectionMatrix + section_right_inverse := F.section_right_inverse + section_height i j := (F.section_height i j).trans hpq + +end FreeCoordinateFrame +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem FreeNilpotentLieAlgebra.of_mem_treeGenerators + (X : Type*) [Fintype X] (s : ℕ) (hs : 1 ≤ s) (x : X) : + FreeNilpotentLieAlgebra.of X s x ∈ FreeNilpotentLieAlgebra.treeGenerators X s := by + classical + apply Finset.mem_image.mpr + refine ⟨FreeMagma.of x, Finset.mem_filter.mpr ⟨?_, hs⟩, rfl⟩ + exact mem_finiteLieTrees_of_length_le X (FreeMagma.of x) hs + +theorem FreeCoordinateFrame.generator_height + {X : Type*} [Fintype X] {s r : ℕ} {w : X → ℕ} {hw : ∀ x, 0 < w x} + {b : Basis (Fin (finrank ℚ (FreeDegreeRankLieAlgebra X s r w hw))) ℚ + (FreeDegreeRankLieAlgebra X s r w hw)} {p : ℝ} + (F : FreeCoordinateFrame b p) (hs : 1 ≤ s) (x : X) (i) : + rationalLogHeight (b.repr (FreeDegreeRankLieAlgebra.of X s r w hw x) i) ≤ p := + F.tree_height (FreeNilpotentLieAlgebra.of X s x) + (FreeNilpotentLieAlgebra.of_mem_treeGenerators X s hs x) i + +theorem exists_submodule_basis_of_spanning_logHeight + {V ι κ : Type*} [AddCommGroup V] [Module ℚ V] [Fintype ι] + (e : Basis ι ℚ V) (U : Submodule ℚ V) (v : κ → V) + (hspan : Submodule.span ℚ (Set.range v) = U) {p : ℝ} + (hv : ∀ a i, rationalLogHeight (e.repr (v a) i) ≤ p) : + ∃ b : Basis (Fin (finrank ℚ U)) ℚ U, + ∀ a i, rationalLogHeight (e.repr (b a : V) i) ≤ p := by + classical + let : FiniteDimensional ℚ V := e.finiteDimensional_of_finite + have hex := Submodule.exists_fun_fin_finrank_span_eq ℚ (Set.range v) + rw [hspan] at hex + obtain ⟨z, hz, hzspan, hzli⟩ := hex + refine ⟨(Basis.span hzli).map (LinearEquiv.ofEq _ _ hzspan), ?_⟩ + intro a i + simp only [Basis.map_apply, LinearEquiv.coe_ofEq_apply, Basis.coe_span_apply] + obtain ⟨k, hk⟩ := hz a + rw [← hk] + exact hv k i + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_petalComparisonSpace_basis_logHeight + {V μ : Type*} [AddCommGroup V] [Module ℚ V] [Fintype μ] + (e : Basis μ ℚ V) (C P K : Submodule ℚ V) + (c : Basis (Fin (finrank ℚ C)) ℚ C) (p : Basis (Fin (finrank ℚ P)) ℚ P) + (k : Basis (Fin (finrank ℚ K)) ℚ K) {q : ℝ} (hq : 0 ≤ q) + (hc : ∀ a i, rationalLogHeight (e.repr (c a : V) i) ≤ q) + (hp : ∀ a i, rationalLogHeight (e.repr (p a : V) i) ≤ q) + (hk : ∀ a i, rationalLogHeight (e.repr (k a : V) i) ≤ q) : + ∃ b : Basis (Fin (finrank ℚ (petalComparisonSpace C P K))) ℚ (petalComparisonSpace C P K), + ∀ a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => e)).repr (b a : Fin 2 → V) i) ≤ q := by + classical + let Δ : V →ₗ[ℚ] (Fin 2 → V) := LinearMap.pi (fun _ => LinearMap.id) + let S₀ : V →ₗ[ℚ] (Fin 2 → V) := LinearMap.single ℚ (fun _ : Fin 2 => V) 0 + let S₁ : V →ₗ[ℚ] (Fin 2 → V) := LinearMap.single ℚ (fun _ : Fin 2 => V) 1 + have hspace : petalComparisonSpace C P K = + (C.map Δ ⊔ P.map S₀) ⊔ (K.map S₀ ⊔ K.map S₁) := by + apply le_antisymm + · intro x hx + obtain ⟨a, ha, b, hb, u, hu, v, hv, h₀, h₁⟩ := petalComparisonSpace_decompose C P K x hx + have hh : (Δ a + S₀ b) + (S₀ u + S₁ v) ∈ + (C.map Δ ⊔ P.map S₀) ⊔ (K.map S₀ ⊔ K.map S₁) := + Submodule.add_mem_sup (Submodule.add_mem_sup ⟨a, ha, rfl⟩ ⟨b, hb, rfl⟩) + (Submodule.add_mem_sup ⟨u, hu, rfl⟩ ⟨v, hv, rfl⟩) + convert hh using 1 + ext i + fin_cases i <;> simp [Δ, S₀, S₁, LinearMap.single_apply, h₀, h₁] + · apply sup_le (sup_le ?_ ?_) (sup_le ?_ ?_) + · rintro x ⟨a, ha, rfl⟩ + apply (mem_petalComparisonSpace C P K _).mpr + simpa [Δ] using And.intro (Submodule.mem_sup_left ha) + ((P ⊔ K).zero_mem) + · rintro x ⟨a, ha, rfl⟩ + apply (mem_petalComparisonSpace C P K _).mpr + simpa [S₀, LinearMap.single_apply] using + And.intro ((C ⊔ K).zero_mem) (Submodule.mem_sup_left ha) + · rintro x ⟨a, ha, rfl⟩ + apply (mem_petalComparisonSpace C P K _).mpr + simpa [S₀, LinearMap.single_apply] using + And.intro ((C ⊔ K).zero_mem) (Submodule.mem_sup_right ha) + · rintro x ⟨a, ha, rfl⟩ + apply (mem_petalComparisonSpace C P K _).mpr + simpa [S₁, LinearMap.single_apply] using + And.intro (Submodule.mem_sup_right ha) (Submodule.mem_sup_right (K.neg_mem ha)) + have hspan (U : Submodule ℚ V) (b : Basis (Fin (finrank ℚ U)) ℚ U) : + Submodule.span ℚ (Set.range (fun j => (b j : V))) = U := by + change Submodule.span ℚ (Set.range (U.subtype ∘ b)) = U + rw [Set.range_comp, ← Submodule.map_span, b.span_eq, Submodule.map_top, Submodule.range_subtype] + have hmap (U : Submodule ℚ V) (b : Basis (Fin (finrank ℚ U)) ℚ U) + (φ : V →ₗ[ℚ] (Fin 2 → V)) : + Submodule.span ℚ (Set.range (fun j => φ (b j : V))) = U.map φ := by + change Submodule.span ℚ (Set.range (φ ∘ fun j => (b j : V))) = _ + rw [Set.range_comp, ← Submodule.map_span, hspan] + let v := Sum.elim (Sum.elim (fun j => Δ (c j : V)) (fun j => S₀ (p j : V))) + (Sum.elim (fun j => S₀ (k j : V)) (fun j => S₁ (k j : V))) + have hv : Submodule.span ℚ (Set.range v) = petalComparisonSpace C P K := by + dsimp only [v] + rw [span_range_sumElim, span_range_sumElim, span_range_sumElim, + hmap, hmap, hmap, hmap, hspace] + have hsingle (j : Fin 2) (x : V) (hx : ∀ i, rationalLogHeight (e.repr x i) ≤ q) + (i : Σ _ : Fin 2, μ) : + rationalLogHeight ((Pi.basis (fun _ : Fin 2 => e)).repr + (LinearMap.single ℚ (fun _ : Fin 2 => V) j x) i) ≤ q := by + rcases i with ⟨i, a⟩ + by_cases hji : j = i + · subst i + simpa [Pi.basis_repr, LinearMap.single_apply] using hx a + · simpa [Pi.basis_repr, LinearMap.single_apply, hji, Ne.symm hji, rationalLogHeight] using hq + apply exists_submodule_basis_of_spanning_logHeight (Pi.basis (fun _ : Fin 2 => e)) _ v hv + intro j i + cases j with + | inl j => + cases j with + | inl j => simpa [v, Δ, Pi.basis_repr] using hc j i.2 + | inr j => exact hsingle 0 (p j) (hp j) i + | inr j => + cases j with + | inl j => exact hsingle 0 (k j) (hk j) i + | inr j => exact hsingle 1 (k j) (hk j) i + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +noncomputable def coefficientFreeSpan (d : Fin s) : Submodule ℚ D.CoefficientFreeLieAlgebra := + D.commonFreeSpan d ⊔ D.dependentFreeSpan d + +theorem commonFreeSpan_le_coefficientFreeSpan (d : Fin s) : + D.commonFreeSpan d ≤ D.coefficientFreeSpan d := le_sup_left + +theorem dependentFreeSpan_le_coefficientFreeSpan (d : Fin s) : + D.dependentFreeSpan d ≤ D.coefficientFreeSpan d := le_sup_right + +theorem coefficientFreeSpan_le_layer (d : Fin s) : + D.coefficientFreeSpan d ≤ D.coefficientFreeFiltration.layer (d.val + 1) 1 := + sup_le (D.commonFreeSpan_le_layer d) (D.dependentFreeSpan_le_layer d) + +variable {Q : ℝ} (B : D.CoefficientBases Q) + +theorem CoefficientBases.freeEvaluation_coefficientFreeSpan (d : Fin s) : + (D.coefficientFreeSpan d).map (B.freeEvaluation D).toLinearMap = + D.commonCoefficientSpace ⟨d.val + 1, by omega⟩ := by + rw [coefficientFreeSpan, Submodule.map_sup, B.freeEvaluation_commonFreeSpan D, + B.freeEvaluation_dependentFreeSpan D] + exact sup_eq_left.mpr (D.dependentCoefficientSpace_le_common _) + +theorem CoefficientBases.realEvaluation_coefficientFreeSpan (d : Fin s) + {x : ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra} + (hx : x ∈ (D.coefficientFreeSpan d).baseChange ℝ) : + realificationLieHom (B.freeEvaluation D) x ∈ + (D.commonCoefficientSpace ⟨d.val + 1, by omega⟩).baseChange ℝ := by + rw [← B.freeEvaluation_coefficientFreeSpan D d, realification_map] + exact ⟨x, hx, rfl⟩ + +theorem CoefficientBases.combined_free_sunflower (n : ℕ) (d : Fin n → Fin s) + (a : FreeMagma (Fin n)) (hd : lieTreeWeight (fun i => (d i).val + 1) a = s) + (hr : a.length = r) (v : Fin n → D.CoefficientFreeLieAlgebra) + (hv : ∀ i, v i ∈ D.coefficientFreeSpan (d i)) + (j k : Fin n) (hjk : j ≠ k) (hj : j ∈ lieTreeSupport a) (hk : k ∈ lieTreeSupport a) + (hvj : v j ∈ D.dependentFreeSpan (d j)) (hvk : v k ∈ D.dependentFreeSpan (d k)) : + B.freeFrequency D (lieTreeEval v a) = 0 := by + have h := D.coefficient_sunflower n (fun i => ⟨(d i).val + 1, by omega⟩) a hd hr + (fun i => B.freeEvaluation D (v i)) + (fun i => (B.freeEvaluation_coefficientFreeSpan D (d i)).le ⟨v i, hv i, rfl⟩) + j k hjk hj hk + ((B.freeEvaluation_dependentFreeSpan D (d j)).le ⟨v j, hvj, rfl⟩) + ((B.freeEvaluation_dependentFreeSpan D (d k)).le ⟨v k, hvk, rfl⟩) + change W.vertical.frequency (B.freeEvaluation D (lieTreeEval v a)) = 0 + rw [map_lieTreeEval] + exact h + +theorem CoefficientBases.real_combined_free_sunflower (n : ℕ) (d : Fin n → Fin s) + (a : FreeMagma (Fin n)) (hd : lieTreeWeight (fun i => (d i).val + 1) a = s) + (hr : a.length = r) (v : Fin n → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + (hv : ∀ i, v i ∈ (D.coefficientFreeSpan (d i)).baseChange ℝ) + (j k : Fin n) (hjk : j ≠ k) (hj : j ∈ lieTreeSupport a) (hk : k ∈ lieTreeSupport a) + (hvj : v j ∈ (D.dependentFreeSpan (d j)).baseChange ℝ) + (hvk : v k ∈ (D.dependentFreeSpan (d k)).baseChange ℝ) : + realifyFunctional (B.freeFrequency D) (lieTreeEval v a) = 0 := by + have h := D.real_coefficient_sunflower n (fun i => ⟨(d i).val + 1, by omega⟩) a hd hr + (fun i => realificationLieHom (B.freeEvaluation D) (v i)) + (fun i => B.realEvaluation_coefficientFreeSpan D (d i) (hv i)) + j k hjk hj hk + (B.realEvaluation_dependentFreeSpan D (d j) hvj) + (B.realEvaluation_dependentFreeSpan D (d k) hvk) + change realifyFunctional (W.vertical.frequency.comp (B.freeEvaluation D).toLinearMap) + (lieTreeEval v a) = 0 + rw [realifyFunctional_comp] + exact (congrArg (realifyFunctional W.vertical.frequency) + (map_lieTreeEval (realLieHomToRat (realificationLieHom (B.freeEvaluation D))) v a)).trans h + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_common_marked_source_basis (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p q P M : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} + (D : R.CommonData P) (B : D.CoefficientBases M), 0 ≤ M → b ≤ M → + ∃ e : Basis (Fin (finrank ℚ D.CoefficientFreeLieAlgebra)) ℚ D.CoefficientFreeLieAlgebra, + ∃ ω : Fin (finrank ℚ D.CoefficientFreeLieAlgebra) → ℕ, + (∀ j, D.coefficientFreeFiltration.associatedDegree.layer j = + Submodule.span ℚ (e '' {i | j ≤ ω i})) ∧ + (∀ i, ω i ≤ s) ∧ + (finrank ℚ D.CoefficientFreeLieAlgebra : ℝ) ≤ (M + C) ^ C ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants e i j k) ≤ (M + C) ^ C) ∧ + (∀ x i, rationalLogHeight (e.repr (D.coefficientFreeGenerator x) i) ≤ (M + C) ^ C) ∧ + ∀ i, rationalLogHeight (B.freeFrequency D (e i)) ≤ (M + C) ^ C := by + obtain ⟨a, _, hfree⟩ := exists_adapted_free_degree_rank_model s + let K₀ : Polynomial ℕ := Polynomial.C (2 * s + 1) * Polynomial.X + 1 + let A₀ := (K₀ + Polynomial.C a) ^ a + let T₀ := Polynomial.X + A₀ + let V₀ := ((T₀ + 3) ^ (6 * s + 2) + T₀ + 2) ^ 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (A₀ + (T₀ + V₀ + 2) ^ 4) + refine ⟨C, hC, ?_⟩ + intro r N _ b p q P M W out H R D B hM hbM + let K := ((2 * s + 1 : ℕ) : ℝ) * M + 1 + let A := (K + a) ^ a + let T := M + A + let V := ((T + 3) ^ (6 * s + 2) + T + 2) ^ 4 + let Z := T + V + have hK : 0 ≤ K := by dsimp [K]; positivity + have hA : 0 ≤ A := by dsimp [A]; positivity + have hT : 0 ≤ T := add_nonneg hM hA + have hMT : M ≤ T := le_add_of_nonneg_right hA + have hAT : A ≤ T := le_add_of_nonneg_left hM + have hTZ : T ≤ Z := le_add_of_nonneg_right (by dsimp [V]; positivity) + have hVZ : V ≤ Z := le_add_of_nonneg_left hT + have hZ : 0 ≤ Z := hT.trans hTZ + have hcost : A + (Z + 2) ^ 4 ≤ (M + C) ^ C := by + simpa [K₀, A₀, T₀, V₀, K, A, T, V, Z, Polynomial.eval₂_pow] using hbudget M hM + have hAC : A ≤ (M + C) ^ C := + (le_add_of_nonneg_right (by positivity : 0 ≤ (Z + 2) ^ 4)).trans hcost + have hZC : (Z + 2) ^ 4 ≤ (M + C) ^ C := (le_add_of_nonneg_left hA).trans hcost + have hdim : (W.dim : ℝ) ≤ M := W.complexity.1.1.trans hbM + have hX : (Fintype.card D.CoefficientAlphabet : ℝ) ≤ K := by + calc + _ ≤ (2 : ℝ) * s * W.dim := by exact_mod_cast D.coefficientAlphabet_card + _ ≤ (2 : ℝ) * s * M := mul_le_mul_of_nonneg_left hdim (by positivity) + _ ≤ (2 : ℝ) * s * M + (M + 1) := le_add_of_nonneg_right (by linarith only [hM]) + _ = K := by dsimp [K]; push_cast; ring + obtain ⟨hd, e, _, htail, hc, htree, e₀, he₀, hd₀, S, hS, hSH⟩ := + hfree D.CoefficientAlphabet r W.rank.filtration.rank_le_degree + D.coefficientWeight D.coefficientWeight_pos K hK hX + have htail' : ∀ j, ∃ c, D.coefficientFreeFiltration.associatedDegree.layer j = basisTail e c := by + intro j + obtain ⟨c, _, hc⟩ := htail j 0 + exact ⟨c, hc⟩ + obtain ⟨ω, hω⟩ := D.coefficientFreeFiltration.associatedDegree.exists_weights_of_tails e htail' + have hmatrix (i j) : rationalLogHeight (W.model.basis.repr (B.freeEvaluation D (e j)) i) ≤ V := by + have h := FreeDegreeRankLieAlgebra.lift_basis_matrix_logHeight W.rank.filtration + D.coefficientWeight D.coefficientWeight_pos (B.generator D) (B.generator_mem_layer D) + e₀ he₀ e W.model.basis S hS hT (hd₀.trans hAT) + (by simpa only [Fintype.card_fin] using hdim.trans hMT) + (fun i j => (hSH i j).trans hAT) + (fun i j k => (W.complexity.1.2.2.1 i j k).trans (hbM.trans hMT)) + (fun x i => (B.generator_height D x i).trans hMT) i j + rw [LinearMap.toMatrix_apply] at h + exact h + refine ⟨e, ω, hω, D.coefficientFreeFiltration.associatedDegree.adaptedBasis_weight_le_step e ω hω, + hd.trans hAC, (fun i j k => (hc i j k).trans hAC), ?_, ?_⟩ + · intro x i + exact (htree (FreeNilpotentLieAlgebra.of D.CoefficientAlphabet s x) + (FreeNilpotentLieAlgebra.of_mem_treeGenerators D.CoefficientAlphabet s hs x) i).trans hAC + · intro i + have h := rational_functional_value_logHeight W.model.basis W.vertical.frequency hZ + (by simpa only [Fintype.card_fin] using hdim.trans (hMT.trans hTZ)) + (fun j => (W.vertical.height j).trans (hbM.trans (hMT.trans hTZ))) + (B.freeEvaluation D (e i)) (fun j => (hmatrix j i).trans hVZ) + exact h.trans hZC + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + (e : Basis (Fin (finrank ℚ D.CoefficientFreeLieAlgebra)) ℚ D.CoefficientFreeLieAlgebra) + {Q : ℝ} (F : FreeCoordinateFrame e Q) + +include F + +theorem exists_commonFreeSpan_basis (hs : 1 ≤ s) (d : Fin s) : + ∃ c : Basis (Fin (finrank ℚ (D.commonFreeSpan d))) ℚ (D.commonFreeSpan d), + ∀ a i, rationalLogHeight (e.repr (c a : D.CoefficientFreeLieAlgebra) i) ≤ Q := + exists_submodule_basis_of_spanning_logHeight e _ + (fun a => D.coefficientFreeGenerator (Sum.inl ⟨d, a⟩)) rfl + (fun a i => F.generator_height hs (Sum.inl ⟨d, a⟩) i) + +theorem exists_dependentFreeSpan_basis (hs : 1 ≤ s) (d : Fin s) : + ∃ c : Basis (Fin (finrank ℚ (D.dependentFreeSpan d))) ℚ (D.dependentFreeSpan d), + ∀ a i, rationalLogHeight (e.repr (c a : D.CoefficientFreeLieAlgebra) i) ≤ Q := + exists_submodule_basis_of_spanning_logHeight e _ + (fun a => D.coefficientFreeGenerator (Sum.inr ⟨d, a⟩)) rfl + (fun a i => F.generator_height hs (Sum.inr ⟨d, a⟩) i) + +theorem exists_coefficientFreeSpan_basis (hs : 1 ≤ s) (d : Fin s) : + ∃ c : Basis (Fin (finrank ℚ (D.coefficientFreeSpan d))) ℚ (D.coefficientFreeSpan d), + ∀ a i, rationalLogHeight (e.repr (c a : D.CoefficientFreeLieAlgebra) i) ≤ Q := by + let v := Sum.elim (fun a => D.coefficientFreeGenerator (Sum.inl ⟨d, a⟩)) + (fun a => D.coefficientFreeGenerator (Sum.inr ⟨d, a⟩)) + have hspan : Submodule.span ℚ (Set.range v) = D.coefficientFreeSpan d := by + dsimp only [v] + rw [span_range_sumElim] + rfl + apply exists_submodule_basis_of_spanning_logHeight e _ v hspan + intro a i + cases a with + | inl a => exact F.generator_height hs (Sum.inl ⟨d, a⟩) i + | inr a => exact F.generator_height hs (Sum.inr ⟨d, a⟩) i + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CommonKernelRangeEquiv.lean b/lean/OAI/Combinatorics/Progressions/Linear/CommonKernelRangeEquiv.lean new file mode 100644 index 0000000000000000000000000000000000000000..2877eb13077d3507f8ba65f1fa78ffa514a182f1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CommonKernelRangeEquiv.lean @@ -0,0 +1,55 @@ +import Mathlib.LinearAlgebra.Isomorphisms + +namespace OAI + +section + +namespace Erdos3 + +variable {K A B C : Type*} [Field K] [AddCommGroup A] [Module K A] + [AddCommGroup B] [Module K B] [AddCommGroup C] [Module K C] + +noncomputable def commonKernelRangeEquiv (f : A →ₗ[K] B) (g : A →ₗ[K] C) + (h : LinearMap.ker f = LinearMap.ker g) : LinearMap.range f ≃ₗ[K] LinearMap.range g := + f.quotKerEquivRange.symm.trans ((Submodule.quotEquivOfEq _ _ h).trans g.quotKerEquivRange) + +theorem commonKernelRangeEquiv_apply (f : A →ₗ[K] B) (g : A →ₗ[K] C) + (h : LinearMap.ker f = LinearMap.ker g) (x : A) : + (commonKernelRangeEquiv f g h ⟨f x, ⟨x, rfl⟩⟩ : C) = g x := by + dsimp only [commonKernelRangeEquiv, LinearEquiv.trans_apply] + rw [f.quotKerEquivRange_symm_apply_image x ⟨x, rfl⟩] + rfl + +noncomputable def commonKernelSubmoduleEquiv (f : A →ₗ[K] B) (g : A →ₗ[K] C) + (U : Submodule K B) (V : Submodule K C) + (h : LinearMap.ker f = LinearMap.ker g) + (hf : LinearMap.range f = U) (hg : LinearMap.range g = V) : U ≃ₗ[K] V := + (LinearEquiv.ofEq U (LinearMap.range f) hf.symm).trans + ((commonKernelRangeEquiv f g h).trans (LinearEquiv.ofEq (LinearMap.range g) V hg)) + +theorem commonKernelSubmoduleEquiv_apply (f : A →ₗ[K] B) (g : A →ₗ[K] C) + (U : Submodule K B) (V : Submodule K C) + (h : LinearMap.ker f = LinearMap.ker g) + (hf : LinearMap.range f = U) (hg : LinearMap.range g = V) + (x : A) (hx : f x ∈ U) : + (commonKernelSubmoduleEquiv f g U V h hf hg ⟨f x, hx⟩ : C) = g x := + commonKernelRangeEquiv_apply f g h x + +theorem commonKernelSubmoduleEquiv_symm_apply (f : A →ₗ[K] B) (g : A →ₗ[K] C) + (U : Submodule K B) (V : Submodule K C) + (h : LinearMap.ker f = LinearMap.ker g) + (hf : LinearMap.range f = U) (hg : LinearMap.range g = V) + (x : A) (y : V) (hy : g x = y.val) : + f x = ((commonKernelSubmoduleEquiv f g U V h hf hg).symm y : B) := by + have hx : f x ∈ U := hf.le ⟨x, rfl⟩ + have he : commonKernelSubmoduleEquiv f g U V h hf hg ⟨f x, hx⟩ = y := + Subtype.ext ((commonKernelSubmoduleEquiv_apply f g U V h hf hg x hx).trans hy) + have hi := congrArg (commonKernelSubmoduleEquiv f g U V h hf hg).symm he + rw [LinearEquiv.symm_apply_apply] at hi + exact congrArg Subtype.val hi + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CommonProjectionFactorizationBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/CommonProjectionFactorizationBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f39b7002a4dce897387a3b47c3906985bb655ab --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CommonProjectionFactorizationBudget.lean @@ -0,0 +1,37 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialDensityBudget + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +theorem exists_commonProjectionFactorization_budget (A B : ℕ) (hA : 2 ≤ A) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + let q := (p + A) ^ A + p ≤ q ∧ 0 ≤ q ∧ (q + 2) ^ B ≤ (p + C) ^ C ∧ + ((q + 2) ^ 2 + 2) ^ 63 + 1 ≤ (p + C) ^ C := by + let Q : Polynomial ℕ := (Polynomial.X + Polynomial.C A) ^ A + let P : Polynomial ℕ := (Q + 2) ^ B + (((Q + 2) ^ 2 + 2) ^ 63 + 1) + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, fun p hp => ?_⟩ + let q : ℝ := (p + A) ^ A + have hbase : 1 ≤ p + A := by + have : (2 : ℝ) ≤ A := by exact_mod_cast hA + linarith + have hpq : p ≤ q := by + apply (le_add_of_nonneg_right (Nat.cast_nonneg A)).trans + simpa only [pow_one] using pow_le_pow_right₀ hbase (show 1 ≤ A by omega) + have hq : 0 ≤ q := hp.trans hpq + have hfirst : 0 ≤ (q + 2) ^ B := by positivity + have hsecond : 0 ≤ ((q + 2) ^ 2 + 2) ^ 63 + 1 := by positivity + have hsum : (q + 2) ^ B + (((q + 2) ^ 2 + 2) ^ 63 + 1) ≤ (p + C) ^ C := by + simpa [P, Q, q, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨hpq, hq, (le_add_of_nonneg_right hsecond).trans hsum, + (le_add_of_nonneg_left hfirst).trans hsum⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CommonRankCoefficientCorrections.lean b/lean/OAI/Combinatorics/Progressions/Linear/CommonRankCoefficientCorrections.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fe5c27e71eab3c42d2e03015fe01d067e7c77a4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CommonRankCoefficientCorrections.lean @@ -0,0 +1,498 @@ +import OAI.Combinatorics.Progressions.Linear.RankOrbitCoefficientCorrections + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_common_rank_relation_budget (c : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → p + (p + c) ^ c ≤ (p + C) ^ C := by + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (Polynomial.X + (Polynomial.X + Polynomial.C c) ^ c) + exact ⟨C, hC, fun p hp => by simpa [Polynomial.eval₂_pow] using hbudget p hp⟩ + +theorem exists_native_common_rank_budget (a c : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + let q := p + (p + a) ^ a + 2 + q ≤ (p + C) ^ C ∧ (q + c) ^ c ≤ (p + C) ^ C := by + let X : Polynomial ℕ := Polynomial.X + let Y := X + (X + Polynomial.C a) ^ a + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Y + (Y + Polynomial.C c) ^ c) + refine ⟨C, hC, ?_⟩ + intro p hp q + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpow : 0 ≤ (q + c) ^ c := by positivity + have hsum : q + (q + c) ^ c ≤ (p + C) ^ C := by + simpa [X, Y, q, Polynomial.eval₂_pow] using hbudget p hp + constructor <;> linarith only [hq, hpow, hsum] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_rank_common_data_budget (s c : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + (p + c) ^ c ≤ (p + C) ^ C ∧ + 3 * (4 * p) * (4 * p) * (refiltrationCoordinateBudget ((p + c) ^ c) + 2) * (s + 1) ≤ + (p + C) ^ C := by + let X : Polynomial ℕ := Polynomial.X + let Y := (X + Polynomial.C c) ^ c + let A := ((Y + 1 + (Y + 3) ^ 7 + 2) ^ 9 + Y + 4) ^ 4 + let P := Y + 3 * (4 * X) * (4 * X) * (A + 2) * Polynomial.C (s + 1) + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro p hp + have hY : 0 ≤ (p + c) ^ c := by positivity + have hA := refiltrationCoordinateBudget_nonneg hY + have hcost : 0 ≤ 3 * (4 * p) * (4 * p) * + (refiltrationCoordinateBudget ((p + c) ^ c) + 2) * (s + 1) := by positivity + have hsum : (p + c) ^ c + 3 * (4 * p) * (4 * p) * + (refiltrationCoordinateBudget ((p + c) ^ c) + 2) * (s + 1) ≤ (p + C) ^ C := by + simpa [P, A, Y, X, refiltrationCoordinateBudget, Polynomial.eval₂_pow] using hbound p hp + constructor <;> linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_common_rank_interval_data (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {α : Type*} {r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : α → ZMod N × ZMod N × ZMod N} {branch : Bool}, + 0 ≤ p → b ≤ p → (I : ∀ a, NativeRankInterval W out H (t a) branch p p) → + (S : Finset α) → S.Nonempty → + (∀ a ∈ S, Real.exp ((p + C) ^ C) ≤ ((I a).length : ℝ)) → + ∃ (K : Fin (s + 1) → Submodule ℚ (Fin 4 → W.L)) (T : Finset α), + T ⊆ S ∧ T.Nonempty ∧ Real.exp (-((p + C) ^ C)) * S.card ≤ (T.card : ℝ) ∧ + (∀ d, K d ∈ heightBoundedSubspaces W.fourRankBasis (Fintype.card (Σ _ : Fin 4, Fin W.dim)) + ⌈Real.exp (refiltrationCoordinateBudget ((p + C) ^ C))⌉₊) ∧ + ∀ a ∈ T, ∃ E : (I a).SunflowerWitness ((p + C) ^ C), + (∀ d : Fin (s + 1), E.projection d.val = K d) ∧ + ∀ d : Fin (s + 1), (I a).refilteredHorizontalImage E.index E.subalgebra d.val = + W.rank.filtration.horizontalImageOfSubmodule (K d) d.val := by + obtain ⟨c, _, hwitness⟩ := exists_rank_sunflower_witness s hs + obtain ⟨C, hC, hbudget⟩ := exists_rank_common_data_budget s c + refine ⟨C, hC, ?_⟩ + intro α r N _ b p W out H t branch hp hbp I S hS hlarge + let P := (p + c) ^ c + have hP : 0 ≤ P := by dsimp [P]; positivity + obtain ⟨hPC, hcostC⟩ := hbudget p hp + have hQ : 0 ≤ (p + C) ^ C := hP.trans hPC + have hex (a : α) (ha : a ∈ S) : Nonempty ((I a).SunflowerWitness P) := + hwitness hp hbp (I a) ((Real.exp_le_exp.mpr hPC).trans (hlarge a ha)) + let D (a : α) (ha : a ∈ S) := Classical.choice (hex a ha) + obtain ⟨K, T, hTS, hT, hsize, _, hdata⟩ := exists_common_rank_projection_family I S hS hP D + have hdim : (W.dim : ℝ) ≤ p := W.complexity.1.1.trans hbp + have hcard : Fintype.card (Σ _ : Fin 4, Fin W.dim) = 4 * W.dim := by simp + have hn : (Fintype.card (Σ _ : Fin 4, Fin W.dim) : ℝ) ≤ 4 * p := by + rw [hcard, Nat.cast_mul] + norm_num + linarith + have hA := refiltrationCoordinateBudget_nonneg hP + have hcost : 3 * (Fintype.card (Σ _ : Fin 4, Fin W.dim) : ℝ) * + Fintype.card (Σ _ : Fin 4, Fin W.dim) * (refiltrationCoordinateBudget P + 2) * (s + 1) ≤ + (p + C) ^ C := by + apply le_trans _ hcostC + change 3 * (Fintype.card (Σ _ : Fin 4, Fin W.dim) : ℝ) * + Fintype.card (Σ _ : Fin 4, Fin W.dim) * (refiltrationCoordinateBudget P + 2) * (s + 1) ≤ + 3 * (4 * p) * (4 * p) * (refiltrationCoordinateBudget P + 2) * (s + 1) + gcongr + have hnew (a : α) (ha : a ∈ T) : ∃ E : (I a).SunflowerWitness ((p + C) ^ C), + (∀ d : Fin (s + 1), E.projection d.val = K d) ∧ + ∀ d : Fin (s + 1), (I a).refilteredHorizontalImage E.index E.subalgebra d.val = + W.rank.filtration.horizontalImageOfSubmodule (K d) d.val := by + obtain ⟨E, hproj, hhor⟩ := hdata a ha + exact ⟨E.mono hPC, hproj, hhor⟩ + refine ⟨K, T, hTS, hT, ?_, ?_, hnew⟩ + · apply le_trans _ hsize + apply mul_le_mul_of_nonneg_right _ (Nat.cast_nonneg _) + apply Real.exp_le_exp.mpr + nlinarith + · obtain ⟨a, ha⟩ := hT + obtain ⟨E, hproj, _⟩ := hnew a ha + intro d + rw [← hproj d] + exact E.projection_mem_candidates hQ d.val + +end Erdos3 + +end + +section + +namespace Erdos3 + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +namespace NativeRankRelation + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} + +structure CommonData (R : NativeRankRelation W out H p q) (P : ℝ) where + quadruples : Finset (ZMod N × ZMod N × ZMod N) + subset : quadruples ⊆ R.quadruples + nonempty : quadruples.Nonempty + density : Real.exp (-P) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ quadruples.card + spaces : Fin (s + 1) → Submodule ℚ (Fin 4 → W.L) + witness : ∀ t, (ht : t ∈ quadruples) → (R.interval ⟨t, subset ht⟩).SunflowerWitness P + projection : ∀ t (ht : t ∈ quadruples) (d : Fin (s + 1)), + (witness t ht).projection d.val = spaces d + +namespace CommonData + +variable {R : NativeRankRelation W out H p q} {P Q : ℝ} (D : R.CommonData P) + +theorem spaces_mem_candidates (hP : 0 ≤ P) (d : Fin (s + 1)) : + D.spaces d ∈ heightBoundedSubspaces W.fourRankBasis (Fintype.card (Σ _ : Fin 4, Fin W.dim)) + ⌈Real.exp (refiltrationCoordinateBudget P)⌉₊ := by + obtain ⟨t, ht⟩ := D.nonempty + rw [← D.projection t ht d] + exact (D.witness t ht).projection_mem_candidates hP d.val + +theorem horizontalImage_eq (t : ZMod N × ZMod N × ZMod N) (ht : t ∈ D.quadruples) + (d : Fin (s + 1)) : + (R.interval ⟨t, D.subset ht⟩).refilteredHorizontalImage + (D.witness t ht).index (D.witness t ht).subalgebra d.val = + W.rank.filtration.horizontalImageOfSubmodule (D.spaces d) d.val := by + rw [(D.witness t ht).horizontalImage_eq, D.projection t ht d] + +noncomputable def mono (hPQ : P ≤ Q) : R.CommonData Q := + { D with + density := (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hPQ)) + (by positivity)).trans D.density + witness := fun t ht => (D.witness t ht).mono hPQ + projection := fun t ht d => D.projection t ht d } + +theorem mono_quadruples (hPQ : P ≤ Q) : (D.mono hPQ).quadruples = D.quadruples := rfl + +theorem mono_spaces (hPQ : P ≤ Q) : (D.mono hPQ).spaces = D.spaces := rfl + +end CommonData + +end NativeRankRelation + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} + +theorem exists_common_denominator (D : R.CommonData P) (hP : 0 ≤ P) : + ∃ (E : R.CommonData (2 * P)) (l : ℕ), + E.quadruples ⊆ D.quadruples ∧ E.spaces = D.spaces ∧ 0 < l ∧ (l : ℝ) ≤ Real.exp P ∧ + ∀ t (ht : t ∈ E.quadruples), (E.witness t ht).denominator = l := by + classical + let code (t : ZMod N × ZMod N × ZMod N) := + if ht : t ∈ D.quadruples then (D.witness t ht).denominator else 1 + let A := (Finset.Icc 1 ⌊Real.exp P⌋₊ : Finset ℕ) + have hcode (t) (ht : t ∈ D.quadruples) : code t ∈ (A : Set ℕ) := by + simp only [code, dite_eq_left ht, Finset.mem_coe, A, Finset.mem_Icc] + exact ⟨(D.witness t ht).denominator_pos, Nat.le_floor (D.witness t ht).denominator_bound⟩ + have hcount : ((A : Set ℕ).ncard : ℝ) ≤ Real.exp P := by + simpa only [Set.ncard_coe_finset, A, Nat.card_Icc, Nat.add_sub_cancel] using + Nat.floor_le (Real.exp_pos P).le + obtain ⟨l, hl, T, hTD, hT, hconst, hsize⟩ := exists_exponential_constant_fiber + D.quadruples D.nonempty code A A.finite_toSet hcode hcount + have hPP : P ≤ 2 * P := by linarith + let E : R.CommonData (2 * P) := { + quadruples := T + subset := hTD.trans D.subset + nonempty := hT + density := by + calc + Real.exp (-(2 * P)) * (Fintype.card (ZMod N) : ℝ) ^ 3 = + Real.exp (-P) * (Real.exp (-P) * (Fintype.card (ZMod N) : ℝ) ^ 3) := by + rw [← mul_assoc, ← Real.exp_add] + congr 2 + ring + _ ≤ Real.exp (-P) * D.quadruples.card := + mul_le_mul_of_nonneg_left D.density (Real.exp_pos _).le + _ ≤ T.card := hsize + spaces := D.spaces + witness := fun t ht => (D.witness t (hTD ht)).mono hPP + projection := fun t ht d => D.projection t (hTD ht) d } + have hl' : 1 ≤ l ∧ l ≤ ⌊Real.exp P⌋₊ := Finset.mem_Icc.mp hl + refine ⟨E, l, hTD, rfl, hl'.1, + (Nat.cast_le.mpr hl'.2).trans (Nat.floor_le (Real.exp_pos P).le), ?_⟩ + intro t ht + change (D.witness t (hTD ht)).denominator = l + simpa only [code, dite_eq_left (hTD ht)] using hconst t ht + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +noncomputable def horizontal (d : Fin (s + 1)) : + Submodule ℚ (Fin 4 → W.rank.filtration.HigherHorizontal d.val) := + W.rank.filtration.horizontalImageOfSubmodule (D.spaces d) d.val + +theorem horizontal_frequency (n : ℕ) (d : Fin n → Fin (s + 1)) (a : FreeMagma (Fin n)) + (hd : lieTreeWeight (fun j => (d j).val) a = s) (hr : a.length = r) + (v : ∀ j, Fin 4 → W.rank.filtration.HigherHorizontal (d j).val) + (hv : ∀ j, v j ∈ D.horizontal (d j)) : + W.vertical.frequency (W.rank.filtration.horizontalTreeValue (fun j => (d j).val) a + (fun j => v j 0)) + + W.vertical.frequency (W.rank.filtration.horizontalTreeValue (fun j => (d j).val) a + (fun j => v j 1)) - + W.vertical.frequency (W.rank.filtration.horizontalTreeValue (fun j => (d j).val) a + (fun j => v j 2)) - + W.vertical.frequency (W.rank.filtration.horizontalTreeValue (fun j => (d j).val) a + (fun j => v j 3)) = 0 := by + obtain ⟨t, ht⟩ := D.nonempty + apply (R.interval ⟨t, D.subset ht⟩).refilteredHorizontalImage_frequency + (D.witness t ht).index (D.witness t ht).subalgebra (fun j => (d j).val) a hd hr + ((D.witness t ht).bracket n (fun j => (d j).val) a hd hr) v + intro j + rw [D.horizontalImage_eq t ht (d j)] + exact hv j + +theorem sunflower_bracket (n : ℕ) (d : Fin n → Fin (s + 1)) (a : FreeMagma (Fin n)) + (hd : lieTreeWeight (fun j => (d j).val) a = s) (hr : a.length = r) + (v : ∀ j, W.rank.filtration.HigherHorizontal (d j).val) + (hv : ∀ j, v j ∈ fourFirstProjection (D.horizontal (d j))) + (j k : Fin n) (hjk : j ≠ k) (hj : j ∈ lieTreeSupport a) (hk : k ∈ lieTreeSupport a) + (hvj : v j ∈ fourDependentProjection (D.horizontal (d j))) + (hvk : v k ∈ fourDependentProjection (D.horizontal (d k))) : + W.vertical.frequency (W.rank.filtration.horizontalTreeValue (fun j => (d j).val) a v) = 0 := + four_dependent_inputs_vanish (lieTreeSupport a) + (W.rank.filtration.horizontalTreeValue (fun j => (d j).val) a) + (fun u j hj hu => W.rank.filtration.horizontalTreeValue_zero_of_leaf + (fun j => (d j).val) a u (i := j) hj hu) + W.vertical.frequency (map_zero _) (fun j => D.horizontal (d j)) + (D.horizontal_frequency n d a hd hr) v hv j k hjk hj hk hvj hvk + +theorem sunflower_representatives (n : ℕ) (d : Fin n → Fin (s + 1)) (a : FreeMagma (Fin n)) + (hd : lieTreeWeight (fun j => (d j).val) a = s) (hr : a.length = r) + (v : ∀ j, W.rank.filtration.layer (d j).val 1) + (hv : ∀ j, W.rank.filtration.higherHorizontalMk (d j).val (v j) ∈ + fourFirstProjection (D.horizontal (d j))) + (j k : Fin n) (hjk : j ≠ k) (hj : j ∈ lieTreeSupport a) (hk : k ∈ lieTreeSupport a) + (hvj : W.rank.filtration.higherHorizontalMk (d j).val (v j) ∈ + fourDependentProjection (D.horizontal (d j))) + (hvk : W.rank.filtration.higherHorizontalMk (d k).val (v k) ∈ + fourDependentProjection (D.horizontal (d k))) : + W.vertical.frequency (lieTreeEval (fun j => (v j).val) a) = 0 := by + have h := D.sunflower_bracket n d a hd hr + (fun j => W.rank.filtration.higherHorizontalMk (d j).val (v j)) hv j k hjk hj hk hvj hvk + rwa [W.rank.filtration.horizontalTreeValue_mk (fun j => (d j).val) a hd hr v] at h + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3 + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_common_rank_relation (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)}, 0 ≤ p → b ≤ p → + (R : NativeRankRelation W out H p p) → + Real.exp ((p + C) ^ C) ≤ N → Nonempty (R.CommonData ((p + C) ^ C)) := by + classical + obtain ⟨c, _, hcommon⟩ := exists_common_rank_interval_data s hs + obtain ⟨C, hC, hbudget⟩ := exists_common_rank_relation_budget c + refine ⟨C, hC, ?_⟩ + intro r N _ b p W out H hp hbp R hN + let A := (p + c) ^ c + have hsum : p + A ≤ (p + C) ^ C := hbudget p hp + have hAQ : A ≤ (p + C) ^ C := by linarith + obtain ⟨t₀, ht₀⟩ := R.quadruples_nonempty + let : Nonempty R.quadruples := ⟨⟨t₀, ht₀⟩⟩ + have hlong (t : R.quadruples) (_ht : t ∈ (Finset.univ : Finset R.quadruples)) : + Real.exp ((p + c) ^ c) ≤ ((R.interval t).length : ℝ) := + (R.interval t).length_exp_lower_bound ((Real.exp_le_exp.mpr hsum).trans hN) + obtain ⟨K, T, _, hT, hsize, _, hdata⟩ := + hcommon hp hbp R.interval Finset.univ Finset.univ_nonempty hlong + let e : R.quadruples ↪ (ZMod N × ZMod N × ZMod N) := + ⟨Subtype.val, Subtype.val_injective⟩ + let Q := T.map e + have hQR : Q ⊆ R.quadruples := by + intro t ht + obtain ⟨u, _, rfl⟩ := Finset.mem_map.mp ht + exact u.property + have hQ : Q.Nonempty := by + obtain ⟨u, hu⟩ := hT + exact ⟨e u, Finset.mem_map.mpr ⟨u, hu, rfl⟩⟩ + have hsize' : Real.exp (-A) * (R.quadruples.card : ℝ) ≤ (T.card : ℝ) := by + simpa only [Finset.card_univ, Fintype.card_coe] using hsize + have hdensity : Real.exp (-(p + A)) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ Q.card := by + calc + _ = Real.exp (-A) * (Real.exp (-p) * (Fintype.card (ZMod N) : ℝ) ^ 3) := by + rw [show -(p + A) = -A + -p by ring, Real.exp_add] + ring + _ ≤ Real.exp (-A) * R.quadruples.card := + mul_le_mul_of_nonneg_left R.density (Real.exp_pos _).le + _ ≤ T.card := hsize' + _ = Q.card := by simp only [Q, Finset.card_map] + have hwitness (t : ZMod N × ZMod N × ZMod N) (ht : t ∈ Q) : + ∃ E : (R.interval ⟨t, hQR ht⟩).SunflowerWitness ((p + C) ^ C), + ∀ d : Fin (s + 1), E.projection d.val = K d := by + obtain ⟨u, hu, rfl⟩ := Finset.mem_map.mp ht + obtain ⟨E, hproj, _⟩ := hdata u hu + exact ⟨E.mono hAQ, hproj⟩ + refine ⟨{ + quadruples := Q + subset := hQR + nonempty := hQ + density := ?_ + spaces := K + witness := fun t ht => Classical.choose (hwitness t ht) + projection := fun t ht => Classical.choose_spec (hwitness t ht) }⟩ + exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hsum)) + (by positivity)).trans hdensity + +end Erdos3 + +end + +section + +namespace Erdos3 + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_native_common_rank_relation (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + Real.exp ((p + C) ^ C) ≤ N → + ∃ (out : Fin W.family.outputDim) (H : Finset (ZMod N)) (q : ℝ), + H ⊆ W.shifts ∧ H.Nonempty ∧ CyclicShortShiftSet H ∧ + Real.exp (-((p + C) ^ C)) * Fintype.card (ZMod N) ≤ (H.card : ℝ) ∧ + p ≤ q ∧ q ≤ (p + C) ^ C ∧ + ∃ R : NativeRankRelation W.family out H q q, + Nonempty (R.CommonData ((p + C) ^ C)) := by + obtain ⟨a, _, hrelation⟩ := exists_native_rank_relation s + obtain ⟨c, _, hcommon⟩ := exists_common_rank_relation s hs + obtain ⟨C, hC, hbudget⟩ := exists_native_common_rank_budget a c + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf hN + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + let q := p + (p + a) ^ a + 2 + have hpow : 0 ≤ (p + a) ^ a := by positivity + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have hbase : (p + a) ^ a ≤ q := by dsimp [q]; linarith + obtain ⟨hqC, hcommonC⟩ := hbudget p hp + obtain ⟨out, H, hHW, hH, hshort, hHsize, ⟨R⟩⟩ := hrelation W hf + let R' : NativeRankRelation W.family out H q q := R.mono hbase hbase + obtain ⟨D⟩ := hcommon hq hpq R' ((Real.exp_le_exp.mpr hcommonC).trans hN) + refine ⟨out, H, q, hHW, hH, hshort, ?_, hpq, hqC, R', ⟨D.mono hcommonC⟩⟩ + exact (mul_le_mul_of_nonneg_right + (Real.exp_le_exp.mpr (neg_le_neg (hbase.trans hqC))) (Nat.cast_nonneg _)).trans hHsize + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} + +theorem exists_bounded_coefficient_corrections (D : R.CommonData P) (hs : 1 ≤ s) (hP : 0 ≤ P) + (t : ZMod N × ZMod N × ZMod N) (ht : t ∈ D.quadruples) : + let I := R.interval ⟨t, D.subset ht⟩ + let V : I.SunflowerWitness P := D.witness t ht + ∃ E Q : ∀ α : Unit →₀ ℕ, + (W.rank.filtration.fourHorizontalLayer (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ, + (∀ α j, |(W.fourRankBasis.baseChange ℝ).repr (E α).val j| ≤ + Real.exp ((P + 3) ^ 2) / monomialScale (fun _ : Unit => (I.length : ℝ)) α) ∧ + (∀ α, (fun j => (W.fourRankBasis.baseChange ℝ).repr (Q α).val j) ∈ + realDenominatorGrid V.projectedDenominator) ∧ + ∀ (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s), + W.rank.filtration.realFourHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) + (V.projectedOrbitCoefficient α - E α - Q α) ∈ + (D.horizontal ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩).baseChange ℝ := by + intro I V + obtain ⟨E, Q, hE, hQ, hres⟩ := V.exists_bounded_coefficient_corrections hs hP + refine ⟨E, Q, hE, hQ, ?_⟩ + intro α hα + exact (congrArg (fun U => _ ∈ U.baseChange ℝ) + (D.horizontalImage_eq t ht ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩)).mp + (hres α) + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CommonRealDependentProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/CommonRealDependentProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c40af7afe2445ffdce251219ef845fbbdb20c1c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CommonRealDependentProjection.lean @@ -0,0 +1,133 @@ +import OAI.Combinatorics.Progressions.Estimates.BoundedNativeDependentApproximations + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {κ : Type*} [Fintype κ] {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + (d : Fin (s + 1)) (f : Basis κ ℚ (W.L ⧸ W.rank.filtration.layer d.val 2)) + +theorem coordinateSpace_first : + fourFirstProjection (D.coordinateSpace d f) = + (fourFirstProjection (D.horizontal d)).map (W.rank.filtration.higherHorizontalCoordinates d.val f) := + fourFirstProjection_map (W.rank.filtration.higherHorizontalCoordinates d.val f) (D.horizontal d) + +theorem coordinateSpace_sparse (S : Finset (Fin 4)) : + fourSparseFirstProjection (D.coordinateSpace d f) S = + (fourSparseFirstProjection (D.horizontal d) S).map + (W.rank.filtration.higherHorizontalCoordinates d.val f) := + fourSparseFirstProjection_map (W.rank.filtration.higherHorizontalCoordinates d.val f) + (W.rank.filtration.higherHorizontalCoordinates_injective d.val f) (D.horizontal d) S + +theorem coordinateSpace_dependent : + fourDependentProjection (D.coordinateSpace d f) = + (fourDependentProjection (D.horizontal d)).map + (W.rank.filtration.higherHorizontalCoordinates d.val f) := + fourDependentProjection_map (W.rank.filtration.higherHorizontalCoordinates d.val f) + (W.rank.filtration.higherHorizontalCoordinates_injective d.val f) (D.horizontal d) + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +namespace NativeDegreeRankFamily + +theorem nativeCoefficientCoordinates_eq_real + {ι κ : Type*} [Fintype ι] {s r N : ℕ} [NeZero N] {b : ℝ} + (W : NativeDegreeRankFamily s r (ZMod N) b) (hs : 1 ≤ s) + (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + (α : Unit →₀ ℕ) + (f : Basis ι ℚ (W.L ⧸ W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 2)) + (h : ZMod N) : + W.nativeCoefficientCoordinates hs c τ hG α f h = + W.rank.filtration.realHigherHorizontalCoordinates (Finsupp.weight (fun _ : Unit => 1) α) f + (W.horizontalCoefficient hs c τ hG α h) := by + funext i + exact (W.rank.filtration.realHigherHorizontalCoordinates_component + (Finsupp.weight (fun _ : Unit => 1) α) f (W.horizontalCoefficient hs c τ hG α h) i).symm + +end NativeDegreeRankFamily + +namespace NativeRankRelation.CommonData + +variable {ι κ : Type*} [Fintype ι] {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} + +theorem real_dependent_coordinateSpace_eq (D : R.CommonData P) (d : Fin (s + 1)) + (f : Basis ι ℚ (W.L ⧸ W.rank.filtration.layer d.val 2)) : + realRationalCoordinateSpan (fourDependentProjection (D.coordinateSpace d f)) = + ((fourDependentProjection (D.horizontal d)).baseChange ℝ).map + (W.rank.filtration.realHigherHorizontalCoordinates d.val f) := by + rw [D.coordinateSpace_dependent] + exact (W.rank.filtration.realHigherHorizontalCoordinates_image d.val f + (fourDependentProjection (D.horizontal d))).symm + +theorem exists_real_dependent_remainder (D : R.CommonData P) (d : Fin (s + 1)) + (f : Basis ι ℚ (W.L ⧸ W.rank.filtration.layer d.val 2)) + (x y : ℝ ⊗[ℚ] W.rank.filtration.HigherHorizontal d.val) (e u : ι → ℝ) + (hmem : W.rank.filtration.realHigherHorizontalCoordinates d.val f x - + W.rank.filtration.realHigherHorizontalCoordinates d.val f y - e - u ∈ + realRationalCoordinateSpan (fourDependentProjection (D.coordinateSpace d f))) : + ∃ z ∈ (fourDependentProjection (D.horizontal d)).baseChange ℝ, + W.rank.filtration.realHigherHorizontalCoordinates d.val f (x - y - z) = e + u := by + rw [D.real_dependent_coordinateSpace_eq d f] at hmem + obtain ⟨z, hz, hcoord⟩ := hmem + refine ⟨z, hz, ?_⟩ + rw [map_sub, map_sub, hcoord] + abel + +theorem exists_native_dependent_remainder (D : R.CommonData P) (hs : 1 ≤ s) + (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s) + (f : Basis ι ℚ (W.L ⧸ W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 2)) + (h h₀ : ZMod N) (e u : ι → ℝ) + (hmem : W.nativeCoefficientCoordinates hs c τ hG α f h - + W.nativeCoefficientCoordinates hs c τ hG α f h₀ - e - u ∈ + realRationalCoordinateSpan (fourDependentProjection + (D.coordinateSpace ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩ f))) : + ∃ z ∈ (fourDependentProjection + (D.horizontal ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩)).baseChange ℝ, + W.rank.filtration.realHigherHorizontalCoordinates (Finsupp.weight (fun _ : Unit => 1) α) f + (W.horizontalCoefficient hs c τ hG α h - W.horizontalCoefficient hs c τ hG α h₀ - z) = e + u := by + apply D.exists_real_dependent_remainder + ⟨Finsupp.weight (fun _ : Unit => 1) α, Nat.lt_succ_of_le hα⟩ f + (W.horizontalCoefficient hs c τ hG α h) (W.horizontalCoefficient hs c τ hG α h₀) e u + simpa only [W.nativeCoefficientCoordinates_eq_real hs c τ hG α f] using hmem + +end NativeRankRelation.CommonData + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ComparisonBasisBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/ComparisonBasisBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9431b23b7043a76993b252e187f626783391532f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ComparisonBasisBudget.lean @@ -0,0 +1,53 @@ +import Mathlib.Data.Nat.Factorial.BigOperators +import OAI.Combinatorics.Progressions.Estimates.RationalPowerHeight + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {σ : Type*} [Fintype σ] + +theorem multidegreeFactorial_mono {a b : σ → ℕ} (h : a ≤ b) : + multidegreeFactorial a ≤ multidegreeFactorial b := + Finset.prod_le_prod (fun i _ => Nat.factorial_le (h i)) + +theorem multidegreeFactorial_le_total (a : σ → ℕ) : + multidegreeFactorial a ≤ (∑ i, a i).factorial := + Nat.le_of_dvd (Nat.factorial_pos _) (Nat.prod_factorial_dvd_factorial_sum Finset.univ a) + +noncomputable def comparisonBasisHeight (bound : σ → ℕ) (p : ℝ) : ℕ := + ⌈Real.exp p⌉₊ * multidegreeFactorial bound + +def comparisonBasisBudget (t : ℕ) (p : ℝ) : ℝ := p + 1 + (t : ℝ) ^ 2 + +theorem comparisonBasisHeight_ge_ceil (bound : σ → ℕ) (p : ℝ) : + ⌈Real.exp p⌉₊ ≤ comparisonBasisHeight bound p := + Nat.le_mul_of_pos_right _ (multidegreeFactorial_pos bound) + +theorem comparisonBasisHeight_ge_factorial (bound : σ → ℕ) (p : ℝ) : + multidegreeFactorial bound ≤ comparisonBasisHeight bound p := + Nat.le_mul_of_pos_left _ (one_le_ceil_exp p) + +theorem comparisonBasisHeight_pos (bound : σ → ℕ) (p : ℝ) : + 0 < comparisonBasisHeight bound p := + (multidegreeFactorial_pos bound).trans_le (comparisonBasisHeight_ge_factorial bound p) + +theorem comparisonBasisHeight_le_exp (bound : σ → ℕ) {p : ℝ} (hp : 0 ≤ p) : + (comparisonBasisHeight bound p : ℝ) ≤ Real.exp (comparisonBasisBudget (∑ i, bound i) p) := by + have hf : (multidegreeFactorial bound : ℝ) ≤ Real.exp (((∑ i, bound i : ℕ) : ℝ) ^ 2) := by + exact (Nat.cast_le.mpr (multidegreeFactorial_le_total bound)).trans (factorial_le_exp_sq _) + rw [comparisonBasisHeight, Nat.cast_mul] + calc + _ ≤ Real.exp (p + 1) * Real.exp (((∑ i, bound i : ℕ) : ℝ) ^ 2) := + mul_le_mul (ceil_exp_le_exp_add_one hp) hf (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = _ := (Real.exp_add _ _).symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ComparisonChosenLayerBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/ComparisonChosenLayerBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c727d96df383da99bef83d3f2212998fd4a14cb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ComparisonChosenLayerBasis.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeSquarefreeCoefficientBases +import OAI.Combinatorics.Progressions.Estimates.SquarefreeLayerBases +import OAI.Combinatorics.Progressions.Estimates.SquarefreeStructureHeight + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open Module +open scoped BigOperators + +variable {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) + +abbrev SquarefreeBasisIndex := Σ a : SquarefreeIndex (ReplicatedIndex bound), + Fin (finrank ℚ (M.filtration.squarefreeCoefficientLayer (fun j : ReplicatedIndex bound => j.1) a)) + +noncomputable def squarefreeBasis (p : ℝ) : Basis M.SquarefreeBasisIndex ℚ + (M.filtration.SquarefreeAlgebra (fun j : ReplicatedIndex bound => j.1)) := + M.filtration.squarefreeBasis _ (M.squarefreeCoefficientBasis p) + +theorem squarefreeBasisIndex_card_le (p : ℝ) : + Fintype.card M.SquarefreeBasisIndex ≤ 2 ^ (∑ i, bound i) * d := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + rw [← finrank_eq_card_basis (M.squarefreeBasis p)] + simpa only [replicatedIndex_card, finrank_eq_card_basis D.basis, Fintype.card_fin] using + M.filtration.squarefreeAlgebra_finrank_le (fun j : ReplicatedIndex bound => j.1) + +theorem squarefreeCoefficientBasis_card_le (a : SquarefreeIndex (ReplicatedIndex bound)) : + finrank ℚ (M.filtration.squarefreeCoefficientLayer (fun j : ReplicatedIndex bound => j.1) a) ≤ d := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + simpa only [finrank_eq_card_basis D.basis, Fintype.card_fin] using + (M.filtration.squarefreeCoefficientLayer (fun j : ReplicatedIndex bound => j.1) a).finrank_le + +theorem squarefreeBasis_structure_height {p : ℝ} (hM : M.ComplexityLE p) + (i j k : M.SquarefreeBasisIndex) : + RationalHeightLE (lieStructureConstants (M.squarefreeBasis p) i j k) + (squarefreeStructureHeight d ⌈Real.exp p⌉₊) := by + have h := M.filtration.squarefreeBasis_structure_height + (fun j : ReplicatedIndex bound => j.1) (M.squarefreeCoefficientBasis p) D.basis + (one_le_ceil_exp p) (M.squarefreeCoefficientBasis_height hM) + (fun i j k => rationalHeightLE_ceil_exp (hM.1.2.2.1 i j k)) + (fun a => by simpa only [Fintype.card_fin] using M.squarefreeCoefficientBasis_card_le a) i j k + simp only [Fintype.card_fin] at h + exact h + +theorem squarefreeBasis_permute (p : ℝ) (e : Equiv.Perm (ReplicatedIndex bound)) + (he : ∀ j, (e j).1 = j.1) (j : M.SquarefreeBasisIndex) : + ∃ k, M.filtration.squarefreeBlockPermute (fun j : ReplicatedIndex bound => j.1) e he + (M.squarefreeBasis p j) = M.squarefreeBasis p k := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + exact M.filtration.squarefreeBasis_permute (fun j : ReplicatedIndex bound => j.1) + (chosenBoundedSubmoduleBasis D.basis ⌈Real.exp p⌉₊) e he j + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open Module + +variable {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) + +noncomputable def comparisonLayerBasis (p : ℝ) (a : σ → ℕ) : + Basis (Fin (finrank ℚ (M.filtration.layer a))) ℚ (M.filtration.layer a) := by + letI : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + exact chosenBoundedSubmoduleBasis D.basis ⌈Real.exp p⌉₊ _ + +theorem comparisonLayerBasis_height {p : ℝ} (hM : M.ComplexityLE p) + (a : σ → ℕ) (ha : a ≤ bound) (j k) : + RationalHeightLE (D.basis.repr (M.comparisonLayerBasis p a j).val k) ⌈Real.exp p⌉₊ := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + apply chosenBoundedSubmoduleBasis_height + obtain ⟨b, hb⟩ := M.exists_layer_basis a ha hM + exact ⟨b, fun j k => rationalHeightLE_ceil_exp (hb j k)⟩ + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ContainedKernelPhysicalDisplacement.lean b/lean/OAI/Combinatorics/Progressions/Linear/ContainedKernelPhysicalDisplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e772c4356a2e813a20a365fa1dd467d181b25f9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ContainedKernelPhysicalDisplacement.lean @@ -0,0 +1,548 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedNarrowSpatialCanonicalComparison + +namespace OAI + +section + +namespace Erdos3 +open BooleanCubeKernel +open scoped BigOperators Classical NNReal +variable {G X : Type*} [Fintype G] [Fintype X] + +noncomputable def fixedSpatialKernelMap (W L : ℝ) (z : Option G × X → ℝ) + (t : G → ℝ) : (Σ _ : X, Unit ⊕ Empty) → ℝ := + fun a => z (none, a.1) + (L / (1 + W)) * ∑ g, z (some g, a.1) * t g + +theorem fixedSpatialKernelMap_lipschitz (W L : ℝ) (z : Option G × X → ℝ) + (hz : ∀ g x, |z (some g, x)| ≤ 1) : + LipschitzWith ((Fintype.card G : ℝ≥0) * ‖L / (1 + W)‖₊) + (fixedSpatialKernelMap W L z) := by + apply LipschitzWith.of_dist_le_mul + intro t u + apply (dist_pi_le_iff (mul_nonneg (NNReal.coe_nonneg _) dist_nonneg)).mpr + intro a + change |(z (none, a.1) + _ * _) - (z (none, a.1) + _ * _)| ≤ _ + rw [add_sub_add_left_eq_sub, ← mul_sub, abs_mul] + have hsum : |(∑ g, z (some g, a.1) * t g) - ∑ g, z (some g, a.1) * u g| ≤ + (Fintype.card G : ℝ) * dist t u := by + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ g, |z (some g, a.1) * t g - z (some g, a.1) * u g| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _g : G, dist t u := by + apply Finset.sum_le_sum + intro g _ + rw [← mul_sub, abs_mul] + exact (mul_le_mul_of_nonneg_right (hz g a.1) (abs_nonneg _)).trans + (by simpa only [one_mul, Real.dist_eq] using dist_le_pi_dist t u g) + _ = _ := by simp + have h := mul_le_mul_of_nonneg_left hsum (abs_nonneg (L / (1 + W))) + simpa only [NNReal.coe_mul, NNReal.coe_natCast, coe_nnnorm, Real.norm_eq_abs, + mul_left_comm, mul_assoc] using h + +theorem fixedSpatialKernelMap_lipschitz_one {W L : ℝ} + (hW : 0 ≤ W) (hL : 0 ≤ L) (hsize : (Fintype.card G : ℝ) * L ≤ W) + (z : Option G × X → ℝ) (hz : ∀ g x, |z (some g, x)| ≤ 1) : + LipschitzWith 1 (fixedSpatialKernelMap W L z) := by + apply (fixedSpatialKernelMap_lipschitz W L z hz).weaken + change (Fintype.card G : ℝ) * ‖L / (1 + W)‖ ≤ 1 + rw [Real.norm_eq_abs, abs_of_nonneg (div_nonneg hL (by linarith))] + rw [← mul_div_assoc] + exact (div_le_one (by linarith : 0 < 1 + W)).mpr (by linarith) + +variable [DecidableEq G] + +omit [Fintype X] in +theorem fixedSpatialKernelMap_integer (s : Empty ↪ G) (root : G → ℤ) + (D : Matrix Empty G ℤ) {W L : ℝ} (hW : 0 ≤ W) (hL : L ≠ 0) + (z : Option G × X → ℝ) : + fixedSpatialKernelMap W L z (fun g => (root g : ℝ) / L) = + canonicalZeroSpatialInputMap s root D W L z := by + funext a + rcases a with ⟨x, a⟩ + cases a with + | inr e => exact Empty.elim e + | inl u => + cases u + rw [canonicalZeroSpatialInputMap_apply s root D W L hW] + unfold fixedSpatialKernelMap + simp only + congr 1 + rw [Finset.mul_sum, Finset.sum_div] + apply Finset.sum_congr rfl + intro g _ + field_simp + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators Classical +variable {G X T : Type*} [Fintype G] [Fintype X] [Fintype T] + +noncomputable def fixedSpatialKernelBlock (e : G ≃ X ⊕ (X ⊕ T)) + (W L : ℝ) (z : Option G × X → ℝ) (second : Bool) : Matrix X X ℝ := + fun x i => (L / (1 + W)) * z (some (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i)), x) + +noncomputable def fixedSpatialKernelRest (e : G ≃ X ⊕ (X ⊕ T)) + (W L : ℝ) (z : Option G × X → ℝ) (t : T → ℝ) : X → ℝ := + fun x => (L / (1 + W)) * ∑ j, z (some (e.symm (Sum.inr (Sum.inr j))), x) * t j + +omit [Fintype G] [Fintype X] in +theorem fixedSpatialKernelRest_measurable (e : G ≃ X ⊕ (X ⊕ T)) + (W L : ℝ) (z : Option G × X → ℝ) : + Measurable (fixedSpatialKernelRest e W L z) := by + unfold fixedSpatialKernelRest + fun_prop + +theorem fixedSpatialKernelMap_blocks (e : G ≃ X ⊕ (X ⊕ T)) + (W L : ℝ) (z : Option G × X → ℝ) + (u v : X → ℝ) (t : T → ℝ) (x : X) : + fixedSpatialKernelMap W L z ((Sum.elim u (Sum.elim v t)) ∘ e) ⟨x, Sum.inl ()⟩ = + z (none, x) + (fixedSpatialKernelBlock e W L z false).mulVec u x + + (fixedSpatialKernelBlock e W L z true).mulVec v x + + fixedSpatialKernelRest e W L z t x := by + unfold fixedSpatialKernelMap + rw [← e.symm.sum_comp] + simp only [Function.comp_apply, Equiv.apply_symm_apply, Fintype.sum_sum_type, + Sum.elim_inl, Sum.elim_inr] + unfold fixedSpatialKernelBlock fixedSpatialKernelRest Matrix.mulVec dotProduct + simp only [Bool.false_eq_true, ↓reduceIte, Finset.mul_sum] + simp only [mul_add, Finset.mul_sum, mul_assoc] + ring + +theorem fixedSpatialKernelMap_blocks_actual (e : G ≃ X ⊕ (X ⊕ T)) + (W L : ℝ) (z : Option G × X → ℝ) (t : G → ℝ) (x : X) : + fixedSpatialKernelMap W L z t ⟨x, Sum.inl ()⟩ = + z (none, x) + (fixedSpatialKernelBlock e W L z false).mulVec + (fun i => t (e.symm (Sum.inl i))) x + + (fixedSpatialKernelBlock e W L z true).mulVec + (fun i => t (e.symm (Sum.inr (Sum.inl i)))) x + + fixedSpatialKernelRest e W L z (fun j => t (e.symm (Sum.inr (Sum.inr j)))) x := by + convert fixedSpatialKernelMap_blocks e W L z + (fun i => t (e.symm (Sum.inl i))) (fun i => t (e.symm (Sum.inr (Sum.inl i)))) + (fun j => t (e.symm (Sum.inr (Sum.inr j)))) x using 1 + congr 1 + funext g + simp only [Function.comp_apply] + generalize he : e g = a + have hg := congrArg e.symm he + simp only [Equiv.symm_apply_apply] at hg + subst g + rcases a with i | (i | j) <;> rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators Classical NNReal + +theorem rectangularWeightIndices_normalized_norm_le + {K : Type*} [Fintype K] (V : K → ℝ) (hV : ∀ k, 0 < V k) + {z : K → ℤ} (hz : z ∈ rectangularWeightIndices 0 V 1) : + ‖fun k => (z k : ℝ) / V k‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro k + rw [Real.norm_eq_abs, abs_div, abs_of_pos (hV k), div_le_one (hV k)] + exact rectangularWeightIndices_zero_bound V hz k + +theorem selectedResidueSmoothPMF_normalized_norm_le + {K X : Type*} [Fintype K] [Fintype X] + (modulus : X → ℕ) (cells : Finset (ColumnResiduePattern K X modulus)) + (V : K × X → ℝ) (hV : ∀ k, 0 < V k) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus cells V z) + {z : K × X → ℤ} (hz : z ∈ (selectedResidueSmoothPMF modulus cells V hV hZ).support) : + ‖fun k => (z k : ℝ) / V k‖ ≤ 1 := by + apply rectangularWeightIndices_normalized_norm_le V hV + by_contra hn + have hpos := ENNReal.toReal_pos ((PMF.mem_support_iff _ _).mp hz) (PMF.apply_ne_top _ _) + have hzero : (selectedResidueSmoothPMF modulus cells V hV hZ z).toReal = 0 := by + rw [selectedResidueSmoothPMF_toReal, + selectedResidueSmoothWeight_zero_off modulus cells V hV z hn, zero_div] + exact hpos.ne' hzero + +variable {G N X : Type*} [Fintype G] [DecidableEq G] + [Fintype N] [DecidableEq N] [Fintype X] + +theorem fixedSpatialKernelMap_narrow_physical_dist + (root : G → ℤ) (principal : N → ℤ) {W L τ ξ : ℝ} + (hW : 0 ≤ W) (hL : L ≠ 0) (hξ : 0 < ξ) + (hbudget : (∑ k : G ⊕ N, |((Sum.elim root principal k : ℤ) : ℝ)|) ≤ W) + (box : X → ℕ) (z : Option (G ⊕ N) × X → ℤ) + (hz : ‖fun k => (z k : ℝ) / narrowTrimmedSpatialWidths W τ ξ box k‖ ≤ 1) : + dist (fun o : Σ _ : X, Unit ⊕ Empty => + (integerPhysicalSite (Sum.elim root principal) z o.1 : ℝ) / + (τ * (box o.1 : ℝ) / 8)) + (fixedSpatialKernelMap W L + ((fun k => (z k : ℝ) / narrowTrimmedSpatialWidths W τ ξ box k) ∘ + canonicalZeroSpatialKernelEmbedding G N X) + (fun g => (root g : ℝ) / L)) ≤ ξ := by + let s : Empty ↪ G := ⟨Empty.elim, fun e => Empty.elim e⟩ + let sf : Empty ↪ (G ⊕ N) := ⟨Empty.elim, fun e => Empty.elim e⟩ + let D : Matrix Empty G ℤ := fun e => Empty.elim e + let Df : Matrix Empty (G ⊕ N) ℤ := fun e => Empty.elim e + have hsite : canonicalZeroSpatialInputMap sf (Sum.elim root principal) Df W L + (canonicalZeroSpatialNarrowInput ξ + (fun k => (z k : ℝ) / narrowTrimmedSpatialWidths W τ ξ box k)) = + fun o : Σ _ : X, Unit ⊕ Empty => + (integerPhysicalSite (Sum.elim root principal) z o.1 : ℝ) / + (τ * (box o.1 : ℝ) / 8) := by + funext o + rcases o with ⟨x, a⟩ + cases a with + | inr e => exact Empty.elim e + | inl a => + cases a + exact canonicalZeroSpatialNarrowInputMap_physicalSite sf _ Df hW hξ.ne' L τ box z x + rw [fixedSpatialKernelMap_integer s root D hW hL, ← hsite, dist_eq_norm] + exact (canonicalZeroSpatialNarrowPrincipal_norm_le s sf root principal D Df W L + hW ξ hξ.le _ hz).trans (mul_le_of_le_one_right hξ.le + (canonicalZeroSpatialPrincipal_mass_ratio_le_one root principal W hW hbudget)) + +theorem fixedSpatialKernelMap_narrow_physical_test_error + (root : G → ℤ) (principal : N → ℤ) {W L τ ξ : ℝ} + (hW : 0 ≤ W) (hL : L ≠ 0) (hξ : 0 < ξ) + (hbudget : (∑ k : G ⊕ N, |((Sum.elim root principal k : ℤ) : ℝ)|) ≤ W) + (box : X → ℕ) (z : Option (G ⊕ N) × X → ℤ) + (hz : ‖fun k => (z k : ℝ) / narrowTrimmedSpatialWidths W τ ξ box k‖ ≤ 1) + {A : ℝ≥0} (φ : ((Σ _ : X, Unit ⊕ Empty) → ℝ) → ℂ) + (hφ : LipschitzWith A φ) : + ‖φ (fun o : Σ _ : X, Unit ⊕ Empty => + (integerPhysicalSite (Sum.elim root principal) z o.1 : ℝ) / + (τ * (box o.1 : ℝ) / 8)) - + φ (fixedSpatialKernelMap W L + ((fun k => (z k : ℝ) / narrowTrimmedSpatialWidths W τ ξ box k) ∘ + canonicalZeroSpatialKernelEmbedding G N X) + (fun g => (root g : ℝ) / L))‖ ≤ (A : ℝ) * ξ := by + rw [← dist_eq_norm] + exact (hφ.dist_le_mul _ _).trans (mul_le_mul_of_nonneg_left + (fixedSpatialKernelMap_narrow_physical_dist root principal hW hL hξ hbudget box z hz) + A.coe_nonneg) + +namespace VectorPolynomial + +variable {m : ℕ} {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "principal" => PrincipalTupleIndex B (layerSamplerDegree I n) +local notation "vars" => LayerSamplerVariables G I n B +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) + +theorem allocatedFixedSpatialKernelMap_narrow_physical_dist + (x : G → IntegerScalarCubeBox Empty S.value) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty (allocatedPrincipalSides B U basis S)) + {τ ξ : ℝ} (hξ : 0 < ξ) (box : X → ℕ) + (z : Option vars × X → ℤ) + (hz : ‖fun k => (z k : ℝ) / + narrowTrimmedSpatialWidths (G := G) (J := principal) budget τ ξ box k‖ ≤ 1) : + dist (fun o : Σ _ : X, Unit ⊕ Empty => + (integerPhysicalSite (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) z o.1 : ℝ) / + (τ * (box o.1 : ℝ) / 8)) + (fixedSpatialKernelMap budget (S.value : ℝ) + ((fun k => (z k : ℝ) / narrowTrimmedSpatialWidths budget τ ξ box k) ∘ + canonicalZeroSpatialKernelEmbedding G principal X) + (fun g => ((x g none : ℤ) : ℝ) / (S.value : ℝ))) ≤ ξ := by + have hr : allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y = + Sum.elim (fun g => (x g none : ℤ)) (fun j => (y j none : ℤ)) := by + funext k + simp only [allocatedPhysicalCubeRoot, zero_add] + have hbudget : (∑ k : vars, + |((Sum.elim (fun g => (x g none : ℤ)) (fun j => (y j none : ℤ)) k : ℤ) : ℝ)|) ≤ budget := by + simpa only [hr] using allocatedPhysicalCube_root_sum B U basis S (fun _ => 0) x y + rw [hr] + exact fixedSpatialKernelMap_narrow_physical_dist _ _ + (allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0)) + (Nat.cast_ne_zero.mpr S.positive.ne') hξ hbudget box z hz + +theorem allocatedFixedSpatialKernelMap_supported_narrow_physical_dist + (x : G → IntegerScalarCubeBox Empty S.value) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty (allocatedPrincipalSides B U basis S)) + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : 0 < ξ) (box : X → ℕ) (hbox : ∀ o, 0 < box o) + (z : Option vars × X → ℤ) + (hz : z ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths (G := G) (J := principal) budget τ ξ box) 1) : + dist (fun o : Σ _ : X, Unit ⊕ Empty => + (integerPhysicalSite (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) z o.1 : ℝ) / + (τ * (box o.1 : ℝ) / 8)) + (fixedSpatialKernelMap budget (S.value : ℝ) + ((fun k => (z k : ℝ) / narrowTrimmedSpatialWidths budget τ ξ box k) ∘ + canonicalZeroSpatialKernelEmbedding G principal X) + (fun g => ((x g none : ℤ) : ℝ) / (S.value : ℝ))) ≤ ξ := by + exact allocatedFixedSpatialKernelMap_narrow_physical_dist B U basis S x y hξ box z + (rectangularWeightIndices_normalized_norm_le _ + (narrowTrimmedSpatialWidths_pos + (allocatedPhysicalRootBudget_nonneg B U basis S (fun _ => 0)) hτ hξ box hbox) hz) + +theorem allocatedFixedSpatialKernelMap_supported_narrow_physical_test_error + (x : G → IntegerScalarCubeBox Empty S.value) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty (allocatedPrincipalSides B U basis S)) + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : 0 < ξ) (box : X → ℕ) (hbox : ∀ o, 0 < box o) + (z : Option vars × X → ℤ) + (hz : z ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths (G := G) (J := principal) budget τ ξ box) 1) + {A : ℝ≥0} (φ : ((Σ _ : X, Unit ⊕ Empty) → ℝ) → ℂ) + (hφ : LipschitzWith A φ) : + ‖φ (fun o : Σ _ : X, Unit ⊕ Empty => + (integerPhysicalSite (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) x y) z o.1 : ℝ) / + (τ * (box o.1 : ℝ) / 8)) - + φ (fixedSpatialKernelMap budget (S.value : ℝ) + ((fun k => (z k : ℝ) / narrowTrimmedSpatialWidths budget τ ξ box k) ∘ + canonicalZeroSpatialKernelEmbedding G principal X) + (fun g => ((x g none : ℤ) : ℝ) / (S.value : ℝ)))‖ ≤ (A : ℝ) * ξ := by + rw [← dist_eq_norm] + exact (hφ.dist_le_mul _ _).trans (mul_le_mul_of_nonneg_left + (allocatedFixedSpatialKernelMap_supported_narrow_physical_dist + B U basis S x y hτ hξ box hbox z hz) A.coe_nonneg) + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Classical + +variable {G X T : Type*} [Fintype G] [Fintype X] [Fintype T] + +def fixedSpatialKernelBlockCoordinates (e : G ≃ X ⊕ (X ⊕ T)) + (t : G → ℝ) : (T → ℝ) × ((X → ℝ) × (X → ℝ)) := + (fun j => t (e.symm (.inr (.inr j))), + (fun i => t (e.symm (.inl i)), fun i => t (e.symm (.inr (.inl i))))) + +theorem fixedSpatialKernelBlockCoordinates_measurePreserving (e : G ≃ X ⊕ (X ⊕ T)) : + MeasurePreserving (fixedSpatialKernelBlockCoordinates e) (unitBoxMeasure G) + ((unitBoxMeasure T).prod ((unitBoxMeasure X).prod (unitBoxMeasure X))) := by + let e' := e.trans (Equiv.sumAssoc X X T).symm + have hr := (unitBoxMeasure_sum (X ⊕ X) T).comp (unitBoxMeasure_reindex e') + have hp := ((unitBoxMeasure_sum X X).prod (MeasurePreserving.id (unitBoxMeasure T))).comp hr + have hs := (Measure.measurePreserving_swap + (μ := (unitBoxMeasure X).prod (unitBoxMeasure X)) (ν := unitBoxMeasure T)).comp hp + convert hs using 1 + funext t + ext j <;> simp [fixedSpatialKernelBlockCoordinates, e', + MeasurableEquiv.coe_piCongrLeft, MeasurableEquiv.coe_sumPiEquivProdPi, + Equiv.sumPiEquivProdPi, Equiv.piCongrLeft_apply_eq_cast] + +theorem fixedSpatialKernelBlockCoordinates_image_law (e : G ≃ X ⊕ (X ⊕ T)) : + (unitBoxMeasure G).map (fixedSpatialKernelBlockCoordinates e) = + (unitBoxMeasure T).prod ((unitBoxMeasure X).prod (unitBoxMeasure X)) := + (fixedSpatialKernelBlockCoordinates_measurePreserving e).map_eq + +variable [DecidableEq X] + +theorem fixedSpatialKernelMap_block_image_law (e : G ≃ X ⊕ (X ⊕ T)) + (W L : ℝ) (z : Option G × X → ℝ) + (A B : (X → ℝ) ≃L[ℝ] (X → ℝ)) + (hA : ∀ u, A u = (fixedSpatialKernelBlock e W L z false).mulVec u) + (hB : ∀ u, B u = (fixedSpatialKernelBlock e W L z true).mulVec u) : + (unitBoxMeasure G).map (fun t x => fixedSpatialKernelMap W L z t ⟨x, .inl ()⟩) = + realDensityMeasure volume (fixedSpatialBlockDensity (unitBoxMeasure T) + (fun x => z (none, x)) (fixedSpatialKernelRest e W L z) A B) := by + have h := fixedSpatialBlockDensity_image_law (unitBoxMeasure T) (fun x => z (none, x)) + (fixedSpatialKernelRest_measurable e W L z) A B + let F := fun p : (T → ℝ) × ((X → ℝ) × (X → ℝ)) => + (fun x => z (none, x)) + A p.2.1 + B p.2.2 + fixedSpatialKernelRest e W L z p.1 + have hF : Measurable F := by + exact ((measurable_const.add (A.continuous.measurable.comp (measurable_fst.comp measurable_snd))).add + (B.continuous.measurable.comp (measurable_snd.comp measurable_snd))).add + ((fixedSpatialKernelRest_measurable e W L z).comp measurable_fst) + change ((unitBoxMeasure T).prod ((unitBoxMeasure X).prod (unitBoxMeasure X))).map F = _ at h + rw [← fixedSpatialKernelBlockCoordinates_image_law e, + Measure.map_map hF (fixedSpatialKernelBlockCoordinates_measurePreserving e).measurable] at h + have he : F ∘ fixedSpatialKernelBlockCoordinates e = + fun t x => fixedSpatialKernelMap W L z t ⟨x, .inl ()⟩ := by + funext t x + simp only [Function.comp_apply, F, fixedSpatialKernelBlockCoordinates, Pi.add_apply, hA, hB] + exact (fixedSpatialKernelMap_blocks_actual e W L z t x).symm + rw [he] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {G X : Type*} [Fintype G] + +noncomputable def fixedSpatialKernelSliceFrame (W L : ℝ) + (z : Option G × X → ℝ) (lower width : G → ℝ) : Option G × X → ℝ := + fun a => match a.1 with + | none => z (none, a.2) + (L / (1 + W)) * ∑ g, z (some g, a.2) * lower g + | some g => width g * z (some g, a.2) + +@[simp] theorem fixedSpatialKernelSliceFrame_none (W L : ℝ) + (z : Option G × X → ℝ) (lower width : G → ℝ) (x : X) : + fixedSpatialKernelSliceFrame W L z lower width (none, x) = + z (none, x) + (L / (1 + W)) * ∑ g, z (some g, x) * lower g := rfl + +@[simp] theorem fixedSpatialKernelSliceFrame_some (W L : ℝ) + (z : Option G × X → ℝ) (lower width : G → ℝ) (g : G) (x : X) : + fixedSpatialKernelSliceFrame W L z lower width (some g, x) = + width g * z (some g, x) := rfl + +theorem fixedSpatialKernelMap_slice (W L : ℝ) + (z : Option G × X → ℝ) (lower width t : G → ℝ) : + fixedSpatialKernelMap W L (fixedSpatialKernelSliceFrame W L z lower width) t = + fixedSpatialKernelMap W L z (fun g => lower g + width g * t g) := by + funext a + simp only [fixedSpatialKernelMap, fixedSpatialKernelSliceFrame_none, + fixedSpatialKernelSliceFrame_some, mul_add, Finset.sum_add_distrib, + mul_assoc, mul_left_comm] + ring + +variable {T : Type*} [Fintype X] + +omit [Fintype X] in +theorem fixedSpatialKernelBlock_slice (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) + (z : Option G × X → ℝ) (lower width : G → ℝ) (second : Bool) : + fixedSpatialKernelBlock e W L (fixedSpatialKernelSliceFrame W L z lower width) second = + fun x i => fixedSpatialKernelBlock e W L z second x i * + width (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i)) := by + funext x i + simp only [fixedSpatialKernelBlock, fixedSpatialKernelSliceFrame_some] + ring + +theorem fixedSpatialKernelBlock_slice_det (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) + (z : Option G × X → ℝ) (lower width : G → ℝ) (second : Bool) : + (fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second).det = + (fixedSpatialKernelBlock e W L z second).det * + ∏ i, width (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i)) := by + have hmatrix : fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second = + fixedSpatialKernelBlock e W L z second * Matrix.diagonal + (fun i => width (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i))) := by + ext x i + simp only [Matrix.mul_diagonal, fixedSpatialKernelBlock, fixedSpatialKernelSliceFrame_some] + ring + rw [hmatrix, Matrix.det_mul, Matrix.det_diagonal] + +theorem fixedSpatialKernelBlock_slice_det_ne_zero + (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) + (z : Option G × X → ℝ) (lower width : G → ℝ) (second : Bool) + (hdet : (fixedSpatialKernelBlock e W L z second).det ≠ 0) + (hwidth : ∀ g, width g ≠ 0) : + (fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second).det ≠ 0 := by + rw [fixedSpatialKernelBlock_slice_det] + exact mul_ne_zero hdet (Finset.prod_ne_zero_iff.mpr (fun _ _ => hwidth _)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {G : Type*} [Fintype G] + +noncomputable def containedKernelCubeMap (S : ℕ) (H step : G → ℕ) (c : G → ℤ) + (hS : 0 < S) + (hsubset : ∀ g, integerProgressionSupport (c g) (step g : ℤ) (H g) ⊆ + Finset.Ico (0 : ℤ) (S : ℤ)) + (x : ∀ g, IntegerScalarCubeBox Empty (H g)) : G → IntegerScalarCubeBox Empty S := + fun g => containedProgressionCubeMap Empty S (H g) (step g) (c g) hS (hsubset g) (x g) + +theorem containedKernelCubeMap_value (S : ℕ) (H step : G → ℕ) (c : G → ℤ) + (hS : 0 < S) (hH : ∀ g, 0 < H g) + (hsubset : ∀ g, integerProgressionSupport (c g) (step g : ℤ) (H g) ⊆ + Finset.Ico (0 : ℤ) (S : ℤ)) + (x : ∀ g, IntegerScalarCubeBox Empty (H g)) + (hx : (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight x ≠ 0) + (g : G) : + (containedKernelCubeMap S H step c hS hsubset x g none : ℤ) = + c g + (step g : ℤ) * (x g none : ℤ) := by + have hpos := lt_of_le_of_ne ((FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).nonneg x) hx.symm + have hg := FiniteProbabilityWeights.pi_weight_pos_component + (fun g => integerScalarCubeWeights Empty (H g) (hH g)) x hpos g + have hcube := (mem_integerScalarCubeSet (H g) (x g)).mp + ((FiniteProbabilityWeights.condition_weight_pos_iff _ _ _ (x g)).mp hg).1 + simpa only [containedKernelCubeMap, ite_true] using + (containedProgressionCubeMap_value Empty S (H g) (step g) (c g) hS + (hsubset g) (x g) hcube none) + +theorem containedKernelCubeMap_normalized (S : ℕ) (H step : G → ℕ) (c : G → ℤ) + (hS : 0 < S) (hH : ∀ g, 0 < H g) + (hsubset : ∀ g, integerProgressionSupport (c g) (step g : ℤ) (H g) ⊆ + Finset.Ico (0 : ℤ) (S : ℤ)) + (x : ∀ g, IntegerScalarCubeBox Empty (H g)) + (hx : (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight x ≠ 0) : + (fun g => ((containedKernelCubeMap S H step c hS hsubset x g none : ℤ) : ℝ) / S) = + fun g => ((c g : ℝ) + (step g : ℝ) * (x g none : ℝ)) / S := by + funext g + rw [containedKernelCubeMap_value S H step c hS hH hsubset x hx g] + simp only [Int.cast_add, Int.cast_mul, Int.cast_natCast] + +namespace VectorPolynomial + +variable {m : ℕ} {X : Type*} [Fintype X] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "principal" => PrincipalTupleIndex B (layerSamplerDegree I n) +local notation "vars" => LayerSamplerVariables G I n B +local notation "budget" => allocatedPhysicalRootBudget B U basis S (fun _ => 0) + +theorem allocatedContainedKernel_supported_narrow_physical_dist + (H step : G → ℕ) (c : G → ℤ) (hH : ∀ g, 0 < H g) + (hsubset : ∀ g, integerProgressionSupport (c g) (step g : ℤ) (H g) ⊆ + Finset.Ico (0 : ℤ) (S.value : ℤ)) + (x : ∀ g, IntegerScalarCubeBox Empty (H g)) + (hx : (FiniteProbabilityWeights.pi + (fun g => integerScalarCubeWeights Empty (H g) (hH g))).weight x ≠ 0) + (y : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty (allocatedPrincipalSides B U basis S)) + {τ ξ : ℝ} (hτ : 0 < τ) (hξ : 0 < ξ) (box : X → ℕ) (hbox : ∀ o, 0 < box o) + (integerFrame : Option vars × X → ℤ) + (hframe : integerFrame ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths (G := G) (J := principal) budget τ ξ box) 1) : + dist (fun o : Σ _ : X, Unit ⊕ Empty => + (integerPhysicalSite (allocatedPhysicalCubeRoot B U basis S (fun _ => 0) + (containedKernelCubeMap S.value H step c S.positive hsubset x) y) integerFrame o.1 : ℝ) / + (τ * (box o.1 : ℝ) / 8)) + (fixedSpatialKernelMap budget (S.value : ℝ) + ((fun k => (integerFrame k : ℝ) / narrowTrimmedSpatialWidths budget τ ξ box k) ∘ + canonicalZeroSpatialKernelEmbedding G principal X) + (fun g => ((c g : ℝ) + (step g : ℝ) * (x g none : ℝ)) / S.value)) ≤ ξ := by + rw [← containedKernelCubeMap_normalized S.value H step c S.positive hH hsubset x hx] + exact allocatedFixedSpatialKernelMap_supported_narrow_physical_dist B U basis S + (containedKernelCubeMap S.value H step c S.positive hsubset x) y + hτ hξ box hbox integerFrame hframe + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ContainedSupportedProgressionKernels.lean b/lean/OAI/Combinatorics/Progressions/Linear/ContainedSupportedProgressionKernels.lean new file mode 100644 index 0000000000000000000000000000000000000000..b845a0dfe2b56732fe55628a18dbaa1a9f29b7c2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ContainedSupportedProgressionKernels.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.Progressions.Probability.ContainedSupportedProgressionJetLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable (h : D → ℕ) (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ t, 0 < L t) +variable (q : ℕ) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B h L hL).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +local notation "conditioned" => FiniteProbabilityWeights.condition + (principalTupleWeights B h L hL) + (Finset.univ.filter (fun y => principalResidueLabel q y = r)) hcell + +theorem principalSupportedResidue_selected_kernels {A : Type*} [Fintype A] + (e : A → D) (he : Function.Injective e) {Y : A → Type*} + [∀ a, Countable (Y a)] [∀ a, MeasurableSpace (Y a)] [∀ a, MeasurableSingletonClass (Y a)] + (k : ∀ a, (∀ b : B (e a), ∀ v : Fin (h (e a)), IntegerScalarCubeBox α (L ⟨e a, b, v⟩)) → + PMF (Y a)) : + (conditioned).toPMF.bind (fun y => dependentProductPMF + (fun a => k a (fun b v => y ⟨e a, b, v⟩))) = + dependentProductPMF (fun a => (conditioned).toPMF.bind + (fun y => k a (fun b v => y ⟨e a, b, v⟩))) := by + exact pmf_bind_of_finite_independent_coordinates (conditioned).toPMF + (fun y a b v => y ⟨e a, b, v⟩) + (fun a => principalSupportedAxisTuplePMF B h L hL q r hcell (e a)) + (principalSupportedResidue_selected_axis_law B h L hL q r hcell e he) k + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {D α : Type*} [Fintype D] [DecidableEq D] [Fintype α] [DecidableEq α] +variable (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] (h : D → ℕ) +variable (L H step : PrincipalTupleIndex B h → ℕ) (c : PrincipalTupleIndex B h → ℤ) +variable (hL : ∀ j, 0 < L j) (hH : ∀ j, 0 < H j) +variable (hsubset : ∀ j, integerProgressionSupport (c j) (step j : ℤ) (H j) ⊆ + Finset.Ico (0 : ℤ) (L j : ℤ)) +variable (q : ℕ) (hq : 0 < q) (r : PrincipalTupleIndex B h → Option α → ZMod q) +variable (hcell : 0 < (principalTupleWeights (α := α) B h H hH).mass + (Finset.univ.filter (fun y => principalResidueLabel q y = r))) + +local notation "law" => containedSupportedProgressionLaw B h L H step c hL hH hsubset q r hcell + +theorem containedSupportedProgressionLaw_selected_kernels {A : Type*} [Fintype A] + (e : A → D) (he : Function.Injective e) {Y : A → Type*} + [∀ a, Countable (Y a)] [∀ a, MeasurableSpace (Y a)] [∀ a, MeasurableSingletonClass (Y a)] + (k : ∀ a, (∀ b : B (e a), ∀ v : Fin (h (e a)), IntegerScalarCubeBox α (L ⟨e a,b,v⟩)) → PMF (Y a)) : + (law).toPMF.bind (fun y => dependentProductPMF (fun a => k a (fun b v => y ⟨e a,b,v⟩))) = + dependentProductPMF (fun a => (law).toPMF.bind (fun y => k a (fun b v => y ⟨e a,b,v⟩))) := by + simp only [containedSupportedProgressionLaw, FiniteProbabilityWeights.toPMF_fiberLaw, PMF.bind_map] + exact principalSupportedResidue_selected_kernels B h H hH q r hcell e he + (fun a y => k a (fun b v => containedProgressionCubeMap α (L ⟨e a,b,v⟩) (H ⟨e a,b,v⟩) + (step ⟨e a,b,v⟩) (c ⟨e a,b,v⟩) (hL _) (hsubset _) (y b v))) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ControlledKernelSplitTransport.lean b/lean/OAI/Combinatorics/Progressions/Linear/ControlledKernelSplitTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..784ef3d38fe6d99466ccb9443ced2c58a5b04857 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ControlledKernelSplitTransport.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.RealSubspaceIntersectionCorrections + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_controlled_kernel_split_equiv {H ι κ ν τ : Type*} + [AddCommGroup H] [Module ℝ H] [Fintype ι] [Fintype κ] [Fintype ν] + (e : H ≃ₗ[ℝ] (ι → ℝ)) (U K : Submodule ℝ H) + (A : Matrix ι κ ℚ) (B : Matrix ι ν ℚ) + (hAspan : Submodule.span ℝ (Set.range (A.map (Rat.castHom ℝ)).col) = U.map e.toLinearMap) + (hBspan : Submodule.span ℝ (Set.range (B.map (Rat.castHom ℝ)).col) = K.map e.toLinearMap) + (b : ν → K) (hb : ∀ j, e (b j).val = (B.map (Rat.castHom ℝ)).col j) + (R : K →ₗ[ℝ] (τ → ℝ)) (n : ℕ) (hR : ∀ j, R (b j) ∈ realDenominatorGrid n) + {J l : ℕ} (hJ : 1 ≤ J) (hl : 0 < l) + (hA : ∀ i j, RationalHeightLE (A i j) J) (hB : ∀ i j, RationalHeightLE (B i j) J) + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hcols : (Fintype.card (κ ⊕ ν) : ℝ) ≤ p) + (hJp : (J : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p) : + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + 2) ^ 36) ∧ + ∃ split : H →ₗ[ℝ] K, + (∀ x, x ∈ U ⊔ K → x - (split x).val ∈ U) ∧ + (∀ x, ‖e (split x).val‖ ≤ Real.exp ((p + 2) ^ 19) * ‖e x‖) ∧ + ∀ x, e x ∈ realDenominatorGrid l → R (split x) ∈ realDenominatorGrid (n * m) := by + let eK : K ≃ₗ[ℝ] K.map e.toLinearMap := e.submoduleMap K + let R' := R.comp eK.symm.toLinearMap + have hb' : ∀ j, (eK (b j)).val = (B.map (Rat.castHom ℝ)).col j := hb + have hR' : ∀ j, R' (eK (b j)) ∈ realDenominatorGrid n := by + intro j + simpa only [R', LinearMap.comp_apply, LinearEquiv.coe_toLinearMap, + LinearEquiv.symm_apply_apply] using hR j + obtain ⟨m, hm, hmp, split', hsplit', hnorm, hgrid⟩ := + exists_controlled_kernel_split (U.map e.toLinearMap) (K.map e.toLinearMap) + A B hAspan hBspan (fun j => eK (b j)) hb' R' n hR' hJ hl hA hB hp hι hcols hJp hlp + let split : H →ₗ[ℝ] K := eK.symm.toLinearMap.comp (split'.comp e.toLinearMap) + have hsplit (x : H) : e (split x).val = (split' (e x)).val := + congrArg Subtype.val (eK.apply_symm_apply (split' (e x))) + refine ⟨m, hm, hmp, split, ?_, ?_, ?_⟩ + · intro x hx + have hex : e x ∈ U.map e.toLinearMap ⊔ K.map e.toLinearMap := by + rw [← Submodule.map_sup] + exact ⟨x, hx, rfl⟩ + have hmem : e (x - (split x).val) ∈ U.map e.toLinearMap := by + rw [map_sub, hsplit] + exact hsplit' (e x) hex + simpa only [Submodule.mem_map_equiv, LinearEquiv.symm_apply_apply] using hmem + · intro x + rw [hsplit] + exact hnorm (e x) + · intro x hx + exact hgrid (e x) hx + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ControlledMarkedKernelNormalization.lean b/lean/OAI/Combinatorics/Progressions/Linear/ControlledMarkedKernelNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..a225f47645be0f78efe71fdc00840cebdc69c75a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ControlledMarkedKernelNormalization.lean @@ -0,0 +1,291 @@ +import OAI.Combinatorics.Progressions.Polynomial.PrescribedFastPolynomialFactorization + +namespace OAI + +section + +namespace Erdos3 + +theorem kernel_normalization_parameter_le {p : ℝ} (hp : 0 ≤ p) : + p ≤ (p + 2) ^ 4 := + le_power_budget hp (by decide) + +theorem kernel_inclusion_height_mul_le_exp (n k H l : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (hk : (k : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hl : (l : ℝ) ≤ Real.exp p) : + ((H ^ (n * k) * l : ℕ) : ℝ) ≤ Real.exp ((p + 2) ^ 4) := by + have hpow := pow_le_pow_left₀ (Nat.cast_nonneg H) hH (n * k) + rw [← Real.exp_nat_mul] at hpow + have hprod : ((n * k : ℕ) : ℝ) * p ≤ (p + 2) ^ 3 := by + rw [Nat.cast_mul, show (3 : ℕ) = 2 + 1 by decide, pow_succ, pow_two] + gcongr <;> linarith + have hlog : ((n * k : ℕ) : ℝ) * p + p ≤ (p + 2) ^ 4 := by + calc + _ ≤ 2 * (p + 2) ^ 3 := by + linarith [le_power_budget hp (by decide : 1 ≤ 3)] + _ ≤ (p + 2) * (p + 2) ^ 3 := + mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = _ := by ring + rw [Nat.cast_mul, Nat.cast_pow] + calc + _ ≤ Real.exp (((n * k : ℕ) : ℝ) * p) * Real.exp p := + mul_le_mul hpow hl (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = Real.exp (((n * k : ℕ) : ℝ) * p + p) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr hlog + +theorem kernel_inclusion_denominator_mul_le_exp (n k H q l : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (hk : (k : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hq : q ≤ H ^ (n * k)) + (hl : (l : ℝ) ≤ Real.exp p) : + ((q * l : ℕ) : ℝ) ≤ Real.exp ((p + 2) ^ 4) := by + have hql : ((q * l : ℕ) : ℝ) ≤ ((H ^ (n * k) * l : ℕ) : ℝ) := + Nat.cast_le.mpr (Nat.mul_le_mul_right l hq) + exact hql.trans (kernel_inclusion_height_mul_le_exp n k H l hp hn hk hH hl) + +theorem kernel_coordinate_factor_le_exp (k H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hk : (k : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + (k : ℝ) * H ≤ Real.exp ((p + 2) ^ 2) := by + have hkexp : (k : ℝ) ≤ Real.exp p := + hk.trans (by linarith [Real.add_one_le_exp p]) + calc + _ ≤ Real.exp p * Real.exp p := + mul_le_mul hkexp hH (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = Real.exp (p + p) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith [sq_nonneg p]) + +theorem kernel_coordinate_succ_factor_le_exp (k H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hk : (k : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + ((k : ℝ) + 1) * (H + 1) ≤ Real.exp ((p + 2) ^ 2) := by + have hkexp : (k : ℝ) + 1 ≤ Real.exp p := + (add_le_add hk (le_refl (1 : ℝ))).trans (Real.add_one_le_exp p) + have hHexp : (H : ℝ) + 1 ≤ Real.exp (p + 1) := by + have hone : 1 ≤ Real.exp p := Real.one_le_exp_iff.mpr hp + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ ≤ Real.exp p * 2 := by linarith + _ ≤ Real.exp p * Real.exp 1 := mul_le_mul_of_nonneg_left htwo (Real.exp_nonneg _) + _ = _ := (Real.exp_add _ _).symm + calc + _ ≤ Real.exp p * Real.exp (p + 1) := + mul_le_mul hkexp hHexp (by positivity) (Real.exp_nonneg _) + _ = Real.exp (p + (p + 1)) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith [sq_nonneg p]) + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι κ L M : Type*} [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (w : σ → ℕ) + +@[simp] theorem realPolynomialSymbolHom_constant (g : F.realification.Group) : + F.realPolynomialSymbolHom b ω hF w + (F.realification.adaptedConstantGroupHom w g) = 1 := by + apply NilpotentLieBCHGroup.ext + change F.realPolynomialSymbolMap b ω hF w _ = 0 + rw [F.realPolynomialSymbolMap_eq_zero_iff] + exact F.realification.polynomialSymbolMap_constant w g.coord + +theorem exists_marked_kernel_normalized_factors + (H : Submodule ℚ L) (hH : F.layer 2 ≤ H) + (bk : Basis κ ℚ (LinearMap.ker φ.toLinearMap)) + (e p r : (F.realification.adaptedPolynomialFiltration w).Group) + (hp : realificationLieHom φ + (coefficients (p.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0) ∈ + (H.map φ.toLinearMap).baseChange ℝ) : + ∃ (a : ℝ ⊗[ℚ] LinearMap.ker φ.toLinearMap) + (c : LinearMap.ker φ.toLinearMap) + (e' p' r' : (F.realification.adaptedPolynomialFiltration w).Group), + (∀ i, 0 ≤ (bk.baseChange ℝ).repr a i ∧ (bk.baseChange ℝ).repr a i < 1) ∧ + (∀ i, ∃ z : ℤ, bk.repr c i = z) ∧ + e' = e * F.realification.adaptedConstantGroupHom w + ⟨(LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ a⟩ ∧ + r' = F.realification.adaptedConstantGroupHom w ⟨(1 : ℝ) ⊗ₜ[ℚ] (c : L)⟩ * r ∧ + e' * p' * r' = e * p * r ∧ + F.realPolynomialSymbolHom b ω hF w e' = F.realPolynomialSymbolHom b ω hF w e ∧ + F.realPolynomialSymbolHom b ω hF w p' = F.realPolynomialSymbolHom b ω hF w p ∧ + F.realPolynomialSymbolHom b ω hF w r' = F.realPolynomialSymbolHom b ω hF w r ∧ + F.realPolynomialGroupMap G φ hφ w e' = F.realPolynomialGroupMap G φ hφ w e ∧ + F.realPolynomialGroupMap G φ hφ w p' = F.realPolynomialGroupMap G φ hφ w p ∧ + F.realPolynomialGroupMap G φ hφ w r' = F.realPolynomialGroupMap G φ hφ w r ∧ + coefficients (p'.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 ∈ H.baseChange ℝ := by + obtain ⟨a, c, ha, hc, hka, hkc, hmid⟩ := + F.exists_kernel_constant_factors G φ H hH bk + (F.realification.adaptedPolynomialConstantHom w p) + (by simpa only [F.realification.adaptedPolynomialConstantHom_coord] using hp) + let ka : F.realification.Group := ⟨(LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ a⟩ + let kc : F.realification.Group := ⟨(1 : ℝ) ⊗ₜ[ℚ] (c : L)⟩ + let C := F.realification.adaptedConstantGroupHom w + let p' := (C ka)⁻¹ * p * (C kc)⁻¹ + have hma : F.realPolynomialGroupMap G φ hφ w (C ka) = 1 := by + rw [F.realPolynomialGroupMap_constant, hka, map_one] + have hmc : F.realPolynomialGroupMap G φ hφ w (C kc) = 1 := by + rw [F.realPolynomialGroupMap_constant, hkc, map_one] + refine ⟨a, c, e * C ka, p', C kc * r, ha, hc, rfl, rfl, ?_, ?_, ?_, ?_, + ?_, ?_, ?_, ?_⟩ + · dsimp only [p']; group + · simp only [map_mul, C, F.realPolynomialSymbolHom_constant, mul_one] + · simp only [p', map_mul, map_inv, C, F.realPolynomialSymbolHom_constant, + inv_one, one_mul, mul_one] + · simp only [map_mul, C, F.realPolynomialSymbolHom_constant, one_mul] + · rw [map_mul, hma, mul_one] + · simp only [p', map_mul, map_inv, hma, hmc, inv_one, one_mul, mul_one] + · rw [map_mul, hmc, one_mul] + · rw [← F.realification.adaptedPolynomialConstantHom_coord] + simpa only [p', map_mul, map_inv, C, + F.realification.adaptedPolynomialConstantHom_constant] using hmid + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +theorem exists_controlled_marked_kernel_normalization (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {σ ι κ L M : Type*} [Fintype σ] [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {t : ℕ} (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (w : σ → ℕ), (∀ i, 0 < w i) → + ∀ (bk : Basis κ ℚ (LinearMap.ker φ.toLinearMap)) + (H l : ℕ) (p : ℝ), 1 ≤ H → 0 < l → 0 ≤ p → + (Fintype.card ι : ℝ) ≤ p → (Fintype.card κ : ℝ) ≤ p → + (Fintype.card σ : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (b.repr ⁅b i, b j⁆ k) H) → + (∀ i j, RationalHeightLE (b.repr (bk j : L) i) H) → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + ∀ (S : Submodule ℚ L), F.layer 2 ≤ S → + ∀ (T : σ → ℝ), (∀ i, 0 < T i) → + ∀ e middle r : (F.realification.adaptedPolynomialFiltration w).Group, + F.PolynomialSlowBound b w T (Real.exp ((p + 2) ^ a)) e → + F.PolynomialRationalGrid b w l r → + realificationLieHom φ + (coefficients (middle.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0) ∈ + (S.map φ.toLinearMap).baseChange ℝ → + ∃ (u : ℝ ⊗[ℚ] LinearMap.ker φ.toLinearMap) + (v : LinearMap.ker φ.toLinearMap) + (e' middle' r' : (F.realification.adaptedPolynomialFiltration w).Group), + (∀ i, 0 ≤ (bk.baseChange ℝ).repr u i ∧ (bk.baseChange ℝ).repr u i < 1) ∧ + (∀ i, ∃ z : ℤ, bk.repr v i = z) ∧ + e' = e * F.realification.adaptedConstantGroupHom w + ⟨(LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ u⟩ ∧ + r' = F.realification.adaptedConstantGroupHom w ⟨(1 : ℝ) ⊗ₜ[ℚ] (v : L)⟩ * r ∧ + e' * middle' * r' = e * middle * r ∧ + F.realPolynomialSymbolHom b ω hF w e' = F.realPolynomialSymbolHom b ω hF w e ∧ + F.realPolynomialSymbolHom b ω hF w middle' = + F.realPolynomialSymbolHom b ω hF w middle ∧ + F.realPolynomialSymbolHom b ω hF w r' = F.realPolynomialSymbolHom b ω hF w r ∧ + F.realPolynomialGroupMap G φ hφ w e' = F.realPolynomialGroupMap G φ hφ w e ∧ + F.realPolynomialGroupMap G φ hφ w middle' = + F.realPolynomialGroupMap G φ hφ w middle ∧ + F.realPolynomialGroupMap G φ hφ w r' = F.realPolynomialGroupMap G φ hφ w r ∧ + coefficients (middle'.coord : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) 0 ∈ + S.baseChange ℝ ∧ + F.PolynomialSlowBound b w T (Real.exp ((p + C) ^ C)) e' ∧ + F.PolynomialRationalGrid b w m r' := by + obtain ⟨ce, _, hslow⟩ := exists_polynomial_slow_product_bound s 1 2 + obtain ⟨cr, _, hrational⟩ := exists_polynomial_rational_product_bound s 2 + let Q : Polynomial ℕ := (Polynomial.X + 2) ^ a + (Polynomial.X + 2) ^ 4 + let B : Polynomial ℕ := (Q + Polynomial.C ce) ^ ce + (Q + Polynomial.C cr) ^ cr + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget B + refine ⟨C, hC, ?_⟩ + intro σ ι κ L M _ _ _ _ _ _ _ t F G φ hφ b ω hF w hw bk H l p hH hl hp + hι hκ hσ hHp hlp hbracket hkernel + obtain ⟨q, hq, hqbound, hkb, hkg⟩ := exists_basis_image_bounds_of_height b bk + (LinearMap.ker φ.toLinearMap).subtype H hkernel + let P : ℝ := (p + 2) ^ a + (p + 2) ^ 4 + have hP : 0 ≤ P := by dsimp [P]; positivity + have hp4 : p ≤ (p + 2) ^ 4 := by + apply (show p ≤ p + 2 by linarith).trans + simpa only [pow_one] using + pow_le_pow_right₀ (show (1 : ℝ) ≤ p + 2 by linarith) (show 1 ≤ 4 by omega) + have hpP : p ≤ P := hp4.trans (le_add_of_nonneg_left (by positivity)) + have hden : ((q * l : ℕ) : ℝ) ≤ Real.exp P := + (kernel_inclusion_denominator_mul_le_exp (Fintype.card ι) (Fintype.card κ) + H q l hp hι hκ hHp hqbound hlp).trans + (Real.exp_le_exp.mpr (le_add_of_nonneg_left (by positivity))) + have hbudgetP : (P + ce) ^ ce + (P + cr) ^ cr ≤ (p + C) ^ C := by + simpa [B, Q, P, Polynomial.eval₂_pow] using hbudget p hp + have heBudget : (P + ce) ^ ce ≤ (p + C) ^ C := + (le_add_of_nonneg_right (by positivity)).trans hbudgetP + have hrBudget : (P + cr) ^ cr ≤ (p + C) ^ C := + (le_add_of_nonneg_left (by positivity)).trans hbudgetP + obtain ⟨m, hm, hmp, hqlm, hprod⟩ := hrational F b ω hF w hw H P hH hP + (hι.trans hpP) (hσ.trans hpP) (hHp.trans (Real.exp_le_exp.mpr hpP)) hbracket + (q * l) (Nat.mul_pos hq hl) hden + refine ⟨m, hm, hmp.trans (Real.exp_le_exp.mpr hrBudget), + (dvd_mul_left l q).trans hqlm, ?_⟩ + intro S hS T hT e middle r he hr hmiddle + obtain ⟨u, v, e', middle', r', hu, hv, he', hr', hproduct, hsymE, hsymP, hsymR, + hmarkE, hmarkP, hmarkR, hconstant⟩ := + F.exists_marked_kernel_normalized_factors G φ hφ b ω hF w S hS bk + e middle r hmiddle + refine ⟨u, v, e', middle', r', hu, hv, he', hr', hproduct, hsymE, hsymP, hsymR, + hmarkE, hmarkP, hmarkR, hconstant, ?_, ?_⟩ + · let ku : F.realification.Group := + ⟨(LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ u⟩ + have hku : ∀ i, |(b.baseChange ℝ).repr ku.coord i| ≤ Real.exp (P + 2) := by + intro i + have hcoord := scalarExtension_fractional_coordinates_bound b bk + (LinearMap.ker φ.toLinearMap).subtype H hkb u hu i + have hfactor := kernel_coordinate_factor_le_exp (Fintype.card κ) H hp hκ hHp + have h24 : (p + 2) ^ 2 ≤ (p + 2) ^ 4 := + pow_le_pow_right₀ (by linarith) (by omega) + exact hcoord.trans (hfactor.trans (Real.exp_le_exp.mpr + (h24.trans (by dsimp [P]; have := pow_nonneg (by linarith : 0 ≤ p + 2) a; linarith)))) + have hcs := F.polynomialSlowBound_constant b w T hT (Real.exp_nonneg _) ku hku + have hes := F.polynomialSlowBound_mono b w T hT + (Real.exp_le_exp.mpr (show (p + 2) ^ a ≤ P + 2 by + dsimp [P]; have := pow_nonneg (by linarith : 0 ≤ p + 2) 4; linarith)) e he + have hout := hslow F b ω hF w hw H P hH hP (hι.trans hpP) (hσ.trans hpP) + (hHp.trans (Real.exp_le_exp.mpr hpP)) hbracket T hT + [e, F.realification.adaptedConstantGroupHom w ku] (by simp) + (by + intro z hz + simp only [List.mem_cons, List.not_mem_nil, or_false] at hz + rcases hz with rfl | rfl + · simpa only [pow_one] using hes + · simpa only [pow_one] using hcs) + have hout' : F.PolynomialSlowBound b w T (Real.exp ((P + ce) ^ ce)) e' := by + simpa only [List.prod_cons, List.prod_nil, mul_one, ← he', ku] using hout + exact F.polynomialSlowBound_mono b w T hT (Real.exp_le_exp.mpr heBudget) e' hout' + · let kv : F.realification.Group := ⟨(1 : ℝ) ⊗ₜ[ℚ] (v : L)⟩ + have hkv := integral_basis_image_realDenominatorGrid b bk + (LinearMap.ker φ.toLinearMap).subtype q hkg v hv + have hcs := F.polynomialRationalGrid_constant b w q kv hkv + have hcs' := F.polynomialRationalGrid_of_dvd b w hq (dvd_mul_right q l) _ hcs + have hrs := F.polynomialRationalGrid_of_dvd b w hl (dvd_mul_left l q) r hr + have hout := hprod [F.realification.adaptedConstantGroupHom w kv, r] (by simp) + (by + intro z hz + simp only [List.mem_cons, List.not_mem_nil, or_false] at hz + rcases hz with rfl | rfl + · exact hcs' + · exact hrs) + simpa only [List.prod_cons, List.prod_nil, mul_one, ← hr', kv] using hout + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ControlledProjectionUniformBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/ControlledProjectionUniformBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..50d82d36c5d43fac505b91e6332217538ab3805b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ControlledProjectionUniformBudget.lean @@ -0,0 +1,592 @@ +import OAI.Combinatorics.Progressions.Estimates.JoinedPairQuotientRefiltration +import OAI.Combinatorics.Progressions.Linear.ActualOrdinaryPointwiseSpanning +import OAI.Combinatorics.Progressions.Polynomial.ProductPolynomialMaps + +namespace OAI + +universe u + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem realificationLieSubalgebra_comap {L M : Type*} + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + (U : LieSubalgebra ℚ M) (φ : L →ₗ⁅ℚ⁆ M) : + realificationLieSubalgebra (U.comap φ) = + (realificationLieSubalgebra U).comap (realificationLieHom φ) := by + apply LieSubalgebra.toSubmodule_injective + exact realification_comap U.toSubmodule φ.toLinearMap + +namespace NilpotentLieFiltration + +variable {σ ι κ L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (f : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (f '' {i | j ≤ ν i})) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +noncomputable def realSymbolProjection (w : σ → ℕ) : + F.RealPolynomialSymbolGroup w →* G.RealPolynomialSymbolGroup w := + NilpotentLieBCHGroup.realificationMap + (hnil := F.polynomialSymbol_lowerCentralSeries_eq_bot w) + (hM := G.polynomialSymbol_lowerCentralSeries_eq_bot w) + (F.filteredPolynomialSymbolMap G φ hφ w) + +theorem exists_symbolFactorizationIn_projection_pullback + [Fintype (SymbolBasisIndex (fun _ : σ => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : σ => 1) ν)] + (hsurj : ∀ j, ∀ y ∈ G.layer j, ∃ x ∈ F.layer j, φ x = y) + {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l) + (hentries : ∀ i j, RationalHeightLE (f.repr (φ (e j)) i) H) + {p : ℝ} (hp : 0 ≤ p) + (hrows : (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω ⊕ + SymbolBasisIndex (fun _ : σ => 1) ν) : ℝ) ≤ p) + (hcols : ((Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) * + Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) : ℕ) : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, 0 < T i) + (X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)) + (U : LieSubalgebra ℚ G.AssociatedGraded) + (hfactor : G.SymbolFactorizationIn f ν hG T + (F.realSymbolProjection G φ hφ (fun _ => 1) X) p l U) : + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp (((p + 2) ^ 10 + 2) ^ 36) ∧ l ∣ m ∧ + F.SymbolFactorizationIn e ω hF T X (((p + 2) ^ 10 + 2) ^ 18 + p) m + (U.comap (F.associatedGradedMap G φ hφ)) := by + classical + let w : σ → ℕ := fun _ => 1 + let B := F.polynomialSymbolBasis e ω hF w + let C := G.polynomialSymbolBasis f ν hG w + let ψ := F.filteredPolynomialSymbolMap G φ hφ w + have hψ : Function.Surjective ψ := + F.filteredPolynomialSymbolMap_surjective G φ hφ w hsurj + have himage : (⊤ : LieSubalgebra ℚ (F.PolynomialSymbol w)).map ψ = ⊤ := by + ext y + constructor + · intro _; trivial + · intro _ + obtain ⟨x, rfl⟩ := hψ y + exact ⟨x, trivial, rfl⟩ + have hb : ∀ j i, RationalHeightLE (B.repr (B j) i) H := by + intro j i + simp only [Basis.repr_self, Finsupp.single_apply] + split_ifs + · exact rationalHeightLE_one hH + · exact rationalHeightLE_zero hH + obtain ⟨S, m, hm, hmp, hlm, hsolve, hslow, hgrid⟩ := + NilpotentLieBCHGroup.exists_controlled_fast_lift + (F.polynomialSymbol_lowerCentralSeries_eq_bot w) + (G.polynomialSymbol_lowerCentralSeries_eq_bot w) B C + (fun z => z.val.1) (fun z => z.val.1) ⊤ B B.span_eq + (fun _ _ _ => trivial) ψ + (fun i j hij => F.filteredPolynomialSymbolMap_monomial_blocks + G e ω hF f ν hG φ hφ w j i hij) + hH hl hb + (fun i j => F.filteredPolynomialSymbolMap_basis_height + G e ω hF f ν hG φ hφ w hH hentries j i) + hp hrows hcols hHp hlp + simp only [Basis.equivFun_apply] at hslow hgrid + let lift := NilpotentLieBCHGroup.realLinearCoordinateLift + (hL := F.polynomialSymbol_lowerCentralSeries_eq_bot w) + (hM := G.polynomialSymbol_lowerCentralSeries_eq_bot w) S + have hright (g : G.RealPolynomialSymbolGroup w) : + F.realSymbolProjection G φ hφ w (lift g) = g := by + apply (hsolve g ?_).2 + change g.coord ∈ ((⊤ : LieSubalgebra ℚ (F.PolynomialSymbol w)).map ψ).toSubmodule.baseChange ℝ + rw [himage] + simp + obtain ⟨E, P, R, hprod, hE, hR, hP⟩ := hfactor + dsimp only [SymbolSlowBound, SymbolRationalGrid] at hE hR + let middle := (lift E)⁻¹ * X * (lift R)⁻¹ + have hmiddle : F.realSymbolProjection G φ hφ w middle = P := by + dsimp only [middle] + rw [map_mul, map_mul, map_inv, map_inv, hright, hright, ← hprod] + group + refine ⟨m, hm, hmp, hlm, lift E, middle, lift R, ?_, ?_, ?_, ?_⟩ + · dsimp only [middle]; group + · have h := hslow (monomialScale T) (monomialScale_pos T hT) + (Real.exp p) (Real.exp_pos p).le E (by with_reducible exact hE) + simp only [← Real.exp_add] at h + dsimp only [SymbolSlowBound] + with_reducible exact h + · apply hgrid R + with_reducible exact hR + · rw [← F.symbolPointwiseSubalgebra_comap G e ω hF f ν hG φ hφ w U, + realificationLieSubalgebra_comap] + change (F.realSymbolProjection G φ hφ w middle).coord ∈ + realificationLieSubalgebra (G.symbolPointwiseSubalgebra f ν hG w U) + rw [hmiddle] + with_reducible exact hP + +end NilpotentLieFiltration +end Erdos3 + +end + +section + +universe v + +namespace Erdos3.RationalFilteredNilmanifold + +open Module VectorPolynomial NilpotentLieFiltration +open scoped TensorProduct + +variable {ι : Type v} {L₀ : Type u} {L : ι → Type u} + [LieRing L₀] [∀ i, LieRing (L i)] [LieAlgebra ℚ L₀] [∀ i, LieAlgebra ℚ (L i)] + +def optionPairProjection (j : ι) : + (∀ i : Option ι, optionLieSpace L₀ L i) →ₗ⁅ℚ⁆ PairAlgebra L₀ (L j) := + liePiMap (fun b => by + cases b + · exact liePiEval (some j) + · exact liePiEval none) + +@[simp] theorem optionPairProjection_true (j : ι) + (x : ∀ i : Option ι, optionLieSpace L₀ L i) : + optionPairProjection j x true = x none := rfl + +@[simp] theorem optionPairProjection_false (j : ι) + (x : ∀ i : Option ι, optionLieSpace L₀ L i) : + optionPairProjection j x false = x (some j) := rfl + +@[simp] theorem pairFrequency_optionPairProjection (j : ι) + (η : L₀ →ₗ[ℚ] ℚ) (θ : L j →ₗ[ℚ] ℚ) + (x : ∀ i : Option ι, optionLieSpace L₀ L i) : + pairFrequency η θ (optionPairProjection j x) = η (x none) + θ (x (some j)) := by + rw [pairFrequency_apply, optionPairProjection_true, optionPairProjection_false] + +@[simp] theorem realification_optionPairProjection_true (j : ι) + (x : ℝ ⊗[ℚ] (∀ i : Option ι, optionLieSpace L₀ L i)) : + realificationLieHom (liePiEval true) (realificationLieHom (optionPairProjection j) x) = + realificationLieHom (liePiEval none) x := by + induction x using TensorProduct.inductionOn with + | tmul r x => rfl + | add x y hx hy => simp only [map_add, hx, hy]; rfl + +@[simp] theorem realification_optionPairProjection_false (j : ι) + (x : ℝ ⊗[ℚ] (∀ i : Option ι, optionLieSpace L₀ L i)) : + realificationLieHom (liePiEval false) (realificationLieHom (optionPairProjection j) x) = + realificationLieHom (liePiEval (some j)) x := by + induction x using TensorProduct.inductionOn with + | tmul r x => rfl + | add x y hx hy => simp only [map_add, hx, hy]; rfl + +variable [Fintype ι] {s d₀ : ℕ} {d : ι → ℕ} + (D₀ : RationalFilteredNilmanifold L₀ s d₀) + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) (j : ι) + +theorem optionPairProjection_layers (k : ℕ) + (x : ∀ i : Option ι, optionLieSpace L₀ L i) + (hx : x ∈ (optionProduct D₀ D).filtration.layer k) : + optionPairProjection j x ∈ (pi (pairModels D₀ (D j))).filtration.layer k := by + apply (mem_pi_layer (fun b => (pairModels D₀ (D j) b).filtration) k _).mpr + intro b + cases b + · exact (mem_pi_layer (fun i => (optionFactors D₀ D i).filtration) k x).mp hx (some j) + · exact (mem_pi_layer (fun i => (optionFactors D₀ D i).filtration) k x).mp hx none + +theorem optionPairProjection_layer_surjective (k : ℕ) (x : PairAlgebra L₀ (L j)) + (hx : x ∈ (pi (pairModels D₀ (D j))).filtration.layer k) : + ∃ y ∈ (optionProduct D₀ D).filtration.layer k, optionPairProjection j y = x := by + classical + let y : ∀ i : Option ι, optionLieSpace L₀ L i + | none => x true + | some i => Pi.single (M := L) j (x false) i + refine ⟨y, ?_, ?_⟩ + · apply (mem_pi_layer (fun i => (optionFactors D₀ D i).filtration) k y).mpr + intro i + cases i with + | none => + exact (mem_pi_layer (fun b => (pairModels D₀ (D j) b).filtration) k x).mp hx true + | some i => + by_cases hij : i = j + · subst i + change Pi.single (M := L) j (x false) j ∈ (D j).filtration.layer k + erw [Pi.single_eq_same] + exact (mem_pi_layer (fun b => (pairModels D₀ (D j) b).filtration) k x).mp hx false + · change Pi.single (M := L) j (x false) i ∈ (D i).filtration.layer k + erw [Pi.single_eq_of_ne hij] + exact Submodule.zero_mem _ + · funext b + cases b + · exact Pi.single_eq_same (M := L) j (x false) + · rfl + +theorem optionPairProjection_piRealOrbit_log {σ : Type*} {w : σ → ℕ} + (g : ∀ i, (optionFactors D₀ D i).filtration.realification.PolynomialOrbit w) : + VectorPolynomial.map + ((realificationLieHom (optionPairProjection j)).toLinearMap.restrictScalars ℚ) + (piRealOrbit (fun i => (optionFactors D₀ D i).filtration) g).log = + (pairOrbit D₀ (D j) (g none) (g (some j))).log := by + apply coefficients.injective + ext α + rw [coefficients_map] + apply ((Pi.basis (fun b => (pairModels D₀ (D j) b).basis)).baseChange ℝ).repr.injective + ext ⟨b, k⟩ + rw [realification_pi_basis_repr, realification_pi_basis_repr] + change ((pairModels D₀ (D j) b).basis.baseChange ℝ).repr + (realificationLieHom (liePiEval b) (realificationLieHom (optionPairProjection j) + (coefficients (piRealOrbit (fun i => (optionFactors D₀ D i).filtration) g).log α))) k = + ((pairModels D₀ (D j) b).basis.baseChange ℝ).repr + (realificationLieHom (liePiEval b) + (coefficients (pairOrbit D₀ (D j) (g none) (g (some j))).log α)) k + have hpair := piRealOrbit_coefficient (fun b => (pairModels D₀ (D j) b).filtration) + (fun b => by cases b; exact g (some j); exact g none) α b + change realificationLieHom (liePiEval b) + (coefficients (pairOrbit D₀ (D j) (g none) (g (some j))).log α) = _ at hpair + rw [hpair] + cases b + · rw [realification_optionPairProjection_false] + exact congrArg (fun x => ((D j).basis.baseChange ℝ).repr x k) + (piRealOrbit_coefficient (fun i => (optionFactors D₀ D i).filtration) g α (some j)) + · rw [realification_optionPairProjection_true] + exact congrArg (fun x => (D₀.basis.baseChange ℝ).repr x k) + (piRealOrbit_coefficient (fun i => (optionFactors D₀ D i).filtration) g α none) + +variable {α β σ : Type*} + (e : Basis α ℚ (∀ i : Option ι, optionLieSpace L₀ L i)) (ω : α → ℕ) + (hF : ∀ k, (optionProduct D₀ D).filtration.layer k = + Submodule.span ℚ (e '' {i | k ≤ ω i})) + (b : Basis β ℚ (PairAlgebra L₀ (L j))) (ν : β → ℕ) + (hG : ∀ k, (pi (pairModels D₀ (D j))).filtration.layer k = + Submodule.span ℚ (b '' {i | k ≤ ν i})) + +theorem optionPairProjection_jointOrbitSymbol {w : σ → ℕ} + (g : ∀ i, (optionFactors D₀ D i).filtration.realification.PolynomialOrbit w) : + (optionProduct D₀ D).filtration.realSymbolProjection + (pi (pairModels D₀ (D j))).filtration + (optionPairProjection j) (optionPairProjection_layers D₀ D j) w + ((optionProduct D₀ D).filtration.realPolynomialSymbolHom e ω hF w + ⟨⟨(piRealOrbit (fun i => (optionFactors D₀ D i).filtration) g).log, + (piRealOrbit (fun i => (optionFactors D₀ D i).filtration) g).property⟩⟩) = + pairOrbitSymbol D₀ (D j) (g none) (g (some j)) b ν hG := by + apply NilpotentLieBCHGroup.ext + have h := (optionProduct D₀ D).filtration.realFilteredPolynomialSymbolMap_polynomial + (pi (pairModels D₀ (D j))).filtration + (optionPairProjection j) (optionPairProjection_layers D₀ D j) + e ω hF b ν hG w + ⟨(piRealOrbit (fun i => (optionFactors D₀ D i).filtration) g).log, + (piRealOrbit (fun i => (optionFactors D₀ D i).filtration) g).property⟩ + change _ = (pi (pairModels D₀ (D j))).filtration.realSymbolOfPolynomial b ν hG w + (pairOrbit D₀ (D j) (g none) (g (some j))).log + exact h.trans (congrArg + ((pi (pairModels D₀ (D j))).filtration.realSymbolOfPolynomial b ν hG w) + (optionPairProjection_piRealOrbit_log D₀ D j g)) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +variable {J : Type*} [Fintype J] {L : Type u} {M : J → Type u} + [LieRing L] [LieAlgebra ℚ L] [∀ j, LieRing (M j)] [∀ j, LieAlgebra ℚ (M j)] + {s d₀ : ℕ} {d : J → ℕ} + (D : RationalFilteredNilmanifold L s d₀) + (E : ∀ j, RationalFilteredNilmanifold (M j) s (d j)) + +theorem optionPairProjection_native_logHeight (j : J) + (x : ∀ i : Option J, optionLieSpace L M i) {p : ℝ} + (hx : ∀ k, rationalLogHeight ((optionProduct D E).basis.repr x k) ≤ p) : + ∀ k, rationalLogHeight ((pi (pairModels D (E j))).basis.repr + (optionPairProjection j x) k) ≤ p := by + intro k + rw [productFinBasis_repr] + generalize hz : (Fintype.equivFin (Σ b : Bool, Fin (Bool.rec (d j) d₀ b))).symm k = z + rcases z with ⟨b, i⟩ + cases b + · change rationalLogHeight ((E j).basis.repr (x (some j)) i) ≤ p + exact (congrArg rationalLogHeight + (productFinBasis_repr_component (optionFactors D E) x (some j) i)).le.trans (hx _) + · change rationalLogHeight (D.basis.repr (x none) i) ≤ p + exact (congrArg rationalLogHeight + (productFinBasis_repr_component (optionFactors D E) x none i)).le.trans (hx _) + +theorem optionPairProjection_adapted_logHeight {α β : Type*} + (j : J) (e : Basis α ℚ (∀ i : Option J, optionLieSpace L M i)) + (b : Basis β ℚ (PairAlgebra L (M j))) {p : ℝ} (hp : 0 ≤ p) + (hdim : (Fintype.card (Σ i : Bool, Fin (Bool.rec (d j) d₀ i)) : ℝ) ≤ p) + (he : ∀ i k, rationalLogHeight ((optionProduct D E).basis.repr (e i) k) ≤ p) + (hb : ∀ i k, rationalLogHeight (b.repr ((pi (pairModels D (E j))).basis i) k) ≤ p) : + ∀ i k, rationalLogHeight (b.repr (optionPairProjection j (e i)) k) ≤ (p + 3) ^ 4 := by + intro i k + have hp' : 0 ≤ p + 1 := by linarith + have hcoord := rational_basis_coordinates_logHeight (pi (pairModels D (E j))).basis b + hp' (by simpa only [Fintype.card_fin] using hdim.trans (show p ≤ p + 1 by linarith)) + (ceil_exp_le_exp_add_one hp) + (fun i k => rationalHeightLE_ceil_exp (hb i k)) (optionPairProjection j (e i)) + (fun k => (optionPairProjection_native_logHeight D E j (e i) (he i) k).trans + (by linarith)) k + convert hcoord using 1 + ring + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +noncomputable def controlledProjectionBudget (p : ℝ) : ℝ := + (((p + 2) ^ 10 + 2) ^ 36) + (((p + 2) ^ 10 + 2) ^ 18 + p) + + (preimageBasisBudget p + 1) + +variable {σ ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] {s : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M s) + (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (f : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (f '' {i | j ≤ ν i})) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +theorem controlledSymbolFactorizationAtFast_projection_pullback + [Fintype (SymbolBasisIndex (fun _ : σ => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : σ => 1) ν)] + (hsurj : ∀ j, ∀ y ∈ G.layer j, ∃ x ∈ F.layer j, φ x = y) + {H : ℕ} (hH : 1 ≤ H) + (hentries : ∀ i j, RationalHeightLE (f.repr (φ (e j)) i) H) + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hrows : (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω ⊕ + SymbolBasisIndex (fun _ : σ => 1) ν) : ℝ) ≤ p) + (hcols : ((Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) * + Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) : ℕ) : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, 0 < T i) + (X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)) + (η : M →ₗ[ℚ] ℚ) (U : LieSubalgebra ℚ G.AssociatedGraded) + (hfactor : G.ControlledSymbolFactorizationAtFast f ν hG η T + (F.realSymbolProjection G φ hφ (fun _ => 1) X) p U) : + F.ControlledSymbolFactorizationAtFast e ω hF (η.comp φ.toLinearMap) T X + (controlledProjectionBudget p) (U.comap (F.associatedGradedMap G φ hφ)) := by + obtain ⟨l, E, P, R, v, hl, hlp, hprod, hE, hR, hv, hgraded, hvH, hzero, hP⟩ := hfactor + obtain ⟨m, hm, hmp, _, hsplit⟩ := + F.exists_symbolFactorizationIn_projection_pullback G e ω hF f ν hG φ hφ + hsurj hH hl hentries hp hrows hcols hHp hlp T hT X U + ⟨E, P, R, hprod, hE, hR, hP⟩ + obtain ⟨u, hu, huH⟩ := F.exists_associatedGradedMap_comap_bounded_spanning + G e ω hF f ν hG φ hφ U v hv hp hι hκ hvH + (fun i j => rationalLogHeight_le_of_height (hentries j i) hHp) + have hbase : 0 ≤ preimageBasisBudget p := preimageBasisBudget_nonneg hp + have hq : 0 ≤ ((p + 2) ^ 10 + 2) := by positivity + have hden : ((p + 2) ^ 10 + 2) ^ 36 ≤ controlledProjectionBudget p := by + unfold controlledProjectionBudget + exact (le_add_of_nonneg_right (by positivity)).trans + (le_add_of_nonneg_right (by positivity)) + have hslow : ((p + 2) ^ 10 + 2) ^ 18 + p ≤ controlledProjectionBudget p := by + unfold controlledProjectionBudget + have := pow_nonneg hq 36 + linarith + have hheight : preimageBasisBudget p + 1 ≤ controlledProjectionBudget p := by + unfold controlledProjectionBudget + have := pow_nonneg hq 36 + have := pow_nonneg hq 18 + linarith + obtain ⟨A, B, C, hABC, hA, hC, hB⟩ := hsplit.mono F e ω hF hslow hT + exact ⟨m, A, B, C, u, hm, hmp.trans (Real.exp_le_exp.mpr hden), + hABC, hA, hC, hu, + F.associatedGradedMap_comap_graded G e ω hF f ν hG φ hφ U hgraded, + fun i j => (huH i j).trans hheight, + F.gradedFrequency_comap_top_zero G e ω hF f ν hG φ hφ η U hzero, hB⟩ + +theorem controlledSymbolFactorization_projection_pullback + [Fintype (SymbolBasisIndex (fun _ : σ => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : σ => 1) ν)] + (hsurj : ∀ j, ∀ y ∈ G.layer j, ∃ x ∈ F.layer j, φ x = y) + {H : ℕ} (hH : 1 ≤ H) + (hentries : ∀ i j, RationalHeightLE (f.repr (φ (e j)) i) H) + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hrows : (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω ⊕ + SymbolBasisIndex (fun _ : σ => 1) ν) : ℝ) ≤ p) + (hcols : ((Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) * + Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) : ℕ) : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, 0 < T i) + (X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)) (η : M →ₗ[ℚ] ℚ) + (hfactor : G.ControlledSymbolFactorization f ν hG η T + (F.realSymbolProjection G φ hφ (fun _ => 1) X) p) : + F.ControlledSymbolFactorization e ω hF (η.comp φ.toLinearMap) T X + (controlledProjectionBudget p) := by + obtain ⟨U, hU⟩ := hfactor.exists_fastWitness G f ν hG + obtain ⟨m, E, P, R, v, hdata⟩ := + F.controlledSymbolFactorizationAtFast_projection_pullback G e ω hF f ν hG φ hφ + hsurj hH hentries hp hι hκ hrows hcols hHp T hT X η U hU + exact ⟨m, E, P, R, _, v, hdata⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +theorem controlledProjectionBudget_nonneg {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ controlledProjectionBudget p := by + have := preimageBasisBudget_nonneg hp + unfold controlledProjectionBudget + positivity + +theorem le_controlledProjectionBudget {p : ℝ} (hp : 0 ≤ p) : + p ≤ controlledProjectionBudget p := by + have hpre := preimageBasisBudget_nonneg hp + have hq : 0 ≤ ((p + 2) ^ 10 + 2) := by positivity + have h36 := pow_nonneg hq 36 + have h18 := pow_nonneg hq 18 + unfold controlledProjectionBudget + linarith + +theorem exists_controlledProjectionBudget_power : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → controlledProjectionBudget p ≤ (p + C) ^ C := by + let Q : Polynomial ℕ := + Polynomial.X + (Polynomial.X + (Polynomial.X + 3) ^ 7 + 2) ^ 4 + 1 + let P : Polynomial ℕ := + ((Polynomial.X + 2) ^ 10 + 2) ^ 36 + + (((Polynomial.X + 2) ^ 10 + 2) ^ 18 + Polynomial.X) + + ((Q + Q * ((Q + 2) ^ 7 + Q)) + 1) + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro p hp + simpa [P, Q, controlledProjectionBudget, preimageBasisBudget, sparseGeneratorBudget, + Polynomial.eval₂_pow] using hbound p hp + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +def controlledProjectionDimensionInput (s : ℕ) (p : ℝ) : ℝ := + 2 * ((p + (s + 2)) ^ (s + 2)) ^ 2 + p + 1 + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +theorem ControlledSymbolFactorizationAtFast.mono {η : L →ₗ[ℚ] ℚ} + {T : σ → ℝ} {X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)} + {p q : ℝ} {U : LieSubalgebra ℚ F.AssociatedGraded} + (h : F.ControlledSymbolFactorizationAtFast e ω hF η T X p U) + (hpq : p ≤ q) (hT : ∀ i, 0 < T i) : + F.ControlledSymbolFactorizationAtFast e ω hF η T X q U := by + obtain ⟨m, E, P, R, v, hm, hmp, hprod, hE, hR, hv, hgraded, hheight, hzero, hP⟩ := h + exact ⟨m, E, P, R, v, hm, hmp.trans (Real.exp_le_exp.mpr hpq), hprod, + F.symbolSlowBound_mono e ω hF _ T hT (Real.exp_le_exp.mpr hpq) E hE, + hR, hv, hgraded, fun i j => (hheight i j).trans hpq, hzero, hP⟩ + +variable {κ M : Type*} [LieRing M] [LieAlgebra ℚ M] + (G : NilpotentLieFiltration M s) + (f : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (f '' {i | j ≤ ν i})) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +theorem controlledSymbolFactorizationAtFast_projection_of_dimensions + [Fintype σ] [Fintype ι] [Fintype κ] + (hsurj : ∀ j, ∀ y ∈ G.layer j, ∃ x ∈ F.layer j, φ x = y) + {H : ℕ} (hH : 1 ≤ H) + (hentries : ∀ i j, RationalHeightLE (f.repr (φ (e j)) i) H) + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) (hσ : (Fintype.card σ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, 0 < T i) + (X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)) + (η : M →ₗ[ℚ] ℚ) (U : LieSubalgebra ℚ G.AssociatedGraded) + (hfactor : G.ControlledSymbolFactorizationAtFast f ν hG η T + (F.realSymbolProjection G φ hφ (fun _ => 1) X) p U) : + F.ControlledSymbolFactorizationAtFast e ω hF (η.comp φ.toLinearMap) T X + (controlledProjectionBudget (controlledProjectionDimensionInput s p)) + (U.comap (F.associatedGradedMap G φ hφ)) := by + let := symbolBasisIndexFintype (fun _ : σ => 1) ω s (fun _ => Nat.zero_lt_one) + (F.adaptedBasis_weight_le_step e ω hF) + let := symbolBasisIndexFintype (fun _ : σ => 1) ν s (fun _ => Nat.zero_lt_one) + (G.adaptedBasis_weight_le_step f ν hG) + let q : ℝ := (p + (s + 2)) ^ (s + 2) + let r : ℝ := controlledProjectionDimensionInput s p + have hpR : p ≤ r := by + change p ≤ 2 * q ^ 2 + p + 1 + nlinarith [sq_nonneg q] + have hR : 0 ≤ r := hp.trans hpR + have hq : 1 ≤ q := by + apply one_le_pow₀ + have := Nat.cast_nonneg (α := ℝ) s + linarith + have hsource : (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) : ℝ) ≤ q := + (Nat.cast_le.mpr (symbolBasisIndex_card_le _ _ s (fun _ => Nat.zero_lt_one) + (F.adaptedBasis_weight_le_step e ω hF))).trans + (symbol_dimension_bound_le_power s (Fintype.card ι) (Fintype.card σ) hp hι hσ) + have htarget : (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ν) : ℝ) ≤ q := + (Nat.cast_le.mpr (symbolBasisIndex_card_le _ _ s (fun _ => Nat.zero_lt_one) + (G.adaptedBasis_weight_le_step f ν hG))).trans + (symbol_dimension_bound_le_power s (Fintype.card κ) (Fintype.card σ) hp hκ hσ) + have hrows : (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω ⊕ + SymbolBasisIndex (fun _ : σ => 1) ν) : ℝ) ≤ r := by + simp only [Fintype.card_sum, Nat.cast_add] + change _ ≤ 2 * q ^ 2 + p + 1 + nlinarith + have hcols : ((Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) * + Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) : ℕ) : ℝ) ≤ r := by + rw [Nat.cast_mul] + have hnonneg := Nat.cast_nonneg (α := ℝ) + (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω)) + have hsquare := mul_self_le_mul_self hnonneg hsource + change _ ≤ 2 * q ^ 2 + p + 1 + nlinarith + exact F.controlledSymbolFactorizationAtFast_projection_pullback G e ω hF f ν hG φ hφ + hsurj hH hentries hR (hι.trans hpR) (hκ.trans hpR) hrows hcols + (hHp.trans (Real.exp_le_exp.mpr hpR)) T hT X η U + (hfactor.mono G f ν hG hpR hT) + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +theorem le_controlledProjectionDimensionInput (s : ℕ) (p : ℝ) : + p ≤ controlledProjectionDimensionInput s p := by + unfold controlledProjectionDimensionInput + nlinarith [sq_nonneg ((p + (s + 2)) ^ (s + 2))] + +theorem controlledProjectionDimensionInput_nonneg (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ controlledProjectionDimensionInput s p := + hp.trans (le_controlledProjectionDimensionInput s p) + +theorem exists_controlledProjectionUniformBudget_power (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + controlledProjectionBudget (controlledProjectionDimensionInput s p) ≤ (p + C) ^ C := by + obtain ⟨a, _, ha⟩ := exists_controlledProjectionBudget_power + let P : Polynomial ℕ := + (2 * ((Polynomial.X + Polynomial.C (s + 2)) ^ (s + 2)) ^ 2 + + Polynomial.X + 1 + Polynomial.C a) ^ a + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, fun p hp => ?_⟩ + apply (ha _ (controlledProjectionDimensionInput_nonneg s hp)).trans + simpa [P, controlledProjectionDimensionInput, Polynomial.eval₂_pow] using hbound p hp + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CoordinateProjectionBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/CoordinateProjectionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..090bdadc9a126de4b550d303894ac41047887ee3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CoordinateProjectionBounds.lean @@ -0,0 +1,58 @@ +import OAI.Combinatorics.Progressions.Linear.BasisGradedCoordinateBasis +import OAI.Combinatorics.Progressions.Sampling.RationalSpanGrid + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem basisCoordinateProjection_abs_repr_le {V ι : Type*} [AddCommGroup V] [Module ℝ V] + (b : Basis ι ℝ V) (S : Set ι) (x : V) (i : ι) : + |b.repr (basisCoordinateProjection b S x) i| ≤ |b.repr x i| := by + classical + rw [basisCoordinateProjection_repr] + split_ifs + · exact le_rfl + · simpa only [abs_zero] using abs_nonneg (b.repr x i) + +theorem basisCoordinateProjection_norm_le {V ι : Type*} [AddCommGroup V] [Module ℝ V] [Fintype ι] + (b : Basis ι ℝ V) (S : Set ι) (x : V) : + ‖b.equivFun (basisCoordinateProjection b S x)‖ ≤ ‖b.equivFun x‖ := by + apply (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr + intro i + exact (basisCoordinateProjection_abs_repr_le b S x i).trans (norm_le_pi_norm (b.equivFun x) i) + +theorem basisCoordinateProjection_real_grid {V ι : Type*} [AddCommGroup V] [Module ℝ V] + (b : Basis ι ℝ V) (S : Set ι) (l : ℕ) (x : V) (hx : (fun i => b.repr x i) ∈ realDenominatorGrid l) : + (fun i => b.repr (basisCoordinateProjection b S x) i) ∈ realDenominatorGrid l := by + classical + obtain ⟨z, hz⟩ := hx + refine ⟨fun i => if i ∈ S then z i else 0, ?_⟩ + funext i + have hi := congrFun hz i + change (z i : ℝ) = (l : ℝ) * b.repr x i at hi + change ((if i ∈ S then z i else 0 : ℤ) : ℝ) = (l : ℝ) * b.repr (basisCoordinateProjection b S x) i + rw [basisCoordinateProjection_repr] + by_cases h : i ∈ S <;> simp only [h, ↓reduceIte, Int.cast_zero, mul_zero] + exact hi + +theorem basisCoordinateProjection_rational_grid {V ι : Type*} [AddCommGroup V] [Module ℚ V] + (b : Basis ι ℚ V) (S : Set ι) (l : ℕ) (x : V) (hx : (fun i => b.repr x i) ∈ denominatorGrid l) : + (fun i => b.repr (basisCoordinateProjection b S x) i) ∈ denominatorGrid l := by + classical + obtain ⟨z, hz⟩ := hx + refine ⟨fun i => if i ∈ S then z i else 0, ?_⟩ + intro i + change (l : ℚ) * b.repr (basisCoordinateProjection b S x) i = ((if i ∈ S then z i else 0 : ℤ) : ℚ) + rw [basisCoordinateProjection_repr] + by_cases h : i ∈ S <;> simp only [h, ↓reduceIte, Int.cast_zero, mul_zero] + exact hz i + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CoordinateZeroProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/CoordinateZeroProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d0a0221daac32870ab35f3c144521098651a50e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CoordinateZeroProjection.lean @@ -0,0 +1,40 @@ +import Mathlib.Analysis.Calculus.ContDiff.Operations +import Mathlib.Analysis.Normed.Group.Constructions + +namespace OAI + +section + +namespace Erdos3 + +open scoped ContDiff + +variable {D : Type*} [Fintype D] (P : D → Prop) [DecidablePred P] + +def coordinateZeroProjection (v : D → ℝ) : D → ℝ := fun d => if P d then 0 else v d + +theorem coordinateZeroProjection_lipschitz : LipschitzWith 1 (coordinateZeroProjection P) := by + apply LipschitzWith.of_dist_le_mul + intro v w + simp only [NNReal.coe_one, one_mul] + apply (dist_pi_le_iff dist_nonneg).mpr + intro d + by_cases h : P d + · simp only [coordinateZeroProjection, h, ite_true, dist_self] + exact dist_nonneg + · simpa only [coordinateZeroProjection, h, ite_false] using dist_le_pi_dist v w d + +theorem coordinateZeroProjection_contDiff : ContDiff ℝ ∞ (coordinateZeroProjection P) := by + apply contDiff_pi.mpr + intro d + by_cases h : P d + · simpa only [coordinateZeroProjection, h, ite_true] using + (contDiff_const : ContDiff ℝ ∞ (fun _ : D → ℝ => (0 : ℝ))) + · simpa only [coordinateZeroProjection, h, ite_false] using + (contDiff_apply ℝ ℝ d : ContDiff ℝ ∞ (fun v : D → ℝ => v d)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CountingKernelOuter.lean b/lean/OAI/Combinatorics/Progressions/Linear/CountingKernelOuter.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e68e2725d1fc73b07b65d740d30d1e5b283f93f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CountingKernelOuter.lean @@ -0,0 +1,281 @@ +import OAI.Combinatorics.Progressions.Estimates.AnchoredReferenceDomination +import OAI.Combinatorics.Progressions.FixedDensity.Energy + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def countingFeature (b t : ℝ) (sigma : Bool) (u : ℝ) : ℝ := + 1 + (b + if sigma then t else -t) * (u - 1) + +noncomputable def countingKernel (b u v : ℝ) : ℝ := + 1 + b * (u + v - 2) + (2 * b ^ 2 - b) * (u - 1) * (v - 1) + +noncomputable def positiveCountingKernel (b u v : ℝ) : ℝ := 1 - b + b * u * v + +theorem countingFeature_pair (b t r u v : ℝ) : + (𝔼 sigma : Bool, countingFeature b t sigma u * countingFeature b r sigma v) = + 1 + b * (u + v - 2) + (b ^ 2 + t * r) * (u - 1) * (v - 1) := by + rw [Fintype.expect_eq_sum_div_card] + norm_num [countingFeature] + ring + +theorem countingFeature_opposite {b t : ℝ} (ht : t ^ 2 = b * (1 - b)) (u v : ℝ) : + (𝔼 sigma : Bool, countingFeature b t sigma u * countingFeature b (-t) sigma v) = + countingKernel b u v := by + have hc : b ^ 2 + t * (-t) = 2 * b ^ 2 - b := by nlinarith + rw [countingFeature_pair, hc] + rfl + +theorem countingFeature_same {b t : ℝ} (ht : t ^ 2 = b * (1 - b)) (u v : ℝ) : + (𝔼 sigma : Bool, countingFeature b t sigma u * countingFeature b t sigma v) = + positiveCountingKernel b u v := by + have hc : b ^ 2 + t * t = b := by nlinarith + rw [countingFeature_pair, hc] + unfold positiveCountingKernel + ring + +theorem countingFeature_sqrt_opposite {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (u v : ℝ) : + (𝔼 sigma : Bool, countingFeature b (Real.sqrt (b * (1 - b))) sigma u * + countingFeature b (-Real.sqrt (b * (1 - b))) sigma v) = countingKernel b u v := + countingFeature_opposite (Real.sq_sqrt (mul_nonneg hb (sub_nonneg.mpr hb1))) u v + +theorem countingFeature_sqrt_same {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (u v : ℝ) : + (𝔼 sigma : Bool, countingFeature b (Real.sqrt (b * (1 - b))) sigma u * + countingFeature b (Real.sqrt (b * (1 - b))) sigma v) = positiveCountingKernel b u v := + countingFeature_same (Real.sq_sqrt (mul_nonneg hb (sub_nonneg.mpr hb1))) u v + +theorem countingKernel_one (u v : ℝ) : countingKernel 1 u v = u * v := by + unfold countingKernel + ring + +theorem countingKernel_quarter (u v : ℝ) : + countingKernel (1 / 4) u v = 3 / 8 + (3 / 8) * u + (3 / 8) * v - (1 / 8) * u * v := by + unfold countingKernel + ring + +theorem positiveCountingKernel_nonneg {b u v : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) + (hu : 0 ≤ u) (hv : 0 ≤ v) : 0 ≤ positiveCountingKernel b u v := + add_nonneg (sub_nonneg.mpr hb1) (mul_nonneg (mul_nonneg hb hu) hv) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def countingFeatureProduct {I X : Type*} [Fintype I] [DecidableEq I] + (b t : ℝ) (f : I → X → ℝ) (sigma : I → Bool) (x : X) : ℝ := + ∏ i, countingFeature b t (sigma i) (f i x) + +noncomputable def countingKernelProductAverage {I X Y : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] (b : ℝ) (f : I → X → ℝ) (g : I → Y → ℝ) : ℝ := + 𝔼 x, 𝔼 y, ∏ i, countingKernel b (f i x) (g i y) + +noncomputable def positiveKernelGram {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] + (b : ℝ) (f : I → X → ℝ) : ℝ := 𝔼 x, 𝔼 y, ∏ i, positiveCountingKernel b (f i x) (f i y) + +theorem countingFeatureProduct_pair {I X Y : Type*} [Fintype I] [DecidableEq I] + (b t r : ℝ) (f : I → X → ℝ) (g : I → Y → ℝ) (x : X) (y : Y) : + (𝔼 sigma : I → Bool, countingFeatureProduct b t f sigma x * countingFeatureProduct b r g sigma y) = + ∏ i, (𝔼 sigma : Bool, countingFeature b t sigma (f i x) * countingFeature b r sigma (g i y)) := by + classical + simp only [countingFeatureProduct, ← Finset.prod_mul_distrib] + exact (FixedDensity.prod_mean (fun i sigma => countingFeature b t sigma (f i x) * + countingFeature b r sigma (g i y))).symm + +theorem countingFeatureProduct_mean_pair {I X Y : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] (b t r : ℝ) + (f : I → X → ℝ) (g : I → Y → ℝ) : + (𝔼 sigma : I → Bool, (𝔼 x, countingFeatureProduct b t f sigma x) * + (𝔼 y, countingFeatureProduct b r g sigma y)) = + 𝔼 x, 𝔼 y, ∏ i, (𝔼 sigma : Bool, + countingFeature b t sigma (f i x) * countingFeature b r sigma (g i y)) := by + simp_rw [Finset.expect_mul_expect] + rw [Finset.expect_comm] + apply Finset.expect_congr rfl + intro x _ + rw [Finset.expect_comm] + apply Finset.expect_congr rfl + intro y _ + exact countingFeatureProduct_pair b t r f g x y + +theorem countingKernelProductAverage_factorization {I X Y : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] {b t : ℝ} (ht : t ^ 2 = b * (1 - b)) + (f : I → X → ℝ) (g : I → Y → ℝ) : + countingKernelProductAverage b f g = + 𝔼 sigma : I → Bool, (𝔼 x, countingFeatureProduct b t f sigma x) * + (𝔼 y, countingFeatureProduct b (-t) g sigma y) := by + simpa only [countingFeature_opposite ht, countingKernelProductAverage] using + (countingFeatureProduct_mean_pair b t (-t) f g).symm + +theorem countingFeatureProduct_square {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] + {b t : ℝ} (ht : t ^ 2 = b * (1 - b)) (f : I → X → ℝ) : + (𝔼 sigma : I → Bool, (𝔼 x, countingFeatureProduct b t f sigma x) ^ 2) = positiveKernelGram b f := by + simpa only [pow_two, countingFeature_same ht, positiveKernelGram] using + countingFeatureProduct_mean_pair b t t f f + +theorem positiveKernelGram_nonneg {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] + {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (f : I → X → ℝ) : 0 ≤ positiveKernelGram b f := by + rw [← countingFeatureProduct_square (Real.sq_sqrt (mul_nonneg hb (sub_nonneg.mpr hb1))) f] + exact Finset.expect_nonneg (fun _ _ => sq_nonneg _) + +theorem countingKernelProductAverage_sq_le {I X Y : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) + (f : I → X → ℝ) (g : I → Y → ℝ) : + countingKernelProductAverage b f g ^ 2 ≤ positiveKernelGram b f * positiveKernelGram b g := by + let t := Real.sqrt (b * (1 - b)) + have ht : t ^ 2 = b * (1 - b) := Real.sq_sqrt (mul_nonneg hb (sub_nonneg.mpr hb1)) + have hnt : (-t) ^ 2 = b * (1 - b) := by simpa only [neg_sq] using ht + rw [countingKernelProductAverage_factorization ht f g] + calc + _ ≤ (𝔼 sigma : I → Bool, (𝔼 x, countingFeatureProduct b t f sigma x) ^ 2) * + (𝔼 sigma : I → Bool, (𝔼 y, countingFeatureProduct b (-t) g sigma y) ^ 2) := + Finset.expect_mul_sq_le_sq_mul_sq Finset.univ _ _ + _ = _ := by rw [countingFeatureProduct_square ht, countingFeatureProduct_square hnt] + +theorem countingKernelProductAverage_abs_le {I X Y : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] {b A : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (hA : 0 ≤ A) + (f : I → X → ℝ) (g : I → Y → ℝ) + (hf : positiveKernelGram b f ≤ A) (hg : positiveKernelGram b g ≤ A) : + |countingKernelProductAverage b f g| ≤ A := by + have hsq := (countingKernelProductAverage_sq_le hb hb1 f g).trans + (mul_le_mul hf hg (positiveKernelGram_nonneg hb hb1 g) hA) + nlinarith [sq_abs (countingKernelProductAverage b f g), abs_nonneg (countingKernelProductAverage b f g)] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def countingBernoulli {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) : + FiniteProbabilityWeights Bool where + weight sigma := if sigma then b else 1 - b + nonneg sigma := by cases sigma <;> simp <;> linarith + total := by simp + +theorem countingBernoulli_mean {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (u : ℝ) : + (countingBernoulli hb hb1).mean (fun sigma => if sigma then u else 1) = 1 - b + b * u := by + simpa [FiniteProbabilityWeights.mean, countingBernoulli] using add_comm (b * u) (1 - b) + +theorem countingBernoulli_product {I : Type*} [Fintype I] [DecidableEq I] + {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (u : I → ℝ) : + (FiniteProbabilityWeights.pi (fun _ : I => countingBernoulli hb hb1)).mean + (fun choice => ∏ i, if choice i then u i else 1) = ∏ i, (1 - b + b * u i) := by + rw [FiniteProbabilityWeights.mean_pi_product (fun _ : I => countingBernoulli hb hb1) + (fun i sigma => if sigma then u i else 1)] + simp only [countingBernoulli_mean] + +theorem positiveKernelGram_le_of_boolean_products {I X : Type*} [Fintype I] [DecidableEq I] [Fintype X] + {b A : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (f : I → X → ℝ) + (h : ∀ choice : I → Bool, (𝔼 x, 𝔼 y, ∏ i, if choice i then f i x * f i y else 1) ≤ A) : + positiveKernelGram b f ≤ A := by + classical + let p := FiniteProbabilityWeights.pi (fun _ : I => countingBernoulli hb hb1) + have hpoint (x y : X) : (∏ i, positiveCountingKernel b (f i x) (f i y)) = + p.mean (fun choice => ∏ i, if choice i then f i x * f i y else 1) := by + simpa only [positiveCountingKernel, mul_assoc] using + (countingBernoulli_product hb hb1 (fun i => f i x * f i y)).symm + calc + positiveKernelGram b f = + p.mean (fun choice => 𝔼 x, 𝔼 y, ∏ i, if choice i then f i x * f i y else 1) := by + simp only [positiveKernelGram, hpoint, FiniteProbabilityWeights.mean_finset_expect] + _ ≤ p.mean (fun _ => A) := p.mean_mono h + _ = A := p.mean_const A + +theorem countingKernelProductAverage_abs_le_of_boolean_products {I X Y : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] {b A : ℝ} + (hb : 0 ≤ b) (hb1 : b ≤ 1) (hA : 0 ≤ A) (f : I → X → ℝ) (g : I → Y → ℝ) + (hf : ∀ choice : I → Bool, (𝔼 x, 𝔼 y, ∏ i, if choice i then f i x * f i y else 1) ≤ A) + (hg : ∀ choice : I → Bool, (𝔼 x, 𝔼 y, ∏ i, if choice i then g i x * g i y else 1) ≤ A) : + |countingKernelProductAverage b f g| ≤ A := + countingKernelProductAverage_abs_le hb hb1 hA f g + (positiveKernelGram_le_of_boolean_products hb hb1 f hf) + (positiveKernelGram_le_of_boolean_products hb hb1 g hg) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem countingKernelProductAverage_outer_sq_le {I X Y Z : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] [Fintype Z] + {b : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) + (f : Z → I → X → ℝ) (g : Z → I → Y → ℝ) : + (𝔼 z, countingKernelProductAverage b (f z) (g z)) ^ 2 ≤ + (𝔼 z, positiveKernelGram b (f z)) * (𝔼 z, positiveKernelGram b (g z)) := by + let t := Real.sqrt (b * (1 - b)) + have ht : t ^ 2 = b * (1 - b) := Real.sq_sqrt (mul_nonneg hb (sub_nonneg.mpr hb1)) + have hnt : (-t) ^ 2 = b * (1 - b) := by simpa only [neg_sq] using ht + let U : Z × (I → Bool) → ℝ := fun q => 𝔼 x, countingFeatureProduct b t (f q.1) q.2 x + let V : Z × (I → Bool) → ℝ := fun q => 𝔼 y, countingFeatureProduct b (-t) (g q.1) q.2 y + have hleft : (𝔼 q, U q * V q) = 𝔼 z, countingKernelProductAverage b (f z) (g z) := by + rw [expect_prod_split] + simp only [U, V, ← countingKernelProductAverage_factorization ht] + have hrightU : (𝔼 q, U q ^ 2) = 𝔼 z, positiveKernelGram b (f z) := by + rw [expect_prod_split] + simp only [U, countingFeatureProduct_square ht] + have hrightV : (𝔼 q, V q ^ 2) = 𝔼 z, positiveKernelGram b (g z) := by + rw [expect_prod_split] + simp only [V, countingFeatureProduct_square hnt] + simpa only [hleft, hrightU, hrightV] using + Finset.expect_mul_sq_le_sq_mul_sq Finset.univ U V + +theorem mean_positiveKernelGram_le_of_boolean_products {I X Z : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Z] + {b A : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (f : Z → I → X → ℝ) + (h : ∀ choice : I → Bool, + (𝔼 z, 𝔼 x, 𝔼 y, ∏ i, if choice i then f z i x * f z i y else 1) ≤ A) : + (𝔼 z, positiveKernelGram b (f z)) ≤ A := by + classical + let p := FiniteProbabilityWeights.pi (fun _ : I => countingBernoulli hb hb1) + have hpoint (z : Z) (x y : X) : (∏ i, positiveCountingKernel b (f z i x) (f z i y)) = + p.mean (fun choice => ∏ i, if choice i then f z i x * f z i y else 1) := by + simpa only [positiveCountingKernel, mul_assoc] using + (countingBernoulli_product hb hb1 (fun i => f z i x * f z i y)).symm + calc + (𝔼 z, positiveKernelGram b (f z)) = + p.mean (fun choice => 𝔼 z, 𝔼 x, 𝔼 y, ∏ i, if choice i then f z i x * f z i y else 1) := by + simp only [positiveKernelGram, hpoint, FiniteProbabilityWeights.mean_finset_expect] + _ ≤ p.mean (fun _ => A) := p.mean_mono h + _ = A := p.mean_const A + +theorem countingKernelProductAverage_outer_abs_le {I X Y Z : Type*} + [Fintype I] [DecidableEq I] [Fintype X] [Fintype Y] [Fintype Z] + {b A : ℝ} (hb : 0 ≤ b) (hb1 : b ≤ 1) (hA : 0 ≤ A) + (f : Z → I → X → ℝ) (g : Z → I → Y → ℝ) + (hf : ∀ choice : I → Bool, + (𝔼 z, 𝔼 x, 𝔼 y, ∏ i, if choice i then f z i x * f z i y else 1) ≤ A) + (hg : ∀ choice : I → Bool, + (𝔼 z, 𝔼 x, 𝔼 y, ∏ i, if choice i then g z i x * g z i y else 1) ≤ A) : + |𝔼 z, countingKernelProductAverage b (f z) (g z)| ≤ A := by + have hsq := (countingKernelProductAverage_outer_sq_le hb hb1 f g).trans + (mul_le_mul (mean_positiveKernelGram_le_of_boolean_products hb hb1 f hf) + (mean_positiveKernelGram_le_of_boolean_products hb hb1 g hg) + (Finset.expect_nonneg (fun z _ => positiveKernelGram_nonneg hb hb1 (g z))) hA) + nlinarith [sq_abs (𝔼 z, countingKernelProductAverage b (f z) (g z)), + abs_nonneg (𝔼 z, countingKernelProductAverage b (f z) (g z))] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CoveredJetProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/CoveredJetProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d1c0b127a6bbb09ba34c0d7d116af7bced91c7d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CoveredJetProjection.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.Progressions.Estimates.CoveredMixedArrayImage + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory + +variable {α K : Type*} [Fintype α] [DecidableEq α] [Fintype K] {m : ℕ} +variable {O J : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (root : K → ℤ) (A : Matrix α K ℤ) (rows : ∀ j, O j → Finset α) + +omit [∀ j, Fintype (O j)] in +theorem euclideanCoefficientJetMap_cover (d : ℕ) (x : CoefficientTorus (K := K) U) : + euclideanCoefficientJetMap U root A rows + (quotientIntegerCover (coefficientIntegerLattice U) d x) = + d • euclideanCoefficientJetMap U root A rows x := + map_nsmul (euclideanCoefficientJetMap U root A rows) d x + +variable [CompactSpace (CoefficientTorus (K := K) U)] +variable [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] +variable (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + +theorem coefficientCover_density_map (d : ℕ) (hd : 0 < d) + (D : CoefficientTorus (K := K) U → ℝ) (hD : Measurable D) (hi : Integrable D μ) + (h0 : ∀ x, 0 ≤ D x) : + (realDensityMeasure μ (fun x => D (quotientIntegerCover (coefficientIntegerLattice U) d x))).map + (quotientIntegerCover (coefficientIntegerLattice U) d) = realDensityMeasure μ D := + measurePreserving_realDensity_map μ μ _ (coefficientCover_measurePreserving U μ d hd) D hD hi h0 + +theorem coveredEuclideanJet_density_projection (d : ℕ) (hd : 0 < d) + (D : CoefficientTorus (K := K) U → ℝ) (hD : Measurable D) (hi : Integrable D μ) + (h0 : ∀ x, 0 ≤ D x) (ξ : Measure (EuclideanJetLayers U O)) + (f : EuclideanJetLayers U O → ℝ) + (hlaw : (realDensityMeasure μ + (fun x => D (quotientIntegerCover (coefficientIntegerLattice U) d x))).map + (euclideanCoefficientJetMap U root A rows) = realDensityMeasure ξ f) : + (realDensityMeasure ξ f).map (fun z => d • z) = + (realDensityMeasure μ D).map (euclideanCoefficientJetMap U root A rows) := by + have hF := (euclideanCoefficientJetMap_continuous U root A rows).measurable + have hC := (quotientIntegerCover_continuous (coefficientIntegerLattice (K := K) U) d).measurable + have hn : Measurable (fun z : EuclideanJetLayers U O => d • z) := + (continuous_id.nsmul d).measurable + rw [← hlaw, Measure.map_map hn hF] + have he : (fun z : EuclideanJetLayers U O => d • z) ∘ euclideanCoefficientJetMap U root A rows = + euclideanCoefficientJetMap U root A rows ∘ quotientIntegerCover (coefficientIntegerLattice U) d := + funext (fun x => (euclideanCoefficientJetMap_cover U root A rows d x).symm) + rw [he, ← Measure.map_map hF hC, coefficientCover_density_map U μ d hd D hD hi h0] + +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +include ν in +theorem coveredCanonicalJet_density_projection + (c w : ∀ j : Fin m, I j → BoundedCoefficientExponent K (j.val + 1) → ℝ) + (p : ∀ j : Fin m, Fin (n j) → BoundedCoefficientExponent K (j.val + 1) → PMF ℤ) + (hw : ∀ j i e, 0 < w j i e) + (hs : ∀ j e x, mixedCoefficientDensity (fun i => c j i e) (fun i => w j i e) + (fun i => p j i e) x ≠ 0 → normalizedLatticePoint (euclideanSubspace (U j)) (b j) + (orthonormalMixedChart (o j) x) ∈ standardLatticeSmallBox (J j)) + (d : ℕ) (hd : 0 < d) (ξ : Measure (EuclideanJetLayers U O)) (f : EuclideanJetLayers U O → ℝ) + (hlaw : (realDensityMeasure μ (fun x => canonicalCoefficientDensity U b hb o c w p + (quotientIntegerCover (coefficientIntegerLattice U) d x))).map + (euclideanCoefficientJetMap U root A rows) = realDensityMeasure ξ f) : + (realDensityMeasure ξ f).map (fun z => d • z) = + (Measure.pi (fun j => mixedScalarArrayLaw (c j) (w j) (p j))).map + (fun x j => mixedArrayQuotient (euclideanSubspace (U j)) (b j) (hb j) (o j) + (canonicalCoefficientJetArrays root A rows x j)) := by + have hi := (canonicalCoefficientDensity_mass U b hb o c w p μ ν hw hs).1 + exact (coveredEuclideanJet_density_projection U root A rows μ d hd + (canonicalCoefficientDensity U b hb o c w p) + (canonicalCoefficientDensity_measurable U b hb o c w p) hi + (canonicalCoefficientDensity_nonneg U b hb o c w p hw) ξ f hlaw).trans + (canonicalCoefficientJetArrays_quotient_law U b hb o root A rows μ ν c w p hw hs).symm + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelApproximation.lean b/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1e91c87bcbf888fbc27d464dfb08030fe6cb68b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelApproximation.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.Progressions.Geometry.CubicBoxStepDrop + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def NativeIntegerExpansion.tripleBoxSlice {s : ℕ} {p : ℝ} + {F : (Fin 6 → ℤ) → ℂ} (E : NativeIntegerExpansion (fun _ : Fin 6 => 1) s p F) + (a : Fin 3 → ℤ) : NativeIntegerExpansion (fun _ : Fin 3 => 1) s p + (fun z => F (Erdos3.tripleBoxSlice a z)) := by + let A : Fin 6 → Fin 3 → ℤ := + ![![1, 0, 0], ![0, 0, 0], ![0, 1, 0], ![0, 0, 0], ![0, 0, 1], ![0, 0, 0]] + let b : Fin 6 → ℤ := ![0, a 0, 0, a 1, 0, a 2] + have hmap (z : Fin 3 → ℤ) : integerAffineMap A b z = Erdos3.tripleBoxSlice a z := by + funext k + have hlast : (5 : Fin 6) = (4 : Fin 5).succ := rfl + fin_cases k <;> norm_num [A, b, integerAffineMap, Erdos3.tripleBoxSlice, + Fin.sum_univ_three, hlast, Matrix.cons_val_succ, Matrix.cons_val_two, + Matrix.head_cons, Matrix.tail_cons] + have heq : (fun z => F (integerAffineMap A b z)) = + (fun z => F (Erdos3.tripleBoxSlice a z)) := by + funext z + rw [hmap] + exact heq ▸ E.affinePullback A b + +theorem exists_cubic_kernel_approximation : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p q : ℝ} + (V : NativeMultidegreeNilcharacter (fun _ : CubicReplicatedIndex => 1) p) + {N : ℕ} [NeZero N] (i j : Fin V.outputDim × Fin V.outputDim) (shift : ℤ) + (F : (Fin 6 → ℤ) → ℂ), 0 ≤ q → + NativeIntegerExpansion (fun _ : Fin 6 => 1) 2 q F → + (∀ x : Fin 6 → ZMod N, ‖F (fun k => ((x k).val : ℤ))‖ ≤ 1) → + ∀ {δ ε : ℝ}, 0 < δ → 0 < ε → + δ ≤ (finiteTripleBoxCorrelation (fun k h y : ZMod N => + V.cubicAntisymmetricPair i j h.val y.val ((k.val : ℤ) + shift))).re → + (𝔼 x : Fin 6 → ZMod N, + ‖V.cubicAntisymmetricBoxValue i j shift (fun k => ((x k).val : ℤ)) - + F (fun k => ((x k).val : ℤ))‖) ≤ ε → + ∃ D G : (Fin 3 → ℤ) → ℂ, + Nonempty (NativeIntegerExpansion (fun _ : Fin 3 => 1) 2 ((p + q + C) ^ C) D) ∧ + Nonempty (NativeIntegerExpansion (fun _ : Fin 3 => 1) 2 ((p + q + C) ^ C) G) ∧ + (∀ z, ‖D z‖ ≤ 1) ∧ + (∀ z : Fin 3 → ZMod N, ‖G (fun k => ((z k).val : ℤ))‖ ≤ 1) ∧ + δ ^ 2 / 2 ≤ (𝔼 z : Fin 3 → ZMod N, ‖D (fun k => ((z k).val : ℤ))‖ ^ 2) ∧ + δ ^ 2 / 2 ≤ (𝔼 z : Fin 3 → ZMod N, + ‖V.cubicAntisymmetricPair i j ((z 1).val : ℤ) ((z 2).val : ℤ) + (((z 0).val : ℤ) + shift) * D (fun k => ((z k).val : ℤ))‖ ^ 2) ∧ + (𝔼 z : Fin 3 → ZMod N, + ‖V.cubicAntisymmetricPair i j ((z 1).val : ℤ) ((z 2).val : ℤ) + (((z 0).val : ℤ) + shift) * D (fun k => ((z k).val : ℤ)) - + G (fun k => ((z k).val : ℤ))‖) ≤ 2 * ε / δ ^ 2 := by + obtain ⟨A, _, hanchor⟩ := NativeMultidegreeNilcharacter.exists_cubic_anchor_expansion + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((X + Polynomial.C A) ^ A + X) + refine ⟨C, hC, ?_⟩ + intro p q V N _ i j shift F hq EF hFunit δ ε hδ hε hbias herr + have hp : 0 ≤ p := (Nat.cast_nonneg V.dim).trans V.complexity.1.1 + let K := fun k h y : ℤ => V.cubicAntisymmetricPair i j h y (k + shift) + let Kc := fun k h y : ZMod N => K k.val h.val y.val + let Fc := fun x : Fin 6 → ZMod N => F (fun k => ((x k).val : ℤ)) + obtain ⟨a, hmass, henergy, herror⟩ := exists_triple_box_anchor_approximation Kc + (fun k h y => V.cubicAntisymmetricPair_norm i j _ _ _) Fc hδ hε hbias herr + let b : Fin 3 → ℤ := fun k => ((a k).val : ℤ) + let D := tripleBoxAnchorFactor K b + let G := fun z : Fin 3 → ℤ => F (tripleBoxSlice b z) + obtain ⟨ED⟩ := hanchor V i j shift b + have hsum : (p + q + A) ^ A + (p + q) ≤ (p + q + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget (p + q) (add_nonneg hp hq) + have hDb : (p + A) ^ A ≤ (p + q + C) ^ C := by + have hmono : (p + A) ^ A ≤ (p + q + A) ^ A := by + apply pow_le_pow_left₀ (by positivity) + linarith only [hq] + exact hmono.trans ((le_add_of_nonneg_right (add_nonneg hp hq)).trans hsum) + have hGb : q ≤ (p + q + C) ^ C := by + have hpow : 0 ≤ (p + q + A) ^ A := by positivity + linarith only [hsum, hpow, hp] + have hcan (z : Fin 3 → ZMod N) : + (fun k => ((tripleBoxSlice a z k).val : ℤ)) = + tripleBoxSlice b (fun k => ((z k).val : ℤ)) := by + funext k + fin_cases k <;> rfl + refine ⟨D, G, ⟨ED.mono hDb⟩, ⟨(EF.tripleBoxSlice b).mono hGb⟩, ?_, ?_, hmass, henergy, ?_⟩ + · exact tripleBoxAnchorFactor_norm_le_one K (fun k h y => V.cubicAntisymmetricPair_norm i j _ _ _) b + · intro z + simpa only [hcan, G] using hFunit (tripleBoxSlice a z) + · simpa only [Fc, hcan, Kc, K, D, G, tripleBoxAnchorFactor, b] using herror + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelCorrelatedModel.lean b/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelCorrelatedModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..c80db9baa36567fdf7feb97ae1e9f565b699f874 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelCorrelatedModel.lean @@ -0,0 +1,71 @@ +import OAI.Combinatorics.Progressions.Geometry.CubicBoxStepDrop + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_cubic_kernel_correlated_model : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + Real.exp ((p + C) ^ C) ≤ (N : ℝ) → + ∀ f : ZMod N → ℂ, (∀ x, ‖f x‖ ≤ 1) → Real.exp (-p) ≤ gowersNorm 4 f → + ∃ H : Finset (ZMod N), H.Nonempty ∧ Real.exp (-((p + C) ^ C)) * N ≤ (H.card : ℝ) ∧ + ∃ M : NativeMultidegreeNilcharacter (mixedCorrelationDegree 2) ((p + C) ^ C), + ∃ V : NativeMultidegreeNilcharacter (fun _ : CubicReplicatedIndex => 1) ((p + C) ^ C), + V.dim ≤ 8 * M.dim ∧ + (∀ (e : ReplicatedPermutation (mixedCorrelationDegree 2)) k x, + V.eval k (fun j => x ((replicatedPermutation (mixedCorrelationDegree 2) e).symm j)) = + V.eval k x) ∧ + NativeIntegerVectorEquivalence 2 ((p + C) ^ C) + M.eval (fun k x => V.eval k (fun j => x j.1)) ∧ + NativeIntegerVectorEquivalence 2 ((p + C) ^ C) + M.cubicMixedDerivative V.cubicTrilinearTriple ∧ + ∃ out : Fin M.outputDim, ∃ χ : ZMod N → AddChar (ZMod N) ℂ, + (∀ h ∈ H, Real.exp (-((p + C) ^ C)) ≤ ‖finiteFourierCoeff + (fun n => multiplicativeDerivative f h n * star (M.evalCyclic N out (correlationInput h n))) (χ h)‖) ∧ + ∃ (branch : Bool) (i j : Fin V.outputDim × Fin V.outputDim), + Nonempty (NativeSampleCorrelation (fun _ : Fin 3 => 1) 2 ((p + C) ^ C) + Finset.univ (fun z : Fin 3 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => V.cubicAntisymmetricPair i j (z 1).val (z 2).val + (cyclicBranchOffset (z 0) branch))) := by + obtain ⟨a, _, hmodel⟩ := exists_cubic_antisymmetric_box + obtain ⟨b, _, hcorrelate⟩ := exists_cubic_kernel_correlation + let X : Polynomial ℕ := Polynomial.X + let Q := (X + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Q + (Q + Polynomial.C b) ^ b) + refine ⟨C, hC, ?_⟩ + intro N _ p hp hN f hf hGowers + let q := (p + a) ^ a + have hq : 0 ≤ q := by dsimp only [q]; positivity + have hsum : q + (q + b) ^ b ≤ (p + C) ^ C := by + simpa [X, Q, q, Polynomial.eval₂_pow] using hbudget p hp + have hpow : 0 ≤ (q + b) ^ b := by positivity + have hqC : q ≤ (p + C) ^ C := by linarith only [hsum, hpow] + have hbC : (q + b) ^ b ≤ (p + C) ^ C := by linarith only [hsum, hq] + obtain ⟨H, hH, hHdense, M, V, hdim, hsymm, hdiag, E, out, χ, hcorr, branch, i, j, hbias⟩ := + hmodel hp ((Real.exp_le_exp.mpr hqC).trans hN) f hf hGowers + let shift : ℤ := -(if branch then (N : ℤ) else 0) + have hbias' : Real.exp (-q) ≤ (finiteTripleBoxCorrelation (fun k h y : ZMod N => + V.cubicAntisymmetricPair i j h.val y.val ((k.val : ℤ) + shift))).re := by + simpa only [shift, cyclicBranchOffset, sub_eq_add_neg] using hbias + obtain ⟨W⟩ := hcorrelate hq V i j shift hbias' + refine ⟨H, hH, ?_, M.mono hqC, V.mono hqC, ?_, hsymm, hdiag.mono hqC, E.mono hqC, + out, χ, ?_, branch, i, j, ?_⟩ + · exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hqC)) + (Nat.cast_nonneg _)).trans hHdense + · change V.dim ≤ 8 * M.dim + exact hdim + · intro h hh + exact (Real.exp_le_exp.mpr (neg_le_neg hqC)).trans (hcorr h hh) + · have hW := W.mono hbC + exact ⟨by simpa only [NativeMultidegreeNilcharacter.cubicAntisymmetricPair, + NativeMultidegreeNilcharacter.mono_eval, cyclicBranchOffset, shift, sub_eq_add_neg] using hW⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelCorrelation.lean b/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba7db018b01ef1028827ee3557266b92995fd754 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/CubicKernelCorrelation.lean @@ -0,0 +1,55 @@ +import OAI.Combinatorics.Progressions.Estimates.CubicAnchorExpansion + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_triple_box_anchor_correlation {X : Type*} [Fintype X] [Nonempty X] + (K : X → X → X → ℂ) : + ∃ a : Fin 3 → X, (finiteTripleBoxCorrelation K).re ≤ + ‖𝔼 z : Fin 3 → X, K (z 0) (z 1) (z 2) * tripleBoxAnchorFactor K a z‖ := by + have hmean : (finiteTripleBoxCorrelation K).re = + 𝔼 a : Fin 3 → X, (𝔼 z : Fin 3 → X, + K (z 0) (z 1) (z 2) * tripleBoxAnchorFactor K a z).re := by + rw [← tripleBoxKernel_mean, expect_tripleBoxSlice, expect_re] + simp_rw [tripleBoxKernel_slice] + obtain ⟨a, _, ha⟩ := Finset.exists_le_of_le_expect Finset.univ_nonempty hmean.le + exact ⟨a, ha.trans (Complex.re_le_norm _)⟩ + +theorem exists_cubic_kernel_correlation : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ}, 0 ≤ p → + ∀ (V : NativeMultidegreeNilcharacter (fun _ : CubicReplicatedIndex => 1) p) + {N : ℕ} [NeZero N] (i j : Fin V.outputDim × Fin V.outputDim) (shift : ℤ), + Real.exp (-p) ≤ (finiteTripleBoxCorrelation (fun k h y : ZMod N => + V.cubicAntisymmetricPair i j h.val y.val ((k.val : ℤ) + shift))).re → + Nonempty (NativeSampleCorrelation (fun _ : Fin 3 => 1) 2 ((p + C) ^ C) + Finset.univ (fun z : Fin 3 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => V.cubicAntisymmetricPair i j (z 1).val (z 2).val (((z 0).val : ℤ) + shift))) := by + obtain ⟨A, _, hanchor⟩ := NativeMultidegreeNilcharacter.exists_cubic_anchor_expansion + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (X + (X + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro p hp V N _ i j shift hbias + let K := fun k h y : ℤ => V.cubicAntisymmetricPair i j h y (k + shift) + let Kc := fun k h y : ZMod N => K k.val h.val y.val + obtain ⟨a, ha⟩ := exists_triple_box_anchor_correlation Kc + obtain ⟨E⟩ := hanchor V i j shift (fun k => ((a k).val : ℤ)) + have hcorr : Real.exp (-p) ≤ ‖𝔼 z : Fin 3 → ZMod N, + V.cubicAntisymmetricPair i j (z 1).val (z 2).val (((z 0).val : ℤ) + shift) * + star (star (tripleBoxAnchorFactor K (fun k => ((a k).val : ℤ)) + (fun k => ((z k).val : ℤ))))‖ := by + simpa only [Kc, K, tripleBoxAnchorFactor, star_star] using hbias.trans ha + obtain ⟨W⟩ := NativeSampleCorrelation.exists_of_expansion E.conjugate hp hcorr + have hcost : p + (p + A) ^ A ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨W.mono hcost⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DerivativeVerticalBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/DerivativeVerticalBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..36680440191b8c4c1ffa16bbe8a079cfb665468b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DerivativeVerticalBasis.lean @@ -0,0 +1,76 @@ +import OAI.Combinatorics.Progressions.Geometry.DerivativeVerticalCoordinates + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_vertical_derivative_grid_matrix + {σ κ : Type*} [Fintype σ] [Fintype κ] [DecidableEq κ] {k : ℕ} + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) + (l : ℕ) (hl : 0 < l) (v : Fin k → EuclideanSpace ℝ (σ ⊕ κ)) + (hli : LinearIndependent ℝ v) + (hv : ∀ j, v j ∈ euclideanDerivativeLattice T hT scale hscale Y A l hl) + (hzero : ∀ j, euclideanDerivativeShiftMap T hT (v j) = 0) : + ∃ B : Matrix κ (Fin k) ℝ, LinearIndependent ℝ B.col ∧ + (∀ j, B.col j ∈ realDenominatorGrid l) ∧ + ∀ j, v j = euclideanVerticalMap scale hscale A (B.col j) := by + choose r hr he using fun j => + euclideanDerivative_vertical_grid_coordinates T hT scale hscale Y A l hl (v j) (hv j) (hzero j) + let B : Matrix κ (Fin k) ℝ := fun i j => r j i + refine ⟨B, ?_, hr, he⟩ + apply LinearIndependent.of_comp (euclideanVerticalMap scale hscale A) + have hf : euclideanVerticalMap scale hscale A ∘ B.col = v := + funext (fun j => (he j).symm) + rw [hf] + exact hli + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_derivative_vertical_basis_matrix + {σ κ : Type*} [Fintype σ] [Fintype κ] [DecidableEq κ] + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) + (l : ℕ) (hl : 0 < l) (R : ℝ) : + let Λ := euclideanDerivativeLattice T hT scale hscale Y A l hl + let Z := shortVectorSpan Λ R + let π := (euclideanDerivativeShiftMap T hT).comp Z.subtype + let V := LinearMap.ker π + let L := latticeKernel (shortVectorLattice Λ R) π + ∃ b : Module.Basis (Fin (Module.finrank ℝ V)) ℤ L, + ∃ B : Matrix κ (Fin (Module.finrank ℝ V)) ℝ, + LinearIndependent ℝ B.col ∧ (∀ j, B.col j ∈ realDenominatorGrid l) ∧ + ∀ j, (b j).val.val.val = euclideanVerticalMap scale hscale A (B.col j) := by + let Λ := euclideanDerivativeLattice T hT scale hscale Y A l hl + let Z := shortVectorSpan Λ R + let π := (euclideanDerivativeShiftMap T hT).comp Z.subtype + let V := LinearMap.ker π + let L := latticeKernel (shortVectorLattice Λ R) π + let : IsZLattice ℝ L := euclideanDerivative_vertical_lattice_full T hT scale hscale Y A l hl R + let b := finiteLatticeBasis L + let f : V →ₗᵢ[ℝ] EuclideanSpace ℝ (σ ⊕ κ) := Z.subtypeₗᵢ.comp V.subtypeₗᵢ + let v := fun j => f (b j).val + have hli : LinearIndependent ℝ v := by + have h := (b.ofZLatticeBasis ℝ L).linearIndependent.map' f.toLinearMap + (LinearMap.ker_eq_bot.mpr f.injective) + simpa only [v, Function.comp_def, Module.Basis.ofZLatticeBasis_apply, + LinearIsometry.coe_toLinearMap] using h + have hv (j) : v j ∈ Λ := (b j).property + have hz (j) : euclideanDerivativeShiftMap T hT (v j) = 0 := (b j).val.property + obtain ⟨B, hB, hgrid, he⟩ := exists_vertical_derivative_grid_matrix + T hT scale hscale Y A l hl v hli hv hz + exact ⟨b, B, hB, hgrid, he⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DetectedTranslationLogProjectionHeight.lean b/lean/OAI/Combinatorics/Progressions/Linear/DetectedTranslationLogProjectionHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..58b755fe08798e1e58193558b0c364ce82b12e51 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DetectedTranslationLogProjectionHeight.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.Progressions.Estimates.DetectedTranslationNormalizedLogBounds +import OAI.Combinatorics.Progressions.Sampling.WeightedTranslationProjectionGridBudget + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open Module RationalFilteredNilmanifold + +variable {B L : Type} {U ι : Type*} [Fintype B] [LieRing L] [LieAlgebra ℚ L] + (w : B → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] (M : ℕ) (hM : 0 < M) + {e : ℕ} (D : RationalFilteredNilmanifold L d e) + (b : Basis ι ℚ (PairAlgebra (weightedSubalgebra w d) L)) (ω : ι → ℕ) + +theorem detectedTranslationLogProjectionMatrix_logHeight {p : ℝ} (hp : 0 ≤ p) + (hb : ∀ i j, rationalLogHeight + ((pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).basis.repr (b i) j) ≤ p) + (k : WeightedBasisIndex w d) (i : ι) : + rationalLogHeight (detectedTranslationLogProjectionMatrix w d hw b ω k i) ≤ p := by + unfold detectedTranslationLogProjectionMatrix + split_ifs + · exact pairResidueTranslationProjection_coordinate_logHeight w d hw hwd M hM D + (b i) (hb i) k + · simpa [rationalLogHeight] using hp + +theorem detectedTranslationLogProjectionMatrix_height_of_basis {p : ℝ} (hp : 0 ≤ p) + (hb : ∀ i j, rationalLogHeight + ((pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).basis.repr (b i) j) ≤ p) + (k : WeightedBasisIndex w d) (i : ι) : + RationalHeightLE (detectedTranslationLogProjectionMatrix w d hw b ω k i) ⌈Real.exp p⌉₊ := + rationalHeightLE_ceil_exp + (detectedTranslationLogProjectionMatrix_logHeight w d hw hwd M hM D b ω hp hb k i) + +variable (hN : ∀ j, + (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.layer j = + Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem exists_detectedTranslationLogCoordinate_grid_of_basis_height [Fintype ι] + {p : ℝ} (hp : 0 ≤ p) + (hb : ∀ i j, rationalLogHeight + ((pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).basis.repr (b i) j) ≤ p) + (m : ℕ) (hm : 0 < m) : + ∃ q : ℕ, 0 < q ∧ + q ≤ ⌈Real.exp p⌉₊ ^ (Fintype.card (WeightedBasisIndex w d) * Fintype.card ι) * m ∧ + ∀ E : (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.RealPolynomialSymbolGroup (fun _ : U => 1), + (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.SymbolRationalGrid + b ω hN (fun _ : U => 1) m E → + ∀ k, realPolynomialCoefficientGrid q + (detectedTranslationLogCoordinatePolynomial w d hw hwd M hM D E k) := + exists_detectedTranslationLogCoordinate_common_grid w d hw hwd M hM D b ω hN + (detectedTranslationLogProjectionMatrix_height_of_basis w d hw hwd M hM D b ω hp hb) m hm + +theorem detectedTranslationLogCoordinate_normalized_mass_of_basis_height [Fintype U] [Fintype ι] + {p : ℝ} (hp : 0 ≤ p) + (hb : ∀ i j, rationalLogHeight + ((pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).basis.repr (b i) j) ≤ p) + (T : U → ℝ) (hT : ∀ i, 0 < T i) {A : ℝ} (hA : 0 ≤ A) + (E : (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.RealPolynomialSymbolGroup (fun _ : U => 1)) + (hE : (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.SymbolSlowBound + b ω hN (fun _ : U => 1) T A E) (k : WeightedBasisIndex w d) : + realPolynomialMass (scaleMvPolynomialAxes T + (detectedTranslationLogCoordinatePolynomial w d hw hwd M hM D E k)) ≤ + ((Fintype.card U : ℝ) + 1) ^ d * + ((Fintype.card ι : ℝ) * (⌈Real.exp p⌉₊ : ℝ) * A) := + detectedTranslationLogCoordinate_normalized_mass w d hw hwd M hM D b ω hN + T hT hA (Nat.cast_nonneg _) k + (fun i => (detectedTranslationLogProjectionMatrix_height_of_basis + w d hw hwd M hM D b ω hp hb k i).abs_real_le) E hE + +theorem exists_detectedTranslationLogCoordinate_exp_grid_of_basis_height [Fintype ι] + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hb : ∀ i j, rationalLogHeight + ((pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).basis.repr (b i) j) ≤ p) + (m : ℕ) (hm : 0 < m) (hmp : (m : ℝ) ≤ Real.exp p) : + ∃ q : ℕ, 0 < q ∧ (q : ℝ) ≤ Real.exp ((p + 3) ^ 3) ∧ + ∀ E : (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.RealPolynomialSymbolGroup (fun _ : U => 1), + (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.SymbolRationalGrid + b ω hN (fun _ : U => 1) m E → + ∀ k, realPolynomialCoefficientGrid q + (detectedTranslationLogCoordinatePolynomial w d hw hwd M hM D E k) := by + obtain ⟨q, hq, hbound, hgrid⟩ := + exists_detectedTranslationLogCoordinate_grid_of_basis_height + w d hw hwd M hM D b ω hN hp hb m hm + refine ⟨q, hq, ?_, hgrid⟩ + apply detectedTranslationCoordinate_denominator_le_exp + (Fintype.card (WeightedBasisIndex w d)) (Fintype.card ι) m q hp _ hι hmp hbound + exact (Nat.cast_le.mpr (weightedBasisIndex_card_le_pair_basis w d hw b)).trans hι + +theorem detectedTranslationLogCoordinate_normalized_mass_exp_of_basis_height + [Fintype U] [Fintype ι] {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hb : ∀ i j, rationalLogHeight + ((pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).basis.repr (b i) j) ≤ p) + (T : U → ℝ) (hT : ∀ i, 0 < T i) + (E : (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.RealPolynomialSymbolGroup (fun _ : U => 1)) + (hE : (pi (pairModels (weightedTranslationResidueNilmanifold w d hw hwd M hM) D)).filtration.SymbolSlowBound + b ω hN (fun _ : U => 1) T (Real.exp p) E) (k : WeightedBasisIndex w d) : + realPolynomialMass (scaleMvPolynomialAxes T + (detectedTranslationLogCoordinatePolynomial w d hw hwd M hM D E k)) ≤ + ((Fintype.card U : ℝ) + 1) ^ d * Real.exp ((p + 3) ^ 3) := by + apply (detectedTranslationLogCoordinate_normalized_mass_of_basis_height + w d hw hwd M hM D b ω hN hp hb T hT (Real.exp_nonneg p) E hE k).trans + exact mul_le_mul_of_nonneg_left + (detectedTranslationCoordinate_slow_factor_le_exp (Fintype.card ι) hp hι) (by positivity) + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DeterminingMatrixDilation.lean b/lean/OAI/Combinatorics/Progressions/Linear/DeterminingMatrixDilation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba13324bd46b832c97a6e481605aa320c502d370 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DeterminingMatrixDilation.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.Progressions.Estimates.AveragedModeledPatchTransfer + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {d m : ℕ} + +def dilatedIntegerMatrix (q : ℕ) (M : Fin m → Fin d → ℤ) : Fin m → Fin d → ℤ := + fun i j => (q : ℤ) * M i j + +theorem dilatedIntegerMatrix_entry_dvd (q : ℕ) (M : Fin m → Fin d → ℤ) + (i : Fin m) (j : Fin d) : (q : ℤ) ∣ dilatedIntegerMatrix q M i j := + dvd_mul_right _ _ + +theorem dilatedIntegerMatrix_nonzero_original (q : ℕ) (M : Fin m → Fin d → ℤ) + {i : Fin m} {j : Fin d} (h : dilatedIntegerMatrix q M i j ≠ 0) : M i j ≠ 0 := by + intro hz + exact h (by simp [dilatedIntegerMatrix, hz]) + +theorem dilatedIntegerMatrix_nonzero_iff (q : ℕ) (M : Fin m → Fin d → ℤ) + (hq : 0 < q) (i : Fin m) (j : Fin d) : + dilatedIntegerMatrix q M i j ≠ 0 ↔ M i j ≠ 0 := by + have hqz : (q : ℤ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hq + simp only [dilatedIntegerMatrix, ne_eq, mul_eq_zero, hqz, false_or] + +theorem dilatedIntegerMatrix_support_relation (q : ℕ) (M : Fin m → Fin d → ℤ) + (R : Fin m → Fin d → Prop) (hR : ∀ i j, M i j ≠ 0 → R i j) : + ∀ i j, dilatedIntegerMatrix q M i j ≠ 0 → R i j := by + intro i j hij + exact hR i j (dilatedIntegerMatrix_nonzero_original q M hij) + +theorem dilatedIntegerMatrix_weights (q : ℕ) (M : Fin m → Fin d → ℤ) + (v : Fin m → ℕ) (w : Fin d → ℕ) + (hM : ∀ i j, M i j ≠ 0 → w j ≤ v i) : + ∀ i j, dilatedIntegerMatrix q M i j ≠ 0 → w j ≤ v i := + dilatedIntegerMatrix_support_relation q M (fun i j => w j ≤ v i) hM + +theorem realIntegerMatrix_dilated_div (q : ℕ) (M : Fin m → Fin d → ℤ) + (hq : 0 < q) (x : Fin d → ℝ) : + realIntegerMatrix (dilatedIntegerMatrix q M) (fun j => x j / (q : ℝ)) = + realIntegerMatrix M x := by + have hqr : (q : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hq + funext i + apply Finset.sum_congr rfl + intro j hj + simp only [dilatedIntegerMatrix, Int.cast_mul, Int.cast_natCast] + field_simp + +theorem dilatedIntegerMatrix_row_abs_sum (q : ℕ) (M : Fin m → Fin d → ℤ) + (i : Fin m) : + (∑ j, |(dilatedIntegerMatrix q M i j : ℝ)|) = + (q : ℝ) * ∑ j, |(M i j : ℝ)| := by + simp only [dilatedIntegerMatrix, Int.cast_mul, Int.cast_natCast, abs_mul, + abs_of_nonneg (Nat.cast_nonneg q : (0 : ℝ) ≤ q), Finset.mul_sum] + +theorem dilatedIntegerMatrix_row_abs_sum_le (q : ℕ) (M : Fin m → Fin d → ℤ) + (i : Fin m) {K : ℝ} (hK : (∑ j, |(M i j : ℝ)|) ≤ K) : + (∑ j, |(dilatedIntegerMatrix q M i j : ℝ)|) ≤ (q : ℝ) * K := by + rw [dilatedIntegerMatrix_row_abs_sum] + exact mul_le_mul_of_nonneg_left hK (Nat.cast_nonneg q) + +theorem dilatedIntegerMatrix_row_abs_sum_le_uniform (q : ℕ) (M : Fin m → Fin d → ℤ) + (K : ℝ) (hM : ∀ i, (∑ j, |(M i j : ℝ)|) ≤ K) : + ∀ i, (∑ j, |(dilatedIntegerMatrix q M i j : ℝ)|) ≤ (q : ℝ) * K := + fun i => dilatedIntegerMatrix_row_abs_sum_le q M i (hM i) + +theorem dilatedIntegerMatrix_projection_columns {A : Type*} [AddCommGroup A] + (q : ℕ) (M : Fin m → Fin d → ℤ) (π : (Fin m → ℤ) →+ A) + (hπ : ∀ j, π (fun i => M i j) = 0) : + ∀ j, π (fun i => dilatedIntegerMatrix q M i j) = 0 := by + intro j + change π ((q : ℤ) • (fun i => M i j)) = 0 + rw [map_zsmul, hπ, zsmul_zero] + +theorem recoveredIntegerLift_dilated_residue (q : ℕ) (M : Fin m → Fin d → ℤ) + (c : Fin m → ℤ) (k : Fin d → ℤ) : + (fun i => (recoveredIntegerLift (dilatedIntegerMatrix q M) c k i : ZMod q)) = + fun i => (c i : ZMod q) := + recoveredIntegerLift_residue _ q (dilatedIntegerMatrix_entry_dvd q M) c k + +theorem recoveredIntegerLift_dilated_projection {A : Type*} [AddCommGroup A] + (q : ℕ) (M : Fin m → Fin d → ℤ) (π : (Fin m → ℤ) →+ A) + (hπ : ∀ j, π (fun i => M i j) = 0) (c : Fin m → ℤ) (k : Fin d → ℤ) : + π (recoveredIntegerLift (dilatedIntegerMatrix q M) c k) = π c := + recoveredIntegerLift_projection _ π (dilatedIntegerMatrix_projection_columns q M π hπ) c k + +theorem recoveredIntegerLift_dilated_discrete_data {A X : Type*} [AddCommGroup A] + (q : ℕ) (M : Fin m → Fin d → ℤ) (π : (Fin m → ℤ) →+ A) + (hπ : ∀ j, π (fun i => M i j) = 0) + (F : (Fin m → ZMod q) → A → X) (c : Fin m → ℤ) (k : Fin d → ℤ) : + F (fun i => (recoveredIntegerLift (dilatedIntegerMatrix q M) c k i : ZMod q)) + (π (recoveredIntegerLift (dilatedIntegerMatrix q M) c k)) = + F (fun i => (c i : ZMod q)) (π c) := + recoveredIntegerLift_discrete_data _ q (dilatedIntegerMatrix_entry_dvd q M) π + (dilatedIntegerMatrix_projection_columns q M π hπ) F c k + +theorem recoveredSmallLift_dilated_div (q : ℕ) (M : Fin m → Fin d → ℤ) + (hq : 0 < q) (a e : Fin d → ℝ) (c : Fin m → ℤ) : + recoveredSmallLift (dilatedIntegerMatrix q M) + (fun j => a j / (q : ℝ)) c (fun j => e j / (q : ℝ)) = + recoveredSmallLift M a c e := by + have hqr : (q : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hq + funext i + apply congrArg (fun x : ℝ => x - c i) + apply Finset.sum_congr rfl + intro j hj + simp only [dilatedIntegerMatrix, Int.cast_mul, Int.cast_natCast] + field_simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DualAdjointAction.lean b/lean/OAI/Combinatorics/Progressions/Linear/DualAdjointAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c59932c8978821169e2c8f875bbbda4c3b22458 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DualAdjointAction.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Nilpotent.DualBCHDifferential + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +@[simp] theorem dualAdjoint_zero (g : NilpotentLieBCHGroup L s hnil) : + dualAdjoint g 0 = 0 := by + apply dualTangentElement_injective (hnil := hnil) + rw [← dualAdjoint_spec, dualTangentElement_zero, mul_one, mul_inv_cancel] + +theorem dualAdjoint_add (g : NilpotentLieBCHGroup L s hnil) (x y : L) : + dualAdjoint g (x + y) = dualAdjoint g x + dualAdjoint g y := by + apply dualTangentElement_injective (hnil := hnil) + rw [← dualAdjoint_spec, ← dualTangentElement_mul, ← dualTangentElement_mul, + ← dualAdjoint_spec, ← dualAdjoint_spec] + group + +@[simp] theorem dualAdjoint_neg (g : NilpotentLieBCHGroup L s hnil) (x : L) : + dualAdjoint g (-x) = -dualAdjoint g x := by + apply dualTangentElement_injective (hnil := hnil) + rw [← dualAdjoint_spec, dualAdjoint_neg_spec] + +theorem dualAdjoint_sub (g : NilpotentLieBCHGroup L s hnil) (x y : L) : + dualAdjoint g (x - y) = dualAdjoint g x - dualAdjoint g y := by + simp only [sub_eq_add_neg, dualAdjoint_add, dualAdjoint_neg] + +@[simp] theorem dualAdjoint_one (x : L) : + dualAdjoint (1 : NilpotentLieBCHGroup L s hnil) x = x := by + apply dualTangentElement_injective (hnil := hnil) + rw [← dualAdjoint_spec, map_one, one_mul, inv_one, mul_one] + +theorem dualAdjoint_mul (g h : NilpotentLieBCHGroup L s hnil) (x : L) : + dualAdjoint (g * h) x = dualAdjoint g (dualAdjoint h x) := by + apply dualTangentElement_injective (hnil := hnil) + rw [← dualAdjoint_spec, ← dualAdjoint_spec, ← dualAdjoint_spec, map_mul] + group + +@[simp] theorem dualAdjoint_inv_cancel (g : NilpotentLieBCHGroup L s hnil) (x : L) : + dualAdjoint g⁻¹ (dualAdjoint g x) = x := by + rw [← dualAdjoint_mul, inv_mul_cancel, dualAdjoint_one] + +@[simp] theorem dualAdjoint_cancel_inv (g : NilpotentLieBCHGroup L s hnil) (x : L) : + dualAdjoint g (dualAdjoint g⁻¹ x) = x := by + rw [← dualAdjoint_mul, mul_inv_cancel, dualAdjoint_one] + +theorem dualAdjoint_injective (g : NilpotentLieBCHGroup L s hnil) : + Function.Injective (dualAdjoint g) := by + intro x y h + simpa only [dualAdjoint_inv_cancel] using congrArg (dualAdjoint g⁻¹) h + +noncomputable def dualAdjointAddEquiv (g : NilpotentLieBCHGroup L s hnil) : L ≃+ L where + toFun := dualAdjoint g + invFun := dualAdjoint g⁻¹ + left_inv := dualAdjoint_inv_cancel g + right_inv := dualAdjoint_cancel_inv g + map_add' := dualAdjoint_add g + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DualAdjointFiltration.lean b/lean/OAI/Combinatorics/Progressions/Linear/DualAdjointFiltration.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c92f8ccba611cd6b36498969105c7b36ccd780f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DualAdjointFiltration.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Linear.DualIdealSteps + +namespace OAI + + +namespace Erdos3 + +namespace NilpotentLieBCHGroup + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +theorem map_dualAdjoint (φ : L →ₗ⁅ℚ⁆ M) (g : NilpotentLieBCHGroup L s hL) (x : L) : + φ (dualAdjoint g x) = dualAdjoint (map (hM := hM) φ g) (φ x) := + dualLinearLift_adjoint hM ⊤ φ φ.toLinearMap (fun a b _ => φ.map_lie a b) g x (by trivial) + +theorem dualAdjoint_eq_self_of_lie_eq_zero (g : NilpotentLieBCHGroup L s hL) (x : L) + (hgx : ⁅g.coord, x⁆ = 0) : dualAdjoint g x = x := by + have hc : Commute (dualConstantHom g) (dualTangentElement x) := by + apply commute_of_lie_eq_zero + change ⁅dualConstantLie g.coord, dualInfinitesimal x⁆ = 0 + rw [dualConstant_infinitesimal_lie, hgx, map_zero] + apply dualTangentElement_injective (hnil := hL) + rw [← dualAdjoint_spec, hc.eq, mul_assoc, mul_inv_cancel, mul_one] + +theorem dualAdjoint_sub_mem_ideal (I : LieIdeal ℚ L) (g : NilpotentLieBCHGroup L s hL) + (x : L) (hgx : ⁅g.coord, x⁆ ∈ I) : dualAdjoint g x - x ∈ I := by + have hz : ⁅(quotientHom I g).coord, lieQuotientMap I x⁆ = 0 := by + rw [quotientHom_coord, ← LieHom.map_lie] + exact (lieQuotientMap_eq_zero I _).mpr hgx + apply (lieQuotientMap_eq_zero I _).mp + rw [map_sub, map_dualAdjoint (hM := lie_quotient_lowerCentralSeries_eq_bot hL I)] + exact sub_eq_zero.mpr (dualAdjoint_eq_self_of_lie_eq_zero (quotientHom I g) _ hz) + +end NilpotentLieBCHGroup + +namespace NilpotentLieFiltration + +open NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} (F : NilpotentLieFiltration L s) + +theorem dualAdjoint_sub_mem_layer {i j : ℕ} (g : F.Group) (hg : g.coord ∈ F.layer i) + (x : L) (hx : x ∈ F.layer j) : dualAdjoint g x - x ∈ F.layer (i + j) := + dualAdjoint_sub_mem_ideal (F.layerIdeal (i + j)) g x (F.lie_mem hg hx) + +theorem dualAdjoint_mem_layer (j : ℕ) (g : F.Group) (x : L) (hx : x ∈ F.layer j) : + dualAdjoint g x ∈ F.layer j := dualAdjoint_mem_ideal (F.layerIdeal j) g x hx + +theorem dualAdjoint_sub_mem_next_layer (j : ℕ) (g : F.Group) (x : L) (hx : x ∈ F.layer j) : + dualAdjoint g x - x ∈ F.layer (j + 1) := by + have hg : g.coord ∈ F.layer 1 := by rw [F.one_eq_top]; trivial + simpa only [Nat.add_comm 1 j] using F.dualAdjoint_sub_mem_layer g hg x hx + +end NilpotentLieFiltration +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DualDerivativeRemoval.lean b/lean/OAI/Combinatorics/Progressions/Linear/DualDerivativeRemoval.lean new file mode 100644 index 0000000000000000000000000000000000000000..58dfa9a839bc7df5c74e3d64b0e03eebe6c2fc52 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DualDerivativeRemoval.lean @@ -0,0 +1,160 @@ +import OAI.Combinatorics.Progressions.Nilpotent.FilteredAdjointFirstBracket + +namespace OAI + +section + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +namespace NilpotentLieBCHGroup + +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dualLogDerivative_sub_tangent_mem (hs : 1 ≤ s) + (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + (z : DualGroup hnil) (hb : dualBaseLinear z.coord ∈ U) + (hbr : ⁅dualBaseLinear z.coord, dualTangentLinear z.coord⁆ ∈ V) : + dualLogDerivative z - dualTangentLinear z.coord ∈ V := by + let S := dualBaseSubalgebra U + let I := dualInvariantTangentIdeal U V hUV + let a : S := ⟨z.coord, ⟨hb, by trivial⟩⟩ + let b : S := ⟨-dualConstantLie (dualBaseLinear z.coord), by + change dualBaseLinear (-dualConstantLie (dualBaseLinear z.coord)) ∈ U ∧ _ + constructor + · rw [map_neg, dualBaseLinear_constant] + exact U.neg_mem hb + · trivial⟩ + have hab : ⁅a, b⁆ ∈ I := by + change dualBaseLinear ⁅z.coord, -dualConstantLie (dualBaseLinear z.coord)⁆ = 0 ∧ + dualTangentLinear ⁅z.coord, -dualConstantLie (dualBaseLinear z.coord)⁆ ∈ V + simp only [dualBaseLinear_lie, dualTangentLinear_lie, map_neg, + dualBaseLinear_constant, dualTangentLinear_constant, neg_zero, lie_zero, + zero_add, lie_neg, lie_self] + rw [lie_skew] + exact ⟨trivial, hbr⟩ + have he : lieBCH s a b - (a + b) ∈ I := by + apply (lieQuotientMap_eq_zero I _).mp + rw [map_sub, map_add, map_lieBCH] + have hzero : ⁅lieQuotientMap I a, lieQuotientMap I b⁆ = 0 := by + rw [← LieHom.map_lie] + exact (lieQuotientMap_eq_zero I _).mpr hab + rw [lieBCH_eq_add_of_lie_eq_zero_pos hs hzero, sub_self] + have h := he.2 + change dualTangentLinear (S.incl (lieBCH s a b - (a + b))) ∈ V at h + simp only [map_sub, map_add, map_lieBCH] at h + change dualTangentLinear + (lieBCH s z.coord (-dualConstantLie (dualBaseLinear z.coord))) - + (dualTangentLinear z.coord + + dualTangentLinear (-dualConstantLie (dualBaseLinear z.coord))) ∈ V at h + simp only [map_neg, dualTangentLinear_constant, neg_zero, add_zero] at h + exact h + +end NilpotentLieBCHGroup + +namespace NilpotentLieFiltration + +open NilpotentLieBCHGroup + +variable {s : ℕ} (F : NilpotentLieFiltration L s) + +theorem dualLogDerivative_sub_tangent_mem_layer (hs : 1 ≤ s) {i j : ℕ} + (z : DualGroup F.lowerCentralSeries_eq_bot) + (hb : dualBaseLinear z.coord ∈ F.layer i) + (ht : dualTangentLinear z.coord ∈ F.layer j) : + dualLogDerivative z - dualTangentLinear z.coord ∈ F.layer (i + j) := by + exact dualLogDerivative_sub_tangent_mem hs ⊤ (F.layerIdeal (i + j)).toSubmodule + (fun _ _ _ hv => (F.layerIdeal _).lie_mem hv) z (by trivial) (F.lie_mem hb ht) + +theorem logDerivative_current_layer_relation (hs : 1 ≤ s) + (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (j : ℕ) + (z : DualGroup F.lowerCentralSeries_eq_bot) (hb : dualBaseLinear z.coord ∈ U) + (hbr : ⁅dualBaseLinear z.coord, dualTangentLinear z.coord⁆ ∈ V ⊔ F.layer (j + 1)) : + dualLogDerivative z - dualTangentLinear z.coord ∈ V ⊔ F.layer (j + 1) := + dualLogDerivative_sub_tangent_mem hs U (V ⊔ F.layer (j + 1)) + (F.invariant_sup_layer U V hUV (j + 1)) z hb hbr + +end NilpotentLieFiltration +end Erdos3 + +end + +section + +namespace Erdos3 + +namespace NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +@[simp] theorem dualLogDerivative_one : dualLogDerivative (1 : DualGroup hnil) = 0 := by + simp only [dualLogDerivative, map_one, inv_one, mul_one, coord_one, map_zero] + +theorem dualLogDerivative_inv (z : DualGroup hnil) : + dualLogDerivative z⁻¹ = -dualAdjoint (dualBaseHom z)⁻¹ (dualLogDerivative z) := by + have h := dualLogDerivative_mul z z⁻¹ + rw [mul_inv_cancel, dualLogDerivative_one] at h + have he := congrArg (dualAdjoint (dualBaseHom z)⁻¹) h + rw [dualAdjoint_zero, dualAdjoint_add, dualAdjoint_inv_cancel] at he + apply eq_neg_iff_add_eq_zero.mpr + simpa only [add_comm] using he.symm + +theorem dualLogDerivative_remove (a z c : DualGroup hnil) : + dualLogDerivative (a⁻¹ * z * c⁻¹) = + dualAdjoint (dualBaseHom a)⁻¹ (dualLogDerivative z - dualLogDerivative a) - + dualAdjoint (dualBaseHom (a⁻¹ * z * c⁻¹)) (dualLogDerivative c) := by + simp only [dualLogDerivative_mul, dualLogDerivative_inv, map_mul, map_inv, + dualAdjoint_mul, dualAdjoint_neg, dualAdjoint_sub] + abel + +theorem dualDerivativeSystem_remove (a z c : DualGroup hnil) (small rational extra : L) + (hsystem : dualLogDerivative z = small + dualAdjoint (dualBaseHom z) rational + extra) : + dualLogDerivative (a⁻¹ * z * c⁻¹) = + dualAdjoint (dualBaseHom a)⁻¹ (small - dualLogDerivative a) + + dualAdjoint (dualBaseHom (a⁻¹ * z * c⁻¹)) + (dualAdjoint (dualBaseHom c) rational - dualLogDerivative c) + + dualAdjoint (dualBaseHom a)⁻¹ extra := by + rw [dualLogDerivative_remove, hsystem] + simp only [map_mul, map_inv, dualAdjoint_mul, dualAdjoint_add, dualAdjoint_sub, + dualAdjoint_inv_cancel] + abel + +end NilpotentLieBCHGroup + +namespace NilpotentLieFiltration + +open NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem derivative_removal_preserves_quotient_layers + (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (j : ℕ) + (a c : DualGroup F.lowerCentralSeries_eq_bot) + (haU : dualBaseLinear a.coord ∈ U) (hcU : dualBaseLinear c.coord ∈ U) + (haV : dualTangentLinear a.coord ∈ V) (hcV : dualTangentLinear c.coord ∈ V) + (small rational : L) (hsmall : small ∈ V ⊔ F.layer j) + (hrational : rational ∈ V ⊔ F.layer j) : + dualAdjoint (dualBaseHom a)⁻¹ (small - dualLogDerivative a) ∈ V ⊔ F.layer j ∧ + dualAdjoint (dualBaseHom c) rational - dualLogDerivative c ∈ V ⊔ F.layer j := by + have hYa := dualLogDerivative_mem_of_invariant U V hUV a haU haV + have hYc := dualLogDerivative_mem_of_invariant U V hUV c hcU hcV + have hW := F.invariant_sup_layer U V hUV j + constructor + · apply dualAdjoint_mem_of_invariant U (V ⊔ F.layer j) hW _ (U.neg_mem haU) + exact (V ⊔ F.layer j).sub_mem hsmall (Submodule.mem_sup_left hYa) + · exact (V ⊔ F.layer j).sub_mem + (dualAdjoint_mem_of_invariant U (V ⊔ F.layer j) hW _ hcU rational hrational) + (Submodule.mem_sup_left hYc) + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DualIdealSteps.lean b/lean/OAI/Combinatorics/Progressions/Linear/DualIdealSteps.lean new file mode 100644 index 0000000000000000000000000000000000000000..97bc6bd1c55058974e83f18c1bca099f2b2cf82d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DualIdealSteps.lean @@ -0,0 +1,608 @@ +import Mathlib.Algebra.Module.TransferInstance +import OAI.Combinatorics.Progressions.Linear.DualAdjointAction +import OAI.Combinatorics.Progressions.Nilpotent.BCHConjugationLinear + +namespace OAI + + +namespace Erdos3 + +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem dualConstant_infinitesimal_lie (x y : L) : + ⁅dualConstantLie x, dualInfinitesimal y⁆ = dualInfinitesimal ⁅x, y⁆ := by + change ⁅(1 : DualNumber ℚ) ⊗ₜ[ℚ] x, DualNumber.eps ⊗ₜ[ℚ] y⁆ = _ + rw [LieAlgebra.ExtendScalars.bracket_tmul, one_mul] + rfl + +theorem dualInfinitesimal_constant_lie (x y : L) : + ⁅dualInfinitesimal x, dualConstantLie y⁆ = dualInfinitesimal ⁅x, y⁆ := by + change ⁅DualNumber.eps ⊗ₜ[ℚ] x, (1 : DualNumber ℚ) ⊗ₜ[ℚ] y⁆ = _ + rw [LieAlgebra.ExtendScalars.bracket_tmul, mul_one] + rfl + +theorem dualTangentLinear_lie (x y : DualLieAlgebra L) : + dualTangentLinear ⁅x, y⁆ = + ⁅dualBaseLinear x, dualTangentLinear y⁆ + ⁅dualTangentLinear x, dualBaseLinear y⁆ := by + have he := congrArg₂ (fun a b : DualLieAlgebra L => ⁅a, b⁆) + (dualLie_decomposition x) (dualLie_decomposition y) + calc + _ = dualTangentLinear ⁅dualConstantLie (dualBaseLinear x) + dualInfinitesimal (dualTangentLinear x), + dualConstantLie (dualBaseLinear y) + dualInfinitesimal (dualTangentLinear y)⁆ := + congrArg dualTangentLinear he + _ = _ := by + rw [LieRing.add_lie (dualConstantLie (dualBaseLinear x)) (dualInfinitesimal (dualTangentLinear x)) + (dualConstantLie (dualBaseLinear y) + dualInfinitesimal (dualTangentLinear y))] + rw [LieRing.lie_add (dualConstantLie (dualBaseLinear x)) (dualConstantLie (dualBaseLinear y)) + (dualInfinitesimal (dualTangentLinear y))] + rw [LieRing.lie_add (dualInfinitesimal (dualTangentLinear x)) (dualConstantLie (dualBaseLinear y)) + (dualInfinitesimal (dualTangentLinear y))] + rw [dualConstant_infinitesimal_lie, dualInfinitesimal_constant_lie, dualInfinitesimal_lie, + ← dualConstantLie.map_lie] + simp only [map_add, dualTangentLinear_constant, dualTangentLinear_infinitesimal, + zero_add, add_zero] + +noncomputable def dualIdealSubalgebra (I : LieIdeal ℚ L) : LieSubalgebra ℚ (DualLieAlgebra L) := + { I.toSubmodule.comap dualTangentLinear with + lie_mem' := by + intro x y hx hy + change dualTangentLinear ⁅x, y⁆ ∈ I + rw [dualTangentLinear_lie] + exact I.add_mem (I.lie_mem hy) (lie_mem_left ℚ L I _ _ hx) } + +@[simp] theorem mem_dualIdealSubalgebra (I : LieIdeal ℚ L) (x : DualLieAlgebra L) : + x ∈ dualIdealSubalgebra I ↔ dualTangentLinear x ∈ I := Iff.rfl + +noncomputable def dualIdealRealization (I J : LieIdeal ℚ L) + (hIJ : ∀ x ∈ I, ∀ y ∈ I, ⁅x, y⁆ ∈ J) : dualIdealSubalgebra I →ₗ⁅ℚ⁆ L ⧸ J := + { toLinearMap := (lieQuotientMap J).toLinearMap.comp + ((dualBaseLinear + dualTangentLinear).comp (dualIdealSubalgebra I).incl.toLinearMap) + map_lie' := by + intro x y + change lieQuotientMap J (dualBaseLinear ⁅x.val, y.val⁆ + dualTangentLinear ⁅x.val, y.val⁆) = + ⁅lieQuotientMap J (dualBaseLinear x.val + dualTangentLinear x.val), + lieQuotientMap J (dualBaseLinear y.val + dualTangentLinear y.val)⁆ + rw [← (lieQuotientMap J).map_lie] + rw [← sub_eq_zero, ← map_sub] + apply (lieQuotientMap_eq_zero J _).mpr + rw [dualBaseLinear_lie, dualTangentLinear_lie, LieRing.add_lie, LieRing.lie_add, + LieRing.lie_add] + have he : ⁅dualBaseLinear x.val, dualBaseLinear y.val⁆ + + (⁅dualBaseLinear x.val, dualTangentLinear y.val⁆ + + ⁅dualTangentLinear x.val, dualBaseLinear y.val⁆) - + (⁅dualBaseLinear x.val, dualBaseLinear y.val⁆ + + ⁅dualBaseLinear x.val, dualTangentLinear y.val⁆ + + (⁅dualTangentLinear x.val, dualBaseLinear y.val⁆ + + ⁅dualTangentLinear x.val, dualTangentLinear y.val⁆)) = + -⁅dualTangentLinear x.val, dualTangentLinear y.val⁆ := by abel + rw [he] + exact J.neg_mem (hIJ _ x.property _ y.property) } + +@[simp] theorem dualIdealRealization_apply (I J : LieIdeal ℚ L) + (hIJ : ∀ x ∈ I, ∀ y ∈ I, ⁅x, y⁆ ∈ J) (x : dualIdealSubalgebra I) : + dualIdealRealization I J hIJ x = + lieQuotientMap J (dualBaseLinear x.val + dualTangentLinear x.val) := rfl + +noncomputable def dualQuotientEvaluate (J : LieIdeal ℚ L) : DualLieAlgebra L →ₗ[ℚ] L ⧸ J := + (lieQuotientMap J).toLinearMap.comp (dualBaseLinear + dualTangentLinear) + +@[simp] theorem dualQuotientEvaluate_apply (J : LieIdeal ℚ L) (x : DualLieAlgebra L) : + dualQuotientEvaluate J x = lieQuotientMap J (dualBaseLinear x + dualTangentLinear x) := rfl + +@[simp] theorem dualQuotientEvaluate_constant (J : LieIdeal ℚ L) (x : L) : + dualQuotientEvaluate J (dualConstantLie x) = lieQuotientMap J x := by + rw [dualQuotientEvaluate_apply, dualBaseLinear_constant, dualTangentLinear_constant, add_zero] + +@[simp] theorem dualQuotientEvaluate_infinitesimal (J : LieIdeal ℚ L) (x : L) : + dualQuotientEvaluate J (dualInfinitesimal x) = lieQuotientMap J x := by + rw [dualQuotientEvaluate_apply, dualBaseLinear_infinitesimal, dualTangentLinear_infinitesimal, zero_add] + +theorem dualQuotientEvaluate_lieBCH (I J : LieIdeal ℚ L) + (hIJ : ∀ x ∈ I, ∀ y ∈ I, ⁅x, y⁆ ∈ J) (s : ℕ) {x y : DualLieAlgebra L} + (hx : x ∈ dualIdealSubalgebra I) (hy : y ∈ dualIdealSubalgebra I) : + dualQuotientEvaluate J (lieBCH s x y) = + lieBCH s (dualQuotientEvaluate J x) (dualQuotientEvaluate J y) := by + let a : dualIdealSubalgebra I := ⟨x, hx⟩ + let b : dualIdealSubalgebra I := ⟨y, hy⟩ + calc + _ = dualQuotientEvaluate J ((dualIdealSubalgebra I).incl (lieBCH s a b)) := + congrArg (dualQuotientEvaluate J) (map_lieBCH (dualIdealSubalgebra I).incl s a b).symm + _ = _ := map_lieBCH (dualIdealRealization I J hIJ) s a b + +end Erdos3 + + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dualAdjoint_conjugation_mod (I J : LieIdeal ℚ L) + (hIJ : ∀ a ∈ I, ∀ b ∈ I, ⁅a, b⁆ ∈ J) + (g : NilpotentLieBCHGroup L s hnil) (x : L) (hx : x ∈ I) : + lieQuotientMap J (dualAdjoint g x) = + lieQuotientMap J (g * (⟨x⟩ : NilpotentLieBCHGroup L s hnil) * g⁻¹).coord := by + have hc : dualConstantLie g.coord ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualConstantLie g.coord) ∈ I + rw [dualTangentLinear_constant] + exact I.zero_mem + have ht : dualInfinitesimal x ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualInfinitesimal x) ∈ I + rwa [dualTangentLinear_infinitesimal] + calc + _ = dualQuotientEvaluate J + (dualConstantHom g * dualTangentElement x * (dualConstantHom g)⁻¹).coord := by + rw [dualAdjoint_spec] + exact (dualQuotientEvaluate_infinitesimal J _).symm + _ = _ := by + change dualQuotientEvaluate J + (lieBCH s (lieBCH s (dualConstantLie g.coord) (dualInfinitesimal x)) + (-dualConstantLie g.coord)) = + lieQuotientMap J (lieBCH s (lieBCH s g.coord x) (-g.coord)) + rw [dualQuotientEvaluate_lieBCH I J hIJ s + (lieBCH_mem (dualIdealSubalgebra I) s hc ht) ((dualIdealSubalgebra I).neg_mem hc), + dualQuotientEvaluate_lieBCH I J hIJ s hc ht, + map_neg, dualQuotientEvaluate_constant, dualQuotientEvaluate_infinitesimal, + map_lieBCH, map_lieBCH, map_neg] + +theorem dualAdjoint_eq_conjugation_of_abelian_ideal (I : LieIdeal ℚ L) + (hI : ∀ a ∈ I, ∀ b ∈ I, ⁅a, b⁆ = 0) + (g : NilpotentLieBCHGroup L s hnil) (x : L) (hx : x ∈ I) : + dualAdjoint g x = (g * (⟨x⟩ : NilpotentLieBCHGroup L s hnil) * g⁻¹).coord := by + have he := dualAdjoint_conjugation_mod I ⊥ + (fun a ha b hb => (Submodule.mem_bot ℚ).mpr (hI a ha b hb)) g x hx + have hz : lieQuotientMap (⊥ : LieIdeal ℚ L) + (dualAdjoint g x - (g * (⟨x⟩ : NilpotentLieBCHGroup L s hnil) * g⁻¹).coord) = 0 := by + rw [map_sub, he, sub_self] + exact sub_eq_zero.mp ((Submodule.mem_bot ℚ).mp ((lieQuotientMap_eq_zero _ _).mp hz)) + +end Erdos3.NilpotentLieBCHGroup + + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def dualCoordinates : DualLieAlgebra L ≃ₗ[ℚ] L × L where + toLinearMap := dualBaseLinear.prod dualTangentLinear + invFun x := dualConstantLie x.1 + dualInfinitesimal x.2 + left_inv x := (dualLie_decomposition x).symm + right_inv x := by ext <;> simp + +@[simp] theorem dualCoordinates_apply (x : DualLieAlgebra L) : + dualCoordinates x = (dualBaseLinear x, dualTangentLinear x) := rfl + +@[simp] theorem dualCoordinates_symm_apply (x : L × L) : + dualCoordinates.symm x = dualConstantLie x.1 + dualInfinitesimal x.2 := rfl + +end Erdos3 + + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def dualFirstOrderIdeal (I J : LieIdeal ℚ L) + (hIJ : ∀ x ∈ I, ∀ y ∈ I, ⁅x, y⁆ ∈ J) : LieIdeal ℚ (dualIdealSubalgebra I) := + { (I.toSubmodule.comap (dualBaseLinear.comp (dualIdealSubalgebra I).incl.toLinearMap)) ⊓ + (J.toSubmodule.comap (dualTangentLinear.comp (dualIdealSubalgebra I).incl.toLinearMap)) with + lie_mem := by + intro x y hy + change dualBaseLinear ⁅x.val, y.val⁆ ∈ I ∧ dualTangentLinear ⁅x.val, y.val⁆ ∈ J + rw [dualBaseLinear_lie, dualTangentLinear_lie] + exact ⟨I.lie_mem hy.1, J.add_mem (J.lie_mem hy.2) (hIJ _ x.property _ hy.1)⟩ } + +def DualFirstOrderCongruent (I J : LieIdeal ℚ L) (x y : DualLieAlgebra L) : Prop := + dualBaseLinear (x - y) ∈ I ∧ dualTangentLinear (x - y) ∈ J + +theorem dualFirstOrderCongruent_lieBCH (I J : LieIdeal ℚ L) + (hIJ : ∀ x ∈ I, ∀ y ∈ I, ⁅x, y⁆ ∈ J) (s : ℕ) + {a b c d : DualLieAlgebra L} + (ha : a ∈ dualIdealSubalgebra I) (hb : b ∈ dualIdealSubalgebra I) + (hc : c ∈ dualIdealSubalgebra I) (hd : d ∈ dualIdealSubalgebra I) + (hac : DualFirstOrderCongruent I J a c) (hbd : DualFirstOrderCongruent I J b d) : + DualFirstOrderCongruent I J (lieBCH s a b) (lieBCH s c d) := by + let K := dualFirstOrderIdeal I J hIJ + let a' : dualIdealSubalgebra I := ⟨a, ha⟩ + let b' : dualIdealSubalgebra I := ⟨b, hb⟩ + let c' : dualIdealSubalgebra I := ⟨c, hc⟩ + let d' : dualIdealSubalgebra I := ⟨d, hd⟩ + have heac : lieQuotientMap K a' = lieQuotientMap K c' := by + rw [← sub_eq_zero, ← map_sub] + exact (lieQuotientMap_eq_zero K _).mpr hac + have hebd : lieQuotientMap K b' = lieQuotientMap K d' := by + rw [← sub_eq_zero, ← map_sub] + exact (lieQuotientMap_eq_zero K _).mpr hbd + have he : lieBCH s a' b' - lieBCH s c' d' ∈ K := by + apply (lieQuotientMap_eq_zero K _).mp + rw [map_sub, map_lieBCH, map_lieBCH, heac, hebd, sub_self] + have hv : (lieBCH s a' b' - lieBCH s c' d').val = lieBCH s a b - lieBCH s c d := by + change (dualIdealSubalgebra I).incl (lieBCH s a' b' - lieBCH s c' d') = _ + rw [map_sub, map_lieBCH, map_lieBCH] + rfl + change dualBaseLinear (lieBCH s a' b' - lieBCH s c' d').val ∈ I ∧ + dualTangentLinear (lieBCH s a' b' - lieBCH s c' d').val ∈ J at he + rw [hv] at he + exact he + +theorem dualFirstOrderCongruent_constant (I J : LieIdeal ℚ L) {x y : L} + (hxy : x - y ∈ I) : DualFirstOrderCongruent I J (dualConstantLie x) (dualConstantLie y) := by + constructor + · simpa only [map_sub, dualBaseLinear_constant] using hxy + · simp only [map_sub, dualTangentLinear_constant, sub_self] + exact J.zero_mem + +theorem dualFirstOrderCongruent_infinitesimal (I J : LieIdeal ℚ L) {x y : L} + (hxy : x - y ∈ J) : DualFirstOrderCongruent I J (dualInfinitesimal x) (dualInfinitesimal y) := by + constructor + · simp only [map_sub, dualBaseLinear_infinitesimal, sub_self] + exact I.zero_mem + · simpa only [map_sub, dualTangentLinear_infinitesimal] using hxy + +namespace NilpotentLieBCHGroup + +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dualLogDerivative_sub_mem (I J : LieIdeal ℚ L) + (hIJ : ∀ x ∈ I, ∀ y ∈ I, ⁅x, y⁆ ∈ J) (z z' : DualGroup hnil) + (hz : dualTangentLinear z.coord ∈ I) (hz' : dualTangentLinear z'.coord ∈ I) + (he : DualFirstOrderCongruent I J z.coord z'.coord) : + dualLogDerivative z - dualLogDerivative z' ∈ J := by + have hbase : -dualBaseLinear z.coord - -dualBaseLinear z'.coord ∈ I := by + have hh := I.neg_mem he.1 + rw [map_sub, neg_sub] at hh + rw [neg_sub_neg] + exact hh + have hconst := dualFirstOrderCongruent_constant I J hbase + rw [map_neg, map_neg] at hconst + have hc (x : L) : -dualConstantLie x ∈ dualIdealSubalgebra I := by + change dualTangentLinear (-dualConstantLie x) ∈ I + rw [map_neg, dualTangentLinear_constant, neg_zero] + exact I.zero_mem + have hh := dualFirstOrderCongruent_lieBCH I J hIJ s hz (hc _) hz' (hc _) he hconst + have ht := hh.2 + rw [map_sub] at ht + exact ht + +theorem dualAdjoint_sub_mem (I J : LieIdeal ℚ L) + (hIJ : ∀ x ∈ I, ∀ y ∈ I, ⁅x, y⁆ ∈ J) + (g g' : NilpotentLieBCHGroup L s hnil) (x x' : L) + (hx : x ∈ I) (hx' : x' ∈ I) (hg : g.coord - g'.coord ∈ I) (hxx' : x - x' ∈ J) : + dualAdjoint g x - dualAdjoint g' x' ∈ J := by + have hc (a : L) : dualConstantLie a ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualConstantLie a) ∈ I + rw [dualTangentLinear_constant] + exact I.zero_mem + have ht : dualInfinitesimal x ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualInfinitesimal x) ∈ I + rwa [dualTangentLinear_infinitesimal] + have ht' : dualInfinitesimal x' ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualInfinitesimal x') ∈ I + rwa [dualTangentLinear_infinitesimal] + have hcc := dualFirstOrderCongruent_constant I J hg + have htt := dualFirstOrderCongruent_infinitesimal I J hxx' + have hp := dualFirstOrderCongruent_lieBCH I J hIJ s (hc _) ht (hc _) ht' hcc htt + have hneg : -g.coord - -g'.coord ∈ I := by + rw [neg_sub_neg] + have hh := I.neg_mem hg + rwa [neg_sub] at hh + have hcc' := dualFirstOrderCongruent_constant I J hneg + rw [map_neg, map_neg] at hcc' + have hh := dualFirstOrderCongruent_lieBCH I J hIJ s + (lieBCH_mem (dualIdealSubalgebra I) s (hc _) ht) ((dualIdealSubalgebra I).neg_mem (hc _)) + (lieBCH_mem (dualIdealSubalgebra I) s (hc _) ht') ((dualIdealSubalgebra I).neg_mem (hc _)) hp hcc' + have he := hh.2 + rw [map_sub] at he + exact he + +end NilpotentLieBCHGroup +end Erdos3 + + +namespace Erdos3 + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +theorem dual_ext {x y : DualLieAlgebra M} + (hb : dualBaseLinear x = dualBaseLinear y) (ht : dualTangentLinear x = dualTangentLinear y) : x = y := by + calc + x = dualConstantLie (dualBaseLinear x) + dualInfinitesimal (dualTangentLinear x) := dualLie_decomposition x + _ = dualConstantLie (dualBaseLinear y) + dualInfinitesimal (dualTangentLinear y) := by rw [hb, ht] + _ = y := (dualLie_decomposition y).symm + +noncomputable def dualLinearLift (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) : + DualLieAlgebra L →ₗ[ℚ] DualLieAlgebra M := + dualConstantLie.toLinearMap.comp (B.toLinearMap.comp dualBaseLinear) + + dualInfinitesimal.comp (T.comp dualTangentLinear) + +@[simp] theorem dualLinearLift_apply (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) (x : DualLieAlgebra L) : + dualLinearLift B T x = dualConstantLie (B (dualBaseLinear x)) + + dualInfinitesimal (T (dualTangentLinear x)) := rfl + +@[simp] theorem dualLinearLift_base (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) (x : DualLieAlgebra L) : + dualBaseLinear (dualLinearLift B T x) = B (dualBaseLinear x) := by + rw [dualLinearLift_apply, map_add, dualBaseLinear_constant, dualBaseLinear_infinitesimal, add_zero] + +@[simp] theorem dualLinearLift_tangent (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) (x : DualLieAlgebra L) : + dualTangentLinear (dualLinearLift B T x) = T (dualTangentLinear x) := by + rw [dualLinearLift_apply, map_add, dualTangentLinear_constant, dualTangentLinear_infinitesimal, zero_add] + +@[simp] theorem dualLinearLift_constant (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) (x : L) : + dualLinearLift B T (dualConstantLie x) = dualConstantLie (B x) := by + rw [dualLinearLift_apply, dualBaseLinear_constant, dualTangentLinear_constant, map_zero, + map_zero, add_zero] + +@[simp] theorem dualLinearLift_infinitesimal (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) (x : L) : + dualLinearLift B T (dualInfinitesimal x) = dualInfinitesimal (T x) := by + rw [dualLinearLift_apply, dualBaseLinear_infinitesimal, dualTangentLinear_infinitesimal, map_zero, + map_zero, zero_add] + +variable (I : LieIdeal ℚ L) (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) + (hT : ∀ x y, y ∈ I → T ⁅x, y⁆ = ⁅B x, T y⁆) + +include hT in +theorem dualIdealMorphism_left {x y : L} (hx : x ∈ I) : T ⁅x, y⁆ = ⁅T x, B y⁆ := by + calc + T ⁅x, y⁆ = T (-⁅y, x⁆) := congrArg T (lie_skew x y).symm + _ = -⁅B y, T x⁆ := by rw [map_neg, hT y x hx] + _ = ⁅T x, B y⁆ := lie_skew _ _ + +noncomputable def dualIdealMorphism : dualIdealSubalgebra I →ₗ⁅ℚ⁆ DualLieAlgebra M := + { toLinearMap := (dualLinearLift B T).comp (dualIdealSubalgebra I).incl.toLinearMap + map_lie' := by + intro x y + apply dual_ext + · change dualBaseLinear (dualLinearLift B T ⁅x.val, y.val⁆) = + dualBaseLinear ⁅dualLinearLift B T x.val, dualLinearLift B T y.val⁆ + rw [dualLinearLift_base, dualBaseLinear_lie, dualBaseLinear_lie, + dualLinearLift_base, dualLinearLift_base, B.map_lie] + · change dualTangentLinear (dualLinearLift B T ⁅x.val, y.val⁆) = + dualTangentLinear ⁅dualLinearLift B T x.val, dualLinearLift B T y.val⁆ + rw [dualLinearLift_tangent, dualTangentLinear_lie, dualTangentLinear_lie, + dualLinearLift_base, dualLinearLift_base, dualLinearLift_tangent, dualLinearLift_tangent, + map_add, hT _ _ y.property, dualIdealMorphism_left I B T hT x.property] } + +include hT in +theorem dualLinearLift_lieBCH (s : ℕ) {x y : DualLieAlgebra L} + (hx : x ∈ dualIdealSubalgebra I) (hy : y ∈ dualIdealSubalgebra I) : + dualLinearLift B T (lieBCH s x y) = lieBCH s (dualLinearLift B T x) (dualLinearLift B T y) := by + let a : dualIdealSubalgebra I := ⟨x, hx⟩ + let b : dualIdealSubalgebra I := ⟨y, hy⟩ + calc + _ = dualLinearLift B T ((dualIdealSubalgebra I).incl (lieBCH s a b)) := + congrArg (dualLinearLift B T) (map_lieBCH (dualIdealSubalgebra I).incl s a b).symm + _ = _ := map_lieBCH (dualIdealMorphism I B T hT) s a b + +end Erdos3 + + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + +noncomputable instance dualRealModule : Module ℝ (DualLieAlgebra L) := + (dualCoordinates (L := L)).toAddEquiv.module ℝ + +noncomputable def dualRealCoordinates : DualLieAlgebra L ≃ₗ[ℝ] L × L := + (dualCoordinates (L := L)).toAddEquiv.linearEquiv ℝ + +@[simp] theorem dualRealCoordinates_apply (x : DualLieAlgebra L) : + dualRealCoordinates x = (dualBaseLinear x, dualTangentLinear x) := rfl + +@[simp] theorem dualRealCoordinates_symm_apply (x : L × L) : + dualRealCoordinates.symm x = dualConstantLie x.1 + dualInfinitesimal x.2 := rfl + +@[simp] theorem dualBaseLinear_smul_real (r : ℝ) (x : DualLieAlgebra L) : + dualBaseLinear (r • x) = r • dualBaseLinear x := + congrArg Prod.fst (dualRealCoordinates.map_smul r x) + +@[simp] theorem dualTangentLinear_smul_real (r : ℝ) (x : DualLieAlgebra L) : + dualTangentLinear (r • x) = r • dualTangentLinear x := + congrArg Prod.snd (dualRealCoordinates.map_smul r x) + +instance dualRealScalarTower [IsScalarTower ℚ ℝ L] : IsScalarTower ℚ ℝ (DualLieAlgebra L) where + smul_assoc q r x := by + apply dualCoordinates.injective + ext <;> simp [smul_assoc] + +noncomputable instance dualRealLieAlgebra : LieAlgebra ℝ (DualLieAlgebra L) where + lie_smul r x y := by + apply dualCoordinates.injective + ext + · simp only [dualCoordinates_apply, dualBaseLinear_lie, dualBaseLinear_smul_real, lie_smul] + · simp only [dualCoordinates_apply, dualTangentLinear_lie, dualTangentLinear_smul_real, + dualBaseLinear_smul_real, lie_smul, smul_add] + +end Erdos3 + + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + (hM : LieModule.lowerCentralSeries ℚ M M s = ⊥) + (I : LieIdeal ℚ L) (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) + (hT : ∀ x y, y ∈ I → T ⁅x, y⁆ = ⁅B x, T y⁆) + +theorem map_coord (f : L →ₗ⁅ℚ⁆ M) (g : NilpotentLieBCHGroup L s hL) : + (map (hM := hM) f g).coord = f g.coord := rfl + +include hT in +theorem dualLinearLift_logDerivative (z : DualGroup hL) + (hz : dualTangentLinear z.coord ∈ I) : + T (dualLogDerivative z) = + dualLogDerivative (hnil := hM) (⟨dualLinearLift B T z.coord⟩ : DualGroup hM) := by + have hc : -dualConstantLie (dualBaseLinear z.coord) ∈ dualIdealSubalgebra I := by + change dualTangentLinear (-dualConstantLie (dualBaseLinear z.coord)) ∈ I + rw [map_neg, dualTangentLinear_constant, neg_zero] + exact I.zero_mem + have hh := dualLinearLift_lieBCH I B T hT s hz hc + have ht := congrArg dualTangentLinear hh + rw [dualLinearLift_tangent, map_neg, dualLinearLift_constant] at ht + change T (dualLogDerivative z) = + dualTangentLinear (lieBCH s (dualLinearLift B T z.coord) + (-dualConstantLie (dualBaseLinear (dualLinearLift B T z.coord)))) + rw [dualLinearLift_base] + exact ht + +include hT in +theorem dualLinearLift_adjoint (g : NilpotentLieBCHGroup L s hL) (x : L) (hx : x ∈ I) : + T (dualAdjoint g x) = dualAdjoint (map (hM := hM) B g) (T x) := by + have hc : dualConstantLie g.coord ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualConstantLie g.coord) ∈ I + rw [dualTangentLinear_constant] + exact I.zero_mem + have ht : dualInfinitesimal x ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualInfinitesimal x) ∈ I + rwa [dualTangentLinear_infinitesimal] + have hh := dualLinearLift_lieBCH I B T hT s + (lieBCH_mem (dualIdealSubalgebra I) s hc ht) ((dualIdealSubalgebra I).neg_mem hc) + rw [dualLinearLift_lieBCH I B T hT s hc ht, dualLinearLift_constant, + dualLinearLift_infinitesimal, map_neg, dualLinearLift_constant] at hh + have he := congrArg dualTangentLinear hh + rw [dualLinearLift_tangent] at he + exact he + +include hT in +theorem dualLinearLift_logDerivative_eq (z : DualGroup hL) + (hz : dualTangentLinear z.coord ∈ I) (z' : DualGroup hM) + (he : dualLinearLift B T z.coord = z'.coord) : + T (dualLogDerivative z) = dualLogDerivative (hnil := hM) z' := by + have hg : (⟨dualLinearLift B T z.coord⟩ : DualGroup hM) = z' := NilpotentLieBCHGroup.ext he + exact (dualLinearLift_logDerivative hM I B T hT z hz).trans + (congrArg (dualLogDerivative (hnil := hM)) hg) + +include hT in +theorem dualLinearLift_adjoint_eq (g : NilpotentLieBCHGroup L s hL) (x : L) (hx : x ∈ I) + (g' : NilpotentLieBCHGroup M s hM) (x' : M) + (hg : B g.coord = g'.coord) (hxx' : T x = x') : + T (dualAdjoint g x) = dualAdjoint g' x' := by + have hmap : map (hM := hM) B g = g' := NilpotentLieBCHGroup.ext hg + have he := dualLinearLift_adjoint hM I B T hT g x hx + rw [hmap, hxx'] at he + exact he + +end Erdos3.NilpotentLieBCHGroup + + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def dualInvariantSubalgebra (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) : LieSubalgebra ℚ (DualLieAlgebra L) := + { U.toSubmodule.comap dualBaseLinear ⊓ V.comap dualTangentLinear with + lie_mem' := by + intro x y hx hy + constructor + · change dualBaseLinear ⁅x, y⁆ ∈ U + rw [dualBaseLinear_lie] + exact U.lie_mem hx.1 hy.1 + · change dualTangentLinear ⁅x, y⁆ ∈ V + rw [dualTangentLinear_lie] + apply V.add_mem (hUV _ hx.1 _ hy.2) + rw [← lie_skew] + exact V.neg_mem (hUV _ hy.1 _ hx.2) } + +@[simp] theorem mem_dualInvariantSubalgebra (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (x : DualLieAlgebra L) : + x ∈ dualInvariantSubalgebra U V hUV ↔ dualBaseLinear x ∈ U ∧ dualTangentLinear x ∈ V := + Iff.rfl + +namespace NilpotentLieBCHGroup + +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dualAdjoint_mem_of_invariant (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + (g : NilpotentLieBCHGroup L s hnil) (hg : g.coord ∈ U) (x : L) (hx : x ∈ V) : + dualAdjoint g x ∈ V := by + let S := dualInvariantSubalgebra U V hUV + have hc : dualConstantLie g.coord ∈ S := by + change dualBaseLinear (dualConstantLie g.coord) ∈ U ∧ + dualTangentLinear (dualConstantLie g.coord) ∈ V + simpa only [dualBaseLinear_constant, dualTangentLinear_constant] using And.intro hg V.zero_mem + have ht : dualInfinitesimal x ∈ S := by + change dualBaseLinear (dualInfinitesimal x) ∈ U ∧ dualTangentLinear (dualInfinitesimal x) ∈ V + simpa only [dualBaseLinear_infinitesimal, dualTangentLinear_infinitesimal] using And.intro U.zero_mem hx + exact (lieBCH_mem S s (lieBCH_mem S s hc ht) (S.neg_mem hc)).2 + +theorem dualLogDerivative_mem_of_invariant (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (z : DualGroup hnil) + (hb : dualBaseLinear z.coord ∈ U) (ht : dualTangentLinear z.coord ∈ V) : + dualLogDerivative z ∈ V := by + let S := dualInvariantSubalgebra U V hUV + have hz : z.coord ∈ S := ⟨hb, ht⟩ + have hc : dualConstantLie (dualBaseLinear z.coord) ∈ S := by + change dualBaseLinear (dualConstantLie (dualBaseLinear z.coord)) ∈ U ∧ + dualTangentLinear (dualConstantLie (dualBaseLinear z.coord)) ∈ V + simpa only [dualBaseLinear_constant, dualTangentLinear_constant] using And.intro hb V.zero_mem + exact (lieBCH_mem S s hz (S.neg_mem hc)).2 + +theorem dualAdjoint_mem_ideal (I : LieIdeal ℚ L) (g : NilpotentLieBCHGroup L s hnil) + (x : L) (hx : x ∈ I) : dualAdjoint g x ∈ I := + dualAdjoint_mem_of_invariant ⊤ I.toSubmodule (fun _ _ _ hv => I.lie_mem hv) g (by trivial) x hx + +theorem dualLogDerivative_mem_ideal (I : LieIdeal ℚ L) (z : DualGroup hnil) + (ht : dualTangentLinear z.coord ∈ I) : dualLogDerivative z ∈ I := + dualLogDerivative_mem_of_invariant ⊤ I.toSubmodule (fun _ _ _ hv => I.lie_mem hv) z (by trivial) ht + +end NilpotentLieBCHGroup +end Erdos3 + + +namespace Erdos3 + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s t : ℕ} (hL : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (hM : LieModule.lowerCentralSeries ℚ M M t = ⊥) + (I : LieIdeal ℚ L) (B : L →ₗ⁅ℚ⁆ M) (T : L →ₗ[ℚ] M) + (hT : ∀ x y, y ∈ I → T ⁅x, y⁆ = ⁅B x, T y⁆) + +include hL hM hT in +theorem dualLinearLift_lieBCH_of_steps {x y : DualLieAlgebra L} + (hx : x ∈ dualIdealSubalgebra I) (hy : y ∈ dualIdealSubalgebra I) : + dualLinearLift B T (lieBCH s x y) = + lieBCH t (dualLinearLift B T x) (dualLinearLift B T y) := by + let a : dualIdealSubalgebra I := ⟨x, hx⟩ + let b : dualIdealSubalgebra I := ⟨y, hy⟩ + calc + _ = dualLinearLift B T ((dualIdealSubalgebra I).incl (lieBCH s a b)) := + congrArg (dualLinearLift B T) (map_lieBCH (dualIdealSubalgebra I).incl s a b).symm + _ = _ := map_lieBCH_of_nilpotent_steps (dualIdealMorphism I B T hT) + (lie_subalgebra_lowerCentralSeries_eq_bot (dualLie_lowerCentralSeries_eq_bot hL) + (dualIdealSubalgebra I)) + (dualLie_lowerCentralSeries_eq_bot hM) a b + +namespace NilpotentLieBCHGroup + +include hT in +theorem dualLinearLift_adjoint_of_steps (g : NilpotentLieBCHGroup L s hL) + (x : L) (hx : x ∈ I) : + T (dualAdjoint g x) = dualAdjoint (mapOfSteps (hM := hM) B g) (T x) := by + have hc : dualConstantLie g.coord ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualConstantLie g.coord) ∈ I + rw [dualTangentLinear_constant] + exact I.zero_mem + have ht : dualInfinitesimal x ∈ dualIdealSubalgebra I := by + change dualTangentLinear (dualInfinitesimal x) ∈ I + rwa [dualTangentLinear_infinitesimal] + have hh := dualLinearLift_lieBCH_of_steps hL hM I B T hT + (lieBCH_mem (dualIdealSubalgebra I) s hc ht) ((dualIdealSubalgebra I).neg_mem hc) + rw [dualLinearLift_lieBCH_of_steps hL hM I B T hT hc ht, dualLinearLift_constant, + dualLinearLift_infinitesimal, map_neg, dualLinearLift_constant] at hh + have he := congrArg dualTangentLinear hh + rw [dualLinearLift_tangent] at he + exact he + +theorem mapOfSteps_dualAdjoint (g : NilpotentLieBCHGroup L s hL) (x : L) : + B (dualAdjoint g x) = dualAdjoint (mapOfSteps (hM := hM) B g) (B x) := + dualLinearLift_adjoint_of_steps hL hM ⊤ B B.toLinearMap + (fun a b _ => B.map_lie a b) g x (by trivial) + +end NilpotentLieBCHGroup +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DualLieAlgebra.lean b/lean/OAI/Combinatorics/Progressions/Linear/DualLieAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..5653d90cbce612830698ccf44ab692771c518d3b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DualLieAlgebra.lean @@ -0,0 +1,114 @@ +import Mathlib.Algebra.DualNumber +import OAI.Combinatorics.Progressions.Estimates.RealifiedMultidegree + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +abbrev DualLieAlgebra (L : Type*) [LieRing L] [LieAlgebra ℚ L] := DualNumber ℚ ⊗[ℚ] L + +noncomputable def dualBaseLinear : DualLieAlgebra L →ₗ[ℚ] L := + (TensorProduct.lid ℚ L).toLinearMap.comp + ((TrivSqZeroExt.fstHom ℚ ℚ ℚ).toLinearMap.rTensor L) + +noncomputable def dualTangentLinear : DualLieAlgebra L →ₗ[ℚ] L := + (TensorProduct.lid ℚ L).toLinearMap.comp ((TrivSqZeroExt.sndHom ℚ ℚ).rTensor L) + +@[simp] theorem dualBaseLinear_tmul (r : DualNumber ℚ) (x : L) : + dualBaseLinear (r ⊗ₜ[ℚ] x) = r.fst • x := rfl + +@[simp] theorem dualTangentLinear_tmul (r : DualNumber ℚ) (x : L) : + dualTangentLinear (r ⊗ₜ[ℚ] x) = r.snd • x := rfl + +noncomputable def dualConstantLie : L →ₗ⁅ℚ⁆ DualLieAlgebra L where + toLinearMap := TensorProduct.mk ℚ (DualNumber ℚ) L 1 + map_lie' {x y} := by simp [LieAlgebra.ExtendScalars.bracket_tmul] + +noncomputable def dualInfinitesimal : L →ₗ[ℚ] DualLieAlgebra L := + TensorProduct.mk ℚ (DualNumber ℚ) L DualNumber.eps + +@[simp] theorem dualBaseLinear_constant (x : L) : dualBaseLinear (dualConstantLie x) = x := by + change (1 : ℚ) • x = x + exact one_smul ℚ x + +@[simp] theorem dualTangentLinear_constant (x : L) : dualTangentLinear (dualConstantLie x) = 0 := by + change (0 : ℚ) • x = 0 + exact zero_smul ℚ x + +@[simp] theorem dualBaseLinear_infinitesimal (x : L) : dualBaseLinear (dualInfinitesimal x) = 0 := by + change (0 : ℚ) • x = 0 + exact zero_smul ℚ x + +@[simp] theorem dualTangentLinear_infinitesimal (x : L) : dualTangentLinear (dualInfinitesimal x) = x := by + change (1 : ℚ) • x = x + exact one_smul ℚ x + +theorem dualInfinitesimal_injective : Function.Injective (dualInfinitesimal (L := L)) := by + intro x y h + simpa only [dualTangentLinear_infinitesimal] using congrArg dualTangentLinear h + +theorem dualLie_decomposition (z : DualLieAlgebra L) : + z = dualConstantLie (dualBaseLinear z) + dualInfinitesimal (dualTangentLinear z) := by + induction z using TensorProduct.inductionOn with + | tmul r x => + have hr : r = r.fst • (1 : DualNumber ℚ) + r.snd • DualNumber.eps := by + ext <;> simp + change r ⊗ₜ[ℚ] x = (1 : DualNumber ℚ) ⊗ₜ[ℚ] (r.fst • x) + + DualNumber.eps ⊗ₜ[ℚ] (r.snd • x) + calc + _ = (r.fst • (1 : DualNumber ℚ) + r.snd • DualNumber.eps) ⊗ₜ[ℚ] x := + congrArg (fun a : DualNumber ℚ => a ⊗ₜ[ℚ] x) hr + _ = _ := by rw [TensorProduct.add_tmul]; simp only [TensorProduct.smul_tmul, TensorProduct.tmul_smul] + | add x y hx hy => + calc + _ = (dualConstantLie (dualBaseLinear x) + dualInfinitesimal (dualTangentLinear x)) + + (dualConstantLie (dualBaseLinear y) + dualInfinitesimal (dualTangentLinear y)) := + congrArg₂ (· + ·) hx hy + _ = _ := by simp only [map_add]; abel + +private theorem ring_zero_lie {K : Type*} [LieRing K] (x : K) : ⁅(0 : K), x⁆ = 0 := zero_lie x +private theorem ring_lie_zero {K : Type*} [LieRing K] (x : K) : ⁅x, (0 : K)⁆ = 0 := lie_zero x + +theorem dualBaseLinear_lie (x y : DualLieAlgebra L) : + dualBaseLinear ⁅x, y⁆ = ⁅dualBaseLinear x, dualBaseLinear y⁆ := by + induction x using TensorProduct.inductionOn with + | tmul r x => + induction y using TensorProduct.inductionOn with + | tmul q y => + simp only [LieAlgebra.ExtendScalars.bracket_tmul, dualBaseLinear_tmul, + TrivSqZeroExt.fst_mul, smul_lie, lie_smul, smul_smul, mul_comm] + | add y z hy hz => + rw [LieRing.lie_add (r ⊗ₜ[ℚ] x) y z, map_add, hy, hz, map_add, LieRing.lie_add] + | add x z hx hz => rw [LieRing.add_lie x z y, map_add, hx, hz, map_add, LieRing.add_lie] + +noncomputable def dualBaseLie : DualLieAlgebra L →ₗ⁅ℚ⁆ L where + toLinearMap := dualBaseLinear + map_lie' {x y} := dualBaseLinear_lie x y + +theorem dualInfinitesimal_lie (x y : L) : ⁅dualInfinitesimal x, dualInfinitesimal y⁆ = 0 := by + change ⁅DualNumber.eps ⊗ₜ[ℚ] x, DualNumber.eps ⊗ₜ[ℚ] y⁆ = 0 + rw [LieAlgebra.ExtendScalars.bracket_tmul, DualNumber.eps_mul_eps, TensorProduct.zero_tmul] + +theorem dualLie_lowerCentralSeries_eq_bot {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) : + LieModule.lowerCentralSeries ℚ (DualLieAlgebra L) (DualLieAlgebra L) s = ⊥ := by + have hdual : LieModule.lowerCentralSeries (DualNumber ℚ) (DualLieAlgebra L) (DualLieAlgebra L) s = ⊥ := by + rw [LieSubmodule.lowerCentralSeries_tensor_eq_baseChange, hnil, LieSubmodule.baseChange_bot] + apply SetLike.coe_injective + change (LieModule.lowerCentralSeries ℚ (DualLieAlgebra L) (DualLieAlgebra L) s : Set (DualLieAlgebra L)) = {0} + rw [LieModule.coe_lowerCentralSeries_eq_int, + ← LieModule.coe_lowerCentralSeries_eq_int (DualNumber ℚ) (DualLieAlgebra L) (DualLieAlgebra L) s, + hdual] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DualLogarithmicDifferential.lean b/lean/OAI/Combinatorics/Progressions/Linear/DualLogarithmicDifferential.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa0580aa166377eac5f12db2b17cf94424faca87 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DualLogarithmicDifferential.lean @@ -0,0 +1,135 @@ +import Mathlib.Algebra.Module.LinearMap.Rat +import OAI.Combinatorics.Progressions.Linear.DualIdealSteps + +namespace OAI + +section + +namespace Erdos3 + +variable {X L : Type*} [LieRing L] [LieAlgebra ℚ L] + +private theorem base_lift_congr (f g : X → DualLieAlgebra L) + (hb : ∀ x, dualBaseLinear (f x) = dualBaseLinear (g x)) (p : FreeLieAlgebra ℚ X) : + dualBaseLinear (FreeLieAlgebra.lift ℚ f p) = dualBaseLinear (FreeLieAlgebra.lift ℚ g p) := by + change dualBaseLie (FreeLieAlgebra.lift ℚ f p) = dualBaseLie (FreeLieAlgebra.lift ℚ g p) + rw [map_freeLie_lift, map_freeLie_lift] + exact congrArg (fun a : X → L => FreeLieAlgebra.lift ℚ a p) (funext hb) + +theorem dualTangentLinear_lift_add (f g k : X → DualLieAlgebra L) + (hfg : ∀ x, dualBaseLinear (f x) = dualBaseLinear (g x)) + (hfk : ∀ x, dualBaseLinear (f x) = dualBaseLinear (k x)) + (ht : ∀ x, dualTangentLinear (f x) = dualTangentLinear (g x) + dualTangentLinear (k x)) + (p : FreeLieAlgebra ℚ X) : + dualTangentLinear (FreeLieAlgebra.lift ℚ f p) = + dualTangentLinear (FreeLieAlgebra.lift ℚ g p) + + dualTangentLinear (FreeLieAlgebra.lift ℚ k p) := by + have hbr (u v : FreeLieAlgebra ℚ X) + (hu : dualTangentLinear (FreeLieAlgebra.lift ℚ f u) = + dualTangentLinear (FreeLieAlgebra.lift ℚ g u) + dualTangentLinear (FreeLieAlgebra.lift ℚ k u)) + (hv : dualTangentLinear (FreeLieAlgebra.lift ℚ f v) = + dualTangentLinear (FreeLieAlgebra.lift ℚ g v) + dualTangentLinear (FreeLieAlgebra.lift ℚ k v)) : + dualTangentLinear (FreeLieAlgebra.lift ℚ f ⁅u, v⁆) = + dualTangentLinear (FreeLieAlgebra.lift ℚ g ⁅u, v⁆) + + dualTangentLinear (FreeLieAlgebra.lift ℚ k ⁅u, v⁆) := by + simp only [LieHom.map_lie, dualTangentLinear_lie, hu, hv, + ← base_lift_congr f g hfg, ← base_lift_congr f k hfk, + LieRing.lie_add, LieRing.add_lie] + abel + apply freeLie_linear_induction (fun q => + dualTangentLinear (FreeLieAlgebra.lift ℚ f q) = + dualTangentLinear (FreeLieAlgebra.lift ℚ g q) + + dualTangentLinear (FreeLieAlgebra.lift ℚ k q)) + · simp only [map_zero, add_zero] + · intro u v hu hv + simp only [map_add, hu, hv] + abel + · intro r q hq + simp only [map_smul, hq, smul_add] + · intro t + induction t with + | ih1 x => simpa only [lieTreeEval, FreeLieAlgebra.lift_of_apply] using ht x + | ih2 u v hu hv => exact hbr _ _ hu hv + +theorem dualTangentLinear_bch_add (s : ℕ) (a a₁ a₂ b b₁ b₂ : DualLieAlgebra L) + (ha₁ : dualBaseLinear a = dualBaseLinear a₁) + (ha₂ : dualBaseLinear a = dualBaseLinear a₂) + (hb₁ : dualBaseLinear b = dualBaseLinear b₁) + (hb₂ : dualBaseLinear b = dualBaseLinear b₂) + (hat : dualTangentLinear a = dualTangentLinear a₁ + dualTangentLinear a₂) + (hbt : dualTangentLinear b = dualTangentLinear b₁ + dualTangentLinear b₂) : + dualTangentLinear (lieBCH s a b) = + dualTangentLinear (lieBCH s a₁ b₁) + dualTangentLinear (lieBCH s a₂ b₂) := by + apply dualTangentLinear_lift_add ![a, b] ![a₁, b₁] ![a₂, b₂] + · intro i; fin_cases i <;> assumption + · intro i; fin_cases i <;> assumption + · intro i; fin_cases i <;> assumption + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dualLogDerivative_value_tangent (x y : L) : + dualLogDerivative (hnil := hnil) ⟨dualConstantLie x + dualInfinitesimal y⟩ = + dualTangentLinear (lieBCH s (dualConstantLie x + dualInfinitesimal y) (-dualConstantLie x)) := by + change dualTangentLinear (lieBCH s (dualConstantLie x + dualInfinitesimal y) + (-dualConstantLie (dualBaseLinear (dualConstantLie x + dualInfinitesimal y)))) = _ + rw [map_add, dualBaseLinear_constant, dualBaseLinear_infinitesimal, add_zero] + +theorem dualLogDerivative_tangent_add (x y z : L) : + dualLogDerivative (hnil := hnil) ⟨dualConstantLie x + dualInfinitesimal (y + z)⟩ = + dualLogDerivative (hnil := hnil) ⟨dualConstantLie x + dualInfinitesimal y⟩ + + dualLogDerivative (hnil := hnil) ⟨dualConstantLie x + dualInfinitesimal z⟩ := by + simp only [dualLogDerivative_value_tangent] + apply dualTangentLinear_bch_add <;> + simp only [map_add, map_neg, dualBaseLinear_constant, dualBaseLinear_infinitesimal, + dualTangentLinear_constant, dualTangentLinear_infinitesimal, add_zero, zero_add, neg_zero] + +noncomputable def dualLogarithmicDifferential (x : L) : L →ₗ[ℚ] L := + (AddMonoidHom.mk' + (fun y => dualLogDerivative (hnil := hnil) ⟨dualConstantLie x + dualInfinitesimal y⟩) + (dualLogDerivative_tangent_add x)).toRatLinearMap + +@[simp] theorem dualLogarithmicDifferential_apply (x y : L) : + dualLogarithmicDifferential (hnil := hnil) x y = + dualLogDerivative (hnil := hnil) ⟨dualConstantLie x + dualInfinitesimal y⟩ := rfl + +theorem dualLogDerivative_eq_differential (z : DualGroup hnil) : + dualLogDerivative z = + dualLogarithmicDifferential (hnil := hnil) (dualBaseLinear z.coord) (dualTangentLinear z.coord) := by + apply congrArg (dualLogDerivative (hnil := hnil)) + apply NilpotentLieBCHGroup.ext + exact dualLie_decomposition z.coord + +theorem dualLogarithmicDifferential_smul_real [LieAlgebra ℝ L] (x y : L) (r : ℝ) : + dualLogarithmicDifferential (hnil := hnil) x (r • y) = + r • dualLogarithmicDifferential (hnil := hnil) x y := by + let T : L →ₗ[ℚ] L := r • LinearMap.id + have hT : ∀ a b : L, b ∈ (⊤ : LieIdeal ℚ L) → + T ⁅a, b⁆ = ⁅(LieHom.id : L →ₗ⁅ℚ⁆ L) a, T b⁆ := by + intro a b _ + change r • ⁅a, b⁆ = ⁅a, r • b⁆ + exact (lie_smul r a b).symm + have he := dualLinearLift_logDerivative_eq (hL := hnil) hnil ⊤ LieHom.id T hT + (⟨dualConstantLie x + dualInfinitesimal y⟩ : DualGroup hnil) (by trivial) + (⟨dualConstantLie x + dualInfinitesimal (r • y)⟩ : DualGroup hnil) + (by simp only [map_add, dualLinearLift_constant, dualLinearLift_infinitesimal]; rfl) + exact he.symm + +noncomputable def dualRealLogarithmicDifferential [LieAlgebra ℝ L] (x : L) : L →ₗ[ℝ] L where + toFun := dualLogarithmicDifferential (hnil := hnil) x + map_add' := (dualLogarithmicDifferential x).map_add + map_smul' r y := dualLogarithmicDifferential_smul_real x y r + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/DynkinProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/DynkinProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..01bddfd5e24aa66ea29fcddbfe4dec1ca5e2130a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/DynkinProjection.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.Progressions.Estimates.DynkinTrees + +namespace OAI + +section + +namespace Erdos3 + +variable {X L : Type*} [LieRing L] [LieAlgebra ℚ L] + +def WordHomogeneous (n : ℕ) (p : WordPolynomial X) : Prop := + ∀ w, p.coeff w ≠ 0 → w.length = n + +theorem WordHomogeneous.sub {n : ℕ} {p q : WordPolynomial X} + (hp : WordHomogeneous n p) (hq : WordHomogeneous n q) : WordHomogeneous n (p - q) := by + intro w hw + by_cases h : p.coeff w = 0 + · apply hq w + intro he + apply hw + change p.coeff w - q.coeff w = 0 + rw [h, he, sub_zero] + · exact hp w h + +theorem WordHomogeneous.mul {n m : ℕ} {p q : WordPolynomial X} + (hp : WordHomogeneous n p) (hq : WordHomogeneous m q) : WordHomogeneous (n + m) (p * q) := by + classical + intro w hw + by_contra hlen + apply hw + rw [MonoidAlgebra.coeff_mul] + apply Finset.sum_eq_zero + intro u hu + apply Finset.sum_eq_zero + intro v hv + have hu' := hp u (Finsupp.mem_support_iff.mp hu) + have hv' := hq v (Finsupp.mem_support_iff.mp hv) + have hne : u * v ≠ w := by + intro he + apply hlen + rw [← he, FreeSemigroup.length_mul, hu', hv'] + simp only [hne, ite_false] + +theorem commutatorTree_homogeneous (t : FreeMagma X) : + WordHomogeneous t.length (commutatorTree t) := by + induction t using FreeMagma.rec with + | of x => + intro w hw + have he : FreeSemigroup.of x = w := by + classical + by_contra hn + apply hw + simp [commutatorTree, hn] + rw [← he] + rfl + | mul u v hu hv => + apply (hu.mul hv).sub + simpa only [Nat.add_comm v.length u.length] using hv.mul hu + +noncomputable def dynkinProjection (f : X → L) : WordPolynomial X →ₗ[ℚ] L := + wordLinearMap (fun w => (w.length : ℚ)⁻¹ • dynkinWord f w) + +theorem dynkinProjection_homogeneous (f : X → L) {n : ℕ} {p : WordPolynomial X} + (hp : WordHomogeneous n p) : dynkinProjection f p = (n : ℚ)⁻¹ • dynkinMap f p := by + classical + change p.coeff.sum (fun w r => r • ((w.length : ℚ)⁻¹ • dynkinWord f w)) = + (n : ℚ)⁻¹ • p.coeff.sum (fun w r => r • dynkinWord f w) + rw [Finsupp.sum, Finsupp.sum, Finset.smul_sum] + apply Finset.sum_congr rfl + intro w hw + rw [hp w (Finsupp.mem_support_iff.mp hw), smul_comm] + +theorem dynkinProjection_commutatorTree (f : X → L) (t : FreeMagma X) : + dynkinProjection f (commutatorTree t) = lieTreeEval f t := by + rw [dynkinProjection_homogeneous f (commutatorTree_homogeneous t), + dynkinMap_commutatorTree, inv_smul_smul₀] + exact_mod_cast (Nat.ne_zero_of_lt t.length_pos) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/EpochEventRank.lean b/lean/OAI/Combinatorics/Progressions/Linear/EpochEventRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..fbe455cbc0890e8ccfe0337e77748a55ab42def4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/EpochEventRank.lean @@ -0,0 +1,85 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialDensityBudget + +namespace OAI + +section + +namespace Erdos3 + +def epochStackRank (d : ℕ) : List ℕ → ℕ + | [] => 0 + | r :: rs => r * (d + 1) ^ rs.length + epochStackRank d rs + +inductive EpochStackEvent (d : ℕ) : List ℕ → List ℕ → Prop + | head {r r' : ℕ} {xs ys : List ℕ} (drop : r' < r) (length : ys.length = xs.length) + (bounded : ∀ q ∈ ys, q ≤ d) : EpochStackEvent d (r :: xs) (r' :: ys) + | tail {r : ℕ} {xs ys : List ℕ} (event : EpochStackEvent d xs ys) : + EpochStackEvent d (r :: xs) (r :: ys) + +theorem EpochStackEvent.length_eq {d : ℕ} {xs ys : List ℕ} (h : EpochStackEvent d xs ys) : + ys.length = xs.length := by + induction h with + | head _ hlen _ => simpa only [List.length_cons] using congrArg Nat.succ hlen + | tail _ ih => simpa only [List.length_cons] using congrArg Nat.succ ih + +theorem epochStackRank_lt (d : ℕ) (xs : List ℕ) (hbounded : ∀ q ∈ xs, q ≤ d) : + epochStackRank d xs < (d + 1) ^ xs.length := by + revert hbounded + induction xs with + | nil => simp [epochStackRank] + | cons r xs ih => + intro hbounded + have hr : r ≤ d := hbounded r (by simp) + have ht := ih (fun q hq => hbounded q (by simp [hq])) + change r * (d + 1) ^ xs.length + epochStackRank d xs < (d + 1) ^ (xs.length + 1) + calc + r * (d + 1) ^ xs.length + epochStackRank d xs < + r * (d + 1) ^ xs.length + (d + 1) ^ xs.length := Nat.add_lt_add_left ht _ + _ = (r + 1) * (d + 1) ^ xs.length := by ring + _ ≤ (d + 1) * (d + 1) ^ xs.length := Nat.mul_le_mul_right _ (Nat.add_le_add_right hr 1) + _ = (d + 1) ^ (xs.length + 1) := by rw [pow_succ]; ring + +theorem EpochStackEvent.rank_lt {d : ℕ} {xs ys : List ℕ} (h : EpochStackEvent d xs ys) : + epochStackRank d ys < epochStackRank d xs := by + induction h with + | @head r r' xs ys hdrop hlen hbounded => + have htail := epochStackRank_lt d ys hbounded + change r' * (d + 1) ^ ys.length + epochStackRank d ys < + r * (d + 1) ^ xs.length + epochStackRank d xs + rw [hlen] at htail ⊢ + calc + r' * (d + 1) ^ xs.length + epochStackRank d ys < + r' * (d + 1) ^ xs.length + (d + 1) ^ xs.length := Nat.add_lt_add_left htail _ + _ = (r' + 1) * (d + 1) ^ xs.length := by ring + _ ≤ r * (d + 1) ^ xs.length := Nat.mul_le_mul_right _ (Nat.succ_le_of_lt hdrop) + _ ≤ r * (d + 1) ^ xs.length + epochStackRank d xs := Nat.le_add_right _ _ + | @tail r xs ys hevent ih => + change r * (d + 1) ^ ys.length + epochStackRank d ys < + r * (d + 1) ^ xs.length + epochStackRank d xs + rw [hevent.length_eq] + exact Nat.add_lt_add_left ih _ + +theorem epochEventChain_length_le_rank (d n : ℕ) (states : ℕ → List ℕ) + (hsteps : ∀ i, i < n → EpochStackEvent d (states i) (states (i + 1))) : + n ≤ epochStackRank d (states 0) := by + induction n generalizing states with + | zero => exact Nat.zero_le _ + | succ n ih => + have hfirst := (hsteps 0 (by omega)).rank_lt + have hrest := ih (fun i => states (i + 1)) (fun i hi => hsteps (i + 1) (by omega)) + simp only [Nat.zero_add] at hfirst hrest + omega + +theorem epochEventChain_bound (d n : ℕ) (states : ℕ → List ℕ) + (hbounded : ∀ q ∈ states 0, q ≤ d) + (hsteps : ∀ i, i < n → EpochStackEvent d (states i) (states (i + 1))) : + n ≤ (d + 1) ^ (states 0).length - 1 := by + have hlength := epochEventChain_length_le_rank d n states hsteps + have hrank := epochStackRank_lt d (states 0) hbounded + omega + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/EuclideanDerivativeProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/EuclideanDerivativeProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a92fc768989badea86586ee89c5653d7adc1bc9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/EuclideanDerivativeProjection.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Lattices.EuclideanDerivativeLattice + +namespace OAI + +section + +namespace Erdos3 + +theorem euclideanDerivativeLattice_shortSpan_projection + {σ κ : Type*} [Fintype σ] [Fintype κ] [DecidableEq σ] [DecidableEq κ] + (T : σ → ℝ) (hT : ∀ i, 1 ≤ T i) + (scale : κ → ℝ) (hscale : ∀ j, scale j ≠ 0) + (Y : (σ → ℝ) →ₗ[ℝ] (κ → ℝ)) (A : (κ → ℝ) ≃ₗ[ℝ] (κ → ℝ)) + (l : ℕ) (hl : 0 < l) (R δ : ℝ) (hR : 1 ≤ R) + (H : Finset (σ → ℤ)) (r : (σ → ℤ) → κ → ℝ) + (hr : ∀ h ∈ H, r h ∈ realDenominatorGrid l) + (hnorm : ∀ h ∈ H, + ‖derivativeGridPoint T scale Y (LinearMap.toMatrix' A.toLinearMap) h (r h)‖ ≤ R) + (hdense : δ * ∏ i, T i ≤ (H.card : ℝ)) + (hlarge : ∀ i, (3 * R) ^ (Fintype.card σ - 1) < δ * T i) : + let ρ := ((Fintype.card σ + Fintype.card κ : ℕ) : ℝ) * R + let Λ := euclideanDerivativeLattice T + (fun i => (lt_of_lt_of_le zero_lt_one (hT i)).ne') scale hscale Y A l hl + (shortVectorSpan Λ ρ).map ((LinearMap.fst ℝ (σ → ℝ) (κ → ℝ)).comp + productEuclideanEquiv.symm.toLinearMap) = ⊤ := by + let hT0 : ∀ i, 0 < T i := fun i => lt_of_lt_of_le zero_lt_one (hT i) + let ρ := ((Fintype.card σ + Fintype.card κ : ℕ) : ℝ) * R + let Λ := euclideanDerivativeLattice T (fun i => (hT0 i).ne') scale hscale Y A l hl + let π₀ := (LinearMap.fst ℝ (σ → ℝ) (κ → ℝ)).comp productEuclideanEquiv.symm.toLinearMap + let e := coordinateScaleEquiv T (fun i => (hT0 i).ne') + let π := e.toLinearMap.comp π₀ + have hspan := integer_points_span_eq_top_of_density H T R δ hT hR + (fun h hh => derivativeGridPoint_shift_bound T hT0 scale Y _ h (r h) R (hnorm h hh)) + hdense hlarge + have hmap : (shortVectorSpan Λ ρ).map π = ⊤ := by + apply shortVectorSpan_map_eq_top_of_spanning_integer_images Λ π H ρ hspan + intro h hh + let v := derivativeGridPoint T scale Y (LinearMap.toMatrix' A.toLinearMap) h (r h) + refine ⟨productEuclideanEquiv v, ?_, ?_, ?_⟩ + · apply (productEuclideanEquiv_mem_derivativeLattice T + (fun i => (hT0 i).ne') scale hscale Y A l hl v).mpr + rw [← SetLike.mem_coe, derivativeLattice_carrier] + exact derivativeGridPoint_mem T scale Y _ l h (r h) (hr h hh) + · exact (productEuclideanEquiv_norm_le v).trans + (mul_le_mul_of_nonneg_left (hnorm h hh) (Nat.cast_nonneg _)) + · change e (LinearMap.fst ℝ (σ → ℝ) (κ → ℝ) + (productEuclideanEquiv.symm (productEuclideanEquiv v))) = _ + rw [LinearEquiv.symm_apply_apply] + funext i + exact mul_div_cancel₀ (h i : ℝ) (hT0 i).ne' + have hmap' : ((shortVectorSpan Λ ρ).map π₀).map e.toLinearMap = ⊤ := by + simpa only [← Submodule.map_comp] using hmap + exact (Submodule.map_eq_top_iff (e := e)).mp hmap' + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/EuclideanHorizontalProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/EuclideanHorizontalProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..7af29678fbd31a8532c66949acde5377b12ede3c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/EuclideanHorizontalProjection.lean @@ -0,0 +1,23 @@ +import OAI.Combinatorics.Progressions.Geometry.ProductEuclideanCoordinates + +namespace OAI + +section + +namespace Erdos3 + +def euclideanHorizontalProjection {σ : Type*} {m : ℕ} (a : ℕ) (ha : a ≤ m) : + EuclideanSpace ℝ (σ ⊕ Fin m) →ₗ[ℝ] (Fin a → ℝ) where + toFun x i := x (Sum.inr (Fin.castLE ha i)) + map_add' _ _ := rfl + map_smul' _ _ := rfl + +@[simp] theorem euclideanHorizontalProjection_apply {σ : Type*} {m : ℕ} + (a : ℕ) (ha : a ≤ m) (x : EuclideanSpace ℝ (σ ⊕ Fin m)) (i : Fin a) : + euclideanHorizontalProjection a ha x i = x (Sum.inr (Fin.castLE ha i)) := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/EuclideanVerticalProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/EuclideanVerticalProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..c427b67887c57e558777e1504e2dac237282437b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/EuclideanVerticalProjection.lean @@ -0,0 +1,30 @@ +import OAI.Combinatorics.Progressions.Geometry.ProductEuclideanCoordinates + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def euclideanVerticalProjection {σ κ : Type*} : + EuclideanSpace ℝ (σ ⊕ κ) →ₗ[ℝ] EuclideanSpace ℝ κ := + (EuclideanSpace.equiv κ ℝ).symm.toLinearMap.comp + ((LinearMap.snd ℝ (σ → ℝ) (κ → ℝ)).comp productEuclideanEquiv.symm.toLinearMap) + +@[simp] theorem euclideanVerticalProjection_apply {σ κ : Type*} + (x : EuclideanSpace ℝ (σ ⊕ κ)) (j : κ) : + euclideanVerticalProjection x j = x (Sum.inr j) := rfl + +theorem euclideanVerticalProjection_norm_le {σ κ : Type*} [Fintype σ] [Fintype κ] + (x : EuclideanSpace ℝ (σ ⊕ κ)) : ‖euclideanVerticalProjection x‖ ≤ ‖x‖ := by + have hs : ‖euclideanVerticalProjection x‖ ^ 2 ≤ ‖x‖ ^ 2 := by + rw [PiLp.norm_sq_eq_of_L2, PiLp.norm_sq_eq_of_L2, Fintype.sum_sum_type] + simp only [euclideanVerticalProjection_apply] + exact le_add_of_nonneg_left (Finset.sum_nonneg (fun i _ => sq_nonneg ‖x (Sum.inl i)‖)) + nlinarith [norm_nonneg (euclideanVerticalProjection x), norm_nonneg x] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyCircleProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyCircleProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a9c0bbfec9e8ec119a9d88c249330ede4763421 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyCircleProjection.lean @@ -0,0 +1,445 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteFiberTest +import OAI.Combinatorics.Progressions.Estimates.IteratedCircleAverageIntegral + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem norm_weighted_mean_sub_le {G : Type*} [Fintype G] [Nonempty G] + (w f g : G → ℂ) {B rho : ℝ} (hB : 0 ≤ B) + (hw : ∀ n, ‖w n‖ ≤ B) (hfg : ∀ n, ‖f n - g n‖ ≤ rho) : + ‖(𝔼 n, w n * f n) - (𝔼 n, w n * g n)‖ ≤ B * rho := by + rw [← Finset.expect_sub_distrib] + apply (RCLike.norm_expect_le (K := ℂ)).trans + apply (Finset.expect_le_expect _).trans_eq (Finset.expect_const Finset.univ_nonempty _) + intro n _ + rw [← mul_sub, norm_mul] + exact mul_le_mul (hw n) (hfg n) (norm_nonneg _) hB + +theorem finite_projection_tested_error {G J : Type*} [Fintype G] [Nonempty G] [Fintype J] + (w f projected : G → ℂ) (v : J → G → ℂ) (keep : J → Prop) [DecidablePred keep] + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hw : ∀ n, ‖w n‖ ≤ B) + (hfull : ∀ n, ‖f n - ∑ j, v j n‖ ≤ rho) + (hprojected : ∀ n, ‖(∑ j, if keep j then v j n else 0) - projected n‖ ≤ rho) + (hdiscard : ∀ j, ¬ keep j → ‖𝔼 n, w n * v j n‖ ≤ tau) : + ‖(𝔼 n, w n * f n) - (𝔼 n, w n * projected n)‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + have hfirst := norm_weighted_mean_sub_le w f (fun n => ∑ j, v j n) hB hw hfull + have hlast := norm_weighted_mean_sub_le w + (fun n => ∑ j, if keep j then v j n else 0) projected hB hw hprojected + have hid : (𝔼 n, w n * ∑ j, v j n) - + (𝔼 n, w n * ∑ j, if keep j then v j n else 0) = + ∑ j, if keep j then 0 else (𝔼 n, w n * v j n) := by + calc + _ = 𝔼 n, w n * ((∑ j, v j n) - ∑ j, if keep j then v j n else 0) := by + simp only [mul_sub, Finset.expect_sub_distrib] + _ = 𝔼 n, ∑ j, if keep j then 0 else w n * v j n := by + apply Finset.expect_congr rfl + intro n _ + rw [← Finset.sum_sub_distrib, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj] + _ = ∑ j, 𝔼 n, if keep j then 0 else w n * v j n := Finset.expect_sum_comm _ _ _ + _ = _ := by + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj] + have hmiddle : ‖(𝔼 n, w n * ∑ j, v j n) - + (𝔼 n, w n * ∑ j, if keep j then v j n else 0)‖ ≤ Fintype.card J * tau := by + rw [hid] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ _j : J, tau := by + apply Finset.sum_le_sum + intro j _ + by_cases hj : keep j + · simpa only [hj, ite_true, norm_zero] using htau + · simpa only [hj, ite_false] using hdiscard j hj + _ = _ := by simp + have htriangle := norm_sub_le_norm_sub_add_norm_sub + (𝔼 n, w n * f n) (𝔼 n, w n * ∑ j, v j n) (𝔼 n, w n * projected n) + have htriangle' := norm_sub_le_norm_sub_add_norm_sub + (𝔼 n, w n * ∑ j, v j n) (𝔼 n, w n * ∑ j, if keep j then v j n else 0) + (𝔼 n, w n * projected n) + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem norm_finiteWeightedSum_sub_le {G : Type*} [Fintype G] + (w f g : G → ℂ) {B rho : ℝ} + (hmass : (∑ x, ‖w x‖) ≤ B) (hrho : 0 ≤ rho) + (hfg : ∀ x, ‖f x - g x‖ ≤ rho) : + ‖(∑ x, w x * f x) - (∑ x, w x * g x)‖ ≤ B * rho := by + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ x, ‖w x * f x - w x * g x‖ := norm_sum_le _ _ + _ ≤ ∑ x, ‖w x‖ * rho := by + apply Finset.sum_le_sum + intro x _ + rw [← mul_sub, norm_mul] + exact mul_le_mul_of_nonneg_left (hfg x) (norm_nonneg _) + _ = (∑ x, ‖w x‖) * rho := (Finset.sum_mul ..).symm + _ ≤ B * rho := mul_le_mul_of_nonneg_right hmass hrho + +theorem finiteWeightedProjection_error {G J : Type*} [Fintype G] [Fintype J] + (w f projected : G → ℂ) (v : J → G → ℂ) (keep : J → Prop) [DecidablePred keep] + {B rho tau : ℝ} (hmass : (∑ x, ‖w x‖) ≤ B) (hrho : 0 ≤ rho) (htau : 0 ≤ tau) + (hfull : ∀ x, ‖f x - ∑ j, v j x‖ ≤ rho) + (hprojected : ∀ x, ‖(∑ j, if keep j then v j x else 0) - projected x‖ ≤ rho) + (hdiscard : ∀ j, ¬ keep j → ‖∑ x, w x * v j x‖ ≤ tau) : + ‖(∑ x, w x * f x) - (∑ x, w x * projected x)‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + have hfirst := norm_finiteWeightedSum_sub_le w f (fun x => ∑ j, v j x) hmass hrho hfull + have hlast := norm_finiteWeightedSum_sub_le w + (fun x => ∑ j, if keep j then v j x else 0) projected hmass hrho hprojected + have hid : (∑ x, w x * ∑ j, v j x) - + (∑ x, w x * ∑ j, if keep j then v j x else 0) = + ∑ j, if keep j then 0 else (∑ x, w x * v j x) := by + calc + _ = ∑ x, w x * ((∑ j, v j x) - ∑ j, if keep j then v j x else 0) := by + simp only [mul_sub, Finset.sum_sub_distrib] + _ = ∑ x, ∑ j, if keep j then 0 else w x * v j x := by + apply Finset.sum_congr rfl + intro x _ + rw [← Finset.sum_sub_distrib, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj] + _ = ∑ j, ∑ x, if keep j then 0 else w x * v j x := Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj] + have hmiddle : ‖(∑ x, w x * ∑ j, v j x) - + (∑ x, w x * ∑ j, if keep j then v j x else 0)‖ ≤ Fintype.card J * tau := by + rw [hid] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ _j : J, tau := by + apply Finset.sum_le_sum + intro j _ + by_cases hj : keep j + · simpa only [hj, ite_true, norm_zero] using htau + · simpa only [hj, ite_false] using hdiscard j hj + _ = _ := by simp + have htriangle := norm_sub_le_norm_sub_add_norm_sub + (∑ x, w x * f x) (∑ x, w x * ∑ j, v j x) (∑ x, w x * projected x) + have htriangle' := norm_sub_le_norm_sub_add_norm_sub + (∑ x, w x * ∑ j, v j x) (∑ x, w x * ∑ j, if keep j then v j x else 0) + (∑ x, w x * projected x) + linarith + +end Erdos3 + +end + +section + +namespace Erdos3.CircleFourier + +open scoped BigOperators NNReal + +theorem lipschitz_finite_complex_sum {X J : Type*} [PseudoMetricSpace X] [Fintype J] + (v : J → X → ℂ) (L : J → ℝ≥0) (hv : ∀ j, LipschitzWith (L j) (v j)) : + LipschitzWith (∑ j, L j) (fun x => ∑ j, v j x) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [dist_eq_norm, ← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j, ‖v j x - v j y‖ := norm_sum_le _ _ + _ ≤ ∑ j, (L j : ℝ) * dist x y := by + apply Finset.sum_le_sum + intro j _ + simpa only [dist_eq_norm] using (hv j).dist_le_mul x y + _ = _ := by simp only [NNReal.coe_sum, Finset.sum_mul] + +theorem iteratedCircleAverage_tested_error + {X α G J : Type*} [PseudoMetricSpace X] [Fintype G] [Nonempty G] [Fintype J] + (A : α → IsometricCircleAction X) (is : List α) (f : X → ℂ) + (v : J → X → ℂ) (n : J → α → ℤ) (path : G → X) (weight : G → ℂ) + (Lf : ℝ≥0) (Lv : J → ℝ≥0) (hf : LipschitzWith Lf f) + (hv : ∀ j, LipschitzWith (Lv j) (v j)) + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hweight : ∀ x, ‖weight x‖ ≤ B) + (happrox : ∀ x, ‖f x - ∑ j, v j x‖ ≤ rho) + (heigen : ∀ j i, i ∈ is → ∀ t x, v j ((A i).act t x) = character (n j i • t) * v j x) + (hdiscard : ∀ j, ¬ (∀ i ∈ is, n j i = 0) → + ‖𝔼 x, weight x * v j (path x)‖ ≤ tau) : + ‖(𝔼 x, weight x * f (path x)) - + (𝔼 x, weight x * iteratedCircleAverage A is f (path x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + classical + let keep : J → Prop := fun j => ∀ i ∈ is, n j i = 0 + have hsum (x : X) : iteratedCircleAverage A is (fun y => ∑ j, v j y) x = + ∑ j, if keep j then v j x else 0 := by + rw [iteratedCircleAverage_sum A is Finset.univ v Lv (fun j _ => hv j)] + apply Finset.sum_congr rfl + intro j _ + rw [iteratedCircleAverage_eigenfunction A is (n j) (v j) (heigen j)] + dsimp only [keep] + split_ifs <;> rfl + apply finite_projection_tested_error weight (fun x => f (path x)) + (fun x => iteratedCircleAverage A is f (path x)) + (fun j x => v j (path x)) keep hB htau hweight (fun x => happrox (path x)) _ hdiscard + intro x + rw [← hsum, norm_sub_rev] + exact iteratedCircleAverage_sub_norm_le A is hf (lipschitz_finite_complex_sum v Lv hv) + happrox (path x) + +end Erdos3.CircleFourier + +end + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +namespace FiniteProbabilityWeights + +variable {G : Type*} [Fintype G] (p : FiniteProbabilityWeights G) + +theorem norm_tested_difference_le (w f g : G → ℂ) {B rho : ℝ} (hB : 0 ≤ B) + (hw : ∀ x, ‖w x‖ ≤ B) (hfg : ∀ x, ‖f x - g x‖ ≤ rho) : + ‖p.complexMean (fun x => w x * f x) - p.complexMean (fun x => w x * g x)‖ ≤ B * rho := by + apply (p.norm_complexMean_sub_le _ _ (fun _ => B * rho) ?_).trans_eq (p.mean_const _) + intro x _ + rw [← mul_sub, norm_mul] + exact mul_le_mul (hw x) (hfg x) (norm_nonneg _) hB + +theorem finite_projection_tested_error {J : Type*} [Fintype J] + (w f projected : G → ℂ) (v : J → G → ℂ) (keep : J → Prop) [DecidablePred keep] + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) (hw : ∀ x, ‖w x‖ ≤ B) + (hfull : ∀ x, ‖f x - ∑ j, v j x‖ ≤ rho) + (hprojected : ∀ x, ‖(∑ j, if keep j then v j x else 0) - projected x‖ ≤ rho) + (hdiscard : ∀ j, ¬ keep j → ‖p.complexMean (fun x => w x * v j x)‖ ≤ tau) : + ‖p.complexMean (fun x => w x * f x) - p.complexMean (fun x => w x * projected x)‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + have hfirst := p.norm_tested_difference_le w f (fun x => ∑ j, v j x) hB hw hfull + have hlast := p.norm_tested_difference_le w + (fun x => ∑ j, if keep j then v j x else 0) projected hB hw hprojected + have hid : p.complexMean (fun x => w x * ∑ j, v j x) - + p.complexMean (fun x => w x * ∑ j, if keep j then v j x else 0) = + ∑ j, if keep j then 0 else p.complexMean (fun x => w x * v j x) := by + rw [← p.complexMean_sub] + calc + _ = ∑ x, ∑ j, if keep j then 0 else (p.weight x : ℂ) * (w x * v j x) := by + apply Finset.sum_congr rfl + intro x _ + dsimp only + rw [← mul_sub, ← Finset.sum_sub_distrib, Finset.mul_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj] + _ = ∑ j, ∑ x, if keep j then 0 else (p.weight x : ℂ) * (w x * v j x) := + Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj, complexMean] + have hmiddle : ‖p.complexMean (fun x => w x * ∑ j, v j x) - + p.complexMean (fun x => w x * ∑ j, if keep j then v j x else 0)‖ ≤ Fintype.card J * tau := by + rw [hid] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ _j : J, tau := by + apply Finset.sum_le_sum + intro j _ + by_cases hj : keep j + · simpa only [hj, ite_true, norm_zero] using htau + · simpa only [hj, ite_false] using hdiscard j hj + _ = _ := by simp + have htriangle := norm_sub_le_norm_sub_add_norm_sub + (p.complexMean (fun x => w x * f x)) (p.complexMean (fun x => w x * ∑ j, v j x)) + (p.complexMean (fun x => w x * projected x)) + have htriangle' := norm_sub_le_norm_sub_add_norm_sub + (p.complexMean (fun x => w x * ∑ j, v j x)) + (p.complexMean (fun x => w x * ∑ j, if keep j then v j x else 0)) + (p.complexMean (fun x => w x * projected x)) + linarith + +end FiniteProbabilityWeights + +namespace CircleFourier + +theorem iteratedCircleAverage_tested_weighted_error + {X α G J : Type*} [PseudoMetricSpace X] [Fintype G] [Fintype J] + (p : FiniteProbabilityWeights G) + (A : α → IsometricCircleAction X) (is : List α) (f : X → ℂ) + (v : J → X → ℂ) (n : J → α → ℤ) (path : G → X) (weight : G → ℂ) + (Lf : ℝ≥0) (Lv : J → ℝ≥0) (hf : LipschitzWith Lf f) + (hv : ∀ j, LipschitzWith (Lv j) (v j)) + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hweight : ∀ x, ‖weight x‖ ≤ B) + (happrox : ∀ x, ‖f x - ∑ j, v j x‖ ≤ rho) + (heigen : ∀ j i, i ∈ is → ∀ t x, v j ((A i).act t x) = character (n j i • t) * v j x) + (hdiscard : ∀ j, ¬ (∀ i ∈ is, n j i = 0) → + ‖p.complexMean (fun x => weight x * v j (path x))‖ ≤ tau) : + ‖p.complexMean (fun x => weight x * f (path x)) - + p.complexMean (fun x => weight x * iteratedCircleAverage A is f (path x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + classical + let keep : J → Prop := fun j => ∀ i ∈ is, n j i = 0 + have hsum (x : X) : iteratedCircleAverage A is (fun y => ∑ j, v j y) x = + ∑ j, if keep j then v j x else 0 := by + rw [iteratedCircleAverage_sum A is Finset.univ v Lv (fun j _ => hv j)] + apply Finset.sum_congr rfl + intro j _ + rw [iteratedCircleAverage_eigenfunction A is (n j) (v j) (heigen j)] + dsimp only [keep] + split_ifs <;> rfl + apply p.finite_projection_tested_error weight (fun x => f (path x)) + (fun x => iteratedCircleAverage A is f (path x)) + (fun j x => v j (path x)) keep hB htau hweight (fun x => happrox (path x)) _ hdiscard + intro x + rw [← hsum, norm_sub_rev] + exact iteratedCircleAverage_sub_norm_le A is hf (lipschitz_finite_complex_sum v Lv hv) + happrox (path x) + +theorem iteratedCircleAverage_weighted_error + {X α G J : Type*} [PseudoMetricSpace X] [Fintype G] [Fintype J] + (A : α → IsometricCircleAction X) (is : List α) (f : X → ℂ) + (v : J → X → ℂ) (n : J → α → ℤ) (path : G → X) (weight : G → ℂ) + (Lf : ℝ≥0) (Lv : J → ℝ≥0) (hf : LipschitzWith Lf f) + (hv : ∀ j, LipschitzWith (Lv j) (v j)) + {B rho tau : ℝ} (hmass : (∑ x, ‖weight x‖) ≤ B) + (hrho : 0 ≤ rho) (htau : 0 ≤ tau) + (happrox : ∀ x, ‖f x - ∑ j, v j x‖ ≤ rho) + (heigen : ∀ j i, i ∈ is → ∀ t x, v j ((A i).act t x) = character (n j i • t) * v j x) + (hdiscard : ∀ j, ¬ (∀ i ∈ is, n j i = 0) → + ‖∑ x, weight x * v j (path x)‖ ≤ tau) : + ‖(∑ x, weight x * f (path x)) - + (∑ x, weight x * iteratedCircleAverage A is f (path x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + classical + let keep : J → Prop := fun j => ∀ i ∈ is, n j i = 0 + let full : X → ℂ := fun x => ∑ j, v j x + let retained : X → ℂ := fun x => ∑ j, if keep j then v j x else 0 + have hsum (x : X) : iteratedCircleAverage A is full x = retained x := by + rw [iteratedCircleAverage_sum A is Finset.univ v Lv (fun j _ => hv j)] + apply Finset.sum_congr rfl + intro j _ + rw [iteratedCircleAverage_eigenfunction A is (n j) (v j) (heigen j)] + dsimp only [keep] + split_ifs <;> rfl + have htested (a b : X → ℂ) (hab : ∀ x, ‖a x - b x‖ ≤ rho) : + ‖(∑ x, weight x * a (path x)) - (∑ x, weight x * b (path x))‖ ≤ B * rho := by + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ x, ‖weight x * a (path x) - weight x * b (path x)‖ := norm_sum_le _ _ + _ ≤ ∑ x, ‖weight x‖ * rho := by + apply Finset.sum_le_sum + intro x _ + rw [← mul_sub, norm_mul] + exact mul_le_mul_of_nonneg_left (hab (path x)) (norm_nonneg _) + _ = (∑ x, ‖weight x‖) * rho := (Finset.sum_mul ..).symm + _ ≤ B * rho := mul_le_mul_of_nonneg_right hmass hrho + have hfirst := htested f full happrox + have hlast := htested retained (iteratedCircleAverage A is f) (fun x => by + rw [← hsum, norm_sub_rev] + exact iteratedCircleAverage_sub_norm_le A is hf (lipschitz_finite_complex_sum v Lv hv) + happrox x) + have hid : (∑ x, weight x * full (path x)) - (∑ x, weight x * retained (path x)) = + ∑ j, if keep j then 0 else ∑ x, weight x * v j (path x) := by + simp only [full, retained, Finset.mul_sum] + rw [Finset.sum_comm, Finset.sum_comm (f := fun x j => weight x * if keep j then v j (path x) else 0), + ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj] + have hmiddle : ‖(∑ x, weight x * full (path x)) - (∑ x, weight x * retained (path x))‖ ≤ + Fintype.card J * tau := by + rw [hid] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ _j : J, tau := by + apply Finset.sum_le_sum + intro j _ + by_cases hj : keep j + · simpa only [hj, ite_true, norm_zero] using htau + · simpa only [hj, ite_false] using hdiscard j hj + _ = _ := by simp + have htri := norm_sub_le_norm_sub_add_norm_sub + (∑ x, weight x * f (path x)) (∑ x, weight x * full (path x)) + (∑ x, weight x * iteratedCircleAverage A is f (path x)) + have htri' := norm_sub_le_norm_sub_add_norm_sub + (∑ x, weight x * full (path x)) (∑ x, weight x * retained (path x)) + (∑ x, weight x * iteratedCircleAverage A is f (path x)) + linarith + +end CircleFourier +end Erdos3 + +end + +section + +namespace Erdos3.CircleFourier + +open scoped BigOperators NNReal + +theorem iteratedCircleAverage_family_tested_weighted_error + {X Y α G J : Type*} [PseudoMetricSpace Y] [Fintype G] [Fintype J] + (p : FiniteProbabilityWeights G) + (A : α → IsometricCircleAction Y) (is : List α) (f : X → Y → ℂ) + (v : J → X → Y → ℂ) (n : J → α → ℤ) + (physical : G → X) (path : G → Y) (weight : G → ℂ) + (Lf : X → ℝ≥0) (Lv : J → X → ℝ≥0) + (hf : ∀ x, LipschitzWith (Lf x) (f x)) + (hv : ∀ j x, LipschitzWith (Lv j x) (v j x)) + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hweight : ∀ g, ‖weight g‖ ≤ B) + (happrox : ∀ x y, ‖f x y - ∑ j, v j x y‖ ≤ rho) + (heigen : ∀ j i, i ∈ is → ∀ t x y, + v j x ((A i).act t y) = character (n j i • t) * v j x y) + (hdiscard : ∀ j, ¬ (∀ i ∈ is, n j i = 0) → + ‖p.complexMean (fun g => weight g * v j (physical g) (path g))‖ ≤ tau) : + ‖p.complexMean (fun g => weight g * f (physical g) (path g)) - + p.complexMean (fun g => + weight g * iteratedCircleAverage A is (f (physical g)) (path g))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + classical + let keep : J → Prop := fun j => ∀ i ∈ is, n j i = 0 + have hsum (x : X) (y : Y) : + iteratedCircleAverage A is (fun z => ∑ j, v j x z) y = + ∑ j, if keep j then v j x y else 0 := by + rw [iteratedCircleAverage_sum A is Finset.univ + (fun j => v j x) (fun j => Lv j x) (fun j _ => hv j x)] + apply Finset.sum_congr rfl + intro j _ + rw [iteratedCircleAverage_eigenfunction A is (n j) (v j x) + (fun i hi t y => heigen j i hi t x y)] + dsimp only [keep] + split_ifs <;> rfl + apply p.finite_projection_tested_error weight + (fun g => f (physical g) (path g)) + (fun g => iteratedCircleAverage A is (f (physical g)) (path g)) + (fun j g => v j (physical g) (path g)) keep hB htau hweight + (fun g => happrox (physical g) (path g)) _ hdiscard + intro g + rw [← hsum, norm_sub_rev] + exact iteratedCircleAverage_sub_norm_le A is (hf (physical g)) + (lipschitz_finite_complex_sum (fun j => v j (physical g)) + (fun j => Lv j (physical g)) (fun j => hv j (physical g))) + (happrox (physical g)) (path g) + +end Erdos3.CircleFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyKernelProjectionQuantitative.lean b/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyKernelProjectionQuantitative.lean new file mode 100644 index 0000000000000000000000000000000000000000..08b10ea1deba8e8df56ace98c8defcb4f06626b0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyKernelProjectionQuantitative.lean @@ -0,0 +1,108 @@ +import OAI.Combinatorics.Progressions.Estimates.ExternalUnitFamilyVerticalExpansion +import OAI.Combinatorics.Progressions.Linear.ExternalFamilyPrecenterProjectionData + +namespace OAI + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_external_family_quantitative_kernel_projection_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ X Ω G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : X → D.Niltest w) (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (∀ x, (T x).UnitIntervalValued) → (∀ x, (T x).ComplexityLE p) → + ∀ (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s), + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (physical : Ω → G → X) + (path : Ω → G → D.Space) (weight : Ω → G → ℂ), + (∀ a x, ‖weight a x‖ ≤ Real.exp p) → + (∀ a ∈ productive, Real.exp (-p) ≤ ((localLaw a).complexMean + (fun x => weight a x * (T (physical a x)).observable (path a x))).re) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → X → D.Niltest w) + (code : Fin (finrank ℚ P) → Option J) (S : X → D.Niltest w) (retained : Finset Ω), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j x, (U j x).ComplexityLE ((p + 2) ^ C) ∧ + (U j x).orbit = (T x).orbit ∧ (U j x).normBound = (T x).normBound ∧ + (U j x).lipBound = (T x).lipBound) ∧ + (∀ j a (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j a).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j a).observable x) ∧ + (∀ x, (S x).UnitIntervalValued ∧ (S x).ComplexityLE ((p + 2) ^ C) ∧ + (S x).orbit = (T x).orbit) ∧ + (∀ x, S x = (T x).kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP)) ∧ + (∀ a (z : D.RealGroup), z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, (S a).observable (z • x) = (S a).observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun x => + weight a x * (U j (physical a x)).observable (path a x))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ ((localLaw a).complexMean + (fun x => weight a x * (S (physical a x)).observable (path a x))).re := by + let R : Polynomial ℕ := Polynomial.X + let Q := 2 * R + 8 + let A := (Q + 3) ^ 9 + 2 * Q + 2 + let V := 2 * A * (2 * A + 2) ^ 4 + ((2 * A + 2) ^ 4 + A + (Q + 3) ^ 5 + 2) ^ 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + (Q + 2 * V + R + 10 + R * (V + 1)) + refine ⟨C, hC, ?_⟩ + intro L σ X Ω G _ _ s d _ _ _ _ _ _ D w T p hp hD hT hTc P hP + outer productive localLaw physical path weight hweight hscore + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let q := 2 * p + 8 + let v := verticalDecompositionBudget q + have hq : 0 ≤ q := by dsimp [q]; linarith + have hpq : p ≤ q := by dsimp [q]; linarith + have hv : 0 ≤ v := verticalDecompositionBudget_nonneg hq + have hprod : 0 ≤ p * (v + 1) := by positivity + have hb : q + 2 * v + p + 10 + p * (v + 1) ≤ (p + 2) ^ C := by + simpa [R, Q, A, V, q, v, verticalDecompositionBudget, centralActionBudget, + Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + 2) ^ C := by linarith + have hvC : v ≤ (p + 2) ^ C := by linarith + have htC : p + v + 8 ≤ (p + 2) ^ C := by linarith + have hnC : p * (v + 1) ≤ (p + 2) ^ C := by linarith + have hsC : p + 1 ≤ (p + 2) ^ C := by linarith + obtain ⟨J, inst, eta, U, hJ, hheight, hU, hvert, hint, hchar, happrox, hintError, hrealError⟩ := + D.exists_externalFamily_vertical_expansion hq (hD.mono D hpq) T + (fun x => (hTc x).mono hpq) (Real.exp (-q)) (Real.exp_pos (-q)) + (by rw [Real.exp_neg, inv_inv]) + let _ := inst + have hsmall := frequency_projection_error_bound hp hJ + obtain ⟨code, S, retained, hidentity, hS, hSinv, hretained, hmass, hlocal⟩ := + RationalFilteredNilmanifold.Niltest.exists_external_family_common_positive_kernel_projection + T hT hTc P hP eta U hvert outer productive localLaw physical path weight + (Real.exp_nonneg p) (Real.exp_nonneg (-(p + v + 8))) hweight happrox hscore hsmall + have hdim : (finrank ℚ P : ℝ) ≤ p := by + have h := Submodule.finrank_le P + rw [finrank_eq_card_basis D.basis, Fintype.card_fin] at h + exact (Nat.cast_le.mpr h).trans hD.1 + refine ⟨J, inst, eta, U, code, S, retained, + hJ.trans (Real.exp_le_exp.mpr hvC), fun j i => (hheight j i).trans hvC, + fun j x => ⟨(hU j x).1.mono hqC, (hU j x).2⟩, hvert, + fun x => ⟨(hS x).1, (hS x).2.1.mono (hpq.trans hqC), (hS x).2.2⟩, + hidentity, hSinv, hretained, ?_, ?_⟩ + · exact (mass_div_frequency_count (outer.mass_nonneg productive) hp hv hdim hJ hnC).trans hmass + · intro a ha + obtain ⟨hpivot, hpositive⟩ := hlocal a ha + refine ⟨fun i j hij => (Real.exp_le_exp.mpr (neg_le_neg htC)).trans_lt (hpivot i j hij), ?_⟩ + exact ((Real.exp_le_exp.mpr (by linarith : -((p + 2) ^ C) ≤ -p - 1)).trans + (exp_sub_one_le_half_exp (-p))).trans hpositive + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyPrecenterProjectionData.lean b/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyPrecenterProjectionData.lean new file mode 100644 index 0000000000000000000000000000000000000000..7643d63563d41c4ceb71d02218e4a343c41a88db --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ExternalFamilyPrecenterProjectionData.lean @@ -0,0 +1,860 @@ +import OAI.Combinatorics.Progressions.Estimates.ExternalPhysicalMemberPivotMasks +import OAI.Combinatorics.Progressions.Fourier.FrequencyProjectionBudget + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module CircleFourier +open scoped TensorProduct BigOperators + +variable {L σ G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def kernelProjection (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) : D.Niltest w := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let b := Module.finBasis ℚ K + exact T.averageCircles + (fun i => D.centralRationalCircle (b i).val (hK (b i).property)) + (List.finRange (finrank ℚ K)) + +theorem kernelProjection_orbit (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) : + (T.kernelProjection K hK).orbit = T.orbit := rfl + +theorem kernelProjection_congr (T : D.Niltest w) {K K' : Submodule ℚ L} + (hK : K ≤ D.filtration.layer s) (hK' : K' ≤ D.filtration.layer s) (h : K = K') : + T.kernelProjection K hK = T.kernelProjection K' hK' := by + subst K' + rfl + +theorem kernelProjection_complexity (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) {p : ℝ} (hT : T.ComplexityLE p) : + (T.kernelProjection K hK).ComplexityLE p := hT + +theorem kernelProjection_unitInterval (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) (hT : T.UnitIntervalValued) : + (T.kernelProjection K hK).UnitIntervalValued := by + unfold kernelProjection + exact T.averageCircles_unit_interval _ _ hT + +theorem kernelProjection_observable_congr (T U : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) (hTU : T.observable = U.observable) : + (T.kernelProjection K hK).observable = (U.kernelProjection K hK).observable := by + unfold kernelProjection averageCircles + dsimp only + rw [hTU] + +theorem kernelProjection_invariant (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + (z : D.RealGroup) (hz : z.coord ∈ K.baseChange ℝ) (x : D.Space) : + (T.kernelProjection K hK).observable (z • x) = (T.kernelProjection K hK).observable x := by + let := D.metricSpace + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let b := Module.finBasis ℚ K + apply D.invariant_of_kernel_circles K hK b _ _ z hz x + intro i t y + apply T.averageCircles_invariant + · dsimp only + intro j _ k _ + exact D.centralRationalCircle_commutes (b j).val (b k).val (hK (b j).property) (hK (b k).property) + · simp + +theorem kernelProjection_tested_error [Fintype G] (T : D.Niltest w) + (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s) + {J : Type*} [Fintype J] (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (hvertical : ∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) + (law : FiniteProbabilityWeights G) (path : G → D.Space) (weight : G → ℂ) + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) (hweight : ∀ x, ‖weight x‖ ≤ B) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (js : List J) + (hsignificant : ∀ j, tau < ‖law.complexMean (fun x => weight x * (U j).observable (path x))‖ → j ∈ js) : + ‖law.complexMean (fun x => weight x * T.observable (path x)) - + law.complexMean (fun x => weight x * + (T.kernelProjection (finiteFrequencyKernel P eta js) + ((finiteFrequencyKernel_le P eta js).trans hP)).observable (path x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + let := D.metricSpace + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let K := finiteFrequencyKernel P eta js + have hK : K ≤ D.filtration.layer s := (finiteFrequencyKernel_le P eta js).trans hP + let b := Module.finBasis ℚ K + let A := fun i => D.centralRationalCircle (b i).val (hK (b i).property) + have hfreq (j : J) (i : Fin (finrank ℚ K)) : ∃ n : ℤ, + (∀ t x, (U j).observable ((A i).act t x) = character (n • t) * (U j).observable x) ∧ + (eta j (b i).val = 0 → n = 0) := + D.exists_centralRationalCircle_frequency (b i).val (hK (b i).property) + (eta j) (U j).observable (hvertical j) + choose n heigen hzero using hfreq + apply iteratedCircleAverage_tested_weighted_error law A (List.finRange (finrank ℚ K)) + T.observable (fun j => (U j).observable) n path weight T.lipBound (fun j => (U j).lipBound) + T.lipschitz (fun j => (U j).lipschitz) hB htau hweight happrox + (fun j i _ => heigen j i) + intro j hj + apply le_of_not_gt + intro hlarge + apply hj + intro i _ + apply hzero j i + exact ((mem_finiteFrequencyKernel P eta js (b i).val).mp (b i).property).2 j + (hsignificant j hlarge) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct BigOperators + +variable {L σ X G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem exists_external_family_centralRationalCircle_frequency + (v : L) (hv : v ∈ D.filtration.layer s) + (eta : L →ₗ[ℚ] ℚ) (f : X → D.Space → ℂ) + (hf : ∀ a (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + f a (z • x) = + character ((realifyFunctional eta z.coord : ℝ) : CircleFourier.Circle) * f a x) : + let := D.metricSpace + ∃ n : ℤ, + (∀ a t x, f a ((D.centralRationalCircle v hv).act t x) = + character (n • t) * f a x) ∧ + (eta v = 0 → n = 0) := by + classical + let := D.metricSpace + by_cases hz : ∀ a x, f a x = 0 + · exact ⟨0, fun a t x => by simp [hz], fun _ => rfl⟩ + push Not at hz + obtain ⟨a, x, hax⟩ := hz + obtain ⟨n, hn⟩ := vertical_frequency_integral_on_lattice D.filtration D.realLattice + eta (f a) (hf a) ⟨x, hax⟩ (⟨D.periodicRealDirection v⟩ : D.RealGroup) + (D.periodicRealDirection_mem_top v hv) (D.periodicRealDirection_mem_lattice v) + refine ⟨n, ?_, ?_⟩ + · intro a t x + obtain ⟨r, rfl⟩ := QuotientAddGroup.mk_surjective t + rw [D.centralRationalCircle_act_coe] + have hr : realBCHLine (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + (D.periodicRealDirection v) r ∈ D.filtration.realification.subgroup s := by + change r • D.periodicRealDirection v ∈ D.filtration.realLayer s + exact (D.filtration.realLayer s).smul_mem r (D.periodicRealDirection_mem_top v hv) + rw [hf a _ hr] + apply congrArg (fun z : CircleFourier.Circle => character z * f a x) + change ((realifyFunctional eta (r • D.periodicRealDirection v) : ℝ) : CircleFourier.Circle) = + n • (r : CircleFourier.Circle) + rw [map_smul, hn, ← AddCircle.coe_zsmul] + congr 1 + simp only [smul_eq_mul, zsmul_eq_mul, mul_comm] + · intro heta + have hzero : realifyFunctional eta (D.periodicRealDirection v) = 0 := by + simp [periodicRealDirection, realifyFunctional_tmul, heta] + have hn0 : (n : ℝ) = 0 := hn.symm.trans hzero + exact_mod_cast hn0 + +namespace Niltest + +theorem external_family_kernelProjection_tested_error [Fintype G] + (T : X → D.Niltest w) (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s) + {J : Type*} [Fintype J] (eta : J → L →ₗ[ℚ] ℚ) (U : J → X → D.Niltest w) + (hvertical : ∀ j a (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j a).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j a).observable x) + (law : FiniteProbabilityWeights G) (physical : G → X) + (path : G → D.Space) (weight : G → ℂ) + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hweight : ∀ x, ‖weight x‖ ≤ B) + (happrox : ∀ a x, ‖(T a).observable x - ∑ j, (U j a).observable x‖ ≤ rho) + (js : List J) + (hsignificant : ∀ j, + tau < ‖law.complexMean (fun x => weight x * (U j (physical x)).observable (path x))‖ → + j ∈ js) : + ‖law.complexMean (fun x => weight x * (T (physical x)).observable (path x)) - + law.complexMean (fun x => weight x * + ((T (physical x)).kernelProjection (finiteFrequencyKernel P eta js) + ((finiteFrequencyKernel_le P eta js).trans hP)).observable (path x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + let := D.metricSpace + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let K := finiteFrequencyKernel P eta js + have hK : K ≤ D.filtration.layer s := (finiteFrequencyKernel_le P eta js).trans hP + let b := Module.finBasis ℚ K + let A := fun i => D.centralRationalCircle (b i).val (hK (b i).property) + have hfreq (j : J) (i : Fin (finrank ℚ K)) : ∃ n : ℤ, + (∀ a t x, (U j a).observable ((A i).act t x) = + character (n • t) * (U j a).observable x) ∧ + (eta j (b i).val = 0 → n = 0) := + exists_external_family_centralRationalCircle_frequency (b i).val (hK (b i).property) + (eta j) (fun a => (U j a).observable) (hvertical j) + choose n heigen hzero using hfreq + apply iteratedCircleAverage_family_tested_weighted_error law A + (List.finRange (finrank ℚ K)) (fun a => (T a).observable) + (fun j a => (U j a).observable) n physical path weight + (fun a => (T a).lipBound) (fun j a => (U j a).lipBound) + (fun a => (T a).lipschitz) (fun j a => (U j a).lipschitz) + hB htau hweight happrox (fun j i _ t a x => heigen j i a t x) + intro j hj + apply le_of_not_gt + intro hlarge + apply hj + intro i _ + apply hzero j i + exact ((mem_finiteFrequencyKernel P eta js (b i).val).mp (b i).property).2 j + (hsignificant j hlarge) + +end Niltest + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module CircleFourier +open scoped TensorProduct + +variable {L σ τ : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} {v : τ → ℕ} + +theorem kernelProjection_observable_sub_norm_le (T : D.Niltest w) (U : D.Niltest v) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) {ε : ℝ} + (hTU : ∀ x, ‖T.observable x - U.observable x‖ ≤ ε) : + ∀ x, ‖(T.kernelProjection K hK).observable x - (U.kernelProjection K hK).observable x‖ ≤ ε := by + let := D.metricSpace + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let b := Module.finBasis ℚ K + exact iteratedCircleAverage_sub_norm_le + (fun i => D.centralRationalCircle (b i).val (hK (b i).property)) + (List.finRange (finrank ℚ K)) T.lipschitz U.lipschitz hTU + +theorem kernelProjection_normBound (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) : + (T.kernelProjection K hK).normBound = T.normBound := rfl + +theorem kernelProjection_lipBound (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) : + (T.kernelProjection K hK).lipBound = T.lipBound := rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup CircleFourier MeasureTheory +open scoped TensorProduct + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem exists_iteratedCentralCircle_translation (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) (v : ι → K) (is : List ι) + (t : CircleAverageTuple is) : + let := D.metricSpace + ∃ g : D.RealGroup, g.coord ∈ K.baseChange ℝ ∧ + (∀ y : ℝ ⊗[ℚ] L, ⁅g.coord, y⁆ = 0) ∧ + ∀ x, iteratedCircleAction + (fun i => D.centralRationalCircle (v i) (hK (v i).property)) is t x = g • x := by + let := D.metricSpace + induction is with + | nil => + refine ⟨1, (K.baseChange ℝ).zero_mem, fun y => zero_lie y, ?_⟩ + intro x + exact (one_smul D.RealGroup x).symm + | cons i is ih => + obtain ⟨g, hg, hcentral, hact⟩ := ih t.2 + obtain ⟨r, hr⟩ := QuotientAddGroup.mk_surjective t.1 + let z : D.RealGroup := realBCHLine (D.periodicRealDirection (v i)) r + have hz : z.coord ∈ K.baseChange ℝ := by + apply (K.baseChange ℝ).smul_mem r + change (1 : ℝ) ⊗ₜ[ℚ] ((D.rationalDirectionPeriod (v i) : ℚ) • (v i : L)) ∈ _ + exact Submodule.tmul_mem_baseChange_of_mem 1 (K.smul_mem _ (v i).property) + have hzc : ∀ y : ℝ ⊗[ℚ] L, ⁅z.coord, y⁆ = 0 := by + intro y + change ⁅r • D.periodicRealDirection (v i), y⁆ = 0 + rw [smul_lie, D.periodicRealDirection_central (v i) (hK (v i).property), smul_zero] + have hcoord : (g * z).coord = g.coord + z.coord := + lieBCH_eq_add_of_lie_eq_zero D.filtration.realification.lowerCentralSeries_eq_bot + (hcentral z.coord) + refine ⟨g * z, ?_, ?_, ?_⟩ + · rw [hcoord] + exact (K.baseChange ℝ).add_mem hg hz + · intro y + rw [hcoord, add_lie, hcentral, hzc, add_zero] + · intro x + change iteratedCircleAction _ is t.2 + ((D.centralRationalCircle (v i) (hK (v i).property)).act t.1 x) = _ + rw [hact, ← hr, D.centralRationalCircle_act_coe, mul_smul] + +abbrev KernelProjectionParameters (K : Submodule ℚ L) := + CircleAverageTuple (List.finRange (finrank ℚ K)) + +noncomputable def kernelProjectionCircleFamily (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) : + let := D.metricSpace + Fin (finrank ℚ K) → IsometricCircleAction D.Space := by + let := D.metricSpace + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + exact fun i => D.centralRationalCircle (Module.finBasis ℚ K i) + (hK (Module.finBasis ℚ K i).property) + +theorem exists_kernelProjectionTranslation (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) (t : KernelProjectionParameters K) : + let := D.metricSpace + ∃ g : D.RealGroup, g.coord ∈ K.baseChange ℝ ∧ + (∀ y : ℝ ⊗[ℚ] L, ⁅g.coord, y⁆ = 0) ∧ + ∀ x, iteratedCircleAction (D.kernelProjectionCircleFamily K hK) + (List.finRange (finrank ℚ K)) t x = g • x := by + let := D.metricSpace + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + exact D.exists_iteratedCentralCircle_translation K hK (Module.finBasis ℚ K) + (List.finRange (finrank ℚ K)) t + +noncomputable def kernelProjectionTranslation (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) (t : KernelProjectionParameters K) : D.RealGroup := + (D.exists_kernelProjectionTranslation K hK t).choose + +theorem kernelProjectionTranslation_mem (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) (t : KernelProjectionParameters K) : + (D.kernelProjectionTranslation K hK t).coord ∈ K.baseChange ℝ := + (D.exists_kernelProjectionTranslation K hK t).choose_spec.1 + +theorem kernelProjectionTranslation_central (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) (t : KernelProjectionParameters K) + (y : ℝ ⊗[ℚ] L) : ⁅(D.kernelProjectionTranslation K hK t).coord, y⁆ = 0 := + (D.exists_kernelProjectionTranslation K hK t).choose_spec.2.1 y + +theorem kernelProjectionTranslation_act (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) (t : KernelProjectionParameters K) (x : D.Space) : + let := D.metricSpace + iteratedCircleAction (D.kernelProjectionCircleFamily K hK) + (List.finRange (finrank ℚ K)) t x = D.kernelProjectionTranslation K hK t • x := + (D.exists_kernelProjectionTranslation K hK t).choose_spec.2.2 x + +theorem continuous_kernelProjectionTranslation_act (K : Submodule ℚ L) + (hK : K ≤ D.filtration.layer s) (x : D.Space) : + let := D.metricSpace + Continuous (fun t => D.kernelProjectionTranslation K hK t • x) := by + let := D.metricSpace + have he : (fun t => D.kernelProjectionTranslation K hK t • x) = + (fun t => iteratedCircleAction (D.kernelProjectionCircleFamily K hK) + (List.finRange (finrank ℚ K)) t x) := + funext (fun t => (D.kernelProjectionTranslation_act K hK t x).symm) + rw [he] + exact continuous_iteratedCircleAction_parameter _ _ _ + +namespace Niltest + +variable {D} {σ : Type*} {w : σ → ℕ} + +theorem continuous_kernelProjectionTranslation_observable (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) (x : D.Space) : + Continuous (fun t => T.observable (D.kernelProjectionTranslation K hK t • x)) := by + let := D.metricSpace + exact T.lipschitz.continuous.comp (D.continuous_kernelProjectionTranslation_act K hK x) + +theorem integrable_kernelProjectionTranslation_observable (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) (x : D.Space) : + Integrable (fun t => T.observable (D.kernelProjectionTranslation K hK t • x)) + (circleAverageTupleMeasure (List.finRange (finrank ℚ K))) := + (T.continuous_kernelProjectionTranslation_observable K hK x).integrable_of_hasCompactSupport + (HasCompactSupport.of_compactSpace _) + +theorem kernelProjection_observable_eq_integral (T : D.Niltest w) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) (x : D.Space) : + (T.kernelProjection K hK).observable x = + ∫ t, T.observable (D.kernelProjectionTranslation K hK t • x) + ∂circleAverageTupleMeasure (List.finRange (finrank ℚ K)) := by + let := D.metricSpace + change iteratedCircleAverage (D.kernelProjectionCircleFamily K hK) + (List.finRange (finrank ℚ K)) T.observable x = _ + rw [iteratedCircleAverage_eq_integral _ _ T.lipschitz.continuous] + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun t => congrArg T.observable + (D.kernelProjectionTranslation_act K hK t x)) + +end Niltest +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_common_positive_kernel_projection + {L σ Ω G J : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] [Fintype J] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (hT : T.UnitIntervalValued) {p : ℝ} (hTc : T.ComplexityLE p) + (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s) + (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (hvertical : ∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) + (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (path : Ω → G → D.Space) (weight : Ω → G → ℂ) + {B rho tau delta : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hweight : ∀ a x, ‖weight a x‖ ≤ B) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (hscore : ∀ a ∈ productive, + delta ≤ ((localLaw a).complexMean (fun x => weight a x * T.observable (path a x))).re) + (hsmall : 2 * B * rho + Fintype.card J * tau ≤ delta / 2) : + ∃ (code : Fin (finrank ℚ P) → Option J) (S : D.Niltest w) (retained : Finset Ω), + S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive / (Fintype.card J + 1) ^ finrank ℚ P ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → + tau < ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖) ∧ + delta / 2 ≤ ((localLaw a).complexMean (fun x => weight a x * S.observable (path a x))).re := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let js : Ω → List J := fun a => (Finset.univ.filter (fun j => + tau < ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖)).toList + obtain ⟨code, retained, hretained, hmass, hcode⟩ := + exists_common_frequency_kernel outer productive P eta js + let K := frequencyCodeKernel P eta code + have hK : K ≤ D.filtration.layer s := + (finiteFrequencyKernel_le P _ _).trans hP + let S := T.kernelProjection K hK + refine ⟨code, S, retained, T.kernelProjection_unitInterval K hK hT, + T.kernelProjection_complexity K hK hTc, T.kernelProjection_orbit K hK, + ?_, hretained, hmass, ?_⟩ + · intro z hz x + exact T.kernelProjection_invariant K hK z hz x + · intro a ha + obtain ⟨hpivots, hk⟩ := hcode a ha + have hsignificant (j : J) + (hj : tau < ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖) : + j ∈ js a := by simpa only [js, Finset.mem_toList, Finset.mem_filter, Finset.mem_univ, true_and] using hj + have herr := T.kernelProjection_tested_error P hP eta U hvertical (localLaw a) + (path a) (weight a) hB htau (hweight a) happrox (js a) hsignificant + rw [T.kernelProjection_congr _ hK hk] at herr + refine ⟨?_, ?_⟩ + · intro i j hij + simpa only [js, Finset.mem_toList, Finset.mem_filter, Finset.mem_univ, true_and] using hpivots i j hij + · have hr := Complex.re_le_norm + ((localLaw a).complexMean (fun x => weight a x * T.observable (path a x)) - + (localLaw a).complexMean (fun x => weight a x * S.observable (path a x))) + rw [Complex.sub_re] at hr + have hs := hscore a (hretained ha) + change ‖(localLaw a).complexMean (fun x => weight a x * T.observable (path a x)) - + (localLaw a).complexMean (fun x => weight a x * S.observable (path a x))‖ ≤ _ at herr + linarith + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_external_family_common_positive_kernel_projection + {L σ X Ω G J : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] [Fintype J] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : X → D.Niltest w) (hT : ∀ x, (T x).UnitIntervalValued) + {p : ℝ} (hTc : ∀ x, (T x).ComplexityLE p) + (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s) + (eta : J → L →ₗ[ℚ] ℚ) (U : J → X → D.Niltest w) + (hvertical : ∀ j a (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j a).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j a).observable x) + (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (physical : Ω → G → X) + (path : Ω → G → D.Space) (weight : Ω → G → ℂ) + {B rho tau delta : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hweight : ∀ a x, ‖weight a x‖ ≤ B) + (happrox : ∀ a x, ‖(T a).observable x - ∑ j, (U j a).observable x‖ ≤ rho) + (hscore : ∀ a ∈ productive, + delta ≤ ((localLaw a).complexMean (fun x => + weight a x * (T (physical a x)).observable (path a x))).re) + (hsmall : 2 * B * rho + Fintype.card J * tau ≤ delta / 2) : + ∃ (code : Fin (finrank ℚ P) → Option J) (S : X → D.Niltest w) + (retained : Finset Ω), + (∀ x, S x = (T x).kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP)) ∧ + (∀ x, (S x).UnitIntervalValued ∧ (S x).ComplexityLE p ∧ (S x).orbit = (T x).orbit) ∧ + (∀ a (z : D.RealGroup), z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, (S a).observable (z • x) = (S a).observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive / (Fintype.card J + 1) ^ finrank ℚ P ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → + tau < ‖(localLaw a).complexMean (fun x => + weight a x * (U j (physical a x)).observable (path a x))‖) ∧ + delta / 2 ≤ ((localLaw a).complexMean (fun x => + weight a x * (S (physical a x)).observable (path a x))).re := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let js : Ω → List J := fun a => (Finset.univ.filter (fun j => + tau < ‖(localLaw a).complexMean (fun x => + weight a x * (U j (physical a x)).observable (path a x))‖)).toList + obtain ⟨code, retained, hretained, hmass, hcode⟩ := + exists_common_frequency_kernel outer productive P eta js + let K := frequencyCodeKernel P eta code + have hK : K ≤ D.filtration.layer s := (finiteFrequencyKernel_le P _ _).trans hP + let S := fun x => (T x).kernelProjection K hK + refine ⟨code, S, retained, fun _ => rfl, ?_, ?_, hretained, hmass, ?_⟩ + · intro x + exact ⟨(T x).kernelProjection_unitInterval K hK (hT x), + (T x).kernelProjection_complexity K hK (hTc x), (T x).kernelProjection_orbit K hK⟩ + · intro a z hz x + exact (T a).kernelProjection_invariant K hK z hz x + · intro a ha + obtain ⟨hpivots, hk⟩ := hcode a ha + have hsignificant (j : J) + (hj : tau < ‖(localLaw a).complexMean (fun x => + weight a x * (U j (physical a x)).observable (path a x))‖) : j ∈ js a := by + simpa only [js, Finset.mem_toList, Finset.mem_filter, Finset.mem_univ, true_and] using hj + have herr := external_family_kernelProjection_tested_error T P hP eta U hvertical + (localLaw a) (physical a) (path a) (weight a) hB htau (hweight a) happrox + (js a) hsignificant + have hproj (x : X) : (T x).kernelProjection (finiteFrequencyKernel P eta (js a)) + ((finiteFrequencyKernel_le P eta (js a)).trans hP) = S x := + (T x).kernelProjection_congr _ hK hk + simp_rw [hproj] at herr + refine ⟨?_, ?_⟩ + · intro i j hij + simpa only [js, Finset.mem_toList, Finset.mem_filter, Finset.mem_univ, true_and] + using hpivots i j hij + · have hr := Complex.re_le_norm + ((localLaw a).complexMean (fun x => weight a x * (T (physical a x)).observable (path a x)) - + (localLaw a).complexMean (fun x => weight a x * (S (physical a x)).observable (path a x))) + rw [Complex.sub_re] at hr + have hs := hscore a (hretained ha) + linarith + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_external_family_contractive_quantitative_kernel_projection_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ X Ω G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : X → D.Niltest w) (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (∀ x, (T x).UnitIntervalValued) → (∀ x, (T x).ComplexityLE p) → + ∀ (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s), + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (physical : Ω → G → X) + (path : Ω → G → D.Space) (weight : Ω → G → ℂ), + (∀ a x, ‖weight a x‖ ≤ Real.exp p) → + (∀ a ∈ productive, Real.exp (-p) ≤ ((localLaw a).complexMean + (fun x => weight a x * (T (physical a x)).observable (path a x))).re) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → X → D.Niltest w) + (code : Fin (finrank ℚ P) → Option J) (S : X → D.Niltest w) (retained : Finset Ω), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j x, (U j x).ComplexityLE ((p + 2) ^ C) ∧ + (U j x).orbit = (T x).orbit ∧ (U j x).normBound = (T x).normBound ∧ + (U j x).lipBound = (T x).lipBound) ∧ + (∀ j a (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j a).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j a).observable x) ∧ + (∀ j a b (ε : ℝ), + (∀ x, ‖(T a).observable x - (T b).observable x‖ ≤ ε) → + ∀ x, ‖(U j a).observable x - (U j b).observable x‖ ≤ ε) ∧ + (∀ x, (S x).UnitIntervalValued ∧ (S x).ComplexityLE ((p + 2) ^ C) ∧ + (S x).orbit = (T x).orbit) ∧ + (∀ x, S x = (T x).kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP)) ∧ + (∀ a (z : D.RealGroup), z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, (S a).observable (z • x) = (S a).observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun x => + weight a x * (U j (physical a x)).observable (path a x))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ ((localLaw a).complexMean + (fun x => weight a x * (S (physical a x)).observable (path a x))).re := by + let R : Polynomial ℕ := Polynomial.X + let Q := 2 * R + 8 + let A := (Q + 3) ^ 9 + 2 * Q + 2 + let V := 2 * A * (2 * A + 2) ^ 4 + ((2 * A + 2) ^ 4 + A + (Q + 3) ^ 5 + 2) ^ 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + (Q + 2 * V + R + 10 + R * (V + 1)) + refine ⟨C, hC, ?_⟩ + intro L σ X Ω G _ _ s d _ _ _ _ _ _ D w T p hp hD hT hTc P hP + outer productive localLaw physical path weight hweight hscore + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let q := 2 * p + 8 + let v := verticalDecompositionBudget q + have hq : 0 ≤ q := by dsimp [q]; linarith + have hpq : p ≤ q := by dsimp [q]; linarith + have hv : 0 ≤ v := verticalDecompositionBudget_nonneg hq + have hprod : 0 ≤ p * (v + 1) := by positivity + have hb : q + 2 * v + p + 10 + p * (v + 1) ≤ (p + 2) ^ C := by + simpa [R, Q, A, V, q, v, verticalDecompositionBudget, centralActionBudget, + Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + 2) ^ C := by linarith + have hvC : v ≤ (p + 2) ^ C := by linarith + have htC : p + v + 8 ≤ (p + 2) ^ C := by linarith + have hnC : p * (v + 1) ≤ (p + 2) ^ C := by linarith + have hsC : p + 1 ≤ (p + 2) ^ C := by linarith + obtain ⟨J, inst, eta, U, hJ, hheight, hU, hvert, hint, hchar, hcontract, happrox, hintError, hrealError⟩ := + D.exists_externalFamily_contractive_vertical_expansion hq (hD.mono D hpq) T + (fun x => (hTc x).mono hpq) (Real.exp (-q)) (Real.exp_pos (-q)) + (by rw [Real.exp_neg, inv_inv]) + let _ := inst + have hsmall := frequency_projection_error_bound hp hJ + obtain ⟨code, S, retained, hidentity, hS, hSinv, hretained, hmass, hlocal⟩ := + RationalFilteredNilmanifold.Niltest.exists_external_family_common_positive_kernel_projection + T hT hTc P hP eta U hvert outer productive localLaw physical path weight + (Real.exp_nonneg p) (Real.exp_nonneg (-(p + v + 8))) hweight happrox hscore hsmall + have hdim : (finrank ℚ P : ℝ) ≤ p := by + have h := Submodule.finrank_le P + rw [finrank_eq_card_basis D.basis, Fintype.card_fin] at h + exact (Nat.cast_le.mpr h).trans hD.1 + refine ⟨J, inst, eta, U, code, S, retained, + hJ.trans (Real.exp_le_exp.mpr hvC), fun j i => (hheight j i).trans hvC, + fun j x => ⟨(hU j x).1.mono hqC, (hU j x).2⟩, hvert, hcontract, + fun x => ⟨(hS x).1, (hS x).2.1.mono (hpq.trans hqC), (hS x).2.2⟩, + hidentity, hSinv, hretained, ?_, ?_⟩ + · exact (mass_div_frequency_count (outer.mass_nonneg productive) hp hv hdim hJ hnC).trans hmass + · intro a ha + obtain ⟨hpivot, hpositive⟩ := hlocal a ha + refine ⟨fun i j hij => (Real.exp_le_exp.mpr (neg_le_neg htC)).trans_lt (hpivot i j hij), ?_⟩ + exact ((Real.exp_le_exp.mpr (by linarith : -((p + 2) ^ C) ≤ -p - 1)).trans + (exp_sub_one_le_half_exp (-p))).trans hpositive + +end Erdos3 + +end + +section + +namespace Erdos3 +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_external_family_precenter_kernel_projection_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ X : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : X → D.Niltest w) (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (∀ x, (T x).UnitIntervalValued) → (∀ x, (T x).ComplexityLE p) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → X → D.Niltest w), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j x, (U j x).ComplexityLE ((p + 2) ^ C) ∧ + (U j x).orbit = (T x).orbit ∧ (U j x).normBound = (T x).normBound ∧ + (U j x).lipBound = (T x).lipBound) ∧ + (∀ j a (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j a).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j a).observable x) ∧ + (∀ j a b (ε : ℝ), + (∀ x, ‖(T a).observable x - (T b).observable x‖ ≤ ε) → + ∀ x, ‖(U j a).observable x - (U j b).observable x‖ ≤ ε) ∧ + ∀ {Ω G : Type*} [Fintype Ω] [Fintype G], + ∀ (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s), + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (physical : Ω → G → X) + (path : Ω → G → D.Space) (weight : Ω → G → ℂ), + (∀ a x, ‖weight a x‖ ≤ Real.exp p) → + (∀ a ∈ productive, Real.exp (-p) ≤ ((localLaw a).complexMean + (fun x => weight a x * (T (physical a x)).observable (path a x))).re) → + ∃ (code : Fin (finrank ℚ P) → Option J) (S : X → D.Niltest w) + (retained : Finset Ω), + (∀ x, (S x).UnitIntervalValued ∧ (S x).ComplexityLE ((p + 2) ^ C) ∧ + (S x).orbit = (T x).orbit) ∧ + (∀ x, S x = (T x).kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP)) ∧ + (∀ a (z : D.RealGroup), z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, (S a).observable (z • x) = (S a).observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun x => + weight a x * (U j (physical a x)).observable (path a x))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ ((localLaw a).complexMean + (fun x => weight a x * (S (physical a x)).observable (path a x))).re := by + let R : Polynomial ℕ := Polynomial.X + let Q := 2 * R + 8 + let A := (Q + 3) ^ 9 + 2 * Q + 2 + let V := 2 * A * (2 * A + 2) ^ 4 + ((2 * A + 2) ^ 4 + A + (Q + 3) ^ 5 + 2) ^ 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + (Q + 2 * V + R + 10 + R * (V + 1)) + refine ⟨C, hC, ?_⟩ + intro L σ X _ _ s d _ _ _ _ D w T p hp hD hT hTc + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let q := 2 * p + 8 + let v := verticalDecompositionBudget q + have hq : 0 ≤ q := by dsimp [q]; linarith + have hpq : p ≤ q := by dsimp [q]; linarith + have hv : 0 ≤ v := verticalDecompositionBudget_nonneg hq + have hprod : 0 ≤ p * (v + 1) := by positivity + have hb : q + 2 * v + p + 10 + p * (v + 1) ≤ (p + 2) ^ C := by + simpa [R, Q, A, V, q, v, verticalDecompositionBudget, centralActionBudget, + Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + 2) ^ C := by linarith + have hvC : v ≤ (p + 2) ^ C := by linarith + have htC : p + v + 8 ≤ (p + 2) ^ C := by linarith + have hnC : p * (v + 1) ≤ (p + 2) ^ C := by linarith + have hsC : p + 1 ≤ (p + 2) ^ C := by linarith + obtain ⟨J, inst, eta, U, hJ, hheight, hU, hvert, hint, hchar, hcontract, happrox, hintError, hrealError⟩ := + D.exists_externalFamily_contractive_vertical_expansion hq (hD.mono D hpq) T + (fun x => (hTc x).mono hpq) (Real.exp (-q)) (Real.exp_pos (-q)) + (by rw [Real.exp_neg, inv_inv]) + let _ := inst + refine ⟨J, inst, eta, U, + hJ.trans (Real.exp_le_exp.mpr hvC), fun j i => (hheight j i).trans hvC, + fun j x => ⟨(hU j x).1.mono hqC, (hU j x).2⟩, hvert, hcontract, ?_⟩ + intro Ω G _ _ P hP outer productive localLaw physical path weight hweight hscore + have hsmall := frequency_projection_error_bound hp hJ + obtain ⟨code, S, retained, hidentity, hS, hSinv, hretained, hmass, hlocal⟩ := + RationalFilteredNilmanifold.Niltest.exists_external_family_common_positive_kernel_projection + T hT hTc P hP eta U hvert outer productive localLaw physical path weight + (Real.exp_nonneg p) (Real.exp_nonneg (-(p + v + 8))) hweight happrox hscore hsmall + have hdim : (finrank ℚ P : ℝ) ≤ p := by + have h := Submodule.finrank_le P + rw [finrank_eq_card_basis D.basis, Fintype.card_fin] at h + exact (Nat.cast_le.mpr h).trans hD.1 + refine ⟨code, S, retained, + fun x => ⟨(hS x).1, (hS x).2.1.mono (hpq.trans hqC), (hS x).2.2⟩, + hidentity, hSinv, hretained, ?_, ?_⟩ + · exact (mass_div_frequency_count (outer.mass_nonneg productive) hp hv hdim hJ hnC).trans hmass + · intro a ha + obtain ⟨hpivot, hpositive⟩ := hlocal a ha + refine ⟨fun i j hij => (Real.exp_le_exp.mpr (neg_le_neg htC)).trans_lt (hpivot i j hij), ?_⟩ + exact ((Real.exp_le_exp.mpr (by linarith : -((p + 2) ^ C) ≤ -p - 1)).trans + (exp_sub_one_le_half_exp (-p))).trans hpositive + +end Erdos3 + +end + +section + +namespace Erdos3 +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +structure ExternalFamilyPrecenterProjectionData + {L σ X : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : X → D.Niltest w) (p q : ℝ) where + Freq : Type + instFintype : Fintype Freq + eta : Freq → L →ₗ[ℚ] ℚ + U : Freq → X → D.Niltest w + card_bound : (@Fintype.card Freq instFintype : ℝ) ≤ Real.exp q + eta_height : ∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ q + U_bounds : ∀ j x, (U j x).ComplexityLE q ∧ + (U j x).orbit = (T x).orbit ∧ (U j x).normBound = (T x).normBound ∧ + (U j x).lipBound = (T x).lipBound + vertical : ∀ j a (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j a).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j a).observable x + contractive : ∀ j a b (ε : ℝ), + (∀ x, ‖(T a).observable x - (T b).observable x‖ ≤ ε) → + ∀ x, ‖(U j a).observable x - (U j b).observable x‖ ≤ ε + select : ∀ {Ω G : Type} [Fintype Ω] [Fintype G], + ∀ (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s), + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (physical : Ω → G → X) + (path : Ω → G → D.Space) (weight : Ω → G → ℂ), + (∀ a x, ‖weight a x‖ ≤ Real.exp p) → + (∀ a ∈ productive, Real.exp (-p) ≤ ((localLaw a).complexMean + (fun x => weight a x * (T (physical a x)).observable (path a x))).re) → + ∃ (code : Fin (finrank ℚ P) → Option Freq) (S : X → D.Niltest w) + (retained : Finset Ω), + (∀ x, (S x).UnitIntervalValued ∧ (S x).ComplexityLE q ∧ + (S x).orbit = (T x).orbit) ∧ + (∀ x, S x = (T x).kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP)) ∧ + (∀ a (z : D.RealGroup), z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, (S a).observable (z • x) = (S a).observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-q) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-q) < + ‖(localLaw a).complexMean (fun x => + weight a x * (U j (physical a x)).observable (path a x))‖) ∧ + Real.exp (-q) ≤ ((localLaw a).complexMean + (fun x => weight a x * (S (physical a x)).observable (path a x))).re + +attribute [instance] ExternalFamilyPrecenterProjectionData.instFintype + +theorem exists_externalFamilyPrecenterProjectionData : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ X : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : X → D.Niltest w) (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + (∀ x, (T x).UnitIntervalValued) → (∀ x, (T x).ComplexityLE p) → + Nonempty (ExternalFamilyPrecenterProjectionData T p ((p + 2) ^ C)) := by + obtain ⟨C, hC, hproduce⟩ := exists_external_family_precenter_kernel_projection_budget + refine ⟨C, hC, ?_⟩ + intro L σ X _ _ s d _ _ _ _ D w T p hp hD hT hTc + obtain ⟨J, inst, eta, U, hJ, hheight, hU, hvert, hcontract, hselect⟩ := + hproduce T p hp hD hT hTc + exact ⟨{ + Freq := J + instFintype := inst + eta := eta + U := U + card_bound := hJ + eta_height := hheight + U_bounds := hU + vertical := hvert + contractive := hcontract + select := hselect }⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ExternalKernelPrecenterNativePointPartners.lean b/lean/OAI/Combinatorics/Progressions/Linear/ExternalKernelPrecenterNativePointPartners.lean new file mode 100644 index 0000000000000000000000000000000000000000..f54844da2fd645421ee275c7d9b6001e6e558999 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ExternalKernelPrecenterNativePointPartners.lean @@ -0,0 +1,214 @@ +import OAI.Combinatorics.Progressions.Sampling.PrecenterForecastNativeAtomDictionary + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators TensorProduct Classical + +noncomputable def externalNetMaskFamily + {Freq X Y I : Type*} (F : Freq → X → Y → ℂ) + (centers : Freq → I → Y → ℂ) {ε : ℝ} + (hnet : ∀ f x, ∃ i, ∀ y, ‖F f x y - centers f i y‖ ≤ ε) + (input : X → ℂ) : (Freq × I) → X → ℂ := + fun b x => if externalNetIndex (F b.1) (centers b.1) (hnet b.1) x = b.2 + then input x else 0 + +theorem exists_external_kernel_precenter_native_partners + {L σ τ X Ω T I Freq NativeCoord Θ : Type*} + [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype T] [Fintype I] [Nonempty I] + {s d r : ℕ} (D : RationalFilteredNilmanifold L s d) + {w : σ → ℕ} {v : τ → ℕ} + (U : Freq → X → D.Niltest w) (representative : I → X) + {p B ε δ M termBound : ℝ} + (hcomplex : ∀ f x, (U f x).ComplexityLE p) + (hnet : ∀ f x, ∃ i, ∀ y, ‖(U f x).observable y - + (U f (representative i)).observable y‖ ≤ ε) + (input : X → ℂ) (models : (Freq × I) → CenteredForecastModel X) + (nativeWeight : NativeCoord → ℕ) (degree : ℕ) (budget : ℝ) + (sample : X → NativeCoord → ℤ) (twist : Θ → X → ℂ) + (hnative : ∀ b i, (models b).models i ∈ + twistedNativeSampleFunctions nativeWeight degree budget sample twist) + (hmodel : ∀ b, externalNetMaskFamily (fun f x => (U f x).observable) + (fun f i => (U f (representative i)).observable) hnet input b = + (∑ i, (models b).coefficient i • (models b).models i) + (models b).residual) + (hc : ∀ b, (∑ i, |(models b).coefficient i|) ≤ M) + (hterms : ∀ b, ((models b).nterms : ℝ) ≤ termBound) + (hM : 0 < M) (hterm : 1 ≤ termBound) + (code : Fin r → Option Freq) + (outer : FiniteProbabilityWeights Ω) (H : Finset Ω) (hH : 0 < outer.mass H) + (localLaw : Ω → FiniteProbabilityWeights T) + (localOrbit : Ω → D.filtration.realification.PolynomialOrbit v) + (physical : Ω → T → X) (point : Ω → T → τ → ℤ) + (hB : 0 ≤ B) (hδ : 0 < δ) (herror : B * ε ≤ δ / 2) + (hinput : ∀ x, ‖input x‖ ≤ B) + (hresidual : ∀ a ∈ H, ∀ f i, + ‖(localLaw a).complexMean (fun t => (models (f, i)).residual (physical a t) * + ((U f (representative i)).withOrbit (localOrbit a)).eval (point a t))‖ ≤ + (δ / (2 * Fintype.card I)) / 2) + (hscore : ∀ a ∈ H, ∀ i f, code i = some f → δ ≤ + ‖(localLaw a).complexMean (fun t => input (physical a t) * + ((U f (physical a t)).withOrbit (localOrbit a)).eval (point a t))‖) : + ∃ (chosen : KernelProjectionPresentPivot code → I) + (fixedTwist : KernelProjectionPresentPivot code → Θ) + (nativeValue : KernelProjectionPresentPivot code → X → ℂ) + (_native : ∀ k, NativeSampleModel nativeWeight degree budget sample (nativeValue k)) + (retained : Finset Ω), + retained ⊆ H ∧ 0 < outer.mass retained ∧ + outer.mass H / ((Fintype.card I : ℝ) ^ r * termBound ^ r) ≤ outer.mass retained ∧ + (∀ a k, ((U (kernelProjectionSelectedPivot code k) (representative (chosen k))).withOrbit + (localOrbit a)).ComplexityLE p) ∧ + ∀ a ∈ retained, ∀ k, (δ / (2 * Fintype.card I)) / (2 * M) ≤ + ‖(localLaw a).complexMean (fun t => + (star (twist (fixedTwist k) (physical a t)) * nativeValue k (physical a t)) * + ((U (kernelProjectionSelectedPivot code k) (representative (chosen k))).withOrbit + (localOrbit a)).eval (point a t))‖ := by + obtain ⟨chosen, masked, H', hmask, _, hsub, hpos, hmass, hlocalComplex, hlocal⟩ := + exists_external_kernel_pivot_masks D code U representative hcomplex hnet + outer H hH localLaw localOrbit physical point input hB hδ herror hinput hscore + let selectedBranch := fun k : KernelProjectionPresentPivot code => + (kernelProjectionSelectedPivot code k, chosen k) + let family := externalNetMaskFamily (fun f x => (U f x).observable) + (fun f i => (U f (representative i)).observable) hnet input + have hfamily (k : KernelProjectionPresentPivot code) : + family (selectedBranch k) = masked k := by + funext x + exact (hmask k x).symm + obtain ⟨fixedTwist, nativeValue, native, retained, hretSub, hretPos, hretMass, hretScore⟩ := + exists_precenter_forecast_finiteLaw_native_partners family models + nativeWeight degree budget sample twist hnative hmodel hM hterm + (div_pos hδ (by positivity)) hc hterms selectedBranch + (kernelProjectionPresentPivot_card_le code) outer H' hpos + (fun a _ => localLaw a) physical + (fun a k t => ((U (kernelProjectionSelectedPivot code k) + (representative (chosen k))).withOrbit (localOrbit a)).eval (point a t)) + (fun a ha k => hresidual a (hsub ha) _ _) + (by intro a ha k; rw [hfamily]; exact hlocal a ha k) + refine ⟨chosen, fixedTwist, nativeValue, native, retained, + fun a ha => hsub (hretSub ha), hretPos, ?_, hlocalComplex, hretScore⟩ + calc + outer.mass H / ((Fintype.card I : ℝ) ^ r * termBound ^ r) + = (outer.mass H / (Fintype.card I : ℝ) ^ r) / termBound ^ r := by + rw [div_div] + _ ≤ outer.mass H' / termBound ^ r := + div_le_div_of_nonneg_right hmass (pow_nonneg (by linarith) _) + _ ≤ outer.mass retained := hretMass + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators TensorProduct Classical + +theorem exists_external_kernel_precenter_native_point_partners + {L σ X Ω T I Freq NativeCoord Θ : Type*} + [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype T] [Fintype I] [Nonempty I] + {s d r : ℕ} (D : RationalFilteredNilmanifold L s d) + {w : σ → ℕ} + (U : Freq → X → D.Niltest w) (representative : I → X) + {p B ε δ M termBound : ℝ} + (hcomplex : ∀ f x, (U f x).ComplexityLE p) + (hnet : ∀ f x, ∃ i, ∀ y, ‖(U f x).observable y - + (U f (representative i)).observable y‖ ≤ ε) + (input : X → ℂ) (models : (Freq × I) → CenteredForecastModel X) + (nativeWeight : NativeCoord → ℕ) (degree : ℕ) (budget : ℝ) + (sample : X → NativeCoord → ℤ) (twist : Θ → X → ℂ) + (hnative : ∀ b i, (models b).models i ∈ + twistedNativeSampleFunctions nativeWeight degree budget sample twist) + (hmodel : ∀ b, externalNetMaskFamily (fun f x => (U f x).observable) + (fun f i => (U f (representative i)).observable) hnet input b = + (∑ i, (models b).coefficient i • (models b).models i) + (models b).residual) + (hc : ∀ b, (∑ i, |(models b).coefficient i|) ≤ M) + (hterms : ∀ b, ((models b).nterms : ℝ) ≤ termBound) + (hM : 0 < M) (hterm : 1 ≤ termBound) + (code : Fin r → Option Freq) + (outer : FiniteProbabilityWeights Ω) (H : Finset Ω) (hH : 0 < outer.mass H) + (localLaw : Ω → FiniteProbabilityWeights T) + (localPoint : Ω → T → D.Space) (physical : Ω → T → X) + (hB : 0 ≤ B) (hδ : 0 < δ) (herror : B * ε ≤ δ / 2) + (hinput : ∀ x, ‖input x‖ ≤ B) + (hresidual : ∀ a ∈ H, ∀ f i, + ‖(localLaw a).complexMean (fun t => (models (f, i)).residual (physical a t) * + (U f (representative i)).observable (localPoint a t))‖ ≤ + (δ / (2 * Fintype.card I)) / 2) + (hscore : ∀ a ∈ H, ∀ i f, code i = some f → δ ≤ + ‖(localLaw a).complexMean (fun t => input (physical a t) * + (U f (physical a t)).observable (localPoint a t))‖) : + ∃ (chosen : KernelProjectionPresentPivot code → I) + (fixedTwist : KernelProjectionPresentPivot code → Θ) + (nativeValue : KernelProjectionPresentPivot code → X → ℂ) + (_native : ∀ k, NativeSampleModel nativeWeight degree budget sample (nativeValue k)) + (retained : Finset Ω), + retained ⊆ H ∧ 0 < outer.mass retained ∧ + outer.mass H / ((Fintype.card I : ℝ) ^ r * termBound ^ r) ≤ outer.mass retained ∧ + (∀ k, (U (kernelProjectionSelectedPivot code k) + (representative (chosen k))).ComplexityLE p) ∧ + ∀ a ∈ retained, ∀ k, (δ / (2 * Fintype.card I)) / (2 * M) ≤ + ‖(localLaw a).complexMean (fun t => + (star (twist (fixedTwist k) (physical a t)) * nativeValue k (physical a t)) * + (U (kernelProjectionSelectedPivot code k) + (representative (chosen k))).observable (localPoint a t))‖ := by + let K := KernelProjectionPresentPivot code + let functions := fun (k : K) x => (U (kernelProjectionSelectedPivot code k) x).observable + let centers := fun (k : K) i => + (U (kernelProjectionSelectedPivot code k) (representative i)).observable + have hselected (a : Ω) (ha : a ∈ H) (k : K) : δ ≤ + ‖(localLaw a).complexMean (fun t => input (physical a t) * + functions k (physical a t) (localPoint a t))‖ := + hscore a ha k.val (kernelProjectionSelectedPivot code k) + (kernelProjectionSelectedPivot_spec code k) + obtain ⟨chosen, masked, H', hmask, _, hsub, hpos, hmass, hlocal⟩ := + exists_simultaneous_external_pivot_masks functions centers + (fun k => hnet (kernelProjectionSelectedPivot code k)) outer H hH + (fun a _ => localLaw a) physical (fun a _ t => localPoint a t) + input hB hδ herror hinput hselected + have hmassRank : outer.mass H / (Fintype.card I : ℝ) ^ r ≤ outer.mass H' := by + apply le_trans _ hmass + apply div_le_div_of_nonneg_left (outer.mass_nonneg H) + (pow_pos (Nat.cast_pos.mpr Fintype.card_pos) _) + exact pow_le_pow_right₀ + (by exact_mod_cast Fintype.card_pos : (1 : ℝ) ≤ Fintype.card I) + (kernelProjectionPresentPivot_card_le code) + let selectedBranch := fun k : KernelProjectionPresentPivot code => + (kernelProjectionSelectedPivot code k, chosen k) + let family := externalNetMaskFamily (fun f x => (U f x).observable) + (fun f i => (U f (representative i)).observable) hnet input + have hfamily (k : KernelProjectionPresentPivot code) : + family (selectedBranch k) = masked k := by + funext x + exact (hmask k x).symm + obtain ⟨fixedTwist, nativeValue, native, retained, hretSub, hretPos, hretMass, hretScore⟩ := + exists_precenter_forecast_finiteLaw_native_partners family models + nativeWeight degree budget sample twist hnative hmodel hM hterm + (div_pos hδ (by positivity)) hc hterms selectedBranch + (kernelProjectionPresentPivot_card_le code) outer H' hpos + (fun a _ => localLaw a) physical + (fun a k t => (U (kernelProjectionSelectedPivot code k) + (representative (chosen k))).observable (localPoint a t)) + (fun a ha k => hresidual a (hsub ha) _ _) + (by intro a ha k; rw [hfamily]; exact hlocal a ha k) + refine ⟨chosen, fixedTwist, nativeValue, native, retained, + fun a ha => hsub (hretSub ha), hretPos, ?_, fun k => hcomplex _ _, hretScore⟩ + calc + outer.mass H / ((Fintype.card I : ℝ) ^ r * termBound ^ r) + = (outer.mass H / (Fintype.card I : ℝ) ^ r) / termBound ^ r := by + rw [div_div] + _ ≤ outer.mass H' / termBound ^ r := + div_le_div_of_nonneg_right hmassRank (pow_nonneg (by linarith) _) + _ ≤ outer.mass retained := hretMass + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FastCoefficientRelativeKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/FastCoefficientRelativeKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..d87ce1c849457d78a6b7f005eb368500fe945d33 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FastCoefficientRelativeKernel.lean @@ -0,0 +1,29 @@ +import OAI.Combinatorics.Progressions.Estimates.ReducedNativeFactorization + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (w : σ → ℕ) (hw : ∀ i, 0 < w i) + (U : LieSubalgebra ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + +theorem firstCoefficientFastSubmodule_relative : + F.firstCoefficientFastSubmodule w hw (F.reducedSquareFastRelativeSubmodule w U) = + F.firstCoefficientFastSubmodule w hw U.toSubmodule := by + rw [F.firstCoefficientFastSubmodule_eq_image, F.firstCoefficientFastSubmodule_eq_image] + simp only [reducedSquareFastRelativeSubmodule, inf_assoc, inf_idem] + +theorem realFirstCoefficientFastSubmodule_relative : + F.realFirstCoefficientFastSubmodule w hw (F.reducedSquareFastRelativeSubmodule w U) = + F.realFirstCoefficientFastSubmodule w hw U.toSubmodule := by + unfold realFirstCoefficientFastSubmodule + rw [F.firstCoefficientFastSubmodule_relative] + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FastCoefficientSpanning.lean b/lean/OAI/Combinatorics/Progressions/Linear/FastCoefficientSpanning.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dc2f1d21f5f5ea4234bdabb8fdfab05e37a791f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FastCoefficientSpanning.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.Progressions.Estimates.FastCoefficientBlocks + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) (w : σ → ℕ) + +theorem reducedSquareCoefficientMap_height [Fintype (ReducedSquareSymbolIndex s w ω)] + {H : ℕ} (x : F.squareFiltration.quotientTop.PolynomialSymbol w) + (hx : ∀ i, RationalHeightLE ((F.reducedSquareSymbolBasis e ω hF w).repr x i) H) + (j : FirstCoefficientIndex w ω) : + RationalHeightLE ((F.firstCoefficientBasis e ω hF w).repr (F.reducedSquareCoefficientMap w x) j) + ((Fintype.card (ReducedSquareSymbolIndex s w ω) + 1) * + H ^ Fintype.card (ReducedSquareSymbolIndex s w ω)) := by + simpa only [mul_one] using linearMap_coordinate_height + (F.reducedSquareSymbolBasis e ω hF w) (F.firstCoefficientBasis e ω hF w) + (F.reducedSquareCoefficientMap w) (F.reducedSquareCoefficientMap_basis_height e ω hF w) x hx j + +theorem firstCoefficientFastSubmodule_spanning (hw : ∀ i, 0 < w i) + (U : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + (v : κ → F.squareFiltration.quotientTop.PolynomialSymbol w) + (hv : Submodule.span ℚ (Set.range v) = U ⊓ (F.reducedSquareSndSymbolMap w).ker.toSubmodule) : + Submodule.span ℚ (Set.range (fun i => F.reducedSquareCoefficientMap w (v i))) = + F.firstCoefficientFastSubmodule w hw U := by + rw [F.firstCoefficientFastSubmodule_eq_image, ← hv, Submodule.map_span, ← Set.range_comp] + rfl + +theorem firstCoefficientFastSubmodule_spanning_height [Fintype (ReducedSquareSymbolIndex s w ω)] + (hw : ∀ i, 0 < w i) (U : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + (v : κ → F.squareFiltration.quotientTop.PolynomialSymbol w) + (hspan : Submodule.span ℚ (Set.range v) = U ⊓ (F.reducedSquareSndSymbolMap w).ker.toSubmodule) + {H : ℕ} (hv : ∀ i j, RationalHeightLE ((F.reducedSquareSymbolBasis e ω hF w).repr (v i) j) H) : + ∃ z : κ → F.FirstCoefficientModule w, + Submodule.span ℚ (Set.range z) = F.firstCoefficientFastSubmodule w hw U ∧ + ∀ i j, RationalHeightLE ((F.firstCoefficientBasis e ω hF w).repr (z i) j) + ((Fintype.card (ReducedSquareSymbolIndex s w ω) + 1) * + H ^ Fintype.card (ReducedSquareSymbolIndex s w ω)) := + ⟨fun i => F.reducedSquareCoefficientMap w (v i), + F.firstCoefficientFastSubmodule_spanning w hw U v hspan, + fun i j => F.reducedSquareCoefficientMap_height e ω hF w (v i) (hv i) j⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FastKernelReabsorption.lean b/lean/OAI/Combinatorics/Progressions/Linear/FastKernelReabsorption.lean new file mode 100644 index 0000000000000000000000000000000000000000..13d8c5ad9d1a9e08f589bdcc3fc86c48dcb3027e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FastKernelReabsorption.lean @@ -0,0 +1,189 @@ +import OAI.Combinatorics.Progressions.Estimates.FastHorizontalFactorization + +namespace OAI + +section + +namespace Erdos3 + +variable {σ G E H R : Type*} [Group G] [Field R] + [AddCommGroup E] [Module R E] [AddCommGroup H] [Module R H] + +theorem cocycle_kernel_reabsorption + (ρ : G →* (E ≃ₗ[R] E)) (Y : G → σ → E) + (hY : ∀ g h i, Y (g * h) i = Y g i + ρ g (Y h i)) + (P : E →ₗ[R] H) (hρ : ∀ g x, P (ρ g x) = P x) + (U K : Submodule R H) (B a c : G) (S T : K →ₗ[R] E) + (hST : S = (ρ B).toLinearMap.comp T) + (hS : P.comp S = K.subtype) (hT : P.comp T = K.subtype) + (small rational : σ → E) (k A C : σ → K) + (hsystem : ∀ i, Y B i = small i + ρ B (rational i) + S (k i)) + (hsmall : ∀ i, P (small i) = 0) (hrational : ∀ i, P (rational i) = 0) + (ha : ∀ i, P (Y a i) = (A i).val) (hc : ∀ i, P (Y c i) = (C i).val) + (hkU : ∀ i, (k i).val ∈ U) (hAU : ∀ i, (A i).val ∈ U) (hCU : ∀ i, (C i).val ∈ U) : + let B' := a⁻¹ * B * c⁻¹ + let S' := (ρ a).symm.toLinearMap.comp S + let T' := (ρ c).toLinearMap.comp T + let small' := fun i => (ρ a).symm (small i - Y a i) + S' (A i) + let rational' := fun i => ρ c (rational i) - Y c i + T' (C i) + let k' := fun i => k i - A i - C i + a * B' * c = B ∧ S' = (ρ B').toLinearMap.comp T' ∧ + P.comp S' = K.subtype ∧ P.comp T' = K.subtype ∧ + ∀ i, Y B' i = small' i + ρ B' (rational' i) + S' (k' i) ∧ + P (small' i) = 0 ∧ P (rational' i) = 0 ∧ P (Y B' i) = (k' i).val ∧ + P (Y B' i) ∈ U ⊓ K := by + intro B' S' T' small' rational' k' + have hprod : a * B' * c = B := by dsimp [B']; group + have haction (x : E) : ρ B x = ρ a (ρ B' (ρ c x)) := by + rw [← hprod] + exact linear_action_triple ρ a B' c x + have hfac : S' = (ρ B').toLinearMap.comp T' := + linear_lift_remove (ρ a) (ρ c) (ρ B) (ρ B') haction S T hST + have hhor := horizontal_lift_remove P (ρ a) (ρ c) (hρ a) (hρ c) S T K.subtype hS hT + refine ⟨hprod, hfac, hhor.1, hhor.2, fun i => ?_⟩ + let rawSmall := (ρ a).symm (small i - Y a i) + let rawRational := ρ c (rational i) - Y c i + have htriple := linear_cocycle_triple ρ (fun g => Y g i) + (fun g h => hY g h i) a B' c + rw [hprod] at htriple + have hraw : Y B' i = rawSmall + ρ B' rawRational + S' (k i) := + linear_derivative_remove (ρ a) (ρ c) (ρ B) (ρ B') haction + (Y B i) (Y a i) (Y B' i) (Y c i) (small i) (rational i) (S (k i)) + htriple (hsystem i) + have hnew : Y B' i = small' i + ρ B' (rational' i) + S' (k' i) := by + have h := linear_derivative_absorb (ρ B').toLinearMap S' T' hfac + (Y B' i) rawSmall rawRational (k i) (-A i) (-C i) hraw + simp only [map_neg, sub_neg_eq_add, ← sub_eq_add_neg] at h + exact h + have hrawSmall : P rawSmall = -(A i).val := by + have h := hρ a rawSmall + change P (ρ a ((ρ a).symm (small i - Y a i))) = P rawSmall at h + rw [LinearEquiv.apply_symm_apply, map_sub, hsmall, ha, zero_sub] at h + exact h.symm + have hrawRational : P rawRational = -(C i).val := by + change P (ρ c (rational i) - Y c i) = _ + rw [map_sub, hρ, hrational, hc, zero_sub] + have hs0 : P (small' i) = 0 := by + change P (rawSmall + S' (A i)) = 0 + rw [map_add, hrawSmall, show P (S' (A i)) = (A i).val from DFunLike.congr_fun hhor.1 (A i)] + exact neg_add_cancel _ + have hr0 : P (rational' i) = 0 := by + change P (rawRational + T' (C i)) = 0 + rw [map_add, hrawRational, show P (T' (C i)) = (C i).val from DFunLike.congr_fun hhor.2 (C i)] + exact neg_add_cancel _ + have hPB : P.comp (ρ B').toLinearMap = P := by + apply LinearMap.ext + intro x + exact hρ B' x + have hk : (k' i).val ∈ U := U.sub_mem (U.sub_mem (hkU i) (hAU i)) (hCU i) + have hfinal := horizontal_derivative_of_zero_parts U K P (ρ B').toLinearMap hPB S' + hhor.1 (Y B' i) (small' i) (rational' i) (k' i) hnew hs0 hr0 hk + exact ⟨hnew, hs0, hr0, hfinal.1, hfinal.2⟩ + +theorem linear_absorption_preserves_projection {K Z : Type*} + [AddCommGroup K] [Module R K] [AddCommGroup Z] [Module R Z] + (Q : E →ₗ[R] Z) (S T : K →ₗ[R] E) + (hS : Q.comp S = 0) (hT : Q.comp T = 0) (small rational : E) (ks kr : K) : + Q (small + S ks) = Q small ∧ Q (rational + T kr) = Q rational := by + have hs : Q (S ks) = 0 := DFunLike.congr_fun hS ks + have ht : Q (T kr) = 0 := DFunLike.congr_fun hT kr + simp only [map_add, hs, ht, add_zero, and_self] + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (U : LieSubalgebra ℚ F.AssociatedGraded) + (W : LieSubalgebra ℚ (F.squareFiltration.quotientTop.PolynomialSymbol (fun _ : σ => 1))) + (hU : (F.symbolPointwiseSubalgebra e ω hF (fun _ : σ => 1) U).map + (F.quotientTopSymbolMap (fun _ => 1)) ≤ F.reducedSquareFastDiagonalSubalgebra (fun _ => 1) W) + +local notation "𝓗" => ℝ ⊗[ℚ] (L ⧸ F.layer 2) +local notation "𝓔" => F.RealFastCoefficientModule (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) W +local notation "𝓖" => F.realFastDiagonalSubgroup (fun _ : σ => 1) W +local notation "𝓟" => F.realFastCoefficientHorizontal (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) + (F.reducedSquareFastRelativeSubmodule (fun _ => 1) W) +local notation "𝓤" => Submodule.baseChange ℝ (F.layerOneGradedSubmodule e ω hF U) +local notation "ρ" => F.realFastCoefficientAction (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) W +local notation "Y" => (fun (g : 𝓖) i => F.realFastCoefficientDirectionMap W (Subtype.val g) (Pi.single i 1)) + +include hU in +theorem realFast_kernel_reabsorption [DecidableEq σ] + (B : 𝓖) (hzero : coefficients (F.realAdaptedPolynomialMap (fun _ => 1) B.val.coord) 0 = 0) + (K : Submodule ℝ 𝓗) (S R : K →ₗ[ℝ] 𝓔) + (hSR : S = (ρ B).toLinearMap.comp R) + (hS : (𝓟).comp S = K.subtype) (hR : (𝓟).comp R = K.subtype) + (small rational : σ → 𝓔) (k A C : σ → K) + (hsystem : ∀ i, Y B i = small i + ρ B (rational i) + S (k i)) + (hsmall : ∀ i, 𝓟 (small i) = 0) (hrational : ∀ i, 𝓟 (rational i) = 0) + (hk : ∀ i, (k i).val ∈ 𝓤) (hA : ∀ i, (A i).val ∈ 𝓤) (hC : ∀ i, (C i).val ∈ 𝓤) : + ∃ a B' c : 𝓖, + a.val = F.realLayerOneCorrection e ω hF (fun i => (A i).val) ∧ + c.val = F.realLayerOneCorrection e ω hF (fun i => (C i).val) ∧ + (B.val ∈ F.realPointwisePolynomialSubgroup e ω hF (fun _ => 1) U → + B'.val ∈ F.realPointwisePolynomialSubgroup e ω hF (fun _ => 1) U) ∧ + coefficients (F.realAdaptedPolynomialMap (fun _ => 1) B'.val.coord) 0 = 0 ∧ + (∀ i, (F.layer 2).mkQ.baseChange ℝ + (coefficients (F.realAdaptedPolynomialMap (fun _ => 1) B'.val.coord) (Finsupp.single i 1)) = + (k i - A i - C i).val) ∧ + let S' := (ρ a).symm.toLinearMap.comp S + let R' := (ρ c).toLinearMap.comp R + let small' := fun i => (ρ a).symm (small i - Y a i) + S' (A i) + let rational' := fun i => ρ c (rational i) - Y c i + R' (C i) + a * B' * c = B ∧ S' = (ρ B').toLinearMap.comp R' ∧ + (𝓟).comp S' = K.subtype ∧ (𝓟).comp R' = K.subtype ∧ + ∀ i, Y B' i = small' i + ρ B' (rational' i) + S' (k i - A i - C i) ∧ + 𝓟 (small' i) = 0 ∧ 𝓟 (rational' i) = 0 ∧ + 𝓟 (Y B' i) = (k i - A i - C i).val ∧ 𝓟 (Y B' i) ∈ 𝓤 ⊓ K := by + let a := F.realFastLayerOneCorrection e ω hF U W hU (fun i => (A i).val) hA + let c := F.realFastLayerOneCorrection e ω hF U W hU (fun i => (C i).val) hC + have hdata := cocycle_kernel_reabsorption ρ Y + (fun g h i => F.realFastCoefficientDirectionMap_mul W e ω hF g h (Pi.single i 1)) + 𝓟 (F.realFastCoefficientAction_horizontal (fun _ => 1) (fun _ => Nat.zero_lt_one) W e ω hF) + 𝓤 K B a c S R hSR hS hR small rational k A C hsystem hsmall hrational + (fun i => F.realFastLayerOneCorrection_horizontal e ω hF U W hU _ hA i) + (fun i => F.realFastLayerOneCorrection_horizontal e ω hF U W hU _ hC i) hk hA hC + have hpointwise : B.val ∈ F.realPointwisePolynomialSubgroup e ω hF (fun _ => 1) U → + (a⁻¹ * B * c⁻¹).val ∈ F.realPointwisePolynomialSubgroup e ω hF (fun _ => 1) U := by + intro hB + let G := F.realPointwisePolynomialSubgroup e ω hF (fun _ : σ => 1) U + exact G.mul_mem (G.mul_mem (G.inv_mem + (F.realLayerOneCorrection_mem_pointwiseSubgroup e ω hF U _ hA)) hB) + (G.inv_mem (F.realLayerOneCorrection_mem_pointwiseSubgroup e ω hF U _ hC)) + have hzeroa : coefficients (F.realAdaptedPolynomialMap (fun _ => 1) a.val.coord) 0 = 0 := by + change coefficients (F.realAdaptedPolynomialMap (fun _ => 1) + (F.realLayerOneCorrection e ω hF _).coord) 0 = 0 + rw [F.realLayerOneCorrection_log, coefficients_linearPolynomial_zero] + have hzeroc : coefficients (F.realAdaptedPolynomialMap (fun _ => 1) c.val.coord) 0 = 0 := by + change coefficients (F.realAdaptedPolynomialMap (fun _ => 1) + (F.realLayerOneCorrection e ω hF _).coord) 0 = 0 + rw [F.realLayerOneCorrection_log, coefficients_linearPolynomial_zero] + have hconst := F.realAdapted_factor_middle_constant (fun _ => 1) B.val a.val + (a⁻¹ * B * c⁻¹).val c.val (congrArg Subtype.val hdata.1) hzeroa hzeroc + have hzero' := hconst.trans hzero + have hlinear (i : σ) : (F.layer 2).mkQ.baseChange ℝ + (coefficients (F.realAdaptedPolynomialMap (fun _ => 1) (a⁻¹ * B * c⁻¹).val.coord) + (Finsupp.single i 1)) = (k i - A i - C i).val := by + have hd := F.realFirstCoefficientDirectionMap_horizontal_unit e ω hF i + (a⁻¹ * B * c⁻¹).val.coord hzero' + have he : 𝓟 (Y (a⁻¹ * B * c⁻¹) i) = (F.layer 2).mkQ.baseChange ℝ + (coefficients (F.realAdaptedPolynomialMap (fun _ => 1) (a⁻¹ * B * c⁻¹).val.coord) + (Finsupp.single i 1)) := hd + exact he.symm.trans (hdata.2.2.2.2 i).2.2.2.1 + exact ⟨a, a⁻¹ * B * c⁻¹, c, rfl, rfl, hpointwise, hzero', hlinear, hdata⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FastKernelReabsorptionControl.lean b/lean/OAI/Combinatorics/Progressions/Linear/FastKernelReabsorptionControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa4ba1b1f10681c3497ce38c1c6e5deed55146fb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FastKernelReabsorptionControl.lean @@ -0,0 +1,116 @@ +import OAI.Combinatorics.Progressions.Estimates.ExtractedInitialState + +namespace OAI + +section + +namespace Erdos3 + +theorem norm_add_lift_coordinate_bound {E K V H : Type*} + [AddCommGroup E] [Module ℝ E] [AddCommGroup K] [Module ℝ K] + [SeminormedAddCommGroup V] [NormedSpace ℝ V] + [SeminormedAddCommGroup H] [NormedSpace ℝ H] + (N : E →ₗ[ℝ] V) (NK : K →ₗ[ℝ] H) (S : K →ₗ[ℝ] E) + (small : E) (a : K) (M C A T : ℝ) (hC : 0 ≤ C) (hT : 0 < T) + (hsmall : ‖N small‖ ≤ M / T) (ha : ‖NK a‖ ≤ A / T) + (hS : ∀ x, ‖N (S x)‖ ≤ C * ‖NK x‖) : + ‖N (small + S a)‖ ≤ (M + C * A) / T := by + rw [map_add] + calc + _ ≤ ‖N small‖ + ‖N (S a)‖ := norm_add_le _ _ + _ ≤ M / T + C * (A / T) := + add_le_add hsmall ((hS a).trans (mul_le_mul_of_nonneg_left ha hC)) + _ = _ := by field_simp [hT.ne'] + +theorem rational_lift_reabsorption_grid {ι κ K : Type*} [Fintype κ] + [AddCommGroup K] [Module ℝ K] + (R : K →ₗ[ℝ] (ι → ℝ)) (v : κ → K) (c : κ → ℝ) (r : ι → ℝ) (l m n : ℕ) + (hc : c ∈ realDenominatorGrid l) (hR : ∀ k, R (v k) ∈ realDenominatorGrid m) + (hr : r ∈ realDenominatorGrid n) : + r + R (∑ k, c k • v k) ∈ realDenominatorGrid (n * (m * l)) := by + have hgrid := linear_lift_grid_of_coefficients R v c l m hc hR + have h := realDenominatorGrid_sub_product n (m * l) r (-R (∑ k, c k • v k)) hr + (realDenominatorGrid_neg (m * l) hgrid) + simpa only [sub_neg_eq_add] using h + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct + +variable {σ ι ν τ K L V H : Type*} [Fintype σ] [DecidableEq σ] [Fintype ν] + [AddCommGroup K] [Module ℝ K] [LieRing L] [LieAlgebra ℚ L] + [SeminormedAddCommGroup V] [NormedSpace ℝ V] + [SeminormedAddCommGroup H] [NormedSpace ℝ H] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) + (U : LieSubalgebra ℚ (F.squareFiltration.quotientTop.PolynomialSymbol (fun _ : σ => 1))) + (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +local notation "𝓔" => F.RealFastCoefficientModule (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) U +local notation "𝓖" => F.realFastDiagonalSubgroup (fun _ : σ => 1) U +local notation "ρ" => F.realFastCoefficientAction (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) U +local notation "P" => F.realFastCoefficientHorizontal (fun _ : σ => 1) (fun _ => Nat.zero_lt_one) + (F.reducedSquareFastRelativeSubmodule (fun _ => 1) U) +local notation "Y" => (fun (g : 𝓖) i => F.realFastCoefficientDirectionMap U (Subtype.val g) (Pi.single i 1)) + +include e ω hF + +theorem realFast_kernel_reabsorption_controlled + (a b c : 𝓖) (S R : K →ₗ[ℝ] 𝓔) + (hSR : S = (ρ (a * b * c)).toLinearMap.comp R) + (I : K →ₗ[ℝ] (ℝ ⊗[ℚ] (L ⧸ F.layer 2))) (hS : (P).comp S = I) (hR : (P).comp R = I) + (small rational : σ → 𝓔) (k A B : σ → K) + (hsystem : ∀ i, Y (a * b * c) i = small i + ρ (a * b * c) (rational i) + S (k i)) + (N : 𝓔 →ₗ[ℝ] V) (NK : K →ₗ[ℝ] H) (coord : 𝓔 →ₗ[ℝ] (τ → ℝ)) + (C M D J A₀ : ℝ) (hC : 0 ≤ C) (hJ : 0 ≤ J) (T : σ → ℝ) (hT : ∀ i, 0 < T i) + (haction : ∀ x, ‖N ((ρ a).symm x)‖ ≤ C * ‖N x‖) + (hsmall : ∀ i, ‖N (small i)‖ ≤ M / T i) (hYa : ∀ i, ‖N (Y a i)‖ ≤ D / T i) + (hSbound : ∀ x, ‖N (S x)‖ ≤ J * ‖NK x‖) (hA : ∀ i, ‖NK (A i)‖ ≤ A₀ / T i) + (v : ν → K) (l q rden : ℕ) (hRgrid : ∀ j, coord (R (v j)) ∈ realDenominatorGrid l) + (hrational : ∀ i, coord (rational i) ∈ realDenominatorGrid l) + (hc : ∀ x, coord x ∈ realDenominatorGrid l → coord (ρ c x) ∈ realDenominatorGrid q) + (hYc : ∀ i, coord (Y c i) ∈ realDenominatorGrid q) + (β : σ → ν → ℝ) (hB : ∀ i, B i = ∑ j, β i j • v j) + (hβ : ∀ i, β i ∈ realDenominatorGrid rden) : + let S' := (ρ a).symm.toLinearMap.comp S + let R' := (ρ c).toLinearMap.comp R + let small' := fun i => (ρ a).symm (small i - Y a i) + S' (A i) + let rational' := fun i => ρ c (rational i) - Y c i + R' (B i) + S' = (ρ b).toLinearMap.comp R' ∧ (P).comp S' = I ∧ (P).comp R' = I ∧ + (∀ x, ‖N (S' x)‖ ≤ (C * J) * ‖NK x‖) ∧ + (∀ j, coord (R' (v j)) ∈ realDenominatorGrid q) ∧ + ∀ i, Y b i = small' i + ρ b (rational' i) + S' (k i - A i - B i) ∧ + ‖N (small' i)‖ ≤ (C * (M + D) + (C * J) * A₀) / T i ∧ + coord (rational' i) ∈ realDenominatorGrid (q * (q * rden)) := by + intro S' R' small' rational' + have hdata := F.realFast_derivative_removal_controlled U e ω hF a b c S R hSR I hS hR + small rational k hsystem N coord C M D hC T hT haction hsmall hYa + (fun x => J * ‖NK x‖) hSbound v l q hRgrid hrational hc hYc + obtain ⟨hfactor, hhorS, hhorR, hS', hR', hderiv⟩ := hdata + have hSbound' (x : K) : ‖N (S' x)‖ ≤ (C * J) * ‖NK x‖ := by + simpa only [mul_assoc] using hS' x + refine ⟨hfactor, hhorS, hhorR, hSbound', hR', fun i => ?_⟩ + obtain ⟨hraw, hrawNorm, hrawGrid⟩ := hderiv i + refine ⟨?_, ?_, ?_⟩ + · have h := linear_derivative_absorb (ρ b).toLinearMap S' R' hfactor (Y b i) + ((ρ a).symm (small i - Y a i)) (ρ c (rational i) - Y c i) (k i) (-A i) (-B i) hraw + simp only [map_neg, sub_neg_eq_add, ← sub_eq_add_neg] at h + exact h + · exact norm_add_lift_coordinate_bound N NK S' _ (A i) (C * (M + D)) (C * J) A₀ + (T i) (mul_nonneg hC hJ) (hT i) hrawNorm (hA i) hSbound' + · change coord (ρ c (rational i) - Y c i + R' (B i)) ∈ _ + rw [map_add, hB i] + exact rational_lift_reabsorption_grid (coord.comp R') v (β i) _ rden q q (hβ i) hR' hrawGrid + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteCenteredKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteCenteredKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..491bab44c61051490fa74a5634632d52f53af1fe --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteCenteredKernel.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.Progressions.Estimates.ScalarDominatedSlack + +namespace OAI + +section + +namespace Erdos3.FiniteProbabilityWeights + +open scoped BigOperators + +variable {X Y : Type*} [Fintype X] [Fintype Y] + +noncomputable def joint (p : FiniteProbabilityWeights X) (q : X → FiniteProbabilityWeights Y) : + FiniteProbabilityWeights (X × Y) where + weight z := p.weight z.1 * (q z.1).weight z.2 + nonneg z := mul_nonneg (p.nonneg z.1) ((q z.1).nonneg z.2) + total := by + simp only [Fintype.sum_prod_type, ← Finset.mul_sum, total, mul_one] + +theorem joint_mean (p : FiniteProbabilityWeights X) (q : X → FiniteProbabilityWeights Y) + (f : X × Y → ℝ) : + (p.joint q).mean f = p.mean (fun x => (q x).mean (fun y => f (x,y))) := by + simp only [mean, joint, Fintype.sum_prod_type, Finset.mul_sum, mul_assoc] + +theorem joint_complexMean (p : FiniteProbabilityWeights X) (q : X → FiniteProbabilityWeights Y) + (f : X × Y → ℂ) : + (p.joint q).complexMean f = p.complexMean (fun x => (q x).complexMean (fun y => f (x,y))) := by + simp only [complexMean, joint, Fintype.sum_prod_type, Complex.ofReal_mul, + Finset.mul_sum, mul_assoc] + +end Erdos3.FiniteProbabilityWeights + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {X Y : Type*} [Fintype X] [Fintype Y] + +noncomputable def centeredKernelMatrix (ν : FiniteProbabilityWeights Y) + (K : X → FiniteProbabilityWeights Y) (x : X) (y : Y) : ℝ := (K x).weight y - ν.weight y + +omit [Fintype X] in +theorem centeredKernelMatrix_apply (ν : FiniteProbabilityWeights Y) + (K : X → FiniteProbabilityWeights Y) (f : Y → ℝ) (x : X) : + (∑ y, centeredKernelMatrix ν K x y * f y) = (K x).mean f - ν.mean f := by + simp only [centeredKernelMatrix, sub_mul, Finset.sum_sub_distrib, FiniteProbabilityWeights.mean] + +theorem FiniteProbabilityWeights.mean_centered_sq (ν : FiniteProbabilityWeights Y) (f : Y → ℝ) : + ν.mean (fun y => (f y - ν.mean f) ^ 2) = ν.mean (fun y => f y ^ 2) - (ν.mean f) ^ 2 := by + calc + _ = ν.mean (fun y => f y ^ 2 - (2 * ν.mean f) * f y + (ν.mean f) ^ 2) := by + congr 1 + funext y + ring + _ = _ := by + rw [ν.mean_add, ν.mean_sub, ν.mean_const_mul, ν.mean_const] + ring + +theorem centeredKernelMatrix_sq_le (μ : FiniteProbabilityWeights X) (ν : FiniteProbabilityWeights Y) + (K : X → FiniteProbabilityWeights Y) {C : ℝ} (hC : 0 ≤ C) + (hbound : ∀ f : Y → ℝ, ν.mean f = 0 → + μ.mean (fun x => (K x).mean f ^ 2) ≤ C * ν.mean (fun y => f y ^ 2)) (f : Y → ℝ) : + μ.mean (fun x => (∑ y, centeredKernelMatrix ν K x y * f y) ^ 2) ≤ + C * ν.mean (fun y => f y ^ 2) := by + have hzero : ν.mean (fun y => f y - ν.mean f) = 0 := by + rw [ν.mean_sub, ν.mean_const, sub_self] + have hc := hbound (fun y => f y - ν.mean f) hzero + have he (x : X) : (K x).mean (fun y => f y - ν.mean f) = + ∑ y, centeredKernelMatrix ν K x y * f y := by + rw [centeredKernelMatrix_apply, FiniteProbabilityWeights.mean_sub, FiniteProbabilityWeights.mean_const] + simp_rw [he] at hc + rw [ν.mean_centered_sq] at hc + exact hc.trans (mul_le_mul_of_nonneg_left (sub_le_self _ (sq_nonneg _)) hC) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteDescendingRankOrder.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteDescendingRankOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..472e2b070420a031d5efed2ca2d22512b2e47f9e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteDescendingRankOrder.lean @@ -0,0 +1,31 @@ +import Mathlib.Data.Finset.Sort +import Mathlib.Data.Prod.Lex + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_finite_descending_rank_equiv {I : Type*} [Fintype I] + (rank : I → ℕ) : + ∃ e : Fin (Fintype.card I) ≃ I, ∀ i j, i ≤ j → rank (e j) ≤ rank (e i) := by + classical + let key : I → OrderDual ℕ ×ₗ Fin (Fintype.card I) := + fun i => toLex (rank i, Fintype.equivFin I i) + have hkey : Function.Injective key := by + intro i j hij + apply (Fintype.equivFin I).injective + exact congrArg (fun z => (ofLex z).2) hij + let _ : LinearOrder I := LinearOrder.lift' key hkey + let e : Fin (Fintype.card I) ≃o I := Fintype.orderIsoFinOfCardEq I rfl + refine ⟨e.toEquiv, ?_⟩ + intro i j hij + have hle : key (e i) ≤ key (e j) := e.monotone hij + exact Prod.Lex.monotone_fst _ _ hle + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteIndependentKernels.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteIndependentKernels.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5a4735308644350277f3b7c805024bc1e29421b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteIndependentKernels.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Probability.ShiftedProductCoordinateLaw + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +universe uA uX uY uZ + +theorem dependentProductPMF_finite_bind + {A : Type uA} [Fintype A] {X : A → Type uX} {Y : A → Type uY} + [∀ a, Fintype (X a)] [∀ a, MeasurableSpace (X a)] [∀ a, MeasurableSingletonClass (X a)] + [∀ a, Countable (Y a)] [∀ a, MeasurableSpace (Y a)] [∀ a, MeasurableSingletonClass (Y a)] + (p : ∀ a, PMF (X a)) (q : ∀ a, X a → PMF (Y a)) : + (dependentProductPMF p).bind (fun x => dependentProductPMF (fun a => q a (x a))) = + dependentProductPMF (fun a => (p a).bind (q a)) := by + classical + ext y + simp only [PMF.bind_apply, tsum_fintype, dependentProductPMF_apply, + ← Finset.prod_mul_distrib] + exact (Fintype.prod_sum (fun a x => p a x * q a x (y a))).symm + +theorem dependentProductPMF_eval + {A : Type uA} [Fintype A] {X : A → Type uX} + [∀ a, Countable (X a)] [∀ a, MeasurableSpace (X a)] [∀ a, MeasurableSingletonClass (X a)] + (p : ∀ a, PMF (X a)) (a : A) : + (dependentProductPMF p).map (fun x => x a) = p a := by + apply PMF.toMeasure_injective + rw [← PMF.toMeasure_map (fun x => x a) (dependentProductPMF p) (by fun_prop)] + simp only [dependentProductPMF, Measure.toPMF_toMeasure] + exact (measurePreserving_eval (fun a => (p a).toMeasure) a).map_eq + +theorem pmf_bind_of_finite_independent_coordinates + {A : Type uA} [Fintype A] {X : A → Type uX} {Y : A → Type uY} {Z : Type uZ} + [∀ a, Fintype (X a)] [∀ a, MeasurableSpace (X a)] [∀ a, MeasurableSingletonClass (X a)] + [∀ a, Countable (Y a)] [∀ a, MeasurableSpace (Y a)] [∀ a, MeasurableSingletonClass (Y a)] + (p : PMF Z) (g : Z → ∀ a, X a) (t : ∀ a, PMF (X a)) + (ht : p.map g = dependentProductPMF t) (q : ∀ a, X a → PMF (Y a)) : + p.bind (fun z => dependentProductPMF (fun a => q a (g z a))) = + dependentProductPMF (fun a => p.bind (fun z => q a (g z a))) := by + have hcoord (a : A) : p.map (fun z => g z a) = t a := + (PMF.map_comp g p (fun x => x a)).symm.trans + ((congrArg (fun μ : PMF (∀ a, X a) => μ.map (fun x => x a)) ht).trans + (dependentProductPMF_eval t a)) + have hlocal (a : A) : p.bind (fun z => q a (g z a)) = (t a).bind (q a) := + (PMF.bind_map p (fun z => g z a) (q a)).symm.trans + (congrArg (fun μ : PMF (X a) => μ.bind (q a)) (hcoord a)) + calc + _ = (p.map g).bind (fun x => dependentProductPMF (fun a => q a (x a))) := + (PMF.bind_map p g (fun x => dependentProductPMF (fun a => q a (x a)))).symm + _ = (dependentProductPMF t).bind (fun x => dependentProductPMF (fun a => q a (x a))) := + congrArg (fun μ : PMF (∀ a, X a) => μ.bind + (fun x => dependentProductPMF (fun a => q a (x a)))) ht + _ = dependentProductPMF (fun a => (t a).bind (q a)) := dependentProductPMF_finite_bind t q + _ = _ := congrArg (fun μ : ∀ a, PMF (Y a) => dependentProductPMF μ) + (funext (fun a => (hlocal a).symm)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelCounting.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..f405e2eade74cdafc981de799ea4561e8860d80d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelCounting.lean @@ -0,0 +1,87 @@ +import Mathlib.Data.Finset.Card +import OAI.Combinatorics.Progressions.Estimates.CountingDeficitDetection + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem subset_counting_error_scale {m n : ℕ} (hmn : m < n) {delta : ℝ} (hdelta : 0 ≤ delta) : + (18 : ℝ) ^ m * delta ≤ ((18 : ℝ) ^ n * delta) / 18 := by + calc + (18 : ℝ) ^ m * delta = ((18 : ℝ) ^ (m + 1) * delta) / 18 := by rw [pow_succ]; ring + _ ≤ _ := div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) (by omega)) hdelta) + (by norm_num) + +theorem finite_products_near_one_of_kernel_bound {I X : Type*} + [DecidableEq I] [Fintype X] [Nonempty X] (s : ℕ) {delta : ℝ} (hdelta : 0 < delta) + (F : I → X → ℝ) (hmean : ∀ i, |(𝔼 x, F i x) - 1| ≤ delta) + (hkernel : ∀ (S : Finset I), S.card ≤ s → ∀ i j : I, i ∉ S → j ∉ S → i ≠ j → + ∀ b : ℝ, (b = 1 ∨ b = 1 / 4) → + countingKernelAverage b (fun x => ∏ k ∈ S, F k x) (F i) (F j) ≤ 1 + delta / 16) + (T : Finset I) (hT : T.card ≤ s + 2) : + |(𝔼 x, ∏ i ∈ T, F i x) - 1| ≤ (18 : ℝ) ^ T.card * delta := by + induction T using Finset.strongInductionOn + rename_i T ih + rcases T.eq_empty_or_nonempty with rfl | hnonempty + · simp only [Finset.prod_empty, Fintype.expect_const, sub_self, abs_zero, + Finset.card_empty, pow_zero, one_mul] + exact le_of_lt hdelta + by_cases hsmall : T.card ≤ 1 + · obtain ⟨i, hi⟩ := hnonempty + have heq : T = {i} := Finset.eq_singleton_iff_unique_mem.mpr + ⟨hi, fun j hj => Finset.card_le_one.mp hsmall j hj i hi⟩ + rw [heq] + simp only [Finset.prod_singleton, Finset.card_singleton, pow_one] + exact (hmean i).trans (by linarith) + obtain ⟨i, hi, j, hj, hij⟩ := Finset.one_lt_card.mp (show 1 < T.card by omega) + let S := (T.erase i).erase j + have hj' : j ∈ T.erase i := Finset.mem_erase.mpr ⟨Ne.symm hij, hj⟩ + have hSi : i ∉ S := by simp [S] + have hSj : j ∉ S := by simp [S] + have hSji : insert j S = T.erase i := Finset.insert_erase hj' + have hSij : insert i S = T.erase j := by + dsimp [S] + rw [Finset.erase_right_comm, Finset.insert_erase (Finset.mem_erase.mpr ⟨hij, hi⟩)] + have hform : T = insert i (insert j S) := by rw [hSji, Finset.insert_erase hi] + have hScard : S.card ≤ s := by + dsimp [S] + rw [Finset.card_erase_of_mem hj', Finset.card_erase_of_mem hi] + omega + have hproper (U : Finset I) (hU : U ⊂ T) : + |(𝔼 x, ∏ k ∈ U, F k x) - 1| ≤ ((18 : ℝ) ^ T.card * delta) / 18 := + (ih U hU ((Finset.card_le_card (le_of_lt hU)).trans hT)).trans + (subset_counting_error_scale (Finset.card_lt_card hU) (le_of_lt hdelta)) + have h00 := hproper S (lt_of_le_of_lt (Finset.erase_subset j (T.erase i)) + (Finset.erase_ssubset hi)) + have h10 : |(𝔼 x, (∏ k ∈ S, F k x) * F i x) - 1| ≤ + ((18 : ℝ) ^ T.card * delta) / 18 := by + have h := hproper (insert i S) (by rw [hSij]; exact Finset.erase_ssubset hj) + simpa only [Finset.prod_insert hSi, mul_comm] using h + have h01 : |(𝔼 x, (∏ k ∈ S, F k x) * F j x) - 1| ≤ + ((18 : ℝ) ^ T.card * delta) / 18 := by + have h := hproper (insert j S) (by rw [hSji]; exact Finset.erase_ssubset hi) + simpa only [Finset.prod_insert hSj, mul_comm] using h + have hprod (x : X) : (∏ k ∈ T, F k x) = (∏ k ∈ S, F k x) * F i x * F j x := by + rw [hform, Finset.prod_insert (by simp [hij, hSi]), Finset.prod_insert hSj] + ring + by_contra! hbad + simp only [hprod] at hbad + obtain ⟨b, hb, hsurplus⟩ := exists_countingKernel_surplus + (mul_pos (pow_pos (by norm_num) _) hdelta) (fun x => ∏ k ∈ S, F k x) + (F i) (F j) h00 h10 h01 hbad + have hu := hkernel S hScard i j hSi hSj hij b hb + have hscale : delta ≤ (18 : ℝ) ^ T.card * delta := by + simpa only [one_mul] using mul_le_mul_of_nonneg_right + (one_le_pow₀ (show (1 : ℝ) ≤ 18 by norm_num)) (le_of_lt hdelta) + linarith + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelRestriction.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6acbde9ffecb7cf0c8f76584300c794a19296453 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelRestriction.lean @@ -0,0 +1,301 @@ +import Mathlib.MeasureTheory.Integral.Prod +import Mathlib.MeasureTheory.Measure.HasOuterApproxClosed +import Mathlib.Probability.Distributions.Uniform +import Mathlib.Probability.ProbabilityMassFunction.Integrals +import OAI.Combinatorics.Progressions.Estimates.ContinuousImageFactor +import OAI.Combinatorics.Progressions.Geometry.IndependentProductTransport +import OAI.Combinatorics.Progressions.Lattices.CoverBasisResidues +import OAI.Combinatorics.Progressions.Probability.SlicedRemainderDensityFamily + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory Topology +open scoped BigOperators + +variable {G H : Type*} [AddCommGroup G] [AddCommGroup H] +variable (C : G →+ H) [Fintype C.ker] + +noncomputable def finiteFiberAverage (f : G → ℝ) (x : G) : ℝ := + (Fintype.card C.ker : ℝ)⁻¹ * ∑ k : C.ker, f (x + k.val) + +theorem finiteFiberAverage_eq_of_map_eq (f : G → ℝ) {x y : G} (hxy : C x = C y) : + finiteFiberAverage C f x = finiteFiberAverage C f y := by + classical + have hk : x - y ∈ C.ker := by + change C (x - y) = 0 + rw [map_sub, hxy, sub_self] + unfold finiteFiberAverage + congr 1 + apply Fintype.sum_equiv (Equiv.addLeft (⟨x - y, hk⟩ : C.ker)) + intro k + congr 1 + change x + k.val = y + (x - y + k.val) + abel + +theorem finiteFiberAverage_integral_uniform + [MeasurableSpace C.ker] [MeasurableSingletonClass C.ker] (f : G → ℝ) (x : G) : + (∫ k : C.ker, f (x + k.val) ∂(PMF.uniformOfFintype C.ker).toMeasure) = + finiteFiberAverage C f x := by + rw [PMF.integral_eq_sum] + simp only [PMF.uniformOfFintype_apply, ENNReal.toReal_inv, ENNReal.toReal_natCast, + smul_eq_mul, ← Finset.mul_sum, finiteFiberAverage] + +variable [TopologicalSpace G] [IsTopologicalAddGroup G] + +theorem finiteFiberAverage_continuous {f : G → ℝ} (hf : Continuous f) : + Continuous (finiteFiberAverage C f) := by + apply continuous_const.mul + apply continuous_finsetSum + intro k _ + exact hf.comp (continuous_id.add continuous_const) + +omit [TopologicalSpace G] [IsTopologicalAddGroup G] in +theorem finiteFiberAverage_norm_le (f : G → ℝ) {B : ℝ} (hf : ∀ x, ‖f x‖ ≤ B) (x : G) : + ‖finiteFiberAverage C f x‖ ≤ B := by + have hn : (0 : ℝ) < Fintype.card C.ker := by exact_mod_cast Fintype.card_pos + rw [finiteFiberAverage, norm_mul, Real.norm_of_nonneg (inv_nonneg.mpr hn.le)] + calc + _ ≤ (Fintype.card C.ker : ℝ)⁻¹ * ∑ _k : C.ker, B := + mul_le_mul_of_nonneg_left ((norm_sum_le _ _).trans (Finset.sum_le_sum (fun k _ => hf _))) + (inv_nonneg.mpr hn.le) + _ = B := by simp [hn.ne'] + +theorem finiteFiberAverage_factor [CompactSpace G] [TopologicalSpace H] [T2Space H] + (hC : Continuous C) (hCs : Function.Surjective C) {f : G → ℝ} (hf : Continuous f) : + ∃ g : H → ℝ, Continuous g ∧ ∀ x, g (C x) = finiteFiberAverage C f x := by + let e : ContinuousMap G H := ⟨C, hC⟩ + have hq : IsQuotientMap e := IsQuotientMap.of_surjective_continuous hCs hC + let a : ContinuousMap G ℝ := ⟨finiteFiberAverage C f, finiteFiberAverage_continuous C hf⟩ + have hfac : Function.FactorsThrough a e := + fun _ _ hxy => finiteFiberAverage_eq_of_map_eq C f hxy + let g := hq.lift a hfac + refine ⟨g, g.continuous, ?_⟩ + intro x + exact DFunLike.congr_fun (hq.lift_comp a hfac) x + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +variable {G H X : Type*} [AddCommGroup G] [AddCommGroup H] +variable [TopologicalSpace G] [IsTopologicalAddGroup G] [MeasurableSpace G] [BorelSpace G] +variable (C : G →+ H) [Fintype C.ker] + +theorem finiteFiberAverage_integral_of_invariant + (μ : Measure G) [IsFiniteMeasure μ] + (hμ : ∀ k : C.ker, μ.map (fun x => x + k.val) = μ) + (f : G → ℝ) (hf : Continuous f) {B : ℝ} (hB : ∀ x, ‖f x‖ ≤ B) : + (∫ x, finiteFiberAverage C f x ∂μ) = ∫ x, f x ∂μ := by + have hi (k : C.ker) : Integrable (fun x => f (x + k.val)) μ := + Integrable.of_bound (hf.comp (continuous_id.add continuous_const)).aestronglyMeasurable + B (ae_of_all μ (fun x => hB _)) + have he (k : C.ker) : (∫ x, f (x + k.val) ∂μ) = ∫ x, f x ∂μ := by + have hm : Measurable (fun x : G => x + k.val) := + (continuous_id.add continuous_const).measurable + have h := integral_map hm.aemeasurable + (hf.aestronglyMeasurable (μ := μ.map (fun x => x + k.val))) + rw [hμ k] at h + exact h.symm + unfold finiteFiberAverage + rw [integral_const_mul, integral_finsetSum _ (fun k _ => hi k)] + simp only [he, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + have hn : (Fintype.card C.ker : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + rw [← mul_assoc, inv_mul_cancel₀ hn, one_mul] + +variable [T2Space G] [MeasurableSpace X] [MeasurableAdd₂ G] + +noncomputable def finiteKernelLiftLaw (ρ : Measure X) (s : X → G) : Measure G := + (ρ.prod (PMF.uniformOfFintype C.ker).toMeasure).map (fun p => s p.1 + p.2.val) + +omit [IsTopologicalAddGroup G] in +theorem finiteKernelLiftLaw_integral (ρ : Measure X) [IsFiniteMeasure ρ] + (s : X → G) (hs : Measurable s) (f : G → ℝ) (hf : Measurable f) + {B : ℝ} (hB : ∀ x, ‖f x‖ ≤ B) : + (∫ y, f y ∂finiteKernelLiftLaw C ρ s) = ∫ x, finiteFiberAverage C f (s x) ∂ρ := by + have hL : Measurable (fun p : X × C.ker => s p.1 + p.2.val) := + (hs.comp measurable_fst).add (measurable_subtype_coe.comp measurable_snd) + have hi : Integrable (fun p : X × C.ker => f (s p.1 + p.2.val)) + (ρ.prod (PMF.uniformOfFintype C.ker).toMeasure) := + Integrable.of_bound (hf.comp hL).aestronglyMeasurable B (ae_of_all _ (fun p => hB _)) + rw [finiteKernelLiftLaw, integral_map hL.aemeasurable hf.aestronglyMeasurable, + integral_prod _ hi] + exact integral_congr_ae (ae_of_all ρ (fun x => finiteFiberAverage_integral_uniform C f (s x))) + +theorem finiteKernelLiftLaw_eq [CompactSpace G] [HasOuterApproxClosed G] + [TopologicalSpace H] [T2Space H] [MeasurableSpace H] [BorelSpace H] + (hC : Continuous C) (hCs : Function.Surjective C) + (μ : Measure G) [IsFiniteMeasure μ] + (hμ : ∀ k : C.ker, μ.map (fun x => x + k.val) = μ) + (ρ : Measure X) [IsFiniteMeasure ρ] (s : X → G) (hs : Measurable s) + (hbase : ρ.map (C ∘ s) = μ.map C) : + finiteKernelLiftLaw C ρ s = μ := by + let _ : IsFiniteMeasure (finiteKernelLiftLaw C ρ s) := by + unfold finiteKernelLiftLaw + infer_instance + apply MeasureTheory.ext_of_forall_integral_eq_of_IsFiniteMeasure + intro φ + obtain ⟨g, hgc, hg⟩ := finiteFiberAverage_factor C hC hCs φ.continuous + calc + (∫ y, φ y ∂finiteKernelLiftLaw C ρ s) = + ∫ x, finiteFiberAverage C φ (s x) ∂ρ := + finiteKernelLiftLaw_integral C ρ s hs φ φ.continuous.measurable φ.norm_coe_le_norm + _ = ∫ x, g (C (s x)) ∂ρ := by simp_rw [hg] + _ = ∫ y, g y ∂ρ.map (C ∘ s) := + (integral_map (hC.measurable.comp hs).aemeasurable hgc.aestronglyMeasurable).symm + _ = ∫ y, g y ∂μ.map C := by rw [hbase] + _ = ∫ x, g (C x) ∂μ := integral_map hC.measurable.aemeasurable hgc.aestronglyMeasurable + _ = ∫ x, finiteFiberAverage C φ x ∂μ := by simp_rw [hg] + _ = ∫ x, φ x ∂μ := + finiteFiberAverage_integral_of_invariant C μ hμ φ φ.continuous φ.norm_coe_le_norm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped Classical + +theorem uniformPMF_map_equiv {R S : Type*} [Fintype R] [Fintype S] + [Nonempty R] [Nonempty S] (e : R ≃ S) : + (PMF.uniformOfFintype R).map e = PMF.uniformOfFintype S := by + ext y + obtain ⟨x, rfl⟩ := e.surjective y + rw [pmf_map_injective_at _ e e.injective, PMF.uniformOfFintype_apply, + PMF.uniformOfFintype_apply, Fintype.card_congr e] + +theorem finiteKernelLiftLaw_relabel {G H X R : Type*} + [AddCommGroup G] [AddCommGroup H] + [TopologicalSpace G] [T2Space G] [MeasurableSpace G] [BorelSpace G] + [MeasurableAdd₂ G] [MeasurableSpace X] + (C : G →+ H) [Fintype C.ker] [Fintype R] [Nonempty R] + [MeasurableSpace R] [MeasurableSingletonClass R] + (e : R ≃ C.ker) (ρ : Measure X) [SFinite ρ] + (s : X → G) (hs : Measurable s) : + (ρ.prod (PMF.uniformOfFintype R).toMeasure).map + (fun p => s p.1 + (e p.2).val) = finiteKernelLiftLaw C ρ s := by + have he : Measurable e := measurable_of_finite _ + have hm : (PMF.uniformOfFintype R).toMeasure.map e = + (PMF.uniformOfFintype C.ker).toMeasure := by + rw [PMF.toMeasure_map e _ he, uniformPMF_map_equiv] + have hp : ρ.prod (PMF.uniformOfFintype C.ker).toMeasure = + (ρ.prod (PMF.uniformOfFintype R).toMeasure).map (Prod.map id e) := by + rw [← hm, ← Measure.map_prod_map _ _ measurable_id he, Measure.map_id] + rw [finiteKernelLiftLaw, hp, Measure.map_map] + · rfl + · exact (hs.comp measurable_fst).add (measurable_subtype_coe.comp measurable_snd) + · exact measurable_id.prodMap he + +theorem finiteKernelLiftLaw_basisResidues {E I X : Type*} + [AddCommGroup E] [Module ℝ E] [Fintype I] + (Γ : AddSubgroup E) (b : Module.Basis I ℤ Γ) + [TopologicalSpace (E ⧸ Γ)] [T2Space (E ⧸ Γ)] + [MeasurableSpace (E ⧸ Γ)] [BorelSpace (E ⧸ Γ)] [MeasurableAdd₂ (E ⧸ Γ)] + [MeasurableSpace X] (d : ℕ) [NeZero d] + [Fintype (quotientIntegerCover Γ d).ker] + (ρ : Measure X) [SFinite ρ] (s : X → E ⧸ Γ) (hs : Measurable s) : + (ρ.prod (PMF.uniformOfFintype (I → ZMod d)).toMeasure).map + (fun p => s p.1 + (coverKernelBasisEquiv Γ b d (Nat.pos_of_ne_zero (NeZero.ne d)) p.2).val) = + finiteKernelLiftLaw (quotientIntegerCover Γ d) ρ s := + finiteKernelLiftLaw_relabel _ (coverKernelBasisEquiv Γ b d _).toEquiv ρ s hs + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +variable {G H X : Type*} [AddCommGroup G] [AddCommGroup H] +variable [TopologicalSpace G] [IsTopologicalAddGroup G] [MeasurableSpace G] [BorelSpace G] +variable [T2Space G] [CompactSpace G] [HasOuterApproxClosed G] +variable [MeasurableAdd₂ G] +variable [TopologicalSpace H] [T2Space H] [MeasurableSpace H] [BorelSpace H] +variable [MeasurableSpace X] (C : G →+ H) [Fintype C.ker] + +theorem finiteKernelLift_density (hC : Continuous C) (hCs : Function.Surjective C) + (μ : Measure G) [μ.IsAddLeftInvariant] (ν : Measure H) + (hmp : MeasurePreserving C μ ν) + (D : H → ℝ) (hD : Measurable D) (hi : Integrable D ν) (h0 : ∀ y, 0 ≤ D y) + (ρ : Measure X) [IsFiniteMeasure ρ] (s : X → G) (hs : Measurable s) + (hbase : ρ.map (C ∘ s) = realDensityMeasure ν D) : + finiteKernelLiftLaw C ρ s = realDensityMeasure μ (fun x => D (C x)) := by + have hci : Integrable (fun x => D (C x)) μ := hmp.integrable_comp_of_integrable hi + let _ := realDensityMeasure_finite μ (fun x => D (C x)) hci (fun x => h0 _) + refine finiteKernelLiftLaw_eq C hC hCs (realDensityMeasure μ (fun x => D (C x))) + ?_ ρ s hs ?_ + · intro k + rw [realDensityMeasure_map_add_right] + congr 1 + funext x + rw [map_sub, show C k.val = 0 from k.property, sub_zero] + · rw [measurePreserving_realDensity_map μ ν C hmp D hD hi h0] + exact hbase + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped ENNReal + +theorem realDensityMeasure_indicator_one {X : Type*} [MeasurableSpace X] + (μ : Measure X) {S : Set X} (hS : MeasurableSet S) : + realDensityMeasure μ (S.indicator (fun _ => (1 : ℝ))) = μ.restrict S := by + have he : (fun x => ENNReal.ofReal (S.indicator (fun _ => (1 : ℝ)) x)) = + S.indicator (fun _ => (1 : ℝ≥0∞)) := by + funext x + by_cases hx : x ∈ S <;> simp [hx] + rw [realDensityMeasure, he] + exact withDensity_indicator_one hS + +theorem finiteKernelLift_restrict {G H X : Type*} + [AddCommGroup G] [AddCommGroup H] + [TopologicalSpace G] [IsTopologicalAddGroup G] [MeasurableSpace G] [BorelSpace G] + [T2Space G] [CompactSpace G] [HasOuterApproxClosed G] [MeasurableAdd₂ G] + [TopologicalSpace H] [T2Space H] [MeasurableSpace H] [BorelSpace H] + [MeasurableSpace X] (C : G →+ H) [Fintype C.ker] + (hC : Continuous C) (hCs : Function.Surjective C) + (μ : Measure G) [μ.IsAddLeftInvariant] (ν : Measure H) [IsFiniteMeasure ν] + (hmp : MeasurePreserving C μ ν) {S : Set H} (hS : MeasurableSet S) + (ρ : Measure X) [IsFiniteMeasure ρ] (s : X → G) (hs : Measurable s) + (hbase : ρ.map (C ∘ s) = ν.restrict S) : + finiteKernelLiftLaw C ρ s = μ.restrict (C ⁻¹' S) := by + have hb : ρ.map (C ∘ s) = realDensityMeasure ν (S.indicator (fun _ => (1 : ℝ))) := by + rw [realDensityMeasure_indicator_one ν hS] + exact hbase + have he : (fun x => S.indicator (fun _ => (1 : ℝ)) (C x)) = + (C ⁻¹' S).indicator (fun _ => (1 : ℝ)) := by + funext x + by_cases hx : C x ∈ S <;> simp [hx] + rw [finiteKernelLift_density C hC hCs μ ν hmp _ (measurable_const.indicator hS) + ((integrable_const (1 : ℝ)).indicator hS) + (fun x => by by_cases hx : x ∈ S <;> simp [hx]) ρ s hs hb, + he, realDensityMeasure_indicator_one μ (hS.preimage hC.measurable)] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelSumBound.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelSumBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..00c978486c4da5ccd7c0eb34a4006c14db98aa7f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteKernelSumBound.lean @@ -0,0 +1,104 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteEqualityPatternCard + +namespace OAI + +section + +namespace Erdos3 + +variable {S I : Type*} + +def kernelFiberEmbeddingEquiv (r : Setoid S) : + {a : S → I // Setoid.ker a = r} ≃ (Quotient r ↪ I) where + toFun a := ⟨Quotient.lift a.1 a.2.symm.le, + (Setoid.lift_injective_iff_ker_eq_of_le a.2.symm.le).mpr a.2⟩ + invFun b := ⟨fun i => b (Quotient.mk'' i), by + apply Setoid.ext + intro i j + change b (Quotient.mk'' i) = b (Quotient.mk'' j) ↔ r i j + rw [b.injective.eq_iff, Quotient.eq]⟩ + left_inv a := by + apply Subtype.ext + rfl + right_inv b := by + apply Function.Embedding.ext + intro i + induction i using Quotient.inductionOn with + | h i => rfl + +theorem kernelFiberEmbeddingEquiv_apply (r : Setoid S) + (a : {a : S → I // Setoid.ker a = r}) (i : S) : + kernelFiberEmbeddingEquiv r a (Quotient.mk'' i) = a.1 i := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {S I : Type*} [Fintype S] [DecidableEq S] [Fintype I] + [DecidableEq I] [DecidableEq (Setoid S)] + +omit [DecidableEq I] in +theorem finiteKernelFiber_sum (r : Setoid S) [Fintype (Quotient r)] + (G : (S → I) → ℝ) : + (∑ a : {a : S → I // Setoid.ker a = r}, G a.1) = + ∑ b : Quotient r ↪ I, G (fun i => b (Quotient.mk'' i)) := by + exact Fintype.sum_equiv (kernelFiberEmbeddingEquiv r) _ _ (fun _ => rfl) + +omit [Fintype S] [DecidableEq S] [Fintype I] [DecidableEq I] in +theorem finiteKernel_sum_grouped (T : Finset (S → I)) (G : (S → I) → ℝ) : + (∑ a ∈ T, G a) = ∑ r ∈ T.image Setoid.ker, ∑ a ∈ T.filter (fun a => Setoid.ker a = r), G a := by + exact (Finset.sum_fiberwise_of_maps_to (fun a ha => Finset.mem_image.mpr ⟨a, ha, rfl⟩) G).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {S I : Type*} [Fintype S] [DecidableEq S] [Fintype I] + [DecidableEq I] [DecidableEq (Setoid S)] + +omit [DecidableEq I] in +theorem finiteKernel_filter_sum_le (T : Finset (S → I)) (G : (S → I) → ℝ) + (hG : ∀ a, 0 ≤ G a) (r : Setoid S) : + (∑ a ∈ T.filter (fun a => Setoid.ker a = r), G a) ≤ + ∑ a : {a : S → I // Setoid.ker a = r}, G a.1 := by + rw [← Finset.sum_subtype (Finset.univ.filter (fun a : S → I => Setoid.ker a = r)) + (fun a => by simp only [Finset.mem_filter, Finset.mem_univ, true_and]) G] + apply Finset.sum_le_sum_of_subset_of_nonneg + (Finset.filter_subset_filter _ (Finset.subset_univ T)) + intro a _ _ + exact hG a + +omit [DecidableEq I] in +theorem finiteKernel_sum_bound (T : Finset (S → I)) (G : (S → I) → ℝ) + (hG : ∀ a, 0 ≤ G a) (B : ℝ) (hB : 0 ≤ B) + (hpattern : ∀ r ∈ T.image Setoid.ker, + (∑ a : {a : S → I // Setoid.ker a = r}, G a.1) ≤ B) : + (∑ a ∈ T, G a) ≤ (Fintype.card S ^ Fintype.card S : ℕ) * B := by + rw [finiteKernel_sum_grouped] + calc + _ ≤ ∑ r ∈ T.image Setoid.ker, B := by + apply Finset.sum_le_sum + intro r hr + exact (finiteKernel_filter_sum_le T G hG r).trans (hpattern r hr) + _ = ((T.image Setoid.ker).card : ℝ) * B := by + rw [Finset.sum_const, nsmul_eq_mul] + _ ≤ (Fintype.card S ^ Fintype.card S : ℕ) * B := + mul_le_mul_of_nonneg_right (by exact_mod_cast finiteEqualityPatterns_card_le_card (T.image Setoid.ker)) hB + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteMarginalProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteMarginalProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0d7445b3ef9a45be1cd6736a13de5dc5d0fd9ff --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteMarginalProjection.lean @@ -0,0 +1,239 @@ +import OAI.Combinatorics.Progressions.Estimates.ObservedUnitTruncation +import OAI.Combinatorics.Progressions.Geometry.ProductMarginalSupport +import OAI.Combinatorics.Progressions.Probability.ProductDensityRepresentative + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem finiteWeightDensity_mean_le {Ω : Type*} [Fintype Ω] + (p : FiniteProbabilityWeights Ω) (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) : + p.mean (finiteWeightDensity p w) ≤ ∑ x, w x := by + unfold FiniteProbabilityWeights.mean + apply Finset.sum_le_sum + intro x _ + by_cases hx : p.weight x = 0 + · simpa only [hx, zero_mul] using hw x + · apply le_of_eq + unfold finiteWeightDensity + field_simp + +theorem zeroLevelGram_bound {s M η : ℝ} (hs : 0 ≤ s) (hM : 0 ≤ M) (hη : 0 ≤ η) + (hcap : s ≤ M * (1 + η)) : + s ^ 2 ≤ 2 * M * s + 2 * η * M ^ 2 * (1 + η) ^ 2 := by + by_cases he : η ≤ 1 + · have h2 : s ≤ 2 * M := by nlinarith + have hmul := mul_le_mul_of_nonneg_right h2 hs + have herr : 0 ≤ 2 * η * M ^ 2 * (1 + η) ^ 2 := by positivity + nlinarith + · have hsq := pow_le_pow_left₀ hs hcap 2 + have hfactor : 1 ≤ 2 * η := by linarith + have hscaled := mul_le_mul_of_nonneg_right hfactor (sq_nonneg (M * (1 + η))) + nlinarith [mul_nonneg hM hs] + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem finiteLaw_zero_projection (w f : (∀ i, X i) → ℝ) (hw : ∀ x, 0 ≤ w x) + {M η : ℝ} (hf : ∀ x, 0 ≤ f x ∧ f x ≤ M) (hη : 0 ≤ η) + (hclose : ∀ x, + |productFiberMass w ∅ x - productFiberMass (FiniteProbabilityWeights.pi μ).weight ∅ x| ≤ + η * productFiberMass (FiniteProbabilityWeights.pi μ).weight ∅ x) : + productANOVAEnergy μ (lowDegreeCoordinateSets I 0) + (finiteWeightDensity (FiniteProbabilityWeights.pi μ) (fun x => w x * f x)) ≤ + 2 * M * (∑ x, w x * f x) + 2 * η * M ^ 2 * (1 + η) ^ 2 := by + let p := FiniteProbabilityWeights.pi μ + let s := ∑ x, w x * f x + have hs : 0 ≤ s := Finset.sum_nonneg (fun x _ => mul_nonneg (hw x) (hf x).1) + have hM : 0 ≤ M := (p.mean_nonneg (fun x => (hf x).1)).trans + ((p.mean_mono (fun x => (hf x).2)).trans_eq (p.mean_const M)) + obtain ⟨x₀, _hx₀⟩ : ∃ x, 0 < p.weight x := by + by_contra hn + push Not at hn + have hsum : (∑ x, p.weight x) ≤ 0 := Finset.sum_nonpos (fun x _ => hn x) + rw [p.total] at hsum + norm_num at hsum + have hmass := hclose x₀ + simp only [productFiberMass_empty, (FiniteProbabilityWeights.pi μ).total, mul_one] at hmass + have hW : (∑ x, w x) ≤ 1 + η := by + have hh := (abs_le.mp hmass).2 + linarith + have hcap : s ≤ M * (1 + η) := by + calc + _ ≤ ∑ x, w x * M := Finset.sum_le_sum + (fun x _ => mul_le_mul_of_nonneg_left (hf x).2 (hw x)) + _ = (∑ x, w x) * M := (Finset.sum_mul _ _ _).symm + _ ≤ (1 + η) * M := mul_le_mul_of_nonneg_right hW hM + _ = _ := mul_comm _ _ + have hnonneg : 0 ≤ p.mean (finiteWeightDensity p (fun x => w x * f x)) := + p.mean_nonneg (finiteWeightDensity_nonneg p _ (fun x => mul_nonneg (hw x) (hf x).1)) + have hmean := finiteWeightDensity_mean_le p (fun x => w x * f x) + (fun x => mul_nonneg (hw x) (hf x).1) + rw [productANOVAEnergy_zero] + exact (pow_le_pow_left₀ hnonneg hmean 2).trans (zeroLevelGram_bound hs hM hη hcap) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem approxProduct_projection_bound (r f : (∀ i, X i) → ℝ) + (hr : ∀ x, 0 ≤ r x) {M η : ℝ} (hf : ∀ x, 0 ≤ f x ∧ f x ≤ M) (hη : 0 ≤ η) + (b : ℕ) + (hclose : ∀ S : Finset I, S.card ≤ 2 * b → ∀ x, + (FiniteProbabilityWeights.pi μ).weight x ≠ 0 → + |productConditionalMean μ S r x - 1| ≤ η) : + productANOVAEnergy μ (lowDegreeCoordinateSets I b) (fun x => r x * f x) ≤ + 2 * M * (FiniteProbabilityWeights.pi μ).mean (fun x => r x * f x) + + 2 * η * ((∑ j ∈ Finset.range (b + 1), (Fintype.card I).choose j : ℕ) : ℝ) ^ 2 * + (4 : ℝ) ^ b * M ^ 2 * (1 + η) ^ 2 := by + have h := productTruncatedGram_bound μ r f hr hf hη (lowDegreeCoordinateSets I b) + (fun S hS => (mem_lowDegreeCoordinateSets I b S).mp hS) hclose + rwa [lowDegreeCoordinateSets_card] at h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem finiteLaw_projection_positive (w f : (∀ i, X i) → ℝ) (hw : ∀ x, 0 ≤ w x) + {M η : ℝ} (hf : ∀ x, 0 ≤ f x ∧ f x ≤ M) (hη : 0 ≤ η) (b : ℕ) (hb : 0 < b) + (hclose : ∀ S : Finset I, S.card ≤ 2 * b → ∀ x, + |productFiberMass w S x - productFiberMass (FiniteProbabilityWeights.pi μ).weight S x| ≤ + η * productFiberMass (FiniteProbabilityWeights.pi μ).weight S x) : + productANOVAEnergy μ (lowDegreeCoordinateSets I b) + (finiteWeightDensity (FiniteProbabilityWeights.pi μ) (fun x => w x * f x)) ≤ + 2 * M * (∑ x, w x * f x) + + 2 * η * ((∑ j ∈ Finset.range (b + 1), (Fintype.card I).choose j : ℕ) : ℝ) ^ 2 * + (4 : ℝ) ^ b * M ^ 2 * (1 + η) ^ 2 := by + let p := FiniteProbabilityWeights.pi μ + let r := finiteWeightDensity p w + have hs : ∀ x, p.weight x = 0 → w x = 0 := + productLaw_supported_of_singleton_marginals μ w hw + (fun i => hclose {i} (by simp only [Finset.card_singleton]; omega)) + have hr : ∀ x, p.weight x * r x = w x := finiteWeightDensity_mul p w hs + have hsf : ∀ x, p.weight x = 0 → w x * f x = 0 := by + intro x hx + rw [hs x hx, zero_mul] + have he : ∀ x, p.weight x * finiteWeightDensity p (fun y => w y * f y) x = + p.weight x * (r x * f x) := by + intro x + rw [finiteWeightDensity_mul p _ hsf, ← mul_assoc, hr] + rw [productANOVAEnergy_of_weighted_eq μ _ _ he] + have h := approxProduct_projection_bound μ r f (finiteWeightDensity_nonneg p w hw) hf hη b + (fun S hS => productConditionalMean_close_of_marginal μ S r w hr (hclose S hS)) + have hmean : (FiniteProbabilityWeights.pi μ).mean (fun x => r x * f x) = ∑ x, w x * f x := + mean_finiteWeightDensity p w f hs + rw [hmean] at h + exact h + +theorem finiteLaw_projection_bound (w f : (∀ i, X i) → ℝ) (hw : ∀ x, 0 ≤ w x) + {M η : ℝ} (hf : ∀ x, 0 ≤ f x ∧ f x ≤ M) (hη : 0 ≤ η) (b : ℕ) + (hclose : ∀ S : Finset I, S.card ≤ 2 * b → ∀ x, + |productFiberMass w S x - productFiberMass (FiniteProbabilityWeights.pi μ).weight S x| ≤ + η * productFiberMass (FiniteProbabilityWeights.pi μ).weight S x) : + productANOVAEnergy μ (lowDegreeCoordinateSets I b) + (finiteWeightDensity (FiniteProbabilityWeights.pi μ) (fun x => w x * f x)) ≤ + 2 * M * (∑ x, w x * f x) + + 2 * η * ((∑ j ∈ Finset.range (b + 1), (Fintype.card I).choose j : ℕ) : ℝ) ^ 2 * + (4 : ℝ) ^ b * M ^ 2 * (1 + η) ^ 2 := by + rcases Nat.eq_zero_or_pos b with hb | hb + · subst b + simpa using finiteLaw_zero_projection μ w f hw hf hη (hclose ∅ (by simp)) + · exact finiteLaw_projection_positive μ w f hw hf hη b hb hclose + +theorem finiteLaw_projection_of_density (w f h : (∀ i, X i) → ℝ) (hw : ∀ x, 0 ≤ w x) + {M η : ℝ} (hf : ∀ x, 0 ≤ f x ∧ f x ≤ M) (hη : 0 ≤ η) (b : ℕ) + (hdensity : ∀ x, (FiniteProbabilityWeights.pi μ).weight x * h x = w x * f x) + (hclose : ∀ S : Finset I, S.card ≤ 2 * b → ∀ x, + |productFiberMass w S x - productFiberMass (FiniteProbabilityWeights.pi μ).weight S x| ≤ + η * productFiberMass (FiniteProbabilityWeights.pi μ).weight S x) : + productANOVAEnergy μ (lowDegreeCoordinateSets I b) h ≤ + 2 * M * (∑ x, w x * f x) + + 2 * η * ((∑ j ∈ Finset.range (b + 1), (Fintype.card I).choose j : ℕ) : ℝ) ^ 2 * + (4 : ℝ) ^ b * M ^ 2 * (1 + η) ^ 2 := by + let p := FiniteProbabilityWeights.pi μ + have hs : ∀ x, p.weight x = 0 → w x * f x = 0 := by + intro x hx + have h := hdensity x + rw [hx, zero_mul] at h + exact h.symm + have he : ∀ x, p.weight x * h x = p.weight x * finiteWeightDensity p (fun y => w y * f y) x := by + intro x + calc + _ = w x * f x := hdensity x + _ = _ := (finiteWeightDensity_mul p _ hs x).symm + rw [productANOVAEnergy_of_weighted_eq μ _ _ he] + exact finiteLaw_projection_bound μ w f hw hf hη b hclose + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem marginal_mass_error_of_density {a b η : ℝ} (hb : 0 ≤ b) + (hzero : b = 0 → a = 0) (hclose : 0 < b → |a / b - 1| ≤ η) : + |a - b| ≤ η * b := by + by_cases hz : b = 0 + · rw [hz, hzero hz] + simp + · have hp : 0 < b := lt_of_le_of_ne hb (Ne.symm hz) + have h := hclose hp + have he : a / b - 1 = (a - b) / b := by field_simp + rw [he, abs_div, abs_of_pos hp] at h + exact (div_le_iff₀ hp).mp h + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem finiteProbability_truncated_projection + (ν : FiniteProbabilityWeights (∀ i, X i)) (f h : (∀ i, X i) → ℝ) + {M η : ℝ} (hf : ∀ x, 0 ≤ f x ∧ f x ≤ M) (hη : 0 ≤ η) (b : ℕ) + (hdensity : ∀ x, (FiniteProbabilityWeights.pi μ).weight x * h x = ν.weight x * f x) + (hzero : ∀ S : Finset I, S.card ≤ 2 * b → ∀ x, + productFiberMass (FiniteProbabilityWeights.pi μ).weight S x = 0 → + productFiberMass ν.weight S x = 0) + (hclose : ∀ S : Finset I, S.card ≤ 2 * b → ∀ x, + 0 < productFiberMass (FiniteProbabilityWeights.pi μ).weight S x → + |productFiberMass ν.weight S x / + productFiberMass (FiniteProbabilityWeights.pi μ).weight S x - 1| ≤ η) : + productANOVAEnergy μ (lowDegreeCoordinateSets I b) h ≤ + 2 * M * ν.mean f + + 2 * η * ((∑ j ∈ Finset.range (b + 1), (Fintype.card I).choose j : ℕ) : ℝ) ^ 2 * + (4 : ℝ) ^ b * M ^ 2 * (1 + η) ^ 2 := by + have h := finiteLaw_projection_of_density μ ν.weight f h ν.nonneg hf hη b hdensity + (fun S hS x => marginal_mass_error_of_density + (productFiberMass_nonneg _ (FiniteProbabilityWeights.pi μ).nonneg S x) + (hzero S hS x) (hclose S hS x)) + simpa only [FiniteProbabilityWeights.mean] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteNormalizedFrame.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteNormalizedFrame.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f5371b9b0355990aff46d22778bc24a3df3c803 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteNormalizedFrame.lean @@ -0,0 +1,83 @@ +import Mathlib.Analysis.InnerProductSpace.PiL2 +import OAI.Combinatorics.Progressions.Estimates.NormalizedVectorLipschitz + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +theorem euclidean_norm_le_card_add_one_mul {I : Type*} [Fintype I] + (v : EuclideanSpace ℂ I) {M : ℝ} (hM : 0 ≤ M) (hv : ∀ i, ‖v i‖ ≤ M) : + ‖v‖ ≤ (Fintype.card I + 1 : ℝ) * M := by + have hsq : ‖v‖ ^ 2 ≤ (Fintype.card I : ℝ) * M ^ 2 := by + rw [EuclideanSpace.norm_sq_eq] + have h := Finset.sum_le_sum (s := Finset.univ) + (fun i _ => pow_le_pow_left₀ (norm_nonneg _) (hv i) 2) + simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using h + have hcard : (Fintype.card I : ℝ) ≤ (Fintype.card I + 1 : ℝ) ^ 2 := by + nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card I)] + have hbound := mul_le_mul_of_nonneg_right hcard (sq_nonneg M) + nlinarith [norm_nonneg v, mul_nonneg (by positivity : (0 : ℝ) ≤ Fintype.card I + 1) hM] + +theorem lipschitzWith_complex_vector {I X : Type*} [Fintype I] [PseudoMetricSpace X] + (u : I → X → ℂ) {K : ℝ≥0} (hu : ∀ i, LipschitzWith K (u i)) : + LipschitzWith ((Fintype.card I + 1 : ℝ≥0) * K) + (fun x => (WithLp.toLp 2 (fun i => u i x) : EuclideanSpace ℂ I)) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [dist_eq_norm] + have h := euclidean_norm_le_card_add_one_mul + ((WithLp.toLp 2 (fun i => u i x) : EuclideanSpace ℂ I) - WithLp.toLp 2 (fun i => u i y)) + (M := (K : ℝ) * dist x y) (by positivity) (fun i => by + simpa only [PiLp.sub_apply, PiLp.toLp_apply, dist_eq_norm] using (hu i).dist_le_mul x y) + simpa only [NNReal.coe_mul, NNReal.coe_add, NNReal.coe_natCast, NNReal.coe_one, mul_assoc] using h + +theorem normalize_complex_unit_smul {I : Type*} [Fintype I] + (c : ℂ) (hc : ‖c‖ = 1) (v : EuclideanSpace ℂ I) : + NormedSpace.normalize (c • v) = c • NormedSpace.normalize v := by + unfold NormedSpace.normalize + rw [norm_smul, hc, one_mul] + exact smul_comm _ _ _ + +theorem exists_normalized_complex_family {I X : Type*} [Fintype I] [PseudoMetricSpace X] + (u : I → X → ℂ) {rho K : ℝ≥0} (hrho : 0 < rho) + (hLip : ∀ i, LipschitzWith K (u i)) (hlower : ∀ x, ∃ i, (rho : ℝ) ≤ ‖u i x‖) : + ∃ v : I → X → ℂ, + (∀ x, ∑ i, ‖v i x‖ ^ 2 = 1) ∧ + (∀ i x, ‖v i x‖ ≤ 1) ∧ + (∀ i, LipschitzWith (2 / rho * ((Fintype.card I + 1 : ℝ≥0) * K)) (v i)) ∧ + ∀ x y c, ‖c‖ = 1 → (∀ i, u i x = c * u i y) → ∀ i, v i x = c * v i y := by + let U (x : X) : EuclideanSpace ℂ I := WithLp.toLp 2 (fun i => u i x) + have hnorm (x : X) : (rho : ℝ) ≤ ‖U x‖ := by + obtain ⟨i, hi⟩ := hlower x + exact hi.trans (PiLp.norm_apply_le (U x) i) + have hne (x : X) : U x ≠ 0 := norm_pos_iff.mp (lt_of_lt_of_le hrho (hnorm x)) + have hone (x : X) : ‖NormedSpace.normalize (U x)‖ = 1 := NormedSpace.norm_normalize (hne x) + let v (i : I) (x : X) := NormedSpace.normalize (U x) i + have hvLip := lipschitzWith_normalize U hrho (lipschitzWith_complex_vector u hLip) hnorm + refine ⟨v, ?_, ?_, ?_, ?_⟩ + · intro x + rw [← EuclideanSpace.norm_sq_eq, hone, one_pow] + · intro i x + exact (PiLp.norm_apply_le (NormedSpace.normalize (U x)) i).trans_eq (hone x) + · intro i + apply LipschitzWith.of_dist_le_mul + intro x y + exact (PiLp.dist_apply_le (NormedSpace.normalize (U x)) (NormedSpace.normalize (U y)) i).trans + (hvLip.dist_le_mul x y) + · intro x y c hc hu i + have heq : U x = c • U y := by + ext j + exact hu j + change NormedSpace.normalize (U x) i = c * NormedSpace.normalize (U y) i + rw [heq, normalize_complex_unit_smul c hc] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteRankTriangularFinset.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteRankTriangularFinset.lean new file mode 100644 index 0000000000000000000000000000000000000000..e50e9c026023134a2de80a7d2216729766e32b31 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteRankTriangularFinset.lean @@ -0,0 +1,213 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteTriangularRationalCorrection +import OAI.Combinatorics.Progressions.Linear.FiniteDescendingRankOrder + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def finiteRankCorrectionSolutions {I : Type*} [Fintype I] + (A : Matrix I I ℝ) (c : I → ℝ) (B : ℝ) (q : ℕ) : + Set ((I → ℝ) × (I → ℚ)) := + {sr | (∀ i, |sr.1 i| ≤ B) ∧ + (∀ i, ∃ z : ℤ, sr.2 i = (z : ℚ) / q) ∧ + ∀ i, c i = ∑ j, A i j * sr.1 j + (sr.2 i : ℝ)} + +theorem finiteRankCorrectionSolutions_reindex + {I J : Type*} [Fintype I] [Fintype J] (e : J ≃ I) + (A : Matrix I I ℝ) (c : I → ℝ) (B : ℝ) (q : ℕ) + (sr : (I → ℝ) × (I → ℚ)) : + sr ∈ finiteRankCorrectionSolutions A c B q ↔ + ((fun i => sr.1 (e i)), (fun i => sr.2 (e i))) ∈ + finiteRankCorrectionSolutions (fun i j => A (e i) (e j)) (fun i => c (e i)) B q := by + constructor + · intro hs + refine ⟨fun i => hs.1 (e i), fun i => hs.2.1 (e i), ?_⟩ + intro i + dsimp only + have hsum : (∑ j, A (e i) (e j) * sr.1 (e j)) = + ∑ j : I, A (e i) j * sr.1 j := e.sum_comp (fun j : I => A (e i) j * sr.1 j) + rw [hsum] + exact hs.2.2 (e i) + · intro hs + refine ⟨?_, ?_, ?_⟩ + · intro i + simpa only [e.apply_symm_apply] using hs.1 (e.symm i) + · intro i + simpa only [e.apply_symm_apply] using hs.2.1 (e.symm i) + · intro i + have hi := hs.2.2 (e.symm i) + dsimp only at hi + have hsum : (∑ j, A i (e j) * sr.1 (e j)) = + ∑ j : I, A i j * sr.1 j := e.sum_comp (fun j : I => A i j * sr.1 j) + simpa only [e.apply_symm_apply, hsum] using hi + +theorem exists_rank_triangular_equiv {I : Type*} [Fintype I] + (rank : I → ℕ) (A : Matrix I I ℝ) + (htri : ∀ i j, rank j ≤ rank i → j ≠ i → A i j = 0) : + ∃ e : Fin (Fintype.card I) ≃ I, + (∀ i j, i ≤ j → rank (e j) ≤ rank (e i)) ∧ + ∀ i j, i < j → A (e i) (e j) = 0 := by + obtain ⟨e, he⟩ := exists_finite_descending_rank_equiv rank + refine ⟨e, he, ?_⟩ + intro i j hij + exact htri (e i) (e j) (he i j hij.le) + (fun h => hij.ne (e.injective h).symm) + +theorem exists_finite_rank_triangular_correction_enumeration + {I : Type*} [Fintype I] (q : ℕ) (hq : 0 < q) (B : ℝ) (hB : 0 ≤ B) + (rank : I → ℕ) (A : Matrix I I ℝ) (c : I → ℝ) + (htri : ∀ i j, rank j ≤ rank i → j ≠ i → A i j = 0) + (hdiag : ∀ i, A i i ≠ 0) (hdiagBound : ∀ i, |A i i| ≤ 1) : + ∃ m : ℕ, m ≤ (2 * ⌈(q : ℝ) * B⌉₊ + 3) ^ Fintype.card I ∧ + ∃ candidate : Fin m → ((I → ℝ) × (I → ℚ)), + (∀ j, candidate j ∈ finiteRankCorrectionSolutions A c B q) ∧ + ∀ sr, sr ∈ finiteRankCorrectionSolutions A c B q → ∃ j, candidate j = sr := by + obtain ⟨e, _, he⟩ := exists_rank_triangular_equiv rank A htri + let A' : Matrix (Fin (Fintype.card I)) (Fin (Fintype.card I)) ℝ := + fun i j => A (e i) (e j) + let c' : Fin (Fintype.card I) → ℝ := fun i => c (e i) + obtain ⟨m, hm, candidate, hmem, hcover⟩ := + exists_triangular_rational_correction_enumeration q hq B hB (Fintype.card I) A' c' + he (fun i => hdiag (e i)) (fun i => hdiagBound (e i)) + let candidate' : Fin m → ((I → ℝ) × (I → ℚ)) := + fun j => (fun i => (candidate j).1 (e.symm i), fun i => (candidate j).2 (e.symm i)) + refine ⟨m, hm, candidate', ?_, ?_⟩ + · intro j + apply (finiteRankCorrectionSolutions_reindex e A c B q (candidate' j)).mpr + simpa only [candidate', e.symm_apply_apply, finiteRankCorrectionSolutions, + triangularCorrectionSolutions, A', c'] using hmem j + · intro sr hsr + have hsr' := (finiteRankCorrectionSolutions_reindex e A c B q sr).mp hsr + obtain ⟨j, hj⟩ := hcover (fun i => sr.1 (e i), fun i => sr.2 (e i)) hsr' + refine ⟨j, ?_⟩ + dsimp only [candidate'] + rw [hj] + simp only [e.apply_symm_apply] + +theorem exists_finite_rank_triangular_correction_enumeration_exp + {I : Type*} [Fintype I] (q : ℕ) (hq : 0 < q) {B p : ℝ} + (hp : 0 ≤ p) (hB : 0 ≤ B) (hI : (Fintype.card I : ℝ) ≤ p) + (hqCap : (q : ℝ) ≤ Real.exp p) (hBCap : B ≤ Real.exp p) + (rank : I → ℕ) (A : Matrix I I ℝ) (c : I → ℝ) + (htri : ∀ i j, rank j ≤ rank i → j ≠ i → A i j = 0) + (hdiag : ∀ i, A i i ≠ 0) (hdiagBound : ∀ i, |A i i| ≤ 1) : + ∃ m : ℕ, (m : ℝ) ≤ Real.exp ((p + 3) ^ 3) ∧ + ∃ candidate : Fin m → ((I → ℝ) × (I → ℚ)), + (∀ j, candidate j ∈ finiteRankCorrectionSolutions A c B q) ∧ + ∀ sr, sr ∈ finiteRankCorrectionSolutions A c B q → ∃ j, candidate j = sr := by + obtain ⟨m, hm, candidate, hmem, hcover⟩ := + exists_finite_rank_triangular_correction_enumeration q hq B hB rank A c htri hdiag hdiagBound + exact ⟨m, (Nat.cast_le.mpr hm).trans + (real_grid_window_count_le_exp (Fintype.card I) q hp hB hI hqCap hBCap), + candidate, hmem, hcover⟩ + +theorem exists_uniform_finite_rank_triangular_correction_enumeration (a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {I : Type*} [Fintype I] (q : ℕ), 0 < q → + ∀ (B p : ℝ), 0 ≤ p → 0 ≤ B → (Fintype.card I : ℝ) ≤ p → + (q : ℝ) ≤ Real.exp ((p + a) ^ a) → B ≤ Real.exp ((p + a) ^ a) → + ∀ (rank : I → ℕ) (A : Matrix I I ℝ) (c : I → ℝ), + (∀ i j, rank j ≤ rank i → j ≠ i → A i j = 0) → + (∀ i, A i i ≠ 0) → (∀ i, |A i i| ≤ 1) → + ∃ m : ℕ, (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ candidate : Fin m → ((I → ℝ) × (I → ℚ)), + (∀ j, candidate j ∈ finiteRankCorrectionSolutions A c B q) ∧ + ∀ sr, sr ∈ finiteRankCorrectionSolutions A c B q → ∃ j, candidate j = sr := by + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((Polynomial.X + (Polynomial.X + Polynomial.C a) ^ a + 3) ^ 3) + refine ⟨C, hC, ?_⟩ + intro I _ q hq B p hp hB hI hqCap hBCap rank A c htri hdiag hdiagBound + let p' := p + (p + a) ^ a + have hp' : 0 ≤ p' := by dsimp [p']; positivity + have hpp : p ≤ p' := le_add_of_nonneg_right (by positivity) + have hap : (p + a) ^ a ≤ p' := le_add_of_nonneg_left hp + obtain ⟨m, hm, candidate, hmem, hcover⟩ := + exists_finite_rank_triangular_correction_enumeration_exp q hq hp' hB (hI.trans hpp) + (hqCap.trans (Real.exp_le_exp.mpr hap)) (hBCap.trans (Real.exp_le_exp.mpr hap)) + rank A c htri hdiag hdiagBound + refine ⟨m, hm.trans (Real.exp_le_exp.mpr ?_), candidate, hmem, hcover⟩ + simpa [p', Polynomial.eval₂_pow] using hbudget p hp + +end Erdos3 + +end + +section + +namespace Erdos3 + +private theorem correction_finset_of_enumeration + {I : Type*} [Fintype I] {A : Matrix I I ℝ} {c : I → ℝ} {B : ℝ} {q m : ℕ} + (candidate : Fin m → ((I → ℝ) × (I → ℚ))) + (hmem : ∀ j, candidate j ∈ finiteRankCorrectionSolutions A c B q) + (hcover : ∀ sr, sr ∈ finiteRankCorrectionSolutions A c B q → + ∃ j, candidate j = sr) : + ∃ H : Finset ((I → ℝ) × (I → ℚ)), H.card ≤ m ∧ + ∀ sr, sr ∈ H ↔ sr ∈ finiteRankCorrectionSolutions A c B q := by + classical + refine ⟨Finset.univ.image candidate, ?_, ?_⟩ + · exact (Finset.card_image_le).trans (by simp) + · intro sr + constructor + · intro hs + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hs + exact hmem j + · intro hs + obtain ⟨j, hj⟩ := hcover sr hs + exact Finset.mem_image.mpr ⟨j, Finset.mem_univ _, hj⟩ + +theorem exists_finite_rank_triangular_correction_finset + {I : Type*} [Fintype I] (q : ℕ) (hq : 0 < q) (B : ℝ) (hB : 0 ≤ B) + (rank : I → ℕ) (A : Matrix I I ℝ) (c : I → ℝ) + (htri : ∀ i j, rank j ≤ rank i → j ≠ i → A i j = 0) + (hdiag : ∀ i, A i i ≠ 0) (hdiagBound : ∀ i, |A i i| ≤ 1) : + ∃ H : Finset ((I → ℝ) × (I → ℚ)), + H.card ≤ (2 * ⌈(q : ℝ) * B⌉₊ + 3) ^ Fintype.card I ∧ + ∀ sr, sr ∈ H ↔ sr ∈ finiteRankCorrectionSolutions A c B q := by + obtain ⟨m, hm, candidate, hmem, hcover⟩ := + exists_finite_rank_triangular_correction_enumeration q hq B hB rank A c htri hdiag hdiagBound + obtain ⟨H, hH, heq⟩ := correction_finset_of_enumeration candidate hmem hcover + exact ⟨H, hH.trans hm, heq⟩ + +theorem exists_finite_rank_triangular_correction_finset_exp + {I : Type*} [Fintype I] (q : ℕ) (hq : 0 < q) {B p : ℝ} + (hp : 0 ≤ p) (hB : 0 ≤ B) (hI : (Fintype.card I : ℝ) ≤ p) + (hqCap : (q : ℝ) ≤ Real.exp p) (hBCap : B ≤ Real.exp p) + (rank : I → ℕ) (A : Matrix I I ℝ) (c : I → ℝ) + (htri : ∀ i j, rank j ≤ rank i → j ≠ i → A i j = 0) + (hdiag : ∀ i, A i i ≠ 0) (hdiagBound : ∀ i, |A i i| ≤ 1) : + ∃ H : Finset ((I → ℝ) × (I → ℚ)), + (H.card : ℝ) ≤ Real.exp ((p + 3) ^ 3) ∧ + ∀ sr, sr ∈ H ↔ sr ∈ finiteRankCorrectionSolutions A c B q := by + obtain ⟨m, hm, candidate, hmem, hcover⟩ := + exists_finite_rank_triangular_correction_enumeration_exp q hq hp hB hI hqCap hBCap + rank A c htri hdiag hdiagBound + obtain ⟨H, hH, heq⟩ := correction_finset_of_enumeration candidate hmem hcover + exact ⟨H, (Nat.cast_le.mpr hH).trans hm, heq⟩ + +theorem exists_uniform_finite_rank_triangular_correction_finset (a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {I : Type*} [Fintype I] (q : ℕ), 0 < q → + ∀ (B p : ℝ), 0 ≤ p → 0 ≤ B → (Fintype.card I : ℝ) ≤ p → + (q : ℝ) ≤ Real.exp ((p + a) ^ a) → B ≤ Real.exp ((p + a) ^ a) → + ∀ (rank : I → ℕ) (A : Matrix I I ℝ) (c : I → ℝ), + (∀ i j, rank j ≤ rank i → j ≠ i → A i j = 0) → + (∀ i, A i i ≠ 0) → (∀ i, |A i i| ≤ 1) → + ∃ H : Finset ((I → ℝ) × (I → ℚ)), + (H.card : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∀ sr, sr ∈ H ↔ sr ∈ finiteRankCorrectionSolutions A c B q := by + obtain ⟨C, hC, h⟩ := exists_uniform_finite_rank_triangular_correction_enumeration a + refine ⟨C, hC, ?_⟩ + intro I _ q hq B p hp hB hI hqCap hBCap rank A c htri hdiag hdiagBound + obtain ⟨m, hm, candidate, hmem, hcover⟩ := + h q hq B p hp hB hI hqCap hBCap rank A c htri hdiag hdiagBound + obtain ⟨H, hH, heq⟩ := correction_finset_of_enumeration candidate hmem hcover + exact ⟨H, (Nat.cast_le.mpr hH).trans hm, heq⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteSpanRounding.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteSpanRounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..66ac15ad7fca1c91086b1009dce74c78338859c5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteSpanRounding.lean @@ -0,0 +1,52 @@ +import Mathlib.Algebra.Order.Floor.Ring +import Mathlib.LinearAlgebra.Finsupp.LinearCombination +import Mathlib.Tactic +import Mathlib.Topology.Algebra.Module.Basic +import Mathlib.Topology.Compactness.Compact +import Mathlib.Topology.Instances.Real.Lemmas + +namespace OAI + +section + +namespace Erdos3 + +variable {ι V : Type*} [Fintype ι] [AddCommGroup V] [Module ℝ V] + +def boundedSpanCell (v : ι → V) (c : ℝ) : Set V := + (fun t : ι → ℝ => ∑ i, t i • v i) '' Set.univ.pi (fun _ => Set.Icc 0 c) + +theorem boundedSpanCell_subset_span (v : ι → V) (c : ℝ) : + boundedSpanCell v c ⊆ Submodule.span ℝ (Set.range v) := by + rintro _ ⟨t, _, rfl⟩ + exact Submodule.sum_mem _ (fun i _ => Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, rfl⟩)) + +theorem exists_bounded_span_remainder (v : ι → V) (c : ℝ) (hc : 0 < c) + (x : V) (hx : x ∈ Submodule.span ℝ (Set.range v)) : + ∃ r ∈ boundedSpanCell v c, ∃ z : ι → ℤ, x = r + ∑ i, ((z i : ℝ) * c) • v i := by + classical + obtain ⟨t, rfl⟩ := (Submodule.mem_span_range_iff_exists_fun ℝ).mp hx + let z : ι → ℤ := fun i => ⌊t i / c⌋ + let u : ι → ℝ := fun i => t i - (z i : ℝ) * c + refine ⟨∑ i, u i • v i, ⟨u, ?_, rfl⟩, z, ?_⟩ + · intro i _ + exact ⟨Int.sub_floor_div_mul_nonneg (t i) hc, (Int.sub_floor_div_mul_lt (t i) hc).le⟩ + · rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i _ + rw [← add_smul] + congr 1 + dsimp [u] + ring + +variable [TopologicalSpace V] [IsTopologicalAddGroup V] [ContinuousSMul ℝ V] + +theorem isCompact_boundedSpanCell (v : ι → V) (c : ℝ) : IsCompact (boundedSpanCell v c) := by + apply (isCompact_univ_pi (fun _ : ι => isCompact_Icc)).image + exact continuous_finsetSum _ (fun i _ => (continuous_apply i).smul continuous_const) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FiniteSpanSum.lean b/lean/OAI/Combinatorics/Progressions/Linear/FiniteSpanSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..612cddc3b62321f1d06bc8ead5dab72ee5d68460 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FiniteSpanSum.lean @@ -0,0 +1,42 @@ +import Mathlib.Algebra.BigOperators.Group.List.Basic +import Mathlib.LinearAlgebra.Span.Basic + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_list_sum_of_mem_span {R V : Type*} [Semiring R] + [AddCommMonoid V] [Module R V] (S : Set V) + (hsmul : ∀ r : R, ∀ x ∈ S, r • x ∈ S) {v : V} (hv : v ∈ Submodule.span R S) : + ∃ xs : List V, (∀ x ∈ xs, x ∈ S) ∧ xs.sum = v := by + induction hv using Submodule.span_induction with + | mem x hx => exact ⟨[x], by simpa using hx, by simp⟩ + | zero => exact ⟨[], by simp, by simp⟩ + | add x y _ _ hx hy => + obtain ⟨xs, hxs, ex⟩ := hx + obtain ⟨ys, hys, ey⟩ := hy + refine ⟨xs ++ ys, ?_, ?_⟩ + · intro z hz + rcases List.mem_append.mp hz with hz | hz + · exact hxs z hz + · exact hys z hz + · simp only [List.sum_append, ex, ey] + | smul r x _ hx => + obtain ⟨xs, hxs, ex⟩ := hx + refine ⟨xs.map (fun y => r • y), ?_, ?_⟩ + · intro z hz + obtain ⟨y, hy, rfl⟩ := List.mem_map.mp hz + exact hsmul r y (hxs y hy) + · rw [← ex] + clear hxs ex + induction xs with + | nil => simp + | cons y ys ih => simp only [List.map_cons, List.sum_cons, ih, smul_add] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedAdaptedSymbolFactorizationBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedAdaptedSymbolFactorizationBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1635749f4bce4e59c403b97dbfd622a31aaa05c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedAdaptedSymbolFactorizationBasis.lean @@ -0,0 +1,404 @@ +import OAI.Combinatorics.Progressions.Estimates.UnnormalizedCommonSymbolFactorization +import OAI.Combinatorics.Progressions.Nilpotent.NiltestVerticalBounds + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem rational_basis_coordinates_logHeight + {ι κ V : Type*} [Fintype ι] [AddCommGroup V] [Module ℚ V] + (b : Basis ι ℚ V) (c : Basis κ ℚ V) {H : ℕ} {p : ℝ} + (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) + (hentries : ∀ i j, RationalHeightLE (c.repr (b i) j) H) + (x : V) (hx : ∀ i, rationalLogHeight (b.repr x i) ≤ p) (j : κ) : + rationalLogHeight (c.repr x j) ≤ (p + 2) ^ 4 := by + classical + let K := ⌈Real.exp p⌉₊ + have hK : (K : ℝ) ≤ Real.exp (p + 1) := ceil_exp_le_exp_add_one hp + have hKH : ((K * H : ℕ) : ℝ) ≤ Real.exp ((p + 2) ^ 2) := by + rw [Nat.cast_mul] + calc + _ ≤ Real.exp (p + 1) * Real.exp p := + mul_le_mul hK hH (Nat.cast_nonneg H) (Real.exp_nonneg _) + _ = Real.exp (2 * p + 1) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith [sq_nonneg p]) + have hcoord := linearMap_coordinate_height b c (LinearMap.id : V →ₗ[ℚ] V) + hentries x (fun i => rationalHeightLE_ceil_exp (hx i)) j + have hcost := rational_sum_cost_le_exp (Fintype.card ι) (K * H) hp 2 1 hKH + (by simpa only [pow_one] using hι.trans (show p ≤ p + 2 by linarith)) + exact rationalLogHeight_le_of_height hcoord hcost + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial + +variable {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hC : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) (w : σ → ℕ) + +theorem gradedSymbolPolynomial_basis_independent : + F.gradedSymbolPolynomial c ν hC w = F.gradedSymbolPolynomial b ω hF w := by + apply LinearMap.ext + intro x + obtain ⟨p, rfl⟩ := F.polynomialSymbolMap_surjective w x + apply coefficients.injective + ext α + rw [F.gradedSymbolPolynomial_coefficient_symbol, F.gradedSymbolPolynomial_coefficient_symbol] + +theorem symbolPointwiseSubalgebra_basis_independent (W : LieSubalgebra ℚ F.AssociatedGraded) : + F.symbolPointwiseSubalgebra c ν hC w W = F.symbolPointwiseSubalgebra b ω hF w W := by + ext x + simp only [F.mem_symbolPointwiseSubalgebra_iff, + F.gradedSymbolPolynomial_basis_independent b ω hF c ν hC w] + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial + +variable {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hC : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + +theorem polynomialSymbolBasis_change_coordinate [DecidableEq σ] (w : σ → ℕ) + (i : SymbolBasisIndex w ω) (j : SymbolBasisIndex w ν) : + (F.polynomialSymbolBasis c ν hC w).repr (F.polynomialSymbolBasis b ω hF w i) j = + if i.val.1 = j.val.1 then c.repr (b i.val.2) j.val.2 else 0 := by + classical + rw [F.polynomialSymbolBasis_apply, F.polynomialSymbolBasis_repr_map, + F.adaptedMonomialBasis_coe, coefficients_monomial] + by_cases hij : i.val.1 = j.val.1 + · simp only [hij, Finsupp.single_eq_same, ite_true] + · simp only [Finsupp.single_eq_of_ne (Ne.symm hij), map_zero, Finsupp.zero_apply, ite_eq_right hij] + +theorem associatedGradedBasis_change_coordinate (i : ι) (j : κ) : + (F.associatedGradedBasis c ν hC).repr (F.associatedGradedBasis b ω hF i) j = + if ω i = ν j then c.repr (b i) j else 0 := by + classical + rw [F.associatedGradedBasis_repr, F.associatedGradedBasis_apply, + F.polynomialSymbolBasis_change_coordinate] + simp only [unitMonomial_injective.eq_iff] + +theorem associatedGradedBasis_projection (k : ℕ) (i : ι) : + basisGradeProjection (F.associatedGradedBasis c ν hC) ν k (F.associatedGradedBasis b ω hF i) = + if ω i = k then F.associatedGradedBasis b ω hF i else 0 := by + classical + by_cases hik : ω i = k + · rw [ite_eq_left hik] + apply (F.associatedGradedBasis c ν hC).repr.injective + ext j + simp only [basisGradeProjection_repr, F.associatedGradedBasis_change_coordinate] + by_cases hj : ν j = k + · rw [ite_eq_left hj] + · rw [ite_eq_right hj, ite_eq_right (show ω i ≠ ν j by omega)] + · rw [ite_eq_right hik] + apply (F.associatedGradedBasis c ν hC).repr.injective + ext j + simp only [basisGradeProjection_repr, F.associatedGradedBasis_change_coordinate, + map_zero, Finsupp.zero_apply] + by_cases hj : ν j = k + · rw [ite_eq_left hj, ite_eq_right (show ω i ≠ ν j by omega)] + · rw [ite_eq_right hj] + +theorem associatedGraded_projection_basis_independent (k : ℕ) : + basisGradeProjection (F.associatedGradedBasis c ν hC) ν k = + basisGradeProjection (F.associatedGradedBasis b ω hF) ω k := by + apply (F.associatedGradedBasis b ω hF).ext + intro i + rw [F.associatedGradedBasis_projection b ω hF c ν hC, + F.associatedGradedBasis_projection b ω hF b ω hF] + +theorem associatedGraded_submodule_basis_independent (U : Submodule ℚ F.AssociatedGraded) : + BasisGradedSubmodule (F.associatedGradedBasis c ν hC) ν U ↔ + BasisGradedSubmodule (F.associatedGradedBasis b ω hF) ω U := by + simp only [BasisGradedSubmodule, F.associatedGraded_projection_basis_independent b ω hF c ν hC] + +theorem gradedFrequency_top_basis_independent (η : L →ₗ[ℚ] ℚ) (x : F.AssociatedGraded) + (hx : basisGradeProjection (F.associatedGradedBasis b ω hF) ω s x = x) : + F.gradedFrequency c ν hC η x = F.gradedFrequency b ω hF η x := by + have hm : x ∈ LinearMap.range (F.associatedGradedPieceMap s) := by + rw [F.associatedGradedPieceMap_range b ω hF] + rw [← hx] + exact basisCoordinateProjection_mem_span (F.associatedGradedBasis b ω hF) {i | ω i = s} x + obtain ⟨v, hv⟩ := hm + rw [← hv, F.gradedFrequency_top_piece c ν hC, F.gradedFrequency_top_piece b ω hF] + +theorem polynomialSymbolBasis_change_height (w : σ → ℕ) {H : ℕ} (hH : 1 ≤ H) + (hb : ∀ i j, RationalHeightLE (c.repr (b i) j) H) + (i : SymbolBasisIndex w ω) (j : SymbolBasisIndex w ν) : + RationalHeightLE ((F.polynomialSymbolBasis c ν hC w).repr + (F.polynomialSymbolBasis b ω hF w i) j) H := by + classical + rw [F.polynomialSymbolBasis_change_coordinate] + split_ifs + · exact hb i.val.2 j.val.2 + · exact rationalHeightLE_zero hH + +theorem associatedGradedBasis_change_height {H : ℕ} (hH : 1 ≤ H) + (hb : ∀ i j, RationalHeightLE (c.repr (b i) j) H) (i : ι) (j : κ) : + RationalHeightLE ((F.associatedGradedBasis c ν hC).repr + (F.associatedGradedBasis b ω hF i) j) H := by + classical + rw [F.associatedGradedBasis_change_coordinate] + split_ifs + · exact hb i j + · exact rationalHeightLE_zero hH + +theorem native_symbol_basis_independent (w : σ → ℕ) (g : F.RealAdaptedPolynomialGroup w) : + F.realPolynomialSymbolHom c ν hC w (F.realAdaptedPolynomialGroupHom w g) = + F.realPolynomialSymbolHom b ω hF w (F.realAdaptedPolynomialGroupHom w g) := by + apply NilpotentLieBCHGroup.ext + rw [F.realPolynomialSymbolHom_groupHom_coord, F.realPolynomialSymbolHom_groupHom_coord] + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped Matrix NNReal + +def ControlledSymbolBasisChangeSpec (s C : ℕ) : Prop := + ∀ {σ ι κ L : Type*} [Fintype σ] [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hC : ∀ j, F.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + (H : ℕ) (p : ℝ) (_hH : 1 ≤ H) (_hp : 0 ≤ p) + (_hι : (Fintype.card ι : ℝ) ≤ p) (_hκ : (Fintype.card κ : ℝ) ≤ p) + (_hσ : (Fintype.card σ : ℝ) ≤ p) (_hHp : (H : ℝ) ≤ Real.exp p) + (_hb : ∀ i j, RationalHeightLE (c.repr (b i) j) H) + (T : σ → ℝ) (_hT : ∀ i, 0 < T i) (η : L →ₗ[ℚ] ℚ) + (X : F.RealPolynomialSymbolGroup (fun _ : σ => 1)), + F.ControlledSymbolFactorization b ω hF η T X p → + F.ControlledSymbolFactorization c ν hC η T X ((p + C) ^ C) + +theorem exists_controlled_symbol_basis_change (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ControlledSymbolBasisChangeSpec s C := by + let Q : Polynomial ℕ := (Polynomial.X + Polynomial.C (s + 2)) ^ (s + 2) + let P : Polynomial ℕ := (Q + 2) ^ 3 + Polynomial.X + (Polynomial.X + 2) ^ 4 + obtain ⟨C, hC, hfinal⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ ι κ L _ _ _ _ _ F b ω hF c ν hc H p hH hp hι hκ hσ hHp hb T hT η X hX + classical + let w := fun _ : σ => 1 + let q : ℝ := (p + (s + 2 : ℕ)) ^ (s + 2) + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + apply (show p ≤ p + (s + 2 : ℕ) from le_add_of_nonneg_right (Nat.cast_nonneg _)).trans + simpa only [pow_one] using pow_le_pow_right₀ + (show (1 : ℝ) ≤ p + (s + 2 : ℕ) by have := Nat.cast_nonneg (α := ℝ) s; push_cast; linarith) + (show 1 ≤ s + 2 by omega) + have hcost : 0 ≤ (q + 2) ^ 3 + p := by positivity + have hheight : 0 ≤ (p + 2) ^ 4 := by positivity + have hbound : (q + 2) ^ 3 + p + (p + 2) ^ 4 ≤ (p + C) ^ C := by + simpa [P, Q, q, Polynomial.eval₂_pow] using hfinal p hp + have hcostC : (q + 2) ^ 3 + p ≤ (p + C) ^ C := by linarith + have hheightC : (p + 2) ^ 4 ≤ (p + C) ^ C := by linarith + let : Fintype (SymbolBasisIndex w ω) := + symbolBasisIndexFintype w ω s (fun _ => Nat.zero_lt_one) (F.adaptedBasis_weight_le_step b ω hF) + let : Fintype (SymbolBasisIndex w ν) := + symbolBasisIndexFintype w ν s (fun _ => Nat.zero_lt_one) (F.adaptedBasis_weight_le_step c ν hc) + let Bb := F.polynomialSymbolBasis b ω hF w + let Bc := F.polynomialSymbolBasis c ν hc w + let M : Matrix (SymbolBasisIndex w ν) (SymbolBasisIndex w ω) ℚ := fun i j => Bc.repr (Bb j) i + have hMb : ∀ i j, RationalHeightLE (M i j) H := + fun i j => F.polynomialSymbolBasis_change_height b ω hF c ν hc w hH hb j i + have hDb : (Fintype.card (SymbolBasisIndex w ω) : ℝ) ≤ q := + (Nat.cast_le.mpr (symbolBasisIndex_card_le w ω s (fun _ => Nat.zero_lt_one) + (F.adaptedBasis_weight_le_step b ω hF))).trans + (by simpa only [q, Nat.cast_add, Nat.cast_ofNat] using + symbol_dimension_bound_le_power s (Fintype.card ι) (Fintype.card σ) hp hι hσ) + have hDc : (Fintype.card (SymbolBasisIndex w ν) : ℝ) ≤ q := + (Nat.cast_le.mpr (symbolBasisIndex_card_le w ν s (fun _ => Nat.zero_lt_one) + (F.adaptedBasis_weight_le_step c ν hc))).trans + (by simpa only [q, Nat.cast_add, Nat.cast_ofNat] using + symbol_dimension_bound_le_power s (Fintype.card κ) (Fintype.card σ) hp hκ hσ) + have hHq : (H : ℝ) ≤ Real.exp q := hHp.trans (Real.exp_le_exp.mpr hpq) + have hδ : (matrixDenominator M : ℝ) ≤ Real.exp ((q + 2) ^ 3) := + real_basis_transfer_denominator Bb Bc hq hDb hDc hHq hMb + have hblock : ∀ i j, i.val.1 ≠ j.val.1 → M i j = 0 := by + intro i j hij + change (F.polynomialSymbolBasis c ν hc w).repr (F.polynomialSymbolBasis b ω hF w j) i = 0 + rw [F.polynomialSymbolBasis_change_coordinate, ite_eq_right hij.symm] + obtain ⟨m, E, R, B, Z, v, hm, hmp, hprod, hE, hB, hv, hZ, hh, hη, hR⟩ := hX + let n := matrixDenominator M * m + have hn : 0 < n := Nat.mul_pos (matrixDenominator_pos M) hm + have hnC : (n : ℝ) ≤ Real.exp ((p + C) ^ C) := by + dsimp only [n] + rw [Nat.cast_mul] + calc + _ ≤ Real.exp ((q + 2) ^ 3) * Real.exp p := mul_le_mul hδ hmp (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = Real.exp ((q + 2) ^ 3 + p) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr hcostC + have hgrid : F.SymbolRationalGrid c ν hc w n B := + real_basis_coordinates_grid Bb Bc m B.coord hB + have hslow : F.SymbolSlowBound c ν hc w T (Real.exp ((p + C) ^ C)) E := by + dsimp only [SymbolSlowBound] at hE + intro i + have hcoord := congrFun (real_basis_coordinates_transfer Bb Bc E.coord) i + change |(Bc.baseChange ℝ).repr E.coord i| ≤ _ + rw [hcoord] + have hEcoord : ∀ j : SymbolBasisIndex w ω, + |(Bb.baseChange ℝ).repr E.coord j| ≤ Real.exp p / monomialScale T j.val.1 := by + simpa only [Bb, w] using hE + have hweighted := weighted_matrix_mulVec_bound (fun i : SymbolBasisIndex w ν => i.val.1) + (fun j : SymbolBasisIndex w ω => j.val.1) (fun i j => (M i j : ℝ)) + (fun i j hij => by rw [hblock i j hij, Rat.cast_zero]) (H : ℝ≥0) + (fun i j => (hMb i j).abs_real_le) (monomialScale T) (monomialScale_pos T hT) + (Real.exp_nonneg p) (fun j => (Bb.baseChange ℝ).repr E.coord j) hEcoord i + have hfactor : ((Fintype.card (SymbolBasisIndex w ω) : ℝ) + 1) * ((H : ℝ) + 1) ≤ + Real.exp ((q + 2) ^ 3) := by + have hHlarge : (H : ℝ) ≤ Real.exp ((q + 2) ^ 1) := + hHq.trans (Real.exp_le_exp.mpr (by simp)) + calc + _ ≤ ((Fintype.card (SymbolBasisIndex w ω) : ℝ) + 1) * + (Real.exp ((q + 2) ^ 1) + 1) := + mul_le_mul_of_nonneg_left (add_le_add hHlarge le_rfl) (by positivity) + _ ≤ _ := matrix_weighted_factor_le_exp_power _ hq hDb 1 (by decide) + apply hweighted.trans + apply div_le_div_of_nonneg_right _ (monomialScale_pos T hT i.val.1).le + calc + _ ≤ Real.exp ((q + 2) ^ 3) * Real.exp p := mul_le_mul_of_nonneg_right hfactor (Real.exp_nonneg p) + _ = Real.exp ((q + 2) ^ 3 + p) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr hcostC + have hcard : Fintype.card κ = Fintype.card ι := by + rw [← finrank_eq_card_basis c, finrank_eq_card_basis b] + let e := Fintype.equivOfCardEq hcard + let v' : κ → F.AssociatedGraded := fun i => v (e i) + have hrange : Set.range v' = Set.range v := by + ext x + constructor + · rintro ⟨i, rfl⟩ + exact ⟨e i, rfl⟩ + · rintro ⟨i, rfl⟩ + exact ⟨e.symm i, congrArg v (e.apply_symm_apply i)⟩ + refine ⟨n, E, R, B, Z, v', hn, hnC, hprod, hslow, hgrid, ?_, ?_, ?_, ?_, ?_⟩ + · rw [hrange] + exact hv + · exact (F.associatedGraded_submodule_basis_independent b ω hF c ν hc Z.toSubmodule).mpr hZ + · intro i j + have hx : ∀ k, rationalLogHeight ((F.associatedGradedBasis b ω hF).repr (v (e i)) k) ≤ p := hh (e i) + have hbc : ∀ j k, RationalHeightLE ((F.associatedGradedBasis c ν hc).repr + (F.associatedGradedBasis b ω hF j) k) H := + F.associatedGradedBasis_change_height b ω hF c ν hc hH hb + have htransfer := rational_basis_coordinates_logHeight (F.associatedGradedBasis b ω hF) + (F.associatedGradedBasis c ν hc) hp hι hHp hbc (v (e i)) hx j + exact htransfer.trans hheightC + · intro x hx htop + have htop' : basisGradeProjection (F.associatedGradedBasis b ω hF) ω s x = x := by + rw [← F.associatedGraded_projection_basis_independent b ω hF c ν hc s] + exact htop + exact (F.gradedFrequency_top_basis_independent b ω hF c ν hc η x htop').trans (hη x hx htop') + · rw [F.symbolPointwiseSubalgebra_basis_independent b ω hF c ν hc w] + simpa only [w] using hR + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +def fixedAdaptedSymbolTransferInput (p q : ℝ) : ℝ := + ((p + 3) ^ 5 + q + 1 + 2) ^ 4 + q + 1 + +theorem exists_fixed_adapted_symbol_factorization_basis (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + (D : RationalFilteredNilmanifold L s d) {p : ℝ}, + 0 ≤ p → D.GeometryComplexityLE p → + ∃ (c : Basis (Fin (finrank ℚ L)) ℚ L) + (ν : Fin (finrank ℚ L) → ℕ) (N : ℕ), + ∃ hC : ∀ j, D.filtration.layer j = + Submodule.span ℚ (c '' {i | j ≤ ν i}), + Monotone ν ∧ IsCentralLieBasis c ∧ + (∀ j i, rationalLogHeight (D.basis.repr (c j) i) ≤ p + 1) ∧ + (∀ i j, rationalLogHeight (c.repr (D.basis i) j) ≤ (p + 3) ^ 5) ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants c i j k) ≤ (p + 3) ^ 11) ∧ + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 3) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates c D.lattice ∧ + bchSubgroupCoordinates c D.lattice ⊆ denominatorGrid N ∧ + ∀ {q : ℝ}, p ≤ q → + ∀ {σ : Type*} [Fintype σ], (Fintype.card σ : ℝ) ≤ q → + ∀ (b : Basis (Fin (finrank ℚ L)) ℚ L) + (ω : Fin (finrank ℚ L) → ℕ) + (hF : ∀ j, D.filtration.layer j = + Submodule.span ℚ (b '' {i | j ≤ ω i})), + (∀ i j, rationalLogHeight (D.basis.repr (b i) j) ≤ q) → + ∀ (T : σ → ℝ), (∀ i, 0 < T i) → + ∀ (η : L →ₗ[ℚ] ℚ) + (X : D.filtration.RealPolynomialSymbolGroup (fun _ : σ => 1)), + D.filtration.ControlledSymbolFactorization b ω hF η T X q → + D.filtration.ControlledSymbolFactorization c ν hC η T X + ((fixedAdaptedSymbolTransferInput p q + C) ^ C) := by + obtain ⟨C, hC, hchange⟩ := + NilpotentLieFiltration.exists_controlled_symbol_basis_change s + refine ⟨C, hC, ?_⟩ + intro L _ _ d D p hp hD + obtain ⟨c, ν, N, hν, hc, hlayers, hcoord, hinv, hbracket, + hN, hNp, hin, hout⟩ := D.exists_controlled_adapted_basis hp hD + refine ⟨c, ν, N, hlayers, hν, hc, hcoord, hinv, hbracket, + hN, hNp, hin, hout, ?_⟩ + intro q hpq σ _ hσ b ω hF hb T hT η X hX + let t : ℝ := (p + 3) ^ 5 + q + 1 + let R : ℝ := (t + 2) ^ 4 + q + 1 + have hq : 0 ≤ q := hp.trans hpq + have hA : 0 ≤ (p + 3) ^ 5 := by positivity + have ht : 0 ≤ t := by dsimp [t]; positivity + have hqt : q ≤ t := by dsimp [t]; linarith + have hqR : q ≤ R := by + dsimp only [R] + linarith [show 0 ≤ (t + 2) ^ 4 by positivity] + have hR : 0 ≤ R := hq.trans hqR + have hd : (Fintype.card (Fin d) : ℝ) ≤ q := by + simpa only [Fintype.card_fin] using hD.1.trans hpq + have hdim : (Fintype.card (Fin (finrank ℚ L)) : ℝ) ≤ q := by + simpa only [Fintype.card_fin, finrank_eq_card_basis D.basis] using hd + have hH₀ : (⌈Real.exp ((p + 3) ^ 5)⌉₊ : ℝ) ≤ Real.exp t := + (ceil_exp_le_exp_add_one hA).trans + (Real.exp_le_exp.mpr (by dsimp [t]; linarith)) + have hbc : ∀ i j, rationalLogHeight (c.repr (b i) j) ≤ (t + 2) ^ 4 := by + intro i j + exact rational_basis_coordinates_logHeight D.basis c ht (hd.trans hqt) hH₀ + (fun i j => rationalHeightLE_ceil_exp (hinv i j)) (b i) + (fun j => (hb i j).trans hqt) j + have hH : (⌈Real.exp ((t + 2) ^ 4)⌉₊ : ℝ) ≤ Real.exp R := + (ceil_exp_le_exp_add_one (by positivity)).trans + (Real.exp_le_exp.mpr (by dsimp [R]; linarith)) + apply hchange D.filtration b ω hF c ν hlayers + ⌈Real.exp ((t + 2) ^ 4)⌉₊ R (one_le_ceil_exp _) hR + (hdim.trans hqR) (hdim.trans hqR) (hσ.trans hqR) hH + (fun i j => rationalHeightLE_ceil_exp (hbc i j)) T hT η X + exact hX.mono D.filtration b ω hF hqR hT + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelDensityProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelDensityProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a06986bcd9192cac37f7dccbe0693ee71b9e5d1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelDensityProjection.lean @@ -0,0 +1,288 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalRowsSiteReconstruction +import OAI.Combinatorics.Progressions.Lattices.IntegerPeriodPivot + +namespace OAI + + +namespace Erdos3 + +theorem linearIndependent_of_fixed_kernel_period {O K₀ K : Type*} + [Fintype O] [DecidableEq O] [Fintype K₀] + (A₀ : Matrix O K₀ ℤ) (A : Matrix O K ℤ) (e : K₀ → K) + (he : ∀ i k, A i (e k) = A₀ i k) {a : ℤ} (ha : a ≠ 0) + (hperiod : integerScalarLattice O a ≤ A₀.mulVecLin.range) : + LinearIndependent ℝ (fun i k => (A i k : ℝ)) := by + classical + obtain ⟨s, hs⟩ := integerPeriod_exists_pivot A₀ ha hperiod + have hdet : ((A₀.submatrix id s).map (fun z => (z : ℝ))).det ≠ 0 := by + rw [← Int.cast_det] + exact_mod_cast hs + let restrict : (K → ℝ) →ₗ[ℝ] (O → ℝ) := + { toFun := fun v j => v (e (s j)) + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + have hrows := Matrix.linearIndependent_rows_of_det_ne_zero hdet + change LinearIndependent ℝ (fun i j => (A₀ i (s j) : ℝ)) at hrows + apply LinearIndependent.of_comp restrict + simpa only [Function.comp_def, restrict, LinearMap.coe_mk, AddHom.coe_mk, + he] using hrows + +end Erdos3 + + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial Polynomial +open scoped BigOperators + +theorem exists_fixed_kernel_covered_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK₀ : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite₀ : ∀ (s : Finset (Fin q)) k, + |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] + {F : Type*} [Fintype F] + (_hn : (Fintype.card I : ℝ) ≤ P) + (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (e : K₀ → K) (_hroot : ∀ k, root (e k) = root₀ k) + (_hdifference : ∀ i k, difference i (e k) = difference₀ i k) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C), + ∃ b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ a j s t, |(b a j s t : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ ε : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hε : 0 < ε) + (_hρP : 1 / ρ ≤ Real.exp P) (_hεP : 1 / ε ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) + (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ i, HasLayerSamplingRank (i.val + 1) H R (U i) (p i)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (Q : MvPolynomial (Option K × I) ℝ) (_hQ : Q.totalDegree ≤ 0) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ t v, ‖test t v‖ ≤ 1) + (G : Finset (ColumnResiduePattern (Option K) I stride)) (_hG : G.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (_hwidth : ∀ z, ρ * H z.2 ≤ V z), + ∃ hZ : 0 < ∑' x, selectedResidueSmoothWeight stride G V x, + ‖(∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + affineCubeFourierSum frequency p c (fun k j => (z (k, j) : ℝ)))) - + (∑' z : Option K × I → ℤ, ((selectedResidueSmoothPMF stride G V hV hZ z).toReal : ℂ) * + (layeredSiteWeight Q (fun s => affineSite root difference s) test (fun k j => (z (k, j) : ℝ)) * + retainedSiteFourierSum U root difference frequency b c + (affineCoveredSiteSample U root difference D p hm (fun k j => (z (k, j) : ℝ)))))‖ ≤ ε := by + obtain ⟨A₀, _, hprojection⟩ := exists_affine_cube_fourier_projection m q + obtain ⟨A₁, _, hcover⟩ := exists_fixed_kernel_site_fourier_projection m q + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C A₀) ^ A₀ + (X + Polynomial.C A₁) ^ A₁) + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK₀ hsite₀ + have hsum : (P + A₀) ^ A₀ + (P + A₁) ^ A₁ ≤ (P + A) ^ A := by + simpa [Polynomial.eval₂_pow] using hbudget P hP + have hb₀ : (P + A₀) ^ A₀ ≤ (P + A) ^ A := by + linarith [pow_nonneg (add_nonneg hP (Nat.cast_nonneg A₁)) A₁] + have hb₁ : (P + A₁) ^ A₁ ≤ (P + A) ^ A := by + linarith [pow_nonneg (add_nonneg hP (Nat.cast_nonneg A₀)) A₀] + obtain ⟨D, hD, hDP, hrows⟩ := hcover root₀ difference₀ a ha hperiod hP hK₀ hsite₀ + refine ⟨D, hD, hDP.trans (Real.exp_le_exp.mpr hb₁), ?_⟩ + intro I K _ _ _ J _ F _ hn hd U root difference e hroot hdifference L C hL hC hLP hCP + hsite frequency hbound + have hlin := linearIndependent_of_fixed_kernel_period + (Matrix.of difference₀) (Matrix.of difference) e hdifference ha hperiod + obtain ⟨b, hb, heq⟩ := hrows root difference e hroot hdifference U frequency + (fun a j d hd t => (hbound a j d hd t).trans hCP) + refine ⟨b, fun a j s t => (hb a j s t).trans (Real.exp_le_exp.mpr hb₁), ?_⟩ + intro c B hB hBP hcoefficients p hp hm stride hs R S ρ ε hS hSP hρ hε hρP hεP + hstride H hsize hrank hR Q hQ test htest G hG V hV hwidth + obtain ⟨hZ, hproj⟩ := hprojection hP hn hd U root difference hlin hL hC hLP hCP hsite + frequency hbound c hB hBP hcoefficients p hp hm stride hs hS hSP hρ hε hρP hεP + hstride H (fun k => (Real.exp_le_exp.mpr hb₀).trans (hsize k)) hrank + ((Real.exp_le_exp.mpr hb₀).trans hR) Q hQ test htest G hG V hV hwidth + refine ⟨hZ, ?_⟩ + have hfun : affineCubeFourierProjection U root difference frequency p c = + fun x => retainedSiteFourierSum U root difference frequency b c + (affineCoveredSiteSample U root difference D p hm x) := funext (fun x => heq p hp hm c x) + rw [hfun] at hproj + exact hproj + +end Erdos3.BooleanCubeKernel + + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators + +theorem selectedResidue_density_projection_error + {I K F : Type*} [Fintype I] [Fintype K] [Fintype F] {m q : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (root : K → ℤ) (difference : Fin q → K → ℤ) (D : ℕ) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) (hm : ∀ j d, coefficients (p j) d ∈ U j) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ) (c : F → ℂ) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ s x, ‖test s x‖ ≤ 1) + (base : I → ℤ) (modulus : I → ℕ) + (T : Finset (ColumnResiduePattern (Option K) I modulus)) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + (density : (Option K × I → ℤ) → ℝ) + {η δ : ℝ} (hη : 0 ≤ η) + (happrox : ∀ z ∈ rectangularWeightIndices 0 V 1, + ‖(density z : ℂ) - affineCubeFourierSum frequency + (fun j => VectorPolynomial.translate (fun i => (base i : ℝ)) (p j)) c (fun k i => (z (k, i) : ℝ))‖ ≤ η) + (hprojection : + ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + (layeredSiteWeight 0 (fun s => affineSite root difference s) + (fun s x => test s ((fun i => (base i : ℝ)) + x)) (fun k i => (z (k, i) : ℝ)) * + affineCubeFourierSum frequency (fun j => VectorPolynomial.translate (fun i => (base i : ℝ)) (p j)) c + (fun k i => (z (k, i) : ℝ)))) - + (∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + (layeredSiteWeight 0 (fun s => affineSite root difference s) + (fun s x => test s ((fun i => (base i : ℝ)) + x)) (fun k i => (z (k, i) : ℝ)) * + retainedSiteFourierSum U root difference frequency b c + (affineCoveredSiteSample U root difference D + (fun j => VectorPolynomial.translate (fun i => (base i : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun i => (base i : ℝ)) (p j) (hm j)) + (fun k i => (z (k, i) : ℝ)))))‖ ≤ δ) + : ‖(∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + (layeredSiteWeight 0 (fun s => affineSite root difference s) + (fun s x => test s ((fun i => (base i : ℝ)) + x)) (fun k i => (z (k, i) : ℝ)) * + (density z : ℂ))) - + ∑' z, ((selectedResidueSmoothPMF modulus T V hV hZ z).toReal : ℂ) * + physicalCubeCoveredTest U root difference D p hm frequency b c test + (physicalCubeRootDifferences root (Matrix.of difference) base z)‖ ≤ η + δ := by + let law := selectedResidueSmoothPMF modulus T V hV hZ + let w := fun z : Option K × I → ℤ => layeredSiteWeight 0 (fun s => affineSite root difference s) + (fun s x => test s ((fun i => (base i : ℝ)) + x)) (fun k i => (z (k, i) : ℝ)) + let fourier := fun z : Option K × I → ℤ => affineCubeFourierSum frequency + (fun j => VectorPolynomial.translate (fun i => (base i : ℝ)) (p j)) c (fun k i => (z (k, i) : ℝ)) + let φ := physicalCubeCoveredTest U root difference D p hm frequency b c test + let output := physicalCubeRootDifferences root (Matrix.of difference) base + let projected := fun z : Option K × I → ℤ => w z * + retainedSiteFourierSum U root difference frequency b c + (affineCoveredSiteSample U root difference D + (fun j => VectorPolynomial.translate (fun i => (base i : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun i => (base i : ℝ)) (p j) (hm j)) + (fun k i => (z (k, i) : ℝ))) + have hfactor : projected = fun z => φ (output z) := by + funext z + exact physicalCubeCoveredTest_of_frame U root difference D p hm frequency b c test base z + have hfirst : ‖(∑' z, ((law z).toReal : ℂ) * (w z * (density z : ℂ))) - + ∑' z, ((law z).toReal : ℂ) * (w z * fourier z)‖ ≤ η := + selectedResidueSmoothPMF_approximation modulus T V hV hZ w (fun z => (density z : ℂ)) fourier hη + (fun z _ => layeredSiteWeight_norm_le 0 _ _ (fun s x => htest s _) _) happrox + have hp := hprojection + change ‖(∑' z, ((law z).toReal : ℂ) * (w z * fourier z)) - + ∑' z, ((law z).toReal : ℂ) * projected z‖ ≤ δ at hp + rw [hfactor] at hp + have hprojected : ‖(∑' z, ((law z).toReal : ℂ) * (w z * (density z : ℂ))) - + ∑' z, ((law z).toReal : ℂ) * φ (output z)‖ ≤ η + δ := + (norm_sub_le_norm_sub_add_norm_sub _ + (∑' z, ((law z).toReal : ℂ) * (w z * fourier z)) _).trans (add_le_add hfirst hp) + exact hprojected + +end Erdos3.BooleanCubeKernel + + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators + +theorem exists_fixed_kernel_density_projection (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK₀ : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite₀ : ∀ (s : Finset (Fin q)) k, + |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {I K : Type*} + [Fintype I] [DecidableEq I] [Fintype K] + {J : Fin m → Type*} [∀ j, Fintype (J j)] {F : Type*} [Fintype F] + (_hn : (Fintype.card I : ℝ) ≤ P) (_hd : (Fintype.card (Option K × I) : ℝ) ≤ P) + (U : ∀ j, Submodule ℝ (J j → ℝ)) (root : K → ℤ) (difference : Fin q → K → ℤ) + (e : K₀ → K) (_hroot : ∀ k, root (e k) = root₀ k) + (_hdifference : ∀ i k, difference i (e k) = difference₀ i k) + {L C : ℝ} (_hL : 0 ≤ L) (_hC : 0 ≤ C) (_hLP : L ≤ Real.exp P) (_hCP : C ≤ Real.exp P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root difference s (some k) : ℤ) : ℝ)| ≤ L) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hbound : ∀ a j d, d.degree ≤ j.val + 1 → ∀ t, |(frequency a j d t : ℝ)| ≤ C), + ∃ b : F → ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ a j s t, |(b a j s t : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (c : F → ℂ) {B : ℝ} (_hB : 0 ≤ B) (_hBP : B ≤ Real.exp P) + (_hcoefficients : (∑ a, ‖c a‖) ≤ B) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (base : I → ℤ) + (stride : I → ℕ) (_hs : ∀ k, 0 < stride k) + {R S ρ δ : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hρ : 0 < ρ) (_hδ : 0 < δ) + (_hρP : 1 / ρ ≤ Real.exp P) (_hδP : 1 / δ ≤ Real.exp P) + (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (H : I → ℝ) (_hsize : ∀ k, Real.exp ((P + A) ^ A) ≤ H k) + (_hrank : ∀ j, HasLayerSamplingRank (j.val + 1) H R (U j) (p j)) + (_hR : Real.exp ((P + A) ^ A) ≤ R) + (test : Finset (Fin q) → (I → ℝ) → ℂ) (_htest : ∀ s x, ‖test s x‖ ≤ 1) + (T : Finset (ColumnResiduePattern (Option K) I stride)) (_hT : T.Nonempty) + (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) (_hwidth : ∀ z, ρ * H z.2 ≤ V z) + (density : CoefficientTorus (K := K) U → ℝ) {η : ℝ} (_hη : 0 ≤ η) + (_happrox : ∀ x, ‖(density x : ℂ) - coefficientTorusFourierSum U frequency c x‖ ≤ η), + let pa := fun j => translate (fun i => (base i : ℝ)) (p j) + let hma := fun j => coefficients_translate_mem (U j) (fun i => (base i : ℝ)) (p j) (hm j) + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride T V z, + ‖(∑' z, ((selectedResidueSmoothPMF stride T V hV hZ z).toReal : ℂ) * + (physicalCubeSiteTest test (physicalCubeRootDifferences root (Matrix.of difference) base z) * + (density (affineSampleCoefficientTorus U pa hma (fun k i => (z (k, i) : ℝ))) : ℂ))) - + ∑' z, ((selectedResidueSmoothPMF stride T V hV hZ z).toReal : ℂ) * + physicalCubeCoveredTest U root difference D p hm frequency b c test + (physicalCubeRootDifferences root (Matrix.of difference) base z)‖ ≤ η + δ := by + obtain ⟨A, hA, hprojection⟩ := exists_fixed_kernel_covered_projection m q + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK₀ hsite₀ + obtain ⟨D, hD, hDP, hrows⟩ := hprojection root₀ difference₀ a ha hperiod hP hK₀ hsite₀ + refine ⟨D, hD, hDP, ?_⟩ + intro I K _ _ _ J _ F _ hn hd U root difference e hroot hdifference L C hL hC hLP hCP + hsite frequency hbound + obtain ⟨b, hb, hproj⟩ := hrows hn hd U root difference e hroot hdifference hL hC hLP hCP hsite + frequency hbound + refine ⟨b, hb, ?_⟩ + intro c B hB hBP hcoefficients p hp hm base stride hs R S ρ δ hS hSP hρ hδ hρP hδP + hstride H hsize hrank hR test htest T hT V hV hwidth density η hη happrox + let pa := fun j => translate (fun i => (base i : ℝ)) (p j) + let hma := fun j => coefficients_translate_mem (U j) (fun i => (base i : ℝ)) (p j) (hm j) + have hpa (j) : DegreeLE (1 : I → ℕ) (j.val + 1) (pa j) := + degreeLE_translate (1 : I → ℕ) (fun _ => by norm_num) _ (p j) (hp j) + have hra (j) : HasLayerSamplingRank (j.val + 1) H R (U j) (pa j) := + (hasLayerSamplingRank_translate_iff (fun i => (base i : ℝ)) (j.val + 1) H R (U j) (p j) (hp j)).mpr (hrank j) + obtain ⟨hZ, hproj⟩ := hproj c hB hBP hcoefficients pa hpa hma stride hs + hS hSP hρ hδ hρP hδP hstride H hsize hra hR 0 (by simp) + (fun s x => test s ((fun i => (base i : ℝ)) + x)) (fun s x => htest s _) T hT V hV hwidth + refine ⟨hZ, ?_⟩ + have happ (z : Option K × I → ℤ) : + ‖(density (affineSampleCoefficientTorus U pa hma (fun k i => (z (k, i) : ℝ))) : ℂ) - + affineCubeFourierSum frequency pa c (fun k i => (z (k, i) : ℝ))‖ ≤ η := by + simpa only [coefficientTorusFourierSum, coefficientTorusCharacter_sample U _ pa hpa hma, + affineCubeFourierSum] using happrox (affineSampleCoefficientTorus U pa hma (fun k i => (z (k, i) : ℝ))) + simpa only [layeredSiteWeight_physicalCube] using + selectedResidue_density_projection_error U root difference D p hm frequency b c test htest base + stride T V hV hZ (fun z => density (affineSampleCoefficientTorus U pa hma (fun k i => (z (k, i) : ℝ)))) + hη (fun z _ => happ z) hproj + +end Erdos3.BooleanCubeKernel + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelEuclideanDensity.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelEuclideanDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a9496a608fe7305acef0bd08eae232124978872 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelEuclideanDensity.lean @@ -0,0 +1,364 @@ +import OAI.Combinatorics.Progressions.Lattices.AffineCoveredJetDensity + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +theorem exists_fixed_kernel_site_residual (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite : ∀ (s : Finset (Fin q)) k, + |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {K : Type*} [Fintype K] (root : K → ℤ) (difference : Fin q → K → ℤ) + (e : K₀ → K) (_hroot : ∀ k, root (e k) = root₀ k) + (_hdifference : ∀ i k, difference i (e k) = difference₀ i k), + ∃ T : ∀ j : Fin m, Matrix (BoundedCoefficientExponent K (j.val + 1)) (Finset (Fin q)) ℤ, + ∀ (j : Fin m) {W : Type*} [AddCommGroup W] [Module ℝ W] + (x : BoundedCoefficientExponent K (j.val + 1) → W), + let E := boundedSiteMatrix (j.val + 1) (fun s k => affineSite root difference s (some k)) + matrixModuleAction (fun s i => (E s i : ℝ)) + (matrixModuleAction (fun i s => (T j i s : ℝ)) + (matrixModuleAction (fun s i => (E s i : ℝ)) x)) = + (d : ℝ) • matrixModuleAction (fun s i => (E s i : ℝ)) x := by + classical + obtain ⟨A, hA, hbudget⟩ := exists_geometric_positive_cover_budget m q + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK hsite + let site₀ := fun s k => affineSite root₀ difference₀ s (some k) + let E₀ := fun j : Fin m => boundedSiteMatrix (j.val + 1) site₀ + obtain ⟨d, T₀, hd, hT₀, hbound⟩ := exists_common_integer_site_residual E₀ + (fun _ => exponentialSiteHeight m P) (fun _ => exponentialSiteHeight_pos m P) + (fun j => boundedSiteMatrix_height_of_exp m (Nat.succ_le_of_lt j.isLt) site₀ hsite) + have hdb := hbound (geometricSiteBudget_nonneg m q hP) + (fun j => boundedCoefficientExponent_card_le_geometricSiteBudget m q + (Nat.succ_le_of_lt j.isLt) hP hK) + (cubeSites_card_le_geometricSiteBudget m q hP) + (fun _ => (exponentialSiteHeight_le m hP).trans + (Real.exp_le_exp.mpr (degree_mul_le_geometricSiteBudget m q hP))) + refine ⟨d, hd, hdb.trans (Real.exp_le_exp.mpr (by + simpa only [Fintype.card_fin] using hbudget P hP)), ?_⟩ + intro K _ root difference e hroot hdifference + let site := fun s k => affineSite root difference s (some k) + have hs : (fun s k => site s (e k)) = site₀ := by + funext s k + simp only [site, site₀, affineSite, hroot, hdifference] + refine ⟨fun j => extendIntegerSiteSection (boundedExponentMap e (j.val + 1)) (T₀ j), ?_⟩ + intro j W _ _ x + have hc : (boundedSiteMatrix (j.val + 1) site).submatrix id (boundedExponentMap e (j.val + 1)) = E₀ j := by + rw [boundedSiteMatrix_mapDomain, hs] + obtain ⟨R, hR⟩ := boundedSiteMatrix_fixed_kernel_factor root₀ (Matrix.of difference₀) + a ha hperiod (j.val + 1) root (Matrix.of difference) + exact integerSiteResidual_extend_columns (E₀ j) (boundedSiteMatrix (j.val + 1) site) + (boundedExponentMap e (j.val + 1)) hc R hR (T₀ j) d (hT₀ j) x + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.VectorPolynomial + +open Polynomial + +theorem exists_bounded_residual_cover_budget (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ P : ℝ, 0 ≤ P → + geometricSiteBudget m q P + ((m : ℝ) + 2) * (geometricSiteBudget m q P + 2) ^ 36 ≤ + (P + A) ^ A := by + let G : Polynomial ℕ := C (m + 1) * (X + 1) ^ (m + 1) + C (2 ^ q) + obtain ⟨A, hA, h⟩ := exists_natPolynomial_eval_budget (G + C (m + 2) * (G + 2) ^ 36) + refine ⟨A, hA, ?_⟩ + intro P hP + simpa [G, geometricSiteBudget, Polynomial.eval₂_pow, Nat.cast_add] using h P hP + +end Erdos3.VectorPolynomial + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial +open scoped BigOperators Classical + +theorem exists_fixed_kernel_bounded_section (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite : ∀ (s : Finset (Fin q)) k, + |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {K : Type*} [Fintype K] (root : K → ℤ) (difference : Fin q → K → ℤ) + (e : K₀ → K) (_hroot : ∀ k, root (e k) = root₀ k) + (_hdifference : ∀ i k, difference i (e k) = difference₀ i k), + ∃ T : ∀ j : Fin m, Matrix (BoundedCoefficientExponent K (j.val + 1)) (Finset (Fin q)) ℤ, + (∀ j s, (∑ i, |(T j i s : ℝ)|) ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (j : Fin m) {W : Type*} [AddCommGroup W] [Module ℝ W] + (x : BoundedCoefficientExponent K (j.val + 1) → W), + let E := boundedSiteMatrix (j.val + 1) (fun s k => affineSite root difference s (some k)) + matrixModuleAction (fun s i => (E s i : ℝ)) + (matrixModuleAction (fun i s => (T j i s : ℝ)) + (matrixModuleAction (fun s i => (E s i : ℝ)) x)) = + (d : ℝ) • matrixModuleAction (fun s i => (E s i : ℝ)) x := by + obtain ⟨A, hA, hbudget⟩ := exists_bounded_residual_cover_budget m q + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK hsite + let site₀ := fun s k => affineSite root₀ difference₀ s (some k) + let E₀ := fun j : Fin m => boundedSiteMatrix (j.val + 1) site₀ + obtain ⟨d, T₀, hd, hT₀, hbound⟩ := exists_bounded_common_site_residual E₀ + (fun _ => exponentialSiteHeight m P) (fun _ => exponentialSiteHeight_pos m P) + (fun j => boundedSiteMatrix_height_of_exp m (Nat.succ_le_of_lt j.isLt) site₀ hsite) + let G := geometricSiteBudget m q P + have hG : 0 ≤ G := geometricSiteBudget_nonneg m q hP + have hcard (j : Fin m) : (Fintype.card (BoundedCoefficientExponent K₀ (j.val + 1)) : ℝ) ≤ G := + boundedCoefficientExponent_card_le_geometricSiteBudget m q (Nat.succ_le_of_lt j.isLt) hP hK + obtain ⟨hdb, hTb⟩ := hbound hG hcard (cubeSites_card_le_geometricSiteBudget m q hP) + (fun _ => (exponentialSiteHeight_le m hP).trans + (Real.exp_le_exp.mpr (degree_mul_le_geometricSiteBudget m q hP))) + have hcost : G + ((m : ℝ) + 2) * (G + 2) ^ 36 ≤ (P + A) ^ A := hbudget P hP + have hpow : 0 ≤ (G + 2) ^ 36 := pow_nonneg (by linarith) _ + refine ⟨d, hd, hdb.trans (Real.exp_le_exp.mpr ?_), ?_⟩ + · simp only [Fintype.card_fin] + nlinarith + · intro K _ root difference e hroot hdifference + let site := fun s k => affineSite root difference s (some k) + have hs : (fun s k => site s (e k)) = site₀ := by + funext s k + simp only [site, site₀, affineSite, hroot, hdifference] + refine ⟨fun j => extendIntegerSiteSection (boundedExponentMap e (j.val + 1)) (T₀ j), ?_, ?_⟩ + · intro j s + apply (extendIntegerSiteSection_column_sum_bound _ (T₀ j) (hTb j) s).trans + simp only [Fintype.card_fin] + calc + _ ≤ G * Real.exp (((m : ℝ) + 2) * (G + 2) ^ 36) := + mul_le_mul_of_nonneg_right (hcard j) (Real.exp_pos _).le + _ ≤ Real.exp G * Real.exp (((m : ℝ) + 2) * (G + 2) ^ 36) := + mul_le_mul_of_nonneg_right (by linarith [Real.add_one_le_exp G]) (Real.exp_pos _).le + _ = Real.exp (G + ((m : ℝ) + 2) * (G + 2) ^ 36) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr hcost + · intro j W _ _ x + have hc : (boundedSiteMatrix (j.val + 1) site).submatrix id (boundedExponentMap e (j.val + 1)) = E₀ j := by + rw [boundedSiteMatrix_mapDomain, hs] + obtain ⟨R, hR⟩ := boundedSiteMatrix_fixed_kernel_factor root₀ (Matrix.of difference₀) + a ha hperiod (j.val + 1) root (Matrix.of difference) + exact integerSiteResidual_extend_columns (E₀ j) (boundedSiteMatrix (j.val + 1) site) + (boundedExponentMap e (j.val + 1)) hc R hR (T₀ j) d (hT₀ j) x + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel +open VectorPolynomial +open scoped BigOperators Classical + +theorem exists_fixed_kernel_bounded_section_multiple (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite : ∀ (s : Finset (Fin q)) k, + |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∀ (period : ℕ), 0 < period → (period : ℝ) ≤ Real.exp P → + ∃ d : ℕ, period ∣ d ∧ 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {K : Type*} [Fintype K] (root : K → ℤ) (difference : Fin q → K → ℤ) + (e : K₀ → K) (_hroot : ∀ k, root (e k) = root₀ k) + (_hdifference : ∀ i k, difference i (e k) = difference₀ i k), + ∃ T : ∀ j : Fin m, Matrix (BoundedCoefficientExponent K (j.val + 1)) (Finset (Fin q)) ℤ, + (∀ j s, (∑ i, |(T j i s : ℝ)|) ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (j : Fin m) {W : Type*} [AddCommGroup W] [Module ℝ W] + (x : BoundedCoefficientExponent K (j.val + 1) → W), + let E := boundedSiteMatrix (j.val + 1) (fun s k => affineSite root difference s (some k)) + matrixModuleAction (fun s i => (E s i : ℝ)) + (matrixModuleAction (fun i s => (T j i s : ℝ)) + (matrixModuleAction (fun s i => (E s i : ℝ)) x)) = + (d : ℝ) • matrixModuleAction (fun s i => (E s i : ℝ)) x := by + obtain ⟨A₀, _, hsection⟩ := exists_fixed_kernel_bounded_section m q + obtain ⟨A, hA, hpoly⟩ := exists_natPolynomial_eval_budget + (Polynomial.X + (Polynomial.X + Polynomial.C A₀) ^ A₀) + have hbudget (P : ℝ) (hP : 0 ≤ P) : P + (P + A₀) ^ A₀ ≤ (P + A) ^ A := by + simpa [Polynomial.eval₂_pow] using hpoly P hP + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK hsite period hp hpP + obtain ⟨d, hd, hdb, hsection⟩ := hsection root₀ difference₀ a ha hperiod hP hK hsite + have hbound {x : ℝ} (hx : x ≤ Real.exp ((P + A₀) ^ A₀)) : + period * x ≤ Real.exp ((P + A) ^ A) := by + calc + _ ≤ (period : ℝ) * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_left hx (Nat.cast_nonneg _) + _ ≤ Real.exp P * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_right hpP (Real.exp_nonneg _) + _ ≤ _ := by rw [← Real.exp_add]; exact Real.exp_le_exp.mpr (hbudget P hP) + refine ⟨period * d, dvd_mul_right period d, Nat.mul_pos hp hd, ?_, ?_⟩ + · simpa only [Nat.cast_mul] using hbound hdb + · intro K _ root difference e hroot hdifference + obtain ⟨T, hTb, hT⟩ := hsection root difference e hroot hdifference + refine ⟨fun j i s => (period : ℤ) * T j i s, ?_, ?_⟩ + · intro j s + simp only [Int.cast_mul, Int.cast_natCast, abs_mul, + abs_of_nonneg (Nat.cast_nonneg period : (0 : ℝ) ≤ period), ← Finset.mul_sum] + exact hbound (hTb j s) + · intro j W _ _ x + dsimp only + rw [matrixModuleAction_int_smul, map_smul, hT j x, smul_smul, Nat.cast_mul] + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators Classical + +theorem exists_fixed_kernel_covered_density (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {K : Type*} [Fintype K] (root : K → ℤ) (difference : Fin q → K → ℤ) + (e : K₀ → K) (_hroot : ∀ k, root (e k) = root₀ k) + (_hdifference : ∀ i k, difference i (e k) = difference₀ i k) + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + [CompactSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ), Continuous D → + ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 → + let E := coefficientSiteTorusMap U (fun s k => affineSite root difference s (some k)) + let π := Set.rangeFactorization E + let C := quotientIntegerCover (coefficientIntegerLattice U) d + ∃ g : Set.range E → ℝ, Continuous g ∧ (∀ y, g y ∈ Set.Icc (0 : ℝ) B) ∧ + Integrable g (μ.map π) ∧ (∫ y, g y ∂μ.map π) = 1 ∧ + (realDensityMeasure μ (fun x => D (C x))).map π = realDensityMeasure (μ.map π) g ∧ + ∀ {I F : Type*} [Fintype F] + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) {η : ℝ}, + (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) → + ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ), + ‖affineCubeFourierProjection U root difference frequency p c b - + (g (π (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by + obtain ⟨A, hA, hresidual⟩ := exists_fixed_kernel_site_residual m q + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK hsite + obtain ⟨d, hd, hdb, hextend⟩ := hresidual root₀ difference₀ a ha hperiod hP hK hsite + refine ⟨d, hd, hdb, ?_⟩ + intro K _ root difference e hroot hdifference + obtain ⟨T, hT⟩ := hextend root difference e hroot hdifference + let site := fun s k => affineSite root difference s (some k) + intro J _ U _ _ _ _ _ μ _ _ D hD B hcap hmass E π C + let R := coefficientSiteResidual U site (fun _ => d) T + let hR := coefficientSiteResidual_preserves_lattice U site (fun _ => d) T + obtain ⟨g, hgc, hgb, hgi, hgmass, hg, hlaw⟩ := + exists_covered_coefficient_density U site d hd T (fun j x => hT j x) μ D hD hcap hmass + refine ⟨g, hgc, hgb, hgi, hgmass, hlaw, ?_⟩ + intro I F _ frequency c η happrox p hp hm b + have hfactor (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) : + (coefficientArrayFunctional U frequency).comp R = 0 ↔ + affineCubeModeFactors U root difference frequency := by + change (coefficientArrayFunctional U frequency).comp + (coefficientSiteResidual U site (fun _ => d) T) = 0 ↔ _ + rw [coefficientSiteResidual_zero_iff U site (fun _ => d) T (fun _ => hd) (fun j x => hT j x), + affineCubeModeFactors_iff_bounded] + have hb (x) : ‖D x‖ ≤ B := by rw [Real.norm_of_nonneg (hcap x).1]; exact (hcap x).2 + have he := coefficientTorusFourierProjection_approx_residualAverage U R hR root difference hfactor + frequency c μ D happrox (affineSampleCoefficientTorus U p hm b) + (coefficientResidual_section_integrable U R hR μ D hD hb _) + have hvalue := hg (affineCoefficientCoverSample U p hm d b) + rw [affineCoefficientCoverSample_projection U p hm d hd b] at hvalue + rw [hvalue] + simpa only [coefficientTorusCharacter_sample U _ p hp hm b, affineCubeFourierProjection] using he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped Classical + +theorem exists_fixed_kernel_euclidean_density (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite : ∀ (s : Finset (Fin q)) k, |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∃ d : ℕ, 0 < d ∧ (d : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {K : Type*} [Fintype K] (root : K → ℤ) (difference : Fin q → K → ℤ) + (e : K₀ → K) (_hroot : ∀ k, root (e k) = root₀ k) + (_hdifference : ∀ i k, difference i (e k) = difference₀ i k) + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + [CompactSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (SiteTorus (Finset (Fin q)) U)] [BorelSpace (SiteTorus (Finset (Fin q)) U)] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (D : CoefficientTorus (K := K) U → ℝ), Continuous D → + ∀ {B : ℝ}, (∀ x, D x ∈ Set.Icc (0 : ℝ) B) → (∫ x, D x ∂μ) = 1 → + let F := euclideanCoefficientJetMap U root (Matrix.of difference) + (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q))) + let C := quotientIntegerCover (coefficientIntegerLattice U) d + let ξ := Measure.pi (fun j => Measure.pi (fun _ : BoundedBooleanJet (Fin q) (j.val + 1) => ν j)) + ∃ f : EuclideanJetLayers U (fun j => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ, + Continuous f ∧ (∀ z, f z ∈ Set.Icc (0 : ℝ) B) ∧ Integrable f ξ ∧ + (∫ z, f z ∂ξ) = 1 ∧ + (realDensityMeasure μ (fun x => D (C x))).map F = realDensityMeasure ξ f ∧ + ∀ {I G : Type*} [Fintype G] + (frequency : G → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : G → ℂ) {η : ℝ}, + (∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) → + ∀ (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)), + (∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) → + ∀ (hm : ∀ j e, coefficients (p j) e ∈ U j) (b : Option K → I → ℝ), + ‖affineCubeFourierProjection U root difference frequency p c b - + (f (F (affineCoefficientCoverSample U p hm d b)) : ℂ)‖ ≤ η := by + obtain ⟨A, hA, hcover⟩ := exists_fixed_kernel_covered_density m q + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK hsite + obtain ⟨d, hd, hdb, hcover⟩ := hcover root₀ difference₀ a ha hperiod hP hK hsite + refine ⟨d, hd, hdb, ?_⟩ + intro K _ root difference e hroot hdifference J _ U _ _ _ _ _ μ _ _ ν _ _ D hD B hcap hmass F C ξ + have hfull := hperiod.trans (integerPeriod_range_le_of_columns + (Matrix.of difference₀) (Matrix.of difference) e hdifference) + obtain ⟨g, hgc, hgb, _, hgmass, hglaw, hgapprox⟩ := + hcover root difference e hroot hdifference U μ D hD hcap hmass + obtain ⟨hfc, hfb, hfi, hfmass, hvalue, hflaw⟩ := siteImage_density_euclideanJet U root + (Matrix.of difference) a ha hfull μ ν (realDensityMeasure μ (fun x => D (C x))) + g hgc hgb hgmass hglaw + refine ⟨_, hfc, hfb, hfi, hfmass, hflaw, ?_⟩ + intro I G _ frequency c η happrox p hp hm b + have he := hvalue (Set.rangeFactorization + (coefficientSiteTorusMap U (integerAffineCube root (Matrix.of difference))) + (affineCoefficientCoverSample U p hm d b)) + change (g ((euclideanSiteImageHomeomorph U root (Matrix.of difference) a ha hfull).symm + (F (affineCoefficientCoverSample U p hm d b)))) = _ at he + rw [he] + exact hgapprox frequency c happrox p hp hm b + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelGeometricCover.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelGeometricCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..114e78c8f2761095b74e073ac8f7b13acc51e7cf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelGeometricCover.lean @@ -0,0 +1,144 @@ +import OAI.Combinatorics.Progressions.Geometry.GeometricRetainedCommonCover + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial Polynomial +open scoped BigOperators Classical + +theorem exists_fixed_kernel_retained_common_cover (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] {q : ℕ} + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {H : ℕ} (_hH : 1 ≤ H) + (_hE : ∀ (j : Fin m) s d, RationalHeightLE + (boundedSiteMatrix (j.val + 1) (fun s k => affineSite root₀ difference₀ s (some k)) s d : ℚ) H) + {P : ℝ} (_hP : 0 ≤ P) + (_hD : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent K₀ (j.val + 1)) : ℝ) ≤ P) + (_hS : (Fintype.card (Finset (Fin q)) : ℝ) ≤ P) (_hHP : (H : ℝ) ≤ Real.exp P), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {K : Type*} [Fintype K] (root : K → ℤ) (difference : Fin q → K → ℤ) (e : K₀ → K) + (_hroot : ∀ k, root (e k) = root₀ k) (_hdifference : ∀ i k, difference i (e k) = difference₀ i k) + {J : Fin m → Type*} [∀ i, Fintype (J i)] + (U : ∀ i, Submodule ℝ (J i → ℝ)) (frequency : ∀ i, (K →₀ ℕ) → J i → ℤ) + {C : ℝ} (_hC : 0 ≤ C) (_hCP : C ≤ Real.exp P) + (_hfrequency : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, |(frequency j d a : ℝ)| ≤ C) + (_hretained : affineCubeModeFactors U root difference frequency), + ∃ b : ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ j s a, |(b j s a : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (j : Fin m) (p : VectorPolynomial K ℝ (U j)), DegreeLE (1 : K → ℕ) (j.val + 1) p → + CircleFourier.character + (coefficientFunctional (fun d a => (frequency j d a : ℝ)) (map (U j).subtype p) : CircleFourier.Circle) = + subspaceArrayCharacter (U j) (b j) + (QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j)) + ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p)) := by + obtain ⟨A₀, _, hcover⟩ := exists_fixed_kernel_polynomial_cover + obtain ⟨A, hA, hbudget⟩ := exists_natPolynomial_eval_budget (C (m + 1) * (X + C A₀) ^ A₀) + refine ⟨A, hA, ?_⟩ + intro K₀ _ q root₀ difference₀ a ha hperiod H hH hE P hP hD hS hHP + choose D hDpos hDP hrows using fun j : Fin m => + hcover root₀ (Matrix.of difference₀) a ha hperiod (j.val + 1) hH (hE j) hP (hD j) hS hHP + have hB : 0 ≤ (P + A₀) ^ A₀ := by positivity + have hbud : ((m : ℝ) + 1) * (P + A₀) ^ A₀ ≤ (P + A) ^ A := by + simpa [Polynomial.eval₂_pow] using hbudget P hP + have hprod : (((∏ j, D j) : ℕ) : ℝ) ≤ Real.exp ((m : ℝ) * (P + A₀) ^ A₀) := by + rw [Nat.cast_prod] + calc + _ ≤ ∏ _j : Fin m, Real.exp ((P + A₀) ^ A₀) := + Finset.prod_le_prod₀ (fun j _ => Nat.cast_nonneg _) (fun j _ => hDP j) + _ = _ := by + rw [Finset.prod_const, Finset.card_univ, Fintype.card_fin, ← Real.exp_nat_mul] + refine ⟨∏ j, D j, Finset.prod_pos (fun j _ => hDpos j), + hprod.trans (Real.exp_le_exp.mpr (by nlinarith)), ?_⟩ + intro K _ root difference e hroot hdifference J _ U frequency C hC hCP hfrequency hretained + choose M hM using fun j => affineCubeModeFactors_bounded U root difference frequency hretained j + choose b hb hchar using fun j => hrows j root (Matrix.of difference) e hroot hdifference + (U j) (frequency j) hC hCP (hfrequency j) (M j) (hM j) + refine ⟨(fun j s a => (complementaryPeriod D j : ℤ) * b j s a), ?_, ?_⟩ + · intro j s a + rw [Int.cast_mul, Int.cast_natCast, abs_mul, + abs_of_nonneg (show (0 : ℝ) ≤ complementaryPeriod D j from Nat.cast_nonneg _)] + calc + _ ≤ (complementaryPeriod D j : ℝ) * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_left (hb j s a) (Nat.cast_nonneg _) + _ ≤ (((∏ i, D i) : ℕ) : ℝ) * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (complementaryPeriod_le_product D hDpos j)) + (Real.exp_pos _).le + _ ≤ Real.exp ((m : ℝ) * (P + A₀) ^ A₀) * Real.exp ((P + A₀) ^ A₀) := + mul_le_mul_of_nonneg_right hprod (Real.exp_pos _).le + _ = Real.exp (((m : ℝ) + 1) * (P + A₀) ^ A₀) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp ((P + A) ^ A) := Real.exp_le_exp.mpr hbud + · intro j p hp + exact (hchar j p hp).trans (subspaceArrayCharacter_common_period D hDpos j (U j) (b j) + (VectorPolynomial.siteEvaluation (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p)).symm + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +theorem exists_fixed_kernel_geometric_cover (m q : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {K₀ : Type*} [Fintype K₀] + (root₀ : K₀ → ℤ) (difference₀ : Fin q → K₀ → ℤ) + (a : ℤ) (_ha : a ≠ 0) + (_hperiod : integerScalarLattice (Fin q) a ≤ (Matrix.of difference₀).mulVecLin.range) + {P : ℝ} (_hP : 0 ≤ P) (_hK : (Fintype.card K₀ : ℝ) ≤ P) + (_hsite : ∀ (s : Finset (Fin q)) k, + |((affineSite root₀ difference₀ s (some k) : ℤ) : ℝ)| ≤ Real.exp P), + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((P + A) ^ A) ∧ + ∀ {K : Type*} [Fintype K] (root : K → ℤ) (difference : Fin q → K → ℤ) (e : K₀ → K) + (_hroot : ∀ k, root (e k) = root₀ k) (_hdifference : ∀ i k, difference i (e k) = difference₀ i k) + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (frequency : ∀ j, (K →₀ ℕ) → J j → ℤ) + (_hfrequency : ∀ j d, d.degree ≤ j.val + 1 → ∀ a, + |(frequency j d a : ℝ)| ≤ Real.exp P) + (_hretained : affineCubeModeFactors U root difference frequency), + ∃ b : ∀ j, Matrix (Finset (Fin q)) (J j) ℤ, + (∀ j s a, |(b j s a : ℝ)| ≤ Real.exp ((P + A) ^ A)) ∧ + ∀ (j : Fin m) (p : VectorPolynomial K ℝ (U j)), + DegreeLE (1 : K → ℕ) (j.val + 1) p → + CircleFourier.character + (coefficientFunctional (fun d a => (frequency j d a : ℝ)) + (map (U j).subtype p) : CircleFourier.Circle) = + subspaceArrayCharacter (U j) (b j) + (QuotientAddGroup.mk' (subspaceArrayIntegerLattice (Finset (Fin q)) (U j)) + ((D : ℝ)⁻¹ • VectorPolynomial.siteEvaluation + (fun s k => ((affineSite root difference s (some k) : ℤ) : ℝ)) p)) := by + obtain ⟨A₀, _, hc⟩ := exists_fixed_kernel_retained_common_cover m + obtain ⟨A, hA, hb⟩ := exists_geometricSiteBudget_absorption m q A₀ + refine ⟨A, hA, ?_⟩ + intro K₀ _ root₀ difference₀ a ha hperiod P hP hK hsite + have hbudget := hb P hP + have hPP := le_geometricSiteBudget m q hP + obtain ⟨D, hD, hDP, hrows⟩ := hc root₀ difference₀ a ha hperiod + (exponentialSiteHeight_pos m P) + (fun j s d => boundedSiteMatrix_height_of_exp m (Nat.succ_le_of_lt j.isLt) + (fun s k => affineSite root₀ difference₀ s (some k)) hsite s d) + (geometricSiteBudget_nonneg m q hP) + (fun j => boundedCoefficientExponent_card_le_geometricSiteBudget m q + (Nat.succ_le_of_lt j.isLt) hP hK) + (cubeSites_card_le_geometricSiteBudget m q hP) + ((exponentialSiteHeight_le m hP).trans + (Real.exp_le_exp.mpr (degree_mul_le_geometricSiteBudget m q hP))) + refine ⟨D, hD, hDP.trans (Real.exp_le_exp.mpr hbudget), ?_⟩ + intro K _ root difference e hroot hdifference J _ U frequency hfrequency hretained + obtain ⟨b, hbnd, hchar⟩ := hrows root difference e hroot hdifference U frequency (Real.exp_pos P).le + (Real.exp_le_exp.mpr hPP) hfrequency hretained + exact ⟨b, fun j s a => (hbnd j s a).trans (Real.exp_le_exp.mpr hbudget), hchar⟩ + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelPatchFunction.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelPatchFunction.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc15be2a901db2be9bfe6f091af0e9c694cfbd4c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelPatchFunction.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialShearObservableNet +import OAI.Combinatorics.Progressions.Probability.ObservedProductDensity + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +namespace PolynomialSlots + +theorem loweringAt_patchValue {X : Type*} {d : ℕ} {w : Fin d → ℕ} + (A : PolynomialSlots X d w) (hw : Monotone w) (Φ : PatchKernel d) (t : X → ℝ) : + ((A.shearTransformedSlots hw (A.loweringAt t)).patchValue Φ) = (A.slots t).patchValue Φ := by + unfold TriangularSlots.patchValue + apply tsum_congr + intro b + congr 1 + rw [shearTransformedSlots_residual] + exact A.top_factorization_residual t b + +theorem exists_fixed_kernel_patch_function {X Ω T : Type*} [Fintype Ω] [Nonempty Ω] [Fintype T] + {d s N : ℕ} {w : Fin d → ℕ} + (A : Ω → PolynomialSlots X d w) (hw : Monotone w) + (hpos : ∀ i, 1 ≤ w i) (hs : ∀ i, w i ≤ s) (Φ : PatchKernel d) + {M : ℝ} (hM : 0 ≤ M) (hA : ∀ a i, realPolynomialMass ((A a).center i) ≤ M) + (hN : 0 < N) (hsmall : patchTopNetError d s N M < 1 / 4) + (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights T) (point : Ω → T → X → ℝ) + (score : Ω → T → ℝ) (hscore : ∀ a t, |score a t| ≤ 1) + {δ : ℝ} (_hδ : 0 < δ) + (hpositive : ∀ a ∈ productive, δ ≤ + (localLaw a).mean (fun t => score a t * ((A a).slots (point a t)).patchValue Φ)) + (herror : Φ.lip * patchTopNetError d s N M ≤ δ / 2) : + ∃ (B : PolynomialSlots X d w) (retained : Finset Ω), + (∀ i, realPolynomialMass (B.center i) ≤ M) ∧ + retained ⊆ productive ∧ + outer.mass productive / ((N + 1 : ℕ) : ℝ) ^ (d * (d + 1) ^ s) ≤ outer.mass retained ∧ + ∀ a ∈ retained, δ / 2 ≤ (localLaw a).mean (fun t => score a t * + (B.shearTransformedSlots hw ((A a).loweringAt (point a t))).patchValue Φ) := by + obtain ⟨code, rep, hnet⟩ := exists_shear_observable_net A hw hpos hs Φ hM hA hN hsmall + obtain ⟨i, hi⟩ := outer.exists_code_fiber_mass productive code + refine ⟨A (rep i), productive.filter (fun a => code a = i), hA _, Finset.filter_subset _ _, ?_, ?_⟩ + · have hcard : outer.mass productive / ((N + 1 : ℕ) : ℝ) ^ (d * (d + 1) ^ s) ≤ + outer.mass productive / Fintype.card (PatchTopCoefficientIndex d s → Fin (N + 1)) := by + apply div_le_div_of_nonneg_left (outer.mass_nonneg productive) + · exact_mod_cast Fintype.card_pos (α := PatchTopCoefficientIndex d s → Fin (N + 1)) + · exact_mod_cast patchTopCoefficientCode_card d s N + apply hcard.trans + convert hi using 1; try rfl + congr 1 + ext a + simp only [Finset.mem_filter] + · intro a ha + obtain ⟨ha, hcode⟩ := Finset.mem_filter.mp ha + have hclose (t : T) : + dist (((A a).slots (point a t)).patchValue Φ) + (((A (rep i)).shearTransformedSlots hw ((A a).loweringAt (point a t))).patchValue Φ) ≤ + Φ.lip * patchTopNetError d s N M := by + have h := hnet a ((A a).loweringAt (point a t)) + rw [hcode, loweringAt_patchValue] at h + exact h + let u := fun t => score a t * ((A a).slots (point a t)).patchValue Φ + let v := fun t => score a t * + ((A (rep i)).shearTransformedSlots hw ((A a).loweringAt (point a t))).patchValue Φ + have he : |(localLaw a).mean (fun t => u t - v t)| ≤ Φ.lip * patchTopNetError d s N M := by + apply (localLaw a).abs_mean_le_on_support + intro t _ + change |score a t * _ - score a t * _| ≤ _ + rw [← mul_sub, abs_mul] + exact (mul_le_mul_of_nonneg_right (hscore a t) (abs_nonneg _)).trans + (by simpa only [one_mul, Real.dist_eq] using hclose t) + rw [(localLaw a).mean_sub] at he + have hp := hpositive a ha + change δ ≤ (localLaw a).mean u at hp + change δ / 2 ≤ (localLaw a).mean v + linarith [le_abs_self ((localLaw a).mean u - (localLaw a).mean v)] + +end PolynomialSlots +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelSiteImage.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelSiteImage.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca067c3bbae6b64a726817c609068b1a59ecbc0c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedKernelSiteImage.lean @@ -0,0 +1,82 @@ +import OAI.Combinatorics.Progressions.Estimates.MixedBooleanSiteValues + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +theorem exists_matrix_factor_of_common_reconstruction {S J K I : Type*} + [Fintype S] [Fintype J] [Fintype K] [Fintype I] + (E₀ : Matrix S K ℝ) (E : Matrix S I ℝ) (B : Matrix S J ℝ) (T : Matrix J S ℝ) + (h₀ : B * T * E₀ = E₀) (hE : B * T * E = E) + (hs : Function.Surjective (Matrix.mulVec (T * E₀))) : + ∃ R : Matrix K I ℝ, E₀ * R = E := by + choose v hv using fun i : I => hs (fun j => (T * E) j i) + let R : Matrix K I ℝ := fun k i => v i k + have hr : (T * E₀) * R = T * E := by + ext j i + exact congrFun (hv i) j + refine ⟨R, ?_⟩ + calc + E₀ * R = (B * (T * E₀)) * R := by rw [← Matrix.mul_assoc, h₀] + _ = B * ((T * E₀) * R) := Matrix.mul_assoc _ _ _ + _ = B * (T * E) := by rw [hr] + _ = E := by rw [← Matrix.mul_assoc, hE] + +theorem boundedSiteMatrix_fixed_kernel_factor {α K I : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype I] + (root₀ : K → ℤ) (D₀ : Matrix α K ℤ) (a : ℤ) (ha : a ≠ 0) + (hperiod : integerScalarLattice α a ≤ D₀.mulVecLin.range) + (h : ℕ) (root : I → ℤ) (D : Matrix α I ℤ) : + ∃ R : Matrix (VectorPolynomial.BoundedCoefficientExponent K h) + (VectorPolynomial.BoundedCoefficientExponent I h) ℝ, + Matrix.of (fun s d => (VectorPolynomial.boundedSiteMatrix h (integerAffineCube root₀ D₀) s d : ℝ)) * R = + Matrix.of (fun s d => (VectorPolynomial.boundedSiteMatrix h (integerAffineCube root D) s d : ℝ)) := by + classical + let B := boundedBooleanReconstructionMatrix α h + let T := booleanJetExtractionMatrix (Subtype.val : BoundedBooleanJet α h → Finset α) + let E₀ := VectorPolynomial.boundedSiteMatrix h (integerAffineCube root₀ D₀) + let E := VectorPolynomial.boundedSiteMatrix h (integerAffineCube root D) + let B' := Matrix.of (fun s j => (B s j : ℝ)) + let T' := Matrix.of (fun j s => (T j s : ℝ)) + let E₀' := Matrix.of (fun s d => (E₀ s d : ℝ)) + let E' := Matrix.of (fun s d => (E s d : ℝ)) + have h₀ : B' * T' * E₀' = E₀' := by + ext s d + have hz := congrArg (fun z : ℤ => (z : ℝ)) + (congrFun (congrFun (boundedBooleanReconstruction_siteMatrix root₀ D₀ h) s) d) + simpa only [B', T', E₀', B, T, E₀, Matrix.mul_apply, Matrix.of_apply, + Int.cast_sum, Int.cast_mul] using hz + have hE : B' * T' * E' = E' := by + ext s d + have hz := congrArg (fun z : ℤ => (z : ℝ)) + (congrFun (congrFun (boundedBooleanReconstruction_siteMatrix root D h) s) d) + simpa only [B', T', E', B, T, E, Matrix.mul_apply, Matrix.of_apply, + Int.cast_sum, Int.cast_mul] using hz + have hjet : T' * E₀' = Matrix.of (fun j d => (boundedCoefficientJetMatrix root₀ D₀ h + (Subtype.val : BoundedBooleanJet α h → Finset α) j d : ℝ)) := by + ext j d + have hz := congrArg (fun z : ℤ => (z : ℝ)) + (congrFun (congrFun (booleanJetExtractionMatrix_mul_boundedSite root₀ D₀ h + (Subtype.val : BoundedBooleanJet α h → Finset α)) j) d) + simpa only [T', E₀', T, E₀, Matrix.mul_apply, Matrix.of_apply, Int.cast_sum, Int.cast_mul] using hz + apply exists_matrix_factor_of_common_reconstruction E₀' E' B' T' h₀ hE + rw [hjet] + intro v + obtain ⟨x, hx⟩ := matrixModuleAction_surjective_of_period (W := ℝ) + (boundedCoefficientJetMatrix root₀ D₀ h (Subtype.val : BoundedBooleanJet α h → Finset α)) + (a ^ h) (pow_ne_zero _ ha) + (boundedCoefficientJetMatrix_period root₀ D₀ a hperiod h + (Subtype.val : BoundedBooleanJet α h → Finset α) Subtype.val_injective (fun j => j.property)) v + refine ⟨x, ?_⟩ + ext j + exact congrFun hx j + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedObservableFamilyKernelProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedObservableFamilyKernelProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..9af3ecca3d7cb666e5f35b17a0a6080bd9d89645 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedObservableFamilyKernelProjection.lean @@ -0,0 +1,249 @@ +import OAI.Combinatorics.Progressions.Linear.ExternalFamilyPrecenterProjectionData + +namespace OAI + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_quantitative_kernel_projection_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ Ω G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (p : ℝ), 0 ≤ p → T.UnitIntervalValued → T.ComplexityLE p → + ∀ (P : Submodule ℚ L), P ≤ D.filtration.layer s → + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (path : Ω → G → D.Space) (weight : Ω → G → ℂ), + (∀ a x, ‖weight a x‖ ≤ Real.exp p) → + (∀ a ∈ productive, + Real.exp (-p) ≤ ((localLaw a).complexMean (fun x => weight a x * T.observable (path a x))).re) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (code : Fin (finrank ℚ P) → Option J) (S : D.Niltest w) (retained : Finset Ω), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j, (U j).ComplexityLE ((p + 2) ^ C) ∧ (U j).orbit = T.orbit) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) ∧ + S.UnitIntervalValued ∧ S.ComplexityLE ((p + 2) ^ C) ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ + ((localLaw a).complexMean (fun x => weight a x * S.observable (path a x))).re := by + let X : Polynomial ℕ := Polynomial.X + let Q := 2 * X + 8 + let A := (Q + 3) ^ 9 + 2 * Q + 2 + let V := 2 * A * (2 * A + 2) ^ 4 + ((2 * A + 2) ^ 4 + A + (Q + 3) ^ 5 + 2) ^ 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + (Q + 2 * V + X + 10 + X * (V + 1)) + refine ⟨C, hC, ?_⟩ + intro L σ Ω G _ _ s d _ _ _ _ _ _ D w T p hp hT hTc P hP outer productive localLaw path weight hweight hscore + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let q := 2 * p + 8 + let v := verticalDecompositionBudget q + have hq : 0 ≤ q := by dsimp [q]; linarith + have hpq : p ≤ q := by dsimp [q]; linarith + have hv : 0 ≤ v := verticalDecompositionBudget_nonneg hq + have hprod : 0 ≤ p * (v + 1) := by positivity + have hb : q + 2 * v + p + 10 + p * (v + 1) ≤ (p + 2) ^ C := by + simpa [X, Q, A, V, q, v, verticalDecompositionBudget, centralActionBudget, + Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + 2) ^ C := by linarith + have hvC : v ≤ (p + 2) ^ C := by linarith + have htC : p + v + 8 ≤ (p + 2) ^ C := by linarith + have hnC : p * (v + 1) ≤ (p + 2) ^ C := by linarith + have hsC : p + 1 ≤ (p + 2) ^ C := by linarith + obtain ⟨J, inst, eta, U, hJ, hheight, hU, hvert, hint, happrox, heval⟩ := + T.exists_vertical_decomposition_preserving_bounds hq (hTc.mono hpq) + (Real.exp_pos (-q)) (by rw [Real.exp_neg, inv_inv]) + let := inst + have hsmall := frequency_projection_error_bound hp hJ + obtain ⟨code, S, retained, hS, hSc, hSo, hSinv, hretained, hmass, hlocal⟩ := + T.exists_common_positive_kernel_projection hT hTc P hP eta U hvert outer productive + localLaw path weight (Real.exp_nonneg p) (Real.exp_nonneg (-(p + v + 8))) hweight + (fun x => by simpa only [norm_sub_rev] using happrox x) hscore hsmall + have hdim : (finrank ℚ P : ℝ) ≤ p := by + have h := Submodule.finrank_le P + rw [finrank_eq_card_basis D.basis, Fintype.card_fin] at h + exact (Nat.cast_le.mpr h).trans hTc.1.1 + refine ⟨J, inst, eta, U, code, S, retained, + hJ.trans (Real.exp_le_exp.mpr hvC), fun j i => (hheight j i).trans hvC, + fun j => ⟨(hU j).1.mono hqC, (hU j).2.1⟩, hvert, hS, + hSc.mono (hpq.trans hqC), hSo, hSinv, hretained, ?_, ?_⟩ + · exact (mass_div_frequency_count (outer.mass_nonneg productive) hp hv hdim hJ hnC).trans hmass + · intro a ha + obtain ⟨hpivot, hpositive⟩ := hlocal a ha + refine ⟨fun i j hij => (Real.exp_le_exp.mpr (neg_le_neg htC)).trans_lt (hpivot i j hij), ?_⟩ + exact ((Real.exp_le_exp.mpr (by linarith : -((p + 2) ^ C) ≤ -p - 1)).trans + (exp_sub_one_le_half_exp (-p))).trans hpositive + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_fixed_observable_family_kernel_projection : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ Ω G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (tests : Ω → D.Niltest w), + (∀ a, (tests a).observable = T.observable) → + ∀ p : ℝ, 0 ≤ p → T.UnitIntervalValued → T.ComplexityLE p → + ∀ (P : Submodule ℚ L), P ≤ D.filtration.layer s → + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (point : Ω → G → σ → ℤ) + (weight : Ω → G → ℂ), + (∀ a t, ‖weight a t‖ ≤ Real.exp p) → + (∀ a ∈ productive, Real.exp (-p) ≤ + ((localLaw a).complexMean (fun t => weight a t * (tests a).eval (point a t))).re) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (code : Fin (finrank ℚ P) → Option J) (S : D.Niltest w) (retained : Finset Ω), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j, (U j).ComplexityLE ((p + 2) ^ C) ∧ (U j).orbit = T.orbit) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j).observable x) ∧ + S.UnitIntervalValued ∧ S.ComplexityLE ((p + 2) ^ C) ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + (∀ a, (S.withOrbit (tests a).orbit).UnitIntervalValued ∧ + (S.withOrbit (tests a).orbit).ComplexityLE ((p + 2) ^ C) ∧ + (S.withOrbit (tests a).orbit).orbit = (tests a).orbit ∧ + (S.withOrbit (tests a).orbit).observable = S.observable) ∧ + (∀ a j, ((U j).withOrbit (tests a).orbit).ComplexityLE ((p + 2) ^ C) ∧ + ((U j).withOrbit (tests a).orbit).orbit = (tests a).orbit ∧ + ((U j).withOrbit (tests a).orbit).observable = (U j).observable) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun t => + weight a t * ((U j).withOrbit (tests a).orbit).eval (point a t))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ + ((localLaw a).complexMean (fun t => + weight a t * (S.withOrbit (tests a).orbit).eval (point a t))).re := by + obtain ⟨C, hC, hproject⟩ := exists_quantitative_kernel_projection_budget + refine ⟨C, hC, ?_⟩ + intro L σ Ω G _ _ s d _ _ _ _ _ _ D w T tests hobs p hp hT hTc P hP + outer productive localLaw point weight hweight hscore + let path : Ω → G → D.Space := fun a t => QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval w (point a t) (tests a).orbit) + have heval (a : Ω) (t : G) : (tests a).eval (point a t) = T.observable (path a t) := by + change (tests a).observable _ = T.observable _ + rw [hobs a] + obtain ⟨J, inst, eta, U, code, S, retained, hJ, heta, hU, hvert, + hS, hSc, hSo, hinvariant, hretained, hmass, hlocal⟩ := + hproject T p hp hT hTc P hP outer productive localLaw path weight hweight + (by simpa only [heval] using hscore) + let _ := inst + refine ⟨J, inst, eta, U, code, S, retained, hJ, heta, hU, hvert, + hS, hSc, hSo, hinvariant, ?_, ?_, hretained, hmass, ?_⟩ + · intro a + exact ⟨hS, hSc, rfl, rfl⟩ + · intro a j + exact ⟨(hU j).1, rfl, rfl⟩ + · intro a ha + exact hlocal a ha + +theorem exists_fixed_observable_family_kernel_projection_real : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ Ω G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (F : D.Space → ℂ) (tests : Ω → D.Niltest w) (p : ℝ), 0 ≤ p → + (∀ a, (tests a).observable = F ∧ (tests a).UnitIntervalValued ∧ + (tests a).ComplexityLE p) → + ∀ (P : Submodule ℚ L), P ≤ D.filtration.layer s → + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (point : Ω → G → σ → ℤ) + (score : Ω → G → ℝ), + (∀ a t, |score a t| ≤ 1) → + (∀ a ∈ productive, Real.exp (-p) ≤ + (localLaw a).mean (fun t => score a t * ((tests a).eval (point a t)).re)) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (code : Fin (finrank ℚ P) → Option J) (S : D.Niltest w) (retained : Finset Ω), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j, (U j).ComplexityLE ((p + 2) ^ C)) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j).observable x) ∧ + S.UnitIntervalValued ∧ S.ComplexityLE ((p + 2) ^ C) ∧ + (∀ z : D.RealGroup, z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + (∀ a, (S.withOrbit (tests a).orbit).UnitIntervalValued ∧ + (S.withOrbit (tests a).orbit).ComplexityLE ((p + 2) ^ C) ∧ + (S.withOrbit (tests a).orbit).orbit = (tests a).orbit ∧ + (S.withOrbit (tests a).orbit).observable = S.observable) ∧ + (∀ a j, ((U j).withOrbit (tests a).orbit).ComplexityLE ((p + 2) ^ C) ∧ + ((U j).withOrbit (tests a).orbit).orbit = (tests a).orbit ∧ + ((U j).withOrbit (tests a).orbit).observable = (U j).observable) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun t => + (score a t : ℂ) * ((U j).withOrbit (tests a).orbit).eval (point a t))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ (localLaw a).mean (fun t => + score a t * ((S.withOrbit (tests a).orbit).eval (point a t)).re) := by + obtain ⟨C, hC, hproject⟩ := exists_fixed_observable_family_kernel_projection + refine ⟨C, hC, ?_⟩ + intro L σ Ω G _ _ s d _ _ _ _ _ _ D w F tests p hp htests P hP + outer productive localLaw point score hscore hpositive + have hnonempty : Nonempty Ω := by + by_contra h + have _ : IsEmpty Ω := not_nonempty_iff.mp h + simpa using outer.total + let a₀ : Ω := Classical.choice hnonempty + have hobs (a : Ω) : (tests a).observable = (tests a₀).observable := + (htests a).1.trans (htests a₀).1.symm + have hweight (a : Ω) (t : G) : ‖(score a t : ℂ)‖ ≤ Real.exp p := by + simpa only [Complex.norm_real, Real.norm_eq_abs] using + (hscore a t).trans (Real.one_le_exp hp) + have hpositive' (a : Ω) (ha : a ∈ productive) : Real.exp (-p) ≤ + ((localLaw a).complexMean (fun t => + (score a t : ℂ) * (tests a).eval (point a t))).re := by + simpa only [FiniteProbabilityWeights.complexMean_re, Complex.re_ofReal_mul] using + hpositive a ha + obtain ⟨J, inst, eta, U, code, S, retained, hJ, heta, hU, hvert, + hS, hSc, _, hinvariant, hSloc, hUloc, hretained, hmass, hlocal⟩ := + hproject (tests a₀) tests hobs p hp (htests a₀).2.1 (htests a₀).2.2 + P hP outer productive localLaw point (fun a t => (score a t : ℂ)) hweight hpositive' + let _ := inst + refine ⟨J, inst, eta, U, code, S, retained, hJ, heta, fun j => (hU j).1, + hvert, hS, hSc, hinvariant, hSloc, hUloc, hretained, hmass, ?_⟩ + intro a ha + refine ⟨(hlocal a ha).1, ?_⟩ + simpa only [FiniteProbabilityWeights.complexMean_re, Complex.re_ofReal_mul] using + (hlocal a ha).2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedObservableFamilyKernelProjectionIdentity.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedObservableFamilyKernelProjectionIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..9783d40d2bc7043d3b672b69dbeb43890928fab0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedObservableFamilyKernelProjectionIdentity.lean @@ -0,0 +1,255 @@ +import OAI.Combinatorics.Progressions.Linear.ExternalFamilyPrecenterProjectionData + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_common_positive_kernel_projection_with_identity + {L σ Ω G J : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] [Fintype J] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (hT : T.UnitIntervalValued) {p : ℝ} (hTc : T.ComplexityLE p) + (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s) + (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (hvertical : ∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) + (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (path : Ω → G → D.Space) (weight : Ω → G → ℂ) + {B rho tau delta : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) + (hweight : ∀ a x, ‖weight a x‖ ≤ B) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (hscore : ∀ a ∈ productive, + delta ≤ ((localLaw a).complexMean (fun x => weight a x * T.observable (path a x))).re) + (hsmall : 2 * B * rho + Fintype.card J * tau ≤ delta / 2) : + ∃ (code : Fin (finrank ℚ P) → Option J) (S : D.Niltest w) (retained : Finset Ω), + S = T.kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP) ∧ + S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive / (Fintype.card J + 1) ^ finrank ℚ P ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → + tau < ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖) ∧ + delta / 2 ≤ ((localLaw a).complexMean (fun x => weight a x * S.observable (path a x))).re := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let js : Ω → List J := fun a => (Finset.univ.filter (fun j => + tau < ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖)).toList + obtain ⟨code, retained, hretained, hmass, hcode⟩ := + exists_common_frequency_kernel outer productive P eta js + let K := frequencyCodeKernel P eta code + have hK : K ≤ D.filtration.layer s := + (finiteFrequencyKernel_le P _ _).trans hP + let S := T.kernelProjection K hK + refine ⟨code, S, retained, rfl, T.kernelProjection_unitInterval K hK hT, + T.kernelProjection_complexity K hK hTc, T.kernelProjection_orbit K hK, + ?_, hretained, hmass, ?_⟩ + · intro z hz x + exact T.kernelProjection_invariant K hK z hz x + · intro a ha + obtain ⟨hpivots, hk⟩ := hcode a ha + have hsignificant (j : J) + (hj : tau < ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖) : + j ∈ js a := by simpa only [js, Finset.mem_toList, Finset.mem_filter, Finset.mem_univ, true_and] using hj + have herr := T.kernelProjection_tested_error P hP eta U hvertical (localLaw a) + (path a) (weight a) hB htau (hweight a) happrox (js a) hsignificant + rw [T.kernelProjection_congr _ hK hk] at herr + refine ⟨?_, ?_⟩ + · intro i j hij + simpa only [js, Finset.mem_toList, Finset.mem_filter, Finset.mem_univ, true_and] using hpivots i j hij + · have hr := Complex.re_le_norm + ((localLaw a).complexMean (fun x => weight a x * T.observable (path a x)) - + (localLaw a).complexMean (fun x => weight a x * S.observable (path a x))) + rw [Complex.sub_re] at hr + have hs := hscore a (hretained ha) + change ‖(localLaw a).complexMean (fun x => weight a x * T.observable (path a x)) - + (localLaw a).complexMean (fun x => weight a x * S.observable (path a x))‖ ≤ _ at herr + linarith + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_quantitative_kernel_projection_budget_with_identity : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ Ω G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (p : ℝ), 0 ≤ p → T.UnitIntervalValued → T.ComplexityLE p → + ∀ (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s), + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (path : Ω → G → D.Space) (weight : Ω → G → ℂ), + (∀ a x, ‖weight a x‖ ≤ Real.exp p) → + (∀ a ∈ productive, + Real.exp (-p) ≤ ((localLaw a).complexMean (fun x => weight a x * T.observable (path a x))).re) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (code : Fin (finrank ℚ P) → Option J) (S : D.Niltest w) (retained : Finset Ω), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j, (U j).ComplexityLE ((p + 2) ^ C) ∧ (U j).orbit = T.orbit) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) ∧ + S.UnitIntervalValued ∧ S.ComplexityLE ((p + 2) ^ C) ∧ S.orbit = T.orbit ∧ + S = T.kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP) ∧ + (∀ z : D.RealGroup, z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun x => weight a x * (U j).observable (path a x))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ + ((localLaw a).complexMean (fun x => weight a x * S.observable (path a x))).re := by + let X : Polynomial ℕ := Polynomial.X + let Q := 2 * X + 8 + let A := (Q + 3) ^ 9 + 2 * Q + 2 + let V := 2 * A * (2 * A + 2) ^ 4 + ((2 * A + 2) ^ 4 + A + (Q + 3) ^ 5 + 2) ^ 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + (Q + 2 * V + X + 10 + X * (V + 1)) + refine ⟨C, hC, ?_⟩ + intro L σ Ω G _ _ s d _ _ _ _ _ _ D w T p hp hT hTc P hP outer productive localLaw path weight hweight hscore + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let q := 2 * p + 8 + let v := verticalDecompositionBudget q + have hq : 0 ≤ q := by dsimp [q]; linarith + have hpq : p ≤ q := by dsimp [q]; linarith + have hv : 0 ≤ v := verticalDecompositionBudget_nonneg hq + have hprod : 0 ≤ p * (v + 1) := by positivity + have hb : q + 2 * v + p + 10 + p * (v + 1) ≤ (p + 2) ^ C := by + simpa [X, Q, A, V, q, v, verticalDecompositionBudget, centralActionBudget, + Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + 2) ^ C := by linarith + have hvC : v ≤ (p + 2) ^ C := by linarith + have htC : p + v + 8 ≤ (p + 2) ^ C := by linarith + have hnC : p * (v + 1) ≤ (p + 2) ^ C := by linarith + have hsC : p + 1 ≤ (p + 2) ^ C := by linarith + obtain ⟨J, inst, eta, U, hJ, hheight, hU, hvert, hint, happrox, heval⟩ := + T.exists_vertical_decomposition_preserving_bounds hq (hTc.mono hpq) + (Real.exp_pos (-q)) (by rw [Real.exp_neg, inv_inv]) + let _ := inst + have hsmall := frequency_projection_error_bound hp hJ + obtain ⟨code, S, retained, hidentity, hS, hSc, hSo, hSinv, hretained, hmass, hlocal⟩ := + T.exists_common_positive_kernel_projection_with_identity hT hTc P hP eta U hvert outer productive + localLaw path weight (Real.exp_nonneg p) (Real.exp_nonneg (-(p + v + 8))) hweight + (fun x => by simpa only [norm_sub_rev] using happrox x) hscore hsmall + have hdim : (finrank ℚ P : ℝ) ≤ p := by + have h := Submodule.finrank_le P + rw [finrank_eq_card_basis D.basis, Fintype.card_fin] at h + exact (Nat.cast_le.mpr h).trans hTc.1.1 + refine ⟨J, inst, eta, U, code, S, retained, + hJ.trans (Real.exp_le_exp.mpr hvC), fun j i => (hheight j i).trans hvC, + fun j => ⟨(hU j).1.mono hqC, (hU j).2.1⟩, hvert, hS, + hSc.mono (hpq.trans hqC), hSo, hidentity, hSinv, hretained, ?_, ?_⟩ + · exact (mass_div_frequency_count (outer.mass_nonneg productive) hp hv hdim hJ hnC).trans hmass + · intro a ha + obtain ⟨hpivot, hpositive⟩ := hlocal a ha + refine ⟨fun i j hij => (Real.exp_le_exp.mpr (neg_le_neg htC)).trans_lt (hpivot i j hij), ?_⟩ + exact ((Real.exp_le_exp.mpr (by linarith : -((p + 2) ^ C) ≤ -p - 1)).trans + (exp_sub_one_le_half_exp (-p))).trans hpositive + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators Classical + +theorem exists_fixed_observable_family_kernel_projection_with_identity : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ Ω G : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype G] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (tests : Ω → D.Niltest w), + (∀ a, (tests a).observable = T.observable) → + ∀ p : ℝ, 0 ≤ p → T.UnitIntervalValued → T.ComplexityLE p → + ∀ (P : Submodule ℚ L) (hP : P ≤ D.filtration.layer s), + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights G) (point : Ω → G → σ → ℤ) + (weight : Ω → G → ℂ), + (∀ a t, ‖weight a t‖ ≤ Real.exp p) → + (∀ a ∈ productive, Real.exp (-p) ≤ + ((localLaw a).complexMean (fun t => weight a t * (tests a).eval (point a t))).re) → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (code : Fin (finrank ℚ P) → Option J) (S : D.Niltest w) (retained : Finset Ω), + (Fintype.card J : ℝ) ≤ Real.exp ((p + 2) ^ C) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + 2) ^ C) ∧ + (∀ j, (U j).ComplexityLE ((p + 2) ^ C) ∧ (U j).orbit = T.orbit) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * + (U j).observable x) ∧ + S.UnitIntervalValued ∧ S.ComplexityLE ((p + 2) ^ C) ∧ S.orbit = T.orbit ∧ + S = T.kernelProjection (frequencyCodeKernel P eta code) + ((finiteFrequencyKernel_le P _ _).trans hP) ∧ + (∀ z : D.RealGroup, z.coord ∈ (frequencyCodeKernel P eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + (∀ a, (S.withOrbit (tests a).orbit).UnitIntervalValued ∧ + (S.withOrbit (tests a).orbit).ComplexityLE ((p + 2) ^ C) ∧ + (S.withOrbit (tests a).orbit).orbit = (tests a).orbit ∧ + (S.withOrbit (tests a).orbit).observable = S.observable) ∧ + (∀ a j, ((U j).withOrbit (tests a).orbit).ComplexityLE ((p + 2) ^ C) ∧ + ((U j).withOrbit (tests a).orbit).orbit = (tests a).orbit ∧ + ((U j).withOrbit (tests a).orbit).observable = (U j).observable) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, + (∀ i j, code i = some j → Real.exp (-((p + 2) ^ C)) < + ‖(localLaw a).complexMean (fun t => + weight a t * ((U j).withOrbit (tests a).orbit).eval (point a t))‖) ∧ + Real.exp (-((p + 2) ^ C)) ≤ + ((localLaw a).complexMean (fun t => + weight a t * (S.withOrbit (tests a).orbit).eval (point a t))).re := by + obtain ⟨C, hC, hproject⟩ := exists_quantitative_kernel_projection_budget_with_identity + refine ⟨C, hC, ?_⟩ + intro L σ Ω G _ _ s d _ _ _ _ _ _ D w T tests hobs p hp hT hTc P hP + outer productive localLaw point weight hweight hscore + let path : Ω → G → D.Space := fun a t => QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval w (point a t) (tests a).orbit) + have heval (a : Ω) (t : G) : (tests a).eval (point a t) = T.observable (path a t) := by + change (tests a).observable _ = T.observable _ + rw [hobs a] + obtain ⟨J, inst, eta, U, code, S, retained, hJ, heta, hU, hvert, + hS, hSc, hSo, hidentity, hinvariant, hretained, hmass, hlocal⟩ := + hproject T p hp hT hTc P hP outer productive localLaw path weight hweight + (by simpa only [heval] using hscore) + let _ := inst + refine ⟨J, inst, eta, U, code, S, retained, hJ, heta, hU, hvert, + hS, hSc, hSo, hidentity, hinvariant, ?_, ?_, hretained, hmass, ?_⟩ + · intro a + exact ⟨hS, hSc, rfl, rfl⟩ + · intro a j + exact ⟨(hU j).1, rfl, rfl⟩ + · intro a ha + exact hlocal a ha + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedSpatialKernelNativeHaarJointMean.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedSpatialKernelNativeHaarJointMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ff2f185070870cf2f883261889a560f120116a5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedSpatialKernelNativeHaarJointMean.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.Progressions.Sampling.ForecastOriginalNativeHaarJointMean + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical NNReal Matrix + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +local notation "short" => allocatedShortAxis (I := I) U basis S.value +local notation "Spatial" => (Σ _ : X, Unit ⊕ Empty) +local notation "Active" => (Σ _a : {a : LayerSamplerAxis I n // ¬short a}, Unit) +local notation "Principal" => PrincipalIntegerTuples B (layerSamplerDegree I n) Empty + (allocatedPrincipalSides B U basis S) +local notation "law" => principalTupleWeights (α := Empty) B (layerSamplerDegree I n) + (allocatedPrincipalSides B U basis S) (allocatedPrincipalSides_pos B U basis S) +local notation "single" => (fun _ : Fin m => Unit) + +local notation "selected" => allocatedShortIntegerSelection U basis S.value +variable (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) +variable (x : G → IntegerScalarCubeBox Empty S.value) +variable {Ω : Type*} [Fintype Ω] {Eout : Fin m → Type*} [∀ j, Fintype (Eout j)] +local notation "Out" => Sigma (AllocatedCongruenceRankOutput X Eout short) +variable (active : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty + (allocatedPrincipalSides B U basis S) → FiniteProbabilityWeights Ω) +variable (Y : PrincipalIntegerTuples B (layerSamplerDegree I n) Empty + (allocatedPrincipalSides B U basis S) → Ω → + Sigma (AllocatedCongruenceRankOutput X Eout (allocatedShortAxis (I := I) U basis S.value)) → ℤ) +variable (N : ℕ) [NeZero N] (volume : ℝ) +variable (base : X → ℤ) (physicalN : X → ℕ) (τ : ℝ) + +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + +variable (hb : ∀ j, Submodule.span ℤ (Set.range (basis j)) = + projectedIntegerLattice (euclideanSubspace (U j))) +variable (bW : ∀ j, Module.Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable {pw cw : ℝ} {Lw : ℝ≥0} +variable (Wtest : NormalizedPolynomialTwist X (Σ j, J j) pw cw Lw) +local notation "raw" => mixedCoveredJetRawReference (I := I) (O := single) (E := Eout) (n := n) N +local notation "RawSource" => MixedCoveredJetSource I single Eout n N + +section FixedSpatialKernelDensity + +variable [DecidableEq X] +variable {T : Type*} [Fintype T] +variable (e : G ≃ X ⊕ (X ⊕ T)) (Wgeo Lgeo : ℝ) (z : Option G × X → ℝ) +variable (h0 : (fixedSpatialKernelBlock e Wgeo Lgeo z false).det ≠ 0) + (h1 : (fixedSpatialKernelBlock e Wgeo Lgeo z true).det ≠ 0) +variable (hB : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis (I := I) U basis S.value a}, + 4 ≤ Fintype.card (B a.val)) + (lower width : ∀ a : {a : LayerSamplerAxis I n // ¬allocatedShortAxis (I := I) U basis S.value a}, + B a.val × Fin (layerSamplerDegree I n a.val) → ℝ) +local notation "original" => fixedSpatialKernelOriginalForecastDensity + B U basis S e Wgeo Lgeo z h0 h1 hB lower width sample + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) + (euclideanSubspace (U j)))] +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] +local notation "originalSource" => forecastDensityPhysicalChartSource B U basis S original selected + sample x active Y N volume base physicalN τ +local notation "chart" => mixedCoveredJetChart (O := single) U o basis hb bW N +local notation "region" => mixedCoveredJetRegion (O := single) (E := Eout) U o basis N + (fun j (_ : Unit) => standardLatticeClosedQuarterBox (J j)) +local notation "haar" => Measure.pi (fun j => Measure.pi (fun _ : Unit => ν j)) + +theorem fixedSpatialKernelNativeHaarMean_eq_jointMean + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + (hs : ∀ j, mixedArraySupported (allocatedLayerCenters B U basis S j) + (allocatedLayerWidths B U basis S j) + (allocatedLayerIntegerPMFs B U basis hR hσ S j) (sample j)) + (hσ1 : ∀ a : AllocatedShortIntegerAxis U basis S.value, σ a.val.1 ≤ 1) + (r : ℝ≥0) (hr : 0 < r) (hr3 : (3 : ℝ) ≤ r) + (hradius : ∀ j : Fin m, (Fintype.card (BoundedCoefficientExponent + (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ r) + (C : Fin m → ℝ) (hC : ∀ j, 0 ≤ C j) + (hchart : ∀ j v, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (basis j)).symm v‖ ≤ + C j * ‖v‖) + (hbudget : ∀ j, C j * (((Fintype.card (I j) : ℝ) + 1) * (2 * (r : ℝ) * R j)) ≤ 1 / 4) + {δ : ℝ} (hδ : 0 < δ) + (hw : ∀ a p, δ ≤ width a p) (hl : ∀ a p, 0 ≤ lower a p) + (hwidth : ∀ a p, |lower a p| + |width a p| ≤ 1) + (hW : 0 ≤ Wgeo) (hL : 0 ≤ Lgeo) + (hsize : (Fintype.card G : ℝ) * Lgeo ≤ Wgeo) + (hz : ∀ a, |z a| ≤ 1) + (hN : ∀ i, 0 < physicalN i) (hτ : 0 < τ) + (hmargin : ∀ i, 2 * spatialTrimMargin τ physicalN i ≤ physicalN i) + (hbase : base ∈ trimmedIntegerBox physicalN (spatialTrimMargin τ physicalN)) + (q : ℕ) [NeZero q] (hq : q ∣ N) (hm : 0 < m) + (hperiod : Wtest.modulus ∣ q) (hcover : Wtest.cover ∣ q) (hV : 0 < volume) : + (forecastGeometricJacobian (X := X) (I := I) U basis R S.value volume τ : ℂ) * + (𝔼 u ∈ integerBox physicalN, + ∫ y, restrictedComplexChartDensity chart region 1 (originalSource u) y * + nativeSingleSiteCoverObservable U Wtest physicalN u N y ∂haar) = + forecastJointOriginalGridMean U basis S.value hm law active + (forecastInactiveFixedOutput B U basis S selected + (allocatedOriginalSampleInactiveCoefficients B selected sample) x) + Y N q hq volume original + (Wtest.forecastShortGridTest U basis S.value hb o bW R q hm hperiod hcover + (fun x => (base x : ℝ) / physicalN x) τ) + (fun j => (forecastJointGridCenter U basis S.value base j : ℝ)) + (forecastJointGridScale U basis R S.value physicalN τ) := by + have hdensity := (fixedSpatialKernelOriginalForecastDensity_bounds B U basis hR hσ S + e Wgeo Lgeo z h0 h1 hB lower width hδ hw hl sample hs).2.continuous + have hsupport := fixedSpatialKernelOriginalForecastDensity_zero_of_norm_gt_two + B U basis hR hσ S e Wgeo Lgeo z h0 h1 hB lower width hδ hw hl sample hs + hwidth hW hL hsize hz + exact forecastNativeHaarMean_eq_jointMean B U basis S original sample x active Y N volume + base physicalN τ o hb bW Wtest ν hR hσ hs hσ1 r hr hr3 hradius C hC hchart hbudget + hdensity hsupport hN hτ hmargin hbase q hq hm hperiod hcover hV + +end FixedSpatialKernelDensity +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FixedSpatialKernelSliceDensity.lean b/lean/OAI/Combinatorics/Progressions/Linear/FixedSpatialKernelSliceDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..53a73a14c14438b51eeb6ac83bd62190384452a9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FixedSpatialKernelSliceDensity.lean @@ -0,0 +1,414 @@ +import OAI.Combinatorics.Progressions.Linear.ContainedKernelPhysicalDisplacement + +namespace OAI + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators Classical NNReal +variable {G X T : Type*} [Fintype G] [Fintype X] [DecidableEq X] [Fintype T] +variable (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) (z : Option G × X → ℝ) + +noncomputable def fixedSpatialKernelBlockEquiv (b : Bool) + (h : (fixedSpatialKernelBlock e W L z b).det ≠ 0) : (X → ℝ) ≃L[ℝ] (X → ℝ) := + Classical.choose (matrixSupCLM_inverse_spec (fixedSpatialKernelBlock e W L z b) h).1 + +omit [Fintype G] [Fintype T] in +theorem fixedSpatialKernelBlockEquiv_coe (b : Bool) + (h : (fixedSpatialKernelBlock e W L z b).det ≠ 0) : + (fixedSpatialKernelBlockEquiv e W L z b h).toContinuousLinearMap = + matrixSupCLM (fixedSpatialKernelBlock e W L z b) := + Classical.choose_spec (matrixSupCLM_inverse_spec (fixedSpatialKernelBlock e W L z b) h).1 + +omit [Fintype G] [Fintype T] in +theorem fixedSpatialKernelBlockEquiv_apply (b : Bool) + (h : (fixedSpatialKernelBlock e W L z b).det ≠ 0) (t : X → ℝ) : + fixedSpatialKernelBlockEquiv e W L z b h t = + (fixedSpatialKernelBlock e W L z b).mulVec t := + congrArg (fun f : (X → ℝ) →L[ℝ] (X → ℝ) => f t) + (fixedSpatialKernelBlockEquiv_coe e W L z b h) + +omit [Fintype G] [Fintype T] in +theorem fixedSpatialKernelBlockEquiv_jacobian (b : Bool) + (h : (fixedSpatialKernelBlock e W L z b).det ≠ 0) : + inverseJacobian (fixedSpatialKernelBlockEquiv e W L z b h) = + |(fixedSpatialKernelBlock e W L z b).det|⁻¹ := by + rw [inverseJacobian_eq] + congr 2 + change LinearMap.det (fixedSpatialKernelBlockEquiv e W L z b h).toContinuousLinearMap.toLinearMap = _ + rw [fixedSpatialKernelBlockEquiv_coe] + exact LinearMap.det_toLin' _ + +variable (h0 : (fixedSpatialKernelBlock e W L z false).det ≠ 0) + (h1 : (fixedSpatialKernelBlock e W L z true).det ≠ 0) + +noncomputable def fixedSpatialKernelDensity : (X → ℝ) → ℝ := + fixedSpatialBlockDensity (unitBoxMeasure T) (fun x => z (none,x)) + (fixedSpatialKernelRest e W L z) + (fixedSpatialKernelBlockEquiv e W L z false h0) + (fixedSpatialKernelBlockEquiv e W L z true h1) + +omit [Fintype G] in +theorem fixedSpatialKernelDensity_bounds : + (∀ x, fixedSpatialKernelDensity e W L z h0 h1 x ∈ Set.Icc (0 : ℝ) + (fixedSpatialBlockDensityCap (fixedSpatialKernelBlockEquiv e W L z true h1))) ∧ + LipschitzWith (fixedSpatialBlockDensityLipschitz + (fixedSpatialKernelBlockEquiv e W L z false h0) + (fixedSpatialKernelBlockEquiv e W L z true h1)) + (fixedSpatialKernelDensity e W L z h0 h1) := + fixedSpatialBlockDensity_bounds (unitBoxMeasure T) _ + (fixedSpatialKernelRest_measurable e W L z) _ _ + +omit [Fintype G] in +theorem fixedSpatialKernelDensity_probability_density : + (∀ x, 0 ≤ fixedSpatialKernelDensity e W L z h0 h1 x) ∧ + Integrable (fixedSpatialKernelDensity e W L z h0 h1) ∧ + (∫ x, fixedSpatialKernelDensity e W L z h0 h1 x) = 1 := + fixedSpatialBlockDensity_probability_density (unitBoxMeasure T) _ + (fixedSpatialKernelRest_measurable e W L z) _ _ + +omit [Fintype G] in +theorem fixedSpatialKernelDensity_probability : + IsProbabilityMeasure (realDensityMeasure volume (fixedSpatialKernelDensity e W L z h0 h1)) := + fixedSpatialBlockDensity_probability (unitBoxMeasure T) _ + (fixedSpatialKernelRest_measurable e W L z) _ _ + +theorem fixedSpatialKernelDensity_image_law : + (unitBoxMeasure G).map (fun t x => fixedSpatialKernelMap W L z t ⟨x, .inl ()⟩) = + realDensityMeasure volume (fixedSpatialKernelDensity e W L z h0 h1) := + fixedSpatialKernelMap_block_image_law e W L z _ _ + (fixedSpatialKernelBlockEquiv_apply e W L z false h0) + (fixedSpatialKernelBlockEquiv_apply e W L z true h1) + +omit [Fintype G] in +theorem fixedSpatialKernelDensity_bounds_of_det + {H κ0 κ1 : ℝ} (hH : 0 ≤ H) (hκ0 : 0 < κ0) (hκ1 : 0 < κ1) + (hentry : ∀ i j, |fixedSpatialKernelBlock e W L z false i j| ≤ H) + (hdet0 : κ0 ≤ |(fixedSpatialKernelBlock e W L z false).det|) + (hdet1 : κ1 ≤ |(fixedSpatialKernelBlock e W L z true).det|) : + (∀ x, fixedSpatialKernelDensity e W L z h0 h1 x ∈ Set.Icc (0 : ℝ) κ1⁻¹) ∧ + LipschitzWith + (2 * (Fintype.card X : ℝ≥0) * Real.toNNReal (κ1⁻¹) * + Real.toNNReal (Fintype.card X * ((Fintype.card X).factorial * + H ^ (Fintype.card X - 1) / κ0))) + (fixedSpatialKernelDensity e W L z h0 h1) := by + have hcap : inverseJacobian (fixedSpatialKernelBlockEquiv e W L z true h1) ≤ κ1⁻¹ := by + rw [fixedSpatialKernelBlockEquiv_jacobian] + exact inv_anti₀ hκ1 hdet1 + have hnorm : ‖(fixedSpatialKernelBlockEquiv e W L z false h0).symm.toContinuousLinearMap‖ ≤ + Fintype.card X * ((Fintype.card X).factorial * H ^ (Fintype.card X - 1) / κ0) := by + have h := (matrixSupCLM_inverse_norm_le (fixedSpatialKernelBlock e W L z false) + hH hentry hκ0 hdet0).2 + rw [← fixedSpatialKernelBlockEquiv_coe e W L z false h0, + ContinuousLinearMap.inverse_equiv] at h + exact h + have h := fixedSpatialBlockDensity_bounds_of_inverseBounds (unitBoxMeasure T) + (fun x => z (none,x)) (fixedSpatialKernelRest_measurable e W L z) + (fixedSpatialKernelBlockEquiv e W L z false h0) + (fixedSpatialKernelBlockEquiv e W L z true h1) + (Real.toNNReal (κ1⁻¹)) + (Real.toNNReal (Fintype.card X * ((Fintype.card X).factorial * H ^ (Fintype.card X - 1) / κ0))) + (by simpa only [Real.coe_toNNReal _ (inv_nonneg.mpr hκ1.le)] using hcap) + (by simpa only [Real.coe_toNNReal _ (by positivity : (0 : ℝ) ≤ Fintype.card X * + ((Fintype.card X).factorial * H ^ (Fintype.card X - 1) / κ0))] using hnorm) + simpa only [fixedSpatialKernelDensity, Real.coe_toNNReal _ (inv_nonneg.mpr hκ1.le)] using h + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators Classical NNReal +variable {G X : Type*} [Fintype G] [Fintype X] + +theorem fixedSpatialKernelMap_norm_le_two {W L : ℝ} + (hW : 0 ≤ W) (hL : 0 ≤ L) (hsize : (Fintype.card G : ℝ) * L ≤ W) + (z : Option G × X → ℝ) (hz : ∀ a, |z a| ≤ 1) + (t : G → ℝ) (ht : ‖t‖ ≤ 1) : + ‖fixedSpatialKernelMap W L z t‖ ≤ 2 := by + have hLip := fixedSpatialKernelMap_lipschitz_one hW hL hsize z (fun g x => hz (some g,x)) + have hd : dist (fixedSpatialKernelMap W L z t) (fixedSpatialKernelMap W L z 0) ≤ 1 := by + have h := hLip.dist_le_mul t 0 + simp only [NNReal.coe_one, one_mul, dist_zero_right] at h + exact h.trans ht + have hzero : ‖fixedSpatialKernelMap W L z 0‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro a + simpa only [fixedSpatialKernelMap, Pi.zero_apply, mul_zero, Finset.sum_const_zero, + add_zero, Real.norm_eq_abs] using hz (none,a.1) + calc + _ ≤ ‖fixedSpatialKernelMap W L z t - fixedSpatialKernelMap W L z 0‖ + + ‖fixedSpatialKernelMap W L z 0‖ := norm_le_norm_sub_add _ _ + _ ≤ 1 + 1 := add_le_add (by simpa only [dist_eq_norm] using hd) hzero + _ = 2 := by norm_num + +variable {T : Type*} [Fintype T] [DecidableEq X] +variable (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) (z : Option G × X → ℝ) +variable (h0 : (fixedSpatialKernelBlock e W L z false).det ≠ 0) + (h1 : (fixedSpatialKernelBlock e W L z true).det ≠ 0) + +theorem fixedSpatialKernelDensity_zero_of_norm_gt_two + (hW : 0 ≤ W) (hL : 0 ≤ L) (hsize : (Fintype.card G : ℝ) * L ≤ W) + (hz : ∀ a, |z a| ≤ 1) (y : X → ℝ) (hy : 2 < ‖y‖) : + fixedSpatialKernelDensity e W L z h0 h1 y = 0 := by + let F := fun t x => fixedSpatialKernelMap W L z t ⟨x, .inl ()⟩ + have hF : Measurable F := by unfold F fixedSpatialKernelMap; fun_prop + apply continuousDensity_zero_off_closed (S := Metric.closedBall 0 2) volume _ + (fixedSpatialKernelDensity_bounds e W L z h0 h1).2.continuous + (fixedSpatialKernelDensity_probability_density e W L z h0 h1).1 + (Metric.isClosed_closedBall) ?_ y ?_ + · rw [← fixedSpatialKernelDensity_image_law] + apply (ae_map_iff hF.aemeasurable Metric.isClosed_closedBall.measurableSet).mpr + filter_upwards [unitBoxMeasure_ae (ι := G)] with t ht + simp only [dist_zero_right] + have htnorm : ‖t‖ ≤ 1 := (pi_norm_le_iff_of_nonneg zero_le_one).mpr + (fun g => by rw [Real.norm_eq_abs, abs_of_pos (ht g).1]; exact (ht g).2) + apply (pi_norm_le_iff_of_nonneg (by norm_num : (0 : ℝ) ≤ 2)).mpr + intro x + exact (norm_le_pi_norm _ ⟨x, .inl ()⟩).trans + (fixedSpatialKernelMap_norm_le_two hW hL hsize z hz t htnorm) + · simpa only [Metric.mem_closedBall, dist_zero_right, not_le] using hy + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem columnScaledEquiv_symm_apply {X : Type*} [Fintype X] + (A C : (X → ℝ) ≃L[ℝ] (X → ℝ)) (width : X → ℝ) + (hscale : ∀ v, C v = A (fun i => width i * v i)) + (hwidth : ∀ i, width i ≠ 0) (y : X → ℝ) (i : X) : + C.symm y i = A.symm y i / width i := by + have hscaled : (fun j => width j * C.symm y j) = A.symm y := by + apply A.injective + simpa only [ContinuousLinearEquiv.apply_symm_apply] using (hscale (C.symm y)).symm + apply (eq_div_iff (hwidth i)).mpr + simpa only [mul_comm] using congrFun hscaled i + +theorem columnScaledEquiv_inverse_norm_le {X : Type*} [Fintype X] + (A C : (X → ℝ) ≃L[ℝ] (X → ℝ)) (width : X → ℝ) + (hscale : ∀ v, C v = A (fun i => width i * v i)) + {δ : ℝ} (hδ : 0 < δ) (hwidth : ∀ i, δ ≤ width i) : + ‖C.symm.toContinuousLinearMap‖ ≤ δ⁻¹ * ‖A.symm.toContinuousLinearMap‖ := by + apply ContinuousLinearMap.opNorm_le_bound _ (mul_nonneg (inv_nonneg.mpr hδ.le) (norm_nonneg _)) + intro y + apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr + intro i + change ‖C.symm y i‖ ≤ _ + rw [columnScaledEquiv_symm_apply A C width hscale + (fun j => (hδ.trans_le (hwidth j)).ne') y i, + Real.norm_eq_abs, abs_div, abs_of_pos (hδ.trans_le (hwidth i))] + have hcoord0 : |A.symm y i| ≤ ‖A.symm y‖ := by + simpa only [Real.norm_eq_abs] using norm_le_pi_norm (A.symm y) i + have hcoord : |A.symm y i| ≤ ‖A.symm.toContinuousLinearMap‖ * ‖y‖ := + hcoord0.trans (A.symm.toContinuousLinearMap.le_opNorm y) + calc + _ ≤ (‖A.symm.toContinuousLinearMap‖ * ‖y‖) / width i := + div_le_div_of_nonneg_right hcoord (hδ.trans_le (hwidth i)).le + _ ≤ (‖A.symm.toContinuousLinearMap‖ * ‖y‖) / δ := + div_le_div_of_nonneg_left (mul_nonneg (norm_nonneg _) (norm_nonneg _)) hδ (hwidth i) + _ = _ := by ring + +variable {G X T : Type*} [Fintype G] [Fintype X] [DecidableEq X] + +theorem fixedSpatialKernelBlockEquiv_slice_apply + (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) (z : Option G × X → ℝ) + (lower width : G → ℝ) (second : Bool) + (hbase : (fixedSpatialKernelBlock e W L z second).det ≠ 0) + (hslice : (fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second).det ≠ 0) + (v : X → ℝ) : + fixedSpatialKernelBlockEquiv e W L (fixedSpatialKernelSliceFrame W L z lower width) second hslice v = + fixedSpatialKernelBlockEquiv e W L z second hbase + (fun i => width (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i)) * v i) := by + rw [fixedSpatialKernelBlockEquiv_apply, fixedSpatialKernelBlockEquiv_apply] + rw [fixedSpatialKernelBlock_slice] + ext x + apply Finset.sum_congr rfl + intro i _ + ring + +theorem fixedSpatialKernelBlockEquiv_slice_inverse_norm_le + (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) (z : Option G × X → ℝ) + (lower width : G → ℝ) (second : Bool) + (hbase : (fixedSpatialKernelBlock e W L z second).det ≠ 0) + (hslice : (fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second).det ≠ 0) + {δ : ℝ} (hδ : 0 < δ) (hwidth : ∀ g, δ ≤ width g) : + ‖(fixedSpatialKernelBlockEquiv e W L + (fixedSpatialKernelSliceFrame W L z lower width) second hslice).symm.toContinuousLinearMap‖ ≤ + δ⁻¹ * ‖(fixedSpatialKernelBlockEquiv e W L z second hbase).symm.toContinuousLinearMap‖ := by + apply columnScaledEquiv_inverse_norm_le + (fixedSpatialKernelBlockEquiv e W L z second hbase) + (fixedSpatialKernelBlockEquiv e W L (fixedSpatialKernelSliceFrame W L z lower width) second hslice) + (fun i => width (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i))) + (fixedSpatialKernelBlockEquiv_slice_apply e W L z lower width second hbase hslice) hδ + intro i + exact hwidth _ + +theorem fixedSpatialKernelBlockEquiv_slice_inverseJacobian_le + (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) (z : Option G × X → ℝ) + (lower width : G → ℝ) (second : Bool) + (hbase : (fixedSpatialKernelBlock e W L z second).det ≠ 0) + (hslice : (fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second).det ≠ 0) + {δ : ℝ} (hδ : 0 < δ) (hwidth : ∀ g, δ ≤ width g) : + inverseJacobian (fixedSpatialKernelBlockEquiv e W L + (fixedSpatialKernelSliceFrame W L z lower width) second hslice) ≤ + (δ⁻¹) ^ Fintype.card X * + inverseJacobian (fixedSpatialKernelBlockEquiv e W L z second hbase) := by + let w : X → ℝ := fun i => width (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i)) + have hw : ∀ i, 0 < w i := fun i => hδ.trans_le (hwidth _) + have hprod : δ ^ Fintype.card X ≤ ∏ i, w i := by + simpa only [Finset.prod_const, Finset.card_univ] using + (Finset.prod_le_prod₀ (s := Finset.univ) (fun _ _ => hδ.le) (fun i _ => hwidth + (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i)))) + have hmatrix : fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second = + fixedSpatialKernelBlock e W L z second * Matrix.diagonal w := by + ext x i + rw [fixedSpatialKernelBlock_slice, Matrix.mul_diagonal] + have hdet : (fixedSpatialKernelBlock e W L + (fixedSpatialKernelSliceFrame W L z lower width) second).det = + (fixedSpatialKernelBlock e W L z second).det * ∏ i, w i := by + rw [hmatrix, Matrix.det_mul, Matrix.det_diagonal] + rw [fixedSpatialKernelBlockEquiv_jacobian, fixedSpatialKernelBlockEquiv_jacobian, + hdet, abs_mul, abs_of_nonneg (Finset.prod_nonneg (fun i _ => (hw i).le)), mul_inv_rev] + apply mul_le_mul_of_nonneg_right _ (inv_nonneg.mpr (abs_nonneg _)) + simpa only [← inv_pow] using inv_anti₀ (pow_pos hδ _) hprod + +end Erdos3 + +end + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators Classical NNReal +variable {G X T : Type*} [Fintype G] [Fintype X] [Fintype T] +variable (e : G ≃ X ⊕ (X ⊕ T)) (W L : ℝ) (z : Option G × X → ℝ) +variable (lower width : G → ℝ) +variable (h0 : (fixedSpatialKernelBlock e W L z false).det ≠ 0) +variable (h1 : (fixedSpatialKernelBlock e W L z true).det ≠ 0) +variable (hw : ∀ g, width g ≠ 0) +local notation "frame" => fixedSpatialKernelSliceFrame W L z lower width +local notation "h0slice" => fixedSpatialKernelBlock_slice_det_ne_zero e W L z lower width false h0 hw +local notation "h1slice" => fixedSpatialKernelBlock_slice_det_ne_zero e W L z lower width true h1 hw + +noncomputable def fixedSpatialKernelSliceDensity : (X → ℝ) → ℝ := + fixedSpatialKernelDensity e W L frame h0slice h1slice + +local notation "density" => fixedSpatialKernelSliceDensity e W L z lower width h0 h1 hw + +theorem fixedSpatialKernelSliceDensity_image_law : + (unitBoxMeasure G).map (fun t x => + fixedSpatialKernelMap W L z (fun g => lower g + width g * t g) ⟨x, .inl ()⟩) = + realDensityMeasure volume density := by + simpa only [fixedSpatialKernelSliceDensity, fixedSpatialKernelMap_slice] using + fixedSpatialKernelDensity_image_law e W L frame h0slice h1slice + +theorem fixedSpatialKernelSliceDensity_probability_data : + (∀ y, 0 ≤ density y) ∧ Integrable density ∧ (∫ y, density y) = 1 := + fixedSpatialKernelDensity_probability_density e W L frame h0slice h1slice + +theorem fixedSpatialKernelSliceDensity_bounds : + (∀ y, density y ∈ Set.Icc (0 : ℝ) + (fixedSpatialBlockDensityCap (fixedSpatialKernelBlockEquiv e W L frame true h1slice))) ∧ + LipschitzWith (fixedSpatialBlockDensityLipschitz + (fixedSpatialKernelBlockEquiv e W L frame false h0slice) + (fixedSpatialKernelBlockEquiv e W L frame true h1slice)) density := + fixedSpatialKernelDensity_bounds e W L frame h0slice h1slice + +omit [Fintype T] in + +theorem fixedSpatialKernelBlock_slice_det_lower (second : Bool) + {κ δ : ℝ} (hδ : 0 < δ) + (hmin : ∀ g, δ ≤ width g) + (hdet : κ ≤ |(fixedSpatialKernelBlock e W L z second).det|) : + κ * δ ^ Fintype.card X ≤ |(fixedSpatialKernelBlock e W L frame second).det| := by + rw [fixedSpatialKernelBlock_slice_det, abs_mul] + have hprod : δ ^ Fintype.card X ≤ + ∏ i : X, width (e.symm (if second then Sum.inr (Sum.inl i) else Sum.inl i)) := by + calc + _ = ∏ _i : X, δ := by simp + _ ≤ _ := Finset.prod_le_prod₀ (fun _ _ => hδ.le) (fun i _ => hmin _) + have hp : 0 ≤ ∏ i : X, width (e.symm + (if second then Sum.inr (Sum.inl i) else Sum.inl i)) := + Finset.prod_nonneg (fun i _ => hδ.le.trans (hmin _)) + rw [abs_of_nonneg hp] + exact mul_le_mul hdet hprod (pow_nonneg hδ.le _) (abs_nonneg _) + +omit [Fintype X] [Fintype T] in +theorem fixedSpatialKernelBlock_slice_entry_bound + {H : ℝ} (hentry : ∀ i j, |fixedSpatialKernelBlock e W L z false i j| ≤ H) + (hwidth : ∀ g, 0 ≤ width g ∧ width g ≤ 1) : + ∀ i j, |fixedSpatialKernelBlock e W L frame false i j| ≤ H := by + intro i j + rw [fixedSpatialKernelBlock_slice] + dsimp only + rw [abs_mul, abs_of_nonneg (hwidth _).1] + exact (mul_le_mul_of_nonneg_left (hwidth _).2 (abs_nonneg _)).trans + (by simpa only [mul_one] using hentry i j) + +theorem fixedSpatialKernelSliceDensity_bounds_of_det + {H κ0 κ1 δ : ℝ} (hH : 0 ≤ H) (hκ0 : 0 < κ0) (hκ1 : 0 < κ1) (hδ : 0 < δ) + (hentry : ∀ i j, |fixedSpatialKernelBlock e W L z false i j| ≤ H) + (hdet0 : κ0 ≤ |(fixedSpatialKernelBlock e W L z false).det|) + (hdet1 : κ1 ≤ |(fixedSpatialKernelBlock e W L z true).det|) + (hmin : ∀ g, δ ≤ width g) (hmax : ∀ g, width g ≤ 1) : + (∀ y, density y ∈ Set.Icc (0 : ℝ) (κ1 * δ ^ Fintype.card X)⁻¹) ∧ + LipschitzWith + (2 * (Fintype.card X : ℝ≥0) * Real.toNNReal ((κ1 * δ ^ Fintype.card X)⁻¹) * + Real.toNNReal (Fintype.card X * ((Fintype.card X).factorial * + H ^ (Fintype.card X - 1) / (κ0 * δ ^ Fintype.card X)))) density := by + exact fixedSpatialKernelDensity_bounds_of_det e W L frame h0slice h1slice hH + (mul_pos hκ0 (pow_pos hδ _)) (mul_pos hκ1 (pow_pos hδ _)) + (fixedSpatialKernelBlock_slice_entry_bound e W L z lower width hentry + (fun g => ⟨hδ.le.trans (hmin g), hmax g⟩)) + (fixedSpatialKernelBlock_slice_det_lower e W L z lower width false hδ hmin hdet0) + (fixedSpatialKernelBlock_slice_det_lower e W L z lower width true hδ hmin hdet1) + +theorem fixedSpatialKernelSliceDensity_zero_of_norm_gt_two + (hW : 0 ≤ W) (hL : 0 ≤ L) (hsize : (Fintype.card G : ℝ) * L ≤ W) + (hz : ∀ a, |z a| ≤ 1) (hl : ∀ g, 0 ≤ lower g) + (hw0 : ∀ g, 0 ≤ width g) (hcontained : ∀ g, lower g + width g ≤ 1) + (y : X → ℝ) (hy : 2 < ‖y‖) : density y = 0 := by + let F := fun (t : G → ℝ) x => fixedSpatialKernelMap W L z + (fun g => lower g + width g * t g) ⟨x, .inl ()⟩ + have hF : Measurable F := by unfold F fixedSpatialKernelMap; fun_prop + apply continuousDensity_zero_off_closed (S := Metric.closedBall 0 2) volume _ + (fixedSpatialKernelSliceDensity_bounds e W L z lower width h0 h1 hw).2.continuous + (fixedSpatialKernelSliceDensity_probability_data e W L z lower width h0 h1 hw).1 + Metric.isClosed_closedBall ?_ y ?_ + · rw [← fixedSpatialKernelSliceDensity_image_law] + apply (ae_map_iff hF.aemeasurable Metric.isClosed_closedBall.measurableSet).mpr + filter_upwards [unitBoxMeasure_ae (ι := G)] with t ht + simp only [dist_zero_right] + have htnorm : ‖fun g => lower g + width g * t g‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro g + rw [Real.norm_eq_abs, abs_of_nonneg (add_nonneg (hl g) (mul_nonneg (hw0 g) (ht g).1.le))] + have hmul : width g * t g ≤ width g := by + simpa only [mul_one] using mul_le_mul_of_nonneg_left (ht g).2 (hw0 g) + exact (add_le_add (le_refl (lower g)) hmul).trans (hcontained g) + apply (pi_norm_le_iff_of_nonneg (by norm_num : (0 : ℝ) ≤ 2)).mpr + intro x + exact (norm_le_pi_norm _ ⟨x, .inl ()⟩).trans + (fixedSpatialKernelMap_norm_le_two hW hL hsize z hz _ htnorm) + · simpa only [Metric.mem_closedBall, dist_zero_right, not_le] using hy + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FormalKernelAbsorption.lean b/lean/OAI/Combinatorics/Progressions/Linear/FormalKernelAbsorption.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ee21f1cb0b5a0740f41115ccdb080267d43ceb7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FormalKernelAbsorption.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Estimates.FastHorizontalFactorization + +namespace OAI + +section + +namespace Erdos3 + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct + +namespace VectorPolynomial + +theorem homogeneous_one_pderiv {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] + (P : VectorPolynomial σ ℚ L) + (hP : ∀ α, Finsupp.weight (fun _ : σ => (1 : ℕ)) α ≠ 1 → coefficients P α = 0) + (i : σ) : + (MvPolynomial.pderiv i).toLinearMap.rTensor L P = monomial 0 (coefficients P (Finsupp.single i 1)) := by + classical + apply coefficients.injective + apply Finsupp.ext + intro α + rw [coefficients_pderiv, coefficients_monomial] + by_cases hα : α = 0 + · subst α + simp only [Finsupp.zero_apply, Nat.cast_zero, zero_add, one_smul, Finsupp.single_eq_same] + · have hp := NilpotentLieFiltration.positive_weight_of_ne_zero (fun _ : σ => 1) (by simp) hα + have hweight : Finsupp.weight (fun _ : σ => (1 : ℕ)) (α + Finsupp.single i 1) ≠ 1 := by + rw [map_add, Finsupp.weight_single] + simp only [one_smul] + omega + rw [hP _ hweight, smul_zero, Finsupp.single_eq_of_ne hα] + +end VectorPolynomial + +namespace NilpotentLieBCHGroup + +variable {σ K L : Type*} [AddCommGroup K] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem PolynomialDerivativeSystemMod.absorb (V : Submodule ℚ L) + (P : PolynomialGroup σ hnil) (S R : K →+ VectorPolynomial σ ℚ L) + (small rational : σ → VectorPolynomial σ ℚ L) (k a b : σ → K) + (hSR : PolynomialLiftSystemMod V P S R) + (hsystem : PolynomialDerivativeSystemMod V P small rational (fun i => S (k i))) : + PolynomialDerivativeSystemMod V P + (fun i => small i + S (a i)) (fun i => rational i + R (b i)) + (fun i => S (k i - a i - b i)) := by + intro i + have h := (coefficientSubmodule V).add_mem (hsystem i) (hSR (b i)) + change formalLogDerivative i P - + ((small i + S (a i)) + dualAdjoint P (rational i + R (b i)) + S (k i - a i - b i)) ∈ _ + convert h using 1 + simp only [map_sub, dualAdjoint_add] + abel + +theorem formal_remove_and_absorb (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + (P A B : PolynomialGroup σ hnil) (hA : ∀ α, coefficients A.coord α ∈ U) + (S R : K →+ VectorPolynomial σ ℚ L) + (small rational : σ → VectorPolynomial σ ℚ L) (k a b : σ → K) + (hSR : PolynomialLiftSystemMod V P S R) + (hsystem : PolynomialDerivativeSystemMod V P small rational (fun i => S (k i))) : + let S' := (dualAdjointAddEquiv A⁻¹).toAddMonoidHom.comp S + let R' := (dualAdjointAddEquiv B).toAddMonoidHom.comp R + PolynomialLiftSystemMod V (A⁻¹ * P * B⁻¹) S' R' ∧ + PolynomialDerivativeSystemMod V (A⁻¹ * P * B⁻¹) + (fun i => dualAdjoint A⁻¹ (small i - formalLogDerivative i A) + S' (a i)) + (fun i => dualAdjoint B (rational i) - formalLogDerivative i B + R' (b i)) + (fun i => S' (k i - a i - b i)) := by + intro S' R' + have hlifts : PolynomialLiftSystemMod V (A⁻¹ * P * B⁻¹) S' R' := + PolynomialLiftSystemMod.remove U V hUV P A B hA S R hSR + have hderivative := PolynomialDerivativeSystemMod.remove U V hUV P A B hA + small rational (fun i => S (k i)) hsystem + exact ⟨hlifts, PolynomialDerivativeSystemMod.absorb V (A⁻¹ * P * B⁻¹) S' R' + _ _ k a b hlifts hderivative⟩ + +end NilpotentLieBCHGroup +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FourBalancedDual.lean b/lean/OAI/Combinatorics/Progressions/Linear/FourBalancedDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..73c506448eefd9dd50bf2957107b68039d8bbb22 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FourBalancedDual.lean @@ -0,0 +1,76 @@ +import OAI.Combinatorics.Progressions.Estimates.FourBalancedRelations + +namespace OAI + +section + +namespace Erdos3 + +variable {R V E : Type*} [CommRing R] [AddCommGroup V] [Module R V] + [AddCommGroup E] [Module R E] + +def fourDiagonalMap : V →ₗ[R] (Fin 4 → V) := LinearMap.pi (fun _ => LinearMap.id) + +theorem four_annihilator_decomposition (C D : Submodule R V) + (ℓ : (Fin 4 → V) →ₗ[R] E) + (hℓ : ∀ z ∈ fourBalancedDependent D, ℓ z = 0) + (v : Fin 4 → V) (hv : v ∈ fourCommonModulo C D) : + ℓ v = ℓ (fourDiagonalMap (R := R) (v 0)) + + ℓ (LinearMap.single R (fun _ : Fin 4 => V) 0 (fourAlternatingMap (R := R) v)) := by + let a := fourAlternatingMap (R := R) v + have ha : a ∈ D := fourAlternatingMap_mem_dependent C D v hv + let z : Fin 4 → V := fun k => v k - v 0 - (Pi.single (0 : Fin 4) a : Fin 4 → V) k + have hz : z ∈ fourBalancedDependent D := by + apply (mem_fourBalancedDependent D z).mpr + refine ⟨?_, ?_⟩ + · intro k + apply D.sub_mem (((mem_fourCommonModulo C D v).mp hv).2 k) + by_cases hk : k = 0 + · subst k; simpa only [Pi.single_eq_same] using ha + · simpa only [Pi.single_eq_of_ne hk] using D.zero_mem + · change (v 0 - v 0 - a) + (v 1 - v 0 - 0) - (v 2 - v 0 - 0) - (v 3 - v 0 - 0) = 0 + dsimp only [a] + rw [fourAlternatingMap_apply] + abel + have h := hℓ z hz + change ℓ (v - fourDiagonalMap (R := R) (v 0) - + LinearMap.single R (fun _ : Fin 4 => V) 0 a) = 0 at h + rw [map_sub, map_sub] at h + calc + ℓ v = (ℓ v - ℓ (fourDiagonalMap (R := R) (v 0))) + + ℓ (fourDiagonalMap (R := R) (v 0)) := (sub_add_cancel _ _).symm + _ = ℓ (LinearMap.single R (fun _ : Fin 4 => V) 0 a) + + ℓ (fourDiagonalMap (R := R) (v 0)) := by rw [sub_eq_zero.mp h] + _ = _ := add_comm _ _ + +theorem four_annihilator_common_zero (D : Submodule R V) + (ℓ : (Fin 4 → V) →ₗ[R] E) + (hℓ : ∀ z ∈ fourBalancedDependent D, ℓ z = 0) (v : V) (hv : v ∈ D) : + ℓ (fourDiagonalMap (R := R) v) = 0 := by + apply hℓ + apply (mem_fourBalancedDependent D _).mpr + exact ⟨fun _ => hv, by change v + v - v - v = 0; abel⟩ + +theorem four_refined_annihilator_identity (C D : Submodule R V) (hDC : D ≤ C) + (K : Submodule R (Fin 4 → V)) (ℓ : (Fin 4 → V) →ₗ[R] E) + (hℓ : ∀ z ∈ fourRefinedRelation C D K, ℓ z = 0) + (v : Fin 4 → V) (hv : v ∈ fourRefinedRelation C D K) : + ℓ (fourDiagonalMap (R := R) (v 0)) + + ℓ (LinearMap.single R (fun _ : Fin 4 => V) 0 (v 0 + v 1 - v 2 - v 3)) = 0 := by + have h := four_annihilator_decomposition C D ℓ + (fun z hz => hℓ z (fourBalancedDependent_le_refined C D K hz)) v + (fourRefinedRelation_le_common C D hDC K hv) + rw [fourAlternatingMap_apply] at h + exact h.symm.trans (hℓ v hv) + +theorem four_refined_annihilator_petal_zero (D : Submodule R V) + (K : Submodule R (Fin 4 → V)) (ℓ : (Fin 4 → V) →ₗ[R] E) + (hℓ : ∀ z ∈ K, ℓ z = 0) (v : V) (hv : v ∈ fourPetalSpace D K) : + ℓ (LinearMap.single R (fun _ : Fin 4 => V) 0 v) = 0 := + hℓ _ hv.2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FreeLieTruncationKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/FreeLieTruncationKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..502c944a70b82bc5f432b57d45cc260b912c1098 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FreeLieTruncationKernel.lean @@ -0,0 +1,42 @@ +import OAI.Combinatorics.Progressions.Nilpotent.FreeNilpotentLieAlgebra +import OAI.Combinatorics.Progressions.Nilpotent.WordTruncationBracket + +namespace OAI + +section + +namespace Erdos3 + +variable {X : Type*} + +theorem freeLieTruncation_eq_zero_iff (s : ℕ) (p : FreeLieAlgebra ℚ X) : + freeLieTruncation s p = 0 ↔ + p ∈ LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s := by + constructor + · intro hp + apply (FreeNilpotentLieAlgebra.mk_eq_zero X s p).mp + rw [← FreeNilpotentLieAlgebra.mk_truncation p, hp, map_zero] + · exact freeLie_lowerCentralSeries_truncation_zero s p + +theorem freeLieTruncation_ker (s : ℕ) : + LinearMap.ker (freeLieTruncation (X := X) s) = + (LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s).toSubmodule := by + ext p + exact freeLieTruncation_eq_zero_iff s p + +theorem freeLie_lowerCentralSeries_iff_low_coeff_zero (s : ℕ) (p : FreeLieAlgebra ℚ X) : + p ∈ LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s ↔ + ∀ w, w.length ≤ s → (freeLieWordExpansion p).coeff w = 0 := by + rw [← freeLieTruncation_eq_zero_iff, ← wordTruncation_eq_zero_iff] + constructor + · intro hp + rw [← freeLieTruncation_expansion, hp, map_zero] + · intro hp + apply freeLieWordExpansion_injective + rw [freeLieTruncation_expansion, hp, map_zero] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FreeWeightedRankGenerators.lean b/lean/OAI/Combinatorics/Progressions/Linear/FreeWeightedRankGenerators.lean new file mode 100644 index 0000000000000000000000000000000000000000..451ba7a6cc753ea725bd1fe91d4cbc21c5054ed6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FreeWeightedRankGenerators.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.Progressions.Estimates.FreeWeightedModelBounds + +namespace OAI + +section + +namespace Erdos3.FreeWeightedNilpotentLieAlgebra + +open Module + +variable (X : Type*) [Fintype X] (s : ℕ) (w : X → ℕ) + +abbrev RankAlphabet := Σ i : Fin (s + 1), layerGenerators X s w (i.val + 1) + +def rankAlphabetWeight (a : RankAlphabet X s w) : ℕ := a.1.val + 1 + +noncomputable def rankAlphabetVector (a : RankAlphabet X s w) : FreeWeightedNilpotentLieAlgebra X s w := a.2.val + +theorem rankAlphabetWeight_pos (a : RankAlphabet X s w) : 0 < rankAlphabetWeight X s w a := Nat.succ_pos _ + +theorem rankAlphabetVector_mem (hw : ∀ x, 0 < w x) (a : RankAlphabet X s w) : + rankAlphabetVector X s w a ∈ (filtration X s w hw).layer (rankAlphabetWeight X s w a) := + layerGenerators_mem X s w hw _ a.2.val a.2.property + +theorem rankAlphabet_card_le : Fintype.card (RankAlphabet X s w) ≤ + (s + 1) * (Fintype.card X + 2) ^ (3 ^ s) := by + classical + simp only [RankAlphabet, Fintype.card_sigma, Fintype.card_coe] + calc + _ ≤ ∑ _i : Fin (s + 1), (Fintype.card X + 2) ^ (3 ^ s) := + Finset.sum_le_sum (fun i _ => layerGenerators_card_le X s w (i.val + 1)) + _ = _ := by simp + +theorem rankAlphabet_spans_layer (hw : ∀ x, 0 < w x) (d : ℕ) (hd : 0 < d) : + (filtration X s w hw).layer d ≤ Submodule.span ℚ + (rankAlphabetVector X s w '' {a | rankAlphabetWeight X s w a = d}) := by + by_cases hds : d ≤ s + 1 + · let j : Fin (s + 1) := ⟨d - 1, by omega⟩ + have hj : j.val + 1 = d := by dsimp only [j]; omega + rw [layer_eq_span] + apply Submodule.span_mono + intro x hx + have hx' : x ∈ layerGenerators X s w (j.val + 1) := by simpa only [hj, Finset.mem_coe] using hx + exact ⟨⟨j, ⟨x, hx'⟩⟩, hj, rfl⟩ + · have hbot : (filtration X s w hw).layer d = ⊥ := by + apply bot_unique + exact ((filtration X s w hw).antitone (by omega : s + 1 ≤ d)).trans + (filtration X s w hw).terminal.le + rw [hbot] + exact bot_le + +noncomputable def topRankGenerators (k : ℕ) : Finset (FreeWeightedNilpotentLieAlgebra X s w) := + finiteWeightedLieValues (rankAlphabetVector X s w) (rankAlphabetWeight X s w) s k + +theorem topRankGenerators_span (hw : ∀ x, 0 < w x) (k : ℕ) : + Submodule.span ℚ (topRankGenerators X s w k : Set _) = (filtration X s w hw).rankLayer s k := by + rw [(filtration X s w hw).rankLayer_eq_weighted_tree_span + (rankAlphabetVector X s w) (rankAlphabetWeight X s w) (rankAlphabetWeight_pos X s w) + (rankAlphabetVector_mem X s w hw) (rankAlphabet_spans_layer X s w hw)] + rw [(filtration X s w hw).terminal, bot_sup_eq, + weightedLieTreeSpan_eq_finite_span _ _ (rankAlphabetWeight_pos X s w)] + rfl + +theorem topRankGenerators_card_le (k : ℕ) : + (topRankGenerators X s w k).card ≤ + ((s + 1) * (Fintype.card X + 2) ^ (3 ^ s) + 2) ^ (3 ^ s) := + (finiteWeightedLieValues_card_le (rankAlphabetVector X s w) (rankAlphabetWeight X s w) s k).trans + (Nat.pow_le_pow_left (Nat.add_le_add_right (rankAlphabet_card_le X s w) 2) _) + +theorem topRankGenerators_logHeight {ι : Type*} [Fintype ι] + (e : Basis ι ℚ (FreeWeightedNilpotentLieAlgebra X s w)) {p : ℝ} + (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) + (hc : ∀ i j k, rationalLogHeight (lieStructureConstants e i j k) ≤ p) + (hgen : ∀ x ∈ FreeNilpotentLieAlgebra.treeGenerators X s, ∀ i, + rationalLogHeight (e.repr (mk X s w x) i) ≤ p) + (k : ℕ) (x : FreeWeightedNilpotentLieAlgebra X s w) (hx : x ∈ topRankGenerators X s w k) (i : ι) : + rationalLogHeight (e.repr x i) ≤ (p + 3) ^ (6 * s + 2) := by + classical + have hv (a : RankAlphabet X s w) (j : ι) : + rationalLogHeight (e.repr (rankAlphabetVector X s w a) j) ≤ p := by + obtain ⟨y, hy, hya⟩ := Finset.mem_image.mp a.2.property + change rationalLogHeight (e.repr a.2.val j) ≤ p + rw [← hya] + exact hgen y (FreeNilpotentLieAlgebra.weightedLayerGenerators_subset X s w _ hy) j + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx + have hraw := finiteLieTrees_coordinate_height e (rankAlphabetVector X s w) + (fun i j k => rationalHeightLE_ceil_exp (hc i j k)) + (fun a j => rationalHeightLE_ceil_exp (hv a j)) s a (Finset.mem_filter.mp ha).1 i + apply rationalLogHeight_le_of_height hraw + simpa only [show p + 1 + 2 = p + 3 by ring] using + lieTreeHeight_le_exp (Fintype.card ι) ⌈Real.exp p⌉₊ s + (hp.trans (le_add_of_nonneg_right zero_le_one)) + (hd.trans (le_add_of_nonneg_right zero_le_one)) (ceil_exp_le_exp_add_one hp) + +end Erdos3.FreeWeightedNilpotentLieAlgebra + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FrozenDiagramKernelInvariance.lean b/lean/OAI/Combinatorics/Progressions/Linear/FrozenDiagramKernelInvariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..2362a3d681df09860b76dac86a949f7840db2028 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FrozenDiagramKernelInvariance.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.Progressions.Estimates.LowerRefilteredCyclicExpansion + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem realification_map_mem_of_kernel + {H L M : Type*} [AddCommGroup H] [Module ℚ H] + [AddCommGroup L] [Module ℚ L] [AddCommGroup M] [Module ℚ M] + (φ : H →ₗ[ℚ] L) (ψ : H →ₗ[ℚ] M) (K : Submodule ℚ L) + (hker : ∀ x, ψ x = 0 → φ x ∈ K) + (x : ℝ ⊗[ℚ] H) (hx : ψ.baseChange ℝ x = 0) : + φ.baseChange ℝ x ∈ K.baseChange ℝ := by + have hle : LinearMap.ker ψ ≤ K.comap φ := fun y hy => hker y hy + have hreal := Submodule.baseChange_mono ℝ hle + rw [realification_ker, realification_comap] at hreal + exact hreal hx + +theorem realificationLieHom_injective + {H M : Type*} [LieRing H] [LieAlgebra ℚ H] [LieRing M] [LieAlgebra ℚ M] + (ψ : H →ₗ⁅ℚ⁆ M) (hψ : Function.Injective ψ) : + Function.Injective (realificationLieHom ψ) := by + let _ : Module.Free ℚ ℝ := Module.Free.of_divisionRing ℚ ℝ + exact Module.Flat.lTensor_preserves_injective_linearMap (M := ℝ) ψ.toLinearMap hψ + +namespace NilpotentLieBCHGroup + +theorem realificationMap_injective + {H M : Type*} [LieRing H] [LieAlgebra ℚ H] [LieRing M] [LieAlgebra ℚ M] + {s t : ℕ} {hH : LieModule.lowerCentralSeries ℚ H H s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + (ψ : H →ₗ⁅ℚ⁆ M) (hψ : Function.Injective ψ) : + Function.Injective (realificationMap (hnil := hH) (hM := hM) ψ) := by + intro x y hxy + apply ext + apply realificationLieHom_injective ψ hψ + exact congrArg coord hxy + +end NilpotentLieBCHGroup + +namespace RationalFilteredNilmanifold + +open NilpotentLieBCHGroup + +theorem frozenDiagramKernelInvariance_of_injective + {H L M : Type*} [LieRing H] [LieAlgebra ℚ H] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s t r d e f : ℕ} + (D : RationalFilteredNilmanifold H s d) + (E : RationalFilteredNilmanifold L t e) + (T : RationalFilteredNilmanifold M r f) + (φ : H →ₗ⁅ℚ⁆ L) (ψ : H →ₗ⁅ℚ⁆ M) (hψ : Function.Injective ψ) + (u : E.Space → ℂ) (a b : E.RealGroup) : + ∀ z ∈ (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := T.filtration.lowerCentralSeries_eq_bot) ψ).ker, ∀ x : D.RealGroup, + u (QuotientGroup.mk (a * realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ (z * x) * b)) = + u (QuotientGroup.mk (a * realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ x * b)) := by + intro z hz x + have hz1 : z = 1 := realificationMap_injective ψ hψ + ((MonoidHom.mem_ker.mp hz).trans (map_one _).symm) + rw [hz1, one_mul] + +end RationalFilteredNilmanifold + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FrozenKernelArrayBridge.lean b/lean/OAI/Combinatorics/Progressions/Linear/FrozenKernelArrayBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..96b2f6956ed31e333cbec0bcc30bf87de0f5b6b9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FrozenKernelArrayBridge.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.Progressions.Lattices.RegularizedAffineComparison + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem canonicalAffineRawArray_frozen_kernel {D G Z α : Type*} [Fintype D] + [Fintype α] [DecidableEq α] {B O J N : D → Type*} + [∀ d, Fintype (B d)] [∀ d, Fintype (O d)] [∀ d, DecidableEq (O d)] + [∀ d, Fintype (J d)] [∀ d, DecidableEq (J d)] [∀ d, Fintype (N d)] + (h : D → ℕ) (hh : ∀ d, 0 < h d) (sets : ∀ d, O d → Finset α) + (Q : D → ℝ) (hQ : ∀ d, 0 < Q d) (T : SamplerTupleIndex G B h → ℝ) (hT : ∀ k, 0 < T k) + (eK : ∀ d, J d → SamplerTupleIndex G B h →₀ ℕ) + (eN : ∀ d, N d → SamplerTupleIndex G B h →₀ ℕ) + (extra : G → Option α → Z) (z : Z → ℝ) + (v : ∀ _d : D, Finset α → SamplerTupleIndex G B h → ℤ) + (hcoords : ∀ d j t k, k ∈ (eK d j).support → + (v d t k : ℝ)/T k = normalizedCubeTuple (canonicalTupleInput extra) z 0 t k) + (hfrozen : ∀ d j k, k ∈ (eK d j).support → ∃ g, k = Sum.inl g) + (s : ∀ d, O d ↪ J d) + (hminor : ∀ d, ((integerJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) (v d) (sets d)).submatrix + id (s d)).det ≠ 0) + (x : JointBlockParameter B h α → ℝ) (c w r : ∀ d, J d ⊕ N d → ℝ) : + let M := fun d => integerJetMatrix (fun j => MvPolynomial.monomial (eK d j) 1) (v d) (sets d) + let S := fun d j => Q d/monomialScale T (eK d j) + let E := fun d => normalizedPivotEquiv ((M d).submatrix id (s d)) (hminor d) + (fun j => S d (s d j)) (fun _ => Q d) + (fun j => div_pos (hQ d) (monomialScale_pos T hT (eK d (s d j)))) (fun _ => hQ d) + let F := fun d => matrixSupCLM + (normalizedIntegerColumns (remainingMatrixColumns (M d) (s d)) (fun j => S d j.val) (fun _ => Q d)) + canonicalAffineRawArray h (fun d => Sum.elim (eK d) (eN d)) Q T c w r sets + (rawCanonicalCubeTuple extra T z (jointCubeScale h (fun i => T (.inr i)) x)) = + fun o => jointAffineJetUnitMap s E F eN (canonicalTupleInput extra) z sets c w x r o.1 o.2 := by + dsimp only + apply canonicalAffineRawArray_eq_jointUnitMap h hh sets _ s hminor _ + (fun d j => div_pos (hQ d) (monomialScale_pos T hT (eK d j))) Q hQ T + (fun k => (hT k).ne') eK eN extra z x _ c w r + intro d + apply normalized_frozenKernelJetMatrix (eK d) (canonicalTupleInput extra) z (sets d) (v d) T + (hQ d).ne' (hcoords d) _ x + intro j k hk a + obtain ⟨g, rfl⟩ := hfrozen d j k hk + exact ⟨extra g a, rfl⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FullFastHorizontalSpanning.lean b/lean/OAI/Combinatorics/Progressions/Linear/FullFastHorizontalSpanning.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ba53152debdd615549f9f265b69c8fae79fbb0c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FullFastHorizontalSpanning.lean @@ -0,0 +1,373 @@ +import OAI.Combinatorics.Progressions.Geometry.GradedTopCoordinates +import OAI.Combinatorics.Progressions.Linear.SplitPreimageSpanning + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +noncomputable def gradedLayerOneProjection : F.AssociatedGraded →ₗ[ℚ] (L ⧸ F.layer 2) := + (F.layer 2).mkQ.comp + (e.repr.symm.toLinearMap.comp (F.associatedGradedBasis e ω hF).repr.toLinearMap) + +theorem gradedLayerOneProjection_coordinate (x : F.AssociatedGraded) (i : LayerOneBasisIndex ω) : + (F.layerOneBasis e ω hF).repr (F.gradedLayerOneProjection e ω hF x) i = + (F.associatedGradedBasis e ω hF).repr x i.val := by + change (F.layerOneBasis e ω hF).repr + ((F.layer 2).mkQ (e.repr.symm ((F.associatedGradedBasis e ω hF).repr x))) i = _ + rw [F.layerOneBasis_repr_mk, LinearEquiv.apply_symm_apply] + +theorem layerOneGradedMap_coordinate (x : L ⧸ F.layer 2) (i : LayerOneBasisIndex ω) : + (F.associatedGradedBasis e ω hF).repr (F.layerOneGradedMap e ω hF x) i.val = + (F.layerOneBasis e ω hF).repr x i := by + obtain ⟨v, rfl⟩ := (F.layer 2).mkQ_surjective x + rw [F.layerOneGradedMap_mk, F.gradedPieceProjection_coordinate, F.layerOneBasis_repr_mk] + have hpos := F.adaptedBasis_weight_pos e ω hF i.val + have hnot := i.property + rw [ite_eq_left (show ω i.val = 1 by omega)] + +theorem gradedLayerOneProjection_rightInverse (x : L ⧸ F.layer 2) : + F.gradedLayerOneProjection e ω hF (F.layerOneGradedMap e ω hF x) = x := by + apply (F.layerOneBasis e ω hF).repr.injective + ext i + rw [F.gradedLayerOneProjection_coordinate, F.layerOneGradedMap_coordinate] + +theorem layerOneGradedMap_projection (x : F.AssociatedGraded) : + F.layerOneGradedMap e ω hF (F.gradedLayerOneProjection e ω hF x) = + basisGradeProjection (F.associatedGradedBasis e ω hF) ω 1 x := by + apply (F.associatedGradedBasis e ω hF).repr.injective + ext i + change (F.associatedGradedBasis e ω hF).repr + (F.gradedPieceProjection e ω hF 1 (supportedQuotientSection e (F.layer 2) {i | 2 ≤ ω i} + (hF 2) (F.gradedLayerOneProjection e ω hF x))) i = _ + rw [F.gradedPieceProjection_coordinate, basisGradeProjection_repr] + by_cases hi : ω i = 1 + · rw [ite_eq_left hi, ite_eq_left hi] + have hni : ¬2 ≤ ω i := by omega + rw [supportedQuotientSection_coordinate e (F.layer 2) {i | 2 ≤ ω i} + (hF 2) _ ⟨i, hni⟩] + exact F.gradedLayerOneProjection_coordinate e ω hF x ⟨i, hni⟩ + · rw [ite_eq_right hi, ite_eq_right hi] + +theorem layerOneGradedSubmodule_eq_image (U : LieSubalgebra ℚ F.AssociatedGraded) + (hU : BasisGradedSubmodule (F.associatedGradedBasis e ω hF) ω U.toSubmodule) : + F.layerOneGradedSubmodule e ω hF U = U.toSubmodule.map (F.gradedLayerOneProjection e ω hF) := by + ext x + constructor + · intro hx + exact ⟨F.layerOneGradedMap e ω hF x, hx, F.gradedLayerOneProjection_rightInverse e ω hF x⟩ + · rintro ⟨v, hv, rfl⟩ + change F.layerOneGradedMap e ω hF (F.gradedLayerOneProjection e ω hF v) ∈ U + rw [F.layerOneGradedMap_projection] + exact hU 1 v hv + +theorem gradedLayerOneProjection_spanning (U : LieSubalgebra ℚ F.AssociatedGraded) + (hU : BasisGradedSubmodule (F.associatedGradedBasis e ω hF) ω U.toSubmodule) + (v : κ → F.AssociatedGraded) (hv : Submodule.span ℚ (Set.range v) = U.toSubmodule) : + Submodule.span ℚ (Set.range (fun j => F.gradedLayerOneProjection e ω hF (v j))) = + F.layerOneGradedSubmodule e ω hF U := by + rw [F.layerOneGradedSubmodule_eq_image e ω hF U hU, ← hv, Submodule.map_span, ← Set.range_comp] + rfl + +theorem gradedLayerOneProjection_height (x : F.AssociatedGraded) {H : ℕ} + (hx : ∀ i, RationalHeightLE ((F.associatedGradedBasis e ω hF).repr x i) H) : + ∀ i, RationalHeightLE ((F.layerOneBasis e ω hF).repr (F.gradedLayerOneProjection e ω hF x) i) H := by + intro i + rw [F.gradedLayerOneProjection_coordinate] + exact hx i.val + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +local notation "bG" => F.associatedGradedBasis e ω hF + +theorem layerOneGradedMap_injective : Function.Injective (F.layerOneGradedMap e ω hF) := by + intro x y hxy + have h := congrArg (F.gradedLayerOneProjection e ω hF) hxy + simpa only [F.gradedLayerOneProjection_rightInverse] using h + +theorem layerOneGradedMap_pure (x : L ⧸ F.layer 2) : + basisGradeProjection bG ω 1 (F.layerOneGradedMap e ω hF x) = F.layerOneGradedMap e ω hF x := by + rw [← F.layerOneGradedMap_projection, F.gradedLayerOneProjection_rightInverse] + +theorem layerOneGradedMap_coordinate_zero (x : L ⧸ F.layer 2) (i : ι) (hi : ω i ≠ 1) : + (bG).repr (F.layerOneGradedMap e ω hF x) i = 0 := by + have h := congrArg (fun y => (bG).repr y i) (F.layerOneGradedMap_pure e ω hF x) + rw [basisGradeProjection_repr, ite_eq_right hi] at h + exact h.symm + +theorem layerOneGradedMap_height (x : L ⧸ F.layer 2) {H : ℕ} (hH : 1 ≤ H) + (hx : ∀ i, RationalHeightLE ((F.layerOneBasis e ω hF).repr x i) H) : + ∀ i, RationalHeightLE ((bG).repr (F.layerOneGradedMap e ω hF x) i) H := by + intro i + by_cases hi : ω i = 1 + · have hni : ¬ 2 ≤ ω i := by omega + rw [F.layerOneGradedMap_coordinate e ω hF x ⟨i, hni⟩] + exact hx ⟨i, hni⟩ + · rw [F.layerOneGradedMap_coordinate_zero e ω hF x i hi] + exact rationalHeightLE_zero hH + +theorem realLayerOneGradedMap_pure (x : ℝ ⊗[ℚ] (L ⧸ F.layer 2)) : + basisGradeProjection ((bG).baseChange ℝ) ω 1 ((F.layerOneGradedMap e ω hF).baseChange ℝ x) = + (F.layerOneGradedMap e ω hF).baseChange ℝ x := by + change basisCoordinateProjection ((bG).baseChange ℝ) {i | ω i = 1} + ((F.layerOneGradedMap e ω hF).baseChange ℝ x) = _ + rw [← basisCoordinateProjection_baseChange] + induction x using TensorProduct.inductionOn with + | add x y hx hy => simp only [map_add, hx, hy] + | tmul a x => + rw [LinearMap.baseChange_tmul, LinearMap.baseChange_tmul] + exact congrArg (fun y => a ⊗ₜ[ℚ] y) (F.layerOneGradedMap_pure e ω hF x) + +noncomputable def gradedHorizontalKernel (K : Submodule ℚ (L ⧸ F.layer 2)) : + Submodule ℚ F.AssociatedGraded := K.map (F.layerOneGradedMap e ω hF) + +noncomputable def gradedHorizontalKernelEquiv (K : Submodule ℚ (L ⧸ F.layer 2)) : + K ≃ₗ[ℚ] F.gradedHorizontalKernel e ω hF K := + Submodule.equivMapOfInjective (F.layerOneGradedMap e ω hF) (F.layerOneGradedMap_injective e ω hF) K + +noncomputable def gradedHorizontalKernelBasis (K : Submodule ℚ (L ⧸ F.layer 2)) (b : Basis κ ℚ K) : + Basis κ ℚ (F.gradedHorizontalKernel e ω hF K) := b.map (F.gradedHorizontalKernelEquiv e ω hF K) + +theorem gradedHorizontalKernelBasis_coe (K : Submodule ℚ (L ⧸ F.layer 2)) (b : Basis κ ℚ K) (i : κ) : + (F.gradedHorizontalKernelBasis e ω hF K b i : F.AssociatedGraded) = + F.layerOneGradedMap e ω hF (b i : L ⧸ F.layer 2) := by + rw [gradedHorizontalKernelBasis, Basis.map_apply] + rfl + +theorem gradedHorizontalKernel_real_mem (K : Submodule ℚ (L ⧸ F.layer 2)) + (x : ℝ ⊗[ℚ] (L ⧸ F.layer 2)) (hx : x ∈ K.baseChange ℝ) : + (F.layerOneGradedMap e ω hF).baseChange ℝ x ∈ (F.gradedHorizontalKernel e ω hF K).baseChange ℝ := by + rw [gradedHorizontalKernel, realification_map] + exact ⟨x, hx, rfl⟩ + +theorem gradedHorizontalKernel_real_pure (K : Submodule ℚ (L ⧸ F.layer 2)) + (x : ℝ ⊗[ℚ] F.AssociatedGraded) (hx : x ∈ (F.gradedHorizontalKernel e ω hF K).baseChange ℝ) : + basisGradeProjection ((bG).baseChange ℝ) ω 1 x = x := by + rw [gradedHorizontalKernel, realification_map] at hx + obtain ⟨y, _, rfl⟩ := hx + exact F.realLayerOneGradedMap_pure e ω hF y + +theorem gradedHorizontalKernelBasis_height (K : Submodule ℚ (L ⧸ F.layer 2)) (b : Basis κ ℚ K) + {H : ℕ} (hH : 1 ≤ H) + (hb : ∀ j i, RationalHeightLE ((F.layerOneBasis e ω hF).repr (b j : L ⧸ F.layer 2) i) H) : + ∀ j i, RationalHeightLE ((bG).repr (F.gradedHorizontalKernelBasis e ω hF K b j : F.AssociatedGraded) i) H := by + intro j i + rw [F.gradedHorizontalKernelBasis_coe] + exact F.layerOneGradedMap_height e ω hF _ hH (hb j) i + +theorem gradedHorizontalKernelBasis_span (K : Submodule ℚ (L ⧸ F.layer 2)) (b : Basis κ ℚ K) : + Submodule.span ℚ (Set.range (fun j => + (F.gradedHorizontalKernelBasis e ω hF K b j : F.AssociatedGraded))) = + F.gradedHorizontalKernel e ω hF K := by + change Submodule.span ℚ (Set.range ((F.gradedHorizontalKernel e ω hF K).subtype ∘ + F.gradedHorizontalKernelBasis e ω hF K b)) = _ + rw [Set.range_comp, ← Submodule.map_span, Basis.span_eq, Submodule.map_top, Submodule.range_subtype] + +theorem exists_gradedHorizontalKernel_quotient_basis [Fintype ι] [Fintype κ] + (K : Submodule ℚ (L ⧸ F.layer 2)) (b : Basis κ ℚ K) + {H : ℕ} (hH : 1 ≤ H) + (hb : ∀ j i, RationalHeightLE ((F.layerOneBasis e ω hF).repr (b j : L ⧸ F.layer 2) i) H) + {p : ℝ} (hp : 0 ≤ p) (hk : (Fintype.card κ : ℝ) ≤ p) (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ H' : ℕ, 1 ≤ H' ∧ (H' : ℝ) ≤ Real.exp ((p + 2) ^ 7) ∧ + ∃ d : ℕ, d ≤ Fintype.card ι ∧ + ∃ f : Basis (Fin d) ℚ (F.AssociatedGraded ⧸ F.gradedHorizontalKernel e ω hF K), + ∀ i j, RationalHeightLE (f.repr ((F.gradedHorizontalKernel e ω hF K).mkQ (bG j)) i) H' := by + exact exists_submodule_quotient_basis_exp bG (F.gradedHorizontalKernel e ω hF K) + (fun j => (F.gradedHorizontalKernelBasis e ω hF K b j : F.AssociatedGraded)) + (F.gradedHorizontalKernelBasis_span e ω hF K b) hH + (F.gradedHorizontalKernelBasis_height e ω hF K b hH hb) hp hk hHp + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +abbrev TopGradedBasisIndex (s : ℕ) (ω : ι → ℕ) := {i : ι // s + 1 ≤ ω i} + +local notation "ωW" => (fun i : ReducedSquareBasisIndex s ω => squareBasisWeight ω (Subtype.val i)) +local notation "bW" => F.squareFiltration.quotientTop.associatedGradedBasis + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) + +noncomputable def fullFastDiagonalGenerators + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) : + κ ⊕ TopGradedBasisIndex s ω → F.AssociatedGraded := + Sum.elim (fun j => F.quotientTopGradedSection e ω hF (F.reducedSquareGradedSndMap (v j))) + (fun i => F.associatedGradedBasis e ω hF i.val) + +theorem fullFastDiagonalGenerators_span + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) : + Submodule.span ℚ (Set.range (F.fullFastDiagonalGenerators e ω hF v)) = + (F.fullFastGradedDiagonal W).toSubmodule := by + have himage : Submodule.span ℚ (Set.range (fun j => F.reducedSquareGradedSndMap (v j))) = + (F.fastGradedDiagonal W).toSubmodule := by + change _ = W.toSubmodule.map F.reducedSquareGradedSndMap.toLinearMap + rw [← hv, Submodule.map_span, ← Set.range_comp] + rfl + have hker : Submodule.span ℚ (Set.range (fun i : TopGradedBasisIndex s ω => + F.associatedGradedBasis e ω hF i.val)) = LinearMap.ker F.quotientTopGradedMap.toLinearMap := by + rw [F.quotientTopGradedMap_kernel e ω hF] + congr 1 + ext x + constructor + · rintro ⟨i, rfl⟩ + exact ⟨i.val, i.property, rfl⟩ + · rintro ⟨i, hi, rfl⟩ + exact ⟨⟨i, hi⟩, rfl⟩ + exact split_preimage_spanning F.quotientTopGradedMap.toLinearMap + (F.quotientTopGradedSection e ω hF) (F.quotientTopGradedSection_rightInverse e ω hF) + (F.fastGradedDiagonal W).toSubmodule (fun j => F.reducedSquareGradedSndMap (v j)) himage + (fun i : TopGradedBasisIndex s ω => F.associatedGradedBasis e ω hF i.val) hker + +theorem fullFastDiagonalGenerators_height + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ j i, RationalHeightLE ((bW).repr (v j) i) H) : + ∀ j i, RationalHeightLE ((F.associatedGradedBasis e ω hF).repr + (F.fullFastDiagonalGenerators e ω hF v j) i) H := by + intro j i + cases j with + | inl j => + change RationalHeightLE ((F.associatedGradedBasis e ω hF).repr + (F.quotientTopGradedSection e ω hF (F.reducedSquareGradedSndMap (v j))) i) H + by_cases hi : s + 1 ≤ ω i + · rw [F.quotientTopGradedSection_coordinate_zero e ω hF _ i hi] + exact rationalHeightLE_zero hH + · rw [F.quotientTopGradedSection_coordinate e ω hF _ ⟨i, hi⟩, + F.reducedSquareGradedSndMap_coordinate] + exact hv j _ + | inr j => + exact (basis_repr_height_one (F.associatedGradedBasis e ω hF) j.val i).mono hH + +theorem fullFastDiagonalGenerators_card [Fintype κ] [Fintype ι] : + Fintype.card (κ ⊕ TopGradedBasisIndex s ω) ≤ Fintype.card κ + Fintype.card ι := by + rw [Fintype.card_sum] + exact Nat.add_le_add_left (Fintype.card_le_of_injective Subtype.val Subtype.val_injective) _ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct Matrix + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +local notation "ωW" => (fun i : ReducedSquareBasisIndex s ω => squareBasisWeight ω (Subtype.val i)) +local notation "bW" => F.squareFiltration.quotientTop.associatedGradedBasis + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) + +noncomputable def fullFastHorizontalGenerators + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) : + κ ⊕ TopGradedBasisIndex s ω → L ⧸ F.layer 2 := + fun j => F.gradedLayerOneProjection e ω hF (F.fullFastDiagonalGenerators e ω hF v j) + +theorem fullFastHorizontalGenerators_span + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + (hW : BasisGradedSubmodule bW ωW W.toSubmodule) + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) : + Submodule.span ℚ (Set.range (F.fullFastHorizontalGenerators e ω hF v)) = + F.layerOneGradedSubmodule e ω hF (F.fullFastGradedDiagonal W) := + F.gradedLayerOneProjection_spanning e ω hF (F.fullFastGradedDiagonal W) + (F.fullFastGradedDiagonal_graded e ω hF W hW) (F.fullFastDiagonalGenerators e ω hF v) + (F.fullFastDiagonalGenerators_span e ω hF W v hv) + +theorem fullFastHorizontalGenerators_height + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ j i, RationalHeightLE ((bW).repr (v j) i) H) : + ∀ j i, RationalHeightLE ((F.layerOneBasis e ω hF).repr + (F.fullFastHorizontalGenerators e ω hF v j) i) H := by + intro j + exact F.gradedLayerOneProjection_height e ω hF (F.fullFastDiagonalGenerators e ω hF v j) + (F.fullFastDiagonalGenerators_height e ω hF v hH hv j) + +noncomputable def fullFastHorizontalMatrix + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) : + Matrix (LayerOneBasisIndex ω) (κ ⊕ TopGradedBasisIndex s ω) ℚ := + fun i j => (F.layerOneBasis e ω hF).repr (F.fullFastHorizontalGenerators e ω hF v j) i + +theorem fullFastHorizontalMatrix_height + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ j i, RationalHeightLE ((bW).repr (v j) i) H) : + ∀ i j, RationalHeightLE (F.fullFastHorizontalMatrix e ω hF v i j) H := by + intro i j + exact F.fullFastHorizontalGenerators_height e ω hF v hH hv j i + +noncomputable def fullFastHorizontalCoordinates [Fintype ι] + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) : + Submodule ℝ (LayerOneBasisIndex ω → ℝ) := + ((F.layerOneGradedSubmodule e ω hF (F.fullFastGradedDiagonal W)).baseChange ℝ).map + ((F.layerOneBasis e ω hF).baseChange ℝ).equivFun.toLinearMap + +theorem mem_fullFastHorizontalCoordinates [Fintype ι] + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + (x : ℝ ⊗[ℚ] (L ⧸ F.layer 2)) : + ((F.layerOneBasis e ω hF).baseChange ℝ).equivFun x ∈ + F.fullFastHorizontalCoordinates e ω hF W ↔ + x ∈ (F.layerOneGradedSubmodule e ω hF (F.fullFastGradedDiagonal W)).baseChange ℝ := by + rw [fullFastHorizontalCoordinates, Submodule.mem_map_equiv, LinearEquiv.symm_apply_apply] + +theorem fullFastHorizontalMatrix_span [Fintype ι] + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + (hW : BasisGradedSubmodule bW ωW W.toSubmodule) + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) : + Submodule.span ℝ (Set.range ((F.fullFastHorizontalMatrix e ω hF v).map (Rat.castHom ℝ)).col) = + F.fullFastHorizontalCoordinates e ω hF W := by + have hspan : Submodule.span ℝ (Set.range (fun j => (1 : ℝ) ⊗ₜ[ℚ] + F.fullFastHorizontalGenerators e ω hF v j)) = + (F.layerOneGradedSubmodule e ω hF (F.fullFastGradedDiagonal W)).baseChange ℝ := by + rw [← F.fullFastHorizontalGenerators_span e ω hF W hW v hv, + Submodule.baseChange_span, ← Set.range_comp] + rfl + rw [fullFastHorizontalCoordinates, ← hspan, Submodule.map_span, ← Set.range_comp] + congr 1 + apply congrArg Set.range + funext j i + change ((F.layerOneBasis e ω hF).repr (F.fullFastHorizontalGenerators e ω hF v j) i : ℝ) = + ((F.layerOneBasis e ω hF).baseChange ℝ).repr + ((1 : ℝ) ⊗ₜ[ℚ] F.fullFastHorizontalGenerators e ω hF v j) i + rw [Basis.baseChange_repr_tmul] + simp only [Rat.smul_def, mul_one] + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FullFastRelativeSpanning.lean b/lean/OAI/Combinatorics/Progressions/Linear/FullFastRelativeSpanning.lean new file mode 100644 index 0000000000000000000000000000000000000000..bef32ba9cc1d87892c2cfb0789b27504b5344bde --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FullFastRelativeSpanning.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Progressions.Dynamics.FastCoefficientGeneratorBudget +import OAI.Combinatorics.Progressions.Estimates.FastGradedRelativeInvariance +import OAI.Combinatorics.Progressions.Geometry.GradedTopCoordinates + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +local notation "ωW" => (fun a : ReducedSquareBasisIndex s ω => squareBasisWeight ω (Subtype.val a)) +local notation "bW" => F.squareFiltration.quotientTop.associatedGradedBasis + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) +local notation "ωQ" => (fun a : QuotientTopBasisIndex s ω => ω (Subtype.val a)) +local notation "bQ" => F.quotientTop.associatedGradedBasis + (F.quotientTopBasis e ω hF) ωQ (F.quotientTopBasis_layers e ω hF) + +theorem reducedSquareGradedSndMap_basis_height (a : ReducedSquareBasisIndex s ω) + (i : QuotientTopBasisIndex s ω) : + RationalHeightLE ((bQ).repr (F.reducedSquareGradedSndMap (bW a)) i) 1 := by + rw [F.reducedSquareGradedSndMap_coordinate e ω hF] + exact basis_repr_height_one bW a _ + +variable [Fintype ι] [Fintype κ] + +theorem exists_bounded_fast_graded_relative_kernel_generators + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) + (hspan : Submodule.span ℚ (Set.range v) = W.toSubmodule) + {H : ℕ} (hH : 1 ≤ H) (hv : ∀ j i, RationalHeightLE ((bW).repr (v j) i) H) : + ∃ r : ℕ, r ≤ Fintype.card (QuotientTopBasisIndex s ω) ∧ + ∃ z : κ → F.squareFiltration.quotientTop.AssociatedGraded, + Submodule.span ℚ (Set.range z) = F.fastGradedRelativeKernel W ∧ + ∀ j i, RationalHeightLE ((bW).repr (z j) i) + (fastKernelGeneratorHeight (Fintype.card (ReducedSquareBasisIndex s ω)) + (Fintype.card κ) r H) := by + have hPv (j : κ) (i : QuotientTopBasisIndex s ω) : + RationalHeightLE ((bQ).repr (F.reducedSquareGradedSndMap (v j)) i) + ((Fintype.card (ReducedSquareBasisIndex s ω) + 1) * + H ^ Fintype.card (ReducedSquareBasisIndex s ω)) := by + simpa only [mul_one, LieHom.coe_toLinearMap] using linearMap_coordinate_height + bW bQ F.reducedSquareGradedSndMap.toLinearMap + (F.reducedSquareGradedSndMap_basis_height e ω hF) (v j) (hv j) i + have hB : 1 ≤ (Fintype.card (ReducedSquareBasisIndex s ω) + 1) * + H ^ Fintype.card (ReducedSquareBasisIndex s ω) := by + have hHp : 0 < H := hH + exact Nat.succ_le_of_lt (by positivity) + have he := exists_bounded_span_kernel_generators bW bQ + F.reducedSquareGradedSndMap.toLinearMap v hB hv hPv + simpa only [hspan, fastKernelGeneratorHeight, fastGradedRelativeKernel, + LieHom.ker_toSubmodule] using he + +theorem exists_bounded_full_fast_relative_generators + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) + (hspan : Submodule.span ℚ (Set.range v) = W.toSubmodule) + {H : ℕ} (hH : 1 ≤ H) (hv : ∀ j i, RationalHeightLE ((bW).repr (v j) i) H) : + ∃ r : ℕ, r ≤ Fintype.card (QuotientTopBasisIndex s ω) ∧ + ∃ z : κ → F.AssociatedGraded, + Submodule.span ℚ (Set.range z) = F.fullFastGradedRelative e ω hF W ∧ + ∀ j i, RationalHeightLE ((F.associatedGradedBasis e ω hF).repr (z j) i) + (fastCoefficientGeneratorHeight (Fintype.card (ReducedSquareBasisIndex s ω)) + (Fintype.card κ) r H) := by + obtain ⟨r, hr, z, hz, hzh⟩ := + F.exists_bounded_fast_graded_relative_kernel_generators e ω hF W v hspan hH hv + refine ⟨r, hr, (F.reducedSquareGradedDifference e ω hF) ∘ z, ?_, fun j i => ?_⟩ + · rw [fullFastGradedRelative, ← hz, Submodule.map_span, ← Set.range_comp] + · simpa only [Function.comp_apply, mul_one, fastCoefficientGeneratorHeight] using + linearMap_coordinate_height bW (F.associatedGradedBasis e ω hF) + (F.reducedSquareGradedDifference e ω hF) + (F.reducedSquareGradedDifference_basis_height e ω hF) (z j) (hzh j) i + +theorem exists_full_fast_relative_generators_exp + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + (v : κ → F.squareFiltration.quotientTop.AssociatedGraded) + (hspan : Submodule.span ℚ (Set.range v) = W.toSubmodule) + {H : ℕ} (hH : 1 ≤ H) (hv : ∀ j i, RationalHeightLE ((bW).repr (v j) i) H) + {p : ℝ} (hp : 0 ≤ p) + (hn : (Fintype.card (ReducedSquareBasisIndex s ω) : ℝ) ≤ p) + (hm : (Fintype.card κ : ℝ) ≤ p) + (hq : (Fintype.card (QuotientTopBasisIndex s ω) : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ H' : ℕ, 1 ≤ H' ∧ (H' : ℝ) ≤ Real.exp ((p + 2) ^ 40) ∧ + ∃ z : κ → F.AssociatedGraded, + Submodule.span ℚ (Set.range z) = F.fullFastGradedRelative e ω hF W ∧ + ∀ j i, RationalHeightLE ((F.associatedGradedBasis e ω hF).repr (z j) i) H' := by + obtain ⟨r, hr, z, hz, hzh⟩ := + F.exists_bounded_full_fast_relative_generators e ω hF W v hspan hH hv + exact ⟨_, fastCoefficientGeneratorHeight_pos _ _ _ _ hH, + fastCoefficientGeneratorHeight_le_exp _ _ _ _ hp hn hm + ((Nat.cast_le.mpr hr).trans hq) hHp, z, hz, hzh⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/FurstenbergWeissProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/FurstenbergWeissProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..be6cb41874b6b4ee387f4c1695797a18306de8d8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/FurstenbergWeissProjection.lean @@ -0,0 +1,175 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +variable {V : Type*} [AddCommGroup V] [Module ℚ V] + +def fourCoordinateKernel (S : Finset (Fin 4)) : Submodule ℚ (Fin 4 → V) := + ⨅ k ∈ S, LinearMap.ker (LinearMap.proj k) + +theorem mem_fourCoordinateKernel (S : Finset (Fin 4)) (v : Fin 4 → V) : + v ∈ fourCoordinateKernel S ↔ ∀ k ∈ S, v k = 0 := by + simp [fourCoordinateKernel] + +def fourFirstProjection (J : Submodule ℚ (Fin 4 → V)) : Submodule ℚ V := + J.map (LinearMap.proj 0) + +theorem mem_fourFirstProjection (J : Submodule ℚ (Fin 4 → V)) (v : V) : + v ∈ fourFirstProjection J ↔ ∃ w ∈ J, w 0 = v := Iff.rfl + +def fourSparseFirstProjection (J : Submodule ℚ (Fin 4 → V)) (S : Finset (Fin 4)) : Submodule ℚ V := + (J ⊓ fourCoordinateKernel S).map (LinearMap.proj 0) + +theorem mem_fourSparseFirstProjection (J : Submodule ℚ (Fin 4 → V)) + (S : Finset (Fin 4)) (v : V) : + v ∈ fourSparseFirstProjection J S ↔ ∃ w ∈ J, w 0 = v ∧ ∀ k ∈ S, w k = 0 := by + change (∃ w, w ∈ J ⊓ fourCoordinateKernel S ∧ w 0 = v) ↔ _ + constructor + · rintro ⟨w, ⟨hw, hS⟩, hv⟩ + exact ⟨w, hw, hv, (mem_fourCoordinateKernel S w).mp hS⟩ + · rintro ⟨w, hw, hv, hS⟩ + exact ⟨w, ⟨hw, (mem_fourCoordinateKernel S w).mpr hS⟩, hv⟩ + +theorem fourSparseFirstProjection_le (J : Submodule ℚ (Fin 4 → V)) (S : Finset (Fin 4)) : + fourSparseFirstProjection J S ≤ fourFirstProjection J := + Submodule.map_mono inf_le_left + +def fourDependentProjection (J : Submodule ℚ (Fin 4 → V)) : Submodule ℚ V := + fourSparseFirstProjection J {1, 2} ⊓ fourSparseFirstProjection J {1, 3} + +theorem fourDependentProjection_le (J : Submodule ℚ (Fin 4 → V)) : + fourDependentProjection J ≤ fourFirstProjection J := + inf_le_left.trans (fourSparseFirstProjection_le J {1, 2}) + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {V W : Type*} [AddCommGroup V] [Module ℚ V] [AddCommGroup W] [Module ℚ W] + +def fourLinearMap (f : V →ₗ[ℚ] W) : (Fin 4 → V) →ₗ[ℚ] (Fin 4 → W) := + LinearMap.pi (fun k => f.comp (LinearMap.proj k)) + +theorem fourFirstProjection_map (f : V →ₗ[ℚ] W) (J : Submodule ℚ (Fin 4 → V)) : + fourFirstProjection (J.map (fourLinearMap f)) = (fourFirstProjection J).map f := by + ext y + constructor + · rintro ⟨w, ⟨v, hv, rfl⟩, rfl⟩ + exact ⟨v 0, ⟨v, hv, rfl⟩, rfl⟩ + · rintro ⟨x, ⟨v, hv, rfl⟩, rfl⟩ + exact ⟨fourLinearMap f v, ⟨v, hv, rfl⟩, rfl⟩ + +theorem fourSparseFirstProjection_map (f : V →ₗ[ℚ] W) (hf : Function.Injective f) + (J : Submodule ℚ (Fin 4 → V)) (S : Finset (Fin 4)) : + fourSparseFirstProjection (J.map (fourLinearMap f)) S = (fourSparseFirstProjection J S).map f := by + ext y + constructor + · intro hy + obtain ⟨w, ⟨v, hv, rfl⟩, hzero, hS⟩ := (mem_fourSparseFirstProjection _ _ _).mp hy + refine ⟨v 0, (mem_fourSparseFirstProjection _ _ _).mpr ⟨v, hv, rfl, ?_⟩, hzero⟩ + intro k hk + exact hf ((hS k hk).trans (map_zero f).symm) + · rintro ⟨x, hx, rfl⟩ + obtain ⟨v, hv, rfl, hS⟩ := (mem_fourSparseFirstProjection _ _ _).mp hx + refine (mem_fourSparseFirstProjection _ _ _).mpr + ⟨fourLinearMap f v, ⟨v, hv, rfl⟩, rfl, ?_⟩ + intro k hk + change f (v k) = 0 + rw [hS k hk, map_zero] + +theorem fourDependentProjection_map (f : V →ₗ[ℚ] W) (hf : Function.Injective f) + (J : Submodule ℚ (Fin 4 → V)) : + fourDependentProjection (J.map (fourLinearMap f)) = (fourDependentProjection J).map f := by + rw [fourDependentProjection, fourSparseFirstProjection_map f hf, fourSparseFirstProjection_map f hf] + ext y + constructor + · rintro ⟨⟨x, hx, hxy⟩, ⟨z, hz, hzy⟩⟩ + have hxz : x = z := hf (hxy.trans hzy.symm) + exact ⟨x, ⟨hx, hxz.symm ▸ hz⟩, hxy⟩ + · rintro ⟨x, ⟨hx, hz⟩, rfl⟩ + exact ⟨⟨x, hx, rfl⟩, ⟨x, hz, rfl⟩⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem four_sparse_lifts_vanish {I : Type*} {V : I → Type*} + [∀ i, AddCommGroup (V i)] [∀ i, Module ℚ (V i)] + {M A : Type*} [Zero M] [AddCommGroup A] + (S : Set I) (B : (∀ i, V i) → M) + (hzero : ∀ v i, i ∈ S → v i = 0 → B v = 0) + (η : M → A) (hη : η 0 = 0) (J : ∀ i, Submodule ℚ (Fin 4 → V i)) + (hJ : ∀ v : ∀ i, Fin 4 → V i, (∀ i, v i ∈ J i) → + η (B (fun i => v i 0)) + η (B (fun i => v i 1)) - + η (B (fun i => v i 2)) - η (B (fun i => v i 3)) = 0) + (v : ∀ i, V i) (hv : ∀ i, v i ∈ fourFirstProjection (J i)) + (a b : I) (hab : a ≠ b) (ha : a ∈ S) (hb : b ∈ S) + (hva : v a ∈ fourSparseFirstProjection (J a) {1, 2}) + (hvb : v b ∈ fourSparseFirstProjection (J b) {1, 3}) : η (B v) = 0 := by + classical + have hlift (i : I) : ∃ w ∈ J i, w 0 = v i := (mem_fourFirstProjection (J i) (v i)).mp (hv i) + choose w hwJ hw0 using hlift + obtain ⟨xa, hxa, hxa0, hxaz⟩ := (mem_fourSparseFirstProjection (J a) {1, 2} (v a)).mp hva + obtain ⟨xb, hxb, hxb0, hxbz⟩ := (mem_fourSparseFirstProjection (J b) {1, 3} (v b)).mp hvb + let z : ∀ i, Fin 4 → V i := Function.update (Function.update w a xa) b xb + have hza : z a = xa := by simp [z, hab] + have hzb : z b = xb := by simp [z] + have hzJ (i : I) : z i ∈ J i := by + by_cases hib : i = b + · subst i + rw [hzb] + exact hxb + by_cases hia : i = a + · subst i + rw [hza] + exact hxa + simpa only [z, Function.update_of_ne hib, Function.update_of_ne hia] using hwJ i + have hzfirst : (fun i => z i 0) = v := by + funext i + by_cases hib : i = b + · subst i + rw [hzb] + exact hxb0 + by_cases hia : i = a + · subst i + rw [hza] + exact hxa0 + simpa only [z, Function.update_of_ne hib, Function.update_of_ne hia] using hw0 i + have hz1 : B (fun i => z i 1) = 0 := hzero _ a ha (by rw [hza]; exact hxaz 1 (by simp)) + have hz2 : B (fun i => z i 2) = 0 := hzero _ a ha (by rw [hza]; exact hxaz 2 (by simp)) + have hz3 : B (fun i => z i 3) = 0 := hzero _ b hb (by rw [hzb]; exact hxbz 3 (by simp)) + have h := hJ z hzJ + simpa only [hzfirst, hz1, hz2, hz3, hη, add_zero, sub_zero] using h + +theorem four_dependent_inputs_vanish {I : Type*} {V : I → Type*} + [∀ i, AddCommGroup (V i)] [∀ i, Module ℚ (V i)] + {M A : Type*} [Zero M] [AddCommGroup A] + (S : Set I) (B : (∀ i, V i) → M) + (hzero : ∀ v i, i ∈ S → v i = 0 → B v = 0) + (η : M → A) (hη : η 0 = 0) (J : ∀ i, Submodule ℚ (Fin 4 → V i)) + (hJ : ∀ v : ∀ i, Fin 4 → V i, (∀ i, v i ∈ J i) → + η (B (fun i => v i 0)) + η (B (fun i => v i 1)) - + η (B (fun i => v i 2)) - η (B (fun i => v i 3)) = 0) + (v : ∀ i, V i) (hv : ∀ i, v i ∈ fourFirstProjection (J i)) + (a b : I) (hab : a ≠ b) (ha : a ∈ S) (hb : b ∈ S) + (hva : v a ∈ fourDependentProjection (J a)) + (hvb : v b ∈ fourDependentProjection (J b)) : η (B v) = 0 := + four_sparse_lifts_vanish S B hzero η hη J hJ v hv a b hab ha hb hva.1 hvb.2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/GeometricKernelLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/GeometricKernelLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd4c30e4763937a73c72dd22d6c2f709033761b0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/GeometricKernelLaw.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedGeometricInputBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +variable {m : ℕ} {G : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) + +theorem geometricScale_cutoff {p c e E : ℝ} + (hp : 0 ≤ p) (hc : 0 ≤ c) (he : 0 ≤ e) (hE : 0 ≤ E) + (hScale : S = allocatedSiteScale (G := G) B U b hR hσ (allocatedGeometryInput m p c 0 E) e E) + {M : ℕ} (hM : (M : ℝ) ≤ Real.exp p) : M ≤ S.value := by + obtain ⟨hq, hpq, _, _, _, _⟩ := allocatedGeometryInput_bounds m hp hc (le_refl 0) hE + have hnum := (allocatedSiteScaleNumeric_bounds m hq).2.1 + have hS := allocatedSiteScale_lower (G := G) B U b hR hσ hq he hE + rw [← hScale] at hS + exact_mod_cast hM.trans ((Real.exp_le_exp.mpr (hpq.trans hnum)).trans hS) + +theorem geometricScale_affine_bad_probability [DecidableEq G] + {dim : ℕ} [Nonempty (Fin dim)] {p c e E Ebad : ℝ} + (hp : 0 ≤ p) (hc : 0 ≤ c) (he : 0 ≤ e) (hE : 0 ≤ E) + (hScale : S = allocatedSiteScale (G := G) B U b hR hσ (allocatedGeometryInput m p c 0 E) e E) + (hG : dim * (dim + 2) ≤ Fintype.card G) (selection : Fin dim ↪ G) + (M D : ℕ) (hM : 0 < M) (hD : 0 < D) + (hcutoff : (scalarKernelCutoff (Fin dim) G M D (Real.exp (-(Ebad + 1))) : ℝ) ≤ Real.exp p) : + let cutoff := scalarKernelCutoff (Fin dim) G M D (Real.exp (-(Ebad + 1))) + let hlarge := geometricScale_cutoff B U b hR hσ S hp hc he hE hScale hcutoff + ∀ (window : G → ℕ) (hwindow : ∀ g, window g ≤ S.value) (hDwindow : ∀ g, S.value ≤ D * window g) + (shift : G → ℤ) (moduli : G → Option (Fin dim) → ℕ) + (residues : ∀ g i, ZMod (moduli g i)) + (hmoduli : ∀ g i, 0 < moduli g i) (hmoduliM : ∀ g i, moduli g i ≤ M), + (FiniteProbabilityWeights.pi (fun g => + affineScalarCubeWindowWeights (Fin dim) S.value (window g) M D (shift g) S.positive + (hwindow g) (hDwindow g) (moduli g) (residues g) (hmoduli g) (hmoduliM g) + (scalarKernelCutoff_window_size (Fin dim) G hM hD (Real.exp_pos _) hlarge (hDwindow g)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple selection (1 / (cutoff : ℝ)) cutoff x) ≤ Real.exp (-(Ebad + 1)) := by + intro cutoff hlarge window hwindow hDwindow shift moduli residues hmoduli hmoduliM + exact affineKernel_explicit_probability_le_of_card_le (Fin dim) G + (by simpa only [Fintype.card_fin] using hG) selection hM hD (Real.exp_pos _) S.positive + hlarge window hwindow hDwindow shift moduli residues hmoduli hmoduliM + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/GoodKernelJetBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/GoodKernelJetBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6a24becdd0ea1b9c8d89410412c2508544bd9fc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/GoodKernelJetBudget.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.Progressions.Lattices.IntegerAffineResidues +import OAI.Combinatorics.Progressions.Linear.AllocatedKernelPrimitiveBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem goodScalarKernelTuple_index_le_exp {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] {L B : ℕ} {H κ : ℝ} + (s : I → J) (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple s κ B x) + (hB : (B : ℝ) ≤ Real.exp H) : + ((scalarCubeDifferenceMatrix x).mulVecLin.range.toAddSubgroup.index : ℝ) ≤ + Real.exp (Fintype.card I * H) := by + have hi := hasBoundedScalarPeriod_index_le (scalarCubeDifferenceMatrix x).mulVecLin.range B hx.2 + calc + _ ≤ (B : ℝ)^Fintype.card I := by exact_mod_cast hi + _ ≤ (Real.exp H)^Fintype.card I := pow_le_pow_left₀ (Nat.cast_nonneg _) hB _ + _ = _ := (Real.exp_nat_mul _ _).symm + +theorem goodScalarKernelTuple_period_powers_le_exp {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] {L B : ℕ} {H κ : ℝ} + (s : I → J) (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple s κ B x) + (hB : (B : ℝ) ≤ Real.exp H) : + ∃ a : ℕ, 0 < a ∧ a ≤ B ∧ + integerScalarLattice I (a : ℤ) ≤ (scalarCubeDifferenceMatrix x).mulVecLin.range ∧ + ∀ h : ℕ, ((a^h : ℕ) : ℝ) ≤ Real.exp (h * H) := by + obtain ⟨a, ha, haB, hperiod⟩ := hx.2 + refine ⟨a, ha, haB, hperiod, fun h => ?_⟩ + have haR : (a : ℝ) ≤ Real.exp H := (by exact_mod_cast haB : (a : ℝ) ≤ B).trans hB + push_cast + exact (pow_le_pow_left₀ (Nat.cast_nonneg _) haR h).trans_eq (Real.exp_nat_mul _ _).symm + +theorem goodScalarKernelTuple_inverse_le_exp {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] {L B : ℕ} {H : ℝ} + (hL : 0 < L) (hBpos : 0 < B) (s : I → J) (x : J → IntegerScalarCubeBox I L) + (hx : GoodScalarKernelTuple s (1 / (B : ℝ)) B x) (hB : (B : ℝ) ≤ Real.exp H) : + (matrixSupCLM (normalizedScalarCubePivot s x)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedScalarCubePivot s x)).inverse‖ ≤ + Real.exp (Fintype.card I + (Fintype.card I : ℝ)^2 + H) := by + have hBp : (0 : ℝ) < B := by exact_mod_cast hBpos + obtain ⟨hinv, hnorm⟩ := goodScalarKernelTuple_pivot_inverse hL s (1 / (B : ℝ)) B + (one_div_pos.mpr hBp) x hx + refine ⟨hinv, hnorm.trans ?_⟩ + rw [one_div, div_inv_eq_mul] + have hq : (Fintype.card I : ℝ) ≤ Real.exp (Fintype.card I : ℝ) := by + linarith [Real.add_one_le_exp (Fintype.card I : ℝ)] + calc + _ ≤ Real.exp (Fintype.card I : ℝ) * Real.exp ((Fintype.card I : ℝ)^2) * Real.exp H := by + gcongr + exact factorial_le_exp_sq _ + _ = _ := by rw [← Real.exp_add, ← Real.exp_add] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem goodScalarKernelTuple_jet_budget {I J O : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype O] {L B : ℕ} {H κ : ℝ} + (selection : I → J) (x : J → IntegerScalarCubeBox I L) + (hx : GoodScalarKernelTuple selection κ B x) (hB : (B : ℝ) ≤ Real.exp H) + (root : J → ℤ) (s : ℕ) : + ∃ a : ℕ, 0 < a ∧ a ≤ B ∧ ((a^s : ℕ) : ℝ) ≤ Real.exp (s * H) ∧ + ∀ (h : ℕ), h ≤ s → ∀ (rows : O → Finset I), Function.Injective rows → + (∀ o, (rows o).card ≤ h) → + integerScalarLattice O ((a^s : ℕ) : ℤ) ≤ + (boundedDegreeIntegerJetMatrix root (scalarCubeDifferenceMatrix x) h rows).mulVecLin.range ∧ + ((boundedDegreeIntegerJetMatrix root (scalarCubeDifferenceMatrix x) h rows).mulVecLin.range.toAddSubgroup.index : ℝ) ≤ + Real.exp (Fintype.card O * (s * H)) := by + obtain ⟨a, ha, haB, hperiod, hpowers⟩ := goodScalarKernelTuple_period_powers_le_exp selection x hx hB + refine ⟨a, ha, haB, hpowers s, fun h hh rows hinj hdegree => ?_⟩ + have hp := boundedDegreeIntegerJetMatrix_common_period root (scalarCubeDifferenceMatrix x) + (a : ℤ) hperiod s h hh rows hinj hdegree + rw [← Nat.cast_pow] at hp + refine ⟨hp, ?_⟩ + let : NeZero (a^s) := ⟨(Nat.pow_pos ha).ne'⟩ + have hi := residueLatticeImage_index_le + (boundedDegreeIntegerJetMatrix root (scalarCubeDifferenceMatrix x) h rows).mulVecLin.range (a^s) hp + calc + _ ≤ (((a^s : ℕ) : ℝ)^Fintype.card O) := by exact_mod_cast hi + _ ≤ (Real.exp (s * H))^Fintype.card O := pow_le_pow_left₀ (Nat.cast_nonneg _) (hpowers s) _ + _ = _ := (Real.exp_nat_mul _ _).symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/GradeProjectionRemainder.lean b/lean/OAI/Combinatorics/Progressions/Linear/GradeProjectionRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d8d318188d289a5a6be66580d8bb7ed5b4f4487 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/GradeProjectionRemainder.lean @@ -0,0 +1,121 @@ +import OAI.Combinatorics.Progressions.Estimates.CurrentLayerSplitting +import OAI.Combinatorics.Progressions.Estimates.SymbolAbsorptionBounds + +namespace OAI + +section + +namespace Erdos3 + +open Module + +section Coordinates + +variable {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + +theorem basisGradeProjection_eq_zero_of_mem_higher (b : Basis ι K V) + (w : ι → ℕ) (k : ℕ) (x : V) + (hx : x ∈ Submodule.span K (b '' {i | k + 1 ≤ w i})) : + basisGradeProjection b w k x = 0 := by + apply (basisCoordinateProjection_eq_zero_iff b {i | w i = k} x).mpr + apply Submodule.span_mono (Set.image_mono ?_) hx + intro i hi + change w i ≠ k + change k + 1 ≤ w i at hi + omega + +theorem sub_basisGradeProjection_mem_higher (b : Basis ι K V) + (w : ι → ℕ) (k : ℕ) (x : V) + (hx : x ∈ Submodule.span K (b '' {i | k ≤ w i})) : + x - basisGradeProjection b w k x ∈ Submodule.span K (b '' {i | k + 1 ≤ w i}) := by + apply (basis_mem_span_image_iff b _ _).mpr + intro i hi + change ¬ k + 1 ≤ w i at hi + rw [map_sub, Finsupp.sub_apply, basisGradeProjection_repr] + by_cases hki : w i = k + · simp only [hki, ↓reduceIte, sub_self] + · rw [ite_eq_right hki, sub_zero] + exact (basis_mem_span_image_iff b _ x).mp hx i (by + change ¬ k ≤ w i + omega) + +theorem BasisGradedSubmodule.mem_sup_higher_of_grade (b : Basis ι K V) + (w : ι → ℕ) (U : Submodule K V) (hU : BasisGradedSubmodule b w U) + (k : ℕ) (x : V) (hx : x ∈ U ⊔ Submodule.span K (b '' {i | k ≤ w i})) + (hgrade : basisGradeProjection b w k x ∈ U) : + x ∈ U ⊔ Submodule.span K (b '' {i | k + 1 ≤ w i}) := by + obtain ⟨u, hu, z, hz, rfl⟩ := Submodule.mem_sup.mp hx + have hgz : basisGradeProjection b w k z ∈ U := by + have h := U.sub_mem hgrade (hU k u hu) + simpa only [map_add, add_sub_cancel_left] using h + refine Submodule.mem_sup.mpr ⟨u + basisGradeProjection b w k z, U.add_mem hu hgz, + z - basisGradeProjection b w k z, sub_basisGradeProjection_mem_higher b w k z hz, ?_⟩ + abel + +end Coordinates + +namespace NilpotentLieFiltration + +open scoped TensorProduct + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) + +include hlayers in +theorem realGradeProjection_eq_zero_of_mem_next_layer (k : ℕ) (x : ℝ ⊗[ℚ] L) + (hx : x ∈ F.realification.layer (k + 1)) : + basisGradeProjection (b.baseChange ℝ) w k x = 0 := by + apply basisGradeProjection_eq_zero_of_mem_higher + change x ∈ (F.realLayer (k + 1)).toSubmodule at hx + rwa [F.realLayer_eq_span_basis b (k + 1) _ (hlayers (k + 1))] at hx + +include hlayers in +theorem realGradeProjection_bch_triple (k : ℕ) (a p d : ℝ ⊗[ℚ] L) + (ha : a ∈ F.realification.layer k) (hd : d ∈ F.realification.layer k) : + basisGradeProjection (b.baseChange ℝ) w k (lieBCH s (lieBCH s a p) d) = + basisGradeProjection (b.baseChange ℝ) w k a + + basisGradeProjection (b.baseChange ℝ) w k p + + basisGradeProjection (b.baseChange ℝ) w k d := by + have h := F.realGradeProjection_eq_zero_of_mem_next_layer b w hlayers k _ + (F.realification.bch_triple_sub_sum_mem_next_layer k a p d ha hd) + simpa only [map_sub, map_add, sub_eq_zero] using h + +include hlayers in +theorem realGradeProjection_normalized_splitting (k : ℕ) + (E P R E₀ R₀ : F.realification.Group) + (hE : NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) E₀ = + NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) E) + (hR : NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) R = + NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) R₀) : + basisGradeProjection (b.baseChange ℝ) w k (E₀⁻¹ * (E * P * R) * R₀⁻¹).coord = + basisGradeProjection (b.baseChange ℝ) w k (E₀⁻¹ * E).coord + + basisGradeProjection (b.baseChange ℝ) w k P.coord + + basisGradeProjection (b.baseChange ℝ) w k (R * R₀⁻¹).coord := by + have h := F.realGradeProjection_eq_zero_of_mem_next_layer b w hlayers k _ + (F.realification.normalized_splitting_sub_sum_mem_next_layer k E P R E₀ R₀ hE hR) + simpa only [map_sub, map_add, sub_eq_zero] using h + +include hlayers in + +theorem realGradeProjection_normalized_residual_mem + (U : Submodule ℝ (ℝ ⊗[ℚ] L)) + (hU : BasisGradedSubmodule (b.baseChange ℝ) w U) (k : ℕ) + (E P R E₀ R₀ : F.realification.Group) (hP : P.coord ∈ U) + (hE : NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) E₀ = + NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) E) + (hR : NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) R = + NilpotentLieBCHGroup.quotientHom (F.realification.layerIdeal k) R₀) : + basisGradeProjection (b.baseChange ℝ) w k (E₀⁻¹ * (E * P * R) * R₀⁻¹).coord - + basisGradeProjection (b.baseChange ℝ) w k (E₀⁻¹ * E).coord - + basisGradeProjection (b.baseChange ℝ) w k (R * R₀⁻¹).coord ∈ U := by + rw [F.realGradeProjection_normalized_splitting b w hlayers k E P R E₀ R₀ hE hR] + convert hU k P.coord hP using 1 + abel + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/GramBasisChange.lean b/lean/OAI/Combinatorics/Progressions/Linear/GramBasisChange.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc23bb73e473f4d24d607cbd8dd38c0001fcaed3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/GramBasisChange.lean @@ -0,0 +1,32 @@ +import Mathlib.Analysis.InnerProductSpace.GramMatrix + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem gram_det_basis_change {ι E : Type*} [Fintype ι] [DecidableEq ι] + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + (b : Basis ι ℝ E) (v : ι → E) : + (Matrix.gram ℝ v).det = (b.det v) ^ 2 * (Matrix.gram ℝ b).det := by + classical + let o : OrthonormalBasis ι ℝ E := (stdOrthonormalBasis ℝ E).reindex + (Fintype.equivOfCardEq (by simpa only [Fintype.card_fin] using finrank_eq_card_basis b)) + have hd (w : ι → E) : (Matrix.gram ℝ w).det = (o.toBasis.toMatrix w).det ^ 2 := by + rw [Matrix.gram_eq_conjTranspose_mul o w, Matrix.det_mul, Matrix.det_conjTranspose] + have he : o.toBasis.toMatrix w = Matrix.of (fun i j => o.repr (w j) i) := by + ext i j + rfl + rw [he] + simp [pow_two] + rw [hd v, hd b, b.det_apply, ← o.toBasis.toMatrix_mul_toMatrix b v, Matrix.det_mul] + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/HomogeneousGradedProjectionBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/HomogeneousGradedProjectionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..377c33219690068fd62e474c672be38265507e38 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/HomogeneousGradedProjectionBounds.lean @@ -0,0 +1,147 @@ +import OAI.Combinatorics.Progressions.Estimates.ProjectedPointwiseCoefficient +import OAI.Combinatorics.Progressions.Estimates.WeightedTranslationAssociatedGraded + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration +open Module +variable {ι κ L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (c : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + (hc : BasisHomogeneousBrackets c ν) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +noncomputable def homogeneousGradedProjection : F.AssociatedGraded →ₗ⁅ℚ⁆ M := + (G.homogeneousAssociatedGradedEquiv c ν hG hc).toLieHom.comp + (F.associatedGradedMap G φ hφ) + +@[simp] theorem homogeneousGradedProjection_repr (x : F.AssociatedGraded) (j : κ) : + c.repr (F.homogeneousGradedProjection G c ν hG hc φ hφ x) j = + (G.associatedGradedBasis c ν hG).repr (F.associatedGradedMap G φ hφ x) j := + G.homogeneousAssociatedGradedEquiv_repr c ν hG hc _ j + +variable (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem homogeneousGradedProjection_basis_repr (i : ι) (j : κ) : + c.repr (F.homogeneousGradedProjection G c ν hG hc φ hφ + (F.associatedGradedBasis b ω hF i)) j = + if ω i = ν j then c.repr (φ (b i)) j else 0 := by + rw [F.homogeneousGradedProjection_repr, + F.associatedGradedMap_basis_repr G b ω hF c ν hG φ hφ] + +theorem homogeneousGradedProjection_gradeProjection (r : ℕ) (x : F.AssociatedGraded) : + F.homogeneousGradedProjection G c ν hG hc φ hφ + (basisGradeProjection (F.associatedGradedBasis b ω hF) ω r x) = + basisGradeProjection c ν r (F.homogeneousGradedProjection G c ν hG hc φ hφ x) := by + apply basisBlockMap_commutes (F.associatedGradedBasis b ω hF) c ω ν + (F.homogeneousGradedProjection G c ν hG hc φ hφ).toLinearMap + intro i j hij + change c.repr (F.homogeneousGradedProjection G c ν hG hc φ hφ + (F.associatedGradedBasis b ω hF i)) j = 0 + rw [F.homogeneousGradedProjection_basis_repr G c ν hG hc φ hφ b ω hF] + exact ite_eq_right (Ne.symm hij) + +theorem homogeneousGradedProjection_image_graded + (W : LieSubalgebra ℚ F.AssociatedGraded) + (hW : BasisGradedSubmodule (F.associatedGradedBasis b ω hF) ω W.toSubmodule) : + BasisGradedSubmodule c ν + (W.map (F.homogeneousGradedProjection G c ν hG hc φ hφ)).toSubmodule := by + rintro r y ⟨x, hx, rfl⟩ + exact ⟨basisGradeProjection (F.associatedGradedBasis b ω hF) ω r x, hW r x hx, + F.homogeneousGradedProjection_gradeProjection G c ν hG hc φ hφ b ω hF r x⟩ + + theorem homogeneousGradedProjection_span {J : Type*} + (W : LieSubalgebra ℚ F.AssociatedGraded) (v : J → F.AssociatedGraded) + (hv : Submodule.span ℚ (Set.range v) = W.toSubmodule) : + Submodule.span ℚ (Set.range (fun j => F.homogeneousGradedProjection G c ν hG hc φ hφ (v j))) = + (W.map (F.homogeneousGradedProjection G c ν hG hc φ hφ)).toSubmodule := by + change _ = W.toSubmodule.map (F.homogeneousGradedProjection G c ν hG hc φ hφ).toLinearMap + rw [← hv, Submodule.map_span] + congr 1 + exact Set.range_comp _ _ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped BigOperators + +variable {ι κ L M : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (c : Basis κ ℚ M) (ν : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + (hc : BasisHomogeneousBrackets c ν) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem homogeneousGradedProjection_repr_sum (x : F.AssociatedGraded) (j : κ) : + c.repr (F.homogeneousGradedProjection G c ν hG hc φ hφ x) j = + ∑ i, (F.associatedGradedBasis b ω hF).repr x i * + (if ω i = ν j then c.repr (φ (b i)) j else 0) := by + classical + conv_lhs => rw [← (F.associatedGradedBasis b ω hF).sum_repr x] + simp only [map_sum, map_smul, Finsupp.finsetSum_apply, Finsupp.smul_apply, + smul_eq_mul, F.homogeneousGradedProjection_basis_repr G c ν hG hc φ hφ b ω hF] + +theorem homogeneousGradedProjection_coordinate_height {H K : ℕ} (hH : 1 ≤ H) + (hentries : ∀ i j, RationalHeightLE (c.repr (φ (b i)) j) H) + (x : F.AssociatedGraded) + (hx : ∀ i, RationalHeightLE ((F.associatedGradedBasis b ω hF).repr x i) K) (j : κ) : + RationalHeightLE (c.repr (F.homogeneousGradedProjection G c ν hG hc φ hφ x) j) + ((Fintype.card ι + 1) * (K * H) ^ Fintype.card ι) := by + apply linearMap_coordinate_height (F.associatedGradedBasis b ω hF) c + (F.homogeneousGradedProjection G c ν hG hc φ hφ).toLinearMap _ x hx j + intro i k + change RationalHeightLE (c.repr + (F.homogeneousGradedProjection G c ν hG hc φ hφ (F.associatedGradedBasis b ω hF i)) k) H + rw [F.homogeneousGradedProjection_basis_repr G c ν hG hc φ hφ b ω hF] + split_ifs + · exact hentries i k + · exact ⟨by simp, by simpa using hH⟩ + +theorem homogeneousGradedProjection_coordinate_logHeight {p : ℝ} + (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hentries : ∀ i j, rationalLogHeight (c.repr (φ (b i)) j) ≤ p) + (x : F.AssociatedGraded) + (hx : ∀ i, rationalLogHeight ((F.associatedGradedBasis b ω hF).repr x i) ≤ p) (j : κ) : + rationalLogHeight (c.repr (F.homogeneousGradedProjection G c ν hG hc φ hφ x) j) ≤ + (p + 2) ^ 4 := by + apply rational_functional_value_logHeight (F.associatedGradedBasis b ω hF) + ((c.coord j).comp (F.homogeneousGradedProjection G c ν hG hc φ hφ).toLinearMap) + hp hι _ x hx + intro i + change rationalLogHeight (c.repr + (F.homogeneousGradedProjection G c ν hG hc φ hφ (F.associatedGradedBasis b ω hF i)) j) ≤ p + rw [F.homogeneousGradedProjection_basis_repr G c ν hG hc φ hφ b ω hF] + split_ifs + · exact hentries i j + · simpa [rationalLogHeight] using hp + +theorem homogeneousGradedProjection_coordinate_ceil_height {p : ℝ} + (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hentries : ∀ i j, rationalLogHeight (c.repr (φ (b i)) j) ≤ p) + (x : F.AssociatedGraded) + (hx : ∀ i, rationalLogHeight ((F.associatedGradedBasis b ω hF).repr x i) ≤ p) (j : κ) : + RationalHeightLE (c.repr (F.homogeneousGradedProjection G c ν hG hc φ hφ x) j) + ⌈Real.exp ((p + 2) ^ 4)⌉₊ := + rationalHeightLE_ceil_exp + (F.homogeneousGradedProjection_coordinate_logHeight G c ν hG hc φ hφ b ω hF + hp hι hentries x hx j) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/HomogeneousLieSpan.lean b/lean/OAI/Combinatorics/Progressions/Linear/HomogeneousLieSpan.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f3adfd598875a9e979e66fec06ef9dda3a188d8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/HomogeneousLieSpan.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.Progressions.Estimates.LieTreeMultidegree +import OAI.Combinatorics.Progressions.Polynomial.ExtendedPolynomialValues + +namespace OAI + +section + +namespace Erdos3 + +open VectorPolynomial + +variable {I σ L : Type*} [LieRing L] [LieAlgebra ℚ L] + +def homogeneousLieSpan (v : I → L) (g : I → σ →₀ ℕ) (S : Set (σ →₀ ℕ)) : Submodule ℚ L := + Submodule.span ℚ {x | ∃ a : FreeMagma I, lieTreeMultidegree g a ∈ S ∧ lieTreeEval v a = x} + +theorem homogeneousLieSpan_mono (v : I → L) (g : I → σ →₀ ℕ) + {S T : Set (σ →₀ ℕ)} (hST : S ⊆ T) : homogeneousLieSpan v g S ≤ homogeneousLieSpan v g T := by + apply Submodule.span_mono + rintro x ⟨a, ha, rfl⟩ + exact ⟨a, hST ha, rfl⟩ + +@[simp] theorem homogeneousLieSpan_empty (v : I → L) (g : I → σ →₀ ℕ) : + homogeneousLieSpan v g ∅ = ⊥ := by + simp [homogeneousLieSpan] + +structure LieGradingExpansion (v : I → L) (g : I → σ →₀ ℕ) where + expand : L →ₗ[ℚ] VectorPolynomial σ ℚ L + expand_tree : ∀ a, expand (lieTreeEval v a) = monomial (lieTreeMultidegree g a) (lieTreeEval v a) + eval_one : ∀ x, eval (fun _ : σ => (1 : ℚ)) (expand x) = x + +namespace LieGradingExpansion + +variable {v : I → L} {g : I → σ →₀ ℕ} (E : LieGradingExpansion v g) + +noncomputable def component (α : σ →₀ ℕ) : L →ₗ[ℚ] L := + (Finsupp.lapply α).comp (coefficients.toLinearMap.comp E.expand) + +@[simp] theorem component_apply (α : σ →₀ ℕ) (x : L) : + E.component α x = coefficients (E.expand x) α := rfl + +theorem component_tree [DecidableEq σ] (α : σ →₀ ℕ) (a : FreeMagma I) : + E.component α (lieTreeEval v a) = + if lieTreeMultidegree g a = α then lieTreeEval v a else 0 := by + classical + rw [component_apply, E.expand_tree, coefficients_monomial] + simp only [Finsupp.single_apply] + +theorem component_mem_span {S : Set (σ →₀ ℕ)} {x : L} (hx : x ∈ homogeneousLieSpan v g S) + (α : σ →₀ ℕ) : E.component α x ∈ homogeneousLieSpan v g (S ∩ {α}) := by + classical + induction hx using Submodule.span_induction with + | mem x hx => + obtain ⟨a, ha, rfl⟩ := hx + rw [E.component_tree] + split_ifs with h + · exact Submodule.subset_span ⟨a, ⟨ha, h⟩, rfl⟩ + · exact Submodule.zero_mem _ + | zero => rw [map_zero]; exact Submodule.zero_mem _ + | add x y _ _ hx hy => rw [map_add]; exact Submodule.add_mem _ hx hy + | smul c x _ hx => rw [map_smul]; exact Submodule.smul_mem _ c hx + +theorem component_eq_zero {S : Set (σ →₀ ℕ)} {x : L} (hx : x ∈ homogeneousLieSpan v g S) + {α : σ →₀ ℕ} (hα : α ∉ S) : E.component α x = 0 := by + have hc := E.component_mem_span hx α + have he : S ∩ {α} = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + rintro β ⟨hβ, rfl⟩ + exact hα hβ + rw [he, homogeneousLieSpan_empty, Submodule.mem_bot] at hc + exact hc + +include E in +theorem span_inter (S T : Set (σ →₀ ℕ)) : + homogeneousLieSpan v g (S ∩ T) = homogeneousLieSpan v g S ⊓ homogeneousLieSpan v g T := by + apply le_antisymm + · exact le_inf (homogeneousLieSpan_mono v g Set.inter_subset_left) + (homogeneousLieSpan_mono v g Set.inter_subset_right) + · intro x hx + have hc : ∀ α, coefficients (E.expand x) α ∈ homogeneousLieSpan v g (S ∩ T) := by + intro α + change E.component α x ∈ homogeneousLieSpan v g (S ∩ T) + by_cases hα : α ∈ T + · apply homogeneousLieSpan_mono v g _ (E.component_mem_span hx.1 α) + rintro β ⟨hβ, rfl⟩ + exact ⟨hβ, hα⟩ + · rw [E.component_eq_zero hx.2 hα] + exact Submodule.zero_mem _ + have h := (eval_mem_iff_coefficients (homogeneousLieSpan v g (S ∩ T)) (E.expand x)).mpr + hc (fun _ : σ => (1 : ℚ)) + rwa [E.eval_one] at h + +end LieGradingExpansion +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ImageDefiningMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/ImageDefiningMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..62b7fced686aa386f280939c61d17c4d70787780 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ImageDefiningMatrix.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.Progressions.Estimates.RealifiedReconstruction + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix TensorProduct + +theorem ker_id_sub_comp_eq_range {R V W : Type*} [Ring R] + [AddCommGroup V] [Module R V] [AddCommGroup W] [Module R W] + (φ : V →ₗ[R] W) (σ : W →ₗ[R] V) (hσ : (φ.comp σ).comp φ = φ) : + LinearMap.ker (LinearMap.id - φ.comp σ) = LinearMap.range φ := by + ext y + change y - φ (σ y) = 0 ↔ ∃ x, φ x = y + constructor + · intro h + exact ⟨σ y, (sub_eq_zero.mp h).symm⟩ + · rintro ⟨x, rfl⟩ + exact sub_eq_zero.mpr (DFunLike.congr_fun hσ x).symm + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +theorem baseChange_matrix_apply [DecidableEq ι] [DecidableEq κ] + (e : Basis ι ℚ L) (f : Basis κ ℚ M) (P : L →ₗ[ℚ] M) (x : ℝ ⊗[ℚ] L) : + (fun i j => (LinearMap.toMatrix e f P i j : ℝ)) *ᵥ (e.baseChange ℝ).equivFun x = + (f.baseChange ℝ).equivFun (P.baseChange ℝ x) := by + have heq : (fun i j => (LinearMap.toMatrix e f P i j : ℝ)) = + LinearMap.toMatrix (e.baseChange ℝ) (f.baseChange ℝ) (P.baseChange ℝ) := by + ext i j + rw [LinearMap.toMatrix_apply, LinearMap.toMatrix_apply, linearMap_baseChange_basis] + rw [heq] + simpa only [Basis.equivFun_apply] using + LinearMap.toMatrix_mulVec_repr (e.baseChange ℝ) (f.baseChange ℝ) (P.baseChange ℝ) x + +open NilpotentLieBCHGroup + +variable {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +theorem realificationMap_mem_range_iff (φ : L →ₗ⁅ℚ⁆ M) + (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] M) s (realification_lowerCentralSeries_eq_bot hM)) : + g ∈ (realificationMap (hnil := hL) (hM := hM) φ).range ↔ + g.coord ∈ LinearMap.range (φ.toLinearMap.baseChange ℝ) := by + constructor + · rintro ⟨x, hx⟩ + exact ⟨x.coord, congrArg NilpotentLieBCHGroup.coord hx⟩ + · rintro ⟨x, hx⟩ + exact ⟨⟨x⟩, ext hx⟩ + +theorem exists_realified_image_defining_matrix (e : Basis ι ℚ L) (f : Basis κ ℚ M) + (φ : L →ₗ⁅ℚ⁆ M) {H : ℕ} (hH : 1 ≤ H) + (hentries : ∀ i j, RationalHeightLE (f.repr (φ (e j)) i) H) : + ∃ Q : Matrix κ κ ℚ, + (∀ i j, RationalHeightLE (Q i j) + (2 * ((Fintype.card ι + 1) * (H * rationalKernelHeight (Fintype.card κ) H) ^ Fintype.card ι))) ∧ + ∀ g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] M) s (realification_lowerCentralSeries_eq_bot hM), + g ∈ (realificationMap (hnil := hL) (hM := hM) φ).range ↔ + (fun i j => (Q i j : ℝ)) *ᵥ (f.baseChange ℝ).equivFun g.coord = 0 := by + classical + obtain ⟨σ, hσ, hσH⟩ := exists_bounded_linear_image_section e f φ.toLinearMap hH hentries + let P : M →ₗ[ℚ] M := LinearMap.id - φ.toLinearMap.comp σ + let Q := LinearMap.toMatrix f f P + have hQ : Q = 1 - LinearMap.toMatrix e f φ.toLinearMap * LinearMap.toMatrix f e σ := by + dsimp [Q, P] + rw [map_sub, LinearMap.toMatrix_id, LinearMap.toMatrix_comp f e f] + refine ⟨Q, ?_, ?_⟩ + · intro i j + have hI : RationalHeightLE ((1 : Matrix κ κ ℚ) i j) 1 := by + by_cases hij : i = j + · simpa [Matrix.one_apply, hij] using rationalHeightLE_one (by decide : 1 ≤ 1) + · simpa [Matrix.one_apply, hij] using rationalHeightLE_zero (by decide : 1 ≤ 1) + have hprod := rationalHeightLE_matrix_mul (LinearMap.toMatrix e f φ.toLinearMap) + (LinearMap.toMatrix f e σ) + (fun i j => by rw [LinearMap.toMatrix_apply]; exact hentries i j) + (fun i j => by rw [LinearMap.toMatrix_apply]; exact hσH i j) i j + rw [hQ] + simpa only [Matrix.sub_apply, mul_one] using hI.sub hprod + · intro g + have hσR := linearMap_baseChange_image_section φ.toLinearMap σ hσ + have hker := ker_id_sub_comp_eq_range (φ.toLinearMap.baseChange ℝ) (σ.baseChange ℝ) hσR + have hPR : P.baseChange ℝ = LinearMap.id - (φ.toLinearMap.baseChange ℝ).comp (σ.baseChange ℝ) := by + simp only [P, LinearMap.baseChange_sub, LinearMap.baseChange_id, LinearMap.baseChange_comp] + rw [realificationMap_mem_range_iff, ← hker, ← hPR] + change P.baseChange ℝ g.coord = 0 ↔ _ + rw [show (fun i j => (Q i j : ℝ)) *ᵥ (f.baseChange ℝ).equivFun g.coord = + (f.baseChange ℝ).equivFun (P.baseChange ℝ g.coord) from baseChange_matrix_apply f f P g.coord] + constructor + · intro h + rw [h, map_zero] + · intro h + apply (f.baseChange ℝ).equivFun.injective + simpa only [map_zero] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/InducedUnitRankFamily.lean b/lean/OAI/Combinatorics/Progressions/Linear/InducedUnitRankFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fbe267aa9060ed4a0c554b1088d07cbef5ee492 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/InducedUnitRankFamily.lean @@ -0,0 +1,184 @@ +import OAI.Combinatorics.Progressions.Estimates.CoveredInducedCorrelationFamily +import OAI.Combinatorics.Progressions.Geometry.NativeCorrelationCoordinates + +namespace OAI + +section + +namespace Erdos3.NativeVectorCorrelation + +theorem exists_combined_factor_correlation {A I J K : Type*} + {degree N : ℕ} [NeZero N] {p : ℝ} + (f : A → ZMod N → ℂ) (g : K → ZMod N → ℂ) + (a : I → ZMod N → ℂ) (b : J → ZMod N → ℂ) + (c : I × J → ZMod N → ℂ) (j : J → K) + (hc : ∀ ij x, c ij x = a ij.1 x * b ij.2 x) + (W : NativeVectorCorrelation degree N p (fun z : A × (I × J) => fun x => + f z.1 x * star (g (j z.2.2) x) * star (a z.2.1 x) * star (b z.2.2 x))) : + Nonempty (NativeVectorCorrelation degree N p (fun z : (A × K) × (I × J) => fun x => + f z.1.1 x * star (g z.1.2 x) * star (c z.2 x))) := by + refine ⟨W.mapCoordinates _ (fun z => ((z.1, j z.2.2), z.2)) ?_⟩ + intro z x + rw [hc, star_mul] + ring + +end Erdos3.NativeVectorCorrelation + +namespace Erdos3.NativeRankRelation.CommonData + +open Module NilpotentLieBCHGroup RationalFilteredNilmanifold +open scoped TensorProduct BigOperators NNReal + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {τ K I : Type} [Fintype I] {s r N n degree : ℕ} [NeZero N] + {b p q P Z : ℝ} {W : NativeDegreeRankFamily s (r + 1) (ZMod N) b} + {out : Fin W.outputDim} {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} + (D : R.CommonData P) (t : ℕ) + (x : ∀ j : Fin s, (D.coefficientFreeSpan j).baseChange ℝ) + (y : ∀ j : Fin s, Fin t → (D.dependentFreeSpan j).baseChange ℝ) + (u c : Fin t → ℝ) (h₀ : ZMod N) (h : τ → ZMod N) + (f : τ → K → ZMod N → ℂ) + +def HasUnitRankInducedCorrelationFamily (B C : ℝ) : Prop := + ∃ k : ℕ, 0 < k ∧ (k : ℝ) ≤ Real.exp B ∧ + ∃ F : NativeUnitRankFamily (fun _ : Unit => 1) s r τ + ((I × I) × (I × Fin k)) C, + ∃ (m : ℕ) (_hm : 0 < m), (m : ℝ) ≤ Real.exp B ∧ + ∃ d : ℕ, ∃ E : RationalFilteredNilmanifold + (MarkedShiftQuotient D.coefficientFreeFiltration D.coefficientFreeGenerator + D.coefficientWeight D.coefficientIsDependent t) (s + 1) d, + ∃ M : E.MultidegreeStructure (mixedCorrelationDegree s), + M.filtration = D.markedQuotientMultidegree t ∧ M.ComplexityLE B ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] MarkedShiftQuotient D.coefficientFreeFiltration + D.coefficientFreeGenerator D.coefficientWeight D.coefficientIsDependent t) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] MarkedShiftQuotient D.coefficientFreeFiltration + D.coefficientFreeGenerator D.coefficientWeight D.coefficientIsDependent t) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 E.basis + letI := E.metricSpace + ∃ G : Fin k → E.Space → ℂ, + (∀ j z, ‖G j z‖ ≤ 2) ∧ + (∀ j, LipschitzWith ⟨Real.exp B, Real.exp_nonneg _⟩ (G j)) ∧ + ∀ z, Nonempty (NativeVectorCorrelation degree N B + (fun ij : (K × Fin k) × ((I × I) × (I × Fin k)) => fun a => + f z ij.1.1 a * star (G ij.1.2 (QuotientGroup.mk + ((D.markedQuotientMultidegree t).realification.polynomialOrbitEval + (correlationInput ((h z).val : ℤ) (a.val : ℤ)) + (D.localPhaseMarkedOrbit t x y u c h₀ m)))) * + star (F.eval z ij.2 (fun _ => (a.val : ℤ)))))) + +theorem HasCommonInducedCorrelationFamily.combineLower + (A : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s n) + {e k : ℕ} (Q : RationalFilteredNilmanifold D.DependentQuotient s e) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] D.DependentQuotient)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.DependentQuotient)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.DependentQuotient)] + [T2Space (ℝ ⊗[ℚ] D.DependentQuotient)] + {S : Subgroup A.RealGroup} {T : Subgroup Q.RealGroup} + (V : A.UnitVerticalObservable S I Z) (U : Q.UnitVerticalObservable T (Fin k) Z) + (hφ : A.lattice ≤ Q.lattice.comap (mapOfSteps + (hL := A.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) D.dependentQuotientMap)) + (a v : τ → A.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + {B C : ℝ} (hk : 0 < k) (hkB : (k : ℝ) ≤ Real.exp B) + (F : NativeUnitRankFamily (fun _ : Unit => 1) s r τ ((I × I) × (I × Fin k)) C) + (hF : ∀ z ij w, F.eval z ij w = + (V.observable ij.1.1 (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) w (v z))) * + star (V.observable ij.1.2 (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) w (a z))))) * + mapDifferenceObservable V U D.dependentQuotientMap hφ ij.2 (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) w (a z)))) + (hcommon : D.HasCommonInducedCorrelationFamily (degree := degree) + t A Q V U hφ x y u c h₀ h a v f B) : + D.HasUnitRankInducedCorrelationFamily (I := I) (degree := degree) t x y u c h₀ h f B C := by + obtain ⟨m, hm, hmB, d₁, _, E₁, M, hMF, hM, hdata⟩ := hcommon + refine ⟨k, hk, hkB, F, m, hm, hmB, d₁, E₁, M, hMF, hM, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] MarkedShiftQuotient D.coefficientFreeFiltration + D.coefficientFreeGenerator D.coefficientWeight D.coefficientIsDependent t) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] MarkedShiftQuotient D.coefficientFreeFiltration + D.coefficientFreeGenerator D.coefficientWeight D.coefficientIsDependent t) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 E₁.basis + let := E₁.metricSpace + obtain ⟨G, hGn, hGL, hcorr⟩ := hdata + refine ⟨G, hGn, hGL, ?_⟩ + intro z + exact NativeVectorCorrelation.exists_combined_factor_correlation (f z) + (fun j w => G j (QuotientGroup.mk + ((D.markedQuotientMultidegree t).realification.polynomialOrbitEval + (correlationInput ((h z).val : ℤ) (w.val : ℤ)) + (D.localPhaseMarkedOrbit t x y u c h₀ m)))) + (fun (ij : I × I) w => V.observable ij.1 (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (fun _ => (w.val : ℤ)) (v z))) * + star (V.observable ij.2 (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (fun _ => (w.val : ℤ)) (a z))))) + (fun (ij : I × Fin k) w => mapDifferenceObservable V U D.dependentQuotientMap hφ ij + (QuotientGroup.mk (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (fun _ => (w.val : ℤ)) (a z)))) + (fun ij w => F.eval z ij (fun _ => (w.val : ℤ))) Prod.snd + (fun ij w => hF z ij (fun _ => (w.val : ℤ))) (Classical.choice (hcorr z)) + +variable (A : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s n) + (T : A.DegreeRankStructure (r + 1)) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : A.UnitVerticalObservable (T.realSubgroup s (r + 1)) I Z) + (a v : τ → A.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + +theorem HasCoveredInducedCorrelationFamily.combineLower + {B C : ℝ} (hB : 0 ≤ B) (hC : 0 ≤ C) + (hcovered : D.HasCoveredInducedCorrelationFamily (degree := degree) + t A T V x y u c h₀ h a v f B) + {L : Type} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + (E : RationalFilteredNilmanifold L s d) (U : E.DegreeRankStructure (r + 1)) + (hfirst : E.HasLowerRankOrbitFamily U (fun _ : Unit => 1) + (fun z (ij : I × I) w => V.observable ij.1 (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) w (v z))) * + star (V.observable ij.2 (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) w (a z))))) C) : + D.HasUnitRankInducedCorrelationFamily (I := I) (degree := degree) + t x y u c h₀ h f B (productNiltestBudget (C + B + 2)) := by + obtain ⟨Λ, _, l, hl, hin, hout, _, e, _, Q, S, _, _, hφ, V₀, _, hVobs, hcoeff⟩ := hcovered + let A₀ := A.withLattice Λ l hl hin hout + let T₀ := T.withLattice Λ l hl hin hout + let := moduleTopology ℝ (ℝ ⊗[ℚ] D.DependentQuotient) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] D.DependentQuotient) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + obtain ⟨k, hk, hkB, U₀, hcommon, hsecond⟩ := hcoeff + obtain ⟨F, _, hF⟩ := exists_binary_lower_rank_unit_family (p := C + B + 2) E A₀ U T₀ + (fun _ : Unit => 1) _ _ (by linarith : 2 ≤ C + B + 2) + (hfirst.mono (show C ≤ C + B + 2 by linarith)) + (hsecond.mono (show B ≤ C + B + 2 by linarith)) + apply HasCommonInducedCorrelationFamily.combineLower D t x y u c h₀ h f + A₀ Q V₀ U₀ hφ a v hk hkB F ?_ hcommon + intro z ij w + rw [hF] + have hvalue (i : I) (o : A.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) : + V₀.observable i (QuotientGroup.mk + (A₀.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) w o)) = + V.observable i (QuotientGroup.mk + (A.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) w o)) := hVobs i _ + simp only [hvalue] + rfl + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/IntegralCoefficientBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/IntegralCoefficientBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..46374e39130d248d675bcebfb25d4aa887e1046f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/IntegralCoefficientBasis.lean @@ -0,0 +1,37 @@ +import OAI.Combinatorics.Progressions.Fourier.EuclideanJetTorus + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module MeasureTheory + +theorem exists_integral_subspace_basis {J : Type*} [Fintype J] + (U : Submodule ℝ (J → ℝ)) + (hspan : Submodule.span ℝ {x : U | ∀ a, ∃ n : ℤ, x.val a = n} = ⊤) : + ∃ b : Basis (Fin (finrank ℝ U)) ℝ U, + ∀ i a, ∃ n : ℤ, (b i).val a = n := by + classical + have hex := Submodule.exists_fun_fin_finrank_span_eq ℝ {x : U | ∀ a, ∃ n : ℤ, x.val a = n} + rw [hspan, finrank_top] at hex + obtain ⟨v, hv, hs, hi⟩ := hex + refine ⟨Basis.mk hi (by rw [hs]), ?_⟩ + intro i a + simpa only [Basis.mk_apply] using hv i a + +theorem exists_coefficient_torus_haar {K : Type*} [Fintype K] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] + (U : ∀ j, Submodule ℝ (J j → ℝ)) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (hspan : ∀ j, Submodule.span ℝ {x : U j | ∀ a, ∃ n : ℤ, x.val a = n} = ⊤) : + ∃ μ : Measure (CoefficientTorus (K := K) U), IsProbabilityMeasure μ ∧ μ.IsAddLeftInvariant := by + choose b hb using fun j => exists_integral_subspace_basis (U j) (hspan j) + exact ⟨coefficientTorusHaar U b hb, inferInstance, inferInstance⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/JoinedPairProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/JoinedPairProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4eccc417bdb1a9a17ae49707b00dbacbdb6bd535 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/JoinedPairProjection.lean @@ -0,0 +1,51 @@ +import Mathlib.Algebra.Lie.Prod +import OAI.Combinatorics.Progressions.Estimates.TranslationMajorTwistedCorrelationStepDrop + +namespace OAI + +universe u + +section + +namespace Erdos3.RationalFilteredNilmanifold + +variable {L M W : Type u} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] [LieRing W] [LieAlgebra ℚ W] + +def joinedPairProjection (ρ : W →ₗ⁅ℚ⁆ M) : (L × W) →ₗ⁅ℚ⁆ PairAlgebra L M := + liePiMap (fun i => by + cases i + · exact ρ.comp (LieHom.snd ℚ L W) + · exact LieHom.fst ℚ L W) + +@[simp] theorem joinedPairProjection_true (ρ : W →ₗ⁅ℚ⁆ M) (x : L × W) : + joinedPairProjection ρ x true = x.1 := rfl + +@[simp] theorem joinedPairProjection_false (ρ : W →ₗ⁅ℚ⁆ M) (x : L × W) : + joinedPairProjection ρ x false = ρ x.2 := rfl + +@[simp] theorem pairFrequency_joinedPairProjection (ρ : W →ₗ⁅ℚ⁆ M) + (η : L →ₗ[ℚ] ℚ) (θ : M →ₗ[ℚ] ℚ) (x : L × W) : + pairFrequency η θ (joinedPairProjection ρ x) = η x.1 + θ (ρ x.2) := by + rw [pairFrequency_apply, joinedPairProjection_true, joinedPairProjection_false] + +theorem joinedPairProjection_mem_layer {s d e : ℕ} + (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M s e) + (H : NilpotentLieFiltration (L × W) s) (ρ : W →ₗ⁅ℚ⁆ M) + (hfirst : ∀ j, ∀ x ∈ H.layer j, x.1 ∈ D.filtration.layer j) + (hpartner : ∀ j, ∀ x ∈ H.layer j, ρ x.2 ∈ E.filtration.layer j) + (j : ℕ) (x : L × W) (hx : x ∈ H.layer j) : + joinedPairProjection ρ x ∈ (pi (pairModels D E)).filtration.layer j := by + change joinedPairProjection ρ x ∈ + (NilpotentLieFiltration.pi (fun i => (pairModels D E i).filtration)).layer j + rw [NilpotentLieFiltration.mem_pi_layer] + intro i + cases i + · exact hpartner j x hx + · exact hfirst j x hx + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/JointFrameCoefficientCoverSample.lean b/lean/OAI/Combinatorics/Progressions/Linear/JointFrameCoefficientCoverSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..38e740b3b02d5735aad6b98fab1e16612c0793b2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/JointFrameCoefficientCoverSample.lean @@ -0,0 +1,117 @@ +import OAI.Combinatorics.Progressions.Estimates.SelectedJointLifts + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel +open scoped BigOperators + +theorem substitute_translate_joint_frame {K X V : Type*} [Fintype K] + [AddCommGroup V] [Module ℝ V] (p : VectorPolynomial X ℝ V) + (a : X → ℤ) (z : Option K × X → ℤ) : + substitute (affineParameterSubstitution (fun k v => (z (k,v) : ℝ))) + (translate (fun v => (a v : ℝ)) p) = + substitute (affineParameterSubstitution + (fun k v => (jointIntegerFrame (a,z) k v : ℝ))) p := by + change substitute _ (substitute (fun v => MvPolynomial.X v + MvPolynomial.C (a v : ℝ)) p) = _ + rw [substitute_comp] + apply congrArg (fun f : X → MvPolynomial K ℝ => substitute f p) + funext v + simp only [map_add, MvPolynomial.aeval_X, MvPolynomial.aeval_C, + affineParameterSubstitution, rowPolynomial, jointIntegerFrame, Int.cast_add, map_add, + MvPolynomial.algebraMap_eq] + ring + +theorem affineSampleCoefficientArray_joint_frame {K X : Type*} [Fintype K] + {m : ℕ} {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (a : X → ℤ) (z : Option K × X → ℤ) : + affineSampleCoefficientArray U (fun j => translate (fun v => (a v : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun v => (a v : ℝ)) (p j) (hm j)) + (fun k v => (z (k,v) : ℝ)) = + affineSampleCoefficientArray U p hm (fun k v => (jointIntegerFrame (a,z) k v : ℝ)) := by + funext s + apply Subtype.ext + simp only [affineSampleCoefficientArray_val, substitute_translate_joint_frame] + +theorem affineSampleCoefficientTorus_joint_frame {K X : Type*} [Fintype K] + {m : ℕ} {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (a : X → ℤ) (z : Option K × X → ℤ) : + affineSampleCoefficientTorus U (fun j => translate (fun v => (a v : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun v => (a v : ℝ)) (p j) (hm j)) + (fun k v => (z (k,v) : ℝ)) = + affineSampleCoefficientTorus U p hm (fun k v => (jointIntegerFrame (a,z) k v : ℝ)) := + congrArg (QuotientAddGroup.mk' (coefficientIntegerLattice U)) + (affineSampleCoefficientArray_joint_frame U p hm a z) + +variable {m : ℕ} {G X : Type*} [Fintype G] +variable {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Module.Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, Submodule.span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable (R σ : Fin m → ℝ) (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (L₀ : ℕ) + +theorem jointSelectedPhysicalDensity_function + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U) : + jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ p hm center = + fun (a : X → ℤ) => translatedSelectedPhysicalDensity (X := X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) + (fun j => translate (fun t => (a t : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun t => (a t : ℝ)) (p j) (hm j)) := rfl + +theorem jointSelectedPhysicalDensity_eq_allocated + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (center : CoefficientTorus (K := LayerSamplerVariables G I n B) U) + (c : ∀ j, U j) + (hc : coefficientConstantCenter U center = + -(QuotientAddGroup.mk' (coefficientIntegerLattice U) + (constantCoefficientArray U (fun s => c s.1)))) + (a : X → ℤ) (z : Option (LayerSamplerVariables G I n B) × X → ℤ) : + jointSelectedPhysicalDensity B U b hb o R σ hR hσ L₀ p hm center a z = + allocatedAffineDensity B U b hb o hR hσ + (selectedLayerSamplerScale B U b R σ hR hσ L₀) p hm c + (fun k v => (jointIntegerFrame (a,z) k v : ℝ)) := by + unfold jointSelectedPhysicalDensity translatedSelectedPhysicalDensity allocatedAffineDensity + rw [centeredAffineCoefficientTorus_eq_subtractive, ← hc, + affineSampleCoefficientTorus_joint_frame] + rfl + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open BooleanCubeKernel + +theorem affineCoefficientCoverSample_joint_frame {K X : Type*} [Fintype K] + {m : ℕ} {J : Fin m → Type*} (U : ∀ j, Submodule ℝ (J j → ℝ)) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (a : X → ℤ) (z : Option K × X → ℤ) (q : ℕ) : + affineCoefficientCoverSample U (fun j => translate (fun v => (a v : ℝ)) (p j)) + (fun j => coefficients_translate_mem (U j) (fun v => (a v : ℝ)) (p j) (hm j)) + q (fun k v => (z (k,v) : ℝ)) = + affineCoefficientCoverSample U p hm q + (fun k v => (jointIntegerFrame (a,z) k v : ℝ)) := by + unfold affineCoefficientCoverSample + rw [affineSampleCoefficientArray_joint_frame] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/JointKernelCutoffBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/JointKernelCutoffBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a118e6ed0ac4cca706839372a22a56b96d78e98e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/JointKernelCutoffBudget.lean @@ -0,0 +1,70 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic + +namespace OAI + + +namespace Erdos3 + +noncomputable def jointKernelCutoff (n b : ℕ) (K T ε κ : ℝ) : ℕ := + ⌈1 + (n : ℝ) + b + (1 + K) / κ + 2 * T / ε⌉₊ + +theorem jointKernelCutoff_bounds (n b : ℕ) {K T ε κ : ℝ} + (hK : 0 ≤ K) (hT : 0 ≤ T) (hε : 0 < ε) (hκ : 0 < κ) : + 0 < jointKernelCutoff n b K T ε κ ∧ + n ≤ jointKernelCutoff n b K T ε κ ∧ + b ≤ jointKernelCutoff n b K T ε κ ∧ + 1 / κ ≤ (jointKernelCutoff n b K T ε κ : ℝ) ∧ + K / κ ≤ (jointKernelCutoff n b K T ε κ : ℝ) ∧ + 2 * T / ε ≤ (jointKernelCutoff n b K T ε κ : ℝ) := by + have h1 : 0 < 1 / κ := one_div_pos.mpr hκ + have h2 : 0 ≤ K / κ := div_nonneg hK hκ.le + have h3 : 0 ≤ 2 * T / ε := div_nonneg (by positivity) hε.le + have hc := Nat.le_ceil (1 + (n : ℝ) + b + (1 + K) / κ + 2 * T / ε) + change 1 + (n : ℝ) + b + (1 + K) / κ + 2 * T / ε ≤ + (jointKernelCutoff n b K T ε κ : ℝ) at hc + rw [add_div] at hc + have hn : (n : ℝ) ≤ jointKernelCutoff n b K T ε κ := by linarith + have hb : (b : ℝ) ≤ jointKernelCutoff n b K T ε κ := by linarith + have hp : (0 : ℝ) < jointKernelCutoff n b K T ε κ := by + have := Nat.cast_nonneg n (α := ℝ) + have := Nat.cast_nonneg b (α := ℝ) + linarith + exact ⟨by exact_mod_cast hp, by exact_mod_cast hn, by exact_mod_cast hb, + by linarith, by linarith, by linarith⟩ + +theorem jointKernelCutoff_le (n b : ℕ) {K T ε κ : ℝ} + (hK : 0 ≤ K) (hT : 0 ≤ T) (hε : 0 < ε) (hκ : 0 < κ) : + (jointKernelCutoff n b K T ε κ : ℝ) ≤ + 2 + (n : ℝ) + b + (1 + K) / κ + 2 * T / ε := by + unfold jointKernelCutoff + have h := Nat.ceil_lt_add_one + (show 0 ≤ 1 + (n : ℝ) + b + (1 + K) / κ + 2 * T / ε by positivity) + linarith + + +theorem jointKernelCutoff_le_exp (n b : ℕ) {K T ε κ P : ℝ} + (hK : 0 ≤ K) (hT : 0 ≤ T) (hε : 0 < ε) (hκ : 0 < κ) (hP : 0 ≤ P) + (hnP : (n : ℝ) ≤ Real.exp P) (hbP : (b : ℝ) ≤ Real.exp P) + (hKP : K ≤ Real.exp P) (hTP : T ≤ Real.exp P) + (hεP : ε⁻¹ ≤ Real.exp P) (hκP : κ⁻¹ ≤ Real.exp P) : + (jointKernelCutoff n b K T ε κ : ℝ) ≤ Real.exp (2 * P + 8) := by + have hE : 1 ≤ Real.exp P := Real.one_le_exp_iff.mpr hP + have h8 : (8 : ℝ) ≤ Real.exp 8 := by linarith [Real.add_one_le_exp (8 : ℝ)] + calc + _ ≤ 2 + (n : ℝ) + b + (1 + K) / κ + 2 * T / ε := jointKernelCutoff_le n b hK hT hε hκ + _ ≤ 2 + Real.exp P + Real.exp P + (1 + Real.exp P) * Real.exp P + + 2 * Real.exp P * Real.exp P := by + simp only [div_eq_mul_inv] + gcongr + _ ≤ 8 * (Real.exp P) ^ 2 := by nlinarith [sq_nonneg (Real.exp P - 1)] + _ ≤ Real.exp 8 * (Real.exp P) ^ 2 := mul_le_mul_of_nonneg_right h8 (sq_nonneg _) + _ = Real.exp (2 * P + 8) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + norm_num + ring + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/JointRationalSpaceDefiningMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/JointRationalSpaceDefiningMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..315e5199ad74ce5388342d2cf685ce82f3c7ea9f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/JointRationalSpaceDefiningMatrix.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Estimates.JointRationalSpaceGenerators + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +namespace VectorPolynomial + +theorem exists_jointRationalSpace_defining_matrix {J C V : Type*} + [Fintype J] [Fintype C] [Fintype V] + (B : Matrix J C ℚ) (A : Matrix V J ℚ) {H R : ℕ} + (hH : 1 ≤ H) + (hB : ∀ i j, RationalHeightLE (B i j) H) + (hA : ∀ v j, RationalHeightLE (A v j) R) : + ∃ Q : Matrix (J ⊕ V) J ℚ, + (∀ v j, RationalHeightLE (Q v j) + (max (imageDefiningHeight (Fintype.card C) (Fintype.card J) H) R)) ∧ + LinearMap.ker (Matrix.of (fun v j => (Q v j : ℝ))).mulVecLin = + jointRationalSpace B A := by + obtain ⟨Q, hQ, hQker⟩ := exists_real_span_defining_matrix B hH hB + let A' : Matrix (J ⊕ V) J ℚ := + Matrix.of (fun v j => Sum.elim (fun i => Q i j) (fun v => A v j) v) + refine ⟨A', ?_, ?_⟩ + · intro v j + cases v with + | inl i => exact (hQ i j).mono (le_max_left _ _) + | inr v => exact (hA v j).mono (le_max_right _ _) + · ext x + change LinearMap.ker (Matrix.of (fun i j => (Q i j : ℝ))).mulVecLin = + LinearMap.range (Matrix.of (fun i j => (B i j : ℝ))).mulVecLin at hQker + change (Matrix.of (fun v j => (A' v j : ℝ)) *ᵥ x = 0) ↔ + x ∈ LinearMap.range (Matrix.of (fun i j => (B i j : ℝ))).mulVecLin ∧ + Matrix.of (fun v j => (A v j : ℝ)) *ᵥ x = 0 + rw [← hQker] + change (Matrix.of (fun v j => (A' v j : ℝ)) *ᵥ x = 0) ↔ + (Matrix.of (fun i j => (Q i j : ℝ)) *ᵥ x = 0) ∧ + Matrix.of (fun v j => (A v j : ℝ)) *ᵥ x = 0 + constructor + · intro hx + exact ⟨funext (fun i => congrFun hx (.inl i)), + funext (fun v => congrFun hx (.inr v))⟩ + · rintro ⟨hQx, hAx⟩ + ext v + cases v with + | inl i => exact congrFun hQx i + | inr v => exact congrFun hAx v + +end VectorPolynomial + +theorem jointSpaceDefiningHeight_le_exp (ambient columns H R : ℕ) {p : ℝ} + (hp : 0 ≤ p) (ha : (ambient : ℝ) ≤ p) (hc : (columns : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hR : (R : ℝ) ≤ Real.exp p) : + ((max (imageDefiningHeight columns ambient H) R : ℕ) : ℝ) ≤ + Real.exp ((p+2)^10) := by + rw [Nat.cast_max] + exact max_le (imageDefiningHeight_le_exp columns ambient H hp hc ha hH) + (hR.trans (Real.exp_le_exp.mpr (le_power_budget hp (by decide : 1 ≤ 10)))) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelBudgetEnvelope.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelBudgetEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..3892ad3d2b1ef9cdd7942a834c2c7384e3bd4714 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelBudgetEnvelope.lean @@ -0,0 +1,59 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +theorem scalarKernel_polynomial_envelope {q j N R Q : ℝ} + (hq : 0 ≤ q) (_hj : 0 ≤ j) (_hN : 0 ≤ N) (hR : 0 ≤ R) + (hQ : 10 ≤ Q) (hqQ : q + 1 ≤ Q) (hjQ : j ≤ Q) (hNQ : N ≤ Q) (hRQ : R ≤ Q) : + 1 ≤ 16 * Q^3 ∧ q + 1 ≤ 16 * Q^3 ∧ 2 * R + (q + 1) ≤ 16 * Q^3 ∧ + N + q^2 + q ≤ 16 * Q^3 ∧ + j * ((q + 1) * (4 + (q + 1)) + q^2 + 1) ≤ 16 * Q^3 ∧ + j * (q + 1) * (4 + (q + 1) + 2 * R) + R ≤ 16 * Q^3 ∧ + j * ((q + 1) * (4 + (q + 1))) + 3 * N + (q + 1) + q * (8 + (q + 1)) ≤ 16 * Q^3 ∧ + N * (q + 1) ≤ 16 * Q^3 := by + have hQ0 : 0 ≤ Q := by linarith + have hqQ' : q ≤ Q := by linarith + have h4 : (4 : ℝ) ≤ Q := by linarith + have h8 : (8 : ℝ) ≤ Q := by linarith + have hQ2 : Q ≤ Q^2 := by nlinarith + have hQ3 : Q^2 ≤ Q^3 := by nlinarith + have ha : (q + 1) * (4 + (q + 1)) ≤ 2 * Q^2 := by + calc + _ ≤ Q * (Q + Q) := by gcongr + _ = _ := by ring + have hu : (q + 1) + q * (8 + (q + 1)) ≤ Q + 2 * Q^2 := by + calc + _ ≤ Q + Q * (Q + Q) := by gcongr + _ = _ := by ring + have hv : N + q^2 + q ≤ 2 * Q + Q^2 := by + calc + _ ≤ Q + Q^2 + Q := by gcongr + _ = _ := by ring + have ht : j * ((q + 1) * (4 + (q + 1)) + q^2 + 1) ≤ 4 * Q^3 := by + calc + _ ≤ Q * (2 * Q^2 + Q^2 + 1) := by gcongr + _ ≤ _ := by nlinarith + have he : j * (q + 1) * (4 + (q + 1) + 2 * R) + R ≤ 4 * Q^3 + Q := by + calc + _ ≤ Q * Q * (Q + Q + 2 * Q) + Q := by gcongr + _ = _ := by ring + have hc : j * ((q + 1) * (4 + (q + 1))) + 3 * N + (q + 1) + q * (8 + (q + 1)) ≤ + 2 * Q^3 + 4 * Q + 2 * Q^2 := by + calc + _ = j * ((q + 1) * (4 + (q + 1))) + 3 * N + ((q + 1) + q * (8 + (q + 1))) := by ring + _ ≤ Q * (2 * Q^2) + 3 * Q + (Q + 2 * Q^2) := by gcongr + _ = _ := by ring + have hs : N * (q + 1) ≤ Q^2 := by nlinarith [mul_le_mul hNQ hqQ (by linarith : 0 ≤ q + 1) hQ0] + exact ⟨by nlinarith, by nlinarith, by nlinarith, by nlinarith, by nlinarith, + by nlinarith, by nlinarith, by nlinarith⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelCoefficientDensity.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelCoefficientDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1ddd0265f53ebcb9b1ebbf3dec99ab02c51aad5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelCoefficientDensity.lean @@ -0,0 +1,62 @@ +import OAI.Combinatorics.Progressions.Lattices.JointAffineL1Parameter + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def kernelCoefficientDensity {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) + (S : J → ℝ) (P : I → ℝ) (hS : ∀ j, 0 < S j) (hP : ∀ i, 0 < P i) + (C : Matrix I N ℤ) (T : N → ℝ) (c w : J ⊕ N → ℝ) : (I → ℝ) → ℝ := + pivotOutputDensity + (normalizedPivotEquiv (A.submatrix id s) hA (fun i => S (s i)) P (fun i => hS (s i)) hP) + (splitFreeColumns + (matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns A s) (fun j => S j.val) P)) + (matrixSupCLM (normalizedIntegerColumns C T P))) + (splitFreeProfile + (selectedCoefficientProfile s (affineProductProfile (fun j => c (.inl j)) (fun j => w (.inl j)))) + (affineProductProfile (fun n => c (.inr n)) (fun n => w (.inr n)))) + +theorem selectedCoefficientDensity_eq_kernel {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) + (S : J → ℝ) (P : I → ℝ) (hS : ∀ j, 0 < S j) (hP : ∀ i, 0 < P i) + (C : Matrix I N ℤ) (T : N → ℝ) (hT : ∀ n, 0 < T n) + (hfull : ((Matrix.fromCols A C).submatrix id (s.trans Function.Embedding.inl)).det ≠ 0) + (c w : J ⊕ N → ℝ) {δ : ℝ≥0} (hδ : 0 < δ) (hw : ∀ j, (δ : ℝ) ≤ w j) + (R : ℝ≥0) (hsupport : ∀ j, |c j|+w j ≤ R) : + selectedCoefficientDensity (Matrix.fromCols A C) (s.trans Function.Embedding.inl) hfull + (Sum.elim S T) P (Sum.rec hS hT) hP (affineProductProfile c w) = + kernelCoefficientDensity A s hA S P hS hP C T c w := + affineCoefficientDensity_split A C s hA hfull S T P hS hT hP c w hδ hw R hsupport + +theorem kernelCoefficientDensity_eq_jet {Z X K α I J N : Type*} + [Fintype α] [DecidableEq α] [Fintype I] [DecidableEq I] + [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + (A : Matrix I J ℤ) (s : I ↪ J) (hA : (A.submatrix id s).det ≠ 0) + (S : J → ℝ) (hS : ∀ j, 0 < S j) {H : ℝ} (hH : 0 < H) + (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : I → Finset α) (x : X → ℝ) (vertices : Finset α → K → ℤ) (T : K → ℝ) + (hcoords : ∀ t k, (vertices t k : ℝ)/T k = normalizedCubeTuple input z x t k) + (c w : J ⊕ N → ℝ) : + kernelCoefficientDensity A s hA S (fun _ => H) hS (fun _ => hH) + (integerJetMatrix (fun n => MvPolynomial.monomial (e n) 1) vertices rows) + (fun n => H/monomialScale T (e n)) c w = + affineSelectedJetDensity s + (normalizedPivotEquiv (A.submatrix id s) hA (fun i => S (s i)) (fun _ => H) + (fun i => hS (s i)) (fun _ => hH)) + (matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns A s) (fun j => S j.val) (fun _ => H))) + e input z rows c w x := by + unfold kernelCoefficientDensity affineSelectedJetDensity normalizedJetDensity + rw [normalizedIntegerJetColumns_eq e input z rows x vertices T hcoords hH.ne'] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelCoefficientLogBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelCoefficientLogBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..538c355230f769438e29e5651a53c5f35af045e7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelCoefficientLogBudget.lean @@ -0,0 +1,651 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedEnormousProfiles + +namespace OAI + +section + +namespace Erdos3 + +theorem kernelJetInterpolationAllowance_le_exp (q h : ℕ) {κ b : ℝ} + (hκ : 0 < κ) (hb : 0 ≤ b) (hi : κ⁻¹ ≤ Real.exp b) : + kernelJetInterpolationAllowance q h κ ≤ + Real.exp ((h : ℝ) * ((q : ℝ)^2 + q + b + 2)) := by + have hq : (q : ℝ) ≤ Real.exp q := by linarith [Real.add_one_le_exp (q : ℝ)] + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hterm : (q : ℝ) * (2 * (q.factorial / κ)) ≤ + Real.exp ((q : ℝ)^2 + q + b + 1) := by + rw [div_eq_mul_inv] + calc + _ ≤ Real.exp q * (Real.exp 1 * (Real.exp ((q : ℝ)^2) * Real.exp b)) := by + gcongr + exact factorial_le_exp_sq q + _ = _ := by + rw [← Real.exp_add, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + have he : 1 ≤ Real.exp ((q : ℝ)^2 + q + b + 1) := + Real.one_le_exp_iff.mpr (by positivity) + have hbase : 1 + (q : ℝ) * (2 * (q.factorial / κ)) ≤ + Real.exp ((q : ℝ)^2 + q + b + 2) := by + calc + _ ≤ 2 * Real.exp ((q : ℝ)^2 + q + b + 1) := by linarith + _ ≤ Real.exp 1 * Real.exp ((q : ℝ)^2 + q + b + 1) := + mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + unfold kernelJetInterpolationAllowance + calc + _ ≤ (Real.exp ((q : ℝ)^2 + q + b + 2)) ^ h := by gcongr + _ = _ := (Real.exp_nat_mul _ _).symm + +theorem kernelJetEntryAllowance_le_exp (q h : ℕ) : + kernelJetEntryAllowance q h ≤ Real.exp ((q : ℝ) * (h + 1)) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hq := Real.add_one_le_exp (q : ℝ) + unfold kernelJetEntryAllowance + calc + _ ≤ (Real.exp 1) ^ q * (Real.exp q) ^ h := by gcongr + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + +theorem kernelJetMinorThreshold_inv_le_exp (q n j h : ℕ) {κ b : ℝ} + (hκ : 0 < κ) (hb : 0 ≤ b) (hi : κ⁻¹ ≤ Real.exp b) : + (kernelJetMinorThreshold q n j h κ)⁻¹ ≤ + Real.exp ((j : ℝ) * (h * n + h * ((q : ℝ)^2 + q + b + 2))) := by + have hn := Real.add_one_le_exp (n : ℝ) + have hQ := kernelJetInterpolationAllowance_le_exp q h hκ hb hi + have hQpos := (kernelJetInterpolationAllowance_pos q h hκ).le + simp only [kernelJetMinorThreshold, one_div, inv_inv] + calc + _ ≤ ((Real.exp n) ^ h * + Real.exp ((h : ℝ) * ((q : ℝ)^2 + q + b + 2))) ^ j := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_nat_mul] + +theorem kernelJetInverseAllowance_le_exp (q n j h : ℕ) {κ b : ℝ} + (hκ : 0 < κ) (hb : 0 ≤ b) (hi : κ⁻¹ ≤ Real.exp b) : + kernelJetInverseAllowance q n j h κ ≤ + Real.exp ((j : ℝ) + (j : ℝ)^2 + + (j - 1 : ℕ) * ((q : ℝ) * (h + 1)) + + j * (h * n + h * ((q : ℝ)^2 + q + b + 2))) := by + have hj : (j : ℝ) ≤ Real.exp j := by linarith [Real.add_one_le_exp (j : ℝ)] + have hE := kernelJetEntryAllowance_le_exp q h + have hEin := (kernelJetEntryAllowance_pos q h).le + have hminor := kernelJetMinorThreshold_inv_le_exp q n j h hκ hb hi + have hminorpos := (kernelJetMinorThreshold_pos q n j h hκ).le + unfold kernelJetInverseAllowance + rw [div_eq_mul_inv] + calc + _ ≤ Real.exp j * ((Real.exp ((j : ℝ)^2) * + (Real.exp ((q : ℝ) * (h + 1))) ^ (j - 1)) * + Real.exp ((j : ℝ) * (h * n + h * ((q : ℝ)^2 + q + b + 2)))) := by + gcongr + exact factorial_le_exp_sq j + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem goodKernel_common_period {Q α J : Type*} + [Fintype α] [DecidableEq α] [Fintype J] + {O : Q → Type*} [∀ q, Fintype (O q)] + {L B : ℕ} {κ : ℝ} (selection : α ↪ J) + (x : J → IntegerScalarCubeBox α L) (hx : GoodScalarKernelTuple selection κ B x) + (smax : ℕ) (hsmax : 1 ≤ smax) (degree : Q → ℕ) (hdegree : ∀ q, degree q ≤ smax) + (rows : ∀ q, O q → Finset α) (hinj : ∀ q, Function.Injective (rows q)) + (hrows : ∀ q i, (rows q i).card ≤ degree q) : + ∃ m : ℕ, 0 < m ∧ m ≤ B^smax ∧ + (∀ root : J → ℤ, integerScalarLattice (Unit ⊕ α) (m : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ q, integerScalarLattice (O q) (m : ℤ) ≤ + (scalarKernelIntegerJet x (degree q) (rows q)).mulVecLin.range) := by + obtain ⟨a, ha, haB, hp⟩ := hx.2 + refine ⟨a^smax, pow_pos ha _, Nat.pow_le_pow_left haB _, ?_, ?_⟩ + · intro root + rw [selectedSpatial_full_image, Nat.cast_pow] + apply (integerScalarLattice_pow_le (a : ℤ) hsmax).trans + simpa only [pow_one] using rootDifferenceMatrix_period root (scalarCubeDifferenceMatrix x) (a : ℤ) hp + · intro q + rw [Nat.cast_pow] + exact boundedDegreeIntegerJetMatrix_common_period _ _ (a : ℤ) hp smax (degree q) + (hdegree q) (rows q) (hinj q) (hrows q) + +theorem goodKernel_mapped_pivots {Q α J K Z X : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + {O N : Q → Type*} [∀ q, Fintype (O q)] [∀ q, DecidableEq (O q)] + [∀ q, Fintype (N q)] [∀ q, DecidableEq (N q)] + {L B : ℕ} {κ : ℝ} (hL : 0 < L) (selection : α ↪ J) (hκ : 0 < κ) + (x : J → IntegerScalarCubeBox α L) (hx : GoodScalarKernelTuple selection κ B x) + (degree : Q → ℕ) (rows : ∀ q, O q → Finset α) + (hinj : ∀ q, Function.Injective (rows q)) (hrows : ∀ q i, (rows q i).card ≤ degree q) : + ∃ s : ∀ q, O q ↪ BoundedIntegerExponent J (degree q), + (∀ q, ((scalarKernelIntegerJet x (degree q) (rows q)).submatrix id (s q)).det ≠ 0) ∧ + ∀ (H : Q → ℝ), (∀ q, 0 < H q) → + ∀ (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ X) + (z : Z → ℤ) (y : X → ℤ) (T : K → ℝ), + (∀ k, 0 < T k) → (∀ k, T k ≤ (L : ℝ)) → + (∀ q n, (e q n).sum (fun _ d => d) ≤ degree q) → + (∀ k a, |((Sum.elim z y (input k a) : ℤ) : ℝ)/T k| ≤ 1) → + ∀ G : ℝ, (∀ q, (((B^degree q)^Fintype.card (O q) : ℕ) : ℝ) ≤ G) → + ∀ q, CoefficientFiberControl + (Matrix.fromCols (scalarKernelIntegerJet x (degree q) (rows q)) + (integerMappedJetMatrix (e q) input z (rows q) y)) + ((s q).trans Function.Embedding.inl) + (Sum.elim (kernelJetCoefficientScale J (degree q) L (H q)) + (fun n => H q / monomialScale T (e q n))) + (H q) L (degree q) (kernelJetEntryAllowance (Fintype.card α) (degree q)) + (kernelJetInverseAllowance (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) (degree q) κ) G := by + classical + have hchoice (q) := goodScalarKernelTuple_fixed_jet_pivot hL selection hκ x hx + (degree q) (rows q) (hinj q) (hrows q) + choose s hd hi using hchoice + refine ⟨s, hd, ?_⟩ + intro H hH e input z y T hT hTL he hn G hG q + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ + · simpa only [fromCols_left_pivot] using hd q + · intro j + cases j with + | inl a => exact kernelJetCoefficientScale_lower J (degree q) (by exact_mod_cast hL) (hH q).le a + | inr n => exact kernelCoefficientScale_lower T hT (hH q).le (by exact_mod_cast hL) hTL (e q n) (he q n) + · intro i j + exact scalarKernelJet_integer_entry hL x (degree q) (rows q) i (s q j) + · intro i j + rw [normalizedIntegerColumns_fromCols] + cases j with + | inl a => + simpa only [Matrix.fromCols_apply_inl, normalizedIntegerColumns_entry_div] using + scalarKernelJet_normalized_entry hL x (degree q) (rows q) (hH q).ne' i a + | inr n => + simpa only [Matrix.fromCols_apply_inr, normalizedIntegerColumns_entry_div, + integerMappedJetMatrix, integerMappedCubeTuple] using + normalizedAffineMonomialJetMatrix_bound + (fun k => Sum.elim z y (input k none)) (fun a k => Sum.elim z y (input k (some a))) + (e q) (rows q) T (he q) (fun k => hn k none) (fun a k => hn k (some a)) (hH q).ne' i n + · rw [fromCols_left_pivot] + exact hi q (H q) (hH q).ne' + · have hb := scalarKernelJet_extended_index selection x hx (degree q) (rows q) + (hinj q) (hrows q) (integerMappedJetMatrix (e q) input z (rows q) y) + have hb' : ((Matrix.fromCols (scalarKernelIntegerJet x (degree q) (rows q)) + (integerMappedJetMatrix (e q) input z (rows q) y)).mulVecLin.range.toAddSubgroup.index : ℝ) ≤ + (((B^degree q)^Fintype.card (O q) : ℕ) : ℝ) := by exact_mod_cast hb + exact hb'.trans (hG q) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem scalarKernel_real_entry_bound {α J O : Type*} + [Fintype α] [DecidableEq α] [Fintype J] {L : ℕ} (hL : 0 < L) + (x : J → IntegerScalarCubeBox α L) (degree : ℕ) (rows : O → Finset α) + (i : O) (a : BoundedIntegerExponent J degree) : + |normalizedScalarKernelJet x degree rows i a| ≤ kernelJetEntryAllowance (Fintype.card α) degree := by + have hc (j : J) (i : Option α) : |(x j i : ℝ) / L| ≤ 1 := + (norm_le_pi_norm (fun i => (x j i : ℝ) / L) i).trans + (integerScalarCubeBox_normalized_norm_le hL (x j)) + exact boundedDegreeRealJetMatrix_entry_bound _ _ (fun j => hc j none) + (fun i j => hc j (some i)) degree rows i a + +theorem scalarKernelFixed_operator_bounds {α J O : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L : ℕ} (hL : 0 < L) + (x : J → IntegerScalarCubeBox α L) (degree : ℕ) (rows : O → Finset α) + (s : O ↪ BoundedIntegerExponent J degree) + (hs : ((scalarKernelIntegerJet x degree rows).submatrix id s).det ≠ 0) : + ‖(scalarKernelFixedPivot hL x degree rows s hs).toContinuousLinearMap‖ ≤ + Fintype.card O * kernelJetEntryAllowance (Fintype.card α) degree ∧ + ‖scalarKernelFixedFree x degree rows s‖ ≤ + Fintype.card (UnselectedColumn s) * kernelJetEntryAllowance (Fintype.card α) degree := by + constructor + · rw [scalarKernelFixedPivot, normalizedPivotEquiv_coe, + normalized_scalarKernel_pivot x degree rows s one_ne_zero] + exact matrixSupCLM_norm_le _ (kernelJetEntryAllowance_pos _ _).le + (fun i j => scalarKernel_real_entry_bound hL x degree rows i (s j)) + · exact matrixSupCLM_norm_le _ (kernelJetEntryAllowance_pos _ _).le + (fun i j => scalarKernel_real_entry_bound hL x degree rows i j.val) + +theorem goodKernel_fixed_pivots {Q α J : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + {O : Q → Type*} [∀ q, Fintype (O q)] [∀ q, DecidableEq (O q)] + {L B : ℕ} {κ : ℝ} (hL : 0 < L) (selection : α ↪ J) (hκ : 0 < κ) + (x : J → IntegerScalarCubeBox α L) (hx : GoodScalarKernelTuple selection κ B x) + (degree : Q → ℕ) (rows : ∀ q, O q → Finset α) + (hinj : ∀ q, Function.Injective (rows q)) (hrows : ∀ q i, (rows q i).card ≤ degree q) : + ∃ s : ∀ q, O q ↪ BoundedIntegerExponent J (degree q), + ∃ hs : ∀ q, ((scalarKernelIntegerJet x (degree q) (rows q)).submatrix id (s q)).det ≠ 0, + ∀ q, ‖(scalarKernelFixedPivot hL x (degree q) (rows q) (s q) (hs q)).symm.toContinuousLinearMap‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) (degree q) κ := by + classical + have hc (q) := goodScalarKernelTuple_fixed_jet_pivot hL selection hκ x hx + (degree q) (rows q) (hinj q) (hrows q) + choose s hs hi using hc + refine ⟨s, hs, fun q => ?_⟩ + rw [scalarKernelFixedPivot, normalizedPivotEquiv_inverse_eq] + exact hi q 1 one_ne_zero + +theorem fixedKernel_mapped_control {α J O N K Z X : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] [Fintype N] [DecidableEq N] + {L B : ℕ} {κ H U G : ℝ} (hL : 0 < L) (selection : α ↪ J) + (x : J → IntegerScalarCubeBox α L) (hx : GoodScalarKernelTuple selection κ B x) + (degree : ℕ) (rows : O → Finset α) (hinj : Function.Injective rows) + (hrows : ∀ i, (rows i).card ≤ degree) (s : O ↪ BoundedIntegerExponent J degree) + (hs : ((scalarKernelIntegerJet x degree rows).submatrix id s).det ≠ 0) + (hi : ‖(scalarKernelFixedPivot hL x degree rows s hs).symm.toContinuousLinearMap‖ ≤ U) + (hH : 0 < H) (e : N → K →₀ ℕ) (input : K → Option α → Z ⊕ X) + (z : Z → ℤ) (y : X → ℤ) (T : K → ℝ) (hT : ∀ k, 0 < T k) + (hTL : ∀ k, T k ≤ (L : ℝ)) (he : ∀ n, (e n).sum (fun _ d => d) ≤ degree) + (hn : ∀ k a, |((Sum.elim z y (input k a) : ℤ) : ℝ)/T k| ≤ 1) + (hG : (((B^degree)^Fintype.card O : ℕ) : ℝ) ≤ G) : + CoefficientFiberControl + (Matrix.fromCols (scalarKernelIntegerJet x degree rows) (integerMappedJetMatrix e input z rows y)) + (s.trans Function.Embedding.inl) + (Sum.elim (kernelJetCoefficientScale J degree L H) (fun n => H / monomialScale T (e n))) + H L degree (kernelJetEntryAllowance (Fintype.card α) degree) U G := by + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ + · simpa only [fromCols_left_pivot] using hs + · intro j + cases j with + | inl a => exact kernelJetCoefficientScale_lower J degree (by exact_mod_cast hL) hH.le a + | inr n => exact kernelCoefficientScale_lower T hT hH.le (by exact_mod_cast hL) hTL (e n) (he n) + · intro i j + exact scalarKernelJet_integer_entry hL x degree rows i (s j) + · intro i j + rw [normalizedIntegerColumns_fromCols] + cases j with + | inl a => + simpa only [Matrix.fromCols_apply_inl, normalizedIntegerColumns_entry_div] using + scalarKernelJet_normalized_entry hL x degree rows hH.ne' i a + | inr n => + simpa only [Matrix.fromCols_apply_inr, normalizedIntegerColumns_entry_div, + integerMappedJetMatrix, integerMappedCubeTuple] using + normalizedAffineMonomialJetMatrix_bound + (fun k => Sum.elim z y (input k none)) (fun a k => Sum.elim z y (input k (some a))) + e rows T he (fun k => hn k none) (fun a k => hn k (some a)) hH.ne' i n + · rw [fromCols_left_pivot] + change ‖(matrixSupCLM (normalizedIntegerPivot ((scalarKernelIntegerJet x degree rows).submatrix id s) + (fun i => kernelJetCoefficientScale J degree L H (s i)) (fun _ => H))).inverse‖ ≤ U + rw [← normalizedPivotEquiv_inverse_eq _ hs + (fun i => kernelJetCoefficientScale J degree L H (s i)) (fun _ => H) + (fun i => kernelJetCoefficientScale_pos J degree (by exact_mod_cast hL) hH (s i)) (fun _ => hH), + scalarKernel_pivot_scale_independent hL x degree rows s hs hH] + exact hi + · have hb := scalarKernelJet_extended_index selection x hx degree rows hinj hrows + (integerMappedJetMatrix e input z rows y) + have hb' : ((Matrix.fromCols (scalarKernelIntegerJet x degree rows) + (integerMappedJetMatrix e input z rows y)).mulVecLin.range.toAddSubgroup.index : ℝ) ≤ + (((B^degree)^Fintype.card O : ℕ) : ℝ) := by exact_mod_cast hb + exact hb'.trans hG + +end Erdos3 + +end + +section + +namespace Erdos3 + +def kernelPeriodCandidate {B : ℕ} (degree : ℕ) (a : Fin B) : ℕ := + (a.val + 1) ^ degree + +theorem kernelPeriodCandidate_pos {B : ℕ} (degree : ℕ) (a : Fin B) : + 0 < kernelPeriodCandidate degree a := + pow_pos (Nat.succ_pos _) _ + +instance kernelPeriodCandidate_neZero {B : ℕ} (degree : ℕ) (a : Fin B) : + NeZero (kernelPeriodCandidate degree a) := + ⟨(kernelPeriodCandidate_pos degree a).ne'⟩ + +theorem kernelPeriodCandidate_le {B : ℕ} (degree : ℕ) (a : Fin B) : + kernelPeriodCandidate degree a ≤ B ^ degree := + Nat.pow_le_pow_left (Nat.succ_le_of_lt a.isLt) _ + +theorem kernelPeriodCandidate_le_exp {B : ℕ} {p : ℝ} + (hB : (B : ℝ) ≤ Real.exp p) (degree : ℕ) (a : Fin B) : + (kernelPeriodCandidate degree a : ℝ) ≤ Real.exp (degree * p) := by + calc + _ ≤ (B : ℝ) ^ degree := by exact_mod_cast kernelPeriodCandidate_le degree a + _ ≤ (Real.exp p) ^ degree := pow_le_pow_left₀ (Nat.cast_nonneg _) hB _ + _ = _ := (Real.exp_nat_mul p degree).symm + +theorem goodKernel_periodFamily {Q α J : Type*} + [Fintype α] [DecidableEq α] [Fintype J] + {O : Q → Type*} [∀ q, Fintype (O q)] + {L B : ℕ} {κ : ℝ} (selection : α ↪ J) + (x : J → IntegerScalarCubeBox α L) (hx : GoodScalarKernelTuple selection κ B x) + (smax : ℕ) (hsmax : 1 ≤ smax) (degree : Q → ℕ) (hdegree : ∀ q, degree q ≤ smax) + (rows : ∀ q, O q → Finset α) (hinj : ∀ q, Function.Injective (rows q)) + (hrows : ∀ q i, (rows q i).card ≤ degree q) : + ∃ a : Fin B, + (∀ root : J → ℤ, integerScalarLattice (Unit ⊕ α) (kernelPeriodCandidate smax a : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + (∀ q, integerScalarLattice (O q) (kernelPeriodCandidate smax a : ℤ) ≤ + (scalarKernelIntegerJet x (degree q) (rows q)).mulVecLin.range) := by + obtain ⟨a, ha, haB, hp⟩ := hx.2 + let candidate : Fin B := ⟨a - 1, by omega⟩ + have hc : candidate.val + 1 = a := by dsimp [candidate]; omega + refine ⟨candidate, ?_, ?_⟩ + · intro root + rw [selectedSpatial_full_image, kernelPeriodCandidate, hc, Nat.cast_pow] + apply (integerScalarLattice_pow_le (a : ℤ) hsmax).trans + simpa only [pow_one] using + rootDifferenceMatrix_period root (scalarCubeDifferenceMatrix x) (a : ℤ) hp + · intro q + rw [kernelPeriodCandidate, hc, Nat.cast_pow] + exact boundedDegreeIntegerJetMatrix_common_period _ _ (a : ℤ) hp smax (degree q) + (hdegree q) (rows q) (hinj q) (hrows q) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem goodKernel_periodFamily_uniform_rows {α J : Type*} + [Fintype α] [DecidableEq α] [Fintype J] + {L B : ℕ} {κ : ℝ} (selection : α ↪ J) + (x : J → IntegerScalarCubeBox α L) (hx : GoodScalarKernelTuple selection κ B x) + (smax : ℕ) (hsmax : 1 ≤ smax) : + ∃ candidate : Fin B, + (∀ root : J → ℤ, integerScalarLattice (Unit ⊕ α) (kernelPeriodCandidate smax candidate : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + ∀ (O : Type*) [Fintype O] (degree : ℕ), degree ≤ smax → + ∀ rows : O → Finset α, Function.Injective rows → + (∀ o, (rows o).card ≤ degree) → + integerScalarLattice O (kernelPeriodCandidate smax candidate : ℤ) ≤ + (scalarKernelIntegerJet x degree rows).mulVecLin.range := by + obtain ⟨a, ha, haB, hp⟩ := hx.2 + let candidate : Fin B := ⟨a - 1, by omega⟩ + have hc : candidate.val + 1 = a := by dsimp [candidate]; omega + refine ⟨candidate, ?_, ?_⟩ + · intro root + rw [selectedSpatial_full_image, kernelPeriodCandidate, hc, Nat.cast_pow] + apply (integerScalarLattice_pow_le (a : ℤ) hsmax).trans + simpa only [pow_one] using rootDifferenceMatrix_period root (scalarCubeDifferenceMatrix x) (a : ℤ) hp + · intro O hO degree hdegree rows hinj hrows + rw [kernelPeriodCandidate, hc, Nat.cast_pow] + exact boundedDegreeIntegerJetMatrix_common_period _ _ (a : ℤ) hp smax degree + hdegree rows hinj hrows + +noncomputable def goodKernelUniformCandidate {α J : Type*} + [Fintype α] [DecidableEq α] [Fintype J] {L B : ℕ} {κ : ℝ} + (selection : α ↪ J) (x : J → IntegerScalarCubeBox α L) + (hx : GoodScalarKernelTuple selection κ B x) (_height : ℕ) : Fin B := + ⟨Classical.choose hx.2 - 1, by + have h := Classical.choose_spec hx.2 + omega⟩ + +theorem goodKernelUniformCandidate_spec {α J : Type*} + [Fintype α] [DecidableEq α] [Fintype J] {L B : ℕ} {κ : ℝ} + (selection : α ↪ J) (x : J → IntegerScalarCubeBox α L) + (hx : GoodScalarKernelTuple selection κ B x) (height : ℕ) : + let period := kernelPeriodCandidate (height + 1) (goodKernelUniformCandidate selection x hx height) + (∀ root : J → ℤ, integerScalarLattice (Unit ⊕ α) (period : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) selection) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) selection)) ∧ + ∀ (O : Type*) [Fintype O] (degree : ℕ), degree ≤ height + 1 → + ∀ rows : O → Finset α, Function.Injective rows → + (∀ o, (rows o).card ≤ degree) → + integerScalarLattice O (period : ℤ) ≤ (scalarKernelIntegerJet x degree rows).mulVecLin.range := +by + let a := Classical.choose hx.2 + obtain ⟨ha, haB, hp⟩ := Classical.choose_spec hx.2 + have hc : (goodKernelUniformCandidate selection x hx height).val + 1 = a := by + dsimp only [goodKernelUniformCandidate, a] + omega + refine ⟨?_, ?_⟩ + · intro root + rw [selectedSpatial_full_image, kernelPeriodCandidate, hc, Nat.cast_pow] + apply (integerScalarLattice_pow_le (a : ℤ) (by omega : 1 ≤ height + 1)).trans + simpa only [pow_one] using rootDifferenceMatrix_period root (scalarCubeDifferenceMatrix x) (a : ℤ) hp + · intro O hO degree hdegree rows hinj hrows + rw [kernelPeriodCandidate, hc, Nat.cast_pow] + exact boundedDegreeIntegerJetMatrix_common_period _ _ (a : ℤ) hp (height + 1) degree + hdegree rows hinj hrows + +theorem integerScalarLattice_le_of_nat_dvd {O : Type*} [Fintype O] {a b : ℕ} + (h : a ∣ b) : integerScalarLattice O (b : ℤ) ≤ integerScalarLattice O (a : ℤ) := by + obtain ⟨c, rfl⟩ := h + rintro y ⟨z, rfl⟩ + refine ⟨(c : ℤ) • z, ?_⟩ + change (a : ℤ) • ((c : ℤ) • z) = ((a * c : ℕ) : ℤ) • z + rw [smul_smul, Nat.cast_mul] + +theorem kernelPeriodCandidate_cover {B : ℕ} (smax : ℕ) (candidate : Fin B) + {d₀ : ℕ} (hd₀ : 0 < d₀) {D P : ℝ} + (hd : (d₀ : ℝ) ≤ Real.exp D) (hB : (B : ℝ) ≤ Real.exp P) : + ∃ d : ℕ, 0 < d ∧ d₀ ∣ d ∧ kernelPeriodCandidate smax candidate ∣ d ∧ + d₀ ≤ d ∧ (d : ℝ) ≤ Real.exp (D + smax * P) := by + refine ⟨d₀ * kernelPeriodCandidate smax candidate, + Nat.mul_pos hd₀ (kernelPeriodCandidate_pos _ _), dvd_mul_right _ _, dvd_mul_left _ _, ?_, ?_⟩ + · exact Nat.le_mul_of_pos_right _ (kernelPeriodCandidate_pos _ _) + · rw [Nat.cast_mul, Real.exp_add] + exact mul_le_mul hd (kernelPeriodCandidate_le_exp hB smax candidate) + (Nat.cast_nonneg _) (Real.exp_nonneg _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +def kernelInverseLog (q n j d : ℕ) (p : ℝ) : ℝ := + (j : ℝ) + (j : ℝ)^2 + (j - 1 : ℕ) * ((q : ℝ) * (d + 1)) + + j * (d * n + d * ((q : ℝ)^2 + q + p + 2)) + +def kernelGeometryLog (q n j k d : ℕ) (p : ℝ) : ℝ := + p + j + k + (q : ℝ) * (d + 1) + kernelInverseLog q n j d p + +theorem kernelGeometryLog_bounds (q n j k d : ℕ) {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ kernelGeometryLog q n j k d p ∧ p ≤ kernelGeometryLog q n j k d p ∧ + kernelInverseLog q n j d p ≤ kernelGeometryLog q n j k d p ∧ + (j : ℝ) + (q : ℝ) * (d + 1) ≤ kernelGeometryLog q n j k d p ∧ + (k : ℝ) + (q : ℝ) * (d + 1) ≤ kernelGeometryLog q n j k d p := by + have hi : 0 ≤ kernelInverseLog q n j d p := by unfold kernelInverseLog; positivity + have hj : (0 : ℝ) ≤ j := Nat.cast_nonneg _ + have hk : (0 : ℝ) ≤ k := Nat.cast_nonneg _ + have he : 0 ≤ (q : ℝ) * (d + 1) := by positivity + unfold kernelGeometryLog + constructor + · positivity + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +theorem nat_mul_kernelEntry_le_exp (a q d : ℕ) : + (a : ℝ) * kernelJetEntryAllowance q d ≤ Real.exp ((a : ℝ) + (q : ℝ) * (d + 1)) := by + have ha : (a : ℝ) ≤ Real.exp a := by linarith [Real.add_one_le_exp (a : ℝ)] + calc + _ ≤ Real.exp a * Real.exp ((q : ℝ) * (d + 1)) := + mul_le_mul ha (kernelJetEntryAllowance_le_exp q d) (kernelJetEntryAllowance_pos q d).le (Real.exp_pos _).le + _ = _ := (Real.exp_add _ _).symm + +theorem fixedKernel_geometry_le_exp {α J O : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L M : ℕ} (hL : 0 < L) (hM : 0 < M) + (x : J → IntegerScalarCubeBox α L) (d : ℕ) (rows : O → Finset α) + (s : O ↪ BoundedIntegerExponent J d) + (hs : ((scalarKernelIntegerJet x d rows).submatrix id s).det ≠ 0) + (hi : ‖(scalarKernelFixedPivot hL x d rows s hs).symm.toContinuousLinearMap‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card J) (Fintype.card O) d (1/(M : ℝ))) + {p : ℝ} (hp : 0 ≤ p) (hMp : (M : ℝ) ≤ Real.exp p) : + let P := kernelGeometryLog (Fintype.card α) (Fintype.card J) (Fintype.card O) + (Fintype.card (BoundedIntegerExponent J d)) d p + ‖(scalarKernelFixedPivot hL x d rows s hs).toContinuousLinearMap‖ ≤ Real.exp P ∧ + ‖(scalarKernelFixedPivot hL x d rows s hs).symm.toContinuousLinearMap‖ ≤ Real.exp P ∧ + ‖scalarKernelFixedFree x d rows s‖ ≤ Real.exp P := by + dsimp only + have hb := kernelGeometryLog_bounds (Fintype.card α) (Fintype.card J) (Fintype.card O) + (Fintype.card (BoundedIntegerExponent J d)) d hp + have he := scalarKernelFixed_operator_bounds hL x d rows s hs + have hcard : Fintype.card (UnselectedColumn s) ≤ Fintype.card (BoundedIntegerExponent J d) := + Fintype.card_subtype_le _ + refine ⟨he.1.trans ((nat_mul_kernelEntry_le_exp _ _ _).trans (Real.exp_le_exp.mpr hb.2.2.2.1)), ?_, ?_⟩ + · apply hi.trans + apply (kernelJetInverseAllowance_le_exp (Fintype.card α) (Fintype.card J) (Fintype.card O) d + (one_div_pos.mpr (by exact_mod_cast hM)) hp (by simpa only [one_div, inv_inv] using hMp)).trans + exact Real.exp_le_exp.mpr hb.2.2.1 + · apply he.2.trans + apply (mul_le_mul_of_nonneg_right (by exact_mod_cast hcard : (Fintype.card (UnselectedColumn s) : ℝ) ≤ + Fintype.card (BoundedIntegerExponent J d)) (kernelJetEntryAllowance_pos _ _).le).trans + exact (nat_mul_kernelEntry_le_exp _ _ _).trans (Real.exp_le_exp.mpr hb.2.2.2.2) + +noncomputable def kernelRowOutputLog (q n j k u d : ℕ) (p : ℝ) : ℝ := + let P := kernelGeometryLog q n j k d p + (j : ℝ)^2 + (j + 1) * P + affineProfileLogBound k p + k * (P + 1) + + jetOutputRadiusLog q u d P + 1 + +theorem kernelRowOutputLog_nonneg (q n j k u d : ℕ) {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ kernelRowOutputLog q n j k u d p := by + have hP := (kernelGeometryLog_bounds q n j k d hp).1 + have hf := affineProfileLogBound_nonneg k hp + have hr := jetOutputRadiusLog_nonneg q u d hP + unfold kernelRowOutputLog + positivity + +theorem fixedKernel_output_le_exp {α J O N : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] [Fintype N] + {L M : ℕ} (hL : 0 < L) (hM : 0 < M) + (x : J → IntegerScalarCubeBox α L) (d : ℕ) (rows : O → Finset α) + (s : O ↪ BoundedIntegerExponent J d) + (hs : ((scalarKernelIntegerJet x d rows).submatrix id s).det ≠ 0) + (hi : ‖(scalarKernelFixedPivot hL x d rows s hs).symm.toContinuousLinearMap‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card J) (Fintype.card O) d (1/(M : ℝ))) + (δ R : ℝ≥0) (hδ : 0 < δ) {p : ℝ} (hp : 0 ≤ p) (hMp : (M : ℝ) ≤ Real.exp p) + (hR : (R : ℝ) ≤ Real.exp p) (hδp : (δ : ℝ)⁻¹ ≤ Real.exp p) : + let E := scalarKernelFixedPivot hL x d rows s hs + let F := scalarKernelFixedFree x d rows s + let B := kernelRowOutputLog (Fintype.card α) (Fintype.card J) (Fintype.card O) + (Fintype.card (BoundedIntegerExponent J d)) (Fintype.card N) d p + (pivotKernelCap (UnselectedColumn s) E R (δ⁻¹^Fintype.card (BoundedIntegerExponent J d)) : ℝ) ≤ Real.exp B ∧ + (pivotKernelLip (UnselectedColumn s) E R (affineProductProfileLip (BoundedIntegerExponent J d) δ) : ℝ) ≤ Real.exp B ∧ + (normalizedJetOutputRadius α N E F d R R : ℝ) ≤ Real.exp B := by + dsimp only + let P := kernelGeometryLog (Fintype.card α) (Fintype.card J) (Fintype.card O) + (Fintype.card (BoundedIntegerExponent J d)) d p + have hb := kernelGeometryLog_bounds (Fintype.card α) (Fintype.card J) (Fintype.card O) + (Fintype.card (BoundedIntegerExponent J d)) d hp + have hnorm := fixedKernel_geometry_le_exp hL hM x d rows s hs hi hp hMp + have hP : 0 ≤ P := hb.1 + have hRP : (R : ℝ) ≤ Real.exp P := hR.trans (Real.exp_le_exp.mpr hb.2.1) + have hprof := affineProfileLogBound_nonneg (Fintype.card (BoundedIntegerExponent J d)) hp + have hrad := jetOutputRadiusLog_nonneg (Fintype.card α) (Fintype.card N) d hb.1 + have hcard : (Fintype.card (UnselectedColumn s) : ℝ) ≤ Fintype.card (BoundedIntegerExponent J d) := + by exact_mod_cast Fintype.card_subtype_le (fun a : BoundedIntegerExponent J d => a ∉ Set.range s) + have hmul := mul_le_mul_of_nonneg_right hcard (by linarith : 0 ≤ P + 1) + have hcap : ((δ⁻¹^Fintype.card (BoundedIntegerExponent J d) : ℝ≥0) : ℝ) ≤ + Real.exp (affineProfileLogBound (Fintype.card (BoundedIntegerExponent J d)) p) := by + simpa only [NNReal.coe_pow, NNReal.coe_inv] using + affineProductProfile_cap_le_exp _ (show (0 : ℝ) < δ from hδ) hp hδp + refine ⟨?_, ?_, ?_⟩ + · apply (pivotKernelCap_le_exp _ _ R _ hnorm.2.1 hRP hcap).trans + apply Real.exp_le_exp.mpr + dsimp [kernelRowOutputLog] + nlinarith [hb.1] + · apply (pivotKernelLip_le_exp _ _ R _ hnorm.2.1 hRP + (affineProductProfileLip_le_exp (BoundedIntegerExponent J d) hδp)).trans + apply Real.exp_le_exp.mpr + dsimp [kernelRowOutputLog] + linarith + · apply (normalizedJetOutputRadius_le_exp α N _ _ d R R hb.1 hnorm.1 hnorm.2.2 hRP hRP).trans + apply Real.exp_le_exp.mpr + have hbase : 0 ≤ (Fintype.card O : ℝ)^2 + (Fintype.card O + 1) * P + + affineProfileLogBound (Fintype.card (BoundedIntegerExponent J d)) p + + Fintype.card (BoundedIntegerExponent J d) * (P + 1) := by positivity + dsimp [kernelRowOutputLog] + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def kernelFamilyIndexLog {Q : Type*} [Fintype Q] + (O : Q → Type*) [∀ q, Fintype (O q)] (smax : ℕ) (p : ℝ) : ℝ := + p * smax * ∑ q, (Fintype.card (O q) : ℝ) + +theorem kernelFamilyIndexLog_nonneg {Q : Type*} [Fintype Q] + (O : Q → Type*) [∀ q, Fintype (O q)] (smax : ℕ) {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ kernelFamilyIndexLog O smax p := by unfold kernelFamilyIndexLog; positivity + +theorem kernelFamilyIndexLog_row {Q : Type*} [Fintype Q] + (O : Q → Type*) [∀ q, Fintype (O q)] (smax : ℕ) (degree : Q → ℕ) + (hdegree : ∀ q, degree q ≤ smax) {M : ℕ} {p : ℝ} + (hp : 0 ≤ p) (hMp : (M : ℝ) ≤ Real.exp p) (q : Q) : + (((M^degree q)^Fintype.card (O q) : ℕ) : ℝ) ≤ Real.exp (kernelFamilyIndexLog O smax p) := by + have hc : (Fintype.card (O q) : ℝ) ≤ ∑ r, (Fintype.card (O r) : ℝ) := + Finset.single_le_sum (f := fun r => (Fintype.card (O r) : ℝ)) + (fun _ _ => Nat.cast_nonneg _) (Finset.mem_univ q) + have hd : (degree q : ℝ) ≤ smax := by exact_mod_cast hdegree q + have he := mul_le_mul_of_nonneg_left + (mul_le_mul hd hc (Nat.cast_nonneg _) (Nat.cast_nonneg _)) hp + calc + _ = (M : ℝ)^(degree q * Fintype.card (O q)) := by simp only [Nat.cast_pow, pow_mul] + _ ≤ (Real.exp p)^(degree q * Fintype.card (O q)) := pow_le_pow_left₀ (Nat.cast_nonneg _) hMp _ + _ = Real.exp (((degree q * Fintype.card (O q) : ℕ) : ℝ) * p) := (Real.exp_nat_mul _ _).symm + _ ≤ _ := by + apply Real.exp_le_exp.mpr + unfold kernelFamilyIndexLog + push_cast + nlinarith + +def kernelCoefficientLog (q n j k d : ℕ) (p g : ℝ) : ℝ := + g + kernelGeometryLog q n j k d p + +theorem kernelCoefficientLog_bounds (q n j k d : ℕ) {M : ℕ} (hM : 0 < M) + {p g : ℝ} (hp : 0 ≤ p) (hg : 0 ≤ g) (hMp : (M : ℝ) ≤ Real.exp p) : + let b := kernelCoefficientLog q n j k d p g + 0 ≤ b ∧ Real.exp g ≤ Real.exp b ∧ + kernelJetInverseAllowance q n j d (1/(M : ℝ)) ≤ Real.exp b ∧ + kernelJetEntryAllowance q d ≤ Real.exp b ∧ Real.exp p ≤ Real.exp b := by + dsimp only + have hb := kernelGeometryLog_bounds q n j k d hp + have hP : kernelGeometryLog q n j k d p ≤ kernelCoefficientLog q n j k d p g := by + unfold kernelCoefficientLog + linarith + refine ⟨add_nonneg hg hb.1, ?_, ?_, ?_, ?_⟩ + · apply Real.exp_le_exp.mpr + unfold kernelCoefficientLog + linarith [hb.1] + · apply (kernelJetInverseAllowance_le_exp q n j d + (one_div_pos.mpr (by exact_mod_cast hM)) hp (by simpa only [one_div, inv_inv] using hMp)).trans + exact Real.exp_le_exp.mpr (hb.2.2.1.trans hP) + · apply (kernelJetEntryAllowance_le_exp q d).trans + apply Real.exp_le_exp.mpr + have he := hb.2.2.2.1.trans hP + linarith [Nat.cast_nonneg j (α := ℝ)] + · exact Real.exp_le_exp.mpr (hb.2.1.trans hP) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelComparisonScales.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelComparisonScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..42e788614c8289b5470303a7ce7ba659f70f40f9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelComparisonScales.lean @@ -0,0 +1,374 @@ +import OAI.Combinatorics.Progressions.Dynamics.CanonicalDetectedScaleInputBudget +import OAI.Combinatorics.Progressions.Dynamics.CoefficientScaleLogBudget +import OAI.Combinatorics.Progressions.Linear.KernelCoefficientLogBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal BigOperators + +noncomputable def kernelFamilyOutputLog {Q α J : Type*} [Fintype Q] [Fintype α] [Fintype J] + (O N : Q → Type*) [∀ q, Fintype (O q)] [∀ q, Fintype (N q)] (degree : Q → ℕ) (p : ℝ) : ℝ := + 1 + ∑ q, kernelRowOutputLog (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) + (Fintype.card (BoundedIntegerExponent J (degree q))) (Fintype.card (N q)) (degree q) p + +theorem kernelFamilyOutputLog_nonneg {Q α J : Type*} [Fintype Q] [Fintype α] [Fintype J] + (O N : Q → Type*) [∀ q, Fintype (O q)] [∀ q, Fintype (N q)] (degree : Q → ℕ) + {p : ℝ} (hp : 0 ≤ p) : 0 ≤ kernelFamilyOutputLog (α := α) (J := J) O N degree p := by + unfold kernelFamilyOutputLog + exact add_nonneg zero_le_one (Finset.sum_nonneg (fun q _ => kernelRowOutputLog_nonneg _ _ _ _ _ _ hp)) + +theorem kernelRowOutputLog_le_family {Q α J : Type*} [Fintype Q] [Fintype α] [Fintype J] + (O N : Q → Type*) [∀ q, Fintype (O q)] [∀ q, Fintype (N q)] (degree : Q → ℕ) + {p : ℝ} (hp : 0 ≤ p) (q : Q) : + kernelRowOutputLog (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) + (Fintype.card (BoundedIntegerExponent J (degree q))) (Fintype.card (N q)) (degree q) p ≤ + kernelFamilyOutputLog (α := α) (J := J) O N degree p := by + unfold kernelFamilyOutputLog + exact (Finset.single_le_sum (fun r _ => kernelRowOutputLog_nonneg (Fintype.card α) (Fintype.card J) + (Fintype.card (O r)) (Fintype.card (BoundedIntegerExponent J (degree r))) (Fintype.card (N r)) (degree r) hp) + (Finset.mem_univ q)).trans (le_add_of_nonneg_left zero_le_one) + +theorem fixedKernel_family_output_bound {Q α J : Type*} + [Fintype Q] [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + {O N : Q → Type*} [∀ q, Fintype (O q)] [∀ q, DecidableEq (O q)] [∀ q, Fintype (N q)] + {L M : ℕ} (hL : 0 < L) (hM : 0 < M) (x : J → IntegerScalarCubeBox α L) + (degree : Q → ℕ) (rows : ∀ q, O q → Finset α) + (s : ∀ q, O q ↪ BoundedIntegerExponent J (degree q)) + (hs : ∀ q, ((scalarKernelIntegerJet x (degree q) (rows q)).submatrix id (s q)).det ≠ 0) + (hi : ∀ q, ‖(scalarKernelFixedPivot hL x (degree q) (rows q) (s q) (hs q)).symm.toContinuousLinearMap‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) (degree q) (1/(M : ℝ))) + (δ R : Q → ℝ≥0) (hδ : ∀ q, 0 < δ q) {p : ℝ} (hp : 0 ≤ p) (hMp : (M : ℝ) ≤ Real.exp p) + (hR : ∀ q, (R q : ℝ) ≤ Real.exp p) (hδp : ∀ q, (δ q : ℝ)⁻¹ ≤ Real.exp p) + (H : Q → ℝ) (hH : ∀ q, 0 < H q) : + let C : ℝ≥0 := ⟨Real.exp (kernelFamilyOutputLog (α := α) (J := J) O N degree p), (Real.exp_pos _).le⟩ + let E := fun q => normalizedPivotEquiv _ (hs q) + (fun i => kernelJetCoefficientScale J (degree q) L (H q) (s q i)) (fun _ => H q) + (fun i => kernelJetCoefficientScale_pos J (degree q) (by exact_mod_cast hL) (hH q) (s q i)) + (fun _ => hH q) + let F := fun q => matrixSupCLM (normalizedIntegerColumns + (remainingMatrixColumns (scalarKernelIntegerJet x (degree q) (rows q)) (s q)) + (fun j => kernelJetCoefficientScale J (degree q) L (H q) j.val) (fun _ => H q)) + 1 ≤ C ∧ + (∀ q, pivotKernelCap (UnselectedColumn (s q)) (E q) (R q) + ((δ q)⁻¹^Fintype.card (BoundedIntegerExponent J (degree q))) ≤ C) ∧ + (∀ q, pivotKernelLip (UnselectedColumn (s q)) (E q) (R q) + (affineProductProfileLip (BoundedIntegerExponent J (degree q)) (δ q)) ≤ C) ∧ + (∀ q, normalizedJetOutputRadius α (N q) (E q) (F q) (degree q) (R q) (R q) ≤ C) := by + dsimp only + have hE (q) := scalarKernel_pivot_scale_independent hL x (degree q) (rows q) (s q) (hs q) (hH q) + have hF (q) := scalarKernel_free_scale_independent x (degree q) (rows q) (s q) (hH q).ne' + simp_rw [hE, hF] + have hrow (q) := fixedKernel_output_le_exp (N := N q) hL hM x (degree q) (rows q) (s q) (hs q) + (hi q) (δ q) (R q) (hδ q) hp hMp (hR q) (hδp q) + have hbound (q) := Real.exp_le_exp.mpr (kernelRowOutputLog_le_family (α := α) (J := J) O N degree hp q) + refine ⟨?_, fun q => ?_, fun q => ?_, fun q => ?_⟩ + · exact_mod_cast Real.one_le_exp_iff.mpr (kernelFamilyOutputLog_nonneg (α := α) (J := J) O N degree hp) + · exact_mod_cast (hrow q).1.trans (hbound q) + · exact_mod_cast (hrow q).2.1.trans (hbound q) + · exact_mod_cast (hrow q).2.2.trans (hbound q) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal BigOperators + +noncomputable def kernelFamilyTupleLog {Q P α J : Type*} + [Fintype Q] [Fintype P] [Fintype α] [Fintype J] + (O N : Q → Type*) [∀ q, Fintype (O q)] [∀ q, Fintype (N q)] + (degree : Q → ℕ) (p : ℝ) : ℝ := + Fintype.card Q + ∑ q, affineJetL1Log (Fintype.card P) (Fintype.card α) + (Fintype.card (BoundedIntegerExponent J (degree q))) (Fintype.card (N q)) (degree q) p + (kernelGeometryLog (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) + (Fintype.card (BoundedIntegerExponent J (degree q))) (degree q) p) + +theorem kernelFamilyTupleLog_nonneg {Q P α J : Type*} + [Fintype Q] [Fintype P] [Fintype α] [Fintype J] + (O N : Q → Type*) [∀ q, Fintype (O q)] [∀ q, Fintype (N q)] + (degree : Q → ℕ) {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ kernelFamilyTupleLog (P := P) (α := α) (J := J) O N degree p := by + unfold kernelFamilyTupleLog + exact add_nonneg (Nat.cast_nonneg _) (Finset.sum_nonneg fun q _ => + affineJetL1Log_nonneg _ _ _ _ _ hp (kernelGeometryLog_bounds _ _ _ _ _ hp).1) + +theorem fixedKernel_family_tuple_bound {Q P α J : Type*} + [Fintype Q] [Fintype P] [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + {O N : Q → Type*} [∀ q, Fintype (O q)] [∀ q, DecidableEq (O q)] [∀ q, Fintype (N q)] + {L M : ℕ} (hL : 0 < L) (hM : 0 < M) (x : J → IntegerScalarCubeBox α L) + (degree : Q → ℕ) (rows : ∀ q, O q → Finset α) + (s : ∀ q, O q ↪ BoundedIntegerExponent J (degree q)) + (hs : ∀ q, ((scalarKernelIntegerJet x (degree q) (rows q)).submatrix id (s q)).det ≠ 0) + (hi : ∀ q, ‖(scalarKernelFixedPivot hL x (degree q) (rows q) (s q) (hs q)).symm.toContinuousLinearMap‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) (degree q) (1/(M : ℝ))) + (δ R : Q → ℝ≥0) {p : ℝ} (hp : 0 ≤ p) (hMp : (M : ℝ) ≤ Real.exp p) + (hR : ∀ q, (R q : ℝ) ≤ Real.exp p) (hδp : ∀ q, (δ q : ℝ)⁻¹ ≤ Real.exp p) + (H : Q → ℝ) (hH : ∀ q, 0 < H q) : + let E := fun q => normalizedPivotEquiv _ (hs q) + (fun i => kernelJetCoefficientScale J (degree q) L (H q) (s q i)) (fun _ => H q) + (fun i => kernelJetCoefficientScale_pos J (degree q) (by exact_mod_cast hL) (hH q) (s q i)) + (fun _ => hH q) + (∑ q, (affineJetL1Cost P α (BoundedIntegerExponent J (degree q)) (N q) + (E q) (degree q) (δ q) (R q) : ℝ)) ≤ + Real.exp (kernelFamilyTupleLog (P := P) (α := α) (J := J) O N degree p) := by + classical + dsimp only + simp_rw [scalarKernel_pivot_scale_independent hL] + let b := fun q => affineJetL1Log (Fintype.card P) (Fintype.card α) + (Fintype.card (BoundedIntegerExponent J (degree q))) (Fintype.card (N q)) (degree q) p + (kernelGeometryLog (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) + (Fintype.card (BoundedIntegerExponent J (degree q))) (degree q) p) + have hb (q) : 0 ≤ b q := + affineJetL1Log_nonneg _ _ _ _ _ hp (kernelGeometryLog_bounds _ _ _ _ _ hp).1 + have hrow (q) := affineJetL1Cost_le_exp P α (BoundedIntegerExponent J (degree q)) (N q) + (scalarKernelFixedPivot hL x (degree q) (rows q) (s q) (hs q)) (degree q) (δ q) (R q) + (hδp q) (hR q) (fixedKernel_geometry_le_exp hL hM x (degree q) (rows q) + (s q) (hs q) (hi q) hp hMp).2.1 + calc + _ ≤ ∑ _q : Q, Real.exp (∑ r, b r) := by + apply Finset.sum_le_sum + intro q _ + exact (hrow q).trans (Real.exp_le_exp.mpr (Finset.single_le_sum (fun r _ => hb r) (Finset.mem_univ q))) + _ = (Fintype.card Q : ℝ) * Real.exp (∑ r, b r) := by simp + _ ≤ Real.exp (Fintype.card Q : ℝ) * Real.exp (∑ r, b r) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + linarith [Real.add_one_le_exp (Fintype.card Q : ℝ)] + _ = _ := by rw [← Real.exp_add]; rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory + +theorem halfAccuracy_inverse_le_exp {η u : ℝ} (hη : 0 < η) (hi : η⁻¹ ≤ Real.exp u) : + (η/2)⁻¹ ≤ Real.exp (u+2) := by + have h2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + calc + _ = 2*η⁻¹ := by rw [inv_div]; ring + _ ≤ Real.exp 2*Real.exp u := mul_le_mul h2 hi (inv_nonneg.mpr hη.le) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add, add_comm] + +def kernelQuadratureLog (q j : ℕ) (B : ℝ) : ℝ := + let V := q+(q+1)*B+2 + j*(V+4)+V + +theorem kernelQuadratureLog_nonneg (q j : ℕ) {B : ℝ} (hB : 0 ≤ B) : + 0 ≤ kernelQuadratureLog q j B := by unfold kernelQuadratureLog; positivity + +theorem kernelQuadrature_le_exp (q j : ℕ) {B : ℝ} (hB : 0 ≤ B) : + (2*Real.exp B+2)^j * + ((q : ℝ)*Real.exp B*(Real.exp B)^q+(q : ℝ)*Real.exp B*(Real.exp B)^q) ≤ + Real.exp (kernelQuadratureLog q j B) := by + let V : ℝ := q+(q+1)*B+2 + have hV : 0 ≤ V := by dsimp only [V]; positivity + have hBV : B ≤ V := by dsimp only [V]; nlinarith [Nat.cast_nonneg (α := ℝ) q] + have hq : (q : ℝ) ≤ Real.exp q := by linarith [Real.add_one_le_exp (q : ℝ)] + have h2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hK : (q : ℝ)*Real.exp B*(Real.exp B)^q+(q : ℝ)*Real.exp B*(Real.exp B)^q ≤ Real.exp V := by + calc + _ = 2*q*Real.exp B*(Real.exp B)^q := by ring + _ ≤ Real.exp 2*Real.exp q*Real.exp B*(Real.exp B)^q := by gcongr + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add, ← Real.exp_add] + congr 1 + dsimp only [V] + ring + exact outputGridQuadratureAllowance_le_exp j (Real.exp_pos _).le (by positivity) + hV (Real.exp_le_exp.mpr hBV) hK + +def kernelTupleAccuracyLog (q : ℕ) (g u : ℝ) : ℝ := 2*(q*g+u+2)+4 + +theorem kernelTupleAccuracyLog_nonneg (q : ℕ) {g u : ℝ} (hg : 0 ≤ g) (hu : 0 ≤ u) : + 0 ≤ kernelTupleAccuracyLog q g u := by unfold kernelTupleAccuracyLog; positivity + +theorem kernelTupleAccuracy_inverse_le_exp (q : ℕ) {g u η : ℝ} + (hg : 0 ≤ g) (hu : 0 ≤ u) (hη : 0 < η) (hi : η⁻¹ ≤ Real.exp u) : + (mixedCoefficientAccuracy ((Real.exp g)^q) (η/2))⁻¹ ≤ + Real.exp (kernelTupleAccuracyLog q g u) := by + apply mixedCoefficientAccuracy_inverse_le_exp (by positivity) (half_pos hη) + (show 0 ≤ (q : ℝ)*g+u+2 by positivity) + · rw [← Real.exp_nat_mul] + exact Real.exp_le_exp.mpr (by linarith) + · exact (halfAccuracy_inverse_le_exp hη hi).trans + (Real.exp_le_exp.mpr (by nlinarith [Nat.cast_nonneg (α := ℝ) q])) + +def kernelOutputMeshLog (q j : ℕ) (g B u : ℝ) : ℝ := + 3*(q*g+kernelQuadratureLog q j B+u+2)+8 + +theorem kernelOutputMeshLog_nonneg (q j : ℕ) {g B u : ℝ} + (hg : 0 ≤ g) (hB : 0 ≤ B) (hu : 0 ≤ u) : 0 ≤ kernelOutputMeshLog q j g B u := by + have hK := kernelQuadratureLog_nonneg q j hB + unfold kernelOutputMeshLog + positivity + +theorem kernelOutputMesh_inverse_le_exp (q j : ℕ) {g B u η : ℝ} + (hg : 0 ≤ g) (hB : 0 ≤ B) (hu : 0 ≤ u) (hη : 0 < η) (hi : η⁻¹ ≤ Real.exp u) : + (outputGridAccuracy ((Real.exp g)^q) + ((2*Real.exp B+2)^j * ((q : ℝ)*Real.exp B*(Real.exp B)^q+(q : ℝ)*Real.exp B*(Real.exp B)^q)) + (η/2))⁻¹ ≤ Real.exp (kernelOutputMeshLog q j g B u) := by + have hK := kernelQuadratureLog_nonneg q j hB + have hqg : 0 ≤ (q : ℝ)*g := by positivity + apply outputGridAccuracy_inverse_le_exp (by positivity) (by positivity) (half_pos hη) + (show 0 ≤ (q : ℝ)*g+kernelQuadratureLog q j B+u+2 by positivity) + · rw [← Real.exp_nat_mul] + exact Real.exp_le_exp.mpr (by linarith) + · exact (kernelQuadrature_le_exp q j hB).trans (Real.exp_le_exp.mpr (by linarith)) + · exact (halfAccuracy_inverse_le_exp hη hi).trans (Real.exp_le_exp.mpr (by linarith)) + +theorem kernelTupleAllowance_le_exp (α : Type*) [Fintype α] [DecidableEq α] + {t : ℝ} (ht : 0 ≤ t) : + 2*scalarCubeGridBoundaryConstant α/volume.real (scalarCubeDomain α)+Real.exp t ≤ + Real.exp (scalarCubeGridRatioLog (Fintype.card α)+t+1) := by + have hr := scalarCubeGridRatioLog_nonneg (Fintype.card α) + have hsum : 0 ≤ scalarCubeGridRatioLog (Fintype.card α)+t := by positivity + have h2 : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ ≤ Real.exp (scalarCubeGridRatioLog (Fintype.card α)+t)+ + Real.exp (scalarCubeGridRatioLog (Fintype.card α)+t) := + add_le_add ((scalarCubeGridRatio_le_exp α).trans (Real.exp_le_exp.mpr (by linarith))) + (Real.exp_le_exp.mpr (by linarith)) + _ = Real.exp (scalarCubeGridRatioLog (Fintype.card α)+t)*2 := by ring + _ ≤ Real.exp (scalarCubeGridRatioLog (Fintype.card α)+t)*Real.exp 1 := + mul_le_mul_of_nonneg_left h2 (Real.exp_pos _).le + _ = _ := (Real.exp_add _ _).symm + +def kernelPrincipalLengthLog (a n q s : ℕ) (p t g u : ℝ) : ℝ := + scalarTupleToleranceLog a n (s*p) (scalarCubeGridRatioLog a+t+1) (kernelTupleAccuracyLog q g u) + +theorem kernelPrincipalLengthLog_nonneg (a n q s : ℕ) {p t g u : ℝ} + (hp : 0 ≤ p) (ht : 0 ≤ t) (hg : 0 ≤ g) (hu : 0 ≤ u) : + 0 ≤ kernelPrincipalLengthLog a n q s p t g u := by + have hr := scalarCubeGridRatioLog_nonneg a + exact scalarTupleToleranceLog_nonneg a n (by positivity) (by positivity) + (kernelTupleAccuracyLog_nonneg q hg hu) + +theorem kernelPrincipalLength_le_exp (α T : Type*) + [Fintype α] [DecidableEq α] [Fintype T] (q s : ℕ) {M : ℕ} {p t g u η : ℝ} + (hp : 0 ≤ p) (ht : 0 ≤ t) (hg : 0 ≤ g) (hu : 0 ≤ u) + (hM : (M : ℝ) ≤ Real.exp p) (hη : 0 < η) (hi : η⁻¹ ≤ Real.exp u) : + (scalarTupleToleranceCutoff α T (M^s) + (2*scalarCubeGridBoundaryConstant α/volume.real (scalarCubeDomain α)+Real.exp t) + (mixedCoefficientAccuracy ((Real.exp g)^q) (η/2)) : ℝ) ≤ + Real.exp (kernelPrincipalLengthLog (Fintype.card α) (Fintype.card T) q s p t g u) := by + have hr := scalarCubeGridRatioLog_nonneg (Fintype.card α) + have hB := (scalarCubeGridBoundaryConstant_pos α).le + have hV := (scalarCubeDomain_volumeReal_pos α).le + apply scalarTupleToleranceCutoff_le_exp α T (by positivity) (by positivity) + (kernelTupleAccuracyLog_nonneg q hg hu) (by positivity) + (mixedCoefficientAccuracy_pos (by positivity) (half_pos hη)) + · push_cast + rw [Real.exp_nat_mul] + exact pow_le_pow_left₀ (Nat.cast_nonneg _) hM s + · exact kernelTupleAllowance_le_exp α ht + · exact kernelTupleAccuracy_inverse_le_exp q hg hu hη hi + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +theorem kernelFamily_scale_choices {Q α P T J : Type*} + [Fintype Q] [Fintype α] [DecidableEq α] [Fintype P] [Fintype T] [Fintype J] + (O N : Q → Type*) [∀ q, Fintype (O q)] [∀ q, Fintype (N q)] + (degree : Q → ℕ) (smax M base : ℕ) {p u c η : ℝ} + (hp : 0 ≤ p) (hu : 0 ≤ u) (hc : 0 ≤ c) (hM : (M : ℝ) ≤ Real.exp p) + (hbase : (base : ℝ) ≤ Real.exp c) (hη : 0 < η) (hi : η⁻¹ ≤ Real.exp u) : + let g := kernelFamilyIndexLog O smax p + let B := kernelFamilyOutputLog (α := α) (J := J) O N degree p + let t := kernelFamilyTupleLog (P := P) (α := α) (J := J) O N degree p + let A := (Real.exp g)^Fintype.card Q + let D := (2*Real.exp B+2)^Fintype.card (Σ q, O q) * + ((Fintype.card Q : ℝ)*Real.exp B*(Real.exp B)^Fintype.card Q+ + (Fintype.card Q : ℝ)*Real.exp B*(Real.exp B)^Fintype.card Q) + let mesh := outputGridAccuracy A D (η/2) + let z := kernelOutputMeshLog (Fintype.card Q) (Fintype.card (Σ q, O q)) g B u + let v := kernelPrincipalLengthLog (Fintype.card α) (Fintype.card T) (Fintype.card Q) smax p t g u + let L := ⌈Real.exp v⌉₊ + let ℓ := max base L + let l := c+v+1 + let b := fun q => kernelCoefficientLog (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) + (Fintype.card (BoundedIntegerExponent J (degree q))) (degree q) p g + let H := fun q => Real.exp (coefficientToleranceLog (Fintype.card (O q)) + (Fintype.card (BoundedIntegerExponent J (degree q) ⊕ N q)) (degree q) + (b q) p (Fintype.card Q+u+4) l z) + 0 < L ∧ L ≤ ℓ ∧ base ≤ ℓ ∧ 0 < ℓ ∧ (ℓ : ℝ) ≤ Real.exp l ∧ + scalarTupleToleranceCutoff α T (M^smax) + (2*scalarCubeGridBoundaryConstant α/volume.real (scalarCubeDomain α)+Real.exp t) + (mixedCoefficientAccuracy A (η/2)) ≤ L ∧ + (∀ q, 0 < H q ∧ 1 ≤ H q) ∧ + ∀ q (s : O q ↪ BoundedIntegerExponent J (degree q)), + coefficientToleranceScale (J := BoundedIntegerExponent J (degree q) ⊕ N q) + (s.trans Function.Embedding.inl) (b q) p + (coefficientRowAccuracy (Fintype.card Q) η) ℓ mesh (degree q) ≤ H q := by + let g := kernelFamilyIndexLog O smax p + let B := kernelFamilyOutputLog (α := α) (J := J) O N degree p + let t := kernelFamilyTupleLog (P := P) (α := α) (J := J) O N degree p + let A := (Real.exp g)^Fintype.card Q + let D := (2*Real.exp B+2)^Fintype.card (Σ q, O q) * + ((Fintype.card Q : ℝ)*Real.exp B*(Real.exp B)^Fintype.card Q+ + (Fintype.card Q : ℝ)*Real.exp B*(Real.exp B)^Fintype.card Q) + let mesh := outputGridAccuracy A D (η/2) + let z := kernelOutputMeshLog (Fintype.card Q) (Fintype.card (Σ q, O q)) g B u + let v := kernelPrincipalLengthLog (Fintype.card α) (Fintype.card T) (Fintype.card Q) smax p t g u + let L := ⌈Real.exp v⌉₊ + let ℓ := max base L + let l := c+v+1 + let b := fun q => kernelCoefficientLog (Fintype.card α) (Fintype.card J) (Fintype.card (O q)) + (Fintype.card (BoundedIntegerExponent J (degree q))) (degree q) p g + have hg : 0 ≤ g := kernelFamilyIndexLog_nonneg O smax hp + have hB : 0 ≤ B := kernelFamilyOutputLog_nonneg O N degree hp + have ht : 0 ≤ t := kernelFamilyTupleLog_nonneg O N degree hp + have hz : 0 ≤ z := kernelOutputMeshLog_nonneg _ _ hg hB hu + have hv : 0 ≤ v := kernelPrincipalLengthLog_nonneg _ _ _ _ hp ht hg hu + have hl : 0 ≤ l := by dsimp only [l]; positivity + have hb (q) : 0 ≤ b q := + add_nonneg hg (kernelGeometryLog_bounds _ _ _ _ _ hp).1 + have hL : 0 < L := Nat.one_le_ceil_iff.mpr (Real.exp_pos v) + have hLℓ : L ≤ ℓ := le_max_right _ _ + have hℓ : 0 < ℓ := hL.trans_le hLℓ + have hLv : (L : ℝ) ≤ Real.exp (v+1) := natCeil_le_exp_succ_of_le hv le_rfl + have hℓl : (ℓ : ℝ) ≤ Real.exp l := by + change ((max base L : ℕ) : ℝ) ≤ _ + rw [Nat.cast_max] + exact max_le (hbase.trans (Real.exp_le_exp.mpr (by dsimp only [l]; linarith))) + (hLv.trans (Real.exp_le_exp.mpr (by dsimp only [l]; linarith))) + have hcut : scalarTupleToleranceCutoff α T (M^smax) + (2*scalarCubeGridBoundaryConstant α/volume.real (scalarCubeDomain α)+Real.exp t) + (mixedCoefficientAccuracy A (η/2)) ≤ L := by + exact_mod_cast (kernelPrincipalLength_le_exp α T (Fintype.card Q) smax hp ht hg hu hM hη hi).trans + (Nat.le_ceil (Real.exp v)) + have he : 0 ≤ (Fintype.card Q : ℝ)+u+4 := by positivity + have hε : 0 < coefficientRowAccuracy (Fintype.card Q) η := coefficientRowAccuracy_pos _ hη + have hεe := coefficientRowAccuracy_inverse_le_exp (Fintype.card Q) hη hi + have hmz : mesh⁻¹ ≤ Real.exp z := kernelOutputMesh_inverse_le_exp _ _ hg hB hu hη hi + refine ⟨hL, hLℓ, le_max_left _ _, hℓ, hℓl, hcut, ?_, ?_⟩ + · intro q + exact ⟨Real.exp_pos _, Real.one_le_exp_iff.mpr + (coefficientToleranceLog_nonneg _ _ _ (hb q) hp he hl hz)⟩ + · intro q s + exact coefficientToleranceScale_le_exp (s.trans Function.Embedding.inl) (degree q) + (hb q) hp he hl hz hε (Nat.cast_nonneg ℓ) hεe hℓl hmz + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelCoreComparison.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelCoreComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..4262c4da627eab941dc4a549e89e78d837cac7e8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelCoreComparison.lean @@ -0,0 +1,350 @@ +import OAI.Combinatorics.Progressions.Estimates.ConditioningShellError +import OAI.Combinatorics.Progressions.Estimates.CorePairingSplit +import OAI.Combinatorics.Progressions.Estimates.FiniteLowLevelSeries +import OAI.Combinatorics.Progressions.Geometry.SupportPairingAggregation + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +omit [Fintype ι] [DecidableEq ι] in +theorem prod_support_factor_bound (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + {κ : ℝ} (hcap : ∀ i, C i ≤ κ ^ 2) (S : Finset ι) : + (∏ i ∈ S, C i) ≤ (κ ^ S.card) ^ 2 := by + calc + _ ≤ ∏ _i ∈ S, κ ^ 2 := Finset.prod_le_prod₀ (fun i _ => hC i) (fun i _ => hcap i) + _ = _ := by + rw [Finset.prod_const, ← pow_mul, ← pow_mul, Nat.mul_comm 2 S.card] + +variable {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + +include hC hbound + +theorem productCouplingPairing_level_abs_le {κ : ℝ} (hκ : 0 ≤ κ) + (hcap : ∀ i, C i ≤ κ ^ 2) (k : ℕ) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : + |productCouplingPairing (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ (Finset.univ.powersetCard k) w) + (productANOVATruncation ν (Finset.univ.powersetCard k) f)| ≤ + κ ^ k * Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) * + Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) := by + apply productCouplingPairing_truncation_abs_le μ ν K C hC hbound hK _ (pow_nonneg hκ k) _ w f + intro S hS + have hc := (Finset.mem_powersetCard.mp hS).2 + simpa only [hc] using prod_support_factor_bound C hC hcap S + +theorem productCouplingPairing_tail_abs_le {κ : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) + (hcap : ∀ i, C i ≤ κ ^ 2) (r : ℕ) (D : Finset (Finset ι)) + (hmin : ∀ S ∈ D, r ≤ S.card) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : + |productCouplingPairing (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ D w) (productANOVATruncation ν D f)| ≤ + κ ^ r * Real.sqrt (productANOVAEnergy μ D w) * Real.sqrt (productANOVAEnergy ν D f) := by + apply productCouplingPairing_truncation_abs_le μ ν K C hC hbound hK D (pow_nonneg hκ0 r) _ w f + intro S hS + have hh := pow_le_pow_of_le_one hκ0 hκ1 (hmin S hS) + exact (prod_support_factor_bound C hC hcap S).trans + (pow_le_pow_left₀ (pow_nonneg hκ0 S.card) hh 2) + +theorem productCouplingPairing_level_of_bounds {κ A B : ℝ} (hκ : 0 ≤ κ) + (hcap : ∀ i, C i ≤ κ ^ 2) (k : ℕ) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) + (hw : Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) ≤ A) + (hf : Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) ≤ B) : + |productCouplingPairing (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ (Finset.univ.powersetCard k) w) + (productANOVATruncation ν (Finset.univ.powersetCard k) f)| ≤ κ ^ k * A * B := by + apply (productCouplingPairing_level_abs_le μ ν K C hC hbound hK hκ hcap k w f).trans + exact mul_le_mul (mul_le_mul_of_nonneg_left hw (pow_nonneg hκ k)) hf (Real.sqrt_nonneg _) + (mul_nonneg (pow_nonneg hκ k) ((Real.sqrt_nonneg _).trans hw)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem productCouplingPairing_low_levels_small {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + {κ A B : ℝ} (hκ : 0 ≤ κ) (hcap : ∀ i, C i ≤ κ ^ 2) + (hsmall : κ * A ^ 2 * B ^ 2 ≤ 1 / 2) (r : ℕ) + (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) + (hw : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) ≤ A ^ (2 * k)) + (hf : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) ≤ B ^ (2 * k)) : + |∑ j ∈ Finset.range r, productCouplingPairing + (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ (Finset.univ.powersetCard (j + 1)) w) + (productANOVATruncation ν (Finset.univ.powersetCard (j + 1)) f)| ≤ 2 * (κ * A ^ 2 * B ^ 2) := by + calc + _ ≤ ∑ j ∈ Finset.range r, |productCouplingPairing + (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ (Finset.univ.powersetCard (j + 1)) w) + (productANOVATruncation ν (Finset.univ.powersetCard (j + 1)) f)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ j ∈ Finset.range r, (κ * A ^ 2 * B ^ 2) ^ (j + 1) := by + apply Finset.sum_le_sum + intro j hj + have hle : j + 1 ≤ r := Finset.mem_range.mp hj + have hb := productCouplingPairing_level_of_bounds μ ν K C hC hbound hK hκ hcap (j + 1) w f + (hw (j + 1) (by omega) hle) (hf (j + 1) (by omega) hle) + exact hb.trans_eq (by rw [mul_pow, mul_pow, pow_mul, pow_mul]) + _ ≤ _ := low_level_series_bound (by positivity) hsmall r + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem finiteKernel_contraction_sq {X Y : Type*} [Fintype X] [Fintype Y] + (μ : FiniteProbabilityWeights X) (ν : FiniteProbabilityWeights Y) + (K : X → FiniteProbabilityWeights Y) + (hK : ∀ f : Y → ℝ, μ.mean (fun x => (K x).mean f) = ν.mean f) (f : Y → ℝ) : + μ.mean (fun x => (K x).mean f ^ 2) ≤ ν.mean (fun y => f y ^ 2) := + (μ.mean_mono (fun x => (K x).mean_square_le f)).trans_eq (hK (fun y => f y ^ 2)) + +theorem productCouplingPairing_restricted_tail_abs_le {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + (J : Finset ι) {κ : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) + (hcap : ∀ i ∈ J, C i ≤ κ ^ 2) (r : ℕ) (D : Finset (Finset ι)) + (hsub : ∀ S ∈ D, S ⊆ J) (hmin : ∀ S ∈ D, r ≤ S.card) + (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : + |productCouplingPairing (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ D w) (productANOVATruncation ν D f)| ≤ + κ ^ r * Real.sqrt (productANOVAEnergy μ D w) * Real.sqrt (productANOVAEnergy ν D f) := by + apply productCouplingPairing_truncation_abs_le μ ν K C hC hbound hK D (pow_nonneg hκ0 r) _ w f + intro S hS + have hp : (∏ i ∈ S, C i) ≤ (κ ^ S.card) ^ 2 := by + calc + _ ≤ ∏ _i ∈ S, κ ^ 2 := Finset.prod_le_prod₀ (fun i _ => hC i) (fun i hi => hcap i (hsub S hS hi)) + _ = _ := by rw [Finset.prod_const, ← pow_mul, ← pow_mul, Nat.mul_comm 2 S.card] + exact hp.trans (pow_le_pow_left₀ (pow_nonneg hκ0 S.card) + (pow_le_pow_of_le_one hκ0 hκ1 (hmin S hS)) 2) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem productKernel_conditioning_shell_bound {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + (I : Finset ι) (b : ℕ) (hIb : I.card ≤ b) + {κ M N : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) + (hcap : ∀ i ∉ I, C i ≤ κ ^ 2) + (x : ∀ i, X i) (y : ∀ i, Y i) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) + (hw : ∀ A ∈ I.powerset, + Real.sqrt (productANOVAEnergy μ (conditioningShellSupports I A b) (productSectionAverage μ I I x w)) ≤ M) + (hf : ∀ A ∈ I.powerset, + Real.sqrt (productANOVAEnergy ν (conditioningShellSupports I A b) (productSectionAverage ν I I y f)) ≤ N) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + |productCouplingPairing c + (productANOVATruncation μ (lowDegreeCoordinateSets ι b) (fun z => productFiberIndicator I x z * w z)) + (productANOVATruncation ν (lowDegreeCoordinateSets ι b) (fun z => productFiberIndicator I y z * f z)) - + productCouplingAtomMass c I x y * productCouplingPairing c + (productANOVATruncation μ (conditioningCoreSupports I b) (productSectionAverage μ I I x w)) + (productANOVATruncation ν (conditioningCoreSupports I b) (productSectionAverage ν I I y f))| ≤ + (2 : ℝ) ^ I.card * (κ ^ (b - I.card) * M * N) := by + dsimp only + apply productCouplingPairing_conditioning_error_le _ I b hIb x y w f + intro A hA + have hs (S : Finset ι) (hS : S ∈ conditioningShellSupports I A b) := + (mem_conditioningShellSupports I A S b).mp hS + have ht := productCouplingPairing_restricted_tail_abs_le μ ν K C hC hbound hK Iᶜ hκ0 hκ1 + (fun i hi => hcap i (Finset.mem_compl.mp hi)) (b - I.card) (conditioningShellSupports I A b) + (fun S hS => (hs S hS).1) (fun S hS => (hs S hS).2.1.le) + (productSectionAverage μ I I x w) (productSectionAverage ν I I y f) + apply ht.trans + exact mul_le_mul (mul_le_mul_of_nonneg_left (hw A hA) (pow_nonneg hκ0 _)) (hf A hA) + (Real.sqrt_nonneg _) (mul_nonneg (pow_nonneg hκ0 _) ((Real.sqrt_nonneg _).trans (hw A hA))) + +theorem productKernel_conditioning_shell_of_truncated {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + (I : Finset ι) (b : ℕ) (hIb : I.card ≤ b) + {κ M N : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) + (hcap : ∀ i ∉ I, C i ≤ κ ^ 2) + (x : ∀ i, X i) (y : ∀ i, Y i) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) + (hw : Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι b) (productSectionAverage μ I I x w)) ≤ M) + (hf : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) (productSectionAverage ν I I y f)) ≤ N) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + |productCouplingPairing c + (productANOVATruncation μ (lowDegreeCoordinateSets ι b) (fun z => productFiberIndicator I x z * w z)) + (productANOVATruncation ν (lowDegreeCoordinateSets ι b) (fun z => productFiberIndicator I y z * f z)) - + productCouplingAtomMass c I x y * productCouplingPairing c + (productANOVATruncation μ (conditioningCoreSupports I b) (productSectionAverage μ I I x w)) + (productANOVATruncation ν (conditioningCoreSupports I b) (productSectionAverage ν I I y f))| ≤ + (2 : ℝ) ^ I.card * (κ ^ (b - I.card) * M * N) := by + have hsub (A : Finset ι) : conditioningShellSupports I A b ⊆ lowDegreeCoordinateSets ι b := by + intro S hS + have hh := (mem_conditioningShellSupports I A S b).mp hS + apply (mem_lowDegreeCoordinateSets ι b S).mpr + omega + apply productKernel_conditioning_shell_bound μ ν K C hC hbound hK I b hIb hκ0 hκ1 hcap x y w f + · intro A _ + exact (Real.sqrt_le_sqrt (productANOVAEnergy_mono μ (hsub A) _)).trans hw + · intro A _ + exact (Real.sqrt_le_sqrt (productANOVAEnergy_mono ν (hsub A) _)).trans hf + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + +include hC hbound + +theorem productCouplingPairing_restricted_level_of_bounds (J : Finset ι) + {κ A B : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∈ J, C i ≤ κ ^ 2) + (k : ℕ) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) + (hw : Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) ≤ A) + (hf : Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) ≤ B) : + |productCouplingPairing (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ (J.powersetCard k) w) + (productANOVATruncation ν (J.powersetCard k) f)| ≤ κ ^ k * A * B := by + have hcard (S : Finset ι) (hS : S ∈ J.powersetCard k) := (Finset.mem_powersetCard.mp hS).2 + have hwr := (Real.sqrt_le_sqrt (productANOVAEnergy_le_level μ (J.powersetCard k) k hcard w)).trans hw + have hfr := (Real.sqrt_le_sqrt (productANOVAEnergy_le_level ν (J.powersetCard k) k hcard f)).trans hf + have ht := productCouplingPairing_restricted_tail_abs_le μ ν K C hC hbound hK J hκ0 hκ1 hcap k + (J.powersetCard k) (fun S hS => (Finset.mem_powersetCard.mp hS).1) + (fun S hS => (hcard S hS).ge) w f + apply ht.trans + exact mul_le_mul (mul_le_mul_of_nonneg_left hwr (pow_nonneg hκ0 k)) hfr (Real.sqrt_nonneg _) + (mul_nonneg (pow_nonneg hκ0 k) ((Real.sqrt_nonneg _).trans hwr)) + +theorem productCouplingPairing_restricted_low_levels_small (J : Finset ι) + {κ A B : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∈ J, C i ≤ κ ^ 2) + (hsmall : κ * A ^ 2 * B ^ 2 ≤ 1 / 2) (r : ℕ) + (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) + (hw : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) ≤ A ^ (2 * k)) + (hf : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) ≤ B ^ (2 * k)) : + |∑ j ∈ Finset.range r, productCouplingPairing + (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ (J.powersetCard (j + 1)) w) + (productANOVATruncation ν (J.powersetCard (j + 1)) f)| ≤ 2 * (κ * A ^ 2 * B ^ 2) := by + calc + _ ≤ ∑ j ∈ Finset.range r, |productCouplingPairing + (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVATruncation μ (J.powersetCard (j + 1)) w) + (productANOVATruncation ν (J.powersetCard (j + 1)) f)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ j ∈ Finset.range r, (κ * A ^ 2 * B ^ 2) ^ (j + 1) := by + apply Finset.sum_le_sum + intro j hj + have hle : j + 1 ≤ r := Finset.mem_range.mp hj + have hb := productCouplingPairing_restricted_level_of_bounds μ ν K C hC hbound hK J hκ0 hκ1 hcap + (j + 1) w f (hw (j + 1) (by omega) hle) (hf (j + 1) (by omega) hle) + exact hb.trans_eq (by rw [mul_pow, mul_pow, pow_mul, pow_mul]) + _ ≤ _ := low_level_series_bound (by positivity) hsmall r + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem productKernel_core_comparison {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + (J : Finset ι) {r b : ℕ} (hrb : r ≤ b) + {κ A B M N : ℝ} (hκ0 : 0 ≤ κ) (hκ1 : κ ≤ 1) (hcap : ∀ i ∈ J, C i ≤ κ ^ 2) + (hsmall : κ * A ^ 2 * B ^ 2 ≤ 1 / 2) + (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) + (hw : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) w) ≤ A ^ (2 * k)) + (hf : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) f) ≤ B ^ (2 * k)) + (hM : Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι b) w) ≤ M) + (hN : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) f) ≤ N) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + |productCouplingPairing c (productANOVATruncation μ (restrictedDegreeSupports J b) w) + (productANOVATruncation ν (restrictedDegreeSupports J b) f) - + (FiniteProbabilityWeights.pi μ).mean w * (FiniteProbabilityWeights.pi ν).mean f| ≤ + 2 * (κ * A ^ 2 * B ^ 2) + κ ^ r * M * N := by + dsimp only + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + have hlo := productCouplingPairing_restricted_low_levels_small μ ν K C hC hbound hK J + hκ0 hκ1 hcap hsmall r w f hw hf + have hsub : degreeTailSupports J r b ⊆ lowDegreeCoordinateSets ι b := by + intro S hS + exact (mem_lowDegreeCoordinateSets ι b S).mpr ((mem_degreeTailSupports J S r b).mp hS).2.2 + have hwm := (Real.sqrt_le_sqrt (productANOVAEnergy_mono μ hsub w)).trans hM + have hfn := (Real.sqrt_le_sqrt (productANOVAEnergy_mono ν hsub f)).trans hN + have ht := productCouplingPairing_restricted_tail_abs_le μ ν K C hC hbound hK J hκ0 hκ1 hcap r + (degreeTailSupports J r b) (fun S hS => ((mem_degreeTailSupports J S r b).mp hS).1) + (fun S hS => ((mem_degreeTailSupports J S r b).mp hS).2.1.le) w f + have htail : |productCouplingPairing c (productANOVATruncation μ (degreeTailSupports J r b) w) + (productANOVATruncation ν (degreeTailSupports J r b) f)| ≤ κ ^ r * M * N := + ht.trans (mul_le_mul (mul_le_mul_of_nonneg_left hwm (pow_nonneg hκ0 r)) hfn + (Real.sqrt_nonneg _) (mul_nonneg (pow_nonneg hκ0 r) ((Real.sqrt_nonneg _).trans hwm))) + calc + _ = |(∑ k ∈ Finset.range r, productCouplingPairing c + (productANOVATruncation μ (J.powersetCard (k + 1)) w) + (productANOVATruncation ν (J.powersetCard (k + 1)) f)) + + productCouplingPairing c (productANOVATruncation μ (degreeTailSupports J r b) w) + (productANOVATruncation ν (degreeTailSupports J r b) f)| := by + rw [productCouplingPairing_core_split c J hrb] + congr 1 + ring + _ ≤ _ := (abs_add_le _ _).trans (add_le_add hlo htail) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelCylinderTotal.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelCylinderTotal.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbb77a4d0a203e7d1d82bfa1026073dfde58d566 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelCylinderTotal.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.Progressions.Dynamics.NormalizedCoreBudget +import OAI.Combinatorics.Progressions.Estimates.RetainedShellComparison +import OAI.Combinatorics.Progressions.Estimates.ScaledConditionedComparison + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem scaled_conditioned_error_rearrange {P a m s H E U : ℝ} + (h : |P - a * (m * H)| ≤ m * s * (E + a * U)) : + |P - (a * m) * H| ≤ m * s * E + a * m * s * U := by + calc + _ = |P - a * (m * H)| := by congr 1; ring + _ ≤ _ := h + _ = _ := by ring + +theorem productKernel_retained_atom_comparison {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + (I : Finset ι) {r b : ℕ} (hIb : I.card ≤ b) (hr : r ≤ b - I.card) + {κ A B M N m v τ lam ε ξ P : ℝ} (hm : 0 < m) (hv : 0 ≤ v) (hτ : 0 < τ) + (hlam : 0 < lam) (hε : 0 ≤ ε) (hξ : 0 < ξ) (hξ1 : ξ ≤ 1) + (hsmall : ξ * (2 + ε) ≤ ε) + (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hcap : ∀ i ∉ I, C i ≤ κ ^ 2) + (hlow : κ * A ^ 2 * B ^ 2 ≤ ξ / 16) (hMN : M * N ≤ Real.exp P) + (hrtail : CyclicCrootSisask.spectralIterations ξ P ≤ r) + (x : ∀ i, X i) (y : ∀ i, Y i) (w : (∀ i, X i) → ℝ) (h g : (∀ i, Y i) → ℝ) + (hmean : productConditionalMean μ I w x = m) + (hHmean : productConditionalMean ν I h y ≤ lam * productConditionalMean ν I g y + lam * τ) + (hGmean : v - τ ≤ productConditionalMean ν I g y) + (hw : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) + (fun z => m⁻¹ * productSectionAverage μ I I x w z)) ≤ A ^ (2 * k)) + (hh : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) + (fun z => (4 * lam * (v + τ))⁻¹ * productSectionAverage ν I I y h z)) ≤ B ^ (2 * k)) + (hg : ∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) + (fun z => (2 * (v + τ))⁻¹ * productSectionAverage ν I I y g z)) ≤ B ^ (2 * k)) + (hM : Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι b) + (fun z => m⁻¹ * productSectionAverage μ I I x w z)) ≤ M) + (hNH : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) + (fun z => (4 * lam * (v + τ))⁻¹ * productSectionAverage ν I I y h z)) ≤ N) + (hNG : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) + (fun z => (2 * (v + τ))⁻¹ * productSectionAverage ν I I y g z)) ≤ N) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + productAtomTruncatedPairing c (lowDegreeCoordinateSets ι b) I x y w + (fun z => h z - (1 + ε) * lam * g z) ≤ + (productCouplingAtomMass c I x y * m) * lam * (1 + 2 * ε) * τ + + m * lam * (v + τ) * (6 + 2 * ε) * (2 : ℝ) ^ I.card * κ ^ (b - I.card) * M * N := by + dsimp only + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + let U := 2 * (κ * A ^ 2 * B ^ 2) + κ ^ r * M * N + let E := (2 : ℝ) ^ I.card * (κ ^ (b - I.card) * M * N) + have hM0 : 0 ≤ M := (Real.sqrt_nonneg _).trans hM + have hN0 : 0 ≤ N := (Real.sqrt_nonneg _).trans hNH + have hcore := normalized_core_error_budget hξ hξ1 hκ0 hκhalf hM0 hN0 hMN hrtail hlow + have hU : 4 * U ≤ ξ := hcore.2 + have hU' : 2 * U ≤ ξ := by linarith + have hH := productKernel_scaled_conditioned_mean_comparison μ ν K C hC hbound hK I hIb hr + hm (by positivity : 0 < 4 * lam * (v + τ)) hκ0 (by linarith) hcap hcore.1 + x y w h hw hh hM hNH + have hG := productKernel_scaled_conditioned_mean_comparison μ ν K C hC hbound hK I hIb hr + hm (by positivity : 0 < 2 * (v + τ)) hκ0 (by linarith) hcap hcore.1 + x y w g hw hg hM hNG + change |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι b) I x y w h - + productCouplingAtomMass c I x y * (productConditionalMean μ I w x * productConditionalMean ν I h y)| ≤ + m * (4 * lam * (v + τ)) * (E + productCouplingAtomMass c I x y * U) at hH + change |productAtomTruncatedPairing c (lowDegreeCoordinateSets ι b) I x y w g - + productCouplingAtomMass c I x y * (productConditionalMean μ I w x * productConditionalMean ν I g y)| ≤ + m * (2 * (v + τ)) * (E + productCouplingAtomMass c I x y * U) at hG + rw [hmean] at hH hG + have hret := retained_atom_from_normalized_errors + (productCouplingAtomMass_nonneg c I x y) hm.le hlam.le hv hτ.le hε + (scaled_conditioned_error_rearrange hH) (scaled_conditioned_error_rearrange hG) + hU hU' hHmean hGmean hsmall + rw [productAtomTruncatedPairing_sub_smul_right] + exact hret.trans_eq (by dsimp only [E]; ring) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem CylinderRemovalChain.kernel_total_pairing_le {Ω ι : Type*} + [Fintype Ω] [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] [∀ i, DecidableEq (X i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + {base : ∀ i, X i} {p : FiniteProbabilityWeights Ω} {F : Ω → ∀ i, X i} + {L τ : ℝ} {j r b : ℕ} {w rem : Ω → ℝ} {cs : List (ProductCylinder X)} + (hchain : CylinderRemovalChain μ base p F L τ j r w rem cs) + (hμ : ∀ i x, 0 < (μ i).weight x) (baseY : ∀ i, Y i) + (hw : ∀ z, w z ≤ 1) (hrem : ∀ z, 0 ≤ rem z ∧ rem z ≤ 1) (hmass : p.mean rem ≤ τ) + {κ A B M N v lam ε ξ P Q η shell H G : ℝ} + (hM0 : 0 ≤ M) (hN0 : 0 ≤ N) (hv : 0 ≤ v) (hτ : 0 < τ) (hlam : 0 < lam) + (hε : 0 ≤ ε) (hξ : 0 < ξ) (hξ1 : ξ ≤ 1) (hsmall : ξ * (2 + ε) ≤ ε) + (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hcap : ∀ i, C i ≤ κ ^ 2) + (hlow : κ * A ^ 2 * B ^ 2 ≤ ξ / 16) (hMN : M * N ≤ Real.exp P) + (hrtail : CyclicCrootSisask.spectralIterations ξ P ≤ r) (hrb : j + r ≤ b) + (hη : 0 ≤ η) + (hclose : ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η (2 * b)) + (herr : 2 * η * ((lowDegreeCoordinateSets ι b).card : ℝ) ^ 2 * (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ τ) + (h g : (∀ i, Y i) → ℝ) + (hh : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) h) ≤ H) + (hg : Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) g) ≤ G) + (hshell : 0 < shell) (hb : j + CyclicCrootSisask.spectralIterations shell Q ≤ b) + (hbudget : ((cs.zip (removedCylinderWeights F w cs)).map (fun cf => + (Fintype.card (∀ i : cf.1.1, Y i) : ℝ) * + (cf.1.mass μ base (observedProductDensity μ p F cf.2) * lam * (v + τ) * (6 + 2 * ε) * + (2 : ℝ) ^ cf.1.1.card * M * N))).sum ≤ Real.exp Q) + (hpieces : ∀ cf ∈ cs.zip (removedCylinderWeights F w cs), + let m := cf.1.mass μ base (observedProductDensity μ p F cf.2) + let x := cf.1.assignment base + let W := observedProductDensity μ p F cf.2 + (∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) + (fun z => m⁻¹ * productSectionAverage μ cf.1.1 cf.1.1 x W z)) ≤ A ^ (2 * k)) ∧ + Real.sqrt (productANOVAEnergy μ (lowDegreeCoordinateSets ι b) + (fun z => m⁻¹ * productSectionAverage μ cf.1.1 cf.1.1 x W z)) ≤ M ∧ + ∀ z : ∀ i : cf.1.1, Y i, + let y := productSubtypePoint cf.1.1 z baseY + productConditionalMean ν cf.1.1 h y ≤ lam * productConditionalMean ν cf.1.1 g y + lam * τ ∧ + v - τ ≤ productConditionalMean ν cf.1.1 g y ∧ + (∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) + (fun a => (4 * lam * (v + τ))⁻¹ * productSectionAverage ν cf.1.1 cf.1.1 y h a)) ≤ B ^ (2 * k)) ∧ + (∀ k, 1 ≤ k → k ≤ r → Real.sqrt (productANOVAEnergy ν (Finset.univ.powersetCard k) + (fun a => (2 * (v + τ))⁻¹ * productSectionAverage ν cf.1.1 cf.1.1 y g a)) ≤ B ^ (2 * k)) ∧ + Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) + (fun a => (4 * lam * (v + τ))⁻¹ * productSectionAverage ν cf.1.1 cf.1.1 y h a)) ≤ N ∧ + Real.sqrt (productANOVAEnergy ν (lowDegreeCoordinateSets ι b) + (fun a => (2 * (v + τ))⁻¹ * productSectionAverage ν cf.1.1 cf.1.1 y g a)) ≤ N) : + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + productTruncatedPairing c (lowDegreeCoordinateSets ι b) (observedProductDensity μ p F w) + (fun z => h z - (1 + ε) * lam * g z) ≤ + lam * (1 + 2 * ε) * τ + shell / 16 + Real.sqrt (3 * τ) * (H + (1 + ε) * lam * G) := by + dsimp only + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i) + let pref := fun (d : ProductCylinder X) (f : Ω → ℝ) (_z : ∀ i : d.1, Y i) => + d.mass μ base (observedProductDensity μ p F f) * lam * (v + τ) * (6 + 2 * ε) * + (2 : ℝ) ^ d.1.card * M * N + apply CylinderRemovalChain.total_pairing_with_shell_budget c hchain hμ _ baseY hw hrem hmass + hη (by positivity) (by positivity) hκ0 hκhalf hshell + (fun S hS => (mem_lowDegreeCoordinateSets ι b S).mp hS) hclose herr h g hh hg pref + · intro cf hcf z + have hm := hτ.trans (hchain.removed_size_mass cf hcf).2 + dsimp only [pref] + positivity + · simpa only [pref, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using hbudget + · exact hb + · intro cf hcf z + obtain ⟨hsize, hmass'⟩ := hchain.removed_size_mass cf hcf + obtain ⟨hwl, hwm, hsite⟩ := hpieces cf hcf + obtain ⟨hHm, hGm, hhl, hgl, hhn, hgn⟩ := hsite z + have hp := productKernel_retained_atom_comparison μ ν K C hC hbound hK cf.1.1 + (by omega) (by omega) (hτ.trans hmass') hv hτ hlam hε hξ hξ1 hsmall hκ0 hκhalf + (fun i _ => hcap i) hlow hMN hrtail (cf.1.assignment base) + (productSubtypePoint cf.1.1 z baseY) (observedProductDensity μ p F cf.2) h g rfl + hHm hGm hwl hhl hgl hwm hhn hgn + exact hp.trans_eq (by dsimp only [pref]; ring) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelFamilyOutputBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelFamilyOutputBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f3d5cc9a8267a78f9586d449805e74f135dd5c7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelFamilyOutputBounds.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.Progressions.Estimates.InactiveShortLogBounds + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal BigOperators + +theorem exists_kernelFamily_output_bounds {Q α J : Type*} + [Fintype Q] [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + {O N : Q → Type*} [∀ q, Fintype (O q)] [∀ q, DecidableEq (O q)] [∀ q, Fintype (N q)] + {L : ℕ} (hL : 0 < L) (x : J → IntegerScalarCubeBox α L) + (degree : Q → ℕ) (rows : ∀ q, O q → Finset α) + (s : ∀ q, O q ↪ BoundedIntegerExponent J (degree q)) + (hs : ∀ q, ((scalarKernelIntegerJet x (degree q) (rows q)).submatrix id (s q)).det ≠ 0) + (δ R : Q → ℝ≥0) : + ∃ Cap Lip Ro : ℝ≥0, 1 ≤ Cap ∧ ∀ (H : Q → ℝ) (hH : ∀ q, 0 < H q), + let E := fun q => normalizedPivotEquiv _ (hs q) + (fun i => kernelJetCoefficientScale J (degree q) L (H q) (s q i)) (fun _ => H q) + (fun i => kernelJetCoefficientScale_pos J (degree q) (by exact_mod_cast hL) (hH q) (s q i)) + (fun _ => hH q) + let F := fun q => matrixSupCLM (normalizedIntegerColumns + (remainingMatrixColumns (scalarKernelIntegerJet x (degree q) (rows q)) (s q)) + (fun j => kernelJetCoefficientScale J (degree q) L (H q) j.val) (fun _ => H q)) + (∀ q, pivotKernelCap (UnselectedColumn (s q)) (E q) (R q) + ((δ q)⁻¹^Fintype.card (BoundedIntegerExponent J (degree q))) ≤ Cap) ∧ + (∀ q, pivotKernelLip (UnselectedColumn (s q)) (E q) (R q) + (affineProductProfileLip (BoundedIntegerExponent J (degree q)) (δ q)) ≤ Lip) ∧ + (∀ q, normalizedJetOutputRadius α (N q) (E q) (F q) (degree q) (R q) (R q) ≤ Ro) := by + classical + let E := fun q => scalarKernelFixedPivot hL x (degree q) (rows q) (s q) (hs q) + let F := fun q => scalarKernelFixedFree x (degree q) (rows q) (s q) + let caps := fun q => pivotKernelCap (UnselectedColumn (s q)) (E q) (R q) + ((δ q)⁻¹^Fintype.card (BoundedIntegerExponent J (degree q))) + let lips := fun q => pivotKernelLip (UnselectedColumn (s q)) (E q) (R q) + (affineProductProfileLip (BoundedIntegerExponent J (degree q)) (δ q)) + let radii := fun q => normalizedJetOutputRadius α (N q) (E q) (F q) (degree q) (R q) (R q) + refine ⟨1 + ∑ q, caps q, ∑ q, lips q, ∑ q, radii q, ?_, ?_⟩ + · exact le_add_of_nonneg_right (by positivity) + · intro H hH + dsimp only + have hE (q) := scalarKernel_pivot_scale_independent hL x (degree q) (rows q) (s q) (hs q) (hH q) + have hF (q) := scalarKernel_free_scale_independent x (degree q) (rows q) (s q) (hH q).ne' + simp_rw [hE, hF] + refine ⟨fun q => ?_, fun q => ?_, fun q => ?_⟩ + · exact (Finset.single_le_sum (fun r _ => (show 0 ≤ caps r from zero_le)) (Finset.mem_univ q)).trans + (le_add_of_nonneg_left zero_le_one) + · exact Finset.single_le_sum (fun r _ => (show 0 ≤ lips r from zero_le)) (Finset.mem_univ q) + · exact Finset.single_le_sum (fun r _ => (show 0 ≤ radii r from zero_le)) (Finset.mem_univ q) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelFullParameterGeometry.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelFullParameterGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d7c27979e83f303e94642e1576aef87dc63d247 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelFullParameterGeometry.lean @@ -0,0 +1,167 @@ +import OAI.Combinatorics.Progressions.Linear.SmallKernelAllSites +import OAI.Combinatorics.Progressions.Sampling.KernelSamplerThreshold + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory BooleanCubeKernel +open scoped BigOperators NNReal Classical + +theorem exists_kernel_full_parameter_geometry (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {X G : Type*} [Fintype X] [DecidableEq X] [Nonempty X] [Fintype G] [Nonempty G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (R σ : Fin m → ℝ) (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (_hσ1 : ∀ j, σ j ≤ 1) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cinv j * ‖x‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ)+1) * R j ≤ 1/4) + (L₀ : ℕ) {P δ : ℝ} (_hP : 0 ≤ P) (_hδ : 0 < δ) (_hδsmall : δ ≤ 1/6) + (_hδP : δ⁻¹ ≤ Real.exp P) (_hX : (Fintype.card X : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables (G × X) I n B) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) (_hL₀P : (L₀ : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (τ : ℝ) (_hτ : 0 < τ) (_hτ1 : τ ≤ 1) (_hτP : 1/τ ≤ Real.exp P) + (x : CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val+1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : X → ℕ) (_hs : ∀ k, 0 < stride k) + {Rrank S : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (N : X → ℕ) (_hN : ∀ i, 4 ≤ N i) + (_hsize : ∀ k, Real.exp ((P+A)^A) ≤ (N k : ℝ)) + (_hrank : ∀ j, HasLayerSamplingRank (j.val+1) (fun i => (N i : ℝ)) Rrank (U j) (p j)) + (_hRrank : Real.exp ((P+A)^A) ≤ Rrank) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables (G × X) I n B)) X stride)) (_hT : T.Nonempty), + let scale := selectedLayerSamplerScale (G := G × X) B U b R σ hR hσ L₀ + let sides := layerSamplerSides (G := G × X) B U b R scale.value + let sites := layerSamplerIntegerBox B U b scale + let F := PrincipalTupleIndex B (layerSamplerDegree I n) + let a := kernelAnchorScale G X F + let η := kernelNoiseScale G X F + let spatialSides := fun k => (sides k : ℝ) + let anchor := kernelSpatialAnchor N spatialSides a + let W := kernelSpatialWidths N spatialSides η τ + let hW := kernelSpatialWidths_pos N (fun i => Nat.lt_of_lt_of_le (by decide : 0 < 4) (_hN i)) + spatialSides (fun k => by + dsimp only [spatialSides, sides] + exact_mod_cast layerSamplerSides_pos B U b R scale.positive k) + (kernelSpatial_scales G X F).2.1 _hτ + let center := coefficientConstantCenter U x + let D := translatedSelectedPhysicalDensity (G := G × X) B U b hb o R σ hR hσ L₀ center p hm + let Z := selectedResidueDensityMass stride T W (fun z => D (anchor + z)) + L₀ ≤ scale.value ∧ (scale.value : ℝ) ≤ Real.exp (selectedFourierInputBudget m P) ∧ + (∀ k, 0 < sides k ∧ sides k ≤ scale.value) ∧ + (∃ k, sides k = scale.value) ∧ sites.Nonempty ∧ + ∃ hZ : 0 < ∑' z, selectedResidueSmoothWeight stride T W z, + ∃ hD : 0 < Z, + let law := translatedSelectedResidueDensityPMF anchor stride T W hW hZ D + (translatedSelectedPhysicalDensity_nonneg B U b hb o R σ hR hσ L₀ center p hm) hD + |Z-1| ≤ 3*δ ∧ 1/2 ≤ Z ∧ Z ≤ 3/2 ∧ + (∀ z, 0 < (law z).toReal → + z - anchor ∈ rectangularWeightIndices 0 W 1 ∧ + columnResiduePattern stride (z - anchor) ∈ T ∧ 0 < D z) ∧ + (∃ c : ∀ j, U j, center = -(QuotientAddGroup.mk' (coefficientIntegerLattice U) + (constantCoefficientArray U (fun s => c s.1))) ∧ + ∀ z, 0 < (law z).toReal → + HasQuarterAffinePolynomialLifts p (fun j => (c j).val) (fun k v => (z (k,v) : ℝ)) + (layerSamplerBox B U b (selectedLayerSamplerScale B U b R σ hR hσ L₀))) ∧ + (∑' z, (law z).toReal * + noninjectivityIndicator (fun q : sites => integerPhysicalSite q.val z)) ≤ δ ∧ + (∀ z, 0 < (law z).toReal → + (∀ g, (matrixSupCLM (normalizedKernelBlock N spatialSides z g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N spatialSides z g)).inverse‖ ≤ + 32 * ((Fintype.card (LayerSamplerVariables (G × X) I n B) : ℝ) + 1)) ∧ + (∀ root : LayerSamplerVariables (G × X) I n B → ℤ, + (∀ k, |(root k : ℝ)| ≤ spatialSides k) → integerPhysicalSite root z ∈ integerBox N) ∧ + (∀ root : LayerSamplerVariables (G × X) I n B → ℤ, + (∀ k, |(root k : ℝ)| ≤ spatialSides k) → ∀ i, + |∑ f : F, (root (.inr f) : ℝ) * (z (some (.inr f), i) : ℝ)| ≤ τ * (N i : ℝ) / 16)) := by + obtain ⟨a₀, _, hgeometry⟩ := exists_centered_full_parameter_anchored_geometry m + obtain ⟨A, hA, hthreshold⟩ := exists_kernelSamplerThreshold m a₀ + refine ⟨A, hA, ?_⟩ + intro X G _ _ _ _ _ I _ n B _ J _ U b hb o _ _ _ _ μ _ _ ν _ _ + R σ hR hσ hσ1 C V hC hV Cinv hCinv hchart hsmall L₀ P δ hP hδ hδsmall hδP + hX hK hI hn hJ hAP hL₀P hCP hVP hRP hσP τ hτ hτ1 hτP x p hp hm stride hs Rrank S + hS hSP hstride N hN hsize hrank hRrank T hT + let scale := selectedLayerSamplerScale (G := G × X) B U b R σ hR hσ L₀ + let sides := layerSamplerSides (G := G × X) B U b R scale.value + let spatialSides := fun k => (sides k : ℝ) + let F := PrincipalTupleIndex B (layerSamplerDegree I n) + let a := kernelAnchorScale G X F + let η := kernelNoiseScale G X F + let anchor := kernelSpatialAnchor N spatialSides a + let W := kernelSpatialWidths N spatialSides η τ + have hpositive (i) : 0 < N i := by have := hN i; omega + have hsidepos (k) : 0 < spatialSides k := by + dsimp only [spatialSides, sides] + exact_mod_cast layerSamplerSides_pos B U b R scale.positive k + have hLpos : (0 : ℝ) < scale.value := by exact_mod_cast scale.positive + have hL1 : (1 : ℝ) ≤ scale.value := by exact_mod_cast scale.positive + have hsidele (k) : spatialSides k ≤ (scale.value : ℝ) := by + dsimp only [spatialSides, sides] + exact_mod_cast layerSamplerSides_le B U b R scale.positive k + have hscales := kernelSpatial_scales G X F + have hW := kernelSpatialWidths_pos N hpositive spatialSides hsidepos hscales.2.1 hτ + let Q := selectedFourierInputBudget m P + let P' := kernelSamplerBudget m P + have hP' : 0 ≤ P' := kernelSamplerBudget_nonneg m hP + have hPP' : P ≤ P' := le_kernelSamplerBudget m hP + have heP : Real.exp P ≤ Real.exp P' := Real.exp_le_exp.mpr hPP' + have hL : (scale.value : ℝ) ≤ Real.exp Q := + selectedLayerSamplerScale_input_bound B U b R σ hR hσ L₀ hP hK hn hRP hσP hAP hL₀P + let ρ := τ * η / (scale.value : ℝ) + have hρ := kernelSpatial_relative_width_budget hK hX hτ hτP hLpos hL + have hwidth (z) : ρ * (N z.2 : ℝ) ≤ W z := + kernelSpatialWidths_lower_bound N spatialSides hsidepos hL1 hsidele + hscales.2.1.le hscales.2.2.1 hτ.le hτ1 z + have hNlarge (i) : Real.exp (Q + 2 * P + 64) ≤ (N i : ℝ) := by + have hb : Q + 2 * P + 64 ≤ P' := by dsimp [P', kernelSamplerBudget, Q]; linarith + exact (Real.exp_le_exp.mpr hb).trans ((hthreshold P hP).1.trans (hsize i)) + have hround := kernelSpatial_rounding_scale hK hX hLpos hL N hNlarge spatialSides hsidepos hsidele + have hresult := hgeometry B U b hb o μ ν R σ hR hσ hσ1 C V hC hV Cinv hCinv hchart hsmall L₀ + hP' hδ hδsmall (hδP.trans heP) (hX.trans hPP') (hK.trans hPP') + (fun j => (hI j).trans hPP') (fun j => (hn j).trans hPP') (fun j => (hJ j).trans hPP') + (hAP.trans heP) (hL₀P.trans heP) (fun j => (hCP j).trans heP) (fun j => (hVP j).trans heP) + (fun j => (hRP j).trans heP) (fun j => (hσP j).trans heP) + x anchor p hp hm stride hs hS (hSP.trans heP) hstride hρ.1 hρ.2 (fun i => (N i : ℝ)) + (fun i => (hthreshold P hP).2.trans (hsize i)) hrank ((hthreshold P hP).2.trans hRrank) + T hT W hW hwidth + obtain ⟨hL₀, _, hsides, hmax, hsites, hZ, hD, hclose, hlower, hupper, + hsupport, hlifts, hcollision⟩ := hresult + refine ⟨hL₀, hL, hsides, hmax, hsites, hZ, hD, hclose, hlower, hupper, + hsupport, hlifts, hcollision, ?_⟩ + intro z hz + exact canonicalKernelSpatial_support N hN spatialSides hsidepos hτ hτ1 hround stride T hZ + (translatedSelectedPhysicalDensity (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U x) p hm) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U x) p hm) hD z hz + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelJetAllowances.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelJetAllowances.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0b8156e64dc20a7a365fc4551ad257c2118e757 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelJetAllowances.lean @@ -0,0 +1,48 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def kernelJetInterpolationAllowance (q h : ℕ) (κ : ℝ) : ℝ := + (1 + (q : ℝ) * (2 * (q.factorial / κ))) ^ h + +def kernelJetEntryAllowance (q h : ℕ) : ℝ := 2 ^ q * ((q : ℝ) + 1) ^ h + +noncomputable def kernelJetMinorThreshold (q n j h : ℕ) (κ : ℝ) : ℝ := + 1 / (((n : ℝ) + 1) ^ h * kernelJetInterpolationAllowance q h κ) ^ j + +noncomputable def kernelJetInverseAllowance (q n j h : ℕ) (κ : ℝ) : ℝ := + (j : ℝ) * ((j.factorial * (kernelJetEntryAllowance q h) ^ (j - 1)) / + kernelJetMinorThreshold q n j h κ) + +theorem kernelJetInterpolationAllowance_pos (q h : ℕ) {κ : ℝ} (hκ : 0 < κ) : + 0 < kernelJetInterpolationAllowance q h κ := by + unfold kernelJetInterpolationAllowance + positivity + +theorem kernelJetEntryAllowance_pos (q h : ℕ) : 0 < kernelJetEntryAllowance q h := by + unfold kernelJetEntryAllowance + positivity + +theorem kernelJetMinorThreshold_pos (q n j h : ℕ) {κ : ℝ} (hκ : 0 < κ) : + 0 < kernelJetMinorThreshold q n j h κ := by + have := kernelJetInterpolationAllowance_pos q h hκ + unfold kernelJetMinorThreshold + positivity + +theorem kernelJetInverseAllowance_nonneg (q n j h : ℕ) {κ : ℝ} (hκ : 0 < κ) : + 0 ≤ kernelJetInverseAllowance q n j h κ := by + have := kernelJetEntryAllowance_pos q h + have := kernelJetMinorThreshold_pos q n j h hκ + unfold kernelJetInverseAllowance + positivity + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelJetExtendedControl.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelJetExtendedControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff5ba309560c60b40638a1e4b0b4f061da9d075b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelJetExtendedControl.lean @@ -0,0 +1,81 @@ +import OAI.Combinatorics.Progressions.Estimates.CoefficientRowReindex + +namespace OAI + +section + +namespace Erdos3 + +theorem scalarKernelJet_normalized_entry {I J O : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype O] [DecidableEq O] + {L : ℕ} (hL : 0 < L) (x : J → IntegerScalarCubeBox I L) + (h : ℕ) (rows : O → Finset I) {H : ℝ} (hH : H ≠ 0) + (o : O) (e : BoundedIntegerExponent J h) : + |normalizedIntegerColumns (scalarKernelIntegerJet x h rows) + (kernelJetCoefficientScale J h L H) (fun _ => H) o e| ≤ + kernelJetEntryAllowance (Fintype.card I) h := by + have hc (j : J) (i : Option I) : |(x j i : ℝ) / L| ≤ 1 := + (norm_le_pi_norm (fun i => (x j i : ℝ) / L) i).trans + (integerScalarCubeBox_normalized_norm_le hL (x j)) + have he := congrFun (congrFun (normalizedScalarKernelJet_eq x h rows hH) o) e + change |normalizedIntegerColumns (scalarKernelIntegerJet x h rows) + (fun e => H / monomialScale (fun _ => (L : ℝ)) e.val) (fun _ => H) o e| ≤ _ + rw [he] + exact boundedDegreeRealJetMatrix_entry_bound _ _ (fun j => hc j none) + (fun i j => hc j (some i)) h rows o e + +theorem scalarKernelJet_integer_entry {I J O : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype O] [DecidableEq O] + {L : ℕ} (hL : 0 < L) (x : J → IntegerScalarCubeBox I L) + (h : ℕ) (rows : O → Finset I) (o : O) (e : BoundedIntegerExponent J h) : + |(scalarKernelIntegerJet x h rows o e : ℝ)| ≤ + kernelJetEntryAllowance (Fintype.card I) h * (L : ℝ) ^ h := by + have hLr : (0 : ℝ) < L := by exact_mod_cast hL + have hc (j : J) (i : Option I) : |(x j i : ℝ) / L| ≤ 1 := + (norm_le_pi_norm (fun i => (x j i : ℝ) / L) i).trans + (integerScalarCubeBox_normalized_norm_le hL (x j)) + exact boundedDegreeIntegerJetMatrix_entry_bound _ _ (fun _ => (L : ℝ)) + (fun _ => hLr) (by exact_mod_cast hL) (fun _ => le_rfl) + (fun j => hc j none) (fun i j => hc j (some i)) h rows o e + +theorem goodScalarKernelTuple_extended_control {I J O N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] [Fintype N] [DecidableEq N] + {L B : ℕ} {κ : ℝ} (hL : 0 < L) (selection : I → J) (hκ : 0 < κ) + (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple selection κ B x) + (h : ℕ) (rows : O → Finset I) (hr : Function.Injective rows) (hrows : ∀ o, (rows o).card ≤ h) : + ∃ s : O ↪ BoundedIntegerExponent J h, ∀ (H : ℝ), 0 < H → + ∀ (C : Matrix O N ℤ) (T : N → ℝ), + (∀ n, H / (L : ℝ) ^ h ≤ T n) → + (∀ o n, |normalizedIntegerColumns C T (fun _ => H) o n| ≤ kernelJetEntryAllowance (Fintype.card I) h) → + CoefficientFiberControl (Matrix.fromCols (scalarKernelIntegerJet x h rows) C) + (s.trans Function.Embedding.inl) (Sum.elim (kernelJetCoefficientScale J h L H) T) + H L h (kernelJetEntryAllowance (Fintype.card I) h) + (kernelJetInverseAllowance (Fintype.card I) (Fintype.card J) (Fintype.card O) h κ) + (((B ^ h) ^ Fintype.card O : ℕ) : ℝ) := by + obtain ⟨s, hd, hn⟩ := goodScalarKernelTuple_fixed_jet_pivot hL selection hκ x hx h rows hr hrows + refine ⟨s, fun H hH C T hscale hentry => ?_⟩ + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ + · rwa [fromCols_left_pivot] + · intro j + cases j with + | inl e => exact kernelJetCoefficientScale_lower J h (by exact_mod_cast hL) hH.le e + | inr n => exact hscale n + · intro o j + exact scalarKernelJet_integer_entry hL x h rows o (s j) + · intro o j + rw [normalizedIntegerColumns_fromCols] + cases j with + | inl e => + simpa only [Matrix.fromCols_apply_inl, normalizedIntegerColumns_entry_div] using + scalarKernelJet_normalized_entry hL x h rows hH.ne' o e + | inr n => exact hentry o n + · rw [fromCols_left_pivot] + exact hn H hH.ne' + · exact_mod_cast scalarKernelJet_extended_index selection x hx h rows hr hrows C + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelJetSupportIdentity.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelJetSupportIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..366f42b12371e4c0a12dad0107d28ee5bbda2df3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelJetSupportIdentity.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Lattices.IntegerNormalizedJetColumns + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem realJetMatrix_monomial_congr_support {α K I J : Type*} [DecidableEq α] + (e : J → K →₀ ℕ) (v u : Finset α → K → ℝ) (rows : I → Finset α) + (he : ∀ j t k, k ∈ (e j).support → v t k = u t k) : + realJetMatrix (fun j => MvPolynomial.monomial (e j) 1) v rows = + realJetMatrix (fun j => MvPolynomial.monomial (e j) 1) u rows := by + funext i j + apply congrArg (fun f => booleanCoefficient f (rows i)) + funext t + simp only [MvPolynomial.eval_monomial, one_mul, Finsupp.prod] + exact Finset.prod_congr rfl (fun k hk => congrArg (fun a => a^e j k) (he j t k hk)) + +theorem normalizedIntegerKernelJetMatrix_eq_support {α K I J : Type*} [DecidableEq α] + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (e : J → K →₀ ℕ) (v : Finset α → K → ℤ) (u : Finset α → K → ℝ) + (rows : I → Finset α) (T : K → ℝ) {H : ℝ} (hH : H ≠ 0) + (he : ∀ j t k, k ∈ (e j).support → (v t k : ℝ)/T k = u t k) : + normalizedIntegerColumns (integerJetMatrix (fun j => MvPolynomial.monomial (e j) 1) v rows) + (fun j => H/monomialScale T (e j)) (fun _ => H) = + realJetMatrix (fun j => MvPolynomial.monomial (e j) 1) u rows := by + rw [normalizedIntegerMonomialJetMatrix_eq e v rows T hH] + exact realJetMatrix_monomial_congr_support e _ u rows he + +theorem normalizedCubeTuple_eq_of_frozen {Z X K α : Type*} [Fintype α] [DecidableEq α] + (input : K → Option α → Z ⊕ X) (z : Z → ℝ) (x y : X → ℝ) (k : K) + (hk : ∀ r, ∃ j, input k r = Sum.inl j) (t : Finset α) : + normalizedCubeTuple input z x t k = normalizedCubeTuple input z y t k := by + unfold normalizedCubeTuple + apply Finset.sum_congr rfl + intro r _ + obtain ⟨j, hj⟩ := hk r + simp only [hj, Sum.elim_inl] + +theorem kernelJetMatrix_ignore_active {Z X K α I J : Type*} [Fintype α] [DecidableEq α] + (e : J → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : I → Finset α) (x y : X → ℝ) + (he : ∀ j k, k ∈ (e j).support → ∀ r, ∃ a, input k r = Sum.inl a) : + realJetMatrix (fun j => MvPolynomial.monomial (e j) 1) (normalizedCubeTuple input z x) rows = + realJetMatrix (fun j => MvPolynomial.monomial (e j) 1) (normalizedCubeTuple input z y) rows := + realJetMatrix_monomial_congr_support e _ _ rows + (fun j t k hk => normalizedCubeTuple_eq_of_frozen input z x y k (he j k hk) t) + +theorem normalized_frozenKernelJetMatrix {Z X K α I J : Type*} [Fintype α] [DecidableEq α] + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (e : J → K →₀ ℕ) (input : K → Option α → Z ⊕ X) (z : Z → ℝ) + (rows : I → Finset α) (v : Finset α → K → ℤ) (T : K → ℝ) {H : ℝ} (hH : H ≠ 0) + (hcoords : ∀ j t k, k ∈ (e j).support → (v t k : ℝ)/T k = normalizedCubeTuple input z 0 t k) + (hfrozen : ∀ j k, k ∈ (e j).support → ∀ r, ∃ a, input k r = Sum.inl a) (x : X → ℝ) : + normalizedIntegerColumns (integerJetMatrix (fun j => MvPolynomial.monomial (e j) 1) v rows) + (fun j => H/monomialScale T (e j)) (fun _ => H) = + realJetMatrix (fun j => MvPolynomial.monomial (e j) 1) (normalizedCubeTuple input z x) rows := + (normalizedIntegerKernelJetMatrix_eq_support e v _ rows T hH hcoords).trans + (kernelJetMatrix_ignore_active e input z rows 0 x hfrozen) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelJointPrescribedError.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelJointPrescribedError.lean new file mode 100644 index 0000000000000000000000000000000000000000..752159b8e4c8553fc34c2d1752b1f0f2449069dc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelJointPrescribedError.lean @@ -0,0 +1,357 @@ +import OAI.Combinatorics.Progressions.Sampling.QuantitativeKernelJointGrid + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem kernel_joint_grid_tolerance {Q Z K D α Ax Jx Nx : Type*} + [Fintype Q] [DecidableEq Q] [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] [Fintype Ax] + [Fintype Jx] [DecidableEq Jx] [Fintype Nx] [DecidableEq Nx] + {I N : Q → Type*} [∀ q, Fintype (I q)] [∀ q, DecidableEq (I q)] + [∀ q, Fintype (N q)] [∀ q, DecidableEq (N q)] + (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] (h : D → ℕ) + {ℓx Mx : ℕ} (hℓx : 0 < ℓx) (hMx : 0 < Mx) (sx : α ↪ Jx) + (x : Jx → IntegerScalarCubeBox α ℓx) (hx : GoodScalarKernelTuple sx (1/(Mx : ℝ)) Mx x) + (smax : ℕ) (hsmax : 1 ≤ smax) (degree : Q → ℕ) (hdegree : ∀ q, degree q ≤ smax) + (rows : ∀ q, I q → Finset α) (hinj : ∀ q, Function.Injective (rows q)) + (hrows : ∀ q i, (rows q i).card ≤ degree q) (δ R : Q → ℝ≥0) + (p : ℝ) (hp : 0 ≤ p) (hMxp : (Mx : ℝ) ≤ Real.exp p) + (hδ : ∀ q, 0 < δ q) (hRp : ∀ q, (R q : ℝ) ≤ Real.exp p) + (hδp : ∀ q, (δ q : ℝ)⁻¹ ≤ Real.exp p) + (η : ℝ) (hη : 0 < η) (hη1 : η ≤ 1) : + ∃ (m : ℕ) (hm : 0 < m), m ≤ Mx^smax ∧ + letI : NeZero m := ⟨hm.ne'⟩ + ∃ s : ∀ q, I q ↪ BoundedIntegerExponent Jx (degree q), + ∃ hA : ∀ q, ((scalarKernelIntegerJet x (degree q) (rows q)).submatrix id (s q)).det ≠ 0, + let Cap : ℝ≥0 := ⟨Real.exp (kernelFamilyOutputLog (α := α) (J := Jx) I N degree p), (Real.exp_pos _).le⟩ + let Lip := Cap + let Ro := Cap + let G := Real.exp (kernelFamilyIndexLog I smax p) + let b := fun q => kernelCoefficientLog (Fintype.card α) (Fintype.card Jx) (Fintype.card (I q)) + (Fintype.card (BoundedIntegerExponent Jx (degree q))) (degree q) p (kernelFamilyIndexLog I smax p) + let t := fun _ : Q => p + let K₀ := 2*scalarCubeGridBoundaryConstant α/volume.real (scalarCubeDomain α) + + Real.exp (kernelFamilyTupleLog (P := JointBlockParameter B h α) (α := α) (J := Jx) I N degree p) + let KO : ℝ≥0 := Fintype.card Q * Lip * Cap^Fintype.card Q + let DO := (2*(Ro : ℝ)+2)^Fintype.card (Σ q, I q) * ((KO : ℝ)+KO) + let ε := coefficientRowAccuracy (Fintype.card Q) η + let mesh := outputGridAccuracy (G^Fintype.card Q) DO (η/2) + let Lmin := scalarTupleToleranceCutoff α (PrincipalTupleIndex B h) (Mx^smax) K₀ + (mixedCoefficientAccuracy (G^Fintype.card Q) (η/2)) + ∀ (H : Q → ℝ) (hH : ∀ q, 0 < H q) (hH1 : ∀ q, 1 ≤ H q) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ JointBlockParameter B h α) + (zi : Z → ℤ) (zr : Z → ℝ) (hz : ∀ j, |zr j| ≤ 1) + (T : K → ℝ) (hT : ∀ k, 0 < T k) (hTℓ : ∀ k, T k ≤ (ℓx : ℝ)) + (hd : ∀ q n, (e q n).sum (fun _ k => k) ≤ degree q) + (c w : ∀ q, BoundedIntegerExponent Jx (degree q) ⊕ N q → ℝ) + (hw : ∀ q j, 0 < w q j) + (hwidth : ∀ q j, (δ q : ℝ) ≤ w q j) (hsupport : ∀ q j, |c q j| + w q j ≤ R q) + (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) + (hLlarge : ∀ j, Lmin ≤ L j) + (hn : ∀ (y : PrincipalIntegerTuples B h α L) k a, + ((Sum.elim zi (principalTupleIntegers y) (input k a) : ℤ) : ℝ)/T k = + Sum.elim zr (principalTupleNormalized L y) (input k a)) + (hHlarge : ∀ q, coefficientToleranceScale + (J := BoundedIntegerExponent Jx (degree q) ⊕ N q) ((s q).trans Function.Embedding.inl) + (b q) (t q) ε ℓx mesh (degree q) ≤ H q) + (grid : Finset ((Σ q, I q) → ℤ)) + (rhoX xiX rX : ℝ) (root : Jx → ℤ) (hroot : ∀ j, |root j| ≤ (ℓx : ℤ)) + (cX : Ax → Nx → ℤ) (indexX : Ax → Nx → PrincipalTupleIndex B h) + (HX : Ax → ℝ) (QX : Ax → Nx → ℝ) (hHX : ∀ a, 0 < HX a) (hQX : ∀ a n, 0 < QX a n) + (hxi0 : 0 ≤ xiX) (hxi1 : xiX ≤ 1) + (hwidthX : ∀ a n, ((|cX a n| : ℤ)+(L (indexX a n) : ℤ) : ℝ)*QX a n ≤ xiX*HX a) + (hrho : 0 < rhoX) (hscaleX : ∀ a, rhoX ≤ HX a/ℓx) (hscaleQX : ∀ a n, rhoX ≤ QX a n) + (hlargeX : smoothSpatialMeshThreshold α Jx Nx ℓx ≤ rhoX) (hrX : 0 < rX) + (spatialGrid : Finset (Ax → (Unit ⊕ α) → ℤ)) + (hbox : ∀ v ∈ spatialGrid, ∀ a i, |((spatialStar (v a) i : ℤ) : ℝ)/HX a| ≤ 1) + (φ : (Ax → (Unit ⊕ α) → ℤ) → ((Σ q, I q) → ℤ) → ℂ) + (hφ : ∀ v ∈ spatialGrid, ∀ z ∈ grid, ‖φ v z‖ ≤ 1), + let A := fun q => scalarKernelIntegerJet x (degree q) (rows q) + let S := fun q => kernelJetCoefficientScale Jx (degree q) ℓx (H q) + let hS := fun q j => kernelJetCoefficientScale_pos Jx (degree q) (by exact_mod_cast hℓx) (hH q) j + let E := fun q => normalizedPivotEquiv ((A q).submatrix id (s q)) (hA q) + (fun i => S q (s q i)) (fun _ => H q) (fun i => hS q (s q i)) (fun _ => hH q) + let F := fun q => matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns (A q) (s q)) + (fun j => S q j.val) (fun _ => H q)) + let mask := fun (rr : PrincipalTupleIndex B h → Option α → ZMod m) q => + coefficientResidueMultiplier (A q) + (integerResidueMatrix (integerMappedJetMatrix (e q) input zi (rows q) (principalResidueLift m rr)) m) + let ρ := fun x => jointAffineJetDensity s E F e input zr rows c w x ∘ sigmaAxisCoordinates I + let PX := selectedSpatialPivot root (scalarCubeDifferenceMatrix x) sx + let FX := selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) sx + let hPX := goodScalarKernelTuple_spatial_det_ne_zero sx x root + (one_div_pos.mpr (by exact_mod_cast hMx)) hx + let fX := fun a => smoothSpatialKernelDensity sx root (scalarCubeDifferenceMatrix x) hPX + (HX a) ℓx (hHX a) (by exact_mod_cast hℓx) + let GX := (m : ℝ)^Fintype.card (Unit ⊕ α) + let EX := smoothSpatialError Nx sx Mx ℓx rhoX xiX + let spatialScale := ∏ a, ∏ _i : Unit ⊕ α, HX a + let spatialError := Fintype.card Ax * (EX + 4 * GX * smoothSpatialDensityLip sx Mx * rX) * + (1 + GX * smoothSpatialDensityCap sx Mx + EX)^Fintype.card Ax + let Δ := spatialError / spatialScale * spatialGrid.card + let site := fun rr v => ∏ a, spatialSiteApprox PX + (Matrix.fromCols FX (liftResidueMatrix (principalSpatialResidueColumns m (cX a) (indexX a) rr))) + m (fX a) (HX a) 1 rX (v a) + let source := principalTupleWeights (α := α) B h L hL + let residues := source.fiberLaw (principalResidueLabel m) + ∃ hZ : ∀ q, 0 < coefficientWeightSum (affineProductProfile (c q) (w q)) + (Sum.elim (S q) (fun n => H q/monomialScale T (e q n))), + ‖source.complexMean (fun y => ∑ v ∈ spatialGrid, + ((smoothVectorSpatialOutputLaw root (scalarCubeDifferenceMatrix x) + (fun a => principalSpatialColumns (cX a) (indexX a) y) HX ℓx QX hHX + (by exact_mod_cast hℓx) hQX v).toReal : ℂ) * + (∑ z ∈ grid, ((∏ q, + (coefficientImagePMF + (Matrix.fromCols (A q) (integerMappedJetMatrix (e q) input zi (rows q) (principalTupleIntegers y))) + (affineProductProfile (c q) (w q)) (affineProductProfile_nonneg (c q) (w q) (hw q)) + (Sum.elim (S q) (fun n => H q/monomialScale T (e q n))) + (Sum.rec (hS q) (fun n => div_pos (hH q) (monomialScale_pos T hT (e q n)))) + (affineProductProfile_zero_outside (c q) (w q) (hw q) (R q).coe_nonneg (hsupport q)) + (hZ q) (fun i => z ⟨q, i⟩)).toReal : ℝ) : ℂ) * φ v z)) - + residues.complexMean (fun rr => ∑ v ∈ spatialGrid, (site rr v / (spatialScale : ℂ)) * + gridDensityTest (densityMixture (jointBooleanSource h) ρ) + 0 (fun j => H j.1) grid (fun z => ∏ q, mask rr q (fun i => z ⟨q, i⟩)) (φ v))‖ ≤ + Δ + (1 + Δ) * η := by + have hκ : 0 < 1/(Mx : ℝ) := one_div_pos.mpr (by exact_mod_cast hMx) + obtain ⟨m, hm, hmB, hpX, hperiod⟩ := goodKernel_common_period sx x hx smax hsmax degree hdegree rows hinj hrows + obtain ⟨s, hA, hinv⟩ := goodKernel_fixed_pivots hℓx sx hκ x hx degree rows hinj hrows + refine ⟨m, hm, hmB, ?_⟩ + let : NeZero m := ⟨hm.ne'⟩ + refine ⟨s, hA, ?_⟩ + dsimp only + intro H hH hH1 e input zi zr hz T hT hTℓ hd c w hw hwidth hsupport + L hL hLlarge hn hHlarge + grid rhoX xiX rX root hroot cX indexX HX QX hHX hQX hxi0 hxi1 hwidthX hrho hscaleX hscaleQX + hlargeX hrX spatialGrid hbox φ hφ + let g := kernelFamilyIndexLog I smax p + let G := Real.exp g + let b := fun q => kernelCoefficientLog (Fintype.card α) (Fintype.card Jx) (Fintype.card (I q)) + (Fintype.card (BoundedIntegerExponent Jx (degree q))) (degree q) p g + let Cap : ℝ≥0 := ⟨Real.exp (kernelFamilyOutputLog (α := α) (J := Jx) I N degree p), (Real.exp_pos _).le⟩ + have hg : 0 ≤ g := kernelFamilyIndexLog_nonneg I smax hp + have hcost (q) := kernelCoefficientLog_bounds (Fintype.card α) (Fintype.card Jx) (Fintype.card (I q)) + (Fintype.card (BoundedIntegerExponent Jx (degree q))) (degree q) hMx hp hg hMxp + have hIndex (q) : (((Mx^degree q)^Fintype.card (I q) : ℕ) : ℝ) ≤ G := + kernelFamilyIndexLog_row I smax degree hdegree hp hMxp q + have hcontrol (q) (y : PrincipalIntegerTuples B h α L) := + fixedKernel_mapped_control hℓx sx x hx (degree q) (rows q) (hinj q) (hrows q) (s q) (hA q) + (hinv q) (hH q) (e q) input zi (principalTupleIntegers y) T hT hTℓ (hd q) + (mappedPrincipal_normalized_bound B h L hL input zi zr hz T y (hn y)) (hIndex q) + obtain ⟨hCap, hcap, hlip, hRo⟩ := fixedKernel_family_output_bound (N := N) + hℓx hMx x degree rows s hA hinv δ R hδ hp hMxp hRp hδp H hH + let K₀ := 2*scalarCubeGridBoundaryConstant α/volume.real (scalarCubeDomain α) + + Real.exp (kernelFamilyTupleLog (P := JointBlockParameter B h α) (α := α) (J := Jx) I N degree p) + let KO : ℝ≥0 := Fintype.card Q * Cap * Cap^Fintype.card Q + let DO := (2*(Cap : ℝ)+2)^Fintype.card (Σ q, I q) * ((KO : ℝ)+KO) + let ε := coefficientRowAccuracy (Fintype.card Q) η + let mesh := outputGridAccuracy (G^Fintype.card Q) DO (η/2) + have hε : 0 < ε := coefficientRowAccuracy_pos _ hη + have hεsum : (∑ _q : Q, ε) ≤ 1 := by + have hh := coefficientRowAccuracy_sum Q hη.le + change 2 * (∑ _q : Q, ε) ≤ η/2 at hh + linarith + have hG0 : 0 ≤ G^Fintype.card Q := by positivity + have hDO : 0 ≤ DO := by dsimp only [DO]; positivity + have hmesh0 : 0 < mesh := outputGridAccuracy_pos hG0 hDO (half_pos hη) + have hmesh1 : mesh ≤ 1 := (outputGridAccuracy_le hG0 hDO (half_pos hη).le).trans (by linarith) + have hK₀ : 0 ≤ K₀ := by + have hB := (scalarCubeGridBoundaryConstant_pos α).le + have hV := (scalarCubeDomain_volumeReal_pos α).le + dsimp only [K₀] + positivity + have hmodulus := scalarTupleToleranceCutoff_mono_modulus α (PrincipalTupleIndex B h) + hmB hK₀ (mixedCoefficientAccuracy_pos hG0 (half_pos hη)).le + have htuple := scalarTupleToleranceCutoff_spec α (PrincipalTupleIndex B h) + (mixedCoefficientAccuracy_pos hG0 (half_pos hη)) (fun j => hmodulus.trans (hLlarge j)) + have hsize := htuple.2.1 + have hsmall := htuple.2.2.1 + have hHspec (q) := coefficientToleranceScale_spec + (J := BoundedIntegerExponent Jx (degree q) ⊕ N q) ((s q).trans Function.Embedding.inl) + (degree q) (hcost q).1 (kernelJetEntryAllowance_pos (Fintype.card α) (degree q)).le + (R q).coe_nonneg hε (show (0 : ℝ) ≤ ℓx by positivity) (hcost q).2.2.2.1 + ((hRp q).trans (hcost q).2.2.2.2) hmesh0 (hHlarge q) + have hKT := fixedKernel_family_tuple_bound (P := JointBlockParameter B h α) (N := N) + hℓx hMx x degree rows s hA hinv δ R hp hMxp hRp hδp H hH + have herr := coefficientComparisonError_le Q (PrincipalTupleIndex B h) + hη hG0 hDO (add_le_add le_rfl hKT) htuple.2.2.2 (le_refl mesh) + obtain ⟨hZ, he⟩ := principalJoint_spatial_grid_comparison B h + (fun q => scalarKernelIntegerJet x (degree q) (rows q)) s hA + (fun q => kernelJetCoefficientScale Jx (degree q) ℓx (H q)) + (fun q j => kernelJetCoefficientScale_pos Jx (degree q) (by exact_mod_cast hℓx) (hH q) j) + H (fun _ => (ℓx : ℝ)) + (fun q => kernelJetEntryAllowance (Fintype.card α) (degree q)) + (fun q => kernelJetInverseAllowance (Fintype.card α) (Fintype.card Jx) + (Fintype.card (I q)) (degree q) (1/(Mx : ℝ))) + G hH hH1 (fun _ => by exact_mod_cast hℓx) + (fun q => (kernelJetEntryAllowance_pos _ _).le) + (fun q => kernelJetInverseAllowance_nonneg _ _ _ _ hκ) (Real.exp_pos _).le + e input zi zr hz T hT rows degree hd c w hw δ R hδ hwidth hsupport + L hL m hm hsize hsmall hn (fun q y _ => hcontrol q y) hperiod + b (fun _ => p) (fun _ => ε) (fun q => (hcost q).1) (fun _ => hp) (fun _ => hε) + (fun q => (hcost q).2.1) (fun q => (hcost q).2.2.1) (fun q => (hcost q).2.2.2.1) + (fun q => (hRp q).trans (hcost q).2.2.2.2) hδp (fun q => (hHspec q).2.2.2) hεsum + Cap Cap Cap hCap hmesh0.le hmesh1 (fun q => (hHspec q).2.2.1) + grid sx x root hMx hℓx hx hroot (hpX root) cX indexX HX QX hHX hQX hxi0 hxi1 hwidthX + hrho hscaleX hscaleQX hlargeX hrX spatialGrid hbox φ hφ hcap hlip hRo + + refine ⟨hZ, he.trans ?_⟩ + apply add_le_add le_rfl + apply mul_le_mul_of_nonneg_left + · simpa only [NNReal.coe_sum] using herr + · have hEX := smoothSpatialError_nonneg Nx sx Mx ℓx hrho.le hxi0 + have hCX := smoothSpatialDensityCap_nonneg sx Mx + have hLX := smoothSpatialDensityLip_nonneg sx Mx + have hscale0 : 0 < ∏ a, ∏ _i : Unit ⊕ α, HX a := + Finset.prod_pos (fun a _ => Finset.prod_pos (fun _ _ => hHX a)) + positivity + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal BigOperators + +theorem kernel_joint_prescribed_error {Q Z K D α Ax Jx Nx : Type*} + [Fintype Q] [DecidableEq Q] [Fintype D] [DecidableEq D] + [Fintype α] [DecidableEq α] [Fintype Ax] + [Fintype Jx] [DecidableEq Jx] [Fintype Nx] [DecidableEq Nx] + {I N : Q → Type*} [∀ q, Fintype (I q)] [∀ q, DecidableEq (I q)] + [∀ q, Fintype (N q)] [∀ q, DecidableEq (N q)] + (B : D → Type*) [∀ d, Fintype (B d)] [∀ d, DecidableEq (B d)] (h : D → ℕ) + {ℓx Mx : ℕ} (hℓx : 0 < ℓx) (hMx : 0 < Mx) (sx : α ↪ Jx) + (x : Jx → IntegerScalarCubeBox α ℓx) (hx : GoodScalarKernelTuple sx (1/(Mx : ℝ)) Mx x) + (smax : ℕ) (hsmax : 1 ≤ smax) (degree : Q → ℕ) (hdegree : ∀ q, degree q ≤ smax) + (rows : ∀ q, I q → Finset α) (hinj : ∀ q, Function.Injective (rows q)) + (hrows : ∀ q i, (rows q i).card ≤ degree q) (δ R : Q → ℝ≥0) + (p : ℝ) (hp : 0 ≤ p) (hMxp : (Mx : ℝ) ≤ Real.exp p) + (hδ : ∀ q, 0 < δ q) (hRp : ∀ q, (R q : ℝ) ≤ Real.exp p) + (hδp : ∀ q, (δ q : ℝ)⁻¹ ≤ Real.exp p) + (τ : ℝ) (hτ : 0 < τ) (hτ1 : τ ≤ 1) : + ∃ (m : ℕ) (hm : 0 < m), m ≤ Mx^smax ∧ + letI : NeZero m := ⟨hm.ne'⟩ + ∃ s : ∀ q, I q ↪ BoundedIntegerExponent Jx (degree q), + ∃ hA : ∀ q, ((scalarKernelIntegerJet x (degree q) (rows q)).submatrix id (s q)).det ≠ 0, + let η := τ/4 + let Cap : ℝ≥0 := ⟨Real.exp (kernelFamilyOutputLog (α := α) (J := Jx) I N degree p), (Real.exp_pos _).le⟩ + let Lip := Cap + let Ro := Cap + let G := Real.exp (kernelFamilyIndexLog I smax p) + let b := fun q => kernelCoefficientLog (Fintype.card α) (Fintype.card Jx) (Fintype.card (I q)) + (Fintype.card (BoundedIntegerExponent Jx (degree q))) (degree q) p (kernelFamilyIndexLog I smax p) + let t := fun _ : Q => p + let K₀ := 2*scalarCubeGridBoundaryConstant α/volume.real (scalarCubeDomain α) + + Real.exp (kernelFamilyTupleLog (P := JointBlockParameter B h α) (α := α) (J := Jx) I N degree p) + let KO : ℝ≥0 := Fintype.card Q * Lip * Cap^Fintype.card Q + let DO := (2*(Ro : ℝ)+2)^Fintype.card (Σ q, I q) * ((KO : ℝ)+KO) + let ε := coefficientRowAccuracy (Fintype.card Q) η + let mesh := outputGridAccuracy (G^Fintype.card Q) DO (η/2) + let Lmin := scalarTupleToleranceCutoff α (PrincipalTupleIndex B h) (Mx^smax) K₀ + (mixedCoefficientAccuracy (G^Fintype.card Q) (η/2)) + let rhoX := smoothJointResolution Nx (Fintype.card Ax) sx Mx ℓx smax τ + let xiX := smoothJointWidth Nx (Fintype.card Ax) sx Mx smax τ + let rX := smoothJointRadius (Fintype.card Ax) sx Mx smax τ + ∀ (H : Q → ℝ) (hH : ∀ q, 0 < H q) (hH1 : ∀ q, 1 ≤ H q) + (e : ∀ q, N q → K →₀ ℕ) (input : K → Option α → Z ⊕ JointBlockParameter B h α) + (zi : Z → ℤ) (zr : Z → ℝ) (hz : ∀ j, |zr j| ≤ 1) + (T : K → ℝ) (hT : ∀ k, 0 < T k) (hTℓ : ∀ k, T k ≤ (ℓx : ℝ)) + (hd : ∀ q n, (e q n).sum (fun _ k => k) ≤ degree q) + (c w : ∀ q, BoundedIntegerExponent Jx (degree q) ⊕ N q → ℝ) + (hw : ∀ q j, 0 < w q j) + (hwidth : ∀ q j, (δ q : ℝ) ≤ w q j) (hsupport : ∀ q j, |c q j| + w q j ≤ R q) + (L : PrincipalTupleIndex B h → ℕ) (hL : ∀ j, 0 < L j) + (hLlarge : ∀ j, Lmin ≤ L j) + (hn : ∀ (y : PrincipalIntegerTuples B h α L) k a, + ((Sum.elim zi (principalTupleIntegers y) (input k a) : ℤ) : ℝ)/T k = + Sum.elim zr (principalTupleNormalized L y) (input k a)) + (hHlarge : ∀ q, coefficientToleranceScale + (J := BoundedIntegerExponent Jx (degree q) ⊕ N q) ((s q).trans Function.Embedding.inl) + (b q) (t q) ε ℓx mesh (degree q) ≤ H q) + (grid : Finset ((Σ q, I q) → ℤ)) + (root : Jx → ℤ) (hroot : ∀ j, |root j| ≤ (ℓx : ℤ)) + (cX : Ax → Nx → ℤ) (indexX : Ax → Nx → PrincipalTupleIndex B h) + (HX : Ax → ℝ) (QX : Ax → Nx → ℝ) (hHX : ∀ a, 0 < HX a) (hQX : ∀ a n, 0 < QX a n) + (hHX1 : ∀ a, 1 ≤ HX a) + (hwidthX : ∀ a n, ((|cX a n| : ℤ)+(L (indexX a n) : ℤ) : ℝ)*QX a n ≤ xiX*HX a) + (hscaleX : ∀ a, rhoX ≤ HX a/ℓx) (hscaleQX : ∀ a n, rhoX ≤ QX a n) + (spatialGrid : Finset (Ax → (Unit ⊕ α) → ℤ)) + (hbox : ∀ v ∈ spatialGrid, ∀ a i, |((spatialStar (v a) i : ℤ) : ℝ)/HX a| ≤ 1) + (φ : (Ax → (Unit ⊕ α) → ℤ) → ((Σ q, I q) → ℤ) → ℂ) + (hφ : ∀ v ∈ spatialGrid, ∀ z ∈ grid, ‖φ v z‖ ≤ 1), + let A := fun q => scalarKernelIntegerJet x (degree q) (rows q) + let S := fun q => kernelJetCoefficientScale Jx (degree q) ℓx (H q) + let hS := fun q j => kernelJetCoefficientScale_pos Jx (degree q) (by exact_mod_cast hℓx) (hH q) j + let E := fun q => normalizedPivotEquiv ((A q).submatrix id (s q)) (hA q) + (fun i => S q (s q i)) (fun _ => H q) (fun i => hS q (s q i)) (fun _ => hH q) + let F := fun q => matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns (A q) (s q)) + (fun j => S q j.val) (fun _ => H q)) + let mask := fun (rr : PrincipalTupleIndex B h → Option α → ZMod m) q => + coefficientResidueMultiplier (A q) + (integerResidueMatrix (integerMappedJetMatrix (e q) input zi (rows q) (principalResidueLift m rr)) m) + let ρ := fun x => jointAffineJetDensity s E F e input zr rows c w x ∘ sigmaAxisCoordinates I + let PX := selectedSpatialPivot root (scalarCubeDifferenceMatrix x) sx + let FX := selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) sx + let hPX := goodScalarKernelTuple_spatial_det_ne_zero sx x root + (one_div_pos.mpr (by exact_mod_cast hMx)) hx + let fX := fun a => smoothSpatialKernelDensity sx root (scalarCubeDifferenceMatrix x) hPX + (HX a) ℓx (hHX a) (by exact_mod_cast hℓx) + let spatialScale := ∏ a, ∏ _i : Unit ⊕ α, HX a + let site := fun rr v => ∏ a, spatialSiteApprox PX + (Matrix.fromCols FX (liftResidueMatrix (principalSpatialResidueColumns m (cX a) (indexX a) rr))) + m (fX a) (HX a) 1 rX (v a) + let source := principalTupleWeights (α := α) B h L hL + let residues := source.fiberLaw (principalResidueLabel m) + ∃ hZ : ∀ q, 0 < coefficientWeightSum (affineProductProfile (c q) (w q)) + (Sum.elim (S q) (fun n => H q/monomialScale T (e q n))), + ‖source.complexMean (fun y => ∑ v ∈ spatialGrid, + ((smoothVectorSpatialOutputLaw root (scalarCubeDifferenceMatrix x) + (fun a => principalSpatialColumns (cX a) (indexX a) y) HX ℓx QX hHX + (by exact_mod_cast hℓx) hQX v).toReal : ℂ) * + (∑ z ∈ grid, ((∏ q, + (coefficientImagePMF + (Matrix.fromCols (A q) (integerMappedJetMatrix (e q) input zi (rows q) (principalTupleIntegers y))) + (affineProductProfile (c q) (w q)) (affineProductProfile_nonneg (c q) (w q) (hw q)) + (Sum.elim (S q) (fun n => H q/monomialScale T (e q n))) + (Sum.rec (hS q) (fun n => div_pos (hH q) (monomialScale_pos T hT (e q n)))) + (affineProductProfile_zero_outside (c q) (w q) (hw q) (R q).coe_nonneg (hsupport q)) + (hZ q) (fun i => z ⟨q, i⟩)).toReal : ℝ) : ℂ) * φ v z)) - + residues.complexMean (fun rr => ∑ v ∈ spatialGrid, (site rr v / (spatialScale : ℂ)) * + gridDensityTest (densityMixture (jointBooleanSource h) ρ) + 0 (fun j => H j.1) grid (fun z => ∏ q, mask rr q (fun i => z ⟨q, i⟩)) (φ v))‖ ≤ + τ := by + obtain ⟨m, hm, hmB, hdata⟩ := kernel_joint_grid_tolerance (Z := Z) (K := K) (Ax := Ax) (Nx := Nx) (N := N) B h hℓx hMx sx x hx + smax hsmax degree hdegree rows hinj hrows δ R p hp hMxp hδ hRp hδp + (τ/4) (by positivity) (by linarith) + refine ⟨m, hm, hmB, ?_⟩ + let : NeZero m := ⟨hm.ne'⟩ + obtain ⟨s, hA, hmain⟩ := hdata + refine ⟨s, hA, ?_⟩ + dsimp only + intro H hH hH1 e input zi zr hz T hT hTℓ hd c w hw hwidth hsupport + L hL hLlarge hn hHlarge grid root hroot cX indexX HX QX hHX hQX hHX1 + hwidthX hscaleX hscaleQX spatialGrid hbox φ hφ + let rhoX := smoothJointResolution Nx (Fintype.card Ax) sx Mx ℓx smax τ + let xiX := smoothJointWidth Nx (Fintype.card Ax) sx Mx smax τ + let rX := smoothJointRadius (Fintype.card Ax) sx Mx smax τ + obtain ⟨hrho, hlargeX, hxi, hxi1, hrX, _, herr⟩ := + smoothSpatial_grid_tolerance (N := Nx) sx Mx ℓx smax hτ hτ1 hmB HX hHX1 spatialGrid hbox + obtain ⟨hZ, he⟩ := hmain H hH hH1 e input zi zr hz T hT hTℓ hd c w hw hwidth hsupport + L hL hLlarge hn hHlarge grid rhoX xiX rX root hroot cX indexX HX QX hHX hQX + hxi.le hxi1 hwidthX hrho hscaleX hscaleQX hlargeX hrX spatialGrid hbox φ hφ + exact ⟨hZ, he.trans herr⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelLiftChart.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelLiftChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..2fbd37ceaa4825a0f89623cc1eae3fcdee43b204 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelLiftChart.lean @@ -0,0 +1,70 @@ +import Mathlib.Data.Set.Prod +import Mathlib.GroupTheory.QuotientGroup.Basic + +namespace OAI + +section + +namespace Erdos3 + +variable {G H X : Type*} [AddCommGroup G] [AddCommGroup H] +variable (C : G →+ H) (s : X → G) (q : X → H) + +theorem kernelLiftChart_injOn (hproj : ∀ x, C (s x) = q x) + {S : Set X} (hq : Set.InjOn q S) : + Set.InjOn (fun p : X × C.ker => s p.1 + p.2.val) (S ×ˢ Set.univ) := by + intro x hx y hy he + change s x.1 + x.2.val = s y.1 + y.2.val at he + have hkx : C x.2.val = 0 := x.2.property + have hky : C y.2.val = 0 := y.2.property + have hb : q x.1 = q y.1 := by + have ht := congrArg C he + simpa only [map_add, hproj, hkx, hky, add_zero] using ht + have hxy : x.1 = y.1 := hq hx.1 hy.1 hb + apply Prod.ext hxy + apply Subtype.ext + rw [hxy] at he + exact add_left_cancel he + +theorem kernelLiftChart_image (hproj : ∀ x, C (s x) = q x) (S : Set X) : + (fun p : X × C.ker => s p.1 + p.2.val) '' (S ×ˢ Set.univ) = C ⁻¹' (q '' S) := by + ext y + constructor + · rintro ⟨x, hx, rfl⟩ + refine ⟨x.1, hx.1, ?_⟩ + have hk : C x.2.val = 0 := x.2.property + simp only [map_add, hproj, hk, add_zero] + · rintro ⟨x, hx, hxy⟩ + have hk : y - s x ∈ C.ker := by + change C (y - s x) = 0 + rw [map_sub, hproj, ← hxy, sub_self] + refine ⟨(x, ⟨y - s x, hk⟩), ⟨hx, Set.mem_univ _⟩, ?_⟩ + change s x + (y - s x) = y + rw [← add_sub_assoc, add_sub_cancel_left] + +theorem kernelLiftChart_relabel_injOn {R : Type*} (e : R ≃ C.ker) + (hproj : ∀ x, C (s x) = q x) {S : Set X} (hq : Set.InjOn q S) : + Set.InjOn (fun p : X × R => s p.1 + (e p.2).val) (S ×ˢ Set.univ) := by + intro x hx y hy he + have hp := kernelLiftChart_injOn C s q hproj hq + (show (x.1, e x.2) ∈ S ×ˢ Set.univ from ⟨hx.1, Set.mem_univ _⟩) + (show (y.1, e y.2) ∈ S ×ˢ Set.univ from ⟨hy.1, Set.mem_univ _⟩) he + exact Prod.ext (congrArg (fun z : X × C.ker => z.1) hp) + (e.injective (congrArg (fun z : X × C.ker => z.2) hp)) + +theorem kernelLiftChart_relabel_image {R : Type*} (e : R ≃ C.ker) + (hproj : ∀ x, C (s x) = q x) (S : Set X) : + (fun p : X × R => s p.1 + (e p.2).val) '' (S ×ˢ Set.univ) = C ⁻¹' (q '' S) := by + rw [← kernelLiftChart_image C s q hproj S] + ext y + constructor + · rintro ⟨x, hx, rfl⟩ + exact ⟨(x.1, e x.2), ⟨hx.1, Set.mem_univ _⟩, rfl⟩ + · rintro ⟨x, hx, rfl⟩ + exact ⟨(x.1, e.symm x.2), ⟨hx.1, Set.mem_univ _⟩, by simp only [e.apply_symm_apply]⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelMixtureControl.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelMixtureControl.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7745c8e6e7bee6a3578ea19b64cc76309055eb2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelMixtureControl.lean @@ -0,0 +1,139 @@ +import Mathlib + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +noncomputable def kernelAverage {X T : Type*} [MeasurableSpace T] + (μ : Measure T) (K : X → T → ℝ) (g : T → ℝ) (x : X) : ℝ := ∫ t, K x t * g t ∂μ + +theorem kernelAverage_lipschitz {X T : Type*} [PseudoMetricSpace X] [MeasurableSpace T] + (μ : Measure T) (K : X → T → ℝ) (g : T → ℝ) (C D : ℝ≥0) + (hK : ∀ x, Integrable (K x) μ) (hg : AEStronglyMeasurable g μ) + (hgC : ∀ t, ‖g t‖ ≤ C) + (hmove : ∀ x y, (∫ t, |K x t - K y t| ∂μ) ≤ D * dist x y) : + LipschitzWith (C * D) (kernelAverage μ K g) := by + have hint (x) : Integrable (fun t => K x t * g t) μ := + (hK x).mul_bdd hg (Filter.Eventually.of_forall hgC) + apply LipschitzWith.of_dist_le_mul + intro x y + rw [Real.dist_eq] + change |(∫ t, K x t * g t ∂μ) - ∫ t, K y t * g t ∂μ| ≤ _ + rw [← integral_sub (hint x) (hint y)] + have hd : Integrable (fun t => |K x t - K y t|) μ := by + simpa only [Real.norm_eq_abs, Pi.sub_apply] using ((hK x).sub (hK y)).norm + have hpoint (t) : ‖K x t * g t - K y t * g t‖ ≤ (C : ℝ) * |K x t - K y t| := by + rw [← sub_mul, norm_mul, Real.norm_eq_abs] + simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hgC t) (abs_nonneg (K x t - K y t)) + have h := norm_integral_le_of_norm_le (hd.const_mul (C : ℝ)) (Filter.Eventually.of_forall hpoint) + rw [integral_const_mul] at h + rw [Real.norm_eq_abs] at h + apply h.trans + have hbound := mul_le_mul_of_nonneg_left (hmove x y) C.coe_nonneg + simpa only [NNReal.coe_mul, mul_assoc] using hbound + +theorem kernelAverage_nonneg {X T : Type*} [MeasurableSpace T] + (μ : Measure T) (K : X → T → ℝ) (g : T → ℝ) + (hK : ∀ x t, 0 ≤ K x t) (hg : ∀ t, 0 ≤ g t) (x : X) : + 0 ≤ kernelAverage μ K g x := integral_nonneg (fun t => mul_nonneg (hK x t) (hg t)) + +theorem kernelAverage_cap {X T : Type*} [MeasurableSpace T] + (μ : Measure T) (K : X → T → ℝ) (g : T → ℝ) {C : ℝ} + (hK : ∀ x, Integrable (K x) μ) (hK0 : ∀ x t, 0 ≤ K x t) + (hmass : ∀ x, (∫ t, K x t ∂μ) = 1) (hg : AEStronglyMeasurable g μ) + (hgC : ∀ t, g t ∈ Set.Icc (0 : ℝ) C) (x : X) : + kernelAverage μ K g x ≤ C := by + have hnorm (t) : ‖g t‖ ≤ C := by simpa only [Real.norm_of_nonneg (hgC t).1] using (hgC t).2 + have hint : Integrable (fun t => K x t * g t) μ := (hK x).mul_bdd hg (Filter.Eventually.of_forall hnorm) + have h := integral_mono hint ((hK x).mul_const C) + (fun t => mul_le_mul_of_nonneg_left (hgC t).2 (hK0 x t)) + simpa only [kernelAverage, integral_mul_const, hmass, one_mul] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem fixedKernelMixture_lipschitz {X T : Type*} [PseudoMetricSpace X] [MeasurableSpace T] + (μ : Measure T) (K : T → ℝ) (g : X → T → ℝ) (L : ℝ≥0) + (hK : Integrable K μ) (hK0 : ∀ t, 0 ≤ K t) (hKmass : (∫ t, K t ∂μ) = 1) + (hint : ∀ x, Integrable (fun t => K t * g x t) μ) + (hLip : ∀ t, LipschitzWith L (fun x => g x t)) : + LipschitzWith L (fun x => ∫ t, K t * g x t ∂μ) := by + apply LipschitzWith.of_dist_le_mul + intro x y + rw [Real.dist_eq, ← integral_sub (hint x) (hint y)] + have hpoint (t) : ‖K t * g x t - K t * g y t‖ ≤ K t * ((L : ℝ) * dist x y) := by + rw [← mul_sub, norm_mul, Real.norm_of_nonneg (hK0 t)] + apply mul_le_mul_of_nonneg_left _ (hK0 t) + simpa only [Real.dist_eq, Real.norm_eq_abs] using (hLip t).dist_le_mul x y + have h := norm_integral_le_of_norm_le (hK.mul_const ((L : ℝ) * dist x y)) + (Filter.Eventually.of_forall hpoint) + simpa only [Real.norm_eq_abs, integral_mul_const, hKmass, one_mul] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem fixedKernelMixture_difference_le {T : Type*} [MeasurableSpace T] + (μ : Measure T) (g f h : T → ℝ) (hg : Integrable g μ) (hg0 : ∀ t, 0 ≤ g t) + (hgmass : (∫ t, g t ∂μ) = 1) + (hf : Integrable (fun t => g t * f t) μ) (hh : Integrable (fun t => g t * h t) μ) + {E : ℝ} (he : ∀ t, g t ≠ 0 → |f t-h t| ≤ E) : + |(∫ t, g t * f t ∂μ) - ∫ t, g t * h t ∂μ| ≤ E := by + rw [← integral_sub hf hh] + have hb (t) : ‖g t * f t-g t * h t‖ ≤ g t * E := by + by_cases ht : g t = 0 + · simp only [ht, zero_mul, sub_self, norm_zero, le_refl] + · rw [← mul_sub, norm_mul, Real.norm_of_nonneg (hg0 t), Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_left (he t ht) (hg0 t) + have hi := norm_integral_le_of_norm_le (hg.mul_const E) (Filter.Eventually.of_forall hb) + simpa only [Real.norm_eq_abs, integral_mul_const, hgmass, one_mul] using hi + +theorem fixedKernelMixture_abs_le {T : Type*} [MeasurableSpace T] + (μ : Measure T) (g f : T → ℝ) (hg : Integrable g μ) (hg0 : ∀ t, 0 ≤ g t) + (hgmass : (∫ t, g t ∂μ) = 1) {H : ℝ} + (hb : ∀ t, g t ≠ 0 → |f t| ≤ H) : |∫ t, g t * f t ∂μ| ≤ H := by + have hpoint (t) : ‖g t * f t‖ ≤ g t * H := by + by_cases ht : g t = 0 + · simp only [ht, zero_mul, norm_zero, le_refl] + · rw [norm_mul, Real.norm_of_nonneg (hg0 t), Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_left (hb t ht) (hg0 t) + have hi := norm_integral_le_of_norm_le (hg.mul_const H) (Filter.Eventually.of_forall hpoint) + simpa only [Real.norm_eq_abs, integral_mul_const, hgmass, one_mul] using hi + +theorem fixedKernelMixture_lipschitzOn {X T : Type*} [PseudoMetricSpace X] [MeasurableSpace T] + (μ : Measure T) (g : T → ℝ) (F : X → T → ℝ) (S : Set X) (L : ℝ≥0) + (hg : Integrable g μ) (hg0 : ∀ t, 0 ≤ g t) (hgmass : (∫ t, g t ∂μ) = 1) + (hint : ∀ x ∈ S, Integrable (fun t => g t * F x t) μ) + (hLip : ∀ t, g t ≠ 0 → LipschitzOnWith L (fun x => F x t) S) : + LipschitzOnWith L (fun x => ∫ t, g t * F x t ∂μ) S := by + apply LipschitzOnWith.of_dist_le_mul + intro x hx y hy + rw [Real.dist_eq] + exact fixedKernelMixture_difference_le μ g (F x) (F y) hg hg0 hgmass (hint x hx) (hint y hy) + (fun t ht => (hLip t ht).dist_le_mul x hx y hy) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelNormalizationCompositionBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelNormalizationCompositionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..71441cc1d804911d55b9ab431bf341b7f9999a93 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelNormalizationCompositionBudget.lean @@ -0,0 +1,31 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialDensityBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_kernelNormalization_composition_budget (a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + p + (p + 2) ^ 2 + ((p + 2) ^ 4 + (a : ℝ)) ^ a ≤ (p + C) ^ C := by + let P : Polynomial ℕ := Polynomial.X + (Polynomial.X + 2) ^ 2 + + ((Polynomial.X + 2) ^ 4 + Polynomial.C a) ^ a + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro p hp + simpa [P, Polynomial.eval₂_pow] using hbound p hp + +theorem exists_kernelNormalization_composition_power_budget (a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + ((p + 2) ^ 4 + (a : ℝ)) ^ a ≤ (p + C) ^ C := by + obtain ⟨C, hC, hbound⟩ := exists_kernelNormalization_composition_budget a + refine ⟨C, hC, ?_⟩ + intro p hp + exact (le_add_of_nonneg_left (add_nonneg hp (sq_nonneg (p + 2)))).trans (hbound p hp) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelPrincipalFiberSliceLaw.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelPrincipalFiberSliceLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..992af377958f00ce970c26db3f5d913507f34d2d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelPrincipalFiberSliceLaw.lean @@ -0,0 +1,118 @@ +import OAI.Combinatorics.Progressions.Lattices.AllocatedSupportedSlicedResidue + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {G D : Type*} [Fintype G] [DecidableEq G] [Fintype D] [DecidableEq D] +variable (B : D → Type*) [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] (h : D → ℕ) +variable (LG : G → ℕ) (L : PrincipalTupleIndex B h → ℕ) + +def kernelZeroTupleFromSumIntegerBox + (z : integerBox (Sum.elim LG L)) : ∀ g, IntegerScalarCubeBox Empty (LG g) := + fun g _ => ⟨z.val (Sum.inl g), Finset.mem_Ico.mpr + ⟨(neg_nonpos.mpr (Int.natCast_nonneg _)).trans + ((mem_integerBox (Sum.elim LG L) z.val).mp z.property (Sum.inl g)).1, + ((mem_integerBox (Sum.elim LG L) z.val).mp z.property (Sum.inl g)).2⟩⟩ + +def principalZeroTupleFromSumIntegerBox + (z : integerBox (Sum.elim LG L)) : PrincipalIntegerTuples B h Empty L := + fun j _ => ⟨z.val (Sum.inr j), Finset.mem_Ico.mpr + ⟨(neg_nonpos.mpr (Int.natCast_nonneg _)).trans + ((mem_integerBox (Sum.elim LG L) z.val).mp z.property (Sum.inr j)).1, + ((mem_integerBox (Sum.elim LG L) z.val).mp z.property (Sum.inr j)).2⟩⟩ + +namespace ResidueBoxSlice + +variable {B h LG L} +variable {keep : G ⊕ PrincipalTupleIndex B h → Prop} [DecidablePred keep] {q : ℕ} +variable (S : ResidueBoxSlice (fun k : {k // keep k} => Sum.elim LG L k.val) q) +variable (hlen : ∀ k, 0 < S.length k) (fixed : {k // ¬keep k} → ℤ) +variable (hfixed : ∀ k, 0 ≤ fixed k ∧ fixed k < ((Sum.elim LG L k.val : ℕ) : ℤ)) +variable (hkernel : ∀ g, keep (Sum.inl g)) + +omit [Fintype G] [DecidableEq G] [Fintype D] [DecidableEq D] + [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] [DecidablePred keep] in +theorem fiberKernelProgression_contained (g : G) : + integerProgressionSupport (S.start ⟨Sum.inl g, hkernel g⟩ : ℤ) (q : ℤ) + (S.length ⟨Sum.inl g, hkernel g⟩) ⊆ Finset.Ico (0 : ℤ) (LG g : ℤ) := by + apply integerProgressionSupport_subset_of_fin + intro t + constructor + · positivity + · exact_mod_cast S.inside ⟨Sum.inl g, hkernel g⟩ t.val t.isLt + +include hlen hfixed in +theorem fiberPrincipalParameter_inside (j : PrincipalTupleIndex B h) + (t : Fin (S.fiberParameterLength (Sum.inr j))) : + 0 ≤ S.fiberParameterStart fixed (Sum.inr j) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inr j) : ℤ) * t.val ∧ + S.fiberParameterStart fixed (Sum.inr j) + + (fiberParameterStride (keep := keep) (q := q) (Sum.inr j) : ℤ) * t.val < L j := + S.fiberParameter_inside hlen fixed hfixed (Sum.inr j) t + +private theorem zeroScalarFinPoint_cube (H : ℕ) (t : Fin H) : + IntegerScalarCube H (fun i => (zeroScalarFinPoint H t i : ℤ)) := by + intro row + have he : row = ∅ := Subsingleton.elim _ _ + simpa only [he, integerScalarCubeValue, Finset.sum_empty, add_zero, zeroScalarFinPoint] + using And.intro (Int.natCast_nonneg t.val) (show (t.val : ℤ) < H by exact_mod_cast t.isLt) + +theorem fiberSliceLaw_kernel_principal_box_complexMean + (test : integerBox (Sum.elim LG L) → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean test = + 𝔼 g : (∀ i, Fin (S.length ⟨Sum.inl i, hkernel i⟩)), + 𝔼 p : (∀ j, Fin (S.fiberParameterLength (Sum.inr j))), + test (S.fiberAffinePointInBox fixed hfixed + (Sum.rec ((S.fiberKernelParameterEquiv hkernel).symm g) p)) := by + rw [fiberSliceLaw_affine_sum_complexMean] + apply Fintype.expect_equiv (S.fiberKernelParameterEquiv hkernel) + intro g + rw [Equiv.symm_apply_apply] + +theorem fiberSliceLaw_kernel_principal_source_complexMean + (hLG : ∀ g, 0 < LG g) + (φ : (∀ g, IntegerScalarCubeBox Empty (LG g)) → PrincipalIntegerTuples B h Empty L → ℂ) : + (S.fiberSliceLaw hlen fixed hfixed).complexMean (fun z => + φ (kernelZeroTupleFromSumIntegerBox B h LG L z) + (principalZeroTupleFromSumIntegerBox B h LG L z)) = + (FiniteProbabilityWeights.pi (fun g => integerScalarCubeWeights Empty + (S.length ⟨Sum.inl g, hkernel g⟩) (hlen ⟨Sum.inl g, hkernel g⟩))).complexMean (fun x => + (principalAffineIntervalLaw B h L + (fun j => S.fiberParameterLength (Sum.inr j)) + (fun j => fiberParameterStride (keep := keep) (q := q) (Sum.inr j)) + (fun j => S.fiberParameterStart fixed (Sum.inr j)) + (S.fiberPrincipalParameter_inside hlen fixed hfixed) + (fun j => S.fiberParameterLength_pos hlen (Sum.inr j))).complexMean (fun y => + φ (fun g => containedProgressionCubeMap Empty (LG g) + (S.length ⟨Sum.inl g, hkernel g⟩) q (S.start ⟨Sum.inl g, hkernel g⟩) + (hLG g) (S.fiberKernelProgression_contained hkernel g) (x g)) y)) := by + rw [S.fiberSliceLaw_kernel_principal_box_complexMean hlen fixed hfixed hkernel, + integerScalarCubeWeights_pi_fin_complexMean] + apply Finset.expect_congr rfl + intro g _ + rw [principalAffineIntervalLaw_complexMean] + apply Finset.expect_congr rfl + intro p _ + congr 1 + · funext i a + apply Subtype.ext + cases a with + | none => + rw [containedProgressionCubeMap_value Empty _ _ _ _ _ _ _ (zeroScalarFinPoint_cube _ _)] + simp only [kernelZeroTupleFromSumIntegerBox, fiberAffinePointInBox, + fiberAffineIntegerPoint, fiberParameterStart, fiberParameterStride, + dite_eq_left (hkernel i), ite_eq_left (hkernel i), fiberKernelParameterEquiv, + Equiv.coe_fn_symm_mk, zeroScalarFinPoint, ite_true] + | some a => exact isEmptyElim a + +end ResidueBoxSlice +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelProductFiber.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelProductFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..5cb3dd9414c5627e113990df74a5524c6868e29d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelProductFiber.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedEnormousProfiles +import OAI.Combinatorics.Progressions.Probability.IndependentEmbeddedMixture + +namespace OAI + +section + +namespace Erdos3.FiniteProbabilityWeights + +open scoped BigOperators Classical + +variable {J : Type*} [Fintype J] [DecidableEq J] + {Ω R : J → Type*} [∀ j, Fintype (Ω j)] [∀ j, DecidableEq (Ω j)] + [∀ j, Fintype (R j)] [∀ j, DecidableEq (R j)] + +theorem pi_fiberLaw (p : ∀ j, FiniteProbabilityWeights (Ω j)) + (residue : ∀ j, Ω j → R j) : + (pi p).fiberLaw (fun x j => residue j (x j)) = + pi (fun j => (p j).fiberLaw (residue j)) := by + apply ext_weight + funext r + rw [fiberLaw_weight_eq_mass, pi_fiber_mass] + change (∏ j, (p j).mass _) = ∏ j, ((p j).fiberLaw (residue j)).weight (r j) + simp only [fiberLaw_weight_eq_mass] + +theorem pi_complexMean_disintegrate (p : ∀ j, FiniteProbabilityWeights (Ω j)) + (residue : ∀ j, Ω j → R j) + (hp : ∀ j r, 0 < (p j).mass (Finset.univ.filter (fun x => residue j x = r))) + (test : (∀ j, R j) → (∀ j, Ω j) → ℂ) : + (pi p).complexMean (fun x => test (fun j => residue j (x j)) x) = + (pi (fun j => (p j).fiberLaw (residue j))).complexMean (fun r => + (pi (fun j => (p j).condition + (Finset.univ.filter (fun x => residue j x = r j)) (hp j (r j)))).complexMean + (test r)) := by + rw [(pi p).complexMean_disintegrate (fun x j => residue j (x j)) + (fun r => pi_fiber_mass_pos p residue r (fun j => hp j (r j))) test] + rw [pi_fiberLaw] + congr 1 + funext r + rw [pi_condition_fiber] + +end Erdos3.FiniteProbabilityWeights + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionExternalNet.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionExternalNet.lean new file mode 100644 index 0000000000000000000000000000000000000000..92f399706e972befc9714b4126f8489b13f45e70 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionExternalNet.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.Progressions.Linear.ExternalFamilyPrecenterProjectionData + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +variable {L σ τ X : Type*} [LieRing L] [LieAlgebra ℚ L] {s d n : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} {v : τ → ℕ} + +theorem exists_kernelProjection_external_net + (T : X → D.Niltest w) (centers : Fin n → D.Niltest v) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + {p ε : ℝ} (hT : ∀ x, (T x).UnitIntervalValued) + (hTc : ∀ x, (T x).ComplexityLE p) + (hcenters : ∀ i, (centers i).UnitIntervalValued) + (hcentersc : ∀ i, (centers i).ComplexityLE p) + (hnet : ∀ x, ∃ i, ∀ y, ‖(T x).observable y - (centers i).observable y‖ ≤ ε) : + ∃ (S : X → D.Niltest w) (projectedCenters : Fin n → D.Niltest v), + (∀ x, S x = (T x).kernelProjection K hK) ∧ + (∀ i, projectedCenters i = (centers i).kernelProjection K hK) ∧ + (∀ x, (S x).UnitIntervalValued ∧ (S x).ComplexityLE p ∧ + (S x).orbit = (T x).orbit ∧ (S x).normBound = (T x).normBound ∧ + (S x).lipBound = (T x).lipBound) ∧ + (∀ i, (projectedCenters i).UnitIntervalValued ∧ + (projectedCenters i).ComplexityLE p ∧ + (projectedCenters i).orbit = (centers i).orbit ∧ + (projectedCenters i).normBound = (centers i).normBound ∧ + (projectedCenters i).lipBound = (centers i).lipBound) ∧ + (∀ x, ∃ i, ∀ y, ‖(S x).observable y - (projectedCenters i).observable y‖ ≤ ε) ∧ + ∀ i, (∃ x, (centers i).observable = (T x).observable) → + ∃ x, (projectedCenters i).observable = (S x).observable := by + let S := fun x => (T x).kernelProjection K hK + let C := fun i => (centers i).kernelProjection K hK + refine ⟨S, C, fun _ => rfl, fun _ => rfl, ?_, ?_, ?_, ?_⟩ + · intro x + exact ⟨(T x).kernelProjection_unitInterval K hK (hT x), + (T x).kernelProjection_complexity K hK (hTc x), rfl, rfl, rfl⟩ + · intro i + exact ⟨(centers i).kernelProjection_unitInterval K hK (hcenters i), + (centers i).kernelProjection_complexity K hK (hcentersc i), rfl, rfl, rfl⟩ + · intro x + obtain ⟨i, hi⟩ := hnet x + exact ⟨i, (T x).kernelProjection_observable_sub_norm_le (centers i) K hK hi⟩ + · intro i hi + obtain ⟨x, hx⟩ := hi + refine ⟨x, funext fun y => sub_eq_zero.mp (norm_eq_zero.mp ?_)⟩ + apply le_antisymm _ (norm_nonneg _) + apply (centers i).kernelProjection_observable_sub_norm_le (T x) K hK + intro z + rw [hx, sub_self, norm_zero] + +theorem exists_kernelProjection_member_external_net + (T : X → D.Niltest w) (representative : Fin n → X) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + {p ε : ℝ} (hT : ∀ x, (T x).UnitIntervalValued) + (hTc : ∀ x, (T x).ComplexityLE p) + (hnet : ∀ x, ∃ i, ∀ y, + ‖(T x).observable y - (T (representative i)).observable y‖ ≤ ε) : + ∃ (S : X → D.Niltest w) (projectedCenters : Fin n → D.Niltest w), + (∀ x, S x = (T x).kernelProjection K hK) ∧ + (∀ i, projectedCenters i = S (representative i)) ∧ + (∀ x, (S x).UnitIntervalValued ∧ (S x).ComplexityLE p ∧ + (S x).orbit = (T x).orbit ∧ (S x).normBound = (T x).normBound ∧ + (S x).lipBound = (T x).lipBound) ∧ + (∀ x, ∃ i, ∀ y, ‖(S x).observable y - (projectedCenters i).observable y‖ ≤ ε) ∧ + ∀ i, ∃ x, projectedCenters i = S x := by + let S := fun x => (T x).kernelProjection K hK + refine ⟨S, fun i => S (representative i), fun _ => rfl, fun _ => rfl, ?_, ?_, ?_⟩ + · intro x + exact ⟨(T x).kernelProjection_unitInterval K hK (hT x), + (T x).kernelProjection_complexity K hK (hTc x), rfl, rfl, rfl⟩ + · intro x + obtain ⟨i, hi⟩ := hnet x + exact ⟨i, (T x).kernelProjection_observable_sub_norm_le + (T (representative i)) K hK hi⟩ + · intro i + exact ⟨representative i, rfl⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionNoPivotGlobalization.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionNoPivotGlobalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..9df280312f4ede794d0e00d95a9050e8ffc7bba8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionNoPivotGlobalization.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Fourier.PivotAnnihilatorFrequencyCode +import OAI.Combinatorics.Progressions.Nilpotent.LocalNiltestFixedNativePartners + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem frequencyCodeKernel_eq_of_no_pivots + {V J : Type*} [AddCommGroup V] [Module ℚ V] {r : ℕ} + (P : Submodule ℚ V) (eta : J → V →ₗ[ℚ] ℚ) + (code : Fin r → Option J) (hnone : ∀ i, code i = none) : + frequencyCodeKernel P eta code = P := by + ext v + rw [mem_frequencyCodeKernel] + constructor + · exact And.left + · intro hv + refine ⟨hv, ?_⟩ + intro i j hij + rw [hnone i] at hij + cases hij + +namespace RationalFilteredNilmanifold.Niltest + +variable {L X Y Ω J : Type*} [LieRing L] [LieAlgebra ℚ L] {d r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L 1 d} {w : Y → ℕ} + +theorem exists_noPivot_ambient_realization + (S : D.Niltest w) (tests : Ω → D.Niltest w) + (hcommon : ∀ a, (tests a).observable = S.observable) + (eta : J → L →ₗ[ℚ] ℚ) (code : Fin r → Option J) + (hnone : ∀ i, code i = none) + (hinv : ∀ z : D.RealGroup, + z.coord ∈ (frequencyCodeKernel (D.filtration.layer 1) eta code).baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) + {p : ℝ} (hcomplexity : S.ComplexityLE p) (hunit : S.UnitIntervalValued) : + ∃ ambient : D.Niltest (fun _ : X => 1), + ambient.observable = S.observable ∧ ambient.UnitIntervalValued ∧ + ambient.ComplexityLE p ∧ + ∀ a x y, ambient.eval x = (tests a).eval y := by + have hkernel : frequencyCodeKernel (D.filtration.layer 1) eta code = ⊤ := by + rw [frequencyCodeKernel_eq_of_no_pivots _ _ _ hnone, D.filtration.one_eq_top] + have hconst (g : D.RealGroup) : + S.observable (QuotientGroup.mk g) = + S.observable (QuotientGroup.mk (1 : D.RealGroup)) := by + have hg : g.coord ∈ (frequencyCodeKernel (D.filtration.layer 1) eta code).baseChange ℝ := by + rw [hkernel, Submodule.baseChange_top] + trivial + simpa using hinv g hg (QuotientGroup.mk (1 : D.RealGroup)) + refine ⟨S.withOrbit 1, rfl, hunit, hcomplexity, ?_⟩ + intro a x y + change S.observable _ = (tests a).observable _ + rw [hcommon a] + exact (hconst _).trans (hconst _).symm + +end RationalFilteredNilmanifold.Niltest +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionPresentPivotIdeal.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionPresentPivotIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..a912fe8a7746b4142bbad0b46b0a3bbe01af2ad1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelProjectionPresentPivotIdeal.lean @@ -0,0 +1,236 @@ +import OAI.Combinatorics.Progressions.Estimates.ExternalPivotMaskSelection +import OAI.Combinatorics.Progressions.Fourier.PivotAnnihilatorFrequencyCode +import OAI.Combinatorics.Progressions.Nilpotent.LocalNiltestFixedNativePartners + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct Classical + +def KernelProjectionPresentPivot {J : Type*} {r : ℕ} + (code : Fin r → Option J) := {i : Fin r // ∃ j, code i = some j} + +noncomputable instance {J : Type*} {r : ℕ} (code : Fin r → Option J) : + Fintype (KernelProjectionPresentPivot code) := inferInstanceAs (Fintype {i // ∃ j, code i = some j}) + +noncomputable def kernelProjectionSelectedPivot {J : Type*} {r : ℕ} + (code : Fin r → Option J) (i : KernelProjectionPresentPivot code) : J := + Classical.choose i.property + +theorem kernelProjectionSelectedPivot_spec {J : Type*} {r : ℕ} + (code : Fin r → Option J) (i : KernelProjectionPresentPivot code) : + code i.val = some (kernelProjectionSelectedPivot code i) := Classical.choose_spec i.property + +theorem kernelProjectionPresentPivot_card_le {J : Type*} {r : ℕ} + (code : Fin r → Option J) : Fintype.card (KernelProjectionPresentPivot code) ≤ r := by + simpa only [Fintype.card_fin] using Fintype.card_le_of_injective + (fun i : KernelProjectionPresentPivot code => i.val) Subtype.val_injective + +variable {L Y Ω T X J I σ Θ : Type*} [LieRing L] [LieAlgebra ℚ L] {s d r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : Y → ℕ} + +noncomputable def kernelProjectionLocalPivotTests + (code : Fin r → Option J) (U : J → D.Niltest w) (tests : Ω → D.Niltest w) : + Ω → KernelProjectionPresentPivot code → D.Niltest w := + fun a i => (U (kernelProjectionSelectedPivot code i)).withOrbit (tests a).orbit + +theorem exists_kernel_projection_fixed_native_partners + [Fintype Ω] [Fintype T] [Nonempty T] [Fintype I] [Nonempty I] + (code : Fin r → Option J) (U : J → D.Niltest w) (tests : Ω → D.Niltest w) + (p : ℝ) (hU : ∀ j, (U j).ComplexityLE p) + (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (physical : Ω → T → X) (slices : Ω → Fin r → Finset T) + (point : Ω → T → Y → ℤ) + (hS : ∀ a i, (slices a i).Nonempty) {cap : ℝ} + (hsize : ∀ a i, (Fintype.card T : ℝ) / (slices a i).card ≤ cap) + (v e : X → ℂ) (Q : I → X → ℂ) (c : I → ℂ) + (hmodel : v = (∑ i, c i • Q i) + e) + {M kappa : ℝ} (hM : 0 < M) (hkappa : 0 < kappa) + (hc : (∑ i, ‖c i‖) ≤ M) (hmass : kappa ≤ outer.mass productive) + (herror : (r : ℝ) * sampledSliceSeminorm outer physical + (fun a (i : KernelProjectionPresentPivot code) => slices a i.val) + (localNiltestPartnerWeight (kernelProjectionLocalPivotTests code U tests) point p) e ≤ + kappa * Real.exp (-2 * p) / 8) + (nativeWeight : σ → ℕ) (degree : ℕ) (budget : ℝ) + (sample : X → σ → ℤ) (twist : Θ → X → ℂ) + (hQ : ∀ i, Q i ∈ twistedNativeSampleFunctions nativeWeight degree budget sample twist) + (hscore : ∀ a ∈ productive, ∀ i j, code i = some j → Real.exp (-p) ≤ + ‖𝔼 t ∈ slices a i, v (physical a t) * + ((U j).withOrbit (tests a).orbit).eval (point a t)‖) : + ∃ (fixedTwist : KernelProjectionPresentPivot code → Θ) + (nativeValue : KernelProjectionPresentPivot code → X → ℂ) + (_native : ∀ i, NativeSampleModel nativeWeight degree budget sample (nativeValue i)) + (retained : Finset Ω), + retained ⊆ productive ∧ 0 < outer.mass retained ∧ + (3 * kappa / 4) / (Fintype.card I : ℝ) ^ r ≤ outer.mass retained ∧ + ∀ a ∈ retained, ∀ i : KernelProjectionPresentPivot code, + Real.exp (-p) / (2 * M) ≤ + ‖𝔼 t ∈ slices a i.val, + (star (twist (fixedTwist i) (physical a t)) * nativeValue i (physical a t)) * + ((U (kernelProjectionSelectedPivot code i)).withOrbit (tests a).orbit).eval + (point a t)‖ := by + let K := KernelProjectionPresentPivot code + have hcard : (Fintype.card K : ℝ) ≤ r := by + exact_mod_cast kernelProjectionPresentPivot_card_le code + have herr : (Fintype.card K : ℝ) * sampledSliceSeminorm outer physical + (fun a (i : K) => slices a i.val) + (localNiltestPartnerWeight (kernelProjectionLocalPivotTests code U tests) point p) e ≤ + kappa * Real.exp (-2 * p) / 8 := + (mul_le_mul_of_nonneg_right hcard (apply_nonneg _ _)).trans herror + obtain ⟨fixedTwist, nativeValue, native, retained, hsub, hpos, hretained, hlocal⟩ := + exists_local_niltest_fixed_native_partners outer productive physical + (fun a (i : K) => slices a i.val) (kernelProjectionLocalPivotTests code U tests) + point p (fun _ i => hU (kernelProjectionSelectedPivot code i)) + (fun a i => hS a i.val) (fun a i => hsize a i.val) + v e Q c hmodel hM hkappa hc hmass herr nativeWeight degree budget sample twist hQ + (fun a ha i => hscore a ha i.val (kernelProjectionSelectedPivot code i) + (kernelProjectionSelectedPivot_spec code i)) + refine ⟨fixedTwist, nativeValue, native, retained, hsub, hpos, ?_, hlocal⟩ + apply le_trans _ hretained + apply div_le_div_of_nonneg_left (by positivity) + (pow_pos (Nat.cast_pos.mpr Fintype.card_pos) _) + exact pow_le_pow_right₀ (by exact_mod_cast Fintype.card_pos : (1 : ℝ) ≤ Fintype.card I) + (kernelProjectionPresentPivot_card_le code) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped TensorProduct Classical + +open RationalFilteredNilmanifold + +theorem exists_external_kernel_pivot_masks + {L σ τ X Ω J I Freq : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [Fintype Ω] [Fintype J] [Fintype I] [Nonempty I] + {s d r : ℕ} (D : RationalFilteredNilmanifold L s d) + {w : σ → ℕ} {v : τ → ℕ} + (code : Fin r → Option Freq) (U : Freq → X → D.Niltest w) + (representative : I → X) {p B ε δ : ℝ} + (hcomplex : ∀ f x, (U f x).ComplexityLE p) + (hnet : ∀ f x, ∃ i, ∀ y, ‖(U f x).observable y - + (U f (representative i)).observable y‖ ≤ ε) + (outer : FiniteProbabilityWeights Ω) (H : Finset Ω) (hH : 0 < outer.mass H) + (localLaw : Ω → FiniteProbabilityWeights J) + (localOrbit : Ω → D.filtration.realification.PolynomialOrbit v) + (physical : Ω → J → X) (point : Ω → J → τ → ℤ) (weight : X → ℂ) + (hB : 0 ≤ B) (hδ : 0 < δ) (herror : B * ε ≤ δ / 2) + (hweight : ∀ x, ‖weight x‖ ≤ B) + (hscore : ∀ a ∈ H, ∀ i f, code i = some f → δ ≤ + ‖(localLaw a).complexMean (fun j => weight (physical a j) * + ((U f (physical a j)).withOrbit (localOrbit a)).eval (point a j))‖) : + ∃ (chosen : KernelProjectionPresentPivot code → I) + (masked : KernelProjectionPresentPivot code → X → ℂ) (H' : Finset Ω), + (∀ k x, masked k x = if externalNetIndex + (fun x => (U (kernelProjectionSelectedPivot code k) x).observable) + (fun i => (U (kernelProjectionSelectedPivot code k) (representative i)).observable) + (hnet (kernelProjectionSelectedPivot code k)) x = chosen k then weight x else 0) ∧ + (∀ k x, ‖masked k x‖ ≤ B) ∧ H' ⊆ H ∧ 0 < outer.mass H' ∧ + outer.mass H / (Fintype.card I : ℝ) ^ r ≤ outer.mass H' ∧ + (∀ a k, ((U (kernelProjectionSelectedPivot code k) (representative (chosen k))).withOrbit + (localOrbit a)).ComplexityLE p) ∧ + ∀ a ∈ H', ∀ k, δ / (2 * Fintype.card I) ≤ + ‖(localLaw a).complexMean (fun j => masked k (physical a j) * + ((U (kernelProjectionSelectedPivot code k) (representative (chosen k))).withOrbit + (localOrbit a)).eval (point a j))‖ := by + let K := KernelProjectionPresentPivot code + let functions := fun (k : K) x => (U (kernelProjectionSelectedPivot code k) x).observable + let centers := fun (k : K) i => (U (kernelProjectionSelectedPivot code k) (representative i)).observable + have hselected (a : Ω) (ha : a ∈ H) (k : K) : δ ≤ + ‖(localLaw a).complexMean (fun j => weight (physical a j) * functions k (physical a j) + (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval v (point a j) (localOrbit a))))‖ := + hscore a ha k.val (kernelProjectionSelectedPivot code k) (kernelProjectionSelectedPivot_spec code k) + obtain ⟨chosen, masked, H', hmask, hcap, hsub, hpos, hmass, hs⟩ := + exists_simultaneous_external_pivot_masks functions centers + (fun k => hnet (kernelProjectionSelectedPivot code k)) outer H hH + (fun a _ => localLaw a) physical + (fun a _ j => QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval v (point a j) (localOrbit a))) + weight hB hδ herror hweight hselected + refine ⟨chosen, masked, H', hmask, hcap, hsub, hpos, ?_, ?_, hs⟩ + · apply le_trans _ hmass + apply div_le_div_of_nonneg_left (outer.mass_nonneg H) + (pow_pos (Nat.cast_pos.mpr Fintype.card_pos) _) + exact pow_le_pow_right₀ + (by exact_mod_cast Fintype.card_pos : (1 : ℝ) ≤ Fintype.card I) + (kernelProjectionPresentPivot_card_le code) + · intro a k + exact hcomplex _ _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule +open scoped Classical + +variable {V J : Type*} [AddCommGroup V] [Module ℚ V] + +theorem finiteFrequencyKernel_presentPivots + (P : Submodule ℚ V) (eta : J → V →ₗ[ℚ] ℚ) + {r : ℕ} (code : Fin r → Option J) : + finiteFrequencyKernel P (fun k => eta (kernelProjectionSelectedPivot code k)) + (Finset.univ : Finset (KernelProjectionPresentPivot code)).toList = + frequencyCodeKernel P eta code := by + ext x + rw [mem_finiteFrequencyKernel, mem_frequencyCodeKernel] + refine and_congr_right (fun _ => ?_) + constructor + · intro h i j hij + let k : KernelProjectionPresentPivot code := ⟨i, ⟨j, hij⟩⟩ + have hselected : kernelProjectionSelectedPivot code k = j := by + exact Option.some.inj ((kernelProjectionSelectedPivot_spec code k).symm.trans hij) + simpa only [hselected] using h k (Finset.mem_toList.mpr (Finset.mem_univ k)) + · intro h k _ + exact h k.val (kernelProjectionSelectedPivot code k) + (kernelProjectionSelectedPivot_spec code k) + +namespace NilpotentLieFiltration + +variable {L Y : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing Y] [LieAlgebra ℚ Y] {s r : ℕ} + (F : NilpotentLieFiltration L s) (φ : L →ₗ⁅ℚ⁆ Y) + (eta : J → L →ₗ[ℚ] ℚ) (code : Fin r → Option J) + +theorem pivotAnnihilatorIdeal_presentPivots_toSubmodule : + (F.pivotAnnihilatorIdeal φ (fun k => eta (kernelProjectionSelectedPivot code k)) + (Finset.univ : Finset (KernelProjectionPresentPivot code)).toList).toSubmodule = + frequencyCodeKernel (F.layer s ⊓ LinearMap.ker φ.toLinearMap) eta code := by + exact finiteFrequencyKernel_presentPivots + (F.layer s ⊓ LinearMap.ker φ.toLinearMap) eta code + +theorem pivotAnnihilatorIdeal_presentPivots + (hK : frequencyCodeKernel (F.layer s ⊓ LinearMap.ker φ.toLinearMap) eta code ≤ + F.layer s) : + F.pivotAnnihilatorIdeal φ (fun k => eta (kernelProjectionSelectedPivot code k)) + (Finset.univ : Finset (KernelProjectionPresentPivot code)).toList = + F.topSubspaceIdeal + (frequencyCodeKernel (F.layer s ⊓ LinearMap.ker φ.toLinearMap) eta code) hK := by + ext x + change x ∈ (F.pivotAnnihilatorIdeal φ + (fun k => eta (kernelProjectionSelectedPivot code k)) + (Finset.univ : Finset (KernelProjectionPresentPivot code)).toList).toSubmodule ↔ + x ∈ frequencyCodeKernel (F.layer s ⊓ LinearMap.ker φ.toLinearMap) eta code + rw [F.pivotAnnihilatorIdeal_presentPivots_toSubmodule φ eta code] + +end NilpotentLieFiltration + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelScalarEnvelope.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelScalarEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fcdf8670d391e9f9ec7d9f507443d0e0158dc32 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelScalarEnvelope.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Linear.KernelCoefficientLogBudget + +namespace OAI + +section + +namespace Erdos3 + +def kernelInverseEnvelope {A : Type*} [Semiring A] (D p : A) : A := + D + D^2 + D*(D*(D+1)) + D*(D*D+D*(D^2+D+p+2)) + +def kernelGeometryEnvelope {A : Type*} [Semiring A] (D p : A) : A := + p+D+D+D*(D+1)+kernelInverseEnvelope D p + +def kernelOutputEnvelope {A : Type*} [Semiring A] (D p : A) : A := + D^2+(D+1)*kernelGeometryEnvelope D p+(D+D+(D+1)*p)+ + D*(kernelGeometryEnvelope D p+1)+ + (4*kernelGeometryEnvelope D p+D+D+D*D+2)+1 + +theorem kernelInverseEnvelope_nonneg {D p : ℝ} (hD : 0 ≤ D) (hp : 0 ≤ p) : + 0 ≤ kernelInverseEnvelope D p := by + unfold kernelInverseEnvelope + positivity + +theorem kernelGeometryEnvelope_nonneg {D p : ℝ} (hD : 0 ≤ D) (hp : 0 ≤ p) : + 0 ≤ kernelGeometryEnvelope D p := by + have hi := kernelInverseEnvelope_nonneg hD hp + unfold kernelGeometryEnvelope + positivity + +theorem kernelOutputEnvelope_nonneg {D p : ℝ} (hD : 0 ≤ D) (hp : 0 ≤ p) : + 0 ≤ kernelOutputEnvelope D p := by + have hg := kernelGeometryEnvelope_nonneg hD hp + unfold kernelOutputEnvelope + positivity + +theorem kernelInverseLog_le_envelope {q n j d : ℕ} {D p : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (hq : (q : ℝ) ≤ D) (hn : (n : ℝ) ≤ D) + (hj : (j : ℝ) ≤ D) (hd : (d : ℝ) ≤ D) : + kernelInverseLog q n j d p ≤ kernelInverseEnvelope D p := by + have hj' : ((j-1 : ℕ) : ℝ) ≤ D := (Nat.cast_le.mpr (Nat.sub_le j 1)).trans hj + unfold kernelInverseLog kernelInverseEnvelope + gcongr + +theorem kernelGeometryLog_le_envelope {q n j k d : ℕ} {D p : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (hq : (q : ℝ) ≤ D) (hn : (n : ℝ) ≤ D) + (hj : (j : ℝ) ≤ D) (hk : (k : ℝ) ≤ D) (hd : (d : ℝ) ≤ D) : + kernelGeometryLog q n j k d p ≤ kernelGeometryEnvelope D p := by + have hi := kernelInverseLog_le_envelope hD hp hq hn hj hd + unfold kernelGeometryLog kernelGeometryEnvelope + gcongr + +theorem kernelRowOutputLog_le_envelope {q n j k u d : ℕ} {D p : ℝ} + (hD : 0 ≤ D) (hp : 0 ≤ p) (hq : (q : ℝ) ≤ D) (hn : (n : ℝ) ≤ D) + (hj : (j : ℝ) ≤ D) (hk : (k : ℝ) ≤ D) (hu : (u : ℝ) ≤ D) + (hd : (d : ℝ) ≤ D) (hprofile : (probabilityProfileLipschitz : ℝ) ≤ D) : + kernelRowOutputLog q n j k u d p ≤ kernelOutputEnvelope D p := by + have hG := kernelGeometryLog_le_envelope hD hp hq hn hj hk hd + have hG0 := (kernelGeometryLog_bounds q n j k d hp).1 + have hGe := kernelGeometryEnvelope_nonneg hD hp + dsimp only [kernelRowOutputLog, kernelOutputEnvelope, affineProfileLogBound, jetOutputRadiusLog] + gcongr + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelScaleIndependence.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelScaleIndependence.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8f612c62d800c3021fda3da3fc4dd7adb9b2c7e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelScaleIndependence.lean @@ -0,0 +1,432 @@ +import OAI.Combinatorics.Progressions.Estimates.BoundedRightInverseMinor +import OAI.Combinatorics.Progressions.Geometry.ScalarCubeProductSupport +import OAI.Combinatorics.Progressions.Geometry.ScalarSpatialScaleBounds +import OAI.Combinatorics.Progressions.Lattices.IntegerNormalizedJetColumns +import OAI.Combinatorics.Progressions.Lattices.SmoothIntegerImage +import OAI.Combinatorics.Progressions.Linear.KernelJetAllowances + +namespace OAI + + +namespace Erdos3 + +theorem realKernelJet_exists_minor {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (hroot : ∀ j, |root (selection j)| ≤ 1) + (hentry : ∀ i j, |difference i (selection j)| ≤ 1) + {κ : ℝ} (hκ : 0 < κ) (hd : κ ≤ |(realDifferencePivot difference selection).det|) + (h : ℕ) (rows : O → Finset α) (hr : Function.Injective rows) + (hrows : ∀ o, (rows o).card ≤ h) : + ∃ p : O → BoundedIntegerExponent K h, Function.Injective p ∧ + kernelJetMinorThreshold (Fintype.card α) (Fintype.card K) (Fintype.card O) h κ ≤ + |((boundedDegreeRealJetMatrix root difference h rows).submatrix id p).det| := by + classical + let Q := kernelJetInterpolationAllowance (Fintype.card α) h κ + have hQ : 0 < Q := kernelJetInterpolationAllowance_pos _ _ hκ + have hdet : (realDifferencePivot difference selection).det ≠ 0 := + abs_pos.mp (hκ.trans_le hd) + obtain ⟨p, hp, hminor⟩ := boundedRightInverse_exists_minor + (boundedDegreeRealJetMatrix root difference h rows) + (realKernelJetRightInverse root difference selection h rows) + (realKernelJetRightInverse_spec root difference selection hdet h rows hr hrows) + hQ (realKernelJetRightInverse_entry_bound root difference selection hroot hentry hκ hd h rows hrows) + refine ⟨p, hp, le_trans ?_ hminor⟩ + have hc : (Fintype.card (BoundedIntegerExponent K h) : ℝ) ≤ + ((Fintype.card K : ℝ) + 1) ^ h := by + exact_mod_cast boundedIntegerExponent_card_le K h + have hcard : (Fintype.card (O → BoundedIntegerExponent K h) : ℝ) ≤ + (((Fintype.card K : ℝ) + 1) ^ h) ^ Fintype.card O := by + simp only [Fintype.card_fun, Nat.cast_pow] + exact pow_le_pow_left₀ (by positivity) hc _ + have hpos : (0 : ℝ) < Fintype.card (O → BoundedIntegerExponent K h) := by + exact_mod_cast Fintype.card_pos + change 1 / ((((Fintype.card K : ℝ) + 1) ^ h) * Q) ^ Fintype.card O ≤ _ + rw [mul_pow] + apply one_div_le_one_div_of_le (mul_pos hpos (pow_pos hQ _)) + exact mul_le_mul_of_nonneg_right hcard (pow_nonneg hQ.le _) + +theorem realKernelJet_exists_controlled_pivot {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (hroot : ∀ k, |root k| ≤ 1) (hentry : ∀ i k, |difference i k| ≤ 1) + {κ : ℝ} (hκ : 0 < κ) (hd : κ ≤ |(realDifferencePivot difference selection).det|) + (h : ℕ) (rows : O → Finset α) (hr : Function.Injective rows) + (hrows : ∀ o, (rows o).card ≤ h) : + ∃ p : O → BoundedIntegerExponent K h, Function.Injective p ∧ + (matrixSupCLM ((boundedDegreeRealJetMatrix root difference h rows).submatrix id p)).IsInvertible ∧ + ‖(matrixSupCLM ((boundedDegreeRealJetMatrix root difference h rows).submatrix id p)).inverse‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card K) (Fintype.card O) h κ := by + obtain ⟨p, hp, hminor⟩ := realKernelJet_exists_minor root difference selection + (fun j => hroot (selection j)) (fun i j => hentry i (selection j)) hκ hd h rows hr hrows + refine ⟨p, hp, ?_⟩ + exact matrixSupCLM_inverse_norm_le _ (kernelJetEntryAllowance_pos _ _).le + (fun i j => boundedDegreeRealJetMatrix_entry_bound root difference hroot hentry h rows i (p j)) + (kernelJetMinorThreshold_pos _ _ _ _ hκ) hminor + + +open scoped BigOperators + +theorem monomialScale_le_uniform_pow {K : Type*} (T : K → ℝ) + (hT : ∀ k, 0 ≤ T k) {L : ℝ} (hL : 1 ≤ L) (hTL : ∀ k, T k ≤ L) + (e : K →₀ ℕ) {h : ℕ} (he : e.sum (fun _ n => n) ≤ h) : + monomialScale T e ≤ L ^ h := by + classical + change (∏ k ∈ e.support, T k ^ e k) ≤ _ + calc + _ ≤ ∏ k ∈ e.support, L ^ e k := + Finset.prod_le_prod₀ (fun k _ => pow_nonneg (hT k) _) + (fun k _ => pow_le_pow_left₀ (hT k) (hTL k) _) + _ = L ^ e.sum (fun _ n => n) := by rw [Finset.prod_pow_eq_pow_sum]; rfl + _ ≤ L ^ h := pow_le_pow_right₀ hL he + +theorem kernelCoefficientScale_lower {K : Type*} (T : K → ℝ) + (hT : ∀ k, 0 < T k) {H L : ℝ} (hH : 0 ≤ H) (hL : 1 ≤ L) + (hTL : ∀ k, T k ≤ L) (e : K →₀ ℕ) {h : ℕ} + (he : e.sum (fun _ n => n) ≤ h) : + H / L ^ h ≤ H / monomialScale T e := + div_le_div_of_nonneg_left hH (monomialScale_pos T hT e) + (monomialScale_le_uniform_pow T (fun k => (hT k).le) hL hTL e he) + +theorem boundedDegreeIntegerJetMatrix_entry_bound {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℤ) (difference : Matrix α K ℤ) (T : K → ℝ) + (hT : ∀ k, 0 < T k) {L : ℝ} (hL : 1 ≤ L) (hTL : ∀ k, T k ≤ L) + (hroot : ∀ k, |(root k : ℝ) / T k| ≤ 1) + (hentry : ∀ i k, |(difference i k : ℝ) / T k| ≤ 1) + (h : ℕ) (rows : O → Finset α) (o : O) (e : BoundedIntegerExponent K h) : + |(boundedDegreeIntegerJetMatrix root difference h rows o e : ℝ)| ≤ + (2 ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ h) * L ^ h := by + have he := congrFun (congrFun + (normalizedBoundedIntegerJetMatrix_eq root difference h rows T (H := 1) one_ne_zero) o) e + rw [normalizedIntegerColumns_entry_div] at he + have hbound := boundedDegreeRealJetMatrix_entry_bound _ _ hroot hentry h rows o e + rw [← he] at hbound + have hs := monomialScale_pos T hT e.val + have hquot : |(boundedDegreeIntegerJetMatrix root difference h rows o e : ℝ)| / + monomialScale T e.val ≤ 2 ^ Fintype.card α * ((Fintype.card α : ℝ) + 1) ^ h := by + simpa only [div_one, mul_one_div, abs_div, abs_of_pos hs] using hbound + exact ((div_le_iff₀ hs).mp hquot).trans + (mul_le_mul_of_nonneg_left + (monomialScale_le_uniform_pow T (fun k => (hT k).le) hL hTL e.val e.property) (by positivity)) + +end Erdos3 + + +namespace Erdos3 + +theorem normalizedIntegerColumns_submatrix {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (S : J → ℝ) (P : I → ℝ) (p : I → J) : + (normalizedIntegerColumns A S P).submatrix id p = + normalizedIntegerPivot (A.submatrix id p) (fun i => S (p i)) P := by + ext i j + simp only [Matrix.submatrix_apply, id_eq, normalizedIntegerColumns_entry_div, + normalizedIntegerPivot_entry] + +theorem integerPivot_det_ne_zero_of_normalized {I : Type*} [Fintype I] [DecidableEq I] + (A : Matrix I I ℤ) (S P : I → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) + (hd : (normalizedIntegerPivot A S P).det ≠ 0) : A.det ≠ 0 := by + intro hz + have he := normalizedIntegerPivot_abs_det A S P hS hP + rw [hz] at he + simp only [Int.natAbs_zero, Nat.cast_zero, zero_mul, zero_div] at he + exact hd (abs_eq_zero.mp he) + +theorem normalizedBoundedIntegerJet_exists_pivot {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℤ) (difference : Matrix α K ℤ) (T : K → ℝ) (hT : ∀ k, 0 < T k) + (selection : α → K) + (hroot : ∀ k, |(root k : ℝ) / T k| ≤ 1) + (hentry : ∀ i k, |(difference i k : ℝ) / T k| ≤ 1) + {κ H : ℝ} (hκ : 0 < κ) (hH : 0 < H) + (hd : κ ≤ |(realDifferencePivot (fun i k => (difference i k : ℝ) / T k) selection).det|) + (h : ℕ) (rows : O → Finset α) (hr : Function.Injective rows) + (hrows : ∀ o, (rows o).card ≤ h) : + ∃ p : O → BoundedIntegerExponent K h, Function.Injective p ∧ + ((boundedDegreeIntegerJetMatrix root difference h rows).submatrix id p).det ≠ 0 ∧ + (matrixSupCLM (normalizedIntegerPivot + ((boundedDegreeIntegerJetMatrix root difference h rows).submatrix id p) + (fun o => H / monomialScale T (p o).val) (fun _ => H))).IsInvertible ∧ + ‖(matrixSupCLM (normalizedIntegerPivot + ((boundedDegreeIntegerJetMatrix root difference h rows).submatrix id p) + (fun o => H / monomialScale T (p o).val) (fun _ => H))).inverse‖ ≤ + kernelJetInverseAllowance (Fintype.card α) (Fintype.card K) (Fintype.card O) h κ := by + obtain ⟨p, hp, hminor⟩ := realKernelJet_exists_minor + (fun k => (root k : ℝ) / T k) (fun i k => (difference i k : ℝ) / T k) selection + (fun j => hroot (selection j)) (fun i j => hentry i (selection j)) hκ hd h rows hr hrows + have he := congrArg (fun A : Matrix O (BoundedIntegerExponent K h) ℝ => A.submatrix id p) + (normalizedBoundedIntegerJetMatrix_eq root difference h rows T hH.ne') + rw [normalizedIntegerColumns_submatrix] at he + have hn := matrixSupCLM_inverse_norm_le + ((boundedDegreeRealJetMatrix (fun k => (root k : ℝ) / T k) + (fun i k => (difference i k : ℝ) / T k) h rows).submatrix id p) + (kernelJetEntryAllowance_pos (Fintype.card α) h).le + (fun i j => boundedDegreeRealJetMatrix_entry_bound _ _ hroot hentry h rows i (p j)) + (kernelJetMinorThreshold_pos _ _ _ _ hκ) hminor + rw [← he] at hn + refine ⟨p, hp, ?_, hn⟩ + apply integerPivot_det_ne_zero_of_normalized _ _ _ + (fun o => div_pos hH (monomialScale_pos T hT (p o).val)) (fun _ => hH) + rw [he] + exact abs_pos.mp ((kernelJetMinorThreshold_pos _ _ _ _ hκ).trans_le hminor) + + +open scoped Matrix + +def remainingMatrixColumns {I J R : Type*} (A : Matrix I J R) (s : I ↪ J) : + Matrix I (UnselectedColumn s) R := A.submatrix id Subtype.val + +theorem selectedMatrix_fromCols {I J R : Type*} [Fintype I] + (A : Matrix I J R) (s : I ↪ J) : + Matrix.fromCols (A.submatrix id s) (remainingMatrixColumns A s) = + A.submatrix id (selectedColumnEquiv s) := by + ext i j + cases j <;> rfl + +theorem selectedMatrix_full_image {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I J ℤ) (s : I ↪ J) : + pivotFullImage (A.submatrix id s) (remainingMatrixColumns A s) = A.mulVecLin.range := by + rw [pivotFullImage_eq_range, selectedMatrix_fromCols] + exact integerColumnEquiv_range _ _ + +theorem selectedMatrix_smooth_law {I J : Type*} [Fintype I] [Fintype J] + (A : Matrix I J ℤ) (s : I ↪ J) (S : J → ℝ) (hS : ∀ j, 0 < S j) : + smoothIntegerImagePMF (A.submatrix id s) (remainingMatrixColumns A s) + (fun i => S (s i)) (fun j => S j.val) (fun i => hS (s i)) (fun j => hS j.val) = + smoothMatrixImagePMF A S hS := by + rw [smoothIntegerImagePMF_eq_matrix, selectedMatrix_fromCols] + have he : Sum.elim (fun i => S (s i)) (fun j : UnselectedColumn s => S j.val) = + S ∘ selectedColumnEquiv s := by + funext j + cases j <;> rfl + simp only [he] + exact smoothMatrixImagePMF_reindex A (selectedColumnEquiv s) S hS + +theorem normalized_remainingMatrixColumns {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (s : I ↪ J) (S : J → ℝ) (P : I → ℝ) : + normalizedIntegerColumns (remainingMatrixColumns A s) (fun j => S j.val) P = + remainingMatrixColumns (normalizedIntegerColumns A S P) s := by + classical + ext i j + simp only [remainingMatrixColumns, Matrix.submatrix_apply, id_eq, + normalizedIntegerColumns_entry_div] + +theorem normalized_remainingMatrixColumns_norm {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (A : Matrix I J ℤ) (s : I ↪ J) (S : J → ℝ) (P : I → ℝ) + {C : ℝ} (hC : 0 ≤ C) (hentry : ∀ i j, |normalizedIntegerColumns A S P i j| ≤ C) : + ‖matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns A s) + (fun j => S j.val) P)‖ ≤ Fintype.card (UnselectedColumn s) * C := by + classical + rw [normalized_remainingMatrixColumns] + exact matrixSupCLM_norm_le _ hC (fun i j => hentry i j.val) + +end Erdos3 + + +namespace Erdos3 + +noncomputable def normalizedScalarKernelJet {I J O : Type*} + [DecidableEq I] {L : ℕ} (x : J → IntegerScalarCubeBox I L) + (h : ℕ) (rows : O → Finset I) : Matrix O (BoundedIntegerExponent J h) ℝ := + boundedDegreeRealJetMatrix (fun j => (x j none : ℝ) / L) + (fun i j => (x j (some i) : ℝ) / L) h rows + +theorem goodScalarKernelTuple_jet_pivot {I J O : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L : ℕ} + (hL : 0 < L) (selection : I → J) (κ : ℝ) (B : ℕ) (hκ : 0 < κ) + (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple selection κ B x) + (h : ℕ) (rows : O → Finset I) (hr : Function.Injective rows) + (hrows : ∀ o, (rows o).card ≤ h) : + ∃ p : O → BoundedIntegerExponent J h, Function.Injective p ∧ + (matrixSupCLM ((normalizedScalarKernelJet x h rows).submatrix id p)).IsInvertible ∧ + ‖(matrixSupCLM ((normalizedScalarKernelJet x h rows).submatrix id p)).inverse‖ ≤ + kernelJetInverseAllowance (Fintype.card I) (Fintype.card J) (Fintype.card O) h κ := by + have hc (j : J) (i : Option I) : |(x j i : ℝ) / L| ≤ 1 := by + exact (norm_le_pi_norm (fun i => (x j i : ℝ) / L) i).trans + (integerScalarCubeBox_normalized_norm_le hL (x j)) + have hd : κ ≤ |(realDifferencePivot + (fun i j => (x j (some i) : ℝ) / L) selection).det| := by + change κ ≤ |(normalizedScalarCubePivot selection x).det| + rw [normalizedScalarCubePivot_det] + exact hx.1.le + exact realKernelJet_exists_controlled_pivot _ _ selection + (fun j => hc j none) (fun i j => hc j (some i)) hκ hd h rows hr hrows + + +noncomputable def scalarKernelIntegerJet {I J O : Type*} [DecidableEq I] [Fintype J] + {L : ℕ} (x : J → IntegerScalarCubeBox I L) (h : ℕ) (rows : O → Finset I) : + Matrix O (BoundedIntegerExponent J h) ℤ := + boundedDegreeIntegerJetMatrix (fun j => (x j none : ℤ)) (scalarCubeDifferenceMatrix x) h rows + +theorem normalizedScalarKernelJet_eq {I J O : Type*} + [DecidableEq I] [Fintype J] [Fintype O] [DecidableEq O] {L : ℕ} + (x : J → IntegerScalarCubeBox I L) (h : ℕ) (rows : O → Finset I) + {H : ℝ} (hH : H ≠ 0) : + normalizedIntegerColumns (scalarKernelIntegerJet x h rows) + (fun e => H / monomialScale (fun _ => (L : ℝ)) e.val) (fun _ => H) = + normalizedScalarKernelJet x h rows := + normalizedBoundedIntegerJetMatrix_eq _ _ _ _ _ hH + +theorem goodScalarKernelTuple_integer_jet_pivot {I J O : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L B : ℕ} {κ H : ℝ} + (hL : 0 < L) (selection : I → J) (hκ : 0 < κ) (hH : 0 < H) + (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple selection κ B x) + (h : ℕ) (rows : O → Finset I) (hr : Function.Injective rows) + (hrows : ∀ o, (rows o).card ≤ h) : + ∃ p : O → BoundedIntegerExponent J h, Function.Injective p ∧ + ((scalarKernelIntegerJet x h rows).submatrix id p).det ≠ 0 ∧ + (matrixSupCLM (normalizedIntegerPivot ((scalarKernelIntegerJet x h rows).submatrix id p) + (fun o => H / monomialScale (fun _ => (L : ℝ)) (p o).val) (fun _ => H))).IsInvertible ∧ + ‖(matrixSupCLM (normalizedIntegerPivot ((scalarKernelIntegerJet x h rows).submatrix id p) + (fun o => H / monomialScale (fun _ => (L : ℝ)) (p o).val) (fun _ => H))).inverse‖ ≤ + kernelJetInverseAllowance (Fintype.card I) (Fintype.card J) (Fintype.card O) h κ := by + have hc (j : J) (i : Option I) : |(x j i : ℝ) / L| ≤ 1 := + (norm_le_pi_norm (fun i => (x j i : ℝ) / L) i).trans + (integerScalarCubeBox_normalized_norm_le hL (x j)) + have hd : κ ≤ |(realDifferencePivot + (fun i j => (scalarCubeDifferenceMatrix x i j : ℝ) / L) selection).det| := by + change κ ≤ |(normalizedScalarCubePivot selection x).det| + rw [normalizedScalarCubePivot_det] + exact hx.1.le + exact normalizedBoundedIntegerJet_exists_pivot _ _ (fun _ => (L : ℝ)) + (fun _ => by exact_mod_cast hL) selection (fun j => hc j none) + (fun i j => hc j (some i)) hκ hH hd h rows hr hrows + + +noncomputable def kernelJetCoefficientScale (J : Type*) (h : ℕ) (L H : ℝ) + (e : BoundedIntegerExponent J h) : ℝ := H / monomialScale (fun _ => L) e.val + +theorem kernelJetCoefficientScale_pos (J : Type*) (h : ℕ) {L H : ℝ} + (hL : 0 < L) (hH : 0 < H) (e : BoundedIntegerExponent J h) : + 0 < kernelJetCoefficientScale J h L H e := + div_pos hH (monomialScale_pos _ (fun _ => hL) e.val) + +theorem kernelJetCoefficientScale_lower (J : Type*) (h : ℕ) {L H : ℝ} + (hL : 1 ≤ L) (hH : 0 ≤ H) (e : BoundedIntegerExponent J h) : + H / L ^ h ≤ kernelJetCoefficientScale J h L H e := + kernelCoefficientScale_lower _ (fun _ => zero_lt_one.trans_le hL) hH hL (fun _ => le_rfl) e.val e.property + +theorem normalized_scalarKernel_pivot {I J O : Type*} [DecidableEq I] [Fintype J] + [Fintype O] [DecidableEq O] {L : ℕ} (x : J → IntegerScalarCubeBox I L) + (h : ℕ) (rows : O → Finset I) (p : O → BoundedIntegerExponent J h) + {H : ℝ} (hH : H ≠ 0) : + normalizedIntegerPivot ((scalarKernelIntegerJet x h rows).submatrix id p) + (fun o => kernelJetCoefficientScale J h L H (p o)) (fun _ => H) = + (normalizedScalarKernelJet x h rows).submatrix id p := by + have he := congrArg (fun A : Matrix O (BoundedIntegerExponent J h) ℝ => A.submatrix id p) + (normalizedScalarKernelJet_eq x h rows hH) + rw [normalizedIntegerColumns_submatrix] at he + exact he + +theorem goodScalarKernelTuple_fixed_jet_pivot {I J O : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L B : ℕ} {κ : ℝ} + (hL : 0 < L) (selection : I → J) (hκ : 0 < κ) + (x : J → IntegerScalarCubeBox I L) (hx : GoodScalarKernelTuple selection κ B x) + (h : ℕ) (rows : O → Finset I) (hr : Function.Injective rows) (hrows : ∀ o, (rows o).card ≤ h) : + ∃ s : O ↪ BoundedIntegerExponent J h, + ((scalarKernelIntegerJet x h rows).submatrix id s).det ≠ 0 ∧ + ∀ H : ℝ, H ≠ 0 → + ‖(matrixSupCLM (normalizedIntegerPivot ((scalarKernelIntegerJet x h rows).submatrix id s) + (fun o => kernelJetCoefficientScale J h L H (s o)) (fun _ => H))).inverse‖ ≤ + kernelJetInverseAllowance (Fintype.card I) (Fintype.card J) (Fintype.card O) h κ := by + obtain ⟨p, hp, hd, _, hn⟩ := goodScalarKernelTuple_integer_jet_pivot hL selection hκ + (show (0 : ℝ) < 1 by norm_num) x hx h rows hr hrows + refine ⟨⟨p, hp⟩, hd, fun H hH => ?_⟩ + change ‖(matrixSupCLM (normalizedIntegerPivot ((scalarKernelIntegerJet x h rows).submatrix id p) + (fun o => kernelJetCoefficientScale J h L H (p o)) (fun _ => H))).inverse‖ ≤ _ + rw [normalized_scalarKernel_pivot x h rows p hH] + change ‖(matrixSupCLM (normalizedIntegerPivot ((scalarKernelIntegerJet x h rows).submatrix id p) + (fun o => kernelJetCoefficientScale J h L 1 (p o)) (fun _ => 1))).inverse‖ ≤ _ at hn + rwa [normalized_scalarKernel_pivot x h rows p one_ne_zero] at hn + +theorem fromCols_left_pivot {O J N R : Type*} (A : Matrix O J R) (C : Matrix O N R) + (s : O ↪ J) : + (Matrix.fromCols A C).submatrix id (s.trans Function.Embedding.inl) = A.submatrix id s := by + ext i j + rfl + +theorem scalarKernelJet_extended_period {I J O N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype O] [Fintype N] + {L B : ℕ} {κ : ℝ} (selection : I → J) (x : J → IntegerScalarCubeBox I L) + (hx : GoodScalarKernelTuple selection κ B x) (h : ℕ) (rows : O → Finset I) + (hr : Function.Injective rows) (hrows : ∀ o, (rows o).card ≤ h) (C : Matrix O N ℤ) : + HasBoundedScalarPeriod (Matrix.fromCols (scalarKernelIntegerJet x h rows) C).mulVecLin.range (B ^ h) := by + obtain ⟨a, ha, haB, hp⟩ := hx.2 + refine ⟨a ^ h, pow_pos ha h, Nat.pow_le_pow_left haB h, ?_⟩ + rw [integerMatrix_fromCols_range, Nat.cast_pow] + exact (boundedDegreeIntegerJetMatrix_period _ _ (a : ℤ) hp h rows hr hrows).trans le_sup_left + +theorem scalarKernelJet_extended_index {I J O N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype O] [Fintype N] + {L B : ℕ} {κ : ℝ} (selection : I → J) (x : J → IntegerScalarCubeBox I L) + (hx : GoodScalarKernelTuple selection κ B x) (h : ℕ) (rows : O → Finset I) + (hr : Function.Injective rows) (hrows : ∀ o, (rows o).card ≤ h) (C : Matrix O N ℤ) : + (Matrix.fromCols (scalarKernelIntegerJet x h rows) C).mulVecLin.range.toAddSubgroup.index ≤ + (B ^ h) ^ Fintype.card O := + hasBoundedScalarPeriod_index_le _ _ (scalarKernelJet_extended_period selection x hx h rows hr hrows C) + + +noncomputable def scalarKernelFixedPivot {α J O : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L : ℕ} + (hL : 0 < L) (x : J → IntegerScalarCubeBox α L) (degree : ℕ) + (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent J degree) + (hs : ((scalarKernelIntegerJet x degree rows).submatrix id s).det ≠ 0) : + (O → ℝ) ≃L[ℝ] (O → ℝ) := + normalizedPivotEquiv _ hs (fun i => kernelJetCoefficientScale J degree L 1 (s i)) + (fun _ => 1) (fun i => kernelJetCoefficientScale_pos J degree (by exact_mod_cast hL) zero_lt_one (s i)) + (fun _ => zero_lt_one) + +noncomputable def scalarKernelFixedFree {α J O : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L : ℕ} + (x : J → IntegerScalarCubeBox α L) (degree : ℕ) + (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent J degree) : + (UnselectedColumn s → ℝ) →L[ℝ] (O → ℝ) := + matrixSupCLM (remainingMatrixColumns (normalizedScalarKernelJet x degree rows) s) + +theorem scalarKernel_pivot_scale_independent {α J O : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L : ℕ} + (hL : 0 < L) (x : J → IntegerScalarCubeBox α L) (degree : ℕ) + (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent J degree) + (hs : ((scalarKernelIntegerJet x degree rows).submatrix id s).det ≠ 0) + {H : ℝ} (hH : 0 < H) : + normalizedPivotEquiv _ hs (fun i => kernelJetCoefficientScale J degree L H (s i)) + (fun _ => H) (fun i => kernelJetCoefficientScale_pos J degree (by exact_mod_cast hL) hH (s i)) + (fun _ => hH) = scalarKernelFixedPivot hL x degree rows s hs := by + ext v i + change ((normalizedPivotEquiv _ hs _ _ _ _).toContinuousLinearMap v) i = + ((scalarKernelFixedPivot hL x degree rows s hs).toContinuousLinearMap v) i + simp only [scalarKernelFixedPivot, normalizedPivotEquiv_coe, + normalized_scalarKernel_pivot x degree rows s hH.ne', + normalized_scalarKernel_pivot x degree rows s one_ne_zero] + +theorem scalarKernel_free_scale_independent {α J O : Type*} + [Fintype α] [DecidableEq α] [Fintype J] [DecidableEq J] + [Fintype O] [DecidableEq O] {L : ℕ} + (x : J → IntegerScalarCubeBox α L) (degree : ℕ) + (rows : O → Finset α) (s : O ↪ BoundedIntegerExponent J degree) + {H : ℝ} (hH : H ≠ 0) : + matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns (scalarKernelIntegerJet x degree rows) s) + (fun j => kernelJetCoefficientScale J degree L H j.val) (fun _ => H)) = + scalarKernelFixedFree x degree rows s := by + rw [normalized_remainingMatrixColumns] + unfold scalarKernelFixedFree + apply congrArg matrixSupCLM + ext i j + change normalizedIntegerColumns (scalarKernelIntegerJet x degree rows) + (kernelJetCoefficientScale J degree L H) (fun _ => H) i j.val = + normalizedScalarKernelJet x degree rows i j.val + have he := congrFun (congrFun (normalizedScalarKernelJet_eq x degree rows hH) i) j.val + simpa only [normalizedIntegerColumns_entry_div, kernelJetCoefficientScale] using he + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/KernelSupportContraction.lean b/lean/OAI/Combinatorics/Progressions/Linear/KernelSupportContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..40c2ed5ab952c9d578ad494e0c08109ff3e65ed7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/KernelSupportContraction.lean @@ -0,0 +1,167 @@ +import OAI.Combinatorics.Progressions.Estimates.PartialProductDifference +import OAI.Combinatorics.Progressions.Probability.ProductMixedLaws + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (Y i)] + +noncomputable def productKernelApply (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) + (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : ℝ := + (FiniteProbabilityWeights.pi (fun i => K i (x i))).mean f + +theorem productKernelApply_eq_matrix (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) + (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productKernelApply K f x = productMatrixApply (fun i x y => (K i x).weight y) f x := rfl + +theorem productKernelApply_conditional (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) + (ν : ∀ i, FiniteProbabilityWeights (Y i)) (S : Finset ι) + (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productKernelApply K (productConditionalMean ν S f) x = + (FiniteProbabilityWeights.pi (fun i => if i ∈ S then K i (x i) else ν i)).mean f := + productMean_mix_laws (fun i => K i (x i)) ν S f + +theorem productKernelApply_sum {J : Type*} (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) + (D : Finset J) (f : J → (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productKernelApply K (fun y => ∑ j ∈ D, f j y) x = ∑ j ∈ D, productKernelApply K (f j) x := + FiniteProbabilityWeights.mean_sum _ D f + +theorem productKernelApply_smul (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) + (c : ℝ) (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productKernelApply K (fun y => c * f y) x = c * productKernelApply K f x := + FiniteProbabilityWeights.mean_const_mul _ c f + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (Y i)] + +noncomputable def anovaKernelMatrix (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (S : Finset ι) + (i : ι) (x : X i) (y : Y i) : ℝ := + if i ∈ S then centeredKernelMatrix (ν i) (K i) x y else (ν i).weight y + +theorem productKernelApply_ANOVA (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (S : Finset ι) + (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productKernelApply K (productANOVA ν S f) x = productMatrixApply (anovaKernelMatrix ν K S) f x := by + have hT (T : Finset ι) : productKernelApply K (productConditionalMean ν T f) x = + ∑ y, (∏ i, if i ∈ T then (K i (x i)).weight (y i) else (ν i).weight (y i)) * f y := by + rw [productKernelApply_conditional] + simp only [FiniteProbabilityWeights.mean, FiniteProbabilityWeights.pi] + apply Finset.sum_congr rfl + intro y _ + congr 1 + apply Finset.prod_congr rfl + intro i _ + by_cases hi : i ∈ T <;> simp only [hi, ite_true, ite_false] + change productKernelApply K (fun y => ∑ U ∈ S.powerset, + (-1 : ℝ) ^ U.card * productConditionalMean ν (S \ U) f y) x = _ + rw [productKernelApply_sum] + simp_rw [productKernelApply_smul, hT, Finset.mul_sum] + rw [Finset.sum_comm] + unfold productMatrixApply + apply Finset.sum_congr rfl + intro y _ + calc + _ = (∑ U ∈ S.powerset, (-1 : ℝ) ^ U.card * + (∏ i, if i ∈ S \ U then (K i (x i)).weight (y i) else (ν i).weight (y i))) * f y := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro U _ + ring + _ = _ := by + rw [partial_product_difference] + rfl + +theorem productKernelApply_ANOVA_active (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (S : Finset ι) + (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productMatrixApply (anovaKernelMatrix ν K S) (productANOVA ν S f) x = + productKernelApply K (productANOVA ν S f) x := by + rw [← productKernelApply_ANOVA] + have he : productANOVA ν S (productANOVA ν S f) = productANOVA ν S f := + funext (productANOVA_idempotent ν S f) + rw [he] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i (f : Y i → ℝ), (ν i).mean f = 0 → + (μ i).mean (fun x => (K i x).mean f ^ 2) ≤ C i * (ν i).mean (fun y => f y ^ 2)) + +include hC hbound + +theorem anovaKernelMatrix_sq_le (S : Finset ι) (f : (∀ i, Y i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productMatrixApply (anovaKernelMatrix ν K S) f x ^ 2) ≤ + (∏ i ∈ S, C i) * (FiniteProbabilityWeights.pi ν).mean (fun y => f y ^ 2) := by + have hc (i : ι) : 0 ≤ if i ∈ S then C i else 1 := by + split_ifs + · exact hC i + · exact zero_le_one + have ha (i : ι) (g : Y i → ℝ) : + (μ i).mean (fun x => (∑ y, anovaKernelMatrix ν K S i x y * g y) ^ 2) ≤ + (if i ∈ S then C i else 1) * (ν i).mean (fun y => g y ^ 2) := by + by_cases hi : i ∈ S + · simp only [anovaKernelMatrix, hi, ite_true] + exact centeredKernelMatrix_sq_le (μ i) (ν i) (K i) (hC i) (hbound i) g + · simp only [anovaKernelMatrix, hi, ite_false, one_mul] + change (μ i).mean (fun _ => (ν i).mean g ^ 2) ≤ _ + rw [FiniteProbabilityWeights.mean_const] + exact (ν i).mean_square_le g + simpa only [Fintype.prod_ite_mem] using + productMatrixApply_sq_le μ ν (anovaKernelMatrix ν K S) (fun i => if i ∈ S then C i else 1) hc ha f + +theorem productKernelApply_ANOVA_sq_le (S : Finset ι) (f : (∀ i, Y i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productKernelApply K (productANOVA ν S f) x ^ 2) ≤ + (∏ i ∈ S, C i) * (FiniteProbabilityWeights.pi ν).mean (fun y => productANOVA ν S f y ^ 2) := by + simpa only [productKernelApply_ANOVA_active] using + anovaKernelMatrix_sq_le μ ν K C hC hbound S (productANOVA ν S f) + +theorem productCouplingPairing_support_sq_le + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + (S : Finset ι) (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : + productCouplingPairing (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) + (productANOVA μ S w) (productANOVA ν S f) ^ 2 ≤ + (∏ i ∈ S, C i) * (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ S w x ^ 2) * + (FiniteProbabilityWeights.pi ν).mean (fun y => productANOVA ν S f y ^ 2) := by + rw [productCouplingPairing_ofKernel] + change ((FiniteProbabilityWeights.pi μ).mean + (fun x => productANOVA μ S w x * productKernelApply K (productANOVA ν S f) x)) ^ 2 ≤ _ + have hcs := (FiniteProbabilityWeights.pi μ).mean_mul_sq_le (productANOVA μ S w) + (productKernelApply K (productANOVA ν S f)) + have hn := productKernelApply_ANOVA_sq_le μ ν K C hC hbound S f + have hm := mul_le_mul_of_nonneg_left hn + ((FiniteProbabilityWeights.pi μ).mean_nonneg (fun x => sq_nonneg (productANOVA μ S w x))) + exact (hcs.trans hm).trans_eq (by ring) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LayerOneCoefficientBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/LayerOneCoefficientBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..873f69378ef87cce729883eb1eb113682ff14c25 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LayerOneCoefficientBasis.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.Progressions.Geometry.RealFastCoefficientCoordinates + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +abbrev LayerOneBasisIndex (ω : ι → ℕ) := {i : ι // ¬ 2 ≤ ω i} + +noncomputable def layerOneBasis : Basis (LayerOneBasisIndex ω) ℚ (L ⧸ F.layer 2) := + supportedQuotientBasis e (F.layer 2) {i | 2 ≤ ω i} (hF 2) + +theorem layerOneBasis_repr_mk (x : L) (i : LayerOneBasisIndex ω) : + (F.layerOneBasis e ω hF).repr ((F.layer 2).mkQ x) i = e.repr x i := + supportedQuotientBasis_repr_mk e (F.layer 2) {i | 2 ≤ ω i} (hF 2) x i + +def horizontalCoefficientIndex (w : σ → ℕ) (i : LayerOneBasisIndex ω) : + FirstCoefficientIndex w ω := + ⟨(0, i.val), by + have hp := F.adaptedBasis_weight_pos e ω hF i.val + have hi := i.property + simp only [map_zero, Nat.zero_add] + omega⟩ + +def layerOneIndexOfConstant (w : σ → ℕ) (z : FirstCoefficientIndex w ω) + (hz : z.val.1 = 0) : LayerOneBasisIndex ω := + ⟨z.val.2, by + have h := z.property + rw [hz, map_zero] at h + omega⟩ + +theorem horizontalCoefficientIndex_of_constant (w : σ → ℕ) + (z : FirstCoefficientIndex w ω) (hz : z.val.1 = 0) : + F.horizontalCoefficientIndex e ω hF w (layerOneIndexOfConstant ω w z hz) = z := by + apply Subtype.ext + exact Prod.ext hz.symm rfl + +theorem firstCoefficientHorizontal_coordinates (w : σ → ℕ) + (x : F.FirstCoefficientModule w) (i : LayerOneBasisIndex ω) : + (F.layerOneBasis e ω hF).repr (F.firstCoefficientHorizontal w x) i = + (F.firstCoefficientBasis e ω hF w).repr x (F.horizontalCoefficientIndex e ω hF w i) := by + obtain ⟨x, rfl⟩ := F.firstCoefficientMap_surjective w x + rw [F.firstCoefficientHorizontal_map, F.layerOneBasis_repr_mk, + F.firstCoefficientBasis_repr_map] + rfl + +theorem realFirstCoefficientHorizontal_coordinates (w : σ → ℕ) + (x : F.RealFirstCoefficientModule w) (i : LayerOneBasisIndex ω) : + ((F.layerOneBasis e ω hF).baseChange ℝ).repr (F.realFirstCoefficientHorizontal w x) i = + (F.realFirstCoefficientBasis e ω hF w).repr x + (F.horizontalCoefficientIndex e ω hF w i) := by + obtain ⟨x, rfl⟩ := (F.firstCoefficientRealEquiv w).surjective x + change ((F.layerOneBasis e ω hF).baseChange ℝ).repr + ((F.firstCoefficientHorizontal w).baseChange ℝ + ((F.firstCoefficientRealEquiv w).symm (F.firstCoefficientRealEquiv w x))) i = _ + rw [LinearEquiv.symm_apply_apply, F.firstCoefficientRealEquiv_coordinates] + exact baseChange_coordinate_eq (F.firstCoefficientBasis e ω hF w) + (F.layerOneBasis e ω hF) (F.firstCoefficientHorizontal w) + (F.horizontalCoefficientIndex e ω hF w) + (F.firstCoefficientHorizontal_coordinates e ω hF w) x i + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LayerOneProjectionMatrixBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/LayerOneProjectionMatrixBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..20355a08f70acde06656a090736e2fd7e9df6470 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LayerOneProjectionMatrixBounds.lean @@ -0,0 +1,197 @@ +import Mathlib.LinearAlgebra.LinearIndependent.Basic +import Mathlib.LinearAlgebra.TensorProduct.Tower +import OAI.Combinatorics.Progressions.Geometry.ControlledLayerOneCoordinates +import OAI.Combinatorics.Progressions.Geometry.LayerOneTransportBudget + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct Matrix + +theorem rational_horizontal_basis_transport + {V ι κ ν : Type*} [AddCommGroup V] [Module ℚ V] + [Fintype ι] [Fintype κ] [DecidableEq κ] + (b : Basis ι ℚ V) (η : (κ → ℝ) ≃ₗ[ℝ] (ℝ ⊗[ℚ] V)) + (A : Matrix ι κ ℚ) + (hA : ∀ x, (b.baseChange ℝ).equivFun (η x) = A.map (Rat.castHom ℝ) *ᵥ x) + (K : Submodule ℝ (κ → ℝ)) (Q : Matrix κ ν ℚ) + (hK : K = Submodule.span ℝ (Set.range (Q.map (Rat.castHom ℝ)).col)) + (hQ : LinearIndependent ℝ (Q.map (Rat.castHom ℝ)).col) + {H J : ℕ} (hAH : ∀ i j, RationalHeightLE (A i j) H) + (hQJ : ∀ i j, RationalHeightLE (Q i j) J) : + ∃ v : ν → V, + (∀ j, (1 : ℝ) ⊗ₜ[ℚ] v j = η ((Q.map (Rat.castHom ℝ)).col j)) ∧ + K.map η.toLinearMap = (Submodule.span ℚ (Set.range v)).baseChange ℝ ∧ + LinearIndependent ℚ v ∧ + ∀ i j, RationalHeightLE (b.repr (v j) i) ((Fintype.card κ + 1) * (H * J) ^ Fintype.card κ) := by + let v : ν → V := fun j => b.equivFun.symm ((A * Q).col j) + have hvc (i : ι) (j : ν) : b.repr (v j) i = (A * Q) i j := + congrFun (b.equivFun.apply_symm_apply ((A * Q).col j)) i + have hv (j : ν) : (1 : ℝ) ⊗ₜ[ℚ] v j = η ((Q.map (Rat.castHom ℝ)).col j) := by + apply (b.baseChange ℝ).equivFun.injective + rw [hA] + funext i + rw [Basis.equivFun_apply, Basis.baseChange_repr_tmul, hvc] + simp [Matrix.mul_apply, Matrix.mulVec, dotProduct, Algebra.smul_def] + refine ⟨v, hv, ?_, ?_, ?_⟩ + · rw [hK, Submodule.map_span, Submodule.baseChange_span] + congr 1 + ext x + constructor + · rintro ⟨_, ⟨j, rfl⟩, rfl⟩ + exact ⟨v j, ⟨j, rfl⟩, hv j⟩ + · rintro ⟨_, ⟨j, rfl⟩, rfl⟩ + exact ⟨_, ⟨j, rfl⟩, (hv j).symm⟩ + · have hreal : LinearIndependent ℝ (fun j => (1 : ℝ) ⊗ₜ[ℚ] v j) := by + simpa only [hv, Function.comp_def, LinearEquiv.coe_coe] using + hQ.map' η.toLinearMap (LinearMap.ker_eq_bot.mpr η.injective) + apply LinearIndependent.of_comp (TensorProduct.mk ℚ ℝ V 1) + exact LinearIndependent.restrict_scalars' ℚ hreal + · intro i j + rw [hvc] + exact rationalHeightLE_matrix_mul A Q hAH hQJ i j + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct Matrix + +variable {σ ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s a d : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (w : σ → ℕ) (hw : ∀ i, 0 < w i) + (U : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + (b : Basis (Fin d) ℝ (F.RealFirstCoefficientModule w ⧸ + F.realFirstCoefficientFastSubmodule w hw U)) + (ha : a ≤ d) (η : (Fin a → ℝ) ≃ₗ[ℝ] (ℝ ⊗[ℚ] (L ⧸ F.layer 2))) + (hη : ∀ x, η (fun i => b.equivFun x (Fin.castLE ha i)) = F.realFastCoefficientHorizontal w hw U x) + (R : (Fin d → ℝ) →ₗ[ℝ] F.RealFirstCoefficientModule w) + (hR : ∀ y, (F.realFirstCoefficientFastSubmodule w hw U).mkQ (R y) = b.equivFun.symm y) + (l m : ℕ) (hm : 0 < m) (C : ℝ) (hC : 0 ≤ C) + (hgrid : ∀ y, y ∈ realDenominatorGrid l → F.FirstCoefficientGrid e ω hF w m (R y)) + (hbound : ∀ (y : Fin d → ℝ) (M : ℝ), 0 ≤ M → (∀ j, |y j| ≤ M) → + F.FirstCoefficientSlowBound e ω hF w (fun _ => 1) (C * M) (R y)) + +include hη hR hm hC hgrid hbound + +theorem layerOne_equiv_rational_matrix : + ∃ A : Matrix (LayerOneBasisIndex ω) (Fin a) ℚ, + (∀ i j, RationalHeightLE (A i j) (max m (Nat.ceil ((m : ℝ) * C)))) ∧ + ∀ x, ((F.layerOneBasis e ω hF).baseChange ℝ).equivFun (η x) = + A.map (Rat.castHom ℝ) *ᵥ x := by + exact exists_bounded_rational_map_matrix + (((F.layerOneBasis e ω hF).baseChange ℝ).equivFun.toLinearMap.comp η.toLinearMap) + m hm (fun j => F.layerOne_equiv_grid e ω hF w hw U b ha η hη l m R hR hgrid + (Pi.single j 1) (realDenominatorGrid_single l j)) C + (F.layerOne_equiv_norm e ω hF w hw U b ha η hη C hC R hR hbound) + +theorem layerOne_rational_kernel_basis {ν : Type*} + (K : Submodule ℝ (Fin a → ℝ)) (Q : Matrix (Fin a) ν ℚ) + (hK : K = Submodule.span ℝ (Set.range (Q.map (Rat.castHom ℝ)).col)) + (hQ : LinearIndependent ℝ (Q.map (Rat.castHom ℝ)).col) + {J : ℕ} (hQJ : ∀ i j, RationalHeightLE (Q i j) J) : + ∃ v : ν → L ⧸ F.layer 2, + (∀ j, (1 : ℝ) ⊗ₜ[ℚ] v j = η ((Q.map (Rat.castHom ℝ)).col j)) ∧ + K.map η.toLinearMap = (Submodule.span ℚ (Set.range v)).baseChange ℝ ∧ + LinearIndependent ℚ v ∧ + ∀ i j, RationalHeightLE ((F.layerOneBasis e ω hF).repr (v j) i) + ((a + 1) * (max m (Nat.ceil ((m : ℝ) * C)) * J) ^ a) := by + obtain ⟨A, hA, heq⟩ := F.layerOne_equiv_rational_matrix e ω hF w hw U b ha η hη + R hR l m hm C hC hgrid hbound + simpa only [Fintype.card_fin] using rational_horizontal_basis_transport + (F.layerOneBasis e ω hF) η A heq K Q hK hQ hA hQJ + +theorem derivative_system_layerOne_rational_basis [Fintype σ] [DecidableEq σ] + (T : σ → ℝ) (Y : (σ → ℝ) →ₗ[ℝ] (Fin d → ℝ)) + (A : (Fin d → ℝ) ≃ₗ[ℝ] (Fin d → ℝ)) (scale : Fin d → ℝ) (B : ℝ) + (D : CoordinateDerivativeSystem ha T Y A scale B) + (p : ℝ) (hp : 0 ≤ p) (hap : (a : ℝ) ≤ p) (hmp : (m : ℝ) ≤ Real.exp p) + (hCp : C ≤ Real.exp p) (hJp : (D.heightBound : ℝ) ≤ Real.exp p) : + ∃ v : Fin D.k → L ⧸ F.layer 2, + (∀ j, (1 : ℝ) ⊗ₜ[ℚ] v j = η ((D.basisMatrix.map (Rat.castHom ℝ)).col j)) ∧ + D.K.map η.toLinearMap = (Submodule.span ℚ (Set.range v)).baseChange ℝ ∧ + LinearIndependent ℚ v ∧ + ∀ i j, (((F.layerOneBasis e ω hF).repr (v j) i).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 3) ∧ + (((F.layerOneBasis e ω hF).repr (v j) i).den : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + obtain ⟨v, hv, hspan, hli, hheight⟩ := F.layerOne_rational_kernel_basis e ω hF w hw U + b ha η hη R hR l m hm C hC hgrid hbound D.K D.basisMatrix D.span_eq D.independent_real D.basis_height + refine ⟨v, hv, hspan, hli, fun i j => ?_⟩ + have hbudget := layerOne_basis_transport_height_le_exp a m D.heightBound C p hp hap hmp hC hCp hJp + exact ⟨(Nat.cast_le.mpr (hheight i j).1).trans hbudget, + (Nat.cast_le.mpr (hheight i j).2).trans hbudget⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct NNReal Matrix + +variable {σ ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s a d : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (w : σ → ℕ) (hw : ∀ i, 0 < w i) + (U : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + (b : Basis (Fin d) ℝ (F.RealFirstCoefficientModule w ⧸ + F.realFirstCoefficientFastSubmodule w hw U)) + (ha : a ≤ d) (η : (Fin a → ℝ) ≃ₗ[ℝ] (ℝ ⊗[ℚ] (L ⧸ F.layer 2))) + (hη : ∀ x, η (fun i => b.equivFun x (Fin.castLE ha i)) = F.realFastCoefficientHorizontal w hw U x) + (A : Matrix (LayerOneBasisIndex ω) (Fin a) ℚ) + (hA : ∀ x, ((F.layerOneBasis e ω hF).baseChange ℝ).equivFun (η x) = + A.map (Rat.castHom ℝ) *ᵥ x) + +include hη hA + +theorem layerOne_projection_matrix (x : F.RealFirstCoefficientModule w ⧸ + F.realFirstCoefficientFastSubmodule w hw U) : + ((F.layerOneBasis e ω hF).baseChange ℝ).equivFun (F.realFastCoefficientHorizontal w hw U x) = + A.map (Rat.castHom ℝ) *ᵥ (fun i => b.equivFun x (Fin.castLE ha i)) := by + rw [← hη, hA] + +theorem layerOne_projection_grid (l : ℕ) (x : F.RealFirstCoefficientModule w ⧸ + F.realFirstCoefficientFastSubmodule w hw U) (hx : b.equivFun x ∈ realDenominatorGrid l) : + ((F.layerOneBasis e ω hF).baseChange ℝ).equivFun (F.realFastCoefficientHorizontal w hw U x) ∈ + realDenominatorGrid (matrixDenominator A * l) := by + rw [F.layerOne_projection_matrix e ω hF w hw U b ha η hη A hA x] + exact real_matrix_denominator_grid A l _ (realDenominatorGrid_comp l _ hx (Fin.castLE ha)) + +theorem layerOne_projection_scaled_norm {J : ℕ} (hAJ : ∀ i j, RationalHeightLE (A i j) J) + (scale : Fin d → ℝ) (hscale : ∀ i : Fin a, scale (Fin.castLE ha i) = 1) + (x : F.RealFirstCoefficientModule w ⧸ F.realFirstCoefficientFastSubmodule w hw U) : + ‖((F.layerOneBasis e ω hF).baseChange ℝ).equivFun (F.realFastCoefficientHorizontal w hw U x)‖ ≤ + ((a : ℝ) + 1) * (J + 1) * + ‖(EuclideanSpace.equiv (Fin d) ℝ).symm (fun j => scale j * b.equivFun x j)‖ := by + rw [F.layerOne_projection_matrix e ω hF w hw U b ha η hη A hA x] + have hinit : ‖(fun i : Fin a => b.equivFun x (Fin.castLE ha i))‖ ≤ + ‖(EuclideanSpace.equiv (Fin d) ℝ).symm (fun j => scale j * b.equivFun x j)‖ := by + apply (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr + intro i + have h := PiLp.norm_apply_le + ((EuclideanSpace.equiv (Fin d) ℝ).symm (fun j => scale j * b.equivFun x j)) (Fin.castLE ha i) + change ‖scale (Fin.castLE ha i) * b.equivFun x (Fin.castLE ha i)‖ ≤ _ at h + rw [hscale, one_mul] at h + exact h + have hmat := norm_matrix_mulVec_le (A.map (Rat.castHom ℝ)) (J : ℝ≥0) + (fun i j => (hAJ i j).abs_real_le) (fun i => b.equivFun x (Fin.castLE ha i)) + simp only [Fintype.card_fin] at hmat + exact hmat.trans (mul_le_mul_of_nonneg_left hinit (by positivity)) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LieKernelRealificationMark.lean b/lean/OAI/Combinatorics/Progressions/Linear/LieKernelRealificationMark.lean new file mode 100644 index 0000000000000000000000000000000000000000..79a15e46be55aa83bd60beb33d6ee33909b500d1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LieKernelRealificationMark.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Estimates.PetalComparisonTree + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +theorem mem_realificationLieKernel_iff (φ : L →ₗ⁅ℚ⁆ M) (x : ℝ ⊗[ℚ] L) : + x ∈ (LinearMap.ker φ.toLinearMap).baseChange ℝ ↔ realificationLieHom φ x = 0 := by + rw [real_baseChange_ker] + rfl + +theorem realificationLieSubalgebra_ker (φ : L →ₗ⁅ℚ⁆ M) : + realificationLieSubalgebra φ.ker.toLieSubalgebra = + (realificationLieHom φ).ker.toLieSubalgebra := by + ext x + change x ∈ (LinearMap.ker φ.toLinearMap).baseChange ℝ ↔ realificationLieHom φ x = 0 + exact mem_realificationLieKernel_iff φ x + +namespace NilpotentLieBCHGroup + +variable {s t : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +theorem coord_mem_realificationKernel_iff (φ : L →ₗ⁅ℚ⁆ M) + (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) : + g.coord ∈ (LinearMap.ker φ.toLinearMap).baseChange ℝ ↔ + realificationMap (hnil := hnil) (hM := hM) φ g = 1 := by + rw [mem_realificationLieKernel_iff] + constructor + · intro h + exact ext h + · intro h + exact congrArg coord h + +theorem mem_realificationSubgroup_ker_iff (φ : L →ₗ⁅ℚ⁆ M) + (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) : + g ∈ realificationSubgroup (hnil := hnil) φ.ker.toLieSubalgebra ↔ + realificationMap (hnil := hnil) (hM := hM) φ g = 1 := by + change g.coord ∈ (LinearMap.ker φ.toLinearMap).baseChange ℝ ↔ _ + exact coord_mem_realificationKernel_iff φ g + +theorem realificationSubgroup_ker (φ : L →ₗ⁅ℚ⁆ M) : + realificationSubgroup (hnil := hnil) φ.ker.toLieSubalgebra = + (realificationMap (hnil := hnil) (hM := hM) φ).ker := by + ext g + exact mem_realificationSubgroup_ker_iff φ g + +theorem exists_realificationKernel_lift (φ : L →ₗ⁅ℚ⁆ M) + (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) + (hg : realificationMap (hnil := hnil) (hM := hM) φ g = 1) : + ∃ x : NilpotentLieBCHGroup (ℝ ⊗[ℚ] φ.ker.toLieSubalgebra) s + (realification_lowerCentralSeries_eq_bot + (lie_subalgebra_lowerCentralSeries_eq_bot hnil φ.ker.toLieSubalgebra)), + realificationMap + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil φ.ker.toLieSubalgebra) + (hM := hnil) φ.ker.toLieSubalgebra.incl x = g := by + have hm := (mem_realificationSubgroup_ker_iff φ g).mpr hg + rw [← realificationMap_incl_range] at hm + exact hm + +end NilpotentLieBCHGroup +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LieWordProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/LieWordProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c22af971f2743fa951f27fefc3478b1fbad0b85 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LieWordProjection.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Estimates.FreePrimitiveCriterion + +namespace OAI + +section + +namespace Erdos3 + +variable {X : Type*} + +noncomputable def lieWordSubalgebra : LieSubalgebra ℚ (WordPolynomial X) := + LieSubalgebra.lieSpan ℚ (WordPolynomial X) + (Set.range (fun x : X => MonoidAlgebra.single (FreeSemigroup.of x) (1 : ℚ))) + +theorem commutatorTree_mem_lieWordSubalgebra (t : FreeMagma X) : + commutatorTree t ∈ lieWordSubalgebra := by + induction t using FreeMagma.rec with + | of x => exact LieSubalgebra.subset_lieSpan ⟨x, rfl⟩ + | mul u v hu hv => exact lieWordSubalgebra.lie_mem hu hv + +theorem freeLieWordExpansion_range : + (freeLieWordExpansion (X := X)).range = lieWordSubalgebra := by + apply le_antisymm + · intro p hp + obtain ⟨x, rfl⟩ := (LieHom.mem_range _ _).mp hp + apply freeLie_linear_induction (fun x => freeLieWordExpansion x ∈ lieWordSubalgebra) + · simpa only [map_zero] using lieWordSubalgebra.zero_mem + · intro x y hx hy + rw [map_add] + exact lieWordSubalgebra.add_mem hx hy + · intro r x hx + rw [map_smul] + exact lieWordSubalgebra.smul_mem r hx + · intro t + rw [freeLieWordExpansion_tree] + exact commutatorTree_mem_lieWordSubalgebra t + · apply LieSubalgebra.lieSpan_le.mpr + rintro p ⟨x, rfl⟩ + exact (LieHom.mem_range _ _).mpr ⟨FreeLieAlgebra.of ℚ x, freeLieWordExpansion_of x⟩ + +noncomputable def lieWordProjection : WordPolynomial X →ₗ[ℚ] WordPolynomial X := + freeLieWordExpansion.toLinearMap.comp (dynkinProjection (FreeLieAlgebra.of ℚ)) + +@[simp] theorem lieWordProjection_apply (p : WordPolynomial X) : + lieWordProjection p = freeLieWordExpansion (dynkinProjection (FreeLieAlgebra.of ℚ) p) := rfl + +theorem lieWordProjection_idempotent (p : WordPolynomial X) : + lieWordProjection (lieWordProjection p) = lieWordProjection p := by + simp only [lieWordProjection_apply, dynkinProjection_freeLieWordExpansion] + +theorem lieWordProjection_eq_self_iff (p : WordPolynomial X) : + lieWordProjection p = p ↔ p ∈ lieWordSubalgebra := by + rw [← freeLieWordExpansion_range] + constructor + · intro h + exact (LieHom.mem_range _ _).mpr ⟨dynkinProjection (FreeLieAlgebra.of ℚ) p, h⟩ + · intro h + obtain ⟨x, rfl⟩ := (LieHom.mem_range _ _).mp h + simp only [lieWordProjection_apply, dynkinProjection_freeLieWordExpansion] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LinearRelativeActualRankBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/LinearRelativeActualRankBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f54627f0ea677a304c6543f63ea1b63f5bb19d4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LinearRelativeActualRankBudget.lean @@ -0,0 +1,33 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativePatchAmplification + +namespace OAI + +section + +namespace Erdos3 + +theorem relative_actual_rank_reconstruction_le + {s d d₀ old removed : ℕ} (hremoved : removed ≤ old) + (hreturned : d ≤ d₀ + s * (old - removed)) : + d + s * removed ≤ d₀ + s * old := by + calc + d + s * removed ≤ d₀ + s * (old - removed) + s * removed := + Nat.add_le_add_right hreturned _ + _ = d₀ + s * old := by + rw [Nat.add_assoc, ← Nat.mul_add, Nat.sub_add_cancel hremoved] + +theorem relative_actual_rank_reconstruction_budget + {s d removed bound : ℕ} {childCost p : ℝ} + (hchild : 0 ≤ childCost) (hd : d ≤ min bound ⌊childCost⌋₊) + (hremoved : (removed : ℝ) ≤ p) : + ((d + s * removed : ℕ) : ℝ) ≤ childCost + (s : ℝ) * p := by + have hdim : (d : ℝ) ≤ childCost := + (Nat.cast_le.mpr (hd.trans (min_le_right _ _))).trans (Nat.floor_le hchild) + simpa only [Nat.cast_add, Nat.cast_mul] using + add_le_add hdim (mul_le_mul_of_nonneg_left hremoved (Nat.cast_nonneg s)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LowTaggedCoordinateProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/LowTaggedCoordinateProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6970add97ca192bb7626df189cc5b709ace9fa4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LowTaggedCoordinateProjection.lean @@ -0,0 +1,58 @@ +import OAI.Combinatorics.Progressions.Geometry.LowTaggedCoordinateRestriction + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +noncomputable def lowTaggedCoordinates (d : ℕ) (x : ∀ j, J j → ℝ) : + Fin (Fintype.card (LowTaggedIndex J d)) → ℝ := + fun i => x (lowTaggedIndex J d i).1 (lowTaggedIndex J d i).2 + +@[simp] theorem lowTaggedCoordinates_apply_slot (d : ℕ) (x : ∀ j, J j → ℝ) + (j : Fin m) (hj : j.val + 1 ≤ d) (k : J j) : + lowTaggedCoordinates J d x (lowTaggedSlot J d j hj k) = x j k := by + unfold lowTaggedCoordinates + rw [lowTaggedIndex_slot] + +theorem lowTaggedCoordinates_projection (d : ℕ) (x : ∀ j, J j → ℝ) + (j : Fin m) (hj : j.val + 1 ≤ d) : + basisGradeProjection (Pi.basisFun ℝ _) (lowTaggedWeight J d) (j.val + 1) + (lowTaggedCoordinates J d x) = + lowTaggedEmbedding J d j hj (x j) := by + classical + funext i + rw [pi_basisGradeProjection_apply] + by_cases hi : (lowTaggedIndex J d i).1 = j + · obtain ⟨k, hk⟩ := lowTaggedSlot_eq_of_tag J d j hj i hi + subst i + simp [lowTaggedWeight] + · have hweight : lowTaggedWeight J d i ≠ j.val + 1 := by + intro he + apply hi + apply Fin.ext + unfold lowTaggedWeight at he + omega + rw [ite_eq_right hweight, lowTaggedEmbedding_apply_of_ne J d j hj _ i hi] + +theorem lowTaggedCoordinates_projection_eq_zero (d : ℕ) (x : ∀ j, J j → ℝ) + (h : ℕ) (hm : m ≤ h) : + basisGradeProjection (Pi.basisFun ℝ _) (lowTaggedWeight J d) (h + 1) + (lowTaggedCoordinates J d x) = 0 := by + classical + funext i + rw [pi_basisGradeProjection_apply] + have hweight : lowTaggedWeight J d i ≠ h + 1 := by + have hi := (lowTaggedIndex J d i).1.isLt + unfold lowTaggedWeight + omega + simp only [hweight, ite_false, Pi.zero_apply] + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LowerRankObservableDifference.lean b/lean/OAI/Combinatorics/Progressions/Linear/LowerRankObservableDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f967802c91d1c3633fdde4f6b06b44e6d2a4ed6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LowerRankObservableDifference.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.UnitVerticalDifference + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +theorem HasUniformLowerRankUnitFamily.mono {L I σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype I] {s r d : ℕ} {D : RationalFilteredNilmanifold L s d} + {R : D.DegreeRankStructure (r + 1)} {v : I → D.Space → ℂ} {w : σ → ℕ} + {p q : ℝ} (h : HasUniformLowerRankUnitFamily D R v w p) (hpq : p ≤ q) : + HasUniformLowerRankUnitFamily D R v w q := by + obtain ⟨n, hn, Q, S, hS, hK⟩ := h + refine ⟨n, hn, Q, S, hS.mono S hpq, ?_⟩ + let := moduleTopology ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1))) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 Q.basis + obtain ⟨K, hKn, hKc, hKu, a, ha0, hKe⟩ := hK + exact ⟨K, hKn, (fun i => (hKc i).mono hpq), hKu, a, ha0, hKe⟩ + +namespace UnitVerticalObservable + +universe u v w t + +theorem exists_uniform_lower_rank_difference_family (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type u} {I : Type v} {J : Type w} {σ : Type t} + [LieRing L] [LieAlgebra ℚ L] + [Fintype I] [Fintype J] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {r d : ℕ} (D : RationalFilteredNilmanifold L s d) + (R : D.DegreeRankStructure (r + 1)) {p : ℝ} + (V : D.UnitVerticalObservable (R.realSubgroup s (r + 1)) I p) + (U : D.UnitVerticalObservable (R.realSubgroup s (r + 1)) J p), + 0 ≤ p → R.ComplexityLE p → + (∀ x ∈ R.filtration.layer s (r + 1), V.frequency x = U.frequency x) → + ∀ w : σ → ℕ, + HasUniformLowerRankUnitFamily D R (V.differenceObservable U) w ((p + C) ^ C) := by + let a := (exists_lower_rank_family.{u, max v w, t} s).choose + let P : Polynomial ℕ := (Polynomial.X + 2 + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro L I J σ _ _ _ _ _ _ _ _ r d D R p V U hp hR hfreq w + have hb : (p + 2 + a) ^ a ≤ (p + C) ^ C := by + simpa [P, Polynomial.eval₂_pow] using hbudget p hp + have h := hasUniformLowerRankUnitFamily D R (rankDifference R V U hfreq) w + (by linarith) (hR.mono R (by linarith)) (fun _ _ => rfl) + exact h.mono hb + +end UnitVerticalObservable +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/LowestWeightEarlyRankNormalizedPreparation.lean b/lean/OAI/Combinatorics/Progressions/Linear/LowestWeightEarlyRankNormalizedPreparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd4a1b2204c18bdb96214fd401648700f92b2102 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/LowestWeightEarlyRankNormalizedPreparation.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativePatchPositivePowerInduction + +namespace OAI + +section + +namespace Erdos3 + +open VectorPolynomial Module +open scoped BigOperators TensorProduct Classical + +theorem exists_lowest_weight_early_rank_normalized_preparation (s requiredPower precisionPower : ℕ) : + ∃ preparationPower costPower : ℕ, + 2 ≤ preparationPower ∧ 2 ≤ costPower ∧ + ∀ (X : Type) [Fintype X] [DecidableEq X] (p : ℝ), 2 ≤ p → + ∀ (d : ℕ) (A : PolynomialPatch X s d), 0 < d → + relativePatchComplexity A ≤ p → (Fintype.card X : ℝ) ≤ p → + ∀ (N : X → ℕ) (f : (X → ℤ) → ℝ) (target : ℝ), + (∀ i, Real.exp ((p + 2) ^ (max costPower requiredPower + 1)) ≤ (N i : ℝ)) → + let R := preparedRoundedRank p requiredPower + ∃ (D j : ℕ) (hD : D ≤ d), 0 < D ∧ j + 1 ≤ s ∧ + ∃ (q : ℕ) (S : ResidueBoxSlice N q), + let A' := (A.castRank (Nat.add_sub_of_le hD).symm).reparam + S.polynomial S.polynomial_weighted_support + ∃ (F : A'.LowestLayerModel (D := D) (E := d - D) (j + 1)) + (L : RankPreparationFamily X (Fin D) (j + 1)) + (ip : Fin D → MvPolynomial X ℤ) (c : Fin D → ℝ) + (err : VectorPolynomial X ℝ (Fin D → ℝ)), + 0 < q ∧ (q : ℝ) ≤ Real.exp ((p + 2) ^ costPower) ∧ + (∀ i, 0 < S.length i ∧ (N i : ℝ) ≤ Real.exp ((p + 2) ^ costPower) * S.length i) ∧ + (∀ i : Fin D, A'.weight (i.castAdd (d - D)) = j + 1) ∧ + (∀ i : Fin (d - D), j + 1 < A'.weight (i.natAdd D)) ∧ + A'.kernel.lip = A.kernel.lip ∧ + relativePatchComplexity A' = relativePatchComplexity A ∧ + relativePatchDistinctWeights A' = relativePatchDistinctWeights A ∧ + (∑ u, (L u).rank) ≤ (j + 1) * D ∧ (∑ u, (L u).rank) ≤ s * D ∧ + L.Sized D ((j + 1) * D) ∧ L.PreparedHeights ((p + 2) ^ preparationPower) R ∧ + (∀ u, Fintype.card (L u).Coord ≤ preparationCoordinateCap (j + 1) D ((j + 1) * D)) ∧ + (∀ u, HasLayerSamplingRank (u.val + 1) (fun i => (S.length i : ℝ)) + R (L u).space (L u).poly) ∧ + (∀ i, (ip i).totalDegree ≤ j + 1) ∧ DegreeLE (fun _ => 1) (j + 1) err ∧ + VectorPolynomial.ofCoordinates (R := ℝ) (Pi.basisFun ℝ (Fin D)) F.normalizedOrigin = + L.polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + err ∧ + (∀ x ∈ integerBox S.length, ∀ i, + |eval (fun k => (x k : ℝ)) err i| ≤ Real.exp (-((p + 2) ^ (max (requiredPower + 1) precisionPower)))) ∧ + (∀ x ∈ integerBox S.length, ∀ i, + |eval (fun k => (x k : ℝ)) err i| ≤ Real.exp (-((p + 2) ^ precisionPower))) ∧ + relativePatchBoxScore N f target A ≤ relativePatchSliceScore S f target A' ∧ + relativePatchBoxScore N f target A ≤ + relativePatchBoxScore S.length (S.integerPullback f) target A' ∧ + (∀ i, Real.exp ((p + 2) ^ requiredPower) ≤ (S.length i : ℝ)) ∧ + (∀ i, Real.exp (-((p + 2) ^ costPower)) * (N i : ℝ) ≤ (S.length i : ℝ)) ∧ + ∃ (b : ∀ u, Module.Basis (Fin (preparedSamplerTransverse L u)) ℝ + (euclideanSubspace (L u).space)ᗮ) + (_o : ∀ u, OrthonormalBasis (PreparedSamplerContinuous L u) ℝ + (euclideanSubspace (L u).space)) + (_bW : ∀ u, Module.Basis (PreparedSamplerContinuous L u) ℤ + (latticeSection (standardEuclideanLattice (L u).Coord) + (euclideanSubspace (L u).space))), + (∀ u, Submodule.span ℤ (Set.range (b u)) = + projectedIntegerLattice (euclideanSubspace (L u).space)) ∧ + (∀ u z, ‖normalizedOrthogonalChart (euclideanSubspace (L u).space) (b u) z‖ ≤ + Real.exp (allocatedUniformChartLog + (preparationCoordinateCap (j + 1) D ((j + 1) * D) : ℝ)) * ‖z‖) ∧ + (∀ u z, ‖(normalizedOrthogonalChart (euclideanSubspace (L u).space) (b u)).symm z‖ ≤ + Real.exp (allocatedUniformChartLog + (preparationCoordinateCap (j + 1) D ((j + 1) * D) : ℝ)) * ‖z‖) ∧ + (∀ u, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (L u).space) (b u) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (L u).space) (b u) ≤ + Real.exp (allocatedUniformChartLog + (preparationCoordinateCap (j + 1) D ((j + 1) * D) : ℝ))) := by + obtain ⟨preparationPower, costPower, hpreparationPower, hcostPower, hprepare⟩ := + exists_lowest_weight_prepared_patch s (max (requiredPower + 1) precisionPower) + refine ⟨preparationPower, costPower, hpreparationPower, hcostPower, ?_⟩ + intro X _ _ p hp d A hd hA hX N f target hN + let R := preparedRoundedRank p requiredPower + have hNprep : ∀ i, Real.exp ((p + 2) ^ costPower) ≤ (N i : ℝ) := by + intro i + apply (Real.exp_le_exp.mpr (pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) + ((Nat.le_max_left costPower requiredPower).trans (Nat.le_succ _)))).trans (hN i) + obtain ⟨D, j, hD, hDpos, hjs, q, S, F, L, ip, c, err, + hq, hqb, hlen, hfirst, hrest, hLip, hComplexity, hCount, hrank, hsRank, + hsize, hheight, hcoord, hgood, hip, herrdeg, hid, herr, hscore, hboxScore⟩ := + hprepare X p hp d R A hd hA hX (preparedRoundedRank_one_le p requiredPower) + ((preparedRoundedRank_le_exp hp requiredPower).trans (Real.exp_le_exp.mpr + (pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) (Nat.le_max_left _ _)))) + N f target hNprep + have hprecision : ∀ x ∈ integerBox S.length, ∀ i, + |eval (fun k => (x k : ℝ)) err i| ≤ Real.exp (-((p + 2) ^ precisionPower)) := by + intro x hx i + exact (herr x hx i).trans (Real.exp_le_exp.mpr (neg_le_neg + (pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) (Nat.le_max_right _ _)))) + have hchildren := prepared_source_side_budgets hp (le_refl ((p + 2) ^ requiredPower)) + N S.length hN (fun i => (hlen i).2) + refine ⟨D, j, hD, hDpos, hjs, q, S, F, L, ip, c, err, + hq, hqb, hlen, hfirst, hrest, hLip, hComplexity, hCount, hrank, hsRank, + hsize, hheight, hcoord, hgood, hip, herrdeg, hid, herr, hprecision, hscore, hboxScore, + hchildren.1, hchildren.2, ?_⟩ + exact hheight.exists_canonical_sampler_geometry L (by positivity) + (preparedRoundedRank_one_le p requiredPower) hcoord + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MahlerBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/MahlerBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..78fb38f9c9570cea3a1052188f40bc33584035b2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MahlerBasis.lean @@ -0,0 +1,259 @@ +import Mathlib.Analysis.Convex.Gauge +import Mathlib.LinearAlgebra.FreeModule.PID + +namespace OAI + +section + +namespace Erdos3.IntegerBasisReduction.Mahler + +open scoped BigOperators +open Module + +abbrev IntegralPoint (n : ℕ) := Fin n → ℤ + +def integralEmbed {n : ℕ} (x : IntegralPoint n) : Fin n → ℝ := + fun i ↦ (x i : ℝ) + +@[simp] +theorem integralEmbed_zero {n : ℕ} : + integralEmbed (0 : IntegralPoint n) = 0 := by + ext i + simp [integralEmbed] + +@[simp] +theorem integralEmbed_add {n : ℕ} (x y : IntegralPoint n) : + integralEmbed (x + y) = integralEmbed x + integralEmbed y := by + ext i + simp [integralEmbed] + +@[simp] +theorem integralEmbed_zsmul {n : ℕ} (a : ℤ) (x : IntegralPoint n) : + integralEmbed (a • x) = (a : ℝ) • integralEmbed x := by + ext i + simp [integralEmbed] + +def AdmitsIndependent {n : ℕ} (p : Seminorm ℝ (Fin n → ℝ)) + (k : ℕ) (r : ℝ) : Prop := + ∃ v : Fin k → IntegralPoint n, + LinearIndependent ℝ (fun j ↦ integralEmbed (v j)) ∧ + ∀ j, p (integralEmbed (v j)) ≤ r + +noncomputable def successiveMinimum {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) (i : Fin n) : ℝ := + sInf {r : ℝ | AdmitsIndependent p (i.val + 1) r} + +theorem AdmitsIndependent.mono {n k : ℕ} + {p : Seminorm ℝ (Fin n → ℝ)} {r R : ℝ} + (h : AdmitsIndependent p k r) (hrR : r ≤ R) : + AdmitsIndependent p k R := by + obtain ⟨v, hvli, hvr⟩ := h + exact ⟨v, hvli, fun j ↦ (hvr j).trans hrR⟩ + +theorem AdmitsIndependent.nonneg {n k : ℕ} + {p : Seminorm ℝ (Fin n → ℝ)} {r : ℝ} + (hk : 0 < k) (h : AdmitsIndependent p k r) : 0 ≤ r := by + obtain ⟨v, _hvli, hvr⟩ := h + exact (apply_nonneg p (integralEmbed (v ⟨0, hk⟩))).trans (hvr ⟨0, hk⟩) + +theorem successiveMinimum_nonneg {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) (i : Fin n) : + 0 ≤ successiveMinimum p i := by + rw [successiveMinimum] + exact Real.sInf_nonneg fun _r hr ↦ + hr.nonneg (Nat.succ_pos i.val) + +theorem successiveMinimum_le_of_admits {n : ℕ} + {p : Seminorm ℝ (Fin n → ℝ)} {i : Fin n} {r : ℝ} + (h : AdmitsIndependent p (i.val + 1) r) : + successiveMinimum p i ≤ r := by + rw [successiveMinimum] + exact csInf_le + ⟨0, fun R hR ↦ hR.nonneg (Nat.succ_pos i.val)⟩ h + +noncomputable def mahlerFactor {n : ℕ} (i : Fin n) : ℝ := + if i.val = 0 then 1 else (i.val + 1 : ℝ) / 2 + +@[simp] +theorem mahlerFactor_zero {n : ℕ} (i : Fin n) (hi : i.val = 0) : + mahlerFactor i = 1 := by + simp [mahlerFactor, hi] + +theorem mahlerFactor_of_pos {n : ℕ} (i : Fin n) (hi : 0 < i.val) : + mahlerFactor i = (i.val + 1 : ℝ) / 2 := by + simp [mahlerFactor, Nat.ne_of_gt hi] + +theorem mahlerFactor_nonneg {n : ℕ} (i : Fin n) : + 0 ≤ mahlerFactor i := by + by_cases hi : i.val = 0 + · rw [mahlerFactor_zero i hi] + positivity + · rw [mahlerFactor_of_pos i (Nat.pos_of_ne_zero hi)] + positivity + +theorem mahlerFactor_le_rank {n : ℕ} (i : Fin n) : + mahlerFactor i ≤ (n : ℝ) := by + by_cases hi : i.val = 0 + · rw [mahlerFactor_zero i hi] + exact_mod_cast (show 1 ≤ n by omega) + · rw [mahlerFactor_of_pos i (Nat.pos_of_ne_zero hi)] + have hin : i.val + 1 ≤ n := i.isLt + have hin' : (i.val + 1 : ℝ) ≤ (n : ℝ) := by exact_mod_cast hin + nlinarith [show (0 : ℝ) ≤ n by positivity] + +def IsDefinite {n : ℕ} (p : Seminorm ℝ (Fin n → ℝ)) : Prop := + ∀ x, p x = 0 → x = 0 + +theorem isDefinite_gaugeSeminorm {n : ℕ} {s : Set (Fin n → ℝ)} + (hs₀ : Balanced ℝ s) (hs₁ : Convex ℝ s) (hs₂ : Absorbent ℝ s) + (hb : Bornology.IsVonNBounded ℝ s) : + IsDefinite (gaugeSeminorm hs₀ hs₁ hs₂) := by + intro x hx + exact (gauge_eq_zero hs₂ hb).mp hx + +def IsMahlerBasis {n : ℕ} (p : Seminorm ℝ (Fin n → ℝ)) + (b : Basis (Fin n) ℤ (IntegralPoint n)) : Prop := + ∀ i, p (integralEmbed (b i)) ≤ + mahlerFactor i * successiveMinimum p i + +def MahlerBasisStatement : Prop := + ∀ (n : ℕ) (p : Seminorm ℝ (Fin n → ℝ)), + IsDefinite p → + ∃ b : Basis (Fin n) ℤ (IntegralPoint n), IsMahlerBasis p b + +theorem exists_isMahlerBasis_zero (p : Seminorm ℝ (Fin 0 → ℝ)) : + ∃ b : Basis (Fin 0) ℤ (IntegralPoint 0), IsMahlerBasis p b := by + refine ⟨Pi.basisFun ℤ (Fin 0), ?_⟩ + intro i + exact Fin.elim0 i + +theorem exists_isMahlerBasis_one (p : Seminorm ℝ (Fin 1 → ℝ)) : + ∃ b : Basis (Fin 1) ℤ (IntegralPoint 1), IsMahlerBasis p b := by + let b : Basis (Fin 1) ℤ (IntegralPoint 1) := Pi.basisFun ℤ (Fin 1) + let u : IntegralPoint 1 := b 0 + have hu_real : integralEmbed u = Pi.basisFun ℝ (Fin 1) 0 := by + ext j + fin_cases j + simp [u, b, integralEmbed] + have hu_ne : integralEmbed u ≠ 0 := by + rw [hu_real] + exact (Pi.basisFun ℝ (Fin 1)).ne_zero 0 + have hadmits : + AdmitsIndependent p 1 (p (integralEmbed u)) := by + refine ⟨fun _ ↦ u, ?_, fun _ ↦ le_rfl⟩ + rw [Fintype.linearIndependent_iff] + intro g hg j + have hgj : g 0 = 0 := by + by_contra hg0 + apply hu_ne + have hsmul : g 0 • integralEmbed u = 0 := by + simpa using hg + exact (smul_eq_zero.mp hsmul).resolve_left hg0 + simpa [Subsingleton.elim j 0] using hgj + refine ⟨b, ?_⟩ + intro i + have hi : i = 0 := Subsingleton.elim _ _ + subst i + rw [mahlerFactor_zero (0 : Fin 1) rfl, one_mul] + change p (integralEmbed u) ≤ successiveMinimum p 0 + rw [successiveMinimum] + refine le_csInf ⟨p (integralEmbed u), hadmits⟩ ?_ + intro r hr + obtain ⟨v, hvli, hvr⟩ := hr + let z : ℤ := v 0 0 + have hz : z ≠ 0 := by + intro hz0 + have hv0 : integralEmbed (v 0) = 0 := by + ext j + have hj : j = 0 := Subsingleton.elim _ _ + subst j + change ((v 0 0 : ℤ) : ℝ) = 0 + exact_mod_cast hz0 + exact (hvli.ne_zero 0) hv0 + have hv_eq : integralEmbed (v 0) = (z : ℝ) • integralEmbed u := by + ext j + have hj : j = 0 := Subsingleton.elim _ _ + subst j + simp [integralEmbed, u, b, z] + have hzabs_int : (1 : ℤ) ≤ |z| := by + have : (0 : ℤ) < |z| := abs_pos.mpr hz + omega + have hzabs_real : (1 : ℝ) ≤ |(z : ℝ)| := by + exact_mod_cast hzabs_int + calc + p (integralEmbed u) ≤ |(z : ℝ)| * p (integralEmbed u) := by + nlinarith [apply_nonneg p (integralEmbed u)] + _ = p ((z : ℝ) • integralEmbed u) := by + rw [map_smul_eq_mul, Real.norm_eq_abs] + _ = p (integralEmbed (v 0)) := by rw [hv_eq] + _ ≤ r := hvr 0 + +theorem IsMahlerBasis.first {n : ℕ} {p : Seminorm ℝ (Fin n → ℝ)} + {b : Basis (Fin n) ℤ (IntegralPoint n)} (hb : IsMahlerBasis p b) + (i : Fin n) (hi : i.val = 0) : + p (integralEmbed (b i)) ≤ successiveMinimum p i := by + simpa [IsMahlerBasis, mahlerFactor, hi] using hb i + +theorem IsMahlerBasis.later {n : ℕ} {p : Seminorm ℝ (Fin n → ℝ)} + {b : Basis (Fin n) ℤ (IntegralPoint n)} (hb : IsMahlerBasis p b) + (i : Fin n) (hi : 0 < i.val) : + p (integralEmbed (b i)) ≤ + (i.val + 1 : ℝ) / 2 * successiveMinimum p i := by + simpa [IsMahlerBasis, mahlerFactor, Nat.ne_of_gt hi] using hb i + +theorem IsMahlerBasis.le_rank_mul_successiveMinimum {n : ℕ} + {p : Seminorm ℝ (Fin n → ℝ)} + {b : Basis (Fin n) ℤ (IntegralPoint n)} (hb : IsMahlerBasis p b) + (i : Fin n) : + p (integralEmbed (b i)) ≤ (n : ℝ) * successiveMinimum p i := by + exact (hb i).trans <| mul_le_mul_of_nonneg_right + (mahlerFactor_le_rank i) (successiveMinimum_nonneg p i) + +theorem seminorm_sum_le {n : ℕ} {E : Type*} [AddCommGroup E] + [Module ℝ E] (p : Seminorm ℝ E) (a : Fin n → ℝ) (e : Fin n → E) : + p (∑ i, a i • e i) ≤ ∑ i, |a i| * p (e i) := by + calc + p (∑ i, a i • e i) ≤ ∑ i, p (a i • e i) := + Finset.le_sum_of_subadditive p (by simp) + (fun x y ↦ map_add_le_add p x y) Finset.univ (fun i ↦ a i • e i) + _ = ∑ i, |a i| * p (e i) := by + apply Finset.sum_congr rfl + intro i _ + rw [map_smul_eq_mul] + exact congrArg (fun t : ℝ ↦ t * p (e i)) (Real.norm_eq_abs (a i)) + +theorem seminorm_sum_basis_le {n : ℕ} {E : Type*} [AddCommGroup E] + [Module ℝ E] (p : Seminorm ℝ E) (a : Fin n → ℝ) (e : Fin n → E) + (M : ℝ) (hM : ∀ i, |a i| * p (e i) ≤ M) : + p (∑ i, a i • e i) ≤ (n : ℝ) * M := by + refine (seminorm_sum_le p a e).trans ?_ + calc + (∑ i, |a i| * p (e i)) ≤ ∑ _i : Fin n, M := + Finset.sum_le_sum fun i _ ↦ hM i + _ = (n : ℝ) * M := by simp + +theorem seminorm_sum_integralBasis_le {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (b : Basis (Fin n) ℤ (IntegralPoint n)) (a : Fin n → ℝ) + (M : ℝ) + (hM : ∀ i, |a i| * p (integralEmbed (b i)) ≤ M) : + p (∑ i, a i • integralEmbed (b i)) ≤ (n : ℝ) * M := + seminorm_sum_basis_le p a (fun i ↦ integralEmbed (b i)) M hM + +theorem IsMahlerBasis.seminorm_sum_le {n : ℕ} + {p : Seminorm ℝ (Fin n → ℝ)} + {b : Basis (Fin n) ℤ (IntegralPoint n)} (hb : IsMahlerBasis p b) + (a : Fin n → ℝ) : + p (∑ i, a i • integralEmbed (b i)) ≤ + ∑ i, |a i| * + (mahlerFactor i * successiveMinimum p i) := by + refine (Erdos3.IntegerBasisReduction.Mahler.seminorm_sum_le + p a (fun i ↦ integralEmbed (b i))).trans ?_ + exact Finset.sum_le_sum fun i _ ↦ + mul_le_mul_of_nonneg_left (hb i) (abs_nonneg _) + +end Erdos3.IntegerBasisReduction.Mahler + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MarkedLieSpan.lean b/lean/OAI/Combinatorics/Progressions/Linear/MarkedLieSpan.lean new file mode 100644 index 0000000000000000000000000000000000000000..64fac51183035b865bec265d4d86e0d58ae739b2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MarkedLieSpan.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.Progressions.Polynomial.WeightedLieDegreeLengthSpan + +namespace OAI + +section + +namespace Erdos3 + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] + +def markedLieSpan (v : I → L) (w : I → ℕ) (marked : I → Bool) (d k l : ℕ) : Submodule ℚ L := + Submodule.span ℚ {x | ∃ a : FreeMagma I, d ≤ lieTreeWeight w a ∧ + k ≤ lieTreeMarkedCount marked a ∧ l ≤ a.length ∧ lieTreeEval v a = x} + +theorem markedLieSpan_antitone (v : I → L) (w : I → ℕ) (marked : I → Bool) + {d e k m l n : ℕ} (hde : d ≤ e) (hkm : k ≤ m) (hln : l ≤ n) : + markedLieSpan v w marked e m n ≤ markedLieSpan v w marked d k l := by + apply Submodule.span_mono + rintro x ⟨a, hd, hk, hl, rfl⟩ + exact ⟨a, hde.trans hd, hkm.trans hk, hln.trans hl, rfl⟩ + +theorem markedLieSpan_lie_mem (v : I → L) (w : I → ℕ) (marked : I → Bool) + {d e k m l n : ℕ} {x y : L} + (hx : x ∈ markedLieSpan v w marked d k l) + (hy : y ∈ markedLieSpan v w marked e m n) : + ⁅x, y⁆ ∈ markedLieSpan v w marked (d + e) (k + m) (l + n) := by + induction hx, hy using Submodule.span_induction₂ with + | mem_mem x y hx hy => + obtain ⟨a, hd, hk, hl, rfl⟩ := hx + obtain ⟨b, he, hm, hn, rfl⟩ := hy + exact Submodule.subset_span ⟨a * b, Nat.add_le_add hd he, + Nat.add_le_add hk hm, Nat.add_le_add hl hn, rfl⟩ + | zero_left y _ => rw [zero_lie]; exact Submodule.zero_mem _ + | zero_right x _ => rw [lie_zero]; exact Submodule.zero_mem _ + | add_left x y z _ _ _ hx hy => rw [add_lie]; exact Submodule.add_mem _ hx hy + | add_right x y z _ _ _ hx hy => rw [lie_add]; exact Submodule.add_mem _ hx hy + | smul_left c x y _ _ h => rw [smul_lie]; exact Submodule.smul_mem _ c h + | smul_right c x y _ _ h => rw [lie_smul]; exact Submodule.smul_mem _ c h + +theorem markedLieSpan_leaf (v : I → L) (w : I → ℕ) (marked : I → Bool) (i : I) : + v i ∈ markedLieSpan v w marked (w i) (if marked i then 1 else 0) 1 := + Submodule.subset_span ⟨.of i, le_rfl, le_rfl, le_rfl, rfl⟩ + +theorem markedLieSpan_zero_marked (v : I → L) (w : I → ℕ) (marked : I → Bool) (d l : ℕ) : + markedLieSpan v w marked d 0 l = weightedLieDegreeLengthSpan v w d l := by + unfold markedLieSpan weightedLieDegreeLengthSpan + congr 1 + ext x + simp only [Nat.zero_le, true_and] + +theorem markedLieSpan_le_layer {s r : ℕ} (F : DegreeRankLieFiltration L s r) + (v : I → L) (w : I → ℕ) (marked : I → Bool) + (hv : ∀ i, v i ∈ F.layer (w i) 1) (d k l : ℕ) : + markedLieSpan v w marked d k l ≤ F.layer d l := by + apply Submodule.span_le.mpr + rintro x ⟨a, hd, _, hl, rfl⟩ + exact F.degree_antitone l hd + (F.rank_antitone (lieTreeWeight w a) hl (F.lieTreeEval_mem_length v w hv a)) + +theorem markedLieSpan_top_le_ker {A : Type*} [AddCommGroup A] [Module ℚ A] + {s r : ℕ} (F : DegreeRankLieFiltration L s r) + (v : I → L) (w : I → ℕ) (marked : I → Bool) + (hv : ∀ i, v i ∈ F.layer (w i) 1) (k : ℕ) (η : L →ₗ[ℚ] A) + (hzero : ∀ a : FreeMagma I, lieTreeWeight w a = s → a.length = r → + k ≤ lieTreeMarkedCount marked a → η (lieTreeEval v a) = 0) : + markedLieSpan v w marked s k r ≤ η.ker := by + apply Submodule.span_le.mpr + rintro x ⟨a, hd, hk, hl, rfl⟩ + change η (lieTreeEval v a) = 0 + by_cases he : lieTreeWeight w a = s + · by_cases hn : a.length = r + · exact hzero a he hn hk + · have hm := F.lieTreeEval_mem_length v w hv a + rw [F.layer_eq_bot_of_past_top (Or.inr ⟨he.symm, by omega⟩), Submodule.mem_bot] at hm + rw [hm, map_zero] + · have hm := F.lieTreeEval_mem_length v w hv a + rw [F.layer_eq_bot_of_past_top (Or.inl (by omega)), Submodule.mem_bot] at hm + rw [hm, map_zero] + +theorem markedLieSpan_marked_terminal {s r : ℕ} (F : DegreeRankLieFiltration L s r) + (v : I → L) (w : I → ℕ) (marked : I → Bool) (hw : ∀ i, 0 < w i) + (hv : ∀ i, v i ∈ F.layer (w i) 1) (d l : ℕ) : + markedLieSpan v w marked d (s + 1) l = ⊥ := by + apply bot_unique + apply Submodule.span_le.mpr + rintro x ⟨a, _, hk, _, rfl⟩ + have hcount := (lieTreeMarkedCount_le_length marked a).trans (lieTree_length_le_weight w hw a) + have hs : s < lieTreeWeight w a := by omega + have hm := F.lieTreeEval_mem_length v w hv a + rw [F.layer_eq_bot_of_past_top (Or.inl hs)] at hm + exact hm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MarkedProjectionBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/MarkedProjectionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7a7cfa3bff62f5214ceb7175a6c572a830b0037 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MarkedProjectionBounds.lean @@ -0,0 +1,239 @@ +import OAI.Combinatorics.Progressions.Estimates.DescendedLinearMapBounds +import OAI.Combinatorics.Progressions.Estimates.MarkedPureEvaluation + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {I ι L : Type*} [Fintype I] [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.associatedDegree.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (v : I → L) (w : I → ℕ) (marked : I → Bool) (hw : ∀ i, 0 < w i) + (hv : ∀ i, v i ∈ F.layer (w i) 1) {H : ℕ} (hH : 1 ≤ H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) + (hgen : ∀ i j, RationalHeightLE (b.repr (v i) j) H) + +include hw hv hH hc hgen in +theorem exists_markedShift_bounded_basis (hω : ∀ i, ω i ≤ s) (t : ℕ) : + ∃ e : Basis (Fin (finrank ℚ (markedShiftSubalgebra F v w marked t))) ℚ + (markedShiftSubalgebra F v w marked t), + ∀ i j, RationalHeightLE ((F.associatedDegree.polynomialShiftBasis b ω hF t).repr + (e i).val j) (lieTreeHeight (Fintype.card ι) H s) := by + let _ := F.associatedDegree.polynomialShift_finiteDimensional b ω hF hω t + let _ : FiniteDimensional ℚ (markedShiftSubalgebra F v w marked t) := + inferInstanceAs (FiniteDimensional ℚ (markedShiftSubalgebra F v w marked t).toSubmodule) + have hex := Submodule.exists_fun_fin_finrank_span_eq ℚ + (Set.range (markedShiftGenerator F v w marked hw hv t 0 0)) + rw [markedShiftGenerator_span, markedShiftBiLayer_zero, finrank_top] at hex + obtain ⟨z, hz, hzspan, hzli⟩ := hex + let e := Basis.mk hzli (le_of_eq hzspan.symm) + refine ⟨e, ?_⟩ + intro i j + simp only [e, Basis.mk_apply] + obtain ⟨k, hk⟩ := hz i + rw [← hk] + exact markedShiftGenerator_coordinate_height F b ω hF v w marked hw hv hH hc hgen t 0 0 k j + +include hw hv hH hc hgen in +theorem exists_markedShiftLayer_coordinate_basis (hω : ∀ i, ω i ≤ s) (t : ℕ) + (e : Basis (Fin (finrank ℚ (markedShiftSubalgebra F v w marked t))) ℚ + (markedShiftSubalgebra F v w marked t)) + (he : ∀ i j, RationalHeightLE ((F.associatedDegree.polynomialShiftBasis b ω hF t).repr + (e i).val j) (lieTreeHeight (Fintype.card ι) H s)) (h n : ℕ) : + let T := lieTreeHeight (Fintype.card ι) H s + let a := finrank ℚ (F.associatedDegree.PolynomialShiftAlgebra t) + let d := finrank ℚ (markedShiftSubalgebra F v w marked t) + ∃ c : Basis (Fin (finrank ℚ (markedShiftBiLayer F v w marked t h n))) ℚ + (markedShiftBiLayer F v w marked t h n), + ∀ i j, RationalHeightLE (e.repr (c i).val j) + ((a + 1) * (rationalSolveHeight d T * T) ^ a) := by + classical + dsimp only + let _ : Fintype (NilpotentLieFiltration.AdaptedBasisIndex (fun _ : Fin t => 1) ω) := + NilpotentLieFiltration.adaptedBasisIndexFintype (fun _ : Fin t => 1) ω s (by simp) hω + obtain ⟨c, hc'⟩ := exists_markedShiftLayer_bounded_basis F b ω hF v w marked hw hv hH hc hgen hω t h n + refine ⟨c, ?_⟩ + intro i j + have hb := embedding_basis_coordinate_height e (F.associatedDegree.polynomialShiftBasis b ω hF t) + (markedShiftSubalgebra F v w marked t).incl.toLinearMap + (fun _ _ h => Subtype.ext h) (hH.trans (lieTreeHeight_ge_input _ _ _)) + (fun j i => he i j) (c i).val (hc' i) j + simpa only [Fintype.card_fin, + ← finrank_eq_card_basis (F.associatedDegree.polynomialShiftBasis b ω hF t)] using hb + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {I ι L : Type*} [Fintype I] [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.associatedDegree.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (v : I → L) (w : I → ℕ) (marked : I → Bool) (hw : ∀ i, 0 < w i) + (hv : ∀ i, v i ∈ F.layer (w i) 1) {H : ℕ} (hH : 1 ≤ H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) + (hgen : ∀ i j, RationalHeightLE (b.repr (v i) j) H) + +include hw hv hH hc hgen in +theorem exists_markedShiftQuotient_bounded_coordinates (hω : ∀ i, ω i ≤ s) (t : ℕ) + (e : Basis (Fin (finrank ℚ (markedShiftSubalgebra F v w marked t))) ℚ + (markedShiftSubalgebra F v w marked t)) + (he : ∀ i j, RationalHeightLE ((F.associatedDegree.polynomialShiftBasis b ω hF t).repr + (e i).val j) (lieTreeHeight (Fintype.card ι) H s)) : + let T := lieTreeHeight (Fintype.card ι) H s + let a := finrank ℚ (F.associatedDegree.PolynomialShiftAlgebra t) + let d := finrank ℚ (markedShiftSubalgebra F v w marked t) + let B := (a + 1) * (rationalSolveHeight d T * T) ^ a + ∃ m : ℕ, m ≤ finrank ℚ (markedShiftSecondIdeal F v w marked t).toSubmodule ∧ + ∃ q : ℕ, q ≤ d ∧ ∃ f : Basis (Fin q) ℚ (MarkedShiftQuotient F v w marked t), + ∀ i j, RationalHeightLE + (f.repr (lieQuotientMap (markedShiftSecondIdeal F v w marked t) (e j)) i) + (rationalKernelHeight m B) := by + let T := lieTreeHeight (Fintype.card ι) H s + let a := finrank ℚ (F.associatedDegree.PolynomialShiftAlgebra t) + let d := finrank ℚ (markedShiftSubalgebra F v w marked t) + let B := (a + 1) * (rationalSolveHeight d T * T) ^ a + have hT : 1 ≤ T := hH.trans (lieTreeHeight_ge_input _ _ _) + have hsolve : 0 < rationalSolveHeight d T := rationalSolveHeight_pos d hT + have hB : 1 ≤ B := by + have hTpos : 0 < T := Nat.zero_lt_of_lt hT + exact Nat.one_le_iff_ne_zero.mpr (by dsimp [B]; positivity) + have hex := exists_markedShiftLayer_coordinate_basis F b ω hF v w marked hw hv hH hc hgen hω t e he 2 0 + dsimp only at hex + rw [markedShiftBiLayer_second] at hex + obtain ⟨c, hc'⟩ := hex + have hcoords : ∀ i j, RationalHeightLE (e.repr (c i).val j) B := hc' + obtain ⟨m, hm, q, hq, f, hf⟩ := exists_bounded_submodule_quotient_basis e + (markedShiftSecondIdeal F v w marked t).toSubmodule (fun i => (c i).val) + (span_submodule_basis _ c) hB hcoords + refine ⟨m, ?_, q, ?_, f, hf⟩ + · simpa only [Fintype.card_fin] using hm + · simpa only [Fintype.card_fin] using hq + +include hw hv hH hc hgen in +theorem exists_markedShiftQuotientLayer_bounded_basis (hω : ∀ i, ω i ≤ s) (t : ℕ) + (e : Basis (Fin (finrank ℚ (markedShiftSubalgebra F v w marked t))) ℚ + (markedShiftSubalgebra F v w marked t)) + (he : ∀ i j, RationalHeightLE ((F.associatedDegree.polynomialShiftBasis b ω hF t).repr + (e i).val j) (lieTreeHeight (Fintype.card ι) H s)) + {q Q : ℕ} (f : Basis (Fin q) ℚ (MarkedShiftQuotient F v w marked t)) + (hf : ∀ i j, RationalHeightLE + (f.repr (lieQuotientMap (markedShiftSecondIdeal F v w marked t) (e j)) i) Q) + (α : Fin 2 → ℕ) : + let T := lieTreeHeight (Fintype.card ι) H s + let a := finrank ℚ (F.associatedDegree.PolynomialShiftAlgebra t) + let d := finrank ℚ (markedShiftSubalgebra F v w marked t) + let B := (a + 1) * (rationalSolveHeight d T * T) ^ a + ∃ c : Basis (Fin (finrank ℚ (markedShiftQuotientLayer F v w marked t α))) ℚ + (markedShiftQuotientLayer F v w marked t α), + ∀ i j, RationalHeightLE (f.repr (c i).val j) ((d + 1) * (B * Q) ^ d) := by + dsimp only + obtain ⟨c, hc'⟩ := exists_markedShiftLayer_coordinate_basis F b ω hF v w marked hw hv hH hc hgen + hω t e he (α 0) (α 1) + let π := (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap + have hspan : Submodule.span ℚ (Set.range (fun i => π (c i).val)) = + markedShiftQuotientLayer F v w marked t α := by + change Submodule.span ℚ (Set.range (π ∘ (fun i => (c i).val))) = _ + rw [Set.range_comp, ← Submodule.map_span, span_submodule_basis] + rfl + apply exists_bounded_submodule_basis_from_spanning f _ (fun i => π (c i).val) hspan + intro i j + have h := linearMap_coordinate_height e f π (fun i j => hf j i) (c i).val (hc' i) j + simpa only [Fintype.card_fin] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module VectorPolynomial + +variable {I ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s r d q : ℕ} + (F : DegreeRankLieFiltration L s r) (v : I → L) (w : I → ℕ) (marked : I → Bool) + (t : ℕ) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.associatedDegree.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (e : Basis (Fin d) ℚ (markedShiftSubalgebra F v w marked t)) + {H : ℕ} (he : ∀ i j, RationalHeightLE + ((F.associatedDegree.polynomialShiftBasis b ω hF t).repr (e i).val j) H) + +include he + +omit [Fintype ι] in +theorem markedShiftPhase_coordinate_height (i : Fin t) (j : Fin d) : + RationalHeightLE ((RationalTorus.basis t).repr (markedShiftPhase F v w marked t (e j)) i) H := by + have h := he j (Sum.inr i) + rw [F.associatedDegree.polynomialShiftBasis_repr_inr] at h + exact h + +omit [Fintype ι] in +theorem markedShiftEval_zero_coordinate_height (i : ι) (j : Fin d) : + RationalHeightLE (b.repr (markedShiftEval F v w marked t 0 (e j)) i) H := by + let z : NilpotentLieFiltration.AdaptedBasisIndex (fun _ : Fin t => 1) ω := + ⟨(0, i), by simp⟩ + have h := he j (Sum.inl z) + rw [F.associatedDegree.polynomialShiftBasis_repr_inl] at h + change RationalHeightLE (b.repr (eval (fun _ => 0) (e j).val.left.val) i) H + rw [eval_zero_eq_coefficient] + exact h + +variable (f : Basis (Fin q) ℚ (MarkedShiftQuotient F v w marked t)) + {Q : ℕ} (hQ : 1 ≤ Q) + (hf : ∀ i j, RationalHeightLE + (f.repr (lieQuotientMap (markedShiftSecondIdeal F v w marked t) (e j)) i) Q) + +include hQ hf + +omit [Fintype ι] in +theorem markedQuotientPhase_coordinate_height (i : Fin t) (j : Fin q) : + RationalHeightLE ((RationalTorus.basis t).repr (markedQuotientPhase F v w marked t (f j)) i) + ((d + 1) * (rationalSolveHeight q Q * H) ^ d) := by + have h := descended_linear_map_coordinate_height e f (RationalTorus.basis t) + (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap + (lieQuotientMap_surjective _) (markedQuotientPhase F v w marked t).toLinearMap hQ hf + (fun i j => markedShiftPhase_coordinate_height F v w marked t b ω hF e he i j) i j + change RationalHeightLE ((RationalTorus.basis t).repr + (markedQuotientPhase F v w marked t (f j)) i) + ((Fintype.card (Fin d) + 1) * (rationalSolveHeight (Fintype.card (Fin q)) Q * H) ^ + Fintype.card (Fin d)) at h + simpa only [Fintype.card_fin] using h + +variable {ν : Type*} (J : LieIdeal ℚ L) (hJ : markedLieSpan v w marked 0 2 0 ≤ J.toSubmodule) + (c : Basis ν ℚ (L ⧸ J)) {K : ℕ} + (hc : ∀ i j, RationalHeightLE (c.repr (lieQuotientMap J (b j)) i) K) + +include hc + +theorem markedBaseEvaluation_zero_coordinate_height (i : ν) (j : Fin q) : + RationalHeightLE (c.repr (markedBaseEvaluation F v w marked t J hJ 0 (f j)) i) + ((d + 1) * (rationalSolveHeight q Q * ((Fintype.card ι + 1) * (H * K) ^ Fintype.card ι)) ^ d) := by + have hcomp (i j) : RationalHeightLE + (c.repr (markedBaseEvaluation F v w marked t J hJ 0 + (lieQuotientMap (markedShiftSecondIdeal F v w marked t) (e j))) i) + ((Fintype.card ι + 1) * (H * K) ^ Fintype.card ι) := by + rw [markedBaseEvaluation_map] + exact linearMap_coordinate_height b c (lieQuotientMap J).toLinearMap + (fun j i => hc i j) (markedShiftEval F v w marked t 0 (e j)) + (fun i => markedShiftEval_zero_coordinate_height F v w marked t b ω hF e he i j) i + have h := descended_linear_map_coordinate_height e f c + (lieQuotientMap (markedShiftSecondIdeal F v w marked t)).toLinearMap + (lieQuotientMap_surjective _) (markedBaseEvaluation F v w marked t J hJ 0) + hQ hf hcomp i j + simpa only [Fintype.card_fin] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MatrixCoordinateSlice.lean b/lean/OAI/Combinatorics/Progressions/Linear/MatrixCoordinateSlice.lean new file mode 100644 index 0000000000000000000000000000000000000000..732fd02e2adcb830debcf9e1efdcc28dd8648595 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MatrixCoordinateSlice.lean @@ -0,0 +1,62 @@ +import Mathlib.Logic.Equiv.Prod +import OAI.Combinatorics.Progressions.Estimates.FiniteBiasedSlice + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +def matrixCoordinateSplit {H I : Type*} [DecidableEq I] + (j : H → I) (X : I → Type*) : + (H → ∀ k, X k) ≃ (∀ i, X (j i)) × (∀ i, ∀ k : {k // k ≠ j i}, X k) where + toFun v := (fun i => v i (j i), fun i k => v i k) + invFun p i := (Equiv.piSplitAt (j i) X).symm (p.1 i, p.2 i) + left_inv v := by + funext i + exact (Equiv.piSplitAt (j i) X).symm_apply_apply (v i) + right_inv p := by + apply Prod.ext + · funext i + exact congrArg Prod.fst ((Equiv.piSplitAt (j i) X).apply_symm_apply (p.1 i, p.2 i)) + · funext i + exact congrArg Prod.snd ((Equiv.piSplitAt (j i) X).apply_symm_apply (p.1 i, p.2 i)) + +theorem matrixCoordinateSplit_symm_update {H I : Type*} [DecidableEq I] + (j : H → I) (X : I → Type*) (x x₀ : ∀ i, X (j i)) + (r : ∀ i, ∀ k : {k // k ≠ j i}, X k) : + (matrixCoordinateSplit j X).symm (x, r) = + fun i => Function.update ((matrixCoordinateSplit j X).symm (x₀, r) i) (j i) (x i) := by + funext i k + by_cases hk : k = j i + · subst k + simp [matrixCoordinateSplit, Equiv.piSplitAt] + · simp [matrixCoordinateSplit, Equiv.piSplitAt, hk] + +theorem exists_biased_matrix_coordinate_slice {H I : Type*} [Fintype H] [Fintype I] + [DecidableEq H] [DecidableEq I] + (X : I → Type*) [∀ k, Fintype (X k)] [∀ k, Nonempty (X k)] + (j : H → I) (F : (H → ∀ k, X k) → ℂ) {δ : ℝ} + (hδ : δ ≤ ‖𝔼 v, F v‖) : + ∃ b : H → ∀ k, X k, δ ≤ ‖𝔼 x : ∀ i, X (j i), + F (fun i => Function.update (b i) (j i) (x i))‖ := by + let e := matrixCoordinateSplit j X + have he := Fintype.expect_equiv e F (fun p => F (e.symm p)) (fun v => by simp) + rw [he, ← Finset.univ_product_univ, Finset.expect_product, Finset.expect_comm] at hδ + obtain ⟨r, hr⟩ := exists_biased_finite_slice (fun r x => F (e.symm (x, r))) hδ + let x₀ : ∀ i, X (j i) := fun i => Classical.choice inferInstance + refine ⟨e.symm (x₀, r), ?_⟩ + have hmean : (𝔼 x : ∀ i, X (j i), F (e.symm (x, r))) = + 𝔼 x : ∀ i, X (j i), F (fun i => Function.update (e.symm (x₀, r) i) (j i) (x i)) := by + apply Finset.expect_congr rfl + intro x _ + exact congrArg F (matrixCoordinateSplit_symm_update j X x x₀ r) + exact hr.trans_eq (congrArg norm hmean) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MatrixModuleAction.lean b/lean/OAI/Combinatorics/Progressions/Linear/MatrixModuleAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc087f8744ac4dfce2af4e6075a88985fb110c59 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MatrixModuleAction.lean @@ -0,0 +1,46 @@ +import Mathlib.LinearAlgebra.Matrix.ToLin +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +noncomputable def matrixModuleAction {I J W : Type*} [Fintype J] + [AddCommGroup W] [Module ℝ W] (A : Matrix I J ℝ) : (J → W) →ₗ[ℝ] (I → W) where + toFun x i := ∑ j, A i j • x j + map_add' x y := by + funext i + simp only [Pi.add_apply, smul_add, Finset.sum_add_distrib] + map_smul' r x := by + funext i + simp only [Pi.smul_apply, RingHom.id_apply, Finset.smul_sum] + apply Finset.sum_congr rfl + intro j _ + exact smul_comm (A i j) r (x j) + +theorem matrixModuleAction_apply {I J W : Type*} [Fintype J] + [AddCommGroup W] [Module ℝ W] (A : Matrix I J ℝ) (x : J → W) (i : I) : + matrixModuleAction A x i = ∑ j, A i j • x j := rfl + +theorem matrixModuleAction_mul {I J K W : Type*} [Fintype J] [Fintype K] + [AddCommGroup W] [Module ℝ W] (A : Matrix I J ℝ) (B : Matrix J K ℝ) (x : K → W) : + matrixModuleAction A (matrixModuleAction B x) = matrixModuleAction (A * B) x := by + funext i + simp only [matrixModuleAction_apply, Matrix.mul_apply, Finset.smul_sum, Finset.sum_smul, mul_smul] + exact Finset.sum_comm + +theorem matrixModuleAction_image_section {I J W : Type*} [Fintype I] [Fintype J] + [AddCommGroup W] [Module ℝ W] (A : Matrix I J ℝ) (S : Matrix J I ℝ) + (hS : A * S * A = A) (x : J → W) : + matrixModuleAction A (matrixModuleAction S (matrixModuleAction A x)) = matrixModuleAction A x := by + rw [matrixModuleAction_mul, matrixModuleAction_mul, hS] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MatrixSupInverse.lean b/lean/OAI/Combinatorics/Progressions/Linear/MatrixSupInverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a2ee847cb4a8c664a65304afa7b4f4a78b782bf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MatrixSupInverse.lean @@ -0,0 +1,154 @@ +import Mathlib.Analysis.Normed.Module.FiniteDimension +import Mathlib.Data.Fintype.Perm +import Mathlib.LinearAlgebra.Matrix.NonsingularInverse +import Mathlib.Tactic +import Mathlib.Topology.Algebra.Module.ContinuousLinearMap.Invertible + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem matrix_det_abs_le_row_bounds (A : Matrix ι ι ℝ) (H : ι → ℝ) + (hA : ∀ i j, |A i j| ≤ H i) : + |A.det| ≤ (Fintype.card ι).factorial * ∏ i, H i := by + rw [Matrix.det_apply'] + calc + _ ≤ ∑ σ : Equiv.Perm ι, |((Equiv.Perm.sign σ : ℤ) : ℝ) * ∏ i, A (σ i) i| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _σ : Equiv.Perm ι, ∏ i, H i := by + apply Finset.sum_le_sum + intro σ _ + have hsign : |((Equiv.Perm.sign σ : ℤ) : ℝ)| = 1 := by + rw [← Int.cast_abs, Equiv.Perm.sign_abs, Int.cast_one] + rw [abs_mul, hsign, one_mul, Finset.abs_prod] + calc + _ ≤ ∏ i, H (σ i) := + Finset.prod_le_prod₀ (fun i _ => abs_nonneg _) (fun i _ => hA (σ i) i) + _ = ∏ i, H i := Equiv.prod_comp σ H + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_perm, nsmul_eq_mul] + +theorem matrix_det_abs_le_uniform_bound (A : Matrix ι ι ℝ) {H : ℝ} + (hA : ∀ i j, |A i j| ≤ H) : + |A.det| ≤ (Fintype.card ι).factorial * H ^ Fintype.card ι := by + simpa only [Finset.prod_const, Finset.card_univ] using + matrix_det_abs_le_row_bounds A (fun _ => H) hA + +theorem matrix_adjugate_entry_abs_le (A : Matrix ι ι ℝ) {H : ℝ} + (hA : ∀ i j, |A i j| ≤ H) (i j : ι) : + |A.adjugate i j| ≤ (Fintype.card ι).factorial * H ^ (Fintype.card ι - 1) := by + rw [Matrix.adjugate_apply] + let K : ι → ℝ := fun k => if k = j then 1 else H + have hentry : ∀ k l, |(A.updateRow j (Pi.single i 1)) k l| ≤ K k := by + intro k l + by_cases hk : k = j + · subst k + simp only [Matrix.updateRow_self, K, ite_true, Pi.single_apply] + split_ifs <;> norm_num + · simpa only [Matrix.updateRow_ne hk, K, hk, ite_false] using hA k l + have hprod : (∏ k, K k) = H ^ (Fintype.card ι - 1) := by + rw [← Finset.mul_prod_erase Finset.univ K (Finset.mem_univ j)] + have hj : K j = 1 := by simp [K] + rw [hj, one_mul] + calc + (∏ k ∈ Finset.univ.erase j, K k) = ∏ _k ∈ Finset.univ.erase j, H := by + apply Finset.prod_congr rfl + intro k hk + simp only [K, Finset.ne_of_mem_erase hk, ite_false] + _ = _ := by simp + simpa only [hprod] using matrix_det_abs_le_row_bounds _ K hentry + +theorem matrix_inverse_entry_abs_le (A : Matrix ι ι ℝ) {H κ : ℝ} + (hA : ∀ i j, |A i j| ≤ H) (hκ : 0 < κ) (hdet : κ ≤ |A.det|) + (i j : ι) : + |A⁻¹ i j| ≤ ((Fintype.card ι).factorial * H ^ (Fintype.card ι - 1)) / κ := by + rw [Matrix.inv_def, Ring.inverse_eq_inv, Matrix.smul_apply, smul_eq_mul, abs_mul, abs_inv] + have hcof := matrix_adjugate_entry_abs_le A hA i j + have hinv : |A.det|⁻¹ ≤ κ⁻¹ := inv_anti₀ hκ hdet + calc + _ ≤ κ⁻¹ * ((Fintype.card ι).factorial * H ^ (Fintype.card ι - 1)) := + mul_le_mul hinv hcof (abs_nonneg _) (inv_nonneg.mpr hκ.le) + _ = _ := by rw [div_eq_mul_inv]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def matrixSupCLM {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℝ) : (κ → ℝ) →L[ℝ] (ι → ℝ) := + A.mulVecLin.toContinuousLinearMap + +theorem matrixSupCLM_apply {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℝ) (x : κ → ℝ) : matrixSupCLM A x = A.mulVec x := rfl + +theorem matrixSupCLM_norm_le {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℝ) {H : ℝ} (hH : 0 ≤ H) (hA : ∀ i j, |A i j| ≤ H) : + ‖matrixSupCLM A‖ ≤ Fintype.card κ * H := by + apply ContinuousLinearMap.opNorm_le_bound _ (by positivity) + intro x + apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr + intro i + change ‖∑ j, A i j * x j‖ ≤ _ + rw [Real.norm_eq_abs] + calc + _ ≤ ∑ j, |A i j * x j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : κ, H * ‖x‖ := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + have hx : |x j| ≤ ‖x‖ := by simpa only [Real.norm_eq_abs] using norm_le_pi_norm x j + exact mul_le_mul (hA i j) hx (abs_nonneg _) hH + _ = _ := by simp [mul_assoc] + +theorem matrixSupCLM_mul {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν] + (A : Matrix ι κ ℝ) (B : Matrix κ ν ℝ) : + matrixSupCLM (A * B) = (matrixSupCLM A).comp (matrixSupCLM B) := by + ext x i + change ((A * B).mulVec x) i = (A.mulVec (B.mulVec x)) i + rw [Matrix.mulVec_mulVec] + +theorem matrixSupCLM_one {ι : Type*} [Fintype ι] [DecidableEq ι] : + matrixSupCLM (1 : Matrix ι ι ℝ) = ContinuousLinearMap.id ℝ (ι → ℝ) := by + ext x i + change ((1 : Matrix ι ι ℝ).mulVec x) i = x i + simp + +theorem matrixSupCLM_inverse_spec {ι : Type*} [Fintype ι] [DecidableEq ι] + (A : Matrix ι ι ℝ) (hA : A.det ≠ 0) : + (matrixSupCLM A).IsInvertible ∧ (matrixSupCLM A).inverse = matrixSupCLM A⁻¹ := by + have hunit : IsUnit A.det := isUnit_iff_ne_zero.mpr hA + have hright : (matrixSupCLM A).comp (matrixSupCLM A⁻¹) = ContinuousLinearMap.id ℝ (ι → ℝ) := by + rw [← matrixSupCLM_mul, A.mul_nonsing_inv hunit, matrixSupCLM_one] + have hleft : (matrixSupCLM A⁻¹).comp (matrixSupCLM A) = ContinuousLinearMap.id ℝ (ι → ℝ) := by + rw [← matrixSupCLM_mul, A.nonsing_inv_mul hunit, matrixSupCLM_one] + exact ⟨ContinuousLinearMap.IsInvertible.of_inverse hright hleft, + ContinuousLinearMap.inverse_eq hright hleft⟩ + +theorem matrixSupCLM_inverse_norm_le {ι : Type*} [Fintype ι] [DecidableEq ι] + (A : Matrix ι ι ℝ) {H κ : ℝ} (hH : 0 ≤ H) (hA : ∀ i j, |A i j| ≤ H) + (hκ : 0 < κ) (hdet : κ ≤ |A.det|) : + (matrixSupCLM A).IsInvertible ∧ + ‖(matrixSupCLM A).inverse‖ ≤ + Fintype.card ι * (((Fintype.card ι).factorial * H ^ (Fintype.card ι - 1)) / κ) := by + have hne : A.det ≠ 0 := abs_pos.mp (hκ.trans_le hdet) + obtain ⟨hinv, heq⟩ := matrixSupCLM_inverse_spec A hne + refine ⟨hinv, ?_⟩ + rw [heq] + exact matrixSupCLM_norm_le A⁻¹ (by positivity) (matrix_inverse_entry_abs_le A hA hκ hdet) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MinkowskiSecondBoxBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/MinkowskiSecondBoxBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..968e10117eb13e2ce6fdbd41051ef98be97665b2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MinkowskiSecondBoxBasis.lean @@ -0,0 +1,40 @@ +import OAI.Combinatorics.Progressions.Geometry.MinkowskiSecondBox + +namespace OAI + +section + +namespace Erdos3.BohrLattice.MinkowskiSecondBox + +open Module + +theorem projectedTail_det_ne_zero {n : ℕ} + (h : Fin (n + 1)) (B : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hdet : B.det ≠ 0) (hB : B h 0 ≠ 0) : + (projectedTail h B).det ≠ 0 := by + intro hq + have habs := abs_det_eq_abs_pivot_mul_abs_det_projectedTail h B hB + rw [hq, abs_zero, mul_zero] at habs + exact hdet (abs_eq_zero.mp habs) + +noncomputable def projectedTailBasis {n : ℕ} + (h : Fin (n + 1)) (B : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hdet : B.det ≠ 0) (hB : B h 0 ≠ 0) : + Basis (Fin n) ℝ (Fin n → ℝ) := + basisOfLinearIndependentOfCardEqFinrank' + (projectedTail h B).col + (Matrix.linearIndependent_cols_of_det_ne_zero + (projectedTail_det_ne_zero h B hdet hB)) + (by simp) + +@[simp] theorem projectedTailBasis_apply {n : ℕ} + (h : Fin (n + 1)) (B : Matrix (Fin (n + 1)) (Fin (n + 1)) ℝ) + (hdet : B.det ≠ 0) (hB : B h 0 ≠ 0) (j : Fin n) : + projectedTailBasis h B hdet hB j = (projectedTail h B).col j := by + simp [projectedTailBasis] + +end Erdos3.BohrLattice.MinkowskiSecondBox + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MixedPairPartitionKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/MixedPairPartitionKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb6cf020b4e1f32312a4d7dede516c2226709202 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MixedPairPartitionKernel.lean @@ -0,0 +1,433 @@ +import OAI.Combinatorics.Progressions.Estimates.MixedPairPartitionPrecision +import OAI.Combinatorics.Progressions.Estimates.QuarticPairPartitionPrecision + +namespace OAI + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold +open scoped BigOperators + +theorem norm_unit_prod_sub_prod_le_sum {I : Type*} (S : Finset I) (f g : I → ℂ) + (hf : ∀ i ∈ S, ‖f i‖ ≤ 1) (hg : ∀ i ∈ S, ‖g i‖ ≤ 1) : + ‖(∏ i ∈ S, f i) - ∏ i ∈ S, g i‖ ≤ ∑ i ∈ S, ‖f i - g i‖ := by + classical + revert hf hg + induction S using Finset.induction_on with + | empty => intro _ _; simp + | @insert i S hi ih => + intro hf hg + have hrec := ih (fun j hj => hf j (Finset.mem_insert_of_mem hj)) + (fun j hj => hg j (Finset.mem_insert_of_mem hj)) + have hprod : ‖∏ j ∈ S, g j‖ ≤ 1 := by + rw [norm_prod] + exact Finset.prod_le_one₀ (fun _ _ => norm_nonneg _) + (fun j hj => hg j (Finset.mem_insert_of_mem hj)) + rw [Finset.prod_insert hi, Finset.prod_insert hi, Finset.sum_insert hi] + calc + _ = ‖f i * ((∏ j ∈ S, f j) - ∏ j ∈ S, g j) + + (f i - g i) * ∏ j ∈ S, g j‖ := by congr 1; ring + _ ≤ ‖f i‖ * ‖(∏ j ∈ S, f j) - ∏ j ∈ S, g j‖ + + ‖f i - g i‖ * ‖∏ j ∈ S, g j‖ := by + simpa only [norm_mul] using norm_add_le + (f i * ((∏ j ∈ S, f j) - ∏ j ∈ S, g j)) ((f i - g i) * ∏ j ∈ S, g j) + _ ≤ ‖(∏ j ∈ S, f j) - ∏ j ∈ S, g j‖ + ‖f i - g i‖ := + add_le_add (mul_le_of_le_one_left (norm_nonneg _) (hf i (Finset.mem_insert_self _ _))) + (mul_le_of_le_one_right (norm_nonneg _) hprod) + _ ≤ _ := by linarith + +theorem norm_cubic_pair_product_sub_le (a b c d A B C D : ℂ) + (ha : ‖a‖ ≤ 1) (hb : ‖b‖ ≤ 1) (hc : ‖c‖ ≤ 1) (hd : ‖d‖ ≤ 1) + (hA : ‖A‖ ≤ 1) (hB : ‖B‖ ≤ 1) (hC : ‖C‖ ≤ 1) (hD : ‖D‖ ≤ 1) : + ‖(star a * b) * (star c * d) - (star A * B) * (star C * D)‖ ≤ + ‖a - A‖ + ‖b - B‖ + ‖c - C‖ + ‖d - D‖ := by + have h := norm_unit_prod_sub_prod_le_sum Finset.univ ![star a, b, star c, d] ![star A, B, star C, D] + (by intro k _; fin_cases k + · simpa using ha + · simpa using hb + · simpa using hc + · simpa using hd) + (by intro k _; fin_cases k + · simpa using hA + · simpa using hB + · simpa using hC + · simpa using hD) + rw [Fin.prod_univ_four, Fin.prod_univ_four, Fin.sum_univ_four] at h + change ‖star a * b * star c * d - star A * B * star C * D‖ ≤ + ‖star a - star A‖ + ‖b - B‖ + ‖star c - star C‖ + ‖d - D‖ at h + rw [← star_sub, ← star_sub, norm_star, norm_star] at h + simpa only [mul_assoc] using h + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +variable {p q r : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (fun _ : CubicReplicatedIndex => 1) p} {i j : Fin W.outputDim × Fin W.outputDim} {shift : ℤ} + {V : NativeSampleCorrelation (fun _ : Fin 3 => 1) 2 q + Finset.univ (fun z : Fin 3 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.cubicAntisymmetricPair i j (z 1).val (z 2).val (((z 0).val : ℤ) + shift))} + +namespace NativeCubicPairPartition + +attribute [local instance] NativeCubicPairPartition.finite + +variable {b ε : ℝ} + {R : NativePolynomialOrbitFactors (pi V.cubicPairModels) + V.cubicPairPolynomial (piFrequency V.cubicPairFrequencies) + (fun _ : Fin 3 => (N : ℝ)) r} + (P : NativeCubicPairPartition R b ε) + +noncomputable def cellWeight (a : Fin 3 → P.I) (x : Fin 3 → ZMod N) : ℝ := + ∏ l, P.weight (a l) (x l) + +theorem cellWeight_nonneg (a : Fin 3 → P.I) (x : Fin 3 → ZMod N) : 0 ≤ P.cellWeight a x := + Finset.prod_nonneg (fun l _ => ((P.positive (a l)).unit_interval (x l)).1) + +theorem cellWeight_total (x : Fin 3 → ZMod N) : ∑ a, P.cellWeight a x = 1 := + sum_productPartitionWeight (fun _ : Fin 3 => P.weight) (fun _ => P.total) x + +noncomputable def cellVector (a : Fin 3 → P.I) (k : Fin 2) (out : Fin W.outputDim) + (x : Fin 3 → ZMod N) : ℂ := + R.cubicPairAnchoredVector (fun l => ((P.anchor a l).val : ℤ)) k out (fun l => ((x l).val : ℤ)) + +theorem cellVector_norm (a : Fin 3 → P.I) (k : Fin 2) (out : Fin W.outputDim) + (x : Fin 3 → ZMod N) : ‖P.cellVector a k out x‖ ≤ 1 := + R.cubicPairAnchoredVector_norm _ _ _ _ + +noncomputable def cellKernel (a : Fin 3 → P.I) (x : Fin 3 → ZMod N) : ℂ := + (star (P.cellVector a 0 i.1 x) * P.cellVector a 1 j.1 x) * + (star (P.cellVector a 0 i.2 x) * P.cellVector a 1 j.2 x) + +theorem weighted_kernel_error : + (𝔼 x : Fin 3 → ZMod N, ∑ a, P.cellWeight a x * + ‖W.cubicAntisymmetricPair i j (x 1).val (x 2).val (((x 0).val : ℤ) + shift) - P.cellKernel a x‖) ≤ + 4 * ε := by + let F := fun (k : Fin 2) (out : Fin W.outputDim) (x : Fin 3 → ZMod N) => + W.eval out (cubicTrilinearInput (x k.succ).val (x k.rev.succ).val (((x 0).val : ℤ) + shift)) + let e := fun k out a x => ‖F k out x - P.cellVector a k out x‖ + have he (k : Fin 2) (out : Fin W.outputDim) : + (𝔼 x, ∑ a, P.cellWeight a x * e k out a x) ≤ ε := + P.weighted_approximation k out + have hpoint (a : Fin 3 → P.I) (x : Fin 3 → ZMod N) : + ‖W.cubicAntisymmetricPair i j (x 1).val (x 2).val (((x 0).val : ℤ) + shift) - P.cellKernel a x‖ ≤ + e 0 i.1 a x + e 1 j.1 a x + e 0 i.2 a x + e 1 j.2 a x := + norm_cubic_pair_product_sub_le _ _ _ _ _ _ _ _ + (W.norm_eval _ _) (W.norm_eval _ _) (W.norm_eval _ _) (W.norm_eval _ _) + (P.cellVector_norm _ _ _ _) (P.cellVector_norm _ _ _ _) + (P.cellVector_norm _ _ _ _) (P.cellVector_norm _ _ _ _) + calc + _ ≤ 𝔼 x, ∑ a, P.cellWeight a x * + (e 0 i.1 a x + e 1 j.1 a x + e 0 i.2 a x + e 1 j.2 a x) := + Finset.expect_le_expect (fun x _ => Finset.sum_le_sum + (fun a _ => mul_le_mul_of_nonneg_left (hpoint a x) (P.cellWeight_nonneg a x))) + _ = (𝔼 x, ∑ a, P.cellWeight a x * e 0 i.1 a x) + + (𝔼 x, ∑ a, P.cellWeight a x * e 1 j.1 a x) + + (𝔼 x, ∑ a, P.cellWeight a x * e 0 i.2 a x) + + (𝔼 x, ∑ a, P.cellWeight a x * e 1 j.2 a x) := by + simp only [mul_add, Finset.sum_add_distrib, Finset.expect_add_distrib] + _ ≤ ε + ε + ε + ε := add_le_add (add_le_add (add_le_add (he _ _) (he _ _)) (he _ _)) (he _ _) + _ = _ := by ring + +theorem kernel_approximation : + (𝔼 x : Fin 3 → ZMod N, + ‖W.cubicAntisymmetricPair i j (x 1).val (x 2).val (((x 0).val : ℤ) + shift) - + ∑ a, (P.cellWeight a x : ℂ) * P.cellKernel a x‖) ≤ 4 * ε := by + apply le_trans _ P.weighted_kernel_error + exact Finset.expect_le_expect (fun x _ => norm_sub_positive_sum_le_weighted + (fun a => P.cellWeight a x) (fun a => P.cellKernel a x) _ + (fun a => P.cellWeight_nonneg a x) (P.cellWeight_total x)) + +theorem exists_correlating_cell (f : (Fin 3 → ZMod N) → ℂ) {δ : ℝ} + (hδ : 0 < δ) (hf : ∀ x, ‖f x‖ ≤ 1) (herr : 4 * ε ≤ δ / 2) + (hcorr : δ ≤ ‖𝔼 x, f x * star + (W.cubicAntisymmetricPair i j (x 1).val (x 2).val (((x 0).val : ℤ) + shift))‖) : + ∃ a : Fin 3 → P.I, δ / (2 * Real.exp b) ≤ + ‖𝔼 x, f x * star ((P.cellWeight a x : ℂ) * P.cellKernel a x)‖ := + exists_correlating_summand_of_mean f _ (fun a x => (P.cellWeight a x : ℂ) * P.cellKernel a x) + hδ (Real.exp_pos b) P.card_bound hf (P.kernel_approximation.trans herr) hcorr + +end NativeCubicPairPartition +end Erdos3 + +end + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold +open scoped BigOperators + +theorem norm_unit_pair_products_sub_le {I : Type*} [Fintype I] + (f g F G : I → ℂ) (hf : ∀ i, ‖f i‖ ≤ 1) (hg : ∀ i, ‖g i‖ ≤ 1) + (hF : ∀ i, ‖F i‖ ≤ 1) (hG : ∀ i, ‖G i‖ ≤ 1) : + ‖(∏ i, f i) * star (∏ i, g i) - (∏ i, F i) * star (∏ i, G i)‖ ≤ + (∑ i, ‖f i - F i‖) + ∑ i, ‖g i - G i‖ := by + have hnorm (u : I → ℂ) (hu : ∀ i, ‖u i‖ ≤ 1) : ‖∏ i, u i‖ ≤ 1 := by + rw [norm_prod] + exact Finset.prod_le_one₀ (fun _ _ => norm_nonneg _) (fun i _ => hu i) + have h := norm_unit_prod_sub_prod_le_sum Finset.univ + ![∏ i, f i, star (∏ i, g i)] ![∏ i, F i, star (∏ i, G i)] + (by intro k _; fin_cases k + · exact hnorm f hf + · change ‖star (∏ i, g i)‖ ≤ 1 + rw [norm_star] + exact hnorm g hg) + (by intro k _; fin_cases k + · exact hnorm F hF + · change ‖star (∏ i, G i)‖ ≤ 1 + rw [norm_star] + exact hnorm G hG) + rw [Fin.prod_univ_two, Fin.prod_univ_two, Fin.sum_univ_two] at h + change ‖(∏ i, f i) * star (∏ i, g i) - (∏ i, F i) * star (∏ i, G i)‖ ≤ + ‖(∏ i, f i) - ∏ i, F i‖ + ‖star (∏ i, g i) - star (∏ i, G i)‖ at h + rw [← star_sub, norm_star] at h + exact h.trans (add_le_add + (norm_unit_prod_sub_prod_le_sum Finset.univ f F (fun i _ => hf i) (fun i _ => hF i)) + (norm_unit_prod_sub_prod_le_sum Finset.univ g G (fun i _ => hg i) (fun i _ => hG i))) + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +namespace NativeMultidegreeNilcharacter + +variable {p : ℝ} (W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) p) + +noncomputable def quarticTensorIndex (i : Fin (W.tensorPower 6).outputDim) : Fin 6 → Fin W.outputDim := + (tensorIndexEquiv W.outputDim 6).symm i + +theorem quarticTensor_eval (i : Fin (W.tensorPower 6).outputDim) (x : QuarticReplicatedIndex → ℤ) : + (W.tensorPower 6).eval i x = ∏ l, W.eval (W.quarticTensorIndex i l) x := rfl + +end NativeMultidegreeNilcharacter + +variable {p q r : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) p} + {i j : Fin (W.tensorPower 6).outputDim} + {V : NativeSampleCorrelation (fun _ : Fin 4 => 1) 3 q + Finset.univ (fun z : Fin 4 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => (W.tensorPower 6).quarticAntisymmetric i j (fun k => ((z k).val : ℤ)))} + +namespace NativeQuarticPairPartition + +attribute [local instance] NativeQuarticPairPartition.finite + +variable {b ε : ℝ} + {R : NativePolynomialOrbitFactors (pi V.quarticPairModels) + V.quarticPairPolynomial (piFrequency V.quarticPairFrequencies) + (fun _ : Fin 4 => (N : ℝ)) r} + (P : NativeQuarticPairPartition R b ε) + +noncomputable def cellWeight (a : Fin 4 → P.I) (x : Fin 4 → ZMod N) : ℝ := + ∏ l, P.weight (a l) (x l) + +theorem cellWeight_nonneg (a : Fin 4 → P.I) (x : Fin 4 → ZMod N) : 0 ≤ P.cellWeight a x := + Finset.prod_nonneg (fun l _ => ((P.positive (a l)).unit_interval (x l)).1) + +theorem cellWeight_total (x : Fin 4 → ZMod N) : ∑ a, P.cellWeight a x = 1 := + sum_productPartitionWeight (fun _ : Fin 4 => P.weight) (fun _ => P.total) x + +noncomputable def cellVector (a : Fin 4 → P.I) (k : Fin 2) (out : Fin W.outputDim) + (x : Fin 4 → ZMod N) : ℂ := + R.quarticPairAnchoredVector (fun l => ((P.anchor a l).val : ℤ)) k out (fun l => ((x l).val : ℤ)) + +theorem cellVector_norm (a : Fin 4 → P.I) (k : Fin 2) (out : Fin W.outputDim) + (x : Fin 4 → ZMod N) : ‖P.cellVector a k out x‖ ≤ 1 := + R.quarticPairAnchoredVector_norm _ _ _ _ + +noncomputable def cellKernel (a : Fin 4 → P.I) (x : Fin 4 → ZMod N) : ℂ := + (∏ l, P.cellVector a 0 (W.quarticTensorIndex i l) x) * + star (∏ l, P.cellVector a 1 (W.quarticTensorIndex j l) x) + +theorem weighted_kernel_error : + (𝔼 x : Fin 4 → ZMod N, ∑ a, P.cellWeight a x * + ‖(W.tensorPower 6).quarticAntisymmetric i j (fun k => ((x k).val : ℤ)) - P.cellKernel a x‖) ≤ + 12 * ε := by + let F := fun (k : Fin 2) (out : Fin W.outputDim) (x : Fin 4 → ZMod N) => + W.eval out (quarticInput ((x (![0, 1] k)).val : ℤ) + ![((x (![1, 0] k)).val : ℤ), ((x 2).val : ℤ), ((x 3).val : ℤ)]) + let e := fun k out a x => ‖F k out x - P.cellVector a k out x‖ + have he (k : Fin 2) (out : Fin W.outputDim) : + (𝔼 x, ∑ a, P.cellWeight a x * e k out a x) ≤ ε := P.weighted_approximation k out + have hpoint (a : Fin 4 → P.I) (x : Fin 4 → ZMod N) : + ‖(W.tensorPower 6).quarticAntisymmetric i j (fun k => ((x k).val : ℤ)) - P.cellKernel a x‖ ≤ + (∑ l, e 0 (W.quarticTensorIndex i l) a x) + ∑ l, e 1 (W.quarticTensorIndex j l) a x := by + change ‖(∏ l, F 0 (W.quarticTensorIndex i l) x) * star (∏ l, F 1 (W.quarticTensorIndex j l) x) - + (∏ l, P.cellVector a 0 (W.quarticTensorIndex i l) x) * + star (∏ l, P.cellVector a 1 (W.quarticTensorIndex j l) x)‖ ≤ _ + exact norm_unit_pair_products_sub_le _ _ _ _ + (fun _ => W.norm_eval _ _) (fun _ => W.norm_eval _ _) + (fun _ => P.cellVector_norm _ _ _ _) (fun _ => P.cellVector_norm _ _ _ _) + have hsum (E : Fin 6 → (Fin 4 → P.I) → (Fin 4 → ZMod N) → ℝ) : + (𝔼 x, ∑ a, P.cellWeight a x * ∑ l, E l a x) = + ∑ l, 𝔼 x, ∑ a, P.cellWeight a x * E l a x := by + calc + _ = 𝔼 x, ∑ l, ∑ a, P.cellWeight a x * E l a x := by + apply Finset.expect_congr rfl + intro x _ + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + _ = _ := Finset.expect_sum_comm _ _ _ + calc + _ ≤ 𝔼 x, ∑ a, P.cellWeight a x * + ((∑ l, e 0 (W.quarticTensorIndex i l) a x) + ∑ l, e 1 (W.quarticTensorIndex j l) a x) := + Finset.expect_le_expect (fun x _ => Finset.sum_le_sum + (fun a _ => mul_le_mul_of_nonneg_left (hpoint a x) (P.cellWeight_nonneg a x))) + _ = (∑ l, 𝔼 x, ∑ a, P.cellWeight a x * e 0 (W.quarticTensorIndex i l) a x) + + ∑ l, 𝔼 x, ∑ a, P.cellWeight a x * e 1 (W.quarticTensorIndex j l) a x := by + simp only [mul_add, Finset.sum_add_distrib, Finset.expect_add_distrib] + rw [hsum, hsum] + _ ≤ (∑ _l : Fin 6, ε) + ∑ _l : Fin 6, ε := + add_le_add (Finset.sum_le_sum (fun l _ => he _ _)) (Finset.sum_le_sum (fun l _ => he _ _)) + _ = _ := by simp; ring + +theorem kernel_approximation : + (𝔼 x : Fin 4 → ZMod N, + ‖(W.tensorPower 6).quarticAntisymmetric i j (fun k => ((x k).val : ℤ)) - + ∑ a, (P.cellWeight a x : ℂ) * P.cellKernel a x‖) ≤ 12 * ε := by + apply le_trans _ P.weighted_kernel_error + exact Finset.expect_le_expect (fun x _ => norm_sub_positive_sum_le_weighted + (fun a => P.cellWeight a x) (fun a => P.cellKernel a x) _ + (fun a => P.cellWeight_nonneg a x) (P.cellWeight_total x)) + +theorem exists_correlating_cell (f : (Fin 4 → ZMod N) → ℂ) {δ : ℝ} + (hδ : 0 < δ) (hf : ∀ x, ‖f x‖ ≤ 1) (herr : 12 * ε ≤ δ / 2) + (hcorr : δ ≤ ‖𝔼 x, f x * star + ((W.tensorPower 6).quarticAntisymmetric i j (fun k => ((x k).val : ℤ)))‖) : + ∃ a : Fin 4 → P.I, δ / (2 * Real.exp b) ≤ + ‖𝔼 x, f x * star ((P.cellWeight a x : ℂ) * P.cellKernel a x)‖ := + exists_correlating_summand_of_mean f _ (fun a x => (P.cellWeight a x : ℂ) * P.cellKernel a x) + hδ (Real.exp_pos b) P.card_bound hf (P.kernel_approximation.trans herr) hcorr + +end NativeQuarticPairPartition +end Erdos3 + +end + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold +open scoped BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +variable {n m : ℕ} {p q r : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (fun _ : MixedReplicatedIndex (n + 1) => 1) p} + {i j : Fin (W.tensorPower m).outputDim} + {V : NativeSampleCorrelation (fun _ : Fin (n + 2) => 1) (n + 1) q + Finset.univ (fun z : Fin (n + 2) → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => (W.tensorPower m).mixedAntisymmetric i j (fun k => ((z k).val : ℤ)))} + +namespace NativeMixedPairPartition + +attribute [local instance] NativeMixedPairPartition.finite + +variable {b ε : ℝ} + {R : NativePolynomialOrbitFactors (pi V.mixedPairModels) + V.mixedPairPolynomial (piFrequency V.mixedPairFrequencies) + (fun _ : Fin (n + 2) => (N : ℝ)) r} + (P : NativeMixedPairPartition R b ε) + +noncomputable def cellWeight (a : Fin (n + 2) → P.I) (x : Fin (n + 2) → ZMod N) : ℝ := + ∏ l, P.weight (a l) (x l) + +theorem cellWeight_nonneg (a : Fin (n + 2) → P.I) (x : Fin (n + 2) → ZMod N) : 0 ≤ P.cellWeight a x := + Finset.prod_nonneg (fun l _ => ((P.positive (a l)).unit_interval (x l)).1) + +theorem cellWeight_total (x : Fin (n + 2) → ZMod N) : ∑ a, P.cellWeight a x = 1 := + sum_productPartitionWeight (fun _ : Fin (n + 2) => P.weight) (fun _ => P.total) x + +noncomputable def cellVector (a : Fin (n + 2) → P.I) (k : Fin 2) (out : Fin W.outputDim) + (x : Fin (n + 2) → ZMod N) : ℂ := + R.mixedPairAnchoredVector (fun l => ((P.anchor a l).val : ℤ)) k out (fun l => ((x l).val : ℤ)) + +theorem cellVector_norm (a : Fin (n + 2) → P.I) (k : Fin 2) (out : Fin W.outputDim) + (x : Fin (n + 2) → ZMod N) : ‖P.cellVector a k out x‖ ≤ 1 := + R.mixedPairAnchoredVector_norm _ _ _ _ + +noncomputable def cellKernel (a : Fin (n + 2) → P.I) (x : Fin (n + 2) → ZMod N) : ℂ := + (∏ l, P.cellVector a 0 ((tensorIndexEquiv W.outputDim m).symm i l) x) * + star (∏ l, P.cellVector a 1 ((tensorIndexEquiv W.outputDim m).symm j l) x) + +theorem weighted_kernel_error : + (𝔼 x : Fin (n + 2) → ZMod N, ∑ a, P.cellWeight a x * + ‖(W.tensorPower m).mixedAntisymmetric i j (fun k => ((x k).val : ℤ)) - P.cellKernel a x‖) ≤ + 2 * (m : ℝ) * ε := by + let F := fun (k : Fin 2) (out : Fin W.outputDim) (x : Fin (n + 2) → ZMod N) => + W.eval out (mixedSlotInput ((x (![0, 1] k)).val : ℤ) ((x (![1, 0] k)).val : ℤ) (fun l => ((x l.succ.succ).val : ℤ))) + let e := fun k out a x => ‖F k out x - P.cellVector a k out x‖ + have he (k : Fin 2) (out : Fin W.outputDim) : + (𝔼 x, ∑ a, P.cellWeight a x * e k out a x) ≤ ε := P.weighted_approximation k out + have hpoint (a : Fin (n + 2) → P.I) (x : Fin (n + 2) → ZMod N) : + ‖(W.tensorPower m).mixedAntisymmetric i j (fun k => ((x k).val : ℤ)) - P.cellKernel a x‖ ≤ + (∑ l, e 0 ((tensorIndexEquiv W.outputDim m).symm i l) a x) + ∑ l, e 1 ((tensorIndexEquiv W.outputDim m).symm j l) a x := by + change ‖(∏ l, F 0 ((tensorIndexEquiv W.outputDim m).symm i l) x) * star (∏ l, F 1 ((tensorIndexEquiv W.outputDim m).symm j l) x) - + (∏ l, P.cellVector a 0 ((tensorIndexEquiv W.outputDim m).symm i l) x) * + star (∏ l, P.cellVector a 1 ((tensorIndexEquiv W.outputDim m).symm j l) x)‖ ≤ _ + exact norm_unit_pair_products_sub_le _ _ _ _ + (fun _ => W.norm_eval _ _) (fun _ => W.norm_eval _ _) + (fun _ => P.cellVector_norm _ _ _ _) (fun _ => P.cellVector_norm _ _ _ _) + have hsum (E : Fin m → (Fin (n + 2) → P.I) → (Fin (n + 2) → ZMod N) → ℝ) : + (𝔼 x, ∑ a, P.cellWeight a x * ∑ l, E l a x) = + ∑ l, 𝔼 x, ∑ a, P.cellWeight a x * E l a x := by + calc + _ = 𝔼 x, ∑ l, ∑ a, P.cellWeight a x * E l a x := by + apply Finset.expect_congr rfl + intro x _ + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + _ = _ := Finset.expect_sum_comm _ _ _ + calc + _ ≤ 𝔼 x, ∑ a, P.cellWeight a x * + ((∑ l, e 0 ((tensorIndexEquiv W.outputDim m).symm i l) a x) + ∑ l, e 1 ((tensorIndexEquiv W.outputDim m).symm j l) a x) := + Finset.expect_le_expect (fun x _ => Finset.sum_le_sum + (fun a _ => mul_le_mul_of_nonneg_left (hpoint a x) (P.cellWeight_nonneg a x))) + _ = (∑ l, 𝔼 x, ∑ a, P.cellWeight a x * e 0 ((tensorIndexEquiv W.outputDim m).symm i l) a x) + + ∑ l, 𝔼 x, ∑ a, P.cellWeight a x * e 1 ((tensorIndexEquiv W.outputDim m).symm j l) a x := by + simp only [mul_add, Finset.sum_add_distrib, Finset.expect_add_distrib] + rw [hsum, hsum] + _ ≤ (∑ _l : Fin m, ε) + ∑ _l : Fin m, ε := + add_le_add (Finset.sum_le_sum (fun l _ => he _ _)) (Finset.sum_le_sum (fun l _ => he _ _)) + _ = _ := by simp; ring + +theorem kernel_approximation : + (𝔼 x : Fin (n + 2) → ZMod N, + ‖(W.tensorPower m).mixedAntisymmetric i j (fun k => ((x k).val : ℤ)) - + ∑ a, (P.cellWeight a x : ℂ) * P.cellKernel a x‖) ≤ 2 * (m : ℝ) * ε := by + apply le_trans _ P.weighted_kernel_error + exact Finset.expect_le_expect (fun x _ => norm_sub_positive_sum_le_weighted + (fun a => P.cellWeight a x) (fun a => P.cellKernel a x) _ + (fun a => P.cellWeight_nonneg a x) (P.cellWeight_total x)) + +theorem exists_correlating_cell (f : (Fin (n + 2) → ZMod N) → ℂ) {δ : ℝ} + (hδ : 0 < δ) (hf : ∀ x, ‖f x‖ ≤ 1) (herr : 2 * (m : ℝ) * ε ≤ δ / 2) + (hcorr : δ ≤ ‖𝔼 x, f x * star + ((W.tensorPower m).mixedAntisymmetric i j (fun k => ((x k).val : ℤ)))‖) : + ∃ a : Fin (n + 2) → P.I, δ / (2 * Real.exp b) ≤ + ‖𝔼 x, f x * star ((P.cellWeight a x : ℂ) * P.cellKernel a x)‖ := + exists_correlating_summand_of_mean f _ (fun a x => (P.cellWeight a x : ℂ) * P.cellKernel a x) + hδ (Real.exp_pos b) P.card_bound hf (P.kernel_approximation.trans herr) hcorr + +end NativeMixedPairPartition +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MixedSumKernelCorrelation.lean b/lean/OAI/Combinatorics/Progressions/Linear/MixedSumKernelCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b94cc18d4ecf4e0fe89339765fa3cfcb3cd713c9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MixedSumKernelCorrelation.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.Progressions.Estimates.MixedAnchorExpansion +import OAI.Combinatorics.Progressions.Geometry.MixedAntisymmetricBox + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_mixed_kernel_correlation (n : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ}, 0 ≤ p → + ∀ (W : NativeMultidegreeNilcharacter (fun _ : MixedReplicatedIndex (n + 1) => 1) p) + {N : ℕ} [NeZero N] (i j : Fin W.outputDim), + Real.exp (-p) ≤ (boxPhaseMoment (n + 2) (fun x : Fin (n + 2) → ZMod N => + W.mixedAntisymmetric i j (fun k => ((x k).val : ℤ)))).re → + Nonempty (NativeSampleCorrelation (fun _ : Fin (n + 2) => 1) (n + 1) ((p + C) ^ C) + Finset.univ (fun x : Fin (n + 2) → ZMod N => fun k => ((x k).val : ℤ)) + (fun x => W.mixedAntisymmetric i j (fun k => ((x k).val : ℤ)))) := by + obtain ⟨A, _, hanchor⟩ := NativeMultidegreeNilcharacter.exists_mixed_anchor_expansion n + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (X + (X + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro p hp W N _ i j hbias + let K := W.mixedAntisymmetric i j + let Kc := fun x : Fin (n + 2) → ZMod N => K (fun k => ((x k).val : ℤ)) + obtain ⟨a, ha⟩ := exists_box_corner_anchor_correlation Kc + obtain ⟨E⟩ := hanchor W i j (fun k => ((a k).val : ℤ)) + have hmap (x : Fin (n + 2) → ZMod N) : boxCornerAnchor Kc a x = + boxCornerAnchor K (fun k => ((a k).val : ℤ)) (fun k => ((x k).val : ℤ)) := + boxCornerAnchor_map (fun z : ZMod N => (z.val : ℤ)) K a x + have hcorr : Real.exp (-p) ≤ ‖𝔼 x : Fin (n + 2) → ZMod N, + K (fun k => ((x k).val : ℤ)) * + star (star (boxCornerAnchor K (fun k => ((a k).val : ℤ)) + (fun k => ((x k).val : ℤ))))‖ := by + have h := hbias.trans ha + simp_rw [hmap] at h + simpa only [Kc, star_star] using h + obtain ⟨S⟩ := NativeSampleCorrelation.exists_of_expansion E.conjugate hp hcorr + have hcost : p + (p + A) ^ A ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨S.mono hcost⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open scoped BigOperators + +theorem exists_mixed_sum_kernel_correlation (n : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ} + (W : NativeMultidegreeNilcharacter (fun _ : MixedReplicatedIndex (n + 1) => 1) p) + {N : ℕ} [NeZero N] (f : ZMod N → ℂ), (∀ x, ‖f x‖ ≤ 1) → + ∀ (i : Fin W.outputDim) (A : Fin (n + 2) → (Fin (n + 2) → ZMod N) → ℂ), + (∀ j x, ‖A j x‖ ≤ 1) → (∀ j, MissesBoxCoordinate (A j) j) → + Real.exp (-p) ≤ ‖𝔼 u : Fin n → ZMod N, 𝔼 m : ZMod N, 𝔼 h : ZMod N, + f (m + h + ∑ j, u j) * star (W.eval i (mixedSlotInput (h.val : ℤ) m.val (fun j => (u j).val))) * + ∏ j, A j (Fin.cons h (Fin.cons m u))‖ → + ∃ j k : Fin W.outputDim, + Nonempty (NativeSampleCorrelation (fun _ : Fin (n + 2) => 1) (n + 1) ((p + C) ^ C) + Finset.univ (fun x : Fin (n + 2) → ZMod N => fun l => ((x l).val : ℤ)) + (fun x => W.mixedAntisymmetric j k (fun l => ((x l).val : ℤ)))) := by + obtain ⟨a, _, hbox⟩ := exists_mixed_sum_antisymmetric_box n + obtain ⟨b, _, hkernel⟩ := exists_mixed_kernel_correlation n + let X : Polynomial ℕ := Polynomial.X + let Q := (X + Polynomial.C a) ^ a + let R := X + Q + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((R + Polynomial.C b) ^ b) + refine ⟨C, hC, ?_⟩ + intro p W N _ f hf i A hA hmiss hcorr + have hp : 0 ≤ p := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + let q := (p + a) ^ a + let r := p + q + 2 + have hq : 0 ≤ q := by dsimp only [q]; positivity + have hpr : p ≤ r := by dsimp only [r]; linarith + have hqr : q ≤ r := by dsimp only [r]; linarith + have hr : 0 ≤ r := hp.trans hpr + obtain ⟨j, k, hmoment⟩ := hbox W f hf i A hA hmiss hcorr + have hmono (x : Fin (n + 2) → ℤ) : + (W.mono hpr).mixedAntisymmetric j k x = W.mixedAntisymmetric j k x := rfl + have hinput : Real.exp (-r) ≤ + (boxPhaseMoment (n + 2) (fun x : Fin (n + 2) → ZMod N => + (W.mono hpr).mixedAntisymmetric j k (fun l => (x l).val))).re := by + simpa only [hmono] using (Real.exp_le_exp.mpr (neg_le_neg hqr)).trans hmoment + obtain ⟨S⟩ := hkernel hr (W.mono hpr) j k hinput + have hcost : (r + b) ^ b ≤ (p + C) ^ C := by + simpa [X, Q, R, q, r, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨j, k, ⟨S.mono hcost⟩⟩ + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ModeRankLogBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/ModeRankLogBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..3bfdc31fd978b8732962ccc76a4c9f41de6b19e6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ModeRankLogBudget.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.Progressions.Dynamics.ModeThresholdLogBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def modeRankLog (m : ℕ) (P : ℝ) : ℝ := + (m : ℝ) + 1 + ∑ i : Fin m, + ((((i.val + 1).factorial : ℝ) + P + (i.val + 1 : ℕ) * P) + + P ^ (i.val + 1) * (modeBiasLog m P + (i.val + 1 : ℕ) * P) + + ((i.val + 1 : ℕ) * P + (i.val + 1 : ℕ) * (modeShrinkLog m P + 2) + modeBiasLog m P) + 2) + +theorem modeRankLog_nonneg (m : ℕ) {P : ℝ} (hP : 0 ≤ P) : 0 ≤ modeRankLog m P := by + have hb := modeBiasLog_nonneg m hP + have ht := modeShrinkLog_nonneg m hP + unfold modeRankLog + positivity + +theorem modeRemovalRankThreshold_le_exp (m n d : ℕ) {P C D S ρ ε : ℝ} + (hP : 0 ≤ P) (hn : (n : ℝ) ≤ P) (hd : (d : ℝ) ≤ P) + (hC : 0 ≤ C) (hCP : C ≤ Real.exp P) (hD : 0 ≤ D) (hDP : D ≤ Real.exp P) + (hS : 0 ≤ S) (hSP : S ≤ Real.exp P) (hρ : 0 < ρ) (hρInv : 1 / ρ ≤ Real.exp P) + (hε : 0 < ε) (hεInv : 1 / ε ≤ Real.exp P) : + modeRemovalRankThreshold m n d C D S ρ ε ≤ Real.exp (modeRankLog m P) := by + let B := finiteLayerBiasBudget m (modeRemovalBias m ε) + let A := 2 * modeRemovalShrink m d D ρ ε + have hB : B ≤ Real.exp (modeBiasLog m P) := chosenBiasBudget_le_exp m hP hε hεInv + have hB0 : 0 ≤ B := zero_le_one.trans (finiteLayerBiasBudget_one_le m (modeRemovalBias_pos m hε)) + have hT0 := modeRemovalShrink_one_le m d hD hρ hε + have hA0 : 0 ≤ A := by dsimp [A]; positivity + have hT := modeRemovalShrink_le_exp m d hP hd hD hDP hρ hρInv hε hεInv + have h2 : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + have hA : A ≤ Real.exp (modeShrinkLog m P + 2) := by + calc + _ ≤ Real.exp 2 * Real.exp (modeShrinkLog m P) := by dsimp [A]; gcongr + _ = _ := by rw [← Real.exp_add, add_comm] + have hnp : (n : ℝ) ≤ Real.exp P := hn.trans (by linarith [Real.add_one_le_exp P]) + have hBL := modeBiasLog_nonneg m hP + have hTL := modeShrinkLog_nonneg m hP + let cost (i : Fin m) := ((i.val + 1).factorial : ℝ) * (C * D ^ (i.val + 1)) + + (B * S ^ (i.val + 1)) ^ (n ^ (i.val + 1)) + + (n : ℝ) ^ (i.val + 1) * (A ^ (i.val + 1) * B) + let bound (i : Fin m) := + ((((i.val + 1).factorial : ℝ) + P + (i.val + 1 : ℕ) * P) + + P ^ (i.val + 1) * (modeBiasLog m P + (i.val + 1 : ℕ) * P) + + ((i.val + 1 : ℕ) * P + (i.val + 1 : ℕ) * (modeShrinkLog m P + 2) + modeBiasLog m P) + 2) + have hbound i : 0 ≤ bound i := by dsimp [bound]; positivity + have hcost (i : Fin m) : cost i ≤ Real.exp (bound i) := by + have hf : ((i.val + 1).factorial : ℝ) ≤ Real.exp ((i.val + 1).factorial : ℝ) := by + linarith [Real.add_one_le_exp ((i.val + 1).factorial : ℝ)] + have hrow : ((i.val + 1).factorial : ℝ) * (C * D ^ (i.val + 1)) ≤ + Real.exp (((i.val + 1).factorial : ℝ) + P + (i.val + 1 : ℕ) * P) := by + calc + _ ≤ Real.exp ((i.val + 1).factorial : ℝ) * (Real.exp P * (Real.exp P) ^ (i.val + 1)) := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hden : (B * S ^ (i.val + 1)) ^ (n ^ (i.val + 1)) ≤ + Real.exp (P ^ (i.val + 1) * (modeBiasLog m P + (i.val + 1 : ℕ) * P)) := by + calc + _ ≤ (Real.exp (modeBiasLog m P) * (Real.exp P) ^ (i.val + 1)) ^ (n ^ (i.val + 1)) := by gcongr + _ = Real.exp ((n : ℝ) ^ (i.val + 1) * (modeBiasLog m P + (i.val + 1 : ℕ) * P)) := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_nat_mul, Nat.cast_pow] + _ ≤ _ := Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (Nat.cast_nonneg _) hn _) (by positivity)) + have hcoeff : (n : ℝ) ^ (i.val + 1) * (A ^ (i.val + 1) * B) ≤ + Real.exp ((i.val + 1 : ℕ) * P + (i.val + 1 : ℕ) * (modeShrinkLog m P + 2) + modeBiasLog m P) := by + calc + _ ≤ (Real.exp P) ^ (i.val + 1) * ((Real.exp (modeShrinkLog m P + 2)) ^ (i.val + 1) * + Real.exp (modeBiasLog m P)) := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add]; congr 1; ring + have hsum := add_le_exp_add_one (by positivity) (by positivity) hrow hden + have hsum' := add_le_exp_add_one (by positivity) (by positivity) hsum hcoeff + convert hsum' using 1 + congr 1 + dsimp [bound] + ring + have hsum := sum_le_exp_card_add_sum cost bound hbound hcost + have hout := one_add_le_exp_succ (by positivity) hsum + change 1 + ∑ i : Fin m, cost i ≤ _ + convert hout using 1 + congr 1 + simp only [modeRankLog, Fintype.card_fin] + dsimp [bound] + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ModularDesignatedCoefficientRank.lean b/lean/OAI/Combinatorics/Progressions/Linear/ModularDesignatedCoefficientRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b774c38d431e3a6166cdfbb1e369ecb6a7ccada --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ModularDesignatedCoefficientRank.lean @@ -0,0 +1,168 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialDifferencePermanentBlocks + +namespace OAI + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +theorem uniform_expect_coordinate_product {A R : Type*} [Fintype A] [DecidableEq A] + [Fintype R] (f : A → R → ℝ) : + (𝔼 c : A → R, ∏ b, f b (c b)) = ∏ b, 𝔼 t : R, f b t := by + simp only [Fintype.expect_eq_sum_div_card] + rw [← Fintype.prod_sum, Finset.prod_div_distrib] + simp [Nat.cast_pow] + +theorem uniform_selected_row_zero_probability_le {A I : Type*} + [Fintype A] [DecidableEq A] [Fintype I] [DecidableEq I] + (N : ℕ) [NeZero N] (row : (A → ZMod N) → I → ZMod N) + (selected : A → I) (offset multiplier : A → ZMod N) + (hrow : ∀ c b, row c (selected b) = offset b + c b * multiplier b) : + (𝔼 c : A → ZMod N, if row c = 0 then (1 : ℝ) else 0) ≤ + ∏ b, (Nat.gcd (multiplier b).val N : ℝ) / N := by + calc + _ ≤ 𝔼 c : A → ZMod N, + ∏ b, if c b * multiplier b + offset b = 0 then (1 : ℝ) else 0 := by + apply Finset.expect_le_expect + intro c _ + by_cases hc : row c = 0 + · simp only [hc, ite_true] + have he (b : A) : c b * multiplier b + offset b = 0 := by + have hz := congrFun hc (selected b) + rw [hrow] at hz + simpa only [Pi.zero_apply, add_comm] using hz + simp only [he, ite_true, Finset.prod_const_one, le_refl] + · simp only [hc, ite_false] + exact Finset.prod_nonneg (fun b _ => by split_ifs <;> norm_num) + _ = ∏ b, 𝔼 t : ZMod N, + if t * multiplier b + offset b = 0 then (1 : ℝ) else 0 := + uniform_expect_coordinate_product (A := A) (R := ZMod N) + (fun b t => if t * multiplier b + offset b = 0 then (1 : ℝ) else 0) + _ ≤ _ := by + apply Finset.prod_le_prod₀ + · intro b _ + exact Finset.expect_nonneg (fun t _ => by split_ifs <;> norm_num) + · intro b _ + simpa only [mul_comm] using zmod_affine_zero_expect_le_gcd N (multiplier b) (offset b) + +theorem designatedPolynomial_linearRow_zero_probability_le {A I : Type*} + [Fintype A] [DecidableEq A] [Fintype I] [decI : DecidableEq I] + (N : ℕ) [NeZero N] (n : ℕ) (S : A → Finset I) + (selected : A → I) (hselected : ∀ b, selected b ∈ S b) + (hcard : ∀ b, (S b).card = n + 1) + (hdisjoint : Pairwise (fun b c => Disjoint (S b) (S c))) + (Q : MvPolynomial I (ZMod N)) (u : Fin n → I → ZMod N) : + (𝔼 c : A → ZMod N, + if polynomialLinearRow (polynomialIterDifference n + (Q + ∑ b, c b • ∏ i ∈ S b, X i) u) = 0 then (1 : ℝ) else 0) ≤ + ∏ b, (Nat.gcd (squarefreePermanent n ((S b).erase (selected b)) u).val N : ℝ) / N := by + apply uniform_selected_row_zero_probability_le N _ selected + (fun b => (polynomialIterDifference n Q u).coeff (Finsupp.single (selected b) 1)) + (fun b => squarefreePermanent n ((S b).erase (selected b)) u) + intro c b + have hd : decI = + (fun i j => Classical.propDecidable (i = j)) := Subsingleton.elim _ _ + rw [hd] + exact polynomialIterDifference_disjoint_designated_linearCoeff + Finset.univ S c Q n b (Finset.mem_univ _) (selected b) (hselected b) (hcard b) + (fun _ _ _ _ hbc => hdisjoint hbc) u + +theorem designatedPolynomial_expected_linearRow_zero_le {A I : Type*} + [Fintype A] [DecidableEq A] [Fintype I] [decI : DecidableEq I] + {p a n : ℕ} [NeZero p] (hp : p.Prime) (ha : 0 < a) + (S : A → Finset I) (selected : A → I) + (hselected : ∀ b, selected b ∈ S b) (hcard : ∀ b, (S b).card = n + 1) + (hdisjoint : Pairwise (fun b c => Disjoint (S b) (S c))) + (Q : MvPolynomial I (ZMod (p ^ a))) : + (𝔼 c : A → ZMod (p ^ a), 𝔼 u : Fin n → I → ZMod (p ^ a), + if polynomialLinearRow (polynomialIterDifference n + (Q + ∑ b, c b • ∏ i ∈ S b, X i) u) = 0 then (1 : ℝ) else 0) ≤ + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := by + have hc (b : A) : Fintype.card ((S b).erase (selected b)) = n := by + rw [Fintype.card_coe, Finset.card_erase_of_mem (hselected b), hcard] + omega + let e (b : A) : Fin n ≃ (S b).erase (selected b) := (Fintype.equivFinOfCardEq (hc b)).symm + let v (b : A) (j : Fin n) : I := (e b j).val + have hv : ∀ b ∈ (Finset.univ : Finset A), Function.Injective (v b) := by + intro b _ i j hij + exact (e b).injective (Subtype.ext hij) + have hsep : ((Finset.univ : Finset A) : Set A).Pairwise (fun b c => + Disjoint (Finset.univ.image (v b)) (Finset.univ.image (v c))) := by + intro b _ c _ hbc + apply Finset.disjoint_left.mpr + intro i hib hic + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hib + obtain ⟨k, _, hk⟩ := Finset.mem_image.mp hic + have hj : v b j ∈ S b := (Finset.mem_erase.mp (e b j).property).2 + have hk' : v b j ∈ S c := hk ▸ (Finset.mem_erase.mp (e c k).property).2 + exact Finset.disjoint_left.mp (hdisjoint hbc) hj hk' + have hperm (b : A) (u : Fin n → I → ZMod (p ^ a)) : + squarefreePermanent n ((S b).erase (selected b)) u = + Matrix.permanent (fun i j => u i (v b j)) := + squarefreePermanent_eq_matrix_permanent n _ (e b) u + rw [Finset.expect_comm] + calc + _ ≤ 𝔼 u : Fin n → I → ZMod (p ^ a), + ∏ b, (Nat.gcd (squarefreePermanent n ((S b).erase (selected b)) u).val + (p ^ a) : ℝ) / (p ^ a : ℕ) := by + apply Finset.expect_le_expect + intro u _ + exact designatedPolynomial_linearRow_zero_probability_le (p ^ a) n S selected + hselected hcard hdisjoint Q u + _ ≤ _ := by + simp_rw [hperm] + simpa only [Finset.card_univ] using + disjoint_permanent_gcd_mean_bound_curried_all hp ha Finset.univ v hv hsep + +theorem uniform_expect_unit_scaled_coefficients {A R : Type*} + [Fintype A] [DecidableEq A] [Fintype R] [Monoid R] + (unit : A → Rˣ) (F : (A → R) → ℝ) : + (𝔼 c : A → R, F (fun b => (unit b : R) * c b)) = 𝔼 c : A → R, F c := by + apply Fintype.expect_equiv (Equiv.piCongrRight (fun b => Units.mulLeft (unit b))) + intro c + rfl + +theorem designatedPolynomial_expected_unit_linearRow_zero_le {A I : Type*} + [Fintype A] [DecidableEq A] [Fintype I] [DecidableEq I] + {p a n : ℕ} [NeZero p] (hp : p.Prime) (ha : 0 < a) + (S : A → Finset I) (selected : A → I) + (hselected : ∀ b, selected b ∈ S b) (hcard : ∀ b, (S b).card = n + 1) + (hdisjoint : Pairwise (fun b c => Disjoint (S b) (S c))) + (Q : MvPolynomial I (ZMod (p ^ a))) (unit : A → (ZMod (p ^ a))ˣ) : + (𝔼 c : A → ZMod (p ^ a), 𝔼 u : Fin n → I → ZMod (p ^ a), + if polynomialLinearRow (polynomialIterDifference n + (Q + ∑ b, ((unit b : ZMod (p ^ a)) * c b) • ∏ i ∈ S b, X i) u) = 0 + then (1 : ℝ) else 0) ≤ + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := by + have he := uniform_expect_unit_scaled_coefficients unit (fun c => + 𝔼 u : Fin n → I → ZMod (p ^ a), + if polynomialLinearRow (polynomialIterDifference n + (Q + ∑ b, c b • ∏ i ∈ S b, X i) u) = 0 then (1 : ℝ) else 0) + rw [he] + exact designatedPolynomial_expected_linearRow_zero_le hp ha S selected + hselected hcard hdisjoint Q + +theorem designatedPolynomial_expected_rank_failure_le {A I : Type*} + [Fintype A] [DecidableEq A] [Fintype I] [DecidableEq I] + {p a n : ℕ} [NeZero p] (hp : p.Prime) (ha : 0 < a) + (S : A → Finset I) (hcard : ∀ b, (S b).card = n + 1) + (hdisjoint : Pairwise (fun b c => Disjoint (S b) (S c))) + (Q : MvPolynomial I (ZMod (p ^ a))) (unit : A → (ZMod (p ^ a))ˣ) : + (𝔼 c : A → ZMod (p ^ a), 𝔼 u : Fin n → I → ZMod (p ^ a), + if polynomialLinearRow (polynomialIterDifference n + (Q + ∑ b, ((unit b : ZMod (p ^ a)) * c b) • ∏ i ∈ S b, X i) u) = 0 + then (1 : ℝ) else 0) ≤ + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := by + have hnonempty (b : A) : (S b).Nonempty := + Finset.card_pos.mp (by rw [hcard]; omega) + choose selected hselected using hnonempty + exact designatedPolynomial_expected_unit_linearRow_zero_le hp ha S selected + hselected hcard hdisjoint Q unit + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ModularVectorCoefficientRank.lean b/lean/OAI/Combinatorics/Progressions/Linear/ModularVectorCoefficientRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..4105200af3ce42e7875895397bc2596637ce7a8b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ModularVectorCoefficientRank.lean @@ -0,0 +1,81 @@ +import OAI.Combinatorics.Progressions.Estimates.ModularDesignatedCoefficientMarkov +import OAI.Combinatorics.Progressions.Estimates.ModularVectorCoefficientDecomposition + +namespace OAI + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +noncomputable def vectorDesignatedRankFailureProbability {A B I : Type*} + [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] (N n : ℕ) [NeZero N] + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod N)) + (w : B → ZMod N) (c : B → A → ZMod N) : ℝ := + 𝔼 u : Fin n → I → ZMod N, + if polynomialLinearRow (polynomialIterDifference n + (∑ b, w b • designatedVectorComponent S Q c b) u) = 0 then 1 else 0 + +theorem vectorDesignatedRankFailureProbability_nonneg {A B I : Type*} + [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] (N n : ℕ) [NeZero N] + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod N)) + (w : B → ZMod N) (c : B → A → ZMod N) : + 0 ≤ vectorDesignatedRankFailureProbability N n S Q w c := + Finset.expect_nonneg (fun _ _ => by split_ifs <;> norm_num) + +theorem vectorDesignatedRankFailureProbability_mean_le_of_unit {A B I : Type*} + [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] {p a n : ℕ} [NeZero p] + (hp : p.Prime) (ha : 0 < a) + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod (p ^ a))) + (w : B → ZMod (p ^ a)) (b₀ : B) (hunit : IsUnit (w b₀)) + (hcard : ∀ j, (S b₀ j).card = n + 1) + (hdisjoint : Pairwise (fun j k => Disjoint (S b₀ j) (S b₀ k))) : + (FiniteProbabilityWeights.uniform (B → A → ZMod (p ^ a))).mean + (vectorDesignatedRankFailureProbability (p ^ a) n S Q w) ≤ + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := by + obtain ⟨unit, hunit⟩ := hunit + have hconditional (c : B → A → ZMod (p ^ a)) : + (𝔼 d : A → ZMod (p ^ a), vectorDesignatedRankFailureProbability (p ^ a) n S Q w + (Function.update c b₀ d)) ≤ + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := by + unfold vectorDesignatedRankFailureProbability + simp_rw [designatedVectorComponent_update_row] + have h := designatedPolynomial_expected_rank_failure_le hp ha (S b₀) hcard hdisjoint + ((∑ b ∈ Finset.univ.erase b₀, w b • designatedVectorComponent S Q c b) + w b₀ • Q b₀) + (fun _ => unit) + simpa only [hunit] using h + rw [FiniteProbabilityWeights.uniform_mean, + ← expect_uniform_coordinate_refresh b₀ (vectorDesignatedRankFailureProbability (p ^ a) n S Q w)] + calc + _ ≤ 𝔼 _c : B → A → ZMod (p ^ a), + (((n + 1 : ℕ) : ℝ) * (p : ℝ) ^ (-(a : ℝ) / (2 : ℝ) ^ n)) ^ Fintype.card A := + Finset.expect_le_expect (fun c _ => hconditional c) + _ = _ := Fintype.expect_const _ + +theorem vectorDesignatedRankFailureProbability_mean_le {A B I : Type*} + [Fintype A] [DecidableEq A] [Fintype B] [DecidableEq B] + [Fintype I] [DecidableEq I] {p a n s : ℕ} [NeZero p] + (hp : p.Prime) (ha : 0 < a) (hns : n + 1 ≤ s) + (S : B → A → Finset I) (Q : B → MvPolynomial I (ZMod (p ^ a))) + (hcard : ∀ b j, (S b j).card = n + 1) + (hdisjoint : ∀ b, Pairwise (fun j k => Disjoint (S b j) (S b k))) + (w : B → ZMod (p ^ a)) (hprimitive : ∃ b, IsUnit (w b)) : + (FiniteProbabilityWeights.uniform (B → A → ZMod (p ^ a))).mean + (vectorDesignatedRankFailureProbability (p ^ a) n S Q w) ≤ + ((s : ℝ) * ((p : ℝ) ^ a) ^ (-modularRankSmallBallExponent s)) ^ Fintype.card A := by + obtain ⟨b, hb⟩ := hprimitive + have h := vectorDesignatedRankFailureProbability_mean_le_of_unit hp ha S Q w b hb + (hcard b) (hdisjoint b) + apply h.trans + apply pow_le_pow_left₀ (by positivity) + exact modularRank_tag_cost_le hns (by exact_mod_cast hp.one_lt.le) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MultiaffineTripleLayerBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/MultiaffineTripleLayerBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e0afb08016235bfbd49037c95f721d35bc23161 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MultiaffineTripleLayerBasis.lean @@ -0,0 +1,90 @@ +import Mathlib.LinearAlgebra.Basis.Prod +import OAI.Combinatorics.Progressions.Linear.RankQuotientHeightBudget + +namespace OAI + +section + +namespace Erdos3.MultidegreeLieFiltration + +open Module + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) + +noncomputable def additiveTripleLayerEquiv (i : σ) (c : σ → ℕ) (n : ℕ) : + (F.weightedLayer c n × F.coordinateActiveLayer i n × F.coordinateActiveLayer i n) + ≃ₗ[ℚ] F.additiveTripleLayer i c n where + toFun x := ⟨tripleAssemble (x.1 : L) (x.2.1 : L) (x.2.2 : L), by + rw [F.mem_additiveTripleLayer, tripleNeutral_assemble, tripleLeft_assemble, + tripleRight_assemble] + exact ⟨x.1.property, x.2.1.property, x.2.2.property⟩⟩ + invFun x := (⟨tripleNeutral x.val, x.property.1⟩, + ⟨tripleLeft x.val, x.property.2.1⟩, ⟨tripleRight x.val, x.property.2.2⟩) + left_inv x := by + apply Prod.ext + · exact Subtype.ext (tripleNeutral_assemble _ _ _) + · exact Prod.ext (Subtype.ext (tripleLeft_assemble _ _ _)) + (Subtype.ext (tripleRight_assemble _ _ _)) + right_inv x := Subtype.ext (tripleAssemble_decompose x.val) + map_add' x y := by + apply Subtype.ext + ext <;> simp only [tripleAssemble, Prod.fst_add, Prod.snd_add, + Submodule.coe_add, LieSubmodule.coe_add] <;> abel + map_smul' r x := by + apply Subtype.ext + ext <;> simp [tripleAssemble, smul_add] + +theorem exists_additiveTriple_layer_basis {ι α β : Type*} + [Fintype ι] [Fintype α] [Fintype β] + (e : Basis ι ℚ L) (i : σ) (c : σ → ℕ) (n : ℕ) + (a : Basis α ℚ (F.weightedLayer c n)) + (b : Basis β ℚ (F.coordinateActiveLayer i n)) + {H : ℕ} (hH : 1 ≤ H) + (ha : ∀ j k, RationalHeightLE (e.repr (a j : L) k) H) + (hb : ∀ j k, RationalHeightLE (e.repr (b j : L) k) H) : + ∃ q : Basis (Fin (finrank ℚ (F.additiveTripleLayer i c n))) ℚ + (F.additiveTripleLayer i c n), + ∀ j k, RationalHeightLE (e.repr (q j).val.1 k) H ∧ + RationalHeightLE (e.repr (q j).val.2.1 k) H ∧ + RationalHeightLE (e.repr (q j).val.2.2 k) H := by + classical + let q := (a.prod (b.prod b)).map (F.additiveTripleLayerEquiv i c n) + have hzero (k : ι) : RationalHeightLE (e.repr 0 k) H := by + simpa only [map_zero, Finsupp.zero_apply] using rationalHeightLE_zero hH + have hq (j : α ⊕ (β ⊕ β)) (k : ι) : + RationalHeightLE (e.repr (q j).val.1 k) H ∧ + RationalHeightLE (e.repr (q j).val.2.1 k) H ∧ + RationalHeightLE (e.repr (q j).val.2.2 k) H := by + rcases j with j | j | j + · simpa [q, Basis.prod_apply, additiveTripleLayerEquiv, tripleAssemble] using + (show RationalHeightLE (e.repr (a j : L) k) H ∧ + RationalHeightLE (e.repr (a j : L) k) H ∧ + RationalHeightLE (e.repr (a j : L) k) H from ⟨ha j k, ha j k, ha j k⟩) + · simpa [q, Basis.prod_apply, additiveTripleLayerEquiv, tripleAssemble] using + (show RationalHeightLE (e.repr (b j : L) k) H ∧ + RationalHeightLE (e.repr (b j : L) k) H ∧ + RationalHeightLE (e.repr 0 k) H from ⟨hb j k, hb j k, hzero k⟩) + · simpa [q, Basis.prod_apply, additiveTripleLayerEquiv, tripleAssemble] using + (show RationalHeightLE (e.repr (b j : L) k) H ∧ + RationalHeightLE (e.repr 0 k) H ∧ + RationalHeightLE (e.repr (b j : L) k) H from ⟨hb j k, hzero k, hb j k⟩) + let r := q.reindex (Fintype.equivFinOfCardEq (finrank_eq_card_basis q).symm) + refine ⟨r, fun j k => ?_⟩ + simpa only [r, Basis.reindex_apply] using hq _ k + +noncomputable def additiveTripleFiltrationLayerEquiv (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) (n : ℕ) (hn : 1 ≤ n) : + (F.additiveTripleFiltration i hi c hc).layer n ≃ₗ[ℚ] F.additiveTripleLayer i c n where + toFun x := ⟨x.val.val, x.property⟩ + invFun x := ⟨⟨x.val, F.additiveTripleLayer_antitone i c hn x.property⟩, x.property⟩ + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl + +end Erdos3.MultidegreeLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/MultidegreeBasisConstruction.lean b/lean/OAI/Combinatorics/Progressions/Linear/MultidegreeBasisConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..efdeca03e4658c3372696718bc97795c58a4d668 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/MultidegreeBasisConstruction.lean @@ -0,0 +1,51 @@ +import OAI.Combinatorics.Progressions.Linear.RankQuotientHeightBudget + +namespace OAI + +section + +namespace Erdos3.MultidegreeLieFiltration + +open Module +open scoped BigOperators + +variable {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) + (b : ∀ a, Basis (Fin (finrank ℚ (F.layer a))) ℚ (F.layer a)) + +theorem ordinaryLayer_eq_span_multidegree_bases (n : ℕ) : + F.ordinary.layer n = Submodule.span ℚ + (Set.range (fun z : Σ a : {a : σ → ℕ // n ≤ ∑ i, a i}, + Fin (finrank ℚ (F.layer a.val)) => ((b z.1.val) z.2).val)) := by + rw [F.degree_eq] + apply le_antisymm + · apply iSup_le + intro a + apply iSup_le + intro ha + rw [← span_submodule_basis (F.layer a) (b a)] + apply Submodule.span_le.mpr + rintro x ⟨j, rfl⟩ + exact Submodule.subset_span ⟨⟨⟨a, ha⟩, j⟩, rfl⟩ + · apply Submodule.span_le.mpr + rintro x ⟨⟨a, j⟩, rfl⟩ + have hle : F.layer a.val ≤ ⨆ (u : σ → ℕ) (_hu : n ≤ ∑ i, u i), F.layer u := + le_iSup_of_le a.val (le_iSup_of_le a.property le_rfl) + exact hle ((b a.val) j).property + +theorem exists_bounded_ordinaryLayer_basis {ι : Type*} [Fintype ι] + (e : Basis ι ℚ L) {H : ℕ} + (hb : ∀ a i j, RationalHeightLE (e.repr ((b a) i).val j) H) (n : ℕ) : + ∃ c : Basis (Fin (finrank ℚ (F.ordinary.layer n))) ℚ (F.ordinary.layer n), + ∀ i j, RationalHeightLE (e.repr (c i).val j) H := by + apply exists_bounded_submodule_basis_from_spanning e (F.ordinary.layer n) + (fun z : Σ a : {a : σ → ℕ // n ≤ ∑ i, a i}, + Fin (finrank ℚ (F.layer a.val)) => ((b z.1.val) z.2).val) + (F.ordinaryLayer_eq_span_multidegree_bases b n).symm + exact fun z j => hb z.1.val z.2 j + +end Erdos3.MultidegreeLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeChartKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeChartKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..48b3a09c5ccc652ca57897e86790a18c12893bb6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeChartKernel.lean @@ -0,0 +1,261 @@ +import OAI.Combinatorics.Progressions.Nilpotent.IdealInvariantNiltestBudget + +namespace OAI + +section + +namespace Erdos3 + +open Set +open scoped NNReal + +variable {ι X : Type*} [Fintype ι] [MetricSpace X] + +noncomputable def chartCoordinateKernel (phi : OpenPartialHomeomorph (ι → ℝ) X) + (F : X → ℝ) : (ι → ℝ) → ℝ := chartCutoff phi.symm F + +omit [Fintype ι] in +theorem chartCoordinateKernel_of_mem (phi : OpenPartialHomeomorph (ι → ℝ) X) + (F : X → ℝ) {v : ι → ℝ} (hv : v ∈ phi.source) : + chartCoordinateKernel phi F v = F (phi v) := by + classical + change (if v ∈ phi.source then F (phi v) else 0) = _ + rw [ite_eq_left hv] + +omit [Fintype ι] in +theorem chartCoordinateKernel_of_not_mem (phi : OpenPartialHomeomorph (ι → ℝ) X) + (F : X → ℝ) {v : ι → ℝ} (hv : v ∉ phi.source) : + chartCoordinateKernel phi F v = 0 := by + classical + change (if v ∈ phi.source then F (phi v) else 0) = _ + rw [ite_eq_right hv] + +omit [Fintype ι] in +theorem chartCoordinateKernel_recover (phi : OpenPartialHomeomorph (ι → ℝ) X) + (F : X → ℝ) {x : X} (hx : x ∈ phi.target) : + chartCoordinateKernel phi F (phi.symm x) = F x := + chartCutoff_apply phi.symm F hx + +omit [Fintype ι] in +theorem chartCoordinateKernel_range (phi : OpenPartialHomeomorph (ι → ℝ) X) + (F : X → ℝ) (hF : ∀ x, 0 ≤ F x ∧ F x ≤ 1) (v : ι → ℝ) : + 0 ≤ chartCoordinateKernel phi F v ∧ chartCoordinateKernel phi F v ≤ 1 := + chartCutoff_range phi.symm F hF v + +theorem chartCoordinateKernel_support (phi : OpenPartialHomeomorph (ι → ℝ) X) + (F : X → ℝ) {r : ℝ} (hr : 0 < r) + (hsource : phi.source = {v | ∀ i, |v i| < r}) + (hinner : tsupport F ⊆ phi '' Metric.closedBall 0 (3 * r / 4)) : + Function.support (chartCoordinateKernel phi F) ⊆ Metric.closedBall 0 (3 * r / 4) := by + intro v hv + change chartCoordinateKernel phi F v ≠ 0 at hv + have hvs : v ∈ phi.source := by + by_contra h + exact hv (chartCoordinateKernel_of_not_mem phi F h) + have hFv : F (phi v) ≠ 0 := by + rwa [chartCoordinateKernel_of_mem phi F hvs] at hv + obtain ⟨u, hu, heq⟩ := hinner (subset_closure hFv) + have hus := closedBox_subset_chart_source phi hr hsource hu + have huv : u = v := by + calc + u = phi.symm (phi u) := (phi.left_inv hus).symm + _ = phi.symm (phi v) := congrArg phi.symm heq + _ = v := phi.left_inv hvs + exact huv ▸ hu + +theorem chartCoordinateKernel_lipschitz (phi : OpenPartialHomeomorph (ι → ℝ) X) + (F : X → ℝ) (A K r : ℝ≥0) (hr : 0 < r) + (hF : ∀ x, 0 ≤ F x ∧ F x ≤ 1) (hLip : LipschitzWith A F) + (hsource : phi.source = {v | ∀ i, |v i| < (r : ℝ)}) + (hinner : tsupport F ⊆ phi '' Metric.closedBall 0 (3 * (r : ℝ) / 4)) + (hForward : LipschitzOnWith K phi phi.source) : + LipschitzWith (A * K + 1 / (r / 4)) (chartCoordinateKernel phi F) := by + apply lipschitz_chartCutoff phi.symm F A K (r / 4) (by positivity) hF hLip hForward + intro v hv hFv y hy + change v ∈ phi.source at hv + change y ∉ phi.source at hy + have hvk : chartCoordinateKernel phi F v ≠ 0 := by + rwa [chartCoordinateKernel_of_mem phi F hv] + have hball := chartCoordinateKernel_support phi F hr hsource hinner hvk + rw [Metric.mem_closedBall, dist_zero_right] at hball + obtain ⟨i, hyi⟩ : ∃ i, (r : ℝ) ≤ |y i| := by + simpa only [hsource, mem_ofPred_eq, not_forall, not_lt] using hy + have hvi : |v i| ≤ 3 * (r : ℝ) / 4 := by + calc + |v i| = ‖v i‖ := (Real.norm_eq_abs _).symm + _ ≤ ‖v‖ := norm_le_pi_norm v i + _ ≤ _ := hball + have hd : |y i - v i| ≤ dist v y := by + simpa only [Real.dist_eq, abs_sub_comm] using dist_le_pi_dist v y i + have ht : |y i| ≤ |y i - v i| + |v i| := by + simpa only [sub_add_cancel] using abs_add_le (y i - v i) (v i) + change (r : ℝ) / 4 ≤ dist v y + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem chartKernelScaling_lipschitz (d B : ℕ) : + LipschitzWith (B : ℝ≥0) (fun x : Fin d → ℝ => (B : ℝ) • x) := by + apply LipschitzWith.of_dist_le_mul + intro x y + simp only [dist_eq_norm, ← smul_sub, norm_smul, Real.norm_eq_abs, + abs_of_nonneg (Nat.cast_nonneg (α := ℝ) B), NNReal.coe_natCast] + exact le_rfl + +variable {X : Type*} [MetricSpace X] {d : ℕ} + (phi : OpenPartialHomeomorph (Fin d → ℝ) X) (F : X → ℝ) + (A K r : ℝ≥0) (hr : 0 < r) (hr1 : r ≤ 1) + (hF : ∀ x, 0 ≤ F x ∧ F x ≤ 1) (hLip : LipschitzWith A F) + (hsource : phi.source = {v | ∀ i, |v i| < (r : ℝ)}) + (hinner : tsupport F ⊆ phi '' Metric.closedBall 0 (3 * (r : ℝ) / 4)) + (hForward : LipschitzOnWith K phi phi.source) (B : ℕ) (hB : 4 ≤ B) + +noncomputable def scaledChartKernel : PatchKernel d where + value x := chartCoordinateKernel phi F ((B : ℝ) • x) + nonneg x := (chartCoordinateKernel_range phi F hF _).1 + le_one x := (chartCoordinateKernel_range phi F hF _).2 + support x hx i := by + have hb := chartCoordinateKernel_support phi F hr hsource hinner hx + rw [Metric.mem_closedBall, dist_zero_right] at hb + have hi : (B : ℝ) * |x i| ≤ 3 * (r : ℝ) / 4 := by + calc + (B : ℝ) * |x i| = ‖((B : ℝ) • x) i‖ := by + simp only [Pi.smul_apply, smul_eq_mul, Real.norm_eq_abs, abs_mul, + abs_of_nonneg (Nat.cast_nonneg (α := ℝ) B)] + _ ≤ ‖(B : ℝ) • x‖ := norm_le_pi_norm ((B : ℝ) • x) i + _ ≤ _ := hb + have hBr : (4 : ℝ) ≤ B := by exact_mod_cast hB + have hsmall := mul_le_mul_of_nonneg_right hBr (abs_nonneg (x i)) + have hr1' : (r : ℝ) ≤ 1 := hr1 + linarith + lip := (A * K + 1 / (r / 4)) * B + lipschitz := by + simpa only [Function.comp_def] using + (chartCoordinateKernel_lipschitz phi F A K r hr hF hLip hsource hinner hForward).comp + (chartKernelScaling_lipschitz d B) + +theorem scaledChartKernel_value (x : Fin d → ℝ) : + (scaledChartKernel phi F A K r hr hr1 hF hLip hsource hinner hForward B hB).value x = + chartCoordinateKernel phi F ((B : ℝ) • x) := rfl + +theorem scaledChartKernel_lip : + (scaledChartKernel phi F A K r hr hr1 hF hLip hsource hinner hForward B hB).lip = + (A * K + 1 / (r / 4)) * B := rfl + +theorem scaledChartKernel_recover {x : X} (hx : x ∈ phi.target) : + (scaledChartKernel phi F A K r hr hr1 hF hLip hsource hinner hForward B hB).value + (fun i => phi.symm x i / B) = F x := by + have hB0 : (B : ℝ) ≠ 0 := by exact_mod_cast (show B ≠ 0 by omega) + have he : (B : ℝ) • (fun i => phi.symm x i / B) = phi.symm x := by + funext i + change (B : ℝ) * (phi.symm x i / B) = phi.symm x i + field_simp [hB0] + rw [scaledChartKernel_value, he] + exact chartCoordinateKernel_recover phi F hx + +theorem chartKernel_log_bound {A K r : ℝ≥0} {B : ℕ} {p : ℝ} (hp : 0 ≤ p) + (hA : (A : ℝ) ≤ Real.exp p) (hK : (K : ℝ) ≤ Real.exp p) + (hr : 1 / (r : ℝ) ≤ Real.exp p) (hB : (B : ℝ) ≤ Real.exp p) : + Real.log (2 + (((A * K + 1 / (r / 4)) * B : ℝ≥0) : ℝ)) ≤ 3 * p + 6 := by + apply (Real.log_le_iff_le_exp (by positivity)).mpr + simp only [NNReal.coe_mul, NNReal.coe_add, NNReal.coe_div, + NNReal.coe_natCast, NNReal.coe_one, NNReal.coe_ofNat] + rw [show 1 / ((r : ℝ) / 4) = 4 * (1 / (r : ℝ)) by ring] + have he : 1 ≤ Real.exp p := Real.one_le_exp hp + have he3 : 1 ≤ Real.exp p ^ 3 := one_le_pow₀ he + have he23 : Real.exp p ^ 2 ≤ Real.exp p ^ 3 := pow_le_pow_right₀ he (by decide) + have hAK := mul_le_mul hA hK K.coe_nonneg (Real.exp_nonneg p) + have hfour := mul_le_mul_of_nonneg_left hr (by norm_num : (0 : ℝ) ≤ 4) + have hprod := mul_le_mul (add_le_add hAK hfour) hB (Nat.cast_nonneg B) + (show 0 ≤ Real.exp p * Real.exp p + 4 * Real.exp p by positivity) + have hseven : (7 : ℝ) ≤ Real.exp 6 := by linarith [Real.add_one_le_exp (6 : ℝ)] + have hlast := mul_le_mul_of_nonneg_left hseven (show 0 ≤ Real.exp p ^ 3 by positivity) + rw [Real.exp_add] + have heq : Real.exp (3 * p) = Real.exp p ^ 3 := by + simpa using Real.exp_nat_mul p 3 + rw [heq] + nlinarith + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} (T : D.Niltest w) + +theorem realObservable_lipschitz : + letI := D.metricSpace + LipschitzWith T.lipBound (fun x => (T.observable x).re) := by + let := D.metricSpace + simpa only [one_mul, Function.comp_def, RCLike.re_eq_complex_re] using + (RCLike.lipschitzWith_re (K := ℂ)).comp T.lipschitz + +theorem realObservable_tsupport : + tsupport (fun x => (T.observable x).re) ⊆ tsupport T.observable := by + apply closure_mono + intro x hx + change T.observable x ≠ 0 + intro hzero + apply hx + change (T.observable x).re = 0 + rw [hzero, Complex.zero_re] + +variable (hT : T.UnitIntervalValued) (phi : OpenPartialHomeomorph (Fin d → ℝ) D.Space) + (K r : ℝ≥0) (hr : 0 < r) (hr1 : r ≤ 1) + (hsource : phi.source = {v | ∀ i, |v i| < (r : ℝ)}) + (hinner : tsupport T.observable ⊆ phi '' Metric.closedBall 0 (3 * (r : ℝ) / 4)) + (hForward : letI := D.metricSpace; LipschitzOnWith K phi phi.source) (hgrid : 4 ≤ D.grid) + +noncomputable def chartKernel : PatchKernel d := by + let := D.metricSpace + exact scaledChartKernel phi (fun x => (T.observable x).re) T.lipBound K r hr hr1 + (fun x => (hT x).2) T.realObservable_lipschitz hsource + (T.realObservable_tsupport.trans hinner) hForward D.grid hgrid + +theorem chartKernel_lip : + (T.chartKernel hT phi K r hr hr1 hsource hinner hForward hgrid).lip = + (T.lipBound * K + 1 / (r / 4)) * D.grid := rfl + +theorem chartKernel_value (v : Fin d → ℝ) : + letI := D.metricSpace + (T.chartKernel hT phi K r hr hr1 hsource hinner hForward hgrid).value v = + chartCoordinateKernel phi (fun x => (T.observable x).re) ((D.grid : ℝ) • v) := rfl + +theorem chartKernel_recover {x : D.Space} (hx : x ∈ phi.target) : + (T.chartKernel hT phi K r hr hr1 hsource hinner hForward hgrid).value + (fun i => phi.symm x i / D.grid) = (T.observable x).re := by + let := D.metricSpace + exact scaledChartKernel_recover phi (fun x => (T.observable x).re) T.lipBound K r hr hr1 + (fun x => (hT x).2) T.realObservable_lipschitz hsource + (T.realObservable_tsupport.trans hinner) hForward D.grid hgrid hx + +theorem chartKernel_log_bound {p : ℝ} (hp : 0 ≤ p) (hcomplexity : T.ComplexityLE p) + (hK : (K : ℝ) ≤ Real.exp p) (hri : 1 / (r : ℝ) ≤ Real.exp p) : + Real.log (2 + ((T.chartKernel hT phi K r hr hr1 hsource hinner hForward hgrid).lip : ℝ)) ≤ + 3 * p + 6 := by + rw [T.chartKernel_lip] + apply Erdos3.chartKernel_log_bound hp ?_ hK hri hcomplexity.1.2.1 + have hb := observable_budget hcomplexity + linarith [T.normBound.coe_nonneg] + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeCoefficientKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeCoefficientKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b2bfd8c0fd6721b0e2b7a13414b127f91debc58 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeCoefficientKernel.lean @@ -0,0 +1,1028 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonSubspaceFamily +import OAI.Combinatorics.Progressions.Estimates.ProjectedHorizontalFactorization +import OAI.Combinatorics.Progressions.Fourier.RealLayerHorizontalFrequency +import OAI.Combinatorics.Progressions.Geometry.NativeCoordinateEstimates +import OAI.Combinatorics.Progressions.Linear.RankProductOrbitCoefficients + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem realifyFunctional_lieTreeEval_rational (η : L →ₗ[ℚ] ℚ) (v : I → L) (a : FreeMagma I) : + realifyFunctional η (lieTreeEval (fun i => rationalLieInclusion (v i)) a) = + (η (lieTreeEval v a) : ℝ) := by + rw [lieTreeEval_hom rationalLieInclusion v a] + simp only [rationalLieInclusion_apply, realifyFunctional_tmul, one_mul] + +theorem rational_lieTree_kernel_of_real (A : I → Submodule ℚ L) + (η : L →ₗ[ℚ] ℚ) (a : FreeMagma I) + (hker : ∀ z : I → ℝ ⊗[ℚ] L, (∀ i, z i ∈ (A i).baseChange ℝ) → + realifyFunctional η (lieTreeEval z a) = 0) + (v : I → L) (hv : ∀ i, v i ∈ A i) : η (lieTreeEval v a) = 0 := by + have h := hker (fun i => rationalLieInclusion (v i)) + (fun i => Submodule.tmul_mem_baseChange_of_mem (1 : ℝ) (hv i)) + rw [realifyFunctional_lieTreeEval_rational] at h + exact_mod_cast h + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankInterval + +open RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + (U : LieSubalgebra ℚ (pi (I.productModels i)).filtration.AssociatedGraded) + +noncomputable def refilteredHorizontalImage (d : ℕ) : + Submodule ℚ (Fin 4 → W.rank.filtration.HigherHorizontal d) := + W.rank.filtration.layerHorizontalImage + ((pi (I.productModels i)).filtration.gradedRefiltrationLayer U) + (I.rankProjection i) (I.rankProjection_mem_refiltered i U) d + +theorem refilteredHorizontalImage_frequency {J : Type*} (d : J → ℕ) (a : FreeMagma J) + (hd : lieTreeWeight d a = s) (hr : a.length = r) + (hker : ∀ z : J → ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k), + (∀ j, z j ∈ (pi (I.productModels i)).filtration.realGradedRefiltrationLayer U (d j)) → + realifyFunctional (piFrequency (I.productFrequencies i)) (lieTreeEval z a) = 0) + (v : ∀ j, Fin 4 → W.rank.filtration.HigherHorizontal (d j)) + (hv : ∀ j, v j ∈ I.refilteredHorizontalImage i U (d j)) : + W.vertical.frequency (W.rank.filtration.horizontalTreeValue d a (fun j => v j 0)) + + W.vertical.frequency (W.rank.filtration.horizontalTreeValue d a (fun j => v j 1)) - + W.vertical.frequency (W.rank.filtration.horizontalTreeValue d a (fun j => v j 2)) - + W.vertical.frequency (W.rank.filtration.horizontalTreeValue d a (fun j => v j 3)) = 0 := by + apply W.rank.filtration.layerHorizontalImage_frequency + ((pi (I.productModels i)).filtration.gradedRefiltrationLayer U) + (I.rankProjection i) (I.rankProjection_mem_refiltered i U) W.vertical.frequency d a hd hr ?_ v hv + intro u hu + rw [← I.rankProjection_frequency i] + exact rational_lieTree_kernel_of_real + (fun j => (pi (I.productModels i)).filtration.gradedRefiltrationLayer U (d j)) + (piFrequency (I.productFrequencies i)) a hker u hu + +theorem refiltered_sunflower_bracket {J : Type*} (d : J → ℕ) (a : FreeMagma J) + (hd : lieTreeWeight d a = s) (hr : a.length = r) + (hker : ∀ z : J → ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k), + (∀ j, z j ∈ (pi (I.productModels i)).filtration.realGradedRefiltrationLayer U (d j)) → + realifyFunctional (piFrequency (I.productFrequencies i)) (lieTreeEval z a) = 0) + (v : ∀ j, W.rank.filtration.HigherHorizontal (d j)) + (hv : ∀ j, v j ∈ fourFirstProjection (I.refilteredHorizontalImage i U (d j))) + (j k : J) (hjk : j ≠ k) (hj : j ∈ lieTreeSupport a) (hk : k ∈ lieTreeSupport a) + (hvj : v j ∈ fourDependentProjection (I.refilteredHorizontalImage i U (d j))) + (hvk : v k ∈ fourDependentProjection (I.refilteredHorizontalImage i U (d k))) : + W.vertical.frequency (W.rank.filtration.horizontalTreeValue d a v) = 0 := + four_dependent_inputs_vanish (lieTreeSupport a) (W.rank.filtration.horizontalTreeValue d a) + (fun u j hj hu => W.rank.filtration.horizontalTreeValue_zero_of_leaf d a u (i := j) hj hu) + W.vertical.frequency (map_zero _) (fun j => I.refilteredHorizontalImage i U (d j)) + (I.refilteredHorizontalImage_frequency i U d a hd hr hker) v hv j k hjk hj hk hvj hvk + +theorem refiltered_sunflower_representatives {J : Type*} (d : J → ℕ) (a : FreeMagma J) + (hd : lieTreeWeight d a = s) (hr : a.length = r) + (hker : ∀ z : J → ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k), + (∀ j, z j ∈ (pi (I.productModels i)).filtration.realGradedRefiltrationLayer U (d j)) → + realifyFunctional (piFrequency (I.productFrequencies i)) (lieTreeEval z a) = 0) + (v : ∀ j, W.rank.filtration.layer (d j) 1) + (hv : ∀ j, W.rank.filtration.higherHorizontalMk (d j) (v j) ∈ + fourFirstProjection (I.refilteredHorizontalImage i U (d j))) + (j k : J) (hjk : j ≠ k) (hj : j ∈ lieTreeSupport a) (hk : k ∈ lieTreeSupport a) + (hvj : W.rank.filtration.higherHorizontalMk (d j) (v j) ∈ + fourDependentProjection (I.refilteredHorizontalImage i U (d j))) + (hvk : W.rank.filtration.higherHorizontalMk (d k) (v k) ∈ + fourDependentProjection (I.refilteredHorizontalImage i U (d k))) : + W.vertical.frequency (lieTreeEval (fun j => (v j).val) a) = 0 := by + have h := I.refiltered_sunflower_bracket i U d a hd hr hker + (fun j => W.rank.filtration.higherHorizontalMk (d j) (v j)) hv j k hjk hj hk hvj hvk + rwa [W.rank.filtration.horizontalTreeValue_mk d a hd hr v] at h + +def SunflowerKernel : Prop := + ∀ (n : ℕ) (d : Fin n → ℕ) (a : FreeMagma (Fin n)), + lieTreeWeight d a = s → a.length = r → + ∀ v : ∀ j, W.rank.filtration.HigherHorizontal (d j), + (∀ j, v j ∈ fourFirstProjection (I.refilteredHorizontalImage i U (d j))) → + ∀ j k, j ≠ k → j ∈ lieTreeSupport a → k ∈ lieTreeSupport a → + v j ∈ fourDependentProjection (I.refilteredHorizontalImage i U (d j)) → + v k ∈ fourDependentProjection (I.refilteredHorizontalImage i U (d k)) → + W.vertical.frequency (W.rank.filtration.horizontalTreeValue d a v) = 0 + +def BracketKernel : Prop := + ∀ (n : ℕ) (d : Fin n → ℕ) (a : FreeMagma (Fin n)), + lieTreeWeight d a = s → a.length = r → + ∀ z : Fin n → ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k), + (∀ j, z j ∈ (pi (I.productModels i)).filtration.realGradedRefiltrationLayer U (d j)) → + realifyFunctional (piFrequency (I.productFrequencies i)) (lieTreeEval z a) = 0 + +theorem sunflowerKernel_of_real (hker : I.BracketKernel i U) : + I.SunflowerKernel i U := by + intro n d a hd hr v hv j k hjk hj hk hvj hvk + exact I.refiltered_sunflower_bracket i U d a hd hr (hker n d a hd hr) v hv j k hjk hj hk hvj hvk + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3.NativeRankInterval + +open RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + (U : LieSubalgebra ℚ (pi (I.productModels i)).filtration.AssociatedGraded) + +noncomputable def refilteredProjectionImage (d : ℕ) : Submodule ℚ (Fin 4 → W.L) := + ((pi (I.productModels i)).filtration.gradedRefiltrationLayer U d).map (I.rankProjection i).toLinearMap + +theorem refilteredHorizontalImage_eq (d : ℕ) : + I.refilteredHorizontalImage i U d = + W.rank.filtration.horizontalImageOfSubmodule (I.refilteredProjectionImage i U d) d := + W.rank.filtration.layerHorizontalImage_eq_of_submodule + ((pi (I.productModels i)).filtration.gradedRefiltrationLayer U) + (I.rankProjection i) (I.rankProjection_mem_refiltered i U) d + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_rank_interval_sunflower (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool}, + 0 ≤ p → b ≤ p → (I : NativeRankInterval W out H t branch p p) → + Real.exp ((p + C) ^ C) ≤ (I.length : ℝ) → + ∃ i : Fin I.expansion.count, + ∃ R₀ : ((I.expansion.model i).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r, + R₀.ComplexityLE ((p + C) ^ C) ∧ R₀.realSubgroup s r = ⊥ ∧ + ∃ F : (piRank (I.productModels i) (I.productRanks i R₀)).AdaptedData, + F.rank.ComplexityLE ((p + C) ^ C) ∧ + (∀ j k, rationalLogHeight ((pi (I.productModels i)).basis.repr (F.basis j) k) ≤ + (p + C) ^ C) ∧ + (∀ k j, rationalLogHeight (F.basis.repr ((pi (I.productModels i)).basis k) j) ≤ + (p + C) ^ C) ∧ + ∃ (l : ℕ) (U : LieSubalgebra ℚ (pi (I.productModels i)).filtration.AssociatedGraded) + (v : Fin (finrank ℚ (∀ k : Option (Fin 4), + optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) → + (pi (I.productModels i)).filtration.AssociatedGraded), + 0 < l ∧ (l : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + Submodule.span ℚ (Set.range v) = U.toSubmodule ∧ + BasisGradedSubmodule + ((pi (I.productModels i)).filtration.associatedGradedBasis F.basis F.weight F.layers) + F.weight U.toSubmodule ∧ + (∀ j k, rationalLogHeight + (((pi (I.productModels i)).filtration.associatedGradedBasis F.basis F.weight F.layers).repr + (v j) k) ≤ (p + C) ^ C) ∧ + I.BracketKernel i U ∧ I.SunflowerKernel i U ∧ + (pi (I.productModels i)).filtration.SymbolFactorizationIn F.basis F.weight F.layers + (fun _ : Unit => (I.length : ℝ)) (I.productSymbol i F.basis F.weight F.layers) + ((p + C) ^ C) l U := by + obtain ⟨C, hC, hfactor⟩ := exists_rank_interval_factorization s hs + refine ⟨C, hC, ?_⟩ + intro r N _ b p W out H t branch hp hbp I hlarge + obtain ⟨i, R₀, hR₀, hzero, F, hF, hforward, hback, hfact⟩ := hfactor hp hbp I hlarge + obtain ⟨l, U, v, hl, hlp, hv, hU, hheight, hker, hinside⟩ := + DegreeRankStructure.ControlledRankBracketFactorization.exists_in F.rank F.weight F.layers hfact + exact ⟨i, R₀, hR₀, hzero, F, hF, hforward, hback, l, U, v, hl, hlp, hv, hU, hheight, + hker, I.sunflowerKernel_of_real i U hker, hinside⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankInterval + +open RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + +theorem real_rankProjection_frequency + (x : ℝ ⊗[ℚ] (∀ k : Option (Fin 4), + optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) : + realifyFunctional (piFrequency (I.productFrequencies i)) x = + realifyFunctional W.vertical.frequency (realificationLieHom ((liePiEval 0).comp (I.rankProjection i)) x) + + realifyFunctional W.vertical.frequency (realificationLieHom ((liePiEval 1).comp (I.rankProjection i)) x) - + realifyFunctional W.vertical.frequency (realificationLieHom ((liePiEval 2).comp (I.rankProjection i)) x) - + realifyFunctional W.vertical.frequency (realificationLieHom ((liePiEval 3).comp (I.rankProjection i)) x) := by + induction x using TensorProduct.inductionOn with + | tmul a x => + simp only [realificationLieHom_tmul, realifyFunctional_tmul, LieHom.comp_apply, + liePiEval_apply, I.rankProjection_frequency, Rat.cast_add, Rat.cast_sub, mul_add, mul_sub] + | add x y hx hy => + simp only [map_add, hx, hy] + ring + +theorem real_refilteredHorizontalImage_frequency + (U : LieSubalgebra ℚ (pi (I.productModels i)).filtration.AssociatedGraded) + {J : Type*} (d : J → ℕ) (a : FreeMagma J) + (hd : lieTreeWeight d a = s) (hr : a.length = r) + (hker : ∀ z : J → ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k), + (∀ j, z j ∈ (pi (I.productModels i)).filtration.realGradedRefiltrationLayer U (d j)) → + realifyFunctional (piFrequency (I.productFrequencies i)) (lieTreeEval z a) = 0) + (v : ∀ j, ℝ ⊗[ℚ] (Fin 4 → W.rank.filtration.HigherHorizontal (d j))) + (hv : ∀ j, v j ∈ (I.refilteredHorizontalImage i U (d j)).baseChange ℝ) : + realifyFunctional W.vertical.frequency (W.rank.filtration.realHorizontalTreeValue d a + (fun j => (LinearMap.proj (0 : Fin 4)).baseChange ℝ (v j))) + + realifyFunctional W.vertical.frequency (W.rank.filtration.realHorizontalTreeValue d a + (fun j => (LinearMap.proj (1 : Fin 4)).baseChange ℝ (v j))) - + realifyFunctional W.vertical.frequency (W.rank.filtration.realHorizontalTreeValue d a + (fun j => (LinearMap.proj (2 : Fin 4)).baseChange ℝ (v j))) - + realifyFunctional W.vertical.frequency (W.rank.filtration.realHorizontalTreeValue d a + (fun j => (LinearMap.proj (3 : Fin 4)).baseChange ℝ (v j))) = 0 := by + apply W.rank.filtration.real_layerHorizontalImage_frequency + ((pi (I.productModels i)).filtration.gradedRefiltrationLayer U) + (I.rankProjection i) (I.rankProjection_mem_refiltered i U) + W.vertical.frequency d a hd hr ?_ v hv + intro z hz + rw [← I.real_rankProjection_frequency i] + exact hker z hz + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +namespace NativeDegreeRankFamily + +noncomputable def fourRankBasis {s r : ℕ} {A : Type*} {p : ℝ} (W : NativeDegreeRankFamily s r A p) : + Basis (Σ _ : Fin 4, Fin W.dim) ℚ (Fin 4 → W.L) := + Pi.basis (fun _ : Fin 4 => W.model.basis) + +end NativeDegreeRankFamily + +namespace NativeRankInterval + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + +theorem rankProjection_coordinates + (x : ∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) + (j : Σ _ : Fin 4, Fin W.dim) : + W.fourRankBasis.repr (I.rankProjection i x) j = + (pi (I.productModels i)).basis.repr x + ((Fintype.equivFin (Σ k : Option (Fin 4), + Fin (optionDimension (I.expansion.dim i) (fun _ : Fin 4 => W.dim) k))) + ⟨some ((![1, 2, 0, 3] : Fin 4 → Fin 4) j.1), j.2⟩) := by + change (Pi.basis (fun _ : Fin 4 => W.model.basis)).repr (I.rankProjection i x) j = _ + rw [Pi.basis_repr] + let k : Σ a : Option (Fin 4), Fin (optionDimension (I.expansion.dim i) (fun _ : Fin 4 => W.dim) a) := + ⟨some ((![1, 2, 0, 3] : Fin 4 → Fin 4) j.1), j.2⟩ + have hk := (Fintype.equivFin _).symm_apply_apply k + have h := productFinBasis_repr (I.productModels i) x ((Fintype.equivFin _) k) + have heq := congrArg (fun z : Σ a : Option (Fin 4), + Fin (optionDimension (I.expansion.dim i) (fun _ : Fin 4 => W.dim) a) => + (I.productModels i z.1).basis.repr (x z.1) z.2) hk + exact (h.trans heq).symm + +theorem rankProjection_coordinates_logHeight + (x : ∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) + {P : ℝ} (hx : ∀ j, rationalLogHeight ((pi (I.productModels i)).basis.repr x j) ≤ P) + (j : Σ _ : Fin 4, Fin W.dim) : + rationalLogHeight (W.fourRankBasis.repr (I.rankProjection i x) j) ≤ P := by + rw [I.rankProjection_coordinates i x j] + exact hx _ + +end NativeRankInterval + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankInterval + +open Module RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + +theorem refilteredProjectionImage_mem_candidates + (R₀ : ((I.expansion.model i).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r) + (F : (piRank (I.productModels i) (I.productRanks i R₀)).AdaptedData) + (U : LieSubalgebra ℚ (pi (I.productModels i)).filtration.AssociatedGraded) + (v : Fin (finrank ℚ (∀ k : Option (Fin 4), + optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) → + (pi (I.productModels i)).filtration.AssociatedGraded) + (hspan : Submodule.span ℚ (Set.range v) = U.toSubmodule) + {P : ℝ} (hP : 0 ≤ P) (hF : F.rank.ComplexityLE P) + (hforward : ∀ j k, rationalLogHeight ((pi (I.productModels i)).basis.repr (F.basis j) k) ≤ P) + (hv : ∀ j k, rationalLogHeight + (((pi (I.productModels i)).filtration.associatedGradedBasis F.basis F.weight F.layers).repr + (v j) k) ≤ P) (d : ℕ) : + I.refilteredProjectionImage i U d ∈ + heightBoundedSubspaces W.fourRankBasis (Fintype.card (Σ _ : Fin 4, Fin W.dim)) + ⌈Real.exp (refiltrationCoordinateBudget P)⌉₊ := by + have hdim : (Fintype.card (Fin (finrank ℚ (∀ k : Option (Fin 4), + optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k))) : ℝ) ≤ P := by + simpa only [Fintype.card_fin] using hF.1.1 + obtain ⟨a, ha⟩ := (pi (I.productModels i)).filtration.exists_refiltration_bases_in_coordinates + F.basis F.weight F.layers (pi (I.productModels i)).basis U v hspan hP hdim hdim hv hforward d + let z := fun j => I.rankProjection i (a j).val + have hz : Submodule.span ℚ (Set.range z) = I.refilteredProjectionImage i U d := by + have hsource := span_submodule_basis ((pi (I.productModels i)).filtration.gradedRefiltrationLayer U d) a + calc + _ = (Submodule.span ℚ (Set.range (fun j => (a j).val))).map (I.rankProjection i).toLinearMap := by + rw [Submodule.map_span, ← Set.range_comp] + rfl + _ = _ := congrArg (fun K => K.map (I.rankProjection i).toLinearMap) hsource + apply bounded_submodule_spanning_mem_candidates W.fourRankBasis _ z hz + (one_le_ceil_exp (refiltrationCoordinateBudget P)) + intro j k + apply rationalHeightLE_ceil_exp + exact I.rankProjection_coordinates_logHeight i (a j).val (ha j) k + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3.NativeRankInterval + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + +theorem real_rankProjection_coordinates + (x : ℝ ⊗[ℚ] (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) + (j : Σ _ : Fin 4, Fin W.dim) : + (W.fourRankBasis.baseChange ℝ).repr ((I.rankProjection i).toLinearMap.baseChange ℝ x) j = + ((pi (I.productModels i)).basis.baseChange ℝ).repr x + ((Fintype.equivFin (Σ k : Option (Fin 4), + Fin (optionDimension (I.expansion.dim i) (fun _ : Fin 4 => W.dim) k))) + ⟨some ((![1, 2, 0, 3] : Fin 4 → Fin 4) j.1), j.2⟩) := by + induction x using TensorProduct.inductionOn with + | tmul a x => + simp only [LinearMap.baseChange_tmul, Basis.baseChange_repr_tmul] + exact congrArg (fun q : ℚ => q • a) (I.rankProjection_coordinates i x j) + | add x y hx hy => simp only [map_add, Finsupp.add_apply, hx, hy] + +theorem real_rankProjection_abs_bound + (x : ℝ ⊗[ℚ] (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) + {B : ℝ} (hx : ∀ j, |((pi (I.productModels i)).basis.baseChange ℝ).repr x j| ≤ B) + (j : Σ _ : Fin 4, Fin W.dim) : + |(W.fourRankBasis.baseChange ℝ).repr ((I.rankProjection i).toLinearMap.baseChange ℝ x) j| ≤ B := by + rw [I.real_rankProjection_coordinates i] + exact hx _ + +theorem real_rankProjection_grid (l : ℕ) + (x : ℝ ⊗[ℚ] (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) + (hx : (fun j => ((pi (I.productModels i)).basis.baseChange ℝ).repr x j) ∈ realDenominatorGrid l) : + (fun j => (W.fourRankBasis.baseChange ℝ).repr + ((I.rankProjection i).toLinearMap.baseChange ℝ x) j) ∈ realDenominatorGrid l := by + obtain ⟨a, ha⟩ := hx + refine ⟨fun j => a ((Fintype.equivFin (Σ k : Option (Fin 4), + Fin (optionDimension (I.expansion.dim i) (fun _ : Fin 4 => W.dim) k))) + ⟨some ((![1, 2, 0, 3] : Fin 4 → Fin 4) j.1), j.2⟩), ?_⟩ + funext j + exact (congrFun ha _).trans + (congrArg (fun y : ℝ => (l : ℝ) * y) (I.real_rankProjection_coordinates i x j)).symm + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +namespace NativeRankInterval + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + +structure SunflowerWitness (I : NativeRankInterval W out H t branch p q) (P : ℝ) where + index : Fin I.expansion.count + lowerRank : ((I.expansion.model index).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r + lower_complexity : lowerRank.ComplexityLE P + lower_top : lowerRank.realSubgroup s r = ⊥ + adapted : (piRank (I.productModels index) (I.productRanks index lowerRank)).AdaptedData + adapted_complexity : adapted.rank.ComplexityLE P + forward : ∀ j k, rationalLogHeight ((pi (I.productModels index)).basis.repr (adapted.basis j) k) ≤ P + backward : ∀ k j, rationalLogHeight (adapted.basis.repr ((pi (I.productModels index)).basis k) j) ≤ P + denominator : ℕ + subalgebra : LieSubalgebra ℚ (pi (I.productModels index)).filtration.AssociatedGraded + spanning : Fin (finrank ℚ (∀ k : Option (Fin 4), + optionLieSpace (I.expansion.L index) (fun _ : Fin 4 => W.L) k)) → + (pi (I.productModels index)).filtration.AssociatedGraded + denominator_pos : 0 < denominator + denominator_bound : (denominator : ℝ) ≤ Real.exp P + span : Submodule.span ℚ (Set.range spanning) = subalgebra.toSubmodule + graded : BasisGradedSubmodule + ((pi (I.productModels index)).filtration.associatedGradedBasis adapted.basis adapted.weight adapted.layers) + adapted.weight subalgebra.toSubmodule + height : ∀ j k, rationalLogHeight + (((pi (I.productModels index)).filtration.associatedGradedBasis adapted.basis adapted.weight adapted.layers).repr + (spanning j) k) ≤ P + bracket : I.BracketKernel index subalgebra + sunflower : I.SunflowerKernel index subalgebra + factorization : (pi (I.productModels index)).filtration.SymbolFactorizationIn + adapted.basis adapted.weight adapted.layers (fun _ : Unit => (I.length : ℝ)) + (I.productSymbol index adapted.basis adapted.weight adapted.layers) P denominator subalgebra + +namespace SunflowerWitness + +variable {I : NativeRankInterval W out H t branch p q} {P : ℝ} (D : I.SunflowerWitness P) + +noncomputable def projection (d : ℕ) : Submodule ℚ (Fin 4 → W.L) := + I.refilteredProjectionImage D.index D.subalgebra d + +theorem projection_mem_candidates (hP : 0 ≤ P) (d : ℕ) : + D.projection d ∈ heightBoundedSubspaces W.fourRankBasis (Fintype.card (Σ _ : Fin 4, Fin W.dim)) + ⌈Real.exp (refiltrationCoordinateBudget P)⌉₊ := + I.refilteredProjectionImage_mem_candidates D.index D.lowerRank D.adapted D.subalgebra + D.spanning D.span hP D.adapted_complexity D.forward D.height d + +theorem horizontalImage_eq (d : ℕ) : + I.refilteredHorizontalImage D.index D.subalgebra d = + W.rank.filtration.horizontalImageOfSubmodule (D.projection d) d := + I.refilteredHorizontalImage_eq D.index D.subalgebra d + +end SunflowerWitness + +end NativeRankInterval + +theorem exists_rank_sunflower_witness (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool}, + 0 ≤ p → b ≤ p → (I : NativeRankInterval W out H t branch p p) → + Real.exp ((p + C) ^ C) ≤ (I.length : ℝ) → + Nonempty (I.SunflowerWitness ((p + C) ^ C)) := by + obtain ⟨C, hC, hexists⟩ := exists_rank_interval_sunflower s hs + refine ⟨C, hC, ?_⟩ + intro r N _ b p W out H t branch hp hbp I hlarge + obtain ⟨i, R₀, hR₀, hzero, F, hF, hforward, hback, l, U, v, hl, hlp, hv, hU, hheight, + hker, hsunflower, hinside⟩ := hexists hp hbp I hlarge + exact ⟨{ + index := i + lowerRank := R₀ + lower_complexity := hR₀ + lower_top := hzero + adapted := F + adapted_complexity := hF + forward := hforward + backward := hback + denominator := l + subalgebra := U + spanning := v + denominator_pos := hl + denominator_bound := hlp + span := hv + graded := hU + height := hheight + bracket := hker + sunflower := hsunflower + factorization := hinside + }⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_common_rank_projection_family + {α : Type*} {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : α → ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : ∀ a, NativeRankInterval W out H (t a) branch p q) + (S : Finset α) (hS : S.Nonempty) (hP : 0 ≤ P) + (D : ∀ a ∈ S, (I a).SunflowerWitness P) : + ∃ (K : Fin (s + 1) → Submodule ℚ (Fin 4 → W.L)) (T : Finset α), + T ⊆ S ∧ T.Nonempty ∧ + Real.exp (-(3 * (Fintype.card (Σ _ : Fin 4, Fin W.dim) : ℝ) * + Fintype.card (Σ _ : Fin 4, Fin W.dim) * (refiltrationCoordinateBudget P + 2)) * (s + 1)) * + S.card ≤ (T.card : ℝ) ∧ + (∀ d, K d ∈ heightBoundedSubspaces W.fourRankBasis (Fintype.card (Σ _ : Fin 4, Fin W.dim)) + ⌈Real.exp (refiltrationCoordinateBudget P)⌉₊) ∧ + ∀ a ∈ T, ∃ E : (I a).SunflowerWitness P, + (∀ d : Fin (s + 1), E.projection d.val = K d) ∧ + ∀ d : Fin (s + 1), (I a).refilteredHorizontalImage E.index E.subalgebra d.val = + W.rank.filtration.horizontalImageOfSubmodule (K d) d.val := by + classical + let code (a : α) : Fin (s + 1) → Submodule ℚ (Fin 4 → W.L) := + if ha : a ∈ S then fun d => (D a ha).projection d.val else 0 + have hcode (a : α) (ha : a ∈ S) : code a = fun d => (D a ha).projection d.val := by + simp only [code, dite_eq_left ha] + have hmem : ∀ a ∈ S, ∀ d, code a d ∈ + heightBoundedSubspaces W.fourRankBasis (Fintype.card (Σ _ : Fin 4, Fin W.dim)) + ⌈Real.exp (refiltrationCoordinateBudget P)⌉₊ := by + intro a ha d + rw [hcode a ha] + exact (D a ha).projection_mem_candidates hP d.val + obtain ⟨a₀, ha₀, T, hTS, haT, hcommon, hsize⟩ := exists_common_height_bounded_subspace_family + W.fourRankBasis S hS code (Fintype.card (Σ _ : Fin 4, Fin W.dim)) + (refiltrationCoordinateBudget_nonneg hP) hmem + refine ⟨code a₀, T, hTS, ⟨a₀, haT⟩, ?_, hmem a₀ ha₀, ?_⟩ + · simpa only [Fintype.card_fin, Nat.cast_add, Nat.cast_one] using hsize + · intro a ha + let E := D a (hTS ha) + have heq (d : Fin (s + 1)) : E.projection d.val = code a₀ d := by + have h := congrFun (hcommon a ha) d + rwa [hcode a (hTS ha)] at h + exact ⟨E, heq, fun d => (E.horizontalImage_eq d.val).trans (congrArg + (fun B => W.rank.filtration.horizontalImageOfSubmodule B d.val) (heq d))⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankInterval + +open RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) + +noncomputable def projectedCoefficient (i : Fin I.expansion.count) (α : Unit →₀ ℕ) : + (pi (I.productModels i)).filtration.PolynomialSymbol (fun _ : Unit => 1) →ₗ[ℚ] + (Fin 4 → W.rank.filtration.HigherHorizontal (Finsupp.weight (fun _ : Unit => 1) α)) := + W.rank.filtration.projectedHorizontalSymbolCoefficient (pi (I.productModels i)).filtration + (I.rankProjection i) (I.rankProjection_mem_layer i) (fun _ => 1) α + +namespace SunflowerWitness + +variable {I} {P : ℝ} (D : I.SunflowerWitness P) + +theorem exists_projected_corrections (hs : 1 ≤ s) : + ∃ E R : (pi (I.productModels D.index)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1), + (pi (I.productModels D.index)).filtration.SymbolSlowBound + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) + (fun _ => (I.length : ℝ)) (Real.exp P) E ∧ + (pi (I.productModels D.index)).filtration.SymbolRationalGrid + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) D.denominator R ∧ + ∀ α : Unit →₀ ℕ, + (I.projectedCoefficient D.index α).baseChange ℝ + (I.productSymbol D.index D.adapted.basis D.adapted.weight D.adapted.layers).coord - + (I.projectedCoefficient D.index α).baseChange ℝ E.coord - + (I.projectedCoefficient D.index α).baseChange ℝ R.coord ∈ + (I.refilteredHorizontalImage D.index D.subalgebra (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ := by + exact W.rank.filtration.projectedHorizontal_factorization (pi (I.productModels D.index)).filtration + (I.rankProjection D.index) (I.rankProjection_mem_layer D.index) hs + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => (I.length : ℝ)) + (I.productSymbol D.index D.adapted.basis D.adapted.weight D.adapted.layers) + P D.denominator D.subalgebra D.factorization + +end SunflowerWitness + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3.NativeRankInterval.SunflowerWitness + +open RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + {I : NativeRankInterval W out H t branch p q} + +noncomputable def mono (D : I.SunflowerWitness P) (hPQ : P ≤ Q) : I.SunflowerWitness Q := + { D with + lower_complexity := D.lower_complexity.mono D.lowerRank hPQ + adapted_complexity := D.adapted_complexity.mono D.adapted.rank hPQ + forward := fun j k => (D.forward j k).trans hPQ + backward := fun k j => (D.backward k j).trans hPQ + denominator_bound := D.denominator_bound.trans (Real.exp_le_exp.mpr hPQ) + height := fun j k => (D.height j k).trans hPQ + factorization := NilpotentLieFiltration.SymbolFactorizationIn.mono + (pi (I.productModels D.index)).filtration D.adapted.basis D.adapted.weight D.adapted.layers + D.factorization hPQ (fun _ => by exact_mod_cast I.length_pos) } + +theorem mono_projection (D : I.SunflowerWitness P) (hPQ : P ≤ Q) (d : ℕ) : + (D.mono hPQ).projection d = D.projection d := rfl + +end Erdos3.NativeRankInterval.SunflowerWitness + +end + +section + +namespace Erdos3.NativeRankInterval.SunflowerWitness + +open Module RationalFilteredNilmanifold VectorPolynomial +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + {I : NativeRankInterval W out H t branch p q} (D : I.SunflowerWitness P) + +noncomputable def projectedRepresentative + (X : (pi (I.productModels D.index)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1)) + (α : Unit →₀ ℕ) : ℝ ⊗[ℚ] (Fin 4 → W.L) := + (I.rankProjection D.index).toLinearMap.baseChange ℝ + (coefficients ((pi (I.productModels D.index)).filtration.realSymbolRepresentative + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) X.coord) α) + +noncomputable def projectedDenominator : ℕ := + matrixDenominator (fun i j => (pi (I.productModels D.index)).basis.repr (D.adapted.basis j) i) * + D.denominator + +theorem projectedDenominator_pos : 0 < D.projectedDenominator := + Nat.mul_pos (matrixDenominator_pos _) D.denominator_pos + +theorem projectedDenominator_bound (hP : 0 ≤ P) : + (D.projectedDenominator : ℝ) ≤ Real.exp ((P + 2) ^ 3 + P) := by + have hdim := D.adapted_complexity.1.1 + apply NilpotentLieFiltration.original_coordinate_denominator_bound D.adapted.basis + (pi (I.productModels D.index)).basis hP + · simpa only [Fintype.card_fin] using hdim + · simpa only [← finrank_eq_card_basis (pi (I.productModels D.index)).basis] using hdim + · exact D.forward + · exact D.denominator_bound + +theorem projectedRepresentative_slow (hP : 0 ≤ P) + (E : (pi (I.productModels D.index)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1)) + (hE : (pi (I.productModels D.index)).filtration.SymbolSlowBound + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) + (fun _ => (I.length : ℝ)) (Real.exp P) E) (α : Unit →₀ ℕ) (j : Σ _ : Fin 4, Fin W.dim) : + |(W.fourRankBasis.baseChange ℝ).repr (D.projectedRepresentative E α) j| ≤ + Real.exp ((P + 3) ^ 2) / monomialScale (fun _ : Unit => (I.length : ℝ)) α := by + apply I.real_rankProjection_abs_bound D.index + intro k + apply (pi (I.productModels D.index)).filtration.realSymbolRepresentative_slow_original_coordinates + D.adapted.basis D.adapted.weight D.adapted.layers (pi (I.productModels D.index)).basis + (fun _ : Unit => 1) (fun _ => (I.length : ℝ)) (fun _ => by exact_mod_cast I.length_pos) hP + · simpa only [Fintype.card_fin] using D.adapted_complexity.1.1 + · exact D.forward + · exact hE + +theorem projectedRepresentative_grid + (R : (pi (I.productModels D.index)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1)) + (hR : (pi (I.productModels D.index)).filtration.SymbolRationalGrid + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) D.denominator R) + (α : Unit →₀ ℕ) : + (fun j => (W.fourRankBasis.baseChange ℝ).repr (D.projectedRepresentative R α) j) ∈ + realDenominatorGrid D.projectedDenominator := by + unfold projectedDenominator projectedRepresentative + have hgrid := (pi (I.productModels D.index)).filtration.realSymbolRepresentative_original_grid + D.adapted.basis D.adapted.weight D.adapted.layers (pi (I.productModels D.index)).basis + (fun _ : Unit => 1) D.denominator R hR α + have hp := I.real_rankProjection_grid D.index + (matrixDenominator (fun i j => (pi (I.productModels D.index)).basis.repr (D.adapted.basis j) i) * + D.denominator) + (coefficients ((pi (I.productModels D.index)).filtration.realSymbolRepresentative + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) R.coord) α) hgrid + convert hp using 2 + +end Erdos3.NativeRankInterval.SunflowerWitness + +end + +section + +namespace Erdos3.NativeRankInterval.SunflowerWitness + +open Module RationalFilteredNilmanifold VectorPolynomial +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + {I : NativeRankInterval W out H t branch p q} (D : I.SunflowerWitness P) + +theorem projectedRepresentative_mem + (X : (pi (I.productModels D.index)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1)) + (α : Unit →₀ ℕ) : D.projectedRepresentative X α ∈ + (W.rank.filtration.fourHorizontalLayer (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ := by + have h := W.rank.filtration.real_projectedCoefficient_mem (pi (I.productModels D.index)).filtration + (I.rankProjection D.index) (I.rankProjection_mem_layer D.index) + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) α + ((pi (I.productModels D.index)).filtration.realAdaptedSymbolRepresentative + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) X.coord) + convert h using 2 + dsimp only [projectedRepresentative, NilpotentLieFiltration.realAdaptedSymbolRepresentative] + +noncomputable def projectedRepresentativeLayer + (X : (pi (I.productModels D.index)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1)) + (α : Unit →₀ ℕ) : + (W.rank.filtration.fourHorizontalLayer (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ := + ⟨D.projectedRepresentative X α, D.projectedRepresentative_mem X α⟩ + +theorem projectedRepresentative_horizontal + (X : (pi (I.productModels D.index)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1)) + (α : Unit →₀ ℕ) : + W.rank.filtration.realFourHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) + (D.projectedRepresentativeLayer X α) = + (I.projectedCoefficient D.index α).baseChange ℝ X.coord := by + have h := W.rank.filtration.real_projectedCoefficient_horizontal + (pi (I.productModels D.index)).filtration (I.rankProjection D.index) + (I.rankProjection_mem_layer D.index) D.adapted.basis D.adapted.weight D.adapted.layers + (fun _ => 1) α ((pi (I.productModels D.index)).filtration.realAdaptedSymbolRepresentative + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) X.coord) + (D.projectedRepresentativeLayer X α) (by + dsimp only [projectedRepresentativeLayer, projectedRepresentative, + NilpotentLieFiltration.realAdaptedSymbolRepresentative]) + rwa [NilpotentLieFiltration.realPolynomialSymbolMap_representative] at h + +noncomputable def projectedOrbitCoefficient (α : Unit →₀ ℕ) : + (W.rank.filtration.fourHorizontalLayer (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ := + ⟨(I.rankProjection D.index).toLinearMap.baseChange ℝ (coefficients (I.productOrbit D.index).log α), + W.rank.filtration.real_projectedCoefficient_mem (pi (I.productModels D.index)).filtration + (I.rankProjection D.index) (I.rankProjection_mem_layer D.index) + D.adapted.basis D.adapted.weight D.adapted.layers (fun _ => 1) α + ⟨(I.productOrbit D.index).log, (I.productOrbit D.index).property⟩⟩ + +@[simp] theorem projectedOrbitCoefficient_coe (α : Unit →₀ ℕ) : + (D.projectedOrbitCoefficient α : ℝ ⊗[ℚ] (Fin 4 → W.L)) = + (I.rankProjection D.index).toLinearMap.baseChange ℝ + (coefficients (I.productOrbit D.index).log α) := rfl + +theorem projectedOrbitCoefficient_horizontal (α : Unit →₀ ℕ) : + W.rank.filtration.realFourHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) + (D.projectedOrbitCoefficient α) = + (I.projectedCoefficient D.index α).baseChange ℝ + (I.productSymbol D.index D.adapted.basis D.adapted.weight D.adapted.layers).coord := by + exact W.rank.filtration.real_projectedCoefficient_horizontal + (pi (I.productModels D.index)).filtration (I.rankProjection D.index) + (I.rankProjection_mem_layer D.index) D.adapted.basis D.adapted.weight D.adapted.layers + (fun _ => 1) α ⟨(I.productOrbit D.index).log, (I.productOrbit D.index).property⟩ + (D.projectedOrbitCoefficient α) rfl + +end Erdos3.NativeRankInterval.SunflowerWitness + +end + +section + +namespace Erdos3.NativeRankInterval.SunflowerWitness + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {κ : Type*} {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + {I : NativeRankInterval W out H t branch p q} (D : I.SunflowerWitness P) + (hs : 1 ≤ s) (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + +theorem projectedSymbol_native_component (α : Unit →₀ ℕ) (k : Fin 4) : + (LinearMap.proj k).baseChange ℝ + ((I.projectedCoefficient D.index α).baseChange ℝ + (I.productSymbol D.index D.adapted.basis D.adapted.weight D.adapted.layers).coord) = + W.horizontalCoefficient hs c τ hG α + (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)) := by + have h := W.rank.filtration.projectedHorizontalSymbolCoefficient_native + (pi (I.productModels D.index)).filtration (I.rankProjection D.index) + (I.rankProjection_mem_layer D.index) hs D.adapted.basis D.adapted.weight D.adapted.layers + c τ hG (fun _ : Unit => 1) α + ⟨(I.productOrbit D.index).log, (I.productOrbit D.index).property⟩ + (W.rank.orbitEquiv (fun _ => 1) + (W.fourPointFactors out (rankQuadrupleParameters t) (cyclicBranchOffset t.1 branch) + ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)).orbit) k (by + exact (I.rankProjection_component_log D.index k).trans + (W.rank.orbitEquiv_log (fun _ : Unit => 1) + (W.fourPointFactors out (rankQuadrupleParameters t) (cyclicBranchOffset t.1 branch) + ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)).orbit).symm) + exact h.trans (W.fourPoint_horizontalCoefficient hs c τ hG out + (rankQuadrupleParameters t) (cyclicBranchOffset t.1 branch) α + ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)) + +theorem projectedOrbitCoefficient_native_component (α : Unit →₀ ℕ) (k : Fin 4) : + (LinearMap.proj k).baseChange ℝ + (W.rank.filtration.realFourHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) + (D.projectedOrbitCoefficient α)) = + W.horizontalCoefficient hs c τ hG α + (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)) := by + exact (congrArg ((LinearMap.proj k).baseChange ℝ) (D.projectedOrbitCoefficient_horizontal α)).trans + (D.projectedSymbol_native_component hs c τ hG α k) + +end Erdos3.NativeRankInterval.SunflowerWitness + +end + +section + +namespace Erdos3 + +open Module VectorPolynomial +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +namespace NativeDegreeRankFamily + +variable {A κ : Type*} {s r : ℕ} {b : ℝ} (W : NativeDegreeRankFamily s r A b) + +theorem logCoefficient_mem_rank_one (α : Unit →₀ ℕ) (a : A) : + coefficients (W.orbit a).log α ∈ + (W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 1).baseChange ℝ := by + have h := W.rank.filtration.polynomialOrbit_coefficient_mem_rank_one (fun _ : Unit => 1) α + (W.rank.orbitEquiv (fun _ : Unit => 1) (W.orbit a)) + exact (congrArg (fun z => coefficients z α ∈ + (W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 1).baseChange ℝ) + (W.rank.orbitEquiv_log (fun _ : Unit => 1) (W.orbit a))).mp h + +theorem horizontalCoefficient_real_log (hs : 1 ≤ s) (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = + Submodule.span ℚ (c '' {i | j ≤ τ i})) (α : Unit →₀ ℕ) (a : A) + (v : (W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 1).baseChange ℝ) + (hv : v.val = coefficients (W.orbit a).log α) : + W.horizontalCoefficient hs c τ hG α a = + W.rank.filtration.realHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) v := by + apply W.rank.filtration.nativeHorizontalCoefficientHom_eq_realHorizontalMap hs c τ hG + (fun _ : Unit => 1) α (W.rank.orbitEquiv (fun _ : Unit => 1) (W.orbit a)) v + exact hv.trans (congrArg (fun z => coefficients z α) + (W.rank.orbitEquiv_log (fun _ : Unit => 1) (W.orbit a))).symm + +end NativeDegreeRankFamily + +namespace NativeRankInterval.SunflowerWitness + +variable {κ : Type*} {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + {I : NativeRankInterval W out H t branch p q} (D : I.SunflowerWitness P) + +theorem projectedOrbitCoefficient_native_log_mod_kernel + (hs : 1 ≤ s) (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = + Submodule.span ℚ (c '' {i | j ≤ τ i})) (α : Unit →₀ ℕ) (k : Fin 4) : + (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L)) (D.projectedOrbitCoefficient α).val k - + coefficients (W.orbit (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))).log α ∈ + (W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 2).baseChange ℝ := by + let a := rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k) + let v := W.rank.filtration.realFourLayerComponent (Finsupp.weight (fun _ : Unit => 1) α) k + (D.projectedOrbitCoefficient α) + let z : (W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 1).baseChange ℝ := + ⟨coefficients (W.orbit a).log α, W.logCoefficient_mem_rank_one α a⟩ + have heq : W.rank.filtration.realHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) v = + W.rank.filtration.realHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) z := + (W.rank.filtration.realFourLayerComponent_horizontal _ k (D.projectedOrbitCoefficient α)).symm.trans + ((D.projectedOrbitCoefficient_native_component hs c τ hG α k).trans + (W.horizontalCoefficient_real_log hs c τ hG α a z rfl)) + have h := (W.rank.filtration.realHorizontalMap_eq _ v z).mp heq + simpa only [v, z, a, W.rank.filtration.realFourLayerComponent_coe, real_four_projection] using h + +end NativeRankInterval.SunflowerWitness +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeComparisonProjections.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeComparisonProjections.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bd906e72f324e7fef6eecd727c7570183571508 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeComparisonProjections.lean @@ -0,0 +1,119 @@ +import OAI.Combinatorics.Progressions.Lattices.ComparisonLattice + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct + +variable {σ : Type} {L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s d r : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) (p : ℝ) (B : ℕ) (hB : 0 < B) + (hstable : M.SquarefreeGridStable p B) + (E : RationalFilteredNilmanifold + (M.filtration.comparisonSubalgebra (fun i : ReplicatedIndex bound => i.1)) + (max s (Fintype.card (ReplicatedIndex bound))) r) + (hEL : E.lattice = M.comparisonLattice p B hB hstable) + +noncomputable def comparisonFirstSpace : E.Space → D.Space := + cosetMap E.realLattice D.realLattice + (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) + (M.filtration.comparisonFirst (fun i : ReplicatedIndex bound => i.1))) + (realificationMap_subgroup _ _ _ (by rw [hEL]; exact M.comparisonLattice_first p B hB hstable)) + +noncomputable def comparisonSecondSpace : E.Space → (M.squarefreeModel p B hB hstable).Space := + cosetMap E.realLattice (M.squarefreeModel p B hB hstable).realLattice + (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := (M.squarefreeModel p B hB hstable).filtration.lowerCentralSeries_eq_bot) + (M.filtration.comparisonSecond (fun i : ReplicatedIndex bound => i.1))) + (realificationMap_subgroup _ _ _ (by rw [hEL]; exact M.comparisonLattice_second p B hB hstable)) + +theorem comparisonFirstSpace_mk (g : E.RealGroup) : + M.comparisonFirstSpace p B hB hstable E hEL (QuotientGroup.mk g) = + QuotientGroup.mk (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) + (M.filtration.comparisonFirst (fun i : ReplicatedIndex bound => i.1)) g) := rfl + +theorem comparisonSecondSpace_mk (g : E.RealGroup) : + M.comparisonSecondSpace p B hB hstable E hEL (QuotientGroup.mk g) = + QuotientGroup.mk (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := (M.squarefreeModel p B hB hstable).filtration.lowerCentralSeries_eq_bot) + (M.filtration.comparisonSecond (fun i : ReplicatedIndex bound => i.1)) g) := rfl + +theorem comparisonFirstSpace_smul (g : E.RealGroup) (x : E.Space) : + M.comparisonFirstSpace p B hB hstable E hEL (g • x) = + realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) + (M.filtration.comparisonFirst (fun i : ReplicatedIndex bound => i.1)) g • + M.comparisonFirstSpace p B hB hstable E hEL x := cosetMap_smul _ _ _ _ _ _ + +theorem comparisonSecondSpace_smul (g : E.RealGroup) (x : E.Space) : + M.comparisonSecondSpace p B hB hstable E hEL (g • x) = + realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := (M.squarefreeModel p B hB hstable).filtration.lowerCentralSeries_eq_bot) + (M.filtration.comparisonSecond (fun i : ReplicatedIndex bound => i.1)) g • + M.comparisonSecondSpace p B hB hstable E hEL x := cosetMap_smul _ _ _ _ _ _ + +variable + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.comparisonSubalgebra (fun i : ReplicatedIndex bound => i.1))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.comparisonSubalgebra (fun i : ReplicatedIndex bound => i.1))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.comparisonSubalgebra (fun i : ReplicatedIndex bound => i.1))] + [T2Space (ℝ ⊗[ℚ] M.filtration.comparisonSubalgebra (fun i : ReplicatedIndex bound => i.1))] + +theorem comparisonFirstSpace_lipschitz + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {q : ℝ} (hq : 0 ≤ q) (hD : D.GeometryComplexityLE q) (hE : E.GeometryComplexityLE q) + (hheight : ∀ j k, rationalLogHeight (D.basis.repr (E.basis j).val.1 k) ≤ q) : + letI := E.metricSpace + letI := D.metricSpace + LipschitzWith ⟨Real.exp ((q + 3) ^ 2), (Real.exp_pos _).le⟩ + (M.comparisonFirstSpace p B hB hstable E hEL) := by + let := E.metricSpace + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + induction x using Quotient.inductionOn with + | h x => + induction y using Quotient.inductionOn with + | h y => + exact nativeMap_dist_le E D + (M.filtration.comparisonFirst (fun i : ReplicatedIndex bound => i.1)) + (by rw [hEL]; exact M.comparisonLattice_first p B hB hstable) + hq hE hD (fun k j => hheight j k) x y + +theorem comparisonSecondSpace_lipschitz + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.SquarefreeAlgebra (fun i : ReplicatedIndex bound => i.1))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.SquarefreeAlgebra (fun i : ReplicatedIndex bound => i.1))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.SquarefreeAlgebra (fun i : ReplicatedIndex bound => i.1))] + [T2Space (ℝ ⊗[ℚ] M.filtration.SquarefreeAlgebra (fun i : ReplicatedIndex bound => i.1))] + {q : ℝ} (hq : 0 ≤ q) + (hA : (M.squarefreeModel p B hB hstable).GeometryComplexityLE q) + (hE : E.GeometryComplexityLE q) + (hheight : ∀ j k, rationalLogHeight ((M.squarefreeFinBasis p).repr (E.basis j).val.2 k) ≤ q) : + letI := E.metricSpace + letI := (M.squarefreeModel p B hB hstable).metricSpace + LipschitzWith ⟨Real.exp ((q + 3) ^ 2), (Real.exp_pos _).le⟩ + (M.comparisonSecondSpace p B hB hstable E hEL) := by + let := E.metricSpace + let := (M.squarefreeModel p B hB hstable).metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + induction x using Quotient.inductionOn with + | h x => + induction y using Quotient.inductionOn with + | h y => + exact nativeMap_dist_le E (M.squarefreeModel p B hB hstable) + (M.filtration.comparisonSecond (fun i : ReplicatedIndex bound => i.1)) + (by rw [hEL]; exact M.comparisonLattice_second p B hB hstable) + hq hE hA (fun k j => hheight j k) x y + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeDilationPairProjections.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeDilationPairProjections.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f5ef06d18542698e4a48887f8f3550c6b0b036e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeDilationPairProjections.lean @@ -0,0 +1,147 @@ +import OAI.Combinatorics.Progressions.Estimates.ControlledComparisonModel +import OAI.Combinatorics.Progressions.Estimates.RealifiedDilationMultidegree + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +def dilationPairProjection (q : ℚ) (j : Fin 2) : F.dilationPairSubalgebra q →ₗ⁅ℚ⁆ L := + (liePiEval j).comp (F.dilationPairToPi q) + +@[simp] theorem dilationPairProjection_zero (q : ℚ) : + F.dilationPairProjection q 0 = F.dilationPairFirst q := rfl + +@[simp] theorem dilationPairProjection_one (q : ℚ) : + F.dilationPairProjection q 1 = F.dilationPairSecond q := rfl + +noncomputable def realDilationPairProjection (q : ℚ) (j : Fin 2) : + (F.dilationPairFiltration q).realification.Group →* F.realification.Group := + NilpotentLieBCHGroup.realificationMap + (hnil := (F.dilationPairFiltration q).lowerCentralSeries_eq_bot) + (hM := F.lowerCentralSeries_eq_bot) (F.dilationPairProjection q j) + +theorem realifiedDilationPairEquiv_projection (q : ℚ) (j : Fin 2) + (x : ℝ ⊗[ℚ] F.dilationPairSubalgebra q) : + pairToPi (F.realifiedDilationPairEquiv q x).val j = + realificationLieHom (F.dilationPairProjection q j) x := by + rw [F.realifiedDilationPairEquiv_coe] + induction x using TensorProduct.inductionOn with + | tmul scalar vector => + rw [realificationLieHom_tmul, realPairEquiv_tmul, realificationLieHom_tmul] + fin_cases j <;> rfl + | add first second hfirst hsecond => + simp only [map_add, Pi.add_apply, hfirst, hsecond] + +theorem realDilationPairProjection_coord (q : ℚ) (j : Fin 2) + (g : (F.dilationPairFiltration q).realification.Group) : + (F.realDilationPairProjection q j g).coord = + pairToPi (F.realifiedDilationPairEquiv q g.coord).val j := + (F.realifiedDilationPairEquiv_projection q j g.coord).symm + +theorem realDilationPairProjection_jointly_injective (q : ℚ) + {g h : (F.dilationPairFiltration q).realification.Group} + (heq : ∀ j, F.realDilationPairProjection q j g = F.realDilationPairProjection q j h) : + g = h := by + apply NilpotentLieBCHGroup.ext + apply (F.realifiedDilationPairEquiv q).injective + apply Subtype.ext + apply pairToPi_injective + funext j + simpa only [F.realDilationPairProjection_coord] using + congrArg NilpotentLieBCHGroup.coord (heq j) + +theorem realDilationPairProjection_mem (q : ℚ) (j : Fin 2) {n : ℕ} + {g : (F.dilationPairFiltration q).realification.Group} + (hg : g ∈ (F.dilationPairFiltration q).realification.subgroup n) : + F.realDilationPairProjection q j g ∈ F.realification.subgroup n := by + have hm := (F.realifiedDilationPairEquiv_mem_layer q n g.coord).mp hg + change (F.realDilationPairProjection q j g).coord ∈ F.realification.layer n + rw [F.realDilationPairProjection_coord] + fin_cases j + · exact hm.1 + · exact hm.2.1 + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct + +variable {σ L : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s d r : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) + +theorem dilationPairProjection_lattice (q : ℚ) (j : Fin 2) : + M.dilationPairLattice q ≤ D.lattice.comap + (mapOfSteps (M.filtration.ordinary.dilationPairProjection q j)) := by + intro x hx + have h := (M.dilationPairLattice_mem q x).mp hx + fin_cases j + · exact h.1 + · exact h.2 + +noncomputable def dilationSpaceProjection (q : ℚ) + (E : RationalFilteredNilmanifold (M.filtration.ordinary.dilationPairSubalgebra q) s r) + (hE : E.lattice = M.dilationPairLattice q) (j : Fin 2) : E.Space → D.Space := + cosetMap E.realLattice D.realLattice (M.filtration.ordinary.realDilationPairProjection q j) + (realificationMap_subgroup (M.filtration.ordinary.dilationPairProjection q j) _ _ + (by rw [hE]; exact M.dilationPairProjection_lattice q j)) + +theorem dilationSpaceProjection_mk (q : ℚ) + (E : RationalFilteredNilmanifold (M.filtration.ordinary.dilationPairSubalgebra q) s r) + (hE : E.lattice = M.dilationPairLattice q) (j : Fin 2) (g : E.RealGroup) : + M.dilationSpaceProjection q E hE j (QuotientGroup.mk g) = + QuotientGroup.mk (M.filtration.ordinary.realDilationPairProjection q j g) := rfl + +theorem dilationSpaceProjection_smul (q : ℚ) + (E : RationalFilteredNilmanifold (M.filtration.ordinary.dilationPairSubalgebra q) s r) + (hE : E.lattice = M.dilationPairLattice q) (j : Fin 2) (g : E.RealGroup) (x : E.Space) : + M.dilationSpaceProjection q E hE j (g • x) = + M.filtration.ordinary.realDilationPairProjection q j g • + M.dilationSpaceProjection q E hE j x := cosetMap_smul _ _ _ _ _ _ + +theorem dilationSpaceProjection_lipschitz (q : ℚ) + (E : RationalFilteredNilmanifold (M.filtration.ordinary.dilationPairSubalgebra q) s r) + (hEL : E.lattice = M.dilationPairLattice q) (j : Fin 2) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra q)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra q)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra q)] + [T2Space (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra q)] + {p : ℝ} (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) (hE : E.GeometryComplexityLE p) + (hheight : ∀ a k, rationalLogHeight + (D.basis.repr (M.filtration.ordinary.dilationPairProjection q j (E.basis a)) k) ≤ p) : + letI := E.metricSpace + letI := D.metricSpace + LipschitzWith ⟨Real.exp ((p + 3) ^ 2), (Real.exp_pos _).le⟩ + (M.dilationSpaceProjection q E hEL j) := by + let := E.metricSpace + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + induction x using Quotient.inductionOn with + | h x => + induction y using Quotient.inductionOn with + | h y => + exact nativeMap_dist_le E D (M.filtration.ordinary.dilationPairProjection q j) + (by rw [hEL]; exact M.dilationPairProjection_lattice q j) + hp hE hD (fun k a => hheight a k) x y + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeExternalKernelQuotientTransfer.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeExternalKernelQuotientTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..209895fbd1b730c177976d9efac730141fba6b4a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeExternalKernelQuotientTransfer.lean @@ -0,0 +1,133 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateAdaptedOptionQuotientFactors +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateSelectedDescentRegularity + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +theorem exists_external_kernelProjection_native_descent (t : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ X : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d n : ℕ} (D : RationalFilteredNilmanifold L s d) (I : LieIdeal ℚ L) + [TopologicalSpace (ℝ ⊗[ℚ] (L ⧸ I))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ I))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (L ⧸ I))] [T2Space (ℝ ⊗[ℚ] (L ⧸ I))] + (hI : D.filtration.layer (t + 1) ≤ I.toSubmodule) + (Q : RationalFilteredNilmanifold (L ⧸ I) t n) + (hQF : Q.filtration = D.filtration.quotientLie I hI) + (_hQL : Q.lattice = D.lattice.map (D.filtration.quotientStepHom I hI)) + (htop : I.toSubmodule ≤ D.filtration.layer s) + {w : σ → ℕ} (tests : X → D.Niltest w) (p : ℝ), + 0 ≤ p → (∀ x, (tests x).ComplexityLE p) → + (∀ x, (tests x).UnitIntervalValued) → Q.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (Q.basis.repr (lieQuotientMap I (D.basis j)) i) ≤ p) → + ∃ descended : X → Q.Niltest w, + (∀ x, (descended x).orbit = D.quotientOrbit I hI Q hQF (tests x).orbit) ∧ + (∀ x, (descended x).normBound = (tests x).normBound) ∧ + (∀ x, (descended x).UnitIntervalValued) ∧ + (∀ x, (descended x).ComplexityLE ((p + 2) ^ C)) ∧ + (∀ x, ((descended x).lipBound : ℝ) ≤ Real.exp ((p + 2) ^ C)) ∧ + (∀ x (g : D.RealGroup), (descended x).observable (QuotientGroup.mk + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) (lieQuotientMap I) g)) = + ((tests x).kernelProjection I.toSubmodule htop).observable (QuotientGroup.mk g)) ∧ + (∀ x z, (descended x).eval z = ((tests x).kernelProjection I.toSubmodule htop).eval z) ∧ + (∀ x y η, (∀ z, ‖(tests x).observable z - (tests y).observable z‖ ≤ η) → + ∀ q, ‖(descended x).observable q - (descended y).observable q‖ ≤ η) := by + obtain ⟨C, hC, hdescent⟩ := exists_idealInvariant_niltest_budget t + refine ⟨C, hC, ?_⟩ + intro L σ X _ _ _ _ _ _ s d n D I _ _ _ _ hI Q hQF hQL htop w tests p + hp htests hunit hQ he + have hex (x : X) := hdescent D I hI Q hQF hQL + ((tests x).kernelProjection I.toSubmodule htop) p hp + ((tests x).kernelProjection_complexity I.toSubmodule htop (htests x)) hQ he + (fun z hz y => (tests x).kernelProjection_invariant I.toSubmodule htop z hz y) + choose descended horbit hnorm hcomplex hrec heval hpos using hex + have hpositive (x : X) : (descended x).UnitIntervalValued := + hpos x ((tests x).kernelProjection_unitInterval I.toSubmodule htop (hunit x)) + refine ⟨descended, horbit, hnorm, hpositive, hcomplex, ?_, hrec, heval, ?_⟩ + · intro x + have hb := (descended x).observable_budget (hcomplex x) + linarith [(descended x).normBound.coe_nonneg] + · intro x y η hxy + exact Niltest.nativeQuotient_observable_sub_norm_le + (tests x) (tests y) I htop Q (descended x).observable (descended y).observable + (hrec x) (hrec y) hxy + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold +open VectorPolynomial NilpotentLieFiltration +open scoped TensorProduct NNReal + +theorem exists_external_kernel_quotient_transfer (t : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ X : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d n : ℕ} (D : RationalFilteredNilmanifold L s d) (I : LieIdeal ℚ L) + [TopologicalSpace (ℝ ⊗[ℚ] (L ⧸ I))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ I))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (L ⧸ I))] [T2Space (ℝ ⊗[ℚ] (L ⧸ I))] + (hI : D.filtration.layer (t + 1) ≤ I.toSubmodule) + (Q : RationalFilteredNilmanifold (L ⧸ I) t n) + (_hQF : Q.filtration = D.filtration.quotientLie I hI) + (_hQL : Q.lattice = D.lattice.map (D.filtration.quotientStepHom I hI)) + (_htop : I.toSubmodule ≤ D.filtration.layer s) + {w : σ → ℕ} (tests : X → D.Niltest w) (p : ℝ), + 0 ≤ p → (∀ x, (tests x).ComplexityLE p) → + (∀ x, (tests x).UnitIntervalValued) → Q.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (Q.basis.repr (lieQuotientMap I (D.basis j)) i) ≤ p) → + ∃ descended : X → Q.Niltest w, + (∀ x, (descended x).UnitIntervalValued) ∧ + (∀ x, (descended x).ComplexityLE ((p + 2) ^ C)) ∧ + (∀ x y η, (∀ z, ‖(tests x).observable z - (tests y).observable z‖ ≤ η) → + ∀ q, ‖(descended x).observable q - (descended y).observable q‖ ≤ η) ∧ + ∀ {M Ω J : Type*} [LieRing M] [LieAlgebra ℚ M] [Fintype Ω] [Fintype J] + {u : ℕ} (G : NilpotentLieFiltration M u) (φ : L →ₗ⁅ℚ⁆ M) + (hker : ∀ x ∈ I, φ x = 0) + (q : Q.filtration.realification.PolynomialOrbit w) + (marked : G.realification.PolynomialOrbit w), + map ((realificationLieHom (quotientInducedMark I φ hker)).toLinearMap.restrictScalars ℚ) + q.log = marked.log → + ∀ (outer : FiniteProbabilityWeights Ω) (H : Finset Ω), 0 < outer.mass H → + ∀ (localLaw : Ω → FiniteProbabilityWeights J) + (physical : Ω → J → X) (point : Ω → J → σ → ℤ) (weight : X → ℂ) + {B δ : ℝ}, 0 < B → 0 < δ → + (∀ a ∈ H, ∀ j, ‖weight (physical a j)‖ ≤ B) → + (∀ a ∈ H, δ ≤ ((localLaw a).complexMean (fun j => weight (physical a j) * + ((descended (physical a j)).withOrbit q).eval (point a j))).re) → + ∃ restored : D.filtration.realification.PolynomialOrbit w, + map (realLieHomToRat (realificationLieHom φ)).toLinearMap restored.log = marked.log ∧ + (∀ x, ((tests x).withOrbit restored).observable = (tests x).observable ∧ + ((tests x).withOrbit restored).UnitIntervalValued ∧ + ∀ p', ((tests x).withOrbit restored).ComplexityLE p' ↔ (tests x).ComplexityLE p') ∧ + ∃ H' : Finset Ω, H' ⊆ H ∧ 0 < outer.mass H' ∧ + δ / (2 * B) * outer.mass H ≤ outer.mass H' ∧ + ∀ a ∈ H', δ / 2 ≤ ((localLaw a).complexMean (fun j => weight (physical a j) * + ((tests (physical a j)).withOrbit restored).eval (point a j))).re := by + obtain ⟨C, hC, hdescent⟩ := exists_external_kernelProjection_native_descent t + refine ⟨C, hC, ?_⟩ + intro L σ X _ _ _ _ _ _ s d n D I _ _ _ _ hI Q hQF hQL htop w tests p + hp htests hunit hQ he + obtain ⟨descended, _, _, hpositive, hcomplex, _, hrec, _, hcontraction⟩ := + hdescent D I hI Q hQF hQL htop tests p hp htests hunit hQ he + refine ⟨descended, hpositive, hcomplex, hcontraction, ?_⟩ + intro M Ω J _ _ _ _ u G φ hker q marked hmark outer H hH localLaw physical point weight + B δ hB hδ hweight hscore + exact D.exists_external_marked_quotient_restoration I hI Q hQF G φ hker htop + tests hunit (fun x => (descended x).observable) hrec q marked hmark + outer H hH localLaw physical point weight hB hδ hweight hscore + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeMarkedKernelFreezing.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeMarkedKernelFreezing.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9cee43e3c8600983f8c02f48e5ea07f805d2f25 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeMarkedKernelFreezing.lean @@ -0,0 +1,47 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformControlledNativeExternalNetsOfRecovery + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {σ L Q : Type*} [LieRing L] [LieAlgebra ℚ L] [Group Q] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem observable_freeze_marked_kernel_factors + (T : D.Niltest w) (π : D.RealGroup →* Q) (ρ : Q → D.RealGroup) + (hρ : Function.RightInverse ρ π) + (a b r : D.RealGroup) (aF rF : Q) + (kE kR : D.RealGroup) (hkE : π kE = 1) (hkR : π kR = 1) + (hcoset : (QuotientGroup.mk ((ρ rF)⁻¹ * r) : D.Space) = QuotientGroup.mk kR) : + π (kE * ρ aF) = aF ∧ π (ρ rF * kR) = rF ∧ + letI := rightMetricSpace + (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) (D.basis.baseChange ℝ) + ‖T.observable (QuotientGroup.mk (a * b * r)) - + T.observable (QuotientGroup.mk ((kE * ρ aF) * b * (ρ rF * kR)))‖ ≤ + (T.lipBound : ℝ) * dist (a * (ρ aF)⁻¹) kE := by + let := rightMetricSpace + (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) (D.basis.baseChange ℝ) + let := rightMetricSpace_isIsometricSMul + (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) (D.basis.baseChange ℝ) + have hright : (QuotientGroup.mk r : D.Space) = QuotientGroup.mk (ρ rF * kR) := by + have h := congrArg (fun x : D.Space => (ρ rF) • x) hcoset + change QuotientGroup.mk (ρ rF * ((ρ rF)⁻¹ * r)) = + (QuotientGroup.mk (ρ rF * kR) : D.Space) at h + simpa only [mul_inv_cancel_left] using h + refine ⟨by rw [map_mul, hkE, hρ, one_mul], by rw [map_mul, hkR, hρ, mul_one], ?_⟩ + have hfreeze := T.observable_freeze_factors a (kE * ρ aF) b r (ρ rF * kR) hright + have hdist : dist a (kE * ρ aF) = dist (a * (ρ aF)⁻¹) kE := by + rw [← dist_mul_right a (kE * ρ aF) (ρ aF)⁻¹, mul_inv_cancel_right] + exact hfreeze.trans_eq (congrArg (fun z : ℝ => (T.lipBound : ℝ) * z) hdist) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeMarkedKernelRepresentatives.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeMarkedKernelRepresentatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..11c4df0e42ca73d70e88199be1a3af8a6fff99cd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeMarkedKernelRepresentatives.lean @@ -0,0 +1,332 @@ +import Mathlib.Algebra.Lie.Ideal +import Mathlib.LinearAlgebra.Matrix.ToLin +import OAI.Combinatorics.Progressions.Dynamics.QuotientDetectorHeightBudget +import OAI.Combinatorics.Progressions.Estimates.CommonRefilteredFactorization +import OAI.Combinatorics.Progressions.Estimates.NativeBoundedSubalgebraRepresentatives + +namespace OAI + +section + +namespace Erdos3 +open Module +open scoped Classical Matrix + +section Linear +variable {ι κ V W : Type*} [Fintype ι] [Fintype κ] + [AddCommGroup V] [Module ℚ V] [AddCommGroup W] [Module ℚ W] + +noncomputable def basisMatrixKernelEquiv (b : Basis ι ℚ V) (c : Basis κ ℚ W) + (T : V →ₗ[ℚ] W) : + LinearMap.ker (LinearMap.toMatrix b c T).mulVecLin ≃ₗ[ℚ] LinearMap.ker T := by + have hker : LinearMap.ker (LinearMap.toMatrix b c T).mulVecLin = + (LinearMap.ker T).comap b.equivFun.symm.toLinearMap := by + ext x + have heq : LinearMap.toMatrix b c T *ᵥ x = c.equivFun (T (b.equivFun.symm x)) := by + simpa only [← Basis.equivFun_apply, LinearEquiv.apply_symm_apply] using + LinearMap.toMatrix_mulVec_repr b c T (b.equivFun.symm x) + simp only [Submodule.mem_comap, LinearMap.mem_ker, Matrix.mulVecLin_apply] + rw [heq] + exact c.equivFun.map_eq_zero_iff + exact (LinearEquiv.ofEq _ _ hker).trans + (b.equivFun.symm.ofSubmodule' (LinearMap.ker T)) + +@[simp] theorem basisMatrixKernelEquiv_repr (b : Basis ι ℚ V) (c : Basis κ ℚ W) + (T : V →ₗ[ℚ] W) (x : LinearMap.ker (LinearMap.toMatrix b c T).mulVecLin) (i : ι) : + b.repr (basisMatrixKernelEquiv b c T x : V) i = (x : ι → ℚ) i := by + change b.repr (b.equivFun.symm (x : ι → ℚ)) i = (x : ι → ℚ) i + rw [← Basis.equivFun_apply, LinearEquiv.apply_symm_apply] + +theorem exists_bounded_linearMap_kernel_basis + (b : Basis ι ℚ V) (c : Basis κ ℚ W) (T : V →ₗ[ℚ] W) + {H : ℕ} (hH : 1 ≤ H) + (hT : ∀ i j, RationalHeightLE (c.repr (T (b j)) i) H) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ bk : Basis (Fin r) ℚ (LinearMap.ker T), + ∀ j i, RationalHeightLE (b.repr (bk j : V) i) + (rationalKernelHeight (Fintype.card κ) H) := by + let A := LinearMap.toMatrix b c T + have hA : ∀ i j, RationalHeightLE (A i j) H := by + simpa only [A, LinearMap.toMatrix_apply] using hT + obtain ⟨t, ht, bk, hbk⟩ := exists_bounded_rational_kernel_basis A hH hA + refine ⟨Module.finrank ℚ (LinearMap.ker A.mulVecLin), ?_, + bk.map (basisMatrixKernelEquiv b c T), ?_⟩ + · simpa only [Module.finrank_pi, Module.finrank_self, Nat.mul_one] using + (LinearMap.ker A.mulVecLin).finrank_le + · intro j i + simp only [Basis.map_apply] + rw [basisMatrixKernelEquiv_repr b c T (bk j) i] + exact (hbk j i).mono (rationalKernelHeight_mono hH ht) + +end Linear + +section Lie +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +theorem exists_bounded_lie_kernel_basis + (b : Basis ι ℚ L) (c : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + {H : ℕ} (hH : 1 ≤ H) + (hφ : ∀ i j, RationalHeightLE (c.repr (φ (b j)) i) H) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ bk : Basis (Fin r) ℚ (LinearMap.ker φ.toLinearMap), + ∀ j i, RationalHeightLE (b.repr (bk j : L) i) + (rationalKernelHeight (Fintype.card κ) H) := + exists_bounded_linearMap_kernel_basis b c φ.toLinearMap hH hφ + +theorem exists_bounded_lie_kernel_subalgebra_basis + (b : Basis ι ℚ L) (c : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + {H : ℕ} (hH : 1 ≤ H) + (hφ : ∀ i j, RationalHeightLE (c.repr (φ (b j)) i) H) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ bk : Basis (Fin r) ℚ φ.ker.toLieSubalgebra, + ∀ j i, RationalHeightLE (b.repr (bk j : L) i) + (rationalKernelHeight (Fintype.card κ) H) := + exists_bounded_lie_kernel_basis b c φ hH hφ + +theorem exists_lie_kernel_basis_exp_height + (b : Basis ι ℚ L) (c : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + {H : ℕ} (hHpos : 1 ≤ H) + (hφ : ∀ i j, RationalHeightLE (c.repr (φ (b j)) i) H) + {p : ℝ} (hp : 0 ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ bk : Basis (Fin r) ℚ (LinearMap.ker φ.toLinearMap), ∀ j i, + ((b.repr (bk j : L) i).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 7) ∧ + ((b.repr (bk j : L) i).den : ℝ) ≤ Real.exp ((p + 2) ^ 7) := by + obtain ⟨r, hr, bk, hbk⟩ := exists_bounded_lie_kernel_basis b c φ hHpos hφ + have hbudget := rationalKernelHeight_le_budget (Fintype.card κ) H hp hκ hH + exact ⟨r, hr, bk, fun j i => + ⟨(Nat.cast_le.mpr (hbk j i).1).trans hbudget, + (Nat.cast_le.mpr (hbk j i).2).trans hbudget⟩⟩ + +theorem exists_lie_kernel_subalgebra_basis_logHeight + (b : Basis ι ℚ L) (c : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + {p : ℝ} (hp : 0 ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hφ : ∀ i j, rationalLogHeight (c.repr (φ (b j)) i) ≤ p) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ bk : Basis (Fin r) ℚ φ.ker.toLieSubalgebra, ∀ j i, + ((b.repr (bk j : L) i).num.natAbs : ℝ) ≤ Real.exp ((p + 3) ^ 7) ∧ + ((b.repr (bk j : L) i).den : ℝ) ≤ Real.exp ((p + 3) ^ 7) := by + obtain ⟨r, hr, bk, hbk⟩ := exists_lie_kernel_basis_exp_height b c φ (one_le_ceil_exp p) + (fun i j => rationalHeightLE_ceil_exp (hφ i j)) + (by linarith : 0 ≤ p + 1) (hκ.trans (by linarith)) + (ceil_exp_le_exp_add_one hp) + refine ⟨r, hr, bk, fun j i => ?_⟩ + rw [show p + 1 + 2 = p + 3 by ring] at hbk + exact hbk j i + +end Lie +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +theorem exists_topLayer_basis_logHeight (hs : 1 ≤ s) {p : ℝ} + (hD : D.GeometryComplexityLE p) : + ∃ r : ℕ, ∃ b : Basis (Fin r) ℚ ((D.filtration.layerIdeal s).toLieSubalgebra), + ∀ a i, rationalLogHeight (D.basis.repr (b a : L) i) ≤ p := by + obtain ⟨b, hb⟩ := D.exists_positive_layer_basis s hs hD + exact ⟨finrank ℚ (D.filtration.layer s), b, hb⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open Module + +noncomputable def markedKernelCommonHeight (p : ℝ) : ℕ := + ⌈Real.exp ((p + 3) ^ 7)⌉₊ + +theorem markedKernelCommonHeight_pos (p : ℝ) : + 1 ≤ markedKernelCommonHeight p := + one_le_ceil_exp _ + +theorem markedKernelCommonHeight_le_exp {p : ℝ} (hp : 0 ≤ p) : + (markedKernelCommonHeight p : ℝ) ≤ Real.exp ((p + 3) ^ 7 + 1) := + ceil_exp_le_exp_add_one (by positivity) + +theorem rationalHeightLE_markedKernelCommonHeight {q : ℚ} {p : ℝ} + (hp : 0 ≤ p) (hq : rationalLogHeight q ≤ p) : + RationalHeightLE q (markedKernelCommonHeight p) := by + have hpow : (p + 3) ^ 1 ≤ (p + 3) ^ 7 := + pow_le_pow_right₀ (by linarith) (by omega) + apply rationalHeightLE_ceil_exp + exact hq.trans (by simpa only [pow_one] using (show p ≤ (p + 3) ^ 7 by + calc + p ≤ p + 3 := by linarith + _ = (p + 3) ^ 1 := (pow_one _).symm + _ ≤ (p + 3) ^ 7 := hpow)) + +section Lie + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +theorem exists_marked_kernel_basis_commonHeight + (b : Basis ι ℚ L) (c : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + {p : ℝ} (hp : 0 ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hφ : ∀ i j, rationalLogHeight (c.repr (φ (b j)) i) ≤ p) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ bk : Basis (Fin r) ℚ (LinearMap.ker φ.toLinearMap), + ∀ j i, RationalHeightLE (b.repr (bk j : L) i) + (markedKernelCommonHeight p) := by + obtain ⟨r, hr, bk, hbk⟩ := + exists_lie_kernel_subalgebra_basis_logHeight b c φ hp hκ hφ + exact ⟨r, hr, bk, fun j i => rationalHeightLE_ceil_exp_of_entries (hbk j i)⟩ + +theorem exists_marked_kernel_basis_commonHeight_of_dim + (b : Basis ι ℚ L) (c : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hφ : ∀ i j, rationalLogHeight (c.repr (φ (b j)) i) ≤ p) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ (r : ℝ) ≤ p ∧ + ∃ bk : Basis (Fin r) ℚ (LinearMap.ker φ.toLinearMap), + ∀ j i, RationalHeightLE (b.repr (bk j : L) i) + (markedKernelCommonHeight p) := by + obtain ⟨r, hr, bk, hbk⟩ := exists_marked_kernel_basis_commonHeight b c φ hp hκ hφ + exact ⟨r, hr, (Nat.cast_le.mpr hr).trans hι, bk, hbk⟩ + +end Lie +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold +open Module + +theorem exists_nativeTopMarkKernel_spanning_budget : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d e : ℕ} (D : RationalFilteredNilmanifold L s d) + (b : Basis (Fin e) ℚ M) (φ : L →ₗ⁅ℚ⁆ M) (p : ℝ), + 1 ≤ s → 0 ≤ p → D.GeometryComplexityLE p → (e : ℝ) ≤ p → + (∀ i j, rationalLogHeight (b.repr (φ (D.basis j)) i) ≤ p) → + ∃ vP : Fin d → L, + Submodule.span ℚ (Set.range vP) = + D.filtration.layer s ⊓ LinearMap.ker φ.toLinearMap ∧ + ∀ i j, rationalLogHeight (D.basis.repr (vP i) j) ≤ (p + 2) ^ C := by + let P : Polynomial ℕ := ((((Polynomial.X + 3) ^ 7 + 4) ^ 2 + 2) ^ 63 + 3) + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget P + refine ⟨C, hC, ?_⟩ + intro L M _ _ _ _ s d e D b φ p hs hp hD he hφ + classical + obtain ⟨r, btop, hbtop⟩ := D.exists_topLayer_basis_logHeight hs hD + obtain ⟨rk, _, bk, hbk⟩ := exists_lie_kernel_subalgebra_basis_logHeight + D.basis b φ hp (by simpa only [Fintype.card_fin] using he) hφ + let q : ℝ := (p + 3) ^ 7 + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + have h := pow_le_pow_right₀ (show (1 : ℝ) ≤ p + 3 by linarith) + (show 1 ≤ (7 : ℕ) by decide) + have h' : p + 3 ≤ q := by simpa only [pow_one] using h + linarith + have htop : ∀ a i, rationalLogHeight (D.basis.repr (btop a : L) i) ≤ q := + fun a i => (hbtop a i).trans hpq + have hk : ∀ a i, rationalLogHeight (D.basis.repr (bk a : L) i) ≤ q := + fun a i => (rationalLogHeight_le_iff _ _).mpr (hbk a i) + let U := (D.filtration.layerIdeal s).toLieSubalgebra + let V := φ.ker.toLieSubalgebra + obtain ⟨bP, hbP⟩ := exists_binary_intersection_basis_logHeight + D.basis U V btop bk hq + (by simpa only [Fintype.card_fin] using hD.1.trans hpq) htop hk + let B : ℝ := ((q + 4) ^ 2 + 2) ^ 63 + 2 + have hB : 0 ≤ B := by dsimp [B]; positivity + have hspan := exists_bounded_ambient_spanning D.basis (U ⊓ V) bP bP.span_eq + (one_le_ceil_exp B) (fun a i => rationalHeightLE_ceil_exp (hbP a i)) + obtain ⟨vP, hvP, hvPh⟩ := hspan + let indexEquiv : Fin d ≃ Fin (Fintype.card (Fin d)) := finCongr (Fintype.card_fin d).symm + refine ⟨fun i => vP (indexEquiv i), ?_, ?_⟩ + · have hrange : Set.range (fun i => vP (indexEquiv i)) = Set.range vP := by + ext x + constructor + · rintro ⟨i, rfl⟩ + exact ⟨indexEquiv i, rfl⟩ + · rintro ⟨i, rfl⟩ + obtain ⟨j, rfl⟩ := indexEquiv.surjective i + exact ⟨j, rfl⟩ + rw [hrange] + exact hvP + intro a i + have hheight : rationalLogHeight (D.basis.repr (vP (indexEquiv a)) i) ≤ B + 1 := + rationalLogHeight_le_of_height (hvPh (indexEquiv a) i) (ceil_exp_le_exp_add_one hB) + apply hheight.trans + simpa [P, q, B, Polynomial.eval₂_pow, add_assoc, + show (2 : ℝ) + 1 = 3 by norm_num] using hbudget p hp + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +theorem exists_native_marked_kernel_representatives (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {κ L M : Type*} [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} (D : RationalFilteredNilmanifold L s d) + (c : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) (p : ℝ), + 0 ≤ p → D.GeometryComplexityLE p → (Fintype.card κ : ℝ) ≤ p → + (∀ i j, rationalLogHeight (c.repr (φ (D.basis j)) i) ≤ p) → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∀ g : D.RealGroup, + g ∈ realificationSubgroup (hnil := D.filtration.lowerCentralSeries_eq_bot) + φ.ker.toLieSubalgebra → + (D.basis.baseChange ℝ).equivFun g.coord ∈ realDenominatorGrid q → + ∃ r : D.RealGroup, + r ∈ realificationSubgroup (hnil := D.filtration.lowerCentralSeries_eq_bot) + φ.ker.toLieSubalgebra ∧ + (∀ i, |(D.basis.baseChange ℝ).repr r.coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + (D.basis.baseChange ℝ).equivFun r.coord ∈ realDenominatorGrid m ∧ + ∃ γ ∈ D.realLattice, g = r * γ := by + obtain ⟨a, _, hrep⟩ := exists_native_bounded_subalgebra_representatives s + let P : Polynomial ℕ := ((Polynomial.X + 3) ^ 7 + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro κ L M _ _ _ _ _ _ _ _ _ d D c φ p hp hD hκ hφ q hq hqp + obtain ⟨n, hn, bk, hbk⟩ := + exists_lie_kernel_subalgebra_basis_logHeight D.basis c φ hp hκ hφ + let t := (p + 3) ^ 7 + have ht : 0 ≤ t := by dsimp [t]; positivity + have hpt : p ≤ t := by + exact (le_power_budget hp (by decide : 1 ≤ 7)).trans + (pow_le_pow_left₀ (by linarith : 0 ≤ p + 2) (by linarith : p + 2 ≤ p + 3) 7) + have hn' : (Fintype.card (Fin n) : ℝ) ≤ t := by + have hnd : n ≤ d := by simpa only [Fintype.card_fin] using hn + simpa only [Fintype.card_fin] using (Nat.cast_le.mpr hnd).trans (hD.1.trans hpt) + have hinc : ∀ i j, rationalLogHeight (D.basis.repr (bk j : L) i) ≤ t := + fun i j => (rationalLogHeight_le_iff _ t).mpr (hbk j i) + obtain ⟨m, hm, hmb, hreps⟩ := hrep D φ.ker.toLieSubalgebra bk t ht + (GeometryComplexityLE.mono D hD hpt) + hn' hinc q hq (hqp.trans (Real.exp_le_exp.mpr hpt)) + have hb : (t + a) ^ a ≤ (p + C) ^ C := by + simpa [P, t, Polynomial.eval₂_pow] using hbudget p hp + refine ⟨m, hm, hmb.trans (Real.exp_le_exp.mpr hb), ?_⟩ + intro g hgK hg + obtain ⟨r, hrK, hr, hrgrid, γ, hγ, hfac⟩ := hreps g hgK hg + exact ⟨r, hrK, fun i => (hr i).trans (Real.exp_le_exp.mpr hb), hrgrid, γ, hγ, hfac⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativePairSymbolProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativePairSymbolProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..b60ab4d57b27b99e6905f2826ba55d27fff25f50 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativePairSymbolProjection.lean @@ -0,0 +1,139 @@ +import OAI.Combinatorics.Progressions.Estimates.TranslationMajorTwistedCorrelationStepDrop +import OAI.Combinatorics.Progressions.Polynomial.ProductPolynomialMaps + +namespace OAI + +universe sourceLevel + +section + +namespace Erdos3.RationalFilteredNilmanifold +open Module +variable {ι : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + + theorem productProjection_repr (x : ∀ i, L i) (i : ι) (j : Fin (d i)) : + (D i).basis.repr (x i) j = + (pi D).basis.repr x (Fintype.equivFin (Σ i, Fin (d i)) ⟨i, j⟩) := by + change _ = (productFinBasis D).repr x _ + rw [productFinBasis, Basis.repr_reindex_apply] + simp only [Equiv.symm_apply_apply, Pi.basis_repr] + + theorem productProjection_coordinate_logHeight {p : ℝ} (x : ∀ i, L i) + (hx : ∀ k, rationalLogHeight ((pi D).basis.repr x k) ≤ p) (i : ι) (j : Fin (d i)) : + rationalLogHeight ((D i).basis.repr (x i) j) ≤ p := by + rw [productProjection_repr D x i j] + exact hx _ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold +open Module +variable {L M : Type sourceLevel} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d e : ℕ} + + theorem pairFirstProjection_filtered (D : RationalFilteredNilmanifold L s d) + (E : RationalFilteredNilmanifold M s e) (j : ℕ) + (x : PairAlgebra L M) (hx : x ∈ (pi (pairModels D E)).filtration.layer j) : + liePiEval (R := ℚ) true x ∈ D.filtration.layer j := + (NilpotentLieFiltration.mem_pi_layer (fun i => (pairModels D E i).filtration) j x).mp hx true + + theorem pairFrequency_zero_comp (η : L →ₗ[ℚ] ℚ) : + pairFrequency η (0 : M →ₗ[ℚ] ℚ) = + η.comp (liePiEval (R := ℚ) (M := BoolLieFamily L M) true).toLinearMap := by + apply LinearMap.ext + intro x + change pairFrequency η (0 : M →ₗ[ℚ] ℚ) x = η (x true) + rw [pairFrequency_apply] + exact add_zero _ + +end Erdos3.RationalFilteredNilmanifold + +namespace Erdos3.PolynomialTranslationLie +open Module RationalFilteredNilmanifold +variable {σ L : Type} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] {e : ℕ} + (D : RationalFilteredNilmanifold L d e) + +theorem pairTranslationProjection_coordinate_logHeight {p : ℝ} + (x : PairAlgebra (weightedSubalgebra w d) L) + (hx : ∀ j, rationalLogHeight + ((pi (pairModels (weightedTranslationNilmanifold w d hw hwd) D)).basis.repr x j) ≤ p) + (i : WeightedBasisIndex w d) : + rationalLogHeight ((weightedBasis w d hw).repr (x true) i) ≤ p := by + have h := productProjection_coordinate_logHeight + (pairModels (weightedTranslationNilmanifold w d hw hwd) D) x hx true + (weightedIndexOrder w d i) + change rationalLogHeight ((weightedOrderedBasis w d hw).repr (x true) + (weightedIndexOrder w d i)) ≤ p at h + have he := weightedOrderedBasis_repr w d hw (x true) (weightedIndexOrder w d i) + have he' : (weightedOrderedBasis w d hw).repr (x true) (weightedIndexOrder w d i) = + (weightedBasis w d hw).repr (x true) i := + he.trans (congrArg ((weightedBasis w d hw).repr (x true)) ((weightedIndexOrder w d).symm_apply_apply i)) + exact he' ▸ h + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold +open Module VectorPolynomial +open scoped TensorProduct + +variable {L M : Type sourceLevel} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d e : ℕ} (D : RationalFilteredNilmanifold L s d) + (E : RationalFilteredNilmanifold M s e) + {σ ι κ : Type*} (w : σ → ℕ) + (b : Basis ι ℚ (PairAlgebra L M)) (ω : ι → ℕ) + (hF : ∀ j, (pi (pairModels D E)).filtration.layer j = + Submodule.span ℚ (b '' {i | j ≤ ω i})) + (c : Basis κ ℚ L) (ν : κ → ℕ) + (hG : ∀ j, D.filtration.layer j = Submodule.span ℚ (c '' {i | j ≤ ν i})) + +theorem pairOrbit_first_projection_log + (p : D.filtration.realification.PolynomialOrbit w) + (q : E.filtration.realification.PolynomialOrbit w) : + VectorPolynomial.map ((realificationLieHom (liePiEval (R := ℚ) + (M := BoolLieFamily L M) true)).toLinearMap.restrictScalars ℚ) (pairOrbit D E p q).log = p.log := by + let g : ∀ i : Bool, (pairModels D E i).filtration.realification.PolynomialOrbit w := + fun i => by cases i; exact q; exact p + have h := NilpotentLieFiltration.piRealOrbit_projection_log + (fun i => (pairModels D E i).filtration) g true + change VectorPolynomial.map ((realificationLieHom (liePiEval (R := ℚ) + (M := BoolLieFamily L M) true)).toLinearMap.restrictScalars ℚ) (pairOrbit D E p q).log = p.log at h + exact h + +theorem pairOrbitSymbol_first_projection + (p : D.filtration.realification.PolynomialOrbit w) + (q : E.filtration.realification.PolynomialOrbit w) : + realificationLieHom + ((pi (pairModels D E)).filtration.filteredPolynomialSymbolMap D.filtration + (liePiEval (R := ℚ) true) (pairFirstProjection_filtered D E) w) + (pairOrbitSymbol D E p q b ω hF).coord = + D.filtration.realSymbolOfPolynomial c ν hG w p.log := by + have h := (pi (pairModels D E)).filtration.realFilteredPolynomialSymbolMap_polynomial + D.filtration (liePiEval (R := ℚ) true) (pairFirstProjection_filtered D E) + b ω hF c ν hG w ⟨(pairOrbit D E p q).log, (pairOrbit D E p q).property⟩ + change realificationLieHom + ((pi (pairModels D E)).filtration.filteredPolynomialSymbolMap D.filtration + (liePiEval (R := ℚ) true) (pairFirstProjection_filtered D E) w) + (pairOrbitSymbol D E p q b ω hF).coord = + D.filtration.realSymbolOfPolynomial c ν hG w + (VectorPolynomial.map ((realificationLieHom (liePiEval (R := ℚ) + (M := BoolLieFamily L M) true)).toLinearMap.restrictScalars ℚ) (pairOrbit D E p q).log) at h + refine h.trans (congrArg (D.filtration.realSymbolOfPolynomial c ν hG w) ?_) + exact pairOrbit_first_projection_log D E w p q + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativePrescribedProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativePrescribedProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..214a71f78352b2b936d0cfeee50f86105c10c538 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativePrescribedProjection.lean @@ -0,0 +1,282 @@ +import OAI.Combinatorics.Progressions.Nilpotent.NiltestVerticalBounds + +namespace OAI + +section + +namespace Erdos3.CircleFourier.IsometricCircleAction + +open MeasureTheory +open scoped NNReal + +variable {X : Type*} [PseudoMetricSpace X] + +noncomputable def project (A : IsometricCircleAction X) (n : ℤ) (f : X → ℂ) : X → ℂ := + let := A.toAddAction + circleFourierComponent n f + +theorem project_character (A : IsometricCircleAction X) (n : ℤ) (f : X → ℂ) + (t : Circle) (x : X) : + A.project n f (A.act t x) = character (n • t) * A.project n f x := by + let := A.toAddAction + exact circleFourierComponent_vadd n f t x + +theorem project_lipschitz (A : IsometricCircleAction X) (n : ℤ) {f : X → ℂ} + {K : ℝ≥0} (hf : LipschitzWith K f) : LipschitzWith K (A.project n f) := by + let := A.toAddAction + let := A.toContinuousVAdd + exact lipschitz_circleFourierComponent n hf A.isometry_act + +theorem project_norm_le (A : IsometricCircleAction X) (n : ℤ) {f : X → ℂ} + {B : ℝ} (hf : ∀ x, ‖f x‖ ≤ B) (x : X) : ‖A.project n f x‖ ≤ B := by + let := A.toAddAction + exact norm_circleFourierComponent_le n f hf x + +theorem project_equivariant (A : IsometricCircleAction X) (n : ℤ) {f : X → ℂ} + (g : X → X) (z : ℂ) (hg : ∀ t x, A.act t (g x) = g (A.act t x)) + (hf : ∀ x, f (g x) = z * f x) (x : X) : + A.project n f (g x) = z * A.project n f x := by + unfold project circleFourierComponent + change (∫ t : Circle, character ((-n) • t) * f (A.act t (g x)) ∂circleHaar) = + z * (∫ t : Circle, character ((-n) • t) * f (A.act t x) ∂circleHaar) + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards [] with t + rw [hg, hf] + ring + +theorem project_eq_at (A : IsometricCircleAction X) (n : ℤ) (f : X → ℂ) (x : X) + (hx : ∀ t, f (A.act t x) = character (n • t) * f x) : A.project n f x = f x := by + unfold project circleFourierComponent + change (∫ t : Circle, character ((-n) • t) * f (A.act t x) ∂circleHaar) = _ + have heq (t : Circle) : character ((-n) • t) * f (A.act t x) = f x := by + rw [hx, ← mul_assoc, ← character_add, ← add_smul] + simp only [neg_add_cancel, zero_smul, character_zero, one_mul] + simp_rw [heq] + simp + +end Erdos3.CircleFourier.IsometricCircleAction + +end + +section + +namespace Erdos3.CircleFourier + +open scoped NNReal + +variable {X α : Type*} [PseudoMetricSpace X] + +noncomputable def iteratedExactProjection (A : α → IsometricCircleAction X) (n : α → ℤ) : + List α → (X → ℂ) → X → ℂ + | [], f => f + | i :: is, f => (A i).project (n i) (iteratedExactProjection A n is f) + +theorem iteratedExactProjection_lipschitz (A : α → IsometricCircleAction X) (n : α → ℤ) + (is : List α) {f : X → ℂ} {K : ℝ≥0} (hf : LipschitzWith K f) : + LipschitzWith K (iteratedExactProjection A n is f) := by + induction is with + | nil => exact hf + | cons i is ih => exact (A i).project_lipschitz (n i) ih + +theorem iteratedExactProjection_norm_le (A : α → IsometricCircleAction X) (n : α → ℤ) + (is : List α) {f : X → ℂ} {B : ℝ} (hf : ∀ x, ‖f x‖ ≤ B) : + ∀ x, ‖iteratedExactProjection A n is f x‖ ≤ B := by + induction is with + | nil => exact hf + | cons i is ih => exact (A i).project_norm_le (n i) ih + +theorem iteratedExactProjection_character (A : α → IsometricCircleAction X) (n : α → ℤ) + (is : List α) (hcomm : ∀ i ∈ is, ∀ j ∈ is, (A i).Commutes (A j)) (f : X → ℂ) + (j : α) (hj : j ∈ is) (t : Circle) (x : X) : + iteratedExactProjection A n is f ((A j).act t x) = + character (n j • t) * iteratedExactProjection A n is f x := by + induction is generalizing x with + | nil => simp only [List.not_mem_nil] at hj + | cons i is ih => + rcases List.mem_cons.mp hj with rfl | hj + · exact (A j).project_character (n j) _ t x + · apply (A i).project_equivariant (n i) ((A j).act t) (character (n j • t)) + · exact fun u y => hcomm i List.mem_cons_self j (List.mem_cons_of_mem i hj) u t y + · intro y + exact ih (fun a ha b hb => hcomm a (List.mem_cons_of_mem i ha) b + (List.mem_cons_of_mem i hb)) hj y + +theorem iteratedExactProjection_eq_on (A : α → IsometricCircleAction X) (n : α → ℤ) + (is : List α) (S : Set X) (f : X → ℂ) + (hstable : ∀ i ∈ is, ∀ t x, x ∈ S → (A i).act t x ∈ S) + (hchar : ∀ i ∈ is, ∀ t x, x ∈ S → f ((A i).act t x) = character (n i • t) * f x) : + ∀ x ∈ S, iteratedExactProjection A n is f x = f x := by + induction is with + | nil => exact fun _ _ => rfl + | cons i is ih => + have htail := ih (fun j hj => hstable j (List.mem_cons_of_mem i hj)) + (fun j hj => hchar j (List.mem_cons_of_mem i hj)) + intro x hx + change (A i).project (n i) (iteratedExactProjection A n is f) x = f x + rw [(A i).project_eq_at (n i) _ x] + · exact htail x hx + · intro t + rw [htail _ (hstable i List.mem_cons_self t x hx), htail x hx] + exact hchar i List.mem_cons_self t x hx + +end Erdos3.CircleFourier + +end + +section + +namespace Erdos3.CircleFourier + +open scoped NNReal + +theorem exists_prescribed_circle_projection {X α : Type*} [PseudoMetricSpace X] [Fintype α] + (A : α → IsometricCircleAction X) (n : α → ℤ) + (hcomm : ∀ i j, (A i).Commutes (A j)) (S : Set X) (f : X → ℂ) + (hstable : ∀ i t x, x ∈ S → (A i).act t x ∈ S) + (hchar : ∀ i t x, x ∈ S → f ((A i).act t x) = character (n i • t) * f x) + {K : ℝ≥0} {B : ℝ} (hf : LipschitzWith K f) (hb : ∀ x, ‖f x‖ ≤ B) : + ∃ g : X → ℂ, LipschitzWith K g ∧ (∀ x, ‖g x‖ ≤ B) ∧ + (∀ i t x, g ((A i).act t x) = character (n i • t) * g x) ∧ + ∀ x ∈ S, g x = f x := by + classical + let is := (Finset.univ : Finset α).toList + refine ⟨iteratedExactProjection A n is f, iteratedExactProjection_lipschitz A n is hf, + iteratedExactProjection_norm_le A n is hb, ?_, ?_⟩ + · intro j t x + exact iteratedExactProjection_character A n is (fun i _ j _ => hcomm i j) f j + (by simp [is]) t x + · exact iteratedExactProjection_eq_on A n is S f (fun i _ => hstable i) (fun i _ => hchar i) + +end Erdos3.CircleFourier + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open CircleFourier +open scoped NNReal + +variable {L ι : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem exists_prescribed_central_projection + (Γ T : Subgroup (NilpotentLieBCHGroup L s hnil)) + [PseudoMetricSpace (NilpotentLieBCHGroup L s hnil ⧸ Γ)] + (hT : ∀ z ∈ T, ∀ v : L, ⁅z.coord, v⁆ = 0) + (u : ι → L) (hline : ∀ i r, realBCHLine (hnil := hnil) (u i) r ∈ T) + (hspan : ∀ z ∈ T, z.coord ∈ Submodule.span ℝ (Set.range u)) + (A : ι → IsometricCircleAction (NilpotentLieBCHGroup L s hnil ⧸ Γ)) + (hcomm : ∀ i j, (A i).Commutes (A j)) + (hact : ∀ i (r : ℝ) x, (A i).act (r : CircleFourier.Circle) x = + realBCHLine (hnil := hnil) (u i) r • x) + (η : L →ₗ[ℝ] ℝ) (f : NilpotentLieBCHGroup L s hnil ⧸ Γ → ℂ) + (hseed : ∀ z ∈ T, f (QuotientGroup.mk z) = logCharacter η z) + {K : ℝ≥0} {B : ℝ} (hf : LipschitzWith K f) (hb : ∀ x, ‖f x‖ ≤ B) : + ∃ g : NilpotentLieBCHGroup L s hnil ⧸ Γ → ℂ, + LipschitzWith K g ∧ (∀ x, ‖g x‖ ≤ B) ∧ + (∀ z ∈ T, ∀ x, g (z • x) = logCharacter η z * g x) ∧ + ∀ z ∈ T, g (QuotientGroup.mk z) = logCharacter η z := by + classical + have hperiod (i) : (QuotientGroup.mk (realBCHLine (hnil := hnil) (u i) 1) : _ ⧸ Γ) = + QuotientGroup.mk (1 : NilpotentLieBCHGroup L s hnil) := by + have h := hact i 1 (QuotientGroup.mk (1 : NilpotentLieBCHGroup L s hnil)) + simpa only [AddCircle.coe_period, (A i).zero_act, MulAction.Quotient.smul_mk, + smul_eq_mul, mul_one] using h.symm + have hint (i) : ∃ n : ℤ, η (u i) = n := by + have he : character (η (u i) : CircleFourier.Circle) = 1 := by + calc + _ = f (QuotientGroup.mk (realBCHLine (hnil := hnil) (u i) 1)) := by + rw [hseed _ (hline i 1)] + simp only [logCharacter, realBCHLine, one_smul] + _ = f (QuotientGroup.mk (1 : NilpotentLieBCHGroup L s hnil)) := congrArg f (hperiod i) + _ = 1 := by rw [hseed _ T.one_mem]; simp only [logCharacter, coord_one, map_zero, + AddCircle.coe_zero, character_zero] + obtain ⟨n, hn⟩ := (AddCircle.coe_eq_zero_iff (1 : ℝ)).mp ((character_eq_one_iff _).mp he) + exact ⟨n, by simpa only [zsmul_eq_mul, mul_one] using hn.symm⟩ + choose n hn using hint + have hlinechar (i r) : logCharacter η (realBCHLine (hnil := hnil) (u i) r) = + character (n i • (r : CircleFourier.Circle)) := by + simp only [logCharacter, realBCHLine, map_smul, smul_eq_mul, hn, ← AddCircle.coe_zsmul, + zsmul_eq_mul, mul_comm] + let S : Set (NilpotentLieBCHGroup L s hnil ⧸ Γ) := Set.range (fun z : T => QuotientGroup.mk z.val) + have hstable : ∀ i t x, x ∈ S → (A i).act t x ∈ S := by + intro i t x hx + obtain ⟨r, rfl⟩ := QuotientAddGroup.mk_surjective t + obtain ⟨z, rfl⟩ := hx + rw [hact, MulAction.Quotient.smul_mk, smul_eq_mul] + exact ⟨⟨realBCHLine (u i) r * z.val, T.mul_mem (hline i r) z.property⟩, rfl⟩ + have hchar : ∀ i t x, x ∈ S → f ((A i).act t x) = character (n i • t) * f x := by + intro i t x hx + obtain ⟨r, rfl⟩ := QuotientAddGroup.mk_surjective t + obtain ⟨z, rfl⟩ := hx + rw [hact, MulAction.Quotient.smul_mk, smul_eq_mul, + hseed _ (T.mul_mem (hline i r) z.property), hseed _ z.property, + logCharacter_mul η _ _ (hT _ (hline i r) z.val.coord), hlinechar] + obtain ⟨g, hg, hgb, hgchar, hgeq⟩ := + exists_prescribed_circle_projection A n hcomm S f hstable hchar hf hb + refine ⟨g, hg, hgb, ?_, fun z hz => (hgeq _ ⟨⟨z, hz⟩, rfl⟩).trans (hseed z hz)⟩ + intro z hz x + apply central_span_character u (fun i v => ?_) η g (fun i r y => ?_) (hspan z hz) x + · simpa only [realBCHLine, one_smul] using hT _ (hline i 1) v + · have h := hgchar i (r : CircleFourier.Circle) y + rw [hact, ← hlinechar] at h + simpa only [logCharacter, realBCHLine, map_smul, smul_eq_mul] using h + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) + +theorem exists_native_prescribed_projection {p : ℝ} (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) + (η : L →ₗ[ℚ] ℚ) (f : D.Space → ℂ) {K : ℝ≥0} {B : ℝ} + (hf : letI := D.metricSpace; LipschitzWith K f) (hb : ∀ x, ‖f x‖ ≤ B) + (hseed : ∀ z : D.RealGroup, z ∈ D.filtration.realification.subgroup s → + f (QuotientGroup.mk z) = logCharacter (realifyFunctional η) z) : + ∃ g : D.Space → ℂ, (letI := D.metricSpace; LipschitzWith K g) ∧ + (∀ x, ‖g x‖ ≤ B) ∧ + (∀ z : D.RealGroup, z ∈ D.filtration.realification.subgroup s → ∀ x, + g (z • x) = logCharacter (realifyFunctional η) z * g x) ∧ + g (QuotientGroup.mk (1 : D.RealGroup)) = 1 := by + let := D.metricSpace + obtain ⟨b, w, N, hlayers, _, _, hN, _, _, _, A, hcomm, _, hact⟩ := + D.exists_controlled_central_actions hp hD + let S : Set (Fin (finrank ℚ L)) := {j | s ≤ w j} + let u (j : S) := (N : ℝ) • b.baseChange ℝ j + have hbReal (j : S) : b.baseChange ℝ j ∈ D.filtration.realLayer s := by + rw [Basis.baseChange_apply] + change rationalLieInclusion (b j) ∈ D.filtration.realLayer s + apply D.filtration.rational_inclusion_mem_realLayer + rw [hlayers s] + exact Submodule.subset_span ⟨j, j.property, rfl⟩ + have hline (j : S) (r : ℝ) : realBCHLine (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + (u j) r ∈ D.filtration.realification.subgroup s := by + change r • ((N : ℝ) • b.baseChange ℝ j) ∈ D.filtration.realLayer s + exact (D.filtration.realLayer s).smul_mem r ((D.filtration.realLayer s).smul_mem _ (hbReal j)) + obtain ⟨g, hg, hgb, hgvert, hgeq⟩ := exists_prescribed_central_projection + D.realLattice (D.filtration.realification.subgroup s) + (fun z hz v => D.filtration.realification.top_layer_central hz v) u hline + (fun z hz => D.filtration.realLayer_le_span_scaled_basis b s S (hlayers s) N hN hz) + A hcomm hact (realifyFunctional η) f hseed hf hb + refine ⟨g, hg, hgb, hgvert, ?_⟩ + have h := hgeq 1 (D.filtration.realification.subgroup s).one_mem + simpa only [logCharacter, coord_one, map_zero, AddCircle.coe_zero, CircleFourier.character_zero] using h + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeRankBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..fadac9de586c5842e7340ca953414f5868bb6aab --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankBudget.lean @@ -0,0 +1,185 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalPowerHeight + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +abbrev RankAlphabet := Σ i : Fin (s + 1), Fin (finrank ℚ (D.filtration.layer (i.val + 1))) + +def rankAlphabetWeight (a : D.RankAlphabet) : ℕ := a.1.val + 1 + +noncomputable def rankAlphabetVector (a : D.RankAlphabet) : L := D.layerBasis a.1 a.2 + +theorem rankAlphabetWeight_pos (a : D.RankAlphabet) : 0 < D.rankAlphabetWeight a := Nat.succ_pos _ + +theorem rankAlphabetVector_mem (a : D.RankAlphabet) : + D.rankAlphabetVector a ∈ D.filtration.layer (D.rankAlphabetWeight a) := + (D.layerBasis a.1 a.2).property + +theorem rankAlphabet_card_le : Fintype.card D.RankAlphabet ≤ (s + 1) * d := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + simp only [RankAlphabet, Fintype.card_sigma, Fintype.card_fin] + calc + _ ≤ ∑ _i : Fin (s + 1), d := by + apply Finset.sum_le_sum + intro i _ + simpa only [finrank_eq_card_basis D.basis, Fintype.card_fin] using + (D.filtration.layer (i.val + 1)).finrank_le + _ = _ := by simp + +theorem rankAlphabet_spans_layer (i : ℕ) (hi : 0 < i) : + D.filtration.layer i ≤ Submodule.span ℚ + (D.rankAlphabetVector '' {a | D.rankAlphabetWeight a = i}) := by + by_cases his : i ≤ s + 1 + · let j : Fin (s + 1) := ⟨i - 1, by omega⟩ + have hj : j.val + 1 = i := by dsimp [j]; omega + have heq : D.filtration.layer i = Submodule.span ℚ + (Set.range (fun k => ((D.layerBasis j k : D.filtration.layer (j.val + 1)) : L))) := by + rw [span_submodule_basis, hj] + rw [heq] + apply Submodule.span_mono + rintro x ⟨k, rfl⟩ + exact ⟨⟨j, k⟩, hj, rfl⟩ + · have hbot : D.filtration.layer i = ⊥ := by + apply bot_unique + exact (D.filtration.antitone (show s + 1 ≤ i by omega)).trans D.filtration.terminal.le + rw [hbot] + exact bot_le + +theorem rankAlphabet_span_layer (i : ℕ) (hi : 0 < i) : + Submodule.span ℚ (D.rankAlphabetVector '' {a | D.rankAlphabetWeight a = i}) = + D.filtration.layer i := by + apply le_antisymm _ (D.rankAlphabet_spans_layer i hi) + apply Submodule.span_le.mpr + rintro x ⟨a, ha, rfl⟩ + exact ha ▸ D.rankAlphabetVector_mem a + +noncomputable def finiteRankGenerators (i r : ℕ) : Finset L := by + classical + exact ((Finset.univ.filter (fun a : D.RankAlphabet => D.rankAlphabetWeight a = i + 1)).image + D.rankAlphabetVector) ∪ finiteWeightedLieValues D.rankAlphabetVector D.rankAlphabetWeight i r + +theorem finiteRankGenerators_span (i r : ℕ) : + Submodule.span ℚ (D.finiteRankGenerators i r : Set L) = D.filtration.rankLayer i r := by + classical + rw [D.filtration.rankLayer_eq_weighted_tree_span D.rankAlphabetVector D.rankAlphabetWeight + D.rankAlphabetWeight_pos D.rankAlphabetVector_mem D.rankAlphabet_spans_layer] + rw [weightedLieTreeSpan_eq_finite_span _ _ D.rankAlphabetWeight_pos] + have hleaf : Submodule.span ℚ + (((Finset.univ.filter (fun a : D.RankAlphabet => D.rankAlphabetWeight a = i + 1)).image + D.rankAlphabetVector : Finset L) : Set L) = D.filtration.layer (i + 1) := by + simpa only [Finset.coe_image, Finset.coe_filter, Finset.mem_univ, + true_and] using D.rankAlphabet_span_layer (i + 1) (Nat.succ_pos i) + change Submodule.span ℚ ((_ ∪ _ : Finset L) : Set L) = _ + rw [Finset.coe_union, Submodule.span_union, hleaf] + +theorem finiteRankGenerators_card_le (i r : ℕ) (hi : i ≤ s) : + (D.finiteRankGenerators i r).card ≤ + (s + 1) * d + ((s + 1) * d + 2) ^ (3 ^ s) := by + classical + have hleaf : ((Finset.univ.filter + (fun a : D.RankAlphabet => D.rankAlphabetWeight a = i + 1)).image D.rankAlphabetVector).card ≤ + Fintype.card D.RankAlphabet := by + exact Finset.card_image_le.trans ((Finset.card_filter_le _ _).trans_eq (Finset.card_univ)) + have htree := finiteWeightedLieValues_card_le D.rankAlphabetVector D.rankAlphabetWeight i r + have htree' : (finiteWeightedLieValues D.rankAlphabetVector D.rankAlphabetWeight i r).card ≤ + ((s + 1) * d + 2) ^ (3 ^ s) := by + apply htree.trans + apply (Nat.pow_le_pow_left (Nat.add_le_add_right D.rankAlphabet_card_le 2) _).trans + exact Nat.pow_le_pow_right (by omega) (Nat.pow_le_pow_right (by omega) hi) + exact (Finset.card_union_le _ _).trans + (Nat.add_le_add (hleaf.trans D.rankAlphabet_card_le) htree') + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +theorem finiteRankGenerators_height {H : ℕ} + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants D.basis i j k) H) + (hb : ∀ i j k, RationalHeightLE (D.basis.repr (D.layerBasis i j) k) H) + (i r : ℕ) (hi : i ≤ s) (x : L) (hx : x ∈ D.finiteRankGenerators i r) (k : Fin d) : + RationalHeightLE (D.basis.repr x k) (lieTreeHeight d H s) := by + classical + rcases Finset.mem_union.mp hx with h | h + · obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp h + exact (hb a.1 a.2 k).mono (lieTreeHeight_ge_input d H s) + · obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp h + have h := finiteLieTrees_coordinate_height D.basis D.rankAlphabetVector hc + (fun a j => hb a.1 a.2 j) i a (Finset.mem_filter.mp ha).1 k + simp only [Fintype.card_fin] at h + exact h.mono (lieTreeHeight_mono d H hi) + +theorem exists_rankLayer_basis_height {H : ℕ} + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants D.basis i j k) H) + (hb : ∀ i j k, RationalHeightLE (D.basis.repr (D.layerBasis i j) k) H) + (i r : ℕ) (hi : i ≤ s) : + ∃ b : Basis (Fin (finrank ℚ (D.filtration.rankLayer i r))) ℚ (D.filtration.rankLayer i r), + ∀ j k, RationalHeightLE (D.basis.repr (b j : L) k) (lieTreeHeight d H s) := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + have hex := Submodule.exists_fun_fin_finrank_span_eq ℚ (D.finiteRankGenerators i r : Set L) + rw [D.finiteRankGenerators_span] at hex + obtain ⟨v, hv, hvspan, hli⟩ := hex + refine ⟨(Basis.span hli).map (LinearEquiv.ofEq _ _ hvspan), ?_⟩ + intro j k + simp only [Basis.map_apply, LinearEquiv.coe_ofEq_apply, Basis.coe_span_apply] + exact D.finiteRankGenerators_height hc hb i r hi (v j) (hv j) k + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +theorem exists_canonical_rank_basis_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + (D : RationalFilteredNilmanifold L s d) {p : ℝ}, + 0 ≤ p → D.GeometryComplexityLE p → ∀ i r : ℕ, i ≤ s → + ∃ b : Basis (Fin (finrank ℚ (D.filtration.rankLayer i r))) ℚ (D.filtration.rankLayer i r), + (finrank ℚ (D.filtration.rankLayer i r) : ℝ) ≤ p ∧ + ∀ j k, rationalLogHeight (D.basis.repr (b j : L) k) ≤ (p + C) ^ C := by + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((Polynomial.X + 3 : Polynomial ℕ) ^ (6 * s + 2)) + refine ⟨C, hC, ?_⟩ + intro L _ _ d D p hp hD i r hi + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + have hcost : (p + 3) ^ (6 * s + 2) ≤ (p + C) ^ C := by + simpa [Polynomial.eval₂_pow] using hbudget p hp + have htree : (lieTreeHeight d ⌈Real.exp p⌉₊ s : ℝ) ≤ Real.exp ((p + 3) ^ (6 * s + 2)) := by + simpa only [add_assoc, show (1 : ℝ) + 2 = 3 by norm_num] using + lieTreeHeight_le_exp d ⌈Real.exp p⌉₊ s (p := p + 1) (by linarith) + (hD.1.trans (by linarith)) (ceil_exp_le_exp_add_one hp) + obtain ⟨b, hb⟩ := D.exists_rankLayer_basis_height + (fun a b c => rationalHeightLE_ceil_exp (hD.2.2.1 a b c)) + (fun a b c => rationalHeightLE_ceil_exp (hD.2.2.2 a b c)) i r hi + refine ⟨b, ?_, fun j k => rationalLogHeight_le_of_height (hb j k) + (htree.trans (Real.exp_le_exp.mpr hcost))⟩ + have hdim : finrank ℚ (D.filtration.rankLayer i r) ≤ d := by + simpa only [finrank_eq_card_basis D.basis, Fintype.card_fin] using + (D.filtration.rankLayer i r).finrank_le + exact (Nat.cast_le.mpr hdim).trans hD.1 + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeRankFamilyConstruction.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankFamilyConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d1e11d94e963f593bb03660abeebfa9f215bb87 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankFamilyConstruction.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Polynomial.DegreeRankNativeInverseModels + +namespace OAI + +section + +namespace Erdos3.NativeDegreeRankDerivativeData + +open scoped BigOperators + +attribute [local instance] NativeCommonDerivativeModels.lie NativeCommonDerivativeModels.algebra + NativeCommonDerivativeModels.topology NativeCommonDerivativeModels.topologicalAdd + NativeCommonDerivativeModels.continuousSMul NativeCommonDerivativeModels.hausdorff + +variable {s r N : ℕ} [NeZero N] {p q : ℝ} {f : ZMod N → ℂ} + {B : NativeCommonDerivativeModels s N p f} (W : NativeDegreeRankDerivativeData B r q) + +noncomputable def toFamily (hpq : p ≤ q) : NativeDegreeRankFamily s r (ZMod N) q where + L := B.L + dim := B.dim + model := B.model + rank := W.rank + complexity := W.complexity + orbit h := (B.test h).orbit + normalized := W.vertical.normalized + outputDim := W.unit.tailDim + 1 + output_pos := by omega + output_bound := by simpa only [Nat.cast_add, Nat.cast_one] using W.unit.dimension + vertical := { + observable := W.unit.observable + unit := W.unit.unit + norm := W.unit.norm + lipBound := W.unit.lipBound + lip_bound := W.unit.lip_bound + lipschitz := W.unit.lipschitz + frequency := W.vertical.frequency + height := fun i => (W.vertical.height i).trans hpq + vertical := W.rank_vertical + integral := W.rank_integral + } + +theorem toFamily_evalCyclic (hpq : p ≤ q) (i : Fin (W.unit.tailDim + 1)) (h x : ZMod N) : + (W.toFamily hpq).evalCyclic N i h x = (W.unit.test i h).evalCyclic N (fun _ => x) := rfl + +theorem toFamily_correlation (hpq : p ≤ q) (h : ZMod N) (hh : h ∈ B.shifts) : + Real.exp (-(p + 1)) ≤ + ‖𝔼 x, multiplicativeDerivative f h x * + star ((W.toFamily hpq).evalCyclic N (0 : Fin (W.unit.tailDim + 1)) h x)‖ := by + simp only [W.toFamily_evalCyclic] + exact W.unit.test_zero_correlation h hh + +end Erdos3.NativeDegreeRankDerivativeData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeRankIteration.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad1a765145f42fe42377ae89b87097959fce5a4f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankIteration.lean @@ -0,0 +1,182 @@ +import OAI.Combinatorics.Progressions.Estimates.MixedPairComparison + +namespace OAI + +section + +namespace Erdos3.NativeCorrelationStructure + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +variable {s N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + +noncomputable def absorbRankZero (W : NativeCorrelationStructure (s + 1) 0 N p f) (hp : 0 ≤ p) : + NativeMixedCorrelation (s + 1) N (productNiltestBudget (p + 4)) f := by + have hq : 0 ≤ p + 4 := by linarith + have hpq : p ≤ productNiltestBudget (p + 4) := + (show p ≤ p + 4 by linarith).trans (le_productNiltestBudget hq) + refine { + shifts := W.shifts + nonempty := W.nonempty + density := (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hpq)) + (Nat.cast_nonneg _)).trans W.density + mixed := W.mixed.mono hpq + correlation := ?_ + } + intro h hh + have hin : Nonempty (NativeVectorCorrelation s N p + (fun ij : Fin W.mixed.outputDim × Fin W.family.outputDim => fun x => + nativeMixedResidual f W.mixed h ij.1 x * + star ((W.family.lowerComponent ij.2 h).evalCyclic N (fun _ => x)))) := by + have hc := W.correlation h hh + change Nonempty (NativeVectorCorrelation s N p + (fun (ij : Fin W.mixed.outputDim × Fin W.family.outputDim) x => + multiplicativeDerivative f h x * star (W.mixed.evalCyclic N ij.1 (correlationInput h x)) * + star (W.family.evalCyclic N ij.2 h x))) at hc + simpa only [nativeMixedResidual, NativeDegreeRankFamily.lowerComponent_evalCyclic] using hc + obtain ⟨V⟩ := hin + exact NativeVectorCorrelation.exists_absorb + (W.family.model.dropTop W.family.rankZero_top_eq_bot) + (fun j => W.family.lowerComponent j h) (nativeMixedResidual f W.mixed h) + (by linarith : 2 ≤ p + 4) (fun j => W.family.lowerComponent_complexity hp j h) + (V.mono (by linarith)) + +theorem exists_absorbRankZero_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {s N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + ∀ f : ZMod N → ℂ, NativeCorrelationStructure (s + 1) 0 N p f → + Nonempty (NativeMixedCorrelation (s + 1) N ((p + C) ^ C) f) := by + obtain ⟨a, _, ha⟩ := exists_productNiltestBudget_bound + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C (4 + a)) ^ a) + refine ⟨C, hC, ?_⟩ + intro s N _ p hp f W + have hcost : (p + 4 + a) ^ a ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow, Nat.cast_add, add_assoc] using hbudget p hp + have hq : productNiltestBudget (p + 4) ≤ (p + C) ^ C := + (ha (p + 4) (by linarith)).trans hcost + exact ⟨(W.absorbRankZero hp).mono hq⟩ + +end Erdos3.NativeCorrelationStructure + +end + +section + +namespace Erdos3 + +theorem exists_native_rank_descent (s : ℕ) (hs : 2 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (_W : NativeCorrelationStructure s (r + 1) N p f), (∀ x, ‖f x‖ ≤ 1) → + Real.exp ((p + C) ^ C) ≤ (N : ℝ) → + Nonempty (NativeCorrelationStructure s r N ((p + C) ^ C) f) := by + obtain ⟨a, _, hproduct⟩ := exists_native_product_correlation s hs + obtain ⟨b, _, hvertical⟩ := exists_native_product_verticalization s + let X : Polynomial ℕ := Polynomial.X + let R : Polynomial ℕ := X + (X + Polynomial.C a) ^ a + 2 + let Q : Polynomial ℕ := (R + Polynomial.C b) ^ b + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (R + Q) + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf hN + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + let p₀ := (p + a) ^ a + let p₁ := p + p₀ + 2 + let p₂ := (p₁ + b) ^ b + have hp₀ : 0 ≤ p₀ := by dsimp [p₀]; positivity + have hp₁ : 0 ≤ p₁ := by dsimp [p₁]; positivity + have hp₂ : 0 ≤ p₂ := by dsimp [p₂]; positivity + have htotal : p₁ + p₂ ≤ (p + C) ^ C := by + simpa [X, R, Q, p₀, p₁, p₂, Polynomial.eval₂_pow] using hbudget p hp + have hpp₁ : p ≤ p₁ := by dsimp [p₁]; linarith + have hp₀p₁ : p₀ ≤ p₁ := by dsimp [p₁]; linarith + have hp₀C : p₀ ≤ (p + C) ^ C := by linarith + have hp₂C : p₂ ≤ (p + C) ^ C := by linarith + obtain ⟨J, _, hJ, hdense, hcorr⟩ := + hproduct W hf ((Real.exp_le_exp.mpr hp₀C).trans hN) + have hdense' : Real.exp (-p₁) * N ≤ (J.card : ℝ) := + (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hp₀p₁)) + (Nat.cast_nonneg _)).trans hdense + have hdim : (W.mixed.outputDim : ℝ) ≤ Real.exp p₁ := + W.mixed.output_bound.trans (Real.exp_le_exp.mpr hpp₁) + have hI : (Fintype.card (Fin W.family.outputDim) : ℝ) ≤ Real.exp p₁ := by + simpa only [Fintype.card_fin] using W.family.output_bound.trans (Real.exp_le_exp.mpr hpp₁) + obtain ⟨V⟩ := hvertical J W.mixed.outputDim hp₁ hf hJ hdense' hdim hI + (hcorr.mono hp₀p₁ hp₀p₁ hp₀p₁) + exact ⟨V.mono hp₂C⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_native_rank_zero_reduction (s : ℕ) (hs : 2 ≤ s) (r : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (_W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + Real.exp ((p + C) ^ C) ≤ (N : ℝ) → + Nonempty (NativeCorrelationStructure s 0 N ((p + C) ^ C) f) := by + induction r with + | zero => + refine ⟨2, le_rfl, ?_⟩ + intro N _ p f W _ _ + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + exact ⟨W.mono (by norm_num; nlinarith [sq_nonneg p])⟩ + | succ r ih => + obtain ⟨a, _, hstep⟩ := exists_native_rank_descent s hs + obtain ⟨b, _, hiterate⟩ := ih + let X : Polynomial ℕ := Polynomial.X + let Q : Polynomial ℕ := (X + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (Q + (Q + Polynomial.C b) ^ b) + refine ⟨C, hC, ?_⟩ + intro N _ p f W hf hN + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + let q := (p + a) ^ a + let q₂ := (q + b) ^ b + have hq : 0 ≤ q := by dsimp [q]; positivity + have hq₂ : 0 ≤ q₂ := by dsimp [q₂]; positivity + have htotal : q + q₂ ≤ (p + C) ^ C := by + simpa [X, Q, q, q₂, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := by linarith + have hq₂C : q₂ ≤ (p + C) ^ C := by linarith + obtain ⟨W₁⟩ := hstep W hf ((Real.exp_le_exp.mpr hqC).trans hN) + obtain ⟨W₀⟩ := hiterate W₁ hf ((Real.exp_le_exp.mpr hq₂C).trans hN) + exact ⟨W₀.mono hq₂C⟩ + +theorem exists_native_rank_elimination (s : ℕ) (hs : 2 ≤ s) (r : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (_W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + Real.exp ((p + C) ^ C) ≤ (N : ℝ) → + Nonempty (NativeMixedCorrelation s N ((p + C) ^ C) f) := by + obtain ⟨a, _, hzero⟩ := exists_native_rank_zero_reduction s hs r + obtain ⟨b, _, habsorb⟩ := NativeCorrelationStructure.exists_absorbRankZero_budget + let X : Polynomial ℕ := Polynomial.X + let Q : Polynomial ℕ := (X + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Q + (Q + Polynomial.C b) ^ b) + refine ⟨C, hC, ?_⟩ + intro N _ p f W hf hN + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + let q := (p + a) ^ a + let q₂ := (q + b) ^ b + have hq : 0 ≤ q := by dsimp [q]; positivity + have hq₂ : 0 ≤ q₂ := by dsimp [q₂]; positivity + have htotal : q + q₂ ≤ (p + C) ^ C := by + simpa [X, Q, q, q₂, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := by linarith + have hq₂C : q₂ ≤ (p + C) ^ C := by linarith + obtain ⟨W₀⟩ := hzero W hf ((Real.exp_le_exp.mpr hqC).trans hN) + cases s with + | zero => omega + | succ s => + obtain ⟨M⟩ := habsorb hq f W₀ + exact ⟨M.mono hq₂C⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeRankPairs.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankPairs.lean new file mode 100644 index 0000000000000000000000000000000000000000..77e9612fd244607c9efd0b410238589199392d72 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankPairs.lean @@ -0,0 +1,54 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeAbsorbedIntervals + +namespace OAI + +section + +namespace Erdos3 + +namespace NativeDegreeRankFamily + +variable {s r : ℕ} {G : Type*} [AddGroup G] {p : ℝ} (W : NativeDegreeRankFamily s r G p) + +noncomputable def shiftPair (i : Fin W.outputDim) (a h : G) (δ n : ℤ) : ℂ := + star (W.eval i h n) * W.eval i (h - a) (n + δ) + +theorem shiftPair_norm (i : Fin W.outputDim) (a h : G) (δ n : ℤ) : + ‖W.shiftPair i a h δ n‖ ≤ 1 := by + rw [shiftPair, norm_mul, norm_star] + exact (mul_le_of_le_one_left (norm_nonneg _) (W.norm_eval i h n)).trans + (W.norm_eval i (h - a) (n + δ)) + +theorem shiftPair_mul_star (i : Fin W.outputDim) (a h k : G) (δ n : ℤ) : + W.shiftPair i a h δ n * star (W.shiftPair i a k δ n) = + fourPointProduct (W.eval i h) (W.eval i (h - a)) + (W.eval i k) (W.eval i (k - a)) δ n := by + simp only [shiftPair, fourPointProduct, star_mul, star_star] + ring + +theorem quadruple_common_anchor (i : Fin W.outputDim) (a h k : G) (δ n : ℤ) (w v : ℂ) : + fourPointProduct (W.eval i h) (W.eval i (h - a)) + (W.eval i k) (W.eval i (k - a)) δ n * w * v = + (w * star (W.shiftPair i a k δ n)) * (W.shiftPair i a h δ n * v) := by + rw [← W.shiftPair_mul_star] + ring + +end NativeDegreeRankFamily + +namespace NativeMultilinearIntervalFamily + +theorem rankProduct_eq_shiftPairs {s r N : ℕ} [NeZero N] {p q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N p f} (B : NativeMultilinearIntervalFamily W q) + (t : B.quadruples) (n : ℤ) : + B.rankProduct t n = + W.family.shiftPair B.rankCoordinate t.val.1 t.val.2.1 (B.delta t) n * + star (W.family.shiftPair B.rankCoordinate t.val.1 t.val.2.2 (B.delta t) n) := + (W.family.shiftPair_mul_star B.rankCoordinate t.val.1 t.val.2.1 t.val.2.2 (B.delta t) n).symm + +end NativeMultilinearIntervalFamily + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeRankQuotientOrbit.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankQuotientOrbit.lean new file mode 100644 index 0000000000000000000000000000000000000000..709097d929139b96a9a67c141eecbb7dc54c1300 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankQuotientOrbit.lean @@ -0,0 +1,480 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformFrozenDescent + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + +noncomputable def basisOfTail (b : Basis (Fin d) ℚ L) (P : Submodule ℚ L) (c : ℕ) + (hP : P = basisTail b c) : Basis (Fin (finrank ℚ P)) ℚ P := by + classical + let a := supportedSubmoduleBasis b P {j | c ≤ j.val} (hP.trans (basisTail_eq_span b c)) + exact a.reindex (Fintype.equivFinOfCardEq (finrank_eq_card_basis a).symm) + +theorem basisOfTail_height (b : Basis (Fin d) ℚ L) (P : Submodule ℚ L) (c : ℕ) + (hP : P = basisTail b c) (i : Fin (finrank ℚ P)) (j : Fin d) : + RationalHeightLE (b.repr (basisOfTail b P c hP i : L) j) 1 := by + classical + unfold basisOfTail + rw [Basis.reindex_apply, supportedSubmoduleBasis_coe] + exact basis_repr_height_one b _ j + +theorem tail_span_basis_members (b : Basis (Fin d) ℚ L) (P : Submodule ℚ L) (c : ℕ) + (hP : P = basisTail b c) : P = Submodule.span ℚ (b '' {j | b j ∈ P}) := by + apply le_antisymm + · conv_lhs => rw [hP, basisTail_eq_span] + apply Submodule.span_mono + rintro x ⟨j, hj, rfl⟩ + exact ⟨j, hP.symm ▸ basis_mem_tail b j hj, rfl⟩ + · exact Submodule.span_le.mpr (by rintro _ ⟨j, hj, rfl⟩; exact hj) + +theorem NilpotentLieFiltration.exists_weights_of_tails {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis (Fin d) ℚ L) + (htail : ∀ i, ∃ c, F.layer i = basisTail b c) : + ∃ w : Fin d → ℕ, ∀ i, F.layer i = Submodule.span ℚ (b '' {j | i ≤ w j}) := by + let S : Fin (s + 1) → Set (Fin d) := fun i => {j | b j ∈ F.layer (i.val + 1)} + have hS : Antitone S := fun _ _ h _ hx => F.antitone (Nat.add_le_add_right h 1) hx + let w := nestedSupportWeight S + refine ⟨w, F.layer_eq_span_of_weighted_flag b w (fun j => nestedSupportWeight_le S j) ?_⟩ + intro i + obtain ⟨c, hc⟩ := htail (i.val + 1) + rw [tail_span_basis_members b _ c hc] + apply congrArg (Submodule.span ℚ) + apply congrArg (fun A : Set (Fin d) => b '' A) + ext j + exact mem_nestedSupport_iff S hS i j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration + +theorem exists_coordinate_quotient_layer_basis + {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype ι] + (b : Basis ι ℚ L) (I : LieIdeal ℚ L) (S : Set ι) [DecidablePred (· ∈ S)] + (hI : I.toSubmodule = Submodule.span ℚ (b '' S)) + (P : Submodule ℚ L) (T : Set ι) (hP : P = Submodule.span ℚ (b '' T)) : + ∃ a : Basis (Fin (finrank ℚ (P.map (lieQuotientMap I).toLinearMap))) ℚ + (P.map (lieQuotientMap I).toLinearMap), + ∀ i j, rationalLogHeight ((quotientFinBasis b I S hI).repr (a i : L ⧸ I) j) ≤ 0 := by + classical + let q := supportedQuotientBasis b I.toSubmodule S hI + have hspan : P.map (lieQuotientMap I).toLinearMap = + Submodule.span ℚ (q '' {i : {i // i ∉ S} | i.val ∈ T}) := by + rw [hP] + exact supportedQuotientBasis_map_span b I.toSubmodule S hI T + let a := supportedSubmoduleBasis q (P.map (lieQuotientMap I).toLinearMap) + {i : {i // i ∉ S} | i.val ∈ T} hspan + let e := Fintype.equivFinOfCardEq (finrank_eq_card_basis a).symm + refine ⟨a.reindex e, ?_⟩ + intro i j + rw [Basis.reindex_apply, supportedSubmoduleBasis_coe, + quotientFinBasis, Basis.repr_reindex_apply] + change rationalLogHeight (q.repr (q (e.symm i).val) + ((Fintype.equivFin {i // i ∉ S}).symm j)) ≤ 0 + rw [Basis.repr_self, Finsupp.single_apply] + split_ifs <;> norm_num [rationalLogHeight] + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L ι κ : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem adaptedSquareBasis_projection_height (e : Basis ι ℚ L) (b : Basis κ ℚ L) (w : κ → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) + {H : ℕ} (hH : 1 ≤ H) (hb : ∀ i j, RationalHeightLE (e.repr (b j) i) H) + (i : κ ⊕ {i // 2 ≤ w i}) (k : ι) : + RationalHeightLE (e.repr (F.squareFst (F.adaptedSquareBasis b w h i)) k) H ∧ + RationalHeightLE (e.repr (F.squareSnd (F.adaptedSquareBasis b w h i)) k) H := by + cases i with + | inl i => + simpa only [squareFst_apply, squareSnd_apply, adaptedSquareBasis_inl] using + And.intro (hb k i) (hb k i) + | inr i => + constructor + · simpa only [squareFst_apply, adaptedSquareBasis_inr] using hb k i + · simp only [squareSnd_apply, adaptedSquareBasis_inr, map_zero, Finsupp.zero_apply] + exact rationalHeightLE_zero hH + +variable [Fintype κ] + +theorem squareFinBasis_projection_height (e : Basis ι ℚ L) (b : Basis κ ℚ L) (w : κ → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) + {H : ℕ} (hH : 1 ≤ H) (hb : ∀ i j, RationalHeightLE (e.repr (b j) i) H) + (i : Fin (Fintype.card (κ ⊕ {i // 2 ≤ w i}))) (k : ι) : + RationalHeightLE (e.repr (F.squareFst (F.squareFinBasis b w h i)) k) H ∧ + RationalHeightLE (e.repr (F.squareSnd (F.squareFinBasis b w h i)) k) H := by + simp only [squareFinBasis, Basis.reindex_apply] + exact F.adaptedSquareBasis_projection_height e b w h hH hb _ k + +theorem quotientFinBasis_projection_height (b : Basis κ ℚ L) (I : LieIdeal ℚ L) + (S : Set κ) [DecidablePred (· ∈ S)] + (hspan : I.toSubmodule = Submodule.span ℚ (b '' S)) + (i : κ) (j : Fin (Fintype.card {i // i ∉ S})) : + RationalHeightLE ((quotientFinBasis b I S hspan).repr (lieQuotientMap I (b i)) j) 1 := by + rw [quotientFinBasis, Basis.repr_reindex_apply] + exact supportedQuotientBasis_projection_height b I S hspan i _ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d r : ℕ} + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure r) + +theorem rankFlag_span_height {H : ℕ} + (hR : ∀ i j a k, RationalHeightLE (D.basis.repr (R.basis i j a : L) k) H) + (n : Fin ((s + 1) * (s + 1) + 1)) : + Submodule.span ℚ ({x : L | ∀ k, RationalHeightLE (D.basis.repr x k) H} ∩ + (R.filtration.rankFlag n.val : Set L)) = R.filtration.rankFlag n.val := by + by_cases hn : n.val < (s + 1) * (s + 1) + · obtain ⟨hi, hj⟩ := DegreeRankLieFiltration.rankFlag_decode_lt hn + let i : Fin (s + 1) := ⟨n.val / (s + 1), by omega⟩ + let j : Fin (s + 1) := ⟨n.val % (s + 1), by omega⟩ + exact span_inter_eq_of_spanning_family _ (R.basis i j) (R.basis i j).span_eq _ + (fun a => hR i j a) + · have heq : n.val = (s + 1) * (s + 1) := by omega + rw [heq, R.filtration.rankFlag_terminal] + exact le_antisymm (Submodule.span_le.mpr (fun _ hx => hx.2)) bot_le + +theorem exists_bounded_rank_adapted_basis {H : ℕ} + (hR : ∀ i j a k, RationalHeightLE (D.basis.repr (R.basis i j a : L) k) H) : + ∃ b : Basis (Fin (finrank ℚ L)) ℚ L, + IsCentralLieBasis b ∧ (∀ a k, RationalHeightLE (D.basis.repr (b a) k) H) ∧ + ∀ i j, ∃ c ≤ finrank ℚ L, R.filtration.layer i j = basisTail b c := by + let := D.basis.finiteDimensional_of_finite + let N := (s + 1) * (s + 1) + let S : Set L := {x | ∀ k, RationalHeightLE (D.basis.repr x k) H} + let P : Fin (N + 1) → Submodule ℚ L := fun n => R.filtration.rankFlag n.val + have hP : Antitone P := fun _ _ h => R.filtration.rankFlag_antitone h + have hspan : ∀ n, Submodule.span ℚ (S ∩ (P n : Set L)) = P n := R.rankFlag_span_height hR + have hS : Submodule.span ℚ S = ⊤ := by + apply top_unique + calc + ⊤ = P 0 := R.filtration.rankFlag_zero.symm + _ = Submodule.span ℚ (S ∩ (P 0 : Set L)) := (hspan 0).symm + _ ≤ Submodule.span ℚ S := Submodule.span_mono Set.inter_subset_left + obtain ⟨b, w, hw, _, hb, hflag⟩ := exists_sorted_flag_basis_from_spanning_set P hP S hS hspan + have hcentral : IsCentralLieBasis b := centralLieBasis_of_finite_flag R.filtration.rankFlag b w + R.filtration.rankFlag_zero R.filtration.rankFlag_terminal + (fun _ {_ _} hy => R.filtration.rankFlag_lie_mem hy) hw hflag + refine ⟨b, hcentral, hb, ?_⟩ + intro i j + obtain ⟨k, hk⟩ := R.filtration.layer_eq_rankFlag i j + exact ⟨weightCut w k.val, weightCut_le w k.val, + hk.trans ((hflag k).trans (span_weight_gt_eq_basisTail b w hw k.val))⟩ + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d r : ℕ} + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure r) + +theorem exists_controlled_rank_adapted_basis {p : ℝ} (hp : 0 ≤ p) (hR : R.ComplexityLE p) : + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (N : ℕ), + IsCentralLieBasis b ∧ + (∀ i j, ∃ c ≤ finrank ℚ L, R.filtration.layer i j = basisTail b c) ∧ + (∀ j i, rationalLogHeight (D.basis.repr (b j) i) ≤ p + 1) ∧ + (∀ i j, rationalLogHeight (b.repr (D.basis i) j) ≤ (p + 3) ^ 5) ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ (p + 3) ^ 11) ∧ + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 3) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b D.lattice ∧ + bchSubgroupCoordinates b D.lattice ⊆ denominatorGrid N := by + let := D.basis.finiteDimensional_of_finite + let H := ⌈Real.exp p⌉₊ + have hH : 1 ≤ H := one_le_ceil_exp p + have hHp : (H : ℝ) ≤ Real.exp (p + 1) := ceil_exp_le_exp_add_one hp + have hp1 : 0 ≤ p + 1 := by linarith + have hd : (d : ℝ) ≤ p + 1 := hR.1.1.trans (by linarith) + have hr : (finrank ℚ L : ℝ) ≤ p + 1 := by + simpa only [finrank_eq_card_basis D.basis, Fintype.card_fin] using hd + have hgrid : (D.grid : ℝ) ≤ Real.exp (p + 1) := + hR.1.2.1.trans (Real.exp_le_exp.mpr (by linarith)) + obtain ⟨b, hcentral, hb, htail⟩ := R.exists_bounded_rank_adapted_basis + (fun i j a k => rationalHeightLE_ceil_exp (hR.2 i j a k)) + obtain ⟨N, hN, hNb, hin, hout⟩ := exists_basis_change_grid_exp_bound D.basis b D.lattice + hH D.grid_pos hb D.inner_grid D.outer_grid hp1 + (by simpa only [Fintype.card_fin] using hd) + (by simpa only [Fintype.card_fin] using hr) hHp hgrid + have hInv := inverse_basis_entries_height D.basis b hH hb + have hStructure := basis_change_structure_height D.basis b hH hb + (fun i j k => rationalHeightLE_ceil_exp (hR.1.2.2.1 i j k)) + have hSolveBudget := rationalSolveHeight_le_budget (finrank ℚ L) H hp1 hr hHp + have hStructureBudget := rationalLieStructureHeight_inverse_budget d (finrank ℚ L) H hp1 hd hr hHp + have hshift : p + 1 + 2 = p + 3 := by ring + refine ⟨b, N, hcentral, htail, ?_, ?_, ?_, hN, ?_, hin, hout⟩ + · exact fun j i => rationalLogHeight_le_of_height (hb j i) hHp + · intro i j + apply rationalLogHeight_le_of_height (hInv i j) + simpa only [Fintype.card_fin, hshift] using hSolveBudget + · intro i j k + apply rationalLogHeight_le_of_height (hStructure i j k) + simpa only [Fintype.card_fin, hshift] using hStructureBudget + · simpa only [hshift] using hNb + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d r : ℕ} + {D : RationalFilteredNilmanifold L s d} + +structure AdaptedData (R : D.DegreeRankStructure r) extends D.AdaptedModelData where + central : IsCentralLieBasis basis + rank_layers : ∀ i j, ∃ c ≤ finrank ℚ L, R.filtration.layer i j = basisTail basis c + +namespace AdaptedData + +variable {R : D.DegreeRankStructure r} (F : R.AdaptedData) + +noncomputable def model : RationalFilteredNilmanifold L s (finrank ℚ L) := F.toAdaptedModelData.model + +noncomputable def rank : F.model.DegreeRankStructure r where + filtration := R.filtration + associated := R.associated + basis i j := basisOfTail F.basis _ (Classical.choose (F.rank_layers i.val j.val)) + (Classical.choose_spec (F.rank_layers i.val j.val)).2 + +theorem rank_filtration : F.rank.filtration = R.filtration := rfl + +theorem rank_realSubgroup (i j : ℕ) : F.rank.realSubgroup i j = R.realSubgroup i j := rfl + +theorem model_geometry_of_bounds {p : ℝ} (hp : 0 ≤ p) (hd : (finrank ℚ L : ℝ) ≤ p) + (hgrid : (F.grid : ℝ) ≤ Real.exp p) + (hc : ∀ i j k, rationalLogHeight (lieStructureConstants F.basis i j k) ≤ p) : + F.model.GeometryComplexityLE p := + D.filtration.ofAdaptedBasis_geometry F.basis F.weight F.layers D.lattice F.grid F.grid_pos + F.inner F.outer hp hd hgrid hc + +theorem rank_complexity {p : ℝ} (hp : 0 ≤ p) (hF : F.model.GeometryComplexityLE p) : + F.rank.ComplexityLE p := by + refine ⟨hF, ?_⟩ + intro i j a k + apply rationalLogHeight_le_of_height + (basisOfTail_height F.basis _ (Classical.choose (F.rank_layers i.val j.val)) + (Classical.choose_spec (F.rank_layers i.val j.val)).2 a k) + simpa only [Nat.cast_one] using Real.one_le_exp hp + +end AdaptedData + +theorem exists_rank_adapted_data (R : D.DegreeRankStructure r) {p : ℝ} + (hp : 0 ≤ p) (hR : R.ComplexityLE p) : + ∃ F : R.AdaptedData, F.rank.ComplexityLE ((p + 3) ^ 11) ∧ + (∀ i j, rationalLogHeight (D.basis.repr (F.basis i) j) ≤ p + 1) ∧ + ∀ j i, rationalLogHeight (F.basis.repr (D.basis j) i) ≤ (p + 3) ^ 5 := by + obtain ⟨b, N, hcentral, htail, hb, hinv, hc, hN, hNb, hin, hout⟩ := + R.exists_controlled_rank_adapted_basis hp hR + have hOrd : ∀ i, ∃ c, D.filtration.layer i = basisTail b c := by + intro i + obtain ⟨c, _, h⟩ := htail i 0 + refine ⟨c, ?_⟩ + rw [← R.associated] + exact h + obtain ⟨w, hw⟩ := D.filtration.exists_weights_of_tails b hOrd + let F : R.AdaptedData := { + basis := b + weight := w + layers := hw + grid := N + grid_pos := hN + inner := hin + outer := hout + central := hcentral + rank_layers := htail + } + have hp1 : 1 ≤ p + 3 := by linarith + have hpow : p ≤ (p + 3) ^ 11 := by + calc + p ≤ p + 3 := by linarith + _ = (p + 3) ^ 1 := (pow_one _).symm + _ ≤ (p + 3) ^ 11 := pow_le_pow_right₀ hp1 (by decide) + have hdim : (finrank ℚ L : ℝ) ≤ (p + 3) ^ 11 := by + simpa only [finrank_eq_card_basis D.basis, Fintype.card_fin] using hR.1.1.trans hpow + have hgeom : F.model.GeometryComplexityLE ((p + 3) ^ 11) := + F.model_geometry_of_bounds (by positivity) hdim + (hNb.trans (Real.exp_le_exp.mpr (pow_le_pow_right₀ hp1 (by decide : 9 ≤ 11)))) hc + exact ⟨F, F.rank_complexity (by positivity) hgeom, hb, hinv⟩ + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3 + +namespace RationalFilteredNilmanifold.DegreeRankStructure.AdaptedData + +open Module NilpotentLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r d : ℕ} + {D : RationalFilteredNilmanifold L s d} {R : D.DegreeRankStructure (r + 1)} + (F : R.AdaptedData) + +theorem exists_lower_rank_quotient {p : ℝ} (hp : 0 ≤ p) (hF : F.model.GeometryComplexityLE p) : + let I := R.filtration.layerIdeal s (r + 1) + let hI : D.filtration.layer (s + 1) ≤ I.toSubmodule := by rw [D.filtration.terminal]; exact bot_le + ∃ n : ℕ, n ≤ finrank ℚ L ∧ + ∃ Q : RationalFilteredNilmanifold (L ⧸ I) s n, + ∃ U : Q.DegreeRankStructure r, + U.filtration = R.filtration.quotientRank r (Nat.le_of_succ_le R.filtration.rank_le_degree) ∧ + Q.filtration = D.filtration.quotientLie I hI ∧ + Q.lattice = D.lattice.map (D.filtration.quotientStepHom I hI) ∧ + U.ComplexityLE p ∧ + (∀ i j, rationalLogHeight (Q.basis.repr (lieQuotientMap I (F.basis i)) j) ≤ 0) ∧ + ∀ j, ∃ k, ∀ x : L, Q.basis.repr (lieQuotientMap I x) j = F.basis.repr x k := by + intro I hI + classical + let S : Set (Fin (finrank ℚ L)) := {i | F.basis i ∈ I} + have hspan : I.toSubmodule = Submodule.span ℚ (F.basis '' S) := by + obtain ⟨c, _, hc⟩ := F.rank_layers s (r + 1) + exact tail_span_basis_members F.basis _ c hc + let Q := D.filtration.coordinateQuotientModel F.basis F.weight F.layers I hI S hspan + D.lattice F.grid F.grid_pos F.inner F.outer + let G := R.filtration.quotientRank r (Nat.le_of_succ_le R.filtration.rank_le_degree) + have hG : G.associatedDegree = Q.filtration := by + apply NilpotentLieFiltration.eq_of_layer_eq + funext j + change (R.filtration.layer j 0).map (lieQuotientMap I).toLinearMap = + (D.filtration.layer j).map (lieQuotientMap I).toLinearMap + exact congrArg (fun P : Submodule ℚ L => P.map (lieQuotientMap I).toLinearMap) + (congrArg (fun H : NilpotentLieFiltration L s => H.layer j) R.associated) + have hbase (i j : Fin (s + 1)) : + ∃ b : Basis (Fin (finrank ℚ (G.layer i.val j.val))) ℚ (G.layer i.val j.val), + ∀ a k, rationalLogHeight (Q.basis.repr (b a : L ⧸ I) k) ≤ 0 := by + obtain ⟨c, _, hc⟩ := F.rank_layers i.val j.val + exact exists_coordinate_quotient_layer_basis F.basis I S hspan (R.filtration.layer i.val j.val) + {k | c ≤ k.val} (hc.trans (basisTail_eq_span F.basis c)) + choose b hb using hbase + let U : Q.DegreeRankStructure r := ⟨G, hG, b⟩ + have hQ : Q.GeometryComplexityLE p := + D.filtration.coordinateQuotientModel_geometry F.basis F.weight F.layers I hI S hspan + D.lattice F.grid F.grid_pos F.inner F.outer hp + (by simpa only [Fintype.card_fin] using hF.1) hF.2.1 hF.2.2.1 + refine ⟨_, ?_, Q, U, rfl, rfl, rfl, ⟨hQ, ?_⟩, ?_, ?_⟩ + · simpa only [Fintype.card_fin] using Fintype.card_subtype_le (fun i : Fin (finrank ℚ L) => i ∉ S) + · intro i j a k + exact (hb i j a k).trans hp + · intro i j + exact rationalLogHeight_le_of_height + (quotientFinBasis_projection_height F.basis I S hspan i j) (by norm_num) + + · intro j + exact ⟨((Fintype.equivFin {i // i ∉ S}).symm j).val, + fun x => quotientFinBasis_repr_mk F.basis I S hspan x j⟩ + +end RationalFilteredNilmanifold.DegreeRankStructure.AdaptedData +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module NilpotentLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r d : ℕ} + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure (r + 1)) + +theorem terminal_le_topRankIdeal : + D.filtration.layer (s + 1) ≤ (R.filtration.layerIdeal s (r + 1)).toSubmodule := by + rw [D.filtration.terminal] + exact bot_le + +theorem exists_controlled_lower_rank_quotient {p : ℝ} (hp : 0 ≤ p) (hR : R.ComplexityLE p) : + let I := R.filtration.layerIdeal s (r + 1) + ∃ n : ℕ, n ≤ d ∧ + ∃ Q : RationalFilteredNilmanifold (L ⧸ I) s n, + ∃ U : Q.DegreeRankStructure r, + U.filtration = R.filtration.quotientRank r (Nat.le_of_succ_le R.filtration.rank_le_degree) ∧ + Q.filtration = D.filtration.quotientLie I R.terminal_le_topRankIdeal ∧ + Q.lattice = D.lattice.map (D.filtration.quotientStepHom I R.terminal_le_topRankIdeal) ∧ + U.ComplexityLE ((p + 3) ^ 11) ∧ + ∀ i j, rationalLogHeight (Q.basis.repr (lieQuotientMap I (D.basis i)) j) ≤ (p + 3) ^ 5 := by + intro I + obtain ⟨F, hF, _, hinv⟩ := R.exists_rank_adapted_data hp hR + obtain ⟨n, hn, Q, U, hU, hQF, hQL, hUc, _, hcoord⟩ := + F.exists_lower_rank_quotient (by positivity : 0 ≤ (p + 3) ^ 11) hF.1 + have hdim : finrank ℚ L = d := by + simpa only [Fintype.card_fin] using finrank_eq_card_basis D.basis + refine ⟨n, hdim ▸ hn, Q, U, hU, hQF, hQL, hUc, ?_⟩ + intro i j + obtain ⟨k, hk⟩ := hcoord j + rw [hk] + exact hinv i k + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct + +variable {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] {s r d n : ℕ} + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure (r + 1)) + (Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n) + (hQ : Q.filtration = D.filtration.quotientLie + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal) {w : σ → ℕ} + +noncomputable def rankQuotientOrbit (g : D.filtration.realification.PolynomialOrbit w) : + Q.filtration.realification.PolynomialOrbit w := + let q := D.filtration.realQuotientPolynomialOrbit + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal g + NilpotentLieFiltration.polynomialOrbitOfLog q.log (by rw [hQ]; exact q.adapted) + +theorem rankQuotientOrbit_eval (g : D.filtration.realification.PolynomialOrbit w) (x : σ → ℤ) : + Q.filtration.realification.polynomialOrbitEval w x (R.rankQuotientOrbit Q hQ g) = + realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) + (lieQuotientMap (R.filtration.layerIdeal s (r + 1))) + (D.filtration.realification.polynomialOrbitEval w x g) := + D.filtration.realQuotientPolynomialOrbit_eval + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal g x + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeRankRelationExistence.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankRelationExistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e0ea609cf4b7c77e429d8efd64ff0f92911532b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeRankRelationExistence.lean @@ -0,0 +1,591 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteTripleAssembly +import OAI.Combinatorics.Progressions.Estimates.NativeIntervalWeightPairs +import OAI.Combinatorics.Progressions.Linear.RankRelationBudget + +namespace OAI + +section + +namespace Erdos3 + +theorem rank_pair_density_loss (p : ℝ) : + Real.exp (-(11 * p + 7)) ≤ Real.exp (-p) / 4 * + (Real.exp (-(8 * p + 1)) * (Real.exp (-p) / 4) ^ 2) := by + have he : Real.exp (-(8 * p + 1)) * Real.exp (-p) ^ 3 = Real.exp (-(11 * p + 1)) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + have hright : Real.exp (-p) / 4 * + (Real.exp (-(8 * p + 1)) * (Real.exp (-p) / 4) ^ 2) = Real.exp (-(11 * p + 1)) / 64 := by + calc + _ = (Real.exp (-(8 * p + 1)) * Real.exp (-p) ^ 3) / 64 := by ring + _ = _ := by rw [he] + rw [hright] + apply (le_div_iff₀ (by norm_num : (0 : ℝ) < 64)).mpr + have h64 := two_pow_le_exp_of_le 6 le_rfl + norm_num at h64 + calc + _ ≤ Real.exp (-(11 * p + 7)) * Real.exp 6 := + mul_le_mul_of_nonneg_left h64 (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +structure NativeWeightedRankIntervals {s r N : ℕ} [NeZero N] {b : ℝ} + (W : NativeDegreeRankFamily s r (ZMod N) b) (out : Fin W.outputDim) + (H : Finset (ZMod N)) (p : ℝ) where + budget_two : 2 ≤ p + count : ℕ + count_pos : 0 < count + index : Fin count → ZMod N × ZMod N × ZMod N + index_injective : Function.Injective index + density : Real.exp (-p) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ count + first_mem : ∀ i, (index i).2.1 ∈ H + second_mem : ∀ i, (index i).2.1 - (index i).1 ∈ H + third_mem : ∀ i, (index i).2.2 ∈ H + fourth_mem : ∀ i, (index i).2.2 - (index i).1 ∈ H + integer_relation : ∀ i, + -((index i).2.1.val : ℤ) + ((index i).2.1 - (index i).1).val + + (index i).2.2.val - ((index i).2.2 - (index i).1).val = 0 + branch : Fin count → Bool + start : Fin count → ℕ + length : Fin count → ℕ + length_pos : ∀ i, 0 < length i + endpoint_le : ∀ i, start i + length i ≤ N + length_short : ∀ i, 2 * ((length i : ℤ) - 1) < N + length_ratio : ∀ i, Real.exp (-p) ≤ (length i : ℝ) / N + weight : ℤ → ℂ + weight_norm : ∀ n, ‖weight n‖ ≤ 1 + lower : Fin count → ℤ → ℂ + expansion : ∀ i, NativeIntegerExpansion (fun _ : Unit => 1) (s - 1) p (fun x => lower i (x ())) + correlation : ∀ i, Real.exp (-p) ≤ ‖𝔼 n ∈ Finset.Ico (start i : ℤ) (start i + length i), + fourPointProduct (W.eval out (index i).2.1) (W.eval out ((index i).2.1 - (index i).1)) + (W.eval out (index i).2.2) (W.eval out ((index i).2.2 - (index i).1)) + (cyclicBranchOffset (index i).1 (branch i)) n * weight n * lower i n‖ + +end Erdos3 + +end + +section + +namespace Erdos3 + +structure NativeAnchoredRankFibers {s r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} (F : NativeWeightedRankIntervals W out H p) where + anchor : ZMod N + branch : Bool + selected : Finset (Fin F.count) + parameters : Finset (ZMod N) + parameters_nonempty : parameters.Nonempty + parameters_density : Real.exp (-p) / 4 * (Fintype.card (ZMod N) : ℝ) ≤ parameters.card + anchor_eq : ∀ i ∈ selected, (F.index i).2.2 = anchor + branch_eq : ∀ i ∈ selected, F.branch i = branch + pair_injective : Set.InjOn (fun i => ((F.index i).1, (F.index i).2.1)) (selected : Set (Fin F.count)) + fiber_density : ∀ a ∈ parameters, Real.exp (-p) / 4 * (Fintype.card (ZMod N) : ℝ) ≤ + ((selected.filter (fun i => (F.index i).1 = a)).card : ℝ) + +namespace NativeWeightedRankIntervals + +theorem exists_anchored_fibers {s r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} (F : NativeWeightedRankIntervals W out H p) : + Nonempty (NativeAnchoredRankFibers F) := by + have hindex : Function.Injective (fun i => ((F.index i).1, (F.index i).2.1, (F.index i).2.2)) := + F.index_injective + have hsize : Real.exp (-p) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ Fintype.card (Fin F.count) := by + simpa only [Fintype.card_fin] using F.density + obtain ⟨anchor, branch, T, A, hA, hAsize, hT, hinj, hfiber⟩ := exists_dense_anchored_fibers + (fun i => (F.index i).1) (fun i => (F.index i).2.1) (fun i => (F.index i).2.2) + F.branch hindex (Real.exp_pos (-p)) hsize + exact ⟨{ + anchor := anchor + branch := branch + selected := T + parameters := A + parameters_nonempty := hA + parameters_density := hAsize + anchor_eq := fun i hi => (hT i hi).1 + branch_eq := fun i hi => (hT i hi).2 + pair_injective := hinj + fiber_density := hfiber }⟩ + +end NativeWeightedRankIntervals + +namespace NativeAnchoredRankFibers + +variable {s r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} {H : Finset (ZMod N)} + {F : NativeWeightedRankIntervals W out H p} (A : NativeAnchoredRankFibers F) + +noncomputable def fiber (a : ZMod N) : Finset (Fin F.count) := + A.selected.filter (fun i => (F.index i).1 = a) + +theorem fiber_nonempty (a : ZMod N) (ha : a ∈ A.parameters) : (A.fiber a).Nonempty := by + have hN : (0 : ℝ) < Fintype.card (ZMod N) := by exact_mod_cast Fintype.card_pos + have hpos : (0 : ℝ) < (A.fiber a).card := + lt_of_lt_of_le (by positivity) (A.fiber_density a ha) + exact Finset.card_pos.mp (by exact_mod_cast hpos) + +theorem fiber_parameter (a : ZMod N) (i : A.fiber a) : (F.index i.val).1 = a := + (Finset.mem_filter.mp i.property).2 + +theorem fiber_anchor (a : ZMod N) (i : A.fiber a) : (F.index i.val).2.2 = A.anchor := + A.anchor_eq i.val (Finset.mem_filter.mp i.property).1 + +theorem fiber_branch (a : ZMod N) (i : A.fiber a) : F.branch i.val = A.branch := + A.branch_eq i.val (Finset.mem_filter.mp i.property).1 + +theorem fiber_shift_injective (a : ZMod N) : + Function.Injective (fun i : A.fiber a => (F.index i.val).2.1) := by + intro i j hij + apply Subtype.ext + apply A.pair_injective (Finset.mem_filter.mp i.property).1 (Finset.mem_filter.mp j.property).1 + exact Prod.ext ((A.fiber_parameter a i).trans (A.fiber_parameter a j).symm) hij + +end NativeAnchoredRankFibers + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +structure NativeRankInterval {s r N : ℕ} [NeZero N] {b : ℝ} + (W : NativeDegreeRankFamily s r (ZMod N) b) (out : Fin W.outputDim) + (H : Finset (ZMod N)) (t : ZMod N × ZMod N × ZMod N) + (branch : Bool) (p q : ℝ) where + first_mem : t.2.1 ∈ H + second_mem : t.2.1 - t.1 ∈ H + third_mem : t.2.2 ∈ H + fourth_mem : t.2.2 - t.1 ∈ H + integer_relation : + -(t.2.1.val : ℤ) + (t.2.1 - t.1).val + t.2.2.val - (t.2.2 - t.1).val = 0 + start : ℕ + length : ℕ + length_pos : 0 < length + endpoint_le : start + length ≤ N + length_short : 2 * ((length : ℤ) - 1) < N + length_ratio : Real.exp (-p) ≤ (length : ℝ) / N + lower : ℤ → ℂ + expansion : NativeIntegerExpansion (fun _ : Unit => 1) (s - 1) q (fun x => lower (x ())) + correlation : Real.exp (-p) ≤ ‖𝔼 n ∈ Finset.Ico (start : ℤ) (start + length), + fourPointProduct (W.eval out t.2.1) (W.eval out (t.2.1 - t.1)) + (W.eval out t.2.2) (W.eval out (t.2.2 - t.1)) + (cyclicBranchOffset t.1 branch) n * lower n‖ + +namespace NativeRankInterval + +noncomputable def mono {s r N : ℕ} [NeZero N] {b p q p' q' : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (hp : p ≤ p') (hq : q ≤ q') : + NativeRankInterval W out H t branch p' q' := + { I with + length_ratio := (Real.exp_le_exp.mpr (neg_le_neg hp)).trans I.length_ratio + expansion := I.expansion.mono hq + correlation := (Real.exp_le_exp.mpr (neg_le_neg hp)).trans I.correlation } + +end NativeRankInterval + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_native_weighted_rank_intervals (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p q P K : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N p f} {B : NativeMultilinearIntervalFamily W q} + {D : NativeMixedReductionData B.mixed P} (_R : NativeReducedIntervalFamily B D K), + Nonempty (NativeWeightedRankIntervals W.family B.rankCoordinate B.shifts + (K + (K + C) ^ C + 2)) := by + obtain ⟨C, hC, hexists⟩ := exists_absorbed_interval_family s + refine ⟨C, hC, ?_⟩ + intro r N _ p q P K f W B D R + have hq : 0 ≤ q := (Nat.cast_nonneg B.mixed.dim).trans B.mixed.complexity.1.1 + have hK : 0 ≤ K := hq.trans R.base_budget + have hpow : 0 ≤ (K + C) ^ C := by positivity + have hKP : K ≤ K + (K + C) ^ C + 2 := by linarith only [hpow] + have hPP : (K + C) ^ C ≤ K + (K + C) ^ C + 2 := by linarith only [hK] + obtain ⟨weight, Q, hw, hQ, hsize, hcor⟩ := hexists R + classical + obtain ⟨t₀, ht₀⟩ := hQ + let : Nonempty Q := ⟨⟨t₀, ht₀⟩⟩ + have hdata (t : Q) := hcor t.val t.property + choose v hE hv using hdata + let e := (Fintype.equivFin Q).symm + let old (i : Fin (Fintype.card Q)) : B.quadruples := (e i).val.val + refine ⟨{ + budget_two := by linarith only [hK, hpow] + count := Fintype.card Q + count_pos := Fintype.card_pos + index := fun i => (old i).val + index_injective := ?_ + density := ?_ + first_mem := fun i => (B.interval (old i)).first_mem + second_mem := fun i => (B.interval (old i)).second_mem + third_mem := fun i => (B.interval (old i)).third_mem + fourth_mem := fun i => (B.interval (old i)).fourth_mem + integer_relation := fun i => (B.interval (old i)).integer_relation + branch := fun i => (B.interval (old i)).branch + start := fun i => (B.interval (old i)).start + length := fun i => (B.interval (old i)).length + length_pos := fun i => (B.interval (old i)).length_pos + endpoint_le := fun i => (B.interval (old i)).endpoint_le + length_short := fun i => (B.interval (old i)).length_short + length_ratio := fun i => (Real.exp_le_exp.mpr (neg_le_neg hKP)).trans + (R.interval_length_ratio (e i).val) + weight := weight + weight_norm := hw + lower := fun i => v (e i) + expansion := fun i => (Classical.choice (hE (e i))).mono hPP + correlation := fun i => (Real.exp_le_exp.mpr (neg_le_neg hPP)).trans (hv (e i)) }⟩ + · intro i j hij + apply e.injective + apply Subtype.ext + apply Subtype.ext + apply Subtype.ext + exact hij + · simpa only [Fintype.card_coe] using + (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hPP)) (by positivity)).trans hsize + +end Erdos3 + +end + +section + +namespace Erdos3 + +namespace NativeAnchoredRankFibers + +variable {s r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} {H : Finset (ZMod N)} + {F : NativeWeightedRankIntervals W out H p} (A : NativeAnchoredRankFibers F) + +theorem exists_interval_pairs (a : ZMod N) (ha : a ∈ A.parameters) : + ∃ Q : Finset (ZMod N × ZMod N), Q.Nonempty ∧ + Real.exp (-(8 * p + 1)) * ((A.fiber a).card : ℝ) ^ 2 ≤ (Q.card : ℝ) ∧ + ∀ t ∈ Q, Nonempty (NativeRankInterval W out H (a, t) A.branch + (8 * p + 1) (mixedErrorPairBudget p)) := by + classical + obtain ⟨i₀, hi₀⟩ := A.fiber_nonempty a ha + let : Nonempty (A.fiber a) := ⟨⟨i₀, hi₀⟩⟩ + obtain ⟨Q, hQ, hQsize, hpair⟩ := native_interval_weight_pairs W out a A.anchor + (cyclicBranchOffset a A.branch) (fun i : A.fiber a => (F.index i.val).2.1) + (fun i => F.start i.val) (fun i => F.length i.val) F.weight + (fun i => F.lower i.val) (fun i => F.expansion i.val) F.budget_two F.weight_norm + (fun i => F.endpoint_le i.val) (fun i => F.length_short i.val) + (fun i => F.length_ratio i.val) (fun i => by + simpa only [A.fiber_parameter a i, A.fiber_anchor a i, A.fiber_branch a i] + using F.correlation i.val) + let e : (A.fiber a × A.fiber a) ↪ ZMod N × ZMod N := { + toFun := fun t => ((F.index t.1.val).2.1, (F.index t.2.val).2.1) + inj' := by + intro t u htu + obtain ⟨h₁, h₂⟩ := Prod.mk.inj htu + exact Prod.ext (A.fiber_shift_injective a h₁) (A.fiber_shift_injective a h₂) } + refine ⟨Q.map e, ?_, ?_, ?_⟩ + · obtain ⟨t, ht⟩ := hQ + exact ⟨e t, Finset.mem_map.mpr ⟨t, ht, rfl⟩⟩ + · simpa only [Finset.card_map, Fintype.card_coe] using hQsize + · intro t ht + obtain ⟨u, hu, rfl⟩ := Finset.mem_map.mp ht + obtain ⟨c, len, hlen, hN, hshort, hsize, ⟨E⟩, hc⟩ := hpair u hu + refine ⟨{ + first_mem := F.first_mem u.1.val + second_mem := ?_ + third_mem := F.first_mem u.2.val + fourth_mem := ?_ + integer_relation := ?_ + start := c + length := len + length_pos := hlen + endpoint_le := hN + length_short := hshort + length_ratio := hsize + lower := fun n => F.lower u.1.val n * star (F.lower u.2.val n) + expansion := E + correlation := hc }⟩ + · change (F.index u.1.val).2.1 - a ∈ H + simpa only [A.fiber_parameter a u.1] using F.second_mem u.1.val + · change (F.index u.2.val).2.1 - a ∈ H + simpa only [A.fiber_parameter a u.2] using F.second_mem u.2.val + · have h₁ := F.integer_relation u.1.val + have h₂ := F.integer_relation u.2.val + rw [A.fiber_parameter a u.1, A.fiber_anchor a u.1] at h₁ + rw [A.fiber_parameter a u.2, A.fiber_anchor a u.2] at h₂ + change -((F.index u.1.val).2.1.val : ℤ) + ((F.index u.1.val).2.1 - a).val + + (F.index u.2.val).2.1.val - ((F.index u.2.val).2.1 - a).val = 0 + omega + +end NativeAnchoredRankFibers + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +namespace NativeRankInterval + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + +theorem select_lower_term (I : NativeRankInterval W out H t branch p q) : + ∃ i : Fin I.expansion.count, Real.exp (-(p + q)) ≤ + ‖𝔼 n ∈ Finset.Ico (I.start : ℤ) (I.start + I.length), + fourPointProduct (W.eval out t.2.1) (W.eval out (t.2.1 - t.1)) + (W.eval out t.2.2) (W.eval out (t.2.2 - t.1)) (cyclicBranchOffset t.1 branch) n * + (I.expansion.test i).eval (fun _ => n)‖ := + I.expansion.select_sample_product_correlation + (Finset.Ico (I.start : ℤ) (I.start + I.length)) (fun n _ => n) + (fun n => fourPointProduct (W.eval out t.2.1) (W.eval out (t.2.1 - t.1)) + (W.eval out t.2.2) (W.eval out (t.2.2 - t.1)) (cyclicBranchOffset t.1 branch) n) + I.correlation + +end NativeRankInterval + +theorem exists_rank_interval_raised_lower_term (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q), + ∃ i : Fin I.expansion.count, + ∃ R : ((I.expansion.model i).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r, + R.ComplexityLE ((q + C) ^ C) ∧ R.realSubgroup s r = ⊥ ∧ + ((I.expansion.test i).raiseStep (Nat.sub_le s 1)).ComplexityLE (raisedNiltestBudget q) ∧ + Real.exp (-(p + q)) ≤ + ‖𝔼 n ∈ Finset.Ico (I.start : ℤ) (I.start + I.length), + fourPointProduct (W.eval out t.2.1) (W.eval out (t.2.1 - t.1)) + (W.eval out t.2.2) (W.eval out (t.2.2 - t.1)) (cyclicBranchOffset t.1 branch) n * + ((I.expansion.test i).raiseStep (Nat.sub_le s 1)).eval (fun _ => n)‖ := by + obtain ⟨C, hC, hraise⟩ := RationalFilteredNilmanifold.exists_raised_degree_rank_structure s + refine ⟨C, hC, ?_⟩ + intro r N _ b p q W out H t branch I + obtain ⟨i, hi⟩ := I.select_lower_term + have hq : 0 ≤ q := (Nat.cast_nonneg _).trans (I.expansion.complexity i).1.1 + have hsmall : s - 1 < s := by omega + obtain ⟨R, hR, hzero⟩ := hraise (I.expansion.model i) hsmall + W.rank.filtration.rank_le_degree hq (I.expansion.complexity i).1 + refine ⟨i, R, hR, hzero, + (I.expansion.test i).raiseStep_complexity (Nat.sub_le s 1) hq (I.expansion.complexity i), ?_⟩ + simpa only [RationalFilteredNilmanifold.Niltest.raiseStep_eval] using hi + +end Erdos3 + +end + +section + +namespace Erdos3 + +structure NativeRankRelation {s r N : ℕ} [NeZero N] {b : ℝ} + (W : NativeDegreeRankFamily s r (ZMod N) b) (out : Fin W.outputDim) + (H : Finset (ZMod N)) (p q : ℝ) where + quadruples : Finset (ZMod N × ZMod N × ZMod N) + quadruples_nonempty : quadruples.Nonempty + density : Real.exp (-p) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ quadruples.card + branch : Bool + interval : ∀ t : quadruples, NativeRankInterval W out H t.val branch p q + +namespace NativeRankRelation + +noncomputable def mono {s r N : ℕ} [NeZero N] {b p q p' q' : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} (R : NativeRankRelation W out H p q) (hp : p ≤ p') (hq : q ≤ q') : + NativeRankRelation W out H p' q' := + { R with + density := (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hp)) + (by positivity)).trans R.density + interval := fun t => (R.interval t).mono hp hq } + +end NativeRankRelation + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankInterval + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) + +theorem monomialScale_modulus_bound (hp : 0 ≤ p) (α : Unit →₀ ℕ) + (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s) : + monomialScale (fun _ : Unit => (N : ℝ)) α ≤ + Real.exp ((s : ℝ) * p) * monomialScale (fun _ : Unit => (I.length : ℝ)) α := by + have hN : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + have hlength : (0 : ℝ) < I.length := by exact_mod_cast I.length_pos + have hlower : Real.exp (-p) * (N : ℝ) ≤ I.length := + (le_div_iff₀ hN).mp I.length_ratio + have hratio : (N : ℝ) ≤ Real.exp p * I.length := by + calc + (N : ℝ) = Real.exp p * (Real.exp (-p) * N) := by + rw [← mul_assoc, ← Real.exp_add, add_neg_cancel, Real.exp_zero, one_mul] + _ ≤ Real.exp p * I.length := mul_le_mul_of_nonneg_left hlower (Real.exp_pos _).le + exact monomialScale_le_exp_mul _ _ (fun _ => hlength) (fun _ => hN) hp + (fun _ => hratio) α hα + +theorem norm_bound_on_modulus {ι : Type*} [Fintype ι] + (hp : 0 ≤ p) (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α ≤ s) + {M : ℝ} (hM : 0 ≤ M) (x : ι → ℝ) + (hx : ‖x‖ ≤ M / monomialScale (fun _ : Unit => (I.length : ℝ)) α) : + ‖x‖ ≤ (M * Real.exp ((s : ℝ) * p)) / monomialScale (fun _ : Unit => (N : ℝ)) α := by + have hN : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + have hlength : (0 : ℝ) < I.length := by exact_mod_cast I.length_pos + apply hx.trans + apply (div_le_div_iff₀ (monomialScale_pos _ (fun _ => hlength) α) + (monomialScale_pos _ (fun _ => hN) α)).mpr + exact (mul_le_mul_of_nonneg_left (I.monomialScale_modulus_bound hp α hα) hM).trans_eq + (mul_assoc _ _ _).symm + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3.NativeRankInterval + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) + +theorem length_lower_bound : Real.exp (-p) * N ≤ (I.length : ℝ) := by + have hN : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + exact (le_div_iff₀ hN).mp I.length_ratio + +theorem length_exp_lower_bound {A : ℝ} (hN : Real.exp (p + A) ≤ N) : + Real.exp A ≤ (I.length : ℝ) := by + calc + Real.exp A = Real.exp (-p) * Real.exp (p + A) := by + rw [← Real.exp_add] + congr 1 + ring + _ ≤ Real.exp (-p) * N := mul_le_mul_of_nonneg_left hN (Real.exp_pos _).le + _ ≤ I.length := I.length_lower_bound + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3 + +namespace NativeWeightedRankIntervals + +theorem remove_weight {s r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} (F : NativeWeightedRankIntervals W out H p) : + Nonempty (NativeRankRelation W out H (11 * p + 7) (mixedErrorPairBudget p)) := by + classical + obtain ⟨A⟩ := F.exists_anchored_fibers + have hdata (a : A.parameters) := A.exists_interval_pairs a.val a.property + choose P _ hPsize hP using hdata + have hpair (a : A.parameters) : + (Real.exp (-(8 * p + 1)) * (Real.exp (-p) / 4) ^ 2) * + (Fintype.card (ZMod N) : ℝ) ^ 2 ≤ ((P a).card : ℝ) := by + have hf := A.fiber_density a.val a.property + calc + _ = Real.exp (-(8 * p + 1)) * + (Real.exp (-p) / 4 * (Fintype.card (ZMod N) : ℝ)) ^ 2 := by ring + _ ≤ Real.exp (-(8 * p + 1)) * ((A.fiber a.val).card : ℝ) ^ 2 := by + apply mul_le_mul_of_nonneg_left _ (Real.exp_nonneg _) + exact pow_le_pow_left₀ (by positivity) hf 2 + _ ≤ _ := hPsize a + obtain ⟨Q, hQsize, hQmem⟩ := dense_triple_fibers A.parameters P + (by positivity) A.parameters_density hpair + have hdense : Real.exp (-(11 * p + 7)) * (Fintype.card (ZMod N) : ℝ) ^ 3 ≤ (Q.card : ℝ) := + (mul_le_mul_of_nonneg_right (rank_pair_density_loss p) (by positivity)).trans hQsize + have hN : (0 : ℝ) < Fintype.card (ZMod N) := by exact_mod_cast Fintype.card_pos + have hQpos : (0 : ℝ) < Q.card := lt_of_lt_of_le (by positivity) hdense + have hbudget : 8 * p + 1 ≤ 11 * p + 7 := by linarith only [F.budget_two] + have hinterval (t : Q) : Nonempty + (NativeRankInterval W out H t.val A.branch (11 * p + 7) (mixedErrorPairBudget p)) := by + obtain ⟨a, ha, ht⟩ := (hQmem t.val).mp t.property + obtain ⟨I⟩ := hP a t.val.2 ht + have heq : (a.val, t.val.2) = t.val := Prod.ext ha rfl + rw [heq] at I + exact ⟨I.mono hbudget le_rfl⟩ + exact ⟨{ + quadruples := Q + quadruples_nonempty := Finset.card_pos.mp (by exact_mod_cast hQpos) + density := hdense + branch := A.branch + interval := fun t => Classical.choice (hinterval t) }⟩ + +end NativeWeightedRankIntervals + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_native_rank_relation (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + ∃ (out : Fin W.family.outputDim) (H : Finset (ZMod N)), + H ⊆ W.shifts ∧ H.Nonempty ∧ CyclicShortShiftSet H ∧ + Real.exp (-((p + C) ^ C)) * Fintype.card (ZMod N) ≤ (H.card : ℝ) ∧ + Nonempty (NativeRankRelation W.family out H ((p + C) ^ C) ((p + C) ^ C)) := by + obtain ⟨a, _, hreduce⟩ := exists_native_reduced_interval_family s + obtain ⟨c, _, habsorb⟩ := exists_native_weighted_rank_intervals s + obtain ⟨C, hC, hbudget⟩ := exists_rank_relation_budget a c + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf + have hp : 0 ≤ p := (Nat.cast_nonneg W.mixed.dim).trans W.mixed.complexity.1.1 + obtain ⟨q, B, P, D, ⟨R⟩⟩ := hreduce W hf + obtain ⟨F⟩ := habsorb R + obtain ⟨T⟩ := F.remove_weight + have hK : 0 ≤ (p + a) ^ a := by positivity + have hq : q ≤ (p + C) ^ C := by + have hpow : 0 ≤ ((p + a) ^ a + c) ^ c := by positivity + linarith only [R.base_budget, (hbudget p hp).1, hK, hpow] + refine ⟨B.rankCoordinate, B.shifts, B.shifts_subset, B.shifts_nonempty, + B.shifts_short, ?_, ⟨T.mono (hbudget p hp).1 (hbudget p hp).2⟩⟩ + exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hq)) + (Nat.cast_nonneg _)).trans B.shifts_density + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeReplacedRankFamily.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeReplacedRankFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..568b7a3a28563fff206d08a1f57aba4deaa136b7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeReplacedRankFamily.lean @@ -0,0 +1,259 @@ +import OAI.Combinatorics.Progressions.Dynamics.FrozenCorrelationBudget +import OAI.Combinatorics.Progressions.Estimates.NativeFixedFactoredQuadruples +import OAI.Combinatorics.Progressions.Estimates.NativePartitionFreezing +import OAI.Combinatorics.Progressions.Estimates.NativePositiveCorrelation +import OAI.Combinatorics.Progressions.Lattices.NativeIntervalResiduePartition + +namespace OAI + +section + +namespace Erdos3.NativeCorrelationStructure + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeVectorCorrelation.lie NativeVectorCorrelation.algebra + NativeVectorCorrelation.topology NativeVectorCorrelation.topologicalAdd + NativeVectorCorrelation.continuousSMul NativeVectorCorrelation.hausdorff + +variable {s r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f) + +noncomputable def replacedRankResidual (h : ZMod N) + (c : Fin W.family.outputDim → ZMod N → ℂ) + (ij : Fin W.mixed.outputDim × Fin W.family.outputDim) (x : ZMod N) : ℂ := + multiplicativeDerivative f h x * star (W.mixed.evalCyclic N ij.1 (correlationInput h x)) * + star (c ij.2 x) + +theorem exists_rank_approximation_correlation {J : Type*} [Fintype J] + (hf : ∀ x, ‖f x‖ ≤ 1) (h : W.shifts) (A : J → ZMod N → ℝ) + (c : J → Fin W.family.outputDim → ZMod N → ℂ) {q : ℝ} + (hq : 2 ≤ q) (hcard : (Fintype.card J : ℝ) ≤ Real.exp q) + (hA : ∀ j, PositiveCyclicNiltest.{0} (s - 1) N q (A j)) + (herr : (𝔼 x, ‖W.selectedRank h x - + ∑ j, (A j x : ℂ) * c j (W.selectedWitness h).coordinate.2 x‖) ≤ Real.exp (-(2 * p)) / 2) : + ∃ j, Nonempty (NativeVectorCorrelation (s - 1) N + (productNiltestBudget (raisedNiltestBudget (p + q + 2))) (W.replacedRankResidual h.val (c j))) := by + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + let b (x : ZMod N) := W.selectedMixed h x * W.selectedLower h x + have hb (x : ZMod N) : ‖b x‖ ≤ Real.exp p := by + have hm := W.mixed.norm_eval (W.selectedWitness h).coordinate.1 + (fun i => (((correlationInput h.val x) i).val : ℤ)) + have hl := (W.selectedWitness h).test.eval_budget (W.selectedWitness h).complexity + (fun _ : Unit => (x.val : ℤ)) + exact (norm_mul _ _).trans_le ((mul_le_mul hm hl (norm_nonneg _) (by norm_num)).trans_eq (one_mul _)) + let v (j : J) (x : ZMod N) := (A j x : ℂ) * c j (W.selectedWitness h).coordinate.2 x * b x + have hmean : (𝔼 x, ‖W.selectedProduct h x - ∑ j, v j x‖) ≤ Real.exp (-p) / 2 := by + have he := mean_error_mul_bounded (W.selectedRank h) + (fun x => ∑ j, (A j x : ℂ) * c j (W.selectedWitness h).coordinate.2 x) b + (Real.exp_pos p).le hb herr + have hid (x : ZMod N) : W.selectedProduct h x - ∑ j, v j x = + W.selectedRank h x * b x - + (∑ j, (A j x : ℂ) * c j (W.selectedWitness h).coordinate.2 x) * b x := by + rw [Finset.sum_mul] + simp only [v, b, W.selectedProduct_eq] + ring + have hexp : Real.exp p * (Real.exp (-(2 * p)) / 2) = Real.exp (-p) / 2 := by + rw [← mul_div_assoc, ← Real.exp_add] + congr 2 + ring + simpa only [hid, hexp] using he + obtain ⟨j, hj⟩ := exists_correlating_summand_of_mean (multiplicativeDerivative f h.val) + (W.selectedProduct h) v (Real.exp_pos (-p)) (Real.exp_pos q) hcard + (multiplicativeDerivative_norm_le_one f hf h.val) hmean (W.selectedProduct_correlation h) + have hthreshold : Real.exp (-(p + q + 2)) ≤ Real.exp (-p) / (2 * Real.exp q) := by + apply (le_div_iff₀ (by positivity)).mpr + have he : Real.exp (-(p + q + 2)) * (2 * Real.exp q) = 2 * Real.exp (-p - 2) := by + rw [mul_left_comm, ← Real.exp_add] + congr 2 + ring + rw [he] + have htwo : (2 : ℝ) ≤ Real.exp 2 := by linarith [Real.add_one_le_exp (2 : ℝ)] + calc + _ ≤ Real.exp 2 * Real.exp (-p - 2) := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = Real.exp (-p) := by rw [← Real.exp_add]; congr 1; ring + have hpR : p ≤ p + q + 2 := by linarith + have hqR : q ≤ p + q + 2 := by linarith + let V : NativeVectorCorrelation (s - 1) N (p + q + 2) + (fun ij x => (A j x : ℂ) * W.replacedRankResidual h.val (c j) ij x) := { + L := (W.selectedWitness h).L + dim := (W.selectedWitness h).dim + model := (W.selectedWitness h).model + test := (W.selectedWitness h).test + complexity := (W.selectedWitness h).complexity.mono hpR + coordinate := (W.selectedWitness h).coordinate + correlation := by + have hc := hthreshold.trans hj + have heq (x : ZMod N) : multiplicativeDerivative f h.val x * star (v j x) = + ((A j x : ℂ) * W.replacedRankResidual h.val (c j) (W.selectedWitness h).coordinate x) * + star ((W.selectedWitness h).test.evalCyclic N (fun _ => x)) := by + simp only [v, b, selectedMixed, selectedLower, replacedRankResidual, star_mul, + Complex.star_def, Complex.conj_ofReal] + ring + simpa only [heq] using hc } + exact ⟨j, V.exists_absorb_positive (W.replacedRankResidual h.val (c j)) (A j) + (by linarith) ((hA j).mono le_rfl hqR)⟩ + +end Erdos3.NativeCorrelationStructure + +end + +section + +namespace Erdos3 + +open VectorPolynomial RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +theorem exists_native_frozen_rank_correlation (s a : ℕ) (hs : 2 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + ∀ (h : W.shifts) (P : ℝ), 2 ≤ P → p ≤ P → + ∀ M : ℕ, 0 < M → (M : ℝ) ≤ Real.exp P → + ∀ ε ξ v γ : W.family.model.filtration.realification.PolynomialOrbit (fun _ : Unit => 1), + ε * ξ * v * γ = W.family.orbit h.val → + CoefficientBound (W.family.model.basis.baseChange ℝ) (fun _ : Unit => (N : ℝ)) + (Real.exp ((P + 2) ^ a)) ε.log → + (∀ x y : Unit → ℤ, (∀ j, (M : ℤ) ∣ x j - y j) → + (QuotientGroup.mk (W.family.model.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) x γ) : W.family.model.Space) = + QuotientGroup.mk (W.family.model.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) y γ)) → + Real.exp ((P + C) ^ C) ≤ N → + ∃ y : ZMod N, + (∀ x, ∑ i, ‖W.family.model.frozenCyclicOrbitValue + (W.family.vertical.observable i) ε (ξ * v) γ y x‖ ^ 2 = 1) ∧ + Nonempty (NativeVectorCorrelation (s - 1) N ((P + C) ^ C) + (W.replacedRankResidual h.val (fun i x => W.family.model.frozenCyclicOrbitValue + (W.family.vertical.observable i) ε (ξ * v) γ y x))) := by + obtain ⟨c, _, hfreeze⟩ := exists_partition_orbit_freezing s a + obtain ⟨b, _, hpart⟩ := exists_interval_residue_partition 1 + obtain ⟨C, hC, hbudget⟩ := exists_frozen_correlation_budget c b + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf h P hP hpP M hM hMP ε ξ v γ hprod hε hperiod hN + classical + let : NeZero M := ⟨hM.ne'⟩ + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + have hP0 : 0 ≤ P := by linarith + let D := (P + c) ^ c + let L := D + 2 * P + 40 + let Q := P + (L + b) ^ b + 2 + let ρ := Real.exp (-L) + have hD : 0 ≤ D := by dsimp only [D]; positivity + have hL : 0 ≤ L := by dsimp only [L]; positivity + have hPL : P ≤ L := by dsimp only [L]; linarith + have hρ : 0 < ρ := Real.exp_pos _ + obtain ⟨hLC, hQC⟩ := hbudget P hP0 + have hlarge : Real.exp L ≤ N := (Real.exp_le_exp.mpr hLC).trans hN + have hprec : 1 / ρ ≤ Real.exp ((L + 2) ^ 1) := by + rw [pow_one] + have he : 1 / ρ = Real.exp L := by simp only [ρ, Real.exp_neg, one_div, inv_inv] + rw [he] + exact Real.exp_le_exp.mpr (by linarith) + obtain ⟨n, hn, hcard, A, hA, hsum, hcells⟩ := hpart N M hL + (hMP.trans (Real.exp_le_exp.mpr hPL)) hρ hprec + have hqQ : (L + b) ^ b ≤ Q := by dsimp only [Q]; linarith + have hQ : 2 ≤ Q := by + have ht : 0 ≤ (L + b) ^ b := by positivity + dsimp only [Q] + linarith + have hDgeom := W.family.complexity.1.mono W.family.model hpP + have hprod' : ε * (ξ * v) * γ = W.family.orbit h.val := by + simpa only [mul_assoc] using hprod + obtain ⟨y, _, hmean⟩ := hfreeze W.family.model (by linarith : 1 ≤ P) hDgeom hρ A + (fun j x => ((hA j).unit_interval x).1) hsum hcells + (W.family.vertical.observable (W.selectedWitness h).coordinate.2) W.family.vertical.lipBound + (W.family.vertical.norm _) (W.family.vertical.lipschitz _) + (W.family.vertical.lip_bound.trans (Real.exp_le_exp.mpr hpP)) + ε (ξ * v) γ (W.family.orbit h.val) hprod' hε hperiod + let B (j : Fin n × ZMod M) (i : Fin W.family.outputDim) (x : ZMod N) := + W.family.model.frozenCyclicOrbitValue (W.family.vertical.observable i) ε (ξ * v) γ (y j) x + have herror : (𝔼 x, ‖W.selectedRank h x - + ∑ j, (A j x : ℂ) * B j (W.selectedWitness h).coordinate.2 x‖) ≤ Real.exp (-(2 * p)) / 2 := by + apply hmean.trans + exact (frozen_correlation_precision_error P D hD (NeZero.pos N) hlarge).trans + (div_le_div_of_nonneg_right (Real.exp_le_exp.mpr (by linarith)) (by norm_num)) + obtain ⟨j, V⟩ := W.exists_rank_approximation_correlation hf h A B hQ + (hcard.trans (Real.exp_le_exp.mpr hqQ)) + (fun j => (hA j).mono (by omega) hqQ) herror + have hcost : productNiltestBudget (raisedNiltestBudget (p + Q + 2)) ≤ (P + C) ^ C := + (frozen_witness_budget_mono (by positivity) (by linarith)).trans hQC + refine ⟨y j, fun x => W.family.vertical.unit _, ?_⟩ + exact ⟨(Classical.choice V).mono hcost⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.NativeCorrelationStructure + +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +variable {s r N : ℕ} [NeZero N] {p q : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f) + {L : Type} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (E : RationalFilteredNilmanifold L s d) (T : E.DegreeRankStructure r) + (hpq : p ≤ q) (hT : T.ComplexityLE q) + (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +noncomputable def replacementFamily : NativeDegreeRankFamily s r (ZMod N) q where + L := L + dim := d + model := E + rank := T + complexity := hT + orbit := g + normalized := hg + outputDim := W.family.outputDim + output_pos := W.family.output_pos + output_bound := W.family.output_bound.trans (Real.exp_le_exp.mpr hpq) + vertical := V + +theorem replacementFamily_evalCyclic (i : Fin W.family.outputDim) (h x : ZMod N) : + (W.replacementFamily E T hpq hT V g hg).evalCyclic N i h x = + V.observable i (QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) (fun _ => (x.val : ℤ)) (g h))) := rfl + +theorem replacementFamily_residual (h : ZMod N) : + nativeCorrelationResidual f (W.mixed.mono hpq) + (W.replacementFamily E T hpq hT V g hg) h = + W.replacedRankResidual h (fun i x => V.observable i (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) (fun _ => (x.val : ℤ)) (g h)))) := rfl + +noncomputable def replaceRank (H : Finset (ZMod N)) (hne : H.Nonempty) + (hdense : Real.exp (-q) * Fintype.card (ZMod N) ≤ (H.card : ℝ)) + (hcorr : ∀ h ∈ H, Nonempty (NativeVectorCorrelation (s - 1) N q + (W.replacedRankResidual h (fun i x => V.observable i (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) (fun _ => (x.val : ℤ)) (g h))))))) : + NativeCorrelationStructure s r N q f where + shifts := H + nonempty := hne + density := hdense + mixed := W.mixed.mono hpq + family := W.replacementFamily E T hpq hT V g hg + correlation := hcorr + +end Erdos3.NativeCorrelationStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeSharedFreeRankRelation.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeSharedFreeRankRelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..bcb03dda854d907e40c33078bfc7c426b43f4b38 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeSharedFreeRankRelation.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeSharedFreeFamily + +namespace OAI + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold VectorPolynomial +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_native_shared_free_rank_relation (s : ℕ) (hs : 2 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℂ} + (W : NativeCorrelationStructure s r N p f), (∀ x, ‖f x‖ ≤ 1) → + Real.exp ((p + C) ^ C) ≤ N → + ∃ (A : ℝ) (hpA : p ≤ A), A ≤ (p + C) ^ C ∧ + ∃ (out : Fin W.family.outputDim) (H : Finset (ZMod N)) (q P : ℝ), + H ⊆ W.shifts ∧ H.Nonempty ∧ CyclicShortShiftSet H ∧ + p ≤ q ∧ q ≤ P ∧ P ≤ A ∧ + ∃ (R : NativeRankRelation W.family out H q q) (D : R.CommonData P) + (B : D.CoefficientBases A) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure r) (hT : T.ComplexityLE A), + T.filtration = D.coefficientFreeFiltration ∧ IsCentralLieBasis E.basis ∧ + Nonempty (FreeCoordinateFrame E.basis A) ∧ + (letI := moduleTopology ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI := realification_moduleTopology_t2 E.basis + ∃ V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) A, + V.frequency = B.freeFrequency D ∧ + ∃ (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hξ : E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 ξ = 1), + (∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ + (D.commonFreeSpan d).baseChange ℝ) ∧ + ∃ H' : Finset (ZMod N), H' ⊆ H ∧ H' ⊆ W.shifts ∧ H'.Nonempty ∧ + CyclicShortShiftSet H' ∧ + Real.exp (-A) * Fintype.card (ZMod N) ≤ (H'.card : ℝ) ∧ + ∃ (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hv : ∀ h, E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) 0 (v h) = 1), + (∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) ∧ + (∀ h ∈ H', Nonempty (NativeVectorCorrelation (s - 1) N A + (W.replacedRankResidual h (fun i x => V.observable i (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) (fun _ => (x.val : ℤ)) (ξ * v h))))))) ∧ + (let U := W.replacementFamily E T hpA hT V (fun h => ξ * v h) + (fun h => by rw [map_mul, hξ, hv h, one_mul]) + ∃ (out' : Fin U.outputDim) (H'' : Finset (ZMod N)) (q' : ℝ), + H'' ⊆ H' ∧ H''.Nonempty ∧ CyclicShortShiftSet H'' ∧ + Real.exp (-((p + C) ^ C)) * Fintype.card (ZMod N) ≤ (H''.card : ℝ) ∧ + A ≤ q' ∧ q' ≤ (p + C) ^ C ∧ + ∃ R' : NativeRankRelation U out' H'' q' q', + Nonempty (R'.CommonData ((p + C) ^ C)))) := by + obtain ⟨a, _, hfree⟩ := exists_native_shared_free_family s hs + obtain ⟨c, _, hrelation⟩ := exists_native_common_rank_relation s (by omega) + let A₀ : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := + exists_natPolynomial_eval_budget (A₀ + (A₀ + Polynomial.C c) ^ c) + refine ⟨C, hC, ?_⟩ + intro r N _ p f W hf hN + classical + have hp : 0 ≤ p := (Nat.cast_nonneg W.family.dim).trans W.family.complexity.1.1 + let A := (p + a) ^ a + let Z := (A + c) ^ c + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hZ : 0 ≤ Z := by dsimp only [Z]; positivity + have hAZ : A + Z ≤ (p + C) ^ C := by + simpa [A₀, A, Z, Polynomial.eval₂_pow] using hbudget p hp + have hAC : A ≤ (p + C) ^ C := (le_add_of_nonneg_right hZ).trans hAZ + have hZC : Z ≤ (p + C) ^ C := (le_add_of_nonneg_left hA).trans hAZ + obtain ⟨out, H, q, P, hHW, hH, hshort, hpq, hqP, hPA, R, D, B, E, T, + hfiltration, hT, hcentral, hframe, hdata⟩ := + hfree W hf ((Real.exp_le_exp.mpr hAC).trans hN) + have hpA : p ≤ A := hpq.trans (hqP.trans hPA) + let := moduleTopology ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let := realification_moduleTopology_t2 E.basis + obtain ⟨V, hfreq, ξ, hξ, hcommon, H', hH'H, hH'W, hH', hshort', hdense, hfactor⟩ := hdata + have hall (h : ZMod N) : + ∃ v : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1), + E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 v = 1 ∧ + (∀ d : Fin s, coefficients v.log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) ∧ + (h ∈ H' → Nonempty (NativeVectorCorrelation (s - 1) N A + (W.replacedRankResidual h (fun i x => V.observable i (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval + (fun _ : Unit => 1) (fun _ => (x.val : ℤ)) (ξ * v))))))) := by + by_cases hh : h ∈ H' + · obtain ⟨v, hv, hcoeff, hc⟩ := hfactor h hh + exact ⟨v, hv, hcoeff, fun _ => hc⟩ + · refine ⟨1, map_one _, ?_, fun hh' => (hh hh').elim⟩ + intro d + change (0 : ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra) ∈ _ + exact Submodule.zero_mem _ + choose v hv hcoeff hcorr using hall + let X := W.replaceRank E T hpA hT V (fun h => ξ * v h) + (fun h => by rw [map_mul, hξ, hv h, one_mul]) H' hH' hdense hcorr + obtain ⟨out', H'', q', hsub, hnonempty, hshort'', hdense'', hAq, hqZ, R', ⟨D'⟩⟩ := + hrelation X hf ((Real.exp_le_exp.mpr hZC).trans hN) + refine ⟨A, hpA, hAC, out, H, q, P, hHW, hH, hshort, hpq, hqP, hPA, + R, D, B, E, T, hT, hfiltration, hcentral, hframe, V, hfreq, ξ, hξ, hcommon, + H', hH'H, hH'W, hH', hshort', hdense, v, hv, hcoeff, hcorr, + out', H'', q', hsub, hnonempty, hshort'', ?_, hAq, hqZ.trans hZC, R', ⟨D'.mono hZC⟩⟩ + exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hZC)) + (Nat.cast_nonneg _)).trans hdense'' + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeTripleProjections.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeTripleProjections.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbdd09955fa846ff04b7614ad54d5f788d57f55d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeTripleProjections.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonRefilteredFactorization + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + {s d r : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) + +theorem additiveTripleProjection_lattice (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) (j : Fin 3) : + M.additiveTripleLattice i hi c hc ≤ D.lattice.comap + (mapOfSteps (M.filtration.additiveTripleProjection i hi c hc j)) := by + intro x hx + have h := (M.additiveTripleLattice_mem i hi c hc x).mp hx + fin_cases j + · exact h.1 + · exact h.2.1 + · exact h.2.2 + +noncomputable def tripleSpaceProjection (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) + (E : RationalFilteredNilmanifold (M.filtration.additiveTripleSubalgebra i hi c hc) s r) + (hE : E.lattice = M.additiveTripleLattice i hi c hc) (j : Fin 3) : E.Space → D.Space := + cosetMap E.realLattice D.realLattice (M.filtration.realAdditiveTripleProjection i hi c hc j) + (realificationMap_subgroup (M.filtration.additiveTripleProjection i hi c hc j) _ _ + (by rw [hE]; exact M.additiveTripleProjection_lattice i hi c hc j)) + +theorem tripleSpaceProjection_mk (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) + (E : RationalFilteredNilmanifold (M.filtration.additiveTripleSubalgebra i hi c hc) s r) + (hE : E.lattice = M.additiveTripleLattice i hi c hc) (j : Fin 3) (g : E.RealGroup) : + M.tripleSpaceProjection i hi c hc E hE j (QuotientGroup.mk g) = + QuotientGroup.mk (M.filtration.realAdditiveTripleProjection i hi c hc j g) := rfl + +theorem tripleSpaceProjection_smul (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) + (E : RationalFilteredNilmanifold (M.filtration.additiveTripleSubalgebra i hi c hc) s r) + (hE : E.lattice = M.additiveTripleLattice i hi c hc) (j : Fin 3) + (g : E.RealGroup) (x : E.Space) : + M.tripleSpaceProjection i hi c hc E hE j (g • x) = + M.filtration.realAdditiveTripleProjection i hi c hc j g • + M.tripleSpaceProjection i hi c hc E hE j x := cosetMap_smul _ _ _ _ _ _ + +theorem tripleSpaceProjection_lipschitz (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) + (E : RationalFilteredNilmanifold (M.filtration.additiveTripleSubalgebra i hi c hc) s r) + (hEL : E.lattice = M.additiveTripleLattice i hi c hc) (j : Fin 3) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi c hc)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi c hc)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi c hc)] + [T2Space (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi c hc)] + {p : ℝ} (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) (hE : E.GeometryComplexityLE p) + (hheight : ∀ a k, rationalLogHeight + (D.basis.repr (M.filtration.additiveTripleProjection i hi c hc j (E.basis a)) k) ≤ p) : + letI := E.metricSpace + letI := D.metricSpace + LipschitzWith ⟨Real.exp ((p + 3) ^ 2), (Real.exp_pos _).le⟩ + (M.tripleSpaceProjection i hi c hc E hEL j) := by + let := E.metricSpace + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + induction x using Quotient.inductionOn with + | h x => + induction y using Quotient.inductionOn with + | h y => + exact nativeMap_dist_le E D (M.filtration.additiveTripleProjection i hi c hc j) + (by rw [hEL]; exact M.additiveTripleProjection_lattice i hi c hc j) + hp hE hD (fun k a => hheight a k) x y + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NativeVerticalTranslateFrame.lean b/lean/OAI/Combinatorics/Progressions/Linear/NativeVerticalTranslateFrame.lean new file mode 100644 index 0000000000000000000000000000000000000000..92d46d57e975c1252745134e9d274e21e6cb4ab1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NativeVerticalTranslateFrame.lean @@ -0,0 +1,136 @@ +import OAI.Combinatorics.Progressions.Dynamics.ComparisonEquivalenceBudget +import OAI.Combinatorics.Progressions.Estimates.VerticalTranslations + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct NNReal + +theorem exists_native_vertical_translate_frame (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {d : ℕ} + (D : RationalFilteredNilmanifold L s d) {w : σ → ℕ} (T : D.Niltest w) + {p : ℝ}, 0 ≤ p → T.ComplexityLE p → T.normBound ≤ 1 → + ∀ eta : L →ₗ[ℚ] ℚ, + (∀ z, z ∈ D.filtration.realification.subgroup s → ∀ x, + T.observable (z • x) = + character ((realifyFunctional eta z.coord : ℝ) : CircleFourier.Circle) * T.observable x) → + ∀ y : D.Space, Real.exp (-p) ≤ ‖T.observable y‖ → + ∃ n : ℕ, 0 < n ∧ (n : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ K : ℝ≥0, (K : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ u : Fin n → D.Space → ℂ, + (∀ i x, ‖u i x‖ ≤ 1) ∧ + (letI := D.metricSpace; ∀ i, LipschitzWith K (u i)) ∧ + (∀ x, ∃ i, Real.exp (-(p + 1)) ≤ ‖u i x‖) ∧ + ∀ i z, z ∈ D.filtration.realification.subgroup s → ∀ x, + u i (z • x) = + character ((realifyFunctional eta z.coord : ℝ) : CircleFourier.Circle) * u i x := by + obtain ⟨a, _, hrep⟩ := exists_realification_representatives_exp_bound s + obtain ⟨b, _, hleft⟩ := exists_bounded_normalization_left_lipschitz s a + obtain ⟨c, _, hcover⟩ := exists_native_quotient_parameter_cover s + let X : Polynomial ℕ := Polynomial.X + let Q := 2 * X + 2 * (X + Polynomial.C a + 2 + Polynomial.C b) ^ b + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (X + Q + (Q + Polynomial.C c) ^ c + 1) + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ _ _ d D w T p hp hT hnorm eta hvertical y hy + let := D.metricSpace + let l := normalizedSquareLeftBudget a b p + let q := 2 * p + 2 * l + 2 + have hl : 0 ≤ l := normalizedSquareLeftBudget_nonneg a b hp + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have htotal : p + q + (q + c) ^ c + 1 ≤ (p + C) ^ C := by + simpa [X, Q, q, l, normalizedSquareLeftBudget, Polynomial.eval₂_pow] using hbudget p hp + have hcp : 0 ≤ (q + c) ^ c := by positivity + have hqp : q ≤ (p + C) ^ C := by linarith + have hcount : (q + c) ^ c ≤ (p + C) ^ C := by linarith + obtain ⟨A, _, hA, hLip⟩ := hleft D p hp hT.1 + have hrepresentatives : ∀ x : D.Space, ∃ r : D.RealGroup, + (∀ i, |(D.basis.baseChange ℝ).repr r.coord i| ≤ Real.exp ((p + 1 + a) ^ a)) ∧ + QuotientGroup.mk r = x := by + intro x + induction x using Quotient.inductionOn with + | h g => + obtain ⟨r, hr, γ, hγ, hg⟩ := + hrep D.basis D.filtration.lowerCentralSeries_eq_bot D.lattice D.grid + ⌈Real.exp p⌉₊ (p + 1) D.grid_pos D.inner_grid + (fun i j k => rationalHeightLE_ceil_exp (hT.1.2.2.1 i j k)) + (by linarith) + (by simpa only [Fintype.card_fin] using hT.1.1.trans (show p ≤ p + 1 by linarith)) + (ceil_exp_le_exp_add_one hp) (hT.1.2.1.trans (Real.exp_le_exp.mpr (by linarith))) g + refine ⟨r, hr, ?_⟩ + change (QuotientGroup.mk r : D.Space) = QuotientGroup.mk g + rw [hg] + exact (QuotientGroup.mk_mul_of_mem r (show γ ∈ D.realLattice from hγ)).symm + choose r hr hrc using hrepresentatives + have hInv (x : D.Space) : ∀ i, + |(D.basis.baseChange ℝ).repr (r x)⁻¹.coord i| ≤ Real.exp ((p + 1 + a) ^ a) := by + intro i + simpa only [coord_inv, map_neg, Finsupp.neg_apply, abs_neg] using hr x i + let ε := Real.exp (-q) + have hε : 0 < ε := Real.exp_pos _ + have hεinv : 1 / ε ≤ Real.exp q := by + simp only [ε, Real.exp_neg, one_div, inv_inv, le_refl] + obtain ⟨n, hn, hnc, centers, hcenters⟩ := + hcover D hq (hT.1.mono D hpq) hε hεinv + let K := T.lipBound * (A * A) + let u (i : Fin n) (x : D.Space) := T.observable (r y • ((r (centers i))⁻¹ • x)) + have hK : (K : ℝ) ≤ Real.exp (p + 2 * l) := by + have hTlip : (T.lipBound : ℝ) ≤ Real.exp p := by + linarith [Niltest.observable_budget hT, T.normBound.coe_nonneg] + calc + _ ≤ Real.exp p * (Real.exp l * Real.exp l) := by + dsimp [K] + exact mul_le_mul hTlip (mul_le_mul hA hA A.coe_nonneg (Real.exp_nonneg _)) + (mul_nonneg A.coe_nonneg A.coe_nonneg) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + have huLip (i : Fin n) : LipschitzWith K (u i) := + T.lipschitz.comp ((hLip (r y) (hr y)).comp (hLip ((r (centers i))⁻¹) (hInv _))) + have hcenter (i : Fin n) : u i (centers i) = T.observable y := by + change T.observable (r y • ((r (centers i))⁻¹ • centers i)) = T.observable y + have heq : (r (centers i))⁻¹ • centers i = (QuotientGroup.mk (1 : D.RealGroup) : D.Space) := by + calc + _ = (r (centers i))⁻¹ • QuotientGroup.mk (r (centers i)) := + congrArg (fun x : D.Space => (r (centers i))⁻¹ • x) (hrc _).symm + _ = _ := by simp only [MulAction.Quotient.smul_mk, smul_eq_mul, inv_mul_cancel] + rw [heq] + simp only [MulAction.Quotient.smul_mk, smul_eq_mul, mul_one, hrc] + have herror : (K : ℝ) * ε ≤ Real.exp (-p) / 2 := by + calc + _ ≤ Real.exp (p + 2 * l) * Real.exp (-q) := mul_le_mul_of_nonneg_right hK hε.le + _ = Real.exp (-p - 2) := by rw [← Real.exp_add]; congr 1; dsimp [q]; ring + _ ≤ Real.exp (-p - 1) := Real.exp_le_exp.mpr (by linarith) + _ ≤ _ := exp_sub_one_le_half_exp (-p) + refine ⟨n, hn, hnc.trans (Real.exp_le_exp.mpr hcount), K, + hK.trans (Real.exp_le_exp.mpr (by dsimp [q] at hqp; linarith)), u, ?_, huLip, ?_, ?_⟩ + · intro i x + have hnorm' : (T.normBound : ℝ) ≤ (1 : ℝ) := by exact_mod_cast hnorm + exact (T.norm_le _).trans hnorm' + · intro x + obtain ⟨i, hi⟩ := hcenters x + have hdist := (huLip i).dist_le_mul x (centers i) + have herr : ‖u i (centers i) - u i x‖ ≤ Real.exp (-p) / 2 := by + have h := hdist.trans ((mul_le_mul_of_nonneg_left hi K.coe_nonneg).trans herror) + simpa only [dist_eq_norm, norm_sub_rev] using h + have ht := norm_sub_norm_le (u i (centers i)) (u i x) + rw [hcenter] at ht herr + refine ⟨i, ?_⟩ + have hh : Real.exp (-(p + 1)) ≤ Real.exp (-p) / 2 := by + simpa only [neg_add, sub_eq_add_neg] using exp_sub_one_le_half_exp (-p) + linarith + · intro i z hz x + exact D.vertical_left_translate (fun x => T.observable (r y • x)) eta + (fun z hz x => D.vertical_left_translate T.observable eta hvertical (r y) z hz x) + ((r (centers i))⁻¹) z hz x + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NormalHyperplaneProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/NormalHyperplaneProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fe0a5f5682d78c4792197f4798ffcab67a88ed6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NormalHyperplaneProjection.lean @@ -0,0 +1,36 @@ +import OAI.Combinatorics.Progressions.Estimates.IntegralHyperplaneCorrection + +namespace OAI + +section + +namespace Erdos3 + +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +theorem normalHyperplane_starProjection (ξ x : E) (hξ : ξ ≠ 0) : + (normalFunctional ξ).ker.starProjection x = + x - (inner ℝ ξ x / ‖ξ‖ ^ 2) • ξ := by + have hn : ‖ξ‖ ^ 2 ≠ 0 := pow_ne_zero _ (norm_ne_zero_iff.mpr hξ) + apply Submodule.eq_starProjection_of_mem_of_inner_eq_zero + · change inner ℝ ξ (x - (inner ℝ ξ x / ‖ξ‖ ^ 2) • ξ) = 0 + rw [inner_sub_right, inner_smul_right, real_inner_self_eq_norm_sq, + div_mul_cancel₀ _ hn, sub_self] + · intro y hy + have hy' : inner ℝ ξ y = 0 := hy + rw [sub_sub_cancel, real_inner_smul_left, hy', mul_zero] + +theorem normalHyperplane_height (ξ w : E) (hξ : ξ ≠ 0) + (hw : inner ℝ ξ w = 1) : + ‖w - (normalFunctional ξ).ker.starProjection w‖ = ‖ξ‖⁻¹ := by + have hn : ‖ξ‖ ≠ 0 := norm_ne_zero_iff.mpr hξ + rw [normalHyperplane_starProjection ξ w hξ, sub_sub_cancel, hw, + norm_smul, Real.norm_eq_abs, abs_of_nonneg (by positivity)] + field_simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/NormalizedBasisBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/NormalizedBasisBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..8043d363fa080c4d8915ca6fe02df92703a42c84 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/NormalizedBasisBounds.lean @@ -0,0 +1,221 @@ +import OAI.Combinatorics.Progressions.Estimates.GramCovolume +import OAI.Combinatorics.Progressions.Linear.BasisAxisNormalization +import OAI.Combinatorics.Progressions.Linear.BasisImageSection +import OAI.Combinatorics.Progressions.Linear.MatrixSupInverse + +namespace OAI + +section + +namespace Erdos3 + +open Module MeasureTheory +open scoped BigOperators + +variable {I E : Type*} [Fintype I] [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +theorem covolume_basis_eq_orthonormal_det [DecidableEq I] + (o : OrthonormalBasis I ℝ E) (b : Basis I ℝ E) : + ZLattice.covolume (Submodule.span ℤ (Set.range b)) = |o.toBasis.det b| := by + classical + have hvolume : volume.real (ZSpan.fundamentalDomain o.toBasis) = 1 := by + rw [measureReal_def] + have hfd : volume (ZSpan.fundamentalDomain o.toBasis) = 1 := by + rw [measure_congr (ZSpan.fundamentalDomain_ae_parallelepiped o.toBasis volume)] + exact o.volume_parallelepiped + rw [hfd] + simp + rw [ZLattice.covolume_eq_measure_fundamentalDomain _ volume + (ZSpan.isAddFundamentalDomain b volume), + ZSpan.measureReal_fundamentalDomain b volume o.toBasis, hvolume, mul_one] + +theorem covolume_basis_scale (o : OrthonormalBasis I ℝ E) (b c : Basis I ℝ E) + (t : I → ℝ) (ht : ∀ i, 0 ≤ t i) (hc : ∀ i, c i = t i • b i) : + ZLattice.covolume (Submodule.span ℤ (Set.range c)) = + (∏ i, t i) * ZLattice.covolume (Submodule.span ℤ (Set.range b)) := by + classical + rw [covolume_basis_eq_orthonormal_det o c, covolume_basis_eq_orthonormal_det o b] + rw [show (c : I → E) = (fun i => t i • b i) from funext hc, + AlternatingMap.map_smul_univ, smul_eq_mul, abs_mul, + abs_of_nonneg (Finset.prod_nonneg (fun i _ => ht i))] + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +theorem orthonormal_basis_coordinate_abs_le (o : OrthonormalBasis I ℝ E) (x : E) (i : I) : + |o.toBasis.equivFun x i| ≤ ‖x‖ := by + have h := PiLp.norm_apply_le (o.repr x) i + change |o.repr x i| ≤ ‖x‖ + simpa only [Real.norm_eq_abs, LinearIsometryEquiv.norm_map] using h + +theorem covolume_basis_le_norm_bound (o : OrthonormalBasis I ℝ E) (b : Basis I ℝ E) + {H : ℝ} (hb : ∀ i, ‖b i‖ ≤ H) : + ZLattice.covolume (Submodule.span ℤ (Set.range b)) ≤ + (Fintype.card I).factorial * H ^ Fintype.card I := by + classical + rw [covolume_basis_eq_orthonormal_det o b, Basis.det_apply] + apply matrix_det_abs_le_uniform_bound + intro i j + exact (orthonormal_basis_coordinate_abs_le o (b j) i).trans (hb j) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule MeasureTheory +open scoped BigOperators Matrix + +theorem basis_synthesis_norm_le {E : Type*} {n : ℕ} + [NormedAddCommGroup E] [NormedSpace ℝ E] + (b : Basis (Fin n) ℝ E) {H : ℝ} (hb : ∀ i, ‖b i‖ ≤ H) (x : Fin n → ℝ) : + ‖b.equivFun.symm x‖ ≤ (n : ℝ) * H * ‖x‖ := by + rw [Basis.equivFun_symm_apply] + calc + _ ≤ ∑ i, ‖x i • b i‖ := norm_sum_le _ _ + _ ≤ ∑ _i : Fin n, ‖x‖ * H := by + apply Finset.sum_le_sum + intro i _ + rw [norm_smul] + exact mul_le_mul (norm_le_pi_norm x i) (hb i) (norm_nonneg _) (norm_nonneg _) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + ring + +theorem basis_coordinates_norm_le_of_covolume {E : Type*} {n : ℕ} + [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + [MeasurableSpace E] [BorelSpace E] + (o : OrthonormalBasis (Fin n) ℝ E) (b : Basis (Fin n) ℝ E) + {H κ : ℝ} (hH : 0 ≤ H) (hκ : 0 < κ) (hb : ∀ i, ‖b i‖ ≤ H) + (hcovol : κ ≤ ZLattice.covolume (span ℤ (Set.range b))) (x : E) : + ‖b.equivFun x‖ ≤ ((n : ℝ) * n.factorial * H ^ (n - 1) / κ) * ‖x‖ := by + classical + let A := o.toBasis.toMatrix b + have hdet : κ ≤ |A.det| := by + simpa only [covolume_basis_eq_orthonormal_det o b, Basis.det_apply] using hcovol + have hentry : ∀ i j, |A i j| ≤ H := fun i j => + (orthonormal_basis_coordinate_abs_le o (b j) i).trans (hb j) + have hinv : ∀ i j, |A⁻¹ i j| ≤ (n.factorial : ℝ) * H ^ (n - 1) / κ := by + intro i j + simpa only [Fintype.card_fin] using matrix_inverse_entry_abs_le A hentry hκ hdet i j + have hM : A *ᵥ (b.equivFun x) = o.toBasis.equivFun x := + basis_coordinate_matrix_mulVec b o.toBasis.equivFun.toLinearMap x + have hback : A⁻¹ *ᵥ (o.toBasis.equivFun x) = b.equivFun x := by + rw [← hM, Matrix.mulVec_mulVec, + Matrix.nonsing_inv_mul A (isUnit_iff_ne_zero.mpr (abs_pos.mp (hκ.trans_le hdet))), + Matrix.one_mulVec] + apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr + intro i + rw [← hback, Real.norm_eq_abs] + change |∑ j, A⁻¹ i j * o.toBasis.equivFun x j| ≤ _ + calc + _ ≤ ∑ j, |A⁻¹ i j * o.toBasis.equivFun x j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : Fin n, ((n.factorial : ℝ) * H ^ (n - 1) / κ) * ‖x‖ := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + exact mul_le_mul (hinv i j) (orthonormal_basis_coordinate_abs_le o x j) + (abs_nonneg _) (by positivity) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule MeasureTheory +open scoped BigOperators + +variable {E : Type*} {n : ℕ} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] + +theorem normalizedAxisBasis_covolume (o : OrthonormalBasis (Fin n) ℝ E) + (b : Basis (Fin n) ℝ E) : + ZLattice.covolume (span ℤ (Set.range (normalizedAxisBasis b))) = + (∏ i, (basisAxisScale b i : ℝ)) * ZLattice.covolume (span ℤ (Set.range b)) := + covolume_basis_scale o b (normalizedAxisBasis b) (fun i => (basisAxisScale b i : ℝ)) + (fun _ => Nat.cast_nonneg _) (normalizedAxisBasis_apply b) + +theorem normalizedAxisBasis_covolume_lower (o : OrthonormalBasis (Fin n) ℝ E) + (b : Basis (Fin n) ℝ E) {D : ℝ} (hD : 0 < D) + (hb : (∏ i, ‖b i‖) ≤ D * ZLattice.covolume (span ℤ (Set.range b))) : + 1 / D ≤ ZLattice.covolume (span ℤ (Set.range (normalizedAxisBasis b))) := by + have hprod : 1 ≤ ∏ i, ‖normalizedAxisBasis b i‖ := by + apply Finset.one_le_prod₀ + intro i _ + rw [normalizedAxisBasis_norm] + exact (basisAxisScale_mul_norm b i).1 + have hupper : (∏ i, ‖normalizedAxisBasis b i‖) ≤ + D * ZLattice.covolume (span ℤ (Set.range (normalizedAxisBasis b))) := by + rw [normalizedAxisBasis_norm_product, normalizedAxisBasis_covolume o b] + calc + _ ≤ (∏ i, (basisAxisScale b i : ℝ)) * + (D * ZLattice.covolume (span ℤ (Set.range b))) := + mul_le_mul_of_nonneg_left hb (Finset.prod_nonneg (fun _ _ => Nat.cast_nonneg _)) + _ = _ := by ring + apply (div_le_iff₀ hD).mpr + simpa only [mul_comm] using hprod.trans hupper + +theorem normalizedAxisBasis_covolume_upper (o : OrthonormalBasis (Fin n) ℝ E) + (b : Basis (Fin n) ℝ E) {B : ℝ} (hb : ∀ i, ‖b i‖ ≤ B) : + ZLattice.covolume (span ℤ (Set.range (normalizedAxisBasis b))) ≤ + (n.factorial : ℝ) * (B + 1) ^ n := by + simpa only [Fintype.card_fin] using covolume_basis_le_norm_bound o (normalizedAxisBasis b) + (fun i => (normalizedAxisBasis_norm_bounds b hb i).2) + +theorem normalizedAxisBasis_coordinates_bound (o : OrthonormalBasis (Fin n) ℝ E) + (b : Basis (Fin n) ℝ E) {B D : ℝ} (hB : 0 ≤ B) (hD : 0 < D) + (hb : ∀ i, ‖b i‖ ≤ B) + (hprod : (∏ i, ‖b i‖) ≤ D * ZLattice.covolume (span ℤ (Set.range b))) (x : E) : + ‖(normalizedAxisBasis b).equivFun x‖ ≤ + ((n : ℝ) * n.factorial * (B + 1) ^ (n - 1) * D) * ‖x‖ := by + have h := basis_coordinates_norm_le_of_covolume o (normalizedAxisBasis b) + (by positivity : 0 ≤ B + 1) (one_div_pos.mpr hD) + (fun i => (normalizedAxisBasis_norm_bounds b hb i).2) + (normalizedAxisBasis_covolume_lower o b hD hprod) x + simpa only [one_div, div_inv_eq_mul] using h + +omit [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] in +theorem normalizedAxisBasis_synthesis_bound (b : Basis (Fin n) ℝ E) {B : ℝ} + (hb : ∀ i, ‖b i‖ ≤ B) (x : Fin n → ℝ) : + ‖(normalizedAxisBasis b).equivFun.symm x‖ ≤ (n : ℝ) * (B + 1) * ‖x‖ := + basis_synthesis_norm_le (normalizedAxisBasis b) + (fun i => (normalizedAxisBasis_norm_bounds b hb i).2) x + +theorem normalizedAxisBasis_reciprocal_covolume (o : OrthonormalBasis (Fin n) ℝ E) + (b : Basis (Fin n) ℝ E) {q : ℝ} + (hq : q * ZLattice.covolume (span ℤ (Set.range b)) = 1) : + q / (∏ i, (basisAxisScale b i : ℝ)) = + 1 / ZLattice.covolume (span ℤ (Set.range (normalizedAxisBasis b))) := by + have hc := (ZLattice.covolume_pos (span ℤ (Set.range b)) volume).ne' + have hp : (∏ i, (basisAxisScale b i : ℝ)) ≠ 0 := + (Finset.prod_pos (fun i _ => Nat.cast_pos.mpr (basisAxisScale_pos b i))).ne' + have heq : q = 1 / ZLattice.covolume (span ℤ (Set.range b)) := (eq_div_iff hc).mpr hq + rw [heq, normalizedAxisBasis_covolume o b] + field_simp [hp, hc] + +theorem normalizedAxisBasis_covolume_ratio_bounds (o : OrthonormalBasis (Fin n) ℝ E) + (b : Basis (Fin n) ℝ E) {B D q : ℝ} (hD : 0 < D) + (hb : ∀ i, ‖b i‖ ≤ B) + (hprod : (∏ i, ‖b i‖) ≤ D * ZLattice.covolume (span ℤ (Set.range b))) + (hq : q * ZLattice.covolume (span ℤ (Set.range b)) = 1) : + 1 / ((n.factorial : ℝ) * (B + 1) ^ n) ≤ q / (∏ i, (basisAxisScale b i : ℝ)) ∧ + q / (∏ i, (basisAxisScale b i : ℝ)) ≤ D := by + rw [normalizedAxisBasis_reciprocal_covolume o b hq] + have hpos := ZLattice.covolume_pos (span ℤ (Set.range (normalizedAxisBasis b))) volume + refine ⟨div_le_div_of_nonneg_left zero_le_one hpos + (normalizedAxisBasis_covolume_upper o b hb), ?_⟩ + apply (div_le_iff₀ hpos).mpr + have h := (div_le_iff₀ hD).mp (normalizedAxisBasis_covolume_lower o b hD hprod) + simpa only [mul_comm] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/OrderedBasisCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Linear/OrderedBasisCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..327242c03f03e06df8b75d311b5e4b94c0db51b2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/OrderedBasisCoordinates.lean @@ -0,0 +1,187 @@ +import Mathlib.Algebra.Group.Submonoid.BigOperators +import Mathlib.Data.List.FinRange +import Mathlib.Data.List.TakeDrop +import OAI.Combinatorics.Progressions.Nilpotent.BCHOrderedReduction + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem mem_drop_finRange_iff {d i : ℕ} {j : Fin d} : + j ∈ (List.finRange d).drop i ↔ i ≤ j.val := by + rw [List.mem_drop_iff_getElem] + constructor + · rintro ⟨k, hk, heq⟩ + have hval : i + k = j.val := by simpa using congrArg Fin.val heq + omega + · intro hij + refine ⟨j.val - i, ?_, ?_⟩ + · simp only [List.length_finRange] + omega + · apply Fin.ext + simp only [List.getElem_finRange, Fin.val_cast] + omega + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d s : ℕ} + (e : Basis (Fin d) ℚ L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + +noncomputable def orderedBasisTailProduct (i : ℕ) (t : Fin d → ℚ) : + NilpotentLieBCHGroup L s hnil := + (((List.finRange d).drop i).map fun j => (⟨t j • e j⟩ : NilpotentLieBCHGroup L s hnil)).prod + +noncomputable def orderedBasisProduct (t : Fin d → ℚ) : NilpotentLieBCHGroup L s hnil := + orderedBasisTailProduct e hnil 0 t + +theorem orderedBasisTailProduct_terminal {i : ℕ} (hi : d ≤ i) (t : Fin d → ℚ) : + orderedBasisTailProduct e hnil i t = 1 := by + simp only [orderedBasisTailProduct, + List.drop_eq_nil_of_le (as := List.finRange d) (i := i) (by simpa using hi), + List.map_nil, List.prod_nil] + +theorem orderedBasisTailProduct_step (j : Fin d) (t : Fin d → ℚ) : + orderedBasisTailProduct e hnil j.val t = + (⟨t j • e j⟩ : NilpotentLieBCHGroup L s hnil) * orderedBasisTailProduct e hnil (j.val + 1) t := by + unfold orderedBasisTailProduct + rw [List.drop_eq_getElem_cons (by simp), List.map_cons, List.prod_cons] + simp only [List.getElem_finRange, Fin.cast_mk, Fin.eta] + +theorem orderedBasisTailProduct_congr (i : ℕ) {t u : Fin d → ℚ} + (h : ∀ j : Fin d, i ≤ j.val → t j = u j) : + orderedBasisTailProduct e hnil i t = orderedBasisTailProduct e hnil i u := by + apply congrArg List.prod + apply List.map_congr_left + intro j hj + rw [h j (mem_drop_finRange_iff.mp hj)] + +namespace IsCentralLieBasis + +variable {e} (he : IsCentralLieBasis e) +include he + +theorem orderedBasisTailProduct_mem_tail (i : ℕ) (t : Fin d → ℚ) : + (orderedBasisTailProduct e hnil i t).coord ∈ basisTail e i := by + change orderedBasisTailProduct e hnil i t ∈ + NilpotentLieBCHGroup.subgroup (he.tailIdeal i).toLieSubalgebra + unfold orderedBasisTailProduct + apply list_prod_mem + intro g hg + obtain ⟨j, hj, rfl⟩ := List.mem_map.mp hg + exact (basisTail e i).smul_mem _ (basis_mem_tail e j (mem_drop_finRange_iff.mp hj)) + +theorem orderedBasisTailProduct_leading (j : Fin d) (t : Fin d → ℚ) : + e.repr (orderedBasisTailProduct e hnil j.val t).coord j = t j := by + rw [orderedBasisTailProduct_step] + exact he.leading_coordinate hnil j (t j) _ (he.orderedBasisTailProduct_mem_tail hnil _ t) + +end IsCentralLieBasis +end Erdos3 + +end + +section + +namespace Erdos3.IsCentralLieBasis + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d s : ℕ} + {e : Basis (Fin d) ℚ L} (he : IsCentralLieBasis e) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + +include he + +theorem exists_orderedBasisTailProduct_aux (k i : ℕ) (hik : i + k = d) + (g : NilpotentLieBCHGroup L s hnil) (hg : g.coord ∈ basisTail e i) : + ∃ t : Fin d → ℚ, orderedBasisTailProduct e hnil i t = g := by + classical + induction k generalizing i g with + | zero => + have hi : i = d := by omega + subst i + refine ⟨fun _ => 0, ?_⟩ + rw [orderedBasisTailProduct_terminal e hnil le_rfl] + apply NilpotentLieBCHGroup.ext + have hz : g.coord = 0 := by + simpa only [basisTail_terminal, Submodule.mem_bot] using hg + exact hz.symm + | succ k ih => + have hi : i < d := by omega + let j : Fin d := ⟨i, hi⟩ + let c : ℚ := e.repr g.coord j + let a : NilpotentLieBCHGroup L s hnil := ⟨c • e j⟩ + let r := a⁻¹ * g + have hr : r.coord ∈ basisTail e (i + 1) := he.peel_mem_tail hnil j g hg + obtain ⟨t, ht⟩ := ih (i + 1) (by omega) r hr + let u := Function.update t j c + have huj : u j = c := by simp [u] + have hu : orderedBasisTailProduct e hnil (i + 1) u = + orderedBasisTailProduct e hnil (i + 1) t := by + apply orderedBasisTailProduct_congr + intro l hl + have hlj : l ≠ j := by + intro h + subst l + change i + 1 ≤ i at hl + omega + exact Function.update_of_ne hlj .. + refine ⟨u, ?_⟩ + change orderedBasisTailProduct e hnil j.val u = g + rw [orderedBasisTailProduct_step, huj] + change a * orderedBasisTailProduct e hnil (i + 1) u = g + rw [hu, ht] + exact mul_inv_cancel_left a g + +theorem exists_orderedBasisTailProduct {i : ℕ} (hi : i ≤ d) + (g : NilpotentLieBCHGroup L s hnil) (hg : g.coord ∈ basisTail e i) : + ∃ t : Fin d → ℚ, orderedBasisTailProduct e hnil i t = g := + he.exists_orderedBasisTailProduct_aux hnil (d - i) i (Nat.add_sub_of_le hi) g hg + +theorem orderedBasisProduct_surjective : Function.Surjective (orderedBasisProduct e hnil) := by + intro g + exact he.exists_orderedBasisTailProduct hnil (Nat.zero_le d) g (by simp [basisTail_zero]) + +theorem orderedBasisTailProduct_eq_of_product_eq {t u : Fin d → ℚ} + (h : orderedBasisProduct e hnil t = orderedBasisProduct e hnil u) + (i : ℕ) (hi : i ≤ d) : + orderedBasisTailProduct e hnil i t = orderedBasisTailProduct e hnil i u := by + induction i with + | zero => exact h + | succ i ih => + have hid : i < d := by omega + let j : Fin d := ⟨i, hid⟩ + have ht := ih (by omega) + change orderedBasisTailProduct e hnil j.val t = + orderedBasisTailProduct e hnil j.val u at ht + have hc : t j = u j := by + have hc := congrArg (fun g => e.repr g.coord j) ht + simpa only [he.orderedBasisTailProduct_leading hnil j] using hc + rw [orderedBasisTailProduct_step, orderedBasisTailProduct_step, hc] at ht + exact mul_left_cancel ht + +theorem orderedBasisProduct_injective : Function.Injective (orderedBasisProduct e hnil) := by + intro t u h + funext j + have ht := he.orderedBasisTailProduct_eq_of_product_eq hnil h j.val (Nat.le_of_lt j.isLt) + have hc := congrArg (fun g => e.repr g.coord j) ht + simpa only [he.orderedBasisTailProduct_leading hnil j] using hc + +noncomputable def orderedBasisEquiv : (Fin d → ℚ) ≃ NilpotentLieBCHGroup L s hnil := + Equiv.ofBijective (orderedBasisProduct e hnil) + ⟨he.orderedBasisProduct_injective hnil, he.orderedBasisProduct_surjective hnil⟩ + +theorem orderedBasisEquiv_apply (t : Fin d → ℚ) : + he.orderedBasisEquiv hnil t = orderedBasisProduct e hnil t := rfl + +theorem orderedBasisProduct_coordinates (g : NilpotentLieBCHGroup L s hnil) : + orderedBasisProduct e hnil ((he.orderedBasisEquiv hnil).symm g) = g := + (he.orderedBasisEquiv hnil).apply_symm_apply g + +end Erdos3.IsCentralLieBasis + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/OrdinarySymbolBasisDimension.lean b/lean/OAI/Combinatorics/Progressions/Linear/OrdinarySymbolBasisDimension.lean new file mode 100644 index 0000000000000000000000000000000000000000..eeca0aa4dd92408d9295559cd2625181b83296a9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/OrdinarySymbolBasisDimension.lean @@ -0,0 +1,237 @@ +import OAI.Combinatorics.Progressions.Dynamics.PointwiseSymbolBudget +import OAI.Combinatorics.Progressions.Estimates.ProjectedPointwiseCoefficient + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial + +variable {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (w : σ → ℕ) + +theorem homogeneousSymbolLift_mem_pointwise (U : LieSubalgebra ℚ F.AssociatedGraded) + (hU : BasisGradedSubmodule (F.associatedGradedBasis b ω hlayers) ω U.toSubmodule) + (α : σ →₀ ℕ) (v : F.AssociatedGraded) (hv : v ∈ U) : + F.homogeneousSymbolLift b ω hlayers w α v ∈ F.symbolPointwiseSubalgebra b ω hlayers w U := by + classical + rw [F.mem_symbolPointwiseSubalgebra_iff] + intro β + rw [F.gradedSymbolPolynomial_homogeneousSymbolLift, coefficients_monomial] + by_cases h : α = β + · subst β + rw [Finsupp.single_eq_same] + exact hU (Finsupp.weight w α) v hv + · rw [Finsupp.single_eq_of_ne (Ne.symm h)] + exact U.zero_mem + +noncomputable def pointwiseSymbolSpanningFamily (v : κ → F.AssociatedGraded) : + SymbolBasisIndex w ω × κ → F.PolynomialSymbol w := + fun z => F.homogeneousSymbolLift b ω hlayers w z.1.val.1 (v z.2) + +theorem pointwiseSymbolSpanningFamily_span [Fintype (SymbolBasisIndex w ω)] + (U : LieSubalgebra ℚ F.AssociatedGraded) + (hU : BasisGradedSubmodule (F.associatedGradedBasis b ω hlayers) ω U.toSubmodule) + (v : κ → F.AssociatedGraded) (hspan : Submodule.span ℚ (Set.range v) = U.toSubmodule) : + Submodule.span ℚ (Set.range (F.pointwiseSymbolSpanningFamily b ω hlayers w v)) = + (F.symbolPointwiseSubalgebra b ω hlayers w U).toSubmodule := by + classical + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨z, rfl⟩ + apply F.homogeneousSymbolLift_mem_pointwise b ω hlayers w U hU + change v z.2 ∈ U.toSubmodule + rw [← hspan] + exact Submodule.subset_span ⟨z.2, rfl⟩ + · intro x hx + rw [← sum_basisBlockProjection (F.polynomialSymbolBasis b ω hlayers w) (fun z => z.val.1) x] + apply Submodule.sum_mem + intro α hα + obtain ⟨z, _, rfl⟩ := Finset.mem_image.mp hα + rw [← F.homogeneousSymbolLift_coefficient] + let W := Submodule.span ℚ (Set.range (F.pointwiseSymbolSpanningFamily b ω hlayers w v)) + have hmap : U.toSubmodule ≤ W.comap (F.homogeneousSymbolLift b ω hlayers w z.val.1) := by + rw [← hspan] + apply Submodule.span_le.mpr + rintro _ ⟨j, rfl⟩ + exact Submodule.subset_span ⟨(z, j), rfl⟩ + exact hmap ((F.mem_symbolPointwiseSubalgebra_iff b ω hlayers w U x).mp hx z.val.1) + +theorem pointwiseSymbolSpanningFamily_height (v : κ → F.AssociatedGraded) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ j i, RationalHeightLE ((F.associatedGradedBasis b ω hlayers).repr (v j) i) H) : + ∀ z i, RationalHeightLE ((F.polynomialSymbolBasis b ω hlayers w).repr + (F.pointwiseSymbolSpanningFamily b ω hlayers w v z) i) H := by + classical + intro z i + change RationalHeightLE ((F.polynomialSymbolBasis b ω hlayers w).repr + (F.homogeneousSymbolLift b ω hlayers w z.1.val.1 (v z.2)) i) H + rw [F.homogeneousSymbolLift_coordinate] + split_ifs + · exact hv z.2 i.val.2 + · exact rationalHeightLE_zero hH + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +def pointwiseFastSectionInput (s : ℕ) (p : ℝ) : ℝ := + 2 * (p + (s + 3)) ^ (s + 3) + ((p + (s + 3)) ^ (s + 3)) ^ 2 + p + +theorem pointwiseFastSectionInput_ge (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + p ≤ pointwiseFastSectionInput s p := by + unfold pointwiseFastSectionInput + exact le_add_of_nonneg_left (by positivity) + +theorem symbolBasisIndex_card_le_spanning_budget + {σ ι L : Type*} [Fintype σ] [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (w : σ → ℕ) (hw : ∀ i, 0 < w i) [Fintype (SymbolBasisIndex w ω)] + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hσ : (Fintype.card σ : ℝ) ≤ p) : + (Fintype.card (SymbolBasisIndex w ω) : ℝ) ≤ (p + (s + 3)) ^ (s + 3) := by + apply (Nat.cast_le.mpr (symbolBasisIndex_card_le w ω s hw + (F.adaptedBasis_weight_le_step b ω hF))).trans + apply (symbol_dimension_bound_le_power s (Fintype.card ι) (Fintype.card σ) hp hι hσ).trans + apply (pow_le_pow_left₀ (by positivity : 0 ≤ p + (s + 2)) + (by linarith : p + (s + 2 : ℝ) ≤ p + (s + 3)) (s + 2)).trans + exact pow_le_pow_right₀ (by have := Nat.cast_nonneg (α := ℝ) s; linarith) (by omega) + +theorem pointwiseSymbolSpanning_section_counts + {σ ι κ ξ L M : Type*} [Fintype σ] [Fintype ι] [Fintype κ] [Fintype ξ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] {s : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M s) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (c : Basis κ ℚ M) (τ : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + (w : σ → ℕ) (hw : ∀ i, 0 < w i) + [Fintype (SymbolBasisIndex w ω)] [Fintype (SymbolBasisIndex w τ)] + {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) (hξ : (Fintype.card ξ : ℝ) ≤ p) + (hσ : (Fintype.card σ : ℝ) ≤ p) : + (Fintype.card (SymbolBasisIndex w ω × ξ) : ℝ) ≤ pointwiseFastSectionInput s p ∧ + (Fintype.card (SymbolBasisIndex w ω ⊕ SymbolBasisIndex w τ) : ℝ) ≤ + pointwiseFastSectionInput s p ∧ + ((Fintype.card (SymbolBasisIndex w ω) * + Fintype.card (SymbolBasisIndex w ω × ξ) : ℕ) : ℝ) ≤ pointwiseFastSectionInput s p := by + let A : ℝ := (p + (s + 3)) ^ (s + 3) + have hA : 0 ≤ A := by dsimp [A]; positivity + have hb := F.symbolBasisIndex_card_le_spanning_budget b ω hF w hw hp hι hσ + have hc := G.symbolBasisIndex_card_le_spanning_budget c τ hG w hw hp hκ hσ + have hv : (Fintype.card (SymbolBasisIndex w ω × ξ) : ℝ) ≤ A := by + have hnat : Fintype.card (SymbolBasisIndex w ω × ξ) ≤ + Fintype.card ι * (s + 1) * (Fintype.card σ + 1) ^ s * Fintype.card ξ := by + rw [Fintype.card_prod] + exact Nat.mul_le_mul_right _ (symbolBasisIndex_card_le w ω s hw + (F.adaptedBasis_weight_le_step b ω hF)) + exact (Nat.cast_le.mpr hnat).trans (symbol_spanning_count_bound s _ _ _ hp hι hσ hξ) + have hrows : (Fintype.card (SymbolBasisIndex w ω ⊕ SymbolBasisIndex w τ) : ℝ) ≤ 2 * A := by + rw [Fintype.card_sum, Nat.cast_add] + dsimp only [A] + linarith + have hcols : ((Fintype.card (SymbolBasisIndex w ω) * + Fintype.card (SymbolBasisIndex w ω × ξ) : ℕ) : ℝ) ≤ A ^ 2 := by + rw [Nat.cast_mul, pow_two] + exact mul_le_mul hb hv (Nat.cast_nonneg _) hA + change _ ≤ 2 * A + A ^ 2 + p ∧ _ ≤ 2 * A + A ^ 2 + p ∧ _ ≤ 2 * A + A ^ 2 + p + refine ⟨hv.trans ?_, hrows.trans ?_, hcols.trans ?_⟩ <;> nlinarith [sq_nonneg A] + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {σ ι L : Type*} [Fintype σ] [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +@[instance_reducible] noncomputable def ordinarySymbolBasisFintype : + Fintype (SymbolBasisIndex (fun _ : σ => 1) ω) := + symbolBasisIndexFintype (fun _ : σ => 1) ω s (fun _ => Nat.zero_lt_one) + (F.adaptedBasis_weight_le_step b ω hF) + +include hF + +theorem ordinarySymbolBasisIndex_card_le + [Fintype (SymbolBasisIndex (fun _ : σ => 1) ω)] + {p : ℝ} (hp : 0 ≤ p) + (hdimension : (Fintype.card ι : ℝ) + (Fintype.card σ : ℝ) ≤ p) : + (Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) : ℝ) ≤ + (p + (s + 3)) ^ (s + 3) := by + apply F.symbolBasisIndex_card_le_spanning_budget b ω hF (fun _ : σ => 1) + (fun _ => Nat.zero_lt_one) hp + · exact (le_add_of_nonneg_right (Nat.cast_nonneg _)).trans hdimension + · exact (le_add_of_nonneg_left (Nat.cast_nonneg _)).trans hdimension + +theorem ordinarySymbolBasisFintype_card_le + {p : ℝ} (hp : 0 ≤ p) + (hdimension : (Fintype.card ι : ℝ) + (Fintype.card σ : ℝ) ≤ p) : + (@Fintype.card (SymbolBasisIndex (fun _ : σ => 1) ω) + (F.ordinarySymbolBasisFintype b ω hF) : ℝ) ≤ + (p + (s + 3)) ^ (s + 3) := by + let : Fintype (SymbolBasisIndex (fun _ : σ => 1) ω) := + F.ordinarySymbolBasisFintype b ω hF + exact F.ordinarySymbolBasisIndex_card_le b ω hF hp hdimension + +theorem ordinaryPolynomialSymbol_finrank_le + {p : ℝ} (hp : 0 ≤ p) + (hdimension : (Fintype.card ι : ℝ) + (Fintype.card σ : ℝ) ≤ p) : + (finrank ℚ (F.PolynomialSymbol (fun _ : σ => 1)) : ℝ) ≤ + (p + (s + 3)) ^ (s + 3) := by + let : Fintype (SymbolBasisIndex (fun _ : σ => 1) ω) := + F.ordinarySymbolBasisFintype b ω hF + rw [finrank_eq_card_basis (F.polynomialSymbolBasis b ω hF (fun _ : σ => 1))] + exact F.ordinarySymbolBasisIndex_card_le b ω hF hp hdimension + +omit hF in + +theorem pointwiseFastSectionInput_le_envelope (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + pointwiseFastSectionInput s p ≤ (p + (s + 5)) ^ (2 * (s + 4)) := by + let A : ℝ := (p + (s + 3)) ^ (s + 3) + let B : ℝ := (p + (s + 5)) ^ (s + 3) + have hs : (0 : ℝ) ≤ s := Nat.cast_nonneg s + have hx : 1 ≤ p + (s + 3 : ℝ) := by linarith + have hy : 2 ≤ p + (s + 5 : ℝ) := by linarith + have hA : 1 ≤ A := one_le_pow₀ hx + have hpA : p ≤ A := by + calc + p ≤ p + (s + 3 : ℝ) := by linarith + _ = (p + (s + 3 : ℝ)) ^ 1 := by simp + _ ≤ A := pow_le_pow_right₀ hx (by omega) + have hAB : A ≤ B := pow_le_pow_left₀ (by positivity) + (by linarith : p + (s + 3 : ℝ) ≤ p + (s + 5 : ℝ)) _ + have hABsq : A ^ 2 ≤ B ^ 2 := pow_le_pow_left₀ (by positivity) hAB 2 + have hy2 : 4 ≤ (p + (s + 5 : ℝ)) ^ 2 := by nlinarith + change 2 * A + A ^ 2 + p ≤ _ + calc + 2 * A + A ^ 2 + p ≤ 4 * A ^ 2 := by nlinarith [sq_nonneg (A - 1)] + _ ≤ (p + (s + 5 : ℝ)) ^ 2 * B ^ 2 := + mul_le_mul hy2 hABsq (sq_nonneg _) (sq_nonneg _) + _ = (p + (s + 5)) ^ (2 * (s + 4)) := by + dsimp [B] + rw [← pow_mul, ← pow_add] + congr 1 + omega + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/OrthogonalBasisChart.lean b/lean/OAI/Combinatorics/Progressions/Linear/OrthogonalBasisChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a794f0e0fa1cb3eb0af5bda1eb7cbc6be42d799 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/OrthogonalBasisChart.lean @@ -0,0 +1,79 @@ +import Mathlib.Analysis.InnerProductSpace.Projection.Submodule +import Mathlib.Analysis.Normed.Module.FiniteDimension + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {E : Type*} {n : ℕ} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [FiniteDimensional ℝ E] + +noncomputable def orthogonalBasisCoordinates (W : Submodule ℝ E) (b : Basis (Fin n) ℝ Wᗮ) : + E ≃ₗ[ℝ] W × (Fin n → ℝ) where + toFun x := (W.orthogonalProjectionOnto x, b.equivFun (Wᗮ.orthogonalProjectionOnto x)) + invFun p := p.1.val + (b.equivFun.symm p.2).val + left_inv x := by + change W.starProjection x + (b.equivFun.symm (b.equivFun (Wᗮ.orthogonalProjectionOnto x))).val = x + rw [LinearEquiv.symm_apply_apply] + exact W.starProjection_add_starProjection_orthogonal x + right_inv p := by + apply Prod.ext + · change W.orthogonalProjectionOnto (p.1.val + (b.equivFun.symm p.2).val) = p.1 + rw [map_add, W.orthogonalProjectionOnto_apply_of_mem_orthogonal + (b.equivFun.symm p.2).property, add_zero] + apply Subtype.ext + exact W.starProjection_eq_self_iff.mpr p.1.property + · change b.equivFun (Wᗮ.orthogonalProjectionOnto (p.1.val + (b.equivFun.symm p.2).val)) = p.2 + rw [map_add, W.orthogonalProjectionOnto_orthogonal_apply_eq_zero p.1.property, zero_add] + have he : Wᗮ.orthogonalProjectionOnto (b.equivFun.symm p.2).val = b.equivFun.symm p.2 := by + apply Subtype.ext + exact Wᗮ.starProjection_eq_self_iff.mpr (b.equivFun.symm p.2).property + rw [he, LinearEquiv.apply_symm_apply] + map_add' x y := by + apply Prod.ext <;> simp + map_smul' a x := by + apply Prod.ext <;> simp + +noncomputable def orthogonalBasisChart (W : Submodule ℝ E) (b : Basis (Fin n) ℝ Wᗮ) : + E ≃L[ℝ] W × (Fin n → ℝ) := (orthogonalBasisCoordinates W b).toContinuousLinearEquiv + +theorem orthogonalBasisChart_apply (W : Submodule ℝ E) (b : Basis (Fin n) ℝ Wᗮ) (x : E) : + orthogonalBasisChart W b x = + (W.orthogonalProjectionOnto x, b.equivFun (Wᗮ.orthogonalProjectionOnto x)) := rfl + +theorem orthogonalBasisChart_symm_apply (W : Submodule ℝ E) (b : Basis (Fin n) ℝ Wᗮ) + (p : W × (Fin n → ℝ)) : + (orthogonalBasisChart W b).symm p = p.1.val + (b.equivFun.symm p.2).val := rfl + +theorem orthogonalBasisChart_norm_le (W : Submodule ℝ E) (b : Basis (Fin n) ℝ Wᗮ) + {C : ℝ} (hC : 0 ≤ C) (hb : ∀ x, ‖b.equivFun x‖ ≤ C * ‖x‖) (x : E) : + ‖orthogonalBasisChart W b x‖ ≤ (1 + C) * ‖x‖ := by + rw [orthogonalBasisChart_apply, Prod.norm_def] + apply max_le + · have h := W.norm_orthogonalProjectionOnto_apply_le x + nlinarith [norm_nonneg x] + · calc + _ ≤ C * ‖Wᗮ.orthogonalProjectionOnto x‖ := hb _ + _ ≤ C * ‖x‖ := mul_le_mul_of_nonneg_left (Wᗮ.norm_orthogonalProjectionOnto_apply_le x) hC + _ ≤ _ := by nlinarith [norm_nonneg x] + +theorem orthogonalBasisChart_symm_norm_le (W : Submodule ℝ E) (b : Basis (Fin n) ℝ Wᗮ) + {C : ℝ} (hC : 0 ≤ C) (hb : ∀ x, ‖b.equivFun.symm x‖ ≤ C * ‖x‖) + (p : W × (Fin n → ℝ)) : + ‖(orthogonalBasisChart W b).symm p‖ ≤ (1 + C) * ‖p‖ := by + rw [orthogonalBasisChart_symm_apply] + calc + _ ≤ ‖p.1‖ + ‖b.equivFun.symm p.2‖ := norm_add_le _ _ + _ ≤ ‖p.1‖ + C * ‖p.2‖ := by gcongr; exact hb _ + _ ≤ ‖p‖ + C * ‖p‖ := by gcongr; exact norm_fst_le p; exact norm_snd_le p + _ = _ := by ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PeriodicKernelPartition.lean b/lean/OAI/Combinatorics/Progressions/Linear/PeriodicKernelPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..6935d0988c9a599c4fe66915ea13a55713e6800c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PeriodicKernelPartition.lean @@ -0,0 +1,111 @@ +import OAI.Combinatorics.Progressions.Dynamics.FlatPatchReset +import OAI.Combinatorics.Progressions.Estimates.NormalizedCutoffs + +namespace OAI + +section + +namespace Erdos3.PatchKernel + +open scoped NNReal + +variable {d : ℕ} {ι : Type*} [Fintype ι] + +noncomputable def translateSum (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (x : Fin d → ℝ) : ℝ := ∑ i, Φ.periodicValue (x - c i) + +theorem translateSum_nonneg (Φ : PatchKernel d) (c : ι → Fin d → ℝ) (x : Fin d → ℝ) : + 0 ≤ Φ.translateSum c x := Finset.sum_nonneg (fun i _ => (Φ.periodicValue_mem_Icc (x - c i)).1) + +theorem periodicValue_le_translateSum (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (i : ι) (x : Fin d → ℝ) : Φ.periodicValue (x - c i) ≤ Φ.translateSum c x := by + exact Finset.single_le_sum (f := fun j => Φ.periodicValue (x - c j)) + (fun j _ => (Φ.periodicValue_mem_Icc (x - c j)).1) (Finset.mem_univ i) + +theorem abs_translateSum_sub_le (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (x y : Fin d → ℝ) : + |Φ.translateSum c x - Φ.translateSum c y| ≤ Fintype.card ι * Φ.lip * dist x y := by + unfold translateSum + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ i, |Φ.periodicValue (x - c i) - Φ.periodicValue (y - c i)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : ι, (Φ.lip : ℝ) * dist x y := by + apply Finset.sum_le_sum + intro i _ + simpa only [Real.dist_eq, dist_sub_right] using Φ.periodicValue_lipschitz.dist_le_mul + (x - c i) (y - c i) + _ = _ := by simp [mul_assoc] + +theorem translateSum_integer_periodic (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (x : Fin d → ℝ) (m : Fin d → ℤ) : + Φ.translateSum c (fun j => x j + m j) = Φ.translateSum c x := by + apply Finset.sum_congr rfl + intro i _ + have heq : (fun j => x j + (m j : ℝ)) - c i = fun j => (x - c i) j + m j := by + funext j + simp only [Pi.sub_apply] + ring + rw [heq, Φ.periodicValue_integer_periodic] + +theorem kernel_le_translateSum (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (i : ι) (x : Fin d → ℝ) : Φ.value x ≤ Φ.translateSum c (c i - x) := by + have hk := Φ.kernel_le_periodicValue (-x) 0 + have hs := Φ.periodicValue_le_translateSum c i (c i - x) + have heq : c i - x - c i = -x := by abel + rw [heq] at hs + simpa only [Pi.zero_apply, Int.cast_zero, Pi.neg_apply, zero_sub, neg_neg] using hk.trans hs + +noncomputable def normalizedTranslate (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (δ : ℝ≥0) (hδ : 0 < δ) (hcover : ∀ x, (δ : ℝ) ≤ Φ.translateSum c x) (i : ι) : + PatchKernel d where + value x := Φ.value x / Φ.translateSum c (c i - x) + nonneg x := div_nonneg (Φ.nonneg x) (Φ.translateSum_nonneg c _) + le_one x := by + apply (div_le_one ((show (0 : ℝ) < δ from hδ).trans_le (hcover (c i - x)))).mpr + exact Φ.kernel_le_translateSum c i x + support x hx := Φ.support x (fun h => hx (by simp only [h, zero_div])) + lip := Φ.lip / δ + Fintype.card ι * Φ.lip / (δ * δ) + lipschitz := by + apply LipschitzWith.of_dist_le_mul + intro x y + have hnum := Φ.lipschitz.dist_le_mul x y + have hden := Φ.abs_translateSum_sub_le c (c i - x) (c i - y) + rw [dist_sub_left] at hden + have h := abs_div_sub_div_bound (show (0 : ℝ) < δ from hδ) (hcover _) (hcover _) + (mul_nonneg Φ.lip.coe_nonneg dist_nonneg) zero_le_one + (by positivity : 0 ≤ (Fintype.card ι : ℝ) * Φ.lip * dist x y) + hnum (by rw [abs_of_nonneg (Φ.nonneg _)]; exact Φ.le_one _) hden + apply h.trans_eq + push_cast + ring + +theorem normalizedTranslate_periodicValue (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (δ : ℝ≥0) (hδ : 0 < δ) (hcover : ∀ x, (δ : ℝ) ≤ Φ.translateSum c x) + (i : ι) (x : Fin d → ℝ) : + (Φ.normalizedTranslate c δ hδ hcover i).periodicValue (x - c i) = + Φ.periodicValue (x - c i) / Φ.translateSum c x := by + have hden (b : Fin d → ℤ) : + Φ.translateSum c (c i - fun j => (b j : ℝ) - (x - c i) j) = Φ.translateSum c x := by + have heq : c i - (fun j => (b j : ℝ) - (x - c i) j) = fun j => x j + ((-b j : ℤ) : ℝ) := by + funext j + simp only [Pi.sub_apply, Int.cast_neg] + ring + rw [heq, Φ.translateSum_integer_periodic] + change (∑' b : Fin d → ℤ, Φ.value (fun j => (b j : ℝ) - (x - c i) j) / + Φ.translateSum c (c i - fun j => (b j : ℝ) - (x - c i) j)) = _ + simp only [hden] + exact tsum_div_const + +theorem sum_normalizedTranslate_periodicValue (Φ : PatchKernel d) (c : ι → Fin d → ℝ) + (δ : ℝ≥0) (hδ : 0 < δ) (hcover : ∀ x, (δ : ℝ) ≤ Φ.translateSum c x) + (x : Fin d → ℝ) : + (∑ i, (Φ.normalizedTranslate c δ hδ hcover i).periodicValue (x - c i)) = 1 := by + simp only [normalizedTranslate_periodicValue, ← Finset.sum_div] + exact div_self (ne_of_gt (lt_of_lt_of_le hδ (hcover x))) + +end Erdos3.PatchKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PhysicalBoxKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalBoxKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b92057255b0a2095eab2c0867dad3a9fe0ecf3e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalBoxKernel.lean @@ -0,0 +1,35 @@ +import OAI.Combinatorics.Progressions.Sampling.SmoothPairPhysicalGrid + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +theorem physicalBox_pair_kernel_grid_error {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] [DecidableEq I] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) + (H : I → ℝ) (L : ℝ) (hH : ∀ i, 0 < H i) (hL : 0 < L) + {C κ ρ : ℝ} (hC : 1 ≤ C) (hκ : 0 < κ) (hρ : 0 ≤ ρ) + (ht : |(t k : ℝ) / L| ≤ C) (hu : |(u k : ℝ) / L| ≤ C) + (hgap : κ ≤ |((u k - t k : ℤ) : ℝ) / L|) (b : Option J × I → ℤ) + (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)) + (hstep : ∀ i c, (P i).step c = 1) + (hlength : ∀ i c, ((P i).length c : ℝ) ≤ ρ * H i) + (x y : translatedIntegerBox lo N) : + |shiftedPairLocationKernel t u k hne H L hH hL b x.val y.val - + shiftedPairLocationKernel t u k hne H L hH hL b + (fun i => intervalCellLower (lo i) (P i) (physicalBoxCell lo N P x i)) + (fun i => intervalCellLower (lo i) (P i) (physicalBoxCell lo N P y i))| ≤ + (smoothPairKernelLip (Fintype.card I) k C κ : ℝ) * ρ := by + exact shiftedPairLocationKernel_grid_error t u k hne H L hH hL hC hκ hρ ht hu hgap b _ _ _ _ + (fun i => (physicalBoxCell_distance_lower lo N P hstep x i).trans (hlength i _)) + (fun i => (physicalBoxCell_distance_lower lo N P hstep y i).trans (hlength i _)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PhysicalCubeMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalCubeMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..52ba72f721ea15e8e11eb7d5e7e212b444827b83 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalCubeMatrix.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.Progressions.Geometry.PrincipalSpatialSiteComparison + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open scoped BigOperators Matrix + +def physicalCubeCoefficient {K α : Type*} (root : K → ℤ) (D : Matrix α K ℤ) : + Matrix (Unit ⊕ α) (Option K) ℤ + | .inl _, none => 1 + | .inl _, some k => root k + | .inr _, none => 0 + | .inr i, some k => D i k + +def physicalCubeOffset {X α : Type*} (base : X → ℤ) (x : X) : (Unit ⊕ α) → ℤ + | .inl _ => base x + | .inr _ => 0 + +def physicalCubeRootDifferences {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (z : Option K × X → ℤ) : X → (Unit ⊕ α) → ℤ := + fun x i => physicalCubeOffset base x i + ∑ k, physicalCubeCoefficient root D i k * z (k, x) + +theorem physicalCubeRootDifferences_root {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (z : Option K × X → ℤ) (x : X) : + physicalCubeRootDifferences root D base z x (.inl ()) = + jointIntegerPhysicalSite root (base, z) x := by + simp [physicalCubeRootDifferences, physicalCubeOffset, physicalCubeCoefficient, + jointIntegerPhysicalSite, integerPhysicalSite] + +theorem physicalCubeRootDifferences_direction {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (z : Option K × X → ℤ) (x : X) (i : α) : + physicalCubeRootDifferences root D base z x (.inr i) = ∑ k, D i k * z (some k, x) := by + simp [physicalCubeRootDifferences, physicalCubeOffset, physicalCubeCoefficient] + +theorem physicalCubeRootDifferences_vertex {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (z : Option K × X → ℤ) (x : X) (t : Finset α) : + physicalCubeRootDifferences root D base z x (.inl ()) + + ∑ i ∈ t, physicalCubeRootDifferences root D base z x (.inr i) = + jointIntegerPhysicalSite (integerAffineCube root D t) (base, z) x := by + rw [physicalCubeRootDifferences_root] + simp_rw [physicalCubeRootDifferences_direction] + have hs : (∑ k, ∑ i ∈ t, D i k * z (some k, x)) = + ∑ i ∈ t, ∑ k, D i k * z (some k, x) := Finset.sum_comm + simp only [jointIntegerPhysicalSite, integerPhysicalSite, Pi.add_apply, + integerAffineCube, add_mul, Finset.sum_add_distrib, Finset.sum_mul] + rw [hs] + ring + +theorem physicalCubeRootDifferences_star {K X α : Type*} [Fintype K] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) + (z : Option K × X → ℤ) (x : X) (i : Unit ⊕ α) : + spatialStar (physicalCubeRootDifferences root D base z x) i = + jointIntegerPhysicalSite (integerAffineCube root D (spatialStarVertex i)) (base, z) x := by + rw [spatialStar_vertex, physicalCubeRootDifferences_vertex] + +def physicalCubeBlockMatrix {K X α : Type*} [DecidableEq X] + (root : K → ℤ) (D : Matrix α K ℤ) : Matrix (X × (Unit ⊕ α)) (Option K × X) ℤ := + fun row col => if row.1 = col.2 then physicalCubeCoefficient root D row.2 col.1 else 0 + +theorem physicalCubeBlockMatrix_mulVec {K X α : Type*} + [Fintype K] [Fintype X] [DecidableEq X] + (root : K → ℤ) (D : Matrix α K ℤ) (z : Option K × X → ℤ) (x : X) (i : Unit ⊕ α) : + (physicalCubeBlockMatrix root D *ᵥ z) (x, i) = + ∑ k, physicalCubeCoefficient root D i k * z (k, x) := by + simp [physicalCubeBlockMatrix, Matrix.mulVec, dotProduct, Fintype.sum_prod_type, ite_mul] + +theorem physicalCubeRootDifferences_matrix {K X α : Type*} + [Fintype K] [Fintype X] [DecidableEq X] + (root : K → ℤ) (D : Matrix α K ℤ) (base : X → ℤ) (z : Option K × X → ℤ) : + (fun row : X × (Unit ⊕ α) => physicalCubeRootDifferences root D base z row.1 row.2) = + (fun row => physicalCubeOffset base row.1 row.2) + physicalCubeBlockMatrix root D *ᵥ z := by + funext row + rw [Pi.add_apply, physicalCubeBlockMatrix_mulVec] + rfl + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PhysicalJetKernelTransfer.lean b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalJetKernelTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ef8691721eb8e739560297d9a17bab7980b9754 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalJetKernelTransfer.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.Progressions.Sampling.PhysicalJetTentSampling + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory Module Submodule VectorPolynomial +open scoped BigOperators Classical NNReal + +variable {m dim : ℕ} {X : Type*} [Fintype X] +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) +local notation "haar" => Measure.pi (fun j => Measure.pi (fun _ : jets j => ν j)) + +theorem physicalJetTent_transfer + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) (hm : ∀ j e, coefficients (p j) e ∈ U j) + (cover : ℕ) [NeZero cover] (stride : X → ℕ) + (cells : Finset (ColumnResiduePattern (Option (Fin dim)) X stride)) + (V : Option (Fin dim) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight stride cells V z) {n : ℕ} (hn : 0 < n) : + let sample := fun z : Option (Fin dim) × X → ℤ => + physicalCubeEuclideanSample U cover p hm (standardPhysicalCubeOutput z) + let law := selectedResidueFiniteLaw stride cells V hV hZ + ∀ {err : ℝ}, err ≤ 1 → + (∀ y, |law.mean (fun z => physicalJetTentKernel U ν n (sample z.val) y) - 1| ≤ err) → + ∀ (φ : EuclideanJetLayers U jets → ℂ), Integrable φ haar → + ∀ (ψ : (JetAmbientIndex jets J → UnitAddCircle) → ℂ) {L : ℝ≥0}, LipschitzWith L ψ → + Integrable (fun y => ψ (coveredJetAmbientTorus U 1 y)) haar → + ∀ F : (Option (Fin dim) × X → ℤ) → ℂ, (∀ z, ‖F z‖ ≤ 1) → + let obs := finiteKernelObservable law (fun z => physicalJetTentKernel U ν n (sample z.val)) 2 (fun z => F z.val) + Measurable obs ∧ (∀ y, ‖obs y‖ ≤ 1) ∧ Integrable (fun y => φ y * obs y) haar ∧ + ‖(∑' z, ((selectedResidueSmoothPMF stride cells V hV hZ z).toReal : ℂ) * + (φ (sample z) * F z)) - (∫ y, φ y * obs y ∂haar) * 2‖ ≤ + selectedResidueDensityMass stride cells V + (fun z => ‖φ (sample z) - ψ (coveredJetAmbientTorus U 1 (sample z))‖) + + (L : ℝ) * (4 / (n : ℝ)) + 2 * ∫ y, ‖ψ (coveredJetAmbientTorus U 1 y) - φ y‖ ∂haar := by + intro sample law err herr hclose φ hφ ψ L hL hψ F hF obs + let : ∀ j, (Measure.pi (fun _ : jets j => ν j)).IsAddLeftInvariant := + fun _ => Measure.pi.isAddLeftInvariant _ + let : (Measure.pi (fun j => Measure.pi (fun _ : jets j => ν j))).IsAddLeftInvariant := + Measure.pi.isAddLeftInvariant _ + let : MeasurableAdd₂ (EuclideanJetLayers U jets) := + ⟨(continuous_fst.add continuous_snd).measurable⟩ + let f := coveredJetAmbientHom (O := jets) U 1 + have hf : Continuous f := coveredJetAmbientTorus_continuous U 1 + have hden (y) : law.mean (fun z => ambientTentKernel haar f n (sample z.val) y) ≤ 2 := by + have h := (abs_le.mp (hclose y)).2 + change law.mean (fun z => ambientTentKernel haar f n (sample z.val) y) - 1 ≤ err at h + linarith only [h, herr] + obtain ⟨hobs, hbound, hint, herror⟩ := finiteAmbientKernel_transfer haar f hf hn law + (fun z => sample z.val) (by norm_num : (0 : ℝ) < 2) hden φ hφ ψ hL hψ + (fun z => F z.val) (fun z => hF z.val) + refine ⟨hobs, hbound, hint, ?_⟩ + have hfeq (y : EuclideanJetLayers U jets) : f y = coveredJetAmbientTorus U 1 y := rfl + simp_rw [hfeq] at herror + change ‖(selectedResidueFiniteLaw stride cells V hV hZ).complexMean + (fun z => φ (sample z.val) * F z.val) - (∫ y, φ y * obs y ∂haar) * 2‖ ≤ + (selectedResidueFiniteLaw stride cells V hV hZ).mean + (fun z => ‖φ (sample z.val) - ψ (coveredJetAmbientTorus U 1 (sample z.val))‖) + + (L : ℝ) * (4 / (n : ℝ)) + 2 * ∫ y, ‖ψ (coveredJetAmbientTorus U 1 y) - φ y‖ ∂haar at herror + rw [selectedResidueFiniteLaw_complexMean stride cells V hV hZ (fun z => φ (sample z) * F z), + selectedResidueFiniteLaw_densityMass stride cells V hV hZ + (fun z => ‖φ (sample z) - ψ (coveredJetAmbientTorus U 1 (sample z))‖)] at herror + exact herror + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PhysicalJetTentKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalJetTentKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..281d777f38966e2992134a197187730e541ea6d9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalJetTentKernel.lean @@ -0,0 +1,439 @@ +import OAI.Combinatorics.Progressions.Probability.AllocatedEarlyCoverCoefficientMass + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +variable {H J : Type*} [AddCommGroup H] [MeasurableSpace H] [Fintype J] +variable (μ : Measure H) (f : H →+ (J → UnitAddCircle)) + +noncomputable def ambientTentKernel (q : ℕ) (a y : H) : ℝ := + normalizedAmbientTent μ f q (f (y - a)) + +theorem ambientTentKernel_symm (q : ℕ) (a y : H) : + ambientTentKernel μ f q a y = ambientTentKernel μ f q y a := by + simp only [ambientTentKernel, normalizedAmbientTent, ambientTorusTent, map_sub] + rw [norm_sub_rev (f y) (f a)] + +theorem ambientTentKernel_support {q : ℕ} (hq : 0 < q) (a y : H) (h : ambientTentKernel μ f q a y ≠ 0) : + ‖f y - f a‖ < 4 / (q : ℝ) := by + have ht : ambientTorusTent q (f (y - a)) ≠ 0 := by + intro he + exact h (by simp only [ambientTentKernel, normalizedAmbientTent, he, zero_div]) + simpa only [map_sub] using ambientTorusTent_support hq (f (y - a)) ht + +variable [TopologicalSpace H] [IsTopologicalAddGroup H] [BorelSpace H] [MeasurableAdd₂ H] +variable [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] +variable (hf : Continuous f) {q : ℕ} (hq : 0 < q) + +include hf hq + +theorem ambientTentKernel_range (a y : H) : + 0 ≤ ambientTentKernel μ f q a y ∧ ambientTentKernel μ f q a y ≤ 2 * (q : ℝ) ^ Fintype.card J := by + have hz := ambientTentMass_pos μ f hf hq + have hi := ambientTentMass_inv_le μ f hf hq + exact ⟨div_nonneg (ambientTorusTent_range q _).1 hz.le, + (div_le_div_of_nonneg_right (ambientTorusTent_range q _).2 hz.le).trans hi⟩ + +theorem normalizedAmbientTent_shift_lipschitz (a : J → UnitAddCircle) : + LipschitzWith ((q : ℝ≥0) ^ (Fintype.card J + 1)) + (fun z => normalizedAmbientTent μ f q (z - a)) := by + have h := normalizedAmbientTent_lipschitz μ f q + (ambientTentMass_pos μ f hf hq) (ambientTentMass_inv_le μ f hf hq) + apply LipschitzWith.of_dist_le_mul + intro z w + simpa only [dist_sub_right] using h.dist_le_mul (z - a) (w - a) + +theorem ambientTentKernel_continuous (a : H) : Continuous (ambientTentKernel μ f q a) := by + have h := normalizedAmbientTent_lipschitz μ f q + (ambientTentMass_pos μ f hf hq) (ambientTentMass_inv_le μ f hf hq) + exact h.continuous.comp (hf.comp (continuous_id.sub continuous_const)) + +theorem ambientTentKernel_integrable (a : H) : Integrable (ambientTentKernel μ f q a) μ := + Integrable.of_bound (ambientTentKernel_continuous μ f hf hq a).aestronglyMeasurable + (2 * (q : ℝ) ^ Fintype.card J) (ae_of_all μ (fun y => by + rw [Real.norm_eq_abs, abs_of_nonneg (ambientTentKernel_range μ f hf hq a y).1] + exact (ambientTentKernel_range μ f hf hq a y).2)) + +theorem ambientTentKernel_integral (a : H) : (∫ y, ambientTentKernel μ f q a y ∂μ) = 1 := by + have htrans : (∫ y, ambientTentKernel μ f q a y ∂μ) = + ∫ y, normalizedAmbientTent μ f q (f y) ∂μ := by + simpa only [ambientTentKernel, sub_eq_add_neg, add_comm] using + integral_add_left_eq_self (μ := μ) (fun y => normalizedAmbientTent μ f q (f y)) (-a) + rw [htrans] + change (∫ y, ambientTorusTent q (f y) / ambientTentMass μ f q ∂μ) = 1 + rw [integral_div] + exact div_self (ambientTentMass_pos μ f hf hq).ne' + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators + +variable {Ω Y : Type*} [Fintype Ω] [MeasurableSpace Y] +variable (law : FiniteProbabilityWeights Ω) (K : Ω → Y → ℝ) + +noncomputable def finiteKernelObservable (C : ℝ) (F : Ω → ℂ) (y : Y) : ℂ := + law.complexMean (fun x => (K x y : ℂ) * F x) / (C : ℂ) + +theorem finiteKernelObservable_measurable (hK : ∀ x, Measurable (K x)) (C : ℝ) (F : Ω → ℂ) : + Measurable (finiteKernelObservable law K C F) := by + unfold finiteKernelObservable FiniteProbabilityWeights.complexMean + fun_prop + +omit [MeasurableSpace Y] in +theorem finiteKernelObservable_norm_le (hK0 : ∀ x y, 0 ≤ K x y) + {C : ℝ} (hC : 0 < C) (hden : ∀ y, law.mean (fun x => K x y) ≤ C) + (F : Ω → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) (y : Y) : + ‖finiteKernelObservable law K C F y‖ ≤ 1 := by + have hbound : ‖law.complexMean (fun x => (K x y : ℂ) * F x)‖ ≤ C := by + apply (law.norm_complexMean_le_mean_norm _).trans + apply (law.mean_mono (fun x => ?_)).trans (hden y) + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hK0 x y)] + exact (mul_le_mul_of_nonneg_left (hF x) (hK0 x y)).trans_eq (mul_one _) + rw [finiteKernelObservable, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hC] + exact (div_le_one hC).mpr hbound + +theorem finiteKernelObservable_integral (μ : Measure Y) (φ : Y → ℂ) (hφ : Integrable φ μ) + (hK : ∀ x, Measurable (K x)) (hK0 : ∀ x y, 0 ≤ K x y) + {M : ℝ} (hKM : ∀ x y, K x y ≤ M) (C : ℝ) (F : Ω → ℂ) : + (∫ y, φ y * finiteKernelObservable law K C F y ∂μ) = + law.complexMean (fun x => F x * ∫ y, φ y * (K x y : ℂ) ∂μ) / (C : ℂ) := by + have hi (x : Ω) : Integrable (fun y => φ y * (K x y : ℂ)) μ := + hφ.mul_bdd (hK x).complex_ofReal.aestronglyMeasurable (ae_of_all μ (fun y => by + simpa only [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hK0 x y)] using hKM x y)) + have heq (y : Y) : φ y * finiteKernelObservable law K C F y = + (∑ x, (law.weight x : ℂ) * (F x * (φ y * (K x y : ℂ)))) / (C : ℂ) := by + unfold finiteKernelObservable FiniteProbabilityWeights.complexMean + rw [← mul_div_assoc, Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro x _ + ring + simp_rw [heq] + rw [integral_div, integral_finsetSum _ (fun x _ => (hi x).const_mul (F x) |>.const_mul (law.weight x : ℂ))] + simp only [integral_const_mul, FiniteProbabilityWeights.complexMean] + +theorem finiteKernelObservable_integrable (μ : Measure Y) (φ : Y → ℂ) (hφ : Integrable φ μ) + (hK : ∀ x, Measurable (K x)) (hK0 : ∀ x y, 0 ≤ K x y) + {C : ℝ} (hC : 0 < C) (hden : ∀ y, law.mean (fun x => K x y) ≤ C) + (F : Ω → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) : + Integrable (fun y => φ y * finiteKernelObservable law K C F y) μ := + hφ.mul_bdd (finiteKernelObservable_measurable law K hK C F).aestronglyMeasurable + (ae_of_all μ (finiteKernelObservable_norm_le law K hK0 hC hden F hF)) + +theorem finiteKernelObservable_source_error (μ : Measure Y) (φ : Y → ℂ) (hφ : Integrable φ μ) + (hK : ∀ x, Measurable (K x)) (hK0 : ∀ x y, 0 ≤ K x y) + {M C : ℝ} (hKM : ∀ x y, K x y ≤ M) (hC : 0 < C) + (v F : Ω → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) : + ‖law.complexMean (fun x => v x * F x) - + (∫ y, φ y * finiteKernelObservable law K C F y ∂μ) * (C : ℂ)‖ ≤ + law.mean (fun x => ‖v x - ∫ y, φ y * (K x y : ℂ) ∂μ‖) := by + rw [finiteKernelObservable_integral law K μ φ hφ hK hK0 hKM C F, + div_mul_cancel₀ _ (Complex.ofReal_ne_zero.mpr hC.ne')] + apply law.norm_complexMean_sub_le + intro x _ + calc + ‖v x * F x - F x * ∫ y, φ y * (K x y : ℂ) ∂μ‖ = + ‖(v x - ∫ y, φ y * (K x y : ℂ) ∂μ) * F x‖ := by congr 1; ring + _ = ‖v x - ∫ y, φ y * (K x y : ℂ) ∂μ‖ * ‖F x‖ := norm_mul _ _ + _ ≤ ‖v x - ∫ y, φ y * (K x y : ℂ) ∂μ‖ := + (mul_le_mul_of_nonneg_left (hF x) (norm_nonneg _)).trans_eq (mul_one _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +variable {H J : Type*} [AddCommGroup H] [MeasurableSpace H] [Fintype J] +variable [TopologicalSpace H] [IsTopologicalAddGroup H] [BorelSpace H] [MeasurableAdd₂ H] +variable (μ : Measure H) [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] +variable (f : H →+ (J → UnitAddCircle)) (hf : Continuous f) {q : ℕ} (hq : 0 < q) + +include hf hq + +theorem ambientTentKernel_lipschitz_error + (ψ : (J → UnitAddCircle) → ℂ) {L : ℝ≥0} (hL : LipschitzWith L ψ) + (hψ : Integrable (fun y => ψ (f y)) μ) (a : H) : + ‖ψ (f a) - ∫ y, ψ (f y) * (ambientTentKernel μ f q a y : ℂ) ∂μ‖ ≤ (L : ℝ) * (4 / (q : ℝ)) := by + have hk := ambientTentKernel_integrable μ f hf hq a + have hkm := (ambientTentKernel_continuous μ f hf hq a).measurable + have hmul : Integrable (fun y => ψ (f y) * (ambientTentKernel μ f q a y : ℂ)) μ := + hψ.mul_bdd hkm.complex_ofReal.aestronglyMeasurable (ae_of_all μ (fun y => by + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (ambientTentKernel_range μ f hf hq a y).1] + exact (ambientTentKernel_range μ f hf hq a y).2)) + have hconst := hk.ofReal.const_mul (ψ (f a)) + have hid : ψ (f a) - ∫ y, ψ (f y) * (ambientTentKernel μ f q a y : ℂ) ∂μ = + ∫ y, (ψ (f a) - ψ (f y)) * (ambientTentKernel μ f q a y : ℂ) ∂μ := by + calc + _ = (∫ y, ψ (f a) * (ambientTentKernel μ f q a y : ℂ) ∂μ) - + ∫ y, ψ (f y) * (ambientTentKernel μ f q a y : ℂ) ∂μ := by + rw [integral_const_mul, integral_complex_ofReal, ambientTentKernel_integral μ f hf hq, + Complex.ofReal_one, mul_one] + _ = ∫ y, ψ (f a) * (ambientTentKernel μ f q a y : ℂ) - + ψ (f y) * (ambientTentKernel μ f q a y : ℂ) ∂μ := (integral_sub hconst hmul).symm + _ = _ := by congr 1; funext y; ring + rw [hid] + have hpoint (y : H) : ‖(ψ (f a) - ψ (f y)) * (ambientTentKernel μ f q a y : ℂ)‖ ≤ + ((L : ℝ) * (4 / (q : ℝ))) * ambientTentKernel μ f q a y := by + by_cases hz : ambientTentKernel μ f q a y = 0 + · simp only [hz, Complex.ofReal_zero, mul_zero, norm_zero, le_refl] + · have hs := ambientTentKernel_support μ f hq a y hz + have hd : ‖ψ (f a) - ψ (f y)‖ ≤ (L : ℝ) * (4 / (q : ℝ)) := by + calc + _ = dist (ψ (f a)) (ψ (f y)) := (dist_eq_norm _ _).symm + _ ≤ (L : ℝ) * dist (f a) (f y) := hL.dist_le_mul _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left (by simpa only [dist_eq_norm, norm_sub_rev] using hs.le) L.coe_nonneg + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (ambientTentKernel_range μ f hf hq a y).1] + exact mul_le_mul_of_nonneg_right hd (ambientTentKernel_range μ f hf hq a y).1 + apply (norm_integral_le_of_norm_le (hk.const_mul ((L : ℝ) * (4 / (q : ℝ)))) (ae_of_all μ hpoint)).trans_eq + rw [integral_const_mul, ambientTentKernel_integral μ f hf hq, mul_one] + +theorem finiteAmbientKernel_transfer {Ω : Type*} [Fintype Ω] + (law : FiniteProbabilityWeights Ω) (sample : Ω → H) + {C : ℝ} (hC : 0 < C) + (hden : ∀ y, law.mean (fun x => ambientTentKernel μ f q (sample x) y) ≤ C) + (φ : H → ℂ) (hφ : Integrable φ μ) + (ψ : (J → UnitAddCircle) → ℂ) {L : ℝ≥0} (hL : LipschitzWith L ψ) + (hψ : Integrable (fun y => ψ (f y)) μ) + (F : Ω → ℂ) (hF : ∀ x, ‖F x‖ ≤ 1) : + let obs := finiteKernelObservable law (fun x => ambientTentKernel μ f q (sample x)) C F + Measurable obs ∧ (∀ y, ‖obs y‖ ≤ 1) ∧ Integrable (fun y => φ y * obs y) μ ∧ + ‖law.complexMean (fun x => φ (sample x) * F x) - (∫ y, φ y * obs y ∂μ) * (C : ℂ)‖ ≤ + law.mean (fun x => ‖φ (sample x) - ψ (f (sample x))‖) + (L : ℝ) * (4 / (q : ℝ)) + + C * ∫ y, ‖ψ (f y) - φ y‖ ∂μ := by + intro obs + let K := fun x => ambientTentKernel μ f q (sample x) + have hK (x : Ω) : Measurable (K x) := (ambientTentKernel_continuous μ f hf hq (sample x)).measurable + have hK0 (x : Ω) (y : H) : 0 ≤ K x y := (ambientTentKernel_range μ f hf hq (sample x) y).1 + have hKM (x : Ω) (y : H) : K x y ≤ 2 * (q : ℝ) ^ Fintype.card J := + (ambientTentKernel_range μ f hf hq (sample x) y).2 + have hobs : Measurable obs := finiteKernelObservable_measurable law K hK C F + have hb : ∀ y, ‖obs y‖ ≤ 1 := finiteKernelObservable_norm_le law K hK0 hC hden F hF + have hiφ : Integrable (fun y => φ y * obs y) μ := + finiteKernelObservable_integrable law K μ φ hφ hK hK0 hC hden F hF + have hiψ : Integrable (fun y => ψ (f y) * obs y) μ := + finiteKernelObservable_integrable law K μ (fun y => ψ (f y)) hψ hK hK0 hC hden F hF + refine ⟨hobs, hb, hiφ, ?_⟩ + have hfirst : ‖law.complexMean (fun x => φ (sample x) * F x) - + law.complexMean (fun x => ψ (f (sample x)) * F x)‖ ≤ + law.mean (fun x => ‖φ (sample x) - ψ (f (sample x))‖) := by + apply law.norm_complexMean_sub_le + intro x _ + rw [← sub_mul, norm_mul] + exact (mul_le_mul_of_nonneg_left (hF x) (norm_nonneg _)).trans_eq (mul_one _) + have hsmooth : law.mean (fun x => ‖ψ (f (sample x)) - ∫ y, ψ (f y) * (K x y : ℂ) ∂μ‖) ≤ + (L : ℝ) * (4 / (q : ℝ)) := + (law.mean_mono (fun x => ambientTentKernel_lipschitz_error μ f hf hq ψ hL hψ (sample x))).trans_eq + (law.mean_const _) + have hmiddle : ‖law.complexMean (fun x => ψ (f (sample x)) * F x) - + (∫ y, ψ (f y) * obs y ∂μ) * (C : ℂ)‖ ≤ (L : ℝ) * (4 / (q : ℝ)) := + (finiteKernelObservable_source_error law K μ (fun y => ψ (f y)) hψ hK hK0 hKM hC + (fun x => ψ (f (sample x))) F hF).trans hsmooth + have hlast : ‖(∫ y, ψ (f y) * obs y ∂μ) * (C : ℂ) - + (∫ y, φ y * obs y ∂μ) * (C : ℂ)‖ ≤ C * ∫ y, ‖ψ (f y) - φ y‖ ∂μ := by + rw [← sub_mul, ← integral_sub hiψ hiφ, norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hC, mul_comm C] + apply mul_le_mul_of_nonneg_right _ hC.le + apply norm_integral_le_of_norm_le (hψ.sub hφ).norm + apply ae_of_all μ + intro y + rw [← sub_mul, norm_mul] + exact (mul_le_mul_of_nonneg_left (hb y) (norm_nonneg _)).trans_eq (mul_one _) + have htri := dist_triangle (law.complexMean (fun x => φ (sample x) * F x)) + (law.complexMean (fun x => ψ (f (sample x)) * F x)) ((∫ y, φ y * obs y ∂μ) * (C : ℂ)) + have htri2 := dist_triangle (law.complexMean (fun x => ψ (f (sample x)) * F x)) + ((∫ y, ψ (f y) * obs y ∂μ) * (C : ℂ)) ((∫ y, φ y * obs y ∂μ) * (C : ℂ)) + simp only [dist_eq_norm] at htri htri2 + linarith only [htri, htri2, hfirst, hmiddle, hlast] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MeasureTheory +open scoped NNReal + +theorem majorant_reweight_norm {v F : ℂ} {w : ℝ} (hv : ‖v‖ ≤ w) (hF : ‖F‖ ≤ 1) : + ‖(v / (w : ℂ)) * F‖ ≤ 1 := by + by_cases hw : w = 0 + · simp only [hw, Complex.ofReal_zero, div_zero, zero_mul, norm_zero, zero_le_one] + · have hw0 : 0 < w := lt_of_le_of_ne ((norm_nonneg v).trans hv) (Ne.symm hw) + rw [norm_mul, norm_div, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hw0] + exact (mul_le_mul ((div_le_one hw0).mpr hv) hF (norm_nonneg _) zero_le_one).trans_eq (one_mul 1) + +theorem majorant_reweight_exact {v F : ℂ} {w : ℝ} (hv : ‖v‖ ≤ w) : + (w : ℂ) * ((v / (w : ℂ)) * F) = v * F := by + by_cases hw : w = 0 + · have hv0 : v = 0 := norm_le_zero_iff.mp (by simpa only [hw] using hv) + simp only [hw, hv0, Complex.ofReal_zero, zero_mul] + · have hwc : (w : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hw + field_simp + +variable {H J : Type*} [AddCommGroup H] [MeasurableSpace H] [Fintype J] +variable [TopologicalSpace H] [IsTopologicalAddGroup H] [BorelSpace H] [MeasurableAdd₂ H] +variable (μ : Measure H) [IsProbabilityMeasure μ] [μ.IsAddLeftInvariant] +variable (f : H →+ (J → UnitAddCircle)) (hf : Continuous f) {q : ℕ} (hq : 0 < q) + +include hf hq + +theorem finiteAmbientMajorant_transfer {Ω : Type*} [Fintype Ω] + (law : FiniteProbabilityWeights Ω) (sample : Ω → H) + {C : ℝ} (hC : 0 < C) + (hden : ∀ y, law.mean (fun x => ambientTentKernel μ f q (sample x) y) ≤ C) + (ψ : (J → UnitAddCircle) → ℝ) {L : ℝ≥0} (hL : LipschitzWith L ψ) + (hψ : Integrable (fun y => ψ (f y)) μ) + (v F : Ω → ℂ) (hv : ∀ x, ‖v x‖ ≤ ψ (f (sample x))) (hF : ∀ x, ‖F x‖ ≤ 1) : + let weight := fun x => (v x / (ψ (f (sample x)) : ℂ)) * F x + let obs := finiteKernelObservable law (fun x => ambientTentKernel μ f q (sample x)) C weight + Measurable obs ∧ (∀ y, ‖obs y‖ ≤ 1) ∧ + Integrable (fun y => (ψ (f y) : ℂ) * obs y) μ ∧ + ‖law.complexMean (fun x => v x * F x) - + (∫ y, (ψ (f y) : ℂ) * obs y ∂μ) * (C : ℂ)‖ ≤ (L : ℝ) * (4 / (q : ℝ)) := by + intro weight obs + have hw : ∀ x, ‖weight x‖ ≤ 1 := fun x => majorant_reweight_norm (hv x) (hF x) + have hLc : LipschitzWith L (fun z => (ψ z : ℂ)) := by + apply LipschitzWith.of_dist_le_mul + intro z t + rw [Complex.isometry_ofReal.dist_eq] + exact hL.dist_le_mul z t + obtain ⟨hm, hb, hi, he⟩ := finiteAmbientKernel_transfer μ f hf hq law sample hC hden + (fun y => (ψ (f y) : ℂ)) hψ.ofReal (fun z => (ψ z : ℂ)) hLc hψ.ofReal weight hw + have heq : law.complexMean (fun x => (ψ (f (sample x)) : ℂ) * weight x) = + law.complexMean (fun x => v x * F x) := by + apply law.complexMean_congr_support + intro x _ + exact majorant_reweight_exact (hv x) + refine ⟨hm, hb, hi, ?_⟩ + simpa only [heq, sub_self, norm_zero, law.mean_const, integral_zero, mul_zero, zero_add, add_zero] using he + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +variable {m : ℕ} {O J : Fin m → Type*} [∀ j, Fintype (O j)] [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) + +noncomputable def coveredJetAmbientHom (d : ℕ) : + EuclideanJetLayers U O →+ (JetAmbientIndex O J → UnitAddCircle) where + toFun := coveredJetAmbientTorus U d + map_zero' := by ext a; simp [coveredJetAmbientTorus] + map_add' x y := by ext a; simp [coveredJetAmbientTorus] + +end Erdos3.VectorPolynomial + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory Module Submodule VectorPolynomial +open scoped BigOperators Classical NNReal + +variable {m dim : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) + +local notation "jets" => (fun j : Fin m => BoundedBooleanJet (Fin dim) (Fin.val j + 1)) + +variable (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + +local notation "haar" => Measure.pi (fun j => Measure.pi (fun _ : jets j => ν j)) + +noncomputable def physicalJetTentKernel (n : ℕ) : EuclideanJetLayers U jets → EuclideanJetLayers U jets → ℝ := + ambientTentKernel haar (coveredJetAmbientHom U 1) n + +variable [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + +theorem physicalJetTentKernel_properties {n : ℕ} (hn : 0 < n) (a : EuclideanJetLayers U jets) : + Measurable (physicalJetTentKernel U ν n a) ∧ + Integrable (physicalJetTentKernel U ν n a) haar ∧ + (∫ y, physicalJetTentKernel U ν n a y ∂haar) = 1 ∧ + ∀ y, 0 ≤ physicalJetTentKernel U ν n a y ∧ + physicalJetTentKernel U ν n a y ≤ 2 * (n : ℝ) ^ Fintype.card (JetAmbientIndex jets J) := by + let : ∀ j, (Measure.pi (fun _ : jets j => ν j)).IsAddLeftInvariant := + fun _ => Measure.pi.isAddLeftInvariant _ + let : (Measure.pi (fun j => Measure.pi (fun _ : jets j => ν j))).IsAddLeftInvariant := + Measure.pi.isAddLeftInvariant _ + have hf : Continuous (coveredJetAmbientHom (O := jets) U 1) := coveredJetAmbientTorus_continuous U 1 + exact ⟨(ambientTentKernel_continuous haar (coveredJetAmbientHom U 1) hf hn a).measurable, + ambientTentKernel_integrable haar (coveredJetAmbientHom U 1) hf hn a, + ambientTentKernel_integral haar (coveredJetAmbientHom U 1) hf hn a, + ambientTentKernel_range haar (coveredJetAmbientHom U 1) hf hn a⟩ + +theorem exists_physicalJetTent_fourier {n : ℕ} (hn : 0 < n) + (a : EuclideanJetLayers U jets) {δ L : ℝ} (hδ : 0 < δ) (hL : 0 ≤ L) + (hamb : (Fintype.card (JetAmbientIndex jets J) : ℝ) ≤ L) + (hLip : (n : ℝ) ^ (Fintype.card (JetAmbientIndex jets J) + 1) ≤ Real.exp L) + (hδL : δ⁻¹ ≤ Real.exp L) : + ∃ (F : Type) (inst : Fintype F), let _ : Fintype F := inst + ∃ (frequency : F → ∀ j, (Fin dim →₀ ℕ) → J j → ℤ) (c : F → ℂ), + (∀ t j e, e.degree ≤ j.val + 1 → ∀ i, + |(frequency t j e i : ℝ)| ≤ Real.exp ((2 * L + 2) ^ 4)) ∧ + (∑ t, ‖c t‖) ≤ Real.exp (2 * L * (2 * L + 2) ^ 4) * + (2 * (n : ℝ) ^ Fintype.card (JetAmbientIndex jets J)) ∧ + ∀ y, ‖(physicalJetTentKernel U ν n a (standardPhysicalJetMap U y) : ℂ) - + coefficientTorusFourierSum U frequency c y‖ ≤ δ := by + let : ∀ j, (Measure.pi (fun _ : jets j => ν j)).IsAddLeftInvariant := + fun _ => Measure.pi.isAddLeftInvariant _ + let : (Measure.pi (fun j => Measure.pi (fun _ : jets j => ν j))).IsAddLeftInvariant := + Measure.pi.isAddLeftInvariant _ + let f := coveredJetAmbientHom (O := jets) U 1 + have hf : Continuous f := coveredJetAmbientTorus_continuous U 1 + let Ltent : ℝ≥0 := (n : ℝ≥0) ^ (Fintype.card (JetAmbientIndex jets J) + 1) + let Btent : ℝ≥0 := 2 * (n : ℝ≥0) ^ Fintype.card (JetAmbientIndex jets J) + let k := fun z => normalizedAmbientTent haar f n (z - f a) + have hk := normalizedAmbientTent_shift_lipschitz haar f hf hn (f a) + have hkc : LipschitzWith Ltent (fun z => (k z : ℂ)) := by + apply LipschitzWith.of_dist_le_mul + intro z w + rw [Complex.isometry_ofReal.dist_eq] + exact hk.dist_le_mul z w + have hz := ambientTentMass_pos haar f hf hn + have hi := ambientTentMass_inv_le haar f hf hn + have hb (z) : ‖(k z : ℂ)‖ ≤ Btent := by + have h0 : 0 ≤ k z := div_nonneg (ambientTorusTent_range n _).1 hz.le + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg h0] + exact (div_le_div_of_nonneg_right (ambientTorusTent_range n _).2 hz.le).trans hi + obtain ⟨F, inst, frequency, c, _hcard, hfreq, hsum, herr⟩ := + exists_ambient_torus_fourier_approximation (fun z => (k z : ℂ)) Ltent Btent hkc hb + hδ hL hamb (by simpa only [Ltent, NNReal.coe_pow, NNReal.coe_natCast] using hLip) hδL + let _ := inst + refine ⟨F, inst, fun t => standardJetFrequency 1 (frequency t), c, ?_, ?_, ?_⟩ + · intro t j e he i + simpa only [Nat.cast_one, mul_one] using standardJetFrequency_bound 1 (frequency t) (hfreq t) j e he i + · simpa only [Btent, NNReal.coe_mul, NNReal.coe_ofNat, NNReal.coe_pow, NNReal.coe_natCast] using hsum + · intro y + change ‖(normalizedAmbientTent haar f n (f (standardPhysicalJetMap U y - a)) : ℂ) - + coefficientTorusFourierSum U (fun t => standardJetFrequency 1 (frequency t)) c y‖ ≤ δ + rw [map_sub] + rw [show f (standardPhysicalJetMap U y) = coveredJetAmbientTorus U 1 (standardPhysicalJetMap U y) from rfl] + simpa only [k, coefficientTorusFourierSum, standardJetFrequency_character] using + herr (coveredJetAmbientTorus U 1 (standardPhysicalJetMap U y)) + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PhysicalSiteProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalSiteProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..21eb83ab643f4166c5e1939c92f24c9e4a44623d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PhysicalSiteProjection.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalSingleSiteAmbient + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +variable {X : Type*} {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j e, coefficients (p j) e ∈ U j) + +noncomputable def physicalEuclideanSitePoint (w : X → ℝ) (j : Fin m) : euclideanSubspace (U j) := + (euclideanSubspaceArrayEquiv (U j)).symm + (fun _ : Unit => eval w (restrictCoefficients (U j) (p j) (hm j))) + +omit [∀ j, Fintype (J j)] in +theorem physicalEuclideanSitePoint_apply (w : X → ℝ) (j : Fin m) (i : J j) : + (physicalEuclideanSitePoint U p hm w j).val i = eval w (p j) i := by + change (eval w (restrictCoefficients (U j) (p j) (hm j))).val i = _ + rw [eval_restrictCoefficients] + +theorem physicalSingleSiteValue_eq_mk (d : ℕ) (w : X → ℝ) (j : Fin m) : + physicalSingleSiteValue U d p hm w j () = + QuotientAddGroup.mk ((d : ℝ)⁻¹ • physicalEuclideanSitePoint U p hm w j) := by + apply (euclideanSubspaceTorusEquiv (U j)).injective + change euclideanSubspaceTorusEquiv (U j) + ((euclideanSubspaceTorusEquiv (U j)).symm _) = + euclideanSubspaceTorusEquiv (U j) (QuotientAddGroup.mk' _ + ((d : ℝ)⁻¹ • physicalEuclideanSitePoint U p hm w j)) + rw [AddEquiv.apply_symm_apply, euclideanSubspaceTorusEquiv_mk] + congr 1 + +theorem physicalSingleSiteValue_projection (d : ℕ) [NeZero d] (w : X → ℝ) (j : Fin m) : + quotientIntegerCover + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup d + (physicalSingleSiteValue U d p hm w j ()) = + QuotientAddGroup.mk (physicalEuclideanSitePoint U p hm w j) := by + have hd : (d : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne d) + apply (euclideanSubspaceTorusEquiv (U j)).injective + change euclideanSubspaceTorusEquiv (U j) + (d • (euclideanSubspaceTorusEquiv (U j)).symm + (QuotientAddGroup.mk' (subspaceArrayIntegerLattice Unit (U j)) + (fun _ => (d : ℝ)⁻¹ • eval w (restrictCoefficients (U j) (p j) (hm j))))) = _ + rw [map_nsmul, AddEquiv.apply_symm_apply] + change quotientIntegerCover (subspaceArrayIntegerLattice Unit (U j)) d + (QuotientAddGroup.mk' _ ((d : ℝ)⁻¹ • + (fun _ : Unit => eval w (restrictCoefficients (U j) (p j) (hm j))))) = + euclideanSubspaceTorusEquiv (U j) (QuotientAddGroup.mk' _ (physicalEuclideanSitePoint U p hm w j)) + rw [euclideanSubspaceTorusEquiv_mk, quotientIntegerCover_mk, smul_smul, mul_inv_cancel₀ hd, one_smul] + congr 1 + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PivotKernelAllowances.lean b/lean/OAI/Combinatorics/Progressions/Linear/PivotKernelAllowances.lean new file mode 100644 index 0000000000000000000000000000000000000000..246990fa51a8bbe34a1c1ce5fc56a447a82dc6d5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PivotKernelAllowances.lean @@ -0,0 +1,44 @@ +import OAI.Combinatorics.Progressions.Estimates.PivotOutputLipschitz + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def pivotKernelCap {I : Type*} [Fintype I] (J : Type*) [Fintype J] + (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (R H : ℝ≥0) : ℝ≥0 := + ⟨inverseJacobian A, (inverseJacobian_pos A).le⟩ * H * (2*R)^Fintype.card J + +noncomputable def pivotKernelLip {I : Type*} [Fintype I] (J : Type*) [Fintype J] + (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (R K : ℝ≥0) : ℝ≥0 := + pivotKernelCap J A R K * ‖A.symm.toContinuousLinearMap‖₊ + +theorem pivotOutputDensity_norm_le_cap {I J : Type*} [Fintype I] [Fintype J] + (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (B : (J → ℝ) →L[ℝ] (I → ℝ)) + (f : (J → ℝ) × (I → ℝ) → ℝ) (R H : ℝ≥0) + (hs : ∀ p, (R : ℝ) < ‖p‖ → f p = 0) (hb : ∀ p, ‖f p‖ ≤ H) (v : I → ℝ) : + ‖pivotOutputDensity A B f v‖ ≤ pivotKernelCap J A R H := by + change ‖pivotOutputDensity A B f v‖ ≤ inverseJacobian A * (H : ℝ) * (2*(R : ℝ))^Fintype.card J + exact pivotOutputDensity_abs_le A B f R.coe_nonneg hs hb v + +theorem pivotOutputDensity_lipschitz {I J : Type*} [Fintype I] [Fintype J] + (A : (I → ℝ) ≃L[ℝ] (I → ℝ)) (B : (J → ℝ) →L[ℝ] (I → ℝ)) + {f : (J → ℝ) × (I → ℝ) → ℝ} (R K : ℝ≥0) (hf : LipschitzWith K f) + (hs : ∀ p, (R : ℝ) < ‖p‖ → f p = 0) : + LipschitzWith (pivotKernelLip J A R K) (pivotOutputDensity A B f) := by + apply LipschitzWith.of_dist_le_mul + intro v w + rw [Real.dist_eq, dist_eq_norm] + apply (pivotOutputDensity_output_bound A B hf R.coe_nonneg hs v w).trans_eq + change _ = (inverseJacobian A * (K : ℝ) * (2*(R : ℝ))^Fintype.card J * + ‖A.symm.toContinuousLinearMap‖) * ‖v-w‖ + ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PivotNormalizedMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/PivotNormalizedMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9af9f90ff0c1caa76b7d677d8db43cd92c22ab1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PivotNormalizedMatrix.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Dynamics.PivotDeterminantBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] + +noncomputable def normalizedIntegerPivot (A : Matrix I I ℤ) (S P : I → ℝ) : Matrix I I ℝ := + Matrix.diagonal (fun i => (P i)⁻¹) * A.map (Int.castRingHom ℝ) * Matrix.diagonal S + +theorem normalizedIntegerPivot_entry (A : Matrix I I ℤ) (S P : I → ℝ) (i j : I) : + normalizedIntegerPivot A S P i j = (A i j : ℝ) * S j / P i := by + simp only [normalizedIntegerPivot, Matrix.mul_diagonal, Matrix.diagonal_mul, + Matrix.map_apply, Int.coe_castRingHom, div_eq_mul_inv] + ring + +theorem normalizedIntegerPivot_abs_det (A : Matrix I I ℤ) (S P : I → ℝ) + (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) : + |(normalizedIntegerPivot A S P).det| = + (A.det.natAbs : ℝ) * (∏ i, S i) / (∏ i, P i) := by + have hprodS : 0 < ∏ i, S i := Finset.prod_pos fun i _ => hS i + have hprodP : 0 < ∏ i, P i := Finset.prod_pos fun i _ => hP i + have hd : (A.map (Int.castRingHom ℝ)).det = (A.det : ℝ) := + (RingHom.map_det (Int.castRingHom ℝ) A).symm + simp only [normalizedIntegerPivot, Matrix.det_mul, Matrix.det_diagonal, + hd, Finset.prod_inv_distrib, abs_mul, abs_inv, abs_of_pos hprodS, abs_of_pos hprodP, + Nat.cast_natAbs, Int.cast_abs, div_eq_mul_inv] + ring + +theorem normalizedIntegerPivot_det_ne_zero (A : Matrix I I ℤ) (hA : A.det ≠ 0) + (S P : I → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) : + (normalizedIntegerPivot A S P).det ≠ 0 := by + apply abs_pos.mp + rw [normalizedIntegerPivot_abs_det A S P hS hP] + have hq : (0 : ℝ) < A.det.natAbs := by exact_mod_cast Int.natAbs_pos.mpr hA + exact div_pos (mul_pos hq (Finset.prod_pos fun i _ => hS i)) + (Finset.prod_pos fun i _ => hP i) + +theorem pivotGrid_normalization_factor {J : Type*} [Fintype J] [DecidableEq J] + (A : Matrix I I ℤ) (hA : A.det ≠ 0) (B : Matrix I J ℤ) + (S P : I → ℝ) (hS : ∀ i, 0 < S i) (hP : ∀ i, 0 < P i) + {m : ℤ} (hm : m ≠ 0) (hdiv : A.det ∣ m) : + ((∏ i, P i) / (∏ i, S i)) * + (Nat.card (integerLatticeResidue (pivotFreeLattice A B) m) : ℝ) / + (m.natAbs : ℝ) ^ Fintype.card J = + ((pivotFullImage A B).toAddSubgroup.index : ℝ) / |(normalizedIntegerPivot A S P).det| := by + have hprodS : (∏ i, S i) ≠ 0 := (Finset.prod_pos fun i _ => hS i).ne' + have hprodP : (∏ i, P i) ≠ 0 := (Finset.prod_pos fun i _ => hP i).ne' + have hq : (A.det.natAbs : ℝ) ≠ 0 := by exact_mod_cast Int.natAbs_ne_zero.mpr hA + have hm' : (m.natAbs : ℝ) ^ Fintype.card J ≠ 0 := + pow_ne_zero _ (by exact_mod_cast Int.natAbs_ne_zero.mpr hm) + have hc : (Nat.card (integerLatticeResidue (pivotFreeLattice A B) m) : ℝ) * A.det.natAbs = + (m.natAbs : ℝ) ^ Fintype.card J * (pivotFullImage A B).toAddSubgroup.index := by + exact_mod_cast pivotFiberGrid_card_mul A hA B hm hdiv + rw [normalizedIntegerPivot_abs_det A S P hS hP] + field_simp + nlinarith [hc] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PositiveKernelNativeDescentBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/PositiveKernelNativeDescentBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..56ca753e5395d6f89237481b7c2beabde82e602f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PositiveKernelNativeDescentBudget.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Estimates.NativePresentPivotQuotientModel + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +noncomputable def nativePresentPivotQuotientExponent : ℕ := + Classical.choose (exists_nativePresentPivotQuotient_budget.{0, 0, 0}) + +theorem nativePresentPivotQuotientExponent_ge_two : + 2 ≤ nativePresentPivotQuotientExponent := + (Classical.choose_spec (exists_nativePresentPivotQuotient_budget.{0, 0, 0})).1 + +private noncomputable def positiveKernelNativeDescentPolynomial (s : ℕ) : Polynomial ℕ := + let q := Polynomial.X + (Polynomial.X + 2) ^ nativePresentPivotQuotientExponent + 1 + q + (q + 2) ^ nativeInvariantFamilyDescentExponent s + +noncomputable def positiveKernelNativeDescentExponent (s : ℕ) : ℕ := + Classical.choose + (exists_natPolynomial_fixed_power_budget (positiveKernelNativeDescentPolynomial s)) + +theorem positiveKernelNativeDescentExponent_ge_two (s : ℕ) : + 2 ≤ positiveKernelNativeDescentExponent s := + (Classical.choose_spec + (exists_natPolynomial_fixed_power_budget (positiveKernelNativeDescentPolynomial s))).1 + +theorem positiveKernelNativeDescentBudget_bounds (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + let pDesc := p + (p + 2) ^ nativePresentPivotQuotientExponent + 1 + p ≤ pDesc ∧ 0 ≤ pDesc ∧ + (p + 2) ^ nativePresentPivotQuotientExponent ≤ pDesc ∧ + pDesc ≤ (p + 2) ^ positiveKernelNativeDescentExponent s ∧ + (pDesc + 2) ^ nativeInvariantFamilyDescentExponent s ≤ + (p + 2) ^ positiveKernelNativeDescentExponent s := by + dsimp only + have hquotient : 0 ≤ (p + 2) ^ nativePresentPivotQuotientExponent := by positivity + have hdesc : 0 ≤ + (p + (p + 2) ^ nativePresentPivotQuotientExponent + 1 + 2) ^ + nativeInvariantFamilyDescentExponent s := by positivity + have hbudget : + p + (p + 2) ^ nativePresentPivotQuotientExponent + 1 + + (p + (p + 2) ^ nativePresentPivotQuotientExponent + 1 + 2) ^ + nativeInvariantFamilyDescentExponent s ≤ + (p + 2) ^ positiveKernelNativeDescentExponent s := by + simpa [positiveKernelNativeDescentPolynomial, positiveKernelNativeDescentExponent, + Polynomial.eval₂_pow] using + (Classical.choose_spec + (exists_natPolynomial_fixed_power_budget (positiveKernelNativeDescentPolynomial s))).2 p hp + exact ⟨by linarith, by positivity, by linarith, by linarith, by linarith⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PositivePhysicalProjectionError.lean b/lean/OAI/Combinatorics/Progressions/Linear/PositivePhysicalProjectionError.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f41e801a87f519c4381dabaa0a6bb99ebf29104 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PositivePhysicalProjectionError.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.Progressions.Estimates.PhysicalRowsSiteReconstruction + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open VectorPolynomial + +variable {I K F : Type*} [Fintype I] [Fintype K] [Fintype F] {m q : ℕ} +variable {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (root : K → ℤ) (difference : Fin q → K → ℤ) (D : ℕ) +variable (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) +variable (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) +variable (hm : ∀ j d, coefficients (p j) d ∈ U j) +variable (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) +variable (test : Finset (Fin q) → (I → ℝ) → ℂ) (htest : ∀ s v, ‖test s v‖ ≤ 1) +variable (base : I → ℤ) (modulus : I → ℕ) +variable (T : Finset (ColumnResiduePattern (Option K) I modulus)) +variable (V : Option K × I → ℝ) (hV : ∀ z, 0 < V z) +variable (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus T V z) + +local notation "frame" => (fun z : Option K × I → ℤ => fun k i => (z (k, i) : ℝ)) +local notation "output" => physicalCubeRootDifferences root (Matrix.of difference) base +local notation "law" => selectedResidueSmoothPMF modulus T V hV hZ + +include hp htest in +theorem selectedResidue_positive_density_projection_error + (density : CoefficientTorus (K := K) U → ℝ) + (f : EuclideanJetLayers U (fun j : Fin m => BoundedBooleanJet (Fin q) (j.val + 1)) → ℝ) + {η δ : ℝ} (hη : 0 ≤ η) + (happrox : ∀ x, ‖(density x : ℂ) - coefficientTorusFourierSum U frequency c x‖ ≤ η) : + let pa := fun j => translate (fun i => (base i : ℝ)) (p j) + let hma := fun j => coefficients_translate_mem (U j) (fun i => (base i : ℝ)) (p j) (hm j) + ∀ (_hpositive : ∀ z, ‖affineCubeFourierProjection U root difference frequency pa c (frame z) - + (f (euclideanCoefficientJetMap U root (Matrix.of difference) + (fun j => (Subtype.val : BoundedBooleanJet (Fin q) (j.val + 1) → Finset (Fin q))) + (affineCoefficientCoverSample U pa hma D (frame z))) : ℂ)‖ ≤ η) + (_hprojection : + ‖(∑' z, ((law z).toReal : ℂ) * (physicalCubeSiteTest test (output z) * + affineCubeFourierSum frequency pa c (frame z))) - + ∑' z, ((law z).toReal : ℂ) * (physicalCubeSiteTest test (output z) * + affineCubeFourierProjection U root difference frequency pa c (frame z))‖ ≤ δ), + ‖(∑' z, ((law z).toReal : ℂ) * (physicalCubeSiteTest test (output z) * + (density (affineSampleCoefficientTorus U pa hma (frame z)) : ℂ))) - + ∑' z, ((law z).toReal : ℂ) * physicalCubePositiveTest U D p hm f test (output z)‖ ≤ 2 * η + δ := by + intro pa hma hpositive hprojection + have hpa (j) : DegreeLE (1 : I → ℕ) (j.val + 1) (pa j) := + degreeLE_translate (1 : I → ℕ) (fun _ => by norm_num) _ (p j) (hp j) + have happ (z) : ‖(density (affineSampleCoefficientTorus U pa hma (frame z)) : ℂ) - + affineCubeFourierSum frequency pa c (frame z)‖ ≤ η := by + have h := happrox (affineSampleCoefficientTorus U pa hma (frame z)) + rw [coefficientTorusFourierSum_sample U frequency c pa hpa hma (frame z)] at h + exact h + have hpos (z) : ‖affineCubeFourierProjection U root difference frequency pa c (frame z) - + (f (physicalCubeEuclideanSample U D p hm (output z)) : ℂ)‖ ≤ η := by + have h := hpositive z + rw [coefficientCoverSample_physicalJet U root difference D p hp hm base z] at h + exact h + exact selectedResidueSmoothPMF_projection_approximation modulus T V hV hZ + (fun z => physicalCubeSiteTest test (output z)) + (fun z => (density (affineSampleCoefficientTorus U pa hma (frame z)) : ℂ)) + (fun z => affineCubeFourierSum frequency pa c (frame z)) + (fun z => affineCubeFourierProjection U root difference frequency pa c (frame z)) + (fun z => (f (physicalCubeEuclideanSample U D p hm (output z)) : ℂ)) + hη (fun z _ => physicalCubeSiteTest_norm_le test htest (output z)) + (fun z _ => happ z) (fun z _ => hpos z) hprojection + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedCenteredMarginalProjectionBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedCenteredMarginalProjectionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3159528b417094ca5bea0997f184e917565a23b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedCenteredMarginalProjectionBounds.lean @@ -0,0 +1,105 @@ +import OAI.Combinatorics.Progressions.Estimates.PreparedModularGeneralDetectorLateCoarseConsumer + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel +open scoped BigOperators Classical NNReal + +variable {m : ℕ} {G : Type} [Fintype G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable (B : LayerSamplerAxis I n → Type) [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] +variable (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (basis : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable {R σ : Fin m → ℝ} (S : LayerSamplerScale (G := G) B U basis R σ) + +structure PreparedCenteredMarginalProjectionBounds (nX : ℕ) (Pmaster Plate Pproj : ℝ) : Prop where + Pproj_nonneg : 0 ≤ Pproj + master_projection : Pmaster ≤ Pproj + late_projection : Plate ≤ Pproj + m_projection : (m : ℝ) ≤ Pproj + variables_projection : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ Pproj + X_projection : (Fintype.card (Fin nX) : ℝ) ≤ Pproj + frame_projection : (Fintype.card (Option (LayerSamplerVariables G I n B) × Fin nX) : ℝ) ≤ Pproj + coefficient_projection : ∀ j : Fin m, + (Fintype.card (BoundedCoefficientExponent (LayerSamplerVariables G I n B) (j.val + 1)) : ℝ) ≤ Pproj + I_projection : ∀ j, (Fintype.card (I j) : ℝ) ≤ Pproj + n_projection : ∀ j, (n j : ℝ) ≤ Pproj + J_projection : ∀ j, (Fintype.card (J j) : ℝ) ≤ Pproj + Rinv_projection : ∀ j, (R j)⁻¹ ≤ Real.exp Pproj + σinv_projection : ∀ j, (σ j)⁻¹ ≤ Real.exp Pproj + S_projection : (S.value : ℝ) ≤ Real.exp Pproj + root_projection : allocatedPhysicalRootBudget B U basis S (fun _ => 0) ≤ Real.exp Pproj + profile_projection : (probabilityProfileLipschitz : ℝ) ≤ Real.exp Pproj + +theorem preparedCenteredMarginalProjectionBounds + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + {s : ℕ} {Pmaster Plate D : ℝ} (hMaster : 0 ≤ Pmaster) (hLate : Pmaster ≤ Plate) + (hd : AllocatedComparisonDimensions (G := G) B (Fin (s + 1)) + (fun j : Fin m => (boundedBooleanJetRows (Fin (s + 1)) (j.val + 1) : Type)) D) + (hD : D ≤ Pmaster) {nX : ℕ} (hnX : (nX : ℝ) ≤ Pmaster) + (hRP : ∀ j, (R j)⁻¹ ≤ Real.exp Pmaster) + (hσLate : ∀ j, (σ j)⁻¹ ≤ Real.exp Plate) + (hLLate : (S.value : ℝ) ≤ Real.exp Plate) : + let r := preparedModularGeneralDetectorResources (preparedModularGeneralDetectorConstants m s) + (s + 1) Pmaster Plate + PreparedCenteredMarginalProjectionBounds B U basis S nX Pmaster Plate r.Pproj := by + intro r + have hproj : r.Pproj = 4 * (Plate + 8) ^ 2 := rfl + have hPlate : 0 ≤ Plate := hMaster.trans hLate + have hLproj : Plate ≤ r.Pproj := by + nlinarith only [hproj, hPlate, sq_nonneg Plate] + have hExpLate := Real.exp_le_exp.mpr hLproj + have hPproj : Pmaster ≤ r.Pproj := hLate.trans hLproj + have h2Pproj : 2 * Pmaster ≤ r.Pproj := by + nlinarith only [hproj, hPlate, hLate, sq_nonneg Plate] + have hframeProj : (2 * Pmaster + 1) * Pmaster ≤ r.Pproj := by + have hsq : Pmaster^2 ≤ Plate^2 := pow_le_pow_left₀ hMaster hLate 2 + nlinarith only [hproj, hPlate, hLate, hsq, sq_nonneg Plate] + have hExp := Real.exp_le_exp.mpr hPproj + have hvars : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ 2 * Pmaster := + (preparedModularGeneralDetector_variable_count B + (fun j : Fin m => boundedBooleanJetRows (Fin (s + 1)) (j.val + 1)) hd).trans + (by linarith only [hD]) + have hframe : (Fintype.card (Option (LayerSamplerVariables G I n B) × Fin nX) : ℝ) ≤ r.Pproj := by + rw [Fintype.card_prod, Fintype.card_option, Fintype.card_fin, Nat.cast_mul, Nat.cast_add, Nat.cast_one] + exact (mul_le_mul (add_le_add_left hvars 1) hnX (Nat.cast_nonneg _) (by positivity)).trans + (by simpa only [add_comm] using hframeProj) + obtain ⟨hI, hn⟩ := preparedModularGeneralDetector_layer_axes B + (fun j : Fin m => boundedBooleanJetRows (Fin (s + 1)) (j.val + 1)) hd + have hJ (j : Fin m) : (Fintype.card (J j) : ℝ) ≤ r.Pproj := + (Nat.cast_le.mpr (allocatedAmbientDimension_le_axes U basis o j)).trans + (hd.axes.trans (hD.trans hPproj)) + have hWproj : allocatedPhysicalRootBudget B U basis S (fun _ => 0) ≤ Real.exp r.Pproj := + (preparedModularGeneralDetector_physical_root B + (fun j : Fin m => boundedBooleanJetRows (Fin (s + 1)) (j.val + 1)) U basis S hd + (hD.trans hLate) hLLate).trans + (Real.exp_le_exp.mpr (by nlinarith only [hproj, hPlate, hLate, sq_nonneg Plate])) + exact { + Pproj_nonneg := hMaster.trans hPproj + master_projection := hPproj + late_projection := hLproj + m_projection := hd.degree.trans (hD.trans hPproj) + variables_projection := hvars.trans h2Pproj + X_projection := by simpa only [Fintype.card_fin] using hnX.trans hPproj + frame_projection := hframe + coefficient_projection := fun j => (hd.coefficients j).trans (hD.trans hPproj) + I_projection := fun j => (hI j).trans (hD.trans hPproj) + n_projection := fun j => (hn j).trans (hD.trans hPproj) + J_projection := hJ + Rinv_projection := fun j => (hRP j).trans hExp + σinv_projection := fun j => (hσLate j).trans hExpLate + S_projection := hLLate.trans hExpLate + root_projection := hWproj + profile_projection := ((hd.profile.trans (hD.trans hPproj)).trans + (by linarith [Real.add_one_le_exp r.Pproj])) } + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeckRankCardinality.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeckRankCardinality.lean new file mode 100644 index 0000000000000000000000000000000000000000..bccb473858d9d03b31d3d36eb28148975d850f46 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeckRankCardinality.lean @@ -0,0 +1,32 @@ +import OAI.Combinatorics.Progressions.Fourier.CommonCoveredSiteCharacter + +namespace OAI + +section + +namespace Erdos3 + +variable {J I E : Type*} [Fintype J] [Fintype I] [Fintype E] + +theorem standardLatticeSection_basis_card_eq + (W : Submodule ℝ (EuclideanSpace ℝ J)) + [IsZLattice ℝ (latticeSection (standardEuclideanLattice J) W)] + (o : OrthonormalBasis I ℝ W) + (bW : Module.Basis E ℤ (latticeSection (standardEuclideanLattice J) W)) : + Fintype.card E = Fintype.card I := by + rw [← Module.finrank_eq_card_basis bW, ZLattice.rank ℝ, + Module.finrank_eq_card_basis o.toBasis] + +theorem preparedDeckBasis_card_eq + (U : Submodule ℝ (J → ℝ)) + [IsZLattice ℝ (latticeSection (standardEuclideanLattice J) (euclideanSubspace U))] + (o : OrthonormalBasis I ℝ (euclideanSubspace U)) + (bW : Module.Basis E ℤ (latticeSection (standardEuclideanLattice J) (euclideanSubspace U))) : + Fintype.card E = Fintype.card I := + standardLatticeSection_basis_card_eq (euclideanSubspace U) o bW + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingMatrixBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingMatrixBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..48bc713d1f8476679ae4bddaf015c5d13ae01e4d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingMatrixBudget.lean @@ -0,0 +1,272 @@ +import OAI.Combinatorics.Progressions.Estimates.PreparedCenteredDeterminingSlots + +namespace OAI + +section + +namespace Erdos3.RankPreparationFamily + +open Module Submodule VectorPolynomial +open scoped BigOperators + +variable {X J : Type} {m : ℕ} (L : RankPreparationFamily X J m) +variable {E : Fin m → Type} [∀ j, Fintype (E j)] +variable [∀ j, IsZLattice ℝ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space))] +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space))) + +theorem determiningMatrix_row_abs_sum (r : L.PreparedCoordinate) : + (∑ a : L.DeterminingIndex E, |(L.determiningMatrix bW r a : ℝ)|) = + ∑ a : E r.1, |((L r.1).integralCoordinateBasis (bW r.1) a).val r.2| := by + classical + rw [Fintype.sum_sigma] + have heq (u : Fin m) : + (∑ a : E u, |(L.determiningMatrix bW r ⟨u, a⟩ : ℝ)|) = + if h : u = r.1 then + ∑ a : E r.1, |((L r.1).integralCoordinateBasis (bW r.1) a).val r.2| + else 0 := by + by_cases h : u = r.1 + · subst u + simp only [determiningMatrix, ↓reduceDIte, + (L r.1).integralCoordinateMatrix_cast (bW r.1)] + · simp [determiningMatrix, h] + simp_rw [heq] + exact Fintype.sum_dite_eq' _ _ + +theorem sortedDeterminingMatrix_row_abs_sum {n : ℕ} + (e : Fin n ≃ L.PreparedCoordinate) (i : Fin n) : + (∑ a, |(L.sortedDeterminingMatrix bW e i a : ℝ)|) = + ∑ a : E (e i).1, |((L (e i).1).integralCoordinateBasis (bW (e i).1) a).val (e i).2| := by + change (∑ a, |(L.determiningMatrix bW (e i) (sortedLayerCoordinateEquiv E a) : ℝ)|) = _ + rw [sum_sortedLayerCoordinateEquiv E (fun a => |(L.determiningMatrix bW (e i) a : ℝ)|)] + exact L.determiningMatrix_row_abs_sum bW (e i) + +theorem sortedDeterminingMatrix_row_abs_sum_le {n : ℕ} + (e : Fin n ≃ L.PreparedCoordinate) (i : Fin n) {B : ℝ} + (hB : ∀ a : E (e i).1, + |((L (e i).1).integralCoordinateBasis (bW (e i).1) a).val (e i).2| ≤ B) : + (∑ a, |(L.sortedDeterminingMatrix bW e i a : ℝ)|) ≤ (L (e i).1).rank * B := by + rw [L.sortedDeterminingMatrix_row_abs_sum bW e i] + calc + _ ≤ ∑ _a : E (e i).1, B := Finset.sum_le_sum (fun a _ => hB a) + _ = (L (e i).1).rank * B := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, + (L (e i).1).integralCoordinateBasis_card (bW (e i).1)] + +theorem sortedDeterminingMatrix_row_abs_sum_le_of_basis_norm {n : ℕ} + (e : Fin n ≃ L.PreparedCoordinate) (i : Fin n) {B : ℝ} + (hB : ∀ a : E (e i).1, ‖(bW (e i).1 a).val‖ ≤ B) : + (∑ a, |(L.sortedDeterminingMatrix bW e i a : ℝ)|) ≤ (L (e i).1).rank * B := by + apply L.sortedDeterminingMatrix_row_abs_sum_le bW e i + intro a + change |(((bW (e i).1).ofZLatticeBasis ℝ _) a).val (e i).2| ≤ B + rw [Basis.ofZLatticeBasis_apply] + have hcoord := PiLp.norm_apply_le (bW (e i).1 a).val.val (e i).2 + rw [Real.norm_eq_abs] at hcoord + exact hcoord.trans (hB a) + +end Erdos3.RankPreparationFamily + +end + +section + +namespace Erdos3 + +open Module Submodule VectorPolynomial BohrLattice.MinkowskiSecondBox +open scoped BigOperators + +namespace RankPreparationLayer + +variable {X J : Type} (L : RankPreparationLayer X J) + +theorem rank_le_coord_card : L.rank ≤ Fintype.card L.Coord := by + have h := L.rank_add_orthogonal_finrank + omega + +attribute [local irreducible] rank + +theorem shortIntegralBasisNormBound_le_exp {H R : ℕ} {p : ℝ} + (hp : 0 ≤ p) (hcoord : (Fintype.card L.Coord : ℝ) ≤ p) + (hcols : (Fintype.card L.Column : ℝ) ≤ p) + (hrows : (Fintype.card L.Row : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hR : (R : ℝ) ≤ Real.exp p) : + L.shortIntegralBasisNormBound H R ≤ Real.exp ((p + 2) ^ 124) := by + have hrank : (L.rank : ℝ) ≤ p := + (Nat.cast_le.mpr L.rank_le_coord_card).trans hcoord + have hgen := jointSpaceGeneratorHeight_le_exp + (Fintype.card L.Coord) (Fintype.card L.Column) (Fintype.card L.Row) H R + hp hcoord hcols hrows hH hR + have hfront : (L.rank : ℝ) * L.rank.factorial * minkowskiSecondConstant L.rank ≤ + Real.exp (4 * (p + 1) ^ 2) := by + calc + _ ≤ projectedAxisNormBudget L.rank := by + unfold projectedAxisNormBudget + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right + (show (L.rank : ℝ) ≤ L.rank + 1 by linarith) (Nat.cast_nonneg _)) + (minkowskiSecondConstant_nonneg L.rank) + _ ≤ Real.exp (4 * ((L.rank : ℝ) + 1) ^ 2) := projectedAxisNormBudget_le_exp L.rank + _ ≤ _ := Real.exp_le_exp.mpr (by gcongr) + have hcoordexp : (Fintype.card L.Coord : ℝ) ≤ Real.exp p := + hcoord.trans (by linarith only [Real.add_one_le_exp p]) + have hpow : + (jointSpaceGeneratorHeight (Fintype.card L.Coord) (Fintype.card L.Column) + (Fintype.card L.Row) H R : ℝ) ^ (Fintype.card L.Coord * Fintype.card L.Coord) ≤ + Real.exp (p ^ 2 * (p + 2) ^ 120) := by + apply (pow_le_pow_left₀ (Nat.cast_nonneg _) hgen _).trans + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + simp only [Nat.cast_mul] + calc + (Fintype.card L.Coord : ℝ) * Fintype.card L.Coord * (p + 2) ^ 120 ≤ + (p * p) * (p + 2) ^ 120 := by gcongr + _ = _ := by rw [pow_two] + have hnorm : L.shortIntegralBasisNormBound H R ≤ + Real.exp (4 * (p + 1) ^ 2 + p + p ^ 2 * (p + 2) ^ 120) := by + unfold shortIntegralBasisNormBound + calc + _ ≤ Real.exp (4 * (p + 1) ^ 2) * + (Real.exp p * Real.exp (p ^ 2 * (p + 2) ^ 120)) := by + apply mul_le_mul hfront (mul_le_mul hcoordexp hpow (by positivity) + (Real.exp_nonneg _)) (by positivity) (Real.exp_nonneg _) + _ = _ := by rw [Real.exp_add, Real.exp_add, mul_assoc] + apply hnorm.trans (Real.exp_le_exp.mpr ?_) + have hbase : 1 ≤ p + 2 := by linarith + have hsmall : 4 * (p + 1) ^ 2 + p ≤ 5 * (p + 2) ^ 2 := by nlinarith + have hcube : (5 : ℝ) ≤ (p + 2) ^ 3 := by + have h := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) + (by linarith : (2 : ℝ) ≤ p + 2) 3 + norm_num at h + linarith + have hsmall' : 4 * (p + 1) ^ 2 + p ≤ (p + 2) ^ 5 := by + apply hsmall.trans + calc + 5 * (p + 2) ^ 2 ≤ (p + 2) ^ 3 * (p + 2) ^ 2 := by gcongr + _ = _ := by rw [← pow_add] + have hmain : p ^ 2 * (p + 2) ^ 120 ≤ (p + 2) ^ 122 := by + calc + _ ≤ (p + 2) ^ 2 * (p + 2) ^ 120 := by gcongr; linarith + _ = _ := by rw [← pow_add] + have hsmall122 := hsmall'.trans (pow_le_pow_right₀ hbase (by decide : 5 ≤ 122)) + calc + _ ≤ (p + 2) ^ 122 + (p + 2) ^ 122 := add_le_add hsmall122 hmain + _ = 2 * (p + 2) ^ 122 := (two_mul _).symm + _ ≤ (p + 2) * (p + 2) ^ 122 := by gcongr; linarith + _ = (p + 2) ^ 123 := (pow_succ' (p + 2) 122).symm + _ ≤ (p + 2) ^ 124 := pow_le_pow_right₀ hbase (by decide) + +theorem exists_bounded_integral_basis {d H R : ℕ} {p : ℝ} + (hL : L.Valid d H R) (hH : 1 ≤ H) (hR : 1 ≤ R) + (hp : 0 ≤ p) (hcoord : (Fintype.card L.Coord : ℝ) ≤ p) + (hcols : (Fintype.card L.Column : ℝ) ≤ p) + (hrows : (Fintype.card L.Row : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hRp : (R : ℝ) ≤ Real.exp p) : + ∃ bW : Basis (Fin L.rank) ℤ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space)), + ∀ a, ‖(bW a).val‖ ≤ Real.exp ((p + 2) ^ 124) := by + obtain ⟨bW, hbW⟩ := L.exists_short_integral_basis hL hH hR + exact ⟨bW, fun a => (hbW a).trans + (L.shortIntegralBasisNormBound_le_exp hp hcoord hcols hrows hHp hRp)⟩ + +end RankPreparationLayer + +def preparedIntegralBasisExponent (m : ℕ) : ℕ := + (budgetDepthExponent 38 m + 2) * 124 + +namespace RankPreparationFamily + +variable {X J : Type} {m : ℕ} (L : RankPreparationFamily X J m) + +theorem PreparedHeights.exists_bounded_integral_bases + {p : ℝ} {R : ℕ} (hL : L.PreparedHeights p R) + (hp : 0 ≤ p) (hR : 1 ≤ R) (hRp : (R : ℝ) ≤ Real.exp p) + (hcoord : ∀ j, (Fintype.card (L j).Coord : ℝ) ≤ p) + (hcols : ∀ j, (Fintype.card (L j).Column : ℝ) ≤ p) + (hrows : ∀ j, (Fintype.card (L j).Row : ℝ) ≤ p) : + ∃ bW : ∀ j, Basis (PreparedSamplerContinuous L j) ℤ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space)), + ∀ j a, ‖(bW j a).val‖ ≤ Real.exp ((p + 2) ^ preparedIntegralBasisExponent m) := by + let q := (p + 2) ^ budgetDepthExponent 38 m + have hpq : p ≤ q := le_power_budget hp (preparationExponent_pos m) + have hq : 0 ≤ q := by dsimp only [q]; positivity + have hheight (j : Fin m) : + (preparationHeight p (m - 1 - j.val) : ℝ) ≤ Real.exp q := + (Nat.cast_le.mpr (preparationHeight_mono hp (by omega : m - 1 - j.val ≤ m))).trans + (preparationHeight_le_exp p m) + have hRpq : (R : ℝ) ≤ Real.exp q := hRp.trans (Real.exp_le_exp.mpr hpq) + have heach (j : Fin m) := (L j).exists_bounded_integral_basis + (hL j) (preparationHeight_pos hp _) hR hq + ((hcoord j).trans hpq) ((hcols j).trans hpq) ((hrows j).trans hpq) + (hheight j) hRpq + choose bW hbW using heach + refine ⟨bW, fun j a => (hbW j a).trans (Real.exp_le_exp.mpr ?_)⟩ + exact shifted_power_budget_le hp (budgetDepthExponent 38 m) 124 + +theorem PreparedHeights.exists_bounded_integral_bases_of_sized + {p : ℝ} {R D t T : ℕ} (hL : L.PreparedHeights p R) + (hp : 0 ≤ p) (hR : 1 ≤ R) (hRp : (R : ℝ) ≤ Real.exp p) + (hsize : L.Sized D t) (ht : t ≤ T) + (hcap : (preparationCoordinateCap m D T : ℝ) ≤ p) : + ∃ bW : ∀ j, Basis (PreparedSamplerContinuous L j) ℤ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space)), + ∀ j a, ‖(bW j a).val‖ ≤ Real.exp ((p + 2) ^ preparedIntegralBasisExponent m) := by + apply hL.exists_bounded_integral_bases L hp hR hRp + · intro j + exact (Nat.cast_le.mpr (preparationCoordinateCap_bounds hsize ht j).1).trans hcap + · intro j + exact (Nat.cast_le.mpr (preparationCoordinateCap_bounds hsize ht j).2.1).trans hcap + · intro j + have h := (preparationCoordinateCap_bounds hsize ht j).2.2 + exact (Nat.cast_le.mpr (Nat.le_trans (Nat.le_succ _) h)).trans hcap + +end RankPreparationFamily +end Erdos3 + +end + +section + +namespace Erdos3.RankPreparationFamily + +open Module Submodule VectorPolynomial +open scoped BigOperators + +variable {X J : Type} {m : ℕ} (L : RankPreparationFamily X J m) +variable {E : Fin m → Type} [∀ j, Fintype (E j)] +variable [∀ j, IsZLattice ℝ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space))] +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space))) + +theorem sortedDeterminingMatrix_row_abs_sum_le_exp {p : ℝ} + (hp : 0 ≤ p) (hcoord : ∀ j, (Fintype.card (L j).Coord : ℝ) ≤ p) + (hbW : ∀ j a, ‖(bW j a).val‖ ≤ Real.exp ((p + 2) ^ preparedIntegralBasisExponent m)) + {n : ℕ} (e : Fin n ≃ L.PreparedCoordinate) (i : Fin n) : + (∑ a, |(L.sortedDeterminingMatrix bW e i a : ℝ)|) ≤ + Real.exp ((p + 2) ^ (preparedIntegralBasisExponent m + 1)) := by + have hrank : ((L (e i).1).rank : ℝ) ≤ p := + (Nat.cast_le.mpr (L (e i).1).rank_le_coord_card).trans (hcoord (e i).1) + have hrankexp : ((L (e i).1).rank : ℝ) ≤ Real.exp p := + hrank.trans (by linarith only [Real.add_one_le_exp p]) + have hpower : p ≤ (p + 2) ^ preparedIntegralBasisExponent m := + le_power_budget hp (by unfold preparedIntegralBasisExponent; omega) + calc + _ ≤ (L (e i).1).rank * Real.exp ((p + 2) ^ preparedIntegralBasisExponent m) := + L.sortedDeterminingMatrix_row_abs_sum_le_of_basis_norm bW e i (hbW (e i).1) + _ ≤ Real.exp p * Real.exp ((p + 2) ^ preparedIntegralBasisExponent m) := + mul_le_mul_of_nonneg_right hrankexp (Real.exp_nonneg _) + _ = Real.exp (p + (p + 2) ^ preparedIntegralBasisExponent m) := + (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by + calc + _ ≤ 2 * (p + 2) ^ preparedIntegralBasisExponent m := by linarith only [hpower] + _ ≤ (p + 2) * (p + 2) ^ preparedIntegralBasisExponent m := by gcongr; linarith + _ = _ := (pow_succ' (p + 2) (preparedIntegralBasisExponent m)).symm) + +end Erdos3.RankPreparationFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingMatrixColumns.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingMatrixColumns.lean new file mode 100644 index 0000000000000000000000000000000000000000..5212e01061199bf24532a37c3275b5e60cdae9bd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingMatrixColumns.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.Progressions.Estimates.PreparedDilatedDeterminingSlots + +namespace OAI + +section + +namespace Erdos3.RankPreparationFamily + +open Module Submodule VectorPolynomial +open scoped BigOperators + +variable {X J : Type} {m : ℕ} (L : RankPreparationFamily X J m) +variable {E : Fin m → Type} [∀ j, Fintype (E j)] +variable [∀ j, IsZLattice ℝ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space))] +variable (bW : ∀ j, Basis (E j) ℤ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (L j).space))) + +theorem determiningMatrix_column_mem (j : Fin m) (a : L.DeterminingIndex E) : + (standardEuclideanPoint (L j).Coord (fun i => L.determiningMatrix bW ⟨j,i⟩ a)).val ∈ + euclideanSubspace (L j).space := by + classical + rcases a with ⟨u,a⟩ + by_cases h : u = j + · subst u + change (fun i => (L.determiningMatrix bW ⟨j,i⟩ ⟨j,a⟩ : ℝ)) ∈ (L j).space + have heq : (fun i => (L.determiningMatrix bW ⟨j,i⟩ ⟨j,a⟩ : ℝ)) = + ((L j).integralCoordinateBasis (bW j) a).val := by + funext i + rw [L.determiningMatrix_same bW, ← (L j).integralCoordinateMatrix_cast (bW j)] + rw [heq] + exact ((L j).integralCoordinateBasis (bW j) a).property + · have heq : (fun i => L.determiningMatrix bW ⟨j,i⟩ ⟨u,a⟩) = 0 := by + funext i + simp [determiningMatrix, h] + rw [heq] + have hz : (standardEuclideanPoint (L j).Coord 0).val = 0 := by + ext i + simp [standardEuclideanPoint_apply] + rw [hz] + exact (euclideanSubspace (L j).space).zero_mem + +theorem sortedDeterminingMatrix_column_mem {n : ℕ} + (e : Fin n ≃ L.PreparedCoordinate) (j : Fin m) + (a : Fin (Fintype.card (Σ j, E j))) : + (standardEuclideanPoint (L j).Coord + (fun i => L.sortedDeterminingMatrix bW e (e.symm ⟨j,i⟩) a)).val ∈ + euclideanSubspace (L j).space := by + simpa only [sortedDeterminingMatrix, Equiv.apply_symm_apply] using + L.determiningMatrix_column_mem bW j (sortedLayerCoordinateEquiv E a) + +theorem dilatedSortedDeterminingMatrix_column_mem (q : ℕ) {n : ℕ} + (e : Fin n ≃ L.PreparedCoordinate) (j : Fin m) + (a : Fin (Fintype.card (Σ j, E j))) : + (standardEuclideanPoint (L j).Coord + (fun i => L.dilatedSortedDeterminingMatrix bW q e (e.symm ⟨j,i⟩) a)).val ∈ + euclideanSubspace (L j).space := by + have h := (euclideanSubspace (L j).space).smul_mem (q : ℝ) + (L.sortedDeterminingMatrix_column_mem bW e j a) + have heq : (standardEuclideanPoint (L j).Coord + (fun i => L.dilatedSortedDeterminingMatrix bW q e (e.symm ⟨j,i⟩) a)).val = + (q : ℝ) • (standardEuclideanPoint (L j).Coord + (fun i => L.sortedDeterminingMatrix bW e (e.symm ⟨j,i⟩) a)).val := by + ext i + simp only [standardEuclideanPoint_apply, dilatedSortedDeterminingMatrix, + dilatedIntegerMatrix, Int.cast_mul, Int.cast_natCast, PiLp.smul_apply, smul_eq_mul] + rw [heq] + exact h + +end Erdos3.RankPreparationFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingRank.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb81f8ed98cd5195afa4f8165d0f39b1ffc8a0fc --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedDeterminingRank.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.Progressions.Sampling.ForecastPreparedScaleBudget + +namespace OAI + +section + +namespace Erdos3 + +open Module Submodule VectorPolynomial +open scoped BigOperators + +namespace RankPreparationFamily + +variable {X J : Type} {m : ℕ} (L : RankPreparationFamily X J m) + +theorem determining_card : + Fintype.card (Σ j, PreparedSamplerContinuous L j) = ∑ j, (L j).rank := by + simp only [Fintype.card_sigma, PreparedSamplerContinuous, Fintype.card_fin] + +theorem determining_card_le_potential : + Fintype.card (Σ j, PreparedSamplerContinuous L j) ≤ L.potential := by + rw [L.determining_card] + exact sum_ranks_le_potential (fun j => (L j).rank) + +variable (U : ∀ j, Submodule ℝ ((L j).Coord → ℝ)) +variable (b : ∀ j, Basis (Fin (preparedSamplerTransverse L j)) ℝ + (euclideanSubspace (U j))ᗮ) +variable (o : ∀ j, OrthonormalBasis (PreparedSamplerContinuous L j) ℝ + (euclideanSubspace (U j))) +variable {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] +variable (bW : ∀ j, Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (U j)))) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = + projectedIntegerLattice (euclideanSubspace (U j))) + +include U b o bW hb + +theorem lattice_determining_card : Fintype.card (Σ j, Eout j) = ∑ j, (L j).rank := by + rw [Fintype.card_sigma] + apply Finset.sum_congr rfl + intro j _ + simpa only [PreparedSamplerContinuous, Fintype.card_fin] using + allocatedLatticeDimension_eq U b o hb bW j + +theorem lattice_determining_card_le {D : ℕ} + (hprepared : (∑ j, (L j).rank) ≤ m * D) : + Fintype.card (Σ j, Eout j) ≤ m * D := by + rw [L.lattice_determining_card U b o bW hb] + exact hprepared + +theorem recovered_lattice_rank_bound {s d₀ d D E : ℕ} + (hprepared : (∑ j, (L j).rank) ≤ m * D) + (hD : D ≤ d) (hE : E ≤ d₀ + s * (d - D)) (hm : m ≤ s) : + Fintype.card (Σ j, Eout j) + E ≤ d₀ + s * d := + recursive_patch_step_rank_bound hD hE + (L.lattice_determining_card_le U b o bW hb hprepared) hm + +end RankPreparationFamily + +namespace PolynomialPatch + +variable {X J σ : Type} {m s d₀ d D E : ℕ} (L : RankPreparationFamily X J m) +variable (U : ∀ j, Submodule ℝ ((L j).Coord → ℝ)) +variable (b : ∀ j, Basis (Fin (preparedSamplerTransverse L j)) ℝ + (euclideanSubspace (U j))ᗮ) +variable (o : ∀ j, OrthonormalBasis (PreparedSamplerContinuous L j) ℝ + (euclideanSubspace (U j))) +variable {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] +variable (bW : ∀ j, Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (L j).Coord) (euclideanSubspace (U j)))) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = + projectedIntegerLattice (euclideanSubspace (U j))) +variable (hprepared : (∑ j, (L j).rank) ≤ m * D) +variable (hs : 1 ≤ s) (hD : D ≤ d) (hE : E ≤ d₀ + s * (d - D)) (hm : m ≤ s) + +noncomputable def padPreparedRecoveredRank + (Q : PolynomialPatch σ s (Fintype.card (Σ j, Eout j) + E)) : + PolynomialPatch σ s (d₀ + s * d) := + Q.padRank hs (L.recovered_lattice_rank_bound U b o bW hb hprepared hD hE hm) + +@[simp] theorem padPreparedRecoveredRank_value + (Q : PolynomialPatch σ s (Fintype.card (Σ j, Eout j) + E)) (x : σ → ℝ) : + (Q.padPreparedRecoveredRank L U b o bW hb hprepared hs hD hE hm).value x = + Q.value x := padRank_value _ _ _ _ + +@[simp] theorem padPreparedRecoveredRank_lip + (Q : PolynomialPatch σ s (Fintype.card (Σ j, Eout j) + E)) : + (Q.padPreparedRecoveredRank L U b o bW hb hprepared hs hD hE hm).kernel.lip = + Q.kernel.lip + 4 := padRank_lip _ _ _ + +end PolynomialPatch +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedFiniteNestedSourceProjectionBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedFiniteNestedSourceProjectionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9eb91897999349225d3c58f009fe2479ecc3c2be --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedFiniteNestedSourceProjectionBudget.lean @@ -0,0 +1,486 @@ +import OAI.Combinatorics.Progressions.Dynamics.PreparedFiniteNestedCanonicalEarlyPrimitiveBudget +import OAI.Combinatorics.Progressions.Dynamics.PreparedFiniteNestedSourceLatePowerBudget + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +def preparedFiniteForwardFrontProjectionPrecision (u p native : ℝ) : ℝ := + u + 2 * p + max (max native 3) (2 * u + 4 * p + 20) + 32 + +theorem preparedFiniteForwardFrontProjectionPrecision_nonneg + {u p native : ℝ} (hu : 0 ≤ u) (hp : 0 ≤ p) : + 0 ≤ preparedFiniteForwardFrontProjectionPrecision u p native := by + have hmax : 2 * u + 4 * p + 20 ≤ max (max native 3) (2 * u + 4 * p + 20) := + le_max_right _ _ + unfold preparedFiniteForwardFrontProjectionPrecision + linarith only [hu, hp, hmax] + +theorem exists_preparedFiniteForwardFrontProjectionPrecision_budget (Cnative : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {t u p native : ℝ}, 0 ≤ t → + u ∈ Set.Icc 0 t → p ∈ Set.Icc 0 t → + native ∈ Set.Icc 0 ((t + Cnative) ^ Cnative) → + preparedFiniteForwardFrontProjectionPrecision u p native ∈ Set.Icc 0 ((t + C) ^ C) := by + let Q : Polynomial ℕ := (Polynomial.X + Polynomial.C Cnative) ^ Cnative + + 9 * Polynomial.X + 55 + obtain ⟨C, hC, hpoly⟩ := exists_natPolynomial_eval_budget Q + refine ⟨C, hC, ?_⟩ + intro t u p native ht hu hp hn + let v : ℝ := (t + Cnative) ^ Cnative + have hv : 0 ≤ v := by dsimp only [v]; positivity + have hcommon : max native 3 ≤ v + 3 := + max_le (by linarith only [hn.2]) (by linarith only [hv]) + have hmax : max (max native 3) (2 * u + 4 * p + 20) ≤ v + 6 * t + 23 := + max_le (by linarith only [hcommon, ht]) (by linarith only [hu.2, hp.2, hv]) + have hbudget : v + 9 * t + 55 ≤ (t + C) ^ C := by + simpa [Q, v, Polynomial.eval₂_pow] using hpoly t ht + refine ⟨preparedFiniteForwardFrontProjectionPrecision_nonneg hu.1 hp.1, ?_⟩ + unfold preparedFiniteForwardFrontProjectionPrecision + linarith only [hmax, hu.2, hp.2, hbudget] + +theorem exists_preparedFiniteForwardFrontProjection_budget (Cnative : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (A Cdirect : ℕ) (stageCountConstant : ℕ → ℕ) (n : ℕ) + {x gainLog stageLog native : ℝ}, 0 ≤ x → + gainLog ∈ Set.Icc 0 x → stageLog ∈ Set.Icc 0 x → + let u := preparedFiniteForwardModelPrecision A stageCountConstant n x gainLog stageLog + let p := preparedFiniteForwardWork A stageCountConstant n x + let t := preparedFiniteForwardPairedSourcePrecision A Cdirect stageCountConstant n false + x gainLog stageLog + p + native ∈ Set.Icc 0 ((t + Cnative) ^ Cnative) → + preparedFiniteForwardFrontProjectionPrecision u p native ∈ Set.Icc 0 ((t + C) ^ C) := by + obtain ⟨C, hC, hbound⟩ := exists_preparedFiniteForwardFrontProjectionPrecision_budget Cnative + refine ⟨C, hC, ?_⟩ + intro A Cdirect stageCountConstant n x gainLog stageLog native hx hg hs u p t hn + have hprecision := preparedFiniteForward_model_precision_bounds A stageCountConstant n hx hg hs + have hu : 0 ≤ u := hprecision.1 + have hp : 0 ≤ p := preparedFiniteForwardWork_nonneg A stageCountConstant n hx + have htEq : t = u + 3 * p + 1 := by + dsimp only [t] + rw [preparedFiniteForwardPairedSourcePrecision_model] + have heq : preparedFiniteForwardSourcePrecision A stageCountConstant n x gainLog stageLog = + u + 2 * p + 1 := hprecision.2.2.1 + rw [heq] + ring + have ht : 0 ≤ t := by linarith only [htEq, hu, hp] + exact hbound ht ⟨hu, by linarith only [htEq, hp]⟩ + ⟨hp, by linarith only [htEq, hu, hp]⟩ hn + +noncomputable def preparedFiniteForwardFrontProjectionExponent (Cnative : ℕ) : ℕ := + Classical.choose (exists_preparedFiniteForwardFrontProjection_budget Cnative) + +theorem preparedFiniteForwardFrontProjectionExponent_two_le (Cnative : ℕ) : + 2 ≤ preparedFiniteForwardFrontProjectionExponent Cnative := + (Classical.choose_spec (exists_preparedFiniteForwardFrontProjection_budget Cnative)).1 + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +noncomputable def preparedFiniteScheduleLocalDegreeRequired + {Stage : Type*} [Fintype Stage] (m : ℕ) (degree : Stage → ℕ) + (Pmaster : Stage → ℝ) (Plate E extraRequired : ℝ) : ℝ := + let r := fun k => preparedModularGeneralDetectorResources + (preparedModularGeneralDetectorConstants m (degree k)) (degree k + 1) (Pmaster k) Plate + let modelRequired := fun k => max (r k).required + ((max (r k).Pproj E + preparedCenteredMarginalExponent m) ^ + preparedCenteredMarginalExponent m) + max (∑ k, max 0 (modelRequired k)) extraRequired + +theorem exists_preparedFiniteScheduleRequiredRank_power_budget + (m cutoff stageCount inputPower : ℕ) : + ∃ requiredPower : ℕ, 2 ≤ requiredPower ∧ + ∀ {Stage : Type*} [Fintype Stage] (degree : Stage → ℕ), + (∀ k, degree k ≤ cutoff) → Fintype.card Stage ≤ stageCount → + ∀ {p : ℝ}, 2 ≤ p → ∀ (Pmaster : Stage → ℝ) (Plate E extraRequired : ℝ), + (∀ k, 0 ≤ Pmaster k) → (∀ k, Pmaster k ≤ Plate) → + Plate ≤ (p + 2) ^ inputPower → E ≤ (p + 2) ^ inputPower → + extraRequired ≤ (p + 2) ^ inputPower → + preparedFiniteScheduleLocalDegreeRequired m degree Pmaster Plate E extraRequired ≤ + (p + 2) ^ requiredPower ∧ + 1 ≤ preparedRoundedRank p requiredPower ∧ + Real.exp (preparedFiniteScheduleLocalDegreeRequired m degree Pmaster Plate E extraRequired) ≤ + (preparedRoundedRank p requiredPower : ℝ) ∧ + (preparedRoundedRank p requiredPower : ℝ) ≤ + Real.exp ((p + 2) ^ (requiredPower + 1)) := by + obtain ⟨C, _, hresources⟩ := exists_preparedModularGeneral_cutoff_resource_budget m cutoff + let A := preparedCenteredMarginalExponent m + let U : Polynomial ℕ := (Polynomial.X + 2) ^ inputPower + let B : Polynomial ℕ := (2 * U + Polynomial.C C) ^ C + let V : Polynomial ℕ := B + (B + U + Polynomial.C A) ^ A + let envelope : Polynomial ℕ := Polynomial.C stageCount * V + U + obtain ⟨requiredPower, hpower, henvelope⟩ := exists_natPolynomial_fixed_power_budget envelope + refine ⟨requiredPower, hpower, ?_⟩ + intro Stage _ degree hdegree hcard p hp Pmaster Plate E extraRequired + hMaster hMasterLate hPlate hE hextra + let u := (p + 2) ^ inputPower + let b := (2 * u + C) ^ C + let v := b + (b + u + A) ^ A + let r := fun k => preparedModularGeneralDetectorResources + (preparedModularGeneralDetectorConstants m (degree k)) (degree k + 1) (Pmaster k) Plate + have hu : 0 ≤ u := by dsimp only [u]; positivity + have hb : 0 ≤ b := by dsimp only [b]; positivity + have hmarg0 : 0 ≤ (b + u + A) ^ A := by positivity + have hv : 0 ≤ v := add_nonneg hb hmarg0 + have hmodel (k : Stage) : max 0 + (max (r k).required ((max (r k).Pproj E + A) ^ A)) ≤ v := by + have hres := hresources (hMaster k) (hMasterLate k) (degree k) (hdegree k) + have hlate0 := (hMaster k).trans (hMasterLate k) + have hresbound : (Pmaster k + Plate + C) ^ C ≤ b := by + apply pow_le_pow_left₀ + (add_nonneg (add_nonneg (hMaster k) hlate0) (Nat.cast_nonneg C)) + change Pmaster k + Plate + C ≤ 2 * u + C + have hmaster := (hMasterLate k).trans hPlate + linarith only [hmaster, hPlate] + have hrequired : (r k).required ≤ b := hres.required.2.trans hresbound + have hproj : (r k).Pproj ≤ b := hres.Pproj.2.trans hresbound + have hmarg : (max (r k).Pproj E + A) ^ A ≤ (b + u + A) ^ A := by + apply pow_le_pow_left₀ + (add_nonneg (hres.Pproj.1.trans (le_max_left _ _)) (Nat.cast_nonneg A)) + apply add_le_add _ le_rfl + exact max_le (hproj.trans (le_add_of_nonneg_right hu)) + (hE.trans (le_add_of_nonneg_left hb)) + apply max_le hv + exact max_le (hrequired.trans (le_add_of_nonneg_right hmarg0)) + (hmarg.trans (le_add_of_nonneg_left hb)) + have hsum : (∑ k : Stage, max 0 + (max (r k).required ((max (r k).Pproj E + A) ^ A))) ≤ (stageCount : ℝ) * v := by + calc + _ ≤ ∑ _k : Stage, v := Finset.sum_le_sum (fun k _ => hmodel k) + _ = (Fintype.card Stage : ℝ) * v := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hcard) hv + have hbound : preparedFiniteScheduleLocalDegreeRequired + m degree Pmaster Plate E extraRequired ≤ (p + 2) ^ requiredPower := by + have htotal : (stageCount : ℝ) * v + u ≤ (p + 2) ^ requiredPower := by + simpa [envelope, V, B, U, v, b, u, Polynomial.eval₂_pow] using + henvelope p (by linarith : 0 ≤ p) + apply le_trans (b := (stageCount : ℝ) * v + u) _ htotal + change max (∑ k : Stage, max 0 + (max (r k).required ((max (r k).Pproj E + A) ^ A))) extraRequired ≤ _ + exact max_le (hsum.trans (le_add_of_nonneg_right hu)) + (hextra.trans (le_add_of_nonneg_left (mul_nonneg (Nat.cast_nonneg _) hv))) + exact ⟨hbound, preparedRoundedRank_one_le p requiredPower, + preparedRoundedRank_exp_requirement hbound, preparedRoundedRank_le_exp hp requiredPower⟩ + +theorem exists_preparedFiniteScheduleUniformRequiredRank_power_budget + (s cutoff stageCount inputPower : ℕ) : + ∃ requiredPower : ℕ, 2 ≤ requiredPower ∧ + ∀ m : ℕ, m ≤ s → + ∀ {Stage : Type*} [Fintype Stage] (degree : Stage → ℕ), + (∀ k, degree k ≤ cutoff) → Fintype.card Stage ≤ stageCount → + ∀ {p : ℝ}, 2 ≤ p → ∀ (Pmaster : Stage → ℝ) (Plate E extraRequired : ℝ), + (∀ k, 0 ≤ Pmaster k) → (∀ k, Pmaster k ≤ Plate) → + Plate ≤ (p + 2) ^ inputPower → E ≤ (p + 2) ^ inputPower → + extraRequired ≤ (p + 2) ^ inputPower → + preparedFiniteScheduleLocalDegreeRequired m degree Pmaster Plate E extraRequired ≤ + (p + 2) ^ requiredPower ∧ + 1 ≤ preparedRoundedRank p requiredPower ∧ + Real.exp (preparedFiniteScheduleLocalDegreeRequired m degree Pmaster Plate E extraRequired) ≤ + (preparedRoundedRank p requiredPower : ℝ) ∧ + (preparedRoundedRank p requiredPower : ℝ) ≤ + Real.exp ((p + 2) ^ (requiredPower + 1)) := by + let exponent (m : ℕ) := + (exists_preparedFiniteScheduleRequiredRank_power_budget m cutoff stageCount inputPower).choose + let requiredPower := 2 + ∑ j ∈ Finset.range (s + 1), exponent j + refine ⟨requiredPower, by dsimp only [requiredPower]; omega, ?_⟩ + intro m hm Stage _ degree hdegree hcard p hp Pmaster Plate E extraRequired + hMaster hMasterLate hPlate hE hextra + have hexponent : exponent m ≤ requiredPower := by + have hsum : exponent m ≤ ∑ j ∈ Finset.range (s + 1), exponent j := + Finset.single_le_sum (f := exponent) (fun _ _ => Nat.zero_le _) + (Finset.mem_range.mpr (Nat.lt_succ_of_le hm)) + dsimp only [requiredPower] + omega + have hlocal := ((exists_preparedFiniteScheduleRequiredRank_power_budget + m cutoff stageCount inputPower).choose_spec.2 degree hdegree hcard hp + Pmaster Plate E extraRequired hMaster hMasterLate hPlate hE hextra).1 + change preparedFiniteScheduleLocalDegreeRequired m degree Pmaster Plate E extraRequired ≤ + (p + 2) ^ exponent m at hlocal + have hbound : preparedFiniteScheduleLocalDegreeRequired + m degree Pmaster Plate E extraRequired ≤ (p + 2) ^ requiredPower := + hlocal.trans (pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) hexponent) + exact ⟨hbound, preparedRoundedRank_one_le p requiredPower, + preparedRoundedRank_exp_requirement hbound, preparedRoundedRank_le_exp hp requiredPower⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +noncomputable def preparedConditionalExcessRequired (m : ℕ) (Plate E : ℝ) : ℝ := + (max (4 * (Plate + 8) ^ 2) E + allocatedExternalConditionalExcessExponent m) ^ + allocatedExternalConditionalExcessExponent m + +theorem preparedConditionalExcessRequired_le_preparedFiniteScheduleLocalDegreeRequired + {Stage : Type*} [Fintype Stage] (m : ℕ) (degree : Stage → ℕ) + (Pmaster : Stage → ℝ) (Plate E : ℝ) : + preparedConditionalExcessRequired m Plate E ≤ + preparedFiniteScheduleLocalDegreeRequired m degree Pmaster Plate E + (preparedConditionalExcessRequired m Plate E) := by + exact le_max_right _ _ + +theorem preparedFiniteScheduleConditionalExcess_exp_le + {Stage : Type*} [Fintype Stage] (m : ℕ) (degree : Stage → ℕ) + (Pmaster : Stage → ℝ) (Plate E : ℝ) {bound : ℝ} + (hbound : Real.exp (preparedFiniteScheduleLocalDegreeRequired + m degree Pmaster Plate E (preparedConditionalExcessRequired m Plate E)) ≤ bound) : + Real.exp ((max (4 * (Plate + 8) ^ 2) E + + allocatedExternalConditionalExcessExponent m) ^ + allocatedExternalConditionalExcessExponent m) ≤ bound := by + exact (Real.exp_le_exp.mpr + (preparedConditionalExcessRequired_le_preparedFiniteScheduleLocalDegreeRequired + m degree Pmaster Plate E)).trans hbound + +theorem preparedFiniteScheduleConditionalExcess_size_rank + {Stage X : Type*} [Fintype Stage] (m : ℕ) (degree : Stage → ℕ) + (Pmaster : Stage → ℝ) (Plate E : ℝ) (N : X → ℕ) (rank : ℝ) + (hsize : ∀ x, Real.exp (preparedFiniteScheduleLocalDegreeRequired + m degree Pmaster Plate E (preparedConditionalExcessRequired m Plate E)) ≤ (N x : ℝ)) + (hRank : Real.exp (preparedFiniteScheduleLocalDegreeRequired + m degree Pmaster Plate E (preparedConditionalExcessRequired m Plate E)) ≤ rank) : + (∀ x, Real.exp ((max (4 * (Plate + 8) ^ 2) E + + allocatedExternalConditionalExcessExponent m) ^ + allocatedExternalConditionalExcessExponent m) ≤ (N x : ℝ)) ∧ + Real.exp ((max (4 * (Plate + 8) ^ 2) E + + allocatedExternalConditionalExcessExponent m) ^ + allocatedExternalConditionalExcessExponent m) ≤ rank := by + exact ⟨fun x => preparedFiniteScheduleConditionalExcess_exp_le + m degree Pmaster Plate E (hsize x), + preparedFiniteScheduleConditionalExcess_exp_le m degree Pmaster Plate E hRank⟩ + +theorem exists_preparedFiniteScheduleConditionalExcess_power_budget (m inputPower : ℕ) : + ∃ extraPower : ℕ, 2 ≤ extraPower ∧ + ∀ {p Plate E : ℝ}, 2 ≤ p → 0 ≤ Plate → + Plate ≤ (p + 2) ^ inputPower → E ≤ (p + 2) ^ inputPower → + preparedConditionalExcessRequired m Plate E ≤ (p + 2) ^ extraPower := by + let A := allocatedExternalConditionalExcessExponent m + let U : Polynomial ℕ := (Polynomial.X + 2) ^ inputPower + let Q : Polynomial ℕ := (4 * (U + 8) ^ 2 + U + Polynomial.C A) ^ A + obtain ⟨extraPower, hpower, hQ⟩ := exists_natPolynomial_fixed_power_budget Q + refine ⟨extraPower, hpower, ?_⟩ + intro p Plate E hp hPlate0 hPlate hE + let u := (p + 2) ^ inputPower + have hu : 0 ≤ u := by dsimp only [u]; positivity + have hproj : 4 * (Plate + 8) ^ 2 ≤ 4 * (u + 8) ^ 2 := by + exact mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (by linarith : 0 ≤ Plate + 8) + (add_le_add hPlate le_rfl) 2) (by norm_num) + have hmax : max (4 * (Plate + 8) ^ 2) E ≤ 4 * (u + 8) ^ 2 + u := by + exact max_le (hproj.trans (le_add_of_nonneg_right hu)) + (hE.trans (le_add_of_nonneg_left (by positivity))) + have hbound : preparedConditionalExcessRequired m Plate E ≤ + (4 * (u + 8) ^ 2 + u + A) ^ A := by + apply pow_le_pow_left₀ + (add_nonneg ((by positivity : 0 ≤ 4 * (Plate + 8) ^ 2).trans + (le_max_left _ _)) (Nat.cast_nonneg A)) + exact add_le_add hmax le_rfl + apply hbound.trans + simpa [Q, U, u, Polynomial.eval₂_pow] using hQ p (by linarith : 0 ≤ p) + +theorem exists_preparedFiniteScheduleUniformConditionalExcess_power_budget + (s inputPower : ℕ) : + ∃ extraPower : ℕ, 2 ≤ extraPower ∧ + ∀ m : ℕ, m ≤ s → + ∀ {p Plate E : ℝ}, 2 ≤ p → 0 ≤ Plate → + Plate ≤ (p + 2) ^ inputPower → E ≤ (p + 2) ^ inputPower → + preparedConditionalExcessRequired m Plate E ≤ (p + 2) ^ extraPower := by + let exponent (m : ℕ) := + (exists_preparedFiniteScheduleConditionalExcess_power_budget m inputPower).choose + let extraPower := 2 + ∑ j ∈ Finset.range (s + 1), exponent j + refine ⟨extraPower, by dsimp only [extraPower]; omega, ?_⟩ + intro m hm p Plate E hp hPlate0 hPlate hE + have hexponent : exponent m ≤ extraPower := by + have hsum : exponent m ≤ ∑ j ∈ Finset.range (s + 1), exponent j := + Finset.single_le_sum (f := exponent) (fun _ _ => Nat.zero_le _) + (Finset.mem_range.mpr (Nat.lt_succ_of_le hm)) + dsimp only [extraPower] + omega + have hlocal := (exists_preparedFiniteScheduleConditionalExcess_power_budget + m inputPower).choose_spec.2 hp hPlate0 hPlate hE + change preparedConditionalExcessRequired m Plate E ≤ (p + 2) ^ exponent m at hlocal + exact hlocal.trans (pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) hexponent) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators + +noncomputable def preparedNestedFrontProjectionEnvelope + {K : Type*} [Fintype K] (A : ℕ) (constants : ℕ → ℕ) + (innerDepth : ℕ) (outer inner : K → ℕ) (native : K → ℝ) + (x gainLog stageLog endpoint : ℝ) : ℝ := + endpoint + 1 + ∑ k, preparedFiniteForwardFrontProjectionPrecision + (preparedFiniteForwardModelPrecision A constants (inner k) + (candidateNestedForwardSeed A constants innerDepth (outer k) x) gainLog stageLog) + (preparedFiniteForwardWork A constants (inner k) + (candidateNestedForwardSeed A constants innerDepth (outer k) x)) (native k) + +theorem exists_preparedNestedFrontProjectionEnvelope_budget + (A Cdirect Cnative : ℕ) (constants : ℕ → ℕ) + (innerDepth outerDepth cardBound inputPower maxLayers : ℕ) (hA : 2 ≤ A) : + ∃ projectionPower requiredPower : ℕ, 2 ≤ projectionPower ∧ 2 ≤ requiredPower ∧ + ∀ {K : Type*} [Fintype K] (outer inner : K → ℕ) (native : K → ℝ), + Fintype.card K ≤ cardBound → (∀ k, outer k ≤ outerDepth) → + (∀ k, inner k ≤ innerDepth) → + ∀ {x gainLog stageLog endpoint Plate : ℝ}, 2 ≤ x → + gainLog ∈ Set.Icc 0 x → stageLog ∈ Set.Icc 0 x → + endpoint ∈ Set.Icc 0 ((x + 2) ^ inputPower) → + Plate ∈ Set.Icc 0 ((x + 2) ^ inputPower) → + (∀ k, native k ∈ Set.Icc 0 + ((preparedFiniteForwardPairedSourcePrecision A Cdirect constants (inner k) false + (candidateNestedForwardSeed A constants innerDepth (outer k) x) gainLog stageLog + + preparedFiniteForwardWork A constants (inner k) + (candidateNestedForwardSeed A constants innerDepth (outer k) x) + Cnative) ^ Cnative)) → + let E := preparedNestedFrontProjectionEnvelope A constants innerDepth + outer inner native x gainLog stageLog endpoint + E ∈ Set.Icc 0 ((x + 2) ^ projectionPower) ∧ endpoint ≤ E ∧ + (∀ k, preparedFiniteForwardFrontProjectionPrecision + (preparedFiniteForwardModelPrecision A constants (inner k) + (candidateNestedForwardSeed A constants innerDepth (outer k) x) gainLog stageLog) + (preparedFiniteForwardWork A constants (inner k) + (candidateNestedForwardSeed A constants innerDepth (outer k) x)) (native k) ≤ E) ∧ + ∀ m ≤ maxLayers, + preparedConditionalExcessRequired m Plate E ≤ (x + 2) ^ requiredPower := by + obtain ⟨D, _, hlocal⟩ := exists_candidateNestedForwardLocal_budget + A Cdirect constants innerDepth outerDepth hA + obtain ⟨C, _, hfront⟩ := exists_preparedFiniteForwardFrontProjection_budget Cnative + let B : Polynomial ℕ := (Polynomial.X + 2) ^ D + let Q : Polynomial ℕ := (Polynomial.X + 2) ^ inputPower + 1 + + Polynomial.C cardBound * (2 * B + Polynomial.C C) ^ C + obtain ⟨projectionPower, hpPower, hQ⟩ := exists_natPolynomial_fixed_power_budget Q + obtain ⟨requiredPower, hrPower, hrequired⟩ := + exists_preparedFiniteScheduleUniformConditionalExcess_power_budget + maxLayers (max inputPower projectionPower) + refine ⟨projectionPower, requiredPower, hpPower, hrPower, ?_⟩ + intro K _ outer inner native hcard houter hinner x gainLog stageLog endpoint Plate + hx hg hs hend hPlate hn E + have hx0 : 0 ≤ x := (by norm_num : (0 : ℝ) ≤ 2).trans hx + let bound : ℝ := (x + 2) ^ D + have hb0 : 0 ≤ bound := by dsimp only [bound]; positivity + let entry := fun k => preparedFiniteForwardFrontProjectionPrecision + (preparedFiniteForwardModelPrecision A constants (inner k) + (candidateNestedForwardSeed A constants innerDepth (outer k) x) gainLog stageLog) + (preparedFiniteForwardWork A constants (inner k) + (candidateNestedForwardSeed A constants innerDepth (outer k) x)) (native k) + have hentry : ∀ k, entry k ∈ Set.Icc 0 ((2 * bound + C) ^ C) := by + intro k + let seed := candidateNestedForwardSeed A constants innerDepth (outer k) x + have hseed : 0 ≤ seed := candidateNestedForwardSeed_nonneg A constants innerDepth (outer k) hx0 + have hxs : x ≤ seed := le_candidateNestedForwardSeed A constants innerDepth (outer k) hA hx0 + have hloc := hlocal hx0 hg hs (outer k) (houter k) (inner k) (hinner k) + have hf := hfront A Cdirect constants (inner k) hseed + ⟨hg.1, hg.2.trans hxs⟩ ⟨hs.1, hs.2.trans hxs⟩ (hn k) + refine ⟨hf.1, hf.2.trans ?_⟩ + have hsource := hloc.2.2.2.2.2 false + have hwork := hloc.2.2.1 + apply pow_le_pow_left₀ + (add_nonneg (add_nonneg hsource.1 hwork.1) (Nat.cast_nonneg C)) + dsimp only [bound] at hsource hwork ⊢ + linarith only [hsource.2, hwork.2] + have hsum0 : 0 ≤ ∑ k, entry k := Finset.sum_nonneg (fun k _ => (hentry k).1) + have hE0 : 0 ≤ E := by + change 0 ≤ endpoint + 1 + ∑ k, entry k + linarith only [hend.1, hsum0] + have hsum : ∑ k, entry k ≤ (cardBound : ℝ) * (2 * bound + C) ^ C := by + calc + ∑ k, entry k ≤ ∑ _k : K, (2 * bound + C) ^ C := + Finset.sum_le_sum (fun k _ => (hentry k).2) + _ = (Fintype.card K : ℝ) * (2 * bound + C) ^ C := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hcard) (by positivity) + have hE : E ≤ (x + 2) ^ projectionPower := by + have htotal : (x + 2) ^ inputPower + 1 + + (cardBound : ℝ) * (2 * bound + C) ^ C ≤ (x + 2) ^ projectionPower := by + simpa [Q, B, bound, Polynomial.eval₂_pow] using hQ x hx0 + change endpoint + 1 + ∑ k, entry k ≤ _ + linarith only [hend.2, hsum, htotal] + refine ⟨⟨hE0, hE⟩, ?_, ?_, ?_⟩ + · change endpoint ≤ endpoint + 1 + ∑ k, entry k + linarith only [hsum0] + · intro k + have hk : entry k ≤ ∑ j, entry j := + Finset.single_le_sum (fun j _ => (hentry j).1) (Finset.mem_univ k) + change entry k ≤ endpoint + 1 + ∑ j, entry j + linarith only [hk, hend.1] + · intro m hm + exact hrequired m hm hx hPlate.1 + (hPlate.2.trans (pow_le_pow_right₀ (by linarith : 1 ≤ x + 2) (Nat.le_max_left _ _))) + (hE.trans (pow_le_pow_right₀ (by linarith : 1 ≤ x + 2) (Nat.le_max_right _ _))) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +noncomputable def preparedFiniteNestedSourceProjectionPrecision + {outerDepth innerDepth cutoff : ℕ} (m : ℕ) (G : Type) [Fintype G] + (count nX A Cdirect : ℕ) (constants : ℕ → ℕ) + (Bstruct pnum Qstride gainLog stageLog Plate endpoint : ℝ) : ℝ := + preparedNestedFrontProjectionEnvelope A constants innerDepth + (fun k : PreparedFiniteNestedForwardAllDegreeSlot outerDepth innerDepth cutoff => k.1.val) + (fun k : PreparedFiniteNestedForwardAllDegreeSlot outerDepth innerDepth cutoff => k.2.1.val) + (preparedFiniteNestedSourceNative m G count nX (preparedFiniteForwardDetectorPolynomial cutoff) + A Cdirect constants Bstruct pnum Qstride gainLog stageLog Plate) + Bstruct gainLog stageLog endpoint + +theorem exists_preparedFiniteNestedSourceProjection_budget + (m cutoff A Cdirect outerDepth innerDepth inputPower : ℕ) + (constants : ℕ → ℕ) + (hA : 2 ≤ A) (hcutoff : cutoff ≤ m) : + ∃ projectionPower requiredPower : ℕ, 2 ≤ projectionPower ∧ 2 ≤ requiredPower ∧ + ∀ (G : Type) [Fintype G] (count nX : ℕ) + {Bstruct pnum Qstride gainLog stageLog Plate endpoint : ℝ}, + 2 ≤ Bstruct → pnum ∈ Set.Icc 0 Bstruct → Qstride ∈ Set.Icc 0 Bstruct → + gainLog ∈ Set.Icc 0 Bstruct → stageLog ∈ Set.Icc 0 Bstruct → + (count : ℝ) ≤ Bstruct → (nX : ℝ) ≤ Bstruct → (Fintype.card G : ℝ) ≤ Bstruct → + endpoint ∈ Set.Icc 0 ((Bstruct + 2) ^ inputPower) → + Plate ∈ Set.Icc 0 ((Bstruct + 2) ^ inputPower) → + let E := preparedFiniteNestedSourceProjectionPrecision + (outerDepth := outerDepth) (innerDepth := innerDepth) (cutoff := cutoff) + m G count nX A Cdirect constants Bstruct pnum Qstride gainLog stageLog Plate endpoint + E ∈ Set.Icc 0 ((Bstruct + 2) ^ projectionPower) ∧ endpoint ≤ E ∧ + preparedConditionalExcessRequired m Plate E ≤ (Bstruct + 2) ^ requiredPower := by + let K := PreparedFiniteNestedForwardAllDegreeSlot outerDepth innerDepth cutoff + let Cnative := preparedFiniteNestedSourceNativeExponent m cutoff Cdirect + obtain ⟨Cp, Cr, hCp, hCr, hbudget⟩ := exists_preparedNestedFrontProjectionEnvelope_budget + A Cdirect Cnative constants innerDepth outerDepth (Fintype.card K) inputPower m hA + refine ⟨Cp, Cr, hCp, hCr, ?_⟩ + intro G _ count nX Bstruct pnum Qstride gainLog stageLog Plate endpoint + hB hnum hstride hg hs hcount hnX hG hend hPlate E + let native : K → ℝ := preparedFiniteNestedSourceNative m G count nX + (preparedFiniteForwardDetectorPolynomial cutoff) A Cdirect constants + Bstruct pnum Qstride gainLog stageLog Plate + have hnative (k : K) := preparedFiniteNestedSourceNative_budget m G count nX A Cdirect constants + hcutoff hA ((by norm_num : (0 : ℝ) ≤ 2).trans hB) hnum hstride hg hs hcount hnX hG Plate k + have h := hbudget (fun k : K => k.1.val) (fun k : K => k.2.1.val) native le_rfl + (fun k => Nat.le_of_lt_succ k.1.isLt) (fun k => Nat.le_of_lt_succ k.2.1.isLt) + hB hg hs hend hPlate (fun k => by + simpa only [native, Cnative, preparedFiniteNestedForwardAllDegreeStage, + preparedFiniteNestedForwardAllDegreeSeed, preparedFiniteNestedForwardAllDegreeOuter, + preparedFiniteForwardPairedSourcePrecision_model] using hnative k) + exact ⟨h.1, h.2.1, h.2.2.2 m le_rfl⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedRoundedRank.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedRoundedRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1b96cf4a376e9b65084795ea9436f3f3c838b39 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedRoundedRank.lean @@ -0,0 +1,50 @@ +import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def preparedRoundedRank (p : ℝ) (e : ℕ) : ℕ := + ⌈Real.exp ((p + 2)^e)⌉₊ + +theorem preparedRoundedRank_exp_le (p : ℝ) (e : ℕ) : + Real.exp ((p + 2)^e) ≤ (preparedRoundedRank p e : ℝ) := + Nat.le_ceil _ + +theorem preparedRoundedRank_one_le (p : ℝ) (e : ℕ) : + 1 ≤ preparedRoundedRank p e := by + have hpos := (Real.exp_pos ((p + 2)^e)).trans_le (preparedRoundedRank_exp_le p e) + have : 0 < preparedRoundedRank p e := by exact_mod_cast hpos + omega + +theorem preparedRoundedRank_le_exp {p : ℝ} (hp : 2 ≤ p) (e : ℕ) : + (preparedRoundedRank p e : ℝ) ≤ Real.exp ((p + 2)^(e + 1)) := by + have hbase : 1 ≤ p + 2 := by linarith + have hu : 1 ≤ (p + 2)^e := one_le_pow₀ hbase + have hexp : 1 ≤ Real.exp ((p + 2)^e) := Real.one_le_exp_iff.mpr (by linarith) + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hnext : (p + 2)^e + 1 ≤ (p + 2)^(e + 1) := by + rw [pow_succ] + nlinarith + calc + _ ≤ Real.exp ((p + 2)^e) + 1 := + (Nat.ceil_lt_add_one (Real.exp_nonneg ((p + 2)^e))).le + _ ≤ Real.exp ((p + 2)^e) * 2 := by linarith + _ ≤ Real.exp ((p + 2)^e) * Real.exp 1 := + mul_le_mul_of_nonneg_left htwo (Real.exp_nonneg _) + _ = Real.exp ((p + 2)^e + 1) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr hnext + +theorem preparedRoundedRank_exp_requirement {p required : ℝ} {e : ℕ} + (hrequired : required ≤ (p + 2)^e) : + Real.exp required ≤ (preparedRoundedRank p e : ℝ) := + (Real.exp_le_exp.mpr hrequired).trans (preparedRoundedRank_exp_le p e) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedSpatialKernelBlocks.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedSpatialKernelBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6d2ed60412cb2476cfccf9ac9e4f6246dce2c46 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedSpatialKernelBlocks.lean @@ -0,0 +1,251 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import OAI.Combinatorics.Progressions.Sampling.ForecastPreparedScaleBudget + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem modularRank_exceptional_numeric {s J : ℕ} {q c C m : ℝ} + (hq : 2 ≤ q) (hc : 0 < c) (hC : 0 ≤ C) (hm : 0 ≤ m) + (hthreshold : (s : ℝ) ^ (4 / c) ≤ q) + (hJ : 2 * (C + m + 10) / c ≤ (J : ℝ)) : + (s : ℝ) ^ (J + 1) * q ^ (C + m - c * J) ≤ q ^ (-(10 : ℝ)) := by + have hq0 : 0 < q := by linarith + have hq1 : 1 ≤ q := by linarith + have hJc : 2 * (C + m + 10) ≤ c * J := by + have := (div_le_iff₀ hc).mp hJ + nlinarith only [this] + have hJpos : 0 < J := by + by_contra hz + have hzero : J = 0 := by omega + simp only [hzero, Nat.cast_zero, mul_zero] at hJc + linarith + have hJ1 : (1 : ℝ) ≤ J := by exact_mod_cast hJpos + have hs : (s : ℝ) ≤ q ^ (c / 4) := by + have h := Real.rpow_le_rpow (Real.rpow_nonneg (Nat.cast_nonneg s) _) hthreshold + (show 0 ≤ c / 4 by positivity) + rw [← Real.rpow_mul (Nat.cast_nonneg s)] at h + have heq : 4 / c * (c / 4) = 1 := by field_simp + simpa only [heq, Real.rpow_one] using h + have hsJ : (s : ℝ) ^ (J + 1) ≤ q ^ (c / 4 * ((J + 1 : ℕ) : ℝ)) := by + simpa only [Real.rpow_mul_natCast hq0.le] using + pow_le_pow_left₀ (Nat.cast_nonneg s) hs (J + 1) + have hexp : c / 4 * ((J + 1 : ℕ) : ℝ) + (C + m - c * J) ≤ -(10 : ℝ) := by + push_cast + have htwice : (J : ℝ) + 1 ≤ 2 * J := by linarith only [hJ1] + have hmul := mul_le_mul_of_nonneg_left htwice (show 0 ≤ c / 4 by positivity) + nlinarith only [hJc, hmul] + calc + _ ≤ q ^ (c / 4 * ((J + 1 : ℕ) : ℝ)) * q ^ (C + m - c * J) := + mul_le_mul_of_nonneg_right hsJ (Real.rpow_nonneg hq0.le _) + _ = q ^ (c / 4 * ((J + 1 : ℕ) : ℝ) + (C + m - c * J)) := (Real.rpow_add hq0 _ _).symm + _ ≤ _ := Real.rpow_le_rpow_of_exponent_le hq1 hexp + +theorem finiteProbability_rank_markov {Ω : Type*} [Fintype Ω] + (w : FiniteProbabilityWeights Ω) (ρ : Ω → ℝ) (hρ : ∀ x, 0 ≤ ρ x) + {q C : ℝ} (hq : 0 < q) : + w.eventProbability (fun x => q ^ (-C) < ρ x) ≤ q ^ C * w.mean ρ := by + change w.mean (fun x => if q ^ (-C) < ρ x then 1 else 0) ≤ _ + calc + _ ≤ w.mean (fun x => q ^ C * ρ x) := by + apply w.mean_mono + intro x + split_ifs with hx + · have h := mul_le_mul_of_nonneg_left hx.le (Real.rpow_nonneg hq.le C) + simpa only [← Real.rpow_add hq, add_neg_cancel, Real.rpow_zero] using h + · exact mul_nonneg (Real.rpow_nonneg hq.le C) (hρ x) + _ = _ := by + simp only [FiniteProbabilityWeights.mean, Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + +theorem modularRank_exceptional_probability {Ω Row : Type*} [Fintype Ω] [Fintype Row] + (w : FiniteProbabilityWeights Ω) (ρ : Row → Ω → ℝ) + (hρ : ∀ r x, 0 ≤ ρ r x) {s J : ℕ} {q c C m : ℝ} + (hq : 2 ≤ q) (hc : 0 < c) (hC : 0 ≤ C) (hm : 0 ≤ m) + (hthreshold : (s : ℝ) ^ (4 / c) ≤ q) + (hJ : 2 * (C + m + 10) / c ≤ (J : ℝ)) + (hrows : (Fintype.card Row : ℝ) ≤ s * q ^ m) + (hmean : ∀ r, w.mean (ρ r) ≤ ((s : ℝ) * q ^ (-c)) ^ J) : + w.eventProbability (fun x => ∃ r, q ^ (-C) < ρ r x) ≤ q ^ (-(10 : ℝ)) := by + have hq0 : 0 < q := by linarith + have hunion := w.eventProbability_union_bound + (fun x => ∃ r, q ^ (-C) < ρ r x) (fun r x => q ^ (-C) < ρ r x) + (fun _ h => h) + have hrow (r) : w.eventProbability (fun x => q ^ (-C) < ρ r x) ≤ + q ^ C * ((s : ℝ) * q ^ (-c)) ^ J := + (finiteProbability_rank_markov w (ρ r) (hρ r) hq0).trans + (mul_le_mul_of_nonneg_left (hmean r) (Real.rpow_nonneg hq0.le C)) + calc + _ ≤ ∑ _r : Row, q ^ C * ((s : ℝ) * q ^ (-c)) ^ J := + hunion.trans (Finset.sum_le_sum (fun r _ => hrow r)) + _ = (Fintype.card Row : ℝ) * (q ^ C * ((s : ℝ) * q ^ (-c)) ^ J) := by + rw [Finset.sum_const, nsmul_eq_mul, Finset.card_univ] + _ ≤ ((s : ℝ) * q ^ m) * (q ^ C * ((s : ℝ) * q ^ (-c)) ^ J) := + mul_le_mul_of_nonneg_right hrows (by positivity) + _ = (s : ℝ) ^ (J + 1) * q ^ (C + m - c * J) := by + rw [mul_pow, ← Real.rpow_mul_natCast hq0.le] + rw [pow_succ] + calc + _ = (s : ℝ) ^ J * s * (q ^ m * q ^ C * q ^ (-c * J)) := by ring + _ = _ := by rw [← Real.rpow_add hq0, ← Real.rpow_add hq0]; congr 2; ring + _ ≤ _ := modularRank_exceptional_numeric hq hc hC hm hthreshold hJ + +noncomputable def modularRankSmallBallExponent (s : ℕ) : ℝ := (2 : ℝ) ^ (1 - (s : ℝ)) + +theorem modularRankSmallBallExponent_pos (s : ℕ) : 0 < modularRankSmallBallExponent s := + Real.rpow_pos_of_pos (by norm_num) _ + +theorem modularRankSmallBallExponent_eq {s : ℕ} (hs : 0 < s) : + modularRankSmallBallExponent s = 1 / (2 : ℝ) ^ (s - 1) := by + have hexp : 1 - (s : ℝ) = -((s - 1 : ℕ) : ℝ) := by + rw [Nat.cast_sub (by omega), Nat.cast_one] + ring + rw [modularRankSmallBallExponent, hexp, Real.rpow_neg (by norm_num), Real.rpow_natCast, + one_div] + +theorem modularRank_exceptional_probability_of_parameters + {Ω Row : Type*} [Fintype Ω] [Fintype Row] + (w : FiniteProbabilityWeights Ω) (ρ : Row → Ω → ℝ) + (hρ : ∀ r x, 0 ≤ ρ r x) {s J : ℕ} {q C m : ℝ} + (hC : 0 ≤ C) (hm : 0 ≤ m) + (hq : max 2 ((s : ℝ) ^ (4 / modularRankSmallBallExponent s)) ≤ q) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ J) + (hrows : (Fintype.card Row : ℝ) ≤ s * q ^ m) + (hmean : ∀ r, w.mean (ρ r) ≤ ((s : ℝ) * q ^ (-modularRankSmallBallExponent s)) ^ J) : + w.eventProbability (fun x => ∃ r, q ^ (-C) < ρ r x) ≤ q ^ (-(10 : ℝ)) := by + apply modularRank_exceptional_probability w ρ hρ + ((le_max_left _ _).trans hq) (modularRankSmallBallExponent_pos s) hC hm + ((le_max_right _ _).trans hq) _ hrows hmean + exact (Nat.le_ceil _).trans (Nat.cast_le.mpr hJ) + +end Erdos3 + +end + +section + +namespace Erdos3 + +def modularInitialRankStrength (s d : ℕ) : ℕ := + 2 ^ (2 * s) * s.factorial * (d + 2) + +def modularInitialBlockCount (s d : ℕ) : ℕ := + 2 ^ s * (modularInitialRankStrength s d + d + 10) + 1 + +theorem modularInitialRankStrength_exponent (s d : ℕ) : + (modularInitialRankStrength s d : ℝ) / + ((2 ^ s * s.factorial : ℕ) : ℝ) / (2 ^ s : ℕ) = d + 2 := by + have hpow : (2 : ℝ) ^ s ≠ 0 := by positivity + have hfac : (s.factorial : ℝ) ≠ 0 := by positivity + simp only [modularInitialRankStrength, Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat, + Nat.cast_add] + rw [show 2 * s = s + s by omega, pow_add] + field_simp + +theorem modularInitialBlockCount_threshold {s : ℕ} (hs : 0 < s) (d : ℕ) : + ⌈2 * ((modularInitialRankStrength s d : ℝ) + d + 10) / + modularRankSmallBallExponent s⌉₊ ≤ modularInitialBlockCount s d := by + apply Nat.ceil_le.mpr + rw [modularRankSmallBallExponent_eq hs, div_div_eq_mul_div, div_one] + have hpow : 2 * (2 : ℝ) ^ (s - 1) = (2 : ℝ) ^ s := by + rw [← pow_succ', Nat.sub_add_cancel hs] + calc + _ = (2 : ℝ) ^ s * ((modularInitialRankStrength s d : ℝ) + d + 10) := by + rw [← hpow] + ring + _ ≤ (modularInitialBlockCount s d : ℝ) := by + simp only [modularInitialBlockCount, Nat.cast_add, Nat.cast_mul, Nat.cast_pow, + Nat.cast_ofNat, Nat.cast_one] + linarith + +theorem modularInitialBlockCount_linear_bound (s d : ℕ) : + modularInitialBlockCount s d ≤ + (2 ^ s * (2 ^ (2 * s) * s.factorial + 1) + 1) * (d + 11) := by + dsimp only [modularInitialBlockCount, modularInitialRankStrength] + nlinarith [Nat.zero_le (2 ^ s), Nat.zero_le (2 ^ (2 * s) * s.factorial)] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem modularRank_tag_cost_le {s n a : ℕ} (hn : n + 1 ≤ s) + {p : ℝ} (hp : 1 ≤ p) : + ((n + 1 : ℕ) : ℝ) * p ^ (-(a : ℝ) / (2 : ℝ) ^ n) ≤ + (s : ℝ) * (p ^ a) ^ (-modularRankSmallBallExponent s) := by + have hs : 0 < s := by omega + have hp0 : 0 < p := lt_of_lt_of_le zero_lt_one hp + have hpow : (2 : ℝ) ^ n ≤ (2 : ℝ) ^ (s - 1) := + pow_le_pow_right₀ (by norm_num) (by omega) + have hdiv : (a : ℝ) / (2 : ℝ) ^ (s - 1) ≤ (a : ℝ) / (2 : ℝ) ^ n := + div_le_div_of_nonneg_left (Nat.cast_nonneg a) (by positivity) hpow + have hphase : p ^ (-(a : ℝ) / (2 : ℝ) ^ n) ≤ + (p ^ a) ^ (-modularRankSmallBallExponent s) := by + rw [modularRankSmallBallExponent_eq hs, ← Real.rpow_natCast_mul hp0.le] + apply Real.rpow_le_rpow_of_exponent_le hp + simpa only [neg_div, mul_neg, mul_one_div] using neg_le_neg hdiv + exact mul_le_mul (by exact_mod_cast hn) hphase (Real.rpow_nonneg hp0.le _) + (Nat.cast_nonneg s) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem modularInitialBlockCount_two_dimensions (m d : ℕ) : + 2 * d ≤ modularInitialBlockCount m d := by + have ha : 1 ≤ 2 ^ (2 * m) * m.factorial := Nat.succ_le_of_lt (by positivity) + have hb : 1 ≤ 2 ^ m := Nat.succ_le_of_lt (by positivity) + have hr : d + 2 ≤ modularInitialRankStrength m d := by + unfold modularInitialRankStrength + nlinarith + unfold modularInitialBlockCount + nlinarith + +namespace VectorPolynomial + +def preparedSpatialKernelBlocks (m M nX : ℕ) : + Fin 2 × Fin nX ↪ EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M)) where + toFun z := ⟨(m + 1) * (m + 3) + (finProdFinEquiv z).val, by + have hz := (finProdFinEquiv z).isLt + have hdim := modularInitialBlockCount_two_dimensions m (nX + m * M) + have hmul : modularInitialBlockCount m (nX + m * M) ≤ + (m + 1) * modularInitialBlockCount m (nX + m * M) := by + exact Nat.le_mul_of_pos_left _ (Nat.succ_pos m) + omega⟩ + inj' := by + intro z w h + apply finProdFinEquiv.injective + apply Fin.ext + have hv := congrArg Fin.val h + dsimp only at hv + omega + +theorem preparedSpatialKernelBlocks_outside_selection (m M nX s : ℕ) (hs : s ≤ m) + (z : Fin 2 × Fin nX) : + preparedSpatialKernelBlocks m M nX z ∉ Set.range + (enlargedPreparedCommonCanonicalSelection m (modularInitialBlockCount m (nX + m * M)) s hs) := by + rintro ⟨i, hi⟩ + have hv := congrArg Fin.val hi + change i.val = (m + 1) * (m + 3) + (finProdFinEquiv z).val at hv + have hn : s + 1 ≤ (m + 1) * (m + 3) := by nlinarith + have hi' := i.isLt + omega + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/PreparedUniformShortSourceRankBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/PreparedUniformShortSourceRankBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9c140398741d74a1d6595eaadb9bc53a284d73b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/PreparedUniformShortSourceRankBudget.lean @@ -0,0 +1,309 @@ +import OAI.Combinatorics.Progressions.Dynamics.PreparedLateScalarPowerBudget +import OAI.Combinatorics.Progressions.Sampling.PreparedCenteredShortForecastGoodInterface + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +structure PreparedSourceScalarData where + D : ℝ + pRadius : ℝ + Ptail : ℝ + Prho : ℝ + Pk : ℝ + target : ℝ + F : ℝ + Tmod : ℝ + Ppert : ℝ + Epert : ℝ + Bstruct : ℝ + Pmin : ℝ + Elog : ℝ + Vlog : ℝ + master : ℝ + Pphysical : ℝ + lateTarget : ℝ + Eforecast : ℝ + gainLog : ℝ + +namespace PreparedSourceScalarData + +def values (v : PreparedSourceScalarData) : List ℝ := + [v.D, v.pRadius, v.Ptail, v.Prho, v.Pk, v.target, v.F, v.Tmod, v.Ppert, v.Epert, v.Bstruct, v.Pmin, v.Elog, v.Vlog, v.master, v.Pphysical, v.lateTarget, v.Eforecast, v.gainLog] + +def Bounded (v : PreparedSourceScalarData) (P : ℝ) : Prop := + ∀ x ∈ v.values, x ∈ Set.Icc 0 P + +theorem Bounded.mono {v : PreparedSourceScalarData} {P Q : ℝ} + (hv : v.Bounded P) (hPQ : P ≤ Q) : v.Bounded Q := + fun x hx => ⟨(hv x hx).1, (hv x hx).2.trans hPQ⟩ + +noncomputable def scale (v : PreparedSourceScalarData) (m : ℕ) : ℝ := + v.pRadius + v.Ptail + fixedPathPerturbationLog v.D (v.D + v.Ppert + 4) v.Epert m + +noncomputable def seed (v : PreparedSourceScalarData) (m : ℕ) : ℝ := + allocatedScaleLog (v.D + v.scale m + + allocatedAffineLengthLog m v.D (v.scale m) v.Prho v.Pk v.target v.F v.Tmod + 1) + +def witnessWidth (v : PreparedSourceScalarData) : ℝ := + 2 * v.Bstruct + 2 * v.Vlog + 5 * v.Elog + 24 + +noncomputable def certificateBase (v : PreparedSourceScalarData) (m : ℕ) : ℝ := + 1 + (v.Bstruct + v.scale m + v.pRadius) + v.seed m + v.witnessWidth + + v.Pmin + v.Elog + v.Vlog + +noncomputable def lateMaster (v : PreparedSourceScalarData) (m : ℕ) : ℝ := + preparedModularGeneralDetectorLateMaster v.master (v.seed m) v.witnessWidth + v.Pphysical v.lateTarget + (1 + (v.seed m) ^ 2) * v.Pmin + v.scale m + +noncomputable def required (v : PreparedSourceScalarData) (m : ℕ) : ℝ := + let width := 4 * (v.lateMaster m + 8) ^ 2 + preparedForecastProductiveRequired m v.master (v.lateMaster m) v.Eforecast + (preparedForecastGoodCertificateBudget (v.certificateBase m) v.Bstruct width v.gainLog v.Vlog) + (preparedForecastGoodAnalyticBudget (preparedCenteredForecastSpatialExponent m) + (v.certificateBase m) v.Bstruct width v.gainLog v.Vlog) width + +end PreparedSourceScalarData + +theorem exists_preparedCompleteSourceRank_power_budget (m inputPower : ℕ) : + ∃ requiredPower : ℕ, 2 ≤ requiredPower ∧ ∀ {p : ℝ}, 2 ≤ p → + ∀ v : PreparedSourceScalarData, v.Bounded ((p + 2) ^ inputPower) → + v.required m ≤ (p + 2) ^ requiredPower ∧ + 1 ≤ preparedRoundedRank p requiredPower ∧ + Real.exp (v.required m) ≤ (preparedRoundedRank p requiredPower : ℝ) ∧ + (preparedRoundedRank p requiredPower : ℝ) ≤ Real.exp ((p + 2) ^ (requiredPower + 1)) := by + obtain ⟨seedPower, _, hseed⟩ := exists_preparedPerturbativeSeed_power_budget m inputPower + let firstPower := max inputPower seedPower + obtain ⟨latePower, _, hlate⟩ := exists_preparedLateScalar_power_budget firstPower + let fullPower := max firstPower latePower + obtain ⟨requiredPower, hrequiredPower, hrequired⟩ := + exists_preparedForecastConstructedRequired_power_budget m fullPower + refine ⟨requiredPower, hrequiredPower, ?_⟩ + intro p hp v hv + have hp0 : 0 ≤ p := by linarith + have hbase : 1 ≤ p + 2 := by linarith + have hfirst : (p + 2) ^ inputPower ≤ (p + 2) ^ firstPower := + pow_le_pow_right₀ hbase (Nat.le_max_left _ _) + have hseedFirst : (p + 2) ^ seedPower ≤ (p + 2) ^ firstPower := + pow_le_pow_right₀ hbase (Nat.le_max_right _ _) + have hfull : (p + 2) ^ firstPower ≤ (p + 2) ^ fullPower := + pow_le_pow_right₀ hbase (Nat.le_max_left _ _) + have hlateFull : (p + 2) ^ latePower ≤ (p + 2) ^ fullPower := + pow_le_pow_right₀ hbase (Nat.le_max_right _ _) + have hvFirst := hv.mono hfirst + have hvFull := hvFirst.mono hfull + have hcap (x : ℝ) (hx : x ∈ v.values) := hv x hx + have hcapFirst (x : ℝ) (hx : x ∈ v.values) := hvFirst x hx + have hcapFull (x : ℝ) (hx : x ∈ v.values) := hvFull x hx + obtain ⟨_, hscale, hseedBound⟩ := hseed hp0 v.D v.pRadius v.Ptail v.Prho v.Pk + v.target v.F v.Tmod v.Ppert v.Epert + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + change v.scale m ∈ Set.Icc 0 ((p + 2) ^ seedPower) at hscale + change v.seed m ∈ Set.Icc 0 ((p + 2) ^ seedPower) at hseedBound + obtain ⟨_, hcert, hLateBound, hMasterLate⟩ := hlate hp0 v.Bstruct (v.scale m) v.pRadius + (v.seed m) v.Pmin v.Elog v.Vlog v.master v.Pphysical v.lateTarget + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + ⟨hscale.1, hscale.2.trans hseedFirst⟩ + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + ⟨hseedBound.1, hseedBound.2.trans hseedFirst⟩ + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + change v.certificateBase m ∈ Set.Icc 0 ((p + 2) ^ latePower) at hcert + change v.lateMaster m ∈ Set.Icc 0 ((p + 2) ^ latePower) at hLateBound + have hbound : v.required m ≤ (p + 2) ^ requiredPower := + hrequired p hp v.master (v.lateMaster m) v.Eforecast (v.certificateBase m) + v.Bstruct v.gainLog v.Vlog + (hcapFull _ (by simp [PreparedSourceScalarData.values])).1 hMasterLate + (hLateBound.2.trans hlateFull) + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + ⟨hcert.1, hcert.2.trans hlateFull⟩ + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + exact ⟨hbound, preparedRoundedRank_one_le p requiredPower, + preparedRoundedRank_exp_requirement hbound, + preparedRoundedRank_le_exp hp requiredPower⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial + +noncomputable def PreparedSourceScalarData.shortRequired (v : PreparedSourceScalarData) (m : ℕ) : ℝ := + let width := 4 * (v.lateMaster m + 8) ^ 2 + preparedShortForecastProductiveRequired m v.master (v.lateMaster m) v.Eforecast + (preparedForecastGoodCertificateBudget (v.certificateBase m) v.Bstruct width v.gainLog v.Vlog) + (preparedForecastGoodAnalyticBudget (preparedCenteredShortForecastSpatialExponent m) + (v.certificateBase m) v.Bstruct width v.gainLog v.Vlog) width + +theorem exists_preparedCompleteShortSourceRank_power_budget (m inputPower : ℕ) : + ∃ requiredPower : ℕ, 2 ≤ requiredPower ∧ ∀ {p : ℝ}, 2 ≤ p → + ∀ v : PreparedSourceScalarData, v.Bounded ((p + 2) ^ inputPower) → + v.shortRequired m ≤ (p + 2) ^ requiredPower ∧ + 1 ≤ preparedRoundedRank p requiredPower ∧ + Real.exp (v.shortRequired m) ≤ (preparedRoundedRank p requiredPower : ℝ) ∧ + (preparedRoundedRank p requiredPower : ℝ) ≤ Real.exp ((p + 2) ^ (requiredPower + 1)) := by + obtain ⟨seedPower, _, hseed⟩ := exists_preparedPerturbativeSeed_power_budget m inputPower + let firstPower := max inputPower seedPower + obtain ⟨latePower, _, hlate⟩ := exists_preparedLateScalar_power_budget firstPower + let fullPower := max firstPower latePower + obtain ⟨requiredPower, hrequiredPower, hrequired⟩ := + exists_preparedShortForecastConstructedRequired_power_budget m fullPower + refine ⟨requiredPower, hrequiredPower, ?_⟩ + intro p hp v hv + have hp0 : 0 ≤ p := by linarith + have hbase : 1 ≤ p + 2 := by linarith + have hfirst : (p + 2) ^ inputPower ≤ (p + 2) ^ firstPower := + pow_le_pow_right₀ hbase (Nat.le_max_left _ _) + have hseedFirst : (p + 2) ^ seedPower ≤ (p + 2) ^ firstPower := + pow_le_pow_right₀ hbase (Nat.le_max_right _ _) + have hfull : (p + 2) ^ firstPower ≤ (p + 2) ^ fullPower := + pow_le_pow_right₀ hbase (Nat.le_max_left _ _) + have hlateFull : (p + 2) ^ latePower ≤ (p + 2) ^ fullPower := + pow_le_pow_right₀ hbase (Nat.le_max_right _ _) + have hvFirst := hv.mono hfirst + have hvFull := hvFirst.mono hfull + have hcap (x : ℝ) (hx : x ∈ v.values) := hv x hx + have hcapFirst (x : ℝ) (hx : x ∈ v.values) := hvFirst x hx + have hcapFull (x : ℝ) (hx : x ∈ v.values) := hvFull x hx + obtain ⟨_, hscale, hseedBound⟩ := hseed hp0 v.D v.pRadius v.Ptail v.Prho v.Pk + v.target v.F v.Tmod v.Ppert v.Epert + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + (hcap _ (by simp [PreparedSourceScalarData.values])) + change v.scale m ∈ Set.Icc 0 ((p + 2) ^ seedPower) at hscale + change v.seed m ∈ Set.Icc 0 ((p + 2) ^ seedPower) at hseedBound + obtain ⟨_, hcert, hLateBound, hMasterLate⟩ := hlate hp0 v.Bstruct (v.scale m) v.pRadius + (v.seed m) v.Pmin v.Elog v.Vlog v.master v.Pphysical v.lateTarget + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + ⟨hscale.1, hscale.2.trans hseedFirst⟩ + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + ⟨hseedBound.1, hseedBound.2.trans hseedFirst⟩ + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + (hcapFirst _ (by simp [PreparedSourceScalarData.values])) + change v.certificateBase m ∈ Set.Icc 0 ((p + 2) ^ latePower) at hcert + change v.lateMaster m ∈ Set.Icc 0 ((p + 2) ^ latePower) at hLateBound + have hbound : v.shortRequired m ≤ (p + 2) ^ requiredPower := + hrequired p hp v.master (v.lateMaster m) v.Eforecast (v.certificateBase m) + v.Bstruct v.gainLog v.Vlog + (hcapFull _ (by simp [PreparedSourceScalarData.values])).1 hMasterLate + (hLateBound.2.trans hlateFull) + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + ⟨hcert.1, hcert.2.trans hlateFull⟩ + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + (hcapFull _ (by simp [PreparedSourceScalarData.values])) + exact ⟨hbound, preparedRoundedRank_one_le p requiredPower, + preparedRoundedRank_exp_requirement hbound, + preparedRoundedRank_le_exp hp requiredPower⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators + +theorem exists_preparedUniformSourceRank_power_budget (s inputPower : ℕ) : + ∃ requiredPower : ℕ, 2 ≤ requiredPower ∧ ∀ {p : ℝ}, 2 ≤ p → + ∀ m : ℕ, m ≤ s → + ∀ v : PreparedSourceScalarData, v.Bounded ((p + 2) ^ inputPower) → + v.required m ≤ (p + 2) ^ requiredPower ∧ + 1 ≤ preparedRoundedRank p requiredPower ∧ + Real.exp (v.required m) ≤ (preparedRoundedRank p requiredPower : ℝ) ∧ + (preparedRoundedRank p requiredPower : ℝ) ≤ + Real.exp ((p + 2) ^ (requiredPower + 1)) := by + let exponent (m : ℕ) := + (exists_preparedCompleteSourceRank_power_budget m inputPower).choose + let requiredPower := 2 + ∑ k ∈ Finset.range (s + 1), exponent k + refine ⟨requiredPower, by dsimp [requiredPower]; omega, ?_⟩ + intro p hp m hm v hv + have hexponent : exponent m ≤ requiredPower := by + have hsum : exponent m ≤ ∑ k ∈ Finset.range (s + 1), exponent k := + Finset.single_le_sum (f := exponent) (fun k _ => Nat.zero_le _) + (Finset.mem_range.mpr (Nat.lt_succ_of_le hm)) + dsimp only [requiredPower] + omega + have hlocal := + ((exists_preparedCompleteSourceRank_power_budget m inputPower).choose_spec.2 hp v hv).1 + change v.required m ≤ (p + 2) ^ exponent m at hlocal + have hbound : v.required m ≤ (p + 2) ^ requiredPower := + hlocal.trans (pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) hexponent) + exact ⟨hbound, preparedRoundedRank_one_le p requiredPower, + preparedRoundedRank_exp_requirement hbound, + preparedRoundedRank_le_exp hp requiredPower⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3.VectorPolynomial +open scoped BigOperators + +theorem exists_preparedUniformShortSourceRank_power_budget (s inputPower : ℕ) : + ∃ requiredPower : ℕ, 2 ≤ requiredPower ∧ ∀ {p : ℝ}, 2 ≤ p → + ∀ m : ℕ, m ≤ s → + ∀ v : PreparedSourceScalarData, v.Bounded ((p + 2) ^ inputPower) → + v.shortRequired m ≤ (p + 2) ^ requiredPower ∧ + 1 ≤ preparedRoundedRank p requiredPower ∧ + Real.exp (v.shortRequired m) ≤ (preparedRoundedRank p requiredPower : ℝ) ∧ + (preparedRoundedRank p requiredPower : ℝ) ≤ + Real.exp ((p + 2) ^ (requiredPower + 1)) := by + let exponent (m : ℕ) := + (exists_preparedCompleteShortSourceRank_power_budget m inputPower).choose + let requiredPower := 2 + ∑ k ∈ Finset.range (s + 1), exponent k + refine ⟨requiredPower, by dsimp [requiredPower]; omega, ?_⟩ + intro p hp m hm v hv + have hexponent : exponent m ≤ requiredPower := by + have hsum : exponent m ≤ ∑ k ∈ Finset.range (s + 1), exponent k := + Finset.single_le_sum (f := exponent) (fun k _ => Nat.zero_le _) + (Finset.mem_range.mpr (Nat.lt_succ_of_le hm)) + dsimp only [requiredPower] + omega + have hlocal := + ((exists_preparedCompleteShortSourceRank_power_budget m inputPower).choose_spec.2 hp v hv).1 + change v.shortRequired m ≤ (p + 2) ^ exponent m at hlocal + have hbound : v.shortRequired m ≤ (p + 2) ^ requiredPower := + hlocal.trans (pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) hexponent) + exact ⟨hbound, preparedRoundedRank_one_le p requiredPower, + preparedRoundedRank_exp_requirement hbound, + preparedRoundedRank_le_exp hp requiredPower⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAEnergyOrder.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAEnergyOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..4284fabe2c30f1aa96e165c521aa418cbc2a5a2c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAEnergyOrder.lean @@ -0,0 +1,562 @@ +import OAI.Combinatorics.Progressions.Estimates.DisjointPowersetSum +import OAI.Combinatorics.Progressions.Estimates.FiniteHypergraphAbstract +import OAI.Combinatorics.Progressions.Estimates.IndependentProductMeans +import OAI.Combinatorics.Progressions.Estimates.PinnedSectionMeans +import OAI.Combinatorics.Progressions.Estimates.ProductMarginalAtomError +import OAI.Combinatorics.Progressions.Estimates.SubsetAlternatingInversion + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem alternating_powerset_sum_zero {I : Type*} [DecidableEq I] + (S : Finset I) {i : I} (hi : i ∈ S) (g : Finset I → ℝ) + (hpair : ∀ U ⊆ S.erase i, g (insert i U) = g U) : + (∑ U ∈ S.powerset, (-1 : ℝ) ^ U.card * g U) = 0 := by + conv_lhs => rw [← Finset.insert_erase hi] + rw [Finset.sum_powerset_insert (Finset.notMem_erase i S), ← Finset.sum_add_distrib] + apply Finset.sum_eq_zero + intro U hU + have hu := Finset.mem_powerset.mp hU + have hni : i ∉ U := fun h => Finset.notMem_erase i S (hu h) + rw [Finset.card_insert_of_notMem hni, pow_succ, hpair U hu] + ring + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +noncomputable def productANOVA (S : Finset I) (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) : ℝ := + ∑ U ∈ S.powerset, (-1 : ℝ) ^ U.card * productConditionalMean μ (S \ U) f x + +theorem productANOVA_inclusion_exclusion (S : Finset I) (f : (∀ i, X i) → ℝ) + (x : ∀ i, X i) : + productANOVA μ S f x = ∑ T ∈ S.powerset, + (-1 : ℝ) ^ (S.card - T.card) * productConditionalMean μ T f x := by + unfold productANOVA + apply Finset.sum_bij' (fun U _ => S \ U) (fun T _ => S \ T) + · intro U _ + exact Finset.mem_powerset.mpr Finset.sdiff_subset + · intro T _ + exact Finset.mem_powerset.mpr Finset.sdiff_subset + · intro U hU + exact Finset.sdiff_sdiff_eq_self (Finset.mem_powerset.mp hU) + · intro T hT + exact Finset.sdiff_sdiff_eq_self (Finset.mem_powerset.mp hT) + · intro U hU + have hu := Finset.mem_powerset.mp hU + have hc : S.card - (S \ U).card = U.card := by + rw [Finset.card_sdiff_of_subset hu] + exact Nat.sub_sub_self (Finset.card_le_card hu) + rw [hc] + +theorem productANOVA_depends (S : Finset I) (f : (∀ i, X i) → ℝ) : + ProductDependsOn S (productANOVA μ S f) := by + intro x y hxy + unfold productANOVA + apply Finset.sum_congr rfl + intro U _ + congr 1 + exact productConditionalMean_depends μ (S \ U) f x y + (fun i hi => hxy i (Finset.sdiff_subset hi)) + +theorem productConditionalMean_ANOVA (S T : Finset I) (f : (∀ i, X i) → ℝ) + (x : ∀ i, X i) : + productConditionalMean μ T (productANOVA μ S f) x = + if S ⊆ T then productANOVA μ S f x else 0 := by + classical + change productConditionalMean μ T (fun y => ∑ U ∈ S.powerset, + (-1 : ℝ) ^ U.card * productConditionalMean μ (S \ U) f y) x = + if S ⊆ T then (∑ U ∈ S.powerset, + (-1 : ℝ) ^ U.card * productConditionalMean μ (S \ U) f x) else 0 + simp only [productConditionalMean_sum, productConditionalMean_smul, productConditionalMean_comp] + by_cases hST : S ⊆ T + · rw [ite_eq_left hST] + apply Finset.sum_congr rfl + intro U _ + rw [Finset.inter_eq_right.mpr (Finset.sdiff_subset.trans hST)] + · rw [ite_eq_right hST] + obtain ⟨i, hi, hni⟩ := Finset.not_subset.mp hST + apply alternating_powerset_sum_zero S hi + intro U _ + have he : T ∩ (S \ insert i U) = T ∩ (S \ U) := by + ext j + by_cases hj : j = i + · subst j + simp [hni] + · simp [hj] + rw [he] + +theorem productANOVA_selfadjoint (S : Finset I) (f g : (∀ i, X i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => f x * productANOVA μ S g x) = + (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ S f x * g x) := by + let p := FiniteProbabilityWeights.pi μ + simp only [productANOVA, Finset.mul_sum, Finset.sum_mul, FiniteProbabilityWeights.mean_sum] + apply Finset.sum_congr rfl + intro U _ + calc + _ = (-1 : ℝ) ^ U.card * p.mean (fun x => f x * productConditionalMean μ (S \ U) g x) := by + rw [← p.mean_const_mul] + congr 1 + funext x + ring + _ = (-1 : ℝ) ^ U.card * p.mean (fun x => productConditionalMean μ (S \ U) f x * g x) := by + rw [productConditionalMean_selfadjoint] + _ = _ := by + rw [← p.mean_const_mul] + congr 1 + funext x + ring + +theorem productANOVA_pairing_self (S : Finset I) (f : (∀ i, X i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ S f x ^ 2) = + (FiniteProbabilityWeights.pi μ).mean (fun x => f x * productANOVA μ S f x) := by + let p := FiniteProbabilityWeights.pi μ + calc + _ = p.mean (fun x => productANOVA μ S f x * productANOVA μ S f x) := by + simp only [pow_two] + rfl + _ = ∑ U ∈ S.powerset, (-1 : ℝ) ^ U.card * + p.mean (fun x => f x * productConditionalMean μ (S \ U) (productANOVA μ S f) x) := by + change p.mean (fun x => (∑ U ∈ S.powerset, + (-1 : ℝ) ^ U.card * productConditionalMean μ (S \ U) f x) * productANOVA μ S f x) = _ + simp only [Finset.sum_mul, FiniteProbabilityWeights.mean_sum] + apply Finset.sum_congr rfl + intro U _ + calc + _ = (-1 : ℝ) ^ U.card * p.mean (fun x => + productConditionalMean μ (S \ U) f x * productANOVA μ S f x) := by + rw [← p.mean_const_mul] + congr 1 + funext x + ring + _ = _ := by rw [← productConditionalMean_selfadjoint] + _ = _ := by + rw [Finset.sum_eq_single ∅] + · simp only [Finset.card_empty, pow_zero, one_mul, Finset.sdiff_empty, + productConditionalMean_ANOVA, Finset.Subset.refl, ite_true] + rfl + · intro U hU hUne + have hUS := Finset.mem_powerset.mp hU + have hn : ¬ S ⊆ S \ U := by + obtain ⟨i, hi⟩ := Finset.nonempty_iff_ne_empty.mpr hUne + intro h + exact (Finset.mem_sdiff.mp (h (hUS hi))).2 hi + simp only [productConditionalMean_ANOVA, hn, ite_false, mul_zero, p.mean_const] + · simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem productANOVA_idempotent {ι : Type*} [Fintype ι] [DecidableEq ι] + {Y : ι → Type*} [∀ i, Fintype (Y i)] (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (S : Finset ι) (f : (∀ i, Y i) → ℝ) (x : ∀ i, Y i) : + productANOVA ν S (productANOVA ν S f) x = productANOVA ν S f x := by + rw [productANOVA, Finset.sum_eq_single ∅] + · simp only [Finset.card_empty, pow_zero, one_mul, Finset.sdiff_empty, + productConditionalMean_ANOVA, Finset.Subset.refl, ite_true] + · intro U hU hne + have hUS := Finset.mem_powerset.mp hU + have hn : ¬ S ⊆ S \ U := by + obtain ⟨i, hi⟩ := Finset.nonempty_iff_ne_empty.mpr hne + intro h + exact (Finset.mem_sdiff.mp (h (hUS hi))).2 hi + simp only [productConditionalMean_ANOVA, hn, ite_false, mul_zero] + · simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {X : ι → Type*} [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_mul_blocks (I J A B : Finset ι) (hIJ : Disjoint I J) + (hAI : A ⊆ I) (hBJ : B ⊆ J) (f g : (∀ i, X i) → ℝ) + (hf : ProductDependsOn I f) (hg : ProductDependsOn J g) (x : ∀ i, X i) : + productANOVA μ (A ∪ B) (fun y => f y * g y) x = productANOVA μ A f x * productANOVA μ B g x := by + have hAB := hIJ.mono hAI hBJ + simp only [productANOVA_inclusion_exclusion] + rw [disjoint_powerset_sum A B hAB] + simp only [Finset.sum_mul, Finset.mul_sum] + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro U hU + apply Finset.sum_congr rfl + intro V hV + have hUA := Finset.mem_powerset.mp hU + have hVB := Finset.mem_powerset.mp hV + have hUV := hAB.mono hUA hVB + rw [productConditionalMean_mul_disjoint μ I J (U ∪ V) hIJ f g hf hg x, + productConditionalMean_union_irrelevant μ I U V (hIJ.mono_right (hVB.trans hBJ)) f hf x] + have he := productConditionalMean_union_irrelevant μ J V U + (hIJ.symm.mono_right (hUA.trans hAI)) g hg x + rw [Finset.union_comm] at he + rw [he] + have hc : (A ∪ B).card - (U ∪ V).card = (A.card - U.card) + (B.card - V.card) := by + rw [Finset.card_union_of_disjoint hAB, Finset.card_union_of_disjoint hUV] + have := Finset.card_le_card hUA + have := Finset.card_le_card hVB + omega + rw [hc, pow_add] + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_orthogonal_of_not_subset (S T : Finset I) (hTS : ¬ T ⊆ S) + (f g : (∀ i, X i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ S f x * productANOVA μ T g x) = 0 := by + have h := productConditionalMean_selfadjoint μ S (productANOVA μ S f) (productANOVA μ T g) + simpa [productConditionalMean_ANOVA, hTS, FiniteProbabilityWeights.mean_const] using h.symm + +theorem productANOVA_orthogonal (S T : Finset I) (hST : S ≠ T) + (f g : (∀ i, X i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ S f x * productANOVA μ T g x) = 0 := by + by_cases hTS : T ⊆ S + · have hn : ¬ S ⊆ T := fun h => hST (Finset.Subset.antisymm h hTS) + simpa only [mul_comm] using productANOVA_orthogonal_of_not_subset μ T S hn g f + · exact productANOVA_orthogonal_of_not_subset μ S T hTS f g + +noncomputable def productANOVATruncation (D : Finset (Finset I)) + (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) : ℝ := ∑ S ∈ D, productANOVA μ S f x + +noncomputable def productANOVAEnergy (D : Finset (Finset I)) (f : (∀ i, X i) → ℝ) : ℝ := + ∑ S ∈ D, (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ S f x ^ 2) + +theorem productANOVAEnergy_nonneg (D : Finset (Finset I)) (f : (∀ i, X i) → ℝ) : + 0 ≤ productANOVAEnergy μ D f := + Finset.sum_nonneg (fun _ _ => (FiniteProbabilityWeights.pi μ).mean_nonneg (fun _ => sq_nonneg _)) + +theorem productANOVAEnergy_pairing (D : Finset (Finset I)) (f : (∀ i, X i) → ℝ) : + productANOVAEnergy μ D f = + (FiniteProbabilityWeights.pi μ).mean (fun x => f x * productANOVATruncation μ D f x) := by + simp only [productANOVAEnergy, productANOVATruncation, Finset.mul_sum, + FiniteProbabilityWeights.mean_sum, productANOVA_pairing_self] + +theorem productANOVAEnergy_square (D : Finset (Finset I)) (f : (∀ i, X i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVATruncation μ D f x ^ 2) = + productANOVAEnergy μ D f := by + simp only [productANOVATruncation, productANOVAEnergy, pow_two, Finset.sum_mul, + Finset.mul_sum, FiniteProbabilityWeights.mean_sum] + apply Finset.sum_congr rfl + intro S hS + rw [Finset.sum_eq_single S] + · intro T _ hTS + exact productANOVA_orthogonal μ T S hTS f f + · exact fun h => False.elim (h hS) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem ProductDependsOn.prod {I J : Type*} {X : I → Type*} + (S : Finset I) (D : Finset J) (f : J → (∀ i, X i) → ℝ) + (hf : ∀ j ∈ D, ProductDependsOn S (f j)) : + ProductDependsOn S (fun x => ∏ j ∈ D, f j x) := by + intro x y hxy + exact Finset.prod_congr rfl (fun j hj => hf j hj x y hxy) + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productMean_mul_zero_of_conditionalMean_zero (S : Finset I) + (f g : (∀ i, X i) → ℝ) (hf : ProductDependsOn S f) + (hg : ∀ x, productConditionalMean μ S g x = 0) : + (FiniteProbabilityWeights.pi μ).mean (fun x => f x * g x) = 0 := by + have h := productConditionalMean_selfadjoint μ S f g + simpa only [hg, productConditionalMean_of_depends μ S hf, mul_zero, + FiniteProbabilityWeights.mean_const] using h.symm + +theorem productANOVA_unique_coordinate_zero {J : Type*} (D : Finset J) + (S : J → Finset I) (f : J → (∀ i, X i) → ℝ) {j₀ : J} (hj₀ : j₀ ∈ D) + {i : I} (hi : i ∈ S j₀) (hother : ∀ j ∈ D, j ≠ j₀ → i ∉ S j) : + (FiniteProbabilityWeights.pi μ).mean (fun x => ∏ j ∈ D, productANOVA μ (S j) (f j) x) = 0 := by + classical + let T : Finset I := Finset.univ.erase i + let g := fun x => ∏ j ∈ D.erase j₀, productANOVA μ (S j) (f j) x + have hg : ProductDependsOn T g := by + apply ProductDependsOn.prod + intro j hj + apply (productANOVA_depends μ (S j) (f j)).mono + intro a ha + apply Finset.mem_erase.mpr + constructor + · intro hai + subst a + exact hother j (Finset.mem_erase.mp hj).2 (Finset.mem_erase.mp hj).1 ha + · exact Finset.mem_univ _ + have hnot : ¬ S j₀ ⊆ T := by + intro hST + exact Finset.notMem_erase i Finset.univ (hST hi) + have hcenter (x : ∀ i, X i) : productConditionalMean μ T (productANOVA μ (S j₀) (f j₀)) x = 0 := by + rw [productConditionalMean_ANOVA, ite_eq_right hnot] + calc + (FiniteProbabilityWeights.pi μ).mean (fun x => ∏ j ∈ D, productANOVA μ (S j) (f j) x) = + (FiniteProbabilityWeights.pi μ).mean (fun x => g x * productANOVA μ (S j₀) (f j₀) x) := by + congr 1 + funext x + exact (Finset.prod_erase_mul D (fun j => productANOVA μ (S j) (f j) x) hj₀).symm + _ = 0 := productMean_mul_zero_of_conditionalMean_zero μ T g _ hg hcenter + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_abs_le (S : Finset I) (f : (∀ i, X i) → ℝ) + (x : ∀ i, X i) {L : ℝ} + (hraw : ∀ T ⊆ S, |productConditionalMean μ T f x| ≤ L) : + |productANOVA μ S f x| ≤ (2 : ℝ) ^ S.card * L := by + unfold productANOVA + calc + _ ≤ ∑ U ∈ S.powerset, |(-1 : ℝ) ^ U.card * productConditionalMean μ (S \ U) f x| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _U ∈ S.powerset, L := by + apply Finset.sum_le_sum + intro U _ + simpa only [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] using + hraw (S \ U) Finset.sdiff_subset + _ = _ := by simp + +theorem productANOVA_weighted_cap (r f : (∀ i, X i) → ℝ) + (hr : ∀ x, 0 ≤ r x) {M η : ℝ} (hM : 0 ≤ M) + (hf : ∀ x, 0 ≤ f x ∧ f x ≤ M) (S : Finset I) + (hclose : ∀ T ⊆ S, ∀ x, (FiniteProbabilityWeights.pi μ).weight x ≠ 0 → + |productConditionalMean μ T r x - 1| ≤ η) + (x : ∀ i, X i) (hx : (FiniteProbabilityWeights.pi μ).weight x ≠ 0) : + |productANOVA μ S (fun y => r y * f y) x| ≤ (2 : ℝ) ^ S.card * (M * (1 + η)) := by + apply productANOVA_abs_le μ S _ x + intro T hT + have hc := productConditionalMean_weighted_cap μ r f hr hf T x + rw [abs_of_nonneg hc.1] + have he := (abs_le.mp (hclose T hT x hx)).2 + exact hc.2.trans (mul_le_mul_of_nonneg_left (by linarith) hM) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_sectionAverage (T A U : Finset I) (hAT : A ⊆ T) + (hTU : Disjoint T U) (z : ∀ i, X i) (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) : + productANOVA μ U (productSectionAverage μ T A z f) x = + ∑ B ∈ U.powerset, (-1 : ℝ) ^ (U.card - B.card) * + productConditionalMean μ (A ∪ B) f (productCoordinateMix T z x) := by + rw [productANOVA_inclusion_exclusion] + apply Finset.sum_congr rfl + intro B hB + rw [productConditionalMean_sectionAverage μ T A B hAT] + have hBT : Disjoint B T := hTU.symm.mono_left (Finset.mem_powerset.mp hB) + rw [Finset.sdiff_eq_self_of_disjoint hBT] + +theorem productANOVA_disjoint_section (T U : Finset I) (hTU : Disjoint T U) + (z : ∀ i, X i) (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) : + productANOVA μ (T ∪ U) f (productCoordinateMix T z x) = + ∑ A ∈ T.powerset, (-1 : ℝ) ^ (T.card - A.card) * + productANOVA μ U (productSectionAverage μ T A z f) x := by + rw [productANOVA_inclusion_exclusion, disjoint_powerset_sum T U hTU] + apply Finset.sum_congr rfl + intro A hA + have hAT := Finset.mem_powerset.mp hA + rw [productANOVA_sectionAverage μ T A U hAT hTU, Finset.mul_sum] + apply Finset.sum_congr rfl + intro B hB + have hBU := Finset.mem_powerset.mp hB + have hAB : Disjoint A B := hTU.mono hAT hBU + have he : (T ∪ U).card - (A ∪ B).card = (T.card - A.card) + (U.card - B.card) := by + rw [Finset.card_union_of_disjoint hTU, Finset.card_union_of_disjoint hAB] + have ha := Finset.card_le_card hAT + have hb := Finset.card_le_card hBU + omega + rw [he, pow_add, mul_assoc] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem productANOVAEnergy_le_mean_sq {ι : Type*} [Fintype ι] [DecidableEq ι] + {X : ι → Type*} [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + (D : Finset (Finset ι)) (f : (∀ i, X i) → ℝ) : + productANOVAEnergy μ D f ≤ (FiniteProbabilityWeights.pi μ).mean (fun x => f x ^ 2) := by + have hcs := (FiniteProbabilityWeights.pi μ).mean_mul_sq_le f (productANOVATruncation μ D f) + rw [productANOVAEnergy_square, ← productANOVAEnergy_pairing] at hcs + by_cases hz : productANOVAEnergy μ D f = 0 + · rw [hz] + exact FiniteProbabilityWeights.mean_nonneg _ (fun x => sq_nonneg (f x)) + · have hp : 0 < productANOVAEnergy μ D f := + lt_of_le_of_ne (productANOVAEnergy_nonneg μ D f) (Ne.symm hz) + rw [pow_two] at hcs + exact le_of_mul_le_mul_right hcs hp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {X : ι → Type*} [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_reconstruct (S : Finset ι) (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) : + (∑ T ∈ S.powerset, productANOVA μ T f x) = productConditionalMean μ S f x := + subsetAlternatingTransform_sum S (fun T => productConditionalMean μ T f x) + +theorem productANOVATruncation_of_depends (S : Finset ι) (f : (∀ i, X i) → ℝ) + (hf : ProductDependsOn S f) : productANOVATruncation μ S.powerset f = f := by + funext x + exact (productANOVA_reconstruct μ S f x).trans (productConditionalMean_of_depends μ S hf x) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {X : ι → Type*} [∀ i, Fintype (X i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_conditional_commute (S T : Finset ι) (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) : + productANOVA μ S (productConditionalMean μ T f) x = + productConditionalMean μ T (productANOVA μ S f) x := by + change (∑ U ∈ S.powerset, (-1 : ℝ) ^ U.card * + productConditionalMean μ (S \ U) (productConditionalMean μ T f) x) = + productConditionalMean μ T (fun y => ∑ U ∈ S.powerset, (-1 : ℝ) ^ U.card * + productConditionalMean μ (S \ U) f y) x + simp only [productConditionalMean_sum, productConditionalMean_smul, + productConditionalMean_comp, Finset.inter_comm] + +theorem productANOVA_of_depends_not_subset (T : Finset ι) (f : (∀ i, X i) → ℝ) + (hf : ProductDependsOn T f) (S : Finset ι) (hS : ¬S ⊆ T) (x : ∀ i, X i) : + productANOVA μ S f x = 0 := by + have he : productConditionalMean μ T f = f := funext (productConditionalMean_of_depends μ T hf) + calc + _ = productANOVA μ S (productConditionalMean μ T f) x := by rw [he] + _ = productConditionalMean μ T (productANOVA μ S f) x := productANOVA_conditional_commute μ S T f x + _ = 0 := by rw [productConditionalMean_ANOVA, ite_eq_right hS] + +theorem productANOVAEnergy_of_depends_filter (T : Finset ι) (f : (∀ i, X i) → ℝ) + (hf : ProductDependsOn T f) (D : Finset (Finset ι)) : + productANOVAEnergy μ D f = productANOVAEnergy μ (D.filter (fun S => S ⊆ T)) f := by + classical + unfold productANOVAEnergy + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro S _ + by_cases hS : S ⊆ T + · rw [ite_eq_left hS] + · simp only [ite_eq_right hS, productANOVA_of_depends_not_subset μ T f hf S hS, + zero_pow (by decide : 2 ≠ 0), FiniteProbabilityWeights.mean_const] + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_energy_le_lp (D : Finset (Finset I)) (f : (∀ i, X i) → ℝ) + (p q : ℝ) (hp : 0 < p) (hq : 0 < q) (hpq : 1 / p + 1 / q = 1) : + productANOVAEnergy μ D f ≤ + finiteWeightedLp (FiniteProbabilityWeights.pi μ).weight p f * + finiteWeightedLp (FiniteProbabilityWeights.pi μ).weight q (productANOVATruncation μ D f) := by + rw [productANOVAEnergy_pairing] + exact (le_abs_self _).trans (finiteWeightedHolder_pair + (FiniteProbabilityWeights.pi μ).weight (FiniteProbabilityWeights.pi μ).nonneg + p q hp hq hpq f (productANOVATruncation μ D f)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVAEnergy_mono {D E : Finset (Finset I)} (hDE : D ⊆ E) + (f : (∀ i, X i) → ℝ) : productANOVAEnergy μ D f ≤ productANOVAEnergy μ E f := by + apply Finset.sum_le_sum_of_subset_of_nonneg hDE + intro U _ _ + exact (FiniteProbabilityWeights.pi μ).mean_nonneg (fun _ => sq_nonneg _) + +theorem productANOVAEnergy_le_level (D : Finset (Finset I)) (d : ℕ) + (hD : ∀ U ∈ D, U.card = d) (f : (∀ i, X i) → ℝ) : + productANOVAEnergy μ D f ≤ productANOVAEnergy μ (Finset.univ.powersetCard d) f := by + apply productANOVAEnergy_mono μ _ f + intro U hU + exact Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, hD U hU⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVALpBound.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVALpBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1c56d6262c3d8dbf44d3d8cb98e0ffd418ed491 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVALpBound.lean @@ -0,0 +1,319 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteEvenMomentTransfer +import OAI.Combinatorics.Progressions.Estimates.FiniteNoSingletonRows +import OAI.Combinatorics.Progressions.Estimates.FiniteSectionCountBounds +import OAI.Combinatorics.Progressions.Estimates.FiniteSectionOrderedFree +import OAI.Combinatorics.Progressions.Estimates.ProductTensorSectionPointwise + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_energy (k : ℕ) (base : ∀ i, X i) (f : (∀ i, X i) → ℝ) : + finiteProductIntegral (fun _ : Fin k => coordinateUnionWeight μ) + (fun z => productANOVATensor μ k base f z ^ 2) = + productANOVAEnergy μ (Finset.univ.powersetCard k) f := by + classical + unfold finiteProductIntegral + rw [finiteTaggedTuple_sum] + calc + _ = ∑ a : Fin k → I, if StrictMono a then + (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ (Finset.univ.image a) f x ^ 2) + else 0 := by + apply Finset.sum_congr rfl + intro a _ + change (∑ v, (FiniteProbabilityWeights.pi (fun j => μ (a j))).weight v * + productANOVATensor μ k base f (fun j => ⟨a j, v j⟩) ^ 2) = _ + simp_rw [productANOVATensor_weighted_sq] + by_cases ha : StrictMono a + · simp only [ha, dite_true, ite_true] + refine productMean_tuple μ a ha.injective + (fun x => productANOVA μ (Finset.univ.image a) f x ^ 2) ?_ base + intro x y hxy + exact congrArg (fun t : ℝ => t ^ 2) (productANOVA_depends μ (Finset.univ.image a) f x y hxy) + · simp only [ha, dite_false, ite_false, Finset.sum_const_zero] + _ = _ := finiteOrderedSubset_sum k + (fun S => (FiniteProbabilityWeights.pi μ).mean (fun x => productANOVA μ S f x ^ 2)) + +theorem productANOVATensor_l2 (k : ℕ) (base : ∀ i, X i) (f : (∀ i, X i) → ℝ) : + finiteWeightedLp (fun z : Fin k → Sigma X => ∏ j, coordinateUnionWeight μ (z j)) 2 + (productANOVATensor μ k base f) = + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f) := by + rw [finiteWeightedLp_two] + exact congrArg Real.sqrt (productANOVATensor_energy μ k base f) + +theorem productANOVATensor_unfixed_section (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (z : Fin k → Sigma X) : + finiteSectionL2Norm (fun _ => coordinateUnionWeight μ) k (fun _ => false) + (productANOVATensor μ k base f) z = + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f) := by + rw [finiteSectionL2Norm, finiteSectionIntegral_eq_product] + change Real.sqrt (finiteProductIntegral (fun _ : Fin k => coordinateUnionWeight μ) + (fun v => productANOVATensor μ k base f v ^ 2)) = _ + rw [productANOVATensor_energy] + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_section_bound (n r : ℕ) (s : Fin n → Bool) + (hsr : finiteSectionCount s ≤ r) (z : Fin n → Sigma X) (base : ∀ i, X i) + {K M B : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) (hB : 0 ≤ B) + (f : (∀ i, X i) → ℝ) (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) + (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - finiteSectionCount s) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard (n - finiteSectionCount s)) g) ≤ B) : + finiteSectionL2Norm (fun _ => coordinateUnionWeight μ) n s (productANOVATensor μ n base f) z ≤ + (1 + K) ^ finiteSectionCount s * B := by + classical + have hbound : 0 ≤ (1 + K) ^ finiteSectionCount s * B := + mul_nonneg (pow_nonneg (by linarith) _) hB + by_cases hn : ∃ i, s i = true ∧ coordinateUnionWeight μ (z i) = 0 + · obtain ⟨i, hi, hz⟩ := hn + rw [productANOVATensor_null_section μ n base f s z i hi hz] + exact hbound + · have hz : ∀ i, s i = true → coordinateUnionWeight μ (z i) ≠ 0 := + fun i hi he => hn ⟨i, hi, he⟩ + by_cases ho : ∃ v : Fin (n - finiteSectionCount s) → Sigma X, + StrictMono (fun i => (finiteSectionFill n s z v i).1) + · obtain ⟨v, hv⟩ := ho + have hinj := finiteSectionFill_fixed_injective n s z v hv + have hcard := finiteFixedTagSet_card n s z hinj + obtain ⟨a, ha, haz⟩ := exists_positive_sectionAnchor μ n s z hinj hz + rw [finiteSectionL2Norm_orderedFree] + apply (Real.sqrt_le_sqrt (finiteProductIntegral_mono + (fun _ : Fin (n - finiteSectionCount s) => coordinateUnionWeight μ) + (fun _ x => coordinateUnionWeight_nonneg μ x) _ _ + (productANOVATensor_filled_sq_le μ n s z base a f haz))).trans + have h := productANOVASectionTensor_bound_of_lower_degree μ (finiteFixedTagSet n s z) + (n - finiteSectionCount s) r (by simpa only [hcard] using hsr) a base ha hK hM f hf0 hfM hf + (by simpa only [hcard] using hLower) + simpa only [hcard] using h + · rw [finiteSectionL2Norm_orderedFree] + have he (v : Fin (n - finiteSectionCount s) → Sigma X) : + productANOVATensor μ n base f (finiteSectionFill n s z v) = 0 := + productANOVATensor_zero_of_not_ordered μ n base f _ (fun hv => ho ⟨v, hv⟩) + simp only [he, zero_pow (by decide : 2 ≠ 0), finiteProductIntegral, mul_zero, + Finset.sum_const_zero, Real.sqrt_zero] + exact hbound + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_uniform_sections (n r : ℕ) (hnr : n ≤ r) (base : ∀ i, X i) + {K M R : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) (hR : 1 + K ≤ R) + (f : (∀ i, X i) → ℝ) (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) + (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ j : ℕ, 0 < j → j ≤ n → ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - j) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard (n - j)) g) ≤ R ^ (2 * (n - j))) + (s : Fin n → Bool) (z : Fin n → Sigma X) : + finiteSectionL2Norm (fun _ => coordinateUnionWeight μ) n s (productANOVATensor μ n base f) z ≤ + max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard n) f)) (R ^ (2 * n - 1)) := by + by_cases hs : finiteSectionCount s = 0 + · have he : s = fun _ => false := funext ((finiteSectionCount_eq_zero_iff n s).mp hs) + rw [he, productANOVATensor_unfixed_section] + exact le_max_left _ _ + · have hj : 0 < finiteSectionCount s := Nat.pos_of_ne_zero hs + have hjn := finiteSectionCount_le n s + have hb := productANOVATensor_section_bound μ n r s (hjn.trans hnr) z base hK hM + (pow_nonneg (by linarith : 0 ≤ R) _) f hf0 hfM hf (hLower _ hj hjn) + exact (hb.trans (anovaSection_power_bound_positive hj hjn hK hR)).trans (le_max_right _ _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I J : Type*} [Fintype I] [LinearOrder I] [Fintype J] [DecidableEq J] + {X : I → Type*} [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_hypergraph_bound (k r : ℕ) (hkr : k ≤ r) + (base : ∀ i, X i) (x₀ : Sigma X) {K M R : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) + (hR : 1 + K ≤ R) (f : (∀ i, X i) → ℝ) (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) + (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ j : ℕ, 0 < j → j ≤ k → ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - j) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard (k - j)) g) ≤ R ^ (2 * (k - j))) + (n : ℕ) (a : J → Fin k → Fin n) (ha : ∀ j, Function.Injective (a j)) + (hdeg : ∀ i : Fin n, 2 ≤ finiteFactorMultiplicity (fun j => finiteSlotMask (a j) i)) : + finiteProductIntegral (fun _ : Fin n => coordinateUnionWeight μ) + (fun v => ∏ j, |productANOVATensor μ k base f (fun l => v (a j l))|) ≤ + (max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1))) ^ Fintype.card J := by + have hc : 0 ≤ max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1)) := (Real.sqrt_nonneg _).trans (le_max_left _ _) + have h := finiteHypergraph_unordered_bound (coordinateUnionWeight μ) (coordinateUnionWeight_nonneg μ) + x₀ n k a ha hdeg (fun _ => productANOVATensor μ k base f) + (fun _ => max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) (R ^ (2 * k - 1))) + (fun _ => hc) (fun _ t z => productANOVATensor_uniform_sections μ k r hkr base hK hM hR f hf0 hfM hf hLower t z) + simpa only [Finset.prod_const, Finset.card_univ] using h + +theorem productANOVATensor_abs_hypergraph_bound (k r : ℕ) (hkr : k ≤ r) + (base : ∀ i, X i) (x₀ : Sigma X) {K M R : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) + (hR : 1 + K ≤ R) (f : (∀ i, X i) → ℝ) (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) + (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ j : ℕ, 0 < j → j ≤ k → ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - j) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard (k - j)) g) ≤ R ^ (2 * (k - j))) + (n : ℕ) (a : J → Fin k → Fin n) (ha : ∀ j, Function.Injective (a j)) + (hdeg : ∀ i : Fin n, 2 ≤ finiteFactorMultiplicity (fun j => finiteSlotMask (a j) i)) : + |finiteProductIntegral (fun _ : Fin n => coordinateUnionWeight μ) + (fun v => ∏ j, productANOVATensor μ k base f (fun l => v (a j l)))| ≤ + (max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1))) ^ Fintype.card J := by + have hc : 0 ≤ max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1)) := (Real.sqrt_nonneg _).trans (le_max_left _ _) + have h := finiteHypergraph_abs_unordered_bound (coordinateUnionWeight μ) (coordinateUnionWeight_nonneg μ) + x₀ n k a ha hdeg (fun _ => productANOVATensor μ k base f) + (fun _ => max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) (R ^ (2 * k - 1))) + (fun _ => hc) (fun _ t z => productANOVATensor_uniform_sections μ k r hkr base hK hM hR f hf0 hfM hf hLower t z) + simpa only [Finset.prod_const, Finset.card_univ] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I J : Type*} [Fintype I] [LinearOrder I] [Fintype J] [DecidableEq J] + {X : I → Type*} [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_grouped_bound (k r : ℕ) (hkr : k ≤ r) + (base : ∀ i, X i) (x₀ : Sigma X) {K M R : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) + (hR : 1 + K ≤ R) (f : (∀ i, X i) → ℝ) (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) + (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ j : ℕ, 0 < j → j ≤ k → ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - j) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard (k - j)) g) ≤ R ^ (2 * (k - j))) + (T : Finset ((J × Fin k) → I)) + (horder : ∀ a ∈ T, ∀ j, StrictMono (fun l => a (j, l))) + (hsingle : ∀ a ∈ T, ∀ i, + (Finset.univ.filter (fun j => ∃ l, a (j, l) = i)).card ≠ 1) : + (∑ a ∈ T, (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ j, |productANOVATensor μ k base f (fun l => ⟨a (j, l), x (a (j, l))⟩)|)) ≤ + ((Fintype.card J * k) ^ (Fintype.card J * k) : ℕ) * + (max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1))) ^ Fintype.card J := by + have hc : 0 ≤ max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1)) := (Real.sqrt_nonneg _).trans (le_max_left _ _) + have h := productTensor_grouped_bound μ base x₀ T + (fun a ha j => (horder a ha j).injective) + (fun a ha s => by + have h := finiteRows_two_le_of_no_singletons a (by + intro i + convert hsingle a ha i using 1 + congr 1 + ext j + simp only [Finset.mem_filter, Finset.mem_univ, true_and]) s + convert h using 1 + congr 1 + ext j + simp only [Finset.mem_filter, Finset.mem_univ, true_and]) + (fun _ => productANOVATensor μ k base f) + (fun _ => max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) (R ^ (2 * k - 1))) + (fun _ => hc) (fun _ t z => productANOVATensor_uniform_sections μ k r hkr base hK hM hR f hf0 hfM hf hLower t z) + simpa only [Finset.prod_const, Finset.card_univ] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_moment_bound (k r q : ℕ) (hkr : k ≤ r) + (base : ∀ i, X i) (x₀ : Sigma X) {K M R : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) + (hR : 1 + K ≤ R) (f : (∀ i, X i) → ℝ) (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) + (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ j : ℕ, 0 < j → j ≤ k → ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - j) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard (k - j)) g) ≤ R ^ (2 * (k - j))) : + |(FiniteProbabilityWeights.pi μ).mean + (fun x => (∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ^ q)| ≤ + ((q * k) ^ (q * k) : ℕ) * + (max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1))) ^ q := by + apply (productANOVATensor_abs_moment_le μ k q base f).trans + have h := productANOVATensor_grouped_bound μ k r hkr base x₀ hK hM hR f hf0 hfM hf hLower + (productANOVATensorChoices k q) + (fun a ha => ((mem_productANOVATensorChoices k q a).mp ha).1) + (fun a ha => ((mem_productANOVATensorChoices k q a).mp ha).2) + simpa only [Fintype.card_fin] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_lp_bound (k r q : ℕ) (hkr : k ≤ r) (hq : 0 < q) (heven : Even q) + (base : ∀ i, X i) (x₀ : Sigma X) {K M R : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) + (hR : 1 + K ≤ R) (f : (∀ i, X i) → ℝ) (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) + (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ j : ℕ, 0 < j → j ≤ k → ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - j) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard (k - j)) g) ≤ R ^ (2 * (k - j))) : + finiteWeightedLp (FiniteProbabilityWeights.pi μ).weight (q : ℝ) + (fun x => ∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ≤ + ((q * k : ℕ) : ℝ) ^ k * + max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) + (R ^ (2 * k - 1)) := by + let C := max (Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard k) f)) (R ^ (2 * k - 1)) + have hC : 0 ≤ C := (Real.sqrt_nonneg _).trans (le_max_left _ _) + apply (FiniteProbabilityWeights.pi μ).even_moment_lp_le q hq heven _ _ + (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) hC) + have h := productANOVA_moment_bound μ k r q hkr base x₀ hK hM hR f hf0 hfM hf hLower + apply h.trans_eq + change ((q * k) ^ (q * k) : ℕ) * C ^ q = (((q * k : ℕ) : ℝ) ^ k * C) ^ q + rw [Nat.cast_pow, mul_pow (((q * k : ℕ) : ℝ) ^ k) C q, ← pow_mul, Nat.mul_comm k q] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVASectionNormalizedBound.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVASectionNormalizedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0389be279a09b2fdd48b3fd9ee720c6d7eec5cea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVASectionNormalizedBound.lean @@ -0,0 +1,255 @@ +import OAI.Combinatorics.Progressions.Estimates.ProductDependsOnMix +import OAI.Combinatorics.Progressions.Estimates.ProductTensorGroupedBound + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_smul (S : Finset I) (c : ℝ) (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) : + productANOVA μ S (fun y => c * f y) x = c * productANOVA μ S f x := by + simp only [productANOVA, productConditionalMean_smul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro U _ + ring + +theorem productANOVAEnergy_smul (D : Finset (Finset I)) (c : ℝ) (f : (∀ i, X i) → ℝ) : + productANOVAEnergy μ D (fun y => c * f y) = c ^ 2 * productANOVAEnergy μ D f := by + simp only [productANOVAEnergy, productANOVA_smul, mul_pow, + FiniteProbabilityWeights.mean_const_mul, Finset.mul_sum] + +theorem sqrt_productANOVAEnergy_smul (D : Finset (Finset I)) (c : ℝ) (f : (∀ i, X i) → ℝ) : + Real.sqrt (productANOVAEnergy μ D (fun y => c * f y)) = + |c| * Real.sqrt (productANOVAEnergy μ D f) := by + rw [productANOVAEnergy_smul, Real.sqrt_mul (sq_nonneg c), Real.sqrt_sq_eq_abs] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +noncomputable def productANOVASectionEnergy (T : Finset I) (D : Finset (Finset I)) + (z : ∀ i, X i) (f : (∀ i, X i) → ℝ) : ℝ := + ∑ U ∈ D, (FiniteProbabilityWeights.pi μ).mean + (fun x => productANOVA μ (T ∪ U) f (productCoordinateMix T z x) ^ 2) + +theorem productANOVASectionEnergy_nonneg (T : Finset I) (D : Finset (Finset I)) + (z : ∀ i, X i) (f : (∀ i, X i) → ℝ) : + 0 ≤ productANOVASectionEnergy μ T D z f := + Finset.sum_nonneg (fun _ _ => (FiniteProbabilityWeights.pi μ).mean_nonneg (fun _ => sq_nonneg _)) + +theorem sqrt_productANOVASectionEnergy_le (T : Finset I) (D : Finset (Finset I)) + (hD : ∀ U ∈ D, Disjoint T U) (z : ∀ i, X i) (f : (∀ i, X i) → ℝ) : + Real.sqrt (productANOVASectionEnergy μ T D z f) ≤ + ∑ A ∈ T.powerset, Real.sqrt (productANOVAEnergy μ D (productSectionAverage μ T A z f)) := by + have hsign (n : ℕ) : ((-1 : ℝ) ^ n) ^ 2 = 1 := by + rw [← pow_mul, Nat.mul_comm n 2, pow_mul] + norm_num + have h := (FiniteProbabilityWeights.pi μ).sqrt_sum_mean_sq_triangle T.powerset D + (fun A U x => (-1 : ℝ) ^ (T.card - A.card) * + productANOVA μ U (productSectionAverage μ T A z f) x) + have he : productANOVASectionEnergy μ T D z f = + ∑ U ∈ D, (FiniteProbabilityWeights.pi μ).mean (fun x => + (∑ A ∈ T.powerset, (-1 : ℝ) ^ (T.card - A.card) * + productANOVA μ U (productSectionAverage μ T A z f) x) ^ 2) := by + apply Finset.sum_congr rfl + intro U hU + congr 1 + funext x + rw [productANOVA_disjoint_section μ T U (hD U hU)] + rw [he] + simpa only [mul_pow, hsign, one_mul, productANOVAEnergy] using h + +theorem sqrt_productANOVASectionEnergy_le_normalized (T : Finset I) (D : Finset (Finset I)) + (hD : ∀ U ∈ D, Disjoint T U) (z : ∀ i, X i) {K : ℝ} (hK : 0 < K) + (f : (∀ i, X i) → ℝ) : + Real.sqrt (productANOVASectionEnergy μ T D z f) ≤ + ∑ A ∈ T.powerset, K ^ A.card * + Real.sqrt (productANOVAEnergy μ D (productNormalizedSection μ T A z K f)) := by + apply (sqrt_productANOVASectionEnergy_le μ T D hD z f).trans_eq + apply Finset.sum_congr rfl + intro A _ + have he : productSectionAverage μ T A z f = + fun x => K ^ A.card * productNormalizedSection μ T A z K f x := + funext (productSectionAverage_eq_normalized μ T A z hK.ne' f) + rw [he, sqrt_productANOVAEnergy_smul, abs_of_nonneg (pow_nonneg hK.le _)] + +theorem sqrt_productANOVASectionEnergy_le_of_normalized (T : Finset I) (D : Finset (Finset I)) + (hD : ∀ U ∈ D, Disjoint T U) (z : ∀ i, X i) {K B : ℝ} (hK : 0 < K) + (f : (∀ i, X i) → ℝ) + (hB : ∀ A ∈ T.powerset, + Real.sqrt (productANOVAEnergy μ D (productNormalizedSection μ T A z K f)) ≤ B) : + Real.sqrt (productANOVASectionEnergy μ T D z f) ≤ (1 + K) ^ T.card * B := by + apply (sqrt_productANOVASectionEnergy_le_normalized μ T D hD z hK f).trans + calc + (∑ A ∈ T.powerset, K ^ A.card * + Real.sqrt (productANOVAEnergy μ D (productNormalizedSection μ T A z K f))) + ≤ ∑ A ∈ T.powerset, K ^ A.card * B := + Finset.sum_le_sum (fun A hA => mul_le_mul_of_nonneg_left (hB A hA) (pow_nonneg hK.le _)) + _ = (1 + K) ^ T.card * B := by + rw [← Finset.sum_mul] + congr 1 + simpa only [Finset.prod_const] using (Finset.prod_one_add (f := fun _ : I => K) T).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVASection_bound_of_lower_degree + (T : Finset I) (D : Finset (Finset I)) (d r : ℕ) (hTr : T.card ≤ r) + (hD : ∀ U ∈ D, Disjoint T U ∧ U.card = d) + (z : ∀ i, X i) (hz : (FiniteProbabilityWeights.pi μ).weight z ≠ 0) + {K M B : ℝ} (hK : 1 ≤ K) (hM : 0 ≤ M) (f : (∀ i, X i) → ℝ) + (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - T.card) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard d) g) ≤ B) : + Real.sqrt (productANOVASectionEnergy μ T D z f) ≤ (1 + K) ^ T.card * B := by + apply sqrt_productANOVASectionEnergy_le_of_normalized μ T D (fun U hU => (hD U hU).1) + z (lt_of_lt_of_le zero_lt_one hK) f + intro A hA + have hAT : A ⊆ T := Finset.mem_powerset.mp hA + have hcard : A.card ≤ T.card := Finset.card_le_card hAT + have hG := productNormalizedSection_boundedMarginals μ T A hAT z hz hK (hcard.trans hTr) f hf + apply (Real.sqrt_le_sqrt (productANOVAEnergy_le_level μ D d (fun U hU => (hD U hU).2) + (productNormalizedSection μ T A z K f))).trans + apply hLower (productNormalizedSection μ T A z K f) + (productNormalizedSection_nonneg μ T A z (le_trans zero_le_one hK) f hf0) + (productNormalizedSection_le μ T A z hK hM f hfM) + intro J hJ x hx + exact hG J (by omega) x hx + +omit μ [Fintype I] [DecidableEq I] [∀ i, Fintype (X i)] in +theorem anovaSection_power_bound {j k : ℕ} (hjk : j ≤ k) {K R : ℝ} + (hK : 1 ≤ K) (hR : 1 + K ≤ R) : + (1 + K) ^ j * R ^ (2 * (k - j)) ≤ R ^ (2 * k - j) := by + have hR0 : 0 ≤ R := by linarith + calc + (1 + K) ^ j * R ^ (2 * (k - j)) ≤ R ^ j * R ^ (2 * (k - j)) := + mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by linarith) hR j) (pow_nonneg hR0 _) + _ = R ^ (2 * k - j) := by + rw [← pow_add] + congr 1 + omega + +omit μ [Fintype I] [DecidableEq I] [∀ i, Fintype (X i)] in +theorem anovaSection_power_bound_positive {j k : ℕ} (hj : 0 < j) (hjk : j ≤ k) + {K R : ℝ} (hK : 1 ≤ K) (hR : 1 + K ≤ R) : + (1 + K) ^ j * R ^ (2 * (k - j)) ≤ R ^ (2 * k - 1) := + (anovaSection_power_bound hjk hK hR).trans (pow_le_pow_right₀ (by linarith) (by omega)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +def disjointCoordinateLevel (T : Finset I) (d : ℕ) : Finset (Finset I) := + (Finset.univ.powersetCard d).filter (fun U => Disjoint T U) + +omit μ [∀ i, Fintype (X i)] in +theorem mem_disjointCoordinateLevel (T U : Finset I) (d : ℕ) : + U ∈ disjointCoordinateLevel T d ↔ Disjoint T U ∧ U.card = d := by + simp only [disjointCoordinateLevel, Finset.mem_filter, Finset.mem_powersetCard, + Finset.subset_univ, true_and, and_comm] + +noncomputable def productANOVASectionTensor (T : Finset I) (d : ℕ) + (z base : ∀ i, X i) (f : (∀ i, X i) → ℝ) : (Fin d → Sigma X) → ℝ := + orderedFamilyTensor d base (fun U x => + if Disjoint T U then productANOVA μ (T ∪ U) f (productCoordinateMix T z x) else 0) + +theorem productANOVASectionTensor_energy (T : Finset I) (d : ℕ) + (z base : ∀ i, X i) (f : (∀ i, X i) → ℝ) : + finiteProductIntegral (fun _ : Fin d => coordinateUnionWeight μ) + (fun v => productANOVASectionTensor μ T d z base f v ^ 2) = + productANOVASectionEnergy μ T (disjointCoordinateLevel T d) z f := by + unfold productANOVASectionTensor + rw [orderedFamilyTensor_energy μ] + · simp only [productANOVASectionEnergy, disjointCoordinateLevel, Finset.sum_filter] + apply Finset.sum_congr rfl + intro U _ + by_cases hTU : Disjoint T U + · simp only [hTU, ite_true] + · simp only [hTU, ite_false, zero_pow (by decide : 2 ≠ 0), FiniteProbabilityWeights.mean_const] + · intro U + by_cases hTU : Disjoint T U + · simpa only [hTU, ite_true] using (productANOVA_depends μ (T ∪ U) f).mix z + · intro x y _ + simp only [hTU, ite_false] + +theorem productANOVASectionTensor_bound_of_lower_degree (T : Finset I) (d r : ℕ) + (hTr : T.card ≤ r) (z base : ∀ i, X i) + (hz : (FiniteProbabilityWeights.pi μ).weight z ≠ 0) {K M B : ℝ} + (hK : 1 ≤ K) (hM : 0 ≤ M) (f : (∀ i, X i) → ℝ) + (hf0 : ∀ x, 0 ≤ f x) (hfM : ∀ x, f x ≤ M) (hf : ProductBoundedMarginals μ f K r) + (hLower : ∀ g : (∀ i, X i) → ℝ, + (∀ x, 0 ≤ g x) → (∀ x, g x ≤ M) → ProductBoundedMarginals μ g K (r - T.card) → + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard d) g) ≤ B) : + Real.sqrt (finiteProductIntegral (fun _ : Fin d => coordinateUnionWeight μ) + (fun v => productANOVASectionTensor μ T d z base f v ^ 2)) ≤ (1 + K) ^ T.card * B := by + rw [productANOVASectionTensor_energy] + exact productANOVASection_bound_of_lower_degree μ T (disjointCoordinateLevel T d) d r hTr + (fun U hU => (mem_disjointCoordinateLevel T U d).mp hU) z hz hK hM f hf0 hfM hf hLower + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVASectionTensor_bound_of_normalized (T : Finset I) (d : ℕ) + (z base : ∀ i, X i) {K B : ℝ} (hK : 0 < K) (f : (∀ i, X i) → ℝ) + (hLower : ∀ A ⊆ T, + Real.sqrt (productANOVAEnergy μ (Finset.univ.powersetCard d) + (productNormalizedSection μ T A z K f)) ≤ B) : + Real.sqrt (finiteProductIntegral (fun _ : Fin d => coordinateUnionWeight μ) + (fun v => productANOVASectionTensor μ T d z base f v ^ 2)) ≤ (1 + K) ^ T.card * B := by + rw [productANOVASectionTensor_energy] + apply sqrt_productANOVASectionEnergy_le_of_normalized μ T (disjointCoordinateLevel T d) + (fun U hU => ((mem_disjointCoordinateLevel T U d).mp hU).1) z hK f + intro A hA + apply (Real.sqrt_le_sqrt (productANOVAEnergy_le_level μ (disjointCoordinateLevel T d) d + (fun U hU => ((mem_disjointCoordinateLevel T U d).mp hU).2) + (productNormalizedSection μ T A z K f))).trans + exact hLower A (Finset.mem_powerset.mp hA) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVATensorChoices.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVATensorChoices.lean new file mode 100644 index 0000000000000000000000000000000000000000..c74e56ffc261a20c68d33e1c1f6b2febc66bf15b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVATensorChoices.lean @@ -0,0 +1,347 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteOrderedSubsetSum +import OAI.Combinatorics.Progressions.Estimates.FiniteSectionVanishing +import OAI.Combinatorics.Progressions.Estimates.ProductMeanPullback +import OAI.Combinatorics.Progressions.Geometry.FiniteGoodSupport +import OAI.Combinatorics.Progressions.Linear.ProductANOVAEnergyOrder + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] + {X : I → Type*} [∀ i, Fintype (X i)] + +def ProductNoSingletonCoordinate (S : J → Finset I) {q : ℕ} (a : Fin q → J) : Prop := + ∀ i, (Finset.univ.filter (fun r => i ∈ S (a r))).card ≠ 1 + +noncomputable def productANOVAMomentChoices (S : J → Finset I) (q : ℕ) : Finset (Fin q → J) := by + classical + exact Finset.univ.filter (ProductNoSingletonCoordinate S) + +theorem productANOVA_moment_expansion (μ : ∀ i, FiniteProbabilityWeights (X i)) + (S : J → Finset I) (f : J → (∀ i, X i) → ℝ) (q : ℕ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => (∑ j, productANOVA μ (S j) (f j) x) ^ q) = + ∑ a : Fin q → J, (FiniteProbabilityWeights.pi μ).mean + (fun x => ∏ r, productANOVA μ (S (a r)) (f (a r)) x) := by + simp_rw [Fintype.sum_pow] + exact FiniteProbabilityWeights.mean_sum _ _ _ + +omit [Fintype J] in +theorem productANOVA_term_zero_of_singleton_count (μ : ∀ i, FiniteProbabilityWeights (X i)) + (S : J → Finset I) (f : J → (∀ i, X i) → ℝ) {q : ℕ} (a : Fin q → J) + (i : I) (hi : (Finset.univ.filter (fun r => i ∈ S (a r))).card = 1) : + (FiniteProbabilityWeights.pi μ).mean (fun x => ∏ r, productANOVA μ (S (a r)) (f (a r)) x) = 0 := by + classical + obtain ⟨r₀, hr₀⟩ := Finset.card_eq_one.mp hi + have hi₀ : i ∈ S (a r₀) := by + have hr : r₀ ∈ Finset.univ.filter (fun r => i ∈ S (a r)) := by + rw [hr₀] + exact Finset.mem_singleton_self _ + exact (Finset.mem_filter.mp hr).2 + apply productANOVA_unique_coordinate_zero μ Finset.univ (fun r => S (a r)) + (fun r => f (a r)) (Finset.mem_univ r₀) hi₀ + intro r _ hne hir + have hr : r ∈ Finset.univ.filter (fun r => i ∈ S (a r)) := + Finset.mem_filter.mpr ⟨Finset.mem_univ _, hir⟩ + rw [hr₀] at hr + exact hne (Finset.mem_singleton.mp hr) + +theorem productANOVA_moment_without_singletons (μ : ∀ i, FiniteProbabilityWeights (X i)) + (S : J → Finset I) (f : J → (∀ i, X i) → ℝ) (q : ℕ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => (∑ j, productANOVA μ (S j) (f j) x) ^ q) = + ∑ a ∈ productANOVAMomentChoices S q, (FiniteProbabilityWeights.pi μ).mean + (fun x => ∏ r, productANOVA μ (S (a r)) (f (a r)) x) := by + classical + rw [productANOVA_moment_expansion] + symm + apply Finset.sum_subset (Finset.filter_subset (ProductNoSingletonCoordinate S) Finset.univ) + intro a _ ha + have hbad : ¬ ProductNoSingletonCoordinate S a := by + simpa only [productANOVAMomentChoices, Finset.mem_filter, Finset.mem_univ, true_and] using ha + unfold ProductNoSingletonCoordinate at hbad + push Not at hbad + obtain ⟨i, hi⟩ := hbad + exact productANOVA_term_zero_of_singleton_count μ S f a i hi + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +def coordinateUnionWeight (z : Sigma X) : ℝ := (μ z.1).weight z.2 + +omit [Fintype I] [LinearOrder I] in +theorem coordinateUnionWeight_nonneg (z : Sigma X) : 0 ≤ coordinateUnionWeight μ z := + (μ z.1).nonneg z.2 + +noncomputable def productANOVATensor (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (z : Fin k → Sigma X) : ℝ := by + classical + exact if h : StrictMono (fun j => (z j).1) then + if (∏ j, coordinateUnionWeight μ (z j)) = 0 then 0 else + productANOVA μ (Finset.univ.image (fun j => (z j).1)) f + (productTuplePoint (fun j => (z j).1) h.injective (fun j => (z j).2) base) + else 0 + +theorem productANOVATensor_zero_of_not_ordered (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (z : Fin k → Sigma X) + (hz : ¬StrictMono (fun j => (z j).1)) : productANOVATensor μ k base f z = 0 := by + simp only [productANOVATensor, hz, dite_false] + +theorem productANOVATensor_zero_of_zero_weight (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (z : Fin k → Sigma X) (j : Fin k) + (hj : coordinateUnionWeight μ (z j) = 0) : productANOVATensor μ k base f z = 0 := by + have hw : (∏ i, coordinateUnionWeight μ (z i)) = 0 := + Finset.prod_eq_zero (Finset.mem_univ j) hj + simp [productANOVATensor, hw] + +theorem productANOVATensor_zero_of_repeated (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (z : Fin k → Sigma X) (j l : Fin k) + (hjl : j ≠ l) (he : (z j).1 = (z l).1) : productANOVATensor μ k base f z = 0 := by + apply productANOVATensor_zero_of_not_ordered μ k base f z + intro h + exact hjl (h.injective he) + +theorem productANOVATensor_basepoint (k : ℕ) (base base' : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (z : Fin k → Sigma X) : + productANOVATensor μ k base f z = productANOVATensor μ k base' f z := by + classical + by_cases hz : StrictMono (fun j => (z j).1) + · simp only [productANOVATensor, hz, dite_true] + split_ifs with hw + · rfl + · apply productANOVA_depends μ (Finset.univ.image (fun j => (z j).1)) f + intro i hi + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hi + exact (productTuplePoint_apply _ hz.injective (fun j => (z j).2) base j).trans + (productTuplePoint_apply _ hz.injective (fun j => (z j).2) base' j).symm + · simp only [productANOVATensor, hz, dite_false] + +theorem productANOVATensor_weighted_sq (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (a : Fin k → I) (v : ∀ j, X (a j)) : + (FiniteProbabilityWeights.pi (fun j => μ (a j))).weight v * + productANOVATensor μ k base f (fun j => ⟨a j, v j⟩) ^ 2 = + if ha : StrictMono a then + (FiniteProbabilityWeights.pi (fun j => μ (a j))).weight v * + productANOVA μ (Finset.univ.image a) f (productTuplePoint a ha.injective v base) ^ 2 + else 0 := by + classical + by_cases ha : StrictMono a + · simp only [productANOVATensor, ha, dite_true] + change _ * (if (FiniteProbabilityWeights.pi (fun j => μ (a j))).weight v = 0 then 0 else _) ^ 2 = _ + by_cases hw : (FiniteProbabilityWeights.pi (fun j => μ (a j))).weight v = 0 + · simp only [hw, zero_mul] + · simp only [hw, ite_false] + · simp only [productANOVATensor, ha, dite_false, zero_pow (by decide : 2 ≠ 0), mul_zero] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_evaluate (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (a : Fin k → I) (x : ∀ i, X i) + (hx : (FiniteProbabilityWeights.pi μ).weight x ≠ 0) : + productANOVATensor μ k base f (fun j => ⟨a j, x (a j)⟩) = + if StrictMono a then productANOVA μ (Finset.univ.image a) f x else 0 := by + classical + have hw : (∏ j, coordinateUnionWeight μ (⟨a j, x (a j)⟩ : Sigma X)) ≠ 0 := by + apply Finset.prod_ne_zero_iff.mpr + intro j _ + exact Finset.prod_ne_zero_iff.mp hx (a j) (Finset.mem_univ _) + by_cases ha : StrictMono a + · simp only [productANOVATensor, ha, dite_true, hw, ite_false, ite_true] + exact (productANOVA_depends μ (Finset.univ.image a) f).tuplePoint ha.injective x base + · simp only [productANOVATensor, ha, dite_false, ite_false] + +theorem productANOVATensor_sum_evaluate (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (x : ∀ i, X i) + (hx : (FiniteProbabilityWeights.pi μ).weight x ≠ 0) : + (∑ a : Fin k → I, productANOVATensor μ k base f (fun j => ⟨a j, x (a j)⟩)) = + ∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x := by + simp_rw [productANOVATensor_evaluate μ k base f _ x hx] + exact finiteOrderedSubset_sum k (fun S => productANOVA μ S f x) + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_null_section (k : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (s : Fin k → Bool) (z : Fin k → Sigma X) + (j : Fin k) (hj : s j = true) (hz : coordinateUnionWeight μ (z j) = 0) : + finiteSectionL2Norm (fun _ => coordinateUnionWeight μ) k s (productANOVATensor μ k base f) z = 0 := by + apply finiteSectionL2Norm_eq_zero_of_fixed _ k s _ z j hj + intro v hv + apply productANOVATensor_zero_of_zero_weight μ k base f v j + rw [hv, hz] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_moment_expansion (k q : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean + (fun x => (∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ^ q) = + ∑ a : (Fin q × Fin k) → I, (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ j, productANOVATensor μ k base f (fun l => ⟨a (j, l), x (a (j, l))⟩)) := by + have h := (FiniteProbabilityWeights.pi μ).mean_congr_on_support + (f := fun x => (∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ^ q) + (g := fun x => (∑ a : Fin k → I, + productANOVATensor μ k base f (fun j => ⟨a j, x (a j)⟩)) ^ q) + (fun x hx => congrArg (fun t : ℝ => t ^ q) (productANOVATensor_sum_evaluate μ k base f x hx).symm) + rw [h] + simp_rw [Fintype.sum_pow] + rw [FiniteProbabilityWeights.mean_sum] + exact Fintype.sum_equiv (Equiv.curry (Fin q) (Fin k) I).symm _ _ (fun _ => rfl) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_mean_product (k q : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (a : (Fin q × Fin k) → I) + (horder : ∀ j, StrictMono (fun l => a (j, l))) : + (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ j, productANOVATensor μ k base f (fun l => ⟨a (j, l), x (a (j, l))⟩)) = + (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ j, productANOVA μ (Finset.univ.image (fun l => a (j, l))) f x) := by + apply FiniteProbabilityWeights.mean_congr_on_support + intro x hx + apply Finset.prod_congr rfl + intro j _ + rw [productANOVATensor_evaluate μ k base f (fun l => a (j, l)) x hx, ite_eq_left (horder j)] + +theorem productANOVATensor_mean_zero_of_not_ordered (k q : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (a : (Fin q × Fin k) → I) (j : Fin q) + (hj : ¬ StrictMono (fun l => a (j, l))) : + (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ b, productANOVATensor μ k base f (fun l => ⟨a (b, l), x (a (b, l))⟩)) = 0 := by + have he : (fun x : ∀ i, X i => ∏ b, productANOVATensor μ k base f + (fun l => ⟨a (b, l), x (a (b, l))⟩)) = fun _ => 0 := by + funext x + exact Finset.prod_eq_zero (Finset.mem_univ j) + (productANOVATensor_zero_of_not_ordered μ k base f _ hj) + rw [he, FiniteProbabilityWeights.mean_const] + +theorem productANOVATensor_mean_zero_of_singleton (k q : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) (a : (Fin q × Fin k) → I) + (horder : ∀ j, StrictMono (fun l => a (j, l))) (i : I) + (hi : (Finset.univ.filter (fun j => ∃ l, a (j, l) = i)).card = 1) : + (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ j, productANOVATensor μ k base f (fun l => ⟨a (j, l), x (a (j, l))⟩)) = 0 := by + rw [productANOVATensor_mean_product μ k q base f a horder] + apply productANOVA_term_zero_of_singleton_count μ + (fun j => Finset.univ.image (fun l => a (j, l))) (fun _ => f) (fun j => j) i + simpa only [Finset.mem_image, Finset.mem_univ, true_and] using hi + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] + +noncomputable def productANOVATensorChoices (k q : ℕ) : Finset ((Fin q × Fin k) → I) := by + classical + exact Finset.univ.filter (fun a => (∀ j, StrictMono (fun l => a (j, l))) ∧ + ∀ i, (Finset.univ.filter (fun j => ∃ l, a (j, l) = i)).card ≠ 1) + +theorem mem_productANOVATensorChoices (k q : ℕ) (a : (Fin q × Fin k) → I) : + a ∈ productANOVATensorChoices k q ↔ (∀ j, StrictMono (fun l => a (j, l))) ∧ + ∀ i, (Finset.univ.filter (fun j => ∃ l, a (j, l) = i)).card ≠ 1 := by + classical + simp only [productANOVATensorChoices, Finset.mem_filter, Finset.mem_univ, true_and] + +variable {X : I → Type*} [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVATensor_moment_admissible (k q : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean + (fun x => (∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ^ q) = + ∑ a ∈ productANOVATensorChoices k q, (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ j, productANOVATensor μ k base f (fun l => ⟨a (j, l), x (a (j, l))⟩)) := by + classical + rw [productANOVATensor_moment_expansion μ k q base f] + symm + apply Finset.sum_subset (Finset.filter_subset _ _) + intro a _ ha + by_cases horder : ∀ j, StrictMono (fun l => a (j, l)) + · have hs : ¬∀ i, (Finset.univ.filter (fun j => ∃ l, a (j, l) = i)).card ≠ 1 := by + intro hs + exact ha ((mem_productANOVATensorChoices k q a).mpr ⟨horder, hs⟩) + push Not at hs + obtain ⟨i, hi⟩ := hs + exact productANOVATensor_mean_zero_of_singleton μ k q base f a horder i hi + · push Not at horder + obtain ⟨j, hj⟩ := horder + exact productANOVATensor_mean_zero_of_not_ordered μ k q base f a j hj + +theorem productANOVATensor_abs_moment_le (k q : ℕ) (base : ∀ i, X i) + (f : (∀ i, X i) → ℝ) : + |(FiniteProbabilityWeights.pi μ).mean + (fun x => (∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ^ q)| ≤ + ∑ a ∈ productANOVATensorChoices k q, (FiniteProbabilityWeights.pi μ).mean (fun x => + ∏ j, |productANOVATensor μ k base f (fun l => ⟨a (j, l), x (a (j, l))⟩)|) := by + rw [productANOVATensor_moment_admissible μ k q base f] + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply Finset.sum_le_sum + intro a _ + simpa only [Finset.abs_prod] using (FiniteProbabilityWeights.pi μ).abs_mean_le_mean_abs + (fun x => ∏ j, productANOVATensor μ k base f (fun l => ⟨a (j, l), x (a (j, l))⟩)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAWeightedEnergy.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAWeightedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..1987033ce8b9b3c5847afd76f783efb022528ba6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAWeightedEnergy.lean @@ -0,0 +1,37 @@ +import OAI.Combinatorics.Progressions.Linear.ProductANOVAEnergyOrder + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_weighted_energy_le_lp (rho F : (∀ i, X i) → ℝ) + (hrho : ∀ x, 0 ≤ rho x) (D : Finset (Finset I)) + (p q : ℝ) (hp : 0 < p) (hq : 0 < q) (hpq : 1 / p + 1 / q = 1) : + productANOVAEnergy μ D (fun x => rho x * F x) ≤ + finiteWeightedLp (fun x => (FiniteProbabilityWeights.pi μ).weight x * rho x) p F * + finiteWeightedLp (fun x => (FiniteProbabilityWeights.pi μ).weight x * rho x) q + (productANOVATruncation μ D (fun x => rho x * F x)) := by + let P := productANOVATruncation μ D (fun x => rho x * F x) + rw [productANOVAEnergy_pairing] + have he : (FiniteProbabilityWeights.pi μ).mean (fun x => (rho x * F x) * P x) = + ∑ x, ((FiniteProbabilityWeights.pi μ).weight x * rho x) * (F x * P x) := by + unfold FiniteProbabilityWeights.mean + apply Finset.sum_congr rfl + intro x _ + ring + rw [he] + exact (le_abs_self _).trans (finiteWeightedHolder_pair _ + (fun x => mul_nonneg ((FiniteProbabilityWeights.pi μ).nonneg x) (hrho x)) p q hp hq hpq F P) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAWeightedLp.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAWeightedLp.lean new file mode 100644 index 0000000000000000000000000000000000000000..9338d8585638229657cfca37e5a70f32f495bbe4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductANOVAWeightedLp.lean @@ -0,0 +1,143 @@ +import OAI.Combinatorics.Progressions.Estimates.FiniteEvenMomentTransfer +import OAI.Combinatorics.Progressions.Estimates.ProductFamilyMomentComparison +import OAI.Combinatorics.Progressions.Estimates.ProductTensorGroupedBound + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [DecidableEq I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_moment_comparison (rho F : (∀ i, X i) → ℝ) + (hrho : ∀ x, 0 ≤ rho x) {M eta : ℝ} (hM : 0 ≤ M) (heta : 0 ≤ eta) + (hF : ∀ x, 0 ≤ F x ∧ F x ≤ M) (k q : ℕ) (hq : 0 < q) + (hclose : ProductMarginalsClose μ rho eta (q * k)) : + |(FiniteProbabilityWeights.pi μ).mean (fun x => rho x * + productANOVATruncation μ (Finset.univ.powersetCard k) (fun y => rho y * F y) x ^ q) - + (FiniteProbabilityWeights.pi μ).mean (fun x => + productANOVATruncation μ (Finset.univ.powersetCard k) (fun y => rho y * F y) x ^ q)| ≤ + eta * ((2 : ℝ) ^ k * (Fintype.card I : ℝ) ^ k * M * (1 + eta)) ^ q := by + classical + let D : Finset (Finset I) := Finset.univ.powersetCard k + let C := (2 : ℝ) ^ k * (M * (1 + eta)) + have hC : 0 ≤ C := by dsimp [C]; positivity + have hd (j : ↥D) : j.1.card = k := (Finset.mem_powersetCard.mp j.2).2 + have hcap : ∀ (j : ↥D) x, (FiniteProbabilityWeights.pi μ).weight x ≠ 0 → + |productANOVA μ j.1 (fun y => rho y * F y) x| ≤ C := by + intro j x hx + have h := productANOVA_weighted_cap μ rho F hrho hM hF j.1 (by + intro T hT + apply hclose T + have ht := Finset.card_le_card hT + rw [hd j] at ht + nlinarith) x hx + simpa only [hd j] using h + have h := productFamily_moment_comparison μ rho (fun j : ↥D => j.1) + (fun j => productANOVA μ j.1 (fun y => rho y * F y)) k q heta hC + (fun j => (hd j).le) (fun j => productANOVA_depends μ j.1 _) hcap hclose + simp only [Fintype.card_coe] at h + have hsum (x : ∀ i, X i) : + (∑ j : ↥D, productANOVA μ j.1 (fun y => rho y * F y) x) = + productANOVATruncation μ D (fun y => rho y * F y) x := + Finset.sum_coe_sort D (fun S => productANOVA μ S (fun y => rho y * F y) x) + simp_rw [hsum] at h + have hcard : (D.card : ℝ) ≤ (Fintype.card I : ℝ) ^ k := by + dsimp [D] + rw [Finset.card_powersetCard, Finset.card_univ] + exact_mod_cast Nat.choose_le_pow (Fintype.card I) k + calc + _ ≤ eta * (D.card : ℝ) ^ q * C ^ q := h + _ ≤ eta * ((Fintype.card I : ℝ) ^ k) ^ q * C ^ q := + mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (Nat.cast_nonneg _) hcard q) heta) + (pow_nonneg hC _) + _ = _ := by simp only [C, mul_pow]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_moment_bound_of_sections (k q : ℕ) (base : ∀ i, X i) (x₀ : Sigma X) + (f : (∀ i, X i) → ℝ) (B : ℝ) (hB : 0 ≤ B) + (hsection : ∀ t z, finiteSectionL2Norm (fun _ => coordinateUnionWeight μ) k t + (productANOVATensor μ k base f) z ≤ B) : + |(FiniteProbabilityWeights.pi μ).mean + (fun x => (∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ^ q)| ≤ + ((q * k) ^ (q * k) : ℕ) * B ^ q := by + apply (productANOVATensor_abs_moment_le μ k q base f).trans + have h := productTensor_grouped_bound μ base x₀ (productANOVATensorChoices k q) + (fun a ha j => (((mem_productANOVATensorChoices k q a).mp ha).1 j).injective) + (fun a ha s => by + have hn := ((mem_productANOVATensorChoices k q a).mp ha).2 (a s) + have hp : 0 < (Finset.univ.filter (fun j => ∃ l, a (j, l) = a s)).card := + Finset.card_pos.mpr ⟨s.1, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ⟨s.2, rfl⟩⟩⟩ + omega) + (fun _ => productANOVATensor μ k base f) (fun _ => B) (fun _ => hB) (fun _ => hsection) + simpa only [Fintype.card_fin, Finset.prod_const, Finset.card_univ] using h + +theorem productANOVA_lp_bound_of_sections (k q : ℕ) (hq : 0 < q) (heven : Even q) + (base : ∀ i, X i) (x₀ : Sigma X) (f : (∀ i, X i) → ℝ) (B : ℝ) (hB : 0 ≤ B) + (hsection : ∀ t z, finiteSectionL2Norm (fun _ => coordinateUnionWeight μ) k t + (productANOVATensor μ k base f) z ≤ B) : + finiteWeightedLp (FiniteProbabilityWeights.pi μ).weight (q : ℝ) + (fun x => ∑ S ∈ Finset.univ.powersetCard k, productANOVA μ S f x) ≤ + ((q * k : ℕ) : ℝ) ^ k * B := by + apply (FiniteProbabilityWeights.pi μ).even_moment_lp_le q hq heven _ _ + (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) hB) + apply (productANOVA_moment_bound_of_sections μ k q base x₀ f B hB hsection).trans_eq + rw [Nat.cast_pow, mul_pow (((q * k : ℕ) : ℝ) ^ k) B q, ← pow_mul, Nat.mul_comm k q] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I : Type*} [Fintype I] [LinearOrder I] {X : I → Type*} + [∀ i, Fintype (X i)] (μ : ∀ i, FiniteProbabilityWeights (X i)) + +theorem productANOVA_weighted_lp_of_sections (rho F : (∀ i, X i) → ℝ) + (hrho : ∀ x, 0 ≤ rho x) {M eta : ℝ} (hM : 0 ≤ M) (heta : 0 ≤ eta) + (hF : ∀ x, 0 ≤ F x ∧ F x ≤ M) (k q : ℕ) (hq : 0 < q) (heven : Even q) + (base : ∀ i, X i) (x₀ : Sigma X) (C : ℝ) (hC : 0 ≤ C) + (hclose : ProductMarginalsClose μ rho eta (q * k)) + (herr : eta * ((2 : ℝ) ^ k * (Fintype.card I : ℝ) ^ k * M * (1 + eta)) ^ q ≤ 1) + (hsection : ∀ t z, finiteSectionL2Norm (fun _ => coordinateUnionWeight μ) k t + (productANOVATensor μ k base (fun x => rho x * F x)) z ≤ C) : + finiteWeightedLp (fun x => (FiniteProbabilityWeights.pi μ).weight x * rho x) (q : ℝ) + (productANOVATruncation μ (Finset.univ.powersetCard k) (fun x => rho x * F x)) ≤ + ((q * k : ℕ) : ℝ) ^ k * C + 1 := by + let P := productANOVATruncation μ (Finset.univ.powersetCard k) (fun x => rho x * F x) + have hm : |∑ x, (FiniteProbabilityWeights.pi μ).weight x * P x ^ q| ≤ + (((q * k : ℕ) : ℝ) ^ k * C) ^ q := by + apply (productANOVA_moment_bound_of_sections μ k q base x₀ _ C hC hsection).trans_eq + rw [Nat.cast_pow, mul_pow (((q * k : ℕ) : ℝ) ^ k) C q, ← pow_mul, Nat.mul_comm k q] + have hc := (productANOVA_moment_comparison μ rho F hrho hM heta hF k q hq hclose).trans herr + apply finiteWeightedLp_transfer_even _ (FiniteProbabilityWeights.pi μ).weight + (fun x => mul_nonneg ((FiniteProbabilityWeights.pi μ).nonneg x) (hrho x)) + q hq heven P _ (mul_nonneg (pow_nonneg (Nat.cast_nonneg _) _) hC) hm + simpa only [FiniteProbabilityWeights.mean, mul_assoc] using hc + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductEmbeddingANOVA.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductEmbeddingANOVA.lean new file mode 100644 index 0000000000000000000000000000000000000000..edec7283213b85a03bc44aceea04cd2bca8ed504 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductEmbeddingANOVA.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Linear.ProductANOVAEnergyOrder +import OAI.Combinatorics.Progressions.Probability.ProductEmbeddingConditional + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] + {X : I → Type*} [∀ i, Fintype (X i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (e : J ↪ I) (base : ∀ i, X i) + +include base + +theorem productANOVA_embedding (S : Finset J) (f : (∀ j, X (e j)) → ℝ) (x : ∀ i, X i) : + productANOVA μ (S.map e) (fun y => f (fun j => y (e j))) x = + productANOVA (fun j => μ (e j)) S f (fun j => x (e j)) := by + have happ (U : Finset J) : (Finset.mapEmbedding e).toEmbedding U = U.map e := rfl + have hp : (S.map e).powerset = S.powerset.map (Finset.mapEmbedding e).toEmbedding := by + simp only [Finset.map_eq_image, Finset.powerset_image] + congr 1 + funext U + exact (Finset.map_eq_image e U).symm + unfold productANOVA + rw [hp, Finset.sum_map] + simp only [happ, Finset.card_map, + ← Finset.map_sdiff, productConditionalMean_embedding μ e base] + +theorem productANOVATruncation_embedding (D : Finset (Finset J)) (f : (∀ j, X (e j)) → ℝ) + (x : ∀ i, X i) : + productANOVATruncation μ (D.map (Finset.mapEmbedding e).toEmbedding) (fun y => f (fun j => y (e j))) x = + productANOVATruncation (fun j => μ (e j)) D f (fun j => x (e j)) := by + have happ (U : Finset J) : (Finset.mapEmbedding e).toEmbedding U = U.map e := rfl + unfold productANOVATruncation + rw [Finset.sum_map] + simp only [happ, productANOVA_embedding μ e base] + +theorem productANOVAEnergy_embedding (D : Finset (Finset J)) (f : (∀ j, X (e j)) → ℝ) : + productANOVAEnergy μ (D.map (Finset.mapEmbedding e).toEmbedding) (fun y => f (fun j => y (e j))) = + productANOVAEnergy (fun j => μ (e j)) D f := by + have happ (U : Finset J) : (Finset.mapEmbedding e).toEmbedding U = U.map e := rfl + unfold productANOVAEnergy + rw [Finset.sum_map] + apply Finset.sum_congr rfl + intro S _ + simp only [happ, productANOVA_embedding μ e base] + exact productMean_pullback μ e e.injective base (fun y => productANOVA (fun j => μ (e j)) S f y ^ 2) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductKernelPairing.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductKernelPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3a429bb7a1fa26228b7e90e3680ad170805d7f7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductKernelPairing.lean @@ -0,0 +1,210 @@ +import OAI.Combinatorics.Progressions.Probability.CylinderJointMass + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +namespace FiniteProbabilityWeights + +theorem mean_pi_fin_cons {n : ℕ} {X : Fin (n + 1) → Type*} [∀ i, Fintype (X i)] + (p : ∀ i, FiniteProbabilityWeights (X i)) (f : (∀ i, X i) → ℝ) : + (pi p).mean f = (p 0).mean (fun a => + (pi (fun i : Fin n => p i.succ)).mean (fun y => f (Fin.cons a y))) := by + have h := congrArg Complex.re (complexMean_pi_fin_cons p (fun x => (f x : ℂ))) + simpa only [complexMean_re, Complex.ofReal_re] using h + +theorem mean_empty_tuple {X : Fin 0 → Type*} [∀ i, Fintype (X i)] + (p : FiniteProbabilityWeights (∀ i, X i)) (f : (∀ i, X i) → ℝ) : + p.mean f = f (fun i => Fin.elim0 i) := by + have hf : f = fun _ => f (fun i => Fin.elim0 i) := by + funext x + exact congrArg f (Subsingleton.elim _ _) + rw [hf, p.mean_const] + +end FiniteProbabilityWeights + +noncomputable def productMatrixApply {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (Y i)] (A : ∀ i, X i → Y i → ℝ) + (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : ℝ := ∑ y, (∏ i, A i (x i) (y i)) * f y + +theorem productMatrixApply_empty {X Y : Fin 0 → Type*} [∀ i, Fintype (Y i)] + (A : ∀ i, X i → Y i → ℝ) (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productMatrixApply A f x = f (fun i => Fin.elim0 i) := by + classical + simp only [productMatrixApply, Fin.prod_univ_zero, one_mul, Fintype.sum_unique] + congr 1 + +theorem productMatrixApply_fin_cons {n : ℕ} {X Y : Fin (n + 1) → Type*} + [∀ i, Fintype (Y i)] (A : ∀ i, X i → Y i → ℝ) (f : (∀ i, Y i) → ℝ) + (x : X 0) (u : ∀ i : Fin n, X i.succ) : + productMatrixApply A f (Fin.cons x u) = ∑ y : Y 0, A 0 x y * + productMatrixApply (fun i : Fin n => A i.succ) (fun v => f (Fin.cons y v)) u := by + simp only [productMatrixApply, sum_dependent_fin_cons, Fin.prod_univ_succ, + Fin.cons_zero, Fin.cons_succ, Finset.mul_sum, mul_assoc] + +theorem productMatrixApply_sq_le_fin {n : ℕ} {X Y : Fin n → Type*} + [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (ν : ∀ i, FiniteProbabilityWeights (Y i)) + (A : ∀ i, X i → Y i → ℝ) (C : Fin n → ℝ) (hC : ∀ i, 0 ≤ C i) + (hA : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (∑ y, A i x y * f y) ^ 2) ≤ + C i * (ν i).mean (fun y => f y ^ 2)) (f : (∀ i, Y i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productMatrixApply A f x ^ 2) ≤ + (∏ i, C i) * (FiniteProbabilityWeights.pi ν).mean (fun y => f y ^ 2) := by + induction n with + | zero => + simp only [productMatrixApply_empty, Fin.prod_univ_zero, one_mul, + FiniteProbabilityWeights.mean_const, FiniteProbabilityWeights.mean_empty_tuple] + exact le_rfl + | succ n ih => + rw [FiniteProbabilityWeights.mean_pi_fin_cons] + simp_rw [productMatrixApply_fin_cons] + rw [FiniteProbabilityWeights.mean_comm] + calc + _ ≤ (FiniteProbabilityWeights.pi (fun i : Fin n => μ i.succ)).mean + (fun x => C 0 * (ν 0).mean (fun y => + productMatrixApply (fun i : Fin n => A i.succ) (fun v => f (Fin.cons y v)) x ^ 2)) := + FiniteProbabilityWeights.mean_mono _ (fun x => hA 0 _) + _ = C 0 * (ν 0).mean (fun y => + (FiniteProbabilityWeights.pi (fun i : Fin n => μ i.succ)).mean + (fun x => productMatrixApply (fun i : Fin n => A i.succ) (fun v => f (Fin.cons y v)) x ^ 2)) := by + rw [FiniteProbabilityWeights.mean_const_mul, FiniteProbabilityWeights.mean_comm] + _ ≤ C 0 * (ν 0).mean (fun y => (∏ i : Fin n, C i.succ) * + (FiniteProbabilityWeights.pi (fun i : Fin n => ν i.succ)).mean + (fun v => f (Fin.cons y v) ^ 2)) := by + apply mul_le_mul_of_nonneg_left _ (hC 0) + apply FiniteProbabilityWeights.mean_mono + intro y + exact ih (fun i => μ i.succ) (fun i => ν i.succ) (fun i => A i.succ) + (fun i => C i.succ) (fun i => hC i.succ) (fun i => hA i.succ) (fun v => f (Fin.cons y v)) + _ = _ := by + rw [FiniteProbabilityWeights.mean_const_mul, Fin.prod_univ_succ, + FiniteProbabilityWeights.mean_pi_fin_cons] + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + +omit [∀ i, Fintype (X i)] in +theorem productMatrixApply_reindex (A : ∀ i, X i → Y i → ℝ) (e : κ ≃ ι) + (f : (∀ i, Y i) → ℝ) (x : ∀ i, X i) : + productMatrixApply A f x = productMatrixApply (fun j => A (e j)) + (fun y => f (Equiv.piCongrLeft Y e y)) (fun j => x (e j)) := by + classical + unfold productMatrixApply + apply Fintype.sum_equiv (Equiv.piCongrLeft Y e).symm + intro y + simp only [Equiv.apply_symm_apply, Equiv.piCongrLeft_symm_apply] + rw [e.prod_comp (fun i => A i (x i) (y i))] + +omit [Fintype κ] [DecidableEq κ] in +theorem productMatrixApply_sq_le (μ : ∀ i, FiniteProbabilityWeights (X i)) + (ν : ∀ i, FiniteProbabilityWeights (Y i)) (A : ∀ i, X i → Y i → ℝ) + (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hA : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (∑ y, A i x y * f y) ^ 2) ≤ + C i * (ν i).mean (fun y => f y ^ 2)) (f : (∀ i, Y i) → ℝ) : + (FiniteProbabilityWeights.pi μ).mean (fun x => productMatrixApply A f x ^ 2) ≤ + (∏ i, C i) * (FiniteProbabilityWeights.pi ν).mean (fun y => f y ^ 2) := by + let e := (Fintype.equivFin ι).symm + let eY := Equiv.piCongrLeft Y e + have hh := productMatrixApply_sq_le_fin (fun j => μ (e j)) (fun j => ν (e j)) + (fun j => A (e j)) (fun j => C (e j)) (fun j => hC (e j)) (fun j => hA (e j)) + (fun y => f (eY y)) + have hleft := productMean_reindex μ e + (fun x => productMatrixApply (fun j => A (e j)) (fun y => f (eY y)) x ^ 2) + rw [← hleft] at hh + have heval (x : ∀ i, X i) : productMatrixApply (fun j => A (e j)) + (fun y => f (eY y)) (fun j => x (e j)) = productMatrixApply A f x := + (productMatrixApply_reindex A e f x).symm + simp_rw [heval] at hh + have hright := productMean_reindex ν e (fun y => f (eY y) ^ 2) + have he (y : ∀ i, Y i) : eY (fun j => y (e j)) = y := eY.apply_symm_apply y + simp_rw [he] at hright + rw [← hright, e.prod_comp C] at hh + exact hh + +omit [Fintype κ] [DecidableEq κ] in +theorem productMatrixApply_pairing_sq_le (μ : ∀ i, FiniteProbabilityWeights (X i)) + (ν : ∀ i, FiniteProbabilityWeights (Y i)) (A : ∀ i, X i → Y i → ℝ) + (C : ι → ℝ) (hC : ∀ i, 0 ≤ C i) + (hA : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (∑ y, A i x y * f y) ^ 2) ≤ + C i * (ν i).mean (fun y => f y ^ 2)) + (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : + ((FiniteProbabilityWeights.pi μ).mean (fun x => w x * productMatrixApply A f x)) ^ 2 ≤ + (∏ i, C i) * (FiniteProbabilityWeights.pi μ).mean (fun x => w x ^ 2) * + (FiniteProbabilityWeights.pi ν).mean (fun y => f y ^ 2) := by + have hc := (FiniteProbabilityWeights.pi μ).mean_mul_sq_le w (productMatrixApply A f) + have ht := productMatrixApply_sq_le μ ν A C hC hA f + have he := mul_le_mul_of_nonneg_left ht ((FiniteProbabilityWeights.pi μ).mean_nonneg (fun x => sq_nonneg (w x))) + exact (hc.trans he).trans_eq (by ring) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def productPairCoordinates {ι : Type*} (X Y : ι → Type*) : + (∀ i, X i × Y i) ≃ (∀ i, X i) × (∀ i, Y i) where + toFun z := (fun i => (z i).1, fun i => (z i).2) + invFun z := fun i => (z.1 i, z.2 i) + left_inv _ := rfl + right_inv _ := rfl + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {X Y : ι → Type*} [∀ i, Fintype (X i)] [∀ i, Fintype (Y i)] + +theorem productJoint_mean (μ : ∀ i, FiniteProbabilityWeights (X i)) + (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) + (F : (∀ i, X i) → (∀ i, Y i) → ℝ) : + (FiniteProbabilityWeights.pi (fun i => (μ i).joint (K i))).mean + (fun z => F (fun i => (z i).1) (fun i => (z i).2)) = + (FiniteProbabilityWeights.pi μ).mean + (fun x => (FiniteProbabilityWeights.pi (fun i => K i (x i))).mean (F x)) := by + calc + _ = ∑ z : (∀ i, X i) × (∀ i, Y i), + (∏ i, (μ i).weight (z.1 i)) * (∏ i, (K i (z.1 i)).weight (z.2 i)) * F z.1 z.2 := by + apply Fintype.sum_equiv (productPairCoordinates X Y) + intro z + change (∏ i, (μ i).weight (z i).1 * (K i (z i).1).weight (z i).2) * _ = _ + rw [Finset.prod_mul_distrib] + rfl + _ = _ := by + simp only [Fintype.sum_prod_type, FiniteProbabilityWeights.mean, + FiniteProbabilityWeights.pi, Finset.mul_sum, mul_assoc] + +theorem productCouplingPairing_ofKernel (μ : ∀ i, FiniteProbabilityWeights (X i)) + (ν : ∀ i, FiniteProbabilityWeights (Y i)) (K : ∀ i, X i → FiniteProbabilityWeights (Y i)) + (hK : ∀ i (f : Y i → ℝ), (μ i).mean (fun x => (K i x).mean f) = (ν i).mean f) + (w : (∀ i, X i) → ℝ) (f : (∀ i, Y i) → ℝ) : + productCouplingPairing (fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (K i) (hK i)) w f = + (FiniteProbabilityWeights.pi μ).mean + (fun x => w x * productMatrixApply (fun i x y => (K i x).weight y) f x) := by + change (FiniteProbabilityWeights.pi (fun i => (μ i).joint (K i))).mean + (fun z => w (fun i => (z i).1) * f (fun i => (z i).2)) = _ + rw [productJoint_mean μ K (fun x y => w x * f y)] + simp only [FiniteProbabilityWeights.mean_const_mul] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProductOneSiteProjectionCap.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProductOneSiteProjectionCap.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5469477086501432681a17edf0a7b1b3f93b91b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProductOneSiteProjectionCap.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.Progressions.Fourier.OneSiteFourierAverage + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial + +theorem affineCubeFourierProjection_approx {I K F : Type*} [Fintype K] [Fintype F] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (t : K → ℤ) (difference : Fin 0 → K → ℤ) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ) {η : ℝ} + (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (b : Option K → I → ℝ) + (hD : Integrable (fun x => D (coefficientFiberMap U t + (coefficientEvaluationTorus U t (affineSampleCoefficientTorus U p hm b)) x)) μ) : + ‖affineCubeFourierProjection U t difference frequency p c b - + ((coefficientFiberAverage U μ t D + (coefficientEvaluationTorus U t (affineSampleCoefficientTorus U p hm b)) : ℝ) : ℂ)‖ ≤ η := by + rw [affineCubeFourierProjection_eq_fiberAverage U t difference frequency c μ p hp hm b] + have he := coefficientFiberAverage_approx U μ t (coefficientTorusFourierSum U frequency c) + (fun x => (D x : ℂ)) happrox _ + (coefficientTorusFourierSum_fiber_integrable U t frequency c μ _) hD.ofReal + simpa only [coefficientFiberAverage, integral_complex_ofReal] using he + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial + +theorem oneSiteDensity_projection_error {X I K F : Type*} [Fintype X] [Fintype K] [Fintype F] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (t : K → ℤ) (difference : Fin 0 → K → ℤ) + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (D : CoefficientTorus (K := K) U → ℝ) {η ε B : ℝ} (hη : 0 ≤ η) + (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - (D x : ℂ)‖ ≤ η) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (prob : FiniteProbabilityWeights X) (b : X → Option K → I → ℝ) (w : X → ℂ) + (hD : ∀ x, prob.weight x ≠ 0 → Integrable (fun z => D (coefficientFiberMap U t + (coefficientEvaluationTorus U t (affineSampleCoefficientTorus U p hm (b x))) z)) μ) + (hw : prob.mean (fun x => ‖w x‖) ≤ B) + (hprojection : ‖prob.complexMean (fun x => w x * affineCubeFourierSum frequency p c (b x)) - + prob.complexMean (fun x => w x * affineCubeFourierProjection U t difference frequency p c (b x))‖ ≤ ε) : + ‖prob.complexMean (fun x => w x * (D (affineSampleCoefficientTorus U p hm (b x)) : ℂ)) - + prob.complexMean (fun x => w x * ((coefficientFiberAverage U μ t D + (coefficientEvaluationTorus U t (affineSampleCoefficientTorus U p hm (b x))) : ℝ) : ℂ))‖ ≤ + 2 * B * η + ε := by + apply prob.weighted_projection_comparison w _ + (fun x => affineCubeFourierSum frequency p c (b x)) + (fun x => affineCubeFourierProjection U t difference frequency p c (b x)) _ hη hw + · intro x _ + rw [norm_sub_rev] + simpa only [affineCubeFourierSum, coefficientTorusFourierSum, + coefficientTorusCharacter_sample U _ p hp hm] using happrox (affineSampleCoefficientTorus U p hm (b x)) + · intro x hx + exact affineCubeFourierProjection_approx U t difference frequency c μ D happrox p hp hm (b x) (hD x hx) + · exact hprojection + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open MeasureTheory VectorPolynomial +open scoped BigOperators + +theorem affineCubeFourierProjection_product_cap {I K F : Type*} [Fintype K] [Fintype F] {m : ℕ} + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + [CompactSpace (CoefficientTorus (K := K) U)] + [MeasurableSpace (CoefficientTorus (K := K) U)] [BorelSpace (CoefficientTorus (K := K) U)] + [∀ j, MeasurableSpace (SubspaceArrayTorus Unit (U j))] + [∀ j, BorelSpace (SubspaceArrayTorus Unit (U j))] + (μ : Measure (CoefficientTorus (K := K) U)) [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ s : CoefficientSlot K m, Measure (SubspaceArrayTorus Unit (U s.1))) + [∀ s, (ν s).IsAddLeftInvariant] [∀ s, IsProbabilityMeasure (ν s)] + (f : ∀ s : CoefficientSlot K m, SubspaceArrayTorus Unit (U s.1) → ℝ) + (hf : ∀ s, Measurable (f s)) (hfi : ∀ s, Integrable (f s) (ν s)) + (hf0 : ∀ s x, 0 ≤ f s x) (hmass : ∀ s, (∫ x, f s x ∂ν s) = 1) + (C : Fin m → ℝ) + (hC : ∀ (s : CoefficientSlot K m), s.2.val = 0 → ∀ x, f s x ≤ C s.1) + (frequency : F → ∀ j, (K →₀ ℕ) → J j → ℤ) (c : F → ℂ) {η : ℝ} + (happrox : ∀ x, ‖coefficientTorusFourierSum U frequency c x - + (coefficientProductDensity U f x : ℂ)‖ ≤ η) + (t : K → ℤ) (difference : Fin 0 → K → ℤ) + (p : ∀ j, VectorPolynomial I ℝ (J j → ℝ)) + (hp : ∀ j, DegreeLE (1 : I → ℕ) (j.val + 1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) (b : Option K → I → ℝ) : + ‖affineCubeFourierProjection U t difference frequency p c b‖ ≤ (∏ j, C j) + η := by + let y := coefficientEvaluationTorus U t (affineSampleCoefficientTorus U p hm b) + let D := coefficientProductDensity U f + let A := affineCubeFourierProjection U t difference frequency p c b + let d := coefficientFiberAverage U μ t D y + have hd := coefficientProductDensity_fiberAverage_cap U μ ν f hf hfi hf0 hmass C hC t y + have he : ‖A - (d : ℂ)‖ ≤ η := + affineCubeFourierProjection_approx U t difference frequency c μ D happrox p hp hm b hd.1 + have hdn : ‖(d : ℂ)‖ ≤ ∏ j, C j := by + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg hd.2.1] + exact hd.2.2 + change ‖A‖ ≤ _ + calc + ‖A‖ = ‖(A - (d : ℂ)) + (d : ℂ)‖ := by rw [sub_add_cancel] + _ ≤ ‖A - (d : ℂ)‖ + ‖(d : ℂ)‖ := norm_add_le _ _ + _ ≤ η + ∏ j, C j := add_le_add he hdn + _ = _ := add_comm _ _ + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProgressionKernelBound.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProgressionKernelBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..fde52037a8c5c2e76fbd34d2f028457d5dc54691 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProgressionKernelBound.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.Progressions.Estimates.DyadicCountingParameters + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_progression_kernel_bound (s : ℕ) {tau : ℝ} (htau : 0 < tau) : + ∃ C : ℕ, 2 ≤ C ∧ ∃ xi0 : ℝ, 0 < xi0 ∧ + ∀ {N : ℕ} [NeZero N] {p xi : ℝ}, 2 ≤ p → 0 < xi → xi ≤ xi0 → + Odd N → Real.exp ((p + 2) ^ C) ≤ N → + ∀ {I : Type} [DecidableEq I] (slopes : I → ZMod N) (mu : I → ZMod N → ℝ) + (a b : ZMod N) (parameter : ℝ) (f g : ZMod N → ℝ), + 0 ≤ parameter → parameter ≤ 1 → + (∀ i x, 0 ≤ mu i x ∧ mu i x ≤ Real.exp p) → + (∀ i, CyclicNiltestUpperComparison.{0} s N ((p + 2) ^ C) + (Real.exp (-((p + 2) ^ C))) (mu i) (fun _ => 1 + xi)) → + (∀ x, 0 ≤ f x ∧ f x ≤ Real.exp p) → + CyclicNiltestUpperComparison.{0} s N ((p + 2) ^ C) + (Real.exp (-((p + 2) ^ C))) f (fun _ => 1 + xi) → + (∀ x, 0 ≤ g x ∧ g x ≤ Real.exp p) → + CyclicNiltestUpperComparison.{0} s N ((p + 2) ^ C) + (Real.exp (-((p + 2) ^ C))) g (fun _ => 1 + xi) → + ∀ S : Finset I, S.card ≤ s → IsUnit (b - a) → + (∀ i ∈ S, IsUnit (a - slopes i) ∧ IsUnit (b - slopes i)) → + (∀ i ∈ S, ∀ j ∈ S, i ≠ j → IsUnit (slopes i - slopes j)) → + |𝔼 x, 𝔼 d, (∏ i ∈ S, mu i (x + slopes i * d)) * + countingKernel parameter (f (x + a * d)) (g (x + b * d))| < 1 + tau := by + obtain ⟨delta, hdelta, C0, hC0, hparameters⟩ := exists_counting_kernel_parameters s htau + obtain ⟨C, hC, xi0, hxi0, hstage⟩ := exists_pivot_stage_bound s hdelta hC0 + refine ⟨C, hC, xi0, hxi0, ?_⟩ + intro N _ p xi hp hxi hxib hodd hN I _ slopes mu a b parameter f g + hparameter hparameter1 hmu hcompare hf hfcompare hg hgcompare S hS hab hends hpairs + obtain ⟨n, hqcap, hsmall⟩ := hparameters p hp + let v : Fin 0 → ZMod N := Fin.elim0 + have hc := pivotCompatible_zero v S slopes a b hab hends hpairs + have h := hstage hp hxi hxib hodd hN n hqcap slopes mu a b parameter f g + hparameter hparameter1 hmu hcompare hf hfcompare hg hgcompare v S + (by simpa only [zero_add] using hS) hc + rw [pivotStageCount_zero] at h + simpa only [pow_zero] using h.trans_lt (hsmall S.card hS) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProjectedBasisSpan.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProjectedBasisSpan.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5c87268c9db4e3303fc38d23f0a35e3276e0666 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProjectedBasisSpan.lean @@ -0,0 +1,78 @@ +import OAI.Combinatorics.Progressions.Geometry.MinkowskiSecondBoxGlue + +namespace OAI + +section + +namespace Erdos3.BohrLattice.MinkowskiSecondBox + +open Module Submodule +open scoped BigOperators + +theorem mem_first_span_of_projection_zero {n : ℕ} + (b : Basis (Fin (n + 1)) ℝ (Fin (n + 1) → ℝ)) + (q : Basis (Fin n) ℝ (Fin n → ℝ)) + (π : (Fin (n + 1) → ℝ) →ₗ[ℝ] (Fin n → ℝ)) + (hzero : π (b 0) = 0) (htail : ∀ j, π (b j.succ) = q j) + {x : Fin (n + 1) → ℝ} (hx : x ∈ span ℤ (Set.range b)) (hπx : π x = 0) : + x ∈ span ℤ ({b 0} : Set (Fin (n + 1) → ℝ)) := by + classical + rw [mem_span_range_iff_exists_fun] at hx + obtain ⟨c, rfl⟩ := hx + have hp : ∑ j : Fin n, c j.succ • q j = 0 := by + rw [map_sum, Fin.sum_univ_succ] at hπx + simpa only [map_zsmul, hzero, htail, smul_zero, zero_add] using hπx + have hc : ∀ j : Fin n, c j.succ = 0 := + Fintype.linearIndependent_iff.mp (q.linearIndependent.restrict_scalars' ℤ) _ hp + rw [Fin.sum_univ_succ] + simp only [hc, zero_smul, Finset.sum_const_zero, add_zero] + exact smul_mem _ _ (subset_span (Set.mem_singleton _)) + +theorem span_fin_cons_of_projected_span {n : ℕ} + (b : Basis (Fin (n + 1)) ℝ (Fin (n + 1) → ℝ)) + (q : Basis (Fin n) ℝ (Fin n → ℝ)) + (π : (Fin (n + 1) → ℝ) →ₗ[ℝ] (Fin n → ℝ)) + (hzero : π (b 0) = 0) (htail : ∀ j, π (b j.succ) = q j) + (w : Fin n → Fin (n + 1) → ℝ) + (hw : ∀ j, w j ∈ span ℤ (Set.range b)) + (hspan : span ℤ (Set.range (fun j => π (w j))) = span ℤ (Set.range q)) : + span ℤ (Set.range (Fin.cons (b 0) w)) = span ℤ (Set.range b) := by + classical + let L := span ℤ (Set.range b) + let S := span ℤ (Set.range (Fin.cons (b 0) w)) + have hfirst : b 0 ∈ S := subset_span ⟨0, rfl⟩ + have hwm : ∀ j, w j ∈ S := fun j => subset_span ⟨j.succ, rfl⟩ + have hsmall : span ℤ ({b 0} : Set (Fin (n + 1) → ℝ)) ≤ S := by + exact span_le.mpr (fun x hx => (Set.mem_singleton_iff.mp hx) ▸ hfirst) + apply le_antisymm + · apply span_le.mpr + rintro _ ⟨i, rfl⟩ + exact Fin.cases (subset_span (Set.mem_range_self 0)) hw i + · apply span_le.mpr + rintro _ ⟨i, rfl⟩ + refine Fin.cases hfirst (fun k => ?_) i + change b k.succ ∈ S + have hk : q k ∈ span ℤ (Set.range (fun j => π (w j))) := by + rw [hspan] + exact subset_span (Set.mem_range_self k) + rw [mem_span_range_iff_exists_fun] at hk + obtain ⟨c, hc⟩ := hk + let y := ∑ j, c j • w j + have hyL : y ∈ L := sum_mem (fun j _ => smul_mem _ _ (hw j)) + have hyS : y ∈ S := sum_mem (fun j _ => smul_mem _ _ (hwm j)) + have hdiff : b k.succ - y ∈ L := + sub_mem (subset_span (Set.mem_range_self k.succ)) hyL + have hπdiff : π (b k.succ - y) = 0 := by + rw [map_sub, htail] + change q k - π (∑ j, c j • w j) = 0 + rw [map_sum] + simp only [map_zsmul, hc, sub_self] + have hm := mem_first_span_of_projection_zero b q π hzero htail hdiff hπdiff + have hadd := S.add_mem (hsmall hm) hyS + simpa only [sub_add_cancel] using hadd + +end Erdos3.BohrLattice.MinkowskiSecondBox + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ProperCyclicKernelBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/ProperCyclicKernelBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a3fde38876d9ede743f369f8433e329a7fc52fa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ProperCyclicKernelBasis.lean @@ -0,0 +1,1200 @@ +import Mathlib.Algebra.Order.Round +import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas +import Mathlib.LinearAlgebra.Matrix.Block +import Mathlib.LinearAlgebra.Matrix.ToLinearEquiv +import Mathlib.Order.Interval.Finset.Fin +import OAI.Combinatorics.Progressions.Estimates.SaturatedFlag +import OAI.Combinatorics.Progressions.Fourier.CyclicTorusCoordinates +import OAI.Combinatorics.Progressions.Lattices.NaturalScaleIntegerWindow +import OAI.Combinatorics.Progressions.Linear.MahlerBasis + +namespace OAI + +section + +namespace Erdos3.IntegerBasisReduction.Mahler + +open scoped BigOperators +open Module + +def IsSeminormOrdered {n : ℕ} (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) : Prop := + ∀ {i j : Fin n}, i ≤ j → + p (integralEmbed (x i)) ≤ p (integralEmbed (x j)) + +noncomputable def basisReductionStandardPoint {n : ℕ} (i : Fin n) : + IntegralPoint n := + (Pi.basisFun ℤ (Fin n)) i + +@[simp] +theorem integralEmbed_basisReductionStandardPoint {n : ℕ} (i : Fin n) : + integralEmbed (basisReductionStandardPoint i) = + (Pi.basisFun ℝ (Fin n)) i := by + ext j + by_cases hij : i = j + · subst j + simp [basisReductionStandardPoint, integralEmbed] + · simp [basisReductionStandardPoint, integralEmbed, hij] + +theorem linearIndependent_basisReductionStandardPoint {n : ℕ} : + LinearIndependent ℝ + (fun i : Fin n ↦ integralEmbed (basisReductionStandardPoint i)) := by + simpa only [integralEmbed_basisReductionStandardPoint] using + (Pi.basisFun ℝ (Fin n)).linearIndependent + +theorem AdmitsIndependent.antitone_rank_basisReduction {n k l : ℕ} + {p : Seminorm ℝ (Fin n → ℝ)} {r : ℝ} (hkl : k ≤ l) + (h : AdmitsIndependent p l r) : AdmitsIndependent p k r := by + obtain ⟨v, hv, hp⟩ := h + let e : Fin k → Fin l := Fin.castLE hkl + exact ⟨fun i ↦ v (e i), hv.comp e (Fin.castLE_injective hkl), fun i ↦ hp (e i)⟩ + +theorem successiveMinimum_set_nonempty_basisReduction {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) (i : Fin n) : + {r : ℝ | AdmitsIndependent p (i.val + 1) r}.Nonempty := by + let R : ℝ := + ∑ j : Fin n, p (integralEmbed (basisReductionStandardPoint j)) + have hfull : AdmitsIndependent p n R := by + refine ⟨basisReductionStandardPoint, + linearIndependent_basisReductionStandardPoint, ?_⟩ + intro j + exact Finset.single_le_sum + (fun k _ ↦ apply_nonneg p + (integralEmbed (basisReductionStandardPoint k))) + (Finset.mem_univ j) + exact ⟨R, AdmitsIndependent.antitone_rank_basisReduction (by omega) hfull⟩ + +theorem successiveMinimum_mono_basisReduction {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) {i j : Fin n} (hij : i ≤ j) : + successiveMinimum p i ≤ successiveMinimum p j := by + rw [successiveMinimum, successiveMinimum] + refine le_csInf (successiveMinimum_set_nonempty_basisReduction p j) ?_ + intro r hr + exact csInf_le + ⟨0, fun R hR ↦ hR.nonneg (Nat.succ_pos i.val)⟩ + (AdmitsIndependent.antitone_rank_basisReduction + (Nat.succ_le_succ hij) hr) + +def IsCenteredReduction {n : ℕ} + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) : Prop := + ∀ i, + integralEmbed (b i) = ∑ j, a i j • integralEmbed (x j) ∧ + (∀ j, i < j → a i j = 0) ∧ + ((|a i i| = 1 ∧ ∀ j, j < i → a i j = 0) ∨ + ∀ j, j ≤ i → |a i j| ≤ (1 : ℝ) / 2) + +def IsRawFlagReduction {n : ℕ} + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (u : Fin n → Fin n → ℝ) : Prop := + (∀ i, integralEmbed (b i) = ∑ j, u i j • integralEmbed (x j)) ∧ + (∀ i j, i < j → u i j = 0) ∧ + (∀ i j, i < j → b.repr (x i) j = 0) ∧ + ∀ i, b.repr (x i) i ≠ 0 ∧ + ((b.repr (x i) i : ℝ) * u i i = 1) + +theorem exists_rawFlagReduction_of_linearIndependent {n : ℕ} + (x : Fin n → IntegralPoint n) + (hli : LinearIndependent ℝ (fun i ↦ integralEmbed (x i))) : + ∃ (b : Basis (Fin n) ℤ (IntegralPoint n)) + (u : Fin n → Fin n → ℝ), IsRawFlagReduction x b u := by + classical + have hrealEmbed (z : IntegralPoint n) : + SaturatedFlag.realEmbed n z = integralEmbed z := by + ext j + rfl + have hli' : LinearIndependent ℝ + (fun i ↦ SaturatedFlag.realEmbed n (x i)) := by + simpa only [hrealEmbed] using hli + obtain ⟨b, hprefix, hxrepr, hxdiag⟩ := + SaturatedFlag.exists_prefix_adapted_basis_realPrefixLattice x hli' + let xb : Basis (Fin n) ℝ (Fin n → ℝ) := + basisOfLinearIndependentOfCardEqFinrank' + (fun i ↦ integralEmbed (x i)) hli (by simp) + let u : Fin n → Fin n → ℝ := + fun i j ↦ xb.repr (integralEmbed (b i)) j + have hxb (i : Fin n) : xb i = integralEmbed (x i) := by + simp [xb] + have hexpand (i : Fin n) : + integralEmbed (b i) = ∑ j, u i j • integralEmbed (x j) := by + simpa only [hxb] using (xb.sum_repr (integralEmbed (b i))).symm + have htri : ∀ i j, i < j → u i j = 0 := by + intro i j hij + have hbi : b i ∈ SaturatedFlag.realPrefixLattice x i := by + rw [hprefix i] + apply Submodule.subset_span + exact ⟨i, Set.mem_Iic.mpr le_rfl, rfl⟩ + have hbispan : integralEmbed (b i) ∈ + Submodule.span ℝ (xb '' Set.Iic i) := by + have hm := SaturatedFlag.mem_realPrefixLattice.mp hbi + have himage : SaturatedFlag.realEmbed n '' (x '' Set.Iic i) = + xb '' Set.Iic i := by + ext y + constructor + · rintro ⟨_, ⟨k, hk, rfl⟩, rfl⟩ + exact ⟨k, hk, (hxb k).trans (hrealEmbed (x k)).symm⟩ + · rintro ⟨k, hk, rfl⟩ + exact ⟨x k, ⟨k, hk, rfl⟩, + (hrealEmbed (x k)).trans (hxb k).symm⟩ + rw [himage] at hm + rw [hrealEmbed] at hm + exact hm + have hsupp := xb.repr_support_subset_of_mem_span (Set.Iic i) hbispan + by_contra hne + have hjmem : j ∈ Set.Iic i := + hsupp (Finsupp.mem_support_iff.mpr hne) + exact (not_le_of_gt hij) (Set.mem_Iic.mp hjmem) + refine ⟨b, u, hexpand, htri, hxrepr, ?_⟩ + intro i + have hxreal : + ∑ j, (b.repr (x i) j : ℝ) • integralEmbed (b j) = + integralEmbed (x i) := by + calc + (∑ j, (b.repr (x i) j : ℝ) • integralEmbed (b j)) = + integralEmbed (∑ j, b.repr (x i) j • b j) := by + ext k + simp [integralEmbed] + _ = integralEmbed (x i) := congrArg integralEmbed (b.sum_repr (x i)) + have hcoord := congrArg (fun y : Fin n → ℝ ↦ xb.repr y i) hxreal + have hrhs : xb.repr (integralEmbed (x i)) i = 1 := by + rw [← hxb] + simp + rw [hrhs] at hcoord + have hcoord' : + ∑ j, (b.repr (x i) j : ℝ) * u j i = 1 := by + simpa [u, hxb] using hcoord + have hsingle : + (∑ j, (b.repr (x i) j : ℝ) * u j i) = + (b.repr (x i) i : ℝ) * u i i := by + apply Finset.sum_eq_single i + · intro j _hj hji + rcases lt_or_gt_of_ne hji with hji | hij + · rw [htri j i hji] + simp + · rw [hxrepr i j hij] + simp + · simp + have hrecip : (b.repr (x i) i : ℝ) * u i i = 1 := by + rw [← hsingle] + exact hcoord' + exact ⟨hxdiag i, hrecip⟩ + +theorem rawFlagReduction_diag_abs_le_one {n : ℕ} + {x : Fin n → IntegralPoint n} + {b : Basis (Fin n) ℤ (IntegralPoint n)} + {u : Fin n → Fin n → ℝ} + (hraw : IsRawFlagReduction x b u) (i : Fin n) : + |u i i| ≤ 1 := by + have hcne := (hraw.2.2.2 i).1 + have hrecip := (hraw.2.2.2 i).2 + have hcabsZ : (1 : ℤ) ≤ |b.repr (x i) i| := by + have hpos : (0 : ℤ) < |b.repr (x i) i| := abs_pos.mpr hcne + omega + have hcabs : (1 : ℝ) ≤ |(b.repr (x i) i : ℝ)| := by + exact_mod_cast hcabsZ + have habsprod : |(b.repr (x i) i : ℝ)| * |u i i| = 1 := by + rw [← abs_mul, hrecip, abs_one] + nlinarith [abs_nonneg (u i i)] + +theorem rawFlagReduction_diag_abs_le_half_of_not_unit {n : ℕ} + {x : Fin n → IntegralPoint n} + {b : Basis (Fin n) ℤ (IntegralPoint n)} + {u : Fin n → Fin n → ℝ} + (hraw : IsRawFlagReduction x b u) (i : Fin n) + (hnot : |b.repr (x i) i| ≠ 1) : + |u i i| ≤ (1 : ℝ) / 2 := by + have hcne := (hraw.2.2.2 i).1 + have hrecip := (hraw.2.2.2 i).2 + have hcabsZ : (2 : ℤ) ≤ |b.repr (x i) i| := by + have hpos : (0 : ℤ) < |b.repr (x i) i| := abs_pos.mpr hcne + omega + have hcabs : (2 : ℝ) ≤ |(b.repr (x i) i : ℝ)| := by + exact_mod_cast hcabsZ + have habsprod : |(b.repr (x i) i : ℝ)| * |u i i| = 1 := by + rw [← abs_mul, hrecip, abs_one] + nlinarith [abs_nonneg (u i i)] + +def prefixIndex {n : ℕ} (i : Fin n) (j : Fin i.val) : Fin n := + ⟨j.val, lt_trans j.isLt i.isLt⟩ + +@[simp] theorem prefixIndex_val {n : ℕ} (i : Fin n) (j : Fin i.val) : + (prefixIndex i j).val = j.val := rfl + +theorem prefixIndex_injective {n : ℕ} (i : Fin n) : + Function.Injective (prefixIndex i) := by + intro j k h + apply Fin.ext + simpa only [prefixIndex_val] using congrArg Fin.val h + +theorem prefixIndex_lt {n : ℕ} (i : Fin n) (j : Fin i.val) : + prefixIndex i j < i := j.isLt + +noncomputable def centeredStep {n : ℕ} (r u : Fin n → ℝ) (j : Fin n) : + Fin n → ℝ := + fun h ↦ r h - (round (r j / u j) : ℝ) * u h + +theorem abs_centeredStep_apply_self_le {n : ℕ} + (r u : Fin n → ℝ) (j : Fin n) + (hdiag_ne : u j ≠ 0) (hdiag_le : |u j| ≤ 1) : + |centeredStep r u j j| ≤ (1 : ℝ) / 2 := by + have heq : centeredStep r u j j = + u j * (r j / u j - (round (r j / u j) : ℝ)) := by + rw [centeredStep] + field_simp + rw [heq, abs_mul] + calc + |u j| * |r j / u j - (round (r j / u j) : ℝ)| ≤ + 1 * ((1 : ℝ) / 2) := + mul_le_mul hdiag_le (abs_sub_round (r j / u j)) + (abs_nonneg _) (by positivity) + _ = (1 : ℝ) / 2 := one_mul _ + +theorem centeredStep_apply_of_eq_zero {n : ℕ} + (r u : Fin n → ℝ) (j h : Fin n) (hzero : u h = 0) : + centeredStep r u j h = r h := by + simp [centeredStep, hzero] + +theorem exists_integerCombination_abs_le_half : ∀ {n : ℕ} + (u : Fin n → Fin n → ℝ), + (∀ j h, j < h → u j h = 0) → + (∀ j, u j j ≠ 0) → + (∀ j, |u j j| ≤ (1 : ℝ)) → + ∀ r : Fin n → ℝ, + ∃ t : Fin n → ℤ, + ∀ h, |r h + ∑ j, (t j : ℝ) * u j h| ≤ (1 : ℝ) / 2 := by + intro n + induction n with + | zero => + intro u _htri _hne _hle r + refine ⟨fun i ↦ Fin.elim0 i, ?_⟩ + intro h + exact Fin.elim0 h + | succ n ih => + intro u htri hne hle r + let last : Fin (n + 1) := Fin.last n + let q : ℤ := -round (r last / u last last) + let rHead : Fin n → ℝ := fun h ↦ + r h.castSucc + (q : ℝ) * u last h.castSucc + let uHead : Fin n → Fin n → ℝ := fun j h ↦ + u j.castSucc h.castSucc + have htriHead : ∀ j h, j < h → uHead j h = 0 := by + intro j h hjh + exact htri j.castSucc h.castSucc (Fin.castSucc_lt_castSucc_iff.mpr hjh) + have hneHead : ∀ j, uHead j j ≠ 0 := fun j ↦ hne j.castSucc + have hleHead : ∀ j, |uHead j j| ≤ (1 : ℝ) := fun j ↦ hle j.castSucc + obtain ⟨tHead, htHead⟩ := ih uHead htriHead hneHead hleHead rHead + let t : Fin (n + 1) → ℤ := Fin.lastCases q tHead + refine ⟨t, ?_⟩ + intro h + refine Fin.lastCases ?_ (fun h ↦ ?_) h + · have hzero : + ∑ j : Fin n, (t j.castSucc : ℝ) * u j.castSucc last = 0 := by + apply Finset.sum_eq_zero + intro j _hj + rw [htri j.castSucc last (Fin.castSucc_lt_last j)] + simp + rw [Fin.sum_univ_castSucc, hzero, zero_add] + have hstep := abs_centeredStep_apply_self_le + r (u last) last (hne last) (hle last) + simpa [t, q, last, centeredStep, sub_eq_add_neg] using hstep + · have hh := htHead h + simpa [Fin.sum_univ_castSucc, t, rHead, uHead, q, + add_assoc, add_comm, add_left_comm] using hh + +theorem exists_prefix_integerCombination_abs_le_half {n : ℕ} + (u : Fin n → Fin n → ℝ) + (htri : ∀ j h, j < h → u j h = 0) + (hne : ∀ j, u j j ≠ 0) + (hle : ∀ j, |u j j| ≤ (1 : ℝ)) + (r : Fin n → ℝ) (i : Fin n) : + ∃ t : Fin i.val → ℤ, ∀ h : Fin i.val, + |r (prefixIndex i h) + + ∑ j, (t j : ℝ) * u (prefixIndex i j) (prefixIndex i h)| ≤ + (1 : ℝ) / 2 := by + let up : Fin i.val → Fin i.val → ℝ := + fun j h ↦ u (prefixIndex i j) (prefixIndex i h) + have htrip : ∀ j h, j < h → up j h = 0 := by + intro j h hjh + exact htri (prefixIndex i j) (prefixIndex i h) hjh + have hnep : ∀ j, up j j ≠ 0 := fun j ↦ hne (prefixIndex i j) + have hlep : ∀ j, |up j j| ≤ (1 : ℝ) := fun j ↦ hle (prefixIndex i j) + simpa [up] using exists_integerCombination_abs_le_half up htrip hnep hlep + (fun h ↦ r (prefixIndex i h)) + +def shearMatrix {n : ℕ} (t : Fin n → Fin n → ℤ) : + Matrix (Fin n) (Fin n) ℤ := + fun j i ↦ if j = i then 1 else if j < i then t i j else 0 + +theorem shearMatrix_isUpperTriangular {n : ℕ} + (t : Fin n → Fin n → ℤ) : + (shearMatrix t).IsUpperTriangular := by + intro i j hji + change j < i at hji + change shearMatrix t i j = 0 + simp [shearMatrix, hji.ne', hji.asymm] + +@[simp] +theorem shearMatrix_apply_self {n : ℕ} + (t : Fin n → Fin n → ℤ) (i : Fin n) : + shearMatrix t i i = 1 := by + simp [shearMatrix] + +@[simp] +theorem shearMatrix_det {n : ℕ} + (t : Fin n → Fin n → ℤ) : + (shearMatrix t).det = 1 := by + rw [Matrix.det_of_isUpperTriangular (shearMatrix_isUpperTriangular t)] + simp + +theorem shearMatrix_isUnit_det {n : ℕ} + (t : Fin n → Fin n → ℤ) : + IsUnit (shearMatrix t).det := by + rw [shearMatrix_det] + exact isUnit_one + +noncomputable def shearBasis {n : ℕ} {M : Type*} + [AddCommGroup M] + (b : Basis (Fin n) ℤ M) (t : Fin n → Fin n → ℤ) : + Basis (Fin n) ℤ M := + b.map ((shearMatrix t).toLinearEquiv b (shearMatrix_isUnit_det t)) + +theorem shearBasis_apply {n : ℕ} {M : Type*} + [AddCommGroup M] + (b : Basis (Fin n) ℤ M) (t : Fin n → Fin n → ℤ) (i : Fin n) : + shearBasis b t i = ∑ j, shearMatrix t j i • b j := by + simp [shearBasis, Matrix.toLinearEquiv_apply, Matrix.toLin_self] + +theorem shearBasis_apply_eq_add_Iio {n : ℕ} {M : Type*} + [AddCommGroup M] + (b : Basis (Fin n) ℤ M) (t : Fin n → Fin n → ℤ) (i : Fin n) : + shearBasis b t i = b i + ∑ j ∈ Finset.Iio i, t i j • b j := by + classical + rw [shearBasis_apply] + let f : Fin n → M := fun j ↦ shearMatrix t j i • b j + have hsum : (∑ j, f j) = ∑ j ∈ insert i (Finset.Iio i), f j := by + symm + apply Finset.sum_subset (by intro j hj; simp) + intro j _hj hjnot + have hne : j ≠ i := by + intro h + subst j + exact hjnot (by simp) + have hnotlt : ¬j < i := by + intro h + exact hjnot (Finset.mem_insert.mpr <| + Or.inr (Finset.mem_Iio.mpr h)) + simp [f, shearMatrix, hne, hnotlt] + calc + (∑ j, shearMatrix t j i • b j) = ∑ j ∈ insert i (Finset.Iio i), f j := hsum + _ = shearMatrix t i i • b i + + ∑ j ∈ Finset.Iio i, shearMatrix t j i • b j := by + rw [Finset.sum_insert (by simp)] + _ = b i + ∑ j ∈ Finset.Iio i, t i j • b j := by + apply congrArg₂ (·+·) + · simp + · apply Finset.sum_congr rfl + intro j hj + have hji : j < i := Finset.mem_Iio.mp hj + simp [shearMatrix, hji, hji.ne] + +noncomputable def basisOfUpperTriangularUnits {n : ℕ} {M : Type*} + [AddCommGroup M] (b : Basis (Fin n) ℤ M) + (A : Matrix (Fin n) (Fin n) ℤ) + (hupper : A.IsUpperTriangular) (hdiag : ∀ i, IsUnit (A i i)) : + Basis (Fin n) ℤ M := by + have hdet : IsUnit A.det := by + rw [Matrix.det_of_isUpperTriangular hupper] + exact IsUnit.prod_univ_iff.mpr hdiag + exact b.map (A.toLinearEquiv b hdet) + +theorem basisOfUpperTriangularUnits_apply {n : ℕ} {M : Type*} + [AddCommGroup M] (b : Basis (Fin n) ℤ M) + (A : Matrix (Fin n) (Fin n) ℤ) + (hupper : A.IsUpperTriangular) (hdiag : ∀ i, IsUnit (A i i)) + (i : Fin n) : + basisOfUpperTriangularUnits b A hupper hdiag i = ∑ j, A j i • b j := by + simp [basisOfUpperTriangularUnits, Matrix.toLinearEquiv_apply, + Matrix.toLin_self] + +def extendPrefix {n : ℕ} (i : Fin n) (t : Fin i.val → ℤ) : Fin n → ℤ := + fun j ↦ if h : j < i then t ⟨j.val, h⟩ else 0 + +@[simp] +theorem extendPrefix_prefixIndex {n : ℕ} (i : Fin n) + (t : Fin i.val → ℤ) (j : Fin i.val) : + extendPrefix i t (prefixIndex i j) = t j := by + simp [extendPrefix, prefixIndex_lt] + +theorem extendPrefix_eq_zero_of_not_lt {n : ℕ} (i j : Fin n) + (t : Fin i.val → ℤ) (h : ¬j < i) : + extendPrefix i t j = 0 := by + simp [extendPrefix, h] + +def prefixIndexEquivIio {n : ℕ} (i : Fin n) : + Fin i.val ≃ {j : Fin n // j ∈ Finset.Iio i} where + toFun j := ⟨prefixIndex i j, Finset.mem_Iio.mpr (prefixIndex_lt i j)⟩ + invFun j := + { val := j.1.val + isLt := by + have hji : j.1 < i := Finset.mem_Iio.mp j.2 + exact hji } + left_inv j := by ext; rfl + right_inv j := by ext; rfl + +theorem sum_extendPrefix_mul {n : ℕ} (i : Fin n) (t : Fin i.val → ℤ) + (f : Fin n → ℝ) : + (∑ j, (extendPrefix i t j : ℝ) * f j) = + ∑ j : Fin i.val, (t j : ℝ) * f (prefixIndex i j) := by + classical + calc + (∑ j, (extendPrefix i t j : ℝ) * f j) = + ∑ j ∈ Finset.Iio i, (extendPrefix i t j : ℝ) * f j := by + symm + apply Finset.sum_subset (by intro j hj; simp) + intro j _hj hjnot + have hnlt : ¬j < i := by simpa using hjnot + simp [extendPrefix, hnlt] + _ = ∑ j : {j : Fin n // j ∈ Finset.Iio i}, + (extendPrefix i t j : ℝ) * f j := by + rw [← Finset.sum_attach] + simp + _ = ∑ j : Fin i.val, (t j : ℝ) * f (prefixIndex i j) := by + symm + refine Fintype.sum_equiv (prefixIndexEquivIio i) _ _ ?_ + intro j + simp [prefixIndexEquivIio] + +noncomputable def centeredReductionMatrix {n : ℕ} + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (t : (i : Fin n) → Fin i.val → ℤ) : Matrix (Fin n) (Fin n) ℤ := + fun j i ↦ + if |b.repr (x i) i| = 1 then + b.repr (x i) i * b.repr (x i) j + else if j = i then 1 else extendPrefix i (t i) j + +theorem centeredReductionMatrix_isUpperTriangular {n : ℕ} + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (t : (i : Fin n) → Fin i.val → ℤ) + (hupper : ∀ i j, i < j → b.repr (x i) j = 0) : + (centeredReductionMatrix x b t).IsUpperTriangular := by + intro i j hji + change j < i at hji + change centeredReductionMatrix x b t i j = 0 + by_cases hunit : |b.repr (x j) j| = 1 + · simp [centeredReductionMatrix, hunit, hupper j i hji] + · have hne : i ≠ j := hji.ne' + have hnlt : ¬i < j := hji.asymm + simp [centeredReductionMatrix, hunit, hne, extendPrefix, hnlt] + +@[simp] +theorem centeredReductionMatrix_apply_self {n : ℕ} + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (t : (i : Fin n) → Fin i.val → ℤ) (i : Fin n) : + centeredReductionMatrix x b t i i = 1 := by + by_cases hunit : |b.repr (x i) i| = 1 + · have hsquare : b.repr (x i) i * b.repr (x i) i = 1 := by + by_cases hnonneg : 0 ≤ b.repr (x i) i + · rw [abs_of_nonneg hnonneg] at hunit + simp [hunit] + · have hnonpos : b.repr (x i) i ≤ 0 := le_of_not_ge hnonneg + rw [abs_of_nonpos hnonpos] at hunit + have hminus : b.repr (x i) i = -1 := by omega + simp [hminus] + simp [centeredReductionMatrix, hunit, hsquare] + · simp [centeredReductionMatrix, hunit] + +theorem centeredReductionMatrix_isUnit_diagonal {n : ℕ} + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (t : (i : Fin n) → Fin i.val → ℤ) : + ∀ i, IsUnit (centeredReductionMatrix x b t i i) := by + intro i + rw [centeredReductionMatrix_apply_self] + exact isUnit_one + +theorem exists_centeredReduction_of_rawFlagReduction {n : ℕ} + (x : Fin n → IntegralPoint n) + (hli : LinearIndependent ℝ (fun i ↦ integralEmbed (x i))) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (u : Fin n → Fin n → ℝ) + (hraw : IsRawFlagReduction x b u) : + ∃ (e : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ), IsCenteredReduction x e a := by + classical + have hudiag_ne : ∀ i, u i i ≠ 0 := by + intro i hui + have hrecip := (hraw.2.2.2 i).2 + rw [hui] at hrecip + norm_num at hrecip + have hudiag_le : ∀ i, |u i i| ≤ (1 : ℝ) := + fun i ↦ rawFlagReduction_diag_abs_le_one hraw i + have hround : ∀ i, ∃ t : Fin i.val → ℤ, ∀ h : Fin i.val, + |u i (prefixIndex i h) + + ∑ j, (t j : ℝ) * u (prefixIndex i j) (prefixIndex i h)| ≤ + (1 : ℝ) / 2 := by + intro i + exact exists_prefix_integerCombination_abs_le_half u hraw.2.1 + hudiag_ne hudiag_le (u i) i + choose t ht using hround + let A : Matrix (Fin n) (Fin n) ℤ := centeredReductionMatrix x b t + have hAupper : A.IsUpperTriangular := + centeredReductionMatrix_isUpperTriangular x b t hraw.2.2.1 + have hAdiag : ∀ i, IsUnit (A i i) := + centeredReductionMatrix_isUnit_diagonal x b t + let e : Basis (Fin n) ℤ (IntegralPoint n) := + basisOfUpperTriangularUnits b A hAupper hAdiag + let xb : Basis (Fin n) ℝ (Fin n → ℝ) := + basisOfLinearIndependentOfCardEqFinrank' + (fun i ↦ integralEmbed (x i)) hli (by simp) + have hxb (i : Fin n) : xb i = integralEmbed (x i) := by + simp [xb] + let a : Fin n → Fin n → ℝ := + fun i h ↦ xb.repr (integralEmbed (e i)) h + have hurepr (j h : Fin n) : + xb.repr (integralEmbed (b j)) h = u j h := by + rw [hraw.1 j] + simp_rw [← hxb] + simp [Finsupp.single_apply] + have he_apply (i : Fin n) : e i = ∑ j, A j i • b j := + basisOfUpperTriangularUnits_apply b A hAupper hAdiag i + have hembed (i : Fin n) : + integralEmbed (e i) = ∑ j, (A j i : ℝ) • integralEmbed (b j) := by + rw [he_apply] + ext k + simp [integralEmbed] + have haformula (i h : Fin n) : + a i h = ∑ j, (A j i : ℝ) * u j h := by + change xb.repr (integralEmbed (e i)) h = _ + rw [hembed] + simp [hurepr] + have hexpand (i : Fin n) : + integralEmbed (e i) = ∑ j, a i j • integralEmbed (x j) := by + simpa only [hxb] using (xb.sum_repr (integralEmbed (e i))).symm + refine ⟨e, a, ?_⟩ + intro i + refine ⟨hexpand i, ?_⟩ + by_cases hunit : |b.repr (x i) i| = 1 + · have heprim : e i = b.repr (x i) i • x i := by + rw [he_apply] + simp only [A, centeredReductionMatrix, hunit, ite_true] + simp_rw [mul_smul] + rw [← Finset.smul_sum, b.sum_repr] + have hembedprim : integralEmbed (e i) = + (b.repr (x i) i : ℝ) • xb i := by + rw [heprim] + ext k + simp [integralEmbed, hxb] + have haprim (h : Fin n) : a i h = + (b.repr (x i) i : ℝ) * (if i = h then 1 else 0) := by + change xb.repr (integralEmbed (e i)) h = _ + rw [hembedprim] + simp [Finsupp.single_apply] + have habove : ∀ j, i < j → a i j = 0 := by + intro j hij + rw [haprim] + simp [hij.ne] + refine ⟨habove, Or.inl ⟨?_, ?_⟩⟩ + · rw [haprim] + have hcabs : |(b.repr (x i) i : ℝ)| = 1 := by + exact_mod_cast hunit + simpa using hcabs + · intro j hji + rw [haprim] + simp [hji.ne'] + · have hainon (h : Fin n) : a i h = + u i h + ∑ j : Fin i.val, + (t i j : ℝ) * u (prefixIndex i j) h := by + rw [haformula] + calc + (∑ j, (A j i : ℝ) * u j h) = + ∑ j, ((if j = i then 1 else 0) + + (extendPrefix i (t i) j : ℤ) : ℤ) * u j h := by + apply Finset.sum_congr rfl + intro j _hj + by_cases hji : j = i + · subst j + simp [A, extendPrefix] + · simp [A, centeredReductionMatrix, hunit, hji] + _ = u i h + ∑ j, (extendPrefix i (t i) j : ℝ) * u j h := by + simp_rw [Int.cast_add, add_mul] + rw [Finset.sum_add_distrib] + simp + _ = u i h + ∑ j : Fin i.val, + (t i j : ℝ) * u (prefixIndex i j) h := by + rw [sum_extendPrefix_mul] + have habove : ∀ h, i < h → a i h = 0 := by + intro h hih + rw [hainon, hraw.2.1 i h hih] + have hsum : (∑ j : Fin i.val, + (t i j : ℝ) * u (prefixIndex i j) h) = 0 := by + apply Finset.sum_eq_zero + intro j _hj + rw [hraw.2.1 (prefixIndex i j) h + (lt_trans (prefixIndex_lt i j) hih)] + simp + rw [hsum, add_zero] + refine ⟨habove, Or.inr ?_⟩ + intro h hhi + rcases lt_or_eq_of_le hhi with hlt | heq + · let h' : Fin i.val := ⟨h.val, hlt⟩ + have hp : prefixIndex i h' = h := by + apply Fin.ext + rfl + rw [hainon] + simpa only [hp] using ht i h' + · subst h + rw [hainon] + have hsum : (∑ j : Fin i.val, + (t i j : ℝ) * u (prefixIndex i j) i) = 0 := by + apply Finset.sum_eq_zero + intro j _hj + rw [hraw.2.1 (prefixIndex i j) i (prefixIndex_lt i j)] + simp + rw [hsum, add_zero] + exact rawFlagReduction_diag_abs_le_half_of_not_unit hraw i hunit + +theorem exists_centeredReduction_of_linearIndependent {n : ℕ} + (x : Fin n → IntegralPoint n) + (hli : LinearIndependent ℝ (fun i ↦ integralEmbed (x i))) : + ∃ (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ), IsCenteredReduction x b a := by + obtain ⟨b, u, hraw⟩ := exists_rawFlagReduction_of_linearIndependent x hli + exact exists_centeredReduction_of_rawFlagReduction x hli b u hraw + +theorem centeredReduction_sum_eq_single {n : ℕ} + {x : Fin n → IntegralPoint n} + {a : Fin n → Fin n → ℝ} {i : Fin n} + (habove : ∀ j, i < j → a i j = 0) + (hbelow : ∀ j, j < i → a i j = 0) : + (∑ j, a i j • integralEmbed (x j)) = + a i i • integralEmbed (x i) := by + classical + apply Finset.sum_eq_single i + · intro j _hj hji + rcases lt_or_gt_of_ne hji with hlt | hgt + · simp [hbelow j hlt] + · simp [habove j hgt] + · simp + +theorem seminorm_basis_le_of_primitive_branch {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) (i : Fin n) + (hexpand : integralEmbed (b i) = + ∑ j, a i j • integralEmbed (x j)) + (habove : ∀ j, i < j → a i j = 0) + (hdiag : |a i i| = 1) + (hbelow : ∀ j, j < i → a i j = 0) : + p (integralEmbed (b i)) ≤ p (integralEmbed (x i)) := by + rw [hexpand, centeredReduction_sum_eq_single habove hbelow, + map_smul_eq_mul, Real.norm_eq_abs, hdiag, one_mul] + +theorem seminorm_basis_le_half_sum {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) (i : Fin n) + (hexpand : integralEmbed (b i) = + ∑ j, a i j • integralEmbed (x j)) + (habove : ∀ j, i < j → a i j = 0) + (hhalf : ∀ j, j ≤ i → |a i j| ≤ (1 : ℝ) / 2) : + p (integralEmbed (b i)) ≤ + (1 : ℝ) / 2 * + ∑ j ∈ Finset.Iic i, p (integralEmbed (x j)) := by + classical + rw [hexpand] + refine (seminorm_sum_le p (a i) (fun j ↦ integralEmbed (x j))).trans ?_ + have hsupport : + (∑ j : Fin n, |a i j| * p (integralEmbed (x j))) = + ∑ j ∈ Finset.Iic i, |a i j| * p (integralEmbed (x j)) := by + symm + apply Finset.sum_subset (by intro j hj; simp) + intro j _hjuniv hj + have hij : i < j := lt_of_not_ge (by simpa using hj) + simp [habove j hij] + rw [hsupport] + calc + (∑ j ∈ Finset.Iic i, |a i j| * p (integralEmbed (x j))) ≤ + ∑ j ∈ Finset.Iic i, + ((1 : ℝ) / 2) * p (integralEmbed (x j)) := by + apply Finset.sum_le_sum + intro j hj + exact mul_le_mul_of_nonneg_right (hhalf j (Finset.mem_Iic.mp hj)) + (apply_nonneg p (integralEmbed (x j))) + _ = (1 : ℝ) / 2 * + ∑ j ∈ Finset.Iic i, p (integralEmbed (x j)) := by + rw [Finset.mul_sum] + +theorem seminorm_basis_le_max_of_centeredReduction {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) + (hred : IsCenteredReduction x b a) (i : Fin n) : + p (integralEmbed (b i)) ≤ + max (p (integralEmbed (x i))) + ((1 : ℝ) / 2 * + ∑ j ∈ Finset.Iic i, p (integralEmbed (x j))) := by + obtain ⟨hexpand, habove, hprimitive | hcentered⟩ := hred i + · exact (seminorm_basis_le_of_primitive_branch p x b a i hexpand habove + hprimitive.1 hprimitive.2).trans (le_max_left _ _) + · exact (seminorm_basis_le_half_sum p x b a i hexpand habove hcentered).trans + (le_max_right _ _) + +theorem seminorm_basis_le_of_centered_branch {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) (i : Fin n) + (hordered : IsSeminormOrdered p x) + (hexpand : integralEmbed (b i) = + ∑ j, a i j • integralEmbed (x j)) + (habove : ∀ j, i < j → a i j = 0) + (hhalf : ∀ j, j ≤ i → |a i j| ≤ (1 : ℝ) / 2) : + p (integralEmbed (b i)) ≤ + ((i.val + 1 : ℕ) : ℝ) / 2 * p (integralEmbed (x i)) := by + classical + refine (seminorm_basis_le_half_sum p x b a i hexpand habove hhalf).trans ?_ + calc + (1 : ℝ) / 2 * ∑ j ∈ Finset.Iic i, p (integralEmbed (x j)) ≤ + (1 : ℝ) / 2 * ∑ _j ∈ Finset.Iic i, + p (integralEmbed (x i)) := by + gcongr with j hj + exact hordered (Finset.mem_Iic.mp hj) + _ = ((i.val + 1 : ℕ) : ℝ) / 2 * p (integralEmbed (x i)) := by + rw [Finset.sum_const, nsmul_eq_mul, Fin.card_Iic] + push_cast + ring + +theorem seminorm_basis_le_mahlerFactor_mul {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) + (hordered : IsSeminormOrdered p x) + (hred : IsCenteredReduction x b a) : + ∀ i, p (integralEmbed (b i)) ≤ + mahlerFactor i * p (integralEmbed (x i)) := by + intro i + obtain ⟨hexpand, habove, hprimitive | hcentered⟩ := hred i + · obtain ⟨hdiag, hbelow⟩ := hprimitive + have hbxi := seminorm_basis_le_of_primitive_branch + p x b a i hexpand habove hdiag hbelow + by_cases hi : i.val = 0 + · rw [mahlerFactor_zero i hi, one_mul] + exact hbxi + · rw [mahlerFactor_of_pos i (Nat.pos_of_ne_zero hi)] + have hfac : (1 : ℝ) ≤ (i.val + 1 : ℝ) / 2 := by + have : 1 ≤ i.val := Nat.one_le_iff_ne_zero.mpr hi + have hreal : (1 : ℝ) ≤ (i.val : ℝ) := by exact_mod_cast this + linarith + exact hbxi.trans <| + le_mul_of_one_le_left (apply_nonneg p (integralEmbed (x i))) hfac + · have hbxi := seminorm_basis_le_of_centered_branch + p x b a i hordered hexpand habove hcentered + by_cases hi : i.val = 0 + · rw [mahlerFactor_zero i hi, one_mul] + have hcoef : (((i.val + 1 : ℕ) : ℝ) / 2) ≤ 1 := by + norm_num [hi, div_eq_mul_inv] + exact hbxi.trans <| by + simpa only [one_mul] using (mul_le_mul_of_nonneg_right hcoef + (apply_nonneg p (integralEmbed (x i)))) + · rw [mahlerFactor_of_pos i (Nat.pos_of_ne_zero hi)] + have hbxi' : p (integralEmbed (b i)) ≤ + (i.val + 1 : ℝ) / 2 * p (integralEmbed (x i)) := by + simpa [Nat.cast_add, Nat.cast_one] using hbxi + exact hbxi' + +theorem isMahlerBasis_of_centeredReduction {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) + (hordered : IsSeminormOrdered p x) + (hred : IsCenteredReduction x b a) + (hmin : ∀ i, p (integralEmbed (x i)) ≤ successiveMinimum p i) : + IsMahlerBasis p b := by + intro i + exact (seminorm_basis_le_mahlerFactor_mul p x b a hordered hred i).trans + (mul_le_mul_of_nonneg_left (hmin i) (mahlerFactor_nonneg i)) + +theorem isMahlerBasis_of_centeredReduction_of_minima_upper {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ) + (hred : IsCenteredReduction x b a) + (hmin : ∀ i, p (integralEmbed (x i)) ≤ successiveMinimum p i) : + IsMahlerBasis p b := by + intro i + obtain ⟨hexpand, habove, hprimitive | hcentered⟩ := hred i + · have hbxi := seminorm_basis_le_of_primitive_branch + p x b a i hexpand habove hprimitive.1 hprimitive.2 + have hbmin := hbxi.trans (hmin i) + exact hbmin.trans (le_mul_of_one_le_left (successiveMinimum_nonneg p i) <| by + by_cases hi : i.val = 0 + · simp [mahlerFactor, hi] + · rw [mahlerFactor_of_pos i (Nat.pos_of_ne_zero hi)] + have hnat : 1 ≤ i.val := Nat.one_le_iff_ne_zero.mpr hi + have hreal : (1 : ℝ) ≤ (i.val : ℝ) := by exact_mod_cast hnat + linarith) + · refine (seminorm_basis_le_half_sum p x b a i + hexpand habove hcentered).trans ?_ + have hsum : + (∑ j ∈ Finset.Iic i, p (integralEmbed (x j))) ≤ + ∑ _j ∈ Finset.Iic i, successiveMinimum p i := by + apply Finset.sum_le_sum + intro j hj + exact (hmin j).trans + (successiveMinimum_mono_basisReduction p (Finset.mem_Iic.mp hj)) + calc + (1 : ℝ) / 2 * ∑ j ∈ Finset.Iic i, p (integralEmbed (x j)) ≤ + (1 : ℝ) / 2 * + ∑ _j ∈ Finset.Iic i, successiveMinimum p i := by + exact mul_le_mul_of_nonneg_left hsum (by positivity) + _ = (((i.val + 1 : ℕ) : ℝ) / 2) * successiveMinimum p i := by + rw [Finset.sum_const, nsmul_eq_mul, Fin.card_Iic] + push_cast + ring + _ ≤ mahlerFactor i * successiveMinimum p i := by + apply mul_le_mul_of_nonneg_right _ (successiveMinimum_nonneg p i) + by_cases hi : i.val = 0 + · norm_num [mahlerFactor, hi, div_eq_mul_inv] + · rw [mahlerFactor_of_pos i (Nat.pos_of_ne_zero hi)] + norm_num [Nat.cast_add, Nat.cast_one] + +theorem exists_isMahlerBasis_of_centeredReduction_of_minima_upper {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (hmin : ∀ i, p (integralEmbed (x i)) ≤ successiveMinimum p i) + (hred : ∃ (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ), IsCenteredReduction x b a) : + ∃ b : Basis (Fin n) ℤ (IntegralPoint n), IsMahlerBasis p b := by + obtain ⟨b, a, ha⟩ := hred + exact ⟨b, + isMahlerBasis_of_centeredReduction_of_minima_upper p x b a ha hmin⟩ + +theorem exists_isMahlerBasis_of_linearIndependent_of_minima_upper {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (hli : LinearIndependent ℝ (fun i ↦ integralEmbed (x i))) + (hmin : ∀ i, p (integralEmbed (x i)) ≤ successiveMinimum p i) : + ∃ b : Basis (Fin n) ℤ (IntegralPoint n), IsMahlerBasis p b := by + exact exists_isMahlerBasis_of_centeredReduction_of_minima_upper p x hmin + (exists_centeredReduction_of_linearIndependent x hli) + +theorem exists_isMahlerBasis_of_centeredReduction {n : ℕ} + (p : Seminorm ℝ (Fin n → ℝ)) + (x : Fin n → IntegralPoint n) + (hordered : IsSeminormOrdered p x) + (hmin : ∀ i, p (integralEmbed (x i)) ≤ successiveMinimum p i) + (hred : ∃ (b : Basis (Fin n) ℤ (IntegralPoint n)) + (a : Fin n → Fin n → ℝ), IsCenteredReduction x b a) : + ∃ b : Basis (Fin n) ℤ (IntegralPoint n), IsMahlerBasis p b := by + obtain ⟨b, a, ha⟩ := hred + exact ⟨b, isMahlerBasis_of_centeredReduction p x b a hordered ha hmin⟩ + +end Erdos3.IntegerBasisReduction.Mahler + +end + +section + +namespace Erdos3 + +open Module +open scoped BigOperators + +theorem IntegerBasisReduction.Mahler.IsCenteredReduction.abs_coefficient_le_one + {n : ℕ} {x : Fin n → IntegerBasisReduction.Mahler.IntegralPoint n} + {b : Basis (Fin n) ℤ (IntegerBasisReduction.Mahler.IntegralPoint n)} + {a : Fin n → Fin n → ℝ} + (h : IntegerBasisReduction.Mahler.IsCenteredReduction x b a) (i j : Fin n) : + |a i j| ≤ 1 := by + obtain ⟨_, habove, hprim | hhalf⟩ := h i + · rcases lt_trichotomy j i with hlt | rfl | hgt + · simp [hprim.2 j hlt] + · exact hprim.1.le + · simp [habove j hgt] + · rcases le_or_gt j i with hle | hgt + · exact (hhalf j hle).trans (by norm_num) + · simp [habove j hgt] + +theorem exists_lattice_basis_bounded_expansion + {E : Type} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] + (Λ : Submodule ℤ E) [DiscreteTopology Λ] [IsZLattice ℝ Λ] + {n : ℕ} (b₀ : Basis (Fin n) ℤ Λ) (v : Fin n → E) + (hv : ∀ i, v i ∈ Λ) (hli : LinearIndependent ℝ v) : + ∃ (b : Basis (Fin n) ℤ Λ) (a : Fin n → Fin n → ℝ), + (∀ i j, |a i j| ≤ 1) ∧ ∀ i, (b i : E) = ∑ j, a i j • v j := by + classical + let B := (b₀.ofZLatticeBasis ℝ Λ).equivFun + let w : Fin n → Λ := fun i => ⟨v i, hv i⟩ + let x : Fin n → IntegerBasisReduction.Mahler.IntegralPoint n := fun i => b₀.equivFun (w i) + have hcoord (i) : IntegerBasisReduction.Mahler.integralEmbed (x i) = B (v i) := by + ext j + change (b₀.repr (w i) j : ℝ) = (b₀.ofZLatticeBasis ℝ Λ).repr (w i : E) j + rw [Basis.ofZLatticeBasis_repr_apply] + have hxi : LinearIndependent ℝ (fun i => IntegerBasisReduction.Mahler.integralEmbed (x i)) := by + simpa only [hcoord, Function.comp_def, LinearEquiv.coe_coe] using + hli.map_injOn B.toLinearMap B.injective.injOn + obtain ⟨c, a, hred⟩ := IntegerBasisReduction.Mahler.exists_centeredReduction_of_linearIndependent x hxi + let b := c.map b₀.equivFun.symm + have hcast (z : Fin n → ℤ) : + B.symm (IntegerBasisReduction.Mahler.integralEmbed z) = (b₀.equivFun.symm z : E) := by + apply B.injective + ext j + rw [LinearEquiv.apply_symm_apply] + change (z j : ℝ) = (b₀.ofZLatticeBasis ℝ Λ).repr (b₀.equivFun.symm z : E) j + rw [Basis.ofZLatticeBasis_repr_apply] + exact (congrArg (fun q : ℤ => (q : ℝ)) + (congrFun (b₀.equivFun.apply_symm_apply z) j)).symm + refine ⟨b, a, hred.abs_coefficient_le_one, ?_⟩ + intro i + have h := congrArg B.symm (hred i).1 + rw [map_sum] at h + simp only [map_smul, hcoord, LinearEquiv.symm_apply_apply] at h + rw [hcast] at h + exact h + +theorem exists_lattice_basis_coordinate_bound + {ι : Type} [Fintype ι] (Λ : Submodule ℤ (ι → ℝ)) + [DiscreteTopology Λ] [IsZLattice ℝ Λ] + {n : ℕ} (b₀ : Basis (Fin n) ℤ Λ) (v : Fin n → ι → ℝ) + (hv : ∀ i, v i ∈ Λ) (hli : LinearIndependent ℝ v) + (R : ι → ℝ) (hbound : ∀ i j, |v i j| ≤ R j) : + ∃ b : Basis (Fin n) ℤ Λ, ∀ i j, |(b i : ι → ℝ) j| ≤ (n : ℝ) * R j := by + obtain ⟨b, a, ha, he⟩ := exists_lattice_basis_bounded_expansion Λ b₀ v hv hli + refine ⟨b, ?_⟩ + intro i j + rw [he] + simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + calc + |∑ k, a i k * v k j| ≤ ∑ k, |a i k * v k j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _k : Fin n, R j := by + apply Finset.sum_le_sum + intro k _ + rw [abs_mul] + have h := mul_le_mul_of_nonneg_right (ha i k) (abs_nonneg (v k j)) + have h' : |a i k| * |v k j| ≤ |v k j| := by simpa only [one_mul] using h + exact h'.trans (hbound k j) + _ = (n : ℝ) * R j := by simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped BigOperators + +theorem cyclicIntegerKernel_eq_zero_of_lt_radii + {ι : Type} [Fintype ι] {N : ℕ} (η : (ι → ℤ) →+ ZMod N) (R : ι → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) + (y : ι → ℝ) (hy : y ∈ cyclicIntegerKernel η) + (hsmall : ∀ i, |y i| < (R i : ℝ) + 1) : y = 0 := by + obtain ⟨x, hx, rfl⟩ := hy + change ∀ i, |(x i : ℝ)| < (R i : ℝ) + 1 at hsmall + have hbound : ∀ i, |x i| ≤ (R i : ℤ) := by + intro i + have h : |x i| < (R i : ℤ) + 1 := by exact_mod_cast hsmall i + omega + have he : x = 0 := hinj hbound (by simp) (by simpa using hx) + rw [he, map_zero] + +theorem cyclicIntegerKernel_nonzero_large_coordinate + {ι : Type} [Fintype ι] {N : ℕ} (η : (ι → ℤ) →+ ZMod N) (R : ι → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) + (y : ι → ℝ) (hy : y ∈ cyclicIntegerKernel η) (hne : y ≠ 0) : + ∃ i, (R i : ℝ) + 1 ≤ |y i| := by + by_contra! h + exact hne (cyclicIntegerKernel_eq_zero_of_lt_radii η R hinj y hy h) + +theorem affine_box_card_le_radius_product + {ι G : Type} [Fintype ι] [AddCommGroup G] + (η : (ι → ℤ) →+ G) (R : ι → ℕ) (h₀ : G) (J : Finset G) + (hrep : ∀ h ∈ J, ∃ x : ι → ℤ, (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + η x) : + (J.card : ℝ) ≤ (2 : ℝ) ^ Fintype.card ι * ∏ i, ((R i : ℝ) + 1) := by + classical + have hsub : J ⊆ (centeredIntegerBox R).image (fun x => h₀ + η x) := by + intro h hh + obtain ⟨x, hx, rfl⟩ := hrep h hh + exact Finset.mem_image.mpr ⟨x, (mem_centeredIntegerBox R x).mpr hx, rfl⟩ + have hc := (Finset.card_le_card hsub).trans (Finset.card_image_le) + have hp : (centeredIntegerBox R).card ≤ 2 ^ Fintype.card ι * ∏ i, (R i + 1) := by + rw [card_centeredIntegerBox] + calc + (∏ i, (2 * R i + 1)) ≤ ∏ i, (2 * (R i + 1)) := by + gcongr with i + omega + _ = _ := by rw [Finset.prod_mul_distrib]; simp + exact_mod_cast hc.trans hp + +theorem cyclicIntegerKernel_normalized_covolume_le + {ι : Type} [Fintype ι] {N : ℕ} [NeZero N] + (η : (ι → ℤ) →+ ZMod N) (R : ι → ℕ) (h₀ : ZMod N) (J : Finset (ZMod N)) + (δ : ℝ) (hδ : 0 < δ) (hdense : δ * N ≤ (J.card : ℝ)) + (hrep : ∀ h ∈ J, ∃ x : ι → ℤ, (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + η x) : + ZLattice.covolume (cyclicIntegerKernel η) * (∏ i, ((R i : ℝ) + 1))⁻¹ ≤ + (2 : ℝ) ^ Fintype.card ι / δ := by + have hprod : 0 < ∏ i, ((R i : ℝ) + 1) := Finset.prod_pos (by intros; positivity) + rw [← div_eq_mul_inv, div_le_div_iff₀ hprod hδ] + have hcov := mul_le_mul_of_nonneg_left (cyclicIntegerKernel_covolume_le η) hδ.le + have hc := affine_box_card_le_radius_product η R h₀ J hrep + nlinarith + +theorem exists_short_independent_cyclic_kernel_vectors + {r N : ℕ} [NeZero N] (η : (Fin r → ℤ) →+ ZMod N) (R : Fin r → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) + (h₀ : ZMod N) (J : Finset (ZMod N)) + (δ : ℝ) (hδ : 0 < δ) (hdense : δ * N ≤ (J.card : ℝ)) + (hrep : ∀ h ∈ J, ∃ x : Fin r → ℤ, (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + η x) : + ∃ v : Fin r → Fin r → ℝ, LinearIndependent ℝ v ∧ + (∀ i, v i ∈ cyclicIntegerKernel η) ∧ + ∀ i j, |v i j| ≤ + (BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant r * 2 ^ r / δ) * + ((R j : ℝ) + 1) := by + classical + let b : Basis (Fin r) ℤ (cyclicIntegerKernel η) := + (finiteLatticeBasis (cyclicIntegerKernel η)).reindex (finCongr (by simp)) + let B := b.ofZLatticeBasis ℝ (cyclicIntegerKernel η) + have hB : Submodule.span ℤ (Set.range B) = cyclicIntegerKernel η := + b.ofZLatticeBasis_span ℝ _ + have hdet : |(Matrix.of B).det| = ZLattice.covolume (cyclicIntegerKernel η) := by + have he : (B : Fin r → Fin r → ℝ) = fun i => (b i : Fin r → ℝ) := + funext (fun i => Basis.ofZLatticeBasis_apply ℝ (cyclicIntegerKernel η) b i) + rw [he] + exact (ZLattice.covolume_eq_det (cyclicIntegerKernel η) b).symm + obtain ⟨C⟩ := BohrLattice.MinkowskiSecondBox.realBox_has_minkowskiSecondCertificate + B (fun i => (R i : ℝ) + 1) (by intro i; positivity) + have hmem (i) : C.point i ∈ cyclicIntegerKernel η := hB ▸ C.point_mem i + have hpoint (i j) : |C.point i j| ≤ C.scale i * ((R j : ℝ) + 1) := by + have h := C.mem_scaledBox i + exact abs_le.mpr ⟨h.1 j, h.2 j⟩ + have hone (i) : 1 ≤ C.scale i := by + obtain ⟨j, hj⟩ := cyclicIntegerKernel_nonzero_large_coordinate η R hinj + (C.point i) (hmem i) (C.independent.ne_zero i) + have hp : 0 < (R j : ℝ) + 1 := by positivity + nlinarith [hpoint i j] + have hbound : ∏ i, C.scale i ≤ + BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant r * 2 ^ r / δ := by + have hm : 0 ≤ BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant r := by + unfold BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant + positivity + have hc := mul_le_mul_of_nonneg_left + (cyclicIntegerKernel_normalized_covolume_le η R h₀ J δ hδ hdense hrep) hm + have he : ∏ i, C.scale i ≤ + BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant r * + (ZLattice.covolume (cyclicIntegerKernel η) * (∏ i, ((R i : ℝ) + 1))⁻¹) := by + simpa only [hdet, mul_assoc] using C.product_le + simpa only [Fintype.card_fin, mul_div_assoc] using he.trans hc + refine ⟨C.point, C.independent, hmem, ?_⟩ + intro i j + have hi : C.scale i ≤ ∏ k, C.scale k := by + calc + C.scale i ≤ C.scale i * ∏ k ∈ Finset.univ.erase i, C.scale k := + le_mul_of_one_le_right (C.scale_nonneg i) (Finset.one_le_prod₀ (fun k _ => hone k)) + _ = ∏ k, C.scale k := Finset.mul_prod_erase _ _ (Finset.mem_univ i) + exact (hpoint i j).trans (mul_le_mul_of_nonneg_right (hi.trans hbound) (by positivity)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped BigOperators + +theorem proper_cyclic_kernel_box_card_le_covolume + {ι : Type} [Fintype ι] {N : ℕ} [NeZero N] + (η : (ι → ℤ) →+ ZMod N) (R : ι → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) : + ((∏ i, (2 * R i + 1) : ℕ) : ℝ) ≤ ZLattice.covolume (cyclicIntegerKernel η) := by + classical + let f : {x // x ∈ centeredIntegerBox R} → η.range := fun x => η.rangeRestrict x.val + have hf : Function.Injective f := by + intro x y h + apply Subtype.ext + exact hinj ((mem_centeredIntegerBox R x.val).mp x.property) + ((mem_centeredIntegerBox R y.val).mp y.property) (congrArg Subtype.val h) + have hc := Nat.card_le_card_of_injective f hf + have hcard : (centeredIntegerBox R).card ≤ Nat.card η.range := by + simpa only [Nat.card_eq_fintype_card, Fintype.card_coe] using hc + rw [card_centeredIntegerBox] at hcard + rw [cyclicIntegerKernel_covolume_eq_card_range] + exact_mod_cast hcard + +theorem proper_cyclic_kernel_covolume_lower_bound + {ι : Type} [Fintype ι] {N : ℕ} [NeZero N] + (η : (ι → ℤ) →+ ZMod N) (R : ι → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) : + (∏ i, ((R i : ℝ) + 1)) ≤ ZLattice.covolume (cyclicIntegerKernel η) := by + have hp : (∏ i, (R i + 1)) ≤ ∏ i, (2 * R i + 1) := by + gcongr with i + omega + have hpR : (∏ i, ((R i : ℝ) + 1)) ≤ ((∏ i, (2 * R i + 1) : ℕ) : ℝ) := by + exact_mod_cast hp + exact hpR.trans (proper_cyclic_kernel_box_card_le_covolume η R hinj) + +noncomputable def properCyclicKernelBasisBound (r : ℕ) (δ : ℝ) : ℝ := + (r : ℝ) * BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant r * 2 ^ r / δ + +theorem properCyclicKernelBasisBound_nonneg (r : ℕ) {δ : ℝ} (hδ : 0 < δ) : + 0 ≤ properCyclicKernelBasisBound r δ := by + unfold properCyclicKernelBasisBound BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant + positivity + +theorem exists_proper_cyclic_kernel_basis + {r N : ℕ} [NeZero N] (η : (Fin r → ℤ) →+ ZMod N) (R : Fin r → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) + (h₀ : ZMod N) (J : Finset (ZMod N)) + (δ : ℝ) (hδ : 0 < δ) (hdense : δ * N ≤ (J.card : ℝ)) + (hrep : ∀ h ∈ J, ∃ x : Fin r → ℤ, (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + η x) : + ∃ b : Basis (Fin r) ℤ (cyclicIntegerKernel η), ∀ i j, + |(b i : Fin r → ℝ) j| ≤ properCyclicKernelBasisBound r δ * ((R j : ℝ) + 1) := by + classical + obtain ⟨v, hli, hv, hbound⟩ := + exists_short_independent_cyclic_kernel_vectors η R hinj h₀ J δ hδ hdense hrep + let b₀ : Basis (Fin r) ℤ (cyclicIntegerKernel η) := + (finiteLatticeBasis (cyclicIntegerKernel η)).reindex (finCongr (by simp)) + obtain ⟨b, hb⟩ := exists_lattice_basis_coordinate_bound (cyclicIntegerKernel η) b₀ v hv hli + (fun j => (BohrLattice.MinkowskiSecondBox.minkowskiSecondConstant r * 2 ^ r / δ) * + ((R j : ℝ) + 1)) hbound + refine ⟨b, ?_⟩ + intro i j + simpa only [properCyclicKernelBasisBound, mul_div_assoc, mul_assoc] using hb i j + +theorem exists_proper_affine_torus_basis + {r N : ℕ} [NeZero N] (η : (Fin r → ℤ) →+ ZMod N) (R : Fin r → ℕ) + (hinj : Set.InjOn η {x | ∀ i, |x i| ≤ (R i : ℤ)}) + (h₀ : ZMod N) (J : Finset (ZMod N)) + (δ : ℝ) (hδ : 0 < δ) (hdense : δ * N ≤ (J.card : ℝ)) + (hrep : ∀ h ∈ J, ∃ x : Fin r → ℤ, (∀ i, |x i| ≤ (R i : ℤ)) ∧ h = h₀ + η x) : + ∃ b : Basis (Fin r) ℤ (cyclicIntegerKernel η), + (∀ i j, |(b i : Fin r → ℝ) j| ≤ properCyclicKernelBasisBound r δ * ((R j : ℝ) + 1)) ∧ + ∃ t : Fin r → ℝ, (∀ i, t i ∈ Set.Ico (0 : ℝ) 1) ∧ + (∀ i, ∃ k : ℤ, (N : ℝ) * t i = (k : ℝ)) ∧ + ∀ (h : ZMod N) (x : Fin r → ℤ), h = h₀ + η x → ∀ i, + ((cyclicKernelRealCoordinates η b (integerVectorRealMap x) i : ℝ) : + AddCircle (1 : ℝ)) = + ((((h.val : ℝ) - h₀.val) * t i : ℝ) : AddCircle (1 : ℝ)) := by + obtain ⟨b, hb⟩ := exists_proper_cyclic_kernel_basis η R hinj h₀ J δ hδ hdense hrep + exact ⟨b, hb, exists_affine_cyclic_kernel_real_frequencies η b h₀⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/QuadraticMatrixSymmetry.lean b/lean/OAI/Combinatorics/Progressions/Linear/QuadraticMatrixSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..e96fb714837dfaf98e53c81c3d54e3567e1ce26d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/QuadraticMatrixSymmetry.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonWeightedExchange +import OAI.Combinatorics.Progressions.Estimates.QuadraticWeightedSymmetry + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_quadratic_matrix_symmetry (k : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + Real.exp ((p + C) ^ C) ≤ (N : ℝ) → + ∀ f : ZMod N → ℂ, (∀ x, ‖f x‖ ≤ 1) → Real.exp (-p) ≤ gowersNorm 3 f → + ∃ q : ℝ, 0 ≤ q ∧ q ≤ (p + C) ^ C ∧ + ∃ H : Finset (ZMod N), H.Nonempty ∧ Real.exp (-q) * N ≤ (H.card : ℝ) ∧ + ∃ M : NativeMultidegreeNilcharacter (mixedCorrelationDegree 1) q, + ∃ i : Fin M.outputDim, + (∀ h ∈ H, Real.exp (-q) ≤ + ‖𝔼 n : ZMod N, multiplicativeDerivative f h n * + star (M.evalCyclic N i (correlationInput h n))‖) ∧ + ∃ w : (Fin 2 → ℤ) → ℝ, + ∃ G : Fin M.outputDim → Fin M.outputDim → (Fin 2 → ℤ) → ℂ, + (∀ z, 0 ≤ w z ∧ w z ≤ 1) ∧ + Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 1 ((p + C) ^ C) + (fun z => (w z : ℂ))) ∧ + (∀ a b, Nonempty (NativeIntegerExpansion (fun _ : Fin 2 => 1) 1 + ((p + C) ^ C) (G a b))) ∧ + Real.exp (-(2 * q + 1)) ≤ + (𝔼 z : Fin 2 → ZMod N, w (fun j => ((z j).val : ℤ))) ∧ + (𝔼 z : Fin 2 → ZMod N, Real.sqrt (∑ a, ∑ b, + ‖M.antisymmetricKernel a b ((z 0).val : ℤ) ((z 1).val : ℤ) * + (w (fun j => ((z j).val : ℤ)) : ℂ) - G a b (fun j => ((z j).val : ℤ))‖ ^ 2)) ≤ + Real.exp (-(2 * q + 1 + (p + 2) ^ k)) := by + obtain ⟨A, _, hselected⟩ := exists_quadratic_weighted_symmetry_approximation k + obtain ⟨B, _, hcommon⟩ := exists_common_weighted_exchange + let X : Polynomial ℕ := Polynomial.X + let T := (X + Polynomial.C A) ^ A + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (T + (2 * T + Polynomial.C B) ^ B) + refine ⟨C, hC, ?_⟩ + intro N _ p hp hN f hf hG + let t := (p + A) ^ A + have ht : 0 ≤ t := by dsimp [t]; positivity + have hsum : t + (2 * t + B) ^ B ≤ (p + C) ^ C := by + simpa [T, X, t, Polynomial.eval₂_pow] using hbudget p hp + have htC : t ≤ (p + C) ^ C := (le_add_of_nonneg_right (by positivity)).trans hsum + have hBC : (2 * t + B) ^ B ≤ (p + C) ^ C := (le_add_of_nonneg_left ht).trans hsum + obtain ⟨q, hq, hqt, H, hH, hdense, M, i, hcorr, i', j', w, G, hw, ⟨EW⟩, + ⟨EG⟩, _hmass, henergy, herr⟩ := + hselected hp ((Real.exp_le_exp.mpr htC).trans hN) f hf hG + obtain ⟨v, U, hv, ⟨EV⟩, hU, hmass, herror⟩ := + hcommon M i' j' w G ht EW EG hw henergy herr + have hcost : (q + t + B) ^ B ≤ (p + C) ^ C := + (pow_le_pow_left₀ (by positivity) (by linarith : q + t + B ≤ 2 * t + B) B).trans hBC + refine ⟨q, hq, hqt.trans htC, H, hH, hdense, M, i, hcorr, v, U, hv, + ⟨EV.mono hcost⟩, ?_, hmass, herror⟩ + intro a b + obtain ⟨E⟩ := hU a b + exact ⟨E.mono hcost⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/QuarticKernelCorrelatedModel.lean b/lean/OAI/Combinatorics/Progressions/Linear/QuarticKernelCorrelatedModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc8bcb0a16940523040e4ba3e2805fb9eac45804 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/QuarticKernelCorrelatedModel.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Geometry.QuarticAntisymmetricBox +import OAI.Combinatorics.Progressions.Geometry.QuarticBoxFactorizationTransport + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_quartic_kernel_correlated_model : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + Real.exp ((p + C) ^ C) ≤ (N : ℝ) → + ∀ f : ZMod N → ℂ, (∀ x, ‖f x‖ ≤ 1) → Real.exp (-p) ≤ gowersNorm 5 f → + ∃ R : NativeMixedCorrelation 3 N ((p + C) ^ C) f, + ∃ W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) ((p + C) ^ C), + W.dim ≤ 16 * R.mixed.dim ∧ + (∀ (e : ReplicatedPermutation (mixedCorrelationDegree 3)) k x, + W.eval k (fun j => x ((replicatedPermutation (mixedCorrelationDegree 3) e).symm j)) = W.eval k x) ∧ + NativeIntegerVectorEquivalence 3 ((p + C) ^ C) R.mixed.eval + (fun i x => W.eval i (quarticInput (x 0) (fun _ => x 1))) ∧ + NativeIntegerVectorEquivalence 3 ((p + C) ^ C) (R.mixed.mixedSecondDifferenceWithShift 0) + (quarticSixFactorVector W.eval) ∧ + ∃ i j : Fin (W.outputDim ^ 6), + Nonempty (NativeSampleCorrelation (fun _ : Fin 4 => 1) 3 ((p + C) ^ C) + Finset.univ (fun x : Fin 4 → ZMod N => fun k => ((x k).val : ℤ)) + (fun x => (W.tensorPower 6).quarticAntisymmetric i j (fun k => ((x k).val : ℤ)))) := by + obtain ⟨a, _, hbox⟩ := exists_quartic_antisymmetric_box_with_mixed + obtain ⟨b, _, hcorrelate⟩ := exists_quartic_kernel_correlation + let Q : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + let V := 7 * (Q + 1) + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (V + (V + Polynomial.C b) ^ b) + refine ⟨C, hC, ?_⟩ + intro N _ p hp hN f hf hGowers + let q := (p + a) ^ a + let v := 7 * (q + 1) + have hq : 0 ≤ q := by dsimp only [q]; positivity + have hqv : q ≤ v := by dsimp only [v]; linarith + have hv : 0 ≤ v := hq.trans hqv + have hsum : v + (v + b) ^ b ≤ (p + C) ^ C := by + simpa [Q, V, q, v, Polynomial.eval₂_pow] using hbudget p hp + have hpow : 0 ≤ (v + b) ^ b := by positivity + have hqC : q ≤ (p + C) ^ C := by linarith only [hsum, hpow, hqv] + have hcorrC : (v + b) ^ b ≤ (p + C) ^ C := by linarith only [hsum, hv] + obtain ⟨M, hret, W, hdim, hsymm, hdiag, E, i, j, hbias⟩ := + hbox hp ((Real.exp_le_exp.mpr hqC).trans hN) f hf hGowers + have hvV : tensorPowerBudget 6 ((p + a) ^ a) = v := by + norm_num [tensorPowerBudget, v, q] + have hVpos : 0 ≤ tensorPowerBudget 6 ((p + a) ^ a) := by rw [hvV]; exact hv + have hqV : q ≤ tensorPowerBudget 6 ((p + a) ^ a) := by rw [hvV]; exact hqv + obtain ⟨S⟩ := hcorrelate hVpos (W.tensorPower 6) i j + ((Real.exp_le_exp.mpr (neg_le_neg hqV)).trans hbias) + have hcost : (tensorPowerBudget 6 ((p + a) ^ a) + b) ^ b ≤ (p + C) ^ C := by + rw [hvV] + exact hcorrC + obtain ⟨R, hR⟩ := hret + rcases hR with rfl + exact ⟨R.mono hqC, W.mono hqC, hdim, hsymm, hdiag.mono hqC, E.mono hqC, + i, j, ⟨S.mono hcost⟩⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/QuarticKernelCorrelation.lean b/lean/OAI/Combinatorics/Progressions/Linear/QuarticKernelCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..09a22f9923a30fbc279eef817ebf5c45b3aa13e1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/QuarticKernelCorrelation.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.Progressions.Estimates.MixedAnchorExpansion + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem exists_quartic_kernel_correlation : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {p : ℝ}, 0 ≤ p → + ∀ (W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) p) + {N : ℕ} [NeZero N] (i j : Fin W.outputDim), + Real.exp (-p) ≤ (boxPhaseMoment 4 (fun x : Fin 4 → ZMod N => + W.quarticAntisymmetric i j (fun k => ((x k).val : ℤ)))).re → + Nonempty (NativeSampleCorrelation (fun _ : Fin 4 => 1) 3 ((p + C) ^ C) + Finset.univ (fun x : Fin 4 → ZMod N => fun k => ((x k).val : ℤ)) + (fun x => W.quarticAntisymmetric i j (fun k => ((x k).val : ℤ)))) := by + obtain ⟨A, _, hanchor⟩ := NativeMultidegreeNilcharacter.exists_quartic_anchor_expansion + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (X + (X + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro p hp W N _ i j hbias + let K := W.quarticAntisymmetric i j + let Kc := fun x : Fin 4 → ZMod N => K (fun k => ((x k).val : ℤ)) + obtain ⟨a, ha⟩ := exists_box_corner_anchor_correlation Kc + obtain ⟨E⟩ := hanchor W i j (fun k => ((a k).val : ℤ)) + have hmap (x : Fin 4 → ZMod N) : boxCornerAnchor Kc a x = + boxCornerAnchor K (fun k => ((a k).val : ℤ)) (fun k => ((x k).val : ℤ)) := + boxCornerAnchor_map (fun z : ZMod N => (z.val : ℤ)) K a x + have hcorr : Real.exp (-p) ≤ ‖𝔼 x : Fin 4 → ZMod N, + K (fun k => ((x k).val : ℤ)) * + star (star (boxCornerAnchor K (fun k => ((a k).val : ℤ)) + (fun k => ((x k).val : ℤ))))‖ := by + have h := hbias.trans ha + simp_rw [hmap] at h + simpa only [Kc, star_star] using h + obtain ⟨S⟩ := NativeSampleCorrelation.exists_of_expansion E.conjugate hp hcorr + have hcost : p + (p + A) ^ A ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨S.mono hcost⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/QuotientActionMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/QuotientActionMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..25870156ef0bbb95ecac5a1029edadcdb5123c59 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/QuotientActionMatrix.lean @@ -0,0 +1,50 @@ +import Mathlib.LinearAlgebra.Matrix.ToLin + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {K V W ι κ : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + +theorem quotient_basis_representative (e : Basis ι K V) (f : Basis κ K W) + (q : V →ₗ[K] W) (D : Matrix κ ι K) (S : Matrix ι κ K) + (hD : LinearMap.toMatrix e f q = D) (hDS : D * S = 1) (y : κ → K) : + f.equivFun.symm y = q (e.equivFun.symm (S *ᵥ y)) := by + apply f.equivFun.injective + rw [LinearEquiv.apply_symm_apply] + change y = f.repr (q (e.equivFun.symm (S *ᵥ y))) + rw [← LinearMap.toMatrix_mulVec_repr e f q, hD] + change y = D *ᵥ e.equivFun (e.equivFun.symm (S *ᵥ y)) + rw [LinearEquiv.apply_symm_apply, Matrix.mulVec_mulVec, hDS, Matrix.one_mulVec] + +theorem quotient_action_matrix (e : Basis ι K V) (f : Basis κ K W) + (q : V →ₗ[K] W) (A : V →ₗ[K] V) (B : W →ₗ[K] W) + (hAB : ∀ x, q (A x) = B (q x)) (S : Matrix ι κ K) + (hS : LinearMap.toMatrix e f q * S = 1) : + LinearMap.toMatrix f f B = LinearMap.toMatrix e f q * LinearMap.toMatrix e e A * S := by + let L := Matrix.toLin f e S + have hqL : q.comp L = LinearMap.id := by + apply (LinearMap.toMatrix f f).injective + rw [LinearMap.toMatrix_comp f e f, LinearMap.toMatrix_id] + change LinearMap.toMatrix e f q * LinearMap.toMatrix f e (Matrix.toLin f e S) = 1 + rw [LinearMap.toMatrix_toLin, hS] + have he : B = q.comp (A.comp L) := by + ext x + change B x = q (A (L x)) + rw [hAB, show q (L x) = x from DFunLike.congr_fun hqL x] + rw [he, LinearMap.toMatrix_comp f e f, LinearMap.toMatrix_comp f e e] + change LinearMap.toMatrix e f q * + (LinearMap.toMatrix e e A * LinearMap.toMatrix f e (Matrix.toLin f e S)) = _ + rw [LinearMap.toMatrix_toLin, Matrix.mul_assoc] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/QuotientProjectionCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Linear/QuotientProjectionCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ab1ed7c27af613d008356c526e78fe86b0006bf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/QuotientProjectionCoordinates.lean @@ -0,0 +1,454 @@ +import Mathlib.LinearAlgebra.Isomorphisms +import OAI.Combinatorics.Progressions.Dynamics.NativeHorizontalLiftBudget + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {K V ι κ δ : Type*} [Field K] [AddCommGroup V] [Module K V] + +def BasisBlockInvariant (b : Basis ι K V) (c : ι → δ) (U : Submodule K V) : Prop := + ∀ d x, x ∈ U → basisCoordinateProjection b {i | c i = d} x ∈ U + +theorem sum_basisBlockProjection [Fintype ι] [DecidableEq δ] + (b : Basis ι K V) (c : ι → δ) (x : V) : + ∑ d ∈ Finset.univ.image c, basisCoordinateProjection b {i | c i = d} x = x := by + classical + apply b.repr.injective + ext i + have hi : c i ∈ Finset.univ.image c := Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩ + simp only [map_sum, Finsupp.finsetSum_apply, basisCoordinateProjection_repr] + change (∑ d ∈ Finset.univ.image c, if c i = d then b.repr x i else 0) = b.repr x i + simp [hi] + +noncomputable def blockSpanningFamily (b : Basis ι K V) (c : ι → δ) (v : κ → V) : ι × κ → V := + fun z => basisCoordinateProjection b {i | c i = c z.1} (v z.2) + +theorem blockSpanningFamily_repr [DecidableEq δ] (b : Basis ι K V) (c : ι → δ) (v : κ → V) + (z : ι × κ) (i : ι) : + b.repr (blockSpanningFamily b c v z) i = if c i = c z.1 then b.repr (v z.2) i else 0 := by + exact basisCoordinateProjection_repr b {i | c i = c z.1} (v z.2) i + +theorem blockSpanningFamily_span [Fintype ι] (b : Basis ι K V) (c : ι → δ) + (U : Submodule K V) (v : κ → V) (hspan : Submodule.span K (Set.range v) = U) + (hU : BasisBlockInvariant b c U) : + Submodule.span K (Set.range (blockSpanningFamily b c v)) = U := by + classical + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨z, rfl⟩ + apply hU (c z.1) (v z.2) + rw [← hspan] + exact Submodule.subset_span ⟨z.2, rfl⟩ + · rw [← hspan] + apply Submodule.span_le.mpr + rintro _ ⟨j, rfl⟩ + rw [← sum_basisBlockProjection b c (v j)] + apply Submodule.sum_mem + intro d hd + obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hd + exact Submodule.subset_span ⟨(i, j), rfl⟩ + +theorem blockSpanningFamily_height {V : Type*} [AddCommGroup V] [Module ℚ V] + (b : Basis ι ℚ V) (c : ι → δ) (v : κ → V) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ j i, RationalHeightLE (b.repr (v j) i) H) : + ∀ z i, RationalHeightLE (b.repr (blockSpanningFamily b c v z) i) H := by + classical + intro z i + rw [blockSpanningFamily_repr] + split_ifs + · exact hv z.2 i + · exact rationalHeightLE_zero hH + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {K V W ι κ δ : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] + +theorem basisBlockMap_commutes (e : Basis ι K V) (f : Basis κ K W) + (c : ι → δ) (d : κ → δ) (T : V →ₗ[K] W) + (hT : ∀ i j, d j ≠ c i → f.repr (T (e i)) j = 0) (a : δ) (x : V) : + T (basisCoordinateProjection e {i | c i = a} x) = + basisCoordinateProjection f {j | d j = a} (T x) := by + classical + have he : T.comp (basisCoordinateProjection e {i | c i = a}) = + (basisCoordinateProjection f {j | d j = a}).comp T := by + apply e.ext + intro i + apply f.repr.injective + ext j + by_cases hi : c i = a <;> by_cases hj : d j = a + · simp [LinearMap.comp_apply, basisCoordinateProjection_basis, basisCoordinateProjection_repr, hi, hj] + · have hij : d j ≠ c i := fun h => hj (h.trans hi) + simp [LinearMap.comp_apply, basisCoordinateProjection_basis, basisCoordinateProjection_repr, hi, hj, hT i j hij] + · have hij : d j ≠ c i := fun h => hi (h.symm.trans hj) + simp [LinearMap.comp_apply, basisCoordinateProjection_basis, basisCoordinateProjection_repr, hi, hj, hT i j hij] + · simp [LinearMap.comp_apply, basisCoordinateProjection_basis, basisCoordinateProjection_repr, hi, hj] + exact DFunLike.congr_fun he x + +theorem BasisBlockInvariant.map (e : Basis ι K V) (f : Basis κ K W) + (c : ι → δ) (d : κ → δ) (T : V →ₗ[K] W) + (hT : ∀ i j, d j ≠ c i → f.repr (T (e i)) j = 0) + (U : Submodule K V) (hU : BasisBlockInvariant e c U) : + BasisBlockInvariant f d (U.map T) := by + rintro a y ⟨x, hx, rfl⟩ + exact ⟨basisCoordinateProjection e {i | c i = a} x, hU a x hx, + basisBlockMap_commutes e f c d T hT a x⟩ + +theorem basisBlockInvariant_ker (e : Basis ι K V) (f : Basis κ K W) + (c : ι → δ) (d : κ → δ) (T : V →ₗ[K] W) + (hT : ∀ i j, d j ≠ c i → f.repr (T (e i)) j = 0) : + BasisBlockInvariant e c (LinearMap.ker T) := by + intro a x hx + change T (basisCoordinateProjection e {i | c i = a} x) = 0 + rw [basisBlockMap_commutes e f c d T hT a x, show T x = 0 from hx, map_zero] + +theorem BasisBlockInvariant.inf (e : Basis ι K V) (c : ι → δ) + (U Z : Submodule K V) (hU : BasisBlockInvariant e c U) (hZ : BasisBlockInvariant e c Z) : + BasisBlockInvariant e c (U ⊓ Z) := + fun a x hx => ⟨hU a x hx.1, hZ a x hx.2⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +section Algebra + +variable {ι κ μ δ K : Type*} [Semiring K] + +noncomputable def matrixBlockPart (r : ι → δ) (c : κ → δ) (A : Matrix ι κ K) : Matrix ι κ K := by + classical + exact fun i j => if r i = c j then A i j else 0 + +theorem matrixBlockPart_eq (r : ι → δ) (c : κ → δ) (A : Matrix ι κ K) + (hA : ∀ i j, r i ≠ c j → A i j = 0) : matrixBlockPart r c A = A := by + classical + ext i j + by_cases h : r i = c j + · simp only [matrixBlockPart, h, ↓reduceIte] + · simp only [matrixBlockPart, h, ↓reduceIte, hA i j h] + +theorem matrixBlockPart_off_block (r : ι → δ) (c : κ → δ) (A : Matrix ι κ K) + (i : ι) (j : κ) (h : r i ≠ c j) : matrixBlockPart r c A i j = 0 := by + classical + simp only [matrixBlockPart, h, ↓reduceIte] + +theorem matrix_mul_blockPart [Fintype κ] (r : ι → δ) (c : κ → δ) (d : μ → δ) + (A : Matrix ι κ K) (B : Matrix κ μ K) + (hA : ∀ i j, r i ≠ c j → A i j = 0) : + A * matrixBlockPart c d B = matrixBlockPart r d (A * B) := by + classical + ext i k + have hterm (j : κ) : + A i j * (if c j = d k then B j k else 0) = + if r i = d k then A i j * B j k else 0 := by + by_cases hij : r i = c j + · rw [hij] + split_ifs <;> simp only [mul_zero] + · rw [hA i j hij] + split_ifs <;> simp only [zero_mul] + simp only [Matrix.mul_apply, matrixBlockPart, hterm] + by_cases h : r i = d k <;> simp only [h, ↓reduceIte, Finset.sum_const_zero] + +theorem matrix_blockPart_mul [Fintype κ] (r : ι → δ) (c : κ → δ) (d : μ → δ) + (A : Matrix ι κ K) (B : Matrix κ μ K) + (hB : ∀ j k, c j ≠ d k → B j k = 0) : + matrixBlockPart r c A * B = matrixBlockPart r d (A * B) := by + classical + ext i k + have hterm (j : κ) : + (if r i = c j then A i j else 0) * B j k = + if r i = d k then A i j * B j k else 0 := by + by_cases hjk : c j = d k + · rw [hjk] + split_ifs <;> simp only [zero_mul] + · rw [hB j k hjk] + split_ifs <;> simp only [mul_zero] + simp only [Matrix.mul_apply, matrixBlockPart, hterm] + by_cases h : r i = d k <;> simp only [h, ↓reduceIte, Finset.sum_const_zero] + +theorem matrixBlockPart_image_section [Fintype ι] [Fintype κ] + (r : ι → δ) (c : κ → δ) (A : Matrix ι κ K) (S : Matrix κ ι K) + (hA : ∀ i j, r i ≠ c j → A i j = 0) (hS : A * S * A = A) : + A * matrixBlockPart c r S * A = A := by + rw [matrix_mul_blockPart r c r A S hA, matrix_blockPart_mul r r c (A * S) A hA, + hS, matrixBlockPart_eq r c A hA] + +end Algebra + +theorem exists_bounded_block_image_section {ι κ δ : Type*} [Fintype ι] [Fintype κ] + (r : ι → δ) (c : κ → δ) (A : Matrix ι κ ℚ) + (hblock : ∀ i j, r i ≠ c j → A i j = 0) {H : ℕ} (hH : 1 ≤ H) + (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ S : Matrix κ ι ℚ, A * S * A = A ∧ + (∀ i j, c i ≠ r j → S i j = 0) ∧ + ∀ i j, RationalHeightLE (S i j) (rationalKernelHeight (Fintype.card ι) H) := by + classical + obtain ⟨S, hS, hSH⟩ := exists_bounded_rational_image_section A hH hA + refine ⟨matrixBlockPart c r S, matrixBlockPart_image_section r c A S hblock hS, + matrixBlockPart_off_block c r S, ?_⟩ + intro i j + by_cases h : c i = r j + · simpa only [matrixBlockPart, h, ↓reduceIte] using hSH i j + · simpa only [matrixBlockPart, h, ↓reduceIte] using + rationalHeightLE_zero (rationalKernelHeight_pos (Fintype.card ι) hH) + +end Erdos3 + +end + +section + +open scoped Matrix + +namespace Erdos3 + +theorem real_matrix_image_section {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℚ) (S : Matrix κ ι ℚ) (hS : A * S * A = A) : + Matrix.of (fun i j => (A i j : ℝ)) * Matrix.of (fun i j => (S i j : ℝ)) * + Matrix.of (fun i j => (A i j : ℝ)) = Matrix.of (fun i j => (A i j : ℝ)) := by + ext i j + have he := congrArg (fun q : ℚ => (q : ℝ)) (congrFun (congrFun hS i) j) + simpa only [Matrix.mul_apply, Matrix.of_apply, Rat.cast_sum, Rat.cast_mul] using he + +theorem exists_real_span_defining_matrix {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℚ) {H : ℕ} (hH : 1 ≤ H) + (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ Q : Matrix ι ι ℚ, + (∀ i j, RationalHeightLE (Q i j) (imageDefiningHeight (Fintype.card κ) (Fintype.card ι) H)) ∧ + LinearMap.ker (Matrix.mulVecLin (fun i j => (Q i j : ℝ))) = + LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) := by + classical + obtain ⟨S, hS, hSH⟩ := exists_bounded_rational_image_section A hH hA + let Q : Matrix ι ι ℚ := 1 - A * S + have hSr := real_matrix_image_section A S hS + have hQr : Matrix.of (fun i j => (Q i j : ℝ)) = + 1 - Matrix.of (fun i j => (A i j : ℝ)) * Matrix.of (fun i j => (S i j : ℝ)) := by + ext i j + by_cases hij : i = j <;> + simp [Q, Matrix.sub_apply, Matrix.mul_apply, Matrix.one_apply, hij] + refine ⟨Q, ?_, ?_⟩ + · intro i j + have hI : RationalHeightLE ((1 : Matrix ι ι ℚ) i j) 1 := by + by_cases hij : i = j + · simpa [Matrix.one_apply, hij] using rationalHeightLE_one (by decide : 1 ≤ 1) + · simpa [Matrix.one_apply, hij] using rationalHeightLE_zero (by decide : 1 ≤ 1) + have hprod := rationalHeightLE_matrix_mul A S hA hSH i j + simpa only [Q, Matrix.sub_apply, imageDefiningHeight, mul_one] using hI.sub hprod + · ext x + change Matrix.of (fun i j => (Q i j : ℝ)) *ᵥ x = 0 ↔ + ∃ y, Matrix.of (fun i j => (A i j : ℝ)) *ᵥ y = x + rw [hQr, Matrix.sub_mulVec, Matrix.one_mulVec, ← Matrix.mulVec_mulVec] + constructor + · intro hx + exact ⟨(fun i j => (S i j : ℝ)) *ᵥ x, (sub_eq_zero.mp hx).symm⟩ + · rintro ⟨y, rfl⟩ + rw [Matrix.mulVec_mulVec, Matrix.mulVec_mulVec, hSr, sub_self] + +theorem real_column_span_mem_iff {ι κ : Type*} [Fintype ι] [Fintype κ] + (A : Matrix ι κ ℚ) (x : ι → ℝ) : + x ∈ Submodule.span ℝ (Set.range (fun j i => (A i j : ℝ))) ↔ + x ∈ LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) := by + have h := congrArg (fun U : Submodule ℝ (ι → ℝ) => x ∈ U) + (Matrix.range_mulVecLin (Matrix.of (fun i j => (A i j : ℝ)))) + exact (iff_of_eq h).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +theorem imageDefiningHeight_pos (d n H : ℕ) (hH : 1 ≤ H) : + 0 < imageDefiningHeight d n H := by + have hHp : 0 < H := lt_of_lt_of_le Nat.zero_lt_one hH + have hK := rationalKernelHeight_pos n hH + unfold imageDefiningHeight + positivity + +theorem exists_bounded_block_quotient_projection {ι κ δ : Type*} [Fintype ι] [Fintype κ] + (c : ι → δ) (d : κ → δ) (A : Matrix ι κ ℚ) + (hblock : ∀ i j, c i ≠ d j → A i j = 0) {H : ℕ} (hH : 1 ≤ H) + (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ Q : Matrix ι ι ℚ, Q * Q = Q ∧ + LinearMap.ker Q.mulVecLin = LinearMap.range A.mulVecLin ∧ + (∀ i j, c i ≠ c j → Q i j = 0) ∧ + ∀ i j, RationalHeightLE (Q i j) (imageDefiningHeight (Fintype.card κ) (Fintype.card ι) H) := by + classical + obtain ⟨S, hS, hSb, hSH⟩ := exists_bounded_block_image_section c d A hblock hH hA + let Q : Matrix ι ι ℚ := 1 - A * S + have hId : (A * S) * (A * S) = A * S := by rw [← Matrix.mul_assoc, hS] + refine ⟨Q, ?_, ?_, ?_, ?_⟩ + · dsimp only [Q] + rw [Matrix.sub_mul, Matrix.one_mul, Matrix.mul_sub, Matrix.mul_one, hId, sub_self, sub_zero] + · ext x + change (1 - A * S) *ᵥ x = 0 ↔ ∃ y, A *ᵥ y = x + rw [Matrix.sub_mulVec, Matrix.one_mulVec, ← Matrix.mulVec_mulVec] + constructor + · intro hx + exact ⟨S *ᵥ x, (sub_eq_zero.mp hx).symm⟩ + · rintro ⟨y, rfl⟩ + rw [Matrix.mulVec_mulVec, Matrix.mulVec_mulVec, hS, sub_self] + · intro i j hij + have hne : i ≠ j := fun h => hij (congrArg c h) + have hprod : (A * S) i j = 0 := by + apply Finset.sum_eq_zero + intro k _ + by_cases hik : c i = d k + · exact (congrArg (fun z : ℚ => A i k * z) + (hSb k j (fun hkj => hij (hik.trans hkj)))).trans (mul_zero _) + · exact (congrArg (fun z : ℚ => z * S k j) (hblock i k hik)).trans (zero_mul _) + simp only [Q, Matrix.sub_apply, Matrix.one_apply, hne, ↓reduceIte, hprod, sub_self] + · intro i j + have hI : RationalHeightLE ((1 : Matrix ι ι ℚ) i j) 1 := by + by_cases hij : i = j + · simpa [Matrix.one_apply, hij] using rationalHeightLE_one (by decide : 1 ≤ 1) + · simpa [Matrix.one_apply, hij] using rationalHeightLE_zero (by decide : 1 ≤ 1) + have hp := rationalHeightLE_matrix_mul A S hA hSH i j + simpa only [Q, Matrix.sub_apply, imageDefiningHeight, mul_one] using hI.sub hp + +theorem exists_submodule_block_quotient_projection + {V ι κ δ : Type*} [AddCommGroup V] [Module ℚ V] [Fintype ι] [Fintype κ] + (b : Basis ι ℚ V) (c : ι → δ) (U : Submodule ℚ V) (v : κ → V) + (hspan : Submodule.span ℚ (Set.range v) = U) (hU : BasisBlockInvariant b c U) + {H : ℕ} (hH : 1 ≤ H) (hv : ∀ j i, RationalHeightLE (b.repr (v j) i) H) : + ∃ Q : Matrix ι ι ℚ, Q * Q = Q ∧ + LinearMap.ker Q.mulVecLin = U.map b.equivFun.toLinearMap ∧ + (∀ i j, c i ≠ c j → Q i j = 0) ∧ + ∀ i j, RationalHeightLE (Q i j) + (imageDefiningHeight (Fintype.card ι * Fintype.card κ) (Fintype.card ι) H) := by + classical + let v' := blockSpanningFamily b c v + let A : Matrix ι (ι × κ) ℚ := fun i j => b.repr (v' j) i + have hA : ∀ i j, RationalHeightLE (A i j) H := + fun i j => blockSpanningFamily_height b c v hH hv j i + have hAb : ∀ i j, c i ≠ c j.1 → A i j = 0 := by + intro i j hij + exact (blockSpanningFamily_repr b c v j i).trans (ite_eq_right hij) + have he := exists_bounded_block_quotient_projection c (fun j : ι × κ => c j.1) A hAb hH hA + obtain ⟨Q, hQQ, hker, hblock, hQ⟩ := he + refine ⟨Q, hQQ, hker.trans ?_, hblock, ?_⟩ + · rw [Matrix.range_mulVecLin, ← blockSpanningFamily_span b c U v hspan hU, + Submodule.map_span, ← Set.range_comp] + rfl + · simpa only [Fintype.card_prod] using hQ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem exists_real_block_span_defining_matrix {ι κ δ : Type*} [Fintype ι] [Fintype κ] + (r : ι → δ) (c : κ → δ) (A : Matrix ι κ ℚ) + (hblock : ∀ i j, r i ≠ c j → A i j = 0) {H : ℕ} (hH : 1 ≤ H) + (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ Q : Matrix ι ι ℚ, + (∀ i j, RationalHeightLE (Q i j) (imageDefiningHeight (Fintype.card κ) (Fintype.card ι) H)) ∧ + (∀ i j, r i ≠ r j → Q i j = 0) ∧ + LinearMap.ker (Matrix.mulVecLin (fun i j => (Q i j : ℝ))) = + LinearMap.range (Matrix.mulVecLin (fun i j => (A i j : ℝ))) := by + classical + obtain ⟨S, hS, hSb, hSH⟩ := exists_bounded_block_image_section r c A hblock hH hA + let Q : Matrix ι ι ℚ := 1 - A * S + have hSr := real_matrix_image_section A S hS + have hQr : Matrix.of (fun i j => (Q i j : ℝ)) = + 1 - Matrix.of (fun i j => (A i j : ℝ)) * Matrix.of (fun i j => (S i j : ℝ)) := by + ext i j + by_cases hij : i = j <;> + simp [Q, Matrix.sub_apply, Matrix.mul_apply, Matrix.one_apply, hij] + refine ⟨Q, ?_, ?_, ?_⟩ + · intro i j + have hI : RationalHeightLE ((1 : Matrix ι ι ℚ) i j) 1 := by + by_cases hij : i = j + · simpa [Matrix.one_apply, hij] using rationalHeightLE_one (by decide : 1 ≤ 1) + · simpa [Matrix.one_apply, hij] using rationalHeightLE_zero (by decide : 1 ≤ 1) + have hprod := rationalHeightLE_matrix_mul A S hA hSH i j + simpa only [Q, Matrix.sub_apply, imageDefiningHeight, mul_one] using hI.sub hprod + · intro i j hij + have hne : i ≠ j := fun h => hij (congrArg r h) + have hprod : (A * S) i j = 0 := by + apply Finset.sum_eq_zero + intro k _ + by_cases hik : r i = c k + · exact (congrArg (fun x : ℚ => A i k * x) + (hSb k j (fun hkj => hij (hik.trans hkj)))).trans (mul_zero _) + · exact (congrArg (fun x : ℚ => x * S k j) (hblock i k hik)).trans (zero_mul _) + simp only [Q, Matrix.sub_apply, Matrix.one_apply, hne, ↓reduceIte, hprod, sub_self] + · ext x + change Matrix.of (fun i j => (Q i j : ℝ)) *ᵥ x = 0 ↔ + ∃ y, Matrix.of (fun i j => (A i j : ℝ)) *ᵥ y = x + rw [hQr, Matrix.sub_mulVec, Matrix.one_mulVec, ← Matrix.mulVec_mulVec] + constructor + · intro hx + exact ⟨(fun i j => (S i j : ℝ)) *ᵥ x, (sub_eq_zero.mp hx).symm⟩ + · rintro ⟨y, rfl⟩ + rw [Matrix.mulVec_mulVec, Matrix.mulVec_mulVec, hSr, sub_self] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {V ι : Type*} [AddCommGroup V] [Module ℚ V] [Fintype ι] + (b : Basis ι ℚ V) (U : Submodule ℚ V) (Q : Matrix ι ι ℚ) + (hker : LinearMap.ker Q.mulVecLin = U.map b.equivFun.toLinearMap) + +noncomputable def quotientProjectionEquiv : + (V ⧸ U) ≃ₗ[ℚ] LinearMap.range Q.mulVecLin := + (Submodule.Quotient.equiv U (U.map b.equivFun.toLinearMap) b.equivFun rfl).trans + ((Submodule.quotEquivOfEq _ _ hker.symm).trans Q.mulVecLin.quotKerEquivRange) + +theorem quotientProjectionEquiv_mk (x : V) : + (quotientProjectionEquiv b U Q hker (U.mkQ x) : ι → ℚ) = Q *ᵥ b.equivFun x := by + change (Q.mulVecLin.quotKerEquivRange (Submodule.Quotient.mk (b.equivFun x)) : ι → ℚ) = _ + rfl + +theorem quotientProjectionEquiv_symm (hQ : Q * Q = Q) (y : LinearMap.range Q.mulVecLin) : + (quotientProjectionEquiv b U Q hker).symm y = U.mkQ (b.equivFun.symm y.val) := by + apply (quotientProjectionEquiv b U Q hker).injective + rw [LinearEquiv.apply_symm_apply] + apply Subtype.ext + rw [quotientProjectionEquiv_mk, LinearEquiv.apply_symm_apply] + obtain ⟨x, hx⟩ := y.property + change Q *ᵥ x = y.val at hx + rw [← hx, Matrix.mulVec_mulVec, hQ] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankDependentInputBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankDependentInputBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..e178afdf40cfdc77531058172ccb422357b68a3c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankDependentInputBudget.lean @@ -0,0 +1,52 @@ +import OAI.Combinatorics.Progressions.Dynamics.SparseGeneratorBudget + +namespace OAI + +section + +namespace Erdos3 + +def rankDependentInputBudget (z : ℝ) : ℝ := + 2 * z + 2 * (z + ((z + 2) ^ 3 + (z + 2) ^ 36)) + + ((z + 2) ^ 3 + (z + 2) ^ 18 + z) + 2 + +theorem rankDependentInputBudget_bounds {z : ℝ} (hz : 0 ≤ z) : + 0 ≤ rankDependentInputBudget z ∧ z ≤ rankDependentInputBudget z ∧ + 2 * z ≤ rankDependentInputBudget z ∧ + 2 * (z + ((z + 2) ^ 3 + (z + 2) ^ 36)) ≤ rankDependentInputBudget z ∧ + 2 * (Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z)) ≤ + Real.exp (rankDependentInputBudget z) := by + let D := 2 * (z + ((z + 2) ^ 3 + (z + 2) ^ 36)) + let L := (z + 2) ^ 3 + (z + 2) ^ 18 + z + have hD : 0 ≤ D := by dsimp only [D]; positivity + have hzL : z ≤ L := by + dsimp only [L] + have h₁ : 0 ≤ (z + 2) ^ 3 := by positivity + have h₂ : 0 ≤ (z + 2) ^ 18 := by positivity + linarith + have hL : 0 ≤ L := hz.trans hzL + have hbudget : rankDependentInputBudget z = 2 * z + D + L + 2 := rfl + have hLbudget : L + 2 ≤ rankDependentInputBudget z := by rw [hbudget]; linarith + refine ⟨by rw [hbudget]; linarith, by rw [hbudget]; linarith, + by rw [hbudget]; linarith, ?_, ?_⟩ + · change D ≤ _ + rw [hbudget] + linarith + · have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hsum : Real.exp z + Real.exp L ≤ Real.exp (L + 1) := by + calc + Real.exp z + Real.exp L ≤ 2 * Real.exp L := by + linarith [Real.exp_le_exp.mpr hzL] + _ ≤ Real.exp 1 * Real.exp L := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = Real.exp (L + 1) := (mul_comm _ _).trans (Real.exp_add L 1).symm + calc + 2 * (Real.exp z + Real.exp L) ≤ 2 * Real.exp (L + 1) := mul_le_mul_of_nonneg_left hsum (by norm_num) + _ ≤ Real.exp 1 * Real.exp (L + 1) := mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = Real.exp (L + 2) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp (rankDependentInputBudget z) := Real.exp_le_exp.mpr hLbudget + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankHorizontalRepresentatives.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankHorizontalRepresentatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b6cd6f079024d1e0e70043088d3d1f20b6dc285 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankHorizontalRepresentatives.lean @@ -0,0 +1,140 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeProductCoefficient + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s n r : ℕ} + {D : RationalFilteredNilmanifold L s n} (R : D.DegreeRankStructure r) + +theorem exists_rank_two_basis (d : Fin (s + 1)) (hd : 1 ≤ d.val) {p : ℝ} + (hR : R.ComplexityLE p) : + ∃ b : Basis (Fin (finrank ℚ (R.filtration.layer d.val 2))) ℚ (R.filtration.layer d.val 2), + ∀ j k, rationalLogHeight (D.basis.repr (b j : L) k) ≤ p := by + by_cases hs : 2 < s + 1 + · exact ⟨R.basis d ⟨2, hs⟩, hR.2 d ⟨2, hs⟩⟩ + · have hbot : R.filtration.layer d.val 2 = ⊥ := by + apply bot_unique + calc + R.filtration.layer d.val 2 ≤ R.filtration.layer s (r + 1) := + R.filtration.lex_antitone (Or.inr ⟨by omega, by have hr := R.filtration.rank_le_degree; omega⟩) + _ = ⊥ := R.filtration.terminal + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let b := Module.finBasis ℚ (R.filtration.layer d.val 2) + refine ⟨b, fun j k => ?_⟩ + have hb : (b j : L) = 0 := by + have h := (b j).property + simpa only [hbot, Submodule.mem_bot] using h + rw [hb] + simpa [rationalLogHeight] using (Nat.cast_nonneg n).trans hR.1.1 + +theorem exists_horizontal_ambient_basis (d : Fin (s + 1)) (hd : 1 ≤ d.val) + {p : ℝ} (hp : 0 ≤ p) (hR : R.ComplexityLE p) : + ∃ H : ℕ, 1 ≤ H ∧ (H : ℝ) ≤ Real.exp ((p + 3) ^ 7) ∧ + ∃ m : ℕ, m ≤ n ∧ ∃ f : Basis (Fin m) ℚ (L ⧸ R.filtration.layer d.val 2), + ∀ i j, RationalHeightLE (f.repr ((R.filtration.layer d.val 2).mkQ (D.basis j)) i) H := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + obtain ⟨b, hb⟩ := R.exists_rank_two_basis d hd hR + have hdim : (finrank ℚ (R.filtration.layer d.val 2) : ℝ) ≤ p + 1 := by + calc + _ ≤ (finrank ℚ L : ℝ) := by exact_mod_cast Submodule.finrank_le (R.filtration.layer d.val 2) + _ = n := by rw [finrank_eq_card_basis D.basis, Fintype.card_fin] + _ ≤ p + 1 := hR.1.1.trans (by linarith) + obtain ⟨H, hH, hHp, m, hm, f, hf⟩ := exists_submodule_quotient_basis_exp D.basis + (R.filtration.layer d.val 2) (fun j => (b j : L)) + (span_submodule_basis (R.filtration.layer d.val 2) b) (one_le_ceil_exp p) + (fun j k => rationalHeightLE_ceil_exp (hb j k)) (by linarith : 0 ≤ p + 1) + (by simpa only [Fintype.card_fin] using hdim) (ceil_exp_le_exp_add_one hp) + refine ⟨H, hH, ?_, m, ?_, f, hf⟩ + · convert hHp using 2 + ring + · simpa only [Fintype.card_fin] using hm + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s n r : ℕ} + {D : RationalFilteredNilmanifold L s n} (R : D.DegreeRankStructure r) + +theorem exists_controlled_horizontal_representatives + {σ : Type*} (d : Fin (s + 1)) (hd : 1 ≤ d.val) + {p : ℝ} (hp : 0 ≤ p) (hR : R.ComplexityLE p) + {t : ℕ} (ht : t ≤ n) (f : Basis (Fin t) ℚ (L ⧸ R.filtration.layer d.val 2)) + (hf : ∀ i j, rationalLogHeight (f.repr ((R.filtration.layer d.val 2).mkQ (D.basis j)) i) ≤ p) + {l : ℕ} (hl : 0 < l) (hlp : (l : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, Real.exp (separationBudget ((p + 3) ^ 4)) ≤ T i) : + let P : ℝ := (p + 3) ^ 4 + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp (P + ((P + 2) ^ 3 + (P + 2) ^ 36)) ∧ l ∣ m ∧ + ∀ (α : σ →₀ ℕ), α ≠ 0 → + ∀ (x y z : ℝ ⊗[ℚ] R.filtration.HigherHorizontal d.val) (a q : Fin t → ℝ), + R.filtration.realHigherHorizontalCoordinates d.val f (x - y - z) = a + q → + ‖a‖ ≤ Real.exp P / monomialScale T α → q ∈ realDenominatorGrid l → + ∃ E Q : (R.filtration.layer d.val 1).baseChange ℝ, + R.filtration.realHigherHorizontalCoordinates d.val f + (R.filtration.realHorizontalMap d.val E) = a ∧ + R.filtration.realHigherHorizontalCoordinates d.val f + (R.filtration.realHorizontalMap d.val Q) = q ∧ + x - y - R.filtration.realHorizontalMap d.val E - + R.filtration.realHorizontalMap d.val Q = z ∧ + ‖(D.basis.baseChange ℝ).equivFun E.val‖ ≤ + Real.exp ((P + 2) ^ 3 + (P + 2) ^ 18 + P) / monomialScale T α ∧ + (D.basis.baseChange ℝ).equivFun Q.val ∈ realDenominatorGrid m := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let b := R.basis d ⟨1, by omega⟩ + let v : Fin (finrank ℚ (R.filtration.layer d.val 1)) → L := fun j => b j + let K := ⌈Real.exp p⌉₊ + let H := max K ((n + 1) * (K * K) ^ n) + let P : ℝ := (p + 3) ^ 4 + have hP : p + 1 ≤ P := by + simpa only [P, show p + 1 + 2 = p + 3 by ring] using + le_power_budget (p := p + 1) (by linarith) (by decide : 1 ≤ 4) + have hpP : p ≤ P := (by linarith : p ≤ p + 1).trans hP + have hn : (n : ℝ) ≤ p := hR.1.1 + have hvdim : finrank ℚ (R.filtration.layer d.val 1) ≤ n := by + simpa only [finrank_eq_card_basis D.basis, Fintype.card_fin] using + Submodule.finrank_le (R.filtration.layer d.val 1) + have hH : 1 ≤ H := (one_le_ceil_exp p).trans (Nat.le_max_left _ _) + have hHP : (H : ℝ) ≤ Real.exp P := by + change ((max K (replicatedFrequencyHeight n K) : ℕ) : ℝ) ≤ Real.exp P + rw [Nat.cast_max] + exact max_le ((ceil_exp_le_exp_add_one hp).trans (Real.exp_le_exp.mpr hP)) + (replicatedFrequencyHeight_ceil_exp n hp hn) + have hvH : ∀ j i, RationalHeightLE (D.basis.repr (v j) i) H := by + intro j i + exact (rationalHeightLE_ceil_exp (hR.2 d ⟨1, by omega⟩ j i)).mono (Nat.le_max_left _ _) + have hfH : ∀ j i, + RationalHeightLE (R.filtration.ambientHorizontalCoordinates d.val f (v j) i) H := by + intro j i + have h := linearMap_coordinate_height D.basis f (R.filtration.layer d.val 2).mkQ + (fun j i => rationalHeightLE_ceil_exp (hf i j)) (v j) + (fun i => rationalHeightLE_ceil_exp (hR.2 d ⟨1, by omega⟩ j i)) i + exact (show RationalHeightLE + (R.filtration.ambientHorizontalCoordinates d.val f (v j) i) + ((n + 1) * (K * K) ^ n) from by + simpa only [Fintype.card_fin, DegreeRankLieFiltration.ambientHorizontalCoordinates, + LinearMap.comp_apply, LinearEquiv.coe_coe, Basis.equivFun_apply] using h).mono + (Nat.le_max_right _ _) + exact R.filtration.exists_controlled_horizontal_lifts d.val f D.basis v + (span_submodule_basis _ b) hH hl hvH hfH (hp.trans hpP) + (by simpa only [Fintype.card_fin] using hn.trans hpP) + (by simpa only [Fintype.card_fin] using (Nat.cast_le.mpr ht).trans (hn.trans hpP)) + (by simpa only [Fintype.card_fin] using (Nat.cast_le.mpr hvdim).trans (hn.trans hpP)) + hHP (hlp.trans (Real.exp_le_exp.mpr hpP)) T hT + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankHorizontalSymbol.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankHorizontalSymbol.lean new file mode 100644 index 0000000000000000000000000000000000000000..16bdff9bfdb74e98da0abb74678ade3c90f9d6f2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankHorizontalSymbol.lean @@ -0,0 +1,113 @@ +import OAI.Combinatorics.Progressions.Polynomial.ShiftedPolynomialBasis + +namespace OAI + +section + +namespace Erdos3.DegreeRankLieFiltration + +open VectorPolynomial +open scoped BigOperators + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) + +noncomputable def rankLayerCoefficient (w : σ → ℕ) (α : σ →₀ ℕ) : + F.associatedDegree.adaptedLieSubalgebra w →ₗ[ℚ] F.layer (Finsupp.weight w α) 1 := + (F.associatedDegree.adaptedCoefficientMap w α).codRestrict (F.layer (Finsupp.weight w α) 1) (by + intro p + rw [← F.rank_zero_eq_one] + exact p.property α) + +@[simp] theorem rankLayerCoefficient_coe (w : σ → ℕ) (α : σ →₀ ℕ) + (p : F.associatedDegree.adaptedLieSubalgebra w) : + (F.rankLayerCoefficient w α p : L) = coefficients p.val α := rfl + +noncomputable def higherHorizontalCoefficient (w : σ → ℕ) (α : σ →₀ ℕ) : + F.associatedDegree.adaptedLieSubalgebra w →ₗ[ℚ] F.HigherHorizontal (Finsupp.weight w α) := + (F.higherHorizontalMk (Finsupp.weight w α)).comp (F.rankLayerCoefficient w α) + +theorem bracket_coefficient_mem_rank_two (w : σ → ℕ) + (p q : F.associatedDegree.adaptedLieSubalgebra w) (α : σ →₀ ℕ) : + coefficients ⁅p.val, q.val⁆ α ∈ F.layer (Finsupp.weight w α) 2 := by + classical + have hmono (β : σ →₀ ℕ) (x : L) (hx : x ∈ F.layer (Finsupp.weight w β) 2) : + coefficients (monomial (R := ℚ) β x) α ∈ F.layer (Finsupp.weight w α) 2 := by + by_cases hβα : β = α + · subst β + simpa using hx + · simp [hβα] + rw [← sum_monomial_coefficients p.val, ← sum_monomial_coefficients q.val] + simp only [Finsupp.sum] + rw [sum_lie_sum (coefficients p.val).support (coefficients q.val).support + (fun β => monomial (R := ℚ) β (coefficients p.val β)) + (fun γ => monomial (R := ℚ) γ (coefficients q.val γ))] + simp only [map_sum, Finsupp.finsetSum_apply] + apply Submodule.sum_mem + intro β _ + apply Submodule.sum_mem + intro γ _ + rw [lie_monomial] + apply hmono + rw [map_add] + exact F.lie_mem (F.rankLayerCoefficient w β p).property (F.rankLayerCoefficient w γ q).property + +theorem higherHorizontalCoefficient_lie (w : σ → ℕ) (α : σ →₀ ℕ) + (p q : F.associatedDegree.adaptedLieSubalgebra w) : + F.higherHorizontalCoefficient w α ⁅p, q⁆ = 0 := by + apply (Submodule.Quotient.mk_eq_zero _).mpr + exact F.bracket_coefficient_mem_rank_two w p q α + +end Erdos3.DegreeRankLieFiltration + +end + +section + +namespace Erdos3.DegreeRankLieFiltration + +open VectorPolynomial + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) + +noncomputable def higherHorizontalSymbolCoefficient (w : σ → ℕ) (α : σ →₀ ℕ) : + F.associatedDegree.PolynomialSymbol w →ₗ[ℚ] F.HigherHorizontal (Finsupp.weight w α) := + (F.associatedDegree.shiftedAdaptedIdeal w).toSubmodule.liftQ + (F.higherHorizontalCoefficient w α) (by + intro p hp + apply (Submodule.Quotient.mk_eq_zero _).mpr + exact F.lex_antitone (Or.inl (Nat.lt_succ_self (Finsupp.weight w α))) (hp α)) + +@[simp] theorem higherHorizontalSymbolCoefficient_map (w : σ → ℕ) (α : σ →₀ ℕ) + (p : F.associatedDegree.adaptedLieSubalgebra w) : + F.higherHorizontalSymbolCoefficient w α (F.associatedDegree.polynomialSymbolMap w p) = + F.higherHorizontalCoefficient w α p := rfl + +theorem higherHorizontalSymbolCoefficient_lie (w : σ → ℕ) (α : σ →₀ ℕ) + (p q : F.associatedDegree.PolynomialSymbol w) : + F.higherHorizontalSymbolCoefficient w α ⁅p, q⁆ = 0 := by + obtain ⟨p, rfl⟩ := F.associatedDegree.polynomialSymbolMap_surjective w p + obtain ⟨q, rfl⟩ := F.associatedDegree.polynomialSymbolMap_surjective w q + rw [← LieHom.map_lie, F.higherHorizontalSymbolCoefficient_map] + exact F.higherHorizontalCoefficient_lie w α p q + +theorem higherHorizontalCoefficient_translate (w : σ → ℕ) (hw : ∀ i, 0 < w i) + (h : σ → ℚ) (α : σ →₀ ℕ) (p : F.associatedDegree.adaptedLieSubalgebra w) : + F.higherHorizontalCoefficient w α + ⟨translate h p.val, (F.associatedDegree.mem_adaptedSubmodule w _).mpr + (F.associatedDegree.adapted_translate w hw h + ((F.associatedDegree.mem_adaptedSubmodule w _).mp p.property))⟩ = + F.higherHorizontalCoefficient w α p := by + apply (F.higherHorizontalMk_eq _ _ _).mpr + have hnext := F.associatedDegree.translate_sub_coefficient_mem w hw h + ((F.associatedDegree.mem_adaptedSubmodule w _).mp p.property) α + have hrank := F.lex_antitone (i := 2) (j := 0) + (Or.inl (Nat.lt_succ_self (Finsupp.weight w α))) hnext + simpa only [rankLayerCoefficient_coe, map_sub, Finsupp.sub_apply] using hrank + +end Erdos3.DegreeRankLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankIntervalFactorization.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankIntervalFactorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f6772ec326d0706018c9d4fcb85e7c01de713d5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankIntervalFactorization.lean @@ -0,0 +1,811 @@ +import OAI.Combinatorics.Progressions.Geometry.UnitIntervalBox +import OAI.Combinatorics.Progressions.Linear.NativeRankRelationExistence +import OAI.Combinatorics.Progressions.Linear.RankUnadaptedFactorization +import OAI.Combinatorics.Progressions.Nilpotent.NativeRankZeroNiltest + +namespace OAI + +section + +namespace Erdos3 + +def rankIntervalInputBudget (c : ℕ) (p : ℝ) : ℝ := + (p + c) ^ c + raisedNiltestBudget p + p + 5 + +theorem rankIntervalInputBudget_bounds (c : ℕ) {p : ℝ} (hp : 0 ≤ p) : + 5 ≤ rankIntervalInputBudget c p ∧ p + 4 ≤ rankIntervalInputBudget c p ∧ + raisedNiltestBudget p ≤ rankIntervalInputBudget c p ∧ + (p + c) ^ c ≤ rankIntervalInputBudget c p := by + have ha : 0 ≤ (p + c) ^ c := by positivity + have hb : 0 ≤ raisedNiltestBudget p := by unfold raisedNiltestBudget; positivity + unfold rankIntervalInputBudget + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +theorem exists_rank_interval_product_budget (c : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + productNiltestBudget (rankIntervalInputBudget c p) ≤ (p + C) ^ C := by + let X : Polynomial ℕ := Polynomial.X + let U := (X + Polynomial.C c) ^ c + (X + (X + 2) ^ 2 + 3) + X + 5 + let P := (U + 2) ^ 2 + U + (U + (U ^ 2 + U + 3) ^ 2) + U ^ 2 + 4 + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, fun p hp => ?_⟩ + simpa [P, U, X, Polynomial.eval₂_pow, productNiltestBudget, productObservableLipBudget, + rankIntervalInputBudget, raisedNiltestBudget] using hbound p hp + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +variable {ι : Type*} [Fintype ι] [Nonempty ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s r : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (R : ∀ i, (D i).DegreeRankStructure r) + +noncomputable def productRankLayerBasis (j k : Fin (s + 1)) : + Basis (Σ i, Fin (finrank ℚ ((R i).filtration.layer j.val k.val))) ℚ + ((DegreeRankLieFiltration.pi (fun i => (R i).filtration)).layer j.val k.val) := + (Pi.basis (fun i => (R i).basis j k)).map + (DegreeRankLieFiltration.piLayerEquiv (fun i => (R i).filtration) j.val k.val) + +noncomputable def productRankLayerFinBasis (j k : Fin (s + 1)) : + Basis (Fin (finrank ℚ + ((DegreeRankLieFiltration.pi (fun i => (R i).filtration)).layer j.val k.val))) ℚ + ((DegreeRankLieFiltration.pi (fun i => (R i).filtration)).layer j.val k.val) := + (productRankLayerBasis D R j k).reindex + (Fintype.equivFinOfCardEq (finrank_eq_card_basis (productRankLayerBasis D R j k)).symm) + +noncomputable def piRank : (pi D).DegreeRankStructure r where + filtration := DegreeRankLieFiltration.pi (fun i => (R i).filtration) + associated := by + rw [DegreeRankLieFiltration.pi_associatedDegree] + exact congrArg NilpotentLieFiltration.pi (funext (fun i => (R i).associated)) + basis := productRankLayerFinBasis D R + +theorem productRankLayerBasis_logHeight {p : ℝ} (hp : 0 ≤ p) + (hR : ∀ i, (R i).ComplexityLE p) (j k : Fin (s + 1)) + (a : Σ i, Fin (finrank ℚ ((R i).filtration.layer j.val k.val))) + (b : Σ i, Fin (d i)) : + rationalLogHeight ((Pi.basis (fun i => (D i).basis)).repr + ((productRankLayerBasis D R j k a).val) b) ≤ p := by + classical + rcases a with ⟨a, m⟩ + rcases b with ⟨b, n⟩ + simp only [productRankLayerBasis, Basis.map_apply, Pi.basis_repr] + change rationalLogHeight ((D b).basis.repr + (((Pi.basis (fun i => (R i).basis j k)) ⟨a, m⟩ b).val) n) ≤ p + rw [Pi.basis_apply] + by_cases hab : a = b + · subst b + rw [Pi.single_eq_same] + exact (hR a).2 j k m n + · rw [Pi.single_eq_of_ne (Ne.symm hab)] + simpa [rationalLogHeight] using hp + +theorem piRank_complexity {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hR : ∀ i, (R i).ComplexityLE p) : + (piRank D R).ComplexityLE ((p + 2) ^ 2) := by + refine ⟨pi_geometry D hp hι (fun i => (hR i).1), ?_⟩ + intro j k a b + change Fin (finrank ℚ + ((DegreeRankLieFiltration.pi (fun i => (R i).filtration)).layer j.val k.val)) at a + change rationalLogHeight ((productFinBasis D).repr + ((productRankLayerFinBasis D R j k a).val) b) ≤ (p + 2) ^ 2 + rw [productFinBasis, Basis.repr_reindex_apply, productRankLayerFinBasis, Basis.reindex_apply] + exact (productRankLayerBasis_logHeight D R hp hR j k _ _).trans (by nlinarith [sq_nonneg p]) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) {G : NilpotentLieFiltration L s} + +theorem orbitEquivOfEq_log (h : F = G) (w : σ → ℕ) (g : F.PolynomialOrbit w) : + (F.orbitEquivOfEq h w g).log = g.log := by + subst G + rfl + +theorem orbitEquivOfEq_translate (h : F = G) (w : σ → ℕ) (hw : ∀ i, 0 < w i) + (g : F.PolynomialOrbit w) (a : σ → ℤ) : + F.orbitEquivOfEq h w (g.translate hw a) = (F.orbitEquivOfEq h w g).translate hw a := by + subst G + rfl + +end Erdos3.NilpotentLieFiltration + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d r : ℕ} + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure r) + +theorem orbitEquiv_log (w : σ → ℕ) (g : D.filtration.realification.PolynomialOrbit w) : + (R.orbitEquiv w g).log = g.log := + D.filtration.realification.orbitEquivOfEq_log R.real_associated.symm w g + +theorem orbitEquiv_translate (w : σ → ℕ) (hw : ∀ i, 0 < w i) + (g : D.filtration.realification.PolynomialOrbit w) (a : σ → ℤ) : + R.orbitEquiv w (g.translate hw a) = (R.orbitEquiv w g).translate hw a := + D.filtration.realification.orbitEquivOfEq_translate R.real_associated.symm w hw g a + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct BigOperators + +variable {ι σ : Type*} [Fintype ι] [Nonempty ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s r : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (R : ∀ i, (D i).DegreeRankStructure r) + +theorem productProjectionHom_mem_rank (i : ι) (k j : ℕ) (g : (pi D).RealGroup) + (hg : g ∈ (piRank D R).realSubgroup k j) : + productProjectionHom D i g ∈ (R i).realSubgroup k j := by + apply baseChange_mem_of_mapsTo ((piRank D R).filtration.layer k j) + ((R i).filtration.layer k j) (liePiEval i).toLinearMap _ hg + intro x hx + exact (DegreeRankLieFiltration.mem_pi_layer (fun i => (R i).filtration) k j x).mp hx i + +variable [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + {w : σ → ℕ} + +theorem productObservable_rank_vertical (T : ∀ i, (D i).Niltest w) + (eta : ∀ i, L i →ₗ[ℚ] ℚ) + (hvert : ∀ i z, z ∈ (R i).realSubgroup s r → ∀ x, + (T i).observable (z • x) = + CircleFourier.character ((realifyFunctional (eta i) z.coord : ℝ) : CircleFourier.Circle) * + (T i).observable x) + (z : (pi D).RealGroup) (hz : z ∈ (piRank D R).realSubgroup s r) + (x : (pi D).Space) : + productObservable D T (z • x) = + CircleFourier.character ((realifyFunctional (piFrequency eta) z.coord : ℝ) : CircleFourier.Circle) * + productObservable D T x := by + have hchar : + CircleFourier.character ((realifyFunctional (piFrequency eta) z.coord : ℝ) : CircleFourier.Circle) = + ∏ i, CircleFourier.character + ((realifyFunctional (eta i) (productProjectionHom D i z).coord : ℝ) : CircleFourier.Circle) := by + rw [realify_piFrequency] + have hcoe (f : ι → ℝ) : ((∑ i, f i : ℝ) : CircleFourier.Circle) = + ∑ i, (f i : CircleFourier.Circle) := + map_sum (QuotientAddGroup.mk' (AddSubgroup.zmultiples (1 : ℝ))) f Finset.univ + simp only [hcoe, CircleFourier.character_fintype_sum, + productProjectionHom, NilpotentLieBCHGroup.realificationMap_coord] + rw [hchar, productObservable, productObservable, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [productProjection_smul] + exact hvert i _ (productProjectionHom_mem_rank D R i s r z hz) _ + +variable [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + +theorem piNiltest_rank_vertical (T : ∀ i, (D i).Niltest w) + (eta : ∀ i, L i →ₗ[ℚ] ℚ) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) + (hvert : ∀ i z, z ∈ (R i).realSubgroup s r → ∀ x, + (T i).observable (z • x) = + CircleFourier.character ((realifyFunctional (eta i) z.coord : ℝ) : CircleFourier.Circle) * + (T i).observable x) + (z : (pi D).RealGroup) (hz : z ∈ (piRank D R).realSubgroup s r) + (x : (pi D).Space) : + (piNiltest D T hp hι hT).observable (z • x) = + CircleFourier.character ((realifyFunctional (piFrequency eta) z.coord : ℝ) : CircleFourier.Circle) * + (piNiltest D T hp hι hT).observable x := + productObservable_rank_vertical D R T eta hvert z hz x + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.NativeDegreeRankFamily + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +variable {s r : ℕ} {A : Type*} {p : ℝ} (W : NativeDegreeRankFamily s r A p) + +noncomputable def fourPointFactors (out : Fin W.outputDim) (a : Fin 4 → A) (δ : ℤ) : + Fin 4 → W.model.Niltest (fun _ : Unit => 1) := + ![(W.component out (a 0)).conjugate, + (W.component out (a 1)).translate (fun _ => by decide) (fun _ => δ), + W.component out (a 2), + ((W.component out (a 3)).translate (fun _ => by decide) (fun _ => δ)).conjugate] + +noncomputable def fourPointFrequencies : Fin 4 → (W.L →ₗ[ℚ] ℚ) := + ![-W.vertical.frequency, W.vertical.frequency, W.vertical.frequency, -W.vertical.frequency] + +theorem fourPointFactors_complexity (hp : 0 ≤ p) (out : Fin W.outputDim) + (a : Fin 4 → A) (δ : ℤ) (i : Fin 4) : + (W.fourPointFactors out a δ i).ComplexityLE (p + 4) := by + fin_cases i + · exact W.component_complexity hp out (a 0) + · exact W.component_complexity hp out (a 1) + · exact W.component_complexity hp out (a 2) + · exact W.component_complexity hp out (a 3) + +theorem fourPointFactors_eval (out : Fin W.outputDim) (a : Fin 4 → A) (δ n : ℤ) : + (∏ i, (W.fourPointFactors out a δ i).eval (fun _ => n)) = + fourPointProduct (W.eval out (a 0)) (W.eval out (a 1)) + (W.eval out (a 2)) (W.eval out (a 3)) δ n := by + have hshift : (fun _ : Unit => n) + (fun _ => δ) = (fun _ => n + δ) := rfl + simp [fourPointFactors, Fin.prod_univ_succ, fourPointProduct, component_eval, hshift, mul_assoc] + +theorem fourPointFactors_vertical (out : Fin W.outputDim) (a : Fin 4 → A) (δ : ℤ) + (i : Fin 4) (z : W.model.RealGroup) (hz : z ∈ W.rank.realSubgroup s r) + (x : W.model.Space) : + (W.fourPointFactors out a δ i).observable (z • x) = + CircleFourier.character + ((realifyFunctional (W.fourPointFrequencies i) z.coord : ℝ) : CircleFourier.Circle) * + (W.fourPointFactors out a δ i).observable x := by + have h := W.vertical.vertical out z hz x + have hn : star (W.vertical.observable out (z • x)) = + CircleFourier.character + ((realifyFunctional (-W.vertical.frequency) z.coord : ℝ) : CircleFourier.Circle) * + star (W.vertical.observable out x) := by + rw [h, star_mul, realifyFunctional_neg, AddCircle.coe_neg, CircleFourier.character_neg] + exact mul_comm _ _ + fin_cases i + · exact hn + · exact h + · exact h + · exact hn + +variable [TopologicalSpace (ℝ ⊗[ℚ] (Fin 4 → W.L))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (Fin 4 → W.L))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (Fin 4 → W.L))] [T2Space (ℝ ⊗[ℚ] (Fin 4 → W.L))] + +noncomputable def fourPointNiltest (hp : 0 ≤ p) (out : Fin W.outputDim) + (a : Fin 4 → A) (δ : ℤ) : + (pi (fun _ : Fin 4 => W.model)).Niltest (fun _ : Unit => 1) := + piNiltest (fun _ : Fin 4 => W.model) (W.fourPointFactors out a δ) + (by linarith) (by simpa using hp) (W.fourPointFactors_complexity hp out a δ) + +theorem fourPointNiltest_complexity (hp : 0 ≤ p) (out : Fin W.outputDim) + (a : Fin 4 → A) (δ : ℤ) : + (W.fourPointNiltest hp out a δ).ComplexityLE (productNiltestBudget (p + 4)) := + piNiltest_complexity (fun _ : Fin 4 => W.model) (W.fourPointFactors out a δ) + (by linarith) (by simpa using hp) (W.fourPointFactors_complexity hp out a δ) + +theorem fourPointNiltest_eval (hp : 0 ≤ p) (out : Fin W.outputDim) + (a : Fin 4 → A) (δ n : ℤ) : + (W.fourPointNiltest hp out a δ).eval (fun _ => n) = + fourPointProduct (W.eval out (a 0)) (W.eval out (a 1)) + (W.eval out (a 2)) (W.eval out (a 3)) δ n := by + rw [fourPointNiltest, piNiltest_eval] + exact W.fourPointFactors_eval out a δ n + +theorem fourPointNiltest_vertical (hp : 0 ≤ p) (out : Fin W.outputDim) + (a : Fin 4 → A) (δ : ℤ) (z : (pi (fun _ : Fin 4 => W.model)).RealGroup) + (hz : z ∈ (piRank (fun _ : Fin 4 => W.model) (fun _ => W.rank)).realSubgroup s r) + (x : (pi (fun _ : Fin 4 => W.model)).Space) : + (W.fourPointNiltest hp out a δ).observable (z • x) = + CircleFourier.character + ((realifyFunctional (piFrequency W.fourPointFrequencies) z.coord : ℝ) : CircleFourier.Circle) * + (W.fourPointNiltest hp out a δ).observable x := + piNiltest_rank_vertical (fun _ : Fin 4 => W.model) (fun _ => W.rank) + (W.fourPointFactors out a δ) W.fourPointFrequencies + (by linarith) (by simpa using hp) (W.fourPointFactors_complexity hp out a δ) + (W.fourPointFactors_vertical out a δ) z hz x + +end Erdos3.NativeDegreeRankFamily + +end + +section + +namespace Erdos3.NativeDegreeRankFamily + +open Module +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +variable {κ A : Type*} {s r : ℕ} {p : ℝ} (W : NativeDegreeRankFamily s r A p) + (hs : 1 ≤ s) (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + +noncomputable def horizontalCoefficient (α : Unit →₀ ℕ) (a : A) : + ℝ ⊗[ℚ] W.rank.filtration.HigherHorizontal (Finsupp.weight (fun _ : Unit => 1) α) := + Multiplicative.toAdd (W.rank.filtration.nativeHorizontalCoefficientHom hs c τ hG (fun _ => 1) α + (W.rank.orbitEquiv (fun _ => 1) (W.orbit a))) + +theorem fourPointFactors_orbit (out : Fin W.outputDim) (a : Fin 4 → A) (δ : ℤ) (k : Fin 4) : + (W.fourPointFactors out a δ k).orbit = + ![W.orbit (a 0), (W.orbit (a 1)).translate (fun _ => Nat.zero_lt_one) (fun _ => δ), + W.orbit (a 2), (W.orbit (a 3)).translate (fun _ => Nat.zero_lt_one) (fun _ => δ)] k := by + fin_cases k <;> rfl + +theorem fourPoint_horizontalCoefficient (out : Fin W.outputDim) (a : Fin 4 → A) + (δ : ℤ) (α : Unit →₀ ℕ) (k : Fin 4) : + Multiplicative.toAdd (W.rank.filtration.nativeHorizontalCoefficientHom hs c τ hG (fun _ => 1) α + (W.rank.orbitEquiv (fun _ => 1) (W.fourPointFactors out a δ k).orbit)) = + W.horizontalCoefficient hs c τ hG α (a k) := by + rw [W.fourPointFactors_orbit] + fin_cases k + · rfl + · have h := congrArg + (fun g : W.rank.filtration.realification.associatedDegree.PolynomialOrbit (fun _ : Unit => 1) => + W.rank.filtration.nativeHorizontalCoefficientHom hs c τ hG (fun _ => 1) α g) + (W.rank.orbitEquiv_translate (fun _ : Unit => 1) (fun _ => Nat.zero_lt_one) + (W.orbit (a 1)) (fun _ => δ)) + exact congrArg Multiplicative.toAdd (h.trans + (W.rank.filtration.nativeHorizontalCoefficientHom_translate hs c τ hG + (fun _ : Unit => 1) (fun _ => Nat.zero_lt_one) α + (W.rank.orbitEquiv (fun _ => 1) (W.orbit (a 1))) (fun _ => δ))) + · rfl + · have h := congrArg + (fun g : W.rank.filtration.realification.associatedDegree.PolynomialOrbit (fun _ : Unit => 1) => + W.rank.filtration.nativeHorizontalCoefficientHom hs c τ hG (fun _ => 1) α g) + (W.rank.orbitEquiv_translate (fun _ : Unit => 1) (fun _ => Nat.zero_lt_one) + (W.orbit (a 3)) (fun _ => δ)) + exact congrArg Multiplicative.toAdd (h.trans + (W.rank.filtration.nativeHorizontalCoefficientHom_translate hs c τ hG + (fun _ : Unit => 1) (fun _ => Nat.zero_lt_one) α + (W.rank.orbitEquiv (fun _ => 1) (W.orbit (a 3))) (fun _ => δ))) + +end Erdos3.NativeDegreeRankFamily + +end + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +def rankQuadrupleParameters {N : ℕ} (t : ZMod N × ZMod N × ZMod N) : Fin 4 → ZMod N := + ![t.2.1, t.2.1 - t.1, t.2.2, t.2.2 - t.1] + +namespace NativeRankInterval + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) + +noncomputable def productModels (i : Fin I.expansion.count) : ∀ k : Option (Fin 4), + RationalFilteredNilmanifold (optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) s + (optionDimension (I.expansion.dim i) (fun _ : Fin 4 => W.dim) k) := + optionFactors ((I.expansion.model i).raiseStep (Nat.sub_le s 1)) (fun _ : Fin 4 => W.model) + +noncomputable def productRanks (i : Fin I.expansion.count) + (R₀ : ((I.expansion.model i).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r) : + ∀ k, (I.productModels i k).DegreeRankStructure r + | none => R₀ + | some _ => W.rank + +noncomputable def productTests (i : Fin I.expansion.count) : + ∀ k, (I.productModels i k).Niltest (fun _ : Unit => 1) + | none => (I.expansion.test i).raiseStep (Nat.sub_le s 1) + | some k => W.fourPointFactors out (rankQuadrupleParameters t) (cyclicBranchOffset t.1 branch) k + +noncomputable def productFrequencies (i : Fin I.expansion.count) : + ∀ k, optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k →ₗ[ℚ] ℚ + | none => 0 + | some k => W.fourPointFrequencies k + +theorem productTests_eval (i : Fin I.expansion.count) (n : ℤ) : + (∏ k, (I.productTests i k).eval (fun _ => n)) = + fourPointProduct (W.eval out t.2.1) (W.eval out (t.2.1 - t.1)) + (W.eval out t.2.2) (W.eval out (t.2.2 - t.1)) (cyclicBranchOffset t.1 branch) n * + ((I.expansion.test i).raiseStep (Nat.sub_le s 1)).eval (fun _ => n) := by + rw [Fintype.prod_option] + change ((I.expansion.test i).raiseStep (Nat.sub_le s 1)).eval (fun _ => n) * + (∏ k, (W.fourPointFactors out (rankQuadrupleParameters t) + (cyclicBranchOffset t.1 branch) k).eval (fun _ => n)) = _ + rw [W.fourPointFactors_eval] + exact mul_comm _ _ + +theorem productTests_vertical (hs : 1 ≤ s) (i : Fin I.expansion.count) + (R₀ : ((I.expansion.model i).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r) + (k : Option (Fin 4)) (z : (I.productModels i k).RealGroup) + (hz : z ∈ (I.productRanks i R₀ k).realSubgroup s r) (x : (I.productModels i k).Space) : + (I.productTests i k).observable (z • x) = + CircleFourier.character + ((realifyFunctional (I.productFrequencies i k) z.coord : ℝ) : CircleFourier.Circle) * + (I.productTests i k).observable x := by + cases k with + | none => exact (I.expansion.test i).raiseStep_rank_vertical (by omega) R₀ z hz x + | some k => + exact W.fourPointFactors_vertical out (rankQuadrupleParameters t) + (cyclicBranchOffset t.1 branch) k z hz x + +end NativeRankInterval + +end Erdos3 + +end + +section + +namespace Erdos3 + +def rankCoordinateTuple {N : ℕ} {ι : Type*} (β : ZMod N → ι → ℝ) + (t : ZMod N × ZMod N × ZMod N) : (Σ _ : Fin 4, ι) → ℝ := + fun j => β (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) j.1)) j.2 + +theorem rankCoordinateTuple_first12 {N : ℕ} {ι : Type*} (β : ZMod N → ι → ℝ) + (a b h : ZMod N) (i : ι) : rankCoordinateTuple β (b - h, b, a) ⟨0, i⟩ = β h i := by + simp [rankCoordinateTuple, rankQuadrupleParameters] + +theorem rankCoordinateTuple_first13 {N : ℕ} {ι : Type*} (β : ZMod N → ι → ℝ) + (c d h : ZMod N) (i : ι) : + rankCoordinateTuple β (c - d, h + (c - d), c) ⟨0, i⟩ = β h i := by + simp [rankCoordinateTuple, rankQuadrupleParameters] + +theorem rankCoordinateTuple_fixed12 {N : ℕ} {ι : Type*} (β : ZMod N → ι → ℝ) + (a b h h₀ : ZMod N) (j : Σ _ : ({1, 2} : Finset (Fin 4)), ι) : + rankCoordinateTuple β (b - h, b, a) ⟨j.1, j.2⟩ = + rankCoordinateTuple β (b - h₀, b, a) ⟨j.1, j.2⟩ := by + have hj := j.1.property + simp only [Finset.mem_insert, Finset.mem_singleton] at hj + rcases hj with hj | hj <;> simp [rankCoordinateTuple, rankQuadrupleParameters, hj] + +theorem rankCoordinateTuple_fixed13 {N : ℕ} {ι : Type*} (β : ZMod N → ι → ℝ) + (c d h h₀ : ZMod N) (j : Σ _ : ({1, 3} : Finset (Fin 4)), ι) : + rankCoordinateTuple β (c - d, h + (c - d), c) ⟨j.1, j.2⟩ = + rankCoordinateTuple β (c - d, h₀ + (c - d), c) ⟨j.1, j.2⟩ := by + have hj := j.1.property + simp only [Finset.mem_insert, Finset.mem_singleton] at hj + rcases hj with hj | hj <;> simp [rankCoordinateTuple, rankQuadrupleParameters, hj] + +theorem card_selected_four_le {ι : Type*} [Fintype ι] (K : Finset (Fin 4)) : + Fintype.card (Σ _ : K, ι) ≤ Fintype.card (Σ _ : Fin 4, ι) := by + let f : (Σ _ : K, ι) → (Σ _ : Fin 4, ι) := fun j => ⟨j.1, j.2⟩ + apply Fintype.card_le_of_injective f + intro x y h + exact Sigma.ext (Subtype.ext (congrArg Sigma.fst h)) + (heq_of_eq (congrArg (fun z : Σ _ : Fin 4, ι => z.2) h)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_rank_interval_product (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool}, + 0 ≤ p → b ≤ p → (I : NativeRankInterval W out H t branch p p) → + ∃ i : Fin I.expansion.count, + ∃ R₀ : ((I.expansion.model i).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r, + R₀.ComplexityLE ((p + C) ^ C) ∧ R₀.realSubgroup s r = ⊥ ∧ + letI : FiniteDimensional ℚ + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) := + (productFinBasis (I.productModels i)).finiteDimensional_of_finite + letI := moduleTopology ℝ (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI : T2Space (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) := + realification_moduleTopology_t2 (productFinBasis (I.productModels i)) + ∃ T : (pi (I.productModels i)).Niltest (fun _ : Unit => 1), + T.ComplexityLE ((p + C) ^ C) ∧ + (piRank (I.productModels i) (I.productRanks i R₀)).ComplexityLE ((p + C) ^ C) ∧ + T.orbit = NilpotentLieFiltration.piRealOrbit (fun k => (I.productModels i k).filtration) + (fun k => (I.productTests i k).orbit) ∧ + (∀ n, T.eval (fun _ => n) = + fourPointProduct (W.eval out t.2.1) (W.eval out (t.2.1 - t.1)) + (W.eval out t.2.2) (W.eval out (t.2.2 - t.1)) (cyclicBranchOffset t.1 branch) n * + ((I.expansion.test i).raiseStep (Nat.sub_le s 1)).eval (fun _ => n)) ∧ + (∀ z ∈ (piRank (I.productModels i) (I.productRanks i R₀)).realSubgroup s r, ∀ x, + T.observable (z • x) = CircleFourier.character + ((realifyFunctional (piFrequency (I.productFrequencies i)) z.coord : ℝ) : + CircleFourier.Circle) * T.observable x) ∧ + Real.exp (-(2 * p)) ≤ + ‖𝔼 x ∈ translatedIntegerBox (fun _ : Unit => (I.start : ℤ)) (fun _ => I.length), T.eval x‖ := by + obtain ⟨c, _, hlower⟩ := exists_rank_interval_raised_lower_term s hs + obtain ⟨C, hC, hbudget⟩ := exists_rank_interval_product_budget c + refine ⟨C, hC, ?_⟩ + intro r N _ b p W out H t branch hp hbp I + obtain ⟨i, R₀, hR₀, hzero, hT₀, hcorr⟩ := hlower I + let u := rankIntervalInputBudget c p + obtain ⟨hu5, hup, huraise, hurank⟩ := rankIntervalInputBudget_bounds c hp + have hu : 0 ≤ u := (by norm_num : (0 : ℝ) ≤ 5).trans hu5 + have hub : u ≤ productNiltestBudget u := by + have hg := productNiltestBudget_geometry hu + nlinarith [sq_nonneg u] + have hcost : productNiltestBudget u ≤ (p + C) ^ C := hbudget p hp + have hsmall : u ≤ (p + C) ^ C := hub.trans hcost + have hb : 0 ≤ b := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + have hbu : b ≤ u := hbp.trans (by linarith) + have hcard : (Fintype.card (Option (Fin 4)) : ℝ) ≤ u := by + simpa using hu5 + have htests : ∀ k, (I.productTests i k).ComplexityLE u := by + intro k + cases k with + | none => exact hT₀.mono huraise + | some k => exact (W.fourPointFactors_complexity hb out (rankQuadrupleParameters t) + (cyclicBranchOffset t.1 branch) k).mono (by linarith) + have hranks : ∀ k, (I.productRanks i R₀ k).ComplexityLE u := by + intro k + cases k with + | none => exact hR₀.mono R₀ hurank + | some _ => exact W.complexity.mono W.rank hbu + refine ⟨i, R₀, hR₀.mono R₀ (hurank.trans hsmall), hzero, ?_⟩ + let : FiniteDimensional ℚ + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) := + (productFinBasis (I.productModels i)).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) := + realification_moduleTopology_t2 (productFinBasis (I.productModels i)) + let T := piNiltest (I.productModels i) (I.productTests i) hu hcard htests + have heval (n : ℤ) : T.eval (fun _ => n) = + fourPointProduct (W.eval out t.2.1) (W.eval out (t.2.1 - t.1)) + (W.eval out t.2.2) (W.eval out (t.2.2 - t.1)) (cyclicBranchOffset t.1 branch) n * + ((I.expansion.test i).raiseStep (Nat.sub_le s 1)).eval (fun _ => n) := + (piNiltest_eval (I.productModels i) (I.productTests i) hu hcard htests _).trans + (I.productTests_eval i n) + refine ⟨T, (piNiltest_complexity _ _ hu hcard htests).mono hcost, + (piRank_complexity _ _ hu hcard hranks).mono (piRank (I.productModels i) (I.productRanks i R₀)) + ((productNiltestBudget_geometry hu).trans hcost), rfl, heval, ?_, ?_⟩ + · exact piNiltest_rank_vertical _ _ _ _ hu hcard htests (I.productTests_vertical hs i R₀) + · rw [unitIntervalBox_expect] + simpa only [heval, two_mul] using hcorr + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankInterval + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + +noncomputable def productOrbit : + (pi (I.productModels i)).filtration.realification.PolynomialOrbit (fun _ : Unit => 1) := + NilpotentLieFiltration.piRealOrbit (fun k => (I.productModels i k).filtration) + (fun k => (I.productTests i k).orbit) + +noncomputable def productSymbol {κ : Type*} + (e : Basis κ ℚ (∀ k : Option (Fin 4), + optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) (ω : κ → ℕ) + (hF : ∀ j, (pi (I.productModels i)).filtration.layer j = + Submodule.span ℚ (e '' {a | j ≤ ω a})) : + (pi (I.productModels i)).filtration.RealPolynomialSymbolGroup (fun _ : Unit => 1) := + (pi (I.productModels i)).filtration.realPolynomialSymbolHom e ω hF (fun _ => 1) + ⟨⟨(I.productOrbit i).log, (I.productOrbit i).property⟩⟩ + +variable [TopologicalSpace (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k))] + [T2Space (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k))] + +theorem productSymbol_eq {κ : Type*} + (e : Basis κ ℚ (∀ k : Option (Fin 4), + optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) (ω : κ → ℕ) + (hF : ∀ j, (pi (I.productModels i)).filtration.layer j = + Submodule.span ℚ (e '' {a | j ≤ ω a})) + (T : (pi (I.productModels i)).Niltest (fun _ : Unit => 1)) (hT : T.orbit = I.productOrbit i) : + T.symbol e ω hF = I.productSymbol i e ω hF := by + unfold RationalFilteredNilmanifold.Niltest.symbol productSymbol + apply congrArg ((pi (I.productModels i)).filtration.realPolynomialSymbolHom e ω hF (fun _ => 1)) + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + exact congrArg (fun o : (pi (I.productModels i)).filtration.realification.PolynomialOrbit + (fun _ : Unit => 1) => o.log) hT + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3.NativeRankInterval + +open RationalFilteredNilmanifold +open scoped BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + +def rankProjection : + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) →ₗ⁅ℚ⁆ + (Fin 4 → W.L) := + liePiMap (fun k : Fin 4 => liePiEval (R := ℚ) + (M := optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L)) + (some ((![1, 2, 0, 3] : Fin 4 → Fin 4) k))) + +theorem rankProjection_frequency + (x : ∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) : + piFrequency (I.productFrequencies i) x = + W.vertical.frequency (I.rankProjection i x 0) + W.vertical.frequency (I.rankProjection i x 1) - + W.vertical.frequency (I.rankProjection i x 2) - W.vertical.frequency (I.rankProjection i x 3) := by + rw [piFrequency_apply, Fintype.sum_option] + simp only [Fin.sum_univ_succ] + change 0 + (-W.vertical.frequency (x (some 0)) + + (W.vertical.frequency (x (some 1)) + (W.vertical.frequency (x (some 2)) + + (-W.vertical.frequency (x (some 3)) + 0)))) = + W.vertical.frequency (x (some 1)) + W.vertical.frequency (x (some 2)) - + W.vertical.frequency (x (some 0)) - W.vertical.frequency (x (some 3)) + ring + +theorem rankProjection_mem_layer (d : ℕ) + (x : ∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) + (hx : x ∈ (pi (I.productModels i)).filtration.layer d) (k : Fin 4) : + I.rankProjection i x k ∈ W.rank.filtration.layer d 1 := by + have h := (NilpotentLieFiltration.mem_pi_layer (fun j => (I.productModels i j).filtration) d x).mp hx + (some ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)) + change I.rankProjection i x k ∈ W.model.filtration.layer d at h + rw [← W.rank.associated] at h + change I.rankProjection i x k ∈ W.rank.filtration.layer d 0 at h + rwa [W.rank.filtration.rank_zero_eq_one] at h + +theorem rankProjection_mem_refiltered + (U : LieSubalgebra ℚ (pi (I.productModels i)).filtration.AssociatedGraded) (d : ℕ) + (x : ∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) + (hx : x ∈ (pi (I.productModels i)).filtration.gradedRefiltrationLayer U d) (k : Fin 4) : + I.rankProjection i x k ∈ W.rank.filtration.layer d 1 := + I.rankProjection_mem_layer i d x + ((pi (I.productModels i)).filtration.gradedRefiltrationLayer_le U d hx) k + +end Erdos3.NativeRankInterval + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +theorem exists_rank_interval_factorization (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {r N : ℕ} [NeZero N] {b p : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool}, + 0 ≤ p → b ≤ p → (I : NativeRankInterval W out H t branch p p) → + Real.exp ((p + C) ^ C) ≤ (I.length : ℝ) → + ∃ i : Fin I.expansion.count, + ∃ R₀ : ((I.expansion.model i).raiseStep (Nat.sub_le s 1)).DegreeRankStructure r, + R₀.ComplexityLE ((p + C) ^ C) ∧ R₀.realSubgroup s r = ⊥ ∧ + ∃ F : (piRank (I.productModels i) (I.productRanks i R₀)).AdaptedData, + F.rank.ComplexityLE ((p + C) ^ C) ∧ + (∀ j k, rationalLogHeight ((pi (I.productModels i)).basis.repr (F.basis j) k) ≤ + (p + C) ^ C) ∧ + (∀ k j, rationalLogHeight (F.basis.repr ((pi (I.productModels i)).basis k) j) ≤ + (p + C) ^ C) ∧ + F.rank.ControlledRankBracketFactorization F.weight F.layers + (piFrequency (I.productFrequencies i)) (fun _ : Unit => (I.length : ℝ)) + (I.productSymbol i F.basis F.weight F.layers) ((p + C) ^ C) := by + obtain ⟨a, _, hproduct⟩ := exists_rank_interval_product s hs + obtain ⟨c, _, hfactor⟩ := exists_rank_unadapted_factorization s hs + let X : Polynomial ℕ := Polynomial.X + let U := (X + Polynomial.C a) ^ a + 2 * X + 1 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (U + (U + Polynomial.C c) ^ c) + refine ⟨C, hC, ?_⟩ + intro r N _ b p W out H t branch hp hbp I hlarge + let u := (p + a) ^ a + 2 * p + 1 + have hpow : 0 ≤ (p + a) ^ a := by positivity + have hu : 0 ≤ u := by dsimp [u]; positivity + have hQu : (p + a) ^ a ≤ u := by dsimp [u]; linarith + have h2pu : 2 * p ≤ u := by dsimp [u]; linarith + have hone : 1 ≤ u := by dsimp [u]; linarith + have hsum : u + (u + c) ^ c ≤ (p + C) ^ C := by + simpa [U, X, u, Polynomial.eval₂_pow] using hbudget p hp + have hfactor0 : 0 ≤ (u + c) ^ c := by positivity + have huC : u ≤ (p + C) ^ C := by linarith + have hfactorC : (u + c) ^ c ≤ (p + C) ^ C := by linarith + obtain ⟨i, R₀, hR₀, hzero, htest⟩ := hproduct hp hbp I + let : FiniteDimensional ℚ + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k) := + (productFinBasis (I.productModels i)).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] + (∀ k : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) k)) := + realification_moduleTopology_t2 (productFinBasis (I.productModels i)) + obtain ⟨T, hT, hR, horbit, _, hvert, hbias⟩ := htest + have hbiasu : Real.exp (-u) ≤ + ‖𝔼 x ∈ translatedIntegerBox (fun _ : Unit => (I.start : ℤ)) (fun _ => I.length), T.eval x‖ := + (Real.exp_le_exp.mpr (neg_le_neg h2pu)).trans hbias + obtain ⟨F, hFR, hforward, hback, hF⟩ := hfactor (pi (I.productModels i)) + (piRank (I.productModels i) (I.productRanks i R₀)) u hu (by simpa using hone) + (hR.mono _ hQu) T (hT.mono hQu) (piFrequency (I.productFrequencies i)) hvert + (fun _ : Unit => (I.start : ℤ)) (fun _ => I.length) (fun _ => I.length_pos) + (fun _ => (Real.exp_le_exp.mpr hfactorC).trans hlarge) hbiasu + have hsymbol := I.productSymbol_eq i F.basis F.weight F.layers T horbit + rw [hsymbol] at hF + refine ⟨i, R₀, hR₀.mono R₀ (hQu.trans huC), hzero, F, hFR.mono F.rank hfactorC, + (fun j k => (hforward j k).trans hfactorC), + (fun k j => (hback k j).trans hfactorC), ?_⟩ + exact DegreeRankStructure.ControlledRankBracketFactorization.mono F.rank F.weight F.layers + hF hfactorC (fun _ => by exact_mod_cast I.length_pos) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankNativeCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankNativeCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..54e52bc63e74771069fa04079f4c5d45b9158609 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankNativeCoordinates.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.Progressions.Linear.NativeCoefficientKernel + +namespace OAI + +section + +namespace Erdos3.NativeRankInterval.SunflowerWitness + +open Module RationalFilteredNilmanifold + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {ι κ : Type*} [Fintype ι] {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + {I : NativeRankInterval W out H t branch p q} + +theorem projectedOrbitCoefficient_native_coordinates (D : I.SunflowerWitness P) + (hs : 1 ≤ s) (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = Submodule.span ℚ (c '' {i | j ≤ τ i})) + (α : Unit →₀ ℕ) + (f : Basis ι ℚ (W.L ⧸ W.rank.filtration.layer (Finsupp.weight (fun _ : Unit => 1) α) 2)) + (k : Fin 4) (i : ι) : + W.rank.filtration.realFourAmbientCoordinates (Finsupp.weight (fun _ : Unit => 1) α) f + (D.projectedOrbitCoefficient α).val ⟨k, i⟩ = + (f.baseChange ℝ).repr + ((W.rank.filtration.higherHorizontalAmbient (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ + (W.horizontalCoefficient hs c τ hG α + (rankQuadrupleParameters t ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)))) i := by + have hmap := congrFun (W.rank.filtration.realFourHorizontalCoordinates_map + (Finsupp.weight (fun _ : Unit => 1) α) f (D.projectedOrbitCoefficient α)).symm ⟨k, i⟩ + have hcomponent := W.rank.filtration.realFourHorizontalCoordinates_component + (Finsupp.weight (fun _ : Unit => 1) α) f + (W.rank.filtration.realFourHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) + (D.projectedOrbitCoefficient α)) k i + exact hmap.trans (hcomponent.trans (congrArg + (fun x => (f.baseChange ℝ).repr + ((W.rank.filtration.higherHorizontalAmbient (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ x) i) + (D.projectedOrbitCoefficient_native_component hs c τ hG α k))) + +end Erdos3.NativeRankInterval.SunflowerWitness + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankOrbitCoefficientCorrections.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankOrbitCoefficientCorrections.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d365c14331d1008ec16fc9cf88766d5095e865c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankOrbitCoefficientCorrections.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Linear.NativeCoefficientKernel + +namespace OAI + +section + +namespace Erdos3.NativeRankInterval.SunflowerWitness + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + {I : NativeRankInterval W out H t branch p q} (D : I.SunflowerWitness P) + +theorem exists_bounded_coefficient_corrections (hs : 1 ≤ s) (hP : 0 ≤ P) : + ∃ E R : ∀ α : Unit →₀ ℕ, + (W.rank.filtration.fourHorizontalLayer (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ, + (∀ α j, |(W.fourRankBasis.baseChange ℝ).repr (E α).val j| ≤ + Real.exp ((P + 3) ^ 2) / monomialScale (fun _ : Unit => (I.length : ℝ)) α) ∧ + (∀ α, (fun j => (W.fourRankBasis.baseChange ℝ).repr (R α).val j) ∈ + realDenominatorGrid D.projectedDenominator) ∧ + ∀ α, W.rank.filtration.realFourHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) + (D.projectedOrbitCoefficient α - E α - R α) ∈ + (I.refilteredHorizontalImage D.index D.subalgebra + (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ := by + obtain ⟨E, R, hE, hR, hres⟩ := D.exists_projected_corrections hs + refine ⟨D.projectedRepresentativeLayer E, D.projectedRepresentativeLayer R, ?_, ?_, ?_⟩ + · intro α j + exact D.projectedRepresentative_slow hP E hE α j + · intro α + exact D.projectedRepresentative_grid R hR α + · intro α + let f := W.rank.filtration.realFourHorizontalMap (Finsupp.weight (fun _ : Unit => 1) α) + have hinner := (map_sub f (D.projectedOrbitCoefficient α) (D.projectedRepresentativeLayer E α)).trans + (congrArg₂ (fun x y => x - y) (D.projectedOrbitCoefficient_horizontal α) + (D.projectedRepresentative_horizontal E α)) + have heq := (map_sub f (D.projectedOrbitCoefficient α - D.projectedRepresentativeLayer E α) + (D.projectedRepresentativeLayer R α)).trans + (congrArg₂ (fun x y => x - y) hinner (D.projectedRepresentative_horizontal R α)) + exact (congrArg (fun v => v ∈ (I.refilteredHorizontalImage D.index D.subalgebra + (Finsupp.weight (fun _ : Unit => 1) α)).baseChange ℝ) heq).mpr (hres α) + +end Erdos3.NativeRankInterval.SunflowerWitness + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationIteration.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ed813559d49d44c6d6076fe922ecd3894c3e823 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationIteration.lean @@ -0,0 +1,202 @@ +import OAI.Combinatorics.Progressions.Dynamics.PreparedEarlyStructuralPowerBudget +import OAI.Combinatorics.Progressions.Estimates.PreparationSliceComposition + +namespace OAI + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial +open scoped BigOperators + +theorem exists_uniform_step {I J : Type} [Fintype I] [DecidableEq I] [DecidableEq J] + {s D t T R : ℕ} {p δ : ℝ} (L : RankPreparationFamily I J s) (N : I → ℕ) + (hp : 0 ≤ p) (hR : 1 ≤ R) (hRp : (R : ℝ) ≤ Real.exp p) (hδ : 0 < δ) + (ht : t ≤ T) (hsize : L.Sized D t) (hheight : L.PreparedHeights p R) + (hM : (preparationCoordinateCap s D T : ℝ) ≤ p) + (hbad : ¬ ∀ u, HasLayerSamplingRank (u.val + 1) (fun i => (N i : ℝ)) R (L u).space (L u).poly) + (f : (∀ i, Fin (N i)) → ℝ) : + let M := preparationCoordinateCap s D T + let Q := preparationModulusCap s M R p + let C := preparationShrink s (Fintype.card I) M R p δ + (∀ i, C ≤ N i) → + ∃ (q : ℕ) (S : ResidueBoxSlice N q) (L' : RankPreparationFamily I J s) + (ip : J → MvPolynomial I ℤ) (c : J → ℝ) (err : (∀ i, Fin (S.length i)) → J → ℝ), + L'.potential + 1 ≤ L.potential ∧ L'.Sized D (t + 1) ∧ L'.PreparedHeights p R ∧ + 0 < q ∧ q ≤ Q ∧ (∀ i, 0 < S.length i ∧ (N i : ℝ) ≤ C * S.length i) ∧ + ((𝔼 x, f x) ≤ 𝔼 x : (∀ i, Fin (S.length i)), f (S.point x)) ∧ + (∀ j, (ip j).totalDegree ≤ s) ∧ (∀ x j, |err x j| ≤ M * δ) ∧ + ∀ x j, L.value (fun i => ((S.point x i).val : ℝ)) j = + L'.value (fun i => ((x i).val : ℝ)) j + + (MvPolynomial.eval (fun i => ((x i).val : ℤ)) (ip j) : ℝ) + c j + err x j := by + classical + intro M Q C hlarge + have hC := preparationShrink_one_le s (Fintype.card I) M hR hp hδ + have hN (i : I) : 0 < N i := by + have h := hC.trans (hlarge i) + exact_mod_cast h + push Not at hbad + obtain ⟨u, hfail⟩ := hbad + obtain ⟨hcoord, hcol, hrow⟩ := preparationCoordinateCap_bounds hsize ht u + let He := rankCutDirectionHeight (Fintype.card (L u).Coord) (Fintype.card (L u).Column) + (Fintype.card (L u).Row) (preparationHeight p (s - 1 - u.val)) R + obtain ⟨heNext, heGlobal⟩ := preparation_section_bound L u hp hM hRp hcoord hcol hrow + have hlargeStep (i : I) := preparation_large_side hp hδ (Nat.succ_le_of_lt u.isLt) + heGlobal hcoord (hlarge i) + have hcaps := preparation_step_caps s (Fintype.card I) M R u.val He + (Fintype.card (L u).Coord) hp hδ (Nat.succ_le_of_lt u.isLt) heGlobal hcoord + by_cases hu : u.val = 0 + · obtain ⟨a, e, q, S, ip, c, err, ha, heH, hpotential, hvalid, hq, hqbound, hlength, + hscore, hip, herr, hid⟩ := exists_absorb_slice_step L u hu N + (fun i => preparationHeight p (s - 1 - i.val)) (fun _ => preparationHeight_pos hp _) + hR hδ hN hheight hfail f hlargeStep + let L' := (L.absorb u a e).reindex S.polynomial + refine ⟨q, S, L', ip, c, err, hpotential, (hsize.absorb u a e).reindex S.polynomial, + hvalid, hq, hqbound.trans hcaps.1, ?_, hscore, ?_, ?_, hid⟩ + · intro i + exact ⟨(hlength i).1, preparation_side_loss hp hδ (Nat.succ_le_of_lt u.isLt) + heGlobal hcoord hqbound (Nat.cast_nonneg _) (hlength i).2⟩ + · intro j + exact (hip j).trans (Nat.succ_le_of_lt u.isLt) + · intro x j + exact (herr x j).trans (mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hcoord) hδ.le) + · let v : Fin s := ⟨u.val - 1, by omega⟩ + have hlevel : u.val = v.val + 1 := by dsimp [v]; omega + obtain ⟨a, e, q, S, l, ip, c, err, ha, heH, hpotential, hvalid, hq, hqbound, hlength, + hscore, hip, herr, hid⟩ := exists_descend_slice_step L u v hlevel N + (fun i => preparationHeight p (s - 1 - i.val)) (fun _ => preparationHeight_pos hp _) + hR hδ hN hheight hfail f hlargeStep + let L' := (L.descend u v a e l).reindex S.polynomial + refine ⟨q, S, L', ip, c, err, hpotential, + (hsize.descend u v hlevel a e l).reindex S.polynomial, ?_, hq, + hqbound.trans hcaps.1, ?_, hscore, ?_, ?_, hid⟩ + · intro i + apply (hvalid i).mono_height + split_ifs with hi + · subst i + apply max_le le_rfl + have hd : s - 1 - v.val = (s - 1 - u.val) + 1 := by omega + rwa [hd] + · exact le_rfl + · intro i + exact ⟨(hlength i).1, preparation_side_loss hp hδ (Nat.succ_le_of_lt u.isLt) + heGlobal hcoord hqbound (Nat.cast_nonneg _) (hlength i).2⟩ + · intro j + exact (hip j).trans (Nat.succ_le_of_lt u.isLt) + · intro x j + exact (herr x j).trans (mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hcoord) hδ.le) + +end Erdos3.RankPreparationFamily + +end + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial +open scoped BigOperators + +theorem exists_prepared_family {I J : Type} [Fintype I] [DecidableEq I] [DecidableEq J] + {s D t T R : ℕ} {p δ : ℝ} (r : ℕ) (L : RankPreparationFamily I J s) (N : I → ℕ) + (hp : 0 ≤ p) (hR : 1 ≤ R) (hRp : (R : ℝ) ≤ Real.exp p) (hδ : 0 < δ) + (hpot : L.potential ≤ r) (ht : t + r ≤ T) + (hsize : L.Sized D t) (hheight : L.PreparedHeights p R) + (hM : (preparationCoordinateCap s D T : ℝ) ≤ p) + (f : (∀ i, Fin (N i)) → ℝ) : + let M := preparationCoordinateCap s D T + let Q := preparationModulusCap s M R p + let C := preparationShrink s (Fintype.card I) M R p δ + (∀ i, C ^ (r + 1) ≤ N i) → + ∃ (q : ℕ) (S : ResidueBoxSlice N q) (L' : RankPreparationFamily I J s) + (ip : J → MvPolynomial I ℤ) (c : J → ℝ) (err : (∀ i, Fin (S.length i)) → J → ℝ), + L'.potential ≤ L.potential ∧ L'.Sized D (t + r) ∧ L'.PreparedHeights p R ∧ + (∀ u, HasLayerSamplingRank (u.val + 1) (fun i => (S.length i : ℝ)) R (L' u).space (L' u).poly) ∧ + 0 < q ∧ q ≤ Q ^ r ∧ (∀ i, 0 < S.length i ∧ (N i : ℝ) ≤ C ^ r * S.length i) ∧ + ((𝔼 x, f x) ≤ 𝔼 x : (∀ i, Fin (S.length i)), f (S.point x)) ∧ + (∀ j, (ip j).totalDegree ≤ s) ∧ (∀ x j, |err x j| ≤ r * M * δ) ∧ + ∀ x j, L.value (fun i => ((S.point x i).val : ℝ)) j = + L'.value (fun i => ((x i).val : ℝ)) j + + (MvPolynomial.eval (fun i => ((x i).val : ℤ)) (ip j) : ℝ) + c j + err x j := by + classical + intro M Q C hlarge + induction r using Nat.strong_induction_on generalizing t L N with + | h r ih => + have hC : 1 ≤ C := preparationShrink_one_le s (Fintype.card I) M hR hp hδ + have hCpos : 0 < C := lt_of_lt_of_le zero_lt_one hC + have hQ : 1 ≤ Q := Nat.mul_pos hR (pow_pos (preparationHeight_pos hp s) M) + have hN (i : I) : 0 < N i := by + have hn : (1 : ℝ) ≤ N i := (one_le_pow₀ hC).trans (hlarge i) + exact_mod_cast hn + by_cases hgood : ∀ u, HasLayerSamplingRank (u.val + 1) (fun i => (N i : ℝ)) R (L u).space (L u).poly + · refine ⟨1, ResidueBoxSlice.identity N, L, fun _ => 0, fun _ => 0, fun _ _ => 0, + le_rfl, hsize.mono (Nat.le_add_right t r), hheight, hgood, by omega, + one_le_pow₀ hQ, ?_, ?_, ?_, ?_, ?_⟩ + · intro i + refine ⟨hN i, ?_⟩ + exact le_mul_of_one_le_left (Nat.cast_nonneg _) (one_le_pow₀ hC) + · change (𝔼 x, f x) ≤ 𝔼 x : (∀ i, Fin (N i)), f ((ResidueBoxSlice.identity N).point x) + simp only [ResidueBoxSlice.identity_point, le_refl] + · intro j + simp + · intro x j + simp only [abs_zero] + positivity + · intro x j + change (∀ i, Fin (N i)) at x + simp only [ResidueBoxSlice.identity_point, map_zero, Int.cast_zero, add_zero] + · have hside (i : I) : C ≤ N i := by + have hpow : C ≤ C ^ (r + 1) := by + simpa only [pow_one] using pow_le_pow_right₀ hC (Nat.le_add_left 1 r) + exact hpow.trans (hlarge i) + obtain ⟨q₁, S₁, L₁, ip₁, c₁, e₁, hdrop, hsize₁, hheight₁, hq₁, hq₁bound, + hlength₁, hscore₁, hip₁, he₁, hid₁⟩ := + exists_uniform_step L N hp hR hRp hδ (by omega) hsize hheight hM hgood f hside + have hr : 0 < r := by omega + obtain ⟨r', hr'⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hr) + subst r + have hnext (i : I) : C ^ (r' + 1) ≤ S₁.length i := by + apply le_of_mul_le_mul_left (a := C) _ hCpos + calc + C * C ^ (r' + 1) = C ^ (r' + 1 + 1) := by rw [pow_succ]; ring + _ ≤ N i := hlarge i + _ ≤ C * S₁.length i := (hlength₁ i).2 + obtain ⟨q₂, S₂, L₂, ip₂, c₂, e₂, hpot₂, hsize₂, hheight₂, hgood₂, hq₂, + hq₂bound, hlength₂, hscore₂, hip₂, he₂, hid₂⟩ := + ih r' (Nat.lt_succ_self r') L₁ S₁.length (by omega) (by omega) hsize₁ hheight₁ + (fun x => f (S₁.point x)) hnext + refine ⟨q₁ * q₂, S₁.comp S₂, L₂, + fun j => S₂.reindexInteger (ip₁ j) + ip₂ j, fun j => c₁ j + c₂ j, + fun x j => e₁ (S₂.point x) j + e₂ x j, + hpot₂.trans (by omega), ?_, hheight₂, hgood₂, Nat.mul_pos hq₁ hq₂, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · convert hsize₂ using 1; omega + · calc + q₁ * q₂ ≤ Q * Q ^ r' := Nat.mul_le_mul hq₁bound hq₂bound + _ = Q ^ (r' + 1) := by rw [pow_succ]; ring + · intro i + refine ⟨(hlength₂ i).1, ?_⟩ + calc + (N i : ℝ) ≤ C * S₁.length i := (hlength₁ i).2 + _ ≤ C * (C ^ r' * S₂.length i) := mul_le_mul_of_nonneg_left (hlength₂ i).2 hCpos.le + _ = C ^ (r' + 1) * (S₁.comp S₂).length i := by + change C * (C ^ r' * (S₂.length i : ℝ)) = C ^ (r' + 1) * S₂.length i + rw [pow_succ] + ring + · change (𝔼 x, f x) ≤ 𝔼 x : (∀ i, Fin (S₂.length i)), f ((S₁.comp S₂).point x) + simpa only [ResidueBoxSlice.comp_point] using hscore₁.trans hscore₂ + · intro j + exact (MvPolynomial.totalDegree_add _ _).trans + (max_le (S₂.reindexInteger_degree _ (hip₁ j)) (hip₂ j)) + · intro x j + calc + |e₁ (S₂.point x) j + e₂ x j| ≤ |e₁ (S₂.point x) j| + |e₂ x j| := abs_add_le _ _ + _ ≤ M * δ + r' * M * δ := add_le_add (he₁ _ _) (he₂ _ _) + _ = (r' + 1 : ℕ) * M * δ := by push_cast; ring + · exact compose_slice_identity S₁ S₂ ip₁ ip₂ c₁ c₂ e₁ e₂ hid₁ hid₂ + +end Erdos3.RankPreparationFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationPaddedFreezingLifts.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationPaddedFreezingLifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9d93a2492a4574254692f7cfcabf2aaaf368c02 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationPaddedFreezingLifts.lean @@ -0,0 +1,333 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedExternalCandidateBufferedCoordinates + +namespace OAI + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial +open scoped BigOperators TensorProduct + +variable {X J : Type} {m q : ℕ} (L : RankPreparationFamily X J m) + +@[simp] theorem pad_polynomial [DecidableEq J] (hmq : m ≤ q) : + (L.pad q).polynomial = L.polynomial := by + apply L.pad_sum hmq (fun layer => map (coordinateCopySum layer.label) layer.poly) + change map (coordinateCopySum (R := ℝ) (PEmpty.elim : PEmpty → J)) + (0 : VectorPolynomial X ℝ (PEmpty → ℝ)) = 0 + exact map_zero _ + +theorem pad_identity [Fintype J] [DecidableEq J] (hmq : m ≤ q) + (P E : VectorPolynomial X ℝ (J → ℝ)) (ip : J → MvPolynomial X ℤ) (c : J → ℝ) + (hP : P = L.polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + E) : + P = (L.pad q).polynomial + integerCoordinates ip + (1 ⊗ₜ[ℝ] c) + E := by + simpa only [L.pad_polynomial hmq] using hP + +noncomputable def padCoordInclusion (hmq : m ≤ q) : + (Σ j, (L j).Coord) → Σ j, (L.pad q j).Coord := fun a => + ⟨a.1.castLE hmq, cast (congrArg RankPreparationLayer.Coord + (L.pad_apply_castLE hmq a.1).symm) a.2⟩ + +private theorem padCoord_isLt (a : Σ j, (L.pad q j).Coord) : a.1.val < m := by + rcases a with ⟨j, i⟩ + by_cases hj : j.val < m + · exact hj + · exact PEmpty.elim (cast (congrArg RankPreparationLayer.Coord + (L.pad_apply_ge j (by omega))) i) + +noncomputable def padCoordRestriction (a : Σ j, (L.pad q j).Coord) : + Σ j, (L j).Coord := + ⟨⟨a.1.val, L.padCoord_isLt a⟩, cast (congrArg RankPreparationLayer.Coord + (L.pad_apply_lt a.1 (L.padCoord_isLt a))) a.2⟩ + +@[simp] theorem padCoordRestriction_inclusion (hmq : m ≤ q) + (a : Σ j, (L j).Coord) : + L.padCoordRestriction (L.padCoordInclusion hmq a) = a := by + rcases a with ⟨j, i⟩ + dsimp only [padCoordInclusion, padCoordRestriction] + apply Sigma.ext + · exact Fin.ext rfl + exact (cast_heq _ _).trans (cast_heq _ _) + +@[simp] theorem padCoordInclusion_restriction (hmq : m ≤ q) + (a : Σ j, (L.pad q j).Coord) : + L.padCoordInclusion hmq (L.padCoordRestriction a) = a := by + rcases a with ⟨j, i⟩ + dsimp only [padCoordInclusion, padCoordRestriction] + apply Sigma.ext + · exact Fin.ext rfl + exact (cast_heq _ _).trans (cast_heq _ _) + +noncomputable def padCoordEquiv (hmq : m ≤ q) : + (Σ j, (L.pad q j).Coord) ≃ Σ j, (L j).Coord where + toFun := L.padCoordRestriction + invFun := L.padCoordInclusion hmq + left_inv := L.padCoordInclusion_restriction hmq + right_inv := L.padCoordRestriction_inclusion hmq + +private theorem label_cast {A B : RankPreparationLayer X J} (h : A = B) + (i : A.Coord) : B.label (cast (congrArg RankPreparationLayer.Coord h) i) = A.label i := by + cases h + rfl + +private theorem eval_cast {A B : RankPreparationLayer X J} (h : A = B) + (x : X → ℝ) (i : A.Coord) : + eval x B.poly (cast (congrArg RankPreparationLayer.Coord h) i) = eval x A.poly i := by + cases h + rfl + +private theorem coefficients_cast {A B : RankPreparationLayer X J} (h : A = B) + (α : X →₀ ℕ) (i : A.Coord) : + coefficients B.poly α (cast (congrArg RankPreparationLayer.Coord h) i) = + coefficients A.poly α i := by + cases h + rfl + +@[simp] theorem padCoordInclusion_label (hmq : m ≤ q) (a : Σ j, (L j).Coord) : + (L.pad q (L.padCoordInclusion hmq a).1).label (L.padCoordInclusion hmq a).2 = + (L a.1).label a.2 := + label_cast (L.pad_apply_castLE hmq a.1).symm a.2 + +@[simp] theorem padCoordEquiv_index (hmq : m ≤ q) (a : Σ j, (L.pad q j).Coord) : + ((L.padCoordEquiv hmq a).1 : ℕ) = a.1.val := rfl + +@[simp] theorem padCoordEquiv_label (hmq : m ≤ q) (a : Σ j, (L.pad q j).Coord) : + (L (L.padCoordEquiv hmq a).1).label (L.padCoordEquiv hmq a).2 = + (L.pad q a.1).label a.2 := by + have h := L.padCoordInclusion_label hmq (L.padCoordRestriction a) + rw [L.padCoordInclusion_restriction hmq a] at h + exact h.symm + +@[simp] theorem padCoordInclusion_eval (hmq : m ≤ q) (x : X → ℝ) + (a : Σ j, (L j).Coord) : + eval x (L.pad q (L.padCoordInclusion hmq a).1).poly (L.padCoordInclusion hmq a).2 = + eval x (L a.1).poly a.2 := + eval_cast (L.pad_apply_castLE hmq a.1).symm x a.2 + +@[simp] theorem padCoordEquiv_eval (hmq : m ≤ q) (x : X → ℝ) + (a : Σ j, (L.pad q j).Coord) : + eval x (L (L.padCoordEquiv hmq a).1).poly (L.padCoordEquiv hmq a).2 = + eval x (L.pad q a.1).poly a.2 := by + have h := L.padCoordInclusion_eval hmq x (L.padCoordRestriction a) + rw [L.padCoordInclusion_restriction hmq a] at h + exact h.symm + +@[simp] theorem padCoordInclusion_coefficients (hmq : m ≤ q) (α : X →₀ ℕ) + (a : Σ j, (L j).Coord) : + coefficients (L.pad q (L.padCoordInclusion hmq a).1).poly α + (L.padCoordInclusion hmq a).2 = coefficients (L a.1).poly α a.2 := + coefficients_cast (L.pad_apply_castLE hmq a.1).symm α a.2 + +@[simp] theorem padCoordEquiv_coefficients (hmq : m ≤ q) (α : X →₀ ℕ) + (a : Σ j, (L.pad q j).Coord) : + coefficients (L (L.padCoordEquiv hmq a).1).poly α (L.padCoordEquiv hmq a).2 = + coefficients (L.pad q a.1).poly α a.2 := by + have h := L.padCoordInclusion_coefficients hmq α (L.padCoordRestriction a) + rw [L.padCoordInclusion_restriction hmq a] at h + exact h.symm + +theorem pad_coordinateCopySum {R : Type*} [CommRing R] [DecidableEq J] + (hmq : m ≤ q) (v : (Σ j, (L j).Coord) → R) : + coordinateCopySum (fun a : Σ j, (L.pad q j).Coord => (L.pad q a.1).label a.2) + (fun a => v (L.padCoordEquiv hmq a)) = + coordinateCopySum (fun a : Σ j, (L j).Coord => (L a.1).label a.2) v := by + ext j + apply Fintype.sum_equiv (L.padCoordEquiv hmq) + intro a + dsimp only + simp only [L.padCoordEquiv_label] + +theorem pad_coordinateCopySum_family {R : Type*} [CommRing R] [DecidableEq J] + (hmq : m ≤ q) (v : ∀ j, (L j).Coord → R) : + (∑ j, coordinateCopySum (L.pad q j).label + (fun i => v (L.padCoordEquiv hmq ⟨j, i⟩).1 (L.padCoordEquiv hmq ⟨j, i⟩).2)) = + ∑ j, coordinateCopySum (L j).label (v j) := by + ext j + simpa only [coordinateCopySum_apply, Fintype.sum_sigma, Finset.sum_apply] using + congrFun (L.pad_coordinateCopySum hmq (fun a => v a.1 a.2)) j + +theorem pad_integerRemainder [Fintype J] [DecidableEq J] (hmq : m ≤ q) + (ip : J → MvPolynomial X ℤ) (β : ∀ j, (L j).Coord → MvPolynomial X ℤ) : + (L.pad q).integerRemainder ip + (fun j i => β (L.padCoordEquiv hmq ⟨j, i⟩).1 (L.padCoordEquiv hmq ⟨j, i⟩).2) = + L.integerRemainder ip β := by + unfold integerRemainder + rw [L.pad_coordinateCopySum_family hmq β] + +end Erdos3.RankPreparationFamily + +end + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial + +variable {X J : Type} {m q : ℕ} (L : RankPreparationFamily X J m) + +noncomputable def unpadCenter (hmq : m ≤ q) + (c : ∀ j, (L.pad q j).Coord → ℝ) : ∀ j, (L j).Coord → ℝ := fun j i => + c ((L.padCoordEquiv hmq).symm ⟨j, i⟩).1 ((L.padCoordEquiv hmq).symm ⟨j, i⟩).2 + +@[simp] theorem unpadCenter_equiv (hmq : m ≤ q) + (c : ∀ j, (L.pad q j).Coord → ℝ) (a : Σ j, (L.pad q j).Coord) : + L.unpadCenter hmq c (L.padCoordEquiv hmq a).1 (L.padCoordEquiv hmq a).2 = + c a.1 a.2 := by + exact congrArg (fun b : Σ j, (L.pad q j).Coord => c b.1 b.2) + ((L.padCoordEquiv hmq).symm_apply_apply a) + +private theorem space_cast {K L' : RankPreparationLayer X J} (h : K = L') + (v : K.Coord → ℝ) (hv : v ∈ K.space) : + (fun i => v (cast (congrArg RankPreparationLayer.Coord h.symm) i)) ∈ L'.space := by + subst L' + exact hv + +theorem unpadCenter_mem (hmq : m ≤ q) (c : ∀ j, (L.pad q j).Coord → ℝ) + (hc : ∀ j, c j ∈ (L.pad q j).space) (j : Fin m) : + L.unpadCenter hmq c j ∈ (L j).space := by + exact space_cast (L.pad_apply_castLE hmq j) (c (j.castLE hmq)) (hc (j.castLE hmq)) + +noncomputable def padFullTaggedEquiv (hmq : m ≤ q) : + (X ⊕ (Σ j, (L.pad q j).Coord)) ≃ (X ⊕ (Σ j, (L j).Coord)) := + (Equiv.refl X).sumCongr (L.padCoordEquiv hmq) + +@[simp] theorem padFullTaggedEquiv_weight (hmq : m ≤ q) + (a : X ⊕ (Σ j, (L.pad q j).Coord)) : + fullTaggedVariableWeight (fun j => (L j).Coord) (L.padFullTaggedEquiv hmq a) = + fullTaggedVariableWeight (fun j => (L.pad q j).Coord) a := by + cases a with + | inl x => rfl + | inr a => + change (L.padCoordEquiv hmq a).1.val + 1 = a.1.val + 1 + rw [L.padCoordEquiv_index] + +theorem pad_fullTaggedPhysicalIntegerPoint (hmq : m ≤ q) + (c : ∀ j, (L.pad q j).Coord → ℝ) (x : X → ℤ) + (a : X ⊕ (Σ j, (L.pad q j).Coord)) : + fullTaggedPhysicalIntegerPoint (fun j => (L.pad q j).Coord) + (fun j => (L.pad q j).poly) c x a = + fullTaggedPhysicalIntegerPoint (fun j => (L j).Coord) + (fun j => (L j).poly) (L.unpadCenter hmq c) x (L.padFullTaggedEquiv hmq a) := by + cases a with + | inl x => rfl + | inr a => + change round (eval (fun i => (x i : ℝ)) (L.pad q a.1).poly a.2 - c a.1 a.2) = + round (eval (fun i => (x i : ℝ)) (L (L.padCoordEquiv hmq a).1).poly + (L.padCoordEquiv hmq a).2 - + L.unpadCenter hmq c (L.padCoordEquiv hmq a).1 (L.padCoordEquiv hmq a).2) + rw [L.padCoordEquiv_eval, L.unpadCenter_equiv] + +theorem pad_fullTaggedPhysicalIntegerPoint_restrict (hmq : m ≤ q) + (c : ∀ j, (L.pad q j).Coord → ℝ) (x : X → ℤ) : + (fun a => fullTaggedPhysicalIntegerPoint (fun j => (L.pad q j).Coord) + (fun j => (L.pad q j).poly) c x ((L.padFullTaggedEquiv hmq).symm a)) = + fullTaggedPhysicalIntegerPoint (fun j => (L j).Coord) + (fun j => (L j).poly) (L.unpadCenter hmq c) x := by + funext a + rw [L.pad_fullTaggedPhysicalIntegerPoint, Equiv.apply_symm_apply] + +theorem pad_fullTagged_observer {E : Type*} (hmq : m ≤ q) + (c : ∀ j, (L.pad q j).Coord → ℝ) (x : X → ℤ) + (F : ((X ⊕ (Σ j, (L j).Coord)) → ℤ) → E) : + F (fun a => fullTaggedPhysicalIntegerPoint (fun j => (L.pad q j).Coord) + (fun j => (L.pad q j).poly) c x ((L.padFullTaggedEquiv hmq).symm a)) = + F (fullTaggedPhysicalIntegerPoint (fun j => (L j).Coord) + (fun j => (L j).poly) (L.unpadCenter hmq c) x) := by + rw [L.pad_fullTaggedPhysicalIntegerPoint_restrict] + +noncomputable def padLowTaggedEquiv (hmq : m ≤ q) (d : ℕ) : + LowTaggedIndex (fun j => (L.pad q j).Coord) d ≃ + LowTaggedIndex (fun j => (L j).Coord) d := + (L.padCoordEquiv hmq).subtypeEquiv (fun a => by + change a.1.val + 1 ≤ d ↔ (L.padCoordEquiv hmq a).1.val + 1 ≤ d + rw [L.padCoordEquiv_index]) + +theorem pad_lowTagged_card (hmq : m ≤ q) (d : ℕ) : + Fintype.card (LowTaggedIndex (fun j => (L.pad q j).Coord) d) = + Fintype.card (LowTaggedIndex (fun j => (L j).Coord) d) := + Fintype.card_congr (L.padLowTaggedEquiv hmq d) + +end Erdos3.RankPreparationFamily + +end + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial +open scoped BigOperators + +variable {X J : Type} {Vars : Type*} {m q : ℕ} + (L : RankPreparationFamily X J m) + +noncomputable def unpadFreezingLifts (hmq : m ≤ q) + (β : ∀ j, (L.pad q j).Coord → MvPolynomial Vars ℤ) : + ∀ j, (L j).Coord → MvPolynomial Vars ℤ := fun j i => + β (L.padCoordInclusion hmq ⟨j, i⟩).1 (L.padCoordInclusion hmq ⟨j, i⟩).2 + +theorem unpadFreezingLifts_degree (hmq : m ≤ q) + (β : ∀ j, (L.pad q j).Coord → MvPolynomial Vars ℤ) + (hβ : ∀ j i, (β j i).totalDegree ≤ j.val + 1) : + ∀ j i, (L.unpadFreezingLifts hmq β j i).totalDegree ≤ j.val + 1 := by + intro j i + exact hβ (L.padCoordInclusion hmq ⟨j, i⟩).1 (L.padCoordInclusion hmq ⟨j, i⟩).2 + +theorem unpadFreezingLifts_bound (hmq : m ≤ q) + (β : ∀ j, (L.pad q j).Coord → MvPolynomial Vars ℤ) + (c : ∀ j, (L.pad q j).Coord → ℝ) + (point : (Vars → ℝ) → X → ℝ) (domain : Set (Vars → ℝ)) (ε : Fin q → ℝ) + (hsmall : ∀ t ∈ domain, ∀ j i, + |eval (point t) (L.pad q j).poly i - c j i - + MvPolynomial.eval t (MvPolynomial.map (Int.castRingHom ℝ) (β j i))| ≤ ε j) : + ∀ t ∈ domain, ∀ j i, + |eval (point t) (L j).poly i - L.unpadCenter hmq c j i - + MvPolynomial.eval t + (MvPolynomial.map (Int.castRingHom ℝ) (L.unpadFreezingLifts hmq β j i))| ≤ + ε (j.castLE hmq) := by + intro t ht j i + have h := hsmall t ht (L.padCoordInclusion hmq ⟨j, i⟩).1 + (L.padCoordInclusion hmq ⟨j, i⟩).2 + rw [L.padCoordInclusion_eval hmq (point t)] at h + exact h + +theorem exists_unpadded_freezing_lifts (hmq : m ≤ q) + (β : ∀ j, (L.pad q j).Coord → MvPolynomial Vars ℤ) + (hβ : ∀ j i, (β j i).totalDegree ≤ j.val + 1) + (c : ∀ j, (L.pad q j).Coord → ℝ) + (point : (Vars → ℝ) → X → ℝ) (domain : Set (Vars → ℝ)) (ε : Fin q → ℝ) + (hsmall : ∀ t ∈ domain, ∀ j i, + |eval (point t) (L.pad q j).poly i - c j i - + MvPolynomial.eval t (MvPolynomial.map (Int.castRingHom ℝ) (β j i))| ≤ ε j) : + ∃ βold : ∀ j, (L j).Coord → MvPolynomial Vars ℤ, + (∀ j i, (βold j i).totalDegree ≤ j.val + 1) ∧ + ∀ t ∈ domain, ∀ j i, + |eval (point t) (L j).poly i - L.unpadCenter hmq c j i - + MvPolynomial.eval t (MvPolynomial.map (Int.castRingHom ℝ) (βold j i))| ≤ + ε (j.castLE hmq) := + ⟨L.unpadFreezingLifts hmq β, L.unpadFreezingLifts_degree hmq β hβ, + L.unpadFreezingLifts_bound hmq β c point domain ε hsmall⟩ + +theorem pad_coordinateWeighted_sum (hmq : m ≤ q) (ε : Fin q → ℝ) : + (∑ j : Fin m, (Fintype.card (L j).Coord : ℝ) * ε (j.castLE hmq)) = + ∑ j : Fin q, (Fintype.card (L.pad q j).Coord : ℝ) * ε j := by + apply Fintype.sum_of_injective (Fin.castLE hmq) + (fun i j hij => Fin.ext (congrArg (fun k : Fin q => k.val) hij)) + · intro j hj + have hge : m ≤ j.val := by + by_contra hnot + have hlt : j.val < m := by omega + exact hj ⟨⟨j.val, hlt⟩, Fin.ext rfl⟩ + rw [L.pad_apply_ge j hge] + change (Fintype.card PEmpty : ℝ) * ε j = 0 + simp + · intro j + rw [L.pad_apply_castLE hmq j] + +end Erdos3.RankPreparationFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationPotential.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationPotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..8884f69c233c1687e7da65aeb1d64d94d821c059 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationPotential.lean @@ -0,0 +1,67 @@ +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +def layerRankPotential {s : ℕ} (d : Fin s → ℕ) : ℕ := + ∑ i, (i.val + 1) * d i + +theorem layerRankPotential_add {s : ℕ} (d e : Fin s → ℕ) : + layerRankPotential (d + e) = layerRankPotential d + layerRankPotential e := by + simp only [layerRankPotential, Pi.add_apply, Nat.mul_add, Finset.sum_add_distrib] + +theorem layerRankPotential_mono {s : ℕ} {d e : Fin s → ℕ} + (h : ∀ i, d i ≤ e i) : layerRankPotential d ≤ layerRankPotential e := + Finset.sum_le_sum (fun i _ => Nat.mul_le_mul_left _ (h i)) + +theorem layerRankPotential_single {s : ℕ} (i : Fin s) (n : ℕ) : + layerRankPotential (Pi.single i n) = (i.val + 1) * n := by + classical + simp [layerRankPotential, Pi.single_apply] + +theorem sum_ranks_le_potential {s : ℕ} (d : Fin s → ℕ) : + ∑ i, d i ≤ layerRankPotential d := by + apply Finset.sum_le_sum + intro i _ + exact Nat.le_mul_of_pos_left _ (Nat.succ_pos _) + +theorem layerRankPotential_transfer {s : ℕ} (upper lower : Fin s) + (hlevel : upper.val = lower.val + 1) {d e : Fin s → ℕ} + (hstep : ∀ i, (e + Pi.single upper 1 : Fin s → ℕ) i ≤ (d + Pi.single lower 1 : Fin s → ℕ) i) : + layerRankPotential e + 1 ≤ layerRankPotential d := by + have h := layerRankPotential_mono hstep + rw [layerRankPotential_add, layerRankPotential_add, + layerRankPotential_single, layerRankPotential_single, Nat.mul_one, Nat.mul_one] at h + omega + +theorem layerRankPotential_absorb_constant {s : ℕ} (lowest : Fin s) (hlowest : lowest.val = 0) + {d e : Fin s → ℕ} (hstep : ∀ i, (e + Pi.single lowest 1 : Fin s → ℕ) i ≤ d i) : + layerRankPotential e + 1 ≤ layerRankPotential d := by + have h := layerRankPotential_mono hstep + simpa only [layerRankPotential_add, layerRankPotential_single, hlowest] using h + +theorem layerRankPotential_iteration_bound {s n : ℕ} (d : ℕ → Fin s → ℕ) + (hstep : ∀ t < n, layerRankPotential (d (t + 1)) + 1 ≤ layerRankPotential (d t)) : + n + layerRankPotential (d n) ≤ layerRankPotential (d 0) := by + induction n with + | zero => simp + | succ n ih => + have hprev := ih (fun t ht => hstep t (by omega)) + have hlast := hstep n (Nat.lt_succ_self n) + omega + +theorem layerRankPotential_initial {s : ℕ} (D : ℕ) : + layerRankPotential (Pi.single (Fin.last s) D) = (s + 1) * D := + layerRankPotential_single (Fin.last s) D + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationProjectedAxisBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationProjectedAxisBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5b9ad85fa0b6c64ed505ecf17a273c3cb0f665f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationProjectedAxisBudget.lean @@ -0,0 +1,527 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedGeometricInputBudget +import OAI.Combinatorics.Progressions.Linear.JointRationalSpaceDefiningMatrix +import OAI.Combinatorics.Progressions.Linear.RankPreparationSizes + +namespace OAI + +section + +namespace Erdos3 + +open VectorPolynomial + +noncomputable def preparationHeight (p : ℝ) (depth : ℕ) : ℕ := + ⌊Real.exp ((p + 2) ^ budgetDepthExponent 38 depth)⌋₊ + +theorem preparationExponent_pos (depth : ℕ) : 1 ≤ budgetDepthExponent 38 depth := by + induction depth with + | zero => rfl + | succ d ih => simp only [budgetDepthExponent]; omega + +theorem preparationExponent_mono : Monotone (budgetDepthExponent 38) := by + apply monotone_nat_of_le_succ + intro d + simp only [budgetDepthExponent] + omega + +theorem preparationHeight_pos {p : ℝ} (hp : 0 ≤ p) (depth : ℕ) : + 1 ≤ preparationHeight p depth := by + apply Nat.le_floor + norm_cast + exact Real.one_le_exp (by positivity) + +theorem preparationHeight_le_exp (p : ℝ) (depth : ℕ) : + (preparationHeight p depth : ℝ) ≤ Real.exp ((p + 2) ^ budgetDepthExponent 38 depth) := + Nat.floor_le (Real.exp_nonneg _) + +theorem preparationHeight_mono {p : ℝ} (hp : 0 ≤ p) : Monotone (preparationHeight p) := by + intro d e hde + apply Nat.floor_mono + apply Real.exp_le_exp.mpr + exact pow_le_pow_right₀ (by linarith) (preparationExponent_mono hde) + +theorem rankCutDirectionHeight_le_preparationHeight (ambient columns rows H R depth : ℕ) + {p : ℝ} (hp : 0 ≤ p) (ha : (ambient : ℝ) ≤ p) (hc : (columns : ℝ) ≤ p) + (hr : (rows : ℝ) + 1 ≤ p) (hH : H ≤ preparationHeight p depth) + (hR : (R : ℝ) ≤ Real.exp p) : + rankCutDirectionHeight ambient columns rows H R ≤ preparationHeight p (depth + 1) := by + have hpq := le_power_budget hp (preparationExponent_pos depth) + have hHp : (H : ℝ) ≤ Real.exp ((p + 2) ^ budgetDepthExponent 38 depth) := + (Nat.cast_le.mpr hH).trans (preparationHeight_le_exp p depth) + have hbound := rankCutDirectionHeight_le_exp ambient columns rows H R + (by positivity : 0 ≤ (p + 2) ^ budgetDepthExponent 38 depth) + (ha.trans hpq) (hc.trans hpq) (hr.trans hpq) hHp + (hR.trans (Real.exp_le_exp.mpr hpq)) + apply Nat.le_floor + apply hbound.trans + apply Real.exp_le_exp.mpr + exact shifted_power_budget_le hp (budgetDepthExponent 38 depth) 38 + +namespace RankPreparationFamily + +def PreparedHeights {I J : Type} {s : ℕ} (L : RankPreparationFamily I J s) (p : ℝ) (R : ℕ) : Prop := + ∀ i, (L i).Valid (i.val + 1) (preparationHeight p (s - 1 - i.val)) R + +theorem PreparedHeights.descend {I J : Type} {s : ℕ} {L : RankPreparationFamily I J s} + {p : ℝ} {R : ℕ} (hL : L.PreparedHeights p R) (hp : 0 ≤ p) (hR : 1 ≤ R) + (upper lower : Fin s) (hlevel : upper.val = lower.val + 1) + (a : (L upper).Coord → ℤ) (e : (L upper).Coord → ℚ) (l : MvPolynomial I ℝ) + {He : ℕ} (ha : ∀ i, |(a i : ℝ)| ≤ R) (heH : ∀ i, RationalHeightLE (e i) He) + (hHe : He ≤ preparationHeight p ((s - 1 - upper.val) + 1)) + (he : (fun i => (e i : ℝ)) ∈ (L upper).space) + (hae : integerRowLinear a (fun i => (e i : ℝ)) = 1) (hl : l.totalDegree ≤ lower.val + 1) : + (L.descend upper lower a e l).PreparedHeights p R := by + have hne : upper ≠ lower := by intro h; rw [h] at hlevel; omega + intro i + apply (L.descend_valid upper lower hne (fun i => preparationHeight p (s - 1 - i.val)) + (fun _ => preparationHeight_pos hp _) hR hL a e l ha heH he hae hl i).mono_height + split_ifs with hi + · subst i + apply max_le le_rfl + have hd : s - 1 - lower.val = (s - 1 - upper.val) + 1 := by omega + rwa [hd] + · exact le_rfl + +end RankPreparationFamily +end Erdos3 + +end + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial +open scoped BigOperators + +variable {I J : Type} [Fintype J] [DecidableEq J] {j : ℕ} + +noncomputable def initial (p : VectorPolynomial I ℝ (J → ℝ)) : RankPreparationFamily I J (j + 1) := + fun i => if i = Fin.last j then RankPreparationLayer.initial p else RankPreparationLayer.empty + +theorem initial_potential (p : VectorPolynomial I ℝ (J → ℝ)) : + (initial (j := j) p).potential = (j + 1) * Fintype.card J := by + have hr : (fun i => (initial (j := j) p i).rank) = Pi.single (Fin.last j) (Fintype.card J) := by + funext i + by_cases hi : i = Fin.last j + · subst i; simp [initial] + · simp [initial, hi] + unfold potential + rw [hr, layerRankPotential_initial] + +theorem initial_value (p : VectorPolynomial I ℝ (J → ℝ)) (x : I → ℝ) : + (initial (j := j) p).value x = eval x p := by + have hv (i : Fin (j + 1)) : (initial p i).value x = if i = Fin.last j then eval x p else 0 := by + by_cases hi : i = Fin.last j <;> simp [initial, hi] + unfold value + simp only [hv, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + +theorem initial_sized (p : VectorPolynomial I ℝ (J → ℝ)) : + (initial (j := j) p).Sized (Fintype.card J) 0 := by + intro i + by_cases hi : i = Fin.last j + · simp only [initial, hi, ite_true] + change Fintype.card J ≤ _ ∧ Fintype.card J ≤ _ ∧ Fintype.card PEmpty ≤ _ + simp + · simp only [initial, hi, ite_false] + change Fintype.card PEmpty ≤ _ ∧ Fintype.card PEmpty ≤ _ ∧ Fintype.card PEmpty ≤ _ + simp + +theorem initial_heights (p : VectorPolynomial I ℝ (J → ℝ)) + {budget : ℝ} {R : ℕ} (hbudget : 0 ≤ budget) (hp : DegreeLE (fun _ => 1) (j + 1) p) : + (initial (j := j) p).PreparedHeights budget R := by + intro i + by_cases hi : i = Fin.last j + · subst i + simpa only [initial, ite_true, Fin.val_last] using + RankPreparationLayer.initial_valid p (preparationHeight_pos hbudget _) hp + · simpa only [initial, hi, ite_false] using + (RankPreparationLayer.empty_valid (I := I) (J := J) (i.val + 1) + (preparationHeight budget (j + 1 - 1 - i.val)) R) + +end Erdos3.RankPreparationFamily + +end + +section + +namespace Erdos3 + +open scoped BigOperators +open VectorPolynomial + +namespace RankPreparationLayer + +theorem empty_samplingRank {I J : Type} (d : ℕ) (T : I → ℝ) (R : ℝ) : + HasLayerSamplingRank d T R (empty : RankPreparationLayer I J).space + (empty : RankPreparationLayer I J).poly := by + intro a _ hw + obtain ⟨w, hw⟩ := hw + exact (hw (Finset.sum_eq_zero (fun j _ => j.elim))).elim + +end RankPreparationLayer + +namespace RankPreparationFamily + +variable {I J : Type} {m q : ℕ} + +noncomputable def pad (L : RankPreparationFamily I J m) (q : ℕ) : + RankPreparationFamily I J q := fun j => + if hj : j.val < m then L ⟨j.val, hj⟩ else RankPreparationLayer.empty + +@[simp] theorem pad_apply_lt (L : RankPreparationFamily I J m) (j : Fin q) + (hj : j.val < m) : L.pad q j = L ⟨j.val, hj⟩ := by + simp only [pad, dite_eq_left hj] + +@[simp] theorem pad_apply_ge (L : RankPreparationFamily I J m) (j : Fin q) + (hj : m ≤ j.val) : L.pad q j = RankPreparationLayer.empty := by + simp only [pad, dite_eq_right (by omega : ¬j.val < m)] + +@[simp] theorem pad_apply_castLE (L : RankPreparationFamily I J m) (hmq : m ≤ q) + (j : Fin m) : L.pad q (j.castLE hmq) = L j := by + simp only [pad, Fin.val_castLE, dite_eq_left j.isLt] + +theorem pad_valid (L : RankPreparationFamily I J m) (H : ℕ → ℕ) + (R : ℕ) (hL : ∀ j, (L j).Valid (j.val + 1) (H j.val) R) : + ∀ j, (L.pad q j).Valid (j.val + 1) (H j.val) R := by + intro j + by_cases hj : j.val < m + · simpa only [pad_apply_lt L j hj] using hL ⟨j.val, hj⟩ + · rw [pad_apply_ge L j (by omega)] + exact RankPreparationLayer.empty_valid _ _ _ + +theorem PreparedHeights.pad {L : RankPreparationFamily I J m} {p : ℝ} {R : ℕ} + (hL : L.PreparedHeights p R) (hmq : m ≤ q) (hp : 0 ≤ p) : + (L.pad q).PreparedHeights p R := by + intro j + by_cases hj : j.val < m + · rw [pad_apply_lt L j hj] + exact (hL ⟨j.val, hj⟩).mono_height + (preparationHeight_mono hp (by change m - 1 - j.val ≤ q - 1 - j.val; omega)) + · rw [pad_apply_ge L j (by omega)] + exact RankPreparationLayer.empty_valid _ _ _ + +theorem pad_samplingRank (L : RankPreparationFamily I J m) (T : I → ℝ) (R : ℝ) + (hL : ∀ j, HasLayerSamplingRank (j.val + 1) T R (L j).space (L j).poly) : + ∀ j, HasLayerSamplingRank (j.val + 1) T R (L.pad q j).space + (L.pad q j).poly := by + intro j + by_cases hj : j.val < m + · rw [pad_apply_lt L j hj] + exact hL ⟨j.val, hj⟩ + · rw [pad_apply_ge L j (by omega)] + exact RankPreparationLayer.empty_samplingRank _ _ _ + +theorem pad_degreeLE (L : RankPreparationFamily I J m) + (hL : ∀ j, DegreeLE (fun _ => 1) (j.val + 1) (L j).poly) : + ∀ j, DegreeLE (fun _ => 1) (j.val + 1) (L.pad q j).poly := by + intro j + by_cases hj : j.val < m + · rw [pad_apply_lt L j hj] + exact hL ⟨j.val, hj⟩ + · rw [pad_apply_ge L j (by omega)] + exact (RankPreparationLayer.empty_valid _ 0 0).1 + +theorem pad_coefficients_mem (L : RankPreparationFamily I J m) + (hL : ∀ j α, coefficients (L j).poly α ∈ (L j).space) : + ∀ j α, coefficients (L.pad q j).poly α ∈ (L.pad q j).space := by + intro j + by_cases hj : j.val < m + · rw [pad_apply_lt L j hj] + exact hL ⟨j.val, hj⟩ + · rw [pad_apply_ge L j (by omega)] + exact (RankPreparationLayer.empty_valid 0 0 0).2.1 + +theorem pad_coordinate_card_le (L : RankPreparationFamily I J m) {M : ℕ} + (hL : ∀ j, Fintype.card (L j).Coord ≤ M) : + ∀ j, Fintype.card (L.pad q j).Coord ≤ M := by + intro j + by_cases hj : j.val < m + · simpa only [pad_apply_lt L j hj] using hL ⟨j.val, hj⟩ + · rw [pad_apply_ge L j (by omega)] + change Fintype.card PEmpty ≤ M + simp + +theorem Sized.pad {L : RankPreparationFamily I J m} {D t : ℕ} + (hL : L.Sized D t) (hmq : m ≤ q) : (L.pad q).Sized D t := by + intro j + by_cases hj : j.val < m + · rw [pad_apply_lt L j hj] + obtain ⟨hc, hb, hr⟩ := hL ⟨j.val, hj⟩ + exact ⟨hc.trans (Nat.mul_le_mul_left D (Nat.pow_le_pow_right (by omega) + (by change m - 1 - j.val ≤ q - 1 - j.val; omega))), hb, hr⟩ + · rw [pad_apply_ge L j (by omega)] + change Fintype.card PEmpty ≤ _ ∧ Fintype.card PEmpty ≤ _ ∧ Fintype.card PEmpty ≤ _ + simp + +theorem pad_sum {V : Type*} [AddCommMonoid V] + (L : RankPreparationFamily I J m) (hmq : m ≤ q) + (f : RankPreparationLayer I J → V) (hf : f RankPreparationLayer.empty = 0) : + (∑ j, f (L.pad q j)) = ∑ j, f (L j) := by + symm + apply Fintype.sum_of_injective (Fin.castLE hmq) + (fun i j hij => Fin.ext (congrArg (fun k : Fin q => k.val) hij)) + · intro j hj + have hge : m ≤ j.val := by + by_contra hnot + have hlt : j.val < m := by omega + exact hj ⟨⟨j.val, hlt⟩, Fin.ext rfl⟩ + rw [pad_apply_ge L j hge, hf] + · intro j + rw [pad_apply_castLE] + +@[simp] theorem pad_value [DecidableEq J] (L : RankPreparationFamily I J m) + (hmq : m ≤ q) (x : I → ℝ) : (L.pad q).value x = L.value x := + pad_sum L hmq (fun layer => layer.value x) (RankPreparationLayer.empty_value x) + +theorem pad_coordinate_card (L : RankPreparationFamily I J m) (hmq : m ≤ q) : + Fintype.card (Σ j, (L.pad q j).Coord) = Fintype.card (Σ j, (L j).Coord) := by + rw [Fintype.card_sigma, Fintype.card_sigma] + exact pad_sum L hmq (fun layer => Fintype.card layer.Coord) + (Fintype.card_eq_zero_iff.mpr ⟨fun i => i.elim⟩) + +end RankPreparationFamily +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module Submodule VectorPolynomial +open scoped BigOperators + +namespace RankPreparationLayer + +variable {I J : Type} (L : RankPreparationLayer I J) + +noncomputable def euclideanEquiv : euclideanSubspace L.space ≃ₗ[ℝ] L.space := + (euclideanSubspaceArrayEquiv L.space).toLinearEquiv.trans + (LinearEquiv.piUnique ℝ (fun _ : Unit => L.space)) + +theorem euclidean_finrank : finrank ℝ (euclideanSubspace L.space) = L.rank := + L.euclideanEquiv.finrank_eq + +theorem rank_add_orthogonal_finrank : + L.rank + finrank ℝ (euclideanSubspace L.space)ᗮ = Fintype.card L.Coord := by + rw [← L.euclidean_finrank, Submodule.finrank_add_finrank_orthogonal, finrank_euclideanSpace] + +theorem lattice_full {d H R : ℕ} (hL : L.Valid d H R) (hH : 1 ≤ H) (hR : 1 ≤ R) : + IsZLattice ℝ (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space)) := + jointRationalSpaceLattice_full L.basis L.rows hH hR hL.2.2.1 hL.2.2.2 + +theorem exists_uniform_chart {d H R : ℕ} (hL : L.Valid d H R) (hH : 1 ≤ H) (hR : 1 ≤ R) + {p : ℝ} (hC : (Fintype.card L.Coord : ℝ) ≤ p) : + ∃ b : Basis (Fin (finrank ℝ (euclideanSubspace L.space)ᗮ)) ℝ (euclideanSubspace L.space)ᗮ, + span ℤ (Set.range b) = projectedIntegerLattice (euclideanSubspace L.space) ∧ + (∀ z, ‖normalizedOrthogonalChart (euclideanSubspace L.space) b z‖ ≤ + Real.exp (allocatedUniformChartLog p) * ‖z‖) ∧ + (∀ z, ‖(normalizedOrthogonalChart (euclideanSubspace L.space) b).symm z‖ ≤ + Real.exp (allocatedUniformChartLog p) * ‖z‖) ∧ + 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace L.space) b ∧ + mixedDensityCovolumeRatio (euclideanSubspace L.space) b ≤ Real.exp (allocatedUniformChartLog p) := by + let := L.lattice_full hL hH hR + exact exists_uniform_projected_chart (euclideanSubspace L.space) hC + +end RankPreparationLayer + +namespace RankPreparationFamily + +variable {I J : Type} {s : ℕ} (L : RankPreparationFamily I J s) + +theorem PreparedHeights.lattice_full {p : ℝ} {R : ℕ} (hL : L.PreparedHeights p R) + (hp : 0 ≤ p) (hR : 1 ≤ R) (i : Fin s) : + IsZLattice ℝ (latticeSection (standardEuclideanLattice (L i).Coord) + (euclideanSubspace (L i).space)) := + (L i).lattice_full (hL i) (preparationHeight_pos hp _) hR + +theorem PreparedHeights.coefficientTorus_compact {K : Type*} [Fintype K] + {p : ℝ} {R : ℕ} (hL : L.PreparedHeights p R) (hp : 0 ≤ p) (hR : 1 ≤ R) : + CompactSpace (CoefficientTorus (K := K) (fun i => (L i).space)) := by + let := fun i => hL.lattice_full L hp hR i + exact coefficientTorus_compact_of_lattice (fun i => (L i).space) + +theorem PreparedHeights.exists_uniform_charts {p c : ℝ} {R : ℕ} + (hL : L.PreparedHeights p R) (hp : 0 ≤ p) (hR : 1 ≤ R) + (hC : ∀ i, (Fintype.card (L i).Coord : ℝ) ≤ c) : + ∃ b : ∀ i, Basis (Fin (finrank ℝ (euclideanSubspace (L i).space)ᗮ)) ℝ + (euclideanSubspace (L i).space)ᗮ, + (∀ i, span ℤ (Set.range (b i)) = projectedIntegerLattice (euclideanSubspace (L i).space)) ∧ + (∀ i z, ‖normalizedOrthogonalChart (euclideanSubspace (L i).space) (b i) z‖ ≤ + Real.exp (allocatedUniformChartLog c) * ‖z‖) ∧ + (∀ i z, ‖(normalizedOrthogonalChart (euclideanSubspace (L i).space) (b i)).symm z‖ ≤ + Real.exp (allocatedUniformChartLog c) * ‖z‖) ∧ + (∀ i, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (L i).space) (b i) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (L i).space) (b i) ≤ + Real.exp (allocatedUniformChartLog c)) := by + let := fun i => hL.lattice_full L hp hR i + exact exists_allocated_uniform_charts (fun i => (L i).space) hC + +end RankPreparationFamily +end Erdos3 + +end + +section + +namespace Erdos3.RankPreparationLayer + +open Module Submodule + +variable {X J E : Type} [Fintype E] (L : RankPreparationLayer X J) +variable [IsZLattice ℝ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space))] + +noncomputable def integralCoordinateBasis + (bW : Basis E ℤ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space))) : + Basis E ℝ L.space := + (bW.ofZLatticeBasis ℝ _).map L.euclideanEquiv + +theorem integralCoordinateBasis_card + (bW : Basis E ℤ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space))) : + Fintype.card E = L.rank := + (Module.finrank_eq_card_basis (L.integralCoordinateBasis bW)).symm + +omit [Fintype E] in +theorem integralCoordinateBasis_integer + (bW : Basis E ℤ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space))) + (i : L.Coord) (e : E) : + ∃ z : ℤ, (L.integralCoordinateBasis bW e).val i = (z : ℝ) := by + have h := (mem_standardEuclideanLattice L.Coord (bW e).val.val).mp (bW e).property i + obtain ⟨z, hz⟩ := h + refine ⟨z, ?_⟩ + change ((bW.ofZLatticeBasis ℝ _) e).val i = (z : ℝ) + rw [Basis.ofZLatticeBasis_apply] + exact hz.symm + +noncomputable def integralCoordinateMatrix + (bW : Basis E ℤ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space))) : + L.Coord → E → ℤ := + fun i e => Classical.choose (L.integralCoordinateBasis_integer bW i e) + +omit [Fintype E] in +theorem integralCoordinateMatrix_cast [Fintype E] + (bW : Basis E ℤ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space))) + (i : L.Coord) (e : E) : + (L.integralCoordinateBasis bW e).val i = (L.integralCoordinateMatrix bW i e : ℝ) := + Classical.choose_spec (L.integralCoordinateBasis_integer bW i e) + +end Erdos3.RankPreparationLayer + +end + +section + +namespace Erdos3.RankPreparationLayer + +open Module Submodule VectorPolynomial BohrLattice.MinkowskiSecondBox + +variable {X J : Type} (L : RankPreparationLayer X J) + +noncomputable def shortIntegralBasisNormBound (H R : ℕ) : ℝ := + (L.rank : ℝ) * L.rank.factorial * minkowskiSecondConstant L.rank * + ((Fintype.card L.Coord : ℝ) * + (jointSpaceGeneratorHeight (Fintype.card L.Coord) (Fintype.card L.Column) + (Fintype.card L.Row) H R : ℝ) ^ (Fintype.card L.Coord * Fintype.card L.Coord)) + +theorem exists_short_integral_basis {d H R : ℕ} + (hL : L.Valid d H R) (hH : 1 ≤ H) (hR : 1 ≤ R) : + ∃ bW : Basis (Fin L.rank) ℤ + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space)), + ∀ a, ‖(bW a).val‖ ≤ L.shortIntegralBasisNormBound H R := by + let := L.lattice_full hL hH hR + obtain ⟨P, hP, hspace⟩ := exists_jointRationalSpace_generators + L.basis L.rows hH hR hL.2.2.1 hL.2.2.2 + obtain ⟨v, hvspan, hvmem, hvnorm⟩ := + exists_bounded_integral_span_of_rational_range P L.space hspace hP + let o : OrthonormalBasis (Fin L.rank) ℝ (euclideanSubspace L.space) := + (stdOrthonormalBasis ℝ (euclideanSubspace L.space)).reindex + (finCongr L.euclidean_finrank) + obtain ⟨b, hbspan, _hbprod, hbnorm⟩ := exists_short_euclidean_lattice_basis + (latticeSection (standardEuclideanLattice L.Coord) (euclideanSubspace L.space)) + o v hvspan hvmem hvnorm + refine ⟨integerBasisOfReal _ b hbspan, ?_⟩ + intro a + rw [integerBasisOfReal_apply] + exact hbnorm a + +end Erdos3.RankPreparationLayer + +end + +section + +namespace Erdos3 + +open Module Submodule + +theorem basisAxisScale_jointRationalSpace_le_exp + {J C V K : Type*} [Fintype J] [Fintype C] [Fintype V] + (B : Matrix J C ℚ) (A : Matrix V J ℚ) {H R : ℕ} + (hH : 1 ≤ H) (hB : ∀ i j, RationalHeightLE (B i j) H) + (hA : ∀ v j, RationalHeightLE (A v j) R) + (b : Basis K ℝ (euclideanSubspace (VectorPolynomial.jointRationalSpace B A))ᗮ) + (hb : span ℤ (Set.range b) = + projectedIntegerLattice (euclideanSubspace (VectorPolynomial.jointRationalSpace B A))) + {p : ℝ} (hp : 0 ≤ p) + (hJ : (Fintype.card J : ℝ) ≤ p) (hC : (Fintype.card C : ℝ) ≤ p) + (hV : (Fintype.card V : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hRp : (R : ℝ) ≤ Real.exp p) + (i : K) : + (basisAxisScale b i : ℝ) ≤ Real.exp ((p+2)^28) := by + obtain ⟨Q, hQ, hQker⟩ := + VectorPolynomial.exists_jointRationalSpace_defining_matrix B A hH hB hA + have hscale := basisAxisScale_le_of_rational_kernel Q _ hQker hQ b hb i + have hrow : (Fintype.card (J ⊕ V) : ℝ) ≤ 2*p := by + rw [Fintype.card_sum, Nat.cast_add] + linarith only [hJ, hV] + have hcol : (Fintype.card J : ℝ) ≤ 2*p := by linarith only [hJ, hp] + have hheight : + ((max (imageDefiningHeight (Fintype.card C) (Fintype.card J) H) R : ℕ) : ℝ) ≤ + Real.exp ((2*p+2)^10) := by + apply (jointSpaceDefiningHeight_le_exp _ _ H R hp hJ hC hHp hRp).trans + apply Real.exp_le_exp.mpr + exact pow_le_pow_left₀ (show 0 ≤ p+2 by positivity) (show p+2 ≤ 2*p+2 by linarith only [hp]) 10 + have hceil := rationalKernelSeparationConstant_ceil_le_exp_power Q + (show 0 ≤ 2*p by positivity) 10 (by decide) hrow hcol hheight hQ + have hpower : (2*p+2)^14 ≤ (p+2)^28 := by + calc + _ ≤ ((p+2)^2)^14 := pow_le_pow_left₀ (show 0 ≤ 2*p+2 by positivity) + (show 2*p+2 ≤ (p+2)^2 by nlinarith only [hp, sq_nonneg p]) 14 + _ = _ := by rw [← pow_mul] + calc + _ ≤ (⌈rationalKernelAxisBound Q + (max (imageDefiningHeight (Fintype.card C) (Fintype.card J) H) R)⌉₊ : ℝ) := + Nat.cast_le.mpr hscale + _ ≤ Real.exp ((2*p+2)^14) := hceil + _ ≤ _ := Real.exp_le_exp.mpr hpower + +namespace RankPreparationLayer + +theorem basisAxisScale_le_exp {X J : Type} (L : RankPreparationLayer X J) + {degree H R : ℕ} (hL : L.Valid degree H R) (hH : 1 ≤ H) + {K : Type*} (b : Basis K ℝ (euclideanSubspace L.space)ᗮ) + (hb : span ℤ (Set.range b) = projectedIntegerLattice (euclideanSubspace L.space)) + {p : ℝ} (hp : 0 ≤ p) + (hCoord : (Fintype.card L.Coord : ℝ) ≤ p) + (hColumn : (Fintype.card L.Column : ℝ) ≤ p) + (hRow : (Fintype.card L.Row : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hRp : (R : ℝ) ≤ Real.exp p) + (i : K) : + (basisAxisScale b i : ℝ) ≤ Real.exp ((p+2)^28) := + basisAxisScale_jointRationalSpace_le_exp L.basis L.rows hH hL.2.2.1 hL.2.2.2 + b hb hp hCoord hColumn hRow hHp hRp i + +end RankPreparationLayer + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationSizes.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationSizes.lean new file mode 100644 index 0000000000000000000000000000000000000000..761d90895c81bc4b916b2c35fe9ba44f66f824d1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankPreparationSizes.lean @@ -0,0 +1,886 @@ +import OAI.Combinatorics.Progressions.Estimates.IntegralSlowSlice +import OAI.Combinatorics.Progressions.Estimates.RelativePatchAmplification +import OAI.Combinatorics.Progressions.Geometry.CoordinateCopySum +import OAI.Combinatorics.Progressions.Linear.RankPreparationPotential + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open scoped BigOperators TensorProduct + +def rankCutDirectionHeight (ambient columns rows H R : ℕ) : ℕ := + (columns + 1) * + (H * rationalKernelHeight (rows + 1) ((ambient + 1) * (R * H) ^ ambient)) ^ columns + +theorem integerPolynomialQuotient_eval {I : Type*} (D : ℕ) (Q : MvPolynomial I ℤ) + (x : I → ℤ) : + MvPolynomial.eval (fun i => (x i : ℝ)) + (MvPolynomial.C (1 / (D : ℝ)) * MvPolynomial.map (Int.castRingHom ℝ) Q) = + (MvPolynomial.eval x Q : ℝ) / D := by + have he : (MvPolynomial.eval x Q : ℝ) = + MvPolynomial.eval (fun i => (x i : ℝ)) (MvPolynomial.map (Int.castRingHom ℝ) Q) := + MvPolynomial.map_eval (Int.castRingHom ℝ) x Q + rw [map_mul, MvPolynomial.eval_C, ← he] + simp only [div_eq_mul_inv] + ring + +theorem exists_rankPreparationStep {I J C V : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [Fintype C] [Fintype V] + (B : Matrix J C ℚ) (A : Matrix V J ℚ) (p : VectorPolynomial I ℝ (J → ℝ)) + (N : I → ℕ) {H R h : ℕ} {δ : ℝ} + (hH : 1 ≤ H) (hR : 1 ≤ R) (hδ : 0 < δ) (hN : ∀ i, 0 < N i) + (hB : ∀ i j, RationalHeightLE (B i j) H) + (hA : ∀ i j, RationalHeightLE (A i j) R) + (hp : DegreeLE (fun _ => 1) (h + 1) p) + (hmem : ∀ α, coefficients p α ∈ jointRationalSpace B A) + (hfail : ¬ HasLayerSamplingRank (h + 1) (fun i => (N i : ℝ)) R (jointRationalSpace B A) p) + (f : (∀ i, Fin (N i)) → ℝ) : + let W := jointRationalSpace B A + let He := rankCutDirectionHeight (Fintype.card J) (Fintype.card C) (Fintype.card V) H R + let K := (((h + 1 : ℕ) : ℝ) + 1) * ((Fintype.card I : ℝ) + 1) ^ (h + 1) * + R * Fintype.card I * ((h + 1 : ℕ) : ℝ) * He + let ρ := min 1 (δ / (K + 1)) + (∀ i, 4 * ((R * He ^ Fintype.card J : ℕ) : ℝ) ≤ ρ * N i) → + ∃ (a : J → ℤ) (e : J → ℚ) (q : ℕ) (S : ResidueBoxSlice N q) + (cut : VectorPolynomial I ℝ (J → ℝ)) (l E : MvPolynomial I ℝ) + (integerPart : J → MvPolynomial I ℤ) (c : J → ℝ), + cut = map (samplingRankProjection a (fun i => (e i : ℝ))) p ∧ + (∀ i, |(a i : ℝ)| ≤ R) ∧ (∀ i, RationalHeightLE (e i) He) ∧ + (fun i => (e i : ℝ)) ∈ W ∧ integerRowLinear a (fun i => (e i : ℝ)) = 1 ∧ + (∀ α, coefficients cut α ∈ W ⊓ LinearMap.ker (integerRowLinear a)) ∧ + DegreeLE (fun _ => 1) (h + 1) cut ∧ l.totalDegree ≤ h ∧ E.totalDegree ≤ h + 1 ∧ + Module.finrank ℝ ↥(W ⊓ LinearMap.ker (integerRowLinear a)) < Module.finrank ℝ W ∧ + 0 < q ∧ q ≤ R * He ^ Fintype.card J ∧ + (∀ i, 0 < S.length i ∧ ρ * N i ≤ 4 * q * S.length i) ∧ + ((𝔼 x, f x) ≤ 𝔼 j : (∀ i, Fin (S.length i)), f (S.point j)) ∧ + (∀ i, (integerPart i).totalDegree ≤ h + 1) ∧ + ∀ (j : ∀ i, Fin (S.length i)) (i : J), + |(MvPolynomial.eval (fun v => ((S.point j v).val : ℝ)) E - + MvPolynomial.eval (fun v => (S.start v : ℝ)) E) * (e i : ℝ)| ≤ δ ∧ + eval (fun v => ((S.point j v).val : ℝ)) p i = + eval (fun v => ((S.point j v).val : ℝ)) cut i + + MvPolynomial.eval (fun v => ((S.point j v).val : ℝ)) l * (e i : ℝ) + + (MvPolynomial.eval (fun v => ((j v).val : ℤ)) (integerPart i) : ℝ) + c i + + (MvPolynomial.eval (fun v => ((S.point j v).val : ℝ)) E - + MvPolynomial.eval (fun v => (S.start v : ℝ)) E) * (e i : ℝ) := by + classical + intro W He K ρ hlarge + simp only [HasLayerSamplingRank, not_forall, not_not] at hfail + obtain ⟨a, ha, hrow, happrox⟩ := hfail + obtain ⟨e, heW, hae, heH⟩ := exists_bounded_joint_rational_direction B A a hH hR hB hA ha + (by simpa only [integerRowLinear_apply] using hrow) + obtain ⟨D, hD, hDR, Q, E, l, hQ, hE, hl, hcoeff, hsplit⟩ := + samplingRankCut_homogeneous_split a (fun i => (e i : ℝ)) p hp + (fun i => by exact_mod_cast hN i) (Nat.cast_nonneg R) happrox + have hDRnat : D ≤ R := by exact_mod_cast hDR + have hlargeD (i : I) : 4 * ((D * He ^ Fintype.card J : ℕ) : ℝ) ≤ ρ * N i := + (mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (Nat.mul_le_mul_right _ hDRnat)) + (by norm_num)).trans (hlarge i) + obtain ⟨q, S, integerPart, c, hq, hqbound, hlength, hscore, hdegree, hparts⟩ := + exists_integral_slow_slice N Q E e hD (Nat.cast_nonneg R) hδ hQ.totalDegree_le + hE.totalDegree_le heH hcoeff f hlargeD + let cut := map (samplingRankProjection a (fun i => (e i : ℝ))) p + refine ⟨a, e, q, S, cut, l, E, integerPart, c, rfl, ha, heH, heW, hae, ?_, hp.map _, hl, + hE.totalDegree_le, samplingRankCut_finrank_lt a _ W heW hae, hq, + hqbound.trans (Nat.mul_le_mul_right _ hDRnat), hlength, hscore, hdegree, ?_⟩ + · intro α + rw [coefficients_map] + exact samplingRankProjection_mem a _ W heW hae (hmem α) + · intro j i + obtain ⟨herror, hparts⟩ := hparts j i + refine ⟨herror, ?_⟩ + have hv := congrArg (fun t : VectorPolynomial I ℝ (J → ℝ) => + eval (fun v => ((S.point j v).val : ℝ)) t i) hsplit + simp only [map_add, eval_tmul, MvPolynomial.aeval_eq_eval, Pi.add_apply, + Pi.smul_apply, smul_eq_mul] at hv + have hr := integerPolynomialQuotient_eval D Q (fun v => ((S.point j v).val : ℤ)) + simp only [Int.cast_natCast] at hr + rw [hr] at hv + change eval (fun v => ((S.point j v).val : ℝ)) p i = _ at hv + dsimp only [cut] + linarith + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct Matrix +open VectorPolynomial + +structure RankPreparationLayer (I J : Type) where + Coord : Type + Column : Type + Row : Type + coordFinite : Fintype Coord + columnFinite : Fintype Column + rowFinite : Fintype Row + label : Coord → J + basis : Matrix Coord Column ℚ + rows : Matrix Row Coord ℚ + poly : VectorPolynomial I ℝ (Coord → ℝ) + +attribute [instance] RankPreparationLayer.coordFinite RankPreparationLayer.columnFinite + RankPreparationLayer.rowFinite + +namespace RankPreparationLayer + +variable {I J : Type} + +noncomputable def space (L : RankPreparationLayer I J) : Submodule ℝ (L.Coord → ℝ) := + jointRationalSpace L.basis L.rows + +noncomputable def rank (L : RankPreparationLayer I J) : ℕ := Module.finrank ℝ L.space + +def Valid (L : RankPreparationLayer I J) (degree H R : ℕ) : Prop := + DegreeLE (fun _ => 1) degree L.poly ∧ + (∀ α, coefficients L.poly α ∈ L.space) ∧ + (∀ i j, RationalHeightLE (L.basis i j) H) ∧ + (∀ i j, RationalHeightLE (L.rows i j) R) + +theorem Valid.mono_height {L : RankPreparationLayer I J} {d H H' R : ℕ} + (h : L.Valid d H R) (hHH' : H ≤ H') : L.Valid d H' R := + ⟨h.1, h.2.1, fun i j => (h.2.2.1 i j).mono hHH', h.2.2.2⟩ + +noncomputable def value [DecidableEq J] (L : RankPreparationLayer I J) (x : I → ℝ) : J → ℝ := + coordinateCopySum L.label (eval x L.poly) + +noncomputable def reindex (L : RankPreparationLayer I J) (f : I → MvPolynomial I ℝ) : + RankPreparationLayer I J := { L with poly := substitute f L.poly } + +@[simp] theorem reindex_space (L : RankPreparationLayer I J) (f : I → MvPolynomial I ℝ) : + (L.reindex f).space = L.space := rfl + +@[simp] theorem reindex_rank (L : RankPreparationLayer I J) (f : I → MvPolynomial I ℝ) : + (L.reindex f).rank = L.rank := rfl + +theorem Valid.reindex {L : RankPreparationLayer I J} {d H R : ℕ} + (hL : L.Valid d H R) (f : I → MvPolynomial I ℝ) (hf : ∀ i, (f i).totalDegree ≤ 1) : + (L.reindex f).Valid d H R := + ⟨degreeLE_substitute_affine f hf L.poly hL.1, + coefficients_substitute_mem L.space f L.poly hL.2.1, hL.2.2⟩ + +theorem reindex_value [DecidableEq J] (L : RankPreparationLayer I J) + (f : I → MvPolynomial I ℝ) (x : I → ℝ) : + (L.reindex f).value x = L.value (fun i => MvPolynomial.aeval (R := ℝ) x (f i)) := by + exact congrArg (coordinateCopySum L.label) (eval_substitute f x L.poly) + +noncomputable def cut (L : RankPreparationLayer I J) (a : L.Coord → ℤ) (e : L.Coord → ℝ) : + RankPreparationLayer I J where + Coord := L.Coord + Column := L.Column + Row := Option L.Row + coordFinite := L.coordFinite + columnFinite := L.columnFinite + rowFinite := inferInstance + label := L.label + basis := L.basis + rows := appendRankCutRow L.rows a + poly := map (samplingRankProjection a e) L.poly + +theorem cut_space (L : RankPreparationLayer I J) (a : L.Coord → ℤ) (e : L.Coord → ℝ) : + (L.cut a e).space = L.space ⊓ LinearMap.ker (integerRowLinear a) := + jointRationalSpace_appendRankCutRow L.basis L.rows a + +theorem Valid.cut {L : RankPreparationLayer I J} {d H R : ℕ} + (hL : L.Valid d H R) (hR : 1 ≤ R) (a : L.Coord → ℤ) (e : L.Coord → ℝ) + (ha : ∀ i, |(a i : ℝ)| ≤ R) (he : e ∈ L.space) (hae : integerRowLinear a e = 1) : + (L.cut a e).Valid d H R := by + refine ⟨hL.1.map _, ?_, hL.2.2.1, ?_⟩ + · intro α + rw [cut_space] + change coefficients (map (samplingRankProjection a e) L.poly) α ∈ _ + rw [coefficients_map] + exact samplingRankProjection_mem a e L.space he hae (hL.2.1 α) + · exact appendRankCutRow_height L.rows a hR hL.2.2.2 ha + +theorem cut_rank_lt (L : RankPreparationLayer I J) (a : L.Coord → ℤ) (e : L.Coord → ℝ) + (he : e ∈ L.space) (hae : integerRowLinear a e = 1) : + (L.cut a e).rank < L.rank := by + unfold rank + rw [cut_space] + exact samplingRankCut_finrank_lt a e L.space he hae + +noncomputable def appendLine (L : RankPreparationLayer I J) {C : Type} [Fintype C] + (label : C → J) (e : C → ℚ) (l : MvPolynomial I ℝ) : RankPreparationLayer I J where + Coord := L.Coord ⊕ C + Column := Option L.Column + Row := L.Row + coordFinite := inferInstance + columnFinite := inferInstance + rowFinite := L.rowFinite + label := Sum.elim L.label label + basis := copiedLayerMatrix L.basis e + rows := copiedLayerRows L.rows + poly := copiedLayerPolynomial L.poly (l ⊗ₜ[ℝ] (fun i => (e i : ℝ))) + +theorem appendLine_space (L : RankPreparationLayer I J) {C : Type} [Fintype C] + (label : C → J) (e : C → ℚ) (l : MvPolynomial I ℝ) : + (L.appendLine label e l).space = + copiedLayerSpace L.space (Submodule.span ℝ {fun i => (e i : ℝ)}) := + jointRationalSpace_copiedLayer L.basis L.rows e + +theorem appendLine_rank (L : RankPreparationLayer I J) {C : Type} [Fintype C] + (label : C → J) (e : C → ℚ) (l : MvPolynomial I ℝ) (he : (fun i => (e i : ℝ)) ≠ 0) : + (L.appendLine label e l).rank = L.rank + 1 := by + unfold rank + rw [appendLine_space] + exact copiedLayerSpace_line_finrank L.space _ he + +theorem Valid.appendLine {L : RankPreparationLayer I J} {C : Type} [Fintype C] + {d H R He : ℕ} (hL : L.Valid d H R) (hH : 1 ≤ H) (hR : 1 ≤ R) + (label : C → J) (e : C → ℚ) (l : MvPolynomial I ℝ) + (he : ∀ i, RationalHeightLE (e i) He) (hl : l.totalDegree ≤ d) : + (L.appendLine label e l).Valid d (max H He) R := by + refine ⟨copiedLayerPolynomial_degree hL.1 (degreeLE_tmul_totalDegree l _ hl), ?_, + copiedLayerMatrix_height L.basis e hH hL.2.2.1 he, + copiedLayerRows_height L.rows hR hL.2.2.2⟩ + intro α + rw [appendLine_space] + apply copiedLayerPolynomial_mem L.space _ L.poly _ hL.2.1 + intro β + rw [coefficients_tmul] + exact Submodule.smul_mem _ _ (Submodule.subset_span (Set.mem_singleton _)) + +theorem appendLine_value [DecidableEq J] (L : RankPreparationLayer I J) + {C : Type} [Fintype C] (label : C → J) (e : C → ℚ) (l : MvPolynomial I ℝ) (x : I → ℝ) : + (L.appendLine label e l).value x = + L.value x + coordinateCopySum label (MvPolynomial.aeval (R := ℝ) x l • fun i => (e i : ℝ)) := by + unfold value + change coordinateCopySum (Sum.elim L.label label) + (eval x (copiedLayerPolynomial L.poly (l ⊗ₜ[ℝ] (fun i => (e i : ℝ))))) = _ + rw [eval_copiedLayerPolynomial, eval_tmul, coordinateCopySum_sum] + +noncomputable def empty : RankPreparationLayer I J where + Coord := PEmpty + Column := PEmpty + Row := PEmpty + coordFinite := inferInstance + columnFinite := inferInstance + rowFinite := inferInstance + label := PEmpty.elim + basis := 0 + rows := 0 + poly := 0 + +theorem empty_valid (d H R : ℕ) : (empty : RankPreparationLayer I J).Valid d H R := by + refine ⟨?_, ?_, ?_, ?_⟩ + · intro α _ + change coefficients (0 : VectorPolynomial I ℝ (PEmpty → ℝ)) α = 0 + simp only [map_zero, Finsupp.zero_apply] + · intro α + change coefficients (0 : VectorPolynomial I ℝ (PEmpty → ℝ)) α ∈ _ + simp only [map_zero, Finsupp.zero_apply] + exact Submodule.zero_mem _ + · intro i + exact i.elim + · intro i + exact i.elim + +@[simp] theorem empty_rank : (empty : RankPreparationLayer I J).rank = 0 := by + apply Module.finrank_zero_iff.mpr + change Subsingleton (jointRationalSpace (0 : Matrix PEmpty PEmpty ℚ) 0) + infer_instance + +@[simp] theorem empty_value [DecidableEq J] (x : I → ℝ) : + (empty : RankPreparationLayer I J).value x = 0 := by + have hzero (y : PEmpty → ℝ) : coordinateCopySum (PEmpty.elim : PEmpty → J) y = 0 := by + ext j + simp only [coordinateCopySum_apply, Fintype.sum_empty, Pi.zero_apply] + exact hzero _ + +noncomputable def initial [Fintype J] [DecidableEq J] + (p : VectorPolynomial I ℝ (J → ℝ)) : RankPreparationLayer I J where + Coord := J + Column := J + Row := PEmpty + coordFinite := inferInstance + columnFinite := inferInstance + rowFinite := inferInstance + label := id + basis := 1 + rows := 0 + poly := p + +theorem initial_space [Fintype J] [DecidableEq J] + (p : VectorPolynomial I ℝ (J → ℝ)) : (initial p).space = ⊤ := by + change jointRationalSpace (1 : Matrix J J ℚ) (0 : Matrix PEmpty J ℚ) = ⊤ + ext x + constructor + · intro _ + trivial + · intro _ + refine ⟨⟨x, ?_⟩, ?_⟩ + · change Matrix.of (fun i j => ((1 : Matrix J J ℚ) i j : ℝ)) *ᵥ x = x + have hcast : Matrix.of (fun i j => ((1 : Matrix J J ℚ) i j : ℝ)) = 1 := by + ext i j + simp only [Matrix.of_apply, Matrix.one_apply] + split_ifs <;> simp + rw [hcast, Matrix.one_mulVec] + · ext i + exact i.elim + +theorem initial_valid [Fintype J] [DecidableEq J] + (p : VectorPolynomial I ℝ (J → ℝ)) {d H R : ℕ} (hH : 1 ≤ H) + (hp : DegreeLE (fun _ => 1) d p) : (initial p).Valid d H R := by + refine ⟨hp, ?_, ?_, ?_⟩ + · intro α + rw [initial_space] + trivial + · change ∀ i j : J, RationalHeightLE ((1 : Matrix J J ℚ) i j) H + intro i j + change RationalHeightLE (if i = j then (1 : ℚ) else 0) H + split_ifs + · exact rationalHeightLE_one hH + · exact rationalHeightLE_zero hH + · intro i + exact i.elim + +@[simp] theorem initial_rank [Fintype J] [DecidableEq J] + (p : VectorPolynomial I ℝ (J → ℝ)) : (initial p).rank = Fintype.card J := by + unfold rank + rw [initial_space] + change Module.finrank ℝ (⊤ : Submodule ℝ (J → ℝ)) = Fintype.card J + simp + +@[simp] theorem initial_value [Fintype J] [DecidableEq J] + (p : VectorPolynomial I ℝ (J → ℝ)) (x : I → ℝ) : (initial p).value x = eval x p := by + ext j + change (coordinateCopySum (R := ℝ) (id : J → J) (eval x p)) j = _ + simp [coordinateCopySum_apply] + +end RankPreparationLayer +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +theorem rankCutDirectionHeight_le_exp (ambient columns rows H R : ℕ) {p : ℝ} + (hp : 0 ≤ p) (ha : (ambient : ℝ) ≤ p) (hc : (columns : ℝ) ≤ p) + (hr : (rows : ℝ) + 1 ≤ p) (hH : (H : ℝ) ≤ Real.exp p) (hR : (R : ℝ) ≤ Real.exp p) : + (rankCutDirectionHeight ambient columns rows H R : ℝ) ≤ Real.exp ((p + 2) ^ 38) := by + let Hsys := (ambient + 1) * (R * H) ^ ambient + have hfront : (ambient : ℝ) + 1 ≤ Real.exp p := + (by linarith : (ambient : ℝ) + 1 ≤ p + 1).trans (Real.add_one_le_exp p) + have hprod : (R : ℝ) * H ≤ Real.exp (2 * p) := by + simpa only [two_mul, Real.exp_add] using mul_le_mul hR hH (Nat.cast_nonneg _) (Real.exp_nonneg _) + have hsys : (Hsys : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + have hpow := pow_le_pow_left₀ (mul_nonneg (Nat.cast_nonneg R) (Nat.cast_nonneg H)) hprod ambient + rw [← Real.exp_nat_mul] at hpow + have htotal : (Hsys : ℝ) ≤ Real.exp (p + ambient * (2 * p)) := by + dsimp only [Hsys] + push_cast + rw [Real.exp_add] + exact mul_le_mul hfront hpow (by positivity) (Real.exp_nonneg _) + apply htotal.trans (Real.exp_le_exp.mpr ?_) + have hm := mul_le_mul_of_nonneg_right ha (show 0 ≤ 2 * p by positivity) + nlinarith [show 0 ≤ p ^ 3 by positivity] + have hp3 : p ≤ (p + 2) ^ 3 := le_power_budget hp (by decide) + have hker : (rationalKernelHeight (rows + 1) Hsys : ℝ) ≤ Real.exp ((p + 2) ^ 35) := by + have h := rationalKernelHeight_le_budget (rows + 1) Hsys (by positivity : 0 ≤ (p + 2) ^ 3) + (by simpa only [Nat.cast_add, Nat.cast_one] using hr.trans hp3) hsys + exact h.trans (Real.exp_le_exp.mpr (shifted_power_budget_le hp 3 7)) + have hp35 : p ≤ (p + 2) ^ 35 := le_power_budget hp (by decide) + have hbase : (H : ℝ) * rationalKernelHeight (rows + 1) Hsys ≤ Real.exp ((p + 2) ^ 36) := by + calc + _ ≤ Real.exp p * Real.exp ((p + 2) ^ 35) := + mul_le_mul hH hker (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = Real.exp (p + (p + 2) ^ 35) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by + calc + p + (p + 2) ^ 35 ≤ 2 * (p + 2) ^ 35 := by linarith + _ ≤ (p + 2) * (p + 2) ^ 35 := by gcongr; linarith + _ = _ := by ring) + have hpow : (((H * rationalKernelHeight (rows + 1) Hsys) ^ columns : ℕ) : ℝ) ≤ + Real.exp ((p + 2) ^ 37) := by + push_cast + apply (pow_le_pow_left₀ (by positivity) hbase columns).trans + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + calc + (columns : ℝ) * (p + 2) ^ 36 ≤ (p + 2) * (p + 2) ^ 36 := by gcongr; linarith + _ = _ := by ring + have hcol : (columns : ℝ) + 1 ≤ Real.exp p := + (by linarith : (columns : ℝ) + 1 ≤ p + 1).trans (Real.add_one_le_exp p) + have hp37 : p ≤ (p + 2) ^ 37 := le_power_budget hp (by decide) + unfold rankCutDirectionHeight + change (((columns + 1) * (H * rationalKernelHeight (rows + 1) Hsys) ^ columns : ℕ) : ℝ) ≤ _ + push_cast + simp only [Nat.cast_pow, Nat.cast_mul] at hpow + calc + _ ≤ Real.exp p * Real.exp ((p + 2) ^ 37) := mul_le_mul hcol hpow (by positivity) (Real.exp_nonneg _) + _ = Real.exp (p + (p + 2) ^ 37) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by + calc + p + (p + 2) ^ 37 ≤ 2 * (p + 2) ^ 37 := by linarith + _ ≤ (p + 2) * (p + 2) ^ 37 := by gcongr; linarith + _ = _ := by ring) + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +open scoped BigOperators +open VectorPolynomial + +abbrev RankPreparationFamily (I J : Type) (s : ℕ) := Fin s → RankPreparationLayer I J + +namespace RankPreparationFamily + +variable {I J : Type} {s : ℕ} + +noncomputable def value [DecidableEq J] (L : RankPreparationFamily I J s) (x : I → ℝ) : J → ℝ := + ∑ i, (L i).value x + +noncomputable def potential (L : RankPreparationFamily I J s) : ℕ := + layerRankPotential (fun i => (L i).rank) + +noncomputable def reindex (L : RankPreparationFamily I J s) (f : I → MvPolynomial I ℝ) : + RankPreparationFamily I J s := fun i => (L i).reindex f + +@[simp] theorem reindex_potential (L : RankPreparationFamily I J s) (f : I → MvPolynomial I ℝ) : + (L.reindex f).potential = L.potential := rfl + +theorem reindex_value [DecidableEq J] (L : RankPreparationFamily I J s) + (f : I → MvPolynomial I ℝ) (x : I → ℝ) : + (L.reindex f).value x = L.value (fun i => MvPolynomial.aeval (R := ℝ) x (f i)) := by + apply Finset.sum_congr rfl + intro i _ + exact (L i).reindex_value f x + +noncomputable def descend (L : RankPreparationFamily I J s) (upper lower : Fin s) + (a : (L upper).Coord → ℤ) (e : (L upper).Coord → ℚ) (l : MvPolynomial I ℝ) : + RankPreparationFamily I J s := fun i => + if i = upper then (L upper).cut a (fun i => (e i : ℝ)) + else if i = lower then (L lower).appendLine (L upper).label e l + else L i + +theorem descend_potential (L : RankPreparationFamily I J s) (upper lower : Fin s) + (hlevel : upper.val = lower.val + 1) + (a : (L upper).Coord → ℤ) (e : (L upper).Coord → ℚ) (l : MvPolynomial I ℝ) + (he : (fun i => (e i : ℝ)) ∈ (L upper).space) + (hae : integerRowLinear a (fun i => (e i : ℝ)) = 1) : + (L.descend upper lower a e l).potential + 1 ≤ L.potential := by + have hne : upper ≠ lower := by intro h; rw [h] at hlevel; omega + have he0 : (fun i => (e i : ℝ)) ≠ 0 := by + intro hz + rw [hz, map_zero] at hae + norm_num at hae + apply layerRankPotential_transfer upper lower hlevel + intro i + by_cases hiu : i = upper + · subst i + have hd := (L upper).cut_rank_lt a (fun i => (e i : ℝ)) he hae + simpa [descend, Pi.single_apply, hne] using hd + · by_cases hil : i = lower + · subst i + simp [descend, Ne.symm hne, + RankPreparationLayer.appendLine_rank _ _ _ _ he0] + · simp [descend, hiu, hil] + +theorem descend_valid (L : RankPreparationFamily I J s) (upper lower : Fin s) + (hne : upper ≠ lower) (H : Fin s → ℕ) {R He : ℕ} + (hH : ∀ i, 1 ≤ H i) (hR : 1 ≤ R) + (hL : ∀ i, (L i).Valid (i.val + 1) (H i) R) + (a : (L upper).Coord → ℤ) (e : (L upper).Coord → ℚ) (l : MvPolynomial I ℝ) + (ha : ∀ i, |(a i : ℝ)| ≤ R) (heH : ∀ i, RationalHeightLE (e i) He) + (he : (fun i => (e i : ℝ)) ∈ (L upper).space) + (hae : integerRowLinear a (fun i => (e i : ℝ)) = 1) + (hl : l.totalDegree ≤ lower.val + 1) : + ∀ i, (L.descend upper lower a e l i).Valid (i.val + 1) + (if i = lower then max (H i) He else H i) R := by + intro i + by_cases hiu : i = upper + · subst i + simpa [descend, hne] using + (hL upper).cut hR a (fun i => (e i : ℝ)) ha he hae + · by_cases hil : i = lower + · subst i + simpa [descend, Ne.symm hne] using + (hL lower).appendLine (hH lower) hR (L upper).label e l heH hl + · simpa [descend, hiu, hil] using hL i + +theorem sum_replace_two {A V : Type*} [Fintype A] [DecidableEq A] [AddCommGroup V] + (f : A → V) (u v : A) (hne : u ≠ v) (a b : V) : + (∑ i, if i = u then a else if i = v then b else f i) = + (∑ i, f i) + (a - f u) + (b - f v) := by + calc + _ = ∑ i, (f i + (if i = u then a - f u else 0) + (if i = v then b - f v else 0)) := by + apply Finset.sum_congr rfl + intro i _ + by_cases hiu : i = u + · subst i + simp [hne] + · by_cases hiv : i = v + · subst i + simp [Ne.symm hne] + · simp [hiu, hiv] + _ = _ := by simp only [Finset.sum_add_distrib, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + +theorem descend_value [DecidableEq J] (L : RankPreparationFamily I J s) (upper lower : Fin s) + (hne : upper ≠ lower) (a : (L upper).Coord → ℤ) (e : (L upper).Coord → ℚ) + (l : MvPolynomial I ℝ) (x : I → ℝ) : + (L.descend upper lower a e l).value x = L.value x + + ((L upper).cut a (fun i => (e i : ℝ))).value x - (L upper).value x + + coordinateCopySum (L upper).label + (MvPolynomial.aeval (R := ℝ) x l • fun i => (e i : ℝ)) := by + have ht := sum_replace_two (fun i => (L i).value x) upper lower hne + (((L upper).cut a (fun i => (e i : ℝ))).value x) + (((L lower).appendLine (L upper).label e l).value x) + have hsum : (L.descend upper lower a e l).value x = + ∑ i, if i = upper then ((L upper).cut a (fun i => (e i : ℝ))).value x + else if i = lower then ((L lower).appendLine (L upper).label e l).value x + else (L i).value x := by + apply Finset.sum_congr rfl + intro i _ + simp only [descend] + split_ifs <;> rfl + rw [hsum, ht, RankPreparationLayer.appendLine_value] + unfold value + abel + +noncomputable def absorb (L : RankPreparationFamily I J s) (lowest : Fin s) + (a : (L lowest).Coord → ℤ) (e : (L lowest).Coord → ℚ) : RankPreparationFamily I J s := + fun i => if i = lowest then (L lowest).cut a (fun i => (e i : ℝ)) else L i + +theorem absorb_potential (L : RankPreparationFamily I J s) (lowest : Fin s) + (hlowest : lowest.val = 0) (a : (L lowest).Coord → ℤ) (e : (L lowest).Coord → ℚ) + (he : (fun i => (e i : ℝ)) ∈ (L lowest).space) + (hae : integerRowLinear a (fun i => (e i : ℝ)) = 1) : + (L.absorb lowest a e).potential + 1 ≤ L.potential := by + apply layerRankPotential_absorb_constant lowest hlowest + intro i + by_cases hi : i = lowest + · subst i + have hd := (L lowest).cut_rank_lt a (fun i => (e i : ℝ)) he hae + simpa [absorb, Pi.single_apply] using hd + · simp [absorb, hi] + +theorem absorb_valid (L : RankPreparationFamily I J s) (lowest : Fin s) + (H : Fin s → ℕ) {R : ℕ} (hR : 1 ≤ R) + (hL : ∀ i, (L i).Valid (i.val + 1) (H i) R) + (a : (L lowest).Coord → ℤ) (e : (L lowest).Coord → ℚ) + (ha : ∀ i, |(a i : ℝ)| ≤ R) + (he : (fun i => (e i : ℝ)) ∈ (L lowest).space) + (hae : integerRowLinear a (fun i => (e i : ℝ)) = 1) : + ∀ i, (L.absorb lowest a e i).Valid (i.val + 1) (H i) R := by + intro i + by_cases hi : i = lowest + · subst i + simpa [absorb] using (hL lowest).cut hR a (fun i => (e i : ℝ)) ha he hae + · simpa [absorb, hi] using hL i + +theorem sum_replace_one {A V : Type*} [Fintype A] [DecidableEq A] [AddCommGroup V] + (f : A → V) (u : A) (a : V) : + (∑ i, if i = u then a else f i) = (∑ i, f i) + (a - f u) := by + calc + _ = ∑ i, (f i + if i = u then a - f u else 0) := by + apply Finset.sum_congr rfl + intro i _ + by_cases hi : i = u + · subst i; simp + · simp [hi] + _ = _ := by simp only [Finset.sum_add_distrib, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + +theorem absorb_value [DecidableEq J] (L : RankPreparationFamily I J s) (lowest : Fin s) + (a : (L lowest).Coord → ℤ) (e : (L lowest).Coord → ℚ) (x : I → ℝ) : + (L.absorb lowest a e).value x = L.value x + + ((L lowest).cut a (fun i => (e i : ℝ))).value x - (L lowest).value x := by + have ht := sum_replace_one (fun i => (L i).value x) lowest + (((L lowest).cut a (fun i => (e i : ℝ))).value x) + have hsum : (L.absorb lowest a e).value x = + ∑ i, if i = lowest then ((L lowest).cut a (fun i => (e i : ℝ))).value x else (L i).value x := by + apply Finset.sum_congr rfl + intro i _ + simp only [absorb] + split_ifs <;> rfl + rw [hsum, ht] + unfold value + abel + +end RankPreparationFamily +end Erdos3 + +end + +section + +namespace Erdos3.RankPreparationFamily + +open VectorPolynomial +open scoped BigOperators + +theorem exists_descend_slice_step {I J : Type} [Fintype I] [DecidableEq I] [DecidableEq J] + {s : ℕ} (L : RankPreparationFamily I J s) (upper lower : Fin s) + (hlevel : upper.val = lower.val + 1) (N : I → ℕ) (H : Fin s → ℕ) + {R : ℕ} {δ : ℝ} (hH : ∀ i, 1 ≤ H i) (hR : 1 ≤ R) (hδ : 0 < δ) + (hN : ∀ i, 0 < N i) (hL : ∀ i, (L i).Valid (i.val + 1) (H i) R) + (hfail : ¬ HasLayerSamplingRank (upper.val + 1) (fun i => (N i : ℝ)) R + (L upper).space (L upper).poly) (f : (∀ i, Fin (N i)) → ℝ) : + let He := rankCutDirectionHeight (Fintype.card (L upper).Coord) + (Fintype.card (L upper).Column) (Fintype.card (L upper).Row) (H upper) R + let K := (((upper.val + 1 : ℕ) : ℝ) + 1) * ((Fintype.card I : ℝ) + 1) ^ (upper.val + 1) * + R * Fintype.card I * ((upper.val + 1 : ℕ) : ℝ) * He + let ρ := min 1 (δ / (K + 1)) + (∀ i, 4 * ((R * He ^ Fintype.card (L upper).Coord : ℕ) : ℝ) ≤ ρ * N i) → + ∃ (a : (L upper).Coord → ℤ) (e : (L upper).Coord → ℚ) + (q : ℕ) (S : ResidueBoxSlice N q) (l : MvPolynomial I ℝ) + (ip : J → MvPolynomial I ℤ) (c : J → ℝ) (err : (∀ i, Fin (S.length i)) → J → ℝ), + let L' := (L.descend upper lower a e l).reindex S.polynomial + (∀ i, |(a i : ℝ)| ≤ R) ∧ (∀ i, RationalHeightLE (e i) He) ∧ + L'.potential + 1 ≤ L.potential ∧ + (∀ i, (L' i).Valid (i.val + 1) (if i = lower then max (H i) He else H i) R) ∧ + 0 < q ∧ q ≤ R * He ^ Fintype.card (L upper).Coord ∧ + (∀ i, 0 < S.length i ∧ ρ * N i ≤ 4 * q * S.length i) ∧ + ((𝔼 x, f x) ≤ 𝔼 x : (∀ i, Fin (S.length i)), f (S.point x)) ∧ + (∀ j, (ip j).totalDegree ≤ upper.val + 1) ∧ + (∀ x j, |err x j| ≤ Fintype.card (L upper).Coord * δ) ∧ + ∀ x j, L.value (fun i => ((S.point x i).val : ℝ)) j = + L'.value (fun i => ((x i).val : ℝ)) j + + (MvPolynomial.eval (fun i => ((x i).val : ℤ)) (ip j) : ℝ) + c j + err x j := by + classical + intro He K ρ hlarge + have hne : upper ≠ lower := by intro h; rw [h] at hlevel; omega + obtain ⟨a, e, q, S, cut, l, E, ip, c, hcut, ha, heH, heW, hae, hmem, hdeg, hl, hE, + hrank, hq, hqbound, hlength, hscore, hip, hparts⟩ := + exists_rankPreparationStep (L upper).basis (L upper).rows (L upper).poly N + (hH upper) hR hδ hN (hL upper).2.2.1 (hL upper).2.2.2 + (hL upper).1 (hL upper).2.1 hfail f hlarge + let V := L.descend upper lower a e l + let L' := V.reindex S.polynomial + let ip' : J → MvPolynomial I ℤ := coordinateCopySum (L upper).label ip + let c' : J → ℝ := coordinateCopySum (L upper).label c + let er (x : ∀ i, Fin (S.length i)) (j : (L upper).Coord) : ℝ := + (MvPolynomial.eval (fun i => ((S.point x i).val : ℝ)) E - + MvPolynomial.eval (fun i => (S.start i : ℝ)) E) * (e j : ℝ) + let er' (x : ∀ i, Fin (S.length i)) : J → ℝ := coordinateCopySum (L upper).label (er x) + refine ⟨a, e, q, S, l, ip', c', er', ha, heH, ?_, ?_, hq, hqbound, hlength, hscore, ?_, ?_, ?_⟩ + · exact L.descend_potential upper lower hlevel a e l heW hae + · intro i + exact (L.descend_valid upper lower hne H hH hR hL a e l ha heH heW hae + (by omega) i).reindex S.polynomial S.polynomial_degree + · exact coordinateCopySum_polynomial_degree (L upper).label ip hip + · intro x j + exact coordinateCopySum_abs_le (L upper).label hδ.le (fun i => (hparts x i).1) j + · intro x j + let y : I → ℝ := fun i => ((S.point x i).val : ℝ) + have hv : eval y (L upper).poly = eval y cut + + MvPolynomial.eval y l • (fun i => (e i : ℝ)) + + (fun i => (MvPolynomial.eval (fun v => ((x v).val : ℤ)) (ip i) : ℝ)) + c + er x := by + ext i + exact (hparts x i).2 + have hcopy := congrArg (coordinateCopySum (L upper).label) hv + simp only [map_add] at hcopy + have hint : (MvPolynomial.eval (fun i => ((x i).val : ℤ)) (ip' j) : ℝ) = + coordinateCopySum (L upper).label + (fun i => (MvPolynomial.eval (fun v => ((x v).val : ℤ)) (ip i) : ℝ)) j := + coordinateCopySum_map (L upper).label + ((Int.castRingHom ℝ).comp (MvPolynomial.eval (fun v => ((x v).val : ℤ)))) ip j + have hnew : L'.value (fun i => ((x i).val : ℝ)) = V.value y := by + exact (reindex_value V S.polynomial _).trans (by simp only [ResidueBoxSlice.polynomial_eval]; rfl) + have hdesc := L.descend_value upper lower hne a e l y + rw [hcut] at hcopy + have hcopyj := congrFun hcopy j + have hdescj := congrFun hdesc j + change L.value y j = L'.value (fun i => ((x i).val : ℝ)) j + _ + _ + _ + rw [hnew, hint] + change (L upper).value y j = + ((L upper).cut a (fun i => (e i : ℝ))).value y j + + coordinateCopySum (L upper).label (MvPolynomial.eval y l • fun i => (e i : ℝ)) j + + coordinateCopySum (L upper).label + (fun i => (MvPolynomial.eval (fun v => ((x v).val : ℤ)) (ip i) : ℝ)) j + c' j + er' x j at hcopyj + simp only [Pi.add_apply, Pi.sub_apply, MvPolynomial.aeval_eq_eval] at hdescj + dsimp only [V] at * + linarith + +theorem exists_absorb_slice_step {I J : Type} [Fintype I] [DecidableEq I] [DecidableEq J] + {s : ℕ} (L : RankPreparationFamily I J s) (lowest : Fin s) + (hlowest : lowest.val = 0) (N : I → ℕ) (H : Fin s → ℕ) + {R : ℕ} {δ : ℝ} (hH : ∀ i, 1 ≤ H i) (hR : 1 ≤ R) (hδ : 0 < δ) + (hN : ∀ i, 0 < N i) (hL : ∀ i, (L i).Valid (i.val + 1) (H i) R) + (hfail : ¬ HasLayerSamplingRank (lowest.val + 1) (fun i => (N i : ℝ)) R + (L lowest).space (L lowest).poly) (f : (∀ i, Fin (N i)) → ℝ) : + let He := rankCutDirectionHeight (Fintype.card (L lowest).Coord) + (Fintype.card (L lowest).Column) (Fintype.card (L lowest).Row) (H lowest) R + let K := (((lowest.val + 1 : ℕ) : ℝ) + 1) * ((Fintype.card I : ℝ) + 1) ^ (lowest.val + 1) * + R * Fintype.card I * ((lowest.val + 1 : ℕ) : ℝ) * He + let ρ := min 1 (δ / (K + 1)) + (∀ i, 4 * ((R * He ^ Fintype.card (L lowest).Coord : ℕ) : ℝ) ≤ ρ * N i) → + ∃ (a : (L lowest).Coord → ℤ) (e : (L lowest).Coord → ℚ) + (q : ℕ) (S : ResidueBoxSlice N q) + (ip : J → MvPolynomial I ℤ) (c : J → ℝ) (err : (∀ i, Fin (S.length i)) → J → ℝ), + let L' := (L.absorb lowest a e).reindex S.polynomial + (∀ i, |(a i : ℝ)| ≤ R) ∧ (∀ i, RationalHeightLE (e i) He) ∧ + L'.potential + 1 ≤ L.potential ∧ + (∀ i, (L' i).Valid (i.val + 1) (H i) R) ∧ + 0 < q ∧ q ≤ R * He ^ Fintype.card (L lowest).Coord ∧ + (∀ i, 0 < S.length i ∧ ρ * N i ≤ 4 * q * S.length i) ∧ + ((𝔼 x, f x) ≤ 𝔼 x : (∀ i, Fin (S.length i)), f (S.point x)) ∧ + (∀ j, (ip j).totalDegree ≤ lowest.val + 1) ∧ + (∀ x j, |err x j| ≤ Fintype.card (L lowest).Coord * δ) ∧ + ∀ x j, L.value (fun i => ((S.point x i).val : ℝ)) j = + L'.value (fun i => ((x i).val : ℝ)) j + + (MvPolynomial.eval (fun i => ((x i).val : ℤ)) (ip j) : ℝ) + c j + err x j := by + classical + intro He K ρ hlarge + obtain ⟨a, e, q, S, cut, l, E, ip, c, hcut, ha, heH, heW, hae, hmem, hdeg, hl, hE, + hrank, hq, hqbound, hlength, hscore, hip, hparts⟩ := + exists_rankPreparationStep (L lowest).basis (L lowest).rows (L lowest).poly N + (hH lowest) hR hδ hN (hL lowest).2.2.1 (hL lowest).2.2.2 + (hL lowest).1 (hL lowest).2.1 hfail f hlarge + have hconst : l = MvPolynomial.C (l.coeff 0) := + MvPolynomial.totalDegree_eq_zero_iff_eq_C.mp (by omega) + let V := L.absorb lowest a e + let L' := V.reindex S.polynomial + let ip' : J → MvPolynomial I ℤ := coordinateCopySum (L lowest).label ip + let c' : J → ℝ := coordinateCopySum (L lowest).label ((l.coeff 0) • (fun i => (e i : ℝ)) + c) + let er (x : ∀ i, Fin (S.length i)) (j : (L lowest).Coord) : ℝ := + (MvPolynomial.eval (fun i => ((S.point x i).val : ℝ)) E - + MvPolynomial.eval (fun i => (S.start i : ℝ)) E) * (e j : ℝ) + let er' (x : ∀ i, Fin (S.length i)) : J → ℝ := coordinateCopySum (L lowest).label (er x) + refine ⟨a, e, q, S, ip', c', er', ha, heH, ?_, ?_, hq, hqbound, hlength, hscore, ?_, ?_, ?_⟩ + · exact L.absorb_potential lowest hlowest a e heW hae + · intro i + exact (L.absorb_valid lowest H hR hL a e ha heW hae i).reindex S.polynomial S.polynomial_degree + · exact coordinateCopySum_polynomial_degree (L lowest).label ip hip + · intro x j + exact coordinateCopySum_abs_le (L lowest).label hδ.le (fun i => (hparts x i).1) j + · intro x j + let y : I → ℝ := fun i => ((S.point x i).val : ℝ) + have hv : eval y (L lowest).poly = eval y cut + + MvPolynomial.eval y l • (fun i => (e i : ℝ)) + + (fun i => (MvPolynomial.eval (fun v => ((x v).val : ℤ)) (ip i) : ℝ)) + c + er x := by + ext i + exact (hparts x i).2 + have hel : MvPolynomial.eval y l = l.coeff 0 := by + conv_lhs => rw [hconst] + rw [MvPolynomial.eval_C] + rw [hel] at hv + have hcopy := congrArg (coordinateCopySum (L lowest).label) hv + simp only [map_add] at hcopy + have hint : (MvPolynomial.eval (fun i => ((x i).val : ℤ)) (ip' j) : ℝ) = + coordinateCopySum (L lowest).label + (fun i => (MvPolynomial.eval (fun v => ((x v).val : ℤ)) (ip i) : ℝ)) j := + coordinateCopySum_map (L lowest).label + ((Int.castRingHom ℝ).comp (MvPolynomial.eval (fun v => ((x v).val : ℤ)))) ip j + have hnew : L'.value (fun i => ((x i).val : ℝ)) = V.value y := by + exact (reindex_value V S.polynomial _).trans (by simp only [ResidueBoxSlice.polynomial_eval]; rfl) + have habs := L.absorb_value lowest a e y + rw [hcut] at hcopy + have hcopyj := congrFun hcopy j + have habsj := congrFun habs j + change L.value y j = L'.value (fun i => ((x i).val : ℝ)) j + _ + _ + _ + rw [hnew, hint] + change (L lowest).value y j = + ((L lowest).cut a (fun i => (e i : ℝ))).value y j + + coordinateCopySum (L lowest).label ((l.coeff 0) • fun i => (e i : ℝ)) j + + coordinateCopySum (L lowest).label + (fun i => (MvPolynomial.eval (fun v => ((x v).val : ℤ)) (ip i) : ℝ)) j + + coordinateCopySum (L lowest).label c j + er' x j at hcopyj + simp only [Pi.add_apply, Pi.sub_apply] at habsj + dsimp only [V, c'] at * + simp only [map_add, Pi.add_apply] + linarith + +end Erdos3.RankPreparationFamily + +end + +section + +namespace Erdos3.RankPreparationFamily + +variable {I J : Type} {s : ℕ} + +def Sized (L : RankPreparationFamily I J s) (D t : ℕ) : Prop := + ∀ i, Fintype.card (L i).Coord ≤ D * (t + 1) ^ (s - 1 - i.val) ∧ + Fintype.card (L i).Column ≤ D + t ∧ Fintype.card (L i).Row ≤ t + +theorem Sized.mono {L : RankPreparationFamily I J s} {D t u : ℕ} + (h : L.Sized D t) (htu : t ≤ u) : L.Sized D u := by + intro i + obtain ⟨hc, hb, hr⟩ := h i + refine ⟨hc.trans (Nat.mul_le_mul_left _ (Nat.pow_le_pow_left (by omega) _)), by omega, by omega⟩ + +theorem Sized.reindex {L : RankPreparationFamily I J s} {D t : ℕ} + (h : L.Sized D t) (f : I → MvPolynomial I ℝ) : (L.reindex f).Sized D t := h + +theorem copy_power_step (a d : ℕ) : a ^ (d + 1) + a ^ d ≤ (a + 1) ^ (d + 1) := by + calc + a ^ (d + 1) + a ^ d = a ^ d * (a + 1) := by rw [pow_succ]; ring + _ ≤ (a + 1) ^ d * (a + 1) := Nat.mul_le_mul_right _ (Nat.pow_le_pow_left (by omega) _) + _ = _ := (pow_succ _ _).symm + +theorem Sized.descend {L : RankPreparationFamily I J s} {D t : ℕ} (h : L.Sized D t) + (upper lower : Fin s) (hlevel : upper.val = lower.val + 1) + (a : (L upper).Coord → ℤ) (e : (L upper).Coord → ℚ) (l : MvPolynomial I ℝ) : + (L.descend upper lower a e l).Sized D (t + 1) := by + have hne : upper ≠ lower := by intro heq; rw [heq] at hlevel; omega + have hmono := h.mono (Nat.le_succ t) + intro i + by_cases hiu : i = upper + · subst i + simp only [RankPreparationFamily.descend, ↓reduceIte] + change Fintype.card (L upper).Coord ≤ _ ∧ Fintype.card (L upper).Column ≤ _ ∧ + Fintype.card (Option (L upper).Row) ≤ _ + exact ⟨(hmono upper).1, (hmono upper).2.1, by simpa using Nat.add_le_add_right (h upper).2.2 1⟩ + · by_cases hil : i = lower + · subst i + simp only [RankPreparationFamily.descend, hiu, ↓reduceIte] + change Fintype.card ((L lower).Coord ⊕ (L upper).Coord) ≤ _ ∧ + Fintype.card (Option (L lower).Column) ≤ _ ∧ Fintype.card (L lower).Row ≤ _ + have hd : s - 1 - lower.val = (s - 1 - upper.val) + 1 := by omega + refine ⟨?_, ?_, (hmono lower).2.2⟩ + · rw [Fintype.card_sum] + calc + _ ≤ D * (t + 1) ^ (s - 1 - lower.val) + D * (t + 1) ^ (s - 1 - upper.val) := + Nat.add_le_add (h lower).1 (h upper).1 + _ = D * ((t + 1) ^ ((s - 1 - upper.val) + 1) + (t + 1) ^ (s - 1 - upper.val)) := by + rw [hd, Nat.mul_add] + _ ≤ D * (t + 1 + 1) ^ ((s - 1 - upper.val) + 1) := + Nat.mul_le_mul_left D (copy_power_step _ _) + _ = _ := by rw [hd] + · rw [Fintype.card_option] + have hb := (h lower).2.1 + omega + · simpa only [RankPreparationFamily.descend, hiu, hil, ↓reduceIte] using hmono i + +theorem Sized.absorb {L : RankPreparationFamily I J s} {D t : ℕ} (h : L.Sized D t) + (lowest : Fin s) (a : (L lowest).Coord → ℤ) (e : (L lowest).Coord → ℚ) : + (L.absorb lowest a e).Sized D (t + 1) := by + have hmono := h.mono (Nat.le_succ t) + intro i + by_cases hi : i = lowest + · subst i + simp only [RankPreparationFamily.absorb, ↓reduceIte] + change Fintype.card (L lowest).Coord ≤ _ ∧ Fintype.card (L lowest).Column ≤ _ ∧ + Fintype.card (Option (L lowest).Row) ≤ _ + exact ⟨(hmono lowest).1, (hmono lowest).2.1, by simpa using Nat.add_le_add_right (h lowest).2.2 1⟩ + · simpa only [RankPreparationFamily.absorb, hi, ↓reduceIte] using hmono i + +theorem Sized.uniform {L : RankPreparationFamily I J s} {D t T : ℕ} + (h : L.Sized D t) (ht : t ≤ T) (i : Fin s) : + Fintype.card (L i).Coord ≤ D * (T + 1) ^ s ∧ + Fintype.card (L i).Column ≤ D + T ∧ Fintype.card (L i).Row ≤ T := by + have hm := h.mono ht + refine ⟨(hm i).1.trans (Nat.mul_le_mul_left D ?_), (hm i).2⟩ + exact Nat.pow_le_pow_right (by omega) (by omega) + +end Erdos3.RankPreparationFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankProductOrbitCoefficients.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankProductOrbitCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..18e252ba4e1f7bdb59d2b1246348a636ba7f0969 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankProductOrbitCoefficients.lean @@ -0,0 +1,58 @@ +import OAI.Combinatorics.Progressions.Linear.RankIntervalFactorization + +namespace OAI + +section + +namespace Erdos3.NativeRankInterval + +open RationalFilteredNilmanifold VectorPolynomial +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {t : ZMod N × ZMod N × ZMod N} {branch : Bool} + (I : NativeRankInterval W out H t branch p q) (i : Fin I.expansion.count) + +theorem rankProjection_coefficient (α : Unit →₀ ℕ) (k : Fin 4) : + (LinearMap.proj k).baseChange ℝ + ((I.rankProjection i).toLinearMap.baseChange ℝ (coefficients (I.productOrbit i).log α)) = + coefficients ((W.fourPointFactors out (rankQuadrupleParameters t) + (cyclicBranchOffset t.1 branch) ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)).orbit).log α := by + change realificationLieHom (liePiEval k) + (realificationLieHom (I.rankProjection i) (coefficients (I.productOrbit i).log α)) = _ + have h := realification_liePiEval_liePiMap (M := fun _ : Fin 4 => W.L) + (fun j : Fin 4 => (liePiEval (some ((![1, 2, 0, 3] : Fin 4 → Fin 4) j)) : + (∀ a : Option (Fin 4), optionLieSpace (I.expansion.L i) (fun _ : Fin 4 => W.L) a) →ₗ⁅ℚ⁆ W.L)) + (coefficients (I.productOrbit i).log α) k + apply h.trans + exact NilpotentLieFiltration.piRealOrbit_coefficient + (fun j => (I.productModels i j).filtration) (fun j => (I.productTests i j).orbit) + α (some ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)) + +theorem rankProjection_component_log (k : Fin 4) : + VectorPolynomial.map + ((realificationLieHom ((liePiEval k).comp (I.rankProjection i))).toLinearMap.restrictScalars ℚ) + (I.productOrbit i).log = + (W.fourPointFactors out (rankQuadrupleParameters t) (cyclicBranchOffset t.1 branch) + ((![1, 2, 0, 3] : Fin 4 → Fin 4) k)).orbit.log := by + apply coefficients.injective + ext α + rw [coefficients_map] + change ((LinearMap.proj k).comp (I.rankProjection i).toLinearMap).baseChange ℝ + (coefficients (I.productOrbit i).log α) = _ + rw [LinearMap.baseChange_comp, LinearMap.comp_apply] + exact I.rankProjection_coefficient i α k + +end Erdos3.NativeRankInterval + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankQuotientHeightBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankQuotientHeightBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..539b4891f63d74762b98263377e2f60e949648d6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankQuotientHeightBudget.lean @@ -0,0 +1,607 @@ +import Mathlib.LinearAlgebra.Basis.VectorSpace +import OAI.Combinatorics.Progressions.Dynamics.SparseGeneratorBudget +import OAI.Combinatorics.Progressions.Estimates.BoundedQuotientFunctional +import OAI.Combinatorics.Progressions.Estimates.StepDropTerminalContainment +import OAI.Combinatorics.Progressions.Geometry.SubmoduleQuotientCoordinates +import OAI.Combinatorics.Progressions.Polynomial.FreeDegreeRankAdaptedBounds + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι κ V : Type*} [AddCommGroup V] [Module ℚ V] [Fintype ι] [Fintype κ] + +theorem exists_bounded_submodule_quotient_basis (b : Basis ι ℚ V) (U : Submodule ℚ V) + (v : κ → V) (hspan : Submodule.span ℚ (Set.range v) = U) + {H : ℕ} (hH : 1 ≤ H) (hv : ∀ j i, RationalHeightLE (b.repr (v j) i) H) : + ∃ t : ℕ, t ≤ Fintype.card κ ∧ ∃ d : ℕ, d ≤ Fintype.card ι ∧ + ∃ f : Basis (Fin d) ℚ (V ⧸ U), + ∀ i j, RationalHeightLE (f.repr (U.mkQ (b j)) i) (rationalKernelHeight t H) := by + classical + let A : Matrix ι κ ℚ := fun i j => b.repr (v j) i + have hA : LinearMap.range A.mulVecLin = U.map b.equivFun.toLinearMap := by + rw [Matrix.range_mulVecLin, ← hspan, Submodule.map_span, ← Set.range_comp] + rfl + obtain ⟨t, ht, d, hd, D, hsurj, hker, hD⟩ := + exists_bounded_image_equations A hH (fun i j => hv j i) + have hkerD := hker.trans hA + let f := submoduleQuotientCoordinateBasis b U D hkerD hsurj + have hf : LinearMap.toMatrix b f U.mkQ = D := + submoduleQuotientCoordinateBasis_matrix b U D hkerD hsurj + refine ⟨t, ht, d, hd, f, fun i j => ?_⟩ + have hij := congrFun (congrFun hf i) j + rw [LinearMap.toMatrix_apply] at hij + rw [hij] + exact hD i j + +theorem exists_submodule_quotient_basis_exp (b : Basis ι ℚ V) (U : Submodule ℚ V) + (v : κ → V) (hspan : Submodule.span ℚ (Set.range v) = U) + {H : ℕ} (hH : 1 ≤ H) (hv : ∀ j i, RationalHeightLE (b.repr (v j) i) H) + {p : ℝ} (hp : 0 ≤ p) (hm : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ H' : ℕ, 1 ≤ H' ∧ (H' : ℝ) ≤ Real.exp ((p + 2) ^ 7) ∧ + ∃ d : ℕ, d ≤ Fintype.card ι ∧ ∃ f : Basis (Fin d) ℚ (V ⧸ U), + ∀ i j, RationalHeightLE (f.repr (U.mkQ (b j)) i) H' := by + obtain ⟨t, ht, d, hd, f, hf⟩ := exists_bounded_submodule_quotient_basis b U v hspan hH hv + exact ⟨rationalKernelHeight t H, rationalKernelHeight_pos t hH, + rationalKernelHeight_le_budget t H hp ((Nat.cast_le.mpr ht).trans hm) hHp, + d, hd, f, hf⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {ν L : Type*} [AddCommGroup L] [Module ℚ L] [FiniteDimensional ℚ L] + (e : Basis ν ℚ L) (H : ℕ) + +noncomputable def chosenBoundedSubmoduleBasis (U : Submodule ℚ L) : + Basis (Fin (finrank ℚ U)) ℚ U := by + classical + exact if h : ∃ b : Basis (Fin (finrank ℚ U)) ℚ U, + ∀ j k, RationalHeightLE (e.repr (b j).val k) H then h.choose else Module.finBasis ℚ U + +theorem chosenBoundedSubmoduleBasis_height (U : Submodule ℚ L) + (h : ∃ b : Basis (Fin (finrank ℚ U)) ℚ U, + ∀ j k, RationalHeightLE (e.repr (b j).val k) H) (j k) : + RationalHeightLE (e.repr (chosenBoundedSubmoduleBasis e H U j).val k) H := by + classical + unfold chosenBoundedSubmoduleBasis + rw [dite_eq_left h] + exact h.choose_spec j k + +theorem chosenBoundedSubmoduleBasis_range {U V : Submodule ℚ L} (h : U = V) : + Set.range (fun j => (chosenBoundedSubmoduleBasis e H U j).val) = + Set.range (fun j => (chosenBoundedSubmoduleBasis e H V j).val) := by + subst V + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +theorem exists_bounded_submodule_basis_from_spanning + {L μ κ : Type*} [AddCommGroup L] [Module ℚ L] [Fintype μ] + (b : Basis μ ℚ L) (V : Submodule ℚ L) (v : κ → L) + (hspan : Submodule.span ℚ (Set.range v) = V) {H : ℕ} + (hv : ∀ i j, RationalHeightLE (b.repr (v i) j) H) : + ∃ e : Basis (Fin (Module.finrank ℚ V)) ℚ V, + ∀ i j, RationalHeightLE (b.repr (e i : L) j) H := by + classical + let : FiniteDimensional ℚ L := b.finiteDimensional_of_finite + have hex := Submodule.exists_fun_fin_finrank_span_eq ℚ (Set.range v) + rw [hspan] at hex + obtain ⟨z, hz, hzspan, hzli⟩ := hex + refine ⟨(Basis.span hzli).map (LinearEquiv.ofEq _ _ hzspan), ?_⟩ + intro i j + simp only [Basis.map_apply, LinearEquiv.coe_ofEq_apply, Basis.coe_span_apply] + obtain ⟨k, hk⟩ := hz i + rw [← hk] + exact hv k j + +variable {L μ υ χ κ ν : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype μ] [Fintype υ] [Fintype χ] [Fintype κ] [Fintype ν] + +theorem exists_stepDrop_bounded_basis (b : Basis μ ℚ L) (w : μ → ℕ) + (U : LieSubalgebra ℚ L) (V K : Submodule ℚ L) + (fU : Basis υ ℚ (L ⧸ U.toSubmodule)) (fK : Basis χ ℚ (L ⧸ K)) + (fV : Basis ν ℚ (L ⧸ V)) (eK : Basis κ ℚ K) {H B : ℕ} (hH : 1 ≤ H) + (hU : ∀ i j, RationalHeightLE (fU.repr (U.toSubmodule.mkQ (b j)) i) H) + (hK : ∀ i j, RationalHeightLE (fK.repr (K.mkQ (b j)) i) H) + (hV : ∀ i j, RationalHeightLE (fV.repr (V.mkQ (b j)) i) H) + (hbr : ∀ i j z, RationalHeightLE (fV.repr (V.mkQ ⁅b j, (eK z : L)⁆) i) B) : + ∃ r : ℕ, r ≤ Fintype.card (StepDropRow υ χ κ ν) ∧ + ∃ e : Basis (Fin (Module.finrank ℚ (stepDropSubmodule b w U V K))) + ℚ (stepDropSubmodule b w U V K), + ∀ i j, RationalHeightLE (b.repr (e i : L) j) + ((Fintype.card μ + 1) * rationalKernelHeight r (max H B) ^ Fintype.card μ) := by + classical + let P := stepDropSystem b w U V K fU fK fV eK + have hP : ∀ i j, RationalHeightLE ((Pi.basisFun ℚ (StepDropRow υ χ κ ν)).repr (P (b i)) j) (max H B) := by + intro i j + change RationalHeightLE (P (b i) j) _ + exact stepDropSystem_basis_height b w U V K fU fK fV eK hH hU hK hV hbr j i + obtain ⟨r, hr, v, hspan, hv⟩ := exists_bounded_span_kernel_generators b + (Pi.basisFun ℚ (StepDropRow υ χ κ ν)) P b + (hH.trans (Nat.le_max_left H B)) (basis_repr_height_one b) hP + have hspan' : Submodule.span ℚ (Set.range v) = stepDropSubmodule b w U V K := by + simpa only [b.span_eq, top_inf_eq, P, stepDropSystem_ker] using hspan + have hv' : ∀ i j, RationalHeightLE (b.repr (v i) j) + ((Fintype.card μ + 1) * rationalKernelHeight r (max H B) ^ Fintype.card μ) := by + simpa only [mul_one] using hv + obtain ⟨e, he⟩ := exists_bounded_submodule_basis_from_spanning b _ v hspan' hv' + exact ⟨r, hr, e, he⟩ + +def stepDropBracketHeight (n H : ℕ) : ℕ := + (n + 1) * (((n ^ 2 + 1) * (H * H) ^ (n ^ 2)) * H) ^ n + +omit [Fintype κ] [Fintype ν] in +theorem stepDrop_bracket_height (b : Basis μ ℚ L) (V K : Submodule ℚ L) + (fV : Basis ν ℚ (L ⧸ V)) (eK : Basis κ ℚ K) {H : ℕ} + (hV : ∀ i j, RationalHeightLE (fV.repr (V.mkQ (b j)) i) H) + (heK : ∀ i j, RationalHeightLE (b.repr (eK j : L) i) H) + (hstructure : ∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) (i : ν) (j : μ) (z : κ) : + RationalHeightLE (fV.repr (V.mkQ ⁅b j, (eK z : L)⁆) i) (stepDropBracketHeight (Fintype.card μ) H) := by + have hbr := lie_bracket_coordinate_height b hstructure (b j) (eK z : L) + (basis_repr_height_one b j) (fun k => heK k z) + have h := linearMap_coordinate_height b fV V.mkQ (fun a c => hV c a) _ hbr i + simpa only [stepDropBracketHeight, mul_one] using h + +theorem stepDrop_basis_height_budget (n r H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (hr : (r : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + (((n + 1) * rationalKernelHeight r H ^ n : ℕ) : ℝ) ≤ Real.exp ((p + 2) ^ 9) := by + have hkernel := rationalKernelHeight_le_budget r H hp hr hH + have hfront : (n + 1 : ℝ) ≤ Real.exp n := Real.add_one_le_exp n + have hpower := pow_le_pow_left₀ (Nat.cast_nonneg (rationalKernelHeight r H)) hkernel n + rw [← Real.exp_nat_mul] at hpower + have h : (((n + 1) * rationalKernelHeight r H ^ n : ℕ) : ℝ) ≤ + Real.exp ((n : ℝ) + n * (p + 2) ^ 7) := by + push_cast + rw [Real.exp_add] + exact mul_le_mul hfront hpower (by positivity) (Real.exp_nonneg _) + apply h.trans (Real.exp_le_exp.mpr ?_) + have ht : (1 : ℝ) ≤ p + 2 := by linarith + have hpow : p + 2 ≤ (p + 2) ^ 8 := by + simpa only [pow_one] using pow_le_pow_right₀ ht (by decide : 1 ≤ 8) + calc + (n : ℝ) + n * (p + 2) ^ 7 ≤ p + p * (p + 2) ^ 7 := by gcongr + _ ≤ (p + 2) + (p + 2) * (p + 2) ^ 7 := by gcongr <;> linarith + _ = (p + 2) + (p + 2) ^ 8 := by ring + _ ≤ 2 * (p + 2) ^ 8 := by linarith + _ ≤ (p + 2) * (p + 2) ^ 8 := mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = (p + 2) ^ 9 := by ring + +theorem exists_stepDrop_basis_exp_height (b : Basis μ ℚ L) (w : μ → ℕ) + (U : LieSubalgebra ℚ L) (V K : Submodule ℚ L) + (fU : Basis υ ℚ (L ⧸ U.toSubmodule)) (fK : Basis χ ℚ (L ⧸ K)) + (fV : Basis ν ℚ (L ⧸ V)) (eK : Basis κ ℚ K) {H : ℕ} (hH : 1 ≤ H) + (hU : ∀ i j, RationalHeightLE (fU.repr (U.toSubmodule.mkQ (b j)) i) H) + (hK : ∀ i j, RationalHeightLE (fK.repr (K.mkQ (b j)) i) H) + (hV : ∀ i j, RationalHeightLE (fV.repr (V.mkQ (b j)) i) H) + (hbr : ∀ i j z, RationalHeightLE (fV.repr (V.mkQ ⁅b j, (eK z : L)⁆) i) H) + {p : ℝ} (hp : 0 ≤ p) (hμ : (Fintype.card μ : ℝ) ≤ p) + (hrows : (Fintype.card (StepDropRow υ χ κ ν) : ℝ) ≤ p) (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ e : Basis (Fin (Module.finrank ℚ (stepDropSubmodule b w U V K))) + ℚ (stepDropSubmodule b w U V K), ∀ i j, + (((b.repr (e i : L) j).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 9)) ∧ + (((b.repr (e i : L) j).den : ℝ) ≤ Real.exp ((p + 2) ^ 9)) := by + obtain ⟨r, hr, e, he⟩ := exists_stepDrop_bounded_basis b w U V K fU fK fV eK hH hU hK hV hbr + have hrp : (r : ℝ) ≤ p := (Nat.cast_le.mpr hr).trans hrows + have hb := stepDrop_basis_height_budget (Fintype.card μ) r H hp hμ hrp hHp + refine ⟨e, fun i j => ?_⟩ + have hij : RationalHeightLE (b.repr (e i : L) j) + ((Fintype.card μ + 1) * rationalKernelHeight r H ^ Fintype.card μ) := by + simpa only [max_self] using he i j + exact ⟨(Nat.cast_le.mpr hij.1).trans hb, (Nat.cast_le.mpr hij.2).trans hb⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +noncomputable def preimageBasisBudget (p : ℝ) : ℝ := + sparseGeneratorBudget (p + (p + (p + 3) ^ 7 + 2) ^ 4 + 1) + +theorem preimageBasisBudget_nonneg {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ preimageBasisBudget p := by + apply sparseGeneratorBudget_nonneg + positivity + +theorem exists_preimage_basis_logHeight + {V W μ ν ι κ : Type*} [AddCommGroup V] [Module ℚ V] + [AddCommGroup W] [Module ℚ W] [Fintype μ] [Fintype ν] [Fintype ι] [Fintype κ] + (e : Basis μ ℚ V) (f : Basis ν ℚ W) (U : Submodule ℚ V) (K : Submodule ℚ W) + (T : V →ₗ[ℚ] W) (u : ι → V) (v : κ → W) + (hu : Submodule.span ℚ (Set.range u) = U) + (hv : Submodule.span ℚ (Set.range v) = K) + {p : ℝ} (hp : 0 ≤ p) (hν : (Fintype.card ν : ℝ) ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (huH : ∀ a i, rationalLogHeight (e.repr (u a) i) ≤ p) + (hvH : ∀ a i, rationalLogHeight (f.repr (v a) i) ≤ p) + (hTu : ∀ a i, rationalLogHeight (f.repr (T (u a)) i) ≤ p) : + ∃ b : Basis (Fin (finrank ℚ (U ⊓ K.comap T : Submodule ℚ V))) ℚ + (U ⊓ K.comap T : Submodule ℚ V), + ∀ a i, rationalLogHeight (e.repr (b a : V) i) ≤ preimageBasisBudget p := by + obtain ⟨H, _, hH, d, hd, g, hg⟩ := exists_submodule_quotient_basis_exp f K v hv + (one_le_ceil_exp p) (fun a i => rationalHeightLE_ceil_exp (hvH a i)) + (show 0 ≤ p + 1 by linarith) (hκ.trans (by linarith)) (ceil_exp_le_exp_add_one hp) + have hgH (i : ν) (j : Fin d) : + rationalLogHeight (g.repr (K.mkQ (f i)) j) ≤ (p + 3) ^ 7 := by + have h := rationalLogHeight_le_of_height (hg j i) hH + simpa only [show p + 1 + 2 = p + 3 by ring] using h + let q := p + (p + 3) ^ 7 + have hpq : p ≤ q := le_add_of_nonneg_right (by positivity) + have hq : 0 ≤ q := hp.trans hpq + have hquot (a : ι) (j : Fin d) : + rationalLogHeight (g.repr (K.mkQ (T (u a))) j) ≤ (q + 2) ^ 4 := + linearMap_coordinate_logHeight f g K.mkQ hq (hν.trans hpq) + (fun i j => (hgH i j).trans (le_add_of_nonneg_left hp)) + (T (u a)) (fun i => (hTu a i).trans hpq) j + let Q := p + (q + 2) ^ 4 + have hpQ : p ≤ Q := le_add_of_nonneg_right (by positivity) + have hQ : 0 ≤ Q := hp.trans hpQ + let B := ⌈Real.exp Q⌉₊ + obtain ⟨t, ht, z, hz, hzH⟩ := exists_bounded_span_kernel_generators e g + (K.mkQ.comp T) u (one_le_ceil_exp Q) + (fun a i => rationalHeightLE_ceil_exp ((huH a i).trans hpQ)) + (fun a i => rationalHeightLE_ceil_exp + ((hquot a i).trans (le_add_of_nonneg_left hp))) + have hker : LinearMap.ker (K.mkQ.comp T) = K.comap T := by + rw [LinearMap.ker_comp, Submodule.ker_mkQ] + rw [hu, hker] at hz + obtain ⟨b, hb⟩ := exists_bounded_submodule_basis_from_spanning e _ z hz hzH + have ht' : (t : ℝ) ≤ p := by + exact (Nat.cast_le.mpr ((show t ≤ d by simpa only [Fintype.card_fin] using ht).trans hd)).trans hν + have hcost : (((Fintype.card ι + 1) * (rationalKernelHeight t B * B) ^ + Fintype.card ι : ℕ) : ℝ) ≤ Real.exp (preimageBasisBudget p) := + sparseGeneratorHeight_bound (show 0 ≤ Q + 1 by linarith) t (Fintype.card ι) B + (ht'.trans (hpQ.trans (by linarith))) (hι.trans (hpQ.trans (by linarith))) + (ceil_exp_le_exp_add_one hQ) + exact ⟨b, fun a i => rationalLogHeight_le_of_height (hb a i) hcost⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +def rankQuotientLayerHeight (n m H : ℕ) : ℕ := + (n + 1) * (H * rationalKernelHeight m H) ^ n + +def rankQuotientFrequencyHeight (n m u H : ℕ) : ℕ := + (u + 1) * (rationalSolveHeight u (rankQuotientLayerHeight n m H) * + ((n + 1) * (H * H) ^ n)) ^ u + +def rankQuotientHeight (n m q u H : ℕ) : ℕ := + max 1 (max (rationalKernelHeight m H) + (max (rationalLieStructureHeight n (max H (max (rationalKernelHeight m H) + (rationalSolveHeight q (rationalKernelHeight m H))))) + (max (rankQuotientLayerHeight n m H) (rankQuotientFrequencyHeight n m u H)))) + +theorem exists_bounded_rank_quotient_data + {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n t : ℕ} + (F : DegreeRankLieFiltration L s r) (e : Basis (Fin n) ℚ L) + (b : ∀ i : Fin (s + 1), Basis (Fin (finrank ℚ (F.associatedDegree.layer (i.val + 1)))) + ℚ (F.associatedDegree.layer (i.val + 1))) + (c : ∀ i j : Fin (s + 1), Basis (Fin (finrank ℚ (F.layer i.val j.val))) + ℚ (F.layer i.val j.val)) + (I : LieIdeal ℚ L) (a : Basis (Fin t) ℚ I) + (η : L →ₗ[ℚ] ℚ) (hann : F.layer s r ⊓ I.toSubmodule ≤ η.ker) + {H : ℕ} (hH : 1 ≤ H) + (hb : ∀ i a j, RationalHeightLE (e.repr (b i a).val j) H) + (hc : ∀ i j a k, RationalHeightLE (e.repr (c i j a).val k) H) + (ha : ∀ i j, RationalHeightLE (e.repr (a i).val j) H) + (hbracket : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hη : ∀ i, RationalHeightLE (η (e i)) H) : + ∃ m : ℕ, m ≤ t ∧ ∃ q : ℕ, q ≤ n ∧ ∃ u : ℕ, u ≤ q ∧ + ∃ f : Basis (Fin q) ℚ (L ⧸ I), + (∀ i j, RationalHeightLE (f.repr (lieQuotientMap I (e j)) i) + (rankQuotientHeight n m q u H)) ∧ + (∀ i j k, RationalHeightLE (lieStructureConstants f i j k) + (rankQuotientHeight n m q u H)) ∧ + (∀ i : Fin (s + 1), ∃ b' : Basis + (Fin (finrank ℚ ((F.associatedDegree.layer (i.val + 1)).map (lieQuotientMap I).toLinearMap))) + ℚ ((F.associatedDegree.layer (i.val + 1)).map (lieQuotientMap I).toLinearMap), + ∀ a j, RationalHeightLE (f.repr (b' a).val j) (rankQuotientHeight n m q u H)) ∧ + (∀ i j : Fin (s + 1), ∃ c' : Basis + (Fin (finrank ℚ ((F.layer i.val j.val).map (lieQuotientMap I).toLinearMap))) + ℚ ((F.layer i.val j.val).map (lieQuotientMap I).toLinearMap), + ∀ a k, RationalHeightLE (f.repr (c' a).val k) (rankQuotientHeight n m q u H)) ∧ + ∃ ξ : (L ⧸ I) →ₗ[ℚ] ℚ, + (∀ x ∈ F.layer s r, ξ (lieQuotientMap I x) = η x) ∧ + ∀ i, RationalHeightLE (ξ (f i)) (rankQuotientHeight n m q u H) := by + classical + obtain ⟨m, hm, q, hq, f, A, _, hmatrix, _, hA, _, hstructure⟩ := + exists_bounded_lie_quotient_with_structure e I (fun i => (a i).val) + (span_submodule_basis I.toSubmodule a) hH (fun i j => ha j i) hbracket + have hm' : m ≤ t := by simpa only [Fintype.card_fin] using hm + have hq' : q ≤ n := by simpa only [Fintype.card_fin] using hq + let π := (lieQuotientMap I).toLinearMap + let Q := rationalKernelHeight m H + let E := rankQuotientLayerHeight n m H + have hQ : 1 ≤ Q := rationalKernelHeight_pos m hH + have hE : 1 ≤ E := by + have : 0 < H := by omega + have : 0 < Q := by omega + change 1 ≤ (n + 1) * (H * Q) ^ n + exact Nat.one_le_iff_ne_zero.mpr (by positivity) + have hproj (i j) : RationalHeightLE (f.repr (π (e j)) i) Q := by + have h := hA i j + rw [← hmatrix, LinearMap.toMatrix_apply] at h + exact h + have himage (P : Submodule ℚ L) + (bP : Basis (Fin (finrank ℚ P)) ℚ P) + (hP : ∀ i j, RationalHeightLE (e.repr (bP i).val j) H) : + ∃ b' : Basis (Fin (finrank ℚ (P.map π))) ℚ (P.map π), + ∀ i j, RationalHeightLE (f.repr (b' i).val j) E := by + have hspan : Submodule.span ℚ (Set.range (fun i => π (bP i).val)) = P.map π := by + change Submodule.span ℚ (Set.range (π ∘ (fun i => (bP i).val))) = _ + rw [Set.range_comp, ← Submodule.map_span, span_submodule_basis] + apply exists_bounded_submodule_basis_from_spanning f _ (fun i => π (bP i).val) hspan + intro i j + simpa only [Fintype.card_fin, E, Q, rankQuotientLayerHeight] using + linearMap_coordinate_height e f π (fun i j => hproj j i) (bP i).val (hP i) j + let u := finrank ℚ ((F.layer s r).map π) + let _ : FiniteDimensional ℚ (L ⧸ I) := f.finiteDimensional_of_finite + have hu : u ≤ q := by + have hfq : finrank ℚ (L ⧸ I) = q := by + simpa only [Fintype.card_fin] using finrank_eq_card_basis f + exact (Submodule.finrank_le _).trans_eq hfq + let cs := c ⟨s, Nat.lt_succ_self s⟩ ⟨r, Nat.lt_succ_of_le F.rank_le_degree⟩ + obtain ⟨ξ, hξ, hξH⟩ := exists_bounded_quotient_functional (F.layer s r) I.toSubmodule f + (fun i => (cs i).val) (span_submodule_basis _ cs) η hann hE + (fun i j => by + change RationalHeightLE (f.repr (π (cs i).val) j) E + simpa only [Fintype.card_fin, E, Q, rankQuotientLayerHeight] using linearMap_coordinate_height e f π + (fun i j => hproj j i) (cs i).val (hc _ _ i) j) + (fun i => by + simpa only [Fintype.card_fin] using + linearFunctional_coordinate_height e η hη (cs i).val (hc _ _ i)) + let K := rankQuotientHeight n m q u H + have hQK : Q ≤ K := by dsimp only [K, rankQuotientHeight, Q]; omega + have hEK : E ≤ K := by dsimp only [K, rankQuotientHeight, E]; omega + have hSK : rationalLieStructureHeight n + (max H (max Q (rationalSolveHeight q Q))) ≤ K := by + dsimp only [K, rankQuotientHeight, Q]; omega + have hFK : rankQuotientFrequencyHeight n m u H ≤ K := by + dsimp only [K, rankQuotientHeight]; omega + refine ⟨m, hm', q, hq', u, hu, f, fun i j => (hproj i j).mono hQK, + ?_, ?_, ?_, ξ, hξ, fun i => (hξH i).mono hFK⟩ + · intro i j k + have h : RationalHeightLE (lieStructureConstants f i j k) + (rationalLieStructureHeight n (max H (max Q (rationalSolveHeight q Q)))) := by + simpa only [Fintype.card_fin] using hstructure i j k + exact h.mono hSK + · intro i + obtain ⟨b', hb'⟩ := himage _ (b i) (hb i) + exact ⟨b', fun a j => (hb' a j).mono hEK⟩ + · intro i j + obtain ⟨c', hc'⟩ := himage _ (c i j) (hc i j) + exact ⟨c', fun a k => (hc' a k).mono hEK⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {ν L : Type*} [AddCommGroup L] [Module ℚ L] [FiniteDimensional ℚ L] + +theorem chosenBasis_smul_coordinate_height (e : Basis ν ℚ L) (H : ℕ) + (U V : Submodule ℚ L) (hUV : U = V) + (j : Fin (finrank ℚ U)) (v : V) (q : ℚ) {K : ℕ} + (hq : RationalHeightLE q K) + (hv : v.val = q • (chosenBoundedSubmoduleBasis e H U j).val) + (k : Fin (finrank ℚ V)) : + RationalHeightLE ((chosenBoundedSubmoduleBasis e H V).repr v k) K := by + subst V + have he : v = q • chosenBoundedSubmoduleBasis e H U j := Subtype.ext hv + rw [he, map_smul, Finsupp.smul_apply, smul_eq_mul] + have hb : RationalHeightLE ((chosenBoundedSubmoduleBasis e H U).repr + (chosenBoundedSubmoduleBasis e H U j) k) 1 := by + classical + rw [Basis.repr_self] + by_cases hkj : k = j <;> simp [hkj, RationalHeightLE] + simpa only [Nat.mul_one] using hq.mul hb + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {L μ υ ν : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def homogeneousIntersectionSystem (b : Basis μ ℚ L) (w : μ → ℕ) (j : ℕ) + (U V : Submodule ℚ L) (fU : Basis υ ℚ (L ⧸ U)) (fV : Basis ν ℚ (L ⧸ V)) : + L →ₗ[ℚ] (υ ⊕ ν ⊕ μ → ℚ) := + LinearMap.pi fun + | .inl i => (fU.coord i).comp U.mkQ + | .inr (.inl i) => (fV.coord i).comp V.mkQ + | .inr (.inr i) => (b.coord i).comp (basisGradeProjection b w j - LinearMap.id) + +theorem homogeneousIntersectionSystem_ker (b : Basis μ ℚ L) (w : μ → ℕ) (j : ℕ) + (U V : Submodule ℚ L) (fU : Basis υ ℚ (L ⧸ U)) (fV : Basis ν ℚ (L ⧸ V)) : + LinearMap.ker (homogeneousIntersectionSystem b w j U V fU fV) = homogeneousIntersection b w j U V := by + ext x + rw [LinearMap.mem_ker, mem_homogeneousIntersection] + constructor + · intro hx + refine ⟨(stepDrop_quotient_mem_iff U fU x).mpr (fun i => congrFun hx (.inl i)), + (stepDrop_quotient_mem_iff V fV x).mpr (fun i => congrFun hx (.inr (.inl i))), ?_⟩ + apply sub_eq_zero.mp + apply b.repr.injective + ext i + have hi := congrFun hx (.inr (.inr i)) + change b.repr (basisGradeProjection b w j x - x) i = 0 at hi + simpa only [map_zero, Finsupp.zero_apply] using hi + · rintro ⟨hU, hV, hj⟩ + funext i + rcases i with i | i | i + · exact (stepDrop_quotient_mem_iff U fU x).mp hU i + · exact (stepDrop_quotient_mem_iff V fV x).mp hV i + · change b.repr (basisGradeProjection b w j x - x) i = 0 + rw [hj, sub_self, map_zero] + rfl + +theorem homogeneousIntersectionSystem_basis_height (b : Basis μ ℚ L) (w : μ → ℕ) (j : ℕ) + (U V : Submodule ℚ L) (fU : Basis υ ℚ (L ⧸ U)) (fV : Basis ν ℚ (L ⧸ V)) + {H : ℕ} (hH : 1 ≤ H) + (hU : ∀ i k, RationalHeightLE (fU.repr (U.mkQ (b k)) i) H) + (hV : ∀ i k, RationalHeightLE (fV.repr (V.mkQ (b k)) i) H) + (i : υ ⊕ ν ⊕ μ) (k : μ) : + RationalHeightLE (homogeneousIntersectionSystem b w j U V fU fV (b k) i) H := by + classical + rcases i with i | i | i + · exact hU i k + · exact hV i k + · change RationalHeightLE (b.repr (basisGradeProjection b w j (b k) - b k) i) H + have hp : basisGradeProjection b w j (b k) = if w k = j then b k else 0 := + basisCoordinateProjection_basis b {i | w i = j} k + rw [hp] + split_ifs + · simpa only [sub_self, map_zero, Finsupp.zero_apply] using rationalHeightLE_zero hH + · simpa only [zero_sub, map_neg, Finsupp.neg_apply] using (basis_repr_height_one b k i).neg.mono hH + +def homogeneousIntersectionBasisHeight (n r H : ℕ) : ℕ := + (n + 1) * rationalKernelHeight r H ^ n + +theorem exists_homogeneousIntersection_basis [Fintype μ] [Fintype υ] [Fintype ν] + (b : Basis μ ℚ L) (w : μ → ℕ) (j : ℕ) (U V : Submodule ℚ L) + (fU : Basis υ ℚ (L ⧸ U)) (fV : Basis ν ℚ (L ⧸ V)) {H r : ℕ} + (hH : 1 ≤ H) (hr : Fintype.card υ + Fintype.card ν + Fintype.card μ ≤ r) + (hU : ∀ i k, RationalHeightLE (fU.repr (U.mkQ (b k)) i) H) + (hV : ∀ i k, RationalHeightLE (fV.repr (V.mkQ (b k)) i) H) : + ∃ e : Basis (Fin (Module.finrank ℚ (homogeneousIntersection b w j U V))) + ℚ (homogeneousIntersection b w j U V), ∀ i k, + RationalHeightLE (b.repr (e i : L) k) (homogeneousIntersectionBasisHeight (Fintype.card μ) r H) := by + classical + let P := homogeneousIntersectionSystem b w j U V fU fV + have hP : ∀ i k, RationalHeightLE ((Pi.basisFun ℚ (υ ⊕ ν ⊕ μ)).repr (P (b i)) k) H := by + intro i k + change RationalHeightLE (P (b i) k) H + exact homogeneousIntersectionSystem_basis_height b w j U V fU fV hH hU hV k i + obtain ⟨t, ht, v, hspan, hv⟩ := exists_bounded_span_kernel_generators b + (Pi.basisFun ℚ (υ ⊕ ν ⊕ μ)) P b hH (basis_repr_height_one b) hP + have htr : t ≤ r := by + simp only [Fintype.card_sum] at ht + omega + have hspan' : Submodule.span ℚ (Set.range v) = homogeneousIntersection b w j U V := by + simpa only [b.span_eq, top_inf_eq, P, homogeneousIntersectionSystem_ker] using hspan + have hv' : ∀ i k, RationalHeightLE (b.repr (v i) k) + (homogeneousIntersectionBasisHeight (Fintype.card μ) r H) := by + intro i k + apply (hv i k).mono + simp only [homogeneousIntersectionBasisHeight, mul_one] + exact Nat.mul_le_mul_left _ (Nat.pow_le_pow_left (rationalKernelHeight_mono hH htr) _) + exact exists_bounded_submodule_basis_from_spanning b _ v hspan' hv' + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem rankQuotientHeight_le_exp (n m q u H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (hm : (m : ℝ) ≤ p) (hq : (q : ℝ) ≤ p) + (hu : (u : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + (rankQuotientHeight n m q u H : ℝ) ≤ Real.exp ((p + 2) ^ 424) := by + let Q := rationalKernelHeight m H + let E := rankQuotientLayerHeight n m H + let V := (n + 1) * (H * H) ^ n + let P := (p + 2) ^ 51 + have hpP : p ≤ P := le_power_budget hp (by decide : 1 ≤ 51) + have hP : 0 ≤ P := hp.trans hpP + have hbase : 1 ≤ p + 2 := by linarith + have hQ : (Q : ℝ) ≤ Real.exp ((p + 2) ^ 7) := rationalKernelHeight_le_budget m H hp hm hH + have hH7 : (H : ℝ) ≤ Real.exp ((p + 2) ^ 7) := + hH.trans (Real.exp_le_exp.mpr (le_power_budget hp (by decide))) + have hprod {A B : ℕ} (hA : (A : ℝ) ≤ Real.exp ((p + 2) ^ 7)) + (hB : (B : ℝ) ≤ Real.exp ((p + 2) ^ 7)) : + ((A * B : ℕ) : ℝ) ≤ Real.exp ((p + 2) ^ 8) := by + rw [Nat.cast_mul] + calc + _ ≤ Real.exp ((p + 2) ^ 7) * Real.exp ((p + 2) ^ 7) := + mul_le_mul hA hB (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = Real.exp (2 * (p + 2) ^ 7) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by + calc + _ ≤ (p + 2) * (p + 2) ^ 7 := + mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = _ := by ring) + have hE10 : (E : ℝ) ≤ Real.exp ((p + 2) ^ 10) := by + exact rational_sum_cost_le_exp n (H * Q) hp 8 1 (hprod hH7 hQ) + (by simpa only [pow_one] using hn.trans (show p ≤ p + 2 by linarith)) + have hV10 : (V : ℝ) ≤ Real.exp ((p + 2) ^ 10) := by + exact rational_sum_cost_le_exp n (H * H) hp 8 1 (hprod hH7 hH7) + (by simpa only [pow_one] using hn.trans (show p ≤ p + 2 by linarith)) + have hEP : (E : ℝ) ≤ Real.exp P := + hE10.trans (Real.exp_le_exp.mpr (pow_le_pow_right₀ hbase (by decide : 10 ≤ 51))) + have hVP : (V : ℝ) ≤ Real.exp P := + hV10.trans (Real.exp_le_exp.mpr (pow_le_pow_right₀ hbase (by decide : 10 ≤ 51))) + have hfreq0 := embedding_coordinate_height_budget u u E V hP + (hu.trans hpP) (hu.trans hpP) hEP hVP + have hfreq : (rankQuotientFrequencyHeight n m u H : ℝ) ≤ Real.exp ((p + 2) ^ 424) := + exponential_budget_comp hp hP 51 8 le_rfl hfreq0 + have h51 : P ≤ (p + 2) ^ 424 := pow_le_pow_right₀ hbase (by decide : 51 ≤ 424) + have hstructure := rationalLieQuotientStructureHeight_le_exp n m q H hp hn hm hq hH + simp only [rankQuotientHeight, Nat.cast_max, Nat.cast_one] + refine max_le (Real.one_le_exp (by positivity)) (max_le ?_ (max_le ?_ (max_le ?_ hfreq))) + · exact hQ.trans (Real.exp_le_exp.mpr (pow_le_pow_right₀ hbase (by decide : 7 ≤ 424))) + · exact hstructure.trans (Real.exp_le_exp.mpr h51) + · exact hEP.trans (Real.exp_le_exp.mpr h51) + +theorem dependentQuotientHeight_le_exp (s n m q u H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (hm : (m : ℝ) ≤ p) (hq : (q : ℝ) ≤ p) + (hu : (u : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + (rankQuotientHeight n m q u (lieTreeHeight n H s) : ℝ) ≤ + Real.exp ((p + 2) ^ ((6 * s + 4) * 424)) := by + let P := (p + 2) ^ (6 * s + 2) + have hpP : p ≤ P := le_power_budget hp (by omega : 1 ≤ 6 * s + 2) + have hP : 0 ≤ P := hp.trans hpP + have h := rankQuotientHeight_le_exp n m q u (lieTreeHeight n H s) hP + (hn.trans hpP) (hm.trans hpP) (hq.trans hpP) (hu.trans hpP) + (lieTreeHeight_le_exp n H s hp hn hH) + have hc := exponential_budget_comp hp hP (6 * s + 2) 424 le_rfl h + simpa only [show 6 * s + 2 + 2 = 6 * s + 4 by omega] using hc + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankRelationBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankRelationBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1e4d5ca149001dd841ef7badc14aaf55f076a35 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankRelationBudget.lean @@ -0,0 +1,34 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeWeightPairRemoval + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_rank_relation_budget (a c : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + let K := (p + a) ^ a + let q := K + (K + c) ^ c + 2 + 11 * q + 7 ≤ (p + C) ^ C ∧ mixedErrorPairBudget q ≤ (p + C) ^ C := by + obtain ⟨b, _, hpair⟩ := exists_mixed_error_budget + let X : Polynomial ℕ := Polynomial.X + let Y := (X + Polynomial.C a) ^ a + let Z := Y + (Y + Polynomial.C c) ^ c + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (11 * Z + 7 + (Z + Polynomial.C b) ^ b) + refine ⟨C, hC, ?_⟩ + intro p hp K q + have hK : 0 ≤ K := by dsimp [K]; positivity + have hq : 0 ≤ q := by dsimp [q]; positivity + have hterm : 0 ≤ (q + b) ^ b := by positivity + have hbound : 11 * q + 7 + (q + b) ^ b ≤ (p + C) ^ C := by + simpa [X, Y, Z, K, q, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨by linarith only [hterm, hbound], + (hpair q hq).1.trans (by linarith only [hq, hbound])⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankSparseFamilies.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankSparseFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..102cb1f2b3235a61ff57d8f6e90c39bbd63216c5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankSparseFamilies.lean @@ -0,0 +1,70 @@ +import OAI.Combinatorics.Progressions.Estimates.AnchoredSparseFamilies +import OAI.Combinatorics.Progressions.Linear.RankIntervalFactorization + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_rank_sparse_family + {ι κ σ : Type*} [Fintype ι] [Fintype κ] {N : ℕ} + (S : Finset (ZMod N)) (h₀ : ZMod N) (hh₀ : h₀ ∈ S) + (J : Submodule ℚ (Fin 4 → ι → ℚ)) (v : κ → Fin 4 → ι → ℚ) + (hv : Submodule.span ℚ (Set.range v) = J) + {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l) (hvH : ∀ a k i, RationalHeightLE (v a k i) H) + {p : ℝ} (hp : 0 ≤ p) (hfour : (Fintype.card (Σ _ : Fin 4, ι) : ℝ) ≤ p) + (hcols : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, Real.exp (separationBudget p) ≤ T i) : + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp (2 * (p + ((p + 2) ^ 3 + (p + 2) ^ 36))) ∧ + l ∣ m ∧ ∀ (α : σ →₀ ℕ), α ≠ 0 → ∀ (β : ZMod N → ι → ℝ) (a b c d : ZMod N) (M : ℝ), + 2 * M ≤ Real.exp p → + (∀ h ∈ S, ∃ E Q : (Σ _ : Fin 4, ι) → ℝ, + ‖E‖ ≤ M / monomialScale T α ∧ Q ∈ realDenominatorGrid l ∧ + rankCoordinateTuple β (b - h, b, a) - E - Q ∈ realFourCoordinateSpan J) → + (∀ h ∈ S, ∃ E Q : (Σ _ : Fin 4, ι) → ℝ, + ‖E‖ ≤ M / monomialScale T α ∧ Q ∈ realDenominatorGrid l ∧ + rankCoordinateTuple β (c - d, h + (c - d), c) - E - Q ∈ realFourCoordinateSpan J) → + ∀ h ∈ S, ∃ e₁₂ q₁₂ e₁₃ q₁₃ : ι → ℝ, + ‖e₁₂‖ ≤ (Real.exp p + Real.exp ((p + 2) ^ 3 + (p + 2) ^ 18 + p)) / monomialScale T α ∧ + ‖e₁₃‖ ≤ (Real.exp p + Real.exp ((p + 2) ^ 3 + (p + 2) ^ 18 + p)) / monomialScale T α ∧ + q₁₂ ∈ realDenominatorGrid m ∧ q₁₃ ∈ realDenominatorGrid m ∧ + β h - β h₀ - e₁₂ - q₁₂ ∈ realRationalCoordinateSpan (fourSparseFirstProjection J {1, 2}) ∧ + β h - β h₀ - e₁₃ - q₁₃ ∈ realRationalCoordinateSpan (fourSparseFirstProjection J {1, 3}) := by + have hselected (K : Finset (Fin 4)) : (Fintype.card (Σ _ : K, ι) : ℝ) ≤ p := + (Nat.cast_le.mpr (card_selected_four_le K)).trans hfour + obtain ⟨m₁₂, hm₁₂, hmp₁₂, hlm₁₂, hsolve₁₂⟩ := + exists_anchored_sparse_family (η := S) J {1, 2} v hv hH hl hvH hp hfour + (hselected _) hcols hHp hlp T hT + obtain ⟨m₁₃, hm₁₃, hmp₁₃, _, hsolve₁₃⟩ := + exists_anchored_sparse_family (η := S) J {1, 3} v hv hH hl hvH hp hfour + (hselected _) hcols hHp hlp T hT + refine ⟨m₁₂ * m₁₃, Nat.mul_pos hm₁₂ hm₁₃, ?_, + hlm₁₂.trans (dvd_mul_right m₁₂ m₁₃), ?_⟩ + · rw [Nat.cast_mul] + calc + (m₁₂ : ℝ) * m₁₃ ≤ Real.exp (p + ((p + 2) ^ 3 + (p + 2) ^ 36)) * + Real.exp (p + ((p + 2) ^ 3 + (p + 2) ^ 36)) := + mul_le_mul hmp₁₂ hmp₁₃ (Nat.cast_nonneg _) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + · intro α hα β a b c d M hM hcorrect₁₂ hcorrect₁₃ h hh + obtain ⟨e₁₂, q₁₂, he₁₂, hq₁₂, hrem₁₂⟩ := hsolve₁₂ α hα + (fun h : S => rankCoordinateTuple β (b - h, b, a)) (fun h : S => β h) + ⟨h₀, hh₀⟩ M hM (fun h i => rankCoordinateTuple_first12 β a b h i) + (fun h j => rankCoordinateTuple_fixed12 β a b h h₀ j) + (fun h => hcorrect₁₂ h h.property) ⟨h, hh⟩ + obtain ⟨e₁₃, q₁₃, he₁₃, hq₁₃, hrem₁₃⟩ := hsolve₁₃ α hα + (fun h : S => rankCoordinateTuple β (c - d, h + (c - d), c)) (fun h : S => β h) + ⟨h₀, hh₀⟩ M hM (fun h i => rankCoordinateTuple_first13 β c d h i) + (fun h j => rankCoordinateTuple_fixed13 β c d h h₀ j) + (fun h => hcorrect₁₃ h h.property) ⟨h, hh⟩ + exact ⟨e₁₂, q₁₂, e₁₃, q₁₃, he₁₂, he₁₃, + realDenominatorGrid_subset_of_dvd hm₁₂ (dvd_mul_right m₁₂ m₁₃) hq₁₂, + realDenominatorGrid_subset_of_dvd hm₁₃ (dvd_mul_left m₁₃ m₁₂) hq₁₃, hrem₁₂, hrem₁₃⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankTwoOrbitTree.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankTwoOrbitTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f675eecf6433e50a0f7b71c455c4b92fc392b35 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankTwoOrbitTree.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeProductCoefficient +import OAI.Combinatorics.Progressions.Polynomial.NativeRankPolynomialFactorization + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open VectorPolynomial +open scoped TensorProduct + +theorem top_tree_product_rank_two + {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n : ℕ} + {E : RationalFilteredNilmanifold L s n} (T : E.DegreeRankStructure r) (hs : 1 ≤ s) + (A K U : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hK : ∀ d : Fin s, coefficients K.log (Finsupp.single () (d.val + 1)) ∈ + (T.filtration.layer (d.val + 1) 2).baseChange ℝ) + (d : I → Fin s) (a : FreeMagma I) + (hd : lieTreeWeight (fun i => (d i).val + 1) a = s) (hr : a.length = r) : + lieTreeEval (fun i => coefficients (A * K * U).log (Finsupp.single () ((d i).val + 1))) a = + lieTreeEval (fun i => coefficients A.log (Finsupp.single () ((d i).val + 1)) + + coefficients U.log (Finsupp.single () ((d i).val + 1))) a := by + have hmem (v : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) (j : Fin s) : + coefficients v.log (Finsupp.single () (j.val + 1)) ∈ + (T.filtration.layer (j.val + 1) 1).baseChange ℝ := by + have h := (E.filtration.realification.adapted_iff_coefficients _ _).mp v.adapted + (Finsupp.single () (j.val + 1)) + have h₀ : coefficients v.log (Finsupp.single () (j.val + 1)) ∈ + T.filtration.realification.associatedDegree.layer (j.val + 1) := by + rw [T.real_associated] + simpa only [Finsupp.weight_single, smul_eq_mul, mul_one] using h + change coefficients v.log (Finsupp.single () (j.val + 1)) ∈ + (T.filtration.layer (j.val + 1) 0).baseChange ℝ at h₀ + rwa [T.filtration.rank_zero_eq_one] at h₀ + have hdiff (j : Fin s) : + coefficients (A * K * U).log (Finsupp.single () (j.val + 1)) - + (coefficients A.log (Finsupp.single () (j.val + 1)) + + coefficients U.log (Finsupp.single () (j.val + 1))) ∈ + (T.filtration.layer (j.val + 1) 2).baseChange ℝ := by + have h₁ := T.polynomialOrbit_mul_coefficient_sub_mem_rank_two hs + (fun _ : Unit => 1) (Finsupp.single () (j.val + 1)) A K + have h₂ := T.polynomialOrbit_mul_coefficient_sub_mem_rank_two hs + (fun _ : Unit => 1) (Finsupp.single () (j.val + 1)) (A * K) U + simp only [Finsupp.weight_single, smul_eq_mul, mul_one] at h₁ h₂ + convert ((T.filtration.layer (j.val + 1) 2).baseChange ℝ).add_mem + (((T.filtration.layer (j.val + 1) 2).baseChange ℝ).add_mem h₂ h₁) (hK j) using 1 + abel + exact T.filtration.realification.top_lieTreeEval_congr _ _ + (fun i => (d i).val + 1) (fun i => hmem _ (d i)) + (fun i => ((T.filtration.layer ((d i).val + 1) 1).baseChange ℝ).add_mem + (hmem A (d i)) (hmem U (d i))) + (fun i => hdiff (d i)) a hd hr + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankUnadaptedFactorization.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankUnadaptedFactorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eac262e45acd786c42dbe66f6bbb4012d8e54be --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankUnadaptedFactorization.lean @@ -0,0 +1,330 @@ +import OAI.Combinatorics.Progressions.Estimates.UnconditionalStepDrop +import OAI.Combinatorics.Progressions.Nilpotent.RankBracketFactorizationMonotone + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +def rankVerticalSelectionBudget (p : ℝ) : ℝ := p + verticalDecompositionBudget (p + 1) + 1 + +theorem rankVerticalSelectionBudget_bounds {p : ℝ} (hp : 0 ≤ p) : + p + 1 ≤ rankVerticalSelectionBudget p ∧ + verticalDecompositionBudget (p + 1) ≤ rankVerticalSelectionBudget p := by + have h := verticalDecompositionBudget_nonneg (show 0 ≤ p + 1 by linarith) + unfold rankVerticalSelectionBudget + constructor <;> linarith + +namespace RationalFilteredNilmanifold.Niltest + +open CircleFourier + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem exists_biased_mode_restricting_frequency (T : D.Niltest (fun _ : σ => 1)) + {p : ℝ} (hp : 0 ≤ p) (hT : T.ComplexityLE p) + (S : Submodule ℚ L) (hS : S ≤ D.filtration.layer s) (η : L →ₗ[ℚ] ℚ) + (hchar : ∀ y ∈ S, ∀ t : ℝ, ∀ x, + T.observable ((⟨t ⊗ₜ[ℚ] y⟩ : D.RealGroup) • x) = + character ((t * (η y : ℝ) : ℝ) : CircleFourier.Circle) * T.observable x) + (Q : Finset (σ → ℤ)) (hQ : Q.Nonempty) + (hbias : Real.exp (-p) ≤ ‖𝔼 x ∈ Q, T.eval x‖) : + ∃ (ξ : L →ₗ[ℚ] ℚ) (U : D.Niltest (fun _ : σ => 1)), + U.ComplexityLE (rankVerticalSelectionBudget p) ∧ U.orbit = T.orbit ∧ + (∀ i, rationalLogHeight (ξ (D.basis i)) ≤ rankVerticalSelectionBudget p) ∧ + (∀ z ∈ D.filtration.realification.subgroup s, ∀ x, + U.observable (z • x) = character ((realifyFunctional ξ z.coord : ℝ) : CircleFourier.Circle) * + U.observable x) ∧ + (∀ y ∈ S, ξ y = η y) ∧ + Real.exp (-rankVerticalSelectionBudget p) ≤ ‖𝔼 x ∈ Q, U.eval x‖ := by + have hp1 : 0 ≤ p + 1 := by linarith + have hρp : (Real.exp (-p) / 2)⁻¹ ≤ Real.exp (p + 1) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + calc + _ = 2 * Real.exp p := by rw [inv_div, Real.exp_neg]; field_simp + _ ≤ Real.exp 1 * Real.exp p := mul_le_mul_of_nonneg_right htwo (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, add_comm] + obtain ⟨ξ, U, hU, hOrbit, hheight, hvert, _, hpres, hc⟩ := + T.exists_correlating_vertical_mode_preserving_characters hp1 + (hT.mono (by linarith)) (Real.exp_pos (-p)) hρp hQ (fun _ => 1) + (fun _ _ => by simp) (by rwa [norm_finiteCorrelation_one]) + rw [norm_finiteCorrelation_one] at hc + have hthreshold : Real.exp (-rankVerticalSelectionBudget p) ≤ + Real.exp (-p) / (2 * Real.exp (verticalDecompositionBudget (p + 1))) := by + calc + _ = Real.exp (-p - 1) / Real.exp (verticalDecompositionBudget (p + 1)) := by + rw [← Real.exp_sub] + congr 1 + unfold rankVerticalSelectionBudget + ring + _ ≤ (Real.exp (-p) / 2) / Real.exp (verticalDecompositionBudget (p + 1)) := + div_le_div_of_nonneg_right (exp_sub_one_le_half_exp (-p)) (Real.exp_nonneg _) + _ = _ := by ring + have hfinal := hthreshold.trans hc + have hne : ∃ x, U.observable x ≠ 0 := by + by_contra! hzero + have heval : ∀ x, U.eval x = 0 := fun x => hzero _ + simp only [heval, Finset.expect_const_zero, norm_zero] at hfinal + exact (not_le_of_gt (Real.exp_pos _)) hfinal + refine ⟨ξ, U, hU.mono (rankVerticalSelectionBudget_bounds hp).1, hOrbit, + fun i => (hheight i).trans (rankVerticalSelectionBudget_bounds hp).2, hvert, ?_, hfinal⟩ + intro y hy + have heq := vertical_frequency_on_real_direction D.filtration D.realLattice ξ U.observable + hvert hne y (hS hy) (η y : ℝ) (fun t x => hpres _ _ (hchar y hy t) x) + exact_mod_cast heq + +end RationalFilteredNilmanifold.Niltest + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_rank_biased_factorization_budget (c : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + rankVerticalSelectionBudget p ≤ (p + C) ^ C ∧ + (rankVerticalSelectionBudget p + c) ^ c ≤ (p + C) ^ C := by + obtain ⟨a, _, hvertical⟩ := exists_verticalDecompositionBudget_bound + let X : Polynomial ℕ := Polynomial.X + let Y := X + (X + 1 + Polynomial.C a) ^ a + 1 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Y + (Y + Polynomial.C c) ^ c) + refine ⟨C, hC, ?_⟩ + intro p hp + have hq : rankVerticalSelectionBudget p ≤ p + (p + 1 + a) ^ a + 1 := by + have h := hvertical (p + 1) (by linarith) + unfold rankVerticalSelectionBudget + linarith only [h] + have hq0 : 0 ≤ rankVerticalSelectionBudget p := + (show 0 ≤ p + 1 by linarith).trans (rankVerticalSelectionBudget_bounds hp).1 + have hY : 0 ≤ p + (p + 1 + a) ^ a + 1 := by positivity + have hZ : 0 ≤ (p + (p + 1 + a) ^ a + 1 + c) ^ c := by positivity + have hpow : (rankVerticalSelectionBudget p + c) ^ c ≤ + (p + (p + 1 + a) ^ a + 1 + c) ^ c := by gcongr + have hbound : p + (p + 1 + a) ^ a + 1 + + (p + (p + 1 + a) ^ a + 1 + c) ^ c ≤ (p + C) ^ C := by + simpa [X, Y, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨by linarith only [hq, hZ, hbound], by linarith only [hpow, hY, hbound]⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_rank_adapted_factorization_budget (c : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + rankAdaptedNiltestBudget p ≤ (p + C) ^ C ∧ + (rankAdaptedNiltestBudget p + c) ^ c ≤ (p + C) ^ C ∧ + p + 1 ≤ (p + C) ^ C ∧ (p + 3) ^ 5 ≤ (p + C) ^ C := by + let X : Polynomial ℕ := Polynomial.X + let A := (X + 3) ^ 11 + X + 2 + let B := A + (A + 2) ^ 2 + let P := B + (B + Polynomial.C c) ^ c + (X + 3) ^ 5 + X + 1 + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro p hp + have hB : 0 ≤ rankAdaptedNiltestBudget p := hp.trans (le_rankAdaptedNiltestBudget hp) + have hpow : 0 ≤ (rankAdaptedNiltestBudget p + c) ^ c := by positivity + have hinv : 0 ≤ (p + 3) ^ 5 := by positivity + have htotal : rankAdaptedNiltestBudget p + (rankAdaptedNiltestBudget p + c) ^ c + + (p + 3) ^ 5 + p + 1 ≤ (p + C) ^ C := by + simpa [P, B, A, X, Polynomial.eval₂_pow, rankAdaptedNiltestBudget, + rankAdaptedNiltestBase] using hbound p hp + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators + +theorem exists_rank_biased_symbol_factorization (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {d r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (R : D.DegreeRankStructure r) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p : ℝ), 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → + (T : D.Niltest (fun _ : σ => 1)) → T.ComplexityLE p → + (η : L →ₗ[ℚ] ℚ) → + (∀ z ∈ R.realSubgroup s r, ∀ x, T.observable (z • x) = + character ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * T.observable x) → + ∀ (origin : σ → ℤ) (lengths : σ → ℕ), (∀ i, 0 < lengths i) → + (∀ i, Real.exp ((p + C) ^ C) ≤ (lengths i : ℝ)) → + Real.exp (-p) ≤ ‖𝔼 x ∈ translatedIntegerBox origin lengths, T.eval x‖ → + ∃ ξ : L →ₗ[ℚ] ℚ, + (∀ x ∈ R.filtration.layer s r, ξ x = η x) ∧ + D.filtration.ControlledSymbolFactorization D.basis ω hF ξ (fun i => (lengths i : ℝ)) + (T.symbol D.basis ω hF) ((p + C) ^ C) := by + obtain ⟨c, _, hstep⟩ := exists_translated_step_drop s hs + obtain ⟨C, hC, hbudget⟩ := exists_rank_biased_factorization_budget c + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ d r _ _ _ _ D R ω hF p hp hσ T hT η hvert origin lengths hlengths hlarge hbias + have hS : R.filtration.layer s r ≤ D.filtration.layer s := by + intro y hy + have h := R.filtration.layer_le_associatedDegree s r hy + rwa [R.associated] at h + have hchar : ∀ y ∈ R.filtration.layer s r, ∀ t : ℝ, ∀ x, + T.observable ((⟨t ⊗ₜ[ℚ] y⟩ : D.RealGroup) • x) = + character ((t * (η y : ℝ) : ℝ) : CircleFourier.Circle) * T.observable x := by + intro y hy t x + have hz : (⟨t ⊗ₜ[ℚ] y⟩ : D.RealGroup) ∈ R.realSubgroup s r := + Submodule.tmul_mem_baseChange_of_mem t hy + simpa only [realifyFunctional_tmul] using hvert _ hz x + have hQ : (translatedIntegerBox origin lengths).Nonempty := by + refine ⟨origin, (mem_translatedIntegerBox origin lengths origin).mpr ?_⟩ + intro i + have hi := hlengths i + exact ⟨le_rfl, by omega⟩ + obtain ⟨ξ, U, hU, hOrbit, hheight, hUvert, hrestrict, hUbias⟩ := + T.exists_biased_mode_restricting_frequency hp hT _ hS η hchar _ hQ hbias + let q := rankVerticalSelectionBudget p + have hpq : p ≤ q := by + have h := (rankVerticalSelectionBudget_bounds hp).1 + dsimp only [q] + linarith + have hq : 0 ≤ q := hp.trans hpq + have hfact := hstep D ω hF q hq (hσ.trans hpq) U hU ξ hheight hUvert origin lengths hlengths + (fun i => (Real.exp_le_exp.mpr (hbudget p hp).2).trans (hlarge i)) hUbias + have hsymbol : U.symbol D.basis ω hF = T.symbol D.basis ω hF := by + unfold RationalFilteredNilmanifold.Niltest.symbol + apply congrArg (D.filtration.realPolynomialSymbolHom D.basis ω hF (fun _ => 1)) + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + exact congrArg (fun o : D.filtration.realification.PolynomialOrbit (fun _ : σ => 1) => o.log) hOrbit + rw [hsymbol] at hfact + exact ⟨ξ, hrestrict, NilpotentLieFiltration.ControlledSymbolFactorization.mono + D.filtration D.basis ω hF hfact (hbudget p hp).2 (fun i => by exact_mod_cast hlengths i)⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators + +theorem exists_rank_biased_refiltration (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {d r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (R : D.DegreeRankStructure r) + (ω : Fin d → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (p : ℝ), 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → + (T : D.Niltest (fun _ : σ => 1)) → T.ComplexityLE p → + (η : L →ₗ[ℚ] ℚ) → + (∀ z ∈ R.realSubgroup s r, ∀ x, T.observable (z • x) = + character ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * T.observable x) → + ∀ (origin : σ → ℤ) (lengths : σ → ℕ), (∀ i, 0 < lengths i) → + (∀ i, Real.exp ((p + C) ^ C) ≤ (lengths i : ℝ)) → + Real.exp (-p) ≤ ‖𝔼 x ∈ translatedIntegerBox origin lengths, T.eval x‖ → + R.ControlledRankBracketFactorization ω hF η (fun i => (lengths i : ℝ)) + (T.symbol D.basis ω hF) ((p + C) ^ C) := by + obtain ⟨C, hC, hfactor⟩ := exists_rank_biased_symbol_factorization s hs + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ d r _ _ _ _ D R ω hF p hp hσ T hT η hvert origin lengths hlengths hlarge hbias + obtain ⟨ξ, hrestrict, h⟩ := hfactor D R ω hF p hp hσ T hT η hvert origin lengths hlengths hlarge hbias + exact R.controlledRankBracketFactorization_of_frequency_restriction ω hF ξ η _ _ _ h hrestrict + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators + +theorem exists_rank_unadapted_factorization (s : ℕ) (hs : 1 ≤ s) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [Fintype σ] [DecidableEq σ] + [LieRing L] [LieAlgebra ℚ L] {d r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (R : D.DegreeRankStructure r) + (p : ℝ), 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → R.ComplexityLE p → + (T : D.Niltest (fun _ : σ => 1)) → T.ComplexityLE p → + (η : L →ₗ[ℚ] ℚ) → + (∀ z ∈ R.realSubgroup s r, ∀ x, T.observable (z • x) = + character ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * T.observable x) → + ∀ (origin : σ → ℤ) (lengths : σ → ℕ), (∀ i, 0 < lengths i) → + (∀ i, Real.exp ((p + C) ^ C) ≤ (lengths i : ℝ)) → + Real.exp (-p) ≤ ‖𝔼 x ∈ translatedIntegerBox origin lengths, T.eval x‖ → + ∃ F : R.AdaptedData, + F.rank.ComplexityLE ((p + C) ^ C) ∧ + (∀ i j, rationalLogHeight (D.basis.repr (F.basis i) j) ≤ (p + C) ^ C) ∧ + (∀ j i, rationalLogHeight (F.basis.repr (D.basis j) i) ≤ (p + C) ^ C) ∧ + F.rank.ControlledRankBracketFactorization F.weight F.layers η (fun i => (lengths i : ℝ)) + (T.symbol F.basis F.weight F.layers) ((p + C) ^ C) := by + obtain ⟨c, _, hfactor⟩ := exists_rank_biased_refiltration s hs + obtain ⟨C, hC, hbudget⟩ := exists_rank_adapted_factorization_budget c + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ d r _ _ _ _ D R p hp hσ hR T hT η hvert origin lengths hlengths hlarge hbias + obtain ⟨F, hFR, hforward, hback, S, horbit, hobs, hS⟩ := R.exists_adapted_niltest T hp hR hT + let q := rankAdaptedNiltestBudget p + have hpq : p ≤ q := le_rankAdaptedNiltestBudget hp + have hq : 0 ≤ q := hp.trans hpq + obtain ⟨hqC, hfactorC, hforwardC, hbackC⟩ := hbudget p hp + have hvertS : ∀ z ∈ F.rank.realSubgroup s r, ∀ x, S.observable (z • x) = + character ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * S.observable x := by + intro z hz x + rw [hobs] + exact hvert z hz x + have heval (x : σ → ℤ) : S.eval x = T.eval x := by + unfold RationalFilteredNilmanifold.Niltest.eval + rw [hobs, horbit] + rfl + have hbiasS : Real.exp (-q) ≤ ‖𝔼 x ∈ translatedIntegerBox origin lengths, S.eval x‖ := by + simp only [heval] + exact (Real.exp_le_exp.mpr (neg_le_neg hpq)).trans hbias + have hfact := hfactor F.model F.rank F.weight F.layers q hq (hσ.trans hpq) + S hS η hvertS origin lengths hlengths + (fun i => (Real.exp_le_exp.mpr hfactorC).trans (hlarge i)) hbiasS + have hsymbol : S.symbol F.basis F.weight F.layers = T.symbol F.basis F.weight F.layers := by + unfold RationalFilteredNilmanifold.Niltest.symbol + apply congrArg (D.filtration.realPolynomialSymbolHom F.basis F.weight F.layers (fun _ => 1)) + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + exact congrArg (fun o : D.filtration.realification.PolynomialOrbit (fun _ : σ => 1) => o.log) horbit + change F.rank.ControlledRankBracketFactorization F.weight F.layers η (fun i => (lengths i : ℝ)) + (S.symbol F.basis F.weight F.layers) ((q + c) ^ c) at hfact + rw [hsymbol] at hfact + refine ⟨F, hFR.mono F.rank hqC, + (fun i j => (hforward i j).trans hforwardC), + (fun j i => (hback j i).trans hbackC), ?_⟩ + exact RationalFilteredNilmanifold.DegreeRankStructure.ControlledRankBracketFactorization.mono + F.rank F.weight F.layers hfact hfactorC (fun i => by exact_mod_cast hlengths i) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RankedCoordinateDecisionTree.lean b/lean/OAI/Combinatorics/Progressions/Linear/RankedCoordinateDecisionTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..91bc7258be35b72ae19af01d40e7d6ca6477f50b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RankedCoordinateDecisionTree.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Geometry.CoordinateTreeTrace + +namespace OAI + +section + +namespace Erdos3.CoordinateDecisionTree + +universe u v w + +variable {ι : Type u} [DecidableEq ι] {Value : ι → Type v} + +theorem Valid.map {Good Better : Finset ι → (∀ i, Value i) → Prop} + {I : Finset ι} {x : ∀ i, Value i} {tree : CoordinateDecisionTree ι Value} {d : ℕ} + (h : Valid Good I x tree d) (hmap : ∀ J y, Good J y → Better J y) : Valid Better I x tree d := by + induction h with + | leaf good => exact .leaf (hmap _ _ good) + | split fresh branches ih => exact .split fresh ih + +theorem Valid.substitute {Good Better : Finset ι → (∀ i, Value i) → Prop} + {I : Finset ι} {x : ∀ i, Value i} {tree : CoordinateDecisionTree ι Value} {d e : ℕ} + (h : Valid Good I x tree d) + (replace : ∀ J y, Good J y → ∃ next : CoordinateDecisionTree ι Value, Valid Better J y next e) : + ∃ next : CoordinateDecisionTree ι Value, Valid Better I x next (d + e) := by + classical + induction h with + | @leaf I x d good => + obtain ⟨next, hnext⟩ := replace I x good + exact ⟨next, hnext.mono (by omega)⟩ + | @split I x i children d fresh branches ih => + choose next hnext using ih + have hsum : d + 1 + e = (d + e) + 1 := by omega + rw [hsum] + exact ⟨.split i next, .split fresh hnext⟩ + +theorem exists_of_rank_decreasing_step + (State : Finset ι → (∀ i, Value i) → Type w) + (rank : ∀ I x, State I x → ℕ) (Good : Finset ι → (∀ i, Value i) → Prop) (cost : ℕ) + (step : ∀ I x (state : State I x), ∃ tree : CoordinateDecisionTree ι Value, + Valid (fun J y => Good J y ∨ ∃ next : State J y, rank J y next < rank I x state) I x tree cost) + (I : Finset ι) (x : ∀ i, Value i) (state : State I x) : + ∃ tree : CoordinateDecisionTree ι Value, Valid Good I x tree (cost * (rank I x state + 1)) := by + have build : ∀ n : ℕ, ∀ I x (state : State I x), rank I x state = n → + ∃ tree : CoordinateDecisionTree ι Value, Valid Good I x tree (cost * (n + 1)) := by + intro n + induction n using Nat.strong_induction_on with + | h n ih => + intro I x state hn + obtain ⟨tree, htree⟩ := step I x state + have replace : ∀ J y, (Good J y ∨ ∃ next : State J y, rank J y next < rank I x state) → + ∃ nextTree : CoordinateDecisionTree ι Value, Valid Good J y nextTree (cost * n) := by + intro J y hleaf + rcases hleaf with hgood | ⟨next, hlt⟩ + · exact ⟨.leaf, .leaf hgood⟩ + · have hlt' : rank J y next < n := by simpa only [hn] using hlt + obtain ⟨nextTree, hnext⟩ := ih (rank J y next) hlt' J y next rfl + exact ⟨nextTree, hnext.mono (Nat.mul_le_mul_left cost (by omega))⟩ + simpa only [Nat.mul_add, Nat.mul_one, Nat.add_comm] using htree.substitute replace + exact build (rank I x state) I x state rfl + +end Erdos3.CoordinateDecisionTree + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalClearedMatrixReal.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalClearedMatrixReal.lean new file mode 100644 index 0000000000000000000000000000000000000000..931a3a3c2b3b27198f165d3575d3a4d959bc2a2e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalClearedMatrixReal.lean @@ -0,0 +1,29 @@ +import Mathlib.Basic.Real.Basic +import OAI.Combinatorics.Progressions.Sampling.RationalSpanGrid + +namespace OAI + +section + +namespace Erdos3 + +open scoped Classical + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +theorem matrixDenominator_mul_entry_real (S : Matrix ι κ ℚ) (i : ι) (j : κ) : + (matrixDenominator S : ℝ) * (S i j : ℝ) = (clearedMatrix S i j : ℝ) := by + classical + have h : (clearedMatrix S i j : ℚ) = (matrixDenominator S : ℚ) * S i j := + congrFun (congrFun (clearedMatrix_cast S) i) j + exact_mod_cast h.symm + +theorem matrixDenominator_mul_entry_real_integral (S : Matrix ι κ ℚ) (i : ι) (j : κ) : + ∃ z : ℤ, (matrixDenominator S : ℝ) * (S i j : ℝ) = (z : ℝ) := + ⟨clearedMatrix S i j, matrixDenominator_mul_entry_real S i j⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalKernelBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalKernelBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc67e993d970d4816afbdef9c6c3893dcdfeeb16 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalKernelBudget.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Dynamics.RationalHeightBudget +import OAI.Combinatorics.Progressions.Estimates.RationalSubspaces + +namespace OAI + +section + +namespace Erdos3 + +theorem rationalKernelHeight_le_budget (r H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hr : (r : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + (rationalKernelHeight r H : ℝ) ≤ Real.exp ((p + 2) ^ 7) := by + have hsolve := rationalSolveHeight_le_budget r H hp hr hH + have htwo : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hfront : (2 : ℝ) * (r + 1) ≤ Real.exp (1 + (r : ℝ)) := by + rw [Real.exp_add] + exact mul_le_mul htwo (Real.add_one_le_exp r) (by positivity) (by positivity) + have hbase : (rationalSolveHeight r H : ℝ) * H ≤ + Real.exp ((p + 2) ^ 5 + p) := by + rw [Real.exp_add] + exact mul_le_mul hsolve hH (Nat.cast_nonneg _) (by positivity) + have hpower := pow_le_pow_left₀ (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + hbase r + rw [← Real.exp_nat_mul] at hpower + have hbound : (rationalKernelHeight r H : ℝ) ≤ + Real.exp (1 + (r : ℝ) + (r : ℝ) * ((p + 2) ^ 5 + p)) := by + unfold rationalKernelHeight + push_cast + rw [Real.exp_add] + exact mul_le_mul hfront hpower (by positivity) (by positivity) + apply hbound.trans + apply Real.exp_le_exp.mpr + calc + 1 + (r : ℝ) + (r : ℝ) * ((p + 2) ^ 5 + p) ≤ + 1 + p + p * ((p + 2) ^ 5 + p) := by gcongr + _ ≤ (p + 2) ^ 7 := by + have h : 0 ≤ p ^ 7 + 13 * p ^ 6 + 74 * p ^ 5 + 240 * p ^ 4 + + 480 * p ^ 3 + 591 * p ^ 2 + 415 * p + 127 := by positivity + nlinarith + +theorem exists_rational_kernel_basis_exp_height {ι κ : Type*} + [Fintype ι] [Fintype κ] [DecidableEq κ] + (A : Matrix ι κ ℚ) {H : ℕ} (hHpos : 1 ≤ H) + (hA : ∀ i j, RationalHeightLE (A i j) H) + {p : ℝ} (hp : 0 ≤ p) (hdim : (Fintype.card ι : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) : + ∃ b : Module.Basis (Fin (Module.finrank ℚ (LinearMap.ker A.mulVecLin))) + ℚ (LinearMap.ker A.mulVecLin), ∀ i j, + ((((b i : κ → ℚ) j).num.natAbs) : ℝ) ≤ Real.exp ((p + 2) ^ 7) ∧ + ((((b i : κ → ℚ) j).den) : ℝ) ≤ Real.exp ((p + 2) ^ 7) := by + obtain ⟨r, hr, b, hb⟩ := exists_bounded_rational_kernel_basis A hHpos hA + have hrp : (r : ℝ) ≤ p := (show (r : ℝ) ≤ Fintype.card ι from by exact_mod_cast hr).trans hdim + have hbudget := rationalKernelHeight_le_budget r H hp hrp hH + refine ⟨b, fun i j => ?_⟩ + constructor + · exact (show ((((b i : κ → ℚ) j).num.natAbs) : ℝ) ≤ rationalKernelHeight r H from + by exact_mod_cast (hb i j).1).trans hbudget + · exact (show ((((b i : κ → ℚ) j).den) : ℝ) ≤ rationalKernelHeight r H from + by exact_mod_cast (hb i j).2).trans hbudget + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalKernelInvariance.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalKernelInvariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..1be549efe4baea1023cbae771ac62e43b8702710 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalKernelInvariance.lean @@ -0,0 +1,41 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalCentralCircle + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem invariant_of_kernel_circles (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + (b : Basis ι ℚ K) (f : D.Space → ℂ) + (hf : let := D.metricSpace; ∀ i t x, + f ((D.centralRationalCircle (b i) (hK (b i).property)).act t x) = f x) + (z : D.RealGroup) (hz : z.coord ∈ K.baseChange ℝ) (x : D.Space) : + f (z • x) = f x := by + let := D.metricSpace + have hspan : Submodule.span ℝ (Set.range (fun i => D.periodicRealDirection (b i))) = + K.baseChange ℝ := + (D.periodicRealDirection_span (fun i => (b i : L))).trans + (real_span_rational_family K (fun i => (b i : L)) (span_submodule_basis K b)) + have h := central_span_character (fun i => D.periodicRealDirection (b i)) + (fun i => D.periodicRealDirection_central (b i) (hK (b i).property)) + (0 : (ℝ ⊗[ℚ] L) →ₗ[ℝ] ℝ) f (fun i r y => by + have hi := hf i (r : CircleFourier.Circle) y + rw [D.centralRationalCircle_act_coe] at hi + simpa only [LinearMap.zero_apply, mul_zero, AddCircle.coe_zero, character_zero, one_mul] using hi) + (hspan.symm ▸ hz) x + simpa only [LinearMap.zero_apply, AddCircle.coe_zero, character_zero, one_mul] using h + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalMatrixSeparation.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalMatrixSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..be943747f35ba02aedb57498396d86db25e3022b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalMatrixSeparation.lean @@ -0,0 +1,121 @@ +import Mathlib.Analysis.Normed.Group.Constructions +import Mathlib.LinearAlgebra.Basis.Defs +import OAI.Combinatorics.Progressions.Linear.FiniteSpanRounding +import OAI.Combinatorics.Progressions.Sampling.RealGridSeparation + +namespace OAI + +section + +namespace Erdos3 + +theorem rational_abs_real_le_numerator (q : ℚ) : + |(q : ℝ)| ≤ (q.num.natAbs : ℝ) := by + have hdenabs : |(q.den : ℝ)| = (q.den : ℝ) := abs_of_nonneg (Nat.cast_nonneg _) + rw [Rat.cast_def, abs_div, hdenabs] + have hden : (1 : ℝ) ≤ q.den := by exact_mod_cast q.den_pos + simpa only [Nat.cast_natAbs, Int.cast_abs] using div_le_self (abs_nonneg (q.num : ℝ)) hden + +theorem RationalHeightLE.abs_real_le {q : ℚ} {H : ℕ} (hq : RationalHeightLE q H) : + |(q : ℝ)| ≤ H := + (rational_abs_real_le_numerator q).trans (Nat.cast_le.mpr hq.1) + +variable {ι κ V : Type*} [Fintype ι] [AddCommGroup V] [Module ℝ V] + +theorem boundedSpanCell_linear_bound (v : ι → V) (f : V →ₗ[ℝ] ℝ) {c H : ℝ} + (hc : 0 ≤ c) (hv : ∀ i, |f (v i)| ≤ H) {x : V} (hx : x ∈ boundedSpanCell v c) : + |f x| ≤ Fintype.card ι * c * H := by + classical + obtain ⟨t, ht, rfl⟩ := hx + simp only [map_sum, map_smul, smul_eq_mul] + calc + _ ≤ ∑ i, |t i * f (v i)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _ : ι, c * H := by + apply Finset.sum_le_sum + intro i _ + have hi := ht i (Set.mem_univ i) + rw [abs_mul, abs_of_nonneg hi.1] + exact mul_le_mul hi.2 (hv i) (abs_nonneg _) hc + _ = _ := by simp [mul_assoc] + +theorem boundedSpanCell_coordinate_bound (e : Module.Basis κ ℝ V) (v : ι → V) {c H : ℝ} + (hc : 0 ≤ c) (hv : ∀ i j, |e.repr (v i) j| ≤ H) {x : V} + (hx : x ∈ boundedSpanCell v c) (j : κ) : + |e.repr x j| ≤ Fintype.card ι * c * H := + boundedSpanCell_linear_bound v (e.coord j) hc (fun i => hv i j) hx + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix NNReal + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +theorem real_matrix_denominator_grid (Q : Matrix ι κ ℚ) (l : ℕ) (x : κ → ℝ) + (hx : x ∈ realDenominatorGrid l) : + (fun i j => (Q i j : ℝ)) *ᵥ x ∈ realDenominatorGrid (matrixDenominator Q * l) := by + classical + obtain ⟨z, hz⟩ := hx + have hcoef (i : ι) (j : κ) : + ((clearedMatrix Q i j : ℤ) : ℝ) = (matrixDenominator Q : ℝ) * (Q i j : ℝ) := by + have h := congrFun (congrFun (clearedMatrix_cast Q) i) j + change ((clearedMatrix Q i j : ℤ) : ℚ) = (matrixDenominator Q : ℚ) * Q i j at h + exact_mod_cast h + refine ⟨clearedMatrix Q *ᵥ z, funext fun i => ?_⟩ + change (((clearedMatrix Q *ᵥ z) i : ℤ) : ℝ) = + ((matrixDenominator Q * l : ℕ) : ℝ) * ((fun i j => (Q i j : ℝ)) *ᵥ x) i + simp only [Matrix.mulVec, dotProduct, Int.cast_sum, Int.cast_mul, Nat.cast_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + have hj : (z j : ℝ) = (l : ℝ) * x j := congrFun hz j + rw [hcoef, hj] + ring + +omit [Fintype ι] in + +theorem abs_matrix_mulVec_le (Q : Matrix ι κ ℝ) (H : ℝ≥0) + (hQ : ∀ i j, |Q i j| ≤ H) (x : κ → ℝ) (i : ι) : + |(Q *ᵥ x) i| ≤ ((Fintype.card κ : ℝ) + 1) * (H + 1) * ‖x‖ := by + classical + calc + _ ≤ ∑ j, |Q i j * x j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : κ, (H : ℝ) * ‖x‖ := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + exact mul_le_mul (hQ i j) (by simpa only [Real.norm_eq_abs] using norm_le_pi_norm x j) + (abs_nonneg _) H.coe_nonneg + _ = (Fintype.card κ : ℝ) * H * ‖x‖ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + _ ≤ _ := by gcongr <;> linarith + +theorem rational_matrix_kernel_separation (Q : Matrix ι κ ℚ) (H : ℝ≥0) + (hQ : ∀ i j, |(Q i j : ℝ)| ≤ H) (l : ℕ) (hl : 0 < l) (x y : κ → ℝ) + (hx : x ∈ realDenominatorGrid l) + (hy : (fun i j => (Q i j : ℝ)) *ᵥ y = 0) + (hnear : ((matrixDenominator Q * l : ℕ) : ℝ) * + (((Fintype.card κ : ℝ) + 1) * (H + 1)) * dist x y < 1) : + (fun i j => (Q i j : ℝ)) *ᵥ x = 0 := by + have hD : 0 < matrixDenominator Q * l := Nat.mul_pos (matrixDenominator_pos Q) hl + apply eq_zero_of_mem_realDenominatorGrid_of_abs_lt hD (real_matrix_denominator_grid Q l x hx) + intro i + have hbound := abs_matrix_mulVec_le (fun i j => (Q i j : ℝ)) H hQ (x - y) i + have heq := Matrix.mulVec_sub (fun i j => (Q i j : ℝ)) x y + rw [hy, sub_zero] at heq + rw [heq, ← dist_eq_norm] at hbound + apply (lt_div_iff₀ (show (0 : ℝ) < ((matrixDenominator Q * l : ℕ) : ℝ) by exact_mod_cast hD)).mpr + calc + |((fun i j => (Q i j : ℝ)) *ᵥ x) i| * ((matrixDenominator Q * l : ℕ) : ℝ) ≤ + (((Fintype.card κ : ℝ) + 1) * (H + 1) * dist x y) * ((matrixDenominator Q * l : ℕ) : ℝ) := + mul_le_mul_of_nonneg_right hbound (by positivity) + _ < 1 := by nlinarith [hnear] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalSpanCoordinates.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalSpanCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3dcffbe1ac05c38a91c1b170ae0ab8b247b124b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalSpanCoordinates.lean @@ -0,0 +1,118 @@ +import OAI.Combinatorics.Progressions.Estimates.RealifiedMultidegree + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem span_submodule_basis (P : Submodule ℚ L) (b : Basis κ ℚ P) : + Submodule.span ℚ (Set.range (fun j => (b j : L))) = P := by + change Submodule.span ℚ (Set.range (P.subtype ∘ b)) = P + rw [Set.range_comp, ← Submodule.map_span, b.span_eq, Submodule.map_top, Submodule.range_subtype] + +theorem real_span_rational_family (P : Submodule ℚ L) (v : κ → L) + (hspan : Submodule.span ℚ (Set.range v) = P) : + Submodule.span ℝ (Set.range (fun j => rationalLieInclusion (v j))) = P.baseChange ℝ := by + rw [← hspan, Submodule.baseChange_span, ← Set.range_comp] + rfl + +theorem realification_layer_eq_span (n : ℕ) (v : κ → L) + (hspan : Submodule.span ℚ (Set.range v) = (LieModule.lowerCentralSeries ℚ L L n).toSubmodule) : + (LieModule.lowerCentralSeries ℚ (ℝ ⊗[ℚ] L) (ℝ ⊗[ℚ] L) n : Set (ℝ ⊗[ℚ] L)) = + (Submodule.span ℝ (Set.range (fun j => rationalLieInclusion (v j))) : Set (ℝ ⊗[ℚ] L)) := by + calc + _ = (LieModule.lowerCentralSeries ℝ (ℝ ⊗[ℚ] L) (ℝ ⊗[ℚ] L) n : Set (ℝ ⊗[ℚ] L)) := by + rw [LieModule.coe_lowerCentralSeries_eq_int ℚ, + LieModule.coe_lowerCentralSeries_eq_int ℝ] + _ = ((LieModule.lowerCentralSeries ℚ L L n).baseChange ℝ : Set (ℝ ⊗[ℚ] L)) := by + rw [LieSubmodule.lowerCentralSeries_tensor_eq_baseChange] + _ = ((LieModule.lowerCentralSeries ℚ L L n).toSubmodule.baseChange ℝ : Set (ℝ ⊗[ℚ] L)) := rfl + _ = _ := congrArg (fun P : Submodule ℝ (ℝ ⊗[ℚ] L) => (P : Set (ℝ ⊗[ℚ] L))) + (real_span_rational_family _ v hspan).symm + +theorem exists_finite_layer_spanning [Fintype ι] (e : Basis ι ℚ L) (n : ℕ) : + ∃ d : ℕ, d ≤ Fintype.card ι ∧ ∃ v : Fin d → L, + Submodule.span ℚ (Set.range v) = (LieModule.lowerCentralSeries ℚ L L n).toSubmodule := by + let : FiniteDimensional ℚ L := e.finiteDimensional_of_finite + let P := (LieModule.lowerCentralSeries ℚ L L n).toSubmodule + let b := Module.finBasis ℚ P + refine ⟨finrank ℚ P, ?_, (fun j => (b j : L)), span_submodule_basis P b⟩ + simpa only [Module.finrank_eq_card_basis e] using P.finrank_le + +theorem rationalLieInclusion_integer_combination [Fintype κ] (v : κ → L) (z : κ → ℤ) (m : ℕ) : + rationalLieInclusion (∑ j, ((z j : ℚ) * (m : ℚ)) • v j) = + ∑ j, ((z j : ℝ) * (m : ℝ)) • rationalLieInclusion (v j) := by + rw [map_sum] + apply Finset.sum_congr rfl + intro j _ + rw [map_smul] + rw [← algebraMap_smul ℝ ((z j : ℚ) * (m : ℚ))] + simp only [map_mul, map_intCast, map_natCast] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι κ η L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + +theorem real_span_family_coordinates (e : Basis ι ℚ L) (v : κ → L) : + (Submodule.span ℝ (Set.range (fun j => rationalLieInclusion (v j)))).map + (e.baseChange ℝ).equivFun.toLinearMap = + Submodule.span ℝ (Set.range (fun j i => (e.repr (v j) i : ℝ))) := by + rw [Submodule.map_span, ← Set.range_comp] + congr 2 + funext j i + exact rationalLieInclusion_coordinates e (v j) i + +theorem real_span_family_mem_iff_coordinates (e : Basis ι ℚ L) (v : κ → L) + (x : ℝ ⊗[ℚ] L) : + x ∈ Submodule.span ℝ (Set.range (fun j => rationalLieInclusion (v j))) ↔ + (e.baseChange ℝ).equivFun x ∈ + Submodule.span ℝ (Set.range (fun j i => (e.repr (v j) i : ℝ))) := by + rw [← real_span_family_coordinates e v, Submodule.mem_map_equiv, + LinearEquiv.symm_apply_apply] + +theorem real_span_sum_family (v : κ → L) (w : η → L) : + Submodule.span ℝ (Set.range (fun j => rationalLieInclusion (Sum.elim v w j))) = + Submodule.span ℝ (Set.range (fun j => rationalLieInclusion (v j))) ⊔ + Submodule.span ℝ (Set.range (fun j => rationalLieInclusion (w j))) := by + have heq : (fun j => rationalLieInclusion (Sum.elim v w j)) = + Sum.elim (fun j => rationalLieInclusion (v j)) (fun j => rationalLieInclusion (w j)) := by + funext j + cases j <;> rfl + rw [heq, Set.Sum.elim_range, Submodule.span_union] + +omit [Fintype ι] in +theorem span_conditional_basis (e : Basis ι ℚ L) (S : Set ι) [DecidablePred (· ∈ S)] : + Submodule.span ℚ (Set.range (fun i => if i ∈ S then e i else 0)) = + Submodule.span ℚ (e '' S) := by + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨i, rfl⟩ + change (if i ∈ S then e i else 0) ∈ _ + split_ifs with h + · exact Submodule.subset_span ⟨i, h, rfl⟩ + · exact Submodule.zero_mem _ + · apply Submodule.span_le.mpr + rintro _ ⟨i, hi, rfl⟩ + apply Submodule.subset_span + exact ⟨i, by simp only [hi, ↓reduceIte]⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalSpanDerivativeSystem.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalSpanDerivativeSystem.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d7a56c809b0c612d654940e2e070625116886ff --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalSpanDerivativeSystem.lean @@ -0,0 +1,138 @@ +import Mathlib.Analysis.InnerProductSpace.PiL2 +import OAI.Combinatorics.Progressions.Estimates.FirstCoefficientDerivativeBounds +import OAI.Combinatorics.Progressions.Geometry.WeightedCoordinateExtraction + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {E ι : Type*} [AddCommGroup E] [Module ℝ E] + +noncomputable def basisWeightedCoordinates (b : Basis ι ℝ E) (scale : ι → ℝ) : + E →ₗ[ℝ] (ι → ℝ) := + LinearMap.pi (fun i => scale i • b.coord i) + +@[simp] theorem basisWeightedCoordinates_apply (b : Basis ι ℝ E) (scale : ι → ℝ) + (x : E) (i : ι) : + basisWeightedCoordinates b scale x i = scale i * b.repr x i := rfl + +theorem basisWeightedCoordinates_norm_le_iff [Fintype ι] + (b : Basis ι ℝ E) (scale : ι → ℝ) (hscale : ∀ i, 0 < scale i) + {M : ℝ} (hM : 0 ≤ M) (x : E) : + ‖basisWeightedCoordinates b scale x‖ ≤ M ↔ ∀ i, |b.equivFun x i| ≤ M / scale i := by + constructor + · intro hx i + apply (le_div_iff₀ (hscale i)).mpr + have hi := (norm_le_pi_norm (basisWeightedCoordinates b scale x) i).trans hx + simpa only [basisWeightedCoordinates_apply, Real.norm_eq_abs, abs_mul, + abs_of_pos (hscale i), Basis.equivFun_apply, mul_comm] using hi + · intro hx + apply (pi_norm_le_iff_of_nonneg hM).mpr + intro i + have hi := (le_div_iff₀ (hscale i)).mp (hx i) + simpa only [basisWeightedCoordinates_apply, Real.norm_eq_abs, abs_mul, + abs_of_pos (hscale i), Basis.equivFun_apply, mul_comm] using hi + +theorem basisWeightedCoordinates_operator_bound [Fintype ι] + (b : Basis ι ℝ E) (scale : ι → ℝ) (hscale : ∀ i, 0 < scale i) + (A : E →ₗ[ℝ] E) (C : ℝ) (hC : 0 ≤ C) + (hA : ∀ M, 0 ≤ M → ∀ x, (∀ i, |b.equivFun x i| ≤ M / scale i) → + ∀ i, |b.equivFun (A x) i| ≤ C * M / scale i) (x : E) : + ‖basisWeightedCoordinates b scale (A x)‖ ≤ C * ‖basisWeightedCoordinates b scale x‖ := by + apply (basisWeightedCoordinates_norm_le_iff b scale hscale + (mul_nonneg hC (norm_nonneg _)) (A x)).mpr + exact hA _ (norm_nonneg _) x + ((basisWeightedCoordinates_norm_le_iff b scale hscale (norm_nonneg _) x).mp le_rfl) + +theorem basisWeightedCoordinates_norm_le_euclidean [Fintype ι] + (b : Basis ι ℝ E) (scale : ι → ℝ) (x : E) : + ‖basisWeightedCoordinates b scale x‖ ≤ + ‖(EuclideanSpace.equiv ι ℝ).symm (basisWeightedCoordinates b scale x)‖ := by + apply (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr + intro i + exact PiLp.norm_apply_le + ((EuclideanSpace.equiv ι ℝ).symm (basisWeightedCoordinates b scale x)) i + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem transport_coordinate_derivatives_to_rational_span + {σ E V : Type*} [Fintype σ] [DecidableEq σ] + [AddCommGroup E] [Module ℝ E] [AddCommGroup V] [Module ℚ V] + {a d : ℕ} (ha : a ≤ d) (b : Basis (Fin d) ℝ E) + (η : (Fin a → ℝ) ≃ₗ[ℝ] (ℝ ⊗[ℚ] V)) (P : E →ₗ[ℝ] (ℝ ⊗[ℚ] V)) + (hP : ∀ x, η (fun i => b.equivFun x (Fin.castLE ha i)) = P x) + (T : σ → ℝ) (Y : (σ → ℝ) →ₗ[ℝ] E) (f : E ≃ₗ[ℝ] E) + (scale : Fin d → ℝ) (bound : ℝ) + (D : CoordinateDerivativeSystem ha T (b.equivFun.toLinearMap.comp Y) + (b.equivFun.symm.trans (f.trans b.equivFun)) scale bound) + (K : Submodule ℚ V) (bK : Basis (Fin D.k) ℚ K) + (hspan : D.K.map η.toLinearMap = K.baseChange ℝ) + (hbasis : ∀ j, (1 : ℝ) ⊗ₜ[ℚ] (bK j : V) = η ((D.basisMatrix.map (Rat.castHom ℝ)).col j)) : + ∃ S R : (K.baseChange ℝ) →ₗ[ℝ] E, + S = f.toLinearMap.comp R ∧ P.comp S = (K.baseChange ℝ).subtype ∧ + P.comp R = (K.baseChange ℝ).subtype ∧ + (∀ x, ‖basisWeightedCoordinates b scale (S x)‖ ≤ bound * ‖η.symm x.val‖) ∧ + (∀ j, b.equivFun (R (realSubmoduleBasis K bK j)) ∈ realDenominatorGrid D.liftDenominator) ∧ + ∃ (small rational : σ → E) (k : σ → K.baseChange ℝ), + (∀ i, Y (Pi.single i 1) = small i + f (rational i) + S (k i)) ∧ + (∀ i, b.equivFun (rational i) ∈ realDenominatorGrid D.derivativeDenominator) ∧ + (∀ i, ‖basisWeightedCoordinates b scale (small i)‖ ≤ bound / T i) := by + have hraw := transport_coordinate_derivative_system ha b η P hP T Y f scale bound D + obtain ⟨_, R₀, S₀, hSR₀, hR₀, hS₀, hnorm₀, hgrid₀, hsystem₀⟩ := hraw + let eK : (K.baseChange ℝ) ≃ₗ[ℝ] D.K.map η.toLinearMap := + LinearEquiv.ofEq _ _ hspan.symm + have heK (x : K.baseChange ℝ) : (eK x).val = x.val := + LinearEquiv.coe_ofEq_apply hspan.symm x + let S := S₀.comp eK.toLinearMap + let R := R₀.comp eK.toLinearMap + have hSR : S = f.toLinearMap.comp R := by + apply LinearMap.ext + intro x + exact LinearMap.congr_fun hSR₀ (eK x) + have hS : P.comp S = (K.baseChange ℝ).subtype := by + apply LinearMap.ext + intro x + exact (hS₀ (eK x)).trans (heK x) + have hR : P.comp R = (K.baseChange ℝ).subtype := by + apply LinearMap.ext + intro x + exact (hR₀ (eK x)).trans (heK x) + refine ⟨S, R, hSR, hS, hR, ?_, ?_, ?_⟩ + · intro x + have h := (basisWeightedCoordinates_norm_le_euclidean b scale (S x)).trans (hnorm₀ (eK x)) + simpa only [heK] using h + · intro j + obtain ⟨x, hx, hg⟩ := hgrid₀ j + have he : eK (realSubmoduleBasis K bK j) = x := by + apply Subtype.ext + exact (heK _).trans ((realSubmoduleBasis_coe K bK j).trans ((hbasis j).trans hx.symm)) + exact (congrArg (fun z => b.equivFun (R₀ z) ∈ realDenominatorGrid D.liftDenominator) he).mpr hg + · choose small rational k₀ hsystem hgrid hsmall using hsystem₀ + refine ⟨small, rational, fun i => eK.symm (k₀ i), ?_, hgrid, ?_⟩ + · intro i + have he : S (eK.symm (k₀ i)) = S₀ (k₀ i) := + congrArg S₀ (eK.apply_symm_apply (k₀ i)) + have hi : Pi.basisFun ℝ σ i = (Pi.single i 1 : σ → ℝ) := Pi.basisFun_apply ℝ σ i + exact (congrArg Y hi).symm.trans + ((hsystem i).trans (congrArg (fun z => small i + f (rational i) + z) he.symm)) + · intro i + exact (basisWeightedCoordinates_norm_le_euclidean b scale (small i)).trans (hsmall i) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalTagConstraintBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalTagConstraintBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..7068bd5ff1c6deb23f5a6d31642f28b0f6c16dda --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalTagConstraintBasis.lean @@ -0,0 +1,150 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalTagConstraintSpaces + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {η B κ : Type*} [Fintype η] [Fintype B] + +theorem realRationalCoordinateSpan_iInf (U : η → Submodule ℚ (B → ℚ)) : + realRationalCoordinateSpan (⨅ a, U a) = ⨅ a, realRationalCoordinateSpan (U a) := by + unfold realRationalCoordinateSpan + rw [real_baseChange_iInf] + apply Submodule.map_iInf_of_ker_le realRationalCoordinateEquiv.surjective + rw [LinearMap.ker_eq_bot.mpr realRationalCoordinateEquiv.injective] + exact bot_le + +theorem realRationalCoordinateSpan_top : + realRationalCoordinateSpan (⊤ : Submodule ℚ (B → ℚ)) = ⊤ := by + unfold realRationalCoordinateSpan + rw [Submodule.baseChange_top, Submodule.map_top] + exact LinearMap.range_eq_top.mpr realRationalCoordinateEquiv.surjective + +theorem realRationalCoordinateSpan_iInf_basis (U : η → Submodule ℚ (B → ℚ)) + (b : Basis κ ℚ ↥(⨅ a, U a)) : + Submodule.span ℝ (Set.range (fun i j => ((b i : B → ℚ) j : ℝ))) = + ⨅ a, realRationalCoordinateSpan (U a) := by + have hb : Submodule.span ℚ (Set.range (fun i => (b i : B → ℚ))) = ⨅ a, U a := by + simpa only [Submodule.map_span, ← Set.range_comp, Function.comp_def, Submodule.subtype_apply, + Submodule.map_top, Submodule.range_subtype] using + congrArg (Submodule.map (⨅ a, U a).subtype) b.span_eq + exact (realRationalCoordinateSpan_span (fun i => (b i : B → ℚ))).symm.trans + ((congrArg realRationalCoordinateSpan hb).trans (realRationalCoordinateSpan_iInf U)) + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module + +variable {m : ℕ} {J : Fin m → Type*} [∀ j, Fintype (J j)] + +noncomputable def rationalTagConstraintIntersection (cs : List (RationalTagConstraint J)) + (j : Fin m) : Submodule ℚ (J j → ℚ) := + ⨅ i : Fin cs.length, (cs.get i).rationalSpace j + +theorem exists_rationalTagConstraintList_basis + (cs : List (RationalTagConstraint J)) (j : Fin m) {p : ℝ} + (hp : 0 ≤ p) (hdim : (Fintype.card (J j) : ℝ) ≤ p) + (hlen : (cs.length : ℝ) ≤ p) (hcs : ∀ c ∈ cs, c.BudgetLE p) : + ∃ n : ℕ, n ≤ Fintype.card (J j) ∧ + ∃ b : Basis (Fin n) ℚ (rationalTagConstraintIntersection cs j), + ∀ a i, rationalLogHeight ((b a : J j → ℚ) i) ≤ ((p + 2) ^ 2 + 2) ^ 63 := by + classical + choose v hv hheight using fun i : Fin cs.length => + (cs.get i).exists_rationalSpace_spanning j hp (hcs _ (List.get_mem _ _)) + obtain ⟨n, hn, b, hb⟩ := exists_submodule_intersection_basis_logHeight + (Pi.basisFun ℚ (J j)) (fun i : Fin cs.length => (cs.get i).rationalSpace j) + v hv hp hdim (by simpa only [Fintype.card_fin] using hdim) + (by simpa only [Fintype.card_fin] using hlen) hheight + exact ⟨n, hn, b, hb⟩ + +private theorem constraint_realSpaces_member_iff {X : Type*} + (c : RationalTagConstraint J) (point : (X ⊕ (Σ j, J j)) → ℝ) : + (∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ realRationalCoordinateSpan (c.rationalSpace j)) ↔ + c.member point := by + constructor + · intro h + simpa only [RationalTagConstraint.rationalSpace_self, realRationalCoordinateSpan_span, + RationalTagConstraint.member] using h c.tag + · intro h j + by_cases hj : j = c.tag + · subst j + simpa only [RationalTagConstraint.rationalSpace_self, realRationalCoordinateSpan_span, + RationalTagConstraint.member] using h + · rw [c.rationalSpace_of_ne hj, realRationalCoordinateSpan_top] + trivial + +theorem rationalTagConstraintList_basis_member_iff {X : Type*} + (cs : List (RationalTagConstraint J)) (n : Fin m → ℕ) + (b : ∀ j, Basis (Fin (n j)) ℚ (rationalTagConstraintIntersection cs j)) + (point : (X ⊕ (Σ j, J j)) → ℝ) : + (∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ + Submodule.span ℝ (Set.range (fun a i => ((b j a : J j → ℚ) i : ℝ)))) ↔ + ∀ c ∈ cs, c.member point := by + have hspan (j : Fin m) : + Submodule.span ℝ (Set.range (fun a i => ((b j a : J j → ℚ) i : ℝ))) = + ⨅ k : Fin cs.length, realRationalCoordinateSpan ((cs.get k).rationalSpace j) := + realRationalCoordinateSpan_iInf_basis + (fun k : Fin cs.length => (cs.get k).rationalSpace j) (b j) + simp_rw [hspan, Submodule.mem_iInf] + constructor + · intro h c hc + obtain ⟨k, hk⟩ := List.mem_iff_get.mp hc + apply (constraint_realSpaces_member_iff c point).mp + intro j + simpa only [hk] using h j k + · intro h j k + exact (constraint_realSpaces_member_iff (cs.get k) point).mpr + (h _ (List.get_mem _ _)) j + +theorem RationalTaggedConstraintCertificate.exists_bounded_tag_bases {X : Type*} + {Kinitial K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p : ℝ} {Cblocks : ℕ} + (hcert : RationalTaggedConstraintCertificate J Kinitial K p Cblocks) + (hp : 0 ≤ p) (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (hblocks : (Cblocks : ℝ) ≤ p) : + ∃ (W : ∀ j, Submodule ℚ (J j → ℚ)) (n : Fin m → ℕ) + (b : ∀ j, Basis (Fin (n j)) ℚ (W j)), + (∀ j, n j ≤ Fintype.card (J j)) ∧ + (∀ j a i, rationalLogHeight ((b j a : J j → ℚ) i) ≤ ((p + 2) ^ 2 + 2) ^ 63) ∧ + K = Kinitial ∩ {point | ∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ + Submodule.span ℝ (Set.range (fun a i => ((b j a : J j → ℚ) i : ℝ)))} := by + classical + obtain ⟨cs, hlen, hbudget, hK⟩ := hcert + have hl : (cs.length : ℝ) ≤ p := (Nat.cast_le.mpr hlen).trans hblocks + choose n hn b hb using fun j => + exists_rationalTagConstraintList_basis cs j hp (hdim j) hl hbudget + refine ⟨rationalTagConstraintIntersection cs, n, b, hn, hb, ?_⟩ + rw [hK] + ext point + simp only [Set.mem_inter_iff, Set.mem_ofPred_eq, + rationalTagConstraintList_basis_member_iff cs n b point] + +theorem RationalTaggedConstraintCertificate.exists_bounded_tag_bases_univ {X : Type*} + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p : ℝ} {Cblocks : ℕ} + (hcert : RationalTaggedConstraintCertificate J Set.univ K p Cblocks) + (hp : 0 ≤ p) (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (hblocks : (Cblocks : ℝ) ≤ p) : + ∃ (W : ∀ j, Submodule ℚ (J j → ℚ)) (n : Fin m → ℕ) + (b : ∀ j, Basis (Fin (n j)) ℚ (W j)), + (∀ j, n j ≤ Fintype.card (J j)) ∧ + (∀ j a i, rationalLogHeight ((b j a : J j → ℚ) i) ≤ ((p + 2) ^ 2 + 2) ^ 63) ∧ + K = {point | ∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ + Submodule.span ℝ (Set.range (fun a i => ((b j a : J j → ℚ) i : ℝ)))} := by + obtain ⟨W, n, b, hn, hb, hK⟩ := hcert.exists_bounded_tag_bases hp hdim hblocks + exact ⟨W, n, b, hn, hb, by simpa only [Set.univ_inter] using hK⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalTagConstraintChartBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalTagConstraintChartBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c9cb6797f2595e7b9d483ecc2ccb803cdb0e209 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalTagConstraintChartBasis.lean @@ -0,0 +1,525 @@ +import Mathlib.LinearAlgebra.Basis.Basic +import Mathlib.LinearAlgebra.TensorProduct.Basis +import Mathlib.RingTheory.MvPolynomial.Basic +import OAI.Combinatorics.Progressions.Estimates.DerivativeIndexBounds +import OAI.Combinatorics.Progressions.Estimates.IndependentColumnsMinor +import OAI.Combinatorics.Progressions.Estimates.PartiallyBoundedNormalization +import OAI.Combinatorics.Progressions.Lattices.LatticeMinorNormBound +import OAI.Combinatorics.Progressions.Linear.RationalTagConstraintBasis +import OAI.Combinatorics.Progressions.Linear.TaggedSubmoduleBasis + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {κ V : Type*} [AddCommGroup V] [Module ℚ V] + (K : Submodule ℚ V) (b : Basis κ ℚ K) + +noncomputable def realSubmoduleBasis : Basis κ ℝ (K.baseChange ℝ) := + (b.baseChange ℝ).map (realificationSubmoduleEquiv K) + +theorem realSubmoduleBasis_coe (i : κ) : + (realSubmoduleBasis K b i : ℝ ⊗[ℚ] V) = (1 : ℝ) ⊗ₜ[ℚ] (b i : V) := by + rw [realSubmoduleBasis, Basis.map_apply, Basis.baseChange_apply, realificationSubmoduleEquiv_tmul] + +variable [Fintype κ] + +noncomputable def realSubmoduleParameterization : (κ → ℝ) ≃ₗ[ℝ] K.baseChange ℝ := + (realSubmoduleBasis K b).equivFun.symm + +theorem realSubmoduleParameterization_basis (i : κ) : + realSubmoduleParameterization K b (Pi.basisFun ℝ κ i) = realSubmoduleBasis K b i := by + classical + apply (realSubmoduleBasis K b).equivFun.injective + rw [realSubmoduleParameterization, LinearEquiv.apply_symm_apply] + ext j + simp [Pi.basisFun_apply, Pi.single_apply, eq_comm] + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_rational_matrix_of_grid_columns {ι κ : Type*} + (B : Matrix ι κ ℝ) (l : ℕ) (hl : 0 < l) + (hB : ∀ j, B.col j ∈ realDenominatorGrid l) : + ∃ Q : Matrix ι κ ℚ, (∀ j, Q.col j ∈ denominatorGrid l) ∧ + ∀ j, (fun i => (Q i j : ℝ)) = B.col j := by + choose q hq he using fun j => realDenominatorGrid_exists_rational l hl (B.col j) (hB j) + exact ⟨fun i j => q j i, hq, he⟩ + +theorem basis_projection_range_eq_span {E ι κ : Type*} + [AddCommGroup E] [Module ℝ E] (b : Module.Basis κ ℝ E) + (P : E →ₗ[ℝ] (ι → ℝ)) : + LinearMap.range P = Submodule.span ℝ (Set.range (fun j => P (b j))) := by + rw [← Submodule.map_top, ← b.span_eq, Submodule.map_span, ← Set.range_comp] + rfl + +theorem exists_rational_basis_projection {E ι κ : Type*} + [AddCommGroup E] [Module ℝ E] (b : Module.Basis κ ℝ E) + (P : E →ₗ[ℝ] (ι → ℝ)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ j, P (b j) ∈ realDenominatorGrid l) : + ∃ Q : Matrix ι κ ℚ, (∀ j, Q.col j ∈ denominatorGrid l) ∧ + (∀ j, (fun i => (Q i j : ℝ)) = P (b j)) ∧ + LinearMap.range P = Submodule.span ℝ (Set.range (fun j => fun i => (Q i j : ℝ))) := by + obtain ⟨Q, hQ, he⟩ := exists_rational_matrix_of_grid_columns + (Matrix.of (fun i j => P (b j) i)) l hl hgrid + refine ⟨Q, hQ, he, ?_⟩ + rw [basis_projection_range_eq_span b P] + congr 2 + funext j + exact (he j).symm + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_bounded_normalized_rational_image_basis {E ι : Type*} {k : ℕ} + [AddCommGroup E] [Module ℝ E] + (b : Module.Basis (Fin k) ℝ E) (P : E →ₗ[ℝ] (ι → ℝ)) + (l : ℕ) (hl : 0 < l) (hgrid : ∀ j, P (b j) ∈ realDenominatorGrid l) + (p : Fin k → ι) (hp : (Matrix.of (fun i j => P (b j) (p i))).det ≠ 0) + (C : ℝ) (hminor : ∀ q : Fin k → ι, |(Matrix.of (fun i j => P (b j) (q i))).det| ≤ C) : + ∃ Q : Matrix ι (Fin k) ℚ, + LinearIndependent ℚ Q.col ∧ LinearIndependent ℝ (Q.map (Rat.castHom ℝ)).col ∧ + (∀ i j, RationalHeightLE (Q i j) (Nat.ceil (C * (l : ℝ) ^ k))) ∧ + LinearMap.range P = Submodule.span ℝ (Set.range (Q.map (Rat.castHom ℝ)).col) := by + let H := Matrix.of (fun i j => P (b j) i) + obtain ⟨Q, hQ, hheight, hidentity⟩ := + exists_bounded_rational_row_normalization H l hl hgrid p hp C hminor + have hrealidentity : (Q.map (Rat.castHom ℝ)).submatrix p id = 1 := by + have h := congrArg (fun M : Matrix (Fin k) (Fin k) ℚ => M.map (Rat.castHom ℝ)) hidentity + rw [Matrix.map_one _ (map_zero _) (map_one _)] at h + calc + _ = (Q.submatrix p id).map (Rat.castHom ℝ) := rfl + _ = 1 := h + refine ⟨Q, independent_columns_of_identity_minor Q p hidentity, + independent_columns_of_identity_minor _ p hrealidentity, hheight, ?_⟩ + rw [hQ, row_normalization_col_span H p hp] + exact basis_projection_range_eq_span b P + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem exists_bounded_rational_projection_lift + {E F α β : Type*} [AddCommGroup E] [Module ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [Fintype α] {k : ℕ} + (b : Module.Basis (Fin k) ℝ E) (P : E →ₗ[ℝ] (α → ℝ)) + (hP : Function.Injective P) (g : E →ₗ[ℝ] (β → ℝ)) + (e : α → β) (hhor : ∀ v i, g v (e i) = P v i) + (W : (β → ℝ) →ₗ[ℝ] F) (C : ℝ) + (hbound : ∀ v, ‖W (g v)‖ ≤ C * ‖P v‖) + (B : Matrix β (Fin k) ℝ) (hB : ∀ i j, B i j = g (b j) i) + (p : Fin k → α) (hp : (B.submatrix (e ∘ p) id).det ≠ 0) + (Q : Matrix β (Fin k) ℚ) + (hQ : Q.map (Rat.castHom ℝ) = B * (B.submatrix (e ∘ p) id)⁻¹) + (hQid : Q.submatrix (e ∘ p) id = 1) : + let QH := Q.submatrix e id + ∃ R : LinearMap.range P →ₗ[ℝ] (β → ℝ), + (∀ x i, R x (e i) = x.val i) ∧ + (∀ x, ‖W (R x)‖ ≤ C * ‖x‖) ∧ + (∀ v, R ⟨P v, v, rfl⟩ = g v) ∧ + LinearMap.range P = Submodule.span ℝ (Set.range (QH.map (Rat.castHom ℝ)).col) ∧ + LinearIndependent ℝ (QH.map (Rat.castHom ℝ)).col ∧ + LinearIndependent ℚ QH.col ∧ + (∀ j, ∃ x : LinearMap.range P, + x.val = (QH.map (Rat.castHom ℝ)).col j ∧ R x = (Q.map (Rat.castHom ℝ)).col j) := by + let J := (LinearEquiv.ofInjective P hP).symm.toLinearMap + have hJ (x : LinearMap.range P) : P (J x) = x.val := + congrArg Subtype.val ((LinearEquiv.ofInjective P hP).apply_symm_apply x) + let R := g.comp J + let H := B.submatrix e id + let QH := Q.submatrix e id + have hHcol : H.col = fun j => P (b j) := by + funext j i + exact (hB (e i) j).trans (hhor (b j) i) + have hQH : QH.map (Rat.castHom ℝ) = H * (H.submatrix p id)⁻¹ := by + ext i j + exact congrArg (fun M : Matrix β (Fin k) ℝ => M (e i) j) hQ + have hQHid : QH.submatrix p id = 1 := hQid + have hrealid : (QH.map (Rat.castHom ℝ)).submatrix p id = 1 := by + rw [hQH] + exact row_normalization_submatrix H p hp + refine ⟨R, ?_, ?_, ?_, ?_, independent_columns_of_identity_minor _ p hrealid, + independent_columns_of_identity_minor QH p hQHid, ?_⟩ + · intro x i + exact (hhor (J x) i).trans (congrFun (hJ x) i) + · intro x + have h := hbound (J x) + rw [hJ x] at h + exact h + · intro v + have h : J ⟨P v, v, rfl⟩ = v := hP (hJ ⟨P v, v, rfl⟩) + change g (J ⟨P v, v, rfl⟩) = g v + rw [h] + · change LinearMap.range P = Submodule.span ℝ (Set.range (QH.map (Rat.castHom ℝ)).col) + rw [hQH, row_normalization_col_span H p hp, hHcol] + exact basis_projection_range_eq_span b P + · intro j + obtain ⟨v, hv⟩ := exists_normalized_basis_vector b g B hB + (B.submatrix (e ∘ p) id)⁻¹ j + have hv' : g v = (Q.map (Rat.castHom ℝ)).col j := by + rw [hQ] + exact hv + let x : LinearMap.range P := ⟨P v, v, rfl⟩ + refine ⟨x, ?_, ?_⟩ + · funext i + exact (hhor v i).symm.trans (congrFun hv' (e i)) + · have hx : J x = v := hP (hJ x) + change g (J x) = _ + rw [hx] + exact hv' + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι κ V : Type*} [Fintype ι] [AddCommGroup V] [Module ℚ V] + (e : Basis ι ℚ V) (K : Submodule ℚ V) (b : Basis κ ℚ K) + +noncomputable def submoduleBasisMatrix : Matrix ι κ ℚ := + fun i j => e.repr (b j).val i + +theorem realSubmoduleBasis_matrix_coordinates (j : κ) : + (e.baseChange ℝ).equivFun (realSubmoduleBasis K b j).val = + ((submoduleBasisMatrix e K b).map (Rat.castHom ℝ)).col j := by + funext i + rw [Basis.equivFun_apply, realSubmoduleBasis_coe, Basis.baseChange_repr_tmul] + simp [submoduleBasisMatrix, Matrix.col, Algebra.smul_def] + +theorem realSubmoduleBasis_matrix_span : + Submodule.span ℝ (Set.range ((submoduleBasisMatrix e K b).map (Rat.castHom ℝ)).col) = + (K.baseChange ℝ).map (e.baseChange ℝ).equivFun.toLinearMap := by + let f := (e.baseChange ℝ).equivFun.toLinearMap.comp (K.baseChange ℝ).subtype + have he : (f ∘ realSubmoduleBasis K b) = + ((submoduleBasisMatrix e K b).map (Rat.castHom ℝ)).col := by + funext j + exact realSubmoduleBasis_matrix_coordinates e K b j + have hs := congrArg (fun U : Submodule ℝ (K.baseChange ℝ) => U.map f) + (realSubmoduleBasis K b).span_eq + rw [Submodule.map_span, ← Set.range_comp, Submodule.map_top, he] at hs + exact hs.trans (by simp only [f, LinearMap.range_comp, Submodule.range_subtype]) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {B I : Type*} [Fintype B] + (U : Submodule ℚ (B → ℚ)) (b : Basis I ℚ U) + +noncomputable def rationalCoordinateRealBasis : Basis I ℝ (realRationalCoordinateSpan U) := + (realSubmoduleBasis U b).map (realRationalCoordinateEquiv.submoduleMap (U.baseChange ℝ)) + +@[simp] theorem rationalCoordinateRealBasis_apply (i : I) (j : B) : + (rationalCoordinateRealBasis U b i : B → ℝ) j = ((b i : B → ℚ) j : ℝ) := by + change realRationalCoordinateEquiv (realSubmoduleBasis U b i : ℝ ⊗[ℚ] (B → ℚ)) j = _ + rw [realSubmoduleBasis_coe, realRationalCoordinateEquiv_tmul, one_mul] + +theorem realRationalCoordinateSpan_basis : + Submodule.span ℝ (Set.range (fun i j => ((b i : B → ℚ) j : ℝ))) = + realRationalCoordinateSpan U := by + have hb : Submodule.span ℚ (Set.range (fun i => (b i : B → ℚ))) = U := by + change Submodule.span ℚ (Set.range (U.subtype ∘ b)) = U + rw [Set.range_comp, ← Submodule.map_span, b.span_eq, + Submodule.map_top, Submodule.range_subtype] + exact (realRationalCoordinateSpan_span (fun i => (b i : B → ℚ))).symm.trans + (congrArg realRationalCoordinateSpan hb) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem euclideanDerivative_bounded_horizontal_basis + {σ : Type*} [Fintype σ] {m : ℕ} + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) + (scale : Fin m → ℝ) (hscale : ∀ j, 1 ≤ scale j) + (Y : (σ → ℝ) →ₗ[ℝ] (Fin m → ℝ)) + (A : (Fin m → ℝ) ≃ₗ[ℝ] (Fin m → ℝ)) + (hA : ∀ i j, i < j → (LinearMap.toMatrix' A.toLinearMap) i j = 0) + (hdiag : ∀ i, (LinearMap.toMatrix' A.toLinearMap) i i = 1) + (l : ℕ) (hl : 0 < l) (R : ℝ) (a : ℕ) (ha : a ≤ m) (Tmin C : ℝ) + (hscalehor : ∀ j, j.val < a → scale j = 1) + (hblock : ∀ i j, i.val < a → j.val < a → + (LinearMap.toMatrix' A.toLinearMap) i j = (1 : Matrix (Fin m) (Fin m) ℝ) i j) + (hfar : ∀ i, a ≤ i.val → Tmin ≤ scale i) (hlarge : C * (l : ℝ) ^ m < Tmin) : + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let Λ := euclideanDerivativeLattice T hT scale hs0 Y A l hl + let Z := shortVectorSpan Λ R + let π := (euclideanDerivativeShiftMap T hT).comp Z.subtype + let V := LinearMap.ker π + let L := latticeKernel (shortVectorLattice Λ R) π + let P := (euclideanHorizontalProjection a ha).comp (Z.subtype.comp V.subtype) + let k := Module.finrank ℝ V + ZLattice.covolume L (MeasureTheory.volume (α := V)) ≤ C → + Function.Injective P ∧ ∃ Q : Matrix (Fin a) (Fin k) ℚ, + LinearIndependent ℚ Q.col ∧ LinearIndependent ℝ (Q.map (Rat.castHom ℝ)).col ∧ + (∀ i j, RationalHeightLE (Q i j) (Nat.ceil (C * (l : ℝ) ^ k))) ∧ + LinearMap.range P = Submodule.span ℝ (Set.range (Q.map (Rat.castHom ℝ)).col) := by + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let Λ := euclideanDerivativeLattice T hT scale hs0 Y A l hl + let Z := shortVectorSpan Λ R + let π := (euclideanDerivativeShiftMap T hT).comp Z.subtype + let V := LinearMap.ker π + let L := latticeKernel (shortVectorLattice Λ R) π + let P := (euclideanHorizontalProjection a ha).comp (Z.subtype.comp V.subtype) + dsimp only + intro hupper + have hinj : Function.Injective P := euclideanDerivative_horizontal_injective + T hT scale hscale Y A hA hdiag l hl R a ha Tmin C hscalehor hblock hfar hlarge hupper + refine ⟨hinj, ?_⟩ + let : IsZLattice ℝ L := euclideanDerivative_vertical_lattice_full T hT scale hs0 Y A l hl R + obtain ⟨b, B, _, hgrid, hrep, p, _, hdet⟩ := euclideanDerivative_horizontal_basis_data + T hT scale hscale Y A hA hdiag l hl R a ha Tmin C hfar hlarge hupper + let bR := b.ofZLatticeBasis ℝ L + let f : V →ₗᵢ[ℝ] EuclideanSpace ℝ (σ ⊕ Fin m) := Z.subtypeₗᵢ.comp V.subtypeₗᵢ + let e : Fin a → σ ⊕ Fin m := fun i => Sum.inr (Fin.castLE ha i) + have he : Function.Injective e := by + intro i j hij + have h : Fin.castLE ha i = Fin.castLE ha j := Sum.inr.inj hij + exact Fin.ext (congrArg (fun u : Fin m => u.val) h) + have hcoord (j) (i : Fin a) : P (bR j) i = B (Fin.castLE ha i) j := by + simp only [bR, Module.Basis.ofZLatticeBasis_apply] + change (b j).val.val.val (Sum.inr (Fin.castLE ha i)) = B (Fin.castLE ha i) j + rw [hrep] + exact euclideanVerticalMap_horizontal scale hs0 hscalehor A hA hblock (B.col j) + (Fin.castLE ha i) i.isLt + have hPgrid (j) : P (bR j) ∈ realDenominatorGrid l := by + obtain ⟨z, hz⟩ := hgrid j + refine ⟨fun i => z (Fin.castLE ha i), ?_⟩ + funext i + change (z (Fin.castLE ha i) : ℝ) = (l : ℝ) * P (bR j) i + rw [hcoord] + exact congrFun hz (Fin.castLE ha i) + have hp : (Matrix.of (fun i j => P (bR j) (p i))).det ≠ 0 := by + have hm : Matrix.of (fun i j => P (bR j) (p i)) = B.submatrix (Fin.castLE ha ∘ p) id := by + ext i j + exact hcoord j (p i) + rw [hm] + exact hdet + apply exists_bounded_normalized_rational_image_basis bR P l hl hPgrid p hp C + let H := Matrix.of (fun i j => P (bR j) i) + have hH (i j) : H i j = f (b j).val (e i) := by + simp only [H, Matrix.of_apply, bR, Module.Basis.ofZLatticeBasis_apply] + rfl + intro q + exact (lattice_projection_all_minors_bound L b f e he H hH q).trans hupper + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem euclideanDerivative_rational_lift_matrix_data + {σ : Type*} [Fintype σ] {m : ℕ} + (T : σ → ℝ) (hT : ∀ i, T i ≠ 0) + (scale : Fin m → ℝ) (hscale : ∀ j, 1 ≤ scale j) + (Y : (σ → ℝ) →ₗ[ℝ] (Fin m → ℝ)) + (A : (Fin m → ℝ) ≃ₗ[ℝ] (Fin m → ℝ)) + (hA : ∀ i j, i < j → (LinearMap.toMatrix' A.toLinearMap) i j = 0) + (hdiag : ∀ i, (LinearMap.toMatrix' A.toLinearMap) i i = 1) + (l : ℕ) (hl : 0 < l) (R : ℝ) (a : ℕ) (ha : a ≤ m) (Tmin C : ℝ) + (hscalehor : ∀ j, j.val < a → scale j = 1) + (hblock : ∀ i j, i.val < a → j.val < a → + (LinearMap.toMatrix' A.toLinearMap) i j = (1 : Matrix (Fin m) (Fin m) ℝ) i j) + (hfar : ∀ i, a ≤ i.val → Tmin ≤ scale i) (hlarge : C * (l : ℝ) ^ m < Tmin) : + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let Λ := euclideanDerivativeLattice T hT scale hs0 Y A l hl + let Z := shortVectorSpan Λ R + let π := (euclideanDerivativeShiftMap T hT).comp Z.subtype + let V := LinearMap.ker π + let L := latticeKernel (shortVectorLattice Λ R) π + let k := Module.finrank ℝ V + ZLattice.covolume L (MeasureTheory.volume (α := V)) ≤ C → + ∃ b : Module.Basis (Fin k) ℤ L, ∃ B : Matrix (Fin m) (Fin k) ℝ, + ∃ p : Fin k → Fin a, + (∀ j, B.col j ∈ realDenominatorGrid l) ∧ + (∀ j, (b j).val.val.val = euclideanVerticalMap scale hs0 A (B.col j)) ∧ + (B.submatrix (Fin.castLE ha ∘ p) id).det ≠ 0 ∧ + ∃ D : ℕ, 0 < D ∧ D ≤ Nat.ceil (C * (l : ℝ) ^ k) ∧ + ∃ Q : Matrix (Fin m) (Fin k) ℚ, + (∀ j, Q.col j ∈ denominatorGrid D) ∧ + Q.map (Rat.castHom ℝ) = B * (B.submatrix (Fin.castLE ha ∘ p) id)⁻¹ ∧ + Q.submatrix (Fin.castLE ha ∘ p) id = 1 ∧ + (∀ i j, RationalHeightLE (Q (Fin.castLE ha i) j) + (Nat.ceil (C * (l : ℝ) ^ k))) := by + let hs0 : ∀ j, scale j ≠ 0 := fun j => (lt_of_lt_of_le zero_lt_one (hscale j)).ne' + let Λ := euclideanDerivativeLattice T hT scale hs0 Y A l hl + let Z := shortVectorSpan Λ R + let π := (euclideanDerivativeShiftMap T hT).comp Z.subtype + let V := LinearMap.ker π + let L := latticeKernel (shortVectorLattice Λ R) π + dsimp only + intro hupper + let : IsZLattice ℝ L := euclideanDerivative_vertical_lattice_full T hT scale hs0 Y A l hl R + obtain ⟨b, B, _, hgrid, hrep, p, _, hdet⟩ := euclideanDerivative_horizontal_basis_data + T hT scale hscale Y A hA hdiag l hl R a ha Tmin C hfar hlarge hupper + refine ⟨b, B, p, hgrid, hrep, hdet, ?_⟩ + apply exists_partially_bounded_grid_normalization B l hl hgrid (Fin.castLE ha) p hdet C + let f : V →ₗᵢ[ℝ] EuclideanSpace ℝ (σ ⊕ Fin m) := Z.subtypeₗᵢ.comp V.subtypeₗᵢ + let e : Fin a → σ ⊕ Fin m := fun i => Sum.inr (Fin.castLE ha i) + have he : Function.Injective e := by + intro i j hij + have h : Fin.castLE ha i = Fin.castLE ha j := Sum.inr.inj hij + exact Fin.ext (congrArg (fun u : Fin m => u.val) h) + let H := B.submatrix (Fin.castLE ha) id + have hH (i j) : H i j = f (b j).val (e i) := by + change B (Fin.castLE ha i) j = (b j).val.val.val (Sum.inr (Fin.castLE ha i)) + rw [hrep] + exact (euclideanVerticalMap_horizontal scale hs0 hscalehor A hA hblock (B.col j) + (Fin.castLE ha i) i.isLt).symm + intro q + exact (lattice_projection_all_minors_bound L b f e he H hH q).trans hupper + +end Erdos3 + +end + +section + +namespace Erdos3.VectorPolynomial + +open Module + +variable {m : ℕ} {J : Fin m → Type*} + +noncomputable def rationalTagChartMatrix + (W : ∀ j, Submodule ℚ (J j → ℚ)) (n : Fin m → ℕ) + (b : ∀ j, Basis (Fin (n j)) ℚ (W j)) : + (Σ j, Fin (n j)) → (Σ j, J j) → ℚ := + fun a x => (Pi.single (M := fun j => J j → ℚ) a.1 + (b a.1 a.2 : J a.1 → ℚ)) x.1 x.2 + +theorem rationalTagChartMatrix_same + (W : ∀ j, Submodule ℚ (J j → ℚ)) (n : Fin m → ℕ) + (b : ∀ j, Basis (Fin (n j)) ℚ (W j)) (j : Fin m) (a : Fin (n j)) (i : J j) : + rationalTagChartMatrix W n b ⟨j, a⟩ ⟨j, i⟩ = (b j a : J j → ℚ) i := by + simp [rationalTagChartMatrix] + +theorem rationalTagChartMatrix_of_ne + (W : ∀ j, Submodule ℚ (J j → ℚ)) (n : Fin m → ℕ) + (b : ∀ j, Basis (Fin (n j)) ℚ (W j)) (a : Σ j, Fin (n j)) (x : Σ j, J j) + (h : x.1 ≠ a.1) : rationalTagChartMatrix W n b a x = 0 := by + simp [rationalTagChartMatrix, Pi.single_eq_of_ne h] + +theorem rationalTagChartMatrix_height + (W : ∀ j, Submodule ℚ (J j → ℚ)) (n : Fin m → ℕ) + (b : ∀ j, Basis (Fin (n j)) ℚ (W j)) {P : ℝ} (hP : 0 ≤ P) + (hb : ∀ j a i, rationalLogHeight ((b j a : J j → ℚ) i) ≤ P) : + ∀ a x, rationalLogHeight (rationalTagChartMatrix W n b a x) ≤ P := by + rintro ⟨j, a⟩ ⟨k, i⟩ + by_cases h : k = j + · subst k + rw [rationalTagChartMatrix_same] + exact hb j a i + · rw [rationalTagChartMatrix_of_ne W n b ⟨j, a⟩ ⟨k, i⟩ h] + simpa [rationalLogHeight] using hP + +theorem RationalTaggedConstraintCertificate.exists_bounded_chart_tag_basis {X : Type*} + [∀ j, Fintype (J j)] + {K : Set ((X ⊕ (Σ j, J j)) → ℝ)} {p : ℝ} {Cblocks : ℕ} + (hcert : RationalTaggedConstraintCertificate J Set.univ K p Cblocks) + (hp : 0 ≤ p) (hdim : ∀ j, (Fintype.card (J j) : ℝ) ≤ p) + (hblocks : (Cblocks : ℝ) ≤ p) : + ∃ (n : Fin m → ℕ) (Ktag : Submodule ℝ ((Σ j, J j) → ℝ)) + (b : Basis (Σ j, Fin (n j)) ℝ Ktag) + (matrix : (Σ j, Fin (n j)) → (Σ j, J j) → ℚ), + (∀ j, n j ≤ Fintype.card (J j)) ∧ + (∀ a x, (b a : (Σ j, J j) → ℝ) x = (matrix a x : ℝ)) ∧ + (∀ a x, x.1 ≠ a.1 → matrix a x = 0) ∧ + (∀ a x, rationalLogHeight (matrix a x) ≤ ((p + 2) ^ 2 + 2) ^ 63) ∧ + K = {point | (fun x => point (Sum.inr x)) ∈ Ktag} ∧ + ∀ (U : ∀ j, Submodule ℝ (J j → ℝ)), + (∀ point, (∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ U j) → point ∈ K) → + ∀ v : (Σ j, J j) → ℝ, (∀ j, (fun i => v ⟨j, i⟩) ∈ U j) → v ∈ Ktag := by + classical + obtain ⟨W, n, b, hn, hb, hK⟩ := hcert.exists_bounded_tag_bases_univ hp hdim hblocks + let R := fun j => realRationalCoordinateSpan (W j) + let br := fun j => rationalCoordinateRealBasis (W j) (b j) + let Ktag := taggedSubmodule R + let basis : Basis (Σ j, Fin (n j)) ℝ Ktag := taggedSubmoduleBasis R br + let matrix := rationalTagChartMatrix W n b + have hentry (a : Σ j, Fin (n j)) (x : Σ j, J j) : + (basis a : (Σ j, J j) → ℝ) x = (matrix a x : ℝ) := by + rcases a with ⟨j, a⟩ + rcases x with ⟨k, i⟩ + by_cases h : k = j + · subst k + change ((taggedSubmoduleBasis R br ⟨j, a⟩ : (Σ j, J j) → ℝ) ⟨j, i⟩) = _ + rw [taggedSubmoduleBasis_same] + dsimp only [matrix] + rw [rationalTagChartMatrix_same] + exact rationalCoordinateRealBasis_apply (W j) (b j) a i + · rw [show (basis ⟨j, a⟩ : (Σ j, J j) → ℝ) ⟨k, i⟩ = 0 from + taggedSubmoduleBasis_of_ne R br j a k i h] + rw [show matrix ⟨j, a⟩ ⟨k, i⟩ = 0 from + rationalTagChartMatrix_of_ne W n b ⟨j, a⟩ ⟨k, i⟩ h, Rat.cast_zero] + have htag : K = {point | (fun x => point (Sum.inr x)) ∈ Ktag} := by + rw [hK] + ext point + change (∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ + Submodule.span ℝ (Set.range (fun a i => ((b j a : J j → ℚ) i : ℝ)))) ↔ + ∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ realRationalCoordinateSpan (W j) + simp_rw [realRationalCoordinateSpan_basis] + refine ⟨n, Ktag, basis, matrix, hn, hentry, + rationalTagChartMatrix_of_ne W n b, + rationalTagChartMatrix_height W n b (by positivity) hb, htag, ?_⟩ + intro U hret v hv + have hpoint := hret (Sum.elim (fun _ : X => (0 : ℝ)) v) (by simpa using hv) + simpa only [htag, Set.mem_ofPred_eq, Sum.elim_inr] using hpoint + +theorem retained_tag_polynomial_coefficients_mem {X V : Type*} + (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) (Ktag : Submodule ℝ ((Σ j, J j) → ℝ)) + (hK : K = {point | (fun x => point (Sum.inr x)) ∈ Ktag}) + (U : ∀ j, Submodule ℝ (J j → ℝ)) + (hret : ∀ point, (∀ j, (fun i => point (Sum.inr ⟨j, i⟩)) ∈ U j) → point ∈ K) + (A : (Σ j, J j) → MvPolynomial V ℝ) + (hA : ∀ α j, (fun i => (A ⟨j, i⟩).coeff α) ∈ U j) : + ∀ α, (fun x => (A x).coeff α) ∈ Ktag := by + intro α + have h := hret (Sum.elim (fun _ : X => (0 : ℝ)) (fun x => (A x).coeff α)) + (by simpa using hA α) + simpa only [hK, Set.mem_ofPred_eq, Sum.elim_inr] using h + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalTagProjectionComplement.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalTagProjectionComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..141d2a5ea2c0dea059ae0d9718f98ea0c57f9d82 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalTagProjectionComplement.lean @@ -0,0 +1,173 @@ +import OAI.Combinatorics.Progressions.Estimates.FullTaggedRationalRetraction +import OAI.Combinatorics.Progressions.Sampling.RealMatrixSpecifiedGrid + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix Classical + +variable {T : Type*} [Fintype T] + +noncomputable def rationalTagProjectionComplement (P : Matrix T T ℚ) : + (T → ℝ) →ₗ[ℝ] (T → ℝ) := + LinearMap.id - Matrix.mulVecLin (fun i j => (P i j : ℝ)) + +@[simp] theorem rationalTagProjectionComplement_apply (P : Matrix T T ℚ) (x : T → ℝ) : + rationalTagProjectionComplement P x = x - (fun i j => (P i j : ℝ)) *ᵥ x := rfl + +theorem rationalTagProjectionComplement_eq_zero_of_mem + (P : Matrix T T ℚ) (V : Submodule ℚ (T → ℚ)) + (hfix : ∀ x ∈ realRationalCoordinateSpan V, + Matrix.mulVecLin (fun i j => (P i j : ℝ)) x = x) + (U : Submodule ℝ (T → ℝ)) (hU : U ≤ realRationalCoordinateSpan V) + {x : T → ℝ} (hx : x ∈ U) : rationalTagProjectionComplement P x = 0 := by + change x - Matrix.mulVecLin (fun i j => (P i j : ℝ)) x = 0 + rw [hfix x (hU hx), sub_self] + +theorem rationalTagProjectionComplement_ker + (P : Matrix T T ℚ) (V : Submodule ℚ (T → ℚ)) + (hrange : LinearMap.range (Matrix.mulVecLin (fun i j => (P i j : ℝ))) = + realRationalCoordinateSpan V) + (hfix : ∀ x ∈ realRationalCoordinateSpan V, + Matrix.mulVecLin (fun i j => (P i j : ℝ)) x = x) : + LinearMap.ker (rationalTagProjectionComplement P) = realRationalCoordinateSpan V := by + ext x + change x - Matrix.mulVecLin (fun i j => (P i j : ℝ)) x = 0 ↔ + x ∈ realRationalCoordinateSpan V + constructor + · intro hx + rw [sub_eq_zero] at hx + rw [hx, ← hrange] + exact ⟨x, rfl⟩ + · intro hx + rw [hfix x hx, sub_self] + +theorem rationalTagProjectionComplement_idempotent + (P : Matrix T T ℚ) (V : Submodule ℚ (T → ℚ)) + (hrange : LinearMap.range (Matrix.mulVecLin (fun i j => (P i j : ℝ))) = + realRationalCoordinateSpan V) + (hfix : ∀ x ∈ realRationalCoordinateSpan V, + Matrix.mulVecLin (fun i j => (P i j : ℝ)) x = x) + (x : T → ℝ) : + rationalTagProjectionComplement P (rationalTagProjectionComplement P x) = + rationalTagProjectionComplement P x := by + let L := Matrix.mulVecLin (fun i j => (P i j : ℝ)) + have hmem : L x ∈ realRationalCoordinateSpan V := by + rw [← hrange] + exact ⟨x, rfl⟩ + have hLL : L (L x) = L x := hfix _ hmem + change x - L x - L (x - L x) = x - L x + rw [map_sub, hLL, sub_self, sub_zero] + +theorem rationalTagProjectionComplement_entry_bound + (P : Matrix T T ℚ) {H : ℝ} (hH : 0 ≤ H) + (hP : ∀ i j, |(P i j : ℝ)| ≤ H) (a i : T) : + |rationalTagProjectionComplement P (Pi.single a 1) i| ≤ 1 + H := by + classical + have he : ((fun i j => (P i j : ℝ)) *ᵥ Pi.single a 1) i = (P i a : ℝ) := + congrFun (Matrix.mulVec_single_one (Matrix.of fun i j => (P i j : ℝ)) a) i + rw [rationalTagProjectionComplement_apply, Pi.sub_apply, he] + have hsingle : |(Pi.single a (1 : ℝ) : T → ℝ) i| ≤ (1 : ℝ) := by + by_cases hai : a = i + · subst i; simp + · simp [hai] + calc + _ ≤ |(Pi.single a (1 : ℝ) : T → ℝ) i| + |(P i a : ℝ)| := abs_sub _ _ + _ ≤ 1 + |H| := add_le_add hsingle ((hP i a).trans (le_abs_self H)) + _ = 1 + H := by rw [abs_of_nonneg hH] + +theorem rationalTagProjectionComplement_coordinate_bound + (P : Matrix T T ℚ) {H : ℝ} (hH : 0 ≤ H) + (hP : ∀ i j, |(P i j : ℝ)| ≤ H) (x : T → ℝ) (i : T) : + |rationalTagProjectionComplement P x i| ≤ + (1 + (Fintype.card T : ℝ) * H) * ‖x‖ := by + classical + have hx (j : T) : |x j| ≤ ‖x‖ := by + simpa only [Real.norm_eq_abs] using norm_le_pi_norm x j + have hrow : |((fun i j => (P i j : ℝ)) *ᵥ x) i| ≤ + (Fintype.card T : ℝ) * H * ‖x‖ := by + calc + _ ≤ ∑ j, |(P i j : ℝ) * x j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : T, H * ‖x‖ := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + exact mul_le_mul (hP i j) (hx j) (abs_nonneg _) hH + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + rw [rationalTagProjectionComplement_apply, Pi.sub_apply] + calc + _ ≤ |x i| + |((fun i j => (P i j : ℝ)) *ᵥ x) i| := abs_sub _ _ + _ ≤ ‖x‖ + (Fintype.card T : ℝ) * H * ‖x‖ := add_le_add (hx i) hrow + _ = _ := by ring + +theorem rationalTagProjectionComplement_coordinate_exp_bound + (P : Matrix T T ℚ) {p h : ℝ} (hp : 0 ≤ p) (hh : 0 ≤ h) + (hdim : (Fintype.card T : ℝ) ≤ p) + (hP : ∀ i j, rationalLogHeight (P i j) ≤ h) (x : T → ℝ) (i : T) : + |rationalTagProjectionComplement P x i| ≤ Real.exp (p + h + 1) * ‖x‖ := by + have hentry : ∀ i j, |(P i j : ℝ)| ≤ Real.exp h := fun i j => + (rational_abs_real_le_numerator (P i j)).trans + ((rationalLogHeight_le_iff _ _).mp (hP i j)).1 + apply (rationalTagProjectionComplement_coordinate_bound P (Real.exp_nonneg _) hentry x i).trans + apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) + have hdimexp : (Fintype.card T : ℝ) ≤ Real.exp p := + hdim.trans (by linarith [Real.add_one_le_exp p]) + have h1 : 1 ≤ Real.exp (p + h) := Real.one_le_exp_iff.mpr (add_nonneg hp hh) + calc + 1 + (Fintype.card T : ℝ) * Real.exp h ≤ 1 + Real.exp p * Real.exp h := by gcongr + _ = 1 + Real.exp (p + h) := by rw [Real.exp_add] + _ ≤ 2 * Real.exp (p + h) := by linarith + _ ≤ Real.exp 1 * Real.exp (p + h) := mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (1 : ℝ)]) (Real.exp_nonneg _) + _ = Real.exp (p + h + 1) := by rw [← Real.exp_add]; congr 1; ring + +theorem rationalTagProjectionComplement_eq_iff_sub_mem + (P : Matrix T T ℚ) (V : Submodule ℚ (T → ℚ)) + (hrange : LinearMap.range (Matrix.mulVecLin (fun i j => (P i j : ℝ))) = + realRationalCoordinateSpan V) + (hfix : ∀ x ∈ realRationalCoordinateSpan V, + Matrix.mulVecLin (fun i j => (P i j : ℝ)) x = x) (x y : T → ℝ) : + rationalTagProjectionComplement P x = rationalTagProjectionComplement P y ↔ + x - y ∈ realRationalCoordinateSpan V := by + rw [← rationalTagProjectionComplement_ker P V hrange hfix, + LinearMap.mem_ker, map_sub, sub_eq_zero] + +theorem rationalTagProjectionComplement_denominator_grid + (P : Matrix T T ℚ) (D l : ℕ) + (hP : ∀ i j, ∃ z : ℤ, (D : ℝ) * (P i j : ℝ) = z) + (x : T → ℝ) (hx : x ∈ realDenominatorGrid l) : + rationalTagProjectionComplement P x ∈ realDenominatorGrid (D * l) := + real_matrix_complement_linearMap_specified_denominator_grid + (fun i j => (P i j : ℝ)) D l hP x hx + +theorem rationalTagProjectionComplement_integer_grid + (P : Matrix T T ℚ) (D : ℕ) + (hP : ∀ i j, ∃ z : ℤ, (D : ℝ) * (P i j : ℝ) = z) + (x : T → ℤ) : + ∃ z : T → ℤ, ∀ i, + (D : ℝ) * rationalTagProjectionComplement P (fun j => (x j : ℝ)) i = (z i : ℝ) := by + have hx : (fun j => (x j : ℝ)) ∈ realDenominatorGrid 1 := + ⟨x, by ext j; simp⟩ + obtain ⟨z, hz⟩ := rationalTagProjectionComplement_denominator_grid P D 1 hP _ hx + refine ⟨z, fun i => ?_⟩ + have hi := congrFun hz i + simpa only [mul_one, Pi.smul_apply, smul_eq_mul] using hi.symm + +namespace VectorPolynomial + +variable {m : ℕ} (J : Fin m → Type*) [∀ j, Fintype (J j)] + +theorem fullTaggedRealMatrixProjection_complement + (P : ∀ j, Matrix (J j) (J j) ℚ) (j : Fin m) : + LinearMap.id - fullTaggedRealMatrixProjection J P j = + rationalTagProjectionComplement (P j) := rfl + +end VectorPolynomial +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RationalTaggedSpanProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/RationalTaggedSpanProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..da2e3de3bb692d8be859b5a420d0389049407a16 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RationalTaggedSpanProjection.lean @@ -0,0 +1,324 @@ +import OAI.Combinatorics.Progressions.Estimates.CocycleHorizontalNormalization +import OAI.Combinatorics.Progressions.Estimates.RationalPowerHeight +import OAI.Combinatorics.Progressions.Linear.RealRationalMatrixPiNaturality + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {I J K : Type*} [Fintype I] [Fintype J] [Fintype K] + +theorem rationalMatrix_real_ker_eq_range + (A : Matrix I K ℚ) (D : Matrix J I ℚ) + (h : LinearMap.ker D.mulVecLin = LinearMap.range A.mulVecLin) : + LinearMap.ker (Matrix.mulVecLin (fun j i => (D j i : ℝ))) = + LinearMap.range (Matrix.mulVecLin (fun i k => (A i k : ℝ))) := by + classical + let : Module.Free ℚ ℝ := Module.Free.of_divisionRing ℚ ℝ + have hex : Function.Exact (A.mulVecLin.baseChange ℝ) (D.mulVecLin.baseChange ℝ) := + Module.Flat.lTensor_exact ℝ (LinearMap.exact_iff.mpr h) + ext x + change Matrix.mulVecLin (fun j i => (D j i : ℝ)) x = 0 ↔ + ∃ y, Matrix.mulVecLin (fun i k => (A i k : ℝ)) y = x + constructor + · intro hx + have hx' : D.mulVecLin.baseChange ℝ + ((TensorProduct.piScalarRight ℚ ℝ ℝ I).symm x) = 0 := by + apply (TensorProduct.piScalarRight ℚ ℝ ℝ J).injective + rw [rationalMatrix_piScalarRight_baseChange, map_zero, + LinearEquiv.apply_symm_apply] + exact hx + obtain ⟨z, hz⟩ := (hex _).mp hx' + refine ⟨TensorProduct.piScalarRight ℚ ℝ ℝ K z, ?_⟩ + rw [← rationalMatrix_piScalarRight_baseChange, hz, + LinearEquiv.apply_symm_apply] + · rintro ⟨y, rfl⟩ + have hz := hex.apply_apply_eq_zero + ((TensorProduct.piScalarRight ℚ ℝ ℝ K).symm y) + have he := congrArg (TensorProduct.piScalarRight ℚ ℝ ℝ J) hz + simpa only [rationalMatrix_piScalarRight_baseChange, + LinearEquiv.apply_symm_apply, map_zero] using he + +theorem rationalMatrix_real_ker_eq_span + (A : Matrix I K ℚ) (D : Matrix J I ℚ) + (h : LinearMap.ker D.mulVecLin = LinearMap.range A.mulVecLin) : + LinearMap.ker (Matrix.mulVecLin (fun j i => (D j i : ℝ))) = + Submodule.span ℝ (Set.range (fun k i => (A i k : ℝ))) := by + rw [rationalMatrix_real_ker_eq_range A D h] + exact Matrix.range_mulVecLin (fun i k => (A i k : ℝ) : Matrix I K ℝ) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem matrixDenominator_le_exp_power {ι κ : Type*} [Fintype ι] [Fintype κ] + (D : Matrix ι κ ℚ) {p : ℝ} (hp : 0 ≤ p) (a : ℕ) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hD : ∀ i j, ((D i j).den : ℝ) ≤ Real.exp ((p + 2) ^ a)) : + (matrixDenominator D : ℝ) ≤ Real.exp ((p + 2) ^ (a + 2)) := by + have hcard : (Fintype.card (ι × κ) : ℝ) ≤ (p + 2) ^ 2 := by + rw [Fintype.card_prod, Nat.cast_mul, pow_two] + exact mul_le_mul (hι.trans (by linarith)) (hκ.trans (by linarith)) + (Nat.cast_nonneg _) (by linarith) + simpa only [matrixDenominator, arrayDenominator, Nat.cast_prod] using + product_exponential_budget Finset.univ (fun ij : ι × κ => ((D ij.1 ij.2).den : ℝ)) + hp a 2 (fun _ _ => Nat.cast_nonneg _) (fun ij _ => hD ij.1 ij.2) hcard + +theorem matrix_weighted_factor_le_exp_power (n : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (a : ℕ) (ha : 1 ≤ a) : + ((n : ℝ) + 1) * (Real.exp ((p + 2) ^ a) + 1) ≤ Real.exp ((p + 2) ^ (a + 2)) := by + have hA : 1 ≤ (p + 2) ^ a := one_le_pow₀ (by linarith) + have hpA : p ≤ (p + 2) ^ a := le_power_budget hp ha + have hplus : Real.exp ((p + 2) ^ a) + 1 ≤ Real.exp ((p + 2) ^ a + 1) := by + calc + _ ≤ Real.exp ((p + 2) ^ a) * 2 := by + have h := Real.one_le_exp_iff.mpr (by positivity : 0 ≤ (p + 2) ^ a) + linarith + _ ≤ Real.exp ((p + 2) ^ a) * Real.exp 1 := + mul_le_mul_of_nonneg_left (by linarith [Real.add_one_le_exp (1 : ℝ)]) (Real.exp_nonneg _) + _ = _ := (Real.exp_add _ _).symm + calc + _ ≤ Real.exp p * Real.exp ((p + 2) ^ a + 1) := + mul_le_mul (by linarith [Real.add_one_le_exp p]) hplus (by positivity) (Real.exp_nonneg _) + _ = Real.exp (p + ((p + 2) ^ a + 1)) := (Real.exp_add _ _).symm + _ ≤ Real.exp ((p + 2) ^ (a + 2)) := by + apply Real.exp_le_exp.mpr + calc + _ ≤ 3 * (p + 2) ^ a := by linarith + _ ≤ (p + 2) ^ 2 * (p + 2) ^ a := + mul_le_mul_of_nonneg_right (by nlinarith) (by positivity) + _ = _ := by rw [pow_add]; ring + +theorem matrix_pair_denominator_le_exp_power {ι κ : Type*} [Fintype ι] [Fintype κ] + (D : Matrix κ ι ℚ) (S : Matrix ι κ ℚ) (l : ℕ) {p : ℝ} (hp : 0 ≤ p) + (a : ℕ) (ha : 1 ≤ a) (hι : (Fintype.card ι : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hD : ∀ i j, ((D i j).den : ℝ) ≤ Real.exp ((p + 2) ^ a)) + (hS : ∀ i j, ((S i j).den : ℝ) ≤ Real.exp ((p + 2) ^ a)) + (hl : (l : ℝ) ≤ Real.exp p) : + ((matrixDenominator D * matrixDenominator S * l : ℕ) : ℝ) ≤ + Real.exp ((p + 2) ^ (a + 4)) := by + have hDb := matrixDenominator_le_exp_power D hp a hκ hι hD + have hSb := matrixDenominator_le_exp_power S hp a hι hκ hS + have hlb := hl.trans (Real.exp_le_exp.mpr (le_power_budget hp (by omega : 1 ≤ a + 2))) + rw [Nat.cast_mul, Nat.cast_mul] + calc + _ ≤ Real.exp ((p + 2) ^ (a + 2)) * Real.exp ((p + 2) ^ (a + 2)) * + Real.exp ((p + 2) ^ (a + 2)) := + mul_le_mul (mul_le_mul hDb hSb (Nat.cast_nonneg _) (Real.exp_nonneg _)) hlb + (Nat.cast_nonneg _) (by positivity) + _ = Real.exp (3 * (p + 2) ^ (a + 2)) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ Real.exp ((p + 2) ^ (a + 4)) := by + apply Real.exp_le_exp.mpr + calc + _ ≤ (p + 2) ^ 2 * (p + 2) ^ (a + 2) := + mul_le_mul_of_nonneg_right (by nlinarith) (by positivity) + _ = _ := by rw [← pow_add]; congr 1; omega + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Matrix + +theorem rationalKernelSeparationConstant_ceil_le_exp_power + {ι κ : Type*} [Fintype ι] [Fintype κ] + (Q : Matrix ι κ ℚ) {H : ℕ} {p : ℝ} (hp : 0 ≤ p) + (a : ℕ) (ha : 1 ≤ a) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp ((p+2)^a)) + (hQ : ∀ i j, RationalHeightLE (Q i j) H) : + (⌈(matrixDenominator Q : ℝ) * + (((Fintype.card κ : ℝ)+1)*((H : ℝ)+1))⌉₊ : ℝ) ≤ + Real.exp ((p+2)^(a+4)) := by + let c : ℝ := (matrixDenominator Q : ℝ) * + (((Fintype.card κ : ℝ)+1)*((H : ℝ)+1)) + have hden := matrixDenominator_le_exp_power Q hp a hι hκ + (fun i j => (Nat.cast_le.mpr (hQ i j).2).trans hH) + have hfactor : ((Fintype.card κ : ℝ)+1)*((H : ℝ)+1) ≤ + Real.exp ((p+2)^(a+2)) := by + apply le_trans _ (matrix_weighted_factor_le_exp_power (Fintype.card κ) hp hκ a ha) + exact mul_le_mul_of_nonneg_left (by linarith only [hH]) (by positivity) + have hc : c ≤ Real.exp ((p+2)^(a+3)) := by + calc + _ ≤ Real.exp ((p+2)^(a+2)) * Real.exp ((p+2)^(a+2)) := + mul_le_mul hden hfactor (by positivity) (Real.exp_nonneg _) + _ = Real.exp (2*(p+2)^(a+2)) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + calc + _ ≤ (p+2)*(p+2)^(a+2) := + mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = _ := by rw [pow_succ]; ring + have hc0 : 0 ≤ c := by dsimp [c]; positivity + have hceil : (⌈c⌉₊ : ℝ) ≤ c+1 := (Nat.ceil_lt_add_one hc0).le + change (⌈c⌉₊ : ℝ) ≤ _ + calc + _ ≤ Real.exp ((p+2)^(a+3))+1 := hceil.trans (by linarith only [hc]) + _ ≤ Real.exp ((p+2)^(a+3)) * 2 := by + have hExp := Real.one_le_exp_iff.mpr (show 0 ≤ (p+2)^(a+3) by positivity) + linarith only [hExp] + _ ≤ Real.exp ((p+2)^(a+3)) * Real.exp 1 := + mul_le_mul_of_nonneg_left (by linarith [Real.add_one_le_exp (1:ℝ)]) (Real.exp_nonneg _) + _ = Real.exp ((p+2)^(a+3)+1) := (Real.exp_add _ _).symm + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hbase : 1 ≤ (p+2)^(a+3) := one_le_pow₀ (by linarith) + calc + _ ≤ 2*(p+2)^(a+3) := by linarith only [hbase] + _ ≤ (p+2)*(p+2)^(a+3) := + mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = _ := by rw [pow_succ]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct Matrix BigOperators + +variable {ι κ V : Type*} [Fintype ι] [Fintype κ] [AddCommGroup V] [Module ℚ V] + (b : Basis ι ℚ V) (e : Basis κ ℚ V) + +omit [Fintype κ] in +theorem real_basis_coordinates_transfer (x : ℝ ⊗[ℚ] V) : + (fun i => (e.baseChange ℝ).repr x i) = + (fun i j => (e.repr (b j) i : ℝ)) *ᵥ (fun j => (b.baseChange ℝ).repr x j) := by + classical + funext i + conv_lhs => rw [← (b.baseChange ℝ).sum_repr x] + simp only [map_sum, map_smul, Finsupp.coe_finsetSum, Finset.sum_apply, Finsupp.smul_apply, smul_eq_mul] + change (∑ j, (b.baseChange ℝ).repr x j * (e.baseChange ℝ).repr ((b.baseChange ℝ) j) i) = _ + have he (j : ι) : (e.baseChange ℝ).repr ((b.baseChange ℝ) j) i = (e.repr (b j) i : ℝ) := by + rw [Basis.baseChange_apply, Basis.baseChange_repr_tmul] + simp + simp only [he, Matrix.mulVec, dotProduct, mul_comm] + +omit [Fintype κ] in +theorem real_basis_coordinates_bound {H : ℕ} {B : ℝ} + (hentries : ∀ i j, RationalHeightLE (e.repr (b j) i) H) + (x : ℝ ⊗[ℚ] V) (hx : ∀ j, |(b.baseChange ℝ).repr x j| ≤ B) (i : κ) : + |(e.baseChange ℝ).repr x i| ≤ (Fintype.card ι : ℝ) * H * B := by + have hcoord := congrFun (real_basis_coordinates_transfer b e x) i + rw [hcoord] + calc + _ ≤ ∑ j, |(e.repr (b j) i : ℝ) * (b.baseChange ℝ).repr x j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : ι, (H : ℝ) * B := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul] + exact mul_le_mul (hentries i j).abs_real_le (hx j) (abs_nonneg _) (Nat.cast_nonneg H) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + +theorem real_basis_coordinates_grid (l : ℕ) (x : ℝ ⊗[ℚ] V) + (hx : (fun j => (b.baseChange ℝ).repr x j) ∈ realDenominatorGrid l) : + (fun i => (e.baseChange ℝ).repr x i) ∈ + realDenominatorGrid (matrixDenominator (fun i j => e.repr (b j) i) * l) := by + rw [real_basis_coordinates_transfer b e x] + exact real_matrix_denominator_grid (fun i j => e.repr (b j) i) l _ hx + +theorem real_basis_transfer_denominator {H : ℕ} {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) + (hentries : ∀ i j, RationalHeightLE (e.repr (b j) i) H) : + (matrixDenominator (fun i j => e.repr (b j) i) : ℝ) ≤ Real.exp ((p + 2) ^ 3) := by + apply matrixDenominator_le_exp_power (fun i j => e.repr (b j) i) hp 1 hκ hι + intro i j + exact (show ((e.repr (b j) i).den : ℝ) ≤ H by exact_mod_cast (hentries i j).2).trans + (hHp.trans (Real.exp_le_exp.mpr (by simp))) + +omit [Fintype κ] in +theorem real_basis_coordinates_exp_bound {H : ℕ} {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hHp : (H : ℝ) ≤ Real.exp p) + (hentries : ∀ i j, RationalHeightLE (e.repr (b j) i) H) + (x : ℝ ⊗[ℚ] V) (hx : ∀ j, |(b.baseChange ℝ).repr x j| ≤ Real.exp p) (i : κ) : + |(e.baseChange ℝ).repr x i| ≤ Real.exp ((p + 2) ^ 2) := by + have hdim : (Fintype.card ι : ℝ) ≤ Real.exp p := hι.trans (by linarith [Real.add_one_le_exp p]) + calc + _ ≤ (Fintype.card ι : ℝ) * H * Real.exp p := real_basis_coordinates_bound b e hentries x hx i + _ ≤ Real.exp p * Real.exp p * Real.exp p := + mul_le_mul_of_nonneg_right (mul_le_mul hdim hHp (Nat.cast_nonneg H) (Real.exp_nonneg p)) + (Real.exp_nonneg p) + _ = Real.exp (3 * p) := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith [sq_nonneg p]) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped Matrix + +theorem exists_rationalTaggedSpanProjection + {J : Type*} [Fintype J] {r : ℕ} (g : Fin r → J → ℚ) + {p : ℝ} (hp : 0 ≤ p) (hJ : (Fintype.card J : ℝ) ≤ p) + (hr : (r : ℝ) ≤ p) (hg : ∀ a j, rationalLogHeight (g a j) ≤ p) : + ∃ d : ℕ, d ≤ Fintype.card J ∧ + ∃ Q : (J → ℝ) →ₗ[ℝ] (Fin d → ℝ), + LinearMap.ker Q = Submodule.span ℝ (Set.range (fun a j => (g a j : ℝ))) ∧ + (∀ x i, |Q x i| ≤ Real.exp ((p + 2) ^ 9) * ‖x‖) ∧ + ∃ D : ℕ, 0 < D ∧ (D : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + ∀ x : J → ℤ, ∃ z : Fin d → ℤ, + ∀ i, (z i : ℝ) = (D : ℝ) * Q (fun j => (x j : ℝ)) i := by + classical + have hheight : ∀ j a, RationalHeightLE (g a j) ⌊Real.exp p⌋₊ := by + intro j a + obtain ⟨hn, hd⟩ := (rationalLogHeight_le_iff (g a j) p).mp (hg a j) + exact ⟨Nat.le_floor hn, Nat.le_floor hd⟩ + obtain ⟨d, hd, M, S, hker, hMS, hM, hS⟩ := + exists_quotient_presentation_exp_height (fun j a => g a j) + ((Nat.one_le_floor_iff _).mpr (Real.one_le_exp_iff.mpr hp)) hheight + hp hJ (by simpa using hr) (Nat.floor_le (Real.exp_nonneg p)) + have hdp : (Fintype.card (Fin d) : ℝ) ≤ p := by + simpa using (Nat.cast_le.mpr hd).trans hJ + let Q : (J → ℝ) →ₗ[ℝ] (Fin d → ℝ) := + Matrix.mulVecLin (fun i j => (M i j : ℝ)) + have hentry : ∀ i j, |(M i j : ℝ)| ≤ Real.exp ((p + 2) ^ 7) := + fun i j => (rational_abs_real_le_numerator (M i j)).trans (hM i j).1 + have hbound : ∀ x i, |Q x i| ≤ Real.exp ((p + 2) ^ 9) * ‖x‖ := by + intro x i + have hb := abs_matrix_mulVec_le (fun i j => (M i j : ℝ)) + ⟨Real.exp ((p + 2) ^ 7), Real.exp_nonneg _⟩ hentry x i + exact hb.trans (mul_le_mul_of_nonneg_right + (matrix_weighted_factor_le_exp_power (Fintype.card J) hp hJ 7 (by decide)) + (norm_nonneg x)) + refine ⟨d, hd, Q, ?_, hbound, matrixDenominator M, matrixDenominator_pos M, + matrixDenominator_le_exp_power M hp 7 hdp hJ (fun i j => (hM i j).2), ?_⟩ + · exact rationalMatrix_real_ker_eq_span (fun j a => g a j) M hker + · intro x + have hx : (fun j => (x j : ℝ)) ∈ realDenominatorGrid 1 := + ⟨x, by ext j; simp⟩ + obtain ⟨z, hz⟩ := real_matrix_denominator_grid M 1 (fun j => (x j : ℝ)) hx + refine ⟨z, fun i => ?_⟩ + change (z i : ℝ) = (matrixDenominator M : ℝ) * + ((fun i j => (M i j : ℝ)) *ᵥ (fun j => (x j : ℝ))) i + simpa only [mul_one, Pi.smul_apply, smul_eq_mul] using congrFun hz i + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealCoefficientKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealCoefficientKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6d90d163a394770d47e3e7562846a919828cd9e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealCoefficientKernel.lean @@ -0,0 +1,150 @@ +import OAI.Combinatorics.Progressions.Estimates.FreeCorrelationRelationRefinement + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem coefficientFourSpace_eq_sup (d : Fin (s + 1)) : + D.coefficientFourSpace d = D.spaces d ⊔ + Submodule.pi Set.univ (fun _ : Fin 4 => W.rank.filtration.layer d.val 2) := by + let F := W.rank.filtration + ext v + constructor + · rintro ⟨w, hw, rfl⟩ + change F.fourHorizontalMap d.val w ∈ F.horizontalImageOfSubmodule (D.spaces d) d.val at hw + obtain ⟨z, hz, he⟩ := hw + apply Submodule.mem_sup.mpr + refine ⟨z.val, hz, w.val - z.val, ?_, by abel⟩ + apply Submodule.mem_pi.mpr + intro k _ + exact (F.higherHorizontalMk_eq d.val _ _).mp (congrFun he.symm k) + · intro hv + obtain ⟨x, hx, y, hy, rfl⟩ := Submodule.mem_sup.mp hv + have hx' := D.spaces_le_fourHorizontalLayer d hx + have hy' : y ∈ F.fourHorizontalLayer d.val := by + apply (F.mem_fourHorizontalLayer d.val y).mpr + intro k + exact F.lex_antitone (Or.inr ⟨rfl, by omega⟩) ((Submodule.mem_pi.mp hy) k (Set.mem_univ k)) + let z : F.fourHorizontalLayer d.val := ⟨x, hx'⟩ + let w : F.fourHorizontalLayer d.val := ⟨x + y, (F.fourHorizontalLayer d.val).add_mem hx' hy'⟩ + apply (D.mem_coefficientFourSpace d w).mpr + change F.fourHorizontalMap d.val w ∈ F.horizontalImageOfSubmodule (D.spaces d) d.val + refine ⟨z, hx, ?_⟩ + funext k + apply (F.higherHorizontalMk_eq d.val _ _).mpr + change x k - (x k + y k) ∈ F.layer d.val 2 + simpa only [sub_add_cancel_left] using + (F.layer d.val 2).neg_mem ((Submodule.mem_pi.mp hy) k (Set.mem_univ k)) + +theorem spaces_le_coefficientFourSpace (d : Fin (s + 1)) : + D.spaces d ≤ D.coefficientFourSpace d := by + rw [D.coefficientFourSpace_eq_sup] + exact le_sup_left + +theorem fourKernel_le_coefficientFourSpace (d : Fin (s + 1)) : + Submodule.pi Set.univ (fun _ : Fin 4 => W.rank.filtration.layer d.val 2) ≤ + D.coefficientFourSpace d := by + rw [D.coefficientFourSpace_eq_sup] + exact le_sup_right + +theorem coefficientFourSpace_add_kernel_iff (d : Fin (s + 1)) + (v z : Fin 4 → W.L) (hz : ∀ k, z k ∈ W.rank.filtration.layer d.val 2) : + v + z ∈ D.coefficientFourSpace d ↔ v ∈ D.coefficientFourSpace d := by + have hz' := D.fourKernel_le_coefficientFourSpace d + (Submodule.mem_pi.mpr (fun k _ => hz k)) + exact Submodule.add_mem_iff_left _ hz' + +end Erdos3.NativeRankRelation.CommonData + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module VectorPolynomial +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P : ℝ} + {W : NativeDegreeRankFamily s r (ZMod N) b} {out : Fin W.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W out H p q} (D : R.CommonData P) + +theorem real_fourKernel_le_coefficientFourSpace (d : Fin (s + 1)) + (v : Fin 4 → ℝ ⊗[ℚ] W.L) + (hv : ∀ k, v k ∈ (W.rank.filtration.layer d.val 2).baseChange ℝ) : + v ∈ D.realCoefficientFourSpace d := by + let e := TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => W.L) + have hbase : e.symm v ∈ + (Submodule.pi Set.univ (fun _ : Fin 4 => W.rank.filtration.layer d.val 2)).baseChange ℝ := by + apply (mem_realified_four_product_iff _ _).mpr + intro k + change e (e.symm v) k ∈ _ + rw [e.apply_symm_apply] + exact hv k + exact ⟨e.symm v, Submodule.baseChange_mono ℝ (D.fourKernel_le_coefficientFourSpace d) hbase, + e.apply_symm_apply v⟩ + +theorem realCoefficientFourSpace_add_kernel_iff (d : Fin (s + 1)) + (v z : Fin 4 → ℝ ⊗[ℚ] W.L) + (hz : ∀ k, z k ∈ (W.rank.filtration.layer d.val 2).baseChange ℝ) : + v + z ∈ D.realCoefficientFourSpace d ↔ v ∈ D.realCoefficientFourSpace d := + Submodule.add_mem_iff_left _ (D.real_fourKernel_le_coefficientFourSpace d z hz) + +theorem realCoefficientFourSpace_congr_mod_kernel (d : Fin (s + 1)) + (v z : Fin 4 → ℝ ⊗[ℚ] W.L) + (hz : ∀ k, v k - z k ∈ (W.rank.filtration.layer d.val 2).baseChange ℝ) : + v ∈ D.realCoefficientFourSpace d ↔ z ∈ D.realCoefficientFourSpace d := by + have h := D.real_fourKernel_le_coefficientFourSpace d (v - z) hz + constructor + · intro hv + simpa only [sub_sub_cancel] using (D.realCoefficientFourSpace d).sub_mem hv h + · intro hz + simpa only [sub_add_cancel] using (D.realCoefficientFourSpace d).add_mem h hz + +theorem realCoefficientFourSpace_log_product_correction_iff + {κ : Type*} (hs : 1 ≤ s) (c : Basis κ ℚ W.L) (τ : κ → ℕ) + (hG : ∀ j, W.rank.filtration.associatedDegree.layer j = + Submodule.span ℚ (c '' {i | j ≤ τ i})) + (d : Fin (s + 1)) (α : Unit →₀ ℕ) (hα : Finsupp.weight (fun _ : Unit => 1) α = d.val) + (g h : Fin 4 → W.rank.filtration.associatedDegree.realification.PolynomialOrbit + (fun _ : Unit => 1)) (E Q : Fin 4 → ℝ ⊗[ℚ] W.L) : + (fun k => coefficients ((g k) * (h k)).log α) - E - Q ∈ D.realCoefficientFourSpace d ↔ + (fun k => coefficients (g k).log α + coefficients (h k).log α) - E - Q ∈ + D.realCoefficientFourSpace d := by + apply D.realCoefficientFourSpace_congr_mod_kernel d + intro k + change (coefficients ((g k) * (h k)).log α - E k - Q k) - + (coefficients (g k).log α + coefficients (h k).log α - E k - Q k) ∈ _ + have heq : (coefficients ((g k) * (h k)).log α - E k - Q k) - + (coefficients (g k).log α + coefficients (h k).log α - E k - Q k) = + coefficients ((g k) * (h k)).log α - + (coefficients (g k).log α + coefficients (h k).log α) := by abel + rw [heq] + simpa only [hα] using W.rank.filtration.polynomialOrbit_log_mul_mod_rank_two hs c τ hG + (fun _ : Unit => 1) α (g k) (h k) + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealComparisonCoefficientProjections.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealComparisonCoefficientProjections.lean new file mode 100644 index 0000000000000000000000000000000000000000..65ff341db26386a6649f8cad7c893c565045eb36 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealComparisonCoefficientProjections.lean @@ -0,0 +1,37 @@ +import OAI.Combinatorics.Progressions.Estimates.ComparisonAmbient + +namespace OAI + +section + +namespace Erdos3.MultidegreeLieFiltration + +open VectorPolynomial + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) (π : ι → σ) + +theorem realComparisonCoefficient_first (p : F.realification.adaptedLieSubalgebra) + (hp : coefficients p.val 0 = 0) (a : σ →₀ ℕ) : + realificationLieHom (F.comparisonFirst π) (F.realComparisonCoefficient π p a) = + coefficients p.val a := by + by_cases ha : a = 0 + · subst a + rw [F.realComparisonCoefficient_zero_index, map_zero, hp] + · rw [realComparisonCoefficient, dite_eq_right ha, F.realComparisonGraphLift_first] + +theorem realComparisonCoefficient_second (p : F.realification.adaptedLieSubalgebra) + (hp : coefficients p.val 0 = 0) (a : σ →₀ ℕ) : + F.realSquarefreeInclusion π + (realificationLieHom (F.comparisonSecond π) (F.realComparisonCoefficient π p a)) = + (factorialBlockMonomial π (fun i => a i)).baseChange ℝ (coefficients p.val a) := by + by_cases ha : a = 0 + · subst a + rw [F.realComparisonCoefficient_zero_index, map_zero, map_zero, hp, map_zero] + · rw [realComparisonCoefficient, dite_eq_right ha, F.realComparisonGraphLift_second] + +end Erdos3.MultidegreeLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealCoordinateImageSpan.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealCoordinateImageSpan.lean new file mode 100644 index 0000000000000000000000000000000000000000..15c14cbd4d4660766089a2d1ff27e68618aff245 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealCoordinateImageSpan.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.Progressions.Geometry.RealCoordinateFunctionals + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {V J B : Type*} [AddCommGroup V] [Module ℚ V] + +theorem coordinateImage_eq_span (U : Submodule ℚ V) (g : J → V) + (hg : Submodule.span ℚ (Set.range g) = U) (ℓ : V →ₗ[ℚ] (B → ℚ)) : + U.map ℓ = Submodule.span ℚ (Set.range (fun j => ℓ (g j))) := by + rw [← hg, Submodule.map_span, ← Set.range_comp] + rfl + +theorem realifyCoordinateMap_image_eq_span (U : Submodule ℚ V) (g : J → V) + (hg : Submodule.span ℚ (Set.range g) = U) (ℓ : V →ₗ[ℚ] (B → ℚ)) : + (U.baseChange ℝ).map (realifyCoordinateMap ℓ) = + Submodule.span ℝ (Set.range (fun j i => (ℓ (g j) i : ℝ))) := by + rw [← hg, Submodule.baseChange_span, Submodule.map_span, Set.image_image, ← Set.range_comp] + apply congrArg (Submodule.span ℝ) + apply congrArg Set.range + funext j i + exact (realifyCoordinateMap_tmul ℓ 1 (g j) i).trans (one_mul _) + +theorem realifyCoordinateMap_mem_span (U : Submodule ℚ V) (g : J → V) + (hg : Submodule.span ℚ (Set.range g) = U) (ℓ : V →ₗ[ℚ] (B → ℚ)) + {x : ℝ ⊗[ℚ] V} (hx : x ∈ U.baseChange ℝ) : + realifyCoordinateMap ℓ x ∈ + Submodule.span ℝ (Set.range (fun j i => (ℓ (g j) i : ℝ))) := by + rw [← realifyCoordinateMap_image_eq_span U g hg ℓ] + exact ⟨x, hx, rfl⟩ + +theorem mem_coordinateColumn_span_iff (U : Submodule ℚ V) (g : J → V) + (hg : Submodule.span ℚ (Set.range g) = U) (ℓ : V →ₗ[ℚ] (B → ℚ)) (y : B → ℝ) : + y ∈ Submodule.span ℝ (Set.range (fun j i => (ℓ (g j) i : ℝ))) ↔ + ∃ x ∈ U.baseChange ℝ, realifyCoordinateMap ℓ x = y := by + rw [← realifyCoordinateMap_image_eq_span U g hg ℓ] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealDualRationalBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealDualRationalBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..436cb4fcedea5f1938016310ac9a8c7c66d9f647 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealDualRationalBounds.lean @@ -0,0 +1,423 @@ +import Mathlib.LinearAlgebra.Basis.Prod +import OAI.Combinatorics.Progressions.Linear.DualIdealSteps +import OAI.Combinatorics.Progressions.Nilpotent.RationalBCHProducts + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + +noncomputable def realDualBasis (b : Basis ι ℝ L) : Basis (ι ⊕ ι) ℝ (DualLieAlgebra L) := + (b.prod b).map dualRealCoordinates.symm + +@[simp] theorem realDualBasis_inl (b : Basis ι ℝ L) (i : ι) : + realDualBasis b (Sum.inl i) = dualConstantLie (b i) := by + simp [realDualBasis, Basis.map_apply] + +@[simp] theorem realDualBasis_inr (b : Basis ι ℝ L) (i : ι) : + realDualBasis b (Sum.inr i) = dualInfinitesimal (b i) := by + simp [realDualBasis, Basis.map_apply] + +@[simp] theorem realDualBasis_repr_inl (b : Basis ι ℝ L) (x : DualLieAlgebra L) (i : ι) : + (realDualBasis b).repr x (Sum.inl i) = b.repr (dualBaseLinear x) i := by + simp [realDualBasis, Basis.map_repr] + +@[simp] theorem realDualBasis_repr_inr (b : Basis ι ℝ L) (x : DualLieAlgebra L) (i : ι) : + (realDualBasis b).repr x (Sum.inr i) = b.repr (dualTangentLinear x) i := by + simp [realDualBasis, Basis.map_repr] + +def dualStructureConstants (c : ι → ι → ι → ℚ) : (ι ⊕ ι) → (ι ⊕ ι) → (ι ⊕ ι) → ℚ + | Sum.inl i, Sum.inl j, Sum.inl k => c i j k + | Sum.inl i, Sum.inr j, Sum.inr k => c i j k + | Sum.inr i, Sum.inl j, Sum.inr k => c i j k + | _, _, _ => 0 + +theorem realDualBasis_structure (b : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hc : ∀ i j k, algebraMap ℚ ℝ (c i j k) = b.repr ⁅b i, b j⁆ k) + (i j k : ι ⊕ ι) : + algebraMap ℚ ℝ (dualStructureConstants c i j k) = + (realDualBasis b).repr ⁅realDualBasis b i, realDualBasis b j⁆ k := by + cases i <;> cases j <;> cases k <;> + simp [dualStructureConstants, dualBaseLinear_lie, dualTangentLinear_lie, ← hc] + +theorem dualStructureConstants_height (c : ι → ι → ι → ℚ) {H : ℕ} (hH : 1 ≤ H) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) (i j k : ι ⊕ ι) : + RationalHeightLE (dualStructureConstants c i j k) H := by + cases i <;> cases j <;> cases k <;> + first | exact hc _ _ _ | exact rationalHeightLE_zero hH + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup + +private theorem dual_basis_bound {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] (e : Basis ι ℝ L) + (z : DualLieAlgebra L) (M : ℝ) + (hb : ∀ i, |e.repr (dualBaseLinear z) i| ≤ M) + (ht : ∀ i, |e.repr (dualTangentLinear z) i| ≤ M) : + ∀ i, |(realDualBasis e).repr z i| ≤ M := by + intro i + cases i with + | inl i => simpa only [realDualBasis_repr_inl] using hb i + | inr i => simpa only [realDualBasis_repr_inr] using ht i + +theorem exists_dual_coordinate_operation_bound (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] + [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + 1 ≤ H → 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + (∀ z : DualGroup hnil, + (∀ i, |e.repr (dualBaseLinear z.coord) i| ≤ Real.exp ((p + 2) ^ a)) → + (∀ i, |e.repr (dualTangentLinear z.coord) i| ≤ Real.exp ((p + 2) ^ a)) → + ∀ i, |e.repr (dualLogDerivative z) i| ≤ Real.exp ((p + C) ^ C)) ∧ + (∀ (g : NilpotentLieBCHGroup L s hnil) (x : L), + (∀ i, |e.repr g.coord i| ≤ Real.exp ((p + 2) ^ a)) → + (∀ i, |e.repr x i| ≤ Real.exp ((p + 2) ^ a)) → + ∀ i, |e.repr (dualAdjoint g x) i| ≤ Real.exp ((p + C) ^ C)) := by + have hproductExists := exists_bch_fixed_product_exp_bound s a 3 + obtain ⟨K, _, hproduct⟩ := hproductExists + let B : Polynomial ℕ := (2 * Polynomial.X + Polynomial.C K) ^ K + have hboundExists := exists_natPolynomial_eval_budget B + obtain ⟨C, hC, hbound⟩ := hboundExists + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ _ _ e c H p hnil hstructure hH hp hd hHp hc + have hfinal : (2 * p + K) ^ K ≤ (p + C) ^ C := by + simpa [B, Polynomial.eval₂_pow] using hbound p hp + have hinput : Real.exp ((p + 2) ^ a) ≤ Real.exp ((2 * p + 2) ^ a) := + Real.exp_le_exp.mpr (pow_le_pow_left₀ (by positivity) (by linarith) a) + have hdim : (Fintype.card (ι ⊕ ι) : ℝ) ≤ 2 * p := by + rw [Fintype.card_sum, Nat.cast_add] + linarith + have hproducts (rs : List (DualGroup hnil)) (hlen : rs.length ≤ 3) + (hrs : ∀ r ∈ rs, ∀ i, + |(realDualBasis e).repr r.coord i| ≤ Real.exp ((p + 2) ^ a)) : + ∀ i, |(realDualBasis e).repr rs.prod.coord i| ≤ Real.exp ((p + C) ^ C) := by + have hb := hproduct (realDualBasis e) (dualStructureConstants c) H (2 * p) + (dualLie_lowerCentralSeries_eq_bot hnil) rs (realDualBasis_structure e c hstructure) + (by positivity) hdim hlen (hHp.trans (Real.exp_le_exp.mpr (by linarith))) + (dualStructureConstants_height c hH hc) (fun r hr i => (hrs r hr i).trans hinput) + exact fun i => (hb i).trans (Real.exp_le_exp.mpr hfinal) + constructor + · intro z hbase htangent i + have hconst : ∀ j, |(realDualBasis e).repr + ((dualConstantHom (dualBaseHom z))⁻¹).coord j| ≤ Real.exp ((p + 2) ^ a) := by + apply dual_basis_bound + · intro j + change |e.repr (dualBaseLinear (-dualConstantLie (dualBaseLinear z.coord))) j| ≤ _ + simpa only [map_neg, dualBaseLinear_constant, Finsupp.neg_apply, abs_neg] using hbase j + · intro j + change |e.repr (dualTangentLinear (-dualConstantLie (dualBaseLinear z.coord))) j| ≤ _ + simp only [map_neg, dualTangentLinear_constant, neg_zero, map_zero, Finsupp.zero_apply, abs_zero] + exact Real.exp_nonneg _ + have hinputs : ∀ r ∈ [z, (dualConstantHom (dualBaseHom z))⁻¹], + ∀ j, |(realDualBasis e).repr r.coord j| ≤ Real.exp ((p + 2) ^ a) := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact dual_basis_bound e _ _ hbase htangent + · exact hconst + have hh := hproducts [z, (dualConstantHom (dualBaseHom z))⁻¹] (by simp) hinputs (Sum.inr i) + simpa only [List.prod_cons, List.prod_nil, mul_one, realDualBasis_repr_inr, dualLogDerivative] using hh + · intro g x hg hx i + have hleft : ∀ j, |(realDualBasis e).repr (dualConstantHom g).coord j| ≤ + Real.exp ((p + 2) ^ a) := by + apply dual_basis_bound + · intro j + change |e.repr (dualBaseLinear (dualConstantLie g.coord)) j| ≤ _ + simpa only [dualBaseLinear_constant] using hg j + · intro j + change |e.repr (dualTangentLinear (dualConstantLie g.coord)) j| ≤ _ + simp only [dualTangentLinear_constant, map_zero, Finsupp.zero_apply, abs_zero] + exact Real.exp_nonneg _ + have hmiddle : ∀ j, |(realDualBasis e).repr (dualTangentElement (hnil := hnil) x).coord j| ≤ + Real.exp ((p + 2) ^ a) := by + apply dual_basis_bound + · intro j + change |e.repr (dualBaseLinear (dualInfinitesimal x)) j| ≤ _ + simp only [dualBaseLinear_infinitesimal, map_zero, Finsupp.zero_apply, abs_zero] + exact Real.exp_nonneg _ + · intro j + change |e.repr (dualTangentLinear (dualInfinitesimal x)) j| ≤ _ + simpa only [dualTangentLinear_infinitesimal] using hx j + have hright : ∀ j, |(realDualBasis e).repr ((dualConstantHom g)⁻¹).coord j| ≤ + Real.exp ((p + 2) ^ a) := by + intro j + simpa only [coord_inv, map_neg, Finsupp.neg_apply, abs_neg] using hleft j + have hinputs : ∀ r ∈ [dualConstantHom g, dualTangentElement x, (dualConstantHom g)⁻¹], + ∀ j, |(realDualBasis e).repr r.coord j| ≤ Real.exp ((p + 2) ^ a) := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hleft + · exact hmiddle + · exact hright + have hh := hproducts [dualConstantHom g, dualTangentElement x, (dualConstantHom g)⁻¹] + (by simp) hinputs (Sum.inr i) + simpa only [List.prod_cons, List.prod_nil, mul_one, ← mul_assoc, realDualBasis_repr_inr, dualAdjoint] using hh + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def rationalDualBasis (b : Basis ι ℚ L) : Basis (ι ⊕ ι) ℚ (DualLieAlgebra L) := + (b.prod b).map dualCoordinates.symm + +@[simp] theorem rationalDualBasis_inl (b : Basis ι ℚ L) (i : ι) : + rationalDualBasis b (Sum.inl i) = dualConstantLie (b i) := by + simp [rationalDualBasis, Basis.map_apply] + +@[simp] theorem rationalDualBasis_inr (b : Basis ι ℚ L) (i : ι) : + rationalDualBasis b (Sum.inr i) = dualInfinitesimal (b i) := by + simp [rationalDualBasis, Basis.map_apply] + +@[simp] theorem rationalDualBasis_repr_inl (b : Basis ι ℚ L) (x : DualLieAlgebra L) (i : ι) : + (rationalDualBasis b).repr x (Sum.inl i) = b.repr (dualBaseLinear x) i := by + simp [rationalDualBasis, Basis.map_repr] + +@[simp] theorem rationalDualBasis_repr_inr (b : Basis ι ℚ L) (x : DualLieAlgebra L) (i : ι) : + (rationalDualBasis b).repr x (Sum.inr i) = b.repr (dualTangentLinear x) i := by + simp [rationalDualBasis, Basis.map_repr] + +theorem rationalDualBasis_structure (b : Basis ι ℚ L) (i j k : ι ⊕ ι) : + lieStructureConstants (L := DualLieAlgebra L) (rationalDualBasis b) i j k = + dualStructureConstants (lieStructureConstants b) i j k := by + cases i <;> cases j <;> cases k <;> + simp [lieStructureConstants, dualStructureConstants, dualBaseLinear_lie, dualTangentLinear_lie] + +theorem rationalDualBasis_structure_height (b : Basis ι ℚ L) {H : ℕ} (hH : 1 ≤ H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) (i j k : ι ⊕ ι) : + RationalHeightLE (lieStructureConstants (L := DualLieAlgebra L) (rationalDualBasis b) i j k) H := by + rw [rationalDualBasis_structure] + exact dualStructureConstants_height _ hH hc i j k + +theorem rationalDualBasis_grid_iff [Fintype ι] (b : Basis ι ℚ L) (l : ℕ) (x : DualLieAlgebra L) : + (rationalDualBasis b).equivFun x ∈ denominatorGrid l ↔ + b.equivFun (dualBaseLinear x) ∈ denominatorGrid l ∧ + b.equivFun (dualTangentLinear x) ∈ denominatorGrid l := by + constructor + · rintro ⟨a, ha⟩ + constructor + · exact ⟨fun i => a (Sum.inl i), fun i => by + simpa only [Basis.equivFun_apply, Pi.smul_apply, rationalDualBasis_repr_inl] using ha (Sum.inl i)⟩ + · exact ⟨fun i => a (Sum.inr i), fun i => by + simpa only [Basis.equivFun_apply, Pi.smul_apply, rationalDualBasis_repr_inr] using ha (Sum.inr i)⟩ + · rintro ⟨⟨a, ha⟩, ⟨b', hb'⟩⟩ + refine ⟨Sum.elim a b', ?_⟩ + intro i + cases i with + | inl i => simpa only [Sum.elim_inl, Basis.equivFun_apply, Pi.smul_apply, rationalDualBasis_repr_inl] using ha i + | inr i => simpa only [Sum.elim_inr, Basis.equivFun_apply, Pi.smul_apply, rationalDualBasis_repr_inr] using hb' i + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup + +theorem exists_rational_dual_operation_grid (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + 1 ≤ H → 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + (∀ z : DualGroup hnil, + e.equivFun (dualBaseLinear z.coord) ∈ denominatorGrid l → + e.equivFun (dualTangentLinear z.coord) ∈ denominatorGrid l → + e.equivFun (dualLogDerivative z) ∈ denominatorGrid m) ∧ + (∀ (g : NilpotentLieBCHGroup L s hnil) (x : L), + e.equivFun g.coord ∈ denominatorGrid l → e.equivFun x ∈ denominatorGrid l → + e.equivFun (dualAdjoint g x) ∈ denominatorGrid m) := by + have hproductsExists := exists_bch_rational_product_bound s 3 + obtain ⟨D, _, hproducts⟩ := hproductsExists + let B : Polynomial ℕ := (2 * Polynomial.X + Polynomial.C D) ^ D + have hboundExists := exists_natPolynomial_eval_budget B + obtain ⟨C, hC, hbound⟩ := hboundExists + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ e H p hnil hH hp hd hHp hc l hl hlp + have hp2 : p ≤ 2 * p := by linarith + have hdim : (Fintype.card (ι ⊕ ι) : ℝ) ≤ 2 * p := by + rw [Fintype.card_sum, Nat.cast_add] + linarith + have hdata := hproducts (rationalDualBasis e) H (2 * p) (dualLie_lowerCentralSeries_eq_bot hnil) + (by positivity) hdim (hHp.trans (Real.exp_le_exp.mpr hp2)) + (rationalDualBasis_structure_height e hH hc) l hl (hlp.trans (Real.exp_le_exp.mpr hp2)) + obtain ⟨m, hm, hmp, hlm, hprod⟩ := hdata + have hfinal : (2 * p + D) ^ D ≤ (p + C) ^ C := by + simpa [B, Polynomial.eval₂_pow] using hbound p hp + have hzero : (0 : ι → ℚ) ∈ denominatorGrid l := ⟨0, by intro i; simp⟩ + refine ⟨m, hm, hmp.trans (Real.exp_le_exp.mpr hfinal), hlm, ?_, ?_⟩ + · intro z hb ht + have hz := (rationalDualBasis_grid_iff e l z.coord).mpr ⟨hb, ht⟩ + have hconst : (rationalDualBasis e).equivFun (dualConstantHom (dualBaseHom z)).coord ∈ + denominatorGrid l := by + apply (rationalDualBasis_grid_iff e l _).mpr + change e.equivFun (dualBaseLinear (dualConstantLie (dualBaseLinear z.coord))) ∈ _ ∧ + e.equivFun (dualTangentLinear (dualConstantLie (dualBaseLinear z.coord))) ∈ _ + simpa only [dualBaseLinear_constant, dualTangentLinear_constant, map_zero] using And.intro hb hzero + have hinv : (rationalDualBasis e).equivFun ((dualConstantHom (dualBaseHom z))⁻¹).coord ∈ + denominatorGrid l := by + simpa only [coord_inv, map_neg] using denominatorGrid_neg l hconst + have hinputs : ∀ r ∈ [z, (dualConstantHom (dualBaseHom z))⁻¹], + (rationalDualBasis e).equivFun r.coord ∈ denominatorGrid l := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl + · exact hz + · exact hinv + have hout := (rationalDualBasis_grid_iff e m _).mp + (hprod [z, (dualConstantHom (dualBaseHom z))⁻¹] (by simp) hinputs) + simpa only [List.prod_cons, List.prod_nil, mul_one, dualLogDerivative] using hout.2 + · intro g x hg hx + have hleft : (rationalDualBasis e).equivFun (dualConstantHom g).coord ∈ denominatorGrid l := by + apply (rationalDualBasis_grid_iff e l _).mpr + change e.equivFun (dualBaseLinear (dualConstantLie g.coord)) ∈ _ ∧ + e.equivFun (dualTangentLinear (dualConstantLie g.coord)) ∈ _ + simpa only [dualBaseLinear_constant, dualTangentLinear_constant, map_zero] using And.intro hg hzero + have hmiddle : (rationalDualBasis e).equivFun (dualTangentElement (hnil := hnil) x).coord ∈ + denominatorGrid l := by + apply (rationalDualBasis_grid_iff e l _).mpr + change e.equivFun (dualBaseLinear (dualInfinitesimal x)) ∈ _ ∧ + e.equivFun (dualTangentLinear (dualInfinitesimal x)) ∈ _ + simpa only [dualBaseLinear_infinitesimal, dualTangentLinear_infinitesimal, map_zero] using And.intro hzero hx + have hright : (rationalDualBasis e).equivFun ((dualConstantHom g)⁻¹).coord ∈ denominatorGrid l := by + simpa only [coord_inv, map_neg] using denominatorGrid_neg l hleft + have hinputs : ∀ r ∈ [dualConstantHom g, dualTangentElement x, (dualConstantHom g)⁻¹], + (rationalDualBasis e).equivFun r.coord ∈ denominatorGrid l := by + intro r hr + simp only [List.mem_cons, List.not_mem_nil, or_false] at hr + rcases hr with rfl | rfl | rfl + · exact hleft + · exact hmiddle + · exact hright + have hout := (rationalDualBasis_grid_iff e m _).mp + (hprod [dualConstantHom g, dualTangentElement x, (dualConstantHom g)⁻¹] (by simp) hinputs) + simpa only [List.prod_cons, List.prod_nil, mul_one, ← mul_assoc, dualAdjoint] using hout.2 + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem real_dual_log_grid_of_rational (e : Basis ι ℚ L) (l m : ℕ) (hl : 0 < l) + (hlog : ∀ z : DualGroup hnil, + e.equivFun (dualBaseLinear z.coord) ∈ denominatorGrid l → + e.equivFun (dualTangentLinear z.coord) ∈ denominatorGrid l → + e.equivFun (dualLogDerivative z) ∈ denominatorGrid m) + (z : DualGroup (realification_lowerCentralSeries_eq_bot hnil)) + (hb : (e.baseChange ℝ).equivFun (dualBaseLinear z.coord) ∈ realDenominatorGrid l) + (ht : (e.baseChange ℝ).equivFun (dualTangentLinear z.coord) ∈ realDenominatorGrid l) : + (e.baseChange ℝ).equivFun (dualLogDerivative z) ∈ realDenominatorGrid m := by + obtain ⟨a, ha, hea⟩ := real_grid_exists_rationalLieInclusion e l hl _ hb + obtain ⟨b, hb, heb⟩ := real_grid_exists_rationalLieInclusion e l hl _ ht + let q : DualGroup hnil := ⟨dualConstantLie a + dualInfinitesimal b⟩ + have hqa : dualBaseLinear q.coord = a := by + change dualBaseLinear (dualConstantLie a + dualInfinitesimal b) = a + simp only [map_add, dualBaseLinear_constant, dualBaseLinear_infinitesimal, add_zero] + have hqb : dualTangentLinear q.coord = b := by + change dualTangentLinear (dualConstantLie a + dualInfinitesimal b) = b + simp only [map_add, dualTangentLinear_constant, dualTangentLinear_infinitesimal, zero_add] + have hq := hlog q (by rwa [hqa]) (by rwa [hqb]) + have he : rationalLieInclusion (dualLogDerivative q) = dualLogDerivative z := by + apply dualLinearLift_logDerivative_eq (realification_lowerCentralSeries_eq_bot hnil) + (⊤ : LieIdeal ℚ L) rationalLieInclusion rationalLieInclusion.toLinearMap + (fun x y _ => rationalLieInclusion.map_lie x y) q (by trivial) z + apply dual_ext + · rw [dualLinearLift_base, hqa] + exact hea + · rw [dualLinearLift_tangent, hqb] + exact heb + change (fun i => (e.baseChange ℝ).repr (dualLogDerivative z) i) ∈ realDenominatorGrid m + rw [← he] + simp_rw [rationalLieInclusion_coordinates] + exact (real_cast_mem_denominatorGrid_iff m _).mpr hq + +theorem real_dual_adjoint_grid_of_rational (e : Basis ι ℚ L) (l m : ℕ) (hl : 0 < l) + (had : ∀ (g : NilpotentLieBCHGroup L s hnil) (x : L), + e.equivFun g.coord ∈ denominatorGrid l → e.equivFun x ∈ denominatorGrid l → + e.equivFun (dualAdjoint g x) ∈ denominatorGrid m) + (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) + (x : ℝ ⊗[ℚ] L) + (hg : (e.baseChange ℝ).equivFun g.coord ∈ realDenominatorGrid l) + (hx : (e.baseChange ℝ).equivFun x ∈ realDenominatorGrid l) : + (e.baseChange ℝ).equivFun (dualAdjoint g x) ∈ realDenominatorGrid m := by + obtain ⟨a, ha, hea⟩ := real_grid_exists_rationalLieInclusion e l hl _ hg + obtain ⟨b, hb, heb⟩ := real_grid_exists_rationalLieInclusion e l hl _ hx + let q : NilpotentLieBCHGroup L s hnil := ⟨a⟩ + have hq := had q b ha hb + have he : rationalLieInclusion (dualAdjoint q b) = dualAdjoint g x := + dualLinearLift_adjoint_eq (realification_lowerCentralSeries_eq_bot hnil) + (⊤ : LieIdeal ℚ L) rationalLieInclusion rationalLieInclusion.toLinearMap + (fun u v _ => rationalLieInclusion.map_lie u v) q b (by trivial) g x hea heb + change (fun i => (e.baseChange ℝ).repr (dualAdjoint g x) i) ∈ realDenominatorGrid m + rw [← he] + simp_rw [rationalLieInclusion_coordinates] + exact (real_cast_mem_denominatorGrid_iff m _).mpr hq + +theorem exists_real_dual_operation_grid (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + 1 ≤ H → 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + (∀ z : DualGroup (realification_lowerCentralSeries_eq_bot hnil), + (e.baseChange ℝ).equivFun (dualBaseLinear z.coord) ∈ realDenominatorGrid l → + (e.baseChange ℝ).equivFun (dualTangentLinear z.coord) ∈ realDenominatorGrid l → + (e.baseChange ℝ).equivFun (dualLogDerivative z) ∈ realDenominatorGrid m) ∧ + (∀ (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) + (x : ℝ ⊗[ℚ] L), + (e.baseChange ℝ).equivFun g.coord ∈ realDenominatorGrid l → + (e.baseChange ℝ).equivFun x ∈ realDenominatorGrid l → + (e.baseChange ℝ).equivFun (dualAdjoint g x) ∈ realDenominatorGrid m) := by + have hratExists := exists_rational_dual_operation_grid s + obtain ⟨C, hC, hrat⟩ := hratExists + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ e H p hnil hH hp hd hHp hc l hl hlp + have hdata := hrat e H p hnil hH hp hd hHp hc l hl hlp + obtain ⟨m, hm, hmp, hlm, hlog, had⟩ := hdata + exact ⟨m, hm, hmp, hlm, real_dual_log_grid_of_rational e l m hl hlog, + real_dual_adjoint_grid_of_rational e l m hl had⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealFastCoefficientMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealFastCoefficientMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..41203550a811a1fef0ed090bfef587cef1b9d8e9 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealFastCoefficientMatrix.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.Progressions.Estimates.ReducedRelativeCoefficientBounds + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +namespace NilpotentLieFiltration + +variable {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) (w : σ → ℕ) + [Fintype (FirstCoefficientIndex w ω)] [DecidableEq (FirstCoefficientIndex w ω)] + [Fintype κ] [DecidableEq κ] (hw : ∀ i, 0 < w i) + (U : LieSubalgebra ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + +theorem realFastCoefficientAdjoint_matrix + (b : Basis κ ℝ (F.RealFirstCoefficientModule w ⧸ + F.realFirstCoefficientFastSubmodule w hw (F.reducedSquareFastRelativeSubmodule w U))) + (D : Matrix κ (FirstCoefficientIndex w ω) ℚ) + (S : Matrix (FirstCoefficientIndex w ω) κ ℚ) + (hD : LinearMap.toMatrix (F.realFirstCoefficientBasis e ω hF w) b + (F.realFirstCoefficientFastSubmodule w hw (F.reducedSquareFastRelativeSubmodule w U)).mkQ = + D.map (Rat.castHom ℝ)) + (hDS : D * S = 1) + (g : F.RealAdaptedPolynomialGroup w) + (hg : (F.adaptedReducedRealSymbolHom w g).coord ∈ + realificationLieSubalgebra (F.reducedSquareFastDiagonalSubalgebra w U)) : + LinearMap.toMatrix b b + (F.realFastCoefficientAdjoint w hw U g hg).toLinearMap = + D.map (Rat.castHom ℝ) * + LinearMap.toMatrix (F.realFirstCoefficientBasis e ω hF w) + (F.realFirstCoefficientBasis e ω hF w) (F.realFirstCoefficientAdjoint w g).toLinearMap * + S.map (Rat.castHom ℝ) := by + have hsection : LinearMap.toMatrix (F.realFirstCoefficientBasis e ω hF w) b + (F.realFirstCoefficientFastSubmodule w hw (F.reducedSquareFastRelativeSubmodule w U)).mkQ * + S.map (Rat.castHom ℝ) = 1 := by + rw [hD] + exact real_matrix_right_inverse D S hDS + have h := quotient_action_matrix (F.realFirstCoefficientBasis e ω hF w) b + (F.realFirstCoefficientFastSubmodule w hw (F.reducedSquareFastRelativeSubmodule w U)).mkQ + (F.realFirstCoefficientAdjoint w g).toLinearMap + (F.realFastCoefficientAdjoint w hw U g hg).toLinearMap + (fun x => (F.realFastCoefficientAdjoint_mk w hw U g hg x).symm) + (S.map (Rat.castHom ℝ)) hsection + exact h.trans (congrArg (fun P : Matrix κ (FirstCoefficientIndex w ω) ℝ => + P * LinearMap.toMatrix (F.realFirstCoefficientBasis e ω hF w) + (F.realFirstCoefficientBasis e ω hF w) (F.realFirstCoefficientAdjoint w g).toLinearMap * + S.map (Rat.castHom ℝ)) hD) + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealFastCoefficientQuotientBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealFastCoefficientQuotientBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cdc6c0cf9a4caa1a1ad6f80a94d31a3361bbf15 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealFastCoefficientQuotientBasis.lean @@ -0,0 +1,189 @@ +import OAI.Combinatorics.Progressions.Dynamics.FastCoefficientGeneratorBudget +import OAI.Combinatorics.Progressions.Estimates.BlockQuotientRows +import OAI.Combinatorics.Progressions.Geometry.RealFastCoefficientCoordinates +import OAI.Combinatorics.Progressions.Geometry.SubmoduleQuotientCoordinates + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +theorem exists_fast_coefficient_quotient_projection + {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype κ] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) (w : σ → ℕ) + [Fintype (ReducedSquareSymbolIndex s w ω)] [Fintype (QuotientTopSymbolIndex s w ω)] + [Fintype (FirstCoefficientIndex w ω)] (hw : ∀ i, 0 < w i) + (U : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + (hU : BasisBlockInvariant (F.reducedSquareSymbolBasis e ω hF w) (fun i => i.val.1) U) + (v : κ → F.squareFiltration.quotientTop.PolynomialSymbol w) + (hspan : Submodule.span ℚ (Set.range v) = U) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ i j, RationalHeightLE ((F.reducedSquareSymbolBasis e ω hF w).repr (v i) j) H) + {p : ℝ} (hp : 0 ≤ p) + (hn : (Fintype.card (ReducedSquareSymbolIndex s w ω) : ℝ) ≤ p) + (hm : (Fintype.card κ : ℝ) ≤ p) + (hq : (Fintype.card (QuotientTopSymbolIndex s w ω) : ℝ) ≤ p) + (hd : (Fintype.card (FirstCoefficientIndex w ω) : ℝ) ≤ p) + (hdm : ((Fintype.card (FirstCoefficientIndex w ω) * Fintype.card κ : ℕ) : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ H' : ℕ, 1 ≤ H' ∧ (H' : ℝ) ≤ Real.exp ((p + 2) ^ 420) ∧ + ∃ Q : Matrix (FirstCoefficientIndex w ω) (FirstCoefficientIndex w ω) ℚ, + Q * Q = Q ∧ + LinearMap.ker Q.mulVecLin = (F.firstCoefficientFastSubmodule w hw U).map + (F.firstCoefficientBasis e ω hF w).equivFun.toLinearMap ∧ + (∀ i j, i.val.1 ≠ j.val.1 → Q i j = 0) ∧ + ∀ i j, RationalHeightLE (Q i j) H' := by + have hg := F.exists_fast_coefficient_generators_exp e ω hF w hw U v hspan hH hv hp hn hm hq hHp + obtain ⟨K, hK, hKp, z, hz, hzK⟩ := hg + have hblocks := F.firstCoefficientFastSubmodule_monomial_blocks e ω hF w hw U hU + have he := exists_submodule_block_quotient_projection (F.firstCoefficientBasis e ω hF w) + (fun i => i.val.1) (F.firstCoefficientFastSubmodule w hw U) z hz hblocks hK hzK + obtain ⟨Q, hQQ, hker, hblock, hQ⟩ := he + have hcost : (imageDefiningHeight + (Fintype.card (FirstCoefficientIndex w ω) * Fintype.card κ) + (Fintype.card (FirstCoefficientIndex w ω)) K : ℝ) ≤ Real.exp ((p + 2) ^ 420) := by + have h := imageDefiningHeight_le_exp _ _ K (by positivity : 0 ≤ (p + 2) ^ 40) + (hdm.trans (le_power_budget hp (by decide : 1 ≤ 40))) + (hd.trans (le_power_budget hp (by decide : 1 ≤ 40))) hKp + exact exponential_budget_comp hp (by positivity) 40 10 le_rfl h + exact ⟨_, imageDefiningHeight_pos _ _ _ hK, hcost, Q, hQQ, hker, hblock, hQ⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped Matrix + +theorem exists_fast_coefficient_quotient_basis + {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype κ] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) (w : σ → ℕ) + [Fintype (ReducedSquareSymbolIndex s w ω)] [Fintype (QuotientTopSymbolIndex s w ω)] + [Fintype (FirstCoefficientIndex w ω)] [DecidableEq (FirstCoefficientIndex w ω)] + (hw : ∀ i, 0 < w i) + (U : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + (hU : BasisBlockInvariant (F.reducedSquareSymbolBasis e ω hF w) (fun i => i.val.1) U) + (v : κ → F.squareFiltration.quotientTop.PolynomialSymbol w) + (hspan : Submodule.span ℚ (Set.range v) = U) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ i j, RationalHeightLE ((F.reducedSquareSymbolBasis e ω hF w).repr (v i) j) H) + {p : ℝ} (hp : 0 ≤ p) + (hn : (Fintype.card (ReducedSquareSymbolIndex s w ω) : ℝ) ≤ p) + (hm : (Fintype.card κ : ℝ) ≤ p) + (hq : (Fintype.card (QuotientTopSymbolIndex s w ω) : ℝ) ≤ p) + (hd : (Fintype.card (FirstCoefficientIndex w ω) : ℝ) ≤ p) + (hdm : ((Fintype.card (FirstCoefficientIndex w ω) * Fintype.card κ : ℕ) : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ d : ℕ, d ≤ Fintype.card (FirstCoefficientIndex w ω) ∧ + ∃ rows : Fin d → FirstCoefficientIndex w ω, Function.Injective rows ∧ + ∃ b : Basis (Fin d) ℚ (F.FirstCoefficientModule w ⧸ F.firstCoefficientFastSubmodule w hw U), + ∃ D : Matrix (Fin d) (FirstCoefficientIndex w ω) ℚ, + ∃ S : Matrix (FirstCoefficientIndex w ω) (Fin d) ℚ, + LinearMap.toMatrix (F.firstCoefficientBasis e ω hF w) b + (F.firstCoefficientFastSubmodule w hw U).mkQ = D ∧ + D * S = 1 ∧ + (∀ i j, (rows i).val.1 ≠ j.val.1 → D i j = 0) ∧ + (∀ i j, i.val.1 ≠ (rows j).val.1 → S i j = 0) ∧ + (∀ i j, ((D i j).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 420) ∧ + ((D i j).den : ℝ) ≤ Real.exp ((p + 2) ^ 420)) ∧ + (∀ i j, ((S i j).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 2954) ∧ + ((S i j).den : ℝ) ≤ Real.exp ((p + 2) ^ 2954)) ∧ + ∀ y : Fin d → ℚ, b.equivFun.symm y = + (F.firstCoefficientFastSubmodule w hw U).mkQ + ((F.firstCoefficientBasis e ω hF w).equivFun.symm (S *ᵥ y)) := by + classical + have he := F.exists_fast_coefficient_quotient_projection e ω hF w hw U hU v hspan hH hv + hp hn hm hq hd hdm hHp + obtain ⟨K, hK, hKp, Q, _, hkerQ, hQb, hQ⟩ := he + have hr := exists_block_quotient_rows (fun i : FirstCoefficientIndex w ω => i.val.1) Q hQb hK hQ + obtain ⟨d, hd', rows, hinj, hsurj, hker, S, hDS, hSb, hS⟩ := hr + let D := Q.submatrix rows id + have hkerD : LinearMap.ker D.mulVecLin = (F.firstCoefficientFastSubmodule w hw U).map + (F.firstCoefficientBasis e ω hF w).equivFun.toLinearMap := hker.trans hkerQ + let b := submoduleQuotientCoordinateBasis (F.firstCoefficientBasis e ω hF w) + (F.firstCoefficientFastSubmodule w hw U) D hkerD hsurj + have hSbudget : (rationalKernelHeight d K : ℝ) ≤ Real.exp ((p + 2) ^ 2954) := by + have h := rationalKernelHeight_le_budget d K (by positivity : 0 ≤ (p + 2) ^ 420) + (((Nat.cast_le.mpr hd').trans hd).trans (le_power_budget hp (by decide : 1 ≤ 420))) hKp + exact exponential_budget_comp hp (by positivity) 420 7 le_rfl h + refine ⟨d, hd', rows, hinj, b, D, S, + submoduleQuotientCoordinateBasis_matrix _ _ _ _ _, hDS, + (fun i j h => hQb (rows i) j h), hSb, ?_, ?_, ?_⟩ + · intro i j + exact ⟨(Nat.cast_le.mpr (hQ (rows i) j).1).trans hKp, + (Nat.cast_le.mpr (hQ (rows i) j).2).trans hKp⟩ + · intro i j + exact ⟨(Nat.cast_le.mpr (hS i j).1).trans hSbudget, + (Nat.cast_le.mpr (hS i j).2).trans hSbudget⟩ + · intro y + exact submoduleQuotientCoordinateEquiv_symm _ _ _ _ _ S hDS y + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped Matrix + +theorem exists_real_fast_coefficient_quotient_basis + {σ ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype κ] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) (w : σ → ℕ) + [Fintype (ReducedSquareSymbolIndex s w ω)] [Fintype (QuotientTopSymbolIndex s w ω)] + [Fintype (FirstCoefficientIndex w ω)] [DecidableEq (FirstCoefficientIndex w ω)] + (hw : ∀ i, 0 < w i) + (U : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + (hU : BasisBlockInvariant (F.reducedSquareSymbolBasis e ω hF w) (fun i => i.val.1) U) + (v : κ → F.squareFiltration.quotientTop.PolynomialSymbol w) + (hspan : Submodule.span ℚ (Set.range v) = U) {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ i j, RationalHeightLE ((F.reducedSquareSymbolBasis e ω hF w).repr (v i) j) H) + {p : ℝ} (hp : 0 ≤ p) + (hn : (Fintype.card (ReducedSquareSymbolIndex s w ω) : ℝ) ≤ p) + (hm : (Fintype.card κ : ℝ) ≤ p) + (hq : (Fintype.card (QuotientTopSymbolIndex s w ω) : ℝ) ≤ p) + (hd : (Fintype.card (FirstCoefficientIndex w ω) : ℝ) ≤ p) + (hdm : ((Fintype.card (FirstCoefficientIndex w ω) * Fintype.card κ : ℕ) : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ d : ℕ, d ≤ Fintype.card (FirstCoefficientIndex w ω) ∧ + ∃ rows : Fin d → FirstCoefficientIndex w ω, Function.Injective rows ∧ + ∃ b : Basis (Fin d) ℝ (F.RealFirstCoefficientModule w ⧸ + F.realFirstCoefficientFastSubmodule w hw U), + ∃ D : Matrix (Fin d) (FirstCoefficientIndex w ω) ℚ, + ∃ S : Matrix (FirstCoefficientIndex w ω) (Fin d) ℚ, + LinearMap.toMatrix (F.realFirstCoefficientBasis e ω hF w) b + (F.realFirstCoefficientFastSubmodule w hw U).mkQ = D.map (Rat.castHom ℝ) ∧ + D * S = 1 ∧ + (∀ i j, (rows i).val.1 ≠ j.val.1 → D i j = 0) ∧ + (∀ i j, i.val.1 ≠ (rows j).val.1 → S i j = 0) ∧ + (∀ i j, ((D i j).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 420) ∧ + ((D i j).den : ℝ) ≤ Real.exp ((p + 2) ^ 420)) ∧ + (∀ i j, ((S i j).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 2954) ∧ + ((S i j).den : ℝ) ≤ Real.exp ((p + 2) ^ 2954)) ∧ + ∀ y : Fin d → ℝ, b.equivFun.symm y = + (F.realFirstCoefficientFastSubmodule w hw U).mkQ + ((F.realFirstCoefficientBasis e ω hF w).equivFun.symm + (S.map (Rat.castHom ℝ) *ᵥ y)) := by + have h := F.exists_fast_coefficient_quotient_basis e ω hF w hw U hU v hspan hH hv + hp hn hm hq hd hdm hHp + obtain ⟨d, hdim, rows, hinj, b, D, S, hD, hDS, hDb, hSb, hDh, hSh, _⟩ := h + refine ⟨d, hdim, rows, hinj, F.realFastCoefficientBasis w hw U b, D, S, + ?_, hDS, hDb, hSb, hDh, hSh, ?_⟩ + · rw [F.realFastCoefficientBasis_matrix, hD] + · exact F.realFastCoefficientBasis_symm w hw U e ω hF b D S hD hDS + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealFirstCoefficientBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealFirstCoefficientBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..315790fafea495ae35d3fe3bc5e5cb6265f9e60b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealFirstCoefficientBasis.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.Progressions.Estimates.RealFirstCoefficientHorizontal +import OAI.Combinatorics.Progressions.Geometry.SupportedSubquotient + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem realShiftedCoefficient_eq_span (w : σ → ℕ) (k : ℕ) : + F.realShiftedCoefficientSubmodule w k = Submodule.span ℝ + ((F.adaptedMonomialBasis b ω hF w).baseChange ℝ '' + {z | Finsupp.weight w z.val.1 + k ≤ ω z.val.2}) := by + change (F.shiftedPolynomialIdeal w k).toSubmodule.baseChange ℝ = _ + rw [F.shiftedPolynomialIdeal_eq_span_monomialBasis b ω hF, + Submodule.baseChange_span, Set.image_image] + congr 2 + funext z + exact (Basis.baseChange_apply ℝ (F.adaptedMonomialBasis b ω hF w) z).symm + +noncomputable def realShiftedMonomialBasis (w : σ → ℕ) (k : ℕ) : + Basis (ShiftedMonomialIndex w ω k) ℝ (F.realShiftedCoefficientSubmodule w k) := + supportedSubmoduleBasis ((F.adaptedMonomialBasis b ω hF w).baseChange ℝ) + (F.realShiftedCoefficientSubmodule w k) + {z | Finsupp.weight w z.val.1 + k ≤ ω z.val.2} + (F.realShiftedCoefficient_eq_span b ω hF w k) + +@[simp] theorem realShiftedMonomialBasis_coe (w : σ → ℕ) (k : ℕ) (z : ShiftedMonomialIndex w ω k) : + (F.realShiftedMonomialBasis b ω hF w k z : ℝ ⊗[ℚ] F.adaptedLieSubalgebra w) = + (F.adaptedMonomialBasis b ω hF w).baseChange ℝ z.val := + supportedSubmoduleBasis_coe _ _ _ _ z + +theorem realShiftedMonomialBasis_repr (w : σ → ℕ) (k : ℕ) + (x : F.realShiftedCoefficientSubmodule w k) (z : ShiftedMonomialIndex w ω k) : + (F.realShiftedMonomialBasis b ω hF w k).repr x z = + ((F.adaptedMonomialBasis b ω hF w).baseChange ℝ).repr x.val z.val := + supportedSubmoduleBasis_repr _ _ _ _ x z + +theorem realShiftedCoefficient_next_eq_span (w : σ → ℕ) (k : ℕ) : + (F.realShiftedCoefficientSubmodule w (k + 1)).comap (F.realShiftedCoefficientSubmodule w k).subtype = + Submodule.span ℝ (F.realShiftedMonomialBasis b ω hF w k '' + {z | Finsupp.weight w z.val.val.1 + (k + 1) ≤ ω z.val.val.2}) := by + have hP := F.realShiftedCoefficient_eq_span b ω hF w k + have hQ := F.realShiftedCoefficient_eq_span b ω hF w (k + 1) + have hdata := supportedSubmoduleBasis_comap_span + ((F.adaptedMonomialBasis b ω hF w).baseChange ℝ) + (F.realShiftedCoefficientSubmodule w k) (F.realShiftedCoefficientSubmodule w (k + 1)) + {z | Finsupp.weight w z.val.1 + k ≤ ω z.val.2} + {z | Finsupp.weight w z.val.1 + (k + 1) ≤ ω z.val.2} hP hQ + exact hdata + +noncomputable def realFirstCoefficientBasis (w : σ → ℕ) : + Basis (FirstCoefficientIndex w ω) ℝ (F.RealFirstCoefficientModule w) := + (supportedQuotientBasis (F.realShiftedMonomialBasis b ω hF w 1) + ((F.realShiftedCoefficientSubmodule w 2).comap (F.realShiftedCoefficientSubmodule w 1).subtype) + {z | Finsupp.weight w z.val.val.1 + 2 ≤ ω z.val.val.2} + (F.realShiftedCoefficient_next_eq_span b ω hF w 1)).reindex (firstCoefficientSurvivorEquiv w ω) + +@[simp] theorem realFirstCoefficientBasis_apply (w : σ → ℕ) (z : FirstCoefficientIndex w ω) : + F.realFirstCoefficientBasis b ω hF w z = + F.realFirstCoefficientMap w + (F.realShiftedMonomialBasis b ω hF w 1 ((firstCoefficientSurvivorEquiv w ω).symm z).val) := by + rw [realFirstCoefficientBasis, Basis.reindex_apply, supportedQuotientBasis_apply] + rfl + +theorem realFirstCoefficientBasis_repr_map (w : σ → ℕ) + (x : F.realShiftedCoefficientSubmodule w 1) (z : FirstCoefficientIndex w ω) : + (F.realFirstCoefficientBasis b ω hF w).repr (F.realFirstCoefficientMap w x) z = + ((F.adaptedMonomialBasis b ω hF w).baseChange ℝ).repr x.val + ((firstCoefficientSurvivorEquiv w ω).symm z).val.val := by + rw [realFirstCoefficientBasis, Basis.repr_reindex_apply] + change (supportedQuotientBasis _ _ _ _).repr + (((F.realShiftedCoefficientSubmodule w 2).comap (F.realShiftedCoefficientSubmodule w 1).subtype).mkQ x) _ = _ + rw [supportedQuotientBasis_repr_mk, F.realShiftedMonomialBasis_repr] + +theorem realFirstCoefficientBasis_polynomial_coordinate (w : σ → ℕ) + (x : F.realShiftedCoefficientSubmodule w 1) (z : FirstCoefficientIndex w ω) : + (F.realFirstCoefficientBasis b ω hF w).repr (F.realFirstCoefficientMap w x) z = + (b.baseChange ℝ).repr (coefficients (F.realAdaptedPolynomialMap w x.val) z.val.1) z.val.2 := by + rw [F.realFirstCoefficientBasis_repr_map] + exact (F.realAdaptedPolynomialTensor_coordinates w b ω hF x.val + ((firstCoefficientSurvivorEquiv w ω).symm z).val.val).symm + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealFourAnnihilatorKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealFourAnnihilatorKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..320bca6cb26621b44fbc65c7607bfac4a5df19dd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealFourAnnihilatorKernel.lean @@ -0,0 +1,58 @@ +import Mathlib.LinearAlgebra.TensorProduct.Pi +import OAI.Combinatorics.Progressions.Estimates.CommonCoefficientFourAnnihilators + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem mem_realified_coordinate_kernel_iff + {V J : Type*} [AddCommGroup V] [Module ℚ V] [Fintype J] + (ℓ : V →ₗ[ℚ] (J → ℚ)) (x : ℝ ⊗[ℚ] V) : + x ∈ (LinearMap.ker ℓ).baseChange ℝ ↔ + ∀ j, realifyFunctional ((LinearMap.proj j).comp ℓ) x = 0 := by + have hker : LinearMap.ker ℓ = ⨅ j, LinearMap.ker ((LinearMap.proj j).comp ℓ) := by + ext v + simp only [LinearMap.mem_ker, Submodule.mem_iInf, LinearMap.comp_apply, LinearMap.proj_apply] + exact funext_iff + rw [hker, real_baseChange_iInf] + simp only [Submodule.mem_iInf, mem_realified_frequency_kernel_iff] + +theorem mem_real_four_annihilator_iff + {V J : Type*} [AddCommGroup V] [Module ℚ V] [Fintype J] + (K : Submodule ℚ (Fin 4 → V)) (ℓ : (Fin 4 → V) →ₗ[ℚ] (J → ℚ)) + (hker : LinearMap.ker ℓ = K) (v : Fin 4 → ℝ ⊗[ℚ] V) : + v ∈ (K.baseChange ℝ).map (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).toLinearMap ↔ + ∀ j, realifyFunctional ((LinearMap.proj j).comp ℓ) + ((TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).symm v) = 0 := by + rw [← mem_realified_coordinate_kernel_iff, hker] + constructor + · rintro ⟨x, hx, rfl⟩ + change (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).symm + ((TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)) x) ∈ K.baseChange ℝ + rw [LinearEquiv.symm_apply_apply] + exact hx + · intro hv + exact ⟨(TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).symm v, hv, + (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).apply_symm_apply v⟩ + +theorem mem_real_petal_annihilator_iff + {V J : Type*} [AddCommGroup V] [Module ℚ V] [Fintype J] + (D : Submodule ℚ V) (K : Submodule ℚ (Fin 4 → V)) + (ℓ : (Fin 4 → V) →ₗ[ℚ] (J → ℚ)) (hker : LinearMap.ker ℓ = K) + (v : ℝ ⊗[ℚ] V) : + v ∈ (fourPetalSpace D K).baseChange ℝ ↔ + v ∈ D.baseChange ℝ ∧ ∀ j, realifyFunctional + (((LinearMap.proj j).comp ℓ).comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0)) v = 0 := by + rw [fourPetalSpace_eq_inf_ker D K ℓ hker, realification_inf, Submodule.mem_inf, + mem_realified_coordinate_kernel_iff] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealFourBalancedDual.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealFourBalancedDual.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c0f9c7122f7546f4835860192e0305c5c65ec9f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealFourBalancedDual.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.Progressions.Estimates.RealAnnihilatorCorrections + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {V J : Type*} [AddCommGroup V] [Module ℚ V] + +noncomputable def realFourCoordinateMap (ℓ : (Fin 4 → V) →ₗ[ℚ] (J → ℚ)) : + (Fin 4 → ℝ ⊗[ℚ] V) →ₗ[ℝ] (J → ℝ) := + (realifyCoordinateMap ℓ).comp + (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).symm.toLinearMap + +theorem real_four_diagonal (x : ℝ ⊗[ℚ] V) : + (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)) + ((fourDiagonalMap (R := ℚ)).baseChange ℝ x) = + fourDiagonalMap (R := ℝ) x := by + induction x using TensorProduct.inductionOn with + | tmul a v => rfl + | add x y hx hy => simp only [map_add, hx, hy] + +theorem realFourCoordinateMap_diagonal + (ℓ : (Fin 4 → V) →ₗ[ℚ] (J → ℚ)) (x : ℝ ⊗[ℚ] V) : + realFourCoordinateMap ℓ (fourDiagonalMap (R := ℝ) x) = + realifyCoordinateMap (ℓ.comp (fourDiagonalMap (R := ℚ))) x := by + change realifyCoordinateMap ℓ + ((TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).symm _) = _ + rw [← real_four_diagonal, LinearEquiv.symm_apply_apply, realifyCoordinateMap_comp] + +theorem realFourCoordinateMap_single + (ℓ : (Fin 4 → V) →ₗ[ℚ] (J → ℚ)) (k : Fin 4) (x : ℝ ⊗[ℚ] V) : + realFourCoordinateMap ℓ (LinearMap.single ℝ (fun _ : Fin 4 => ℝ ⊗[ℚ] V) k x) = + realifyCoordinateMap (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) k)) x := by + change realifyCoordinateMap ℓ + ((TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).symm _) = _ + rw [← real_four_single, LinearEquiv.symm_apply_apply, realifyCoordinateMap_comp] + +variable [Fintype J] + +theorem realFourCoordinateMap_decomposition (C D : Submodule ℚ V) + (ℓ : (Fin 4 → V) →ₗ[ℚ] (J → ℚ)) + (hℓ : fourBalancedDependent D ≤ LinearMap.ker ℓ) + (v : Fin 4 → ℝ ⊗[ℚ] V) (hv : v ∈ fourCommonModulo (C.baseChange ℝ) (D.baseChange ℝ)) : + realFourCoordinateMap ℓ v = + realifyCoordinateMap (ℓ.comp (fourDiagonalMap (R := ℚ))) (v 0) + + realifyCoordinateMap (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0)) + (v 0 + v 1 - v 2 - v 3) := by + have hzero (z) (hz : z ∈ fourBalancedDependent (D.baseChange ℝ)) : + realFourCoordinateMap ℓ z = 0 := by + rw [← realification_fourBalancedDependent] at hz + have hmem := (Submodule.mem_map_equiv _).mp hz + exact (mem_realified_coordinate_kernel_iff_eq_zero ℓ _).mp + (Submodule.baseChange_mono ℝ hℓ hmem) + have h := four_annihilator_decomposition (C.baseChange ℝ) (D.baseChange ℝ) + (realFourCoordinateMap ℓ) hzero v hv + simpa only [realFourCoordinateMap_diagonal, realFourCoordinateMap_single, + fourAlternatingMap_apply] using h + +theorem realFourCoordinateMap_shared_decomposition (C D : Submodule ℚ V) (hDC : D ≤ C) + (ℓ : (Fin 4 → V) →ₗ[ℚ] (J → ℚ)) + (hℓ : fourBalancedDependent D ≤ LinearMap.ker ℓ) + (c : ℝ ⊗[ℚ] V) (hc : c ∈ C.baseChange ℝ) + (v : Fin 4 → ℝ ⊗[ℚ] V) (hv : ∀ k, v k ∈ D.baseChange ℝ) : + realFourCoordinateMap ℓ (fun k => c + v k) = + realifyCoordinateMap (ℓ.comp (fourDiagonalMap (R := ℚ))) c + + realifyCoordinateMap (ℓ.comp (LinearMap.single ℚ (fun _ : Fin 4 => V) 0)) + (v 0 + v 1 - v 2 - v 3) := by + have hmem : (fun k => c + v k) ∈ fourCommonModulo (C.baseChange ℝ) (D.baseChange ℝ) := by + apply (mem_fourCommonModulo _ _ _).mpr + refine ⟨fun k => (C.baseChange ℝ).add_mem hc + (Submodule.baseChange_mono ℝ hDC (hv k)), ?_⟩ + intro k + rw [add_sub_add_left_eq_sub] + exact (D.baseChange ℝ).sub_mem (hv k) (hv 0) + have hdiag : D ≤ LinearMap.ker (ℓ.comp (fourDiagonalMap (R := ℚ))) := by + intro x hx + exact four_annihilator_common_zero D ℓ (fun z hz => hℓ hz) x hx + have hz := (mem_realified_coordinate_kernel_iff_eq_zero + (ℓ.comp (fourDiagonalMap (R := ℚ))) (v 0)).mp + (Submodule.baseChange_mono ℝ hdiag (hv 0)) + have halt : (c + v 0) + (c + v 1) - (c + v 2) - (c + v 3) = + v 0 + v 1 - v 2 - v 3 := by abel + have h := realFourCoordinateMap_decomposition C D ℓ hℓ (fun k => c + v k) hmem + rw [halt, map_add, hz, add_zero] at h + exact h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealGradedFastCoefficientKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealGradedFastCoefficientKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..abf180ad09ef79b0c5333abbf5e9106b65af3251 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealGradedFastCoefficientKernel.lean @@ -0,0 +1,192 @@ +import OAI.Combinatorics.Progressions.Estimates.GradedUnitEvaluation + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +local notation "ωW" => (fun a : ReducedSquareBasisIndex s ω => squareBasisWeight ω (Subtype.val a)) +local notation "bW" => F.squareFiltration.quotientTop.associatedGradedBasis + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) + +noncomputable def fastGradedRelativeKernel + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) : + Submodule ℚ F.squareFiltration.quotientTop.AssociatedGraded := + W.toSubmodule ⊓ F.reducedSquareGradedSndMap.ker.toSubmodule + +noncomputable def fullFastGradedRelative + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) : + Submodule ℚ F.AssociatedGraded := + (F.fastGradedRelativeKernel W).map (F.reducedSquareGradedDifference e ω hF) + +variable (w : σ → ℕ) (hw : ∀ i, 0 < w i) + (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + +theorem firstCoefficientFastSubmodule_graded_coefficients (x : F.FirstCoefficientModule w) + (hx : x ∈ F.firstCoefficientFastSubmodule w hw (F.fastPointwiseSquare e ω hF w W).toSubmodule) : + ∀ α, coefficients (F.firstCoefficientGradedPolynomial e ω hF w x) α ∈ + F.fullFastGradedRelative e ω hF W := by + rw [F.firstCoefficientFastSubmodule_eq_image] at hx + obtain ⟨y, hy, rfl⟩ := hx + intro α + rw [F.firstCoefficientGradedPolynomial_reducedSquare_coefficient] + refine ⟨coefficients (F.squareFiltration.quotientTop.gradedSymbolPolynomial + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) w y) α, ?_, rfl⟩ + constructor + · exact (F.squareFiltration.quotientTop.mem_symbolPointwiseSubalgebra_iff + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) w W y).mp hy.1 α + · change F.reducedSquareGradedSndMap _ = 0 + rw [F.reducedSquareGradedSnd_coefficient] + have hz : F.reducedSquareSndSymbolMap w y = 0 := hy.2 + simp only [hz, map_zero, Finsupp.zero_apply] + +theorem firstCoefficientFastSubmodule_iff_graded + (hW : BasisGradedSubmodule bW ωW W.toSubmodule) (x : F.FirstCoefficientModule w) : + x ∈ F.firstCoefficientFastSubmodule w hw (F.fastPointwiseSquare e ω hF w W).toSubmodule ↔ + ∀ α, coefficients (F.firstCoefficientGradedPolynomial e ω hF w x) α ∈ + F.fullFastGradedRelative e ω hF W := by + classical + constructor + · exact F.firstCoefficientFastSubmodule_graded_coefficients e ω hF w hw W x + · intro hx + have hex (α : σ →₀ ℕ) : ∃ y, y ∈ F.fastGradedRelativeKernel W ∧ + F.reducedSquareGradedDifference e ω hF y = + coefficients (F.firstCoefficientGradedPolynomial e ω hF w x) α := hx α + choose y hy hey using hex + let q (α : σ →₀ ℕ) : F.FirstCoefficientModule w := + F.reducedSquareCoefficientMap w (F.squareFiltration.quotientTop.homogeneousSymbolLift + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) w α (y α)) + have hq (α : σ →₀ ℕ) : q α ∈ + F.firstCoefficientFastSubmodule w hw (F.fastPointwiseSquare e ω hF w W).toSubmodule := by + rw [F.firstCoefficientFastSubmodule_eq_image] + refine ⟨F.squareFiltration.quotientTop.homogeneousSymbolLift + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) w α (y α), ?_, rfl⟩ + constructor + · exact F.squareFiltration.quotientTop.homogeneousSymbolLift_mem_pointwise + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) w W hW α (y α) (hy α).1 + · change F.reducedSquareSndSymbolMap w _ = 0 + rw [F.reducedSquareSnd_homogeneousSymbolLift] + have hz : F.reducedSquareGradedSndMap (y α) = 0 := (hy α).2 + rw [hz, map_zero] + have hp (α : σ →₀ ℕ) : F.firstCoefficientGradedPolynomial e ω hF w (q α) = + monomial α (coefficients (F.firstCoefficientGradedPolynomial e ω hF w x) α) := by + dsimp only [q] + rw [F.firstCoefficientGradedPolynomial_reducedSquare_homogeneous, hey, + F.firstCoefficientGradedPolynomial_homogeneous] + have he : (∑ α ∈ (coefficients (F.firstCoefficientGradedPolynomial e ω hF w x)).support, q α) = x := by + apply F.firstCoefficientGradedPolynomial_injective e ω hF w + rw [map_sum] + simp_rw [hp] + exact sum_monomial_coefficients _ + rw [← he] + exact Submodule.sum_mem _ (fun α _ => hq α) + +noncomputable def firstCoefficientGradedQuotientMap : + F.FirstCoefficientModule w →ₗ[ℚ] VectorPolynomial σ ℚ + (F.AssociatedGraded ⧸ F.fullFastGradedRelative e ω hF W) := + (VectorPolynomial.map (F.fullFastGradedRelative e ω hF W).mkQ).comp + (F.firstCoefficientGradedPolynomial e ω hF w) + +theorem firstCoefficientFastSubmodule_eq_gradedKernel + (hW : BasisGradedSubmodule bW ωW W.toSubmodule) : + F.firstCoefficientFastSubmodule w hw (F.fastPointwiseSquare e ω hF w W).toSubmodule = + LinearMap.ker (F.firstCoefficientGradedQuotientMap e ω hF w W) := by + ext x + rw [F.firstCoefficientFastSubmodule_iff_graded e ω hF w hw W hW] + change (∀ α, coefficients (F.firstCoefficientGradedPolynomial e ω hF w x) α ∈ + F.fullFastGradedRelative e ω hF W) ↔ F.firstCoefficientGradedQuotientMap e ω hF w W x = 0 + constructor + · intro hx + apply coefficients.injective + ext α + change coefficients (VectorPolynomial.map (F.fullFastGradedRelative e ω hF W).mkQ + (F.firstCoefficientGradedPolynomial e ω hF w x)) α = _ + rw [coefficients_map, map_zero, Finsupp.zero_apply] + exact (Submodule.Quotient.mk_eq_zero _).mpr (hx α) + · intro hx α + have hc := congrArg (fun p => coefficients p α) hx + change coefficients (VectorPolynomial.map (F.fullFastGradedRelative e ω hF W).mkQ + (F.firstCoefficientGradedPolynomial e ω hF w x)) α = _ at hc + rw [coefficients_map, map_zero, Finsupp.zero_apply] at hc + exact (Submodule.Quotient.mk_eq_zero _).mp hc + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (w : σ → ℕ) (W : LieSubalgebra ℚ F.squareFiltration.quotientTop.AssociatedGraded) + +local notation "ωW" => (fun a : ReducedSquareBasisIndex s ω => squareBasisWeight ω (Subtype.val a)) +local notation "bW" => F.squareFiltration.quotientTop.associatedGradedBasis + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) + +theorem realFirstCoefficientGradedQuotient_coefficient (x : ℝ ⊗[ℚ] F.FirstCoefficientModule w) + (α : σ →₀ ℕ) : + coefficients (realificationLinearEquiv + ((F.firstCoefficientGradedQuotientMap e ω hF w W).baseChange ℝ x)) α = + (F.fullFastGradedRelative e ω hF W).mkQ.baseChange ℝ + (coefficients (F.realFirstCoefficientGradedPolynomial e ω hF w + (F.firstCoefficientRealEquiv w x)) α) := by + induction x using TensorProduct.inductionOn with + | add x y hx hy => simp only [map_add, Finsupp.add_apply, hx, hy] + | tmul a x => + rw [LinearMap.baseChange_tmul, coefficients_realificationLinearEquiv_tmul, + F.realFirstCoefficientGradedPolynomial_tmul, LinearMap.baseChange_tmul] + change a ⊗ₜ[ℚ] coefficients (VectorPolynomial.map (F.fullFastGradedRelative e ω hF W).mkQ + (F.firstCoefficientGradedPolynomial e ω hF w x)) α = _ + rw [coefficients_map] + +theorem realFirstCoefficientFastSubmodule_iff_graded (hw : ∀ i, 0 < w i) + (hW : BasisGradedSubmodule bW ωW W.toSubmodule) (x : F.RealFirstCoefficientModule w) : + x ∈ F.realFirstCoefficientFastSubmodule w hw (F.fastPointwiseSquare e ω hF w W).toSubmodule ↔ + ∀ α, coefficients (F.realFirstCoefficientGradedPolynomial e ω hF w x) α ∈ + (F.fullFastGradedRelative e ω hF W).baseChange ℝ := by + obtain ⟨y, rfl⟩ := (F.firstCoefficientRealEquiv w).surjective x + have hmem : F.firstCoefficientRealEquiv w y ∈ + F.realFirstCoefficientFastSubmodule w hw (F.fastPointwiseSquare e ω hF w W).toSubmodule ↔ + y ∈ (F.firstCoefficientFastSubmodule w hw (F.fastPointwiseSquare e ω hF w W).toSubmodule).baseChange ℝ := by + constructor + · rintro ⟨z, hz, he⟩ + have hzy : z = y := (F.firstCoefficientRealEquiv w).injective he + rwa [hzy] at hz + · intro hy + exact ⟨y, hy, rfl⟩ + rw [hmem, F.firstCoefficientFastSubmodule_eq_gradedKernel e ω hF w hw W hW, realification_ker] + change (F.firstCoefficientGradedQuotientMap e ω hF w W).baseChange ℝ y = 0 ↔ _ + rw [realificationLinearEquiv_eq_zero_iff] + have hker : (F.fullFastGradedRelative e ω hF W).baseChange ℝ = + LinearMap.ker ((F.fullFastGradedRelative e ω hF W).mkQ.baseChange ℝ) := by + simpa only [Submodule.ker_mkQ] using + realification_ker (F.fullFastGradedRelative e ω hF W).mkQ + constructor + · intro hy α + rw [hker] + change (F.fullFastGradedRelative e ω hF W).mkQ.baseChange ℝ _ = 0 + exact (F.realFirstCoefficientGradedQuotient_coefficient e ω hF w W y α).symm.trans (hy α) + · intro hy α + have h := hy α + rw [hker] at h + exact (F.realFirstCoefficientGradedQuotient_coefficient e ω hF w W y α).trans h + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealKernelJetInverse.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealKernelJetInverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a681ca77a972e0ba83a5194e4e9561ea4ac3075 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealKernelJetInverse.lean @@ -0,0 +1,159 @@ +import OAI.Combinatorics.Progressions.Estimates.RealBooleanInterpolation +import OAI.Combinatorics.Progressions.Linear.MatrixSupInverse + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +noncomputable def realJetMatrix {α K O J : Type*} [DecidableEq α] + (basis : J → MvPolynomial K ℝ) (vertices : Finset α → K → ℝ) + (rows : O → Finset α) : Matrix O J ℝ := + fun o j => booleanCoefficient (fun t => MvPolynomial.eval (vertices t) (basis j)) (rows o) + +theorem realJetMatrix_apply_coefficients {α K O J : Type*} [DecidableEq α] [Fintype J] + (basis : J → MvPolynomial K ℝ) (vertices : Finset α → K → ℝ) + (rows : O → Finset α) (c : J → ℝ) (o : O) : + (realJetMatrix basis vertices rows *ᵥ c) o = + booleanCoefficient (fun t => MvPolynomial.eval (vertices t) + (∑ j, MvPolynomial.C (c j) * basis j)) (rows o) := by + simp only [map_sum, map_mul, MvPolynomial.eval_C, + booleanCoefficient_sum, booleanCoefficient_const_mul] + change (∑ j, realJetMatrix basis vertices rows o j * c j) = _ + apply Finset.sum_congr rfl + intro j _ + exact mul_comm _ _ + +noncomputable def boundedDegreeRealJetMatrix {α K O : Type*} [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (h : ℕ) + (rows : O → Finset α) : Matrix O (BoundedIntegerExponent K h) ℝ := + realJetMatrix (fun e => MvPolynomial.monomial e.val 1) + (realAffineCube root difference) rows + +theorem boundedDegreeRealJetMatrix_interpolation {α K O : Type*} + [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℝ) (difference : α → K → ℝ) (h : ℕ) (rows : O → Finset α) + (p : O → MvPolynomial K ℝ) (hp : ∀ o, (p o).totalDegree ≤ h) + (hjet : ∀ i j, booleanCoefficient + (fun t => MvPolynomial.eval (realAffineCube root difference t) (p j)) (rows i) = + if i = j then 1 else 0) : + boundedDegreeRealJetMatrix root difference h rows * + Matrix.of (fun (e : BoundedIntegerExponent K h) j => (p j).coeff e.val) = 1 := by + ext i j + change (realJetMatrix _ _ rows *ᵥ + (fun e : BoundedIntegerExponent K h => (p j).coeff e.val)) i = _ + rw [realJetMatrix_apply_coefficients, boundedRealPolynomial_expansion (p j) h (hp j)] + exact hjet i j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +def realDifferencePivot {α K : Type*} (difference : α → K → ℝ) + (selection : α → K) : Matrix α α ℝ := fun i j => difference i (selection j) + +theorem realDifferencePivot_inverse_dual {α K : Type*} [Fintype α] [DecidableEq α] + (difference : α → K → ℝ) (selection : α → K) + (hd : (realDifferencePivot difference selection).det ≠ 0) (r s : α) : + (∑ j, (realDifferencePivot difference selection)⁻¹ j r * difference s (selection j)) = + if r = s then 1 else 0 := by + have hm := Matrix.mul_nonsing_inv (realDifferencePivot difference selection) + (isUnit_iff_ne_zero.mpr hd) + have he := congrFun (congrFun hm s) r + simpa only [Matrix.mul_apply, realDifferencePivot, Matrix.one_apply, mul_comm, eq_comm] using he + +noncomputable def realKernelInterpolant {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (s : Finset α) : MvPolynomial K ℝ := + realBooleanInterpolant (fun r => realAffineDualPolynomial root selection + (fun j => (realDifferencePivot difference selection)⁻¹ j r)) s + +theorem realKernelInterpolant_degree {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) (s : Finset α) : + (realKernelInterpolant root difference selection s).totalDegree ≤ s.card := + realBooleanInterpolant_degree _ _ (fun _ _ => realAffineDualPolynomial_degree _ _ _) + +theorem realKernelInterpolant_jet {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (hd : (realDifferencePivot difference selection).det ≠ 0) (s row : Finset α) : + booleanCoefficient (fun t => MvPolynomial.eval (realAffineCube root difference t) + (realKernelInterpolant root difference selection s)) row = + if row = s then 1 else 0 := by + apply realBooleanInterpolant_jet + exact realAffineDualPolynomial_boolean root difference selection _ + (realDifferencePivot_inverse_dual difference selection hd) + +theorem realKernelInterpolant_mass {α K : Type*} [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (hroot : ∀ j, |root (selection j)| ≤ 1) + (hentry : ∀ i j, |difference i (selection j)| ≤ 1) + {κ : ℝ} (hκ : 0 < κ) (hd : κ ≤ |(realDifferencePivot difference selection).det|) + {h : ℕ} (s : Finset α) (hs : s.card ≤ h) : + realPolynomialMass (realKernelInterpolant root difference selection s) ≤ + (1 + (Fintype.card α : ℝ) * (2 * ((Fintype.card α).factorial / κ))) ^ h := by + apply realBooleanInterpolant_mass _ s (le_add_of_nonneg_right (by positivity)) _ hs + intro r _ + have hi : ∀ j, |(realDifferencePivot difference selection)⁻¹ j r| ≤ + (Fintype.card α).factorial / κ := by + intro j + simpa only [one_pow, mul_one] using + matrix_inverse_entry_abs_le (realDifferencePivot difference selection) hentry hκ hd j r + exact (realAffineDualPolynomial_mass root selection _ hroot (by positivity) hi).trans + (by linarith) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def realKernelJetRightInverse {α K O : Type*} + [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (h : ℕ) (rows : O → Finset α) : Matrix (BoundedIntegerExponent K h) O ℝ := + fun e o => (realKernelInterpolant root difference selection (rows o)).coeff e.val + +theorem realKernelJetRightInverse_spec {α K O : Type*} + [Fintype α] [DecidableEq α] [Fintype K] [Fintype O] [DecidableEq O] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (hd : (realDifferencePivot difference selection).det ≠ 0) + (h : ℕ) (rows : O → Finset α) (hr : Function.Injective rows) + (hrows : ∀ o, (rows o).card ≤ h) : + boundedDegreeRealJetMatrix root difference h rows * + realKernelJetRightInverse root difference selection h rows = 1 := by + apply boundedDegreeRealJetMatrix_interpolation + · intro o + exact (realKernelInterpolant_degree root difference selection (rows o)).trans (hrows o) + · intro i j + rw [realKernelInterpolant_jet root difference selection hd] + simp only [hr.eq_iff] + +theorem realKernelJetRightInverse_entry_bound {α K O : Type*} + [Fintype α] [DecidableEq α] + (root : K → ℝ) (difference : α → K → ℝ) (selection : α → K) + (hroot : ∀ j, |root (selection j)| ≤ 1) + (hentry : ∀ i j, |difference i (selection j)| ≤ 1) + {κ : ℝ} (hκ : 0 < κ) (hd : κ ≤ |(realDifferencePivot difference selection).det|) + (h : ℕ) (rows : O → Finset α) (hrows : ∀ o, (rows o).card ≤ h) + (e : BoundedIntegerExponent K h) (o : O) : + |realKernelJetRightInverse root difference selection h rows e o| ≤ + (1 + (Fintype.card α : ℝ) * (2 * ((Fintype.card α).factorial / κ))) ^ h := by + exact (realPolynomialMass_coeff_le _ _).trans + (realKernelInterpolant_mass root difference selection hroot hentry hκ hd (rows o) (hrows o)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealOrderedBasisProduct.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealOrderedBasisProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..454a5030c11a5a6babb21cba00675e94f63f912d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealOrderedBasisProduct.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.Progressions.Estimates.PowerIndexFromOrderedGenerators +import OAI.Combinatorics.Progressions.Nilpotent.RealBCHOrderedReduction + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] {d s : ℕ} + (e : Basis (Fin d) ℝ L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + +noncomputable def realOrderedBasisTailProduct (i : ℕ) (t : Fin d → ℝ) : + NilpotentLieBCHGroup L s hnil := + (((List.finRange d).drop i).map fun j => (⟨t j • e j⟩ : NilpotentLieBCHGroup L s hnil)).prod + +noncomputable def realOrderedBasisProduct (t : Fin d → ℝ) : NilpotentLieBCHGroup L s hnil := + realOrderedBasisTailProduct e hnil 0 t + +theorem realOrderedBasisTailProduct_terminal {i : ℕ} (hi : d ≤ i) (t : Fin d → ℝ) : + realOrderedBasisTailProduct e hnil i t = 1 := by + simp only [realOrderedBasisTailProduct, + List.drop_eq_nil_of_le (as := List.finRange d) (i := i) (by simpa using hi), + List.map_nil, List.prod_nil] + +theorem realOrderedBasisTailProduct_step (j : Fin d) (t : Fin d → ℝ) : + realOrderedBasisTailProduct e hnil j.val t = + (⟨t j • e j⟩ : NilpotentLieBCHGroup L s hnil) * realOrderedBasisTailProduct e hnil (j.val + 1) t := by + unfold realOrderedBasisTailProduct + rw [List.drop_eq_getElem_cons (by simp), List.map_cons, List.prod_cons] + simp only [List.getElem_finRange, Fin.cast_mk, Fin.eta] + +theorem realOrderedBasisTailProduct_congr (i : ℕ) {t u : Fin d → ℝ} + (h : ∀ j : Fin d, i ≤ j.val → t j = u j) : + realOrderedBasisTailProduct e hnil i t = realOrderedBasisTailProduct e hnil i u := by + apply congrArg List.prod + apply List.map_congr_left + intro j hj + rw [h j (mem_drop_finRange_iff.mp hj)] + +noncomputable def realOrderedBasisPrefixProduct (i : ℕ) (t : Fin d → ℝ) : + NilpotentLieBCHGroup L s hnil := + (((List.finRange d).take i).map fun j => (⟨t j • e j⟩ : NilpotentLieBCHGroup L s hnil)).prod + +theorem realOrderedBasisProduct_eq_prefix_mul_tail (i : ℕ) (t : Fin d → ℝ) : + realOrderedBasisProduct e hnil t = + realOrderedBasisPrefixProduct e hnil i t * realOrderedBasisTailProduct e hnil i t := by + unfold realOrderedBasisProduct realOrderedBasisPrefixProduct realOrderedBasisTailProduct + rw [List.drop_zero, ← List.prod_append, ← List.map_append, List.take_append_drop] + +theorem realOrderedBasisPrefixProduct_congr (i : ℕ) {t u : Fin d → ℝ} + (h : ∀ j : Fin d, j.val < i → t j = u j) : + realOrderedBasisPrefixProduct e hnil i t = realOrderedBasisPrefixProduct e hnil i u := by + apply congrArg List.prod + apply List.map_congr_left + intro j hj + obtain ⟨k, hk, hkj⟩ := List.mem_take_iff_getElem.mp hj + have hval : k = j.val := by simpa using congrArg Fin.val hkj + rw [h j (by omega)] + +variable [IsScalarTower ℚ ℝ L] + +namespace IsRealCentralLieBasis + +variable {e} (he : IsRealCentralLieBasis e) +include he + +theorem realOrderedBasisTailProduct_mem_tail (i : ℕ) (t : Fin d → ℝ) : + (realOrderedBasisTailProduct e hnil i t).coord ∈ realBasisTail e i := by + change realOrderedBasisTailProduct e hnil i t ∈ + NilpotentLieBCHGroup.subgroup (he.tailIdeal i).toLieSubalgebra + unfold realOrderedBasisTailProduct + apply list_prod_mem + intro g hg + obtain ⟨j, hj, rfl⟩ := List.mem_map.mp hg + exact (realBasisTail e i).smul_mem _ (real_basis_mem_tail e j (mem_drop_finRange_iff.mp hj)) + +theorem realOrderedBasisTailProduct_leading (j : Fin d) (t : Fin d → ℝ) : + e.repr (realOrderedBasisTailProduct e hnil j.val t).coord j = t j := by + rw [realOrderedBasisTailProduct_step] + exact he.leading_coordinate hnil j (t j) _ (he.realOrderedBasisTailProduct_mem_tail hnil _ t) + +theorem mul_tail_coordinate (a b : NilpotentLieBCHGroup L s hnil) (j : Fin d) + (hb : b.coord ∈ realBasisTail e (j.val + 1)) : + e.repr (a * b).coord j = e.repr a.coord j := by + change e.repr (lieBCH s a.coord b.coord) j = _ + rw [he.bch_low_coordinate hnil (j.val + 1) a.coord hb j (Nat.le_succ _), + hb j (Nat.lt_succ_self _), add_zero] + +theorem mul_basis_coordinate (a : NilpotentLieBCHGroup L s hnil) (j : Fin d) (t : ℝ) : + e.repr (a * (⟨t • e j⟩ : NilpotentLieBCHGroup L s hnil)).coord j = + e.repr a.coord j + t := by + change e.repr (lieBCH s a.coord (t • e j)) j = _ + rw [he.bch_low_coordinate hnil j.val a.coord + ((realBasisTail e j.val).smul_mem t (real_basis_mem_tail e j le_rfl)) j le_rfl] + simp only [map_smul, Finsupp.smul_apply, Basis.repr_self, Finsupp.single_eq_same, + smul_eq_mul, mul_one] + +theorem mul_realOrderedBasisProduct_coordinate (a : NilpotentLieBCHGroup L s hnil) + (t : Fin d → ℝ) (j : Fin d) : + e.repr (a * realOrderedBasisProduct e hnil t).coord j = + e.repr (a * realOrderedBasisPrefixProduct e hnil j.val t).coord j + t j := by + calc + _ = e.repr (((a * realOrderedBasisPrefixProduct e hnil j.val t) * + (⟨t j • e j⟩ : NilpotentLieBCHGroup L s hnil)) * + realOrderedBasisTailProduct e hnil (j.val + 1) t).coord j := by + rw [realOrderedBasisProduct_eq_prefix_mul_tail e hnil j.val, + realOrderedBasisTailProduct_step] + simp only [mul_assoc] + _ = e.repr ((a * realOrderedBasisPrefixProduct e hnil j.val t) * + (⟨t j • e j⟩ : NilpotentLieBCHGroup L s hnil)).coord j := + he.mul_tail_coordinate hnil _ _ j (he.realOrderedBasisTailProduct_mem_tail hnil _ t) + _ = _ := he.mul_basis_coordinate hnil _ j (t j) + +end IsRealCentralLieBasis +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealRankHorizontalSymbol.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealRankHorizontalSymbol.lean new file mode 100644 index 0000000000000000000000000000000000000000..676463a7930dcc6f2737efe3e36796dbd629840a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealRankHorizontalSymbol.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.Progressions.Polynomial.RealCoordinatePolynomialSymbol + +namespace OAI + +section + +namespace Erdos3.DegreeRankLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) + +noncomputable def realHorizontalSymbolHom (hs : 1 ≤ s) (w : σ → ℕ) (α : σ →₀ ℕ) : + F.associatedDegree.RealPolynomialSymbolGroup w →* + Multiplicative (ℝ ⊗[ℚ] F.HigherHorizontal (Finsupp.weight w α)) where + toFun X := Multiplicative.ofAdd ((F.higherHorizontalSymbolCoefficient w α).baseChange ℝ X.coord) + map_one' := by + change Multiplicative.ofAdd ((F.higherHorizontalSymbolCoefficient w α).baseChange ℝ 0) = 1 + rw [map_zero] + rfl + map_mul' X Y := by + change Multiplicative.ofAdd ((F.higherHorizontalSymbolCoefficient w α).baseChange ℝ + (lieBCH s X.coord Y.coord)) = Multiplicative.ofAdd + ((F.higherHorizontalSymbolCoefficient w α).baseChange ℝ X.coord + + (F.higherHorizontalSymbolCoefficient w α).baseChange ℝ Y.coord) + exact congrArg Multiplicative.ofAdd (linearMap_baseChange_lieBCH_eq_add + (F.higherHorizontalSymbolCoefficient w α) (F.higherHorizontalSymbolCoefficient_lie w α) + hs X.coord Y.coord) + +@[simp] theorem realHorizontalSymbolHom_apply (hs : 1 ≤ s) (w : σ → ℕ) (α : σ →₀ ℕ) + (X : F.associatedDegree.RealPolynomialSymbolGroup w) : + Multiplicative.toAdd (F.realHorizontalSymbolHom hs w α X) = + (F.higherHorizontalSymbolCoefficient w α).baseChange ℝ X.coord := rfl + +theorem realHorizontalSymbolCoefficient_extended (w : σ → ℕ) (α : σ →₀ ℕ) + (x : ℝ ⊗[ℚ] F.associatedDegree.adaptedLieSubalgebra w) : + (F.higherHorizontalSymbolCoefficient w α).baseChange ℝ + (F.associatedDegree.realExtendedSymbolMap w x) = + (F.higherHorizontalCoefficient w α).baseChange ℝ x := by + induction x using TensorProduct.inductionOn with + | tmul a p => + change (F.higherHorizontalSymbolCoefficient w α).baseChange ℝ + (a ⊗ₜ[ℚ] F.associatedDegree.polynomialSymbolMap w p) = + (F.higherHorizontalCoefficient w α).baseChange ℝ (a ⊗ₜ[ℚ] p) + simp only [LinearMap.baseChange_tmul, F.higherHorizontalSymbolCoefficient_map] + | add x y hx hy => simp only [map_add, hx, hy] + +noncomputable def realHorizontalPolynomialHom (hs : 1 ≤ s) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.associatedDegree.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (w : σ → ℕ) (α : σ →₀ ℕ) : + (F.associatedDegree.realification.adaptedPolynomialFiltration w).Group →* + Multiplicative (ℝ ⊗[ℚ] F.HigherHorizontal (Finsupp.weight w α)) := + (F.realHorizontalSymbolHom hs w α).comp + (F.associatedDegree.realPolynomialSymbolHom b ω hF w) + +theorem realHorizontalPolynomialHom_tensor (hs : 1 ≤ s) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.associatedDegree.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (w : σ → ℕ) (α : σ →₀ ℕ) + (x : ℝ ⊗[ℚ] F.associatedDegree.adaptedLieSubalgebra w) : + Multiplicative.toAdd (F.realHorizontalPolynomialHom hs b ω hF w α + ⟨F.associatedDegree.realAdaptedPolynomialTensor w x⟩) = + (F.higherHorizontalCoefficient w α).baseChange ℝ x := by + change (F.higherHorizontalSymbolCoefficient w α).baseChange ℝ + (F.associatedDegree.realSymbolOfPolynomial b ω hF w + (F.associatedDegree.realAdaptedPolynomialMap w x)) = _ + rw [F.associatedDegree.realSymbolOfPolynomial_realAdaptedPolynomialMap] + exact F.realHorizontalSymbolCoefficient_extended w α x + +end Erdos3.DegreeRankLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealRationalMatrixPiNaturality.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealRationalMatrixPiNaturality.lean new file mode 100644 index 0000000000000000000000000000000000000000..90a6d53f46fffc18b7cf972ef11012249e2a8e16 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealRationalMatrixPiNaturality.lean @@ -0,0 +1,36 @@ +import Mathlib.Algebra.Algebra.Rat +import Mathlib.Basic.Real.Basic +import Mathlib.LinearAlgebra.Matrix.ToLin +import Mathlib.LinearAlgebra.TensorProduct.Pi + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem rationalMatrix_piScalarRight_baseChange + {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] + (A : Matrix I J ℚ) (x : ℝ ⊗[ℚ] (J → ℚ)) : + TensorProduct.piScalarRight ℚ ℝ ℝ I (A.mulVecLin.baseChange ℝ x) = + (Matrix.mulVecLin (fun i j => (A i j : ℝ))) + (TensorProduct.piScalarRight ℚ ℝ ℝ J x) := by + classical + induction x using TensorProduct.inductionOn with + | tmul a v => + rw [LinearMap.baseChange_tmul] + simp only [TensorProduct.piScalarRight_apply, TensorProduct.piScalarRightHom_tmul, + Matrix.mulVecLin_apply, Matrix.mulVec, dotProduct, Rat.smul_def] + funext i + change ((∑ j, A i j * v j : ℚ) : ℝ) * a = + ∑ j, (A i j : ℝ) * ((v j : ℝ) * a) + simp only [Rat.cast_sum, Rat.cast_mul, Finset.sum_mul, mul_assoc] + | add x y hx hy => simp only [map_add, hx, hy] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealReducedFastKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealReducedFastKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..13eca01e424d3f33e14fb463087ab69c0c230647 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealReducedFastKernel.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.Progressions.Estimates.ReducedNativeFactorization + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (w : σ → ℕ) + (W : LieSubalgebra ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + +theorem reducedSquareRealFastRelative_lie_eq_zero (hw : ∀ i, 0 < w i) + {v z : ℝ ⊗[ℚ] F.squareFiltration.quotientTop.PolynomialSymbol w} + (hv : v ∈ (F.reducedSquareFastRelativeSubmodule w W).baseChange ℝ) + (hz : z ∈ (F.reducedSquareFastRelativeSubmodule w W).baseChange ℝ) : + ⁅v, z⁆ = 0 := by + have h := lie_mem_real_baseChange (F.reducedSquareFastRelativeSubmodule w W) + (F.reducedSquareFastRelativeSubmodule w W) ⊥ + (fun a ha b hb => (Submodule.mem_bot ℚ).mpr + (F.reducedSquareFastRelative_lie_eq_zero w W hw ha hb)) hv hz + simpa only [Submodule.baseChange_bot, Submodule.mem_bot] using h + +theorem reducedSquareRealFastRelative_action_mem (hw : ∀ i, 0 < w i) + {u : ℝ ⊗[ℚ] F.quotientTop.PolynomialSymbol w} + (hu : u ∈ realificationLieSubalgebra (F.reducedSquareFastDiagonalSubalgebra w W)) + {v : ℝ ⊗[ℚ] F.squareFiltration.quotientTop.PolynomialSymbol w} + (hv : v ∈ (F.reducedSquareFastRelativeSubmodule w W).baseChange ℝ) : + ⁅(F.reducedSquareDiagonalSymbolMap w).toLinearMap.baseChange ℝ u, v⁆ ∈ + (F.reducedSquareFastRelativeSubmodule w W).baseChange ℝ := by + let P := (F.reducedSquareFastDiagonalSubalgebra w W).toSubmodule + let K := F.reducedSquareFastRelativeSubmodule w W + let d := (F.reducedSquareDiagonalSymbolMap w).toLinearMap + have hu' : d.baseChange ℝ u ∈ (P.map d).baseChange ℝ := by + rw [realification_map] + exact ⟨u, hu, rfl⟩ + have hclosed : ∀ x ∈ P.map d, ∀ y ∈ K, ⁅x, y⁆ ∈ K := by + rintro x ⟨y, hy, rfl⟩ z hz + exact F.reducedSquareFastRelative_action_mem w W hw hy hz + exact lie_mem_real_baseChange (P.map d) K K hclosed hu' hv + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealSparseFourProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealSparseFourProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..a57f53d0fa7c3f614bbc794d7c53ae786cb027db --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealSparseFourProjection.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.Progressions.Geometry.HorizontalCoordinateBounds + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {ι : Type*} [Fintype ι] + +theorem real_fourCoordinateKernel_mem_iff (S : Finset (Fin 4)) + (x : ℝ ⊗[ℚ] (Fin 4 → ι → ℚ)) : + x ∈ (fourCoordinateKernel (V := ι → ℚ) S).baseChange ℝ ↔ + ∀ k ∈ S, ∀ i, DegreeRankLieFiltration.realFourCoordinateEquiv x ⟨k, i⟩ = 0 := by + have hker : fourCoordinateKernel (V := ι → ℚ) S = + ⨅ k : S, LinearMap.ker (LinearMap.proj (k : Fin 4) : (Fin 4 → ι → ℚ) →ₗ[ℚ] (ι → ℚ)) := by + ext v + constructor + · intro hv + apply (Submodule.mem_iInf _).mpr + intro k + exact (mem_fourCoordinateKernel S v).mp hv k k.property + · intro hv + apply (mem_fourCoordinateKernel S v).mpr + intro k hk + exact (Submodule.mem_iInf _).mp hv ⟨k, hk⟩ + rw [hker, real_baseChange_iInf] + constructor + · intro hx k hk i + have hz := (Submodule.mem_iInf _).mp hx ⟨k, hk⟩ + rw [realification_ker] at hz + have hzero : (LinearMap.proj k : (Fin 4 → ι → ℚ) →ₗ[ℚ] (ι → ℚ)).baseChange ℝ x = 0 := hz + rw [← realCoordinate_projection] + simpa only [map_zero, Pi.zero_apply] using + congrFun (congrArg realRationalCoordinateEquiv hzero) i + · intro hx + apply (Submodule.mem_iInf _).mpr + intro k + rw [realification_ker] + change (LinearMap.proj (k : Fin 4) : (Fin 4 → ι → ℚ) →ₗ[ℚ] (ι → ℚ)).baseChange ℝ x = 0 + apply realRationalCoordinateEquiv.injective + funext i + simpa only [map_zero, Pi.zero_apply, realCoordinate_projection] using hx k k.property i + +theorem mem_realSparseFirstProjection_of_zero + (J : Submodule ℚ (Fin 4 → ι → ℚ)) (S : Finset (Fin 4)) + (y : (Σ _ : Fin 4, ι) → ℝ) (hy : y ∈ realFourCoordinateSpan J) + (hzero : ∀ k ∈ S, ∀ i, y ⟨k, i⟩ = 0) : + (fun i => y ⟨0, i⟩) ∈ realRationalCoordinateSpan (fourSparseFirstProjection J S) := by + obtain ⟨x, hx, rfl⟩ := hy + have hxK := (real_fourCoordinateKernel_mem_iff S x).mpr hzero + have hxJK : x ∈ (J ⊓ fourCoordinateKernel S).baseChange ℝ := by + rw [realification_inf] + exact ⟨hx, hxK⟩ + have hproj : (LinearMap.proj (0 : Fin 4)).baseChange ℝ x ∈ + (fourSparseFirstProjection J S).baseChange ℝ := by + change _ ∈ ((J ⊓ fourCoordinateKernel S).map (LinearMap.proj 0)).baseChange ℝ + rw [realification_map] + exact ⟨x, hxJK, rfl⟩ + have hmem : realRationalCoordinateEquiv ((LinearMap.proj (0 : Fin 4)).baseChange ℝ x) ∈ + realRationalCoordinateSpan (fourSparseFirstProjection J S) := ⟨_, hproj, rfl⟩ + have heq : realRationalCoordinateEquiv ((LinearMap.proj (0 : Fin 4)).baseChange ℝ x) = + fun i => DegreeRankLieFiltration.realFourCoordinateEquiv x ⟨0, i⟩ := by + funext i + exact realCoordinate_projection x 0 i + rwa [heq] at hmem + +theorem realRationalCoordinateSpan_inf (U V : Submodule ℚ (ι → ℚ)) : + realRationalCoordinateSpan (U ⊓ V) = + realRationalCoordinateSpan U ⊓ realRationalCoordinateSpan V := by + unfold realRationalCoordinateSpan + rw [realification_inf] + ext y + constructor + · rintro ⟨x, ⟨hx, hv⟩, rfl⟩ + exact ⟨⟨x, hx, rfl⟩, ⟨x, hv, rfl⟩⟩ + · rintro ⟨⟨x, hx, hxy⟩, ⟨z, hz, hzy⟩⟩ + have hxz : x = z := realRationalCoordinateEquiv.injective (hxy.trans hzy.symm) + exact ⟨x, ⟨hx, hxz.symm ▸ hz⟩, hxy⟩ + +theorem real_fourDependentProjection_eq (J : Submodule ℚ (Fin 4 → ι → ℚ)) : + realRationalCoordinateSpan (fourDependentProjection J) = + realRationalCoordinateSpan (fourSparseFirstProjection J {1, 2}) ⊓ + realRationalCoordinateSpan (fourSparseFirstProjection J {1, 3}) := + realRationalCoordinateSpan_inf _ _ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealifiedCentralBasisAction.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealifiedCentralBasisAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..05053da5a645c9e3a46043303760e214f0d03fd4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealifiedCentralBasisAction.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Estimates.LowerStepSquare + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +variable {ι κ L : Type*} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +variable (e : Basis ι ℚ L) (b : Basis κ ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (l : ℕ) (hl : 0 < l) (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (N : ℕ) (hinner : scaledIntegerGrid N ⊆ bchSubgroupCoordinates b Γ) + +noncomputable def realifiedCentralBasisAction (j : κ) (hj : ∀ w : L, ⁅b j, w⁆ = 0) : + letI := realificationQuotientMetricSpace e Γ l hl houter + CircleFourier.IsometricCircleAction + (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil) ⧸ + Γ.map realificationHom) := + centralBCHCircleAction (e.baseChange ℝ) (Γ.map realificationHom) + (realification_subgroup_closed_discrete e Γ l hl houter).1 + ((N : ℝ) • (b.baseChange ℝ) j) (scaled_real_basis_central b j hj N) + (scaled_real_basis_mem_realification b Γ N hinner j) + +theorem realifiedCentralBasisAction_act_coe (j : κ) (hj : ∀ w : L, ⁅b j, w⁆ = 0) + (r : ℝ) (x : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s + (realification_lowerCentralSeries_eq_bot hnil) ⧸ Γ.map realificationHom) : + letI := realificationQuotientMetricSpace e Γ l hl houter + (realifiedCentralBasisAction e b Γ l hl houter N hinner j hj).act (r : CircleFourier.Circle) x = + realBCHLine (hnil := realification_lowerCentralSeries_eq_bot hnil) + ((N : ℝ) • (b.baseChange ℝ) j) r • x := by + let := realificationQuotientMetricSpace e Γ l hl houter + exact centralBCHCircleAction_act_coe _ _ _ _ _ _ r x + +theorem realifiedCentralBasisAction_displacement (j : κ) (hj : ∀ w : L, ⁅b j, w⁆ = 0) + {B : ℝ} (hB : 0 ≤ B) (hb : ∀ i, |(e.repr (b j) i : ℝ)| ≤ B) + (t : CircleFourier.Circle) (x : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s + (realification_lowerCentralSeries_eq_bot hnil) ⧸ Γ.map realificationHom) : + letI := realificationQuotientMetricSpace e Γ l hl houter + dist ((realifiedCentralBasisAction e b Γ l hl houter N hinner j hj).act t x) x ≤ + ((Fintype.card ι : ℝ) + 1) * ((N : ℝ) * B) * ‖t‖ := by + let := realificationQuotientMetricSpace e Γ l hl houter + apply (centralBCHCircleAction_displacement _ _ _ _ _ _ t x).trans + exact mul_le_mul_of_nonneg_right (scaled_real_basis_coordinate_bound e b N j hB hb) (norm_nonneg t) + +theorem realifiedCentralBasisAction_commutes (i j : κ) + (hi : ∀ w : L, ⁅b i, w⁆ = 0) (hj : ∀ w : L, ⁅b j, w⁆ = 0) : + letI := realificationQuotientMetricSpace e Γ l hl houter + (realifiedCentralBasisAction e b Γ l hl houter N hinner i hi).Commutes + (realifiedCentralBasisAction e b Γ l hl houter N hinner j hj) := by + let := realificationQuotientMetricSpace e Γ l hl houter + exact centralBCHCircleAction_commutes _ _ _ _ _ _ _ _ _ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RealifiedTripleProjections.lean b/lean/OAI/Combinatorics/Progressions/Linear/RealifiedTripleProjections.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6e43554fd80e7305a98f7b6e35a71867e74c44a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RealifiedTripleProjections.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.Progressions.Estimates.RealifiedTripleLayers + +namespace OAI + +section + +namespace Erdos3.MultidegreeLieFiltration + +open scoped TensorProduct + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) + +noncomputable def additiveTripleProjection (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) (j : Fin 3) : + F.additiveTripleSubalgebra i hi c hc →ₗ⁅ℚ⁆ L := + (liePiEval j).comp (F.additiveTripleToPi i hi c hc) + +@[simp] theorem additiveTripleProjection_zero (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) : + F.additiveTripleProjection i hi c hc 0 = F.additiveTripleFirst i hi c hc := rfl + +@[simp] theorem additiveTripleProjection_one (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) : + F.additiveTripleProjection i hi c hc 1 = F.additiveTripleSecond i hi c hc := rfl + +@[simp] theorem additiveTripleProjection_two (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) : + F.additiveTripleProjection i hi c hc 2 = F.additiveTripleThird i hi c hc := rfl + +noncomputable def realAdditiveTripleProjection (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) (j : Fin 3) : + (F.additiveTripleFiltration i hi c hc).realification.Group →* F.realification.Group := + NilpotentLieBCHGroup.realificationMap + (hnil := (F.additiveTripleFiltration i hi c hc).lowerCentralSeries_eq_bot) + (hM := F.ordinary.lowerCentralSeries_eq_bot) (F.additiveTripleProjection i hi c hc j) + +theorem realifiedAdditiveTripleEquiv_projection (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) (j : Fin 3) + (x : ℝ ⊗[ℚ] F.additiveTripleSubalgebra i hi c hc) : + tripleToPi (F.realifiedAdditiveTripleEquiv i hi c hc x).val j = + realificationLieHom (F.additiveTripleProjection i hi c hc j) x := by + rw [F.realifiedAdditiveTripleEquiv_coe] + induction x using TensorProduct.inductionOn with + | tmul r x => + rw [realificationLieHom_tmul, realTripleEquiv_tmul, realificationLieHom_tmul] + fin_cases j <;> rfl + | add x y hx hy => simp only [map_add, Pi.add_apply, hx, hy] + +theorem realAdditiveTripleProjection_coord (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) (j : Fin 3) + (g : (F.additiveTripleFiltration i hi c hc).realification.Group) : + (F.realAdditiveTripleProjection i hi c hc j g).coord = + tripleToPi (F.realifiedAdditiveTripleEquiv i hi c hc g.coord).val j := + (F.realifiedAdditiveTripleEquiv_projection i hi c hc j g.coord).symm + +theorem realAdditiveTripleProjection_jointly_injective (i : σ) (hi : bound i ≤ 1) + (c : σ → ℕ) (hc : ∀ j, c j ≤ 1) + {g h : (F.additiveTripleFiltration i hi c hc).realification.Group} + (heq : ∀ j, F.realAdditiveTripleProjection i hi c hc j g = + F.realAdditiveTripleProjection i hi c hc j h) : g = h := by + apply NilpotentLieBCHGroup.ext + apply (F.realifiedAdditiveTripleEquiv i hi c hc).injective + apply Subtype.ext + apply tripleToPi_injective + funext j + simpa only [F.realAdditiveTripleProjection_coord] using + congrArg NilpotentLieBCHGroup.coord (heq j) + +end Erdos3.MultidegreeLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RecoveredKernelScalarBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RecoveredKernelScalarBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a57359df8a539fe59c7d8d2577970b162b3fc3fa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RecoveredKernelScalarBudget.lean @@ -0,0 +1,158 @@ +import OAI.Combinatorics.Progressions.Geometry.ActualFixedSpatialRetainedPatchEndpoint + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +def recoveredKernelScalarBudget (B : ℝ) : ℝ := 8 * (B + 1) ^ 2 + +theorem recoveredKernelScalarBudget_ge {B : ℝ} (hB : 1 ≤ B) : + 1 ≤ recoveredKernelScalarBudget B ∧ B ≤ recoveredKernelScalarBudget B := by + unfold recoveredKernelScalarBudget + constructor <;> nlinarith [sq_nonneg B] + +theorem recoveredKernelScalarBudget_discounted_score {B score δ : ℝ} + (hB : 1 ≤ B) (hscore : Real.exp (-B) ≤ score) + (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) : + Real.exp (-recoveredKernelScalarBudget B) ≤ (score / 2) / (1 + δ) := by + have hL : B + 4 ≤ recoveredKernelScalarBudget B := by + unfold recoveredKernelScalarBudget + nlinarith [sq_nonneg B] + have hexp4 : (4 : ℝ) ≤ Real.exp 4 := by + linarith only [Real.add_one_le_exp (4 : ℝ)] + have hfour : 4 * Real.exp (-recoveredKernelScalarBudget B) ≤ score := by + calc + _ ≤ Real.exp 4 * Real.exp (-recoveredKernelScalarBudget B) := + mul_le_mul_of_nonneg_right hexp4 (Real.exp_nonneg _) + _ = Real.exp (4 - recoveredKernelScalarBudget B) := by rw [← Real.exp_add]; rfl + _ ≤ Real.exp (-B) := Real.exp_le_exp.mpr (by linarith) + _ ≤ score := hscore + apply (le_div_iff₀ (by linarith : (0 : ℝ) < 1 + δ)).mpr + apply (le_div_iff₀ (by norm_num : (0 : ℝ) < 2)).mpr + have he := Real.exp_nonneg (-recoveredKernelScalarBudget B) + nlinarith + +private theorem mul_exp_bound {x y a b : ℝ} (hx : x ≤ Real.exp a) + (hy : y ≤ Real.exp b) (hy0 : 0 ≤ y) : x * y ≤ Real.exp (a + b) := by + calc + _ ≤ Real.exp a * Real.exp b := mul_le_mul hx hy hy0 (Real.exp_nonneg _) + _ = _ := (Real.exp_add _ _).symm + +theorem recoveredRationalCap_le_exp {B : ℝ} (hB : 1 ≤ B) + (q r : ℕ) (Icap : ℝ≥0) + (hq : (q : ℝ) ≤ Real.exp B) (hr : (r : ℝ) ≤ B) + (hI : (Icap : ℝ) ≤ Real.exp B) : + (Icap : ℝ) * (q : ℝ) ^ r ≤ Real.exp (B + B ^ 2) := by + have hpow : (q : ℝ) ^ r ≤ Real.exp (B ^ 2) := by + calc + _ ≤ (Real.exp B) ^ r := pow_le_pow_left₀ (Nat.cast_nonneg _) hq r + _ = Real.exp ((r : ℝ) * B) := (Real.exp_nat_mul B r).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + exact mul_exp_bound hI hpow (pow_nonneg (Nat.cast_nonneg _) _) + +theorem recoveredKernel_constants_le_exp {B : ℝ} (hB : 1 ≤ B) + (κ Dcap Dlip Rcap K H Tinverse : ℝ≥0) + (hκ : (κ : ℝ) ≤ Real.exp B) (hDcap : (Dcap : ℝ) ≤ Real.exp B) + (hDlip : (Dlip : ℝ) ≤ Real.exp B) + (hRcap : (Rcap : ℝ) ≤ Real.exp (B + B ^ 2)) + (hK : (K : ℝ) ≤ Real.exp B) (hH : (H : ℝ) ≤ Real.exp B) + (hTinverse : (Tinverse : ℝ) ≤ Real.exp B) : + ((κ * (Dcap * Rcap) : ℝ≥0) : ℝ) ≤ Real.exp (recoveredKernelScalarBudget B) ∧ + ((κ * (Rcap * (Dlip * Tinverse)) : ℝ≥0) : ℝ) ≤ + Real.exp (recoveredKernelScalarBudget B) ∧ + ((κ * (Rcap * (Dlip * (K * H))) : ℝ≥0) : ℝ) ≤ + Real.exp (recoveredKernelScalarBudget B) := by + have hDC := mul_exp_bound hDcap hRcap Rcap.coe_nonneg + have hDT := mul_exp_bound hDlip hTinverse Tinverse.coe_nonneg + have hKH := mul_exp_bound hK hH H.coe_nonneg + have hDKH := mul_exp_bound hDlip hKH (mul_nonneg K.coe_nonneg H.coe_nonneg) + have hspace := mul_exp_bound hRcap hDT (mul_nonneg Dlip.coe_nonneg Tinverse.coe_nonneg) + have hlift := mul_exp_bound hRcap hDKH + (mul_nonneg Dlip.coe_nonneg (mul_nonneg K.coe_nonneg H.coe_nonneg)) + have hcap := mul_exp_bound hκ hDC (mul_nonneg Dcap.coe_nonneg Rcap.coe_nonneg) + have hspace' := mul_exp_bound hκ hspace + (mul_nonneg Rcap.coe_nonneg (mul_nonneg Dlip.coe_nonneg Tinverse.coe_nonneg)) + have hlift' := mul_exp_bound hκ hlift + (mul_nonneg Rcap.coe_nonneg + (mul_nonneg Dlip.coe_nonneg (mul_nonneg K.coe_nonneg H.coe_nonneg))) + simp only [NNReal.coe_mul] + refine ⟨hcap.trans ?_, hspace'.trans ?_, hlift'.trans ?_⟩ <;> + apply Real.exp_le_exp.mpr <;> + unfold recoveredKernelScalarBudget <;> nlinarith [sq_nonneg B] + +theorem recoveredKernel_joint_constants_le_exp {B : ℝ} (hB : 1 ≤ B) + (κ Dcap Dlip D Icap H Tinverse : ℝ≥0) (q r : ℕ) + (hDcap : Dcap ≤ D) (hDlip : Dlip ≤ D) + (hjoint : (κ : ℝ) * (D : ℝ) * (Icap : ℝ) ≤ Real.exp B) + (hq : (q : ℝ) ≤ Real.exp B) (hr : (r : ℝ) ≤ B) + (hH : (H : ℝ) ≤ Real.exp B) (hTinverse : (Tinverse : ℝ) ≤ Real.exp B) : + let Rcap : ℝ≥0 := Icap * (q : ℝ≥0) ^ r + ((κ * (Dcap * Rcap) : ℝ≥0) : ℝ) ≤ Real.exp (recoveredKernelScalarBudget B) ∧ + ((κ * (Rcap * (Dlip * Tinverse)) : ℝ≥0) : ℝ) ≤ + Real.exp (recoveredKernelScalarBudget B) ∧ + ((κ * (Rcap * (Dlip * H)) : ℝ≥0) : ℝ) ≤ + Real.exp (recoveredKernelScalarBudget B) := by + have hpow : (q : ℝ) ^ r ≤ Real.exp (B ^ 2) := by + calc + _ ≤ (Real.exp B) ^ r := pow_le_pow_left₀ (Nat.cast_nonneg _) hq r + _ = Real.exp ((r : ℝ) * B) := (Real.exp_nat_mul B r).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + have hbaseCap : (κ : ℝ) * (Dcap : ℝ) * (Icap : ℝ) ≤ Real.exp B := by + apply le_trans _ hjoint + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hDcap κ.coe_nonneg) Icap.coe_nonneg + have hbaseLip : (κ : ℝ) * (Dlip : ℝ) * (Icap : ℝ) ≤ Real.exp B := by + apply le_trans _ hjoint + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hDlip κ.coe_nonneg) Icap.coe_nonneg + have hcap := mul_exp_bound hbaseCap hpow (pow_nonneg (Nat.cast_nonneg _) _) + have hlip := mul_exp_bound hbaseLip hpow (pow_nonneg (Nat.cast_nonneg _) _) + have hspace := mul_exp_bound hlip hTinverse Tinverse.coe_nonneg + have hactive := mul_exp_bound hlip hH H.coe_nonneg + have hexp : Real.exp (B + B ^ 2) ≤ Real.exp (recoveredKernelScalarBudget B) := by + apply Real.exp_le_exp.mpr + unfold recoveredKernelScalarBudget + nlinarith [sq_nonneg B] + have hexp' : Real.exp (B + B ^ 2 + B) ≤ Real.exp (recoveredKernelScalarBudget B) := by + apply Real.exp_le_exp.mpr + unfold recoveredKernelScalarBudget + nlinarith [sq_nonneg B] + dsimp only + simp only [NNReal.coe_mul, NNReal.coe_pow, NNReal.coe_natCast] + constructor + · convert hcap.trans hexp using 1 + first | rfl | ring + constructor + · convert hspace.trans hexp' using 1 + first | rfl | ring + · convert hactive.trans hexp' using 1 + first | rfl | ring + +theorem recoveredKernelScalarBudget_le_power {p B : ℝ} {a : ℕ} + (hp : 2 ≤ p) (hB : 0 ≤ B) (hbudget : B ≤ (p + 2) ^ a) : + recoveredKernelScalarBudget B ≤ (p + 2) ^ (2 * a + 4) := by + apply le_trans _ (spatialPatchExtractionCost_le_power hp hB hbudget) + unfold recoveredKernelScalarBudget spatialPatchExtractionCost + nlinarith [sq_nonneg (B + 1)] + +theorem recoveredPatchExtractionCost_le_power {p B : ℝ} {a : ℕ} + (hp : 2 ≤ p) (hB : 0 ≤ B) (hbudget : B ≤ (p + 2) ^ a) : + spatialPatchExtractionCost (recoveredKernelScalarBudget B) ≤ + (p + 2) ^ (4 * a + 12) := by + have hnonneg : 0 ≤ recoveredKernelScalarBudget B := by + unfold recoveredKernelScalarBudget + positivity + have h := spatialPatchExtractionCost_le_power hp hnonneg + (recoveredKernelScalarBudget_le_power hp hB hbudget) + have he : 2 * (2 * a + 4) + 4 = 4 * a + 12 := by omega + rwa [he] at h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RecursiveLayerRankBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RecursiveLayerRankBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9268578b537659b928e3e9101f10cb89121c63e5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RecursiveLayerRankBudget.lean @@ -0,0 +1,105 @@ +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Tactic +import OAI.Combinatorics.Progressions.Polynomial.PolynomialPatchProductBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem finite_backward_rank_bound {s d₀ : ℕ} + (R : Fin (s + 1) → ℕ) (charge : Fin s → ℕ) + (hbase : R (Fin.last s) ≤ d₀) + (hstep : ∀ j, R j.castSucc ≤ R j.succ + charge j) : + R 0 ≤ d₀ + ∑ j, charge j := by + induction s with + | zero => simpa using hbase + | succ s ih => + have htail := ih (fun j => R j.succ) (fun j => charge j.succ) hbase + (fun j => hstep j.succ) + have hhead := hstep 0 + rw [Fin.sum_univ_succ] + simpa only [Fin.castSucc_zero, Fin.succ_zero_eq_one] using + (hhead.trans (Nat.add_le_add_right htail (charge 0))).trans_eq (by omega) + +theorem recursive_layer_rank_bound {s d₀ d : ℕ} + (D : Fin s → ℕ) (R : Fin (s + 1) → ℕ) + (hbase : R (Fin.last s) ≤ d₀) + (hstep : ∀ j, R j.castSucc ≤ R j.succ + (j.val + 1) * D j) + (hslots : ∑ j, D j ≤ d) : + R 0 ≤ d₀ + ∑ j, (j.val + 1) * D j ∧ + d₀ + ∑ j, (j.val + 1) * D j ≤ d₀ + s * d := by + refine ⟨finite_backward_rank_bound R _ hbase hstep, Nat.add_le_add_left ?_ d₀⟩ + calc + ∑ j, (j.val + 1) * D j ≤ ∑ j, s * D j := by + exact Finset.sum_le_sum (fun j _ => Nat.mul_le_mul_right (D j) (by omega)) + _ = s * ∑ j, D j := (Finset.mul_sum _ _ _).symm + _ ≤ s * d := Nat.mul_le_mul_left s hslots + +theorem recursive_detector_rank_bound {s d₀ d : ℕ} + (D detector : Fin s → ℕ) (R : Fin (s + 1) → ℕ) + (hbase : R (Fin.last s) ≤ d₀) + (hdetector : ∀ j, detector j ≤ (j.val + 1) * D j) + (htransfer : ∀ j, R j.castSucc ≤ detector j + R j.succ) + (hslots : ∑ j, D j ≤ d) : + R 0 ≤ d₀ + ∑ j, (j.val + 1) * D j ∧ R 0 ≤ d₀ + s * d := by + have hstep (j) : R j.castSucc ≤ R j.succ + (j.val + 1) * D j := by + have h := (htransfer j).trans (Nat.add_le_add_right (hdetector j) (R j.succ)) + simpa only [Nat.add_comm] using h + have h := recursive_layer_rank_bound D R hbase hstep hslots + exact ⟨h.1, h.1.trans h.2⟩ + +noncomputable def originalWeightLayerCount {ι : Type*} [Fintype ι] + (w : ι → ℕ) {s : ℕ} (j : Fin s) : ℕ := + (Finset.univ.filter (fun i => w i = j.val + 1)).card + +theorem sum_originalWeightLayerCount {ι : Type*} [Fintype ι] + {s : ℕ} (w : ι → ℕ) (hwpos : ∀ i, 1 ≤ w i) (hwmax : ∀ i, w i ≤ s) : + ∑ j : Fin s, originalWeightLayerCount w j = Fintype.card ι := by + simp only [originalWeightLayerCount, Finset.card_eq_sum_ones, Finset.sum_filter] + rw [Finset.sum_comm] + have hi (i : ι) : (∑ j : Fin s, if w i = j.val + 1 then 1 else 0) = (1 : ℕ) := by + let j : Fin s := ⟨w i - 1, by have := hwpos i; have := hwmax i; omega⟩ + rw [Finset.sum_eq_single j] + · simp only [j] + rw [ite_eq_left (by have := hwpos i; omega)] + · intro l _ hlj + rw [ite_eq_right] + intro h + apply hlj + apply Fin.ext + dsimp [j] + omega + · simp + simp only [hi, Finset.sum_const, Finset.card_univ, smul_eq_mul, mul_one] + +theorem recursive_original_slot_rank_bound {ι : Type*} [Fintype ι] + {s d₀ : ℕ} (w : ι → ℕ) (hwpos : ∀ i, 1 ≤ w i) (hwmax : ∀ i, w i ≤ s) + (detector : Fin s → ℕ) (R : Fin (s + 1) → ℕ) + (hbase : R (Fin.last s) ≤ d₀) + (hdetector : ∀ j, detector j ≤ (j.val + 1) * originalWeightLayerCount w j) + (htransfer : ∀ j, R j.castSucc ≤ detector j + R j.succ) : + R 0 ≤ d₀ + ∑ j : Fin s, (j.val + 1) * originalWeightLayerCount w j ∧ + R 0 ≤ d₀ + s * Fintype.card ι := + recursive_detector_rank_bound (originalWeightLayerCount w) detector R hbase hdetector htransfer + (sum_originalWeightLayerCount w hwpos hwmax).le + +theorem PolynomialPatch.recursive_layer_rank_bound {σ : Type*} {s d d₀ : ℕ} + (B : PolynomialPatch σ s d) + (detector : Fin s → ℕ) (R : Fin (s + 1) → ℕ) + (hbase : R (Fin.last s) ≤ d₀) + (hdetector : ∀ j, detector j ≤ (j.val + 1) * originalWeightLayerCount B.weight j) + (htransfer : ∀ j, R j.castSucc ≤ detector j + R j.succ) : + R 0 ≤ d₀ + ∑ j : Fin s, (j.val + 1) * originalWeightLayerCount B.weight j ∧ + R 0 ≤ d₀ + s * d := by + simpa only [Fintype.card_fin] using recursive_original_slot_rank_bound + B.weight B.weight_pos B.weight_le detector R hbase hdetector htransfer + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ReducedProjectionBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/ReducedProjectionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f56af426a65eefb15795ea8582711d3926f0d89 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ReducedProjectionBounds.lean @@ -0,0 +1,136 @@ +import OAI.Combinatorics.Progressions.Estimates.ReducedNativeFactorization + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + +def reducedSquareDiagonalIndex (s : ℕ) (ω : ι → ℕ) + (i : QuotientTopBasisIndex s ω) : ReducedSquareBasisIndex s ω := + ⟨Sum.inl i.val, i.property⟩ + +def reducedSquareDiagonalSymbolIndex (s : ℕ) (w : σ → ℕ) (ω : ι → ℕ) + (z : QuotientTopSymbolIndex s w ω) : ReducedSquareSymbolIndex s w ω := + ⟨(z.val.1, reducedSquareDiagonalIndex s ω z.val.2), z.property⟩ + +variable (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +theorem reducedSquareSnd_basis_repr [DecidableEq ι] + (a : ReducedSquareBasisIndex s ω) (b : QuotientTopBasisIndex s ω) : + (F.quotientTopBasis e ω hF).repr + (F.reducedSquareSnd (F.reducedSquareBasis e ω hF a)) b = + if a = reducedSquareDiagonalIndex s ω b then 1 else 0 := by + classical + dsimp only [reducedSquareBasis] + rw [F.squareFiltration.quotientTopBasis_apply, F.reducedSquareSnd_mk, + F.quotientTopBasis_repr_mk] + rcases a with ⟨a, ha⟩ + cases a with + | inl i => + change e.repr ((F.adaptedSquareBasis e ω (hF 2) (Sum.inl i)).val.2) b.val = _ + rw [F.adaptedSquareBasis_inl] + simp [reducedSquareDiagonalIndex, Basis.repr_self, Finsupp.single_apply, + Subtype.ext_iff] + | inr i => + change e.repr ((F.adaptedSquareBasis e ω (hF 2) (Sum.inr i)).val.2) b.val = _ + rw [F.adaptedSquareBasis_inr] + simp [reducedSquareDiagonalIndex, Subtype.ext_iff] + +theorem reducedSquareSndSymbolMap_basis_repr [DecidableEq σ] [DecidableEq ι] (w : σ → ℕ) + (a : ReducedSquareSymbolIndex s w ω) (b : QuotientTopSymbolIndex s w ω) : + (F.quotientTopSymbolBasis e ω hF w).repr + (F.reducedSquareSndSymbolMap w (F.reducedSquareSymbolBasis e ω hF w a)) b = + if a = reducedSquareDiagonalSymbolIndex s w ω b then 1 else 0 := by + classical + change (F.quotientTop.polynomialSymbolBasis _ _ _ w).repr + (F.squareFiltration.quotientTop.filteredPolynomialSymbolMap F.quotientTop + F.reducedSquareSnd F.reducedSquareSnd_mem w + (F.squareFiltration.quotientTop.polynomialSymbolBasis _ _ _ w a)) b = _ + rw [filteredPolynomialSymbolMap_basis_repr, F.reducedSquareSnd_basis_repr e ω hF] + simp [reducedSquareDiagonalSymbolIndex, Subtype.ext_iff, Prod.ext_iff, ite_and] + +theorem reducedSquareSndSymbolMap_repr (w : σ → ℕ) + (x : F.squareFiltration.quotientTop.PolynomialSymbol w) + (b : QuotientTopSymbolIndex s w ω) : + (F.quotientTopSymbolBasis e ω hF w).repr (F.reducedSquareSndSymbolMap w x) b = + (F.reducedSquareSymbolBasis e ω hF w).repr x + (reducedSquareDiagonalSymbolIndex s w ω b) := by + classical + have h : ((F.quotientTopSymbolBasis e ω hF w).coord b).comp + (F.reducedSquareSndSymbolMap w).toLinearMap = + (F.reducedSquareSymbolBasis e ω hF w).coord + (reducedSquareDiagonalSymbolIndex s w ω b) := by + apply (F.reducedSquareSymbolBasis e ω hF w).ext + intro a + change (F.quotientTopSymbolBasis e ω hF w).repr + (F.reducedSquareSndSymbolMap w (F.reducedSquareSymbolBasis e ω hF w a)) b = _ + rw [F.reducedSquareSndSymbolMap_basis_repr e ω hF] + simp [Basis.coord_apply, Basis.repr_self, Finsupp.single_apply] + exact DFunLike.congr_fun h x + +theorem reducedSquareRealSymbolHom_repr (w : σ → ℕ) + (g : F.squareFiltration.quotientTop.RealPolynomialSymbolGroup w) + (b : QuotientTopSymbolIndex s w ω) : + ((F.quotientTopSymbolBasis e ω hF w).baseChange ℝ).repr + (F.reducedSquareRealSymbolHom w g).coord b = + ((F.reducedSquareSymbolBasis e ω hF w).baseChange ℝ).repr g.coord + (reducedSquareDiagonalSymbolIndex s w ω b) := by + classical + have h : (((F.quotientTopSymbolBasis e ω hF w).baseChange ℝ).coord b).comp + ((F.reducedSquareSndSymbolMap w).toLinearMap.baseChange ℝ) = + ((F.reducedSquareSymbolBasis e ω hF w).baseChange ℝ).coord + (reducedSquareDiagonalSymbolIndex s w ω b) := by + apply ((F.reducedSquareSymbolBasis e ω hF w).baseChange ℝ).ext + intro a + change ((F.quotientTopSymbolBasis e ω hF w).baseChange ℝ).repr + ((F.reducedSquareSndSymbolMap w).toLinearMap.baseChange ℝ + (((F.reducedSquareSymbolBasis e ω hF w).baseChange ℝ) a)) b = _ + rw [linearMap_baseChange_basis] + change ((F.quotientTopSymbolBasis e ω hF w).repr + (F.reducedSquareSndSymbolMap w (F.reducedSquareSymbolBasis e ω hF w a)) b : ℝ) = _ + rw [F.reducedSquareSndSymbolMap_basis_repr e ω hF] + simp [Basis.coord_apply, Basis.repr_self, Finsupp.single_apply] + split_ifs <;> norm_num + exact DFunLike.congr_fun h g.coord + +theorem reducedSquareRealSymbolHom_slow (w : σ → ℕ) (T : σ → ℝ) (M : ℝ) + (g : F.squareFiltration.quotientTop.RealPolynomialSymbolGroup w) + (hg : F.squareFiltration.quotientTop.SymbolSlowBound (F.reducedSquareBasis e ω hF) + (fun i => squareBasisWeight ω i.val) (F.reducedSquareBasis_layers e ω hF) w T M g) : + F.quotientTop.SymbolSlowBound (F.quotientTopBasis e ω hF) + (fun i => ω i.val) (F.quotientTopBasis_layers e ω hF) w T M + (F.reducedSquareRealSymbolHom w g) := by + intro b + change |((F.quotientTopSymbolBasis e ω hF w).baseChange ℝ).repr + (F.reducedSquareRealSymbolHom w g).coord b| ≤ _ + rw [F.reducedSquareRealSymbolHom_repr e ω hF] + exact hg (reducedSquareDiagonalSymbolIndex s w ω b) + +theorem reducedSquareRealSymbolHom_grid (w : σ → ℕ) (l : ℕ) + (g : F.squareFiltration.quotientTop.RealPolynomialSymbolGroup w) + (hg : F.squareFiltration.quotientTop.SymbolRationalGrid (F.reducedSquareBasis e ω hF) + (fun i => squareBasisWeight ω i.val) (F.reducedSquareBasis_layers e ω hF) w l g) : + F.quotientTop.SymbolRationalGrid (F.quotientTopBasis e ω hF) + (fun i => ω i.val) (F.quotientTopBasis_layers e ω hF) w l + (F.reducedSquareRealSymbolHom w g) := by + obtain ⟨z, hz⟩ := hg + refine ⟨fun b => z (reducedSquareDiagonalSymbolIndex s w ω b), ?_⟩ + funext b + change (z (reducedSquareDiagonalSymbolIndex s w ω b) : ℝ) = + (l : ℝ) * ((F.quotientTopSymbolBasis e ω hF w).baseChange ℝ).repr + (F.reducedSquareRealSymbolHom w g).coord b + rw [F.reducedSquareRealSymbolHom_repr e ω hF] + exact congrFun hz (reducedSquareDiagonalSymbolIndex s w ω b) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ReducedSquareFastKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/ReducedSquareFastKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecc5a52ca25b72c084b79446c1436136b6929432 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ReducedSquareFastKernel.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.Progressions.Estimates.FastCoefficientImage + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (w : σ → ℕ) + (W : LieSubalgebra ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w)) + +noncomputable def reducedSquareFastDiagonalSubalgebra : LieSubalgebra ℚ (F.quotientTop.PolynomialSymbol w) := + W.map (F.reducedSquareSndSymbolMap w) + +noncomputable def reducedSquareFastRelativeSubmodule : Submodule ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w) := + W.toSubmodule ⊓ (F.reducedSquareSndSymbolMap w).ker.toSubmodule + +theorem reducedSquareFastRelative_lie_eq_zero (hw : ∀ i, 0 < w i) + {v z : F.squareFiltration.quotientTop.PolynomialSymbol w} + (hv : v ∈ F.reducedSquareFastRelativeSubmodule w W) (hz : z ∈ F.reducedSquareFastRelativeSubmodule w W) : + ⁅v, z⁆ = 0 := F.reducedSquareSndSymbolKernel_lie_eq_zero w hw hv.2 hz.2 + +theorem reducedSquareFastRelative_action_mem (hw : ∀ i, 0 < w i) + {u : F.quotientTop.PolynomialSymbol w} (hu : u ∈ F.reducedSquareFastDiagonalSubalgebra w W) + {v : F.squareFiltration.quotientTop.PolynomialSymbol w} (hv : v ∈ F.reducedSquareFastRelativeSubmodule w W) : + ⁅F.reducedSquareDiagonalSymbolMap w u, v⁆ ∈ F.reducedSquareFastRelativeSubmodule w W := by + obtain ⟨x, hx, hxu⟩ := hu + change F.reducedSquareSndSymbolMap w x = u at hxu + have hk : F.reducedSquareSndSymbolMap w (x - F.reducedSquareDiagonalSymbolMap w u) = 0 := by + rw [map_sub, F.reducedSquareSndSymbolMap_diagonal, hxu, sub_self] + have hbracket := F.reducedSquareSndSymbolKernel_lie_eq_zero w hw hk hv.2 + rw [sub_lie] at hbracket + have he := sub_eq_zero.mp hbracket + constructor + · rw [← he] + exact W.lie_mem hx hv.1 + · change F.reducedSquareSndSymbolMap w ⁅F.reducedSquareDiagonalSymbolMap w u, v⁆ = 0 + rw [LieHom.map_lie, F.reducedSquareSndSymbolMap_diagonal, show F.reducedSquareSndSymbolMap w v = 0 from hv.2, + lie_zero] + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ReducedSquareGradedKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/ReducedSquareGradedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee23532fe3be433f5750a6192e8bf5ffe6aa894f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ReducedSquareGradedKernel.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.Progressions.Estimates.GradedUnitEvaluation + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) + +theorem quotientTopGradedMap_piece (j : ℕ) (x : F.layer j) : + F.quotientTopGradedMap (F.associatedGradedPieceMap j x) = + F.quotientTop.associatedGradedPieceMap j + ⟨lieQuotientMap (F.layerIdeal (s + 1)) x, + F.quotientLie_mem (F.layerIdeal (s + 1)) (t := s) le_rfl x.property⟩ := + F.quotientGradedMap_piece (F.layerIdeal (s + 1)) (t := s) le_rfl j x + +theorem reducedSquareGradedSnd_piece (j : ℕ) (x : F.squareFiltration.layer j) : + F.reducedSquareGradedSndMap + (F.squareFiltration.quotientTopGradedMap (F.squareFiltration.associatedGradedPieceMap j x)) = + F.quotientTopGradedMap (F.associatedGradedPieceMap j ⟨x.val.val.2, x.property.2.1⟩) := by + simp only [reducedSquareGradedSndMap, quotientTopGradedMap] + rfl + +theorem reducedSquareGradedPiece_kernel_relative (j : ℕ) (hpos : 1 ≤ j) (hj : j ≤ s) + (x : F.squareFiltration.layer j) + (hx : F.reducedSquareGradedSndMap + (F.squareFiltration.quotientTopGradedMap (F.squareFiltration.associatedGradedPieceMap j x)) = 0) : + F.reducedSquareGradedRelativePiece j hpos ⟨x.val.val.1 - x.val.val.2, x.property.2.2⟩ = + F.squareFiltration.quotientTopGradedMap (F.squareFiltration.associatedGradedPieceMap j x) := by + rw [F.reducedSquareGradedSnd_piece] at hx + have hsnd := (F.quotientTopGradedMap_piece_eq_zero_iff j hj _).mp hx + have hd := (F.reducedSquareGradedDiagonalPiece_eq_zero_iff j hj + ⟨x.val.val.2, x.property.2.1⟩).mpr hsnd + have hdec := congrArg F.squareFiltration.quotientTopGradedMap + (F.squareGradedPiece_decomposition j hpos x) + rw [map_add] at hdec + change _ = F.reducedSquareGradedDiagonalPiece j ⟨x.val.val.2, x.property.2.1⟩ + + F.reducedSquareGradedRelativePiece j hpos ⟨x.val.val.1 - x.val.val.2, x.property.2.2⟩ at hdec + rw [hd, zero_add] at hdec + exact hdec.symm + +variable (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +local notation "ωW" => (fun a : ReducedSquareBasisIndex s ω => squareBasisWeight ω (Subtype.val a)) +local notation "bW" => F.squareFiltration.quotientTop.associatedGradedBasis + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) + +theorem exists_reducedSquareGradedRelativePiece_of_pure_kernel + (j : ℕ) (hpos : 1 ≤ j) (hj : j ≤ s) + (y : F.squareFiltration.quotientTop.AssociatedGraded) + (hy : basisGradeProjection bW ωW j y = y) (hker : F.reducedSquareGradedSndMap y = 0) : + ∃ x : F.layer (j + 1), F.reducedSquareGradedRelativePiece j hpos x = y := by + obtain ⟨q, hq⟩ := F.squareFiltration.quotientTop.exists_associatedGradedPieceMap_of_pure + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF) j y hy + obtain ⟨x, hx, hxq⟩ := q.property + have he : F.squareFiltration.quotientTopGradedMap + (F.squareFiltration.associatedGradedPieceMap j ⟨x, hx⟩) = y := by + rw [F.squareFiltration.quotientTopGradedMap_piece] + refine Eq.trans ?_ hq + apply congrArg (F.squareFiltration.quotientTop.associatedGradedPieceMap j) + exact Subtype.ext hxq + refine ⟨⟨x.val.1 - x.val.2, hx.2.2⟩, ?_⟩ + exact (F.reducedSquareGradedPiece_kernel_relative j hpos hj ⟨x, hx⟩ + (by rw [he]; exact hker)).trans he + +theorem reducedSquareGradedDifference_relativePiece (j : ℕ) (hj : 1 ≤ j) + (x : F.layer (j + 1)) : + F.reducedSquareGradedDifference e ω hF (F.reducedSquareGradedRelativePiece j hj x) = + F.associatedGradedPieceMap (j + 1) x := by + change F.reducedSquareGradedDifference e ω hF + (F.squareFiltration.quotientTopGradedMap + (F.squareFiltration.associatedGradedPieceMap j (F.squareRelativeLayer j hj x))) = _ + rw [F.squareFiltration.quotientTopGradedMap_piece, + ← F.squareFiltration.quotientTop.gradedPieceProjection_eq_pieceMap + (F.reducedSquareBasis e ω hF) ωW (F.reducedSquareBasis_layers e ω hF)] + rw [F.reducedSquareGradedDifference_projection, F.reducedSquareDifference_mk] + change F.gradedPieceProjection e ω hF (j + 1) ((x : L) - 0) = _ + rw [sub_zero, F.gradedPieceProjection_eq_pieceMap] + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RefilteredKernelConstantBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/RefilteredKernelConstantBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0bda65a50a584dafdcec8f3e1b0ab816cf73129 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RefilteredKernelConstantBounds.lean @@ -0,0 +1,307 @@ +import Mathlib.Algebra.Order.Floor.Ring +import OAI.Combinatorics.Progressions.Estimates.StrongRefiltrationReconstruction + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open scoped TensorProduct + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M s) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + +include hφ in + +theorem realificationLieHom_layer_surjective + (hsurj : ∀ j, ∀ y ∈ G.layer j, ∃ x ∈ F.layer j, φ x = y) + (j : ℕ) (y : ℝ ⊗[ℚ] M) (hy : y ∈ G.realification.layer j) : + ∃ x ∈ F.realification.layer j, realificationLieHom φ x = y := by + have hmap : (F.layer j).map φ.toLinearMap = G.layer j := by + apply le_antisymm + · rintro _ ⟨x, hx, rfl⟩ + exact hφ j x hx + · intro y hy + obtain ⟨x, hx, hxy⟩ := hsurj j y hy + exact ⟨x, hx, hxy⟩ + have hreal : ((F.layer j).baseChange ℝ).map (φ.toLinearMap.baseChange ℝ) = + (G.layer j).baseChange ℝ := by + rw [← realification_map, hmap] + change y ∈ (G.layer j).baseChange ℝ at hy + rw [← hreal] at hy + obtain ⟨x, hx, hxy⟩ := hy + exact ⟨x, hx, hxy⟩ + +theorem realificationLieHom_top_kernel_eq_zero + (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ G.layer j) + (hinj : ∀ x ∈ F.layer s, φ x = 0 → x = 0) + (x : ℝ ⊗[ℚ] L) (hx : x ∈ F.realification.layer s) + (hzero : realificationLieHom φ x = 0) : x = 0 := by + let f := (G.layer s).subtype.comp (φ.toLinearMap.restrict (hφ s)) + have hker : LinearMap.ker f = ⊥ := by + apply bot_unique + intro z hz + change z = 0 + exact Subtype.ext (hinj z z.property hz) + have hkerReal : LinearMap.ker (f.baseChange ℝ) = ⊥ := by + rw [← realification_ker, hker, Submodule.baseChange_bot] + change x ∈ LinearMap.range ((F.layer s).subtype.baseChange ℝ) at hx + obtain ⟨z, hz⟩ := hx + have hfz : f.baseChange ℝ z = 0 := by + rw [show f = φ.toLinearMap.comp (F.layer s).subtype from rfl, LinearMap.baseChange_comp] + change φ.toLinearMap.baseChange ℝ ((F.layer s).subtype.baseChange ℝ z) = 0 + rw [hz] + exact hzero + have hz0 : z = 0 := by + have hm : z ∈ LinearMap.ker (f.baseChange ℝ) := hfz + rwa [hkerReal, Submodule.mem_bot] at hm + rw [← hz, hz0, map_zero] + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3 +open Module +open scoped TensorProduct BigOperators + +theorem realification_fractional_integer_split {ι V : Type*} [Fintype ι] + [AddCommGroup V] [Module ℚ V] (b : Basis ι ℚ V) (x : ℝ ⊗[ℚ] V) : + ∃ (e : ℝ ⊗[ℚ] V) (r : V), + x = e + (1 : ℝ) ⊗ₜ[ℚ] r ∧ + (∀ i, 0 ≤ (b.baseChange ℝ).repr e i ∧ (b.baseChange ℝ).repr e i < 1) ∧ + ∀ i, ∃ z : ℤ, b.repr r i = z := by + let B := b.baseChange ℝ + let r := b.equivFun.symm (fun i => (⌊B.repr x i⌋ : ℚ)) + let e := x - (1 : ℝ) ⊗ₜ[ℚ] r + have hr (i) : b.repr r i = (⌊B.repr x i⌋ : ℚ) := by + change b.equivFun (b.equivFun.symm _) i = _ + rw [LinearEquiv.apply_symm_apply] + have he (i) : B.repr e i = Int.fract (B.repr x i) := by + change B.repr (x - (1 : ℝ) ⊗ₜ[ℚ] r) i = _ + rw [map_sub, Finsupp.sub_apply, Module.Basis.baseChange_repr_tmul (S := ℝ), hr] + simp only [Rat.smul_def, Rat.cast_intCast, mul_one] + rfl + refine ⟨e, r, by dsimp [e]; abel, ?_, fun i => ⟨⌊B.repr x i⌋, hr i⟩⟩ + intro i + change 0 ≤ B.repr e i ∧ B.repr e i < 1 + rw [he] + exact ⟨Int.fract_nonneg _, Int.fract_lt_one _⟩ + +theorem exists_fractional_integer_kernel_correction + {ι L M : Type*} [Fintype ι] [AddCommGroup L] [Module ℚ L] + [AddCommGroup M] [Module ℚ M] (φ : L →ₗ[ℚ] M) + (H : Submodule ℚ L) (b : Basis ι ℚ (LinearMap.ker φ)) + (x : ℝ ⊗[ℚ] L) (hx : φ.baseChange ℝ x ∈ (H.map φ).baseChange ℝ) : + ∃ (e : ℝ ⊗[ℚ] LinearMap.ker φ) (r : LinearMap.ker φ), + (∀ i, 0 ≤ (b.baseChange ℝ).repr e i ∧ (b.baseChange ℝ).repr e i < 1) ∧ + (∀ i, ∃ z : ℤ, b.repr r i = z) ∧ + x - (LinearMap.ker φ).subtype.baseChange ℝ e - + (1 : ℝ) ⊗ₜ[ℚ] (r : L) ∈ H.baseChange ℝ := by + rw [realification_map] at hx + obtain ⟨y, hy, hxy⟩ := hx + have hk : x - y ∈ (LinearMap.ker φ).baseChange ℝ := by + rw [realification_ker, LinearMap.mem_ker, map_sub, hxy, sub_self] + obtain ⟨k, hk⟩ := hk + obtain ⟨e, r, heq, he, hr⟩ := realification_fractional_integer_split b k + refine ⟨e, r, he, hr, ?_⟩ + have heq' := congrArg ((LinearMap.ker φ).subtype.baseChange ℝ) heq + rw [hk, map_add, LinearMap.baseChange_tmul] at heq' + change x - y = (LinearMap.ker φ).subtype.baseChange ℝ e + (1 : ℝ) ⊗ₜ[ℚ] (r : L) at heq' + have hfinal : x - (LinearMap.ker φ).subtype.baseChange ℝ e - + (1 : ℝ) ⊗ₜ[ℚ] (r : L) = y := by + rw [show x = (x - y) + y by abel, heq'] + abel + rwa [hfinal] + +namespace NilpotentLieFiltration + +variable {ι L M : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (H : Submodule ℚ L) (hH : F.layer 2 ≤ H) + (b : Basis ι ℚ (LinearMap.ker φ.toLinearMap)) + +include hH + +theorem exists_kernel_constant_factors (g : F.realification.Group) + (hg : realificationLieHom φ g.coord ∈ (H.map φ.toLinearMap).baseChange ℝ) : + ∃ (e : ℝ ⊗[ℚ] LinearMap.ker φ.toLinearMap) (r : LinearMap.ker φ.toLinearMap), + (∀ i, 0 ≤ (b.baseChange ℝ).repr e i ∧ (b.baseChange ℝ).repr e i < 1) ∧ + (∀ i, ∃ z : ℤ, b.repr r i = z) ∧ + let kE : F.realification.Group := ⟨(LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ e⟩ + let kR : F.realification.Group := ⟨(1 : ℝ) ⊗ₜ[ℚ] (r : L)⟩ + NilpotentLieBCHGroup.realificationMap (hnil := F.lowerCentralSeries_eq_bot) + (hM := G.lowerCentralSeries_eq_bot) φ kE = 1 ∧ + NilpotentLieBCHGroup.realificationMap (hnil := F.lowerCentralSeries_eq_bot) + (hM := G.lowerCentralSeries_eq_bot) φ kR = 1 ∧ + (kE⁻¹ * g * kR⁻¹).coord ∈ H.baseChange ℝ := by + obtain ⟨e, r, he, hr, hlin⟩ := + exists_fractional_integer_kernel_correction φ.toLinearMap H b g.coord hg + refine ⟨e, r, he, hr, ?_⟩ + dsimp only + refine ⟨?_, ?_, ?_⟩ + · apply NilpotentLieBCHGroup.ext + change φ.toLinearMap.baseChange ℝ + ((LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ e) = 0 + have hm : (LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ e ∈ + (LinearMap.ker φ.toLinearMap).baseChange ℝ := ⟨e, rfl⟩ + rwa [realification_ker, LinearMap.mem_ker] at hm + · apply NilpotentLieBCHGroup.ext + change φ.toLinearMap.baseChange ℝ ((1 : ℝ) ⊗ₜ[ℚ] (r : L)) = 0 + rw [LinearMap.baseChange_tmul, show φ.toLinearMap (r : L) = 0 from r.property, + TensorProduct.tmul_zero] + · let a := (LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ e + let c := (1 : ℝ) ⊗ₜ[ℚ] (r : L) + have hbch := F.realification.bch_triple_sub_sum_mem_next_layer 1 (-a) g.coord (-c) + (by rw [F.realification.one_eq_top]; trivial) + (by rw [F.realification.one_eq_top]; trivial) + have hm : lieBCH s (lieBCH s (-a) g.coord) (-c) - (-a + g.coord + -c) ∈ + H.baseChange ℝ := Submodule.baseChange_mono ℝ hH hbch + have hlin' : -a + g.coord + -c ∈ H.baseChange ℝ := by + convert hlin using 1 + dsimp [a, c] + abel + have hh := (H.baseChange ℝ).add_mem hm hlin' + simpa only [sub_add_cancel, NilpotentLieBCHGroup.coord_mul, + NilpotentLieBCHGroup.coord_inv] using hh + +end NilpotentLieFiltration + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct BigOperators + +section Linear + +variable {ι κ V L : Type*} [Fintype κ] [AddCommGroup V] [Module ℚ V] + [AddCommGroup L] [Module ℚ L] + +theorem scalarExtension_coordinate_sum (b : Basis ι ℚ L) (bk : Basis κ ℚ V) + (f : V →ₗ[ℚ] L) (x : ℝ ⊗[ℚ] V) (i : ι) : + (b.baseChange ℝ).repr (f.baseChange ℝ x) i = + ∑ j, (bk.baseChange ℝ).repr x j * (b.repr (f (bk j)) i : ℝ) := by + classical + conv_lhs => rw [← (bk.baseChange ℝ).sum_repr x] + simp only [map_sum, map_smul, Finsupp.coe_finsetSum, Finset.sum_apply, + Finsupp.smul_apply, smul_eq_mul, scalarExtension_basis_coordinates] + +theorem scalarExtension_fractional_coordinates_bound + (b : Basis ι ℚ L) (bk : Basis κ ℚ V) (f : V →ₗ[ℚ] L) + (H : ℝ) + (hentries : ∀ i j, |(b.repr (f (bk j)) i : ℝ)| ≤ H) + (x : ℝ ⊗[ℚ] V) + (hx : ∀ j, 0 ≤ (bk.baseChange ℝ).repr x j ∧ (bk.baseChange ℝ).repr x j < 1) + (i : ι) : + |(b.baseChange ℝ).repr (f.baseChange ℝ x) i| ≤ (Fintype.card κ : ℝ) * H := by + rw [scalarExtension_coordinate_sum b bk f x i] + calc + _ ≤ ∑ j, |(bk.baseChange ℝ).repr x j * (b.repr (f (bk j)) i : ℝ)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : κ, H := by + apply Finset.sum_le_sum + intro j _ + rw [abs_mul, abs_of_nonneg (hx j).1] + exact (mul_le_mul (hx j).2.le (hentries i j) (abs_nonneg _) (by norm_num)).trans + (by rw [one_mul]) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + +theorem integral_basis_image_denominatorGrid + (b : Basis ι ℚ L) (bk : Basis κ ℚ V) (f : V →ₗ[ℚ] L) + (q : ℕ) (hentries : ∀ j, (fun i => b.repr (f (bk j)) i) ∈ denominatorGrid q) + (r : V) (hr : ∀ j, ∃ z : ℤ, bk.repr r j = z) : + (fun i => b.repr (f r) i) ∈ denominatorGrid q := by + classical + choose z hz using hr + choose a ha using hentries + refine ⟨fun i => ∑ j, z j * a j i, ?_⟩ + intro i + change (q : ℚ) * b.repr (f r) i = ((∑ j, z j * a j i : ℤ) : ℚ) + conv_lhs => rw [← bk.sum_repr r] + simp only [map_sum, map_smul, Finsupp.coe_finsetSum, Finset.sum_apply, + Finsupp.smul_apply, smul_eq_mul, Int.cast_sum, Int.cast_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + have hj : (q : ℚ) * b.repr (f (bk j)) i = (a j i : ℚ) := ha j i + rw [hz, ← hj] + ring + +theorem integral_basis_image_realDenominatorGrid + (b : Basis ι ℚ L) (bk : Basis κ ℚ V) (f : V →ₗ[ℚ] L) + (q : ℕ) (hentries : ∀ j, (fun i => b.repr (f (bk j)) i) ∈ denominatorGrid q) + (r : V) (hr : ∀ j, ∃ z : ℤ, bk.repr r j = z) : + (fun i => (b.baseChange ℝ).repr ((1 : ℝ) ⊗ₜ[ℚ] f r) i) ∈ realDenominatorGrid q := by + have h := integral_basis_image_denominatorGrid b bk f q hentries r hr + have hreal := (real_cast_mem_denominatorGrid_iff q (fun i => b.repr (f r) i)).mpr h + simpa only [Basis.baseChange_repr_tmul (S := ℝ), Rat.smul_def, mul_one] using hreal + +theorem exists_basis_image_bounds_of_height [Fintype ι] + (b : Basis ι ℚ L) (bk : Basis κ ℚ V) (f : V →ₗ[ℚ] L) + (H : ℕ) (hentries : ∀ i j, RationalHeightLE (b.repr (f (bk j)) i) H) : + ∃ q : ℕ, 0 < q ∧ q ≤ H ^ (Fintype.card ι * Fintype.card κ) ∧ + (∀ i j, |(b.repr (f (bk j)) i : ℝ)| ≤ H) ∧ + ∀ j, (fun i => b.repr (f (bk j)) i) ∈ denominatorGrid q := by + classical + let A : Matrix ι κ ℚ := fun i j => b.repr (f (bk j)) i + refine ⟨matrixDenominator A, matrixDenominator_pos A, + matrixDenominator_le A hentries, fun i j => (hentries i j).abs_real_le, ?_⟩ + intro j + refine ⟨fun i => clearedMatrix A i j, fun i => ?_⟩ + exact (congrFun (congrFun (clearedMatrix_cast A) i) j).symm + +end Linear + +namespace NilpotentLieFiltration + +variable {ι κ L M : Type*} [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t : ℕ} + +theorem exists_kernel_constant_factors_with_bounds + (F : NilpotentLieFiltration L s) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (S : Submodule ℚ L) (hS : F.layer 2 ≤ S) + (b : Basis ι ℚ L) (bk : Basis κ ℚ (LinearMap.ker φ.toLinearMap)) + (H : ℝ) (q : ℕ) + (hbound : ∀ i j, |(b.repr (bk j : L) i : ℝ)| ≤ H) + (hgrid : ∀ j, (fun i => b.repr (bk j : L) i) ∈ denominatorGrid q) + (g : F.realification.Group) + (hg : realificationLieHom φ g.coord ∈ (S.map φ.toLinearMap).baseChange ℝ) : + ∃ (e : ℝ ⊗[ℚ] LinearMap.ker φ.toLinearMap) (r : LinearMap.ker φ.toLinearMap), + (∀ j, 0 ≤ (bk.baseChange ℝ).repr e j ∧ (bk.baseChange ℝ).repr e j < 1) ∧ + (∀ j, ∃ z : ℤ, bk.repr r j = z) ∧ + let kE : F.realification.Group := ⟨(LinearMap.ker φ.toLinearMap).subtype.baseChange ℝ e⟩ + let kR : F.realification.Group := ⟨(1 : ℝ) ⊗ₜ[ℚ] (r : L)⟩ + (∀ i, |(b.baseChange ℝ).repr kE.coord i| ≤ (Fintype.card κ : ℝ) * H) ∧ + (fun i => (b.baseChange ℝ).repr kR.coord i) ∈ realDenominatorGrid q ∧ + NilpotentLieBCHGroup.realificationMap (hnil := F.lowerCentralSeries_eq_bot) + (hM := G.lowerCentralSeries_eq_bot) φ kE = 1 ∧ + NilpotentLieBCHGroup.realificationMap (hnil := F.lowerCentralSeries_eq_bot) + (hM := G.lowerCentralSeries_eq_bot) φ kR = 1 ∧ + (kE⁻¹ * g * kR⁻¹).coord ∈ S.baseChange ℝ := by + obtain ⟨e, r, he, hr, hfac⟩ := F.exists_kernel_constant_factors G φ S hS bk g hg + refine ⟨e, r, he, hr, ?_⟩ + dsimp only + refine ⟨?_, ?_, hfac⟩ + · exact scalarExtension_fractional_coordinates_bound b bk + (LinearMap.ker φ.toLinearMap).subtype H hbound e he + · exact integral_basis_image_realDenominatorGrid b bk + (LinearMap.ker φ.toLinearMap).subtype q hgrid r hr + +end NilpotentLieFiltration + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RefiltrationLayerBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/RefiltrationLayerBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..0809615ed44e4c32f8f49f46fbadc670270dfb48 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RefiltrationLayerBasis.lean @@ -0,0 +1,110 @@ +import OAI.Combinatorics.Progressions.Estimates.GradedUnitEvaluation + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem span_selected_basis {ι V : Type*} [AddCommGroup V] [Module ℚ V] + (b : Basis ι ℚ V) (S : Set ι) [DecidablePred (· ∈ S)] : + Submodule.span ℚ (Set.range (fun i => if i ∈ S then b i else 0)) = + Submodule.span ℚ (b '' S) := by + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨i, rfl⟩ + change (if i ∈ S then b i else 0) ∈ Submodule.span ℚ (b '' S) + split_ifs with hi + · exact Submodule.subset_span ⟨i, hi, rfl⟩ + · exact Submodule.zero_mem _ + · apply Submodule.span_le.mpr + rintro _ ⟨i, hi, rfl⟩ + simpa only [ite_eq_left hi] using + (Submodule.subset_span (s := Set.range (fun i => if i ∈ S then b i else 0)) ⟨i, rfl⟩) + +namespace NilpotentLieFiltration + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) + +theorem exists_refiltration_layer_basis_of_quotient + {κ : Type*} [Fintype κ] (W : LieSubalgebra ℚ F.AssociatedGraded) + (f : Basis κ ℚ (F.AssociatedGraded ⧸ W.toSubmodule)) {H : ℕ} (hH : 1 ≤ H) + (hf : ∀ i k, RationalHeightLE + (f.repr (W.toSubmodule.mkQ (F.associatedGradedBasis b w hlayers i)) k) H) (j : ℕ) : + ∃ r : ℕ, r ≤ Fintype.card κ ∧ + ∃ e : Basis (Fin (finrank ℚ (F.gradedRefiltrationLayer W j))) ℚ (F.gradedRefiltrationLayer W j), + ∀ i k, RationalHeightLE (b.repr (e i : L) k) + ((Fintype.card ι + 1) * rationalKernelHeight r H ^ Fintype.card ι) := by + classical + let v : ι → L := fun i => if j ≤ w i then b i else 0 + let P := W.toSubmodule.mkQ.comp (F.gradedPieceProjection b w hlayers j) + have hv : ∀ i k, RationalHeightLE (b.repr (v i) k) 1 := by + intro i k + dsimp [v] + split_ifs + · exact basis_repr_height_one b i k + · simpa only [map_zero, Finsupp.zero_apply] using rationalHeightLE_zero (by decide : 1 ≤ 1) + have hPv : ∀ i k, RationalHeightLE (f.repr (P (v i)) k) H := by + intro i k + dsimp only [P, v, LinearMap.comp_apply] + split_ifs + · rw [F.gradedPieceProjection_basis] + split_ifs + · exact hf i k + · simpa only [map_zero, Finsupp.zero_apply] using rationalHeightLE_zero hH + · simpa only [map_zero, Finsupp.zero_apply] using rationalHeightLE_zero hH + have hspan : Submodule.span ℚ (Set.range v) = F.layer j := by + rw [hlayers j] + exact span_selected_basis b {i | j ≤ w i} + have hker : F.layer j ⊓ LinearMap.ker P = F.gradedRefiltrationLayer W j := by + rw [F.gradedRefiltrationLayer_eq_inf_comap b w hlayers W j] + dsimp only [P] + rw [LinearMap.ker_comp, Submodule.ker_mkQ] + obtain ⟨r, hr, z, hz, hheight⟩ := exists_bounded_span_kernel_generators b f P v hH hv hPv + rw [hspan, hker] at hz + have hh : ∀ i k, RationalHeightLE (b.repr (z i) k) + ((Fintype.card ι + 1) * rationalKernelHeight r H ^ Fintype.card ι) := by + simpa only [mul_one] using hheight + obtain ⟨e, he⟩ := exists_bounded_submodule_basis_from_spanning b _ z hz hh + exact ⟨r, hr, e, he⟩ + +theorem exists_uniform_refiltration_layer_bases + {κ : Type*} [Fintype κ] (W : LieSubalgebra ℚ F.AssociatedGraded) + (v : κ → F.AssociatedGraded) (hspan : Submodule.span ℚ (Set.range v) = W.toSubmodule) + {H : ℕ} (hH : 1 ≤ H) + (hv : ∀ i k, RationalHeightLE ((F.associatedGradedBasis b w hlayers).repr (v i) k) H) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) (hHp : (H : ℝ) ≤ Real.exp p) : + ∃ B : ℕ, 1 ≤ B ∧ (B : ℝ) ≤ Real.exp ((p + (p + 2) ^ 7 + 2) ^ 9) ∧ + ∀ j, ∃ e : Basis (Fin (finrank ℚ (F.gradedRefiltrationLayer W j))) ℚ (F.gradedRefiltrationLayer W j), + ∀ i k, RationalHeightLE (b.repr (e i : L) k) B := by + obtain ⟨A, hA, hAp, d, hdim, f, hf⟩ := exists_submodule_quotient_basis_exp + (F.associatedGradedBasis b w hlayers) W.toSubmodule v hspan hH hv hp hκ hHp + let B := (Fintype.card ι + 1) * rationalKernelHeight (Fintype.card ι) A ^ Fintype.card ι + have hB : 1 ≤ B := by + exact Nat.mul_le_mul (Nat.le_add_left 1 _) (one_le_pow₀ (rationalKernelHeight_pos _ hA)) + let q := p + (p + 2) ^ 7 + have hpq : p ≤ q := le_add_of_nonneg_right (by positivity) + have hq : 0 ≤ q := hp.trans hpq + have hAq : (A : ℝ) ≤ Real.exp q := hAp.trans (Real.exp_le_exp.mpr (by dsimp [q]; linarith)) + have hBp : (B : ℝ) ≤ Real.exp ((q + 2) ^ 9) := + stepDrop_basis_height_budget _ _ A hq (hd.trans hpq) (hd.trans hpq) hAq + refine ⟨B, hB, hBp, ?_⟩ + intro j + obtain ⟨r, hr, e, he⟩ := F.exists_refiltration_layer_basis_of_quotient b w hlayers W f hA + (fun i k => hf k i) j + have hrd : r ≤ d := by simpa only [Fintype.card_fin] using hr + have hrι : r ≤ Fintype.card ι := hrd.trans hdim + refine ⟨e, fun i k => (he i k).mono ?_⟩ + exact Nat.mul_le_mul_left _ (Nat.pow_le_pow_left (rationalKernelHeight_mono hA hrι) _) + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ReindexGradedBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/ReindexGradedBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1b00bbea0dd736c9d9aadb3a72ac8da94fe6fda --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ReindexGradedBasis.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Fourier.HomogeneousGradedProjectionFrequency + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem basisGradeProjection_reindex {K V ι κ : Type*} [Field K] [AddCommGroup V] [Module K V] + (b : Basis ι K V) (ω : ι → ℕ) (e : ι ≃ κ) (j : ℕ) : + basisGradeProjection (b.reindex e) (fun k => ω (e.symm k)) j = basisGradeProjection b ω j := by + apply LinearMap.ext + intro x + apply (b.reindex e).repr.injective + ext k + simp only [basisGradeProjection_repr, Basis.repr_reindex_apply] + +theorem basisGradedSubmodule_reindex_iff {K V ι κ : Type*} [Field K] + [AddCommGroup V] [Module K V] (b : Basis ι K V) (ω : ι → ℕ) (e : ι ≃ κ) + (U : Submodule K V) : + BasisGradedSubmodule (b.reindex e) (fun k => ω (e.symm k)) U ↔ BasisGradedSubmodule b ω U := by + simp only [BasisGradedSubmodule, basisGradeProjection_reindex] + +namespace NilpotentLieFiltration + +variable {ι κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) (e : ι ≃ κ) + (hF' : ∀ j, F.layer j = Submodule.span ℚ ((b.reindex e) '' {k | j ≤ ω (e.symm k)})) + +theorem associatedGradedBasis_reindex : + F.associatedGradedBasis (b.reindex e) (fun k => ω (e.symm k)) hF' = + (F.associatedGradedBasis b ω hF).reindex e := by + apply DFunLike.ext + intro k + rw [Basis.reindex_apply] + rw [← F.associatedGradedPieceMap_basis (b.reindex e) (fun k => ω (e.symm k)) hF' + (ω (e.symm k)) k le_rfl rfl, + ← F.associatedGradedPieceMap_basis b ω hF (ω (e.symm k)) (e.symm k) le_rfl rfl] + congr 1 + apply Subtype.ext + exact Basis.reindex_apply b e k + +theorem gradedFrequency_reindex (η : L →ₗ[ℚ] ℚ) : + F.gradedFrequency (b.reindex e) (fun k => ω (e.symm k)) hF' η = + F.gradedFrequency b ω hF η := by + apply LinearMap.ext + intro x + change η ((b.reindex e).repr.symm + ((F.associatedGradedBasis (b.reindex e) (fun k => ω (e.symm k)) hF').repr x)) = + η (b.repr.symm ((F.associatedGradedBasis b ω hF).repr x)) + rw [F.associatedGradedBasis_reindex b ω hF e hF'] + apply congrArg η + apply (b.reindex e).repr.injective + ext k + simp only [LinearEquiv.apply_symm_apply, Basis.repr_reindex_apply] + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ReindexQuotientBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/ReindexQuotientBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..72f6a86cc1bf9f1043f72b6ee4c4fda6e18f0e1b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ReindexQuotientBasis.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformFrozenDescent + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι κ : Type*} + +def reindexWeightSurvivors (s : ℕ) (ω : ι → ℕ) (e : ι ≃ κ) : + QuotientTopBasisIndex s ω ≃ QuotientTopBasisIndex s (fun k => ω (e.symm k)) where + toFun i := ⟨e i.val, by simpa only [Equiv.symm_apply_apply] using i.property⟩ + invFun i := ⟨e.symm i.val, i.property⟩ + left_inv i := by apply Subtype.ext; exact e.symm_apply_apply i.val + right_inv i := by apply Subtype.ext; exact e.apply_symm_apply i.val + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem quotientTopBasis_reindex (e : ι ≃ κ) + (hF' : ∀ j, F.layer j = Submodule.span ℚ ((b.reindex e) '' {k | j ≤ ω (e.symm k)})) : + F.quotientTopBasis (b.reindex e) (fun k => ω (e.symm k)) hF' = + (F.quotientTopBasis b ω hF).reindex (reindexWeightSurvivors s ω e) := by + apply DFunLike.ext + intro i + simp only [F.quotientTopBasis_apply, Basis.reindex_apply] + rfl + +variable [Fintype ι] + +noncomputable def reducedSquareFinIndexEquiv (s : ℕ) (ω : ι → ℕ) : + ReducedSquareBasisIndex s ω ≃ + Fin (Fintype.card {i // ¬ s + 1 ≤ squareFinWeight ω i}) := + (reindexWeightSurvivors s (squareBasisWeight ω) (Fintype.equivFin _)).trans (Fintype.equivFin _) + +theorem reducedSquareFinIndexEquiv_weight + (i : Fin (Fintype.card {i // ¬ s + 1 ≤ squareFinWeight ω i})) : + quotientFinWeight (squareFinWeight ω) {i | s + 1 ≤ squareFinWeight ω i} i = + squareBasisWeight ω ((reducedSquareFinIndexEquiv s ω).symm i).val := rfl + +theorem squareTopQuotientModel_basis_reindex (Γ : Subgroup F.squareFiltration.Group) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates (F.squareFinBasis b ω (hF 2)) Γ) + (hout : bchSubgroupCoordinates (F.squareFinBasis b ω (hF 2)) Γ ⊆ denominatorGrid N) : + (F.squareFiltration.topQuotientModel (F.squareFinBasis b ω (hF 2)) (squareFinWeight ω) + (F.squareFinBasis_layers b ω hF) Γ N hN hin hout).basis = + (F.reducedSquareBasis b ω hF).reindex (reducedSquareFinIndexEquiv s ω) := by + change (F.squareFiltration.quotientTopBasis (F.squareFinBasis b ω (hF 2)) (squareFinWeight ω) + (F.squareFinBasis_layers b ω hF)).reindex (Fintype.equivFin _) = _ + have hb := F.squareFiltration.quotientTopBasis_reindex + (F.adaptedSquareBasis b ω (hF 2)) (squareBasisWeight ω) (F.adaptedSquareBasis_layers b ω hF) + (Fintype.equivFin _) (F.squareFinBasis_layers b ω hF) + calc + _ = ((F.reducedSquareBasis b ω hF).reindex + (reindexWeightSurvivors s (squareBasisWeight ω) (Fintype.equivFin _))).reindex + (Fintype.equivFin _) := congrArg (fun c => c.reindex (Fintype.equivFin _)) hb + _ = _ := by + apply DFunLike.ext + intro i + simp only [Basis.reindex_apply] + exact (Basis.reindex_apply (F.reducedSquareBasis b ω hF) + (reducedSquareFinIndexEquiv s ω) i).symm + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RelativeActualRankBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/RelativeActualRankBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f54627f0ea677a304c6543f63ea1b63f5bb19d4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RelativeActualRankBudget.lean @@ -0,0 +1,33 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativePatchAmplification + +namespace OAI + +section + +namespace Erdos3 + +theorem relative_actual_rank_reconstruction_le + {s d d₀ old removed : ℕ} (hremoved : removed ≤ old) + (hreturned : d ≤ d₀ + s * (old - removed)) : + d + s * removed ≤ d₀ + s * old := by + calc + d + s * removed ≤ d₀ + s * (old - removed) + s * removed := + Nat.add_le_add_right hreturned _ + _ = d₀ + s * old := by + rw [Nat.add_assoc, ← Nat.mul_add, Nat.sub_add_cancel hremoved] + +theorem relative_actual_rank_reconstruction_budget + {s d removed bound : ℕ} {childCost p : ℝ} + (hchild : 0 ≤ childCost) (hd : d ≤ min bound ⌊childCost⌋₊) + (hremoved : (removed : ℝ) ≤ p) : + ((d + s * removed : ℕ) : ℝ) ≤ childCost + (s : ℝ) * p := by + have hdim : (d : ℝ) ≤ childCost := + (Nat.cast_le.mpr (hd.trans (min_le_right _ _))).trans (Nat.floor_le hchild) + simpa only [Nat.cast_add, Nat.cast_mul] using + add_le_add hdim (mul_le_mul_of_nonneg_left hremoved (Nat.cast_nonneg s)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RelativePatchRankTightening.lean b/lean/OAI/Combinatorics/Progressions/Linear/RelativePatchRankTightening.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae87bb863def12551b1304bfa258adf0e4f1a4f3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RelativePatchRankTightening.lean @@ -0,0 +1,28 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativePatchAmplification + +namespace OAI + +section + +namespace Erdos3 + +theorem RelativePatchSliceConclusion.tighten_rank + {X : Type*} [Fintype X] {s : ℕ} {N : X → ℕ} {f : (X → ℤ) → ℝ} + {target cost : ℝ} {rankBound : ℕ} + (h : RelativePatchSliceConclusion s N f target rankBound cost) : + RelativePatchSliceConclusion s N f target (min rankBound ⌊cost⌋₊) cost := by + obtain ⟨q,hq,S,d,A,hlength,hd,hcomplexity,hscore⟩ := h + have hdp : d ≤ ⌊cost⌋₊ := Nat.le_floor ((relativePatchComplexity_rank_le A).trans hcomplexity) + exact ⟨q,hq,S,d,A,hlength,le_min hd hdp,hcomplexity,hscore⟩ + +theorem RelativePatchAbsoluteRule.tighten_rank {s n₀ d₀ : ℕ} {p a Λ : ℝ} + (h : RelativePatchAbsoluteRule s n₀ p a Λ d₀) : + RelativePatchAbsoluteRule s n₀ p a Λ (min d₀ ⌊p⌋₊) := by + intro N hprime hinj hratio hsize f hf hfree hmean + exact (h N hprime hinj hratio hsize f hf hfree hmean).tighten_rank + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RelativeRankZeroSource.lean b/lean/OAI/Combinatorics/Progressions/Linear/RelativeRankZeroSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..a13b11f1d7a00278987381417141e64acb81ae5f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RelativeRankZeroSource.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.Progressions.Estimates.RelativePatchAmplification + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem RelativePatchPowerInductionRule.of_mean_increment + {s n₀ E d₀ : ℕ} {τ p a Λ : ℝ} + (hrelative : RelativePatchPowerInductionRule s n₀ s τ E) + (hp : 2 ≤ p) (ha : Real.exp (-p) ≤ a) (haΛ : a ≤ Λ) (hΛ : Λ ≤ 1) + (habsolute : RelativePatchAbsoluteRule s n₀ p a Λ d₀) + (X : Type) [Fintype X] [DecidableEq X] [Nonempty X] + (hX : (Fintype.card X : ℝ) ≤ p) + (N : X → ℕ) (hN : ∀ i, Real.exp ((p + 2) ^ E) ≤ (N i : ℝ)) + (f : (X → ℤ) → ℝ) (hf : ∀ x ∈ integerBox N, f x ∈ Set.Icc (0 : ℝ) 1) + (hfree : IntegerVectorAPFree {x | x ∈ integerBox N ∧ f x ≠ 0} (s + 2)) + (hmean : 2 * a ≤ 𝔼 x ∈ integerBox N, f x) : + RelativePatchSliceConclusion s N f ((1 - τ) ^ (s + 1) * Λ) d₀ ((p + 2) ^ E) := by + let A := PolynomialPatch.constant X s 1 (by constructor <;> norm_num) + have hval (t : X → ℝ) : A.value t = 1 := PolynomialPatch.constant_value _ _ t + have hbox : (integerBox N).Nonempty := by + refine ⟨0, (mem_integerBox N _).mpr (fun i => ⟨le_rfl, ?_⟩)⟩ + have hi : (0 : ℝ) < N i := (Real.exp_pos _).trans_le (hN i) + change (0 : ℤ) < N i + exact_mod_cast hi + have hscore : Real.exp (-p) ≤ relativePatchBoxScore N f a A := by + simp only [relativePatchBoxScore, hval, mul_one, + Finset.expect_sub_distrib, Finset.expect_const hbox] + linarith + have hcomp : relativePatchComplexity A ≤ p := by + have hlip : A.kernel.lip = 0 := PolynomialPatch.constant_lip _ _ + rw [relativePatchComplexity, hlip] + norm_num only [NNReal.coe_zero, Nat.cast_zero, add_zero, zero_add, Real.log_one] + linarith + have hstage : relativePatchDistinctWeights A ≤ s := by + rw [(relativePatchDistinctWeights_eq_zero_iff A).mpr rfl] + exact Nat.zero_le _ + simpa only [Nat.mul_zero, Nat.add_zero] using hrelative p a Λ d₀ hp ha haΛ hΛ habsolute + X hX N hN f hf hfree 0 A hcomp hstage hscore + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RescaledLieBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/RescaledLieBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..cca6c188a671e33fb3d5d165c4f0123f66565e77 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RescaledLieBasis.lean @@ -0,0 +1,50 @@ +import Mathlib.Algebra.Lie.Basic +import Mathlib.Basic.Real.Basic +import Mathlib.LinearAlgebra.Basis.SMul +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℝ L] + +noncomputable def inverseScaledBasis (e : Basis ι ℝ L) (d : ι → ℝ) + (hd : ∀ i, 0 < d i) : Basis ι ℝ L := + e.unitsSMul (fun i => (Units.mk0 (d i) (hd i).ne')⁻¹) + +theorem inverseScaledBasis_apply (e : Basis ι ℝ L) (d : ι → ℝ) + (hd : ∀ i, 0 < d i) (i : ι) : + inverseScaledBasis e d hd i = (d i)⁻¹ • e i := by + simp only [inverseScaledBasis, Basis.unitsSMul_apply, Units.smul_def, + Units.val_inv_eq_inv_val, Units.val_mk0] + +theorem inverseScaledBasis_repr (e : Basis ι ℝ L) (d : ι → ℝ) + (hd : ∀ i, 0 < d i) (x : L) (i : ι) : + (inverseScaledBasis e d hd).repr x i = d i * e.repr x i := by + simp only [inverseScaledBasis, Basis.repr_unitsSMul, inv_inv, + Units.smul_def, Units.val_mk0, smul_eq_mul] + +theorem inverseScaledBasis_bracket (e : Basis ι ℝ L) (d : ι → ℝ) + (hd : ∀ i, 0 < d i) + (hcompat : ∀ i j k, e.repr ⁅e i, e j⁆ k ≠ 0 → d k = d i * d j) + (i j k : ι) : + (inverseScaledBasis e d hd).repr + ⁅inverseScaledBasis e d hd i, inverseScaledBasis e d hd j⁆ k = + e.repr ⁅e i, e j⁆ k := by + rw [inverseScaledBasis_repr, inverseScaledBasis_apply, inverseScaledBasis_apply] + simp only [smul_lie, lie_smul, map_smul, Finsupp.smul_apply, smul_eq_mul] + by_cases h : e.repr ⁅e i, e j⁆ k = 0 + · simp only [h, mul_zero] + · rw [hcompat i j k h] + field_simp [(hd i).ne', (hd j).ne'] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/RootDifferenceMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/RootDifferenceMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..f158b783ce28abb5ab7e90012c897ecc735e88b5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/RootDifferenceMatrix.lean @@ -0,0 +1,44 @@ +import Mathlib.LinearAlgebra.Matrix.Determinant.Basic +import Mathlib.LinearAlgebra.Matrix.ToLin + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +def rootDifferenceMatrix {I J R : Type*} [CommRing R] + (root : J → R) (D : Matrix I J R) : Matrix (Unit ⊕ I) (Unit ⊕ J) R := + Matrix.fromBlocks (1 : Matrix Unit Unit R) (Matrix.of (fun (_ : Unit) j => root j)) (0 : Matrix I Unit R) D + +theorem rootDifferenceMatrix_mulVec {I J R : Type*} [Fintype J] [CommRing R] + (root : J → R) (D : Matrix I J R) (x : R) (v : J → R) : + rootDifferenceMatrix root D *ᵥ Sum.elim (fun _ : Unit => x) v = + Sum.elim (fun _ : Unit => x + ∑ j, root j * v j) (D *ᵥ v) := by + funext i + cases i with + | inl i => + cases i + simp [Matrix.mulVec, dotProduct, Fintype.sum_sum_type, rootDifferenceMatrix, Matrix.fromBlocks] + | inr i => simp [Matrix.mulVec, dotProduct, Fintype.sum_sum_type, rootDifferenceMatrix, Matrix.fromBlocks] + +theorem rootDifferenceMatrix_det {I R : Type*} [Fintype I] [DecidableEq I] [CommRing R] + (root : I → R) (A : Matrix I I R) : (rootDifferenceMatrix root A).det = A.det := by + change (Matrix.fromBlocks (1 : Matrix Unit Unit R) (Matrix.of (fun (_ : Unit) j => root j)) + (0 : Matrix I Unit R) A).det = A.det + rw [Matrix.det_fromBlocks_zero₂₁, Matrix.det_one, one_mul] + +theorem rootDifferenceMatrix_submatrix {I J R : Type*} [CommRing R] + (root : J → R) (D : Matrix I J R) (s : I → J) : + (rootDifferenceMatrix root D).submatrix id (Sum.map id s) = + rootDifferenceMatrix (fun i => root (s i)) (D.submatrix id s) := by + ext i j + cases i <;> cases j <;> rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ScalarKernelDenseSliceStride.lean b/lean/OAI/Combinatorics/Progressions/Linear/ScalarKernelDenseSliceStride.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d237d21570d987db0f67ad67022622a8745f315 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ScalarKernelDenseSliceStride.lean @@ -0,0 +1,43 @@ +import OAI.Combinatorics.Progressions.Estimates.DenseProgressionInnerFamily + +namespace OAI + +section + +namespace Erdos3 + +theorem scalarKernelCutoff_dense_slice_stride (s : ℕ) (G : Type*) [Fintype G] + {p η : ℝ} (hη : 0 < η) {S step H : ℕ} (c : ℤ) + (hcutoff : scalarKernelCutoff (Fin (s + 1)) G 1 ⌈Real.exp (p + 1)⌉₊ η ≤ S) + (hstep : 0 < step) + (hsubset : integerProgressionSupport c (step : ℤ) H ⊆ Finset.Ico (0 : ℤ) (S : ℤ)) + (hdense : Real.exp (-(p + 1)) * S ≤ (H : ℝ)) : + 2 ≤ H ∧ (step : ℝ) ≤ 4 * Real.exp (p + 1) := by + have hD : 0 < ⌈Real.exp (p + 1)⌉₊ := Nat.ceil_pos.mpr (Real.exp_pos _) + have hc := ((scalarKernelCutoff_bounds (Fin (s + 1)) G (by norm_num : 0 < (1 : ℕ)) hD hη).2.2.1).trans hcutoff + have hcR : (⌈Real.exp (p + 1)⌉₊ : ℝ) * ((s : ℝ) + 2) ≤ S := by + simpa only [Fintype.card_fin, mul_one, Nat.cast_mul, Nat.cast_add, Nat.cast_one, + add_assoc, one_add_one_eq_two, Nat.cast_ofNat] using (Nat.cast_le (α := ℝ).mpr hc) + have hS : 2 * Real.exp (p + 1) ≤ S := by + have hceil := Nat.le_ceil (Real.exp (p + 1)) + have hnonneg : 0 ≤ (⌈Real.exp (p + 1)⌉₊ : ℝ) * (s : ℝ) := mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + nlinarith only [hcR, hceil, hnonneg] + have hSpos : 0 < S := by + have h := (mul_pos (by norm_num : (0 : ℝ) < 2) (Real.exp_pos (p + 1))).trans_le hS + exact_mod_cast h + have hH : 2 ≤ H := by + have hmul := (mul_le_mul_of_nonneg_left hS (Real.exp_pos (-(p + 1))).le).trans hdense + have he : Real.exp (-(p + 1)) * (2 * Real.exp (p + 1)) = 2 := by + rw [mul_left_comm, ← Real.exp_add, neg_add_cancel, Real.exp_zero, mul_one] + rw [he] at hmul + exact_mod_cast hmul + refine ⟨hH, ?_⟩ + have h := progression_slice_step_le_inverse_density c hSpos hstep hH (Real.exp_pos (-(p + 1))) + hsubset (by simpa only [card_integerProgressionSupport c step H hstep] using hdense) + simpa only [div_eq_mul_inv, ← Real.exp_neg, neg_neg] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ScaledBasisNorm.lean b/lean/OAI/Combinatorics/Progressions/Linear/ScaledBasisNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..48bd020fa55d202b502e7a6abbe52950d6ea233f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ScaledBasisNorm.lean @@ -0,0 +1,33 @@ +import OAI.Combinatorics.Progressions.Estimates.EuclideanGraphNorm + +namespace OAI + +section + +namespace Erdos3 + +theorem divided_basisFun_eq_smul {σ : Type*} [Fintype σ] [DecidableEq σ] + (T : σ → ℝ) (i : σ) : + (fun j => (Pi.basisFun ℝ σ i) j / T j) = (1 / T i) • Pi.basisFun ℝ σ i := by + funext j + by_cases hij : i = j + · subst j + simp + · simp [Pi.basisFun_apply, Ne.symm hij] + +theorem linearMap_divided_basis_norm_le {E σ : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] [Fintype σ] [DecidableEq σ] + (G : (σ → ℝ) →ₗ[ℝ] E) (T : σ → ℝ) (i : σ) (hTi : 0 < T i) + (B : ℝ) (hB : ‖G (Pi.basisFun ℝ σ i)‖ ≤ B) : + ‖G (fun j => (Pi.basisFun ℝ σ i) j / T j)‖ ≤ B / T i := by + rw [divided_basisFun_eq_smul, map_smul, norm_smul, Real.norm_eq_abs, + abs_of_pos (one_div_pos.mpr hTi)] + calc + _ ≤ (1 / T i) * B := mul_le_mul_of_nonneg_left hB (one_div_pos.mpr hTi).le + _ = B / T i := by ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ScaledPairBasisHeight.lean b/lean/OAI/Combinatorics/Progressions/Linear/ScaledPairBasisHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac4d0ae84cc4264cf31d586f7e5f39d15a0c38a5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ScaledPairBasisHeight.lean @@ -0,0 +1,46 @@ +import Mathlib.LinearAlgebra.Basis.Prod +import OAI.Combinatorics.Progressions.Estimates.RationalRowReduction +import OAI.Combinatorics.Progressions.Geometry.DilationPairCoordinates + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem exists_scaledPair_basis_height {ι α β L : Type*} [Fintype α] [Fintype β] + [AddCommGroup L] [Module ℚ L] (e : Basis ι ℚ L) + (P Q : Submodule ℚ L) (hQP : Q ≤ P) (a : Basis α ℚ Q) (b : Basis β ℚ P) + (q : ℚ) {H K : ℕ} (hH : 1 ≤ H) (hK : 1 ≤ K) (hq : RationalHeightLE q K) + (ha : ∀ j k, RationalHeightLE (e.repr (a j : L) k) H) + (hb : ∀ j k, RationalHeightLE (e.repr (b j : L) k) H) : + ∃ c : Basis (Fin (finrank ℚ (scaledPairLayer P Q q))) ℚ (scaledPairLayer P Q q), + ∀ j k, RationalHeightLE (e.repr (c j).val.1 k) (H * K) ∧ + RationalHeightLE (e.repr (c j).val.2 k) (H * K) := by + classical + let c := (a.prod b).map (scaledPairLayerEquiv P Q hQP q) + have hHK : H ≤ H * K := Nat.le_mul_of_pos_right H (by omega) + have hz (k : ι) : RationalHeightLE (e.repr 0 k) (H * K) := by + simpa only [map_zero, Finsupp.zero_apply] using rationalHeightLE_zero (hH.trans hHK) + have hc (j : α ⊕ β) (k : ι) : + RationalHeightLE (e.repr (c j).val.1 k) (H * K) ∧ + RationalHeightLE (e.repr (c j).val.2 k) (H * K) := by + rcases j with j | j + · simpa [c, Basis.prod_apply, scaledPairLayerEquiv, scaledPairAssemble] using + (show RationalHeightLE (e.repr (a j : L) k) (H * K) ∧ + RationalHeightLE (e.repr 0 k) (H * K) from ⟨(ha j k).mono hHK, hz k⟩) + · have hmul : RationalHeightLE (q * e.repr (b j : L) k) (H * K) := by + simpa only [Nat.mul_comm K H] using hq.mul (hb j k) + simpa [c, Basis.prod_apply, scaledPairLayerEquiv, scaledPairAssemble, smul_eq_mul] using + (show RationalHeightLE (q * e.repr (b j : L) k) (H * K) ∧ + RationalHeightLE (e.repr (b j : L) k) (H * K) from ⟨hmul, (hb j k).mono hHK⟩) + let c' := c.reindex (Fintype.equivFinOfCardEq (finrank_eq_card_basis c).symm) + exact ⟨c', fun j k => by simpa only [c', Basis.reindex_apply] using hc _ k⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SelectedCoordinateMatrix.lean b/lean/OAI/Combinatorics/Progressions/Linear/SelectedCoordinateMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..67e7f93c0fbdc76850042b49b0267fce283661da --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SelectedCoordinateMatrix.lean @@ -0,0 +1,33 @@ +import OAI.Combinatorics.Progressions.Geometry.CoordinateInjection +import OAI.Combinatorics.Progressions.Linear.MatrixSupInverse + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +theorem clm_coordinateInjection_matrix {ι κ : Type*} + [Fintype ι] [Fintype κ] [DecidableEq κ] + (A : (κ → ℝ) →L[ℝ] (ι → ℝ)) (f : ι → κ) : + A.comp (coordinateInjection f) = + matrixSupCLM (fun row col => A (Pi.single (f col) 1) row) := by + ext x row + change A (coordinateInjection f x) row = _ + rw [coordinateInjection_apply, map_sum, Finset.sum_apply] + change (∑ i, A (Pi.single (f i) (x i)) row) = ∑ i, A (Pi.single (f i) 1) row * x i + apply Finset.sum_congr rfl + intro i _ + have hs : Pi.single (f i) (x i) = (x i) • (Pi.single (f i) (1 : ℝ) : κ → ℝ) := by + rw [← Pi.single_smul] + simp + rw [hs, map_smul] + simp only [Pi.smul_apply, smul_eq_mul, mul_comm] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SelectedKernelReconstruction.lean b/lean/OAI/Combinatorics/Progressions/Linear/SelectedKernelReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..98d4a1bc5cc6e6b311bf1e5315905c468377b67c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SelectedKernelReconstruction.lean @@ -0,0 +1,41 @@ +import OAI.Combinatorics.Progressions.Probability.SelectedDensityNormalization + +namespace OAI + +section + +namespace Erdos3 + +open scoped Matrix + +theorem selectedKernel_matrix_reconstruct {I J R : Type*} [Fintype I] [Fintype J] [CommRing R] + (M : Matrix I J R) (s : I ↪ J) (a : J → R) : + M *ᵥ a = M.submatrix id s *ᵥ (fun i => a (s i)) + + remainingMatrixColumns M s *ᵥ (fun j => a j.val) := by + have h := Matrix.submatrix_mulVec_equiv M (a ∘ selectedColumnEquiv s) id (selectedColumnEquiv s) + rw [← selectedMatrix_fromCols, Matrix.fromCols_mulVec] at h + have hl (i : I) : selectedColumnEquiv s (Sum.inl i) = s i := rfl + have hr (j : UnselectedColumn s) : selectedColumnEquiv s (Sum.inr j) = j.val := rfl + simpa only [Function.comp_def, Equiv.apply_symm_apply, id_eq, hl, hr] using h.symm + +theorem normalizedKernel_reconstruct {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (M : Matrix I J ℤ) (s : I ↪ J) (hM : (M.submatrix id s).det ≠ 0) + (S : J → ℝ) (P : I → ℝ) (hS : ∀ j, 0 < S j) (hP : ∀ i, 0 < P i) (a : J → ℝ) : + matrixSupCLM (normalizedIntegerColumns M S P) a = + normalizedPivotEquiv (M.submatrix id s) hM (fun i => S (s i)) P (fun i => hS (s i)) hP + (fun i => a (s i)) + + matrixSupCLM (normalizedIntegerColumns (remainingMatrixColumns M s) (fun j => S j.val) P) + (fun j => a j.val) := by + change _ = + (normalizedPivotEquiv (M.submatrix id s) hM (fun i => S (s i)) P (fun i => hS (s i)) hP).toContinuousLinearMap + (fun i => a (s i)) + _ + rw [normalizedPivotEquiv_coe, normalized_remainingMatrixColumns] + simpa only [matrixSupCLM_apply, normalizedIntegerColumns_submatrix] using + selectedKernel_matrix_reconstruct (normalizedIntegerColumns M S P) s a + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeCommonProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeCommonProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c29b68dea90e994755c52fd1fd9c0922dcd908c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeCommonProjection.lean @@ -0,0 +1,191 @@ +import OAI.Combinatorics.Progressions.Lattices.SharedFreeAffineBudget + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem dependent_le_refined_firstProjection + {R V : Type*} [CommRing R] [AddCommGroup V] [Module R V] + (C D : Submodule R V) (K : Submodule R (Fin 4 → V)) : + D ≤ (fourRefinedRelation C D K).map (LinearMap.proj 0) := by + intro v hv + refine ⟨fun _ : Fin 4 => v, fourBalancedDependent_le_refined C D K ?_, rfl⟩ + exact (mem_fourBalancedDependent D _).mpr ⟨fun _ => hv, by abel⟩ + +theorem realification_firstProjection + {V : Type*} [AddCommGroup V] [Module ℚ V] (K : Submodule ℚ (Fin 4 → V)) : + (K.map (LinearMap.proj 0)).baseChange ℝ = + ((K.baseChange ℝ).map (TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => V)).toLinearMap).map + (LinearMap.proj 0) := by + rw [realification_map] + ext x + constructor + · rintro ⟨y, hy, rfl⟩ + exact ⟨_, ⟨y, hy, rfl⟩, (real_four_projection y 0).symm⟩ + · rintro ⟨v, ⟨y, hy, rfl⟩, rfl⟩ + exact ⟨y, hy, real_four_projection y 0⟩ + +theorem real_four_projection_norm_le + {V ι : Type*} [LieRing V] [LieAlgebra ℚ V] [Fintype ι] + (b : Basis ι ℚ V) (x : ℝ ⊗[ℚ] (Fin 4 → V)) (k : Fin 4) : + ‖(b.baseChange ℝ).equivFun ((LinearMap.proj k).baseChange ℝ x)‖ ≤ + ‖((Pi.basis (fun _ : Fin 4 => b)).baseChange ℝ).equivFun x‖ := by + apply (pi_norm_le_iff_of_nonneg (norm_nonneg _)).mpr + intro i + change |(b.baseChange ℝ).repr ((LinearMap.proj k).baseChange ℝ x) i| ≤ _ + rw [real_pi_projection_coordinates] + exact norm_le_pi_norm (((Pi.basis (fun _ : Fin 4 => b)).baseChange ℝ).equivFun x) ⟨k, i⟩ + +theorem real_four_projection_grid + {V ι : Type*} [LieRing V] [LieAlgebra ℚ V] [Fintype ι] + (b : Basis ι ℚ V) (x : ℝ ⊗[ℚ] (Fin 4 → V)) (k : Fin 4) (l : ℕ) + (hx : ((Pi.basis (fun _ : Fin 4 => b)).baseChange ℝ).equivFun x ∈ realDenominatorGrid l) : + (b.baseChange ℝ).equivFun ((LinearMap.proj k).baseChange ℝ x) ∈ realDenominatorGrid l := by + obtain ⟨z, hz⟩ := hx + refine ⟨fun i => z ⟨k, i⟩, funext fun i => ?_⟩ + exact (congrFun hz ⟨k, i⟩).trans (congrArg (fun a : ℝ => (l : ℝ) * a) + (real_pi_projection_coordinates b x k i).symm) + +end Erdos3 + +end + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module VectorPolynomial CyclicCrootSisask +open scoped TensorProduct BigOperators + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q) + (F : FreeCoordinateFrame E.basis Q) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ} + {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'} + (D' : R'.CommonData P') + +include F + +theorem exists_shared_free_common_projection + (hs : 2 ≤ s) (hp' : 0 ≤ p') (hP' : 0 ≤ P') (hQP' : Q ≤ P') (hpp' : p' ≤ P') + (ξ : E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (v : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hsplit : ∀ h, g h = ξ * v h) + (hξ : ∀ d : Fin s, coefficients ξ.log (Finsupp.single () (d.val + 1)) ∈ + (D.commonFreeSpan d).baseChange ℝ) + (hv : ∀ h (d : Fin s), coefficients (v h).log (Finsupp.single () (d.val + 1)) ∈ + (D.dependentFreeSpan d).baseChange ℝ) + (hN : Real.exp ((P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s) ≤ (N : ℝ)) : + let Λ := (P' + sharedFreeAffineConstant s) ^ sharedFreeAffineConstant s + ∃ (m : Fin s → ℕ) (γ e q : Fin s → ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra), + ∀ d, 0 < m d ∧ (m d : ℝ) ≤ Real.exp Λ ∧ + γ d ∈ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ ∧ + coefficients ξ.log (Finsupp.single () (d.val + 1)) = γ d + e d + q d ∧ + ‖(E.basis.baseChange ℝ).equivFun (e d)‖ ≤ Real.exp Λ / (N : ℝ) ^ (d.val + 1) ∧ + (E.basis.baseChange ℝ).equivFun (q d) ∈ realDenominatorGrid (m d) := by + intro Λ + classical + let z := 8 * sharedRefinementInputBudget s P' + 1 + let A₀ := sharedFreeEquationInputBudget s Q P' + have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1 + have hbudget := (sharedFreeAffineConstant_spec s).2 Q P' hQ hQP' hP' 0 + (by simpa only [Nat.cast_zero] using + mul_nonneg (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) (Nat.cast_nonneg s)) hP') + have hcut := sharedFreeRecoveryThreshold_spec s hQ hP' N + ((Real.exp_le_exp.mpr hbudget.1).trans hN) + have hb := sharedFreeEquationInputBudget_bounds s hQ hP' + have hA₀ : 0 ≤ A₀ := hb.1 + have hcoeff := sharedFreeRecoveryThreshold_coefficient_bounds s hQ hP' + have hAΛ : A₀ ≤ Λ := + (le_power_budget hb.1 (by decide : 1 ≤ 4)).trans (hcoeff.1.trans hbudget.1) + have hnum : Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z) ≤ Real.exp Λ := by + have hfac : 1 ≤ 2 * Real.exp ((A₀ + 2) ^ 3) := by + have h := Real.one_le_exp_iff.mpr (show 0 ≤ (A₀ + 2) ^ 3 by positivity) + linarith + calc + _ ≤ 2 * (Real.exp ((A₀ + 2) ^ 3) * + (Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z))) := by + have h := mul_le_mul_of_nonneg_right hfac + (show 0 ≤ Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z) by positivity) + simpa only [one_mul, mul_assoc] using h + _ ≤ _ := hcoeff.2.trans (Real.exp_le_exp.mpr hbudget.1) + obtain ⟨D₁, _hsub, _hspaces, hcorr⟩ := + D.exists_controlled_shared_free_refinement E T hbQ hT F V g hg D' + hs hp' hP' hQP' hpp' ξ v hsplit hξ hv hcut.1 + obtain ⟨t, ht⟩ := D₁.nonempty + choose m hm hmb hcorr using hcorr + have hdenom (d : Fin s) : (m d : ℝ) ≤ Real.exp Λ := + (hmb d).trans (Real.exp_le_exp.mpr (hb.2.2.2.trans hAΛ)) + let π := (LinearMap.proj (0 : Fin 4) : + (Fin 4 → D.CoefficientFreeLieAlgebra) →ₗ[ℚ] D.CoefficientFreeLieAlgebra).baseChange ℝ + have hcommon (d : Fin s) : ∃ γ e q : ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra, + γ ∈ ((fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0)).baseChange ℝ ∧ + coefficients ξ.log (Finsupp.single () (d.val + 1)) = γ + e + q ∧ + ‖(E.basis.baseChange ℝ).equivFun e‖ ≤ Real.exp Λ / (N : ℝ) ^ (d.val + 1) ∧ + (E.basis.baseChange ℝ).equivFun q ∈ realDenominatorGrid (m d) := by + obtain ⟨A, S, hA, hS, hmem⟩ := hcorr d t ht + let K := fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩) + let u := coefficients (v (rankQuadrupleParameters t 1)).log (Finsupp.single () (d.val + 1)) + let γ := coefficients ξ.log (Finsupp.single () (d.val + 1)) - π A - π S + have hhead : π ((TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra)).symm + (sharedLogCoefficientTuple E.filtration ξ v (Finsupp.single () (d.val + 1)) t)) = + coefficients ξ.log (Finsupp.single () (d.val + 1)) + u := by + dsimp only [π] + rw [real_four_projection, LinearEquiv.apply_symm_apply] + rfl + have hproj : π ((TensorProduct.piRight ℚ ℝ ℝ (fun _ : Fin 4 => D.CoefficientFreeLieAlgebra)).symm + (sharedLogCoefficientTuple E.filtration ξ v (Finsupp.single () (d.val + 1)) t) - A - S) ∈ + (K.map (LinearMap.proj 0)).baseChange ℝ := by + rw [realification_map] + exact ⟨_, hmem, rfl⟩ + rw [map_sub, map_sub, hhead] at hproj + have hu : u ∈ (K.map (LinearMap.proj 0)).baseChange ℝ := + Submodule.baseChange_mono ℝ (dependent_le_refined_firstProjection _ _ _) (hv _ d) + refine ⟨γ, π A, π S, ?_, ?_, ?_, ?_⟩ + · have h := ((K.map (LinearMap.proj 0)).baseChange ℝ).sub_mem hproj hu + convert h using 1 + dsimp [γ] + abel + · dsimp [γ] + abel + · have hA' : ‖((Pi.basis (fun _ : Fin 4 => E.basis)).baseChange ℝ).equivFun A‖ ≤ + (Real.exp z + Real.exp ((z + 2) ^ 3 + (z + 2) ^ 18 + z)) / (N : ℝ) ^ (d.val + 1) := by + simpa only [monomialScale, Finsupp.prod_single_index, pow_zero] using hA + exact (real_four_projection_norm_le E.basis A 0).trans + (hA'.trans (div_le_div_of_nonneg_right hnum (by positivity))) + · exact real_four_projection_grid E.basis S 0 (m d) hS + choose γ e q hγ heq he hq using hcommon + exact ⟨m, γ, e, q, fun d => ⟨hm d, hdenom d, hγ d, heq d, he d, hq d⟩⟩ + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeComparisonBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeComparisonBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cae7a89d956bae6febbdaf1eb8914cc7ca1c50c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeComparisonBasis.lean @@ -0,0 +1,219 @@ +import OAI.Combinatorics.Progressions.Estimates.SharedFreeRoundingThreshold + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module + +theorem exists_layer_basis_of_eq + {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n : ℕ} + {E : RationalFilteredNilmanifold L s n} (T : E.DegreeRankStructure r) + {p : ℝ} (hT : T.ComplexityLE p) (i j : Fin (s + 1)) + (K : Submodule ℚ L) (hK : T.filtration.layer i.val j.val = K) : + ∃ k : Basis (Fin (finrank ℚ K)) ℚ K, + ∀ a b, rationalLogHeight (E.basis.repr (k a : L) b) ≤ p := by + subst K + exact ⟨T.basis i j, hT.2 i j⟩ + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3 + +open Module + +variable {V μ : Type*} [AddCommGroup V] [Module ℚ V] [Fintype μ] + +theorem exists_firstProjection_basis_logHeight + (e : Basis μ ℚ V) (K : Submodule ℚ (Fin 4 → V)) + (k : Basis (Fin (finrank ℚ K)) ℚ K) {p : ℝ} + (hk : ∀ a i, rationalLogHeight ((Pi.basis (fun _ : Fin 4 => e)).repr (k a : Fin 4 → V) i) ≤ p) : + ∃ c : Basis (Fin (finrank ℚ (K.map (LinearMap.proj 0)))) ℚ (K.map (LinearMap.proj 0)), + ∀ a i, rationalLogHeight (e.repr (c a : V) i) ≤ p := by + have hspan : Submodule.span ℚ (Set.range (fun a => (k a : Fin 4 → V))) = K := by + change Submodule.span ℚ (Set.range (K.subtype ∘ k)) = K + rw [Set.range_comp, ← Submodule.map_span, k.span_eq, Submodule.map_top, Submodule.range_subtype] + have hproj : Submodule.span ℚ (Set.range (fun a => (k a : Fin 4 → V) 0)) = + K.map (LinearMap.proj 0) := by + change Submodule.span ℚ (Set.range + ((LinearMap.proj (0 : Fin 4) : (Fin 4 → V) →ₗ[ℚ] V) ∘ fun a => (k a : Fin 4 → V))) = _ + rw [Set.range_comp, ← Submodule.map_span, hspan] + apply exists_submodule_basis_of_spanning_logHeight e _ (fun a => (k a : Fin 4 → V) 0) hproj + intro a i + simpa only [Pi.basis_repr] using hk a ⟨0, i⟩ + +theorem exists_fourPetalSpace_basis_logHeight + (e : Basis μ ℚ V) (D : Submodule ℚ V) (K : Submodule ℚ (Fin 4 → V)) + (b : Basis (Fin (finrank ℚ D)) ℚ D) (k : Basis (Fin (finrank ℚ K)) ℚ K) + {p : ℝ} (hp : 0 ≤ p) (hdim : (Fintype.card μ : ℝ) ≤ p) + (hb : ∀ a i, rationalLogHeight (e.repr (b a : V) i) ≤ p) + (hk : ∀ a i, rationalLogHeight ((Pi.basis (fun _ : Fin 4 => e)).repr (k a : Fin 4 → V) i) ≤ p) : + ∃ c : Basis (Fin (finrank ℚ (fourPetalSpace D K))) ℚ (fourPetalSpace D K), + ∀ a i, rationalLogHeight (e.repr (c a : V) i) ≤ preimageBasisBudget (4 * p) := by + let : FiniteDimensional ℚ V := e.finiteDimensional_of_finite + have hp4 : p ≤ 4 * p := by linarith only [hp] + have hspan (U : Submodule ℚ V) (a : Basis (Fin (finrank ℚ U)) ℚ U) : + Submodule.span ℚ (Set.range (fun j => (a j : V))) = U := by + change Submodule.span ℚ (Set.range (U.subtype ∘ a)) = U + rw [Set.range_comp, ← Submodule.map_span, a.span_eq, Submodule.map_top, Submodule.range_subtype] + have hkspan : Submodule.span ℚ (Set.range (fun j => (k j : Fin 4 → V))) = K := by + change Submodule.span ℚ (Set.range (K.subtype ∘ k)) = K + rw [Set.range_comp, ← Submodule.map_span, k.span_eq, Submodule.map_top, Submodule.range_subtype] + apply exists_preimage_basis_logHeight e (Pi.basis (fun _ : Fin 4 => e)) D K + (LinearMap.single ℚ (fun _ : Fin 4 => V) 0) + (fun j => (b j : V)) (fun j => (k j : Fin 4 → V)) (hspan D b) hkspan + (mul_nonneg (by norm_num) hp) + · simpa using mul_le_mul_of_nonneg_left hdim (by norm_num : (0 : ℝ) ≤ 4) + · have hD : (finrank ℚ D : ℝ) ≤ Fintype.card μ := by + exact_mod_cast D.finrank_le.trans_eq (finrank_eq_card_basis e) + simpa only [Fintype.card_fin] using (hD.trans hdim).trans hp4 + · have hK : (finrank ℚ K : ℝ) ≤ 4 * Fintype.card μ := by + exact_mod_cast four_submodule_finrank_le e K + simpa only [Fintype.card_fin] using hK.trans + (mul_le_mul_of_nonneg_left hdim (by norm_num : (0 : ℝ) ≤ 4)) + · exact fun a i => (hb a i).trans hp4 + · exact fun a i => (hk a i).trans hp4 + · rintro a ⟨j, i⟩ + by_cases hj : j = 0 + · subst j + simpa [Pi.basis_repr, LinearMap.single_apply] using (hb a i).trans hp4 + · simpa [Pi.basis_repr, LinearMap.single_apply, hj, Ne.symm hj, rationalLogHeight] using + (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) hp) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem preimageBasisBudget_mono {p q : ℝ} (hp : 0 ≤ p) (hpq : p ≤ q) : + preimageBasisBudget p ≤ preimageBasisBudget q := by + have hq : 0 ≤ q := hp.trans hpq + unfold preimageBasisBudget sparseGeneratorBudget + gcongr + +theorem fourRefinementBasisBudget_mono {p q : ℝ} (hp : 0 ≤ p) (hpq : p ≤ q) : + fourRefinementBasisBudget p ≤ fourRefinementBasisBudget q := + add_le_add hpq (preimageBasisBudget_mono (by positivity) + (mul_le_mul_of_nonneg_left hpq (by norm_num))) + +noncomputable def sharedFreeComparisonBasisBudget (q p : ℝ) : ℝ := + let A := q + fourRefinementBasisBudget (q + coefficientFourHeightBudget p) + A + preimageBasisBudget (4 * A) + +theorem exists_sharedFreeComparisonBasisBudget_bound : + ∃ C : ℕ, 2 ≤ C ∧ ∀ q p : ℝ, 0 ≤ q → q ≤ p → 0 ≤ p → + sharedFreeComparisonBasisBudget q p ≤ (p + C) ^ C := by + let R (X : Polynomial ℕ) := ((X + 1 + (X + 3) ^ 7 + 2) ^ 9 + X + 4) ^ 4 + let H (X : Polynomial ℕ) := X + R X + 2 + let G (X : Polynomial ℕ) := X + X * ((X + 2) ^ 7 + X) + let V (X : Polynomial ℕ) := G (X + (X + (X + 3) ^ 7 + 2) ^ 4 + 1) + let F (X : Polynomial ℕ) := X + V (4 * X) + let A : Polynomial ℕ := Polynomial.X + F (Polynomial.X + H Polynomial.X) + let T : Polynomial ℕ := A + V (4 * A) + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget T + refine ⟨C, hC, ?_⟩ + intro q p hq hqp hp + have hheight : 0 ≤ coefficientFourHeightBudget p := coefficientFourHeightBudget_nonneg hp + have hupper : sharedFreeComparisonBasisBudget q p ≤ sharedFreeComparisonBasisBudget p p := by + have hA := add_le_add hqp (fourRefinementBasisBudget_mono (add_nonneg hq hheight) + (add_le_add hqp (le_refl (coefficientFourHeightBudget p)))) + have hA0 : 0 ≤ q + fourRefinementBasisBudget (q + coefficientFourHeightBudget p) := + add_nonneg hq (fourRefinementBasisBudget_nonneg (add_nonneg hq hheight)) + dsimp only [sharedFreeComparisonBasisBudget] + exact add_le_add hA (preimageBasisBudget_mono (mul_nonneg (by norm_num) hA0) + (mul_le_mul_of_nonneg_left hA (by norm_num))) + apply hupper.trans + simpa [T, A, F, V, G, H, R, sharedFreeComparisonBasisBudget, coefficientFourHeightBudget, + refiltrationCoordinateBudget, fourRefinementBasisBudget, preimageBasisBudget, + sparseGeneratorBudget, Polynomial.eval₂_pow] using hbound p hp + +end Erdos3 + +namespace Erdos3.NativeRankRelation.CommonData + +open Module +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q) + (F : FreeCoordinateFrame E.basis Q) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ} + {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'} + (D' : R'.CommonData P') + +include F + +theorem exists_sharedFreeComparisonSpace_basis + (hTfil : T.filtration = D.coefficientFreeFiltration) + (hs : 2 ≤ s) (hP' : 0 ≤ P') (hQP' : Q ≤ P') (d : Fin s) : + let C := (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)).map (LinearMap.proj 0) + let P := fourPetalSpace (D.dependentFreeSpan d) + (fourRefinedRelation (D.coefficientFreeSpan d) (D.dependentFreeSpan d) + (D'.coefficientFourSpace ⟨d.val + 1, by omega⟩)) + let K := D.coefficientFreeFiltration.layer (d.val + 1) 2 + ∃ b : Basis (Fin (finrank ℚ (petalComparisonSpace C P K))) ℚ (petalComparisonSpace C P K), + ∀ a i, rationalLogHeight ((Pi.basis (fun _ : Fin 2 => E.basis)).repr + (b a : Fin 2 → D.CoefficientFreeLieAlgebra) i) ≤ sharedFreeComparisonBasisBudget Q P' := by + intro C P K + have hQ : 0 ≤ Q := (Nat.cast_nonneg _).trans hT.1.1 + let H := fourRefinementBasisBudget (Q + coefficientFourHeightBudget P') + let A := Q + H + have hH : 0 ≤ H := fourRefinementBasisBudget_nonneg + (add_nonneg hQ (coefficientFourHeightBudget_nonneg hP')) + have hA : 0 ≤ A := add_nonneg hQ hH + have hQA : Q ≤ A := le_add_of_nonneg_right hH + have hHA : H ≤ A := le_add_of_nonneg_left hQ + obtain ⟨k, hk⟩ := D.exists_correlation_refined_basis E T hbQ hT F V g hg D' hs hP' hQP' d + obtain ⟨b, hb⟩ := D.exists_dependentFreeSpan_basis E.basis F (by omega) d + obtain ⟨c, hc⟩ := exists_firstProjection_basis_logHeight E.basis _ k + (fun a i => (hk a i).trans hHA) + obtain ⟨p, hp⟩ := exists_fourPetalSpace_basis_logHeight E.basis _ _ b k hA + (by simpa only [Fintype.card_fin] using hT.1.1.trans hQA) + (fun a i => (hb a i).trans hQA) (fun a i => (hk a i).trans hHA) + have hK : ∃ k : Basis (Fin (finrank ℚ K)) ℚ K, + ∀ a i, rationalLogHeight (E.basis.repr (k a : D.CoefficientFreeLieAlgebra) i) ≤ Q := by + exact T.exists_layer_basis_of_eq hT ⟨d.val + 1, by omega⟩ ⟨2, by omega⟩ K + (congrArg (fun T => T.layer (d.val + 1) 2) hTfil) + obtain ⟨k₂, hk₂⟩ := hK + have hpre : 0 ≤ preimageBasisBudget (4 * A) := preimageBasisBudget_nonneg (by positivity) + have hAL : A ≤ sharedFreeComparisonBasisBudget Q P' := le_add_of_nonneg_right hpre + have hPL : preimageBasisBudget (4 * A) ≤ sharedFreeComparisonBasisBudget Q P' := + le_add_of_nonneg_left hA + exact exists_petalComparisonSpace_basis_logHeight E.basis C P K c p k₂ + (add_nonneg hA hpre) (fun a i => (hc a i).trans hAL) (fun a i => (hp a i).trans hPL) + (fun a i => (hk₂ a i).trans (hQA.trans hAL)) + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeComparisonKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeComparisonKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..a03993e93c0d2580b61ebbd18042097f53453ccb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SharedFreeComparisonKernel.lean @@ -0,0 +1,105 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonDependentWordLayers +import OAI.Combinatorics.Progressions.Estimates.SharedFreeComparisonLift + +namespace OAI + +section + +namespace Erdos3.NativeRankRelation.CommonData + +open Module +open scoped TensorProduct + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + NativeIntegerExpansion.lie NativeIntegerExpansion.algebra + NativeIntegerExpansion.topology NativeIntegerExpansion.topologicalAdd + NativeIntegerExpansion.continuousSMul NativeIntegerExpansion.hausdorff + +variable {s r N : ℕ} [NeZero N] {b p q P Q : ℝ} {f : ZMod N → ℂ} + {W : NativeCorrelationStructure s r N b f} {out : Fin W.family.outputDim} + {H : Finset (ZMod N)} {R : NativeRankRelation W.family out H p q} (D : R.CommonData P) + (B : D.CoefficientBases Q) + (E : RationalFilteredNilmanifold D.CoefficientFreeLieAlgebra s + (finrank ℚ D.CoefficientFreeLieAlgebra)) + (T : E.DegreeRankStructure r) (hbQ : b ≤ Q) (hT : T.ComplexityLE Q) + [TopologicalSpace (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + [T2Space (ℝ ⊗[ℚ] D.CoefficientFreeLieAlgebra)] + (V : E.UnitVerticalObservable (T.realSubgroup s r) (Fin W.family.outputDim) Q) + (g : ZMod N → E.filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (hg : ∀ h, E.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) 0 (g h) = 1) + +variable {out' : Fin W.family.outputDim} {H' : Finset (ZMod N)} {p' q' P' : ℝ} + {R' : NativeRankRelation (W.replacementFamily E T hbQ hT V g hg) out' H' p' q'} + (D' : R'.CommonData P') + +theorem CoefficientBases.comparison_free_top_frequency + (hTfil : T.filtration = D.coefficientFreeFiltration) + (hfreq : V.frequency = B.freeFrequency D) : + let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D' + let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil + ∀ (J : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j)) + (x : SubspaceFreeLift.Algebra S r), + x ∈ (SubspaceFreeLift.filtration S T.filtration.rank_le_degree).layer s r → + pairDifferenceFunctional V.frequency + (SubspaceFreeLift.evaluation S J + (RationalFilteredNilmanifold.piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS x) = 0 := by + intro S hS J x hx + apply FreeDegreeRankLieAlgebra.lift_top_frequency_zero + (RationalFilteredNilmanifold.piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration + (SubspaceFreeLift.weight S) (SubspaceFreeLift.weight_pos S) + (fun a => (J a.1 a.2).val) (fun a => hS a.1 (J a.1 a.2).property) + (pairDifferenceFunctional V.frequency) _ hx + intro a hd hr + classical + let e := Fintype.equivFin (SubspaceFreeLift.Alphabet S) + let d : Fin (Fintype.card (SubspaceFreeLift.Alphabet S)) → Fin s := fun i => (e.symm i).1 + let z : Fin (Fintype.card (SubspaceFreeLift.Alphabet S)) → Fin 2 → D.CoefficientFreeLieAlgebra := + fun i => (J (e.symm i).1 (e.symm i).2).val + have hd' : lieTreeWeight (fun i => (d i).val + 1) (FreeMagma.map e a) = s := by + have heq : (fun i => (d i).val + 1) ∘ e = SubspaceFreeLift.weight S := by + funext i + change (e.symm (e i)).1.val + 1 = i.1.val + 1 + rw [e.symm_apply_apply] + rw [lieTreeWeight_relabel, heq] + exact hd + have hr' : (FreeMagma.map e a).length = r := (lieTreeLength_relabel e a).trans hr + have hz : ∀ i, z i ∈ S (d i) := fun i => (J (e.symm i).1 (e.symm i).2).property + have h := B.comparison_space_top_frequency D E T hbQ hT V g hg D' hfreq + (Fintype.card (SubspaceFreeLift.Alphabet S)) d (FreeMagma.map e a) hd' hr' z hz + have heq : z ∘ e = (fun a : SubspaceFreeLift.Alphabet S => (J a.1 a.2).val) := by + funext i + change (J (e.symm (e i)).1 (e.symm (e i)).2).val = (J i.1 i.2).val + rw [e.symm_apply_apply] + rw [lieTreeEval_relabel, heq] at h + rw [hfreq] + exact h + +theorem CoefficientBases.native_comparison_frequency_zero + (hTfil : T.filtration = D.coefficientFreeFiltration) + (hfreq : V.frequency = B.freeFrequency D) : + let S := D.comparisonCoefficientSpace E T hbQ hT V g hg D' + let hS := D.comparisonCoefficientSpace_le_layer E T hbQ hT V g hg D' hTfil + ∀ (J : ∀ j, Basis (Fin (finrank ℚ (S j))) ℚ (S j)) + (M : RationalFilteredNilmanifold (SubspaceFreeLift.Algebra S r) s + (finrank ℚ (SubspaceFreeLift.Algebra S r))) (U : M.DegreeRankStructure r), + U.filtration = SubspaceFreeLift.filtration S T.filtration.rank_le_degree → + ∀ η : SubspaceFreeLift.Algebra S r →ₗ[ℚ] ℚ, + η = (pairDifferenceFunctional V.frequency).comp + (SubspaceFreeLift.evaluation S J + (RationalFilteredNilmanifold.piRank (fun _ : Fin 2 => E) (fun _ => T)).filtration hS).toLinearMap → + ∀ x ∈ U.filtration.layer s r, η x = 0 := by + intro S hS J M U hU η hη x hx + rw [hη] + change pairDifferenceFunctional V.frequency (SubspaceFreeLift.evaluation S J _ hS x) = 0 + apply B.comparison_free_top_frequency D E T hbQ hT V g hg D' hTfil hfreq J x + simpa only [hU] using hx + +end Erdos3.NativeRankRelation.CommonData + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ShiftFailurePositiveBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/ShiftFailurePositiveBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..33e29e0796333b2d17aa63453a873f2bb4f3035a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ShiftFailurePositiveBasis.lean @@ -0,0 +1,703 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonPositivePartitionRefinement +import OAI.Combinatorics.Progressions.Estimates.ControlledAdaptedRebase +import OAI.Combinatorics.Progressions.Nilpotent.CommonVariableDimensionNiltests + +namespace OAI + +section + +namespace Erdos3 + +theorem positive_basis_error_bound (p v : ℝ) : + 2 * Real.exp p * Real.exp (-(2 * p + 8)) + + Real.exp v * Real.exp (-(v + p + 8)) ≤ Real.exp (-p) / 2 := by + have hfirst : Real.exp p * Real.exp (-(2 * p + 8)) = Real.exp (-p) * Real.exp (-8) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + have hsecond : Real.exp v * Real.exp (-(v + p + 8)) = Real.exp (-p) * Real.exp (-8) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + have h6 : 6 * Real.exp (-8) ≤ 1 := by + calc + 6 * Real.exp (-8) ≤ Real.exp 8 * Real.exp (-8) := + mul_le_mul_of_nonneg_right (by linarith [Real.add_one_le_exp (8 : ℝ)]) (Real.exp_pos _).le + _ = 1 := by rw [← Real.exp_add]; norm_num + rw [mul_assoc (2 : ℝ), hfirst, hsecond] + have hmul := mul_le_mul_of_nonneg_left h6 (Real.exp_pos (-p)).le + nlinarith + +theorem exists_positive_basis_precision : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → ∃ q rho tau : ℝ, + p ≤ q ∧ q ≤ (p + C) ^ C ∧ verticalDecompositionBudget q ≤ (p + C) ^ C ∧ + 0 < rho ∧ rho⁻¹ ≤ Real.exp q ∧ 0 < tau ∧ Real.exp (-((p + C) ^ C)) ≤ tau ∧ + 2 * Real.exp p * rho + Real.exp (verticalDecompositionBudget q) * tau ≤ Real.exp (-p) / 2 := by + obtain ⟨c, _, hvertical⟩ := exists_verticalDecompositionBudget_bound + let X : Polynomial ℕ := Polynomial.X + let Q := 2 * X + 8 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (Q + (Q + Polynomial.C c) ^ c + X + 8) + refine ⟨C, hC, ?_⟩ + intro p hp + let q := 2 * p + 8 + have hpq : p ≤ q := by dsimp [q]; linarith + have hq0 : 0 ≤ q := hp.trans hpq + have hv0 := verticalDecompositionBudget_nonneg hq0 + have hb : q + (q + c) ^ c + p + 8 ≤ (p + C) ^ C := by + simpa [X, Q, q, Polynomial.eval₂_pow] using hbudget p hp + have hv := hvertical q hq0 + have hpow : 0 ≤ (q + c) ^ c := by positivity + have hqC : q ≤ (p + C) ^ C := by linarith + have hvC : verticalDecompositionBudget q + p + 8 ≤ (p + C) ^ C := by linarith + refine ⟨q, Real.exp (-q), Real.exp (-(verticalDecompositionBudget q + p + 8)), + hpq, hqC, by linarith, Real.exp_pos _, ?_, Real.exp_pos _, ?_, ?_⟩ + · rw [Real.exp_neg, inv_inv] + · exact Real.exp_le_exp.mpr (neg_le_neg hvC) + · exact positive_basis_error_bound p (verticalDecompositionBudget q) + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module CircleFourier +open scoped TensorProduct BigOperators + +theorem exists_quantitative_positive_basis : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} (T : D.Niltest (fun _ : Unit => 1)) + {p : ℝ}, 0 ≤ p → T.UnitIntervalValued → T.ComplexityLE p → T.normBound ≤ 1 → + ∀ {N : ℕ} [NeZero N] (weight : ZMod N → ℂ), (∀ x, ‖weight x‖ ≤ Real.exp p) → + ∃ (m : ℕ) (eta : Fin m → L →ₗ[ℚ] ℚ) (U : Fin m → D.Niltest (fun _ : Unit => 1)) + (S : D.Niltest (fun _ : Unit => 1)), + m ≤ d ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ (p + C) ^ C) ∧ + (∀ j, (U j).ComplexityLE ((p + C) ^ C) ∧ (U j).orbit = T.orbit ∧ (U j).normBound ≤ 1) ∧ + (∀ j z, z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) ∧ + (∀ j, Real.exp (-((p + C) ^ C)) < ‖𝔼 n, weight n * (U j).evalCyclic N (fun _ => n)‖) ∧ + LinearIndependent ℚ (fun j => (eta j).comp (D.filtration.layer s).subtype) ∧ + S.UnitIntervalValued ∧ S.ComplexityLE ((p + C) ^ C) ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z ∈ D.filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j) z.coord = 0) → ∀ x, S.observable (z • x) = S.observable x) ∧ + ‖(𝔼 n, weight n * T.evalCyclic N (fun _ => n)) - + (𝔼 n, weight n * S.evalCyclic N (fun _ => n))‖ ≤ Real.exp (-p) / 2 := by + obtain ⟨C, hC, hprecision⟩ := exists_positive_basis_precision + refine ⟨C, hC, ?_⟩ + intro L _ _ s d _ _ _ _ D T p hp hT hTc hcap N _ weight hweight + obtain ⟨q, rho, tau, hpq, hqC, hvC, hrho, hrhoq, htau, htauC, hsmall⟩ := hprecision p hp + obtain ⟨J, inst, hresult⟩ := T.exists_bounded_positive_fourier_basis (hp.trans hpq) + hT (hTc.mono hpq) hcap hrho hrhoq htau.le (Real.exp_pos p).le weight hweight + let := inst + obtain ⟨eta, U, S, m, indices, _, hheight, hU, hvert, hmd, hcorr, hlin, hS, hSc, hSo, hinv, herr⟩ := hresult + exact ⟨m, (fun j => eta (indices j)), (fun j => U (indices j)), S, hmd, + (fun j i => (hheight (indices j) i).trans hvC), + (fun j => ⟨(hU (indices j)).1.mono hqC, (hU (indices j)).2⟩), + (fun j => hvert (indices j)), (fun j => htauC.trans_lt (hcorr j)), hlin, + hS, hSc.mono hqC, hSo, hinv, herr.trans hsmall⟩ + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +theorem positive_violation_of_norm_sub_le {a b : ℂ} {delta error : ℝ} + (hviolation : delta < a.re) (herror : ‖a - b‖ ≤ error) (hsmall : error ≤ delta / 2) : + delta / 2 < b.re := by + have h := Complex.re_le_norm (a - b) + rw [Complex.sub_re] at h + linarith + +namespace RationalFilteredNilmanifold + +open Module CircleFourier +open scoped TensorProduct BigOperators + +theorem exists_common_positive_basis : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {G L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (H : Finset G), H.Nonempty → + ∀ (T : G → D.Niltest (fun _ : Unit => 1)) {p delta : ℝ}, 0 ≤ p → + Real.exp (-p) ≤ delta → + (∀ h ∈ H, (T h).UnitIntervalValued) → + (∀ h ∈ H, (T h).ComplexityLE p) → (∀ h ∈ H, (T h).normBound ≤ 1) → + ∀ {N : ℕ} [NeZero N] (weight : G → ZMod N → ℂ), + (∀ h ∈ H, ∀ n, ‖weight h n‖ ≤ Real.exp p) → + (∀ h ∈ H, delta < (𝔼 n, weight h n * (T h).evalCyclic N (fun _ => n)).re) → + ∃ (m : ℕ) (H' : Finset G) (eta : G → Fin m → L →ₗ[ℚ] ℚ) + (U : G → Fin m → D.Niltest (fun _ : Unit => 1)) (S : G → D.Niltest (fun _ : Unit => 1)), + m ≤ d ∧ H' ⊆ H ∧ H'.Nonempty ∧ Real.exp (-((p + C) ^ C)) * H.card ≤ (H'.card : ℝ) ∧ + ∀ h ∈ H', + (∀ j i, rationalLogHeight (eta h j (D.basis i)) ≤ (p + C) ^ C) ∧ + (∀ j, (U h j).ComplexityLE ((p + C) ^ C) ∧ (U h j).orbit = (S h).orbit ∧ (U h j).normBound ≤ 1) ∧ + (∀ j z, z ∈ D.filtration.realification.subgroup s → ∀ x, + (U h j).observable (z • x) = character + ((realifyFunctional (eta h j) z.coord : ℝ) : CircleFourier.Circle) * (U h j).observable x) ∧ + (∀ j, Real.exp (-((p + C) ^ C)) < ‖𝔼 n, weight h n * (U h j).evalCyclic N (fun _ => n)‖) ∧ + LinearIndependent ℚ (fun j => (eta h j).comp (D.filtration.layer s).subtype) ∧ + (S h).UnitIntervalValued ∧ (S h).ComplexityLE ((p + C) ^ C) ∧ (S h).orbit = (T h).orbit ∧ + (∀ z : D.RealGroup, z ∈ D.filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta h j) z.coord = 0) → ∀ x, + (S h).observable (z • x) = (S h).observable x) ∧ + delta / 2 < (𝔼 n, weight h n * (S h).evalCyclic N (fun _ => n)).re := by + classical + obtain ⟨c, _, hbasis⟩ := Niltest.exists_quantitative_positive_basis + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (X + (X + Polynomial.C c) ^ c + 1) + refine ⟨C, hC, ?_⟩ + intro G L _ _ s d _ _ _ _ D H hH T p delta hp hdelta hT hTc hcap N _ weight hweight hviolation + obtain ⟨hbase, hhbase⟩ := hH + let pick (h : G) := if h ∈ H then h else hbase + have hpick (h : G) : pick h ∈ H := by + dsimp only [pick] + split_ifs with hh + · exact hh + · exact hhbase + have hchoices (h : G) := hbasis (T (pick h)) hp (hT _ (hpick h)) (hTc _ (hpick h)) + (hcap _ (hpick h)) (weight (pick h)) (hweight _ (hpick h)) + choose m eta U S hm hheight hU hvert hcorr hlin hS hSc hSo hinv herr using hchoices + have hd : (d : ℝ) ≤ p := (hTc hbase hhbase).1.1 + have hpexp : p ≤ Real.exp p := by linarith [Real.add_one_le_exp p] + obtain ⟨a, _, H', hsub, ha, hsame, hlarge⟩ := + exists_common_bounded_moduli H ⟨hbase, hhbase⟩ (fun h (_ : Unit) => m h) hp + (fun h _ _ => ((Nat.cast_le.mpr (hm h)).trans hd).trans hpexp) + let index (h : G) (hh : h ∈ H') : Fin (m a) ≃ Fin (m h) := + (finCongr (congrFun (hsame h hh) ())).symm + let eta' (h : G) (j : Fin (m a)) : L →ₗ[ℚ] ℚ := + if hh : h ∈ H' then eta h (index h hh j) else 0 + let U' (h : G) (j : Fin (m a)) : D.Niltest (fun _ : Unit => 1) := + if hh : h ∈ H' then U h (index h hh j) else Niltest.const D (fun _ => 1) 0 + have hbud : p + (p + c) ^ c + 1 ≤ (p + C) ^ C := by + simpa [X, Polynomial.eval₂_pow] using hbudget p hp + have hcC : (p + c) ^ c ≤ (p + C) ^ C := by linarith + have hpC : p + 1 ≤ (p + C) ^ C := by + have hn : 0 ≤ (p + c) ^ c := by positivity + linarith + have hlarge' : Real.exp (-(p + 1)) * H.card ≤ (H'.card : ℝ) := by + simpa only [Fintype.card_unit, Nat.cast_one, mul_one] using hlarge + refine ⟨m a, H', eta', U', S, hm a, hsub, ⟨a, ha⟩, + (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hpC)) + (Nat.cast_nonneg _)).trans hlarge', ?_⟩ + intro h hh + have hpickh : pick h = h := ite_eq_left (hsub hh) + simp only [eta', U', dite_eq_left hh] + refine ⟨(fun j i => (hheight h (index h hh j) i).trans hcC), ?_, + (fun j => hvert h (index h hh j)), ?_, ?_, hS h, (hSc h).mono hcC, ?_, ?_, ?_⟩ + · intro j + exact ⟨(hU h (index h hh j)).1.mono hcC, + (hU h (index h hh j)).2.1.trans (hSo h).symm, (hU h (index h hh j)).2.2⟩ + · intro j + have ht := (Real.exp_le_exp.mpr (neg_le_neg hcC)).trans_lt (hcorr h (index h hh j)) + simpa only [hpickh] using ht + · exact (hlin h).comp (index h hh) (index h hh).injective + · simpa only [hpickh] using hSo h + · intro z hz hzero x + apply hinv h z hz _ x + intro i + obtain ⟨j, rfl⟩ := (index h hh).surjective i + exact hzero j + · have he : ‖(𝔼 n, weight h n * (T h).evalCyclic N (fun _ => n)) - + (𝔼 n, weight h n * (S h).evalCyclic N (fun _ => n))‖ ≤ Real.exp (-p) / 2 := by + simpa only [hpickh] using herr h + exact positive_violation_of_norm_sub_le (hviolation h (hsub hh)) he (by linarith) + +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module CircleFourier +open scoped TensorProduct BigOperators + +theorem exists_common_model_positive_basis (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {G : Type*} {L : G → Type*} + [∀ h, LieRing (L h)] [∀ h, LieAlgebra ℚ (L h)] + [∀ h, TopologicalSpace (ℝ ⊗[ℚ] L h)] [∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] L h)] + [∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] L h)] [∀ h, T2Space (ℝ ⊗[ℚ] L h)] {d : G → ℕ} + (D : ∀ h, RationalFilteredNilmanifold (L h) s (d h)) + (T : ∀ h, (D h).Niltest (fun _ : Unit => 1)) (H : Finset G), H.Nonempty → + ∀ {p delta : ℝ}, 0 ≤ p → Real.exp (-p) ≤ delta → (∀ h, (T h).ComplexityLE p) → + (∀ h ∈ H, (T h).UnitIntervalValued) → + ∀ {N : ℕ} [NeZero N] (weight : G → ZMod N → ℂ), + (∀ h ∈ H, ∀ n, ‖weight h n‖ ≤ Real.exp p) → + (∀ h ∈ H, delta < (𝔼 n, weight h n * (T h).evalCyclic N (fun _ => n)).re) → + ∃ h₀ ∈ H, ∃ E : RationalFilteredNilmanifold (L h₀) s (d h₀), + E.GeometryComplexityLE ((p + C) ^ C) ∧ + ∃ (m : ℕ) (H' : Finset G) (eta : G → Fin m → L h₀ →ₗ[ℚ] ℚ) + (U : G → Fin m → E.Niltest (fun _ : Unit => 1)) (S : G → E.Niltest (fun _ : Unit => 1)), + m ≤ d h₀ ∧ H' ⊆ H ∧ H'.Nonempty ∧ Real.exp (-((p + C) ^ C)) * H.card ≤ (H'.card : ℝ) ∧ + ∀ h ∈ H', + (∀ j i, rationalLogHeight (eta h j (E.basis i)) ≤ (p + C) ^ C) ∧ + (∀ j, (U h j).ComplexityLE ((p + C) ^ C) ∧ (U h j).orbit = (S h).orbit ∧ (U h j).normBound ≤ 1) ∧ + (∀ j z, z ∈ E.filtration.realification.subgroup s → ∀ x, + (U h j).observable (z • x) = character + ((realifyFunctional (eta h j) z.coord : ℝ) : CircleFourier.Circle) * (U h j).observable x) ∧ + (∀ j, Real.exp (-((p + C) ^ C)) < ‖𝔼 n, weight h n * (U h j).evalCyclic N (fun _ => n)‖) ∧ + LinearIndependent ℚ (fun j => (eta h j).comp (E.filtration.layer s).subtype) ∧ + (S h).UnitIntervalValued ∧ (S h).ComplexityLE ((p + C) ^ C) ∧ + (∀ z : E.RealGroup, z ∈ E.filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta h j) z.coord = 0) → ∀ x, + (S h).observable (z • x) = (S h).observable x) ∧ + delta / 2 < (𝔼 n, weight h n * (S h).evalCyclic N (fun _ => n)).re := by + classical + obtain ⟨c, _, hmodels⟩ := exists_common_variable_dimension_niltest_model s + obtain ⟨k, _, hbases⟩ := exists_common_positive_basis + let X : Polynomial ℕ := Polynomial.X + let Q := X + 1 + (X + 1 + Polynomial.C c) ^ c + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Q + (Q + Polynomial.C k) ^ k) + refine ⟨C, hC, ?_⟩ + intro G L _ _ _ _ _ _ d D T H hH p delta hp hdelta hTc hT N _ weight hweight hviolation + let T₀ : ∀ h, (D h).Niltest (fun _ : Unit => 1) := fun h => + if hh : h ∈ H then (T h).withUnitBound (hT h hh).norm_le_one else T h + have hTc₀ (h) : (T₀ h).ComplexityLE (p + 1) := by + by_cases hh : h ∈ H + · simpa only [T₀, dite_eq_left hh] using + (T h).withUnitBound_complexity (hT h hh).norm_le_one (hTc h) + · simpa only [T₀, dite_eq_right hh] using (hTc h).mono (by linarith : p ≤ p + 1) + have hT₀ (h) (hh : h ∈ H) : (T₀ h).UnitIntervalValued := by + simp only [T₀, dite_eq_left hh] + exact hT h hh + have hcap₀ (h) (hh : h ∈ H) : (T₀ h).normBound ≤ 1 := by + simp only [T₀, dite_eq_left hh] + exact le_rfl + have hvalue₀ (h) (hh : h ∈ H) (x : Unit → ℤ) : (T₀ h).eval x = (T h).eval x := by + simp only [T₀, dite_eq_left hh, Niltest.withUnitBound_eval] + let q := p + 1 + (p + 1 + c) ^ c + 2 + have hpow : 0 ≤ (p + 1 + c) ^ c := by positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have hmodelq : (p + 1 + c) ^ c ≤ q := by dsimp [q]; linarith + have hq0 : 0 ≤ q := hp.trans hpq + have hbud : q + (q + k) ^ k ≤ (p + C) ^ C := by + simpa [Q, X, q, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := by + have hh : 0 ≤ (q + k) ^ k := by positivity + linarith + have hbaseC : (q + k) ^ k ≤ (p + C) ^ C := by linarith + have hloss : (p + 1 + c) ^ c + (q + k) ^ k ≤ (p + C) ^ C := by linarith + obtain ⟨h₀, hh₀, E, hE, H₁, P, hsub₁, hh₀', hlarge₁, hP⟩ := + hmodels D T₀ H hH (by linarith : 0 ≤ p + 1) hTc₀ + have hPc (h) (hh : h ∈ H₁) : (P h).ComplexityLE q := (hP h hh).1.mono hmodelq + have hPunit (h) (hh : h ∈ H₁) : (P h).UnitIntervalValued := (hP h hh).2.2.2 (hT₀ h (hsub₁ hh)) + have hPcap (h) (hh : h ∈ H₁) : (P h).normBound ≤ 1 := by + rw [(hP h hh).2.1] + exact hcap₀ h (hsub₁ hh) + have hPvalue (h) (hh : h ∈ H₁) (n : ZMod N) : + (P h).evalCyclic N (fun _ => n) = (T h).evalCyclic N (fun _ => n) := + ((hP h hh).2.2.1 _).trans (hvalue₀ h (hsub₁ hh) _) + have hPviolation (h) (hh : h ∈ H₁) : + delta < (𝔼 n, weight h n * (P h).evalCyclic N (fun _ => n)).re := by + simpa only [hPvalue h hh] using hviolation h (hsub₁ hh) + obtain ⟨m, H₂, eta, U, S, hm, hsub₂, hnonempty, hlarge₂, hbasis⟩ := + hbases E H₁ ⟨h₀, hh₀'⟩ P hq0 + ((Real.exp_le_exp.mpr (neg_le_neg hpq)).trans hdelta) hPunit hPc hPcap weight + (fun h hh n => (hweight h (hsub₁ hh) n).trans (Real.exp_le_exp.mpr hpq)) hPviolation + refine ⟨h₀, hh₀, E, hE.mono E (hmodelq.trans hqC), m, H₂, eta, U, S, hm, + hsub₂.trans hsub₁, hnonempty, ?_, ?_⟩ + · calc + Real.exp (-((p + C) ^ C)) * H.card ≤ + Real.exp (-((p + 1 + c) ^ c + (q + k) ^ k)) * H.card := + mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hloss)) (Nat.cast_nonneg _) + _ = Real.exp (-((q + k) ^ k)) * (Real.exp (-((p + 1 + c) ^ c)) * H.card) := by + rw [← mul_assoc, ← Real.exp_add] + congr 2 + ring + _ ≤ Real.exp (-((q + k) ^ k)) * H₁.card := + mul_le_mul_of_nonneg_left hlarge₁ (Real.exp_pos _).le + _ ≤ H₂.card := hlarge₂ + · intro h hh + obtain ⟨hheight, hU, hvert, hcorr, hlin, hS, hSc, _, hinv, hv⟩ := hbasis h hh + exact ⟨(fun j i => (hheight j i).trans hbaseC), + (fun j => ⟨(hU j).1.mono hbaseC, (hU j).2⟩), hvert, + (fun j => (Real.exp_le_exp.mpr (neg_le_neg hbaseC)).trans_lt (hcorr j)), + hlin, hS, hSc.mono hbaseC, hinv, hv⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +universe u + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators + +structure PositiveShiftBasis (degree N : ℕ) [NeZero N] (p : ℝ) + (a J : ZMod N → ℝ) where + L : Type u + [lie : LieRing L] + [algebra : LieAlgebra ℚ L] + dim : ℕ + [topology : TopologicalSpace (ℝ ⊗[ℚ] L)] + [topologicalAdd : IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [continuousSMul : ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + [hausdorff : T2Space (ℝ ⊗[ℚ] L)] + model : RationalFilteredNilmanifold L degree dim + geometry : model.GeometryComplexityLE p + count : ℕ + count_le_dim : count ≤ dim + shifts : Finset (ZMod N) + shifts_nonempty : shifts.Nonempty + shifts_large : Real.exp (-p) * N ≤ (shifts.card : ℝ) + frequency : ZMod N → Fin count → L →ₗ[ℚ] ℚ + mode : ZMod N → Fin count → model.Niltest (fun _ : Unit => 1) + test : ZMod N → model.Niltest (fun _ : Unit => 1) + frequency_height : ∀ h ∈ shifts, ∀ j i, rationalLogHeight (frequency h j (model.basis i)) ≤ p + mode_complexity : ∀ h ∈ shifts, ∀ j, (mode h j).ComplexityLE p + mode_orbit : ∀ h ∈ shifts, ∀ j, (mode h j).orbit = (test h).orbit + mode_norm : ∀ h ∈ shifts, ∀ j, (mode h j).normBound ≤ 1 + mode_vertical : ∀ h ∈ shifts, ∀ j z, z ∈ model.filtration.realification.subgroup degree → ∀ x, + (mode h j).observable (z • x) = character + ((realifyFunctional (frequency h j) z.coord : ℝ) : CircleFourier.Circle) * (mode h j).observable x + mode_bias : ∀ h ∈ shifts, ∀ j, Real.exp (-p) < + ‖𝔼 n, (mode h j).evalCyclic N (fun _ => n) * (a n : ℂ) * (J (n + h) : ℂ)‖ + independent : ∀ h ∈ shifts, + LinearIndependent ℚ (fun j => (frequency h j).comp (model.filtration.layer degree).subtype) + test_positive : ∀ h ∈ shifts, (test h).UnitIntervalValued + test_complexity : ∀ h ∈ shifts, (test h).ComplexityLE p + test_invariant : ∀ h ∈ shifts, ∀ z : model.RealGroup, + z ∈ model.filtration.realification.subgroup degree → + (∀ j, realifyFunctional (frequency h j) z.coord = 0) → ∀ x, + (test h).observable (z • x) = (test h).observable x + test_violation : ∀ h ∈ shifts, Real.exp (-p) < + 𝔼 n, a n * J (n + h) * ((test h).evalCyclic N (fun _ => n)).re + +end Erdos3 + +end + +section + +universe u + +namespace Erdos3.PositiveShiftBasis + +open Module +open scoped TensorProduct BigOperators + +attribute [local instance] PositiveShiftBasis.lie PositiveShiftBasis.algebra + PositiveShiftBasis.topology PositiveShiftBasis.topologicalAdd + PositiveShiftBasis.continuousSMul PositiveShiftBasis.hausdorff + +theorem exists_adapted : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {s N : ℕ} [NeZero N] {p : ℝ} {a J : ZMod N → ℝ} + (B : PositiveShiftBasis.{u} s N p a J), + ∃ (B' : PositiveShiftBasis.{u} s N ((p + C) ^ C) a J) (hcount : B'.count = B.count), + (∃ weight : Fin B'.dim → ℕ, ∀ i, B'.model.filtration.layer i = + Submodule.span ℚ (B'.model.basis '' {j | i ≤ weight j})) ∧ + B'.shifts = B.shifts ∧ + (∀ h j x, (B'.mode h j).eval x = (B.mode h (Fin.cast hcount j)).eval x) ∧ + ∀ h x, (B'.test h).eval x = (B.test h).eval x := by + obtain ⟨C, hC, hrebase⟩ := RationalFilteredNilmanifold.exists_controlled_adapted_rebase + refine ⟨C, hC, ?_⟩ + intro s N _ p a J B + have hp : 0 ≤ p := (Nat.cast_nonneg B.dim).trans B.geometry.1 + obtain ⟨F, H, hH, hbase, hF, hcomp, hfreq⟩ := hrebase B.model hp B.geometry + have hdim : finrank ℚ B.L = B.dim := by + simpa only [Fintype.card_fin] using finrank_eq_card_basis B.model.basis + let B' : PositiveShiftBasis s N ((p + C) ^ C) a J := { + L := B.L + lie := B.lie + algebra := B.algebra + dim := finrank ℚ B.L + topology := B.topology + topologicalAdd := B.topologicalAdd + continuousSMul := B.continuousSMul + hausdorff := B.hausdorff + model := F.model + geometry := hF + count := B.count + count_le_dim := by rw [hdim]; exact B.count_le_dim + shifts := B.shifts + shifts_nonempty := B.shifts_nonempty + shifts_large := (mul_le_mul_of_nonneg_right + (Real.exp_le_exp.mpr (neg_le_neg hbase)) (Nat.cast_nonneg N)).trans B.shifts_large + frequency := B.frequency + mode := fun h j => F.rebaseNiltest H hH (B.mode h j) + test := fun h => F.rebaseNiltest H hH (B.test h) + frequency_height := fun h hh j => hfreq (B.frequency h j) (B.frequency_height h hh j) + mode_complexity := fun h hh j => hcomp (B.mode h j) (B.mode_complexity h hh j) + mode_orbit := fun h hh j => B.mode_orbit h hh j + mode_norm := fun h hh j => B.mode_norm h hh j + mode_vertical := fun h hh j => B.mode_vertical h hh j + mode_bias := fun h hh j => (Real.exp_le_exp.mpr (neg_le_neg hbase)).trans_lt (B.mode_bias h hh j) + independent := fun h hh => B.independent h hh + test_positive := fun h hh => B.test_positive h hh + test_complexity := fun h hh => hcomp (B.test h) (B.test_complexity h hh) + test_invariant := fun h hh => B.test_invariant h hh + test_violation := fun h hh => (Real.exp_le_exp.mpr (neg_le_neg hbase)).trans_lt (B.test_violation h hh) } + exact ⟨B', rfl, ⟨F.weight, F.model_layers⟩, rfl, fun _ _ _ => rfl, fun _ _ => rfl⟩ + +end Erdos3.PositiveShiftBasis + +end + +section + +namespace Erdos3.PositiveShiftBasis + +attribute [local instance] PositiveShiftBasis.lie PositiveShiftBasis.algebra + PositiveShiftBasis.topology PositiveShiftBasis.topologicalAdd + PositiveShiftBasis.continuousSMul PositiveShiftBasis.hausdorff + +def mono {s N : ℕ} [NeZero N] {p q : ℝ} {a J : ZMod N → ℝ} + (B : PositiveShiftBasis s N p a J) (hpq : p ≤ q) : PositiveShiftBasis s N q a J where + L := B.L + lie := B.lie + algebra := B.algebra + dim := B.dim + topology := B.topology + topologicalAdd := B.topologicalAdd + continuousSMul := B.continuousSMul + hausdorff := B.hausdorff + model := B.model + geometry := B.geometry.mono B.model hpq + count := B.count + count_le_dim := B.count_le_dim + shifts := B.shifts + shifts_nonempty := B.shifts_nonempty + shifts_large := (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hpq)) + (Nat.cast_nonneg N)).trans B.shifts_large + frequency := B.frequency + mode := B.mode + test := B.test + frequency_height := fun h hh j i => (B.frequency_height h hh j i).trans hpq + mode_complexity := fun h hh j => (B.mode_complexity h hh j).mono hpq + mode_orbit := B.mode_orbit + mode_norm := B.mode_norm + mode_vertical := B.mode_vertical + mode_bias := fun h hh j => (Real.exp_le_exp.mpr (neg_le_neg hpq)).trans_lt (B.mode_bias h hh j) + independent := B.independent + test_positive := B.test_positive + test_complexity := fun h hh => (B.test_complexity h hh).mono hpq + test_invariant := B.test_invariant + test_violation := fun h hh => (Real.exp_le_exp.mpr (neg_le_neg hpq)).trans_lt (B.test_violation h hh) + +end Erdos3.PositiveShiftBasis + +end + +section + +namespace Erdos3.PositiveShiftBasis + +open scoped BigOperators + +attribute [local instance] PositiveShiftBasis.lie PositiveShiftBasis.algebra + PositiveShiftBasis.topology PositiveShiftBasis.topologicalAdd + PositiveShiftBasis.continuousSMul PositiveShiftBasis.hausdorff + +variable {s N : ℕ} [NeZero N] {q : ℝ} {a J : ZMod N → ℝ} + +noncomputable def testingFamily (B : PositiveShiftBasis s N q a J) : + ZMod N × Fin B.count → ZMod N → ℂ := by + classical + exact fun hk n => if hk.1 ∈ B.shifts then (B.mode hk.1 hk.2).evalCyclic N (fun _ => n) else 0 + +theorem testingFamily_of_mem (B : PositiveShiftBasis s N q a J) {h : ZMod N} + (hh : h ∈ B.shifts) (j : Fin B.count) (n : ZMod N) : + B.testingFamily (h, j) n = (B.mode h j).evalCyclic N (fun _ => n) := by + simp only [testingFamily, ite_eq_left hh] + +theorem testingFamily_norm_le (B : PositiveShiftBasis s N q a J) + (hk : ZMod N × Fin B.count) (n : ZMod N) : ‖B.testingFamily hk n‖ ≤ 1 := by + classical + by_cases hh : hk.1 ∈ B.shifts + · rw [testingFamily, ite_eq_left hh] + exact ((B.mode hk.1 hk.2).norm_evalCyclic_le N _).trans (B.mode_norm hk.1 hh hk.2) + · simp only [testingFamily, ite_eq_right hh, norm_zero, zero_le_one] + +theorem exists_fixed_partners (B : PositiveShiftBasis s N q a J) + {I : Type*} {K : I → Type*} [Fintype I] [∀ i, Fintype (K i)] + (Q : I → ZMod N → ℂ) (R : ∀ i, K i → ZMod N → ℂ) + (ea : ZMod N → ℂ) (eb : I → ZMod N → ℂ) (c : I → ℂ) (d : ∀ i, K i → ℂ) + (ha : ∀ n, (a n : ℂ) = (∑ i, c i * Q i n) + ea n) + (hb : ∀ i n, (J n : ℂ) = (∑ j, d i j * R i j n) + eb i n) + {p M : ℝ} (hqp : q ≤ p) + (hc : (∑ i, ‖c i‖) ≤ Real.exp p) (hd : ∀ i, (∑ j, ‖d i j‖) ≤ Real.exp p) + (hJ : ∀ n, |J n| ≤ M) (hQ : ∀ i n, ‖Q i n‖ ≤ 1) + (herror : shiftTestingSeminorm (fun n => (J n : ℂ)) B.testingFamily ea + + ∑ i, ‖c i‖ * shiftTestingSeminorm (Q i) (translatedTestFamily B.testingFamily) (eb i) ≤ + Real.exp (-(2 * q + 2))) + (hcount : (Fintype.card (Sigma K) : ℝ) ≤ Real.exp p) : + ∃ (choice : Fin B.count → Sigma K) (S : Finset (ZMod N)), S ⊆ B.shifts ∧ S.Nonempty ∧ + Real.exp (-((p + 2) ^ 2)) * N ≤ (S.card : ℝ) ∧ + ∀ h ∈ S, ∀ j, Real.exp (-((p + 2) ^ 2)) ≤ + ‖𝔼 n, (B.mode h j).evalCyclic N (fun _ => n) * Q (choice j).1 n * + R (choice j).1 (choice j).2 (n + h)‖ := by + have hq : 0 ≤ q := (Nat.cast_nonneg B.dim).trans B.geometry.1 + have hK : (Fintype.card (Fin B.count) : ℝ) ≤ p := by + rw [Fintype.card_fin] + exact (Nat.cast_le.mpr B.count_le_dim).trans (B.geometry.1.trans hqp) + have hH : Real.exp (-q) * Fintype.card (ZMod N) ≤ (B.shifts.card : ℝ) := by + simpa only [ZMod.card] using B.shifts_large + have hbcap (n) : ‖(J n : ℂ)‖ ≤ M := by simpa only [Complex.norm_real, Real.norm_eq_abs] using hJ n + have hcorr (h) (hh : h ∈ B.shifts) (j : Fin B.count) : + Real.exp (-q) ≤ ‖𝔼 n, B.testingFamily (h, j) n * (a n : ℂ) * (J (n + h) : ℂ)‖ := by + simp only [testingFamily_of_mem B hh] + exact (B.mode_bias h hh j).le + obtain ⟨choice, S, hsub, hSn, hlarge, hbias⟩ := exists_fixed_partners_power B.shifts + (fun n => (a n : ℂ)) (fun n => (J n : ℂ)) ea B.testingFamily (fun h j => (h, j)) + Q R eb c d ha hb (hq.trans hqp) hqp hK hc hd B.testingFamily_norm_le hbcap hQ herror hH hcorr hcount + refine ⟨choice, S, hsub, hSn, ?_, ?_⟩ + · simpa only [ZMod.card] using hlarge + · intro h hh j + simpa only [testingFamily_of_mem B (hsub hh)] using hbias h hh j + +end Erdos3.PositiveShiftBasis + +end + +section + +universe u + +namespace Erdos3 + +open Module CircleFourier +open scoped TensorProduct BigOperators + +theorem exists_positive_basis_of_shift_failure (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p epsilon : ℝ}, 0 ≤ p → + 0 ≤ epsilon → epsilon ≤ 1 → ∀ f g J : ZMod N → ℝ, + (∀ n, 0 ≤ f n ∧ f n ≤ Real.exp p) → + (∀ n, 0 ≤ g n ∧ g n ≤ Real.exp p) → + (∀ n, 0 ≤ J n ∧ J n ≤ Real.exp p) → + (¬ ∃ E : Finset (ZMod N), (E.card : ℝ) ≤ Real.exp (-p) * N ∧ + CyclicNiltestShiftBound.{u} s N p (Real.exp (-p)) + (fun n => f n - (1 + epsilon) * g n) J E) → + Nonempty (PositiveShiftBasis.{u} s N ((p + C) ^ C) + (fun n => f n - (1 + epsilon) * g n) J) := by + classical + obtain ⟨c, _, hmodels⟩ := RationalFilteredNilmanifold.exists_common_model_positive_basis s + let X : Polynomial ℕ := Polynomial.X + let T := X + (X + 2) ^ 2 + 3 + 2 * X + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (T + (T + Polynomial.C c) ^ c + X + 2) + refine ⟨C, hC, ?_⟩ + intro N _ p epsilon hp hepsilon hepsilon1 f g J hf hg hJ hfailure + let a := fun n => f n - (1 + epsilon) * g n + obtain ⟨H, F, hH, hlarge, hF, hviolation⟩ := + exists_many_positive_cyclic_violations a J (Real.exp_pos (-p)).le hfailure + let R := fun h => Classical.choice ((hF h).model_nonempty hp) + let L := fun h => (R h).L + let : ∀ h, LieRing (L h) := fun h => (R h).lie + let : ∀ h, LieAlgebra ℚ (L h) := fun h => (R h).algebra + let : ∀ h, TopologicalSpace (ℝ ⊗[ℚ] L h) := fun h => (R h).topology + let : ∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] L h) := fun h => (R h).topologicalAdd + let : ∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] L h) := fun h => (R h).continuousSMul + let : ∀ h, T2Space (ℝ ⊗[ℚ] L h) := fun h => (R h).hausdorff + let t := raisedNiltestBudget p + 2 * p + 2 + have hraised : 0 ≤ raisedNiltestBudget p := hp.trans (le_raisedNiltestBudget p) + have hrt : raisedNiltestBudget p ≤ t := by dsimp [t]; linarith + have hwt : 2 * p + 2 ≤ t := by dsimp [t]; linarith + have hpt : p ≤ t := (le_raisedNiltestBudget p).trans hrt + have ht : 0 ≤ t := hp.trans hpt + have hbud : t + (t + c) ^ c + p + 2 ≤ (p + C) ^ C := by + simpa [T, X, t, raisedNiltestBudget, Polynomial.eval₂_pow] using hbudget p hp + have hcomp : (t + c) ^ c ≤ (p + C) ^ C := by linarith + have hloss : p + (t + c) ^ c ≤ (p + C) ^ C := by linarith + have hhalf : Real.exp (-((p + C) ^ C)) ≤ Real.exp (-p) / 2 := by + have hpow : 0 ≤ (t + c) ^ c := by positivity + exact (Real.exp_le_exp.mpr (by linarith : -((p + C) ^ C) ≤ -p - 1)).trans + (exp_sub_one_le_half_exp (-p)) + let weight : ZMod N → ZMod N → ℂ := fun h n => ((a n * J (n + h) : ℝ) : ℂ) + have hw (h n : ZMod N) : ‖weight h n‖ ≤ Real.exp t := + (shift_violation_weight_cap hepsilon hepsilon1 f g J hf hg hJ h n).trans + (Real.exp_le_exp.mpr hwt) + have hv (h) (hh : h ∈ H) : Real.exp (-p) < + (𝔼 n, weight h n * (R h).test.evalCyclic N (fun _ => n)).re := by + change Real.exp (-p) < (𝔼 n, ((a n * J (n + h) : ℝ) : ℂ) * + (R h).test.evalCyclic N (fun _ => n)).re + rw [real_shift_weighted_mean] + simpa only [(R h).eval] using hviolation h hh + obtain ⟨h₀, _, E, hE, m, H', eta, U, S, hm, _, hH', hlarge', hresult⟩ := + hmodels (fun h => (R h).model) (fun h => (R h).test) H hH ht + (Real.exp_le_exp.mpr (neg_le_neg hpt)) + (fun h => (R h).complexity.mono hrt) (fun h _ => (R h).positive) weight + (fun h _ n => hw h n) hv + have hdensity : Real.exp (-((p + C) ^ C)) * N ≤ (H'.card : ℝ) := by + calc + _ ≤ Real.exp (-(p + (t + c) ^ c)) * N := + mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg hloss)) (Nat.cast_nonneg N) + _ = Real.exp (-((t + c) ^ c)) * (Real.exp (-p) * N) := by + rw [← mul_assoc, ← Real.exp_add] + congr 2 + ring + _ ≤ Real.exp (-((t + c) ^ c)) * H.card := + mul_le_mul_of_nonneg_left hlarge.le (Real.exp_pos _).le + _ ≤ H'.card := hlarge' + refine ⟨{ + L := L h₀ + lie := inferInstance + algebra := inferInstance + dim := (R h₀).dim + topology := inferInstance + topologicalAdd := inferInstance + continuousSMul := inferInstance + hausdorff := inferInstance + model := E + geometry := hE.mono E hcomp + count := m + count_le_dim := hm + shifts := H' + shifts_nonempty := hH' + shifts_large := hdensity + frequency := eta + mode := U + test := S + frequency_height := ?_ + mode_complexity := ?_ + mode_orbit := ?_ + mode_norm := ?_ + mode_vertical := ?_ + mode_bias := ?_ + independent := ?_ + test_positive := ?_ + test_complexity := ?_ + test_invariant := ?_ + test_violation := ?_ }⟩ + · exact fun h hh j i => ((hresult h hh).1 j i).trans hcomp + · exact fun h hh j => ((hresult h hh).2.1 j).1.mono hcomp + · exact fun h hh j => ((hresult h hh).2.1 j).2.1 + · exact fun h hh j => ((hresult h hh).2.1 j).2.2 + · exact fun h hh => (hresult h hh).2.2.1 + · intro h hh j + have hc := (Real.exp_le_exp.mpr (neg_le_neg hcomp)).trans_lt ((hresult h hh).2.2.2.1 j) + have he : (𝔼 n, weight h n * (U h j).evalCyclic N (fun _ => n)) = + 𝔼 n, (U h j).evalCyclic N (fun _ => n) * (a n : ℂ) * (J (n + h) : ℂ) := by + apply Finset.expect_congr rfl + intro n _ + dsimp only [weight] + rw [Complex.ofReal_mul] + ring + simpa only [he] using hc + · exact fun h hh => (hresult h hh).2.2.2.2.1 + · exact fun h hh => (hresult h hh).2.2.2.2.2.1 + · exact fun h hh => (hresult h hh).2.2.2.2.2.2.1.mono hcomp + · exact fun h hh => (hresult h hh).2.2.2.2.2.2.2.1 + · intro h hh + have hv' := hhalf.trans_lt (hresult h hh).2.2.2.2.2.2.2.2 + simpa only [weight, real_shift_weighted_mean] using hv' + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ShiftedMatrixCountError.lean b/lean/OAI/Combinatorics/Progressions/Linear/ShiftedMatrixCountError.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5ed855b039e3bad322772e2b004d0cd499dc8f6 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ShiftedMatrixCountError.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.Progressions.Lattices.ResidueAffineProfileLaw + +namespace OAI + +section + +namespace Erdos3 + +open MeasureTheory +open scoped BigOperators Matrix + +noncomputable def shiftedMatrixCountFactor (I J : Type*) [Fintype I] [Fintype J] : ℝ := + (4 * (Fintype.card J : ℝ) + 1) ^ Fintype.card I + +theorem shiftedMatrixCountFactor_le_exp (I J : Type*) [Fintype I] [Fintype J] : + shiftedMatrixCountFactor I J ≤ + Real.exp ((Fintype.card I : ℝ) * (4 * (Fintype.card J : ℝ) + 1)) := by + unfold shiftedMatrixCountFactor + calc + _ ≤ (Real.exp (4 * (Fintype.card J : ℝ) + 1)) ^ Fintype.card I := by + gcongr + linarith [Real.add_one_le_exp (4 * (Fintype.card J : ℝ) + 1)] + _ = _ := (Real.exp_nat_mul _ _).symm + +variable {I J : Type*} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + +theorem shiftedMatrixGridProxy_integrable (M : Matrix I J ℤ) (s : I ↪ J) + (hM : (M.submatrix id s).det ≠ 0) (a S : J → ℝ) (P : I → ℝ) + (hS : ∀ j, 0 < S j) (hP : ∀ i, 0 < P i) (ha : ∀ j, |a j| ≤ S j) + (hentry : ∀ i j, |normalizedIntegerColumns M S P i j| ≤ 1) : + Integrable (coefficientGridProxy M s hM S P hS hP (shiftedUnitProfile a S)) Measure.count := by + apply coefficientGridProxy_integrable M s hM S P hS hP _ (shiftedUnitProfile_support a S hS ha) + exact mul_le_mul_of_nonneg_right + (normalized_selected_split_norm_le M s S P zero_le_one hentry) (by norm_num : (0 : ℝ) ≤ 2) + +theorem shiftedMatrixImage_count_error (M : Matrix I J ℤ) (s : I ↪ J) + (hM : (M.submatrix id s).det ≠ 0) (a S : J → ℝ) (P : I → ℝ) + (hS : ∀ j, 0 < S j) (hP : ∀ i, 0 < P i) (hP1 : ∀ i, 1 ≤ P i) + (ha : ∀ j, |a j| ≤ S j) (hZ : 0 < shiftedSmoothProductMass a S) + (hentry : ∀ i j, |normalizedIntegerColumns M S P i j| ≤ 1) {ε : ℝ} + (he : ∀ v, |(∏ i, P i) * + (((shiftedSmoothProductPMF a S hS hZ).map (fun z => M *ᵥ z)) v).toReal - + coefficientImageMask M P (selectedCoefficientDensity M s hM S P hS hP (shiftedUnitProfile a S)) v| ≤ ε) : + (∫ v, |(((shiftedSmoothProductPMF a S hS hZ).map (fun z => M *ᵥ z)) v).toReal - + coefficientGridProxy M s hM S P hS hP (shiftedUnitProfile a S) v| ∂Measure.count) ≤ + shiftedMatrixCountFactor I J * ε := by + let f := shiftedUnitProfile a S + have hs := shiftedUnitProfile_support a S hS ha + have hz : 0 < coefficientWeightSum f S := by rw [shiftedUnitProfile_mass]; exact hZ + have hmap : coefficientImagePMF M f (shiftedUnitProfile_nonneg a S) S hS hs hz = + (shiftedSmoothProductPMF a S hS hZ).map (fun z => M *ᵥ z) := by + unfold coefficientImagePMF + rw [coefficientPMF_shiftedUnitProfile a S hS hs hZ] + have hnorm : ‖matrixSupCLM (normalizedIntegerColumns M S P)‖ ≤ (Fintype.card J : ℝ) := by + simpa only [mul_one] using matrixSupCLM_norm_le _ zero_le_one hentry + have hsplit := normalized_selected_split_norm_le M s S P zero_le_one hentry + have hpoint : ∀ v, |(∏ i, P i) * + (coefficientImagePMF M f (shiftedUnitProfile_nonneg a S) S hS hs hz v).toReal - + coefficientImageMask M P (selectedCoefficientDensity M s hM S P hS hP f) v| ≤ ε := by + simpa only [hmap] using he + have h := coefficientImage_count_error M s hM S P hS hP hP1 f + (shiftedUnitProfile_nonneg a S) hs hz (T := (Fintype.card J : ℝ) * 2) + (by positivity) (mul_le_mul_of_nonneg_right hnorm (by norm_num)) + (by simpa only [mul_one] using mul_le_mul_of_nonneg_right hsplit (by norm_num : (0 : ℝ) ≤ 2)) hpoint + rw [hmap] at h + simpa only [shiftedMatrixCountFactor, + show 2 * ((Fintype.card J : ℝ) * 2) + 1 = 4 * (Fintype.card J : ℝ) + 1 by ring] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ShortGeneratingBasisBound.lean b/lean/OAI/Combinatorics/Progressions/Linear/ShortGeneratingBasisBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e9f610b3446ec801e97c86b9671f4a592c9be7f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ShortGeneratingBasisBound.lean @@ -0,0 +1,128 @@ +import OAI.Combinatorics.Progressions.Lattices.ReducedLatticeBasis +import OAI.Combinatorics.Progressions.Linear.MatrixSupInverse + +namespace OAI + +section + +namespace Erdos3.BohrLattice.MinkowskiSecondBox + +open Module Submodule +open scoped BigOperators + +theorem basis_norm_le_of_integral_combination {n : ℕ} + (b : Basis (Fin n) ℝ (Fin n → ℝ)) {C : ℝ} + (hprod : (∏ j, ‖b j‖) ≤ C * |(Matrix.of b).det|) + (c : Fin n → ℤ) (i : Fin n) (hci : c i ≠ 0) : + ‖b i‖ ≤ (n.factorial : ℝ) * C * ‖∑ j, c j • b j‖ := by + classical + let x := ∑ j, c j • b j + let H := Function.update (fun j => ‖b j‖) i ‖x‖ + have hentry : ∀ j k, |((Matrix.of b).updateRow i x) j k| ≤ H j := by + intro j k + by_cases hji : j = i + · subst j + simpa only [Matrix.updateRow_self, H, Function.update_self] using abs_apply_le_norm x k + · simpa only [Matrix.updateRow_ne hji, Matrix.of_apply, H, Function.update_of_ne hji] + using abs_apply_le_norm (b j) k + have hx : x = ∑ j, (c j : ℝ) • b j := by + simp only [x, Int.cast_smul_eq_zsmul] + have hdetx : ((Matrix.of b).updateRow i x).det = (c i : ℝ) * (Matrix.of b).det := by + rw [hx] + exact Matrix.det_updateRow_sum (Matrix.of b) i (fun j => (c j : ℝ)) + have hH : (∏ j, H j) = ‖x‖ * ∏ j ∈ Finset.univ.erase i, ‖b j‖ := by + rw [← Finset.mul_prod_erase Finset.univ H (Finset.mem_univ i)] + rw [show H i = ‖x‖ by simp [H]] + congr 1 + apply Finset.prod_congr rfl + intro j hj + exact Function.update_of_ne (Finset.ne_of_mem_erase hj) _ _ + have hbound := Erdos3.matrix_det_abs_le_row_bounds ((Matrix.of b).updateRow i x) H hentry + rw [hdetx, abs_mul, hH, Fintype.card_fin] at hbound + have hci1 : (1 : ℝ) ≤ |(c i : ℝ)| := by exact_mod_cast Int.one_le_abs hci + have hdet : 0 < |(Matrix.of b).det| := by + apply abs_pos.mpr + have h := (AlternatingMap.map_basis_ne_zero_iff b (Pi.basisFun ℝ (Fin n)).det).mpr + (Pi.basisFun ℝ (Fin n)).det_ne_zero + simpa only [Pi.basisFun_det_apply] using h + have hdetle : |(Matrix.of b).det| ≤ + (n.factorial : ℝ) * (‖x‖ * ∏ j ∈ Finset.univ.erase i, ‖b j‖) := by + exact (le_mul_of_one_le_left hdet.le hci1).trans hbound + have hmul : ‖b i‖ * |(Matrix.of b).det| ≤ + ((n.factorial : ℝ) * C * ‖∑ j, c j • b j‖) * |(Matrix.of b).det| := by + calc + ‖b i‖ * |(Matrix.of b).det| ≤ ‖b i‖ * + ((n.factorial : ℝ) * (‖x‖ * ∏ j ∈ Finset.univ.erase i, ‖b j‖)) := + mul_le_mul_of_nonneg_left hdetle (norm_nonneg _) + _ = (n.factorial : ℝ) * ‖x‖ * (∏ j, ‖b j‖) := by + rw [← Finset.mul_prod_erase Finset.univ (fun j => ‖b j‖) (Finset.mem_univ i)] + ring + _ ≤ (n.factorial : ℝ) * ‖x‖ * (C * |(Matrix.of b).det|) := + mul_le_mul_of_nonneg_left hprod (mul_nonneg (Nat.cast_nonneg _) (norm_nonneg _)) + _ = ((n.factorial : ℝ) * C * ‖∑ j, c j • b j‖) * |(Matrix.of b).det| := by + dsimp only [x] + ring + nlinarith + +theorem basis_norm_le_of_short_spanning_family {n : ℕ} {A : Type*} + (b : Basis (Fin n) ℝ (Fin n → ℝ)) {C R : ℝ} (hC : 0 ≤ C) + (hprod : (∏ j, ‖b j‖) ≤ C * |(Matrix.of b).det|) + (v : A → Fin n → ℝ) (hspan : span ℝ (Set.range v) = ⊤) + (hmem : ∀ a, v a ∈ span ℤ (Set.range b)) (hnorm : ∀ a, ‖v a‖ ≤ R) + (i : Fin n) : ‖b i‖ ≤ (n.factorial : ℝ) * C * R := by + classical + have hex : ∃ a, b.coord i (v a) ≠ 0 := by + by_contra! h + have hs : span ℝ (Set.range v) ≤ LinearMap.ker (b.coord i) := by + apply span_le.mpr + rintro _ ⟨a, rfl⟩ + exact LinearMap.mem_ker.mpr (h a) + rw [hspan] at hs + have hz := LinearMap.mem_ker.mp (hs (show b i ∈ (⊤ : Submodule ℝ (Fin n → ℝ)) from trivial)) + simp only [Basis.coord_apply, Basis.repr_self, Finsupp.single_eq_same, one_ne_zero] at hz + obtain ⟨a, ha⟩ := hex + have hm := hmem a + rw [mem_span_range_iff_exists_fun] at hm + obtain ⟨c, hc⟩ := hm + have hci : c i ≠ 0 := by + intro hz + apply ha + rw [← hc, map_sum] + simp only [map_zsmul, Basis.coord_apply, Basis.repr_self, Finsupp.single_apply] + simp [hz] + have hb := basis_norm_le_of_integral_combination b hprod c i hci + rw [hc] at hb + exact hb.trans (mul_le_mul_of_nonneg_left (hnorm a) (mul_nonneg (Nat.cast_nonneg _) hC)) + +theorem abs_det_eq_of_same_integer_span {n : ℕ} + (b c : Basis (Fin n) ℝ (Fin n → ℝ)) + (hspan : span ℤ (Set.range b) = span ℤ (Set.range c)) : + |(Matrix.of b).det| = |(Matrix.of c).det| := by + have hcov (d : Basis (Fin n) ℝ (Fin n → ℝ)) : + ZLattice.covolume (span ℤ (Set.range d)) = |(Matrix.of d).det| := by + simpa only [Function.comp_def, Basis.restrictScalars_apply] using + ZLattice.covolume_eq_det (span ℤ (Set.range d)) (d.restrictScalars ℤ) + rw [← hcov b, hspan, hcov c] + +theorem exists_short_same_lattice_basis {n : ℕ} {A : Type*} + (b : Basis (Fin n) ℝ (Fin n → ℝ)) (v : A → Fin n → ℝ) {R : ℝ} + (hspan : span ℝ (Set.range v) = ⊤) + (hmem : ∀ a, v a ∈ span ℤ (Set.range b)) (hnorm : ∀ a, ‖v a‖ ≤ R) : + ∃ c : Basis (Fin n) ℝ (Fin n → ℝ), + span ℤ (Set.range c) = span ℤ (Set.range b) ∧ + (∏ i, ‖c i‖) ≤ minkowskiSecondConstant n * |(Matrix.of c).det| ∧ + ∀ i, ‖c i‖ ≤ (n.factorial : ℝ) * minkowskiSecondConstant n * R := by + obtain ⟨c, hc, hp⟩ := exists_same_lattice_basis_norm_product_le b + rw [← abs_det_eq_of_same_integer_span c b hc] at hp + refine ⟨c, hc, hp, ?_⟩ + apply basis_norm_le_of_short_spanning_family c (minkowskiSecondConstant_nonneg n) hp v hspan + · intro a + rw [hc] + exact hmem a + · exact hnorm + +end Erdos3.BohrLattice.MinkowskiSecondBox + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ShortVectorProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/ShortVectorProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..9553638fcb49f5e3e2eb75e9e7d3c90e6fd615f5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ShortVectorProjection.lean @@ -0,0 +1,41 @@ +import OAI.Combinatorics.Progressions.Lattices.DenseIntegerSpan +import OAI.Combinatorics.Progressions.Lattices.LatticeVoronoiPacking + +namespace OAI + +section + +namespace Erdos3 + +theorem shortVectorSpan_map_eq_top_of_spanning_integer_images + {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (Λ : Submodule ℤ E) (π : E →ₗ[ℝ] (ι → ℝ)) (H : Finset (ι → ℤ)) (R : ℝ) + (hspan : Submodule.span ℝ {x : ι → ℝ | ∃ h ∈ H, x = fun i => (h i : ℝ)} = ⊤) + (hlift : ∀ h ∈ H, ∃ v ∈ Λ, ‖v‖ ≤ R ∧ π v = fun i => (h i : ℝ)) : + (shortVectorSpan Λ R).map π = ⊤ := by + apply top_unique + rw [← hspan] + apply Submodule.span_le.mpr + rintro x ⟨h, hh, rfl⟩ + obtain ⟨v, hv, hnorm, hπ⟩ := hlift h hh + exact ⟨v, mem_shortVectorSpan Λ R hv hnorm, hπ⟩ + +theorem shortVectorSpan_map_eq_top_of_dense_integer_images + {E ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [Fintype ι] [DecidableEq ι] + (Λ : Submodule ℤ E) (π : E →ₗ[ℝ] (ι → ℝ)) + (H : Finset (ι → ℤ)) (T : ι → ℝ) (R δ : ℝ) + (hT : ∀ i, 1 ≤ T i) (hR : 1 ≤ R) + (hbound : ∀ h ∈ H, ∀ i, |(h i : ℝ)| ≤ R * T i) + (hdense : δ * ∏ i, T i ≤ (H.card : ℝ)) + (hlarge : ∀ i, (3 * R) ^ (Fintype.card ι - 1) < δ * T i) + (hlift : ∀ h ∈ H, ∃ v ∈ Λ, ‖v‖ ≤ R ∧ π v = fun i => (h i : ℝ)) : + (shortVectorSpan Λ R).map π = ⊤ := by + have hspan := integer_points_span_eq_top_of_density H T R δ hT hR hbound hdense hlarge + exact shortVectorSpan_map_eq_top_of_spanning_integer_images Λ π H R hspan hlift + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SingleRefilteredKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/SingleRefilteredKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..f50eab02f736d5a651be9b217601d04e20d2ec74 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SingleRefilteredKernel.lean @@ -0,0 +1,173 @@ +import OAI.Combinatorics.Progressions.Estimates.RefilteredReconstructionDiagram + +namespace OAI + +section + +universe u + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +variable {ι : Type u} [Fintype ι] [DecidableEq ι] {L : ι → Type u} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) (s + 1) (d i)) (a : ι) + (W : LieSubalgebra ℚ (pi D).filtration.AssociatedGraded) {e n : ℕ} + (E : RationalFilteredNilmanifold ((pi D).filtration.gradedRefiltrationSubalgebra W) (s + 1) e) + +noncomputable def refilteredComponentMap (b : ι) : + ((pi D).filtration.gradedRefiltrationSubalgebra W) →ₗ⁅ℚ⁆ L b := + (liePiEval b).comp ((pi D).filtration.gradedRefiltrationSubalgebra W).incl + +noncomputable def nativeRefilteredTarget + (Q : RationalFilteredNilmanifold + (((pi D).filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n) := + optionProduct (Q.raiseStep (Nat.le_succ s)) (fun i : {i : ι // i ≠ a} => D i.val) + +noncomputable def nativeRefilteredMap := + optionProductMap (lieQuotientMap (E.filtration.layerIdeal (s + 1))) + (fun i : {i : ι // i ≠ a} => refilteredComponentMap D W i.val) + +theorem nativeRefilteredMap_real_kernel + (Q : RationalFilteredNilmanifold + (((pi D).filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n) + (hEF : E.filtration = (pi D).filtration.gradedRefiltration W) + (x : ℝ ⊗[ℚ] ((pi D).filtration.gradedRefiltrationSubalgebra W)) : + realificationLieHom (nativeRefilteredMap D a W E) x = 0 ↔ + realificationLieHom (refilteredReconstructionMap D a W) x = 0 := by + rw [refilteredReconstructionMap_real_kernel] + dsimp only [nativeRefilteredMap] + rw [topQuotientOtherMap_real_kernel E Q (fun i : {i : ι // i ≠ a} => D i.val)] + have htop : x ∈ E.filtration.realification.layer (s + 1) ↔ + realificationLieHom ((pi D).filtration.gradedRefiltrationSubalgebra W).incl x ∈ + (pi D).filtration.realGradedRefiltrationLayer W (s + 1) := by + rw [hEF] + exact (pi D).filtration.mem_native_refiltration_layer W (s + 1) x + have hcomp (i : ι) : realificationLieHom (refilteredComponentMap D W i) x = + realificationLieHom (liePiEval i) + (realificationLieHom ((pi D).filtration.gradedRefiltrationSubalgebra W).incl x) := by + change (((liePiEval i).toLinearMap.comp + ((pi D).filtration.gradedRefiltrationSubalgebra W).incl.toLinearMap).baseChange ℝ) x = _ + rw [LinearMap.baseChange_comp] + rfl + apply and_congr htop + constructor + · intro h i hi + exact (hcomp i) ▸ h ⟨i, hi⟩ + · intro h i + exact (hcomp i.val).symm ▸ h i.val i.property + +theorem native_refiltered_frozen_invariant {J : Type*} + (Q : RationalFilteredNilmanifold + (((pi D).filtration.gradedRefiltrationSubalgebra W) ⧸ E.filtration.layerIdeal (s + 1)) s n) + (hEF : E.filtration = (pi D).filtration.gradedRefiltration W) + (eta : J → ∀ i, L i →ₗ[ℚ] ℚ) (S : (D a).Space → ℂ) + (hinvariant : ∀ z, z ∈ (D a).filtration.realification.subgroup (s + 1) → + (∀ j, realifyFunctional (eta j a) z.coord = 0) → ∀ x, S (z • x) = S x) + (hfrequency : ∀ j x, x ∈ (pi D).filtration.realGradedRefiltrationLayer W (s + 1) → + realifyFunctional (piFrequency (eta j)) x = 0) + (l r : (D a).RealGroup) (z x : E.RealGroup) + (hz : realificationLieHom (nativeRefilteredMap D a W E) z.coord = 0) : + let φ := NilpotentLieBCHGroup.realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := (D a).filtration.lowerCentralSeries_eq_bot) (refilteredComponentMap D W a) + S (QuotientGroup.mk (l * φ (z * x) * r)) = S (QuotientGroup.mk (l * φ x * r)) := by + let φ := NilpotentLieBCHGroup.realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := (D a).filtration.lowerCentralSeries_eq_bot) (refilteredComponentMap D W a) + let z' : (pi D).RealGroup := NilpotentLieBCHGroup.realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := (pi D).filtration.lowerCentralSeries_eq_bot) + ((pi D).filtration.gradedRefiltrationSubalgebra W).incl z + obtain ⟨htop, hother⟩ := (refilteredReconstructionMap_real_kernel D a W z.coord).mp + ((nativeRefilteredMap_real_kernel D a W E Q hEF z.coord).mp hz) + have hproj : φ z = productProjectionHom D a z' := by + apply NilpotentLieBCHGroup.ext + change (((liePiEval a).toLinearMap.comp + ((pi D).filtration.gradedRefiltrationSubalgebra W).incl.toLinearMap).baseChange ℝ) z.coord = _ + rw [LinearMap.baseChange_comp] + rfl + have hzlayer : φ z ∈ (D a).filtration.realification.subgroup (s + 1) := by + rw [hproj] + exact productProjectionHom_mem_layer D a (s + 1) z' + ((pi D).filtration.realGradedRefiltrationLayer_le W (s + 1) htop) + have hinv : ∀ y, S (φ z • y) = S y := by + rw [hproj] + apply refiltered_product_kernel_invariant D a W eta S hinvariant hfrequency z' htop + intro i hi + apply NilpotentLieBCHGroup.ext + exact hother i hi + have hcomm := (D a).filtration.realification.top_commutes (φ z) hzlayer l + change S (QuotientGroup.mk (l * φ (z * x) * r)) = S (QuotientGroup.mk (l * φ x * r)) + rw [map_mul] + have heq : l * (φ z * φ x) * r = φ z * (l * φ x * r) := by + calc + l * (φ z * φ x) * r = (l * φ z) * φ x * r := by simp only [mul_assoc] + _ = (φ z * l) * φ x * r := by rw [hcomm.eq] + _ = φ z * (l * φ x * r) := by simp only [mul_assoc] + rw [heq] + exact hinv (QuotientGroup.mk (l * φ x * r)) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d e : ℕ} + (D : RationalFilteredNilmanifold L (s + 1) d) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (E : RationalFilteredNilmanifold (D.filtration.gradedRefiltrationSubalgebra W) (s + 1) e) + +theorem singleRefilteredQuotient_real_kernel + (hEF : E.filtration = D.filtration.gradedRefiltration W) + (x : ℝ ⊗[ℚ] D.filtration.gradedRefiltrationSubalgebra W) : + realificationLieHom (lieQuotientMap (E.filtration.layerIdeal (s + 1))) x = 0 ↔ + realificationLieHom (D.filtration.gradedRefiltrationSubalgebra W).incl x ∈ + D.filtration.realGradedRefiltrationLayer W (s + 1) := by + change (E.filtration.layerIdeal (s + 1)).toSubmodule.mkQ.baseChange ℝ x = 0 ↔ _ + rw [realification_mkQ_eq_zero_iff] + change x ∈ E.filtration.realification.layer (s + 1) ↔ _ + rw [hEF] + exact D.filtration.mem_native_refiltration_layer W (s + 1) x + +theorem single_refiltered_frozen_invariant + (hEF : E.filtration = D.filtration.gradedRefiltration W) + (S : D.Space → ℂ) + (hinvariant : ∀ z : D.RealGroup, + z.coord ∈ D.filtration.realGradedRefiltrationLayer W (s + 1) → + ∀ x, S (z • x) = S x) + (l r : D.RealGroup) (z x : E.RealGroup) + (hz : realificationLieHom (lieQuotientMap (E.filtration.layerIdeal (s + 1))) z.coord = 0) : + let φ := NilpotentLieBCHGroup.realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (D.filtration.gradedRefiltrationSubalgebra W).incl + S (QuotientGroup.mk (l * φ (z * x) * r)) = S (QuotientGroup.mk (l * φ x * r)) := by + let φ := NilpotentLieBCHGroup.realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (D.filtration.gradedRefiltrationSubalgebra W).incl + have htop : (φ z).coord ∈ D.filtration.realGradedRefiltrationLayer W (s + 1) := + (singleRefilteredQuotient_real_kernel D W E hEF z.coord).mp hz + have hzlayer : φ z ∈ D.filtration.realification.subgroup (s + 1) := + D.filtration.realGradedRefiltrationLayer_le W (s + 1) htop + have hcomm := D.filtration.realification.top_commutes (φ z) hzlayer l + change S (QuotientGroup.mk (l * φ (z * x) * r)) = S (QuotientGroup.mk (l * φ x * r)) + rw [map_mul] + have heq : l * (φ z * φ x) * r = φ z * (l * φ x * r) := by + calc + l * (φ z * φ x) * r = (l * φ z) * φ x * r := by simp only [mul_assoc] + _ = (φ z * l) * φ x * r := by rw [hcomm.eq] + _ = φ z * (l * φ x * r) := by simp only [mul_assoc] + rw [heq] + exact hinvariant (φ z) htop (QuotientGroup.mk (l * φ x * r)) + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SmallKernelAllSites.lean b/lean/OAI/Combinatorics/Progressions/Linear/SmallKernelAllSites.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3e4af2580497d4069b4a1e2ef36cec8357c6c77 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SmallKernelAllSites.lean @@ -0,0 +1,1382 @@ +import Mathlib.Analysis.SpecialFunctions.Exp +import OAI.Combinatorics.Progressions.Estimates.AnchoredFixedCenterDomination +import OAI.Combinatorics.Progressions.Estimates.CenteredFullParameterGeometry +import OAI.Combinatorics.Progressions.Estimates.ScaledFloorPerturbation +import OAI.Combinatorics.Progressions.Sampling.SmallKernelSamplerThreshold + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +theorem matrixSupCLM_smul {ι κ : Type*} [Fintype ι] [Fintype κ] + (a : ℝ) (A : Matrix ι κ ℝ) : + matrixSupCLM (a • A) = a • matrixSupCLM A := by + ext x i + simp only [smul_apply, matrixSupCLM_apply, Matrix.smul_mulVec, + Pi.smul_apply] + +theorem scalar_identity_inverse_bound {E : Type*} [NormedAddCommGroup E] + [NormedSpace ℝ E] {a : ℝ} (ha : 0 < a) : + (a • ContinuousLinearMap.id ℝ E).IsInvertible ∧ + ‖(a • ContinuousLinearMap.id ℝ E).inverse‖ ≤ 1 / a := by + let A := a • ContinuousLinearMap.id ℝ E + let B := a⁻¹ • ContinuousLinearMap.id ℝ E + have hAB : A.comp B = ContinuousLinearMap.id ℝ E := by + ext x + simp [A, B, smul_smul, ne_of_gt ha] + have hBA : B.comp A = ContinuousLinearMap.id ℝ E := by + ext x + simp [A, B, smul_smul, ne_of_gt ha] + refine ⟨ContinuousLinearMap.IsInvertible.of_inverse hAB hBA, ?_⟩ + change ‖A.inverse‖ ≤ 1 / a + rw [ContinuousLinearMap.inverse_eq hAB hBA] + calc + ‖B‖ = |a⁻¹| * ‖ContinuousLinearMap.id ℝ E‖ := by + simp only [B, norm_smul, Real.norm_eq_abs] + _ ≤ a⁻¹ * 1 := by + rw [abs_of_pos (inv_pos.mpr ha)] + exact mul_le_mul_of_nonneg_left ContinuousLinearMap.norm_id_le (inv_nonneg.mpr ha.le) + _ = 1 / a := by simp only [mul_one, one_div] + +theorem matrix_inverse_near_scalar_identity {ι : Type*} [Fintype ι] [DecidableEq ι] + (M : Matrix ι ι ℝ) {a ε : ℝ} (ha : 0 < a) (hε : 0 ≤ ε) + (hentry : ∀ i j, |M i j - (a • (1 : Matrix ι ι ℝ)) i j| ≤ ε) + (hsmall : (Fintype.card ι : ℝ) * ε ≤ a / 2) : + (matrixSupCLM M).IsInvertible ∧ ‖(matrixSupCLM M).inverse‖ ≤ 2 / a := by + have hA := scalar_identity_inverse_bound (E := ι → ℝ) ha + have hdiff : ‖matrixSupCLM M - a • ContinuousLinearMap.id ℝ (ι → ℝ)‖ ≤ + (Fintype.card ι : ℝ) * ε := by + rw [← matrixSupCLM_one, ← matrixSupCLM_smul, ← matrixSupCLM_sub] + exact matrixSupCLM_norm_le _ hε hentry + have hbound : (1 / a) * ‖matrixSupCLM M - a • ContinuousLinearMap.id ℝ (ι → ℝ)‖ ≤ + (1 / 2 : ℝ) := by + have h := (mul_le_mul_of_nonneg_left hdiff (by positivity : 0 ≤ 1 / a)).trans + (mul_le_mul_of_nonneg_left hsmall (by positivity : 0 ≤ 1 / a)) + calc + _ ≤ (1 / a) * (a / 2) := h + _ = 1 / 2 := by field_simp + have h := inverse_perturbation_bound _ (matrixSupCLM M) hA.1 + (⟨1 / a, by positivity⟩ : ℝ≥0) hA.2 hbound + refine ⟨h.1, ?_⟩ + calc + _ ≤ 2 * (1 / a) := h.2 + _ = 2 / a := by ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel + +def kernelColumnCenter {G X F : Type*} [DecidableEq X] (a : ℝ) : + (G × X) ⊕ F → X → ℝ + | .inl (_, j), i => if i = j then a else 0 + | .inr _, _ => 0 + +noncomputable def kernelSpatialAnchor {G X F : Type*} [DecidableEq X] + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (a : ℝ) : + Option ((G × X) ⊕ F) × X → ℤ + | (none, i) => integerBoxCenter N i + | (some k, i) => ⌊((N i : ℝ) / T k) * kernelColumnCenter a k i⌋ + +noncomputable def kernelSpatialWidths {G X F : Type*} + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (η σ : ℝ) : + Option ((G × X) ⊕ F) × X → ℝ + | (none, i) => (N i : ℝ) / 8 + | (some (.inl (g, j)), i) => η * ((N i : ℝ) / T (.inl (g, j))) + | (some (.inr f), i) => σ * η * ((N i : ℝ) / T (.inr f)) + +theorem kernelSpatialWidths_pos {G X F : Type*} + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) + (hT : ∀ k, 0 < T k) {η σ : ℝ} (hη : 0 < η) (hσ : 0 < σ) + (z : Option ((G × X) ⊕ F) × X) : 0 < kernelSpatialWidths N T η σ z := by + rcases z with ⟨k, i⟩ + have hn : (0 : ℝ) < N i := by exact_mod_cast hN i + cases k with + | none => exact div_pos hn (by norm_num) + | some k => + rcases k with ⟨g,j⟩ | f + · exact mul_pos hη (div_pos hn (hT _)) + · exact mul_pos (mul_pos hσ hη) (div_pos hn (hT _)) + +noncomputable def normalizedKernelBlock {G X F : Type*} + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) + (z : Option ((G × X) ⊕ F) × X → ℤ) (g : G) : Matrix X X ℝ := + fun i j => (z (some (.inl (g,j)),i) : ℝ) / ((N i : ℝ) / T (.inl (g,j))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] [DecidableEq X] + +theorem kernelSpatial_kernel_error + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + (a η σ : ℝ) (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ η) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (kernelSpatialWidths N T η σ) 1) + (g : G) (i j : X) : + |normalizedKernelBlock N T (kernelSpatialAnchor N T a + u) g i j - + (if i = j then a else 0)| ≤ 2 * η := by + have hn : (0 : ℝ) < N i := by exact_mod_cast hN i + have hs : 0 < (N i : ℝ) / T (.inl (g,j)) := div_pos hn (hT _) + have hb := rectangularWeightIndices_zero_bound (kernelSpatialWidths N T η σ) hu + (some (.inl (g,j)), i) + have h := scaled_floor_perturbation_le_twice (a := if i = j then a else 0) + hs (hscale g j i) (u (some (.inl (g,j)), i)) hb + exact h + +theorem kernelSpatial_nonkernel_bound + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + (a η σ : ℝ) {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (kernelSpatialWidths N T η σ) 1) + (f : F) (i : X) : + |((kernelSpatialAnchor N T a + u) (some (.inr f), i) : ℝ) / + ((N i : ℝ) / T (.inr f))| ≤ σ * η := by + have hn : (0 : ℝ) < N i := by exact_mod_cast hN i + have hs : 0 < (N i : ℝ) / T (.inr f) := div_pos hn (hT _) + have hb := rectangularWeightIndices_zero_bound (kernelSpatialWidths N T η σ) hu + (some (.inr f), i) + simp only [kernelSpatialWidths] at hb + simpa only [Pi.add_apply, kernelSpatialAnchor, kernelColumnCenter, mul_zero, + Int.floor_zero, zero_add, abs_div, abs_of_pos hs] using (div_le_iff₀ hs).mpr hb + +theorem kernelSpatial_column_bound + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {a η σ : ℝ} (ha : 0 ≤ a) (hη : 0 ≤ η) (hσ : σ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ η) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (kernelSpatialWidths N T η σ) 1) + (k : (G × X) ⊕ F) (i : X) : + |((kernelSpatialAnchor N T a + u) (some k, i) : ℝ) / + ((N i : ℝ) / T k)| ≤ a + 2 * η := by + cases k with + | inl k => + rcases k with ⟨g,j⟩ + have h := kernelSpatial_kernel_error N hN T hT a η σ hscale hu g i j + have hc : |(if i = j then a else 0 : ℝ)| ≤ a := by + split_ifs <;> simp_all only [abs_zero, abs_of_nonneg ha, le_refl] + have ht := abs_add_le + (normalizedKernelBlock N T (kernelSpatialAnchor N T a + u) g i j - + (if i = j then a else 0)) (if i = j then a else 0) + rw [sub_add_cancel] at ht + exact ht.trans (by linarith) + | inr f => + have h := kernelSpatial_nonkernel_bound N hN T hT a η σ hu f i + exact h.trans (by nlinarith) + +theorem scaled_coordinate_product_bound {H T c v t : ℝ} + (hH : 0 < H) (hT : 0 < T) (hv : |v / (H / T)| ≤ c) (ht : |t| ≤ T) : + |t * v| ≤ c * H := by + have hs : 0 < H / T := div_pos hH hT + have hv' : |v| ≤ c * (H / T) := + (div_le_iff₀ hs).mp (by simpa only [abs_div, abs_of_pos hs] using hv) + calc + |t * v| = |t| * |v| := abs_mul _ _ + _ ≤ T * (c * (H / T)) := mul_le_mul ht hv' (abs_nonneg _) hT.le + _ = c * H := by field_simp + +theorem kernelSpatial_nonkernel_displacement + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + (a η σ : ℝ) {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (kernelSpatialWidths N T η σ) 1) + (root : (G × X) ⊕ F → ℤ) (hroot : ∀ k, |(root k : ℝ)| ≤ T k) (i : X) : + |∑ f : F, (root (.inr f) : ℝ) * + ((kernelSpatialAnchor N T a + u) (some (.inr f), i) : ℝ)| ≤ + (Fintype.card F : ℝ) * (σ * η) * (N i : ℝ) := by + have hn : (0 : ℝ) < N i := by exact_mod_cast hN i + calc + _ ≤ ∑ f : F, |(root (.inr f) : ℝ) * + ((kernelSpatialAnchor N T a + u) (some (.inr f), i) : ℝ)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _f : F, (σ * η) * (N i : ℝ) := by + apply Finset.sum_le_sum + intro f _ + exact scaled_coordinate_product_bound hn (hT _) + (kernelSpatial_nonkernel_bound N hN T hT a η σ hu f i) (hroot _) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] [DecidableEq X] + +theorem kernelSpatial_kernel_inverse + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {a η σ : ℝ} (ha : 0 < a) (hη : 0 ≤ η) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ η) + (hsmall : (Fintype.card X : ℝ) * (2 * η) ≤ a / 2) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (kernelSpatialWidths N T η σ) 1) (g : G) : + (matrixSupCLM (normalizedKernelBlock N T (kernelSpatialAnchor N T a + u) g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N T (kernelSpatialAnchor N T a + u) g)).inverse‖ ≤ + 2 / a := by + apply matrix_inverse_near_scalar_identity _ ha (by positivity) _ hsmall + intro i j + simpa only [Matrix.smul_apply, smul_eq_mul, Matrix.one_apply, mul_ite, mul_one, mul_zero] using + kernelSpatial_kernel_error N hN T hT a η σ hscale hu g i j + +theorem kernelSpatial_site_deviation + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {a η σ : ℝ} (ha : 0 ≤ a) (hη : 0 ≤ η) (hσ : σ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ η) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (kernelSpatialWidths N T η σ) 1) + (root : (G × X) ⊕ F → ℤ) (hroot : ∀ k, |(root k : ℝ)| ≤ T k) (i : X) : + |(integerPhysicalSite root (kernelSpatialAnchor N T a + u) i : ℝ) - + (integerBoxCenter N i : ℝ)| ≤ + (N i : ℝ) / 8 + (Fintype.card ((G × X) ⊕ F) : ℝ) * (a + 2 * η) * (N i : ℝ) := by + have hn : (0 : ℝ) < N i := by exact_mod_cast hN i + have hbase := rectangularWeightIndices_zero_bound (kernelSpatialWidths N T η σ) hu (none, i) + change |(u (none, i) : ℝ)| ≤ (N i : ℝ) / 8 at hbase + have hcol (k) : |(root k : ℝ) * ((kernelSpatialAnchor N T a + u) (some k, i) : ℝ)| ≤ + (a + 2 * η) * (N i : ℝ) := + scaled_coordinate_product_bound hn (hT k) + (kernelSpatial_column_bound N hN T hT ha hη hσ hscale hu k i) (hroot k) + have heq : (integerPhysicalSite root (kernelSpatialAnchor N T a + u) i : ℝ) - + (integerBoxCenter N i : ℝ) = (u (none, i) : ℝ) + + ∑ k, (root k : ℝ) * ((kernelSpatialAnchor N T a + u) (some k, i) : ℝ) := by + simp only [integerPhysicalSite, Int.cast_add, Int.cast_sum, Int.cast_mul, + Pi.add_apply, kernelSpatialAnchor] + ring + rw [heq] + calc + _ ≤ |(u (none, i) : ℝ)| + + |∑ k, (root k : ℝ) * ((kernelSpatialAnchor N T a + u) (some k, i) : ℝ)| := abs_add_le _ _ + _ ≤ (N i : ℝ) / 8 + + ∑ k, |(root k : ℝ) * ((kernelSpatialAnchor N T a + u) (some k, i) : ℝ)| := + add_le_add hbase (Finset.abs_sum_le_sum_abs _ _) + _ ≤ (N i : ℝ) / 8 + ∑ _k : (G × X) ⊕ F, (a + 2 * η) * (N i : ℝ) := + add_le_add le_rfl (Finset.sum_le_sum (fun k _ => hcol k)) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + +theorem kernelSpatial_site_mem_box + (N : X → ℕ) (hN : ∀ i, 4 ≤ N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {a η σ : ℝ} (ha : 0 ≤ a) (hη : 0 ≤ η) (hσ : σ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ η) + (hfit : (Fintype.card ((G × X) ⊕ F) : ℝ) * (a + 2 * η) ≤ 1 / 8) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (kernelSpatialWidths N T η σ) 1) + (root : (G × X) ⊕ F → ℤ) (hroot : ∀ k, |(root k : ℝ)| ≤ T k) : + integerPhysicalSite root (kernelSpatialAnchor N T a + u) ∈ integerBox N := by + apply (mem_integerBox N _).mpr + intro i + have h := kernelSpatial_site_deviation N (fun i => by have := hN i; omega) + T hT ha hη hσ hscale hu root hroot i + have hfit' := mul_le_mul_of_nonneg_right hfit (Nat.cast_nonneg (α := ℝ) (N i)) + have hr : 4 * |((integerPhysicalSite root (kernelSpatialAnchor N T a + u) i - + integerBoxCenter N i : ℤ) : ℝ)| ≤ (N i : ℝ) := by + rw [Int.cast_sub] + linarith + have hz : 4 * |integerPhysicalSite root (kernelSpatialAnchor N T a + u) i - + integerBoxCenter N i| ≤ (N i : ℤ) := by exact_mod_cast hr + have hmem := integer_center_quarter_mem (N i) (hN i) _ hz + change 0 ≤ integerBoxCenter N i + + (integerPhysicalSite root (kernelSpatialAnchor N T a + u) i - integerBoxCenter N i) ∧ + integerBoxCenter N i + + (integerPhysicalSite root (kernelSpatialAnchor N T a + u) i - integerBoxCenter N i) < N i at hmem + have heq : integerBoxCenter N i + + (integerPhysicalSite root (kernelSpatialAnchor N T a + u) i - integerBoxCenter N i) = + integerPhysicalSite root (kernelSpatialAnchor N T a + u) i := by abel + simpa only [heq] using hmem + +theorem translatedKernelSpatial_support + (N : X → ℕ) (hN : ∀ i, 4 ≤ N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {a η σ : ℝ} (ha : 0 < a) (hη : 0 < η) (hσ0 : 0 < σ) (hσ1 : σ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ η) + (hsmall : (Fintype.card X : ℝ) * (2 * η) ≤ a / 2) + (hfit : (Fintype.card ((G × X) ⊕ F) : ℝ) * (a + 2 * η) ≤ 1 / 8) + (modulus : X → ℕ) + (S : Finset (ColumnResiduePattern (Option ((G × X) ⊕ F)) X modulus)) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus S (kernelSpatialWidths N T η σ) z) + (D : (Option ((G × X) ⊕ F) × X → ℤ) → ℝ) (hD0 : ∀ z, 0 ≤ D z) + (hD : 0 < selectedResidueDensityMass modulus S (kernelSpatialWidths N T η σ) + (fun u => D (kernelSpatialAnchor N T a + u))) + (z : Option ((G × X) ⊕ F) × X → ℤ) + (hz : 0 < (translatedSelectedResidueDensityPMF (kernelSpatialAnchor N T a) modulus S + (kernelSpatialWidths N T η σ) + (kernelSpatialWidths_pos N (fun i => by have := hN i; omega) T hT hη hσ0) + hZ D hD0 hD z).toReal) : + (∀ g, (matrixSupCLM (normalizedKernelBlock N T z g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N T z g)).inverse‖ ≤ 2 / a) ∧ + (∀ root : (G × X) ⊕ F → ℤ, (∀ k, |(root k : ℝ)| ≤ T k) → + integerPhysicalSite root z ∈ integerBox N) ∧ + (∀ root : (G × X) ⊕ F → ℤ, (∀ k, |(root k : ℝ)| ≤ T k) → ∀ i, + |∑ f : F, (root (.inr f) : ℝ) * (z (some (.inr f), i) : ℝ)| ≤ + (Fintype.card F : ℝ) * (σ * η) * (N i : ℝ)) := by + have hpositive (i) : 0 < N i := by have := hN i; omega + have hs := (translatedSelectedResidueDensityPMF_support (kernelSpatialAnchor N T a) + modulus S (kernelSpatialWidths N T η σ) + (kernelSpatialWidths_pos N hpositive T hT hη hσ0) hZ D hD0 hD z hz).1 + have heq : kernelSpatialAnchor N T a + (z - kernelSpatialAnchor N T a) = z := by abel + refine ⟨?_, ?_, ?_⟩ + · intro g + simpa only [heq] using kernelSpatial_kernel_inverse N hpositive T hT ha hη.le hscale hsmall hs g + · intro root hroot + simpa only [heq] using kernelSpatial_site_mem_box N hN T hT ha.le hη.le hσ1 hscale hfit hs root hroot + · intro root hroot i + simpa only [heq] using kernelSpatial_nonkernel_displacement N hpositive T hT a η σ hs root hroot i + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def kernelAnchorScale (G X F : Type*) [Fintype G] [Fintype X] [Fintype F] : ℝ := + 1 / (16 * ((Fintype.card ((G × X) ⊕ F) : ℝ) + 1)) + +noncomputable def kernelNoiseScale (G X F : Type*) [Fintype G] [Fintype X] [Fintype F] : ℝ := + kernelAnchorScale G X F / (4 * ((Fintype.card X : ℝ) + 1)) + +theorem kernelSpatial_scales (G X F : Type*) [Fintype G] [Fintype X] [Fintype F] : + let a := kernelAnchorScale G X F + let η := kernelNoiseScale G X F + 0 < a ∧ 0 < η ∧ η ≤ 1 / 8 ∧ + (Fintype.card X : ℝ) * (2 * η) ≤ a / 2 ∧ + (Fintype.card ((G × X) ⊕ F) : ℝ) * (a + 2 * η) ≤ 1 / 8 := by + let M : ℝ := Fintype.card ((G × X) ⊕ F) + let n : ℝ := Fintype.card X + let a := kernelAnchorScale G X F + let η := kernelNoiseScale G X F + have hM : 0 ≤ M := Nat.cast_nonneg _ + have hn : 0 ≤ n := Nat.cast_nonneg _ + have ha : 0 < a := by dsimp [a, kernelAnchorScale]; positivity + have hη : 0 < η := by dsimp [η, kernelNoiseScale]; positivity + have hma : (M + 1) * a = 1 / 16 := by + dsimp [M, a, kernelAnchorScale] + field_simp + have hnη : 4 * (n + 1) * η = a := by + dsimp [n, η, kernelNoiseScale, a] + field_simp + have hηa : 2 * η ≤ a := by nlinarith [mul_nonneg hn hη.le] + have hna : n * (2 * η) ≤ a / 2 := by nlinarith + have hMa : M * a ≤ 1 / 16 := by nlinarith + have ha1 : a ≤ 1 / 16 := by nlinarith [mul_nonneg hM ha.le] + have hfit : M * (a + 2 * η) ≤ 1 / 8 := by + calc + _ ≤ M * (2 * a) := mul_le_mul_of_nonneg_left (by linarith) hM + _ ≤ 1 / 8 := by nlinarith + exact ⟨ha, hη, by linarith, hna, hfit⟩ + +theorem kernelSpatialWidths_lower_bound {G X F : Type*} + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {L η σ : ℝ} (hL : 1 ≤ L) (hTL : ∀ k, T k ≤ L) + (hη : 0 ≤ η) (hη1 : η ≤ 1 / 8) (hσ : 0 ≤ σ) (hσ1 : σ ≤ 1) + (z : Option ((G × X) ⊕ F) × X) : + (σ * η / L) * (N z.2 : ℝ) ≤ kernelSpatialWidths N T η σ z := by + have hL0 : 0 < L := by linarith + have hρ : σ * η / L ≤ η := by + apply (div_le_iff₀ hL0).mpr + nlinarith + rcases z with ⟨k, i⟩ + have hN : 0 ≤ (N i : ℝ) := Nat.cast_nonneg _ + cases k with + | none => + change (σ * η / L) * (N i : ℝ) ≤ (N i : ℝ) / 8 + calc + _ ≤ η * (N i : ℝ) := mul_le_mul_of_nonneg_right hρ hN + _ ≤ (1 / 8) * (N i : ℝ) := mul_le_mul_of_nonneg_right hη1 hN + _ = _ := by ring + | some k => + cases k with + | inl k => + have hleft : σ * η / L ≤ η / T (.inl k) := by + calc + _ ≤ η / L := div_le_div_of_nonneg_right (by nlinarith) hL0.le + _ ≤ _ := div_le_div_of_nonneg_left hη (hT _) (hTL _) + change (σ * η / L) * (N i : ℝ) ≤ η * ((N i : ℝ) / T (.inl k)) + calc + _ ≤ (η / T (.inl k)) * (N i : ℝ) := mul_le_mul_of_nonneg_right hleft hN + _ = _ := by ring + | inr f => + have hleft : σ * η / L ≤ (σ * η) / T (.inr f) := + div_le_div_of_nonneg_left (mul_nonneg hσ hη) (hT _) (hTL _) + change (σ * η / L) * (N i : ℝ) ≤ (σ * η) * ((N i : ℝ) / T (.inr f)) + calc + _ ≤ ((σ * η) / T (.inr f)) * (N i : ℝ) := mul_le_mul_of_nonneg_right hleft hN + _ = _ := by ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] + +theorem kernelNoiseScale_reciprocal : + 1 / kernelNoiseScale G X F = + 64 * ((Fintype.card ((G × X) ⊕ F) : ℝ) + 1) * ((Fintype.card X : ℝ) + 1) := by + unfold kernelNoiseScale kernelAnchorScale + field_simp + ring + +theorem kernelNoiseScale_reciprocal_le {P : ℝ} + (hK : (Fintype.card ((G × X) ⊕ F) : ℝ) ≤ P) (hX : (Fintype.card X : ℝ) ≤ P) : + 1 / kernelNoiseScale G X F ≤ Real.exp (2 * P + 64) := by + have h1 : (Fintype.card ((G × X) ⊕ F) : ℝ) + 1 ≤ Real.exp P := + (add_le_add hK (le_refl 1)).trans (Real.add_one_le_exp P) + have h2 : (Fintype.card X : ℝ) + 1 ≤ Real.exp P := + (add_le_add hX (le_refl 1)).trans (Real.add_one_le_exp P) + have h64 : (64 : ℝ) ≤ Real.exp 64 := by linarith [Real.add_one_le_exp 64] + rw [kernelNoiseScale_reciprocal] + calc + _ ≤ Real.exp 64 * Real.exp P * Real.exp P := + mul_le_mul (mul_le_mul h64 h1 (by positivity) (Real.exp_nonneg _)) h2 + (by positivity) (by positivity) + _ = Real.exp (2 * P + 64) := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + +theorem kernelSpatial_relative_width_budget {P Q σ L : ℝ} + (hK : (Fintype.card ((G × X) ⊕ F) : ℝ) ≤ P) (hX : (Fintype.card X : ℝ) ≤ P) + (hσ : 0 < σ) (hσP : 1 / σ ≤ Real.exp P) (hL : 0 < L) (hLQ : L ≤ Real.exp Q) : + 0 < σ * kernelNoiseScale G X F / L ∧ + 1 / (σ * kernelNoiseScale G X F / L) ≤ Real.exp (Q + 3 * P + 64) := by + have hη : 0 < kernelNoiseScale G X F := (kernelSpatial_scales G X F).2.1 + refine ⟨by positivity, ?_⟩ + have heq : 1 / (σ * kernelNoiseScale G X F / L) = + L * (1 / σ) * (1 / kernelNoiseScale G X F) := by field_simp + rw [heq] + calc + _ ≤ Real.exp Q * Real.exp P * Real.exp (2 * P + 64) := + mul_le_mul (mul_le_mul hLQ hσP (by positivity) (Real.exp_nonneg _)) + (kernelNoiseScale_reciprocal_le hK hX) (by positivity) (by positivity) + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + +theorem kernelSpatial_rounding_scale [DecidableEq X] {P Q L : ℝ} + (hK : (Fintype.card ((G × X) ⊕ F) : ℝ) ≤ P) (hX : (Fintype.card X : ℝ) ≤ P) + (_hL : 0 < L) (hLQ : L ≤ Real.exp Q) + (N : X → ℕ) (hN : ∀ i, Real.exp (Q + 2 * P + 64) ≤ (N i : ℝ)) + (T : (G × X) ⊕ F → ℝ) (_hT : ∀ k, 0 < T k) (hTL : ∀ k, T k ≤ L) + (g : G) (j i : X) : + 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ kernelNoiseScale G X F := by + have hη : 0 < kernelNoiseScale G X F := (kernelSpatial_scales G X F).2.1 + have hn : (0 : ℝ) < N i := (Real.exp_pos _).trans_le (hN i) + have hlarge : L * (1 / kernelNoiseScale G X F) ≤ (N i : ℝ) := by + calc + _ ≤ Real.exp Q * Real.exp (2 * P + 64) := + mul_le_mul hLQ (kernelNoiseScale_reciprocal_le hK hX) (by positivity) (Real.exp_nonneg _) + _ = Real.exp (Q + 2 * P + 64) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := hN i + have hmul : L ≤ (N i : ℝ) * kernelNoiseScale G X F := by + apply (div_le_iff₀ hη).mp + simpa only [div_eq_mul_inv, one_div, one_mul] using hlarge + have heq : 1 / ((N i : ℝ) / T (.inl (g,j))) = T (.inl (g,j)) / (N i : ℝ) := by field_simp + rw [heq] + apply (div_le_iff₀ hn).mpr + simpa only [mul_comm] using (hTL (.inl (g,j))).trans hmul + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] + +theorem two_div_kernelAnchorScale : + 2 / kernelAnchorScale G X F = 32 * ((Fintype.card ((G × X) ⊕ F) : ℝ) + 1) := by + unfold kernelAnchorScale + field_simp + ring + +theorem kernelNoiseScale_nonkernel_cap : + (Fintype.card F : ℝ) * kernelNoiseScale G X F ≤ 1 / 16 := by + have hs := kernelSpatial_scales G X F + have hFM : (Fintype.card F : ℝ) ≤ (Fintype.card ((G × X) ⊕ F) : ℝ) := by + exact_mod_cast (show Fintype.card F ≤ Fintype.card ((G × X) ⊕ F) by + simp only [Fintype.card_sum]; omega) + have hmul := mul_le_mul_of_nonneg_right hFM hs.2.1.le + have hnonneg := mul_nonneg (Nat.cast_nonneg (α := ℝ) (Fintype.card ((G × X) ⊕ F))) hs.1.le + have hfit := hs.2.2.2.2 + nlinarith + +omit [Fintype G] [Fintype X] [Fintype F] in +theorem kernelSpatial_early_widths_independent + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (η σ τ : ℝ) : + (∀ i, kernelSpatialWidths N T η σ (none, i) = kernelSpatialWidths N T η τ (none, i)) ∧ + (∀ g j i, kernelSpatialWidths N T η σ (some (.inl (g,j)), i) = + kernelSpatialWidths N T η τ (some (.inl (g,j)), i)) := ⟨fun _ => rfl, fun _ _ _ => rfl⟩ + +theorem canonicalKernelSpatial_support [DecidableEq X] + (N : X → ℕ) (hN : ∀ i, 4 ≤ N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {σ : ℝ} (hσ0 : 0 < σ) (hσ1 : σ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ kernelNoiseScale G X F) + (modulus : X → ℕ) + (S : Finset (ColumnResiduePattern (Option ((G × X) ⊕ F)) X modulus)) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight modulus S + (kernelSpatialWidths N T (kernelNoiseScale G X F) σ) z) + (D : (Option ((G × X) ⊕ F) × X → ℤ) → ℝ) (hD0 : ∀ z, 0 ≤ D z) + (hD : 0 < selectedResidueDensityMass modulus S + (kernelSpatialWidths N T (kernelNoiseScale G X F) σ) + (fun u => D (kernelSpatialAnchor N T (kernelAnchorScale G X F) + u))) + (z : Option ((G × X) ⊕ F) × X → ℤ) + (hz : 0 < (translatedSelectedResidueDensityPMF + (kernelSpatialAnchor N T (kernelAnchorScale G X F)) modulus S + (kernelSpatialWidths N T (kernelNoiseScale G X F) σ) + (kernelSpatialWidths_pos N (fun i => by have := hN i; omega) T hT + (kernelSpatial_scales G X F).2.1 hσ0) hZ D hD0 hD z).toReal) : + (∀ g, (matrixSupCLM (normalizedKernelBlock N T z g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N T z g)).inverse‖ ≤ + 32 * ((Fintype.card ((G × X) ⊕ F) : ℝ) + 1)) ∧ + (∀ root : (G × X) ⊕ F → ℤ, (∀ k, |(root k : ℝ)| ≤ T k) → + integerPhysicalSite root z ∈ integerBox N) ∧ + (∀ root : (G × X) ⊕ F → ℤ, (∀ k, |(root k : ℝ)| ≤ T k) → ∀ i, + |∑ f : F, (root (.inr f) : ℝ) * (z (some (.inr f), i) : ℝ)| ≤ σ * (N i : ℝ) / 16) := by + have hs := kernelSpatial_scales G X F + have h := translatedKernelSpatial_support N hN T hT hs.1 hs.2.1 hσ0 hσ1 hscale + hs.2.2.2.1 hs.2.2.2.2 modulus S hZ D hD0 hD z hz + refine ⟨?_, h.2.1, ?_⟩ + · intro g + simpa only [two_div_kernelAnchorScale] using h.1 g + · intro root hroot i + calc + _ ≤ (Fintype.card F : ℝ) * (σ * kernelNoiseScale G X F) * (N i : ℝ) := h.2.2 root hroot i + _ = ((Fintype.card F : ℝ) * kernelNoiseScale G X F) * (σ * (N i : ℝ)) := by ring + _ ≤ (1 / 16) * (σ * (N i : ℝ)) := + mul_le_mul_of_nonneg_right kernelNoiseScale_nonkernel_cap (by positivity) + _ = _ := by ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] + +noncomputable def smallKernelSpatialAnchor [DecidableEq X] + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (θ : ℝ) : Option ((G × X) ⊕ F) × X → ℤ := + baseArrayJoin (fun k => kernelSpatialAnchor N T (θ * kernelAnchorScale G X F) (some k.1,k.2)) 0 + +noncomputable def smallKernelSpatialWidths + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (θ τ : ℝ) : Option ((G × X) ⊕ F) × X → ℝ := + fun z => θ * kernelSpatialWidths N T (kernelNoiseScale G X F) τ z + +theorem smallKernelSpatialWidths_pos + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 < θ) (hτ : 0 < τ) (z) : + 0 < smallKernelSpatialWidths N T θ τ z := + mul_pos hθ (kernelSpatialWidths_pos N hN T hT (kernelSpatial_scales G X F).2.1 hτ z) + +theorem smallKernelSpatialWidths_le + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) {θ τ : ℝ} (hθ : θ ≤ 1) (z) : + smallKernelSpatialWidths N T θ τ z ≤ + kernelSpatialWidths N T (θ * kernelNoiseScale G X F) τ z := by + rcases z with ⟨k,i⟩ + cases k with + | none => + change θ * ((N i : ℝ) / 8) ≤ (N i : ℝ) / 8 + exact mul_le_of_le_one_left (by positivity) hθ + | some k => + rcases k with ⟨g,j⟩ | f + · change θ * (kernelNoiseScale G X F * ((N i : ℝ) / T (.inl (g,j)))) ≤ _ + exact le_of_eq (by dsimp only [kernelSpatialWidths]; ring) + · change θ * (τ * kernelNoiseScale G X F * ((N i : ℝ) / T (.inr f))) ≤ _ + exact le_of_eq (by dsimp only [kernelSpatialWidths]; ring) + +theorem smallKernelSpatial_column_identity [DecidableEq X] + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (θ : ℝ) + (u : Option ((G × X) ⊕ F) × X → ℤ) (k) (i) : + (smallKernelSpatialAnchor N T θ + u) (some k,i) = + (kernelSpatialAnchor N T (θ * kernelAnchorScale G X F) + u) (some k,i) := rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] [DecidableEq X] + +theorem smallKernelSpatial_column_bound + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 ≤ θ) (hθ1 : θ ≤ 1) (hτ1 : τ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ θ * kernelNoiseScale G X F) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (smallKernelSpatialWidths N T θ τ) 1) (k) (i) : + |((smallKernelSpatialAnchor N T θ + u) (some k,i) : ℝ) / ((N i : ℝ) / T k)| ≤ + θ * (kernelAnchorScale G X F + 2 * kernelNoiseScale G X F) := by + have hs := kernelSpatial_scales G X F + have hu' := rectangularWeightIndices_zero_mono (smallKernelSpatialWidths_le N T hθ1) hu + have h := kernelSpatial_column_bound N hN T hT (mul_nonneg hθ hs.1.le) + (mul_nonneg hθ hs.2.1.le) hτ1 hscale hu' k i + rw [smallKernelSpatial_column_identity] + exact h.trans_eq (by ring) + +theorem smallKernelSpatial_site_bound + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 ≤ θ) (hθ1 : θ ≤ 1) (hτ1 : τ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ θ * kernelNoiseScale G X F) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (smallKernelSpatialWidths N T θ τ) 1) + (root : (G × X) ⊕ F → ℤ) (hroot : ∀ k, |(root k : ℝ)| ≤ T k) (i : X) : + |(integerPhysicalSite root (smallKernelSpatialAnchor N T θ + u) i : ℝ)| ≤ θ * (N i : ℝ) / 4 := by + have hn : (0 : ℝ) < N i := by exact_mod_cast hN i + let a := kernelAnchorScale G X F + let η := kernelNoiseScale G X F + have hbase := rectangularWeightIndices_zero_bound (smallKernelSpatialWidths N T θ τ) hu (none,i) + change |(u (none,i) : ℝ)| ≤ θ * ((N i : ℝ) / 8) at hbase + have hcol (k) : |(root k : ℝ) * ((smallKernelSpatialAnchor N T θ + u) (some k,i) : ℝ)| ≤ + (θ * (a + 2 * η)) * (N i : ℝ) := + scaled_coordinate_product_bound hn (hT k) + (smallKernelSpatial_column_bound N hN T hT hθ hθ1 hτ1 hscale hu k i) (hroot k) + have hfit := mul_le_mul_of_nonneg_right (kernelSpatial_scales G X F).2.2.2.2 + (mul_nonneg hθ hn.le) + have heq : (integerPhysicalSite root (smallKernelSpatialAnchor N T θ + u) i : ℝ) = + (u (none,i) : ℝ) + ∑ k, (root k : ℝ) * + ((smallKernelSpatialAnchor N T θ + u) (some k,i) : ℝ) := by + simp only [integerPhysicalSite, Pi.add_apply, smallKernelSpatialAnchor, baseArrayJoin, + Pi.zero_apply, zero_add, Int.cast_add, Int.cast_sum, Int.cast_mul] + have hraw : |(integerPhysicalSite root (smallKernelSpatialAnchor N T θ + u) i : ℝ)| ≤ + θ * ((N i : ℝ) / 8) + (Fintype.card ((G × X) ⊕ F) : ℝ) * + (θ * (a + 2 * η)) * (N i : ℝ) := by + rw [heq] + calc + _ ≤ |(u (none,i) : ℝ)| + |∑ k, (root k : ℝ) * + ((smallKernelSpatialAnchor N T θ + u) (some k,i) : ℝ)| := abs_add_le _ _ + _ ≤ θ * ((N i : ℝ) / 8) + ∑ k, |(root k : ℝ) * + ((smallKernelSpatialAnchor N T θ + u) (some k,i) : ℝ)| := + add_le_add hbase (Finset.abs_sum_le_sum_abs _ _) + _ ≤ θ * ((N i : ℝ) / 8) + ∑ _k : (G × X) ⊕ F, + (θ * (a + 2 * η)) * (N i : ℝ) := add_le_add le_rfl (Finset.sum_le_sum (fun k _ => hcol k)) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + dsimp only [a, η] at hraw + nlinarith + +theorem smallKernelSpatial_trim_margin + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 ≤ θ) (hθ1 : θ ≤ 1) (hτ1 : τ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ θ * kernelNoiseScale G X F) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (smallKernelSpatialWidths N T θ τ) 1) + (root : (G × X) ⊕ F → ℤ) (hroot : ∀ k, |(root k : ℝ)| ≤ T k) (i : X) : + |integerPhysicalSite root (smallKernelSpatialAnchor N T θ + u) i| ≤ + (spatialTrimMargin θ N i : ℤ) := by + have h := (smallKernelSpatial_site_bound N hN T hT hθ hθ1 hτ1 hscale hu root hroot i).trans + (Nat.le_ceil (θ * (N i : ℝ) / 4)) + exact_mod_cast h + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] + +theorem smallKernelSpatialWidths_lower_bound + (N : X → ℕ) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {L θ τ : ℝ} (hL : 1 ≤ L) (hTL : ∀ k, T k ≤ L) + (hθ : 0 ≤ θ) (hτ : 0 ≤ τ) (hτ1 : τ ≤ 1) (z) : + (θ * τ * kernelNoiseScale G X F / L) * (N z.2 : ℝ) ≤ smallKernelSpatialWidths N T θ τ z := by + have hs := kernelSpatial_scales G X F + have h := mul_le_mul_of_nonneg_left + (kernelSpatialWidths_lower_bound N T hT hL hTL hs.2.1.le hs.2.2.1 hτ hτ1 z) hθ + change (θ * τ * kernelNoiseScale G X F / L) * (N z.2 : ℝ) ≤ + θ * kernelSpatialWidths N T (kernelNoiseScale G X F) τ z + calc + _ = θ * ((τ * kernelNoiseScale G X F / L) * (N z.2 : ℝ)) := by ring + _ ≤ _ := h + +theorem smallKernelSpatial_relative_width_budget {P Q θ τ L : ℝ} + (hK : (Fintype.card ((G × X) ⊕ F) : ℝ) ≤ P) (hX : (Fintype.card X : ℝ) ≤ P) + (hθ : 0 < θ) (hθP : 1 / θ ≤ Real.exp P) (hτ : 0 < τ) (hτP : 1 / τ ≤ Real.exp P) + (hL : 0 < L) (hLQ : L ≤ Real.exp Q) : + 0 < θ * τ * kernelNoiseScale G X F / L ∧ + 1 / (θ * τ * kernelNoiseScale G X F / L) ≤ Real.exp (Q + 4 * P + 64) := by + have hη := (kernelSpatial_scales G X F).2.1 + have hρ := kernelSpatial_relative_width_budget hK hX hτ hτP hL hLQ + refine ⟨by positivity, ?_⟩ + have heq : 1 / (θ * τ * kernelNoiseScale G X F / L) = + (1 / θ) * (1 / (τ * kernelNoiseScale G X F / L)) := by field_simp + rw [heq] + calc + _ ≤ Real.exp P * Real.exp (Q + 3 * P + 64) := + mul_le_mul hθP hρ.2 (by positivity) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem smallKernelSpatial_rounding_scale {P Q θ L : ℝ} + (hK : (Fintype.card ((G × X) ⊕ F) : ℝ) ≤ P) (hX : (Fintype.card X : ℝ) ≤ P) + (hθ : 0 < θ) (hθP : 1 / θ ≤ Real.exp P) (hLQ : L ≤ Real.exp Q) + (N : X → ℕ) (hN : ∀ i, Real.exp (Q + 3 * P + 64) ≤ (N i : ℝ)) + (T : (G × X) ⊕ F → ℝ) (hTL : ∀ k, T k ≤ L) (g : G) (j i : X) : + 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ θ * kernelNoiseScale G X F := by + have hη := (kernelSpatial_scales G X F).2.1 + have hn : (0 : ℝ) < N i := (Real.exp_pos _).trans_le (hN i) + have hinv : 1 / (θ * kernelNoiseScale G X F) ≤ Real.exp (3 * P + 64) := by + have heq : 1 / (θ * kernelNoiseScale G X F) = + (1 / θ) * (1 / kernelNoiseScale G X F) := by field_simp + rw [heq] + calc + _ ≤ Real.exp P * Real.exp (2 * P + 64) := + mul_le_mul hθP (kernelNoiseScale_reciprocal_le hK hX) (by positivity) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hlarge : L / (θ * kernelNoiseScale G X F) ≤ (N i : ℝ) := by + calc + _ = L * (1 / (θ * kernelNoiseScale G X F)) := by ring + _ ≤ Real.exp Q * Real.exp (3 * P + 64) := + mul_le_mul hLQ hinv (by positivity) (Real.exp_nonneg _) + _ = Real.exp (Q + 3 * P + 64) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := hN i + have hmul := (div_le_iff₀ (mul_pos hθ hη)).mp hlarge + have heq : 1 / ((N i : ℝ) / T (.inl (g,j))) = T (.inl (g,j)) / (N i : ℝ) := by field_simp + rw [heq] + apply (div_le_iff₀ hn).mpr + simpa only [mul_comm] using (hTL (.inl (g,j))).trans hmul + +end Erdos3 + +end + +section + +namespace Erdos3 + +open BooleanCubeKernel +open scoped BigOperators + +variable {G X F : Type*} [Fintype G] [Fintype X] [Fintype F] [DecidableEq X] + +theorem smallKernelSpatial_kernel_inverse + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 < θ) (hθ1 : θ ≤ 1) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ θ * kernelNoiseScale G X F) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (smallKernelSpatialWidths N T θ τ) 1) + (base : X → ℤ) (g : G) : + (matrixSupCLM (normalizedKernelBlock N T + ((integerBaseTranslation base + smallKernelSpatialAnchor N T θ) + u) g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N T + ((integerBaseTranslation base + smallKernelSpatialAnchor N T θ) + u) g)).inverse‖ ≤ + (32 * ((Fintype.card ((G × X) ⊕ F) : ℝ) + 1)) / θ := by + have hs := kernelSpatial_scales G X F + have hu' := rectangularWeightIndices_zero_mono (smallKernelSpatialWidths_le N T hθ1) hu + have hsmall : (Fintype.card X : ℝ) * (2 * (θ * kernelNoiseScale G X F)) ≤ + (θ * kernelAnchorScale G X F) / 2 := by + have h := mul_le_mul_of_nonneg_left hs.2.2.2.1 hθ.le + nlinarith + have h := kernelSpatial_kernel_inverse N hN T hT (mul_pos hθ hs.1) + (mul_nonneg hθ.le hs.2.1.le) hscale hsmall hu' g + have heq : normalizedKernelBlock N T + ((integerBaseTranslation base + smallKernelSpatialAnchor N T θ) + u) g = + normalizedKernelBlock N T (kernelSpatialAnchor N T (θ * kernelAnchorScale G X F) + u) g := by + ext i j + simp only [normalizedKernelBlock, integerBaseTranslation, smallKernelSpatialAnchor, + baseArrayJoin, Pi.add_apply, Pi.zero_apply, zero_add] + rw [heq] + refine ⟨h.1, h.2.trans_eq ?_⟩ + rw [show 2 / (θ * kernelAnchorScale G X F) = (2 / kernelAnchorScale G X F) / θ by + field_simp, two_div_kernelAnchorScale] + +theorem smallKernelSpatial_nonkernel_displacement + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 ≤ θ) (hθ1 : θ ≤ 1) (hτ : 0 ≤ τ) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (smallKernelSpatialWidths N T θ τ) 1) + (base : X → ℤ) (root : (G × X) ⊕ F → ℤ) (hroot : ∀ k, |(root k : ℝ)| ≤ T k) (i : X) : + |∑ f : F, (root (.inr f) : ℝ) * + (((integerBaseTranslation base + smallKernelSpatialAnchor N T θ + u : + Option ((G × X) ⊕ F) × X → ℤ) (some (.inr f),i)) : ℝ)| ≤ + τ * θ * (N i : ℝ) / 16 := by + have hu' := rectangularWeightIndices_zero_mono (smallKernelSpatialWidths_le N T hθ1) hu + have h := kernelSpatial_nonkernel_displacement N hN T hT + (θ * kernelAnchorScale G X F) (θ * kernelNoiseScale G X F) τ hu' root hroot i + calc + _ ≤ (Fintype.card F : ℝ) * (τ * (θ * kernelNoiseScale G X F)) * (N i : ℝ) := by + simpa only [Pi.add_apply, integerBaseTranslation, smallKernelSpatialAnchor, baseArrayJoin, + kernelSpatialAnchor, kernelColumnCenter, Pi.zero_apply, mul_zero, Int.floor_zero, zero_add] using h + _ = ((Fintype.card F : ℝ) * kernelNoiseScale G X F) * (τ * θ * (N i : ℝ)) := by ring + _ ≤ (1 / 16) * (τ * θ * (N i : ℝ)) := + mul_le_mul_of_nonneg_right kernelNoiseScale_nonkernel_cap (by positivity) + _ = _ := by ring + +theorem smallKernelSpatial_base_mem_box + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 < θ) (hθhalf : θ ≤ 1/2) (hτ1 : τ ≤ 1) + (hsize : ∀ i, 4 ≤ θ * (N i : ℝ)) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ θ * kernelNoiseScale G X F) + {u : Option ((G × X) ⊕ F) × X → ℤ} + (hu : u ∈ rectangularWeightIndices 0 (smallKernelSpatialWidths N T θ τ) 1) + {base : X → ℤ} (hb : base ∈ trimmedIntegerBox N (spatialTrimMargin θ N)) + (root : (G × X) ⊕ F → ℤ) (hroot : ∀ k, |(root k : ℝ)| ≤ T k) : + integerPhysicalSite root ((integerBaseTranslation base + smallKernelSpatialAnchor N T θ) + u) ∈ + integerBox N := by + rw [add_assoc, integerPhysicalSite_baseTranslation_add] + exact trimmedIntegerBox_add_mem N (spatialTrimMargin θ N) + (fun i => (spatialTrimMargin_proper hθhalf N hN hsize i).le) hb _ + (smallKernelSpatial_trim_margin N hN T hT hθ.le (by linarith) hτ1 hscale hu root hroot) + +theorem translatedSmallKernelSpatial_support + (N : X → ℕ) (hN : ∀ i, 0 < N i) (T : (G × X) ⊕ F → ℝ) (hT : ∀ k, 0 < T k) + {θ τ : ℝ} (hθ : 0 < θ) (hθhalf : θ ≤ 1/2) (hτ : 0 < τ) (hτ1 : τ ≤ 1) + (hsize : ∀ i, 4 ≤ θ * (N i : ℝ)) + (hscale : ∀ g j i, 1 / ((N i : ℝ) / T (.inl (g,j))) ≤ θ * kernelNoiseScale G X F) + {base : X → ℤ} (hb : base ∈ trimmedIntegerBox N (spatialTrimMargin θ N)) + (modulus : X → ℕ) + (S : Finset (ColumnResiduePattern (Option ((G × X) ⊕ F)) X modulus)) + (hZ : 0 < ∑' u, selectedResidueSmoothWeight modulus S (smallKernelSpatialWidths N T θ τ) u) + (D : (Option ((G × X) ⊕ F) × X → ℤ) → ℝ) (hD0 : ∀ z, 0 ≤ D z) + (hD : 0 < selectedResidueDensityMass modulus S (smallKernelSpatialWidths N T θ τ) + (fun u => D ((integerBaseTranslation base + smallKernelSpatialAnchor N T θ) + u))) + (z : Option ((G × X) ⊕ F) × X → ℤ) + (hz : 0 < (translatedSelectedResidueDensityPMF + (integerBaseTranslation base + smallKernelSpatialAnchor N T θ) modulus S + (smallKernelSpatialWidths N T θ τ) (smallKernelSpatialWidths_pos N hN T hT hθ hτ) + hZ D hD0 hD z).toReal) : + (∀ g, (matrixSupCLM (normalizedKernelBlock N T z g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N T z g)).inverse‖ ≤ + (32 * ((Fintype.card ((G × X) ⊕ F) : ℝ) + 1)) / θ) ∧ + (∀ root : (G × X) ⊕ F → ℤ, (∀ k, |(root k : ℝ)| ≤ T k) → + integerPhysicalSite root z ∈ integerBox N) ∧ + (∀ root : (G × X) ⊕ F → ℤ, (∀ k, |(root k : ℝ)| ≤ T k) → ∀ i, + |∑ f : F, (root (.inr f) : ℝ) * (z (some (.inr f),i) : ℝ)| ≤ τ * θ * (N i : ℝ) / 16) := by + let anchor := integerBaseTranslation base + smallKernelSpatialAnchor N T θ + have hu := (translatedSelectedResidueDensityPMF_support anchor modulus S + (smallKernelSpatialWidths N T θ τ) (smallKernelSpatialWidths_pos N hN T hT hθ hτ) + hZ D hD0 hD z hz).1 + have heq : (integerBaseTranslation base + smallKernelSpatialAnchor N T θ) + (z - anchor) = z := by + dsimp only [anchor] + abel + refine ⟨?_, ?_, ?_⟩ + · intro g + simpa only [heq] using smallKernelSpatial_kernel_inverse N hN T hT hθ (by linarith) hscale hu base g + · intro root hroot + simpa only [heq] using smallKernelSpatial_base_mem_box N hN T hT hθ hθhalf hτ1 hsize hscale hu hb root hroot + + · intro root hroot i + simpa only [heq] using smallKernelSpatial_nonkernel_displacement N hN T hT hθ.le + (by linarith) hτ.le hu base root hroot i + +end Erdos3 + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open Module Submodule MeasureTheory VectorPolynomial +open scoped BigOperators NNReal Classical + +theorem exists_small_kernel_near_uniform_sampler (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {X G : Type*} [Fintype X] [DecidableEq X] [Nonempty X] [Fintype G] [Nonempty G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (R σ : Fin m → ℝ) (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (_hσ1 : ∀ j, σ j ≤ 1) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cinv j * ‖x‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ)+1) * R j ≤ 1/4) + (L₀ : ℕ) {P δ : ℝ} (_hP : 0 ≤ P) (_hδ : 0 < δ) (_hδsmall : δ ≤ 1/6) + (_hδP : δ⁻¹ ≤ Real.exp P) (_hX : (Fintype.card X : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables (G × X) I n B) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) (_hL₀P : (L₀ : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (θ τ : ℝ) (_hθ : 0 < θ) (_hθhalf : θ ≤ 1/2) (_hθP : 1/θ ≤ Real.exp P) + (_hτ : 0 < τ) (_hτ1 : τ ≤ 1) (_hτP : 1/τ ≤ Real.exp P) + (_hθδ : 2 * (Fintype.card X : ℝ) * θ ≤ δ) + (root : LayerSamplerVariables (G × X) I n B → ℤ) (_hroot : root ∈ layerSamplerIntegerBox B U b + (selectedLayerSamplerScale (G := G × X) B U b R σ hR hσ L₀)) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val+1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : X → ℕ) (_hs : ∀ k, 0 < stride k) + {Rrank S : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (N : X → ℕ) (_hN : ∀ i, 0 < N i) + (_hsize : ∀ k, Real.exp ((P+A)^A) ≤ (N k : ℝ)) + (_hrank : ∀ j, HasLayerSamplingRank (j.val+1) (fun i => (N i : ℝ)) Rrank (U j) (p j)) + (_hRrank : Real.exp ((P+A)^A) ≤ Rrank) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables (G × X) I n B)) X stride)) (_hT : T.Nonempty), + let scale := selectedLayerSamplerScale (G := G × X) B U b R σ hR hσ L₀ + let sites := layerSamplerIntegerBox B U b scale + let F := PrincipalTupleIndex B (layerSamplerDegree I n) + let spatialSides := layerSamplerBox B U b scale + let anchor := smallKernelSpatialAnchor N spatialSides θ + let W := smallKernelSpatialWidths N spatialSides θ τ + let hW := smallKernelSpatialWidths_pos N _hN spatialSides + (fun k => lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) (layerSamplerBox_one_le B U b scale k)) _hθ _hτ + let bases := trimmedIntegerBox N (spatialTrimMargin θ N) + let D := fun center => translatedSelectedPhysicalDensity (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm + let Z := fun base center => selectedResidueDensityMass stride T W + (fun u => D center ((integerBaseTranslation base + anchor) + u)) + ∃ hbase : bases.Nonempty, ∃ hparent : (integerBox N).Nonempty, + ∃ hZ : 0 < ∑' u, selectedResidueSmoothWeight stride T W u, + ∃ hD : ∀ base center, 0 < Z base center, + let law := fun center => selectedAnchoredMixture bases hbase + (fun base => integerBaseTranslation base + anchor) stride T W hW hZ (D center) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (fun base => hD base center); + (∀ base center, |Z base center-1| ≤ 3*δ ∧ 1/2 ≤ Z base center ∧ Z base center ≤ 3/2) ∧ + (∀ φ : (X → ℝ) → ℂ, (∀ v, ‖φ v‖ ≤ 1) → + ‖(𝔼 base ∈ bases, + ∫ center, ∑' z, ((translatedSelectedResidueDensityPMF + (integerBaseTranslation base + anchor) stride T W hW hZ (D center) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (hD base center) z).toReal : ℂ) * + φ (physicalAffineSite root z) ∂μ) - + 𝔼 x ∈ integerBox N, φ (fun i => (x i : ℝ))‖ ≤ 7*δ) ∧ + (∀ base ∈ bases, ∀ center z, + 0 < (translatedSelectedResidueDensityPMF + (integerBaseTranslation base + anchor) stride T W hW hZ (D center) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (hD base center) z).toReal → + (∀ g, (matrixSupCLM (normalizedKernelBlock N spatialSides z g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N spatialSides z g)).inverse‖ ≤ + (32 * ((Fintype.card (LayerSamplerVariables (G × X) I n B) : ℝ) + 1)) / θ) ∧ + (∀ r : LayerSamplerVariables (G × X) I n B → ℤ, + (∀ k, |(r k : ℝ)| ≤ spatialSides k) → integerPhysicalSite r z ∈ integerBox N) ∧ + (∀ r : LayerSamplerVariables (G × X) I n B → ℤ, + (∀ k, |(r k : ℝ)| ≤ spatialSides k) → ∀ i, + |∑ f : F, (r (.inr f) : ℝ) * (z (some (.inr f),i) : ℝ)| ≤ τ * θ * (N i : ℝ) / 16)) ∧ + (∀ base center, + (∑' z, (translatedSelectedResidueDensityPMF + (integerBaseTranslation base + anchor) stride T W hW hZ (D center) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (hD base center) z).toReal * + noninjectivityIndicator (fun q : sites => integerPhysicalSite q.val z)) ≤ δ) ∧ + (∀ center, ∃ c : ∀ j, U j, coefficientConstantCenter U center = + -(QuotientAddGroup.mk' (coefficientIntegerLattice U) (constantCoefficientArray U (fun s => c s.1))) ∧ + ∀ base z, 0 < (translatedSelectedResidueDensityPMF + (integerBaseTranslation base + anchor) stride T W hW hZ (D center) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (hD base center) z).toReal → + HasQuarterAffinePolynomialLifts p (fun j => (c j).val) (fun k v => (z (k,v) : ℝ)) + (layerSamplerBox B U b scale)) ∧ + (∀ center (φ : (X → ℝ) → ℝ), (∀ v, φ v ∈ Set.Icc (0 : ℝ) 1) → + (𝔼 base ∈ bases, + ∑' z, (translatedSelectedResidueDensityPMF + (integerBaseTranslation base + anchor) stride T W hW hZ (D center) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (hD base center) z).toReal * + φ (physicalAffineSite root z)) ≤ + 2 * (∏ j, earlyConstantDensityCap (Fintype.card (I j)) (n j) (R j) (V j)) * + (𝔼 x ∈ integerBox N, φ (fun i => (x i : ℝ))) + 6*δ) ∧ + (∀ center, + (∀ {Y : Type*} [Fintype Y] (Fobs : (X → ℝ) → Y), + let reference := (FiniteProbabilityWeights.uniformFinset (integerBox N) hparent).fiberLaw + (fun x => Fobs (fun i => (x.val i : ℝ))) + let marginal := (law center).fiberLaw (fun z => Fobs (physicalAffineSite root + ((integerBaseTranslation (K := LayerSamplerVariables (G × X) I n B) z.1.val + anchor) + z.2.val))) + let M := ∏ j, earlyConstantDensityCap (Fintype.card (I j)) (n j) (R j) (V j) + reference.excessMass marginal (2*M) ≤ 6*δ ∧ + marginal.mass (Finset.univ.filter (fun y => 4*M*reference.weight y < marginal.weight y)) ≤ 12*δ) ∧ + (let marginal := (law center).fiberLaw (fun z => integerBoxObservation N hparent + (physicalAffineSite root + ((integerBaseTranslation (K := LayerSamplerVariables (G × X) I n B) z.1.val + anchor) + z.2.val))); + let M := ∏ j, earlyConstantDensityCap (Fintype.card (I j)) (n j) (R j) (V j); + (FiniteProbabilityWeights.uniformFinset (integerBox N) hparent).excessMass marginal (2*M) ≤ 6*δ ∧ + marginal.mass (Finset.univ.filter (fun x => 4*M/(integerBox N).card < marginal.weight x)) ≤ 12*δ)) := by + obtain ⟨aM, haM, hmixed⟩ := exists_base_and_center_mixed_selected_sampler_law m + obtain ⟨aG, _, hgeometry⟩ := exists_centered_full_parameter_anchored_geometry m + obtain ⟨aD, _, hdomination⟩ := exists_anchored_fixed_center_selected_sampler_box_domination m + let a := max aM (max aG aD) + have ha : 2 ≤ a := haM.trans (le_max_left _ _) + obtain ⟨A, hA, hthreshold⟩ := exists_smallKernelSamplerThreshold m a + refine ⟨A, hA, ?_⟩ + intro X G _ _ _ _ _ I _ n B _ J _ U b hb o _ _ _ _ μ _ _ ν _ _ + R σ hR hσ hσ1 C V hC hV Cinv hCinv hchart hsmall L₀ P δ hP hδ hδsmall hδP + hX hK hI hn hJ hAP hL₀P hCP hVP hRP hσP θ τ hθ hθhalf hθP hτ hτ1 hτP hθδ + root hroot p hp hm stride hs Rrank S hS hSP hstride N hN hsize hrank hRrank T hT + let scale := selectedLayerSamplerScale (G := G × X) B U b R σ hR hσ L₀ + let spatialSides := layerSamplerBox B U b scale + let anchor := smallKernelSpatialAnchor N spatialSides θ + let W := smallKernelSpatialWidths N spatialSides θ τ + have hsidepos (k) : 0 < spatialSides k := + lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) (layerSamplerBox_one_le B U b scale k) + have hLpos : (0 : ℝ) < scale.value := by exact_mod_cast scale.positive + have hL1 : (1 : ℝ) ≤ scale.value := by exact_mod_cast scale.positive + have hsidele (k) : spatialSides k ≤ (scale.value : ℝ) := layerSamplerBox_le B U b scale k + have hW := smallKernelSpatialWidths_pos N hN spatialSides hsidepos hθ hτ + let Q := selectedFourierInputBudget m P + let P' := smallKernelSamplerBudget m P + have hP' : 0 ≤ P' := smallKernelSamplerBudget_nonneg m hP + have hmono (c : ℕ) (hc : c ≤ a) : Real.exp ((P'+c)^c) ≤ Real.exp ((P'+a)^a) := by + apply Real.exp_le_exp.mpr + have hca : (c : ℝ) ≤ a := by exact_mod_cast hc + have ha2 : (2 : ℝ) ≤ a := by exact_mod_cast ha + exact (pow_le_pow_left₀ (by positivity) (by linarith : P'+(c:ℝ) ≤ P'+a) c).trans + (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ P'+a) hc) + have hthresholdM := (hmono aM (le_max_left _ _)).trans (hthreshold P hP).2 + have hthresholdG := (hmono aG ((le_max_left _ _).trans (le_max_right _ _))).trans (hthreshold P hP).2 + have hthresholdD := (hmono aD ((le_max_right _ _).trans (le_max_right _ _))).trans (hthreshold P hP).2 + have hPP' : P ≤ P' := le_smallKernelSamplerBudget m hP + have hQQ' : Q ≤ P' := by dsimp [P', smallKernelSamplerBudget, Q]; linarith + have heP : Real.exp P ≤ Real.exp P' := Real.exp_le_exp.mpr hPP' + have hL : (scale.value : ℝ) ≤ Real.exp Q := + selectedLayerSamplerScale_input_bound B U b R σ hR hσ L₀ hP hK hn hRP hσP hAP hL₀P + let ρ := θ * τ * kernelNoiseScale G X (PrincipalTupleIndex B (layerSamplerDegree I n)) / + (scale.value : ℝ) + have hρ := smallKernelSpatial_relative_width_budget hK hX hθ hθP hτ hτP hLpos hL + have hρP : 1 / ρ ≤ Real.exp P' := hρ.2.trans (Real.exp_le_exp.mpr (by + dsimp [P', smallKernelSamplerBudget, Q]; linarith)) + have hwidth (z) : ρ * (N z.2 : ℝ) ≤ W z := + smallKernelSpatialWidths_lower_bound N spatialSides hsidepos hL1 hsidele hθ.le hτ.le hτ1 z + have hNlarge (i) : Real.exp (Q + 3 * P + 64) ≤ (N i : ℝ) := by + have hb' : Q + 3 * P + 64 ≤ P' := by dsimp [P', smallKernelSamplerBudget, Q]; linarith + exact (Real.exp_le_exp.mpr hb').trans ((hthreshold P hP).1.trans (hsize i)) + have hround := smallKernelSpatial_rounding_scale hK hX hθ hθP hL N hNlarge spatialSides hsidele + have hNθ (i) : 4 ≤ θ * (N i : ℝ) := by + apply spatialTrimMargin_size_of_exp_size hP hθ (by simpa only [one_div] using hθP) + have hb' : 5 * P + 128 ≤ P' := by + dsimp [P', smallKernelSamplerBudget, Q] + have h := le_selectedFourierInputBudget m hP + linarith + exact (Real.exp_le_exp.mpr hb').trans ((hthreshold P hP).1.trans (hsize i)) + have hrootSide (k) : |(root k : ℝ)| ≤ spatialSides k := layerSamplerIntegerBox_abs_bound B U b scale hroot k + have hrootP (k) : |(root k : ℝ)| ≤ Real.exp P' := + (hrootSide k).trans ((hsidele k).trans (hL.trans (Real.exp_le_exp.mpr hQQ'))) + have hnoise (u) (hu : u ∈ rectangularWeightIndices 0 W 1) (i) : + |integerPhysicalSite root (anchor + u) i| ≤ (spatialTrimMargin θ N i : ℤ) := + smallKernelSpatial_trim_margin N hN spatialSides hsidepos hθ.le (by linarith) hτ1 hround hu root hrootSide i + obtain ⟨hZ, hD, hnormal, hcompare⟩ := hmixed B U b hb o μ ν R σ hR hσ hσ1 C V hC hV + Cinv hCinv hchart hsmall L₀ hP' hδ hδsmall (hδP.trans heP) (hX.trans hPP') (hK.trans hPP') + (fun j => (hI j).trans hPP') (fun j => (hn j).trans hPP') (fun j => (hJ j).trans hPP') + (hAP.trans heP) (hL₀P.trans heP) (fun j => (hCP j).trans heP) (fun j => (hVP j).trans heP) + (fun j => (hRP j).trans heP) (fun j => (hσP j).trans heP) + anchor root hrootP p hp hm stride hs hS (hSP.trans heP) hstride hρ.1 hρP (fun i => (N i : ℝ)) + (fun i => hthresholdM.trans (hsize i)) hrank (hthresholdM.trans hRrank) + T hT W hW hwidth N (spatialTrimMargin θ N) (spatialTrimMargin_proper hθhalf N hN hNθ) hnoise + have hbase := trimmedIntegerBox_nonempty N (spatialTrimMargin θ N) + (spatialTrimMargin_proper hθhalf N hN hNθ) + have hparent : (integerBox N).Nonempty := by + refine ⟨0, (mem_integerBox N 0).mpr ?_⟩ + intro i + refine ⟨le_refl 0, ?_⟩ + change (0 : ℤ) < (N i : ℤ) + exact_mod_cast hN i + refine ⟨hbase, hparent, hZ, hD, hnormal, ?_, ?_, ?_, ?_, ?_⟩ + · intro φ hφ + have hc := hcompare φ hφ + have hb' := spatialTrimMargin_error_bound N hN hNθ + exact hc.trans (by linarith) + · intro base hb' center z hz + exact translatedSmallKernelSpatial_support N hN spatialSides hsidepos hθ hθhalf hτ hτ1 hNθ hround + hb' stride T hZ _ + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (hD base center) z hz + + · intro base center + obtain ⟨_, _, _, _, _, _, _, _, _, _, _, _, hcollision⟩ := + hgeometry B U b hb o μ ν R σ hR hσ hσ1 C V hC hV Cinv hCinv hchart hsmall L₀ + hP' hδ hδsmall (hδP.trans heP) (hX.trans hPP') (hK.trans hPP') + (fun j => (hI j).trans hPP') (fun j => (hn j).trans hPP') (fun j => (hJ j).trans hPP') + (hAP.trans heP) (hL₀P.trans heP) (fun j => (hCP j).trans heP) (fun j => (hVP j).trans heP) + (fun j => (hRP j).trans heP) (fun j => (hσP j).trans heP) + center (integerBaseTranslation base + anchor) p hp hm stride hs hS (hSP.trans heP) hstride + hρ.1 hρP (fun i => (N i : ℝ)) (fun i => hthresholdG.trans (hsize i)) hrank + (hthresholdG.trans hRrank) T hT W hW hwidth + exact hcollision + · intro center + obtain ⟨c, hc, hlift⟩ := exists_constant_center_uniform_lifts B U b hb o R σ hR hσ L₀ + hσ1 Cinv hCinv hchart hsmall p hp hm center + refine ⟨c, hc, ?_⟩ + intro base z hz + have hpos := (translatedSelectedResidueDensityPMF_support + (integerBaseTranslation base + anchor) stride T W hW hZ + (translatedSelectedPhysicalDensity (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (hD base center) z hz).2.2 + exact hlift z (ne_of_gt hpos) + · have hloss : (∑ i, 2 * (spatialTrimMargin θ N i : ℝ) / N i) ≤ 1/2 := by + have h := spatialTrimMargin_error_bound N hN hNθ + linarith + obtain ⟨_, _, _, hbound⟩ := hdomination B U b hb o μ ν R σ hR hσ hσ1 C V hC hV + Cinv hCinv hchart hsmall L₀ hP' hδ hδsmall (hδP.trans heP) (hX.trans hPP') (hK.trans hPP') + (fun j => (hI j).trans hPP') (fun j => (hn j).trans hPP') (fun j => (hJ j).trans hPP') + (hAP.trans heP) (hL₀P.trans heP) (fun j => (hCP j).trans heP) (fun j => (hVP j).trans heP) + (fun j => (hRP j).trans heP) (fun j => (hσP j).trans heP) + anchor root hrootP p hp hm stride hs hS (hSP.trans heP) hstride hρ.1 hρP (fun i => (N i : ℝ)) + (fun i => hthresholdD.trans (hsize i)) hrank (hthresholdD.trans hRrank) + T hT W hW hwidth N (spatialTrimMargin θ N) (spatialTrimMargin_proper hθhalf N hN hNθ) hnoise hloss + constructor + · intro center φ hφ + exact hbound (coefficientConstantCenter U center) φ hφ + · intro center + have htwice (v : ℝ) : 2 * (2*v) = 4*v := by ring + have herror : 2 * (6*δ) = 12*δ := by ring + constructor + · intro Y _ Fobs + have hexcess := selectedAnchoredMixture_physical_excess_le _ hbase + (fun base => integerBaseTranslation base + anchor) stride T W hW hZ _ + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (fun base => hD base center) + root (integerBox N) hparent (hbound (coefficientConstantCenter U center)) Fobs + refine ⟨hexcess, ?_⟩ + have htail := FiniteProbabilityWeights.mass_above_double_cap_le_of_excess _ _ hexcess + simpa only [htwice, herror] using htail + · have htail := selectedAnchoredMixture_integer_box_excess_tail _ hbase + (fun base => integerBaseTranslation base + anchor) stride T W hW hZ _ + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (fun base => hD base center) + root N hparent (hbound (coefficientConstantCenter U center)) + simpa only [htwice, herror] using htail + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel + +open Module Submodule MeasureTheory VectorPolynomial +open scoped BigOperators NNReal Classical + +theorem exists_small_kernel_all_sites_sampler (m : ℕ) : + ∃ A : ℕ, 2 ≤ A ∧ ∀ {X G : Type*} [Fintype X] [DecidableEq X] [Nonempty X] [Fintype G] [Nonempty G] + {I : Fin m → Type*} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + (B : LayerSamplerAxis I n → Type*) [∀ a, Fintype (B a)] + {J : Fin m → Type*} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) + (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + [CompactSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + [BorelSpace (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables (G × X) I n B) U)) + [μ.IsAddLeftInvariant] [IsProbabilityMeasure μ] + (ν : ∀ j, Measure (euclideanSubspace (U j) ⧸ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j))).toAddSubgroup)) + [∀ j, (ν j).IsAddLeftInvariant] [∀ j, IsProbabilityMeasure (ν j)] + (R σ : Fin m → ℝ) (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) (_hσ1 : ∀ j, σ j ≤ 1) + (C V : Fin m → ℝ≥0) + (_hC : ∀ j x, ‖normalizedOrthogonalChart (euclideanSubspace (U j)) (b j) x‖ ≤ C j * ‖x‖) + (_hV : ∀ j, 0 ≤ mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ∧ + mixedDensityCovolumeRatio (euclideanSubspace (U j)) (b j) ≤ V j) + (Cinv : Fin m → ℝ) (_hCinv : ∀ j, 0 ≤ Cinv j) + (_hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (b j)).symm x‖ ≤ Cinv j * ‖x‖) + (_hsmall : ∀ j, Cinv j * ((Fintype.card (I j) : ℝ)+1) * R j ≤ 1/4) + (L₀ : ℕ) {P δ : ℝ} (_hP : 0 ≤ P) (_hδ : 0 < δ) (_hδsmall : δ ≤ 1/6) + (_hδP : δ⁻¹ ≤ Real.exp P) (_hX : (Fintype.card X : ℝ) ≤ P) + (_hK : (Fintype.card (LayerSamplerVariables (G × X) I n B) : ℝ) ≤ P) + (_hI : ∀ j, (Fintype.card (I j) : ℝ) ≤ P) (_hn : ∀ j, (n j : ℝ) ≤ P) + (_hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ P) + (_hAP : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P) (_hL₀P : (L₀ : ℝ) ≤ Real.exp P) + (_hCP : ∀ j, (C j : ℝ) ≤ Real.exp P) (_hVP : ∀ j, (V j : ℝ) ≤ Real.exp P) + (_hRP : ∀ j, (R j)⁻¹ ≤ Real.exp P) (_hσP : ∀ j, (σ j)⁻¹ ≤ Real.exp P) + (θ τ : ℝ) (_hθ : 0 < θ) (_hθhalf : θ ≤ 1/2) (_hθP : 1/θ ≤ Real.exp P) + (_hτ : 0 < τ) (_hτ1 : τ ≤ 1) (_hτP : 1/τ ≤ Real.exp P) + (_hθδ : 2 * (Fintype.card X : ℝ) * θ ≤ δ) + (p : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (_hp : ∀ j, DegreeLE (1 : X → ℕ) (j.val+1) (p j)) + (hm : ∀ j d, coefficients (p j) d ∈ U j) + (stride : X → ℕ) (_hs : ∀ k, 0 < stride k) + {Rrank S : ℝ} (_hS : 0 ≤ S) (_hSP : S ≤ Real.exp P) (_hstride : ∀ k, (stride k : ℝ) ≤ S) + (N : X → ℕ) (_hN : ∀ i, 0 < N i) + (_hsize : ∀ k, Real.exp ((P+A)^A) ≤ (N k : ℝ)) + (_hrank : ∀ j, HasLayerSamplingRank (j.val+1) (fun i => (N i : ℝ)) Rrank (U j) (p j)) + (_hRrank : Real.exp ((P+A)^A) ≤ Rrank) + (T : Finset (ColumnResiduePattern (Option (LayerSamplerVariables (G × X) I n B)) X stride)) (_hT : T.Nonempty), + let scale := selectedLayerSamplerScale (G := G × X) B U b R σ hR hσ L₀ + let sites := layerSamplerIntegerBox B U b scale + let F := PrincipalTupleIndex B (layerSamplerDegree I n) + let spatialSides := layerSamplerBox B U b scale + let anchor := smallKernelSpatialAnchor N spatialSides θ + let W := smallKernelSpatialWidths N spatialSides θ τ + let hW := smallKernelSpatialWidths_pos N _hN spatialSides + (fun k => lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) (layerSamplerBox_one_le B U b scale k)) _hθ _hτ + let bases := trimmedIntegerBox N (spatialTrimMargin θ N) + let D := fun center => translatedSelectedPhysicalDensity (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm + let Z := fun base center => selectedResidueDensityMass stride T W + (fun u => D center ((integerBaseTranslation base + anchor) + u)) + ∃ hsites : sites.Nonempty, ∃ hbase : bases.Nonempty, ∃ hparent : (integerBox N).Nonempty, + ∃ hZ : 0 < ∑' u, selectedResidueSmoothWeight stride T W u, + ∃ hD : ∀ base center, 0 < Z base center, + letI : Nonempty sites := hsites.to_subtype; + let frame : (bases × rectangularWeightIndices 0 W 1) → + Option (LayerSamplerVariables (G × X) I n B) × X → ℤ := + fun z => (integerBaseTranslation (K := LayerSamplerVariables (G × X) I n B) z.1.val + anchor) + z.2.val + let law := fun center => selectedAnchoredMixture bases hbase + (fun base => integerBaseTranslation base + anchor) stride T W hW hZ (D center) + (translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm) (fun base => hD base center) + let point := fun z (root : sites) => integerBoxObservation N hparent (physicalAffineSite root.val (frame z)) + let M := ∏ j, earlyConstantDensityCap (Fintype.card (I j)) (n j) (R j) (V j); + (∀ base center, |Z base center-1| ≤ 3*δ ∧ 1/2 ≤ Z base center ∧ Z base center ≤ 3/2) ∧ + (∀ center z, 0 < (law center).weight z → + (∀ g, (matrixSupCLM (normalizedKernelBlock N spatialSides (frame z) g)).IsInvertible ∧ + ‖(matrixSupCLM (normalizedKernelBlock N spatialSides (frame z) g)).inverse‖ ≤ + (32 * ((Fintype.card (LayerSamplerVariables (G × X) I n B) : ℝ) + 1)) / θ) ∧ + (∀ r : LayerSamplerVariables (G × X) I n B → ℤ, + (∀ k, |(r k : ℝ)| ≤ spatialSides k) → integerPhysicalSite r (frame z) ∈ integerBox N) ∧ + (∀ r : LayerSamplerVariables (G × X) I n B → ℤ, + (∀ k, |(r k : ℝ)| ≤ spatialSides k) → ∀ i, + |∑ f : F, (r (.inr f) : ℝ) * (frame z (some (.inr f),i) : ℝ)| ≤ τ*θ*(N i : ℝ)/16)) ∧ + (∀ center z, 0 < (law center).weight z → ∀ root : sites, + (point z root).val = integerPhysicalSite root.val (frame z)) ∧ + (∀ center, ∃ c : ∀ j, U j, coefficientConstantCenter U center = + -(QuotientAddGroup.mk' (coefficientIntegerLattice U) (constantCoefficientArray U (fun s => c s.1))) ∧ + ∀ z, 0 < (law center).weight z → + HasQuarterAffinePolynomialLifts p (fun j => (c j).val) (fun k v => (frame z (k,v) : ℝ)) spatialSides) ∧ + (∀ center, (law center).mean (fun z => + noninjectivityIndicator (fun root : sites => integerPhysicalSite root.val (frame z))) ≤ δ) ∧ + (∀ root : sites, ∀ φ : (X → ℝ) → ℂ, (∀ v, ‖φ v‖ ≤ 1) → + ‖(∫ center, (law center).complexMean (fun z => φ (physicalAffineSite root.val (frame z))) ∂μ) - + 𝔼 x ∈ integerBox N, φ (fun i => (x i : ℝ))‖ ≤ 7*δ) ∧ + (∀ root : sites, ∀ center (φ : (X → ℝ) → ℝ), (∀ v, φ v ∈ Set.Icc (0 : ℝ) 1) → + (law center).mean (fun z => φ (physicalAffineSite root.val (frame z))) ≤ + 2*M*(𝔼 x ∈ integerBox N, φ (fun i => (x i : ℝ))) + 6*δ) ∧ + (∀ center, let marginal := (law center).siteLaw point; + (FiniteProbabilityWeights.uniformFinset (integerBox N) hparent).excessMass marginal (2*M) ≤ 6*δ ∧ + marginal.mass (Finset.univ.filter (fun x => 4*M/(integerBox N).card < marginal.weight x)) ≤ 12*δ) := by + obtain ⟨A, hA, hcore⟩ := exists_small_kernel_near_uniform_sampler.{_, _, _, _, _, 0} m + refine ⟨A, hA, ?_⟩ + intro X G _ _ _ _ _ I _ n B _ J _ U b hb o _ _ _ _ μ _ _ ν _ _ + R σ hR hσ hσ1 C V hC hV Cinv hCinv hchart hsmall L₀ P δ hP hδ hδsmall hδP + hX hK hI hn hJ hAP hL₀P hCP hVP hRP hσP θ τ hθ hθhalf hθP hτ hτ1 hτP hθδ + p hp hm stride hs Rrank S hS hSP hstride N hN hsize hrank hRrank T hT + let scale := selectedLayerSamplerScale (G := G × X) B U b R σ hR hσ L₀ + let sites := layerSamplerIntegerBox B U b scale + let spatialSides := layerSamplerBox B U b scale + let anchor := smallKernelSpatialAnchor N spatialSides θ + let W := smallKernelSpatialWidths N spatialSides θ τ + have hsidepos (k) : 0 < spatialSides k := + lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) (layerSamplerBox_one_le B U b scale k) + have hW := smallKernelSpatialWidths_pos N hN spatialSides hsidepos hθ hτ + let bases := trimmedIntegerBox N (spatialTrimMargin θ N) + let D := fun center => translatedSelectedPhysicalDensity (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm + let anchors := fun base : X → ℤ => (integerBaseTranslation base : + Option (LayerSamplerVariables (G × X) I n B) × X → ℤ) + anchor + have hsites : sites.Nonempty := layerSamplerIntegerBox_nonempty B U b scale + let : Nonempty sites := hsites.to_subtype + have hfamily (root : sites) := hcore B U b hb o μ ν R σ hR hσ hσ1 C V hC hV + Cinv hCinv hchart hsmall L₀ hP hδ hδsmall hδP hX hK hI hn hJ hAP hL₀P hCP hVP hRP hσP + θ τ hθ hθhalf hθP hτ hτ1 hτP hθδ root.val root.property p hp hm stride hs + hS hSP hstride N hN hsize hrank hRrank T hT + obtain ⟨hbase, hparent, hZ, hD, hnormal, _, hgeometry, hcollision, hlifts, _, _⟩ := + hfamily (Classical.choice inferInstance) + let frame : (bases × rectangularWeightIndices 0 W 1) → + Option (LayerSamplerVariables (G × X) I n B) × X → ℤ := + fun z => anchors z.1.val + z.2.val + let hD0 := fun center => translatedSelectedPhysicalDensity_nonneg (G := G × X) B U b hb o R σ hR hσ L₀ + (coefficientConstantCenter U center) p hm + let law := fun center => selectedAnchoredMixture bases hbase anchors stride T W hW hZ + (D center) (hD0 center) (fun base => hD base center) + let point := fun z (root : sites) => integerBoxObservation N hparent (physicalAffineSite root.val (frame z)) + have hpositive (center) (z : bases × rectangularWeightIndices 0 W 1) + (hz : 0 < (law center).weight z) : + 0 < (translatedSelectedResidueDensityPMF (anchors z.1.val) stride T W hW hZ + (D center) (hD0 center) (hD z.1.val center) (frame z)).toReal := + (selectedAnchoredMixture_pos_iff bases hbase anchors stride T W hW hZ + (D center) (hD0 center) (fun base => hD base center) z).mp hz + have htest (root : sites) (center) (φ : (X → ℝ) → ℝ) + (hφ : ∀ v, φ v ∈ Set.Icc (0 : ℝ) 1) : + (law center).mean (fun z => φ (physicalAffineSite root.val (frame z))) ≤ + 2*(∏ j, earlyConstantDensityCap (Fintype.card (I j)) (n j) (R j) (V j)) * + (𝔼 x ∈ integerBox N, φ (fun i => (x i : ℝ))) + 6*δ := by + obtain ⟨_, _, _, _, _, _, _, _, _, hdom, _⟩ := hfamily root + rw [selectedAnchoredMixture_mean bases hbase anchors stride T W hW hZ + (D center) (hD0 center) (fun base => hD base center) (fun _ z => φ (physicalAffineSite root.val z))] + exact hdom center φ hφ + refine ⟨hsites, hbase, hparent, hZ, hD, hnormal, ?_, ?_, ?_, ?_, ?_, htest, ?_⟩ + · intro center z hz + exact hgeometry z.1.val z.1.property center (frame z) (hpositive center z hz) + · intro center z hz root + exact integerBoxObservation_physical N hparent root.val (frame z) + ((hgeometry z.1.val z.1.property center (frame z) (hpositive center z hz)).2.1 + root.val (layerSamplerIntegerBox_abs_bound B U b scale root.property)) + · intro center + obtain ⟨c, hc, hlift⟩ := hlifts center + refine ⟨c, hc, ?_⟩ + intro z hz + exact hlift z.1.val (frame z) (hpositive center z hz) + · intro center + rw [selectedAnchoredMixture_mean bases hbase anchors stride T W hW hZ + (D center) (hD0 center) (fun base => hD base center) + (fun _ z => noninjectivityIndicator (fun root : sites => integerPhysicalSite root.val z))] + exact Finset.expect_le hbase (fun base _ => hcollision base center) + · intro root φ hφ + obtain ⟨_, _, _, _, _, hmix, _, _, _, _, _⟩ := hfamily root + have hDm (z) : Measurable (fun center => D center z) := + (translatedSelectedPhysicalDensity_measurable_center B U b hb o R σ hR hσ L₀ p hm z).comp + (coefficientConstantCenter_continuous U).measurable + rw [integral_selectedAnchoredMixture_complexMean μ bases hbase anchors stride T W hW hZ D + hDm hD0 hD (fun _ z => φ (physicalAffineSite root.val z)) (fun _ _ => hφ _)] + exact hmix φ hφ + · intro center + have hexcess := FiniteProbabilityWeights.siteLaw_excess_le (law center) point + (FiniteProbabilityWeights.uniformFinset (integerBox N) hparent) (C := + 2*(∏ j, earlyConstantDensityCap (Fintype.card (I j)) (n j) (R j) (V j))) (ε := 6*δ) (by + intro root f hf + have h := htest root center (fun v => f (integerBoxObservation N hparent v)) (fun v => hf _) + rw [integerBoxObservation_mean] at h + exact h) + refine ⟨hexcess, ?_⟩ + have htail := FiniteProbabilityWeights.mass_above_double_cap_le_of_excess _ _ hexcess + have htwice (v : ℝ) : 2*(2*v) = 4*v := by ring + have herror : 2*(6*δ) = 12*δ := by ring + simpa only [FiniteProbabilityWeights.uniformFinset_weight, htwice, herror, div_eq_mul_inv] using htail + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SmoothCoefficientRankBadProduct.lean b/lean/OAI/Combinatorics/Progressions/Linear/SmoothCoefficientRankBadProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c6a0ff1d0ac9f79987c524a46f78be3a53d51d7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SmoothCoefficientRankBadProduct.lean @@ -0,0 +1,160 @@ +import OAI.Combinatorics.Progressions.Lattices.ModularCoefficientBadPrimeProduct + +namespace OAI + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +def scalarCoefficientTupleEquiv {T D V : Type*} {B : T → Type*} [AddCommGroup V] : + ((Σ t, B t × D) → V) ≃+ (∀ t, B t → D → V) where + toFun x t b d := x ⟨t, (b,d)⟩ + invFun c j := c j.1 j.2.1 j.2.2 + left_inv x := by + funext j + rcases j with ⟨t,b,d⟩ + rfl + right_inv c := rfl + map_add' x y := rfl + +variable {T D I : Type*} [Fintype T] [DecidableEq T] + [Fintype D] [DecidableEq D] [Fintype I] [DecidableEq I] + {B : T → Type*} [∀ t, Fintype (B t)] [∀ t, DecidableEq (B t)] + +def scalarCoefficientBad (n : T → ℕ) (S : ∀ t, B t → D → Finset I) + (Q : ∀ t, B t → MvPolynomial I ℤ) (C : ℝ) (M : ℕ) [NeZero M] + (x : (Σ t, B t × D) → ZMod M) : Prop := + ∃ t, ∃ w : B t → ZMod M, (∃ b, IsUnit (w b)) ∧ + (M : ℝ) ^ (-C) < vectorDesignatedRankFailureProbability M (n t) (S t) + (fun b => (Q t b).map (Int.castRingHom (ZMod M))) w + (fun b d => x ⟨t,(b,d)⟩) + +theorem scalarCoefficientBad_probability_eq (n : T → ℕ) + (S : ∀ t, B t → D → Finset I) (Q : ∀ t, B t → MvPolynomial I ℤ) + (C : ℝ) (M : ℕ) [NeZero M] : + (FiniteProbabilityWeights.uniform ((Σ t, B t × D) → ZMod M)).eventProbability + (scalarCoefficientBad n S Q C M) = + (FiniteProbabilityWeights.uniform (∀ t, B t → D → ZMod M)).eventProbability + (fun c => ∃ t, ∃ w : B t → ZMod M, (∃ b, IsUnit (w b)) ∧ + (M : ℝ) ^ (-C) < vectorDesignatedRankFailureProbability M (n t) (S t) + (fun b => (Q t b).map (Int.castRingHom (ZMod M))) w (c t)) := by + classical + let e := scalarCoefficientTupleEquiv (T := T) (B := B) (D := D) (V := ZMod M) + have h := uniform_mean_surjective_hom e.toAddMonoidHom e.surjective + (fun c => @ite ℝ (∃ t, ∃ w : B t → ZMod M, (∃ b, IsUnit (w b)) ∧ + (M : ℝ) ^ (-C) < vectorDesignatedRankFailureProbability M (n t) (S t) + (fun b => (Q t b).map (Int.castRingHom (ZMod M))) w (c t)) (Classical.propDecidable _) 1 0) + exact h + +theorem scalarCoefficientBad_probability {p a s m : ℕ} [NeZero p] + (hp : p.Prime) (ha : 0 < a) + (n : T → ℕ) (hns : ∀ t, n t + 1 ≤ s) (hTs : Fintype.card T ≤ s) + (hBm : ∀ t, Fintype.card (B t) ≤ m) + (S : ∀ t, B t → D → Finset I) (Q : ∀ t, B t → MvPolynomial I ℤ) + (hcard : ∀ t b j, (S t b j).card = n t + 1) + (hdisjoint : ∀ t b, Pairwise (fun j k => Disjoint (S t b j) (S t b k))) + {C : ℝ} (hC : 0 ≤ C) + (hlarge : modularCoefficientPrimeThreshold s ≤ p ^ a) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ Fintype.card D) : + (FiniteProbabilityWeights.uniform ((Σ t, B t × D) → ZMod (p ^ a))).eventProbability + (scalarCoefficientBad n S Q C (p ^ a)) ≤ 1 / ((p ^ a : ℕ) : ℝ) ^ 10 := by + rw [scalarCoefficientBad_probability_eq] + have h := taggedVectorDesignatedRank_exceptional_probability hp ha n hns hTs hBm S + (fun t b => (Q t b).map (Int.castRingHom (ZMod (p ^ a)))) hcard hdisjoint hC + (modularCoefficientPrimeThreshold_le_primePower hlarge) hJ + simpa only [Nat.cast_pow, primePower_rpow_neg_ten] using h + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +open FiniteProbabilityWeights MvPolynomial + +private theorem uniform_eventProbability_instances (X : Type*) (f g : Fintype X) + [Nonempty X] (E : X → Prop) : + @eventProbability X f (@uniform X f _) E = + @eventProbability X g (@uniform X g _) E := by + cases Subsingleton.elim f g + rfl + +variable {T D I : Type*} [Fintype T] [DecidableEq T] + [Fintype D] [DecidableEq D] [Fintype I] [DecidableEq I] + {B : T → Type*} [∀ t, Fintype (B t)] [∀ t, DecidableEq (B t)] + +def smoothCoefficientRankBad (P : Finset ℕ) [∀ p : P, NeZero p.val] + (n : T → ℕ) (S : ∀ t, B t → D → Finset I) + (Q : ∀ t, B t → MvPolynomial I ℤ) (C : ℝ) : + ℕ → ℕ → ((Σ t, B t × D) → ℤ) → Prop := + smoothResiduePrimeBad P (fun p a => scalarCoefficientBad n S Q C (p.val ^ a)) + +theorem smoothCoefficientRank_bad_product_probability + (center width : (Σ t, B t × D) → ℝ) (hwidth : ∀ j, 0 < width j) + (hZ : 0 < shiftedSmoothProductMass center width) + (P : Finset ℕ) (A : ℕ → ℕ) [∀ p : P, NeZero p.val] + (hprime : ∀ p ∈ P, p.Prime) {s m Qbound R : ℕ} + (hQ : 1 ≤ Qbound) (hR : 0 < R) (hdepth : ∀ p ∈ P, p ^ A p ≤ Qbound) + (n : T → ℕ) (hns : ∀ t, n t + 1 ≤ s) (hTs : Fintype.card T ≤ s) + (hBm : ∀ t, Fintype.card (B t) ≤ m) + (S : ∀ t, B t → D → Finset I) (Q : ∀ t, B t → MvPolynomial I ℤ) + (hcard : ∀ t b j, (S t b j).card = n t + 1) + (hdisjoint : ∀ t b, Pairwise (fun j k => Disjoint (S t b j) (S t b k))) + {C : ℝ} (hC : 0 ≤ C) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ Fintype.card D) + (hlarge : ∀ j, 8 * (probabilityProfileLipschitz : ℝ) * + (max Qbound (R ^ 2) : ℕ) ≤ width j) + {η : ℝ} (hη : 0 ≤ η) + (herror : (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * + (max Qbound (R ^ 2) : ℕ) / width j) ≤ η) : + (shiftedSmoothProductFiniteWeights center width hwidth hZ).eventProbability + (fun x => smallPrimePowerCorrection (modularCoefficientPrimeThreshold s) * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => smoothCoefficientRankBad P n S Q C p a x.val) p x) ≤ + 2 / (9 * (R : ℝ) ^ 9) + ((Qbound : ℝ) + (R : ℝ) ^ 2) * η := by + apply smoothResidue_badPrimeProduct_probability center width hwidth hZ P A + (fun p a => scalarCoefficientBad n S Q C (p.val ^ a)) hprime + (modularCoefficientPrimeThreshold_two_le s) hQ hR hdepth + ?_ hlarge hη herror + intro p a ha _had hlargep + convert scalarCoefficientBad_probability (hprime p p.property) ha n hns hTs hBm + S Q hcard hdisjoint hC hlargep hJ using 1 + exact uniform_eventProbability_instances _ _ _ _ + +theorem exists_early_smoothCoefficientRank_bad_product_cutoff {s m : ℕ} + (n : T → ℕ) (hns : ∀ t, n t + 1 ≤ s) (hTs : Fintype.card T ≤ s) + (hBm : ∀ t, Fintype.card (B t) ≤ m) + (S : ∀ t, B t → D → Finset I) + (hcard : ∀ t b j, (S t b j).card = n t + 1) + (hdisjoint : ∀ t b, Pairwise (fun j k => Disjoint (S t b j) (S t b k))) + {C : ℝ} (hC : 0 ≤ C) + (hJ : ⌈2 * (C + m + 10) / modularRankSmallBallExponent s⌉₊ ≤ Fintype.card D) + {δ : ℝ} (hδ : 0 < δ) : + ∃ R : ℕ, 0 < R ∧ ∀ (Qbound : ℕ) (P : Finset ℕ) (A : ℕ → ℕ) + [∀ p : P, NeZero p.val] (Q : ∀ t, B t → MvPolynomial I ℤ) + (center width : (Σ t, B t × D) → ℝ) (hwidth : ∀ j, 0 < width j) + (hZ : 0 < shiftedSmoothProductMass center width), + 1 ≤ Qbound → (∀ p ∈ P, p.Prime) → (∀ p ∈ P, p ^ A p ≤ Qbound) → + (∀ j, 8 * (probabilityProfileLipschitz : ℝ) * (max Qbound (R ^ 2) : ℕ) ≤ width j) → + (∑ j, 16 * (probabilityProfileLipschitz : ℝ) * (max Qbound (R ^ 2) : ℕ) / width j) ≤ + δ / (2 * ((Qbound : ℝ) + (R : ℝ) ^ 2)) → + (shiftedSmoothProductFiniteWeights center width hwidth hZ).eventProbability + (fun x => smallPrimePowerCorrection (modularCoefficientPrimeThreshold s) * R < + ∏ p ∈ P, p ^ largestTestedBadDepth A + (fun p a x => smoothCoefficientRankBad P n S Q C p a x.val) p x) ≤ δ := by + obtain ⟨R, hR, hradius⟩ := exists_early_badPrime_radius hδ + refine ⟨R, hR, ?_⟩ + intro Qbound P A _ Q center width hwidth hZ hQ hprime hdepth hlarge herror + exact (smoothCoefficientRank_bad_product_probability center width hwidth hZ P A hprime + hQ hR hdepth n hns hTs hBm S Q hcard hdisjoint hC hJ hlarge + (hradius Qbound hQ).1.le herror).trans (hradius Qbound hQ).2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SmoothMatrixBlockBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/SmoothMatrixBlockBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..c84fc24131fa167da1ebd3c8020232140f461e93 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SmoothMatrixBlockBudget.lean @@ -0,0 +1,255 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialThresholdBudget +import OAI.Combinatorics.Progressions.Polynomial.ShiftedSmoothPolynomialSublevel + +namespace OAI + +section + +namespace Erdos3 +open MeasureTheory +open scoped BigOperators Classical + +private theorem matrixBlock_decide_eq_classical (p : Prop) [d : Decidable p] : + @decide p d = @decide p (Classical.propDecidable p) := by + cases Subsingleton.elim d (Classical.propDecidable p) + rfl + +theorem smoothMatrixBlock_bad_probability {n N : ℕ} (hn : 0 < n) (hN : 0 < N) + {T : Type*} [Fintype T] (entry : T → (Fin n × Fin n ↪ Fin N)) + (a S : Fin N → ℝ) (hS : ∀ i, 0 < S i) (hZ : 0 < shiftedSmoothProductMass a S) + (hlarge : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ S i) + {δ η : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hη : 0 < η) (hmesh : ∀ i, 1 / S i ≤ δ) + (hsmall : embeddedMatrixDeterminantLip n N * δ ≤ + shiftedSmoothSublevelThreshold N n (Fintype.card T) η) : + ((shiftedSmoothProductPMF a S hS hZ).map (fun k => decide + (∃ t, |Matrix.det (fun i j : Fin n => rectangularLatticePoint a S k (entry t (i,j)))| ≤ + shiftedSmoothSublevelThreshold N n (Fintype.card T) η)) true).toReal ≤ η / 2 := by + have h := shiftedSmoothProduct_polynomial_family_threshold hN hn a S hS hZ hlarge + hδ hδ1 hη hmesh (fun t => embeddedMatrixDeterminantPolynomial (entry t)) + (fun t => embeddedMatrixDeterminantPolynomial_degree (entry t)) + (embeddedMatrixDeterminantLip n N) (embeddedMatrixDeterminantLip_nonneg n N) + (fun t => embeddedMatrixDeterminantPolynomial_lipschitz (entry t)) + (fun t => embeddedMatrixIdentityPoint (entry t)) + (fun t => embeddedMatrixIdentityPoint_bound (entry t)) + (fun t => by rw [embeddedMatrixDeterminantPolynomial_identity]; norm_num) hsmall + simpa only [embeddedMatrixDeterminantPolynomial_eval, matrixBlock_decide_eq_classical] using h + +theorem smoothMatrixBlock_threshold_log_inv {N : ℕ} (hN : 0 < N) (n count : ℕ) + {η : ℝ} (hη : 0 < η) : + Real.log (shiftedSmoothSublevelThreshold N n count η)⁻¹ = + Real.log 2 + Real.log (1 + (n + 1 : ℝ) ^ N) + + (N * n : ℕ) * Real.log (1 + 2 * shiftedSmoothSublevelConstant N n * (count + 1 : ℝ) / η) := + polynomialSublevelThreshold_log_inv _ _ (shiftedSmoothSublevelConstant_nonneg hN n) + (by positivity) hη + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem embeddedMatrixDeterminantLip_le_exp (n N : ℕ) : + embeddedMatrixDeterminantLip n N ≤ + Real.exp ((N : ℝ) + (n : ℝ) ^ 2 + 2 * n) := by + have hN : (N : ℝ) ≤ Real.exp (N : ℝ) := by + linarith [Real.add_one_le_exp (N : ℝ)] + have hn : (n : ℝ) ≤ Real.exp (n : ℝ) := by + linarith [Real.add_one_le_exp (n : ℝ)] + have htwo : (2 : ℝ) ≤ Real.exp 1 := by + linarith [Real.add_one_le_exp (1 : ℝ)] + have hpow : (2 : ℝ) ^ n ≤ Real.exp (n : ℝ) := by + calc + _ ≤ (Real.exp 1) ^ n := pow_le_pow_left₀ (by norm_num) htwo n + _ = _ := by rw [← Real.exp_nat_mul, mul_one] + unfold embeddedMatrixDeterminantLip + calc + _ ≤ Real.exp (N : ℝ) * + (Real.exp ((n : ℝ) ^ 2) * (Real.exp (n : ℝ) * Real.exp (n : ℝ))) := by + gcongr + exact factorial_le_exp_sq n + _ = _ := by + simp only [← Real.exp_add] + congr 1 + ring + +noncomputable def smoothMatrixBlockMesh (n N : ℕ) (κ : ℝ) : ℝ := + min 1 (κ / (embeddedMatrixDeterminantLip n N + 1)) + +theorem smoothMatrixBlockMesh_spec (n N : ℕ) {κ : ℝ} (hκ : 0 < κ) : + 0 < smoothMatrixBlockMesh n N κ ∧ smoothMatrixBlockMesh n N κ ≤ 1 ∧ + embeddedMatrixDeterminantLip n N * smoothMatrixBlockMesh n N κ ≤ κ := by + have hK := embeddedMatrixDeterminantLip_nonneg n N + have hK1 : 0 < embeddedMatrixDeterminantLip n N + 1 := by positivity + have hδ : 0 < smoothMatrixBlockMesh n N κ := + lt_min (by norm_num) (div_pos hκ hK1) + have hmul : smoothMatrixBlockMesh n N κ * (embeddedMatrixDeterminantLip n N + 1) ≤ κ := + (le_div_iff₀ hK1).mp (min_le_right 1 (κ / (embeddedMatrixDeterminantLip n N + 1))) + refine ⟨hδ, min_le_left _ _, ?_⟩ + nlinarith + +theorem smoothMatrixBlockMesh_width_spec (n N : ℕ) {κ S : ℝ} (hκ : 0 < κ) + (hS : max (8 * (probabilityProfileLipschitz : ℝ)) + (smoothMatrixBlockMesh n N κ)⁻¹ ≤ S) : + 0 < S ∧ 8 * (probabilityProfileLipschitz : ℝ) ≤ S ∧ + 1 / S ≤ smoothMatrixBlockMesh n N κ := by + have hδ := (smoothMatrixBlockMesh_spec n N hκ).1 + have hi : (smoothMatrixBlockMesh n N κ)⁻¹ ≤ S := (le_max_right _ _).trans hS + have hS0 : 0 < S := (inv_pos.mpr hδ).trans_le hi + refine ⟨hS0, (le_max_left _ _).trans hS, ?_⟩ + have h := (inv_le_inv₀ hS0 (inv_pos.mpr hδ)).mpr hi + simpa only [inv_inv, one_div] using h + +theorem smoothMatrixBlockMesh_inv_le_exp_of_lip_bound (n N : ℕ) + {κ P Klog : ℝ} (hκ : 0 < κ) (hP : 0 ≤ P) (hKlog : 0 ≤ Klog) + (hκP : κ⁻¹ ≤ Real.exp P) + (hK : embeddedMatrixDeterminantLip n N ≤ Real.exp Klog) : + (smoothMatrixBlockMesh n N κ)⁻¹ ≤ Real.exp (P + Klog + 1) := by + have hK1 : embeddedMatrixDeterminantLip n N + 1 ≤ Real.exp (Klog + 1) := by + simpa only [add_comm] using one_add_le_exp_succ hKlog hK + unfold smoothMatrixBlockMesh + apply inv_min_le_of_inv_le + · simpa only [inv_one] using Real.one_le_exp (by positivity : 0 ≤ P + Klog + 1) + · rw [inv_div, div_eq_mul_inv] + calc + _ ≤ Real.exp (Klog + 1) * Real.exp P := + mul_le_mul hK1 hκP (inv_nonneg.mpr hκ.le) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem smoothMatrixBlockMesh_inv_le_exp (n N : ℕ) {κ P : ℝ} + (hκ : 0 < κ) (hP : 0 ≤ P) (hκP : κ⁻¹ ≤ Real.exp P) : + (smoothMatrixBlockMesh n N κ)⁻¹ ≤ + Real.exp (P + ((N : ℝ) + (n : ℝ) ^ 2 + 2 * n) + 1) := + smoothMatrixBlockMesh_inv_le_exp_of_lip_bound n N hκ hP (by positivity) hκP + (embeddedMatrixDeterminantLip_le_exp n N) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped Classical + +noncomputable def smoothMatrixBlockConstantLogBudget (N n : ℕ) : ℝ := + 5 * (N : ℝ) + (n + 1 : ℝ) + n * (8 + (n + 1 : ℝ)) + +noncomputable def smoothMatrixBlockThresholdLogBudget (N n count : ℕ) (E : ℝ) : ℝ := + (N : ℝ) * n + 2 + ((N * n : ℕ) : ℝ) * + (smoothMatrixBlockConstantLogBudget N n + count + E + 2) + +theorem smoothMatrixBlockConstantLogBudget_nonneg (N n : ℕ) : + 0 ≤ smoothMatrixBlockConstantLogBudget N n := by + unfold smoothMatrixBlockConstantLogBudget + positivity + +theorem smoothMatrixBlockThresholdLogBudget_nonneg (N n count : ℕ) + {E : ℝ} (hE : 0 ≤ E) : 0 ≤ smoothMatrixBlockThresholdLogBudget N n count E := by + unfold smoothMatrixBlockThresholdLogBudget + have := smoothMatrixBlockConstantLogBudget_nonneg N n + positivity + +theorem shiftedSmoothSublevelConstant_le_exp {N n : ℕ} + (hN : 0 < N) (hn : 0 < n) : + shiftedSmoothSublevelConstant N n ≤ Real.exp (smoothMatrixBlockConstantLogBudget N n) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by + linarith [Real.add_one_le_exp (1 : ℝ)] + have hmulti := multivariateSublevelConstant_le_exp N n hn + have hmulti0 := (multivariateSublevelConstant_pos hN n).le + unfold shiftedSmoothSublevelConstant smoothMatrixBlockConstantLogBudget + calc + _ ≤ (Real.exp 1) ^ N * ((Real.exp 1) ^ N * + Real.exp (3 * (N : ℝ) + (n + 1 : ℝ) + n * (8 + (n + 1 : ℝ)))) := by + gcongr + _ = _ := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +theorem smoothMatrixBlock_scale_le_exp (N n : ℕ) : + (n + 1 : ℝ) ^ N ≤ Real.exp ((N : ℝ) * n) := by + have hb : (n + 1 : ℝ) ≤ Real.exp (n : ℝ) := Real.add_one_le_exp _ + calc + _ ≤ (Real.exp (n : ℝ)) ^ N := pow_le_pow_left₀ (by positivity) hb N + _ = _ := (Real.exp_nat_mul (n : ℝ) N).symm + +theorem smoothMatrixBlock_threshold_inverse_le_exp {N n : ℕ} + (hN : 0 < N) (hn : 0 < n) (count : ℕ) + {η E : ℝ} (hη : 0 < η) (hE : 0 ≤ E) (hηb : η⁻¹ ≤ Real.exp E) : + (shiftedSmoothSublevelThreshold N n count η)⁻¹ ≤ + Real.exp (smoothMatrixBlockThresholdLogBudget N n count E) := by + exact polynomialSublevelThreshold_inverse_le_exp (N * n) count + (shiftedSmoothSublevelConstant_nonneg hN n) (by positivity) hη + (smoothMatrixBlockConstantLogBudget_nonneg N n) (by positivity) hE + (shiftedSmoothSublevelConstant_le_exp hN hn) + (smoothMatrixBlock_scale_le_exp N n) hηb + +noncomputable def smoothMatrixBlockMeshLogBudget (N n count : ℕ) (E : ℝ) : ℝ := + smoothMatrixBlockThresholdLogBudget N n count E + + ((N : ℝ) + (n : ℝ) ^ 2 + 2 * n) + 1 + +noncomputable def smoothMatrixBlockWidthLogBudget (N n count : ℕ) (E : ℝ) : ℝ := + smoothMatrixBlockMeshLogBudget N n count E + 8 + probabilityProfileLipschitz + +theorem smoothMatrixBlockMeshLogBudget_nonneg (N n count : ℕ) + {E : ℝ} (hE : 0 ≤ E) : 0 ≤ smoothMatrixBlockMeshLogBudget N n count E := by + unfold smoothMatrixBlockMeshLogBudget + have := smoothMatrixBlockThresholdLogBudget_nonneg N n count hE + positivity + +theorem smoothMatrixBlock_actual_mesh_inverse_le_exp {N n : ℕ} + (hN : 0 < N) (hn : 0 < n) (count : ℕ) + {η E : ℝ} (hη : 0 < η) (hE : 0 ≤ E) (hηb : η⁻¹ ≤ Real.exp E) : + (smoothMatrixBlockMesh n N (shiftedSmoothSublevelThreshold N n count η))⁻¹ ≤ + Real.exp (smoothMatrixBlockMeshLogBudget N n count E) := + smoothMatrixBlockMesh_inv_le_exp n N (shiftedSmoothSublevelThreshold_pos hN n count hη) + (smoothMatrixBlockThresholdLogBudget_nonneg N n count hE) + (smoothMatrixBlock_threshold_inverse_le_exp hN hn count hη hE hηb) + +theorem smoothMatrixBlock_actual_width_le_exp {N n : ℕ} + (hN : 0 < N) (hn : 0 < n) (count : ℕ) + {η E : ℝ} (hη : 0 < η) (hE : 0 ≤ E) (hηb : η⁻¹ ≤ Real.exp E) : + max (8 * (probabilityProfileLipschitz : ℝ)) + (smoothMatrixBlockMesh n N (shiftedSmoothSublevelThreshold N n count η))⁻¹ ≤ + Real.exp (smoothMatrixBlockWidthLogBudget N n count E) := by + have hB := smoothMatrixBlockMeshLogBudget_nonneg N n count hE + have hL : (0 : ℝ) ≤ probabilityProfileLipschitz := NNReal.coe_nonneg _ + apply max_le + · have h8 : (8 : ℝ) ≤ Real.exp 8 := by linarith [Real.add_one_le_exp (8 : ℝ)] + have hLip : (probabilityProfileLipschitz : ℝ) ≤ Real.exp probabilityProfileLipschitz := by + linarith [Real.add_one_le_exp (probabilityProfileLipschitz : ℝ)] + calc + _ ≤ Real.exp 8 * Real.exp probabilityProfileLipschitz := + mul_le_mul h8 hLip hL (Real.exp_pos _).le + _ = Real.exp (8 + probabilityProfileLipschitz) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by unfold smoothMatrixBlockWidthLogBudget; linarith) + · apply (smoothMatrixBlock_actual_mesh_inverse_le_exp hN hn count hη hE hηb).trans + apply Real.exp_le_exp.mpr + unfold smoothMatrixBlockWidthLogBudget + linarith + +theorem smoothMatrixBlock_bad_probability_of_exp_width {n N : ℕ} + (hn : 0 < n) (hN : 0 < N) {T : Type*} [Fintype T] + (entry : T → (Fin n × Fin n ↪ Fin N)) + (a S : Fin N → ℝ) (hS : ∀ i, 0 < S i) + (hZ : 0 < shiftedSmoothProductMass a S) + {η E : ℝ} (hη : 0 < η) (hE : 0 ≤ E) (hηb : η⁻¹ ≤ Real.exp E) + (hwide : ∀ i, Real.exp (smoothMatrixBlockWidthLogBudget N n (Fintype.card T) E) ≤ S i) : + ((shiftedSmoothProductPMF a S hS hZ).map (fun k => decide + (∃ t, |Matrix.det (fun i j : Fin n => rectangularLatticePoint a S k (entry t (i,j)))| ≤ + shiftedSmoothSublevelThreshold N n (Fintype.card T) η)) true).toReal ≤ η / 2 := by + classical + have hκ := shiftedSmoothSublevelThreshold_pos hN n (Fintype.card T) hη + have hδ := smoothMatrixBlockMesh_spec n N hκ + have hwidth (i) := smoothMatrixBlockMesh_width_spec n N hκ + ((smoothMatrixBlock_actual_width_le_exp hN hn (Fintype.card T) hη hE hηb).trans (hwide i)) + exact smoothMatrixBlock_bad_probability hn hN entry a S hS hZ + (fun i => (hwidth i).2.1) hδ.1.le hδ.2.1 hη (fun i => (hwidth i).2.2) hδ.2.2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SmoothPairKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/SmoothPairKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5c75d1a0b9ce5641d4561cbc56c11656ec62dc2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SmoothPairKernel.lean @@ -0,0 +1,63 @@ +import OAI.Combinatorics.Progressions.Probability.AnisotropicSmoothPairLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators NNReal + +noncomputable def smoothPairProductDensity {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) + (H : I → ℝ) (L : ℝ) (hH : ∀ i, 0 < H i) (hL : 0 < L) + (y : I → Fin 2 → ℝ) : ℝ := + ∏ i, affinePairRowDensity t u k hne (H i) L (hH i) hL + (splitSmoothProductProfile {j : J // j ≠ k} (Fin 2)) (y i) + +theorem smoothPairProductDensity_regularity {J I : Type*} + [Fintype J] [DecidableEq J] [Fintype I] + (t u : J → ℤ) (k : J) (hne : u k - t k ≠ 0) + (H : I → ℝ) (L : ℝ) (hH : ∀ i, 0 < H i) (hL : 0 < L) + {C κ : ℝ} (hC : 1 ≤ C) (hκ : 0 < κ) + (ht : |(t k : ℝ) / L| ≤ C) (hu : |(u k : ℝ) / L| ≤ C) + (hgap : κ ≤ |((u k - t k : ℤ) : ℝ) / L|) : + let B : ℝ≥0 := Real.toNNReal (1 + 2 * (4 * C / κ) ^ 2 * 2 ^ Fintype.card {j : J // j ≠ k}) + let K : ℝ≥0 := Real.toNNReal (2 * (4 * C / κ) ^ 3 * (smoothPairRowLipschitz k : ℝ) * + 2 ^ Fintype.card {j : J // j ≠ k}) + (∀ y, |smoothPairProductDensity t u k hne H L hH hL y| ≤ (B : ℝ) ^ Fintype.card I) ∧ + LipschitzWith (Fintype.card I * K * B ^ Fintype.card I) + (smoothPairProductDensity t u k hne H L hH hL) := by + dsimp only + let B : ℝ≥0 := Real.toNNReal (1 + 2 * (4 * C / κ) ^ 2 * 2 ^ Fintype.card {j : J // j ≠ k}) + let K : ℝ≥0 := Real.toNNReal (2 * (4 * C / κ) ^ 3 * (smoothPairRowLipschitz k : ℝ) * + 2 ^ Fintype.card {j : J // j ≠ k}) + have hB : 1 ≤ B := by + apply NNReal.coe_le_coe.mp + dsimp only [B] + rw [Real.coe_toNNReal _ (by positivity)] + simp only [NNReal.coe_one] + exact le_add_of_nonneg_right (by positivity) + have hlip (i : I) : LipschitzWith K (fun y : I → Fin 2 → ℝ => + affinePairRowDensity t u k hne (H i) L (hH i) hL + (splitSmoothProductProfile {j : J // j ≠ k} (Fin 2)) (y i)) := by + have h := smooth_affinePairRowDensity_lipschitz t u k hne (hH i) hL hC hκ ht hu hgap + apply LipschitzWith.of_dist_le_mul + intro x y + exact (h.dist_le_mul (x i) (y i)).trans + (mul_le_mul_of_nonneg_left (dist_le_pi_dist x y i) K.coe_nonneg) + have hcap (i : I) (y : I → Fin 2 → ℝ) : + |affinePairRowDensity t u k hne (H i) L (hH i) hL + (splitSmoothProductProfile {j : J // j ≠ k} (Fin 2)) (y i)| ≤ B := by + have h := smooth_affinePairRowDensity_cap t u k hne (hH i) hL hC hκ ht hu hgap (y i) + dsimp only [B] + rw [Real.coe_toNNReal _ (by positivity)] + linarith + exact bounded_lipschitz_real_prod _ hB hlip hcap + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SmoothSpatialKernelRegularity.lean b/lean/OAI/Combinatorics/Progressions/Linear/SmoothSpatialKernelRegularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..07a410f6b3941576547a6dcd616ded8f169a99d7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SmoothSpatialKernelRegularity.lean @@ -0,0 +1,142 @@ +import OAI.Combinatorics.Progressions.Geometry.SmoothSpatialCostBudget +import OAI.Combinatorics.Progressions.Probability.SmoothSelectedSpatialLaw + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def smoothSpatialOutputLaw {I J N : Type*} + [Fintype I] [Fintype J] [Fintype N] + (root : J → ℤ) (D : Matrix I J ℤ) (C : Matrix (Unit ⊕ I) N ℤ) + (H L : ℝ) (Q : N → ℝ) (hH : 0 < H) (hL : 0 < L) (hQ : ∀ j, 0 < Q j) : + PMF ((Unit ⊕ I) → ℤ) := + smoothMatrixImagePMF (Matrix.fromCols (rootDifferenceMatrix root D) C) + (Sum.elim (spatialPivotScale J H L) Q) + (fun k => Sum.rec (spatialPivotScale_pos J hH hL) hQ k) + +noncomputable def smoothSpatialKernelDensity {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + (s : I ↪ J) (root : J → ℤ) (D : Matrix I J ℤ) + (hA : (selectedSpatialPivot root D s).det ≠ 0) + (H L : ℝ) (hH : 0 < H) (hL : 0 < L) : ((Unit ⊕ I) → ℝ) → ℝ := + normalizedFiberDensity (selectedSpatialPivot root D s) hA (selectedSpatialFreeColumns root D s) + (spatialPivotScale I H L) (fun _ => H) (fun _ => H / L) + (spatialPivotScale_pos I hH hL) (fun _ => hH) (smoothSplitProfile (UnselectedColumn s) (Unit ⊕ I)) + +theorem goodScalarKernelTuple_selected_period {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + {L B : ℕ} {κ : ℝ} (s : I ↪ J) (x : J → IntegerScalarCubeBox I L) + (root : J → ℤ) (hx : GoodScalarKernelTuple s κ B x) : + ∃ m : ℕ, 0 < m ∧ m ≤ B ∧ + integerScalarLattice (Unit ⊕ I) (m : ℤ) ≤ + pivotFullImage (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s) + (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s) := by + obtain ⟨m, hm, hmB, hp⟩ := rootDifferenceMatrix_bounded_period root (scalarCubeDifferenceMatrix x) hx.2 + exact ⟨m, hm, hmB, by rwa [selectedSpatial_full_image]⟩ + +theorem smoothSpatial_original_error {I J N : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype N] [DecidableEq N] + {L B : ℕ} {H ρ ξ : ℝ} + (s : I ↪ J) (x : J → IntegerScalarCubeBox I L) (root : J → ℤ) + (hB : 0 < B) (hL : 0 < L) (hH : 0 < H) + (hx : GoodScalarKernelTuple s (1 / (B : ℝ)) B x) (hroot : ∀ j, |root j| ≤ (L : ℤ)) + (C : Matrix (Unit ⊕ I) N ℤ) (Q : N → ℝ) (hQ : ∀ j, 0 < Q j) + (hξ0 : 0 ≤ ξ) (hξ1 : ξ ≤ 1) (hC : ∀ i j, |(C i j : ℝ)| * Q j ≤ ξ * H) + (hρ : 0 < ρ) (hscale : ρ ≤ H / L) (hscaleQ : ∀ j, ρ ≤ Q j) + (hlarge : smoothSpatialMeshThreshold I J N L ≤ ρ) : + let hA := goodScalarKernelTuple_spatial_det_ne_zero s x root + (one_div_pos.mpr (by exact_mod_cast hB)) hx + ∀ v, |(∏ _i : Unit ⊕ I, H) * + (smoothSpatialOutputLaw root (scalarCubeDifferenceMatrix x) C H L Q hH + (by exact_mod_cast hL) hQ v).toReal - + maskedIntegerImageDensity (selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s) + (Matrix.fromCols (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s) C) + (fun _ => H) (smoothSpatialKernelDensity s root (scalarCubeDifferenceMatrix x) hA + H L hH (by exact_mod_cast hL)) v| ≤ smoothSpatialError N s B L ρ ξ := by + obtain ⟨hsmall, hsmallMass⟩ := smoothSpatial_mesh_conditions s hρ hlarge + have h := (smoothSpatial_probability_comparison s x root hB hL hH hx hroot C Q hQ + hξ0 hξ1 hC hρ hscale hscaleQ hsmall hsmallMass).1 + rw [smoothSelectedSpatial_original_law root (scalarCubeDifferenceMatrix x) s C + hH (by exact_mod_cast hL) Q hQ] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def smoothSpatialDensityCap {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (B : ℕ) : ℝ := + (Fintype.card (Unit ⊕ I)).factorial * + (scalarSpatialInverseAllowance I B)^Fintype.card (Unit ⊕ I) * 2^Fintype.card (UnselectedColumn s) + +noncomputable def smoothSpatialDensityLip {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (B : ℕ) : ℝ := + smoothSpatialDensityCap s B * + ((Fintype.card (UnselectedColumn s) + Fintype.card (Unit ⊕ I) : ℝ) * probabilityProfileLipschitz) * + scalarSpatialInverseAllowance I B + +theorem smoothSpatialDensityCap_nonneg {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (B : ℕ) : 0 ≤ smoothSpatialDensityCap s B := by + unfold smoothSpatialDensityCap scalarSpatialInverseAllowance + positivity + +theorem smoothSpatialDensityLip_nonneg {I J : Type*} [Fintype I] [Fintype J] + (s : I ↪ J) (B : ℕ) : 0 ≤ smoothSpatialDensityLip s B := by + unfold smoothSpatialDensityLip + have h := smoothSpatialDensityCap_nonneg s B + unfold scalarSpatialInverseAllowance + positivity + +theorem smoothSpatialKernelDensity_bounds {I J : Type*} + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] + {L B : ℕ} {H : ℝ} (s : I ↪ J) (x : J → IntegerScalarCubeBox I L) (root : J → ℤ) + (hB : 0 < B) (hL : 0 < L) (hH : 0 < H) + (hx : GoodScalarKernelTuple s (1 / (B : ℝ)) B x) (hroot : ∀ j, |root j| ≤ (L : ℤ)) : + let hA := goodScalarKernelTuple_spatial_det_ne_zero s x root + (one_div_pos.mpr (by exact_mod_cast hB)) hx + let f := smoothSpatialKernelDensity s root (scalarCubeDifferenceMatrix x) hA H L hH (by exact_mod_cast hL) + (∀ y, |f y| ≤ smoothSpatialDensityCap s B) ∧ + LipschitzWith (Real.toNNReal (smoothSpatialDensityLip s B)) f := by + have hBp : (0 : ℝ) < B := by exact_mod_cast hB + have hLp : (0 : ℝ) < L := by exact_mod_cast hL + let A := selectedSpatialPivot root (scalarCubeDifferenceMatrix x) s + have hA : A.det ≠ 0 := goodScalarKernelTuple_spatial_det_ne_zero s x root (one_div_pos.mpr hBp) hx + let E := normalizedPivotEquiv A hA (spatialPivotScale I H L) (fun _ => H) + (spatialPivotScale_pos I hH hLp) (fun _ => hH) + have hi : ‖E.symm.toContinuousLinearMap‖ ≤ scalarSpatialInverseAllowance I B := by + simpa only [E, A, scalarSpatialInverseAllowance, one_div, div_inv_eq_mul] using + scalarSpatialPivot_inverse_bound s x root (one_div_pos.mpr hBp) hx hH hL hroot + constructor + · intro y + have h := pivotOutputDensity_abs_le_uniform E + (matrixSupCLM (normalizedIntegerColumns (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s) + (fun _ => H / L) (fun _ => H))) (smoothSplitProfile (UnselectedColumn s) (Unit ⊕ I)) + zero_le_one zero_le_one (smoothSplitProfile_zero_outside _ _) (smoothSplitProfile_norm_le _ _) hi y + simpa only [smoothSpatialKernelDensity, normalizedFiberDensity, smoothSpatialDensityCap, + E, A, mul_one] using h + · apply LipschitzWith.of_dist_le_mul + intro v w + rw [Real.dist_eq, Real.coe_toNNReal _ (smoothSpatialDensityLip_nonneg s B)] + have h := pivotOutputDensity_output_bound_uniform E + (matrixSupCLM (normalizedIntegerColumns (selectedSpatialFreeColumns root (scalarCubeDifferenceMatrix x) s) + (fun _ => H / L) (fun _ => H))) (smoothSplitProfile_lipschitz (UnselectedColumn s) (Unit ⊕ I)) + zero_le_one (smoothSplitProfile_zero_outside _ _) hi v w + simpa only [smoothSpatialKernelDensity, normalizedFiberDensity, smoothSpatialDensityLip, + smoothSpatialDensityCap, E, A, mul_one, NNReal.coe_mul, NNReal.coe_add, NNReal.coe_natCast, + dist_eq_norm, mul_assoc] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SortedBasisTriangular.lean b/lean/OAI/Combinatorics/Progressions/Linear/SortedBasisTriangular.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cb2b628a4cb2454edbd1fba67e33ff01ab5ff70 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SortedBasisTriangular.lean @@ -0,0 +1,99 @@ +import Mathlib.LinearAlgebra.Matrix.ToLin +import OAI.Combinatorics.Progressions.Sampling.RationalSpanGrid + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem basis_reindex_equivFun {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] [Fintype ι] + (b : Basis ι K E) (e : Equiv.Perm ι) (x : E) : + (b.reindex e.symm).equivFun x = fun i => b.equivFun x (e i) := by + funext i + simp only [Basis.equivFun_apply, Basis.repr_reindex_apply, Equiv.symm_symm] + +theorem basis_reindex_toMatrix {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] [Fintype ι] [DecidableEq ι] + (b : Basis ι K E) (e : Equiv.Perm ι) (f : E →ₗ[K] E) (i j : ι) : + LinearMap.toMatrix (b.reindex e.symm) (b.reindex e.symm) f i j = + LinearMap.toMatrix b b f (e i) (e j) := by + simp only [LinearMap.toMatrix_apply, Basis.repr_reindex_apply, Basis.reindex_apply, + Equiv.symm_symm] + +theorem basis_coordinate_linearEquiv_matrix {K E ι : Type*} [Field K] + [AddCommGroup E] [Module K E] [Fintype ι] [DecidableEq ι] + (b : Basis ι K E) (f : E ≃ₗ[K] E) : + LinearMap.toMatrix' (b.equivFun.symm.trans (f.trans b.equivFun)).toLinearMap = + LinearMap.toMatrix b b f.toLinearMap := by + ext i j + rw [LinearMap.toMatrix'_apply, LinearMap.toMatrix_apply] + change b.equivFun (f (b.equivFun.symm (Pi.single j 1))) i = b.repr (f (b j)) i + have he : b.equivFun.symm (Pi.single j 1) = b j := by + apply b.equivFun.injective + simp only [b.equivFun.apply_symm_apply] + funext i + simp [Basis.equivFun_self, Pi.single_apply, eq_comm] + rw [he, Basis.equivFun_apply] + +theorem realDenominatorGrid_comp {ι κ : Type*} (l : ℕ) (x : ι → ℝ) + (hx : x ∈ realDenominatorGrid l) (e : κ → ι) : + (x ∘ e) ∈ realDenominatorGrid l := by + obtain ⟨z, hz⟩ := hx + refine ⟨z ∘ e, ?_⟩ + funext i + exact congrFun hz (e i) + +theorem basis_reindex_grid {E ι : Type*} [AddCommGroup E] [Module ℝ E] [Fintype ι] + (b : Basis ι ℝ E) (e : Equiv.Perm ι) (l : ℕ) (x : E) + (hx : b.equivFun x ∈ realDenominatorGrid l) : + (b.reindex e.symm).equivFun x ∈ realDenominatorGrid l := by + rw [basis_reindex_equivFun] + exact realDenominatorGrid_comp l (b.equivFun x) hx e + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem sorted_basis_upper_zero {K E : Type*} [Field K] + [AddCommGroup E] [Module K E] {d : ℕ} + (b : Basis (Fin d) K E) (w : Fin d → ℕ) (f : E →ₗ[K] E) + (hf : ∀ i j, w i ≤ w j → LinearMap.toMatrix b b f i j = (1 : Matrix (Fin d) (Fin d) K) i j) + (e : Equiv.Perm (Fin d)) (hm : Monotone (w ∘ e)) (i j : Fin d) (hij : i < j) : + LinearMap.toMatrix (b.reindex e.symm) (b.reindex e.symm) f i j = 0 := by + rw [basis_reindex_toMatrix, hf _ _ (hm hij.le)] + simp only [Matrix.one_apply, e.injective.eq_iff, ite_eq_right (ne_of_lt hij)] + +theorem sorted_basis_diagonal_one {K E : Type*} [Field K] + [AddCommGroup E] [Module K E] {d : ℕ} + (b : Basis (Fin d) K E) (w : Fin d → ℕ) (f : E →ₗ[K] E) + (hf : ∀ i j, w i ≤ w j → LinearMap.toMatrix b b f i j = (1 : Matrix (Fin d) (Fin d) K) i j) + (e : Equiv.Perm (Fin d)) (i : Fin d) : + LinearMap.toMatrix (b.reindex e.symm) (b.reindex e.symm) f i i = 1 := by + rw [basis_reindex_toMatrix, hf _ _ le_rfl, Matrix.one_apply_eq] + +theorem sorted_basis_initial_identity {K E : Type*} [Field K] + [AddCommGroup E] [Module K E] {d a : ℕ} + (b : Basis (Fin d) K E) (w : Fin d → ℕ) (f : E →ₗ[K] E) + (hf : ∀ i j, w i ≤ w j → LinearMap.toMatrix b b f i j = (1 : Matrix (Fin d) (Fin d) K) i j) + (e : Equiv.Perm (Fin d)) (hfirst : ∀ i, i.val < a → w (e i) = 1) + (i j : Fin d) (hi : i.val < a) (hj : j.val < a) : + LinearMap.toMatrix (b.reindex e.symm) (b.reindex e.symm) f i j = + (1 : Matrix (Fin d) (Fin d) K) i j := by + rw [basis_reindex_toMatrix, hf _ _ (by rw [hfirst i hi, hfirst j hj])] + simp only [Matrix.one_apply, e.injective.eq_iff] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SpanKernelGenerators.lean b/lean/OAI/Combinatorics/Progressions/Linear/SpanKernelGenerators.lean new file mode 100644 index 0000000000000000000000000000000000000000..16551f891558f427f1d4ecb10551d9905957741e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SpanKernelGenerators.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.Progressions.Geometry.LinearMapCoordinateHeight + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Matrix + +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + +theorem range_kernel_projection (A : Matrix ι κ ℚ) (S : Matrix κ ι ℚ) + (hS : A * S = 1) : + LinearMap.range (1 - S * A).mulVecLin = LinearMap.ker A.mulVecLin := by + have hzero : A * (1 - S * A) = 0 := by + rw [Matrix.mul_sub, Matrix.mul_one, ← Matrix.mul_assoc, hS, Matrix.one_mul, sub_self] + ext y + constructor + · rintro ⟨x, rfl⟩ + change A *ᵥ ((1 - S * A) *ᵥ x) = 0 + rw [Matrix.mulVec_mulVec, hzero, Matrix.zero_mulVec] + · intro hy + change A *ᵥ y = 0 at hy + refine ⟨y, ?_⟩ + change (1 - S * A) *ᵥ y = y + rw [Matrix.sub_mulVec, Matrix.one_mulVec, ← Matrix.mulVec_mulVec, + hy, Matrix.mulVec_zero, sub_zero] + +def rationalKernelHeight (r H : ℕ) : ℕ := + 2 * (r + 1) * (rationalSolveHeight r H * H) ^ r + +omit [DecidableEq ι] in +theorem exists_bounded_kernel_projection (A : Matrix ι κ ℚ) {H : ℕ} + (hH : 1 ≤ H) (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ ∃ P : Matrix κ κ ℚ, + LinearMap.range P.mulVecLin = LinearMap.ker A.mulVecLin ∧ + ∀ i j, RationalHeightLE (P i j) (rationalKernelHeight r H) := by + obtain ⟨r, hr, rows, _, hsurj, hker⟩ := exists_independent_defining_rows A + let R := A.submatrix rows id + obtain ⟨S, hS, hSH⟩ := exists_bounded_rational_section R hsurj hH + (fun i j => hA (rows i) j) + refine ⟨r, hr, 1 - S * R, (range_kernel_projection R S hS).trans hker, ?_⟩ + intro i j + have hI : RationalHeightLE ((1 : Matrix κ κ ℚ) i j) 1 := by + by_cases hij : i = j + · simpa [Matrix.one_apply, hij] using rationalHeightLE_one (by decide : 1 ≤ 1) + · simpa [Matrix.one_apply, hij] using rationalHeightLE_zero (by decide : 1 ≤ 1) + have hprod := rationalHeightLE_matrix_mul S R hSH (fun i j => hA (rows i) j) i j + have hout := hI.sub hprod + simpa only [Matrix.sub_apply, Fintype.card_fin, rationalKernelHeight, mul_one, + mul_assoc] using hout + +omit [DecidableEq ι] in + +theorem exists_bounded_rational_kernel_family (A : Matrix ι κ ℚ) {H : ℕ} + (hH : 1 ≤ H) (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ v : Fin (Module.finrank ℚ (LinearMap.ker A.mulVecLin)) → (κ → ℚ), + LinearIndependent ℚ v ∧ Submodule.span ℚ (Set.range v) = LinearMap.ker A.mulVecLin ∧ + ∀ i j, RationalHeightLE (v i j) (rationalKernelHeight r H) := by + obtain ⟨r, hr, P, hP, hPH⟩ := exists_bounded_kernel_projection A hH hA + have hspan : Submodule.span ℚ (Set.range P.col) = LinearMap.ker A.mulVecLin := by + rw [← Matrix.range_mulVecLin, hP] + have hex := Submodule.exists_fun_fin_finrank_span_eq ℚ (Set.range P.col) + rw [hspan] at hex + obtain ⟨v, hv, hvspan, hli⟩ := hex + refine ⟨r, hr, v, hli, hvspan, ?_⟩ + intro i j + obtain ⟨k, hk⟩ := hv i + rw [← hk] + exact hPH j k + +omit [DecidableEq ι] in + +theorem exists_bounded_rational_kernel_basis (A : Matrix ι κ ℚ) {H : ℕ} + (hH : 1 ≤ H) (hA : ∀ i j, RationalHeightLE (A i j) H) : + ∃ r : ℕ, r ≤ Fintype.card ι ∧ + ∃ b : Module.Basis (Fin (Module.finrank ℚ (LinearMap.ker A.mulVecLin))) + ℚ (LinearMap.ker A.mulVecLin), + ∀ i j, RationalHeightLE ((b i : κ → ℚ) j) (rationalKernelHeight r H) := by + obtain ⟨r, hr, v, hli, hspan, hv⟩ := exists_bounded_rational_kernel_family A hH hA + refine ⟨r, hr, (Module.Basis.span hli).map (LinearEquiv.ofEq _ _ hspan), ?_⟩ + intro i j + simpa only [Module.Basis.map_apply, LinearEquiv.coe_ofEq_apply, + Module.Basis.coe_span_apply] using hv i j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {K V W κ : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] [Fintype κ] + +noncomputable def finiteCombination (v : κ → V) : (κ → K) →ₗ[K] V := + (Pi.basisFun K κ).constr K v + +theorem finiteCombination_apply (v : κ → V) (x : κ → K) : + finiteCombination v x = ∑ i, x i • v i := by + classical + rw [finiteCombination, Basis.constr_apply_fintype] + rfl + +theorem finiteCombination_basis (v : κ → V) (i : κ) : + finiteCombination v (Pi.basisFun K κ i) = v i := + Basis.constr_basis (Pi.basisFun K κ) K v i + +theorem finiteCombination_range (v : κ → V) : + LinearMap.range (finiteCombination (K := K) v) = Submodule.span K (Set.range v) := + Basis.constr_range (Pi.basisFun K κ) K + +theorem finiteCombination_kernel_image (v : κ → V) (P : V →ₗ[K] W) : + (LinearMap.ker (P.comp (finiteCombination v))).map (finiteCombination v) = + Submodule.span K (Set.range v) ⊓ LinearMap.ker P := by + ext y + constructor + · rintro ⟨x, hx, rfl⟩ + exact ⟨(finiteCombination_range v).le ⟨x, rfl⟩, hx⟩ + · rintro ⟨hy, hP⟩ + obtain ⟨x, rfl⟩ := (finiteCombination_range v).ge hy + exact ⟨x, hP, rfl⟩ + +section Rational + +variable {V W ι η κ : Type*} [AddCommGroup V] [Module ℚ V] + [AddCommGroup W] [Module ℚ W] [Fintype κ] [Fintype η] + +theorem finiteCombination_constraint_kernel (f : Basis η ℚ W) (P : V →ₗ[ℚ] W) + (v : κ → V) : + LinearMap.ker (Matrix.mulVecLin (show Matrix η κ ℚ from fun i j => f.repr (P (v j)) i)) = + LinearMap.ker (P.comp (finiteCombination v)) := by + classical + ext x + have he : (show Matrix η κ ℚ from fun i j => f.repr (P (v j)) i) *ᵥ x = + f.equivFun (P (finiteCombination v x)) := by + ext i + simp only [finiteCombination_apply, map_sum, map_smul, Basis.equivFun_apply, + Finset.sum_apply, Pi.smul_apply, smul_eq_mul, Matrix.mulVec, dotProduct] + apply Finset.sum_congr rfl + intro j _ + exact mul_comm _ _ + change (show Matrix η κ ℚ from fun i j => f.repr (P (v j)) i) *ᵥ x = 0 ↔ + P (finiteCombination v x) = 0 + rw [he, LinearEquiv.map_eq_zero_iff] + +theorem exists_bounded_span_kernel_generators (e : Basis ι ℚ V) (f : Basis η ℚ W) + (P : V →ₗ[ℚ] W) (v : κ → V) {H B : ℕ} (hB : 1 ≤ B) + (hv : ∀ i j, RationalHeightLE (e.repr (v i) j) H) + (hPv : ∀ i j, RationalHeightLE (f.repr (P (v i)) j) B) : + ∃ r : ℕ, r ≤ Fintype.card η ∧ ∃ z : κ → V, + Submodule.span ℚ (Set.range z) = Submodule.span ℚ (Set.range v) ⊓ LinearMap.ker P ∧ + ∀ i j, RationalHeightLE (e.repr (z i) j) + ((Fintype.card κ + 1) * (rationalKernelHeight r B * H) ^ Fintype.card κ) := by + classical + let A : Matrix η κ ℚ := fun i j => f.repr (P (v j)) i + obtain ⟨r, hr, Q, hQ, hQH⟩ := exists_bounded_kernel_projection A hB (fun i j => hPv j i) + refine ⟨r, hr, fun i => finiteCombination v (Q.col i), ?_, ?_⟩ + · rw [← finiteCombination_kernel_image v P, ← finiteCombination_constraint_kernel f P v, + ← hQ, Matrix.range_mulVecLin, Submodule.map_span, ← Set.range_comp] + rfl + · intro i j + exact linearMap_coordinate_height (Pi.basisFun ℚ κ) e (finiteCombination v) + (by intro a b; rw [finiteCombination_basis]; exact hv a b) + (Q.col i) (fun a => hQH a i) j + +end Rational +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SpanSubsetBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/SpanSubsetBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..fec052d320a7f70feec33b5de96f7e5d9c50b78d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SpanSubsetBasis.lean @@ -0,0 +1,37 @@ +import Mathlib.Basic.Real.Basic +import Mathlib.LinearAlgebra.Basis.Submodule +import Mathlib.LinearAlgebra.FiniteDimensional.Basic + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem exists_basis_of_span_subset {E : Type*} [AddCommGroup E] [Module ℝ E] + [FiniteDimensional ℝ E] (S : Set E) : + ∃ d : ℕ, ∃ b : Basis (Fin d) ℝ (Submodule.span ℝ S), + d = finrank ℝ (Submodule.span ℝ S) ∧ ∀ i, (b i).val ∈ S := by + classical + obtain ⟨s, hs, hspan, hli⟩ := exists_linearIndependent ℝ S + let : Fintype s := hli.setFinite.fintype + have he : Submodule.span ℝ (Set.range ((↑) : s → E)) = Submodule.span ℝ S := by + simpa only [Subtype.range_coe_subtype, Set.ofPred_mem_eq] using hspan + let b₀ : Basis s ℝ (Submodule.span ℝ S) := (Basis.span hli).map (LinearEquiv.ofEq _ _ he) + let b := b₀.reindex (Fintype.equivFin s) + refine ⟨Fintype.card s, b, ?_, ?_⟩ + · simpa only [Fintype.card_fin] using (finrank_eq_card_basis b).symm + intro i + have hb : (b i).val = ((Fintype.equivFin s).symm i).val := by + simp only [b, Basis.reindex_apply, b₀, Basis.map_apply] + exact Basis.coe_span_apply hli _ + rw [hb] + exact hs ((Fintype.equivFin s).symm i).property + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SpanningFlagSelection.lean b/lean/OAI/Combinatorics/Progressions/Linear/SpanningFlagSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..06d64f4f9ab95c8a2580375fd0207ae0d7da40c8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SpanningFlagSelection.lean @@ -0,0 +1,72 @@ +import Mathlib.LinearAlgebra.Basis.VectorSpace +import Mathlib.LinearAlgebra.FiniteDimensional.Basic + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +theorem exists_nested_independent_spanning_sets (n : ℕ) : + ∀ (P : Fin n → Submodule K V) (S : Set V), Antitone P → + (∀ i, Submodule.span K (S ∩ (P i : Set V)) = P i) → + ∃ B : Set V, B ⊆ S ∧ LinearIndepOn K id B ∧ + Submodule.span K B = Submodule.span K S ∧ + ∃ T : Fin n → Set V, Antitone T ∧ (∀ i, T i ⊆ B) ∧ + ∀ i, Submodule.span K (T i) = P i := by + induction n with + | zero => + intro P S _ _ + let h := linearIndepOn_empty K (id : V → V) + let hsub : (∅ : Set V) ⊆ S := Set.empty_subset S + refine ⟨h.extend hsub, h.extend_subset hsub, h.linearIndepOn_extend hsub, + h.span_extend_eq_span hsub, Fin.elim0, ?_, ?_, ?_⟩ + · intro i + exact Fin.elim0 i + · intro i + exact Fin.elim0 i + · intro i + exact Fin.elim0 i + | succ n ih => + intro P S hP hspan + let S₀ := S ∩ (P 0 : Set V) + let P' : Fin n → Submodule K V := fun i => P i.succ + have hP' : Antitone P' := fun i j hij => hP (by simpa using hij) + have hspan' (i : Fin n) : Submodule.span K (S₀ ∩ (P' i : Set V)) = P' i := by + have heq : S₀ ∩ (P' i : Set V) = S ∩ (P i.succ : Set V) := by + ext x + constructor + · exact fun hx => ⟨hx.1.1, hx.2⟩ + · exact fun hx => ⟨⟨hx.1, hP (Fin.zero_le i.succ) hx.2⟩, hx.2⟩ + rw [heq] + exact hspan i.succ + obtain ⟨B₀, hB₀, hiB₀, hspB₀, T₀, hT₀, hTB₀, hspT₀⟩ := ih P' S₀ hP' hspan' + have hBS : B₀ ⊆ S := fun _ hx => (hB₀ hx).1 + let B := hiB₀.extend hBS + have hB₀B : B₀ ⊆ B := hiB₀.subset_extend hBS + let T : Fin (n + 1) → Set V := Fin.cases B₀ T₀ + refine ⟨B, hiB₀.extend_subset hBS, hiB₀.linearIndepOn_extend hBS, + hiB₀.span_extend_eq_span hBS, T, ?_, ?_, ?_⟩ + · intro i j hij + obtain rfl | ⟨i, rfl⟩ := i.eq_zero_or_eq_succ + · obtain rfl | ⟨j, rfl⟩ := j.eq_zero_or_eq_succ + · exact Set.Subset.rfl + · exact hTB₀ j + · obtain rfl | ⟨j, rfl⟩ := j.eq_zero_or_eq_succ + · exact False.elim ((not_le_of_gt (Fin.succ_pos i)) hij) + · exact hT₀ (by simpa using hij) + · intro i + exact Fin.cases hB₀B (fun j => (hTB₀ j).trans hB₀B) i + · intro i + refine Fin.cases ?_ (fun j => hspT₀ j) i + exact hspB₀.trans (hspan 0) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SpatialFrameSlopeBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/SpatialFrameSlopeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1f1e9d1f3a9f9b30585eba18689bcff2d2f87b0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SpatialFrameSlopeBudget.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Geometry.AllocatedSpatialProxyCap + +namespace OAI + +section + +namespace Erdos3 +open scoped BigOperators + +variable {G J X : Type*} [Fintype G] [Fintype J] [Fintype X] + +theorem narrowSpatial_frame_slope_bound + {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : ξ ≤ 1) + (N : X → ℕ) (hN : ∀ x, 0 < N x) + (v : Option (G ⊕ J) × X → ℤ) + (hv : v ∈ rectangularWeightIndices 0 (narrowTrimmedSpatialWidths W τ ξ N) 1) + (k : G ⊕ J) (x : X) : + |(v (some k, x) : ℝ)| ≤ τ * (N x : ℝ) / (8 * (1 + W)) := by + have h := (rectangularWeightIndices_zero_bound _ hv (some k, x)).trans + (narrowTrimmedSpatialWidths_le hW hτ hξ N hN (some k, x)) + simpa only [trimmedSpatialWidths, centeredSpatialWidths, one_mul, mul_div_assoc] using h + +theorem narrowSpatial_frame_slope_sum + {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : ξ ≤ 1) + (N : X → ℕ) (hN : ∀ x, 0 < N x) + (T : G ⊕ J → ℝ) (hT : ∀ k, 0 ≤ T k) (hsum : ∑ k, T k ≤ W) + (v : Option (G ⊕ J) × X → ℤ) + (hv : v ∈ rectangularWeightIndices 0 (narrowTrimmedSpatialWidths W τ ξ N) 1) + (x : X) : + (∑ k, |(v (some k, x) : ℝ)| * T k) ≤ τ * (N x : ℝ) / 8 := by + have hden : 0 < 8 * (1 + W) := by positivity + have hcoef : 0 ≤ τ * (N x : ℝ) / (8 * (1 + W)) := by positivity + calc + _ ≤ ∑ k, (τ * (N x : ℝ) / (8 * (1 + W))) * T k := + Finset.sum_le_sum (fun k _ => mul_le_mul_of_nonneg_right + (narrowSpatial_frame_slope_bound hW hτ hξ N hN v hv k x) (hT k)) + _ = (τ * (N x : ℝ) / (8 * (1 + W))) * ∑ k, T k := + (Finset.mul_sum _ _ _).symm + _ ≤ (τ * (N x : ℝ) / (8 * (1 + W))) * (1 + W) := + mul_le_mul_of_nonneg_left (hsum.trans (by linarith)) hcoef + _ = τ * (N x : ℝ) / 8 := by + have hw : 1 + W ≠ 0 := by positivity + field_simp + +theorem narrowSpatial_frame_normalized_slope_sum + {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : ξ ≤ 1) + (N : X → ℕ) (hN : ∀ x, 0 < N x) + (T : G ⊕ J → ℝ) (hT : ∀ k, 0 ≤ T k) (hsum : ∑ k, T k ≤ W) + (v : Option (G ⊕ J) × X → ℤ) + (hv : v ∈ rectangularWeightIndices 0 (narrowTrimmedSpatialWidths W τ ξ N) 1) + (x : X) : + (∑ k, |(v (some k, x) : ℝ) / (N x : ℝ)| * T k) ≤ τ / 8 := by + have hn : (0 : ℝ) < N x := by exact_mod_cast hN x + have h := narrowSpatial_frame_slope_sum hW hτ hξ N hN T hT hsum v hv x + have hd : (∑ k, |(v (some k, x) : ℝ)| * T k) / (N x : ℝ) ≤ τ / 8 := by + apply (div_le_iff₀ hn).mpr + nlinarith + calc + _ = (∑ k, |(v (some k, x) : ℝ)| * T k) / (N x : ℝ) := by + simp only [abs_div, abs_of_pos hn, div_mul_eq_mul_div, Finset.sum_div] + _ ≤ τ / 8 := hd + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SpatialMatrixBlockWideProbability.lean b/lean/OAI/Combinatorics/Progressions/Linear/SpatialMatrixBlockWideProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..c008eb4a2c158548c12d842d649ebb3050495b21 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SpatialMatrixBlockWideProbability.lean @@ -0,0 +1,825 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankCongruenceOutput +import OAI.Combinatorics.Progressions.Linear.SmoothMatrixBlockBudget + +namespace OAI + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +noncomputable def spatialRankExponent {K : Type*} : Option K → K →₀ ℕ + | none => 0 + | some k => Finsupp.single k 1 + +noncomputable def spatialRankPolynomial {K R : Type*} [Fintype K] [CommRing R] + (c : Option K → R) : MvPolynomial K R := + ∑ e, monomial (spatialRankExponent e) (c e) + +theorem spatialRankPolynomial_degree {K R : Type*} [Fintype K] [CommRing R] + (c : Option K → R) : (spatialRankPolynomial c).totalDegree ≤ 1 := by + unfold spatialRankPolynomial + apply totalDegree_finsetSum_le + intro e _ + apply (totalDegree_monomial_le _ _).trans + cases e <;> simp [spatialRankExponent] + +theorem spatialRankPolynomial_eq {K R : Type*} [Fintype K] [CommRing R] + (c : Option K → R) : + spatialRankPolynomial c = C (c none) + ∑ k, C (c (some k)) * X k := by + rw [spatialRankPolynomial, Fintype.sum_option] + simp only [spatialRankExponent, monomial_zero', C_mul_X_eq_monomial] + +theorem spatialRankPolynomial_actual_eval {K X : Type*} [Fintype K] + (base : X → ℤ) (noise : Option K × X → ℤ) (x : X) (t : K → ℤ) : + MvPolynomial.eval t (C (base x) + spatialRankPolynomial (fun e => noise (e,x))) = + BooleanCubeKernel.jointIntegerPhysicalSite t (base, noise) x := by + rw [spatialRankPolynomial_eq] + simp only [map_add, eval_C, map_sum, map_mul, eval_X] + simp only [BooleanCubeKernel.jointIntegerPhysicalSite, Pi.add_apply, + BooleanCubeKernel.integerPhysicalSite] + congr 1 + simp only [mul_comm] + +theorem spatialRankPolynomial_top {K R : Type*} [Fintype K] [CommRing R] + (base : R) (c : Option K → R) : + homogeneousComponent 1 (C base + spatialRankPolynomial c) = + ∑ k, C (c (some k)) * X k := by + rw [spatialRankPolynomial_eq, map_add, map_add, map_sum] + have hc (r : R) : homogeneousComponent 1 (C r : MvPolynomial K R) = 0 := + homogeneousComponent_eq_zero 1 (C r) (by simp) + simp only [hc, zero_add] + apply Finset.sum_congr rfl + intro k _ + rw [C_mul_X_eq_monomial] + exact homogeneousComponent_eq_self (isHomogeneous_monomial _ (by simp)) + +def spatialKernelRankSlot {G P A : Type*} (e : A ↪ G) (a : A) : Option (G ⊕ P) := + some (.inl (e a)) + +theorem spatialKernelRankSlot_injective {G P A : Type*} (e : A ↪ G) : + Function.Injective (spatialKernelRankSlot (P := P) e) := by + intro a b hab + exact e.injective (Sum.inl.inj (Option.some.inj hab)) + +private theorem spatial_kernel_selected_sum {G P A R : Type*} + [Fintype A] [CommRing R] (e : A ↪ G) (c : A → R) : + (∑ a, monomial (spatialRankExponent (spatialKernelRankSlot (P := P) e a)) (c a) : + MvPolynomial (G ⊕ P) R) = ∑ a, c a • X (.inl (e a)) := by + apply Finset.sum_congr rfl + intro a _ + rw [smul_eq_C_mul, C_mul_X_eq_monomial] + rfl + +private theorem spatial_kernel_selected_raw {G P A R : Type*} + [Fintype G] [Fintype P] [Fintype A] [CommRing R] + (e : A ↪ G) (fixed : Option (G ⊕ P) → R) (c : A → R) : + spatialRankPolynomial (Function.extend (spatialKernelRankSlot e) c fixed) = + (∑ d ∈ Finset.univ.filter (fun d => d ∉ Set.range (spatialKernelRankSlot (P := P) e)), + monomial (spatialRankExponent d) (fixed d)) + + ∑ a, monomial (spatialRankExponent (spatialKernelRankSlot (P := P) e a)) (c a) := by + unfold spatialRankPolynomial + convert modularMonomialArrayPolynomial_selected (E := Option (G ⊕ P)) + (K := G ⊕ P) (R := R) (A := A) spatialRankExponent + (spatialKernelRankSlot e) (spatialKernelRankSlot_injective (P := P) e) fixed c using 1 + congr 1 + apply Finset.sum_congr + · congr 1 + · intro d _ + rfl + +theorem spatialRankPolynomial_kernel_selected {G P A R : Type*} + [Fintype G] [Fintype P] [Fintype A] [CommRing R] + (e : A ↪ G) (fixed : Option (G ⊕ P) → R) (c : A → R) : + spatialRankPolynomial (Function.extend (spatialKernelRankSlot e) c fixed) = + (∑ d ∈ Finset.univ.filter (fun d => d ∉ Set.range (spatialKernelRankSlot (P := P) e)), + monomial (spatialRankExponent d) (fixed d)) + + ∑ a, c a • (X (.inl (e a)) : MvPolynomial (G ⊕ P) R) := by + rw [spatial_kernel_selected_raw e fixed c, spatial_kernel_selected_sum e c] + +theorem spatialRankPolynomial_kernel_selected_top {G P A R : Type*} + [Fintype G] [Fintype P] [Fintype A] [CommRing R] + (e : A ↪ G) (fixed : Option (G ⊕ P) → R) (c : A → R) : + homogeneousComponent 1 (spatialRankPolynomial (Function.extend (spatialKernelRankSlot e) c fixed)) = + homogeneousComponent 1 + (∑ d ∈ Finset.univ.filter (fun d => d ∉ Set.range (spatialKernelRankSlot (P := P) e)), + monomial (spatialRankExponent d) (fixed d)) + + ∑ a, c a • (X (.inl (e a)) : MvPolynomial (G ⊕ P) R) := by + rw [spatialRankPolynomial_kernel_selected e fixed c, map_add] + congr 1 + rw [map_sum] + apply Finset.sum_congr rfl + intro a _ + rw [smul_eq_C_mul, C_mul_X_eq_monomial] + exact homogeneousComponent_eq_self (isHomogeneous_monomial _ (by simp)) + +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +variable {D G A R : Type*} {B : D → Type*} [CommRing R] + +theorem samplerLong_killCompl_common (inactive : D → Prop) (h : D → ℕ) (g : G) : + killCompl (samplerLongEmbedding (B := B) inactive h).injective + (X (.inl g) : MvPolynomial (SamplerTupleIndex G B h) R) = X (.inl g) := by + change killCompl (samplerLongEmbedding (B := B) inactive h).injective + (X (samplerLongEmbedding inactive h (.inl g))) = _ + rw [← rename_X, killCompl_rename_app] + +theorem spatialRankPolynomial_kernel_selected_long + [Fintype D] [Fintype G] [∀ d, Fintype (B d)] [Fintype A] + (inactive : D → Prop) (h : D → ℕ) (e : A ↪ G) + (fixed : Option (SamplerTupleIndex G B h) → R) (c : A → R) + (v : SamplerTupleIndex G B h → R) : + homogeneousComponent 1 + (conditionPolynomial (samplerLongEmbedding inactive h) + (samplerLongEmbedding inactive h).injective v + (spatialRankPolynomial (Function.extend (spatialKernelRankSlot e) c fixed))) = + killCompl (samplerLongEmbedding inactive h).injective + (homogeneousComponent 1 + (∑ d ∈ Finset.univ.filter + (fun d => d ∉ Set.range (spatialKernelRankSlot (P := PrincipalTupleIndex B h) e)), + MvPolynomial.monomial (spatialRankExponent d) (fixed d))) + + ∑ a, c a • (X (.inl (e a)) : MvPolynomial (SamplerLongVariables inactive G B h) R) := by + rw [homogeneousComponent_conditionPolynomial_top _ _ _ v 1 + (spatialRankPolynomial_degree _), spatialRankPolynomial_kernel_selected_top, map_add] + apply congrArg₂ (fun P Q => P + Q) + · apply congrArg (killCompl (samplerLongEmbedding inactive h).injective) + apply congrArg (homogeneousComponent 1) + apply Finset.sum_congr + · exact Finset.filter_congr_decidable _ _ _ + · intro d _ + rfl + · rw [map_sum] + apply Finset.sum_congr rfl + intro a _ + rw [map_smul, samplerLong_killCompl_common] + +namespace VectorPolynomial + +variable {m : ℕ} {I : Fin m → Type*} {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type*} + +theorem allocatedSpatialRankPolynomial_kernel_selected_long + [∀ j, Fintype (I j)] [Fintype G] [∀ d, Fintype (B d)] [Fintype A] + (inactive : LayerSamplerAxis I n → Prop) (e : A ↪ G) + (fixed : Option (LayerSamplerVariables G I n B) → R) (c : A → R) + (v : LayerSamplerVariables G I n B → R) : + homogeneousComponent 1 + (conditionPolynomial (allocatedLongEmbedding inactive) + (allocatedLongEmbedding inactive).injective v + (spatialRankPolynomial (Function.extend (spatialKernelRankSlot e) c fixed))) = + killCompl (allocatedLongEmbedding inactive).injective + (homogeneousComponent 1 + (∑ d ∈ Finset.univ.filter (fun d => d ∉ Set.range + (spatialKernelRankSlot (P := PrincipalTupleIndex B (layerSamplerDegree I n)) e)), + MvPolynomial.monomial (spatialRankExponent d) (fixed d))) + + ∑ a, c a • (X (.inl (e a)) : MvPolynomial (LayerSamplerLongVariables inactive G B) R) := by + convert spatialRankPolynomial_kernel_selected_long inactive (layerSamplerDegree I n) e fixed c v using 1 + · rfl + · apply congrArg₂ (fun P Q => P + Q) + · apply congrArg (killCompl (allocatedLongEmbedding inactive).injective) + apply congrArg (homogeneousComponent 1) + apply Finset.sum_congr + · congr 1 + · intro d _ + rfl + · rfl + +end VectorPolynomial +end Erdos3 + +end + +section + +namespace Erdos3 +open MvPolynomial +open scoped BigOperators Classical + +def spatialNoiseRankSlot {G P A X : Type*} (e : A ↪ G) : + A × X → Option (G ⊕ P) × X := + fun ax => (spatialKernelRankSlot e ax.1, ax.2) + +theorem spatialNoiseRankSlot_injective {G P A X : Type*} (e : A ↪ G) : + Function.Injective (spatialNoiseRankSlot (P := P) (X := X) e) := by + intro a b hab + apply Prod.ext + · exact spatialKernelRankSlot_injective e (congrArg (fun z : Option (G ⊕ P) × X => z.1) hab) + · exact congrArg (fun z : Option (G ⊕ P) × X => z.2) hab + +noncomputable def resampleSpatialRankNoise {G P A X R : Type*} (e : A ↪ G) + (fixed : Option (G ⊕ P) × X → R) (c : X → A → R) : + Option (G ⊕ P) × X → R := + Function.extend (spatialNoiseRankSlot e) (fun ax => c ax.2 ax.1) fixed + +theorem resampleSpatialRankNoise_coordinate {G P A X R : Type*} (e : A ↪ G) + (fixed : Option (G ⊕ P) × X → R) (c : X → A → R) (x : X) : + (fun d => resampleSpatialRankNoise e fixed c (d,x)) = + Function.extend (spatialKernelRankSlot e) (c x) (fun d => fixed (d,x)) := by + funext d + by_cases hd : d ∈ Set.range (spatialKernelRankSlot (P := P) e) + · obtain ⟨a, rfl⟩ := hd + change Function.extend (spatialNoiseRankSlot e) (fun ax => c ax.2 ax.1) + fixed (spatialNoiseRankSlot e (a,x)) = _ + rw [(spatialNoiseRankSlot_injective e).extend_apply, + (spatialKernelRankSlot_injective e).extend_apply] + · have hdx : (d,x) ∉ Set.range (spatialNoiseRankSlot (P := P) (X := X) e) := by + rintro ⟨⟨a,y⟩, h⟩ + exact hd ⟨a, congrArg Prod.fst h⟩ + simp only [resampleSpatialRankNoise, Function.extend_apply' _ _ _ hdx, + Function.extend_apply' _ _ _ hd] + +theorem spatialRankNoise_selected_top {G P A X R : Type*} + [Fintype G] [Fintype P] [Fintype A] [CommRing R] + (e : A ↪ G) (fixed : Option (G ⊕ P) × X → R) (c : X → A → R) (x : X) : + homogeneousComponent 1 + (spatialRankPolynomial (fun d => resampleSpatialRankNoise e fixed c (d,x))) = + homogeneousComponent 1 + (∑ d ∈ Finset.univ.filter (fun d => d ∉ Set.range (spatialKernelRankSlot (P := P) e)), + monomial (spatialRankExponent d) (fixed (d,x))) + + ∑ a, c x a • (MvPolynomial.X (.inl (e a)) : MvPolynomial (G ⊕ P) R) := by + rw [resampleSpatialRankNoise_coordinate] + exact spatialRankPolynomial_kernel_selected_top e (fun d => fixed (d,x)) (c x) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators + +variable {K J R : Type*} [Fintype K] [CommRing R] + +theorem spatialRankPolynomial_top_congr (f g : Option K → R) + (hfg : ∀ k, f (some k) = g (some k)) : + homogeneousComponent 1 (spatialRankPolynomial f) = + homogeneousComponent 1 (spatialRankPolynomial g) := by + have hf := spatialRankPolynomial_top (0 : R) f + have hg := spatialRankPolynomial_top (0 : R) g + simp only [map_zero, zero_add] at hf hg + rw [hf, hg] + apply Finset.sum_congr rfl + intro k _ + rw [hfg k] + +theorem spatialRankPolynomial_conditioned_top_congr (e : J ↪ K) + (f g : Option K → R) (hfg : ∀ k, f (some k) = g (some k)) + (v w : K → R) : + homogeneousComponent 1 (conditionPolynomial e e.injective v (spatialRankPolynomial f)) = + homogeneousComponent 1 (conditionPolynomial e e.injective w (spatialRankPolynomial g)) := by + rw [homogeneousComponent_conditionPolynomial_top e e.injective _ v 1 + (spatialRankPolynomial_degree f), + homogeneousComponent_conditionPolynomial_top e e.injective _ w 1 + (spatialRankPolynomial_degree g), + spatialRankPolynomial_top_congr f g hfg] + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical +open BooleanCubeKernel + +theorem selectedResidueSmoothPMF_singleton_eq_residue + {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) (r : ColumnResiduePattern K X q) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q {r} V z) + (hc : 0 < shiftedSmoothProductMass + (residueProfileCenter (columnResidueRepresentative q r) q) (residueProfileWidth q V)) : + selectedResidueSmoothPMF q {r} V hV hZ = + residueSmoothPMF (columnResidueRepresentative q r) q hq V hV hc := by + ext z + apply (ENNReal.toReal_eq_toReal_iff' (PMF.apply_ne_top _ _) (PMF.apply_ne_top _ _)).mp + simp only [selectedResidueSmoothPMF_toReal, selectedResidueSmoothWeight_singleton, + residueSmoothPMF_conditional_weight] + +theorem selectedResidueSmoothWeight_singleton_index_mass_pos + {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) (r : ColumnResiduePattern K X q) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q {r} V z) : + 0 < shiftedSmoothProductMass + (residueProfileCenter (columnResidueRepresentative q r) q) (residueProfileWidth q V) := by + rw [residueSmoothWeight_mass _ q hq V hV] + simpa only [selectedResidueSmoothWeight_singleton] using hZ + +theorem selectedResidueSmoothPMF_singleton_eq_independent_map + {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) (r : ColumnResiduePattern K X q) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q {r} V z) : + let hc := selectedResidueSmoothWeight_singleton_index_mass_pos q hq r V hV hZ + selectedResidueSmoothPMF q {r} V hV hZ = + (independentProductPMF + (residueSmoothScalarPMFs (columnResidueRepresentative q r) q hq V hV hc)).map + (residueLatticeArray (columnResidueRepresentative q r) q) := by + intro hc + rw [selectedResidueSmoothPMF_singleton_eq_residue q hq r V hV hZ hc, + residueSmoothPMF, residueSmoothIndexPMF_eq_independent] + +theorem selectedResidueSmoothPMF_independent_mixture + {K X : Type*} [Fintype K] [Fintype X] + (q : X → ℕ) (hq : ∀ x, 0 < q x) + (T : Finset (ColumnResiduePattern K X q)) + (V : K × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative q r.val) q) + (residueProfileWidth q V)) (φ : (K × X → ℤ) → ℂ) : + (∑' z, ((selectedResidueSmoothPMF q T V hV hZ z).toReal : ℂ) * φ z) = + ∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' t, ((independentProductPMF + (residueSmoothScalarPMFs (boundedColumnResidueRepresentative q r.val) + q hq V hV (hc r)) t).toReal : ℂ) * + φ (residueLatticeArray (boundedColumnResidueRepresentative q r.val) q t) := by + rw [selectedResidueSmoothPMF_bounded_mixture q hq T V hV hZ hc φ] + apply Finset.sum_congr rfl + intro r _ + rw [residueSmoothPMF_expectation, residueSmoothIndexPMF_eq_independent] + +theorem allocatedSpatialRank_residue_width + {G P A X : Type*} (e : A ↪ G) (W τ ξ : ℝ) (N q : X → ℕ) + (a : A) (x : X) : + residueProfileWidth q (narrowTrimmedSpatialWidths (G := G) (J := P) W τ ξ N) + (spatialNoiseRankSlot e (a,x)) = trimmedSpatialSlopeScale W τ N q x := by + exact congrFun (narrowTrimmedSpatial_residue_scale (G := G) (J := P) W τ ξ N q x) + (some (.inl (e a))) + +theorem allocatedSpatialRank_scalar_law + {G P A X : Type*} [Fintype G] [Fintype P] [Fintype X] + (e : A ↪ G) (residue : Option (G ⊕ P) × X → ℤ) + (q : X → ℕ) (hq : ∀ x, 0 < q x) (N : X → ℕ) + {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) (hN : ∀ x, 0 < N x) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) + (residueProfileWidth q (narrowTrimmedSpatialWidths W τ ξ N))) (a : A) (x : X) + (hwidth : 0 < trimmedSpatialSlopeScale W τ N q x) + (hmass : 0 < shiftedSmoothSampleSum + (-(residue (spatialNoiseRankSlot e (a,x)) : ℝ) / q x) + (trimmedSpatialSlopeScale W τ N q x)) : + residueSmoothScalarPMFs residue q hq (narrowTrimmedSpatialWidths W τ ξ N) + (narrowTrimmedSpatialWidths_pos hW hτ hξ N hN) hZ (spatialNoiseRankSlot e (a,x)) = + shiftedSmoothCoefficientPMF + (-(residue (spatialNoiseRankSlot e (a,x)) : ℝ) / q x) + (trimmedSpatialSlopeScale W τ N q x) hwidth hmass := by + unfold residueSmoothScalarPMFs + have hw := allocatedSpatialRank_residue_width (P := P) e W τ ξ N q a x + simp only [residueProfileCenter, spatialNoiseRankSlot, spatialKernelRankSlot] at * + congr 1 + +theorem allocatedSpatialRank_scalar_mass_pos + {G P A X : Type*} [Fintype G] [Fintype P] [Fintype X] + (e : A ↪ G) (residue : Option (G ⊕ P) × X → ℤ) + (q : X → ℕ) (hq : ∀ x, 0 < q x) (N : X → ℕ) + {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) (hN : ∀ x, 0 < N x) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) + (residueProfileWidth q (narrowTrimmedSpatialWidths W τ ξ N))) (a : A) (x : X) : + 0 < shiftedSmoothSampleSum + (-(residue (spatialNoiseRankSlot e (a,x)) : ℝ) / q x) + (trimmedSpatialSlopeScale W τ N q x) := by + have h := shiftedSmoothProductMass_coordinate_pos (residueProfileCenter residue q) + (residueProfileWidth q (narrowTrimmedSpatialWidths W τ ξ N)) + (residueProfileWidth_pos q _ hq (narrowTrimmedSpatialWidths_pos hW hτ hξ N hN)) + hZ (spatialNoiseRankSlot e (a,x)) + rw [allocatedSpatialRank_residue_width] at h + exact h + +theorem allocatedSpatialRank_index_mass_pos + {G P X : Type*} [Fintype G] [Fintype P] [Fintype X] + (residue : Option (G ⊕ P) × X → ℤ) (q N : X → ℕ) + (hq : ∀ x, 0 < q x) (hN : ∀ x, 0 < N x) + {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ1 : ξ ≤ 1) + (hsize : ∀ x, 8 * (1 + W) * (q x : ℝ) * + (8 * (probabilityProfileLipschitz : ℝ)) ≤ (ξ * τ) * (N x : ℝ)) : + 0 < shiftedSmoothProductMass (residueProfileCenter residue q) + (residueProfileWidth q (narrowTrimmedSpatialWidths W τ ξ N)) := by + have hscale (z : Option (G ⊕ P) × X) : + 8 * (probabilityProfileLipschitz : ℝ) ≤ + residueProfileWidth q (narrowTrimmedSpatialWidths W τ ξ N) z := + narrowTrimmedSpatial_residue_width_lower hW hτ hξ1 (by positivity) N q hN hq hsize z + rw [shiftedSmoothProductMass_eq_prod _ _ (fun z => smoothSamplingScale_pos (hscale z))] + exact Finset.prod_pos (fun z _ => shiftedSmoothSampleSum_pos _ (hscale z)) + +theorem allocatedSpatialRank_scalar_law_of_cell_mass + {G P A X : Type*} [Fintype G] [Fintype P] [Fintype X] + (e : A ↪ G) (residue : Option (G ⊕ P) × X → ℤ) + (q : X → ℕ) (hq : ∀ x, 0 < q x) (N : X → ℕ) + {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) (hN : ∀ x, 0 < N x) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) + (residueProfileWidth q (narrowTrimmedSpatialWidths W τ ξ N))) (a : A) (x : X) : + residueSmoothScalarPMFs residue q hq (narrowTrimmedSpatialWidths W τ ξ N) + (narrowTrimmedSpatialWidths_pos hW hτ hξ N hN) hZ (spatialNoiseRankSlot e (a,x)) = + shiftedSmoothCoefficientPMF + (-(residue (spatialNoiseRankSlot e (a,x)) : ℝ) / q x) + (trimmedSpatialSlopeScale W τ N q x) + (trimmedSpatial_scales_pos hW hτ N q x (hN x) (hq x)).2 + (allocatedSpatialRank_scalar_mass_pos e residue q hq N hW hτ hξ hN hZ a x) := + allocatedSpatialRank_scalar_law e residue q hq N hW hτ hξ hN hZ a x _ _ + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +abbrev SpatialMatrixBlockIndex (X : Type*) := Fin 2 × X × X + +def spatialMatrixBlockSlot {G P X : Type*} (e : Fin 2 × X ↪ G) : + SpatialMatrixBlockIndex X ↪ Option (G ⊕ P) × X where + toFun t := (some (.inl (e (t.1,t.2.1))),t.2.2) + inj' := by + rintro ⟨b,j,x⟩ ⟨c,k,y⟩ h + have hx : x = y := congrArg Prod.snd h + have hbj : (b,j) = (c,k) := e.injective + (Sum.inl.inj (Option.some.inj (congrArg Prod.fst h))) + have hb : b = c := congrArg Prod.fst hbj + have hj : j = k := congrArg Prod.snd hbj + subst c + subst k + subst y + rfl + +noncomputable def spatialMatrixNormalizedEntries {G P X : Type*} (e : Fin 2 × X ↪ G) + (V : Option (G ⊕ P) × X → ℝ) (z : Option (G ⊕ P) × X → ℤ) : + SpatialMatrixBlockIndex X → ℝ := + fun t => (z (spatialMatrixBlockSlot e t) : ℝ) / V (spatialMatrixBlockSlot e t) + +noncomputable def spatialMatrixIndexCenter {G P X : Type*} (e : Fin 2 × X ↪ G) + (residue : Option (G ⊕ P) × X → ℤ) (q : X → ℕ) : SpatialMatrixBlockIndex X → ℝ := + fun t => -(residue (spatialMatrixBlockSlot e t) : ℝ) / q t.2.2 + +noncomputable def spatialMatrixIndexWidth {G P X : Type*} (e : Fin 2 × X ↪ G) + (q : X → ℕ) (V : Option (G ⊕ P) × X → ℝ) : SpatialMatrixBlockIndex X → ℝ := + fun t => V (spatialMatrixBlockSlot e t) / q t.2.2 + +theorem spatialMatrixIndexWidth_pos {G P X : Type*} (e : Fin 2 × X ↪ G) + (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) (t : SpatialMatrixBlockIndex X) : + 0 < spatialMatrixIndexWidth e q V t := + div_pos (hV _) (by exact_mod_cast hq t.2.2) + +variable {G P X : Type*} [Fintype G] [Fintype P] [Fintype X] + +theorem spatialMatrixIndexMass_pos (e : Fin 2 × X ↪ G) + (residue : Option (G ⊕ P) × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) (residueProfileWidth q V)) : + 0 < shiftedSmoothProductMass (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) := + shiftedSmoothProductMass_restrict_pos (spatialMatrixBlockSlot e) + (residueProfileCenter residue q) (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) hZ + +theorem spatialMatrixNormalizedEntries_residue (e : Fin 2 × X ↪ G) + (residue : Option (G ⊕ P) × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (t : Option (G ⊕ P) × X → ℤ) : + spatialMatrixNormalizedEntries e V (residueLatticeArray residue q t) = + rectangularLatticePoint (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) + (fun i => t (spatialMatrixBlockSlot e i)) := by + funext i + exact (congrFun (residueProfile_point residue q hq V hV t) (spatialMatrixBlockSlot e i)).symm + +theorem spatialMatrixIndexPMF_marginal (e : Fin 2 × X ↪ G) + (residue : Option (G ⊕ P) × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) (residueProfileWidth q V)) : + (residueSmoothIndexPMF residue q hq V hV hZ).map + (fun t i => t (spatialMatrixBlockSlot e i)) = + shiftedSmoothProductPMF (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) + (spatialMatrixIndexWidth_pos e q hq V hV) (spatialMatrixIndexMass_pos e residue q hq V hV hZ) := by + exact shiftedSmoothProductPMF_selected_marginal (spatialMatrixBlockSlot e) + (residueProfileCenter residue q) (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) hZ + +theorem spatialMatrixNormalizedEntries_residue_law (e : Fin 2 × X ↪ G) + (residue : Option (G ⊕ P) × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) (residueProfileWidth q V)) : + (residueSmoothPMF residue q hq V hV hZ).map (spatialMatrixNormalizedEntries e V) = + (shiftedSmoothProductPMF (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) + (spatialMatrixIndexWidth_pos e q hq V hV) (spatialMatrixIndexMass_pos e residue q hq V hV hZ)).map + (rectangularLatticePoint (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V)) := by + rw [residueSmoothPMF, PMF.map_comp] + have hf : spatialMatrixNormalizedEntries e V ∘ residueLatticeArray residue q = + rectangularLatticePoint (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) ∘ + (fun t i => t (spatialMatrixBlockSlot e i)) := by + funext t + exact spatialMatrixNormalizedEntries_residue e residue q hq V hV t + rw [hf, ← PMF.map_comp, spatialMatrixIndexPMF_marginal] + +theorem spatialMatrixNormalizedEntries_singleton_law (e : Fin 2 × X ↪ G) + (q : X → ℕ) (hq : ∀ x, 0 < q x) (r : ColumnResiduePattern (Option (G ⊕ P)) X q) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q {r} V z) : + let hc := selectedResidueSmoothWeight_singleton_index_mass_pos q hq r V hV hZ + (selectedResidueSmoothPMF q {r} V hV hZ).map (spatialMatrixNormalizedEntries e V) = + (shiftedSmoothProductPMF (spatialMatrixIndexCenter e (columnResidueRepresentative q r) q) + (spatialMatrixIndexWidth e q V) (spatialMatrixIndexWidth_pos e q hq V hV) + (spatialMatrixIndexMass_pos e _ q hq V hV hc)).map + (rectangularLatticePoint (spatialMatrixIndexCenter e (columnResidueRepresentative q r) q) + (spatialMatrixIndexWidth e q V)) := by + intro hc + rw [selectedResidueSmoothPMF_singleton_eq_residue q hq r V hV hZ hc] + exact spatialMatrixNormalizedEntries_residue_law e _ q hq V hV hc + +theorem spatialMatrixNormalizedEntries_residue_expectation (e : Fin 2 × X ↪ G) + (residue : Option (G ⊕ P) × X → ℤ) (q : X → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) (residueProfileWidth q V)) + (φ : (SpatialMatrixBlockIndex X → ℝ) → ℂ) : + (∑' z, ((residueSmoothPMF residue q hq V hV hZ z).toReal : ℂ) * + φ (spatialMatrixNormalizedEntries e V z)) = + ∑' t, ((shiftedSmoothProductPMF (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) + (spatialMatrixIndexWidth_pos e q hq V hV) (spatialMatrixIndexMass_pos e residue q hq V hV hZ) t).toReal : ℂ) * + φ (rectangularLatticePoint (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) t) := by + rw [residueSmoothPMF_expectation] + simp only [spatialMatrixNormalizedEntries_residue e residue q hq V hV] + exact shiftedSmoothProductPMF_selected_expectation (spatialMatrixBlockSlot e) + (residueProfileCenter residue q) (residueProfileWidth q V) + (residueProfileWidth_pos q V hq hV) hZ + (fun t => φ (rectangularLatticePoint (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) t)) + +theorem spatialMatrixNormalizedEntries_mixture_expectation (e : Fin 2 × X ↪ G) + (q : X → ℕ) (hq : ∀ x, 0 < q x) + (T : Finset (ColumnResiduePattern (Option (G ⊕ P)) X q)) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative q r.val) q) (residueProfileWidth q V)) + (φ : (SpatialMatrixBlockIndex X → ℝ) → ℂ) : + (∑' z, ((selectedResidueSmoothPMF q T V hV hZ z).toReal : ℂ) * + φ (spatialMatrixNormalizedEntries e V z)) = + ∑ r : T, (selectedResidueCellWeight q T V r : ℂ) * + ∑' t, ((shiftedSmoothProductPMF + (spatialMatrixIndexCenter e (boundedColumnResidueRepresentative q r.val) q) + (spatialMatrixIndexWidth e q V) (spatialMatrixIndexWidth_pos e q hq V hV) + (spatialMatrixIndexMass_pos e _ q hq V hV (hc r)) t).toReal : ℂ) * + φ (rectangularLatticePoint + (spatialMatrixIndexCenter e (boundedColumnResidueRepresentative q r.val) q) + (spatialMatrixIndexWidth e q V) t) := by + rw [selectedResidueSmoothPMF_bounded_mixture q hq T V hV hZ hc] + apply Finset.sum_congr rfl + intro r _ + rw [spatialMatrixNormalizedEntries_residue_expectation e _ q hq V hV (hc r)] + +theorem spatialMatrixNormalizedEntries_mixture_event (e : Fin 2 × X ↪ G) + (q : X → ℕ) (hq : ∀ x, 0 < q x) + (T : Finset (ColumnResiduePattern (Option (G ⊕ P)) X q)) + (V : Option (G ⊕ P) × X → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hc : ∀ r : T, 0 < shiftedSmoothProductMass + (residueProfileCenter (boundedColumnResidueRepresentative q r.val) q) (residueProfileWidth q V)) + (bad : (SpatialMatrixBlockIndex X → ℝ) → Prop) : + (∑' z, (selectedResidueSmoothPMF q T V hV hZ z).toReal * + (if bad (spatialMatrixNormalizedEntries e V z) then 1 else 0)) = + ∑ r : T, selectedResidueCellWeight q T V r * + ∑' t, (shiftedSmoothProductPMF + (spatialMatrixIndexCenter e (boundedColumnResidueRepresentative q r.val) q) + (spatialMatrixIndexWidth e q V) (spatialMatrixIndexWidth_pos e q hq V hV) + (spatialMatrixIndexMass_pos e _ q hq V hV (hc r)) t).toReal * + (if bad (rectangularLatticePoint + (spatialMatrixIndexCenter e (boundedColumnResidueRepresentative q r.val) q) + (spatialMatrixIndexWidth e q V) t) then 1 else 0) := by + apply Complex.ofReal_injective + simpa only [Complex.ofReal_tsum, Complex.ofReal_sum, Complex.ofReal_mul, + apply_ite, Complex.ofReal_one, Complex.ofReal_zero] using + spatialMatrixNormalizedEntries_mixture_expectation e q hq T V hV hZ hc + (fun z => if bad z then 1 else 0) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +def spatialMatrixBlockEquiv (n : ℕ) : + SpatialMatrixBlockIndex (Fin n) ≃ Fin (2 * n * n) := + (Equiv.prodCongr (Equiv.refl (Fin 2)) finProdFinEquiv).trans + (finProdFinEquiv.trans (finCongr (Nat.mul_assoc 2 n n).symm)) + +def spatialMatrixBlockEntry (n : ℕ) (b : Fin 2) : + Fin n × Fin n ↪ Fin (2 * n * n) where + toFun rc := spatialMatrixBlockEquiv n (b, rc.2, rc.1) + inj' := by + intro x y h + have hs := (spatialMatrixBlockEquiv n).injective h + have hp := congrArg Prod.snd hs + exact Prod.ext (congrArg Prod.snd hp) (congrArg Prod.fst hp) + +@[simp] theorem spatialMatrixBlockEntry_apply (n : ℕ) (b : Fin 2) (r c : Fin n) : + spatialMatrixBlockEntry n b (r,c) = spatialMatrixBlockEquiv n (b,c,r) := rfl + +@[simp] theorem spatialMatrixBlockEntry_symm (n : ℕ) (b : Fin 2) (r c : Fin n) : + (spatialMatrixBlockEquiv n).symm (spatialMatrixBlockEntry n b (r,c)) = (b,c,r) := + (spatialMatrixBlockEquiv n).symm_apply_apply _ + +theorem spatialMatrixBlockEntry_reindex_eval {R : Type*} + (n : ℕ) (z : SpatialMatrixBlockIndex (Fin n) → R) (b : Fin 2) (r c : Fin n) : + z ((spatialMatrixBlockEquiv n).symm (spatialMatrixBlockEntry n b (r,c))) = z (b,c,r) := by + rw [spatialMatrixBlockEntry_symm] + +theorem spatialMatrixBlockEntry_disjoint (n : ℕ) {b c : Fin 2} (hbc : b ≠ c) : + Disjoint (Set.range (spatialMatrixBlockEntry n b)) + (Set.range (spatialMatrixBlockEntry n c)) := by + rw [Set.disjoint_left] + rintro k ⟨x, rfl⟩ ⟨y, he⟩ + have hh := (spatialMatrixBlockEquiv n).injective he + exact hbc (congrArg Prod.fst hh).symm + +theorem shiftedSmoothProductPMF_reindex {D J : Type*} [Fintype D] [Fintype J] + (e : D ≃ J) (a S : J → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) : + (shiftedSmoothProductPMF a S hS hZ).map (fun z d => z (e d)) = + shiftedSmoothProductPMF (fun d => a (e d)) (fun d => S (e d)) + (fun d => hS (e d)) (shiftedSmoothProductMass_restrict_pos e a S hS hZ) := + shiftedSmoothProductPMF_selected_marginal e.toEmbedding a S hS hZ + +theorem rectangularLatticePoint_reindex {D J : Type*} (e : D → J) + (a S : J → ℝ) (z : J → ℤ) : + rectangularLatticePoint (fun d => a (e d)) (fun d => S (e d)) (fun d => z (e d)) = + fun d => rectangularLatticePoint a S z (e d) := rfl + +theorem spatialMatrixBlock_normalized_law (n : ℕ) + (a S : SpatialMatrixBlockIndex (Fin n) → ℝ) (hS : ∀ j, 0 < S j) + (hZ : 0 < shiftedSmoothProductMass a S) : + (shiftedSmoothProductPMF a S hS hZ).map + (fun z k => rectangularLatticePoint a S z ((spatialMatrixBlockEquiv n).symm k)) = + (shiftedSmoothProductPMF + (fun k => a ((spatialMatrixBlockEquiv n).symm k)) + (fun k => S ((spatialMatrixBlockEquiv n).symm k)) + (fun k => hS ((spatialMatrixBlockEquiv n).symm k)) + (shiftedSmoothProductMass_restrict_pos (spatialMatrixBlockEquiv n).symm a S hS hZ)).map + (rectangularLatticePoint (fun k => a ((spatialMatrixBlockEquiv n).symm k)) + (fun k => S ((spatialMatrixBlockEquiv n).symm k))) := by + exact shiftedSmoothProductPMF_selected_map (spatialMatrixBlockEquiv n).symm.toEmbedding + a S hS hZ + (rectangularLatticePoint (fun k => a ((spatialMatrixBlockEquiv n).symm k)) + (fun k => S ((spatialMatrixBlockEquiv n).symm k))) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +private theorem spatialMatrix_decide_eq_classical (p : Prop) [d : Decidable p] : + @decide p d = @decide p (Classical.propDecidable p) := by + cases Subsingleton.elim d (Classical.propDecidable p) + rfl + +noncomputable def spatialMatrixBlockThreshold (n : ℕ) (η : ℝ) : ℝ := + shiftedSmoothSublevelThreshold (2 * n * n) n 2 η + +theorem spatialMatrixBlockThreshold_pos {n : ℕ} (hn : 0 < n) {η : ℝ} (hη : 0 < η) : + 0 < spatialMatrixBlockThreshold n η := + shiftedSmoothSublevelThreshold_pos (by positivity) n 2 hη + +def spatialMatrixBlockBad {G P : Type*} {n : ℕ} (e : Fin 2 × Fin n ↪ G) + (V : Option (G ⊕ P) × Fin n → ℝ) (κ : ℝ) + (z : Option (G ⊕ P) × Fin n → ℤ) : Prop := + ∃ b : Fin 2, |Matrix.det (fun i j : Fin n => spatialMatrixNormalizedEntries e V z (b,j,i))| ≤ κ + +theorem spatialMatrixBlock_flat_bad_probability {n : ℕ} (hn : 0 < n) + (a S : SpatialMatrixBlockIndex (Fin n) → ℝ) (hS : ∀ i, 0 < S i) + (hZ : 0 < shiftedSmoothProductMass a S) + (hlarge : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ S i) + {δ η : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hη : 0 < η) (hmesh : ∀ i, 1 / S i ≤ δ) + (hsmall : embeddedMatrixDeterminantLip n (2*n*n) * δ ≤ spatialMatrixBlockThreshold n η) : + ((shiftedSmoothProductPMF a S hS hZ).map (fun k => decide + (∃ b : Fin 2, |Matrix.det (fun i j : Fin n => rectangularLatticePoint a S k (b,j,i))| ≤ + spatialMatrixBlockThreshold n η)) true).toReal ≤ η / 2 := by + unfold spatialMatrixBlockThreshold at hsmall ⊢ + simp only [spatialMatrix_decide_eq_classical] + have h := smoothMatrixBlock_bad_probability hn (show 0 < 2*n*n by positivity) + (spatialMatrixBlockEntry n) + (fun k => a ((spatialMatrixBlockEquiv n).symm k)) + (fun k => S ((spatialMatrixBlockEquiv n).symm k)) + (fun k => hS ((spatialMatrixBlockEquiv n).symm k)) + (shiftedSmoothProductMass_restrict_pos (spatialMatrixBlockEquiv n).symm a S hS hZ) + (fun k => hlarge ((spatialMatrixBlockEquiv n).symm k)) hδ hδ1 hη + (fun k => hmesh ((spatialMatrixBlockEquiv n).symm k)) + (by simpa only [Fintype.card_fin, spatialMatrixBlockThreshold] using hsmall) + rw [← shiftedSmoothProductPMF_reindex (spatialMatrixBlockEquiv n).symm a S hS hZ, + PMF.map_comp] at h + simpa only [Function.comp_def, rectangularLatticePoint_reindex, + spatialMatrixBlockEntry_reindex_eval, Fintype.card_fin, spatialMatrixBlockThreshold, + spatialMatrix_decide_eq_classical] using h + +variable {G P : Type*} [Fintype G] [Fintype P] {n : ℕ} + +theorem spatialMatrixBlock_residue_bad_probability (hn : 0 < n) (e : Fin 2 × Fin n ↪ G) + (residue : Option (G ⊕ P) × Fin n → ℤ) (q : Fin n → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × Fin n → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < shiftedSmoothProductMass (residueProfileCenter residue q) (residueProfileWidth q V)) + (hlarge : ∀ i, 8 * (probabilityProfileLipschitz : ℝ) ≤ spatialMatrixIndexWidth e q V i) + {δ η : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hη : 0 < η) + (hmesh : ∀ i, 1 / spatialMatrixIndexWidth e q V i ≤ δ) + (hsmall : embeddedMatrixDeterminantLip n (2*n*n) * δ ≤ spatialMatrixBlockThreshold n η) : + ((residueSmoothPMF residue q hq V hV hZ).map + (fun z => decide (spatialMatrixBlockBad e V (spatialMatrixBlockThreshold n η) z)) true).toReal ≤ η / 2 := by + let test : (SpatialMatrixBlockIndex (Fin n) → ℝ) → Bool := fun z => decide + (∃ b : Fin 2, |Matrix.det (fun i j : Fin n => z (b,j,i))| ≤ spatialMatrixBlockThreshold n η) + have heq := congrArg (fun law : PMF (SpatialMatrixBlockIndex (Fin n) → ℝ) => + (law.map test true).toReal) + (spatialMatrixNormalizedEntries_residue_law e residue q hq V hV hZ) + have hbound := spatialMatrixBlock_flat_bad_probability hn + (spatialMatrixIndexCenter e residue q) (spatialMatrixIndexWidth e q V) + (spatialMatrixIndexWidth_pos e q hq V hV) (spatialMatrixIndexMass_pos e residue q hq V hV hZ) + hlarge hδ hδ1 hη hmesh hsmall + simp only [PMF.map_comp, Function.comp_def, test, spatialMatrixBlockBad, + spatialMatrix_decide_eq_classical] at heq hbound ⊢ + exact heq.trans_le hbound + +theorem spatialMatrixBlock_cellMass_pos + (q : Fin n → ℕ) (hq : ∀ x, 0 < q x) + (V : Option (G ⊕ P) × Fin n → ℝ) (hV : ∀ z, 0 < V z) + (hscale : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + (residue : Option (G ⊕ P) × Fin n → ℤ) : + 0 < shiftedSmoothProductMass (residueProfileCenter residue q) (residueProfileWidth q V) := by + rw [shiftedSmoothProductMass_eq_prod _ _ (residueProfileWidth_pos q V hq hV)] + exact Finset.prod_pos (fun z _ => shiftedSmoothSampleSum_pos _ (hscale z)) + +theorem spatialMatrixBlock_bad_probability (hn : 0 < n) (e : Fin 2 × Fin n ↪ G) + (q : Fin n → ℕ) (hq : ∀ x, 0 < q x) + (T : Finset (ColumnResiduePattern (Option (G ⊕ P)) (Fin n) q)) + (V : Option (G ⊕ P) × Fin n → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hscale : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + {δ η : ℝ} (hδ : 0 ≤ δ) (hδ1 : δ ≤ 1) (hη : 0 < η) + (hmesh : ∀ i, 1 / spatialMatrixIndexWidth e q V i ≤ δ) + (hsmall : embeddedMatrixDeterminantLip n (2*n*n) * δ ≤ spatialMatrixBlockThreshold n η) : + ((selectedResidueSmoothPMF q T V hV hZ).map + (fun z => decide (spatialMatrixBlockBad e V (spatialMatrixBlockThreshold n η) z)) true).toReal ≤ η / 2 := by + let hc (r : T) := spatialMatrixBlock_cellMass_pos q hq V hV hscale + (boundedColumnResidueRepresentative q r.val) + apply selectedResidueSmoothPMF_bind_le_of_cells q hq T V hV hZ hc + (fun z => PMF.pure (decide (spatialMatrixBlockBad e V (spatialMatrixBlockThreshold n η) z))) true (η/2) + intro r + exact spatialMatrixBlock_residue_bad_probability hn e _ q hq V hV (hc r) + (fun i => hscale (spatialMatrixBlockSlot e i)) hδ hδ1 hη hmesh hsmall + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators Classical + +theorem spatialMatrixBlockThreshold_inverse_le_exp {n : ℕ} (hn : 0 < n) + {η E : ℝ} (hη : 0 < η) (hE : 0 ≤ E) (hηb : η⁻¹ ≤ Real.exp E) : + (spatialMatrixBlockThreshold n η)⁻¹ ≤ + Real.exp (smoothMatrixBlockThresholdLogBudget (2 * n * n) n 2 E) := + smoothMatrixBlock_threshold_inverse_le_exp (by positivity) hn 2 hη hE hηb + +theorem spatialMatrixBlock_bad_probability_of_exp_width + {G P : Type*} [Fintype G] [Fintype P] {n : ℕ} (hn : 0 < n) + (e : Fin 2 × Fin n ↪ G) + (q : Fin n → ℕ) (hq : ∀ x, 0 < q x) + (T : Finset (ColumnResiduePattern (Option (G ⊕ P)) (Fin n) q)) + (V : Option (G ⊕ P) × Fin n → ℝ) (hV : ∀ z, 0 < V z) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight q T V z) + (hscale : ∀ z, 8 * (probabilityProfileLipschitz : ℝ) ≤ residueProfileWidth q V z) + {η E : ℝ} (hη : 0 < η) (hE : 0 ≤ E) (hηb : η⁻¹ ≤ Real.exp E) + (hwide : ∀ i, Real.exp (smoothMatrixBlockWidthLogBudget (2 * n * n) n 2 E) ≤ + spatialMatrixIndexWidth e q V i) : + ((selectedResidueSmoothPMF q T V hV hZ).map + (fun z => decide (spatialMatrixBlockBad e V (spatialMatrixBlockThreshold n η) z)) true).toReal ≤ η / 2 := by + have hκ := spatialMatrixBlockThreshold_pos hn hη + have hδ := smoothMatrixBlockMesh_spec n (2 * n * n) hκ + have hwide' (i) := smoothMatrixBlockMesh_width_spec n (2 * n * n) hκ + ((smoothMatrixBlock_actual_width_le_exp (by positivity) hn 2 hη hE hηb).trans (hwide i)) + exact spatialMatrixBlock_bad_probability hn e q hq T V hV hZ hscale + hδ.1.le hδ.2.1 hη (fun i => (hwide' i).2.2) hδ.2.2 + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SpatialMatrixCutoffBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/SpatialMatrixCutoffBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..89852bf5aacb98afb6ce8310896c4d51e343de2a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SpatialMatrixCutoffBudget.lean @@ -0,0 +1,54 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedDeterminantCutoff + +namespace OAI + +section + +namespace Erdos3 + +theorem nat_mul_factorial_le_exp_square (n : ℕ) : + ((n * n.factorial : ℕ) : ℝ) ≤ Real.exp (((n : ℝ) + 1) ^ 2) := by + have hn : (n : ℝ) ≤ Real.exp (n : ℝ) := by + have h := Real.add_one_le_exp (n : ℝ) + linarith + have hf : (n.factorial : ℝ) ≤ (n : ℝ) ^ n := by exact_mod_cast n.factorial_le_pow + have hp : (n : ℝ) ^ n ≤ Real.exp ((n : ℝ) * n) := by + rw [Real.exp_nat_mul] + exact pow_le_pow_left₀ (Nat.cast_nonneg _) hn n + calc + _ = (n : ℝ) * n.factorial := by push_cast; rfl + _ ≤ Real.exp (n : ℝ) * Real.exp ((n : ℝ) * n) := + mul_le_mul hn (hf.trans hp) (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = Real.exp ((n : ℝ) + (n : ℝ) * n) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith [Nat.cast_nonneg (α := ℝ) n]) + +theorem determinantCutoff_lip_le_exp (n : ℕ) {κ K : ℝ} + (hκ : 0 < κ) (hK : κ⁻¹ ≤ Real.exp K) : + (2 / κ) * ((n * n.factorial : ℕ) : ℝ) ≤ + Real.exp (K + ((n : ℝ) + 1) ^ 2 + 1) := by + have htwo : (2 : ℝ) ≤ Real.exp 1 := by + have h := Real.add_one_le_exp (1 : ℝ) + linarith + calc + _ = (2 * κ⁻¹) * ((n * n.factorial : ℕ) : ℝ) := by rw [div_eq_mul_inv] + _ ≤ (Real.exp 1 * Real.exp K) * Real.exp (((n : ℝ) + 1) ^ 2) := by + gcongr + exact nat_mul_factorial_le_exp_square n + _ = _ := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + +theorem spatialMatrixBlockCutoff_lip_exp_budget {n : ℕ} (hn : 0 < n) + {η E : ℝ} (hη : 0 < η) (hE : 0 ≤ E) (hηb : η⁻¹ ≤ Real.exp E) : + (2 / spatialMatrixBlockThreshold n η) * ((n * n.factorial : ℕ) : ℝ) ≤ + Real.exp (smoothMatrixBlockThresholdLogBudget (2 * n * n) n 2 E + + ((n : ℝ) + 1) ^ 2 + 1) := + determinantCutoff_lip_le_exp n (spatialMatrixBlockThreshold_pos hn hη) + (spatialMatrixBlockThreshold_inverse_le_exp hn hη hE hηb) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SplitCoverProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/SplitCoverProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..57630bc24dd41f3b4c9fa3575e5a646383040fb3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SplitCoverProjection.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.Progressions.Estimates.OptionComplementCover + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D E : RationalFilteredNilmanifold L s d) + +noncomputable def sublatticeProjection (h : E.lattice ≤ D.lattice) : E.Space → D.Space := + cosetMap E.realLattice D.realLattice (MonoidHom.id _) (Subgroup.map_mono h) + +@[simp] theorem sublatticeProjection_mk (h : E.lattice ≤ D.lattice) (x : E.RealGroup) : + sublatticeProjection D E h (QuotientGroup.mk x) = QuotientGroup.mk x := rfl + +theorem sublatticeProjection_surjective (h : E.lattice ≤ D.lattice) : + Function.Surjective (sublatticeProjection D E h) := + cosetMap_surjective E.realLattice D.realLattice (MonoidHom.id _) (Subgroup.map_mono h) + Function.surjective_id + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem sublatticeProjection_lipschitz (h : E.lattice ≤ D.lattice) (hb : E.basis = D.basis) : + letI := E.metricSpace + letI := D.metricSpace + LipschitzWith 1 (sublatticeProjection D E h) := by + let : FiniteDimensional ℝ (ℝ ⊗[ℚ] L) := (D.basis.baseChange ℝ).finiteDimensional_of_finite + let := rightMetricSpace (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) (D.basis.baseChange ℝ) + let := rightMetricSpace_isIsometricSMul (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + (D.basis.baseChange ℝ) + have hLip : LipschitzWith 1 (MonoidHom.id D.RealGroup) := LipschitzWith.id + have hc := lipschitz_cosetMap E.realLattice D.realLattice E.realLattice_closed_discrete.1 + D.realLattice_closed_discrete.1 (MonoidHom.id _) (Subgroup.map_mono h) hLip + change @LipschitzWith E.Space D.Space + (quotientMetricSpace (E.basis.baseChange ℝ) E.realLattice + E.realLattice_closed_discrete.1).toEMetricSpace.toPseudoEMetricSpace + (quotientMetricSpace (D.basis.baseChange ℝ) D.realLattice + D.realLattice_closed_discrete.1).toEMetricSpace.toPseudoEMetricSpace + 1 (sublatticeProjection D E h) + rw [hb] + exact hc + +theorem sublattice_pullback_lipschitz (h : E.lattice ≤ D.lattice) (hb : E.basis = D.basis) + (u : D.Space → ℂ) {K : ℝ≥0} (hu : letI := D.metricSpace; LipschitzWith K u) : + letI := E.metricSpace + LipschitzWith K (u ∘ sublatticeProjection D E h) := by + let := E.metricSpace + let := D.metricSpace + simpa only [mul_one] using hu.comp (sublatticeProjection_lipschitz D E h hb) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct NNReal + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + {L : Option ι → Type*} [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + {s : ℕ} {d : Option ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (V : RationalFilteredNilmanifold (∀ i, L i) s (Fintype.card (Σ i, Fin (d i)))) + (hsub : (pi D).lattice ≤ V.lattice) + +noncomputable def splitCoverProjection : + (D none).Space × (pi (fun i => D (some i))).Space → V.Space := + sublatticeProjection V (pi D) hsub ∘ (optionProductSpaceEquiv D).symm + +theorem splitCoverProjection_surjective : Function.Surjective (splitCoverProjection D V hsub) := + (sublatticeProjection_surjective V (pi D) hsub).comp (optionProductSpaceEquiv D).symm.surjective + +theorem splitCoverProjection_mk (x : (pi D).RealGroup) : + splitCoverProjection D V hsub (optionProductSpaceEquiv D (QuotientGroup.mk x)) = + QuotientGroup.mk x := by + simp only [splitCoverProjection, Function.comp_apply, Equiv.symm_apply_apply, + sublatticeProjection_mk] + +variable [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L (some i)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L (some i)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L (some i)))] + [T2Space (ℝ ⊗[ℚ] (∀ i, L (some i)))] + +theorem splitCoverProjection_lipschitz (hb : (pi D).basis = V.basis) : + letI := (D none).metricSpace + letI := (pi (fun i => D (some i))).metricSpace + letI := V.metricSpace + LipschitzWith ((1 + productMetricBound (fun i => d (some i))) * productMetricBound d) + (splitCoverProjection D V hsub) := by + let := (D none).metricSpace + let := (pi (fun i => D (some i))).metricSpace + let := (pi D).metricSpace + let := V.metricSpace + simpa only [one_mul, splitCoverProjection] using + (sublatticeProjection_lipschitz V (pi D) hsub hb).comp (optionProductSpaceEquiv_symm_lipschitz D) + +theorem splitCoverProjection_pullback (hb : (pi D).basis = V.basis) + (u : V.Space → ℂ) {K : ℝ≥0} (hu : letI := V.metricSpace; LipschitzWith K u) + (hpositive : ∀ x, (u x).im = 0 ∧ 0 ≤ (u x).re ∧ (u x).re ≤ 1) : + letI := (D none).metricSpace + letI := (pi (fun i => D (some i))).metricSpace + let v := u ∘ splitCoverProjection D V hsub + LipschitzWith (K * ((1 + productMetricBound (fun i => d (some i))) * productMetricBound d)) v ∧ + (∀ x, (v x).im = 0 ∧ 0 ≤ (v x).re ∧ (v x).re ≤ 1) ∧ + ∀ x : (pi D).RealGroup, v (optionProductSpaceEquiv D (QuotientGroup.mk x)) = + u (QuotientGroup.mk x) := by + let := (D none).metricSpace + let := (pi (fun i => D (some i))).metricSpace + let := V.metricSpace + exact ⟨hu.comp (splitCoverProjection_lipschitz D V hsub hb), + fun x => hpositive _, fun x => congrArg u (splitCoverProjection_mk D V hsub x)⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SplitPreimageSpanning.lean b/lean/OAI/Combinatorics/Progressions/Linear/SplitPreimageSpanning.lean new file mode 100644 index 0000000000000000000000000000000000000000..493b449fd0c062952268abfcd99fa6e5b7bf3869 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SplitPreimageSpanning.lean @@ -0,0 +1,59 @@ +import Mathlib.LinearAlgebra.Basis.Basic +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +variable {R V W ι κ : Type*} [Field R] + [AddCommGroup V] [Module R V] [AddCommGroup W] [Module R W] + +theorem comap_eq_section_image_sup_kernel (P : V →ₗ[R] W) (S : W →ₗ[R] V) + (hS : ∀ x, P (S x) = x) (U : Submodule R W) : + U.comap P = U.map S ⊔ LinearMap.ker P := by + ext x + constructor + · intro hx + apply Submodule.mem_sup.mpr + refine ⟨S (P x), ⟨P x, hx, rfl⟩, x - S (P x), ?_, ?_⟩ + · change P (x - S (P x)) = 0 + rw [map_sub, hS, sub_self] + · abel + · intro hx + obtain ⟨a, ⟨y, hy, rfl⟩, b, hb, rfl⟩ := Submodule.mem_sup.mp hx + change P (S y + b) ∈ U + rw [map_add, hS, show P b = 0 from hb, add_zero] + exact hy + +theorem span_range_sumElim (v : ι → V) (w : κ → V) : + Submodule.span R (Set.range (Sum.elim v w)) = + Submodule.span R (Set.range v) ⊔ Submodule.span R (Set.range w) := by + have he : Set.range (Sum.elim v w) = Set.range v ∪ Set.range w := by + ext x + constructor + · rintro ⟨i, rfl⟩ + cases i with + | inl i => exact Or.inl ⟨i, rfl⟩ + | inr i => exact Or.inr ⟨i, rfl⟩ + · rintro (⟨i, rfl⟩ | ⟨i, rfl⟩) + · exact ⟨Sum.inl i, rfl⟩ + · exact ⟨Sum.inr i, rfl⟩ + rw [he, Submodule.span_union] + +theorem split_preimage_spanning (P : V →ₗ[R] W) (S : W →ₗ[R] V) + (hS : ∀ x, P (S x) = x) (U : Submodule R W) + (v : ι → W) (hv : Submodule.span R (Set.range v) = U) + (k : κ → V) (hk : Submodule.span R (Set.range k) = LinearMap.ker P) : + Submodule.span R (Set.range (Sum.elim (fun i => S (v i)) k)) = U.comap P := by + rw [span_range_sumElim, hk, comap_eq_section_image_sup_kernel P S hS, ← hv, + Submodule.map_span] + congr 1 + exact congrArg (Submodule.span R) (Set.range_comp S v) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SplitSurjectionBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/SplitSurjectionBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..e89108859d3f60e874c8deeacb23a5d535ce6a9b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SplitSurjectionBasis.lean @@ -0,0 +1,57 @@ +import Mathlib.Algebra.Module.Projective +import Mathlib.LinearAlgebra.Basis.Prod +import Mathlib.Tactic + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {R E F : Type*} [Ring R] [AddCommGroup E] [Module R E] + [AddCommGroup F] [Module R F] + +def splitSurjectionEquiv (q : E →ₗ[R] F) (s : F →ₗ[R] E) + (hs : ∀ x, q (s x) = x) : (LinearMap.ker q × F) ≃ₗ[R] E where + toFun p := p.1.val + s p.2 + invFun x := (⟨x - s (q x), by rw [LinearMap.mem_ker, map_sub, hs, sub_self]⟩, q x) + left_inv p := by + refine Prod.ext (Subtype.ext ?_) ?_ + · change p.1.val + s p.2 - s (q (p.1.val + s p.2)) = p.1.val + rw [map_add, show q p.1.val = 0 from p.1.property, hs, zero_add, add_sub_cancel_right] + · change q (p.1.val + s p.2) = p.2 + rw [map_add, show q p.1.val = 0 from p.1.property, hs, zero_add] + right_inv x := sub_add_cancel x (s (q x)) + map_add' x y := by + change x.1.val + y.1.val + s (x.2 + y.2) = (x.1.val + s x.2) + (y.1.val + s y.2) + rw [map_add] + abel + map_smul' a x := by + change a • x.1.val + s (a • x.2) = a • (x.1.val + s x.2) + rw [map_smul, smul_add] + +@[simp] theorem splitSurjectionEquiv_apply (q : E →ₗ[R] F) (s : F →ₗ[R] E) + (hs : ∀ x, q (s x) = x) (p : LinearMap.ker q × F) : + splitSurjectionEquiv q s hs p = p.1.val + s p.2 := rfl + +theorem exists_basis_of_surjection [Projective R F] {α β : Type*} + (q : E →ₗ[R] F) (hq : Function.Surjective q) + (bK : Basis α R (LinearMap.ker q)) (bI : Basis β R F) : + ∃ b : Basis (α ⊕ β) R E, + (∀ i, b (Sum.inl i) = (bK i).val) ∧ (∀ j, q (b (Sum.inr j)) = bI j) := by + obtain ⟨s, hs⟩ := q.exists_rightInverse_of_surjective (LinearMap.range_eq_top.mpr hq) + have hret : ∀ x, q (s x) = x := fun x => LinearMap.congr_fun hs x + let b := (bK.prod bI).map (splitSurjectionEquiv q s hret) + refine ⟨b, ?_, ?_⟩ + · intro i + simp [b] + · intro j + simp [b, hret] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SquareBasisGeometry.lean b/lean/OAI/Combinatorics/Progressions/Linear/SquareBasisGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f47826f2d72d3e48bf6ac3ddf63e462924e4e19a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SquareBasisGeometry.lean @@ -0,0 +1,587 @@ +import Mathlib.LinearAlgebra.Basis.Prod +import OAI.Combinatorics.Progressions.Estimates.QuotientTopSymbol +import OAI.Combinatorics.Progressions.Estimates.ReducedSquareSymbol +import OAI.Combinatorics.Progressions.Estimates.SquareSymbolRelative +import OAI.Combinatorics.Progressions.Geometry.FilteredSymbolMapCoordinates +import OAI.Combinatorics.Progressions.Geometry.SupportedLieQuotient + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L ι κ : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +def squareCoordinates : F.squareLieSubalgebra ≃ₗ[ℚ] L × F.layer 2 where + toFun x := (x.val.2, ⟨x.val.1 - x.val.2, (F.mem_squareLieSubalgebra x.val).mp x.property⟩) + invFun x := ⟨(x.1 + x.2, x.1), (F.mem_squareLieSubalgebra _).mpr (by + change x.1 + (x.2 : L) - x.1 ∈ F.layer 2 + rw [add_sub_cancel_left] + exact x.2.property)⟩ + left_inv x := by apply Subtype.ext; apply Prod.ext <;> simp + right_inv x := by + apply Prod.ext + · rfl + · apply Subtype.ext; simp + map_add' x y := by + apply Prod.ext + · rfl + · apply Subtype.ext; dsimp; abel + map_smul' r x := by + apply Prod.ext + · rfl + · apply Subtype.ext; exact (smul_sub r _ _).symm + +noncomputable def squareBasis (b : Basis ι ℚ L) (c : Basis κ ℚ (F.layer 2)) : + Basis (ι ⊕ κ) ℚ F.squareLieSubalgebra := + (b.prod c).map F.squareCoordinates.symm + +@[simp] theorem squareBasis_inl (b : Basis ι ℚ L) (c : Basis κ ℚ (F.layer 2)) (i : ι) : + (F.squareBasis b c (Sum.inl i)).val = (b i, b i) := by + simp [squareBasis, Basis.map_apply, squareCoordinates] + +@[simp] theorem squareBasis_inr (b : Basis ι ℚ L) (c : Basis κ ℚ (F.layer 2)) (i : κ) : + (F.squareBasis b c (Sum.inr i)).val = ((c i : L), 0) := by + simp [squareBasis, Basis.map_apply, squareCoordinates] + +theorem squareBasis_repr_inl (b : Basis ι ℚ L) (c : Basis κ ℚ (F.layer 2)) + (x : F.squareLieSubalgebra) (i : ι) : + (F.squareBasis b c).repr x (Sum.inl i) = b.repr x.val.2 i := by + simp [squareBasis, Basis.map_repr, squareCoordinates] + +theorem squareBasis_repr_inr (b : Basis ι ℚ L) (c : Basis κ ℚ (F.layer 2)) + (x : F.squareLieSubalgebra) (i : κ) : + (F.squareBasis b c).repr x (Sum.inr i) = + c.repr ⟨x.val.1 - x.val.2, (F.mem_squareLieSubalgebra x.val).mp x.property⟩ i := by + simp [squareBasis, Basis.map_repr, squareCoordinates] + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem mem_squareLayer_iff_second_and_difference (j : ℕ) (x : L × L) : + x ∈ F.squareLayer j ↔ x.2 ∈ F.layer j ∧ x.1 - x.2 ∈ F.layer (j + 1) := by + constructor + · exact fun h => h.2 + · intro h + refine ⟨?_, h.1, h.2⟩ + have hx := (F.layer j).add_mem (F.antitone (Nat.le_succ j) h.2) h.1 + simpa only [sub_add_cancel] using hx + +noncomputable def adaptedSquareBasis (b : Basis ι ℚ L) (w : ι → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) : + Basis (ι ⊕ {i // 2 ≤ w i}) ℚ F.squareLieSubalgebra := + F.squareBasis b (supportedSubmoduleBasis b (F.layer 2) {i | 2 ≤ w i} h) + +@[simp] theorem adaptedSquareBasis_inl (b : Basis ι ℚ L) (w : ι → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) (i : ι) : + (F.adaptedSquareBasis b w h (Sum.inl i)).val = (b i, b i) := + F.squareBasis_inl b _ i + +@[simp] theorem adaptedSquareBasis_inr (b : Basis ι ℚ L) (w : ι → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) (i : {i // 2 ≤ w i}) : + (F.adaptedSquareBasis b w h (Sum.inr i)).val = (b i, 0) := by + simp only [adaptedSquareBasis, F.squareBasis_inr] + apply Prod.ext + · exact supportedSubmoduleBasis_coe b (F.layer 2) {i | 2 ≤ w i} h i + · rfl + +def squareBasisWeight (w : ι → ℕ) : (ι ⊕ {i // 2 ≤ w i}) → ℕ := + Sum.elim w (fun i => w i - 1) + +theorem adaptedSquareBasis_layers (b : Basis ι ℚ L) (w : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) (j : ℕ) : + F.squareFiltration.layer j = Submodule.span ℚ + (F.adaptedSquareBasis b w (hlayers 2) '' {i | j ≤ squareBasisWeight w i}) := by + have hmem (k : ℕ) (x : L) : x ∈ F.layer k ↔ ∀ i, ¬ k ≤ w i → b.repr x i = 0 := by + rw [hlayers k, basis_mem_span_image_iff] + rfl + ext x + rw [F.mem_squareFiltration_layer, F.mem_squareLayer_iff_second_and_difference, + basis_mem_span_image_iff, hmem, hmem] + constructor + · rintro ⟨hy, hz⟩ i hi + cases i with + | inl i => + change (F.squareBasis b _).repr x (Sum.inl i) = 0 + rw [F.squareBasis_repr_inl] + exact hy i hi + | inr i => + change (F.squareBasis b _).repr x (Sum.inr i) = 0 + rw [F.squareBasis_repr_inr, supportedSubmoduleBasis_repr] + exact hz i (by change ¬ j ≤ w i - 1 at hi; have := i.property; omega) + · intro hx + constructor + · intro i hi + have hh := hx (Sum.inl i) hi + change (F.squareBasis b _).repr x (Sum.inl i) = 0 at hh + simpa only [F.squareBasis_repr_inl] using hh + · intro i hi + by_cases h2 : 2 ≤ w i + · have hsmall : ¬ j ≤ squareBasisWeight w (Sum.inr (⟨i, h2⟩ : {i // 2 ≤ w i})) := by + change ¬ j ≤ w i - 1 + omega + have hh := hx (Sum.inr ⟨i, h2⟩) hsmall + change (F.squareBasis b _).repr x + (Sum.inr (⟨i, h2⟩ : {i // 2 ≤ w i})) = 0 at hh + rw [F.squareBasis_repr_inr] at hh + exact (supportedSubmoduleBasis_repr b (F.layer 2) {i | 2 ≤ w i} + (hlayers 2) _ (⟨i, h2⟩ : {i // 2 ≤ w i})).symm.trans hh + · exact (hmem 2 (x.val.1 - x.val.2)).mp + ((F.mem_squareLieSubalgebra x.val).mp x.property) i h2 + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + +abbrev QuotientTopBasisIndex (s : ℕ) (ω : ι → ℕ) := {i : ι // ¬ s + 1 ≤ ω i} + +variable (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +noncomputable def quotientTopBasis : + Basis (QuotientTopBasisIndex s ω) ℚ (L ⧸ F.layerIdeal (s + 1)) := + supportedQuotientBasis e (F.layerIdeal (s + 1)).toSubmodule {i | s + 1 ≤ ω i} (hF (s + 1)) + +@[simp] theorem quotientTopBasis_apply (i : QuotientTopBasisIndex s ω) : + F.quotientTopBasis e ω hF i = lieQuotientMap (F.layerIdeal (s + 1)) (e i.val) := + supportedQuotientBasis_apply e _ _ _ i + +theorem quotientTopBasis_repr_mk (x : L) (i : QuotientTopBasisIndex s ω) : + (F.quotientTopBasis e ω hF).repr (lieQuotientMap (F.layerIdeal (s + 1)) x) i = e.repr x i.val := + supportedQuotientBasis_repr_mk e _ _ _ x i + +theorem quotientTopBasis_layers (j : ℕ) : + F.quotientTop.layer j = Submodule.span ℚ + (F.quotientTopBasis e ω hF '' {i | j ≤ ω i.val}) := + F.supportedQuotientBasis_layers e ω hF (F.layerIdeal (s + 1)) le_rfl + {i | s + 1 ≤ ω i} (hF (s + 1)) j + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) + +noncomputable def reducedSquareSnd : + (F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)) →ₗ⁅ℚ⁆ + (L ⧸ F.layerIdeal (s + 1)) := + lieQuotientDescend (F.squareFiltration.layerIdeal (s + 1)) + ((lieQuotientMap (F.layerIdeal (s + 1))).comp F.squareSnd) (by + intro x hx + exact (lieQuotientMap_eq_zero _ _).mpr hx.2.1) + +noncomputable def reducedSquareDiagonal : + (L ⧸ F.layerIdeal (s + 1)) →ₗ⁅ℚ⁆ + (F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)) := + lieQuotientDescend (F.layerIdeal (s + 1)) + ((lieQuotientMap (F.squareFiltration.layerIdeal (s + 1))).comp F.squareDiagonalLie) (by + intro x hx + apply (lieQuotientMap_eq_zero _ _).mpr + exact ⟨hx, hx, by change x - x ∈ F.layer (s + 1 + 1); simp⟩) + +@[simp] theorem reducedSquareSnd_mk (x : F.squareLieSubalgebra) : + F.reducedSquareSnd (lieQuotientMap (F.squareFiltration.layerIdeal (s + 1)) x) = + lieQuotientMap (F.layerIdeal (s + 1)) (F.squareSnd x) := rfl + +@[simp] theorem reducedSquareDiagonal_mk (x : L) : + F.reducedSquareDiagonal (lieQuotientMap (F.layerIdeal (s + 1)) x) = + lieQuotientMap (F.squareFiltration.layerIdeal (s + 1)) (F.squareDiagonalLie x) := rfl + +@[simp] theorem reducedSquareSnd_diagonal (x : L ⧸ F.layerIdeal (s + 1)) : + F.reducedSquareSnd (F.reducedSquareDiagonal x) = x := by + obtain ⟨a, rfl⟩ := lieQuotientMap_surjective (F.layerIdeal (s + 1)) x + rfl + +theorem reducedSquareSnd_mem (j : ℕ) + (x : F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)) + (hx : x ∈ F.squareFiltration.quotientTop.layer j) : + F.reducedSquareSnd x ∈ F.quotientTop.layer j := by + obtain ⟨a, ha, rfl⟩ := hx + exact F.quotientLie_mem _ le_rfl ha.2.1 + +theorem reducedSquareDiagonal_mem (j : ℕ) (x : L ⧸ F.layerIdeal (s + 1)) + (hx : x ∈ F.quotientTop.layer j) : + F.reducedSquareDiagonal x ∈ F.squareFiltration.quotientTop.layer j := by + obtain ⟨a, ha, rfl⟩ := hx + apply F.squareFiltration.quotientLie_mem _ le_rfl + exact ⟨ha, ha, by change a - a ∈ F.layer (j + 1); simp⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module NilpotentLieBCHGroup + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +def squarePairMap : F.squareLieSubalgebra →ₗ⁅ℚ⁆ (Bool → L) := + liePiMap (fun i : Bool => cond i F.squareFst F.squareSnd) + +@[simp] theorem squarePairMap_false (x : F.squareLieSubalgebra) : F.squarePairMap x false = x.val.2 := rfl +@[simp] theorem squarePairMap_true (x : F.squareLieSubalgebra) : F.squarePairMap x true = x.val.1 := rfl + +theorem squarePairMap_injective : Function.Injective F.squarePairMap := by + intro x y h + apply Subtype.ext + exact Prod.ext (congrFun h true) (congrFun h false) + +theorem squareLattice_eq_pair_comap (Γ : Subgroup F.Group) : + F.squareLattice Γ = + (piBCHSubgroup (fun _ : Bool => F) (fun _ => Γ)).comap + (map (hnil := F.squareFiltration.lowerCentralSeries_eq_bot) + (hM := (pi (fun _ : Bool => F)).lowerCentralSeries_eq_bot) F.squarePairMap) := by + ext g + rw [F.mem_squareLattice, Subgroup.mem_comap, mem_piBCHSubgroup] + constructor + · intro h i + cases i + · exact h.2 + · exact h.1 + · intro h + exact ⟨h true, h false⟩ + +variable [Fintype ι] + +theorem card_squareBasis_index_le (w : ι → ℕ) : + Fintype.card (ι ⊕ {i // 2 ≤ w i}) ≤ 2 * Fintype.card ι := by + rw [Fintype.card_sum] + have h := Fintype.card_subtype_le (fun i => 2 ≤ w i) + omega + +omit [Fintype ι] in + +theorem adaptedSquareBasis_pairMap_height (b : Basis ι ℚ L) (w : ι → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) + (k : Σ _ : Bool, ι) (j : ι ⊕ {i // 2 ≤ w i}) : + RationalHeightLE ((Pi.basis (fun _ : Bool => b)).repr + (F.squarePairMap (F.adaptedSquareBasis b w h j)) k) 1 := by + rcases k with ⟨flag, i⟩ + rw [Pi.basis_repr] + cases j with + | inl j => + cases flag <;> + simpa only [squarePairMap_false, squarePairMap_true, adaptedSquareBasis_inl] using + basis_repr_height_one b j i + | inr j => + cases flag + · simp only [squarePairMap_false, adaptedSquareBasis_inr, map_zero, Finsupp.zero_apply] + exact rationalHeightLE_zero le_rfl + · simpa only [squarePairMap_true, adaptedSquareBasis_inr] using basis_repr_height_one b j i + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open VectorPolynomial + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (w : σ → ℕ) + +noncomputable def reducedSquareSndPolynomialMap : + F.squareFiltration.quotientTop.adaptedLieSubalgebra w →ₗ⁅ℚ⁆ + F.quotientTop.adaptedLieSubalgebra w := + F.squareFiltration.quotientTop.filteredPolynomialMap F.quotientTop + F.reducedSquareSnd F.reducedSquareSnd_mem w + +noncomputable def reducedSquareDiagonalPolynomialMap : + F.quotientTop.adaptedLieSubalgebra w →ₗ⁅ℚ⁆ + F.squareFiltration.quotientTop.adaptedLieSubalgebra w := + F.quotientTop.filteredPolynomialMap F.squareFiltration.quotientTop + F.reducedSquareDiagonal F.reducedSquareDiagonal_mem w + +noncomputable def reducedSquareSndSymbolMap : + F.squareFiltration.quotientTop.PolynomialSymbol w →ₗ⁅ℚ⁆ F.quotientTop.PolynomialSymbol w := + F.squareFiltration.quotientTop.filteredPolynomialSymbolMap F.quotientTop + F.reducedSquareSnd F.reducedSquareSnd_mem w + +noncomputable def reducedSquareDiagonalSymbolMap : + F.quotientTop.PolynomialSymbol w →ₗ⁅ℚ⁆ F.squareFiltration.quotientTop.PolynomialSymbol w := + F.quotientTop.filteredPolynomialSymbolMap F.squareFiltration.quotientTop + F.reducedSquareDiagonal F.reducedSquareDiagonal_mem w + +@[simp] theorem reducedSquareSndSymbolMap_symbol + (r : F.squareFiltration.quotientTop.adaptedLieSubalgebra w) : + F.reducedSquareSndSymbolMap w (F.squareFiltration.quotientTop.polynomialSymbolMap w r) = + F.quotientTop.polynomialSymbolMap w (F.reducedSquareSndPolynomialMap w r) := rfl + +@[simp] theorem reducedSquareDiagonalSymbolMap_symbol (p : F.quotientTop.adaptedLieSubalgebra w) : + F.reducedSquareDiagonalSymbolMap w (F.quotientTop.polynomialSymbolMap w p) = + F.squareFiltration.quotientTop.polynomialSymbolMap w (F.reducedSquareDiagonalPolynomialMap w p) := rfl + +@[simp] theorem reducedSquareSndPolynomialMap_diagonal (p : F.quotientTop.adaptedLieSubalgebra w) : + F.reducedSquareSndPolynomialMap w (F.reducedSquareDiagonalPolynomialMap w p) = p := by + apply Subtype.ext + apply coefficients.injective + apply Finsupp.ext + intro α + simp only [reducedSquareSndPolynomialMap, reducedSquareDiagonalPolynomialMap, + filteredPolynomialMap_coefficient, F.reducedSquareSnd_diagonal] + +@[simp] theorem reducedSquareSndSymbolMap_diagonal (x : F.quotientTop.PolynomialSymbol w) : + F.reducedSquareSndSymbolMap w (F.reducedSquareDiagonalSymbolMap w x) = x := by + obtain ⟨p, rfl⟩ := F.quotientTop.polynomialSymbolMap_surjective w x + rw [F.reducedSquareDiagonalSymbolMap_symbol, F.reducedSquareSndSymbolMap_symbol, + F.reducedSquareSndPolynomialMap_diagonal] + +theorem reducedSquareSndPolynomialMap_quotient (p : F.squareFiltration.adaptedLieSubalgebra w) : + F.reducedSquareSndPolynomialMap w (F.reducedSquarePolynomialMap w p) = + F.quotientTopPolynomialMap w (F.squareSndPolynomialMap w p) := by + apply Subtype.ext + apply coefficients.injective + apply Finsupp.ext + intro α + change coefficients (VectorPolynomial.map F.reducedSquareSnd.toLinearMap + (VectorPolynomial.map (lieQuotientMap (F.squareFiltration.layerIdeal (s + 1))).toLinearMap p.val)) α = + coefficients (VectorPolynomial.map (lieQuotientMap (F.layerIdeal (s + 1))).toLinearMap + (VectorPolynomial.map F.squareSnd.toLinearMap p.val)) α + simp only [coefficients_map] + rfl + +theorem reducedSquareDiagonalPolynomialMap_quotient (p : F.adaptedLieSubalgebra w) : + F.reducedSquareDiagonalPolynomialMap w (F.quotientTopPolynomialMap w p) = + F.reducedSquarePolynomialMap w (F.squareDiagonalPolynomialMap w p) := by + apply Subtype.ext + apply coefficients.injective + apply Finsupp.ext + intro α + change coefficients (VectorPolynomial.map F.reducedSquareDiagonal.toLinearMap + (VectorPolynomial.map (lieQuotientMap (F.layerIdeal (s + 1))).toLinearMap p.val)) α = + coefficients (VectorPolynomial.map (lieQuotientMap (F.squareFiltration.layerIdeal (s + 1))).toLinearMap + (VectorPolynomial.map F.squareDiagonalLie.toLinearMap p.val)) α + simp only [coefficients_map] + rfl + +theorem reducedSquareSndSymbolMap_quotient (x : F.squareFiltration.PolynomialSymbol w) : + F.reducedSquareSndSymbolMap w (F.reducedSquareSymbolMap w x) = + F.quotientTopSymbolMap w (F.squareSndSymbolMap w x) := by + obtain ⟨p, rfl⟩ := F.squareFiltration.polynomialSymbolMap_surjective w x + rw [F.reducedSquareSymbolMap_symbol, F.reducedSquareSndSymbolMap_symbol, + F.squareSndSymbolMap_symbol, F.quotientTopSymbolMap_symbol, + F.reducedSquareSndPolynomialMap_quotient] + +theorem reducedSquareDiagonalSymbolMap_quotient (x : F.PolynomialSymbol w) : + F.reducedSquareDiagonalSymbolMap w (F.quotientTopSymbolMap w x) = + F.reducedSquareSymbolMap w (F.squareDiagonalSymbolMap w x) := by + obtain ⟨p, rfl⟩ := F.polynomialSymbolMap_surjective w x + rw [F.quotientTopSymbolMap_symbol, F.reducedSquareDiagonalSymbolMap_symbol, + F.squareDiagonalSymbolMap_symbol, F.reducedSquareSymbolMap_symbol, + F.reducedSquareDiagonalPolynomialMap_quotient] + +theorem reducedSquareSymbolMap_surjective : Function.Surjective (F.reducedSquareSymbolMap w) := + F.squareFiltration.quotientTopSymbolMap_surjective w + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + +abbrev ReducedSquareBasisIndex (s : ℕ) (ω : ι → ℕ) := + QuotientTopBasisIndex s (squareBasisWeight ω) + +variable (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + +noncomputable def reducedSquareBasis : + Basis (ReducedSquareBasisIndex s ω) ℚ + (F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)) := + F.squareFiltration.quotientTopBasis (F.adaptedSquareBasis e ω (hF 2)) + (squareBasisWeight ω) (F.adaptedSquareBasis_layers e ω hF) + +theorem reducedSquareBasis_layers (j : ℕ) : + F.squareFiltration.quotientTop.layer j = Submodule.span ℚ + (F.reducedSquareBasis e ω hF '' {i | j ≤ squareBasisWeight ω i.val}) := + F.squareFiltration.quotientTopBasis_layers (F.adaptedSquareBasis e ω (hF 2)) + (squareBasisWeight ω) (F.adaptedSquareBasis_layers e ω hF) j + +theorem reducedSquareSnd_basis_height + (a : ReducedSquareBasisIndex s ω) (b : QuotientTopBasisIndex s ω) : + RationalHeightLE ((F.quotientTopBasis e ω hF).repr + (F.reducedSquareSnd (F.reducedSquareBasis e ω hF a)) b) 1 := by + dsimp only [reducedSquareBasis] + rw [F.squareFiltration.quotientTopBasis_apply, F.reducedSquareSnd_mk, F.quotientTopBasis_repr_mk] + rcases a with ⟨a, ha⟩ + cases a with + | inl i => + change RationalHeightLE (e.repr ((F.adaptedSquareBasis e ω (hF 2) (Sum.inl i)).val.2) b.val) 1 + rw [F.adaptedSquareBasis_inl] + exact basis_repr_height_one e i b.val + | inr i => + change RationalHeightLE (e.repr ((F.adaptedSquareBasis e ω (hF 2) (Sum.inr i)).val.2) b.val) 1 + rw [F.adaptedSquareBasis_inr, map_zero, Finsupp.zero_apply] + exact rationalHeightLE_zero le_rfl + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + +abbrev QuotientTopSymbolIndex (s : ℕ) (w : σ → ℕ) (ω : ι → ℕ) := + SymbolBasisIndex w (fun i : QuotientTopBasisIndex s ω => ω i.val) + +abbrev ReducedSquareSymbolIndex (s : ℕ) (w : σ → ℕ) (ω : ι → ℕ) := + SymbolBasisIndex w (fun i : ReducedSquareBasisIndex s ω => squareBasisWeight ω i.val) + +variable (F : NilpotentLieFiltration L (s + 1)) (e : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) (w : σ → ℕ) + +noncomputable def quotientTopSymbolBasis : + Basis (QuotientTopSymbolIndex s w ω) ℚ (F.quotientTop.PolynomialSymbol w) := + F.quotientTop.polynomialSymbolBasis (F.quotientTopBasis e ω hF) + (fun i => ω i.val) (F.quotientTopBasis_layers e ω hF) w + +noncomputable def reducedSquareSymbolBasis : + Basis (ReducedSquareSymbolIndex s w ω) ℚ (F.squareFiltration.quotientTop.PolynomialSymbol w) := + F.squareFiltration.quotientTop.polynomialSymbolBasis (F.reducedSquareBasis e ω hF) + (fun i => squareBasisWeight ω i.val) (F.reducedSquareBasis_layers e ω hF) w + +theorem reducedSquareSndSymbolMap_basis_height + (a : ReducedSquareSymbolIndex s w ω) (b : QuotientTopSymbolIndex s w ω) : + RationalHeightLE ((F.quotientTopSymbolBasis e ω hF w).repr + (F.reducedSquareSndSymbolMap w (F.reducedSquareSymbolBasis e ω hF w a)) b) 1 := + filteredPolynomialSymbolMap_basis_height F.squareFiltration.quotientTop F.quotientTop + (F.reducedSquareBasis e ω hF) (fun i => squareBasisWeight ω i.val) + (F.reducedSquareBasis_layers e ω hF) + (F.quotientTopBasis e ω hF) (fun i => ω i.val) (F.quotientTopBasis_layers e ω hF) + F.reducedSquareSnd F.reducedSquareSnd_mem w le_rfl + (fun i j => F.reducedSquareSnd_basis_height e ω hF j i) a b + +theorem reducedSquareSndSymbolMap_monomial_blocks + (a : ReducedSquareSymbolIndex s w ω) (b : QuotientTopSymbolIndex s w ω) + (hab : b.val.1 ≠ a.val.1) : + (F.quotientTopSymbolBasis e ω hF w).repr + (F.reducedSquareSndSymbolMap w (F.reducedSquareSymbolBasis e ω hF w a)) b = 0 := + filteredPolynomialSymbolMap_monomial_blocks F.squareFiltration.quotientTop F.quotientTop + (F.reducedSquareBasis e ω hF) (fun i => squareBasisWeight ω i.val) + (F.reducedSquareBasis_layers e ω hF) + (F.quotientTopBasis e ω hF) (fun i => ω i.val) (F.quotientTopBasis_layers e ω hF) + F.reducedSquareSnd F.reducedSquareSnd_mem w a b hab + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype ι] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem adaptedSquareBasis_structure_bound (b : Basis ι ℚ L) (w : ι → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) + {H : ℕ} (hH : 1 ≤ H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) H) + {p : ℝ} (hp : 0 ≤ p) (hd : 2 * (Fintype.card ι : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (i j k : ι ⊕ {i // 2 ≤ w i}) : + rationalLogHeight (lieStructureConstants (F.adaptedSquareBasis b w h) i j k) ≤ + (p + 2) ^ 11 := by + classical + have hB (i j) : RationalHeightLE + (LinearMap.toMatrix (F.adaptedSquareBasis b w h) (Pi.basis (fun _ : Bool => b)) + F.squarePairMap.toLinearMap i j) H := by + rw [LinearMap.toMatrix_apply] + exact (F.adaptedSquareBasis_pairMap_height b w h i j).mono hH + obtain ⟨_, _, _, hbr⟩ := exists_bounded_lie_embedding_retraction + (F.adaptedSquareBasis b w h) (Pi.basis (fun _ : Bool => b)) + F.squarePairMap F.squarePairMap_injective hH + (lie_pi_structure_height (fun _ : Bool => b) hH (fun _ => hc)) + hB + apply rationalLogHeight_le_of_height (hbr i j k) + apply rationalLieStructureHeight_inverse_budget _ _ _ hp + · simpa only [Fintype.card_sigma, Finset.sum_const, Finset.card_univ, + Fintype.card_bool, smul_eq_mul, Nat.cast_mul, Nat.cast_ofNat] using hd + · exact (Nat.cast_le.mpr (card_squareBasis_index_le w)).trans (by + simpa only [Nat.cast_mul, Nat.cast_ofNat] using hd) + · exact hHp + +theorem exists_adaptedSquareBasis_grid (b : Basis ι ℚ L) (w : ι → ℕ) + (h : F.layer 2 = Submodule.span ℚ (b '' {i | 2 ≤ w i})) + (Γ : Subgroup F.Group) {l : ℕ} (hl : 0 < l) + (hin : scaledIntegerGrid l ⊆ bchSubgroupCoordinates b Γ) + (hout : bchSubgroupCoordinates b Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : 2 * (Fintype.card ι : ℝ) ≤ p) + (hlp : (l : ℝ) ≤ Real.exp p) : + ∃ N : ℕ, 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates + (F.adaptedSquareBasis b w h) (F.squareLattice Γ) ∧ + bchSubgroupCoordinates (F.adaptedSquareBasis b w h) (F.squareLattice Γ) ⊆ + denominatorGrid N := by + classical + have hB (i j) : RationalHeightLE + (LinearMap.toMatrix (F.adaptedSquareBasis b w h) (Pi.basis (fun _ : Bool => b)) + F.squarePairMap.toLinearMap i j) 1 := by + rw [LinearMap.toMatrix_apply] + exact F.adaptedSquareBasis_pairMap_height b w h i j + rw [F.squareLattice_eq_pair_comap] + apply exists_bchSubgroup_comap_grid_exp_bound + (F.adaptedSquareBasis b w h) (Pi.basis (fun _ : Bool => b)) + F.squarePairMap F.squarePairMap_injective _ (H := 1) le_rfl hl + hB + (piBCHSubgroup_inner_grid (fun _ : Bool => F) (fun _ => b) (fun _ => Γ) l + (fun _ => hin)) + (piBCHSubgroup_outer_grid (fun _ : Bool => F) (fun _ => b) (fun _ => Γ) l + (fun _ => hout)) hp + · simpa only [Fintype.card_sigma, Finset.sum_const, Finset.card_univ, + Fintype.card_bool, smul_eq_mul, Nat.cast_mul, Nat.cast_ofNat] using hd + · exact (Nat.cast_le.mpr (card_squareBasis_index_le w)).trans (by + simpa only [Nat.cast_mul, Nat.cast_ofNat] using hd) + · simpa only [Nat.cast_one] using Real.one_le_exp hp + · exact hlp + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SquareFastKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/SquareFastKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..c64d98b6230af54743c6892723ca6d206c4fa71e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SquareFastKernel.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.Progressions.Estimates.SquareSymbolRelative + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (w : σ → ℕ) + (W : LieSubalgebra ℚ (F.squareFiltration.PolynomialSymbol w)) + +noncomputable def squareFastDiagonalSubalgebra : LieSubalgebra ℚ (F.PolynomialSymbol w) := + W.map (F.squareSndSymbolMap w) + +noncomputable def squareFastRelativeSubmodule : Submodule ℚ (F.squareFiltration.PolynomialSymbol w) := + W.toSubmodule ⊓ (F.squareSndSymbolMap w).ker.toSubmodule + +theorem squareFastRelative_lie_eq_zero (hw : ∀ i, 0 < w i) + {v z : F.squareFiltration.PolynomialSymbol w} + (hv : v ∈ F.squareFastRelativeSubmodule w W) (hz : z ∈ F.squareFastRelativeSubmodule w W) : + ⁅v, z⁆ = 0 := F.squareSndSymbolKernel_lie_eq_zero w hw hv.2 hz.2 + +theorem squareFastRelative_action_mem (hw : ∀ i, 0 < w i) + {u : F.PolynomialSymbol w} (hu : u ∈ F.squareFastDiagonalSubalgebra w W) + {v : F.squareFiltration.PolynomialSymbol w} (hv : v ∈ F.squareFastRelativeSubmodule w W) : + ⁅F.squareDiagonalSymbolMap w u, v⁆ ∈ F.squareFastRelativeSubmodule w W := by + obtain ⟨x, hx, hxu⟩ := hu + change F.squareSndSymbolMap w x = u at hxu + have hk : F.squareSndSymbolMap w (x - F.squareDiagonalSymbolMap w u) = 0 := by + rw [map_sub, F.squareSndSymbolMap_diagonal, hxu, sub_self] + have hbracket := F.squareSndSymbolKernel_lie_eq_zero w hw hk hv.2 + rw [sub_lie] at hbracket + have he := sub_eq_zero.mp hbracket + constructor + · rw [← he] + exact W.lie_mem hx hv.1 + · change F.squareSndSymbolMap w ⁅F.squareDiagonalSymbolMap w u, v⁆ = 0 + rw [LieHom.map_lie, F.squareSndSymbolMap_diagonal, show F.squareSndSymbolMap w v = 0 from hv.2, + lie_zero] + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SquareSymbolProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/SquareSymbolProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3947e0fbcbb5f7a4426f620483da46ba50ac7d7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SquareSymbolProjection.lean @@ -0,0 +1,162 @@ +import Mathlib.LinearAlgebra.Isomorphisms +import OAI.Combinatorics.Progressions.Polynomial.RelativeSquarePolynomial + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open VectorPolynomial + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (w : σ → ℕ) + +noncomputable def filteredFirstJetConstant : F.FilteredFirstJet w →ₗ[ℚ] L ⧸ F.layer 2 := + (F.shiftedPolynomialIdeal w 2).toSubmodule.liftQ + ((F.layer 2).mkQ.comp (F.adaptedCoefficientMap w 0)) (by + intro p hp + apply (Submodule.Quotient.mk_eq_zero _).mpr + change coefficients p.val 0 ∈ F.layer 2 + have hc : coefficients p.val 0 ∈ F.layer (Finsupp.weight w 0 + 2) := hp 0 + simpa only [map_zero, Nat.zero_add] using hc) + +@[simp] theorem filteredFirstJetConstant_map (p : F.adaptedLieSubalgebra w) : + F.filteredFirstJetConstant w (F.filteredFirstJetMap w p) = + (F.layer 2).mkQ (coefficients p.val 0) := rfl + +noncomputable def normalizedFirstJetKernel : Submodule ℚ (F.FilteredFirstJet w) := + LinearMap.ker (F.filteredFirstJetSymbol w).toLinearMap ⊓ LinearMap.ker (F.filteredFirstJetConstant w) + +theorem normalizedRelativeFirstJet_range : + LinearMap.range (F.normalizedRelativeFirstJet w) = F.normalizedFirstJetKernel w := by + ext x + constructor + · rintro ⟨p, rfl⟩ + constructor + · change F.polynomialSymbolMap w p.val = 0 + exact (F.polynomialSymbolMap_eq_zero_iff w p.val).mpr p.property.1 + · change (F.layer 2).mkQ (coefficients p.val.val 0) = 0 + exact (Submodule.Quotient.mk_eq_zero _).mpr p.property.2 + · intro hx + obtain ⟨p, rfl⟩ := F.filteredFirstJetMap_surjective w x + have hp : p ∈ F.shiftedAdaptedIdeal w := + (F.polynomialSymbolMap_eq_zero_iff w p).mp hx.1 + have hzero : coefficients p.val 0 ∈ F.layer 2 := + (Submodule.Quotient.mk_eq_zero _).mp hx.2 + exact ⟨⟨p, hp, hzero⟩, rfl⟩ + +variable (hw : ∀ i, 0 < w i) + +theorem relativeSquareSymbolMap_ker : + LinearMap.ker (F.normalizedRelativeFirstJet w) = LinearMap.ker (F.relativeSquareSymbolMap w hw) := by + ext p + change F.normalizedRelativeFirstJet w p = 0 ↔ F.relativeSquareSymbolMap w hw p = 0 + simpa only [map_zero] using (F.relativeSquareSymbolMap_eq_iff w hw p 0).symm + +noncomputable def relativeFirstJetRangeEquiv : + LinearMap.range (F.normalizedRelativeFirstJet w) ≃ₗ[ℚ] + LinearMap.range (F.relativeSquareSymbolMap w hw) := + (F.normalizedRelativeFirstJet w).quotKerEquivRange.symm.trans + ((Submodule.quotEquivOfEq _ _ (F.relativeSquareSymbolMap_ker w hw)).trans + (F.relativeSquareSymbolMap w hw).quotKerEquivRange) + +theorem relativeFirstJetRangeEquiv_apply (p : F.normalizedRelativeSubmodule w) : + (F.relativeFirstJetRangeEquiv w hw ⟨F.normalizedRelativeFirstJet w p, ⟨p, rfl⟩⟩ : + F.squareFiltration.PolynomialSymbol w) = F.relativeSquareSymbolMap w hw p := by + dsimp only [relativeFirstJetRangeEquiv, LinearEquiv.trans_apply] + rw [(F.normalizedRelativeFirstJet w).quotKerEquivRange_symm_apply_image p ⟨p, rfl⟩] + rfl + +noncomputable def normalizedRelativeKernelEquiv : + F.normalizedFirstJetKernel w ≃ₗ[ℚ] LinearMap.range (F.relativeSquareSymbolMap w hw) := + (LinearEquiv.ofEq _ _ (F.normalizedRelativeFirstJet_range w).symm).trans + (F.relativeFirstJetRangeEquiv w hw) + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open VectorPolynomial + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (w : σ → ℕ) + +noncomputable def squareSndSymbolMap : F.squareFiltration.PolynomialSymbol w →ₗ⁅ℚ⁆ F.PolynomialSymbol w := + F.squareFiltration.filteredPolynomialSymbolMap F F.squareSnd (fun _ _ hx => hx.2.1) w + +theorem squareSndSymbolMap_map_eq_zero_iff (r : F.squareFiltration.adaptedLieSubalgebra w) : + F.squareSndSymbolMap w (F.squareFiltration.polynomialSymbolMap w r) = 0 ↔ + ∀ α, (coefficients r.val α).val.2 ∈ F.layer (Finsupp.weight w α + 1) := by + change F.polynomialSymbolMap w + (F.squareFiltration.filteredPolynomialMap F F.squareSnd (fun _ _ hx => hx.2.1) w r) = 0 ↔ _ + rw [F.polynomialSymbolMap_eq_zero_iff] + change (∀ α, coefficients (VectorPolynomial.map F.squareSnd.toLinearMap r.val) α ∈ + F.layer (Finsupp.weight w α + 1)) ↔ _ + simp only [coefficients_map] + rfl + +variable (hw : ∀ i, 0 < w i) + +theorem squareSndSymbolMap_relative (p : F.normalizedRelativeSubmodule w) : + F.squareSndSymbolMap w (F.relativeSquareSymbolMap w hw p) = 0 := by + apply (F.squareSndSymbolMap_map_eq_zero_iff w (F.relativeSquareLift w hw p)).mpr + intro α + change (coefficients (F.relativeSquarePolynomial w hw p) α).val.2 ∈ _ + rw [F.relativeSquarePolynomial_coefficient] + exact (F.layer _).zero_mem + +theorem relativeSquareSymbolMap_range : + LinearMap.range (F.relativeSquareSymbolMap w hw) = (F.squareSndSymbolMap w).ker.toSubmodule := by + apply le_antisymm + · rintro x ⟨p, rfl⟩ + exact F.squareSndSymbolMap_relative w hw p + · intro x hx + obtain ⟨r, rfl⟩ := F.squareFiltration.polynomialSymbolMap_surjective w x + have hs : ∀ α, (coefficients r.val α).val.2 ∈ F.layer (Finsupp.weight w α + 1) := + (F.squareSndSymbolMap_map_eq_zero_iff w r).mp hx + let p : VectorPolynomial σ ℚ L := + VectorPolynomial.map F.squareFst.toLinearMap r.val - VectorPolynomial.map F.squareSnd.toLinearMap r.val + have hc (α : σ →₀ ℕ) : coefficients p α = + (coefficients r.val α).val.1 - (coefficients r.val α).val.2 := by + simp only [p, map_sub, Finsupp.sub_apply, coefficients_map] + rfl + have hp : ∀ α, coefficients p α ∈ F.layer (Finsupp.weight w α + 1) := by + intro α + rw [hc] + exact (r.property α).2.2 + have hpa : p ∈ F.adaptedLieSubalgebra w := + fun α => F.antitone (Nat.le_succ _) (hp α) + have hp0 : coefficients p 0 ∈ F.layer 2 := by + rw [hc] + exact (F.mem_squareLieSubalgebra _).mp (coefficients r.val 0).property + let q : F.normalizedRelativeSubmodule w := ⟨⟨p, hpa⟩, hp, hp0⟩ + refine ⟨q, ?_⟩ + apply (F.squareFiltration.polynomialSymbolMap_eq_iff w (F.relativeSquareLift w hw q) r).mpr + intro α + rw [map_sub, Finsupp.sub_apply] + change (coefficients (F.relativeSquarePolynomial w hw q) α).val - (coefficients r.val α).val ∈ + F.squareLayer (Finsupp.weight w α + 1) + rw [F.relativeSquarePolynomial_coefficient] + change (coefficients p α, (0 : L)) - (coefficients r.val α).val ∈ _ + rw [hc] + have he : ((coefficients r.val α).val.1 - (coefficients r.val α).val.2, (0 : L)) - + (coefficients r.val α).val = (-(coefficients r.val α).val.2, -(coefficients r.val α).val.2) := by + apply Prod.ext <;> dsimp <;> abel + rw [he] + exact ⟨(F.layer _).neg_mem (hs α), (F.layer _).neg_mem (hs α), by simp⟩ + +noncomputable def normalizedRelativeSquareKernelEquiv : + F.normalizedFirstJetKernel w ≃ₗ[ℚ] (F.squareSndSymbolMap w).ker := + (F.normalizedRelativeKernelEquiv w hw).trans + (LinearEquiv.ofEq _ _ (F.relativeSquareSymbolMap_range w hw)) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SquarefreeBasisPermutation.lean b/lean/OAI/Combinatorics/Progressions/Linear/SquarefreeBasisPermutation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d9634f6182432ff2ec0b57e26a5333f8d9ff83d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SquarefreeBasisPermutation.lean @@ -0,0 +1,132 @@ +import Mathlib.LinearAlgebra.StdBasis +import OAI.Combinatorics.Progressions.Estimates.SquarefreePermutationFiltration +import OAI.Combinatorics.Progressions.Linear.BasisGradedCoordinateBasis + +namespace OAI + +section + +namespace Erdos3.MultidegreeLieFiltration + +open Module + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) (π : ι → σ) + {κ : SquarefreeIndex ι → Type*} + (b : ∀ a, Basis (κ a) ℚ (F.squarefreeCoefficientLayer π a)) + +noncomputable def squarefreeBasis : Basis (Σ a, κ a) ℚ (F.SquarefreeAlgebra π) := + (Pi.basis b).map (F.squarefreeAlgebraEquiv π).symm + +theorem squarefreeBasis_repr (x : F.SquarefreeAlgebra π) (j : Σ a, κ a) : + (F.squarefreeBasis π b).repr x j = (b j.1).repr (F.squarefreeAlgebraEquiv π x j.1) j.2 := by + rfl + +theorem squarefreeBasis_coefficient_self (a : SquarefreeIndex ι) (j : κ a) : + squarefreePolynomialEquiv (F.squarefreeBasis π b ⟨a, j⟩).val a = (b a j).val := by + classical + change (F.squarefreeAlgebraEquiv π (F.squarefreeBasis π b ⟨a, j⟩) a).val = _ + simp only [squarefreeBasis, Basis.map_apply, LinearEquiv.apply_symm_apply, Pi.basis_apply, + Pi.single_eq_same] + +theorem squarefreeBasis_coefficient_ne (a c : SquarefreeIndex ι) (h : a ≠ c) (j : κ a) : + squarefreePolynomialEquiv (F.squarefreeBasis π b ⟨a, j⟩).val c = 0 := by + classical + change (F.squarefreeAlgebraEquiv π (F.squarefreeBasis π b ⟨a, j⟩) c).val = _ + simp only [squarefreeBasis, Basis.map_apply, LinearEquiv.apply_symm_apply, Pi.basis_apply, + Pi.single_eq_of_ne (Ne.symm h), ZeroMemClass.coe_zero] + +theorem squarefreeBasis_monomial (j : Σ a, κ a) : + (F.squarefreeBasis π b j).val = squarefreeMonomial j.1 (b j.1 j.2).val := by + apply squarefreePolynomialEquiv.injective + ext a + by_cases h : j.1 = a + · subst a + rw [F.squarefreeBasis_coefficient_self, squarefreePolynomialEquiv_monomial_self] + · rw [F.squarefreeBasis_coefficient_ne π b _ _ h, + squarefreePolynomialEquiv_monomial_ne _ _ h] + +end Erdos3.MultidegreeLieFiltration + +end + +section + +namespace Erdos3.MultidegreeLieFiltration + +open Module + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) (π : ι → σ) + {κ : SquarefreeIndex ι → Type*} + (b : ∀ a, Basis (κ a) ℚ (F.squarefreeCoefficientLayer π a)) + +theorem squarefreeSupport_eq_span (P : SquarefreeIndex ι → Prop) : + (squarefreeSupportModule P).comap (F.squarefreeAdaptedSubalgebra π).incl.toLinearMap = + Submodule.span ℚ (F.squarefreeBasis π b '' {j | P j.1}) := by + ext x + rw [basis_mem_span_image_iff] + constructor + · intro hx j hj + have hz : F.squarefreeAlgebraEquiv π x j.1 = 0 := Subtype.ext (hx j.1 hj) + rw [F.squarefreeBasis_repr, hz, map_zero, Finsupp.zero_apply] + · intro hx a ha + have hz : F.squarefreeAlgebraEquiv π x a = 0 := by + apply (b a).repr.injective + ext j + simpa only [F.squarefreeBasis_repr, map_zero, Finsupp.zero_apply] using hx ⟨a, j⟩ ha + exact congrArg Subtype.val hz + +noncomputable def squarefreeSupportedBasis (P : SquarefreeIndex ι → Prop) : + Basis {j : Σ a, κ a // P j.1} ℚ + ((squarefreeSupportModule P).comap (F.squarefreeAdaptedSubalgebra π).incl.toLinearMap) := + supportedSubmoduleBasis (F.squarefreeBasis π b) _ _ (F.squarefreeSupport_eq_span π b P) + +theorem squarefreeSupportedBasis_coe (P : SquarefreeIndex ι → Prop) + (j : {j : Σ a, κ a // P j.1}) : + (F.squarefreeSupportedBasis π b P j).val = F.squarefreeBasis π b j.val := + supportedSubmoduleBasis_coe _ _ _ _ j + +end Erdos3.MultidegreeLieFiltration + +end + +section + +namespace Erdos3.MultidegreeLieFiltration + +open Module + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) (π : ι → σ) + +theorem squarefreeCoefficientLayer_permute (e : ι ≃ ι) (he : ∀ i, π (e i) = π i) + (a : SquarefreeIndex ι) : + F.squarefreeCoefficientLayer π (SquarefreeIndex.permute e a) = F.squarefreeCoefficientLayer π a := by + classical + simp only [squarefreeCoefficientLayer, SquarefreeIndex.permute_zero_iff, + SquarefreeIndex.permute_blockDegree π e he a] + +theorem squarefreeBasis_permute + (b : ∀ U : Submodule ℚ L, Basis (Fin (finrank ℚ U)) ℚ U) + (e : ι ≃ ι) (he : ∀ i, π (e i) = π i) + (j : Σ a : SquarefreeIndex ι, Fin (finrank ℚ (F.squarefreeCoefficientLayer π a))) : + ∃ k, F.squarefreeBlockPermute π e he (F.squarefreeBasis π (fun a => b (F.squarefreeCoefficientLayer π a)) j) = + F.squarefreeBasis π (fun a => b (F.squarefreeCoefficientLayer π a)) k := by + have hex : ∃ k, + (b (F.squarefreeCoefficientLayer π (SquarefreeIndex.permute e j.1)) k).val = + (b (F.squarefreeCoefficientLayer π j.1) j.2).val := by + rw [F.squarefreeCoefficientLayer_permute π e he] + exact ⟨j.2, rfl⟩ + obtain ⟨k, hk⟩ := hex + refine ⟨⟨SquarefreeIndex.permute e j.1, k⟩, ?_⟩ + apply Subtype.ext + rw [F.squarefreeBlockPermute_apply, F.squarefreeBasis_monomial, squarefreePermute_monomial, + F.squarefreeBasis_monomial] + exact congrArg (squarefreeMonomial (SquarefreeIndex.permute e j.1)) hk.symm + +end Erdos3.MultidegreeLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/StableCountedKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/StableCountedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..46f5d1bdc9d203ff1d801dfee270b41ba2d3394d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/StableCountedKernel.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.Progressions.Lattices.ResidueBaselineBounds +import OAI.Combinatorics.Progressions.Lattices.StableResidueKernelTotal + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem stable_residue_counted_kernel_total {Ω ι σ : Type*} + [Fintype Ω] + [Fintype ι] [LinearOrder ι] [Fintype σ] [DecidableEq σ] + {h g : (σ → ℤ) → ℂ} {lo a : σ → ℤ} {N : σ → ℕ} {M : ℕ} {q : ι → ℕ} + [∀ i, NeZero (q i)] {j r b moment : ℕ} {level inc δ η τ L T P : ℝ} {K : Finset ι} + {base : ∀ i, σ → ZMod (q i)} + {X : {i // i ∉ K} → Type*} [∀ i, Fintype (X i)] [∀ i, DecidableEq (X i)] + (μ : ∀ i, FiniteProbabilityWeights (X i)) (p : FiniteProbabilityWeights Ω) + (F : Ω → ∀ i, X i) (sourceBase : ∀ i, X i) + (siteBase : ∀ i : {i // i ∉ K}, σ → ZMod (q i.val)) + {regK κ ε ξ shell sourceLog siteLog : ℝ} {w rem : Ω → ℝ} {cs : List (ProductCylinder X)} + (hchain : CylinderRemovalChain μ sourceBase p F regK τ j r w rem cs) + (hμ : ∀ i x, 0 < (μ i).weight x) (hregK : 1 ≤ regK) + (hw : ∀ z, 0 ≤ w z ∧ w z ≤ 1) (hrem : ∀ z, 0 ≤ rem z ∧ rem z ≤ 1) (hmass : p.mean rem ≤ τ) + (hstable : ResiduePrimeCoordinateStable g lo N M a q (j + r) δ K base) + (hupper : PrimeRefinementUpperBound h g lo N M a q (j + r) level inc δ K base) + (hM : 0 < M) (hpair : Pairwise (fun i k => (q i).Coprime (q k))) + (hcop : ∀ i ∉ K, M.Coprime (q i)) (u : ResiduePrimeCoordinateCell lo N M a q K base) + (hg : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (g z).re ∧ (g z).re ≤ 1) + (hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) + (hlevel : 0 < level) (hτ : 0 < τ) (hδ : δ ≤ τ / 8) (hinc : inc ≤ level * τ / 8) + (hη0 : 0 ≤ η) (hη : η < 1) (hητ : η ≤ τ / 8) (hηlevel : η ≤ level * τ / 8) + (hL : 0 ≤ L) (hT : 0 ≤ T) (hlower : Real.exp (-L) ≤ level) (hτinv : τ⁻¹ ≤ Real.exp T) + (hlog : L + T + 2 ≤ P) (hrP : ((j + r : ℕ) : ℝ) ≤ P) + (hmoment : 2 ≤ moment) (heven : Even moment) (hPq : P ≤ (moment : ℝ)) (hqP : (moment : ℝ) ≤ P + 2) + (hcount : (Fintype.card ι : ℝ) ≤ Real.exp P) + (hηsmall : η ≤ (1 / 2) * Real.exp (-((P + 3) ^ 3))) + (herror : ∀ S : Finset {i // i ∉ K}, S.card ≤ j + r → + 2 * (∑ k, ((∏ i ∈ S, q i.val : ℕ) : ℝ) / + residueIndexLength (lo k) (lo k + N k) (M.lcm (∏ i ∈ K, q i)) ((u.val k).val)) ≤ η) + (hclose : ProductMarginalsClose (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val)) + (residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) (fun k => (u.val k).val) + (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) (fun _ => 1)) η + (max ((j + r) * (moment + 1)) (2 * b + j))) + (hgram : 2 * η * ((lowDegreeCoordinateSets {i // i ∉ K} b).card : ℝ) ^ 2 * + (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ 1) + (hsourceclose : ProductMarginalsClose μ (observedProductDensity μ p F (fun _ => 1)) η + (max ((j + r) * (moment + 1)) (2 * b + j))) + (hresGram : 2 * η * ((lowDegreeCoordinateSets {i // i ∉ K} b).card : ℝ) ^ 2 * + (4 : ℝ) ^ b * (1 + η) ^ 2 ≤ τ) + (kernel : ∀ i : {i // i ∉ K}, X i → FiniteProbabilityWeights (σ → ZMod (q i.val))) + (C : {i // i ∉ K} → ℝ) (hC : ∀ i, 0 ≤ C i) + (hbound : ∀ i : {i // i ∉ K}, ∀ f : (σ → ZMod (q i.val)) → ℝ, + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) i).mean f = 0 → + (μ i).mean (fun x => (kernel i x).mean f ^ 2) ≤ C i * + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) i).mean (fun y => f y ^ 2)) + (hK : ∀ i : {i // i ∉ K}, ∀ f : (σ → ZMod (q i.val)) → ℝ, (μ i).mean (fun x => (kernel i x).mean f) = + (primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) i).mean f) + (hε : 0 ≤ ε) (hξ : 0 < ξ) (hξ1 : ξ ≤ 1) (hslack : ξ * (2 + ε) ≤ ε) + (hκ0 : 0 ≤ κ) (hκhalf : κ ≤ 1 / 2) (hcap : ∀ i, C i ≤ κ ^ 2) + (hlow : κ * (8 * (1 + regK) * (P + 2)) ^ 2 * (16 * (P + 2)) ^ 2 ≤ ξ / 16) + (hrtail : CyclicCrootSisask.spectralIterations ξ (L + 2 * T + 4) ≤ r) (hrb : j + r ≤ b) + (hshell : 0 < shell) (hb : j + CyclicCrootSisask.spectralIterations shell ((j : ℝ) * (P + sourceLog + siteLog + 2) + ε + L + 2 * T + 10) ≤ b) + (hlevel2 : level ≤ 2) (hτ1 : τ ≤ 1) + (hsourceLog : 0 ≤ sourceLog) (hsiteLog : 0 ≤ siteLog) + (hsourceAlphabet : ∀ i, (Fintype.card (X i) : ℝ) ≤ Real.exp sourceLog) + (hsiteAlphabet : ∀ i : {i // i ∉ K}, (Fintype.card (σ → ZMod (q i.val)) : ℝ) ≤ Real.exp siteLog) : + let density := fun f => residuePrimeCoordinateDensity lo N (M.lcm (∏ i ∈ K, q i)) + (fun k => (u.val k).val) (residuePrimeCoordinateCell_lcm_nonempty lo N M a q hpair K base u) + (fun i : {i // i ∉ K} => q i.val) f + let ν := primeCoordinateReference (σ := σ) (fun i : {i // i ∉ K} => q i.val) + let c := fun i => FiniteProbabilityCoupling.ofKernel (μ i) (ν i) (kernel i) (hK i) + productTruncatedPairing c (lowDegreeCoordinateSets {i // i ∉ K} b) (observedProductDensity μ p F w) + (fun z => density (fun x => (h x).re) z - (1 + ε) * level * density (fun x => (g x).re) z) ≤ + level * (1 + 2 * ε) * τ + shell / 16 + Real.sqrt (3 * τ) * (3 + (1 + ε) * level * 3) := by + have hP : 0 ≤ P := (Nat.cast_nonneg (j + r)).trans hrP + have houtside : (Fintype.card {i // i ∉ K} : ℝ) ≤ Real.exp P := + (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans hcount + have hv0 := residuePrimeCoordinateMean_re_nonneg g lo N M a q K base (fun z hz => (hg z hz).1) + have hv1 := residuePrimeCoordinateMean_re_le_one g lo N M a q K base hg + have hbudget := hchain.shell_prefactor_le_exp (Y := fun i : {i // i ∉ K} => σ → ZMod (q i.val)) (L := L) + hμ hw hτ hτ1 hη.le (ProductMarginalsClose.mono μ hsourceclose (by omega)) + hP hsourceLog hsiteLog houtside hsourceAlphabet hsiteAlphabet hlevel.le hlevel2 hv0 hv1 hε hτinv + exact stable_residue_kernel_total μ p F sourceBase siteBase hchain hμ hregK hw hrem hmass + hstable hupper hM hpair hcop u hg hh hlevel hτ hδ hinc hη0 hη hητ hηlevel hL hT hlower hτinv + hlog hrP hmoment heven hPq hqP hcount hηsmall herror hclose hgram hsourceclose hresGram + kernel C hC hbound hK hε hξ hξ1 hslack hκ0 hκhalf hcap hlow hrtail hrb hshell hb hbudget + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/StepDropBasisBudget.lean b/lean/OAI/Combinatorics/Progressions/Linear/StepDropBasisBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e857af4b289b1282a33b1f6cbc53cce797ba369 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/StepDropBasisBudget.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Progressions.Linear.RankQuotientHeightBudget + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem stepDropBracketHeight_le_exp (n H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + (stepDropBracketHeight n H : ℝ) ≤ Real.exp ((p + 2) ^ 5) := by + have hh : (H : ℝ) * H ≤ Real.exp (2 * p) := by + rw [show 2 * p = p + p by ring, Real.exp_add] + exact mul_le_mul hH hH (Nat.cast_nonneg _) (Real.exp_nonneg _) + have hpow := pow_le_pow_left₀ (mul_nonneg (Nat.cast_nonneg H) (Nat.cast_nonneg H)) hh (n ^ 2) + rw [← Real.exp_nat_mul] at hpow + have hinner : (((n ^ 2 + 1) * (H * H) ^ (n ^ 2)) * H : ℕ) ≤ + Real.exp ((n : ℝ) ^ 2 + n ^ 2 * (2 * p) + p) := by + push_cast + rw [Real.exp_add, Real.exp_add] + apply mul_le_mul _ hH (Nat.cast_nonneg H) (by positivity) + exact mul_le_mul (Real.add_one_le_exp ((n : ℝ) ^ 2)) + (by simpa only [Nat.cast_pow] using hpow) (by positivity) (Real.exp_nonneg _) + have hout := pow_le_pow_left₀ + (Nat.cast_nonneg (((n ^ 2 + 1) * (H * H) ^ (n ^ 2)) * H)) hinner n + rw [← Real.exp_nat_mul] at hout + have htotal : (stepDropBracketHeight n H : ℝ) ≤ + Real.exp ((n : ℝ) + n * (n ^ 2 + n ^ 2 * (2 * p) + p)) := by + unfold stepDropBracketHeight + rw [Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_pow, Real.exp_add] + exact mul_le_mul (Real.add_one_le_exp n) hout (by positivity) (Real.exp_nonneg _) + apply htotal.trans (Real.exp_le_exp.mpr ?_) + calc + (n : ℝ) + n * (n ^ 2 + n ^ 2 * (2 * p) + p) ≤ + p + p * (p ^ 2 + p ^ 2 * (2 * p) + p) := by gcongr + _ ≤ (p + 2) ^ 5 := by + have h : 0 ≤ p ^ 5 + 8 * p ^ 4 + 39 * p ^ 3 + 79 * p ^ 2 + 79 * p + 32 := by positivity + nlinarith + +theorem exists_stepDrop_basis_uniform_budget : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {L μ υ χ κ ν : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype μ] [Fintype υ] [Fintype χ] [Fintype κ] [Fintype ν] + (b : Basis μ ℚ L) (w : μ → ℕ) (U : LieSubalgebra ℚ L) (V K : Submodule ℚ L) + (fU : Basis υ ℚ (L ⧸ U.toSubmodule)) (fK : Basis χ ℚ (L ⧸ K)) + (fV : Basis ν ℚ (L ⧸ V)) (eK : Basis κ ℚ K) {H : ℕ} (_hH : 1 ≤ H) + (_hU : ∀ i j, RationalHeightLE (fU.repr (U.toSubmodule.mkQ (b j)) i) H) + (_hK : ∀ i j, RationalHeightLE (fK.repr (K.mkQ (b j)) i) H) + (_hV : ∀ i j, RationalHeightLE (fV.repr (V.mkQ (b j)) i) H) + (_heK : ∀ i j, RationalHeightLE (b.repr (eK j : L) i) H) + (_hstructure : ∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) + {p : ℝ} (_hp : 0 ≤ p) + (_hμ : (Fintype.card μ : ℝ) ≤ p) (_hυ : (Fintype.card υ : ℝ) ≤ p) + (_hχ : (Fintype.card χ : ℝ) ≤ p) (_hκ : (Fintype.card κ : ℝ) ≤ p) + (_hν : (Fintype.card ν : ℝ) ≤ p) (_hHp : (H : ℝ) ≤ Real.exp p), + ∃ e : Basis (Fin (Module.finrank ℚ (stepDropSubmodule b w U V K))) + ℚ (stepDropSubmodule b w U V K), ∀ i j, + (((b.repr (e i : L) j).num.natAbs : ℝ) ≤ Real.exp ((p + C) ^ C)) ∧ + (((b.repr (e i : L) j).den : ℝ) ≤ Real.exp ((p + C) ^ C)) := by + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (((Polynomial.X + 2) ^ 5 + 2) ^ 9) + refine ⟨C, hC, ?_⟩ + intro L μ υ χ κ ν _ _ _ _ _ _ _ b w U V K fU fK fV eK H hH hU hK hV heK hstructure + p hp hμ hυ hχ hκ hν hHp + let q := (p + 2) ^ 5 + let J := max H (stepDropBracketHeight (Fintype.card μ) H) + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + have hp2 : p ≤ p + 2 := by linarith + apply hp2.trans + simpa only [pow_one] using pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + 2) (by decide : 1 ≤ 5) + have hrows : (Fintype.card (StepDropRow υ χ κ ν) : ℝ) ≤ q := by + simp only [StepDropRow, Fintype.card_sum, Fintype.card_prod, Nat.cast_add, Nat.cast_mul] + have hprod : (Fintype.card κ : ℝ) * Fintype.card ν ≤ p * p := + mul_le_mul hκ hν (Nat.cast_nonneg _) hp + have hpoly : p ^ 2 + 3 * p ≤ (p + 2) ^ 5 := by + have h : 0 ≤ p ^ 5 + 10 * p ^ 4 + 40 * p ^ 3 + 79 * p ^ 2 + 77 * p + 32 := by positivity + nlinarith + dsimp [q] + nlinarith + have hJ : 1 ≤ J := hH.trans (Nat.le_max_left _ _) + have hJq : (J : ℝ) ≤ Real.exp q := by + rw [Nat.cast_max] + exact max_le (hHp.trans (Real.exp_le_exp.mpr hpq)) + (stepDropBracketHeight_le_exp (Fintype.card μ) H hp hμ hHp) + obtain ⟨e, he⟩ := exists_stepDrop_basis_exp_height b w U V K fU fK fV eK hJ + (fun i j => (hU i j).mono (Nat.le_max_left _ _)) + (fun i j => (hK i j).mono (Nat.le_max_left _ _)) + (fun i j => (hV i j).mono (Nat.le_max_left _ _)) + (fun i j z => (stepDrop_bracket_height b V K fV eK hV heK hstructure i j z).mono (Nat.le_max_right _ _)) + hq (hμ.trans hpq) hrows hJq + have hcap : (q + 2) ^ 9 ≤ (p + C) ^ C := by + simpa [q, Polynomial.eval₂_pow] using hbudget p hp + exact ⟨e, fun i j => ⟨(he i j).1.trans (Real.exp_le_exp.mpr hcap), + (he i j).2.trans (Real.exp_le_exp.mpr hcap)⟩⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/StepOneGradedKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/StepOneGradedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecca2fa9104c2edfa75eac31372312ea61897ce5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/StepOneGradedKernel.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Estimates.StepOneSymbolLinearPart + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L 1) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +noncomputable def stepOneGradedFrequency (η : L →ₗ[ℚ] ℚ) : F.AssociatedGraded →ₗ[ℚ] ℚ := + η.comp (F.stepOneGradedEquiv b ω hlayers).symm.toLinearEquiv.toLinearMap + +@[simp] theorem stepOneGradedFrequency_equiv (η : L →ₗ[ℚ] ℚ) (x : L) : + F.stepOneGradedFrequency b ω hlayers η (F.stepOneGradedEquiv b ω hlayers x) = η x := by + change η ((F.stepOneGradedEquiv b ω hlayers).symm (F.stepOneGradedEquiv b ω hlayers x)) = _ + rw [LieEquiv.symm_apply_apply] + +noncomputable def stepOneGradedKernel (η : L →ₗ[ℚ] ℚ) : LieSubalgebra ℚ F.AssociatedGraded := + F.associatedGradedFiltration.stepOneFrequencyKernel (F.stepOneGradedFrequency b ω hlayers η) + +theorem mem_stepOneGradedKernel (η : L →ₗ[ℚ] ℚ) (x : F.AssociatedGraded) : + x ∈ F.stepOneGradedKernel b ω hlayers η ↔ F.stepOneGradedFrequency b ω hlayers η x = 0 := Iff.rfl + +theorem stepOneGradedKernel_span {κ : Type*} (η : L →ₗ[ℚ] ℚ) (v : κ → L) + (hv : Submodule.span ℚ (Set.range v) = (F.stepOneFrequencyKernel η).toSubmodule) : + Submodule.span ℚ (Set.range (fun i => F.stepOneGradedEquiv b ω hlayers (v i))) = + (F.stepOneGradedKernel b ω hlayers η).toSubmodule := by + have hmap : (F.stepOneFrequencyKernel η).toSubmodule.map + (F.stepOneGradedEquiv b ω hlayers).toLinearEquiv.toLinearMap = + (F.stepOneGradedKernel b ω hlayers η).toSubmodule := by + ext y + constructor + · rintro ⟨x, hx, rfl⟩ + change F.stepOneGradedFrequency b ω hlayers η (F.stepOneGradedEquiv b ω hlayers x) = 0 + rw [F.stepOneGradedFrequency_equiv] + exact hx + · intro hy + refine ⟨(F.stepOneGradedEquiv b ω hlayers).symm y, hy, ?_⟩ + exact (F.stepOneGradedEquiv b ω hlayers).apply_symm_apply y + calc + _ = (Submodule.span ℚ (Set.range v)).map + (F.stepOneGradedEquiv b ω hlayers).toLinearEquiv.toLinearMap := by + rw [Submodule.map_span, ← Set.range_comp] + rfl + _ = _ := by rw [hv, hmap] + +theorem stepOne_gradedPieceProjection_mem_kernel (η : L →ₗ[ℚ] ℚ) (j : ℕ) + {x : L} (hx : x ∈ F.stepOneFrequencyKernel η) : + F.gradedPieceProjection b ω hlayers j x ∈ F.stepOneGradedKernel b ω hlayers η := by + rw [F.stepOne_gradedPieceProjection] + split_ifs + · change F.stepOneGradedFrequency b ω hlayers η (F.stepOneGradedEquiv b ω hlayers x) = 0 + rw [F.stepOneGradedFrequency_equiv] + exact hx + · exact (F.stepOneGradedKernel b ω hlayers η).zero_mem + +theorem stepOne_symbol_values_in_gradedKernel (η : L →ₗ[ℚ] ℚ) + (w : σ → ℕ) (p : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (hp : ∀ t : σ → ℝ, eval₂ t p ∈ realificationLieSubalgebra (F.stepOneFrequencyKernel η)) : + ∀ t : σ → ℝ, eval₂ t (F.realGradedSymbolPolynomial b ω hlayers w + (F.realSymbolOfPolynomial b ω hlayers w p)) ∈ + realificationLieSubalgebra (F.stepOneGradedKernel b ω hlayers η) := by + have hc := (eval₂_mem_iff_coefficients + (realificationLieSubalgebra (F.stepOneFrequencyKernel η)).toSubmodule p).mp hp + apply (eval₂_mem_iff_coefficients + (realificationLieSubalgebra (F.stepOneGradedKernel b ω hlayers η)).toSubmodule _).mpr + intro α + rw [F.realGradedSymbolPolynomial_coefficient_of_polynomial] + exact baseChange_mem_of_mapsTo (F.stepOneFrequencyKernel η).toSubmodule + (F.stepOneGradedKernel b ω hlayers η).toSubmodule + (F.gradedPieceProjection b ω hlayers (Finsupp.weight w α)) + (fun _ hx => F.stepOne_gradedPieceProjection_mem_kernel b ω hlayers η _ hx) (hc α) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SubmoduleQuotientSectionBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/SubmoduleQuotientSectionBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef6f1a1bbcd44a7517ac995b3dcc6dad14f7419d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SubmoduleQuotientSectionBasis.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.Progressions.Geometry.RealSubspaceCoordinateRetraction +import OAI.Combinatorics.Progressions.Geometry.SubmoduleQuotientCoordinates + +namespace OAI + +section + +namespace Erdos3 +open Module +open scoped Matrix TensorProduct + +theorem exists_submoduleQuotientSectionBasis_with_coordinates + {ι κ V : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + [AddCommGroup V] [Module ℚ V] + (b : Basis ι ℚ V) (U : Submodule ℚ V) (D : Matrix κ ι ℚ) (T : Matrix ι κ ℚ) + (hker : LinearMap.ker D.mulVecLin = U.map b.equivFun.toLinearMap) + (hDT : D * T = 1) : + ∃ (eQ : Basis κ ℚ (V ⧸ U)) (S : (V ⧸ U) →ₗ[ℚ] V), + Function.RightInverse S U.mkQ ∧ + Function.RightInverse (S.baseChange ℝ) (U.mkQ.baseChange ℝ) ∧ + (∀ i j, b.repr (S (eQ j)) i = T i j) ∧ + (∀ i j, (b.baseChange ℝ).repr (S.baseChange ℝ ((eQ.baseChange ℝ) j)) i = + (T i j : ℝ)) ∧ + ∀ j i, eQ.repr (U.mkQ (b i)) j = D j i := by + have hsurj : Function.Surjective D.mulVec := by + intro y + refine ⟨T *ᵥ y, ?_⟩ + rw [Matrix.mulVec_mulVec, hDT, Matrix.one_mulVec] + let eQ := submoduleQuotientCoordinateBasis b U D hker hsurj + let S : (V ⧸ U) →ₗ[ℚ] V := b.equivFun.symm.toLinearMap.comp + (T.mulVecLin.comp eQ.equivFun.toLinearMap) + have hright : Function.RightInverse S U.mkQ := by + intro y + change U.mkQ (b.equivFun.symm (T *ᵥ eQ.equivFun y)) = y + rw [← submoduleQuotientCoordinateEquiv_symm b U D hker hsurj T hDT] + exact (submoduleQuotientCoordinateEquiv b U D hker hsurj).symm_apply_apply y + have hentry (i : ι) (j : κ) : b.repr (S (eQ j)) i = T i j := by + change b.equivFun (b.equivFun.symm (T *ᵥ eQ.equivFun (eQ j))) i = T i j + rw [LinearEquiv.apply_symm_apply] + simp [Matrix.mulVec, dotProduct, Basis.equivFun_self] + refine ⟨eQ, S, hright, ?_, hentry, ?_, ?_⟩ + · have heq : U.mkQ.comp S = LinearMap.id := LinearMap.ext hright + have heqR := congrArg (fun f : (V ⧸ U) →ₗ[ℚ] (V ⧸ U) => f.baseChange ℝ) heq + rw [LinearMap.baseChange_comp, LinearMap.baseChange_id] at heqR + intro x + exact DFunLike.congr_fun heqR x + · intro i j + rw [scalarExtension_basis_coordinates, hentry] + · intro j i + have hmatrix := submoduleQuotientCoordinateBasis_matrix b U D hker hsurj + have h := congrFun (congrFun hmatrix j) i + simpa only [LinearMap.toMatrix_apply] using h + +theorem exists_submoduleQuotientSectionBasis + {ι κ V : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + [AddCommGroup V] [Module ℚ V] + (b : Basis ι ℚ V) (U : Submodule ℚ V) (D : Matrix κ ι ℚ) (T : Matrix ι κ ℚ) + (hker : LinearMap.ker D.mulVecLin = U.map b.equivFun.toLinearMap) + (hDT : D * T = 1) : + ∃ (eQ : Basis κ ℚ (V ⧸ U)) (S : (V ⧸ U) →ₗ[ℚ] V), + Function.RightInverse S U.mkQ ∧ + Function.RightInverse (S.baseChange ℝ) (U.mkQ.baseChange ℝ) ∧ + (∀ i j, b.repr (S (eQ j)) i = T i j) ∧ + ∀ i j, (b.baseChange ℝ).repr (S.baseChange ℝ ((eQ.baseChange ℝ) j)) i = + (T i j : ℝ) := by + obtain ⟨eQ, S, hright, hrightR, hentry, hentryR, _hcoord⟩ := + exists_submoduleQuotientSectionBasis_with_coordinates b U D T hker hDT + exact ⟨eQ, S, hright, hrightR, hentry, hentryR⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SubquadraticRankPayment.lean b/lean/OAI/Combinatorics/Progressions/Linear/SubquadraticRankPayment.lean new file mode 100644 index 0000000000000000000000000000000000000000..bac6cfd591d8834e79ca5d9c3706c6130a3597f8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SubquadraticRankPayment.lean @@ -0,0 +1,191 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics +import OAI.Combinatorics.Progressions.Dynamics.ReplacementCellPotential + +namespace OAI + +section + +namespace Erdos3 + +theorem affine_recurrence_le {f : ℕ → ℝ} {q B : ℝ} (hq : 1 < q) (hB : 0 ≤ B) + (hstep : ∀ n, f (n + 1) ≤ q * f n + B) (n : ℕ) : + f n ≤ q ^ n * (f 0 + B / (q - 1)) := by + have hq0 : 0 ≤ q := by linarith + have hden : q - 1 ≠ 0 := by linarith + have hoff : B + B / (q - 1) = q * (B / (q - 1)) := by + field_simp + ring + have h : f n + B / (q - 1) ≤ q ^ n * (f 0 + B / (q - 1)) := by + induction n with + | zero => simp + | succ n ih => + calc + f (n + 1) + B / (q - 1) ≤ q * f n + B + B / (q - 1) := + add_le_add (hstep n) le_rfl + _ = q * (f n + B / (q - 1)) := by rw [add_assoc, hoff, mul_add] + _ ≤ q * (q ^ n * (f 0 + B / (q - 1))) := + mul_le_mul_of_nonneg_left ih hq0 + _ = q ^ (n + 1) * (f 0 + B / (q - 1)) := by rw [pow_succ]; ring + exact (le_add_of_nonneg_right (div_nonneg hB (by linarith))).trans h + +theorem log_rank_step {R R' C q : ℝ} (hR : 1 ≤ R) (hR' : 0 < R') + (hC : 0 < C) (hq : 0 ≤ q) (hstep : R' ≤ C * (1 + R) ^ q) : + Real.log R' ≤ q * Real.log R + (Real.log C + q * Real.log 2) := by + have hR0 : 0 < R := by linarith + have hbase : 0 < 1 + R := by linarith + have hlog := Real.log_le_log hR' hstep + rw [Real.log_mul hC.ne' (Real.rpow_pos_of_pos hbase q).ne', Real.log_rpow hbase] at hlog + have hsum : Real.log (1 + R) ≤ Real.log 2 + Real.log R := by + rw [← Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) hR0.ne'] + apply Real.log_le_log hbase + linarith + have hmul := mul_le_mul_of_nonneg_left hsum hq + linarith + +theorem log_rank_recurrence_le {R : ℕ → ℝ} {C q : ℝ} + (hR : ∀ n, 1 ≤ R n) (hC : 1 ≤ C) (hq : 1 < q) + (hstep : ∀ n, R (n + 1) ≤ C * (1 + R n) ^ q) (n : ℕ) : + Real.log (R n) ≤ q ^ n * + (Real.log (R 0) + (Real.log C + q * Real.log 2) / (q - 1)) := by + apply affine_recurrence_le (f := fun n => Real.log (R n)) hq _ _ n + · exact add_nonneg (Real.log_nonneg hC) + (mul_nonneg (by linarith) (Real.log_nonneg (by norm_num))) + · intro n + exact log_rank_step (hR n) (by linarith [hR (n + 1)]) (by linarith) + (by linarith) (hstep n) + +theorem log_rank_at_selected_level {R : ℕ → ℝ} {C q K p : ℝ} + (hR : ∀ n, 1 ≤ R n) (hC : 1 ≤ C) (hq : 1 < q) + (hK : 1 < K) (hp : 1 ≤ p) + (hstep : ∀ n, R (n + 1) ≤ C * (1 + R n) ^ q) : + Real.log (R ⌊levelCoefficient K * Real.log p⌋₊) ≤ + p ^ (levelCoefficient K * Real.log q) * + (Real.log (R 0) + (Real.log C + q * Real.log 2) / (q - 1)) := by + apply (log_rank_recurrence_le hR hC hq hstep _).trans + apply mul_le_mul_of_nonneg_right + (pow_floor_log_le hq hp (levelCoefficient_pos hK).le) + exact add_nonneg (Real.log_nonneg (hR 0)) + (div_nonneg (add_nonneg (Real.log_nonneg hC) + (mul_nonneg (by linarith) (Real.log_nonneg (by norm_num)))) (by linarith)) + +theorem subquadratic_rank_exponents {K q : ℝ} (hK : 2 ≤ K) + (hq : 1 ≤ q) (hq2 : q < 2) : + let t := levelCoefficient K + let ν := gainExponent K + let μ := t * Real.log q + let β := 1 - (ν - μ) / 2 + 0 < t ∧ 0 < ν ∧ 0 ≤ μ ∧ μ < ν ∧ 1 / 4 < β ∧ β < 1 ∧ μ < β + ν - 1 := by + dsimp only + have ht := levelCoefficient_pos (show 1 < K by linarith) + obtain ⟨hν, hνq⟩ := gainExponent_pos_le_quarter hK + have hμ : 0 ≤ levelCoefficient K * Real.log q := + mul_nonneg ht.le (Real.log_nonneg hq) + have hμν : levelCoefficient K * Real.log q < gainExponent K := by + exact mul_lt_mul_of_pos_left + (Real.log_lt_log (by linarith : 0 < q) hq2) ht + refine ⟨ht, hν, hμ, hμν, ?_, ?_, ?_⟩ <;> linarith + +theorem density_invariant_with_general_loss {p p' L L' A C₀ loss β ν c : ℝ} + (hp : 0 < p) (hp' : 0 ≤ p') (hβ0 : 0 ≤ β) (hβ1 : β ≤ 1) (hA : 0 ≤ A) + (hinvariant : A * p ^ β + C₀ ≤ L) + (hdrop : p' ≤ p - c * p ^ ν) + (hlength : L - loss ≤ L') + (hpayment : loss ≤ A * (β * c * p ^ (β + ν - 1))) : + A * p' ^ β + C₀ ≤ L' := by + have hpotential := mul_le_mul_of_nonneg_left + (concave_power_drop hp hp' hβ0 hβ1 hdrop) hA + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem log_one_add_rank_recurrence {R : ℕ → ℝ} {C q : ℝ} + (hR : ∀ n, 0 ≤ R n) (hC : 0 ≤ C) (hq : 1 < q) + (hstep : ∀ n, R (n + 1) ≤ C * (1 + R n) ^ q) (n : ℕ) : + Real.log (1 + R n) ≤ q ^ n * (Real.log (1 + R 0) + Real.log (C + 1) / (q - 1)) := by + apply affine_recurrence_le (f := fun j => Real.log (1 + R j)) hq + (Real.log_nonneg (by linarith)) _ n + intro j + have hbase : 0 < 1 + R j := by linarith [hR j] + have hpow : 1 ≤ (1 + R j) ^ q := Real.one_le_rpow (by linarith [hR j]) (by linarith) + have hbound : 1 + R (j + 1) ≤ (C + 1) * (1 + R j) ^ q := by + nlinarith [hstep j] + have hl := Real.log_le_log (by linarith [hR (j + 1)]) hbound + rw [Real.log_mul (by linarith) (by positivity), Real.log_rpow hbase] at hl + linarith + +theorem log_one_add_rank_at_selected_level {R : ℕ → ℝ} {C q K p : ℝ} + (hR : ∀ n, 0 ≤ R n) (hC : 0 ≤ C) (hq : 1 < q) (hK : 1 < K) (hp : 1 ≤ p) + (hstep : ∀ n, R (n + 1) ≤ C * (1 + R n) ^ q) : + Real.log (1 + R ⌊levelCoefficient K * Real.log p⌋₊) ≤ + p ^ (levelCoefficient K * Real.log q) * + (Real.log (1 + R 0) + Real.log (C + 1) / (q - 1)) := by + apply (log_one_add_rank_recurrence hR hC hq hstep _).trans + apply mul_le_mul_of_nonneg_right (pow_floor_log_le hq hp (levelCoefficient_pos hK).le) + exact add_nonneg (Real.log_nonneg (by linarith [hR 0])) + (div_nonneg (Real.log_nonneg (by linarith)) (by linarith)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Filter + +theorem eventually_rpow_log_le {μ δ A B : ℝ} + (hgap : μ < δ) (hA : 0 < A) (hB : 0 < B) : + ∀ᶠ p : ℝ in atTop, B * p ^ μ * Real.log (2 + p) ≤ A * p ^ δ := by + have heps : 0 < A / (2 * B) := div_pos hA (by positivity) + have hsmall := (isLittleO_log_rpow_atTop (sub_pos.mpr hgap)).bound heps + filter_upwards [hsmall, eventually_ge_atTop (2 : ℝ)] with p hsmall hp + have hp0 : 0 < p := by linarith + have hlog0 : 0 ≤ Real.log p := Real.log_nonneg (by linarith) + have hpow0 : 0 ≤ p ^ (δ - μ) := Real.rpow_nonneg hp0.le _ + simp only [Real.norm_of_nonneg hlog0, Real.norm_of_nonneg hpow0] at hsmall + have hlog : Real.log (2 + p) ≤ 2 * Real.log p := by + rw [show 2 * Real.log p = Real.log (p * p) by rw [Real.log_mul hp0.ne' hp0.ne']; ring] + apply Real.log_le_log (by linarith) + nlinarith + have hco : 0 ≤ B * p ^ μ := mul_nonneg hB.le (Real.rpow_nonneg hp0.le _) + calc + B * p ^ μ * Real.log (2 + p) ≤ B * p ^ μ * (2 * Real.log p) := + mul_le_mul_of_nonneg_left hlog hco + _ = (2 * B * p ^ μ) * Real.log p := by ring + _ ≤ (2 * B * p ^ μ) * (A / (2 * B) * p ^ (δ - μ)) := + mul_le_mul_of_nonneg_left hsmall (by positivity) + _ = A * p ^ δ := by + have hpow : p ^ μ * p ^ (δ - μ) = p ^ δ := by + rw [← Real.rpow_add hp0] + congr 1 + ring + calc + _ = A * (p ^ μ * p ^ (δ - μ)) := by field_simp + _ = _ := by rw [hpow] + +theorem eventually_subquadratic_rank_loss_paid {K q A c B : ℝ} + (hK : 2 ≤ K) (hq : 1 ≤ q) (hq2 : q < 2) + (hA : 0 < A) (hc : 0 < c) (hB : 0 < B) : + let μ := levelCoefficient K * Real.log q + let ν := gainExponent K + let β := 1 - (ν - μ) / 2 + ∀ᶠ p : ℝ in atTop, + B * p ^ μ * Real.log (2 + p) ≤ A * (β * c * p ^ (β + ν - 1)) := by + dsimp only + obtain ⟨_, _, _, _, hβ, _, hgap⟩ := subquadratic_rank_exponents hK hq hq2 + have hcoef : 0 < A * ((1 - (gainExponent K - levelCoefficient K * Real.log q) / 2) * c) := + mul_pos hA (mul_pos (by linarith) hc) + simpa only [mul_assoc] using eventually_rpow_log_le hgap hcoef hB + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/SynchronizeSplittingProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/SynchronizeSplittingProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..034e7a7447a203932baa255f7782a2a08cd1ac2f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/SynchronizeSplittingProjection.lean @@ -0,0 +1,42 @@ +import OAI.Combinatorics.Progressions.Estimates.SplitGroupRelative + +namespace OAI + +section + +namespace Erdos3 + +variable {G Q : Type*} [Group G] [Group Q] + +theorem synchronize_splitting_projection (q : G →* Q) (H : Subgroup G) + (E P R a d : G) (A D : Q) (hP : P ∈ H) (ha : a ∈ H) (hd : d ∈ H) + (haq : q a = A⁻¹ * q E) (hdq : q d = q R * D⁻¹) : + (E * a⁻¹) * (a * P * d) * (d⁻¹ * R) = E * P * R ∧ + a * P * d ∈ H ∧ q (E * a⁻¹) = A ∧ q (d⁻¹ * R) = D ∧ + q (a * P * d) = A⁻¹ * q (E * P * R) * D⁻¹ := by + refine ⟨?_, H.mul_mem (H.mul_mem ha hP) hd, ?_, ?_, ?_⟩ + · group + · rw [map_mul, map_inv, haq] + group + · rw [map_mul, map_inv, hdq] + group + · simp only [map_mul, haq, hdq] + group + +theorem exists_synchronized_splitting (q : G →* Q) (H : Subgroup G) + (E P R : G) (A D : Q) (hP : P ∈ H) + (hleft : A⁻¹ * q E ∈ H.map q) (hright : q R * D⁻¹ ∈ H.map q) : + ∃ a d : G, a ∈ H ∧ d ∈ H ∧ q a = A⁻¹ * q E ∧ q d = q R * D⁻¹ ∧ + (E * a⁻¹) * (a * P * d) * (d⁻¹ * R) = E * P * R ∧ + a * P * d ∈ H ∧ q (E * a⁻¹) = A ∧ q (d⁻¹ * R) = D ∧ + q (a * P * d) = A⁻¹ * q (E * P * R) * D⁻¹ := by + obtain ⟨a, ha, haq⟩ := hleft + obtain ⟨d, hd, hdq⟩ := hright + exact ⟨a, d, ha, hd, haq, hdq, + synchronize_splitting_projection q H E P R a d A D hP ha hd haq hdq⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/TaggedSubmoduleBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/TaggedSubmoduleBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..be5070b8200ff35c08dccd5eb078226f87ed5e1c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/TaggedSubmoduleBasis.lean @@ -0,0 +1,89 @@ +import Mathlib.LinearAlgebra.StdBasis + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {R T : Type*} [Semiring R] {J I : T → Type*} + +def taggedSubmodule (U : ∀ t, Submodule R (J t → R)) : Submodule R ((Σ t, J t) → R) where + carrier := {x | ∀ t, (fun j => x ⟨t, j⟩) ∈ U t} + zero_mem' := fun t => (U t).zero_mem + add_mem' := fun hx hy t => (U t).add_mem (hx t) (hy t) + smul_mem' := fun c _ hx t => (U t).smul_mem c (hx t) + +@[simp] +theorem mem_taggedSubmodule (U : ∀ t, Submodule R (J t → R)) (x : (Σ t, J t) → R) : + x ∈ taggedSubmodule U ↔ ∀ t, (fun j => x ⟨t, j⟩) ∈ U t := Iff.rfl + +def taggedSubmoduleEquiv (U : ∀ t, Submodule R (J t → R)) : + (∀ t, U t) ≃ₗ[R] taggedSubmodule U where + toFun x := ⟨fun j => (x j.1 : J j.1 → R) j.2, fun t => (x t).property⟩ + invFun x := fun t => ⟨fun j => (x : (Σ t, J t) → R) ⟨t, j⟩, x.property t⟩ + left_inv x := by + funext t + apply Subtype.ext + rfl + right_inv x := by + apply Subtype.ext + funext j + rfl + map_add' x y := rfl + map_smul' c x := rfl + +@[simp] +theorem taggedSubmoduleEquiv_apply (U : ∀ t, Submodule R (J t → R)) + (x : ∀ t, U t) (t : T) (j : J t) : + (taggedSubmoduleEquiv U x : (Σ t, J t) → R) ⟨t, j⟩ = (x t : J t → R) j := rfl + +@[simp] +theorem taggedSubmoduleEquiv_symm_apply (U : ∀ t, Submodule R (J t → R)) + (x : taggedSubmodule U) (t : T) (j : J t) : + ((taggedSubmoduleEquiv U).symm x t : J t → R) j = + (x : (Σ t, J t) → R) ⟨t, j⟩ := rfl + +variable [Fintype T] + +noncomputable def taggedSubmoduleBasis (U : ∀ t, Submodule R (J t → R)) + (b : ∀ t, Basis (I t) R (U t)) : Basis (Σ t, I t) R (taggedSubmodule U) := + (Pi.basis b).map (taggedSubmoduleEquiv U) + +theorem taggedSubmoduleBasis_apply [DecidableEq T] + (U : ∀ t, Submodule R (J t → R)) (b : ∀ t, Basis (I t) R (U t)) + (t : T) (i : I t) (t' : T) (j : J t') : + (taggedSubmoduleBasis U b ⟨t, i⟩ : (Σ t, J t) → R) ⟨t', j⟩ = + ((Pi.single (M := fun t => U t) t (b t i) t' : U t') : J t' → R) j := by + rw [taggedSubmoduleBasis, Basis.map_apply, Pi.basis_apply] + rfl + +@[simp] +theorem taggedSubmoduleBasis_same + (U : ∀ t, Submodule R (J t → R)) (b : ∀ t, Basis (I t) R (U t)) + (t : T) (i : I t) (j : J t) : + (taggedSubmoduleBasis U b ⟨t, i⟩ : (Σ t, J t) → R) ⟨t, j⟩ = (b t i : J t → R) j := by + classical + rw [taggedSubmoduleBasis_apply, Pi.single_eq_same] + +theorem taggedSubmoduleBasis_of_ne + (U : ∀ t, Submodule R (J t → R)) (b : ∀ t, Basis (I t) R (U t)) + (t : T) (i : I t) (t' : T) (j : J t') (h : t' ≠ t) : + (taggedSubmoduleBasis U b ⟨t, i⟩ : (Σ t, J t) → R) ⟨t', j⟩ = 0 := by + classical + rw [taggedSubmoduleBasis_apply, Pi.single_eq_of_ne h] + rfl + +theorem taggedSubmoduleBasis_repr + (U : ∀ t, Submodule R (J t → R)) (b : ∀ t, Basis (I t) R (U t)) + (x : taggedSubmodule U) (t : T) (i : I t) : + (taggedSubmoduleBasis U b).repr x ⟨t, i⟩ = + (b t).repr ((taggedSubmoduleEquiv U).symm x t) i := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/TopSubspaceAdaptedBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/TopSubspaceAdaptedBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..78c62a26f5be051da201d5c3f6b283428e240922 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/TopSubspaceAdaptedBasis.lean @@ -0,0 +1,88 @@ +import OAI.Combinatorics.Progressions.Estimates.LowerStepSquare +import OAI.Combinatorics.Progressions.Linear.BoundedAdaptedBasis + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype ι] {s : ℕ} + +def topSubspaceIdeal (F : NilpotentLieFiltration L s) (K : Submodule ℚ L) + (hK : K ≤ F.layer s) : LieIdeal ℚ L := + { K with + lie_mem := by + intro x y hy + rw [← lie_skew, F.top_layer_central (hK hy) x, neg_zero] + exact K.zero_mem } + +theorem exists_bounded_adapted_basis_with_top_subspace + (F : NilpotentLieFiltration L s) (hs : 1 ≤ s) (e : Basis ι ℚ L) + {η : Fin (s + 1) → Type*} + (v : ∀ i, η i → F.layer (i.val + 1)) + (hspan : ∀ i, Submodule.span ℚ (Set.range (v i)) = ⊤) + (K : Submodule ℚ L) (hK : K ≤ F.layer s) {κ : Type*} (vK : κ → K) + (hspanK : Submodule.span ℚ (Set.range vK) = ⊤) {H : ℕ} + (hv : ∀ i j k, RationalHeightLE (e.repr (v i j : L) k) H) + (hvK : ∀ j k, RationalHeightLE (e.repr (vK j : L) k) H) : + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ) + (S : Set (Fin (finrank ℚ L))), + Monotone w ∧ IsCentralLieBasis b ∧ + (∀ j k, RationalHeightLE (e.repr (b j) k) H) ∧ + (∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) ∧ + K = Submodule.span ℚ (b '' S) := by + classical + let : FiniteDimensional ℚ L := e.finiteDimensional_of_finite + let bounded : Set L := {x | ∀ k, RationalHeightLE (e.repr x k) H} + let flag : Fin (s + 1) → Submodule ℚ L := fun i => if i.val < s then F.layer (i.val + 1) else K + have hflag : Antitone flag := by + intro i j hij + have hij' : i.val ≤ j.val := hij + dsimp only [flag] + split_ifs with hi hj + · exact F.antitone (Nat.add_le_add_right hij 1) + · omega + · exact hK.trans (F.antitone (by omega)) + · exact le_rfl + have hbounded (i : Fin (s + 1)) : + Submodule.span ℚ (bounded ∩ (flag i : Set L)) = flag i := by + dsimp only [flag] + split_ifs with hi + · exact span_inter_eq_of_spanning_family _ (v i) (hspan i) bounded (hv i) + · exact span_inter_eq_of_spanning_family K vK hspanK bounded hvK + have hzero : flag 0 = ⊤ := by + simpa only [flag, Fin.val_zero, show 0 < s by omega, ite_true, Nat.zero_add] using F.one_eq_top + have htotal : Submodule.span ℚ bounded = ⊤ := by + apply top_unique + rw [← hzero, ← hbounded 0] + exact Submodule.span_mono Set.inter_subset_left + obtain ⟨b, u, hu, hub, hbb, hbf⟩ := + exists_sorted_flag_basis_from_spanning_set flag hflag bounded htotal hbounded + let w := fun i => min s (u i) + have hw : Monotone w := fun i j hij => min_le_min le_rfl (hu hij) + have hlayers (i : Fin (s + 1)) : + F.layer (i.val + 1) = Submodule.span ℚ (b '' {j | i.val < w j}) := by + by_cases hi : i.val < s + · have h := hbf i + simp only [flag, hi, ite_true] at h + simpa only [w, lt_min_iff, hi, true_and] using h + · have his : i.val = s := by omega + rw [his, F.terminal] + have hempty : {j | s < w j} = (∅ : Set (Fin (finrank ℚ L))) := by + ext j + simp [w] + rw [hempty, Set.image_empty, Submodule.span_empty] + have hlayer := F.layer_eq_span_of_weighted_flag b w (fun j => + (min_le_left s (u j)).trans (Nat.le_succ s)) hlayers + refine ⟨b, w, {i | s < u i}, hw, + centralLieBasis_of_sorted_filtration F b w hw hlayer, hbb, hlayer, ?_⟩ + simpa only [flag, lt_self_iff_false, ite_false] using hbf ⟨s, Nat.lt_succ_self s⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/TripleProductBasisBounds.lean b/lean/OAI/Combinatorics/Progressions/Linear/TripleProductBasisBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc43661ff37fa797471b91bda31139183ef590d0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/TripleProductBasisBounds.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.Progressions.Nilpotent.NiltestBasepointNormalization + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +variable {ι : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + +noncomputable def productBasisWeight (weight : ∀ i, Fin (d i) → ℕ) + (k : Fin (Fintype.card (Σ i, Fin (d i)))) : ℕ := + let z := (Fintype.equivFin (Σ i, Fin (d i))).symm k + weight z.1 z.2 + +theorem productFinBasis_repr (x : ∀ i, L i) (k : Fin (Fintype.card (Σ i, Fin (d i)))) : + let z := (Fintype.equivFin (Σ i, Fin (d i))).symm k + (pi D).basis.repr x k = (D z.1).basis.repr (x z.1) z.2 := by + change (productFinBasis D).repr x k = _ + rw [productFinBasis, Basis.repr_reindex_apply, Pi.basis_repr] + +theorem pi_layer_span (weight : ∀ i, Fin (d i) → ℕ) + (hF : ∀ i n, (D i).filtration.layer n = + Submodule.span ℚ ((D i).basis '' {k | n ≤ weight i k})) (n : ℕ) : + (pi D).filtration.layer n = + Submodule.span ℚ ((pi D).basis '' {k | n ≤ productBasisWeight weight k}) := by + classical + ext x + change x ∈ (NilpotentLieFiltration.pi (fun i => (D i).filtration)).layer n ↔ _ + rw [NilpotentLieFiltration.mem_pi_layer] + constructor + · intro hx + apply (pi D).basis.mem_span_image.mpr + intro k hk + have hcoeff : (pi D).basis.repr x k ≠ 0 := Finsupp.mem_support_iff.mp hk + rw [productFinBasis_repr D] at hcoeff + let z := (Fintype.equivFin (Σ i, Fin (d i))).symm k + have hm := hx z.1 + rw [hF z.1 n] at hm + exact (D z.1).basis.mem_span_image.mp hm (Finsupp.mem_support_iff.mpr hcoeff) + · intro hx i + rw [hF i n] + apply (D i).basis.mem_span_image.mpr + intro k hk + let q := (Fintype.equivFin (Σ i, Fin (d i))) ⟨i, k⟩ + have hq : (Fintype.equivFin (Σ i, Fin (d i))).symm q = ⟨i, k⟩ := + Equiv.symm_apply_apply _ _ + have hrepr : (pi D).basis.repr x q = (D i).basis.repr (x i) k := + (productFinBasis_repr D x q).trans + (congrArg (fun z : Σ i, Fin (d i) => (D z.1).basis.repr (x z.1) z.2) hq) + have hcoeff : (pi D).basis.repr x q ≠ 0 := by + rw [hrepr] + exact Finsupp.mem_support_iff.mp hk + have hw := (pi D).basis.mem_span_image.mp hx (Finsupp.mem_support_iff.mpr hcoeff) + change n ≤ productBasisWeight weight q at hw + have hweight : productBasisWeight weight q = weight i k := + congrArg (fun z : Σ i, Fin (d i) => weight z.1 z.2) hq + exact hw.trans_eq hweight + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +theorem triple_product_basis_logHeight (x : L × L × L) {p : ℝ} + (hx : ∀ k, rationalLogHeight (D.basis.repr x.1 k) ≤ p ∧ + rationalLogHeight (D.basis.repr x.2.1 k) ≤ p ∧ + rationalLogHeight (D.basis.repr x.2.2 k) ≤ p) + (k : Fin (Fintype.card (Σ _ : Fin 3, Fin d))) : + rationalLogHeight ((pi (fun _ : Fin 3 => D)).basis.repr (tripleToPi x) k) ≤ p := by + have h (j : Fin 3) (l : Fin d) : + rationalLogHeight (D.basis.repr (tripleToPi x j) l) ≤ p := by + fin_cases j + · exact (hx l).1 + · exact (hx l).2.1 + · exact (hx l).2.2 + rw [productFinBasis_repr] + exact h _ _ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/TruncatedProjectionError.lean b/lean/OAI/Combinatorics/Progressions/Linear/TruncatedProjectionError.lean new file mode 100644 index 0000000000000000000000000000000000000000..af85a06bbce8dc8e921e9aaa284b6d8d4cbba3cf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/TruncatedProjectionError.lean @@ -0,0 +1,405 @@ +import OAI.Combinatorics.Progressions.Estimates.DenseProductApproximation + +namespace OAI + +section + +namespace Erdos3.FiniteProbabilityWeights + +open scoped BigOperators + +theorem complexMean_sum {X J : Type*} [Fintype X] [Fintype J] + (p : FiniteProbabilityWeights X) (f : J → X → ℂ) : + p.complexMean (fun x => ∑ j, f j x) = ∑ j, p.complexMean (f j) := by + simp only [complexMean, Finset.mul_sum] + exact Finset.sum_comm + +theorem norm_weighted_complexMean_sub_le_mean_norm {X : Type*} [Fintype X] + (p : FiniteProbabilityWeights X) (w f g : X → ℂ) {ρ : ℝ} + (he : ∀ x, p.weight x ≠ 0 → ‖f x - g x‖ ≤ ρ) : + ‖p.complexMean (fun x => w x * f x) - p.complexMean (fun x => w x * g x)‖ ≤ + ρ * p.mean (fun x => ‖w x‖) := by + apply (p.norm_complexMean_sub_le _ _ (fun x => ρ * ‖w x‖) ?_).trans_eq + (p.mean_const_mul ρ _) + intro x hx + rw [← mul_sub, norm_mul, mul_comm ρ] + exact mul_le_mul_of_nonneg_left (he x hx) (norm_nonneg _) + +theorem complexMean_weighted_expansion {X J : Type*} [Fintype X] [Fintype J] + (p : FiniteProbabilityWeights X) (w : X → ℂ) (c : J → ℂ) (u : J → X → ℂ) : + p.complexMean (fun x => w x * ∑ j, c j * u j x) = + ∑ j, c j * p.complexMean (fun x => w x * u j x) := by + simp only [Finset.mul_sum] + rw [p.complexMean_sum] + apply Finset.sum_congr rfl + intro j _ + rw [← p.complexMean_mul_left] + congr 1 + funext x + ring + +theorem weighted_expansion_discard_error {X J : Type*} [Fintype X] [Fintype J] + (p : FiniteProbabilityWeights X) (w : X → ℂ) (c : J → ℂ) (u : J → X → ℂ) + (keep : J → Prop) [DecidablePred keep] {C τ : ℝ} + (hc : (∑ j, ‖c j‖) ≤ C) (hτ : 0 ≤ τ) + (hdiscard : ∀ j, ¬ keep j → ‖p.complexMean (fun x => w x * u j x)‖ ≤ τ) : + ‖p.complexMean (fun x => w x * ∑ j, c j * u j x) - + p.complexMean (fun x => w x * ∑ j, if keep j then c j * u j x else 0)‖ ≤ C * τ := by + have he : (fun x => w x * ∑ j, if keep j then c j * u j x else 0) = + (fun x => w x * ∑ j, (if keep j then c j else 0) * u j x) := by + funext x + congr 1 + apply Finset.sum_congr rfl + intro j _ + by_cases hj : keep j <;> simp [hj] + rw [he, p.complexMean_weighted_expansion, p.complexMean_weighted_expansion, + ← Finset.sum_sub_distrib] + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ j, ‖c j‖ * τ := by + apply Finset.sum_le_sum + intro j _ + by_cases hj : keep j + · simp only [hj, ite_true, sub_self, norm_zero] + exact mul_nonneg (norm_nonneg _) hτ + · simp only [hj, ite_false, zero_mul, sub_zero, norm_mul] + exact mul_le_mul_of_nonneg_left (hdiscard j hj) (norm_nonneg _) + _ = (∑ j, ‖c j‖) * τ := (Finset.sum_mul _ _ _).symm + _ ≤ C * τ := mul_le_mul_of_nonneg_right hc hτ + +theorem weighted_projection_tested_error {X J : Type*} [Fintype X] [Fintype J] + (p : FiniteProbabilityWeights X) (w f projected : X → ℂ) + (c : J → ℂ) (u : J → X → ℂ) (keep : J → Prop) [DecidablePred keep] + {B C ρ τ : ℝ} (hρ : 0 ≤ ρ) (hτ : 0 ≤ τ) + (hw : p.mean (fun x => ‖w x‖) ≤ B) (hc : (∑ j, ‖c j‖) ≤ C) + (hfull : ∀ x, p.weight x ≠ 0 → ‖f x - ∑ j, c j * u j x‖ ≤ ρ) + (hprojected : ∀ x, p.weight x ≠ 0 → ‖(∑ j, if keep j then c j * u j x else 0) - projected x‖ ≤ ρ) + (hdiscard : ∀ j, ¬ keep j → ‖p.complexMean (fun x => w x * u j x)‖ ≤ τ) : + ‖p.complexMean (fun x => w x * f x) - p.complexMean (fun x => w x * projected x)‖ ≤ + 2 * B * ρ + C * τ := by + have hfirst := (p.norm_weighted_complexMean_sub_le_mean_norm w f (fun x => ∑ j, c j * u j x) hfull).trans + (mul_le_mul_of_nonneg_left hw hρ) + have hlast := (p.norm_weighted_complexMean_sub_le_mean_norm w + (fun x => ∑ j, if keep j then c j * u j x else 0) projected hprojected).trans + (mul_le_mul_of_nonneg_left hw hρ) + have hmid := p.weighted_expansion_discard_error w c u keep hc hτ hdiscard + have htri := norm_sub_le_norm_sub_add_norm_sub + (p.complexMean (fun x => w x * f x)) + (p.complexMean (fun x => w x * ∑ j, c j * u j x)) + (p.complexMean (fun x => w x * projected x)) + have htri' := norm_sub_le_norm_sub_add_norm_sub + (p.complexMean (fun x => w x * ∑ j, c j * u j x)) + (p.complexMean (fun x => w x * ∑ j, if keep j then c j * u j x else 0)) + (p.complexMean (fun x => w x * projected x)) + linarith + +end Erdos3.FiniteProbabilityWeights + +end + +section + +namespace Erdos3 + +noncomputable def projectionApproxTolerance (W δ : ℝ) : ℝ := min 1 (δ / (2 * (W + 1))) + +noncomputable def projectionModeTolerance (C δ : ℝ) : ℝ := δ / (2 * (C + 1)) + +theorem projectionErrorBudget_spec {W C δ : ℝ} (hW : 0 ≤ W) (hC : 0 ≤ C) (hδ : 0 < δ) : + 0 < projectionApproxTolerance W δ ∧ projectionApproxTolerance W δ ≤ 1 ∧ + 0 < projectionModeTolerance C δ ∧ + W * projectionApproxTolerance W δ + C * projectionModeTolerance C δ ≤ δ := by + have hWp : 0 < 2 * (W + 1) := by positivity + have hCp : 0 < 2 * (C + 1) := by positivity + have hρ : 0 < projectionApproxTolerance W δ := lt_min (by norm_num) (div_pos hδ hWp) + have hρ1 : projectionApproxTolerance W δ ≤ 1 := min_le_left _ _ + have hρδ : projectionApproxTolerance W δ * (2 * (W + 1)) ≤ δ := + (le_div_iff₀ hWp).mp (min_le_right _ _) + have hτ : 0 < projectionModeTolerance C δ := div_pos hδ hCp + have hτδ : projectionModeTolerance C δ * (2 * (C + 1)) = δ := by + unfold projectionModeTolerance + exact div_mul_cancel₀ _ hCp.ne' + refine ⟨hρ, hρ1, hτ, ?_⟩ + nlinarith + +end Erdos3 + +end + +section + +namespace Erdos3.FiniteProbabilityWeights + +theorem weighted_projection_comparison {X : Type*} [Fintype X] + (p : FiniteProbabilityWeights X) (w f F G g : X → ℂ) {B η ε : ℝ} + (hη : 0 ≤ η) (hw : p.mean (fun x => ‖w x‖) ≤ B) + (hF : ∀ x, p.weight x ≠ 0 → ‖f x - F x‖ ≤ η) + (hG : ∀ x, p.weight x ≠ 0 → ‖G x - g x‖ ≤ η) + (hprojection : ‖p.complexMean (fun x => w x * F x) - + p.complexMean (fun x => w x * G x)‖ ≤ ε) : + ‖p.complexMean (fun x => w x * f x) - p.complexMean (fun x => w x * g x)‖ ≤ + 2 * B * η + ε := by + have hfirst := (p.norm_weighted_complexMean_sub_le_mean_norm w f F hF).trans + (mul_le_mul_of_nonneg_left hw hη) + have hlast := (p.norm_weighted_complexMean_sub_le_mean_norm w G g hG).trans + (mul_le_mul_of_nonneg_left hw hη) + have htri := norm_sub_le_norm_sub_add_norm_sub + (p.complexMean (fun x => w x * f x)) (p.complexMean (fun x => w x * F x)) + (p.complexMean (fun x => w x * g x)) + have htri' := norm_sub_le_norm_sub_add_norm_sub + (p.complexMean (fun x => w x * F x)) (p.complexMean (fun x => w x * G x)) + (p.complexMean (fun x => w x * g x)) + linarith + +end Erdos3.FiniteProbabilityWeights + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +noncomputable def finiteAverageMap {H X : Type*} [Fintype H] + (p : FiniteProbabilityWeights H) (T : H → X → X) (f : X → ℂ) (x : X) : ℂ := + p.complexMean (fun h => f (T h x)) + +theorem finiteAverageMap_sub_norm_le {H X : Type*} [Fintype H] + (p : FiniteProbabilityWeights H) (T : H → X → X) (f g : X → ℂ) {ρ : ℝ} + (he : ∀ x, ‖f x - g x‖ ≤ ρ) (x : X) : + ‖finiteAverageMap p T f x - finiteAverageMap p T g x‖ ≤ ρ := by + exact (p.norm_complexMean_sub_le _ _ (fun _ => ρ) (fun h _ => he (T h x))).trans_eq (p.mean_const ρ) + +theorem finiteAverageMap_ofReal {H X : Type*} [Fintype H] + (p : FiniteProbabilityWeights H) (T : H → X → X) (f : X → ℝ) (x : X) : + finiteAverageMap p T (fun y => (f y : ℂ)) x = (p.mean (fun h => f (T h x)) : ℂ) := + p.complexMean_ofReal _ + +theorem finiteAverageMap_real_unit_interval {H X : Type*} [Fintype H] + (p : FiniteProbabilityWeights H) (T : H → X → X) (f : X → ℝ) + (hf : ∀ x, f x ∈ Set.Icc (0 : ℝ) 1) (x : X) : + (finiteAverageMap p T (fun y => (f y : ℂ)) x).im = 0 ∧ + (finiteAverageMap p T (fun y => (f y : ℂ)) x).re ∈ Set.Icc (0 : ℝ) 1 := by + rw [finiteAverageMap_ofReal] + simp only [Complex.ofReal_im, Complex.ofReal_re, true_and, Set.mem_Icc] + exact ⟨p.mean_nonneg (fun h => (hf (T h x)).1), + (p.mean_mono (fun h => (hf (T h x)).2)).trans_eq (p.mean_const 1)⟩ + +theorem finiteAverageMap_expansion {H X J : Type*} [Fintype H] [Fintype J] + (p : FiniteProbabilityWeights H) (T : H → X → X) (c : J → ℂ) (u : J → X → ℂ) + (χ : J → H → ℂ) (keep : J → Prop) [DecidablePred keep] + (heigen : ∀ j h x, u j (T h x) = χ j h * u j x) + (hχ : ∀ j, p.complexMean (χ j) = if keep j then 1 else 0) (x : X) : + finiteAverageMap p T (fun y => ∑ j, c j * u j y) x = + ∑ j, if keep j then c j * u j x else 0 := by + unfold finiteAverageMap + rw [p.complexMean_sum] + apply Finset.sum_congr rfl + intro j _ + have he : (fun h => c j * u j (T h x)) = (fun h => (c j * u j x) * χ j h) := by + funext h + rw [heigen] + ring + rw [he, p.complexMean_mul_left, hχ] + by_cases hj : keep j <;> simp [hj] + +theorem finiteAverageMap_tested_error {H X G J : Type*} [Fintype H] [Fintype G] [Fintype J] + (p : FiniteProbabilityWeights G) (q : FiniteProbabilityWeights H) (T : H → X → X) + (f : X → ℂ) (path : G → X) (w : G → ℂ) (c : J → ℂ) (u : J → X → ℂ) + (χ : J → H → ℂ) (keep : J → Prop) [DecidablePred keep] + {B C ρ τ : ℝ} (hρ : 0 ≤ ρ) (hτ : 0 ≤ τ) + (hw : p.mean (fun x => ‖w x‖) ≤ B) (hc : (∑ j, ‖c j‖) ≤ C) + (happrox : ∀ x, ‖f x - ∑ j, c j * u j x‖ ≤ ρ) + (heigen : ∀ j h x, u j (T h x) = χ j h * u j x) + (hχ : ∀ j, q.complexMean (χ j) = if keep j then 1 else 0) + (hdiscard : ∀ j, ¬ keep j → ‖p.complexMean (fun x => w x * u j (path x))‖ ≤ τ) : + ‖p.complexMean (fun x => w x * f (path x)) - + p.complexMean (fun x => w x * finiteAverageMap q T f (path x))‖ ≤ 2 * B * ρ + C * τ := by + apply p.weighted_projection_tested_error w (fun x => f (path x)) + (fun x => finiteAverageMap q T f (path x)) c (fun j x => u j (path x)) keep hρ hτ hw hc + (fun x _ => happrox (path x)) _ hdiscard + intro x _ + rw [← finiteAverageMap_expansion q T c u χ keep heigen hχ (path x), norm_sub_rev] + exact finiteAverageMap_sub_norm_le q T f (fun y => ∑ j, c j * u j y) happrox (path x) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem uniform_complexMean_addChar {H : Type*} [AddGroup H] [Fintype H] (χ : AddChar H ℂ) : + (FiniteProbabilityWeights.uniform H).complexMean χ = if χ = 1 then 1 else 0 := by + rw [FiniteProbabilityWeights.uniform_complexMean, Fintype.expect_eq_sum_div_card] + by_cases hχ : χ = 1 + · simp only [hχ, ite_true, AddChar.one_apply, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] + exact div_self (by exact_mod_cast Fintype.card_ne_zero : (Fintype.card H : ℂ) ≠ 0) + · rw [ite_eq_right hχ, AddChar.sum_eq_zero_of_ne_one hχ, zero_div] + +noncomputable def finiteCosetAverage {H X : Type*} [AddCommGroup H] [Fintype H] [AddCommGroup X] + (ι : H →+ X) (f : X → ℂ) : X → ℂ := + finiteAverageMap (FiniteProbabilityWeights.uniform H) (fun h x => x + ι h) f + +theorem finiteCosetAverage_invariant {H X : Type*} [AddCommGroup H] [Fintype H] [AddCommGroup X] + (ι : H →+ X) (f : X → ℂ) (h₀ : H) (x : X) : + finiteCosetAverage ι f (x + ι h₀) = finiteCosetAverage ι f x := by + unfold finiteCosetAverage finiteAverageMap + rw [FiniteProbabilityWeights.uniform_complexMean, FiniteProbabilityWeights.uniform_complexMean] + apply Fintype.expect_equiv (Equiv.addLeft h₀) + intro h + change f ((x + ι h₀) + ι h) = f (x + ι (h₀ + h)) + rw [map_add, add_assoc] + +theorem finiteCosetAverage_idempotent {H X : Type*} [AddCommGroup H] [Fintype H] [AddCommGroup X] + (ι : H →+ X) (f : X → ℂ) (x : X) : + finiteCosetAverage ι (finiteCosetAverage ι f) x = finiteCosetAverage ι f x := by + change (FiniteProbabilityWeights.uniform H).complexMean + (fun h => finiteCosetAverage ι f (x + ι h)) = _ + simp_rw [finiteCosetAverage_invariant] + exact (FiniteProbabilityWeights.uniform H).complexMean_const _ + +theorem finiteCosetAverage_character {H X : Type*} [AddCommGroup H] [Fintype H] [AddCommGroup X] + (ι : H →+ X) (χ : AddChar X ℂ) (x : X) : + finiteCosetAverage ι χ x = if χ.compAddMonoidHom ι = 1 then χ x else 0 := by + change (FiniteProbabilityWeights.uniform H).complexMean (fun h => χ (x + ι h)) = _ + simp only [AddChar.map_add_eq_mul] + rw [FiniteProbabilityWeights.complexMean_mul_left] + change χ x * (FiniteProbabilityWeights.uniform H).complexMean (χ.compAddMonoidHom ι) = _ + rw [uniform_complexMean_addChar] + split_ifs <;> simp + +theorem finiteCosetAverage_expansion {H X J : Type*} + [AddCommGroup H] [Fintype H] [AddCommGroup X] [Fintype J] + (ι : H →+ X) (c : J → ℂ) (χ : J → AddChar X ℂ) (x : X) : + finiteCosetAverage ι (fun y => ∑ j, c j * χ j y) x = + ∑ j, if (χ j).compAddMonoidHom ι = 1 then c j * χ j x else 0 := by + apply finiteAverageMap_expansion (FiniteProbabilityWeights.uniform H) + (fun h x => x + ι h) c (fun j x => χ j x) + (fun j h => χ j (ι h)) (fun j => (χ j).compAddMonoidHom ι = 1) _ _ x + · intro j h y + rw [AddChar.map_add_eq_mul, mul_comm] + · intro j + exact uniform_complexMean_addChar ((χ j).compAddMonoidHom ι) + +theorem finiteCosetAverage_tested_error {H X G J : Type*} + [AddCommGroup H] [Fintype H] [AddCommGroup X] [Fintype G] [Fintype J] + (p : FiniteProbabilityWeights G) (ι : H →+ X) (f : X → ℂ) (path : G → X) + (w : G → ℂ) (c : J → ℂ) (χ : J → AddChar X ℂ) {B C ρ τ : ℝ} + (hρ : 0 ≤ ρ) (hτ : 0 ≤ τ) (hw : p.mean (fun x => ‖w x‖) ≤ B) + (hc : (∑ j, ‖c j‖) ≤ C) (happrox : ∀ x, ‖f x - ∑ j, c j * χ j x‖ ≤ ρ) + (hdiscard : ∀ j, (χ j).compAddMonoidHom ι ≠ 1 → + ‖p.complexMean (fun x => w x * χ j (path x))‖ ≤ τ) : + ‖p.complexMean (fun x => w x * f (path x)) - + p.complexMean (fun x => w x * finiteCosetAverage ι f (path x))‖ ≤ 2 * B * ρ + C * τ := by + apply finiteAverageMap_tested_error p (FiniteProbabilityWeights.uniform H) (fun h x => x + ι h) + f path w c (fun j x => χ j x) (fun j h => χ j (ι h)) + (fun j => (χ j).compAddMonoidHom ι = 1) hρ hτ hw hc happrox _ _ hdiscard + · intro j h x + rw [AddChar.map_add_eq_mul, mul_comm] + · intro j + exact uniform_complexMean_addChar ((χ j).compAddMonoidHom ι) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped Classical + +noncomputable def finiteKernelAverage {X Y : Type*} [AddCommGroup X] [Fintype X] [AddCommGroup Y] + (E : X →+ Y) (f : X → ℂ) : X → ℂ := finiteCosetAverage E.ker.subtype f + +theorem finiteKernelAverage_eq_of_map_eq {X Y : Type*} + [AddCommGroup X] [Fintype X] [AddCommGroup Y] + (E : X →+ Y) (f : X → ℂ) (x y : X) (hxy : E x = E y) : + finiteKernelAverage E f x = finiteKernelAverage E f y := by + have hz : y - x ∈ E.ker := by + change E (y - x) = 0 + rw [map_sub, hxy, sub_self] + have h := finiteCosetAverage_invariant E.ker.subtype f ⟨y - x, hz⟩ x + change finiteKernelAverage E f (x + (y - x)) = finiteKernelAverage E f x at h + have he : x + (y - x) = y := by abel + rw [he] at h + exact h.symm + +theorem finiteKernelAverage_factors {X Y : Type*} + [AddCommGroup X] [Fintype X] [AddCommGroup Y] (E : X →+ Y) (f : X → ℂ) : + ∃ g : Set.range E → ℂ, ∀ x, + finiteKernelAverage E f x = g ⟨E x, x, rfl⟩ := by + refine ⟨fun y => finiteKernelAverage E f (Classical.choose y.property), ?_⟩ + intro x + apply finiteKernelAverage_eq_of_map_eq E f + exact (Classical.choose_spec (show E x ∈ Set.range E from ⟨x, rfl⟩)).symm + +theorem character_trivial_on_kernel_iff {X Y : Type*} [AddCommGroup X] [AddCommGroup Y] + (E : X →+ Y) (χ : AddChar X ℂ) : + χ.compAddMonoidHom E.ker.subtype = 1 ↔ ∀ x, E x = 0 → χ x = 1 := by + rw [AddChar.eq_one_iff] + constructor + · intro h x hx + exact h ⟨x, hx⟩ + · intro h x + exact h x.val x.property + +theorem finiteKernelAverage_character {X Y : Type*} + [AddCommGroup X] [Fintype X] [AddCommGroup Y] (E : X →+ Y) (χ : AddChar X ℂ) (x : X) : + finiteKernelAverage E χ x = if ∀ y, E y = 0 → χ y = 1 then χ x else 0 := by + simp only [finiteKernelAverage, finiteCosetAverage_character, character_trivial_on_kernel_iff] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +theorem FiniteProbabilityWeights.weighted_projection_truncation_error {X J : Type*} + [Fintype X] [Fintype J] (p : FiniteProbabilityWeights X) + (w f : X → ℂ) (c : J → ℂ) (u : J → X → ℂ) (keep : J → Prop) [DecidablePred keep] + {B C ρ τ : ℝ} (hρ : 0 ≤ ρ) (hτ : 0 ≤ τ) + (hw : p.mean (fun x => ‖w x‖) ≤ B) (hc : (∑ j, ‖c j‖) ≤ C) + (happrox : ∀ x, p.weight x ≠ 0 → ‖f x - ∑ j, c j * u j x‖ ≤ ρ) + (hdiscard : ∀ j, ¬ keep j → ‖p.complexMean (fun x => w x * u j x)‖ ≤ τ) : + ‖p.complexMean (fun x => w x * f x) - + p.complexMean (fun x => w x * ∑ j, if keep j then c j * u j x else 0)‖ ≤ B * ρ + C * τ := by + have hfirst := (p.norm_weighted_complexMean_sub_le_mean_norm w f (fun x => ∑ j, c j * u j x) happrox).trans + (mul_le_mul_of_nonneg_left hw hρ) + have hmid := p.weighted_expansion_discard_error w c u keep hc hτ hdiscard + have htri := norm_sub_le_norm_sub_add_norm_sub + (p.complexMean (fun x => w x * f x)) + (p.complexMean (fun x => w x * ∑ j, c j * u j x)) + (p.complexMean (fun x => w x * ∑ j, if keep j then c j * u j x else 0)) + linarith + +theorem finiteCosetAverage_truncation_tested_error {H X G J : Type*} + [AddCommGroup H] [Fintype H] [AddCommGroup X] [Fintype G] [Fintype J] + (p : FiniteProbabilityWeights G) (ι : H →+ X) (f : G → ℂ) (path : G → X) + (w : G → ℂ) (c : J → ℂ) (χ : J → AddChar X ℂ) {B C ρ τ : ℝ} + (hρ : 0 ≤ ρ) (hτ : 0 ≤ τ) (hw : p.mean (fun x => ‖w x‖) ≤ B) + (hc : (∑ j, ‖c j‖) ≤ C) + (happrox : ∀ x, p.weight x ≠ 0 → ‖f x - ∑ j, c j * χ j (path x)‖ ≤ ρ) + (hdiscard : ∀ j, (χ j).compAddMonoidHom ι ≠ 1 → + ‖p.complexMean (fun x => w x * χ j (path x))‖ ≤ τ) : + ‖p.complexMean (fun x => w x * f x) - + p.complexMean (fun x => w x * finiteCosetAverage ι (fun y => ∑ j, c j * χ j y) (path x))‖ ≤ + B * ρ + C * τ := by + simp_rw [finiteCosetAverage_expansion] + exact p.weighted_projection_truncation_error w f c (fun j x => χ j (path x)) + (fun j => (χ j).compAddMonoidHom ι = 1) hρ hτ hw hc happrox hdiscard + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/UnconditionedJointFrameDomination.lean b/lean/OAI/Combinatorics/Progressions/Linear/UnconditionedJointFrameDomination.lean new file mode 100644 index 0000000000000000000000000000000000000000..ead5a03c3d76b54a535681763392c2e0d71982ea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/UnconditionedJointFrameDomination.lean @@ -0,0 +1,175 @@ +import OAI.Combinatorics.Progressions.Estimates.UnconditionedSmoothSlopeCap +import OAI.Combinatorics.Progressions.Lattices.IntegerBoxUniformWeightVolume +import OAI.Combinatorics.Progressions.Lattices.RoundedAffineLifts +import OAI.Combinatorics.Progressions.Probability.PositiveDensityNormalization + +namespace OAI + +section + +namespace Erdos3.BooleanCubeKernel + +open FiniteProbabilityWeights +open scoped BigOperators Classical + +theorem jointIntegerFrame_uniform_base_cap_at {K I : Type*} + [Fintype K] [Fintype I] + (A : Finset (I → ℤ)) (hA : A.Nonempty) + (noise y : Option K × I → ℤ) : + (uniformFinset A hA).mean + (fun a => if jointIntegerFrame (a.val, noise) = (fun k i => y (k, i)) then 1 else 0) ≤ + (A.card : ℝ)⁻¹ * + (if (fun k i => noise (some k, i)) = (fun k i => y (some k, i)) then 1 else 0) := by + by_cases hslope : (fun k i => noise (some k, i)) = (fun k i => y (some k, i)) + · simp only [hslope, ite_true, mul_one] + by_cases hex : ∃ a : A, jointIntegerFrame (a.val, noise) = (fun k i => y (k, i)) + · obtain ⟨a, ha⟩ := hex + have heq (b : A) : + jointIntegerFrame (b.val, noise) = (fun k i => y (k, i)) ↔ b = a := by + constructor + · intro hb + apply Subtype.ext + funext i + have h := congrFun (congrFun (hb.trans ha.symm) none) i + exact add_right_cancel h + · rintro rfl + exact ha + simp only [mean, heq, mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', + Finset.mem_univ, ite_true] + exact (uniformFinset_weight A hA a).le + · have hn (a : A) : jointIntegerFrame (a.val, noise) ≠ (fun k i => y (k, i)) := + fun ha => hex ⟨a, ha⟩ + simp only [hn, ite_false, mean_const] + positivity + · have hn (a : A) : jointIntegerFrame (a.val, noise) ≠ (fun k i => y (k, i)) := by + intro ha + apply hslope + funext k i + exact congrFun (congrFun ha (some k)) i + simp only [hn, ite_false, mean_const, hslope, mul_zero, le_refl] + +theorem jointIntegerFrame_uniform_base_cap {K I Ω : Type*} + [Fintype K] [Fintype I] [Fintype Ω] + (A : Finset (I → ℤ)) (hA : A.Nonempty) + (q : FiniteProbabilityWeights Ω) + (noise : Ω → (Option K × I → ℤ)) (y : Option K × I → ℤ) : + ((uniformFinset A hA).prod q).mean + (fun z => if jointIntegerFrame (z.1.val, noise z.2) = (fun k i => y (k, i)) + then 1 else 0) ≤ + (A.card : ℝ)⁻¹ * q.mean + (fun z => if (fun k i => noise z (some k, i)) = (fun k i => y (some k, i)) + then 1 else 0) := by + rw [mean_prod] + calc + _ = q.mean (fun z => (uniformFinset A hA).mean + (fun a => if jointIntegerFrame (a.val, noise z) = (fun k i => y (k, i)) + then 1 else 0)) := by + simp only [mean, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro z _ + apply Finset.sum_congr rfl + intro a _ + ring + _ ≤ q.mean (fun z => (A.card : ℝ)⁻¹ * + (if (fun k i => noise z (some k, i)) = (fun k i => y (some k, i)) + then 1 else 0)) := + q.mean_mono (fun z => jointIntegerFrame_uniform_base_cap_at A hA (noise z) y) + _ = _ := by + simp only [mean, Finset.mul_sum] + apply Finset.sum_congr rfl + intro z _ + ring + +end Erdos3.BooleanCubeKernel + +end + +section + +namespace Erdos3.BooleanCubeKernel +open scoped BigOperators Classical + +variable {K I : Type*} [Fintype K] [Fintype I] + +def selectedJointFrameBoxMap + (bases : Finset (I → ℤ)) (width : Option K × I → ℝ) + (sourceLo sourceHi : Option K × I → ℤ) + (hframe : ∀ z : bases × rectangularWeightIndices 0 width 1, ∀ t, + jointIntegerFrame (z.1.val,z.2.val) t.1 t.2 ∈ Finset.Ico (sourceLo t) (sourceHi t)) + (z : bases × rectangularWeightIndices 0 width 1) : + ∀ t, Finset.Ico (sourceLo t) (sourceHi t) := + fun t => ⟨jointIntegerFrame (z.1.val,z.2.val) t.1 t.2, hframe z t⟩ + +theorem selectedJointReference_frame_cap + (bases : Finset (I → ℤ)) (hbases : bases.Nonempty) + (width : Option K × I → ℝ) (hwidth : ∀ t, 0 < width t) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight (fun _ => 1) {0} width z) + (hscale : ∀ t : K × I, 8 * (probabilityProfileLipschitz : ℝ) ≤ width (some t.1,t.2)) + (y : Option K × I → ℤ) : + (selectedJointReference bases hbases (fun _ => 1) {0} width hwidth hZ).mean + (fun z => if jointIntegerFrame (z.1.val,z.2.val) = (fun k i => y (k,i)) then 1 else 0) ≤ + (bases.card : ℝ)⁻¹ * ∏ t : K × I, 2 / width (some t.1,t.2) := by + have hbase := jointIntegerFrame_uniform_base_cap bases hbases + (selectedResidueFiniteLaw (fun _ => 1) {0} width hwidth hZ) (fun z => z.val) y + exact hbase.trans (mul_le_mul_of_nonneg_left + (selectedResidueFiniteLaw_one_slopes_cap width hwidth hZ hscale (fun k i => y (some k,i))) + (inv_nonneg.mpr (Nat.cast_nonneg _))) + +theorem selectedJointReference_frame_box_domination + (bases : Finset (I → ℤ)) (hbases : bases.Nonempty) + (width : Option K × I → ℝ) (hwidth : ∀ t, 0 < width t) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight (fun _ => 1) {0} width z) + (hscale : ∀ t : K × I, 8 * (probabilityProfileLipschitz : ℝ) ≤ width (some t.1,t.2)) + (sourceLo sourceHi : Option K × I → ℤ) (hsource : ∀ t, sourceLo t < sourceHi t) + (hframe : ∀ z : bases × rectangularWeightIndices 0 width 1, ∀ t, + jointIntegerFrame (z.1.val,z.2.val) t.1 t.2 ∈ Finset.Ico (sourceLo t) (sourceHi t)) + {p : ℝ} + (hbudget : (∏ t, ((sourceHi t - sourceLo t : ℤ) : ℝ)) * + ((bases.card : ℝ)⁻¹ * ∏ t : K × I, 2 / width (some t.1,t.2)) ≤ Real.exp p) + (y : ∀ t, Finset.Ico (sourceLo t) (sourceHi t)) : + ((selectedJointReference bases hbases (fun _ => 1) {0} width hwidth hZ).fiberLaw + (selectedJointFrameBoxMap bases width sourceLo sourceHi hframe)).weight y ≤ + Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight y := by + rw [FiniteProbabilityWeights.fiberLaw_weight] + unfold FiniteProbabilityWeights.fiberMean + have he (z : bases × rectangularWeightIndices 0 width 1) : + selectedJointFrameBoxMap bases width sourceLo sourceHi hframe z = y ↔ + jointIntegerFrame (z.1.val,z.2.val) = (fun k i => (y (k,i)).val) := by + constructor + · intro h + funext k i + exact congrArg Subtype.val (congrFun h (k,i)) + · intro h + funext t + apply Subtype.ext + exact congrFun (congrFun h t.1) t.2 + simp_rw [he] + apply (selectedJointReference_frame_cap bases hbases width hwidth hZ hscale + (fun t => (y t).val)).trans + rw [integerBoxUniformWeights_weight_eq_inv_volume] + have hv := integerBox_volume_pos sourceLo sourceHi hsource + rw [← div_eq_mul_inv] + apply (le_div_iff₀ hv).mpr + rw [mul_comm] + exact hbudget + +theorem selectedJointReference_frame_box_eventProbability + (bases : Finset (I → ℤ)) (hbases : bases.Nonempty) + (width : Option K × I → ℝ) (hwidth : ∀ t, 0 < width t) + (hZ : 0 < ∑' z, selectedResidueSmoothWeight (fun _ => 1) {0} width z) + (sourceLo sourceHi : Option K × I → ℤ) + (hframe : ∀ z : bases × rectangularWeightIndices 0 width 1, ∀ t, + jointIntegerFrame (z.1.val,z.2.val) t.1 t.2 ∈ Finset.Ico (sourceLo t) (sourceHi t)) + (event : (∀ t, Finset.Ico (sourceLo t) (sourceHi t)) → Prop) : + ((selectedJointReference bases hbases (fun _ => 1) {0} width hwidth hZ).fiberLaw + (selectedJointFrameBoxMap bases width sourceLo sourceHi hframe)).eventProbability event = + (selectedJointReference bases hbases (fun _ => 1) {0} width hwidth hZ).eventProbability + (fun z => event (selectedJointFrameBoxMap bases width sourceLo sourceHi hframe z)) := + FiniteProbabilityWeights.fiberLaw_mean _ _ _ + +end Erdos3.BooleanCubeKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/UniformControlledFrameVisit.lean b/lean/OAI/Combinatorics/Progressions/Linear/UniformControlledFrameVisit.lean new file mode 100644 index 0000000000000000000000000000000000000000..d05ba729bf7b1cb4d6aada9b82af29567837594a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/UniformControlledFrameVisit.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformPhysicalVisitBounds + +namespace OAI + +section + +namespace Erdos3 + +universe u v + +theorem exists_uniform_controlled_frame_visit (C : ℕ) : + ∃ A Kf : ℕ, 1 ≤ A ∧ 2 ≤ Kf ∧ + ∀ {σ : Type u} [Fintype σ] [DecidableEq σ] {s bound m a J : ℕ} {gap U : ℝ} + {base : PhysicalEpochSource.{u, v} σ (s + 1) bound} + (frame : PhysicalEpochFrame base) (c : PhysicalEpochComparison base m a J gap), + c.Controlled → base.recordBudget ≤ U → + (base.incomingBudget + 2) ^ A ≤ base.recordBudget → + (frame.child.incomingBudget + 2) ^ A ≤ frame.child.recordBudget → + frame.work ≤ U → (frame.period : ℝ) ≤ Real.exp U → + frame.freezePower ≤ C → frame.eventPower ≤ C → + frame.modulus ∣ m → + (∀ i, c.anchor i ≡ frame.anchor i [ZMOD (frame.modulus : ℤ)]) → + (m * a * (m * a * frame.period)).Coprime J → + (∀ i, ((m * J : ℕ) : ℝ) * Real.exp (5 * U + 2 * (U + 2) ^ Kf + 16) ≤ (base.sides i : ℝ)) → + (∃ state : PhysicalEpochRecords base, + (∃ r, state.records = r :: frame.state.records) ∧ + (∀ r ∈ state.records, r.modulus ∣ m * J) ∧ state.dimension < frame.state.dimension) ∨ + ∃ next : PhysicalEpochComparison frame.child m (a * frame.period) J (gap / 4), + next.Controlled ∧ + (∀ i, c.lower i ≤ next.lower i ∧ next.lower i + next.sides i ≤ c.lower i + c.sides i) ∧ + (∀ i, next.anchor i ≡ c.anchor i [ZMOD (m * a : ℕ)]) ∧ + (∀ i, next.refined i ≡ c.refined i [ZMOD (m * a * J : ℕ)]) := by + obtain ⟨Ke, _, hprecision⟩ := exists_physical_frame_precision + obtain ⟨Kf, hKf, hprecision⟩ := hprecision C + obtain ⟨A, hA, hinflation⟩ := exists_physical_record_inflation Ke C Kf + refine ⟨A, Kf, hA, hKf, ?_⟩ + intro σ _ _ s bound m a J gap U base frame c hc hrecord hbase hchild hwork hperiod hfreeze hevent hmod hanchor hcop hsource + have hU : 0 ≤ U := base.incoming_nonneg.trans (base.incoming_le_record.trans hrecord) + have hwork0 : 0 ≤ frame.work := by linarith [base.incoming_nonneg, frame.incoming_le_work] + obtain ⟨rho, q, ε, δ, hpq, hfreq, hq, hrho, hrhop, hε, hεhalf, hδ, hδone, + hεinv, hδinv, hprojection, hfreezing⟩ := hprecision frame c hfreeze + have hq1 : 1 ≤ q := by linarith [base.incoming_nonneg] + have hB : (q + frame.eventPower) ^ frame.eventPower ≤ base.recordBudget := + ((hinflation base.incomingBudget base.incoming_nonneg).2.2 q hq1 hq frame.eventPower hevent).trans hbase + have hF : (frame.work + 2) ^ Kf ≤ (U + 2) ^ Kf := + pow_le_pow_left₀ (by linarith) (by linarith) Kf + obtain ⟨hwide, hstep, hround, hcount⟩ := frame.uniform_visit_bounds c hc hrecord hperiod + (show 0 ≤ (U + 2) ^ Kf by positivity) (hB.trans hrecord) hε hδ + (hεinv.trans (Real.exp_le_exp.mpr hF)) (hδinv.trans (Real.exp_le_exp.mpr hF)) hsource + rcases frame.visit c (hmod.trans (Nat.dvd_mul_right m a)) hanchor q rho ε δ + hpq hfreq hrho hrhop hcop hstep hδ hδone hεhalf hprojection hfreezing hround hcount with he | hn + · exact Or.inl (frame.extend_records_of_comparison c hc + (fun r hr => (frame.record_moduli r hr).trans hmod) hB hwide he) + · obtain ⟨next, hcontained, hside, hnextAnchor, hnextRefined⟩ := hn + have hc' := frame.child_comparison_controlled c next hc hfreeze + ((hinflation frame.child.incomingBudget frame.child.incoming_nonneg).1.trans hchild) + ((hinflation frame.child.incomingBudget frame.child.incoming_nonneg).2.1.trans hchild) + hδ hδinv (fun i => (hside i).1) + exact Or.inr ⟨next, hc', hcontained, hnextAnchor, hnextRefined⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/UniformPhysicalFrameConstruction.lean b/lean/OAI/Combinatorics/Progressions/Linear/UniformPhysicalFrameConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..282ac9b404c08466e6bc012ee32bac1da1f02d60 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/UniformPhysicalFrameConstruction.lean @@ -0,0 +1,373 @@ +import OAI.Combinatorics.Progressions.Dynamics.AnchoredEpochVisit +import OAI.Combinatorics.Progressions.Dynamics.ControlledAdaptedEpochChild +import OAI.Combinatorics.Progressions.Dynamics.RetainedEpochTransition +import OAI.Combinatorics.Progressions.Estimates.PhysicalChildComparison +import OAI.Combinatorics.Progressions.Estimates.PhysicalOrbitRecovery + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +universe u v + +structure PhysicalEpochFrame {σ : Type u} [Fintype σ] [DecidableEq σ] {s bound : ℕ} + (base : PhysicalEpochSource.{u, v} σ (s + 1) bound) where + state : PhysicalEpochRecords base + modulus : ℕ + modulus_pos : 0 < modulus + anchor : σ → ℤ + anchor_inside : ∀ i, base.lower i ≤ anchor i ∧ anchor i < base.lower i + base.sides i + record_moduli : ∀ r ∈ state.records, r.modulus ∣ modulus + work : ℝ + incoming_le_work : base.incomingBudget + 16 ≤ work + record_le_work : base.recordBudget + 16 ≤ work + period : ℕ + period_pos : 0 < period + freezePower : ℕ + eventPower : ℕ + period_le : (period : ℝ) ≤ Real.exp ((work + 2) ^ freezePower) + child : PhysicalEpochSource.{u, v} σ s bound + child_lower : child.lower = base.lower + child_sides : child.sides = base.sides + child_dimension_le : child.dimension ≤ base.dimension + childCost : ℝ + childCost_nonneg : 0 ≤ childCost + childCost_le : childCost ≤ child.incomingBudget + incoming_le_child : base.incomingBudget + 16 ≤ child.incomingBudget + work_le_child : work ≤ child.incomingBudget + transition : FixedAffineEpochTransition base.model base.weights base.adapted + (epochRecordIntersection state.records) + (base.fixedMap.scalarAffinePullback (modulus : ℚ) (fun i => (anchor i : ℚ))) + (fun i => (base.sides i : ℝ) / modulus) + child.model (child.fixedMap.scalarAffinePullback (modulus : ℚ) (fun i => (anchor i : ℚ))).orbit + work childCost period freezePower eventPower + +end Erdos3 + +end + +section + +namespace Erdos3 + +universe u v + +theorem exists_physical_frame_precision : + ∃ Ke : ℕ, 2 ≤ Ke ∧ ∀ C : ℕ, ∃ Kf : ℕ, 2 ≤ Kf ∧ + ∀ {σ : Type u} [Fintype σ] [DecidableEq σ] {s bound m a J : ℕ} {gap : ℝ} + {base : PhysicalEpochSource.{u, v} σ (s + 1) bound} + (frame : PhysicalEpochFrame base) (_c : PhysicalEpochComparison base m a J gap), + frame.freezePower ≤ C → ∃ rho q ε δ : ℝ, + base.incomingBudget + 16 ≤ q ∧ verticalDecompositionBudget (base.incomingBudget + 16) ≤ q ∧ + q ≤ (base.incomingBudget + 2) ^ Ke ∧ 0 < rho ∧ rho⁻¹ ≤ Real.exp (base.incomingBudget + 16) ∧ + 0 < ε ∧ ε < 1 / 2 ∧ 0 < δ ∧ δ ≤ 1 ∧ + ε⁻¹ ≤ Real.exp ((frame.work + 2) ^ Kf) ∧ δ⁻¹ ≤ Real.exp ((frame.work + 2) ^ Kf) ∧ + 2 * (2 * rho + Real.exp (verticalDecompositionBudget (base.incomingBudget + 16) - q)) ≤ gap / 2 ∧ + 8 * ε + 2 * (Real.exp ((frame.work + 2) ^ frame.freezePower) * δ) ≤ gap / 4 := by + obtain ⟨Ke, hKe, hprecision⟩ := exists_separated_residue_precision + refine ⟨Ke, hKe, ?_⟩ + intro C + obtain ⟨Kf, hKf, hstep⟩ := hprecision C + refine ⟨Kf, hKf, ?_⟩ + intro σ _ _ s bound m a J gap base frame c hC + obtain ⟨rho, q, hpq, hfreq, hq, hrho, hrhop, hprojection, hfreezing⟩ := + hstep base.incomingBudget base.incoming_nonneg gap c.gap_pos c.gap_le_one c.gap_inverse + obtain ⟨ε, δ, hε, hεhalf, hδ, hδone, hεbound, hδbound, herror⟩ := + hfreezing frame.work frame.incoming_le_work + refine ⟨rho, q, ε, δ, hpq, hfreq, hq, hrho, hrhop, hε, hεhalf, hδ, hδone, + hεbound, hδbound, hprojection, ?_⟩ + have hwork : 0 ≤ frame.work := by linarith [frame.incoming_le_work, base.incoming_nonneg] + have hpow : (frame.work + 2) ^ frame.freezePower ≤ (frame.work + 2) ^ C := + pow_le_pow_right₀ (by linarith) hC + calc + 8 * ε + 2 * (Real.exp ((frame.work + 2) ^ frame.freezePower) * δ) ≤ + 8 * ε + 2 * (Real.exp ((frame.work + 2) ^ C) * δ) := by gcongr + _ = gap / 4 := herror + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct BigOperators + +universe u v + +theorem PhysicalEpochFrame.visit + {σ : Type u} [Fintype σ] [DecidableEq σ] {s bound m a J : ℕ} {gap : ℝ} + {base : PhysicalEpochSource.{u, v} σ (s + 1) bound} + (frame : PhysicalEpochFrame base) (c : PhysicalEpochComparison base m a J gap) + (hdiv : frame.modulus ∣ m * a) + (hcompat : ∀ i, c.anchor i ≡ frame.anchor i [ZMOD (frame.modulus : ℤ)]) + (q rho ε δ : ℝ) (hpq : base.incomingBudget + 16 ≤ q) + (hfreq : verticalDecompositionBudget (base.incomingBudget + 16) ≤ q) + (hrho : 0 < rho) (hrhop : rho⁻¹ ≤ Real.exp (base.incomingBudget + 16)) + (hcop : (m * a * (m * a * frame.period)).Coprime J) + (hsteplarge : ∀ i, ((m * a * J : ℕ) : ℝ) * + (Real.exp ((q + frame.eventPower) ^ frame.eventPower) + 1) ≤ (c.sides i : ℝ)) + (hδ : 0 < δ) (hδone : δ ≤ 1) (hε : ε < 1 / 2) + (hprojection : 2 * (2 * rho + Real.exp (verticalDecompositionBudget (base.incomingBudget + 16) - q)) ≤ gap / 2) + (hfreezing : 8 * ε + 2 * (Real.exp ((frame.work + 2) ^ frame.freezePower) * δ) ≤ gap / 4) + (hlarge : ∀ i, 8 ≤ δ * (c.sides i : ℝ)) + (hcount : (∑ i, ((Nat.lcm (m * a) (m * a * frame.period) * J : ℕ) : ℝ) / (c.sides i : ℝ)) ≤ δ * ε / 8) : + ResiduePairDimensionDrop base.model base.weights base.adapted c.test + (epochRecordIntersection frame.state.records) c.lower c.sides (m * a) c.anchor c.refined + (fun _ => J) ((q + frame.eventPower) ^ frame.eventPower) ∨ + ∃ next : PhysicalEpochComparison frame.child m (a * frame.period) J (gap / 4), + (∀ i, c.lower i ≤ next.lower i ∧ next.lower i + next.sides i ≤ c.lower i + c.sides i) ∧ + (∀ i, δ * (c.sides i : ℝ) / 8 ≤ (next.sides i : ℝ) ∧ (next.sides i : ℝ) ≤ δ * (c.sides i : ℝ) / 2) ∧ + (∀ i, next.anchor i ≡ c.anchor i [ZMOD (m * a : ℕ)]) ∧ + (∀ i, next.refined i ≡ c.refined i [ZMOD (m * a * J : ℕ)]) := by + have hparent := base.fixedMap.scalarAffinePullback_refinement_orbit frame.anchor c.anchor hdiv hcompat + have hinput : c.test.orbit = base.model.filtration.realification.scalarAffineOrbitHom (m * a / frame.modulus : ℕ) + (fun i => (commonStrideIndex frame.anchor frame.modulus c.anchor i : ℚ)) + (base.fixedMap.scalarAffinePullback (frame.modulus : ℚ) (fun i => (frame.anchor i : ℚ))).orbit := + c.orbit.trans hparent.symm + have hresult := FixedAffineEpochTransition.on_anchored_box + base.model base.weights base.adapted (epochRecordIntersection frame.state.records) + (base.fixedMap.scalarAffinePullback (frame.modulus : ℚ) (fun i => (frame.anchor i : ℚ))) + frame.child.model (frame.child.fixedMap.scalarAffinePullback (frame.modulus : ℚ) (fun i => (frame.anchor i : ℚ))).orbit + frame.work frame.childCost frame.period frame.freezePower frame.eventPower + base.lower frame.anchor base.sides frame.modulus frame.modulus_pos frame.anchor_inside frame.transition + (base.incomingBudget + 16) (by linarith [base.incoming_nonneg]) frame.incoming_le_work + c.lower c.anchor c.refined c.sides (m * a) (fun _ => J) (Nat.mul_pos c.selected_pos c.auxiliary_pos) + hdiv hcompat c.anchor_inside c.contained c.sides_pos c.test hinput c.positive + (c.complexity.mono (by linarith)) q rho hpq (base.coordinates_le.trans (by linarith)) + hfreq hrho hrhop (fun _ => c.pending_pos) c.compatible (fun _ => hcop) hsteplarge + gap ε δ hδ hδone hε hprojection hfreezing hlarge hcount c.discrepancy + rcases hresult with hevent | hchild + · exact Or.inl hevent + · have hchildOrbit := frame.child.fixedMap.scalarAffinePullback_refinement_orbit + frame.anchor c.anchor hdiv hcompat + have hchild' : AnchoredChildResidueComparison frame.child.model + (frame.child.fixedMap.scalarAffinePullback (m * a : ℕ) (fun i => (c.anchor i : ℚ))).orbit + frame.childCost (gap / 4) δ c.lower c.sides (m * a) frame.period c.anchor c.refined (fun _ => J) := by + rw [← hchildOrbit] + exact hchild + exact Or.inr (physical_comparison_of_anchored frame.child m a J frame.period + c.selected_pos c.auxiliary_pos c.pending_pos frame.period_pos c.lower c.sides c.anchor c.refined + frame.childCost (gap / 4) δ frame.childCost_le (div_pos c.gap_pos (by norm_num)) (by linarith [c.gap_le_one]) + (quarter_discrepancy_inverse c.gap_inverse frame.incoming_le_child) + (fun i => by simpa only [frame.child_lower, frame.child_sides] using c.contained i) hchild') + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module RationalFilteredNilmanifold +open scoped TensorProduct + +universe u v + +theorem exists_physical_epoch_frame (s : ℕ) : + ∃ K : ℕ, 2 ≤ K ∧ ∀ {σ : Type u} [Fintype σ] [DecidableEq σ] {bound : ℕ} + (base : PhysicalEpochSource.{u, v} σ (s + 1) bound) (state : PhysicalEpochRecords base) + (M : ℕ), 0 < M → ∀ anchor : σ → ℤ, + (∀ i, base.lower i ≤ anchor i ∧ anchor i < base.lower i + base.sides i) → + (∀ r ∈ state.records, r.modulus ∣ M) → + ∀ inflate : ℝ → ℝ, (∀ p, 0 ≤ p → p ≤ inflate p) → + (∀ i, Real.exp ((base.recordBudget + 2) ^ K) ≤ (base.sides i : ℝ) / M) → + ∃ frame : PhysicalEpochFrame base, + frame.state = state ∧ frame.modulus = M ∧ frame.anchor = anchor ∧ + frame.work ≤ (base.recordBudget + 2) ^ K ∧ + frame.child.incomingBudget ≤ (base.recordBudget + 2) ^ K ∧ + frame.child.recordBudget = inflate frame.child.incomingBudget ∧ + (frame.period : ℝ) ≤ Real.exp ((base.recordBudget + 2) ^ K) ∧ + frame.freezePower ≤ K ∧ frame.eventPower ≤ K := by + obtain ⟨C, K₀, _, _, hretained⟩ := exists_retained_epoch_from_records s + obtain ⟨B, _, htransition⟩ := exists_retained_affine_epoch_transition s + obtain ⟨R, _, hadapted⟩ := exists_controlled_adapted_epoch_child + let Q : Polynomial ℕ := (Polynomial.X + 2) ^ K₀ + + ((Polynomial.X + 2) ^ K₀ + Polynomial.C R) ^ R + Polynomial.X + 16 + + ((Polynomial.X + 2) ^ K₀ + 2) ^ C + obtain ⟨K₁, hK₁, hbudget⟩ := exists_natPolynomial_fixed_power_budget Q + let K := max K₁ (max B C) + refine ⟨K, hK₁.trans (le_max_left _ _), ?_⟩ + intro σ _ _ bound base state M hM anchor hanchor hdiv inflate hinflate hlarge + let p := base.recordBudget + have hp : 0 ≤ p := base.incoming_nonneg.trans base.incoming_le_record + have hK₁K : (p + 2) ^ K₁ ≤ (p + 2) ^ K := + pow_le_pow_right₀ (by linarith : 1 ≤ p + 2) (le_max_left _ _) + have hsum : (p + 2) ^ K₀ + ((p + 2) ^ K₀ + R) ^ R + p + 16 + + ((p + 2) ^ K₀ + 2) ^ C ≤ (p + 2) ^ K := by + have h := hbudget p hp + simp only [Q, Polynomial.eval₂_add, Polynomial.eval₂_pow, Polynomial.eval₂_X, + Polynomial.eval₂_ofNat, Polynomial.eval₂_C] at h + exact h.trans hK₁K + have hpow0 : 0 ≤ (p + 2) ^ K₀ := by positivity + have hpowR : 0 ≤ ((p + 2) ^ K₀ + R) ^ R := by positivity + have hperiodPow0 : 0 ≤ ((p + 2) ^ K₀ + 2) ^ C := by positivity + have hsize : (p + 2) ^ K₀ ≤ (p + 2) ^ K := by linarith + have hMr : (0 : ℝ) < M := by exact_mod_cast hM + have hspan : ∀ i, (M : ℝ) * ((base.sides i : ℝ) / M) ≤ (base.sides i : ℝ) := by + intro i + apply le_of_eq + field_simp + obtain ⟨work, cost, hpwork, hwork, hcost0, hcost, hepoch⟩ := + hretained base.model base.weights base.adapted base.fixedMap state.records state.history + p hp (base.geometry.mono base.model base.incoming_le_record) + (base.coordinates_le.trans base.incoming_le_record) + (fun i => (base.sides i : ℝ)) state.controlled M hM hdiv + (fun i => (base.sides i : ℝ) / M) + (fun i => (Real.exp_le_exp.mpr hsize).trans (hlarge i)) hspan (fun i => (anchor i : ℚ)) + obtain ⟨P, hP, hPb, E, hE, n, hn, V₀, hV₀, hchild⟩ := + htransition base.model base.weights base.adapted (epochRecordIntersection state.records) + (base.fixedMap.scalarAffinePullback (M : ℚ) (fun i => (anchor i : ℚ))) + (fun i => (base.sides i : ℝ) / M) work cost C (by linarith) hepoch + let N := (base.model.filtration.gradedRefiltrationSubalgebra (epochRecordIntersection state.records)) ⧸ + E.filtration.layerIdeal (s + 1) + let := moduleTopology ℝ (ℝ ⊗[ℚ] N) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] N) + let := realification_moduleTopology_t2 V₀.basis + obtain ⟨V, _, _, hV, childOrbit, _, hstep⟩ := hchild + obtain ⟨F, hdimension, hgeometry, hstep'⟩ := hadapted base.model base.weights base.adapted + (epochRecordIntersection state.records) + (base.fixedMap.scalarAffinePullback (M : ℚ) (fun i => (anchor i : ℚ))) + (fun i => (base.sides i : ℝ) / M) V childOrbit work cost P C B hcost0 hV hstep + let childCost := (cost + R) ^ R + let next := base.incomingBudget + work + childCost + 16 + have hwork0 : 0 ≤ work := by linarith + have hchildCost0 : 0 ≤ childCost := by dsimp only [childCost]; positivity + have hnext0 : 0 ≤ next := by dsimp only [next]; linarith [base.incoming_nonneg] + have hchildCost : childCost ≤ ((p + 2) ^ K₀ + R) ^ R := by + dsimp only [childCost] + gcongr + have hnext : next ≤ (p + 2) ^ K := by + dsimp only [next] + linarith [base.incoming_le_record] + let physicalOrbit := F.model.filtration.realification.scalarAffineOrbitHom (1 / (M : ℚ)) + (fun i => -(anchor i : ℚ) / M) childOrbit + let child : PhysicalEpochSource.{u, v} σ s bound := { + Carrier := N + dimension := finrank ℚ N + dimension_le := (by rw [hdimension]; exact hn.trans base.dimension_le) + model := F.model + weights := F.weight + adapted := F.model_layers + fixedMap := (RationalFilteredNilmanifold.Niltest.const F.model (fun _ : σ => 1) 0).withOrbit physicalOrbit + lower := base.lower + sides := base.sides + sides_pos := base.sides_pos + incomingBudget := next + recordBudget := inflate next + incoming_nonneg := hnext0 + incoming_le_record := hinflate next hnext0 + geometry := hgeometry.mono F.model (by change childCost ≤ next; dsimp only [next]; linarith [base.incoming_nonneg]) + coordinates_le := base.coordinates_le.trans (by dsimp only [next]; linarith) } + have hrecover : (child.fixedMap.scalarAffinePullback (M : ℚ) (fun i => (anchor i : ℚ))).orbit = childOrbit := by + change F.model.filtration.realification.scalarAffineOrbitHom (M : ℚ) (fun i => (anchor i : ℚ)) + (F.model.filtration.realification.scalarAffineOrbitHom (1 / (M : ℚ)) + (fun i => -(anchor i : ℚ) / M) childOrbit) = childOrbit + exact F.model.filtration.realification.scalarAffineOrbitHom_inverse_recover childOrbit M hM anchor + let frame : PhysicalEpochFrame base := { + state := state + modulus := M + modulus_pos := hM + anchor := anchor + anchor_inside := hanchor + record_moduli := hdiv + work := work + incoming_le_work := by linarith [base.incoming_le_record] + record_le_work := hpwork + period := P + period_pos := hP + freezePower := C + eventPower := B + period_le := hPb + child := child + child_lower := rfl + child_sides := rfl + child_dimension_le := by change finrank ℚ N ≤ base.dimension; rw [hdimension]; exact hn + childCost := childCost + childCost_nonneg := hchildCost0 + childCost_le := by change childCost ≤ next; dsimp only [next]; linarith [base.incoming_nonneg] + incoming_le_child := by change base.incomingBudget + 16 ≤ next; dsimp only [next]; linarith + work_le_child := by change work ≤ next; dsimp only [next]; linarith [base.incoming_nonneg] + transition := by rw [hrecover]; exact hstep' } + have hperiodWork : (work + 2) ^ C ≤ ((p + 2) ^ K₀ + 2) ^ C := by + have hwork0 : 0 ≤ work := by linarith + gcongr + have hperiodBound : (P : ℝ) ≤ Real.exp ((p + 2) ^ K) := + hPb.trans (Real.exp_le_exp.mpr (hperiodWork.trans (by linarith))) + exact ⟨frame, rfl, rfl, rfl, hwork.trans hsize, hnext, rfl, hperiodBound, + (le_max_right B C).trans (le_max_right K₁ (max B C)), + (le_max_left B C).trans (le_max_right K₁ (max B C))⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +universe u v + +def PhysicalFrameConstructionBound (s K : ℕ) : Prop := + ∀ {σ : Type u} [Fintype σ] [DecidableEq σ] {bound : ℕ} + (base : PhysicalEpochSource.{u, v} σ (s + 1) bound) (state : PhysicalEpochRecords base) + (M : ℕ), 0 < M → ∀ anchor : σ → ℤ, + (∀ i, base.lower i ≤ anchor i ∧ anchor i < base.lower i + base.sides i) → + (∀ r ∈ state.records, r.modulus ∣ M) → + ∀ inflate : ℝ → ℝ, (∀ p, 0 ≤ p → p ≤ inflate p) → + (∀ i, Real.exp ((base.recordBudget + 2) ^ K) ≤ (base.sides i : ℝ) / M) → + ∃ frame : PhysicalEpochFrame base, + frame.state = state ∧ frame.modulus = M ∧ frame.anchor = anchor ∧ + frame.work ≤ (base.recordBudget + 2) ^ K ∧ + frame.child.incomingBudget ≤ (base.recordBudget + 2) ^ K ∧ + frame.child.recordBudget = inflate frame.child.incomingBudget ∧ + (frame.period : ℝ) ≤ Real.exp ((base.recordBudget + 2) ^ K) ∧ + frame.freezePower ≤ K ∧ frame.eventPower ≤ K + +theorem PhysicalFrameConstructionBound.mono {s K L : ℕ} + (h : PhysicalFrameConstructionBound.{u, v} s K) (hKL : K ≤ L) : + PhysicalFrameConstructionBound.{u, v} s L := by + intro σ _ _ bound base state M hM anchor hanchor hmod inflate hinflate hlarge + have hp : 0 ≤ base.recordBudget := base.incoming_nonneg.trans base.incoming_le_record + have hpow : (base.recordBudget + 2) ^ K ≤ (base.recordBudget + 2) ^ L := + pow_le_pow_right₀ (by linarith) hKL + obtain ⟨frame, hs, hm, ha, hw, hi, hr, hperiod, hf, he⟩ := + h base state M hM anchor hanchor hmod inflate hinflate + (fun i => (Real.exp_le_exp.mpr hpow).trans (hlarge i)) + exact ⟨frame, hs, hm, ha, hw.trans hpow, hi.trans hpow, hr, + hperiod.trans (Real.exp_le_exp.mpr hpow), hf.trans hKL, he.trans hKL⟩ + +theorem exists_uniform_physical_frame_construction (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ t : ℕ, t ≤ s → PhysicalFrameConstructionBound.{u, v} t C := by + induction s with + | zero => + obtain ⟨C, hC, hframe⟩ := exists_physical_epoch_frame 0 + refine ⟨C, hC, ?_⟩ + intro t ht + have : t = 0 := by omega + subst t + exact @hframe + | succ s ih => + obtain ⟨C, hC, hframes⟩ := ih + obtain ⟨K, hK, htop⟩ := exists_physical_epoch_frame (s + 1) + refine ⟨max C K, hC.trans (le_max_left _ _), ?_⟩ + intro t ht + by_cases hts : t ≤ s + · exact PhysicalFrameConstructionBound.mono (@hframes t hts) (le_max_left _ _) + · have heq : t = s + 1 := by omega + subst t + exact PhysicalFrameConstructionBound.mono (@htop) (le_max_right _ _) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/VaryingRankFixedPatchFunction.lean b/lean/OAI/Combinatorics/Progressions/Linear/VaryingRankFixedPatchFunction.lean new file mode 100644 index 0000000000000000000000000000000000000000..83330af05feebaab3b76a8a55de06b88a74599aa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/VaryingRankFixedPatchFunction.lean @@ -0,0 +1,180 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedFixedPatchFunction + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators Classical + +namespace PolynomialPatch + +def castRank {X : Type*} {s d e : ℕ} (P : PolynomialPatch X s d) (h : d = e) : + PolynomialPatch X s e := h ▸ P + +theorem castRank_value {X : Type*} {s d e : ℕ} (P : PolynomialPatch X s d) + (h : d = e) (t : X → ℝ) : (P.castRank h).value t = P.value t := by + subst e + rfl + +theorem castRank_kernel_lip {X : Type*} {s d e : ℕ} (P : PolynomialPatch X s d) + (h : d = e) : (P.castRank h).kernel.lip = P.kernel.lip := by + subst e + rfl + +def formAtWeight {X : Type*} {s d : ℕ} (P : PolynomialPatch X s d) + (w : Fin d → ℕ) (h : P.weight = w) : PolynomialSlots X d w := h ▸ P.form + +theorem formAtWeight_value {X : Type*} {s d : ℕ} (P : PolynomialPatch X s d) + (w : Fin d → ℕ) (h : P.weight = w) (t : X → ℝ) : + ((P.formAtWeight w h).slots t).patchValue P.kernel = P.value t := by + subst w + rfl + +def rankWeightCode {X : Type*} {s d : ℕ} (P : PolynomialPatch X s d) + (D : ℕ) (hd : d ≤ D) : Fin (D + 1) × (Fin D → Fin (s + 1)) := + (⟨d, Nat.lt_succ_of_le hd⟩, fun i => + if hi : i.val < d then ⟨P.weight ⟨i.val, hi⟩, Nat.lt_succ_of_le (P.weight_le _)⟩ else 0) + +theorem rankWeightCode_eq {X : Type*} {s d e D : ℕ} + (P : PolynomialPatch X s d) (Q : PolynomialPatch X s e) + (hd : d ≤ D) (he : e ≤ D) + (hc : P.rankWeightCode D hd = Q.rankWeightCode D he) : + ∃ h : d = e, (P.castRank h).weight = Q.weight := by + have hde : d = e := congrArg (fun c => c.1.val) hc + subst e + refine ⟨rfl, ?_⟩ + funext i + have h := congrArg (fun c => (c.2 ⟨i.val, i.isLt.trans_le hd⟩).val) hc + simpa only [rankWeightCode, dite_eq_left i.isLt, castRank] using h + +end PolynomialPatch + +theorem exists_patch_rank_weight_class {X H : Type*} [Fintype H] + (outer : FiniteProbabilityWeights H) (productive : Finset H) + {s D : ℕ} (d : H → ℕ) (P : ∀ h, PolynomialPatch X s (d h)) + (hd : ∀ h, d h ≤ D) (hproductive : 0 < outer.mass productive) : + ∃ (h₀ : H) (retained : Finset H), h₀ ∈ retained ∧ retained ⊆ productive ∧ + outer.mass productive / ((D + 1 : ℕ) * (s + 1) ^ D : ℕ) ≤ outer.mass retained ∧ + ∀ h ∈ retained, ∃ heq : d h = d h₀, ((P h).castRank heq).weight = (P h₀).weight := by + let code := fun h => (P h).rankWeightCode D (hd h) + obtain ⟨c, hc⟩ := outer.exists_code_fiber_mass productive code + let retained := productive.filter (fun h => code h = c) + have hmass : outer.mass productive / ((D + 1 : ℕ) * (s + 1) ^ D : ℕ) ≤ + outer.mass retained := by + simp only [Fintype.card_prod, Fintype.card_fun, Fintype.card_fin] at hc + convert hc using 1 + congr 1 + ext h + simp only [retained, Finset.mem_filter] + have hretained : 0 < outer.mass retained := + (div_pos hproductive (by positivity)).trans_le hmass + have hnonempty : retained.Nonempty := by + apply Finset.nonempty_iff_ne_empty.mpr + intro hempty + simp only [hempty, FiniteProbabilityWeights.mass, Finset.sum_empty, lt_self_iff_false] at hretained + obtain ⟨h₀, hh₀⟩ := hnonempty + refine ⟨h₀, retained, hh₀, Finset.filter_subset _ _, hmass, ?_⟩ + intro h hh + apply PolynomialPatch.rankWeightCode_eq (P h) (P h₀) (hd h) (hd h₀) + exact (Finset.mem_filter.mp hh).2.trans (Finset.mem_filter.mp hh₀).2.symm + +theorem exists_common_rank_weight_patch_family {X H : Type*} [Fintype H] + (outer : FiniteProbabilityWeights H) (productive : Finset H) + {s D : ℕ} (d : H → ℕ) (P : ∀ h, PolynomialPatch X s (d h)) + (hd : ∀ h, d h ≤ D) (hproductive : 0 < outer.mass productive) + (L : ℝ) (hL : ∀ h, ((P h).kernel.lip : ℝ) ≤ L) : + ∃ (d₀ : ℕ) (w : Fin d₀ → ℕ) (A : H → PolynomialSlots X d₀ w) + (Φ : H → PatchKernel d₀) (retained : Finset H), + d₀ ≤ D ∧ Monotone w ∧ (∀ i, 1 ≤ w i) ∧ (∀ i, w i ≤ s) ∧ + retained ⊆ productive ∧ + outer.mass productive / ((D + 1 : ℕ) * (s + 1) ^ D : ℕ) ≤ outer.mass retained ∧ + (∀ h, ((Φ h).lip : ℝ) ≤ L) ∧ + (∀ h ∈ retained, (Φ h).lip = (P h).kernel.lip) ∧ + ∀ h ∈ retained, ∀ t : X → ℝ, ((A h).slots t).patchValue (Φ h) = (P h).value t := by + obtain ⟨h₀, retained, hh₀, hsub, hmass, hshape⟩ := + exists_patch_rank_weight_class outer productive d P hd hproductive + let chooseIndex := fun h => if h ∈ retained then h else h₀ + have hmem (h) : chooseIndex h ∈ retained := by + dsimp only [chooseIndex] + split_ifs with hh + · exact hh + · exact hh₀ + choose rankEq weightEq using fun h => hshape (chooseIndex h) (hmem h) + let patch := fun h => (P (chooseIndex h)).castRank (rankEq h) + let A := fun h => (patch h).formAtWeight (P h₀).weight (weightEq h) + let Φ := fun h => (patch h).kernel + have hchoose (h) (hh : h ∈ retained) : chooseIndex h = h := by + exact ite_eq_left hh + refine ⟨d h₀, (P h₀).weight, A, Φ, retained, hd h₀, (P h₀).weight_mono, + (P h₀).weight_pos, (P h₀).weight_le, hsub, hmass, ?_, ?_, ?_⟩ + · intro h + simpa only [Φ, patch, PolynomialPatch.castRank_kernel_lip] using hL (chooseIndex h) + · intro h hh + change ((P (chooseIndex h)).castRank (rankEq h)).kernel.lip = _ + rw [PolynomialPatch.castRank_kernel_lip] + exact congrArg (fun a => (P a).kernel.lip) (hchoose h hh) + · intro h hh t + change (((patch h).formAtWeight _ (weightEq h)).slots t).patchValue (patch h).kernel = _ + rw [PolynomialPatch.formAtWeight_value] + change ((P (chooseIndex h)).castRank (rankEq h)).value t = _ + rw [PolynomialPatch.castRank_value] + exact congrArg (fun a => (P a).value t) (hchoose h hh) + +end Erdos3 + +end + +section + +namespace Erdos3 +open scoped BigOperators NNReal Classical + +theorem exists_varying_rank_fixed_patch_function (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {X H T : Type*} + [Fintype X] [Fintype H] [Nonempty H] [Fintype T] + (outer : FiniteProbabilityWeights H) (productive : Finset H) + (d : H → ℕ) (patch : ∀ h, PolynomialPatch X s (d h)) (D : ℕ) (p : ℝ), + (∀ h, d h ≤ D) → 0 < outer.mass productive → + 0 ≤ p → (D : ℝ) ≤ p → (Fintype.card X : ℝ) ≤ p → + (∀ h, ((patch h).kernel.lip : ℝ) ≤ Real.exp p) → + ∀ (localLaw : H → FiniteProbabilityWeights T) (point : H → T → X → ℤ) + (score : H → T → ℝ), (∀ h t, |score h t| ≤ 1) → + (∀ h ∈ productive, Real.exp (-p) ≤ (localLaw h).mean + (fun t => score h t * (patch h).value (fun i => (point h t i : ℝ)))) → + ∃ (d₀ : ℕ) (w : Fin d₀ → ℕ) (hw : Monotone w) (Ψ : PatchKernel d₀) + (B : PolynomialSlots X d₀ w) (localForm : H → PolynomialSlots X d₀ w) + (retained : Finset H), + d₀ ≤ D ∧ (∀ i, 1 ≤ w i) ∧ (∀ i, w i ≤ s) ∧ + (Ψ.lip : ℝ) ≤ Real.exp ((p + 2) ^ E) ∧ + (∀ i, realPolynomialMass (B.center i) ≤ (p + 2) ^ E) ∧ + retained ⊆ productive ∧ + (outer.mass productive / ((D + 1) * (s + 1) ^ D : ℕ)) * + Real.exp (-((p + 2) ^ E)) ≤ outer.mass retained ∧ + ∀ h ∈ retained, Real.exp (-((p + 2) ^ E)) ≤ (localLaw h).mean + (fun t => score h t * + (B.shearTransformedSlots hw + ((localForm h).loweringAt (fun i => (point h t i : ℝ)))).patchValue Ψ) := by + obtain ⟨E, hE, hfixed⟩ := exists_unrestricted_fixed_weight_patch_function s + refine ⟨E, hE, ?_⟩ + intro X H T _ _ _ _ outer productive d patch D p hd hproductive hp hD hX hLip + localLaw point score hscore hpositive + obtain ⟨d₀, w, A, Φ, middle, hd₀, hw, hpos, hws, hsub, hmass, hΦ, _, heval⟩ := + exists_common_rank_weight_patch_family outer productive d patch hd hproductive (Real.exp p) hLip + have hmiddle (h) (hh : h ∈ middle) : Real.exp (-p) ≤ (localLaw h).mean (fun t => + score h t * ((A h).slots (fun i => (point h t i : ℝ))).patchValue (Φ h)) := by + simp_rw [heval h hh] + exact hpositive h (hsub hh) + have hdreal : (d₀ : ℝ) ≤ p := (Nat.cast_le.mpr hd₀).trans hD + obtain ⟨Ψ, B, localForm, retained, hΨ, hB, hretained, hmass', hlocal⟩ := + hfixed A Φ hw hpos hws p hp hdreal hX hΦ outer middle localLaw point score hscore hmiddle + refine ⟨d₀, w, hw, Ψ, B, localForm, retained, hd₀, hpos, hws, + hΨ, hB, hretained.trans hsub, ?_, hlocal⟩ + exact (mul_le_mul_of_nonneg_right hmass (Real.exp_nonneg _)).trans hmass' + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedDualVector.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedDualVector.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bf99b8bab45a11dece84e1a0cba9942a9e3d724 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedDualVector.lean @@ -0,0 +1,206 @@ +import OAI.Combinatorics.Progressions.Linear.BalancedDualBounds +import OAI.Combinatorics.Progressions.Probability.FiniteProbabilityLipschitz + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {Ω : Type*} [Fintype Ω] [DecidableEq Ω] [Nonempty Ω] + +noncomputable def uniformDualVector (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (x : Ω) : ℂ := + (Fintype.card Ω : ℂ) * star (f (Pi.single x 1)) + +omit [Nonempty Ω] in +theorem functional_eq_sum_coordinates (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (v : Ω → ℂ) : + f v = ∑ x, v x * f (Pi.single x 1) := by + calc + _ = f (∑ x, Pi.single x (v x)) := by rw [Finset.univ_sum_single] + _ = ∑ x, f (Pi.single x (v x)) := map_sum f _ _ + _ = _ := by + apply Finset.sum_congr rfl + intro x _ + have h : Pi.single x (v x) = v x • Pi.single x (1 : ℂ) := by + ext y + by_cases hy : y = x <;> simp [hy] + rw [h, map_smul, smul_eq_mul] + +theorem functional_eq_uniform_inner (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (v : Ω → ℂ) : + f v = 𝔼 x, v x * star (uniformDualVector f x) := by + have hcard : (Fintype.card Ω : ℂ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + rw [Fintype.expect_eq_sum_div_card, functional_eq_sum_coordinates] + simp only [uniformDualVector, star_mul, star_natCast, star_star] + have hsum : (∑ x, v x * (f (Pi.single x 1) * (Fintype.card Ω : ℂ))) = + (Fintype.card Ω : ℂ) * ∑ x, v x * f (Pi.single x 1) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + rw [hsum] + field_simp + +omit [Nonempty Ω] in +theorem uniformDualVector_norm (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (x : Ω) : + ‖uniformDualVector f x‖ = (Fintype.card Ω : ℝ) * ‖f (Pi.single x 1)‖ := by + simp [uniformDualVector] + +omit [Nonempty Ω] in +theorem uniform_single_norm_mean (x : Ω) : + (𝔼 y, ‖(Pi.single x (1 : ℂ) : Ω → ℂ) y‖) = 1 / (Fintype.card Ω : ℝ) := by + rw [Fintype.expect_eq_sum_div_card] + have hpoint : (fun y => ‖(Pi.single x (1 : ℂ) : Ω → ℂ) y‖) = Pi.single x (1 : ℝ) := by + ext y + by_cases hy : y = x <;> simp [hy] + rw [hpoint] + simp + +theorem uniformDualVector_self (f : (Ω → ℂ) →ₗ[ℂ] ℂ) : + f (uniformDualVector f) = ((𝔼 x, ‖uniformDualVector f x‖ ^ 2) : ℝ) := by + rw [functional_eq_uniform_inner] + have hpoint (x : Ω) : uniformDualVector f x * star (uniformDualVector f x) = + ((‖uniformDualVector f x‖ ^ 2 : ℝ) : ℂ) := by + change uniformDualVector f x * (starRingEnd ℂ) (uniformDualVector f x) = _ + rw [Complex.mul_conj, Complex.normSq_eq_norm_sq] + simp_rw [hpoint] + simp [Fintype.expect_eq_sum_div_card] + +theorem uniformDualVector_cap (X : Seminorm ℂ (Ω → ℂ)) + (f : (Ω → ℂ) →ₗ[ℂ] ℂ) {K tau : ℝ} (htau : 0 < tau) + (hX : ∀ v, X v ≤ K * (𝔼 x, ‖v x‖)) + (hdual : ∀ v, tau * ‖f v‖ ≤ X v) : + ∀ x, ‖uniformDualVector f x‖ ≤ K / tau := by + intro x + have hcard : (0 : ℝ) < Fintype.card Ω := by exact_mod_cast Fintype.card_pos + have hbound := (hdual (Pi.single x 1)).trans (hX (Pi.single x 1)) + rw [uniform_single_norm_mean] at hbound + have hscaled := mul_le_mul_of_nonneg_left hbound hcard.le + have hcancel : (Fintype.card Ω : ℝ) * (K * (1 / (Fintype.card Ω : ℝ))) = K := by + field_simp + rw [hcancel] at hscaled + apply (le_div_iff₀ htau).mpr + rw [uniformDualVector_norm] + nlinarith only [hscaled] + +theorem uniformDualVector_detectable (X : Seminorm ℂ (Ω → ℂ)) + (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (b : Ω → ℂ) {M tau : ℝ} + (hM : 0 < M) (htau : 0 < tau) (hb : ∀ x, ‖b x‖ ≤ M) + (hfb : 1 < (f b).re) (hdual : ∀ v, tau * ‖f v‖ ≤ X v) : + tau / M ^ 2 < X (uniformDualVector f) := by + have hbMean : (𝔼 x, ‖b x‖ ^ 2) ≤ M ^ 2 := + (Finset.expect_le_expect (fun x (_ : x ∈ Finset.univ) => + pow_le_pow_left₀ (norm_nonneg _) (hb x) 2)).trans_eq + (Finset.expect_const Finset.univ_nonempty (M ^ 2)) + have hself : ‖f (uniformDualVector f)‖ = 𝔼 x, ‖uniformDualVector f x‖ ^ 2 := by + rw [uniformDualVector_self, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (Finset.expect_nonneg (fun x _ => sq_nonneg _))] + have hcs := norm_expect_mul_star_sq_le b (uniformDualVector f) + rw [← functional_eq_uniform_inner, ← hself] at hcs + have hupper := mul_le_mul_of_nonneg_right hbMean (norm_nonneg (f (uniformDualVector f))) + have hnorm : 1 < ‖f b‖ := hfb.trans_le (Complex.re_le_norm _) + have hlarge : 1 < M ^ 2 * ‖f (uniformDualVector f)‖ := by + nlinarith only [hcs, hupper, hnorm] + have hscaled := mul_lt_mul_of_pos_left hlarge htau + have hdom := mul_le_mul_of_nonneg_left (hdual (uniformDualVector f)) (sq_nonneg M) + apply (div_lt_iff₀ (pow_pos hM 2)).mpr + nlinarith only [hscaled, hdom] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {Ω : Type*} [Fintype Ω] [DecidableEq Ω] + +noncomputable def weightedDualVector (p : FiniteProbabilityWeights Ω) + (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (x : Ω) : ℂ := + star (f (Pi.single x 1)) / (p.weight x : ℂ) + +theorem functional_eq_weighted_inner (p : FiniteProbabilityWeights Ω) + (f : (Ω → ℂ) →ₗ[ℂ] ℂ) + (hzero : ∀ x, p.weight x = 0 → f (Pi.single x 1) = 0) (v : Ω → ℂ) : + f v = p.correlation v (weightedDualVector p f) := by + rw [functional_eq_sum_coordinates, FiniteProbabilityWeights.correlation] + apply Finset.sum_congr rfl + intro x _ + by_cases hx : p.weight x = 0 + · simp [weightedDualVector, hx, hzero x hx] + · have hxC : (p.weight x : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr hx + simp only [weightedDualVector, star_div₀, Complex.star_def, + Complex.conj_ofReal, Complex.conj_conj] + field_simp + +theorem weightedDualVector_norm (p : FiniteProbabilityWeights Ω) + (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (x : Ω) : + ‖weightedDualVector p f x‖ = ‖f (Pi.single x 1)‖ / p.weight x := by + rw [weightedDualVector, norm_div, norm_star, Complex.norm_real, + Real.norm_of_nonneg (p.nonneg x)] + +theorem modeling_dual_zero_weight (p : FiniteProbabilityWeights Ω) + (X : Seminorm ℂ (Ω → ℂ)) (f : (Ω → ℂ) →ₗ[ℂ] ℂ) {K tau : ℝ} + (htau : 0 < tau) (hX : ∀ v, X v ≤ K * p.mean (fun x => ‖v x‖)) + (hdual : ∀ v, tau * ‖f v‖ ≤ X v) : + ∀ x, p.weight x = 0 → f (Pi.single x 1) = 0 := by + intro x hx + have h := (hdual (Pi.single x 1)).trans (hX (Pi.single x 1)) + rw [p.mean_single_norm, hx, mul_zero] at h + apply norm_eq_zero.mp + nlinarith [norm_nonneg (f (Pi.single x 1))] + +theorem weightedDualVector_cap (p : FiniteProbabilityWeights Ω) + (X : Seminorm ℂ (Ω → ℂ)) (f : (Ω → ℂ) →ₗ[ℂ] ℂ) {K tau : ℝ} + (hK : 0 ≤ K) (htau : 0 < tau) + (hX : ∀ v, X v ≤ K * p.mean (fun x => ‖v x‖)) + (hdual : ∀ v, tau * ‖f v‖ ≤ X v) : + ∀ x, ‖weightedDualVector p f x‖ ≤ K / tau := by + intro x + rw [weightedDualVector_norm] + rcases (p.nonneg x).eq_or_lt with hx | hx + · rw [← hx, div_zero] + exact div_nonneg hK htau.le + · have h := (hdual (Pi.single x 1)).trans (hX (Pi.single x 1)) + rw [p.mean_single_norm] at h + apply (div_le_iff₀ hx).mpr + have h' : ‖f (Pi.single x 1)‖ ≤ (K * p.weight x) / tau := + (le_div_iff₀ htau).mpr (by nlinarith only [h]) + calc + _ ≤ (K * p.weight x) / tau := h' + _ = _ := by ring + +theorem weightedDualVector_detectable (p : FiniteProbabilityWeights Ω) + (X : Seminorm ℂ (Ω → ℂ)) (f : (Ω → ℂ) →ₗ[ℂ] ℂ) (b : Ω → ℂ) {M tau : ℝ} + (hM : 0 < M) (htau : 0 < tau) (hb : ∀ x, ‖b x‖ ≤ M) + (hfb : 1 < (f b).re) (hdual : ∀ v, tau * ‖f v‖ ≤ X v) + (hzero : ∀ x, p.weight x = 0 → f (Pi.single x 1) = 0) : + tau / M ^ 2 < X (weightedDualVector p f) := by + have hbMean : p.mean (fun x => ‖b x‖ ^ 2) ≤ M ^ 2 := + (p.mean_mono (fun x => pow_le_pow_left₀ (norm_nonneg _) (hb x) 2)).trans_eq + (p.mean_const (M ^ 2)) + have hself : ‖f (weightedDualVector p f)‖ = + p.mean (fun x => ‖weightedDualVector p f x‖ ^ 2) := by + rw [functional_eq_weighted_inner p f hzero, p.correlation_self, + Complex.norm_real, Real.norm_of_nonneg (p.mean_nonneg (fun x => sq_nonneg _))] + have hcs := p.norm_correlation_sq_le b (weightedDualVector p f) + rw [← functional_eq_weighted_inner p f hzero, ← hself] at hcs + have hupper := mul_le_mul_of_nonneg_right hbMean + (norm_nonneg (f (weightedDualVector p f))) + have hnorm : 1 < ‖f b‖ := hfb.trans_le (Complex.re_le_norm _) + have hlarge : 1 < M ^ 2 * ‖f (weightedDualVector p f)‖ := by + nlinarith only [hcs, hupper, hnorm] + have hscaled := mul_lt_mul_of_pos_left hlarge htau + have hdom := mul_le_mul_of_nonneg_left (hdual (weightedDualVector p f)) (sq_nonneg M) + apply (div_lt_iff₀ (pow_pos hM 2)).mpr + nlinarith only [hscaled, hdom] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedFlagBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedFlagBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3bce9fc3b888e45214c9fdfea6c5a943d6194bd --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedFlagBasis.lean @@ -0,0 +1,189 @@ +import Mathlib.Data.Fin.Tuple.Sort +import Mathlib.LinearAlgebra.Basis.Prod +import Mathlib.LinearAlgebra.FiniteDimensional.Basic +import Mathlib.LinearAlgebra.Projection + +namespace OAI + +section + +namespace Erdos3 + +open Module + +universe u v + +variable {K : Type u} [Field K] {V : Type v} [AddCommGroup V] [Module K V] + +theorem span_image_inl_of_basis_extension + {P R : Submodule K V} (hRP : R ≤ P) {κ μ : Type*} + (bP : Basis κ K P) (bV : Basis (κ ⊕ μ) K V) + (hext : ∀ i, bV (Sum.inl i) = (bP i : V)) (s : Set κ) + (hspan : R.comap P.subtype = Submodule.span K (bP '' s)) : + R = Submodule.span K (bV '' (Sum.inl '' s)) := by + have himage : P.subtype '' (bP '' s) = bV '' (Sum.inl '' s) := by + ext x + constructor + · rintro ⟨_, ⟨i, hi, rfl⟩, rfl⟩ + exact ⟨Sum.inl i, ⟨i, hi, rfl⟩, hext i⟩ + · rintro ⟨_, ⟨i, hi, rfl⟩, rfl⟩ + exact ⟨bP i, ⟨i, hi, rfl⟩, (hext i).symm⟩ + calc + R = (R.comap P.subtype).map P.subtype := + (Submodule.map_comap_eq_self (by + simpa [Submodule.range_subtype] using hRP)).symm + _ = (Submodule.span K (bP '' s)).map P.subtype := by rw [hspan] + _ = Submodule.span K (P.subtype '' (bP '' s)) := by rw [Submodule.map_span] + _ = Submodule.span K (bV '' (Sum.inl '' s)) := by rw [himage] + +theorem span_range_inl_complement_basis {P Q : Submodule K V} (hPQ : IsCompl P Q) + {κ μ : Type*} (bP : Basis κ K P) (bQ : Basis μ K Q) : + let bV := (bP.prod bQ).map (P.prodEquivOfIsCompl Q hPQ) + P = Submodule.span K (bV '' Set.range Sum.inl) := by + classical + let bV := (bP.prod bQ).map (P.prodEquivOfIsCompl Q hPQ) + apply le_antisymm + · intro x hx + have hxp : (⟨x, hx⟩ : P) ∈ Submodule.span K (Set.range bP) := by + rw [bP.span_eq] + exact Submodule.mem_top + exact Submodule.span_induction (R := K) (s := Set.range bP) + (p := fun y _ => (y : V) ∈ Submodule.span K (bV '' Set.range Sum.inl)) + (fun y hy => by + obtain ⟨i, rfl⟩ := hy + apply Submodule.subset_span + refine ⟨Sum.inl i, ⟨i, rfl⟩, ?_⟩ + simp [bV]) + (Submodule.zero_mem _) + (fun _ _ _ _ hy hz => Submodule.add_mem _ hy hz) + (fun a _ _ hy => Submodule.smul_mem _ a hy) hxp + · refine Submodule.span_le.mpr ?_ + rintro _ ⟨_, ⟨i, rfl⟩, rfl⟩ + simp + +theorem exists_basis_with_nested_supports (n : ℕ) : + ∀ {V : Type v} [AddCommGroup V] [Module K V] [FiniteDimensional K V] + (P : Fin n → Submodule K V), Antitone P → + ∃ (κ : Type) (_ : Fintype κ) (b : Basis κ K V) (s : Fin n → Set κ), + Antitone s ∧ ∀ i, P i = Submodule.span K (b '' s i) := by + induction n with + | zero => + intro V _ _ _ P _ + refine ⟨Fin (finrank K V), inferInstance, finBasis K V, Fin.elim0, ?_, ?_⟩ + · intro i + exact Fin.elim0 i + · intro i + exact Fin.elim0 i + | succ n ih => + intro V _ _ _ P hanti + classical + let P₀ : Submodule K V := P 0 + let tail : Fin n → Submodule K P₀ := fun i => (P i.succ).comap P₀.subtype + have htail : Antitone tail := by + intro i j hij + apply Submodule.comap_mono + exact hanti (by simpa using hij) + obtain ⟨κ, instκ, bP, sP, hsP, hbP⟩ := ih tail htail + let : Fintype κ := instκ + obtain ⟨Q, hPQ⟩ := Submodule.exists_isCompl P₀ + let bQ := finBasis K Q + let e : (P₀ × Q) ≃ₗ[K] V := P₀.prodEquivOfIsCompl Q hPQ + let b : Basis (κ ⊕ Fin (finrank K Q)) K V := (bP.prod bQ).map e + let s : Fin (n + 1) → Set (κ ⊕ Fin (finrank K Q)) := + Fin.cases (Set.range Sum.inl) (fun j => Sum.inl '' sP j) + refine ⟨κ ⊕ Fin (finrank K Q), inferInstance, b, s, ?_, ?_⟩ + · intro i j hij + obtain rfl | ⟨i', rfl⟩ := i.eq_zero_or_eq_succ + · obtain rfl | ⟨j', rfl⟩ := j.eq_zero_or_eq_succ + · exact fun _ hx => hx + · rintro x ⟨k, _, rfl⟩ + exact Set.mem_range.mpr ⟨k, rfl⟩ + · obtain rfl | ⟨j', rfl⟩ := j.eq_zero_or_eq_succ + · exact False.elim ((not_le_of_gt (Fin.succ_pos i')) hij) + · exact Set.image_mono (hsP (by simpa using hij)) + · intro i + refine Fin.cases ?_ (fun j => ?_) i + · exact span_range_inl_complement_basis hPQ bP bQ + · apply span_image_inl_of_basis_extension + (P := P₀) (R := P j.succ) (hanti (Fin.zero_le j.succ)) + bP b (fun k => by simp [b, e]) (sP j) + simpa [tail, P₀] using hbP j + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +variable {κ : Type*} {n : ℕ} + +noncomputable def nestedSupportWeight (S : Fin n → Set κ) (x : κ) : ℕ := + by classical exact (Finset.univ.filter fun i => x ∈ S i).card + +theorem nestedSupportWeight_le (S : Fin n → Set κ) (x : κ) : + nestedSupportWeight S x ≤ n := by + classical + simpa only [nestedSupportWeight, Finset.card_univ, Fintype.card_fin] using + Finset.card_filter_le (s := (Finset.univ : Finset (Fin n))) (p := fun i => x ∈ S i) + +theorem mem_nestedSupport_iff (S : Fin n → Set κ) (hS : Antitone S) (i : Fin n) (x : κ) : + x ∈ S i ↔ i.val < nestedSupportWeight S x := by + classical + let A := Finset.univ.filter fun j => x ∈ S j + constructor + · intro hx + have hle : Finset.Iic i ⊆ A := by + intro j hj + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hS (Finset.mem_Iic.mp hj) hx⟩ + have hcard := Finset.card_le_card hle + rw [Fin.card_Iic] at hcard + exact hcard + · intro hi + by_contra hx + have hle : A ⊆ Finset.Iio i := by + intro j hj + apply Finset.mem_Iio.mpr + by_contra hij + exact hx (hS (le_of_not_gt hij) (Finset.mem_filter.mp hj).2) + have hcard := Finset.card_le_card hle + rw [Fin.card_Iio] at hcard + exact Nat.not_lt_of_ge hcard hi + +theorem exists_sorted_weighted_flag_basis {K V : Type*} [Field K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + (P : Fin n → Submodule K V) (hP : Antitone P) : + ∃ (e : Basis (Fin (finrank K V)) K V) (w : Fin (finrank K V) → ℕ), + Monotone w ∧ (∀ j, w j ≤ n) ∧ + ∀ i, P i = Submodule.span K (e '' {j | i.val < w j}) := by + classical + obtain ⟨κ, instκ, b, S, hS, hb⟩ := exists_basis_with_nested_supports n P hP + let : Fintype κ := instκ + let ρ : κ ≃ Fin (finrank K V) := Fintype.equivFinOfCardEq (finrank_eq_card_basis b).symm + let u : Fin (finrank K V) → ℕ := fun j => nestedSupportWeight S (ρ.symm j) + let σ := Tuple.sort u + let e := b.reindex (ρ.trans σ.symm) + let w : Fin (finrank K V) → ℕ := fun j => u (σ j) + refine ⟨e, w, Tuple.monotone_sort u, fun j => nestedSupportWeight_le S _, ?_⟩ + intro i + rw [hb i] + congr 1 + ext x + constructor + · rintro ⟨k, hk, rfl⟩ + refine ⟨σ.symm (ρ k), ?_, ?_⟩ + · simpa only [Set.mem_ofPred_eq, w, u, Equiv.apply_symm_apply, Equiv.symm_apply_apply] using + (mem_nestedSupport_iff S hS i k).mp hk + · simp [e, Basis.reindex_apply] + · rintro ⟨j, hj, rfl⟩ + refine ⟨ρ.symm (σ j), (mem_nestedSupport_iff S hS i _).mpr hj, ?_⟩ + simp [e, Basis.reindex_apply] + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedLieUpperSpan.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedLieUpperSpan.lean new file mode 100644 index 0000000000000000000000000000000000000000..631c9e9c0bcdf4bc75726bf33216f5e7e64defbe --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedLieUpperSpan.lean @@ -0,0 +1,64 @@ +import OAI.Combinatorics.Progressions.Estimates.LieTreeMultidegree + +namespace OAI + +section + +namespace Erdos3 + +variable {I L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +def weightedLieUpperGenerators (v : I → L) (w : I → ℕ) (d : ℕ) : Set L := + {x | ∃ a : FreeMagma I, d ≤ lieTreeWeight w a ∧ lieTreeEval v a = x} + +def weightedLieUpperSpan (v : I → L) (w : I → ℕ) (d : ℕ) : Submodule ℚ L := + Submodule.span ℚ (weightedLieUpperGenerators v w d) + +theorem weightedLieUpperSpan_antitone (v : I → L) (w : I → ℕ) : + Antitone (weightedLieUpperSpan v w) := by + intro d e hde + apply Submodule.span_mono + rintro x ⟨a, ha, rfl⟩ + exact ⟨a, hde.trans ha, rfl⟩ + +theorem weightedLieUpperSpan_lie_mem (v : I → L) (w : I → ℕ) {d e : ℕ} {x y : L} + (hx : x ∈ weightedLieUpperSpan v w d) (hy : y ∈ weightedLieUpperSpan v w e) : + ⁅x, y⁆ ∈ weightedLieUpperSpan v w (d + e) := by + induction hx, hy using Submodule.span_induction₂ with + | mem_mem x y hx hy => + obtain ⟨a, ha, rfl⟩ := hx + obtain ⟨b, hb, rfl⟩ := hy + exact Submodule.subset_span ⟨a * b, Nat.add_le_add ha hb, rfl⟩ + | zero_left y _ => rw [zero_lie]; exact Submodule.zero_mem _ + | zero_right x _ => rw [lie_zero]; exact Submodule.zero_mem _ + | add_left x y z _ _ _ hx hy => rw [add_lie]; exact Submodule.add_mem _ hx hy + | add_right x y z _ _ _ hx hy => rw [lie_add]; exact Submodule.add_mem _ hx hy + | smul_left c x y _ _ h => rw [smul_lie]; exact Submodule.smul_mem _ c h + | smul_right c x y _ _ h => rw [lie_smul]; exact Submodule.smul_mem _ c h + +theorem weightedLieUpperSpan_leaf (v : I → L) (w : I → ℕ) (i : I) : + v i ∈ weightedLieUpperSpan v w (w i) := + Submodule.subset_span ⟨.of i, le_rfl, rfl⟩ + +theorem weightedLieTree_eval_mem_layer {s : ℕ} (F : NilpotentLieFiltration M s) + (v : I → M) (w : I → ℕ) (hv : ∀ i, v i ∈ F.layer (w i)) (a : FreeMagma I) : + lieTreeEval v a ∈ F.layer (lieTreeWeight w a) := by + induction a using FreeMagma.rec with + | of i => exact hv i + | mul a b ha hb => exact F.lie_mem ha hb + +theorem weightedLieUpperSpan_le_comap {s : ℕ} (F : NilpotentLieFiltration M s) + (φ : L →ₗ⁅ℚ⁆ M) (v : I → L) (w : I → ℕ) + (hv : ∀ i, φ (v i) ∈ F.layer (w i)) (d : ℕ) : + weightedLieUpperSpan v w d ≤ (F.layer d).comap φ.toLinearMap := by + apply Submodule.span_le.mpr + rintro x ⟨a, ha, rfl⟩ + change φ (lieTreeEval v a) ∈ F.layer d + rw [map_lieTreeEval] + exact F.antitone ha (weightedLieTree_eval_mem_layer F (fun i => φ (v i)) w hv a) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedLinearBaseProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedLinearBaseProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b7e0b4a1ee89a03507dfa06240b36ab3bb3a8aa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedLinearBaseProjection.lean @@ -0,0 +1,92 @@ +import OAI.Combinatorics.Progressions.Polynomial.WeightedLinearPolynomialRestriction + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {σ τ : Type*} [Fintype τ] [DecidableEq τ] + +theorem linearMap_coordinateGradeProjection + (A : (τ → ℚ) →ₗ[ℚ] (σ → ℚ)) (v : τ → ℕ) (w : σ → ℕ) + (hweight : ∀ j i, v j ≠ w i → A (Pi.single j 1) i = 0) + (n : ℕ) (z : τ → ℚ) : + A (fun j => if v j = n then z j else 0) = + fun i => if w i = n then A z i else 0 := by + classical + funext i + rw [← linearMap_apply_sum_coordinates A _ i] + by_cases hi : w i = n + · rw [ite_eq_left hi, ← linearMap_apply_sum_coordinates A z i] + apply Finset.sum_congr rfl + intro j _ + by_cases hj : v j = n + · rw [ite_eq_left hj] + · rw [ite_eq_right hj, mul_zero, hweight j i (by omega), zero_mul] + · rw [ite_eq_right hi] + apply Finset.sum_eq_zero + intro j _ + by_cases hj : v j = n + · rw [ite_eq_left hj, hweight j i (by omega), zero_mul] + · rw [ite_eq_right hj, mul_zero] + +theorem linearMap_preserves_weighted_base_layer + (A : (τ → ℚ) →ₗ[ℚ] (σ → ℚ)) (v : τ → ℕ) (w : σ → ℕ) + (hweight : ∀ j i, v j ≠ w i → A (Pi.single j 1) i = 0) + (n : ℕ) (z : τ → ℚ) (hz : ∀ j, v j < n → z j = 0) : + ∀ i, w i < n → A z i = 0 := by + classical + intro i hi + rw [← linearMap_apply_sum_coordinates A z i] + apply Finset.sum_eq_zero + intro j _ + by_cases hj : v j = w i + · rw [hz j (by omega), mul_zero] + · rw [hweight j i hj, zero_mul] + +theorem linearMap_coordinateGradeProjection_eq_self_iff + (A : (τ → ℚ) →ₗ[ℚ] (σ → ℚ)) (v : τ → ℕ) (w : σ → ℕ) + (hweight : ∀ j i, v j ≠ w i → A (Pi.single j 1) i = 0) + (hA : Function.Injective A) (n : ℕ) (z : τ → ℚ) : + (fun i => if w i = n then A z i else 0) = A z ↔ + (fun j => if v j = n then z j else 0) = z := by + rw [← linearMap_coordinateGradeProjection A v w hweight n z] + exact hA.eq_iff + +theorem linearMap_reflects_weighted_base_layer + (A : (τ → ℚ) →ₗ[ℚ] (σ → ℚ)) (v : τ → ℕ) (w : σ → ℕ) + (hweight : ∀ j i, v j ≠ w i → A (Pi.single j 1) i = 0) + (hA : Function.Injective A) (n : ℕ) (z : τ → ℚ) + (hz : ∀ i, w i < n → A z i = 0) : + ∀ j, v j < n → z j = 0 := by + classical + intro j hj + have hout : (fun i => if w i = v j then A z i else 0) = 0 := by + funext i + by_cases hi : w i = v j + · rw [ite_eq_left hi, hz i (by omega)] + rfl + · rw [ite_eq_right hi] + rfl + have hin : (fun k => if v k = v j then z k else 0) = 0 := by + apply hA + rw [linearMap_coordinateGradeProjection A v w hweight, hout, map_zero] + have hh := congrFun hin j + simpa only [ite_true, Pi.zero_apply] using hh + +theorem linearMap_weighted_base_layer_iff + (A : (τ → ℚ) →ₗ[ℚ] (σ → ℚ)) (v : τ → ℕ) (w : σ → ℕ) + (hweight : ∀ j i, v j ≠ w i → A (Pi.single j 1) i = 0) + (hA : Function.Injective A) (n : ℕ) (z : τ → ℚ) : + (∀ i, w i < n → A z i = 0) ↔ (∀ j, v j < n → z j = 0) := + ⟨linearMap_reflects_weighted_base_layer A v w hweight hA n z, + linearMap_preserves_weighted_base_layer A v w hweight n z⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedParameterPatchRankPadding.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedParameterPatchRankPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..05cb6a629b2cd8c2509964c951b67ade435d9292 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedParameterPatchRankPadding.lean @@ -0,0 +1,269 @@ +import OAI.Combinatorics.Progressions.Estimates.WeightedPatchReparam + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def localTentKernel (d q : ℕ) (hq : 8 ≤ q) : PatchKernel d where + value x := max 0 (1 - (q : ℝ) / 2 * dist x 0) + nonneg x := le_max_left _ _ + le_one x := max_le zero_le_one (by + have h : 0 ≤ (q : ℝ) / 2 * dist x 0 := by positivity + linarith) + support x hx i := by + have hqR : (8 : ℝ) ≤ q := by exact_mod_cast hq + have hsmall : (q : ℝ) / 2 * dist x 0 < 1 := by + by_contra h + exact hx (max_eq_left (by linarith)) + have hcoord : |x i| ≤ dist x 0 := by + simpa only [Real.dist_eq, Pi.zero_apply, sub_zero] using dist_le_pi_dist x 0 i + have hdist : 0 ≤ dist x 0 := dist_nonneg + nlinarith [mul_le_mul_of_nonneg_right hqR hdist] + lip := (q : ℝ≥0) / 2 + lipschitz := by + apply LipschitzWith.of_dist_le_mul + intro x y + change |max 0 (1 - (q : ℝ) / 2 * dist x 0) - max 0 (1 - (q : ℝ) / 2 * dist y 0)| ≤ + (q : ℝ) / 2 * dist x y + calc + _ ≤ |(1 - (q : ℝ) / 2 * dist x 0) - (1 - (q : ℝ) / 2 * dist y 0)| := by + rw [max_comm 0 _, max_comm 0 _] + exact abs_max_sub_max_le_abs _ _ _ + _ = (q : ℝ) / 2 * |dist x 0 - dist y 0| := by + rw [show (1 - (q : ℝ) / 2 * dist x 0) - (1 - (q : ℝ) / 2 * dist y 0) = + -((q : ℝ) / 2) * (dist x 0 - dist y 0) by ring, + abs_mul, abs_neg, abs_of_nonneg (by positivity : 0 ≤ (q : ℝ) / 2)] + _ ≤ _ := mul_le_mul_of_nonneg_left (abs_dist_sub_le x y 0) (by positivity) + +theorem localTentKernel_ge_half {d q : ℕ} (hq : 8 ≤ q) (x : Fin d → ℝ) + (hx : dist x 0 ≤ 1 / (q : ℝ)) : 1 / 2 ≤ (localTentKernel d q hq).value x := by + have hqR : (0 : ℝ) < q := by exact_mod_cast (show 0 < q by omega) + have hmul : (q : ℝ) * dist x 0 ≤ 1 := by + simpa only [mul_comm] using (le_div_iff₀ hqR).mp hx + exact (by linarith : (1 : ℝ) / 2 ≤ 1 - (q : ℝ) / 2 * dist x 0).trans (le_max_right _ _) + +theorem localTentKernel_support {d q : ℕ} (hq : 8 ≤ q) (x : Fin d → ℝ) + (hx : (localTentKernel d q hq).value x ≠ 0) : dist x 0 ≤ 2 / (q : ℝ) := by + have hqR : (0 : ℝ) < q := by exact_mod_cast (show 0 < q by omega) + apply (le_div_iff₀ hqR).mpr + have hsmall : (q : ℝ) / 2 * dist x 0 < 1 := by + by_contra h + exact hx (max_eq_left (by linarith)) + nlinarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators NNReal + +namespace WeightedParameterSlots + +variable {σ : Type*} {p : σ → ℕ} {d n D E : ℕ} + +theorem placementSubstitution_degree {w : Fin d → ℕ} {v : Fin n → ℕ} + (f : Fin d → Fin n) (hweight : ∀ i, v (f i) = w i) (k : Fin n) (i : Fin d) + (a : σ ⊕ Fin i.val) : + PolynomialSlots.placementSubstitution f k i a ∈ + weightedSupportLE (weightedPatchVariableWeight p v k) (weightedPatchVariableWeight p w i a) := by + cases a with + | inl a => exact weightedSupportLE_X _ (Sum.inl a) + | inr j => + simp only [PolynomialSlots.placementSubstitution, Sum.elim_inr] + split_ifs with h + · have hX := weightedSupportLE_X (R := ℝ) (weightedPatchVariableWeight (σ := σ) p v k) + (Sum.inr (⟨(f (earlierSlot i j)).val, h⟩ : Fin k.val)) + change _ ∈ weightedSupportLE _ (v (f (earlierSlot i j))) at hX + rw [hweight] at hX + exact hX + · exact (weightedSupportLE _ _).zero_mem + +noncomputable def placeCenter {w : Fin d → ℕ} (A : WeightedParameterSlots σ p d w) + (f : Fin d → Fin n) (k : Fin n) (i : Fin d) : + MvPolynomial (σ ⊕ Fin k.val) ℝ := aeval (PolynomialSlots.placementSubstitution f k i) (A.center i) + +theorem placeCenter_degree {w : Fin d → ℕ} {v : Fin n → ℕ} + (A : WeightedParameterSlots σ p d w) (f : Fin d → Fin n) + (hweight : ∀ i, v (f i) = w i) (k : Fin n) (i : Fin d) : + A.placeCenter f k i ∈ weightedSupportLE (weightedPatchVariableWeight p v k) (w i) := + weightedSupportLE_aeval _ _ _ (placementSubstitution_degree f hweight k i) (A.degree i) + +theorem placeCenter_eval {w : Fin d → ℕ} (A : WeightedParameterSlots σ p d w) + (f : Fin d → Fin n) (hf : StrictMono f) (i : Fin d) (t : σ → ℝ) (x : Fin n → ℝ) : + aeval (Sum.elim t (fun j => x (earlierSlot (f i) j))) (A.placeCenter f (f i) i) = + (A.slots t).center (fun j => x (f j)) i := by + simp only [placeCenter, MvPolynomial.comp_aeval_apply, slots] + apply congrArg (fun g : σ ⊕ Fin i.val → ℝ => aeval g (A.center i)) + funext a + cases a with + | inl a => simp [PolynomialSlots.placementSubstitution] + | inr j => + have h : (f (earlierSlot i j)).val < (f i).val := + hf (show earlierSlot i j < i from j.isLt) + simp only [PolynomialSlots.placementSubstitution, Sum.elim_inr, dite_eq_left h, aeval_X] + rfl + +noncomputable def interleave {w : Fin D → ℕ} {v : Fin E → ℕ} + (A : WeightedParameterSlots σ p D w) (B : WeightedParameterSlots σ p E v) (I : SlotInterleaving D E) : + WeightedParameterSlots σ p (D + E) (I.fill w v) where + center k := Fin.addCases (A.placeCenter I.left k) (B.placeCenter I.right k) (I.perm k) + degree k := by + change Fin.addCases (A.placeCenter I.left k) (B.placeCenter I.right k) (I.perm k) ∈ + weightedSupportLE (weightedPatchVariableWeight p (I.fill w v) k) (Fin.append w v (I.perm k)) + generalize I.perm k = z + refine Fin.addCases (fun i => ?_) (fun i => ?_) z + · simpa only [Fin.addCases_left, Fin.append_left] using + A.placeCenter_degree I.left (fun j => I.fill_left w v j) k i + · simpa only [Fin.addCases_right, Fin.append_right] using + B.placeCenter_degree I.right (fun j => I.fill_right w v j) k i + +@[simp] theorem interleave_center_left {w : Fin D → ℕ} {v : Fin E → ℕ} + (A : WeightedParameterSlots σ p D w) (B : WeightedParameterSlots σ p E v) (I : SlotInterleaving D E) + (i : Fin D) : (A.interleave B I).center (I.left i) = A.placeCenter I.left (I.left i) i := by + simp [interleave, SlotInterleaving.left] + +@[simp] theorem interleave_center_right {w : Fin D → ℕ} {v : Fin E → ℕ} + (A : WeightedParameterSlots σ p D w) (B : WeightedParameterSlots σ p E v) (I : SlotInterleaving D E) + (i : Fin E) : (A.interleave B I).center (I.right i) = B.placeCenter I.right (I.right i) i := by + simp [interleave, SlotInterleaving.right] + +theorem interleave_slots {w : Fin D → ℕ} {v : Fin E → ℕ} + (A : WeightedParameterSlots σ p D w) (B : WeightedParameterSlots σ p E v) (I : SlotInterleaving D E) + (t : σ → ℝ) : (A.interleave B I).slots t = (A.slots t).interleave (B.slots t) I := by + apply TriangularSlots.ext + intro x k + apply I.cases (p := fun k => ((A.interleave B I).slots t).center x k = + ((A.slots t).interleave (B.slots t) I).center x k) _ _ k + · intro i + change aeval _ ((A.interleave B I).center (I.left i)) = _ + rw [interleave_center_left] + simpa only [TriangularSlots.interleave, SlotInterleaving.fill_left] using + A.placeCenter_eval I.left I.left_strictMono i t x + · intro i + change aeval _ ((A.interleave B I).center (I.right i)) = _ + rw [interleave_center_right] + simpa only [TriangularSlots.interleave, SlotInterleaving.fill_right] using + B.placeCenter_eval I.right I.right_strictMono i t x + +end WeightedParameterSlots + +namespace WeightedParameterPatch + +variable {σ : Type*} {p : σ → ℕ} {s D E : ℕ} + +noncomputable def product (A : WeightedParameterPatch σ p s D) (B : WeightedParameterPatch σ p s E) : + WeightedParameterPatch σ p s (D + E) := + let I := SlotInterleaving.sorted A.weight B.weight A.weight_mono B.weight_mono + { weight := I.fill A.weight B.weight + weight_pos := I.cases (fun i => by simpa only [SlotInterleaving.fill_left] using A.weight_pos i) + (fun i => by simpa only [SlotInterleaving.fill_right] using B.weight_pos i) + weight_le := I.cases (fun i => by simpa only [SlotInterleaving.fill_left] using A.weight_le i) + (fun i => by simpa only [SlotInterleaving.fill_right] using B.weight_le i) + weight_mono := SlotInterleaving.sorted_weight_mono _ _ _ _ + form := A.form.interleave B.form I + kernel := A.kernel.product B.kernel I } + +@[simp] theorem product_lip (A : WeightedParameterPatch σ p s D) (B : WeightedParameterPatch σ p s E) : + (A.product B).kernel.lip = A.kernel.lip + B.kernel.lip := rfl + +@[simp] theorem product_value (A : WeightedParameterPatch σ p s D) (B : WeightedParameterPatch σ p s E) + (t : σ → ℝ) : (A.product B).value t = A.value t * B.value t := by + let I := SlotInterleaving.sorted A.weight B.weight A.weight_mono B.weight_mono + change ((A.form.interleave B.form I).slots t).patchValue (A.kernel.product B.kernel I) = _ + rw [WeightedParameterSlots.interleave_slots, TriangularSlots.interleave_patchValue] + rfl + +def castRank {d e : ℕ} (P : WeightedParameterPatch σ p s d) (h : d = e) : + WeightedParameterPatch σ p s e := h ▸ P + +@[simp] theorem castRank_value {d e : ℕ} (P : WeightedParameterPatch σ p s d) + (h : d = e) (t : σ → ℝ) : (P.castRank h).value t = P.value t := by + subst e + rfl + +@[simp] theorem castRank_kernel_lip {d e : ℕ} (P : WeightedParameterPatch σ p s d) + (h : d = e) : (P.castRank h).kernel.lip = P.kernel.lip := by + subst e + rfl + +noncomputable def unitRank (σ : Type*) (p : σ → ℕ) (s d : ℕ) (hs : 1 ≤ s) : + WeightedParameterPatch σ p s d where + weight := fun _ => 1 + weight_pos := fun _ => le_rfl + weight_le := fun _ => hs + weight_mono := fun _ _ _ => le_rfl + form := { center := fun _ => 0, degree := fun _ => Submodule.zero_mem _ } + kernel := localTentKernel d 8 le_rfl + +@[simp] theorem unitRank_value {σ : Type*} {p : σ → ℕ} {s d : ℕ} (hs : 1 ≤ s) (t : σ → ℝ) : + (unitRank σ p s d hs).value t = 1 := by + change ((unitRank σ p s d hs).form.slots t).patchValue (localTentKernel d 8 le_rfl) = 1 + have hres : ((unitRank σ p s d hs).form.slots t).residual 0 = 0 := by + ext i + simp [unitRank, WeightedParameterSlots.slots, TriangularSlots.residual] + rw [TriangularSlots.patchValue_eq_at_residual (b := 0)] + · rw [hres] + norm_num [localTentKernel] + · intro i + rw [hres] + norm_num + +@[simp] theorem unitRank_lip {σ : Type*} {p : σ → ℕ} {s d : ℕ} (hs : 1 ≤ s) : + (unitRank σ p s d hs).kernel.lip = 4 := by + norm_num [unitRank, localTentKernel] + +noncomputable def padRank {σ : Type*} {p : σ → ℕ} {s d D : ℕ} + (P : WeightedParameterPatch σ p s d) (hs : 1 ≤ s) (hd : d ≤ D) : + WeightedParameterPatch σ p s D := + (P.product (unitRank σ p s (D-d) hs)).castRank (Nat.add_sub_of_le hd) + +@[simp] theorem padRank_value {σ : Type*} {p : σ → ℕ} {s d D : ℕ} + (P : WeightedParameterPatch σ p s d) (hs : 1 ≤ s) (hd : d ≤ D) (t : σ → ℝ) : + (P.padRank hs hd).value t = P.value t := by + simp only [padRank, castRank_value, product_value, unitRank_value, mul_one] + +@[simp] theorem padRank_lip {σ : Type*} {p : σ → ℕ} {s d D : ℕ} + (P : WeightedParameterPatch σ p s d) (hs : 1 ≤ s) (hd : d ≤ D) : + (P.padRank hs hd).kernel.lip = P.kernel.lip + 4 := by + simp only [padRank, castRank_kernel_lip, product_lip, unitRank_lip] + +theorem padRank_score {σ Ω : Type*} {p : σ → ℕ} [Fintype Ω] {s d D : ℕ} + (P : WeightedParameterPatch σ p s d) (hs : 1 ≤ s) (hd : d ≤ D) + (t : Ω → σ → ℝ) (f : Ω → ℝ) (a : ℝ) : + (𝔼 x, (f x - a) * (P.padRank hs hd).value (t x)) = + 𝔼 x, (f x - a) * P.value (t x) := by + simp only [padRank_value] + +noncomputable def padRankFamily {σ H : Type*} {p : σ → ℕ} {s D : ℕ} + (d : H → ℕ) (P : ∀ h, WeightedParameterPatch σ p s (d h)) + (hs : 1 ≤ s) (hd : ∀ h, d h ≤ D) : H → WeightedParameterPatch σ p s D := + fun h => (P h).padRank hs (hd h) + +@[simp] theorem padRankFamily_value {σ H : Type*} {p : σ → ℕ} {s D : ℕ} + (d : H → ℕ) (P : ∀ h, WeightedParameterPatch σ p s (d h)) + (hs : 1 ≤ s) (hd : ∀ h, d h ≤ D) (h : H) (t : σ → ℝ) : + (padRankFamily d P hs hd h).value t = (P h).value t := + padRank_value _ _ _ _ + +theorem padRankFamily_lip_bound {σ H : Type*} {p : σ → ℕ} {s D : ℕ} + (d : H → ℕ) (P : ∀ h, WeightedParameterPatch σ p s (d h)) + (hs : 1 ≤ s) (hd : ∀ h, d h ≤ D) {L : ℝ≥0} + (hL : ∀ h, (P h).kernel.lip ≤ L) (h : H) : + (padRankFamily d P hs hd h).kernel.lip ≤ L + 4 := by + exact (padRank_lip (P h) hs (hd h)).le.trans (add_le_add (hL h) le_rfl) + +end WeightedParameterPatch +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedPatchKernel.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedPatchKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..309a33c819353e6da1fcb770f16c0bd4bd7e348c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedPatchKernel.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Estimates.DependentPatchValue + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal + +theorem lipschitz_mul_unit_interval {X : Type*} [PseudoMetricSpace X] + {f g : X → ℝ} {L M : ℝ≥0} (hf : LipschitzWith L f) (hg : LipschitzWith M g) + (hfI : ∀ x, f x ∈ Set.Icc (0 : ℝ) 1) (hgI : ∀ x, g x ∈ Set.Icc (0 : ℝ) 1) : + LipschitzWith (L + M) (fun x => f x * g x) := by + apply LipschitzWith.of_dist_le_mul + intro x y + have h₁ : dist (f x * g x) (f y * g x) ≤ dist (f x) (f y) := by + rw [Real.dist_eq, ← sub_mul, abs_mul, abs_of_nonneg (hgI x).1] + exact mul_le_of_le_one_right (abs_nonneg _) (hgI x).2 + have h₂ : dist (f y * g x) (f y * g y) ≤ dist (g x) (g y) := by + rw [Real.dist_eq, ← mul_sub, abs_mul, abs_of_nonneg (hfI y).1] + exact mul_le_of_le_one_left (abs_nonneg _) (hfI y).2 + exact (dist_triangle _ (f y * g x) _).trans + ((add_le_add (h₁.trans (hf.dist_le_mul _ _)) (h₂.trans (hg.dist_le_mul _ _))).trans_eq + (by simp [add_mul])) + +namespace PatchKernel + +variable {d : ℕ} + +def weight (Φ : PatchKernel d) (f : (Fin d → ℝ) → ℝ) (L : ℝ≥0) + (hf : LipschitzWith L f) (hI : ∀ x, f x ∈ Set.Icc (0 : ℝ) 1) : PatchKernel d where + value x := Φ.value x * f x + nonneg x := mul_nonneg (Φ.nonneg x) (hI x).1 + le_one x := (mul_le_of_le_one_left (hI x).1 (Φ.le_one x)).trans (hI x).2 + support x hx := Φ.support x (mul_ne_zero_iff.mp hx).1 + lip := Φ.lip + L + lipschitz := lipschitz_mul_unit_interval Φ.lipschitz hf (fun x => ⟨Φ.nonneg x, Φ.le_one x⟩) hI + +@[simp] theorem weight_lip (Φ : PatchKernel d) (f : (Fin d → ℝ) → ℝ) (L : ℝ≥0) + (hf : LipschitzWith L f) (hI : ∀ x, f x ∈ Set.Icc (0 : ℝ) 1) : + (Φ.weight f L hf hI).lip = Φ.lip + L := rfl + +@[simp] theorem weight_value (Φ : PatchKernel d) (f : (Fin d → ℝ) → ℝ) (L : ℝ≥0) + (hf : LipschitzWith L f) (hI : ∀ x, f x ∈ Set.Icc (0 : ℝ) 1) (x : Fin d → ℝ) : + (Φ.weight f L hf hI).value x = Φ.value x * f x := rfl + +def weightAlong {m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m) + (g : (Fin d → ℝ) → Fin m → ℝ) (K : ℝ≥0) (hg : LipschitzWith K g) : PatchKernel d := + Φ.weight (fun x => Ψ.value (g x)) (Ψ.lip * K) (Ψ.lipschitz.comp hg) + (fun x => ⟨Ψ.nonneg (g x), Ψ.le_one (g x)⟩) + +@[simp] theorem weightAlong_lip {m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m) + (g : (Fin d → ℝ) → Fin m → ℝ) (K : ℝ≥0) (hg : LipschitzWith K g) : + (Φ.weightAlong Ψ g K hg).lip = Φ.lip + Ψ.lip * K := rfl + +@[simp] theorem weightAlong_value {m : ℕ} (Φ : PatchKernel d) (Ψ : PatchKernel m) + (g : (Fin d → ℝ) → Fin m → ℝ) (K : ℝ≥0) (hg : LipschitzWith K g) + (x : Fin d → ℝ) : (Φ.weightAlong Ψ g K hg).value x = Φ.value x * Ψ.value (g x) := rfl + +end PatchKernel +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationAssociatedGradedProjection.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationAssociatedGradedProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..f31aa527a28cb4e35667122e3cbd61db39a3c5db --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationAssociatedGradedProjection.lean @@ -0,0 +1,61 @@ +import OAI.Combinatorics.Progressions.Fourier.HomogeneousGradedProjectionFrequency + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie +open Module MvPolynomial + +variable {σ L ι : Type*} [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} (F : NilpotentLieFiltration L s) + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + (φ : L →ₗ⁅ℚ⁆ weightedSubalgebra w d) + (hφ : ∀ j, ∀ x ∈ F.layer j, φ x ∈ (weightedFiltration w d hwd).layer j) + +noncomputable def weightedTranslationGradedProjection : + F.AssociatedGraded →ₗ⁅ℚ⁆ weightedSubalgebra w d := + F.homogeneousGradedProjection (weightedFiltration w d hwd) + (weightedBasis w d hw) (weightedBasisGrade w d) + (weightedFiltration_layer_eq_span w d hw hwd) + (weightedBasis_homogeneous_brackets w d hw) φ hφ + +variable (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + +theorem weightedTranslationGradedProjection_basis_base (i : ι) (a : σ) : + (weightedTranslationGradedProjection F w d hw hwd φ hφ + (F.associatedGradedBasis b ω hF i)).val.base a = + if ω i = w a then (φ (b i)).val.base a else 0 := by + simpa only [weightedTranslationGradedProjection, weightedBasis_repr_inl, weightedBasisGrade_inl] using + F.homogeneousGradedProjection_basis_repr (weightedFiltration w d hwd) + (weightedBasis w d hw) (weightedBasisGrade w d) + (weightedFiltration_layer_eq_span w d hw hwd) + (weightedBasis_homogeneous_brackets w d hw) φ hφ b ω hF i (Sum.inl a) + +theorem weightedTranslationGradedProjection_basis_coeff (i : ι) + (a : {a : σ →₀ ℕ | Finsupp.weight w a < d}) : + (weightedTranslationGradedProjection F w d hw hwd φ hφ + (F.associatedGradedBasis b ω hF i)).val.polynomial.coeff a.val = + if ω i = d - Finsupp.weight w a.val then (φ (b i)).val.polynomial.coeff a.val else 0 := by + simpa only [weightedTranslationGradedProjection, weightedBasis_repr_inr, weightedBasisGrade_inr] using + F.homogeneousGradedProjection_basis_repr (weightedFiltration w d hwd) + (weightedBasis w d hw) (weightedBasisGrade w d) + (weightedFiltration_layer_eq_span w d hw hwd) + (weightedBasis_homogeneous_brackets w d hw) φ hφ b ω hF i (Sum.inr a) + +theorem weightedTranslationGradedProjection_image_graded + (W : LieSubalgebra ℚ F.AssociatedGraded) + (hW : BasisGradedSubmodule (F.associatedGradedBasis b ω hF) ω W.toSubmodule) : + BasisGradedSubmodule (weightedBasis w d hw) (weightedBasisGrade w d) + (W.map (weightedTranslationGradedProjection F w d hw hwd φ hφ)).toSubmodule := + F.homogeneousGradedProjection_image_graded (weightedFiltration w d hwd) + (weightedBasis w d hw) (weightedBasisGrade w d) + (weightedFiltration_layer_eq_span w d hw hwd) + (weightedBasis_homogeneous_brackets w d hw) φ hφ b ω hF W hW + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationBasisHeight.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationBasisHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecc89e715bdd4056d701e0426ca6c6f3634b6be2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationBasisHeight.lean @@ -0,0 +1,462 @@ +import Mathlib.LinearAlgebra.Basis.Prod +import OAI.Combinatorics.Progressions.Estimates.WeightedTranslationShearExponential +import OAI.Combinatorics.Progressions.Linear.BasisGradedCoordinateBasis + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial +variable {σ : Type*} [Fintype σ] + +noncomputable def constantDirection : PolynomialTranslationLie σ := ⟨0, 1⟩ + +noncomputable def topProjection (w : σ → ℕ) (d : ℕ) : + PolynomialTranslationLie σ →ₗ[ℚ] PolynomialTranslationLie σ where + toFun x := ⟨fun i => if w i = d then x.base i else 0, C (x.polynomial.coeff 0)⟩ + map_add' x y := by + ext i + · by_cases hi : w i = d <;> simp [hi] + · simp + map_smul' r x := by + ext i + · by_cases hi : w i = d <;> simp [hi] + · simp + +omit [Fintype σ] in +@[simp] theorem topProjection_base (w : σ → ℕ) (d : ℕ) + (x : PolynomialTranslationLie σ) (i : σ) : + (topProjection w d x).base i = if w i = d then x.base i else 0 := rfl + +omit [Fintype σ] in +@[simp] theorem topProjection_polynomial (w : σ → ℕ) (d : ℕ) + (x : PolynomialTranslationLie σ) : + (topProjection w d x).polynomial = C (x.polynomial.coeff 0) := rfl + +omit [Fintype σ] in +theorem topProjection_mem_top (w : σ → ℕ) (d : ℕ) (x : PolynomialTranslationLie σ) : + topProjection w d x ∈ weightedLayer w d d := by + refine ⟨fun i hi => ?_, ?_⟩ + · simp [Nat.ne_of_lt hi] + · exact (monomial_mem_restrictSupport ℚ).mpr (Or.inl (by simp)) + +omit [Fintype σ] in +theorem topProjection_pure (w : σ → ℕ) (d : ℕ) (P : MvPolynomial σ ℚ) : + topProjection w d ⟨0, P⟩ = P.coeff 0 • (constantDirection : PolynomialTranslationLie σ) := by + apply PolynomialTranslationLie.ext + · funext i + simp [constantDirection] + · simp [constantDirection, MvPolynomial.C_eq_smul_one] + +theorem pure_constant_zero_of_top_frequency (w : σ → ℕ) (d : ℕ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hgraded : ∀ x ∈ U, topProjection w d x ∈ U) + (frequency : PolynomialTranslationLie σ →ₗ[ℚ] ℚ) + (hfrequency : frequency constantDirection ≠ 0) + (hkill : ∀ x ∈ U, x ∈ weightedLayer w d d → frequency x = 0) + (P : MvPolynomial σ ℚ) (hP : (⟨0, P⟩ : PolynomialTranslationLie σ) ∈ U) : + P.coeff 0 = 0 := by + have h := hkill _ (hgraded _ hP) (topProjection_mem_top w d ⟨0, P⟩) + rw [topProjection_pure, map_smul, smul_eq_mul] at h + exact (mul_eq_zero.mp h).resolve_right hfrequency + +theorem raw_lie_mem (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (x z : σ → ℚ) (P Q : MvPolynomial σ ℚ) + (hx : (⟨x,P⟩ : PolynomialTranslationLie σ) ∈ U) + (hz : (⟨z,Q⟩ : PolynomialTranslationLie σ) ∈ U) : + (⟨0, scalarDirectionalDerivative x Q - scalarDirectionalDerivative z P⟩ : + PolynomialTranslationLie σ) ∈ U := + U.lie_mem (x := ⟨x,P⟩) (y := ⟨z,Q⟩) hx hz + +noncomputable def relationSpace (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) : + Submodule ℚ ((σ → ℚ) × MvPolynomial σ ℚ) := + U.toSubmodule.comap toProdl.symm.toLinearMap + +theorem mem_relationSpace (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (x : σ → ℚ) (P : MvPolynomial σ ℚ) : + (x,P) ∈ relationSpace U ↔ (⟨x,P⟩ : PolynomialTranslationLie σ) ∈ U := Iff.rfl + +noncomputable def potentialRelationOfTopFrequency (w : σ → ℕ) (d : ℕ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hgraded : ∀ x ∈ U, topProjection w d x ∈ U) + (frequency : PolynomialTranslationLie σ →ₗ[ℚ] ℚ) + (hfrequency : frequency constantDirection ≠ 0) + (hkill : ∀ x ∈ U, x ∈ weightedLayer w d d → frequency x = 0) : + Erdos3.PolynomialPotentialRelation σ where + space := relationSpace U + bracket_mem := by + intro x P z Q hx hz + exact (mem_relationSpace U _ _).mpr (raw_lie_mem U x z P Q + ((mem_relationSpace U _ _).mp hx) ((mem_relationSpace U _ _).mp hz)) + pure_constant_zero := fun P hP => pure_constant_zero_of_top_frequency w d U hgraded + frequency hfrequency hkill P ((mem_relationSpace U _ _).mp hP) + +@[simp] theorem mem_potentialRelationOfTopFrequency (w : σ → ℕ) (d : ℕ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hgraded : ∀ x ∈ U, topProjection w d x ∈ U) + (frequency : PolynomialTranslationLie σ →ₗ[ℚ] ℚ) + (hfrequency : frequency constantDirection ≠ 0) + (hkill : ∀ x ∈ U, x ∈ weightedLayer w d d → frequency x = 0) + (x : σ → ℚ) (P : MvPolynomial σ ℚ) : + (x,P) ∈ (potentialRelationOfTopFrequency w d U hgraded frequency hfrequency hkill).space ↔ + (⟨x,P⟩ : PolynomialTranslationLie σ) ∈ U := Iff.rfl + +theorem exists_weighted_potential_of_top_frequency [DecidableEq σ] + (w : σ → ℕ) {d : ℕ} (hd : 0 < d) (hw : ∀ i, w i ≤ d) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hgraded : ∀ x ∈ U, topProjection w d x ∈ U) + (frequency : PolynomialTranslationLie σ →ₗ[ℚ] ℚ) + (hfrequency : frequency constantDirection ≠ 0) + (hkill : ∀ x ∈ U, x ∈ weightedLayer w d d → frequency x = 0) + (P : σ → MvPolynomial σ ℚ) + (hlift : ∀ i, (⟨Pi.single i 1, P i⟩ : PolynomialTranslationLie σ) ∈ U) + (hhom : ∀ i, (P i).IsWeightedHomogeneous w (d - w i)) : + ∃ V : MvPolynomial σ ℚ, V.IsWeightedHomogeneous w d ∧ + ∀ x ∈ U, scalarDirectionalDerivative x.base V = x.polynomial := by + let A := potentialRelationOfTopFrequency w d U hgraded frequency hfrequency hkill + have hA : ∀ i, (Pi.single i 1, P i) ∈ A.space := hlift + obtain ⟨V,hV,h⟩ := A.exists_weighted_potential P hA w hd hw hhom + exact ⟨V,hV,fun x hx => h x.base x.polynomial hx⟩ + +theorem exponential_closure_potential_of_top_frequency [DecidableEq σ] + (w : σ → ℕ) {d : ℕ} (hd : 0 < d) (hw : ∀ i, w i ≤ d) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hgraded : ∀ x ∈ U, topProjection w d x ∈ U) + (frequency : PolynomialTranslationLie σ →ₗ[ℚ] ℚ) + (hfrequency : frequency constantDirection ≠ 0) + (hkill : ∀ x ∈ U, x ∈ weightedLayer w d d → frequency x = 0) + (P : σ → MvPolynomial σ ℚ) + (hlift : ∀ i, (⟨Pi.single i 1, P i⟩ : PolynomialTranslationLie σ) ∈ U) + (hhom : ∀ i, (P i).IsWeightedHomogeneous w (d - w i)) : + ∃ V : MvPolynomial σ ℚ, V.IsWeightedHomogeneous w d ∧ + ∀ g ∈ Subgroup.closure + ((fun x : U => PolynomialTranslationGroup.exponentialElement + x.val.base x.val.polynomial) '' Set.univ), + g.polynomial = V - polynomialTranslate (-g.base) V := by + obtain ⟨V,hV,h⟩ := exists_weighted_potential_of_top_frequency w hd hw U hgraded + frequency hfrequency hkill P hlift hhom + refine ⟨V,hV,fun g hg => PolynomialTranslationGroup.potential_identity_of_mem_closure V ?_ hg⟩ + rintro a ⟨x,_,rfl⟩ + exact ⟨x.val.base, by rw [h x.val x.property]⟩ + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module + +variable {σ : Type*} [Fintype σ] + +noncomputable def weightedCoordinatesEquiv (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) : + weightedSubalgebra w d ≃ₗ[ℚ] (σ → ℚ) × weightedSupportLT (R := ℚ) w d where + toFun x := (x.val.base, ⟨x.val.polynomial, + by simpa only [← weightedSupportDrop_one] using x.property.2⟩) + invFun x := ⟨⟨x.1, x.2.val⟩, ⟨fun i hi => by have := hw i; omega, + by simpa only [weightedSupportDrop_one] using x.2.property⟩⟩ + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl + +abbrev WeightedBasisIndex (w : σ → ℕ) (d : ℕ) := + σ ⊕ {a : σ →₀ ℕ | Finsupp.weight w a < d} + +noncomputable def weightedBasis (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) : + Basis (WeightedBasisIndex w d) ℚ (weightedSubalgebra w d) := + ((Pi.basisFun ℚ σ).prod + (MvPolynomial.basisRestrictSupport ℚ {a : σ →₀ ℕ | Finsupp.weight w a < d})).map + (weightedCoordinatesEquiv w d hw).symm + +noncomputable def weightedBasisGrade (w : σ → ℕ) (d : ℕ) : WeightedBasisIndex w d → ℕ := + Sum.elim w (fun a => d - Finsupp.weight w a.val) + +@[simp] theorem weightedBasis_repr_inl (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (x : weightedSubalgebra w d) (i : σ) : + (weightedBasis w d hw).repr x (Sum.inl i) = x.val.base i := by + change (Pi.basisFun ℚ σ).repr x.val.base i = _ + simp only [Pi.basisFun_repr] + +@[simp] theorem weightedBasis_repr_inr (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (x : weightedSubalgebra w d) (a : {a : σ →₀ ℕ | Finsupp.weight w a < d}) : + (weightedBasis w d hw).repr x (Sum.inr a) = x.val.polynomial.coeff a.val := by + rfl + +omit [Fintype σ] in +@[simp] theorem weightedBasisGrade_inl (w : σ → ℕ) (d : ℕ) (i : σ) : + weightedBasisGrade w d (Sum.inl i) = w i := rfl + +omit [Fintype σ] in +@[simp] theorem weightedBasisGrade_inr (w : σ → ℕ) (d : ℕ) + (a : {a : σ →₀ ℕ | Finsupp.weight w a < d}) : + weightedBasisGrade w d (Sum.inr a) = d - Finsupp.weight w a.val := rfl + +@[simp] theorem weightedBasis_projection_base (w : σ → ℕ) (d j : ℕ) + (hw : ∀ i, 0 < w i) (x : weightedSubalgebra w d) (i : σ) : + (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) j x).val.base i = + if w i = j then x.val.base i else 0 := by + simpa only [weightedBasis_repr_inl, weightedBasisGrade_inl] using + basisGradeProjection_repr (weightedBasis w d hw) (weightedBasisGrade w d) j x (Sum.inl i) + +@[simp] theorem weightedBasis_projection_coeff (w : σ → ℕ) (d j : ℕ) + (hw : ∀ i, 0 < w i) (x : weightedSubalgebra w d) + (a : {a : σ →₀ ℕ | Finsupp.weight w a < d}) : + (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) j x).val.polynomial.coeff a.val = + if d - Finsupp.weight w a.val = j then x.val.polynomial.coeff a.val else 0 := by + simpa only [weightedBasis_repr_inr, weightedBasisGrade_inr] using + basisGradeProjection_repr (weightedBasis w d hw) (weightedBasisGrade w d) j x (Sum.inr a) + +theorem weightedBasis_top_projection_polynomial (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) (x : weightedSubalgebra w d) : + (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) d x).val.polynomial = + C (x.val.polynomial.coeff 0) := by + classical + let : Finsupp.NonTorsionWeight ℕ w := Finsupp.nonTorsionWeight_of ℕ w (fun i => (hw i).ne') + apply MvPolynomial.ext + intro a + by_cases ha : Finsupp.weight w a < d + · rw [weightedBasis_projection_coeff w d d hw x ⟨a, ha⟩] + have he : d - Finsupp.weight w a = d ↔ a = 0 := by + rw [← Finsupp.weight_eq_zero_iff_eq_zero w] + omega + simp only [he] + by_cases ha0 : a = 0 + · subst a + simp + · simp [ha0, Ne.symm ha0] + · have ha0 : a ≠ 0 := by + intro h + subst a + simp only [map_zero] at ha + omega + rw [coeff_C, ite_eq_right (Ne.symm ha0)] + by_contra hne + have hh := (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) d x).property.2 + (MvPolynomial.mem_support_iff.mpr hne) + change Finsupp.weight w a + 1 ≤ d at hh + omega + +theorem weightedBasis_top_projection_val (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) (x : weightedSubalgebra w d) : + (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) d x).val = + ⟨fun i => if w i = d then x.val.base i else 0, C (x.val.polynomial.coeff 0)⟩ := by + apply PolynomialTranslationLie.ext + · funext i + exact weightedBasis_projection_base w d d hw x i + · exact weightedBasis_top_projection_polynomial w d hw hd x + +theorem weightedFiltration_layer_eq_span (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) (j : ℕ) : + (weightedFiltration w d hwd).layer j = + Submodule.span ℚ (weightedBasis w d hw '' {i | j ≤ weightedBasisGrade w d i}) := by + ext x + rw [basis_mem_span_image_iff] + constructor + · intro hx a ha + change (∀ i, w i < j → x.val.base i = 0) ∧ + x.val.polynomial ∈ weightedSupportDrop w d j at hx + cases a with + | inl i => + rw [weightedBasis_repr_inl] + exact hx.1 i (by change ¬ j ≤ w i at ha; omega) + | inr a => + rw [weightedBasis_repr_inr] + by_contra hne + have hh := hx.2 (MvPolynomial.mem_support_iff.mpr hne) + change Finsupp.weight w a.val + j ≤ d at hh + change ¬ j ≤ d - Finsupp.weight w a.val at ha + omega + · intro hx + change (∀ i, w i < j → x.val.base i = 0) ∧ + x.val.polynomial ∈ weightedSupportDrop w d j + constructor + · intro i hi + exact (weightedBasis_repr_inl w d hw x i) ▸ hx (Sum.inl i) (by + change ¬ j ≤ w i + omega) + · intro a ha + have hb := x.property.2 ha + change Finsupp.weight w a + 1 ≤ d at hb + change Finsupp.weight w a + j ≤ d + by_contra hnot + have haLT : Finsupp.weight w a < d := by omega + have hh := hx (Sum.inr ⟨a, haLT⟩) (by + change ¬ j ≤ d - Finsupp.weight w a + omega) + rw [weightedBasis_repr_inr] at hh + exact (MvPolynomial.mem_support_iff.mp ha) hh + +theorem weightedBasis_top_projection_eq (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) (x : weightedSubalgebra w d) : + (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) d x).val = + topProjection w d x.val := + weightedBasis_top_projection_val w d hw hd x + +theorem topProjection_mem_map_of_basisGraded (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) + (U : Submodule ℚ (weightedSubalgebra w d)) + (hU : BasisGradedSubmodule (weightedBasis w d hw) (weightedBasisGrade w d) U) + {x : PolynomialTranslationLie σ} + (hx : x ∈ U.map (weightedSubalgebra w d).subtype) : + topProjection w d x ∈ U.map (weightedSubalgebra w d).subtype := by + obtain ⟨y, hy, rfl⟩ := hx + exact ⟨_, hU d y hy, weightedBasis_top_projection_eq w d hw hd y⟩ + +theorem topProjection_mem_of_basisGraded (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (hd : 0 < d) + (U : Submodule ℚ (PolynomialTranslationLie σ)) + (hU : U ≤ (weightedSubalgebra w d).toSubmodule) + (hgraded : BasisGradedSubmodule (weightedBasis w d hw) (weightedBasisGrade w d) + (U.comap (weightedSubalgebra w d).subtype)) + {x : PolynomialTranslationLie σ} (hx : x ∈ U) : topProjection w d x ∈ U := by + let y : weightedSubalgebra w d := ⟨x, hU hx⟩ + have hy := hgraded d y hx + change (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) d y).val ∈ U at hy + rw [weightedBasis_top_projection_eq w d hw hd] at hy + exact hy + +theorem weightedBasis_projection_isWeightedHomogeneous (w : σ → ℕ) (d j : ℕ) + (hw : ∀ i, 0 < w i) (x : weightedSubalgebra w d) : + (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) j x).val.polynomial.IsWeightedHomogeneous w (d - j) := by + classical + intro a ha + have hbound := (basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) j x).property.2 + (MvPolynomial.mem_support_iff.mpr ha) + change Finsupp.weight w a + 1 ≤ d at hbound + have haLT : Finsupp.weight w a < d := by omega + rw [weightedBasis_projection_coeff w d j hw x ⟨a, haLT⟩] at ha + have hgrade : d - Finsupp.weight w a = j := by + by_contra hne + simp only [hne, ↓reduceIte, ne_self_iff_false] at ha + omega + +theorem exists_homogeneous_coordinate_lifts [DecidableEq σ] (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (U : Submodule ℚ (weightedSubalgebra w d)) + (hgraded : BasisGradedSubmodule (weightedBasis w d hw) (weightedBasisGrade w d) U) + (hsurj : Function.Surjective (fun x : U => x.val.val.base)) : + ∃ P : σ → MvPolynomial σ ℚ, + (∀ i, (⟨Pi.single i 1, P i⟩ : PolynomialTranslationLie σ) ∈ + U.map (weightedSubalgebra w d).subtype) ∧ + ∀ i, (P i).IsWeightedHomogeneous w (d - w i) := by + classical + have h : ∀ i : σ, ∃ P : MvPolynomial σ ℚ, + (⟨Pi.single i 1, P⟩ : PolynomialTranslationLie σ) ∈ + U.map (weightedSubalgebra w d).subtype ∧ + P.IsWeightedHomogeneous w (d - w i) := by + intro i + obtain ⟨x, hx⟩ := hsurj (Pi.single i 1) + change x.val.val.base = Pi.single i 1 at hx + let y := basisGradeProjection (weightedBasis w d hw) (weightedBasisGrade w d) (w i) x.val + have hy : y ∈ U := hgraded (w i) x.val x.property + have hbase : y.val.base = Pi.single i 1 := by + funext k + rw [weightedBasis_projection_base, hx] + by_cases hk : k = i + · subst k + simp + · simp [hk] + refine ⟨y.val.polynomial, ⟨y, hy, ?_⟩, + weightedBasis_projection_isWeightedHomogeneous w d (w i) hw x.val⟩ + exact PolynomialTranslationLie.ext hbase rfl + choose P hP hhom using h + exact ⟨P, hP, hhom⟩ + +theorem exists_ambient_homogeneous_coordinate_lifts [DecidableEq σ] (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (U : Submodule ℚ (PolynomialTranslationLie σ)) + (hU : U ≤ (weightedSubalgebra w d).toSubmodule) + (hgraded : BasisGradedSubmodule (weightedBasis w d hw) (weightedBasisGrade w d) + (U.comap (weightedSubalgebra w d).subtype)) + (hsurj : Function.Surjective (fun x : U => x.val.base)) : + ∃ P : σ → MvPolynomial σ ℚ, + (∀ i, (⟨Pi.single i 1, P i⟩ : PolynomialTranslationLie σ) ∈ U) ∧ + ∀ i, (P i).IsWeightedHomogeneous w (d - w i) := by + let U' := U.comap (weightedSubalgebra w d).subtype + have hs : Function.Surjective (fun x : U' => x.val.val.base) := by + intro b + obtain ⟨x, hx⟩ := hsurj b + exact ⟨⟨⟨x.val, hU x.property⟩, x.property⟩, hx⟩ + obtain ⟨P, hP, hhom⟩ := exists_homogeneous_coordinate_lifts w d hw U' hgraded hs + refine ⟨P, fun i => ?_, hhom⟩ + obtain ⟨x, hx, he⟩ := hP i + exact he ▸ hx + +omit [Fintype σ] in +theorem weightedBasisGrade_pos (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (i : WeightedBasisIndex w d) : 0 < weightedBasisGrade w d i := by + cases i with + | inl i => exact hw i + | inr a => exact Nat.sub_pos_of_lt a.property + +omit [Fintype σ] in +theorem weightedBasisGrade_le (w : σ → ℕ) (d : ℕ) (hw : ∀ i, w i ≤ d) + (i : WeightedBasisIndex w d) : weightedBasisGrade w d i ≤ d := by + cases i with + | inl i => exact hw i + | inr a => exact Nat.sub_le _ _ + +theorem weightedBasisIndex_finite (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) : + Finite (WeightedBasisIndex w d) := by + let : Finite {a : σ →₀ ℕ | Finsupp.weight w a < d} := + (Finsupp.finite_of_nat_weight_lt w (fun i => (hw i).ne') d).to_subtype + infer_instance + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial + +variable {σ : Type*} [Fintype σ] + (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (x : weightedSubalgebra w d) {H : ℕ} + +theorem weightedBasis_base_height + (hall : ∀ i : WeightedBasisIndex w d, + RationalHeightLE ((weightedBasis w d hw).repr x i) H) : + ∀ i, RationalHeightLE (x.val.base i) H := by + intro i + simpa only [weightedBasis_repr_inl] using hall (Sum.inl i) + +theorem weightedBasis_polynomial_height (hH : 1 ≤ H) + (hall : ∀ i : WeightedBasisIndex w d, + RationalHeightLE ((weightedBasis w d hw).repr x i) H) : + RationalPolynomialHeightLE x.val.polynomial H := by + intro α + by_cases hα : Finsupp.weight w α < d + · exact hall (Sum.inr ⟨α, hα⟩) + · have hzero : x.val.polynomial.coeff α = 0 := by + by_contra hne + have h := x.property.2 (MvPolynomial.mem_support_iff.mpr hne) + change Finsupp.weight w α + 1 ≤ d at h + omega + rw [hzero] + exact rationalHeightLE_zero hH + +theorem weightedBasis_height_iff (hH : 1 ≤ H) : + (∀ i : WeightedBasisIndex w d, + RationalHeightLE ((weightedBasis w d hw).repr x i) H) ↔ + (∀ i, RationalHeightLE (x.val.base i) H) ∧ + RationalPolynomialHeightLE x.val.polynomial H := by + constructor + · intro hall + exact ⟨weightedBasis_base_height w d hw x hall, + weightedBasis_polynomial_height w d hw x hH hall⟩ + · rintro ⟨hbase, hpoly⟩ (i | α) + · simpa only [weightedBasis_repr_inl] using hbase i + · exact hpoly α.val + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationOrderedBasis.lean b/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationOrderedBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..36c38d788067e96e25e46a845361a4f305343893 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WeightedTranslationOrderedBasis.lean @@ -0,0 +1,111 @@ +import OAI.Combinatorics.Progressions.Estimates.WeightedTranslationStructureConstants + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open Module + +variable {σ : Type*} [Fintype σ] (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) [Fintype (WeightedBasisIndex w d)] + +noncomputable def weightedIndexOrder : + WeightedBasisIndex w d ≃ Fin (Fintype.card (WeightedBasisIndex w d)) := + let ρ := Fintype.equivFin (WeightedBasisIndex w d) + let u := fun j => weightedBasisGrade w d (ρ.symm j) + ρ.trans (Tuple.sort u).symm + +noncomputable def weightedOrderedBasis : + Basis (Fin (Fintype.card (WeightedBasisIndex w d))) ℚ (weightedSubalgebra w d) := + (weightedBasis w d hw).reindex (weightedIndexOrder w d) + +noncomputable def weightedOrderedGrade (j : Fin (Fintype.card (WeightedBasisIndex w d))) : ℕ := + weightedBasisGrade w d ((weightedIndexOrder w d).symm j) + +omit [Fintype σ] in +theorem weightedOrderedGrade_monotone : Monotone (weightedOrderedGrade w d) := + Tuple.monotone_sort (fun j => weightedBasisGrade w d ((Fintype.equivFin (WeightedBasisIndex w d)).symm j)) + +include hw in +omit [Fintype σ] in +theorem weightedOrderedGrade_pos (j : Fin (Fintype.card (WeightedBasisIndex w d))) : + 0 < weightedOrderedGrade w d j := weightedBasisGrade_pos w d hw _ + +omit [Fintype σ] in +theorem weightedOrderedGrade_le (hwd : ∀ i, w i ≤ d) + (j : Fin (Fintype.card (WeightedBasisIndex w d))) : weightedOrderedGrade w d j ≤ d := + weightedBasisGrade_le w d hwd _ + +theorem weightedOrderedBasis_layers (hwd : ∀ i, w i ≤ d) (r : ℕ) : + (weightedFiltration w d hwd).layer r = Submodule.span ℚ + (weightedOrderedBasis w d hw '' {j | r ≤ weightedOrderedGrade w d j}) := by + change (weightedFiltration w d hwd).layer r = Submodule.span ℚ + (((weightedBasis w d hw).reindex (weightedIndexOrder w d)) '' + {j | r ≤ weightedBasisGrade w d ((weightedIndexOrder w d).symm j)}) + rw [basis_reindex_span_weights, ← weightedFiltration_layer_eq_span w d hw hwd r] + +theorem weightedOrderedBasis_central (hwd : ∀ i, w i ≤ d) : + IsCentralLieBasis (weightedOrderedBasis w d hw) := + centralLieBasis_of_sorted_filtration (weightedFiltration w d hwd) + (weightedOrderedBasis w d hw) (weightedOrderedGrade w d) + (weightedOrderedGrade_monotone w d) (weightedOrderedBasis_layers w d hw hwd) + +noncomputable def weightedLayerBasis (hwd : ∀ i, w i ≤ d) (r : ℕ) : + Basis {j : Fin (Fintype.card (WeightedBasisIndex w d)) // r ≤ weightedOrderedGrade w d j} + ℚ ((weightedFiltration w d hwd).layer r) := + supportedSubmoduleBasis (weightedOrderedBasis w d hw) ((weightedFiltration w d hwd).layer r) + {j | r ≤ weightedOrderedGrade w d j} (weightedOrderedBasis_layers w d hw hwd r) + +theorem weightedLayerBasis_height (hwd : ∀ i, w i ≤ d) (r : ℕ) + (i : {j : Fin (Fintype.card (WeightedBasisIndex w d)) // r ≤ weightedOrderedGrade w d j}) (j) : + RationalHeightLE ((weightedOrderedBasis w d hw).repr + (weightedLayerBasis w d hw hwd r i).val j) 1 := by + rw [weightedLayerBasis, supportedSubmoduleBasis_coe] + exact basis_repr_height_one (weightedOrderedBasis w d hw) _ _ + +noncomputable def weightedLayerIndexEquiv (hwd : ∀ i, w i ≤ d) (r : ℕ) : + {j : Fin (Fintype.card (WeightedBasisIndex w d)) // r ≤ weightedOrderedGrade w d j} ≃ + Fin (finrank ℚ ((weightedFiltration w d hwd).layer r)) := by + classical + exact Fintype.equivFinOfCardEq (finrank_eq_card_basis (weightedLayerBasis w d hw hwd r)).symm + +noncomputable def weightedLayerFinBasis (hwd : ∀ i, w i ≤ d) (r : ℕ) : + Basis (Fin (finrank ℚ ((weightedFiltration w d hwd).layer r))) + ℚ ((weightedFiltration w d hwd).layer r) := + (weightedLayerBasis w d hw hwd r).reindex (weightedLayerIndexEquiv w d hw hwd r) + +theorem weightedLayerFinBasis_height (hwd : ∀ i, w i ≤ d) (r : ℕ) (i j) : + RationalHeightLE ((weightedOrderedBasis w d hw).repr + (weightedLayerFinBasis w d hw hwd r i).val j) 1 := by + rw [weightedLayerFinBasis, Basis.reindex_apply] + exact weightedLayerBasis_height w d hw hwd r _ _ + +include hw in +theorem weightedBasisIndex_card_le : + Fintype.card (WeightedBasisIndex w d) ≤ Fintype.card σ + (Fintype.card σ + 1)^d := by + rw [← finrank_eq_card_basis (weightedBasis w d hw)] + exact weightedSubalgebra_finrank_le w d hw + +@[simp] theorem weightedOrderedBasis_repr (x : weightedSubalgebra w d) + (i : Fin (Fintype.card (WeightedBasisIndex w d))) : + (weightedOrderedBasis w d hw).repr x i = + (weightedBasis w d hw).repr x ((weightedIndexOrder w d).symm i) := + Basis.repr_reindex_apply _ _ _ _ + +theorem weightedOrderedBasis_structure_height (a b c) : + RationalHeightLE (lieStructureConstants (weightedOrderedBasis w d hw) a b c) (2 * d + 1) := by + rw [weightedOrderedBasis, lieStructureConstants_reindex] + exact weightedBasis_structure_height w d hw _ _ _ + +theorem weightedOrderedBasis_structure_height_succ (a b c) : + RationalHeightLE (lieStructureConstants (weightedOrderedBasis w d hw) a b c) (d + 1) := by + rw [weightedOrderedBasis, lieStructureConstants_reindex] + exact weightedBasis_structure_height_succ w d hw _ _ _ + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/WindowGoodKernelBound.lean b/lean/OAI/Combinatorics/Progressions/Linear/WindowGoodKernelBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..8471a174260d86467487493e3214ecb5323d2693 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/WindowGoodKernelBound.lean @@ -0,0 +1,45 @@ +import OAI.Combinatorics.Progressions.Linear.AllocatedKernelPrimitiveBudget +import OAI.Combinatorics.Progressions.Probability.ScalarCubeWindowLaw + +namespace OAI + +section + +namespace Erdos3 + +theorem exists_window_good_scalar_kernel_bound (I J : Type*) + [Fintype I] [DecidableEq I] [Nonempty I] [Fintype J] [DecidableEq J] + (hJ : Fintype.card J = Fintype.card I * (Fintype.card I + 2)) : + ∃ s : I ↪ J, ∀ (M D : ℕ), 0 < M → ∀ hD : 0 < D, ∀ η : ℝ, 0 < η → ∃ B L₀ : ℕ, + 0 < B ∧ ∃ hsize : D * ((Fintype.card I + 1) * M) ≤ L₀, + ∀ (L : ℕ) (hL : 0 < L) (hlarge : L₀ ≤ L) (K : J → ℕ) + (hKL : ∀ j, K j ≤ L) (hDK : ∀ j, L ≤ D * K j) + (m : J → Option I → ℕ) (r : ∀ j i, ZMod (m j i)) + (hm : ∀ j i, 0 < m j i) (hmM : ∀ j i, m j i ≤ M), + (FiniteProbabilityWeights.pi (fun j => + scalarCubeWindowWeights I L (K j) M D hL (hKL j) (hDK j) + (m j) (r j) (hm j) (hmM j) + (scalarCubeWindow_size hD (hsize.trans hlarge) (hDK j)))).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (B : ℝ)) B x) ≤ η := by + obtain ⟨s, hs⟩ := exists_uniform_good_scalar_kernel_bound I J hJ + refine ⟨s, fun M D hM hD η hη => ?_⟩ + let C := (scalarCubeResidueDensityCap I (M * D)) ^ Fintype.card J + have hC : 0 < C := pow_pos (scalarCubeResidueDensityCap_pos I (M * D) (Nat.mul_pos hM hD)) _ + obtain ⟨B, L₁, hB, hL₁, hprob⟩ := hs (η / C) (div_pos hη hC) + refine ⟨B, max L₁ (D * ((Fintype.card I + 1) * M)), hB, Nat.le_max_right _ _, ?_⟩ + intro L hL hlarge K hKL hDK m r hm hmM + have hsize : ∀ j, (Fintype.card I + 1) * M ≤ K j := fun j => + scalarCubeWindow_size hD ((Nat.le_max_right _ _).trans hlarge) (hDK j) + calc + _ ≤ C * (FiniteProbabilityWeights.pi (fun _ : J => integerScalarCubeWeights I L hL)).eventProbability + (fun x => ¬ GoodScalarKernelTuple s (1 / (B : ℝ)) B x) := + scalarCubeWindow_pi_eventProbability_le I J L M D K hL hKL hDK m r hm hmM hsize _ + _ ≤ C * (η / C) := mul_le_mul_of_nonneg_left + (hprob L hL ((Nat.le_max_left _ _).trans hlarge)) hC.le + _ = η := by field_simp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Linear/ZSpanRounding.lean b/lean/OAI/Combinatorics/Progressions/Linear/ZSpanRounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..68f606213851925646cd8609733a2ae693ed4fd3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Linear/ZSpanRounding.lean @@ -0,0 +1,42 @@ +import Mathlib.Algebra.Module.ZLattice.Basic +import Mathlib.Algebra.Order.Round + +namespace OAI + +section + +namespace Erdos3 + +open Module + +theorem exists_zspan_near_of_basis_bound {ι E : Type*} [Fintype ι] + [NormedAddCommGroup E] [NormedSpace ℝ E] + (b : Basis ι ℝ E) (R : ℝ) (hb : ∀ i, ‖b i‖ ≤ R) (x : E) : + ∃ z ∈ Submodule.span ℤ (Set.range b), ‖x - z‖ ≤ (Fintype.card ι : ℝ) * R / 2 := by + classical + let a : ι → ℤ := fun i => round (b.repr x i) + let z : E := ∑ i, (a i : ℝ) • b i + have hz : z ∈ Submodule.span ℤ (Set.range b) := by + apply Submodule.sum_mem + intro i _ + rw [Int.cast_smul_eq_zsmul] + exact Submodule.smul_mem _ _ (Submodule.subset_span ⟨i, rfl⟩) + have he : x - z = ∑ i, (b.repr x i - (a i : ℝ)) • b i := by + simp only [sub_smul, Finset.sum_sub_distrib] + rw [b.sum_repr] + refine ⟨z, hz, ?_⟩ + rw [he] + calc + _ ≤ ∑ i, ‖(b.repr x i - (a i : ℝ)) • b i‖ := norm_sum_le _ _ + _ = ∑ i, |b.repr x i - (a i : ℝ)| * ‖b i‖ := by simp only [norm_smul, Real.norm_eq_abs] + _ ≤ ∑ _i : ι, (1 / 2 : ℝ) * R := by + apply Finset.sum_le_sum + intro i _ + exact mul_le_mul (abs_sub_round (b.repr x i)) (hb i) (norm_nonneg _) (by norm_num) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Main.lean b/lean/OAI/Combinatorics/Progressions/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..6eb0380a56083c87686d154c255ba8e22211ce4b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Main.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.Progressions.Dynamics.ActualPathBufferedLocalMajorPacket +import OAI.Combinatorics.Progressions.Dynamics.CanonicalScalarDimensionBudget +import OAI.Combinatorics.Progressions.Dynamics.CanonicalScalarLogBudget +import OAI.Combinatorics.Progressions.Dynamics.GradedTranslationPotential +import OAI.Combinatorics.Progressions.Dynamics.PreparedFiniteForwardActualPacketBudget +import OAI.Combinatorics.Progressions.Dynamics.PreparedFiniteScheduleLatePowerBudget +import OAI.Combinatorics.Progressions.Dynamics.PreparedFiniteScheduleLocalMasterBudget +import OAI.Combinatorics.Progressions.Dynamics.PreparedFiniteScheduleUniformLocalResourceBudgetWithCutoff +import OAI.Combinatorics.Progressions.Dynamics.PreparedModularGeneralDetectorBudgetedConsumer +import OAI.Combinatorics.Progressions.Dynamics.ProductivePathwiseFrozenLocalMajorFamily +import OAI.Combinatorics.Progressions.Dynamics.UnconditionedBaseRetentionPowerBudget +import OAI.Combinatorics.Progressions.Dynamics.UnconditionedFixedObservableBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateRefinedQuotientAssembly +import OAI.Combinatorics.Progressions.Estimates.AllocatedShortRationalMarginal +import OAI.Combinatorics.Progressions.Estimates.AllocatedSlicedModularSeparateTailContinuousSource +import OAI.Combinatorics.Progressions.Estimates.CenteredFiniteReferenceComparison +import OAI.Combinatorics.Progressions.Estimates.ComplexModelComparisonL1 +import OAI.Combinatorics.Progressions.Estimates.ConstructedNoPivotTopDescent +import OAI.Combinatorics.Progressions.Estimates.ControlledNativeMarkedFreezing +import OAI.Combinatorics.Progressions.Estimates.CorrelatedModerateSiteComparison +import OAI.Combinatorics.Progressions.Estimates.EmptyVariableCommonFactors +import OAI.Combinatorics.Progressions.Estimates.EstimatesProductiveAllocatedFreezing +import OAI.Combinatorics.Progressions.Estimates.FiniteCorrectionHistory +import OAI.Combinatorics.Progressions.Estimates.LowestWeightSourceReadyPreparation +import OAI.Combinatorics.Progressions.Estimates.NativeTrimmedTwistedSliceStepDrop +import OAI.Combinatorics.Progressions.Estimates.NormalizedTwistTrimmedOuterCells +import OAI.Combinatorics.Progressions.Estimates.PreparationReindex +import OAI.Combinatorics.Progressions.Estimates.PreparedDetectedCanonicalNativeSourceGeometry +import OAI.Combinatorics.Progressions.Estimates.PreparedDetectionFixedNativePartners +import OAI.Combinatorics.Progressions.Estimates.PreparedFiniteForwardDescendingAnchoredPaddedSource +import OAI.Combinatorics.Progressions.Estimates.PreparedFiniteForwardDescendingPaddedSource +import OAI.Combinatorics.Progressions.Estimates.PreparedFiniteForwardLocalProductiveSource +import OAI.Combinatorics.Progressions.Estimates.PreparedFiniteNestedInitializedRelativeSource +import OAI.Combinatorics.Progressions.Estimates.PreparedFiniteScheduleActualModelFamily +import OAI.Combinatorics.Progressions.Estimates.ProductRestrictionsCommonRefiltration +import OAI.Combinatorics.Progressions.Estimates.ProductiveLocalMajorFamily +import OAI.Combinatorics.Progressions.Estimates.RelativeSliceTargetCap +import OAI.Combinatorics.Progressions.Estimates.TranslationLogSlowNormalization +import OAI.Combinatorics.Progressions.Estimates.UnconditionedAbsolutePatchFamily +import OAI.Combinatorics.Progressions.Estimates.WeightedTranslationCentralCircleAction +import OAI.Combinatorics.Progressions.Fourier.ForecastInactiveSpectrum +import OAI.Combinatorics.Progressions.Geometry.AllocatedCenteredJointExcessTransport +import OAI.Combinatorics.Progressions.Geometry.AllocatedExternalCandidateSpatialNativeAdaptedTerminal +import OAI.Combinatorics.Progressions.Geometry.AllocatedZeroLayerDetectionTransport +import OAI.Combinatorics.Progressions.Geometry.CertifiedFullChartBudgetedTreeBudget +import OAI.Combinatorics.Progressions.Geometry.DetectedTranslationCoordinateZero +import OAI.Combinatorics.Progressions.Geometry.FixedSpatialNativeRawSupport +import OAI.Combinatorics.Progressions.Geometry.FullTaggedSlowChartCenterDependence +import OAI.Combinatorics.Progressions.Geometry.NativeSampleSliceChartVerticalPartners +import OAI.Combinatorics.Progressions.Geometry.NormalizedTwistUniformSpatialHaar +import OAI.Combinatorics.Progressions.Geometry.SharedWidthPreparedFullChartNativeDetection +import OAI.Combinatorics.Progressions.Lattices.AllocatedCandidateEarlyAffinePhysicalTerminal +import OAI.Combinatorics.Progressions.Lattices.EarlyAllocatedAffineCoveredSourceWithCutoff +import OAI.Combinatorics.Progressions.Lattices.IntegerBoxUniformMeanInstance +import OAI.Combinatorics.Progressions.Lattices.MaskedIntegerProductLaw +import OAI.Combinatorics.Progressions.Lattices.PreparedAffineDensityEighthRemainder +import OAI.Combinatorics.Progressions.Lattices.RefilteredMarkedLatticeMap +import OAI.Combinatorics.Progressions.Lattices.TranslationIntegerReduction +import OAI.Combinatorics.Progressions.Linear.AllocatedModularRankUniformRow +import OAI.Combinatorics.Progressions.Linear.FixedObservableFamilyKernelProjectionIdentity +import OAI.Combinatorics.Progressions.Linear.KernelNormalizationCompositionBudget +import OAI.Combinatorics.Progressions.Linear.KernelProjectionExternalNet +import OAI.Combinatorics.Progressions.Linear.LinearRelativeActualRankBudget +import OAI.Combinatorics.Progressions.Linear.LowestWeightEarlyRankNormalizedPreparation +import OAI.Combinatorics.Progressions.Nilpotent.AllocatedOriginalDegreeQuotientBinNiltest +import OAI.Combinatorics.Progressions.Nilpotent.DiagramExternalNetMaskedNiltests +import OAI.Combinatorics.Progressions.Nilpotent.FormalMarkedNiltestRestoration +import OAI.Combinatorics.Progressions.Nilpotent.PreparedFiniteScheduleAllNilmanifoldModel +import OAI.Combinatorics.Progressions.Nilpotent.UnconditionedArbitraryNiltestBase +import OAI.Combinatorics.Progressions.Polynomial.AllocatedAxisPartitionWithTailDegree +import OAI.Combinatorics.Progressions.Polynomial.AllocatedExternalCandidateDegreeOne +import OAI.Combinatorics.Progressions.Polynomial.AllocatedExternalCandidateDictionaryDegreeOne +import OAI.Combinatorics.Progressions.Polynomial.AllocatedExternalCandidateGeneratedFreezingDegreeOne +import OAI.Combinatorics.Progressions.Polynomial.AllocatedExternalCandidateThresholdDegreeOne +import OAI.Combinatorics.Progressions.Polynomial.PolynomialPatchNoPivotGlobalization +import OAI.Combinatorics.Progressions.Polynomial.PreparedFiniteForwardAllDegreePaddedSource +import OAI.Combinatorics.Progressions.Polynomial.PreparedFiniteScheduleLocalScalarConstructionWithDegree +import OAI.Combinatorics.Progressions.Polynomial.TranslationMajorCorrelationStepDropPolynomial +import OAI.Combinatorics.Progressions.Probability.CandidateDetectionMassBudget +import OAI.Combinatorics.Progressions.Probability.ComparableUnconditionedScalarFamilyDensity +import OAI.Combinatorics.Progressions.Probability.RecoveredChartMassEarlyPower +import OAI.Combinatorics.Progressions.Probability.WeightedPotentialMass +import OAI.Combinatorics.Progressions.Results.FullLibrary +import OAI.Combinatorics.Progressions.Sampling.AllocatedAllGridScale +import OAI.Combinatorics.Progressions.Sampling.AllocatedExternalCandidateDenseForecastData +import OAI.Combinatorics.Progressions.Sampling.AllocatedPhysicalDensityNativeForecastSource +import OAI.Combinatorics.Progressions.Sampling.AllocatedRecoveredNativeJointGridComparison +import OAI.Combinatorics.Progressions.Sampling.AllocatedSlicedModularForecastContinuousSource +import OAI.Combinatorics.Progressions.Sampling.ExternalCandidateStepZeroScores +import OAI.Combinatorics.Progressions.Sampling.FixedSpatialSliceNativeJointGridDetComparison +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveShortAxis +import OAI.Combinatorics.Progressions.Sampling.ForecastInactiveSlicedNativeSource +import OAI.Combinatorics.Progressions.Sampling.ForecastPhysicalTargetSpatialSplit +import OAI.Combinatorics.Progressions.Sampling.PreparedActualSlicedForecastModelExtension +import OAI.Combinatorics.Progressions.Sampling.PreparedShortForecastCertificateSpecialization +import OAI.Combinatorics.Progressions.Sampling.RelativePatchScoreObstruction +import OAI.Combinatorics.Progressions.Sampling.SamplingLowTaggedSamplingRank +import OAI.Combinatorics.Progressions.Sampling.SharedWidthPreparedProductiveShortGoodForecastSource diff --git a/lean/OAI/Combinatorics/Progressions/Model.lean b/lean/OAI/Combinatorics/Progressions/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..156947ed5e96871e0d5eb7eba8293971cffc0d16 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Model.lean @@ -0,0 +1,45 @@ +import Mathlib + +namespace OAI + +namespace Erdos3 + +def HasAP (A : Set ℕ) (k : ℕ) : Prop := + ∃ a d : ℕ, 0 < d ∧ ∀ i < k, a + i * d ∈ A + +def APFree (A : Set ℕ) (k : ℕ) : Prop := ¬ HasAP A k + +noncomputable def extremalNumber (k N : ℕ) : ℕ := by + classical + exact (((Finset.Icc 1 N).powerset).filter fun S : Finset ℕ ↦ APFree (S : Set ℕ) k).sup + Finset.card + +end Erdos3 + +open scoped BigOperators + +namespace Erdos3 + +noncomputable def reciprocalTerm (A : Set ℕ) (n : ℕ) : ℝ := by + classical + exact if n ∈ A then (n : ℝ)⁻¹ else 0 + +end Erdos3 + +namespace Erdos3 + +def QuantitativeDensityBound (k : ℕ) : Prop := + ∃ C c η : ℝ, 0 < C ∧ 0 < c ∧ 0 < η ∧ + ∀ N : ℕ, 3 ≤ N → + (extremalNumber k N : ℝ) ≤ + C * N * Real.exp (-c * (Real.log (Real.log N)) ^ (1 + η)) + +def QuantitativeDensityTheorem : Prop := + ∀ k : ℕ, 3 ≤ k → QuantitativeDensityBound k + +def ReciprocalProgressionTheorem : Prop := + ∀ A : Set ℕ, ¬ Summable (reciprocalTerm A) → ∀ k : ℕ, HasAP A k + +end Erdos3 + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AdaptedBasisNilmanifold.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AdaptedBasisNilmanifold.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d05721fd2081887956d83c183ce839228720a8b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AdaptedBasisNilmanifold.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalPowerHeight + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis (Fin d) ℚ L) (w : Fin d → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) + +noncomputable def adaptedLayerBasis (j : ℕ) : + Basis (Fin (finrank ℚ (F.layer j))) ℚ (F.layer j) := by + classical + let c := supportedSubmoduleBasis b (F.layer j) {i | j ≤ w i} (hlayers j) + exact c.reindex (Fintype.equivFinOfCardEq (finrank_eq_card_basis c).symm) + +theorem adaptedLayerBasis_height (j : ℕ) (i : Fin (finrank ℚ (F.layer j))) (k : Fin d) : + RationalHeightLE (b.repr (F.adaptedLayerBasis b w hlayers j i) k) 1 := by + classical + unfold adaptedLayerBasis + rw [Basis.reindex_apply, supportedSubmoduleBasis_coe] + exact basis_repr_height_one b _ k + +noncomputable def ofAdaptedBasis (Γ : Subgroup F.Group) (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates b Γ) + (hout : bchSubgroupCoordinates b Γ ⊆ denominatorGrid N) : + RationalFilteredNilmanifold L s d where + filtration := F + basis := b + layerBasis i := F.adaptedLayerBasis b w hlayers (i.val + 1) + lattice := Γ + grid := N + grid_pos := hN + inner_grid := hin + outer_grid := hout + +theorem ofAdaptedBasis_geometry (Γ : Subgroup F.Group) (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates b Γ) + (hout : bchSubgroupCoordinates b Γ ⊆ denominatorGrid N) + {p : ℝ} (hp : 0 ≤ p) (hd : (d : ℝ) ≤ p) (hNp : (N : ℝ) ≤ Real.exp p) + (hc : ∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ p) : + (F.ofAdaptedBasis b w hlayers Γ N hN hin hout).GeometryComplexityLE p := by + refine ⟨hd, hNp, hc, ?_⟩ + intro i j k + exact rationalLogHeight_le_of_height (F.adaptedLayerBasis_height b w hlayers _ j k) + (by simpa only [Nat.cast_one] using Real.one_le_exp hp) + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedCandidateHistoryLocalNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedCandidateHistoryLocalNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a4468400c52ee1984e11cf4420906ccbe5add18 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedCandidateHistoryLocalNiltests.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.Progressions.Estimates.AllocatedExternalCandidateKeptSymbolFactors +import OAI.Combinatorics.Progressions.Nilpotent.AllocatedKeptCommonCurrentGradeLocalNiltest +import OAI.Combinatorics.Progressions.Sampling.AllocatedExternalCandidateSamplerFacts + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped Classical TensorProduct BigOperators + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom realSymbolGradeEvaluation + CertifiedFullChartFiniteHistory.outer + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] + {I Deck J : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {Rad σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag Rad σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hRad : ∀ j, 0 < Rad j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U btag S hb o hRad hσ N poly hm τ ξ stride cells center} + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} + {Fmark : NilpotentLieFiltration M s} {φ : L →ₗ⁅ℚ⁆ M} + {marked : Fmark.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + +namespace AllocatedExternalCandidateProblem + +variable {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := Deck) A D Fmark φ marked observable weight + cost massThreshold scoreThreshold) + (keep : LayerSamplerVariables G I n B → Prop) + (hkeep : ∀ z : P.productive, (P.chart z).keep = keep) + {ι κ χ η : Type} [Fintype ι] [Fintype κ] [Fintype χ] [Fintype η] + (bD : Basis ι ℚ L) (ω : ι → ℕ) + (hD : ∀ j, D.filtration.layer j = span ℚ (bD '' {i | j ≤ ω i})) + (bF : Basis κ ℚ M) (ν : κ → ℕ) + (hF : ∀ j, Fmark.layer j = span ℚ (bF '' {i | j ≤ ν i})) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.layer j) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + +local notation "Vars" => {i : LayerSamplerVariables G I n B // keep i} +local notation "fast" => W.map (D.filtration.associatedGradedMap Fmark φ hφ) +local notation "gmark" => Fmark.realification.polynomialOrbitCoordinates (fullTaggedVariableWeight J) marked +local notation "Z" => Fmark.realPolynomialSymbolHom bF ν hF (fullTaggedVariableWeight J) gmark +local notation "Q" => P.withKeep keep hkeep + +theorem exists_history_current_grade_local_niltests + [Fintype (SymbolBasisIndex (fun _ : Vars => 1) ω)] + [Fintype (SymbolBasisIndex (fun _ : Vars => 1) ν)] + (eQ : Basis η ℚ (Fmark.AssociatedGraded ⧸ (fast).toSubmodule)) + (lift : (Fmark.AssociatedGraded ⧸ (fast).toSubmodule) →ₗ[ℚ] Fmark.AssociatedGraded) + (r a : ℕ) (hr : r ≤ s) + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + (Bhistory Bstage budget : ℝ) + (history : CertifiedFullChartFiniteHistory Fmark bF ν hF J (fast).toSubmodule + (eQ.baseChange ℝ) lift Z Set.univ U poly N Bhistory r) + (hcontrol : FullChartControlledFactors Fmark bF ν hF J poly N history.outer.1 history.outer.2 budget) + (hcertificate : RationalTaggedConstraintCertificate J Set.univ history.K Bstage + (r * (Fintype.card η * m))) + (HMap l : ℕ) (pMap : ℝ) (hHMap : 1 ≤ HMap) (hl : 0 < l) (hpMap : 0 ≤ pMap) + (hentries : ∀ i j, RationalHeightLE (bF.repr (φ (bD j)) i) HMap) + (hsource : (Fintype.card (SymbolBasisIndex (fun _ : Vars => 1) ω) : ℝ) ≤ pMap) + (htarget : (Fintype.card (SymbolBasisIndex (fun _ : Vars => 1) ν) : ℝ) ≤ pMap) + (hHMapExp : (HMap : ℝ) ≤ Real.exp pMap) (hlExp : (l : ℝ) ≤ Real.exp pMap) + (H : ℕ) (p qNative : ℝ) (hH : 1 ≤ H) (hp : 0 ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) (hVars : (Fintype.card Vars : ℝ) ≤ p) + (hχ : (Fintype.card χ : ℝ) ≤ p) (hHExp : (H : ℝ) ≤ Real.exp p) + (hbracket : ∀ i j z, RationalHeightLE (bF.repr ⁅bF i, bF j⁆ z) H) + (hcommon : Real.exp budget * Real.exp ((pMap + 2) ^ 4) ≤ Real.exp p) + (hmapSlow : Real.exp ((pMap + 2) ^ 3 + qNative) ≤ Real.exp ((p + 2) ^ a)) + (hallowance : + (((s : ℝ) + 1) * ((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ s * Real.exp budget * + (((m + 1 : ℕ) : ℝ) * ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ m) ^ s) + ≤ Real.exp ((p + 2) ^ a)) + (hNreset : ∀ i : Vars, Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ (A.sides i.val : ℝ)) + (vg : χ → Fmark.PolynomialSymbol (fun _ : Vars => 1)) + (hspan : span ℚ (Set.range vg) = (Fmark.symbolPointwiseSubalgebra bF ν hF (fun _ : Vars => 1) fast).toSubmodule) + (hvg : ∀ i z, RationalHeightLE ((Fmark.polynomialSymbolBasis bF ν hF (fun _ : Vars => 1)).repr (vg i) z) H) + (hτ : τ ≤ 1) (hξ : ξ ≤ 1) (hσone : ∀ j, σ j ≤ 1) + (Cgeo : Fin m → ℝ) (hCgeo : ∀ j, 0 ≤ Cgeo j) + (hchart : ∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (U j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) + (hsmall : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1 / 8) + (hpoly : ∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) + (pK Mbound LongSide : ℝ) (hpK : 0 ≤ pK) (hBstage : Bstage ≤ pK) + (hJ : ∀ j, (Fintype.card (J j) : ℝ) ≤ pK) (hM : 0 ≤ Mbound) + (hcap : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ Mbound) + (hLong : 1 ≤ LongSide) (hlong : ∀ i, keep i → LongSide ≤ layerSamplerBox B U btag S i) + (hthreshold : Real.exp ((pK + 2) ^ 9) ^ 2 * Mbound < LongSide) + (hlength : ∀ z : P.productive, ∀ i, s < ((Q).chart z).slice.length i) + (hfactor : ∀ z : P.productive, D.filtration.HasCommonRefilteredOrbitFactors bD ω hD + (fun i : Vars => (A.sides i.val : ℝ)) qNative l W + (D.filtration.realification.polynomialOrbitCoordinates _ ((Q).candidate z).orbit)) + (Hθ : ℕ) (pLocal : ℝ) + (hθ : ∀ j i, RationalHeightLE (((eQ.coord j).comp (fast).toSubmodule.mkQ) + (Fmark.associatedGradedBasis bF ν hF i)) Hθ) + (hpLocal : 1 ≤ pLocal) (hLocalDim : (Fintype.card Vars : ℝ) ≤ pLocal) + (hLocalSize : (Fintype.card κ : ℝ) * Hθ * Real.exp + ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ allocatedFrozenCurrentGradeResetConstant s a) ≤ Real.exp pLocal) + (hLocalDen : ((Hθ ^ Fintype.card κ : ℕ) : ℝ) * Real.exp + ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ allocatedFrozenCurrentGradeResetConstant s a) ≤ Real.exp pLocal) + (hNLocal : ∀ i : Vars, Real.exp ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) ≤ (A.sides i.val : ℝ)) : + ∃ reset : ℕ, 0 < reset ∧ + (reset : ℝ) ≤ Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ∧ + ∀ (j : η) (z : P.productive) (score : (Vars → ℤ) → ℝ), + ∃ q : ℕ, 0 < q ∧ q ≤ Hθ ^ Fintype.card κ * reset ∧ + ∃ slice : ResidueBoxSlice (fun i : Vars => A.sides i.val) q, + IsDenseCommonStrideBox (fun i : Vars => A.sides i.val) + ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) slice.integerPoints ∧ + (𝔼 x : (∀ i : Vars, Fin (A.sides i.val)), score (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ slice.integerPoints, score x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold r).Niltest (fun _ : Vars => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget r) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ slice.integerPoints, + majorPhasePlateauSignal J (r + 1) poly + (fun i => (P.centerLift (lowTaggedIndex J (r + 1) i).1).val (lowTaggedIndex J (r + 1) i).2) + (coordinate ((eQ.baseChange ℝ).coord j).toAddMonoidHom + (lowTaggedVectorRestrict J (r + 1) (Fmark.realSymbolGradeQuotientPolynomial bF ν hF + (fullTaggedVariableWeight J) (fast).toSubmodule (r + 1) + (history.outer.1⁻¹ * Z * history.outer.2⁻¹).coord))) + (jointIntegerPhysicalSite (finiteSplitPoint keep x ((Q).chart z).fixed) + (z.val.1.val, z.val.2.val)) * + star (T.eval (commonStrideIndex (fun i => (slice.start i : ℤ)) q x))‖ := by + obtain ⟨lLocal, hlLocal, hlLocalBound, _, hmarkedFactors⟩ := + P.exists_withKeep_marked_frozen_symbol_factors keep hkeep bD ω hD bF ν hF hφ + hHMap hl hentries hpMap hsource htarget hHMapExp hlExp + have hcommon' : Real.exp budget * (lLocal : ℝ) ≤ Real.exp p := + (mul_le_mul_of_nonneg_left hlLocalBound (Real.exp_nonneg _)).trans hcommon + obtain ⟨qCurrent, _, _, reset, hreset, hresetBound, _, hlocal⟩ := + exists_allocated_controlled_frozen_current_grade_local_niltest (Deck := Deck) B U btag hb o S hRad hσ poly hm + s a keep Fmark bF ν hF H lLocal p hH hlLocal hp hκ hVars hχ hHExp hbracket + history.outer.1 history.outer.2 N A.size_pos hcontrol hcommon' hallowance hNreset + refine ⟨reset, hreset, hresetBound, ?_⟩ + intro j z score + obtain ⟨El, Pl, Rl, hprod, hPl, hEl, hRl⟩ := + hmarkedFactors z qNative W (hlength z) (hfactor z) + have hsidePos : ∀ i : Vars, (0 : ℝ) < A.sides i.val := + fun i => (Real.exp_pos _).trans_le (hNreset i) + have hEl' := Fmark.symbolSlowBound_mono bF ν hF (fun _ : Vars => 1) + (fun i => (A.sides i.val : ℝ)) hsidePos hmapSlow El hEl + have hden : ((Hθ ^ Fintype.card κ * reset : ℕ) : ℝ) ≤ Real.exp pLocal := by + rw [Nat.cast_mul] + exact (mul_le_mul_of_nonneg_left hresetBound (Nat.cast_nonneg _)).trans hLocalDen + have hrecover := P.withKeep_chart_recovered z + have hspatial := P.currentGrade_spatial_support z + have hfixed := ((Q).chart z).fixed_in_box + exact hlocal hr fast vg hspan hvg eQ j P.centerLift z.val.1.val z.val.2.val + (P.chart z).sample (P.chart z).read hrecover A.trim_pos hτ hξ hspatial + ((Q).chart z).fixed hfixed hσone Cgeo hCgeo hchart hsmall hpoly + history.K Bstage pK Mbound LongSide (r * (Fintype.card η * m)) hcertificate + (fun point hpoint => history.retained point (Set.mem_univ _) hpoint) + hpK hBstage hJ hM hcap hLong hlong hthreshold gmark + (fun point hpoint d hd => history.invariant_outer point hpoint d (by omega)) + El Pl Rl hprod hPl hEl' hRl Hθ pLocal (hθ j) hpLocal hLocalDim hLocalSize hden score hNLocal + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedExternalCandidateQuotientNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedExternalCandidateQuotientNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..042c11278a6b0788e754d95c641990998c25178f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedExternalCandidateQuotientNiltests.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.Progressions.Estimates.InheritedTaggedQuotientPrecenterMasks + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + (A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center) + +namespace AllocatedExternalCandidateProblem + +variable {L M ι κ : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s d f nD nF nQ nQF : ℕ} + {D : RationalFilteredNilmanifold L (s + 1) d} + (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + {marked : Fmark.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)} + {observable : (X → ℤ) → D.Space → ℂ} {weight : (X → ℤ) → ℂ} + {cost massThreshold scoreThreshold : ℝ} + (P : AllocatedExternalCandidateProblem (E := E) A D Fmark.filtration φ marked + observable weight cost massThreshold scoreThreshold) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (Dref : RationalFilteredNilmanifold + (D.filtration.gradedRefiltrationSubalgebra W) (s + 1) nD) + (hDref : Dref.filtration = D.filtration.gradedRefiltration W) + (Fref : RationalFilteredNilmanifold + (Fmark.filtration.gradedRefiltrationSubalgebra + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))) (s + 1) nF) + (hFref : Fref.filtration = Fmark.filtration.gradedRefiltration + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))) + (Q : RationalFilteredNilmanifold + ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ Dref.filtration.layerIdeal (s + 1)) s nQ) + (hQ : Q.filtration = Dref.filtration.quotientTop) + (QF : RationalFilteredNilmanifold + ((Fmark.filtration.gradedRefiltrationSubalgebra + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))) ⧸ + Fref.filtration.layerIdeal (s + 1)) s nQF) + (hQF : QF.filtration = Fref.filtration.quotientTop) + [PseudoMetricSpace Fref.Space] + [TopologicalSpace (ℝ ⊗[ℚ] ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ Dref.filtration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ Dref.filtration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ Dref.filtration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ Dref.filtration.layerIdeal (s + 1)))] + +variable (left right : D.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)) + (markedMiddle : Fref.filtration.realification.PolynomialOrbit (fullTaggedVariableWeight (X := X) J)) + (K : ℝ≥0) + +theorem exists_refilteredQuotient_niltests + {σtest : Type*} (w : σtest → ℕ) {pGeo : ℝ} + (hGeo : Q.GeometryComplexityLE pGeo) (hK : (K : ℝ) ≤ Real.exp pGeo) + (hpositive : ∀ x y, (observable x y).im = 0 ∧ + 0 ≤ (observable x y).re ∧ (observable x y).re ≤ 1) : + letI := Q.metricSpace + ∃ tests : (X → ℤ) → Q.Niltest w, ∀ x, + (tests x).orbit = 1 ∧ + (tests x).observable = + P.refilteredQuotientObservable A Fmark φ hφ W Dref Fref Q left right markedMiddle K x ∧ + (tests x).normBound = 1 ∧ (tests x).lipBound = K ∧ + (tests x).UnitIntervalValued ∧ (tests x).ComplexityLE (pGeo + 3) ∧ + ∀ (orbit : Q.filtration.realification.PolynomialOrbit w) u, + ((tests x).withOrbit orbit).eval u = + P.refilteredQuotientObservable A Fmark φ hφ W Dref Fref Q left right markedMiddle K x + (QuotientGroup.mk (Q.filtration.realification.polynomialOrbitEval w u orbit)) := by + let := Q.metricSpace + let f := P.refilteredQuotientObservable A Fmark φ hφ W Dref Fref Q left right markedMiddle K + have hLip (x : X → ℤ) : LipschitzWith K (f x) := by + apply positiveImageSlice_lipschitz + intro source + exact (hpositive x _).2.1 + have hcap (x : X → ℤ) (y : Q.Space) : ‖f x y‖ ≤ 1 := + positiveImageExtension_norm_le_one _ _ _ _ + have hunit (x : X → ℤ) (y : Q.Space) : + (f x y).im = 0 ∧ 0 ≤ (f x y).re ∧ (f x y).re ≤ 1 := + positiveImageExtension_unit_interval _ _ _ _ + let tests (x : X → ℤ) : Q.Niltest w := + Q.externalNetNiltest (f x) K (hcap x) (hLip x) 1 + refine ⟨tests, fun x => ⟨rfl, rfl, rfl, rfl, hunit x, ?_, fun _ _ => rfl⟩⟩ + exact Q.externalNetNiltest_complexity (f x) K (hcap x) (hLip x) 1 + ((Nat.cast_nonneg _).trans hGeo.1) hGeo hK + +end AllocatedExternalCandidateProblem +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedKeptCommonCurrentGradeLocalNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedKeptCommonCurrentGradeLocalNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..68f1b29f6a05cb1b21dee9111948bd53f8e4c1f8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedKeptCommonCurrentGradeLocalNiltest.lean @@ -0,0 +1,1213 @@ +import OAI.Combinatorics.Progressions.Dynamics.ActualPathCurrentGradeReset +import OAI.Combinatorics.Progressions.Estimates.AllocatedCommonFrozenSymbolFactors +import OAI.Combinatorics.Progressions.Estimates.AllocatedControlledFrozenPullbacks +import OAI.Combinatorics.Progressions.Estimates.AllocatedProductiveFrozenMajorDetection +import OAI.Combinatorics.Progressions.Geometry.CertifiedFullChartRecoveredTerminal + +namespace OAI + +section + +namespace Erdos3 + +open Module _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped BigOperators TensorProduct + +theorem realPolynomialCoefficientGrid_homogeneousComponent {σ : Type*} + {q : ℕ} {P : MvPolynomial σ ℝ} (hP : realPolynomialCoefficientGrid q P) + (k : ℕ) : realPolynomialCoefficientGrid q (homogeneousComponent k P) := by + classical + obtain ⟨z, hz⟩ := hP + refine ⟨fun α => if α.degree = k then z α else 0, funext fun α => ?_⟩ + change ((if α.degree = k then z α else 0 : ℤ) : ℝ) = + (q : ℝ) * (homogeneousComponent k P).coeff α + rw [coeff_homogeneousComponent] + split_ifs with h + · exact congrFun hz α + · simp + +theorem homogeneousComponent_scaled_coeff_bound {σ : Type*} + (P : MvPolynomial σ ℝ) (k : ℕ) (N : σ → ℝ) + (hN : ∀ i, 0 < N i) (M : ℝ) (hM : 0 ≤ M) + (hP : ∀ α, |P.coeff α| ≤ M / monomialScale N α) : + ∀ α, |(homogeneousComponent k P).coeff α| ≤ M / monomialScale N α := by + intro α + rw [coeff_homogeneousComponent] + split_ifs with h + · exact hP α + · simpa only [abs_zero] using div_nonneg hM (monomialScale_pos N hN α).le + +namespace NilpotentLieFiltration + +variable {U ι L : Type*} [Fintype U] [DecidableEq U] [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] {s n : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + +theorem exists_currentGrade_localMajor_niltest + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ F.AssociatedGraded) + (θ : F.AssociatedGraded →ₗ[ℚ] ℚ) (hθW : ∀ x ∈ W, θ x = 0) + (E P R E₀ R₀ : F.RealPolynomialSymbolGroup (fun _ : U => 1)) + (hP : P.coord ∈ realificationLieSubalgebra + (F.symbolPointwiseSubalgebra b ω hF (fun _ : U => 1) W)) + (hE : F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) E₀ = + F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) E) + (hR : F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) R = + F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) R₀) + (N : U → ℕ) (H m : ℕ) (hm : 0 < m) (M p : ℝ) (hM : 0 ≤ M) + (hθH : ∀ i, RationalHeightLE (θ (F.associatedGradedBasis b ω hF i)) H) + (hslow : F.SymbolSlowBound b ω hF (fun _ : U => 1) + (fun i => (N i : ℝ)) M (E₀⁻¹ * E)) + (hgrid : F.SymbolRationalGrid b ω hF (fun _ : U => 1) m (R * R₀⁻¹)) + (hp : 1 ≤ p) (hdim : (Fintype.card U : ℝ) ≤ p) + (hMexp : (Fintype.card ι : ℝ) * H * M ≤ Real.exp p) + (hqexp : ((H ^ Fintype.card ι * m : ℕ) : ℝ) ≤ Real.exp p) + (f : (U → ℤ) → ℝ) + (hN : ∀ i, Real.exp ((p + (n + 401 : ℕ)) ^ (n + 401)) ≤ (N i : ℝ)) : + ∃ q : ℕ, 0 < q ∧ q ≤ H ^ Fintype.card ι * m ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((p + (n + 401 : ℕ)) ^ (n + 401)) A.integerPoints ∧ + (𝔼 x : (∀ i, Fin (N i)), f (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ A.integerPoints, f x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ A.integerPoints, + (Real.fourierChar (eval (fun i => (x i : ℝ)) + (homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ + (E₀⁻¹ * (E * P * R) * R₀⁻¹)))) : ℂ) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))‖ := by + have hNpos : ∀ i, 0 < (N i : ℝ) := fun i => (Real.exp_pos _).trans_le (hN i) + obtain ⟨q, hq, hqbound, hqgrid⟩ := + F.scalarSymbolPolynomial_exists_coefficient_grid b ω hF (fun _ : U => 1) + θ hθH m hm (R * R₀⁻¹) hgrid + let φ := F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ + (E₀⁻¹ * (E * P * R) * R₀⁻¹) + let slow := homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ (E₀⁻¹ * E)) + let rat := homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ (R * R₀⁻¹)) + have htop : homogeneousComponent (n + 1) (homogeneousComponent (n + 1) φ) = + slow + rat := by + rw [homogeneousComponent_eq_self (homogeneousComponent_isHomogeneous _ _)] + exact F.scalarSymbolPolynomial_homogeneous_normalized_splitting b ω hF θ W hθW + (n + 1) E P R E₀ R₀ hP hE hR + have hcap : 0 ≤ (Fintype.card ι : ℝ) * H * M := by positivity + have hcoeff : ∀ α, |slow.coeff α| ≤ + ((Fintype.card ι : ℝ) * H * M) / monomialScale (fun i => (N i : ℝ)) α := + homogeneousComponent_scaled_coeff_bound _ (n + 1) _ hNpos _ hcap + (F.scalarSymbolPolynomial_slow_coefficients_of_height b ω hF (fun _ : U => 1) + θ _ hNpos hM hθH (E₀⁻¹ * E) hslow) + obtain ⟨A, hA, hscore, T, hTnorm, hTbudget, hcorr⟩ := + exists_localMajor_dense_slice_niltest_early N q hq + (homogeneousComponent (n + 1) φ) slow rat + (homogeneousComponent_isHomogeneous _ _).totalDegree_le + (homogeneousComponent_isHomogeneous _ _).totalDegree_le htop + (realPolynomialCoefficientGrid_homogeneousComponent hqgrid (n + 1)) + ((Fintype.card ι : ℝ) * H * M) p hcap hp hdim hMexp + ((Nat.cast_le.mpr hqbound).trans hqexp) hcoeff f hN + exact ⟨q, hq, hqbound, A, hA, hscore, T, hTnorm, hTbudget, hcorr⟩ + +theorem exists_currentGrade_localMajor_niltest_with_lower_phase + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (W : LieSubalgebra ℚ F.AssociatedGraded) + (θ : F.AssociatedGraded →ₗ[ℚ] ℚ) (hθW : ∀ x ∈ W, θ x = 0) + (E P R E₀ R₀ : F.RealPolynomialSymbolGroup (fun _ : U => 1)) + (hP : P.coord ∈ realificationLieSubalgebra + (F.symbolPointwiseSubalgebra b ω hF (fun _ : U => 1) W)) + (hE : F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) E₀ = + F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) E) + (hR : F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) R = + F.realSymbolGradeQuotientHom (fun _ : U => 1) (n + 1) R₀) + (N : U → ℕ) (H m : ℕ) (hm : 0 < m) (M p : ℝ) (hM : 0 ≤ M) + (hθH : ∀ i, RationalHeightLE (θ (F.associatedGradedBasis b ω hF i)) H) + (hslow : F.SymbolSlowBound b ω hF (fun _ : U => 1) + (fun i => (N i : ℝ)) M (E₀⁻¹ * E)) + (hgrid : F.SymbolRationalGrid b ω hF (fun _ : U => 1) m (R * R₀⁻¹)) + (hp : 1 ≤ p) (hdim : (Fintype.card U : ℝ) ≤ p) + (hMexp : (Fintype.card ι : ℝ) * H * M ≤ Real.exp p) + (hqexp : ((H ^ Fintype.card ι * m : ℕ) : ℝ) ≤ Real.exp p) + (f : (U → ℤ) → ℝ) (lower : MvPolynomial U ℝ) + (hlower : lower.totalDegree ≤ n) + (hN : ∀ i, Real.exp ((p + (n + 401 : ℕ)) ^ (n + 401)) ≤ (N i : ℝ)) : + ∃ q : ℕ, 0 < q ∧ q ≤ H ^ Fintype.card ι * m ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((p + (n + 401 : ℕ)) ^ (n + 401)) A.integerPoints ∧ + (𝔼 x : (∀ i, Fin (N i)), f (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ A.integerPoints, f x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ A.integerPoints, + (Real.fourierChar (eval (fun i => (x i : ℝ)) + (homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ + (E₀⁻¹ * (E * P * R) * R₀⁻¹)) + lower)) : ℂ) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))‖ := by + have hNpos : ∀ i, 0 < (N i : ℝ) := fun i => (Real.exp_pos _).trans_le (hN i) + obtain ⟨q, hq, hqbound, hqgrid⟩ := + F.scalarSymbolPolynomial_exists_coefficient_grid b ω hF (fun _ : U => 1) + θ hθH m hm (R * R₀⁻¹) hgrid + let φ := F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ + (E₀⁻¹ * (E * P * R) * R₀⁻¹) + let slow := homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ (E₀⁻¹ * E)) + let rat := homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : U => 1) θ (R * R₀⁻¹)) + have htop : homogeneousComponent (n + 1) (homogeneousComponent (n + 1) φ + lower) = + slow + rat := by + rw [map_add, homogeneousComponent_eq_self (homogeneousComponent_isHomogeneous _ _), + homogeneousComponent_eq_zero _ lower (by omega), add_zero] + exact F.scalarSymbolPolynomial_homogeneous_normalized_splitting b ω hF θ W hθW + (n + 1) E P R E₀ R₀ hP hE hR + have hcap : 0 ≤ (Fintype.card ι : ℝ) * H * M := by positivity + have hcoeff : ∀ α, |slow.coeff α| ≤ + ((Fintype.card ι : ℝ) * H * M) / monomialScale (fun i => (N i : ℝ)) α := + homogeneousComponent_scaled_coeff_bound _ (n + 1) _ hNpos _ hcap + (F.scalarSymbolPolynomial_slow_coefficients_of_height b ω hF (fun _ : U => 1) + θ _ hNpos hM hθH (E₀⁻¹ * E) hslow) + obtain ⟨A, hA, hscore, T, hTnorm, hTbudget, hcorr⟩ := + exists_localMajor_dense_slice_niltest_early N q hq + (homogeneousComponent (n + 1) φ + lower) slow rat + ((totalDegree_add _ _).trans (max_le + (homogeneousComponent_isHomogeneous _ _).totalDegree_le (hlower.trans (Nat.le_succ n)))) + (homogeneousComponent_isHomogeneous _ _).totalDegree_le htop + (realPolynomialCoefficientGrid_homogeneousComponent hqgrid (n + 1)) + ((Fintype.card ι : ℝ) * H * M) p hcap hp hdim hMexp + ((Nat.cast_le.mpr hqbound).trans hqexp) hcoeff f hN + exact ⟨q, hq, hqbound, A, hA, hscore, T, hTnorm, hTbudget, hcorr⟩ + +end NilpotentLieFiltration + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped TensorProduct BigOperators + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom + +theorem exists_actual_path_current_grade_local_niltest (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {τ ι κ L : Type*} [Fintype τ] [DecidableEq τ] [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (H l : ℕ) (p : ℝ), 1 ≤ H → 0 < l → 0 ≤ p → + (Fintype.card ι : ℝ) ≤ p → (Fintype.card τ : ℝ) ≤ p → (Fintype.card κ : ℝ) ≤ p → + (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + (∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) → + ∀ N : τ → ℕ, (∀ i, Real.exp ((p + C) ^ C) ≤ (N i : ℝ)) → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + ∀ {n : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)], n ≤ s → + ∀ (U : LieSubalgebra ℚ F.AssociatedGraded) + (vg : κ → F.PolynomialSymbol (fun _ : τ => 1)), + Submodule.span ℚ (Set.range vg) = + (F.symbolPointwiseSubalgebra b ω hF (fun _ : τ => 1) U).toSubmodule → + (∀ i z, RationalHeightLE + ((F.polynomialSymbolBasis b ω hF (fun _ : τ => 1)).repr (vg i) z) H) → + ∀ {σ : Type*} (w : σ → ℕ) (β : σ → MvPolynomial τ ℝ), + ∀ hβ : ∀ i, β i ∈ weightedSupportLE (fun _ : τ => 1) (w i), + ∀ K : Set (σ → ℝ), + (∀ u : τ → ℝ, + (fun i => MvPolynomial.eval u + (weightedHomogeneousComponent (fun _ : τ => 1) (w i) (β i))) ∈ K) → + ∀ (g : (F.realification.adaptedPolynomialFiltration w).Group) + (E R : F.RealPolynomialSymbolGroup w), + (∀ t ∈ K, ∀ j < n + 1, F.realSymbolGradeEvaluation b ω hF w j t + (E⁻¹ * F.realPolynomialSymbolHom b ω hF w g * R⁻¹).coord ∈ realificationLieSubalgebra U) → + let pull := F.realSymbolHomogeneousPullbackHom b ω hF w (fun _ : τ => 1) + (fun i => weightedHomogeneousComponent (fun _ : τ => 1) (w i) (β i)) + (fun _i => weightedHomogeneousComponent_isWeightedHomogeneous _ _) + ∀ (El Pl Rl : F.RealPolynomialSymbolGroup (fun _ : τ => 1)), + El * Pl * Rl = F.realPolynomialSymbolHom b ω hF (fun _ : τ => 1) + (F.weightedAdaptedRealChartHom w (fun _ : τ => 1) β hβ g) → + Pl.coord ∈ realificationLieSubalgebra + (F.symbolPointwiseSubalgebra b ω hF (fun _ : τ => 1) U) → + F.SymbolSlowBound b ω hF (fun _ : τ => 1) (fun i => (N i : ℝ)) + (Real.exp ((p + 2) ^ a)) El → + F.SymbolSlowBound b ω hF (fun _ : τ => 1) (fun i => (N i : ℝ)) + (Real.exp ((p + 2) ^ a)) (pull E) → + F.SymbolRationalGrid b ω hF (fun _ : τ => 1) l Rl → + F.SymbolRationalGrid b ω hF (fun _ : τ => 1) l (pull R) → + ∀ (θ : F.AssociatedGraded →ₗ[ℚ] ℚ), (∀ x ∈ U, θ x = 0) → + ∀ (Hθ : ℕ) (pLocal : ℝ), + (∀ i, RationalHeightLE (θ (F.associatedGradedBasis b ω hF i)) Hθ) → + 1 ≤ pLocal → (Fintype.card τ : ℝ) ≤ pLocal → + (Fintype.card ι : ℝ) * Hθ * Real.exp ((p + C) ^ C) ≤ Real.exp pLocal → + ((Hθ ^ Fintype.card ι * m : ℕ) : ℝ) ≤ Real.exp pLocal → + ∀ (score : (τ → ℤ) → ℝ) (lower : MvPolynomial τ ℝ), lower.totalDegree ≤ n → + (∀ i, Real.exp ((pLocal + (n + 401 : ℕ)) ^ (n + 401)) ≤ (N i : ℝ)) → + ∃ q : ℕ, 0 < q ∧ q ≤ Hθ ^ Fintype.card ι * m ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((pLocal + (n + 401 : ℕ)) ^ (n + 401)) A.integerPoints ∧ + (𝔼 x : (∀ i, Fin (N i)), score (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ A.integerPoints, score x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : τ => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ A.integerPoints, + (Real.fourierChar (eval (fun i => (x i : ℝ)) + (homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : τ => 1) θ + ((pull E)⁻¹ * F.realPolynomialSymbolHom b ω hF (fun _ : τ => 1) + (F.weightedAdaptedRealChartHom w (fun _ : τ => 1) β hβ g) * + (pull R)⁻¹)) + lower)) : ℂ) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))‖ := by + obtain ⟨C, hC, hreset⟩ := exists_actual_path_current_grade_reset s a + refine ⟨C, hC, ?_⟩ + intro τ ι κ L _ _ _ _ _ _ F b ω hF H l p hH hl hp hι hτ hκ hHp hlp hb N hN + obtain ⟨m, hm, hmp, hlm, hresetm⟩ := hreset F b ω hF (fun _ : τ => 1) + (fun _ => Nat.zero_lt_one) H l p hH hl hp hι hτ hκ hHp hlp hb (fun i => (N i : ℝ)) hN + refine ⟨m, hm, hmp, hlm, ?_⟩ + intro n _ _ _ _ hn U vg hspan hvg σ w β hβ K hK g E R hx + dsimp only + let pull := F.realSymbolHomogeneousPullbackHom b ω hF w (fun _ : τ => 1) + (fun i => weightedHomogeneousComponent (fun _ : τ => 1) (w i) (β i)) + (fun _i => weightedHomogeneousComponent_isWeightedHomogeneous _ _) + intro El Pl Rl hlocal hPl hEl hE hRl hR θ hθ Hθ pLocal hθH hpLocal hdimLocal + hMexp hqexp score lower hlower hNLocal + obtain ⟨E', P', R', hprod, hP', hE', hR', _, _, hslowdiff, hgriddiff⟩ := + hresetm U vg hspan hvg w β hβ K hK g E R (n + 1) (Nat.add_le_add_right hn 1) + hx El Pl Rl hlocal hPl hEl hE hRl hR + have htest := F.exists_currentGrade_localMajor_niltest_with_lower_phase b ω hF U θ hθ + E' P' R' (pull E) (pull R) hP' hE' hR' N Hθ m hm + (Real.exp ((p + C) ^ C)) pLocal (Real.exp_nonneg _) hθH hslowdiff hgriddiff + hpLocal hdimLocal hMexp hqexp score lower hlower hNLocal + rw [hprod] at htest + exact htest + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial _root_.MvPolynomial _root_.OAI.MvPolynomial +open scoped TensorProduct BigOperators + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom + +theorem exists_actual_path_buffered_localMajor_niltest (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {τ ι κ L : Type*} [Fintype τ] [DecidableEq τ] [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (H l : ℕ) (p : ℝ), 1 ≤ H → 0 < l → 0 ≤ p → + (Fintype.card ι : ℝ) ≤ p → (Fintype.card τ : ℝ) ≤ p → (Fintype.card κ : ℝ) ≤ p → + (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + (∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) → + ∀ N : τ → ℕ, (∀ i, Real.exp ((p + C) ^ C) ≤ (N i : ℝ)) → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + ∀ {n : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)], n ≤ s → + ∀ (U : LieSubalgebra ℚ F.AssociatedGraded) + (vg : κ → F.PolynomialSymbol (fun _ : τ => 1)), + Submodule.span ℚ (Set.range vg) = + (F.symbolPointwiseSubalgebra b ω hF (fun _ : τ => 1) U).toSubmodule → + (∀ i z, RationalHeightLE + ((F.polynomialSymbolBasis b ω hF (fun _ : τ => 1)).repr (vg i) z) H) → + ∀ {mTag : ℕ} {X η : Type} (J : Fin mTag → Type) [∀ j, Fintype (J j)] + (eQ : Basis η ℚ (F.AssociatedGraded ⧸ U.toSubmodule)) (j : η) + (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) + (c : Fin (Fintype.card (LowTaggedIndex J (n + 1))) → ℝ) + (β : X ⊕ (Σ j, J j) → MvPolynomial τ ℤ), + ∀ hβ : ∀ i, integerSampledRealChart β i ∈ + weightedSupportLE (fun _ : τ => 1) (fullTaggedVariableWeight J i), + ∀ K : Set ((X ⊕ (Σ j, J j)) → ℝ), + (∀ u : τ → ℝ, (fun i => MvPolynomial.eval u + (homogeneousComponent (fullTaggedVariableWeight J i) (integerSampledRealChart β i))) ∈ K) → + ∀ (g : (F.realification.adaptedPolynomialFiltration (fullTaggedVariableWeight (X := X) J)).Group) + (E R : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)), + (∀ t ∈ K, ∀ d < n + 1, + F.realSymbolGradeEvaluation b ω hF (fullTaggedVariableWeight J) d t + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord ∈ + realificationLieSubalgebra U) → + let pull := F.realSymbolHomogeneousPullbackHom b ω hF (fullTaggedVariableWeight J) + (fun _ : τ => 1) + (fun i => homogeneousComponent (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) + (fun i => sampledTopPhase_coordinate_homogeneous + (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) + ∀ (El Pl Rl : F.RealPolynomialSymbolGroup (fun _ : τ => 1)), + El * Pl * Rl = F.realPolynomialSymbolHom b ω hF (fun _ : τ => 1) + (F.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) (fun _ : τ => 1) + (integerSampledRealChart β) hβ g) → + Pl.coord ∈ realificationLieSubalgebra + (F.symbolPointwiseSubalgebra b ω hF (fun _ : τ => 1) U) → + F.SymbolSlowBound b ω hF (fun _ : τ => 1) (fun i => (N i : ℝ)) + (Real.exp ((p + 2) ^ a)) El → + F.SymbolSlowBound b ω hF (fun _ : τ => 1) (fun i => (N i : ℝ)) + (Real.exp ((p + 2) ^ a)) (pull E) → + F.SymbolRationalGrid b ω hF (fun _ : τ => 1) l Rl → + F.SymbolRationalGrid b ω hF (fun _ : τ => 1) l (pull R) → + ∀ (Hθ : ℕ) (pLocal : ℝ), + (∀ i, RationalHeightLE (((eQ.coord j).comp U.toSubmodule.mkQ) + (F.associatedGradedBasis b ω hF i)) Hθ) → + 1 ≤ pLocal → (Fintype.card τ : ℝ) ≤ pLocal → + (Fintype.card ι : ℝ) * Hθ * Real.exp ((p + C) ^ C) ≤ Real.exp pLocal → + ((Hθ ^ Fintype.card ι * m : ℕ) : ℝ) ≤ Real.exp pLocal → + ∀ score : (τ → ℤ) → ℝ, + (∀ i, Real.exp ((pLocal + (n + 401 : ℕ)) ^ (n + 401)) ≤ (N i : ℝ)) → + (∀ u ∈ integerBox N, ∀ i, + |MvPolynomial.eval (fun x => (integerSampledSpatial β u x : ℝ)) + (lowTaggedPolynomial J (n + 1) poly i) - c i - + (integerSampledLowTags J (n + 1) β u i : ℝ)| ≤ 1 / 8) → + ∃ q : ℕ, 0 < q ∧ q ≤ Hθ ^ Fintype.card ι * m ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((pLocal + (n + 401 : ℕ)) ^ (n + 401)) A.integerPoints ∧ + (𝔼 x : (∀ i, Fin (N i)), score (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ A.integerPoints, score x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : τ => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ A.integerPoints, + majorPhasePlateauSignal J (n + 1) poly c + (coordinate ((eQ.baseChange ℝ).coord j).toAddMonoidHom + (lowTaggedVectorRestrict J (n + 1) + (F.realSymbolGradeQuotientPolynomial b ω hF (fullTaggedVariableWeight J) + U.toSubmodule (n + 1) + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord))) + (integerSampledSpatial β x) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))‖ := by + obtain ⟨C, hC, htest⟩ := exists_actual_path_current_grade_local_niltest s a + refine ⟨C, hC, ?_⟩ + intro τ ι κ L _ _ _ _ _ _ F b ω hF H l p hH hl hp hι hτ hκ hHp hlp hb N hN + obtain ⟨m, hm, hmp, hlm, htestm⟩ := htest F b ω hF H l p + hH hl hp hι hτ hκ hHp hlp hb N hN + refine ⟨m, hm, hmp, hlm, ?_⟩ + intro n _ _ _ _ hn U vg hspan hvg mTag X η J _ eQ j poly c β hβ K hK g E R hx + dsimp only + intro El Pl Rl hlocal hPl hEl hE hRl hR Hθ pLocal hθH hpLocal hdimLocal + hMexp hqexp score hNLocal hbuffer + obtain ⟨lower, hlower, hphase⟩ := F.exists_bufferedSampledCurrentGrade_phase + b ω hF J β hβ U.toSubmodule eQ j n + (F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g) E R poly c + have hθ : ∀ x ∈ U, ((eQ.coord j).comp U.toSubmodule.mkQ) x = 0 := + fun x hx => F.quotientFunctional_kills_fast U.toSubmodule (eQ.coord j) x hx + obtain ⟨q, hq, hqbound, A, hAdense, hscore, T, hTnorm, hTcomplexity, hcorr⟩ := + htestm hn U vg hspan hvg (fullTaggedVariableWeight J) (integerSampledRealChart β) + hβ K hK g E R hx El Pl Rl hlocal hPl hEl hE hRl hR + ((eQ.coord j).comp U.toSubmodule.mkQ) hθ Hθ pLocal hθH hpLocal hdimLocal + hMexp hqexp score lower hlower hNLocal + refine ⟨q, hq, hqbound, A, hAdense, hscore, T, hTnorm, hTcomplexity, ?_⟩ + have hactual := F.realPolynomialSymbolHom_weightedAdaptedRealChart b ω hF + (fullTaggedVariableWeight J) (fun _ : τ => 1) (integerSampledRealChart β) hβ g + have hinside (u : τ → ℤ) (hu : u ∈ A.integerPoints) : u ∈ integerBox N := by + obtain ⟨t, _, rfl⟩ := Finset.mem_image.mp hu + apply (mem_integerBox N _).mpr + intro i + refine ⟨Int.natCast_nonneg _, ?_⟩ + change ((A.point t i).val : ℤ) < (N i : ℤ) + exact_mod_cast (A.point t i).isLt + have heq : (𝔼 x ∈ A.integerPoints, + majorPhasePlateauSignal J (n + 1) poly c + (coordinate ((eQ.baseChange ℝ).coord j).toAddMonoidHom + (lowTaggedVectorRestrict J (n + 1) + (F.realSymbolGradeQuotientPolynomial b ω hF (fullTaggedVariableWeight J) + U.toSubmodule (n + 1) + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord))) + (integerSampledSpatial β x) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))) = + (𝔼 x ∈ A.integerPoints, + (Real.fourierChar (eval (fun i => (x i : ℝ)) + (homogeneousComponent (n + 1) + (F.scalarSymbolPolynomial b ω hF (fun _ : τ => 1) + ((eQ.coord j).comp U.toSubmodule.mkQ) + ((F.realSymbolHomogeneousPullbackHom b ω hF (fullTaggedVariableWeight J) + (fun _ : τ => 1) + (fun i => homogeneousComponent (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) + (fun i => sampledTopPhase_coordinate_homogeneous + (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) E)⁻¹ * + F.realPolynomialSymbolHom b ω hF (fun _ : τ => 1) + (F.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) (fun _ : τ => 1) + (integerSampledRealChart β) hβ g) * + (F.realSymbolHomogeneousPullbackHom b ω hF (fullTaggedVariableWeight J) + (fun _ : τ => 1) + (fun i => homogeneousComponent (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) + (fun i => sampledTopPhase_coordinate_homogeneous + (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) R)⁻¹)) + lower)) : ℂ) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))) := by + apply Finset.expect_congr rfl + intro x hxA + have h := hphase x (hbuffer x (hinside x hxA)) + rw [hactual] + exact congrArg (fun z : ℂ => z * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))) h + rw [heq] + exact hcorr + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration +open Module VectorPolynomial _root_.MvPolynomial _root_.OAI.MvPolynomial BooleanCubeKernel +open scoped TensorProduct BigOperators Classical + +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom + +noncomputable def allocatedFrozenCurrentGradeResetConstant (s a : ℕ) : ℕ := + Classical.choose (exists_actual_path_buffered_localMajor_niltest.{0, 0, 0, 0} s a) + +theorem allocatedFrozenCurrentGradeResetConstant_ge_two (s a : ℕ) : + 2 ≤ allocatedFrozenCurrentGradeResetConstant s a := by + unfold allocatedFrozenCurrentGradeResetConstant + with_reducible exact + (Classical.choose_spec (exists_actual_path_buffered_localMajor_niltest.{0, 0, 0, 0} s a)).1 + +variable {mTag : ℕ} {G X : Type} [Fintype G] {I Deck J : Fin mTag → Type} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin mTag → ℕ} (B : LayerSamplerAxis I n → Type) [∀ k, Fintype (B k)] +variable (Utag : ∀ j, Submodule ℝ (J j → ℝ)) +variable (btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (Utag j))ᗮ) +variable (hbtag : ∀ j, Submodule.span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (Utag j))) +variable (otag : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (Utag j))) +variable {Rad σ : Fin mTag → ℝ} (S : LayerSamplerScale (G := G) B Utag btag Rad σ) +variable (hRad : ∀ j, 0 < Rad j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ Utag j) + +theorem exists_allocated_frozen_current_grade_local_niltest (s a : ℕ) + (keep : LayerSamplerVariables G I n B → Prop) + {ι κ L : Type} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (H l : ℕ) (p : ℝ) (hH : 1 ≤ H) (hl : 0 < l) (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) + (hτ : (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hlp : (l : ℝ) ≤ Real.exp p) + (hbracket : ∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) + (hN : ∀ i : {i : LayerSamplerVariables G I n B // keep i}, + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ + ((Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val : ℕ) : ℝ)) : + ∃ reset : ℕ, 0 < reset ∧ + (reset : ℝ) ≤ Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ∧ l ∣ reset ∧ + ∀ {r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)], r ≤ s → + ∀ (fast : LieSubalgebra ℚ F.AssociatedGraded) + (vg : κ → F.PolynomialSymbol (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + Submodule.span ℚ (Set.range vg) = + (F.symbolPointwiseSubalgebra b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) fast).toSubmodule → + (∀ i z, RationalHeightLE ((F.polynomialSymbolBasis b ω hF + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)).repr (vg i) z) H) → + ∀ {η : Type} (eQ : Basis η ℚ (F.AssociatedGraded ⧸ fast.toSubmodule)) (j : η) + (c : ∀ j, Utag j) (origin : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I Deck n B → ℤ), + AllocatedCenteredFramedRecoveredSampleAt B Utag btag hbtag otag S hRad hσ poly hm c origin v sample read → + ∀ (fixed : {i : LayerSamplerVariables G I n B // ¬keep i} → ℤ), + (∀ i, 0 ≤ fixed i ∧ fixed i < + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val) → + (∀ j, σ j ≤ 1) → + ∀ (Cgeo : Fin mTag → ℝ), (∀ j, 0 ≤ Cgeo j) → + (∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (Utag j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) → + (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1 / 8) → + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + ∀ (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) (Bstage pK M LongSide : ℝ) (blocks : ℕ), + RationalTaggedConstraintCertificate J Set.univ K Bstage blocks → + (∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ Utag j) → t ∈ K) → + 0 ≤ pK → Bstage ≤ pK → (∀ j, (Fintype.card (J j) : ℝ) ≤ pK) → + 0 ≤ M → (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ M) → + 1 ≤ LongSide → + (∀ i, keep i → LongSide ≤ layerSamplerBox B Utag btag S i) → + Real.exp ((pK + 2) ^ 9) ^ 2 * M < LongSide → + let β := allocatedFrozenIntegerFullChart B Utag btag otag poly hm c origin v sample keep fixed + let N := fun i : {i : LayerSamplerVariables G I n B // keep i} => + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val + ∀ (g : (F.realification.adaptedPolynomialFiltration (fullTaggedVariableWeight (X := X) J)).Group) + (E R : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)), + (∀ t ∈ K, ∀ d < r + 1, + F.realSymbolGradeEvaluation b ω hF (fullTaggedVariableWeight J) d t + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord ∈ + realificationLieSubalgebra fast) → + let pull := F.realSymbolHomogeneousPullbackHom b ω hF (fullTaggedVariableWeight J) + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (fun i => homogeneousComponent (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) + (fun i => sampledTopPhase_coordinate_homogeneous (fullTaggedVariableWeight J i) (integerSampledRealChart β i)) + ∀ (El Pl Rl : F.RealPolynomialSymbolGroup (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + El * Pl * Rl = F.realPolynomialSymbolHom b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (F.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (integerSampledRealChart β) + (allocatedFrozenIntegerFullChart_support B Utag btag otag poly hm c origin v sample keep fixed) g) → + Pl.coord ∈ realificationLieSubalgebra + (F.symbolPointwiseSubalgebra b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) fast) → + F.SymbolSlowBound b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (fun i => (N i : ℝ)) (Real.exp ((p + 2) ^ a)) El → + F.SymbolSlowBound b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (fun i => (N i : ℝ)) (Real.exp ((p + 2) ^ a)) (pull E) → + F.SymbolRationalGrid b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) l Rl → + F.SymbolRationalGrid b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) l (pull R) → + ∀ (Hθ : ℕ) (pLocal : ℝ), + (∀ i, RationalHeightLE (((eQ.coord j).comp fast.toSubmodule.mkQ) + (F.associatedGradedBasis b ω hF i)) Hθ) → + 1 ≤ pLocal → (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ pLocal → + (Fintype.card ι : ℝ) * Hθ * + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ Real.exp pLocal → + ((Hθ ^ Fintype.card ι * reset : ℕ) : ℝ) ≤ Real.exp pLocal → + ∀ score : ({i : LayerSamplerVariables G I n B // keep i} → ℤ) → ℝ, + (∀ i, Real.exp ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) ≤ (N i : ℝ)) → + ∃ q : ℕ, 0 < q ∧ q ≤ Hθ ^ Fintype.card ι * reset ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) A.integerPoints ∧ + (𝔼 u : (∀ i, Fin (N i)), score (fun i => ((u i).val : ℤ))) ≤ + (𝔼 u ∈ A.integerPoints, score u) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold r).Niltest + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget r) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 u ∈ A.integerPoints, + majorPhasePlateauSignal J (r + 1) poly + (fun i => (c (lowTaggedIndex J (r + 1) i).1).val (lowTaggedIndex J (r + 1) i).2) + (coordinate ((eQ.baseChange ℝ).coord j).toAddMonoidHom + (lowTaggedVectorRestrict J (r + 1) + (F.realSymbolGradeQuotientPolynomial b ω hF (fullTaggedVariableWeight J) + fast.toSubmodule (r + 1) + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord))) + (jointIntegerPhysicalSite (finiteSplitPoint keep u fixed) (origin, v)) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q u))‖ := by + let N := fun i : {i : LayerSamplerVariables G I n B // keep i} => + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val + obtain ⟨reset, hreset, hresetbound, hlreset, hlocal⟩ := + (Classical.choose_spec (exists_actual_path_buffered_localMajor_niltest.{0, 0, 0, 0} s a)).2 + (τ := {i : LayerSamplerVariables G I n B // keep i}) (κ := κ) + F b ω hF H l p hH hl hp hι hτ hκ hHp hlp hbracket N hN + refine ⟨reset, hreset, hresetbound, hlreset, ?_⟩ + intro r _ _ _ _ hr fast vg hspan hvg η eQ j c origin v sample read hread fixed hfixed + hσ1 Cgeo hCgeo hchart hsmall hpoly K Bstage pK M LongSide blocks hcertificate + hretained hpK hBpK hJ hM hcap hLong hlong hthreshold + dsimp only + intro g E R hinvariant El Pl Rl hfactor hPl hEl hE hRl hR Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal + have hβ := allocatedFrozenIntegerFullChart_support B Utag btag otag poly hm c origin v sample keep fixed + have hrange := hread.integerFrozenFullChart_certified_top_range B Utag btag hbtag otag S hRad hσ + poly hm hσ1 c origin v sample read K hcertificate hretained hpK hBpK hJ + Cgeo hCgeo hchart hM hcap keep hLong hlong hthreshold fixed + have hbuffer := hread.integerFrozenFullChart_low_residual B Utag btag hbtag otag S hRad hσ poly hm + hσ1 Cgeo hCgeo hchart hsmall hpoly c origin v sample read keep fixed hfixed (r + 1) + obtain ⟨q, hq, hqbound, A, hAdense, hscore, T, hTnorm, hTcomplexity, hcorr⟩ := + hlocal hr fast vg hspan hvg J eQ j poly + (fun i => (c (lowTaggedIndex J (r + 1) i).1).val (lowTaggedIndex J (r + 1) i).2) + (allocatedFrozenIntegerFullChart B Utag btag otag poly hm c origin v sample keep fixed) + hβ K hrange g E R hinvariant El Pl Rl hfactor hPl hEl hE hRl hR + Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal hbuffer + refine ⟨q, hq, hqbound, A, hAdense, hscore, T, hTnorm, hTcomplexity, ?_⟩ + simpa only [allocatedFrozenIntegerFullChart_spatial] using hcorr + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration +open Module VectorPolynomial _root_.MvPolynomial _root_.OAI.MvPolynomial BooleanCubeKernel +open scoped TensorProduct BigOperators Classical +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom + +variable {mTag : ℕ} {G X : Type} [Fintype G] [Fintype X] {I Deck J : Fin mTag → Type} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin mTag → ℕ} (B : LayerSamplerAxis I n → Type) [∀ k, Fintype (B k)] +variable (Utag : ∀ j, Submodule ℝ (J j → ℝ)) +variable (btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (Utag j))ᗮ) +variable (hbtag : ∀ j, Submodule.span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (Utag j))) +variable (otag : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (Utag j))) +variable {Rad σ : Fin mTag → ℝ} (S : LayerSamplerScale (G := G) B Utag btag Rad σ) +variable (hRad : ∀ j, 0 < Rad j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ Utag j) + +theorem exists_allocated_controlled_frozen_current_grade_local_niltest (s a : ℕ) + (keep : LayerSamplerVariables G I n B → Prop) + {ι κ L : Type} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (H lLocal : ℕ) (p : ℝ) (hH : 1 ≤ H) (hlLocal : 0 < lLocal) (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) + (hτ : (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) + (hbracket : ∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) + (E R : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (Nambient : X → ℕ) (hNambient : ∀ i, 0 < Nambient i) {budget : ℝ} + (hcontrol : FullChartControlledFactors F b ω hF J poly Nambient E R budget) + (hcommon : Real.exp budget * (lLocal : ℝ) ≤ Real.exp p) + (hallowance : + (((s : ℝ) + 1) * ((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ s * + Real.exp budget * + (((mTag + 1 : ℕ) : ℝ) * ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ mTag) ^ s) + ≤ Real.exp ((p + 2) ^ a)) + (hN : ∀ i : {i : LayerSamplerVariables G I n B // keep i}, + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ + ((Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val : ℕ) : ℝ)) : + ∃ qCurrent : ℕ, 0 < qCurrent ∧ (qCurrent : ℝ) ≤ Real.exp budget ∧ + ∃ reset : ℕ, 0 < reset ∧ + (reset : ℝ) ≤ Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ∧ qCurrent * lLocal ∣ reset ∧ + ∀ {r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)], r ≤ s → + ∀ (fast : LieSubalgebra ℚ F.AssociatedGraded) + (vg : κ → F.PolynomialSymbol (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + Submodule.span ℚ (Set.range vg) = + (F.symbolPointwiseSubalgebra b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) fast).toSubmodule → + (∀ i z, RationalHeightLE ((F.polynomialSymbolBasis b ω hF + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)).repr (vg i) z) H) → + ∀ {η : Type} (eQ : Basis η ℚ (F.AssociatedGraded ⧸ fast.toSubmodule)) (j : η) + (c : ∀ j, Utag j) (origin : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I Deck n B → ℤ), + AllocatedCenteredFramedRecoveredSampleAt B Utag btag hbtag otag S hRad hσ poly hm c origin v sample read → + ∀ {τ ξ : ℝ}, 0 < τ → τ ≤ 1 → ξ ≤ 1 → + v ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths + (allocatedPhysicalRootBudget B Utag btag S (fun _ => 0)) τ ξ Nambient) 1 → + ∀ (fixed : {i : LayerSamplerVariables G I n B // ¬keep i} → ℤ), + (∀ i, 0 ≤ fixed i ∧ fixed i < + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val) → + (∀ j, σ j ≤ 1) → + ∀ (Cgeo : Fin mTag → ℝ), (∀ j, 0 ≤ Cgeo j) → + (∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (Utag j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) → + (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1 / 8) → + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + ∀ (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) (Bstage pK M LongSide : ℝ) (blocks : ℕ), + RationalTaggedConstraintCertificate J Set.univ K Bstage blocks → + (∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ Utag j) → t ∈ K) → + 0 ≤ pK → Bstage ≤ pK → (∀ j, (Fintype.card (J j) : ℝ) ≤ pK) → + 0 ≤ M → (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ M) → + 1 ≤ LongSide → + (∀ i, keep i → LongSide ≤ layerSamplerBox B Utag btag S i) → + Real.exp ((pK + 2) ^ 9) ^ 2 * M < LongSide → + let β := allocatedFrozenIntegerFullChart B Utag btag otag poly hm c origin v sample keep fixed + let N := fun i : {i : LayerSamplerVariables G I n B // keep i} => + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val + ∀ (g : (F.realification.adaptedPolynomialFiltration (fullTaggedVariableWeight (X := X) J)).Group), + (∀ t ∈ K, ∀ d < r + 1, + F.realSymbolGradeEvaluation b ω hF (fullTaggedVariableWeight J) d t + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord ∈ + realificationLieSubalgebra fast) → + ∀ (El Pl Rl : F.RealPolynomialSymbolGroup (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + El * Pl * Rl = F.realPolynomialSymbolHom b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (F.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (integerSampledRealChart β) + (allocatedFrozenIntegerFullChart_support B Utag btag otag poly hm c origin v sample keep fixed) g) → + Pl.coord ∈ realificationLieSubalgebra + (F.symbolPointwiseSubalgebra b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) fast) → + F.SymbolSlowBound b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (fun i => (N i : ℝ)) (Real.exp ((p + 2) ^ a)) El → + F.SymbolRationalGrid b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) lLocal Rl → + ∀ (Hθ : ℕ) (pLocal : ℝ), + (∀ i, RationalHeightLE (((eQ.coord j).comp fast.toSubmodule.mkQ) + (F.associatedGradedBasis b ω hF i)) Hθ) → + 1 ≤ pLocal → (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ pLocal → + (Fintype.card ι : ℝ) * Hθ * + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ Real.exp pLocal → + ((Hθ ^ Fintype.card ι * reset : ℕ) : ℝ) ≤ Real.exp pLocal → + ∀ score : ({i : LayerSamplerVariables G I n B // keep i} → ℤ) → ℝ, + (∀ i, Real.exp ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) ≤ (N i : ℝ)) → + ∃ q : ℕ, 0 < q ∧ q ≤ Hθ ^ Fintype.card ι * reset ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) A.integerPoints ∧ + (𝔼 u : (∀ i, Fin (N i)), score (fun i => ((u i).val : ℤ))) ≤ + (𝔼 u ∈ A.integerPoints, score u) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold r).Niltest + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget r) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 u ∈ A.integerPoints, + majorPhasePlateauSignal J (r + 1) poly + (fun i => (c (lowTaggedIndex J (r + 1) i).1).val (lowTaggedIndex J (r + 1) i).2) + (coordinate ((eQ.baseChange ℝ).coord j).toAddMonoidHom + (lowTaggedVectorRestrict J (r + 1) + (F.realSymbolGradeQuotientPolynomial b ω hF (fullTaggedVariableWeight J) + fast.toSubmodule (r + 1) + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord))) + (jointIntegerPhysicalSite (finiteSplitPoint keep u fixed) (origin, v)) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q u))‖ := by + obtain ⟨qCurrent, hqCurrent, hqCurrentBound, hpulls⟩ := + hcontrol.exists_allocated_frozen_pullbacks B Utag btag hbtag otag S hRad hσ poly hm + F b ω hF E R Nambient hNambient hallowance + have hl : 0 < qCurrent * lLocal := Nat.mul_pos hqCurrent hlLocal + have hlp : ((qCurrent * lLocal : ℕ) : ℝ) ≤ Real.exp p := by + rw [Nat.cast_mul] + exact (mul_le_mul_of_nonneg_right hqCurrentBound (Nat.cast_nonneg lLocal)).trans hcommon + obtain ⟨reset, hreset, hresetbound, hlreset, hlocal⟩ := + exists_allocated_frozen_current_grade_local_niltest B Utag btag hbtag otag S hRad hσ poly hm + s a keep F b ω hF H (qCurrent * lLocal) p hH hl hp hι hτ hκ hHp hlp hbracket hN + refine ⟨qCurrent, hqCurrent, hqCurrentBound, reset, hreset, hresetbound, hlreset, ?_⟩ + intro r _ _ _ _ hr fast vg hspan hvg η eQ j c origin v sample read hread + τ ξ hτpos hτone hξ hv fixed hfixed hσ1 Cgeo hCgeo hchart hsmall hpoly + K Bstage pK M LongSide blocks hcertificate hretained hpK hBpK hJ hM hcap hLong hlong hthreshold + dsimp only + intro g hinvariant El Pl Rl hfactor hPl hEl hRl Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal + have hsmallOne : ∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1 := + fun j => (hsmall j).trans (by norm_num) + have hcurrent := hpulls c origin v sample read hread keep fixed + have hpullR := hcurrent.1 (qCurrent * lLocal) (dvd_mul_right qCurrent lLocal) + have hpullE := hcurrent.2 hτpos hτone hξ hv hσ1 hpoly Cgeo hCgeo hchart hsmallOne + have hlocalR := F.symbolRationalGrid_mono b ω hF + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + hlLocal (dvd_mul_left lLocal qCurrent) Rl hRl + exact hlocal hr fast vg hspan hvg eQ j c origin v sample read hread fixed hfixed + hσ1 Cgeo hCgeo hchart hsmall hpoly K Bstage pK M LongSide blocks hcertificate + hretained hpK hBpK hJ hM hcap hLong hlong hthreshold + g E R hinvariant El Pl Rl hfactor hPl hEl hpullE hlocalR hpullR + Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration +open Module VectorPolynomial _root_.MvPolynomial _root_.OAI.MvPolynomial BooleanCubeKernel +open scoped TensorProduct BigOperators Classical +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom + +variable {mTag : ℕ} {G X : Type} [Fintype G] [Fintype X] {I Deck J : Fin mTag → Type} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin mTag → ℕ} (B : LayerSamplerAxis I n → Type) [∀ k, Fintype (B k)] +variable (Utag : ∀ j, Submodule ℝ (J j → ℝ)) +variable (btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (Utag j))ᗮ) +variable (hbtag : ∀ j, Submodule.span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (Utag j))) +variable (otag : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (Utag j))) +variable {Rad σ : Fin mTag → ℝ} (S : LayerSamplerScale (G := G) B Utag btag Rad σ) +variable (hRad : ∀ j, 0 < Rad j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ Utag j) + +theorem exists_allocated_common_frozen_current_grade_local_niltest (s a : ℕ) + (keep : LayerSamplerVariables G I n B → Prop) + {ι κ L : Type} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (H lLocal : ℕ) (p : ℝ) (hH : 1 ≤ H) (hlLocal : 0 < lLocal) (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) + (hτ : (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) + (hbracket : ∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) + (E R : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (Nambient : X → ℕ) (hNambient : ∀ i, 0 < Nambient i) {budget : ℝ} + (hcontrol : FullChartControlledFactors F b ω hF J poly Nambient E R budget) + (hcommon : Real.exp budget * (lLocal : ℝ) ≤ Real.exp p) + (hallowance : + (((s : ℝ) + 1) * ((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ s * + Real.exp budget * + (((mTag + 1 : ℕ) : ℝ) * ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ mTag) ^ s) + ≤ Real.exp ((p + 2) ^ a)) + (hN : ∀ i : {i : LayerSamplerVariables G I n B // keep i}, + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ + ((Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val : ℕ) : ℝ)) : + ∃ qCurrent : ℕ, 0 < qCurrent ∧ (qCurrent : ℝ) ≤ Real.exp budget ∧ + ∃ reset : ℕ, 0 < reset ∧ + (reset : ℝ) ≤ Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ∧ qCurrent * lLocal ∣ reset ∧ + ∀ {r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)], r ≤ s → + ∀ (fast : LieSubalgebra ℚ F.AssociatedGraded) + (vg : κ → F.PolynomialSymbol (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + Submodule.span ℚ (Set.range vg) = + (F.symbolPointwiseSubalgebra b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) fast).toSubmodule → + (∀ i z, RationalHeightLE ((F.polynomialSymbolBasis b ω hF + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)).repr (vg i) z) H) → + ∀ {η : Type} (eQ : Basis η ℚ (F.AssociatedGraded ⧸ fast.toSubmodule)) (j : η) + (c : ∀ j, Utag j) (origin : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I Deck n B → ℤ), + AllocatedCenteredFramedRecoveredSampleAt B Utag btag hbtag otag S hRad hσ poly hm c origin v sample read → + ∀ {τ ξ : ℝ}, 0 < τ → τ ≤ 1 → ξ ≤ 1 → + v ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths + (allocatedPhysicalRootBudget B Utag btag S (fun _ => 0)) τ ξ Nambient) 1 → + ∀ (fixed : {i : LayerSamplerVariables G I n B // ¬keep i} → ℤ), + (∀ i, 0 ≤ fixed i ∧ fixed i < + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val) → + (∀ j, σ j ≤ 1) → + ∀ (Cgeo : Fin mTag → ℝ), (∀ j, 0 ≤ Cgeo j) → + (∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (Utag j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) → + (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1 / 8) → + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + ∀ (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) (Bstage pK M LongSide : ℝ) (blocks : ℕ), + RationalTaggedConstraintCertificate J Set.univ K Bstage blocks → + (∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ Utag j) → t ∈ K) → + 0 ≤ pK → Bstage ≤ pK → (∀ j, (Fintype.card (J j) : ℝ) ≤ pK) → + 0 ≤ M → (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ M) → + 1 ≤ LongSide → + (∀ i, keep i → LongSide ≤ layerSamplerBox B Utag btag S i) → + Real.exp ((pK + 2) ^ 9) ^ 2 * M < LongSide → + let N := fun i : {i : LayerSamplerVariables G I n B // keep i} => + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val + ∀ (g : (F.realification.adaptedPolynomialFiltration (fullTaggedVariableWeight (X := X) J)).Group), + (∀ t ∈ K, ∀ d < r + 1, + F.realSymbolGradeEvaluation b ω hF (fullTaggedVariableWeight J) d t + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord ∈ + realificationLieSubalgebra fast) → + F.HasCommonRefilteredOrbitFactors b ω hF + (layerSamplerBox B Utag btag S) ((p + 2) ^ a) lLocal fast + (F.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : LayerSamplerVariables G I n B => 1) + (integerSampledRealChart + (allocatedRecoveredIntegerFullChart B Utag btag otag poly hm c origin v sample)) + (allocatedRecoveredIntegerFullChart_support B Utag btag otag poly hm c origin v sample) g) → + ∀ (Hθ : ℕ) (pLocal : ℝ), + (∀ i, RationalHeightLE (((eQ.coord j).comp fast.toSubmodule.mkQ) + (F.associatedGradedBasis b ω hF i)) Hθ) → + 1 ≤ pLocal → (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ pLocal → + (Fintype.card ι : ℝ) * Hθ * + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ Real.exp pLocal → + ((Hθ ^ Fintype.card ι * reset : ℕ) : ℝ) ≤ Real.exp pLocal → + ∀ score : ({i : LayerSamplerVariables G I n B // keep i} → ℤ) → ℝ, + (∀ i, Real.exp ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) ≤ (N i : ℝ)) → + ∃ q : ℕ, 0 < q ∧ q ≤ Hθ ^ Fintype.card ι * reset ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) A.integerPoints ∧ + (𝔼 u : (∀ i, Fin (N i)), score (fun i => ((u i).val : ℤ))) ≤ + (𝔼 u ∈ A.integerPoints, score u) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold r).Niltest + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget r) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 u ∈ A.integerPoints, + majorPhasePlateauSignal J (r + 1) poly + (fun i => (c (lowTaggedIndex J (r + 1) i).1).val (lowTaggedIndex J (r + 1) i).2) + (coordinate ((eQ.baseChange ℝ).coord j).toAddMonoidHom + (lowTaggedVectorRestrict J (r + 1) + (F.realSymbolGradeQuotientPolynomial b ω hF (fullTaggedVariableWeight J) + fast.toSubmodule (r + 1) + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord))) + (jointIntegerPhysicalSite (finiteSplitPoint keep u fixed) (origin, v)) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q u))‖ := by + obtain ⟨qCurrent, hqCurrent, hqCurrentBound, reset, hreset, hresetbound, hlreset, hlocal⟩ := + exists_allocated_controlled_frozen_current_grade_local_niltest B Utag btag hbtag otag S hRad hσ poly hm + s a keep F b ω hF H lLocal p hH hlLocal hp hι hτ hκ hHp hbracket + E R Nambient hNambient hcontrol hcommon hallowance hN + refine ⟨qCurrent, hqCurrent, hqCurrentBound, reset, hreset, hresetbound, hlreset, ?_⟩ + intro r _ _ _ _ hr fast vg hspan hvg η eQ j c origin v sample read hread + τ ξ hτpos hτone hξ hv fixed hfixed hσ1 Cgeo hCgeo hchart hsmall hpoly + K Bstage pK M LongSide blocks hcertificate hretained hpK hBpK hJ hM hcap hLong hlong hthreshold + dsimp only + intro g hinvariant hnative Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal + obtain ⟨El, Pl, Rl, hfactor, hPl, hEl, hRl⟩ := + hnative.allocatedFrozenSymbolFactors F b ω hF B Utag btag otag S poly hm + c origin v sample keep fixed ((p + 2) ^ a) lLocal fast g + exact hlocal hr fast vg hspan hvg eQ j c origin v sample read hread hτpos hτone hξ hv + fixed hfixed hσ1 Cgeo hCgeo hchart hsmall hpoly K Bstage pK M LongSide blocks hcertificate + hretained hpK hBpK hJ hM hcap hLong hlong hthreshold + g hinvariant El Pl Rl hfactor hPl hEl hRl + Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3 +open Module VectorPolynomial Submodule BooleanCubeKernel RationalFilteredNilmanifold +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] [DecidableEq X] + {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {J : Fin m → Type} [∀ j, Fintype (J j)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag R σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + (A : AllocatedExternalCandidateSampler B U btag S hb o hR hσ N poly hm τ ξ stride cells center) + +namespace NilpotentLieFiltration + +theorem exists_allocated_full_chart_major_correlation_witness_of_frozen_local_niltests + {k t : ℕ} {L ι η : Type} [Fintype η] + [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (fast : Submodule ℚ F.AssociatedGraded) + (basis : Basis η ℝ (ℝ ⊗[ℚ] (F.AssociatedGraded ⧸ fast))) + (Z left right : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (htk : t < k) + (hpoly : ∀ j, DegreeLE (fun _ => 1) (j.val + 1) (poly j)) + (c : Fin (Fintype.card (LowTaggedIndex J k)) → ℝ) + (pSlice pTest pNative pMajor Rrank : ℝ) (C : ℕ) + (hpNative : 2 ≤ pNative) (hη : (Fintype.card η : ℝ) ≤ pNative) + (hNativeMajor : pNative ≤ pMajor) (hproduct : productNiltestBudget pNative ≤ pMajor) + (hdim : ((Fintype.card X + Fintype.card (Σ j, J j) : ℕ) : ℝ) ≤ pMajor) + (hN : ∀ i, Real.exp ((pMajor + C) ^ C) ≤ (N i : ℝ)) + (hRrank : Real.exp ((pMajor + C) ^ C) ≤ Rrank) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) + (fun i => (N i : ℝ)) Rrank (U j) (poly j)) + (good : η → Finset A.Path) + (keep : LayerSamplerVariables G I n B → Prop) + (cost Bshort : ℝ) (hcost : 0 ≤ cost) + (hBshort : 1 ≤ Bshort) (hshort : ∀ i, ¬keep i → (A.sides i : ℝ) ≤ Bshort) + (hξ : ξ ≤ 1) + (α : ℝ) (hmass : ∀ j, α ≤ (9 / 10 : ℝ) * A.law.mass (good j)) + (hdirect : A.NativeDetection t pSlice pTest pNative α) + (hslice : max cost (Real.log Bshort) ≤ pSlice) + (htest : OrdinaryPolynomialPhase.budget t ≤ pTest) + (strideBound : η → A.Path → ℕ) + (score : η → A.Path → ({i : LayerSamplerVariables G I n B // keep i} → ℤ) → ℝ) + (hlocal : ∀ j z, z ∈ good j → + ∃ fixed : {i // ¬keep i} → ℤ, + (∀ i, 0 ≤ fixed i ∧ fixed i < A.sides i.val) ∧ + ∃ q : ℕ, 0 < q ∧ q ≤ strideBound j z ∧ + ∃ slice : ResidueBoxSlice (fun i : {i // keep i} => A.sides i.val) q, + IsDenseCommonStrideBox (fun i : {i // keep i} => A.sides i.val) cost slice.integerPoints ∧ + (𝔼 x : (∀ i : {i // keep i}, Fin (A.sides i.val)), + score j z (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ slice.integerPoints, score j z x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold t).Niltest (fun _ : {i // keep i} => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget t) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ slice.integerPoints, + majorPhasePlateauSignal J k poly c + (coordinate (basis.coord j).toAddMonoidHom + (lowTaggedVectorRestrict J k (F.realSymbolGradeQuotientPolynomial b ω hF + (fullTaggedVariableWeight (X := X) J) fast k (left⁻¹ * Z * right⁻¹).coord))) + (jointIntegerPhysicalSite (finiteSplitPoint keep x fixed) (z.1.val, z.2.val)) * + star (T.eval (commonStrideIndex (fun i => (slice.start i : ℤ)) q x))‖) : + Nonempty (FullChartMajorCorrelationWitness F b ω hF J k fast basis + Z left right N poly U pMajor Rrank C) := by + apply exists_allocated_full_chart_major_correlation_witness_of_frozen_local_tests + A F b ω hF fast basis Z left right htk hpoly c pSlice pTest pNative pMajor Rrank C + hpNative hη hNativeMajor hproduct hdim hN hRrank hrank good keep cost Bshort + hcost hBshort hshort hξ α hmass hdirect hslice htest + intro j z hz + obtain ⟨fixed, hfixed, q, hq, _, slice, hdense, _, T, hnorm, hcomplex, hcorr⟩ := hlocal j z hz + let packet : LocalMajorSliceTest (OrdinaryPolynomialPhase.nilmanifold t) + (fun i : {i // keep i} => A.sides i.val) cost (OrdinaryPolynomialPhase.budget t) := + { stride := q + stride_pos := hq + slice := slice + dense := hdense + test := T + norm := by rw [hnorm]; norm_num + complexity := hcomplex } + exact ⟨fixed, hfixed, packet, hcorr⟩ + +end NilpotentLieFiltration +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration +open Module VectorPolynomial _root_.MvPolynomial _root_.OAI.MvPolynomial BooleanCubeKernel +open scoped TensorProduct BigOperators Classical +attribute [local irreducible] weightedAdaptedRealChartHom realPolynomialSymbolHom + realSymbolHomogeneousPullbackHom + +variable {mTag : ℕ} {G X : Type} [Fintype G] [Fintype X] {I Deck J : Fin mTag → Type} +variable [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] +variable {n : Fin mTag → ℕ} (B : LayerSamplerAxis I n → Type) [∀ k, Fintype (B k)] +variable (Utag : ∀ j, Submodule ℝ (J j → ℝ)) +variable (btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (Utag j))ᗮ) +variable (hbtag : ∀ j, Submodule.span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (Utag j))) +variable (otag : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (Utag j))) +variable {Rad σ : Fin mTag → ℝ} (S : LayerSamplerScale (G := G) B Utag btag Rad σ) +variable (hRad : ∀ j, 0 < Rad j) (hσ : ∀ j, 0 < σ j) +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hm : ∀ j d, coefficients (poly j) d ∈ Utag j) + +theorem exists_allocated_kept_common_current_grade_local_niltest (s a : ℕ) + (keep : LayerSamplerVariables G I n B → Prop) + {ι κ L : Type} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (H lLocal : ℕ) (p : ℝ) (hH : 1 ≤ H) (hlLocal : 0 < lLocal) (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) + (hτ : (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ p) + (hκ : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) + (hbracket : ∀ i j z, RationalHeightLE (b.repr ⁅b i, b j⁆ z) H) + (E R : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (Nambient : X → ℕ) (hNambient : ∀ i, 0 < Nambient i) {budget : ℝ} + (hcontrol : FullChartControlledFactors F b ω hF J poly Nambient E R budget) + (hcommon : Real.exp budget * (lLocal : ℝ) ≤ Real.exp p) + (hallowance : + (((s : ℝ) + 1) * ((Fintype.card (X ⊕ (Σ j, J j)) : ℝ) + 1) ^ s * + Real.exp budget * + (((mTag + 1 : ℕ) : ℝ) * ((Fintype.card (LayerSamplerVariables G I n B) + 1 : ℕ) : ℝ) ^ mTag) ^ s) + ≤ Real.exp ((p + 2) ^ a)) + (hN : ∀ i : {i : LayerSamplerVariables G I n B // keep i}, + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ + ((Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val : ℕ) : ℝ)) : + ∃ qCurrent : ℕ, 0 < qCurrent ∧ (qCurrent : ℝ) ≤ Real.exp budget ∧ + ∃ reset : ℕ, 0 < reset ∧ + (reset : ℝ) ≤ Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ∧ qCurrent * lLocal ∣ reset ∧ + ∀ {r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra OrdinaryPolynomialPhase.weight r)], r ≤ s → + ∀ (fast : LieSubalgebra ℚ F.AssociatedGraded) + (vg : κ → F.PolynomialSymbol (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)), + Submodule.span ℚ (Set.range vg) = + (F.symbolPointwiseSubalgebra b ω hF (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) fast).toSubmodule → + (∀ i z, RationalHeightLE ((F.polynomialSymbolBasis b ω hF + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1)).repr (vg i) z) H) → + ∀ {η : Type} (eQ : Basis η ℚ (F.AssociatedGraded ⧸ fast.toSubmodule)) (j : η) + (c : ∀ j, Utag j) (origin : X → ℤ) + (v : Option (LayerSamplerVariables G I n B) × X → ℤ) + (sample : CoefficientSamplerArrays (K := LayerSamplerVariables G I n B) I n) + (read : AllocatedActualCoefficientIndex G X I Deck n B → ℤ), + AllocatedCenteredFramedRecoveredSampleAt B Utag btag hbtag otag S hRad hσ poly hm c origin v sample read → + ∀ {τ ξ : ℝ}, 0 < τ → τ ≤ 1 → ξ ≤ 1 → + v ∈ rectangularWeightIndices 0 + (narrowTrimmedSpatialWidths + (allocatedPhysicalRootBudget B Utag btag S (fun _ => 0)) τ ξ Nambient) 1 → + ∀ (fixed : {i : LayerSamplerVariables G I n B // ¬keep i} → ℤ), + (∀ i, 0 ≤ fixed i ∧ fixed i < + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val) → + (∀ j, σ j ≤ 1) → + ∀ (Cgeo : Fin mTag → ℝ), (∀ j, 0 ≤ Cgeo j) → + (∀ j x, ‖(normalizedOrthogonalChart (euclideanSubspace (Utag j)) (btag j)).symm x‖ ≤ Cgeo j * ‖x‖) → + (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ 1 / 8) → + (∀ j, DegreeLE (1 : X → ℕ) (j.val + 1) (poly j)) → + ∀ (K : Set ((X ⊕ (Σ j, J j)) → ℝ)) (Bstage pK M LongSide : ℝ) (blocks : ℕ), + RationalTaggedConstraintCertificate J Set.univ K Bstage blocks → + (∀ t, (∀ j, (fun i => t (Sum.inr ⟨j, i⟩)) ∈ Utag j) → t ∈ K) → + 0 ≤ pK → Bstage ≤ pK → (∀ j, (Fintype.card (J j) : ℝ) ≤ pK) → + 0 ≤ M → (∀ j, Cgeo j * (((Fintype.card (I j) : ℝ) + 1) * Rad j) ≤ M) → + 1 ≤ LongSide → + (∀ i, keep i → LongSide ≤ layerSamplerBox B Utag btag S i) → + Real.exp ((pK + 2) ^ 9) ^ 2 * M < LongSide → + let N := fun i : {i : LayerSamplerVariables G I n B // keep i} => + Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B Utag btag S) i.val + ∀ (g : (F.realification.adaptedPolynomialFiltration (fullTaggedVariableWeight (X := X) J)).Group), + (∀ t ∈ K, ∀ d < r + 1, + F.realSymbolGradeEvaluation b ω hF (fullTaggedVariableWeight J) d t + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord ∈ + realificationLieSubalgebra fast) → + F.HasCommonRefilteredOrbitFactors b ω hF + (fun i : {i : LayerSamplerVariables G I n B // keep i} => (N i : ℝ)) + ((p + 2) ^ a) lLocal fast + (F.weightedAdaptedRealChartHom (fullTaggedVariableWeight J) + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1) + (integerSampledRealChart + (allocatedFrozenIntegerFullChart B Utag btag otag poly hm c origin v sample keep fixed)) + (allocatedFrozenIntegerFullChart_support B Utag btag otag poly hm c origin v sample keep fixed) g) → + ∀ (Hθ : ℕ) (pLocal : ℝ), + (∀ i, RationalHeightLE (((eQ.coord j).comp fast.toSubmodule.mkQ) + (F.associatedGradedBasis b ω hF i)) Hθ) → + 1 ≤ pLocal → (Fintype.card {i : LayerSamplerVariables G I n B // keep i} : ℝ) ≤ pLocal → + (Fintype.card ι : ℝ) * Hθ * + Real.exp ((p + allocatedFrozenCurrentGradeResetConstant s a) ^ + allocatedFrozenCurrentGradeResetConstant s a) ≤ Real.exp pLocal → + ((Hθ ^ Fintype.card ι * reset : ℕ) : ℝ) ≤ Real.exp pLocal → + ∀ score : ({i : LayerSamplerVariables G I n B // keep i} → ℤ) → ℝ, + (∀ i, Real.exp ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) ≤ (N i : ℝ)) → + ∃ q : ℕ, 0 < q ∧ q ≤ Hθ ^ Fintype.card ι * reset ∧ + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((pLocal + (r + 401 : ℕ)) ^ (r + 401)) A.integerPoints ∧ + (𝔼 u : (∀ i, Fin (N i)), score (fun i => ((u i).val : ℤ))) ≤ + (𝔼 u ∈ A.integerPoints, score u) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold r).Niltest + (fun _ : {i : LayerSamplerVariables G I n B // keep i} => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget r) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 u ∈ A.integerPoints, + majorPhasePlateauSignal J (r + 1) poly + (fun i => (c (lowTaggedIndex J (r + 1) i).1).val (lowTaggedIndex J (r + 1) i).2) + (coordinate ((eQ.baseChange ℝ).coord j).toAddMonoidHom + (lowTaggedVectorRestrict J (r + 1) + (F.realSymbolGradeQuotientPolynomial b ω hF (fullTaggedVariableWeight J) + fast.toSubmodule (r + 1) + (E⁻¹ * F.realPolynomialSymbolHom b ω hF (fullTaggedVariableWeight J) g * R⁻¹).coord))) + (jointIntegerPhysicalSite (finiteSplitPoint keep u fixed) (origin, v)) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q u))‖ := by + obtain ⟨qCurrent, hqCurrent, hqCurrentBound, reset, hreset, hresetbound, hlreset, hlocal⟩ := + exists_allocated_controlled_frozen_current_grade_local_niltest B Utag btag hbtag otag S hRad hσ poly hm + s a keep F b ω hF H lLocal p hH hlLocal hp hι hτ hκ hHp hbracket + E R Nambient hNambient hcontrol hcommon hallowance hN + refine ⟨qCurrent, hqCurrent, hqCurrentBound, reset, hreset, hresetbound, hlreset, ?_⟩ + intro r _ _ _ _ hr fast vg hspan hvg η eQ j c origin v sample read hread + τ ξ hτpos hτone hξ hv fixed hfixed hσ1 Cgeo hCgeo hchart hsmall hpoly + K Bstage pK M LongSide blocks hcertificate hretained hpK hBpK hJ hM hcap hLong hlong hthreshold + dsimp only + intro g hinvariant hnative Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal + obtain ⟨El, Pl, Rl, hfactor, hPl, hEl, hRl⟩ := + hnative.symbolFactors F b ω hF _ ((p + 2) ^ a) lLocal fast _ + exact hlocal hr fast vg hspan hvg eQ j c origin v sample read hread hτpos hτone hξ hv + fixed hfixed hσ1 Cgeo hCgeo hchart hsmall hpoly K Bstage pK M LongSide blocks hcertificate + hretained hpK hBpK hJ hM hcap hLong hlong hthreshold + g hinvariant El Pl Rl hfactor hPl hEl hRl + Hθ pLocal hθ hpLocal hdimLocal hMexp hqexp score hNLocal + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestNativeDetection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestNativeDetection.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3bf41cbcefd56622ba30d50c67453583d1b4f75 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestNativeDetection.lean @@ -0,0 +1,137 @@ +import OAI.Combinatorics.Progressions.Estimates.PreparedCanonicalNativeSource + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G : Type} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {s nX : ℕ} +variable (poly : ∀ j, VectorPolynomial (Fin nX) ℝ (J j → ℝ)) +variable (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +variable (N : (Fin nX) → ℕ) (hN : ∀ t, 0 < N t) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (stride : (Fin nX) → ℕ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) (Fin nX) stride)) + +local notation "widths" => narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (bases : Finset ((Fin nX) → ℤ)) (hbases : bases.Nonempty) +variable (htotal : 0 < selectedJointDensityMass bases stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) + (allocatedJointBaseDensity B U b hb o hR hσ S (Fin nX) poly hmem)) + +local notation "sides" => Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U b S) +local notation "kernelLaw" => FiniteProbabilityWeights.pi + (fun _ : G => integerScalarCubeWeights (Fin (s + 2)) S.value S.positive) + +local notation "Path" => bases × rectangularWeightIndices 0 widths 1 +local notation "pathLaw" => allocatedOriginalPathLaw B U b hb o hR hσ S (Fin nX) poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal + +variable {M : ℕ} (hM : 0 < M) (selection : Fin (s + 2) ↪ G) +variable {Kcov : Fin m → Type} [∀ j, Fintype (Kcov j)] +variable (bW : ∀ j, Basis (Kcov j) ℤ + (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))) +variable (pI p0 pAccuracy w v E0 Dcap O pc gc Pτ : ℝ) + +variable (family : ∀ x : {x : G → IntegerScalarCubeBox (Fin (s + 2)) S.value // GoodScalarKernelTuple selection (1 / (M : ℝ)) M x}, ∀ base : Fin nX → ℤ, + AllocatedCoarseSourceData (Kcov := Kcov) B U b S stride N x.val hM selection x.property τ base + pI p0 pAccuracy w v E0 Dcap O pc gc Pτ (selectedJointDensityMass bases stride cells (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) (allocatedJointBaseDensity B U b hb o hR hσ S (Fin nX) poly hmem))) + +theorem allocatedOriginalPathLaw_niltest_native_detection + (P : Polynomial ℕ) + {T : Type} [Fintype T] [Nonempty T] + (e : T → LayerSamplerVariables G I n B → ℤ) (he : Function.Injective e) + (hcover : ∀ t ∈ integerBox sides, ∃ u, e u = t) + {Tests : Path → Type} [∀ z, Nonempty (Tests z)] + {L : ∀ z, Tests z → Type} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dims : ∀ z, Tests z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] + [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) (s + 1) (dims z j)) + (V : ∀ z j, (D z j).Niltest (fun _ : LayerSamplerVariables G I n B => 1)) + (slices : ∀ z, Tests z → Finset T) + (c : ∀ z, Tests z → LayerSamplerVariables G I n B → ℤ) + (step : ∀ z, Tests z → ℕ) + (H : ∀ z, Tests z → LayerSamplerVariables G I n B → ℕ) + (hstep : ∀ z j, 0 < step z j) + (hslices : ∀ z j, (slices z j).image e = commonStrideBox (c z j) (step z j) (H z j)) + (p q : ℝ) (hp : 0 ≤ p) (hq : 0 ≤ q) + (hdense : ∀ z j, IsDenseCommonStrideBox sides p ((slices z j).image e)) + (hdimension : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q) + (hcomplexity : ∀ z j, (V z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) + (hcap : ∀ z j, ((V z j).normBound : ℝ) ≤ 1) + (f : ((Fin nX) → ℤ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) + (α : ℝ) (hα : 0 < α) (hαone : α ≤ 1) + (hmesh : Fintype.card (LayerSamplerVariables G I n B) * Real.exp (-p) ≤ α / 8) + (hthreshold : Real.exp (-q) ≤ α / 4) + (hdetected : α ≤ sampledSliceSeminorm (pathLaw) + (fun z t => jointIntegerPhysicalSite (e t) (z.1.val, z.2.val)) slices + (fun z j t => star ((V z j).eval (commonStrideIndex (c z j) (step z j) (e t)))) f) + {budget E η : ℝ} (hbudget : 0 ≤ budget) (hnX : (nX : ℝ) ≤ budget) + (hcost : allocatedCoarseNativeLog m (s + 2) pI p0 pAccuracy w v E0 Dcap O pc gc Pτ ≤ budget) + (hdetectBudget : (p + q + sampledFullboxDetectionConstant s P) ^ + sampledFullboxDetectionConstant s P + 1 ≤ budget) + (hE : (p + q + sampledFullboxDetectionConstant s P) ^ + sampledFullboxDetectionConstant s P + 5 ≤ E) + (hη : η ≤ Real.exp (-((p + q + sampledFullboxDetectionConstant s P) ^ + sampledFullboxDetectionConstant s P + 5))) + (hcomparison : + ‖(pathLaw).complexMean (fun z => + 𝔼 cube : SupportedCube (s + 2) (integerBox sides : Set (LayerSamplerVariables G I n B → ℤ)), + physicalCubeSiteTest (integerSelfSiteTest (s + 2) f) + (physicalCubeRootDifferences cube.val.2 cube.val.1 z.1.val z.2.val)) - + (kernelLaw).goodPartBaseMean bases (GoodScalarKernelTuple selection (1 / (M : ℝ)) M) + (fun x hx base => (family ⟨x, hx⟩ base).source hb o bW cells poly hmem widths f)‖ ≤ + 2 * Real.exp (-E) + η) : + ∃ (x : {x : G → IntegerScalarCubeBox (Fin (s + 2)) S.value // GoodScalarKernelTuple selection (1 / (M : ℝ)) M x}) (base : Fin nX → ℤ), base ∈ bases ∧ + ∃ ψ ∈ (family x base).twists hb o bW cells poly hmem, ∃ g : integerBox N → ℂ, + Nonempty (NativeSampleModel (fun _ : Fin nX => 1) (s + 1) + ((budget + 2) ^ Classical.choose (exists_native_partner_of_physical_cube_mixture_all_degrees.{0} (s + 1))) + (fun u : integerBox N => u.val) g) ∧ + Real.exp (-((budget + 2) ^ Classical.choose + (exists_native_partner_of_physical_cube_mixture_all_degrees.{0} (s + 1)))) ≤ + ‖(FiniteProbabilityWeights.uniformFinset (integerBox N) + (by let : ∀ i, NeZero (N i) := fun i => ⟨(hN i).ne'⟩; exact integerBox_nonempty N)).correlation + (fun u => f u.val) (fun u => star (ψ u) * g u)‖ := by + let : ∀ i, NeZero (N i) := fun i => ⟨(hN i).ne'⟩ + obtain ⟨x, hx, base, _, hbase, hpositive⟩ := + allocatedOriginalPathLaw_niltest_selection B U b hb o hR hσ S (Fin nX) poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal P e he hcover D V slices c step H + hstep hslices p q hp hq hdense hdimension hcomplexity hcap f hf α hα hαone hmesh hthreshold + hdetected (GoodScalarKernelTuple selection (1 / (M : ℝ)) M) (fun x hx base => (family ⟨x, hx⟩ base).source hb o bW cells poly hmem widths f) + hE hη hcomparison + have hsource : Real.exp (-budget) ≤ + ((family ⟨x, hx⟩ base).source hb o bW cells poly hmem widths f).re := + (Real.exp_le_exp.mpr (neg_le_neg hdetectBudget)).trans hpositive + obtain ⟨ψ, hψ, g, hg, hcorrelation⟩ := + (family ⟨x, hx⟩ base).detect hb o bW cells poly hmem hbudget hnX hcost htotal widths + (narrowTrimmedSpatialWidths_pos hW hτ hξ N hN) hmass f (fun u _ => hf u) hsource + exact ⟨⟨x, hx⟩, base, hbase, ψ, hψ, g, hg, hcorrelation⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestSourceSelection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestSourceSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..6741ea0c09a9c0eccf50b9cf8bc6fa0fdb12af67 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestSourceSelection.lean @@ -0,0 +1,615 @@ +import OAI.Combinatorics.Progressions.Dynamics.SampledFullboxDetectionBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedOriginalCubeSelection +import OAI.Combinatorics.Progressions.Estimates.CommonStrideCorrelation +import OAI.Combinatorics.Progressions.Estimates.SourceDetectionError +import OAI.Combinatorics.Progressions.Geometry.SampledDenseCommonBox +import OAI.Combinatorics.Progressions.Polynomial.PolynomialBoxDetection + +namespace OAI + +universe u v w w₁ w₂ w₃ w₄ + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +theorem exists_nested_box_niltest_detection (s : ℕ) (P : Polynomial ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {I : Type v} [Fintype I] [DecidableEq I] {L : Type u} [LieRing L] [LieAlgebra ℚ L] {dim : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s dim) (p : ℝ), 0 ≤ p → + (Fintype.card I : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) p → + ∀ (T : D.Niltest (fun _ : I => 1)), T.ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) p) → + ∀ (c b : I → ℤ) (m d : ℕ) (H K : I → ℕ), 0 < m → 0 < d → (∀ i, 0 < K i) → + commonStrideBox b d K ⊆ commonStrideBox c m H → + ∀ f : (I → ℤ) → ℂ, (∀ x ∈ commonStrideBox b d K, ‖f x‖ ≤ 1) → + Real.exp (-p) ≤ ‖finiteCorrelation (commonStrideBox b d K) f + (fun y => T.eval (commonStrideIndex c m y))‖ → + Real.exp (-((p + C) ^ C)) ≤ finiteSupportGowersNorm (s + 1) (integerBox K) + (fun x => f (commonStridePoint b d x)) := by + obtain ⟨C, hC, hdetect⟩ := exists_polynomial_box_detection s P + refine ⟨C, hC, ?_⟩ + intro I _ _ L _ _ dim _ _ _ _ D p hp hI T hT c b m d H K hm hd hK hsub f hf hcorr + obtain ⟨U, hU, heval⟩ := T.exists_nested_box_restriction c b hm hd H K hK hsub + let _ : ∀ i, NeZero (K i) := fun i => ⟨(hK i).ne'⟩ + have hzero : translatedIntegerBox (0 : I → ℤ) K = integerBox K := by + simp [translatedIntegerBox, translateSupport] + have hcorr' : Real.exp (-p) ≤ ‖finiteCorrelation (integerBox K) + (fun x => f (commonStridePoint b d x)) U.eval‖ := by + rw [finiteCorrelation_commonStrideBox b hd] at hcorr + have he : finiteCorrelation (integerBox K) (fun x => f (commonStridePoint b d x)) U.eval = + finiteCorrelation (integerBox K) (fun x => f (commonStridePoint b d x)) + (fun x => T.eval (commonStrideIndex c m (commonStridePoint b d x))) := by + apply Finset.expect_congr rfl + intro x hx + rw [heval x hx] + rwa [he] + have hn := hdetect D p hp hI (fun _ : I => 1) (fun _ => zero_lt_one) U ((hU _).mpr hT) + 0 K (fun x => f (commonStridePoint b d x)) + (fun x hx => hf _ (commonStridePoint_mem b d K (hzero ▸ hx))) (hzero.symm ▸ hcorr') + simpa only [hzero] using hn + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +theorem exists_finite_site_niltest_detection (s : ℕ) (P : Polynomial ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {I : Type v} [Fintype I] [DecidableEq I] {L : Type u} [LieRing L] [LieAlgebra ℚ L] {dim : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s dim) (p : ℝ), 0 ≤ p → + (Fintype.card I : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) p → + ∀ (U : D.Niltest (fun _ : I => 1)), U.ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) p) → + ∀ {T : Type w} [Nonempty T] [DecidableEq T] (e : T → I → ℤ), Function.Injective e → + ∀ (A S : Finset T) (c b : I → ℤ) (m d : ℕ) (H K : I → ℕ), + 0 < m → 0 < d → (∀ i, 0 < K i) → A ⊆ S → + S.image e = commonStrideBox c m H → A.image e = commonStrideBox b d K → + ∀ (f w : T → ℂ), (∀ t, ‖f t‖ ≤ 1) → + (∀ t ∈ S, w t = star (U.eval (commonStrideIndex c m (e t)))) → + Real.exp (-p) ≤ ‖𝔼 t ∈ A, f t * w t‖ → + Real.exp (-((p + C) ^ C)) ≤ finiteSupportGowersNorm (s + 1) (integerBox K) + (fun x => finiteSiteExtension e f (commonStridePoint b d x)) := by + obtain ⟨C, hC, hdetect⟩ := exists_nested_box_niltest_detection s P + refine ⟨C, hC, ?_⟩ + intro I _ _ L _ _ dim _ _ _ _ D p hp hI U hU T _ _ e he A S c b m d H K hm hd hK hAS hS hA f w hf hw hc + have hsub : commonStrideBox b d K ⊆ commonStrideBox c m H := by + rw [← hA, ← hS] + exact Finset.image_subset_image hAS + have heq := finiteSiteExtension_test_mean e he A f w + (fun y => U.eval (commonStrideIndex c m y)) (fun t ht => hw t (hAS ht)) + rw [heq, hA] at hc + exact hdetect D p hp hI U hU c b m d H K hm hd hK hsub (finiteSiteExtension e f) + (fun x _ => finiteSiteExtension_norm_le e f hf x) hc + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +theorem exists_sampled_niltest_cube_detection (s : ℕ) (P : Polynomial ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {I : Type v} [Fintype I] [DecidableEq I] + {Ω : Type w₁} [Fintype Ω] [Nonempty Ω] {T : Type w₂} [Fintype T] [Nonempty T] + {X : Type w₃} {J : Ω → Type w₄} [∀ z, Nonempty (J z)] + {L : ∀ z, J z → Type u} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dim : ∀ z, J z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) s (dim z j)) + (U : ∀ z j, (D z j).Niltest (fun _ : I => 1)) + (μ : FiniteProbabilityWeights Ω) (F : Ω → T → X) + (S : ∀ z, J z → Finset T) (e : T → I → ℤ), Function.Injective e → + ∀ (c : ∀ z, J z → I → ℤ) (m : ∀ z, J z → ℕ) (H : ∀ z, J z → I → ℕ), + (∀ z j, 0 < m z j) → (∀ z j, (S z j).image e = commonStrideBox (c z j) (m z j) (H z j)) → + ∀ (p q : ℝ) (N : I → ℕ), 0 ≤ p → 0 ≤ q → + (∀ z j, IsDenseCommonStrideBox N p ((S z j).image e)) → + (Fintype.card I : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q → + (∀ z j, (U z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) → + (∀ z j, ((U z j).normBound : ℝ) ≤ 1) → + ∀ (v : X → ℂ) (α : ℝ), (∀ x, ‖v x‖ ≤ 1) → 0 < α → α ≤ 1 → + Fintype.card I * Real.exp (-p) ≤ α / 8 → Real.exp (-q) ≤ α / 4 → + α ≤ sampledSliceSeminorm μ F S + (fun z j t => star ((U z j).eval (commonStrideIndex (c z j) (m z j) (e t)))) v → + ∃ (b : I → ℤ) (d : ℕ) (K : I → ℕ), 0 < d ∧ (∀ i, 0 < K i) ∧ + IsDenseCommonStrideBox N (p + 1) (commonStrideBox b d K) ∧ + commonStrideBox b d K ⊆ Finset.univ.image e ∧ + (Real.exp (-((5 * p + 20) * Fintype.card I + p + 2)) * (α / 2)) * + Real.exp (-((q + C) ^ C)) ^ (2 ^ (s + 1)) ≤ + (μ.complexMean (fun z => normalizedSupportedCubeSum (s + 1) (integerBox K) + (fun _ x => finiteSiteExtension e (fun t => v (F z t)) (commonStridePoint b d x)))).re := by + obtain ⟨C, hC, hdetect⟩ := exists_finite_site_niltest_detection s P + refine ⟨C, hC, ?_⟩ + intro I _ _ Ω _ _ T _ _ X J _ L _ _ dim _ _ _ _ D U μ F S e he c m H hm hS p q N hp hq + hslice hI hU hcap v α hv hα hαone hmesh hthreshold hmean + let w : ∀ z, J z → T → ℂ := fun z j t => + star ((U z j).eval (commonStrideIndex (c z j) (m z j) (e t))) + have hw (z) (j) (t) : ‖w z j t‖ ≤ 1 := by + simpa only [w, norm_star] using + ((U z j).norm_eval_le (commonStrideIndex (c z j) (m z j) (e t))).trans (hcap z j) + obtain ⟨A, hAn, hAdense, G, j, hmass, hcorr⟩ := + exists_dense_common_sampled_box_of_seminorm μ F S w e he hp N hslice hw v hv hα hαone hmesh hmean + have hDense := hAdense + obtain ⟨b, d, K, hd, hK, _, _, hA⟩ := hAdense + have hnorm (z : Ω) (hz : z ∈ G) : + Real.exp (-((q + C) ^ C)) ≤ finiteSupportGowersNorm (s + 1) (integerBox K) + (fun x => finiteSiteExtension e (fun t => v (F z t)) (commonStridePoint b d x)) := by + exact hdetect (D z (j z)) q hq hI (U z (j z)) (hU z (j z)) e he A (S z (j z)) + (c z (j z)) b (m z (j z)) d (H z (j z)) K (hm z (j z)) hd hK + (hcorr z hz).1 (hS z (j z)) hA (fun t => v (F z t)) (w z (j z)) + (fun t => hv _) (fun _ _ => rfl) (hthreshold.trans (hcorr z hz).2) + refine ⟨b, d, K, hd, hK, ?_, ?_, ?_⟩ + · rw [← hA] + exact hDense + · rw [← hA] + exact Finset.image_subset_image (Finset.subset_univ A) + · let _ : ∀ i, NeZero (K i) := fun i => ⟨(hK i).ne'⟩ + exact sampled_normalized_cube_lower_bound (boxReduction_reflectsPairSums K) μ G s + (fun z x => finiteSiteExtension e (fun t => v (F z t)) (commonStridePoint b d x)) + (Real.exp_nonneg _) hmass hnorm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +theorem exists_sampled_niltest_cube_detection_with_sides (s : ℕ) (P : Polynomial ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {I : Type v} [Fintype I] [DecidableEq I] + {Ω : Type w₁} [Fintype Ω] [Nonempty Ω] {T : Type w₂} [Fintype T] [Nonempty T] + {X : Type w₃} {J : Ω → Type w₄} [∀ z, Nonempty (J z)] + {L : ∀ z, J z → Type u} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dim : ∀ z, J z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) s (dim z j)) + (U : ∀ z j, (D z j).Niltest (fun _ : I => 1)) + (μ : FiniteProbabilityWeights Ω) (F : Ω → T → X) + (S : ∀ z, J z → Finset T) (e : T → I → ℤ), Function.Injective e → + ∀ (c : ∀ z, J z → I → ℤ) (m : ∀ z, J z → ℕ) (H : ∀ z, J z → I → ℕ), + (∀ z j, 0 < m z j) → (∀ z j, (S z j).image e = commonStrideBox (c z j) (m z j) (H z j)) → + ∀ (p q : ℝ) (N : I → ℕ), 0 ≤ p → 0 ≤ q → + (∀ z j, IsDenseCommonStrideBox N p ((S z j).image e)) → + (Fintype.card I : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q → + (∀ z j, (U z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) → + (∀ z j, ((U z j).normBound : ℝ) ≤ 1) → + ∀ (v : X → ℂ) (α : ℝ), (∀ x, ‖v x‖ ≤ 1) → 0 < α → α ≤ 1 → + Fintype.card I * Real.exp (-p) ≤ α / 8 → Real.exp (-q) ≤ α / 4 → + α ≤ sampledSliceSeminorm μ F S + (fun z j t => star ((U z j).eval (commonStrideIndex (c z j) (m z j) (e t)))) v → + ∃ (b : I → ℤ) (d : ℕ) (K : I → ℕ), 0 < d ∧ (∀ i, 0 < K i) ∧ + (∀ i, integerProgressionSupport (b i) (d : ℤ) (K i) ⊆ Finset.Ico (0 : ℤ) (N i : ℤ)) ∧ + (∀ i, Real.exp (-(p + 1)) * N i ≤ (K i : ℝ)) ∧ + IsDenseCommonStrideBox N (p + 1) (commonStrideBox b d K) ∧ + commonStrideBox b d K ⊆ Finset.univ.image e ∧ + (Real.exp (-((5 * p + 20) * Fintype.card I + p + 2)) * (α / 2)) * + Real.exp (-((q + C) ^ C)) ^ (2 ^ (s + 1)) ≤ + (μ.complexMean (fun z => normalizedSupportedCubeSum (s + 1) (integerBox K) + (fun _ x => finiteSiteExtension e (fun t => v (F z t)) (commonStridePoint b d x)))).re := by + obtain ⟨C, hC, hdetect⟩ := exists_finite_site_niltest_detection s P + refine ⟨C, hC, ?_⟩ + intro I _ _ Ω _ _ T _ _ X J _ L _ _ dim _ _ _ _ D U μ F S e he c m H hm hS p q N hp hq + hslice hI hU hcap v α hv hα hαone hmesh hthreshold hmean + let w : ∀ z, J z → T → ℂ := fun z j t => + star ((U z j).eval (commonStrideIndex (c z j) (m z j) (e t))) + have hw (z) (j) (t) : ‖w z j t‖ ≤ 1 := by + simpa only [w, norm_star] using + ((U z j).norm_eval_le (commonStrideIndex (c z j) (m z j) (e t))).trans (hcap z j) + obtain ⟨A, hAn, hAdense, G, j, hmass, hcorr⟩ := + exists_dense_common_sampled_box_of_seminorm μ F S w e he hp N hslice hw v hv hα hαone hmesh hmean + have hDense := hAdense + obtain ⟨b, d, K, hd, hK, hsubsetK, hdenseK, hA⟩ := hAdense + have hnorm (z : Ω) (hz : z ∈ G) : + Real.exp (-((q + C) ^ C)) ≤ finiteSupportGowersNorm (s + 1) (integerBox K) + (fun x => finiteSiteExtension e (fun t => v (F z t)) (commonStridePoint b d x)) := by + exact hdetect (D z (j z)) q hq hI (U z (j z)) (hU z (j z)) e he A (S z (j z)) + (c z (j z)) b (m z (j z)) d (H z (j z)) K (hm z (j z)) hd hK + (hcorr z hz).1 (hS z (j z)) hA (fun t => v (F z t)) (w z (j z)) + (fun t => hv _) (fun _ _ => rfl) (hthreshold.trans (hcorr z hz).2) + refine ⟨b, d, K, hd, hK, hsubsetK, hdenseK, ?_, ?_, ?_⟩ + · rw [← hA] + exact hDense + · rw [← hA] + exact Finset.image_subset_image (Finset.subset_univ A) + · let _ : ∀ i, NeZero (K i) := fun i => ⟨(hK i).ne'⟩ + exact sampled_normalized_cube_lower_bound (boxReduction_reflectsPairSums K) μ G s + (fun z x => finiteSiteExtension e (fun t => v (F z t)) (commonStridePoint b d x)) + (Real.exp_nonneg _) hmass hnorm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +theorem exists_sampled_niltest_fullbox_detection (s : ℕ) (P : Polynomial ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {I : Type v} [Fintype I] [DecidableEq I] + {Ω : Type w₁} [Fintype Ω] [Nonempty Ω] {T : Type w₂} [Fintype T] [Nonempty T] + {X : Type w₃} {J : Ω → Type w₄} [∀ z, Nonempty (J z)] + {L : ∀ z, J z → Type u} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dim : ∀ z, J z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) (s + 1) (dim z j)) + (U : ∀ z j, (D z j).Niltest (fun _ : I => 1)) + (μ : FiniteProbabilityWeights Ω) (F : Ω → T → X) + (S : ∀ z, J z → Finset T) (e : T → I → ℤ), Function.Injective e → + ∀ (c : ∀ z, J z → I → ℤ) (m : ∀ z, J z → ℕ) (H : ∀ z, J z → I → ℕ), + (∀ z j, 0 < m z j) → (∀ z j, (S z j).image e = commonStrideBox (c z j) (m z j) (H z j)) → + ∀ (p q : ℝ) (N : I → ℕ), 0 ≤ p → 0 ≤ q → (∀ i, 0 < N i) → + (∀ z j, IsDenseCommonStrideBox N p ((S z j).image e)) → + (Fintype.card I : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q → + (∀ z j, (U z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) → + (∀ z j, ((U z j).normBound : ℝ) ≤ 1) → + ∀ (v : X → ℂ) (α : ℝ), (∀ x, ‖v x‖ ≤ 1) → 0 < α → α ≤ 1 → + Fintype.card I * Real.exp (-p) ≤ α / 8 → Real.exp (-q) ≤ α / 4 → + α ≤ sampledSliceSeminorm μ F S + (fun z j t => star ((U z j).eval (commonStrideIndex (c z j) (m z j) (e t)))) v → + (Real.exp (-((5 * p + 20) * Fintype.card I + p + 2)) * (α / 2)) * + Real.exp (-denseBoxGowersTransferCost s (Fintype.card I) (p + 1) ((q + C) ^ C)) ^ + (2 ^ (s + 2)) ≤ + (μ.complexMean (fun z => normalizedSupportedCubeSum (s + 2) (integerBox N) + (fun _ x => finiteSiteExtension e (fun t => v (F z t)) x))).re := by + obtain ⟨C, hC, hdetect⟩ := exists_finite_site_niltest_detection (s + 1) P + refine ⟨C, hC, ?_⟩ + intro I _ _ Ω _ _ T _ _ X J _ L _ _ dim _ _ _ _ D U μ F S e he c m H hm hS p q N hp hq + hN hslice hI hU hcap v α hv hα hαone hmesh hthreshold hmean + let w : ∀ z, J z → T → ℂ := fun z j t => + star ((U z j).eval (commonStrideIndex (c z j) (m z j) (e t))) + have hw (z) (j) (t) : ‖w z j t‖ ≤ 1 := by + simpa only [w, norm_star] using + ((U z j).norm_eval_le (commonStrideIndex (c z j) (m z j) (e t))).trans (hcap z j) + obtain ⟨A, hAn, hAdense, G, j, hmass, hcorr⟩ := + exists_dense_common_sampled_box_of_seminorm μ F S w e he hp N hslice hw v hv hα hαone hmesh hmean + have hDense := hAdense + obtain ⟨b, d, K, hd, hK, _, _, hA⟩ := hAdense + let : ∀ i, NeZero (N i) := fun i => ⟨(hN i).ne'⟩ + have hnorm (z : Ω) (hz : z ∈ G) : + Real.exp (-denseBoxGowersTransferCost s (Fintype.card I) (p + 1) ((q + C) ^ C)) ≤ + finiteSupportGowersNorm (s + 2) (integerBox N) + (fun x => finiteSiteExtension e (fun t => v (F z t)) x) := by + have hlocal : Real.exp (-((q + C) ^ C)) ≤ finiteSupportGowersNorm (s + 2) (integerBox K) + (fun x => finiteSiteExtension e (fun t => v (F z t)) (commonStridePoint b d x)) := + hdetect (D z (j z)) q hq hI (U z (j z)) (hU z (j z)) e he A (S z (j z)) + (c z (j z)) b (m z (j z)) d (H z (j z)) K (hm z (j z)) hd hK + (hcorr z hz).1 (hS z (j z)) hA (fun t => v (F z t)) (w z (j z)) + (fun t => hv _) (fun _ _ => rfl) (hthreshold.trans (hcorr z hz).2) + have hdense : IsDenseCommonStrideBox N (p + 1) (commonStrideBox b d K) := by + rw [← hA] + exact hDense + have hlocal' : Real.exp (-((q + C) ^ C)) ≤ + finiteSupportGowersNorm (s + 2) (commonStrideBox b d K) + (finiteSiteExtension e (fun t => v (F z t))) := by + rwa [finiteSupportGowersNorm_commonStride (s + 2) b hd K] + exact denseBox_gowers_transfer s N (by linarith) (by positivity) hdense + (finiteSiteExtension e (fun t => v (F z t))) + (fun x _ => finiteSiteExtension_norm_le e _ (fun t => hv _) x) hlocal' + exact sampled_normalized_cube_lower_bound (boxReduction_reflectsPairSums N) μ G (s + 1) + (fun z x => finiteSiteExtension e (fun t => v (F z t)) x) (Real.exp_nonneg _) hmass hnorm + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +theorem exists_sampled_niltest_fullbox_detection_uniform (s : ℕ) (P : Polynomial ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {I : Type v} [Fintype I] [DecidableEq I] + {Ω : Type w₁} [Fintype Ω] [Nonempty Ω] {T : Type w₂} [Fintype T] [Nonempty T] + {X : Type w₃} {J : Ω → Type w₄} [∀ z, Nonempty (J z)] + {L : ∀ z, J z → Type u} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dim : ∀ z, J z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) (s + 1) (dim z j)) + (U : ∀ z j, (D z j).Niltest (fun _ : I => 1)) + (μ : FiniteProbabilityWeights Ω) (F : Ω → T → X) + (S : ∀ z, J z → Finset T) (e : T → I → ℤ), Function.Injective e → + ∀ (c : ∀ z, J z → I → ℤ) (m : ∀ z, J z → ℕ) (H : ∀ z, J z → I → ℕ), + (∀ z j, 0 < m z j) → (∀ z j, (S z j).image e = commonStrideBox (c z j) (m z j) (H z j)) → + ∀ (p q : ℝ) (N : I → ℕ), 0 ≤ p → 0 ≤ q → (∀ i, 0 < N i) → + (∀ z j, IsDenseCommonStrideBox N p ((S z j).image e)) → + (Fintype.card I : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q → + (∀ z j, (U z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) → + (∀ z j, ((U z j).normBound : ℝ) ≤ 1) → + ∀ (v : X → ℂ) (α : ℝ), (∀ x, ‖v x‖ ≤ 1) → 0 < α → α ≤ 1 → + Fintype.card I * Real.exp (-p) ≤ α / 8 → Real.exp (-q) ≤ α / 4 → + α ≤ sampledSliceSeminorm μ F S + (fun z j t => star ((U z j).eval (commonStrideIndex (c z j) (m z j) (e t)))) v → + Real.exp (-((p + q + C) ^ C)) ≤ + (μ.complexMean (fun z => normalizedSupportedCubeSum (s + 2) (integerBox N) + (fun _ x => finiteSiteExtension e (fun t => v (F z t)) x))).re := by + obtain ⟨C₀, hC₀, hdetect⟩ := exists_sampled_niltest_fullbox_detection s P + obtain ⟨C, hC, hbudget⟩ := exists_sampledFullboxDetection_budget s C₀ P + refine ⟨C, hC, ?_⟩ + intro I _ _ Ω _ _ T _ _ X J _ L _ _ dim _ _ _ _ D U μ F S e he c m H hm hS p q N hp hq + hN hslice hI hU hcap v α hv hα hαone hmesh hthreshold hmean + have hwhole := hdetect D U μ F S e he c m H hm hS p q N hp hq hN hslice hI hU hcap + v α hv hα hαone hmesh hthreshold hmean + have hcost := hbudget p q (Fintype.card I) hp hq hI + exact (Real.exp_le_exp.mpr (neg_le_neg hcost)).trans + ((sampledFullboxDetection_exp_lower s C₀ (Fintype.card I) p q α hthreshold).trans hwhole) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def sampledSlicedDetectionConstant (s : ℕ) (P : Polynomial ℕ) : ℕ := + Classical.choose (exists_sampled_niltest_cube_detection.{0,0,0,0,0,0} s P) + +theorem sampledSlicedDetectionConstant_two_le (s : ℕ) (P : Polynomial ℕ) : + 2 ≤ sampledSlicedDetectionConstant s P := + (Classical.choose_spec (exists_sampled_niltest_cube_detection.{0,0,0,0,0,0} s P)).1 + +end Erdos3 + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G : Type} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {s : ℕ} (X : Type) [Fintype X] +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +variable (N : X → ℕ) (hN : ∀ t, 0 < N t) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (stride : X → ℕ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + +local notation "widths" => narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (bases : Finset (X → ℤ)) (hbases : bases.Nonempty) +variable (htotal : 0 < selectedJointDensityMass bases stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem)) + +local notation "sides" => Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U b S) +local notation "kernelLaw" => FiniteProbabilityWeights.pi + (fun _ : G => integerScalarCubeWeights (Fin (s + 2)) S.value S.positive) + +local notation "Path" => bases × rectangularWeightIndices 0 widths 1 +local notation "pathLaw" => allocatedOriginalPathLaw B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal + +theorem allocatedOriginalPathLaw_niltest_sliced_detection + (P : Polynomial ℕ) + {T : Type} [Fintype T] [Nonempty T] + (e : T → LayerSamplerVariables G I n B → ℤ) (he : Function.Injective e) + {Tests : Path → Type} [∀ z, Nonempty (Tests z)] + {L : ∀ z, Tests z → Type} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dims : ∀ z, Tests z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] + [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) s (dims z j)) + (V : ∀ z j, (D z j).Niltest (fun _ : LayerSamplerVariables G I n B => 1)) + (slices : ∀ z, Tests z → Finset T) + (c : ∀ z, Tests z → LayerSamplerVariables G I n B → ℤ) + (step : ∀ z, Tests z → ℕ) + (H : ∀ z, Tests z → LayerSamplerVariables G I n B → ℕ) + (hstep : ∀ z j, 0 < step z j) + (hslices : ∀ z j, (slices z j).image e = commonStrideBox (c z j) (step z j) (H z j)) + (p q : ℝ) (hp : 0 ≤ p) (hq : 0 ≤ q) + (hdense : ∀ z j, IsDenseCommonStrideBox sides p ((slices z j).image e)) + (hdimension : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q) + (hcomplexity : ∀ z j, (V z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) + (hcap : ∀ z j, ((V z j).normBound : ℝ) ≤ 1) + (f : (X → ℤ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) + (α : ℝ) (hα : 0 < α) (hαone : α ≤ 1) + (hmesh : Fintype.card (LayerSamplerVariables G I n B) * Real.exp (-p) ≤ α / 8) + (hthreshold : Real.exp (-q) ≤ α / 4) + (hdetected : α ≤ sampledSliceSeminorm (pathLaw) + (fun z t => jointIntegerPhysicalSite (e t) (z.1.val, z.2.val)) slices + (fun z j t => star ((V z j).eval (commonStrideIndex (c z j) (step z j) (e t)))) f) : + ∃ (c₀ : LayerSamplerVariables G I n B → ℤ) (step₀ : ℕ) + (H₀ : LayerSamplerVariables G I n B → ℕ) (_hstep₀ : 0 < step₀) (hH₀ : ∀ k, 0 < H₀ k), + IsDenseCommonStrideBox sides (p + 1) (commonStrideBox c₀ step₀ H₀) ∧ + commonStrideBox c₀ step₀ H₀ ⊆ Finset.univ.image e ∧ + (Real.exp (-((5 * p + 20) * Fintype.card (LayerSamplerVariables G I n B) + p + 2)) * (α / 2)) * + Real.exp (-((q + sampledSlicedDetectionConstant s P) ^ sampledSlicedDetectionConstant s P)) ^ + (2 ^ (s + 1)) ≤ + (allocatedSlicedCubeSource (dim := s + 1) B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases H₀ hH₀ c₀ step₀ f).re := by + obtain ⟨z, _⟩ := (pathLaw).exists_weight_pos + let : Nonempty Path := ⟨z⟩ + obtain ⟨c₀, step₀, H₀, hstep₀, hH₀, hdense₀, hcover₀, hcube⟩ := + (Classical.choose_spec (exists_sampled_niltest_cube_detection.{0,0,0,0,0,0} s P)).2 + D V (pathLaw) (fun z t => jointIntegerPhysicalSite (e t) (z.1.val, z.2.val)) + slices e he c step H hstep hslices p q sides hp hq hdense hdimension hcomplexity hcap + f α hf hα hαone hmesh hthreshold hdetected + have hcover' (t) (ht : t ∈ integerBox H₀) : ∃ u, e u = commonStridePoint c₀ step₀ t := by + obtain ⟨u, _, hu⟩ := Finset.mem_image.mp (hcover₀ (commonStridePoint_mem c₀ step₀ H₀ ht)) + exact ⟨u, hu⟩ + have hext (z : Path) : + normalizedSupportedCubeSum (s + 1) (integerBox H₀) + (fun _ t => finiteSiteExtension e + (fun u => f (jointIntegerPhysicalSite (e u) (z.1.val, z.2.val))) (commonStridePoint c₀ step₀ t)) = + normalizedSupportedCubeSum (s + 1) (integerBox H₀) + (fun _ t => f (jointIntegerPhysicalSite (commonStridePoint c₀ step₀ t) (z.1.val, z.2.val))) := by + exact normalizedSupportedCubeSum_finiteSiteExtension_on_map (s + 1) (integerBox H₀) + e he (commonStridePoint c₀ step₀) hcover' + (fun t => f (jointIntegerPhysicalSite t (z.1.val, z.2.val))) + simp only [hext] at hcube + rw [allocatedOriginalPathLaw_sliced_cube_source B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal H₀ hH₀ c₀ step₀ f] at hcube + exact ⟨c₀, step₀, H₀, hstep₀, hH₀, hdense₀, hcover₀, hcube⟩ + +end Erdos3.VectorPolynomial + +end + +section + +namespace Erdos3 + +noncomputable def sampledFullboxDetectionConstant (s : ℕ) (P : Polynomial ℕ) : ℕ := + Classical.choose (exists_sampled_niltest_fullbox_detection_uniform.{0,0,0,0,0,0} s P) + +theorem sampledFullboxDetectionConstant_two_le (s : ℕ) (P : Polynomial ℕ) : + 2 ≤ sampledFullboxDetectionConstant s P := + (Classical.choose_spec (exists_sampled_niltest_fullbox_detection_uniform.{0,0,0,0,0,0} s P)).1 + +end Erdos3 + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G : Type} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {s : ℕ} (X : Type) [Fintype X] +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +variable (N : X → ℕ) (hN : ∀ t, 0 < N t) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (stride : X → ℕ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + +local notation "widths" => narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (bases : Finset (X → ℤ)) (hbases : bases.Nonempty) +variable (htotal : 0 < selectedJointDensityMass bases stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem)) + +local notation "sides" => Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U b S) +local notation "kernelLaw" => FiniteProbabilityWeights.pi + (fun _ : G => integerScalarCubeWeights (Fin (s + 2)) S.value S.positive) + +local notation "Path" => bases × rectangularWeightIndices 0 widths 1 +local notation "pathLaw" => allocatedOriginalPathLaw B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal + +theorem allocatedOriginalPathLaw_niltest_selection + (P : Polynomial ℕ) + {T : Type} [Fintype T] [Nonempty T] + (e : T → LayerSamplerVariables G I n B → ℤ) (he : Function.Injective e) + (hcover : ∀ t ∈ integerBox sides, ∃ u, e u = t) + {Tests : Path → Type} [∀ z, Nonempty (Tests z)] + {L : ∀ z, Tests z → Type} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dims : ∀ z, Tests z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] + [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) (s + 1) (dims z j)) + (V : ∀ z j, (D z j).Niltest (fun _ : LayerSamplerVariables G I n B => 1)) + (slices : ∀ z, Tests z → Finset T) + (c : ∀ z, Tests z → LayerSamplerVariables G I n B → ℤ) + (step : ∀ z, Tests z → ℕ) + (H : ∀ z, Tests z → LayerSamplerVariables G I n B → ℕ) + (hstep : ∀ z j, 0 < step z j) + (hslices : ∀ z j, (slices z j).image e = commonStrideBox (c z j) (step z j) (H z j)) + (p q : ℝ) (hp : 0 ≤ p) (hq : 0 ≤ q) + (hdense : ∀ z j, IsDenseCommonStrideBox sides p ((slices z j).image e)) + (hdimension : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q) + (hcomplexity : ∀ z j, (V z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) + (hcap : ∀ z j, ((V z j).normBound : ℝ) ≤ 1) + (f : (X → ℤ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) + (α : ℝ) (hα : 0 < α) (hαone : α ≤ 1) + (hmesh : Fintype.card (LayerSamplerVariables G I n B) * Real.exp (-p) ≤ α / 8) + (hthreshold : Real.exp (-q) ≤ α / 4) + (hdetected : α ≤ sampledSliceSeminorm (pathLaw) + (fun z t => jointIntegerPhysicalSite (e t) (z.1.val, z.2.val)) slices + (fun z j t => star ((V z j).eval (commonStrideIndex (c z j) (step z j) (e t)))) f) + (Good : (G → IntegerScalarCubeBox (Fin (s + 2)) S.value) → Prop) + (genuine : ∀ x, Good x → (X → ℤ) → ℂ) + {E η : ℝ} + (hE : (p + q + sampledFullboxDetectionConstant s P) ^ + sampledFullboxDetectionConstant s P + 5 ≤ E) + (hη : η ≤ Real.exp (-((p + q + sampledFullboxDetectionConstant s P) ^ + sampledFullboxDetectionConstant s P + 5))) + (hcomparison : + ‖(pathLaw).complexMean (fun z => + 𝔼 cube : SupportedCube (s + 2) (integerBox sides : Set (LayerSamplerVariables G I n B → ℤ)), + physicalCubeSiteTest (integerSelfSiteTest (s + 2) f) + (physicalCubeRootDifferences cube.val.2 cube.val.1 z.1.val z.2.val)) - + (kernelLaw).goodPartBaseMean bases Good genuine‖ ≤ 2 * Real.exp (-E) + η) : + ∃ (x : G → IntegerScalarCubeBox (Fin (s + 2)) S.value) (hx : Good x) (base : X → ℤ), + 0 < (kernelLaw).weight x ∧ base ∈ bases ∧ + Real.exp (-((p + q + sampledFullboxDetectionConstant s P) ^ + sampledFullboxDetectionConstant s P + 1)) ≤ (genuine x hx base).re := by + obtain ⟨z, _⟩ := (pathLaw).exists_weight_pos + let : Nonempty Path := ⟨z⟩ + have hparam : ∀ i, 0 < sides i := by + intro i + cases i with + | inl g => exact S.positive + | inr i => exact allocatedPrincipalSides_pos B U b S i + have hcube := (Classical.choose_spec + (exists_sampled_niltest_fullbox_detection_uniform.{0,0,0,0,0,0} s P)).2 + D V (pathLaw) (fun z t => jointIntegerPhysicalSite (e t) (z.1.val, z.2.val)) + slices e he c step H hstep hslices p q sides hp hq hparam hdense hdimension hcomplexity hcap + f α hf hα hαone hmesh hthreshold hdetected + exact allocatedOriginalPathLaw_finite_self_cube_selection B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal e he hcover f Good genuine + (Real.exp_pos _) hcomparison ((sourceDetection_error_share hE hη).trans hcube) + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestSupportedSlicedDetection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestSupportedSlicedDetection.lean new file mode 100644 index 0000000000000000000000000000000000000000..02bd9f52ad9fd0942edcb4cf8c30890ee39bfc6b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedNiltestSupportedSlicedDetection.lean @@ -0,0 +1,131 @@ +import OAI.Combinatorics.Progressions.Nilpotent.AllocatedNiltestSourceSelection + +namespace OAI + +section + +namespace Erdos3 + +noncomputable def sampledSupportedSlicedDetectionConstant (s : ℕ) (P : Polynomial ℕ) : ℕ := + Classical.choose (exists_sampled_niltest_cube_detection_with_sides.{0,0,0,0,0,0} s P) + +theorem sampledSupportedSlicedDetectionConstant_two_le (s : ℕ) (P : Polynomial ℕ) : + 2 ≤ sampledSupportedSlicedDetectionConstant s P := + (Classical.choose_spec (exists_sampled_niltest_cube_detection_with_sides.{0,0,0,0,0,0} s P)).1 + +end Erdos3 + +namespace Erdos3.VectorPolynomial + +open Module Submodule MeasureTheory BooleanCubeKernel +open scoped BigOperators Classical TensorProduct + +variable {m : ℕ} {G : Type} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] [∀ j, DecidableEq (I j)] +variable {n : Fin m → ℕ} (B : LayerSamplerAxis I n → Type) +variable [∀ a, Fintype (B a)] [∀ a, DecidableEq (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] (U : ∀ j, Submodule ℝ (J j → ℝ)) +variable (b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ) +variable (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) +variable (o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))) +variable {R σ : Fin m → ℝ} (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) +variable (S : LayerSamplerScale (G := G) B U b R σ) +variable {s : ℕ} (X : Type) [Fintype X] +variable (poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)) +variable (hmem : ∀ j e, coefficients (poly j) e ∈ U j) + +variable [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + +variable (N : X → ℕ) (hN : ∀ t, 0 < N t) +variable {W τ ξ : ℝ} (hW : 0 ≤ W) (hτ : 0 < τ) (hξ : 0 < ξ) +variable (stride : X → ℕ) +variable (cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)) + +local notation "widths" => narrowTrimmedSpatialWidths (G := G) + (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N + +variable (hmass : 0 < ∑' z, selectedResidueSmoothWeight stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) z) +variable (bases : Finset (X → ℤ)) (hbases : bases.Nonempty) +variable (htotal : 0 < selectedJointDensityMass bases stride cells + (narrowTrimmedSpatialWidths (G := G) (J := PrincipalTupleIndex B (layerSamplerDegree I n)) W τ ξ N) + (allocatedJointBaseDensity B U b hb o hR hσ S X poly hmem)) + +local notation "sides" => Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U b S) +local notation "kernelLaw" => FiniteProbabilityWeights.pi + (fun _ : G => integerScalarCubeWeights (Fin (s + 2)) S.value S.positive) + +local notation "Path" => bases × rectangularWeightIndices 0 widths 1 +local notation "pathLaw" => allocatedOriginalPathLaw B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal + +theorem allocatedOriginalPathLaw_niltest_sliced_detection_with_sides + (P : Polynomial ℕ) + {T : Type} [Fintype T] [Nonempty T] + (e : T → LayerSamplerVariables G I n B → ℤ) (he : Function.Injective e) + {Tests : Path → Type} [∀ z, Nonempty (Tests z)] + {L : ∀ z, Tests z → Type} [∀ z j, LieRing (L z j)] [∀ z j, LieAlgebra ℚ (L z j)] + {dims : ∀ z, Tests z → ℕ} + [∀ z j, TopologicalSpace (ℝ ⊗[ℚ] L z j)] + [∀ z j, IsTopologicalAddGroup (ℝ ⊗[ℚ] L z j)] + [∀ z j, ContinuousSMul ℝ (ℝ ⊗[ℚ] L z j)] [∀ z j, T2Space (ℝ ⊗[ℚ] L z j)] + (D : ∀ z j, RationalFilteredNilmanifold (L z j) s (dims z j)) + (V : ∀ z j, (D z j).Niltest (fun _ : LayerSamplerVariables G I n B => 1)) + (slices : ∀ z, Tests z → Finset T) + (c : ∀ z, Tests z → LayerSamplerVariables G I n B → ℤ) + (step : ∀ z, Tests z → ℕ) + (H : ∀ z, Tests z → LayerSamplerVariables G I n B → ℕ) + (hstep : ∀ z j, 0 < step z j) + (hslices : ∀ z j, (slices z j).image e = commonStrideBox (c z j) (step z j) (H z j)) + (p q : ℝ) (hp : 0 ≤ p) (hq : 0 ≤ q) + (hdense : ∀ z j, IsDenseCommonStrideBox sides p ((slices z j).image e)) + (hdimension : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ P.eval₂ (Nat.castRingHom ℝ) q) + (hcomplexity : ∀ z j, (V z j).ComplexityLE (P.eval₂ (Nat.castRingHom ℝ) q)) + (hcap : ∀ z j, ((V z j).normBound : ℝ) ≤ 1) + (f : (X → ℤ) → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) + (α : ℝ) (hα : 0 < α) (hαone : α ≤ 1) + (hmesh : Fintype.card (LayerSamplerVariables G I n B) * Real.exp (-p) ≤ α / 8) + (hthreshold : Real.exp (-q) ≤ α / 4) + (hdetected : α ≤ sampledSliceSeminorm (pathLaw) + (fun z t => jointIntegerPhysicalSite (e t) (z.1.val, z.2.val)) slices + (fun z j t => star ((V z j).eval (commonStrideIndex (c z j) (step z j) (e t)))) f) : + ∃ (c₀ : LayerSamplerVariables G I n B → ℤ) (step₀ : ℕ) + (H₀ : LayerSamplerVariables G I n B → ℕ) (_hstep₀ : 0 < step₀) (hH₀ : ∀ k, 0 < H₀ k), + (∀ i, integerProgressionSupport (c₀ i) (step₀ : ℤ) (H₀ i) ⊆ Finset.Ico (0 : ℤ) (sides i : ℤ)) ∧ + (∀ i, Real.exp (-(p + 1)) * sides i ≤ (H₀ i : ℝ)) ∧ + IsDenseCommonStrideBox sides (p + 1) (commonStrideBox c₀ step₀ H₀) ∧ + commonStrideBox c₀ step₀ H₀ ⊆ Finset.univ.image e ∧ + (Real.exp (-((5 * p + 20) * Fintype.card (LayerSamplerVariables G I n B) + p + 2)) * (α / 2)) * + Real.exp (-((q + sampledSupportedSlicedDetectionConstant s P) ^ sampledSupportedSlicedDetectionConstant s P)) ^ + (2 ^ (s + 1)) ≤ + (allocatedSlicedCubeSource (dim := s + 1) B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases H₀ hH₀ c₀ step₀ f).re := by + obtain ⟨z, _⟩ := (pathLaw).exists_weight_pos + let : Nonempty Path := ⟨z⟩ + obtain ⟨c₀, step₀, H₀, hstep₀, hH₀, hsubset₀, hcounts₀, hdense₀, hcover₀, hcube⟩ := + (Classical.choose_spec (exists_sampled_niltest_cube_detection_with_sides.{0,0,0,0,0,0} s P)).2 + D V (pathLaw) (fun z t => jointIntegerPhysicalSite (e t) (z.1.val, z.2.val)) + slices e he c step H hstep hslices p q sides hp hq hdense hdimension hcomplexity hcap + f α hf hα hαone hmesh hthreshold hdetected + have hcover' (t) (ht : t ∈ integerBox H₀) : ∃ u, e u = commonStridePoint c₀ step₀ t := by + obtain ⟨u, _, hu⟩ := Finset.mem_image.mp (hcover₀ (commonStridePoint_mem c₀ step₀ H₀ ht)) + exact ⟨u, hu⟩ + have hext (z : Path) : + normalizedSupportedCubeSum (s + 1) (integerBox H₀) + (fun _ t => finiteSiteExtension e + (fun u => f (jointIntegerPhysicalSite (e u) (z.1.val, z.2.val))) (commonStridePoint c₀ step₀ t)) = + normalizedSupportedCubeSum (s + 1) (integerBox H₀) + (fun _ t => f (jointIntegerPhysicalSite (commonStridePoint c₀ step₀ t) (z.1.val, z.2.val))) := by + exact normalizedSupportedCubeSum_finiteSiteExtension_on_map (s + 1) (integerBox H₀) + e he (commonStridePoint c₀ step₀) hcover' + (fun t => f (jointIntegerPhysicalSite t (z.1.val, z.2.val))) + simp only [hext] at hcube + rw [allocatedOriginalPathLaw_sliced_cube_source B U b hb o hR hσ S X poly hmem + N hN hW hτ hξ stride cells hmass bases hbases htotal H₀ hH₀ c₀ step₀ f] at hcube + exact ⟨c₀, step₀, H₀, hstep₀, hH₀, hsubset₀, hcounts₀, hdense₀, hcover₀, hcube⟩ + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedOriginalDegreeQuotientBinNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedOriginalDegreeQuotientBinNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..565e44ff9c26282a96b019e09be470d74ad6b702 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedOriginalDegreeQuotientBinNiltest.lean @@ -0,0 +1,196 @@ +import OAI.Combinatorics.Progressions.Estimates.InheritedTaggedQuotientPrecenterMasks + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open Module Submodule BooleanCubeKernel NilpotentLieFiltration NilpotentLieBCHGroup +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type*} [Fintype G] [Fintype X] + {I E J : Fin m → Type*} [∀ j, Fintype (I j)] [∀ j, Fintype (J j)] + {n : Fin m → ℕ} {B : LayerSamplerAxis I n → Type*} [∀ a, Fintype (B a)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} + {hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + {A : AllocatedExternalCandidateSampler B U b S hb o hR hσ N poly hm τ ξ stride cells center} + +namespace AllocatedExternalLocalChart + +variable {cost : ℝ} (C : AllocatedExternalLocalChart (E := E) A cost) + {L M : Type} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s d f nD nF nQ : ℕ} + (D : RationalFilteredNilmanifold L (s + 1) d) + (W : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (Dref : RationalFilteredNilmanifold + (D.filtration.gradedRefiltrationSubalgebra W) (s + 1) nD) + (hDref : Dref.filtration = D.filtration.gradedRefiltration W) + (left right : D.filtration.realification.PolynomialOrbit + (fullTaggedVariableWeight (X := X) J)) + (middle : Dref.filtration.realification.PolynomialOrbit (fun _ : C.Variables => 1)) + +noncomputable def originalDegreeRefilteredBinOrbit : + D.filtration.realification.PolynomialOrbit (fun _ : C.Variables => 1) := + D.externalCandidateOrbit W Dref hDref (fun _ => 1) + (D.filtration.polynomialOrbitRealChart (fullTaggedVariableWeight J) (fun _ => 1) + (integerSampledRealChart C.integerChart) C.integerChart_support left) + (D.filtration.polynomialOrbitRealChart (fullTaggedVariableWeight J) (fun _ => 1) + (integerSampledRealChart C.integerChart) C.integerChart_support right) + middle + +theorem originalDegreeRefilteredBinOrbit_eval (u : C.Variables → ℤ) : + D.filtration.realification.polynomialOrbitEval (fun _ => 1) u + (C.originalDegreeRefilteredBinOrbit D W Dref hDref left right middle) = + D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u) left * + realificationMap (hnil := Dref.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) + (D.filtration.gradedRefiltrationSubalgebra W).incl + (Dref.filtration.realification.polynomialOrbitEval (fun _ => 1) u middle) * + D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u) right := by + have he := D.externalCandidateOrbit_realEval W Dref hDref (fun _ : C.Variables => 1) + (D.filtration.polynomialOrbitRealChart (fullTaggedVariableWeight J) (fun _ => 1) + (integerSampledRealChart C.integerChart) C.integerChart_support left) + (D.filtration.polynomialOrbitRealChart (fullTaggedVariableWeight J) (fun _ => 1) + (integerSampledRealChart C.integerChart) C.integerChart_support right) + middle (fun i => (u i : ℝ)) + unfold chartValues + simpa only [originalDegreeRefilteredBinOrbit, polynomialOrbitRealEval_integer, + polynomialOrbitIntegerChart_eval] using he + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {σtest : Type*} {w : σtest → ℕ} (bin : D.Niltest w) + +noncomputable def originalDegreeRefilteredBinTest : D.Niltest (fun _ : C.Variables => 1) := + bin.withOrbit (C.originalDegreeRefilteredBinOrbit D W Dref hDref left right middle) + +theorem originalDegreeRefilteredBinTest_complexity (p : ℝ) : + (C.originalDegreeRefilteredBinTest D W Dref hDref left right middle bin).ComplexityLE p ↔ + bin.ComplexityLE p := Iff.rfl + +@[simp] theorem originalDegreeRefilteredBinTest_normBound : + (C.originalDegreeRefilteredBinTest D W Dref hDref left right middle bin).normBound = + bin.normBound := rfl + +noncomputable def originalDegreeBinFrozen (u : C.Variables → ℤ) + (source : Dref.RealGroup) : ℂ := + bin.observable (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u) left * + realificationMap (hnil := Dref.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) + (D.filtration.gradedRefiltrationSubalgebra W).incl source * + D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u) right)) + +theorem originalDegreeRefilteredBinTest_eval (u : C.Variables → ℤ) : + (C.originalDegreeRefilteredBinTest D W Dref hDref left right middle bin).eval u = + C.originalDegreeBinFrozen D W Dref left right bin u + (Dref.filtration.realification.polynomialOrbitEval (fun _ => 1) u middle) := by + rw [originalDegreeRefilteredBinTest, RationalFilteredNilmanifold.Niltest.withOrbit_eval, + C.originalDegreeRefilteredBinOrbit_eval] + rfl + +variable (Fmark : RationalFilteredNilmanifold M (s + 1) f) + (φ : L →ₗ⁅ℚ⁆ M) + (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ Fmark.filtration.layer j) + (Fref : RationalFilteredNilmanifold + (Fmark.filtration.gradedRefiltrationSubalgebra + (W.map (D.filtration.associatedGradedMap Fmark.filtration φ hφ))) (s + 1) nF) + (Q : RationalFilteredNilmanifold + ((D.filtration.gradedRefiltrationSubalgebra W) ⧸ Dref.filtration.layerIdeal (s + 1)) s nQ) + (hQ : Q.filtration = Dref.filtration.quotientTop) + [PseudoMetricSpace Q.Space] [PseudoMetricSpace Fref.Space] + (markedMiddle : Fref.filtration.realification.PolynomialOrbit + (fullTaggedVariableWeight (X := X) J)) + (candidate : AllocatedExternalLocalCandidate C Dref Fref.filtration + (D.filtration.gradedRefiltrationMap Fmark.filtration φ hφ W) markedMiddle) + (K : ℝ≥0) + +theorem originalDegreeRefilteredBinTest_positiveImage_on_slice + (hrecovery : ∀ u ∈ C.slice.integerPoints, ∀ source, + positiveImageSlice (Dref.markedTopQuotientDiagram Fref + (D.filtration.gradedRefiltrationMap Fmark.filtration φ hφ W) Q) K + (C.originalDegreeBinFrozen D W Dref left right bin u) + (Dref.markedTopQuotientDiagram Fref + (D.filtration.gradedRefiltrationMap Fmark.filtration φ hφ W) Q source).2 + (Dref.markedTopQuotientDiagram Fref + (D.filtration.gradedRefiltrationMap Fmark.filtration φ hφ W) Q source).1 = + C.originalDegreeBinFrozen D W Dref left right bin u source) + (u : C.Variables → ℤ) (hu : u ∈ C.slice.integerPoints) : + taggedRefilteredQuotientOperator D Fmark φ hφ W Dref Fref Q K + (D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u) left) + (D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u) right) + (QuotientGroup.mk (Fref.filtration.realification.polynomialOrbitEval + (fullTaggedVariableWeight J) (C.chartValues u) markedMiddle)) + bin.observable + (QuotientGroup.mk (Q.filtration.realification.polynomialOrbitEval (fun _ => 1) u + (Dref.topQuotientOrbit Q hQ candidate.orbit))) = + (C.originalDegreeRefilteredBinTest D W Dref hDref left right candidate.orbit bin).eval u := by + rw [C.originalDegreeRefilteredBinTest_eval, Dref.topQuotientOrbit_eval] + have he := hrecovery u hu + (Dref.filtration.realification.polynomialOrbitEval (fun _ => 1) u candidate.orbit) + unfold originalDegreeBinFrozen at he ⊢ + simpa only [taggedRefilteredQuotientOperator, + RationalFilteredNilmanifold.markedTopQuotientDiagram, candidate.mark_on_slice u hu] using he + +noncomputable def originalDegreeRefilteredBinNative + (hnorm : bin.normBound ≤ 1) {p : ℝ} (hcomplexity : bin.ComplexityLE p) + (hrecovery : ∀ u ∈ C.slice.integerPoints, ∀ source, + positiveImageSlice (Dref.markedTopQuotientDiagram Fref + (D.filtration.gradedRefiltrationMap Fmark.filtration φ hφ W) Q) K + (C.originalDegreeBinFrozen D W Dref left right bin u) + (Dref.markedTopQuotientDiagram Fref + (D.filtration.gradedRefiltrationMap Fmark.filtration φ hφ W) Q source).2 + (Dref.markedTopQuotientDiagram Fref + (D.filtration.gradedRefiltrationMap Fmark.filtration φ hφ W) Q source).1 = + C.originalDegreeBinFrozen D W Dref left right bin u source) + : NativeSampleModel (fun _ : C.Variables => 1) (s + 1) p + (fun u : C.slice.integerPoints => + commonStrideIndex (fun i => (C.slice.start i : ℤ)) C.step u.val) + (fun u => taggedRefilteredQuotientOperator D Fmark φ hφ W Dref Fref Q K + (D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u.val) left) + (D.filtration.realification.polynomialOrbitEval (fullTaggedVariableWeight J) + (C.chartValues u.val) right) + (QuotientGroup.mk (Fref.filtration.realification.polynomialOrbitEval + (fullTaggedVariableWeight J) (C.chartValues u.val) markedMiddle)) + bin.observable + (QuotientGroup.mk (Q.filtration.realification.polynomialOrbitEval (fun _ => 1) u.val + (Dref.topQuotientOrbit Q hQ candidate.orbit)))) where + L := L + dim := d + model := D + test := (C.originalDegreeRefilteredBinTest D W Dref hDref left right candidate.orbit bin).commonStridePullback (fun i => (C.slice.start i : ℤ)) C.step + norm := hnorm + complexity := hcomplexity + eval u := by + apply (C.originalDegreeRefilteredBinTest_positiveImage_on_slice D W Dref hDref + left right bin Fmark φ hφ Fref Q hQ markedMiddle candidate K + hrecovery u.val u.property).trans + apply ((C.originalDegreeRefilteredBinTest D W Dref hDref left right candidate.orbit bin).commonStridePullback_eval_index_of_mem + (fun i => (C.slice.start i : ℤ)) C.step C.slice.length u.val _).symm + rw [← C.slice.integerPoints_eq_commonStrideBox] + exact u.property + +end AllocatedExternalLocalChart +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedPathwiseFrozenNiltestMajorWitness.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedPathwiseFrozenNiltestMajorWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..d65da2a92852b6659e86d52809af21bfdb2ad2c3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AllocatedPathwiseFrozenNiltestMajorWitness.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.Progressions.Dynamics.AllocatedPathwiseFrozenMajorDetection +import OAI.Combinatorics.Progressions.Nilpotent.AllocatedKeptCommonCurrentGradeLocalNiltest + +namespace OAI + +section + +namespace Erdos3 +open Module VectorPolynomial Submodule BooleanCubeKernel RationalFilteredNilmanifold +open scoped BigOperators Classical TensorProduct NNReal + +variable {m : ℕ} {G X : Type} [Fintype G] [Fintype X] [DecidableEq X] + {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} + {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] + {J : Fin m → Type} [∀ j, Fintype (J j)] + {U : ∀ j, Submodule ℝ (J j → ℝ)} + {btag : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} + {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U btag R σ} + {hb : ∀ j, span ℤ (Set.range (btag j)) = projectedIntegerLattice (euclideanSubspace (U j))} + {o : ∀ j, OrthonormalBasis (I j) ℝ (euclideanSubspace (U j))} + {hR : ∀ j, 0 < R j} {hσ : ∀ j, 0 < σ j} + {N : X → ℕ} {poly : ∀ j, VectorPolynomial X ℝ (J j → ℝ)} + {hm : ∀ j e, coefficients (poly j) e ∈ U j} + {τ ξ : ℝ} {stride : X → ℕ} + {cells : Finset (ColumnResiduePattern (Option (LayerSamplerVariables G I n B)) X stride)} + {center : CoefficientTorus (K := LayerSamplerVariables G I n B) U} + [∀ j, IsZLattice ℝ (latticeSection (standardEuclideanLattice (J j)) (euclideanSubspace (U j)))] + (A : AllocatedExternalCandidateSampler B U btag S hb o hR hσ N poly hm τ ξ stride cells center) + +namespace NilpotentLieFiltration + +theorem exists_allocated_full_chart_major_correlation_witness_of_pathwise_frozen_local_niltests + {k t : ℕ} {L ι η : Type} [Fintype η] + [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight t)] + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (fast : Submodule ℚ F.AssociatedGraded) + (basis : Basis η ℝ (ℝ ⊗[ℚ] (F.AssociatedGraded ⧸ fast))) + (Z left right : F.RealPolynomialSymbolGroup (fullTaggedVariableWeight (X := X) J)) + (htk : t < k) + (hpoly : ∀ j, DegreeLE (fun _ => 1) (j.val + 1) (poly j)) + (c : Fin (Fintype.card (LowTaggedIndex J k)) → ℝ) + (pSlice pTest pNative pMajor Rrank : ℝ) (C : ℕ) + (hpNative : 2 ≤ pNative) (hη : (Fintype.card η : ℝ) ≤ pNative) + (hNativeMajor : pNative ≤ pMajor) (hproduct : productNiltestBudget pNative ≤ pMajor) + (hdim : ((Fintype.card X + Fintype.card (Σ j, J j) : ℕ) : ℝ) ≤ pMajor) + (hN : ∀ i, Real.exp ((pMajor + C) ^ C) ≤ (N i : ℝ)) + (hRrank : Real.exp ((pMajor + C) ^ C) ≤ Rrank) + (hrank : ∀ j, HasLayerSamplingRank (j.val + 1) + (fun i => (N i : ℝ)) Rrank (U j) (poly j)) + (good : η → Finset A.Path) + (keep : A.Path → LayerSamplerVariables G I n B → Prop) + (cost Bshort : ℝ) (hcost : 0 ≤ cost) + (hBshort : 1 ≤ Bshort) (hshort : ∀ z i, ¬keep z i → (A.sides i : ℝ) ≤ Bshort) + (hξ : ξ ≤ 1) + (α : ℝ) (hmass : ∀ j, α ≤ (9 / 10 : ℝ) * A.law.mass (good j)) + (hdirect : A.NativeDetection t pSlice pTest pNative α) + (hslice : max cost (Real.log Bshort) ≤ pSlice) + (htest : OrdinaryPolynomialPhase.budget t ≤ pTest) + (strideBound : η → A.Path → ℕ) + (score : η → ∀ z : A.Path, ({i : LayerSamplerVariables G I n B // keep z i} → ℤ) → ℝ) + (hlocal : ∀ j z, z ∈ good j → + ∃ fixed : {i // ¬keep z i} → ℤ, + (∀ i, 0 ≤ fixed i ∧ fixed i < A.sides i.val) ∧ + ∃ q : ℕ, 0 < q ∧ q ≤ strideBound j z ∧ + ∃ slice : ResidueBoxSlice (fun i : {i // keep z i} => A.sides i.val) q, + IsDenseCommonStrideBox (fun i : {i // keep z i} => A.sides i.val) cost slice.integerPoints ∧ + (𝔼 x : (∀ i : {i // keep z i}, Fin (A.sides i.val)), + score j z (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ slice.integerPoints, score j z x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold t).Niltest (fun _ : {i // keep z i} => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget t) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ slice.integerPoints, + majorPhasePlateauSignal J k poly c + (coordinate (basis.coord j).toAddMonoidHom + (lowTaggedVectorRestrict J k (F.realSymbolGradeQuotientPolynomial b ω hF + (fullTaggedVariableWeight (X := X) J) fast k (left⁻¹ * Z * right⁻¹).coord))) + (jointIntegerPhysicalSite (finiteSplitPoint (keep z) x fixed) (z.1.val, z.2.val)) * + star (T.eval (commonStrideIndex (fun i => (slice.start i : ℤ)) q x))‖) : + Nonempty (FullChartMajorCorrelationWitness F b ω hF J k fast basis + Z left right N poly U pMajor Rrank C) := by + apply exists_allocated_full_chart_major_correlation_witness_of_pathwise_frozen_local_tests + A F b ω hF fast basis Z left right htk hpoly c pSlice pTest pNative pMajor Rrank C + hpNative hη hNativeMajor hproduct hdim hN hRrank hrank good keep cost Bshort + hcost hBshort hshort hξ α hmass hdirect hslice htest + intro j z hz + obtain ⟨fixed, hfixed, q, hq, _, slice, hdense, _, T, hnorm, hcomplex, hcorr⟩ := hlocal j z hz + let packet : LocalMajorSliceTest (OrdinaryPolynomialPhase.nilmanifold t) + (fun i : {i // keep z i} => A.sides i.val) cost (OrdinaryPolynomialPhase.budget t) := + { stride := q + stride_pos := hq + slice := slice + dense := hdense + test := T + norm := by rw [hnorm]; norm_num + complexity := hcomplex } + exact ⟨fixed, hfixed, packet, hcorr⟩ + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AmbientBracketCorrectionPolynomials.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AmbientBracketCorrectionPolynomials.lean new file mode 100644 index 0000000000000000000000000000000000000000..b51f0adfb8c4ac38ccee7b1c39d62793be19a53a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AmbientBracketCorrectionPolynomials.lean @@ -0,0 +1,285 @@ +import OAI.Combinatorics.Progressions.Estimates.CocycleHorizontalNormalization + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix TensorProduct + +variable {L ι κ ν σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype ι] [Fintype κ] [Fintype ν] {E V : Submodule ℚ L} + +theorem exists_controlled_bracket_corrections + (e : Basis ν ℚ E) (f : Basis ι ℚ (L ⧸ V)) (k : κ → L) + {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l) + (hA : ∀ i n, RationalHeightLE (bracketSystemMatrix e f k i n) H) + {p : ℝ} (hp : 0 ≤ p) (hrows : (Fintype.card (κ × ι) : ℝ) ≤ p) + (hcols : (Fintype.card ν : ℝ) ≤ p) (hHp : (H : ℝ) ≤ Real.exp p) + (hlp : (l : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, Real.exp (separationBudget p) ≤ T i) : + ∃ (Q : Matrix ν (κ × ι) ℚ) (m : ℕ), + 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + 2) ^ 36) ∧ + let C := Matrix.mulVecLin (fun i j => (Q i j : ℝ)) + ∀ (α : σ →₀ ℕ), α ≠ 0 → ∀ (small rational : κ × ι → ℝ) (v : ν → ℝ), + ‖small‖ ≤ Real.exp p / monomialScale T α → rational ∈ realDenominatorGrid l → + realBracketSystem f k (bracketSystemLift e v) = small + rational → + bracketSystemLift e (C small) ∈ E.baseChange ℝ ∧ + bracketSystemLift e (C rational) ∈ E.baseChange ℝ ∧ + realBracketSystem f k (bracketSystemLift e (C small)) = small ∧ + realBracketSystem f k (bracketSystemLift e (C rational)) = rational ∧ + ‖C small‖ ≤ Real.exp ((p + 2) ^ 18 + p) / monomialScale T α ∧ + C rational ∈ realDenominatorGrid m ∧ + ∀ b, ⁅bracketSystemLift e v - bracketSystemLift e (C small) - + bracketSystemLift e (C rational), (1 : ℝ) ⊗ₜ[ℚ] k b⁆ ∈ V.baseChange ℝ := by + have hsplit := exists_controlled_linear_splitting (bracketSystemMatrix e f k) + hH hl hA hp hrows hcols hHp hlp T hT + obtain ⟨Q, m, hm, hmp, hQ⟩ := hsplit + refine ⟨Q, m, hm, hmp, ?_⟩ + intro C α hα small rational v hsmall hrational heq + have heq' := (bracketSystemMatrix_real_apply e f k v).trans heq + obtain ⟨hsmallQ, hratQ, hnorm, hgrid, hzero⟩ := + hQ α hα small rational v hsmall hrational heq' + refine ⟨bracketSystemLift_mem e _, bracketSystemLift_mem e _, + (bracketSystemMatrix_real_apply e f k (C small)).symm.trans hsmallQ, + (bracketSystemMatrix_real_apply e f k (C rational)).symm.trans hratQ, + hnorm, hgrid, ?_⟩ + apply (realBracketSystem_eq_zero_iff f k _).mp + have h := (bracketSystemMatrix_real_apply e f k (v - C small - C rational)).symm.trans hzero + simpa only [map_sub] using h + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix TensorProduct NNReal + +variable {L μ ν : Type*} [LieRing L] [LieAlgebra ℚ L] {E : Submodule ℚ L} + +noncomputable def bracketLiftMatrix (b : Basis μ ℚ L) (e : Basis ν ℚ E) : Matrix μ ν ℚ := + fun i j => b.repr (e j : L) i + +theorem bracketSystemLift_coordinates [Fintype μ] [Fintype ν] + (b : Basis μ ℚ L) (e : Basis ν ℚ E) (x : ν → ℝ) : + (b.baseChange ℝ).equivFun (bracketSystemLift e x) = + (fun i j => (bracketLiftMatrix b e i j : ℝ)) *ᵥ x := by + classical + have h : (b.baseChange ℝ).equivFun.toLinearMap.comp (bracketSystemLift e) = + Matrix.mulVecLin (fun i j => (bracketLiftMatrix b e i j : ℝ)) := by + apply (Pi.basisFun ℝ ν).ext + intro j + change (b.baseChange ℝ).equivFun (bracketSystemLift e (Pi.single j 1)) = + Matrix.of (fun i n => (bracketLiftMatrix b e i n : ℝ)) *ᵥ Pi.single j 1 + rw [bracketSystemLift_single, Matrix.mulVec_single_one] + funext i + simp only [Basis.equivFun_apply, Basis.baseChange_repr_tmul, Matrix.col_apply, + Matrix.of_apply, bracketLiftMatrix] + simp [Algebra.smul_def] + exact DFunLike.congr_fun h x + +theorem bracketSystemLift_norm_bound [Fintype μ] [Fintype ν] + (b : Basis μ ℚ L) (e : Basis ν ℚ E) {H : ℕ} + (he : ∀ i j, RationalHeightLE (b.repr (e j : L) i) H) (x : ν → ℝ) : + ‖(b.baseChange ℝ).equivFun (bracketSystemLift e x)‖ ≤ + ((Fintype.card ν : ℝ) + 1) * (H + 1) * ‖x‖ := by + rw [bracketSystemLift_coordinates] + exact norm_matrix_mulVec_le _ (H : ℝ≥0) (fun i j => (he i j).abs_real_le) x + +theorem bracketSystemLift_grid [Fintype μ] [Fintype ν] + (b : Basis μ ℚ L) (e : Basis ν ℚ E) (m : ℕ) (x : ν → ℝ) + (hx : x ∈ realDenominatorGrid m) : + (b.baseChange ℝ).equivFun (bracketSystemLift e x) ∈ + realDenominatorGrid (matrixDenominator (bracketLiftMatrix b e) * m) := by + rw [bracketSystemLift_coordinates] + exact real_matrix_denominator_grid (bracketLiftMatrix b e) m x hx + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module VectorPolynomial +open scoped Matrix TensorProduct + +variable {L ι κ ν σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype ι] [Fintype κ] [Fintype ν] {E V : Submodule ℚ L} + +theorem exists_bracket_correction_polynomials + (e : Basis ν ℚ E) (f : Basis ι ℚ (L ⧸ V)) (k : κ → L) + {H l : ℕ} (hH : 1 ≤ H) (hl : 0 < l) + (hA : ∀ i n, RationalHeightLE (bracketSystemMatrix e f k i n) H) + {p : ℝ} (hp : 0 ≤ p) (hrows : (Fintype.card (κ × ι) : ℝ) ≤ p) + (hcols : (Fintype.card ν : ℝ) ≤ p) (hHp : (H : ℝ) ≤ Real.exp p) + (hlp : (l : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, Real.exp (separationBudget p) ≤ T i) + (P : VectorPolynomial σ ℚ (ν → ℝ)) + (small rational : VectorPolynomial σ ℚ (κ × ι → ℝ)) + (hP0 : coefficients P 0 = 0) (hsmall0 : coefficients small 0 = 0) + (hrational0 : coefficients rational 0 = 0) + (hsmall : ∀ α, ‖coefficients small α‖ ≤ Real.exp p / monomialScale T α) + (hrational : ∀ α, coefficients rational α ∈ realDenominatorGrid l) + (heq : ∀ α, realBracketSystem f k (bracketSystemLift e (coefficients P α)) = + coefficients small α + coefficients rational α) : + ∃ (m : ℕ) (A B : VectorPolynomial σ ℚ (ν → ℝ)), + 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + 2) ^ 36) ∧ + map (((realBracketSystem f k).comp (bracketSystemLift e)).restrictScalars ℚ) A = small ∧ + map (((realBracketSystem f k).comp (bracketSystemLift e)).restrictScalars ℚ) B = rational ∧ + (∀ α, coefficients small α = 0 → coefficients A α = 0) ∧ + (∀ α, coefficients rational α = 0 → coefficients B α = 0) ∧ + (∀ α, ‖coefficients A α‖ ≤ Real.exp ((p + 2) ^ 18 + p) / monomialScale T α) ∧ + (∀ α, coefficients B α ∈ realDenominatorGrid m) ∧ + ∀ α b, ⁅bracketSystemLift e (coefficients (P - A - B) α), + (1 : ℝ) ⊗ₜ[ℚ] k b⁆ ∈ V.baseChange ℝ := by + have h := exists_controlled_bracket_corrections e f k hH hl hA hp hrows hcols hHp hlp T hT + obtain ⟨Q, m, hm, hmp, hQ⟩ := h + let C : (κ × ι → ℝ) →ₗ[ℝ] (ν → ℝ) := Matrix.mulVecLin (fun i j => (Q i j : ℝ)) + let A := map (C.restrictScalars ℚ) small + let B := map (C.restrictScalars ℚ) rational + have hAc (α : σ →₀ ℕ) : coefficients A α = C (coefficients small α) := + coefficients_map _ _ _ + have hBc (α : σ →₀ ℕ) : coefficients B α = C (coefficients rational α) := + coefficients_map _ _ _ + have hcoeff (α : σ →₀ ℕ) (hα : α ≠ 0) := + hQ α hα (coefficients small α) (coefficients rational α) (coefficients P α) + (hsmall α) (hrational α) (heq α) + refine ⟨m, A, B, hm, hmp, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · apply coefficients.injective + apply Finsupp.ext + intro α + rw [coefficients_map, hAc] + change realBracketSystem f k (bracketSystemLift e (C (coefficients small α))) = _ + by_cases hα : α = 0 + · simp only [hα, hsmall0, map_zero] + · exact (hcoeff α hα).2.2.1 + · apply coefficients.injective + apply Finsupp.ext + intro α + rw [coefficients_map, hBc] + change realBracketSystem f k (bracketSystemLift e (C (coefficients rational α))) = _ + by_cases hα : α = 0 + · simp only [hα, hrational0, map_zero] + · exact (hcoeff α hα).2.2.2.1 + · intro α hα + rw [hAc, hα, map_zero] + · intro α hα + rw [hBc, hα, map_zero] + · intro α + rw [hAc] + by_cases hα : α = 0 + · simp only [hα, hsmall0, map_zero, norm_zero, monomialScale_zero, div_one] + exact Real.exp_nonneg _ + · exact (hcoeff α hα).2.2.2.2.1 + · intro α + rw [hBc] + by_cases hα : α = 0 + · rw [hα, hrational0, map_zero] + exact ⟨0, by ext i; simp⟩ + · exact (hcoeff α hα).2.2.2.2.2.1 + · intro α b + simp only [map_sub, Finsupp.sub_apply, hAc, hBc] + by_cases hα : α = 0 + · simp only [hα, hP0, hsmall0, hrational0, map_zero, sub_zero, zero_lie] + exact (V.baseChange ℝ).zero_mem + · simpa only [map_sub] using (hcoeff α hα).2.2.2.2.2.2 b + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module VectorPolynomial +open scoped Matrix TensorProduct + +variable {L μ ι κ ν σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype μ] [Fintype ι] [Fintype κ] [Fintype ν] {E V : Submodule ℚ L} + +theorem exists_ambient_bracket_correction_polynomials + (b : Basis μ ℚ L) (e : Basis ν ℚ E) (f : Basis ι ℚ (L ⧸ V)) (k : κ → L) + {H J l : ℕ} (hH : 1 ≤ H) (hl : 0 < l) + (hA : ∀ i n, RationalHeightLE (bracketSystemMatrix e f k i n) H) + (he : ∀ i j, RationalHeightLE (b.repr (e j : L) i) J) + {p : ℝ} (hp : 0 ≤ p) (hrows : (Fintype.card (κ × ι) : ℝ) ≤ p) + (hcols : (Fintype.card ν : ℝ) ≤ p) (hHp : (H : ℝ) ≤ Real.exp p) + (hlp : (l : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, Real.exp (separationBudget p) ≤ T i) + (P : VectorPolynomial σ ℚ (ν → ℝ)) + (small rational : VectorPolynomial σ ℚ (κ × ι → ℝ)) + (hP0 : coefficients P 0 = 0) (hsmall0 : coefficients small 0 = 0) + (hrational0 : coefficients rational 0 = 0) + (hsmall : ∀ α, ‖coefficients small α‖ ≤ Real.exp p / monomialScale T α) + (hrational : ∀ α, coefficients rational α ∈ realDenominatorGrid l) + (heq : ∀ α, realBracketSystem f k (bracketSystemLift e (coefficients P α)) = + coefficients small α + coefficients rational α) : + ∃ (m : ℕ) (A B : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)), + 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + 2) ^ 36) ∧ + map ((realBracketSystem f k).restrictScalars ℚ) A = small ∧ + map ((realBracketSystem f k).restrictScalars ℚ) B = rational ∧ + (∀ α, coefficients A α ∈ E.baseChange ℝ ∧ coefficients B α ∈ E.baseChange ℝ) ∧ + (∀ α, coefficients small α = 0 → coefficients A α = 0) ∧ + (∀ α, coefficients rational α = 0 → coefficients B α = 0) ∧ + (∀ α, ‖(b.baseChange ℝ).equivFun (coefficients A α)‖ ≤ + (((Fintype.card ν : ℝ) + 1) * (J + 1)) * + Real.exp ((p + 2) ^ 18 + p) / monomialScale T α) ∧ + (∀ α, (b.baseChange ℝ).equivFun (coefficients B α) ∈ + realDenominatorGrid (matrixDenominator (bracketLiftMatrix b e) * m)) ∧ + ∀ α t, ⁅coefficients (map ((bracketSystemLift e).restrictScalars ℚ) P - A - B) α, + (1 : ℝ) ⊗ₜ[ℚ] k t⁆ ∈ V.baseChange ℝ := by + have h := exists_bracket_correction_polynomials e f k hH hl hA hp hrows hcols hHp hlp + T hT P small rational hP0 hsmall0 hrational0 hsmall hrational heq + obtain ⟨m, A₀, B₀, hm, hmp, hAQ, hBQ, hAzero, hBzero, hAnorm, hBgrid, hres⟩ := h + let A := map ((bracketSystemLift e).restrictScalars ℚ) A₀ + let B := map ((bracketSystemLift e).restrictScalars ℚ) B₀ + have hAc (α : σ →₀ ℕ) : coefficients A α = bracketSystemLift e (coefficients A₀ α) := + coefficients_map _ _ _ + have hBc (α : σ →₀ ℕ) : coefficients B α = bracketSystemLift e (coefficients B₀ α) := + coefficients_map _ _ _ + refine ⟨m, A, B, hm, hmp, ?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · apply coefficients.injective + apply Finsupp.ext + intro α + rw [coefficients_map, hAc] + simpa only [coefficients_map, LinearMap.restrictScalars_apply, LinearMap.comp_apply] + using congrArg (fun q => coefficients q α) hAQ + · apply coefficients.injective + apply Finsupp.ext + intro α + rw [coefficients_map, hBc] + simpa only [coefficients_map, LinearMap.restrictScalars_apply, LinearMap.comp_apply] + using congrArg (fun q => coefficients q α) hBQ + · intro α + rw [hAc, hBc] + exact ⟨bracketSystemLift_mem e _, bracketSystemLift_mem e _⟩ + · intro α hα + rw [hAc, hAzero α hα, map_zero] + · intro α hα + rw [hBc, hBzero α hα, map_zero] + · intro α + rw [hAc] + apply (bracketSystemLift_norm_bound b e he _).trans + simpa only [mul_div_assoc] using mul_le_mul_of_nonneg_left (hAnorm α) + (by positivity : 0 ≤ ((Fintype.card ν : ℝ) + 1) * (J + 1)) + · intro α + rw [hBc] + exact bracketSystemLift_grid b e m _ (hBgrid α) + · intro α t + simp only [map_sub, Finsupp.sub_apply, coefficients_map, hAc, hBc] + simpa only [map_sub, Finsupp.sub_apply, LinearMap.restrictScalars_apply] using hres α t + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/AntisymmetricPairNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/AntisymmetricPairNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca54478725e13f9fde2daf3cea38a8453125ce01 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/AntisymmetricPairNiltest.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Estimates.QuadraticPairCorrelator + +namespace OAI + +section + +namespace Erdos3.NativeSampleCorrelation + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +variable {p q : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (mixedCorrelationDegree 1) p} {i j : Fin W.outputDim} + (V : NativeSampleCorrelation (fun _ : Fin 2 => 1) 1 q + Finset.univ (fun z : Fin 2 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.antisymmetricKernel i j ((z 0).val : ℤ) ((z 1).val : ℤ))) + [TopologicalSpace (ℝ ⊗[ℚ] V.AntisymmetricPairAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V.AntisymmetricPairAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V.AntisymmetricPairAlgebra)] + [T2Space (ℝ ⊗[ℚ] V.AntisymmetricPairAlgebra)] + +noncomputable def antisymmetricPairNiltest : + (pi V.antisymmetricPairModels).Niltest (fun _ : Fin 2 => 1) := + piNiltest V.antisymmetricPairModels V.antisymmetricPairTests + ((by norm_num : (0 : ℝ) ≤ 4).trans V.antisymmetricPairBudget_four_le) + (by simpa using (show (3 : ℝ) ≤ antisymmetricPairBudget p q from + (by norm_num : (3 : ℝ) ≤ 4).trans V.antisymmetricPairBudget_four_le)) + V.antisymmetricPairTests_complexity + +theorem antisymmetricPairNiltest_complexity : + V.antisymmetricPairNiltest.ComplexityLE (productNiltestBudget (antisymmetricPairBudget p q)) := + piNiltest_complexity V.antisymmetricPairModels V.antisymmetricPairTests _ _ _ + +theorem antisymmetricPairNiltest_eval (n : Fin 2 → ℤ) : + V.antisymmetricPairNiltest.eval n = + W.antisymmetricKernel i j (n 0) (n 1) * star (V.test.eval n) := by + rw [antisymmetricPairNiltest, piNiltest_eval] + exact V.antisymmetricPairTests_eval n + +theorem antisymmetricPairNiltest_vertical + (z : (pi V.antisymmetricPairModels).RealGroup) + (hz : z ∈ (pi V.antisymmetricPairModels).filtration.realification.subgroup + (∑ l, mixedCorrelationDegree 1 l)) (x : (pi V.antisymmetricPairModels).Space) : + V.antisymmetricPairNiltest.observable (z • x) = + CircleFourier.character + ((realifyFunctional (piFrequency V.antisymmetricPairFrequencies) z.coord : ℝ) : + CircleFourier.Circle) * V.antisymmetricPairNiltest.observable x := + piNiltest_vertical V.antisymmetricPairModels V.antisymmetricPairTests + V.antisymmetricPairFrequencies _ _ _ V.antisymmetricPairTests_vertical z hz x + +theorem antisymmetricPairNiltest_bias : + Real.exp (-q) ≤ ‖𝔼 n ∈ integerBox (fun _ : Fin 2 => N), V.antisymmetricPairNiltest.eval n‖ := by + rw [integerBox_expect_eq_zmod] + simp_rw [V.antisymmetricPairNiltest_eval] + exact V.correlation + +end Erdos3.NativeSampleCorrelation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHChartCutoffSmooth.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHChartCutoffSmooth.lean new file mode 100644 index 0000000000000000000000000000000000000000..025653d5528e091b975600aadc4195f106de3b13 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHChartCutoffSmooth.lean @@ -0,0 +1,642 @@ +import Mathlib.AlgebraicTopology.FundamentalGroupoid.SimplyConnected +import Mathlib.Analysis.Convex.Contractible +import Mathlib.Geometry.Manifold.Algebra.LieGroup +import Mathlib.Geometry.Manifold.Diffeomorph +import Mathlib.Topology.Algebra.Module.FiniteDimension +import Mathlib.Topology.Algebra.Module.ModuleTopology +import OAI.Combinatorics.Progressions.Estimates.RightCosetEDistance +import OAI.Combinatorics.Progressions.Geometry.LieCoordinateSmooth +import OAI.Combinatorics.Progressions.Linear.RationalSpanCoordinates + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} [TopologicalSpace L] + +instance : TopologicalSpace (NilpotentLieBCHGroup L s hnil) := + TopologicalSpace.induced coord inferInstance + +@[fun_prop] +theorem continuous_coord : Continuous (coord : NilpotentLieBCHGroup L s hnil → L) := + continuous_induced_dom + +@[fun_prop] +theorem continuous_mk : Continuous (fun x : L => (⟨x⟩ : NilpotentLieBCHGroup L s hnil)) := + continuous_induced_rng.mpr continuous_id + +def coordHomeomorph : NilpotentLieBCHGroup L s hnil ≃ₜ L where + toFun := coord + invFun x := ⟨x⟩ + left_inv _ := rfl + right_inv _ := rfl + continuous_toFun := continuous_coord + continuous_invFun := continuous_mk + +instance [T2Space L] : T2Space (NilpotentLieBCHGroup L s hnil) := + (coordHomeomorph (hnil := hnil)).isEmbedding.t2Space + +instance [ContractibleSpace L] : ContractibleSpace (NilpotentLieBCHGroup L s hnil) := + (coordHomeomorph (hnil := hnil)).contractibleSpace + +theorem isTopologicalGroup_of_continuous_lie [IsTopologicalAddGroup L] [ContinuousConstSMul ℚ L] + (hlie : Continuous (fun z : L × L => ⁅z.1, z.2⁆)) : + IsTopologicalGroup (NilpotentLieBCHGroup L s hnil) where + continuous_mul := by + change Continuous (fun z : NilpotentLieBCHGroup L s hnil × NilpotentLieBCHGroup L s hnil => + (⟨lieBCH s z.1.coord z.2.coord⟩ : NilpotentLieBCHGroup L s hnil)) + have hcoords : Continuous + (fun z : NilpotentLieBCHGroup L s hnil × NilpotentLieBCHGroup L s hnil => + (z.1.coord, z.2.coord)) := + (continuous_coord.comp continuous_fst).prodMk (continuous_coord.comp continuous_snd) + have hbch : Continuous + (fun z : NilpotentLieBCHGroup L s hnil × NilpotentLieBCHGroup L s hnil => + lieBCH s z.1.coord z.2.coord) := + Continuous.comp + (g := fun z : L × L => lieBCH s z.1 z.2) + (f := fun z : NilpotentLieBCHGroup L s hnil × NilpotentLieBCHGroup L s hnil => + (z.1.coord, z.2.coord)) + (continuous_lieBCH (L := L) hlie s) hcoords + exact (continuous_mk (hnil := hnil)).comp hbch + continuous_inv := by + change Continuous (fun z : NilpotentLieBCHGroup L s hnil => + (⟨-z.coord⟩ : NilpotentLieBCHGroup L s hnil)) + exact (continuous_mk (hnil := hnil)).comp (continuous_coord (hnil := hnil)).neg + +theorem continuous_map_of_continuous {M : Type*} [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace M] {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + (φ : L →ₗ⁅ℚ⁆ M) (hφ : Continuous φ) : + Continuous (map (hnil := hnil) (hM := hM) φ) := + continuous_mk.comp (hφ.comp continuous_coord) + +section Real + +variable [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] [FiniteDimensional ℝ L] + +instance : IsTopologicalGroup (NilpotentLieBCHGroup L s hnil) := by + let : ContinuousConstSMul ℚ L := ⟨fun q => by + simpa only [algebraMap_smul] using + (continuous_const_smul (algebraMap ℚ ℝ q) : Continuous (fun x : L => algebraMap ℚ ℝ q • x))⟩ + exact isTopologicalGroup_of_continuous_lie continuous_lie_finiteDimensional + +omit [IsScalarTower ℚ ℝ L] [T2Space L] [FiniteDimensional ℝ L] in + +theorem connected_simplyConnected : + ConnectedSpace (NilpotentLieBCHGroup L s hnil) ∧ + SimplyConnectedSpace (NilpotentLieBCHGroup L s hnil) := by + constructor <;> infer_instance + +end Real + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Topology + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def basisHomeomorph (e : Basis ι ℝ L) : + NilpotentLieBCHGroup L s hnil ≃ₜ (ι → ℝ) := + (coordHomeomorph (hnil := hnil)).trans e.equivFunL.toHomeomorph + +@[simp] +theorem basisHomeomorph_apply (e : Basis ι ℝ L) (g : NilpotentLieBCHGroup L s hnil) : + basisHomeomorph e g = e.equivFun g.coord := rfl + +theorem closed_discrete_subgroup_of_grid (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) : + IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil)) ∧ + IsDiscrete (Γ : Set (NilpotentLieBCHGroup L s hnil)) := by + let f := basisHomeomorph (hnil := hnil) e + have hsub : (Γ : Set (NilpotentLieBCHGroup L s hnil)) ⊆ f ⁻¹' realDenominatorGrid l := + fun g hg => hgrid g hg + have hd : IsDiscrete (f ⁻¹' realDenominatorGrid l) := + (isDiscrete_realDenominatorGrid l hl).preimage f.continuous.continuousOn f.injective + have hc : IsClosed (f ⁻¹' realDenominatorGrid l) := + (isClosed_realDenominatorGrid l).preimage f.continuous + exact ⟨isClosed_of_subset_discrete_closed hsub hd hc, hd.mono hsub⟩ + +theorem discreteTopology_subgroup_of_grid (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) : + DiscreteTopology Γ := + isDiscrete_iff_discreteTopology.mp (closed_discrete_subgroup_of_grid e Γ l hl hgrid).2 + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + +noncomputable def realLieSubalgebraOverRat (K : LieSubalgebra ℝ L) : LieSubalgebra ℚ L := + { K.toSubmodule.restrictScalars ℚ with lie_mem' := K.lie_mem } + +namespace NilpotentLieBCHGroup + +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def realLieSubgroup (K : LieSubalgebra ℝ L) : Subgroup (NilpotentLieBCHGroup L s hnil) := + subgroup (realLieSubalgebraOverRat K) + +theorem mem_realLieSubgroup (K : LieSubalgebra ℝ L) (g : NilpotentLieBCHGroup L s hnil) : + g ∈ realLieSubgroup K ↔ g.coord ∈ K := Iff.rfl + +variable [TopologicalSpace L] + +def realLieSubgroupCoordHomeomorph (K : LieSubalgebra ℝ L) : + realLieSubgroup (hnil := hnil) K ≃ₜ K.toSubmodule where + toFun g := ⟨g.1.coord, g.2⟩ + invFun v := ⟨⟨v.1⟩, v.2⟩ + left_inv _ := rfl + right_inv _ := rfl + continuous_toFun := (continuous_coord.comp continuous_subtype_val).subtype_mk _ + continuous_invFun := (continuous_mk.comp continuous_subtype_val).subtype_mk _ + +variable [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] + +theorem realLieSubgroup_contractible (K : LieSubalgebra ℝ L) : + ContractibleSpace (realLieSubgroup (hnil := hnil) K) := + (realLieSubgroupCoordHomeomorph K).contractibleSpace + +theorem realLieSubgroup_connected_simplyConnected (K : LieSubalgebra ℝ L) : + ConnectedSpace (realLieSubgroup (hnil := hnil) K) ∧ + SimplyConnectedSpace (realLieSubgroup (hnil := hnil) K) := by + let := realLieSubgroup_contractible (hnil := hnil) K + exact ⟨inferInstance, inferInstance⟩ + +theorem realLieSubgroup_closed [T2Space L] [FiniteDimensional ℝ L] (K : LieSubalgebra ℝ L) : + IsClosed (realLieSubgroup (hnil := hnil) K : Set (NilpotentLieBCHGroup L s hnil)) := + K.toSubmodule.closed_of_finiteDimensional.preimage continuous_coord + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +def coordinateBox (e : Basis ι ℝ L) (B : ℝ) : Set (NilpotentLieBCHGroup L s hnil) := + {g | ∀ i, |e.repr g.coord i| ≤ B} + +variable [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + +theorem isCompact_coordinateBox (e : Basis ι ℝ L) (B : ℝ) : + IsCompact (coordinateBox (hnil := hnil) e B) := by + let f := basisHomeomorph (hnil := hnil) e + have heq : coordinateBox (hnil := hnil) e B = + f.symm '' Set.univ.pi (fun _ : ι => Set.Icc (-B) B) := by + ext g + constructor + · intro hg + refine ⟨f g, ?_, f.symm_apply_apply g⟩ + intro i _ + exact abs_le.mp (hg i) + · rintro ⟨v, hv, rfl⟩ i + apply abs_le.mpr + have hi : e.repr (f.symm v).coord i = v i := congrFun (f.apply_symm_apply v) i + rw [hi] + exact hv i (Set.mem_univ i) + rw [heq] + exact (isCompact_univ_pi (fun _ : ι => isCompact_Icc)).image f.symm.continuous + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +@[instance_reducible] +noncomputable def basisChartedSpace (e : Basis ι ℝ L) : + ChartedSpace (ι → ℝ) (NilpotentLieBCHGroup L s hnil) := + (basisHomeomorph (hnil := hnil) e).isOpenEmbedding.singletonChartedSpace + +variable (e : Basis ι ℝ L) + +theorem isManifold_basis (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + IsManifold 𝓘(ℝ, ι → ℝ) n (NilpotentLieBCHGroup L s hnil) := + (basisHomeomorph e).isOpenEmbedding.isManifold_singleton + +theorem contMDiff_basisHomeomorph (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n (basisHomeomorph (hnil := hnil) e) := + contMDiff_isOpenEmbedding (basisHomeomorph e).isOpenEmbedding + +theorem contMDiff_basisHomeomorph_symm (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n (basisHomeomorph (hnil := hnil) e).symm := by + let := basisChartedSpace (hnil := hnil) e + apply ContMDiff.of_comp_isOpenEmbedding (basisHomeomorph e).isOpenEmbedding + have heq : (basisHomeomorph (hnil := hnil) e) ∘ (basisHomeomorph e).symm = id := + funext (fun x => (basisHomeomorph e).apply_symm_apply x) + rw [heq] + exact contMDiff_id + +noncomputable def basisDiffeomorph (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + (NilpotentLieBCHGroup L s hnil) ≃ₘ^n⟮𝓘(ℝ, ι → ℝ), 𝓘(ℝ, ι → ℝ)⟯ (ι → ℝ) := by + letI := basisChartedSpace (hnil := hnil) e + exact + { toEquiv := (basisHomeomorph e).toEquiv + contMDiff_toFun := contMDiff_basisHomeomorph e n + contMDiff_invFun := contMDiff_basisHomeomorph_symm e n } + +variable [IsScalarTower ℚ ℝ L] + +theorem lieGroup_basis (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + LieGroup 𝓘(ℝ, ι → ℝ) n (NilpotentLieBCHGroup L s hnil) := by + let := basisChartedSpace (hnil := hnil) e + refine + { __ := isManifold_basis (hnil := hnil) e n + contMDiff_mul := ?_ + contMDiff_inv := ?_ } + · apply ContMDiff.of_comp_isOpenEmbedding (basisHomeomorph e).isOpenEmbedding + have hcoords : ContMDiff (𝓘(ℝ, ι → ℝ).prod 𝓘(ℝ, ι → ℝ)) + 𝓘(ℝ, (ι → ℝ) × (ι → ℝ)) n + (fun z : NilpotentLieBCHGroup L s hnil × NilpotentLieBCHGroup L s hnil => + (basisHomeomorph e z.1, basisHomeomorph e z.2)) := + ((contMDiff_basisHomeomorph e n).comp contMDiff_fst).prodMk_space + ((contMDiff_basisHomeomorph e n).comp contMDiff_snd) + have hbch := (contDiff_coordinateBCH (n := n) e s).contMDiff.comp hcoords + convert hbch using 1; try rfl + funext z + simp only [Function.comp_apply, basisHomeomorph_apply, LinearEquiv.symm_apply_apply] + rfl + · apply ContMDiff.of_comp_isOpenEmbedding (basisHomeomorph e).isOpenEmbedding + have hneg := (contDiff_neg (𝕜 := ℝ) (F := ι → ℝ) (n := n)).contMDiff.comp + (contMDiff_basisHomeomorph (hnil := hnil) e n) + have heq : (basisHomeomorph (hnil := hnil) e) ∘ (fun z => z⁻¹) = + (fun z => -z) ∘ (basisHomeomorph e) := by + funext z i + change e.equivFun (-z.coord) i = -(e.equivFun z.coord i) + simp only [map_neg, Pi.neg_apply] + rw [heq] + exact hneg + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + +local notation "E" => ℝ ⊗[ℚ] L +local notation "G" => NilpotentLieBCHGroup E s (realification_lowerCentralSeries_eq_bot hnil) + +omit [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] in + +theorem realification_layer_reduction_in_cell {κ : Type*} [Fintype κ] (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) (n : ℕ) (v : κ → L) + (hspan : Submodule.span ℚ (Set.range v) = (LieModule.lowerCentralSeries ℚ L L n).toSubmodule) : + ∀ g : G, g.coord ∈ LieModule.lowerCentralSeries ℚ E E n → + ∃ r ∈ (fun x : E => (⟨x⟩ : G)) '' + boundedSpanCell (fun j => rationalLieInclusion (v j)) (rationalSpanGridStep e v l : ℝ), + ∃ w ∈ Γ.map NilpotentLieBCHGroup.realificationHom, + (r⁻¹ * g * w⁻¹).coord ∈ LieModule.lowerCentralSeries ℚ E E (n + 1) := by + classical + let m := rationalSpanGridStep e v l + have hm : 0 < m := rationalSpanGridStep_pos e v l hl + let vR : κ → E := fun j => rationalLieInclusion (v j) + intro g hg + have hspanreal : (LieModule.lowerCentralSeries ℚ E E n : Set E) = + (Submodule.span ℝ (Set.range vR) : Set E) := realification_layer_eq_span n v hspan + have hgspan : g.coord ∈ Submodule.span ℝ (Set.range vR) := + (Set.ext_iff.mp hspanreal g.coord).mp hg + obtain ⟨r, hr, z, hdecomp⟩ := exists_bounded_span_remainder vR (m : ℝ) + (by exact_mod_cast hm) g.coord hgspan + let wQ : L := ∑ j, ((z j : ℚ) * (m : ℚ)) • v j + have hwQ : (⟨wQ⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ := by + have h := hinner (rationalSpanGridStep_combination e v l z) + change (⟨e.equivFun.symm (e.equivFun wQ)⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ at h + simpa only [LinearEquiv.symm_apply_apply] using h + have hdecomp' : g.coord = r + rationalLieInclusion wQ := by + change g.coord = r + rationalLieInclusion (∑ j, ((z j : ℚ) * (m : ℚ)) • v j) + rw [rationalLieInclusion_integer_combination v z m] + exact hdecomp + have hrLayer : r ∈ LieModule.lowerCentralSeries ℚ E E n := + (Set.ext_iff.mp hspanreal r).mpr (boundedSpanCell_subset_span vR (m : ℝ) hr) + have hwLayer : rationalLieInclusion wQ ∈ LieModule.lowerCentralSeries ℚ E E n := by + have h := (LieModule.lowerCentralSeries ℚ E E n).sub_mem hg hrLayer + rwa [hdecomp', add_sub_cancel_left] at h + have hbracket : ⁅r, rationalLieInclusion wQ⁆ ∈ LieModule.lowerCentralSeries ℚ E E (n + 1) := by + rw [LieModule.lowerCentralSeries_succ] + exact LieSubmodule.lie_mem_lie (by simp) hwLayer + refine ⟨⟨r⟩, ⟨r, hr, rfl⟩, NilpotentLieBCHGroup.realificationHom ⟨wQ⟩, + Subgroup.mem_map.mpr ⟨⟨wQ⟩, hwQ, rfl⟩, ?_⟩ + have hg' : g = (⟨r + rationalLieInclusion wQ⟩ : G) := NilpotentLieBCHGroup.ext hdecomp' + rw [hg'] + exact NilpotentLieBCHGroup.additive_remainder_mem (realification_lowerCentralSeries_eq_bot hnil) + (LieModule.lowerCentralSeries ℚ E E (n + 1)) r (rationalLieInclusion wQ) hbracket + +theorem exists_realification_layer_reduction (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) (n : ℕ) : + ∃ K : Set G, IsCompact K ∧ + ∀ g : G, g.coord ∈ LieModule.lowerCentralSeries ℚ E E n → + ∃ r ∈ K, ∃ w ∈ Γ.map NilpotentLieBCHGroup.realificationHom, + (r⁻¹ * g * w⁻¹).coord ∈ LieModule.lowerCentralSeries ℚ E E (n + 1) := by + obtain ⟨d, _, v, hspan⟩ := exists_finite_layer_spanning e n + refine ⟨(fun x : E => (⟨x⟩ : G)) '' + boundedSpanCell (fun j => rationalLieInclusion (v j)) (rationalSpanGridStep e v l : ℝ), + (isCompact_boundedSpanCell _ _).image NilpotentLieBCHGroup.continuous_mk, ?_⟩ + exact realification_layer_reduction_in_cell e Γ l hl hinner n v hspan + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem realificationHom_coordinates (e : Basis ι ℚ L) (g : NilpotentLieBCHGroup L s hnil) : + (e.baseChange ℝ).equivFun (realificationHom g).coord = fun i => (e.repr g.coord i : ℝ) := by + funext i + exact rationalLieInclusion_coordinates e g.coord i + +theorem realification_subgroup_grid (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∀ g ∈ Γ.map realificationHom, + (e.baseChange ℝ).equivFun g.coord ∈ realDenominatorGrid l := by + intro g hg + obtain ⟨a, ha, rfl⟩ := Subgroup.mem_map.mp hg + rw [realificationHom_coordinates, real_cast_mem_denominatorGrid_iff] + apply hgrid + change (⟨e.equivFun.symm (e.equivFun a.coord)⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ + simpa only [LinearEquiv.symm_apply_apply] using ha + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem realification_subgroup_closed_discrete (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + IsClosed (Γ.map realificationHom : Set + (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil))) ∧ + IsDiscrete (Γ.map realificationHom : Set + (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil))) := + closed_discrete_subgroup_of_grid (e.baseChange ℝ) (Γ.map realificationHom) l hl + (realification_subgroup_grid e Γ l hgrid) + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem rational_inclusion_mem_realLayer_iff (i : ℕ) (a : L) : + rationalLieInclusion a ∈ F.realLayer i ↔ a ∈ F.layer i := + one_tmul_mem_real_baseChange_iff (F.layer i) a + +theorem realificationHom_mem_subgroup_iff (i : ℕ) (g : F.Group) : + NilpotentLieBCHGroup.realificationHom g ∈ F.realification.subgroup i ↔ g ∈ F.subgroup i := + F.rational_inclusion_mem_realLayer_iff i g.coord + +theorem realification_subgroup_eq_realLieSubgroup (i : ℕ) : + F.realification.subgroup i = NilpotentLieBCHGroup.realLieSubgroup + (F.realLayer i).toLieSubalgebra := rfl + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] + +theorem realification_subgroup_contractible (i : ℕ) : + ContractibleSpace (F.realification.subgroup i) := + NilpotentLieBCHGroup.realLieSubgroup_contractible (F.realLayer i).toLieSubalgebra + +theorem realification_subgroup_connected_simplyConnected (i : ℕ) : + ConnectedSpace (F.realification.subgroup i) ∧ SimplyConnectedSpace (F.realification.subgroup i) := + NilpotentLieBCHGroup.realLieSubgroup_connected_simplyConnected (F.realLayer i).toLieSubalgebra + +theorem realification_subgroup_closed [T2Space (ℝ ⊗[ℚ] L)] + [FiniteDimensional ℚ L] (i : ℕ) : + IsClosed (F.realification.subgroup i : Set F.realification.Group) := + NilpotentLieBCHGroup.realLieSubgroup_closed (F.realLayer i).toLieSubalgebra + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Set Manifold +open scoped Manifold ContDiff Topology + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem eventuallyEq_quotient_chartInverse + (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (z : NilpotentLieBCHGroup L s hnil) (φ : OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ)) + (hφ : ∀ v, φ v = QuotientGroup.mk (z * (basisHomeomorph e).symm v)) + (g : NilpotentLieBCHGroup L s hnil) (hg : (QuotientGroup.mk g : _ ⧸ Γ) ∈ φ.target) : + ∃ γ : Γ, (fun h : NilpotentLieBCHGroup L s hnil => φ.symm (QuotientGroup.mk h)) =ᶠ[𝓝 g] + (fun h => basisHomeomorph e (z⁻¹ * (h * (γ : NilpotentLieBCHGroup L s hnil)))) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let v := φ.symm (QuotientGroup.mk g) + let a := z * (basisHomeomorph e).symm v + have ha : (QuotientGroup.mk a : _ ⧸ Γ) = QuotientGroup.mk g := + (hφ v).symm.trans (φ.right_inv hg) + let γ : Γ := ⟨g⁻¹ * a, QuotientGroup.eq.mp ha.symm⟩ + have hga : g * (γ : NilpotentLieBCHGroup L s hnil) = a := by + simp only [γ, mul_inv_cancel_left] + let f := fun h : NilpotentLieBCHGroup L s hnil => + basisHomeomorph e (z⁻¹ * (h * (γ : NilpotentLieBCHGroup L s hnil))) + have hf : Continuous f := (basisHomeomorph e).continuous.comp + (continuous_const.mul (continuous_id.mul continuous_const)) + have hfg : f g = v := by + dsimp only [f] + rw [hga] + simp only [a, inv_mul_cancel_left, Homeomorph.apply_symm_apply] + have hnear : ∀ᶠ h in 𝓝 g, f h ∈ φ.source := + hf.continuousAt (φ.open_source.mem_nhds (hfg ▸ φ.map_target hg)) + refine ⟨γ, ?_⟩ + filter_upwards [hnear] with h hh + have hφf : φ (f h) = (QuotientGroup.mk h : _ ⧸ Γ) := by + rw [hφ] + dsimp only [f] + rw [Homeomorph.symm_apply_apply, mul_inv_cancel_left] + exact quotient_mk_mul_mem Γ h γ + change φ.symm (QuotientGroup.mk h) = f h + rw [← hφf, φ.left_inv hh] + +theorem contMDiffAt_quotient_chartInverse + (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (z : NilpotentLieBCHGroup L s hnil) (φ : OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ)) + (hφ : ∀ v, φ v = QuotientGroup.mk (z * (basisHomeomorph e).symm v)) + (n : ℕ∞ω) (g : NilpotentLieBCHGroup L s hnil) (hg : (QuotientGroup.mk g : _ ⧸ Γ) ∈ φ.target) : + letI := basisChartedSpace (hnil := hnil) e + ContMDiffAt 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n + (fun h : NilpotentLieBCHGroup L s hnil => φ.symm (QuotientGroup.mk h)) g := by + let := basisChartedSpace (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e n + obtain ⟨γ, hγ⟩ := eventuallyEq_quotient_chartInverse e Γ z φ hφ g hg + have hsmooth : ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n + (fun h : NilpotentLieBCHGroup L s hnil => + basisHomeomorph e (z⁻¹ * (h * (γ : NilpotentLieBCHGroup L s hnil)))) := + (contMDiff_basisHomeomorph e n).comp (contMDiff_const.mul (contMDiff_id.mul contMDiff_const)) + exact hsmooth.contMDiffAt.congr_of_eventuallyEq hγ + +theorem contDiffOn_quotient_chart_transition + (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (z w : NilpotentLieBCHGroup L s hnil) (φ ψ : OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ)) + (hφ : ∀ v, φ v = QuotientGroup.mk (z * (basisHomeomorph e).symm v)) + (hψ : ∀ v, ψ v = QuotientGroup.mk (w * (basisHomeomorph e).symm v)) (n : ℕ∞ω) : + ContDiffOn ℝ n (φ.trans ψ.symm) (φ.trans ψ.symm).source := by + let := basisChartedSpace (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e n + intro v hv + have htarget : (QuotientGroup.mk (z * (basisHomeomorph e).symm v) : _ ⧸ Γ) ∈ ψ.target := by + rw [← hφ] + exact hv.2 + have hi := contMDiffAt_quotient_chartInverse e Γ w ψ hψ n + (z * (basisHomeomorph e).symm v) htarget + have hz : ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n + (fun u : ι → ℝ => z * (basisHomeomorph e).symm u) := + contMDiff_const.mul (contMDiff_basisHomeomorph_symm e n) + have ht := (hi.comp v hz.contMDiffAt).contDiffAt.contDiffWithinAt (s := (φ.trans ψ.symm).source) + simpa only [Function.comp_def, OpenPartialHomeomorph.coe_trans, hφ] using ht + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem exists_realification_topology_of_grid (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ τ : TopologicalSpace (ℝ ⊗[ℚ] L), + letI := τ + IsTopologicalAddGroup (ℝ ⊗[ℚ] L) ∧ ContinuousSMul ℝ (ℝ ⊗[ℚ] L) ∧ T2Space (ℝ ⊗[ℚ] L) ∧ + IsTopologicalGroup (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) ∧ + ConnectedSpace (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) ∧ + SimplyConnectedSpace (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) ∧ + IsClosed (Γ.map NilpotentLieBCHGroup.realificationHom : Set + (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil))) ∧ + IsDiscrete (Γ.map NilpotentLieBCHGroup.realificationHom : Set + (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil))) := by + let τ := moduleTopology ℝ (ℝ ⊗[ℚ] L) + let : TopologicalSpace (ℝ ⊗[ℚ] L) := τ + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] L) := IsModuleTopology.isTopologicalAddGroup ℝ _ + let : FiniteDimensional ℝ (ℝ ⊗[ℚ] L) := (e.baseChange ℝ).finiteDimensional_of_finite + have hcoord : Continuous (e.baseChange ℝ).equivFun := + IsModuleTopology.continuous_of_linearMap (e.baseChange ℝ).equivFun.toLinearMap + let : T2Space (ℝ ⊗[ℚ] L) := + T2Space.of_injective_continuous (e.baseChange ℝ).equivFun.injective hcoord + refine ⟨τ, inferInstance, inferInstance, inferInstance, inferInstance, inferInstance, inferInstance, ?_⟩ + exact NilpotentLieBCHGroup.realification_subgroup_closed_discrete e Γ l hl hgrid + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Set Manifold +open scoped Manifold ContDiff Topology + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem contMDiff_quotient_chartCutoff + (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (z : NilpotentLieBCHGroup L s hnil) + (φ : OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ)) + (hφ : ∀ v, φ v = QuotientGroup.mk (z * (basisHomeomorph e).symm v)) + (ψ : (ι → ℝ) → ℝ) (hsmooth : ContDiff ℝ ∞ ψ) + (hsupport : tsupport (chartCutoff φ ψ) ⊆ φ.target) : + letI := basisChartedSpace (hnil := hnil) e + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ℝ) ∞ + (fun g : NilpotentLieBCHGroup L s hnil => chartCutoff φ ψ (QuotientGroup.mk g)) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := basisChartedSpace (hnil := hnil) e + apply contMDiff_of_tsupport + intro g hg + have hgt : (QuotientGroup.mk g : _ ⧸ Γ) ∈ φ.target := + hsupport (tsupport_comp_subset_preimage (chartCutoff φ ψ) QuotientGroup.continuous_mk hg) + have hi := contMDiffAt_quotient_chartInverse e Γ z φ hφ ∞ g hgt + have hnear : ∀ᶠ h in 𝓝 g, (QuotientGroup.mk h : _ ⧸ Γ) ∈ φ.target := + QuotientGroup.continuous_mk.continuousAt (φ.open_target.mem_nhds hgt) + apply (hsmooth.contMDiff.contMDiffAt.comp g hi).congr_of_eventuallyEq + filter_upwards [hnear] with h hh + exact dite_eq_left hh + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHConjugationLinear.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHConjugationLinear.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4e9e4127d6c0946e4cd893e160a28e91b87bfbf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHConjugationLinear.lean @@ -0,0 +1,1083 @@ +import Mathlib.Algebra.Group.End +import Mathlib.Analysis.Calculus.Deriv.Comp +import Mathlib.Analysis.Calculus.Deriv.Mul +import Mathlib.Analysis.LocallyConvex.Bounded +import Mathlib.Analysis.Normed.Module.FiniteDimension +import Mathlib.Geometry.Manifold.Riemannian.Basic +import Mathlib.Geometry.Manifold.VectorBundle.Riemannian +import Mathlib.Geometry.Manifold.VectorBundle.Tangent +import Mathlib.Topology.Instances.Rat +import Mathlib.Topology.MetricSpace.IsometricSMul +import OAI.Combinatorics.Progressions.Estimates.RiemannianLipschitz +import OAI.Combinatorics.Progressions.Nilpotent.BCHChartCutoffSmooth + +namespace OAI + +section + +namespace Erdos3 + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s t : ℕ} + +attribute [local instance] LieRing.ofAssociativeRing + +theorem lieBCH_eq_of_step_le (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (hst : s ≤ t) (a b : L) : lieBCH t a b = lieBCH s a b := by + let x : Fin 2 → FreeLieAlgebra ℚ (Fin 2) := FreeLieAlgebra.of ℚ + let F := truncatedSeriesFiltration (A := FreeAlgebra ℚ (Fin 2)) s + have hx (i : Fin 2) : scaledFreeGenerator s i ∈ F.layer 1 := scaledFreeGenerator_mem_layer s i + have h : scaledFreeLieEval s (lieBCH t (x 0) (x 1)) = + scaledFreeLieEval s (lieBCH s (x 0) (x 1)) := by + simp only [map_lieBCH, x, scaledFreeLieEval_of] + rw [(F.extend hst).lieBCH_eq (hx 0) (hx 1), F.lieBCH_eq (hx 0) (hx 1)] + have he := lie_lift_eq_of_scaledFreeLieEval_eq ![a, b] hnil h + simpa only [map_lieBCH, x, FreeLieAlgebra.lift_of_apply, + Matrix.cons_val_zero, Matrix.cons_val_one] using he + +theorem lieBCH_eq_of_nilpotent_steps (hs : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (ht : LieModule.lowerCentralSeries ℚ L L t = ⊥) (a b : L) : lieBCH s a b = lieBCH t a b := by + rcases le_total s t with hst | hts + · exact (lieBCH_eq_of_step_le hs hst a b).symm + · exact lieBCH_eq_of_step_le ht hts a b + +theorem map_lieBCH_of_nilpotent_steps (φ : L →ₗ⁅ℚ⁆ M) + (hs : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (ht : LieModule.lowerCentralSeries ℚ M M t = ⊥) (a b : L) : + φ (lieBCH s a b) = lieBCH t (φ a) (φ b) := by + rcases le_total s t with hst | hts + · rw [← lieBCH_eq_of_step_le hs hst, map_lieBCH] + · rw [map_lieBCH, lieBCH_eq_of_step_le ht hts] + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L M N : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [LieRing N] [LieAlgebra ℚ N] {s t u : ℕ} + {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + {hN : LieModule.lowerCentralSeries ℚ N N u = ⊥} + +noncomputable def mapOfSteps (φ : L →ₗ⁅ℚ⁆ M) : + NilpotentLieBCHGroup L s hL →* NilpotentLieBCHGroup M t hM where + toFun g := ⟨φ g.coord⟩ + map_one' := ext (map_zero φ) + map_mul' g h := ext (map_lieBCH_of_nilpotent_steps φ hL hM g.coord h.coord) + +@[simp] theorem mapOfSteps_coord (φ : L →ₗ⁅ℚ⁆ M) (g : NilpotentLieBCHGroup L s hL) : + (mapOfSteps (hM := hM) φ g).coord = φ g.coord := rfl + +theorem mapOfSteps_injective (φ : L →ₗ⁅ℚ⁆ M) (hφ : Function.Injective φ) : + Function.Injective (mapOfSteps (hL := hL) (hM := hM) φ) := by + intro g h heq + exact ext (hφ (congrArg coord heq)) + +theorem mapOfSteps_surjective (φ : L →ₗ⁅ℚ⁆ M) (hφ : Function.Surjective φ) : + Function.Surjective (mapOfSteps (hL := hL) (hM := hM) φ) := by + intro g + obtain ⟨x, hx⟩ := hφ g.coord + exact ⟨⟨x⟩, ext hx⟩ + +theorem mapOfSteps_comp (φ : L →ₗ⁅ℚ⁆ M) (ψ : M →ₗ⁅ℚ⁆ N) : + (mapOfSteps (hL := hM) (hM := hN) ψ).comp (mapOfSteps (hL := hL) (hM := hM) φ) = + mapOfSteps (hL := hL) (hM := hN) (ψ.comp φ) := by + ext g + rfl + +noncomputable def changeStep (hs : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (ht : LieModule.lowerCentralSeries ℚ L L t = ⊥) : + NilpotentLieBCHGroup L s hs ≃* NilpotentLieBCHGroup L t ht where + toFun g := ⟨g.coord⟩ + invFun g := ⟨g.coord⟩ + left_inv _ := rfl + right_inv _ := rfl + map_mul' g h := ext (lieBCH_eq_of_nilpotent_steps hs ht g.coord h.coord) + +@[simp] theorem changeStep_coord (hs : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (ht : LieModule.lowerCentralSeries ℚ L L t = ⊥) (g : NilpotentLieBCHGroup L s hs) : + (changeStep hs ht g).coord = g.coord := rfl + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s t : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +theorem bchSubgroupCoordinates_comap_of_steps [DecidableEq κ] + (b : Basis κ ℚ M) (e : Basis ι ℚ L) + (φ : M →ₗ⁅ℚ⁆ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) : + bchSubgroupCoordinates b (Γ.comap (NilpotentLieBCHGroup.mapOfSteps (hL := hM) φ)) = + (LinearMap.toMatrix b e φ.toLinearMap).mulVec ⁻¹' bchSubgroupCoordinates e Γ := by + ext x + change ((⟨φ (b.equivFun.symm x)⟩ : NilpotentLieBCHGroup L s hL) ∈ Γ) ↔ + ((⟨e.equivFun.symm (LinearMap.toMatrix b e φ.toLinearMap *ᵥ x)⟩ : + NilpotentLieBCHGroup L s hL) ∈ Γ) + rw [basisMatrix_mulVec, LinearEquiv.symm_apply_apply] + rfl + +theorem exists_bchSubgroup_comap_grid_of_steps [DecidableEq ι] [DecidableEq κ] + (b : Basis κ ℚ M) (e : Basis ι ℚ L) (φ : M →ₗ⁅ℚ⁆ L) (hφ : Function.Injective φ) + (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) {H l : ℕ} (hHpos : 1 ≤ H) (hlpos : 0 < l) + (hB : ∀ i j, RationalHeightLE (LinearMap.toMatrix b e φ.toLinearMap i j) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) (hr : (Fintype.card κ : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hl : (l : ℝ) ≤ Real.exp p) : + ∃ N : ℕ, 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.mapOfSteps (hL := hM) φ)) ∧ + bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.mapOfSteps (hL := hM) φ)) ⊆ denominatorGrid N := by + rw [bchSubgroupCoordinates_comap_of_steps b e φ Γ] + exact exists_preimage_grid_exp_bound (LinearMap.toMatrix b e φ.toLinearMap) + (Matrix.mulVec_injective_iff.mp (basisMatrix_injective b e φ.toLinearMap hφ)) + hHpos hlpos hB _ hinner houter hp hd hr hH hl + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) + +noncomputable def rightTranslate (g : NilpotentLieBCHGroup L s hnil) (x : ι → ℝ) : ι → ℝ := + basisHomeomorph e ((basisHomeomorph e).symm x * g) + +@[simp] theorem rightTranslate_coordinates (g h : NilpotentLieBCHGroup L s hnil) : + rightTranslate e h (basisHomeomorph e g) = basisHomeomorph e (g * h) := by + simp only [rightTranslate, Homeomorph.symm_apply_apply] + +@[simp] theorem rightTranslate_one : rightTranslate (hnil := hnil) e 1 = id := by + funext x + simp only [rightTranslate, mul_one, Homeomorph.apply_symm_apply, id_eq] + +theorem rightTranslate_comp (g h : NilpotentLieBCHGroup L s hnil) : + rightTranslate e h ∘ rightTranslate e g = rightTranslate e (g * h) := by + funext x + simp only [Function.comp_apply, rightTranslate, Homeomorph.symm_apply_apply, mul_assoc] + +variable [IsScalarTower ℚ ℝ L] + +theorem contDiff_rightTranslate (g : NilpotentLieBCHGroup L s hnil) (n : ℕ∞ω) : + ContDiff ℝ n (rightTranslate e g) := by + let := basisChartedSpace (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e n + exact ((contMDiff_basisHomeomorph e n).comp + ((contMDiff_basisHomeomorph_symm e n).mul contMDiff_const)).contDiff + +theorem rightTranslate_fderiv_leftInverse (g : NilpotentLieBCHGroup L s hnil) (x : ι → ℝ) : + (fderiv ℝ (rightTranslate e g⁻¹) (rightTranslate e g x)).comp + (fderiv ℝ (rightTranslate e g) x) = ContinuousLinearMap.id ℝ (ι → ℝ) := by + have hg := (contDiff_rightTranslate e g 1).differentiable (by decide) + have hi := (contDiff_rightTranslate e g⁻¹ 1).differentiable (by decide) + rw [← fderiv_comp x hi.differentiableAt hg.differentiableAt, + rightTranslate_comp, mul_inv_cancel, rightTranslate_one, fderiv_id] + +theorem rightTranslate_fderiv_injective (g : NilpotentLieBCHGroup L s hnil) (x : ι → ℝ) : + Function.Injective (fderiv ℝ (rightTranslate e g) x) := by + intro v w hvw + have h := congrArg (fderiv ℝ (rightTranslate e g⁻¹) (rightTranslate e g x)) hvw + simpa only [← ContinuousLinearMap.comp_apply, rightTranslate_fderiv_leftInverse, + ContinuousLinearMap.id_apply] using h + +noncomputable def rightVelocity (g : NilpotentLieBCHGroup L s hnil) : + (ι → ℝ) →L[ℝ] (ι → ℝ) := + fderiv ℝ (rightTranslate e g⁻¹) (basisHomeomorph e g) + +theorem rightVelocity_injective (g : NilpotentLieBCHGroup L s hnil) : + Function.Injective (rightVelocity e g) := + rightTranslate_fderiv_injective e g⁻¹ (basisHomeomorph e g) + +omit [IsScalarTower ℚ ℝ L] in +@[simp] theorem rightVelocity_one : + rightVelocity (hnil := hnil) e 1 = ContinuousLinearMap.id ℝ (ι → ℝ) := by + simp only [rightVelocity, inv_one, rightTranslate_one, fderiv_id] + +theorem rightVelocity_mul (g h : NilpotentLieBCHGroup L s hnil) : + (rightVelocity e (g * h)).comp (fderiv ℝ (rightTranslate e h) (basisHomeomorph e g)) = + rightVelocity e g := by + have hh := (contDiff_rightTranslate e h 1).differentiable (by decide) + have hi := (contDiff_rightTranslate e (g * h)⁻¹ 1).differentiable (by decide) + unfold rightVelocity + rw [← rightTranslate_coordinates e g h, ← fderiv_comp _ hi.differentiableAt hh.differentiableAt, + rightTranslate_comp] + simp only [mul_inv_rev, mul_inv_cancel_left] + +theorem contDiff_rightVelocity : + ContDiff ℝ ∞ (fun x : ι → ℝ => rightVelocity (hnil := hnil) e ((basisHomeomorph e).symm x)) := by + have h : ContDiff ℝ ∞ (fun p : (ι → ℝ) × (ι → ℝ) => + e.equivFun (lieBCH s (e.equivFun.symm p.2) (e.equivFun.symm (-p.1)))) := + ContDiff.comp + (g := fun z : (ι → ℝ) × (ι → ℝ) => + e.equivFun (lieBCH s (e.equivFun.symm z.1) (e.equivFun.symm z.2))) + (f := fun p : (ι → ℝ) × (ι → ℝ) => (p.2, -p.1)) + (contDiff_coordinateBCH (n := ∞) e s) (contDiff_snd.prodMk contDiff_fst.neg) + have hd : ContDiff ℝ ∞ (fun x : ι → ℝ => + fderiv ℝ (fun y => e.equivFun (lieBCH s (e.equivFun.symm y) (e.equivFun.symm (-x)))) x) := + h.fderiv contDiff_id (by simp) + convert hd using 1 + funext x + unfold rightVelocity + rw [Homeomorph.apply_symm_apply] + apply congrArg (fun f : (ι → ℝ) → (ι → ℝ) => fderiv ℝ f x) + funext y + change e.equivFun (lieBCH s (e.equivFun.symm y) (-e.equivFun.symm x)) = _ + rw [map_neg] + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open scoped ContDiff + +noncomputable def coordinateDotForm {ι : Type*} [Fintype ι] : + (ι → ℝ) →L[ℝ] (ι → ℝ) →L[ℝ] ℝ := + ∑ i, (ContinuousLinearMap.mul ℝ ℝ).bilinearComp + (ContinuousLinearMap.proj i) (ContinuousLinearMap.proj i) + +@[simp] theorem coordinateDotForm_apply {ι : Type*} [Fintype ι] (v w : ι → ℝ) : + coordinateDotForm v w = ∑ i, v i * w i := by + simp [coordinateDotForm] + +theorem contDiff_bilinearComp_self {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] {n : ℕ∞ω} + (B : F →L[ℝ] F →L[ℝ] ℝ) (T : E → F →L[ℝ] F) (hT : ContDiff ℝ n T) : + ContDiff ℝ n (fun x => B.bilinearComp (T x) (T x)) := by + have hflip : ContDiff ℝ n (fun A : F →L[ℝ] F →L[ℝ] ℝ => A.flip) := + (show IsBoundedLinearMap ℝ (fun A : F →L[ℝ] F →L[ℝ] ℝ => A.flip) from + { map_add := ContinuousLinearMap.flip_add + map_smul := ContinuousLinearMap.flip_smul + bound := ⟨1, zero_lt_one, fun A => by simp only [one_mul, ContinuousLinearMap.opNorm_flip, le_refl]⟩ }).contDiff + exact hflip.comp ((hflip.comp (contDiff_const.clm_comp hT)).clm_comp hT) + +end Erdos3 + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) + +noncomputable def rightInnerForm (g : NilpotentLieBCHGroup L s hnil) : + (ι → ℝ) →L[ℝ] (ι → ℝ) →L[ℝ] ℝ := + coordinateDotForm.bilinearComp (rightVelocity e g) (rightVelocity e g) + +theorem rightInnerForm_apply (g : NilpotentLieBCHGroup L s hnil) (v w : ι → ℝ) : + rightInnerForm e g v w = ∑ i, rightVelocity e g v i * rightVelocity e g w i := by + simp only [rightInnerForm, ContinuousLinearMap.bilinearComp_apply, coordinateDotForm_apply] + +theorem rightInnerForm_symm (g : NilpotentLieBCHGroup L s hnil) (v w : ι → ℝ) : + rightInnerForm e g v w = rightInnerForm e g w v := by + simp only [rightInnerForm_apply, mul_comm] + +@[simp] theorem rightInnerForm_one : rightInnerForm (hnil := hnil) e 1 = coordinateDotForm := by + ext v w + simp only [rightInnerForm, rightVelocity_one, ContinuousLinearMap.bilinearComp_apply, + ContinuousLinearMap.id_apply] + +variable [IsScalarTower ℚ ℝ L] + +theorem rightInnerForm_pos (g : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) (hv : v ≠ 0) : + 0 < rightInnerForm e g v v := by + have hne : rightVelocity e g v ≠ 0 := by + intro h + apply hv + exact (rightVelocity_injective e g) (h.trans (map_zero _).symm) + obtain ⟨i, hi⟩ : ∃ i, rightVelocity e g v i ≠ 0 := by + by_contra! h + exact hne (funext h) + rw [rightInnerForm_apply] + exact (Finset.sum_pos_iff_of_nonneg (fun j _ => mul_self_nonneg _)).mpr + ⟨i, Finset.mem_univ i, mul_self_pos.mpr hi⟩ + +theorem rightInnerForm_right_invariant (g h : NilpotentLieBCHGroup L s hnil) (v w : ι → ℝ) : + rightInnerForm e (g * h) + (fderiv ℝ (rightTranslate e h) (basisHomeomorph e g) v) + (fderiv ℝ (rightTranslate e h) (basisHomeomorph e g) w) = rightInnerForm e g v w := by + have hv := congrArg (fun T : (ι → ℝ) →L[ℝ] (ι → ℝ) => T v) (rightVelocity_mul e g h) + have hw := congrArg (fun T : (ι → ℝ) →L[ℝ] (ι → ℝ) => T w) (rightVelocity_mul e g h) + simp only [ContinuousLinearMap.comp_apply] at hv hw + simp only [rightInnerForm_apply, hv, hw] + +theorem contDiff_rightInnerForm : + ContDiff ℝ ∞ (fun x : ι → ℝ => rightInnerForm (hnil := hnil) e ((basisHomeomorph e).symm x)) := + contDiff_bilinearComp_self (E := ι → ℝ) (F := ι → ℝ) (n := ∞) coordinateDotForm + (fun x => rightVelocity (hnil := hnil) e ((basisHomeomorph e).symm x)) + (contDiff_rightVelocity (hnil := hnil) e) + +theorem rightInnerForm_isVonNBounded (g : NilpotentLieBCHGroup L s hnil) : + Bornology.IsVonNBounded ℝ {v : ι → ℝ | rightInnerForm e g v v < 1} := by + let A := fderiv ℝ (rightTranslate e g) + (rightTranslate e g⁻¹ (basisHomeomorph e g)) + have hleft : A.comp (rightVelocity e g) = ContinuousLinearMap.id ℝ (ι → ℝ) := by + simpa only [inv_inv, A, rightVelocity] using + rightTranslate_fderiv_leftInverse e g⁻¹ (basisHomeomorph e g) + apply (NormedSpace.isVonNBounded_iff' ℝ).mpr + refine ⟨‖A‖, ?_⟩ + intro v hv + change rightInnerForm e g v v < 1 at hv + have hTv : ‖rightVelocity e g v‖ ≤ 1 := by + apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr + intro i + have hi : rightVelocity e g v i * rightVelocity e g v i ≤ rightInnerForm e g v v := by + rw [rightInnerForm_apply] + exact Finset.single_le_sum (fun j _ => mul_self_nonneg _) (Finset.mem_univ i) + rw [Real.norm_eq_abs] + apply abs_le.mpr + constructor <;> nlinarith + have heq : A (rightVelocity e g v) = v := by + simpa only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.id_apply] using + congrArg (fun T : (ι → ℝ) →L[ℝ] (ι → ℝ) => T v) hleft + calc + ‖v‖ = ‖A (rightVelocity e g v)‖ := congrArg norm heq.symm + _ ≤ ‖A‖ * ‖rightVelocity e g v‖ := A.le_opNorm _ + _ ≤ ‖A‖ := mul_le_of_le_one_right (norm_nonneg _) hTv + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module MvPolynomial +open scoped NNReal Topology + +theorem lieBCH_right_coordinates_sub_bound {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) {H s : ℕ} + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (x y z : L) {B δ : ℝ} (hB : 1 ≤ B) (hδ : 0 ≤ δ) + (hx : ∀ i, |e.repr x i| ≤ B) (hy : ∀ i, |e.repr y i| ≤ B) + (hz : ∀ i, |e.repr z i| ≤ B) (hxy : ∀ i, |e.repr x i - e.repr y i| ≤ δ) (k : ι) : + |e.repr (lieBCH s x z) k - e.repr (lieBCH s y z) k| ≤ + bchBoxCoordinateBound s (Fintype.card ι) H B * δ := by + classical + let P := bchCoordinatePolynomial c s k + let v : Fin 2 × ι → ℝ := fun i => e.repr (![x, z] i.1) i.2 + let w : Fin 2 × ι → ℝ := fun i => e.repr (![y, z] i.1) i.2 + have hdegree : P.totalDegree ≤ s := bchCoordinatePolynomial_totalDegree c s k + have hv (i : Fin 2 × ι) : |v i| ≤ B := by + rcases i with ⟨j, i⟩ + fin_cases j + · exact hx i + · exact hz i + have hw (i : Fin 2 × ι) : |w i| ≤ B := by + rcases i with ⟨j, i⟩ + fin_cases j + · exact hy i + · exact hz i + have hvw (i : Fin 2 × ι) : |v i - w i| ≤ δ := by + rcases i with ⟨j, i⟩ + fin_cases j + · exact hxy i + · simpa [v, w] using hδ + have hcoeff (m) : |((P.coeff m : ℚ) : ℝ)| ≤ bchCoordinateHeight s (Fintype.card ι) H := + (bchCoordinatePolynomial_height c hc s k m).abs_real_le + have h := abs_aeval_sub_aeval_box_bound P v w (Nat.cast_nonneg _) hB hδ hcoeff hv hw hvw hdegree + have hevalv : aeval v P = e.repr (lieBCH s x z) k := + bchCoordinatePolynomial_eval_over e c hstructure s x z k + have hevalw : aeval w P = e.repr (lieBCH s y z) k := + bchCoordinatePolynomial_eval_over e c hstructure s y z k + rw [hevalv, hevalw] at h + have hcard := polynomial_support_card_le P hdegree + apply h.trans + dsimp only [bchBoxCoordinateBound] + simp only [Fintype.card_prod, Fintype.card_fin] at hcard + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul, Nat.cast_ofNat] + gcongr + exact_mod_cast hcard + +namespace NilpotentLieBCHGroup + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem lipschitzOn_rightTranslate_box (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (g : NilpotentLieBCHGroup L s hnil) (B : ℝ) (hB : 1 ≤ B) + (hg : ∀ i, |e.repr g.coord i| ≤ B) : + LipschitzOnWith ⟨bchBoxCoordinateBound s (Fintype.card ι) H B, + bchBoxCoordinateBound_nonneg _ _ _ (by linarith)⟩ + (rightTranslate e g) {v | ∀ i, |v i| ≤ B} := by + apply LipschitzOnWith.of_dist_le_mul + intro v hv w hw + change ∀ i, |v i| ≤ B at hv + change ∀ i, |w i| ≤ B at hw + apply (dist_pi_le_iff (mul_nonneg + (bchBoxCoordinateBound_nonneg _ _ _ (by linarith : 0 ≤ B)) dist_nonneg)).mpr + intro k + rw [Real.dist_eq] + change |e.equivFun (lieBCH s (e.equivFun.symm v) g.coord) k - + e.equivFun (lieBCH s (e.equivFun.symm w) g.coord) k| ≤ _ + simp only [Basis.equivFun_apply] + apply lieBCH_right_coordinates_sub_bound e c hstructure hc _ _ _ hB dist_nonneg + · simpa only [← Basis.equivFun_apply, LinearEquiv.apply_symm_apply] using hv + · simpa only [← Basis.equivFun_apply, LinearEquiv.apply_symm_apply] using hw + · exact hg + · intro i + simpa only [← Basis.equivFun_apply, LinearEquiv.apply_symm_apply, Real.dist_eq] using + dist_le_pi_dist v w i + +theorem norm_fderiv_rightTranslate_zero_le (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (g : NilpotentLieBCHGroup L s hnil) (B : ℝ) (hB : 1 ≤ B) + (hg : ∀ i, |e.repr g.coord i| ≤ B) : + ‖fderiv ℝ (rightTranslate e g) 0‖ ≤ bchBoxCoordinateBound s (Fintype.card ι) H B := by + apply norm_fderiv_le_of_lipschitzOn ℝ ?_ (lipschitzOn_rightTranslate_box e c hstructure hc g B hB hg) + apply Filter.mem_of_superset (Metric.ball_mem_nhds (0 : ι → ℝ) (by linarith : 0 < B)) + intro v hv i + have hi := norm_le_pi_norm v i + rw [Metric.mem_ball, dist_zero_right] at hv + exact (show |v i| ≤ ‖v‖ by simpa only [Real.norm_eq_abs] using hi).trans hv.le + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Bundle +open scoped Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) + +noncomputable def rightRiemannianMetric : + letI := basisChartedSpace (hnil := hnil) e + RiemannianMetric (fun g : NilpotentLieBCHGroup L s hnil => TangentSpace 𝓘(ℝ, ι → ℝ) g) := by + letI := basisChartedSpace (hnil := hnil) e + refine + { inner := fun g => ?_ + symm := ?_ + pos := ?_ + continuousAt := ?_ + isVonNBounded := ?_ } + · exact rightInnerForm e g + · intro g v w + exact rightInnerForm_symm e g v w + · intro g v hv + exact rightInnerForm_pos e g v hv + · intro g + exact ((rightInnerForm e g).continuous.clm_apply continuous_id).continuousAt + · intro g + exact rightInnerForm_isVonNBounded e g + +omit [IsScalarTower ℚ ℝ L] in +theorem basisChart_mem_source (x y : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + y ∈ (chartAt (ι → ℝ) x).source := by + let := basisChartedSpace (hnil := hnil) e + change y ∈ ((basisHomeomorph e).isOpenEmbedding.toOpenPartialHomeomorph (basisHomeomorph e)).source + simp + +omit [IsScalarTower ℚ ℝ L] in +theorem basis_tangentCoordChange (x y z : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e 1 + tangentCoordChange 𝓘(ℝ, ι → ℝ) x y z = ContinuousLinearMap.id ℝ (ι → ℝ) := by + let := basisChartedSpace (hnil := hnil) e + let := isManifold_basis (hnil := hnil) e 1 + apply ContinuousLinearMap.ext + intro v + change tangentCoordChange 𝓘(ℝ, ι → ℝ) x x z v = v + apply tangentCoordChange_self + rw [extChartAt_source] + exact basisChart_mem_source e x z + +omit [IsScalarTower ℚ ℝ L] in +theorem basis_tangent_trivialization (x y : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e 1 + (trivializationAt (ι → ℝ) (TangentSpace 𝓘(ℝ, ι → ℝ)) x ⟨y, v⟩).2 = v := by + let := basisChartedSpace (hnil := hnil) e + let := isManifold_basis (hnil := hnil) e 1 + change tangentCoordChange 𝓘(ℝ, ι → ℝ) y x y v = v + rw [basis_tangentCoordChange] + rfl + +omit [IsScalarTower ℚ ℝ L] in +theorem basis_tangent_symmL (x y : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e 1 + (trivializationAt (ι → ℝ) (TangentSpace 𝓘(ℝ, ι → ℝ)) x).symmL ℝ y v = v := by + let := basisChartedSpace (hnil := hnil) e + let := isManifold_basis (hnil := hnil) e 1 + rw [TangentBundle.symmL_trivializationAt_eq_core (basisChart_mem_source e x y)] + change tangentCoordChange 𝓘(ℝ, ι → ℝ) x y y v = v + rw [basis_tangentCoordChange] + rfl + +theorem contMDiff_rightInnerForm : + letI := basisChartedSpace (hnil := hnil) e + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, (ι → ℝ) →L[ℝ] (ι → ℝ) →L[ℝ] ℝ) ∞ + (rightInnerForm (hnil := hnil) e) := by + let := basisChartedSpace (hnil := hnil) e + have h := (contDiff_rightInnerForm (hnil := hnil) e).contMDiff.comp + (contMDiff_basisHomeomorph (hnil := hnil) e ∞) + simpa only [Function.comp_def, Homeomorph.symm_apply_apply] using h + +noncomputable def rightSmoothRiemannianMetric : + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e ∞ + ContMDiffRiemannianMetric 𝓘(ℝ, ι → ℝ) ∞ (ι → ℝ) + (fun g : NilpotentLieBCHGroup L s hnil => TangentSpace 𝓘(ℝ, ι → ℝ) g) := by + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e ∞ + refine + { __ := rightRiemannianMetric (hnil := hnil) e + contMDiff := ?_ } + intro x + rw [contMDiffAt_section] + convert (contMDiff_rightInnerForm (hnil := hnil) e).contMDiffAt (x := x) using 1; try rfl + funext y + ext v w + simp [hom_trivializationAt_apply, ContinuousLinearMap.inCoordinates, + rightRiemannianMetric, Trivialization.continuousLinearMapAt_apply] + have hy : y ∈ (trivializationAt (ι → ℝ) (TangentSpace 𝓘(ℝ, ι → ℝ)) x).baseSet := + basisChart_mem_source e x y + have hw : (trivializationAt (ι → ℝ) (TangentSpace 𝓘(ℝ, ι → ℝ)) x).symm y w = w := + (Trivialization.symmL_apply (R := ℝ) _ hy w).symm.trans (basis_tangent_symmL e x y w) + change rightInnerForm e y + ((trivializationAt (ι → ℝ) (TangentSpace 𝓘(ℝ, ι → ℝ)) x).symmL ℝ y v) + ((trivializationAt (ι → ℝ) (TangentSpace 𝓘(ℝ, ι → ℝ)) x).symm y w) = rightInnerForm e y v w + exact congrArg₂ (fun a b : ι → ℝ => rightInnerForm e y a b) + (basis_tangent_symmL e x y v) hw + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Set +open scoped ENNReal Topology + +theorem edist_ne_top_of_preconnected {X : Type*} [PseudoEMetricSpace X] [PreconnectedSpace X] + (x y : X) : edist x y ≠ ⊤ := by + have ho : IsOpen (Metric.eball x ⊤)ᶜ := by + apply isOpen_iff_mem_nhds.mpr + intro z hz + apply Filter.mem_of_superset (Metric.eball_mem_nhds z zero_lt_one) + intro w hw hfin + apply hz + change edist z x < ⊤ + have hzw : edist z w < ⊤ := by + have hw' : edist w z < 1 := hw + rw [edist_comm] + exact hw'.trans (by simp) + exact (edist_triangle z w x).trans_lt (ENNReal.add_lt_top.mpr ⟨hzw, hfin⟩) + have hall : Metric.eball x ⊤ = univ := + (show IsClopen (Metric.eball x ⊤) from ⟨isOpen_compl_iff.mp ho, Metric.isOpen_eball⟩).eq_univ + ⟨x, by simp⟩ + have hy : y ∈ Metric.eball x ⊤ := by rw [hall]; trivial + have hxy : edist y x < ⊤ := hy + exact (by simpa only [edist_comm] using hxy.ne) + +end Erdos3 + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Bundle +open scoped Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) + +@[instance_reducible] +noncomputable def rightRiemannianBundle : + letI := basisChartedSpace (hnil := hnil) e + RiemannianBundle (fun g : NilpotentLieBCHGroup L s hnil => TangentSpace 𝓘(ℝ, ι → ℝ) g) := by + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e ∞ + exact ⟨(rightSmoothRiemannianMetric (hnil := hnil) e).toRiemannianMetric⟩ + +theorem rightRiemannianBundle_continuous : + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e ∞ + letI := rightRiemannianBundle (hnil := hnil) e + IsContinuousRiemannianBundle (ι → ℝ) + (fun g : NilpotentLieBCHGroup L s hnil => TangentSpace 𝓘(ℝ, ι → ℝ) g) := by + let := basisChartedSpace (hnil := hnil) e + let := isManifold_basis (hnil := hnil) e ∞ + let := rightRiemannianBundle (hnil := hnil) e + exact ⟨(rightSmoothRiemannianMetric e).inner, + (rightSmoothRiemannianMetric e).contMDiff.continuous, fun _ _ _ => rfl⟩ + +@[instance_reducible] +noncomputable def rightEMetricSpace : EMetricSpace (NilpotentLieBCHGroup L s hnil) := by + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e ∞ + letI := rightRiemannianBundle (hnil := hnil) e + letI := rightRiemannianBundle_continuous (hnil := hnil) e + letI : T3Space (NilpotentLieBCHGroup L s hnil) := (basisHomeomorph e).isEmbedding.t3Space + exact EMetricSpace.ofRiemannianMetric 𝓘(ℝ, ι → ℝ) (NilpotentLieBCHGroup L s hnil) + +theorem rightEMetricSpace_topology : + (rightEMetricSpace (hnil := hnil) e).toUniformSpace.toTopologicalSpace = + (inferInstance : TopologicalSpace (NilpotentLieBCHGroup L s hnil)) := rfl + +@[instance_reducible] +noncomputable def rightMetricSpace : MetricSpace (NilpotentLieBCHGroup L s hnil) := by + letI := rightEMetricSpace (hnil := hnil) e + exact EMetricSpace.toMetricSpace edist_ne_top_of_preconnected + +theorem rightMetricSpace_topology : + (rightMetricSpace (hnil := hnil) e).toUniformSpace.toTopologicalSpace = + (inferInstance : TopologicalSpace (NilpotentLieBCHGroup L s hnil)) := rfl + +theorem rightMetricSpace_isRiemannian : + letI := basisChartedSpace (hnil := hnil) e + letI := isManifold_basis (hnil := hnil) e ∞ + letI := rightRiemannianBundle (hnil := hnil) e + letI := rightMetricSpace (hnil := hnil) e + IsRiemannianManifold 𝓘(ℝ, ι → ℝ) (NilpotentLieBCHGroup L s hnil) := by + let := basisChartedSpace (hnil := hnil) e + let := isManifold_basis (hnil := hnil) e ∞ + let := rightRiemannianBundle (hnil := hnil) e + let := rightMetricSpace (hnil := hnil) e + exact ⟨fun _ _ => rfl⟩ + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Bundle Manifold +open scoped Manifold ContDiff Bundle + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) + +theorem basis_extChartAt_apply (g x : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + extChartAt 𝓘(ℝ, ι → ℝ) g x = basisHomeomorph e x := rfl + +theorem basis_extChartAt_symm_apply (g : NilpotentLieBCHGroup L s hnil) (x : ι → ℝ) : + letI := basisChartedSpace (hnil := hnil) e + (extChartAt 𝓘(ℝ, ι → ℝ) g).symm x = (basisHomeomorph e).symm x := by + let := basisChartedSpace (hnil := hnil) e + have hs : (basisHomeomorph e).symm x ∈ (extChartAt 𝓘(ℝ, ι → ℝ) g).source := by + rw [extChartAt_source] + exact basisChart_mem_source e g _ + have h := (extChartAt 𝓘(ℝ, ι → ℝ) g).left_inv hs + rw [basis_extChartAt_apply, Homeomorph.apply_symm_apply] at h + exact h + +variable [IsScalarTower ℚ ℝ L] + +theorem mfderiv_mul_right_coordinates (g h : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + letI := basisChartedSpace (hnil := hnil) e + mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (fun x => x * h) g v = + fderiv ℝ (rightTranslate e h) (basisHomeomorph e g) v := by + let := basisChartedSpace (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e 1 + have hm : MDifferentiableAt 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (fun x => x * h) g := + contMDiff_mul_right.mdifferentiableAt one_ne_zero + rw [hm.mfderiv_abuse] + simp only [writtenInExtChartAt, Function.comp_def, basis_extChartAt_apply, + basis_extChartAt_symm_apply, modelWithCornersSelf_coe, Set.range_id, fderivWithin_univ] + rfl + +theorem enorm_mfderiv_mul_right (g h : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + ∀ v : TangentSpace 𝓘(ℝ, ι → ℝ) g, + ‖mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (fun x => x * h) g v‖ₑ = ‖v‖ₑ := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + intro v + have hn : ‖mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (fun x => x * h) g v‖ = ‖v‖ := by + rw [norm_eq_sqrt_real_inner, norm_eq_sqrt_real_inner] + congr 1 + change rightInnerForm e (g * h) + (mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (fun x => x * h) g v) + (mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (fun x => x * h) g v) = rightInnerForm e g v v + have hv := mfderiv_mul_right_coordinates e g h v + exact (congrArg₂ (fun a b : ι → ℝ => rightInnerForm e (g * h) a b) hv hv).trans + (rightInnerForm_right_invariant e g h v v) + exact enorm_eq_iff_norm_eq.mpr hn + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Bundle Manifold +open scoped Manifold ContDiff Bundle + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) + +theorem riemannianEDist_mul_right_le (x y h : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + riemannianEDist 𝓘(ℝ, ι → ℝ) (x * h) (y * h) ≤ riemannianEDist 𝓘(ℝ, ι → ℝ) x y := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e 1 + exact riemannianEDist_le_of_mfderiv_norm_le contMDiff_mul_right + (fun z v => (enorm_mfderiv_mul_right e z h v).le) x y + +theorem riemannianEDist_mul_right (x y h : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + riemannianEDist 𝓘(ℝ, ι → ℝ) (x * h) (y * h) = riemannianEDist 𝓘(ℝ, ι → ℝ) x y := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + apply le_antisymm (riemannianEDist_mul_right_le e x y h) + simpa only [mul_inv_cancel_right] using riemannianEDist_mul_right_le e (x * h) (y * h) h⁻¹ + +theorem rightMetricSpace_isometry_mul_right (h : NilpotentLieBCHGroup L s hnil) : + letI := rightMetricSpace (hnil := hnil) e + Isometry (fun x => x * h) := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + let := rightMetricSpace (hnil := hnil) e + intro x y + exact riemannianEDist_mul_right e x y h + +theorem rightMetricSpace_isIsometricSMul : + letI := rightMetricSpace (hnil := hnil) e + IsIsometricSMul (NilpotentLieBCHGroup L s hnil)ᵐᵒᵖ (NilpotentLieBCHGroup L s hnil) := by + let := rightMetricSpace (hnil := hnil) e + exact ⟨fun h => rightMetricSpace_isometry_mul_right e h.unop⟩ + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module + +noncomputable def basisCoordinateMap {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [AddCommGroup L] [Module ℝ L] [AddCommGroup M] [Module ℝ M] + (e : Basis ι ℝ L) (f : Basis κ ℝ M) (φ : L →ₗ[ℝ] M) : (ι → ℝ) →L[ℝ] (κ → ℝ) := + LinearMap.toContinuousLinearMap + (f.equivFun.toLinearMap.comp (φ.comp e.equivFun.symm.toLinearMap)) + +@[simp] theorem basisCoordinateMap_apply {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [AddCommGroup L] [Module ℝ L] [AddCommGroup M] [Module ℝ M] + (e : Basis ι ℝ L) (f : Basis κ ℝ M) (φ : L →ₗ[ℝ] M) (x : ι → ℝ) : + basisCoordinateMap e f φ x = f.equivFun (φ (e.equivFun.symm x)) := rfl + +variable {L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] [IsScalarTower ℚ ℝ M] + +def realLieHomToRat (φ : L →ₗ⁅ℝ⁆ M) : L →ₗ⁅ℚ⁆ M where + toLinearMap := φ.toLinearMap.restrictScalars ℚ + map_lie' {x y} := φ.map_lie x y + +namespace NilpotentLieBCHGroup + +variable {s t : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +noncomputable def mapReal (φ : L →ₗ⁅ℝ⁆ M) : + NilpotentLieBCHGroup L s hnil →* NilpotentLieBCHGroup M t hM := + mapOfSteps (realLieHomToRat φ) + +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + +open scoped Manifold ContDiff + +variable (e : Basis ι ℝ L) (f : Basis κ ℝ M) (φ : L →ₗ⁅ℝ⁆ M) + +theorem mapReal_basisHomeomorph (g : NilpotentLieBCHGroup L s hnil) : + basisHomeomorph f (mapReal (hM := hM) φ g) = + basisCoordinateMap e f φ.toLinearMap (basisHomeomorph e g) := by + change f.equivFun (φ g.coord) = f.equivFun (φ (e.equivFun.symm (e.equivFun g.coord))) + rw [LinearEquiv.symm_apply_apply] + +theorem mapReal_basisHomeomorph_symm (x : ι → ℝ) : + mapReal (hnil := hnil) (hM := hM) φ ((basisHomeomorph e).symm x) = + (basisHomeomorph f).symm (basisCoordinateMap e f φ.toLinearMap x) := by + apply (basisHomeomorph f).injective + rw [mapReal_basisHomeomorph e f, Homeomorph.apply_symm_apply, Homeomorph.apply_symm_apply] + +theorem contMDiff_mapReal (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + letI := basisChartedSpace (hnil := hM) f + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) n (mapReal (hnil := hnil) (hM := hM) φ) := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + apply ContMDiff.of_comp_isOpenEmbedding (basisHomeomorph f).isOpenEmbedding + have hc := (basisCoordinateMap e f φ.toLinearMap).contDiff.contMDiff.comp + (contMDiff_basisHomeomorph (hnil := hnil) e n) + convert hc using 1; try rfl + funext g + exact mapReal_basisHomeomorph e f φ g + +theorem mfderiv_mapReal_coordinates (g : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + letI := basisChartedSpace (hnil := hnil) e + letI := basisChartedSpace (hnil := hM) f + mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) (mapReal (hnil := hnil) (hM := hM) φ) g v = + basisCoordinateMap e f φ.toLinearMap v := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + have hm := (contMDiff_mapReal (hnil := hnil) (hM := hM) e f φ 1).mdifferentiableAt + (x := g) one_ne_zero + have heq : writtenInExtChartAt 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) g (mapReal (hM := hM) φ) = + basisCoordinateMap e f φ.toLinearMap := by + funext x + simp only [writtenInExtChartAt, Function.comp_apply, basis_extChartAt_apply, + basis_extChartAt_symm_apply, mapReal_basisHomeomorph e f, Homeomorph.apply_symm_apply] + rw [hm.mfderiv_abuse, heq] + simp only [modelWithCornersSelf_coe, Set.range_id, fderivWithin_univ, + ContinuousLinearMap.fderiv] + rfl + +theorem basisCoordinateMap_rightTranslate (g : NilpotentLieBCHGroup L s hnil) (x : ι → ℝ) : + basisCoordinateMap e f φ.toLinearMap (rightTranslate e g x) = + rightTranslate f (mapReal (hM := hM) φ g) (basisCoordinateMap e f φ.toLinearMap x) := by + change basisCoordinateMap e f φ.toLinearMap + (basisHomeomorph e ((basisHomeomorph e).symm x * g)) = _ + rw [← mapReal_basisHomeomorph e f φ, map_mul, mapReal_basisHomeomorph_symm e f φ] + rfl + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +variable (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : NilpotentLieBCHGroup L s hnil →* NilpotentLieBCHGroup M s hM) + +noncomputable def homCoordinates (v : ι → ℝ) : κ → ℝ := + basisHomeomorph f (φ ((basisHomeomorph e).symm v)) + +theorem homCoordinates_apply (g : NilpotentLieBCHGroup L s hnil) : + homCoordinates e f φ (basisHomeomorph e g) = basisHomeomorph f (φ g) := by + simp only [homCoordinates, Homeomorph.symm_apply_apply] + +theorem homCoordinates_rightTranslate (g : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + homCoordinates e f φ (rightTranslate e g v) = + rightTranslate f (φ g) (homCoordinates e f φ v) := by + simp only [homCoordinates, rightTranslate, Homeomorph.symm_apply_apply, map_mul] + +theorem homCoordinates_continuous (hφ : Continuous φ) : Continuous (homCoordinates e f φ) := + (basisHomeomorph f).continuous.comp (hφ.comp (basisHomeomorph e).symm.continuous) + +@[simp] theorem homCoordinates_zero : homCoordinates e f φ 0 = 0 := by + have he : (basisHomeomorph (hnil := hnil) e).symm 0 = 1 := by + apply ext + exact map_zero e.equivFun.symm + simp only [homCoordinates, he, map_one] + exact map_zero f.equivFun + +theorem basisHomeomorph_pow (g : NilpotentLieBCHGroup L s hnil) (n : ℕ) : + basisHomeomorph e (g ^ n) = n • basisHomeomorph e g := by + change e.equivFun (g ^ n).coord = n • e.equivFun g.coord + rw [coord_pow, map_nsmul] + +theorem basisHomeomorph_zpow (g : NilpotentLieBCHGroup L s hnil) (n : ℤ) : + basisHomeomorph e (g ^ n) = n • basisHomeomorph e g := by + change e.equivFun (g ^ n).coord = n • e.equivFun g.coord + rw [coord_zpow, map_zsmul] + +theorem homCoordinates_nsmul (n : ℕ) (v : ι → ℝ) : + homCoordinates e f φ (n • v) = n • homCoordinates e f φ v := by + have he : (basisHomeomorph (hnil := hnil) e).symm (n • v) = + ((basisHomeomorph e).symm v) ^ n := by + apply (basisHomeomorph e).injective + simp only [Homeomorph.apply_symm_apply, basisHomeomorph_pow] + simp only [homCoordinates, he, map_pow, basisHomeomorph_pow] + +theorem homCoordinates_zsmul (n : ℤ) (v : ι → ℝ) : + homCoordinates e f φ (n • v) = n • homCoordinates e f φ v := by + have he : (basisHomeomorph (hnil := hnil) e).symm (n • v) = + ((basisHomeomorph e).symm v) ^ n := by + apply (basisHomeomorph e).injective + simp only [Homeomorph.apply_symm_apply, basisHomeomorph_zpow] + simp only [homCoordinates, he, map_zpow, basisHomeomorph_zpow] + +theorem homCoordinates_natCast_smul (n : ℕ) (v : ι → ℝ) : + homCoordinates e f φ ((n : ℝ) • v) = (n : ℝ) • homCoordinates e f φ v := by + simpa only [Nat.cast_smul_eq_nsmul] using homCoordinates_nsmul e f φ n v + +theorem homCoordinates_intCast_smul (n : ℤ) (v : ι → ℝ) : + homCoordinates e f φ ((n : ℝ) • v) = (n : ℝ) • homCoordinates e f φ v := by + simpa only [Int.cast_smul_eq_zsmul] using homCoordinates_zsmul e f φ n v + +theorem homCoordinates_ratCast_smul (q : ℚ) (v : ι → ℝ) : + homCoordinates e f φ ((q : ℝ) • v) = (q : ℝ) • homCoordinates e f φ v := by + have hd : (q.den : ℝ) ≠ 0 := by exact_mod_cast q.den_ne_zero + have hq : (q.den : ℝ) * (q : ℝ) = (q.num : ℝ) := by + rw [Rat.cast_def] + field_simp + apply smul_right_injective (κ → ℝ) hd + dsimp only + rw [← homCoordinates_natCast_smul, smul_smul, hq, homCoordinates_intCast_smul, + smul_smul, hq] + +theorem homCoordinates_smul (hφ : Continuous φ) (t : ℝ) (v : ι → ℝ) : + homCoordinates e f φ (t • v) = t • homCoordinates e f φ v := by + have heq : (fun t : ℝ => homCoordinates e f φ (t • v)) = + fun t : ℝ => t • homCoordinates e f φ v := + (Rat.denseRange_cast : DenseRange ((↑) : ℚ → ℝ)).equalizer + ((homCoordinates_continuous e f φ hφ).comp (continuous_id.smul continuous_const)) + (continuous_id.smul continuous_const) + (funext fun q => homCoordinates_ratCast_smul e f φ q v) + exact congrFun heq t + +theorem homCoordinates_eq_fderiv (hφ : Continuous φ) + (hd : DifferentiableAt ℝ (homCoordinates e f φ) 0) (v : ι → ℝ) : + homCoordinates e f φ v = fderiv ℝ (homCoordinates e f φ) 0 v := by + have hline : HasDerivAt (fun t : ℝ => t • v) v 0 := by + simpa using (hasDerivAt_id (0 : ℝ)).smul_const v + have hD : HasFDerivAt (homCoordinates e f φ) (fderiv ℝ (homCoordinates e f φ) 0) + ((0 : ℝ) • v) := by simpa using hd.hasFDerivAt + have hcomp := hD.comp_hasDerivAt (0 : ℝ) hline + have heq : homCoordinates e f φ ∘ (fun t : ℝ => t • v) = + fun t : ℝ => t • homCoordinates e f φ v := + funext fun t => homCoordinates_smul e f φ hφ t v + rw [heq] at hcomp + have hlin : HasDerivAt (fun t : ℝ => t • homCoordinates e f φ v) + (homCoordinates e f φ v) 0 := by + simpa using (hasDerivAt_id (0 : ℝ)).smul_const (homCoordinates e f φ v) + exact hlin.unique hcomp + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (a : NilpotentLieBCHGroup L s hnil) + +include e in +theorem continuous_conjugation : Continuous ((MulAut.conj a).toMonoidHom) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + exact (continuous_const.mul continuous_id).mul continuous_const + +theorem contDiff_conjugationCoordinates (n : ℕ∞ω) : + ContDiff ℝ n (homCoordinates e e (MulAut.conj a).toMonoidHom) := by + let := basisChartedSpace (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e n + exact ((contMDiff_basisHomeomorph e n).comp + ((contMDiff_const.mul (contMDiff_basisHomeomorph_symm e n)).mul contMDiff_const)).contDiff + +noncomputable def conjugationLinearMap : (ι → ℝ) →L[ℝ] (ι → ℝ) := + fderiv ℝ (homCoordinates e e (MulAut.conj a).toMonoidHom) 0 + +theorem homCoordinates_conjugation_eq : + homCoordinates e e (MulAut.conj a).toMonoidHom = conjugationLinearMap e a := by + funext v + exact homCoordinates_eq_fderiv e e (MulAut.conj a).toMonoidHom (continuous_conjugation e a) + ((contDiff_conjugationCoordinates e a 1).differentiable one_ne_zero).differentiableAt v + +theorem conjugationLinearMap_coordinates (x : NilpotentLieBCHGroup L s hnil) : + conjugationLinearMap e a (basisHomeomorph e x) = basisHomeomorph e (a * x * a⁻¹) := by + rw [← homCoordinates_conjugation_eq, homCoordinates_apply] + rfl + +theorem conjugationLinearMap_basis [DecidableEq ι] (i k : ι) : + conjugationLinearMap e a (Pi.single i 1) k = + e.repr (a * (⟨e i⟩ : NilpotentLieBCHGroup L s hnil) * a⁻¹).coord k := by + have he : basisHomeomorph (hnil := hnil) e ⟨e i⟩ = Pi.single i 1 := by + funext j + simpa only [basisHomeomorph_apply, Pi.single_apply, eq_comm] using e.equivFun_self i j + rw [← he, conjugationLinearMap_coordinates] + rfl + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHDenominatorBudget.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHDenominatorBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..1685a30d20911ce4fe15b8c754c5a5e9b6fe6ef4 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHDenominatorBudget.lean @@ -0,0 +1,242 @@ +import OAI.Combinatorics.Progressions.Geometry.LieCoordinateHeight +import OAI.Combinatorics.Progressions.Polynomial.PolynomialDensityBudget +import OAI.Combinatorics.Progressions.Polynomial.RationalPolynomialGrid +import OAI.Combinatorics.Progressions.Sampling.ConjugationGridBudget + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + +noncomputable def bchCoordinateDenominator (e : Basis ι ℚ L) (s : ℕ) : ℕ := + polynomialFamilyDenominator (bchCoordinatePolynomial (lieStructureConstants e) s) + +theorem bchCoordinateDenominator_pos (e : Basis ι ℚ L) (s : ℕ) : + 0 < bchCoordinateDenominator e s := polynomialFamilyDenominator_pos _ + +theorem lieBCH_mem_denominatorGrid (e : Basis ι ℚ L) (s q : ℕ) (a b : L) + (ha : e.equivFun a ∈ denominatorGrid q) (hb : e.equivFun b ∈ denominatorGrid q) : + e.equivFun (lieBCH s a b) ∈ denominatorGrid (bchCoordinateDenominator e s * q ^ s) := by + have h := polynomial_family_rational_values_grid + (bchCoordinatePolynomial (lieStructureConstants e) s) q s + (bchCoordinatePolynomial_totalDegree _ s) + (fun xi : Fin 2 × ι => (![e.equivFun a, e.equivFun b] xi.1) xi.2) + (pairInput_mem_denominatorGrid (e.equivFun a) (e.equivFun b) q ha hb) + have he : (fun k => MvPolynomial.eval + (fun xi : Fin 2 × ι => (![e.equivFun a, e.equivFun b] xi.1) xi.2) + (bchCoordinatePolynomial (lieStructureConstants e) s k)) = e.equivFun (lieBCH s a b) := by + funext k + have hi : (fun xi : Fin 2 × ι => (![e.equivFun a, e.equivFun b] xi.1) xi.2) = + (fun xi : Fin 2 × ι => e.repr (![a, b] xi.1) xi.2) := by + funext xi + rcases xi with ⟨i, j⟩ + fin_cases i <;> rfl + rw [hi] + exact bchCoordinatePolynomial_eval e s a b k + rw [he] at h + exact h + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem lieCoordinateHeight_le_exp (d H n : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hd : (d : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) : + (lieCoordinateHeight d H n : ℝ) ≤ Real.exp ((p + 2) ^ (3 * n + 2)) := by + have hd2 : (d : ℝ) ^ 2 ≤ p ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg d) hd 2 + have hpexp : Real.exp p ≤ Real.exp (p ^ 2 + 1) := + Real.exp_le_exp.mpr (by nlinarith [sq_nonneg (p - 1)]) + have hsmall : (d : ℝ) ^ 2 + 2 ≤ Real.exp (p ^ 2 + 1) := by + have h := Real.add_one_le_exp (p ^ 2 + 1) + linarith + have htwo : (2 : ℝ) ≤ Real.exp 1 := by + have h := Real.add_one_le_exp (1 : ℝ) + linarith + have hbase : (d : ℝ) ^ 2 + H + 2 ≤ Real.exp ((p + 2) ^ 2) := by + calc + _ ≤ 2 * Real.exp (p ^ 2 + 1) := by linarith [hH.trans hpexp] + _ ≤ Real.exp 1 * Real.exp (p ^ 2 + 1) := + mul_le_mul_of_nonneg_right htwo (Real.exp_nonneg _) + _ = Real.exp (p ^ 2 + 2) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + have hexponent : ((2 * d ^ 2 + 2) ^ n : ℕ) ≤ (p + 2) ^ (3 * n) := by + push_cast + rw [pow_mul] + apply pow_le_pow_left₀ (by positivity) + nlinarith [pow_nonneg hp 3] + unfold lieCoordinateHeight + push_cast + calc + _ ≤ (Real.exp ((p + 2) ^ 2)) ^ ((2 * d ^ 2 + 2) ^ n) := + pow_le_pow_left₀ (by positivity) hbase _ + _ = Real.exp ((((2 * d ^ 2 + 2) ^ n : ℕ) : ℝ) * (p + 2) ^ 2) := + (Real.exp_nat_mul _ _).symm + _ ≤ Real.exp ((p + 2) ^ (3 * n) * (p + 2) ^ 2) := + Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hexponent (by positivity)) + _ = _ := by rw [pow_add] + +theorem bchCoordinateHeight_le_exp (s d H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hd : (d : ℝ) ≤ p) (hH : (H : ℝ) ≤ Real.exp p) + (hc : (bchCoefficientHeight s : ℝ) ≤ Real.exp p) + (hm : ((bchBracketSupport s).card : ℝ) ≤ p) : + (bchCoordinateHeight s d H : ℝ) ≤ Real.exp ((p + 2) ^ (3 * s + 5)) := by + have hlie := lieCoordinateHeight_le_exp d H s hp hd hH + have hpbudget : p ≤ (p + 2) ^ (3 * s + 2) := le_power_budget hp (by omega) + have hprod : ((bchCoefficientHeight s * lieCoordinateHeight d H s : ℕ) : ℝ) ≤ + Real.exp ((p + 2) ^ (3 * s + 3)) := by + push_cast + calc + _ ≤ Real.exp ((p + 2) ^ (3 * s + 2)) * Real.exp ((p + 2) ^ (3 * s + 2)) := + mul_le_mul (hc.trans (Real.exp_le_exp.mpr hpbudget)) hlie + (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = Real.exp (2 * (p + 2) ^ (3 * s + 2)) := by + rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + rw [show 3 * s + 3 = (3 * s + 2) + 1 by omega, + pow_succ (p + 2) (3 * s + 2)] + nlinarith [pow_nonneg (by linarith : 0 ≤ p + 2) (3 * s + 2)] + have hcard : ((bchBracketSupport s).card : ℝ) ≤ (p + 2) ^ 1 := by + rw [pow_one] + linarith + exact rational_sum_cost_le_exp (bchBracketSupport s).card + (bchCoefficientHeight s * lieCoordinateHeight d H s) hp (3 * s + 3) 1 hprod hcard + +theorem exists_bchCoordinateHeight_exp_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (d H : ℕ) (p : ℝ), 0 ≤ p → (d : ℝ) ≤ p → + (H : ℝ) ≤ Real.exp p → + (bchCoordinateHeight s d H : ℝ) ≤ Real.exp ((p + C) ^ C) := by + let C := bchCoefficientHeight s + (bchBracketSupport s).card + 3 * s + 7 + refine ⟨C, by dsimp [C]; omega, ?_⟩ + intro d H p hp hd hH + let q : ℝ := p + bchCoefficientHeight s + (bchBracketSupport s).card + have hpq : p ≤ q := by + dsimp [q] + linarith [Nat.cast_nonneg (α := ℝ) (bchCoefficientHeight s), + Nat.cast_nonneg (α := ℝ) (bchBracketSupport s).card] + have hq : 0 ≤ q := hp.trans hpq + have hc : (bchCoefficientHeight s : ℝ) ≤ Real.exp q := by + have h := Real.add_one_le_exp q + dsimp [q] + dsimp [q] at h + linarith [Nat.cast_nonneg (α := ℝ) (bchBracketSupport s).card] + have hm : ((bchBracketSupport s).card : ℝ) ≤ q := by + dsimp [q] + linarith [Nat.cast_nonneg (α := ℝ) (bchCoefficientHeight s)] + have hbound := bchCoordinateHeight_le_exp s d H hq (hd.trans hpq) + (hH.trans (Real.exp_le_exp.mpr hpq)) hc hm + apply hbound.trans + apply Real.exp_le_exp.mpr + have hbase : q + 2 ≤ p + C := by + dsimp [q, C] + push_cast + nlinarith + calc + (q + 2) ^ (3 * s + 5) ≤ (p + C) ^ (3 * s + 5) := + pow_le_pow_left₀ (by linarith) hbase _ + _ ≤ (p + C) ^ C := pow_le_pow_right₀ (by linarith) (by dsimp [C]; omega) + +theorem exists_bch_coordinate_polynomials_exp_height (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Module.Basis ι ℚ L) (H : ℕ) (p : ℝ), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + ∃ P : ι → MvPolynomial (Fin 2 × ι) ℚ, + (∀ (a b : L) k, + MvPolynomial.aeval (fun xi : Fin 2 × ι => e.repr (![a, b] xi.1) xi.2) (P k) = + e.repr (lieBCH s a b) k) ∧ + (∀ k, (P k).totalDegree ≤ s) ∧ + ∀ k m, (((P k).coeff m).num.natAbs : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (((P k).coeff m).den : ℝ) ≤ Real.exp ((p + C) ^ C) := by + obtain ⟨C, hC, hbudget⟩ := exists_bchCoordinateHeight_exp_budget s + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ e H p hp hd hH hc + refine ⟨bchCoordinatePolynomial (lieStructureConstants e) s, + bchCoordinatePolynomial_eval e s, bchCoordinatePolynomial_totalDegree _ s, ?_⟩ + intro k m + have hheight := bchCoordinatePolynomial_height (lieStructureConstants e) hc s k m + have hbound := hbudget (Fintype.card ι) H p hp hd hH + constructor + · exact (Nat.cast_le.mpr hheight.1).trans hbound + · exact (Nat.cast_le.mpr hheight.2).trans hbound + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_bchCoordinateDenominator_exp_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (H : ℕ) (p : ℝ), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + (bchCoordinateDenominator e s : ℝ) ≤ Real.exp ((p + C) ^ C) := by + obtain ⟨c, _, hc⟩ := exists_bchCoordinateHeight_exp_budget s + let R : Polynomial ℕ := + (2 * Polynomial.X + (Polynomial.X + Polynomial.C c) ^ c + Polynomial.C (s + 3)) ^ (s + 3) + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget R + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ e H p hp hd hH hstructure + let q : ℝ := 2 * p + (p + c) ^ c + have hpower : 0 ≤ (p + c) ^ c := by positivity + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by dsimp [q]; linarith + have hheight := hc (Fintype.card ι) H p hp hd hH + have hcoeff : ∀ i α, (((bchCoordinatePolynomial (lieStructureConstants e) s i).coeff α).den : ℝ) ≤ + Real.exp q := by + intro i α + exact (Nat.cast_le.mpr (bchCoordinatePolynomial_height (lieStructureConstants e) hstructure s i α).2).trans + (hheight.trans (Real.exp_le_exp.mpr (by dsimp [q]; linarith))) + have hinputs : (Fintype.card (Fin 2 × ι) : ℝ) ≤ q := by + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul, Nat.cast_ofNat] + dsimp [q] + linarith + have hD := polynomialFamilyDenominator_degree_budget (bchCoordinatePolynomial (lieStructureConstants e) s) + s (bchCoordinatePolynomial_totalDegree _ s) hq (hd.trans hpq) hinputs hcoeff + have hpoly : (q + (s + 3)) ^ (s + 3) ≤ (p + C) ^ C := by + simpa [R, q, Polynomial.eval₂_pow] using hbound p hp + exact hD.trans (Real.exp_le_exp.mpr hpoly) + +theorem exists_bch_rational_closure (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (H : ℕ) (p : ℝ), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + ∀ q : ℕ, 0 < q → (q : ℝ) ≤ Real.exp p → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ q ∣ m ∧ + ∀ a b : L, e.equivFun a ∈ denominatorGrid q → e.equivFun b ∈ denominatorGrid q → + e.equivFun (lieBCH s a b) ∈ denominatorGrid m := by + obtain ⟨K, _, hK⟩ := exists_bchCoordinateDenominator_exp_budget s + refine ⟨K + s + 5, by omega, ?_⟩ + intro ι L _ _ _ e H p hp hd hH hstructure q hq hqp + let D := bchCoordinateDenominator e s + let m := q * D * q ^ s + have hD : 0 < D := bchCoordinateDenominator_pos e s + have hqm : q ∣ m := ⟨D * q ^ s, Nat.mul_assoc q D (q ^ s)⟩ + have hDm : D * q ^ s ∣ m := ⟨q, + (Nat.mul_assoc q D (q ^ s)).trans (Nat.mul_comm q (D * q ^ s))⟩ + refine ⟨m, Nat.mul_pos (Nat.mul_pos hq hD) (pow_pos hq _), ?_, hqm, ?_⟩ + · simpa only [Nat.cast_add, Nat.cast_ofNat] using conjugation_grid_allowance_le_exp K s q D q hp hqp + (hK e H p hp hd hH hstructure) hqp + · intro a b ha hb + exact denominatorGrid_subset_of_dvd hDm (lieBCH_mem_denominatorGrid e s q a b ha hb) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHLatticeImageGap.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHLatticeImageGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..0790a1c1df50c2486ef7e6bdf7b4d88d294d1d5c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHLatticeImageGap.lean @@ -0,0 +1,942 @@ +import Mathlib.Analysis.Calculus.Deriv.Comp +import Mathlib.Analysis.Calculus.Deriv.Mul +import OAI.Combinatorics.Progressions.Geometry.RiemannianLocalCoordinates +import OAI.Combinatorics.Progressions.Linear.BasisCoordinateBounds +import OAI.Combinatorics.Progressions.Nilpotent.BCHQuotientChart + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped ContDiff + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] [IsScalarTower ℚ ℝ M] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + {s t : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +theorem rightVelocity_mapReal (e : Basis ι ℝ L) (f : Basis κ ℝ M) (φ : L →ₗ⁅ℝ⁆ M) + (g : NilpotentLieBCHGroup L s hnil) : + (rightVelocity f (mapReal (hM := hM) φ g)).comp (basisCoordinateMap e f φ.toLinearMap) = + (basisCoordinateMap e f φ.toLinearMap).comp (rightVelocity e g) := by + let A := basisCoordinateMap e f φ.toLinearMap + have hc : rightTranslate f (mapReal (hM := hM) φ g⁻¹) ∘ A = A ∘ rightTranslate e g⁻¹ := by + funext x + exact (basisCoordinateMap_rightTranslate e f φ g⁻¹ x).symm + have hi := (contDiff_rightTranslate e g⁻¹ 1).differentiable (by decide) + have ho := (contDiff_rightTranslate f (mapReal (hM := hM) φ g⁻¹) 1).differentiable (by decide) + have hd := congrArg (fun F : (ι → ℝ) → (κ → ℝ) => fderiv ℝ F (basisHomeomorph e g)) hc + rw [fderiv_comp _ ho.differentiableAt A.differentiableAt, + fderiv_comp _ A.differentiableAt hi.differentiableAt, + ContinuousLinearMap.fderiv, ContinuousLinearMap.fderiv] at hd + dsimp only [A] at hd + rw [← mapReal_basisHomeomorph e f φ, map_inv] at hd + exact hd + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Manifold +open scoped Manifold ContDiff Bundle NNReal ENNReal + +section Norm + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem norm_tangent_eq_coordinateL2Norm (e : Basis ι ℝ L) (g : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + ∀ v : TangentSpace 𝓘(ℝ, ι → ℝ) g, ‖v‖ = coordinateL2Norm (rightVelocity e g v) := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + intro v + rw [norm_eq_sqrt_real_inner] + change Real.sqrt (rightInnerForm e g v v) = _ + simpa only [coordinateL2Norm, pow_two] using + congrArg Real.sqrt (rightInnerForm_apply e g v v) + +end Norm + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] [IsScalarTower ℚ ℝ M] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + {s t : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +variable (e : Basis ι ℝ L) (f : Basis κ ℝ M) (φ : L →ₗ⁅ℝ⁆ M) + +theorem norm_mfderiv_mapReal_le {C : ℝ} + (hA : ∀ w, coordinateL2Norm (basisCoordinateMap e f φ.toLinearMap w) ≤ C * coordinateL2Norm w) + (g : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + letI := basisChartedSpace (hnil := hM) f + letI := rightRiemannianBundle (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hM) f + ∀ v : TangentSpace 𝓘(ℝ, ι → ℝ) g, + ‖mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) (mapReal (hM := hM) φ) g v‖ ≤ C * ‖v‖ := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + let := rightRiemannianBundle (hnil := hnil) e + let := rightRiemannianBundle (hnil := hM) f + intro v + have hv := mfderiv_mapReal_coordinates (hM := hM) e f φ g v + have hc := congrArg (fun T : (ι → ℝ) →L[ℝ] (κ → ℝ) => T v) + (rightVelocity_mapReal (hM := hM) e f φ g) + have hvel := (congrArg (fun w : κ → ℝ => rightVelocity f (mapReal (hM := hM) φ g) w) hv).trans hc + calc + ‖mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) (mapReal (hM := hM) φ) g v‖ = + coordinateL2Norm (rightVelocity f (mapReal (hM := hM) φ g) + (mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) (mapReal (hM := hM) φ) g v)) := + norm_tangent_eq_coordinateL2Norm f _ _ + _ = coordinateL2Norm (basisCoordinateMap e f φ.toLinearMap (rightVelocity e g v)) := + congrArg coordinateL2Norm hvel + _ ≤ C * coordinateL2Norm (rightVelocity e g v) := hA _ + _ = C * ‖v‖ := congrArg (C * ·) (norm_tangent_eq_coordinateL2Norm e g v).symm + +theorem lipschitz_mapReal_of_coordinate_bound {C : ℝ≥0} (hC : 0 < C) + (hA : ∀ w, coordinateL2Norm (basisCoordinateMap e f φ.toLinearMap w) ≤ C * coordinateL2Norm w) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + LipschitzWith C (mapReal (hnil := hnil) (hM := hM) φ) := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + let := rightRiemannianBundle (hnil := hnil) e + let := rightRiemannianBundle (hnil := hM) f + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace (hnil := hM) f + apply riemannianEDist_le_mul_of_mfderiv_bound hC (contMDiff_mapReal e f φ 1) + intro g v + have h := ENNReal.ofReal_le_ofReal (norm_mfderiv_mapReal_le (hM := hM) e f φ hA g v) + simpa only [ENNReal.ofReal_mul (NNReal.coe_nonneg C), ofReal_norm, + ENNReal.ofReal_coe_nnreal] using h + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s t : ℕ} (e : Basis ι ℝ L) + (hs : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (ht : LieModule.lowerCentralSeries ℚ L L t = ⊥) + +theorem lipschitz_changeStep : + letI := rightMetricSpace (hnil := hs) e + letI := rightMetricSpace (hnil := ht) e + LipschitzWith 1 (changeStep hs ht) := by + apply lipschitz_mapReal_of_coordinate_bound (hnil := hs) (hM := ht) + e e (LieHom.id : L →ₗ⁅ℝ⁆ L) (by norm_num : (0 : ℝ≥0) < 1) + intro w + change coordinateL2Norm (e.equivFun (e.equivFun.symm w)) ≤ 1 * coordinateL2Norm w + rw [LinearEquiv.apply_symm_apply, one_mul] + +theorem isometry_changeStep : + letI := rightMetricSpace (hnil := hs) e + letI := rightMetricSpace (hnil := ht) e + Isometry (changeStep hs ht) := by + let := rightMetricSpace (hnil := hs) e + let := rightMetricSpace (hnil := ht) e + apply Isometry.of_dist_eq + intro x y + apply le_antisymm + · simpa only [NNReal.coe_one, one_mul] using (lipschitz_changeStep e hs ht).dist_le_mul x y + · have h := (lipschitz_changeStep e ht hs).dist_le_mul (changeStep hs ht x) (changeStep hs ht y) + rw [show changeStep ht hs (changeStep hs ht x) = x from rfl, + show changeStep ht hs (changeStep hs ht y) = y from rfl] at h + simpa only [NNReal.coe_one, one_mul] using h + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Manifold +open scoped Manifold ContDiff Bundle NNReal ENNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem rightTranslate_fderiv_zero_rightVelocity (e : Basis ι ℝ L) + (g : NilpotentLieBCHGroup L s hnil) : + (fderiv ℝ (rightTranslate e g) 0).comp (rightVelocity e g) = + ContinuousLinearMap.id ℝ (ι → ℝ) := by + have h := rightTranslate_fderiv_leftInverse e g⁻¹ (basisHomeomorph e g) + rw [rightTranslate_coordinates, mul_inv_cancel] at h + simpa only [inv_inv, rightTranslate_coordinates, mul_inv_cancel, basisHomeomorph_apply, + coord_one, map_zero, rightVelocity] using h + +theorem coordinate_norm_le_rightVelocity (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (g : NilpotentLieBCHGroup L s hnil) (B : ℝ) (hB : 1 ≤ B) + (hg : ∀ i, |e.repr g.coord i| ≤ B) (v : ι → ℝ) : + ‖v‖ ≤ bchBoxCoordinateBound s (Fintype.card ι) H B * coordinateL2Norm (rightVelocity e g v) := by + have h := congrArg (fun A : (ι → ℝ) →L[ℝ] (ι → ℝ) => A v) + (rightTranslate_fderiv_zero_rightVelocity e g) + simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.id_apply] at h + calc + ‖v‖ = ‖fderiv ℝ (rightTranslate e g) 0 (rightVelocity e g v)‖ := congrArg norm h.symm + _ ≤ ‖fderiv ℝ (rightTranslate e g) 0‖ * ‖rightVelocity e g v‖ := + ContinuousLinearMap.le_opNorm _ _ + _ ≤ bchBoxCoordinateBound s (Fintype.card ι) H B * coordinateL2Norm (rightVelocity e g v) := + mul_le_mul (norm_fderiv_rightTranslate_zero_le e c hstructure hc g B hB hg) + (norm_le_coordinateL2Norm _) (norm_nonneg _) (bchBoxCoordinateBound_nonneg _ _ _ (by linarith)) + +omit [IsScalarTower ℚ ℝ L] in +theorem mfderiv_basisHomeomorph_coordinates (e : Basis ι ℝ L) + (g : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + letI := basisChartedSpace (hnil := hnil) e + mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (basisHomeomorph e) g v = v := by + let := basisChartedSpace (hnil := hnil) e + have hm := (contMDiff_basisHomeomorph (hnil := hnil) e 1).mdifferentiableAt (x := g) one_ne_zero + have heq : writtenInExtChartAt 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) g (basisHomeomorph e) = id := by + funext x + simp only [writtenInExtChartAt, Function.comp_apply, basis_extChartAt_symm_apply, + extChartAt_model_space_eq_id, Homeomorph.apply_symm_apply, id_eq] + rfl + rw [hm.mfderiv_abuse, heq] + simp only [modelWithCornersSelf_coe, Set.range_id, fderivWithin_univ, fderiv_id] + rfl + +theorem norm_mfderiv_basisHomeomorph_le (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (g : NilpotentLieBCHGroup L s hnil) (B : ℝ) (hB : 1 ≤ B) + (hg : ∀ i, |e.repr g.coord i| ≤ B) : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + ∀ v : TangentSpace 𝓘(ℝ, ι → ℝ) g, + ‖tangentModelVector (mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (basisHomeomorph e) g v)‖ ≤ + bchBoxCoordinateBound s (Fintype.card ι) H B * ‖v‖ := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + intro v + have hcoords : tangentModelVector + (mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) (basisHomeomorph e) g v) = tangentModelVector v := + mfderiv_basisHomeomorph_coordinates e g v + apply (congrArg norm hcoords).le.trans + exact (coordinate_norm_le_rightVelocity e c hstructure hc g B hB hg v).trans_eq + (congrArg (bchBoxCoordinateBound s (Fintype.card ι) H B * ·) + (norm_tangent_eq_coordinateL2Norm e g v).symm) + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Manifold +open scoped Manifold ContDiff Bundle + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def coordinateLine (e : Basis ι ℝ L) (v : ι → ℝ) (t : ℝ) : + NilpotentLieBCHGroup L s hnil := (basisHomeomorph e).symm (t • v) + +variable (e : Basis ι ℝ L) (v : ι → ℝ) + +@[simp] theorem coordinateLine_zero : coordinateLine (hnil := hnil) e v 0 = 1 := by + apply ext + change e.equivFun.symm ((0 : ℝ) • v) = 0 + simp only [zero_smul, map_zero] + +@[simp] theorem coordinateLine_one : + coordinateLine (hnil := hnil) e v 1 = (basisHomeomorph e).symm v := by + simp only [coordinateLine, one_smul] + +theorem contMDiff_coordinateLine (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + ContMDiff 𝓘(ℝ) 𝓘(ℝ, ι → ℝ) n (coordinateLine (hnil := hnil) e v) := by + let := basisChartedSpace (hnil := hnil) e + exact (contMDiff_basisHomeomorph_symm e n).comp (contMDiff_id.smul contMDiff_const) + +theorem rightTranslate_coordinateLine_inv (t u : ℝ) : + rightTranslate e (coordinateLine (hnil := hnil) e v t)⁻¹ (u • v) = (u - t) • v := by + change e.equivFun (lieBCH s (e.equivFun.symm (u • v)) (-e.equivFun.symm (t • v))) = _ + rw [map_smul, map_smul, lieBCH_eq_add_of_lie_eq_zero hnil (by simp [smul_lie, lie_smul])] + simp only [map_add, map_neg, map_smul, LinearEquiv.apply_symm_apply, sub_eq_add_neg, add_smul, neg_smul] + +variable [IsScalarTower ℚ ℝ L] + +theorem rightVelocity_coordinateLine (t : ℝ) : + rightVelocity e (coordinateLine (hnil := hnil) e v t) v = v := by + have hl : HasDerivAt (fun u : ℝ => u • v) v t := by + simpa using (hasDerivAt_id t).smul_const v + have hr := ((contDiff_rightTranslate e (coordinateLine (hnil := hnil) e v t)⁻¹ 1).differentiable + one_ne_zero).differentiableAt (x := t • v) |>.hasFDerivAt + have hcomp := hr.comp_hasDerivAt t hl + have heq : rightTranslate e (coordinateLine (hnil := hnil) e v t)⁻¹ ∘ (fun u : ℝ => u • v) = + fun u : ℝ => (u - t) • v := funext (rightTranslate_coordinateLine_inv e v t) + rw [heq] at hcomp + have hd : HasDerivAt (fun u : ℝ => (u - t) • v) v t := by + simpa using ((hasDerivAt_id t).sub_const t).smul_const v + simpa only [rightVelocity, coordinateLine, Homeomorph.apply_symm_apply] using hcomp.unique hd + +omit [IsScalarTower ℚ ℝ L] in +theorem mfderiv_coordinateLine (t : ℝ) : + letI := basisChartedSpace (hnil := hnil) e + mfderiv 𝓘(ℝ) 𝓘(ℝ, ι → ℝ) (coordinateLine (hnil := hnil) e v) t 1 = v := by + let := basisChartedSpace (hnil := hnil) e + have hm := (contMDiff_coordinateLine (hnil := hnil) e v 1).mdifferentiableAt (x := t) one_ne_zero + have heq : writtenInExtChartAt 𝓘(ℝ) 𝓘(ℝ, ι → ℝ) t (coordinateLine (hnil := hnil) e v) = + fun u : ℝ => u • v := by + funext u + simp [writtenInExtChartAt, coordinateLine] + rfl + rw [hm.mfderiv_abuse, heq] + simp only [modelWithCornersSelf_coe, Set.range_id, fderivWithin_univ] + change deriv (fun u : ℝ => u • v) t = v + exact (show HasDerivAt (fun u : ℝ => u • v) v t by + simpa using (hasDerivAt_id t).smul_const v).deriv + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Manifold +open scoped Manifold ContDiff Bundle NNReal ENNReal + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +variable (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : NilpotentLieBCHGroup L s hnil →* NilpotentLieBCHGroup M s hM) + (A : (ι → ℝ) →L[ℝ] (κ → ℝ)) (hA : homCoordinates e f φ = A) + +include hA + +theorem linear_hom_basisHomeomorph (g : NilpotentLieBCHGroup L s hnil) : + basisHomeomorph f (φ g) = A (basisHomeomorph e g) := by + rw [← homCoordinates_apply e f φ, hA] + +theorem contMDiff_linear_hom (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + letI := basisChartedSpace (hnil := hM) f + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) n φ := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + apply ContMDiff.of_comp_isOpenEmbedding (basisHomeomorph f).isOpenEmbedding + have hc := A.contDiff.contMDiff.comp (contMDiff_basisHomeomorph (hnil := hnil) e n) + convert hc using 1; try rfl + funext g + exact linear_hom_basisHomeomorph e f φ A hA g + +theorem mfderiv_linear_hom_coordinates (g : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + letI := basisChartedSpace (hnil := hnil) e + letI := basisChartedSpace (hnil := hM) f + mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) φ g v = A v := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + have hm := (contMDiff_linear_hom e f φ A hA 1).mdifferentiableAt (x := g) one_ne_zero + have heq : writtenInExtChartAt 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) g φ = A := by + funext x + simpa only [writtenInExtChartAt, Function.comp_apply, basis_extChartAt_apply, + basis_extChartAt_symm_apply, homCoordinates] using congrFun hA x + rw [hm.mfderiv_abuse, heq] + simp only [modelWithCornersSelf_coe, Set.range_id, fderivWithin_univ, ContinuousLinearMap.fderiv] + rfl + +variable [IsScalarTower ℚ ℝ L] [IsScalarTower ℚ ℝ M] + +theorem rightVelocity_linear_hom (g : NilpotentLieBCHGroup L s hnil) : + (rightVelocity f (φ g)).comp A = A.comp (rightVelocity e g) := by + have hc : rightTranslate f (φ g⁻¹) ∘ A = A ∘ rightTranslate e g⁻¹ := by + funext v + have h := homCoordinates_rightTranslate e f φ g⁻¹ v + rw [hA] at h + exact h.symm + have hi := (contDiff_rightTranslate e g⁻¹ 1).differentiable (by decide) + have ho := (contDiff_rightTranslate f (φ g⁻¹) 1).differentiable (by decide) + have hd := congrArg (fun F : (ι → ℝ) → (κ → ℝ) => fderiv ℝ F (basisHomeomorph e g)) hc + rw [fderiv_comp _ ho.differentiableAt A.differentiableAt, + fderiv_comp _ A.differentiableAt hi.differentiableAt, + ContinuousLinearMap.fderiv, ContinuousLinearMap.fderiv] at hd + rw [← linear_hom_basisHomeomorph e f φ A hA, map_inv] at hd + exact hd + +theorem norm_mfderiv_linear_hom_le {C : ℝ} + (hbound : ∀ w, coordinateL2Norm (A w) ≤ C * coordinateL2Norm w) + (g : NilpotentLieBCHGroup L s hnil) : + letI := basisChartedSpace (hnil := hnil) e + letI := basisChartedSpace (hnil := hM) f + letI := rightRiemannianBundle (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hM) f + ∀ v : TangentSpace 𝓘(ℝ, ι → ℝ) g, + ‖mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) φ g v‖ ≤ C * ‖v‖ := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + let := rightRiemannianBundle (hnil := hnil) e + let := rightRiemannianBundle (hnil := hM) f + intro v + have hv := mfderiv_linear_hom_coordinates e f φ A hA g v + have hc := congrArg (fun T : (ι → ℝ) →L[ℝ] (κ → ℝ) => T v) + (rightVelocity_linear_hom e f φ A hA g) + have hvel := (congrArg (fun w : κ → ℝ => rightVelocity f (φ g) w) hv).trans hc + calc + _ = coordinateL2Norm (rightVelocity f (φ g) + (mfderiv 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) φ g v)) := norm_tangent_eq_coordinateL2Norm f _ _ + _ = coordinateL2Norm (A (rightVelocity e g v)) := congrArg coordinateL2Norm hvel + _ ≤ C * coordinateL2Norm (rightVelocity e g v) := hbound _ + _ = C * ‖v‖ := congrArg (C * ·) (norm_tangent_eq_coordinateL2Norm e g v).symm + +theorem lipschitz_linear_hom {C : ℝ≥0} (hC : 0 < C) + (hbound : ∀ w, coordinateL2Norm (A w) ≤ C * coordinateL2Norm w) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + LipschitzWith C φ := by + let := basisChartedSpace (hnil := hnil) e + let := basisChartedSpace (hnil := hM) f + let := rightRiemannianBundle (hnil := hnil) e + let := rightRiemannianBundle (hnil := hM) f + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace (hnil := hM) f + apply riemannianEDist_le_mul_of_mfderiv_bound hC (contMDiff_linear_hom e f φ A hA 1) + intro g v + have h := ENNReal.ofReal_le_ofReal (norm_mfderiv_linear_hom_le e f φ A hA hbound g v) + simpa only [ENNReal.ofReal_mul (NNReal.coe_nonneg C), ofReal_norm, + ENNReal.ofReal_coe_nnreal] using h + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def bchLogMetricConstant (s d H : ℕ) (B : ℝ≥0) : ℝ≥0 := + ⟨bchBoxCoordinateBound s d H B + 1, + add_nonneg (bchBoxCoordinateBound_nonneg _ _ _ B.coe_nonneg) zero_le_one⟩ + +theorem bchLogMetricConstant_pos (s d H : ℕ) (B : ℝ≥0) : 0 < bchLogMetricConstant s d H B := by + change 0 < bchBoxCoordinateBound s d H B + 1 + have := bchBoxCoordinateBound_nonneg s d H B.coe_nonneg + linarith + +namespace NilpotentLieBCHGroup + +open Module Manifold +open scoped Manifold ContDiff Bundle ENNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem edist_coordinates_le_of_near_one (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (B : ℝ≥0) (hB : 1 ≤ B) (g : NilpotentLieBCHGroup L s hnil) : + letI := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H B + (C : ℝ≥0∞) * edist 1 g < B → + edist (basisHomeomorph (hnil := hnil) e 1) (basisHomeomorph e g) ≤ C * edist 1 g := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + let := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H B + dsimp only + intro hnear + apply coordinate_edist_le_of_riemannianEDist_lt (bchLogMetricConstant_pos s (Fintype.card ι) H B) + (contMDiff_basisHomeomorph e 1) 1 g ?_ hnear + intro z hz v + have hznorm : ‖basisHomeomorph e z‖ ≤ B := by + simpa only [Metric.mem_closedBall, basisHomeomorph_apply, coord_one, map_zero, + dist_zero_right] using hz + have hzbox (i) : |e.repr z.coord i| ≤ B := by + have hi := (norm_le_pi_norm (basisHomeomorph e z) i).trans hznorm + simpa only [basisHomeomorph_apply, Basis.equivFun_apply, Real.norm_eq_abs] using hi + have hv := norm_mfderiv_basisHomeomorph_le e c hstructure hc z B hB hzbox v + have hAC : bchBoxCoordinateBound s (Fintype.card ι) H B ≤ (C : ℝ) := by + change bchBoxCoordinateBound s (Fintype.card ι) H B ≤ bchBoxCoordinateBound s (Fintype.card ι) H B + 1 + linarith + have hv' := hv.trans (mul_le_mul_of_nonneg_right hAC (norm_nonneg v)) + simpa only [ENNReal.ofReal_mul C.coe_nonneg, ofReal_norm, ENNReal.ofReal_coe_nnreal] using + ENNReal.ofReal_le_ofReal hv' + +theorem norm_coordinates_le_of_near_one (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (B : ℝ≥0) (hB : 1 ≤ B) (g : NilpotentLieBCHGroup L s hnil) : + letI := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H B + (C : ℝ) * dist 1 g < B → ‖basisHomeomorph e g‖ ≤ C * dist 1 g := by + let := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H B + dsimp only + intro hnear + have hBpos : (0 : ℝ) < B := lt_of_lt_of_le zero_lt_one hB + have hnearE : (C : ℝ≥0∞) * edist 1 g < B := by + have h : ENNReal.ofReal ((C : ℝ) * dist 1 g) < ENNReal.ofReal (B : ℝ) := + (ENNReal.ofReal_lt_ofReal_iff hBpos).mpr hnear + rw [ENNReal.ofReal_mul C.coe_nonneg, ENNReal.ofReal_coe_nnreal, ENNReal.ofReal_coe_nnreal] at h + simpa only [edist_dist] using h + have h := edist_coordinates_le_of_near_one e c hstructure hc B hB g hnearE + have hr := ENNReal.toReal_mono (ENNReal.mul_ne_top ENNReal.coe_ne_top (edist_ne_top 1 g)) h + simpa only [ENNReal.toReal_mul, ENNReal.coe_toReal, edist_dist, ENNReal.toReal_ofReal dist_nonneg, + basisHomeomorph_apply, coord_one, map_zero, dist_zero_left, + ENNReal.toReal_ofReal (norm_nonneg _)] using hr + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def bchInverseBoxConstant (s d H : ℕ) (B : ℝ≥0) : ℝ≥0 := + (⟨bchBoxCoordinateBound s d H B, bchBoxCoordinateBound_nonneg _ _ _ B.coe_nonneg⟩ + 2 * B) * + bchLogMetricConstant s d H 1 + +namespace NilpotentLieBCHGroup + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dist_coordinates_le_bchInverseBoxConstant + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (B : ℝ≥0) (hB : 1 ≤ B) (g h : NilpotentLieBCHGroup L s hnil) + (hg : ∀ i, |e.repr g.coord i| ≤ B) (hh : ∀ i, |e.repr h.coord i| ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + dist (basisHomeomorph e g) (basisHomeomorph e h) ≤ + bchInverseBoxConstant s (Fintype.card ι) H B * dist g h := by + let := rightMetricSpace (hnil := hnil) e + let A := bchBoxCoordinateBound s (Fintype.card ι) H B + let C := bchLogMetricConstant s (Fintype.card ι) H 1 + have hA : 0 ≤ A := bchBoxCoordinateBound_nonneg _ _ _ B.coe_nonneg + change dist (basisHomeomorph e g) (basisHomeomorph e h) ≤ + (A + 2 * (B : ℝ)) * (C : ℝ) * dist g h + by_cases hnear : (C : ℝ) * dist g h < 1 + · let z := h * g⁻¹ + have hdist : dist 1 z = dist g h := by + simpa only [mul_inv_cancel] using (rightMetricSpace_isometry_mul_right e g⁻¹).dist_eq g h + have hz : ‖basisHomeomorph e z‖ ≤ (C : ℝ) * dist g h := by + have hn : (C : ℝ) * dist 1 z < (1 : ℝ≥0) := by simpa only [hdist, NNReal.coe_one] using hnear + simpa only [hdist] using norm_coordinates_le_of_near_one e c hstructure hc 1 le_rfl z hn + have hzbox : ∀ i, |basisHomeomorph e z i| ≤ B := by + intro i + have hi : |basisHomeomorph e z i| ≤ ‖basisHomeomorph e z‖ := by + simpa only [Real.norm_eq_abs] using norm_le_pi_norm (basisHomeomorph e z) i + exact ((hi.trans hz).trans hnear.le).trans hB + have hzero : basisHomeomorph (hnil := hnil) e 1 = 0 := by + simp only [basisHomeomorph_apply, coord_one, map_zero] + have hRzero : rightTranslate e g 0 = basisHomeomorph e g := by + rw [← hzero, rightTranslate_coordinates, one_mul] + have hzg : z * g = h := by simp only [z, inv_mul_cancel_right] + have hLip := (lipschitzOn_rightTranslate_box e c hstructure hc g B hB hg).dist_le_mul + (basisHomeomorph e z) hzbox 0 + (show ∀ i, |(0 : ι → ℝ) i| ≤ (B : ℝ) by simpa only [Pi.zero_apply, abs_zero] using fun _ : ι => B.coe_nonneg) + have hfirst : dist (basisHomeomorph e g) (basisHomeomorph e h) ≤ A * ‖basisHomeomorph e z‖ := by + rw [rightTranslate_coordinates, hzg, hRzero, dist_zero_right] at hLip + simpa only [NNReal.toReal, dist_comm, A] using hLip + calc + _ ≤ A * ‖basisHomeomorph e z‖ := hfirst + _ ≤ A * ((C : ℝ) * dist g h) := mul_le_mul_of_nonneg_left hz hA + _ ≤ (A + 2 * (B : ℝ)) * ((C : ℝ) * dist g h) := + mul_le_mul_of_nonneg_right (by linarith [B.coe_nonneg]) (by positivity) + _ = _ := by ring + · have hdist : dist (basisHomeomorph e g) (basisHomeomorph e h) ≤ 2 * (B : ℝ) := by + apply (dist_pi_le_iff (by positivity)).mpr + intro i + change |e.repr g.coord i - e.repr h.coord i| ≤ _ + exact (abs_sub _ _).trans (by linarith [hg i, hh i]) + calc + _ ≤ 2 * (B : ℝ) := hdist + _ ≤ 2 * (B : ℝ) * ((C : ℝ) * dist g h) := + le_mul_of_one_le_right (by positivity) (le_of_not_gt hnear) + _ ≤ (A + 2 * (B : ℝ)) * ((C : ℝ) * dist g h) := by gcongr; linarith + _ = _ := by ring + +theorem lipschitzOn_basisHomeomorph_box + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) (B : ℝ≥0) (hB : 1 ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + LipschitzOnWith (bchInverseBoxConstant s (Fintype.card ι) H B) (basisHomeomorph (hnil := hnil) e) + {g | ∀ i, |e.repr g.coord i| ≤ B} := by + let := rightMetricSpace (hnil := hnil) e + apply LipschitzOnWith.of_dist_le_mul + intro g hg h hh + exact dist_coordinates_le_bchInverseBoxConstant e c hstructure hc B hB g h hg hh + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def bchLatticeSeparationRadius (s d H l : ℕ) : ℝ := + 1 / ((l : ℝ) + 1) / (bchLogMetricConstant s d H 1 : ℝ) + +theorem bchLatticeSeparationRadius_pos (s d H l : ℕ) : 0 < bchLatticeSeparationRadius s d H l := by + have hC : (0 : ℝ) < bchLogMetricConstant s d H 1 := bchLogMetricConstant_pos _ _ _ _ + unfold bchLatticeSeparationRadius + positivity + +namespace NilpotentLieBCHGroup + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem eq_one_of_subgroup_of_dist_lt (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ γ ∈ Γ, e.equivFun γ.coord ∈ realDenominatorGrid l) + (γ : NilpotentLieBCHGroup L s hnil) (hγ : γ ∈ Γ) : + letI := rightMetricSpace (hnil := hnil) e + dist 1 γ < bchLatticeSeparationRadius s (Fintype.card ι) H l → γ = 1 := by + let := rightMetricSpace (hnil := hnil) e + intro hsmall + let C := bchLogMetricConstant s (Fintype.card ι) H 1 + have hC : (0 : ℝ) < C := bchLogMetricConstant_pos _ _ _ _ + have hl' : (0 : ℝ) < l := by exact_mod_cast hl + have hscaled : (C : ℝ) * dist 1 γ < 1 / ((l : ℝ) + 1) := by + have h := (lt_div_iff₀ hC).mp hsmall + simpa only [mul_comm] using h + have hunit : 1 / ((l : ℝ) + 1) ≤ 1 := (div_le_one (by positivity)).mpr (by linarith) + have hn := norm_coordinates_le_of_near_one e c hstructure hc 1 le_rfl γ (hscaled.trans_le hunit) + apply eq_one_of_subgroup_grid_of_small_coordinates e Γ l hl hgrid γ hγ + intro i + have hi : |e.repr γ.coord i| ≤ ‖basisHomeomorph e γ‖ := by + simpa only [basisHomeomorph_apply, Basis.equivFun_apply, Real.norm_eq_abs] using + norm_le_pi_norm (basisHomeomorph e γ) i + exact ((hi.trans hn).trans_lt hscaled).trans (one_div_lt_one_div_of_lt hl' (by linarith)) + +theorem latticeSeparationRadius_le_dist (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ γ ∈ Γ, e.equivFun γ.coord ∈ realDenominatorGrid l) + (γ : NilpotentLieBCHGroup L s hnil) (hγ : γ ∈ Γ) (hne : γ ≠ 1) : + letI := rightMetricSpace (hnil := hnil) e + bchLatticeSeparationRadius s (Fintype.card ι) H l ≤ dist 1 γ := by + let := rightMetricSpace (hnil := hnil) e + by_contra! h + exact hne (eq_one_of_subgroup_of_dist_lt e c hstructure hc Γ l hl hgrid γ hγ h) + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem one_le_bchLogMetricConstant (s d H : ℕ) (B : ℝ≥0) : + 1 ≤ bchLogMetricConstant s d H B := by + change (1 : ℝ) ≤ bchBoxCoordinateBound s d H B + 1 + linarith [bchBoxCoordinateBound_nonneg s d H B.coe_nonneg] + +namespace NilpotentLieBCHGroup + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dist_coordinates_le_of_near_box + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (B : ℝ≥0) (hB : 1 ≤ B) (g h : NilpotentLieBCHGroup L s hnil) + (hg : ∀ i, |e.repr g.coord i| ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H 1 + (C : ℝ) * dist g h < 1 → + dist (basisHomeomorph e g) (basisHomeomorph e h) ≤ + bchBoxCoordinateBound s (Fintype.card ι) H B * C * dist g h := by + let := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H 1 + dsimp only + intro hnear + let z := h * g⁻¹ + have hdist : dist 1 z = dist g h := by + simpa only [mul_inv_cancel] using (rightMetricSpace_isometry_mul_right e g⁻¹).dist_eq g h + have hz : ‖basisHomeomorph e z‖ ≤ (C : ℝ) * dist g h := by + have hn : (C : ℝ) * dist 1 z < (1 : ℝ≥0) := by simpa only [hdist, NNReal.coe_one] using hnear + simpa only [hdist] using norm_coordinates_le_of_near_one e c hstructure hc 1 le_rfl z hn + have hzbox (i) : |basisHomeomorph e z i| ≤ B := by + have hi : |basisHomeomorph e z i| ≤ ‖basisHomeomorph e z‖ := by + simpa only [Real.norm_eq_abs] using norm_le_pi_norm (basisHomeomorph e z) i + exact ((hi.trans hz).trans hnear.le).trans hB + have hzero : basisHomeomorph (hnil := hnil) e 1 = 0 := by + simp only [basisHomeomorph_apply, coord_one, map_zero] + have hRzero : rightTranslate e g 0 = basisHomeomorph e g := by + rw [← hzero, rightTranslate_coordinates, one_mul] + have hzg : z * g = h := by simp only [z, inv_mul_cancel_right] + have hLip := (lipschitzOn_rightTranslate_box e c hstructure hc g B hB hg).dist_le_mul + (basisHomeomorph e z) hzbox 0 (by + intro i + simpa only [Pi.zero_apply, abs_zero] using B.coe_nonneg) + rw [rightTranslate_coordinates, hzg, hRzero, dist_zero_right] at hLip + calc + _ ≤ bchBoxCoordinateBound s (Fintype.card ι) H B * ‖basisHomeomorph e z‖ := by + simpa only [dist_comm, NNReal.toReal] using hLip + _ ≤ bchBoxCoordinateBound s (Fintype.card ι) H B * ((C : ℝ) * dist g h) := + mul_le_mul_of_nonneg_left hz (bchBoxCoordinateBound_nonneg s _ H B.coe_nonneg) + _ = _ := by ring + +theorem dist_coordinates_le_of_near_unit_box + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (g h : NilpotentLieBCHGroup L s hnil) (hg : ∀ i, |e.repr g.coord i| ≤ 1) : + letI := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H 1 + (C : ℝ) * dist g h < 1 → + dist (basisHomeomorph e g) (basisHomeomorph e h) ≤ (C : ℝ) ^ 2 * dist g h := by + let := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card ι) H 1 + dsimp only + intro hnear + let z := h * g⁻¹ + have hdist : dist 1 z = dist g h := by + simpa only [mul_inv_cancel] using (rightMetricSpace_isometry_mul_right e g⁻¹).dist_eq g h + have hz : ‖basisHomeomorph e z‖ ≤ (C : ℝ) * dist g h := by + have hn : (C : ℝ) * dist 1 z < (1 : ℝ≥0) := by simpa only [hdist, NNReal.coe_one] using hnear + simpa only [hdist] using norm_coordinates_le_of_near_one e c hstructure hc 1 le_rfl z hn + have hzbox (i) : |basisHomeomorph e z i| ≤ 1 := by + have hi : |basisHomeomorph e z i| ≤ ‖basisHomeomorph e z‖ := by + simpa only [Real.norm_eq_abs] using norm_le_pi_norm (basisHomeomorph e z) i + exact ((hi.trans hz).trans hnear.le) + have hzero : basisHomeomorph (hnil := hnil) e 1 = 0 := by + simp only [basisHomeomorph_apply, coord_one, map_zero] + have hRzero : rightTranslate e g 0 = basisHomeomorph e g := by + rw [← hzero, rightTranslate_coordinates, one_mul] + have hzg : z * g = h := by simp only [z, inv_mul_cancel_right] + have hLip := (lipschitzOn_rightTranslate_box e c hstructure hc g 1 le_rfl hg).dist_le_mul + (basisHomeomorph e z) hzbox 0 (by simp) + rw [rightTranslate_coordinates, hzg, hRzero, dist_zero_right] at hLip + have hAC : bchBoxCoordinateBound s (Fintype.card ι) H 1 ≤ (C : ℝ) := by + change bchBoxCoordinateBound s (Fintype.card ι) H 1 ≤ bchBoxCoordinateBound s (Fintype.card ι) H 1 + 1 + linarith + calc + _ ≤ bchBoxCoordinateBound s (Fintype.card ι) H 1 * ‖basisHomeomorph e z‖ := by + simpa only [dist_comm, NNReal.toReal] using hLip + _ ≤ (C : ℝ) * ‖basisHomeomorph e z‖ := mul_le_mul_of_nonneg_right hAC (norm_nonneg _) + _ ≤ (C : ℝ) * ((C : ℝ) * dist g h) := mul_le_mul_of_nonneg_left hz C.coe_nonneg + _ = _ := by ring + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped Matrix NNReal + +variable {ι κ L : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem rational_kernel_of_near_bounded_point + (e : Basis κ ℝ L) (c : κ → κ → κ → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Q : Matrix ι κ ℚ) (HQ B : ℝ≥0) (hB : 1 ≤ B) + (hQ : ∀ i j, |(Q i j : ℝ)| ≤ HQ) (l : ℕ) (hl : 0 < l) + (g γ : NilpotentLieBCHGroup L s hnil) + (hg : ∀ i, |e.repr g.coord i| ≤ B) + (hγ : basisHomeomorph e γ ∈ realDenominatorGrid l) + (hkernel : (fun i j => (Q i j : ℝ)) *ᵥ basisHomeomorph e g = 0) : + letI := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card κ) H 1 + let A := bchBoxCoordinateBound s (Fintype.card κ) H B + (C : ℝ) * dist g γ < 1 → + ((matrixDenominator Q * l : ℕ) : ℝ) * (((Fintype.card κ : ℝ) + 1) * (HQ + 1)) * + (A * C) * dist g γ < 1 → + (fun i j => (Q i j : ℝ)) *ᵥ basisHomeomorph e γ = 0 := by + let := rightMetricSpace (hnil := hnil) e + dsimp only + intro hnear hsmall + apply rational_matrix_kernel_separation Q HQ hQ l hl (basisHomeomorph e γ) (basisHomeomorph e g) + hγ hkernel + have hcoord := dist_coordinates_le_of_near_box e c hstructure hc B hB g γ hg hnear + rw [dist_comm] at hcoord + calc + _ ≤ ((matrixDenominator Q * l : ℕ) : ℝ) * (((Fintype.card κ : ℝ) + 1) * (HQ + 1)) * + (bchBoxCoordinateBound s (Fintype.card κ) H B * + (bchLogMetricConstant s (Fintype.card κ) H 1 : ℝ) * dist g γ) := by + exact mul_le_mul_of_nonneg_left hcoord (by positivity) + _ < 1 := by nlinarith [hsmall] + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped Matrix NNReal + +variable {ι κ L : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem lattice_translate_mem_of_small_dist + (e : Basis κ ℝ L) (c : κ → κ → κ → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Q : Matrix ι κ ℚ) (HQ B K : ℝ≥0) (hB : 1 ≤ B) + (hQ : ∀ i j, |(Q i j : ℝ)| ≤ HQ) (l : ℕ) (hl : 0 < l) + (J : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hJ : ∀ g, g ∈ J ↔ (fun i j => (Q i j : ℝ)) *ᵥ basisHomeomorph e g = 0) + (x y γ : NilpotentLieBCHGroup L s hnil) (hx : x ∈ J) (hy : y ∈ J) + (hγ : basisHomeomorph e γ ∈ realDenominatorGrid l) + (hxy : ∀ i, |e.repr (y⁻¹ * x).coord i| ≤ B) + (hleft : letI := rightMetricSpace (hnil := hnil) e; LipschitzWith K (fun z => y⁻¹ * z)) : + letI := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card κ) H 1 + let A := bchBoxCoordinateBound s (Fintype.card κ) H B + (C : ℝ) * K * dist x (y * γ) < 1 → + ((matrixDenominator Q * l : ℕ) : ℝ) * (((Fintype.card κ : ℝ) + 1) * (HQ + 1)) * + (A * C) * K * dist x (y * γ) < 1 → γ ∈ J := by + let := rightMetricSpace (hnil := hnil) e + dsimp only + intro hnear hsmall + have hdist : dist (y⁻¹ * x) γ ≤ (K : ℝ) * dist x (y * γ) := by + simpa only [inv_mul_cancel_left] using hleft.dist_le_mul x (y * γ) + apply (hJ γ).mpr + apply rational_kernel_of_near_bounded_point e c hstructure hc Q HQ B hB hQ l hl (y⁻¹ * x) γ + hxy hγ ((hJ _).mp (J.mul_mem (J.inv_mem hy) hx)) + · calc + _ ≤ (bchLogMetricConstant s (Fintype.card κ) H 1 : ℝ) * (K * dist x (y * γ)) := + mul_le_mul_of_nonneg_left hdist (NNReal.coe_nonneg _) + _ < 1 := by nlinarith [hnear] + · have hA := bchBoxCoordinateBound_nonneg s (Fintype.card κ) H B.coe_nonneg + calc + _ ≤ ((matrixDenominator Q * l : ℕ) : ℝ) * (((Fintype.card κ : ℝ) + 1) * (HQ + 1)) * + (bchBoxCoordinateBound s (Fintype.card κ) H B * + (bchLogMetricConstant s (Fintype.card κ) H 1 : ℝ)) * (K * dist x (y * γ)) := + mul_le_mul_of_nonneg_left hdist (by positivity) + _ < 1 := by nlinarith [hsmall] + +theorem exists_uniform_lattice_image_gap + (e : Basis κ ℝ L) (c : κ → κ → κ → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Q : Matrix ι κ ℚ) (HQ B K : ℝ≥0) (hB : 1 ≤ B) + (hQ : ∀ i j, |(Q i j : ℝ)| ≤ HQ) (l : ℕ) (hl : 0 < l) + (J Λ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hJ : ∀ g, g ∈ J ↔ (fun i j => (Q i j : ℝ)) *ᵥ basisHomeomorph e g = 0) + (hΛ : ∀ γ ∈ Λ, basisHomeomorph e γ ∈ realDenominatorGrid l) + (S : Set (NilpotentLieBCHGroup L s hnil)) (hS : S ⊆ J) + (hprod : ∀ x ∈ S, ∀ y ∈ S, ∀ i, |e.repr (y⁻¹ * x).coord i| ≤ B) + (hleft : letI := rightMetricSpace (hnil := hnil) e; + ∀ y ∈ S, LipschitzWith K (fun z => y⁻¹ * z)) : + letI := rightMetricSpace (hnil := hnil) e + let C := bchLogMetricConstant s (Fintype.card κ) H 1 + let A := bchBoxCoordinateBound s (Fintype.card κ) H B + ∃ ε : ℝ≥0, 0 < ε ∧ + (ε : ℝ)⁻¹ = (C : ℝ) * K + + ((matrixDenominator Q * l : ℕ) : ℝ) * (((Fintype.card κ : ℝ) + 1) * (HQ + 1)) * + (A * C) * K + 1 ∧ + ∀ x ∈ S, ∀ y ∈ S, ∀ γ ∈ Λ, dist x (y * γ) < ε → γ ∈ J := by + let := rightMetricSpace (hnil := hnil) e + let a : ℝ := (bchLogMetricConstant s (Fintype.card κ) H 1 : ℝ) * K + let b : ℝ := ((matrixDenominator Q * l : ℕ) : ℝ) * + (((Fintype.card κ : ℝ) + 1) * (HQ + 1)) * + (bchBoxCoordinateBound s (Fintype.card κ) H B * + (bchLogMetricConstant s (Fintype.card κ) H 1 : ℝ)) * K + have ha : 0 ≤ a := by dsimp [a]; positivity + have hb : 0 ≤ b := by + have := bchBoxCoordinateBound_nonneg s (Fintype.card κ) H B.coe_nonneg + dsimp [b] + positivity + have hr : 0 < a + b + 1 := by linarith + let ε : ℝ≥0 := ⟨(a + b + 1)⁻¹, (inv_pos.mpr hr).le⟩ + refine ⟨ε, show (0 : ℝ) < (a + b + 1)⁻¹ from inv_pos.mpr hr, ?_, ?_⟩ + · exact inv_inv (a + b + 1) + · intro x hx y hy γ hγ hnear + have hscaled : (a + b + 1) * dist x (y * γ) < 1 := by + have h := mul_lt_mul_of_pos_left hnear hr + change (a + b + 1) * dist x (y * γ) < (a + b + 1) * (a + b + 1)⁻¹ at h + simpa only [mul_inv_cancel₀ hr.ne'] using h + apply lattice_translate_mem_of_small_dist e c hstructure hc Q HQ B K hB hQ l hl + J hJ x y γ (hS hx) (hS hy) (hΛ γ hγ) (hprod x hx y hy) (hleft y hy) + · change a * dist x (y * γ) < 1 + nlinarith [dist_nonneg (x := x) (y := y * γ)] + · change b * dist x (y * γ) < 1 + nlinarith [dist_nonneg (x := x) (y := y * γ)] + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHNonlinearRemainder.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHNonlinearRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae0c7b552054586754f14d7c3645383a007a7887 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHNonlinearRemainder.lean @@ -0,0 +1,639 @@ +import OAI.Combinatorics.Progressions.Estimates.TruncatedSeriesFiltration +import OAI.Combinatorics.Progressions.Geometry.LieCoordinateScalarExtension + +namespace OAI + +section + +namespace Erdos3 +variable {X L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +theorem map_freeLie_lift (φ : L →ₗ⁅ℚ⁆ M) (f : X → L) (p : FreeLieAlgebra ℚ X) : + φ (FreeLieAlgebra.lift ℚ f p) = FreeLieAlgebra.lift ℚ (fun x => φ (f x)) p := by + have h : φ.comp (FreeLieAlgebra.lift ℚ f) = FreeLieAlgebra.lift ℚ (fun x => φ (f x)) := by + apply FreeLieAlgebra.hom_ext + intro x + simp + exact DFunLike.congr_fun h p + +theorem map_lieBCH (φ : L →ₗ⁅ℚ⁆ M) (s : ℕ) (a b : L) : + φ (lieBCH s a b) = lieBCH s (φ a) (φ b) := by + have hf : (fun x : Fin 2 => φ (![a, b] x)) = ![φ a, φ b] := by + funext x + fin_cases x <;> rfl + simpa only [lieBCH, hf] using map_freeLie_lift φ ![a, b] (bchLiePolynomial s) + +attribute [local instance] LieRing.ofAssociativeRing + +noncomputable def scaledFreeLieEval (s : ℕ) : + FreeLieAlgebra ℚ X →ₗ⁅ℚ⁆ TruncatedSeries (FreeAlgebra ℚ X) s := + FreeLieAlgebra.lift ℚ (scaledFreeGenerator s) + +@[simp] theorem scaledFreeLieEval_of (s : ℕ) (x : X) : + scaledFreeLieEval s (FreeLieAlgebra.of ℚ x) = scaledFreeGenerator s x := + FreeLieAlgebra.lift_of_apply _ _ + +theorem scaledFreeLieEval_eq (s : ℕ) (p : FreeLieAlgebra ℚ X) : + scaledFreeLieEval s p = truncatedSeriesMk s (freeScaleSeries (freeLieAssociativeExpansion p)) := by + have h : FreeAlgebra.lift ℚ (scaledFreeGenerator (X := X) s) = + (truncatedSeriesMk s).comp freeScaleSeries := by + apply FreeAlgebra.hom_ext + funext x + simp [scaledFreeGenerator] + change FreeLieAlgebra.lift ℚ (scaledFreeGenerator s) p = _ + rw [← freeLieAssociativeExpansion_eval, h] + rfl + +theorem lie_lift_eq_of_scaledFreeLieEval_eq (f : X → L) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) {p q : FreeLieAlgebra ℚ X} + (h : scaledFreeLieEval s p = scaledFreeLieEval s q) : + FreeLieAlgebra.lift ℚ f p = FreeLieAlgebra.lift ℚ f q := by + apply lie_lift_eq_of_scaled_series_eq f hnil + simpa only [scaledFreeLieEval_eq] using h + +end Erdos3 + +end + +section + +namespace Erdos3 +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} +attribute [local instance] LieRing.ofAssociativeRing + +theorem scaledFreeGenerator_mem_layer (s : ℕ) {X : Type*} (x : X) : + scaledFreeGenerator s x ∈ (truncatedSeriesFiltration (A := FreeAlgebra ℚ X) s).layer 1 := + truncatedSeriesLayer_one.mpr (scaledFreeGenerator_positive s x) + +theorem lieBCH_assoc (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (a b c : L) : + lieBCH s (lieBCH s a b) c = lieBCH s a (lieBCH s b c) := by + let x : Fin 3 → FreeLieAlgebra ℚ (Fin 3) := FreeLieAlgebra.of ℚ + let F := truncatedSeriesFiltration (A := FreeAlgebra ℚ (Fin 3)) s + have hx (i : Fin 3) : scaledFreeGenerator s i ∈ F.layer 1 := scaledFreeGenerator_mem_layer s i + have h : scaledFreeLieEval s (lieBCH s (lieBCH s (x 0) (x 1)) (x 2)) = + scaledFreeLieEval s (lieBCH s (x 0) (lieBCH s (x 1) (x 2))) := by + simp only [map_lieBCH, x, scaledFreeLieEval_of] + rw [F.lieBCH_eq (hx 0) (hx 1), F.lieBCH_eq (hx 1) (hx 2), + F.lieBCH_eq (F.bch_mem le_rfl (hx 0) (hx 1)) (hx 2), + F.lieBCH_eq (hx 0) (F.bch_mem le_rfl (hx 1) (hx 2))] + exact nilpotentBCH_assoc (F.layerAlgebra 1) F.positive_nilpotent (hx 0) (hx 1) (hx 2) + have he := lie_lift_eq_of_scaledFreeLieEval_eq ![a, b, c] hnil h + simpa only [map_lieBCH, x, FreeLieAlgebra.lift_of_apply, Matrix.cons_val_zero, + Matrix.cons_val_one, Matrix.cons_val, Matrix.head_cons] using he + +theorem lieBCH_zero_left (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (a : L) : + lieBCH s 0 a = a := by + let x : FreeLieAlgebra ℚ (Fin 1) := FreeLieAlgebra.of ℚ 0 + let F := truncatedSeriesFiltration (A := FreeAlgebra ℚ (Fin 1)) s + have hx : scaledFreeGenerator s (0 : Fin 1) ∈ F.layer 1 := scaledFreeGenerator_mem_layer s 0 + have h : scaledFreeLieEval s (lieBCH s 0 x) = scaledFreeLieEval s x := by + simp only [map_lieBCH, map_zero, x, scaledFreeLieEval_of] + rw [F.lieBCH_eq (F.layer 1).zero_mem hx] + exact nilpotentBCH_zero_left (F.isNilpotent_of_mem le_rfl hx) + have he := lie_lift_eq_of_scaledFreeLieEval_eq (fun _ : Fin 1 => a) hnil h + simpa only [map_lieBCH, map_zero, x, FreeLieAlgebra.lift_of_apply] using he + +theorem lieBCH_neg_left (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (a : L) : + lieBCH s (-a) a = 0 := by + let x : FreeLieAlgebra ℚ (Fin 1) := FreeLieAlgebra.of ℚ 0 + let F := truncatedSeriesFiltration (A := FreeAlgebra ℚ (Fin 1)) s + have hx : scaledFreeGenerator s (0 : Fin 1) ∈ F.layer 1 := scaledFreeGenerator_mem_layer s 0 + have h : scaledFreeLieEval s (lieBCH s (-x) x) = scaledFreeLieEval s 0 := by + simp only [map_lieBCH, map_neg, map_zero, x, scaledFreeLieEval_of] + rw [F.lieBCH_eq ((F.layer 1).neg_mem hx) hx] + exact nilpotentBCH_neg_left (F.isNilpotent_of_mem le_rfl hx) + have he := lie_lift_eq_of_scaledFreeLieEval_eq (fun _ : Fin 1 => a) hnil h + simpa only [map_lieBCH, map_neg, map_zero, x, FreeLieAlgebra.lift_of_apply] using he + +structure NilpotentLieBCHGroup (L : Type*) [LieRing L] [LieAlgebra ℚ L] (s : ℕ) + (_hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) where + coord : L + +namespace NilpotentLieBCHGroup +variable {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +@[ext] theorem ext {a b : NilpotentLieBCHGroup L s hnil} (h : a.coord = b.coord) : a = b := by + cases a + cases b + cases h + rfl + +noncomputable instance : Mul (NilpotentLieBCHGroup L s hnil) where + mul a b := ⟨lieBCH s a.coord b.coord⟩ + +instance : One (NilpotentLieBCHGroup L s hnil) where + one := ⟨0⟩ + +instance : Inv (NilpotentLieBCHGroup L s hnil) where + inv a := ⟨-a.coord⟩ + +@[simp] theorem coord_mul (a b : NilpotentLieBCHGroup L s hnil) : + (a * b).coord = lieBCH s a.coord b.coord := rfl +@[simp] theorem coord_one : (1 : NilpotentLieBCHGroup L s hnil).coord = 0 := rfl +@[simp] theorem coord_inv (a : NilpotentLieBCHGroup L s hnil) : (a⁻¹).coord = -a.coord := rfl + +noncomputable instance : Group (NilpotentLieBCHGroup L s hnil) := + Group.ofLeftAxioms + (fun a b c => ext (lieBCH_assoc hnil a.coord b.coord c.coord)) + (fun a => ext (lieBCH_zero_left hnil a.coord)) + (fun a => ext (lieBCH_neg_left hnil a.coord)) + +noncomputable def map {M : Type*} [LieRing M] [LieAlgebra ℚ M] + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} (φ : L →ₗ⁅ℚ⁆ M) : + NilpotentLieBCHGroup L s hnil →* NilpotentLieBCHGroup M s hM where + toFun a := ⟨φ a.coord⟩ + map_one' := ext (map_zero φ) + map_mul' a b := ext (map_lieBCH φ s a.coord b.coord) + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {X L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +noncomputable def lieBCHList (s : ℕ) (f : X → L) : List X → L + | [] => 0 + | x :: xs => lieBCH s (f x) (lieBCHList s f xs) + +theorem map_lieBCHList (φ : L →ₗ⁅ℚ⁆ M) (s : ℕ) (f : X → L) (xs : List X) : + φ (lieBCHList s f xs) = lieBCHList s (fun x => φ (f x)) xs := by + induction xs with + | nil => exact map_zero φ + | cons x xs ih => simp only [lieBCHList, map_lieBCH, ih] + +theorem lieBCHList_group_prod (s : ℕ) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (f : X → L) (xs : List X) : + ((xs.map (fun x => (⟨f x⟩ : NilpotentLieBCHGroup L s hnil))).prod).coord = + lieBCHList s f xs := by + induction xs with + | nil => rfl + | cons x xs ih => + simp only [List.map_cons, List.prod_cons, NilpotentLieBCHGroup.coord_mul, lieBCHList, ih] + +noncomputable def bchProductLiePolynomial (s : ℕ) (xs : List X) : FreeLieAlgebra ℚ X := + freeLieTruncation s (lieBCHList s (FreeLieAlgebra.of ℚ) xs) + +theorem bchProductLiePolynomial_eval (s : ℕ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (f : X → L) (xs : List X) : + FreeLieAlgebra.lift ℚ f (bchProductLiePolynomial s xs) = lieBCHList s f xs := by + rw [bchProductLiePolynomial, lift_freeLieTruncation f hnil, map_lieBCHList] + congr 1 + funext x + exact FreeLieAlgebra.lift_of_apply _ _ + +theorem bchProductLiePolynomial_support_length (s : ℕ) (xs : List X) + {w : FreeSemigroup X} (hw : w ∈ (freeLieWordExpansion (bchProductLiePolynomial s xs)).coeff.support) : + w.length ≤ s := freeLieTruncation_support_length s _ hw + +end Erdos3 + +end + +section + +namespace Erdos3 +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem lieBCH_mem (K : LieSubalgebra ℚ L) (s : ℕ) {a b : L} + (ha : a ∈ K) (hb : b ∈ K) : lieBCH s a b ∈ K := by + have h := map_lieBCH K.incl s (⟨a, ha⟩ : K) (⟨b, hb⟩ : K) + change ((lieBCH s (⟨a, ha⟩ : K) (⟨b, hb⟩ : K) : K) : L) = lieBCH s a b at h + rw [← h] + exact (lieBCH s (⟨a, ha⟩ : K) (⟨b, hb⟩ : K)).property + +namespace NilpotentLieBCHGroup +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +def subgroup (K : LieSubalgebra ℚ L) : Subgroup (NilpotentLieBCHGroup L s hnil) where + carrier := {a | a.coord ∈ K} + one_mem' := K.zero_mem + mul_mem' ha hb := lieBCH_mem K s ha hb + inv_mem' ha := K.neg_mem ha + +@[simp] theorem mem_subgroup (K : LieSubalgebra ℚ L) (a : NilpotentLieBCHGroup L s hnil) : + a ∈ subgroup K ↔ a.coord ∈ K := Iff.rfl + +end NilpotentLieBCHGroup + +def lieQuotientMap (I : LieIdeal ℚ L) : L →ₗ⁅ℚ⁆ L ⧸ I := + { I.toSubmodule.mkQ with map_lie' := by intro a b; rfl } + +theorem lieQuotientMap_surjective (I : LieIdeal ℚ L) : Function.Surjective (lieQuotientMap I) := + Submodule.mkQ_surjective _ + +@[simp] theorem lieQuotientMap_eq_zero (I : LieIdeal ℚ L) (a : L) : + lieQuotientMap I a = 0 ↔ a ∈ I := Submodule.Quotient.mk_eq_zero _ + +theorem lie_quotient_lowerCentralSeries_eq_bot {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (I : LieIdeal ℚ L) : + LieModule.lowerCentralSeries ℚ (L ⧸ I) (L ⧸ I) s = ⊥ := by + rw [← LieIdeal.lowerCentralSeries_map_eq s (lieQuotientMap_surjective I), hnil] + simp + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {X A : Type*} [Ring A] [Algebra ℚ A] +attribute [local instance] LieRing.ofAssociativeRing + +noncomputable def bchProductPolynomial (s : ℕ) (xs : List X) : FreeAlgebra ℚ X := + finiteLog (s + 1) + ((xs.map (fun x => finiteExp (s + 1) (FreeAlgebra.ι ℚ x))).prod - 1) + +theorem bchProductPolynomial_eval (s : ℕ) (f : X → A) (xs : List X) : + FreeAlgebra.lift ℚ f (bchProductPolynomial s xs) = + finiteLog (s + 1) ((xs.map (fun x => finiteExp (s + 1) (f x))).prod - 1) := by + simp only [bchProductPolynomial, map_finiteLog, map_sub, map_one, + map_list_prod, List.map_map, Function.comp_def, map_finiteExp, FreeAlgebra.lift_ι_apply] + +namespace NilpotentAlgebraFiltration + +variable {s : ℕ} (F : NilpotentAlgebraFiltration A s) (f : X → A) + +theorem lieBCHList_mem (hf : ∀ x, f x ∈ F.layer 1) (xs : List X) : + lieBCHList s f xs ∈ F.layer 1 := by + induction xs with + | nil => exact (F.layer 1).zero_mem + | cons x xs ih => + rw [lieBCHList, F.lieBCH_eq (hf x) ih] + exact F.bch_mem le_rfl (hf x) ih + +theorem exp_lieBCHList (hf : ∀ x, f x ∈ F.layer 1) (xs : List X) : + IsNilpotent.exp (lieBCHList s f xs) = (xs.map (fun x => IsNilpotent.exp (f x))).prod := by + induction xs with + | nil => exact IsNilpotent.exp_zero + | cons x xs ih => + rw [lieBCHList, F.lieBCH_eq (hf x) (F.lieBCHList_mem f hf xs), + exp_nilpotentBCH (F.layerAlgebra 1) F.positive_nilpotent (hf x) (F.lieBCHList_mem f hf xs), + ih, List.map_cons, List.prod_cons] + +theorem bchProductPolynomial_formula (hf : ∀ x, f x ∈ F.layer 1) (xs : List X) : + FreeAlgebra.lift ℚ f (bchProductPolynomial s xs) = lieBCHList s f xs := by + have hx := F.lieBCHList_mem f hf xs + have hn := F.isNilpotent_of_mem le_rfl hx + have hprod : (xs.map (fun x => finiteExp (s + 1) (f x))).prod = + IsNilpotent.exp (lieBCHList s f xs) := by + rw [F.exp_lieBCHList f hf xs] + congr 1 + apply List.map_congr_left + intro x _ + exact finiteExp_eq_exp (F.pow_eq_zero le_rfl (hf x)) + rw [bchProductPolynomial_eval, hprod, + finiteLog_eq_log (F.pow_eq_zero le_rfl (F.exp_sub_one_mem_layer hx hn)), + nilpotentLog_exp_sub_one hn] + +end NilpotentAlgebraFiltration + +theorem bchProductLiePolynomial_associativeExpansion (s : ℕ) (xs : List X) : + freeLieAssociativeExpansion (bchProductLiePolynomial s xs) = + freeTruncation s (bchProductPolynomial s xs) := by + rw [bchProductLiePolynomial, freeLieTruncation_associativeExpansion] + apply freeTruncation_eq_of_scaled_series_eq + rw [← scaledFreeLieEval_eq, map_lieBCHList] + have hf : (fun x : X => scaledFreeLieEval s (FreeLieAlgebra.of ℚ x)) = scaledFreeGenerator s := by + funext x + exact scaledFreeLieEval_of s x + rw [hf] + have h := (truncatedSeriesFiltration (A := FreeAlgebra ℚ X) s).bchProductPolynomial_formula + (scaledFreeGenerator s) (scaledFreeGenerator_mem_layer s) xs + rw [← h] + have he : FreeAlgebra.lift ℚ (scaledFreeGenerator (X := X) s) = + (truncatedSeriesMk s).comp freeScaleSeries := by + apply FreeAlgebra.hom_ext + funext x + simp [scaledFreeGenerator] + rw [he] + rfl + +end Erdos3 + +end + +section + +namespace Erdos3 + +namespace NilpotentAlgebraFiltration +variable {A : Type*} [Ring A] [Algebra ℚ A] {s t : ℕ} + +def extend (F : NilpotentAlgebraFiltration A s) (hst : s ≤ t) : NilpotentAlgebraFiltration A t where + layer := F.layer + antitone := F.antitone + zero_eq_top := F.zero_eq_top + mul_mem := F.mul_mem + terminal := le_antisymm (by + rw [← F.terminal] + exact F.antitone (Nat.add_le_add_right hst 1)) bot_le + +end NilpotentAlgebraFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] +attribute [local instance] LieRing.ofAssociativeRing + +theorem lieBCH_eq_add_of_isLieAbelian [IsLieAbelian L] {s : ℕ} (hs : 1 ≤ s) (a b : L) : + lieBCH s a b = a + b := by + let x : Fin 2 → FreeLieAlgebra ℚ (Fin 2) := FreeLieAlgebra.of ℚ + let F := truncatedSeriesFiltration (A := FreeAlgebra ℚ (Fin 2)) 1 + have hx (i : Fin 2) : scaledFreeGenerator 1 i ∈ F.layer 1 := scaledFreeGenerator_mem_layer 1 i + have hmul (i j : Fin 2) : scaledFreeGenerator 1 i * scaledFreeGenerator 1 j = 0 := by + have h := F.mul_mem (hx i) (hx j) + simpa only [F.terminal, Submodule.mem_bot] using h + have hc : Commute (scaledFreeGenerator 1 (0 : Fin 2)) (scaledFreeGenerator 1 (1 : Fin 2)) := by + change _ * _ = _ * _ + rw [hmul 0 1, hmul 1 0] + have h : scaledFreeLieEval 1 (lieBCH s (x 0) (x 1)) = scaledFreeLieEval 1 (x 0 + x 1) := by + simp only [map_lieBCH, map_add, x, scaledFreeLieEval_of] + rw [(F.extend hs).lieBCH_eq (hx 0) (hx 1)] + exact nilpotentBCH_eq_add_of_commute (F.isNilpotent_of_mem le_rfl (hx 0)) + (F.isNilpotent_of_mem le_rfl (hx 1)) hc + have hn : LieModule.lowerCentralSeries ℚ L L 1 = ⊥ := by + simp [LieModule.lowerCentralSeries_succ] + have he := lie_lift_eq_of_scaledFreeLieEval_eq ![a, b] hn h + simpa only [map_lieBCH, map_add, x, FreeLieAlgebra.lift_of_apply, + Matrix.cons_val_zero, Matrix.cons_val_one] using he + +theorem lieBCH_eq_add_of_lie_eq_zero_pos {s : ℕ} (hs : 1 ≤ s) {a b : L} + (hab : ⁅a, b⁆ = 0) : lieBCH s a b = a + b := by + let K := LieSubalgebra.lieSpan ℚ L ({a, b} : Set L) + have ha : a ∈ K := LieSubalgebra.subset_lieSpan (by simp) + have hb : b ∈ K := LieSubalgebra.subset_lieSpan (by simp) + have : IsLieAbelian K := by + apply LieSubalgebra.isLieAbelian_lieSpan_iff.mpr + intro u hu v hv + simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hu hv + rcases hu with rfl | rfl <;> rcases hv with rfl | rfl + · exact lie_self _ + · exact hab + · rw [← lie_skew, hab, neg_zero] + · exact lie_self _ + have h := congrArg K.incl (lieBCH_eq_add_of_isLieAbelian hs (⟨a, ha⟩ : K) (⟨b, hb⟩ : K)) + simp only [map_lieBCH, map_add] at h + change lieBCH s a b = a + b at h + exact h + +theorem lieBCH_eq_add_of_lie_eq_zero {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) {a b : L} + (hab : ⁅a, b⁆ = 0) : lieBCH s a b = a + b := by + by_cases hs : 1 ≤ s + · exact lieBCH_eq_add_of_lie_eq_zero_pos hs hab + · have hs0 : s = 0 := by omega + subst s + have he (z : L) : z = 0 := by + have hz : z ∈ LieModule.lowerCentralSeries ℚ L L 0 := by simp + simpa only [hnil, LieSubmodule.mem_bot] using hz + rw [he a, he b, zero_add, lieBCH_zero_left hnil] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module MvPolynomial + +noncomputable def bchBoxCoordinateBound (s d H : ℕ) (B : ℝ) : ℝ := + (((s + 1) * (2 * d + 1) ^ s : ℕ) : ℝ) * bchCoordinateHeight s d H * (2 * d) * s * + B ^ (s * (2 * d + 1)) + +theorem bchBoxCoordinateBound_nonneg (s d H : ℕ) {B : ℝ} (hB : 0 ≤ B) : + 0 ≤ bchBoxCoordinateBound s d H B := by + unfold bchBoxCoordinateBound + positivity + +theorem lieBCH_sub_coordinates_bound {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) {H s : ℕ} + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (x y : L) {B δ : ℝ} (hB : 1 ≤ B) (hδ : 0 ≤ δ) + (hx : ∀ i, |e.repr x i| ≤ B) (hy : ∀ i, |e.repr y i| ≤ B) + (hxy : ∀ i, |e.repr x i - e.repr y i| ≤ δ) (k : ι) : + |e.repr (lieBCH s x (-y)) k| ≤ bchBoxCoordinateBound s (Fintype.card ι) H B * δ := by + classical + let P := bchCoordinatePolynomial c s k + let v : Fin 2 × ι → ℝ := fun z => e.repr (![x, -y] z.1) z.2 + let w : Fin 2 × ι → ℝ := fun z => e.repr (![y, -y] z.1) z.2 + have hdegree : P.totalDegree ≤ s := bchCoordinatePolynomial_totalDegree c s k + have hv (z : Fin 2 × ι) : |v z| ≤ B := by + rcases z with ⟨j, i⟩ + fin_cases j + · exact hx i + · simpa [v] using hy i + have hw (z : Fin 2 × ι) : |w z| ≤ B := by + rcases z with ⟨j, i⟩ + fin_cases j + · exact hy i + · simpa [w] using hy i + have hvw (z : Fin 2 × ι) : |v z - w z| ≤ δ := by + rcases z with ⟨j, i⟩ + fin_cases j + · exact hxy i + · simpa [v, w] using hδ + have hcoeff (m) : |((P.coeff m : ℚ) : ℝ)| ≤ bchCoordinateHeight s (Fintype.card ι) H := + (bchCoordinatePolynomial_height c hc s k m).abs_real_le + have h := abs_aeval_sub_aeval_box_bound P v w (Nat.cast_nonneg _) hB hδ hcoeff hv hw hvw hdegree + have hyneg : lieBCH s y (-y) = 0 := by + have hg := congrArg NilpotentLieBCHGroup.coord + (mul_inv_cancel (⟨y⟩ : NilpotentLieBCHGroup L s hnil)) + exact hg + have hevalv : aeval v P = e.repr (lieBCH s x (-y)) k := + bchCoordinatePolynomial_eval_over e c hstructure s x (-y) k + have hevalw : aeval w P = e.repr (lieBCH s y (-y)) k := + bchCoordinatePolynomial_eval_over e c hstructure s y (-y) k + rw [hevalv, hevalw, hyneg, map_zero, Finsupp.zero_apply, sub_zero] at h + have hcard := polynomial_support_card_le P hdegree + apply h.trans + dsimp only [bchBoxCoordinateBound] + simp only [Fintype.card_prod, Fintype.card_fin] at hcard + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul, Nat.cast_ofNat] + gcongr + exact_mod_cast hcard + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial Module + +variable {X : Type*} + +noncomputable def bchProductWordCoefficients (s : ℕ) (xs : List X) : FreeSemigroup X →₀ ℚ := + (freeLieWordExpansion (bchProductLiePolynomial s xs)).coeff + +noncomputable def bchProductBracketSupport (s : ℕ) (xs : List X) : Finset (FreeSemigroup X) := + (bchProductWordCoefficients s xs).support + +noncomputable def bchProductBracketCoefficient (s : ℕ) (xs : List X) (w : FreeSemigroup X) : ℚ := + bchProductWordCoefficients s xs w / w.length + +theorem bchProductBracketSupport_length (s : ℕ) (xs : List X) {w : FreeSemigroup X} + (hw : w ∈ bchProductBracketSupport s xs) : w.length ≤ s := + bchProductLiePolynomial_support_length s xs hw + +theorem bchProductWordCoefficients_eq (s : ℕ) (xs : List X) (w : FreeSemigroup X) : + bchProductWordCoefficients s xs w = + if w.length ≤ s then freeWordCoefficients (bchProductPolynomial s xs) w.toFreeMonoid else 0 := by + rw [bchProductWordCoefficients, ← freeWordCoefficients_embedding, + wordPolynomialEmbedding_freeLieExpansion, bchProductLiePolynomial_associativeExpansion, + freeWordCoefficients_truncation, freeSemigroup_toFreeMonoid_length] + +theorem lieBCHList_bracket_formula {L : Type*} [LieRing L] [LieAlgebra ℚ L] + (s : ℕ) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (f : X → L) (xs : List X) : + lieBCHList s f xs = ∑ w ∈ bchProductBracketSupport s xs, + bchProductBracketCoefficient s xs w • dynkinWord f w := by + rw [← bchProductLiePolynomial_eval s hnil f xs, ← dynkinProjection_lift] + change (bchProductWordCoefficients s xs).sum + (fun w r => r • ((w.length : ℚ)⁻¹ • dynkinWord f w)) = _ + simp only [Finsupp.sum, bchProductBracketSupport, bchProductBracketCoefficient, + smul_smul, div_eq_mul_inv] + +variable {ι : Type*} [Fintype ι] + +noncomputable def bchProductCoordinatePolynomial (c : ι → ι → ι → ℚ) (s : ℕ) + (xs : List X) (k : ι) : MvPolynomial (X × ι) ℚ := + ∑ w ∈ bchProductBracketSupport s xs, + C (bchProductBracketCoefficient s xs w) * dynkinCoordinatePolynomial c w k + +theorem bchProductCoordinatePolynomial_totalDegree (c : ι → ι → ι → ℚ) (s : ℕ) + (xs : List X) (k : ι) : + (bchProductCoordinatePolynomial c s xs k).totalDegree ≤ s := by + apply totalDegree_finsetSum_le + intro w hw + have h := totalDegree_mul (C (bchProductBracketCoefficient s xs w)) (dynkinCoordinatePolynomial c w k) + rw [totalDegree_C, zero_add] at h + exact h.trans ((dynkinCoordinatePolynomial_totalDegree c w k).trans + (bchProductBracketSupport_length s xs hw)) + +theorem bchProductCoordinatePolynomial_support_card [Fintype X] + (c : ι → ι → ι → ℚ) (s : ℕ) (xs : List X) (k : ι) : + (bchProductCoordinatePolynomial c s xs k).support.card ≤ + (s + 1) * (Fintype.card X * Fintype.card ι + 1) ^ s := by + simpa only [Fintype.card_prod] using polynomial_support_card_le + (bchProductCoordinatePolynomial c s xs k) (bchProductCoordinatePolynomial_totalDegree c s xs k) + +theorem bchProductCoordinatePolynomial_eval {L : Type*} [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (s : ℕ) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (f : X → L) (xs : List X) (k : ι) : + aeval (fun xi : X × ι => e.repr (f xi.1) xi.2) + (bchProductCoordinatePolynomial (lieStructureConstants e) s xs k) = + e.repr (lieBCHList s f xs) k := by + rw [lieBCHList_bracket_formula s hnil] + simp only [bchProductCoordinatePolynomial, map_sum, map_mul, aeval_C, + Algebra.algebraMap_self, RingHom.id_apply, dynkinCoordinatePolynomial_eval, + map_smul, Finsupp.coe_finsetSum, Finset.sum_apply, Finsupp.smul_apply, smul_eq_mul] + +theorem bchProductCoordinatePolynomial_eval_over {R L : Type*} [CommRing R] [Algebra ℚ R] + [LieRing L] [LieAlgebra R L] [LieAlgebra ℚ L] [IsScalarTower ℚ R L] + (e : Basis ι R L) (c : ι → ι → ι → ℚ) + (hc : ∀ i j k, algebraMap ℚ R (c i j k) = e.repr ⁅e i, e j⁆ k) + (s : ℕ) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (f : X → L) (xs : List X) (k : ι) : + aeval (fun xi : X × ι => e.repr (f xi.1) xi.2) + (bchProductCoordinatePolynomial c s xs k) = e.repr (lieBCHList s f xs) k := by + change _ = e.coord k (lieBCHList s f xs) + rw [lieBCHList_bracket_formula s hnil] + simp only [bchProductCoordinatePolynomial, map_sum, map_mul, aeval_C, + dynkinCoordinatePolynomial_eval_over e c hc, + LinearMap.map_smul_of_tower, Algebra.smul_def, Basis.coord_apply] + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + +theorem lieBCH_sub_right_mem_of_mem_ideal + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (I : LieIdeal ℚ L) + {a : L} (ha : a ∈ I) (b : L) : lieBCH s a b - b ∈ I := by + apply (lieQuotientMap_eq_zero I _).mp + rw [map_sub, map_lieBCH, (lieQuotientMap_eq_zero I a).mpr ha, + lieBCH_zero_left (lie_quotient_lowerCentralSeries_eq_bot hnil I), sub_self] + +theorem lieBCH_sub_left_mem_of_mem_ideal + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (I : LieIdeal ℚ L) + (a : L) {b : L} (hb : b ∈ I) : lieBCH s a b - a ∈ I := by + apply (lieQuotientMap_eq_zero I _).mp + rw [map_sub, map_lieBCH, (lieQuotientMap_eq_zero I b).mpr hb, + lieBCH_eq_add_of_lie_eq_zero (lie_quotient_lowerCentralSeries_eq_bot hnil I) (lie_zero _), + add_zero, sub_self] + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {X L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem dynkinWord_eq_zero_of_abelian [IsLieAbelian L] (f : X → L) + (w : FreeSemigroup X) (hw : w.tail ≠ []) : dynkinWord f w = 0 := by + unfold dynkinWord + cases h : w.tail with + | nil => exact False.elim (hw h) + | cons x xs => + simp only [rightBracketList_cons, Module.End.mul_apply, rightBracket_apply, + trivial_lie_zero, map_zero] + +theorem bch_linear_words_sum {s : ℕ} (hs : 1 ≤ s) (a b : L) : + ∑ w ∈ (bchBracketSupport s).filter (fun w => w.tail = []), + bchBracketCoefficient s w • dynkinWord ![a, b] w = a + b := by + classical + let : LieRing (ℚ × ℚ) := LieRing.ofAssociativeRing + let : IsLieAbelian (ℚ × ℚ) := + ⟨fun x y => by rw [LieRing.of_associative_ring_bracket, mul_comm x y, sub_self]⟩ + let φ : (ℚ × ℚ) →ₗ[ℚ] L := + (LinearMap.fst ℚ ℚ ℚ).smulRight a + (LinearMap.snd ℚ ℚ ℚ).smulRight b + let x : ℚ × ℚ := (1, 0) + let y : ℚ × ℚ := (0, 1) + have hxy (i : Fin 2) : φ (![x, y] i) = ![a, b] i := by + fin_cases i <;> simp [φ, x, y] + have hterm (w : FreeSemigroup (Fin 2)) : + φ (dynkinWord ![x, y] w) = if w.tail = [] then dynkinWord ![a, b] w else 0 := by + by_cases hw : w.tail = [] + · simp only [hw, ite_eq_left, dynkinWord, rightBracketList_nil, Module.End.one_apply] + exact hxy w.head + · rw [dynkinWord_eq_zero_of_abelian _ _ hw, map_zero, ite_eq_right hw] + have h := congrArg φ (lieBCH_eq_add_of_isLieAbelian hs x y) + rw [lieBCH_bracket_formula] at h + simp only [map_sum, map_smul, hterm, smul_ite, smul_zero] at h + simpa only [Finset.sum_filter, map_add, hxy 0, hxy 1, φ, x, y, + LinearMap.add_apply, LinearMap.smulRight_apply, LinearMap.fst_apply, LinearMap.snd_apply, + one_smul, zero_smul, add_zero, zero_add] using h + +theorem lieBCH_eq_add_nonlinear_sum {s : ℕ} (hs : 1 ≤ s) (a b : L) : + lieBCH s a b = a + b + + ∑ w ∈ (bchBracketSupport s).filter (fun w => w.tail ≠ []), + bchBracketCoefficient s w • dynkinWord ![a, b] w := by + classical + rw [lieBCH_bracket_formula, ← bch_linear_words_sum hs a b] + exact (Finset.sum_filter_add_sum_filter_not (bchBracketSupport s) + (fun w => w.tail = []) (fun w => bchBracketCoefficient s w • dynkinWord ![a, b] w)).symm + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHOrderedReduction.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHOrderedReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3d1cea5398f6507258038868824f3ac4da6783a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHOrderedReduction.lean @@ -0,0 +1,51 @@ +import OAI.Combinatorics.Progressions.Linear.BoundedAdaptedBasis + +namespace OAI + +section + +namespace Erdos3.IsCentralLieBasis + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d s : ℕ} + {e : Basis (Fin d) ℚ L} (he : IsCentralLieBasis e) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + +include he hnil + +theorem bch_remainder_mem_tail (i : ℕ) (a : L) {b : L} (hb : b ∈ basisTail e i) : + lieBCH s a b - (a + b) ∈ basisTail e (i + 1) := + lieBCH_sub_add_mem hnil (he.tailIdeal (i + 1)) a b (he.lie_mem_tail_succ i a hb) + +theorem bch_low_coordinate (i : ℕ) (a : L) {b : L} (hb : b ∈ basisTail e i) + (k : Fin d) (hk : k.val ≤ i) : + e.repr (lieBCH s a b) k = e.repr a k + e.repr b k := by + have h := he.bch_remainder_mem_tail hnil i a hb k (Nat.lt_succ_of_le hk) + rw [map_sub, Finsupp.sub_apply, map_add, Finsupp.add_apply] at h + exact sub_eq_zero.mp h + +theorem peel_mem_tail (j : Fin d) (g : NilpotentLieBCHGroup L s hnil) + (hg : g.coord ∈ basisTail e j.val) : + (((⟨e.repr g.coord j • e j⟩ : NilpotentLieBCHGroup L s hnil)⁻¹ * g).coord) ∈ + basisTail e (j.val + 1) := by + change lieBCH s (-(e.repr g.coord j • e j)) g.coord ∈ _ + have herr := he.bch_remainder_mem_tail hnil j.val (-(e.repr g.coord j • e j)) hg + have hlin : -(e.repr g.coord j • e j) + g.coord ∈ basisTail e (j.val + 1) := by + simpa only [sub_eq_add_neg, add_comm] using sub_coordinate_mem_tail e j hg + simpa only [sub_add_cancel] using (basisTail e (j.val + 1)).add_mem herr hlin + +theorem leading_coordinate (j : Fin d) (t : ℚ) (r : NilpotentLieBCHGroup L s hnil) + (hr : r.coord ∈ basisTail e (j.val + 1)) : + e.repr (((⟨t • e j⟩ : NilpotentLieBCHGroup L s hnil) * r).coord) j = t := by + change e.repr (lieBCH s (t • e j) r.coord) j = t + rw [he.bch_low_coordinate hnil j.val (t • e j) + (basisTail_antitone e (Nat.le_succ j.val) hr) j le_rfl] + simp only [map_smul, Finsupp.smul_apply, Basis.repr_self, Finsupp.single_eq_same, + smul_eq_mul, mul_one, hr j (Nat.lt_succ_self j.val), add_zero] + +end Erdos3.IsCentralLieBasis + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHOuterGridChangeBasis.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHOuterGridChangeBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf7e5ed5f41eeb1adb7f15e715296e6d1552c2e3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHOuterGridChangeBasis.lean @@ -0,0 +1,275 @@ +import OAI.Combinatorics.Progressions.Estimates.PowerSubgroup +import OAI.Combinatorics.Progressions.Nilpotent.BCHSubgroupGridExistence +import OAI.Combinatorics.Progressions.Sampling.IntegralGridFunctional + +namespace OAI + +section + +namespace Erdos3 + +variable {X L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem rational_nat_smul_mem (M : Submodule ℤ L) {z : L} (hz : z ∈ M) (D : ℕ) : + (D : ℚ) • z ∈ M := by + rw [Nat.cast_smul_eq_nsmul ℚ] + exact M.nsmul_mem hz D + +theorem rightBracketList_mem_intModule (M : Submodule ℤ L) + (hbr : ∀ a ∈ M, ∀ b ∈ M, ⁅a, b⁆ ∈ M) + (f : X → L) (hf : ∀ x, f x ∈ M) (xs : List X) {z : L} (hz : z ∈ M) : + rightBracketList f xs z ∈ M := by + induction xs generalizing z with + | nil => exact hz + | cons x xs ih => exact ih (hbr z hz (f x) (hf x)) + +theorem dynkinWord_mem_multiple (M : Submodule ℤ L) (D : ℕ) + (hbr : ∀ a ∈ M, ∀ b ∈ M, ∃ z ∈ M, ⁅a, b⁆ = (D : ℚ) • z) + (f : X → L) (hf : ∀ x, f x ∈ M) (w : FreeSemigroup X) (hw : w.tail ≠ []) : + ∃ z ∈ M, dynkinWord f w = (D : ℚ) • z := by + have hclosed : ∀ a ∈ M, ∀ b ∈ M, ⁅a, b⁆ ∈ M := by + intro a ha b hb + obtain ⟨z, hz, heq⟩ := hbr a ha b hb + rw [heq] + exact rational_nat_smul_mem M hz D + cases htail : w.tail with + | nil => exact False.elim (hw htail) + | cons x xs => + obtain ⟨z, hz, heq⟩ := hbr (f w.head) (hf _) (f x) (hf _) + refine ⟨rightBracketList f xs z, rightBracketList_mem_intModule M hclosed f hf xs hz, ?_⟩ + simp only [dynkinWord, htail, rightBracketList_cons, Module.End.mul_apply, + rightBracket_apply, heq, map_smul] + +theorem lieBCH_mem_of_divisible_brackets (M : Submodule ℤ L) (D : ℕ) {s : ℕ} + (hs : 1 ≤ s) + (hbr : ∀ a ∈ M, ∀ b ∈ M, ∃ z ∈ M, ⁅a, b⁆ = (D : ℚ) • z) + (hc : ∀ w ∈ bchBracketSupport s, ∃ n : ℤ, (D : ℚ) * bchBracketCoefficient s w = (n : ℚ)) + {a b : L} (ha : a ∈ M) (hb : b ∈ M) : lieBCH s a b ∈ M := by + classical + rw [lieBCH_eq_add_nonlinear_sum hs] + apply M.add_mem (M.add_mem ha hb) + apply M.sum_mem + intro w hw + obtain ⟨hw, htail⟩ := Finset.mem_filter.mp hw + have hf : ∀ i : Fin 2, ![a, b] i ∈ M := by + intro i + fin_cases i <;> assumption + obtain ⟨z, hz, heq⟩ := dynkinWord_mem_multiple M D hbr ![a, b] hf w htail + obtain ⟨n, hn⟩ := hc w hw + rw [heq, smul_smul, mul_comm _ (D : ℚ), hn, Int.cast_smul_eq_zsmul ℚ] + exact M.smul_mem n hz + +theorem lieBCH_mem_of_divisible_brackets_nilpotent (M : Submodule ℤ L) (D : ℕ) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (hbr : ∀ a ∈ M, ∀ b ∈ M, ∃ z ∈ M, ⁅a, b⁆ = (D : ℚ) • z) + (hc : ∀ w ∈ bchBracketSupport s, ∃ n : ℤ, (D : ℚ) * bchBracketCoefficient s w = (n : ℚ)) + {a b : L} (ha : a ∈ M) (hb : b ∈ M) : lieBCH s a b ∈ M := by + by_cases hs : 1 ≤ s + · exact lieBCH_mem_of_divisible_brackets M D hs hbr hc ha hb + · have hs0 : s = 0 := by omega + subst s + have hz : a = 0 := by + have h : a ∈ LieModule.lowerCentralSeries ℚ L L 0 := by simp + simpa only [hnil, LieSubmodule.mem_bot] using h + rw [hz, lieBCH_zero_left hnil] + exact hb + +def intModuleBCHSubgroup (M : Submodule ℤ L) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (hstable : ∀ a ∈ M, ∀ b ∈ M, lieBCH s a b ∈ M) : + Subgroup (NilpotentLieBCHGroup L s hnil) where + carrier := {g | g.coord ∈ M} + one_mem' := M.zero_mem + mul_mem' := by intro a b ha hb; exact hstable a.coord ha b.coord hb + inv_mem' := by intro a ha; exact M.neg_mem ha + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem denominator_grid_smul_mem_scaled {ι : Type*} (l m₀ m : ℕ) + (hm : l * m₀ ∣ m) {x : ι → ℚ} (hx : x ∈ denominatorGrid l) : + (m : ℚ) • x ∈ scaledIntegerGrid m₀ := by + obtain ⟨k, rfl⟩ := hm + obtain ⟨z, hz⟩ := hx + refine ⟨fun i => (k : ℤ) * z i, ?_⟩ + ext i + have hi := hz i + change (l : ℚ) * x i = (z i : ℚ) at hi + simp only [Pi.smul_apply, smul_eq_mul, Nat.cast_mul, Int.cast_mul, Int.cast_natCast] + calc + _ = (m₀ : ℚ) * k * ((l : ℚ) * x i) := by ring + _ = _ := by rw [hi]; ring + +theorem denominator_grid_subset_mul {ι : Type*} (l m : ℕ) : + (denominatorGrid l : Set (ι → ℚ)) ⊆ denominatorGrid (m * l) := by + intro x hx + have h := hx.nat_smul m + simpa only [denominatorGrid, Set.mem_ofPred_eq, smul_smul, Nat.cast_mul] using h + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem bchSubgroupCoordinates_repr (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (g : NilpotentLieBCHGroup L s hnil) : + e.equivFun g.coord ∈ bchSubgroupCoordinates e Γ ↔ g ∈ Γ := by + change (⟨e.equivFun.symm (e.equivFun g.coord)⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ ↔ _ + rw [LinearEquiv.symm_apply_apply] + +theorem subgroupPowerCover_inner_grid (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l m : ℕ) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) : + scaledIntegerGrid (m * l) ⊆ bchSubgroupCoordinates e (subgroupPowerCover Γ m) := by + rintro x ⟨z, rfl⟩ + let g : NilpotentLieBCHGroup L s hnil := ⟨e.equivFun.symm ((l : ℚ) • fun i => (z i : ℚ))⟩ + have hg : g ∈ Γ := hinner ⟨z, rfl⟩ + have heq : e.equivFun (g ^ m).coord = ((m * l : ℕ) : ℚ) • fun i => (z i : ℚ) := by + rw [NilpotentLieBCHGroup.coord_pow_rat, map_smul] + change (m : ℚ) • e.equivFun (e.equivFun.symm ((l : ℚ) • fun i => (z i : ℚ))) = _ + rw [LinearEquiv.apply_symm_apply, smul_smul, Nat.cast_mul] + rw [← heq] + exact (bchSubgroupCoordinates_repr e _ _).mpr (pow_mem_subgroupPowerCover Γ hg m) + +theorem subgroupPowerCover_le_of_grid (e : Basis ι ℚ L) + (Γ Λ₀ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l m₀ m : ℕ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (hinner : scaledIntegerGrid m₀ ⊆ bchSubgroupCoordinates e Λ₀) + (hm : l * m₀ ∣ m) : subgroupPowerCover Γ m ≤ Λ₀ := by + apply (subgroupPowerCover_le_iff Γ Λ₀ m).mpr + intro g hg + apply (bchSubgroupCoordinates_repr e Λ₀ (g ^ m)).mp + rw [NilpotentLieBCHGroup.coord_pow_rat, map_smul] + exact hinner (denominator_grid_smul_mem_scaled l m₀ m hm + (houter ((bchSubgroupCoordinates_repr e Γ g).mpr hg))) + +theorem subgroupPowerCover_grid (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l m : ℕ) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + scaledIntegerGrid (m * l) ⊆ bchSubgroupCoordinates e (subgroupPowerCover Γ m) ∧ + bchSubgroupCoordinates e (subgroupPowerCover Γ m) ⊆ denominatorGrid (m * l) := by + refine ⟨subgroupPowerCover_inner_grid e Γ l m hinner, ?_⟩ + intro x hx + exact denominator_grid_subset_mul l m (houter (subgroupPowerCover_le Γ m hx)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +noncomputable def bchIntegralDenominatorBound (s : ℕ) : ℕ := + bchCoefficientHeight s ^ (bchBracketSupport s).card + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + +theorem exists_bch_stable_integral_grid (e : Basis ι ℚ L) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (l : ℕ) (hl : 0 < l) {H : ℕ} + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) : + ∃ B : ℕ, 0 < B ∧ l ∣ B ∧ + B ≤ bchIntegralDenominatorBound s * H ^ (Fintype.card ι ^ 3) * l ∧ + ∀ a ∈ coordinateGridModule e B, ∀ b ∈ coordinateGridModule e B, + lieBCH s a b ∈ coordinateGridModule e B := by + classical + obtain ⟨D, hD, hDb, u, hu, _⟩ := exists_bch_integer_coefficients s + obtain ⟨E, hE, hEb, c, hEcoeff, _⟩ := exists_bounded_integer_array + (fun ijk : ι × (ι × ι) => lieStructureConstants e ijk.1 ijk.2.1 ijk.2.2) + (fun ijk => hc ijk.1 ijk.2.1 ijk.2.2) + have hEb' : E ≤ H ^ (Fintype.card ι ^ 3) := by + simpa only [Fintype.card_prod, pow_succ, pow_zero, one_mul, mul_assoc] using hEb + let B := (D * E) * l + have hscaled (i j k : ι) : + ∃ n : ℤ, (B : ℚ) * lieStructureConstants e i j k = (D : ℚ) * n := by + refine ⟨(l : ℤ) * c (i, j, k), ?_⟩ + simp only [B, Nat.cast_mul, Int.cast_mul, Int.cast_natCast, hEcoeff] + ring + refine ⟨B, Nat.mul_pos (Nat.mul_pos hD hE) hl, dvd_mul_left l (D * E), + Nat.mul_le_mul_right l (Nat.mul_le_mul hDb hEb'), ?_⟩ + intro a ha b hb + exact lieBCH_mem_of_divisible_brackets_nilpotent (coordinateGridModule e B) D hnil + (fun x hx y hy => coordinateGrid_bracket_divisible e B D hscaled hx hy) + (fun w hw => ⟨u w hw, (hu w hw).symm⟩) ha hb + +def coordinateGridBCHSubgroup (e : Basis ι ℚ L) (B : ℕ) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (hstable : ∀ a ∈ coordinateGridModule e B, ∀ b ∈ coordinateGridModule e B, + lieBCH s a b ∈ coordinateGridModule e B) : + Subgroup (NilpotentLieBCHGroup L s hnil) := + intModuleBCHSubgroup (coordinateGridModule e B) hnil hstable + +theorem coordinateGridBCHSubgroup_coordinates (e : Basis ι ℚ L) (B : ℕ) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (hstable : ∀ a ∈ coordinateGridModule e B, ∀ b ∈ coordinateGridModule e B, + lieBCH s a b ∈ coordinateGridModule e B) : + bchSubgroupCoordinates e (coordinateGridBCHSubgroup e B hnil hstable) = scaledIntegerGrid B := by + ext x + change e.equivFun (e.equivFun.symm x) ∈ scaledIntegerGrid B ↔ x ∈ scaledIntegerGrid B + rw [LinearEquiv.apply_symm_apply] + +theorem exists_integral_grid_subgroup (e : Basis ι ℚ L) {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) {H : ℕ} + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) : + ∃ (B : ℕ) (Λ : Subgroup (NilpotentLieBCHGroup L s hnil)), + 0 < B ∧ l ∣ B ∧ B ≤ bchIntegralDenominatorBound s * H ^ (Fintype.card ι ^ 3) * l ∧ + Λ ≤ Γ ∧ bchSubgroupCoordinates e Λ = scaledIntegerGrid B := by + obtain ⟨B, hB, hdiv, hbound, hstable⟩ := exists_bch_stable_integral_grid e hnil l hl hc + let Λ := coordinateGridBCHSubgroup e B hnil hstable + have hcoords := coordinateGridBCHSubgroup_coordinates e B hnil hstable + refine ⟨B, Λ, hB, hdiv, hbound, ?_, hcoords⟩ + intro g hg + apply (bchSubgroupCoordinates_repr e Γ g).mp + apply hinner + apply scaledIntegerGrid_subset_of_dvd hdiv + rw [← hcoords] + exact (bchSubgroupCoordinates_repr e Λ g).mpr hg + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +theorem exists_bchSubgroup_outer_grid_change_basis + {ι κ L : Type*} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + (e : Basis ι ℚ L) (b : Basis κ ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ N : ℕ, 0 < N ∧ bchSubgroupCoordinates b Γ ⊆ denominatorGrid N := by + classical + let A := LinearMap.toMatrix e b (LinearMap.id : L →ₗ[ℚ] L) + refine ⟨matrixDenominator A * l, Nat.mul_pos (matrixDenominator_pos A) hl, ?_⟩ + intro x hx + let g : NilpotentLieBCHGroup L s hnil := ⟨b.equivFun.symm x⟩ + have hg : g ∈ Γ := hx + have hgrid := houter ((bchSubgroupCoordinates_repr e Γ g).mpr hg) + have hint := integralVector_denominator_mulVec A ((l : ℚ) • e.equivFun g.coord) hgrid + have hA : A *ᵥ e.equivFun g.coord = x := by + dsimp only [A] + rw [basisMatrix_mulVec, LinearEquiv.symm_apply_apply] + exact b.equivFun.apply_symm_apply x + simpa only [denominatorGrid, Set.mem_ofPred_eq, Matrix.mulVec_smul, hA, + smul_smul, Nat.cast_mul] using hint + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHPairCoordinateMetric.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHPairCoordinateMetric.lean new file mode 100644 index 0000000000000000000000000000000000000000..552fa9afd2fbbf1ee491d874cde11861391d3e61 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHPairCoordinateMetric.lean @@ -0,0 +1,102 @@ +import OAI.Combinatorics.Progressions.Nilpotent.BCHNonlinearRemainder + +namespace OAI + +section + +namespace Erdos3 + +open Module MvPolynomial + +variable {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) {H s : ℕ} + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + +include hstructure hc + +theorem lieBCH_pair_coordinates_bound (x₁ y₁ x₂ y₂ : L) {B δ : ℝ} + (hB : 1 ≤ B) (hδ : 0 ≤ δ) + (hx₁ : ∀ i, |e.repr x₁ i| ≤ B) (hy₁ : ∀ i, |e.repr y₁ i| ≤ B) + (hx₂ : ∀ i, |e.repr x₂ i| ≤ B) (hy₂ : ∀ i, |e.repr y₂ i| ≤ B) + (hxx : ∀ i, |e.repr x₁ i - e.repr x₂ i| ≤ δ) + (hyy : ∀ i, |e.repr y₁ i - e.repr y₂ i| ≤ δ) (k : ι) : + |e.repr (lieBCH s x₁ y₁) k - e.repr (lieBCH s x₂ y₂) k| ≤ + bchBoxCoordinateBound s (Fintype.card ι) H B * δ := by + classical + let P := bchCoordinatePolynomial c s k + let v : Fin 2 × ι → ℝ := fun z => e.repr (![x₁, y₁] z.1) z.2 + let w : Fin 2 × ι → ℝ := fun z => e.repr (![x₂, y₂] z.1) z.2 + have hdegree : P.totalDegree ≤ s := bchCoordinatePolynomial_totalDegree c s k + have hv (z : Fin 2 × ι) : |v z| ≤ B := by + rcases z with ⟨j, i⟩ + fin_cases j + · exact hx₁ i + · exact hy₁ i + have hw (z : Fin 2 × ι) : |w z| ≤ B := by + rcases z with ⟨j, i⟩ + fin_cases j + · exact hx₂ i + · exact hy₂ i + have hvw (z : Fin 2 × ι) : |v z - w z| ≤ δ := by + rcases z with ⟨j, i⟩ + fin_cases j + · exact hxx i + · exact hyy i + have hcoeff (m) : |((P.coeff m : ℚ) : ℝ)| ≤ bchCoordinateHeight s (Fintype.card ι) H := + (bchCoordinatePolynomial_height c hc s k m).abs_real_le + have h := abs_aeval_sub_aeval_box_bound P v w (Nat.cast_nonneg _) hB hδ hcoeff hv hw hvw hdegree + have hevalv : aeval v P = e.repr (lieBCH s x₁ y₁) k := + bchCoordinatePolynomial_eval_over e c hstructure s x₁ y₁ k + have hevalw : aeval w P = e.repr (lieBCH s x₂ y₂) k := + bchCoordinatePolynomial_eval_over e c hstructure s x₂ y₂ k + rw [hevalv, hevalw] at h + have hcard := polynomial_support_card_le P hdegree + apply h.trans + dsimp only [bchBoxCoordinateBound] + simp only [Fintype.card_prod, Fintype.card_fin] at hcard + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul, Nat.cast_ofNat] + gcongr + exact_mod_cast hcard + +theorem lieBCH_pair_coordinate_dist_le (x₁ y₁ x₂ y₂ : L) {B δ : ℝ} + (hB : 1 ≤ B) (hδ : 0 ≤ δ) + (hx₁ : ‖e.equivFun x₁‖ ≤ B) (hy₁ : ‖e.equivFun y₁‖ ≤ B) + (hx₂ : ‖e.equivFun x₂‖ ≤ B) (hy₂ : ‖e.equivFun y₂‖ ≤ B) + (hxx : dist (e.equivFun x₁) (e.equivFun x₂) ≤ δ) + (hyy : dist (e.equivFun y₁) (e.equivFun y₂) ≤ δ) : + dist (e.equivFun (lieBCH s x₁ y₁)) (e.equivFun (lieBCH s x₂ y₂)) ≤ + bchBoxCoordinateBound s (Fintype.card ι) H B * δ := by + apply (dist_pi_le_iff (mul_nonneg (bchBoxCoordinateBound_nonneg s _ H (by linarith)) hδ)).mpr + intro i + have hcoord (x : L) (hx : ‖e.equivFun x‖ ≤ B) (j : ι) : |e.repr x j| ≤ B := by + calc + _ ≤ ‖e.equivFun x‖ := by + simpa only [Real.norm_eq_abs, Basis.equivFun_apply] using norm_le_pi_norm (e.equivFun x) j + _ ≤ B := hx + have hdiff (x y : L) (hxy : dist (e.equivFun x) (e.equivFun y) ≤ δ) (j : ι) : + |e.repr x j - e.repr y j| ≤ δ := by + calc + _ ≤ dist (e.equivFun x) (e.equivFun y) := by + simpa only [Real.dist_eq, Basis.equivFun_apply] using dist_le_pi_dist (e.equivFun x) (e.equivFun y) j + _ ≤ δ := hxy + exact lieBCH_pair_coordinates_bound e c hstructure hc x₁ y₁ x₂ y₂ hB hδ + (hcoord _ hx₁) (hcoord _ hy₁) (hcoord _ hx₂) (hcoord _ hy₂) (hdiff _ _ hxx) (hdiff _ _ hyy) i + +theorem lieBCH_coordinate_norm_le + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (x y : L) {B : ℝ} (hB : 1 ≤ B) + (hx : ‖e.equivFun x‖ ≤ B) (hy : ‖e.equivFun y‖ ≤ B) : + ‖e.equivFun (lieBCH s x y)‖ ≤ bchBoxCoordinateBound s (Fintype.card ι) H B * B := by + have hB₀ : 0 ≤ B := by linarith + simpa only [lieBCH_zero_left hnil, map_zero, norm_zero, dist_zero_right] using + lieBCH_pair_coordinate_dist_le (s := s) e c hstructure hc x y 0 0 hB hB₀ + hx hy (by simpa using hB₀) (by simpa using hB₀) + (by simpa using hx) (by simpa using hy) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHQuotientChart.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHQuotientChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..666ae3e34db99f87a758091349a6b0c46ff1c0cf --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHQuotientChart.lean @@ -0,0 +1,68 @@ +import Mathlib.GroupTheory.Coset.Defs +import OAI.Combinatorics.Progressions.Nilpotent.BCHChartCutoffSmooth + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem eq_one_of_subgroup_grid_of_small_coordinates (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + (g : NilpotentLieBCHGroup L s hnil) (hg : g ∈ Γ) + (hsmall : ∀ i, |e.repr g.coord i| < 1 / (l : ℝ)) : g = 1 := by + apply ext + apply e.equivFun.injective + simpa only [coord_one, map_zero] using + eq_zero_of_mem_realDenominatorGrid_of_abs_lt hl (hgrid g hg) hsmall + +variable [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + +theorem quotient_coordinate_injOn_of_radius + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + {r : ℝ} (hr : 0 ≤ r) (hr1 : r ≤ 1) + (hsep : bchBoxCoordinateBound s (Fintype.card ι) H 1 * (2 * r) < 1 / (l : ℝ)) + (z : NilpotentLieBCHGroup L s hnil) : + Set.InjOn (fun v : ι → ℝ => (QuotientGroup.mk (z * (basisHomeomorph e).symm v) : _ ⧸ Γ)) + {v | ∀ i, |v i| ≤ r} := by + intro x hx y hy hxy + let u := (basisHomeomorph (hnil := hnil) e).symm x + let v := (basisHomeomorph (hnil := hnil) e).symm y + have hu : e.equivFun u.coord = x := (basisHomeomorph (hnil := hnil) e).apply_symm_apply x + have hv : e.equivFun v.coord = y := (basisHomeomorph (hnil := hnil) e).apply_symm_apply y + have hur (i) : |e.repr u.coord i| ≤ r := by simpa only [← hu, Basis.equivFun_apply] using hx i + have hvr (i) : |e.repr v.coord i| ≤ r := by simpa only [← hv, Basis.equivFun_apply] using hy i + have hmem : u⁻¹ * v ∈ Γ := by + have h := QuotientGroup.eq.mp hxy + simpa only [mul_inv_rev, mul_assoc, inv_mul_cancel_left] using h + have hone : u⁻¹ * v = 1 := by + apply eq_one_of_subgroup_grid_of_small_coordinates e Γ l hl hgrid _ hmem + intro k + have hbound := lieBCH_sub_coordinates_bound e c hstructure hc hnil (-u.coord) (-v.coord) + (B := 1) (δ := 2 * r) le_rfl (by positivity) + (fun i => by simpa only [map_neg, Finsupp.neg_apply, abs_neg] using (hur i).trans hr1) + (fun i => by simpa only [map_neg, Finsupp.neg_apply, abs_neg] using (hvr i).trans hr1) + (fun i => by + simp only [map_neg, Finsupp.neg_apply, neg_sub_neg] + exact (abs_sub _ _).trans (by linarith [hur i, hvr i])) k + simpa only [coord_mul, coord_inv, neg_neg] using hbound.trans_lt hsep + have huv : u = v := inv_mul_eq_one.mp hone + exact hu.symm.trans ((congrArg (fun g => e.equivFun g.coord) huv).trans hv) + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHQuotientLocalIsometry.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHQuotientLocalIsometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5ec0f2b96a3a26eee598d454c547dd17b81566d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHQuotientLocalIsometry.lean @@ -0,0 +1,755 @@ +import Mathlib.Analysis.SpecialFunctions.Exp +import Mathlib.Topology.Covering.Quotient +import OAI.Combinatorics.Progressions.Estimates.GroupReductionFactors +import OAI.Combinatorics.Progressions.Estimates.SeparatedCosetBalls +import OAI.Combinatorics.Progressions.Nilpotent.BCHLatticeImageGap + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +local notation "E" => ℝ ⊗[ℚ] L +local notation "G" => NilpotentLieBCHGroup E s (realification_lowerCentralSeries_eq_bot hnil) + +section Topology + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem exists_compact_realification_representatives (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) : + ∃ C : Set G, IsCompact C ∧ + ∀ g : G, ∃ c ∈ C, ∃ γ ∈ Γ.map NilpotentLieBCHGroup.realificationHom, g = c * γ := by + let : FiniteDimensional ℝ E := (e.baseChange ℝ).finiteDimensional_of_finite + let H : ℕ → Subgroup G := fun n => NilpotentLieBCHGroup.subgroup + (show LieIdeal ℚ E from LieModule.lowerCentralSeries ℚ E E n).toLieSubalgebra + have hzero : H 0 = ⊤ := by + ext g + change (g.coord ∈ LieModule.lowerCentralSeries ℚ E E 0) ↔ g ∈ (⊤ : Subgroup G) + simp + have hterminal : H s = ⊥ := by + ext g + change (g.coord ∈ LieModule.lowerCentralSeries ℚ E E s) ↔ g = 1 + rw [realification_lowerCentralSeries_eq_bot hnil, LieSubmodule.mem_bot] + exact ⟨fun h => NilpotentLieBCHGroup.ext h, fun h => congrArg NilpotentLieBCHGroup.coord h⟩ + apply exists_compact_representatives_of_reductions (Γ.map NilpotentLieBCHGroup.realificationHom) + H s hzero hterminal + intro i _ + obtain ⟨K, hK, hreduce⟩ := exists_realification_layer_reduction e Γ l hl hinner i + exact ⟨K, hK, fun g hg => hreduce g hg⟩ + +theorem compactSpace_realification_quotient (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) : + CompactSpace (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := by + obtain ⟨C, hC, hrep⟩ := exists_compact_realification_representatives e Γ l hl hinner + exact compactSpace_quotient_of_representatives _ hC hrep + +end Topology + +theorem exists_realification_cocompact_lattice (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ τ : TopologicalSpace E, + letI := τ + IsTopologicalAddGroup E ∧ ContinuousSMul ℝ E ∧ T2Space E ∧ + IsTopologicalGroup G ∧ ConnectedSpace G ∧ SimplyConnectedSpace G ∧ + IsClosed (Γ.map NilpotentLieBCHGroup.realificationHom : Set G) ∧ + IsDiscrete (Γ.map NilpotentLieBCHGroup.realificationHom : Set G) ∧ + CompactSpace (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := by + obtain ⟨τ, hA, hS, hT, hG, hC, hSC, hclosed, hdiscrete⟩ := + exists_realification_topology_of_grid e Γ l hl houter + let : TopologicalSpace E := τ + let : IsTopologicalAddGroup E := hA + let : ContinuousSMul ℝ E := hS + let : T2Space E := hT + exact ⟨τ, hA, hS, hT, hG, hC, hSC, hclosed, hdiscrete, + compactSpace_realification_quotient e Γ l hl hinner⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +local notation "E" => ℝ ⊗[ℚ] L +local notation "G" => NilpotentLieBCHGroup E s (realification_lowerCentralSeries_eq_bot hnil) + +section Topology + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem isCoveringMap_realification_quotient (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + IsCoveringMap (QuotientGroup.mk : G → G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := by + let : FiniteDimensional ℝ E := (e.baseChange ℝ).finiteDimensional_of_finite + exact ((Γ.map NilpotentLieBCHGroup.realificationHom).isQuotientCoveringMap + (NilpotentLieBCHGroup.realification_subgroup_closed_discrete e Γ l hl houter).2).isCoveringMap + +end Topology + +theorem exists_realification_lieGroup_lattice (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ τ : TopologicalSpace E, + letI := τ + ∃ c : ChartedSpace (ι → ℝ) G, + letI := c + IsTopologicalAddGroup E ∧ ContinuousSMul ℝ E ∧ T2Space E ∧ + LieGroup 𝓘(ℝ, ι → ℝ) ω G ∧ IsTopologicalGroup G ∧ + ConnectedSpace G ∧ SimplyConnectedSpace G ∧ SecondCountableTopology G ∧ + Group.IsNilpotent G ∧ Group.nilpotencyClass G ≤ s ∧ + IsClosed (Γ.map NilpotentLieBCHGroup.realificationHom : Set G) ∧ + IsDiscrete (Γ.map NilpotentLieBCHGroup.realificationHom : Set G) ∧ + CompactSpace (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) ∧ + IsCoveringMap (QuotientGroup.mk : G → G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := by + obtain ⟨τ, hA, hS, hT, hG, hC, hSC, hclosed, hdiscrete, hcompact⟩ := + exists_realification_cocompact_lattice e Γ l hl hinner houter + let : TopologicalSpace E := τ + let : IsTopologicalAddGroup E := hA + let : ContinuousSMul ℝ E := hS + let : T2Space E := hT + refine ⟨τ, NilpotentLieBCHGroup.basisChartedSpace (e.baseChange ℝ), + hA, hS, hT, NilpotentLieBCHGroup.lieGroup_basis (e.baseChange ℝ) ω, + hG, hC, hSC, ?_, NilpotentLieBCHGroup.isNilpotentGroup, + NilpotentLieBCHGroup.nilpotencyClass_le, hclosed, hdiscrete, hcompact, ?_⟩ + · exact (NilpotentLieBCHGroup.basisHomeomorph (e.baseChange ℝ)).secondCountableTopology + · exact isCoveringMap_realification_quotient e Γ l hl houter + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Set + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +@[instance_reducible] +noncomputable def quotientMetricSpace (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) : + MetricSpace (NilpotentLieBCHGroup L s hnil ⧸ Γ) := by + letI : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace_isIsometricSMul (hnil := hnil) e + exact rightCosetMetricSpace Γ hΓ + +theorem quotientMetricSpace_topology (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) : + (quotientMetricSpace e Γ hΓ).toUniformSpace.toTopologicalSpace = + (inferInstance : TopologicalSpace (NilpotentLieBCHGroup L s hnil ⧸ Γ)) := rfl + +theorem quotientMetricSpace_edist_mk (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (x y : NilpotentLieBCHGroup L s hnil) : + letI := rightMetricSpace (hnil := hnil) e + letI := quotientMetricSpace e Γ hΓ + edist (QuotientGroup.mk x : _ ⧸ Γ) (QuotientGroup.mk y) = ⨅ γ : Γ, edist x (y * γ) := rfl + +theorem quotientMetricSpace_lipschitz_mk (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) : + letI := rightMetricSpace (hnil := hnil) e + letI := quotientMetricSpace e Γ hΓ + LipschitzWith 1 (QuotientGroup.mk : NilpotentLieBCHGroup L s hnil → _ ⧸ Γ) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + exact rightCosetMetricSpace_lipschitz_mk Γ hΓ + +end Erdos3.NilpotentLieBCHGroup + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +local notation "G" => NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil) + +@[instance_reducible] +noncomputable def realificationQuotientMetricSpace (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + MetricSpace (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := + NilpotentLieBCHGroup.quotientMetricSpace (e.baseChange ℝ) + (Γ.map NilpotentLieBCHGroup.realificationHom) + (NilpotentLieBCHGroup.realification_subgroup_closed_discrete e Γ l hl houter).1 + +theorem realificationQuotientMetricSpace_topology (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + (realificationQuotientMetricSpace e Γ l hl houter).toUniformSpace.toTopologicalSpace = + (inferInstance : TopologicalSpace (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom)) := rfl + +theorem realificationQuotientMetricSpace_compact (e : Basis ι ℚ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + letI := realificationQuotientMetricSpace e Γ l hl houter + CompactSpace (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := + compactSpace_realification_quotient e Γ l hl hinner + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable {ι κ L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + +noncomputable def realificationLieHom (φ : L →ₗ⁅ℚ⁆ M) : + (ℝ ⊗[ℚ] L) →ₗ⁅ℝ⁆ (ℝ ⊗[ℚ] M) where + toLinearMap := φ.toLinearMap.baseChange ℝ + map_lie' {x y} := (LieAlgebra.ExtendScalars.map (AlgHom.id ℚ ℝ) φ).map_lie x y + +@[simp] theorem realificationLieHom_tmul (φ : L →ₗ⁅ℚ⁆ M) (a : ℝ) (x : L) : + realificationLieHom φ (a ⊗ₜ[ℚ] x) = a ⊗ₜ[ℚ] φ x := rfl + +theorem realificationLieHom_inclusion (φ : L →ₗ⁅ℚ⁆ M) (x : L) : + realificationLieHom φ (rationalLieInclusion x) = rationalLieInclusion (φ x) := rfl + +theorem realificationLieHom_basis (e : Basis ι ℚ L) (f : Basis κ ℚ M) + (φ : L →ₗ⁅ℚ⁆ M) (k : κ) (i : ι) : + (f.baseChange ℝ).repr (realificationLieHom φ ((e.baseChange ℝ) i)) k = + (f.repr (φ (e i)) k : ℝ) := by + simp only [Basis.baseChange_apply, realificationLieHom_tmul, Basis.baseChange_repr_tmul] + simp [Algebra.smul_def] + +namespace NilpotentLieBCHGroup + +variable {s t : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +noncomputable def realificationMap (φ : L →ₗ⁅ℚ⁆ M) : + NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil) →* + NilpotentLieBCHGroup (ℝ ⊗[ℚ] M) t (realification_lowerCentralSeries_eq_bot hM) := + mapReal (realificationLieHom φ) + +@[simp] theorem realificationMap_coord (φ : L →ₗ⁅ℚ⁆ M) + (g : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) : + (realificationMap (hnil := hnil) (hM := hM) φ g).coord = realificationLieHom φ g.coord := rfl + +theorem realificationMap_realificationHom_ofSteps (φ : L →ₗ⁅ℚ⁆ M) + (g : NilpotentLieBCHGroup L s hnil) : + realificationMap (hnil := hnil) (hM := hM) φ (realificationHom g) = + realificationHom (mapOfSteps (hM := hM) φ g) := by + apply ext + rfl + +theorem realificationMap_realificationHom + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + (φ : L →ₗ⁅ℚ⁆ M) (g : NilpotentLieBCHGroup L s hnil) : + realificationMap (hnil := hnil) (hM := hM) φ (realificationHom g) = + realificationHom (map (hM := hM) φ g) := by + apply ext + rfl + +theorem realificationMap_subgroup (φ : L →ₗ⁅ℚ⁆ M) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (Λ : Subgroup (NilpotentLieBCHGroup M t hM)) (hφ : Γ ≤ Λ.comap (mapOfSteps φ)) : + Γ.map realificationHom ≤ (Λ.map realificationHom).comap + (realificationMap (hnil := hnil) (hM := hM) φ) := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Subgroup.mem_map.mp hx + change realificationMap (hnil := hnil) (hM := hM) φ (realificationHom y) ∈ Λ.map realificationHom + rw [realificationMap_realificationHom_ofSteps (hM := hM)] + exact Subgroup.mem_map.mpr ⟨mapOfSteps φ y, hφ hy, rfl⟩ + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +def coordinateLipschitzBound (m n : ℕ) (B : ℝ≥0) : ℝ≥0 := + ((m : ℝ≥0) + n + 1) * (B + 1) + +theorem coordinateLipschitzBound_pos (m n : ℕ) (B : ℝ≥0) : + 0 < coordinateLipschitzBound m n B := by + unfold coordinateLipschitzBound + positivity + +theorem coordinateLipschitzBound_le_exp (m n : ℕ) (B : ℝ≥0) {p : ℝ} + (hp : 0 ≤ p) (hm : (m : ℝ) ≤ p) (hn : (n : ℝ) ≤ p) + (hB : (B : ℝ) ≤ Real.exp p) : + (coordinateLipschitzBound m n B : ℝ) ≤ Real.exp ((p + 2) ^ 2) := by + have hdim : (m : ℝ) + n + 1 ≤ Real.exp (2 * p) := by + linarith [Real.add_one_le_exp (2 * p)] + have htwo : (2 : ℝ) ≤ Real.exp 1 := by + linarith [Real.add_one_le_exp (1 : ℝ)] + have hheight : (B : ℝ) + 1 ≤ Real.exp (p + 1) := by + calc + _ ≤ Real.exp p * 2 := by linarith [Real.one_le_exp_iff.mpr hp] + _ ≤ Real.exp p * Real.exp 1 := mul_le_mul_of_nonneg_left htwo (Real.exp_nonneg _) + _ = Real.exp (p + 1) := (Real.exp_add _ _).symm + change ((m : ℝ) + n + 1) * ((B : ℝ) + 1) ≤ _ + calc + _ ≤ Real.exp (2 * p) * Real.exp (p + 1) := + mul_le_mul hdim hheight (by positivity) (Real.exp_nonneg _) + _ = Real.exp (3 * p + 1) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp ((p + 2) ^ 2) := Real.exp_le_exp.mpr (by nlinarith [sq_nonneg p]) + +namespace NilpotentLieBCHGroup + +open Module + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] [IsScalarTower ℚ ℝ M] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + {s t : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +variable (e : Basis ι ℝ L) (f : Basis κ ℝ M) (φ : L →ₗ⁅ℝ⁆ M) + +theorem lipschitz_mapReal_of_entry_bound (B : ℝ≥0) + (hφ : ∀ k i, |f.repr (φ (e i)) k| ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + LipschitzWith (coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B) + (mapReal (hnil := hnil) (hM := hM) φ) := by + apply lipschitz_mapReal_of_coordinate_bound e f φ (coordinateLipschitzBound_pos _ _ _) + intro w + exact basisCoordinateMap_L2_bound e f φ.toLinearMap B B.coe_nonneg hφ w + +theorem lipschitz_mapReal_of_rational_height (A : κ → ι → ℚ) (H : ℕ) + (hA : ∀ k i, f.repr (φ (e i)) k = (A k i : ℝ)) + (hH : ∀ k i, RationalHeightLE (A k i) H) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + LipschitzWith (coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) H) + (mapReal (hnil := hnil) (hM := hM) φ) := by + apply lipschitz_mapReal_of_entry_bound e f φ H + intro k i + rw [hA] + exact (hH k i).abs_real_le + +theorem exists_mapReal_lipschitz_exp_bound (B : ℝ≥0) {p : ℝ} + (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hB : (B : ℝ) ≤ Real.exp p) (hφ : ∀ k i, |f.repr (φ (e i)) k| ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + ∃ C : ℝ≥0, 0 < C ∧ (C : ℝ) ≤ Real.exp ((p + 2) ^ 2) ∧ + LipschitzWith C (mapReal (hnil := hnil) (hM := hM) φ) := by + exact ⟨coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B, + coordinateLipschitzBound_pos _ _ _, coordinateLipschitzBound_le_exp _ _ B hp hκ hι hB, + lipschitz_mapReal_of_entry_bound e f φ B hφ⟩ + +variable (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (Λ : Subgroup (NilpotentLieBCHGroup M t hM)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (hΛ : IsClosed (Λ : Set (NilpotentLieBCHGroup M t hM))) + (hmap : Γ ≤ Λ.comap (mapReal φ)) + +theorem lipschitz_quotient_mapReal_of_entry_bound (B : ℝ≥0) + (hφ : ∀ k i, |f.repr (φ (e i)) k| ≤ B) : + letI := quotientMetricSpace e Γ hΓ + letI := quotientMetricSpace f Λ hΛ + LipschitzWith (coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B) + (cosetMap Γ Λ (mapReal φ) hmap) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let : FiniteDimensional ℝ M := f.finiteDimensional_of_finite + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace (hnil := hM) f + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hM) f + exact lipschitz_cosetMap Γ Λ hΓ hΛ (mapReal φ) hmap + (lipschitz_mapReal_of_entry_bound e f φ B hφ) + +theorem exists_quotient_mapReal_lipschitz_exp_bound (B : ℝ≥0) {p : ℝ} + (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hB : (B : ℝ) ≤ Real.exp p) (hφ : ∀ k i, |f.repr (φ (e i)) k| ≤ B) : + letI := quotientMetricSpace e Γ hΓ + letI := quotientMetricSpace f Λ hΛ + ∃ C : ℝ≥0, 0 < C ∧ (C : ℝ) ≤ Real.exp ((p + 2) ^ 2) ∧ + LipschitzWith C (cosetMap Γ Λ (mapReal φ) hmap) := by + exact ⟨coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B, + coordinateLipschitzBound_pos _ _ _, coordinateLipschitzBound_le_exp _ _ B hp hκ hι hB, + lipschitz_quotient_mapReal_of_entry_bound e f φ Γ Λ hΓ hΛ hmap B hφ⟩ + +end NilpotentLieBCHGroup + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +section Distance + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def basisRiemannianDist (e : Basis ι ℝ L) (x y : NilpotentLieBCHGroup L s hnil) : ℝ := + letI := rightMetricSpace (hnil := hnil) e + dist x y + +noncomputable def basisQuotientDist (e : Basis ι ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) (x y : _ ⧸ Γ) : ℝ := + letI := quotientMetricSpace e Γ hΓ + dist x y + +end Distance + +section Map + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] [IsScalarTower ℚ ℝ M] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +theorem basisRiemannianDist_mapReal_le (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : L →ₗ⁅ℝ⁆ M) (B : ℝ≥0) (hφ : ∀ k i, |f.repr (φ (e i)) k| ≤ B) + (x y : NilpotentLieBCHGroup L s hnil) : + basisRiemannianDist f (mapReal (hM := hM) φ x) (mapReal (hM := hM) φ y) ≤ + coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B * basisRiemannianDist e x y := by + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace (hnil := hM) f + exact (lipschitz_mapReal_of_entry_bound e f φ B hφ).dist_le_mul x y + +theorem basisQuotientDist_mapReal_le (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : L →ₗ⁅ℝ⁆ M) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (Λ : Subgroup (NilpotentLieBCHGroup M s hM)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (hΛ : IsClosed (Λ : Set (NilpotentLieBCHGroup M s hM))) + (hmap : Γ ≤ Λ.comap (mapReal φ)) (B : ℝ≥0) (hφ : ∀ k i, |f.repr (φ (e i)) k| ≤ B) + (x y : _ ⧸ Γ) : + basisQuotientDist f Λ hΛ (cosetMap Γ Λ (mapReal φ) hmap x) (cosetMap Γ Λ (mapReal φ) hmap y) ≤ + coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B * basisQuotientDist e Γ hΓ x y := by + let := quotientMetricSpace e Γ hΓ + let := quotientMetricSpace f Λ hΛ + exact (lipschitz_quotient_mapReal_of_entry_bound e f φ Γ Λ hΓ hΛ hmap B hφ).dist_le_mul x y + +end Map + +section BasisChange + +variable {ι κ L : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +omit [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] in +@[simp] theorem mapReal_id (x : NilpotentLieBCHGroup L s hnil) : + mapReal (hM := hnil) (LieHom.id : L →ₗ⁅ℝ⁆ L) x = x := rfl + +theorem basisRiemannianDist_change_le (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (B : ℝ≥0) (hB : ∀ k i, |f.repr (e i) k| ≤ B) (x y : NilpotentLieBCHGroup L s hnil) : + basisRiemannianDist f x y ≤ + coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B * basisRiemannianDist e x y := by + simpa only [mapReal_id] using + basisRiemannianDist_mapReal_le (hM := hnil) e f LieHom.id B hB x y + +theorem basisRiemannianDist_compare (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (B D : ℝ≥0) (hB : ∀ k i, |f.repr (e i) k| ≤ B) (hD : ∀ i k, |e.repr (f k) i| ≤ D) + (x y : NilpotentLieBCHGroup L s hnil) : + basisRiemannianDist f x y ≤ + coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B * basisRiemannianDist e x y ∧ + basisRiemannianDist e x y ≤ + coordinateLipschitzBound (Fintype.card ι) (Fintype.card κ) D * basisRiemannianDist f x y := + ⟨basisRiemannianDist_change_le e f B hB x y, basisRiemannianDist_change_le f e D hD x y⟩ + +theorem basisRiemannianDist_exp_change_le (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (B : ℝ≥0) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hBp : (B : ℝ) ≤ Real.exp p) (hB : ∀ k i, |f.repr (e i) k| ≤ B) + (x y : NilpotentLieBCHGroup L s hnil) : + basisRiemannianDist f x y ≤ Real.exp ((p + 2) ^ 2) * basisRiemannianDist e x y := by + let := rightMetricSpace (hnil := hnil) e + have hn : 0 ≤ basisRiemannianDist e x y := dist_nonneg + exact (basisRiemannianDist_change_le e f B hB x y).trans + (mul_le_mul_of_nonneg_right (coordinateLipschitzBound_le_exp _ _ B hp hκ hι hBp) hn) + +theorem basisRiemannianDist_exp_compare (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (B : ℝ≥0) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hBp : (B : ℝ) ≤ Real.exp p) + (hB : ∀ k i, |f.repr (e i) k| ≤ B) (hD : ∀ i k, |e.repr (f k) i| ≤ B) + (x y : NilpotentLieBCHGroup L s hnil) : + basisRiemannianDist f x y ≤ Real.exp ((p + 2) ^ 2) * basisRiemannianDist e x y ∧ + basisRiemannianDist e x y ≤ Real.exp ((p + 2) ^ 2) * basisRiemannianDist f x y := + ⟨basisRiemannianDist_exp_change_le e f B hp hι hκ hBp hB x y, + basisRiemannianDist_exp_change_le f e B hp hκ hι hBp hD x y⟩ + +theorem basisQuotientDist_change_le (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (B : ℝ≥0) (hB : ∀ k i, |f.repr (e i) k| ≤ B) (x y : _ ⧸ Γ) : + basisQuotientDist f Γ hΓ x y ≤ + coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B * basisQuotientDist e Γ hΓ x y := by + have hmap : Γ ≤ Γ.comap (mapReal (LieHom.id : L →ₗ⁅ℝ⁆ L)) := by + intro g hg + simpa only [Subgroup.mem_comap, mapReal_id] using hg + have heq : cosetMap Γ Γ (mapReal (LieHom.id : L →ₗ⁅ℝ⁆ L)) hmap = id := by + funext z + induction z using Quotient.inductionOn with + | h z => rfl + simpa only [heq, id_eq] using + basisQuotientDist_mapReal_le e f LieHom.id Γ Γ hΓ hΓ hmap B hB x y + +theorem basisQuotientDist_compare (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (B D : ℝ≥0) (hB : ∀ k i, |f.repr (e i) k| ≤ B) (hD : ∀ i k, |e.repr (f k) i| ≤ D) + (x y : _ ⧸ Γ) : + basisQuotientDist f Γ hΓ x y ≤ + coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) B * basisQuotientDist e Γ hΓ x y ∧ + basisQuotientDist e Γ hΓ x y ≤ + coordinateLipschitzBound (Fintype.card ι) (Fintype.card κ) D * basisQuotientDist f Γ hΓ x y := + ⟨basisQuotientDist_change_le e f Γ hΓ B hB x y, + basisQuotientDist_change_le f e Γ hΓ D hD x y⟩ + +theorem basisQuotientDist_exp_change_le (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (B : ℝ≥0) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hBp : (B : ℝ) ≤ Real.exp p) (hB : ∀ k i, |f.repr (e i) k| ≤ B) (x y : _ ⧸ Γ) : + basisQuotientDist f Γ hΓ x y ≤ Real.exp ((p + 2) ^ 2) * basisQuotientDist e Γ hΓ x y := by + let := quotientMetricSpace e Γ hΓ + have hn : 0 ≤ basisQuotientDist e Γ hΓ x y := dist_nonneg + exact (basisQuotientDist_change_le e f Γ hΓ B hB x y).trans + (mul_le_mul_of_nonneg_right (coordinateLipschitzBound_le_exp _ _ B hp hκ hι hBp) hn) + +theorem basisQuotientDist_exp_compare (e : Basis ι ℝ L) (f : Basis κ ℝ L) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (B : ℝ≥0) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hBp : (B : ℝ) ≤ Real.exp p) + (hB : ∀ k i, |f.repr (e i) k| ≤ B) (hD : ∀ i k, |e.repr (f k) i| ≤ B) (x y : _ ⧸ Γ) : + basisQuotientDist f Γ hΓ x y ≤ Real.exp ((p + 2) ^ 2) * basisQuotientDist e Γ hΓ x y ∧ + basisQuotientDist e Γ hΓ x y ≤ Real.exp ((p + 2) ^ 2) * basisQuotientDist f Γ hΓ x y := + ⟨basisQuotientDist_exp_change_le e f Γ hΓ B hp hι hκ hBp hB x y, + basisQuotientDist_exp_change_le f e Γ hΓ B hp hκ hι hBp hD x y⟩ + +end BasisChange + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (a : NilpotentLieBCHGroup L s hnil) + +theorem lipschitz_conjugation_of_basis_bound (B : ℝ≥0) + (hB : ∀ i k, |e.repr (a * (⟨e i⟩ : NilpotentLieBCHGroup L s hnil) * a⁻¹).coord k| ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + LipschitzWith (coordinateLipschitzBound (Fintype.card ι) (Fintype.card ι) B) + (MulAut.conj a) := by + classical + apply lipschitz_linear_hom e e (MulAut.conj a).toMonoidHom (conjugationLinearMap e a) + (homCoordinates_conjugation_eq e a) (coordinateLipschitzBound_pos _ _ _) + intro v + apply coordinateLinearMap_L2_bound _ B B.coe_nonneg + intro k i + rw [conjugationLinearMap_basis] + exact hB i k + +theorem lipschitz_mul_left_of_basis_bound (B : ℝ≥0) + (hB : ∀ i k, |e.repr (a * (⟨e i⟩ : NilpotentLieBCHGroup L s hnil) * a⁻¹).coord k| ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + LipschitzWith (coordinateLipschitzBound (Fintype.card ι) (Fintype.card ι) B) + (fun x => a * x) := by + let := rightMetricSpace (hnil := hnil) e + have h := (rightMetricSpace_isometry_mul_right e a).lipschitzWith.comp + (lipschitz_conjugation_of_basis_bound e a B hB) + simpa only [one_mul, Function.comp_def, MulAut.conj_apply, mul_assoc, inv_mul_cancel, mul_one] using h + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped TensorProduct NNReal + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + {s t : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +variable (e : Basis ι ℚ L) (f : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + +theorem lipschitz_realificationMap (H : ℕ) + (hH : ∀ k i, RationalHeightLE (f.repr (φ (e i)) k) H) : + letI := rightMetricSpace (hnil := realification_lowerCentralSeries_eq_bot hnil) (e.baseChange ℝ) + letI := rightMetricSpace (hnil := realification_lowerCentralSeries_eq_bot hM) (f.baseChange ℝ) + LipschitzWith (coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) H) + (realificationMap (hnil := hnil) (hM := hM) φ) := + lipschitz_mapReal_of_rational_height (e.baseChange ℝ) (f.baseChange ℝ) (realificationLieHom φ) + (fun k i => f.repr (φ (e i)) k) H (realificationLieHom_basis e f φ) hH + +theorem exists_realificationMap_lipschitz_exp_bound (H : ℕ) {p : ℝ} + (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hH : ∀ k i, RationalHeightLE (f.repr (φ (e i)) k) H) : + letI := rightMetricSpace (hnil := realification_lowerCentralSeries_eq_bot hnil) (e.baseChange ℝ) + letI := rightMetricSpace (hnil := realification_lowerCentralSeries_eq_bot hM) (f.baseChange ℝ) + ∃ C : ℝ≥0, 0 < C ∧ (C : ℝ) ≤ Real.exp ((p + 2) ^ 2) ∧ + LipschitzWith C (realificationMap (hnil := hnil) (hM := hM) φ) := + ⟨coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) H, + coordinateLipschitzBound_pos _ _ _, coordinateLipschitzBound_le_exp _ _ H hp hκ hι hHp, + lipschitz_realificationMap e f φ H hH⟩ + +variable (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (Λ : Subgroup (NilpotentLieBCHGroup M t hM)) (hφ : Γ ≤ Λ.comap (mapOfSteps φ)) + +theorem lipschitz_realificationMap_quotient (l m : ℕ) (hl : 0 < l) (hm : 0 < m) + (hΓ : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (hΛ : bchSubgroupCoordinates f Λ ⊆ denominatorGrid m) + (H : ℕ) (hH : ∀ k i, RationalHeightLE (f.repr (φ (e i)) k) H) : + letI := realificationQuotientMetricSpace e Γ l hl hΓ + letI := realificationQuotientMetricSpace f Λ m hm hΛ + LipschitzWith (coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) H) + (cosetMap (Γ.map realificationHom) (Λ.map realificationHom) + (realificationMap (hnil := hnil) (hM := hM) φ) + (realificationMap_subgroup φ Γ Λ hφ)) := by + apply lipschitz_quotient_mapReal_of_entry_bound (e.baseChange ℝ) (f.baseChange ℝ) + (realificationLieHom φ) (Γ.map realificationHom) (Λ.map realificationHom) + (realification_subgroup_closed_discrete e Γ l hl hΓ).1 + (realification_subgroup_closed_discrete f Λ m hm hΛ).1 + (realificationMap_subgroup φ Γ Λ hφ) H + intro k i + rw [realificationLieHom_basis] + exact (hH k i).abs_real_le + +theorem exists_realificationMap_quotient_lipschitz_exp_bound + (l m : ℕ) (hl : 0 < l) (hm : 0 < m) + (hΓ : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (hΛ : bchSubgroupCoordinates f Λ ⊆ denominatorGrid m) + (H : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hκ : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hH : ∀ k i, RationalHeightLE (f.repr (φ (e i)) k) H) : + letI := realificationQuotientMetricSpace e Γ l hl hΓ + letI := realificationQuotientMetricSpace f Λ m hm hΛ + ∃ C : ℝ≥0, 0 < C ∧ (C : ℝ) ≤ Real.exp ((p + 2) ^ 2) ∧ + LipschitzWith C (cosetMap (Γ.map realificationHom) (Λ.map realificationHom) + (realificationMap (hnil := hnil) (hM := hM) φ) (realificationMap_subgroup φ Γ Λ hφ)) := + ⟨coordinateLipschitzBound (Fintype.card κ) (Fintype.card ι) H, + coordinateLipschitzBound_pos _ _ _, coordinateLipschitzBound_le_exp _ _ H hp hκ hι hHp, + lipschitz_realificationMap_quotient e f φ Γ Λ hφ l m hl hm hΓ hΛ H hH⟩ + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem quotient_dist_eq_on_ball_of_lattice_grid + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ γ ∈ Γ, e.equivFun γ.coord ∈ realDenominatorGrid l) : + letI := rightMetricSpace (hnil := hnil) e + ∀ (C : ℝ≥0), 0 < C → ∀ z : NilpotentLieBCHGroup L s hnil, + LipschitzWith C (fun x => z⁻¹ * x) → + letI := quotientMetricSpace e Γ hΓ + ∀ {x y : NilpotentLieBCHGroup L s hnil}, + dist x z ≤ bchLatticeSeparationRadius s (Fintype.card ι) H l / (4 * C) → + dist y z ≤ bchLatticeSeparationRadius s (Fintype.card ι) H l / (4 * C) → + dist (QuotientGroup.mk x : _ ⧸ Γ) (QuotientGroup.mk y) = dist x y := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + intro C hC z hleft + have hC' : (0 : ℝ) < C := hC + have hgap := fun γ hγ hne => latticeSeparationRadius_le_dist e c hstructure hc Γ l hl hgrid γ hγ hne + apply quotient_dist_eq_of_separated_ball Γ hΓ z _ + apply separated_ball_of_lipschitz_left Γ hC hgap ?_ z hleft + have heq : 4 * (bchLatticeSeparationRadius s (Fintype.card ι) H l / (4 * (C : ℝ))) * C = + bchLatticeSeparationRadius s (Fintype.card ι) H l := by + field_simp + exact heq.le + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSmoothChartPartition.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSmoothChartPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8eae9ada749b29c11bbbd41b803b74c54af325b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSmoothChartPartition.lean @@ -0,0 +1,232 @@ +import OAI.Combinatorics.Progressions.Estimates.AmbientImageExtension +import OAI.Combinatorics.Progressions.Estimates.NormalizedCutoffs +import OAI.Combinatorics.Progressions.Nilpotent.BCHQuotientLocalIsometry + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Set +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem ball_subset_quotient_coordinate_image + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) : + letI := rightMetricSpace (hnil := hnil) e + ∀ C : ℝ≥0, 0 < C → ∀ z : NilpotentLieBCHGroup L s hnil, + LipschitzWith C (fun x => z⁻¹ * x) → ∀ r : ℝ, 0 < r → r ≤ 1 → + letI := quotientMetricSpace e Γ hΓ + let M := C * (bchLogMetricConstant s (Fintype.card ι) H 1) ^ 2 + let q := fun u => (QuotientGroup.mk (z * (basisHomeomorph e).symm u) : _ ⧸ Γ) + ∀ v : ι → ℝ, (∀ i, |v i| ≤ 3 * r / 4) → + Metric.ball (q v) (r / (4 * (M : ℝ))) ⊆ q '' {u | ∀ i, |u i| < r} := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + intro C hC z hleft r hr hr1 + let := quotientMetricSpace e Γ hΓ + dsimp only + intro v hv x hx + let C₀ := bchLogMetricConstant s (Fintype.card ι) H 1 + let M : ℝ≥0 := C * C₀ ^ 2 + have hC' : (0 : ℝ) < C := hC + have hC₀ : (1 : ℝ) ≤ C₀ := one_le_bchLogMetricConstant _ _ _ _ + have hM : (0 : ℝ) < M := by + change 0 < (C : ℝ) * (C₀ : ℝ) ^ 2 + positivity + obtain ⟨g, hg, hquot⟩ := rightCosetMetricSpace_exists_lift Γ hΓ + (z * (basisHomeomorph e).symm v) (r / (4 * (M : ℝ))) x hx + let a := (basisHomeomorph (hnil := hnil) e).symm v + let b := z⁻¹ * g + have hab : dist a b ≤ (C : ℝ) * dist g (z * a) := by + have ht := hleft.dist_le_mul (z * a) g + simpa only [inv_mul_cancel_left, dist_comm] using ht + have hsmall : (C₀ : ℝ) ^ 2 * dist a b < r / 4 := by + calc + _ ≤ (C₀ : ℝ) ^ 2 * ((C : ℝ) * dist g (z * a)) := + mul_le_mul_of_nonneg_left hab (sq_nonneg _) + _ = (M : ℝ) * dist g (z * a) := by simp only [M, NNReal.coe_mul, NNReal.coe_pow]; ring + _ < r / 4 := by + have ht := (lt_div_iff₀ (by positivity : 0 < 4 * (M : ℝ))).mp hg + apply (lt_div_iff₀ (by norm_num : (0 : ℝ) < 4)).mpr + nlinarith + have hnear : (C₀ : ℝ) * dist a b < 1 := by + have hsq : (C₀ : ℝ) ≤ (C₀ : ℝ) ^ 2 := by nlinarith + have ht := (mul_le_mul_of_nonneg_right hsq (dist_nonneg (x := a) (y := b))).trans_lt hsmall + linarith + have ha (i) : |e.repr a.coord i| ≤ 1 := by + change |basisHomeomorph (hnil := hnil) e ((basisHomeomorph e).symm v) i| ≤ 1 + rw [Homeomorph.apply_symm_apply] + linarith [hv i] + have hcoords := dist_coordinates_le_of_near_unit_box e c hstructure hc a b ha hnear + have hav : basisHomeomorph e a = v := Homeomorph.apply_symm_apply _ v + rw [hav] at hcoords + have hu : ∀ i, |basisHomeomorph e b i| < r := by + intro i + have hi := dist_le_pi_dist (basisHomeomorph e a) (basisHomeomorph e b) i + rw [hav, Real.dist_eq] at hi + have hb := abs_sub_abs_le_abs_sub (basisHomeomorph e b i) (v i) + rw [abs_sub_comm] at hb + have ht := (hi.trans hcoords).trans_lt hsmall + linarith [hv i] + refine ⟨basisHomeomorph e b, hu, ?_⟩ + change (QuotientGroup.mk (z * (basisHomeomorph e).symm (basisHomeomorph e b)) : _ ⧸ Γ) = x + rw [Homeomorph.symm_apply_apply] + simpa only [b, mul_inv_cancel_left] using hquot + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem lipschitz_quotient_chartCutoff + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) : + letI := rightMetricSpace (hnil := hnil) e + ∀ C : ℝ≥0, 0 < C → ∀ z : NilpotentLieBCHGroup L s hnil, + LipschitzWith C (fun x => z⁻¹ * x) → ∀ r : ℝ≥0, 0 < r → r ≤ 1 → + letI := quotientMetricSpace e Γ hΓ + ∀ φ : OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ), + (∀ v, φ v = QuotientGroup.mk (z * (basisHomeomorph e).symm v)) → + φ.source = {v | ∀ i, |v i| < (r : ℝ)} → + ∀ (ψ : (ι → ℝ) → ℝ) (A K : ℝ≥0), + (∀ v, 0 ≤ ψ v ∧ ψ v ≤ 1) → + (∀ v, (∃ i, 3 * (r : ℝ) / 4 ≤ |v i|) → ψ v = 0) → + LipschitzWith A ψ → LipschitzOnWith K φ.symm φ.target → + LipschitzWith (A * K + 1 / (r / (4 * (C * bchLogMetricConstant s (Fintype.card ι) H 1 ^ 2)))) + (chartCutoff φ ψ) := by + let := rightMetricSpace (hnil := hnil) e + intro C hC z hleft r hr hr1 + let := quotientMetricSpace e Γ hΓ + intro φ hφ hsource ψ A K hψ hzero hLip hInv + let M := C * bchLogMetricConstant s (Fintype.card ι) H 1 ^ 2 + let δ : ℝ≥0 := r / (4 * M) + have hδ : 0 < δ := by + exact div_pos hr (mul_pos (by norm_num) (mul_pos hC (pow_pos (bchLogMetricConstant_pos _ _ _ _) _))) + apply lipschitz_chartCutoff φ ψ A K δ hδ hψ hLip hInv + intro x hx hn y hy + have hv (i) : |φ.symm x i| ≤ 3 * (r : ℝ) / 4 := by + by_contra! hi + exact hn (hzero _ ⟨i, hi.le⟩) + have hball := ball_subset_quotient_coordinate_image e c hstructure hc Γ hΓ C hC z hleft + r hr hr1 (φ.symm x) hv + have heqx : (QuotientGroup.mk (z * (basisHomeomorph e).symm (φ.symm x)) : _ ⧸ Γ) = x := + (hφ _).symm.trans (φ.right_inv hx) + dsimp only at hball + rw [heqx] at hball + by_contra! hd + have hyball : y ∈ Metric.ball x ((r : ℝ) / (4 * (M : ℝ))) := by + simpa only [Metric.mem_ball, dist_comm, δ, NNReal.coe_div, NNReal.coe_mul, NNReal.coe_ofNat] using hd + obtain ⟨u, hu, heq⟩ := hball hyball + apply hy + have hus : u ∈ φ.source := by rwa [hsource] + have hym : φ u = y := (hφ u).trans heq + exact hym ▸ φ.map_source hus + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal Manifold ContDiff + +variable {ι κ L : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem exists_smooth_quotient_chart_partition + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) : + letI := rightMetricSpace (hnil := hnil) e + ∀ C : ℝ≥0, 0 < C → ∀ centers : κ → NilpotentLieBCHGroup L s hnil, + (∀ j, LipschitzWith C (fun x => (centers j)⁻¹ * x)) → + ∀ r : ℝ≥0, 0 < r → r ≤ 1 → + letI := quotientMetricSpace e Γ hΓ + letI := basisChartedSpace (hnil := hnil) e + ∀ (φ : κ → OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ)) (K : ℝ≥0), + (∀ j v, φ j v = QuotientGroup.mk (centers j * (basisHomeomorph e).symm v)) → + (∀ j, (φ j).source = {v | ∀ i, |v i| < (r : ℝ)}) → + (∀ j, LipschitzOnWith K (φ j).symm (φ j).target) → + (∀ x, ∃ j v, (∀ i, |v i| ≤ (r : ℝ) / 2) ∧ φ j v = x) → + ∀ (ψ : (ι → ℝ) → ℝ) (A : ℝ≥0), ContDiff ℝ ∞ ψ → + (∀ v, 0 ≤ ψ v ∧ ψ v ≤ 1) → + (∀ v, (∀ i, |v i| ≤ (r : ℝ) / 2) → ψ v = 1) → + (∀ v, (∃ i, 3 * (r : ℝ) / 4 ≤ |v i|) → ψ v = 0) → LipschitzWith A ψ → + let Q := (Fintype.card κ + 1) * + (A * K + 1 / (r / (4 * (C * bchLogMetricConstant s (Fintype.card ι) H 1 ^ 2)))) + ∃ f : κ → (_ ⧸ Γ) → ℝ, + (∀ j x, 0 ≤ f j x ∧ f j x ≤ 1) ∧ (∀ x, ∑ j, f j x = 1) ∧ + (∀ j, HasCompactSupport (f j) ∧ tsupport (f j) ⊆ (φ j).target) ∧ + (∀ j, ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ℝ) ∞ + (fun g : NilpotentLieBCHGroup L s hnil => f j (QuotientGroup.mk g))) ∧ + (∀ j, LipschitzWith Q (f j)) ∧ + (∀ j, tsupport (f j) ⊆ φ j '' Metric.closedBall 0 (3 * (r : ℝ) / 4)) := by + let := rightMetricSpace (hnil := hnil) e + intro C hC centers hleft r hr hr1 + let := quotientMetricSpace e Γ hΓ + let := basisChartedSpace (hnil := hnil) e + intro φ K hφ hsource hInv hcover ψ A hsmooth hrange hone hzero hLip + dsimp only + let g := fun j => chartCutoff (φ j) ψ + have hgpos (j) (x) : 0 ≤ g j x := (chartCutoff_range (φ j) ψ hrange x).1 + have hgrange (j) (x) : 0 ≤ g j x ∧ g j x ≤ 1 := chartCutoff_range (φ j) ψ hrange x + have hgcover (x) : ∃ j, g j x = 1 := by + obtain ⟨j, v, hv, rfl⟩ := hcover x + exact ⟨j, boxChartCutoff_eq_one (φ j) ψ hr (hsource j) hone v hv⟩ + have hgsupport (j) : HasCompactSupport (g j) ∧ tsupport (g j) ⊆ (φ j).target := + boxChartCutoff_support (φ j) ψ hr (hsource j) hzero + have hgsmooth (j) : ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ℝ) ∞ + (fun x : NilpotentLieBCHGroup L s hnil => g j (QuotientGroup.mk x)) := + contMDiff_quotient_chartCutoff e Γ (centers j) (φ j) (hφ j) ψ hsmooth (hgsupport j).2 + have hgLip (j) := lipschitz_quotient_chartCutoff e c hstructure hc Γ hΓ C hC + (centers j) (hleft j) r hr hr1 (φ j) (hφ j) (hsource j) ψ A K hrange hzero hLip (hInv j) + refine ⟨normalizedCutoffs g, normalizedCutoffs_range g hgpos hgcover, + sum_normalizedCutoffs g hgpos hgcover, ?_, ?_, ?_, ?_⟩ + · intro j + have hs := tsupport_normalizedCutoffs_subset g j + exact ⟨(hgsupport j).1.of_isClosed_subset isClosed_closure hs, hs.trans (hgsupport j).2⟩ + · exact fun j => contMDiff_normalizedCutoffs_comp g QuotientGroup.mk hgsmooth hgpos hgcover j + · exact fun j => lipschitz_normalizedCutoffs g _ hgLip hgrange hgcover j + · intro j + exact (tsupport_normalizedCutoffs_subset g j).trans + (tsupport_chartCutoff_subset (φ j) ψ (isCompact_closedBall _ _) + (closedBox_subset_chart_source (φ j) hr (hsource j)) + (support_subset_box_of_cutoff ψ hr hzero)) + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSmoothPartitionBudget.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSmoothPartitionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..113aee1bd5a560d4018b0dc98691bd388e6a8504 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSmoothPartitionBudget.lean @@ -0,0 +1,796 @@ +import OAI.Combinatorics.Progressions.Geometry.QuantitativeMetricPartition +import OAI.Combinatorics.Progressions.Nilpotent.BCHSmoothChartPartition + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Manifold MeasureTheory +open scoped Manifold ContDiff Bundle ENNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (v : ι → ℝ) + +theorem norm_mfderiv_coordinateLine (t : ℝ) : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + ‖mfderiv 𝓘(ℝ) 𝓘(ℝ, ι → ℝ) (coordinateLine (hnil := hnil) e v) t 1‖ = coordinateL2Norm v := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + have hv := (congrArg (fun w : ι → ℝ => rightVelocity e (coordinateLine (hnil := hnil) e v t) w) + (mfderiv_coordinateLine (hnil := hnil) e v t)).trans (rightVelocity_coordinateLine e v t) + exact (norm_tangent_eq_coordinateL2Norm e (coordinateLine (hnil := hnil) e v t) _).trans + (congrArg coordinateL2Norm hv) + +theorem enorm_mfderiv_coordinateLine (t : ℝ) : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + ‖mfderiv 𝓘(ℝ) 𝓘(ℝ, ι → ℝ) (coordinateLine (hnil := hnil) e v) t 1‖ₑ = + ENNReal.ofReal (coordinateL2Norm v) := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + rw [← ofReal_norm] + exact congrArg ENNReal.ofReal (norm_mfderiv_coordinateLine e v t) + +theorem pathELength_coordinateLine : + letI := basisChartedSpace (hnil := hnil) e + letI := rightRiemannianBundle (hnil := hnil) e + pathELength 𝓘(ℝ, ι → ℝ) (coordinateLine (hnil := hnil) e v) 0 1 = + ENNReal.ofReal (coordinateL2Norm v) := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + rw [pathELength_eq_lintegral_mfderiv_Icc] + have hf : (fun t : ℝ => ‖mfderiv 𝓘(ℝ) 𝓘(ℝ, ι → ℝ) (coordinateLine (hnil := hnil) e v) t 1‖ₑ) = + fun _ => ENNReal.ofReal (coordinateL2Norm v) := + funext (enorm_mfderiv_coordinateLine e v) + rw [hf] + simp + +theorem dist_one_le_coordinateL2Norm (g : NilpotentLieBCHGroup L s hnil) : + letI := rightMetricSpace (hnil := hnil) e + dist 1 g ≤ coordinateL2Norm (basisHomeomorph e g) := by + let := basisChartedSpace (hnil := hnil) e + let := rightRiemannianBundle (hnil := hnil) e + let := rightMetricSpace (hnil := hnil) e + have hedist : edist 1 g ≤ ENNReal.ofReal (coordinateL2Norm (basisHomeomorph e g)) := by + apply (riemannianEDist_le_pathELength + (contMDiff_coordinateLine e (basisHomeomorph e g) 1).contMDiffOn + (coordinateLine_zero e _) (by simp only [coordinateLine_one, Homeomorph.symm_apply_apply]) + zero_le_one).trans_eq + exact pathELength_coordinateLine e _ + rw [dist_edist] + exact (ENNReal.toReal_mono (by simp) hedist).trans_eq + (ENNReal.toReal_ofReal (coordinateL2Norm_nonneg _)) + +theorem dist_le_coordinateL2Norm_mul_inv (x y : NilpotentLieBCHGroup L s hnil) : + letI := rightMetricSpace (hnil := hnil) e + dist x y ≤ coordinateL2Norm (basisHomeomorph e (x * y⁻¹)) := by + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + rw [← dist_mul_right x y y⁻¹, mul_inv_cancel, dist_comm] + exact dist_one_le_coordinateL2Norm e (x * y⁻¹) + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open scoped NNReal + +noncomputable def bchBoxMetricConstant (s d H : ℕ) (B : ℝ≥0) : ℝ≥0 := + ⟨(d + 1) * bchBoxCoordinateBound s d H B, + mul_nonneg (by positivity) (bchBoxCoordinateBound_nonneg s d H B.coe_nonneg)⟩ + +namespace NilpotentLieBCHGroup + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) {H : ℕ} + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + +include hstructure hc + +theorem dist_le_bchBoxMetricConstant (B : ℝ≥0) (hB : 1 ≤ B) {δ : ℝ} (hδ : 0 ≤ δ) + (x y : NilpotentLieBCHGroup L s hnil) + (hx : ∀ i, |e.repr x.coord i| ≤ B) (hy : ∀ i, |e.repr y.coord i| ≤ B) + (hxy : ∀ i, |e.repr x.coord i - e.repr y.coord i| ≤ δ) : + letI := rightMetricSpace (hnil := hnil) e + dist x y ≤ bchBoxMetricConstant s (Fintype.card ι) H B * δ := by + let := rightMetricSpace (hnil := hnil) e + have hBr : (1 : ℝ) ≤ B := by exact_mod_cast hB + have hcoord (i : ι) : |basisHomeomorph e (x * y⁻¹) i| ≤ + bchBoxCoordinateBound s (Fintype.card ι) H B * δ := + lieBCH_sub_coordinates_bound e c hstructure hc hnil x.coord y.coord hBr hδ hx hy hxy i + calc + _ ≤ coordinateL2Norm (basisHomeomorph e (x * y⁻¹)) := dist_le_coordinateL2Norm_mul_inv e x y + _ ≤ (Fintype.card ι + 1) * (bchBoxCoordinateBound s (Fintype.card ι) H B * δ) := + coordinateL2Norm_le_card_bound _ + (mul_nonneg (bchBoxCoordinateBound_nonneg s _ H B.coe_nonneg) hδ) hcoord + _ = _ := by change _ = ((Fintype.card ι + 1) * bchBoxCoordinateBound s (Fintype.card ι) H B) * δ; ring + +theorem lipschitzOn_basisHomeomorph_symm_box (B : ℝ≥0) (hB : 1 ≤ B) : + letI := rightMetricSpace (hnil := hnil) e + LipschitzOnWith (bchBoxMetricConstant s (Fintype.card ι) H B) + (basisHomeomorph (hnil := hnil) e).symm {v | ∀ i, |v i| ≤ B} := by + let := rightMetricSpace (hnil := hnil) e + apply LipschitzOnWith.of_dist_le_mul + intro v hv w hw + apply dist_le_bchBoxMetricConstant e c hstructure hc B hB dist_nonneg + · intro i + change |basisHomeomorph (hnil := hnil) e ((basisHomeomorph (hnil := hnil) e).symm v) i| ≤ _ + simpa only [Homeomorph.apply_symm_apply] using hv i + · intro i + change |basisHomeomorph (hnil := hnil) e ((basisHomeomorph (hnil := hnil) e).symm w) i| ≤ _ + simpa only [Homeomorph.apply_symm_apply] using hw i + · intro i + change |basisHomeomorph (hnil := hnil) e ((basisHomeomorph (hnil := hnil) e).symm v) i - + basisHomeomorph (hnil := hnil) e ((basisHomeomorph (hnil := hnil) e).symm w) i| ≤ _ + simpa only [Homeomorph.apply_symm_apply, Real.dist_eq] using dist_le_pi_dist v w i + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [LieRing M] [LieAlgebra ℚ M] [LieAlgebra ℝ M] [IsScalarTower ℚ ℝ M] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + [TopologicalSpace M] [IsTopologicalAddGroup M] [ContinuousSMul ℝ M] [T2Space M] + {s t H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M t = ⊥} + +theorem dist_linear_lift_le (e : Basis ι ℝ L) (f : Basis κ ℝ M) (σ : M →ₗ[ℝ] L) + (B : ℝ≥0) (hσB : ∀ i j, |e.repr (σ (f j)) i| ≤ B) + (c : κ → κ → κ → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = f.repr ⁅f i, f j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + let C := bchLogMetricConstant t (Fintype.card κ) H 1 + let K := coordinateLipschitzBound (Fintype.card ι) (Fintype.card κ) B * + ((Fintype.card κ : ℝ≥0) + 1) * C + ∀ g : NilpotentLieBCHGroup M t hM, dist 1 g < (C⁻¹ : ℝ≥0) → + dist 1 (⟨σ g.coord⟩ : NilpotentLieBCHGroup L s hnil) ≤ K * dist 1 g := by + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace (hnil := hM) f + let C := bchLogMetricConstant t (Fintype.card κ) H 1 + let A := coordinateLipschitzBound (Fintype.card ι) (Fintype.card κ) B + change ∀ g : NilpotentLieBCHGroup M t hM, dist 1 g < (C⁻¹ : ℝ≥0) → + dist 1 (⟨σ g.coord⟩ : NilpotentLieBCHGroup L s hnil) ≤ + (A * ((Fintype.card κ : ℝ≥0) + 1) * C : ℝ≥0) * dist 1 g + intro g hg + have hC : (0 : ℝ) < C := bchLogMetricConstant_pos t (Fintype.card κ) H 1 + have hnear : (C : ℝ) * dist 1 g < (1 : ℝ≥0) := by + rw [NNReal.coe_inv] at hg + change (C : ℝ) * dist 1 g < 1 + have hh := mul_lt_mul_of_pos_left hg hC + simpa only [mul_inv_cancel₀ hC.ne'] using hh + have hnorm := norm_coordinates_le_of_near_one f c hstructure hc 1 le_rfl g hnear + let h : NilpotentLieBCHGroup L s hnil := ⟨σ g.coord⟩ + have hcoord : basisHomeomorph e h = basisCoordinateMap f e σ (basisHomeomorph f g) := by + change e.equivFun (σ g.coord) = e.equivFun (σ (f.equivFun.symm (f.equivFun g.coord))) + rw [LinearEquiv.symm_apply_apply] + calc + dist 1 h ≤ coordinateL2Norm (basisHomeomorph e h) := dist_one_le_coordinateL2Norm e h + _ ≤ (A : ℝ) * coordinateL2Norm (basisHomeomorph f g) := by + rw [hcoord] + exact basisCoordinateMap_L2_bound f e σ B B.coe_nonneg hσB _ + _ ≤ A * (((Fintype.card κ : ℝ) + 1) * ‖basisHomeomorph f g‖) := by + apply mul_le_mul_of_nonneg_left _ A.coe_nonneg + exact coordinateL2Norm_le_card_bound _ (norm_nonneg _) (fun j => by + simpa only [Real.norm_eq_abs] using norm_le_pi_norm (basisHomeomorph f g) j) + _ ≤ A * (((Fintype.card κ : ℝ) + 1) * ((C : ℝ) * dist 1 g)) := by + gcongr + _ = _ := by simp only [NNReal.coe_mul, NNReal.coe_add, NNReal.coe_natCast, NNReal.coe_one]; ring + +theorem exists_local_metric_lifts_of_section (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : L →ₗ⁅ℝ⁆ M) (σ : M →ₗ[ℝ] L) (hσ : Function.RightInverse σ φ) + (B : ℝ≥0) (hσB : ∀ i j, |e.repr (σ (f j)) i| ≤ B) + (c : κ → κ → κ → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = f.repr ⁅f i, f j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + let C := bchLogMetricConstant t (Fintype.card κ) H 1 + let K := coordinateLipschitzBound (Fintype.card ι) (Fintype.card κ) B * + ((Fintype.card κ : ℝ≥0) + 1) * C + ∀ g : NilpotentLieBCHGroup M t hM, dist 1 g < (C⁻¹ : ℝ≥0) → + ∃ h : NilpotentLieBCHGroup L s hnil, + mapReal φ h = g ∧ dist 1 h ≤ K * dist 1 g := by + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace (hnil := hM) f + dsimp only + intro g hg + exact ⟨⟨σ g.coord⟩, ext (hσ g.coord), dist_linear_lift_le e f σ B hσB c hstructure hc g hg⟩ + +theorem exists_local_metric_lifts_on_image (e : Basis ι ℝ L) (f : Basis κ ℝ M) + (φ : L →ₗ⁅ℝ⁆ M) (σ : M →ₗ[ℝ] L) + (hσ : (φ.toLinearMap.comp σ).comp φ.toLinearMap = φ.toLinearMap) + (B : ℝ≥0) (hσB : ∀ i j, |e.repr (σ (f j)) i| ≤ B) + (c : κ → κ → κ → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = f.repr ⁅f i, f j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) : + letI := rightMetricSpace (hnil := hnil) e + letI := rightMetricSpace (hnil := hM) f + let C := bchLogMetricConstant t (Fintype.card κ) H 1 + let K := coordinateLipschitzBound (Fintype.card ι) (Fintype.card κ) B * + ((Fintype.card κ : ℝ≥0) + 1) * C + ∀ g ∈ (mapReal (hnil := hnil) (hM := hM) φ).range, dist 1 g < (C⁻¹ : ℝ≥0) → + ∃ h : NilpotentLieBCHGroup L s hnil, + mapReal φ h = g ∧ dist 1 h ≤ K * dist 1 g := by + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace (hnil := hM) f + dsimp only + intro g hgrange hg + obtain ⟨x, hx⟩ := hgrange + have hcoord : φ x.coord = g.coord := congrArg NilpotentLieBCHGroup.coord hx + have hs := DFunLike.congr_fun hσ x.coord + change φ (σ (φ x.coord)) = φ x.coord at hs + rw [hcoord] at hs + exact ⟨⟨σ g.coord⟩, ext hs, dist_linear_lift_le e f σ B hσB c hstructure hc g hg⟩ + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module + +theorem coordinateL2Norm_smul {ι : Type*} [Fintype ι] (r : ℝ) (v : ι → ℝ) : + coordinateL2Norm (r • v) = |r| * coordinateL2Norm v := by + unfold coordinateL2Norm + simp only [Pi.smul_apply, smul_eq_mul, mul_pow, ← Finset.mul_sum] + rw [Real.sqrt_mul (sq_nonneg r), Real.sqrt_sq_eq_abs] + +namespace NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +def realBCHLine (v : L) (r : ℝ) : NilpotentLieBCHGroup L s hnil := ⟨r • v⟩ + +theorem realBCHLine_zero (v : L) : realBCHLine (hnil := hnil) v 0 = 1 := by + apply ext + exact zero_smul ℝ v + +theorem realBCHLine_one (v : L) : realBCHLine (hnil := hnil) v 1 = ⟨v⟩ := by + apply ext + exact one_smul ℝ v + +theorem realBCHLine_add (v : L) (r t : ℝ) : + realBCHLine (hnil := hnil) v (r + t) = realBCHLine v r * realBCHLine v t := by + apply ext + change (r + t) • v = lieBCH s (r • v) (t • v) + rw [lieBCH_eq_add_of_lie_eq_zero hnil (by simp [smul_lie, lie_smul]), add_smul] + +theorem realBCHLine_commute (v : L) (hv : ∀ w : L, ⁅v, w⁆ = 0) + (r : ℝ) (g : NilpotentLieBCHGroup L s hnil) : Commute (realBCHLine v r) g := by + apply commute_of_lie_eq_zero + change ⁅r • v, g.coord⁆ = 0 + rw [smul_lie, hv, smul_zero] + +variable [IsScalarTower ℚ ℝ L] {ι : Type*} [Fintype ι] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + +theorem realBCHLine_dist_one_le (e : Basis ι ℝ L) (v : L) (r : ℝ) : + letI := rightMetricSpace (hnil := hnil) e + dist (realBCHLine (hnil := hnil) v r) 1 ≤ |r| * coordinateL2Norm (e.equivFun v) := by + let := rightMetricSpace (hnil := hnil) e + rw [dist_comm] + apply (dist_one_le_coordinateL2Norm e (realBCHLine v r)).trans_eq + change coordinateL2Norm (e.equivFun (r • v)) = _ + rw [map_smul, coordinateL2Norm_smul] + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem exists_bchBoxMetricConstant_exp_bound (s r : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ (d H : ℕ) (B : ℝ≥0) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (B : ℝ) ≤ Real.exp ((p + 2) ^ r) → + (bchBoxMetricConstant s d H B : ℝ) ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C, hC, hheight⟩ := exists_bchCoordinateHeight_exp_budget s + let D := C + 2 * s + r + 10 + refine ⟨D, by dsimp [D]; omega, ?_⟩ + intro d H B p hp hd hH hB + let t : ℝ := p + D + have hD3 : (3 : ℝ) ≤ D := by exact_mod_cast (show 3 ≤ D by dsimp [D]; omega) + have ht : 3 ≤ t := by dsimp [t]; linarith + have hp2 : p + 2 ≤ t := by dsimp [t]; linarith + have hd1 : (d : ℝ) + 1 ≤ t := by dsimp [t]; linarith + have hs1 : (s : ℝ) + 1 ≤ t := by + have h : (s : ℝ) + 1 ≤ D := by exact_mod_cast (show s + 1 ≤ D by dsimp [D]; omega) + dsimp [t] + linarith + have hbase : 2 * (d : ℝ) + 1 ≤ t ^ 2 := by nlinarith [sq_nonneg (t - 1)] + have hpoly : ((d : ℝ) + 1) * (((s : ℝ) + 1) * (2 * d + 1) ^ s) * (2 * d) * s ≤ + t ^ (2 * s + 5) := by + calc + _ ≤ t * (t * (t ^ 2) ^ s) * t ^ 2 * t := by + gcongr <;> linarith + _ = _ := by rw [← pow_mul, pow_add]; ring + have hpolyexp : ((d : ℝ) + 1) * (((s : ℝ) + 1) * (2 * d + 1) ^ s) * (2 * d) * s ≤ + Real.exp (t ^ (D - 1)) := by + apply hpoly.trans + apply (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ t) + (by dsimp [D]; omega : 2 * s + 5 ≤ D - 1)).trans + linarith [Real.add_one_le_exp (t ^ (D - 1))] + have hcoef : (bchCoordinateHeight s d H : ℝ) ≤ Real.exp (t ^ (D - 1)) := by + apply (hheight d H p hp hd hH).trans + apply Real.exp_le_exp.mpr + have hCD : (C : ℝ) ≤ D := by exact_mod_cast (show C ≤ D by dsimp [D]; omega) + apply (pow_le_pow_left₀ (by positivity) (show p + C ≤ t by dsimp [t]; linarith) C).trans + exact pow_le_pow_right₀ (by linarith) (by dsimp [D]; omega) + have hlength : ((s * (2 * d + 1) : ℕ) : ℝ) ≤ t ^ 3 := by + push_cast + calc + _ ≤ t * t ^ 2 := mul_le_mul (by linarith) hbase (by positivity) (by linarith) + _ = _ := by ring + have hinput : (B : ℝ) ^ (s * (2 * d + 1)) ≤ Real.exp (t ^ (D - 1)) := by + calc + _ ≤ (Real.exp ((p + 2) ^ r)) ^ (s * (2 * d + 1)) := + pow_le_pow_left₀ B.coe_nonneg hB _ + _ = Real.exp (((s * (2 * d + 1) : ℕ) : ℝ) * (p + 2) ^ r) := (Real.exp_nat_mul _ _).symm + _ ≤ Real.exp (t ^ 3 * t ^ r) := Real.exp_le_exp.mpr + (mul_le_mul hlength (pow_le_pow_left₀ (by linarith) hp2 r) (by positivity) (by positivity)) + _ = Real.exp (t ^ (r + 3)) := by rw [← pow_add, Nat.add_comm 3 r] + _ ≤ Real.exp (t ^ (D - 1)) := Real.exp_le_exp.mpr + (pow_le_pow_right₀ (by linarith) (by dsimp [D]; omega)) + change ((d : ℝ) + 1) * bchBoxCoordinateBound s d H B ≤ _ + unfold bchBoxCoordinateBound + push_cast + calc + _ = (((d : ℝ) + 1) * (((s : ℝ) + 1) * (2 * d + 1) ^ s) * (2 * d) * s) * + bchCoordinateHeight s d H * (B : ℝ) ^ (s * (2 * d + 1)) := by ring + _ ≤ Real.exp (t ^ (D - 1)) * Real.exp (t ^ (D - 1)) * Real.exp (t ^ (D - 1)) := + mul_le_mul (mul_le_mul hpolyexp hcoef (by positivity) (by positivity)) hinput + (by positivity) (by positivity) + _ = Real.exp (3 * t ^ (D - 1)) := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + _ ≤ Real.exp (t ^ D) := by + apply Real.exp_le_exp.mpr + calc + _ ≤ t * t ^ (D - 1) := mul_le_mul_of_nonneg_right ht (by positivity) + _ = _ := by rw [← pow_succ', Nat.sub_add_cancel (by dsimp [D]; omega : 1 ≤ D)] + _ = _ := rfl + +namespace NilpotentLieBCHGroup + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem lipschitzOn_quotient_basisHomeomorph_symm_box + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) (B : ℝ≥0) (hB : 1 ≤ B) : + letI := quotientMetricSpace e Γ hΓ + LipschitzOnWith (bchBoxMetricConstant s (Fintype.card ι) H B) + (fun v : ι → ℝ => (QuotientGroup.mk ((basisHomeomorph e).symm v) : _ ⧸ Γ)) + {v | ∀ i, |v i| ≤ B} := by + let := rightMetricSpace (hnil := hnil) e + let := quotientMetricSpace e Γ hΓ + simpa only [one_mul, Function.comp_def] using + (quotientMetricSpace_lipschitz_mk e Γ hΓ).comp_lipschitzOnWith + (lipschitzOn_basisHomeomorph_symm_box e c hstructure hc B hB) + +end NilpotentLieBCHGroup + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +theorem exists_coordinateBox_metric_cover {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) (B : ℝ≥0) (hB : 1 ≤ B) + {ε : ℝ} (hε : 0 < ε) : + let K := bchBoxMetricConstant s (Fintype.card ι) H B + let N := boxCoverMeshCount B K ε + ∃ centers : (ι → Fin (N + 1)) → coordinateBox (hnil := hnil) e B, + letI := rightMetricSpace (hnil := hnil) e + ∀ x : coordinateBox (hnil := hnil) e B, ∃ j, dist x (centers j) ≤ ε := by + let K := bchBoxMetricConstant s (Fintype.card ι) H B + let N := boxCoverMeshCount B K ε + have hN : 0 < N := boxCoverMeshCount_pos _ _ _ + let centers : (ι → Fin (N + 1)) → coordinateBox (hnil := hnil) e B := fun k => + ⟨(basisHomeomorph (hnil := hnil) e).symm (uniformBoxGrid B N k), by + intro i + change |basisHomeomorph (hnil := hnil) e + ((basisHomeomorph (hnil := hnil) e).symm (uniformBoxGrid B N k)) i| ≤ B + rw [Homeomorph.apply_symm_apply] + exact uniformBoxGrid_mem B.coe_nonneg hN k i⟩ + refine ⟨centers, ?_⟩ + let := rightMetricSpace (hnil := hnil) e + intro x + obtain ⟨j, hj⟩ := exists_uniformBoxGrid_approx (lt_of_lt_of_le zero_lt_one hB) hN + (basisHomeomorph (hnil := hnil) e x.val) x.property + refine ⟨j, ?_⟩ + have h := (lipschitzOn_basisHomeomorph_symm_box (hnil := hnil) e c hstructure hc B hB).dist_le_mul + (basisHomeomorph (hnil := hnil) e x.val) x.property + (uniformBoxGrid B N j) (uniformBoxGrid_mem B.coe_nonneg hN j) + have hdist := h.trans ((mul_le_mul_of_nonneg_left hj K.coe_nonneg).trans (boxCoverMeshCount_error K hε)) + simpa only [centers, Subtype.dist_eq, Homeomorph.symm_apply_apply] using hdist + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +noncomputable def bchInjectivityRadius (s d H l : ℕ) : ℝ := + 1 / (4 * ((l : ℝ) + 1) * (bchBoxCoordinateBound s d H 1 + 1)) + +theorem bchInjectivityRadius_pos (s d H l : ℕ) : 0 < bchInjectivityRadius s d H l := by + have := bchBoxCoordinateBound_nonneg s d H (B := 1) (by norm_num) + unfold bchInjectivityRadius + positivity + +theorem bchInjectivityRadius_le_one (s d H l : ℕ) : bchInjectivityRadius s d H l ≤ 1 := by + have hA := bchBoxCoordinateBound_nonneg s d H (B := 1) (by norm_num) + unfold bchInjectivityRadius + apply (div_le_one (by positivity)).mpr + nlinarith [Nat.cast_nonneg (α := ℝ) l] + +theorem bchInjectivityRadius_separation (s d H l : ℕ) (hl : 0 < l) : + bchBoxCoordinateBound s d H 1 * (2 * bchInjectivityRadius s d H l) < 1 / (l : ℝ) := by + have hl' : (0 : ℝ) < l := by exact_mod_cast hl + have hl1 : (0 : ℝ) < l + 1 := by positivity + have hA := bchBoxCoordinateBound_nonneg s d H (B := 1) (by norm_num) + have hA1 : 0 < bchBoxCoordinateBound s d H 1 + 1 := by linarith + have hr := bchInjectivityRadius_pos s d H l + calc + _ ≤ (bchBoxCoordinateBound s d H 1 + 1) * (2 * bchInjectivityRadius s d H l) := + mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = 1 / (2 * ((l : ℝ) + 1)) := by + unfold bchInjectivityRadius + field_simp + ring + _ < 1 / (l : ℝ) := one_div_lt_one_div_of_lt hl' (by linarith) + +namespace NilpotentLieBCHGroup + +open Module + +theorem quotient_coordinate_injOn + {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + (z : NilpotentLieBCHGroup L s hnil) : + Set.InjOn (fun v : ι → ℝ => (QuotientGroup.mk (z * (basisHomeomorph e).symm v) : _ ⧸ Γ)) + {v | ∀ i, |v i| ≤ bchInjectivityRadius s (Fintype.card ι) H l} := + quotient_coordinate_injOn_of_radius e c hstructure hc Γ l hl hgrid + (bchInjectivityRadius_pos _ _ _ _).le (bchInjectivityRadius_le_one _ _ _ _) + (bchInjectivityRadius_separation _ _ _ _ hl) z + +end NilpotentLieBCHGroup + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem exists_bch_partition_input_exp_bound (s a C₀ : ℕ) (hC₀ : 2 ≤ C₀) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (d H : ℕ) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + let B : ℝ≥0 := ⟨Real.exp ((p + C₀) ^ C₀), Real.exp_nonneg _⟩ + (B : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (bchBoxMetricConstant s d H B : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + Real.exp ((p + 2) ^ a) ≤ Real.exp ((p + C) ^ C) := by + obtain ⟨C₁, hC₁, hchart⟩ := exists_bchBoxMetricConstant_exp_bound s C₀ + let C := C₀ + C₁ + a + 4 + have hC : 2 ≤ C := by dsimp [C]; omega + refine ⟨C, hC, ?_⟩ + intro d H p hp hd hH + dsimp only + have hBp := shifted_power_self_mono (C := C₀) (D := C) hp + (by omega) (by dsimp [C]; omega) + refine ⟨Real.exp_le_exp.mpr hBp, ?_, ?_⟩ + · have hKr := hchart d H ⟨Real.exp ((p + C₀) ^ C₀), Real.exp_nonneg _⟩ (p + C₀) + (by positivity) (hd.trans (by linarith [Nat.cast_nonneg (α := ℝ) C₀])) + (hH.trans (Real.exp_le_exp.mpr (by linarith [Nat.cast_nonneg (α := ℝ) C₀]))) + (Real.exp_le_exp.mpr (pow_le_pow_left₀ (by positivity) (by linarith) C₀)) + apply hKr.trans + apply Real.exp_le_exp.mpr + have hbase : p + C₀ + C₁ ≤ p + C := by + have h : (C₀ : ℝ) + C₁ ≤ C := by + exact_mod_cast (show C₀ + C₁ ≤ C by dsimp [C]; omega) + linarith + apply (pow_le_pow_left₀ (by positivity) hbase C₁).trans + have hC' : (2 : ℝ) ≤ C := by exact_mod_cast hC + exact pow_le_pow_right₀ (by linarith) (by dsimp [C]; omega) + · apply Real.exp_le_exp.mpr + have hC' : (2 : ℝ) ≤ C := by exact_mod_cast hC + apply (pow_le_pow_left₀ (by linarith) (show p + 2 ≤ p + C by linarith) a).trans + exact pow_le_pow_right₀ (by linarith) (by dsimp [C]; omega) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem inverse_radius_product_exp_bound {A l q : ℝ} (hA : 0 ≤ A) + (hq : 0 ≤ q) (hAq : A ≤ Real.exp q) (hlq : l ≤ Real.exp q) : + 4 * (l + 1) * (A + 1) ≤ Real.exp (2 * q + 16) := by + have h1 := Real.one_le_exp hq + have h16 : (16 : ℝ) ≤ Real.exp 16 := by linarith [Real.add_one_le_exp (16 : ℝ)] + calc + _ ≤ 4 * (2 * Real.exp q) * (2 * Real.exp q) := by gcongr <;> linarith + _ = 16 * Real.exp (2 * q) := by rw [show 2 * q = q + q by ring, Real.exp_add]; ring + _ ≤ Real.exp 16 * Real.exp (2 * q) := mul_le_mul_of_nonneg_right h16 (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem enlarged_power_dominates_twice_add_sixteen {p : ℝ} (hp : 0 ≤ p) + (C : ℕ) (hC : 2 ≤ C) : + 2 * (p + C) ^ C + 16 ≤ (p + (C + 5 : ℕ)) ^ (C + 5) := by + let t : ℝ := p + (C + 5 : ℕ) + have ht : 7 ≤ t := by + have hC' : (2 : ℝ) ≤ C := by exact_mod_cast hC + dsimp [t] + push_cast + linarith + have hpow : 1 ≤ t ^ C := one_le_pow₀ (by linarith) + have hq : (p + C) ^ C ≤ t ^ C := by + apply pow_le_pow_left₀ (by positivity) + dsimp [t] + push_cast + linarith + calc + _ ≤ 18 * t ^ C := by linarith + _ ≤ t ^ 2 * t ^ C := mul_le_mul_of_nonneg_right (by nlinarith) (by positivity) + _ = t ^ (C + 2) := by rw [← pow_add, Nat.add_comm] + _ ≤ t ^ (C + 5) := pow_le_pow_right₀ (by linarith) (by omega) + +theorem exists_bchInjectivityRadius_inv_exp_bound (s : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ (d H l : ℕ) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + 1 / bchInjectivityRadius s d H l ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C, hC, hbound⟩ := exists_bchBoxMetricConstant_exp_bound s 0 + refine ⟨C + 5, by omega, ?_⟩ + intro d H l p hp hd hH hl + let A := bchBoxCoordinateBound s d H 1 + have hA : 0 ≤ A := bchBoxCoordinateBound_nonneg _ _ _ (by norm_num) + have hAq : A ≤ Real.exp ((p + C) ^ C) := by + apply le_trans (show A ≤ (bchBoxMetricConstant s d H 1 : ℝ) from ?_) + (hbound d H 1 p hp hd hH ?_) + · change A ≤ ((d : ℝ) + 1) * A + nlinarith [Nat.cast_nonneg (α := ℝ) d] + · simpa only [NNReal.coe_one, pow_zero] using Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1) + have hC' : (2 : ℝ) ≤ C := by exact_mod_cast hC + have hpq : p ≤ (p + C) ^ C := by + apply (show p ≤ p + C by linarith).trans + simpa only [pow_one] using + pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + C) (by omega : 1 ≤ C) + have hlq := hl.trans (Real.exp_le_exp.mpr hpq) + have hproduct := inverse_radius_product_exp_bound hA + (by positivity : 0 ≤ (p + C) ^ C) hAq hlq + calc + 1 / bchInjectivityRadius s d H l = 4 * ((l : ℝ) + 1) * (A + 1) := by + simp only [bchInjectivityRadius, A, one_div_one_div] + _ ≤ Real.exp (2 * (p + C) ^ C + 16) := hproduct + _ ≤ _ := Real.exp_le_exp.mpr (enlarged_power_dominates_twice_add_sixteen hp C hC) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem bchBoxCoordinateBound_le_bchBoxMetricConstant (s d H : ℕ) (B : ℝ≥0) : + bchBoxCoordinateBound s d H B ≤ (bchBoxMetricConstant s d H B : ℝ) := by + change bchBoxCoordinateBound s d H B ≤ ((d : ℝ) + 1) * bchBoxCoordinateBound s d H B + have := bchBoxCoordinateBound_nonneg s d H B.coe_nonneg + nlinarith [Nat.cast_nonneg (α := ℝ) d] + +theorem exists_bchInverseBoxConstant_exp_bound (s a : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ (d H : ℕ) (B : ℝ≥0) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (B : ℝ) ≤ Real.exp ((p + 2) ^ a) → + (bchInverseBoxConstant s d H B : ℝ) ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C₁, hC₁, hbox⟩ := exists_bchBoxMetricConstant_exp_bound s a + obtain ⟨C₂, hC₂, hone⟩ := exists_bchBoxMetricConstant_exp_bound s 0 + let C := C₁ + C₂ + a + 4 + have hC : 2 ≤ C := by dsimp [C]; omega + refine ⟨C + 5, by omega, ?_⟩ + intro d H B p hp hd hH hB + let q := (p + C) ^ C + have hq : 0 ≤ q := by dsimp [q]; positivity + have hC' : (2 : ℝ) ≤ C := by exact_mod_cast hC + have hBq : (B : ℝ) ≤ Real.exp q := by + apply hB.trans + apply Real.exp_le_exp.mpr + apply (pow_le_pow_left₀ (by linarith) (show p + 2 ≤ p + C by linarith) a).trans + exact pow_le_pow_right₀ (by linarith) (by dsimp [C]; omega) + have hAq : bchBoxCoordinateBound s d H B ≤ Real.exp q := + (bchBoxCoordinateBound_le_bchBoxMetricConstant s d H B).trans + ((hbox d H B p hp hd hH hB).trans (Real.exp_le_exp.mpr + (shifted_power_self_mono (C := C₁) (D := C) hp (by omega) (by dsimp [C]; omega)))) + have hA1q : bchBoxCoordinateBound s d H 1 ≤ Real.exp q := by + apply (bchBoxCoordinateBound_le_bchBoxMetricConstant s d H 1).trans + have hunit : ((1 : ℝ≥0) : ℝ) ≤ Real.exp ((p + 2) ^ 0) := by + simpa only [NNReal.coe_one, pow_zero] using + Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1) + apply (hone d H 1 p hp hd hH hunit).trans + exact Real.exp_le_exp.mpr + (shifted_power_self_mono (C := C₂) (D := C) hp (by omega) (by dsimp [C]; omega)) + have hnum : bchBoxCoordinateBound s d H B + 2 * (B : ℝ) ≤ 3 * Real.exp q := by linarith + have hden : bchBoxCoordinateBound s d H 1 + 1 ≤ 2 * Real.exp q := by + linarith [Real.one_le_exp hq] + have h6 : (6 : ℝ) ≤ Real.exp 16 := by linarith [Real.add_one_le_exp (16 : ℝ)] + change (bchBoxCoordinateBound s d H B + 2 * (B : ℝ)) * + (bchBoxCoordinateBound s d H 1 + 1) ≤ _ + calc + _ ≤ (3 * Real.exp q) * (2 * Real.exp q) := + mul_le_mul hnum hden (by have := bchBoxCoordinateBound_nonneg s d H (B := 1) (by norm_num); linarith) + (by positivity) + _ = 6 * Real.exp (2 * q) := by rw [show 2 * q = q + q by ring, Real.exp_add]; ring + _ ≤ Real.exp 16 * Real.exp (2 * q) := mul_le_mul_of_nonneg_right h6 (Real.exp_nonneg _) + _ = Real.exp (2 * q + 16) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (enlarged_power_dominates_twice_add_sixteen hp C hC) + +namespace NilpotentLieBCHGroup + +open Module + +theorem exists_uniform_inverse_chart_lipschitz_exp_bound (s a : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (B : ℝ≥0), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + (∀ i j k, RationalHeightLE (c i j k) H) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + 1 ≤ B → (B : ℝ) ≤ Real.exp ((p + 2) ^ a) → + letI := rightMetricSpace (hnil := hnil) e + ∃ K : ℝ≥0, (K : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + LipschitzOnWith K (basisHomeomorph (hnil := hnil) e) + {g | ∀ i, |e.repr g.coord i| ≤ B} := by + obtain ⟨D, hD, hbudget⟩ := exists_bchInverseBoxConstant_exp_bound s a + refine ⟨D, hD, ?_⟩ + intro ι L _ _ _ _ _ _ _ _ _ e c H p hnil B hstructure hc hp hd hH hB hBp + let := rightMetricSpace (hnil := hnil) e + exact ⟨bchInverseBoxConstant s (Fintype.card ι) H B, + hbudget _ _ _ _ hp hd hH hBp, lipschitzOn_basisHomeomorph_box e c hstructure hc B hB⟩ + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem bchLogMetricConstant_le_inverseBoxConstant (s d H : ℕ) : + bchLogMetricConstant s d H 1 ≤ bchInverseBoxConstant s d H 1 := by + change bchBoxCoordinateBound s d H 1 + 1 ≤ + (bchBoxCoordinateBound s d H 1 + 2 * (1 : ℝ)) * (bchBoxCoordinateBound s d H 1 + 1) + have := bchBoxCoordinateBound_nonneg s d H (B := 1) (by norm_num) + nlinarith + +theorem smooth_partition_cost_le_exp (n d : ℕ) (A K C B r : ℝ≥0) {q : ℝ} + (hq : 0 ≤ q) (hn : (n : ℝ) ≤ Real.exp q) (hd : (d : ℝ) ≤ Real.exp q) + (hA : (A : ℝ) ≤ Real.exp q) (hK : (K : ℝ) ≤ Real.exp q) + (hC : (C : ℝ) ≤ Real.exp q) (hB : (B : ℝ) ≤ Real.exp q) + (hr : 1 / (r : ℝ) ≤ Real.exp q) : + (((n + 1) * ((d * A / r) * K + 1 / (r / (4 * (C * B ^ 2))))) : ℝ≥0) ≤ + Real.exp (5 * q + 16) := by + have h1 : (d : ℝ) * A / r * K ≤ Real.exp q ^ 4 := by + calc + _ = (d : ℝ) * A * (1 / r) * K := by ring + _ ≤ Real.exp q * Real.exp q * Real.exp q * Real.exp q := by gcongr + _ = _ := by ring + have h2 : 1 / ((r : ℝ) / (4 * ((C : ℝ) * (B : ℝ) ^ 2))) ≤ 4 * Real.exp q ^ 4 := by + calc + _ = 4 * ((C : ℝ) * ((B : ℝ) * B) * (1 / r)) := by rw [one_div_div]; ring + _ ≤ 4 * (Real.exp q * (Real.exp q * Real.exp q) * Real.exp q) := by gcongr + _ = _ := by ring + have hn1 : (n : ℝ) + 1 ≤ 2 * Real.exp q := by linarith [Real.one_le_exp hq] + change ((n : ℝ) + 1) * ((d : ℝ) * A / r * K + 1 / ((r : ℝ) / (4 * ((C : ℝ) * (B : ℝ) ^ 2)))) ≤ _ + calc + _ ≤ (2 * Real.exp q) * (Real.exp q ^ 4 + 4 * Real.exp q ^ 4) := by gcongr + _ = 10 * Real.exp q ^ 5 := by ring + _ = 10 * Real.exp (5 * q) := by rw [← Real.exp_nat_mul]; norm_num + _ ≤ Real.exp 16 * Real.exp (5 * q) := by + apply mul_le_mul_of_nonneg_right ?_ (Real.exp_nonneg _) + linarith [Real.add_one_le_exp (16 : ℝ)] + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem smooth_partition_power_budget (T n d : ℕ) (hT : 2 ≤ T) + (A K C B r : ℝ≥0) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ Real.exp ((p + T) ^ T)) (hd : (d : ℝ) ≤ Real.exp ((p + T) ^ T)) + (hA : (A : ℝ) ≤ Real.exp ((p + T) ^ T)) (hK : (K : ℝ) ≤ Real.exp ((p + T) ^ T)) + (hC : (C : ℝ) ≤ Real.exp ((p + T) ^ T)) (hB : (B : ℝ) ≤ Real.exp ((p + T) ^ T)) + (hr : 1 / (r : ℝ) ≤ Real.exp ((p + T) ^ T)) : + (((n + 1) * ((d * A / r) * K + 1 / (r / (4 * (C * B ^ 2))))) : ℝ≥0) ≤ + Real.exp ((p + (T + 21 : ℕ)) ^ (T + 21)) := by + apply (smooth_partition_cost_le_exp n d A K C B r (by positivity) hn hd hA hK hC hB hr).trans + apply Real.exp_le_exp.mpr + let t : ℝ := p + (T + 21 : ℕ) + have ht : 21 ≤ t := by dsimp [t]; push_cast; linarith [Nat.cast_nonneg (α := ℝ) T] + have hpow : 1 ≤ t ^ T := one_le_pow₀ (by linarith) + have hq : (p + T) ^ T ≤ t ^ T := + pow_le_pow_left₀ (by positivity) (by dsimp [t]; push_cast; linarith) T + calc + _ ≤ 21 * t ^ T := by linarith + _ ≤ t * t ^ T := mul_le_mul_of_nonneg_right ht (by positivity) + _ = t ^ (T + 1) := (pow_succ' t T).symm + _ ≤ t ^ (T + 21) := pow_le_pow_right₀ (by linarith) (by omega) + _ = _ := rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSubgroupGridExistence.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSubgroupGridExistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c003e646a503ea169de3fbe01d502c9362e2358 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSubgroupGridExistence.lean @@ -0,0 +1,587 @@ +import Mathlib.Algebra.Group.End +import Mathlib.Algebra.Group.Submonoid.BigOperators +import Mathlib.GroupTheory.QuotientGroup.Basic +import Mathlib.LinearAlgebra.Basis.VectorSpace +import OAI.Combinatorics.Progressions.Estimates.RationalLieSubalgebra + +namespace OAI + +section + +namespace Erdos3 +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} +namespace NilpotentLieBCHGroup +variable {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def quotientHom (I : LieIdeal ℚ L) : + NilpotentLieBCHGroup L s hnil →* + NilpotentLieBCHGroup (L ⧸ I) s (lie_quotient_lowerCentralSeries_eq_bot hnil I) := + map (lieQuotientMap I) + +@[simp] theorem quotientHom_coord (I : LieIdeal ℚ L) (a : NilpotentLieBCHGroup L s hnil) : + (quotientHom I a).coord = lieQuotientMap I a.coord := rfl + +theorem quotientHom_surjective (I : LieIdeal ℚ L) : + Function.Surjective (quotientHom (hnil := hnil) I) := by + intro b + obtain ⟨a, ha⟩ := lieQuotientMap_surjective I b.coord + exact ⟨⟨a⟩, ext ha⟩ + +theorem quotientHom_ker (I : LieIdeal ℚ L) : + (quotientHom (hnil := hnil) I).ker = subgroup I.toLieSubalgebra := by + ext a + change quotientHom I a = 1 ↔ a.coord ∈ I + constructor + · intro h + apply (lieQuotientMap_eq_zero I a.coord).mp + exact congrArg coord h + · intro h + apply ext + exact (lieQuotientMap_eq_zero I a.coord).mpr h + +noncomputable def quotientEquiv (I : LieIdeal ℚ L) : + NilpotentLieBCHGroup L s hnil ⧸ (quotientHom (hnil := hnil) I).ker ≃* + NilpotentLieBCHGroup (L ⧸ I) s (lie_quotient_lowerCentralSeries_eq_bot hnil I) := + QuotientGroup.quotientKerEquivOfSurjective (quotientHom I) (quotientHom_surjective I) + +@[simp] theorem quotientEquiv_mk (I : LieIdeal ℚ L) (a : NilpotentLieBCHGroup L s hnil) : + quotientEquiv I (QuotientGroup.mk a) = quotientHom I a := rfl + +theorem subgroup_ideal_normal (I : LieIdeal ℚ L) : + (subgroup (hnil := hnil) I.toLieSubalgebra).Normal := by + rw [← quotientHom_ker] + infer_instance + +theorem commute_of_lie_eq_zero (a b : NilpotentLieBCHGroup L s hnil) + (hab : ⁅a.coord, b.coord⁆ = 0) : Commute a b := by + apply ext + change lieBCH s a.coord b.coord = lieBCH s b.coord a.coord + have hba : ⁅b.coord, a.coord⁆ = 0 := by rw [← lie_skew, hab, neg_zero] + rw [lieBCH_eq_add_of_lie_eq_zero hnil hab, lieBCH_eq_add_of_lie_eq_zero hnil hba, add_comm] + +theorem commutator_mem_ideal (I : LieIdeal ℚ L) (a b : NilpotentLieBCHGroup L s hnil) + (hab : ⁅a.coord, b.coord⁆ ∈ I) : (a * b * a⁻¹ * b⁻¹).coord ∈ I := by + have hlie : ⁅(quotientHom I a).coord, (quotientHom I b).coord⁆ = 0 := by + rw [quotientHom_coord, quotientHom_coord, ← LieHom.map_lie] + exact (lieQuotientMap_eq_zero I _).mpr hab + have hc := commute_of_lie_eq_zero (quotientHom I a) (quotientHom I b) hlie + have h : quotientHom I (a * b * a⁻¹ * b⁻¹) = 1 := by + simp only [map_mul, map_inv] + rw [hc.eq] + simp [mul_assoc] + apply (lieQuotientMap_eq_zero I _).mp + exact congrArg coord h + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + +include hnil + +theorem lieBCH_sub_add_mem (I : LieIdeal ℚ L) (a b : L) (hab : ⁅a, b⁆ ∈ I) : + lieBCH s a b - (a + b) ∈ I := by + apply (lieQuotientMap_eq_zero I _).mp + have hbracket : ⁅lieQuotientMap I a, lieQuotientMap I b⁆ = 0 := by + rw [← LieHom.map_lie] + exact (lieQuotientMap_eq_zero I _).mpr hab + rw [map_sub, map_add, map_lieBCH, + lieBCH_eq_add_of_lie_eq_zero (lie_quotient_lowerCentralSeries_eq_bot hnil I) hbracket, sub_self] + +namespace NilpotentLieBCHGroup + +theorem additive_remainder_mem (I : LieIdeal ℚ L) (r w : L) (hrw : ⁅r, w⁆ ∈ I) : + (((⟨r⟩ : NilpotentLieBCHGroup L s hnil)⁻¹ * ⟨r + w⟩ * (⟨w⟩ : NilpotentLieBCHGroup L s hnil)⁻¹).coord) ∈ I := by + have hsum : quotientHom I (⟨r + w⟩ : NilpotentLieBCHGroup L s hnil) = + quotientHom I (⟨r⟩ : NilpotentLieBCHGroup L s hnil) * quotientHom I (⟨w⟩ : NilpotentLieBCHGroup L s hnil) := by + apply ext + change lieQuotientMap I (r + w) = lieBCH s (lieQuotientMap I r) (lieQuotientMap I w) + rw [map_add] + apply (lieBCH_eq_add_of_lie_eq_zero (lie_quotient_lowerCentralSeries_eq_bot hnil I) ?_).symm + rw [← LieHom.map_lie] + exact (lieQuotientMap_eq_zero I _).mpr hrw + apply (lieQuotientMap_eq_zero I _).mp + have h : quotientHom I + ((⟨r⟩ : NilpotentLieBCHGroup L s hnil)⁻¹ * ⟨r + w⟩ * (⟨w⟩ : NilpotentLieBCHGroup L s hnil)⁻¹) = 1 := by + rw [map_mul, map_mul, map_inv, map_inv, hsum] + simp only [inv_mul_cancel_left, mul_inv_cancel] + exact congrArg coord h + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem coord_pow (g : NilpotentLieBCHGroup L s hnil) (n : ℕ) : + (g ^ n).coord = n • g.coord := by + induction n with + | zero => simp + | succ n ih => + rw [pow_succ, coord_mul, ih, + lieBCH_eq_add_of_lie_eq_zero hnil (by simp [nsmul_lie]), succ_nsmul] + +theorem coord_zpow (g : NilpotentLieBCHGroup L s hnil) (n : ℤ) : + (g ^ n).coord = n • g.coord := by + cases n with + | ofNat n => + change (g ^ (n : ℤ)).coord = (n : ℤ) • g.coord + simpa only [zpow_natCast, natCast_zsmul] using coord_pow g n + | negSucc n => + simp only [zpow_negSucc, coord_inv, coord_pow, negSucc_zsmul] + +theorem coord_pow_rat (g : NilpotentLieBCHGroup L s hnil) (n : ℕ) : + (g ^ n).coord = (n : ℚ) • g.coord := by + rw [coord_pow, Nat.cast_smul_eq_nsmul ℚ] + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 +variable (L : Type*) [LieRing L] [LieAlgebra ℚ L] + +structure NilpotentLieFiltration (s : ℕ) where + layer : ℕ → Submodule ℚ L + antitone : Antitone layer + one_eq_top : layer 1 = ⊤ + lie_mem : ∀ {i j : ℕ} {a b : L}, a ∈ layer i → b ∈ layer j → ⁅a, b⁆ ∈ layer (i + j) + terminal : layer (s + 1) = ⊥ + +namespace NilpotentLieFiltration +variable {L} {s : ℕ} (F : NilpotentLieFiltration L s) +include F + +def layerIdeal (i : ℕ) : LieIdeal ℚ L := + { F.layer i with + lie_mem := by + intro x y hy + have hx : x ∈ F.layer 1 := by simp [F.one_eq_top] + exact F.antitone (Nat.le_add_left i 1) (F.lie_mem hx hy) } + +@[simp] theorem mem_layerIdeal (i : ℕ) (a : L) : a ∈ F.layerIdeal i ↔ a ∈ F.layer i := Iff.rfl + +theorem lowerCentralSeries_le (n : ℕ) : + LieModule.lowerCentralSeries ℚ L L n ≤ F.layerIdeal (n + 1) := by + induction n with + | zero => + intro a _ + change a ∈ F.layer 1 + simp [F.one_eq_top] + | succ n ih => + rw [LieModule.lowerCentralSeries_succ, LieSubmodule.lie_le_iff] + intro a _ b hb + have ha : a ∈ F.layer 1 := by simp [F.one_eq_top] + have h := F.lie_mem ha (ih hb) + change ⁅a, b⁆ ∈ F.layer (n + 1 + 1) + simpa only [Nat.add_comm 1 (n + 1)] using h + +theorem lowerCentralSeries_eq_bot : LieModule.lowerCentralSeries ℚ L L s = ⊥ := by + apply bot_unique + intro a ha + have h := F.lowerCentralSeries_le s ha + change a ∈ F.layer (s + 1) at h + change a = 0 + simpa only [F.terminal, Submodule.mem_bot] using h + +abbrev Group := NilpotentLieBCHGroup L s F.lowerCentralSeries_eq_bot + +theorem bch_mem {i : ℕ} {a b : L} (ha : a ∈ F.layer i) (hb : b ∈ F.layer i) : + lieBCH s a b ∈ F.layer i := + lieBCH_mem (F.layerIdeal i).toLieSubalgebra s ha hb + +def subgroup (i : ℕ) : Subgroup F.Group := + NilpotentLieBCHGroup.subgroup (F.layerIdeal i).toLieSubalgebra + +@[simp] theorem mem_subgroup (i : ℕ) (a : F.Group) : a ∈ F.subgroup i ↔ a.coord ∈ F.layer i := Iff.rfl + +theorem subgroup_normal (i : ℕ) : (F.subgroup i).Normal := + NilpotentLieBCHGroup.subgroup_ideal_normal (F.layerIdeal i) + +theorem commutator_mem {i j : ℕ} {a b : F.Group} + (ha : a.coord ∈ F.layer i) (hb : b.coord ∈ F.layer j) : + (a * b * a⁻¹ * b⁻¹).coord ∈ F.layer (i + j) := + NilpotentLieBCHGroup.commutator_mem_ideal (F.layerIdeal (i + j)) a b (F.lie_mem ha hb) + +theorem subgroup_one : F.subgroup 1 = ⊤ := by + apply top_unique + intro a _ + change a.coord ∈ F.layer 1 + simp [F.one_eq_top] + +theorem subgroup_terminal : F.subgroup (s + 1) = ⊥ := by + apply bot_unique + intro a ha + rw [Subgroup.mem_bot] + apply NilpotentLieBCHGroup.ext + change a.coord = 0 + change a.coord ∈ F.layer (s + 1) at ha + simpa only [F.terminal, Submodule.mem_bot] using ha + +theorem descendingCentralSeries : + Subgroup.IsDescendingCentralSeries (fun n => F.subgroup (n + 1)) := by + refine ⟨F.subgroup_one, ?_⟩ + intro a n ha b + change (a * b * a⁻¹ * b⁻¹).coord ∈ F.layer (n + 1 + 1) + have hb : b.coord ∈ F.layer 1 := by simp [F.one_eq_top] + exact F.commutator_mem ha hb + +theorem group_lowerCentralSeries_eq_bot : (⊤ : Subgroup F.Group).lowerCentralSeries s = ⊥ := by + apply bot_unique + exact (Subgroup.descending_central_series_ge_lower _ F.descendingCentralSeries s).trans + F.subgroup_terminal.le + +theorem isNilpotentGroup : _root_.Group.IsNilpotent F.Group := + Subgroup.nilpotent_iff_lowerCentralSeries.mpr ⟨s, F.group_lowerCentralSeries_eq_bot⟩ + +theorem nilpotencyClass_le : _root_.Group.nilpotencyClass F.Group ≤ s := by + have := F.isNilpotentGroup + exact Subgroup.lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mp F.group_lowerCentralSeries_eq_bot + +end NilpotentLieFiltration +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +def bchSubgroupCoordinates (e : Basis ι ℚ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) : + Set (ι → ℚ) := {x | (⟨e.equivFun.symm x⟩ : NilpotentLieBCHGroup L s hL) ∈ Γ} + +variable [DecidableEq ι] [DecidableEq κ] + +omit [DecidableEq ι] in + +theorem bchSubgroupCoordinates_comap (b : Basis κ ℚ M) (e : Basis ι ℚ L) + (φ : M →ₗ⁅ℚ⁆ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) : + bchSubgroupCoordinates b (Γ.comap (NilpotentLieBCHGroup.map (hnil := hM) φ)) = + (LinearMap.toMatrix b e φ.toLinearMap).mulVec ⁻¹' bchSubgroupCoordinates e Γ := by + ext x + change ((⟨φ (b.equivFun.symm x)⟩ : NilpotentLieBCHGroup L s hL) ∈ Γ) ↔ + ((⟨e.equivFun.symm (LinearMap.toMatrix b e φ.toLinearMap *ᵥ x)⟩ : + NilpotentLieBCHGroup L s hL) ∈ Γ) + rw [basisMatrix_mulVec, LinearEquiv.symm_apply_apply] + rfl + +omit [DecidableEq κ] in + +theorem bchSubgroupCoordinates_map (e : Basis ι ℚ L) (b : Basis κ ℚ M) + (φ : L →ₗ⁅ℚ⁆ M) (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) : + bchSubgroupCoordinates b (Γ.map (NilpotentLieBCHGroup.map (hM := hM) φ)) = + (LinearMap.toMatrix e b φ.toLinearMap).mulVec '' bchSubgroupCoordinates e Γ := by + ext y + constructor + · intro hy + obtain ⟨g, hg, heq⟩ := Subgroup.mem_map.mp hy + refine ⟨e.equivFun g.coord, ?_, ?_⟩ + · change (⟨e.equivFun.symm (e.equivFun g.coord)⟩ : NilpotentLieBCHGroup L s hL) ∈ Γ + simpa only [LinearEquiv.symm_apply_apply] using hg + · rw [basisMatrix_mulVec, LinearEquiv.symm_apply_apply] + have h := congrArg NilpotentLieBCHGroup.coord heq + change φ g.coord = b.equivFun.symm y at h + change b.equivFun (φ g.coord) = y + rw [h, LinearEquiv.apply_symm_apply] + · rintro ⟨x, hx, hxy⟩ + apply Subgroup.mem_map.mpr + refine ⟨⟨e.equivFun.symm x⟩, hx, ?_⟩ + apply NilpotentLieBCHGroup.ext + change φ (e.equivFun.symm x) = b.equivFun.symm y + apply b.equivFun.injective + rw [LinearEquiv.apply_symm_apply] + change b.equivFun (φ.toLinearMap (e.equivFun.symm x)) = y + simpa only [basisMatrix_mulVec] using hxy + +theorem exists_bchSubgroup_comap_grid_exp_bound (b : Basis κ ℚ M) (e : Basis ι ℚ L) + (φ : M →ₗ⁅ℚ⁆ L) (hφ : Function.Injective φ) + (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) {H l : ℕ} (hHpos : 1 ≤ H) (hlpos : 0 < l) + (hB : ∀ i j, RationalHeightLE (LinearMap.toMatrix b e φ.toLinearMap i j) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) (hr : (Fintype.card κ : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hl : (l : ℝ) ≤ Real.exp p) : + ∃ N : ℕ, 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.map (hnil := hM) φ)) ∧ + bchSubgroupCoordinates b (Γ.comap (NilpotentLieBCHGroup.map (hnil := hM) φ)) ⊆ denominatorGrid N := by + rw [bchSubgroupCoordinates_comap b e φ Γ] + exact exists_preimage_grid_exp_bound (LinearMap.toMatrix b e φ.toLinearMap) + (Matrix.mulVec_injective_iff.mp (basisMatrix_injective b e φ.toLinearMap hφ)) + hHpos hlpos hB _ hinner houter hp hd hr hH hl + +theorem exists_bchSubgroup_map_grid_exp_bound (e : Basis ι ℚ L) (b : Basis κ ℚ M) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : Function.Surjective φ) + (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) {H l : ℕ} (hHpos : 1 ≤ H) (hlpos : 0 < l) + (hD : ∀ i j, RationalHeightLE (LinearMap.toMatrix e b φ.toLinearMap i j) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) (hr : (Fintype.card κ : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hl : (l : ℝ) ≤ Real.exp p) : + ∃ N : ℕ, 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b + (Γ.map (NilpotentLieBCHGroup.map (hM := hM) φ)) ∧ + bchSubgroupCoordinates b (Γ.map (NilpotentLieBCHGroup.map (hM := hM) φ)) ⊆ denominatorGrid N := by + rw [bchSubgroupCoordinates_map e b φ Γ] + exact exists_image_grid_exp_bound (LinearMap.toMatrix e b φ.toLinearMap) + (basisMatrix_surjective e b φ.toLinearMap hφ) hHpos hlpos hD _ hinner houter hp hd hr hH hl + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} +variable {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem descendingCentralSeries : Subgroup.IsDescendingCentralSeries + (fun n => subgroup (hnil := hnil) + ((LieModule.lowerCentralSeries ℚ L L n : LieIdeal ℚ L) : LieSubalgebra ℚ L)) := by + constructor + · apply top_unique + intro a _ + change a.coord ∈ LieModule.lowerCentralSeries ℚ L L 0 + simp + · intro a n ha b + change (a * b * a⁻¹ * b⁻¹).coord ∈ LieModule.lowerCentralSeries ℚ L L (n + 1) + apply commutator_mem_ideal + rw [← lie_skew a.coord b.coord] + apply (LieModule.lowerCentralSeries ℚ L L (n + 1)).neg_mem + rw [LieModule.lowerCentralSeries_succ] + exact LieSubmodule.lie_mem_lie (LieSubmodule.mem_top b.coord) ha + +theorem lowerCentralSeries_eq_bot : + (⊤ : Subgroup (NilpotentLieBCHGroup L s hnil)).lowerCentralSeries s = ⊥ := by + apply bot_unique + apply (Subgroup.descending_central_series_ge_lower _ (descendingCentralSeries (hnil := hnil)) s).trans + intro a ha + rw [Subgroup.mem_bot] + apply ext + change a.coord = 0 + change a.coord ∈ LieModule.lowerCentralSeries ℚ L L s at ha + simpa only [hnil, LieSubmodule.mem_bot] using ha + +theorem isNilpotentGroup : _root_.Group.IsNilpotent (NilpotentLieBCHGroup L s hnil) := + Subgroup.nilpotent_iff_lowerCentralSeries.mpr ⟨s, lowerCentralSeries_eq_bot⟩ + +theorem nilpotencyClass_le : _root_.Group.nilpotencyClass (NilpotentLieBCHGroup L s hnil) ≤ s := by + have := isNilpotentGroup (hnil := hnil) + exact Subgroup.lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mp lowerCentralSeries_eq_bot + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def conjugationCoord (g : NilpotentLieBCHGroup L s hnil) (x : L) : L := + (g * (⟨x⟩ : NilpotentLieBCHGroup L s hnil) * g⁻¹).coord + +theorem conjugationCoord_nsmul (g : NilpotentLieBCHGroup L s hnil) (n : ℕ) (x : L) : + conjugationCoord g (n • x) = n • conjugationCoord g x := by + have he : (⟨n • x⟩ : NilpotentLieBCHGroup L s hnil) = + (⟨x⟩ : NilpotentLieBCHGroup L s hnil) ^ n := by + apply ext + exact (coord_pow _ _).symm + change ((MulAut.conj g) (⟨n • x⟩ : NilpotentLieBCHGroup L s hnil)).coord = _ + rw [he, map_pow, coord_pow] + rfl + +theorem conjugationCoord_zsmul (g : NilpotentLieBCHGroup L s hnil) (n : ℤ) (x : L) : + conjugationCoord g (n • x) = n • conjugationCoord g x := by + have he : (⟨n • x⟩ : NilpotentLieBCHGroup L s hnil) = + (⟨x⟩ : NilpotentLieBCHGroup L s hnil) ^ n := by + apply ext + exact (coord_zpow _ _).symm + change ((MulAut.conj g) (⟨n • x⟩ : NilpotentLieBCHGroup L s hnil)).coord = _ + rw [he, map_zpow, coord_zpow] + rfl + +theorem conjugationCoord_rat_smul (g : NilpotentLieBCHGroup L s hnil) (q : ℚ) (x : L) : + conjugationCoord g (q • x) = q • conjugationCoord g x := by + have hd : (q.den : ℚ) ≠ 0 := by exact_mod_cast q.den_ne_zero + have hq : (q.den : ℚ) * q = (q.num : ℚ) := by + calc + _ = (q.den : ℚ) * ((q.num : ℚ) / q.den) := + congrArg ((q.den : ℚ) * ·) (Rat.num_div_den q).symm + _ = _ := by field_simp + apply smul_right_injective L hd + dsimp only + calc + _ = conjugationCoord g ((q.den : ℚ) • (q • x)) := by + simpa only [Nat.cast_smul_eq_nsmul] using (conjugationCoord_nsmul g q.den (q • x)).symm + _ = conjugationCoord g ((q.num : ℚ) • x) := by rw [smul_smul, hq] + _ = (q.num : ℚ) • conjugationCoord g x := by + simpa only [Int.cast_smul_eq_zsmul] using conjugationCoord_zsmul g q.num x + _ = _ := by rw [smul_smul, hq] + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem quotient_bch_eq_add {i : ℕ} (hi : 1 ≤ i) {a b : L} + (ha : a ∈ F.layer i) (hb : b ∈ F.layer i) : + lieQuotientMap (F.layerIdeal (i + 1)) (lieBCH s a b) = + lieQuotientMap (F.layerIdeal (i + 1)) (a + b) := by + rw [map_lieBCH, map_add] + apply lieBCH_eq_add_of_lie_eq_zero + (lie_quotient_lowerCentralSeries_eq_bot F.lowerCentralSeries_eq_bot (F.layerIdeal (i + 1))) + rw [← LieHom.map_lie] + exact (lieQuotientMap_eq_zero _ _).mpr (F.antitone (by omega) (F.lie_mem ha hb)) + +theorem quotient_prod_eq_sum {i : ℕ} (hi : 1 ≤ i) (xs : List L) + (hx : ∀ a ∈ xs, a ∈ F.layer i) : + NilpotentLieBCHGroup.quotientHom (F.layerIdeal (i + 1)) + (xs.map (fun a => (⟨a⟩ : F.Group))).prod = + NilpotentLieBCHGroup.quotientHom (F.layerIdeal (i + 1)) (⟨xs.sum⟩ : F.Group) := by + induction xs with + | nil => rfl + | cons a xs ih => + have ha := hx a (List.mem_cons_self ..) + have hxs : ∀ b ∈ xs, b ∈ F.layer i := fun b hb => hx b (List.mem_cons_of_mem a hb) + simp only [List.map_cons, List.prod_cons, map_mul, List.sum_cons] + rw [ih hxs] + apply NilpotentLieBCHGroup.ext + change lieBCH s (lieQuotientMap (F.layerIdeal (i + 1)) a) + (lieQuotientMap (F.layerIdeal (i + 1)) xs.sum) = + lieQuotientMap (F.layerIdeal (i + 1)) (a + xs.sum) + rw [← map_lieBCH] + exact F.quotient_bch_eq_add hi ha (list_sum_mem hxs) + +theorem exists_product_of_layerwise_sum (S : Set L) + (hS : ∀ i, 1 ≤ i → ∀ a ∈ F.layer i, + ∃ xs : List L, (∀ b ∈ xs, b ∈ S ∧ b ∈ F.layer i) ∧ xs.sum = a) + (a : L) : + ∃ xs : List L, (∀ b ∈ xs, b ∈ S) ∧ (xs.map (fun b => (⟨b⟩ : F.Group))).prod = ⟨a⟩ := by + have aux : ∀ k i : ℕ, i + k = s + 1 → 1 ≤ i → ∀ a ∈ F.layer i, + ∃ xs : List L, (∀ b ∈ xs, b ∈ S) ∧ (xs.map (fun b => (⟨b⟩ : F.Group))).prod = ⟨a⟩ := by + intro k + induction k with + | zero => + intro i hi _ a ha + have hieq : i = s + 1 := by omega + have haz : a = 0 := by simpa only [hieq, F.terminal, Submodule.mem_bot] using ha + refine ⟨[], by simp, ?_⟩ + simp only [List.map_nil, List.prod_nil, haz] + rfl + | succ k ih => + intro i hi hipos a ha + obtain ⟨ys, hys, hsum⟩ := hS i hipos a ha + let g : F.Group := (ys.map (fun b => (⟨b⟩ : F.Group))).prod + let r : F.Group := g⁻¹ * ⟨a⟩ + have hquot : NilpotentLieBCHGroup.quotientHom (F.layerIdeal (i + 1)) g = + NilpotentLieBCHGroup.quotientHom (F.layerIdeal (i + 1)) (⟨a⟩ : F.Group) := by + simpa only [g, hsum] using F.quotient_prod_eq_sum hipos ys (fun b hb => (hys b hb).2) + have hr : r.coord ∈ F.layer (i + 1) := by + have hzero : NilpotentLieBCHGroup.quotientHom (F.layerIdeal (i + 1)) r = 1 := by + simp only [r, map_mul, map_inv, hquot, inv_mul_cancel] + have hc := congrArg NilpotentLieBCHGroup.coord hzero + exact (lieQuotientMap_eq_zero _ _).mp hc + obtain ⟨zs, hzs, hprod⟩ := ih (i + 1) (by omega) (by omega) r.coord hr + refine ⟨ys ++ zs, ?_, ?_⟩ + · intro b hb + rcases List.mem_append.mp hb with hb | hb + · exact (hys b hb).1 + · exact hzs b hb + · rw [List.map_append, List.prod_append, hprod] + change g * r = ⟨a⟩ + simp only [r, mul_inv_cancel_left] + exact aux s 1 (by omega) (by omega) a (by simp [F.one_eq_top]) + +theorem exists_product_of_layerwise_range {J : Type*} (f : J → L) + (hf : ∀ i, 1 ≤ i → ∀ a ∈ F.layer i, + ∃ xs : List L, (∀ b ∈ xs, b ∈ Set.range f ∧ b ∈ F.layer i) ∧ xs.sum = a) + (a : L) : + ∃ xs : List J, (xs.map (fun j => (⟨f j⟩ : F.Group))).prod = ⟨a⟩ := by + classical + obtain ⟨ys, hys, hprod⟩ := F.exists_product_of_layerwise_sum (Set.range f) hf a + choose c hc using fun y : {y : L // y ∈ ys} => hys y.val y.property + let xs := ys.attach.map c + have hmap : xs.map f = ys := by + dsimp only [xs] + rw [List.map_map] + have hfc : f ∘ c = Subtype.val := funext hc + rw [hfc] + exact List.attach_map_subtype_val ys + refine ⟨xs, ?_⟩ + have h := congrArg (fun zs : List L => (zs.map (fun b => (⟨b⟩ : F.Group))).prod) hmap + simpa only [List.map_map, Function.comp_def] using h.trans hprod + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_bchSubgroup_comap_grid + {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + {s : ℕ} {hL : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + (b : Basis κ ℚ M) (e : Basis ι ℚ L) (φ : M →ₗ⁅ℚ⁆ L) (hφ : Function.Injective φ) + (Γ : Subgroup (NilpotentLieBCHGroup L s hL)) (l : ℕ) (hl : 0 < l) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) : + ∃ N : ℕ, 0 < N ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b (Γ.comap (NilpotentLieBCHGroup.map (hnil := hM) φ)) ∧ + bchSubgroupCoordinates b (Γ.comap (NilpotentLieBCHGroup.map (hnil := hM) φ)) ⊆ denominatorGrid N := by + classical + obtain ⟨σ, hσ⟩ := φ.toLinearMap.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hφ) + let B := LinearMap.toMatrix b e φ.toLinearMap + let C := LinearMap.toMatrix e b σ + have hCB : C * B = 1 := by + change LinearMap.toMatrix e b σ * LinearMap.toMatrix b e φ.toLinearMap = 1 + rw [← LinearMap.toMatrix_comp] + rw [hσ] + exact LinearMap.toMatrix_id b + rw [bchSubgroupCoordinates_comap b e φ Γ] + exact ⟨l * (matrixDenominator B * matrixDenominator C), + Nat.mul_pos hl (Nat.mul_pos (matrixDenominator_pos B) (matrixDenominator_pos C)), + rational_preimage_grid_transport B C hCB l _ hinner houter⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSubmoduleRemainder.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSubmoduleRemainder.lean new file mode 100644 index 0000000000000000000000000000000000000000..7951affcef7ab76264bc5579cc5d85a586fe5ef7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHSubmoduleRemainder.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Nilpotent.BCHNonlinearRemainder + +namespace OAI + +section + +namespace Erdos3 + +variable {X L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem rightBracketList_mem_submodule (K W : Submodule ℚ L) + (hbracket : ∀ x ∈ W, ∀ y ∈ K, ⁅x, y⁆ ∈ W) + (f : X → L) (hf : ∀ x, f x ∈ K) (xs : List X) (a : L) (ha : a ∈ W) : + rightBracketList f xs a ∈ W := by + induction xs generalizing a with + | nil => exact ha + | cons x xs ih => + exact ih ⁅a, f x⁆ (hbracket a ha (f x) (hf x)) + +theorem dynkinWord_mem_submodule_of_nonlinear (K W : Submodule ℚ L) (hWK : W ≤ K) + (hbracket : ∀ x ∈ K, ∀ y ∈ K, ⁅x, y⁆ ∈ W) + (f : X → L) (hf : ∀ x, f x ∈ K) (w : FreeSemigroup X) (hw : w.tail ≠ []) : + dynkinWord f w ∈ W := by + unfold dynkinWord + cases ht : w.tail with + | nil => exact False.elim (hw ht) + | cons x xs => + exact rightBracketList_mem_submodule K W + (fun a ha b hb => hbracket a (hWK ha) b hb) f hf xs ⁅f w.head, f x⁆ + (hbracket _ (hf _) _ (hf _)) + +theorem lieBCH_sub_add_mem_submodule {s : ℕ} (hs : 1 ≤ s) + (K W : Submodule ℚ L) (hWK : W ≤ K) + (hbracket : ∀ x ∈ K, ∀ y ∈ K, ⁅x, y⁆ ∈ W) + (a b : L) (ha : a ∈ K) (hb : b ∈ K) : + lieBCH s a b - (a + b) ∈ W := by + classical + rw [lieBCH_eq_add_nonlinear_sum hs, add_sub_cancel_left] + apply Submodule.sum_mem + intro w hw + apply W.smul_mem + apply dynkinWord_mem_submodule_of_nonlinear K W hWK hbracket ![a, b] + · intro i + fin_cases i + · exact ha + · exact hb + · exact (Finset.mem_filter.mp hw).2 + +theorem lieBCH_triple_sub_sum_mem_submodule {s : ℕ} (hs : 1 ≤ s) + (K W : Submodule ℚ L) (hWK : W ≤ K) + (hbracket : ∀ x ∈ K, ∀ y ∈ K, ⁅x, y⁆ ∈ W) + (a b c : L) (ha : a ∈ K) (hb : b ∈ K) (hc : c ∈ K) : + lieBCH s (lieBCH s a b) c - (a + b + c) ∈ W := by + have hab := lieBCH_sub_add_mem_submodule hs K W hWK hbracket a b ha hb + have habK : lieBCH s a b ∈ K := by + simpa only [sub_add_cancel] using K.add_mem (hWK hab) (K.add_mem ha hb) + have habc := lieBCH_sub_add_mem_submodule hs K W hWK hbracket (lieBCH s a b) c habK hc + convert W.add_mem habc hab using 1 + abel + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHUniformQuotientCharts.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHUniformQuotientCharts.lean new file mode 100644 index 0000000000000000000000000000000000000000..e78c5290dc99e80e4bb134146b0612f462388f1b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BCHUniformQuotientCharts.lean @@ -0,0 +1,1003 @@ +import OAI.Combinatorics.Progressions.Estimates.BoundedFreeWords +import OAI.Combinatorics.Progressions.Estimates.FiniteSeriesCoefficientBounds +import OAI.Combinatorics.Progressions.Estimates.FrozenCosetVariation +import OAI.Combinatorics.Progressions.Fourier.TorusCircleActions +import OAI.Combinatorics.Progressions.Geometry.QuotientCoordinateRadius + +namespace OAI + +section + +namespace Erdos3 + +def bchProductCoefficientBase (s : ℕ) : ℕ := + 2 * s + 4 + finiteSeriesDenominator s + + (s + 1) * ((s + 1) * finiteSeriesNumeratorBound s) + finiteSeriesNumeratorBound s + +def bchProductCoefficientHeight (s n : ℕ) : ℕ := + bchProductCoefficientBase s ^ ((s + 2) * (n + 2)) + +theorem bchProductCoefficientBase_pos (s : ℕ) : 0 < bchProductCoefficientBase s := by + unfold bchProductCoefficientBase + omega + +theorem bchProductDenominator_le_height (s n : ℕ) : + bchProductDenominator s n ≤ bchProductCoefficientHeight s n := by + let B := bchProductCoefficientBase s + have hB : 1 ≤ B := bchProductCoefficientBase_pos s + have hD : finiteSeriesDenominator s ≤ B := by dsimp [B, bchProductCoefficientBase]; omega + unfold bchProductDenominator bchProductCoefficientHeight + change finiteSeriesDenominator s * (finiteSeriesDenominator s ^ n) ^ s ≤ B ^ ((s + 2) * (n + 2)) + calc + _ ≤ B * (B ^ n) ^ s := Nat.mul_le_mul hD (Nat.pow_le_pow_left (Nat.pow_le_pow_left hD _) _) + _ = B ^ (1 + n * s) := by rw [← pow_mul, ← pow_succ']; congr 1; omega + _ ≤ _ := Nat.pow_le_pow_right hB (by nlinarith) + +theorem bchProductNumeratorBound_le_height (s n : ℕ) : + bchProductNumeratorBound s n ≤ bchProductCoefficientHeight s n := by + let B := bchProductCoefficientBase s + let A := (s + 1) * ((s + 1) * finiteSeriesNumeratorBound s) + have hB : 1 ≤ B := bchProductCoefficientBase_pos s + have hD : finiteSeriesDenominator s ≤ B := by dsimp [B, bchProductCoefficientBase]; omega + have hA : A ≤ B := by dsimp [A, B, bchProductCoefficientBase]; omega + have hs : s + 1 ≤ B := by dsimp [B, bchProductCoefficientBase]; omega + have hU : finiteSeriesNumeratorBound s ≤ B := by dsimp [B, bchProductCoefficientBase]; omega + have hsum : finiteSeriesDenominator s ^ n + (s + 1) * (A ^ n + finiteSeriesDenominator s ^ n) ≤ + B ^ (n + 1) := by + calc + _ ≤ B ^ n + (s + 1) * (B ^ n + B ^ n) := + Nat.add_le_add (Nat.pow_le_pow_left hD _) + (Nat.mul_le_mul_left _ (Nat.add_le_add (Nat.pow_le_pow_left hA _) (Nat.pow_le_pow_left hD _))) + _ = (2 * s + 3) * B ^ n := by ring + _ ≤ B * B ^ n := Nat.mul_le_mul_right _ (by dsimp [B, bchProductCoefficientBase]; omega) + _ = _ := (pow_succ' B n).symm + unfold bchProductNumeratorBound bchProductCoefficientHeight + change (s + 1) * finiteSeriesNumeratorBound s * + (finiteSeriesDenominator s ^ n + (s + 1) * (A ^ n + finiteSeriesDenominator s ^ n)) ^ s ≤ + B ^ ((s + 2) * (n + 2)) + calc + _ ≤ (B * B) * (B ^ (n + 1)) ^ s := + Nat.mul_le_mul (Nat.mul_le_mul hs hU) (Nat.pow_le_pow_left hsum _) + _ = B ^ (2 + (n + 1) * s) := by rw [← pow_two, ← pow_mul, ← pow_add] + _ ≤ _ := Nat.pow_le_pow_right hB (by nlinarith) + +variable {X : Type*} + +theorem bchProductWordCoefficient_height (s : ℕ) (xs : List X) (w : FreeMonoid X) + (hw : w.length ≤ s) : + RationalHeightLE (freeWordCoefficients (bchProductPolynomial s xs) w) + (bchProductCoefficientHeight s xs.length) := by + exact ((bchProductPolynomial_coefficient_bound s xs).rationalHeight + (bchProductDenominator_pos s xs.length) w hw).mono + (max_le (bchProductDenominator_le_height s xs.length) (bchProductNumeratorBound_le_height s xs.length)) + +theorem bchProductBracketCoefficient_height (s : ℕ) (xs : List X) {w : FreeSemigroup X} + (hw : w ∈ bchProductBracketSupport s xs) : + RationalHeightLE (bchProductBracketCoefficient s xs w) + (bchProductCoefficientHeight s xs.length * (s + 1)) := by + have hlen := bchProductBracketSupport_length s xs hw + have hword := bchProductWordCoefficient_height s xs w.toFreeMonoid + (by simpa only [freeSemigroup_toFreeMonoid_length] using hlen) + have hinv : RationalHeightLE ((w.length : ℚ)⁻¹) (s + 1) := by + have hpos : 0 < w.length := by change 0 < w.tail.length + 1; omega + have h := rationalHeightLE_fraction (1 : ℤ) (w.length : ℤ) + (by exact_mod_cast hpos.ne') (H := s + 1) (by simp) + (by simpa only [Int.natAbs_natCast] using hlen.trans (Nat.le_succ s)) + simpa only [Int.cast_one, Int.cast_natCast, one_div] using h + rw [bchProductBracketCoefficient, bchProductWordCoefficients_eq, ite_eq_left hlen, div_eq_mul_inv] + exact hword.mul hinv + +variable {ι : Type*} [Fintype ι] + +theorem bchProductCoordinatePolynomial_height (c : ι → ι → ι → ℚ) {H : ℕ} + (hc : ∀ i j k, RationalHeightLE (c i j k) H) (s : ℕ) (xs : List X) (k : ι) : + RationalPolynomialHeightLE (bchProductCoordinatePolynomial c s xs k) + (((bchProductBracketSupport s xs).card + 1) * + (bchProductCoefficientHeight s xs.length * (s + 1) * + lieCoordinateHeight (Fintype.card ι) H s) ^ (bchProductBracketSupport s xs).card) := by + apply RationalPolynomialHeightLE.sum_finset + intro w hw + exact RationalPolynomialHeightLE.C_mul (bchProductBracketCoefficient_height s xs hw) + ((dynkinCoordinatePolynomial_height c hc w k).mono + (lieCoordinateHeight_mono_length _ _ (bchProductBracketSupport_length s xs hw))) + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem bchProductCoefficientHeight_le_exp (s n C : ℕ) {p : ℝ} (hp : 0 ≤ p) + (hn : (n : ℝ) ≤ p) (hB : bchProductCoefficientBase s ≤ C) (hs : s + 2 ≤ C) : + (bchProductCoefficientHeight s n : ℝ) ≤ Real.exp ((p + C) ^ 3) := by + let t : ℝ := p + C + have hbase : (bchProductCoefficientBase s : ℝ) ≤ t := by + have h := (Nat.cast_le (α := ℝ)).mpr hB + dsimp [t] + linarith + have hs' : (s : ℝ) + 2 ≤ t := by + have h : (s : ℝ) + 2 ≤ C := by exact_mod_cast hs + dsimp [t] + linarith + have hn' : (n : ℝ) + 2 ≤ t := by + have hC : (2 : ℝ) ≤ C := by exact_mod_cast (show 2 ≤ C by omega) + dsimp [t] + linarith + have ht : 0 ≤ t := by dsimp [t]; positivity + have he : (bchProductCoefficientBase s : ℝ) ≤ Real.exp (bchProductCoefficientBase s) := by + have h := Real.add_one_le_exp (bchProductCoefficientBase s) + linarith + unfold bchProductCoefficientHeight + rw [Nat.cast_pow] + calc + _ ≤ (Real.exp (bchProductCoefficientBase s)) ^ ((s + 2) * (n + 2)) := + pow_le_pow_left₀ (Nat.cast_nonneg _) he _ + _ = Real.exp ((((s + 2) * (n + 2) : ℕ) : ℝ) * bchProductCoefficientBase s) := + (Real.exp_nat_mul _ _).symm + _ ≤ Real.exp (t * t * t) := by + apply Real.exp_le_exp.mpr + push_cast + exact mul_le_mul (mul_le_mul hs' hn' (by positivity) ht) hbase (by positivity) (by positivity) + _ = _ := by congr 1; dsimp [t]; ring + +theorem exists_bchProductCoordinatePolynomial_exp_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X ι : Type*} [Fintype X] [Fintype ι] + (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) (xs : List X), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (Fintype.card X : ℝ) ≤ p → + (xs.length : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + ∀ k m, (((bchProductCoordinatePolynomial c s xs k).coeff m).num.natAbs : ℝ) ≤ + Real.exp ((p + C) ^ C) ∧ + (((bchProductCoordinatePolynomial c s xs k).coeff m).den : ℝ) ≤ Real.exp ((p + C) ^ C) := by + let C := bchProductCoefficientBase s + 5 * s + 10 + have hC : 2 ≤ C := by dsimp [C]; omega + refine ⟨C, hC, ?_⟩ + intro X ι _ _ c H p xs hp hd hX hn hH hc k m + let t : ℝ := p + C + have ht : 2 ≤ t := by + have h : (2 : ℝ) ≤ C := by exact_mod_cast hC + dsimp [t] + linarith + have hshift : p + 2 ≤ t := by + have h : (2 : ℝ) ≤ C := by exact_mod_cast hC + dsimp [t] + linarith + have hs : (s : ℝ) + 1 ≤ t := by + have h : (s : ℝ) + 1 ≤ C := by exact_mod_cast (show s + 1 ≤ C by dsimp [C]; omega) + dsimp [t] + linarith + have hword : (bchProductCoefficientHeight s xs.length : ℝ) ≤ Real.exp (t ^ (3 * s + 3)) := by + apply (bchProductCoefficientHeight_le_exp s xs.length C hp hn + (by dsimp [C]; omega) (by dsimp [C]; omega)).trans + exact Real.exp_le_exp.mpr (pow_le_pow_right₀ (by linarith) (by omega)) + have hsbound : ((s + 1 : ℕ) : ℝ) ≤ Real.exp (t ^ (3 * s + 3)) := by + have h1 : t ≤ t ^ (3 * s + 3) := by + simpa only [pow_one] using pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ t) + (show 1 ≤ 3 * s + 3 by omega) + have h2 := Real.add_one_le_exp (t ^ (3 * s + 3)) + push_cast + linarith + have hlie : (lieCoordinateHeight (Fintype.card ι) H s : ℝ) ≤ Real.exp (t ^ (3 * s + 3)) := by + apply (lieCoordinateHeight_le_exp (Fintype.card ι) H s hp hd hH).trans + apply Real.exp_le_exp.mpr + exact (pow_le_pow_left₀ (by linarith) hshift _).trans + (pow_le_pow_right₀ (by linarith) (by omega)) + have hproduct : ((bchProductCoefficientHeight s xs.length * (s + 1) * + lieCoordinateHeight (Fintype.card ι) H s : ℕ) : ℝ) ≤ Real.exp (t ^ (3 * s + 5)) := by + rw [Nat.cast_mul, Nat.cast_mul] + calc + _ ≤ Real.exp (t ^ (3 * s + 3)) * Real.exp (t ^ (3 * s + 3)) * Real.exp (t ^ (3 * s + 3)) := + mul_le_mul (mul_le_mul hword hsbound (by positivity) (by positivity)) hlie + (by positivity) (by positivity) + _ = Real.exp (3 * t ^ (3 * s + 3)) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := by + apply Real.exp_le_exp.mpr + rw [show 3 * s + 5 = (3 * s + 3) + 2 by omega, pow_add t (3 * s + 3) 2] + have hsq : 3 ≤ t ^ 2 := by nlinarith + nlinarith [mul_le_mul_of_nonneg_left hsq (by positivity : 0 ≤ t ^ (3 * s + 3))] + have hcard : ((bchProductBracketSupport s xs).card : ℝ) ≤ t ^ (s + 1) := by + have h := (Nat.cast_le (α := ℝ)).mpr (bchProductBracketSupport_card_le s xs) + push_cast at h + apply h.trans + calc + ((s : ℝ) + 1) * ((Fintype.card X : ℝ) + 1) ^ s ≤ t * t ^ s := + mul_le_mul hs (pow_le_pow_left₀ (by positivity) (by linarith) _) + (by positivity) (by positivity) + _ = _ := (pow_succ' t s).symm + have hsum := rational_sum_cost_le_exp (bchProductBracketSupport s xs).card + (bchProductCoefficientHeight s xs.length * (s + 1) * lieCoordinateHeight (Fintype.card ι) H s) + (p := t - 2) (by linarith) (3 * s + 5) (s + 1) + (by simpa only [sub_add_cancel] using hproduct) (by simpa only [sub_add_cancel] using hcard) + have hfinal : (((bchProductBracketSupport s xs).card + 1) * + (bchProductCoefficientHeight s xs.length * (s + 1) * lieCoordinateHeight (Fintype.card ι) H s) ^ + (bchProductBracketSupport s xs).card : ℕ) ≤ Real.exp (t ^ C) := by + apply hsum.trans + apply Real.exp_le_exp.mpr + rw [sub_add_cancel] + exact pow_le_pow_right₀ (by linarith) (by dsimp [C]; omega) + have hheight := bchProductCoordinatePolynomial_height c hc s xs k m + exact ⟨(Nat.cast_le.mpr hheight.1).trans hfinal, (Nat.cast_le.mpr hheight.2).trans hfinal⟩ + +theorem exists_bch_product_coordinate_polynomials_exp_height (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X ι R L : Type*} [Fintype X] [Fintype ι] + [CommRing R] [Algebra ℚ R] [LieRing L] [LieAlgebra R L] [LieAlgebra ℚ L] + [IsScalarTower ℚ R L] (e : Module.Basis ι R L) (c : ι → ι → ι → ℚ) + (H : ℕ) (p : ℝ) (xs : List X), + (∀ i j k, algebraMap ℚ R (c i j k) = e.repr ⁅e i, e j⁆ k) → + LieModule.lowerCentralSeries ℚ L L s = ⊥ → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (Fintype.card X : ℝ) ≤ p → + (xs.length : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + ∃ P : ι → MvPolynomial (X × ι) ℚ, + (∀ (f : X → L) k, + MvPolynomial.aeval (fun xi : X × ι => e.repr (f xi.1) xi.2) (P k) = + e.repr (lieBCHList s f xs) k) ∧ + (∀ k, (P k).totalDegree ≤ s) ∧ + (∀ k, (P k).support.card ≤ (s + 1) * (Fintype.card X * Fintype.card ι + 1) ^ s) ∧ + ∀ k m, (((P k).coeff m).num.natAbs : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + (((P k).coeff m).den : ℝ) ≤ Real.exp ((p + C) ^ C) := by + obtain ⟨C, hC, hbudget⟩ := exists_bchProductCoordinatePolynomial_exp_budget s + refine ⟨C, hC, ?_⟩ + intro X ι R L _ _ _ _ _ _ _ _ e c H p xs hstructure hnil hp hd hX hn hH hc + refine ⟨bchProductCoordinatePolynomial c s xs, ?_, + bchProductCoordinatePolynomial_totalDegree c s xs, + bchProductCoordinatePolynomial_support_card c s xs, hbudget c H p xs hp hd hX hn hH hc⟩ + intro f k + exact bchProductCoordinatePolynomial_eval_over e c hstructure s hnil f xs k + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module MvPolynomial + +theorem exists_bch_product_box_bound (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X ι L : Type*} [Fintype X] [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (xs : List X) (f : X → L) (B : ℝ), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + LieModule.lowerCentralSeries ℚ L L s = ⊥ → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (Fintype.card X : ℝ) ≤ p → + (xs.length : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + 1 ≤ B → (∀ x i, |e.repr (f x) i| ≤ B) → + ∀ i, |e.repr (lieBCHList s f xs) i| ≤ + ((s + 1) * (Fintype.card X * Fintype.card ι + 1) ^ s : ℕ) * + Real.exp ((p + C) ^ C) * B ^ s := by + obtain ⟨C, hC, hpoly⟩ := exists_bch_product_coordinate_polynomials_exp_height s + refine ⟨C, hC, ?_⟩ + intro X ι L _ _ _ _ _ _ e c H p xs f B hstructure hnil hp hd hX hn hH hc hB hf i + obtain ⟨P, heval, hdegree, hcard, hheight⟩ := + hpoly e c H p xs hstructure hnil hp hd hX hn hH hc + rw [← heval f i] + have hbound := abs_aeval_le_box_bound (P i) + (fun xi : X × ι => e.repr (f xi.1) xi.2) + (Real.exp_nonneg _) hB + (fun m => (rational_abs_real_le_numerator _).trans (hheight i m).1) + (fun xi => hf xi.1 xi.2) (hdegree i) + apply hbound.trans + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (hcard i)) (Real.exp_nonneg _)) + (pow_nonneg (by linarith) _) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem bch_box_expression_le_exp (s a C n d : ℕ) (hC : 2 ≤ C) {p : ℝ} + (hp : 0 ≤ p) (hn : n ≤ s) (hd : (d : ℝ) ≤ p) : + (((s + 1) * (n * d + 1) ^ s : ℕ) : ℝ) * + Real.exp ((p + s + C) ^ C) * (Real.exp ((p + 2) ^ a)) ^ s ≤ + Real.exp ((p + (C + 3 * s + a + 10)) ^ (C + 3 * s + a + 10)) := by + let D := C + 3 * s + a + 10 + let t := p + D + have hD : 3 ≤ D := by dsimp [D]; omega + have hD' : (3 : ℝ) ≤ D := by exact_mod_cast hD + have ht : 3 ≤ t := by dsimp [t]; linarith + have hs : (s : ℝ) + 1 ≤ t := by + have h : s + 1 ≤ D := by dsimp [D]; omega + have h' := (Nat.cast_le (α := ℝ)).mpr h + dsimp [t] + push_cast at h' + linarith + have hp2 : p + 2 ≤ t := by dsimp [t]; linarith + have hn' : (n : ℝ) ≤ t := (Nat.cast_le.mpr hn).trans (by linarith) + have hd' : (d : ℝ) ≤ t := hd.trans (by linarith) + have hbase : ((n * d + 1 : ℕ) : ℝ) ≤ t ^ 3 := by + have hnd := mul_le_mul hn' hd' (Nat.cast_nonneg d) (by linarith : 0 ≤ t) + push_cast + nlinarith [sq_nonneg (t - 1)] + have hcount : (((s + 1) * (n * d + 1) ^ s : ℕ) : ℝ) ≤ t ^ (3 * s + 1) := by + push_cast at hbase + push_cast + calc + _ ≤ t * (t ^ 3) ^ s := + mul_le_mul hs (pow_le_pow_left₀ (by positivity) hbase s) (by positivity) (by linarith) + _ = t ^ (3 * s + 1) := by rw [← pow_mul, pow_succ'] + have hcount' : (((s + 1) * (n * d + 1) ^ s : ℕ) : ℝ) ≤ Real.exp (t ^ (D - 1)) := by + have he : 3 * s + 1 ≤ D - 1 := by dsimp [D]; omega + apply hcount.trans + apply (pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ t) he).trans + linarith [Real.add_one_le_exp (t ^ (D - 1))] + have hshift : p + s + C ≤ t := by + have h : s + C ≤ D := by dsimp [D]; omega + have h' := (Nat.cast_le (α := ℝ)).mpr h + dsimp [t] + push_cast at h' + linarith + have hcoef : Real.exp ((p + s + C) ^ C) ≤ Real.exp (t ^ (D - 1)) := by + apply Real.exp_le_exp.mpr + apply (pow_le_pow_left₀ (by positivity) hshift C).trans + exact pow_le_pow_right₀ (by linarith) (by dsimp [D]; omega) + have hinput : (Real.exp ((p + 2) ^ a)) ^ s ≤ Real.exp (t ^ (D - 1)) := by + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + calc + _ ≤ t * t ^ a := + mul_le_mul (by linarith : (s : ℝ) ≤ t) + (pow_le_pow_left₀ (by linarith) hp2 a) (by positivity) (by linarith) + _ = t ^ (a + 1) := (pow_succ' _ _).symm + _ ≤ _ := pow_le_pow_right₀ (by linarith) (by dsimp [D]; omega) + calc + _ ≤ Real.exp (t ^ (D - 1)) * Real.exp (t ^ (D - 1)) * Real.exp (t ^ (D - 1)) := + mul_le_mul (mul_le_mul hcount' hcoef (by positivity) (by positivity)) hinput + (by positivity) (by positivity) + _ = Real.exp (3 * t ^ (D - 1)) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ Real.exp (t ^ D) := by + apply Real.exp_le_exp.mpr + calc + _ ≤ t * t ^ (D - 1) := mul_le_mul_of_nonneg_right ht (by positivity) + _ = t ^ D := by rw [← pow_succ', Nat.sub_add_cancel (by omega : 1 ≤ D)] + _ = _ := by simp [t, D] + +theorem exists_bch_group_product_exp_bound (s a : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (rs : List (NilpotentLieBCHGroup L s hnil)), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → rs.length ≤ s → + (H : ℝ) ≤ Real.exp p → (∀ i j k, RationalHeightLE (c i j k) H) → + (∀ r ∈ rs, ∀ i, |e.repr r.coord i| ≤ Real.exp ((p + 2) ^ a)) → + ∀ i, |e.repr rs.prod.coord i| ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C, hC, hbox⟩ := exists_bch_product_box_bound s + refine ⟨C + 3 * s + a + 10, by omega, ?_⟩ + intro ι L _ _ _ _ _ e c H p hnil rs hstructure hp hd hn hH hc hrs i + let f : Fin rs.length → L := fun j => (rs.get j).coord + let xs := List.finRange rs.length + have hlen : (xs.length : ℝ) ≤ p + s := by + have hn' : (rs.length : ℝ) ≤ s := by exact_mod_cast hn + simpa only [xs, List.length_finRange] using hn'.trans (by linarith) + have hlabels : (Fintype.card (Fin rs.length) : ℝ) ≤ p + s := by + simpa only [Fintype.card_fin, xs, List.length_finRange] using hlen + have hbound := hbox e c H (p + s) xs f (Real.exp ((p + 2) ^ a)) hstructure hnil + (by positivity) (hd.trans (by linarith [Nat.cast_nonneg (α := ℝ) s])) hlabels hlen + (hH.trans (Real.exp_le_exp.mpr (by linarith [Nat.cast_nonneg (α := ℝ) s]))) hc + (Real.one_le_exp (by positivity)) + (fun j k => hrs (rs.get j) (List.get_mem _ _) k) i + have hmap : (xs.map (fun j => (⟨f j⟩ : NilpotentLieBCHGroup L s hnil))) = rs := by + change (List.finRange rs.length).map rs.get = rs + exact List.map_get_finRange rs + have hcoord := lieBCHList_group_prod s hnil f xs + rw [hmap] at hcoord + rw [← hcoord, Fintype.card_fin] at hbound + exact hbound.trans (by + simpa only [Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] using + bch_box_expression_le_exp s a C rs.length (Fintype.card ι) hC hp hn hd) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem bch_bounded_product_box_expression_le_exp (s a C n k d : ℕ) + (hC : 2 ≤ C) (hn : n ≤ k) {p : ℝ} (hp : 0 ≤ p) (hd : (d : ℝ) ≤ p) : + (((s + 1) * (n * d + 1) ^ s : ℕ) : ℝ) * Real.exp ((p + k + C) ^ C) * + (Real.exp ((p + 2) ^ a)) ^ s ≤ + Real.exp ((p + (C + 3 * (s + k) + a + 10)) ^ (C + 3 * (s + k) + a + 10)) := by + have hcount : (s + 1) * (n * d + 1) ^ s ≤ (s + k + 1) * (n * d + 1) ^ (s + k) := + Nat.mul_le_mul (by omega) (Nat.pow_le_pow_right (by omega) (by omega)) + have hcoef : Real.exp ((p + k + C) ^ C) ≤ Real.exp ((p + (s + k) + C) ^ C) := by + apply Real.exp_le_exp.mpr + apply pow_le_pow_left₀ (by positivity) + linarith [Nat.cast_nonneg (α := ℝ) s] + have hinput : (Real.exp ((p + 2) ^ a)) ^ s ≤ (Real.exp ((p + 2) ^ a)) ^ (s + k) := + pow_le_pow_right₀ (Real.one_le_exp (by positivity)) (by omega) + apply le_trans (mul_le_mul (mul_le_mul (Nat.cast_le.mpr hcount) hcoef + (by positivity) (by positivity)) hinput (by positivity) (by positivity)) + simpa only [Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] using + bch_box_expression_le_exp (s + k) a C n d hC hp (by omega) hd + +theorem exists_bch_fixed_product_exp_bound (s a k : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (rs : List (NilpotentLieBCHGroup L s hnil)), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → rs.length ≤ k → + (H : ℝ) ≤ Real.exp p → (∀ i j k, RationalHeightLE (c i j k) H) → + (∀ r ∈ rs, ∀ i, |e.repr r.coord i| ≤ Real.exp ((p + 2) ^ a)) → + ∀ i, |e.repr rs.prod.coord i| ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C, hC, hbox⟩ := exists_bch_product_box_bound s + refine ⟨C + 3 * (s + k) + a + 10, by omega, ?_⟩ + intro ι L _ _ _ _ _ e c H p hnil rs hstructure hp hd hn hH hc hrs i + let f : Fin rs.length → L := fun j => (rs.get j).coord + let xs := List.finRange rs.length + have hlen : (xs.length : ℝ) ≤ p + k := by + have hn' : (rs.length : ℝ) ≤ k := by exact_mod_cast hn + simpa only [xs, List.length_finRange] using hn'.trans (by linarith) + have hlabels : (Fintype.card (Fin rs.length) : ℝ) ≤ p + k := by + simpa only [Fintype.card_fin, xs, List.length_finRange] using hlen + have hbound := hbox e c H (p + k) xs f (Real.exp ((p + 2) ^ a)) hstructure hnil + (by positivity) (hd.trans (by linarith [Nat.cast_nonneg (α := ℝ) k])) hlabels hlen + (hH.trans (Real.exp_le_exp.mpr (by linarith [Nat.cast_nonneg (α := ℝ) k]))) hc + (Real.one_le_exp (by positivity)) (fun j z => hrs (rs.get j) (List.get_mem _ _) z) i + have hmap : xs.map (fun j => (⟨f j⟩ : NilpotentLieBCHGroup L s hnil)) = rs := by + change (List.finRange rs.length).map rs.get = rs + exact List.map_get_finRange rs + have hcoord := lieBCHList_group_prod s hnil f xs + rw [hmap] at hcoord + rw [← hcoord, Fintype.card_fin] at hbound + exact hbound.trans (by + simpa only [Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] using + bch_bounded_product_box_expression_le_exp s a C rs.length k (Fintype.card ι) hC hn hp hd) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem bch_triple_box_expression_le_exp (s a C d : ℕ) (hC : 2 ≤ C) {p : ℝ} + (hp : 0 ≤ p) (hd : (d : ℝ) ≤ p) : + (((s + 1) * (3 * d + 1) ^ s : ℕ) : ℝ) * Real.exp ((p + 3 + C) ^ C) * + (Real.exp ((p + 2) ^ a)) ^ s ≤ + Real.exp ((p + (C + 3 * (s + 3) + a + 10)) ^ (C + 3 * (s + 3) + a + 10)) := by + have hcount : (s + 1) * (3 * d + 1) ^ s ≤ (s + 3 + 1) * (3 * d + 1) ^ (s + 3) := + Nat.mul_le_mul (by omega) (Nat.pow_le_pow_right (by omega) (by omega)) + have hcoef : Real.exp ((p + 3 + C) ^ C) ≤ Real.exp ((p + (s + 3) + C) ^ C) := by + apply Real.exp_le_exp.mpr + apply pow_le_pow_left₀ (by positivity) + linarith [Nat.cast_nonneg (α := ℝ) s] + have hinput : (Real.exp ((p + 2) ^ a)) ^ s ≤ (Real.exp ((p + 2) ^ a)) ^ (s + 3) := + pow_le_pow_right₀ (Real.one_le_exp (by positivity)) (by omega) + apply le_trans (mul_le_mul (mul_le_mul (Nat.cast_le.mpr hcount) hcoef + (by positivity) (by positivity)) hinput (by positivity) (by positivity)) + simpa only [Nat.cast_add, Nat.cast_ofNat] using + bch_box_expression_le_exp (s + 3) a C 3 d hC hp (by omega) hd + +theorem exists_bch_triple_product_exp_bound (s a : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (u v w : NilpotentLieBCHGroup L s hnil), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + (∀ i, |e.repr u.coord i| ≤ Real.exp ((p + 2) ^ a)) → + (∀ i, |e.repr v.coord i| ≤ Real.exp ((p + 2) ^ a)) → + (∀ i, |e.repr w.coord i| ≤ Real.exp ((p + 2) ^ a)) → + ∀ i, |e.repr (u * v * w).coord i| ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C, hC, hbox⟩ := exists_bch_product_box_bound s + refine ⟨C + 3 * (s + 3) + a + 10, by omega, ?_⟩ + intro ι L _ _ _ _ _ e c H p hnil u v w hstructure hp hd hH hc hu hv hw i + let f : Fin 3 → L := ![u.coord, v.coord, w.coord] + let xs : List (Fin 3) := [0, 1, 2] + have hcoords (j : Fin 3) (k : ι) : |e.repr (f j) k| ≤ Real.exp ((p + 2) ^ a) := by + fin_cases j + · exact hu k + · exact hv k + · exact hw k + have hbound := hbox e c H (p + 3) xs f (Real.exp ((p + 2) ^ a)) hstructure hnil + (by linarith) (hd.trans (by linarith)) + (by norm_num only [Fintype.card_fin, Nat.cast_ofNat]; linarith) + (by simp only [xs, List.length_cons, List.length_nil]; norm_num; linarith) + (hH.trans (Real.exp_le_exp.mpr (by linarith))) hc + (Real.one_le_exp (by positivity)) hcoords i + have heq : lieBCHList s f xs = (u * v * w).coord := by + simpa [xs, f, mul_assoc] using + (lieBCHList_group_prod s hnil f xs).symm + rw [heq, Fintype.card_fin] at hbound + exact hbound.trans (by + simpa only [Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat] using + bch_triple_box_expression_le_exp s a C (Fintype.card ι) hC hp hd) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped NNReal + +theorem coordinateLipschitzBound_power_budget (d D : ℕ) (hD : 2 ≤ D) (B : ℝ≥0) + {p : ℝ} (hp : 0 ≤ p) (hd : (d : ℝ) ≤ p) (hB : (B : ℝ) ≤ Real.exp ((p + D) ^ D)) : + (coordinateLipschitzBound d d B : ℝ) ≤ + Real.exp ((p + ((D + 2) * 2 : ℕ)) ^ ((D + 2) * 2)) := by + have hD' : (2 : ℝ) ≤ D := by exact_mod_cast hD + have hq : 0 ≤ (p + D) ^ D := by positivity + have hpq : p ≤ (p + D) ^ D := by + calc + p ≤ p + D := by linarith + _ ≤ (p + D) ^ D := by + simpa only [pow_one] using pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + D) + (by omega : 1 ≤ D) + apply (coordinateLipschitzBound_le_exp d d B hq (hd.trans hpq) (hd.trans hpq) hB).trans + apply Real.exp_le_exp.mpr + have hshift := shifted_power_budget_le (p := p + D - 2) (by linarith) D 2 + rw [show p + D - 2 + 2 = p + D by ring] at hshift + apply hshift.trans + apply pow_le_pow_left₀ (by positivity) + have hDE : D ≤ (D + 2) * 2 := by omega + exact add_le_add le_rfl (Nat.cast_le.mpr hDE) + +theorem exists_bch_conjugation_basis_exp_bound (s r : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (a : NilpotentLieBCHGroup L s hnil), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + (∀ i, |e.repr a.coord i| ≤ Real.exp ((p + 2) ^ r)) → + ∀ i k, |e.repr (a * (⟨e i⟩ : NilpotentLieBCHGroup L s hnil) * a⁻¹).coord k| ≤ + Real.exp ((p + D) ^ D) := by + classical + obtain ⟨D, hD, hprod⟩ := exists_bch_triple_product_exp_bound s r + refine ⟨D, hD, ?_⟩ + intro ι L _ _ _ _ _ e c H p hnil a hstructure hp hd hH hc ha i k + apply hprod e c H p hnil a ⟨e i⟩ a⁻¹ hstructure hp hd hH hc ha + · intro j + change |e.repr (e i) j| ≤ _ + rw [Basis.repr_self_apply] + split_ifs + · simpa only [abs_one] using Real.one_le_exp (by positivity : 0 ≤ (p + 2) ^ r) + · simpa only [abs_zero] using Real.exp_nonneg ((p + 2) ^ r) + · intro j + change |e.repr (-a.coord) j| ≤ _ + simpa only [map_neg, Finsupp.neg_apply, abs_neg] using ha j + +namespace NilpotentLieBCHGroup + +theorem exists_uniform_left_lipschitz_exp_bound (s r : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + letI := rightMetricSpace (hnil := hnil) e + ∃ C : ℝ≥0, 0 < C ∧ (C : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + ∀ a : NilpotentLieBCHGroup L s hnil, + (∀ i, |e.repr a.coord i| ≤ Real.exp ((p + 2) ^ r)) → + LipschitzWith C (fun x => a * x) := by + obtain ⟨D, hD, hbound⟩ := exists_bch_conjugation_basis_exp_bound s r + refine ⟨(D + 2) * 2, by omega, ?_⟩ + intro ι L _ _ _ _ _ _ _ _ _ e c H p hnil hstructure hp hd hH hc + let := rightMetricSpace (hnil := hnil) e + let B : ℝ≥0 := ⟨Real.exp ((p + D) ^ D), Real.exp_nonneg _⟩ + refine ⟨coordinateLipschitzBound (Fintype.card ι) (Fintype.card ι) B, + coordinateLipschitzBound_pos _ _ _, + coordinateLipschitzBound_power_budget _ D hD B hp hd le_rfl, ?_⟩ + intro a ha + exact lipschitz_mul_left_of_basis_bound e a B (hbound e c H p hnil a hstructure hp hd hH hc ha) + +end NilpotentLieBCHGroup + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +section Quotient + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + +theorem quotientMetricSpace_lipschitz_left (a : NilpotentLieBCHGroup L s hnil) {C : ℝ≥0} + (hLip : letI := rightMetricSpace (hnil := hnil) e; LipschitzWith C (fun x => a * x)) : + letI := quotientMetricSpace e Γ hΓ + LipschitzWith C (fun x : _ ⧸ Γ => a • x) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + exact lipschitz_quotient_left_smul Γ hΓ a hLip + +theorem quotientMetricSpace_lipschitz_orbit (x : NilpotentLieBCHGroup L s hnil ⧸ Γ) : + letI := rightMetricSpace (hnil := hnil) e + letI := quotientMetricSpace e Γ hΓ + LipschitzWith 1 (fun a : NilpotentLieBCHGroup L s hnil => a • x) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + exact lipschitz_quotient_orbit Γ hΓ x + +theorem quotientMetricSpace_dist_action_le (a b : NilpotentLieBCHGroup L s hnil) {C : ℝ≥0} + (hLip : letI := rightMetricSpace (hnil := hnil) e; LipschitzWith C (fun x => a * x)) + (x y : NilpotentLieBCHGroup L s hnil ⧸ Γ) : + letI := rightMetricSpace (hnil := hnil) e + letI := quotientMetricSpace e Γ hΓ + dist (a • x) (b • y) ≤ C * dist x y + dist a b := by + let := rightMetricSpace (hnil := hnil) e + let := quotientMetricSpace e Γ hΓ + apply (dist_triangle (a • x) (a • y) (b • y)).trans + apply add_le_add ((quotientMetricSpace_lipschitz_left e Γ hΓ a hLip).dist_le_mul x y) + simpa only [NNReal.coe_one, one_mul] using (quotientMetricSpace_lipschitz_orbit e Γ hΓ y).dist_le_mul a b + +end Quotient + +theorem exists_uniform_quotient_left_lipschitz_exp_bound (s r : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℝ L] [LieAlgebra ℚ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (c i j k) H) → + ∃ C : ℝ≥0, 0 < C ∧ (C : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + ∀ (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + (a : NilpotentLieBCHGroup L s hnil), + (∀ i, |e.repr a.coord i| ≤ Real.exp ((p + 2) ^ r)) → + letI := quotientMetricSpace e Γ hΓ + LipschitzWith C (fun x : _ ⧸ Γ => a • x) := by + obtain ⟨D, hD, hbound⟩ := exists_uniform_left_lipschitz_exp_bound s r + refine ⟨D, hD, ?_⟩ + intro ι L _ _ _ _ _ _ _ _ _ e c H p hnil hstructure hp hd hH hc + obtain ⟨C, hC, hCp, hLip⟩ := hbound e c H p hnil hstructure hp hd hH hc + refine ⟨C, hC, hCp, ?_⟩ + intro Γ hΓ a ha + exact quotientMetricSpace_lipschitz_left e Γ hΓ a (hLip a ha) + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem quotient_coordinate_chart_metric_bounds + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ γ ∈ Γ, e.equivFun γ.coord ∈ realDenominatorGrid l) : + letI := rightMetricSpace (hnil := hnil) e + ∀ C : ℝ≥0, 0 < C → ∀ z : NilpotentLieBCHGroup L s hnil, + LipschitzWith C (fun x => z * x) → LipschitzWith C (fun x => z⁻¹ * x) → + ∀ r : ℝ, 0 ≤ r → r ≤ 1 → + 4 * (C : ℝ) ^ 2 * (Fintype.card ι + 1) * r ≤ bchLatticeSeparationRadius s (Fintype.card ι) H l → + letI := quotientMetricSpace e Γ hΓ + ∀ v w : ι → ℝ, (∀ i, |v i| ≤ r) → (∀ i, |w i| ≤ r) → + let q := fun u => (QuotientGroup.mk (z * (basisHomeomorph e).symm u) : _ ⧸ Γ) + dist (q v) (q w) ≤ (C : ℝ) * (bchBoxMetricConstant s (Fintype.card ι) H 1 : ℝ) * dist v w ∧ + dist v w ≤ (bchInverseBoxConstant s (Fintype.card ι) H 1 : ℝ) * C * dist (q v) (q w) := by + let := rightMetricSpace (hnil := hnil) e + intro C hC z hleft hleftInv r hr hr1 hsmall + let := quotientMetricSpace e Γ hΓ + intro v w hv hw + have hC' : (0 : ℝ) < C := hC + have hR : (C : ℝ) * (Fintype.card ι + 1) * r ≤ + bchLatticeSeparationRadius s (Fintype.card ι) H l / (4 * C) := by + apply (le_div_iff₀ (by positivity : (0 : ℝ) < 4 * C)).mpr + calc + ((C : ℝ) * (Fintype.card ι + 1) * r) * (4 * C) = + 4 * (C : ℝ) ^ 2 * (Fintype.card ι + 1) * r := by ring + _ ≤ _ := hsmall + have hball (u : ι → ℝ) (hu : ∀ i, |u i| ≤ r) : + dist (z * (basisHomeomorph e).symm u) z ≤ + bchLatticeSeparationRadius s (Fintype.card ι) H l / (4 * C) := by + have hlog : dist ((basisHomeomorph (hnil := hnil) e).symm u) 1 ≤ (Fintype.card ι + 1) * r := by + calc + _ = dist 1 ((basisHomeomorph (hnil := hnil) e).symm u) := dist_comm _ _ + _ ≤ coordinateL2Norm (basisHomeomorph e ((basisHomeomorph (hnil := hnil) e).symm u)) := + dist_one_le_coordinateL2Norm e _ + _ = coordinateL2Norm u := by rw [Homeomorph.apply_symm_apply] + _ ≤ _ := coordinateL2Norm_le_card_bound u hr hu + have htrans := hleft.dist_le_mul ((basisHomeomorph (hnil := hnil) e).symm u) 1 + rw [mul_one] at htrans + calc + _ ≤ (C : ℝ) * dist ((basisHomeomorph (hnil := hnil) e).symm u) 1 := htrans + _ ≤ (C : ℝ) * ((Fintype.card ι + 1) * r) := mul_le_mul_of_nonneg_left hlog C.coe_nonneg + _ = (C : ℝ) * (Fintype.card ι + 1) * r := by ring + _ ≤ _ := hR + have hq := quotient_dist_eq_on_ball_of_lattice_grid e c hstructure hc Γ hΓ l hl hgrid C hC z + hleftInv (hball v hv) (hball w hw) + have hv1 (i) : |v i| ≤ (1 : ℝ) := (hv i).trans hr1 + have hw1 (i) : |w i| ≤ (1 : ℝ) := (hw i).trans hr1 + have hforward := (lipschitzOn_basisHomeomorph_symm_box (hnil := hnil) e c hstructure hc 1 le_rfl).dist_le_mul v hv1 w hw1 + have hinverse := dist_coordinates_le_bchInverseBoxConstant e c hstructure hc 1 le_rfl + ((basisHomeomorph (hnil := hnil) e).symm v) ((basisHomeomorph (hnil := hnil) e).symm w) + (fun i => by + change |basisHomeomorph (hnil := hnil) e ((basisHomeomorph (hnil := hnil) e).symm v) i| ≤ _ + simpa only [Homeomorph.apply_symm_apply, NNReal.coe_one] using hv1 i) + (fun i => by + change |basisHomeomorph (hnil := hnil) e ((basisHomeomorph (hnil := hnil) e).symm w) i| ≤ _ + simpa only [Homeomorph.apply_symm_apply, NNReal.coe_one] using hw1 i) + rw [Homeomorph.apply_symm_apply, Homeomorph.apply_symm_apply] at hinverse + dsimp only + rw [hq] + constructor + · apply (hleft.dist_le_mul _ _).trans + exact (mul_le_mul_of_nonneg_left hforward C.coe_nonneg).trans_eq (by ring) + · have hback : dist ((basisHomeomorph (hnil := hnil) e).symm v) ((basisHomeomorph (hnil := hnil) e).symm w) ≤ + (C : ℝ) * dist (z * (basisHomeomorph e).symm v) (z * (basisHomeomorph e).symm w) := by + have hb := hleftInv.dist_le_mul + (z * (basisHomeomorph e).symm v) (z * (basisHomeomorph e).symm w) + rw [inv_mul_cancel_left, inv_mul_cancel_left] at hb + exact hb + exact hinverse.trans ((mul_le_mul_of_nonneg_left hback (bchInverseBoxConstant _ _ _ _).coe_nonneg).trans_eq (by ring)) + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) + +omit [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] in +theorem centralBCHFlow_period (v : L) (hv : ∀ w : L, ⁅v, w⁆ = 0) + (hperiod : (⟨v⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ) (x : NilpotentLieBCHGroup L s hnil ⧸ Γ) : + realBCHLine (hnil := hnil) v 1 • x = x := by + apply central_smul_eq_self_of_mem Γ + · simpa only [realBCHLine_one] using hperiod + · exact realBCHLine_commute v hv 1 + +theorem centralBCHFlow_isometry (v : L) (hv : ∀ w : L, ⁅v, w⁆ = 0) (r : ℝ) : + letI := quotientMetricSpace e Γ hΓ + Isometry (fun x : NilpotentLieBCHGroup L s hnil ⧸ Γ => realBCHLine (hnil := hnil) v r • x) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := rightMetricSpace (hnil := hnil) e + let := rightMetricSpace_isIsometricSMul (hnil := hnil) e + exact isometry_quotient_central_smul Γ hΓ (realBCHLine (hnil := hnil) v r) (realBCHLine_commute v hv r) + +theorem centralBCHFlow_displacement (v : L) (r : ℝ) (x : NilpotentLieBCHGroup L s hnil ⧸ Γ) : + letI := quotientMetricSpace e Γ hΓ + dist (realBCHLine (hnil := hnil) v r • x) x ≤ coordinateL2Norm (e.equivFun v) * |r| := by + let := rightMetricSpace (hnil := hnil) e + let := quotientMetricSpace e Γ hΓ + have h := (quotientMetricSpace_lipschitz_orbit e Γ hΓ x).dist_le_mul (realBCHLine (hnil := hnil) v r) 1 + have hbound := realBCHLine_dist_one_le (hnil := hnil) e v r + simp only [one_smul, NNReal.coe_one, one_mul] at h + exact h.trans (hbound.trans_eq (mul_comm _ _)) + +noncomputable def centralBCHCircleAction (v : L) (hv : ∀ w : L, ⁅v, w⁆ = 0) + (hperiod : (⟨v⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ) : + letI := quotientMetricSpace e Γ hΓ + CircleFourier.IsometricCircleAction (NilpotentLieBCHGroup L s hnil ⧸ Γ) := by + let := quotientMetricSpace e Γ hΓ + exact CircleFourier.isometricCircleActionOfFlow (fun r x => realBCHLine (hnil := hnil) v r • x) + (fun x => by rw [realBCHLine_zero, one_smul]) + (fun r t x => by rw [realBCHLine_add, mul_smul]) + (centralBCHFlow_period Γ v hv hperiod) + (centralBCHFlow_isometry e Γ hΓ v hv) + ⟨coordinateL2Norm (e.equivFun v), coordinateL2Norm_nonneg _⟩ + (centralBCHFlow_displacement e Γ hΓ v) + +theorem centralBCHCircleAction_act_coe (v : L) (hv : ∀ w : L, ⁅v, w⁆ = 0) + (hperiod : (⟨v⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ) + (r : ℝ) (x : NilpotentLieBCHGroup L s hnil ⧸ Γ) : + letI := quotientMetricSpace e Γ hΓ + (centralBCHCircleAction e Γ hΓ v hv hperiod).act (r : CircleFourier.Circle) x = + realBCHLine (hnil := hnil) v r • x := by + let := quotientMetricSpace e Γ hΓ + dsimp only [centralBCHCircleAction, CircleFourier.isometricCircleActionOfFlow] + exact CircleFourier.periodicFlowAct_coe _ _ r x + +theorem centralBCHCircleAction_displacement (v : L) (hv : ∀ w : L, ⁅v, w⁆ = 0) + (hperiod : (⟨v⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ) + (t : CircleFourier.Circle) (x : NilpotentLieBCHGroup L s hnil ⧸ Γ) : + letI := quotientMetricSpace e Γ hΓ + dist ((centralBCHCircleAction e Γ hΓ v hv hperiod).act t x) x ≤ + coordinateL2Norm (e.equivFun v) * ‖t‖ := by + let := quotientMetricSpace e Γ hΓ + dsimp only [centralBCHCircleAction, CircleFourier.isometricCircleActionOfFlow] + exact CircleFourier.periodicFlowAct_displacement _ _ + ⟨coordinateL2Norm (e.equivFun v), coordinateL2Norm_nonneg _⟩ + (centralBCHFlow_displacement e Γ hΓ v) t x + +theorem centralBCHCircleAction_commutes (v w : L) + (hv : ∀ z : L, ⁅v, z⁆ = 0) (hw : ∀ z : L, ⁅w, z⁆ = 0) + (hvΓ : (⟨v⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ) + (hwΓ : (⟨w⟩ : NilpotentLieBCHGroup L s hnil) ∈ Γ) : + letI := quotientMetricSpace e Γ hΓ + (centralBCHCircleAction e Γ hΓ v hv hvΓ).Commutes (centralBCHCircleAction e Γ hΓ w hw hwΓ) := by + let := quotientMetricSpace e Γ hΓ + intro t u x + obtain ⟨r, rfl⟩ := QuotientAddGroup.mk_surjective t + obtain ⟨q, rfl⟩ := QuotientAddGroup.mk_surjective u + simp only [centralBCHCircleAction_act_coe] + rw [← mul_smul, ← mul_smul, (realBCHLine_commute v hv r (realBCHLine (hnil := hnil) w q)).eq] + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +theorem exists_uniform_quotient_isometric_radius_exp_bound (s a : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) (l : ℕ), + 0 < l → (∀ γ ∈ Γ, e.equivFun γ.coord ∈ realDenominatorGrid l) → + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + (∀ i j k, RationalHeightLE (c i j k) H) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + letI := rightMetricSpace (hnil := hnil) e + letI := quotientMetricSpace e Γ hΓ + ∃ R : ℝ, 0 < R ∧ 1 / R ≤ Real.exp ((p + D) ^ D) ∧ + ∀ z : NilpotentLieBCHGroup L s hnil, + (∀ i, |e.repr z.coord i| ≤ Real.exp ((p + 2) ^ a)) → + ∀ x y : NilpotentLieBCHGroup L s hnil, dist x z ≤ R → dist y z ≤ R → + dist (QuotientGroup.mk x : _ ⧸ Γ) (QuotientGroup.mk y) = dist x y := by + obtain ⟨A, hA, hgap⟩ := exists_bchLatticeSeparationRadius_inv_exp_bound s + obtain ⟨B, hB, hleft⟩ := exists_uniform_left_lipschitz_exp_bound s a + refine ⟨A + B + 5, by omega, ?_⟩ + intro ι L _ _ _ _ _ _ _ _ _ e c H p hnil Γ hΓ l hl hgrid hstructure hc hp hd hH hlp + let := rightMetricSpace (hnil := hnil) e + let := quotientMetricSpace e Γ hΓ + obtain ⟨C, hC, hCp, hleft⟩ := hleft e c H p hnil hstructure hp hd hH hc + let δ := bchLatticeSeparationRadius s (Fintype.card ι) H l + have hδ : 0 < δ := bchLatticeSeparationRadius_pos _ _ _ _ + have hC' : (0 : ℝ) < C := hC + refine ⟨δ / (4 * C), by positivity, + quotient_radius_inverse_power_budget A B hA hB hδ hC' hp (hgap _ _ _ _ hp hd hH hlp) hCp, ?_⟩ + intro z hz x y hx hy + have hzinv : ∀ i, |e.repr z⁻¹.coord i| ≤ Real.exp ((p + 2) ^ a) := by + intro i + simpa only [coord_inv, map_neg, Finsupp.neg_apply, abs_neg] using hz i + exact quotient_dist_eq_on_ball_of_lattice_grid e c hstructure hc Γ hΓ l hl hgrid C hC z + (hleft z⁻¹ hzinv) hx hy + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +theorem exists_uniform_quotient_chart_metric_exp_bound (s a : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (hΓ : IsClosed (Γ : Set (NilpotentLieBCHGroup L s hnil))) (l : ℕ), + 0 < l → (∀ γ ∈ Γ, e.equivFun γ.coord ∈ realDenominatorGrid l) → + (∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) → + (∀ i j k, RationalHeightLE (c i j k) H) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + letI := quotientMetricSpace e Γ hΓ + ∃ r : ℝ, 0 < r ∧ r ≤ 1 ∧ 1 / r ≤ Real.exp ((p + D) ^ D) ∧ + ∃ K : ℝ≥0, (K : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + ∀ z : NilpotentLieBCHGroup L s hnil, + (∀ i, |e.repr z.coord i| ≤ Real.exp ((p + 2) ^ a)) → + ∀ v w : ι → ℝ, (∀ i, |v i| ≤ r) → (∀ i, |w i| ≤ r) → + let q := fun u => (QuotientGroup.mk (z * (basisHomeomorph e).symm u) : _ ⧸ Γ) + dist (q v) (q w) ≤ K * dist v w ∧ dist v w ≤ K * dist (q v) (q w) := by + obtain ⟨A, hA, hgap⟩ := exists_bchLatticeSeparationRadius_inv_exp_bound s + obtain ⟨B, hB, hleft⟩ := exists_uniform_left_lipschitz_exp_bound s a + obtain ⟨E, hE, hforward⟩ := exists_bchBoxMetricConstant_exp_bound s 0 + obtain ⟨F, hF, hinverse⟩ := exists_bchInverseBoxConstant_exp_bound s 0 + refine ⟨A + B + E + F + 10, by omega, ?_⟩ + intro ι L _ _ _ _ _ _ _ _ _ e c H p hnil Γ hΓ l hl hgrid hstructure hc hp hd hH hlp + let := rightMetricSpace (hnil := hnil) e + let := quotientMetricSpace e Γ hΓ + obtain ⟨C, hC, hCp, hleft⟩ := hleft e c H p hnil hstructure hp hd hH hc + let δ := bchLatticeSeparationRadius s (Fintype.card ι) H l + have hδ : 0 < δ := bchLatticeSeparationRadius_pos _ _ _ _ + let r := quotientCoordinateRadius δ (C : ℝ) (Fintype.card ι) + let U := bchBoxMetricConstant s (Fintype.card ι) H 1 + let V := bchInverseBoxConstant s (Fintype.card ι) H 1 + have hunit : ((1 : ℝ≥0) : ℝ) ≤ Real.exp ((p + 2) ^ 0) := by + simpa only [NNReal.coe_one, pow_zero] using Real.one_le_exp (by norm_num : (0 : ℝ) ≤ 1) + obtain ⟨hrp, hCU, hVC⟩ := quotient_chart_parameter_budget A B E F hA hB hE hF + hδ C.coe_nonneg U.coe_nonneg hp (Fintype.card ι) hd + (hgap _ _ _ _ hp hd hH hlp) hCp + (hforward _ _ 1 _ hp hd hH hunit) (hinverse _ _ 1 _ hp hd hH hunit) + let K : ℝ≥0 := max (C * U) (V * C) + have hK : (K : ℝ) ≤ Real.exp ((p + (A + B + E + F + 10 : ℕ)) ^ (A + B + E + F + 10)) := by + simpa only [K, NNReal.coe_max, NNReal.coe_mul] using max_le hCU hVC + have hKU : (C : ℝ) * U ≤ (K : ℝ) := by exact_mod_cast (le_max_left (C * U) (V * C)) + have hKV : (V : ℝ) * C ≤ (K : ℝ) := by exact_mod_cast (le_max_right (C * U) (V * C)) + refine ⟨r, quotientCoordinateRadius_pos hδ _, quotientCoordinateRadius_le_one hδ _, hrp, K, hK, ?_⟩ + intro z hz v w hv hw + have hzinv (i) : |e.repr z⁻¹.coord i| ≤ Real.exp ((p + 2) ^ a) := by + simpa only [coord_inv, map_neg, Finsupp.neg_apply, abs_neg] using hz i + obtain ⟨hvw, hwv⟩ := quotient_coordinate_chart_metric_bounds e c hstructure hc Γ hΓ l hl hgrid + C hC z (hleft z hz) (hleft z⁻¹ hzinv) r (quotientCoordinateRadius_pos hδ _).le + (quotientCoordinateRadius_le_one hδ _) (quotientCoordinateRadius_small hδ _) v w hv hw + exact ⟨hvw.trans (mul_le_mul_of_nonneg_right hKU dist_nonneg), + hwv.trans (mul_le_mul_of_nonneg_right hKV dist_nonneg)⟩ + +end Erdos3.NilpotentLieBCHGroup + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BlockLayerBracket.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BlockLayerBracket.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf962cb2d613252df9cc71d325674a3983acfa90 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BlockLayerBracket.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.Progressions.Estimates.SquarefreePermutationFiltration + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + +theorem blockMonomial_lie_coefficient [DecidableEq ι] [DecidableEq σ] (π : ι → σ) (a b : σ → ℕ) + (x y : L) (c : SquarefreeIndex ι) : + squarefreePolynomialEquiv ⁅blockMonomial π a x, blockMonomial π b y⁆ c = + Fintype.card (SquarefreeSplit π c a b) • ⁅x, y⁆ := by + classical + rw [squarefree_lie_coefficient] + simp only [blockMonomial_coefficient] + have hterm (u v : SquarefreeIndex ι) : + (if u.val + v.val = c.val then + ⁅if blockDegree π u.val = a then x else 0, + if blockDegree π v.val = b then y else 0⁆ else 0) = + if u.val + v.val = c.val ∧ blockDegree π u.val = a ∧ blockDegree π v.val = b + then ⁅x, y⁆ else 0 := by + by_cases hs : u.val + v.val = c.val <;> + by_cases hu : blockDegree π u.val = a <;> + by_cases hv : blockDegree π v.val = b <;> simp [hs, hu, hv] + simp_rw [hterm] + rw [← Fintype.sum_prod_type'] + rw [Fintype.card_subtype, ← Finset.sum_filter, Finset.sum_const] + +theorem blockMonomial_lie (π : ι → σ) (a b : σ → ℕ) (x y : L) : + ⁅blockMonomial π a x, blockMonomial π b y⁆ = + blockSplitMultiplicity a b • blockMonomial π (a + b) ⁅x, y⁆ := by + classical + apply squarefreePolynomialEquiv.injective + ext c + rw [blockMonomial_lie_coefficient, map_nsmul, Pi.smul_apply, blockMonomial_coefficient] + by_cases hc : blockDegree π c.val = a + b + · rw [ite_eq_left hc, card_squarefreeSplit π c a b hc] + · have hz : Fintype.card (SquarefreeSplit π c a b) = 0 := + Fintype.card_eq_zero_iff.mpr ⟨fun p => hc (squarefreeSplit_degree π c a b p)⟩ + rw [hz, zero_smul, ite_eq_right hc, smul_zero] + +theorem factorialBlockMonomial_lie (π : ι → σ) (a b : σ → ℕ) (x y : L) : + ⁅factorialBlockMonomial π a x, factorialBlockMonomial π b y⁆ = + factorialBlockMonomial π (a + b) ⁅x, y⁆ := by + simp only [factorialBlockMonomial, LinearMap.smul_apply, smul_lie, lie_smul, blockMonomial_lie] + rw [← Nat.cast_smul_eq_nsmul ℚ, smul_smul, smul_smul] + have h := congrArg (fun n : ℕ => (n : ℚ)) (multidegreeFactorial_split a b) + simp only [Nat.cast_mul] at h + rw [mul_comm (multidegreeFactorial b : ℚ) (multidegreeFactorial a : ℚ), h] + +end Erdos3 + +end + +section + +namespace Erdos3.MultidegreeLieFiltration + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) (π : ι → σ) + +theorem blockLayerMap_lie (a b : σ → ℕ) (ha : a ≠ 0) (hb : b ≠ 0) (hab : a + b ≠ 0) + (x : F.layer a) (y : F.layer b) : + ⁅F.blockLayerMap π a ha x, F.blockLayerMap π b hb y⁆ = + F.blockLayerMap π (a + b) hab ⟨⁅x.val, y.val⁆, F.lie_mem x.property y.property⟩ := by + apply Subtype.ext + exact factorialBlockMonomial_lie π a b x.val y.val + +end Erdos3.MultidegreeLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BoxNiltestDetection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BoxNiltestDetection.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7b986d741b2d70b67c1cce0688bf97c7b2b6fc7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BoxNiltestDetection.lean @@ -0,0 +1,101 @@ +import OAI.Combinatorics.Progressions.Nilpotent.NiltestBasepointNormalization + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct BigOperators + +variable {σ L Ω : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L 0 d) {w : σ → ℕ} + +theorem norm_correlation_step_zero_sample (T : D.Niltest w) + (Q : Finset Ω) (x : Ω → (σ → ℤ)) (f : Ω → ℂ) : + ‖finiteCorrelation Q f (fun a => T.eval (x a))‖ ≤ + (T.normBound : ℝ) * ‖𝔼 a ∈ Q, f a‖ := by + calc + _ = ‖𝔼 a ∈ Q, f a‖ * ‖T.observable (QuotientGroup.mk (1 : D.RealGroup))‖ := by + simp only [finiteCorrelation, eval_step_zero D, ← Finset.expect_mul, norm_mul, norm_star] + _ ≤ _ := by + rw [mul_comm (T.normBound : ℝ)] + exact mul_le_mul_of_nonneg_left (T.norm_le _) (norm_nonneg _) + +theorem detection_step_zero_sample (T : D.Niltest w) {p ρ : ℝ} + (hT : T.ComplexityLE p) (Q : Finset Ω) (x : Ω → (σ → ℤ)) (f : Ω → ℂ) + (hcorr : ρ ≤ ‖finiteCorrelation Q f (fun a => T.eval (x a))‖) : + ρ / Real.exp p ≤ ‖𝔼 a ∈ Q, f a‖ := by + apply (div_le_iff₀ (Real.exp_pos p)).mpr + have hB : (T.normBound : ℝ) ≤ Real.exp p := by + have hh := T.observable_budget hT + linarith [T.lipBound.coe_nonneg] + have hc := hcorr.trans (norm_correlation_step_zero_sample D T Q x f) + exact hc.trans (by nlinarith [norm_nonneg (𝔼 a ∈ Q, f a)]) + +theorem detection_step_zero_box [Fintype σ] [DecidableEq σ] + (T : D.Niltest w) {p ρ : ℝ} (hT : T.ComplexityLE p) + (lengths : σ → ℕ) [∀ i, NeZero (lengths i)] (f : (σ → ℤ) → ℂ) + (hcorr : ρ ≤ ‖finiteCorrelation (integerBox lengths) f T.eval‖) : + ρ / Real.exp p ≤ integerBoxGowersNorm lengths 1 f := by + rw [integerBoxGowersNorm_degree_one] + exact detection_step_zero_sample D T hT (integerBox lengths) id f hcorr + +theorem detection_step_zero_cyclic [Fintype σ] [DecidableEq σ] (T : D.Niltest w) + {p ρ : ℝ} (hT : T.ComplexityLE p) (N : ℕ) [NeZero N] + (f : (σ → ZMod N) → ℂ) + (hcorr : ρ ≤ ‖finiteCorrelation Finset.univ f (T.evalCyclic N)‖) : + ρ / Real.exp p ≤ gowersNorm 1 f := by + rw [gowersNorm_one] + let points : (σ → ZMod N) → (σ → ℤ) := fun x i => ((x i).val : ℤ) + have hc : ρ ≤ ‖finiteCorrelation Finset.univ f (fun x => T.eval (points x))‖ := hcorr + exact detection_step_zero_sample D T hT Finset.univ points f hc + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +def BoxNiltestDetection.{u,v} (s : ℕ) (F : ℝ → ℝ) : Prop := + ∀ {σ : Type v} [Fintype σ] [DecidableEq σ] {L : Type u} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (p : ℝ), + 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → ∀ (w : σ → ℕ), (∀ i, 0 < w i) → + ∀ (T : D.Niltest w), T.ComplexityLE p → + ∀ (a : σ → ℤ) (lengths : σ → ℕ) [∀ i, NeZero (lengths i)] (f : (σ → ℤ) → ℂ), + (∀ x ∈ translatedIntegerBox a lengths, ‖f x‖ ≤ 1) → + Real.exp (-p) ≤ ‖finiteCorrelation (translatedIntegerBox a lengths) f T.eval‖ → + Real.exp (-F p) ≤ finiteSupportGowersNorm (s + 1) (translatedIntegerBox a lengths) f + +theorem BoxNiltestDetection.mono.{u,v} {s : ℕ} {F G : ℝ → ℝ} + (hF : BoxNiltestDetection.{u,v} s F) (hFG : ∀ p, 0 ≤ p → F p ≤ G p) : + BoxNiltestDetection.{u,v} s G := by + intro σ _ _ L _ _ d _ _ _ _ D p hp hσ w hw T hT a lengths _ f hf hc + exact (Real.exp_le_exp.mpr (neg_le_neg (hFG p hp))).trans + (hF D p hp hσ w hw T hT a lengths f hf hc) + +theorem boxNiltestDetection_zero.{u,v} : BoxNiltestDetection.{u,v} 0 (fun p => 2 * p) := by + intro σ _ _ L _ _ d _ _ _ _ D p hp hσ w hw T hT a lengths _ f hf hc + have hb := RationalFilteredNilmanifold.Niltest.detection_step_zero_sample + D T hT (translatedIntegerBox a lengths) id f hc + have he : Real.exp (-p) / Real.exp p = Real.exp (-(2 * p)) := by + rw [← Real.exp_sub] + congr 1 + ring + rw [he] at hb + rw [translatedIntegerBox_norm_degree_one] + exact hb + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BracketArrayEquation.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BracketArrayEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..24563a9d26ad1e5e4cd17e14eba7357ebb759056 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BracketArrayEquation.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialLiftArrays + +namespace OAI + +section + +namespace Erdos3 + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ κ ι L : Type*} [Fintype κ] [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {V : Submodule ℚ L} + +theorem liftQuotientArray_neg (f : Basis ι ℚ (L ⧸ V)) + (S : κ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) : + liftQuotientArray f (fun t => -S t) = -liftQuotientArray f S := by + apply coefficients.injective + apply Finsupp.ext + intro α + funext bi + simp only [coefficients_liftQuotientArray, map_neg, Finsupp.neg_apply, Pi.neg_apply] + +theorem liftQuotientArray_norm_bound (f : Basis ι ℚ (L ⧸ V)) + (S : κ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (α : σ →₀ ℕ) + {M : ℝ} (hM : 0 ≤ M) + (hS : ∀ t, ‖realQuotientCoordinateMap f (coefficients (S t) α)‖ ≤ M) : + ‖coefficients (liftQuotientArray f S) α‖ ≤ M := by + apply (pi_norm_le_iff_of_nonneg hM).mpr + intro bi + rw [coefficients_liftQuotientArray] + exact (norm_le_pi_norm (realQuotientCoordinateMap f (coefficients (S bi.1) α)) bi.2).trans (hS bi.1) + +theorem liftQuotientArray_grid (f : Basis ι ℚ (L ⧸ V)) + (S : κ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (α : σ →₀ ℕ) (l : ℕ) + (hS : ∀ t, realQuotientCoordinateMap f (coefficients (S t) α) ∈ realDenominatorGrid l) : + coefficients (liftQuotientArray f S) α ∈ realDenominatorGrid l := by + classical + have hex : ∀ t, ∃ z : ι → ℤ, + (fun i => (z i : ℝ)) = (l : ℝ) • realQuotientCoordinateMap f (coefficients (S t) α) := hS + choose z hz using hex + refine ⟨fun bi => z bi.1 bi.2, ?_⟩ + funext bi + change (z bi.1 bi.2 : ℝ) = (l : ℝ) * coefficients (liftQuotientArray f S) α bi + rw [coefficients_liftQuotientArray] + exact congrFun (hz bi.1) bi.2 + +theorem bracket_array_equation_of_current_relation + (f : Basis ι ℚ (L ⧸ V)) (k : κ → L) (π : (ℝ ⊗[ℚ] L) →ₗ[ℝ] (ℝ ⊗[ℚ] L)) + (P : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (S R : κ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (hcurrent : ∀ t α, ⁅coefficients P α, (1 : ℝ) ⊗ₜ[ℚ] k t⁆ - + (π (coefficients (S t) α) - π (coefficients (R t) α)) ∈ V.baseChange ℝ) : + ∀ α, realBracketSystem f k (coefficients P α) = + coefficients (liftQuotientArray f (fun t => map (π.restrictScalars ℚ) + (S t - monomial 0 ((1 : ℝ) ⊗ₜ[ℚ] k t)))) α + + coefficients (liftQuotientArray f (fun t => map (π.restrictScalars ℚ) + (-(R t - monomial 0 ((1 : ℝ) ⊗ₜ[ℚ] k t))))) α := by + intro α + funext bi + have hi := congrFun ((realQuotientCoordinateMap_eq_zero_iff f _).mpr (hcurrent bi.1 α)) bi.2 + simp only [map_sub, Pi.sub_apply, Pi.zero_apply] at hi + change realQuotientCoordinateMap f ⁅coefficients P α, (1 : ℝ) ⊗ₜ[ℚ] k bi.1⁆ bi.2 = _ + simp only [Pi.add_apply, coefficients_liftQuotientArray, coefficients_map, + LinearMap.restrictScalars_apply, map_neg, map_sub, Finsupp.sub_apply, + Finsupp.neg_apply, Pi.sub_apply, Pi.neg_apply] + linear_combination hi + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/BracketStepBudget.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/BracketStepBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..6689f7cea735437a1a3e3f63fea5a7b7cdc13100 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/BracketStepBudget.lean @@ -0,0 +1,82 @@ +import OAI.Combinatorics.Progressions.Dynamics.CurrentLayerBudget + +namespace OAI + +section + +namespace Erdos3 + +def bracketConstructionBudget (p : ℝ) : ℝ := (p + 2) ^ 3 + 3 * p + 2 + +def bracketCorrectionBudget (p : ℝ) : ℝ := + (bracketConstructionBudget p + 2) ^ 36 + (bracketConstructionBudget p + 2) ^ 18 + + bracketConstructionBudget p + (p + 2) ^ 3 + 2 * p + 1 + +theorem bracketConstructionBudget_nonneg {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ bracketConstructionBudget p := by unfold bracketConstructionBudget; positivity + +theorem bracketCorrectionBudget_nonneg {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ bracketCorrectionBudget p := by + have hq := bracketConstructionBudget_nonneg hp + unfold bracketCorrectionBudget + positivity + +theorem bracket_construction_budget_bounds {p : ℝ} (hp : 0 ≤ p) : + p ≤ bracketConstructionBudget p ∧ (p + 2) ^ 2 ≤ bracketConstructionBudget p ∧ + (p + 2) ^ 3 + p ≤ bracketConstructionBudget p ∧ + 3 * p + 1 ≤ bracketConstructionBudget p := by + have hc : 0 ≤ (p + 2) ^ 3 := by positivity + have hpow : (p + 2) ^ 2 ≤ (p + 2) ^ 3 := + pow_le_pow_right₀ (by linarith : (1 : ℝ) ≤ p + 2) (by decide : 2 ≤ 3) + unfold bracketConstructionBudget + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +theorem bracket_correction_budget_bounds {p : ℝ} (hp : 0 ≤ p) + (n J D : ℕ) (hn : (n : ℝ) ≤ p) (hJ : (J : ℝ) ≤ Real.exp p) + (hD : (D : ℝ) ≤ Real.exp ((p + 2) ^ 3)) : + (((n : ℝ) + 1) * (J + 1)) * + Real.exp ((bracketConstructionBudget p + 2) ^ 18 + bracketConstructionBudget p) ≤ + Real.exp (bracketCorrectionBudget p) ∧ + (D : ℝ) * Real.exp ((bracketConstructionBudget p + 2) ^ 36) ≤ + Real.exp (bracketCorrectionBudget p) := by + have hq := bracketConstructionBudget_nonneg hp + have h36 : 0 ≤ (bracketConstructionBudget p + 2) ^ 36 := by positivity + have h18 : 0 ≤ (bracketConstructionBudget p + 2) ^ 18 := by positivity + have h3 : 0 ≤ (p + 2) ^ 3 := by positivity + constructor + · calc + _ ≤ Real.exp (2 * p + 1) * + Real.exp ((bracketConstructionBudget p + 2) ^ 18 + bracketConstructionBudget p) := + mul_le_mul_of_nonneg_right (current_layer_coordinate_factor_bound hp n J hn hJ) + (Real.exp_nonneg _) + _ = Real.exp (2 * p + 1 + + ((bracketConstructionBudget p + 2) ^ 18 + bracketConstructionBudget p)) := + (Real.exp_add _ _).symm + _ ≤ _ := by apply Real.exp_le_exp.mpr; unfold bracketCorrectionBudget; linarith + · calc + _ ≤ Real.exp ((p + 2) ^ 3) * Real.exp ((bracketConstructionBudget p + 2) ^ 36) := + mul_le_mul_of_nonneg_right hD (Real.exp_nonneg _) + _ = Real.exp ((p + 2) ^ 3 + (bracketConstructionBudget p + 2) ^ 36) := + (Real.exp_add _ _).symm + _ ≤ _ := by apply Real.exp_le_exp.mpr; unfold bracketCorrectionBudget; linarith + +theorem exists_bracket_uniform_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → + separationBudget (bracketConstructionBudget p) + bracketCorrectionBudget p ≤ (p + C) ^ C := by + let Q : Polynomial ℕ := (Polynomial.X + 2) ^ 3 + 3 * Polynomial.X + 2 + let B : Polynomial ℕ := (Q + 2) ^ 48 + (Q + 2) ^ 24 + Q + 1 + + ((Q + 2) ^ 36 + (Q + 2) ^ 18 + Q + (Polynomial.X + 2) ^ 3 + 2 * Polynomial.X + 1) + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget B + refine ⟨C, hC, fun p hp => ?_⟩ + simpa [B, Q, separationBudget, bracketCorrectionBudget, bracketConstructionBudget, + Polynomial.eval₂_pow] using hbound p hp + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CanonicalReducedMajorTwistedNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CanonicalReducedMajorTwistedNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..726b980500d2fbb9edaa23e3653e30e39f3d4b0e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CanonicalReducedMajorTwistedNiltest.lean @@ -0,0 +1,620 @@ +import OAI.Combinatorics.Progressions.Dynamics.ReducedTwistedTranslationBudget + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module +open scoped NNReal TensorProduct + +variable {U : Type*} {m : ℕ} + +theorem majorZeroParameterSlice_eq (D : MvPolynomial (U ⊕ Fin m) ℝ) : + specializeMajorParameters (RingHom.id ℝ) D 0 = + aeval (Sum.elim (fun _ : U => (0 : MvPolynomial (Fin m) ℝ)) X) D := by + simp only [specializeMajorParameters, RingHom.comp_id, Pi.zero_apply, map_zero] + rfl + +theorem majorZeroParameterSlice_mass (D : MvPolynomial (U ⊕ Fin m) ℝ) : + realPolynomialMass (specializeMajorParameters (RingHom.id ℝ) D 0) ≤ + realPolynomialMass D := by + rw [majorZeroParameterSlice_eq] + exact realPolynomialMass_zeroParameterEval_le D + +theorem majorZeroParameterSlice_degree (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) + {d : ℕ} {D : MvPolynomial (U ⊕ Fin m) ℝ} + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) : + (specializeMajorParameters (RingHom.id ℝ) D 0).totalDegree ≤ d := by + rw [majorZeroParameterSlice_eq] + apply totalDegree_le_of_positive_weightedSupport w hw + apply weightedSupportLE_aeval _ _ _ _ hD + intro i + cases i with + | inl i => exact Submodule.zero_mem _ + | inr i => exact weightedSupportLE_X w i + +variable (w : Fin m → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + +theorem exists_majorTranslation_buffered_niltest (hd : 0 < d) + (Ψ : PatchKernel m) (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + (M : ℝ≥0) (hM : realPolynomialMass D ≤ M) : + ∃ F : (weightedTranslationNilmanifold w d hw hwd).Niltest (fun _ : U => 1), + F.normBound = 1 ∧ F.lipBound = 2 * bufferedTranslationTermLip w d Ψ M ∧ + F.orbit = majorTranslationPolynomialOrbit w d hw hwd D hD A hA ∧ + (∀ u : U → ℝ, ∀ β : Fin m → ℤ, + (∀ i, |eval u (A i) - (β i : ℝ)| ≤ 1 / 2) → + F.evalReal u = (Ψ.value (fun i => eval u (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (Sum.elim u (fun i => (β i : ℝ))) D) : ℂ)) ∧ + (∀ u : U → ℝ, ‖F.evalReal u‖ ≤ 1) := by + let q := majorTranslationPolynomialOrbit w d hw hwd D hD A hA + have hq := majorTranslationPolynomialOrbit_realEval w d hw hwd D hD A hA + let D₀ := specializeMajorParameters (RingHom.id ℝ) D 0 + have hdegree : D₀.totalDegree ≤ d := majorZeroParameterSlice_degree w hw hD + have hmass : realPolynomialMass D₀ ≤ M := (majorZeroParameterSlice_mass D).trans hM + let F := weightedTranslationBufferedNiltest w d hw hwd (fun _ : U => 1) + hd Ψ D₀ M hdegree hmass q + refine ⟨F, rfl, rfl, rfl, ?_, ?_⟩ + · intro u β hβ + change bufferedTranslationPhase Ψ D₀ + (bchRealTranslationHom w d hwd + ((weightedFiltration w d hwd).realification.polynomialOrbitRealEval + (fun _ : U => 1) u q)) = _ + rw [hq u] + exact bufferedTranslationPhase_majorSymbol Ψ D D₀ A u β hβ + · intro u + exact weightedTranslationBufferedObservable_norm_le_one w d hw hwd Ψ D₀ _ + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3 + +open MvPolynomial + +theorem fractionalCoefficientPolynomial_mem_weightedSupportLE {σ : Type*} + (D : MvPolynomial σ ℝ) (w : σ → ℕ) (d : ℕ) + (hD : D ∈ weightedSupportLE w d) : + fractionalCoefficientPolynomial D ∈ weightedSupportLE w d := by + intro a ha + apply hD + apply mem_support_iff.mpr + intro hz + change D.coeff a = 0 at hz + have hcoeff := mem_support_iff.mp ha + apply hcoeff + change (fractionalCoefficientPolynomial D).coeff a = 0 + simp only [fractionalCoefficientPolynomial_coeff, hz, Int.fract_zero] + +theorem fractionalCoefficientPolynomial_mass_le_of_weightedSupportLE + {σ : Type*} [Fintype σ] (D : MvPolynomial σ ℝ) + (w : σ → ℕ) (hw : ∀ i, 0 < w i) (d : ℕ) + (hD : D ∈ weightedSupportLE w d) : + realPolynomialMass (fractionalCoefficientPolynomial D) ≤ + ((Fintype.card σ : ℝ) + 1) ^ d := by + refine (fractionalCoefficientPolynomial_mass_le_card D).trans ?_ + have hcard := boundedExponentSet_card_le (fractionalCoefficientPolynomial D).support d + (fun a ha => (exponentSum_le_positive_weight w hw a).trans + (fractionalCoefficientPolynomial_mem_weightedSupportLE D w d hD ha)) + exact_mod_cast hcard + +end Erdos3 + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module +open scoped NNReal TensorProduct + +theorem exists_majorTranslation_degree_reduced_niltest (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {U : Type*} [Fintype U] {m : ℕ} + (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + (_hd : 0 < d) (Ψ : PatchKernel m) (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + {p : ℝ} (_hp : 0 ≤ p) (_hdim : (Fintype.card U + m : ℕ) ≤ p) + (_hΨ : (Ψ.lip : ℝ) ≤ Real.exp p), + ∃ F : (weightedTranslationNilmanifold w d hw hwd).Niltest (fun _ : U => 1), + F.normBound = 1 ∧ F.ComplexityLE ((p + C) ^ C) ∧ + F.orbit = majorTranslationPolynomialOrbit w d hw hwd + (fractionalCoefficientPolynomial D) + (fractionalCoefficientPolynomial_mem_weightedSupportLE D + (Sum.elim (fun _ : U => 1) w) d hD) A hA ∧ + ∀ u : U → ℤ, ∀ β : Fin m → ℤ, + (∀ i, |eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)| ≤ 1 / 2) → + F.eval u = + (Ψ.value (fun i => eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (fun j => ((Sum.elim u β j : ℤ) : ℝ)) D) : ℂ) := by + obtain ⟨a, ha, hbudget⟩ := exists_weightedTranslationBuffered_budget d + let X : Polynomial ℕ := Polynomial.X + let Q := (Polynomial.C (d + 1) * (X + 1) + Polynomial.C a) ^ a + 4 + obtain ⟨C, hC, hCbudget⟩ := exists_natPolynomial_eval_budget Q + refine ⟨C, hC, ?_⟩ + intro U _ m w hw hwd _ _ _ _ _ hd Ψ D hD A hA p hp hdim hΨ + let v : U ⊕ Fin m → ℕ := Sum.elim (fun _ : U => 1) w + have hv : ∀ i, 0 < v i := by intro i; cases i with + | inl i => exact Nat.zero_lt_one + | inr i => exact hw i + let Dred := fractionalCoefficientPolynomial D + have hDred : Dred ∈ weightedSupportLE v d := + fractionalCoefficientPolynomial_mem_weightedSupportLE D v d hD + let M : ℝ≥0 := ((Fintype.card U + m + 1 : ℕ) : ℝ≥0) ^ d + have hmass : realPolynomialMass Dred ≤ M := by + change realPolynomialMass Dred ≤ (((Fintype.card U + m + 1 : ℕ) : ℝ) ^ d) + have hh := fractionalCoefficientPolynomial_mass_le_of_weightedSupportLE D v hv d hD + simpa only [Dred, + Fintype.card_sum, Fintype.card_fin, Nat.cast_add, Nat.cast_one] using hh + obtain ⟨F, hnorm, hlip, horbit, heval, _⟩ := exists_majorTranslation_buffered_niltest + w d hw hwd hd Ψ Dred hDred A hA M hmass + let q : ℝ := (d + 1 : ℕ) * (p + 1) + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + dsimp [q] + push_cast + nlinarith [Nat.cast_nonneg (α := ℝ) d] + have hm : (m : ℝ) ≤ q := by + have hh : (m : ℝ) ≤ (Fintype.card U + m : ℕ) := by exact_mod_cast Nat.le_add_left m (Fintype.card U) + exact hh.trans (hdim.trans hpq) + have hM : (M : ℝ) ≤ Real.exp q := by + have hb : ((Fintype.card U + m + 1 : ℕ) : ℝ) ≤ Real.exp (p + 1) := by + push_cast at hdim ⊢ + linarith [Real.add_one_le_exp (p + 1)] + calc + (M : ℝ) ≤ (Real.exp (p + 1)) ^ d := by + change (((Fintype.card U + m + 1 : ℕ) : ℝ) ^ d) ≤ _ + exact pow_le_pow_left₀ (Nat.cast_nonneg _) hb d + _ = Real.exp ((d : ℝ) * (p + 1)) := (Real.exp_nat_mul _ _).symm + _ ≤ Real.exp q := by apply Real.exp_le_exp.mpr; dsimp [q]; push_cast; nlinarith + obtain ⟨hgeometry, hlipBudget⟩ := hbudget w hw hwd Ψ M q hq hm + (hΨ.trans (Real.exp_le_exp.mpr hpq)) hM + have hcost : (q + a) ^ a + 4 ≤ (p + C) ^ C := by + simpa [Q, X, q, Polynomial.eval₂_pow] using hCbudget p hp + have hlog : Real.log (3 + (F.lipBound : ℝ)) ≤ (q + a) ^ a + 4 := by + have hnonneg : 0 ≤ (q + a) ^ a := by positivity + have hh := add_le_exp_add_one (by norm_num : (0 : ℝ) ≤ 3) hnonneg + (show (3 : ℝ) ≤ Real.exp 3 by linarith [Real.add_one_le_exp (3 : ℝ)]) + (show (F.lipBound : ℝ) ≤ Real.exp ((q + a) ^ a) by rw [hlip]; exact hlipBudget) + apply (Real.log_le_iff_le_exp (by positivity)).mpr + convert hh using 1 + congr 1 + ring + refine ⟨F, hnorm, ⟨RationalFilteredNilmanifold.GeometryComplexityLE.mono _ + hgeometry (by linarith), ?_⟩, horbit, ?_⟩ + · simpa only [hnorm, NNReal.coe_one, show (2 : ℝ) + 1 = 3 by norm_num] + using hlog.trans hcost + · intro u β hβ + rw [← F.evalReal_integer u, heval _ β hβ] + have hcast : Sum.elim (fun j => (u j : ℝ)) (fun i => (β i : ℝ)) = + (fun j => ((Sum.elim u β j : ℤ) : ℝ)) := by + funext j + cases j <;> rfl + rw [hcast] + congr 1 + exact congrArg (fun z : Circle => (z : ℂ)) + (fractionalCoefficientPolynomial_fourierChar D (Sum.elim u β)) + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module +open scoped NNReal TensorProduct + +theorem exists_majorTranslation_reduced_niltest (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {U : Type*} [Fintype U] {m : ℕ} + (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + (_hd : 0 < d) (Ψ : PatchKernel m) (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + {p : ℝ} (_hp : 0 ≤ p) (_hdim : (Fintype.card U + m : ℕ) ≤ p) + (_hΨ : (Ψ.lip : ℝ) ≤ Real.exp p), + ∃ F : (weightedTranslationNilmanifold w d hw hwd).Niltest (fun _ : U => 1), + F.normBound = 1 ∧ F.ComplexityLE ((p + C) ^ C) ∧ + F.orbit = majorTranslationPolynomialOrbit w d hw hwd + (fractionalCoefficientPolynomial D) + (fun _α hα => (fractionalCoefficientPolynomial_isWeightedHomogeneous D + (Sum.elim (fun _ : U => 1) w) d hD (mem_support_iff.mp hα)).le) A hA ∧ + ∀ u : U → ℤ, ∀ β : Fin m → ℤ, + (∀ i, |eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)| ≤ 1 / 2) → + F.eval u = + (Ψ.value (fun i => eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (fun j => ((Sum.elim u β j : ℤ) : ℝ)) D) : ℂ) := by + obtain ⟨a, ha, hbudget⟩ := exists_weightedTranslationBuffered_budget d + let X : Polynomial ℕ := Polynomial.X + let Q := (Polynomial.C (d + 1) * (X + 1) + Polynomial.C a) ^ a + 4 + obtain ⟨C, hC, hCbudget⟩ := exists_natPolynomial_eval_budget Q + refine ⟨C, hC, ?_⟩ + intro U _ m w hw hwd _ _ _ _ _ hd Ψ D hD A hA p hp hdim hΨ + let v : U ⊕ Fin m → ℕ := Sum.elim (fun _ : U => 1) w + have hv : ∀ i, 0 < v i := by intro i; cases i with + | inl i => exact Nat.zero_lt_one + | inr i => exact hw i + let Dred := fractionalCoefficientPolynomial D + have hDred : Dred.IsWeightedHomogeneous v d := + fractionalCoefficientPolynomial_isWeightedHomogeneous D v d hD + let M : ℝ≥0 := ((Fintype.card U + m + 1 : ℕ) : ℝ≥0) ^ d + have hmass : realPolynomialMass Dred ≤ M := by + change realPolynomialMass Dred ≤ (((Fintype.card U + m + 1 : ℕ) : ℝ) ^ d) + have hh := fractionalCoefficientPolynomial_mass_le D v hv d hD + simpa only [Dred, + Fintype.card_sum, Fintype.card_fin, Nat.cast_add, Nat.cast_one] using hh + obtain ⟨F, hnorm, hlip, horbit, heval, _⟩ := exists_majorTranslation_buffered_niltest + w d hw hwd hd Ψ Dred (fun α hα => (hDred (mem_support_iff.mp hα)).le) A hA M hmass + let q : ℝ := (d + 1 : ℕ) * (p + 1) + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + dsimp [q] + push_cast + nlinarith [Nat.cast_nonneg (α := ℝ) d] + have hm : (m : ℝ) ≤ q := by + have hh : (m : ℝ) ≤ (Fintype.card U + m : ℕ) := by exact_mod_cast Nat.le_add_left m (Fintype.card U) + exact hh.trans (hdim.trans hpq) + have hM : (M : ℝ) ≤ Real.exp q := by + have hb : ((Fintype.card U + m + 1 : ℕ) : ℝ) ≤ Real.exp (p + 1) := by + push_cast at hdim ⊢ + linarith [Real.add_one_le_exp (p + 1)] + calc + (M : ℝ) ≤ (Real.exp (p + 1)) ^ d := by + change (((Fintype.card U + m + 1 : ℕ) : ℝ) ^ d) ≤ _ + exact pow_le_pow_left₀ (Nat.cast_nonneg _) hb d + _ = Real.exp ((d : ℝ) * (p + 1)) := (Real.exp_nat_mul _ _).symm + _ ≤ Real.exp q := by apply Real.exp_le_exp.mpr; dsimp [q]; push_cast; nlinarith + obtain ⟨hgeometry, hlipBudget⟩ := hbudget w hw hwd Ψ M q hq hm + (hΨ.trans (Real.exp_le_exp.mpr hpq)) hM + have hcost : (q + a) ^ a + 4 ≤ (p + C) ^ C := by + simpa [Q, X, q, Polynomial.eval₂_pow] using hCbudget p hp + have hlog : Real.log (3 + (F.lipBound : ℝ)) ≤ (q + a) ^ a + 4 := by + have hnonneg : 0 ≤ (q + a) ^ a := by positivity + have hh := add_le_exp_add_one (by norm_num : (0 : ℝ) ≤ 3) hnonneg + (show (3 : ℝ) ≤ Real.exp 3 by linarith [Real.add_one_le_exp (3 : ℝ)]) + (show (F.lipBound : ℝ) ≤ Real.exp ((q + a) ^ a) by rw [hlip]; exact hlipBudget) + apply (Real.log_le_iff_le_exp (by positivity)).mpr + convert hh using 1 + congr 1 + ring + refine ⟨F, hnorm, ⟨RationalFilteredNilmanifold.GeometryComplexityLE.mono _ + hgeometry (by linarith), ?_⟩, horbit, ?_⟩ + · simpa only [hnorm, NNReal.coe_one, show (2 : ℝ) + 1 = 3 by norm_num] + using hlog.trans hcost + · intro u β hβ + rw [← F.evalReal_integer u, heval _ β hβ] + have hcast : Sum.elim (fun j => (u j : ℝ)) (fun i => (β i : ℝ)) = + (fun j => ((Sum.elim u β j : ℤ) : ℝ)) := by + funext j + cases j <;> rfl + rw [hcast] + congr 1 + exact congrArg (fun z : Circle => (z : ℂ)) + (fractionalCoefficientPolynomial_fourierChar D (Sum.elim u β)) + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module +open scoped NNReal TensorProduct + +section Construction + +variable {U : Type*} {m : ℕ} (w : Fin m → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + +theorem exists_majorTranslation_twisted_niltest (hd : 0 < d) + (M : ℕ) (hM : 0 < M) (Ψ : PatchKernel m) (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + (B K : ℝ≥0) (hB : realPolynomialMass D ≤ B) + (T : (Fin m → ℝ) → (Fin m → ZMod M) → ℂ) + (hT : ∀ x r, ‖T x r‖ ≤ 1) (hLip : ∀ r, LipschitzWith K (fun x => T x r)) : + ∃ F : (weightedTranslationResidueNilmanifold w d hw hwd M hM).Niltest (fun _ : U => 1), + F.normBound = 1 ∧ F.lipBound = 2 * twistedBufferedTranslationTermLip w d Ψ B K ∧ + F.orbit = majorTranslationPolynomialOrbit w d hw hwd D hD A hA ∧ + ∀ u : U → ℝ, ∀ β : Fin m → ℤ, + (∀ i, |eval u (A i) - (β i : ℝ)| ≤ 1 / 2) → + F.evalReal u = + T (fun i => eval u (A i) - (β i : ℝ)) (fun i => (β i : ZMod M)) * + (Ψ.value (fun i => eval u (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (Sum.elim u (fun i => (β i : ℝ))) D) : ℂ) := by + let q := majorTranslationPolynomialOrbit w d hw hwd D hD A hA + have hq := majorTranslationPolynomialOrbit_realEval w d hw hwd D hD A hA + let D₀ := specializeMajorParameters (RingHom.id ℝ) D 0 + have hdegree : D₀.totalDegree ≤ d := majorZeroParameterSlice_degree w hw hD + have hmass : realPolynomialMass D₀ ≤ B := (majorZeroParameterSlice_mass D).trans hB + let F := weightedTranslationTwistedNiltest w d hw hwd M hM (fun _ : U => 1) + hd Ψ D₀ B K hdegree hmass T hT hLip q + refine ⟨F, rfl, rfl, rfl, ?_⟩ + intro u β hβ + change twistedBufferedTranslationPhase M Ψ D₀ T + (bchRealTranslationHom w d hwd + ((weightedFiltration w d hwd).realification.polynomialOrbitRealEval + (fun _ : U => 1) u q)) = _ + rw [hq u] + exact twistedBufferedTranslationPhase_majorSymbol M Ψ D D₀ T A u β hβ + +end Construction + +theorem exists_majorTranslation_reduced_twisted_niltest (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {U : Type*} [Fintype U] {m : ℕ} + (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + (_hd : 0 < d) (M : ℕ) (hM : 0 < M) (Ψ : PatchKernel m) + (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + (K : ℝ≥0) (T : (Fin m → ℝ) → (Fin m → ZMod M) → ℂ) + (_hT : ∀ x r, ‖T x r‖ ≤ 1) (_hLip : ∀ r, LipschitzWith K (fun x => T x r)) + {p : ℝ} (_hp : 0 ≤ p) (_hdim : (Fintype.card U + m : ℕ) ≤ p) + (_hMp : (M : ℝ) ≤ Real.exp p) (_hΨ : (Ψ.lip : ℝ) ≤ Real.exp p) + (_hK : (K : ℝ) ≤ Real.exp p), + ∃ F : (weightedTranslationResidueNilmanifold w d hw hwd M hM).Niltest (fun _ : U => 1), + F.normBound = 1 ∧ F.ComplexityLE ((p + C) ^ C) ∧ + F.orbit = majorTranslationPolynomialOrbit w d hw hwd + (fractionalCoefficientPolynomial D) + (fun _ hα => (fractionalCoefficientPolynomial_isWeightedHomogeneous D + (Sum.elim (fun _ : U => 1) w) d hD (mem_support_iff.mp hα)).le) A hA ∧ + ∀ u : U → ℤ, ∀ β : Fin m → ℤ, + (∀ i, |eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)| ≤ 1 / 2) → + F.eval u = + T (fun i => eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)) + (fun i => (β i : ZMod M)) * + (Ψ.value (fun i => eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (fun j => ((Sum.elim u β j : ℤ) : ℝ)) D) : ℂ) := by + obtain ⟨a, _, hbudget⟩ := exists_weightedTwistedTranslation_budget d + let X : Polynomial ℕ := Polynomial.X + let Q := (Polynomial.C (d + 1) * (X + 1) + Polynomial.C a) ^ a + obtain ⟨C, hC, hCbudget⟩ := exists_natPolynomial_eval_budget Q + refine ⟨C, hC, ?_⟩ + intro U _ m w hw hwd _ _ _ _ _ hd M hM Ψ D hD A hA K T hT hLip p hp hdim hMp hΨ hK + let v : U ⊕ Fin m → ℕ := Sum.elim (fun _ : U => 1) w + have hv : ∀ i, 0 < v i := by + intro i + cases i with + | inl i => exact Nat.zero_lt_one + | inr i => exact hw i + let Dred := fractionalCoefficientPolynomial D + have hDred : Dred.IsWeightedHomogeneous v d := + fractionalCoefficientPolynomial_isWeightedHomogeneous D v d hD + let B : ℝ≥0 := ((Fintype.card U + m + 1 : ℕ) : ℝ≥0) ^ d + have hmass : realPolynomialMass Dred ≤ B := by + change realPolynomialMass Dred ≤ (((Fintype.card U + m + 1 : ℕ) : ℝ) ^ d) + have hh := fractionalCoefficientPolynomial_mass_le D v hv d hD + simpa only [Dred, Fintype.card_sum, Fintype.card_fin, Nat.cast_add, Nat.cast_one] using hh + obtain ⟨F, hnorm, hlip, horbit, heval⟩ := exists_majorTranslation_twisted_niltest + w d hw hwd hd M hM Ψ Dred (fun _ hα => (hDred (mem_support_iff.mp hα)).le) + A hA B K hmass T hT hLip + let q : ℝ := (d + 1 : ℕ) * (p + 1) + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + dsimp [q] + push_cast + nlinarith [Nat.cast_nonneg (α := ℝ) d] + have hm : (m : ℝ) ≤ q := by + have hh : (m : ℝ) ≤ (Fintype.card U + m : ℕ) := by + exact_mod_cast Nat.le_add_left m (Fintype.card U) + exact hh.trans (hdim.trans hpq) + have hB : (B : ℝ) ≤ Real.exp q := by + have hb : ((Fintype.card U + m + 1 : ℕ) : ℝ) ≤ Real.exp (p + 1) := by + push_cast at hdim ⊢ + linarith [Real.add_one_le_exp (p + 1)] + calc + (B : ℝ) ≤ (Real.exp (p + 1)) ^ d := by + change (((Fintype.card U + m + 1 : ℕ) : ℝ) ^ d) ≤ _ + exact pow_le_pow_left₀ (Nat.cast_nonneg _) hb d + _ = Real.exp ((d : ℝ) * (p + 1)) := (Real.exp_nat_mul _ _).symm + _ ≤ Real.exp q := by apply Real.exp_le_exp.mpr; dsimp [q]; push_cast; nlinarith + obtain ⟨hgeometry, hlog⟩ := hbudget w hw hwd M hM Ψ B K q hq hm + (hMp.trans (Real.exp_le_exp.mpr hpq)) (hΨ.trans (Real.exp_le_exp.mpr hpq)) + hB (hK.trans (Real.exp_le_exp.mpr hpq)) + have hcost : (q + a) ^ a ≤ (p + C) ^ C := by + simpa [Q, X, q, Polynomial.eval₂_pow] using hCbudget p hp + refine ⟨F, hnorm, + ⟨RationalFilteredNilmanifold.GeometryComplexityLE.mono _ hgeometry hcost, ?_⟩, + horbit, ?_⟩ + · simpa only [hnorm, hlip, NNReal.coe_one, show (2 : ℝ) + 1 = 3 by norm_num] + using hlog.trans hcost + · intro u β hβ + rw [← F.evalReal_integer u, heval _ β hβ] + have hcast : Sum.elim (fun j => (u j : ℝ)) (fun i => (β i : ℝ)) = + (fun j => ((Sum.elim u β j : ℤ) : ℝ)) := by + funext j + cases j <;> rfl + rw [hcast] + congr 1 + exact congrArg (fun z : Circle => (z : ℂ)) + (fractionalCoefficientPolynomial_fourierChar D (Sum.elim u β)) + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module +open scoped NNReal TensorProduct + +section Construction + +variable {U : Type*} [Fintype U] {m : ℕ} + +omit [Fintype U] in +theorem fractionalMajorPolynomial_support (w : Fin m → ℕ) (d : ℕ) + (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) : + fractionalCoefficientPolynomial D ∈ + weightedSupportLE (Sum.elim (fun _ : U => 1) w) d := + fun _ hα => (fractionalCoefficientPolynomial_isWeightedHomogeneous D + (Sum.elim (fun _ : U => 1) w) d hD (mem_support_iff.mp hα)).le + +theorem fractionalMajorPolynomial_mass (w : Fin m → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) : + realPolynomialMass (fractionalCoefficientPolynomial D) ≤ + ((((Fintype.card U + m + 1 : ℕ) : ℝ≥0) ^ d : ℝ≥0) : ℝ) := by + change realPolynomialMass (fractionalCoefficientPolynomial D) ≤ + (((Fintype.card U + m + 1 : ℕ) : ℝ) ^ d) + have hv : ∀ i, 0 < Sum.elim (fun _ : U => 1) w i := by + intro i + cases i with + | inl i => exact Nat.zero_lt_one + | inr i => exact hw i + simpa only [Fintype.card_sum, Fintype.card_fin, NNReal.coe_pow, + NNReal.coe_natCast, Nat.cast_add, Nat.cast_one] using + fractionalCoefficientPolynomial_mass_le D (Sum.elim (fun _ : U => 1) w) hv d hD + +variable (w : Fin m → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + +noncomputable def reducedMajorTranslationTwistedNiltest (hd : 0 < d) + (M : ℕ) (hM : 0 < M) (Ψ : PatchKernel m) + (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + (K : ℝ≥0) (T : (Fin m → ℝ) → (Fin m → ZMod M) → ℂ) + (hT : ∀ x r, ‖T x r‖ ≤ 1) (hLip : ∀ r, LipschitzWith K (fun x => T x r)) : + (weightedTranslationResidueNilmanifold w d hw hwd M hM).Niltest (fun _ : U => 1) := + weightedTranslationTwistedNiltest w d hw hwd M hM (fun _ : U => 1) hd Ψ + (specializeMajorParameters (RingHom.id ℝ) (fractionalCoefficientPolynomial D) 0) + (((Fintype.card U + m + 1 : ℕ) : ℝ≥0) ^ d) K + (majorZeroParameterSlice_degree w hw (fractionalMajorPolynomial_support w d D hD)) + ((majorZeroParameterSlice_mass (fractionalCoefficientPolynomial D)).trans + (fractionalMajorPolynomial_mass w d hw D hD)) T hT hLip + (majorTranslationPolynomialOrbit w d hw hwd (fractionalCoefficientPolynomial D) + (fractionalMajorPolynomial_support w d D hD) A hA) + +variable (hd : 0 < d) (M : ℕ) (hM : 0 < M) (Ψ : PatchKernel m) + (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + (K : ℝ≥0) (T : (Fin m → ℝ) → (Fin m → ZMod M) → ℂ) + (hT : ∀ x r, ‖T x r‖ ≤ 1) (hLip : ∀ r, LipschitzWith K (fun x => T x r)) + +@[simp] theorem reducedMajorTranslationTwistedNiltest_normBound : + (reducedMajorTranslationTwistedNiltest w d hw hwd hd M hM Ψ D hD A hA K T hT hLip).normBound = 1 := rfl + +@[simp] theorem reducedMajorTranslationTwistedNiltest_lipBound : + (reducedMajorTranslationTwistedNiltest w d hw hwd hd M hM Ψ D hD A hA K T hT hLip).lipBound = 2 * twistedBufferedTranslationTermLip w d Ψ + (((Fintype.card U + m + 1 : ℕ) : ℝ≥0) ^ d) K := rfl + +@[simp] theorem reducedMajorTranslationTwistedNiltest_orbit : + (reducedMajorTranslationTwistedNiltest w d hw hwd hd M hM Ψ D hD A hA K T hT hLip).orbit = majorTranslationPolynomialOrbit w d hw hwd (fractionalCoefficientPolynomial D) + (fractionalMajorPolynomial_support w d D hD) A hA := rfl + +@[simp] theorem reducedMajorTranslationTwistedNiltest_observable : + (reducedMajorTranslationTwistedNiltest w d hw hwd hd M hM Ψ D hD A hA K T hT hLip).observable = weightedTranslationTwistedObservable w d hw hwd M hM Ψ + (specializeMajorParameters (RingHom.id ℝ) (fractionalCoefficientPolynomial D) 0) T := rfl + +theorem reducedMajorTranslationTwistedNiltest_evalReal + (u : U → ℝ) (β : Fin m → ℤ) + (hβ : ∀ i, |eval u (A i) - (β i : ℝ)| ≤ 1 / 2) : + (reducedMajorTranslationTwistedNiltest w d hw hwd hd M hM Ψ D hD A hA K T hT hLip).evalReal u = + T (fun i => eval u (A i) - (β i : ℝ)) (fun i => (β i : ZMod M)) * + (Ψ.value (fun i => eval u (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (Sum.elim u (fun i => (β i : ℝ))) + (fractionalCoefficientPolynomial D)) : ℂ) := by + change twistedBufferedTranslationPhase M Ψ + (specializeMajorParameters (RingHom.id ℝ) (fractionalCoefficientPolynomial D) 0) T + (bchRealTranslationHom w d hwd + ((weightedFiltration w d hwd).realification.polynomialOrbitRealEval + (fun _ : U => 1) u + (majorTranslationPolynomialOrbit w d hw hwd (fractionalCoefficientPolynomial D) + (fractionalMajorPolynomial_support w d D hD) A hA))) = _ + rw [majorTranslationPolynomialOrbit_realEval] + exact twistedBufferedTranslationPhase_majorSymbol M Ψ (fractionalCoefficientPolynomial D) + (specializeMajorParameters (RingHom.id ℝ) (fractionalCoefficientPolynomial D) 0) T A u β hβ + +theorem reducedMajorTranslationTwistedNiltest_eval + (u : U → ℤ) (β : Fin m → ℤ) + (hβ : ∀ i, |eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)| ≤ 1 / 2) : + (reducedMajorTranslationTwistedNiltest w d hw hwd hd M hM Ψ D hD A hA K T hT hLip).eval u = + T (fun i => eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)) + (fun i => (β i : ZMod M)) * + (Ψ.value (fun i => eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (fun j => ((Sum.elim u β j : ℤ) : ℝ)) D) : ℂ) := by + rw [← RationalFilteredNilmanifold.Niltest.evalReal_integer, + reducedMajorTranslationTwistedNiltest_evalReal w d hw hwd hd M hM Ψ D hD A hA K T hT hLip + _ β hβ] + have hcast : Sum.elim (fun j => (u j : ℝ)) (fun i => (β i : ℝ)) = + (fun j => ((Sum.elim u β j : ℤ) : ℝ)) := by + funext j + cases j <;> rfl + rw [hcast] + congr 1 + exact congrArg (fun z : Circle => (z : ℂ)) + (fractionalCoefficientPolynomial_fourierChar D (Sum.elim u β)) + +end Construction + +theorem exists_reducedMajorTranslationTwistedNiltest_complexity (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {U : Type*} [Fintype U] {m : ℕ} + (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + (hd : 0 < d) (M : ℕ) (hM : 0 < M) (Ψ : PatchKernel m) + (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (hA : ∀ i, (A i).totalDegree ≤ w i) + (K : ℝ≥0) (T : (Fin m → ℝ) → (Fin m → ZMod M) → ℂ) + (hT : ∀ x r, ‖T x r‖ ≤ 1) (hLip : ∀ r, LipschitzWith K (fun x => T x r)) + {p : ℝ} (_hp : 0 ≤ p) (_hdim : (Fintype.card U + m : ℕ) ≤ p) + (_hMp : (M : ℝ) ≤ Real.exp p) (_hΨ : (Ψ.lip : ℝ) ≤ Real.exp p) + (_hK : (K : ℝ) ≤ Real.exp p), + (reducedMajorTranslationTwistedNiltest w d hw hwd hd M hM Ψ D hD A hA K T hT hLip).ComplexityLE ((p + C) ^ C) := by + obtain ⟨C, hC, hbudget⟩ := exists_reducedTwistedTranslation_budget d + refine ⟨C, hC, ?_⟩ + intro U _ m w hw hwd _ _ _ _ _ hd M hM Ψ D hD A hA K T hT hLip p hp hdim hMp hΨ hK + obtain ⟨hgeometry, hlog⟩ := hbudget U w hw hwd M hM Ψ K p hp hdim hMp hΨ hK + refine ⟨hgeometry, ?_⟩ + simpa only [reducedMajorTranslationTwistedNiltest_normBound, + reducedMajorTranslationTwistedNiltest_lipBound, NNReal.coe_one, + show (2 : ℝ) + 1 = 3 by norm_num] using hlog + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CellwiseNiltestDiscretization.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CellwiseNiltestDiscretization.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fcfb383dfcb6f60570c0bc63d3a2890f4250e7e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CellwiseNiltestDiscretization.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Nilpotent.IdealInvariantNiltestBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct NNReal + +theorem exists_cellwise_niltest_discretization + {I J Ξ : Type*} [Fintype I] [Fintype J] [PseudoMetricSpace Ξ] + (N : ℕ) [NeZero N] {K : ZMod N → Type*} + [∀ h, LieRing (K h)] [∀ h, LieAlgebra ℚ (K h)] {s : ℕ} {d : ZMod N → ℕ} + [∀ h, TopologicalSpace (ℝ ⊗[ℚ] K h)] [∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] K h)] + [∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] K h)] [∀ h, T2Space (ℝ ⊗[ℚ] K h)] + (D : ∀ h, RationalFilteredNilmanifold (K h) s (d h)) + (g : ∀ h, (D h).filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (F : I → ∀ h, (D h).Space → Ξ → ℝ) + (A : I → ZMod N → ℝ) (B : J → ZMod N → ℝ) (E : ZMod N → Set (ZMod N)) + (xi : ZMod N → ZMod N → Ξ) (T : ZMod N → ZMod N → ℝ) + {L M : ℝ≥0} {rho delta p : ℝ} + (hA : ∀ i n, 0 ≤ A i n) (hB : ∀ j n, 0 ≤ B j n) + (hAsum : ∀ n, ∑ i, A i n = 1) (hBsum : ∀ n, ∑ j, B j n = 1) + (hF : ∀ i h z a, 0 ≤ F i h z a ∧ F i h z a ≤ 1) + (hFirstLip : ∀ i h, let := (D h).metricSpace; ∀ a, LipschitzWith M (fun z => F i h z a)) + (hSecondLip : ∀ i h z, LipschitzWith L (F i h z)) + (hGeometry : ∀ h, (D h).GeometryComplexityLE p) + (hBudget : Real.log (3 + (M : ℝ)) ≤ p) + (hT : ∀ i h n, n ∉ E h → 0 < A i n → + |T h n - F i h ((D h).cyclicOrbitPoint (g h) N (fun _ : Unit => n)) (xi h n)| ≤ delta) + (hdiam : ∀ i j h n n', n ∉ E h → n' ∉ E h → + 0 < A i n * B j (n + h) → 0 < A i n' * B j (n' + h) → + dist (xi h n) (xi h n') ≤ rho) : + ∃ U : I → J → (h : ZMod N) → (D h).Niltest (fun _ : Unit => 1), + (∀ i j h, (U i j h).UnitIntervalValued) ∧ + (∀ i j h, (U i j h).ComplexityLE p) ∧ + (∀ i j h, (¬∃ n, n ∉ E h ∧ 0 < A i n * B j (n + h)) → + ∀ x, (U i j h).eval x = 0) ∧ + ∀ h n, n ∉ E h → + |T h n - ∑ i, ∑ j, A i n * B j (n + h) * + ((U i j h).evalCyclic N (fun _ : Unit => n)).re| ≤ delta + L * rho := by + let z : (h : ZMod N) → ZMod N → (D h).Space := + fun h n => (D h).cyclicOrbitPoint (g h) N (fun _ : Unit => n) + obtain ⟨a, hempty, herr⟩ := exists_cellwise_positive_shift_discretization A B E z xi F T + hA hB hAsum hBsum hT hSecondLip hdiam + let U : I → J → (h : ZMod N) → (D h).Niltest (fun _ : Unit => 1) := + fun i j h => (D h).sectionNiltest (g h) (F i h) (hF i h) M (hFirstLip i h) (a i j h) + refine ⟨U, ?_, ?_, ?_, ?_⟩ + · intro i j h + exact (D h).sectionNiltest_unit_interval (g h) (F i h) (hF i h) M (hFirstLip i h) (a i j h) + · intro i j h + exact (D h).sectionNiltest_complexityLE (g h) (F i h) (hF i h) M (hFirstLip i h) + (a i j h) (hGeometry h) hBudget + · intro i j h hcell x + dsimp only [U] + rw [hempty i j h hcell] + exact (D h).sectionNiltest_none_eval (g h) (F i h) (hF i h) M (hFirstLip i h) x + · intro h n hn + have heval (i : I) (j : J) : ((U i j h).evalCyclic N (fun _ : Unit => n)).re = + frozenRealSection (F i h) (a i j h) (z h n) := rfl + simpa only [heval] using herr h n hn + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/ChosenBCHGrids.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/ChosenBCHGrids.lean new file mode 100644 index 0000000000000000000000000000000000000000..d54d6456765f60f170a3da22fa1c9eb3103dedf3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/ChosenBCHGrids.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.Progressions.Dynamics.RationalLieQuotientBudget +import OAI.Combinatorics.Progressions.Nilpotent.BCHSubgroupGridExistence + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +variable {ι η L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem exists_subalgebra_basis_and_grid (e : Basis ι ℚ L) (K : LieSubalgebra ℚ L) + (v : η → K) (hspan : Submodule.span ℚ (Set.range v) = ⊤) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) {H l : ℕ} (hHpos : 1 ≤ H) (hlpos : 0 < l) + (hv : ∀ i j, RationalHeightLE (e.repr (v i : L) j) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hd : (Fintype.card ι : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hl : (l : ℝ) ≤ Real.exp p) : + ∃ b : Basis (Fin (finrank ℚ K)) ℚ K, ∃ N : ℕ, + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + (∀ i j, RationalHeightLE (e.repr (b i : L) j) H) ∧ + (∀ i j k, ((lieStructureConstants b i j k).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 11) ∧ + ((lieStructureConstants b i j k).den : ℝ) ≤ Real.exp ((p + 2) ^ 11)) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.map + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)) ∧ + bchSubgroupCoordinates b + (Γ.comap (NilpotentLieBCHGroup.map + (hnil := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) K.incl)) ⊆ denominatorGrid N := by + classical + obtain ⟨b, hb, hc'⟩ := exists_lie_subalgebra_basis_exp_height e K v hspan hHpos hv hc hp hd hH + have hr : (Fintype.card (Fin (finrank ℚ K)) : ℝ) ≤ p := by + rw [Fintype.card_fin] + exact (Nat.cast_le.mpr (lie_subalgebra_finrank_le e K)).trans hd + obtain ⟨N, hN, hNbound, hin, hout⟩ := + exists_bchSubgroup_comap_grid_exp_bound (hM := lie_subalgebra_lowerCentralSeries_eq_bot hnil K) + b e K.incl (fun _ _ h => Subtype.ext h) Γ hHpos hlpos (by + intro i j + rw [LinearMap.toMatrix_apply] + change RationalHeightLE (e.repr (b j : L) i) H + exact hb j i) hinner houter hp hd hr hH hl + exact ⟨b, N, hN, hNbound, hb, hc', hin, hout⟩ + +theorem exists_quotient_basis_and_grid [Fintype η] (e : Basis ι ℚ L) (I : LieIdeal ℚ L) + (v : η → L) (hspan : Submodule.span ℚ (Set.range v) = I.toSubmodule) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) {H l : ℕ} (hHpos : 1 ≤ H) (hlpos : 0 < l) + (hv : ∀ i j, RationalHeightLE (e.repr (v j) i) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + {p : ℝ} (hp : 0 ≤ p) (hn : (Fintype.card ι : ℝ) ≤ p) (hm : (Fintype.card η : ℝ) ≤ p) + (hH : (H : ℝ) ≤ Real.exp p) (hl : (l : ℝ) ≤ Real.exp p) : + ∃ d : ℕ, d ≤ Fintype.card ι ∧ ∃ b : Basis (Fin d) ℚ (L ⧸ I), ∃ N : ℕ, + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 2) ^ 81) ∧ + (∀ i j k, ((lieStructureConstants b i j k).num.natAbs : ℝ) ≤ Real.exp ((p + 2) ^ 51) ∧ + ((lieStructureConstants b i j k).den : ℝ) ≤ Real.exp ((p + 2) ^ 51)) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b (Γ.map (NilpotentLieBCHGroup.quotientHom I)) ∧ + bchSubgroupCoordinates b (Γ.map (NilpotentLieBCHGroup.quotientHom I)) ⊆ denominatorGrid N := by + classical + obtain ⟨t, ht, d, hd, b, D, S, hmatrix, _, hD, _, hbracket⟩ := + exists_bounded_lie_quotient_with_structure e I v hspan hHpos hv hc + have htp : (t : ℝ) ≤ p := (Nat.cast_le.mpr ht).trans hm + have hdp : (d : ℝ) ≤ p := (Nat.cast_le.mpr hd).trans hn + have hpq : p ≤ (p + 2) ^ 7 := le_power_budget hp (by decide) + obtain ⟨N, hN, hNbound, hin, hout⟩ := + exists_bchSubgroup_map_grid_exp_bound (hM := lie_quotient_lowerCentralSeries_eq_bot hnil I) + e b (lieQuotientMap I) (lieQuotientMap_surjective I) Γ + (rationalKernelHeight_pos t hHpos) hlpos (by + intro i j + rw [hmatrix] + exact hD i j) hinner houter (by positivity : 0 ≤ (p + 2) ^ 7) (hn.trans hpq) + (by simpa only [Fintype.card_fin] using hdp.trans hpq) + (rationalKernelHeight_le_budget t H hp htp hH) (hl.trans (Real.exp_le_exp.mpr hpq)) + have hC := rationalLieQuotientStructureHeight_le_exp (Fintype.card ι) t d H hp hn htp hdp hH + refine ⟨d, hd, b, N, hN, exponential_budget_comp hp (by positivity) 7 9 le_rfl hNbound, ?_, hin, hout⟩ + intro i j k + exact ⟨(Nat.cast_le.mpr (hbracket i j k).1).trans hC, + (Nat.cast_le.mpr (hbracket i j k).2).trans hC⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CommonProductNiltestFamily.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CommonProductNiltestFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fe144dbe6adc32ca8871c741f26b8bde3853084 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CommonProductNiltestFamily.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeSampleModelFamily + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct BigOperators + +variable {ι J σ : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + +theorem exists_common_product_niltest_family + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) {w : σ → ℕ} + (base : ∀ i, (D i).Niltest w) (T : J → ∀ i, (D i).Niltest w) + (active : J → Finset ι) (eta : J → ∀ i, L i →ₗ[ℚ] ℚ) + {p : ℝ} (hp : 2 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hD : ∀ i, (D i).GeometryComplexityLE p) + (horbit : ∀ j i, i ∈ active j → (T j i).orbit = (base i).orbit) + (hcomp : ∀ j i, i ∈ active j → (T j i).ComplexityLE p) + (hcap : ∀ j i, i ∈ active j → (T j i).normBound ≤ 1) + (hheight : ∀ j i, i ∈ active j → ∀ k, rationalLogHeight (eta j i ((D i).basis k)) ≤ p) + (hvert : ∀ j i, i ∈ active j → ∀ z, z ∈ (D i).filtration.realification.subgroup s → ∀ x, + (T j i).observable (z • x) = + CircleFourier.character ((realifyFunctional (eta j i) z.coord : ℝ) : CircleFourier.Circle) * + (T j i).observable x) : + ∃ (S0 : (pi D).Niltest w) (S : J → (pi D).Niltest w), + S0.orbit = NilpotentLieFiltration.piRealOrbit (fun i => (D i).filtration) (fun i => (base i).orbit) ∧ + S0.ComplexityLE (productNiltestBudget p) ∧ + ∀ j, (S j).orbit = S0.orbit ∧ + (S j).normBound = 1 ∧ (S j).ComplexityLE (productNiltestBudget p) ∧ + (∀ x, (S j).eval x = ∏ i ∈ active j, (T j i).eval x) ∧ + (∀ k, rationalLogHeight + (piFrequency (selectedOrbitFrequencies (eta j) (active j)) ((pi D).basis k)) ≤ p) ∧ + (∀ z, z ∈ (pi D).filtration.realification.subgroup s → ∀ x, + (S j).observable (z • x) = CircleFourier.character + ((realifyFunctional (piFrequency (selectedOrbitFrequencies (eta j) (active j))) z.coord : ℝ) : + CircleFourier.Circle) * (S j).observable x) := by + have hp0 : 0 ≤ p := by linarith + let U := fun i => (base i).oneOnOrbit + have hU : ∀ i, (U i).ComplexityLE p := fun i => (base i).oneOnOrbit_complexity hp (hD i) + let S0 := piNiltest D U hp0 hι hU + let factors := fun j => selectedOrbitFactors base (T j) (active j) + have hfactorComp : ∀ j i, (factors j i).ComplexityLE p := fun j => + selectedOrbitFactors_complexity base (T j) (active j) hp hD (hcomp j) + have hfactorCap : ∀ j i, (factors j i).normBound ≤ 1 := fun j => + selectedOrbitFactors_normBound base (T j) (active j) (hcap j) + let S := fun j => unitBoundedPiNiltest D (factors j) hp0 hι (hfactorComp j) (hfactorCap j) + refine ⟨S0, S, rfl, piNiltest_complexity D U hp0 hι hU, fun j => ?_⟩ + refine ⟨?_, rfl, unitBoundedPiNiltest_complexity D (factors j) hp0 hι (hfactorComp j) (hfactorCap j), + ?_, ?_, ?_⟩ + · change NilpotentLieFiltration.piRealOrbit _ _ = NilpotentLieFiltration.piRealOrbit _ _ + apply congrArg (NilpotentLieFiltration.piRealOrbit (fun i => (D i).filtration)) + exact funext (selectedOrbitFactors_orbit base (T j) (active j) (horbit j)) + · intro x + exact (unitBoundedPiNiltest_eval D (factors j) hp0 hι (hfactorComp j) (hfactorCap j) x).trans + (selectedOrbitFactors_eval base (T j) (active j) x) + · exact piFrequency_logHeight D _ + (selectedOrbitFrequencies_logHeight (eta j) (active j) hp0 (hheight j)) + · exact productObservable_vertical D (factors j) _ + (selectedOrbitFactors_vertical base (T j) (eta j) (active j) (hvert j)) + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CommonVariableDimensionNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CommonVariableDimensionNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..15d6ce46313c3ee48741e9d3b937694471f6d272 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CommonVariableDimensionNiltests.lean @@ -0,0 +1,287 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonIntegralModelEquivalences +import OAI.Combinatorics.Progressions.Estimates.NativeEqualDimension + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.NativeModelEquiv + +open Module CircleFourier +open scoped TensorProduct NNReal + +variable {σ L M : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {E : RationalFilteredNilmanifold M s d} + (e : NativeModelEquiv D E) {w : σ → ℕ} + +noncomputable def transport (T : D.Niltest w) : E.Niltest w where + orbit := e.mapOrbit T.orbit + observable := T.observable ∘ e.symm.spaceMap + normBound := T.normBound + lipBound := T.lipBound * coordinateLipschitzBound d d 1 + norm_le x := T.norm_le _ + lipschitz := by + let := D.metricSpace + let := E.metricSpace + exact T.lipschitz.comp e.symm.spaceMap_lipschitz + +theorem transport_orbit (T : D.Niltest w) : (e.transport T).orbit = e.mapOrbit T.orbit := rfl + +theorem transport_normBound (T : D.Niltest w) : (e.transport T).normBound = T.normBound := rfl + +theorem transport_eval (T : D.Niltest w) (x : σ → ℤ) : (e.transport T).eval x = T.eval x := by + change T.observable (e.symm.spaceMap + (QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval w x (e.mapOrbit T.orbit)))) = _ + rw [e.mapOrbit_eval, ← e.spaceMap_mk, e.symm_spaceMap_apply] + rfl + +theorem transport_evalCyclic (T : D.Niltest w) (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (e.transport T).evalCyclic N x = T.evalCyclic N x := e.transport_eval T _ + +theorem transport_unit_interval (T : D.Niltest w) (hT : T.UnitIntervalValued) : + (e.transport T).UnitIntervalValued := fun x => hT (e.symm.spaceMap x) + +theorem transport_complexity (T : D.Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hT : T.ComplexityLE p) (hE : E.GeometryComplexityLE p) : + (e.transport T).ComplexityLE (p + (p + 2) ^ 2) := by + have hK : (coordinateLipschitzBound d d 1 : ℝ) ≤ Real.exp ((p + 2) ^ 2) := + coordinateLipschitzBound_le_exp d d 1 hp hT.1.1 hE.1 (Real.one_le_exp_iff.mpr hp) + have h1 : 1 ≤ Real.exp ((p + 2) ^ 2) := Real.one_le_exp_iff.mpr (sq_nonneg _) + refine ⟨hE.mono E (le_add_of_nonneg_right (sq_nonneg _)), ?_⟩ + change Real.log (2 + (T.normBound : ℝ) + + (T.lipBound : ℝ) * coordinateLipschitzBound d d 1) ≤ p + (p + 2) ^ 2 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + calc + 2 + (T.normBound : ℝ) + (T.lipBound : ℝ) * coordinateLipschitzBound d d 1 ≤ + (2 + (T.normBound : ℝ)) * Real.exp ((p + 2) ^ 2) + + (T.lipBound : ℝ) * Real.exp ((p + 2) ^ 2) := + add_le_add (le_mul_of_one_le_right (by positivity) h1) + (mul_le_mul_of_nonneg_left hK T.lipBound.coe_nonneg) + _ = (2 + (T.normBound : ℝ) + (T.lipBound : ℝ)) * Real.exp ((p + 2) ^ 2) := by ring + _ ≤ Real.exp p * Real.exp ((p + 2) ^ 2) := + mul_le_mul_of_nonneg_right (Niltest.observable_budget hT) (Real.exp_pos _).le + _ = Real.exp (p + (p + 2) ^ 2) := (Real.exp_add _ _).symm + +omit [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] in +theorem transported_frequency_basis (eta : L →ₗ[ℚ] ℚ) (i : Fin d) : + (eta.comp e.toLieEquiv.symm.toLieHom.toLinearMap) (E.basis i) = eta (D.basis i) := by + change eta (e.symm.toLieEquiv (E.basis i)) = _ + rw [e.symm.map_basis] + +theorem transport_vertical (T : D.Niltest w) (eta : L →ₗ[ℚ] ℚ) + (hT : ∀ z, z ∈ D.filtration.realification.subgroup s → ∀ x, + T.observable (z • x) = character ((realifyFunctional eta z.coord : ℝ) : CircleFourier.Circle) * T.observable x) + (z : E.RealGroup) (hz : z ∈ E.filtration.realification.subgroup s) (x : E.Space) : + (e.transport T).observable (z • x) = + character ((realifyFunctional (eta.comp e.toLieEquiv.symm.toLieHom.toLinearMap) z.coord : ℝ) : CircleFourier.Circle) * + (e.transport T).observable x := by + change T.observable (e.symm.spaceMap (z • x)) = _ + rw [e.symm.spaceMap_smul] + have heq : realifyFunctional (eta.comp e.toLieEquiv.symm.toLieHom.toLinearMap) z.coord = + realifyFunctional eta (e.symm.realGroupEquiv z).coord := by + calc + _ = realifyFunctional eta + (e.toLieEquiv.symm.toLieHom.toLinearMap.baseChange ℝ z.coord) := + realifyFunctional_comp eta e.toLieEquiv.symm.toLieHom.toLinearMap z.coord + _ = _ := rfl + rw [heq] + exact hT _ (e.symm.map_real_layer s z hz) _ + +theorem transport_kernel_invariant (T : D.Niltest w) {J : Type*} (eta : J → L →ₗ[ℚ] ℚ) + (hT : ∀ z, z ∈ D.filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j) z.coord = 0) → ∀ x, T.observable (z • x) = T.observable x) + (z : E.RealGroup) (hz : z ∈ E.filtration.realification.subgroup s) + (hzero : ∀ j, realifyFunctional ((eta j).comp e.toLieEquiv.symm.toLieHom.toLinearMap) z.coord = 0) + (x : E.Space) : (e.transport T).observable (z • x) = (e.transport T).observable x := by + change T.observable (e.symm.spaceMap (z • x)) = T.observable (e.symm.spaceMap x) + rw [e.symm.spaceMap_smul] + apply hT _ (e.symm.map_real_layer s z hz) _ _ + intro j + calc + _ = realifyFunctional (eta j) + (e.toLieEquiv.symm.toLieHom.toLinearMap.baseChange ℝ z.coord) := rfl + _ = realifyFunctional ((eta j).comp e.toLieEquiv.symm.toLieHom.toLinearMap) z.coord := + (realifyFunctional_comp (eta j) e.toLieEquiv.symm.toLieHom.toLinearMap z.coord).symm + _ = 0 := hzero j + +end Erdos3.RationalFilteredNilmanifold.NativeModelEquiv + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +theorem exists_common_native_niltest_model (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {G σ : Type*} {L : G → Type*} + [∀ h, LieRing (L h)] [∀ h, LieAlgebra ℚ (L h)] + [∀ h, TopologicalSpace (ℝ ⊗[ℚ] L h)] [∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] L h)] + [∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] L h)] [∀ h, T2Space (ℝ ⊗[ℚ] L h)] {d : ℕ} + (D : ∀ h, RationalFilteredNilmanifold (L h) s d) {w : σ → ℕ} + (T : ∀ h, (D h).Niltest w) (H : Finset G), H.Nonempty → + ∀ {p : ℝ}, 0 ≤ p → (∀ h, (T h).ComplexityLE p) → + ∃ h₀ ∈ H, ∃ E : RationalFilteredNilmanifold (L h₀) s d, + E.GeometryComplexityLE ((p + C) ^ C) ∧ + ∃ (H' : Finset G) (S : G → E.Niltest w), + H' ⊆ H ∧ h₀ ∈ H' ∧ Real.exp (-((p + C) ^ C)) * H.card ≤ (H'.card : ℝ) ∧ + ∀ h ∈ H', (S h).ComplexityLE ((p + C) ^ C) ∧ (S h).normBound = (T h).normBound ∧ + (∀ x : σ → ℤ, (S h).eval x = (T h).eval x) ∧ + ((T h).UnitIntervalValued → (S h).UnitIntervalValued) := by + classical + obtain ⟨c, _, hmodels⟩ := exists_common_integral_models s + let X : Polynomial ℕ := Polynomial.X + let Q := X + (X + Polynomial.C c) ^ c + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Q + (Q + 2) ^ 2) + refine ⟨C, hC, ?_⟩ + intro G σ L _ _ _ _ _ _ d D w T H hH p hp hT + let q := p + (p + c) ^ c + have hc0 : 0 ≤ (p + c) ^ c := by positivity + have hpq : p ≤ q := le_add_of_nonneg_right hc0 + have hcq : (p + c) ^ c ≤ q := le_add_of_nonneg_left hp + have hq0 : 0 ≤ q := hp.trans hpq + have hbud : q + (q + 2) ^ 2 ≤ (p + C) ^ C := by + simpa [Q, X, q, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := (le_add_of_nonneg_right (sq_nonneg _)).trans hbud + obtain ⟨B, Λ, hB, hin, hout, hcover, h₀, hh₀, H', hsub, hh₀', hsame, hlarge⟩ := + hmodels D H hH hp (fun h => (hT h).1) + let E₀ := (D h₀).withLattice (Λ h₀) (B h₀) (hB h₀) (hin h₀) (hout h₀) + have hE₀ : E₀.GeometryComplexityLE q := (hcover h₀).2.2.2.mono E₀ hcq + have hbuild (h : {h // h ∈ H'}) : ∃ S : E₀.Niltest w, + S.ComplexityLE ((p + C) ^ C) ∧ S.normBound = (T h.val).normBound ∧ + (∀ x : σ → ℤ, S.eval x = (T h.val).eval x) ∧ + ((T h.val).UnitIntervalValued → S.UnitIntervalValued) := by + let E₁ := (D h.val).withLattice (Λ h.val) (B h.val) (hB h.val) (hin h.val) (hout h.val) + have hE₁ : E₁.GeometryComplexityLE q := (hcover h.val).2.2.2.mono E₁ hcq + have hcode : E₁.rationalModelCoordinates = E₀.rationalModelCoordinates := (hsame h.val h.property).2 + have hcoords₁ : bchSubgroupCoordinates E₁.basis E₁.lattice = scaledIntegerGrid (B h₀) := by + change bchSubgroupCoordinates (D h.val).basis (Λ h.val) = _ + rw [(hcover h.val).2.2.1, (hsame h.val h.property).1] + let e := nativeModelEquivOfCoordinates E₁ E₀ hcode (B h₀) hcoords₁ (hcover h₀).2.2.1 + let T₁ := (T h.val).onSublattice (Λ h.val) (B h.val) (hB h.val) + (hin h.val) (hout h.val) (hcover h.val).2.1 + have hT₁ : T₁.ComplexityLE q := (T h.val).onSublattice_complexity + (Λ h.val) (B h.val) (hB h.val) (hin h.val) (hout h.val) (hcover h.val).2.1 + ((hT h.val).mono hpq) hE₁ + refine ⟨e.transport T₁, (e.transport_complexity T₁ hq0 hT₁ hE₀).mono hbud, rfl, ?_, ?_⟩ + · intro x + exact e.transport_eval T₁ x + · intro ht + apply e.transport_unit_interval + exact (T h.val).onSublattice_unit_interval (Λ h.val) (B h.val) (hB h.val) + (hin h.val) (hout h.val) (hcover h.val).2.1 ht + choose S hS using hbuild + let S₀ : G → E₀.Niltest w := fun h => + if hh : h ∈ H' then S ⟨h, hh⟩ else Niltest.const E₀ w 0 + refine ⟨h₀, hh₀, E₀, hE₀.mono E₀ hqC, H', S₀, hsub, hh₀', ?_, ?_⟩ + · exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg (hcq.trans hqC))) + (Nat.cast_nonneg _)).trans hlarge + · intro h hh + simpa only [S₀, dite_eq_left hh] using hS ⟨h, hh⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +theorem exists_common_variable_dimension_niltest_model (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {G σ : Type*} {L : G → Type*} + [∀ h, LieRing (L h)] [∀ h, LieAlgebra ℚ (L h)] + [∀ h, TopologicalSpace (ℝ ⊗[ℚ] L h)] [∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] L h)] + [∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] L h)] [∀ h, T2Space (ℝ ⊗[ℚ] L h)] {d : G → ℕ} + (D : ∀ h, RationalFilteredNilmanifold (L h) s (d h)) {w : σ → ℕ} + (T : ∀ h, (D h).Niltest w) (H : Finset G), H.Nonempty → + ∀ {p : ℝ}, 0 ≤ p → (∀ h, (T h).ComplexityLE p) → + ∃ h₀ ∈ H, ∃ E : RationalFilteredNilmanifold (L h₀) s (d h₀), + E.GeometryComplexityLE ((p + C) ^ C) ∧ + ∃ (H' : Finset G) (S : G → E.Niltest w), + H' ⊆ H ∧ h₀ ∈ H' ∧ Real.exp (-((p + C) ^ C)) * H.card ≤ (H'.card : ℝ) ∧ + ∀ h ∈ H', (S h).ComplexityLE ((p + C) ^ C) ∧ (S h).normBound = (T h).normBound ∧ + (∀ x : σ → ℤ, (S h).eval x = (T h).eval x) ∧ + ((T h).UnitIntervalValued → (S h).UnitIntervalValued) := by + classical + obtain ⟨c, _, hmodels⟩ := exists_common_native_niltest_model s + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C c) ^ c + X + 1) + refine ⟨C, hC, ?_⟩ + intro G σ L _ _ _ _ _ _ d D w T H hH p hp hT + let q := (p + c) ^ c + have hbud : q + p + 1 ≤ (p + C) ^ C := by + simpa [X, q, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + C) ^ C := by linarith + have hpexp : p ≤ Real.exp p := by linarith [Real.add_one_le_exp p] + obtain ⟨hbase, _, H₀, hsub₀, hhbase, hsame, hlarge₀⟩ := + exists_common_bounded_moduli H hH (fun h (_ : Unit) => d h) hp + (fun h _ _ => (hT h).1.1.trans hpexp) + have hdim (h : {h // h ∈ H₀}) : d h.val = d hbase := congrFun (hsame h.val h.property) () + let D₀ := fun h : {h // h ∈ H₀} => (D h.val).castDimension (hdim h) + let T₀ := fun h : {h // h ∈ H₀} => (T h.val).castDimension (hdim h) + have hT₀ (h : {h // h ∈ H₀}) : (T₀ h).ComplexityLE p := + ((T h.val).castDimension_complexity (hdim h) p).mpr (hT h.val) + obtain ⟨a, _, E₀, hE₀, H₁, S₁, _, ha, hlarge₁, hS₁⟩ := + hmodels D₀ T₀ Finset.univ ⟨⟨hbase, hhbase⟩, Finset.mem_univ _⟩ hp hT₀ + let E := E₀.castDimension (hdim a).symm + let H' := H₁.image Subtype.val + let S : G → E.Niltest w := fun h => if hh : h ∈ H₀ then + (S₁ ⟨h, hh⟩).castDimension (hdim a).symm else Niltest.const E w 0 + have hcard : H'.card = H₁.card := Finset.card_image_of_injective _ Subtype.val_injective + have hcard₀ : (Finset.univ : Finset {h // h ∈ H₀}).card = H₀.card := by simp + have hlarge₀' : Real.exp (-(p + 1)) * H.card ≤ (H₀.card : ℝ) := by + simpa only [Fintype.card_unit, Nat.cast_one, mul_one] using hlarge₀ + have hlarge₁' : Real.exp (-q) * H₀.card ≤ (H'.card : ℝ) := by + rw [hcard] + simpa only [hcard₀] using hlarge₁ + refine ⟨a.val, hsub₀ a.property, E, + (E₀.castDimension_geometry (hdim a).symm _).mpr (hE₀.mono E₀ hqC), H', S, ?_, ?_, ?_, ?_⟩ + · intro h hh + obtain ⟨g, _, rfl⟩ := Finset.mem_image.mp hh + exact hsub₀ g.property + · exact Finset.mem_image.mpr ⟨a, ha, rfl⟩ + · calc + Real.exp (-((p + C) ^ C)) * H.card ≤ Real.exp (-(q + (p + 1))) * H.card := + mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (neg_le_neg (by linarith))) (Nat.cast_nonneg _) + _ = Real.exp (-q) * (Real.exp (-(p + 1)) * H.card) := by + rw [← mul_assoc, ← Real.exp_add] + congr 2 + ring + _ ≤ Real.exp (-q) * H₀.card := mul_le_mul_of_nonneg_left hlarge₀' (Real.exp_pos _).le + _ ≤ H'.card := hlarge₁' + · intro h hh + obtain ⟨g, hg, rfl⟩ := Finset.mem_image.mp hh + have hSg := hS₁ g hg + dsimp only [S] + rw [dite_eq_left g.property] + refine ⟨((S₁ g).castDimension_complexity (hdim a).symm _).mpr (hSg.1.mono hqC), ?_, ?_, ?_⟩ + · calc + _ = (S₁ g).normBound := (S₁ g).castDimension_normBound _ + _ = (T₀ g).normBound := hSg.2.1 + _ = (T g.val).normBound := (T g.val).castDimension_normBound _ + · intro x + calc + _ = (S₁ g).eval x := (S₁ g).castDimension_eval _ x + _ = (T₀ g).eval x := hSg.2.2.1 x + _ = (T g.val).eval x := (T g.val).castDimension_eval _ x + · intro ht + apply ((S₁ g).castDimension_unit_interval (hdim a).symm).mpr + apply hSg.2.2.2 + exact ((T g.val).castDimension_unit_interval (hdim g)).mpr ht + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/ComparisonLayerBracket.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/ComparisonLayerBracket.lean new file mode 100644 index 0000000000000000000000000000000000000000..1428ea05cf360f5a74854cc7aef073611de619be --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/ComparisonLayerBracket.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.Progressions.Estimates.SquarefreeRealAction + +namespace OAI + +section + +namespace Erdos3.MultidegreeLieFiltration + +open scoped BigOperators + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) (π : ι → σ) + +theorem comparisonGraphLayer_lie_mem {i j : ℕ} {x y : L × F.SquarefreeAlgebra π} + (hx : x ∈ F.comparisonGraphLayer π i) (hy : y ∈ F.comparisonGraphLayer π j) : + ⁅x, y⁆ ∈ F.comparisonGraphLayer π (i + j) := by + refine F.comparisonGraphLayer_induction π i + (P := fun z => ⁅z, y⁆ ∈ F.comparisonGraphLayer π (i + j)) hx ?_ ?_ ?_ + · intro a ha hia u + refine F.comparisonGraphLayer_induction π j + (P := fun z => ⁅F.comparisonGraph π a ha u, z⁆ ∈ F.comparisonGraphLayer π (i + j)) hy ?_ ?_ ?_ + · intro b hb hjb v + have hab : a + b ≠ 0 := by + intro h + apply ha + funext k + change a k = 0 + have hk : a k + b k = 0 := congrFun h k + omega + rw [F.comparisonGraph_lie π a b ha hb hab u v] + apply F.comparisonGraph_mem_graphLayer π (i + j) (a + b) hab + simpa only [Pi.add_apply, Finset.sum_add_distrib] using Nat.add_le_add hia hjb + · rw [lie_zero] + exact Submodule.zero_mem _ + · intro v w hv hw + rw [lie_add] + exact Submodule.add_mem _ hv hw + · rw [zero_lie] + exact Submodule.zero_mem _ + · intro u v hu hv + rw [add_lie] + exact Submodule.add_mem _ hu hv + +end Erdos3.MultidegreeLieFiltration + +end + +section + +namespace Erdos3.MultidegreeLieFiltration + +variable {ι σ L : Type*} [Fintype ι] [Fintype σ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {bound : σ → ℕ} (F : MultidegreeLieFiltration σ L s bound) (π : ι → σ) + +theorem comparison_deep_lie_mem {i j : ℕ} {x y : L × F.SquarefreeAlgebra π} + (hx : x ∈ F.comparisonProductLayer π (i + 1)) (hy : y ∈ F.comparisonLayer π j) : + ⁅x, y⁆ ∈ F.comparisonLayer π (i + j) := by + apply (le_sup_left : F.comparisonProductLayer π (i + j + 1) ≤ F.comparisonLayer π (i + j)) + simpa only [Nat.add_right_comm i 1 j] using + F.comparisonProductLayer_lie_mem π hx (F.comparisonLayer_le_product π j hy) + +theorem comparison_lie_deep_mem {i j : ℕ} {x y : L × F.SquarefreeAlgebra π} + (hx : x ∈ F.comparisonLayer π i) (hy : y ∈ F.comparisonProductLayer π (j + 1)) : + ⁅x, y⁆ ∈ F.comparisonLayer π (i + j) := by + apply (le_sup_left : F.comparisonProductLayer π (i + j + 1) ≤ F.comparisonLayer π (i + j)) + simpa only [Nat.add_assoc] using + F.comparisonProductLayer_lie_mem π (F.comparisonLayer_le_product π i hx) hy + +theorem comparisonLayer_lie_mem {i j : ℕ} {x y : L × F.SquarefreeAlgebra π} + (hx : x ∈ F.comparisonLayer π i) (hy : y ∈ F.comparisonLayer π j) : + ⁅x, y⁆ ∈ F.comparisonLayer π (i + j) := by + obtain ⟨u, hu, v, hv, rfl⟩ := Submodule.mem_sup.mp hx + rw [add_lie] + apply Submodule.add_mem _ (F.comparison_deep_lie_mem π hu hy) + obtain ⟨z, hz, w, hw, rfl⟩ := Submodule.mem_sup.mp hy + rw [lie_add] + apply Submodule.add_mem _ + (F.comparison_lie_deep_mem π + ((le_sup_right : F.comparisonGraphLayer π i ≤ F.comparisonLayer π i) hv) hz) + exact (le_sup_right : F.comparisonGraphLayer π (i + j) ≤ F.comparisonLayer π (i + j)) + (F.comparisonGraphLayer_lie_mem π hv hw) + +end Erdos3.MultidegreeLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/ControlledBracketToCurrentLayer.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/ControlledBracketToCurrentLayer.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7b007c0ec40fe05ce871e551d499abb6e688295 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/ControlledBracketToCurrentLayer.lean @@ -0,0 +1,508 @@ +import OAI.Combinatorics.Progressions.Estimates.UniformFormalCurrentLayerStep +import OAI.Combinatorics.Progressions.Polynomial.PolynomialKernelDirectionBudget + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct + +variable {μ σ κ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis μ ℚ L) (w : μ → ℕ) + (hF : ∀ d, F.layer d = Submodule.span ℚ (b '' {i | d ≤ w i})) + +theorem formal_invariant_correction_preserves_derivative_remainder + (U : LieSubalgebra ℚ (ℝ ⊗[ℚ] L)) (V : Submodule ℝ (ℝ ⊗[ℚ] L)) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (j : ℕ) + (A B : PolynomialGroup σ F.realification.lowerCentralSeries_eq_bot) + (hAU : ∀ α, coefficients A.coord α ∈ U) (hBU : ∀ α, coefficients B.coord α ∈ U) + (hAV : ∀ α, coefficients A.coord α ∈ V) (hBV : ∀ α, coefficients B.coord α ∈ V) + (small rational : σ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (hsmall : ∀ i α, coefficients (small i) α ∈ V ⊔ (F.realLayer j).toSubmodule) + (hrational : ∀ i α, coefficients (rational i) α ∈ V ⊔ (F.realLayer j).toSubmodule) : + ∀ i α, coefficients (dualAdjoint A⁻¹ (small i - formalLogDerivative i A)) α ∈ + V ⊔ (F.realLayer j).toSubmodule ∧ + coefficients (dualAdjoint B (rational i) - formalLogDerivative i B) α ∈ + V ⊔ (F.realLayer j).toSubmodule := by + let W := V.restrictScalars ℚ ⊔ F.realification.layer j + have hWiff (x : ℝ ⊗[ℚ] L) : x ∈ W ↔ x ∈ V ⊔ (F.realLayer j).toSubmodule := by + change x ∈ V.restrictScalars ℚ ⊔ (F.realLayer j).toSubmodule.restrictScalars ℚ ↔ _ + rw [← Submodule.restrictScalars_sup] + rfl + intro i α + have h := polynomial_derivative_removal_preserves_coefficients U W + (F.realification.invariant_sup_layer U (V.restrictScalars ℚ) hUV j) + i A B (small i) (rational i) hAU hBU + (fun β => Submodule.mem_sup_left (hAV β)) (fun β => Submodule.mem_sup_left (hBV β)) + (fun β => (hWiff _).mpr (hsmall i β)) (fun β => (hWiff _).mpr (hrational i β)) + exact ⟨(hWiff _).mp (h.1 α), (hWiff _).mp (h.2 α)⟩ + +include hF in +theorem formal_invariant_bracket_derivative_step (hs : 2 ≤ s) + (U : LieSubalgebra ℚ (ℝ ⊗[ℚ] L)) (V : Submodule ℝ (ℝ ⊗[ℚ] L)) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (hV : BasisGradedSubmodule (b.baseChange ℝ) w V) + {j : ℕ} (hj : 2 ≤ j) + (P A B : PolynomialGroup σ F.realification.lowerCentralSeries_eq_bot) + (hAU : ∀ α, coefficients A.coord α ∈ U) (hBU : ∀ α, coefficients B.coord α ∈ U) + (hAV : ∀ α, coefficients A.coord α ∈ V) (hBV : ∀ α, coefficients B.coord α ∈ V) + (S : κ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (k : σ → κ) (I : κ → ℝ ⊗[ℚ] L) + (hI : ∀ x, basisGradeProjection (b.baseChange ℝ) w 1 (I x) = I x) + (small rational : σ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (hsystem : PolynomialDerivativeSystemMod (V.restrictScalars ℚ) P small rational (fun i => S (k i))) + (hsmall : ∀ i α, coefficients (small i) α ∈ V ⊔ (F.realLayer j).toSubmodule) + (hrational : ∀ i α, coefficients (rational i) α ∈ V ⊔ (F.realLayer j).toSubmodule) + (hS : ∀ x α, coefficients (dualAdjoint A⁻¹ (S x) - monomial 0 (I x)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) : + let P' := A⁻¹ * P * B⁻¹ + let small' := fun i => dualAdjoint A⁻¹ (small i - formalLogDerivative i A) + let rational' := fun i => dualAdjoint B (rational i) - formalLogDerivative i B + let extra' := fun i => dualAdjoint A⁻¹ (S (k i)) + PolynomialDerivativeSystemMod (V.restrictScalars ℚ) P' small' rational' extra' ∧ + (∀ i α, coefficients (small' i) α ∈ V ⊔ (F.realLayer j).toSubmodule ∧ + coefficients (rational' i) α ∈ V ⊔ (F.realLayer j).toSubmodule) ∧ + ∀ i α, coefficients (extra' i - VectorPolynomial.map + ((basisGradeProjection (b.baseChange ℝ) w 1).restrictScalars ℚ) + ((MvPolynomial.pderiv i).toLinearMap.rTensor (ℝ ⊗[ℚ] L) P'.coord)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule := by + intro P' small' rational' extra' + have hnew := PolynomialDerivativeSystemMod.remove U (V.restrictScalars ℚ) hUV P A B hAU + small rational (fun i => S (k i)) hsystem + have hrem := F.formal_invariant_correction_preserves_derivative_remainder U V hUV j A B + hAU hBU hAV hBV small rational hsmall hrational + have hmono : V ⊔ (F.realLayer j).toSubmodule ≤ V ⊔ (F.realLayer 2).toSubmodule := by + apply sup_le_sup_left _ V + intro x hx + exact F.realification.antitone hj hx + refine ⟨hnew, hrem, ?_⟩ + apply F.formal_extra_horizontal_equation b w hF hs V hV j P' small' rational' extra' + hnew (fun i α => hmono (hrem i α).1) (fun i α => hmono (hrem i α).2) + intro i + exact F.formal_lift_nonhorizontal_remainder b w hF V hV (by omega : 1 ≤ j) + (extra' i) (I (k i)) (hI _) (hS _) + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct + +variable {μ σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis μ ℚ L) (w : μ → ℕ) + (hF : ∀ d, F.layer d = Submodule.span ℚ (b '' {i | d ≤ w i})) + +include hF in +theorem formal_bracket_correction_preserves_log_conditions + (V K : Submodule ℝ (ℝ ⊗[ℚ] L)) {j : ℕ} (hj : 2 ≤ j) + (P A B : PolynomialGroup σ F.realification.lowerCentralSeries_eq_bot) + (hA : ∀ α, basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients A.coord α) = coefficients A.coord α) + (hB : ∀ α, basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients B.coord α) = coefficients B.coord α) + (hAK : j = 2 → ∀ α, coefficients A.coord α ∈ K) + (hBK : j = 2 → ∀ α, coefficients B.coord α ∈ K) + (hAV : 2 < j → ∀ α, coefficients A.coord α ∈ V) + (hBV : 2 < j → ∀ α, coefficients B.coord α ∈ V) + (hK : ∀ α, basisGradeProjection (b.baseChange ℝ) w 1 (coefficients P.coord α) ∈ K) + (hlower : ∀ α d, 2 ≤ d → d < j → + basisGradeProjection (b.baseChange ℝ) w d (coefficients P.coord α) ∈ V) : + (∀ α, basisGradeProjection (b.baseChange ℝ) w 1 (coefficients (A⁻¹ * P * B⁻¹).coord α) ∈ K) ∧ + ∀ α d, 2 ≤ d → d < j → + basisGradeProjection (b.baseChange ℝ) w d (coefficients (A⁻¹ * P * B⁻¹).coord α) ∈ V := by + let E := LinearMap.ker (basisGradeProjection (b.baseChange ℝ) w (j - 1) - LinearMap.id) + have hE : ∀ x ∈ E, basisGradeProjection (b.baseChange ℝ) w (j - 1) x = x := + fun _ hx => sub_eq_zero.mp hx + have hgrades := F.polynomial_bchRemove_grades b w hF E (j - 1) hE A.coord P.coord B.coord + (fun α => sub_eq_zero.mpr (hA α)) (fun α => sub_eq_zero.mpr (hB α)) + have hcurrent (α : σ →₀ ℕ) : + basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients (A⁻¹ * P * B⁻¹).coord α) = + basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients P.coord α) - + coefficients A.coord α - coefficients B.coord α := by + have h := congrArg (fun Q : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L) => coefficients Q α) hgrades.1 + simp only [coefficients_map, map_sub, Finsupp.sub_apply, LinearMap.restrictScalars_apply] at h + exact h + have hbelow (d : ℕ) (hd : d < j - 1) (α : σ →₀ ℕ) : + basisGradeProjection (b.baseChange ℝ) w d (coefficients (A⁻¹ * P * B⁻¹).coord α) = + basisGradeProjection (b.baseChange ℝ) w d (coefficients P.coord α) := by + have h := congrArg (fun Q : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L) => coefficients Q α) (hgrades.2 d hd) + simp only [coefficients_map, LinearMap.restrictScalars_apply] at h + exact h + constructor + · intro α + by_cases hj2 : j = 2 + · have h := hcurrent α + rw [hj2] at h + change basisGradeProjection (b.baseChange ℝ) w 1 (coefficients (A⁻¹ * P * B⁻¹).coord α) = _ at h + rw [h] + exact K.sub_mem (K.sub_mem (hK α) (hAK hj2 α)) (hBK hj2 α) + · rw [hbelow 1 (by omega)] + exact hK α + · intro α d hd hdj + rcases lt_or_eq_of_le (show d ≤ j - 1 by omega) with hlt | rfl + · rw [hbelow d hlt] + exact hlower α d hd hdj + · rw [hcurrent] + exact V.sub_mem (V.sub_mem (hlower α (j - 1) hd hdj) (hAV (by omega) α)) (hBV (by omega) α) + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct + +variable {μ σ K L : Type*} [AddCommGroup K] [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis μ ℚ L) (w : μ → ℕ) + (hF : ∀ d, F.layer d = Submodule.span ℚ (b '' {i | d ≤ w i})) + +include hF in +theorem formal_bracket_to_current_layer (hs : 2 ≤ s) + (U : LieSubalgebra ℝ (ℝ ⊗[ℚ] L)) (V H : Submodule ℝ (ℝ ⊗[ℚ] L)) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (hV : BasisGradedSubmodule (b.baseChange ℝ) w V) + (I : K →+ ℝ ⊗[ℚ] L) (hI : ∀ x, basisGradeProjection (b.baseChange ℝ) w 1 (I x) = I x) + {j : ℕ} (hj : 2 ≤ j) + (P A B : PolynomialGroup σ F.realification.lowerCentralSeries_eq_bot) + (hPU : ∀ α, coefficients P.coord α ∈ U) + (hAU : ∀ α, coefficients A.coord α ∈ U) (hBU : ∀ α, coefficients B.coord α ∈ U) + (hA : ∀ α, basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients A.coord α) = coefficients A.coord α) + (hB : ∀ α, basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients B.coord α) = coefficients B.coord α) + (hAhom : ∀ α, Finsupp.weight (fun _ : σ => (1 : ℕ)) α ≠ j - 1 → coefficients A.coord α = 0) + (hBhom : ∀ α, Finsupp.weight (fun _ : σ => (1 : ℕ)) α ≠ j - 1 → coefficients B.coord α = 0) + (hAH : j = 2 → ∀ α, coefficients A.coord α ∈ H) + (hBH : j = 2 → ∀ α, coefficients B.coord α ∈ H) + (hAV : 2 < j → ∀ α, coefficients A.coord α ∈ V) + (hBV : 2 < j → ∀ α, coefficients B.coord α ∈ V) + (hH : ∀ α, basisGradeProjection (b.baseChange ℝ) w 1 (coefficients P.coord α) ∈ H) + (hlower : ∀ α d, 2 ≤ d → d < j → + basisGradeProjection (b.baseChange ℝ) w d (coefficients P.coord α) ∈ V) + (S R : K →+ VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (small rational : σ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (k a c : σ → K) + (ha : j = 2 → ∀ i, I (a i) = coefficients A.coord (Finsupp.single i 1)) + (hc : j = 2 → ∀ i, I (c i) = coefficients B.coord (Finsupp.single i 1)) + (hSR : PolynomialLiftSystemMod (V.restrictScalars ℚ) P S R) + (hsystem : PolynomialDerivativeSystemMod (V.restrictScalars ℚ) P small rational (fun i => S (k i))) + (hsmall : ∀ i α, coefficients (small i) α ∈ V ⊔ (F.realLayer j).toSubmodule) + (hrational : ∀ i α, coefficients (rational i) α ∈ V ⊔ (F.realLayer j).toSubmodule) + (hS : ∀ x α, coefficients (dualAdjoint A⁻¹ (S x) - monomial 0 (I x)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) + (hR : ∀ x α, coefficients (dualAdjoint B (R x) - monomial 0 (I x)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) + (hbracket : ∀ α x, x ∈ H → ⁅coefficients (A⁻¹ * P * B⁻¹).coord α, x⁆ ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) : + let P' := A⁻¹ * P * B⁻¹ + let S' := (dualAdjointAddEquiv A⁻¹).toAddMonoidHom.comp S + let R' := (dualAdjointAddEquiv B).toAddMonoidHom.comp R + let small' := fun i => dualAdjoint A⁻¹ (small i - formalLogDerivative i A) + if j = 2 then S' (a i) else 0 + let rational' := fun i => dualAdjoint B (rational i) - formalLogDerivative i B + if j = 2 then R' (c i) else 0 + let k' := fun i => if j = 2 then k i - a i - c i else k i + let extra' := fun i => S' (k' i) + (∀ α, coefficients P'.coord α ∈ U) ∧ + (∀ α, basisGradeProjection (b.baseChange ℝ) w 1 (coefficients P'.coord α) ∈ H) ∧ + (∀ α d, 2 ≤ d → d < j → basisGradeProjection (b.baseChange ℝ) w d (coefficients P'.coord α) ∈ V) ∧ + PolynomialLiftSystemMod (V.restrictScalars ℚ) P' S' R' ∧ + PolynomialDerivativeSystemMod (V.restrictScalars ℚ) P' small' rational' extra' ∧ + (∀ i α, coefficients (small' i) α ∈ V ⊔ (F.realLayer j).toSubmodule ∧ + coefficients (rational' i) α ∈ V ⊔ (F.realLayer j).toSubmodule) ∧ + (∀ i α, coefficients (extra' i - VectorPolynomial.map + ((basisGradeProjection (b.baseChange ℝ) w 1).restrictScalars ℚ) + ((MvPolynomial.pderiv i).toLinearMap.rTensor (ℝ ⊗[ℚ] L) P'.coord)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) ∧ + ∀ i α, coefficients + ((MvPolynomial.pderiv i).toLinearMap.rTensor (ℝ ⊗[ℚ] L) + (VectorPolynomial.map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) P'.coord) - + VectorPolynomial.map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) (small' i) - + VectorPolynomial.map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) (rational' i)) α ∈ V := by + intro P' S' R' small' rational' k' extra' + let Uq : LieSubalgebra ℚ (ℝ ⊗[ℚ] L) := + { U.toSubmodule.restrictScalars ℚ with lie_mem' := fun hx hy => U.lie_mem hx hy } + have hnewU : ∀ α, coefficients P'.coord α ∈ U := + bchRemove_coefficients_mem Uq s A.coord P.coord B.coord hAU hPU hBU + have hlogs := F.formal_bracket_correction_preserves_log_conditions b w hF V H hj P A B + hA hB hAH hBH hAV hBV hH hlower + have hlifts : PolynomialLiftSystemMod (V.restrictScalars ℚ) P' S' R' := + PolynomialLiftSystemMod.remove Uq (V.restrictScalars ℚ) hUV P A B hAU S R hSR + have hderivatives : + PolynomialDerivativeSystemMod (V.restrictScalars ℚ) P' small' rational' extra' ∧ + (∀ i α, coefficients (small' i) α ∈ V ⊔ (F.realLayer j).toSubmodule ∧ + coefficients (rational' i) α ∈ V ⊔ (F.realLayer j).toSubmodule) ∧ + ∀ i α, coefficients (extra' i - VectorPolynomial.map + ((basisGradeProjection (b.baseChange ℝ) w 1).restrictScalars ℚ) + ((MvPolynomial.pderiv i).toLinearMap.rTensor (ℝ ⊗[ℚ] L) P'.coord)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule := by + by_cases hj2 : j = 2 + · subst j + have h := F.formal_degree_two_reabsorption b w hF hs Uq V hUV hV I hI P A B hAU + hAhom hBhom S R small rational k a c (ha rfl) (hc rfl) hSR hsystem hsmall hrational hS hR + simp only [P', S', R', small', rational', k', extra', ite_true] + exact h.2 + · have h := F.formal_invariant_bracket_derivative_step b w hF hs Uq V hUV hV hj P A B + hAU hBU (hAV (by omega)) (hBV (by omega)) S k I hI small rational hsystem hsmall hrational hS + simp only [P', S', small', rational', k', extra', ite_eq_right hj2, add_zero] + exact h + refine ⟨hnewU, hlogs.1, hlogs.2, hlifts, hderivatives.1, hderivatives.2.1, hderivatives.2.2, ?_⟩ + exact F.formal_current_layer_derivative_equation_mod b w hF hs U V H hUV hV hj P' + hnewU hlogs.1 hlogs.2 hbracket small' rational' extra' + (fun i α => (hderivatives.2.1 i α).2) hderivatives.2.2 hderivatives.1 + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3 + +def bracketTransitionBudget (p : ℝ) : ℝ := + 4 * p + (p + 2) ^ 8 + (p + 2) ^ 9 + 1 + +theorem bracket_transition_budget_bounds {p : ℝ} (hp : 0 ≤ p) + (k m d : ℕ) (hk : (k : ℝ) ≤ p) (hm : (m : ℝ) ≤ Real.exp p) + (hd : (d : ℝ) ≤ Real.exp ((p + 2) ^ 9)) : + Real.exp p ≤ Real.exp (bracketTransitionBudget p) ∧ + Real.exp p + (k : ℝ) * Real.exp p * Real.exp ((p + 2) ^ 8) ≤ + Real.exp (bracketTransitionBudget p) ∧ + ((m * (m * d) : ℕ) : ℝ) ≤ Real.exp (bracketTransitionBudget p) := by + have h8 : 0 ≤ (p + 2) ^ 8 := by positivity + have h9 : 0 ≤ (p + 2) ^ 9 := by positivity + have hpE : p ≤ Real.exp p := by linarith [Real.add_one_le_exp p] + have hterm : (k : ℝ) * Real.exp p * Real.exp ((p + 2) ^ 8) ≤ + Real.exp (2 * p + (p + 2) ^ 8) := by + calc + _ ≤ Real.exp p * Real.exp p * Real.exp ((p + 2) ^ 8) := by + gcongr + exact hk.trans hpE + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + refine ⟨Real.exp_le_exp.mpr (by unfold bracketTransitionBudget; linarith), ?_, ?_⟩ + · calc + _ ≤ Real.exp (2 * p + (p + 2) ^ 8) + Real.exp (2 * p + (p + 2) ^ 8) := + add_le_add (Real.exp_le_exp.mpr (by linarith)) hterm + _ = Real.exp (2 * p + (p + 2) ^ 8) * 2 := by ring + _ ≤ Real.exp (2 * p + (p + 2) ^ 8) * Real.exp 1 := + mul_le_mul_of_nonneg_left (by linarith [Real.add_one_le_exp (1 : ℝ)]) (Real.exp_nonneg _) + _ = Real.exp (2 * p + (p + 2) ^ 8 + 1) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by unfold bracketTransitionBudget; linarith) + · calc + _ = (m : ℝ) * ((m : ℝ) * (d : ℝ)) := by simp only [Nat.cast_mul] + _ ≤ Real.exp p * (Real.exp p * Real.exp ((p + 2) ^ 9)) := + mul_le_mul hm (mul_le_mul hm hd (Nat.cast_nonneg _) (Real.exp_nonneg _)) + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) (Real.exp_nonneg _) + _ = Real.exp (2 * p + (p + 2) ^ 9) := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by unfold bracketTransitionBudget; linarith) + +theorem exists_bracket_transition_uniform_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → bracketTransitionBudget p ≤ (p + C) ^ C := by + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget + (4 * Polynomial.X + (Polynomial.X + 2) ^ 8 + (Polynomial.X + 2) ^ 9 + 1) + refine ⟨C, hC, fun p hp => ?_⟩ + simpa [bracketTransitionBudget, Polynomial.eval₂_pow] using hbound p hp + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module VectorPolynomial NilpotentLieBCHGroup +open scoped TensorProduct + +variable {L μ κ σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype μ] [Fintype κ] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis μ ℚ L) (w : μ → ℕ) + (hF : ∀ d, F.layer d = Submodule.span ℚ (b '' {i | d ≤ w i})) + {K : Submodule ℚ L} + +include hF in +theorem exists_controlled_bracket_to_current_layer (hs : 2 ≤ s) + (U : LieSubalgebra ℝ (ℝ ⊗[ℚ] L)) (V : Submodule ℝ (ℝ ⊗[ℚ] L)) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) (hV : BasisGradedSubmodule (b.baseChange ℝ) w V) + (e : Basis κ ℚ K) + (hK : ∀ x ∈ K.baseChange ℝ, basisGradeProjection (b.baseChange ℝ) w 1 x = x) + {j H m : ℕ} (hj : 2 ≤ j) (hH : 1 ≤ H) (hm : 0 < m) + (he : ∀ i z, RationalHeightLE (b.repr (e z : L) i) H) + {p : ℝ} (hp : 0 ≤ p) (hambient : (Fintype.card μ : ℝ) ≤ p) + (hkernel : (Fintype.card κ : ℝ) ≤ p) + (hHp : (H : ℝ) ≤ Real.exp p) (hmp : (m : ℝ) ≤ Real.exp p) + (T : σ → ℝ) (hT : ∀ i, 0 < T i) + (P A B : PolynomialGroup σ F.realification.lowerCentralSeries_eq_bot) + (hPU : ∀ α, coefficients P.coord α ∈ U) + (hAU : ∀ α, coefficients A.coord α ∈ U) (hBU : ∀ α, coefficients B.coord α ∈ U) + (hA : ∀ α, basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients A.coord α) = coefficients A.coord α) + (hB : ∀ α, basisGradeProjection (b.baseChange ℝ) w (j - 1) (coefficients B.coord α) = coefficients B.coord α) + (hAhom : ∀ α, Finsupp.weight (fun _ : σ => (1 : ℕ)) α ≠ j - 1 → coefficients A.coord α = 0) + (hBhom : ∀ α, Finsupp.weight (fun _ : σ => (1 : ℕ)) α ≠ j - 1 → coefficients B.coord α = 0) + (hAK : j = 2 → ∀ α, coefficients A.coord α ∈ K.baseChange ℝ) + (hBK : j = 2 → ∀ α, coefficients B.coord α ∈ K.baseChange ℝ) + (hAV : 2 < j → ∀ α, coefficients A.coord α ∈ V) + (hBV : 2 < j → ∀ α, coefficients B.coord α ∈ V) + (hPK : ∀ α, basisGradeProjection (b.baseChange ℝ) w 1 (coefficients P.coord α) ∈ K.baseChange ℝ) + (hlower : ∀ α d, 2 ≤ d → d < j → basisGradeProjection (b.baseChange ℝ) w d (coefficients P.coord α) ∈ V) + (S R : κ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (small rational : σ → VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) (k : σ → κ → ℝ) + (hSR : PolynomialLiftSystemMod (V.restrictScalars ℚ) P S R) + (hsystem : PolynomialDerivativeSystemMod (V.restrictScalars ℚ) P small rational + (fun i => basisPolynomialLift (Pi.basisFun ℝ κ) S (k i))) + (hsmall : ∀ i α, coefficients (small i) α ∈ V ⊔ (F.realLayer j).toSubmodule) + (hrational : ∀ i α, coefficients (rational i) α ∈ V ⊔ (F.realLayer j).toSubmodule) + (hS : ∀ z α, coefficients (dualAdjoint A⁻¹ (S z) - monomial 0 ((1 : ℝ) ⊗ₜ[ℚ] (e z : L))) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) + (hR : ∀ z α, coefficients (dualAdjoint B (R z) - monomial 0 ((1 : ℝ) ⊗ₜ[ℚ] (e z : L))) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) + (hbracket : ∀ z α, ⁅coefficients (A⁻¹ * P * B⁻¹).coord α, (1 : ℝ) ⊗ₜ[ℚ] (e z : L)⁆ ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) + (hAbound : CoefficientBound (b.baseChange ℝ) T (Real.exp p) A.coord) + (hBgrid : CoefficientGrid (b.baseChange ℝ) m B.coord) + (hSbound : ∀ z, CoefficientBound (b.baseChange ℝ) T (Real.exp p) (dualAdjoint A⁻¹ (S z))) + (hRgrid : ∀ z, CoefficientGrid (b.baseChange ℝ) m (dualAdjoint B (R z))) + (hsmallBound : ∀ i, CoefficientBound (b.baseChange ℝ) T (Real.exp p / T i) + (dualAdjoint A⁻¹ (small i - formalLogDerivative i A))) + (hrationalGrid : ∀ i, CoefficientGrid (b.baseChange ℝ) m + (dualAdjoint B (rational i) - formalLogDerivative i B)) + (hSshift : ∀ z, dualAdjoint A⁻¹ (S z) ∈ shiftedGradedPolynomialSubmodule (b.baseChange ℝ) w (fun _ : σ => 1) 1) + (hRshift : ∀ z, dualAdjoint B (R z) ∈ shiftedGradedPolynomialSubmodule (b.baseChange ℝ) w (fun _ : σ => 1) 1) + (hsmallShift : ∀ i, dualAdjoint A⁻¹ (small i - formalLogDerivative i A) ∈ + shiftedGradedPolynomialSubmodule (b.baseChange ℝ) w (fun _ : σ => 1) 1) + (hrationalShift : ∀ i, dualAdjoint B (rational i) - formalLogDerivative i B ∈ + shiftedGradedPolynomialSubmodule (b.baseChange ℝ) w (fun _ : σ => 1) 1) : + let S₀ := basisPolynomialLift (Pi.basisFun ℝ κ) S + let R₀ := basisPolynomialLift (Pi.basisFun ℝ κ) R + let S' := (dualAdjointAddEquiv A⁻¹).toAddMonoidHom.comp S₀.toAddMonoidHom + let R' := (dualAdjointAddEquiv B).toAddMonoidHom.comp R₀.toAddMonoidHom + ∃ (a c : σ → κ → ℝ) (n : ℕ), + 0 < n ∧ (n : ℝ) ≤ Real.exp (bracketTransitionBudget p) ∧ + let P' := A⁻¹ * P * B⁻¹ + let small' := fun i => dualAdjoint A⁻¹ (small i - formalLogDerivative i A) + if j = 2 then S' (a i) else 0 + let rational' := fun i => dualAdjoint B (rational i) - formalLogDerivative i B + if j = 2 then R' (c i) else 0 + let k' := fun i => if j = 2 then k i - a i - c i else k i + let extra' := fun i => S' (k' i) + (∀ α, coefficients P'.coord α ∈ U) ∧ + (∀ α, basisGradeProjection (b.baseChange ℝ) w 1 (coefficients P'.coord α) ∈ K.baseChange ℝ) ∧ + (∀ α d, 2 ≤ d → d < j → basisGradeProjection (b.baseChange ℝ) w d (coefficients P'.coord α) ∈ V) ∧ + PolynomialLiftSystemMod (V.restrictScalars ℚ) P' S' R' ∧ + PolynomialDerivativeSystemMod (V.restrictScalars ℚ) P' small' rational' extra' ∧ + (∀ i α, coefficients (small' i) α ∈ V ⊔ (F.realLayer j).toSubmodule ∧ + coefficients (rational' i) α ∈ V ⊔ (F.realLayer j).toSubmodule) ∧ + (∀ i α, coefficients (extra' i - VectorPolynomial.map + ((basisGradeProjection (b.baseChange ℝ) w 1).restrictScalars ℚ) + ((MvPolynomial.pderiv i).toLinearMap.rTensor (ℝ ⊗[ℚ] L) P'.coord)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) ∧ + (∀ i α, coefficients + ((MvPolynomial.pderiv i).toLinearMap.rTensor (ℝ ⊗[ℚ] L) + (VectorPolynomial.map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) P'.coord) - + VectorPolynomial.map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) (small' i) - + VectorPolynomial.map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) (rational' i)) α ∈ V) ∧ + (∀ α x, x ∈ K.baseChange ℝ → ⁅coefficients P'.coord α, x⁆ ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule) ∧ + (∀ i, CoefficientBound (b.baseChange ℝ) T (Real.exp (bracketTransitionBudget p) / T i) (small' i) ∧ + CoefficientGrid (b.baseChange ℝ) n (rational' i) ∧ + small' i ∈ shiftedGradedPolynomialSubmodule (b.baseChange ℝ) w (fun _ : σ => 1) 1 ∧ + rational' i ∈ shiftedGradedPolynomialSubmodule (b.baseChange ℝ) w (fun _ : σ => 1) 1) ∧ + ∀ z, CoefficientBound (b.baseChange ℝ) T (Real.exp (bracketTransitionBudget p)) (dualAdjoint A⁻¹ (S z)) ∧ + CoefficientGrid (b.baseChange ℝ) n (dualAdjoint B (R z)) := by + classical + intro S₀ R₀ S' R' + let I := bracketSystemLift e + have hchoice : ∃ (a c : σ → κ → ℝ) (d : ℕ), 0 < d ∧ + (d : ℝ) ≤ Real.exp ((p + 2) ^ 9) ∧ + (j = 2 → ∀ i, I (a i) = coefficients A.coord (Finsupp.single i 1) ∧ + I (c i) = coefficients B.coord (Finsupp.single i 1)) ∧ + ∀ i, ‖a i‖ ≤ Real.exp ((p + 2) ^ 8) / T i ∧ c i ∈ realDenominatorGrid d := by + by_cases hj2 : j = 2 + · obtain ⟨a, c, d, hd, hdp, hdirs⟩ := exists_uniform_polynomial_kernel_directions b e hH hm he hp + (Real.exp_nonneg p) hambient hkernel hHp hmp le_rfl A.coord B.coord (hAK hj2) (hBK hj2) + T hT hAbound hBgrid + exact ⟨a, c, d, hd, hdp, fun _ i => ⟨(hdirs i).1, (hdirs i).2.1⟩, + fun i => ⟨(hdirs i).2.2.1, (hdirs i).2.2.2⟩⟩ + · refine ⟨0, 0, 1, by decide, ?_, fun h => (hj2 h).elim, fun i => ?_⟩ + · simpa only [Nat.cast_one] using Real.one_le_exp (by positivity : 0 ≤ (p + 2) ^ 9) + · constructor + · simp only [Pi.zero_apply, norm_zero] + exact div_nonneg (Real.exp_nonneg _) (hT i).le + · exact ⟨0, by ext z; simp⟩ + obtain ⟨a, c, d, hd, hdp, hdirs, hcoordinates⟩ := hchoice + let n := m * (m * d) + have hn : 0 < n := Nat.mul_pos hm (Nat.mul_pos hm hd) + have hmdiv : m ∣ n := dvd_mul_right m (m * d) + obtain ⟨hbase, habsorb, hnbound⟩ := bracket_transition_budget_bounds hp (Fintype.card κ) m d hkernel hmp hdp + refine ⟨a, c, n, hn, hnbound, ?_⟩ + intro P' small' rational' k' extra' + have hI : ∀ x, basisGradeProjection (b.baseChange ℝ) w 1 (I x) = I x := + fun x => hK _ (bracketSystemLift_mem e x) + have hSR₀ : PolynomialLiftSystemMod (V.restrictScalars ℚ) P S₀ R₀ := + hSR.extend_basis (Pi.basisFun ℝ κ) V P S R + have hSall : ∀ x α, coefficients (dualAdjoint A⁻¹ (S₀ x) - monomial 0 (I x)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule := by + apply basisPolynomialLift_adjoint_residual (Pi.basisFun ℝ κ) A⁻¹ S I + (V ⊔ (F.realLayer (j + 1)).toSubmodule) + intro z α + simpa only [I, Pi.basisFun_apply, bracketSystemLift_single] using hS z α + have hRall : ∀ x α, coefficients (dualAdjoint B (R₀ x) - monomial 0 (I x)) α ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule := by + apply basisPolynomialLift_adjoint_residual (Pi.basisFun ℝ κ) B R I + (V ⊔ (F.realLayer (j + 1)).toSubmodule) + intro z α + simpa only [I, Pi.basisFun_apply, bracketSystemLift_single] using hR z α + have hbracketall : ∀ α x, x ∈ K.baseChange ℝ → ⁅coefficients P'.coord α, x⁆ ∈ + V ⊔ (F.realLayer (j + 1)).toSubmodule := by + intro α x hx + obtain ⟨v, rfl⟩ := exists_subspace_basis_coordinates e x hx + apply real_bracket_mem_of_basis (Pi.basisFun ℝ κ) I + (V ⊔ (F.realLayer (j + 1)).toSubmodule) (coefficients P'.coord α) _ v + intro z + simpa only [I, Pi.basisFun_apply, bracketSystemLift_single] using hbracket z α + have hgeometry := F.formal_bracket_to_current_layer b w hF hs U V (K.baseChange ℝ) hUV hV + I.toAddMonoidHom hI hj P A B hPU hAU hBU hA hB hAhom hBhom hAK hBK hAV hBV hPK hlower + S₀.toAddMonoidHom R₀.toAddMonoidHom small rational k a c + (fun h i => (hdirs h i).1) (fun h i => (hdirs h i).2) + hSR₀ hsystem hsmall hrational hSall hRall hbracketall + refine ⟨hgeometry.1, hgeometry.2.1, hgeometry.2.2.1, hgeometry.2.2.2.1, + hgeometry.2.2.2.2.1, hgeometry.2.2.2.2.2.1, hgeometry.2.2.2.2.2.2.1, + hgeometry.2.2.2.2.2.2.2, hbracketall, ?_, ?_⟩ + · intro i + by_cases hj2 : j = 2 + · have ha : ‖(Pi.basisFun ℝ κ).equivFun (a i)‖ ≤ Real.exp ((p + 2) ^ 8) / T i := by + rw [Pi.basisFun_equivFun] + exact (hcoordinates i).1 + have hc : (Pi.basisFun ℝ κ).equivFun (c i) ∈ realDenominatorGrid d := by + rw [Pi.basisFun_equivFun] + exact (hcoordinates i).2 + have hbound := basisPolynomialLift_reabsorption_bound (Pi.basisFun ℝ κ) + (fun z => dualAdjoint A⁻¹ (S z)) (b.baseChange ℝ) T hT (Real.exp p) (Real.exp p) + (Real.exp ((p + 2) ^ 8)) (T i) (Real.exp_nonneg p) hSbound _ (hsmallBound i) (a i) ha + have hgrid := basisPolynomialLift_reabsorption_grid (Pi.basisFun ℝ κ) + (fun z => dualAdjoint B (R z)) (b.baseChange ℝ) d m m hRgrid _ (hrationalGrid i) (c i) hc + have hSsh := basisPolynomialLift_shiftedGraded (Pi.basisFun ℝ κ) + (fun z => dualAdjoint A⁻¹ (S z)) (b.baseChange ℝ) w (fun _ : σ => 1) 1 hSshift (a i) + have hRsh := basisPolynomialLift_shiftedGraded (Pi.basisFun ℝ κ) + (fun z => dualAdjoint B (R z)) (b.baseChange ℝ) w (fun _ : σ => 1) 1 hRshift (c i) + rw [basisPolynomialLift_adjoint (hnil := F.realification.lowerCentralSeries_eq_bot) + (Pi.basisFun ℝ κ) A⁻¹ S] at hbound hSsh + rw [basisPolynomialLift_adjoint (hnil := F.realification.lowerCentralSeries_eq_bot) + (Pi.basisFun ℝ κ) B R] at hgrid hRsh + simp only [small', rational', ite_eq_left hj2] + exact ⟨hbound.mono _ T hT (div_le_div_of_nonneg_right habsorb (hT i).le), hgrid, + (shiftedGradedPolynomialSubmodule _ _ _ _).add_mem (hsmallShift i) hSsh, + (shiftedGradedPolynomialSubmodule _ _ _ _).add_mem (hrationalShift i) hRsh⟩ + · simp only [small', rational', ite_eq_right hj2, add_zero] + exact ⟨(hsmallBound i).mono _ T hT (div_le_div_of_nonneg_right hbase (hT i).le), + fun α => realDenominatorGrid_subset_of_dvd hm hmdiv (hrationalGrid i α), + hsmallShift i, hrationalShift i⟩ + · intro z + exact ⟨(hSbound z).mono _ T hT hbase, + fun α => realDenominatorGrid_subset_of_dvd hm hmdiv (hRgrid z α)⟩ + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CoordinateNiltestSplitting.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CoordinateNiltestSplitting.lean new file mode 100644 index 0000000000000000000000000000000000000000..de396ee076217ee969872ae8ed3f20dc5c0b1dc7 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CoordinateNiltestSplitting.lean @@ -0,0 +1,112 @@ +import OAI.Combinatorics.Progressions.Estimates.TwoDownsetPrecision +import OAI.Combinatorics.Progressions.Geometry.NativeCoordinateSplitFreezing +import OAI.Combinatorics.Progressions.Polynomial.NativeTotalDegreeMultifiltration + +namespace OAI + +section + +namespace Erdos3 + +open Module VectorPolynomial RationalFilteredNilmanifold +open RationalFilteredNilmanifold.MultidegreeStructure +open scoped TensorProduct BigOperators NNReal + +theorem exists_coordinate_niltest_splitting (σ : Type) [Fintype σ] [DecidableEq σ] [Nonempty σ] + (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (i : σ) {L : Type} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} {D : RationalFilteredNilmanifold L s d} {p : ℝ} + (T : D.Niltest (fun _ : σ => 1)), T.ComplexityLE p → T.normBound ≤ 1 → + ∀ epsilon : ℝ, 0 < epsilon → 1 / epsilon ≤ Real.exp ((p + 2) ^ a) → + Nonempty (NativeCoordinateSplit i s d ((p + C) ^ C) epsilon T.eval) := by + obtain ⟨C, hC, hsplit⟩ := exists_two_downset_splitting s (Fintype.card σ * s) a + refine ⟨C, hC, ?_⟩ + intro i L _ _ _ _ _ _ d D p T hT hnorm epsilon hepsilon hscale + classical + let M := D.totalDegreeMultidegree σ hT.1 + let J := coordinateSplitDownset s i + have hJ : ∀ b, IsLowerSet (J b) := coordinateSplitDownset_lower s i + let K := fun b => M.filtration.positivePolynomialAlgebra ⧸ + restrictedOutsideDownsetIdeal M.filtration.positivePolynomialAlgebra (J b) (hJ b) + let : ∀ b, TopologicalSpace (ℝ ⊗[ℚ] K b) := fun _ => moduleTopology ℝ _ + let : ∀ b, IsTopologicalAddGroup (ℝ ⊗[ℚ] K b) := + fun _ => IsModuleTopology.isTopologicalAddGroup ℝ _ + let : ∀ b, T2Space (ℝ ⊗[ℚ] K b) := + fun b => realification_moduleTopology_t2 (M.positivePolynomialDownsetFinBasis (J b) (hJ b) p) + let g := D.filtration.realTotalDegreeOrbit T.orbit + have hsum : (∑ _ : σ, s) = Fintype.card σ * s := by simp + have hM : M.ComplexityLE p := D.totalDegreeMultidegree_complexity σ hT.1 + have hcover : ∀ c, c ≠ 0 → c ∉ J false ∪ J true → + M.filtration.layer (fun j => c j) = ⊥ := + fun c _ hc => coordinateSplitDownset_terminal D.filtration i c hc + obtain ⟨r, _, _, B, hB, hstable, hresult⟩ := + hsplit M J hJ p hsum hM hcover g epsilon hepsilon hscale + obtain ⟨hE, hdim, hterminal, h, _, happrox⟩ := hresult + have hlip : (T.lipBound : ℝ) ≤ Real.exp p := by + have hb := T.observable_budget hT + have hn := T.normBound.coe_nonneg + linarith + have hub : ∀ x, ‖T.observable x‖ ≤ 1 := fun x => + (T.norm_le x).trans (show (T.normBound : ℝ) ≤ 1 from hnorm) + obtain ⟨N, hN, hNbound, A, B', hAnorm, hBnorm, hA, hB', hAg, hBg, herr⟩ := + happrox T.observable T.lipBound hlip T.lipschitz hub + let E := fun b => M.positivePolynomialDownsetModel (J b) (hJ b) r B hB hstable + let F := fun b => M.positivePolynomialDownsetModelMultidegree (J b) (hJ b) r B hB hstable + have hzero (b : Bool) (v : σ → ℕ) (hv : ¬v ≤ coordinateSplitBound s i b) : + (F b).filtration.layer v = ⊥ := by + let c : σ →₀ ℕ := Finsupp.equivFunOnFinite.symm v + exact hterminal b c hv + let R := fun b => (F b).restrictBound (coordinateSplitBound s i b) + (coordinateSplitBound_le s i b) (hzero b) + let tests : ∀ b, Fin N → (E b).Niltest (fun _ : σ => 1) := + fun b => match b with + | false => A + | true => B' + refine ⟨{ + count := N + count_pos := hN + count_bound := hNbound + L := K + dim := fun b => Fintype.card (M.PositivePolynomialDownsetIndex (J b)) + model := E + multi := R + complexity := fun b => (F b).restrictBound_complexity (coordinateSplitBound s i b) + (coordinateSplitBound_le s i b) (hzero b) (hE b) + dimension_bound := hdim + orbit := fun b => (F b).filtration.restrictBoundRealOrbit (coordinateSplitBound s i b) + (hzero b) (M.filtration.positivePolynomialDownsetOrbit (J b) (hJ b) h) + test := tests + test_norm := ?_ + test_complexity := ?_ + test_orbit := ?_ + approximation := ?_ }⟩ + · intro b j + cases b + · exact hAnorm j + · exact hBnorm j + · intro b j + cases b + · exact hA j + · exact hB' j + · intro b j + cases b + · exact hAg j + · exact hBg j + · intro x + change ‖T.eval x - ∑ j, (A j).eval x * (B' j).eval x‖ ≤ epsilon + have heval : T.observable (QuotientGroup.mk (M.filtration.realification.polynomialOrbitEval x g)) = + T.eval x := by + change T.observable (QuotientGroup.mk + ((D.filtration.totalDegreeMultifiltration σ).realification.polynomialOrbitEval x + (D.filtration.realTotalDegreeOrbit T.orbit))) = _ + rw [D.filtration.realTotalDegreeOrbit_eval] + rfl + simpa only [heval] using herr x + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CoveredAnchoredSquareNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CoveredAnchoredSquareNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..60f4381f0b676a355e7398acf9127e3702d99ec8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CoveredAnchoredSquareNiltests.lean @@ -0,0 +1,190 @@ +import OAI.Combinatorics.Progressions.Estimates.AnchoredSquareImagePartition +import OAI.Combinatorics.Progressions.Nilpotent.NativeSquareNiltest + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieFiltration +open scoped TensorProduct + +def CoveredAnchoredSquareNiltestsSpec (s a C : ℕ) : Prop := + ∀ {L : Type} [LieRing L] [LieAlgebra ℚ L] {d m : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) + [TopologicalSpace (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + (b : Basis (Fin m) ℚ L) (v : Fin m → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ v i})) + (M : ℕ) (hM : 0 < M) + (hin : scaledIntegerGrid M ⊆ bchSubgroupCoordinates + (D.filtration.squareFinBasis b v (hF 2)) (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates (D.filtration.squareFinBasis b v (hF 2)) + (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid M), + let V := D.filtration.squareFiltration.ofAdaptedBasis + (D.filtration.squareFinBasis b v (hF 2)) (squareFinWeight v) + (D.filtration.squareFinBasis_layers b v hF) + (D.filtration.squareLattice D.lattice) M hM hin hout + let Q := D.filtration.squareFiltration.topQuotientModel + (D.filtration.squareFinBasis b v (hF 2)) (squareFinWeight v) + (D.filtration.squareFinBasis_layers b v hF) + (D.filtration.squareLattice D.lattice) M hM hin hout + ∀ (Λ : Subgroup Q.filtration.Group) (hΛ : Λ ≤ Q.lattice) (l : ℕ) (hl : 0 < l) + (hlin : scaledIntegerGrid l ⊆ bchSubgroupCoordinates Q.basis Λ) + (hlout : bchSubgroupCoordinates Q.basis Λ ⊆ denominatorGrid l), + let Q' := Q.withLattice Λ l hl hlin hlout + ∀ (T : D.Niltest (fun _ : Unit => 1)) (c : ℤ) (q N : ℕ) [NeZero q] [NeZero N] {p ε : ℝ}, + 2 ≤ p → T.ComplexityLE p → V.GeometryComplexityLE p → Q'.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (D.basis.repr (b i) j) ≤ p) → + (q : ℝ) ≤ Real.exp p → 0 < ε → ε ≤ 1 → 1 / ε ≤ Real.exp ((p + 2) ^ a) → + ∃ δ : ℝ, 0 < δ ∧ δ ≤ ε ∧ 1 / δ ≤ Real.exp ((p + C) ^ C) ∧ + ∃ n k : ℕ, 0 < n ∧ 0 < k ∧ + (Fintype.card ((Fin n × ZMod q) × Fin k) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ A : ((Fin n × ZMod q) × Fin k) → ZMod N → ℝ, + (∀ j, PositiveCyclicNiltest.{0} (s + 1) N ((p + C) ^ C) (A j)) ∧ + (∀ x, ∑ j, A j x = 1) ∧ + (∀ j x, 0 < A j x → (x.val : ZMod q) = j.1.2) ∧ + (∀ j x y, 0 < A j x → 0 < A j y → + dist (ZMod.toAddCircle x) (ZMod.toAddCircle y) ≤ δ) ∧ + (∀ h : ZMod N, ((cyclicWrapExceptional h δ).card : ℝ) / N ≤ 6 * δ + 3 / N) ∧ + letI := Q'.metricSpace + ∀ χ : D.RealGroup → CircleFourier.Circle, + (∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = CircleFourier.character (χ z) * T.observable x) → + ∀ (h : ZMod N) (branch : Fin 2), ∃ S : Q.Niltest (fun _ : Unit => 1), + S.normBound = T.normBound ^ 2 ∧ S.ComplexityLE ((p + C) ^ C) ∧ + (∀ z : Unit → ℤ, S.eval z = + T.eval (z + fun _ => (h.val : ℤ) - (branch.val : ℤ) * N) * + star (T.eval (z + fun _ => c))) ∧ + let S' := S.onSublattice Λ l hl hlin hlout hΛ + S'.ComplexityLE ((p + C) ^ C) ∧ + (∀ z : Unit → ℤ, S'.eval z = S.eval z) ∧ + ∀ i j x y, + x ∉ cyclicWrapExceptional h δ → y ∉ cyclicWrapExceptional h δ → + 0 < A i x * A j (x + h) → 0 < A i y * A j (y + h) → + dist (Q'.cyclicOrbitPoint S'.orbit N (fun _ : Unit => x)) + (Q'.cyclicOrbitPoint S'.orbit N (fun _ : Unit => y)) ≤ ε + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieFiltration NilpotentLieBCHGroup +open scoped TensorProduct + +theorem exists_covered_anchored_square_niltests (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ CoveredAnchoredSquareNiltestsSpec s a C := by + obtain ⟨B, _, hpartition⟩ := exists_anchored_square_image_partition (s + 1) s a + let R : ℕ := Classical.choose (exists_specified_square_niltest.{0, 0} s) + have hconstruct := @(Classical.choose_spec (exists_specified_square_niltest.{0, 0} s)).2 + let X : Polynomial ℕ := Polynomial.X + let P := X + 2 + let U := P + (P + Polynomial.C B) ^ B + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (U + (U + Polynomial.C R) ^ R) + refine ⟨C, hC, ?_⟩ + dsimp only [CoveredAnchoredSquareNiltestsSpec] + intro L _ _ d m _ _ _ _ D _ _ _ _ _ _ _ _ b v hF M hM hin hout + Λ hΛ l hl hlin hlout T c q N _ _ p ε hp hT hV hQ' hb hq hε hε1 hεinv + let bs := D.filtration.squareFinBasis b v (hF 2) + let vs := squareFinWeight v + let hls := D.filtration.squareFinBasis_layers b v hF + let V := D.filtration.squareFiltration.ofAdaptedBasis bs vs hls + (D.filtration.squareLattice D.lattice) M hM hin hout + let Q := D.filtration.squareFiltration.topQuotientModel bs vs hls + (D.filtration.squareLattice D.lattice) M hM hin hout + let Q' := Q.withLattice Λ l hl hlin hlout + let φ := lieQuotientMap (D.filtration.squareFiltration.layerIdeal (s + 1)) + have hp0 : 0 ≤ p := by linarith + let r := p + 2 + have hpr : p ≤ r := by dsimp [r]; linarith + have hr : 0 ≤ r := hp0.trans hpr + have hpair : ∀ i j, rationalLogHeight ((pi (fun _ : Bool => D)).basis.repr + (D.filtration.squarePairMap (V.basis j)) i) ≤ r := by + intro i j + exact (D.squarePairMap_matrix_logHeight b v (hF 2) hp0 (fun i j => hb j i) i j).trans + (by dsimp [r]; linarith) + have hφ : ∀ i j, rationalLogHeight (Q'.basis.repr (φ (V.basis j)) i) ≤ r := by + intro i j + apply rationalLogHeight_le_of_height + (quotientFinBasis_projection_height bs (D.filtration.squareFiltration.layerIdeal (s + 1)) + {i | s + 1 ≤ vs i} (hls (s + 1)) j i) + simpa only [Nat.cast_one] using Real.one_le_exp hr + obtain ⟨δ, hδ, hδε, hδinv, n, k, hn, hk, hcount, A, hA, hsum, hres, hcircle, + hexception, hblocks⟩ := + hpartition D V Q' φ T.orbit c q N (by omega) (hp.trans hpr) + (hT.1.mono D hpr) (hV.mono V hpr) (hQ'.mono Q' hpr) hpair hφ + (hq.trans (Real.exp_le_exp.mpr hpr)) hε hε1 + (hεinv.trans (Real.exp_le_exp.mpr + (pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ p + 2) + (by linarith : p + 2 ≤ r + 2) a))) + let u := r + (r + B) ^ B + have hru : r ≤ u := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have hu : 0 ≤ u := hr.trans hru + have hBu : (r + B) ^ B ≤ u := le_add_of_nonneg_left hr + have htotal : u + (u + R) ^ R ≤ (p + C) ^ C := by + simpa [X, P, U, r, u, Polynomial.eval₂_pow] using hbudget p hp0 + have huC : u ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (by positivity) _)).trans htotal + have hBC : (r + B) ^ B ≤ (p + C) ^ C := hBu.trans huC + have hRC : (u + R) ^ R ≤ (p + C) ^ C := (le_add_of_nonneg_left hu).trans htotal + have hpu : p ≤ u := hpr.trans hru + refine ⟨δ, hδ, hδε, hδinv.trans (Real.exp_le_exp.mpr hBC), n, k, hn, hk, + hcount.trans (Real.exp_le_exp.mpr hBC), A, fun j => (hA j).mono le_rfl hBC, + hsum, hres, hcircle, hexception, ?_⟩ + let := Q'.metricSpace + intro χ hvert h branch + obtain ⟨η, γ, rSq, hγ, hη, hnorm, hcell⟩ := hblocks h branch + obtain ⟨S, horbit, _, hSNorm, hSComplexity, hSval⟩ := + hconstruct D b v hF M hM hin hout T hu (hT.mono hpu) (hV.mono V hpu) + (fun i j => (hb i j).trans hpu) η + (fun i => (hη i).trans (Real.exp_le_exp.mpr hBu)) rSq χ hvert + have hSC : S.ComplexityLE ((p + C) ^ C) := hSComplexity.mono hRC + refine ⟨S, hSNorm, hSC, ?_, + S.onSublattice_complexity Λ l hl hlin hlout hΛ hSC (hQ'.mono Q' (hpu.trans huC)), + S.onSublattice_eval Λ l hl hlin hlout hΛ, ?_⟩ + · intro z + exact (hSval z).trans (D.filtration.realSquareObservable_recovers_product D.lattice η γ + (D.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (z + fun _ => (h.val : ℤ) - (branch.val : ℤ) * N) T.orbit) + (D.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (z + fun _ => c) T.orbit) hγ T.observable + (D.filtration.squareFiltration.realification.polynomialOrbitEval + (fun _ : Unit => 1) z rSq) (hnorm z).1 (hnorm z).2) + · intro i j x y hx hy hxy hyy + have hpoint (z : ZMod N) : + Q'.cyclicOrbitPoint (S.onSublattice Λ l hl hlin hlout hΛ).orbit N (fun _ : Unit => z) = + QuotientGroup.mk (realificationMap + (hnil := D.filtration.squareFiltration.lowerCentralSeries_eq_bot) + (hM := Q'.filtration.lowerCentralSeries_eq_bot) φ + (D.filtration.squareFiltration.realification.polynomialOrbitEval + (fun _ : Unit => 1) (fun _ => (z.val : ℤ)) rSq)) := by + apply (congrArg (fun g => Q'.cyclicOrbitPoint g N (fun _ : Unit => z)) horbit).trans + exact congrArg (fun g : Q'.RealGroup => (QuotientGroup.mk g : Q'.Space)) + (D.filtration.squareFiltration.realQuotientPolynomialOrbit_eval + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl rSq + (fun _ : Unit => (z.val : ℤ))) + exact (congrArg₂ (fun u v : Q'.Space => dist u v) (hpoint x) (hpoint y)).trans_le + (hcell i j x y hx hy hxy hyy) + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CubicPairNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CubicPairNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..966d32b5f9cc877f9fe8aefa362d995045bd95fb --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CubicPairNiltest.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Estimates.CubicRootPermutation + +namespace OAI + +section + +namespace Erdos3.NativeSampleCorrelation + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +variable {p q : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (fun _ : CubicReplicatedIndex => 1) p} + {i j : Fin W.outputDim × Fin W.outputDim} {shift : ℤ} + (V : NativeSampleCorrelation (fun _ : Fin 3 => 1) 2 q + Finset.univ (fun z : Fin 3 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.cubicAntisymmetricPair i j (z 1).val (z 2).val (((z 0).val : ℤ) + shift))) + [TopologicalSpace (ℝ ⊗[ℚ] V.CubicPairAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V.CubicPairAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V.CubicPairAlgebra)] + [T2Space (ℝ ⊗[ℚ] V.CubicPairAlgebra)] + +noncomputable def cubicPairNiltest : (pi V.cubicPairModels).Niltest (fun _ : Fin 3 => 1) := + piNiltest V.cubicPairModels V.cubicPairTests + ((by norm_num : (0 : ℝ) ≤ 6).trans V.cubicPairBudget_six_le) + (by simpa using (show (3 : ℝ) ≤ cubicPairBudget p q from + (by norm_num : (3 : ℝ) ≤ 6).trans V.cubicPairBudget_six_le)) + V.cubicPairTests_complexity + +theorem cubicPairNiltest_complexity : + V.cubicPairNiltest.ComplexityLE (productNiltestBudget (cubicPairBudget p q)) := + piNiltest_complexity V.cubicPairModels V.cubicPairTests _ _ _ + +theorem cubicPairNiltest_eval (n : Fin 3 → ℤ) : + V.cubicPairNiltest.eval n = + W.cubicAntisymmetricPair i j (n 1) (n 2) (n 0 + shift) * star (V.test.eval n) := by + rw [cubicPairNiltest, piNiltest_eval] + exact V.cubicPairTests_eval n + +theorem cubicPairNiltest_vertical (z : (pi V.cubicPairModels).RealGroup) + (hz : z ∈ (pi V.cubicPairModels).filtration.realification.subgroup (∑ _ : CubicReplicatedIndex, 1)) + (x : (pi V.cubicPairModels).Space) : + V.cubicPairNiltest.observable (z • x) = + CircleFourier.character + ((realifyFunctional (piFrequency V.cubicPairFrequencies) z.coord : ℝ) : CircleFourier.Circle) * + V.cubicPairNiltest.observable x := + piNiltest_vertical V.cubicPairModels V.cubicPairTests V.cubicPairFrequencies _ _ _ + V.cubicPairTests_vertical z hz x + +theorem cubicPairNiltest_bias : + Real.exp (-q) ≤ ‖𝔼 n ∈ integerBox (fun _ : Fin 3 => N), V.cubicPairNiltest.eval n‖ := by + rw [integerBox_expect_eq_zmod] + simp_rw [V.cubicPairNiltest_eval] + exact V.correlation + +end Erdos3.NativeSampleCorrelation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CubicPrimitiveNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CubicPrimitiveNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1269b782627cdc1de0233099ff89c5a0f98048c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CubicPrimitiveNiltest.lean @@ -0,0 +1,108 @@ +import OAI.Combinatorics.Progressions.Estimates.CubicPrimitiveGowers + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeCyclicModel.lie NativeCyclicModel.algebra NativeCyclicModel.topology + NativeCyclicModel.topologicalAdd NativeCyclicModel.continuousSMul NativeCyclicModel.hausdorff + +theorem exists_cubic_diagonal_niltest {p : ℝ} + (W : NativeMultidegreeNilcharacter (fun _ : CubicReplicatedIndex => 1) p) (i : Fin W.outputDim) : + ∃ T : W.model.Niltest (fun _ : Unit => 1), T.normBound = 1 ∧ T.ComplexityLE (p + 4) ∧ + ∀ n : ℤ, T.eval (fun _ => n) = W.eval i (fun _ => n) := by + obtain ⟨T, hT, hcomplexity, heval⟩ := W.exists_linear_niltest i + (fun _ => { toFun := fun x : Unit → ℤ => x (), map_zero' := rfl, map_add' := fun _ _ => rfl }) + exact ⟨T, hT, hcomplexity, fun n => heval (fun _ => n)⟩ + +theorem exists_cubic_primitive_niltest_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + ∀ W : NativeMultidegreeNilcharacter (fun _ : CubicReplicatedIndex => 1) p, + ∀ i : Fin W.outputDim, ∀ g ∈ nativeCyclicFunctions 2 N p, + (fun n : ZMod N => star (W.eval i (fun _ => (n.val : ℤ))) * g n) ∈ + nativeCyclicFunctions 3 N ((p + C) ^ C) := by + obtain ⟨A, _, hproduct⟩ := exists_productNiltestBudget_bound + let X : Polynomial ℕ := Polynomial.X + let R := 2 * X + (X + 2) ^ 2 + 7 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((R + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro N _ p hp W i g ⟨G⟩ + have hdegree : (∑ _ : CubicReplicatedIndex, (1 : ℕ)) = 3 := by + have hc : Fintype.card CubicReplicatedIndex = 3 := by + calc + _ = ∑ j : Fin 2, mixedCorrelationDegree 2 j := replicatedIndex_card _ + _ = 3 := by rw [Fin.sum_univ_two]; rfl + simpa using hc + have hraise : 2 ≤ ∑ _ : CubicReplicatedIndex, (1 : ℕ) := by omega + obtain ⟨T, hTnorm, hT, hTeval⟩ := W.exists_cubic_diagonal_niltest i + let r := 2 * p + (p + 2) ^ 2 + 7 + have hr : 0 ≤ r := by dsimp [r]; positivity + have hpr : p + 4 ≤ r := by dsimp [r]; nlinarith [sq_nonneg (p + 2)] + have hGr : raisedNiltestBudget p ≤ r := by dsimp [raisedNiltestBudget, r]; linarith + let K : Bool → Type := BoolLieFamily W.L G.L + let dims : Bool → ℕ := fun b => Bool.rec G.dim W.dim b + let models : ∀ b, RationalFilteredNilmanifold (K b) (∑ _ : CubicReplicatedIndex, 1) (dims b) := fun b => by + cases b + · exact G.model.raiseStep hraise + · exact W.model + let tests : ∀ b, (models b).Niltest (fun _ : Unit => 1) := fun b => by + cases b + · exact G.test.raiseStep hraise + · exact T.conjugate + have htests : ∀ b, (tests b).ComplexityLE r := by + intro b + cases b + · exact (G.test.raiseStep_complexity hraise hp G.complexity).mono hGr + · exact hT.mono hpr + have hcap : ∀ b, (tests b).normBound ≤ 1 := by + intro b + cases b + · exact G.norm + · exact hTnorm.le + have hcard : (Fintype.card Bool : ℝ) ≤ r := by + simp only [Fintype.card_bool, Nat.cast_ofNat] + linarith + let : FiniteDimensional ℚ (∀ b, K b) := + (RationalFilteredNilmanifold.productFinBasis models).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ b, K b)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ b, K b)) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (∀ b, K b)) := + realification_moduleTopology_t2 (RationalFilteredNilmanifold.productFinBasis models) + let S := RationalFilteredNilmanifold.unitBoundedPiNiltest models tests hr hcard htests hcap + have hcost : productNiltestBudget r ≤ (p + C) ^ C := by + apply (hproduct r hr).trans + simpa [X, R, r, Polynomial.eval₂_pow] using hbudget p hp + have H : Nonempty (NativeCyclicModel (∑ _ : CubicReplicatedIndex, 1) N ((p + C) ^ C) + (fun n : ZMod N => star (W.eval i (fun _ => (n.val : ℤ))) * g n)) := by + refine ⟨{ + L := ∀ b, K b + dim := _ + model := RationalFilteredNilmanifold.pi models + test := S + norm := le_rfl + complexity := (RationalFilteredNilmanifold.unitBoundedPiNiltest_complexity + models tests hr hcard htests hcap).mono hcost + eval := ?_ }⟩ + intro n + change _ = S.eval (fun _ => (n.val : ℤ)) + rw [RationalFilteredNilmanifold.unitBoundedPiNiltest_eval, Fintype.prod_bool] + change _ = star (T.eval (fun _ => (n.val : ℤ))) * + (G.test.raiseStep hraise).eval (fun _ => (n.val : ℤ)) + rw [hTeval, RationalFilteredNilmanifold.Niltest.raiseStep_eval, G.eval n] + rfl + change Nonempty (NativeCyclicModel 3 N ((p + C) ^ C) _) + simpa only [hdegree] using H + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CurrentBracketInductionStep.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CurrentBracketInductionStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..daf3ddfb6b2a983c3f1adaa1f2bc7437dc49b2e0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CurrentBracketInductionStep.lean @@ -0,0 +1,294 @@ +import OAI.Combinatorics.Progressions.Estimates.CurrentLayerPreservation + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +section General + +variable {R L ι : Type*} [Field R] [LieRing L] [LieAlgebra R L] + +def BasisHomogeneousBrackets (b : Basis ι R L) (w : ι → ℕ) : Prop := + ∀ i j k, w k ≠ w i + w j → b.repr ⁅b i, b j⁆ k = 0 + +theorem BasisHomogeneousBrackets.lie_mem_span (b : Basis ι R L) (w : ι → ℕ) + (hb : BasisHomogeneousBrackets b w) {i j : ℕ} {x y : L} + (hx : x ∈ Submodule.span R (b '' {k | w k = i})) + (hy : y ∈ Submodule.span R (b '' {k | w k = j})) : + ⁅x, y⁆ ∈ Submodule.span R (b '' {k | w k = i + j}) := by + induction hx, hy using Submodule.span_induction₂ with + | mem_mem x y hx hy => + obtain ⟨a, ha, rfl⟩ := hx + obtain ⟨c, hc, rfl⟩ := hy + change w a = i at ha + change w c = j at hc + apply (basis_mem_span_image_iff b _ _).mpr + intro k hk + change w k ≠ i + j at hk + exact hb a c k (by simpa only [ha, hc] using hk) + | zero_left y _ => rw [zero_lie]; exact Submodule.zero_mem _ + | zero_right x _ => rw [lie_zero]; exact Submodule.zero_mem _ + | add_left x y z _ _ _ hx hy => rw [add_lie]; exact Submodule.add_mem _ hx hy + | add_right x y z _ _ _ hx hy => rw [lie_add]; exact Submodule.add_mem _ hx hy + | smul_left r x y _ _ h => rw [smul_lie]; exact Submodule.smul_mem _ r h + | smul_right r x y _ _ h => rw [lie_smul]; exact Submodule.smul_mem _ r h + +theorem BasisHomogeneousBrackets.projection_lie (b : Basis ι R L) (w : ι → ℕ) + (hb : BasisHomogeneousBrackets b w) {i j : ℕ} {x y : L} + (hx : basisGradeProjection b w i x = x) (hy : basisGradeProjection b w j y = y) : + basisGradeProjection b w (i + j) ⁅x, y⁆ = ⁅x, y⁆ := by + apply basisCoordinateProjection_eq_self + apply hb.lie_mem_span b w + · rw [← hx] + exact basisCoordinateProjection_mem_span b _ _ + · rw [← hy] + exact basisCoordinateProjection_mem_span b _ _ + +end General + +theorem BasisHomogeneousBrackets.baseChange {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] + (b : Basis ι ℚ L) (w : ι → ℕ) (hb : BasisHomogeneousBrackets b w) : + BasisHomogeneousBrackets (b.baseChange ℝ) w := by + intro i j k hk + rw [Basis.baseChange_apply, Basis.baseChange_apply, + LieAlgebra.ExtendScalars.bracket_tmul, one_mul, Basis.baseChange_repr_tmul, hb i j k hk] + exact zero_smul ℚ (1 : ℝ) + +namespace NilpotentLieFiltration + +variable {L ι : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) + +theorem associatedGradedBasis_homogeneous_brackets : + BasisHomogeneousBrackets (F.associatedGradedBasis b w hlayers) w := by + intro i j k hk + rw [F.associatedGradedBasis_bracket b w hlayers, ite_eq_right (Ne.symm hk)] + +theorem realAssociatedGradedBasis_homogeneous_brackets : + BasisHomogeneousBrackets ((F.associatedGradedBasis b w hlayers).baseChange ℝ) w := + (F.associatedGradedBasis_homogeneous_brackets b w hlayers).baseChange _ _ + +end NilpotentLieFiltration +end Erdos3 + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module + +variable {σ : Type*} [Fintype σ] + +@[simp] theorem weightedBasis_inl_base [DecidableEq σ] (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (i : σ) : (weightedBasis w d hw (Sum.inl i)).val.base = Pi.single i 1 := by + classical + unfold weightedBasis + erw [Basis.map_apply] + rw [Basis.prod_apply] + simp [weightedCoordinatesEquiv] + rfl + +@[simp] theorem weightedBasis_inl_polynomial (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (i : σ) : + (weightedBasis w d hw (Sum.inl i)).val.polynomial = 0 := by + unfold weightedBasis + erw [Basis.map_apply] + rw [Basis.prod_apply] + simp [weightedCoordinatesEquiv] + rfl + +@[simp] theorem weightedBasis_inr_base (w : σ → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (a : {a : σ →₀ ℕ | Finsupp.weight w a < d}) : + (weightedBasis w d hw (Sum.inr a)).val.base = 0 := by + unfold weightedBasis + erw [Basis.map_apply] + rw [Basis.prod_apply] + simp [weightedCoordinatesEquiv] + rfl + +@[simp] theorem weightedBasis_inr_polynomial (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) (a : {a : σ →₀ ℕ | Finsupp.weight w a < d}) : + (weightedBasis w d hw (Sum.inr a)).val.polynomial = monomial a.val 1 := by + classical + apply MvPolynomial.ext + intro t + by_cases ht : Finsupp.weight w t < d + · rw [← weightedBasis_repr_inr w d hw _ ⟨t, ht⟩] + simp [Basis.repr_self, Finsupp.single_apply, coeff_monomial, Subtype.ext_iff] + · have hcoeff : (weightedBasis w d hw (Sum.inr a)).val.polynomial.coeff t = 0 := by + by_contra hn + have hh := (weightedBasis w d hw (Sum.inr a)).property.2 (mem_support_iff.mpr hn) + change Finsupp.weight w t + 1 ≤ d at hh + omega + rw [hcoeff, coeff_monomial] + have hne : a.val ≠ t := by + intro he + exact ht (he ▸ a.property) + simp [hne] + +private theorem single_direction_derivative [DecidableEq σ] (i : σ) + (P : MvPolynomial σ ℚ) : scalarDirectionalDerivative (Pi.single i 1) P = pderiv i P := by + classical + simp [scalarDirectionalDerivative_apply, Pi.single_apply] + +omit [Fintype σ] in +private theorem coeff_pderiv_monomial_grade (w : σ → ℕ) (d : ℕ) + (i : σ) (a c : {a : σ →₀ ℕ | Finsupp.weight w a < d}) + (h : d - Finsupp.weight w c.val ≠ w i + (d - Finsupp.weight w a.val)) : + (pderiv i (monomial a.val (1 : ℚ))).coeff c.val = 0 := by + classical + have hne : a.val ≠ c.val + Finsupp.single i 1 := by + intro he + have hh := congrArg (Finsupp.weight w) he + simp only [map_add, Finsupp.weight_single, one_smul] at hh + have ha : Finsupp.weight w a.val < d := a.property + have hc : Finsupp.weight w c.val < d := c.property + omega + rw [coeff_pderiv, coeff_monomial, ite_eq_right hne, zero_mul] + +theorem weightedBasis_homogeneous_brackets (w : σ → ℕ) (d : ℕ) + (hw : ∀ i, 0 < w i) : + BasisHomogeneousBrackets (weightedBasis w d hw) (weightedBasisGrade w d) := by + classical + intro i j k hk + cases k with + | inl k => + rw [weightedBasis_repr_inl] + rfl + | inr c => + rw [weightedBasis_repr_inr] + change (scalarDirectionalDerivative (weightedBasis w d hw i).val.base + (weightedBasis w d hw j).val.polynomial - + scalarDirectionalDerivative (weightedBasis w d hw j).val.base + (weightedBasis w d hw i).val.polynomial).coeff c.val = 0 + cases i with + | inl i => + cases j with + | inl j => simp + | inr a => + simp only [weightedBasis_inl_base, weightedBasis_inr_polynomial, + weightedBasis_inr_base, weightedBasis_inl_polynomial, + scalarDirectionalDerivative_direction_zero, sub_zero, + single_direction_derivative] + exact coeff_pderiv_monomial_grade w d i a c hk + | inr a => + cases j with + | inl i => + simp only [weightedBasis_inl_base, weightedBasis_inr_polynomial, + weightedBasis_inr_base, weightedBasis_inl_polynomial, + scalarDirectionalDerivative_direction_zero, zero_sub, + single_direction_derivative, coeff_neg, neg_eq_zero] + exact coeff_pderiv_monomial_grade w d i a c (by + simpa only [weightedBasisGrade_inl, weightedBasisGrade_inr, Nat.add_comm] using hk) + | inr b => simp + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +variable {ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) + +include hlayers in +theorem real_bracket_induction_step (hgraded : BasisHomogeneousBrackets b w) (hs : 2 ≤ s) + (U : LieSubalgebra ℚ (ℝ ⊗[ℚ] L)) (V K : Submodule ℝ (ℝ ⊗[ℚ] L)) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + (hV : BasisGradedSubmodule (b.baseChange ℝ) w V) + (hK : ∀ k ∈ K, basisGradeProjection (b.baseChange ℝ) w 1 k = k) + {j : ℕ} (hj : 2 ≤ j) (g a c : F.realification.Group) + (hg : g.coord ∈ U) (haU : a.coord ∈ U) (hcU : c.coord ∈ U) + (ha : basisGradeProjection (b.baseChange ℝ) w (j - 1) a.coord = a.coord) + (hc : basisGradeProjection (b.baseChange ℝ) w (j - 1) c.coord = c.coord) + (S R : K → ℝ ⊗[ℚ] L) (hSR : ∀ k, S k = dualAdjoint g (R k)) + (hR : ∀ k, R k - k.val ∈ V ⊔ (F.realLayer j).toSubmodule) + (hlower : ∀ d < j - 1, ∀ k : K, + ⁅basisGradeProjection (b.baseChange ℝ) w d g.coord, k.val⁆ ∈ V) + (hleft : ∀ k, S k - k.val - ⁅a.coord, k.val⁆ ∈ V ⊔ (F.realLayer (j + 1)).toSubmodule) + (hright : ∀ k, R k - k.val + ⁅c.coord, k.val⁆ ∈ V ⊔ (F.realLayer (j + 1)).toSubmodule) : + let g' := a⁻¹ * g * c⁻¹ + let S' := fun k => dualAdjoint a⁻¹ (S k) + let R' := fun k => dualAdjoint c (R k) + a * g' * c = g ∧ g'.coord ∈ U ∧ + (∀ d < j - 1, basisGradeProjection (b.baseChange ℝ) w d g'.coord = + basisGradeProjection (b.baseChange ℝ) w d g.coord) ∧ + (∀ d < j, ∀ k : K, ⁅basisGradeProjection (b.baseChange ℝ) w d g'.coord, k.val⁆ ∈ V) ∧ + (∀ k, S' k = dualAdjoint g' (R' k)) ∧ + ∀ k, S' k - k.val ∈ V ⊔ (F.realLayer (j + 1)).toSubmodule ∧ + R' k - k.val ∈ V ⊔ (F.realLayer (j + 1)).toSubmodule ∧ + ⁅g'.coord, k.val⁆ ∈ V ⊔ (F.realLayer (j + 1)).toSubmodule := by + intro g' S' R' + have hW (d : ℕ) (x : ℝ ⊗[ℚ] L) : + x ∈ V.restrictScalars ℚ ⊔ F.realification.layer d ↔ + x ∈ V ⊔ (F.realLayer d).toSubmodule := by + change x ∈ V.restrictScalars ℚ ⊔ (F.realLayer d).toSubmodule.restrictScalars ℚ ↔ _ + rw [← Submodule.restrictScalars_sup] + rfl + let p := basisGradeProjection (b.baseChange ℝ) w (j - 1) g.coord + have hstep : j - 1 + 2 = j + 1 := by omega + have hp : p ∈ F.realification.layer (j - 1) := + F.realGradeProjection_mem_layer b w hlayers (j - 1) g.coord + have hal : a.coord ∈ F.realification.layer (j - 1) := by + simpa only [ha] using F.realGradeProjection_mem_layer b w hlayers (j - 1) a.coord + have hcl : c.coord ∈ F.realification.layer (j - 1) := by + simpa only [hc] using F.realGradeProjection_mem_layer b w hlayers (j - 1) c.coord + have hkl (k : K) : k.val ∈ F.realification.layer 1 := by + rw [F.realification.one_eq_top] + trivial + have hrem (k : K) : ⁅g.coord - p, k.val⁆ ∈ V ⊔ (F.realLayer (j + 1)).toSubmodule := by + have h := F.real_current_bracket_remainder b w hlayers V (j - 1) g.coord k.val (hkl k) + (fun d hd => hlower d hd k) + simpa only [hstep] using h + have hnorm := F.realification.current_layer_normalization hs U (V.restrictScalars ℚ) + hUV hj g a c hg haU hcU hal hcl S R (fun k => k.val) p hp hSR + (fun k => (hW j _).mpr (hR k)) (fun k => (hW (j + 1) _).mpr (hrem k)) + (fun k => (hW (j + 1) _).mpr (hleft k)) (fun k => (hW (j + 1) _).mpr (hright k)) + obtain ⟨hprod, hg', _, _, hSR', hcurrent⟩ := hnorm + have hbelow := F.real_correction_preserves_grades_below b w hlayers (j - 1) a g c hal hcl + have hgrade : basisGradeProjection (b.baseChange ℝ) w (j - 1) g'.coord = p - a.coord - c.coord := by + have h := F.real_correction_current_grade b w hlayers (j - 1) a g c hal hcl + simpa only [ha, hc] using h + have hcur (k : K) : ⁅basisGradeProjection (b.baseChange ℝ) w (j - 1) g'.coord, k.val⁆ ∈ V := by + apply F.real_mem_of_homogeneous_mem_sup_next b w hlayers V hV j + · have h := (hgraded.baseChange b w).projection_lie (b.baseChange ℝ) w + (basisCoordinateProjection_idempotent (b.baseChange ℝ) {i | w i = j - 1} g'.coord) + (hK k.val k.property) + simp only [Nat.sub_add_cancel (by omega : 1 ≤ j)] at h + exact h + · rw [hgrade] + exact (hW (j + 1) _).mp (hcurrent k).2.2 + have hall (d : ℕ) (hd : d < j) (k : K) : + ⁅basisGradeProjection (b.baseChange ℝ) w d g'.coord, k.val⁆ ∈ V := by + rcases lt_or_eq_of_le (show d ≤ j - 1 by omega) with hlt | rfl + · rw [hbelow d hlt] + exact hlower d hlt k + · exact hcur k + refine ⟨hprod, hg', hbelow, hall, hSR', fun k => + ⟨(hW (j + 1) _).mp (hcurrent k).1, (hW (j + 1) _).mp (hcurrent k).2.1, ?_⟩⟩ + have hrem' := F.real_current_bracket_remainder b w hlayers V (j - 1) g'.coord k.val (hkl k) + (fun d hd => hall d (by omega) k) + rw [hstep] at hrem' + have h := (V ⊔ (F.realLayer (j + 1)).toSubmodule).add_mem hrem' + (Submodule.mem_sup_left (hcur k)) + simpa only [sub_lie, sub_add_cancel] using h + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicNiltestApproximation.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicNiltestApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f967ff323e94e59787e79721bc151a767f6e673 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicNiltestApproximation.lean @@ -0,0 +1,733 @@ +import OAI.Combinatorics.Progressions.Estimates.ProductOrbitCongruence +import OAI.Combinatorics.Progressions.Estimates.RealificationModuleTopology +import OAI.Combinatorics.Progressions.Fourier.ProductFrequencyKernel +import OAI.Combinatorics.Progressions.Linear.TripleProductBasisBounds +import OAI.Combinatorics.Progressions.Nilpotent.CellwiseNiltestDiscretization + +namespace OAI + +section + +open scoped NNReal + +namespace Erdos3 + +noncomputable def productExpBound (p : ℝ) : ℝ≥0 := ⟨Real.exp p, Real.exp_nonneg p⟩ + +@[simp] theorem coe_productExpBound (p : ℝ) : (productExpBound p : ℝ) = Real.exp p := rfl + +def productObservableLipBudget (p : ℝ) : ℝ := p + (p ^ 2 + p + 3) ^ 2 + +def productNiltestBudget (p : ℝ) : ℝ := + (p + 2) ^ 2 + p + productObservableLipBudget p + p ^ 2 + 4 + +theorem productObservableLipBudget_nonneg {p : ℝ} (hp : 0 ≤ p) : + 0 ≤ productObservableLipBudget p := by + unfold productObservableLipBudget + positivity + +theorem productNiltestBudget_geometry {p : ℝ} (hp : 0 ≤ p) : + (p + 2) ^ 2 ≤ productNiltestBudget p := by + have hr := productObservableLipBudget_nonneg hp + unfold productNiltestBudget + nlinarith [sq_nonneg p] + +theorem productNiltestBudget_observable {p : ℝ} (hp : 0 ≤ p) (m : ℕ) (hm : (m : ℝ) ≤ p) : + 2 + Real.exp p ^ m + (m : ℝ) * Real.exp (productObservableLipBudget p) * Real.exp p ^ m ≤ + Real.exp (productNiltestBudget p) := by + let A := p + productObservableLipBudget p + p ^ 2 + have hR := productObservableLipBudget_nonneg hp + have hA : 0 ≤ A := by dsimp [A]; positivity + have hB : Real.exp p ^ m ≤ Real.exp (p ^ 2) := by + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + nlinarith + have hmexp : (m : ℝ) ≤ Real.exp p := hm.trans (by linarith [Real.add_one_le_exp p]) + have hB' : Real.exp p ^ m ≤ Real.exp A := hB.trans (Real.exp_le_exp.mpr (by dsimp [A]; linarith)) + have hK : (m : ℝ) * Real.exp (productObservableLipBudget p) * Real.exp p ^ m ≤ Real.exp A := by + calc + _ ≤ Real.exp p * Real.exp (productObservableLipBudget p) * Real.exp (p ^ 2) := by gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add] + have hfour : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + calc + _ ≤ 4 * Real.exp A := by linarith [Real.one_le_exp_iff.mpr hA] + _ ≤ Real.exp 4 * Real.exp A := mul_le_mul_of_nonneg_right hfour (Real.exp_nonneg _) + _ = Real.exp (4 + A) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by unfold productNiltestBudget; dsimp [A]; nlinarith [sq_nonneg (p + 2)]) + +theorem exists_productNiltestBudget_bound : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → productNiltestBudget p ≤ (p + C) ^ C := by + let X : Polynomial ℕ := Polynomial.X + let P := (X + 2) ^ 2 + X + (X + (X ^ 2 + X + 3) ^ 2) + X ^ 2 + 4 + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, fun p hp => ?_⟩ + simpa [P, X, Polynomial.eval₂_pow, productNiltestBudget, productObservableLipBudget] using hbound p hp + +end Erdos3 + +end + +section + +open Module +open scoped BigOperators + +namespace Erdos3.RationalFilteredNilmanifold + +variable {ι : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + +theorem productLayerBasis_logHeight {p : ℝ} (hp : 0 ≤ p) + (hD : ∀ i, (D i).GeometryComplexityLE p) (j : Fin (s + 1)) + (k : Σ i, Fin (finrank ℚ ((D i).filtration.layer (j.val + 1)))) (l : Σ i, Fin (d i)) : + rationalLogHeight ((Pi.basis (fun i => (D i).basis)).repr ((productLayerBasis D j k).val) l) ≤ p := by + classical + rcases k with ⟨a, k⟩ + rcases l with ⟨b, l⟩ + simp only [productLayerBasis, Basis.map_apply, Pi.basis_repr] + change rationalLogHeight ((D b).basis.repr + (((Pi.basis (fun i => (D i).layerBasis j)) ⟨a, k⟩ b).val) l) ≤ p + rw [Pi.basis_apply] + by_cases hab : a = b + · subst b + rw [Pi.single_eq_same] + exact (hD a).2.2.2 j k l + · rw [Pi.single_eq_of_ne (Ne.symm hab)] + simpa [rationalLogHeight] using hp + +theorem pi_geometry {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hD : ∀ i, (D i).GeometryComplexityLE p) : + (pi D).GeometryComplexityLE ((p + 2) ^ 2) := by + classical + have hdim : (Fintype.card (Σ i, Fin (d i)) : ℝ) ≤ p ^ 2 := + sigma_card_le_budget hp hι (fun i => by simpa only [Fintype.card_fin] using (hD i).1) + have hgrid : ((∏ i, (D i).grid : ℕ) : ℝ) ≤ Real.exp (p ^ 2) := + product_denominator_le_budget (fun i => (D i).grid) hp hι (fun i => (hD i).2.1) + have hsmall : p + 1 ≤ (p + 2) ^ 2 := by nlinarith [sq_nonneg p] + have hsq : p ^ 2 ≤ (p + 2) ^ 2 := by nlinarith + refine ⟨hdim.trans hsq, hgrid.trans (Real.exp_le_exp.mpr hsq), ?_, ?_⟩ + · intro i j k + change rationalLogHeight (lieStructureConstants (productFinBasis D) i j k) ≤ _ + rw [productFinBasis, lieStructureConstants_reindex] + have hh := lie_pi_structure_height (fun i => (D i).basis) (one_le_ceil_exp p) + (fun a i j k => rationalHeightLE_ceil_exp ((hD a).2.2.1 i j k)) + exact (rationalLogHeight_le_of_height (hh _ _ _) (ceil_exp_le_exp_add_one hp)).trans hsmall + · change ∀ (j : Fin (s + 1)) + (k : Fin (finrank ℚ ((NilpotentLieFiltration.pi (fun i => (D i).filtration)).layer (j.val + 1)))) + (l : Fin (Fintype.card (Σ i, Fin (d i)))), + rationalLogHeight ((productFinBasis D).repr ((productLayerFinBasis D j k).val) l) ≤ (p + 2) ^ 2 + intro j k l + rw [productFinBasis, Basis.repr_reindex_apply, productLayerFinBasis, Basis.reindex_apply] + apply le_trans _ (show p ≤ (p + 2) ^ 2 by linarith) + exact productLayerBasis_logHeight D hp hD j _ _ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +open Module +open scoped TensorProduct BigOperators + +namespace Erdos3.RationalFilteredNilmanifold + +variable {ι : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + +theorem productProjection_lattice (i : ι) : + (pi D).lattice ≤ (D i).lattice.comap (NilpotentLieBCHGroup.mapOfSteps (liePiEval i)) := by + intro g hg + exact (mem_piBCHSubgroup (fun i => (D i).filtration) (fun i => (D i).lattice) g).mp hg i + +noncomputable def productProjectionHom (i : ι) : (pi D).RealGroup →* (D i).RealGroup := + NilpotentLieBCHGroup.realificationMap (hnil := (pi D).filtration.lowerCentralSeries_eq_bot) + (hM := (D i).filtration.lowerCentralSeries_eq_bot) (liePiEval i) + +noncomputable def productProjection (i : ι) : (pi D).Space → (D i).Space := + cosetMap (pi D).realLattice (D i).realLattice (productProjectionHom D i) + (NilpotentLieBCHGroup.realificationMap_subgroup (liePiEval i) _ _ (productProjection_lattice D i)) + +@[simp] theorem productProjection_mk (i : ι) (g : (pi D).RealGroup) : + productProjection D i (QuotientGroup.mk g) = QuotientGroup.mk (productProjectionHom D i g) := rfl + +theorem productProjection_matrix_height (i : ι) + (j : Fin (Fintype.card (Σ i, Fin (d i)))) (k : Fin (d i)) : + RationalHeightLE ((D i).basis.repr (liePiEval (R := ℚ) i ((pi D).basis j)) k) 1 := by + classical + change RationalHeightLE ((D i).basis.repr (productFinBasis D j i) k) 1 + rw [productFinBasis, Basis.reindex_apply] + generalize he : (Fintype.equivFin (Σ i, Fin (d i))).symm j = z + rcases z with ⟨a, l⟩ + rw [Pi.basis_apply] + by_cases hai : a = i + · subst a + rw [Pi.single_eq_same, Basis.repr_self] + by_cases hlk : l = k <;> simp [hlk, RationalHeightLE] + · rw [Pi.single_eq_of_ne (Ne.symm hai), map_zero, Finsupp.zero_apply] + exact rationalHeightLE_zero le_rfl + +variable [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + +theorem productProjection_lipschitz (i : ι) : + letI := (pi D).metricSpace + letI := (D i).metricSpace + LipschitzWith (coordinateLipschitzBound (d i) (Fintype.card (Σ i, Fin (d i))) 1) + (productProjection D i) := by + let := realificationQuotientMetricSpace (pi D).basis (pi D).lattice + (pi D).grid (pi D).grid_pos (pi D).outer_grid + let := realificationQuotientMetricSpace (D i).basis (D i).lattice + (D i).grid (D i).grid_pos (D i).outer_grid + have hh := NilpotentLieBCHGroup.lipschitz_realificationMap_quotient + (pi D).basis (D i).basis (liePiEval i) (pi D).lattice (D i).lattice + (productProjection_lattice D i) (pi D).grid (D i).grid (pi D).grid_pos (D i).grid_pos + (pi D).outer_grid (D i).outer_grid 1 (fun k j => productProjection_matrix_height D i j k) + exact hh.weaken (by simp only [Fintype.card_fin, Nat.cast_one, le_refl]) + +omit [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] in +theorem productProjection_lipschitz_bound {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hD : ∀ i, (D i).GeometryComplexityLE p) (i : ι) : + (coordinateLipschitzBound (d i) (Fintype.card (Σ i, Fin (d i))) 1 : ℝ) ≤ + Real.exp ((p ^ 2 + p + 3) ^ 2) := by + have hdim := sigma_card_le_budget hp hι + (κ := fun i => Fin (d i)) (fun i => by simpa only [Fintype.card_fin] using (hD i).1) + have hi := (hD i).1 + have hq : 0 ≤ p ^ 2 + p + 1 := by positivity + have hh := coordinateLipschitzBound_le_exp (d i) (Fintype.card (Σ i, Fin (d i))) 1 hq + (by nlinarith [sq_nonneg p]) (by linarith) + (by simpa only [NNReal.coe_one] using Real.one_le_exp_iff.mpr hq) + convert hh using 2 + ring + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +universe u v + +namespace Erdos3 + +def optionLieSpace {ι : Type v} (L₀ : Type u) (L : ι → Type u) : Option ι → Type u + | none => L₀ + | some i => L i + +instance optionLieRing {ι : Type v} {L₀ : Type u} {L : ι → Type u} + [LieRing L₀] [∀ i, LieRing (L i)] (i : Option ι) : LieRing (optionLieSpace L₀ L i) := by + cases i <;> dsimp [optionLieSpace] <;> infer_instance + +instance optionLieAlgebra {ι : Type v} {L₀ : Type u} {L : ι → Type u} + [LieRing L₀] [∀ i, LieRing (L i)] [LieAlgebra ℚ L₀] [∀ i, LieAlgebra ℚ (L i)] + (i : Option ι) : LieAlgebra ℚ (optionLieSpace L₀ L i) := by + cases i <;> dsimp [optionLieSpace] <;> infer_instance + +def optionDimension {ι : Type v} (d₀ : ℕ) (d : ι → ℕ) : Option ι → ℕ + | none => d₀ + | some i => d i + +namespace RationalFilteredNilmanifold + +open Module +open scoped TensorProduct + +variable {ι : Type v} [Fintype ι] {L₀ : Type u} {L : ι → Type u} + [LieRing L₀] [∀ i, LieRing (L i)] [LieAlgebra ℚ L₀] [∀ i, LieAlgebra ℚ (L i)] + {s d₀ : ℕ} {d : ι → ℕ} + (D₀ : RationalFilteredNilmanifold L₀ s d₀) + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + +noncomputable def optionFactors : ∀ i : Option ι, + RationalFilteredNilmanifold (optionLieSpace L₀ L i) s (optionDimension d₀ d i) + | none => D₀ + | some i => D i + +noncomputable def optionProduct := pi (optionFactors D₀ D) + +theorem optionProduct_geometry {p : ℝ} (hp : 0 ≤ p) (hι : (Fintype.card ι : ℝ) ≤ p) + (hD₀ : D₀.GeometryComplexityLE p) (hD : ∀ i, (D i).GeometryComplexityLE p) : + (optionProduct D₀ D).GeometryComplexityLE ((p + 3) ^ 2) := by + have hpp : p ≤ p + 1 := le_add_of_nonneg_right zero_le_one + have h := pi_geometry (optionFactors D₀ D) (p := p + 1) (by linarith) + (by simp only [Fintype.card_option, Nat.cast_add, Nat.cast_one]; linarith) + (fun i => by cases i with + | none => exact hD₀.mono D₀ hpp + | some i => exact (hD i).mono (D i) hpp) + simpa only [optionProduct, show p + 1 + 2 = p + 3 by ring] using h + +variable {H : Type u} [LieRing H] [LieAlgebra ℚ H] + +def optionMaps (φ₀ : H →ₗ⁅ℚ⁆ L₀) (φ : ∀ i, H →ₗ⁅ℚ⁆ L i) : + ∀ i : Option ι, H →ₗ⁅ℚ⁆ optionLieSpace L₀ L i + | none => φ₀ + | some i => φ i + +def optionProductMap (φ₀ : H →ₗ⁅ℚ⁆ L₀) (φ : ∀ i, H →ₗ⁅ℚ⁆ L i) : + H →ₗ⁅ℚ⁆ (∀ i : Option ι, optionLieSpace L₀ L i) := + liePiMap (optionMaps φ₀ φ) + +theorem optionProductMap_logHeight {κ : Type*} (b : Basis κ ℚ H) + (φ₀ : H →ₗ⁅ℚ⁆ L₀) (φ : ∀ i, H →ₗ⁅ℚ⁆ L i) {p : ℝ} + (h₀ : ∀ i j, rationalLogHeight (D₀.basis.repr (φ₀ (b j)) i) ≤ p) + (hφ : ∀ a i j, rationalLogHeight ((D a).basis.repr (φ a (b j)) i) ≤ p) : + ∀ i j, rationalLogHeight ((optionProduct D₀ D).basis.repr (optionProductMap φ₀ φ (b j)) i) ≤ p := by + intro i j + dsimp only [optionProduct] + rw [productFinBasis_repr] + generalize hz : (Fintype.equivFin (Σ i : Option ι, Fin (optionDimension d₀ d i))).symm i = z + rcases z with ⟨a, k⟩ + cases a with + | none => exact h₀ k j + | some a => exact hφ a k j + +include D₀ D in +theorem optionProductMap_real_kernel + (φ₀ : H →ₗ⁅ℚ⁆ L₀) (φ : ∀ i, H →ₗ⁅ℚ⁆ L i) (x : ℝ ⊗[ℚ] H) : + realificationLieHom (optionProductMap φ₀ φ) x = 0 ↔ + realificationLieHom φ₀ x = 0 ∧ ∀ i, realificationLieHom (φ i) x = 0 := by + rw [optionProductMap, realification_liePiMap_eq_zero_iff (fun i => (optionFactors D₀ D i).basis)] + constructor + · intro h + exact ⟨h none, fun i => h (some i)⟩ + · rintro ⟨h₀, hφ⟩ i + cases i with + | none => exact h₀ + | some i => exact hφ i + +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +open scoped TensorProduct BigOperators NNReal + +namespace Erdos3.RationalFilteredNilmanifold + +variable {ι σ : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) {w : σ → ℕ} + +noncomputable def productObservable (T : ∀ i, (D i).Niltest w) (z : (pi D).Space) : ℂ := + ∏ i, (T i).observable (productProjection D i z) + +theorem productObservable_bounds (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) : + letI := (pi D).metricSpace + (∀ z, ‖productObservable D T z‖ ≤ Real.exp p ^ Fintype.card ι) ∧ + LipschitzWith ((Fintype.card ι : ℝ≥0) * + productExpBound (productObservableLipBudget p) * + productExpBound p ^ Fintype.card ι) (productObservable D T) := by + let := (pi D).metricSpace + have hB : (1 : ℝ≥0) ≤ productExpBound p := Real.one_le_exp_iff.mpr hp + have hnorm (i : ι) (z : (pi D).Space) : + ‖(T i).observable (productProjection D i z)‖ ≤ Real.exp p := by + have hb := (T i).observable_budget (hT i) + exact ((T i).norm_le _).trans (by linarith [(T i).lipBound.coe_nonneg]) + have hlip (i : ι) : LipschitzWith + (productExpBound (productObservableLipBudget p)) + (fun z => (T i).observable (productProjection D i z)) := by + let := (D i).metricSpace + apply ((T i).lipschitz.comp (productProjection_lipschitz D i)).weaken + change (T i).lipBound * + (coordinateLipschitzBound (d i) (Fintype.card (Σ i, Fin (d i))) 1 : ℝ) ≤ _ + have hb := (T i).observable_budget (hT i) + have hk : ((T i).lipBound : ℝ) ≤ Real.exp p := by linarith [(T i).normBound.coe_nonneg] + calc + _ ≤ Real.exp p * Real.exp ((p ^ 2 + p + 3) ^ 2) := + mul_le_mul hk (productProjection_lipschitz_bound D hp hι (fun i => (hT i).1) i) + (by positivity) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; rfl + exact bounded_lipschitz_fintype_prod (fun i z => (T i).observable (productProjection D i z)) + hB hlip hnorm + +noncomputable def piNiltest (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) : (pi D).Niltest w where + orbit := NilpotentLieFiltration.piRealOrbit (fun i => (D i).filtration) (fun i => (T i).orbit) + observable := productObservable D T + normBound := productExpBound p ^ Fintype.card ι + lipBound := (Fintype.card ι : ℝ≥0) * + productExpBound (productObservableLipBudget p) * + productExpBound p ^ Fintype.card ι + norm_le z := by simpa only [NNReal.coe_pow, coe_productExpBound] using (productObservable_bounds D T hp hι hT).1 z + lipschitz := (productObservable_bounds D T hp hι hT).2 + +theorem piNiltest_eval (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) (x : σ → ℤ) : + (piNiltest D T hp hι hT).eval x = ∏ i, (T i).eval x := by + change (∏ i, (T i).observable (productProjection D i + (QuotientGroup.mk ((pi D).filtration.realification.polynomialOrbitEval w x + (NilpotentLieFiltration.piRealOrbit (fun i => (D i).filtration) (fun i => (T i).orbit)))))) = _ + apply Finset.prod_congr rfl + intro i _ + rw [productProjection_mk] + exact congrArg (fun g => (T i).observable (QuotientGroup.mk g)) + (NilpotentLieFiltration.piRealOrbit_eval (fun i => (D i).filtration) (fun i => (T i).orbit) x i) + +theorem piNiltest_complexity (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) : + (piNiltest D T hp hι hT).ComplexityLE (productNiltestBudget p) := by + constructor + · exact GeometryComplexityLE.mono (pi D) (pi_geometry D hp hι (fun i => (hT i).1)) + (productNiltestBudget_geometry hp) + · change Real.log (2 + (Real.exp p) ^ Fintype.card ι + + (Fintype.card ι : ℝ) * Real.exp (productObservableLipBudget p) * (Real.exp p) ^ Fintype.card ι) ≤ _ + apply (Real.log_le_iff_le_exp (by positivity)).mpr + exact productNiltestBudget_observable hp _ hι + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +open scoped TensorProduct BigOperators + +namespace Erdos3.RationalFilteredNilmanifold + +theorem exists_product_niltest {ι σ : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) {w : σ → ℕ} + (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) : + letI : FiniteDimensional ℚ (∀ i, L i) := (productFinBasis D).finiteDimensional_of_finite + letI := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i)) := IsModuleTopology.isTopologicalAddGroup ℝ _ + letI : T2Space (ℝ ⊗[ℚ] (∀ i, L i)) := realification_moduleTopology_t2 (productFinBasis D) + ∃ S : (pi D).Niltest w, S.ComplexityLE (productNiltestBudget p) ∧ + ∀ x, S.eval x = ∏ i, (T i).eval x := by + let : FiniteDimensional ℚ (∀ i, L i) := (productFinBasis D).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i)) := IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (∀ i, L i)) := realification_moduleTopology_t2 (productFinBasis D) + exact ⟨piNiltest D T hp hι hT, piNiltest_complexity D T hp hι hT, piNiltest_eval D T hp hι hT⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +open scoped TensorProduct BigOperators + +namespace Erdos3.RationalFilteredNilmanifold + +variable {ι σ : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + +theorem productProjection_smul (i : ι) (g : (pi D).RealGroup) (x : (pi D).Space) : + productProjection D i (g • x) = productProjectionHom D i g • productProjection D i x := + cosetMap_smul _ _ _ _ g x + +theorem productProjectionHom_mem_layer (i : ι) (k : ℕ) (g : (pi D).RealGroup) + (hg : g ∈ (pi D).filtration.realification.subgroup k) : + productProjectionHom D i g ∈ (D i).filtration.realification.subgroup k := by + apply baseChange_mem_of_mapsTo ((pi D).filtration.layer k) ((D i).filtration.layer k) + (liePiEval i).toLinearMap _ hg + intro x hx + exact (NilpotentLieFiltration.mem_pi_layer (fun i => (D i).filtration) k x).mp hx i + +variable [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + {w : σ → ℕ} + +omit [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] in +theorem productObservable_vertical (T : ∀ i, (D i).Niltest w) + (eta : ∀ i, L i →ₗ[ℚ] ℚ) + (hvert : ∀ i z, z ∈ (D i).filtration.realification.subgroup s → ∀ x, + (T i).observable (z • x) = + CircleFourier.character ((realifyFunctional (eta i) z.coord : ℝ) : CircleFourier.Circle) * + (T i).observable x) + (z : (pi D).RealGroup) (hz : z ∈ (pi D).filtration.realification.subgroup s) + (x : (pi D).Space) : + productObservable D T (z • x) = + CircleFourier.character ((realifyFunctional (piFrequency eta) z.coord : ℝ) : CircleFourier.Circle) * + productObservable D T x := by + have hchar : + CircleFourier.character ((realifyFunctional (piFrequency eta) z.coord : ℝ) : CircleFourier.Circle) = + ∏ i, CircleFourier.character + ((realifyFunctional (eta i) (productProjectionHom D i z).coord : ℝ) : CircleFourier.Circle) := by + rw [realify_piFrequency] + have hcoe (f : ι → ℝ) : ((∑ i, f i : ℝ) : CircleFourier.Circle) = + ∑ i, (f i : CircleFourier.Circle) := + map_sum (QuotientAddGroup.mk' (AddSubgroup.zmultiples (1 : ℝ))) f Finset.univ + simp only [hcoe, CircleFourier.character_fintype_sum, + productProjectionHom, NilpotentLieBCHGroup.realificationMap_coord] + rw [hchar, productObservable, productObservable, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [productProjection_smul] + exact hvert i _ (productProjectionHom_mem_layer D i s z hz) _ + +theorem piNiltest_vertical (T : ∀ i, (D i).Niltest w) + (eta : ∀ i, L i →ₗ[ℚ] ℚ) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) + (hvert : ∀ i z, z ∈ (D i).filtration.realification.subgroup s → ∀ x, + (T i).observable (z • x) = + CircleFourier.character ((realifyFunctional (eta i) z.coord : ℝ) : CircleFourier.Circle) * + (T i).observable x) + (z : (pi D).RealGroup) (hz : z ∈ (pi D).filtration.realification.subgroup s) + (x : (pi D).Space) : + (piNiltest D T hp hι hT).observable (z • x) = + CircleFourier.character ((realifyFunctional (piFrequency eta) z.coord : ℝ) : CircleFourier.Circle) * + (piNiltest D T hp hι hT).observable x := + productObservable_vertical D T eta hvert z hz x + +theorem piNiltest_orbit_eq (T U : ∀ i, (D i).Niltest w) {p q : ℝ} + (hp : 0 ≤ p) (hq : 0 ≤ q) (hιp : (Fintype.card ι : ℝ) ≤ p) + (hιq : (Fintype.card ι : ℝ) ≤ q) + (hT : ∀ i, (T i).ComplexityLE p) (hU : ∀ i, (U i).ComplexityLE q) + (horbit : ∀ i, (T i).orbit = (U i).orbit) : + (piNiltest D T hp hιp hT).orbit = (piNiltest D U hq hιq hU).orbit := by + change NilpotentLieFiltration.piRealOrbit _ _ = NilpotentLieFiltration.piRealOrbit _ _ + exact congrArg (NilpotentLieFiltration.piRealOrbit (fun i => (D i).filtration)) (funext horbit) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +open scoped TensorProduct BigOperators NNReal + +namespace Erdos3.RationalFilteredNilmanifold + +variable {ι σ : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) {w : σ → ℕ} + +omit [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] in +theorem productObservable_norm_le_one (T : ∀ i, (D i).Niltest w) + (hcap : ∀ i, (T i).normBound ≤ 1) (x : (pi D).Space) : + ‖productObservable D T x‖ ≤ 1 := by + unfold productObservable + calc + _ = ∏ i, ‖(T i).observable (productProjection D i x)‖ := norm_prod _ _ + _ ≤ ∏ _i : ι, (1 : ℝ) := Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun i _ => ((T i).norm_le _).trans (by exact_mod_cast hcap i)) + _ = 1 := by simp + +noncomputable def unitBoundedPiNiltest (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) + (hcap : ∀ i, (T i).normBound ≤ 1) : (pi D).Niltest w := + { piNiltest D T hp hι hT with + normBound := 1 + norm_le := productObservable_norm_le_one D T hcap } + +theorem unitBoundedPiNiltest_normBound (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) + (hcap : ∀ i, (T i).normBound ≤ 1) : + (unitBoundedPiNiltest D T hp hι hT hcap).normBound = 1 := rfl + +theorem unitBoundedPiNiltest_eval (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) + (hcap : ∀ i, (T i).normBound ≤ 1) (x : σ → ℤ) : + (unitBoundedPiNiltest D T hp hι hT hcap).eval x = ∏ i, (T i).eval x := + piNiltest_eval D T hp hι hT x + +theorem unitBoundedPiNiltest_complexity (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) + (hcap : ∀ i, (T i).normBound ≤ 1) : + (unitBoundedPiNiltest D T hp hι hT hcap).ComplexityLE (productNiltestBudget p) := by + have h := piNiltest_complexity D T hp hι hT + refine ⟨h.1, le_trans ?_ h.2⟩ + apply Real.log_le_log (by positivity) + change 2 + 1 + ((piNiltest D T hp hι hT).lipBound : ℝ) ≤ + 2 + Real.exp p ^ Fintype.card ι + ((piNiltest D T hp hι hT).lipBound : ℝ) + have hb : 1 ≤ Real.exp p ^ Fintype.card ι := one_le_pow₀ (Real.one_le_exp_iff.mpr hp) + linarith + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct + +theorem complex_prod_unit_interval {I : Type*} [Fintype I] (a : I → ℂ) + (ha : ∀ i, (a i).im = 0 ∧ 0 ≤ (a i).re ∧ (a i).re ≤ 1) : + (∏ i, a i).im = 0 ∧ 0 ≤ (∏ i, a i).re ∧ (∏ i, a i).re ≤ 1 := by + have he (i : I) : a i = ((a i).re : ℂ) := by + apply Complex.ext + · simp + · simpa using (ha i).1 + have hprod : (∏ i, a i) = ((∏ i, (a i).re : ℝ) : ℂ) := by + calc + _ = ∏ i, ((a i).re : ℂ) := Finset.prod_congr rfl (fun i _ => he i) + _ = _ := by rw [Complex.ofReal_prod] + rw [hprod] + simp only [Complex.ofReal_im, Complex.ofReal_re, true_and] + exact ⟨Finset.prod_nonneg (fun i _ => (ha i).2.1), + Finset.prod_le_one₀ (fun i _ => (ha i).2.1) (fun i _ => (ha i).2.2)⟩ + +namespace RationalFilteredNilmanifold + +theorem piNiltest_unit_interval {ι σ : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + [TopologicalSpace (ℝ ⊗[ℚ] (∀ i, L i))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ i, L i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (∀ i, L i))] [T2Space (ℝ ⊗[ℚ] (∀ i, L i))] + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) {w : σ → ℕ} + (T : ∀ i, (D i).Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hι : (Fintype.card ι : ℝ) ≤ p) (hT : ∀ i, (T i).ComplexityLE p) + (hunit : ∀ i, (T i).UnitIntervalValued) : + (piNiltest D T hp hι hT).UnitIntervalValued := by + intro z + exact complex_prod_unit_interval (fun i => (T i).observable (productProjection D i z)) + (fun i => hunit i _) + +namespace Niltest + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem unit_interval_eval (T : D.Niltest w) (hT : T.UnitIntervalValued) (x : σ → ℤ) : + (T.eval x).im = 0 ∧ 0 ≤ (T.eval x).re ∧ (T.eval x).re ≤ 1 := hT _ + +theorem unit_interval_evalCyclic (T : D.Niltest w) (hT : T.UnitIntervalValued) + (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (T.evalCyclic N x).im = 0 ∧ 0 ≤ (T.evalCyclic N x).re ∧ (T.evalCyclic N x).re ≤ 1 := hT _ + +end Niltest +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +theorem exists_cellwise_niltest_error + {I J : Type*} [Fintype I] [Fintype J] (N : ℕ) [NeZero N] + {K : ZMod N → Type*} [∀ h, LieRing (K h)] [∀ h, LieAlgebra ℚ (K h)] + [∀ h, TopologicalSpace (ℝ ⊗[ℚ] K h)] [∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] K h)] + [∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] K h)] [∀ h, T2Space (ℝ ⊗[ℚ] K h)] + {s : ℕ} {d : ZMod N → ℕ} (D : ∀ h, RationalFilteredNilmanifold (K h) s (d h)) + (U : I → J → (h : ZMod N) → (D h).Niltest (fun _ : Unit => 1)) + (A : I → ZMod N → ℝ) (B : J → ZMod N → ℝ) + (T : ZMod N → ZMod N → ℝ) (E : ZMod N → Finset (ZMod N)) + {ε : ℝ} (hε : 0 ≤ ε) + (hA : ∀ i n, 0 ≤ A i n) (hB : ∀ j n, 0 ≤ B j n) + (hAsum : ∀ n, ∑ i, A i n = 1) (hBsum : ∀ n, ∑ j, B j n = 1) + (hT : ∀ h n, 0 ≤ T h n ∧ T h n ≤ 1) + (hU : ∀ i j h, (U i j h).UnitIntervalValued) + (hgood : ∀ h n, n ∉ E h → + |T h n - ∑ i, ∑ j, A i n * B j (n + h) * + ((U i j h).evalCyclic N (fun _ : Unit => n)).re| ≤ ε) : + ∃ e : ZMod N → ZMod N → ℝ, + (∀ h n, T h n = (∑ i, ∑ j, A i n * B j (n + h) * + ((U i j h).evalCyclic N (fun _ : Unit => n)).re) + e h n) ∧ + ∀ h, (𝔼 n, |e h n|) ≤ ε + ((E h).card : ℝ) / N := by + let e : ZMod N → ZMod N → ℝ := fun h n => + T h n - ∑ i, ∑ j, A i n * B j (n + h) * ((U i j h).evalCyclic N (fun _ : Unit => n)).re + refine ⟨e, fun h n => by dsimp [e]; ring, ?_⟩ + intro h + have hmean := positive_partition_approximation_mean_error (E h) + (fun ij : I × J => fun n => A ij.1 n * B ij.2 (n + h)) + (fun ij : I × J => fun n => ((U ij.1 ij.2 h).evalCyclic N (fun _ : Unit => n)).re) + (T h) hε + (fun ij n => mul_nonneg (hA ij.1 n) (hB ij.2 (n + h))) + (fun n => sum_pair_partition_weights (fun i => A i n) (fun j => B j (n + h)) + (hAsum n) (hBsum (n + h))) + (fun ij n => ((U ij.1 ij.2 h).unit_interval_evalCyclic (hU ij.1 ij.2 h) N (fun _ : Unit => n)).2) + (hT h) (fun n hn => by simpa only [Fintype.sum_prod_type] using hgood h n hn) + simpa only [e, Fintype.sum_prod_type, ZMod.card] using hmean + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators NNReal + +theorem exists_cyclic_cellwise_niltest_approximation + {I J Ξ : Type*} [Fintype I] [Fintype J] [PseudoMetricSpace Ξ] + (N : ℕ) [NeZero N] {K : ZMod N → Type*} + [∀ h, LieRing (K h)] [∀ h, LieAlgebra ℚ (K h)] {s : ℕ} {d : ZMod N → ℕ} + [∀ h, TopologicalSpace (ℝ ⊗[ℚ] K h)] [∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] K h)] + [∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] K h)] [∀ h, T2Space (ℝ ⊗[ℚ] K h)] + (D : ∀ h, RationalFilteredNilmanifold (K h) s (d h)) + (g : ∀ h, (D h).filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (F : I → ∀ h, (D h).Space → Ξ → ℝ) + (A : I → ZMod N → ℝ) (B : J → ZMod N → ℝ) + (xi : ZMod N → ZMod N → Ξ) (T : ZMod N → ZMod N → ℝ) + {L M : ℝ≥0} {ρ δ η p : ℝ} (hρ : 0 < ρ) (hδ : 0 ≤ δ) (hη : 0 ≤ η) + (hA : ∀ i n, 0 ≤ A i n) (hB : ∀ j n, 0 ≤ B j n) + (hAsum : ∀ n, ∑ i, A i n = 1) (hBsum : ∀ n, ∑ j, B j n = 1) + (hF : ∀ i h z a, 0 ≤ F i h z a ∧ F i h z a ≤ 1) + (hFirstLip : ∀ i h, let := (D h).metricSpace; ∀ a, LipschitzWith M (fun z => F i h z a)) + (hSecondLip : ∀ i h z, LipschitzWith L (F i h z)) + (hGeometry : ∀ h, (D h).GeometryComplexityLE p) + (hBudget : Real.log (3 + (M : ℝ)) ≤ p) + (hT : ∀ h n, 0 ≤ T h n ∧ T h n ≤ 1) + (happrox : ∀ i h n, n ∉ cyclicWrapExceptional h ρ → 0 < A i n → + |T h n - F i h ((D h).cyclicOrbitPoint (g h) N (fun _ : Unit => n)) (xi h n)| ≤ δ) + (hdiam : ∀ i j h n n', n ∉ cyclicWrapExceptional h ρ → n' ∉ cyclicWrapExceptional h ρ → + 0 < A i n * B j (n + h) → 0 < A i n' * B j (n' + h) → dist (xi h n) (xi h n') ≤ η) : + ∃ U : I → J → (h : ZMod N) → (D h).Niltest (fun _ : Unit => 1), + (∀ i j h, (U i j h).UnitIntervalValued) ∧ + (∀ i j h, (U i j h).ComplexityLE p) ∧ + (∀ i j h, (¬∃ n, n ∉ cyclicWrapExceptional h ρ ∧ 0 < A i n * B j (n + h)) → + ∀ x, (U i j h).eval x = 0) ∧ + (∀ h n, n ∉ cyclicWrapExceptional h ρ → + |T h n - ∑ i, ∑ j, A i n * B j (n + h) * + ((U i j h).evalCyclic N (fun _ : Unit => n)).re| ≤ δ + L * η) ∧ + ∃ e : ZMod N → ZMod N → ℝ, + (∀ h n, T h n = (∑ i, ∑ j, A i n * B j (n + h) * + ((U i j h).evalCyclic N (fun _ : Unit => n)).re) + e h n) ∧ + ∀ h, (𝔼 n, |e h n|) ≤ δ + L * η + 6 * ρ + 3 / N := by + obtain ⟨U, hU, hUcomplexity, hUempty, hgood⟩ := exists_cellwise_niltest_discretization + N D g F A B (fun h => ↑(cyclicWrapExceptional h ρ)) xi T + hA hB hAsum hBsum hF hFirstLip hSecondLip hGeometry hBudget happrox hdiam + have herror : 0 ≤ δ + (L : ℝ) * η := add_nonneg hδ (mul_nonneg L.coe_nonneg hη) + obtain ⟨e, heval, hmean⟩ := exists_cellwise_niltest_error N D U A B T + (fun h => cyclicWrapExceptional h ρ) herror hA hB hAsum hBsum hT hU hgood + refine ⟨U, hU, hUcomplexity, hUempty, hgood, e, heval, ?_⟩ + intro h + calc + _ ≤ δ + (L : ℝ) * η + ((cyclicWrapExceptional h ρ).card : ℝ) / N := hmean h + _ ≤ δ + (L : ℝ) * η + (6 * ρ + 3 / N) := by + linarith [cyclicWrapExceptional_density_le h hρ.le] + _ = _ := by ring + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicNiltestDetection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicNiltestDetection.lean new file mode 100644 index 0000000000000000000000000000000000000000..588bce48ae8a7a687db6ef806b51a9e3d3330cab --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicNiltestDetection.lean @@ -0,0 +1,251 @@ +import OAI.Combinatorics.Progressions.Dynamics.CyclicDetectionBudget +import OAI.Combinatorics.Progressions.Estimates.CommonNativeSquareFactors +import OAI.Combinatorics.Progressions.Estimates.CyclicIntervalCubeComparison + +namespace OAI + +section + +namespace Erdos3 + +open CircleFourier +open scoped TensorProduct BigOperators + +theorem boxNiltestDetection_succ.{u,v} {s c : ℕ} + (hI : BoxNiltestDetection.{u,v} s (fun p => (p + c) ^ c)) : + ∃ C : ℕ, 2 ≤ C ∧ BoxNiltestDetection.{u,v} (s + 1) (fun p => (p + C) ^ C) := by + classical + obtain ⟨av, _, hav⟩ := exists_verticalDecompositionBudget_bound + obtain ⟨bs, _, hder⟩ := exists_vertical_derivative_detection s + obtain ⟨C, hC, hbudget⟩ := exists_boxDetectionStepBudget_bound s av bs c + refine ⟨C, hC, ?_⟩ + intro σ _ _ L _ _ d _ _ _ _ D p hp hσ w hw T hT z lengths _ f hf hc + let Q := translatedIntegerBox z lengths + have hQ : Q.Nonempty := translatedIntegerBox_nonempty lengths z + obtain ⟨η, U, hU, hcorrU, hchar⟩ := + T.exists_detection_vertical_mode av hav hp hT hQ f hf hc + let r := boxModeBudget av p + let q := boxInductionInputBudget av bs p + let ℓ := boxRetainedBudget av p + let ρ := Real.exp (-r) + let δ := Real.exp (-(ℓ + p)) + let η0 := Real.exp (-((q + c) ^ c)) + let μ := Real.exp (-ℓ) + let P := fun h : σ → ℤ => + ρ ^ 2 / 2 ≤ ‖finiteCorrelation (derivativeSupport Q h) + (multiplicativeDerivative f h) (multiplicativeDerivative U.eval h)‖ ∧ + δ * Q.card < ((derivativeSupport Q h).card : ℝ) + have hcost := boxInductionInputBudget_bounds av bs hp + have hq : 0 ≤ q := hp.trans hcost.2.2 + have hρsq : Real.exp (-q) ≤ ρ ^ 2 / 2 := by + have hq' : 2 * r + 1 ≤ q := hcost.2.1 + have he : ρ ^ 2 = Real.exp (-2 * r) := by + dsimp [ρ] + rw [← Real.exp_nat_mul] + congr 1 + ring + rw [he] + exact (Real.exp_le_exp.mpr (by linarith : -q ≤ -2 * r - 1)).trans + (exp_sub_one_le_half_exp (-2 * r)) + have hweight := weight_correlating_large_box_overlaps z lengths f U.eval + (ρ := ρ) (B := Real.exp (p + 1)) (δ := δ) + (Real.exp_nonneg _) (Real.exp_pos _) (Real.exp_nonneg _) hf + (fun x _ => U.eval_budget hU x) hcorrU + have hμ : μ ≤ ∑ h ∈ cubeDifferenceSupport Q, + (((derivativeSupport Q h).card : ℝ) / (Q.card : ℝ) ^ 2) * (if P h then (1 : ℝ) else 0) := + (retained_exponential_weight (Fintype.card σ) (r := r) hσ).trans hweight + have hretained (h : σ → ℤ) (hh : h ∈ cubeDifferenceSupport Q) (hP : P h) : + δ * Q.card ≤ ((derivativeSupport Q h).card : ℝ) ∧ + η0 ≤ finiteSupportGowersNorm (s + 1) (derivativeSupport Q h) (multiplicativeDerivative f h) := by + refine ⟨hP.2.le, ?_⟩ + let lens := fun i => ((lengths i : ℤ) - |h i|).toNat + let origin := fun i => z i + max 0 (-h i) + let : ∀ i, NeZero (lens i) := fun i => ⟨(box_overlap_length_pos z lengths hh i).ne'⟩ + have hR : derivativeSupport Q h = translatedIntegerBox origin lens := + derivativeSupport_translatedIntegerBox z lengths h + have hunit : ∀ x ∈ translatedIntegerBox origin lens, ‖multiplicativeDerivative f h x‖ ≤ 1 := by + rw [← hR] + intro x hx + obtain ⟨hx, hxh⟩ := Finset.mem_filter.mp hx + simpa only [multiplicativeDerivative, norm_mul, norm_star, one_mul] using + mul_le_mul (hf x hx) (hf (x + h) hxh) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hcorr : Real.exp (-q) ≤ ‖finiteCorrelation (translatedIntegerBox origin lens) + (multiplicativeDerivative f h) (multiplicativeDerivative U.eval h)‖ := by + rw [← hR] + exact hρsq.trans hP.1 + have hd := hder c hI D (p + 1) q (by linarith) hq (hσ.trans hcost.2.2) hcost.1 + w hw U hU (fun g => ((realifyFunctional η g.coord : ℝ) : CircleFourier.Circle)) hchar + h origin lens (multiplicativeDerivative f h) hunit hcorr + rwa [← hR] at hd + have hgowers := box_gowers_lower_bound_of_overlaps z lengths s f P + (Real.exp_nonneg _) (Real.exp_nonneg _) hμ hretained + have hpow : Real.exp (-boxDetectionStepBudget s av bs c p) ≤ + finiteSupportGowersNorm (s + 2) Q f ^ (2 ^ (s + 2)) := + (box_detection_exponential_product s av bs c (Fintype.card σ) hσ).trans hgowers + have hnorm : 0 ≤ finiteSupportGowersNorm (s + 2) Q f := by + rw [finiteSupportGowersNorm_eq_restricted (translatedIntegerBox_reflectsPairSums lengths z)] + exact restrictedGowersNorm_nonneg (s + 1) _ _ + exact (Real.exp_le_exp.mpr (neg_le_neg (hbudget p hp))).trans + (exp_neg_le_of_pow hnorm (boxDetectionStepBudget_nonneg s av bs c hp) + (pow_ne_zero _ (by norm_num)) hpow) + +theorem exists_boxNiltestDetection.{u,v} (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ BoxNiltestDetection.{u,v} s (fun p => (p + C) ^ C) := by + induction s with + | zero => + refine ⟨2, le_rfl, ?_⟩ + intro σ _ _ L _ _ d _ _ _ _ D p hp hσ w hw T hT z lengths _ f hf hc + have hb : 2 * p ≤ (p + (2 : ℕ)) ^ 2 := by + norm_num only [Nat.cast_ofNat] + nlinarith [sq_nonneg p] + exact (Real.exp_le_exp.mpr (neg_le_neg hb)).trans + (boxNiltestDetection_zero D p hp hσ w hw T hT z lengths f hf hc) + | succ s ih => + obtain ⟨c, _, hc⟩ := ih + exact boxNiltestDetection_succ hc + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem exists_intervalNiltestDetection.{u} (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ + ∀ {L : Type u} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (p : ℝ), + 1 ≤ p → ∀ (w : Fin 1 → ℕ), (∀ i, 0 < w i) → + ∀ (T : D.Niltest w), T.ComplexityLE p → + ∀ (a : ℤ) (len : ℕ) [NeZero len] (f : ℤ → ℂ), + (∀ x ∈ Finset.Ico a (a + len), ‖f x‖ ≤ 1) → + Real.exp (-p) ≤ ‖finiteCorrelation (Finset.Ico a (a + len)) f + (fun x => T.eval (fun _ => x))‖ → + Real.exp (-((p + C) ^ C)) ≤ finiteSupportGowersNorm (s + 1) + (Finset.Ico a (a + len)) f := by + obtain ⟨C, hC, hdet⟩ := exists_boxNiltestDetection s + refine ⟨C, hC, ?_⟩ + intro L _ _ d _ _ _ _ D p hp w hw T hT a len hlen f hf hc + have hunit : ∀ x ∈ translatedIntegerBox (fun _ : Fin 1 => a) (fun _ => len), + ‖f (x 0)‖ ≤ 1 := by + intro x hx + exact hf (x 0) (Finset.mem_Ico.mpr ((mem_translatedIntegerBox _ _ x).mp hx 0)) + have hcorr : Real.exp (-p) ≤ ‖finiteCorrelation + (translatedIntegerBox (fun _ : Fin 1 => a) (fun _ => len)) (fun x => f (x 0)) T.eval‖ := by + rwa [oneDimensionalBox_correlation] + have hp0 : 0 ≤ p := by linarith + have hdim : (Fintype.card (Fin 1) : ℝ) ≤ p := by simpa using hp + have hh := @hdet (Fin 1) inferInstance inferInstance L inferInstance inferInstance d + inferInstance inferInstance inferInstance inferInstance D p hp0 hdim w hw T hT + (fun _ => a) (fun _ => len) (fun _ => hlen) (fun x => f (x 0)) hunit hcorr + simpa only [oneDimensionalBox_norm] using hh + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +def CyclicNiltestDetection.{u} (s : ℕ) (F : ℝ → ℝ) : Prop := + ∀ {L : Type u} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) (p : ℝ), + 0 ≤ p → ∀ (w : Fin 1 → ℕ), (∀ i, 0 < w i) → + ∀ (T : D.Niltest w), T.ComplexityLE p → + ∀ (N : ℕ) [NeZero N] (f : ZMod N → ℂ), + (∀ x, ‖f x‖ ≤ 1) → + Real.exp (-p) ≤ ‖finiteCorrelation Finset.univ f + (fun x => T.eval (fun _ => (x.val : ℤ)))‖ → + Real.exp (-F p) ≤ gowersNorm (s + 1) f + +theorem cyclicNiltestDetection_zero.{u} : CyclicNiltestDetection.{u} 0 (fun p => 2 * p) := by + intro L _ _ d _ _ _ _ D p hp w hw T hT N _ f hf hc + have hh := RationalFilteredNilmanifold.Niltest.detection_step_zero_sample + D T hT Finset.univ (fun x : ZMod N => fun _ => (x.val : ℤ)) f hc + have he : Real.exp (-p) / Real.exp p = Real.exp (-(2 * p)) := by + rw [← Real.exp_sub] + congr 1 + ring + rwa [he, ← gowersNorm_one] at hh + +theorem exists_cyclicNiltestDetection_succ.{u} (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ CyclicNiltestDetection.{u} (s + 1) (fun p => (p + C) ^ C) := by + obtain ⟨c, _, hdet⟩ := exists_intervalNiltestDetection.{u} (s + 1) + obtain ⟨C, hC, hbudget⟩ := exists_cyclicDetectionBudget_bound s c + refine ⟨C, hC, ?_⟩ + intro L _ _ d _ _ _ _ D p hp w hw T hT N _ f hf hc + obtain ⟨i, hi, hcorr, hvol⟩ := exists_correlating_cyclicQuarter f + (fun x => T.eval (fun _ => (x.val : ℤ))) (Real.exp_pos (-p)) (Real.exp_pos p) + hf (fun x => T.eval_budget hT _) hc + let a := quarterLower N i + let len := quarterUpper N i - quarterLower N i + have hb := quarter_bounds N i + have hlen : len ≤ N := by dsimp [len]; omega + have hcard : (cyclicQuarter N i).card = len := + cyclicInterval_card (a : ZMod N) hlen + have hlenpos : 0 < len := by rw [← hcard]; exact hi.card_pos + let : NeZero len := ⟨hlenpos.ne'⟩ + have hshort : 2 * ((len : ℤ) - 1) < N := by + have hs := quarter_short N (NeZero.pos N) i + dsimp [len] + omega + have hbound : a + len ≤ N := by dsimp [a, len]; omega + have hvolume : Real.exp (-(2 * p + 8)) ≤ (len : ℝ) / N := by + rw [hcard] at hvol + exact (cyclic_retained_volume_exp p).trans hvol + have hcorr' : Real.exp (-(p + 8)) ≤ ‖finiteCorrelation + (Finset.Ico (a : ℤ) (a + len)) (fun x => f (x : ZMod N)) + (fun x => T.eval (fun _ => x))‖ := by + change Real.exp (-p) / 8 ≤ ‖finiteCorrelation (cyclicInterval (a : ZMod N) len) f + (fun x => T.eval (fun _ => (x.val : ℤ)))‖ at hcorr + rw [cyclicInterval_representative_correlation a len hbound hshort f + (fun x => T.eval (fun _ => x))] at hcorr + have he : Real.exp (-(p + 8)) ≤ Real.exp (-p) / 8 := by + simpa only [neg_add_rev, sub_eq_add_neg, add_comm] using exp_sub_eight_le_eighth_exp (-p) + exact he.trans hcorr + have hlocal := hdet D (p + 8) (by linarith) w hw T (hT.mono (by linarith)) + (a : ℤ) len (fun x => f (x : ZMod N)) (fun x _ => hf _) hcorr' + have hpow := cyclicInterval_gowersNorm_lower_pow (a : ℤ) len (s + 1) hshort f + (Real.exp_nonneg (-(2 * p + 8))) (Real.exp_nonneg (-((p + 8 + c) ^ c))) hvolume hlocal + have hpower : Real.exp (-cyclicCutoffBudget s c p) ≤ + gowersNorm (s + 2) (fun x => f x * finiteIndicator (cyclicInterval (a : ZMod N) len) x) + ^ (2 ^ (s + 2)) := by + apply (cyclic_cutoff_exponential_product s c p).trans + norm_num only [Nat.cast_add, Nat.cast_one, Nat.add_assoc, add_assoc, Int.cast_natCast] at hpow ⊢ + exact hpow + have hcut := exp_neg_le_of_pow (gowersNorm_nonneg (s + 1) _) + (cyclicCutoffBudget_nonneg s c hp) (pow_ne_zero _ (by norm_num : (2 : ℕ) ≠ 0)) hpower + have htransfer := gowersNorm_transfer_cyclicInterval s f hf (a : ZMod N) len + (Real.exp_pos (-cyclicCutoffBudget s c p)) + (Real.exp_le_one_iff.mpr (neg_nonpos.mpr (cyclicCutoffBudget_nonneg s c hp))) hcut + exact (Real.exp_le_exp.mpr (neg_le_neg (hbudget p hp))).trans + ((cyclic_transfer_exponential s c p).trans htransfer) + +theorem exists_cyclicNiltestDetection.{u} (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ CyclicNiltestDetection.{u} s (fun p => (p + C) ^ C) := by + cases s with + | zero => + refine ⟨2, le_rfl, ?_⟩ + intro L _ _ d _ _ _ _ D p hp w hw T hT N _ f hf hc + have hb : 2 * p ≤ (p + (2 : ℕ)) ^ 2 := by + norm_num only [Nat.cast_ofNat] + nlinarith [sq_nonneg p] + exact (Real.exp_le_exp.mpr (neg_le_neg hb)).trans + (cyclicNiltestDetection_zero D p hp w hw T hT N f hf hc) + | succ s => exact exists_cyclicNiltestDetection_succ s + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicPairNiltestDetection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicPairNiltestDetection.lean new file mode 100644 index 0000000000000000000000000000000000000000..ebd601b8e14a306eee6c78e577a34336fed52bac --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/CyclicPairNiltestDetection.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.Progressions.Estimates.CyclicProductDetection + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct + +theorem cyclic_pair_niltest_detection.{u,v} + {s : ℕ} {F : ℝ → ℝ} (hdet : CyclicProductNiltestDetection.{u,0} s F) + {ι : Type v} {L : ι → Type u} [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + {d : ι → ℕ} [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] + [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + {p : ℝ} (hp : 2 ≤ p) (w : Fin 1 → ℕ) (hw : ∀ j, 0 < w j) + (T : ∀ i, (D i).Niltest w) (hT : ∀ i, (T i).ComplexityLE p) + (N : ℕ) [NeZero N] (f : ZMod N → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) + (i j : ι) (a : ZMod N) + (hc : Real.exp (-p) ≤ ‖𝔼 x, f x * (T i).eval (fun _ => (x.val : ℤ)) * + star ((T j).eval (fun _ => ((x + a).val : ℤ)))‖) : + Real.exp (-F p) ≤ gowersNorm (s + 1) f := by + let index : Fin 2 → ι := ![i, j] + let D' := fun k : Fin 2 => D (index k) + let U : ∀ k : Fin 2, (D' k).Niltest w := fun k => + if k = 0 then (T (index k)).conjugate else T (index k) + have hU : ∀ k, (U k).ComplexityLE p := by + intro k + dsimp only [U] + split_ifs <;> exact hT (index k) + let shifts : Fin 2 → ZMod N := ![0, a] + have heval (x : ZMod N) : + translatedCyclicProduct shifts (fun k n => (U k).eval (fun _ => n)) x = + star ((T i).eval (fun _ => (x.val : ℤ))) * + (T j).eval (fun _ => ((x + a).val : ℤ)) := by + simp [translatedCyclicProduct, Fin.prod_univ_two, shifts, U, D', index, add_comm] + rfl + have hcorr : Real.exp (-p) ≤ ‖finiteCorrelation Finset.univ f + (translatedCyclicProduct shifts (fun k n => (U k).eval (fun _ => n)))‖ := by + convert hc using 1 + congr 1 + unfold finiteCorrelation + apply Finset.expect_congr rfl + intro x _ + rw [heval] + simp only [star_mul, star_star] + ring + exact hdet D' p (by linarith) (by simpa using hp) w hw U hU N shifts f hf hcorr + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/DegreeRankBCH.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/DegreeRankBCH.lean new file mode 100644 index 0000000000000000000000000000000000000000..84a5786178ad3e29e4fb947b506268ac0479865d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/DegreeRankBCH.lean @@ -0,0 +1,70 @@ +import OAI.Combinatorics.Progressions.Polynomial.DegreeRankSunflower + +namespace OAI + +section + +namespace Erdos3.DegreeRankLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r : ℕ} + (F : DegreeRankLieFiltration L s r) + +def layerIdeal (d i : ℕ) : LieIdeal ℚ L := + { F.layer d i with + lie_mem := by + intro x y hy + have hx : x ∈ F.layer 1 0 := by simp only [F.one_eq_top, Submodule.mem_top] + exact F.lex_antitone (Or.inl (show d < 1 + d by omega)) (F.lie_mem hx hy) } + +@[simp] theorem mem_layerIdeal (d i : ℕ) (x : L) : + x ∈ F.layerIdeal d i ↔ x ∈ F.layer d i := Iff.rfl + +abbrev Group := F.associatedDegree.Group + +def subgroup (d i : ℕ) : Subgroup F.Group := + NilpotentLieBCHGroup.subgroup (F.layerIdeal d i).toLieSubalgebra + +@[simp] theorem mem_subgroup (d i : ℕ) (x : F.Group) : + x ∈ F.subgroup d i ↔ x.coord ∈ F.layer d i := Iff.rfl + +theorem subgroup_normal (d i : ℕ) : (F.subgroup d i).Normal := + NilpotentLieBCHGroup.subgroup_ideal_normal (F.layerIdeal d i) + +theorem subgroup_lex_antitone {d e i j : ℕ} (h : d < e ∨ d = e ∧ i ≤ j) : + F.subgroup e j ≤ F.subgroup d i := fun _ hx => F.lex_antitone h hx + +theorem subgroup_zero (d : ℕ) : F.subgroup d 0 = F.associatedDegree.subgroup d := by + ext x + rfl + +theorem subgroup_one (d : ℕ) : F.subgroup d 1 = F.associatedDegree.subgroup d := by + ext x + change x.coord ∈ F.layer d 1 ↔ x.coord ∈ F.layer d 0 + rw [F.rank_zero_eq_one] + +theorem subgroup_le_associatedDegree (d i : ℕ) : F.subgroup d i ≤ F.associatedDegree.subgroup d := + fun _ hx => F.layer_le_associatedDegree d i hx + +theorem subgroup_commutator_mem {d e i j : ℕ} {x y : F.Group} + (hx : x ∈ F.subgroup d i) (hy : y ∈ F.subgroup e j) : + x * y * x⁻¹ * y⁻¹ ∈ F.subgroup (d + e) (i + j) := + NilpotentLieBCHGroup.commutator_mem_ideal (F.layerIdeal (d + e) (i + j)) x y (F.lie_mem hx hy) + +theorem subgroup_eq_bot_of_past_top {d i : ℕ} (h : s < d ∨ s = d ∧ r < i) : + F.subgroup d i = ⊥ := by + apply bot_unique + intro x hx + apply Subgroup.mem_bot.mpr + apply NilpotentLieBCHGroup.ext + change x.coord = 0 + have hm := (F.mem_subgroup d i x).mp hx + simpa only [F.layer_eq_bot_of_past_top h, Submodule.mem_bot] using hm + +theorem subgroup_terminal : F.subgroup s (r + 1) = ⊥ := + F.subgroup_eq_bot_of_past_top (Or.inr ⟨rfl, by omega⟩) + +end Erdos3.DegreeRankLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/DegreeRankLieBrackets.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/DegreeRankLieBrackets.lean new file mode 100644 index 0000000000000000000000000000000000000000..58ebc6c5bc0f0f3e2d17ba2052c267456ca6b17a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/DegreeRankLieBrackets.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.Progressions.Polynomial.DegreeRankLayers + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem rank_span_lie_mem {d e r t : ℕ} {x y : L} + (hx : x ∈ Submodule.span ℚ (F.rankGenerators d r)) + (hy : y ∈ Submodule.span ℚ (F.rankGenerators e t)) : + ⁅x, y⁆ ∈ F.rankLayer (d + e) (r + t) := by + induction hx, hy using Submodule.span_induction₂ with + | mem_mem x y hx hy => + obtain ⟨i, hi, a, rfl⟩ := hx + obtain ⟨j, hj, b, rfl⟩ := hy + exact F.tree_eval_mem_rankLayer (a.bracket b) (Nat.add_le_add hi hj) + | zero_left y _ => rw [zero_lie]; exact Submodule.zero_mem _ + | zero_right x _ => rw [lie_zero]; exact Submodule.zero_mem _ + | add_left x y z _ _ _ hx hy => rw [add_lie]; exact Submodule.add_mem _ hx hy + | add_right x y z _ _ _ hx hy => rw [lie_add]; exact Submodule.add_mem _ hx hy + | smul_left c x y _ _ h => rw [smul_lie]; exact Submodule.smul_mem _ c h + | smul_right c x y _ _ h => rw [lie_smul]; exact Submodule.smul_mem _ c h + +theorem rankLayer_lie_mem {d e r t : ℕ} {x y : L} + (hx : x ∈ F.rankLayer d r) (hy : y ∈ F.rankLayer e t) : + ⁅x, y⁆ ∈ F.rankLayer (d + e) (r + t) := by + obtain ⟨a, ha, b, hb, rfl⟩ := Submodule.mem_sup.mp hx + obtain ⟨c, hc, z, hz, rfl⟩ := Submodule.mem_sup.mp hy + have hb' : b ∈ F.layer d := F.rankLayer_le_layer d r (F.span_rankGenerators_le_rankLayer d r hb) + have hz' : z ∈ F.layer e := F.rankLayer_le_layer e t (F.span_rankGenerators_le_rankLayer e t hz) + have hc' : c ∈ F.layer e := F.antitone (by omega) hc + have hleft {u v : L} (hu : u ∈ F.layer (d + 1)) (hv : v ∈ F.layer e) : + ⁅u, v⁆ ∈ F.rankLayer (d + e) (r + t) := by + apply F.layer_succ_le_rankLayer + simpa only [Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using F.lie_mem hu hv + have hright : ⁅b, c⁆ ∈ F.rankLayer (d + e) (r + t) := by + apply F.layer_succ_le_rankLayer + simpa only [Nat.add_assoc] using F.lie_mem hb' hc + simp only [add_lie, lie_add] + exact Submodule.add_mem _ (Submodule.add_mem _ (hleft ha hc') hright) + (Submodule.add_mem _ (hleft ha hz') (F.rank_span_lie_mem hb hz)) + +def rankIdeal (d r : ℕ) : LieIdeal ℚ L := + { F.rankLayer d r with + lie_mem := by + intro x y hy + apply F.layer_succ_le_rankLayer + have hx : x ∈ F.layer 1 := by simp only [F.one_eq_top, Submodule.mem_top] + simpa only [Nat.add_comm 1 d] using F.lie_mem hx (F.rankLayer_le_layer d r hy) } + +@[simp] theorem mem_rankIdeal (d r : ℕ) (x : L) : + x ∈ F.rankIdeal d r ↔ x ∈ F.rankLayer d r := Iff.rfl + +theorem rankIdeal_le_layerIdeal (d r : ℕ) : F.rankIdeal d r ≤ F.layerIdeal d := + F.rankLayer_le_layer d r + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/DiagramExternalNetMaskedNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/DiagramExternalNetMaskedNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..e09e7e5638d1937c6b21e27cda43c36919408b2d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/DiagramExternalNetMaskedNiltests.lean @@ -0,0 +1,254 @@ +import OAI.Combinatorics.Progressions.Estimates.DiagramNativeExternalNetMonotone + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct NNReal + +variable {L σ Ω G X : Type*} [LieRing L] [LieAlgebra ℚ L] + [Fintype Ω] [Fintype G] [Nonempty X] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (Q : RationalFilteredNilmanifold L s d) + +theorem exists_externalNet_masked_niltests + {cost : ℝ} (hcost : 0 ≤ cost) (hQ : Q.GeometryComplexityLE cost) + (K : ℝ≥0) (hK : (K : ℝ) ≤ Real.exp cost) + (n : ℕ) (hn : (n : ℝ) ≤ Real.exp cost) + (centers : Fin n → Q.Space → ℂ) + (hcap : ∀ i y, ‖centers i y‖ ≤ 1) + (hLip : letI := Q.metricSpace; ∀ i, LipschitzWith K (centers i)) + (hpositive : ∀ i y, (centers i y).im = 0 ∧ 0 ≤ (centers i y).re ∧ (centers i y).re ≤ 1) + (F : X → Q.Space → ℂ) {B ε δ : ℝ} + (hnet : ∀ x, ∃ i, ∀ y, ‖F x y - centers i y‖ ≤ ε) + (outer : FiniteProbabilityWeights Ω) (H : Finset Ω) (hH : 0 < outer.mass H) + (localLaw : Ω → FiniteProbabilityWeights G) + (physical : Ω → G → X) (globalWeight : X → ℝ) + {w : σ → ℕ} (localOrbits : Ω → Q.filtration.realification.PolynomialOrbit w) + (point : Ω → G → σ → ℤ) + (hB : 0 ≤ B) (hδ : 0 < δ) (herror : B * ε ≤ δ / 2) + (hweight : ∀ x, |globalWeight x| ≤ B) + (hscore : ∀ a ∈ H, δ ≤ (localLaw a).mean (fun z => + globalWeight (physical a z) * + (F (physical a z) (QuotientGroup.mk + (Q.filtration.realification.polynomialOrbitEval w (point a z) (localOrbits a)))).re)) : + ∃ (i : Fin n) (reference : Q.Niltest w) (localTests : Ω → Q.Niltest w) + (masked : X → ℝ) (H' : Finset Ω), + reference.orbit = 1 ∧ reference.observable = centers i ∧ + reference.normBound = 1 ∧ reference.lipBound = K ∧ + reference.UnitIntervalValued ∧ reference.ComplexityLE (cost + 3) ∧ + (∀ a, (localTests a).orbit = localOrbits a ∧ + (localTests a).observable = reference.observable ∧ + (localTests a).normBound = 1 ∧ (localTests a).lipBound = K ∧ + (localTests a).UnitIntervalValued ∧ (localTests a).ComplexityLE (cost + 3) ∧ + ∀ x, (localTests a).eval x = centers i (QuotientGroup.mk + (Q.filtration.realification.polynomialOrbitEval w x (localOrbits a)))) ∧ + (∀ x, masked x = if externalNetIndex F centers hnet x = i then globalWeight x else 0) ∧ + (∀ x, |masked x| ≤ B) ∧ H' ⊆ H ∧ 0 < outer.mass H' ∧ + outer.mass H / Real.exp cost ≤ outer.mass H' ∧ + ∀ a ∈ H', δ / (2 * Real.exp cost) ≤ (localLaw a).mean + (fun z => masked (physical a z) * ((localTests a).eval (point a z)).re) := by + classical + let : Nonempty (Fin n) := ⟨Classical.choose (hnet (Classical.choice inferInstance))⟩ + let lowerPoint : Ω → G → Q.Space := fun a z => QuotientGroup.mk + (Q.filtration.realification.polynomialOrbitEval w (point a z) (localOrbits a)) + obtain ⟨i, masked, H', hmask, hmaskcap, hsub, hpos, hmass, hretained⟩ := + exists_externalNet_common_mask F centers hnet outer H hH localLaw physical lowerPoint + globalWeight hB hδ herror hweight hscore + let reference := Q.externalNetNiltest (centers i) K (hcap i) (hLip i) + (1 : Q.filtration.realification.PolynomialOrbit w) + let localTests := fun a => Q.externalNetNiltest (centers i) K (hcap i) (hLip i) (localOrbits a) + have hnNat : 0 < n := by simpa only [Fintype.card_fin] using Fintype.card_pos (α := Fin n) + have hnp : (0 : ℝ) < n := by exact_mod_cast hnNat + have hmass' : outer.mass H / Real.exp cost ≤ outer.mass H' := by + apply le_trans _ hmass + simp only [Fintype.card_fin] + exact div_le_div_of_nonneg_left hH.le hnp hn + refine ⟨i, reference, localTests, masked, H', rfl, rfl, rfl, rfl, hpositive i, + Q.externalNetNiltest_complexity _ K (hcap i) (hLip i) 1 hcost hQ hK, + ?_, ?_, hmaskcap, hsub, hpos, hmass', ?_⟩ + · intro a + exact ⟨rfl, rfl, rfl, rfl, hpositive i, + Q.externalNetNiltest_complexity _ K (hcap i) (hLip i) (localOrbits a) hcost hQ hK, + fun _ => rfl⟩ + · intro x + rw [hmask] + split_ifs <;> rfl + · intro a ha + apply le_trans _ (hretained a ha) + simp only [Fintype.card_fin] + exact div_le_div_of_nonneg_left hδ.le (by positivity) + (mul_le_mul_of_nonneg_left hn (by norm_num)) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +universe u uO uR uIO uX uΩ uG uσ + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +attribute [local instance_reducible] optionLieSpace + +theorem DiagramNativeExternalNetConclusion.exists_masked_niltests (s t k : ℕ) +{H M L₀ ι : Type u} [Fintype ι] [DecidableEq ι] + {L : ι → Type u} + [LieRing H] [LieAlgebra ℚ H] [LieRing M] [LieAlgebra ℚ M] + [LieRing L₀] [LieAlgebra ℚ L₀] [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + [TopologicalSpace (ℝ ⊗[ℚ] H)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] H)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] H)] [T2Space (ℝ ⊗[ℚ] H)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + [TopologicalSpace (ℝ ⊗[ℚ] L₀)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L₀)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L₀)] [T2Space (ℝ ⊗[ℚ] L₀)] + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + {e f d₀ : ℕ} {d : ι → ℕ} + (E : RationalFilteredNilmanifold H t e) (D : RationalFilteredNilmanifold M t f) + (Q : RationalFilteredNilmanifold L₀ s d₀) + (F : ∀ i, RationalFilteredNilmanifold (L i) t (d i)) + (φ : H →ₗ⁅ℚ⁆ M) (ψ₀ : H →ₗ⁅ℚ⁆ L₀) (ψ : ∀ i, H →ₗ⁅ℚ⁆ L i) (p cost : ℝ) (q : ℕ) + (h : DiagramNativeExternalNetConclusion.{u, uO, uR, uIO} s t k E D Q F φ ψ₀ ψ p cost q) + (hcost : 0 ≤ cost) : + let Z₀ := pi F + letI := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + letI := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + letI := realification_moduleTopology_t2 Z₀.basis + ∃ Q' : RationalFilteredNilmanifold L₀ s d₀, + Q'.filtration = Q.filtration ∧ Q'.basis = Q.basis ∧ Q'.lattice ≤ Q.lattice ∧ + Q'.GeometryComplexityLE cost ∧ + ∃ Z : RationalFilteredNilmanifold (∀ i, L i) t (Fintype.card (Σ i, Fin (d i))), + Z.filtration = Z₀.filtration ∧ Z.basis = Z₀.basis ∧ Z.lattice ≤ Z₀.lattice ∧ + Z.GeometryComplexityLE cost ∧ + ∃ K : ℝ≥0, (K : ℝ) ≤ Real.exp cost ∧ + letI := Q'.metricSpace + letI := Z.metricSpace + let diagram := fun x : E.RealGroup => + ((QuotientGroup.mk (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := Q'.filtration.lowerCentralSeries_eq_bot) ψ₀ x) : Q'.Space), + (QuotientGroup.mk (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := Z.filtration.lowerCentralSeries_eq_bot) (liePiMap ψ) x) : Z.Space)) + ∀ {O : Type uO} {R : Type uR} {IO : Type uIO} [Fintype R] [Fintype IO] + (S : O → D.Space → ℂ) (oc : IO → O) (r : R → D.RealGroup) + (ℓ B : ℝ≥0) {ε : ℝ}, + (ℓ : ℝ) ≤ Real.exp p → 1 ≤ B → (B : ℝ) ≤ Real.exp ((p + 2) ^ k) → + 0 < ε → 1 / ε ≤ Real.exp p → + (Fintype.card IO : ℝ) ≤ Real.exp p → (Fintype.card R : ℝ) ≤ Real.exp p → + (∀ o, letI := D.metricSpace; LipschitzWith ℓ (S o)) → + (∀ o x, (S o x).im = 0 ∧ 0 ≤ (S o x).re ∧ (S o x).re ≤ 1) → + (∀ o, ∃ i, ∀ x, ‖S o x - S (oc i) x‖ ≤ ε / 3) → + (∀ j, (D.basis.baseChange ℝ).equivFun (r j).coord ∈ realDenominatorGrid q) → + let A := coordinateBox (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + (D.basis.baseChange ℝ) B + let frozen := fun o (a : A) j (x : E.RealGroup) => + S o (QuotientGroup.mk (a.val * realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) φ x * r j)) + ∃ n : ℕ, (n : ℝ) ≤ Real.exp cost ∧ + ∃ centers : Fin n → Q'.Space → ℂ, + (∀ i, LipschitzWith K (centers i)) ∧ + (∀ i y, (centers i y).im = 0 ∧ 0 ≤ (centers i y).re ∧ (centers i y).re ≤ 1) ∧ + (∀ i y, ‖centers i y‖ ≤ 1) ∧ + (∀ o a j x, positiveImageSlice diagram K (frozen o a j) + (diagram x).2 (diagram x).1 = frozen o a j x) ∧ + (∀ o a j z, ∃ i, ∀ y, + ‖positiveImageSlice diagram K (frozen o a j) z y - centers i y‖ ≤ ε) ∧ + ∀ {X : Type uX} [Nonempty X] + (observableAt : X → O) (leftAt : X → A) (rightAt : X → R) + (externalAt : X → Z.Space), + let physicalFunction := fun x y => positiveImageSlice diagram K + (frozen (observableAt x) (leftAt x) (rightAt x)) (externalAt x) y + ∀ {Ω : Type uΩ} {G : Type uG} {σ : Type uσ} [Fintype Ω] [Fintype G] + (outer : FiniteProbabilityWeights Ω) (retained : Finset Ω), + 0 < outer.mass retained → + ∀ (localLaw : Ω → FiniteProbabilityWeights G) + (physical : Ω → G → X) (globalWeight : X → ℝ) + (site : Ω → G → E.RealGroup) {w : σ → ℕ} + (localOrbits : Ω → Q'.filtration.realification.PolynomialOrbit w) + (point : Ω → G → σ → ℤ) {Bscore δ : ℝ}, + 0 ≤ Bscore → 0 < δ → Bscore * ε ≤ δ / 2 → + (∀ x, |globalWeight x| ≤ Bscore) → + (∀ a ∈ retained, ∀ z, (diagram (site a z)).1 = + QuotientGroup.mk (Q'.filtration.realification.polynomialOrbitEval w + (point a z) (localOrbits a))) → + (∀ a ∈ retained, ∀ z, (diagram (site a z)).2 = externalAt (physical a z)) → + (∀ a ∈ retained, δ ≤ (localLaw a).mean (fun z => + globalWeight (physical a z) * + (frozen (observableAt (physical a z)) (leftAt (physical a z)) + (rightAt (physical a z)) (site a z)).re)) → + ∃ (i : Fin n) (idx : X → Fin n) (reference : Q'.Niltest w) + (localTests : Ω → Q'.Niltest w) (masked : X → ℝ) (retained' : Finset Ω), + (∀ x y, ‖physicalFunction x y - centers (idx x) y‖ ≤ ε) ∧ + reference.orbit = 1 ∧ reference.observable = centers i ∧ + reference.normBound = 1 ∧ reference.lipBound = K ∧ + reference.UnitIntervalValued ∧ reference.ComplexityLE (cost + 3) ∧ + (∀ a, (localTests a).orbit = localOrbits a ∧ + (localTests a).observable = reference.observable ∧ + (localTests a).normBound = 1 ∧ (localTests a).lipBound = K ∧ + (localTests a).UnitIntervalValued ∧ (localTests a).ComplexityLE (cost + 3) ∧ + ∀ x, (localTests a).eval x = centers i (QuotientGroup.mk + (Q'.filtration.realification.polynomialOrbitEval w x (localOrbits a)))) ∧ + (∀ x, masked x = if idx x = i then globalWeight x else 0) ∧ + (∀ x, |masked x| ≤ Bscore) ∧ retained' ⊆ retained ∧ + 0 < outer.mass retained' ∧ + outer.mass retained / Real.exp cost ≤ outer.mass retained' ∧ + ∀ a ∈ retained', δ / (2 * Real.exp cost) ≤ (localLaw a).mean + (fun z => masked (physical a z) * ((localTests a).eval (point a z)).re) := by + let Z₀ := pi F + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + let := realification_moduleTopology_t2 Z₀.basis + obtain ⟨Q', hQF, hQb, hQle, hQgeom, Z, hZF, hZb, hZle, hZgeom, + K, hK, hnet⟩ := h + refine ⟨Q', hQF, hQb, hQle, hQgeom, Z, hZF, hZb, hZle, hZgeom, K, hK, ?_⟩ + let := Q'.metricSpace + let := Z.metricSpace + intro diagram O J IO _ _ S oc r ℓ Bbox ε hℓ hB hBbound hε hεinv hIO hJ hS hpositive hO hr + obtain ⟨n, hn, centers, hLip, hunit, hcap, heval, hcover⟩ := + hnet (O := O) (R := J) (IO := IO) S oc r ℓ Bbox hℓ hB hBbound hε hεinv hIO hJ + hS hpositive hO hr + refine ⟨n, hn, centers, hLip, hunit, hcap, heval, hcover, ?_⟩ + intro X _ observableAt leftAt rightAt externalAt physicalFunction Ω G σ _ _ + outer retained hretained localLaw physical globalWeight site w localOrbits point Bscore δ + hBscore hδ herror hweight hlower hexternal hscore + have hnetPhysical : ∀ x, ∃ i, ∀ y, ‖physicalFunction x y - centers i y‖ ≤ ε := + fun x => hcover (observableAt x) (leftAt x) (rightAt x) (externalAt x) + have hpoint (a : Ω) (ha : a ∈ retained) (z : G) : + physicalFunction (physical a z) (QuotientGroup.mk + (Q'.filtration.realification.polynomialOrbitEval w (point a z) (localOrbits a))) = + S (observableAt (physical a z)) (QuotientGroup.mk + ((leftAt (physical a z)).val * realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) φ (site a z) * r (rightAt (physical a z)))) := by + change positiveImageSlice diagram K _ (externalAt (physical a z)) _ = _ + rw [← hlower a ha z, ← hexternal a ha z] + exact heval (observableAt (physical a z)) (leftAt (physical a z)) + (rightAt (physical a z)) (site a z) + have hs : ∀ a ∈ retained, δ ≤ (localLaw a).mean (fun z => + globalWeight (physical a z) * (physicalFunction (physical a z) (QuotientGroup.mk + (Q'.filtration.realification.polynomialOrbitEval w (point a z) (localOrbits a)))).re) := by + intro a ha + simpa only [hpoint a ha] using hscore a ha + obtain ⟨i, reference, localTests, masked, retained', href, hobs, hnorm, hlip, + hunitref, hcomplex, hlocal, hmask, hmaskcap, hsub, hpos, hmass, hretainedScore⟩ := + Q'.exists_externalNet_masked_niltests hcost hQgeom K hK n hn centers hcap hLip hunit + physicalFunction hnetPhysical outer retained hretained localLaw physical globalWeight + localOrbits point hBscore hδ herror hweight hs + exact ⟨i, externalNetIndex physicalFunction centers hnetPhysical, reference, localTests, + masked, retained', externalNetIndex_approx physicalFunction centers hnetPhysical, + href, hobs, hnorm, hlip, hunitref, hcomplex, hlocal, + hmask, hmaskcap, hsub, hpos, hmass, hretainedScore⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/DiagramExternalPhysicalNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/DiagramExternalPhysicalNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..a22ddca8fcb93da3ea537eef04fbb51460991030 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/DiagramExternalPhysicalNiltests.lean @@ -0,0 +1,143 @@ +import OAI.Combinatorics.Progressions.Estimates.DiagramNativeExternalNetMonotone + +namespace OAI + +section + +universe u uO uR uIO uX uσ + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +attribute [local instance_reducible] optionLieSpace + +theorem DiagramNativeExternalNetConclusion.exists_physical_niltest_family (s t k : ℕ) +{H M L₀ ι : Type u} [Fintype ι] [DecidableEq ι] + {L : ι → Type u} + [LieRing H] [LieAlgebra ℚ H] [LieRing M] [LieAlgebra ℚ M] + [LieRing L₀] [LieAlgebra ℚ L₀] [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + [TopologicalSpace (ℝ ⊗[ℚ] H)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] H)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] H)] [T2Space (ℝ ⊗[ℚ] H)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + [TopologicalSpace (ℝ ⊗[ℚ] L₀)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L₀)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L₀)] [T2Space (ℝ ⊗[ℚ] L₀)] + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + {e f d₀ : ℕ} {d : ι → ℕ} + (E : RationalFilteredNilmanifold H t e) (D : RationalFilteredNilmanifold M t f) + (Q : RationalFilteredNilmanifold L₀ s d₀) + (F : ∀ i, RationalFilteredNilmanifold (L i) t (d i)) + (φ : H →ₗ⁅ℚ⁆ M) (ψ₀ : H →ₗ⁅ℚ⁆ L₀) (ψ : ∀ i, H →ₗ⁅ℚ⁆ L i) (p cost : ℝ) (q : ℕ) + (h : DiagramNativeExternalNetConclusion.{u, uO, uR, uIO} s t k E D Q F φ ψ₀ ψ p cost q) : + let Z₀ := pi F + letI := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + letI := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + letI := realification_moduleTopology_t2 Z₀.basis + ∃ Q' : RationalFilteredNilmanifold L₀ s d₀, + Q'.filtration = Q.filtration ∧ Q'.basis = Q.basis ∧ Q'.lattice ≤ Q.lattice ∧ + Q'.GeometryComplexityLE cost ∧ + ∃ Z : RationalFilteredNilmanifold (∀ i, L i) t (Fintype.card (Σ i, Fin (d i))), + Z.filtration = Z₀.filtration ∧ Z.basis = Z₀.basis ∧ Z.lattice ≤ Z₀.lattice ∧ + Z.GeometryComplexityLE cost ∧ + ∃ K : ℝ≥0, (K : ℝ) ≤ Real.exp cost ∧ + letI := Q'.metricSpace + letI := Z.metricSpace + let diagram := fun x : E.RealGroup => + ((QuotientGroup.mk (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := Q'.filtration.lowerCentralSeries_eq_bot) ψ₀ x) : Q'.Space), + (QuotientGroup.mk (realificationMap (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := Z.filtration.lowerCentralSeries_eq_bot) (liePiMap ψ) x) : Z.Space)) + ∀ {O : Type uO} {R : Type uR} {IO : Type uIO} [Fintype R] [Fintype IO] + (S : O → D.Space → ℂ) (oc : IO → O) (r : R → D.RealGroup) + (ℓ B : ℝ≥0) {ε : ℝ}, + (ℓ : ℝ) ≤ Real.exp p → 1 ≤ B → (B : ℝ) ≤ Real.exp ((p + 2) ^ k) → + 0 < ε → 1 / ε ≤ Real.exp p → + (Fintype.card IO : ℝ) ≤ Real.exp p → (Fintype.card R : ℝ) ≤ Real.exp p → + (∀ o, letI := D.metricSpace; LipschitzWith ℓ (S o)) → + (∀ o x, (S o x).im = 0 ∧ 0 ≤ (S o x).re ∧ (S o x).re ≤ 1) → + (∀ o, ∃ i, ∀ x, ‖S o x - S (oc i) x‖ ≤ ε / 3) → + (∀ j, (D.basis.baseChange ℝ).equivFun (r j).coord ∈ realDenominatorGrid q) → + let A := coordinateBox (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + (D.basis.baseChange ℝ) B + let frozen := fun o (a : A) j (x : E.RealGroup) => + S o (QuotientGroup.mk (a.val * realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) φ x * r j)) + ∃ n : ℕ, (n : ℝ) ≤ Real.exp cost ∧ + ∃ centers : Fin n → Q'.Space → ℂ, + (∀ i, LipschitzWith K (centers i)) ∧ + (∀ i y, (centers i y).im = 0 ∧ 0 ≤ (centers i y).re ∧ (centers i y).re ≤ 1) ∧ + (∀ i y, ‖centers i y‖ ≤ 1) ∧ + (∀ o a j x, positiveImageSlice diagram K (frozen o a j) + (diagram x).2 (diagram x).1 = frozen o a j x) ∧ + (∀ o a j z, ∃ i, ∀ y, + ‖positiveImageSlice diagram K (frozen o a j) z y - centers i y‖ ≤ ε) ∧ + ∀ {X : Type uX} [Nonempty X] + (observableAt : X → O) (leftAt : X → A) (rightAt : X → R) + (externalAt : X → Z.Space), + let physicalFunction := fun x y => positiveImageSlice diagram K + (frozen (observableAt x) (leftAt x) (rightAt x)) (externalAt x) y + (∀ x, LipschitzWith K (physicalFunction x)) ∧ + (∀ x y, (physicalFunction x y).im = 0 ∧ + 0 ≤ (physicalFunction x y).re ∧ (physicalFunction x y).re ≤ 1) ∧ + (∀ x y, ‖physicalFunction x y‖ ≤ 1) ∧ + (∀ x, ∃ i, ∀ y, ‖physicalFunction x y - centers i y‖ ≤ ε) ∧ + (∀ x (source : E.RealGroup), externalAt x = (diagram source).2 → + physicalFunction x (diagram source).1 = + frozen (observableAt x) (leftAt x) (rightAt x) source) ∧ + ∀ {σ : Type uσ} (w : σ → ℕ), + ∃ (tests : X → Q'.Niltest w) (centerTests : Fin n → Q'.Niltest w), + (∀ x, (tests x).orbit = 1 ∧ (tests x).observable = physicalFunction x ∧ + (tests x).normBound = 1 ∧ (tests x).lipBound = K ∧ + (tests x).UnitIntervalValued ∧ (tests x).ComplexityLE (cost + 3)) ∧ + (∀ i, (centerTests i).orbit = 1 ∧ (centerTests i).observable = centers i ∧ + (centerTests i).normBound = 1 ∧ (centerTests i).lipBound = K ∧ + (centerTests i).UnitIntervalValued ∧ (centerTests i).ComplexityLE (cost + 3)) ∧ + (∀ x, ∃ i, ∀ y, + ‖(tests x).observable y - (centerTests i).observable y‖ ≤ ε) ∧ + ∀ x (source : E.RealGroup), externalAt x = (diagram source).2 → + (tests x).observable (diagram source).1 = + frozen (observableAt x) (leftAt x) (rightAt x) source := by + let Z₀ := pi F + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + let := IsModuleTopology.isTopologicalAddGroup ℝ (ℝ ⊗[ℚ] (∀ i, L i)) + let := realification_moduleTopology_t2 Z₀.basis + obtain ⟨Q', hQF, hQb, hQle, hQgeom, Z, hZF, hZb, hZle, hZgeom, + K, hK, hnet⟩ := + DiagramNativeExternalNetConclusion.exists_physical_family s t k E D Q F φ ψ₀ ψ p cost q h + refine ⟨Q', hQF, hQb, hQle, hQgeom, Z, hZF, hZb, hZle, hZgeom, K, hK, ?_⟩ + let := Q'.metricSpace + let := Z.metricSpace + intro diagram O J IO _ _ S oc r ℓ Bbox ε hℓ hB hBbound hε hεinv hIO hJ hS hpositive hO hr + obtain ⟨n, hn, centers, hLip, hunit, hcap, heval, hcover, hphysical⟩ := + hnet (O := O) (R := J) (IO := IO) S oc r ℓ Bbox hℓ hB hBbound hε hεinv hIO hJ + hS hpositive hO hr + refine ⟨n, hn, centers, hLip, hunit, hcap, heval, hcover, ?_⟩ + intro X _ observableAt leftAt rightAt externalAt physicalFunction + obtain ⟨hfLip, hfunit, hfcap, hfnet, hrecon⟩ := + hphysical observableAt leftAt rightAt externalAt + refine ⟨hfLip, hfunit, hfcap, hfnet, hrecon, ?_⟩ + intro σ w + have hcost : 0 ≤ cost := (Nat.cast_nonneg d₀).trans hQgeom.1 + let tests : X → Q'.Niltest w := fun x => + Q'.externalNetNiltest (physicalFunction x) K (hfcap x) (hfLip x) 1 + let centerTests : Fin n → Q'.Niltest w := fun i => + Q'.externalNetNiltest (centers i) K (hcap i) (hLip i) 1 + refine ⟨tests, centerTests, ?_, ?_, hfnet, hrecon⟩ + · intro x + exact ⟨rfl, rfl, rfl, rfl, hfunit x, + Q'.externalNetNiltest_complexity (physicalFunction x) K (hfcap x) (hfLip x) 1 + hcost hQgeom hK⟩ + · intro i + exact ⟨rfl, rfl, rfl, rfl, hunit i, + Q'.externalNetNiltest_complexity (centers i) K (hcap i) (hLip i) 1 + hcost hQgeom hK⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/DualBCHDifferential.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/DualBCHDifferential.lean new file mode 100644 index 0000000000000000000000000000000000000000..25d4e92d3d296e79d5f1faeeb4528dcec4919e21 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/DualBCHDifferential.lean @@ -0,0 +1,146 @@ +import Mathlib.Tactic.Group +import OAI.Combinatorics.Progressions.Linear.DualLieAlgebra + +namespace OAI + + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +abbrev DualGroup (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) := + NilpotentLieBCHGroup (DualLieAlgebra L) s (dualLie_lowerCentralSeries_eq_bot hnil) + +noncomputable def dualConstantHom : NilpotentLieBCHGroup L s hnil →* DualGroup hnil := + map dualConstantLie + +noncomputable def dualBaseHom : DualGroup hnil →* NilpotentLieBCHGroup L s hnil := + map dualBaseLie + +noncomputable def dualTangentElement (x : L) : DualGroup hnil := ⟨dualInfinitesimal x⟩ + +@[simp] theorem dualBaseHom_constant (g : NilpotentLieBCHGroup L s hnil) : + dualBaseHom (dualConstantHom g) = g := by + apply ext + exact dualBaseLinear_constant g.coord + +@[simp] theorem dualBaseHom_tangent (x : L) : + dualBaseHom (dualTangentElement (hnil := hnil) x) = 1 := by + apply ext + exact dualBaseLinear_infinitesimal x + +theorem dualTangentElement_injective : Function.Injective (dualTangentElement (hnil := hnil)) := by + intro x y h + exact dualInfinitesimal_injective (congrArg coord h) + +@[simp] theorem dualTangentElement_zero : dualTangentElement (hnil := hnil) (0 : L) = 1 := by + apply ext + exact map_zero dualInfinitesimal + +theorem dualTangentElement_mul (x y : L) : + dualTangentElement (hnil := hnil) x * dualTangentElement y = dualTangentElement (x + y) := by + apply ext + change lieBCH s (dualInfinitesimal x) (dualInfinitesimal y) = dualInfinitesimal (x + y) + rw [lieBCH_eq_add_of_lie_eq_zero (dualLie_lowerCentralSeries_eq_bot hnil) (dualInfinitesimal_lie x y), + map_add] + +theorem dualTangentElement_neg (x : L) : + dualTangentElement (hnil := hnil) (-x) = (dualTangentElement x)⁻¹ := by + apply ext + exact map_neg dualInfinitesimal x + +theorem dualBaseHom_eq_one_iff (g : DualGroup hnil) : + dualBaseHom g = 1 ↔ g = dualTangentElement (dualTangentLinear g.coord) := by + constructor + · intro hg + have hb : dualBaseLinear g.coord = 0 := congrArg coord hg + apply ext + change g.coord = dualInfinitesimal (dualTangentLinear g.coord) + conv_lhs => rw [dualLie_decomposition g.coord, hb, map_zero, zero_add] + · intro hg + rw [hg, dualBaseHom_tangent] + +end Erdos3.NilpotentLieBCHGroup + + +namespace Erdos3.NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +noncomputable def dualAdjoint (g : NilpotentLieBCHGroup L s hnil) (x : L) : L := + dualTangentLinear + (dualConstantHom g * dualTangentElement x * (dualConstantHom g)⁻¹).coord + +theorem dualAdjoint_spec (g : NilpotentLieBCHGroup L s hnil) (x : L) : + dualConstantHom g * dualTangentElement x * (dualConstantHom g)⁻¹ = + dualTangentElement (dualAdjoint g x) := by + apply (dualBaseHom_eq_one_iff _).mp + simp only [map_mul, map_inv, dualBaseHom_constant, dualBaseHom_tangent, mul_one, mul_inv_cancel] + +theorem dualAdjoint_neg_spec (g : NilpotentLieBCHGroup L s hnil) (x : L) : + dualConstantHom g * dualTangentElement (-x) * (dualConstantHom g)⁻¹ = + dualTangentElement (-dualAdjoint g x) := by + calc + _ = (dualConstantHom g * dualTangentElement x * (dualConstantHom g)⁻¹)⁻¹ := by + rw [dualTangentElement_neg] + group + _ = _ := by rw [dualAdjoint_spec, dualTangentElement_neg] + +noncomputable def dualLogDerivative (z : DualGroup hnil) : L := + dualTangentLinear (z * (dualConstantHom (dualBaseHom z))⁻¹).coord + +theorem dualLogDerivative_spec (z : DualGroup hnil) : + z * (dualConstantHom (dualBaseHom z))⁻¹ = dualTangentElement (dualLogDerivative z) := by + apply (dualBaseHom_eq_one_iff _).mp + simp only [map_mul, map_inv, dualBaseHom_constant, mul_inv_cancel] + +theorem dualLogDerivative_factorization (z : DualGroup hnil) : + z = dualTangentElement (dualLogDerivative z) * dualConstantHom (dualBaseHom z) := by + calc + _ = (z * (dualConstantHom (dualBaseHom z))⁻¹) * dualConstantHom (dualBaseHom z) := by group + _ = _ := by rw [dualLogDerivative_spec] + +theorem dualLogDerivative_tangent_mul_constant (x : L) (g : NilpotentLieBCHGroup L s hnil) : + dualLogDerivative (dualTangentElement x * dualConstantHom g) = x := by + simp only [dualLogDerivative, map_mul, dualBaseHom_tangent, dualBaseHom_constant, one_mul, + mul_inv_cancel_right] + exact dualTangentLinear_infinitesimal x + +theorem dualLogDerivative_mul (z w : DualGroup hnil) : + dualLogDerivative (z * w) = dualLogDerivative z + dualAdjoint (dualBaseHom z) (dualLogDerivative w) := by + have h : z * w = + dualTangentElement (dualLogDerivative z + dualAdjoint (dualBaseHom z) (dualLogDerivative w)) * + dualConstantHom (dualBaseHom z * dualBaseHom w) := by + calc + _ = (dualTangentElement (dualLogDerivative z) * dualConstantHom (dualBaseHom z)) * + (dualTangentElement (dualLogDerivative w) * dualConstantHom (dualBaseHom w)) := + congrArg₂ (· * ·) (dualLogDerivative_factorization z) (dualLogDerivative_factorization w) + _ = dualTangentElement (dualLogDerivative z) * + (dualConstantHom (dualBaseHom z) * dualTangentElement (dualLogDerivative w) * + (dualConstantHom (dualBaseHom z))⁻¹) * + (dualConstantHom (dualBaseHom z) * dualConstantHom (dualBaseHom w)) := by group + _ = _ := by rw [dualAdjoint_spec, dualTangentElement_mul, map_mul] + rw [h, dualLogDerivative_tangent_mul_constant] + +theorem dualBCH_insertion_identity (z : DualGroup hnil) (e m : L) : + dualTangentElement (-e) * z * dualTangentElement (-m) * + (dualConstantHom (dualBaseHom z))⁻¹ = + dualTangentElement (dualLogDerivative z - e - dualAdjoint (dualBaseHom z) m) := by + calc + _ = dualTangentElement (-e) * + (dualTangentElement (dualLogDerivative z) * dualConstantHom (dualBaseHom z)) * + dualTangentElement (-m) * (dualConstantHom (dualBaseHom z))⁻¹ := + congrArg (fun a => dualTangentElement (-e) * a * dualTangentElement (-m) * + (dualConstantHom (dualBaseHom z))⁻¹) (dualLogDerivative_factorization z) + _ = dualTangentElement (-e) * dualTangentElement (dualLogDerivative z) * + (dualConstantHom (dualBaseHom z) * dualTangentElement (-m) * + (dualConstantHom (dualBaseHom z))⁻¹) := by group + _ = dualTangentElement (-e + dualLogDerivative z + -dualAdjoint (dualBaseHom z) m) := by + rw [dualAdjoint_neg_spec, dualTangentElement_mul, dualTangentElement_mul] + _ = _ := by congr 1; abel + +end Erdos3.NilpotentLieBCHGroup + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FactorwiseBCHCovers.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FactorwiseBCHCovers.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f3cd19a731e44a180f37fa580ffc69c8f375e05 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FactorwiseBCHCovers.lean @@ -0,0 +1,193 @@ +import Mathlib.Algebra.Group.Subgroup.Finite +import OAI.Combinatorics.Progressions.Estimates.ControlledSurjectiveReconstruction + +namespace OAI + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup + +variable {α : Type*} {M : α → Type*} [∀ a, LieRing (M a)] + [∀ a, LieAlgebra ℚ (M a)] {s : ℕ} + +noncomputable def piBCHSubgroup (F : ∀ a, NilpotentLieFiltration (M a) s) + (Δ : ∀ a, Subgroup (F a).Group) : Subgroup (NilpotentLieFiltration.pi F).Group := + ⨅ a, (Δ a).comap (map (hM := (F a).lowerCentralSeries_eq_bot) (liePiEval a)) + +theorem mem_piBCHSubgroup (F : ∀ a, NilpotentLieFiltration (M a) s) + (Δ : ∀ a, Subgroup (F a).Group) (g : (NilpotentLieFiltration.pi F).Group) : + g ∈ piBCHSubgroup F Δ ↔ ∀ a, (⟨g.coord a⟩ : (F a).Group) ∈ Δ a := by + simp only [piBCHSubgroup, Subgroup.mem_iInf, Subgroup.mem_comap] + rfl + +variable [Fintype α] {κ : α → Type*} [∀ a, Fintype (κ a)] + +theorem pi_basis_equivFun_symm_apply (f : ∀ a, Basis (κ a) ℚ (M a)) + (x : (Σ a, κ a) → ℚ) (a : α) : + (Pi.basis f).equivFun.symm x a = (f a).equivFun.symm (fun i => x ⟨a, i⟩) := by + apply (f a).equivFun.injective + funext i + change (Pi.basis f).equivFun ((Pi.basis f).equivFun.symm x) ⟨a, i⟩ = _ + simp only [LinearEquiv.apply_symm_apply] + +theorem piBCHSubgroup_coordinates (F : ∀ a, NilpotentLieFiltration (M a) s) + (f : ∀ a, Basis (κ a) ℚ (M a)) (Δ : ∀ a, Subgroup (F a).Group) + (x : (Σ a, κ a) → ℚ) : + x ∈ bchSubgroupCoordinates (Pi.basis f) (piBCHSubgroup F Δ) ↔ + ∀ a, (fun i => x ⟨a, i⟩) ∈ bchSubgroupCoordinates (f a) (Δ a) := by + change (⟨(Pi.basis f).equivFun.symm x⟩ : (NilpotentLieFiltration.pi F).Group) ∈ + piBCHSubgroup F Δ ↔ _ + rw [mem_piBCHSubgroup] + simp only [pi_basis_equivFun_symm_apply, bchSubgroupCoordinates, Set.mem_ofPred_eq] + +theorem piBCHSubgroup_inner_grid (F : ∀ a, NilpotentLieFiltration (M a) s) + (f : ∀ a, Basis (κ a) ℚ (M a)) (Δ : ∀ a, Subgroup (F a).Group) (m : ℕ) + (hin : ∀ a, scaledIntegerGrid m ⊆ bchSubgroupCoordinates (f a) (Δ a)) : + scaledIntegerGrid m ⊆ bchSubgroupCoordinates (Pi.basis f) (piBCHSubgroup F Δ) := by + rintro x ⟨z, rfl⟩ + apply (piBCHSubgroup_coordinates F f Δ _).mpr + intro a + exact hin a ⟨fun i => z ⟨a, i⟩, rfl⟩ + +theorem piBCHSubgroup_outer_grid (F : ∀ a, NilpotentLieFiltration (M a) s) + (f : ∀ a, Basis (κ a) ℚ (M a)) (Δ : ∀ a, Subgroup (F a).Group) (m : ℕ) + (hout : ∀ a, bchSubgroupCoordinates (f a) (Δ a) ⊆ denominatorGrid m) : + bchSubgroupCoordinates (Pi.basis f) (piBCHSubgroup F Δ) ⊆ denominatorGrid m := by + intro x hx + have h := (piBCHSubgroup_coordinates F f Δ x).mp hx + choose z hz using fun a => hout a (h a) + exact ⟨fun i => z i.1 i.2, fun i => hz i.1 i.2⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open NilpotentLieBCHGroup + +variable {α : Type*} {M : α → Type*} [∀ a, LieRing (M a)] [∀ a, LieAlgebra ℚ (M a)] + [DecidableEq α] {s : ℕ} + +def liePiSingle (a : α) : M a →ₗ⁅ℚ⁆ (∀ a, M a) where + toLinearMap := LinearMap.single ℚ M a + map_lie' {x y} := by + ext i + change Pi.single a ⁅x, y⁆ i = ⁅Pi.single a x i, Pi.single a y i⁆ + by_cases hi : i = a + · subst i + simp only [Pi.single_eq_same] + · simp only [Pi.single_eq_of_ne hi, lie_zero] + +noncomputable def bchPiEquiv (F : ∀ a, NilpotentLieFiltration (M a) s) : + (NilpotentLieFiltration.pi F).Group ≃* (∀ a, (F a).Group) where + toFun g a := ⟨g.coord a⟩ + invFun g := ⟨fun a => (g a).coord⟩ + left_inv g := by cases g; rfl + right_inv g := by funext a; exact NilpotentLieBCHGroup.ext rfl + map_mul' g h := by + funext a + exact (map (hnil := (NilpotentLieFiltration.pi F).lowerCentralSeries_eq_bot) + (hM := (F a).lowerCentralSeries_eq_bot) (liePiEval a)).map_mul g h + +noncomputable def bchPiSingle (F : ∀ a, NilpotentLieFiltration (M a) s) (a : α) : + (F a).Group →* (NilpotentLieFiltration.pi F).Group := + map (hnil := (F a).lowerCentralSeries_eq_bot) + (hM := (NilpotentLieFiltration.pi F).lowerCentralSeries_eq_bot) (liePiSingle a) + +theorem bchPiEquiv_single (F : ∀ a, NilpotentLieFiltration (M a) s) (a : α) (g : (F a).Group) : + bchPiEquiv F (bchPiSingle F a g) = Pi.mulSingle a g := by + funext i + apply NilpotentLieBCHGroup.ext + change Pi.single a g.coord i = ((Pi.mulSingle a g : ∀ i, (F i).Group) i).coord + by_cases hi : i = a + · subst i + simp only [Pi.single_eq_same, Pi.mulSingle_eq_same] + · simp only [Pi.single_eq_of_ne hi, Pi.mulSingle_eq_of_ne hi, coord_one] + +theorem bchPiSingle_eq_symm_mulSingle (F : ∀ a, NilpotentLieFiltration (M a) s) + (a : α) (g : (F a).Group) : + bchPiSingle F a g = (bchPiEquiv F).symm (Pi.mulSingle a g) := by + apply (bchPiEquiv F).injective + rw [bchPiEquiv_single, MulEquiv.apply_symm_apply] + +theorem piBCHSubgroup_le_of_factors [Finite α] (F : ∀ a, NilpotentLieFiltration (M a) s) + (Δ : ∀ a, Subgroup (F a).Group) (Λ : Subgroup (NilpotentLieFiltration.pi F).Group) + (h : ∀ a, Δ a ≤ Λ.comap (bchPiSingle F a)) : piBCHSubgroup F Δ ≤ Λ := by + intro g hg + let Λ' := Λ.comap (bchPiEquiv F).symm.toMonoidHom + have hp : bchPiEquiv F g ∈ Λ' := by + apply Subgroup.pi_mem_of_mulSingle_mem + intro a + change (bchPiEquiv F).symm (Pi.mulSingle a (bchPiEquiv F g a)) ∈ Λ + rw [← bchPiSingle_eq_symm_mulSingle] + exact h a ((mem_piBCHSubgroup F Δ g).mp hg a) + simpa only [Λ', Subgroup.mem_comap, MulEquiv.coe_toMonoidHom, MulEquiv.symm_apply_apply] using hp + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup + +variable {α : Type*} [Fintype α] [DecidableEq α] {M : α → Type*} + [∀ a, LieRing (M a)] [∀ a, LieAlgebra ℚ (M a)] {s : ℕ} + (F : ∀ a, NilpotentLieFiltration (M a) s) + {κ : α → Type*} [∀ a, Fintype (κ a)] (f : ∀ a, Basis (κ a) ℚ (M a)) + +theorem bchPiSingle_comap_inner_grid (Λ : Subgroup (NilpotentLieFiltration.pi F).Group) + (m : ℕ) (hΛ : scaledIntegerGrid m ⊆ bchSubgroupCoordinates (Pi.basis f) Λ) (a : α) : + scaledIntegerGrid m ⊆ bchSubgroupCoordinates (f a) (Λ.comap (bchPiSingle F a)) := by + classical + rintro x ⟨z, rfl⟩ + change bchPiSingle F a ⟨(f a).equivFun.symm ((m : ℚ) • fun i => (z i : ℚ))⟩ ∈ Λ + apply (bchSubgroupCoordinates_repr (Pi.basis f) Λ _).mp + apply hΛ + refine ⟨fun i : Σ a, κ a => (Pi.single a z : ∀ a, κ a → ℤ) i.1 i.2, ?_⟩ + ext ⟨i, j⟩ + change (f i).repr (Pi.single a ((f a).equivFun.symm ((m : ℚ) • fun k => (z k : ℚ))) i) j = _ + by_cases hi : i = a + · subst i + simp only [Pi.single_eq_same, Pi.smul_apply, smul_eq_mul] + change (f a).equivFun ((f a).equivFun.symm ((m : ℚ) • fun k => (z k : ℚ))) j = _ + rw [LinearEquiv.apply_symm_apply] + rfl + · simp only [Pi.single_eq_of_ne hi, map_zero, Finsupp.zero_apply, Pi.zero_apply, + Int.cast_zero, Pi.smul_apply, smul_eq_mul, mul_zero] + +theorem exists_factorwise_bch_covers (Γ : ∀ a, Subgroup (F a).Group) (l : α → ℕ) + (hl : ∀ a, 0 < l a) + (hΓin : ∀ a, scaledIntegerGrid (l a) ⊆ bchSubgroupCoordinates (f a) (Γ a)) + (hΓout : ∀ a, bchSubgroupCoordinates (f a) (Γ a) ⊆ denominatorGrid (l a)) + (Λ : Subgroup (NilpotentLieFiltration.pi F).Group) (m : ℕ) (hm : 0 < m) + (hΛ : scaledIntegerGrid m ⊆ bchSubgroupCoordinates (Pi.basis f) Λ) + {p : ℝ} (hp : 0 ≤ p) (hd : ∀ a, (Fintype.card (κ a) : ℝ) ≤ p) + (hlp : ∀ a, (l a : ℝ) ≤ Real.exp p) (hmp : (m : ℝ) ≤ Real.exp p) : + ∃ (Δ : ∀ a, Subgroup (F a).Group) (N : α → ℕ), + (∀ a, Δ a ≤ Γ a ∧ ((Δ a).subgroupOf (Γ a)).Characteristic ∧ + ((Δ a).subgroupOf (Γ a)).Normal ∧ ((Δ a).subgroupOf (Γ a)).FiniteIndex ∧ + ((Δ a).relIndex (Γ a) : ℝ) ≤ Real.exp (2 * p ^ 2) ∧ + 0 < N a ∧ (N a : ℝ) ≤ Real.exp ((p + 2) ^ 2) ∧ + scaledIntegerGrid (N a) ⊆ bchSubgroupCoordinates (f a) (Δ a) ∧ + bchSubgroupCoordinates (f a) (Δ a) ⊆ denominatorGrid (N a)) ∧ + piBCHSubgroup F Δ ≤ Λ := by + have h := fun a => (F a).exists_normal_cover_exp_quadratic (f a) (Γ a) + (Λ.comap (bchPiSingle F a)) (l a) m (hl a) hm (hΓin a) (hΓout a) + (bchPiSingle_comap_inner_grid F f Λ m hΛ a) hp (hd a) (hlp a) hmp + choose Δ htarget hΔ hchar hnormal hfinite hindex N hN hNb hin hout using h + exact ⟨Δ, N, fun a => ⟨hΔ a, hchar a, hnormal a, hfinite a, hindex a, + hN a, hNb a, hin a, hout a⟩, piBCHSubgroup_le_of_factors F Δ Λ htarget⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FilteredAdjointFirstBracket.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FilteredAdjointFirstBracket.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c62694e464ffd38cfe09383e4bb1b7c63a39c72 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FilteredAdjointFirstBracket.lean @@ -0,0 +1,464 @@ +import OAI.Combinatorics.Progressions.Linear.DualAdjointFiltration + +namespace OAI + +section + +namespace Erdos3 + +namespace NilpotentAlgebraFiltration + +variable {A : Type*} [Ring A] [Algebra ℚ A] (F : NilpotentAlgebraFiltration A 2) + +theorem mul_eq_zero_of_degrees {i j : ℕ} {a b : A} + (ha : a ∈ F.layer i) (hb : b ∈ F.layer j) (hij : 3 ≤ i + j) : a * b = 0 := by + have h := F.antitone hij (F.mul_mem ha hb) + simpa only [F.terminal, Submodule.mem_bot] using h + +theorem exp_eq_quadratic {a : A} (ha : a ∈ F.layer 1) : + IsNilpotent.exp a = 1 + a + (1 / 2 : ℚ) • a ^ 2 := by + rw [IsNilpotent.exp_eq_sum (F.pow_eq_zero le_rfl ha)] + norm_num [Finset.sum_range_succ] + +theorem nilpotentBCH_eq_quadratic {a b : A} (ha : a ∈ F.layer 1) + (hb : b ∈ F.layer 1) : + nilpotentBCH a b = a + b + (1 / 2 : ℚ) • (a * b - b * a) := by + have ha2 : a ^ 2 ∈ F.layer 2 := by simpa using F.pow_mem ha 2 + have hb2 : b ^ 2 ∈ F.layer 2 := by simpa using F.pow_mem hb 2 + have hab2 := F.mul_eq_zero_of_degrees ha hb2 (by decide) + have ha2b := F.mul_eq_zero_of_degrees ha2 hb (by decide) + have ha2b2 := F.mul_eq_zero_of_degrees ha2 hb2 (by decide) + let q := (1 / 2 : ℚ) • a ^ 2 + a * b + (1 / 2 : ℚ) • b ^ 2 + have hq : q ∈ F.layer 2 := + (F.layer 2).add_mem ((F.layer 2).add_mem ((F.layer 2).smul_mem _ ha2) + (F.mul_mem ha hb)) ((F.layer 2).smul_mem _ hb2) + have hab : a + b ∈ F.layer 1 := (F.layer 1).add_mem ha hb + have hp : IsNilpotent.exp a * IsNilpotent.exp b - 1 = a + b + q := by + rw [F.exp_eq_quadratic ha, F.exp_eq_quadratic hb] + simp only [add_mul, mul_add, one_mul, mul_one, smul_mul_assoc, mul_smul_comm, + hab2, ha2b, ha2b2, smul_zero] + dsimp [q] + module + have hq1 : q ∈ F.layer 1 := F.antitone (by decide) hq + have hp2 : (a + b + q) ^ 2 = (a + b) ^ 2 := by + rw [pow_two, add_mul (a + b) q (a + b + q), + mul_add (a + b) (a + b) q, mul_add q (a + b) q, + F.mul_eq_zero_of_degrees hab hq (by decide), + F.mul_eq_zero_of_degrees hq hab (by decide), + F.mul_eq_zero_of_degrees hq hq (by decide)] + simp only [add_zero, pow_two] + rw [nilpotentBCH, hp, + nilpotentLog_eq_sum (F.pow_eq_zero le_rfl ((F.layer 1).add_mem hab hq1))] + norm_num [Finset.sum_range_succ, hp2] + dsimp [q] + simp only [pow_two, add_mul, mul_add, smul_add, smul_sub] + module + +end NilpotentAlgebraFiltration + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] +attribute [local instance] LieRing.ofAssociativeRing + +theorem lieBCH_eq_quadratic_of_step_two {s : ℕ} (hs : 2 ≤ s) + (hnil : LieModule.lowerCentralSeries ℚ L L 2 = ⊥) (a b : L) : + lieBCH s a b = a + b + (1 / 2 : ℚ) • ⁅a, b⁆ := by + let x : Fin 2 → FreeLieAlgebra ℚ (Fin 2) := FreeLieAlgebra.of ℚ + let F := truncatedSeriesFiltration (A := FreeAlgebra ℚ (Fin 2)) 2 + have hx (i : Fin 2) : scaledFreeGenerator 2 i ∈ F.layer 1 := + scaledFreeGenerator_mem_layer 2 i + have h : scaledFreeLieEval 2 (lieBCH s (x 0) (x 1)) = + scaledFreeLieEval 2 (x 0 + x 1 + (1 / 2 : ℚ) • ⁅x 0, x 1⁆) := by + simp only [map_lieBCH, map_add, map_smul, LieHom.map_lie, x, scaledFreeLieEval_of] + rw [(F.extend hs).lieBCH_eq (hx 0) (hx 1)] + exact F.nilpotentBCH_eq_quadratic (hx 0) (hx 1) + have he := lie_lift_eq_of_scaledFreeLieEval_eq ![a, b] hnil h + simpa only [map_lieBCH, map_add, map_smul, LieHom.map_lie, x, + FreeLieAlgebra.lift_of_apply, Matrix.cons_val_zero, Matrix.cons_val_one] using he + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +def centralPairSpan (a b : L) : Submodule ℚ L := + Submodule.span ℚ {a, b, ⁅a, b⁆} + +theorem centralPairSpan_lie_mem (a b : L) (ha : ⁅a, ⁅a, b⁆⁆ = 0) + (hb : ⁅b, ⁅a, b⁆⁆ = 0) {x y : L} + (hx : x ∈ centralPairSpan a b) (hy : y ∈ centralPairSpan a b) : + ⁅x, y⁆ ∈ Submodule.span ℚ {⁅a, b⁆} := by + let W := Submodule.span ℚ {⁅a, b⁆} + have hc : ⁅a, b⁆ ∈ W := Submodule.subset_span (by simp) + have hba : ⁅b, a⁆ = -⁅a, b⁆ := (lie_skew b a).symm + have hca : ⁅⁅a, b⁆, a⁆ = 0 := by rw [← lie_skew ⁅a, b⁆ a, ha, neg_zero] + have hcb : ⁅⁅a, b⁆, b⁆ = 0 := by rw [← lie_skew ⁅a, b⁆ b, hb, neg_zero] + change x ∈ Submodule.span ℚ {a, b, ⁅a, b⁆} at hx + change y ∈ Submodule.span ℚ {a, b, ⁅a, b⁆} at hy + change ⁅x, y⁆ ∈ W + induction hx using Submodule.span_induction generalizing y with + | mem x hx => + induction hy using Submodule.span_induction with + | mem y hy => + simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy + rcases hx with rfl | rfl | rfl <;> rcases hy with rfl | rfl | rfl <;> + try simp only [lie_self, ha, hb, hba, hca, hcb] + all_goals first | exact W.zero_mem | exact hc | exact W.neg_mem hc + | zero => simpa only [lie_zero] using W.zero_mem + | add y z _ _ hy hz => simpa only [lie_add] using W.add_mem hy hz + | smul r y _ hy => simpa only [lie_smul] using W.smul_mem r hy + | zero => simpa only [zero_lie] using W.zero_mem + | add x z _ _ hx hz => simpa only [add_lie] using W.add_mem (hx hy) (hz hy) + | smul r x _ hx => simpa only [smul_lie] using W.smul_mem r (hx hy) + +theorem centralPairSpan_lie_eq_zero (a b : L) (ha : ⁅a, ⁅a, b⁆⁆ = 0) + (hb : ⁅b, ⁅a, b⁆⁆ = 0) {x y : L} + (hx : x ∈ centralPairSpan a b) (hy : y ∈ Submodule.span ℚ {⁅a, b⁆}) : + ⁅x, y⁆ = 0 := by + have hc : ⁅x, ⁅a, b⁆⁆ = 0 := by + change x ∈ Submodule.span ℚ {a, b, ⁅a, b⁆} at hx + induction hx using Submodule.span_induction with + | mem x hx => + simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hx + rcases hx with rfl | rfl | rfl + · exact ha + · exact hb + · exact lie_self _ + | zero => exact zero_lie _ + | add x y _ _ hx hy => rw [add_lie, hx, hy, add_zero] + | smul r x _ hx => rw [smul_lie, hx, smul_zero] + obtain ⟨r, rfl⟩ := Submodule.mem_span_singleton.mp hy + rw [lie_smul, hc, smul_zero] + +def centralPairSubalgebra (a b : L) (ha : ⁅a, ⁅a, b⁆⁆ = 0) + (hb : ⁅b, ⁅a, b⁆⁆ = 0) : LieSubalgebra ℚ L := + { centralPairSpan a b with + lie_mem' := fun hx hy => + (Submodule.span_mono (by simp)) (centralPairSpan_lie_mem a b ha hb hx hy) } + +theorem centralPairSubalgebra_step_two (a b : L) (ha : ⁅a, ⁅a, b⁆⁆ = 0) + (hb : ⁅b, ⁅a, b⁆⁆ = 0) : + let K := centralPairSubalgebra a b ha hb + LieModule.lowerCentralSeries ℚ K K 2 = ⊥ := by + intro K + have hcenter : LieModule.lowerCentralSeries ℚ K K 1 ≤ LieAlgebra.center ℚ K := by + rw [LieModule.lowerCentralSeries_succ, LieSubmodule.lie_le_iff] + intro x _ y _ + rw [LieModule.mem_maxTrivSubmodule] + intro z + apply Subtype.ext + exact centralPairSpan_lie_eq_zero a b ha hb z.property + (centralPairSpan_lie_mem a b ha hb x.property y.property) + apply bot_unique + rw [LieModule.lowerCentralSeries_succ, LieSubmodule.lie_le_iff] + intro x _ y hy + exact (LieSubmodule.mem_bot _).mpr ((hcenter hy) x) + +theorem lieBCH_eq_quadratic_of_central_commutator {s : ℕ} (hs : 2 ≤ s) + (a b : L) (ha : ⁅a, ⁅a, b⁆⁆ = 0) (hb : ⁅b, ⁅a, b⁆⁆ = 0) : + lieBCH s a b = a + b + (1 / 2 : ℚ) • ⁅a, b⁆ := by + let K := centralPairSubalgebra a b ha hb + have haK : a ∈ K := Submodule.subset_span (by simp) + have hbK : b ∈ K := Submodule.subset_span (by simp) + have h := congrArg K.incl (lieBCH_eq_quadratic_of_step_two hs + (centralPairSubalgebra_step_two a b ha hb) (⟨a, haK⟩ : K) (⟨b, hbK⟩ : K)) + simp only [map_lieBCH, map_add, map_smul, LieHom.map_lie] at h + exact h + +theorem lieBCH_conjugation_of_central_commutator {s : ℕ} (hs : 2 ≤ s) + (a b : L) (ha : ⁅a, ⁅a, b⁆⁆ = 0) (hb : ⁅b, ⁅a, b⁆⁆ = 0) : + lieBCH s (lieBCH s a b) (-a) = b + ⁅a, b⁆ := by + have hba : ⁅b, a⁆ = -⁅a, b⁆ := (lie_skew b a).symm + have hca : ⁅⁅a, b⁆, a⁆ = 0 := by rw [← lie_skew ⁅a, b⁆ a, ha, neg_zero] + have hc : ⁅a + b + (1 / 2 : ℚ) • ⁅a, b⁆, -a⁆ = ⁅a, b⁆ := by + simp only [add_lie, lie_neg, lie_self, smul_lie, hca, + smul_zero, hba, neg_neg, zero_add, add_zero] + have hu : ⁅a + b + (1 / 2 : ℚ) • ⁅a, b⁆, ⁅a, b⁆⁆ = 0 := by + simp only [add_lie, ha, hb, smul_lie, lie_self, smul_zero, add_zero] + rw [lieBCH_eq_quadratic_of_central_commutator hs a b ha hb, + lieBCH_eq_quadratic_of_central_commutator hs _ _ + (by rw [hc, hu]) (by rw [hc, neg_lie, ha, neg_zero]), hc] + module + +theorem lieBCH_conjugation_sub_mem {s : ℕ} (hs : 2 ≤ s) (I : LieIdeal ℚ L) + (a b : L) (ha : ⁅a, ⁅a, b⁆⁆ ∈ I) (hb : ⁅b, ⁅a, b⁆⁆ ∈ I) : + lieBCH s (lieBCH s a b) (-a) - (b + ⁅a, b⁆) ∈ I := by + apply (lieQuotientMap_eq_zero I _).mp + rw [map_sub, map_add, map_lieBCH, map_lieBCH, map_neg, LieHom.map_lie] + apply sub_eq_zero.mpr + apply lieBCH_conjugation_of_central_commutator hs + · rw [← LieHom.map_lie, ← LieHom.map_lie] + exact (lieQuotientMap_eq_zero I _).mpr ha + · rw [← LieHom.map_lie, ← LieHom.map_lie] + exact (lieQuotientMap_eq_zero I _).mpr hb + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def dualBaseSubalgebra (U : LieSubalgebra ℚ L) : + LieSubalgebra ℚ (DualLieAlgebra L) := + dualInvariantSubalgebra U ⊤ (fun _ _ _ _ => trivial) + +noncomputable def dualInvariantTangentIdeal (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) : LieIdeal ℚ (dualBaseSubalgebra U) := + { (dualBaseLinear.comp (dualBaseSubalgebra U).incl.toLinearMap).ker ⊓ + V.comap (dualTangentLinear.comp (dualBaseSubalgebra U).incl.toLinearMap) with + lie_mem := by + intro x y hy + change dualBaseLinear ⁅x.val, y.val⁆ = 0 ∧ dualTangentLinear ⁅x.val, y.val⁆ ∈ V + change dualBaseLinear y.val = 0 ∧ dualTangentLinear y.val ∈ V at hy + simp only [dualBaseLinear_lie, dualTangentLinear_lie, hy.1, lie_zero, add_zero] + exact ⟨trivial, hUV _ x.property.1 _ hy.2⟩ } + +@[simp] theorem mem_dualInvariantTangentIdeal (U : LieSubalgebra ℚ L) + (V : Submodule ℚ L) (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + (z : dualBaseSubalgebra U) : + z ∈ dualInvariantTangentIdeal U V hUV ↔ + dualBaseLinear z.val = 0 ∧ dualTangentLinear z.val ∈ V := Iff.rfl + +namespace NilpotentLieBCHGroup + +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem dualAdjoint_eq_add_lie (hs : 2 ≤ s) + (g : NilpotentLieBCHGroup L s hnil) (x : L) (hgx : ⁅g.coord, ⁅g.coord, x⁆⁆ = 0) : + dualAdjoint g x = x + ⁅g.coord, x⁆ := by + change dualTangentLinear + (lieBCH s (lieBCH s (dualConstantLie g.coord) (dualInfinitesimal x)) + (-dualConstantLie g.coord)) = _ + rw [lieBCH_conjugation_of_central_commutator hs _ _ + (by rw [dualConstant_infinitesimal_lie, dualConstant_infinitesimal_lie, hgx, map_zero]) + (by rw [dualConstant_infinitesimal_lie, dualInfinitesimal_lie]), + dualConstant_infinitesimal_lie, map_add, dualTangentLinear_infinitesimal, + dualTangentLinear_infinitesimal] + +theorem dualAdjoint_sub_first_bracket_mem (hs : 2 ≤ s) + (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + (g : NilpotentLieBCHGroup L s hnil) (hg : g.coord ∈ U) (x : L) + (hgx : ⁅g.coord, ⁅g.coord, x⁆⁆ ∈ V) : + dualAdjoint g x - (x + ⁅g.coord, x⁆) ∈ V := by + let S := dualBaseSubalgebra U + let I := dualInvariantTangentIdeal U V hUV + let a : S := ⟨dualConstantLie g.coord, by + change dualBaseLinear (dualConstantLie g.coord) ∈ U ∧ _ + exact ⟨by simpa only [dualBaseLinear_constant] using hg, by trivial⟩⟩ + let b : S := ⟨dualInfinitesimal x, by + change dualBaseLinear (dualInfinitesimal x) ∈ U ∧ _ + exact ⟨by simpa only [dualBaseLinear_infinitesimal] using U.zero_mem, by trivial⟩⟩ + have ha : ⁅a, ⁅a, b⁆⁆ ∈ I := by + change dualBaseLinear ⁅dualConstantLie g.coord, + ⁅dualConstantLie g.coord, dualInfinitesimal x⁆⁆ = 0 ∧ + dualTangentLinear ⁅dualConstantLie g.coord, + ⁅dualConstantLie g.coord, dualInfinitesimal x⁆⁆ ∈ V + rw [dualConstant_infinitesimal_lie, dualConstant_infinitesimal_lie, + dualBaseLinear_infinitesimal, dualTangentLinear_infinitesimal] + exact ⟨rfl, hgx⟩ + have hb : ⁅b, ⁅a, b⁆⁆ ∈ I := by + have he : ⁅b, ⁅a, b⁆⁆ = 0 := by + apply Subtype.ext + change ⁅dualInfinitesimal x, ⁅dualConstantLie g.coord, dualInfinitesimal x⁆⁆ = 0 + rw [dualConstant_infinitesimal_lie, dualInfinitesimal_lie] + rw [he] + exact I.zero_mem + have h := (lieBCH_conjugation_sub_mem hs I a b ha hb).2 + change dualTangentLinear (S.incl + (lieBCH s (lieBCH s a b) (-a) - (b + ⁅a, b⁆))) ∈ V at h + simp only [map_sub, map_add, map_lieBCH, map_neg, LieHom.map_lie] at h + change dualTangentLinear + (lieBCH s (lieBCH s (dualConstantLie g.coord) (dualInfinitesimal x)) + (-dualConstantLie g.coord)) - + (dualTangentLinear (dualInfinitesimal x) + + dualTangentLinear ⁅dualConstantLie g.coord, dualInfinitesimal x⁆) ∈ V at h + simp only [dualConstant_infinitesimal_lie, dualTangentLinear_infinitesimal] at h + exact h + +theorem dualAdjoint_current_bracket_relation (hs : 2 ≤ s) + (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + (g : NilpotentLieBCHGroup L s hnil) (hg : g.coord ∈ U) (r k p : L) + (hr : ⁅g.coord, r - k⁆ ∈ V) (hp : ⁅g.coord - p, k⁆ ∈ V) + (hk : ⁅g.coord, ⁅g.coord, k⁆⁆ ∈ V) : + ⁅p, k⁆ - (dualAdjoint g r - r) ∈ V := by + have hdouble : ⁅g.coord, ⁅g.coord, r⁆⁆ ∈ V := by + have h := V.add_mem (hUV _ hg _ hr) hk + simp only [lie_sub] at h + simpa only [sub_add_cancel] using h + have hmain := dualAdjoint_sub_first_bracket_mem hs U V hUV g hg r hdouble + have hdelta : ⁅g.coord, r⁆ - ⁅p, k⁆ ∈ V := by + have h := V.add_mem hr hp + simp only [lie_sub, sub_lie] at h + convert h using 1; abel + convert V.neg_mem (V.add_mem hmain hdelta) using 1; abel + +end NilpotentLieBCHGroup + +namespace NilpotentLieFiltration + +open NilpotentLieBCHGroup + +variable {s : ℕ} (F : NilpotentLieFiltration L s) + +theorem dualAdjoint_sub_first_bracket_mem_layer (hs : 2 ≤ s) {i j : ℕ} + (g : F.Group) (hg : g.coord ∈ F.layer i) (x : L) (hx : x ∈ F.layer j) : + dualAdjoint g x - (x + ⁅g.coord, x⁆) ∈ F.layer (2 * i + j) := by + apply dualAdjoint_sub_first_bracket_mem hs ⊤ (F.layerIdeal (2 * i + j)).toSubmodule + (fun _ _ _ hv => (F.layerIdeal _).lie_mem hv) g (by trivial) x + change ⁅g.coord, ⁅g.coord, x⁆⁆ ∈ F.layer (2 * i + j) + simpa only [two_mul, Nat.add_assoc] using F.lie_mem hg (F.lie_mem hg hx) + +end NilpotentLieFiltration +end Erdos3 + +end + +section + +namespace Erdos3 + +open VectorPolynomial +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def polynomialDualEval : VectorPolynomial Unit ℚ L →ₗ⁅ℚ⁆ DualLieAlgebra L where + toLinearMap := (MvPolynomial.aeval (fun _ : Unit => (DualNumber.eps : DualNumber ℚ))).toLinearMap.rTensor L + map_lie' {p q} := by + let e : VectorPolynomial Unit ℚ L →ₗ[ℚ] DualLieAlgebra L := + (MvPolynomial.aeval (fun _ : Unit => (DualNumber.eps : DualNumber ℚ))).toLinearMap.rTensor L + change e ⁅p, q⁆ = ⁅e p, e q⁆ + induction p using TensorProduct.inductionOn with + | tmul a x => + induction q using TensorProduct.inductionOn with + | tmul b y => + simp only [e, LieAlgebra.ExtendScalars.bracket_tmul, LinearMap.rTensor_tmul, + AlgHom.toLinearMap_apply, map_mul] + | add q q' hq hq' => + simp only [LieRing.lie_add, map_add, hq, hq'] + exact (LieRing.lie_add (e (a ⊗ₜ[ℚ] x)) (e q) (e q')).symm + | add p p' hp hp' => + simp only [LieRing.add_lie, map_add, hp, hp'] + exact (LieRing.add_lie (e p) (e p') (e q)).symm + +theorem polynomialDualEval_constant (x : L) : + polynomialDualEval (monomial (0 : Unit →₀ ℕ) x) = dualConstantLie x := by + change MvPolynomial.aeval (fun _ : Unit => (DualNumber.eps : DualNumber ℚ)) + (1 : MvPolynomial Unit ℚ) ⊗ₜ[ℚ] x = _ + rw [map_one] + rfl + +theorem polynomialDualEval_linear (x : L) : + polynomialDualEval (monomial (Finsupp.single () 1) x) = dualInfinitesimal x := by + change MvPolynomial.aeval (fun _ : Unit => (DualNumber.eps : DualNumber ℚ)) + (MvPolynomial.X ()) ⊗ₜ[ℚ] x = _ + rw [MvPolynomial.aeval_X] + rfl + +namespace NilpotentLieBCHGroup + +variable {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem conjugation_polynomial (g : NilpotentLieBCHGroup L s hnil) (x : L) : + lieBCH s (lieBCH s (monomial (R := ℚ) (0 : Unit →₀ ℕ) g.coord) + (monomial (Finsupp.single () 1) x)) (-monomial 0 g.coord) = + monomial (Finsupp.single () 1) (conjugationCoord g x) := by + apply sub_eq_zero.mp + apply eq_zero_of_eval_zero + intro a + simp only [map_sub, eval_lieBCH, map_neg, eval_monomial, + Finsupp.prod_zero_index, one_smul, Finsupp.prod_single_index, pow_zero, pow_one] + exact sub_eq_zero.mpr (conjugationCoord_rat_smul g (a ()) x) + +theorem dualAdjoint_eq_conjugationCoord (g : NilpotentLieBCHGroup L s hnil) (x : L) : + dualAdjoint g x = conjugationCoord g x := by + have he := congrArg (polynomialDualEval (L := L)) (conjugation_polynomial g x) + rw [map_lieBCH, map_lieBCH, map_neg, polynomialDualEval_constant, + polynomialDualEval_linear, polynomialDualEval_linear] at he + have ht := congrArg (dualTangentLinear (L := L)) he + exact ht.trans (dualTangentLinear_infinitesimal _) + +theorem conjugationCoord_eq_add_lie (hs : 2 ≤ s) + (g : NilpotentLieBCHGroup L s hnil) (x : L) (hx : ⁅g.coord, ⁅g.coord, x⁆⁆ = 0) : + conjugationCoord g x = x + ⁅g.coord, x⁆ := by + rw [← dualAdjoint_eq_conjugationCoord] + exact dualAdjoint_eq_add_lie hs g x hx + +end NilpotentLieBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open NilpotentLieBCHGroup + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + (U : LieSubalgebra ℚ L) (V : Submodule ℚ L) + (hUV : ∀ u ∈ U, ∀ v ∈ V, ⁅u, v⁆ ∈ V) + +include hUV + +theorem invariant_sup_layer (j : ℕ) : + ∀ u ∈ U, ∀ v ∈ V ⊔ F.layer j, ⁅u, v⁆ ∈ V ⊔ F.layer j := by + intro u hu v hv + obtain ⟨x, hx, y, hy, rfl⟩ := Submodule.mem_sup.mp hv + rw [lie_add] + exact (V ⊔ F.layer j).add_mem (Submodule.mem_sup_left (hUV _ hu _ hx)) + (Submodule.mem_sup_right ((F.layerIdeal j).lie_mem hy)) + +theorem lie_mem_invariant_sup_next_layer (j : ℕ) {u v : L} (hu : u ∈ U) + (hv : v ∈ V ⊔ F.layer j) : ⁅u, v⁆ ∈ V ⊔ F.layer (j + 1) := by + obtain ⟨x, hx, y, hy, rfl⟩ := Submodule.mem_sup.mp hv + rw [lie_add] + apply (V ⊔ F.layer (j + 1)).add_mem (Submodule.mem_sup_left (hUV _ hu _ hx)) + apply Submodule.mem_sup_right + have hu1 : u ∈ F.layer 1 := by rw [F.one_eq_top]; trivial + simpa only [Nat.add_comm 1 j] using F.lie_mem hu1 hy + +theorem adjoint_current_layer_relation (hs : 2 ≤ s) {j : ℕ} (hj : 1 ≤ j) + (g : F.Group) (hg : g.coord ∈ U) (r k p : L) + (hp : p ∈ F.layer (j - 1)) (hk : k ∈ F.layer 1) + (hr : r - k ∈ V ⊔ F.layer j) + (hlower : ⁅g.coord - p, k⁆ ∈ V ⊔ F.layer (j + 1)) : + ⁅p, k⁆ - (dualAdjoint g r - r) ∈ V ⊔ F.layer (j + 1) := by + have hW := F.invariant_sup_layer U V hUV (j + 1) + apply dualAdjoint_current_bracket_relation hs U (V ⊔ F.layer (j + 1)) hW g hg r k p + (F.lie_mem_invariant_sup_next_layer U V hUV j hg hr) hlower + have hpk : ⁅p, k⁆ ∈ F.layer j := by + simpa only [Nat.sub_add_cancel hj] using F.lie_mem hp hk + have hg1 : g.coord ∈ F.layer 1 := by rw [F.one_eq_top]; trivial + have hhigh : ⁅g.coord, ⁅p, k⁆⁆ ∈ F.layer (j + 1) := by + simpa only [Nat.add_comm 1 j] using F.lie_mem hg1 hpk + have h := (V ⊔ F.layer (j + 1)).add_mem (hW _ hg _ hlower) (Submodule.mem_sup_right hhigh) + simpa only [sub_lie, lie_sub, sub_add_cancel] using h + +theorem adjoint_current_layer_quotient (hs : 2 ≤ s) {j : ℕ} (hj : 1 ≤ j) + (g : F.Group) (hg : g.coord ∈ U) (r k p : L) + (hp : p ∈ F.layer (j - 1)) (hk : k ∈ F.layer 1) + (hr : r - k ∈ V ⊔ F.layer j) + (hlower : ⁅g.coord - p, k⁆ ∈ V ⊔ F.layer (j + 1)) + (t : L) (ht : t = dualAdjoint g r) : + (V ⊔ F.layer (j + 1)).mkQ ⁅p, k⁆ = (V ⊔ F.layer (j + 1)).mkQ (t - r) := by + rw [← sub_eq_zero, ← map_sub, Submodule.mkQ_apply, + Submodule.Quotient.mk_eq_zero, ht] + exact F.adjoint_current_layer_relation U V hUV hs hj g hg r k p hp hk hr hlower + +end Erdos3.NilpotentLieFiltration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FixedPatchNiltestFamily.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FixedPatchNiltestFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..aecb2007a964da01e7a4a569dbd5ee18dfcfea80 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FixedPatchNiltestFamily.lean @@ -0,0 +1,72 @@ +import OAI.Combinatorics.Progressions.Estimates.NormalizedFixedPatchFunction + +namespace OAI + +section + +namespace Erdos3 + +open scoped NNReal TensorProduct + +theorem exists_fixed_patch_niltest_family (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X Ω T : Type*} [Fintype X] [Fintype Ω] [Nonempty Ω] [Fintype T] + {d : ℕ} {w : Fin d → ℕ} + [Fintype (PolynomialShearIndex w)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)], + ∀ (A : Ω → PolynomialSlots X d w) (Φ : Ω → PatchKernel d) + (_hw : Monotone w) (_hpos : ∀ i, 1 ≤ w i) (hs : ∀ i, w i ≤ s) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (Fintype.card X : ℝ) ≤ p → + (∀ a, ((Φ a).lip : ℝ) ≤ Real.exp p) → + ∀ (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights T) (point : Ω → T → X → ℤ) + (score : Ω → T → ℝ), (∀ a t, |score a t| ≤ 1) → + (∀ a ∈ productive, Real.exp (-p) ≤ (localLaw a).mean (fun t => + score a t * ((A a).slots (fun i => (point a t i : ℝ))).patchValue (Φ a))) → + ∃ (F : (polynomialShearNilmanifold w s hs).Space → ℂ) + (tests : Ω → (polynomialShearNilmanifold w s hs).Niltest (fun _ : X => 1)) + (retained : Finset Ω), + (∀ a, (tests a).observable = F ∧ (tests a).UnitIntervalValued ∧ + (tests a).ComplexityLE ((p + 2) ^ C)) ∧ + retained ⊆ productive ∧ + outer.mass productive * Real.exp (-((p + 2) ^ C)) ≤ outer.mass retained ∧ + ∀ a ∈ retained, Real.exp (-((p + 2) ^ C)) ≤ (localLaw a).mean (fun t => + score a t * ((tests a).eval (point a t)).re) := by + obtain ⟨E, hE, hfixed⟩ := exists_unrestricted_fixed_weight_patch_function s + obtain ⟨B, hB, hnil⟩ := exists_mass_bounded_patch_niltest_budget s + let Q : Polynomial ℕ := (Polynomial.X + 2) ^ E + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget ((Q + 2) ^ B + Q) + refine ⟨C, hC, ?_⟩ + intro X Ω T _ _ _ _ d w _ _ _ _ _ A Φ hw hpos hs p hp hd hX hΦ outer productive localLaw point score hscore hpositive + let q := (p + 2) ^ E + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := le_power_budget hp (by omega) + have hbudget' : (q + 2) ^ B + q ≤ (p + 2) ^ C := by + simpa [Q, q, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + 2) ^ C := by + have : 0 ≤ (q + 2) ^ B := by positivity + linarith + obtain ⟨Ψ, form, localForm, retained, hLip, hMass, hretained, hprob, hlocal⟩ := + hfixed A Φ hw hpos hs p hp hd hX hΦ outer productive localLaw point score hscore hpositive + let P : PolynomialPatch X s d := ⟨w, hpos, hs, hw, form, Ψ⟩ + let M : ℝ≥0 := ⟨q, hq⟩ + have hPm (i) : realPolynomialMass (P.form.center i) ≤ M := hMass i + have hcomplex := hnil P M hPm q hq (hd.trans hpq) le_rfl hLip + have hcomplex' : (P.shearNiltest M hPm).ComplexityLE ((p + 2) ^ C) := + hcomplex.mono (by linarith) + obtain ⟨F, tests, htests, heval⟩ := P.exists_fixed_observable_family M hPm localForm hcomplex' + refine ⟨F, tests, retained, htests, hretained, ?_, ?_⟩ + · exact (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (neg_le_neg hqC)) + (outer.mass_nonneg productive)).trans hprob + · intro a ha + have h := (Real.exp_le_exp.mpr (neg_le_neg hqC)).trans (hlocal a ha) + simp_rw [heval] + exact h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FormalMarkedNiltestRestoration.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FormalMarkedNiltestRestoration.lean new file mode 100644 index 0000000000000000000000000000000000000000..8441af0a7d2c34f9e86c56ad632224ed25174fea --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FormalMarkedNiltestRestoration.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeFrozenMarkedLocalMark + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ κ L M : Type*} [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem exists_formal_marked_restoration + (T : D.Niltest w) (G : NilpotentLieFiltration M t) + (φ : L →ₗ⁅ℚ⁆ M) (hφ : ∀ j, ∀ x ∈ D.filtration.layer j, φ x ∈ G.layer j) + (c : Basis κ ℚ M) (v : κ → ℕ) + (hG : ∀ j, G.layer j = Submodule.span ℚ (c '' {k | j ≤ v k})) + (hsurj : ∀ j, ∀ y ∈ G.layer j, ∃ x ∈ D.filtration.layer j, φ x = y) + (q : G.realification.PolynomialOrbit w) : + ∃ restored : D.Niltest w, + restored.observable = T.observable ∧ + restored.normBound = T.normBound ∧ restored.lipBound = T.lipBound ∧ + (∀ p, restored.ComplexityLE p ↔ T.ComplexityLE p) ∧ + (restored.UnitIntervalValued ↔ T.UnitIntervalValued) ∧ + map ((realificationLieHom φ).toLinearMap.restrictScalars ℚ) restored.orbit.log = q.log ∧ + ∀ z : σ → ℤ, NilpotentLieBCHGroup.realificationMap + (hnil := D.filtration.lowerCentralSeries_eq_bot) (hM := G.lowerCentralSeries_eq_bot) φ + (D.filtration.realification.polynomialOrbitEval w z T.orbit) = + G.realification.polynomialOrbitEval w z q → + restored.eval z = T.eval z := by + obtain ⟨orbit, hmap, _, heval⟩ := D.filtration.exists_formal_marked_orbit_restoration + G φ hφ c v hG hsurj w T.orbit q + refine ⟨T.withOrbit orbit, rfl, rfl, rfl, fun _ => Iff.rfl, Iff.rfl, hmap, ?_⟩ + intro z hz + have hz' : NilpotentLieBCHGroup.realificationMap + (hnil := D.filtration.lowerCentralSeries_eq_bot) (hM := G.lowerCentralSeries_eq_bot) φ + (D.filtration.realification.polynomialOrbitRealEval w (fun i => (z i : ℝ)) T.orbit) = + G.realification.polynomialOrbitRealEval w (fun i => (z i : ℝ)) q := by + simpa only [NilpotentLieFiltration.polynomialOrbitRealEval_integer] using hz + have h := heval (fun i => (z i : ℝ)) hz' + simp only [NilpotentLieFiltration.polynomialOrbitRealEval_integer] at h + exact congrArg (fun g : D.RealGroup => T.observable (QuotientGroup.mk g)) h + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeDegreeRankNilmanifold.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeDegreeRankNilmanifold.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d21c890c883aa287b94776b1518c10cda43c89f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeDegreeRankNilmanifold.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.Progressions.Linear.NativeRankQuotientOrbit +import OAI.Combinatorics.Progressions.Sampling.ControlledIntegralGrid + +namespace OAI + +section + +namespace Erdos3 + +theorem scaledIntegerGrid_le_denominatorGrid {ι : Type*} (a b : ℕ) : + (scaledIntegerGrid a : Set (ι → ℚ)) ⊆ denominatorGrid b := by + rintro x ⟨z, rfl⟩ + exact ((show IntegralVector (fun i => (z i : ℚ)) from ⟨z, fun _ => rfl⟩).nat_smul a).nat_smul b + +namespace DegreeRankLieFiltration + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r d : ℕ} + (F : DegreeRankLieFiltration L s r) (b : Basis (Fin d) ℚ L) + (htail : ∀ i j, ∃ c ≤ d, F.layer i j = basisTail b c) + +noncomputable def tailLayerBasis (i j : ℕ) : + Basis (Fin (finrank ℚ (F.layer i j))) ℚ (F.layer i j) := + basisOfTail b (F.layer i j) (Classical.choose (htail i j)) (Classical.choose_spec (htail i j)).2 + +theorem tailLayerBasis_height (i j : ℕ) (a : Fin (finrank ℚ (F.layer i j))) (k : Fin d) : + RationalHeightLE (b.repr (F.tailLayerBasis b htail i j a : L) k) 1 := + basisOfTail_height b (F.layer i j) (Classical.choose (htail i j)) (Classical.choose_spec (htail i j)).2 a k + +variable (B : ℕ) (hB : 0 < B) + (hstable : ∀ x ∈ coordinateGridModule b B, ∀ y ∈ coordinateGridModule b B, + lieBCH s x y ∈ coordinateGridModule b B) + +noncomputable def integralGridNilmanifold : RationalFilteredNilmanifold L s d where + filtration := F.associatedDegree + basis := b + layerBasis i := F.tailLayerBasis b htail (i.val + 1) 0 + lattice := coordinateGridBCHSubgroup b B F.associatedDegree.lowerCentralSeries_eq_bot hstable + grid := B + grid_pos := hB + inner_grid := by + rw [coordinateGridBCHSubgroup_coordinates] + outer_grid := by + rw [coordinateGridBCHSubgroup_coordinates] + exact scaledIntegerGrid_le_denominatorGrid B B + +noncomputable def integralGridDegreeRank : + (F.integralGridNilmanifold b htail B hB hstable).DegreeRankStructure r where + filtration := F + associated := rfl + basis i j := F.tailLayerBasis b htail i.val j.val + +theorem integralGridNilmanifold_basis : (F.integralGridNilmanifold b htail B hB hstable).basis = b := rfl + +theorem integralGridDegreeRank_filtration : + (F.integralGridDegreeRank b htail B hB hstable).filtration = F := rfl + +theorem integralGridNilmanifold_coordinates : + bchSubgroupCoordinates (F.integralGridNilmanifold b htail B hB hstable).basis + (F.integralGridNilmanifold b htail B hB hstable).lattice = scaledIntegerGrid B := + coordinateGridBCHSubgroup_coordinates b B F.associatedDegree.lowerCentralSeries_eq_bot hstable + +theorem integralGridDegreeRank_complexity {p : ℝ} (hp : 0 ≤ p) (hd : (d : ℝ) ≤ p) + (hgrid : (B : ℝ) ≤ Real.exp p) + (hc : ∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ p) : + (F.integralGridDegreeRank b htail B hB hstable).ComplexityLE p := by + have hone : ((1 : ℕ) : ℝ) ≤ Real.exp p := by + simpa only [Nat.cast_one, Real.exp_zero] using Real.exp_le_exp.mpr hp + refine ⟨⟨hd, hgrid, hc, ?_⟩, ?_⟩ + · intro i a k + exact rationalLogHeight_le_of_height (F.tailLayerBasis_height b htail (i.val + 1) 0 a k) hone + · intro i j a k + exact rationalLogHeight_le_of_height (F.tailLayerBasis_height b htail i.val j.val a k) hone + +end DegreeRankLieFiltration + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_controlled_nilmanifold_of_tails (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (L : Type*) [LieRing L] [LieAlgebra ℚ L] (r d : ℕ) + (F : DegreeRankLieFiltration L s r) (b : Basis (Fin d) ℚ L), + (∀ i j, ∃ c ≤ d, F.layer i j = basisTail b c) → + ∀ (l : ℕ), 0 < l → ∀ (p : ℝ), 0 ≤ p → (d : ℝ) ≤ p → (l : ℝ) ≤ Real.exp p → + (∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ p) → + p ≤ (p + C) ^ C ∧ ∃ D : RationalFilteredNilmanifold L s d, + ∃ R : D.DegreeRankStructure r, D.basis = b ∧ R.filtration = F ∧ + l ∣ D.grid ∧ bchSubgroupCoordinates D.basis D.lattice = scaledIntegerGrid D.grid ∧ + R.ComplexityLE ((p + C) ^ C) := by + obtain ⟨C, hC, hgrid⟩ := exists_controlled_integral_grid s + refine ⟨C, hC, ?_⟩ + intro L _ _ r d F b htail l hl p hp hd hlp hc + obtain ⟨hpC, B, hB, hdiv, hBbound, hstable⟩ := hgrid L (Fin d) b + F.associatedDegree.lowerCentralSeries_eq_bot l hl p hp + (by simpa only [Fintype.card_fin] using hd) hlp hc + refine ⟨hpC, F.integralGridNilmanifold b htail B hB hstable, + F.integralGridDegreeRank b htail B hB hstable, rfl, rfl, hdiv, + F.integralGridNilmanifold_coordinates b htail B hB hstable, ?_⟩ + exact F.integralGridDegreeRank_complexity b htail B hB hstable + (hp.trans hpC) (hd.trans hpC) hBbound (fun i j k => (hc i j k).trans hpC) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped Matrix + +theorem exists_free_degree_rank_nilmanifold (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (X : Type*) [Fintype X] (r : ℕ) (hr : r ≤ s) + (w : X → ℕ) (hw : ∀ x, 0 < w x) (l : ℕ), 0 < l → + ∀ (p : ℝ), 0 ≤ p → (Fintype.card X : ℝ) ≤ p → (l : ℝ) ≤ Real.exp p → + ∃ D : RationalFilteredNilmanifold (FreeDegreeRankLieAlgebra X s r w hw) s + (finrank ℚ (FreeDegreeRankLieAlgebra X s r w hw)), + ∃ R : D.DegreeRankStructure r, + R.filtration = FreeDegreeRankLieAlgebra.filtration X s r w hw hr ∧ + R.ComplexityLE ((p + C) ^ C) ∧ IsCentralLieBasis D.basis ∧ l ∣ D.grid ∧ + bchSubgroupCoordinates D.basis D.lattice = scaledIntegerGrid D.grid ∧ + (∀ x ∈ FreeNilpotentLieAlgebra.treeGenerators X s, ∀ i, + rationalLogHeight (D.basis.repr (FreeDegreeRankLieAlgebra.projection X s r w hw x) i) ≤ (p + C) ^ C) ∧ + ∃ e : Basis (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) ℚ (FreeNilpotentLieAlgebra X s), + (∀ i, e i ∈ FreeNilpotentLieAlgebra.treeGenerators X s) ∧ + (finrank ℚ (FreeNilpotentLieAlgebra X s) : ℝ) ≤ (p + C) ^ C ∧ + ∃ S : Matrix (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) + (Fin (finrank ℚ (FreeDegreeRankLieAlgebra X s r w hw))) ℚ, + LinearMap.toMatrix e D.basis (FreeDegreeRankLieAlgebra.projection X s r w hw).toLinearMap * S = 1 ∧ + ∀ i j, rationalLogHeight (S i j) ≤ (p + C) ^ C := by + obtain ⟨a, _, hfree⟩ := exists_adapted_free_degree_rank_model s + obtain ⟨c, _, hnative⟩ := exists_controlled_nilmanifold_of_tails s + let Q : Polynomial ℕ := Polynomial.X + (Polynomial.X + Polynomial.C a) ^ a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Q + (Q + Polynomial.C c) ^ c) + refine ⟨C, hC, ?_⟩ + intro X _ r hr w hw l hl p hp hX hlp + let B := (p + a) ^ a + let T := p + B + have hB : 0 ≤ B := by dsimp only [B]; positivity + have hBT : B ≤ T := le_add_of_nonneg_left hp + have hpT : p ≤ T := le_add_of_nonneg_right hB + have hT : 0 ≤ T := hp.trans hpT + have hsum : T + (T + c) ^ c ≤ (p + C) ^ C := by + simpa [Q, T, B, Polynomial.eval₂_pow] using hbudget p hp + have hTC : T ≤ (p + C) ^ C := + (le_add_of_nonneg_right (by positivity : 0 ≤ (T + c) ^ c)).trans hsum + have hNC : (T + c) ^ c ≤ (p + C) ^ C := (le_add_of_nonneg_left hT).trans hsum + obtain ⟨hdim, b, hcentral, htail, hstructure, htree, e, he, hdim₀, S, hS, hSH⟩ := + hfree X r hr w hw p hp hX + obtain ⟨_, D, R, hb, hR, hdiv, hcoords, hcomplexity⟩ := + hnative (FreeDegreeRankLieAlgebra X s r w hw) r _ + (FreeDegreeRankLieAlgebra.filtration X s r w hw hr) b htail l hl T hT + (hdim.trans hBT) (hlp.trans (Real.exp_le_exp.mpr hpT)) + (fun i j k => (hstructure i j k).trans hBT) + refine ⟨D, R, hR, hcomplexity.mono R hNC, ?_, hdiv, hcoords, ?_, e, he, + hdim₀.trans (hBT.trans hTC), S, ?_, fun i j => (hSH i j).trans (hBT.trans hTC)⟩ + · rw [hb] + exact hcentral + · intro x hx i + rw [hb] + exact (htree x hx i).trans (hBT.trans hTC) + · rw [hb] + exact hS + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeNilpotentLieAlgebra.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeNilpotentLieAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..265ea2ea5d45598ccef5e3e2b804f59e32a65f81 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeNilpotentLieAlgebra.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.Progressions.Estimates.QuotientInducedMark + +namespace OAI + +section + +namespace Erdos3 + +variable (X : Type*) (s : ℕ) + +def FreeNilpotentLieAlgebra := + FreeLieAlgebra ℚ X ⧸ LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s + +namespace FreeNilpotentLieAlgebra + +noncomputable instance instLieRing : LieRing (FreeNilpotentLieAlgebra X s) := + inferInstanceAs (LieRing (FreeLieAlgebra ℚ X ⧸ + LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s)) + +noncomputable instance instLieAlgebra : LieAlgebra ℚ (FreeNilpotentLieAlgebra X s) := + inferInstanceAs (LieAlgebra ℚ (FreeLieAlgebra ℚ X ⧸ + LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s)) + +noncomputable def mk : FreeLieAlgebra ℚ X →ₗ⁅ℚ⁆ FreeNilpotentLieAlgebra X s := + lieQuotientMap (LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s) + +theorem mk_surjective : Function.Surjective (mk X s) := + lieQuotientMap_surjective _ + +theorem mk_eq_zero (x : FreeLieAlgebra ℚ X) : + mk X s x = 0 ↔ x ∈ LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s := + lieQuotientMap_eq_zero _ x + +theorem lowerCentralSeries_eq_bot : + LieModule.lowerCentralSeries ℚ (FreeNilpotentLieAlgebra X s) (FreeNilpotentLieAlgebra X s) s = ⊥ := by + rw [← LieIdeal.lowerCentralSeries_map_eq s (mk_surjective X s), LieIdeal.map_eq_bot_iff] + intro x hx + exact (mk_eq_zero X s x).mpr hx + +noncomputable def of (x : X) : FreeNilpotentLieAlgebra X s := mk X s (FreeLieAlgebra.of ℚ x) + +variable {X s} {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem lowerCentralSeries_le_lift_ker (f : X → L) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) : + LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s ≤ + (FreeLieAlgebra.lift ℚ f).ker := by + apply LieIdeal.map_eq_bot_iff.mp + apply bot_unique + rw [← hnil] + exact LieIdeal.map_lowerCentralSeries_le s + +noncomputable def lift (f : X → L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) : + FreeNilpotentLieAlgebra X s →ₗ⁅ℚ⁆ L := + lieQuotientDescend _ (FreeLieAlgebra.lift ℚ f) (lowerCentralSeries_le_lift_ker f hnil) + +theorem lift_mk (f : X → L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (x : FreeLieAlgebra ℚ X) : lift f hnil (mk X s x) = FreeLieAlgebra.lift ℚ f x := rfl + +@[simp] theorem lift_of (f : X → L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) (x : X) : + lift f hnil (of X s x) = f x := FreeLieAlgebra.lift_of_apply _ _ + +theorem hom_ext {f g : FreeNilpotentLieAlgebra X s →ₗ⁅ℚ⁆ L} + (h : ∀ x, f (of X s x) = g (of X s x)) : f = g := by + have heq : f.comp (mk X s) = g.comp (mk X s) := FreeLieAlgebra.hom_ext h + apply LieHom.ext + intro x + obtain ⟨y, rfl⟩ := mk_surjective X s x + exact LieHom.congr_fun heq y + +theorem mk_truncation (x : FreeLieAlgebra ℚ X) : + mk X s (freeLieTruncation s x) = mk X s x := by + have h := lift_freeLieTruncation ((mk X s) ∘ FreeLieAlgebra.of ℚ) + (lowerCentralSeries_eq_bot X s) x + simpa only [FreeLieAlgebra.lift_comp_of] using h + +end FreeNilpotentLieAlgebra + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeNilpotentSourceBounds.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeNilpotentSourceBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..8296f33fbf83af593adbc8d12bf578377d6c863e --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeNilpotentSourceBounds.lean @@ -0,0 +1,476 @@ +import Mathlib.LinearAlgebra.Dimension.StrongRankCondition +import OAI.Combinatorics.Progressions.Geometry.EmbeddingCoordinateHeight +import OAI.Combinatorics.Progressions.Linear.FreeLieTruncationKernel + +namespace OAI + +section + +namespace Erdos3 + +variable (X : Type*) (s : ℕ) + +noncomputable def freeLieBoundedCoordinates : FreeLieAlgebra ℚ X →ₗ[ℚ] (BoundedFreeWord X s → ℚ) where + toFun p w := (freeLieWordExpansion p).coeff w.val + map_add' p q := by ext w; simp + map_smul' c p := by ext w; simp + +theorem freeLieBoundedCoordinates_eq_zero_iff (p : FreeLieAlgebra ℚ X) : + freeLieBoundedCoordinates X s p = 0 ↔ + p ∈ LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s := by + rw [freeLie_lowerCentralSeries_iff_low_coeff_zero] + constructor + · intro hp w hw + exact congrFun hp ⟨w, hw⟩ + · intro hp + ext w + exact hp w.val w.property + +namespace FreeNilpotentLieAlgebra + +noncomputable def coordinates : FreeNilpotentLieAlgebra X s →ₗ[ℚ] (BoundedFreeWord X s → ℚ) := + (LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s).toSubmodule.liftQ + (freeLieBoundedCoordinates X s) + (fun p hp => (freeLieBoundedCoordinates_eq_zero_iff X s p).mpr hp) + +theorem coordinates_mk (p : FreeLieAlgebra ℚ X) : + coordinates X s (mk X s p) = freeLieBoundedCoordinates X s p := rfl + +theorem coordinates_injective : Function.Injective (coordinates X s) := by + intro x y hxy + obtain ⟨a, rfl⟩ := mk_surjective X s x + obtain ⟨b, rfl⟩ := mk_surjective X s y + apply sub_eq_zero.mp + rw [← map_sub] + apply (mk_eq_zero X s (a - b)).mpr + apply (freeLieBoundedCoordinates_eq_zero_iff X s (a - b)).mp + rw [map_sub] + exact sub_eq_zero.mpr hxy + +instance finite [Fintype X] : Module.Finite ℚ (FreeNilpotentLieAlgebra X s) := + Module.Finite.of_injective (coordinates X s) (coordinates_injective X s) + +theorem finrank_le [Fintype X] : + Module.finrank ℚ (FreeNilpotentLieAlgebra X s) ≤ (s + 1) * (Fintype.card X + 1) ^ s := by + have h := LinearMap.finrank_le_finrank_of_injective (coordinates_injective X s) + calc + _ ≤ Module.finrank ℚ (BoundedFreeWord X s → ℚ) := h + _ = Fintype.card (BoundedFreeWord X s) := by simp + _ ≤ _ := boundedFreeWord_card_le + +end FreeNilpotentLieAlgebra + +end Erdos3 + +end + +section + +namespace Erdos3 + +theorem wordTruncation_lie {X : Type*} (s : ℕ) (p q : WordPolynomial X) : + wordTruncation s ⁅p, q⁆ = wordTruncation s ⁅wordTruncation s p, wordTruncation s q⁆ := by + simp only [wordPolynomial_lie, map_sub] + exact congrArg₂ (· - ·) (wordTruncation_mul s p q) (wordTruncation_mul s q p) + +namespace FreeNilpotentLieAlgebra + +variable (X : Type*) (s : ℕ) + +noncomputable def expansion : FreeNilpotentLieAlgebra X s →ₗ[ℚ] WordPolynomial X := + (LieModule.lowerCentralSeries ℚ (FreeLieAlgebra ℚ X) (FreeLieAlgebra ℚ X) s).toSubmodule.liftQ + ((wordTruncation s).comp freeLieWordExpansion.toLinearMap) + (fun p hp => (wordTruncation_eq_zero_iff s _).mpr + ((freeLie_lowerCentralSeries_iff_low_coeff_zero s p).mp hp)) + +theorem expansion_mk (p : FreeLieAlgebra ℚ X) : + expansion X s (mk X s p) = wordTruncation s (freeLieWordExpansion p) := rfl + +theorem expansion_coeff (x : FreeNilpotentLieAlgebra X s) (w : BoundedFreeWord X s) : + (expansion X s x).coeff w.val = coordinates X s x w := by + obtain ⟨p, rfl⟩ := mk_surjective X s x + rw [expansion_mk, wordTruncation_coeff, ite_eq_left w.property] + rfl + +theorem expansion_injective : Function.Injective (expansion X s) := by + intro x y hxy + apply coordinates_injective X s + funext w + rw [← expansion_coeff, ← expansion_coeff, hxy] + +theorem expansion_truncated (x : FreeNilpotentLieAlgebra X s) : + wordTruncation s (expansion X s x) = expansion X s x := by + obtain ⟨p, rfl⟩ := mk_surjective X s x + exact wordTruncation_idempotent s _ + +theorem expansion_lie (x y : FreeNilpotentLieAlgebra X s) : + expansion X s ⁅x, y⁆ = wordTruncation s ⁅expansion X s x, expansion X s y⁆ := by + obtain ⟨a, rfl⟩ := mk_surjective X s x + obtain ⟨b, rfl⟩ := mk_surjective X s y + rw [← LieHom.map_lie, expansion_mk, LieHom.map_lie, expansion_mk, expansion_mk] + exact wordTruncation_lie s _ _ + +theorem expansion_of (hs : 1 ≤ s) (x : X) : + expansion X s (of X s x) = MonoidAlgebra.single (FreeSemigroup.of x) 1 := by + rw [of, expansion_mk, freeLieWordExpansion_of, wordTruncation_single] + exact ite_eq_left hs + +end FreeNilpotentLieAlgebra + +end Erdos3 + +end + +section + +namespace Erdos3.FreeNilpotentLieAlgebra + +variable (X : Type*) (s : ℕ) + +theorem mk_tree_eq_zero_of_length_gt (a : FreeMagma X) (ha : s < a.length) : + mk X s (lieTreeEval (FreeLieAlgebra.of ℚ) a) = 0 := by + apply (mk_eq_zero X s _).mpr + apply (freeLie_lowerCentralSeries_iff_low_coeff_zero s _).mpr + intro w hw + rw [freeLieWordExpansion_tree] + by_contra h + have he := commutatorTree_homogeneous a w h + omega + +noncomputable def treeGenerators [Fintype X] : Finset (FreeNilpotentLieAlgebra X s) := by + classical + exact ((finiteLieTrees X s).filter (fun a => a.length ≤ s)).image + (fun a => mk X s (lieTreeEval (FreeLieAlgebra.of ℚ) a)) + +theorem treeGenerators_span [Fintype X] : + Submodule.span ℚ (treeGenerators X s : Set (FreeNilpotentLieAlgebra X s)) = ⊤ := by + classical + apply top_unique + intro x _ + obtain ⟨p, rfl⟩ := mk_surjective X s x + apply freeLie_linear_induction + (fun p => mk X s p ∈ Submodule.span ℚ (treeGenerators X s : Set (FreeNilpotentLieAlgebra X s))) + · simpa only [map_zero] using (Submodule.zero_mem + (Submodule.span ℚ (treeGenerators X s : Set (FreeNilpotentLieAlgebra X s)))) + · intro p q hp hq + rw [map_add] + exact Submodule.add_mem _ hp hq + · intro c p hp + rw [map_smul] + exact Submodule.smul_mem _ c hp + · intro a + by_cases ha : a.length ≤ s + · apply Submodule.subset_span + exact Finset.mem_image.mpr ⟨a, Finset.mem_filter.mpr + ⟨mem_finiteLieTrees_of_length_le X a ha, ha⟩, rfl⟩ + · rw [mk_tree_eq_zero_of_length_gt X s a (Nat.lt_of_not_ge ha)] + exact Submodule.zero_mem _ + +theorem treeGenerators_card_le [Fintype X] : + (treeGenerators X s).card ≤ (Fintype.card X + 2) ^ (3 ^ s) := by + classical + exact (Finset.card_image_le.trans (Finset.card_filter_le _ _)).trans + (finiteLieTrees_card_le X s) + +end Erdos3.FreeNilpotentLieAlgebra + +end + +section + +namespace Erdos3.FreeNilpotentLieAlgebra + +open Module + +variable (X : Type*) [Fintype X] (s : ℕ) + +theorem treeGenerators_coordinate_height (x : FreeNilpotentLieAlgebra X s) + (hx : x ∈ treeGenerators X s) (w : BoundedFreeWord X s) : + RationalHeightLE (coordinates X s x w) ((2 * (s + 1)) ^ s) := by + classical + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx + have hlen := (Finset.mem_filter.mp ha).2 + change RationalHeightLE ((freeLieWordExpansion (lieTreeEval (FreeLieAlgebra.of ℚ) a)).coeff w.val) _ + rw [freeLieWordExpansion_tree] + exact (commutatorTree_coefficient_height s a w.val w.property).mono + (Nat.pow_le_pow_right (by omega) (by omega)) + +theorem treeGenerators_coordinate_integral (x : FreeNilpotentLieAlgebra X s) + (hx : x ∈ treeGenerators X s) (w : BoundedFreeWord X s) : + ∃ z : ℤ, (z : ℚ) = coordinates X s x w ∧ z.natAbs ≤ (2 * (s + 1)) ^ s := by + classical + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx + have hlen := (Finset.mem_filter.mp ha).2 + obtain ⟨z, hz, hbound⟩ := commutatorTree_coefficient_integral s a w.val w.property + refine ⟨z, ?_, hbound.trans (Nat.pow_le_pow_right (by omega) (by omega))⟩ + change (z : ℚ) = (freeLieWordExpansion (lieTreeEval (FreeLieAlgebra.of ℚ) a)).coeff w.val + rwa [freeLieWordExpansion_tree] + +theorem exists_bounded_tree_basis : + ∃ b : Basis (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) ℚ (FreeNilpotentLieAlgebra X s), + (∀ i, b i ∈ treeGenerators X s) ∧ + (∀ i w, RationalHeightLE (coordinates X s (b i) w) ((2 * (s + 1)) ^ s)) ∧ + ∀ i w, ∃ z : ℤ, (z : ℚ) = coordinates X s (b i) w ∧ z.natAbs ≤ (2 * (s + 1)) ^ s := by + have hex := Submodule.exists_fun_fin_finrank_span_eq ℚ + (treeGenerators X s : Set (FreeNilpotentLieAlgebra X s)) + rw [treeGenerators_span, finrank_top] at hex + obtain ⟨v, hv, hspan, hlin⟩ := hex + let b := Basis.mk hlin (le_of_eq hspan.symm) + have hb (i) : b i ∈ treeGenerators X s := by + simpa only [b, Basis.mk_apply, Finset.mem_coe] using hv i + exact ⟨b, hb, fun i w => treeGenerators_coordinate_height X s (b i) (hb i) w, + fun i w => treeGenerators_coordinate_integral X s (b i) (hb i) w⟩ + +end Erdos3.FreeNilpotentLieAlgebra + +end + +section + +namespace Erdos3.FreeNilpotentLieAlgebra + +open Module + +variable {X ι L : Type*} [Fintype X] [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s H : ℕ} (e : Basis ι ℚ L) (f : X → L) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + +theorem lift_treeGenerator_height + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hf : ∀ x i, RationalHeightLE (e.repr (f x) i) H) + (x : FreeNilpotentLieAlgebra X s) (hx : x ∈ treeGenerators X s) (i : ι) : + RationalHeightLE (e.repr (lift f hnil x) i) (lieTreeHeight (Fintype.card ι) H s) := by + classical + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hx + rw [lift_mk, lift_lieTreeEval] + exact finiteLieTrees_coordinate_height e f hc hf s a (Finset.mem_filter.mp ha).1 i + +theorem lift_basis_matrix_height + (b : Basis (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) ℚ (FreeNilpotentLieAlgebra X s)) + (hb : ∀ j, b j ∈ treeGenerators X s) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + (hf : ∀ x i, RationalHeightLE (e.repr (f x) i) H) (i j) : + RationalHeightLE (LinearMap.toMatrix b e (lift f hnil).toLinearMap i j) + (lieTreeHeight (Fintype.card ι) H s) := by + rw [LinearMap.toMatrix_apply] + exact lift_treeGenerator_height e f hnil hc hf (b j) (hb j) i + +theorem lift_basis_matrix_logHeight + (b : Basis (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) ℚ (FreeNilpotentLieAlgebra X s)) + (hb : ∀ j, b j ∈ treeGenerators X s) {p : ℝ} (hp : 0 ≤ p) + (hd : (Fintype.card ι : ℝ) ≤ p) + (hc : ∀ i j k, rationalLogHeight (lieStructureConstants e i j k) ≤ p) + (hf : ∀ x i, rationalLogHeight (e.repr (f x) i) ≤ p) (i j) : + rationalLogHeight (LinearMap.toMatrix b e (lift f hnil).toLinearMap i j) ≤ + (p + 3) ^ (6 * s + 2) := by + have hraw := lift_basis_matrix_height e f hnil b hb + (fun i j k => rationalHeightLE_ceil_exp (hc i j k)) + (fun x i => rationalHeightLE_ceil_exp (hf x i)) i j + apply rationalLogHeight_le_of_height hraw + have h := lieTreeHeight_le_exp (Fintype.card ι) ⌈Real.exp p⌉₊ s + (p := p + 1) (by linarith) (by linarith) (ceil_exp_le_exp_add_one hp) + simpa only [show p + 1 + 2 = p + 3 by ring] using h + +end Erdos3.FreeNilpotentLieAlgebra + +end + +section + +namespace Erdos3.FreeNilpotentLieAlgebra + +open Module +attribute [local instance] LieRing.ofAssociativeRing + +variable (X : Type*) [Fintype X] (s : ℕ) + +theorem treeGenerators_lie_or_zero {x y : FreeNilpotentLieAlgebra X s} + (hx : x ∈ treeGenerators X s) (hy : y ∈ treeGenerators X s) : + ⁅x, y⁆ = 0 ∨ ⁅x, y⁆ ∈ treeGenerators X s := by + classical + obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hx + obtain ⟨b, _, rfl⟩ := Finset.mem_image.mp hy + have he : ⁅mk X s (lieTreeEval (FreeLieAlgebra.of ℚ) a), + mk X s (lieTreeEval (FreeLieAlgebra.of ℚ) b)⁆ = + mk X s (lieTreeEval (FreeLieAlgebra.of ℚ) (a * b)) := (LieHom.map_lie _ _ _).symm + rw [he] + by_cases hab : (a * b).length ≤ s + · right + exact Finset.mem_image.mpr ⟨a * b, Finset.mem_filter.mpr + ⟨mem_finiteLieTrees_of_length_le X (a * b) hab, hab⟩, rfl⟩ + · exact Or.inl (mk_tree_eq_zero_of_length_gt X s (a * b) (Nat.lt_of_not_ge hab)) + +theorem treeGenerators_lie_coordinate_height {x y : FreeNilpotentLieAlgebra X s} + (hx : x ∈ treeGenerators X s) (hy : y ∈ treeGenerators X s) (w : BoundedFreeWord X s) : + RationalHeightLE (coordinates X s ⁅x, y⁆ w) ((2 * (s + 1)) ^ s) := by + rcases treeGenerators_lie_or_zero X s hx hy with hzero | hmem + · rw [hzero, map_zero, Pi.zero_apply] + have hH : 1 ≤ (2 * (s + 1)) ^ s := one_le_pow₀ (by omega) + simpa only [RationalHeightLE, Rat.num_zero, Int.natAbs_zero, Rat.den_zero, Nat.zero_le, + true_and] using hH + · exact treeGenerators_coordinate_height X s _ hmem w + +theorem exists_bounded_structure_basis : + let n := Fintype.card (BoundedFreeWord X s) + let d := finrank ℚ (FreeNilpotentLieAlgebra X s) + let H := (2 * (s + 1)) ^ s + ∃ b : Basis (Fin d) ℚ (FreeNilpotentLieAlgebra X s), + (∀ i, b i ∈ treeGenerators X s) ∧ + (∀ i w, RationalHeightLE (coordinates X s (b i) w) H) ∧ + ∀ i j k, RationalHeightLE (lieStructureConstants b i j k) + ((n + 1) * (rationalSolveHeight d H * H) ^ n) := by + dsimp only + obtain ⟨b, hb, hcoord, _⟩ := exists_bounded_tree_basis X s + refine ⟨b, hb, hcoord, ?_⟩ + intro i j k + have h := embedding_basis_coordinate_height b (Pi.basisFun ℚ (BoundedFreeWord X s)) + (coordinates X s) (coordinates_injective X s) + (show 1 ≤ (2 * (s + 1)) ^ s from one_le_pow₀ (by omega)) + (fun w l => by simpa only [Pi.basisFun_repr] using hcoord l w) + ⁅b i, b j⁆ (fun w => by simpa only [Pi.basisFun_repr] using + treeGenerators_lie_coordinate_height X s (hb i) (hb j) w) k + simpa only [Fintype.card_fin, lieStructureConstants] using h + +end Erdos3.FreeNilpotentLieAlgebra + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_bounded_free_nilpotent_model (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (X : Type*) [Fintype X] (p : ℝ), + 0 ≤ p → (Fintype.card X : ℝ) ≤ p → + (finrank ℚ (FreeNilpotentLieAlgebra X s) : ℝ) ≤ (p + C) ^ C ∧ + (Fintype.card (BoundedFreeWord X s) : ℝ) ≤ (p + C) ^ C ∧ + ∃ b : Basis (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) ℚ (FreeNilpotentLieAlgebra X s), + (∀ i, b i ∈ FreeNilpotentLieAlgebra.treeGenerators X s) ∧ + (∀ i w, rationalLogHeight (FreeNilpotentLieAlgebra.coordinates X s (b i) w) ≤ (p + C) ^ C) ∧ + ∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ (p + C) ^ C := by + let H := (2 * (s + 1)) ^ s + let Q : Polynomial ℕ := Polynomial.C (s + 1) * (Polynomial.X + 1) ^ s + + Polynomial.C H + Polynomial.X + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Q + (Q + 2) ^ 8) + refine ⟨C, hC, ?_⟩ + intro X _ p hp hX + let A := ((s : ℝ) + 1) * (p + 1) ^ s + let T := A + (H : ℝ) + p + 2 + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hAT : A ≤ T := by + exact (le_add_of_nonneg_right (Nat.cast_nonneg H)).trans + ((le_add_of_nonneg_right hp).trans (le_add_of_nonneg_right (by norm_num))) + have hT : 0 ≤ T := hA.trans hAT + have hHT : (H : ℝ) ≤ T := by + exact (le_add_of_nonneg_left hA).trans + ((le_add_of_nonneg_right hp).trans (le_add_of_nonneg_right (by norm_num))) + have hsum : T + (T + 2) ^ 8 ≤ (p + C) ^ C := by + simpa [Q, T, A, Polynomial.eval₂_pow] using hbudget p hp + have hTC : T ≤ (p + C) ^ C := + (le_add_of_nonneg_right (by positivity : 0 ≤ (T + 2) ^ 8)).trans hsum + have hBC : (T + 2) ^ 8 ≤ (p + C) ^ C := (le_add_of_nonneg_left hT).trans hsum + have hsize : ((s : ℝ) + 1) * ((Fintype.card X : ℝ) + 1) ^ s ≤ A := + mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (by positivity) (add_le_add hX (le_refl (1 : ℝ))) s) (by positivity) + have hn : (Fintype.card (BoundedFreeWord X s) : ℝ) ≤ A := by + calc + _ ≤ ((s : ℝ) + 1) * ((Fintype.card X : ℝ) + 1) ^ s := by + exact_mod_cast (boundedFreeWord_card_le (X := X) (s := s)) + _ ≤ _ := hsize + have hd : (finrank ℚ (FreeNilpotentLieAlgebra X s) : ℝ) ≤ A := by + calc + _ ≤ ((s : ℝ) + 1) * ((Fintype.card X : ℝ) + 1) ^ s := by + exact_mod_cast (FreeNilpotentLieAlgebra.finrank_le X s) + _ ≤ _ := hsize + have hHexp : (H : ℝ) ≤ Real.exp T := hHT.trans + ((le_add_of_nonneg_right (by norm_num : (0 : ℝ) ≤ 1)).trans (Real.add_one_le_exp T)) + obtain ⟨b, hb, hcoord, hstructure⟩ := FreeNilpotentLieAlgebra.exists_bounded_structure_basis X s + refine ⟨hd.trans (hAT.trans hTC), hn.trans (hAT.trans hTC), b, hb, ?_, ?_⟩ + · intro i w + exact rationalLogHeight_le_of_height (hcoord i w) + (hHexp.trans (Real.exp_le_exp.mpr hTC)) + · intro i j k + have hcost := embedding_coordinate_height_budget + (Fintype.card (BoundedFreeWord X s)) (finrank ℚ (FreeNilpotentLieAlgebra X s)) H H + hT (hn.trans hAT) (hd.trans hAT) hHexp hHexp + exact rationalLogHeight_le_of_height (hstructure i j k) + (hcost.trans (Real.exp_le_exp.mpr hBC)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +attribute [local instance] LieRing.ofAssociativeRing + +theorem exists_free_nilpotent_source_basis (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ (X : Type*) [Fintype X] (p : ℝ), + 0 ≤ p → (Fintype.card X : ℝ) ≤ p → + (finrank ℚ (FreeNilpotentLieAlgebra X s) : ℝ) ≤ (p + C) ^ C ∧ + ((FreeNilpotentLieAlgebra.treeGenerators X s).card : ℝ) ≤ (p + C) ^ C ∧ + ∃ b : Basis (Fin (finrank ℚ (FreeNilpotentLieAlgebra X s))) ℚ (FreeNilpotentLieAlgebra X s), + (∀ i, b i ∈ FreeNilpotentLieAlgebra.treeGenerators X s) ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ (p + C) ^ C) ∧ + ∀ x ∈ FreeNilpotentLieAlgebra.treeGenerators X s, ∀ i, + rationalLogHeight (b.repr x i) ≤ (p + C) ^ C := by + obtain ⟨a, _, hmodel⟩ := exists_bounded_free_nilpotent_model s + let H := (2 * (s + 1)) ^ s + let Q : Polynomial ℕ := (Polynomial.X + Polynomial.C a) ^ a + + (Polynomial.X + 2) ^ (3 ^ s) + Polynomial.C H + 2 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (Q + (Q + 2) ^ 8) + refine ⟨C, hC, ?_⟩ + intro X _ p hp hX + let B := (p + a) ^ a + let V := (p + 2) ^ (3 ^ s) + let T := B + V + (H : ℝ) + 2 + have hB : 0 ≤ B := by dsimp only [B]; positivity + have hV : 0 ≤ V := by dsimp only [V]; positivity + have hBT : B ≤ T := by + exact (le_add_of_nonneg_right hV).trans + ((le_add_of_nonneg_right (Nat.cast_nonneg H)).trans (le_add_of_nonneg_right (by norm_num))) + have hVT : V ≤ T := by + exact (le_add_of_nonneg_left hB).trans + ((le_add_of_nonneg_right (Nat.cast_nonneg H)).trans (le_add_of_nonneg_right (by norm_num))) + have hHT : (H : ℝ) ≤ T := + (le_add_of_nonneg_left (add_nonneg hB hV)).trans (le_add_of_nonneg_right (by norm_num)) + have hT : 0 ≤ T := hB.trans hBT + have hsum : T + (T + 2) ^ 8 ≤ (p + C) ^ C := by + simpa [Q, T, B, V, Polynomial.eval₂_pow] using hbudget p hp + have hTC : T ≤ (p + C) ^ C := + (le_add_of_nonneg_right (by positivity : 0 ≤ (T + 2) ^ 8)).trans hsum + have hPC : (T + 2) ^ 8 ≤ (p + C) ^ C := (le_add_of_nonneg_left hT).trans hsum + obtain ⟨hd, hn, b, hb, _, hstructure⟩ := hmodel X p hp hX + have hgen : ((FreeNilpotentLieAlgebra.treeGenerators X s).card : ℝ) ≤ V := by + calc + _ ≤ ((Fintype.card X : ℝ) + 2) ^ (3 ^ s) := by + exact_mod_cast FreeNilpotentLieAlgebra.treeGenerators_card_le X s + _ ≤ _ := pow_le_pow_left₀ (by positivity) (add_le_add hX (le_refl (2 : ℝ))) _ + have hHexp : (H : ℝ) ≤ Real.exp T := hHT.trans + ((le_add_of_nonneg_right (by norm_num : (0 : ℝ) ≤ 1)).trans (Real.add_one_le_exp T)) + refine ⟨hd.trans (hBT.trans hTC), hgen.trans (hVT.trans hTC), b, hb, + fun i j k => (hstructure i j k).trans (hBT.trans hTC), ?_⟩ + intro x hx i + have hraw := embedding_basis_coordinate_height b (Pi.basisFun ℚ (BoundedFreeWord X s)) + (FreeNilpotentLieAlgebra.coordinates X s) (FreeNilpotentLieAlgebra.coordinates_injective X s) + (show 1 ≤ H from one_le_pow₀ (by omega)) + (fun w j => by simpa only [Pi.basisFun_repr] using + FreeNilpotentLieAlgebra.treeGenerators_coordinate_height X s (b j) (hb j) w) + x (fun w => by simpa only [Pi.basisFun_repr] using + FreeNilpotentLieAlgebra.treeGenerators_coordinate_height X s x hx w) i + have hcost := embedding_coordinate_height_budget + (Fintype.card (BoundedFreeWord X s)) (finrank ℚ (FreeNilpotentLieAlgebra X s)) H H + hT (hn.trans hBT) (hd.trans hBT) hHexp hHexp + apply rationalLogHeight_le_of_height hraw + simpa only [Fintype.card_fin] using hcost.trans (Real.exp_le_exp.mpr hPC) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeWeightedNilpotentLieAlgebra.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeWeightedNilpotentLieAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f1b331a597fafd997fa47b766f81ed5cabfe434 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FreeWeightedNilpotentLieAlgebra.lean @@ -0,0 +1,75 @@ +import OAI.Combinatorics.Progressions.Estimates.FreeWeightedLayerBounds + +namespace OAI + +section + +namespace Erdos3 + +def FreeWeightedNilpotentLieAlgebra (X : Type*) (s : ℕ) (w : X → ℕ) := + FreeNilpotentLieAlgebra X s ⧸ FreeNilpotentLieAlgebra.weightedLayerIdeal X s w (s + 1) + +namespace FreeWeightedNilpotentLieAlgebra + +variable (X : Type*) (s : ℕ) (w : X → ℕ) + +noncomputable instance instLieRing : LieRing (FreeWeightedNilpotentLieAlgebra X s w) := + inferInstanceAs (LieRing (FreeNilpotentLieAlgebra X s ⧸ + FreeNilpotentLieAlgebra.weightedLayerIdeal X s w (s + 1))) + +noncomputable instance instLieAlgebra : LieAlgebra ℚ (FreeWeightedNilpotentLieAlgebra X s w) := + inferInstanceAs (LieAlgebra ℚ (FreeNilpotentLieAlgebra X s ⧸ + FreeNilpotentLieAlgebra.weightedLayerIdeal X s w (s + 1))) + +noncomputable def mk : FreeNilpotentLieAlgebra X s →ₗ⁅ℚ⁆ FreeWeightedNilpotentLieAlgebra X s w := + lieQuotientMap (FreeNilpotentLieAlgebra.weightedLayerIdeal X s w (s + 1)) + +theorem mk_surjective : Function.Surjective (mk X s w) := lieQuotientMap_surjective _ + +theorem mk_eq_zero (x : FreeNilpotentLieAlgebra X s) : + mk X s w x = 0 ↔ x ∈ FreeNilpotentLieAlgebra.weightedLayer X s w (s + 1) := + lieQuotientMap_eq_zero _ x + +theorem lowerCentralSeries_eq_bot : + LieModule.lowerCentralSeries ℚ (FreeWeightedNilpotentLieAlgebra X s w) + (FreeWeightedNilpotentLieAlgebra X s w) s = ⊥ := + lie_quotient_lowerCentralSeries_eq_bot (FreeNilpotentLieAlgebra.lowerCentralSeries_eq_bot X s) _ + +noncomputable def of (x : X) : FreeWeightedNilpotentLieAlgebra X s w := + mk X s w (FreeNilpotentLieAlgebra.of X s x) + +noncomputable def filtration (hw : ∀ i, 0 < w i) : + NilpotentLieFiltration (FreeWeightedNilpotentLieAlgebra X s w) s where + layer d := (FreeNilpotentLieAlgebra.weightedLayer X s w d).map (mk X s w).toLinearMap + antitone := fun _ _ h => Submodule.map_mono (FreeNilpotentLieAlgebra.weightedLayer_antitone X s w h) + one_eq_top := by + rw [FreeNilpotentLieAlgebra.weightedLayer_one X s w hw, Submodule.map_top] + exact LinearMap.range_eq_top.mpr (mk_surjective X s w) + lie_mem := by + rintro d e x y ⟨a, ha, rfl⟩ ⟨b, hb, rfl⟩ + exact ⟨⁅a, b⁆, FreeNilpotentLieAlgebra.weightedLayer_lie_mem X s w ha hb, (mk X s w).map_lie a b⟩ + terminal := by + apply bot_unique + rintro x ⟨a, ha, rfl⟩ + exact (mk_eq_zero X s w a).mpr ha + +theorem of_mem_layer (hw : ∀ i, 0 < w i) (x : X) : + of X s w x ∈ (filtration X s w hw).layer (w x) := + ⟨FreeNilpotentLieAlgebra.of X s x, + weightedLieUpperSpan_leaf (FreeNilpotentLieAlgebra.of X s) w x, rfl⟩ + +instance finite [Fintype X] : Module.Finite ℚ (FreeWeightedNilpotentLieAlgebra X s w) := + Module.Finite.of_surjective (mk X s w).toLinearMap (mk_surjective X s w) + +theorem finrank_le [Fintype X] : + Module.finrank ℚ (FreeWeightedNilpotentLieAlgebra X s w) ≤ (s + 1) * (Fintype.card X + 1) ^ s := + (LinearMap.finrank_le_finrank_of_surjective (mk_surjective X s w)).trans + (FreeNilpotentLieAlgebra.finrank_le X s) + +end FreeWeightedNilpotentLieAlgebra + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/FrozenComplexNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/FrozenComplexNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7fd879d34f1bf9ff6ae13cefb13bda463484962 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/FrozenComplexNiltest.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeSharedFrozenCorrelations + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {L M σ : Type*} [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + {s d e : ℕ} (D : RationalFilteredNilmanifold L s d) (E : RationalFilteredNilmanifold M s e) + (φ : L →ₗ⁅ℚ⁆ M) (a r : E.RealGroup) + (h : ∀ γ ∈ D.realLattice, + r⁻¹ * realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ γ * r ∈ E.realLattice) + {w : σ → ℕ} (T : E.Niltest w) (g : D.filtration.realification.PolynomialOrbit w) + (K : ℝ≥0) + (hK : letI := D.metricSpace + letI := E.metricSpace + LipschitzWith K (frozenCosetMap D.realLattice E.realLattice + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ) a r h)) + +noncomputable def frozenComplexNiltest : D.Niltest w where + orbit := g + observable := T.observable ∘ frozenCosetMap D.realLattice E.realLattice + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ) a r h + normBound := T.normBound + lipBound := T.lipBound * K + norm_le x := T.norm_le _ + lipschitz := by + let := D.metricSpace + let := E.metricSpace + exact T.lipschitz.comp hK + +theorem frozenComplexNiltest_eval (x : σ → ℤ) : + (D.frozenComplexNiltest E φ a r h T g K hK).eval x = + T.observable (QuotientGroup.mk + (a * realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ + (D.filtration.realification.polynomialOrbitEval w x g) * r)) := rfl + +theorem frozenComplexNiltest_complexity {p q : ℝ} (hp : 0 ≤ p) (hq : 0 ≤ q) + (hD : D.GeometryComplexityLE q) (hT : T.ComplexityLE p) + (hbound : (K : ℝ) ≤ Real.exp q) : + (D.frozenComplexNiltest E φ a r h T g K hK).ComplexityLE (p + q + 4) := by + have hb := T.observable_budget hT + have hnorm : (T.normBound : ℝ) ≤ Real.exp (p + q) := + (by linarith [T.lipBound.coe_nonneg] : (T.normBound : ℝ) ≤ Real.exp p).trans + (Real.exp_le_exp.mpr (by linarith)) + have hlip : (T.lipBound : ℝ) * K ≤ Real.exp (p + q) := by + rw [Real.exp_add] + exact mul_le_mul (by linarith [T.normBound.coe_nonneg]) hbound K.coe_nonneg (Real.exp_pos _).le + refine ⟨hD.mono D (by linarith), ?_⟩ + change Real.log (2 + (T.normBound : ℝ) + ((T.lipBound * K : ℝ≥0) : ℝ)) ≤ p + q + 4 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + calc + _ ≤ 4 * Real.exp (p + q) := by + simp only [NNReal.coe_mul] + linarith [Real.one_le_exp (show 0 ≤ p + q by linarith)] + _ ≤ Real.exp 4 * Real.exp (p + q) := mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (4 : ℝ)]) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem frozenComplexNiltest_top_invariant + (hinv : ∀ z ∈ D.filtration.realification.subgroup s, ∀ x : D.RealGroup, + T.observable (QuotientGroup.mk + (a * realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ (z * x) * r)) = + T.observable (QuotientGroup.mk + (a * realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := E.filtration.lowerCentralSeries_eq_bot) φ x * r))) + (z : D.RealGroup) (hz : z ∈ D.filtration.realification.subgroup s) (x : D.Space) : + (D.frozenComplexNiltest E φ a r h T g K hK).observable (z • x) = + (D.frozenComplexNiltest E φ a r h T g K hK).observable x := by + induction x using Quotient.inductionOn with + | h x => exact hinv z hz x + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/IdealInvariantNiltestBudget.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/IdealInvariantNiltestBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..19f41005a8fcc73fd544fd45e93d0759f1b09b97 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/IdealInvariantNiltestBudget.lean @@ -0,0 +1,490 @@ +import Mathlib.Topology.MetricSpace.Lipschitz +import OAI.Combinatorics.Progressions.Estimates.RepresentativeWindowPatch +import OAI.Combinatorics.Progressions.Polynomial.PolynomialShearParameterBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +namespace RationalFilteredNilmanifold.Niltest + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +def UnitIntervalValued (T : D.Niltest w) : Prop := + ∀ z, (T.observable z).im = 0 ∧ 0 ≤ (T.observable z).re ∧ (T.observable z).re ≤ 1 + +end RationalFilteredNilmanifold.Niltest + +def CyclicNiltestUpperComparison.{u} (degree N : ℕ) [NeZero N] + (P epsilon : ℝ) (f g : ZMod N → ℝ) : Prop := + ∀ {L : Type u} [LieRing L] [LieAlgebra ℚ L] {s dim : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s dim), s ≤ degree → + ∀ (T : D.Niltest (fun _ : Unit => 1)), T.UnitIntervalValued → T.ComplexityLE P → + (𝔼 x : ZMod N, (f x - g x) * (T.evalCyclic N (fun _ => x)).re) ≤ epsilon + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] {s t d n : ℕ} + (D : RationalFilteredNilmanifold L s d) (I : LieIdeal ℚ L) + (hI : D.filtration.layer (t + 1) ≤ I.toSubmodule) + (Q : RationalFilteredNilmanifold (L ⧸ I) t n) + (hQF : Q.filtration = D.filtration.quotientLie I hI) + +noncomputable def idealQuotientOrbit {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) : + Q.filtration.realification.PolynomialOrbit w := + let q := D.filtration.realQuotientPolynomialOrbit I hI g + NilpotentLieFiltration.polynomialOrbitOfLog q.log (by rw [hQF]; exact q.adapted) + +theorem idealQuotientOrbit_eval {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (x : σ → ℤ) : + Q.filtration.realification.polynomialOrbitEval w x (D.idealQuotientOrbit I hI Q hQF g) = + realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) (lieQuotientMap I) + (D.filtration.realification.polynomialOrbitEval w x g) := + D.filtration.realQuotientPolynomialOrbit_eval I hI g x + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] (L ⧸ I))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ I))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (L ⧸ I))] [T2Space (ℝ ⊗[ℚ] (L ⧸ I))] + +theorem exists_idealInvariant_niltest + (hQL : Q.lattice = D.lattice.map (D.filtration.quotientStepHom I hI)) + {w : σ → ℕ} (T : D.Niltest w) + (hinv : ∀ z : D.RealGroup, z.coord ∈ I.toSubmodule.baseChange ℝ → ∀ x, + T.observable (z • x) = T.observable x) + (H : ℕ) (hH : 1 ≤ H) + (he : ∀ i j, RationalHeightLE (Q.basis.repr (lieQuotientMap I (D.basis j)) i) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants Q.basis i j k) H) : + ∃ S : Q.Niltest w, + S.orbit = D.idealQuotientOrbit I hI Q hQF T.orbit ∧ + S.normBound = T.normBound ∧ + S.lipBound = rationalReconstructionLipschitzBound t d n H T.lipBound T.normBound ∧ + (∀ x : D.RealGroup, S.observable (QuotientGroup.mk + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) (lieQuotientMap I) x)) = + T.observable (QuotientGroup.mk x)) ∧ + (∀ x, S.eval x = T.eval x) ∧ + (T.UnitIntervalValued → S.UnitIntervalValued) := by + have hcover : Q.lattice ≤ D.lattice.map + (mapOfSteps (hL := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) (lieQuotientMap I)) := by + rw [hQL] + exact le_rfl + obtain ⟨f, hf, hfLip, hfBound⟩ := exists_lipschitz_realification_reconstruction + D.basis Q.basis (lieQuotientMap I) (lieQuotientMap_surjective I) D.lattice Q.lattice hcover + D.grid Q.grid H D.grid_pos Q.grid_pos hH D.outer_grid Q.outer_grid he hc + T.observable (fun k hk x => hinv k (by + apply (realification_mkQ_eq_zero_iff I.toSubmodule k.coord).mp + exact congrArg (fun z : Q.RealGroup => z.coord) (MonoidHom.mem_ker.mp hk)) + (QuotientGroup.mk x)) T.lipBound T.normBound T.lipschitz T.norm_le + let S : Q.Niltest w := { + orbit := D.idealQuotientOrbit I hI Q hQF T.orbit + observable := f + normBound := T.normBound + lipBound := rationalReconstructionLipschitzBound t d n H T.lipBound T.normBound + norm_le := hfBound + lipschitz := by + let : MetricSpace (Q.RealGroup ⧸ Q.lattice.map realificationHom) := + realificationQuotientMetricSpace Q.basis Q.lattice Q.grid Q.grid_pos Q.outer_grid + exact hfLip.weaken (by simp only [Fintype.card_fin]; exact le_rfl) } + refine ⟨S, rfl, rfl, rfl, hf, ?_, ?_⟩ + · intro x + exact (congrArg (fun z : Q.RealGroup => f (QuotientGroup.mk z)) + (D.idealQuotientOrbit_eval I hI Q hQF T.orbit x)).trans (hf _) + · intro hT z + induction z using Quotient.inductionOn with + | h z => + obtain ⟨x, hx⟩ := LinearMap.lTensor_surjective ℝ (lieQuotientMap_surjective I) z.coord + let g : D.RealGroup := ⟨x⟩ + have hg : realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) (lieQuotientMap I) g = z := + NilpotentLieBCHGroup.ext hx + have hfg := hf g + rw [hg] at hfg + change (f (QuotientGroup.mk z)).im = 0 ∧ 0 ≤ (f (QuotientGroup.mk z)).re ∧ + (f (QuotientGroup.mk z)).re ≤ 1 + rw [hfg] + exact hT (QuotientGroup.mk g) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def intervalClip (T : D.Niltest w) : D.Niltest w where + orbit := T.orbit + observable := fun z => ((max 0 (min 1 (T.observable z).re) : ℝ) : ℂ) + normBound := T.normBound + lipBound := T.lipBound + norm_le z := by + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (le_max_left _ _)] + exact (max_le (norm_nonneg _) ((min_le_right _ _).trans (Complex.re_le_norm _))).trans (T.norm_le z) + lipschitz := by + let := D.metricSpace + have hr : LipschitzWith T.lipBound (fun z => (T.observable z).re) := by + apply LipschitzWith.of_dist_le_mul + intro x y + calc + dist (T.observable x).re (T.observable y).re ≤ dist (T.observable x) (T.observable y) := by + simpa only [Real.dist_eq, dist_eq_norm, Complex.sub_re, Real.norm_eq_abs] using + Complex.abs_re_le_norm (T.observable x - T.observable y) + _ ≤ T.lipBound * dist x y := T.lipschitz.dist_le_mul x y + simpa only [one_mul, Function.comp_def] using + Complex.isometry_ofReal.lipschitzWith.comp ((hr.const_min 1).const_max 0) + +theorem intervalClip_unitInterval (T : D.Niltest w) : T.intervalClip.UnitIntervalValued := by + intro z + exact ⟨rfl, le_max_left _ _, max_le (by norm_num) (min_le_left _ _)⟩ + +theorem intervalClip_complexityLE (T : D.Niltest w) (p : ℝ) : + T.intervalClip.ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +theorem intervalClip_eval (T : D.Niltest w) (x : σ → ℤ) + (hx : (T.eval x).im = 0 ∧ 0 ≤ (T.eval x).re ∧ (T.eval x).re ≤ 1) : + T.intervalClip.eval x = T.eval x := by + change ((max 0 (min 1 (T.eval x).re) : ℝ) : ℂ) = T.eval x + apply Complex.ext + · simp only [Complex.ofReal_re, min_eq_right hx.2.2, max_eq_right hx.2.1] + · exact hx.1.symm + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct NNReal + +variable {σ K Ξ : Type*} [LieRing K] [LieAlgebra ℚ K] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] + (D : RationalFilteredNilmanifold K s d) {w : σ → ℕ} + +noncomputable def cyclicOrbitPoint + (g : D.filtration.realification.PolynomialOrbit w) + (N : ℕ) [NeZero N] (x : σ → ZMod N) : D.Space := + QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w + (fun i => ((x i).val : ℤ)) g) + +noncomputable def sectionNiltest + (g : D.filtration.realification.PolynomialOrbit w) (F : D.Space → Ξ → ℝ) + (hF : ∀ z a, 0 ≤ F z a ∧ F z a ≤ 1) (M : ℝ≥0) + (hLip : let := D.metricSpace; ∀ a, LipschitzWith M (fun z => F z a)) + (a : Option Ξ) : D.Niltest w where + orbit := g + observable := fun z => (frozenRealSection F a z : ℂ) + normBound := 1 + lipBound := M + norm_le z := by + have h := frozenRealSection_unit_interval F hF a z + simpa only [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg h.1, NNReal.coe_one] using h.2 + lipschitz := by + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + cases a with + | none => + change dist (0 : ℂ) 0 ≤ (M : ℝ) * dist x y + rw [dist_self] + positivity + | some a => + change dist (F x a : ℂ) (F y a : ℂ) ≤ (M : ℝ) * dist x y + simpa only [dist_eq_norm, ← Complex.ofReal_sub, Complex.norm_real] using + (hLip a).dist_le_mul x y + +theorem sectionNiltest_unit_interval + (g : D.filtration.realification.PolynomialOrbit w) (F : D.Space → Ξ → ℝ) + (hF : ∀ z a, 0 ≤ F z a ∧ F z a ≤ 1) (M : ℝ≥0) + (hLip : let := D.metricSpace; ∀ a, LipschitzWith M (fun z => F z a)) (a : Option Ξ) : + (D.sectionNiltest g F hF M hLip a).UnitIntervalValued := by + intro z + exact ⟨rfl, frozenRealSection_unit_interval F hF a z⟩ + +theorem sectionNiltest_complexityLE + (g : D.filtration.realification.PolynomialOrbit w) (F : D.Space → Ξ → ℝ) + (hF : ∀ z a, 0 ≤ F z a ∧ F z a ≤ 1) (M : ℝ≥0) + (hLip : let := D.metricSpace; ∀ a, LipschitzWith M (fun z => F z a)) + (a : Option Ξ) {p : ℝ} (hD : D.GeometryComplexityLE p) + (hbudget : Real.log (3 + (M : ℝ)) ≤ p) : + (D.sectionNiltest g F hF M hLip a).ComplexityLE p := by + refine ⟨hD, ?_⟩ + change Real.log (2 + (1 : ℝ) + (M : ℝ)) ≤ p + norm_num only [show (2 : ℝ) + 1 = 3 by norm_num] + exact hbudget + +theorem sectionNiltest_evalCyclic_re + (g : D.filtration.realification.PolynomialOrbit w) (F : D.Space → Ξ → ℝ) + (hF : ∀ z a, 0 ≤ F z a ∧ F z a ≤ 1) (M : ℝ≥0) + (hLip : let := D.metricSpace; ∀ a, LipschitzWith M (fun z => F z a)) + (a : Option Ξ) (N : ℕ) [NeZero N] (x : σ → ZMod N) : + ((D.sectionNiltest g F hF M hLip a).evalCyclic N x).re = + frozenRealSection F a (D.cyclicOrbitPoint g N x) := rfl + +theorem sectionNiltest_none_eval + (g : D.filtration.realification.PolynomialOrbit w) (F : D.Space → Ξ → ℝ) + (hF : ∀ z a, 0 ≤ F z a ∧ F z a ≤ 1) (M : ℝ≥0) + (hLip : let := D.metricSpace; ∀ a, LipschitzWith M (fun z => F z a)) + (x : σ → ℤ) : (D.sectionNiltest g F hF M hLip none).eval x = 0 := rfl + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +def CyclicNiltestShiftBound.{u} (degree N : ℕ) [NeZero N] + (p error : ℝ) (a J : ZMod N → ℝ) (E : Finset (ZMod N)) : Prop := + ∀ h ∉ E, ∀ {L : Type u} [LieRing L] [LieAlgebra ℚ L] {s dim : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s dim), s ≤ degree → + ∀ (T : D.Niltest (fun _ : Unit => 1)), T.UnitIntervalValued → T.ComplexityLE p → + (𝔼 x : ZMod N, a x * J (x + h) * (T.evalCyclic N (fun _ => x)).re) ≤ error + +theorem cyclicNiltestShiftBound_zero_of_constants.{u} {N : ℕ} [NeZero N] + (a J : ZMod N → ℝ) (E : Finset (ZMod N)) {p error : ℝ} + (hbound : ∀ h ∉ E, ∀ t : ℝ, 0 ≤ t → t ≤ 1 → realShiftCorrelation a J h * t ≤ error) : + CyclicNiltestShiftBound.{u} 0 N p error a J E := by + intro h hh L _ _ s dim _ _ _ _ D hs T hT _ + have hs0 : s = 0 := by omega + subst s + let t := (T.observable (QuotientGroup.mk (1 : D.RealGroup))).re + have ht : 0 ≤ t ∧ t ≤ 1 := (hT _).2 + have heval (x : ZMod N) : (T.evalCyclic N (fun _ => x)).re = t := by + exact congrArg Complex.re (RationalFilteredNilmanifold.Niltest.eval_step_zero D T _) + simp_rw [heval] + rw [← Finset.expect_mul] + exact hbound h hh t ht.1 ht.2 + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem UnitIntervalValued.norm_le_one {T : D.Niltest w} (hT : T.UnitIntervalValued) (x : D.Space) : + ‖T.observable x‖ ≤ 1 := by + have heq : ((T.observable x).re : ℂ) = T.observable x := by + apply Complex.ext + · rfl + · simpa only [Complex.ofReal_im] using (hT x).1.symm + rw [← heq, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (hT x).2.1] + exact (hT x).2.2 + +noncomputable def withUnitBound (T : D.Niltest w) (hcap : ∀ x, ‖T.observable x‖ ≤ 1) : D.Niltest w := + { T with normBound := 1, norm_le := hcap } + +theorem withUnitBound_orbit (T : D.Niltest w) (hcap : ∀ x, ‖T.observable x‖ ≤ 1) : + (T.withUnitBound hcap).orbit = T.orbit := rfl + +theorem withUnitBound_eval (T : D.Niltest w) (hcap : ∀ x, ‖T.observable x‖ ≤ 1) (x : σ → ℤ) : + (T.withUnitBound hcap).eval x = T.eval x := rfl + +theorem withUnitBound_complexity (T : D.Niltest w) (hcap : ∀ x, ‖T.observable x‖ ≤ 1) + {p : ℝ} (hT : T.ComplexityLE p) : (T.withUnitBound hcap).ComplexityLE (p + 1) := by + refine ⟨hT.1.mono D (by linarith), ?_⟩ + change Real.log (2 + 1 + (T.lipBound : ℝ)) ≤ p + 1 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + rw [Real.exp_add] + have h := T.observable_budget hT + have he : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] + have hm := mul_le_mul_of_nonneg_left he (Real.exp_nonneg p) + nlinarith [T.normBound.coe_nonneg, T.lipBound.coe_nonneg] + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (hT : T.UnitIntervalValued) + (psi : D.Space → ℝ) (hpsi : ∀ z, 0 ≤ psi z ∧ psi z ≤ 1) + (K : ℝ≥0) (hLip : letI := D.metricSpace; LipschitzWith K psi) + +noncomputable def positiveLocalization : D.Niltest w where + orbit := T.orbit + observable z := (((T.observable z).re * psi z : ℝ) : ℂ) + normBound := 1 + lipBound := T.lipBound + K + norm_le z := by + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (hT z).2.1 (hpsi z).1)] + exact (mul_le_of_le_one_right (hT z).2.1 (hpsi z).2).trans (hT z).2.2 + lipschitz := by + let := D.metricSpace + have ht : LipschitzWith T.lipBound (fun z => (T.observable z).re) := by + simpa only [one_mul, Function.comp_def, RCLike.re_eq_complex_re] using + (RCLike.lipschitzWith_re (K := ℂ)).comp T.lipschitz + have hproduct := bounded_weight_cutoff_lipschitz (fun z => (T.observable z).re) psi + (B := 1) + (fun z => by rw [abs_of_nonneg (hT z).2.1]; exact (hT z).2.2) + (fun z => by rw [abs_of_nonneg (hpsi z).1]; exact (hpsi z).2) ht hLip + simpa only [one_mul, Function.comp_def] using Complex.isometry_ofReal.lipschitzWith.comp hproduct + +theorem positiveLocalization_orbit : + (T.positiveLocalization hT psi hpsi K hLip).orbit = T.orbit := rfl + +theorem positiveLocalization_unit_interval : + (T.positiveLocalization hT psi hpsi K hLip).UnitIntervalValued := by + intro z + exact ⟨rfl, mul_nonneg (hT z).2.1 (hpsi z).1, + (mul_le_of_le_one_right (hT z).2.1 (hpsi z).2).trans (hT z).2.2⟩ + +theorem positiveLocalization_eval_re (x : σ → ℤ) : + ((T.positiveLocalization hT psi hpsi K hLip).eval x).re = + (T.eval x).re * psi (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval w x T.orbit)) := rfl + +theorem positiveLocalization_support : + tsupport (T.positiveLocalization hT psi hpsi K hLip).observable ⊆ tsupport psi := by + apply closure_mono + intro z hz + change psi z ≠ 0 + intro hzero + apply hz + change (((T.observable z).re * psi z : ℝ) : ℂ) = 0 + rw [hzero, mul_zero, Complex.ofReal_zero] + +theorem positiveLocalization_complexity {p : ℝ} (hp : 0 ≤ p) + (hcomplexity : T.ComplexityLE p) (hK : (K : ℝ) ≤ Real.exp p) : + (T.positiveLocalization hT psi hpsi K hLip).ComplexityLE (p + 4) := by + refine ⟨hcomplexity.1.mono D (by linarith), ?_⟩ + change Real.log (2 + (1 : ℝ) + ((T.lipBound + K : ℝ≥0) : ℝ)) ≤ p + 4 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + rw [NNReal.coe_add, Real.exp_add] + have hbudget := observable_budget hcomplexity + have hnorm := T.normBound.coe_nonneg + have hone := Real.one_le_exp hp + have hfive : (5 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have hprod := mul_le_mul_of_nonneg_right hfive (Real.exp_nonneg p) + nlinarith + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct NNReal + +theorem exists_idealInvariant_niltest_budget (t : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d n : ℕ} (D : RationalFilteredNilmanifold L s d) (I : LieIdeal ℚ L) + [TopologicalSpace (ℝ ⊗[ℚ] (L ⧸ I))] [IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ I))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (L ⧸ I))] [T2Space (ℝ ⊗[ℚ] (L ⧸ I))] + (hI : D.filtration.layer (t + 1) ≤ I.toSubmodule) + (Q : RationalFilteredNilmanifold (L ⧸ I) t n) + (hQF : Q.filtration = D.filtration.quotientLie I hI) + (_hQL : Q.lattice = D.lattice.map (D.filtration.quotientStepHom I hI)) + {w : σ → ℕ} (T : D.Niltest w) (p : ℝ), + 0 ≤ p → T.ComplexityLE p → Q.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (Q.basis.repr (lieQuotientMap I (D.basis j)) i) ≤ p) → + (∀ z : D.RealGroup, z.coord ∈ I.toSubmodule.baseChange ℝ → ∀ x, + T.observable (z • x) = T.observable x) → + ∃ S : Q.Niltest w, S.orbit = D.idealQuotientOrbit I hI Q hQF T.orbit ∧ + S.normBound = T.normBound ∧ S.ComplexityLE ((p + 2) ^ C) ∧ + (∀ x : D.RealGroup, S.observable (QuotientGroup.mk + (NilpotentLieBCHGroup.realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) (lieQuotientMap I) x)) = + T.observable (QuotientGroup.mk x)) ∧ + (∀ x, S.eval x = T.eval x) ∧ (T.UnitIntervalValued → S.UnitIntervalValued) := by + obtain ⟨a, _, hcost⟩ := exists_rationalReconstructionLipschitzBound_exp t + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + ((X + 1 + Polynomial.C a) ^ a + X + 4) + refine ⟨C, hC, ?_⟩ + intro L σ _ _ _ _ _ _ s d n D I _ _ _ _ hI Q hQF hQL w T p hp hT hQ he hinv + let H := ⌈Real.exp p⌉₊ + obtain ⟨S, hSo, hSn, hSl, hObs, hSe, hPos⟩ := D.exists_idealInvariant_niltest I hI Q hQF hQL T hinv H + (one_le_ceil_exp p) (fun i j => rationalHeightLE_ceil_exp (he i j)) + (fun i j k => rationalHeightLE_ceil_exp (hQ.2.2.1 i j k)) + have hB : (T.normBound : ℝ) ≤ Real.exp p := by + linarith [T.observable_budget hT, T.lipBound.coe_nonneg] + have hL : (T.lipBound : ℝ) ≤ Real.exp p := by + linarith [T.observable_budget hT, T.normBound.coe_nonneg] + have hpp : Real.exp p ≤ Real.exp (p + 1) := Real.exp_le_exp.mpr (by linarith) + let r := (p + 1 + a) ^ a + have hr : 0 ≤ r := by dsimp [r]; positivity + have hK : (S.lipBound : ℝ) ≤ Real.exp r := by + rw [hSl] + exact hcost d n H T.lipBound T.normBound (p + 1) (by linarith) + (hT.1.1.trans (by linarith)) (hQ.1.trans (by linarith)) + (ceil_exp_le_exp_add_one hp) (hL.trans hpp) (hB.trans hpp) + have hnum : 2 + (S.normBound : ℝ) + (S.lipBound : ℝ) ≤ Real.exp (r + p + 4) := by + have hSn' : (S.normBound : ℝ) ≤ Real.exp (r + p) := by + rw [hSn] + exact hB.trans (Real.exp_le_exp.mpr (by linarith)) + have hSl' : (S.lipBound : ℝ) ≤ Real.exp (r + p) := + hK.trans (Real.exp_le_exp.mpr (by linarith)) + calc + _ ≤ 4 * Real.exp (r + p) := by linarith [Real.one_le_exp (show 0 ≤ r + p by linarith)] + _ ≤ Real.exp 4 * Real.exp (r + p) := mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (4 : ℝ)]) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hbound : r + p + 4 ≤ (p + 2) ^ C := by + simpa [r, X, Polynomial.eval₂_pow] using hbudget p hp + refine ⟨S, hSo, hSn, ⟨hQ.mono Q ((by linarith : p ≤ r + p + 4).trans hbound), ?_⟩, + hObs, hSe, hPos⟩ + exact ((Real.log_le_iff_le_exp (by positivity)).mpr hnum).trans hbound + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/IntegralCentralNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/IntegralCentralNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b1eebad35f14aba4060222f897f3f4704970f03 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/IntegralCentralNiltest.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.Progressions.Estimates.CentralAdaptedRebase +import OAI.Combinatorics.Progressions.Estimates.LinearMapIntegralCover + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module +open scoped TensorProduct + +theorem exists_integral_central_niltest_lift (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) {w : σ → ℕ} (T : D.Niltest w) {p : ℝ}, + 0 ≤ p → T.ComplexityLE p → T.UnitIntervalValued → + ∃ (E : RationalFilteredNilmanifold L s (finrank ℚ L)) (omega : Fin (finrank ℚ L) → ℕ), + E.filtration = D.filtration ∧ Monotone omega ∧ IsCentralLieBasis E.basis ∧ + (∀ i, 1 ≤ omega i ∧ omega i ≤ s) ∧ + (∀ k, E.filtration.layer k = Submodule.span ℚ (E.basis '' {i | k ≤ omega i})) ∧ + 4 ≤ E.grid ∧ E.lattice ≤ D.lattice ∧ (E.lattice.subgroupOf D.lattice).FiniteIndex ∧ + bchSubgroupCoordinates E.basis E.lattice = scaledIntegerGrid E.grid ∧ + (∀ g ∈ E.lattice, ∃! z : Fin (finrank ℚ L) → ℤ, + integralOrderedBasisProduct E.basis E.filtration.lowerCentralSeries_eq_bot E.grid z = g) ∧ + ∃ U : E.Niltest w, U.UnitIntervalValued ∧ U.ComplexityLE ((p + 2) ^ C) ∧ + ∀ x : σ → ℤ, U.eval x = T.eval x := by + obtain ⟨A, _, hrebase⟩ := exists_controlled_central_rebase + obtain ⟨B, _, hcover⟩ := exists_controlled_integral_coordinates s + let Q : Polynomial ℕ := (Polynomial.X + 2) ^ A + 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_fixed_power_budget + (Q + (Q + Polynomial.C B) ^ B) + refine ⟨C, hC, ?_⟩ + intro σ L _ _ d _ _ _ _ D w T p hp hT hpositive + obtain ⟨F, H, hH, hmono, hcentral, hweights, hpA, hF, htests⟩ := hrebase D hp hT.1 + let U₀ := F.rebaseNiltest H hH T + have hU₀ : U₀.ComplexityLE ((p + 2) ^ A) := htests T hT + let q₀ : ℝ := (p + 2) ^ A + let q : ℝ := q₀ + 4 + let Hc := ⌈Real.exp q₀⌉₊ + have hq₀ : 0 ≤ q₀ := by dsimp [q₀]; positivity + have hq : 0 ≤ q := by dsimp [q]; positivity + have hq₀q : q₀ ≤ q := by dsimp [q]; linarith + have hfour : (4 : ℝ) ≤ Real.exp 4 := by linarith [Real.add_one_le_exp (4 : ℝ)] + have hlp : ((4 * F.grid : ℕ) : ℝ) ≤ Real.exp q := by + rw [Nat.cast_mul, Nat.cast_ofNat] + calc + _ ≤ 4 * Real.exp q₀ := mul_le_mul_of_nonneg_left hF.2.1 (by norm_num) + _ ≤ Real.exp 4 * Real.exp q₀ := mul_le_mul_of_nonneg_right hfour (Real.exp_nonneg _) + _ = Real.exp q := by rw [← Real.exp_add]; congr 1; dsimp [q]; ring + have hHcp : (Hc : ℝ) ≤ Real.exp q := + (ceil_exp_le_exp_add_one hq₀).trans (Real.exp_le_exp.mpr (by dsimp [q]; linarith)) + have hdivgrid : F.grid ∣ 4 * F.grid := dvd_mul_left _ _ + have hinner : scaledIntegerGrid (4 * F.grid) ⊆ bchSubgroupCoordinates F.basis D.lattice := + (scaledIntegerGrid_subset_of_dvd hdivgrid).trans F.inner + have houter : bchSubgroupCoordinates F.basis D.lattice ⊆ denominatorGrid (4 * F.grid) := + F.outer.trans (denominatorGrid_subset_of_dvd hdivgrid) + obtain ⟨m, Λ, hm, hdiv, hmb, hΛ, hfinite, hcoords, hordered⟩ := + hcover F.basis hcentral D.filtration.lowerCentralSeries_eq_bot D.lattice + (4 * F.grid) Hc q (Nat.mul_pos (by decide) F.grid_pos) + (fun i j k => rationalHeightLE_ceil_exp (hF.2.2.1 i j k)) hinner houter hq + (hF.1.trans hq₀q) hHcp hlp + have hm4 : 4 ≤ m := by + have hn := F.grid_pos + have hle : 4 * F.grid ≤ m := Nat.le_of_dvd hm hdiv + omega + have hin : scaledIntegerGrid m ⊆ bchSubgroupCoordinates F.model.basis Λ := hcoords.symm.le + have hout : bchSubgroupCoordinates F.model.basis Λ ⊆ denominatorGrid m := by + change bchSubgroupCoordinates F.basis Λ ⊆ denominatorGrid m + rw [hcoords] + exact fun _ hx => scaledIntegerGrid_mem_denominatorGrid m m hx + let E := F.model.withLattice Λ m hm hin hout + let U : E.Niltest w := U₀.onSublattice Λ m hm hin hout hΛ + have hcost : q + (q + B) ^ B ≤ (p + 2) ^ C := by + simpa [Q, q, q₀, Polynomial.eval₂_pow] using hbudget p hp + have hqC : q ≤ (p + 2) ^ C := (le_add_of_nonneg_right (by positivity)).trans hcost + have hBC : (q + B) ^ B ≤ (p + 2) ^ C := (le_add_of_nonneg_left hq).trans hcost + have hE : E.GeometryComplexityLE ((p + 2) ^ C) := + F.model.withLattice_geometry Λ m hm hin hout hF (hq₀q.trans hqC) + (hmb.trans (Real.exp_le_exp.mpr hBC)) + refine ⟨E, F.weight, rfl, hmono, hcentral, hweights, F.layers, hm4, hΛ, hfinite, + hcoords, hordered, U, ?_, ?_, ?_⟩ + · exact U₀.onSublattice_unit_interval Λ m hm hin hout hΛ hpositive + · exact U₀.onSublattice_complexity Λ m hm hin hout hΛ (hU₀.mono (hq₀q.trans hqC)) hE + · intro x + rfl + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/LieBCHContinuity.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/LieBCHContinuity.lean new file mode 100644 index 0000000000000000000000000000000000000000..6785808c8285d04c74938d435eb5b5d73674786f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/LieBCHContinuity.lean @@ -0,0 +1,1092 @@ +import Mathlib.Algebra.Algebra.Hom.Rat +import Mathlib.Algebra.Algebra.NonUnitalSubalgebra +import Mathlib.Algebra.FreeAlgebra +import Mathlib.Algebra.Group.MinimalAxioms +import Mathlib.Algebra.Group.Subgroup.Ker +import Mathlib.GroupTheory.Nilpotent +import Mathlib.RingTheory.Adjoin.Polynomial.Basic +import Mathlib.RingTheory.Nilpotent.Exp +import Mathlib.Topology.Algebra.Module.FiniteDimension +import OAI.Combinatorics.Progressions.Estimates.FormalExpLog +import OAI.Combinatorics.Progressions.Estimates.FreeLieTreeCoefficientBounds +import OAI.Combinatorics.Progressions.Nilpotent.NilpotentBilinearExponential + +namespace OAI + +section + +namespace Erdos3 + +open PowerSeries Finset + +section Ring +variable {A B : Type*} [Ring A] [Algebra ℚ A] [Ring B] [Algebra ℚ B] + +noncomputable def nilpotentSeries (f : PowerSeries ℚ) (a : A) : A := + ∑ i ∈ range (nilpotencyClass a), coeff i f • a ^ i + +theorem nilpotentSeries_eq_sum (f : PowerSeries ℚ) {a : A} {k : ℕ} (h : a ^ k = 0) : + nilpotentSeries f a = ∑ i ∈ range k, coeff i f • a ^ i := by + unfold nilpotentSeries + have hle : nilpotencyClass a ≤ k := csInf_le' h + apply sum_subset (range_mono hle) + intro i hi hnot + rw [pow_eq_zero_of_le (Nat.le_of_not_gt (by simpa using hnot)) + (pow_nilpotencyClass ⟨k, h⟩), smul_zero] + +theorem nilpotentSeries_eq_finsum (f : PowerSeries ℚ) {a : A} (ha : IsNilpotent a) : + nilpotentSeries f a = ∑ᶠ i : ℕ, coeff i f • a ^ i := by + symm + apply finsum_eq_sum_of_support_subset + intro i hi + by_contra hn + have he : a ^ i = 0 := pow_eq_zero_of_le + (Nat.le_of_not_gt (by simpa using hn)) (pow_nilpotencyClass ha) + exact hi (by simp [he]) + +theorem map_nilpotentSeries (f : PowerSeries ℚ) {a : A} (ha : IsNilpotent a) + (φ : A →ₐ[ℚ] B) : φ (nilpotentSeries f a) = nilpotentSeries f (φ a) := by + obtain ⟨k, hk⟩ := ha + have hk' : (φ a) ^ k = 0 := by rw [← map_pow, hk, map_zero] + simp [nilpotentSeries_eq_sum f hk, nilpotentSeries_eq_sum f hk'] + +theorem nilpotentSeries_exp (a : A) : + nilpotentSeries (PowerSeries.exp ℚ) a = IsNilpotent.exp a := by + simp [nilpotentSeries, IsNilpotent.exp, coeff_exp, one_div] + +end Ring + +section CommRing +variable {A : Type*} [CommRing A] [Algebra ℚ A] + +omit [Algebra ℚ A] in +theorem hasSubst_C_nilpotent {a : A} (ha : IsNilpotent a) : + HasSubst (C a : PowerSeries A) := by + change IsNilpotent (constantCoeff (C a)) + simpa only [constantCoeff_C] using ha + +theorem subst_C_nilpotent_eq (f : PowerSeries ℚ) {a : A} (ha : IsNilpotent a) : + f.subst (C a : PowerSeries A) = C (nilpotentSeries f a) := by + ext n + rw [coeff_subst' (hasSubst_C_nilpotent ha)] + simp only [← map_pow, coeff_C] + cases n with + | zero => simp only [ite_true, nilpotentSeries_eq_finsum f ha] + | succ n => simp + +noncomputable def nilpotentSeriesHom {a : A} (ha : IsNilpotent a) : + PowerSeries ℚ →ₐ[ℚ] A := + constantCoeff.toRatAlgHom.comp (substAlgHom (hasSubst_C_nilpotent ha)) + +theorem nilpotentSeriesHom_apply {a : A} (ha : IsNilpotent a) (f : PowerSeries ℚ) : + nilpotentSeriesHom ha f = nilpotentSeries f a := by + simp only [nilpotentSeriesHom, AlgHom.comp_apply, RingHom.toRatAlgHom_apply, + coe_substAlgHom, subst_C_nilpotent_eq f ha, constantCoeff_C] + +theorem nilpotentSeries_X {a : A} (ha : IsNilpotent a) : + nilpotentSeries X a = a := by + have h := subst_X (R := ℚ) (hasSubst_C_nilpotent ha) + rw [subst_C_nilpotent_eq _ ha] at h + exact C_injective h + +theorem isNilpotent_nilpotentSeries {a : A} (ha : IsNilpotent a) + {g : PowerSeries ℚ} (hg : constantCoeff g = 0) : + IsNilpotent (nilpotentSeries g a) := by + have h := (HasSubst.of_constantCoeff_zero' hg).comp (hasSubst_C_nilpotent ha) + change IsNilpotent (nilpotentSeriesHom ha g) at h + rwa [nilpotentSeriesHom_apply] at h + +theorem nilpotentSeries_subst {a : A} (ha : IsNilpotent a) + (f : PowerSeries ℚ) {g : PowerSeries ℚ} (hg : constantCoeff g = 0) : + nilpotentSeries (f.subst g) a = nilpotentSeries f (nilpotentSeries g a) := by + have h := subst_comp_subst_apply (HasSubst.of_constantCoeff_zero' hg) + (hasSubst_C_nilpotent ha) f + rw [subst_C_nilpotent_eq _ ha, subst_C_nilpotent_eq _ ha, + subst_C_nilpotent_eq _ (isNilpotent_nilpotentSeries ha hg)] at h + exact C_injective h + +end CommRing +end Erdos3 + +end + +section + +namespace Erdos3 + +open PowerSeries + +section Ring +variable {A B : Type*} [Ring A] [Algebra ℚ A] [Ring B] [Algebra ℚ B] + +noncomputable def nilpotentLog (a : A) : A := nilpotentSeries (log ℚ) a + +theorem nilpotentLog_eq_sum {a : A} {k : ℕ} (h : a ^ k = 0) : + nilpotentLog a = ∑ i ∈ Finset.range k, ((-1 : ℚ) ^ (i + 1) / i) • a ^ i := by + rw [nilpotentLog, nilpotentSeries_eq_sum _ h] + apply Finset.sum_congr rfl + intro i hi + by_cases hzero : i = 0 + · simp [hzero] + · simp [coeff_log, hzero] + +theorem nilpotentLog_zero : nilpotentLog (0 : A) = 0 := by + simp [nilpotentLog_eq_sum (pow_one (0 : A))] + +theorem map_nilpotentLog {a : A} (ha : IsNilpotent a) (φ : A →ₐ[ℚ] B) : + φ (nilpotentLog a) = nilpotentLog (φ a) := map_nilpotentSeries _ ha φ + +end Ring + +section CommRing +variable {A : Type*} [CommRing A] [Algebra ℚ A] + +theorem isNilpotent_nilpotentLog_comm {a : A} (ha : IsNilpotent a) : + IsNilpotent (nilpotentLog a) := isNilpotent_nilpotentSeries ha constantCoeff_log + +theorem exp_nilpotentLog_comm {a : A} (ha : IsNilpotent a) : + IsNilpotent.exp (nilpotentLog a) = 1 + a := by + have h := nilpotentSeries_subst ha (exp ℚ) (g := log ℚ) constantCoeff_log + rw [formal_exp_log, ← nilpotentSeriesHom_apply ha, map_add, map_one, + nilpotentSeriesHom_apply, nilpotentSeries_X ha, nilpotentSeries_exp] at h + exact h.symm + +theorem nilpotentLog_exp_sub_one_comm {a : A} (ha : IsNilpotent a) : + nilpotentLog (IsNilpotent.exp a - 1) = a := by + have h := nilpotentSeries_subst ha (log ℚ) (g := exp ℚ - 1) + (by simp [constantCoeff_exp]) + rw [formal_log_exp, nilpotentSeries_X ha, ← nilpotentSeriesHom_apply ha, + map_sub, map_one, nilpotentSeriesHom_apply, nilpotentSeries_exp] at h + exact h.symm + +end CommRing + +section Ring +variable {A : Type*} [Ring A] [Algebra ℚ A] + +theorem isNilpotent_nilpotentLog {a : A} (ha : IsNilpotent a) : + IsNilpotent (nilpotentLog a) := by + let S := Algebra.adjoin ℚ ({a} : Set A) + let x : S := ⟨a, Algebra.self_mem_adjoin_singleton ℚ a⟩ + have hx : IsNilpotent x := + (IsNilpotent.map_iff (f := S.val) Subtype.val_injective).mp ha + have h := (isNilpotent_nilpotentLog_comm hx).map S.val + rwa [map_nilpotentLog hx S.val] at h + +theorem exp_nilpotentLog {a : A} (ha : IsNilpotent a) : + IsNilpotent.exp (nilpotentLog a) = 1 + a := by + let S := Algebra.adjoin ℚ ({a} : Set A) + let x : S := ⟨a, Algebra.self_mem_adjoin_singleton ℚ a⟩ + have hx : IsNilpotent x := + (IsNilpotent.map_iff (f := S.val) Subtype.val_injective).mp ha + have h := congrArg S.val (exp_nilpotentLog_comm hx) + rw [IsNilpotent.map_exp (isNilpotent_nilpotentLog_comm hx), + map_nilpotentLog hx, map_add, map_one] at h + exact h + +theorem nilpotentLog_exp_sub_one {a : A} (ha : IsNilpotent a) : + nilpotentLog (IsNilpotent.exp a - 1) = a := by + let S := Algebra.adjoin ℚ ({a} : Set A) + let x : S := ⟨a, Algebra.self_mem_adjoin_singleton ℚ a⟩ + have hx : IsNilpotent x := + (IsNilpotent.map_iff (f := S.val) Subtype.val_injective).mp ha + have h := congrArg S.val (nilpotentLog_exp_sub_one_comm hx) + rw [map_nilpotentLog (IsNilpotent.isNilpotent_exp_sub_one hx), map_sub, map_one, + IsNilpotent.map_exp hx] at h + exact h + +theorem exp_injective_on_nilpotents {a b : A} (ha : IsNilpotent a) + (hb : IsNilpotent b) (h : IsNilpotent.exp a = IsNilpotent.exp b) : a = b := by + rw [← nilpotentLog_exp_sub_one ha, ← nilpotentLog_exp_sub_one hb, h] + +end Ring +end Erdos3 + +end + +section + +namespace Erdos3 + +open PowerSeries Finset + +variable {A : Type*} [Ring A] [Algebra ℚ A] + +theorem nonUnitalSubalgebra_pow_mem (I : NonUnitalSubalgebra ℚ A) {a : A} + (ha : a ∈ I) {n : ℕ} (hn : 0 < n) : a ^ n ∈ I := by + obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_zero_of_lt hn) + clear hn + induction n with + | zero => simpa using ha + | succ n ih => + rw [pow_succ] + exact mul_mem ih ha + +theorem nilpotentSeries_sub (f g : PowerSeries ℚ) (a : A) : + nilpotentSeries (f - g) a = nilpotentSeries f a - nilpotentSeries g a := by + simp [nilpotentSeries, sub_smul, sum_sub_distrib] + +theorem nilpotentSeries_one {a : A} (ha : IsNilpotent a) : + nilpotentSeries 1 a = 1 := by + obtain ⟨k, hk⟩ := ha + rw [nilpotentSeries_eq_sum _ (pow_eq_zero_of_le (Nat.le_succ k) hk)] + simp [coeff_one] + +theorem nilpotentSeries_mem (I : NonUnitalSubalgebra ℚ A) {a : A} (ha : a ∈ I) + {f : PowerSeries ℚ} (hf : constantCoeff f = 0) : nilpotentSeries f a ∈ I := by + apply I.sum_mem + intro i hi + by_cases hzero : i = 0 + · simp [hzero, coeff_zero_eq_constantCoeff, hf] + · exact I.smul_mem _ (nonUnitalSubalgebra_pow_mem I ha (Nat.pos_of_ne_zero hzero)) + +theorem nilpotentLog_mem (I : NonUnitalSubalgebra ℚ A) {a : A} (ha : a ∈ I) : + nilpotentLog a ∈ I := nilpotentSeries_mem I ha constantCoeff_log + +theorem exp_sub_one_mem (I : NonUnitalSubalgebra ℚ A) {a : A} + (ha : a ∈ I) (hna : IsNilpotent a) : IsNilpotent.exp a - 1 ∈ I := by + rw [← nilpotentSeries_exp a, ← nilpotentSeries_one hna, ← nilpotentSeries_sub] + exact nilpotentSeries_mem I ha (by simp [constantCoeff_exp]) + +theorem exp_mul_exp_sub_one_mem (I : NonUnitalSubalgebra ℚ A) {a b : A} + (ha : a ∈ I) (hb : b ∈ I) (hna : IsNilpotent a) (hnb : IsNilpotent b) : + IsNilpotent.exp a * IsNilpotent.exp b - 1 ∈ I := by + have hpa := exp_sub_one_mem I ha hna + have hpb := exp_sub_one_mem I hb hnb + have hid : IsNilpotent.exp a * IsNilpotent.exp b - 1 = + (IsNilpotent.exp a - 1) * (IsNilpotent.exp b - 1) + + (IsNilpotent.exp a - 1) + (IsNilpotent.exp b - 1) := by noncomm_ring + rw [hid] + exact I.add_mem (I.add_mem (I.mul_mem hpa hpb) hpa) hpb + +noncomputable def nilpotentBCH (a b : A) : A := + nilpotentLog (IsNilpotent.exp a * IsNilpotent.exp b - 1) + +theorem nilpotentBCH_mem (I : NonUnitalSubalgebra ℚ A) {a b : A} + (ha : a ∈ I) (hb : b ∈ I) (hna : IsNilpotent a) (hnb : IsNilpotent b) : + nilpotentBCH a b ∈ I := + nilpotentLog_mem I (exp_mul_exp_sub_one_mem I ha hb hna hnb) + +section NilAlgebra +variable (I : NonUnitalSubalgebra ℚ A) (hI : ∀ a ∈ I, IsNilpotent a) +include hI + +theorem exp_nilpotentBCH {a b : A} (ha : a ∈ I) (hb : b ∈ I) : + IsNilpotent.exp (nilpotentBCH a b) = IsNilpotent.exp a * IsNilpotent.exp b := by + have hn := hI _ (exp_mul_exp_sub_one_mem I ha hb (hI _ ha) (hI _ hb)) + rw [nilpotentBCH, exp_nilpotentLog hn] + abel + +theorem nilpotentBCH_assoc {a b c : A} (ha : a ∈ I) (hb : b ∈ I) (hc : c ∈ I) : + nilpotentBCH (nilpotentBCH a b) c = nilpotentBCH a (nilpotentBCH b c) := by + have hab := nilpotentBCH_mem I ha hb (hI _ ha) (hI _ hb) + have hbc := nilpotentBCH_mem I hb hc (hI _ hb) (hI _ hc) + apply exp_injective_on_nilpotents + (hI _ (nilpotentBCH_mem I hab hc (hI _ hab) (hI _ hc))) + (hI _ (nilpotentBCH_mem I ha hbc (hI _ ha) (hI _ hbc))) + rw [exp_nilpotentBCH I hI hab hc, exp_nilpotentBCH I hI ha hbc, + exp_nilpotentBCH I hI ha hb, exp_nilpotentBCH I hI hb hc, mul_assoc] + +end NilAlgebra + +theorem nilpotentBCH_zero_left {a : A} (ha : IsNilpotent a) : nilpotentBCH 0 a = a := by + simp only [nilpotentBCH, IsNilpotent.exp_zero, one_mul, nilpotentLog_exp_sub_one ha] + +theorem nilpotentBCH_zero_right {a : A} (ha : IsNilpotent a) : nilpotentBCH a 0 = a := by + simp only [nilpotentBCH, IsNilpotent.exp_zero, mul_one, nilpotentLog_exp_sub_one ha] + +theorem nilpotentBCH_neg_left {a : A} (ha : IsNilpotent a) : nilpotentBCH (-a) a = 0 := by + rw [nilpotentBCH, IsNilpotent.exp_neg_mul_exp_self ha, sub_self, nilpotentLog_zero] + +theorem nilpotentBCH_neg_right {a : A} (ha : IsNilpotent a) : nilpotentBCH a (-a) = 0 := by + rw [nilpotentBCH, IsNilpotent.exp_mul_exp_neg_self ha, sub_self, nilpotentLog_zero] + +theorem nilpotentBCH_eq_add_of_commute {a b : A} (ha : IsNilpotent a) + (hb : IsNilpotent b) (hab : Commute a b) : nilpotentBCH a b = a + b := by + rw [nilpotentBCH, ← IsNilpotent.exp_add_of_commute hab ha hb, + nilpotentLog_exp_sub_one (hab.isNilpotent_add ha hb)] + +end Erdos3 + +end + +section + +namespace Erdos3 + +open IsNilpotent TensorProduct Module.End + +variable {R M N P : Type*} [CommRing R] [Algebra ℚ R] + [AddCommGroup M] [Module R M] [Module ℚ M] [IsScalarTower ℚ R M] + [AddCommGroup N] [Module R N] [Module ℚ N] [IsScalarTower ℚ R N] + [AddCommGroup P] [Module R P] [Module ℚ P] [IsScalarTower ℚ R P] + +theorem nilpotentLog_intertwine + {DM : Module.End R M} {DN : Module.End R N} {g : M →ₗ[R] N} + (hM : IsNilpotent DM) (hN : IsNilpotent DN) (h : DN ∘ₗ g = g ∘ₗ DM) : + nilpotentLog DN ∘ₗ g = g ∘ₗ nilpotentLog DM := by + ext x + obtain ⟨k, hk⟩ := hM + obtain ⟨l, hl⟩ := hN + have hmk : DM ^ max k l = 0 := pow_eq_zero_of_le (le_max_left k l) hk + have hnl : DN ^ max k l = 0 := pow_eq_zero_of_le (le_max_right k l) hl + have hp (i : ℕ) : (DN ^ i) (g x) = g ((DM ^ i) x) := by + simpa using LinearMap.congr_fun (Module.End.commute_pow_left_of_commute h i) x + simp [nilpotentLog_eq_sum hmk, nilpotentLog_eq_sum hnl, hp, map_rat_smul] + +theorem nilpotentExp_intertwine_injective + {DM : Module.End R M} {DN : Module.End R N} {g : M →ₗ[R] N} + (hM : IsNilpotent DM) (hN : IsNilpotent DN) + (h : exp DN ∘ₗ g = g ∘ₗ exp DM) : DN ∘ₗ g = g ∘ₗ DM := by + have hd : (exp DN - 1) ∘ₗ g = g ∘ₗ (exp DM - 1) := by + ext x + have hx := LinearMap.congr_fun h x + simpa only [LinearMap.comp_apply, LinearMap.sub_apply, Module.End.one_apply, map_sub] + using congrArg (fun y => y - g x) hx + have hl := nilpotentLog_intertwine (isNilpotent_exp_sub_one hM) + (isNilpotent_exp_sub_one hN) hd + simpa only [nilpotentLog_exp_sub_one hM, nilpotentLog_exp_sub_one hN] using hl + +omit [IsScalarTower ℚ R M] [IsScalarTower ℚ R N] in +theorem nilpotentExp_bilinear_injective + (b : M →ₗ[R] N →ₗ[R] P) + (DM : Module.End R M) (DN : Module.End R N) (DP : Module.End R P) + (hM : IsNilpotent DM) (hN : IsNilpotent DN) (hP : IsNilpotent DP) + (hb : ∀ x y, exp DP (b x y) = b (exp DM x) (exp DN y)) (x : M) (y : N) : + DP (b x y) = b (DM x) y + b x (DN y) := by + let DL : Module.End R (M ⊗[R] N) := DM.rTensor N + let DR : Module.End R (M ⊗[R] N) := DN.lTensor M + have hL : IsNilpotent DL := hM.map (rTensorAlgHom R M N) + have hR : IsNilpotent DR := hN.map (lTensorAlgHom R N M) + have hc : Commute DL DR := by ext; simp [DL, DR] + let m : M ⊗[R] N →ₗ[R] P := TensorProduct.lift b + have heL : exp DL = (exp DM).rTensor N := (hM.map_exp (rTensorAlgHom R M N)).symm + have heR : exp DR = (exp DN).lTensor M := (hN.map_exp (lTensorAlgHom R N M)).symm + have he : exp DP ∘ₗ m = m ∘ₗ exp (DL + DR) := by + ext x y + simp [m, exp_add_of_commute hc hL hR, heL, heR, hb] + have hd := nilpotentExp_intertwine_injective (hc.isNilpotent_add hL hR) hP he + simpa [m, DL, DR] using LinearMap.congr_fun hd (x ⊗ₜ[R] y) + +theorem nilpotentLog_bilinear + (b : M →ₗ[R] N →ₗ[R] P) + (FM : Module.End R M) (FN : Module.End R N) (FP : Module.End R P) + (hM : IsNilpotent (FM - 1)) (hN : IsNilpotent (FN - 1)) + (hP : IsNilpotent (FP - 1)) + (hb : ∀ x y, FP (b x y) = b (FM x) (FN y)) (x : M) (y : N) : + nilpotentLog (FP - 1) (b x y) = + b (nilpotentLog (FM - 1) x) y + b x (nilpotentLog (FN - 1) y) := by + apply nilpotentExp_bilinear_injective b _ _ _ + (isNilpotent_nilpotentLog hM) (isNilpotent_nilpotentLog hN) + (isNilpotent_nilpotentLog hP) _ x y + simpa only [exp_nilpotentLog hM, exp_nilpotentLog hN, exp_nilpotentLog hP, + show 1 + (FM - 1) = FM by abel, + show 1 + (FN - 1) = FN by abel, + show 1 + (FP - 1) = FP by abel] using hb + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable {A : Type*} [Ring A] [Algebra ℚ A] + +structure NilpotentBCHGroup (I : NonUnitalSubalgebra ℚ A) + (_hI : ∀ a ∈ I, IsNilpotent a) where + coord : A + mem_coord : coord ∈ I + +namespace NilpotentBCHGroup +variable {I : NonUnitalSubalgebra ℚ A} {hI : ∀ a ∈ I, IsNilpotent a} + +@[ext] +theorem ext {a b : NilpotentBCHGroup I hI} (h : a.coord = b.coord) : a = b := by + cases a + cases b + cases h + rfl + +noncomputable instance : Mul (NilpotentBCHGroup I hI) where + mul a b := ⟨nilpotentBCH a.coord b.coord, + nilpotentBCH_mem I a.mem_coord b.mem_coord (hI _ a.mem_coord) (hI _ b.mem_coord)⟩ + +instance : One (NilpotentBCHGroup I hI) where + one := ⟨0, I.zero_mem⟩ + +instance : Inv (NilpotentBCHGroup I hI) where + inv a := ⟨-a.coord, I.neg_mem a.mem_coord⟩ + +@[simp] theorem coord_mul (a b : NilpotentBCHGroup I hI) : + (a * b).coord = nilpotentBCH a.coord b.coord := rfl +@[simp] theorem coord_one : (1 : NilpotentBCHGroup I hI).coord = 0 := rfl +@[simp] theorem coord_inv (a : NilpotentBCHGroup I hI) : (a⁻¹).coord = -a.coord := rfl + +noncomputable instance : Group (NilpotentBCHGroup I hI) := + Group.ofLeftAxioms + (fun a b c => ext (nilpotentBCH_assoc I hI a.mem_coord b.mem_coord c.mem_coord)) + (fun a => ext (nilpotentBCH_zero_left (hI _ a.mem_coord))) + (fun a => ext (nilpotentBCH_neg_left (hI _ a.mem_coord))) + +noncomputable def expHom : NilpotentBCHGroup I hI →* Aˣ where + toFun a := + { val := IsNilpotent.exp a.coord + inv := IsNilpotent.exp (-a.coord) + val_inv := IsNilpotent.exp_mul_exp_neg_self (hI _ a.mem_coord) + inv_val := IsNilpotent.exp_neg_mul_exp_self (hI _ a.mem_coord) } + map_one' := by apply Units.ext; exact IsNilpotent.exp_zero + map_mul' a b := by + apply Units.ext + exact exp_nilpotentBCH I hI a.mem_coord b.mem_coord + +@[simp] theorem expHom_val (a : NilpotentBCHGroup I hI) : + ↑(expHom a) = IsNilpotent.exp a.coord := rfl + +theorem expHom_injective : Function.Injective (expHom (I := I) (hI := hI)) := by + intro a b hab + apply ext + exact exp_injective_on_nilpotents (hI _ a.mem_coord) (hI _ b.mem_coord) + (congrArg Units.val hab) + +noncomputable def unipotentSubgroup (I : NonUnitalSubalgebra ℚ A) + (hI : ∀ a ∈ I, IsNilpotent a) : Subgroup Aˣ := (expHom (I := I) (hI := hI)).range + +theorem mem_unipotentSubgroup_iff (u : Aˣ) : + u ∈ unipotentSubgroup I hI ↔ (u : A) - 1 ∈ I := by + constructor + · rintro ⟨a, rfl⟩ + exact exp_sub_one_mem I a.mem_coord (hI _ a.mem_coord) + · intro hu + let a : NilpotentBCHGroup I hI := ⟨nilpotentLog ((u : A) - 1), nilpotentLog_mem I hu⟩ + refine ⟨a, ?_⟩ + apply Units.ext + change IsNilpotent.exp (nilpotentLog ((u : A) - 1)) = (u : A) + rw [exp_nilpotentLog (hI _ hu)] + abel + +end NilpotentBCHGroup +end Erdos3 + +end + +section + +namespace Erdos3 + +open Finset + +variable {A B : Type*} [Ring A] [Algebra ℚ A] [Ring B] [Algebra ℚ B] + +noncomputable def finiteExp (k : ℕ) (a : A) : A := + ∑ i ∈ range k, (i.factorial : ℚ)⁻¹ • a ^ i + +noncomputable def finiteLog (k : ℕ) (a : A) : A := + ∑ i ∈ range k, ((-1 : ℚ) ^ (i + 1) / i) • a ^ i + +theorem map_finiteExp (φ : A →ₐ[ℚ] B) (k : ℕ) (a : A) : + φ (finiteExp k a) = finiteExp k (φ a) := by simp [finiteExp] + +theorem map_finiteLog (φ : A →ₐ[ℚ] B) (k : ℕ) (a : A) : + φ (finiteLog k a) = finiteLog k (φ a) := by simp [finiteLog] + +theorem finiteExp_eq_exp {a : A} {k : ℕ} (h : a ^ k = 0) : + finiteExp k a = IsNilpotent.exp a := (IsNilpotent.exp_eq_sum h).symm + +theorem finiteLog_eq_log {a : A} {k : ℕ} (h : a ^ k = 0) : + finiteLog k a = nilpotentLog a := (nilpotentLog_eq_sum h).symm + +noncomputable def bchPolynomial (k : ℕ) : FreeAlgebra ℚ (Fin 2) := + finiteLog k (finiteExp k (FreeAlgebra.ι ℚ 0) * finiteExp k (FreeAlgebra.ι ℚ 1) - 1) + +noncomputable def bchPolynomialEval (a b : A) : FreeAlgebra ℚ (Fin 2) →ₐ[ℚ] A := + FreeAlgebra.lift ℚ ![a, b] + +theorem bchPolynomialEval_formula (k : ℕ) (a b : A) : + bchPolynomialEval a b (bchPolynomial k) = + finiteLog k (finiteExp k a * finiteExp k b - 1) := by + simp [bchPolynomial, bchPolynomialEval, map_finiteLog, map_finiteExp] + +theorem bchPolynomialEval_eq (I : NonUnitalSubalgebra ℚ A) {k : ℕ} + (hI : ∀ a ∈ I, a ^ k = 0) {a b : A} (ha : a ∈ I) (hb : b ∈ I) : + bchPolynomialEval a b (bchPolynomial k) = nilpotentBCH a b := by + have hna : IsNilpotent a := ⟨k, hI a ha⟩ + have hnb : IsNilpotent b := ⟨k, hI b hb⟩ + rw [bchPolynomialEval_formula, finiteExp_eq_exp (hI a ha), finiteExp_eq_exp (hI b hb), + finiteLog_eq_log (hI _ (exp_mul_exp_sub_one_mem I ha hb hna hnb))] + rfl + +theorem map_nilpotentBCH (I : NonUnitalSubalgebra ℚ A) + (hI : ∀ a ∈ I, IsNilpotent a) (φ : A →ₐ[ℚ] B) {a b : A} + (ha : a ∈ I) (hb : b ∈ I) : φ (nilpotentBCH a b) = nilpotentBCH (φ a) (φ b) := by + rw [nilpotentBCH, map_nilpotentLog (hI _ + (exp_mul_exp_sub_one_mem I ha hb (hI _ ha) (hI _ hb))), map_sub, map_mul, map_one, + IsNilpotent.map_exp (hI _ ha), IsNilpotent.map_exp (hI _ hb), nilpotentBCH] + +end Erdos3 + +end + +section + +namespace Erdos3 +variable {A B : Type*} [Ring A] [Algebra ℚ A] [Ring B] [Algebra ℚ B] + +theorem nilpotentBCH_commuting_maps + (I : NonUnitalSubalgebra ℚ A) (hI : ∀ a ∈ I, IsNilpotent a) + (J : NonUnitalSubalgebra ℚ B) (hJ : ∀ b ∈ J, IsNilpotent b) + (L R : A →ₐ[ℚ] B) (hL : ∀ a ∈ I, L a ∈ J) (hR : ∀ a ∈ I, R a ∈ J) + (hcomm : ∀ a b, Commute (L a) (R b)) {a b : A} (ha : a ∈ I) (hb : b ∈ I) : + nilpotentBCH (L a + R a) (L b + R b) = L (nilpotentBCH a b) + R (nilpotentBCH a b) := by + have hc := nilpotentBCH_mem I ha hb (hI _ ha) (hI _ hb) + have hca := J.add_mem (hL _ ha) (hR _ ha) + have hcb := J.add_mem (hL _ hb) (hR _ hb) + apply exp_injective_on_nilpotents + (hJ _ (nilpotentBCH_mem J hca hcb (hJ _ hca) (hJ _ hcb))) + (hJ _ (J.add_mem (hL _ hc) (hR _ hc))) + rw [exp_nilpotentBCH J hJ hca hcb, + IsNilpotent.exp_add_of_commute (hcomm a a) (hJ _ (hL _ ha)) (hJ _ (hR _ ha)), + IsNilpotent.exp_add_of_commute (hcomm b b) (hJ _ (hL _ hb)) (hJ _ (hR _ hb)), + IsNilpotent.exp_add_of_commute (hcomm _ _) (hJ _ (hL _ hc)) (hJ _ (hR _ hc)), + ← IsNilpotent.map_exp (hI _ ha) L, ← IsNilpotent.map_exp (hI _ ha) R, + ← IsNilpotent.map_exp (hI _ hb) L, ← IsNilpotent.map_exp (hI _ hb) R, + ← IsNilpotent.map_exp (hI _ hc) L, ← IsNilpotent.map_exp (hI _ hc) R, + exp_nilpotentBCH I hI ha hb, map_mul, map_mul] + exact (hcomm (IsNilpotent.exp b) (IsNilpotent.exp a)).symm.mul_mul_mul_comm _ _ + +end Erdos3 + +end + +section + +namespace Erdos3 + +variable (A : Type*) [Ring A] [Algebra ℚ A] + +structure NilpotentAlgebraFiltration (s : ℕ) where + layer : ℕ → Submodule ℚ A + antitone : Antitone layer + zero_eq_top : layer 0 = ⊤ + mul_mem : ∀ {i j : ℕ} {a b : A}, a ∈ layer i → b ∈ layer j → a * b ∈ layer (i + j) + terminal : layer (s + 1) = ⊥ + +namespace NilpotentAlgebraFiltration +variable {A} {s : ℕ} (F : NilpotentAlgebraFiltration A s) + +def layerAlgebra (i : ℕ) : NonUnitalSubalgebra ℚ A where + carrier := F.layer i + zero_mem' := (F.layer i).zero_mem + add_mem' := (F.layer i).add_mem + smul_mem' c _ hx := (F.layer i).smul_mem c hx + mul_mem' ha hb := F.antitone (Nat.le_add_right i i) (F.mul_mem ha hb) + +@[simp] theorem mem_layerAlgebra (i : ℕ) (a : A) : a ∈ F.layerAlgebra i ↔ a ∈ F.layer i := + Iff.rfl + +theorem pow_mem {i : ℕ} {a : A} (ha : a ∈ F.layer i) (n : ℕ) : + a ^ n ∈ F.layer (n * i) := by + induction n with + | zero => simp [F.zero_eq_top] + | succ n ih => + rw [pow_succ, Nat.succ_mul] + exact F.mul_mem ih ha + +theorem pow_eq_zero {i : ℕ} (hi : 1 ≤ i) {a : A} (ha : a ∈ F.layer i) : + a ^ (s + 1) = 0 := by + have h := F.antitone (Nat.le_mul_of_pos_right (s + 1) hi) (F.pow_mem ha (s + 1)) + simpa only [F.terminal, Submodule.mem_bot] using h + +theorem isNilpotent_of_mem {i : ℕ} (hi : 1 ≤ i) {a : A} (ha : a ∈ F.layer i) : + IsNilpotent a := ⟨s + 1, F.pow_eq_zero hi ha⟩ + +theorem positive_nilpotent : ∀ a ∈ F.layerAlgebra 1, IsNilpotent a := + fun _ ha => F.isNilpotent_of_mem le_rfl ha + +abbrev Group := NilpotentBCHGroup (F.layerAlgebra 1) F.positive_nilpotent + +theorem bchPolynomial_formula {a b : A} (ha : a ∈ F.layer 1) (hb : b ∈ F.layer 1) : + bchPolynomialEval a b (bchPolynomial (s + 1)) = nilpotentBCH a b := + bchPolynomialEval_eq (F.layerAlgebra 1) (fun _ hx => F.pow_eq_zero le_rfl hx) ha hb + +theorem bch_mem {i : ℕ} (hi : 1 ≤ i) {a b : A} + (ha : a ∈ F.layer i) (hb : b ∈ F.layer i) : nilpotentBCH a b ∈ F.layer i := + nilpotentBCH_mem (F.layerAlgebra i) ha hb + (F.isNilpotent_of_mem hi ha) (F.isNilpotent_of_mem hi hb) + +def subgroup (i : ℕ) : Subgroup F.Group where + carrier := {a | a.coord ∈ F.layer i} + one_mem' := (F.layer i).zero_mem + mul_mem' {a b} ha hb := by + by_cases hi : 1 ≤ i + · exact F.bch_mem hi ha hb + · have he : i = 0 := by omega + simp [he, F.zero_eq_top] + inv_mem' ha := (F.layer i).neg_mem ha + +theorem exp_sub_one_mem_layer {i : ℕ} {a : A} (ha : a ∈ F.layer i) + (hna : IsNilpotent a) : IsNilpotent.exp a - 1 ∈ F.layer i := + exp_sub_one_mem (F.layerAlgebra i) ha hna + +theorem ring_commutator_mem {i j : ℕ} {a b : A} + (ha : a ∈ F.layer i) (hb : b ∈ F.layer j) : a * b - b * a ∈ F.layer (i + j) := by + apply (F.layer (i + j)).sub_mem (F.mul_mem ha hb) + simpa only [Nat.add_comm j i] using F.mul_mem hb ha + +theorem mul_mem_right {i : ℕ} {a : A} (ha : a ∈ F.layer i) (b : A) : + a * b ∈ F.layer i := by + have hb : b ∈ F.layer 0 := by simp [F.zero_eq_top] + simpa only [Nat.add_zero] using F.mul_mem ha hb + +theorem exp_commutator_sub_one_mem {i j : ℕ} {a b : A} + (ha : a ∈ F.layer i) (hb : b ∈ F.layer j) (hna : IsNilpotent a) + (hnb : IsNilpotent b) : + IsNilpotent.exp a * IsNilpotent.exp b * IsNilpotent.exp (-a) * IsNilpotent.exp (-b) - 1 + ∈ F.layer (i + j) := by + have hab := F.ring_commutator_mem (F.exp_sub_one_mem_layer ha hna) + (F.exp_sub_one_mem_layer hb hnb) + have he : (IsNilpotent.exp a - 1) * (IsNilpotent.exp b - 1) - + (IsNilpotent.exp b - 1) * (IsNilpotent.exp a - 1) = + IsNilpotent.exp a * IsNilpotent.exp b - IsNilpotent.exp b * IsNilpotent.exp a := by + noncomm_ring + rw [he] at hab + have h := F.mul_mem_right (F.mul_mem_right hab (IsNilpotent.exp (-a))) + (IsNilpotent.exp (-b)) + have hcancel : IsNilpotent.exp b * IsNilpotent.exp a * IsNilpotent.exp (-a) * + IsNilpotent.exp (-b) = 1 := by + rw [mul_assoc (IsNilpotent.exp b), IsNilpotent.exp_mul_exp_neg_self hna, mul_one, + IsNilpotent.exp_mul_exp_neg_self hnb] + simpa only [sub_mul, hcancel] using h + +theorem commutator_mem {i j : ℕ} {a b : F.Group} + (ha : a.coord ∈ F.layer i) (hb : b.coord ∈ F.layer j) : + (a * b * a⁻¹ * b⁻¹).coord ∈ F.layer (i + j) := by + let c := a * b * a⁻¹ * b⁻¹ + have hc : IsNilpotent c.coord := F.positive_nilpotent _ c.mem_coord + rw [← nilpotentLog_exp_sub_one hc] + apply nilpotentLog_mem (F.layerAlgebra (i + j)) + have he : IsNilpotent.exp c.coord = IsNilpotent.exp a.coord * IsNilpotent.exp b.coord * + IsNilpotent.exp (-a.coord) * IsNilpotent.exp (-b.coord) := by + change (NilpotentBCHGroup.expHom c).val = _ + simp only [c, map_mul, Units.val_mul, NilpotentBCHGroup.expHom_val, + NilpotentBCHGroup.coord_inv] + change IsNilpotent.exp c.coord - 1 ∈ F.layer (i + j) + rw [he] + exact F.exp_commutator_sub_one_mem ha hb + (F.positive_nilpotent _ a.mem_coord) (F.positive_nilpotent _ b.mem_coord) + +theorem subgroup_one : F.subgroup 1 = ⊤ := by + apply top_unique + intro a _ + exact a.mem_coord + +theorem subgroup_terminal : F.subgroup (s + 1) = ⊥ := by + apply bot_unique + intro a ha + rw [Subgroup.mem_bot] + apply NilpotentBCHGroup.ext + change a.coord = 0 + change a.coord ∈ F.layer (s + 1) at ha + simpa only [F.terminal, Submodule.mem_bot] using ha + +theorem descendingCentralSeries : + Subgroup.IsDescendingCentralSeries (fun n => F.subgroup (n + 1)) := by + refine ⟨F.subgroup_one, ?_⟩ + intro a n ha b + change (a * b * a⁻¹ * b⁻¹).coord ∈ F.layer (n + 1 + 1) + exact F.commutator_mem ha b.mem_coord + +theorem lowerCentralSeries_eq_bot : + (⊤ : Subgroup F.Group).lowerCentralSeries s = ⊥ := by + apply bot_unique + exact (Subgroup.descending_central_series_ge_lower _ F.descendingCentralSeries s).trans + F.subgroup_terminal.le + +theorem isNilpotentGroup : _root_.Group.IsNilpotent F.Group := + Subgroup.nilpotent_iff_lowerCentralSeries.mpr ⟨s, F.lowerCentralSeries_eq_bot⟩ + +theorem nilpotencyClass_le : _root_.Group.nilpotencyClass F.Group ≤ s := by + have := F.isNilpotentGroup + exact Subgroup.lowerCentralSeries_eq_bot_iff_nilpotencyClass_le.mp F.lowerCentralSeries_eq_bot + +end NilpotentAlgebraFiltration +end Erdos3 + +end + +section + +namespace Erdos3 +open TensorProduct +variable {A B : Type*} [Ring A] [Algebra ℚ A] [Ring B] [Algebra ℚ B] + +theorem seriesMap_commute (L R : A →ₐ[ℚ] B) (hcomm : ∀ a b, Commute (L a) (R b)) + (f g : PowerSeries A) : Commute (PowerSeries.mapAlgHom L f) (PowerSeries.mapAlgHom R g) := by + apply PowerSeries.ext + intro n + rw [PowerSeries.coeff_mul, PowerSeries.coeff_mul] + conv_rhs => rw [← Finset.HasAntidiagonal.map_swap_antidiagonal] + simp only [Finset.sum_map, Function.Embedding.coeFn_mk, + PowerSeries.mapAlgHom_apply, PowerSeries.coeff_map] + apply Finset.sum_congr rfl + intro ij _ + exact (hcomm _ _).eq + +theorem truncatedSeriesMap_commute (s : ℕ) (L R : A →ₐ[ℚ] B) + (hcomm : ∀ a b, Commute (L a) (R b)) (p q : TruncatedSeries A s) : + Commute (truncatedSeriesMap s L p) (truncatedSeriesMap s R q) := by + obtain ⟨f, rfl⟩ := truncatedSeriesMk_surjective s p + obtain ⟨g, rfl⟩ := truncatedSeriesMk_surjective s q + exact (seriesMap_commute L R hcomm f g).map (truncatedSeriesMk s) + +variable {X : Type*} + +def TruncatedPrimitive {s : ℕ} (p : TruncatedSeries (FreeAlgebra ℚ X) s) : Prop := + truncatedSeriesMap s freeCoproduct p = + truncatedSeriesMap s Algebra.TensorProduct.includeLeft p + + truncatedSeriesMap s Algebra.TensorProduct.includeRight p + +theorem TruncatedPrimitive.coeff {s : ℕ} {p : TruncatedSeries (FreeAlgebra ℚ X) s} + (hp : TruncatedPrimitive p) (n : ℕ) (hn : n ≤ s) : + FreePrimitive (truncatedSeriesCoeff s n hn p) := by + have h := congrArg (truncatedSeriesCoeff s n hn) hp + simpa only [FreePrimitive, truncatedSeriesCoeff_map, map_add, Algebra.TensorProduct.includeLeft_apply, + Algebra.TensorProduct.includeRight_apply] using h + +theorem truncatedPrimitive_iff_coeff {s : ℕ} (p : TruncatedSeries (FreeAlgebra ℚ X) s) : + TruncatedPrimitive p ↔ ∀ n (hn : n ≤ s), FreePrimitive (truncatedSeriesCoeff s n hn p) := by + refine ⟨fun hp n hn => hp.coeff n hn, fun h => ?_⟩ + apply truncatedSeries_ext + intro n hn + simpa only [FreePrimitive, truncatedSeriesCoeff_map, map_add, Algebra.TensorProduct.includeLeft_apply, + Algebra.TensorProduct.includeRight_apply] using h n hn + +theorem TruncatedPrimitive.bch {s : ℕ} {p q : TruncatedSeries (FreeAlgebra ℚ X) s} + (hp : TruncatedPrimitive p) (hq : TruncatedPrimitive q) + (hp0 : p ∈ truncatedSeriesPositive s) (hq0 : q ∈ truncatedSeriesPositive s) : + TruncatedPrimitive (nilpotentBCH p q) := by + let I := truncatedSeriesPositive (A := FreeAlgebra ℚ X) s + let J := truncatedSeriesPositive (A := FreeAlgebra ℚ X ⊗[ℚ] FreeAlgebra ℚ X) s + let D : TruncatedSeries (FreeAlgebra ℚ X) s →ₐ[ℚ] + TruncatedSeries (FreeAlgebra ℚ X ⊗[ℚ] FreeAlgebra ℚ X) s := + truncatedSeriesMap s freeCoproduct + let L : TruncatedSeries (FreeAlgebra ℚ X) s →ₐ[ℚ] + TruncatedSeries (FreeAlgebra ℚ X ⊗[ℚ] FreeAlgebra ℚ X) s := + truncatedSeriesMap s Algebra.TensorProduct.includeLeft + let R : TruncatedSeries (FreeAlgebra ℚ X) s →ₐ[ℚ] + TruncatedSeries (FreeAlgebra ℚ X ⊗[ℚ] FreeAlgebra ℚ X) s := + truncatedSeriesMap s Algebra.TensorProduct.includeRight + have hI : ∀ a ∈ I, IsNilpotent a := fun _ ha => truncatedSeriesPositive_nilpotent ha + have hJ : ∀ a ∈ J, IsNilpotent a := fun _ ha => truncatedSeriesPositive_nilpotent ha + change D (nilpotentBCH p q) = L (nilpotentBCH p q) + R (nilpotentBCH p q) + calc + D (nilpotentBCH p q) = nilpotentBCH (D p) (D q) := + map_nilpotentBCH (A := TruncatedSeries (FreeAlgebra ℚ X) s) + (B := TruncatedSeries (FreeAlgebra ℚ X ⊗[ℚ] FreeAlgebra ℚ X) s) + I hI D (a := p) (b := q) hp0 hq0 + _ = nilpotentBCH (L p + R p) (L q + R q) := congrArg₂ nilpotentBCH hp hq + _ = L (nilpotentBCH p q) + R (nilpotentBCH p q) := ?_ + apply nilpotentBCH_commuting_maps (A := TruncatedSeries (FreeAlgebra ℚ X) s) + (B := TruncatedSeries (FreeAlgebra ℚ X ⊗[ℚ] FreeAlgebra ℚ X) s) I hI J hJ L R + (fun _ ha => truncatedSeriesMap_positive s _ ha) + (fun _ ha => truncatedSeriesMap_positive s _ ha) _ hp0 hq0 + intro a b + apply truncatedSeriesMap_commute + intro u v + change (u ⊗ₜ[ℚ] 1) * (1 ⊗ₜ[ℚ] v) = (1 ⊗ₜ[ℚ] v) * (u ⊗ₜ[ℚ] 1) + simp only [Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul] + +end Erdos3 + +end + +section + +namespace Erdos3 +variable {X : Type*} +attribute [local instance] LieRing.ofAssociativeRing + +noncomputable def scaledFreeGenerator (s : ℕ) (x : X) : TruncatedSeries (FreeAlgebra ℚ X) s := + truncatedSeriesMk s (PowerSeries.monomial 1 (FreeAlgebra.ι ℚ x)) + +theorem scaledFreeGenerator_positive (s : ℕ) (x : X) : + scaledFreeGenerator s x ∈ truncatedSeriesPositive s := by + rw [mem_truncatedSeriesPositive] + change PowerSeries.constantCoeff (PowerSeries.monomial 1 (FreeAlgebra.ι ℚ x)) = 0 + rw [← PowerSeries.coeff_zero_eq_constantCoeff, PowerSeries.coeff_monomial] + rfl + +theorem scaledFreeGenerator_primitive (s : ℕ) (x : X) : + TruncatedPrimitive (scaledFreeGenerator s x) := by + apply (truncatedPrimitive_iff_coeff _).mpr + intro n hn + change FreePrimitive (PowerSeries.coeff n (PowerSeries.monomial 1 (FreeAlgebra.ι ℚ x))) + rw [PowerSeries.coeff_monomial] + split_ifs + · exact freePrimitive_generator x + · simp [FreePrimitive] + +theorem scaled_bchPolynomial (s : ℕ) : + truncatedSeriesMk s (freeScaleSeries (bchPolynomial (s + 1))) = + nilpotentBCH (scaledFreeGenerator s (0 : Fin 2)) (scaledFreeGenerator s (1 : Fin 2)) := by + have h := bchPolynomialEval_eq (A := TruncatedSeries (FreeAlgebra ℚ (Fin 2)) s) + (truncatedSeriesPositive s) (k := s + 1) + (fun _ ha => truncatedSeriesPositive_pow ha) + (a := scaledFreeGenerator s (0 : Fin 2)) (b := scaledFreeGenerator s (1 : Fin 2)) + (scaledFreeGenerator_positive s (0 : Fin 2)) (scaledFreeGenerator_positive s (1 : Fin 2)) + rw [bchPolynomialEval_formula] at h + simpa only [bchPolynomial, map_finiteLog, map_sub, map_mul, map_one, map_finiteExp, + freeScaleSeries_generator, scaledFreeGenerator] using h + +theorem bchHomogeneousPart_primitive (s n : ℕ) (hn : n ≤ s) : + FreePrimitive (freeHomogeneousPart n (bchPolynomial (s + 1))) := by + have h := (scaledFreeGenerator_primitive s (0 : Fin 2)).bch + (scaledFreeGenerator_primitive s (1 : Fin 2)) + (scaledFreeGenerator_positive s (0 : Fin 2)) (scaledFreeGenerator_positive s (1 : Fin 2)) + rw [← scaled_bchPolynomial] at h + exact h.coeff n hn + +theorem bchHomogeneousPart_mem (s n : ℕ) (hn : n ≤ s) : + freeHomogeneousPart n (bchPolynomial (s + 1)) ∈ freeAssociativeLieSubalgebra := + (bchHomogeneousPart_primitive s n hn).mem + +theorem bchTruncation_mem (s : ℕ) : + freeTruncation s (bchPolynomial (s + 1)) ∈ freeAssociativeLieSubalgebra := by + rw [freeTruncation_apply] + apply freeAssociativeLieSubalgebra.sum_mem + intro n hn + exact bchHomogeneousPart_mem s n (Nat.lt_succ_iff.mp (Finset.mem_range.mp hn)) + +noncomputable def bchLiePolynomial (s : ℕ) : FreeLieAlgebra ℚ (Fin 2) := + Classical.choose (bchTruncation_mem s) + +theorem bchLiePolynomial_expansion (s : ℕ) : + freeLieAssociativeExpansion (bchLiePolynomial s) = freeTruncation s (bchPolynomial (s + 1)) := + Classical.choose_spec (bchTruncation_mem s) + +theorem bchLiePolynomial_unique (s : ℕ) {p : FreeLieAlgebra ℚ (Fin 2)} + (hp : freeLieAssociativeExpansion p = freeTruncation s (bchPolynomial (s + 1))) : + p = bchLiePolynomial s := + freeLieAssociativeExpansion_injective (hp.trans (bchLiePolynomial_expansion s).symm) + +noncomputable def lieBCH {L : Type*} [LieRing L] [LieAlgebra ℚ L] (s : ℕ) (a b : L) : L := + FreeLieAlgebra.lift ℚ ![a, b] (bchLiePolynomial s) + +end Erdos3 + +end + +section + +namespace Erdos3 + +noncomputable def bchWordCoefficients (s : ℕ) : FreeSemigroup (Fin 2) →₀ ℚ := + (freeLieWordExpansion (bchLiePolynomial s)).coeff + +noncomputable def bchBracketSupport (s : ℕ) : Finset (FreeSemigroup (Fin 2)) := + (bchWordCoefficients s).support + +noncomputable def bchBracketCoefficient (s : ℕ) (w : FreeSemigroup (Fin 2)) : ℚ := + bchWordCoefficients s w / w.length + +theorem bchWordExpansion_truncation (s : ℕ) : + wordTruncation s (freeLieWordExpansion (bchLiePolynomial s)) = + freeLieWordExpansion (bchLiePolynomial s) := by + apply wordPolynomialEmbedding_injective + rw [wordPolynomialEmbedding_truncation, wordPolynomialEmbedding_freeLieExpansion, + bchLiePolynomial_expansion, freeTruncation_idempotent] + +theorem bchBracketSupport_length (s : ℕ) {w : FreeSemigroup (Fin 2)} + (hw : w ∈ bchBracketSupport s) : w.length ≤ s := by + have h := congrArg (fun p : WordPolynomial (Fin 2) => p.coeff w) (bchWordExpansion_truncation s) + rw [wordTruncation_coeff] at h + by_contra hgt + rw [ite_eq_right hgt] at h + exact (Finsupp.mem_support_iff.mp hw) h.symm + +theorem lieBCH_bracket_formula {L : Type*} [LieRing L] [LieAlgebra ℚ L] + (s : ℕ) (a b : L) : + lieBCH s a b = ∑ w ∈ bchBracketSupport s, bchBracketCoefficient s w • dynkinWord ![a, b] w := by + rw [lieBCH, ← dynkinProjection_lift] + change (bchWordCoefficients s).sum (fun w r => r • ((w.length : ℚ)⁻¹ • dynkinWord ![a, b] w)) = _ + simp only [Finsupp.sum, bchBracketSupport, bchBracketCoefficient, smul_smul, div_eq_mul_inv] + +noncomputable def bchCoefficientHeight (s : ℕ) : ℕ := + 1 + (bchBracketSupport s).sup (fun w => + max (bchBracketCoefficient s w).num.natAbs (bchBracketCoefficient s w).den) + +theorem bchCoefficientHeight_pos (s : ℕ) : 0 < bchCoefficientHeight s := by + unfold bchCoefficientHeight + omega + +theorem bchBracketCoefficient_height (s : ℕ) {w : FreeSemigroup (Fin 2)} + (hw : w ∈ bchBracketSupport s) : RationalHeightLE (bchBracketCoefficient s w) (bchCoefficientHeight s) := by + have h := Finset.le_sup (f := fun w => + max (bchBracketCoefficient s w).num.natAbs (bchBracketCoefficient s w).den) hw + constructor + · exact (le_max_left _ _).trans (h.trans (Nat.le_add_left _ 1)) + · exact (le_max_right _ _).trans (h.trans (Nat.le_add_left _ 1)) + +theorem exists_bch_integer_coefficients (s : ℕ) : + ∃ D : ℕ, 0 < D ∧ D ≤ bchCoefficientHeight s ^ (bchBracketSupport s).card ∧ + ∃ c : (w : FreeSemigroup (Fin 2)) → w ∈ bchBracketSupport s → ℤ, + (∀ w hw, (c w hw : ℚ) = (D : ℚ) * bchBracketCoefficient s w) ∧ + ∀ w hw, (c w hw).natAbs ≤ bchCoefficientHeight s ^ (bchBracketSupport s).card := by + classical + let q : bchBracketSupport s → ℚ := fun w => bchBracketCoefficient s w + have hq : ∀ w, RationalHeightLE (q w) (bchCoefficientHeight s) := + fun w => bchBracketCoefficient_height s w.property + obtain ⟨D, hD, hDb, c, hc, hcb⟩ := exists_bounded_integer_array q hq + refine ⟨D, hD, ?_, (fun w hw => c ⟨w, hw⟩), ?_, ?_⟩ + · simpa only [Fintype.card_coe] using hDb + · intro w hw + exact hc ⟨w, hw⟩ + · intro w hw + simpa only [Fintype.card_coe] using hcb ⟨w, hw⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 +variable {X A : Type*} [Ring A] [Algebra ℚ A] +attribute [local instance] LieRing.ofAssociativeRing + +namespace NilpotentAlgebraFiltration +variable {s : ℕ} (F : NilpotentAlgebraFiltration A s) (f : X → A) + +theorem eval_freeWord_mem (hf : ∀ x, f x ∈ F.layer 1) (w : FreeMonoid X) : + FreeAlgebra.lift ℚ f (freeWord w) ∈ F.layer w.length := by + induction w using freeMonoid_induction_right with + | h1 => simp [F.zero_eq_top] + | hstep w x hw => + rw [map_mul, map_mul, freeWord_of, FreeAlgebra.lift_ι_apply, + FreeMonoid.length_mul, FreeMonoid.length_of] + exact F.mul_mem hw (hf x) + +theorem eval_freeWord_eq_zero (hf : ∀ x, f x ∈ F.layer 1) (w : FreeMonoid X) + (hw : s < w.length) : FreeAlgebra.lift ℚ f (freeWord w) = 0 := by + have h := F.antitone (Nat.succ_le_of_lt hw) (F.eval_freeWord_mem f hf w) + simpa only [F.terminal, Submodule.mem_bot] using h + +theorem eval_freeTruncation (hf : ∀ x, f x ∈ F.layer 1) (p : FreeAlgebra ℚ X) : + FreeAlgebra.lift ℚ f (freeTruncation s p) = FreeAlgebra.lift ℚ f p := by + apply freeAlgebra_linear_induction (fun p => + FreeAlgebra.lift ℚ f (freeTruncation s p) = FreeAlgebra.lift ℚ f p) + · simp + · intro p q hp hq + simp only [map_add, hp, hq] + · intro r p hp + simp only [map_smul, hp] + · intro w + rw [freeTruncation_word] + split_ifs with hw + · rfl + · rw [map_zero, F.eval_freeWord_eq_zero f hf w (Nat.lt_of_not_ge hw)] + +end NilpotentAlgebraFiltration + +theorem freeLieAssociativeExpansion_eval (f : X → A) (p : FreeLieAlgebra ℚ X) : + FreeAlgebra.lift ℚ f (freeLieAssociativeExpansion p) = FreeLieAlgebra.lift ℚ f p := by + have h : (FreeAlgebra.lift ℚ f).toLieHom.comp freeLieAssociativeExpansion = FreeLieAlgebra.lift ℚ f := by + apply FreeLieAlgebra.hom_ext + intro x + simp [freeLieAssociativeExpansion] + exact DFunLike.congr_fun h p + +theorem NilpotentAlgebraFiltration.lieBCH_eq {s : ℕ} (F : NilpotentAlgebraFiltration A s) + {a b : A} (ha : a ∈ F.layer 1) (hb : b ∈ F.layer 1) : lieBCH s a b = nilpotentBCH a b := by + rw [lieBCH, ← freeLieAssociativeExpansion_eval, bchLiePolynomial_expansion, + F.eval_freeTruncation ![a, b] (by intro x; fin_cases x <;> assumption)] + exact F.bchPolynomial_formula ha hb + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module + +section General + +variable {X Y L : Type*} [TopologicalSpace Y] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousConstSMul ℚ L] + +omit [IsTopologicalAddGroup L] [ContinuousConstSMul ℚ L] in +theorem continuous_rightBracketList + (hlie : Continuous (fun z : L × L => ⁅z.1, z.2⁆)) + (f : X → Y → L) (hf : ∀ x, Continuous (f x)) (xs : List X) + (a : Y → L) (ha : Continuous a) : + Continuous (fun y => rightBracketList (fun x => f x y) xs (a y)) := by + induction xs generalizing a with + | nil => exact ha + | cons x xs ih => + exact ih (fun y => ⁅a y, f x y⁆) (hlie.comp (ha.prodMk (hf x))) + +omit [IsTopologicalAddGroup L] [ContinuousConstSMul ℚ L] in +theorem continuous_dynkinWord + (hlie : Continuous (fun z : L × L => ⁅z.1, z.2⁆)) + (f : X → Y → L) (hf : ∀ x, Continuous (f x)) (w : FreeSemigroup X) : + Continuous (fun y => dynkinWord (fun x => f x y) w) := + continuous_rightBracketList hlie f hf w.tail (f w.head) (hf w.head) + +theorem continuous_lieBCH + (hlie : Continuous (fun z : L × L => ⁅z.1, z.2⁆)) (s : ℕ) : + Continuous (fun z : L × L => lieBCH s z.1 z.2) := by + simp only [lieBCH_bracket_formula] + apply continuous_finsetSum + intro w _ + apply Continuous.const_smul + exact continuous_dynkinWord hlie (fun i (z : L × L) => ![z.1, z.2] i) + (by intro i; fin_cases i; exact continuous_fst; exact continuous_snd) w + +end General + +section Real + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + +theorem continuous_lie_of_real_basis (e : Basis ι ℝ L) : + Continuous (fun z : L × L => ⁅z.1, z.2⁆) := by + classical + have hcoord (i : ι) : Continuous (fun x : L => e.repr x i) := + (continuous_apply i).comp e.equivFunL.continuous + have hformula (a b : L) : ⁅a, b⁆ = + ∑ i, ∑ j, e.repr a i • e.repr b j • ⁅e i, e j⁆ := by + conv_lhs => rw [← e.sum_repr a, ← e.sum_repr b] + simp only [sum_lie, lie_sum, smul_lie, lie_smul, Finset.smul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + exact smul_comm _ _ _ + have heq : (fun z : L × L => ⁅z.1, z.2⁆) = + (fun z => ∑ i, ∑ j, e.repr z.1 i • e.repr z.2 j • ⁅e i, e j⁆) := + funext (fun z => hformula z.1 z.2) + rw [heq] + apply continuous_finsetSum + intro i _ + apply continuous_finsetSum + intro j _ + exact ((hcoord i).comp continuous_fst).smul + (((hcoord j).comp continuous_snd).smul continuous_const) + +theorem continuous_lie_finiteDimensional [FiniteDimensional ℝ L] : + Continuous (fun z : L × L => ⁅z.1, z.2⁆) := + continuous_lie_of_real_basis (Module.finBasis ℝ L) + +end Real + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/LinearBCHAbelian.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/LinearBCHAbelian.lean new file mode 100644 index 0000000000000000000000000000000000000000..88b962c47aa37157d4adb4bb43f5cf056f940964 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/LinearBCHAbelian.lean @@ -0,0 +1,54 @@ +import Mathlib.Algebra.Lie.BaseChange +import OAI.Combinatorics.Progressions.Nilpotent.BCHNonlinearRemainder + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem linearMap_lieBCH_eq_add {L V : Type*} [LieRing L] [LieAlgebra ℚ L] + [AddCommGroup V] [Module ℚ V] (f : L →ₗ[ℚ] V) + (hf : ∀ x y : L, f ⁅x, y⁆ = 0) {s : ℕ} (hs : 1 ≤ s) (a b : L) : + f (lieBCH s a b) = f a + f b := by + let : LieRing V := { + toAddCommGroup := inferInstance + bracket := fun _ _ => 0 + add_lie := fun _ _ _ => (add_zero 0).symm + lie_add := fun _ _ _ => (add_zero 0).symm + lie_self := fun _ => rfl + leibniz_lie := fun _ _ _ => (add_zero 0).symm } + let : LieAlgebra ℚ V := { + toModule := inferInstance + lie_smul := fun t _ _ => (smul_zero t).symm } + let : IsLieAbelian V := ⟨fun _ _ => rfl⟩ + let φ : L →ₗ⁅ℚ⁆ V := { f with map_lie' := fun {x y} => hf x y } + exact (map_lieBCH φ s a b).trans (lieBCH_eq_add_of_isLieAbelian hs (f a) (f b)) + +theorem linearMap_baseChange_lie_eq_zero {L V : Type*} [LieRing L] [LieAlgebra ℚ L] + [AddCommGroup V] [Module ℚ V] (f : L →ₗ[ℚ] V) + (hf : ∀ x y : L, f ⁅x, y⁆ = 0) (a b : ℝ ⊗[ℚ] L) : + f.baseChange ℝ ⁅a, b⁆ = 0 := by + induction a using TensorProduct.inductionOn with + | tmul a x => + induction b using TensorProduct.inductionOn with + | tmul b y => + simp only [LieAlgebra.ExtendScalars.bracket_tmul, LinearMap.baseChange_tmul, hf, + TensorProduct.tmul_zero] + | add b c hb hc => rw [lie_add, map_add, hb, hc, add_zero] + | add a b ha hb => rw [add_lie, map_add, ha, hb, add_zero] + +theorem linearMap_baseChange_lieBCH_eq_add {L V : Type*} [LieRing L] [LieAlgebra ℚ L] + [AddCommGroup V] [Module ℚ V] (f : L →ₗ[ℚ] V) + (hf : ∀ x y : L, f ⁅x, y⁆ = 0) {s : ℕ} (hs : 1 ≤ s) (a b : ℝ ⊗[ℚ] L) : + f.baseChange ℝ (lieBCH s a b) = f.baseChange ℝ a + f.baseChange ℝ b := + linearMap_lieBCH_eq_add ((f.baseChange ℝ).restrictScalars ℚ) + (linearMap_baseChange_lie_eq_zero f hf) hs a b + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/LocalMajorDenseSliceNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/LocalMajorDenseSliceNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..34bb35f14b0dccd69a3886b1c71d7ba17849b48a --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/LocalMajorDenseSliceNiltest.lean @@ -0,0 +1,783 @@ +import Mathlib.Algebra.MvPolynomial.Degrees +import Mathlib.Analysis.Complex.Circle +import OAI.Combinatorics.Progressions.Estimates.VectorApproximationPrecomposition +import OAI.Combinatorics.Progressions.Estimates.WeightedTwistedTranslationLipschitz +import OAI.Combinatorics.Progressions.Fourier.BohrNiltestBudget +import OAI.Combinatorics.Progressions.Lattices.ResidueBoxSliceCoordinateDisintegration +import OAI.Combinatorics.Progressions.Polynomial.MajorTranslationDegreeSymbol +import OAI.Combinatorics.Progressions.Polynomial.SlowPolynomialSliceLogCost +import OAI.Combinatorics.Progressions.Polynomial.WeightedTranslationLatticePhase + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def scaleComplex (T : D.Niltest w) (c : ℂ) : D.Niltest w where + orbit := T.orbit + observable := fun x => c * T.observable x + normBound := ‖c‖₊ * T.normBound + lipBound := ‖c‖₊ * T.lipBound + norm_le x := by + simpa only [norm_mul, NNReal.coe_mul, coe_nnnorm] using + mul_le_mul_of_nonneg_left (T.norm_le x) (norm_nonneg c) + lipschitz := by + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + simpa only [dist_eq_norm, ← mul_sub, norm_mul, NNReal.coe_mul, coe_nnnorm, mul_assoc] using + mul_le_mul_of_nonneg_left (T.lipschitz.dist_le_mul x y) (norm_nonneg c) + +theorem scaleComplex_eval (T : D.Niltest w) (c : ℂ) (x : σ → ℤ) : + (T.scaleComplex c).eval x = c * T.eval x := rfl + +theorem scaleComplex_evalCyclic (T : D.Niltest w) (c : ℂ) (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (T.scaleComplex c).evalCyclic N x = c * T.evalCyclic N x := rfl + +theorem scaleComplex_norm (T : D.Niltest w) {c : ℂ} (hc : ‖c‖ ≤ 1) : + (T.scaleComplex c).normBound ≤ T.normBound := by + change ‖c‖₊ * T.normBound ≤ T.normBound + exact mul_le_of_le_one_left (by positivity) (by exact_mod_cast hc) + +theorem scaleComplex_complexity (T : D.Niltest w) {c : ℂ} (hc : ‖c‖ ≤ 1) + {p : ℝ} (hT : T.ComplexityLE p) : (T.scaleComplex c).ComplexityLE p := by + refine ⟨hT.1, ?_⟩ + change Real.log (2 + ‖c‖ * (T.normBound : ℝ) + ‖c‖ * (T.lipBound : ℝ)) ≤ p + have hn := mul_le_mul_of_nonneg_right hc T.normBound.coe_nonneg + have hl := mul_le_mul_of_nonneg_right hc T.lipBound.coe_nonneg + exact (Real.log_le_log (by positivity) (by linarith)).trans hT.2 + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct Manifold ContDiff + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def evalReal (T : D.Niltest w) (x : σ → ℝ) : ℂ := + T.observable (QuotientGroup.mk (D.filtration.realification.polynomialOrbitRealEval w x T.orbit)) + +theorem evalReal_integer (T : D.Niltest w) (x : σ → ℤ) : + T.evalReal (fun i => (x i : ℝ)) = T.eval x := by + unfold evalReal eval + rw [NilpotentLieFiltration.polynomialOrbitRealEval_integer] + +theorem norm_evalReal_le (T : D.Niltest w) (x : σ → ℝ) : ‖T.evalReal x‖ ≤ T.normBound := + T.norm_le _ + +theorem continuous_evalReal [Fintype σ] (T : D.Niltest w) : Continuous T.evalReal := by + let := D.metricSpace + let := NilpotentLieBCHGroup.basisChartedSpace + (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) (D.basis.baseChange ℝ) + have hp := D.filtration.realification.contMDiff_polynomialOrbitRealEval + (D.basis.baseChange ℝ) w T.orbit ⊤ + exact T.lipschitz.continuous.comp (QuotientGroup.continuous_mk.comp hp.continuous) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def expNormalize (T : D.Niltest w) (p : ℝ) : D.Niltest w := + T.scaleComplex (Real.exp (-p) : ℂ) + +theorem expNormalize_norm (T : D.Niltest w) {p : ℝ} (hT : T.ComplexityLE p) : + (T.expNormalize p).normBound ≤ 1 := by + have hb := T.observable_budget hT + have hl := T.lipBound.coe_nonneg + have hn : (T.normBound : ℝ) ≤ Real.exp p := by linarith + change ‖(Real.exp (-p) : ℂ)‖₊ * T.normBound ≤ 1 + apply NNReal.coe_le_coe.mp + simp only [NNReal.coe_mul, coe_nnnorm, NNReal.coe_one, Complex.norm_real, + Real.norm_eq_abs, abs_of_pos (Real.exp_pos (-p))] + calc + _ ≤ Real.exp (-p) * Real.exp p := mul_le_mul_of_nonneg_left hn (Real.exp_nonneg _) + _ = 1 := by rw [← Real.exp_add, neg_add_cancel, Real.exp_zero] + +theorem expNormalize_complexity (T : D.Niltest w) {p : ℝ} (hT : T.ComplexityLE p) : + (T.expNormalize p).ComplexityLE p := by + have hp : 0 ≤ p := (Nat.cast_nonneg d).trans hT.1.1 + apply T.scaleComplex_complexity _ hT + simp only [Complex.norm_real, Real.norm_eq_abs, abs_of_pos (Real.exp_pos (-p))] + exact Real.exp_le_one_iff.mpr (by linarith) + +theorem expNormalize_eval (T : D.Niltest w) (p : ℝ) (x : σ → ℤ) : + (T.expNormalize p).eval x = (Real.exp (-p) : ℂ) * T.eval x := rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct BigOperators + +theorem exists_bounded_niltest_pair_sum {J σ L K : Type*} [Fintype J] [Nonempty J] + [LieRing L] [LieAlgebra ℚ L] [LieRing K] [LieAlgebra ℚ K] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] K)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] K)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] K)] [T2Space (ℝ ⊗[ℚ] K)] + {s t d e : ℕ} (D : RationalFilteredNilmanifold L s d) + (E : RationalFilteredNilmanifold K t e) (w : σ → ℕ) + (gD : D.filtration.realification.PolynomialOrbit w) + (gE : E.filtration.realification.PolynomialOrbit w) + (A : J → D.Niltest w) (B : J → E.Niltest w) (c : J → ℂ) {p : ℝ} + (hAnorm : ∀ j, (A j).normBound ≤ 1) (hBnorm : ∀ j, (B j).normBound ≤ 1) + (hA : ∀ j, (A j).ComplexityLE p) (hB : ∀ j, (B j).ComplexityLE p) + (hAg : ∀ j, (A j).orbit = gD) (hBg : ∀ j, (B j).orbit = gE) + (hc : ∀ j, ‖c j‖ ≤ 2) : + ∃ N : ℕ, 0 < N ∧ N = 2 * Fintype.card J ∧ + ∃ (A' : Fin N → D.Niltest w) (B' : Fin N → E.Niltest w), + (∀ j, (A' j).normBound ≤ 1) ∧ (∀ j, (B' j).normBound ≤ 1) ∧ + (∀ j, (A' j).ComplexityLE p) ∧ (∀ j, (B' j).ComplexityLE p) ∧ + (∀ j, (A' j).orbit = gD) ∧ (∀ j, (B' j).orbit = gE) ∧ + ∀ x, ∑ j, (A' j).eval x * (B' j).eval x = + ∑ j, ((A j).eval x * (B j).eval x) * c j := by + classical + let f := (Fintype.equivFin (Bool × J)).symm + let A' (j : Fin (Fintype.card (Bool × J))) := + (A (f j).2).scaleComplex (c (f j).2 / 2) + let B' (j : Fin (Fintype.card (Bool × J))) := B (f j).2 + refine ⟨Fintype.card (Bool × J), Fintype.card_pos, ?_, A', B', ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · simp only [Fintype.card_prod, Fintype.card_bool] + · intro j + exact ((A (f j).2).scaleComplex_norm (norm_complex_half_le_one (hc (f j).2))).trans (hAnorm _) + · intro j + exact hBnorm _ + · intro j + exact (A (f j).2).scaleComplex_complexity (norm_complex_half_le_one (hc (f j).2)) (hA _) + · intro j + exact hB _ + · intro j + exact hAg _ + · intro j + exact hBg _ + · intro x + exact (f.sum_comp (fun j => (c j.2 / 2 * (A j.2).eval x) * (B j.2).eval x)).trans + (sum_double_half_products (fun j => (A j).eval x) (fun j => (B j).eval x) c) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def phaseShift (T : D.Niltest w) (a : ℝ) : D.Niltest w := + T.scaleComplex (Real.fourierChar a : ℂ) + +@[simp] theorem phaseShift_orbit (T : D.Niltest w) (a : ℝ) : + (T.phaseShift a).orbit = T.orbit := rfl + +@[simp] theorem phaseShift_normBound (T : D.Niltest w) (a : ℝ) : + (T.phaseShift a).normBound = T.normBound := by + have hn : ‖(Real.fourierChar a : ℂ)‖₊ = 1 := by + apply NNReal.coe_injective + exact Circle.norm_coe _ + change ‖(Real.fourierChar a : ℂ)‖₊ * T.normBound = T.normBound + rw [hn, one_mul] + +@[simp] theorem phaseShift_lipBound (T : D.Niltest w) (a : ℝ) : + (T.phaseShift a).lipBound = T.lipBound := by + have hn : ‖(Real.fourierChar a : ℂ)‖₊ = 1 := by + apply NNReal.coe_injective + exact Circle.norm_coe _ + change ‖(Real.fourierChar a : ℂ)‖₊ * T.lipBound = T.lipBound + rw [hn, one_mul] + +@[simp] theorem phaseShift_complexity_iff (T : D.Niltest w) (a p : ℝ) : + (T.phaseShift a).ComplexityLE p ↔ T.ComplexityLE p := by + simp only [ComplexityLE, phaseShift_normBound, phaseShift_lipBound] + +@[simp] theorem phaseShift_eval (T : D.Niltest w) (a : ℝ) (u : σ → ℤ) : + (T.phaseShift a).eval u = (Real.fourierChar a : ℂ) * T.eval u := rfl + +@[simp] theorem phaseShift_evalReal (T : D.Niltest w) (a : ℝ) (u : σ → ℝ) : + (T.phaseShift a).evalReal u = (Real.fourierChar a : ℂ) * T.evalReal u := rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalTorus + +instance zeroAlgebraSubsingleton : Subsingleton (Algebra 0) := + inferInstanceAs (Subsingleton (Fin 0 → ℚ)) + +def trivialFiltration (s : ℕ) : NilpotentLieFiltration (Algebra 0) s where + layer _ := ⊤ + antitone _ _ _ := le_rfl + one_eq_top := rfl + lie_mem _ _ := Submodule.mem_top + terminal := by + apply le_antisymm _ bot_le + intro x _ + simpa only [Submodule.mem_bot] using (Subsingleton.elim x 0) + +theorem trivialFiltration_basis_layers (s j : ℕ) : + (trivialFiltration s).layer j = Submodule.span ℚ ((basis 0) '' {_i : Fin 0 | j ≤ (0 : ℕ)}) := by + ext x + rw [Subsingleton.elim x 0] + simp only [Submodule.zero_mem] + +theorem trivial_lattice_inner_grid (s : ℕ) : + scaledIntegerGrid 1 ⊆ bchSubgroupCoordinates (basis 0) (⊤ : Subgroup (trivialFiltration s).Group) := by + intro x _ + trivial + +theorem trivial_lattice_outer_grid (s : ℕ) : + bchSubgroupCoordinates (basis 0) (⊤ : Subgroup (trivialFiltration s).Group) ⊆ denominatorGrid 1 := by + intro x _ + exact ⟨0, fun i => Fin.elim0 i⟩ + +noncomputable def trivialNilmanifold (s : ℕ) : RationalFilteredNilmanifold (Algebra 0) s 0 := + (trivialFiltration s).ofAdaptedBasis (basis 0) (fun _ => 0) (trivialFiltration_basis_layers s) + ⊤ 1 (by omega) (trivial_lattice_inner_grid s) (trivial_lattice_outer_grid s) + +theorem trivialNilmanifold_geometry (s : ℕ) {p : ℝ} (hp : 0 ≤ p) : + (trivialNilmanifold s).GeometryComplexityLE p := by + apply (trivialFiltration s).ofAdaptedBasis_geometry (basis 0) (fun _ => 0) + (trivialFiltration_basis_layers s) ⊤ 1 (by omega) + (trivial_lattice_inner_grid s) (trivial_lattice_outer_grid s) hp (by simpa using hp) + · simpa only [Nat.cast_one] using Real.one_le_exp hp + · intro i + exact Fin.elim0 i + +theorem trivialNilmanifold_const_one_complexity (s : ℕ) {σ : Type*} (w : σ → ℕ) {p : ℝ} + (hp : 2 ≤ p) : + (RationalFilteredNilmanifold.Niltest.const (trivialNilmanifold s) w 1).ComplexityLE p := by + refine ⟨trivialNilmanifold_geometry s (by linarith), ?_⟩ + change Real.log (2 + (‖(1 : ℂ)‖₊ : ℝ) + (0 : ℝ)) ≤ p + simp only [nnnorm_one, NNReal.coe_one, add_zero] + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3) + norm_num at * + linarith + +end Erdos3.RationalTorus + +end + +section + +namespace Erdos3 + +open MvPolynomial + +variable {U : Type*} + +noncomputable def zeroDegreePolynomialPhaseNiltest (w : U → ℕ) + (P : MvPolynomial U ℝ) : (RationalTorus.trivialNilmanifold 0).Niltest w := + RationalFilteredNilmanifold.Niltest.const (RationalTorus.trivialNilmanifold 0) w + (Real.fourierChar (P.coeff 0) : ℂ) + +@[simp] theorem zeroDegreePolynomialPhaseNiltest_normBound (w : U → ℕ) + (P : MvPolynomial U ℝ) : + (zeroDegreePolynomialPhaseNiltest w P).normBound = 1 := by + apply NNReal.eq + exact Circle.norm_coe _ + +theorem zeroDegreePolynomialPhaseNiltest_complexity (w : U → ℕ) + (P : MvPolynomial U ℝ) {p : ℝ} (hp : 2 ≤ p) : + (zeroDegreePolynomialPhaseNiltest w P).ComplexityLE p := by + refine ⟨RationalTorus.trivialNilmanifold_geometry 0 (by linarith), ?_⟩ + change Real.log (2 + (‖(Real.fourierChar (P.coeff 0) : ℂ)‖₊ : ℝ) + 0) ≤ p + simp only [coe_nnnorm, Circle.norm_coe, add_zero] + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3) + norm_num at h ⊢ + linarith + +theorem zeroDegreePolynomialPhaseNiltest_evalReal (w : U → ℕ) + (P : MvPolynomial U ℝ) (hP : P.totalDegree ≤ 0) (u : U → ℝ) : + (zeroDegreePolynomialPhaseNiltest w P).evalReal u = + (Real.fourierChar (eval u P) : ℂ) := by + have heq : P = C (P.coeff 0) := totalDegree_eq_zero_iff_eq_C.mp (Nat.eq_zero_of_le_zero hP) + change (Real.fourierChar (P.coeff 0) : ℂ) = (Real.fourierChar (eval u P) : ℂ) + conv_rhs => rw [heq, eval_C] + +theorem exists_zeroDegreePolynomialPhaseNiltest (w : U → ℕ) + (P : MvPolynomial U ℝ) (hP : P.totalDegree ≤ 0) : + ∃ T : (RationalTorus.trivialNilmanifold 0).Niltest w, + T.normBound = 1 ∧ T.ComplexityLE 2 ∧ + ∀ u : U → ℝ, T.evalReal u = (Real.fourierChar (eval u P) : ℂ) := + ⟨zeroDegreePolynomialPhaseNiltest w P, + zeroDegreePolynomialPhaseNiltest_normBound w P, + zeroDegreePolynomialPhaseNiltest_complexity w P le_rfl, + zeroDegreePolynomialPhaseNiltest_evalReal w P hP⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module NilpotentLieBCHGroup +open scoped NNReal TensorProduct + +variable {m : ℕ} (w : Fin m → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) + (hwd : ∀ i, w i ≤ d) [Fintype (WeightedBasisIndex w d)] + +noncomputable def weightedTranslationBufferedObservable (Ψ : PatchKernel m) + (D₀ : MvPolynomial (Fin m) ℝ) : + (weightedTranslationNilmanifold w d hw hwd).Space → ℂ := + bufferedTranslationQuotientPhase Ψ D₀ ∘ weightedTranslationPhaseQuotientMap w d hw hwd + +@[simp] theorem weightedTranslationBufferedObservable_mk (Ψ : PatchKernel m) + (D₀ : MvPolynomial (Fin m) ℝ) + (g : (weightedFiltration w d hwd).realification.Group) : + weightedTranslationBufferedObservable w d hw hwd Ψ D₀ (QuotientGroup.mk g) = + bufferedTranslationPhase Ψ D₀ (bchRealTranslationHom w d hwd g) := rfl + +theorem weightedTranslationBufferedObservable_norm_le_one (Ψ : PatchKernel m) + (D₀ : MvPolynomial (Fin m) ℝ) + (g : (weightedTranslationNilmanifold w d hw hwd).Space) : + ‖weightedTranslationBufferedObservable w d hw hwd Ψ D₀ g‖ ≤ 1 := + bufferedTranslationQuotientPhase_norm_le_one Ψ D₀ _ + +variable [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + +theorem weightedTranslationBufferedObservable_lipschitz + (hd : 0 < d) (Ψ : PatchKernel m) (D₀ : MvPolynomial (Fin m) ℝ) (M : ℝ≥0) + (hdegree : D₀.totalDegree ≤ d) (hD : realPolynomialMass D₀ ≤ M) : + letI := (weightedTranslationNilmanifold w d hw hwd).metricSpace + LipschitzWith (2 * bufferedTranslationTermLip w d Ψ M) + (weightedTranslationBufferedObservable w d hw hwd Ψ D₀) := by + let e := (weightedOrderedBasis w d hw).baseChange ℝ + let : FiniteDimensional ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d) := e.finiteDimensional_of_finite + let := rightMetricSpace + (hnil := (weightedFiltration w d hwd).realification.lowerCentralSeries_eq_bot) e + let := rightMetricSpace_isIsometricSMul + (hnil := (weightedFiltration w d hwd).realification.lowerCentralSeries_eq_bot) e + exact rightCosetMetricSpace_lipschitz_lift + (weightedTranslationNilmanifold w d hw hwd).realLattice + (weightedTranslationNilmanifold w d hw hwd).realLattice_closed_discrete.1 + (weightedTranslationBufferedObservable w d hw hwd Ψ D₀) + (bufferedTranslationPhase_lipschitz w d hw hd hwd Ψ D₀ M hdegree hD) + +noncomputable def weightedTranslationBufferedNiltest {U : Type*} (ω : U → ℕ) + (hd : 0 < d) (Ψ : PatchKernel m) (D₀ : MvPolynomial (Fin m) ℝ) (M : ℝ≥0) + (hdegree : D₀.totalDegree ≤ d) (hD : realPolynomialMass D₀ ≤ M) + (q : (weightedFiltration w d hwd).realification.PolynomialOrbit ω) : + (weightedTranslationNilmanifold w d hw hwd).Niltest ω where + orbit := q + observable := weightedTranslationBufferedObservable w d hw hwd Ψ D₀ + normBound := 1 + lipBound := 2 * bufferedTranslationTermLip w d Ψ M + norm_le := weightedTranslationBufferedObservable_norm_le_one w d hw hwd Ψ D₀ + lipschitz := weightedTranslationBufferedObservable_lipschitz w d hw hwd hd Ψ D₀ M hdegree hD + +@[simp] theorem weightedTranslationBufferedNiltest_eval {U : Type*} (ω : U → ℕ) + (hd : 0 < d) (Ψ : PatchKernel m) (D₀ : MvPolynomial (Fin m) ℝ) (M : ℝ≥0) + (hdegree : D₀.totalDegree ≤ d) (hD : realPolynomialMass D₀ ≤ M) + (q : (weightedFiltration w d hwd).realification.PolynomialOrbit ω) (t : U → ℤ) : + (weightedTranslationBufferedNiltest w d hw hwd ω hd Ψ D₀ M hdegree hD q).eval t = + bufferedTranslationPhase Ψ D₀ (bchRealTranslationHom w d hwd + ((weightedFiltration w d hwd).realification.polynomialOrbitEval ω t q)) := rfl + +@[simp] theorem weightedTranslationBufferedNiltest_evalReal {U : Type*} (ω : U → ℕ) + (hd : 0 < d) (Ψ : PatchKernel m) (D₀ : MvPolynomial (Fin m) ℝ) (M : ℝ≥0) + (hdegree : D₀.totalDegree ≤ d) (hD : realPolynomialMass D₀ ≤ M) + (q : (weightedFiltration w d hwd).realification.PolynomialOrbit ω) (t : U → ℝ) : + (weightedTranslationBufferedNiltest w d hw hwd ω hd Ψ D₀ M hdegree hD q).evalReal t = + bufferedTranslationPhase Ψ D₀ (bchRealTranslationHom w d hwd + ((weightedFiltration w d hwd).realification.polynomialOrbitRealEval ω t q)) := rfl + +theorem weightedTranslationBufferedNiltest_complexity {U : Type*} (ω : U → ℕ) + (hd : 0 < d) (Ψ : PatchKernel m) (D₀ : MvPolynomial (Fin m) ℝ) (M : ℝ≥0) + (hdegree : D₀.totalDegree ≤ d) (hD : realPolynomialMass D₀ ≤ M) + (q : (weightedFiltration w d hwd).realification.PolynomialOrbit ω) {p : ℝ} + (hgeometry : (weightedTranslationNilmanifold w d hw hwd).GeometryComplexityLE p) + (hbound : Real.log (3 + (2 * bufferedTranslationTermLip w d Ψ M : ℝ≥0)) ≤ p) : + (weightedTranslationBufferedNiltest w d hw hwd ω hd Ψ D₀ M hdegree hD q).ComplexityLE p := by + refine ⟨hgeometry, ?_⟩ + simpa only [weightedTranslationBufferedNiltest, NNReal.coe_one, + show (2 : ℝ) + 1 = 3 by norm_num] using hbound + +end Erdos3.PolynomialTranslationLie + +end + +section + +namespace Erdos3.OrdinaryPolynomialPhase + +open MvPolynomial PolynomialTranslationLie +open scoped TensorProduct NNReal + +def weight : Fin 0 → ℕ := fun _ => 1 + +theorem weight_pos : ∀ i, 0 < weight i := fun i => Fin.elim0 i + +theorem weight_le (s : ℕ) : ∀ i, weight i ≤ s := fun i => Fin.elim0 i + +noncomputable local instance phaseBasisFintype (s : ℕ) : + Fintype (WeightedBasisIndex weight s) := by + let := weightedBasisIndex_finite weight s weight_pos + exact Fintype.ofFinite _ + +noncomputable abbrev nilmanifold (s : ℕ) := + weightedTranslationNilmanifold weight s weight_pos (weight_le s) + +noncomputable def budget (s : ℕ) : ℝ := + max ((0 + (0 + 1)^s + s.factorial + 2*s + 1 : ℕ) : ℝ) + (Real.log (3 + (2 * bufferedTranslationTermLip weight s + (localTentKernel 0 8 (by decide)) 0 : ℝ≥0))) + +theorem two_le_budget (s : ℕ) : 2 ≤ budget s := by + apply le_trans _ (le_max_left _ _) + have hf := Nat.factorial_pos s + have hn : 2 ≤ 0 + (0 + 1)^s + s.factorial + 2*s + 1 := by + simp only [zero_add, one_pow] + omega + exact_mod_cast hn + +theorem nilmanifold_geometry (s : ℕ) : (nilmanifold s).GeometryComplexityLE (budget s) := by + apply RationalFilteredNilmanifold.GeometryComplexityLE.mono _ + (weightedTranslationNilmanifold_complexity_budget weight s weight_pos (weight_le s)) + simpa only [Fintype.card_fin, budget] using le_max_left + (((0 + (0 + 1)^s + s.factorial + 2*s + 1 : ℕ) : ℝ)) + (Real.log (3 + (2 * bufferedTranslationTermLip weight s + (localTentKernel 0 8 (by decide)) 0 : ℝ≥0))) + +theorem specialize_rename {U : Type*} (P : MvPolynomial U ℝ) (u : U → ℝ) : + specializeMajorParameters (RingHom.id ℝ) (rename (Sum.inl : U → U ⊕ Fin 0) P) u = + C (eval u P) := by + simp only [specializeMajorParameters, RingHom.comp_id, eval₂Hom_rename] + change eval₂ C (fun i => C (u i)) P = C (eval u P) + exact (eval₂_comp C u P).symm + +theorem exists_phase_orbit {U : Type*} (s : ℕ) (hs : 0 < s) + (P : MvPolynomial U ℝ) (hP : P.totalDegree ≤ s) : + ∃ q : (nilmanifold s).filtration.realification.PolynomialOrbit (fun _ : U => 1), + ∀ u : U → ℝ, + bchRealTranslationHom weight s (weight_le s) + ((nilmanifold s).filtration.realification.polynomialOrbitRealEval + (fun _ : U => 1) u q) = ⟨0, C (eval u P)⟩ := by + have hslot : ∀ u : U → ℝ, + specializeMajorParameters (RingHom.id ℝ) (rename (Sum.inl : U → U ⊕ Fin 0) P) u ∈ + weightedSupportLT weight s := by + intro u α _ + have hα : α = 0 := Subsingleton.elim _ _ + change Finsupp.weight weight α < s + simpa only [hα, map_zero] using hs + obtain ⟨q, hq⟩ := exists_translation_coordinate_polynomialOrbit weight s weight_pos + (weight_le s) (fun _ : Fin 0 => (0 : MvPolynomial U ℝ)) (fun i => Fin.elim0 i) + (rename Sum.inl P) + (majorParameterRename_degree (fun _ : U => 1) weight + ((mem_weightedSupportLE_one_iff P s).mpr hP)) hslot + refine ⟨q, fun u => ?_⟩ + change bchRealTranslationHom weight s (weight_le s) + ((weightedFiltration weight s (weight_le s)).realification.polynomialOrbitRealEval + (fun _ : U => 1) u q) = _ + rw [hq u, specialize_rename] + rfl + +variable {s : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra weight s)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra weight s)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra weight s)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra weight s)] + +theorem exists_niltest {U : Type*} (hs : 0 < s) + (P : MvPolynomial U ℝ) (hP : P.totalDegree ≤ s) : + ∃ T : (nilmanifold s).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (budget s) ∧ + ∀ u : U → ℝ, T.evalReal u = (Real.fourierChar (eval u P) : ℂ) := by + obtain ⟨q, hq⟩ := exists_phase_orbit s hs P hP + let Ψ := localTentKernel 0 8 (by decide) + let T := weightedTranslationBufferedNiltest weight s weight_pos (weight_le s) + (fun _ : U => 1) hs Ψ 0 0 (by simp) (by simp [realPolynomialMass]) q + refine ⟨T, rfl, ?_, ?_⟩ + · apply weightedTranslationBufferedNiltest_complexity + · exact nilmanifold_geometry s + · exact le_max_right _ _ + · intro u + change bufferedTranslationPhase Ψ 0 (bchRealTranslationHom weight s (weight_le s) + ((nilmanifold s).filtration.realification.polynomialOrbitRealEval + (fun _ : U => 1) u q)) = _ + rw [hq u] + rw [bufferedTranslationPhase_eq_chart Ψ 0 _ 0 (fun i => Fin.elim0 i)] + have hd : ∀ x y : Fin 0 → ℝ, dist x y = 0 := by + intro x y + rw [Subsingleton.elim x y, dist_self] + simp [bufferedTranslationTerm, translationPhaseArgument, Ψ, localTentKernel, hd] + +theorem exists_niltest_of_degree {U : Type*} + (P : MvPolynomial U ℝ) (hP : P.totalDegree ≤ s) : + ∃ T : (nilmanifold s).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (budget s) ∧ + ∀ u : U → ℝ, T.evalReal u = (Real.fourierChar (eval u P) : ℂ) := by + by_cases hs : 0 < s + · exact exists_niltest hs P hP + · have hs : s = 0 := by omega + subst s + let T := RationalFilteredNilmanifold.Niltest.const (nilmanifold 0) + (fun _ : U => 1) (Real.fourierChar (P.coeff 0) : ℂ) + have hn : T.normBound = 1 := by + apply NNReal.eq + exact Circle.norm_coe _ + refine ⟨T, hn, ⟨nilmanifold_geometry 0, ?_⟩, ?_⟩ + · rw [hn] + change Real.log (2 + (1 : ℝ) + 0) ≤ budget 0 + have hl := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3) + norm_num at hl ⊢ + exact hl.trans (two_le_budget 0) + · intro u + have heq : P = C (P.coeff 0) := + totalDegree_eq_zero_iff_eq_C.mp (Nat.eq_zero_of_le_zero hP) + change (Real.fourierChar (P.coeff 0) : ℂ) = (Real.fourierChar (eval u P) : ℂ) + conv_rhs => rw [heq, eval_C] + +end Erdos3.OrdinaryPolynomialPhase + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators TensorProduct + +variable {U : Type*} [Fintype U] [DecidableEq U] {n : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + +theorem exists_localMajor_slice_niltest + (N : U → ℕ) (q : ℕ) (hq : 0 < q) + (P E R : MvPolynomial U ℝ) (hP : P.totalDegree ≤ n + 1) + (hE : E.totalDegree ≤ n + 1) + (htop : homogeneousComponent (n + 1) P = E + R) + (hR : realPolynomialCoefficientGrid q R) + (M δ : ℝ) (hM : 0 ≤ M) (hδ : 0 < δ) + (hcoeff : ∀ α, |E.coeff α| ≤ M / monomialScale (fun i => (N i : ℝ)) α) + (f : (∀ i, Fin (N i)) → ℝ) : + let K := ((n + 1 : ℕ) + 1 : ℝ) * ((Fintype.card U : ℝ) + 1) ^ (n + 1) * + M * Fintype.card U * (n + 1) + let ρ := min 1 (δ / (K + 1)) + (∀ i, 4 * (q : ℝ) ≤ ρ * N i) → + ∃ A : ResidueBoxSlice N q, + (∀ i, 0 < A.length i ∧ ρ * N i ≤ 4 * q * A.length i) ∧ + (𝔼 x, f x) ≤ (𝔼 j : (∀ i, Fin (A.length i)), f (A.point j)) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + 1 - 2 * Real.pi * δ ≤ ‖𝔼 j : (∀ i, Fin (A.length i)), + (Real.fourierChar (eval (fun i => ((A.point j i).val : ℝ)) P) : ℂ) * + star (T.eval (fun i => ((j i).val : ℤ)))‖ := by + intro K ρ hlarge + have hK : 0 ≤ K := by dsimp [K]; positivity + have hρ : 0 < ρ := lt_min (by norm_num) (div_pos hδ (by linarith)) + have hKρ : K * ρ ≤ δ := by + have hle := (le_div_iff₀ (by linarith : 0 < K + 1)).mp + (min_le_right (1 : ℝ) (δ / (K + 1))) + change ρ * (K + 1) ≤ δ at hle + nlinarith + obtain ⟨A, hA, hscore, hslow⟩ := exists_slowPolynomial_residueSlice N hq hρ + (min_le_left _ _) hM hlarge E hE hcoeff f + let r : U → ℤ := fun i => (A.start i : ℤ) + let v : (∀ i, Fin (A.length i)) → U → ℤ := fun j i => ((j i).val : ℤ) + let Q := localMajorLowerPhase n q r P + obtain ⟨T, hnorm, hbudget, hT⟩ := OrdinaryPolynomialPhase.exists_niltest_of_degree + Q (localMajorLowerPhase_totalDegree_le n q r P hP) + refine ⟨A, hA, hscore, T, hnorm, hbudget, ?_⟩ + let : ∀ i, Nonempty (Fin (A.length i)) := fun i => ⟨⟨0, (hA i).1⟩⟩ + have hpoint (j : ∀ i, Fin (A.length i)) : + (fun i => ((r i + (q : ℤ) * v j i : ℤ) : ℝ)) = + (fun i => ((A.point j i).val : ℝ)) := by + funext i + simp only [r, v, ResidueBoxSlice.point, Int.cast_add, Int.cast_mul, + Int.cast_natCast, Nat.cast_add, Nat.cast_mul] + have hlocal := (localMajorPhaseCorrelation + (FiniteProbabilityWeights.uniform (∀ i, Fin (A.length i))) v n q hq r P E R hP htop hR + (eval (fun i => (A.start i : ℝ)) E) δ (by + intro j _ + rw [hpoint j] + exact (hslow j).trans (by simpa only [K, Nat.cast_add, Nat.cast_one] using hKρ))).2 + rw [FiniteProbabilityWeights.uniform_complexMean] at hlocal + have heval (j : ∀ i, Fin (A.length i)) : T.eval (v j) = + (Real.fourierChar (eval (fun i => (v j i : ℝ)) Q) : ℂ) := by + rw [← T.evalReal_integer, hT] + simpa only [hpoint, heval, Q, v] using hlocal + +end Erdos3 + +end + +section + +namespace Erdos3 + +open MvPolynomial +open scoped BigOperators TensorProduct + +variable {U : Type*} [Fintype U] [DecidableEq U] {n : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + [T2Space (ℝ ⊗[ℚ] PolynomialTranslationLie.weightedSubalgebra + OrdinaryPolynomialPhase.weight n)] + +theorem exists_localMajor_dense_slice_niltest + (N : U → ℕ) (q : ℕ) (hq : 0 < q) + (P E R : MvPolynomial U ℝ) (hP : P.totalDegree ≤ n + 1) + (hE : E.totalDegree ≤ n + 1) + (htop : homogeneousComponent (n + 1) P = E + R) + (hR : realPolynomialCoefficientGrid q R) + (M δ : ℝ) (hM : 0 ≤ M) (hδ : 0 < δ) + (hcoeff : ∀ α, |E.coeff α| ≤ M / monomialScale (fun i => (N i : ℝ)) α) + (f : (U → ℤ) → ℝ) : + let K := ((n + 1 : ℕ) + 1 : ℝ) * ((Fintype.card U : ℝ) + 1) ^ (n + 1) * + M * Fintype.card U * (n + 1) + let ρ := min 1 (δ / (K + 1)) + (∀ i, 4 * (q : ℝ) ≤ ρ * N i) → + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N (Real.log (4 * (q : ℝ) / ρ)) A.integerPoints ∧ + (𝔼 x : (∀ i, Fin (N i)), f (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ A.integerPoints, f x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + 1 - 2 * Real.pi * δ ≤ ‖𝔼 x ∈ A.integerPoints, + (Real.fourierChar (eval (fun i => (x i : ℝ)) P) : ℂ) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))‖ := by + intro K ρ hlarge + obtain ⟨A, hA, hscore, T, hnorm, hbudget, hcorr⟩ := exists_localMajor_slice_niltest + N q hq P E R hP hE htop hR M δ hM hδ hcoeff + (fun x => f (fun i => ((x i).val : ℤ))) hlarge + have hK : 0 ≤ K := by dsimp [K]; positivity + have hρ : 0 < ρ := lt_min (by norm_num) (div_pos hδ (by linarith)) + refine ⟨A, A.isDenseCommonStrideBox hq hρ (fun i => (hA i).1) + (fun i => (hA i).2), ?_, T, hnorm, hbudget, ?_⟩ + · rw [A.expect_integerPoints hq] + exact hscore + · rw [A.expect_integerPoints hq] + simp only [A.commonStrideIndex_integerPoint hq, ResidueBoxSlice.integerPoint, + Int.cast_natCast] + exact hcorr + +theorem major_phase_nine_tenths : + 1 - 2 * Real.pi * (1 / (20 * Real.pi)) = (9 / 10 : ℝ) := by + field_simp + ring + +theorem exists_localMajor_dense_slice_niltest_nine_tenths + (N : U → ℕ) (q : ℕ) (hq : 0 < q) + (P E R : MvPolynomial U ℝ) (hP : P.totalDegree ≤ n + 1) + (hE : E.totalDegree ≤ n + 1) + (htop : homogeneousComponent (n + 1) P = E + R) + (hR : realPolynomialCoefficientGrid q R) + (M : ℝ) (hM : 0 ≤ M) + (hcoeff : ∀ α, |E.coeff α| ≤ M / monomialScale (fun i => (N i : ℝ)) α) + (f : (U → ℤ) → ℝ) : + let K := ((n + 1 : ℕ) + 1 : ℝ) * ((Fintype.card U : ℝ) + 1) ^ (n + 1) * + M * Fintype.card U * (n + 1) + let ρ := min 1 ((1 / (20 * Real.pi)) / (K + 1)) + (∀ i, 4 * (q : ℝ) ≤ ρ * N i) → + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N (Real.log (4 * (q : ℝ) / ρ)) A.integerPoints ∧ + (𝔼 x : (∀ i, Fin (N i)), f (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ A.integerPoints, f x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ A.integerPoints, + (Real.fourierChar (eval (fun i => (x i : ℝ)) P) : ℂ) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))‖ := by + simpa only [major_phase_nine_tenths] using exists_localMajor_dense_slice_niltest + N q hq P E R hP hE htop hR M (1 / (20 * Real.pi)) hM (by positivity) hcoeff f + +theorem exists_localMajor_dense_slice_niltest_early + (N : U → ℕ) (q : ℕ) (hq : 0 < q) + (P E R : MvPolynomial U ℝ) (hP : P.totalDegree ≤ n + 1) + (hE : E.totalDegree ≤ n + 1) + (htop : homogeneousComponent (n + 1) P = E + R) + (hR : realPolynomialCoefficientGrid q R) + (M p : ℝ) (hM : 0 ≤ M) (hp : 1 ≤ p) + (hdim : (Fintype.card U : ℝ) ≤ p) (hMexp : M ≤ Real.exp p) + (hqexp : (q : ℝ) ≤ Real.exp p) + (hcoeff : ∀ α, |E.coeff α| ≤ M / monomialScale (fun i => (N i : ℝ)) α) + (f : (U → ℤ) → ℝ) + (hN : ∀ i, Real.exp ((p + (n + 401 : ℕ)) ^ (n + 401)) ≤ (N i : ℝ)) : + ∃ A : ResidueBoxSlice N q, + IsDenseCommonStrideBox N ((p + (n + 401 : ℕ)) ^ (n + 401)) A.integerPoints ∧ + (𝔼 x : (∀ i, Fin (N i)), f (fun i => ((x i).val : ℤ))) ≤ + (𝔼 x ∈ A.integerPoints, f x) ∧ + ∃ T : (OrdinaryPolynomialPhase.nilmanifold n).Niltest (fun _ : U => 1), + T.normBound = 1 ∧ T.ComplexityLE (OrdinaryPolynomialPhase.budget n) ∧ + (9 / 10 : ℝ) ≤ ‖𝔼 x ∈ A.integerPoints, + (Real.fourierChar (eval (fun i => (x i : ℝ)) P) : ℂ) * + star (T.eval (commonStrideIndex (fun i => (A.start i : ℤ)) q x))‖ := by + let ρ := slowPolynomialSliceRadius (n + 1) (Fintype.card U) M + have hρ : 0 < ρ := slowPolynomialSliceRadius_pos _ _ hM + have hcost : Real.log (4 * (q : ℝ) / ρ) ≤ (p + (n + 401 : ℕ)) ^ (n + 401) := by + simpa only [Nat.add_assoc, Nat.reduceAdd] using slowPolynomialSlice_log_cost + (n + 1) (Fintype.card U) hp hdim hM hMexp (by exact_mod_cast hq) hqexp + have hlarge : ∀ i, 4 * (q : ℝ) ≤ ρ * N i := by + intro i + have hratio : 4 * (q : ℝ) / ρ ≤ Real.exp ((p + (n + 401 : ℕ)) ^ (n + 401)) := + (Real.log_le_iff_le_exp (by positivity)).mp hcost + simpa only [mul_comm] using (div_le_iff₀ hρ).mp (hratio.trans (hN i)) + obtain ⟨A, hA, hscore, hT⟩ := exists_localMajor_dense_slice_niltest_nine_tenths + N q hq P E R hP hE htop hR M hM hcoeff f (by + simpa only [ρ, slowPolynomialSliceRadius, slowPolynomialSliceSlope, + Nat.cast_add, Nat.cast_one] using hlarge) + have hA' : IsDenseCommonStrideBox N (Real.log (4 * (q : ℝ) / ρ)) A.integerPoints := by + simpa only [ρ, slowPolynomialSliceRadius, slowPolynomialSliceSlope, + Nat.cast_add, Nat.cast_one] using hA + exact ⟨A, hA'.mono hcost, hscore, hT⟩ + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/LocalNiltestFixedNativePartners.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/LocalNiltestFixedNativePartners.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f36c2e41558806c06050fee7766b079e732216f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/LocalNiltestFixedNativePartners.lean @@ -0,0 +1,256 @@ +import OAI.Combinatorics.Progressions.Estimates.PinnedSectionMeans +import OAI.Combinatorics.Progressions.Estimates.SampledSliceFixedModelPartners + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {L σ τ : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} {v : τ → ℕ} + +noncomputable def withOrbit (T : D.Niltest w) + (g : D.filtration.realification.PolynomialOrbit v) : D.Niltest v where + orbit := g + observable := T.observable + normBound := T.normBound + lipBound := T.lipBound + norm_le := T.norm_le + lipschitz := T.lipschitz + +theorem withOrbit_complexity (T : D.Niltest w) + (g : D.filtration.realification.PolynomialOrbit v) (p : ℝ) : + (T.withOrbit g).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +theorem withOrbit_eval (T : D.Niltest w) + (g : D.filtration.realification.PolynomialOrbit v) (x : τ → ℤ) : + (T.withOrbit g).eval x = T.observable + (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval v x g)) := rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.NilpotentLieFiltration + +open VectorPolynomial + +variable {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (w : σ → ℕ) + +noncomputable def constantGroupOrbit (g : F.Group) : F.PolynomialOrbit w := + polynomialOrbitOfLog (monomial (R := ℚ) 0 g.coord) + ((F.mem_adaptedSubmodule w _).mp + (F.monomial_mem_adaptedSubmodule w 0 (by + simp only [map_zero] + exact F.antitone (Nat.zero_le 1) (by simp [F.one_eq_top])))) + +@[simp] theorem polynomialOrbitEval_constantGroupOrbit (g : F.Group) (x : σ → ℤ) : + F.polynomialOrbitEval w x (F.constantGroupOrbit w g) = g := by + apply NilpotentLieBCHGroup.ext + simp [polynomialOrbitEval_coord, constantGroupOrbit, eval_monomial] + +end Erdos3.NilpotentLieFiltration + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {L σ τ : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} {v : τ → ℕ} + +noncomputable def withLeftTranslatedOrbit (T : D.Niltest w) (g : D.RealGroup) + (orbit : D.filtration.realification.PolynomialOrbit v) : D.Niltest v := + T.withOrbit (D.filtration.realification.constantGroupOrbit v g * orbit) + +@[simp] theorem withLeftTranslatedOrbit_observable (T : D.Niltest w) (g : D.RealGroup) + (orbit : D.filtration.realification.PolynomialOrbit v) : + (T.withLeftTranslatedOrbit g orbit).observable = T.observable := rfl + +@[simp] theorem withLeftTranslatedOrbit_complexity (T : D.Niltest w) (g : D.RealGroup) + (orbit : D.filtration.realification.PolynomialOrbit v) (p : ℝ) : + (T.withLeftTranslatedOrbit g orbit).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +@[simp] theorem withLeftTranslatedOrbit_eval (T : D.Niltest w) (g : D.RealGroup) + (orbit : D.filtration.realification.PolynomialOrbit v) (x : τ → ℤ) : + (T.withLeftTranslatedOrbit g orbit).eval x = T.observable + (g • QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval v x orbit)) := by + rw [withLeftTranslatedOrbit, withOrbit_eval, map_mul, + NilpotentLieFiltration.polynomialOrbitEval_constantGroupOrbit] + rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {L X Y Ω T : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L 0 d} {w : Y → ℕ} + +theorem exists_step_zero_ambient_realization (reference : D.Niltest w) + (localTests : Ω → D.Niltest w) + (hcommon : ∀ a, (localTests a).observable = reference.observable) + {p : ℝ} (hcomplexity : reference.ComplexityLE p) + (hunit : reference.UnitIntervalValued) : + ∃ ambient : D.Niltest (fun _ : X => 1), + ambient.observable = reference.observable ∧ ambient.UnitIntervalValued ∧ + ambient.ComplexityLE p ∧ + ∀ a x y, ambient.eval x = (localTests a).eval y := by + refine ⟨reference.withOrbit 1, rfl, hunit, hcomplexity, ?_⟩ + intro a x y + rw [eval_step_zero, eval_step_zero, hcommon] + rfl + +theorem exists_step_zero_ambient_realization_preserving_scores + [Fintype Ω] [Fintype T] + (reference : D.Niltest w) (localTests : Ω → D.Niltest w) + (hcommon : ∀ a, (localTests a).observable = reference.observable) + {p : ℝ} (hcomplexity : reference.ComplexityLE p) + (hunit : reference.UnitIntervalValued) + (outer : FiniteProbabilityWeights Ω) (productive retained : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights T) + (localPoint : Ω → T → Y → ℤ) (physical : Ω → T → X → ℤ) + (score : Ω → T → ℝ) (massThreshold correlationThreshold : ℝ) + (hretained : retained ⊆ productive) (hmass : massThreshold ≤ outer.mass retained) + (hscore : ∀ a ∈ retained, correlationThreshold ≤ + (localLaw a).mean (fun t => score a t * ((localTests a).eval (localPoint a t)).re)) : + ∃ ambient : D.Niltest (fun _ : X => 1), + ambient.observable = reference.observable ∧ ambient.UnitIntervalValued ∧ + ambient.ComplexityLE p ∧ retained ⊆ productive ∧ + massThreshold ≤ outer.mass retained ∧ + ∀ a ∈ retained, correlationThreshold ≤ + (localLaw a).mean (fun t => score a t * (ambient.eval (physical a t)).re) := by + obtain ⟨ambient, hobservable, hunit', hcomplexity', heval⟩ := + exists_step_zero_ambient_realization (X := X) + reference localTests hcommon hcomplexity hunit + refine ⟨ambient, hobservable, hunit', hcomplexity', hretained, hmass, ?_⟩ + intro a ha + have hvalues : (fun t => score a t * (ambient.eval (physical a t)).re) = + (fun t => score a t * ((localTests a).eval (localPoint a t)).re) := by + funext t + rw [heval a (physical a t) (localPoint a t)] + rw [hvalues] + exact hscore a ha + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct Classical + +variable {L Y Ω T X K : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : Y → ℕ} + +noncomputable def localNiltestPartnerWeight + (tests : Ω → K → D.Niltest w) (point : Ω → T → Y → ℤ) (p : ℝ) : + Ω → K → T → ℂ := + fun a k t => (Real.exp (-p) : ℂ) * (tests a k).eval (point a t) + +theorem localNiltestPartnerWeight_norm_le + (tests : Ω → K → D.Niltest w) (point : Ω → T → Y → ℤ) (p : ℝ) + (hcomplexity : ∀ a k, (tests a k).ComplexityLE p) (a : Ω) (k : K) (t : T) : + ‖localNiltestPartnerWeight tests point p a k t‖ ≤ 1 := by + rw [localNiltestPartnerWeight, norm_mul, Complex.norm_real, + Real.norm_of_nonneg (Real.exp_nonneg _)] + calc + _ ≤ Real.exp (-p) * Real.exp p := mul_le_mul_of_nonneg_left + ((tests a k).eval_budget (hcomplexity a k) _) (Real.exp_nonneg _) + _ = 1 := by rw [← Real.exp_add]; simp + +theorem localNiltestPartnerWeight_mean_norm [Fintype T] + (tests : Ω → K → D.Niltest w) (point : Ω → T → Y → ℤ) (p : ℝ) + (a : Ω) (k : K) (S : Finset T) (v : T → ℂ) : + ‖𝔼 t ∈ S, v t * localNiltestPartnerWeight tests point p a k t‖ = + Real.exp (-p) * ‖𝔼 t ∈ S, v t * (tests a k).eval (point a t)‖ := by + have heq : (fun t => v t * localNiltestPartnerWeight tests point p a k t) = + (fun t => (Real.exp (-p) : ℂ) * (v t * (tests a k).eval (point a t))) := by + funext t + dsimp only [localNiltestPartnerWeight] + ring + rw [heq, ← Finset.mul_expect, norm_mul, Complex.norm_real, + Real.norm_of_nonneg (Real.exp_nonneg _)] + +theorem exists_local_niltest_fixed_native_partners + {I σ Θ : Type*} [Fintype Ω] [Fintype T] [Nonempty T] + [Fintype K] [Fintype I] [Nonempty I] + (outer : FiniteProbabilityWeights Ω) (productive : Finset Ω) + (physical : Ω → T → X) (slices : Ω → K → Finset T) + (tests : Ω → K → D.Niltest w) (point : Ω → T → Y → ℤ) + (p : ℝ) (hcomplexity : ∀ a k, (tests a k).ComplexityLE p) + (hS : ∀ a k, (slices a k).Nonempty) {cap : ℝ} + (hsize : ∀ a k, (Fintype.card T : ℝ) / (slices a k).card ≤ cap) + (v e : X → ℂ) (Q : I → X → ℂ) (c : I → ℂ) + (hmodel : v = (∑ i, c i • Q i) + e) + {M kappa : ℝ} (hM : 0 < M) (hkappa : 0 < kappa) + (hc : (∑ i, ‖c i‖) ≤ M) (hmass : kappa ≤ outer.mass productive) + (herror : (Fintype.card K : ℝ) * + sampledSliceSeminorm outer physical slices + (localNiltestPartnerWeight tests point p) e ≤ kappa * Real.exp (-2 * p) / 8) + (nativeWeight : σ → ℕ) (degree : ℕ) (budget : ℝ) + (sample : X → σ → ℤ) (twist : Θ → X → ℂ) + (hQ : ∀ i, Q i ∈ twistedNativeSampleFunctions nativeWeight degree budget sample twist) + (hscore : ∀ a ∈ productive, ∀ k, Real.exp (-p) ≤ + ‖𝔼 t ∈ slices a k, v (physical a t) * (tests a k).eval (point a t)‖) : + ∃ (fixedTwist : K → Θ) (nativeValue : K → X → ℂ) + (_native : ∀ k, NativeSampleModel nativeWeight degree budget sample (nativeValue k)) + (retained : Finset Ω), + retained ⊆ productive ∧ 0 < outer.mass retained ∧ + (3 * kappa / 4) / (Fintype.card I : ℝ) ^ Fintype.card K ≤ outer.mass retained ∧ + ∀ a ∈ retained, ∀ k, Real.exp (-p) / (2 * M) ≤ + ‖𝔼 t ∈ slices a k, + (star (twist (fixedTwist k) (physical a t)) * nativeValue k (physical a t)) * + (tests a k).eval (point a t)‖ := by + have herr : (∑ _k : K, sampledSliceSeminorm outer physical slices + (localNiltestPartnerWeight tests point p) e) ≤ kappa * Real.exp (-2 * p) / 8 := by + simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] using herror + have hscale : Real.exp (-p) * Real.exp (-p) = Real.exp (-2 * p) := by + rw [← Real.exp_add] + congr 1 + ring + obtain ⟨fixedTwist, nativeValue, native, retained, hsub, hpos, hretained, hlocal⟩ := + exists_fixed_sampled_slice_native_partners outer productive physical slices + (localNiltestPartnerWeight tests point p) (fun _ k => k) hS hsize + (localNiltestPartnerWeight_norm_le tests point p hcomplexity) + (fun _ : K => v) (fun _ : K => e) (fun _ : K => Q) (fun _ : K => c) + (fun _ => hmodel) (Real.exp_pos _) hM (fun _ => hc) hmass herr hkappa + nativeWeight degree budget sample twist (fun _ => hQ) (by + intro a ha k + rw [localNiltestPartnerWeight_mean_norm, ← hscale] + exact mul_le_mul_of_nonneg_left (hscore a ha k) (Real.exp_nonneg _)) + refine ⟨fixedTwist, nativeValue, native, retained, hsub, hpos, ?_, ?_⟩ + · simpa only [Finset.prod_const, Finset.card_univ] using hretained + · intro a ha k + have h := hlocal a ha k + rw [localNiltestPartnerWeight_mean_norm, ← hscale] at h + have heq : Real.exp (-p) * Real.exp (-p) / (2 * M) = + Real.exp (-p) * (Real.exp (-p) / (2 * M)) := by ring + rw [heq] at h + exact le_of_mul_le_mul_left h (Real.exp_pos (-p)) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/MajorTranslationPartnerNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/MajorTranslationPartnerNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa5ad02fd1bec6f019f742baea13868484a13c7c --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/MajorTranslationPartnerNiltest.lean @@ -0,0 +1,100 @@ +import OAI.Combinatorics.Progressions.Dynamics.MajorTranslationPartnerBudget +import OAI.Combinatorics.Progressions.Estimates.TranslationMajorTwistedCorrelationStepDrop + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module RationalFilteredNilmanifold +open scoped NNReal TensorProduct + +noncomputable abbrev majorTranslationPartnerModel {L : Type} + [LieRing L] [LieAlgebra ℚ L] {m t e : ℕ} + (w : Fin m → ℕ) (d : ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + (D : RationalFilteredNilmanifold L t e) (htd : t ≤ d) := + pi (pairModels (weightedTranslationNilmanifold w d hw hwd) (D.raiseStep htd)) + +theorem exists_majorTranslation_partner_niltest (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {U L : Type} [Fintype U] [LieRing L] [LieAlgebra ℚ L] + {m t e : ℕ} (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L t e) (htd : t ≤ d) + (R : D.Niltest (fun _ : U => 1)) (_hd : 0 < d) + (Ψ : PatchKernel m) (F : MvPolynomial (U ⊕ Fin m) ℝ) + (_hF : F ∈ weightedSupportLE (Sum.elim (fun _ : U => 1) w) d) + (A : Fin m → MvPolynomial U ℝ) (_hA : ∀ i, (A i).totalDegree ≤ w i) + (p : ℝ), 0 ≤ p → (Fintype.card U + m : ℕ) ≤ p → + (Ψ.lip : ℝ) ≤ Real.exp p → R.ComplexityLE p → (R.normBound : ℝ) ≤ 1 → + let N := majorTranslationPartnerModel w d hw hwd D htd + letI : FiniteDimensional ℚ (PairAlgebra (weightedSubalgebra w d) L) := + N.basis.finiteDimensional_of_finite + letI := moduleTopology ℝ (ℝ ⊗[ℚ] PairAlgebra (weightedSubalgebra w d) L) + letI : IsTopologicalAddGroup (ℝ ⊗[ℚ] PairAlgebra (weightedSubalgebra w d) L) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + letI : T2Space (ℝ ⊗[ℚ] PairAlgebra (weightedSubalgebra w d) L) := + realification_moduleTopology_t2 N.basis + ∃ S : N.Niltest (fun _ : U => 1), S.normBound = 1 ∧ S.ComplexityLE ((p + C) ^ C) ∧ + ∀ u : U → ℤ, ∀ β : Fin m → ℤ, + (∀ i, |eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)| ≤ 1 / 2) → + S.eval u = + ((Ψ.value (fun i => eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (fun j => ((Sum.elim u β j : ℤ) : ℝ)) F) : ℂ)) * + R.eval u := by + obtain ⟨a, ha, hmajor⟩ := exists_majorTranslation_degree_reduced_niltest d + obtain ⟨C, hC, hbudget⟩ := exists_majorTranslationPartnerBudget_bound a + refine ⟨C, hC, ?_⟩ + intro U L _ _ _ m t e w hw hwd _ _ _ _ _ _ _ _ _ D htd R hd Ψ F hF A hA p + hp hdim hΨ hR hcap + let N := majorTranslationPartnerModel w d hw hwd D htd + let : FiniteDimensional ℚ (PairAlgebra (weightedSubalgebra w d) L) := + N.basis.finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] PairAlgebra (weightedSubalgebra w d) L) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] PairAlgebra (weightedSubalgebra w d) L) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] PairAlgebra (weightedSubalgebra w d) L) := + realification_moduleTopology_t2 N.basis + obtain ⟨V, hVnorm, hV, _, hVeval⟩ := hmajor w hw hwd hd Ψ F hF A hA hp hdim hΨ + let q : ℝ := (p + a) ^ a + raisedNiltestBudget p + 2 + have hraise : 0 ≤ raisedNiltestBudget p := hp.trans (le_raisedNiltestBudget p) + have hpow : 0 ≤ (p + a) ^ a := by positivity + have hq : 2 ≤ q := by dsimp [q]; linarith + have hVq : V.ComplexityLE q := hV.mono (by dsimp [q]; linarith) + have hRq : (R.raiseStep htd).ComplexityLE q := + (R.raiseStep_complexity htd hp hR).mono (by dsimp [q]; linarith) + let models := pairModels (weightedTranslationNilmanifold w d hw hwd) (D.raiseStep htd) + let tests := pairTests (weightedTranslationNilmanifold w d hw hwd) (D.raiseStep htd) + V (R.raiseStep htd) + have htests : ∀ i, (tests i).ComplexityLE q := + pairTests_complexity _ _ V (R.raiseStep htd) hVq hRq + have hcaps : ∀ i, (tests i).normBound ≤ 1 := by + intro i + cases i + · change R.normBound ≤ 1 + exact_mod_cast hcap + · change V.normBound ≤ 1 + exact hVnorm.le + have hcard : (Fintype.card Bool : ℝ) ≤ q := by simpa using hq + let S := unitBoundedPiNiltest models tests (by linarith : 0 ≤ q) hcard htests hcaps + refine ⟨S, rfl, ?_, ?_⟩ + · exact (unitBoundedPiNiltest_complexity models tests (by linarith : 0 ≤ q) + hcard htests hcaps).mono (hbudget p hp) + · intro u β hβ + change (unitBoundedPiNiltest models tests _ _ _ _).eval u = _ + rw [unitBoundedPiNiltest_eval, Fintype.prod_bool] + change V.eval u * (R.raiseStep htd).eval u = _ + rw [hVeval u β hβ, R.raiseStep_eval] + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/MajorTranslationRationalLiftNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/MajorTranslationRationalLiftNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb95799d6b3e601e69c5d0cbff85085190a72a12 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/MajorTranslationRationalLiftNiltest.lean @@ -0,0 +1,139 @@ +import OAI.Combinatorics.Progressions.Nilpotent.CanonicalReducedMajorTwistedNiltest + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial Module +open scoped NNReal TensorProduct BigOperators + +noncomputable def nearestLowCoordinateLift {U : Type*} {m : ℕ} + (L : Fin m → MvPolynomial U ℝ) (c : Fin m → ℝ) (u : U → ℤ) : Fin m → ℤ := + nearestIntegerLift (fun i => eval (fun j => (u j : ℝ)) (L i) - c i) + +theorem nearestLowCoordinateLift_close {U : Type*} {m : ℕ} + (L : Fin m → MvPolynomial U ℝ) (c : Fin m → ℝ) (u : U → ℤ) (i : Fin m) : + |eval (fun j => (u j : ℝ)) (L i) - c i - (nearestLowCoordinateLift L c u i : ℝ)| ≤ 1 / 2 := + nearestIntegerLift_close (fun j => eval (fun k => (u k : ℝ)) (L j) - c j) i + +theorem exists_majorTranslation_rationalLift_niltest (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {U : Type*} [Fintype U] {m : ℕ} + (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + (_hd : 0 < d) (M : ℕ) (hM : 0 < M) (Ψ : PatchKernel m) + (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) + (L : Fin m → MvPolynomial U ℝ) (hL : ∀ i, (L i).totalDegree ≤ w i) + (c : Fin m → ℝ) (a : Fin m → ℤ) + {p : ℝ} (_hp : 0 ≤ p) (_hdim : (Fintype.card U + m : ℕ) ≤ p) + (_hMp : (M : ℝ) ≤ Real.exp p) (_hΨ : (Ψ.lip : ℝ) ≤ Real.exp p) + (_ha : ∀ i, |(a i : ℝ)| ≤ Real.exp p), + ∃ F : (weightedTranslationResidueNilmanifold w d hw hwd M hM).Niltest (fun _ : U => 1), + F.normBound = 1 ∧ F.ComplexityLE ((p + C) ^ C) ∧ + F.orbit = majorTranslationPolynomialOrbit w d hw hwd + (fractionalCoefficientPolynomial D) + (fun _ hα => (fractionalCoefficientPolynomial_isWeightedHomogeneous D + (Sum.elim (fun _ : U => 1) w) d hD (mem_support_iff.mp hα)).le) + (fun i => L i - MvPolynomial.C (c i)) + (fun i => (MvPolynomial.totalDegree_sub_C_le (L i) (c i)).trans (hL i)) ∧ + ∀ u : U → ℤ, ∀ β : Fin m → ℤ, + (∀ i, |eval (fun j => (u j : ℝ)) (L i) - c i - (β i : ℝ)| ≤ 1 / 2) → + F.eval u = + (Ψ.value (fun i => eval (fun j => (u j : ℝ)) (L i) - c i - (β i : ℝ)) : ℂ) * + (Real.fourierChar (eval (fun j => ((Sum.elim u β j : ℤ) : ℝ)) D) : ℂ) * + (Real.fourierChar ((∑ i, (a i : ℝ) * eval (fun j => (u j : ℝ)) (L i)) / (M : ℝ)) : ℂ) := by + obtain ⟨b, _, htwisted⟩ := exists_majorTranslation_reduced_twisted_niltest d + let X : Polynomial ℕ := Polynomial.X + let Q := (2 * X + 8 + Polynomial.C b) ^ b + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget Q + refine ⟨C, hC, ?_⟩ + intro U _ m w hw hwd _ _ _ _ _ hd M hM Ψ D hD L hL c a p hp hdim hMp hΨ ha + let A : Fin m → MvPolynomial U ℝ := fun i => L i - MvPolynomial.C (c i) + have hA : ∀ i, (A i).totalDegree ≤ w i := + fun i => (MvPolynomial.totalDegree_sub_C_le (L i) (c i)).trans (hL i) + let q : ℝ := 2 * p + 8 + have hpq : p ≤ q := by dsimp [q]; linarith + have hq : 0 ≤ q := hp.trans hpq + have hm : (m : ℝ) ≤ p := by + have hh : (m : ℝ) ≤ (Fintype.card U + m : ℕ) := by + exact_mod_cast Nat.le_add_left m (Fintype.card U) + exact hh.trans hdim + have hK : (rationalLiftCharacterTwistLip M a : ℝ) ≤ Real.exp q := by + have hpi : 2 * Real.pi ≤ Real.exp (8 : ℝ) := by + linarith [Real.pi_lt_four, Real.add_one_le_exp (8 : ℝ)] + have hmexp : (m : ℝ) ≤ Real.exp p := hm.trans (by linarith [Real.add_one_le_exp p]) + calc + _ ≤ 2 * Real.pi * m * Real.exp p := rationalLiftCharacterTwistLip_le M hM a _ ha + _ ≤ Real.exp 8 * Real.exp p * Real.exp p := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg p) + exact mul_le_mul hpi hmexp (Nat.cast_nonneg m) (Real.exp_nonneg 8) + _ = Real.exp q := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + dsimp [q] + ring + obtain ⟨F, hnorm, hcomp, horbit, heval⟩ := htwisted w hw hwd hd M hM Ψ D hD A hA + (rationalLiftCharacterTwistLip M a) (rationalLiftCharacterTwist M a c) + (fun x r => (rationalLiftCharacterTwist_norm M a c x r).le) + (rationalLiftCharacterTwist_lipschitz M a c) hq (hdim.trans hpq) + (hMp.trans (Real.exp_le_exp.mpr hpq)) (hΨ.trans (Real.exp_le_exp.mpr hpq)) hK + have hcost : (q + b) ^ b ≤ (p + C) ^ C := by + simpa [Q, X, q, Polynomial.eval₂_pow] using hbudget p hp + refine ⟨F, hnorm, hcomp.mono hcost, horbit, ?_⟩ + intro u β hβ + have hβ' : ∀ i, |eval (fun j => (u j : ℝ)) (A i) - (β i : ℝ)| ≤ 1 / 2 := by + simpa only [A, map_sub, eval_C] using hβ + rw [heval u β hβ', rationalLiftCharacterTwist_residual M hM] + simp only [A, map_sub, eval_C, sub_add_cancel] + ring + +theorem exists_majorTranslation_rationalLift_niltest_nearest (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {U : Type*} [Fintype U] {m : ℕ} + (w : Fin m → ℕ) (hw : ∀ i, 0 < w i) (hwd : ∀ i, w i ≤ d) + [Fintype (WeightedBasisIndex w d)] + [TopologicalSpace (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] weightedSubalgebra w d)] + [T2Space (ℝ ⊗[ℚ] weightedSubalgebra w d)] + (_hd : 0 < d) (M : ℕ) (hM : 0 < M) (Ψ : PatchKernel m) + (D : MvPolynomial (U ⊕ Fin m) ℝ) + (hD : D.IsWeightedHomogeneous (Sum.elim (fun _ : U => 1) w) d) + (L : Fin m → MvPolynomial U ℝ) (hL : ∀ i, (L i).totalDegree ≤ w i) + (c : Fin m → ℝ) (a : Fin m → ℤ) + {p : ℝ} (_hp : 0 ≤ p) (_hdim : (Fintype.card U + m : ℕ) ≤ p) + (_hMp : (M : ℝ) ≤ Real.exp p) (_hΨ : (Ψ.lip : ℝ) ≤ Real.exp p) + (_ha : ∀ i, |(a i : ℝ)| ≤ Real.exp p), + ∃ F : (weightedTranslationResidueNilmanifold w d hw hwd M hM).Niltest (fun _ : U => 1), + F.normBound = 1 ∧ F.ComplexityLE ((p + C) ^ C) ∧ + F.orbit = majorTranslationPolynomialOrbit w d hw hwd + (fractionalCoefficientPolynomial D) + (fun _ hα => (fractionalCoefficientPolynomial_isWeightedHomogeneous D + (Sum.elim (fun _ : U => 1) w) d hD (mem_support_iff.mp hα)).le) + (fun i => L i - MvPolynomial.C (c i)) + (fun i => (MvPolynomial.totalDegree_sub_C_le (L i) (c i)).trans (hL i)) ∧ + ∀ u : U → ℤ, + F.eval u = + (Ψ.value (fun i => eval (fun j => (u j : ℝ)) (L i) - c i - + (nearestLowCoordinateLift L c u i : ℝ)) : ℂ) * + (Real.fourierChar (eval + (fun j => ((Sum.elim u (nearestLowCoordinateLift L c u) j : ℤ) : ℝ)) D) : ℂ) * + (Real.fourierChar ((∑ i, (a i : ℝ) * eval (fun j => (u j : ℝ)) (L i)) / (M : ℝ)) : ℂ) := by + obtain ⟨C, hC, hmain⟩ := exists_majorTranslation_rationalLift_niltest d + refine ⟨C, hC, ?_⟩ + intro U _ m w hw hwd _ _ _ _ _ hd M hM Ψ D hD L hL c a p hp hdim hMp hΨ ha + obtain ⟨F, hnorm, hcomp, horbit, heval⟩ := + hmain w hw hwd hd M hM Ψ D hD L hL c a hp hdim hMp hΨ ha + exact ⟨F, hnorm, hcomp, horbit, fun u => heval u (nearestLowCoordinateLift L c u) + (nearestLowCoordinateLift_close L c u)⟩ + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/MatchedFlatNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/MatchedFlatNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd763652b0c1abe5769abcc50f6a2476bef6c176 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/MatchedFlatNiltest.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.MatchedFlatDecay +import OAI.Combinatorics.Progressions.Fourier.BohrNiltestBudget + +namespace OAI + +section + +namespace Erdos3.CellRefinement + +open scoped BigOperators + +variable {N : ℕ} [NeZero N] + +theorem matched_flat_integral_of_niltest_comparison + (L : Finset (ZMod N)) (S : CyclicBohr.Set N) + (hS : S.IsRankRegular) (hS1 : S.radius ≤ 1) + (A B f g : ZMod N → ℝ) (z : ZMod N) + {u v : ℝ} (hu : 0 < u) (hv : 0 < v) (hu1 : u ≤ 1) (hv1 : v ≤ 1) + {epsilon p C D R P M : ℝ} (hepsilon : 0 < epsilon) (hp : 1 ≤ p) + (hC : 0 ≤ C) (hD : 0 ≤ D) (hR : 0 ≤ R) (hM : 0 ≤ M) + (hMcap : M ≤ Real.exp (C * p)) (hwidth : Real.exp (-R) ≤ S.radius) + {q : ℕ} (hq : 0 < q) + (horder : (1 + C + (D + 1) + Real.log 3) * p ≤ (q : ℝ) * Real.log 2) + (hA : ∀ x, 0 ≤ A x ∧ A x ≤ Real.exp p) + (hB : ∀ x, 0 ≤ B x ∧ B x ≤ Real.exp p) + (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, 0 ≤ g x) (hgcap : ∀ x, g x / v ≤ M) + (hfsupport : ∀ x, x ∉ L → f x = 0) (hfmean : (𝔼 x ∈ L, f x) = u) + (hflat : LocalConvolution.sumLp S.carrier + (fun x => LocalConvolution.convolution L (fun y => f y / u) (fun y => g y / v) x - 1) q ≤ + flatComparisonDelta epsilon) + (hcomplexity : 2 * (S.rank : ℝ) + p + (D + 2) * p + R + 1612 ≤ P) + (hprecision : (D + 2) * p + 2 + (S.rank : ℝ) * (R + 10) ≤ P) + (hcompare : CyclicNiltestUpperComparison.{0} 1 N P (Real.exp (-P)) A B) : + matchedIntegral L S.carrier (fun x => A (z + x) - (1 + epsilon) * B (z + x)) f g ≤ + Real.exp (-(D * p)) * (u * v) ^ (1 / 4 : ℝ) := by + have hp0 : 0 ≤ p := by linarith + have hE : 0 ≤ (D + 2) * p := by positivity + have hmean := S.small_sum_average_of_exponential_niltest_comparison hS hS1 A B + (Real.exp_nonneg p) hp0 hE hR le_rfl hwidth + (fun x => (hA x).1) (fun x => (hB x).2) hcomplexity hprecision hcompare z + obtain ⟨hdelta, hdelta4, hcoeff⟩ := flatComparisonDelta_spec hepsilon + have heta : Real.exp (-((D + 2) * p)) ≤ Real.exp (-(D * p)) / 4 := by + have hfirst := exp_extra_decay_le_half (D := D + 1) hp + have hsecond := exp_extra_decay_le_half (D := D) hp + have heq : D + 1 + 1 = D + 2 := by ring + rw [heq] at hfirst + linarith + apply matched_flat_integral_decay L S.carrier + (fun x => A (z + x)) (fun x => B (z + x)) f g hu hv hu1 hv1 hq + (Real.exp_nonneg p) hM hepsilon.le hdelta (hdelta4.trans (by norm_num)) hcoeff + hp hC (by simp only [one_mul, le_refl]) hMcap heta horder + (fun x => hA (z + x)) (fun x => hB (z + x)) hf hg hgcap hfsupport hfmean hflat + simpa only [add_assoc] using hmean + +end Erdos3.CellRefinement + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/MissingCoordinateNiltestApproximation.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/MissingCoordinateNiltestApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4b327edab9197b41fa38fc39b25101753c77063 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/MissingCoordinateNiltestApproximation.lean @@ -0,0 +1,144 @@ +import OAI.Combinatorics.Progressions.Estimates.TwoDownsetPrecision +import OAI.Combinatorics.Progressions.Geometry.MissingCoordinateDownsets +import OAI.Combinatorics.Progressions.Geometry.NativeCoordinateSplitFreezing +import OAI.Combinatorics.Progressions.Polynomial.NativeTotalDegreeMultifiltration + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open scoped TensorProduct + +theorem niltest_eval_eq_of_zero_coordinate {σ L : Type*} [Fintype σ] + [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) (i : σ) (hi : bound i = 0) + (T : D.Niltest (fun _ : σ => 1)) (g : M.filtration.realification.PolynomialOrbit) + (hT : T.orbit = M.orbitToOrdinary g) (x y : σ → ℤ) + (hxy : ∀ j, j ≠ i → x j = y j) : T.eval x = T.eval y := by + unfold RationalFilteredNilmanifold.Niltest.eval + rw [hT, M.orbitToOrdinary_eval, M.orbitToOrdinary_eval] + apply congrArg T.observable + apply congrArg QuotientGroup.mk + exact M.filtration.realification.polynomialOrbitEval_eq_of_zero_coordinate i hi g x y hxy + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +section + +namespace Erdos3 + +open Module VectorPolynomial RationalFilteredNilmanifold +open RationalFilteredNilmanifold.MultidegreeStructure +open scoped TensorProduct BigOperators NNReal + +theorem exists_missing_coordinate_niltest_approximation (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {d : ℕ} {D : RationalFilteredNilmanifold L s d} {p : ℝ} + (T : D.Niltest (fun _ : Fin (s + 1) => 1)), T.ComplexityLE p → T.normBound ≤ 1 → + ∀ epsilon : ℝ, 0 < epsilon → 1 / epsilon ≤ Real.exp ((p + 2) ^ a) → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ (c : Fin m → ℂ) (F : Fin (s + 1) → Fin m → (Fin (s + 1) → ℤ) → ℂ), + (∀ j, ‖c j‖ ≤ 2) ∧ (∀ i j x, ‖F i j x‖ ≤ 1) ∧ + (∀ i j x y, (∀ k, k ≠ i → x k = y k) → F i j x = F i j y) ∧ + ∀ x, ‖T.eval x - ∑ j, c j * ∏ i, F i j x‖ ≤ epsilon := by + obtain ⟨B, _, hsplit⟩ := exists_multidegree_downset_splitting s ((s + 1) * s) a + let X : Polynomial ℕ := Polynomial.X + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((X + Polynomial.C (s + 1) + Polynomial.C B) ^ B) + refine ⟨C, hC, ?_⟩ + intro L _ _ _ _ _ _ d D p T hT hnorm epsilon hepsilon hscale + classical + have hp : 0 ≤ p := (Nat.cast_nonneg d).trans hT.1.1 + let q := p + (s + 1 : ℕ) + have hpq : p ≤ q := le_add_of_nonneg_right (Nat.cast_nonneg _) + have hq : 0 ≤ q := hp.trans hpq + have hcost : (q + B) ^ B ≤ (p + C) ^ C := by + simpa [X, q, Polynomial.eval₂_pow] using hbudget p hp + let M := D.totalDegreeMultidegree (Fin (s + 1)) hT.1 + let J := missingCoordinateDownset s + have hJ : ∀ i, IsLowerSet (J i) := missingCoordinateDownset_lower s + let K := fun i => M.filtration.positivePolynomialAlgebra ⧸ + restrictedOutsideDownsetIdeal M.filtration.positivePolynomialAlgebra (J i) (hJ i) + let : ∀ i, TopologicalSpace (ℝ ⊗[ℚ] K i) := fun _ => moduleTopology ℝ _ + let : ∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] K i) := + fun _ => IsModuleTopology.isTopologicalAddGroup ℝ _ + let : ∀ i, T2Space (ℝ ⊗[ℚ] K i) := + fun i => realification_moduleTopology_t2 (M.positivePolynomialDownsetFinBasis (J i) (hJ i) q) + have hM : M.ComplexityLE q := (D.totalDegreeMultidegree_complexity (Fin (s + 1)) hT.1).mono M hpq + have hfamily : (Fintype.card (Fin (s + 1)) : ℝ) ≤ q + 2 := by + simp only [Fintype.card_fin] + dsimp [q] + linarith only [hp] + have hcover : ∀ b, b ≠ 0 → (∀ i, b ∉ J i) → M.filtration.layer (fun k => b k) = ⊥ := + fun b _ hb => missingCoordinateDownset_terminal D.filtration b hb + have hscaleq : 1 / epsilon ≤ Real.exp ((q + 2) ^ a) := + hscale.trans (Real.exp_le_exp.mpr (pow_le_pow_left₀ (by positivity) (by linarith only [hpq]) a)) + obtain ⟨r, _, _, b, hb, hstable, hE, _, h, _, n, hn, _, hcount, U, + hUnorm, _, _, hUorbit, happrox⟩ := + hsplit (I := Unit) (α := Fin (s + 1)) M J hJ q (by simp) hM hfamily hcover + (D.filtration.realTotalDegreeOrbit T.orbit) epsilon hepsilon hscaleq + (by simpa using Real.one_le_exp hq) + let V := fun i => M.positivePolynomialDownsetModelMultidegree (J i) (hJ i) r b hb hstable + have hzero (i : Fin (s + 1)) (v : Fin (s + 1) → ℕ) + (hv : ¬v ≤ missingCoordinateBound s i) : (V i).filtration.layer v = ⊥ := by + let c : Fin (s + 1) →₀ ℕ := Finsupp.equivFunOnFinite.symm v + exact M.filtration.positivePolynomialDownsetQuotient_terminal (J i) (hJ i) c hv + let V' := fun i => (V i).restrictBound (missingCoordinateBound s i) + (missingCoordinateBound_le s i) (hzero i) + have hindependent (i : Fin (s + 1)) (j : Fin (n i)) (x y : Fin (s + 1) → ℤ) + (hxy : ∀ k, k ≠ i → x k = y k) : (U i j).eval x = (U i j).eval y := by + let g : (V i).filtration.realification.PolynomialOrbit := + M.filtration.positivePolynomialDownsetOrbit (J i) (hJ i) h + let g' := (V i).filtration.restrictBoundRealOrbit (missingCoordinateBound s i) (hzero i) g + exact (V' i).niltest_eval_eq_of_zero_coordinate i (by simp [missingCoordinateBound]) + (U i j) g' (hUorbit i j) x y hxy + have hlip : (T.lipBound : ℝ) ≤ Real.exp q := by + have hobs := T.observable_budget hT + have hnonneg := T.normBound.coe_nonneg + exact (by linarith only [hobs, hnonneg] : (T.lipBound : ℝ) ≤ Real.exp p).trans + (Real.exp_le_exp.mpr hpq) + have hub : ∀ x, ‖T.observable x‖ ≤ 1 := fun x => + (T.norm_le x).trans (show (T.normBound : ℝ) ≤ 1 from hnorm) + obtain ⟨coeff, hcoeff, _, herr⟩ := happrox (fun _ : Unit => T.observable) T.lipBound hlip + (fun _ => T.lipschitz) (fun _ => hub) + have hscalar := scalar_error_le_of_vector_error (I := Unit) (J := ∀ i, Fin (n i)) + (S := (Fin (s + 1) → ℤ)) (epsilon := epsilon) + (fun _ : Unit => fun x => T.observable (QuotientGroup.mk + (M.filtration.realification.polynomialOrbitEval x (D.filtration.realTotalDegreeOrbit T.orbit)))) + (fun j x => ∏ i, (U i (j i)).eval x) coeff herr () + let W := ∀ i, Fin (n i) + let : Nonempty W := ⟨fun i => ⟨0, hn i⟩⟩ + let e : Fin (Fintype.card W) ≃ W := (Fintype.equivFin W).symm + refine ⟨Fintype.card W, Fintype.card_pos, hcount.trans (Real.exp_le_exp.mpr hcost), + (fun j => coeff (e j) ()), (fun i j x => (U i (e j i)).eval x), + (fun j => hcoeff (e j) ()), ?_, ?_, ?_⟩ + · intro i j x + exact ((U i (e j i)).norm_eval_le x).trans (by rw [hUnorm]; rfl) + · intro i j x y hxy + exact hindependent i (e j i) x y hxy + · intro x + have hval : T.observable (QuotientGroup.mk + (M.filtration.realification.polynomialOrbitEval x + (D.filtration.realTotalDegreeOrbit T.orbit))) = T.eval x := by + exact congrArg (fun z => T.observable (QuotientGroup.mk z)) + (D.filtration.realTotalDegreeOrbit_eval T.orbit x) + have hs := hscalar x + rw [hval] at hs + have hsum := e.sum_comp (fun j => coeff j () * ∏ i, (U i (j i)).eval x) + rw [hsum] + simpa only [mul_comm] using hs + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/MixedPrimitiveNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/MixedPrimitiveNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd646bfb8c95c364c49eb947d1c0a7ebd2244104 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/MixedPrimitiveNiltest.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Progressions.Estimates.MixedPrimitiveGowers + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeCyclicModel.lie NativeCyclicModel.algebra NativeCyclicModel.topology + NativeCyclicModel.topologicalAdd NativeCyclicModel.continuousSMul NativeCyclicModel.hausdorff + +theorem exists_mixed_diagonal_niltest {d : ℕ} {p : ℝ} + (W : NativeMultidegreeNilcharacter (fun _ : MixedReplicatedIndex (d + 2) => 1) p) (i : Fin W.outputDim) : + ∃ T : W.model.Niltest (fun _ : Unit => 1), T.normBound = 1 ∧ T.ComplexityLE (p + 4) ∧ + ∀ n : ℤ, T.eval (fun _ => n) = W.eval i (fun _ => n) := by + obtain ⟨T, hT, hcomplexity, heval⟩ := W.exists_linear_niltest i + (fun _ => { toFun := fun x : Unit → ℤ => x (), map_zero' := rfl, map_add' := fun _ _ => rfl }) + exact ⟨T, hT, hcomplexity, fun n => heval (fun _ => n)⟩ + +theorem exists_mixed_primitive_niltest_budget (d : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + ∀ W : NativeMultidegreeNilcharacter (fun _ : MixedReplicatedIndex (d + 2) => 1) p, + ∀ i : Fin W.outputDim, ∀ g ∈ nativeCyclicFunctions (d + 2) N p, + (fun n : ZMod N => star (W.eval i (fun _ => (n.val : ℤ))) * g n) ∈ + nativeCyclicFunctions (d + 3) N ((p + C) ^ C) := by + obtain ⟨A, _, hproduct⟩ := exists_productNiltestBudget_bound + let X : Polynomial ℕ := Polynomial.X + let R := 2 * X + (X + 2) ^ 2 + 7 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((R + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro N _ p hp W i g ⟨G⟩ + have hdegree : (∑ _ : MixedReplicatedIndex (d + 2), (1 : ℕ)) = d + 3 := mixedReplicated_totalDegree (d + 1) + have hraise : d + 2 ≤ ∑ _ : MixedReplicatedIndex (d + 2), (1 : ℕ) := by omega + obtain ⟨T, hTnorm, hT, hTeval⟩ := W.exists_mixed_diagonal_niltest i + let r := 2 * p + (p + 2) ^ 2 + 7 + have hr : 0 ≤ r := by dsimp [r]; positivity + have hpr : p + 4 ≤ r := by dsimp [r]; nlinarith [sq_nonneg (p + 2)] + have hGr : raisedNiltestBudget p ≤ r := by dsimp [raisedNiltestBudget, r]; linarith + let K : Bool → Type := BoolLieFamily W.L G.L + let dims : Bool → ℕ := fun b => Bool.rec G.dim W.dim b + let models : ∀ b, RationalFilteredNilmanifold (K b) (∑ _ : MixedReplicatedIndex (d + 2), 1) (dims b) := fun b => by + cases b + · exact G.model.raiseStep hraise + · exact W.model + let tests : ∀ b, (models b).Niltest (fun _ : Unit => 1) := fun b => by + cases b + · exact G.test.raiseStep hraise + · exact T.conjugate + have htests : ∀ b, (tests b).ComplexityLE r := by + intro b + cases b + · exact (G.test.raiseStep_complexity hraise hp G.complexity).mono hGr + · exact hT.mono hpr + have hcap : ∀ b, (tests b).normBound ≤ 1 := by + intro b + cases b + · exact G.norm + · exact hTnorm.le + have hcard : (Fintype.card Bool : ℝ) ≤ r := by + simp only [Fintype.card_bool, Nat.cast_ofNat] + linarith + let : FiniteDimensional ℚ (∀ b, K b) := + (RationalFilteredNilmanifold.productFinBasis models).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ b, K b)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ b, K b)) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (∀ b, K b)) := + realification_moduleTopology_t2 (RationalFilteredNilmanifold.productFinBasis models) + let S := RationalFilteredNilmanifold.unitBoundedPiNiltest models tests hr hcard htests hcap + have hcost : productNiltestBudget r ≤ (p + C) ^ C := by + apply (hproduct r hr).trans + simpa [X, R, r, Polynomial.eval₂_pow] using hbudget p hp + have H : Nonempty (NativeCyclicModel (∑ _ : MixedReplicatedIndex (d + 2), 1) N ((p + C) ^ C) + (fun n : ZMod N => star (W.eval i (fun _ => (n.val : ℤ))) * g n)) := by + refine ⟨{ + L := ∀ b, K b + dim := _ + model := RationalFilteredNilmanifold.pi models + test := S + norm := le_rfl + complexity := (RationalFilteredNilmanifold.unitBoundedPiNiltest_complexity + models tests hr hcard htests hcap).mono hcost + eval := ?_ }⟩ + intro n + change _ = S.eval (fun _ => (n.val : ℤ)) + rw [RationalFilteredNilmanifold.unitBoundedPiNiltest_eval, Fintype.prod_bool] + change _ = star (T.eval (fun _ => (n.val : ℤ))) * + (G.test.raiseStep hraise).eval (fun _ => (n.val : ℤ)) + rw [hTeval, RationalFilteredNilmanifold.Niltest.raiseStep_eval, G.eval n] + rfl + change Nonempty (NativeCyclicModel (d + 3) N ((p + C) ^ C) _) + simpa only [hdegree] using H + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeAnchoredSquareNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeAnchoredSquareNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..c96614829fc5261853defe30464f1ec288fe02af --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeAnchoredSquareNiltests.lean @@ -0,0 +1,141 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeAnchoredSquarePartition +import OAI.Combinatorics.Progressions.Nilpotent.NativeSquareNiltest + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct + +def NativeAnchoredSquareNiltestsSpec (s a C : ℕ) : Prop := + ∀ {L : Type} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) + [TopologicalSpace (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + (T : D.Niltest (fun _ : Unit => 1)) (c : ℤ) (q N : ℕ) [NeZero q] [NeZero N] {p ε : ℝ}, + 2 ≤ p → T.ComplexityLE p → (q : ℝ) ≤ Real.exp p → + 0 < ε → ε ≤ 1 → 1 / ε ≤ Real.exp ((p + 2) ^ a) → + ∃ (dQ : ℕ) (Q : RationalFilteredNilmanifold (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)) s dQ) (weight : Fin dQ → ℕ), + (∀ j, Q.filtration.layer j = Submodule.span ℚ (Q.basis '' {i | j ≤ weight i})) ∧ + Q.GeometryComplexityLE ((p + C) ^ C) ∧ + ∃ δ : ℝ, 0 < δ ∧ δ ≤ ε ∧ 1 / δ ≤ Real.exp ((p + C) ^ C) ∧ + ∃ n k : ℕ, 0 < n ∧ 0 < k ∧ + (Fintype.card ((Fin n × ZMod q) × Fin k) : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ A : ((Fin n × ZMod q) × Fin k) → ZMod N → ℝ, + (∀ j, PositiveCyclicNiltest.{0} (s + 1) N ((p + C) ^ C) (A j)) ∧ + (∀ x, ∑ j, A j x = 1) ∧ + (∀ j x, 0 < A j x → (x.val : ZMod q) = j.1.2) ∧ + (∀ j x y, 0 < A j x → 0 < A j y → + dist (ZMod.toAddCircle x) (ZMod.toAddCircle y) ≤ δ) ∧ + (∀ h : ZMod N, ((cyclicWrapExceptional h δ).card : ℝ) / N ≤ 6 * δ + 3 / N) ∧ + letI := Q.metricSpace + ∀ χ : D.RealGroup → CircleFourier.Circle, + (∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = CircleFourier.character (χ z) * T.observable x) → + ∀ (h : ZMod N) (branch : Fin 2), ∃ S : Q.Niltest (fun _ : Unit => 1), + S.normBound = T.normBound ^ 2 ∧ S.ComplexityLE ((p + C) ^ C) ∧ + (∀ z : Unit → ℤ, S.eval z = + T.eval (z + fun _ => (h.val : ℤ) - (branch.val : ℤ) * N) * + star (T.eval (z + fun _ => c))) ∧ + ∀ i j x y, + x ∉ cyclicWrapExceptional h δ → y ∉ cyclicWrapExceptional h δ → + 0 < A i x * A j (x + h) → 0 < A i y * A j (y + h) → + dist (Q.cyclicOrbitPoint S.orbit N (fun _ : Unit => x)) + (Q.cyclicOrbitPoint S.orbit N (fun _ : Unit => y)) ≤ ε + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieFiltration +open scoped TensorProduct + +theorem exists_native_anchored_square_niltests (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ NativeAnchoredSquareNiltestsSpec s a C := by + obtain ⟨B, _, hpartition⟩ := exists_native_anchored_square_partition s a + let R : ℕ := Classical.choose (exists_specified_square_niltest.{0, 0} s) + have hconstruct := @(Classical.choose_spec (exists_specified_square_niltest.{0, 0} s)).2 + let X : Polynomial ℕ := Polynomial.X + let U := X + (X + Polynomial.C B) ^ B + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (U + (U + Polynomial.C R) ^ R) + refine ⟨C, hC, ?_⟩ + dsimp only [NativeAnchoredSquareNiltestsSpec] + intro L _ _ d _ _ _ _ D _ _ _ _ _ _ _ _ T c q N _ _ p ε hp hT hq hε hε1 hεinv + have hp0 : 0 ≤ p := by linarith + obtain ⟨b, v, hF, M, hM, hin, hout, hb, hV, hQ, δ, hδ, hδε, hδinv, + n, k, hn, hk, hcount, A, hA, hsum, hres, hcircle, hexception, hblocks⟩ := + hpartition D T.orbit c q N hp hT.1 hq hε hε1 hεinv + let bs := D.filtration.squareFinBasis b v (hF 2) + let vs := squareFinWeight v + let hls := D.filtration.squareFinBasis_layers b v hF + let V := D.filtration.squareFiltration.ofAdaptedBasis bs vs hls + (D.filtration.squareLattice D.lattice) M hM hin hout + let Q := D.filtration.squareFiltration.topQuotientModel bs vs hls + (D.filtration.squareLattice D.lattice) M hM hin hout + let r := p + (p + B) ^ B + have hpr : p ≤ r := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have hBr : (p + B) ^ B ≤ r := le_add_of_nonneg_left hp0 + have hr : 0 ≤ r := hp0.trans hpr + have htotal : r + (r + R) ^ R ≤ (p + C) ^ C := by + simpa [X, U, r, Polynomial.eval₂_pow] using hbudget p hp0 + have hrC : r ≤ (p + C) ^ C := + (le_add_of_nonneg_right (pow_nonneg (by positivity) _)).trans htotal + have hBC : (p + B) ^ B ≤ (p + C) ^ C := hBr.trans hrC + have hRC : (r + R) ^ R ≤ (p + C) ^ C := (le_add_of_nonneg_left hr).trans htotal + refine ⟨_, Q, quotientFinWeight vs {i | s + 1 ≤ vs i}, ?_, hQ.mono Q hBC, + δ, hδ, hδε, hδinv.trans (Real.exp_le_exp.mpr hBC), n, k, hn, hk, + hcount.trans (Real.exp_le_exp.mpr hBC), A, + fun j => (hA j).mono le_rfl hBC, hsum, hres, hcircle, hexception, ?_⟩ + · exact D.filtration.squareFiltration.quotientFinBasis_layers bs vs hls + (D.filtration.squareFiltration.layerIdeal (s + 1)) le_rfl + {i | s + 1 ≤ vs i} (hls (s + 1)) + let := Q.metricSpace + intro χ hvert h branch + obtain ⟨η, γ, rSq, hγ, hη, hnorm, hcell⟩ := hblocks h branch + obtain ⟨S, horbit, _, hSNorm, hSComplexity, hSval⟩ := + hconstruct D b v hF M hM hin hout T hr (hT.mono hpr) (hV.mono V hBr) + (fun i j => (hb i j).trans hBr) η + (fun i => (hη i).trans (Real.exp_le_exp.mpr hBr)) rSq χ hvert + refine ⟨S, hSNorm, hSComplexity.mono hRC, ?_, ?_⟩ + · intro z + exact (hSval z).trans (D.filtration.realSquareObservable_recovers_product D.lattice η γ + (D.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (z + fun _ => (h.val : ℤ) - (branch.val : ℤ) * N) T.orbit) + (D.filtration.realification.polynomialOrbitEval (fun _ : Unit => 1) + (z + fun _ => c) T.orbit) hγ T.observable + (D.filtration.squareFiltration.realification.polynomialOrbitEval + (fun _ : Unit => 1) z rSq) (hnorm z).1 (hnorm z).2) + · intro i j x y hx hy hxy hyy + have hpoint (z : ZMod N) : Q.cyclicOrbitPoint S.orbit N (fun _ : Unit => z) = + Q.cyclicOrbitPoint + (D.filtration.squareFiltration.realQuotientPolynomialOrbit + (D.filtration.squareFiltration.layerIdeal (s + 1)) le_rfl rSq) N + (fun _ : Unit => z) := + congrArg (fun g => Q.cyclicOrbitPoint g N (fun _ : Unit => z)) horbit + exact (congrArg₂ (fun u v : Q.Space => dist u v) (hpoint x) (hpoint y)).trans_le + (hcell i j x y hx hy hxy hyy) + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeCoverNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeCoverNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a416c1e80d142ab913fd142cf25cdb25ad05d39 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeCoverNiltest.lean @@ -0,0 +1,122 @@ +import OAI.Combinatorics.Progressions.Linear.SplitCoverProjection + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (Λ : Subgroup D.filtration.Group) (m : ℕ) (hm : 0 < m) + (hin : scaledIntegerGrid m ⊆ bchSubgroupCoordinates D.basis Λ) + (hout : bchSubgroupCoordinates D.basis Λ ⊆ denominatorGrid m) (hΛ : Λ ≤ D.lattice) + +noncomputable def onSublattice : (D.withLattice Λ m hm hin hout).Niltest w where + orbit := T.orbit + observable := T.observable ∘ sublatticeProjection D (D.withLattice Λ m hm hin hout) hΛ + normBound := T.normBound + lipBound := T.lipBound + norm_le _ := T.norm_le _ + lipschitz := sublattice_pullback_lipschitz D (D.withLattice Λ m hm hin hout) hΛ rfl + T.observable T.lipschitz + +theorem onSublattice_orbit : (T.onSublattice Λ m hm hin hout hΛ).orbit = T.orbit := rfl + +theorem onSublattice_normBound : + (T.onSublattice Λ m hm hin hout hΛ).normBound = T.normBound := rfl + +theorem onSublattice_lipBound : + (T.onSublattice Λ m hm hin hout hΛ).lipBound = T.lipBound := rfl + +theorem onSublattice_eval (x : σ → ℤ) : + (T.onSublattice Λ m hm hin hout hΛ).eval x = T.eval x := rfl + +theorem onSublattice_evalCyclic (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (T.onSublattice Λ m hm hin hout hΛ).evalCyclic N x = T.evalCyclic N x := rfl + +theorem onSublattice_complexity {p : ℝ} (hT : T.ComplexityLE p) + (hD : (D.withLattice Λ m hm hin hout).GeometryComplexityLE p) : + (T.onSublattice Λ m hm hin hout hΛ).ComplexityLE p := ⟨hD, hT.2⟩ + +theorem onSublattice_unit_interval (hT : T.UnitIntervalValued) : + (T.onSublattice Λ m hm hin hout hΛ).UnitIntervalValued := fun _ => hT _ + +theorem onSublattice_vertical (χ : D.RealGroup → CircleFourier.Circle) + (hT : ∀ z ∈ D.filtration.realification.subgroup s, ∀ x, + T.observable (z • x) = CircleFourier.character (χ z) * T.observable x) + (z : D.RealGroup) (hz : z ∈ D.filtration.realification.subgroup s) + (x : (D.withLattice Λ m hm hin hout).Space) : + (T.onSublattice Λ m hm hin hout hΛ).observable (z • x) = + CircleFourier.character (χ z) * (T.onSublattice Λ m hm hin hout hΛ).observable x := by + induction x using Quotient.inductionOn with + | _ x => exact hT z hz (QuotientGroup.mk x) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open NilpotentLieFiltration +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (T : D.Niltest w) (E : RationalFilteredNilmanifold L s d) + (hfil : E.filtration = D.filtration) (hb : E.basis = D.basis) + (hΛ : E.lattice ≤ D.lattice) + +noncomputable def onNativeCover : E.Niltest w where + orbit := polynomialOrbitOfLog T.orbit.log (by rw [hfil]; exact T.orbit.adapted) + observable := T.observable ∘ sublatticeProjection D E hΛ + normBound := T.normBound + lipBound := T.lipBound + norm_le _ := T.norm_le _ + lipschitz := sublattice_pullback_lipschitz D E hΛ hb T.observable T.lipschitz + +@[simp] theorem onNativeCover_log : + (T.onNativeCover E hfil hb hΛ).orbit.log = T.orbit.log := rfl + +@[simp] theorem onNativeCover_normBound : + (T.onNativeCover E hfil hb hΛ).normBound = T.normBound := rfl + +@[simp] theorem onNativeCover_lipBound : + (T.onNativeCover E hfil hb hΛ).lipBound = T.lipBound := rfl + +@[simp] theorem onNativeCover_eval (x : σ → ℤ) : + (T.onNativeCover E hfil hb hΛ).eval x = T.eval x := rfl + +@[simp] theorem onNativeCover_evalCyclic (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (T.onNativeCover E hfil hb hΛ).evalCyclic N x = T.evalCyclic N x := rfl + +theorem onNativeCover_complexity {p : ℝ} (hT : T.ComplexityLE p) + (hE : E.GeometryComplexityLE p) : + (T.onNativeCover E hfil hb hΛ).ComplexityLE p := ⟨hE, hT.2⟩ + +theorem onNativeCover_unit_interval (hT : T.UnitIntervalValued) : + (T.onNativeCover E hfil hb hΛ).UnitIntervalValued := fun _ => hT _ + +theorem onNativeCover_vertical (χ : D.RealGroup → CircleFourier.Circle) + (hT : ∀ z ∈ D.filtration.realification.subgroup s, ∀ x, + T.observable (z • x) = CircleFourier.character (χ z) * T.observable x) + (z : D.RealGroup) (hz : z ∈ D.filtration.realification.subgroup s) + (x : E.Space) : + (T.onNativeCover E hfil hb hΛ).observable (z • x) = + CircleFourier.character (χ z) * (T.onNativeCover E hfil hb hΛ).observable x := by + induction x using Quotient.inductionOn with + | _ x => exact hT z hz (QuotientGroup.mk x) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeFrozenMultidegreeNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeFrozenMultidegreeNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..853c38680b39a06316688a5f9d7d0e6202191b53 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeFrozenMultidegreeNiltest.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.Progressions.Estimates.CommonRefilteredFactorization + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) (S : Finset σ) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.weightedSubalgebra (retainedCoordinateWeight S))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.weightedSubalgebra (retainedCoordinateWeight S))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.weightedSubalgebra (retainedCoordinateWeight S))] + [T2Space (ℝ ⊗[ℚ] M.filtration.weightedSubalgebra (retainedCoordinateWeight S))] + +theorem exists_frozen_niltest {n : ℕ} + (E : RationalFilteredNilmanifold (M.filtration.weightedSubalgebra (retainedCoordinateWeight S)) + (multidegreeWeight (retainedCoordinateWeight S) bound) n) + (hEF : E.filtration = M.filtration.weightedFiltration (retainedCoordinateWeight S)) + (hEL : E.lattice = D.lattice.comap + (mapOfSteps (M.filtration.weightedSubalgebra (retainedCoordinateWeight S)).incl)) + (b : σ → ℤ) (p : M.filtration.realification.PolynomialOrbit) + (u : D.Space → ℂ) (ℓ B : ℝ≥0) + (hu : letI := D.metricSpace; LipschitzWith ℓ u) (hub : ∀ x, ‖u x‖ ≤ B) + (a γ : D.RealGroup) (hγ : γ ∈ D.realLattice) + (hfactor : M.filtration.realification.polynomialOrbitEval (freezeCoordinates S b 0) p = a * γ) + (A : ℝ≥0) (hA : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => a • x)) + (H : ℕ) (he : ∀ i k, RationalHeightLE (D.basis.repr (E.basis i : L) k) H) : + ∃ T : E.Niltest (fun _ : S => 1), T.normBound = B ∧ + T.lipBound = ℓ * (A * coordinateLipschitzBound d n H) ∧ + E.filtration.realification.polynomialOrbitEval _ 0 T.orbit = 1 ∧ + ∀ x, T.eval x = u (QuotientGroup.mk + (M.filtration.realification.polynomialOrbitEval (freezeCoordinates S b x) p)) := by + let c := retainedCoordinateWeight S + let K := M.filtration.weightedSubalgebra c + let F := M.filtration.weightedFiltration c + have hΓ : E.lattice ≤ D.lattice.comap (mapOfSteps K.incl) := by rw [hEL] + let φ : E.RealGroup →* D.RealGroup := realificationMap + (hnil := E.filtration.lowerCentralSeries_eq_bot) (hM := D.filtration.lowerCentralSeries_eq_bot) K.incl + have hφ : E.realLattice ≤ D.realLattice.comap φ := + realificationMap_subgroup K.incl E.lattice D.lattice hΓ + let π : E.Space → D.Space := cosetMap E.realLattice D.realLattice φ hφ + have hπ : letI := E.metricSpace; letI := D.metricSpace + LipschitzWith (coordinateLipschitzBound d n H) π := by + let : MetricSpace (E.RealGroup ⧸ E.lattice.map realificationHom) := + realificationQuotientMetricSpace E.basis E.lattice E.grid E.grid_pos E.outer_grid + let : MetricSpace (D.RealGroup ⧸ D.lattice.map realificationHom) := + realificationQuotientMetricSpace D.basis D.lattice D.grid D.grid_pos D.outer_grid + exact (lipschitz_realificationMap_quotient E.basis D.basis K.incl E.lattice D.lattice hΓ + E.grid D.grid E.grid_pos D.grid_pos E.outer_grid D.outer_grid H + (fun k i => he i k)).weaken (by simp only [Fintype.card_fin]; exact le_rfl) + obtain ⟨q, hq, hval⟩ := M.filtration.exists_real_normalized_frozen_orbit S b p a γ hfactor + have hF : F.realification = E.filtration.realification := by rw [hEF] + let qE := F.realification.orbitEquivOfEq hF (fun _ : S => 1) q + have hqE (x : S → ℤ) : E.filtration.realification.polynomialOrbitEval _ x qE = + F.realification.polynomialOrbitEval _ x q := + F.realification.orbitEquivOfEq_eval hF _ q x + have hvalE (x : S → ℤ) : φ (E.filtration.realification.polynomialOrbitEval _ x qE) = + a⁻¹ * M.filtration.realification.polynomialOrbitEval (freezeCoordinates S b x) p * γ⁻¹ := by + rw [hqE] + exact hval x + let T : E.Niltest (fun _ : S => 1) := + { orbit := qE + observable := fun x => u (a • π x) + normBound := B + lipBound := ℓ * (A * coordinateLipschitzBound d n H) + norm_le := fun _ => hub _ + lipschitz := by + let := E.metricSpace + let := D.metricSpace + exact hu.comp (hA.comp hπ) } + refine ⟨T, rfl, rfl, (hqE 0).trans hq, ?_⟩ + intro x + change u (a • π (QuotientGroup.mk + (E.filtration.realification.polynomialOrbitEval _ x qE))) = _ + rw [show π (QuotientGroup.mk (E.filtration.realification.polynomialOrbitEval _ x qE)) = + QuotientGroup.mk (φ (E.filtration.realification.polynomialOrbitEval _ x qE)) from rfl, hvalE] + simp only [MulAction.Quotient.smul_mk, smul_eq_mul, ← mul_assoc, mul_inv_cancel, one_mul] + exact congrArg u (QuotientGroup.mk_mul_of_mem _ (D.realLattice.inv_mem hγ)) + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeIntegerChartNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeIntegerChartNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..632756b3494c717dcd88817bd1cba7868f0502aa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeIntegerChartNiltest.lean @@ -0,0 +1,154 @@ +import OAI.Combinatorics.Progressions.Geometry.CommonRefilteredFactorsSymbolTransport + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +theorem integerSampledRealChart_freeze_support {σ τ : Type*} + (w : σ → ℕ) (β : σ → MvPolynomial τ ℤ) + (hβ : ∀ i, integerSampledRealChart β i ∈ weightedSupportLE (fun _ : τ => 1) (w i)) + (keep : τ → Prop) (fixed : {i // ¬keep i} → ℤ) : + ∀ i, integerSampledRealChart (fun z => freezePolynomial keep fixed (β z)) i ∈ + weightedSupportLE (fun _ : {i // keep i} => 1) (w i) := by + intro i + change MvPolynomial.map (Int.castRingHom ℝ) (freezePolynomial keep fixed (β i)) ∈ _ + rw [freezePolynomial_map] + exact freezePolynomial_support keep (fun j => (fixed j : ℝ)) (hβ i) + +end Erdos3.VectorPolynomial + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module VectorPolynomial NilpotentLieFiltration +open scoped TensorProduct + +attribute [local irreducible] realChartSubstitute polynomialOrbitRealChart + weightedAdaptedRealChartHom realPolynomialSymbolHom + +variable {L σ τ : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + (Q : D.Niltest w) (v : τ → ℕ) (β : σ → MvPolynomial τ ℤ) + (hβ : ∀ i, integerSampledRealChart β i ∈ weightedSupportLE v (w i)) + +noncomputable def integerChartPullback : D.Niltest v := + Q.withOrbit (D.filtration.polynomialOrbitRealChart w v (integerSampledRealChart β) hβ Q.orbit) + +@[simp] theorem integerChartPullback_orbit : + (Q.integerChartPullback v β hβ).orbit = + D.filtration.polynomialOrbitRealChart w v (integerSampledRealChart β) hβ Q.orbit := rfl + +@[simp] theorem integerChartPullback_observable : + (Q.integerChartPullback v β hβ).observable = Q.observable := rfl + +@[simp] theorem integerChartPullback_normBound : + (Q.integerChartPullback v β hβ).normBound = Q.normBound := rfl + +@[simp] theorem integerChartPullback_lipBound : + (Q.integerChartPullback v β hβ).lipBound = Q.lipBound := rfl + +@[simp] theorem integerChartPullback_complexity (p : ℝ) : + (Q.integerChartPullback v β hβ).ComplexityLE p ↔ Q.ComplexityLE p := Iff.rfl + +theorem integerChartPullback_complexity_of {p : ℝ} (hQ : Q.ComplexityLE p) : + (Q.integerChartPullback v β hβ).ComplexityLE p := hQ + +@[simp] theorem integerChartPullback_unitIntervalValued : + (Q.integerChartPullback v β hβ).UnitIntervalValued ↔ Q.UnitIntervalValued := Iff.rfl + +@[simp] theorem integerChartPullback_eval (t : τ → ℤ) : + (Q.integerChartPullback v β hβ).eval t = + Q.eval (fun i => MvPolynomial.eval t (β i)) := by + change Q.observable (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval v t + (D.filtration.polynomialOrbitRealChart w v (integerSampledRealChart β) hβ Q.orbit))) = _ + rw [← D.filtration.realification.polynomialOrbitRealEval_integer, + D.filtration.polynomialOrbitRealChart_realEval] + simp only [integerSampledRealChart_eval] + rw [D.filtration.realification.polynomialOrbitRealEval_integer] + rfl + +theorem integerChartPullback_vertical (η : L →ₗ[ℚ] ℚ) + (hQ : ∀ z : D.RealGroup, z ∈ D.filtration.realification.subgroup s → ∀ x, + Q.observable (z • x) = + CircleFourier.character ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * + Q.observable x) : + ∀ z : D.RealGroup, z ∈ D.filtration.realification.subgroup s → ∀ x, + (Q.integerChartPullback v β hβ).observable (z • x) = + CircleFourier.character ((realifyFunctional η z.coord : ℝ) : CircleFourier.Circle) * + (Q.integerChartPullback v β hβ).observable x := hQ + +theorem integerChartPullback_polynomialCoordinates : + D.filtration.realification.polynomialOrbitCoordinates v + (Q.integerChartPullback v β hβ).orbit = + D.filtration.weightedAdaptedRealChartHom w v (integerSampledRealChart β) hβ + (D.filtration.realification.polynomialOrbitCoordinates w Q.orbit) := by + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + change (D.filtration.polynomialOrbitRealChart w v (integerSampledRealChart β) hβ Q.orbit).log = + ((D.filtration.weightedAdaptedRealChartHom w v (integerSampledRealChart β) hβ + (D.filtration.realification.polynomialOrbitCoordinates w Q.orbit)).coord : + VectorPolynomial τ ℚ (ℝ ⊗[ℚ] L)) + rw [polynomialOrbitRealChart_log, weightedAdaptedRealChartHom_coord, + polynomialOrbitCoordinates_log] + +theorem integerChartPullback_orbit_eq_of_orbit_eq (R : D.Niltest w) + (hQR : Q.orbit = R.orbit) : + (Q.integerChartPullback v β hβ).orbit = (R.integerChartPullback v β hβ).orbit := by + simp only [integerChartPullback_orbit, hQR] + +theorem integerChartPullback_symbol {κ : Type*} (b : Basis κ ℚ L) (ω : κ → ℕ) + (hF : ∀ k, D.filtration.layer k = Submodule.span ℚ (b '' {i | k ≤ ω i})) : + (Q.integerChartPullback v β hβ).symbol b ω hF = + D.filtration.realPolynomialSymbolHom b ω hF v + (D.filtration.weightedAdaptedRealChartHom w v (integerSampledRealChart β) hβ + (D.filtration.realification.polynomialOrbitCoordinates w Q.orbit)) := by + change D.filtration.realPolynomialSymbolHom b ω hF v + (D.filtration.realification.polynomialOrbitCoordinates v + (Q.integerChartPullback v β hβ).orbit) = _ + rw [integerChartPullback_polynomialCoordinates] + +theorem integerChartPullback_frozen_symbol_independent + (hβ₁ : ∀ i, integerSampledRealChart β i ∈ weightedSupportLE (fun _ : τ => 1) (w i)) + (keep : τ → Prop) (fixed fixed' : {i // ¬keep i} → ℤ) + (hfreeze : ∀ i, integerSampledRealChart (fun z => freezePolynomial keep fixed (β z)) i ∈ + weightedSupportLE (fun _ : {i // keep i} => 1) (w i)) + (hfreeze' : ∀ i, integerSampledRealChart (fun z => freezePolynomial keep fixed' (β z)) i ∈ + weightedSupportLE (fun _ : {i // keep i} => 1) (w i)) + {κ : Type*} (b : Basis κ ℚ L) (ω : κ → ℕ) + (hF : ∀ k, D.filtration.layer k = Submodule.span ℚ (b '' {i | k ≤ ω i})) : + (Q.integerChartPullback (fun _ : {i // keep i} => 1) + (fun z => freezePolynomial keep fixed (β z)) hfreeze).symbol b ω hF = + (Q.integerChartPullback (fun _ : {i // keep i} => 1) + (fun z => freezePolynomial keep fixed' (β z)) hfreeze').symbol b ω hF := by + rw [integerChartPullback_symbol, integerChartPullback_symbol] + have hcast (a : {i // ¬keep i} → ℤ) + (ha : ∀ i, integerSampledRealChart (fun z => freezePolynomial keep a (β z)) i ∈ + weightedSupportLE (fun _ : {i // keep i} => 1) (w i)) : + D.filtration.weightedAdaptedRealChartHom w (fun _ : {i // keep i} => 1) + (integerSampledRealChart (fun z => freezePolynomial keep a (β z))) ha + (D.filtration.realification.polynomialOrbitCoordinates w Q.orbit) = + D.filtration.weightedAdaptedRealChartHom w (fun _ : {i // keep i} => 1) + (fun i => freezePolynomial keep (fun j => (a j : ℝ)) (integerSampledRealChart β i)) + (fun i => freezePolynomial_support keep (fun j => (a j : ℝ)) (hβ₁ i)) + (D.filtration.realification.polynomialOrbitCoordinates w Q.orbit) := by + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + simp only [weightedAdaptedRealChartHom_coord] + apply congrArg (fun chart => realChartSubstitute chart Q.orbit.log) + funext i + exact freezePolynomial_map (Int.castRingHom ℝ) keep a (β i) + rw [hcast fixed hfreeze, hcast fixed' hfreeze'] + exact D.filtration.realPolynomialSymbolHom_frozenChart_independent b ω hF w + (integerSampledRealChart β) hβ₁ keep (fun i => (fixed i : ℝ)) + (fun i => (fixed' i : ℝ)) + (D.filtration.realification.polynomialOrbitCoordinates w Q.orbit) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeMixedPairNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeMixedPairNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4906cf768e85108bcc420f286a65edb2d60bb79 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeMixedPairNiltest.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Estimates.OriginalMixedRootEquivalence + +namespace OAI + +section + +namespace Erdos3.NativeSampleCorrelation + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +variable {n : ℕ} {p q : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (fun _ : MixedReplicatedIndex (n + 1) => 1) p} + {i j : Fin W.outputDim} + (V : NativeSampleCorrelation (fun _ : Fin (n + 2) => 1) (n + 1) q + Finset.univ (fun z : Fin (n + 2) → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.mixedAntisymmetric i j (fun k => ((z k).val : ℤ)))) + [TopologicalSpace (ℝ ⊗[ℚ] V.MixedPairAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V.MixedPairAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V.MixedPairAlgebra)] + [T2Space (ℝ ⊗[ℚ] V.MixedPairAlgebra)] + +noncomputable def mixedPairNiltest : (pi V.mixedPairModels).Niltest (fun _ : Fin (n + 2) => 1) := + piNiltest V.mixedPairModels V.mixedPairTests + ((by norm_num : (0 : ℝ) ≤ 6).trans V.mixedPairBudget_six_le) + (by simpa using (show (3 : ℝ) ≤ mixedPairBudget p q from + (by norm_num : (3 : ℝ) ≤ 6).trans V.mixedPairBudget_six_le)) + V.mixedPairTests_complexity + +theorem mixedPairNiltest_complexity : + V.mixedPairNiltest.ComplexityLE (productNiltestBudget (mixedPairBudget p q)) := + piNiltest_complexity V.mixedPairModels V.mixedPairTests _ _ _ + +theorem mixedPairNiltest_eval (x : Fin (n + 2) → ℤ) : + V.mixedPairNiltest.eval x = + W.mixedAntisymmetric i j x * star (V.test.eval x) := by + rw [mixedPairNiltest, piNiltest_eval] + exact V.mixedPairTests_eval x + +theorem mixedPairNiltest_vertical (z : (pi V.mixedPairModels).RealGroup) + (hz : z ∈ (pi V.mixedPairModels).filtration.realification.subgroup (∑ _ : MixedReplicatedIndex (n + 1), 1)) + (x : (pi V.mixedPairModels).Space) : + V.mixedPairNiltest.observable (z • x) = + CircleFourier.character + ((realifyFunctional (piFrequency V.mixedPairFrequencies) z.coord : ℝ) : CircleFourier.Circle) * + V.mixedPairNiltest.observable x := + piNiltest_vertical V.mixedPairModels V.mixedPairTests V.mixedPairFrequencies _ _ _ + V.mixedPairTests_vertical z hz x + +theorem mixedPairNiltest_bias : + Real.exp (-q) ≤ ‖𝔼 x ∈ integerBox (fun _ : Fin (n + 2) => N), V.mixedPairNiltest.eval x‖ := by + rw [integerBox_expect_eq_zmod] + simp_rw [V.mixedPairNiltest_eval] + exact V.correlation + +end Erdos3.NativeSampleCorrelation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeMultidegreeNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeMultidegreeNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d93fe51229d774c3149f29d67f31b7cbb337478 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeMultidegreeNiltest.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.Progressions.Estimates.SourceUnitCover + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + +variable {σ τ : Type*} [Fintype σ] {bound : σ → ℕ} {p : ℝ} + (W : NativeMultidegreeNilcharacter bound p) + +noncomputable def component (i : Fin W.outputDim) : W.model.Niltest (fun _ : σ => 1) where + orbit := W.multi.orbitToOrdinary W.orbit + observable := W.vertical.observable i + normBound := 1 + lipBound := W.vertical.lipBound + norm_le := W.vertical.norm i + lipschitz := W.vertical.lipschitz i + +theorem component_eval (i : Fin W.outputDim) (x : σ → ℤ) : (W.component i).eval x = W.eval i x := by + exact congrArg (fun z : W.model.RealGroup => W.vertical.observable i (QuotientGroup.mk z)) + (W.multi.orbitToOrdinary_eval W.orbit x) + +theorem component_complexity (i : Fin W.outputDim) : (W.component i).ComplexityLE (p + 4) := by + have hp : 0 ≤ p := (Nat.cast_nonneg W.dim).trans W.complexity.1.1 + refine ⟨W.complexity.1.mono W.model (by linarith), ?_⟩ + change Real.log (2 + (1 : ℝ) + (W.vertical.lipBound : ℝ)) ≤ p + 4 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + calc + _ ≤ 4 * Real.exp p := by linarith [W.vertical.lip_bound, Real.one_le_exp hp] + _ ≤ Real.exp 4 * Real.exp p := mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (4 : ℝ)]) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, add_comm] + +theorem exists_affine_niltest [Fintype τ] (i : Fin W.outputDim) (A : σ → τ → ℤ) (b : σ → ℤ) : + ∃ T : W.model.Niltest (fun _ : τ => 1), T.normBound = 1 ∧ T.ComplexityLE (p + 4) ∧ + ∀ x, T.eval x = W.eval i (integerAffineMap A b x) := by + refine ⟨(W.component i).affinePullback A b, rfl, W.component_complexity i, ?_⟩ + intro x + rw [RationalFilteredNilmanifold.Niltest.eval_affinePullback, W.component_eval] + +theorem exists_linear_niltest [Fintype τ] (i : Fin W.outputDim) (f : σ → ((τ → ℤ) →+ ℤ)) : + ∃ T : W.model.Niltest (fun _ : τ => 1), T.normBound = 1 ∧ T.ComplexityLE (p + 4) ∧ + ∀ x, T.eval x = W.eval i (fun j => f j x) := by + refine ⟨(W.component i).linearPullbackHom f, rfl, W.component_complexity i, ?_⟩ + intro x + rw [RationalFilteredNilmanifold.Niltest.eval_linearPullbackHom, W.component_eval] + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeNilsequenceExpansion.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeNilsequenceExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..e12226c4f899760a68d924338e46502f1aa5a028 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeNilsequenceExpansion.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Progressions.Nilpotent.NiltestBasepointNormalization + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def conjugate (T : D.Niltest w) : D.Niltest w where + orbit := T.orbit + observable := fun x => star (T.observable x) + normBound := T.normBound + lipBound := T.lipBound + norm_le x := by simpa only [norm_star] using T.norm_le x + lipschitz := by + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + simpa only [dist_eq_norm, ← star_sub, norm_star] using T.lipschitz.dist_le_mul x y + +@[simp] theorem eval_conjugate (T : D.Niltest w) (x : σ → ℤ) : + T.conjugate.eval x = star (T.eval x) := rfl + +@[simp] theorem conjugate_complexityLE (T : D.Niltest w) (p : ℝ) : + T.conjugate.ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +structure NativeNilsequenceExpansion (s N : ℕ) [NeZero N] (p : ℝ) (f : ZMod N → ℂ) where + count : ℕ + count_bound : (count : ℝ) ≤ Real.exp p + L : Fin count → Type + [lie : ∀ i, LieRing (L i)] + [algebra : ∀ i, LieAlgebra ℚ (L i)] + dim : Fin count → ℕ + [topology : ∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] + [topologicalAdd : ∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [continuousSMul : ∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] + [hausdorff : ∀ i, T2Space (ℝ ⊗[ℚ] L i)] + model : ∀ i, RationalFilteredNilmanifold (L i) s (dim i) + test : ∀ i, (model i).Niltest (fun _ : Unit => 1) + complexity : ∀ i, (test i).ComplexityLE p + coefficient : Fin count → ℂ + cost : (∑ i, ‖coefficient i‖) ≤ Real.exp p + eval : ∀ x, f x = ∑ i, coefficient i * (test i).evalCyclic N (fun _ => x) + +attribute [local instance] NativeNilsequenceExpansion.lie NativeNilsequenceExpansion.algebra + NativeNilsequenceExpansion.topology NativeNilsequenceExpansion.topologicalAdd + NativeNilsequenceExpansion.continuousSMul NativeNilsequenceExpansion.hausdorff + +namespace NativeNilsequenceExpansion + +variable {s N : ℕ} [NeZero N] {p q : ℝ} {f : ZMod N → ℂ} + +noncomputable def mono (E : NativeNilsequenceExpansion s N p f) (hpq : p ≤ q) : + NativeNilsequenceExpansion s N q f := + { E with + count_bound := E.count_bound.trans (Real.exp_le_exp.mpr hpq) + complexity := fun i => (E.complexity i).mono hpq + cost := E.cost.trans (Real.exp_le_exp.mpr hpq) } + +noncomputable def conjugate (E : NativeNilsequenceExpansion s N p f) : + NativeNilsequenceExpansion s N p (fun x => star (f x)) := + { E with + test := fun i => (E.test i).conjugate + complexity := E.complexity + coefficient := fun i => star (E.coefficient i) + cost := by simpa only [norm_star] using E.cost + eval := by + intro x + have h := congrArg star (E.eval x) + simpa only [star_sum, star_mul, mul_comm, RationalFilteredNilmanifold.Niltest.evalCyclic, + RationalFilteredNilmanifold.Niltest.eval_conjugate] using h } + +end NativeNilsequenceExpansion + +structure NativeVectorEquivalence {J K : Type*} [Fintype J] [Fintype K] + (s N : ℕ) [NeZero N] (p : ℝ) (chi : J → ZMod N → ℂ) (chi' : K → ZMod N → ℂ) : Prop where + left_dimension : (Fintype.card J : ℝ) ≤ Real.exp p + right_dimension : (Fintype.card K : ℝ) ≤ Real.exp p + expansion : ∀ j k, Nonempty (NativeNilsequenceExpansion s N p + (fun x => chi j x * star (chi' k x))) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeNiltestPartition.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeNiltestPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..bafff940d9ac4afa0e98b947f46091b90bdbe8b5 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeNiltestPartition.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Estimates.FixedObservableCorrelation + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct NNReal + +theorem exists_native_niltest_partition (s a : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] {d : ℕ} + (D : RationalFilteredNilmanifold L s d) (w : σ → ℕ) {p ρ : ℝ}, + 0 ≤ p → D.GeometryComplexityLE p → 0 < ρ → + 1 / ρ ≤ Real.exp ((p + 2) ^ a) → + ∀ g : D.filtration.realification.PolynomialOrbit w, + ∃ n : ℕ, 0 < n ∧ (n : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ + ∃ A : Fin n → D.Niltest w, + (∀ i, (A i).orbit = g) ∧ + (∀ i, (A i).UnitIntervalValued) ∧ + (∀ i, (A i).ComplexityLE ((p + C) ^ C)) ∧ + (∀ z, ∑ i, ((A i).observable z).re = 1) ∧ + (letI := D.metricSpace + ∀ i x y, 0 < ((A i).observable x).re → 0 < ((A i).observable y).re → dist x y ≤ ρ) := by + obtain ⟨B, _, hpartition⟩ := exists_native_positive_partition s a + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + (Polynomial.X + (Polynomial.X + Polynomial.C B) ^ B + 2) + refine ⟨C, hC, ?_⟩ + intro σ L _ _ _ _ _ _ d D w p ρ hp hD hρ hρinv g + obtain ⟨n, hn, hnb, K, hK, ψ, hψ, hsum, hLip, hdiam⟩ := hpartition D hp hD hρ hρinv + have hcost : p + (p + B) ^ B + 2 ≤ (p + C) ^ C := by + simpa [Polynomial.eval₂_pow] using hbudget p hp + have hB0 : 0 ≤ (p + B) ^ B := pow_nonneg (by positivity) _ + have hBC : (p + B) ^ B ≤ (p + C) ^ C := by linarith + have hpC : p ≤ (p + C) ^ C := by linarith + have hlog : Real.log (3 + (K : ℝ)) ≤ (p + C) ^ C := by + apply (Real.log_le_iff_le_exp (by positivity)).mpr + have h1 : 1 ≤ Real.exp ((p + B) ^ B) := Real.one_le_exp hB0 + have h2 : (4 : ℝ) ≤ Real.exp 2 := by + rw [show (2 : ℝ) = 1 + 1 by norm_num, Real.exp_add] + nlinarith [Real.add_one_le_exp (1 : ℝ)] + have hle : 3 + (K : ℝ) ≤ Real.exp ((p + B) ^ B + 2) := by + rw [Real.exp_add] + nlinarith [mul_le_mul_of_nonneg_left h2 (Real.exp_nonneg ((p + B) ^ B))] + exact hle.trans (Real.exp_le_exp.mpr (by linarith)) + let A : Fin n → D.Niltest w := fun i => + D.sectionNiltest g (fun z (_ : Unit) => ψ i z) (fun z _ => hψ i z) K (fun _ => hLip i) (some ()) + refine ⟨n, hn, hnb.trans (Real.exp_le_exp.mpr hBC), A, fun _ => rfl, ?_, ?_, ?_, ?_⟩ + · intro i + exact D.sectionNiltest_unit_interval g _ _ K _ (some ()) + · intro i + exact D.sectionNiltest_complexityLE g _ _ K _ (some ()) (hD.mono D hpC) hlog + · intro z + change ∑ i, ψ i z = 1 + exact hsum z + · let := D.metricSpace + intro i x y hx hy + exact hdiam i x y hx hy + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeRankZeroNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeRankZeroNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..de22b726894421462b1de06f45c6b4c48aa13c68 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeRankZeroNiltest.lean @@ -0,0 +1,193 @@ +import OAI.Combinatorics.Progressions.Dynamics.ComparisonEquivalenceBudget +import OAI.Combinatorics.Progressions.Estimates.AllocatedMarkedDictionaryRecovery + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L (s + 1) d) (hD : D.filtration.layer (s + 1) = ⊥) + +noncomputable def dropTopMap : (D.dropTop hD).Space → D.Space := + cosetMap (D.dropTop hD).realLattice D.realLattice + (realificationMap (hnil := (D.dropTop hD).filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L)) + (realificationMap_subgroup (LieHom.id : L →ₗ⁅ℚ⁆ L) (D.dropTop hD).lattice D.lattice + (D.dropTop_lattice_back hD)) + +theorem dropTopMap_mk (x : (D.dropTop hD).RealGroup) : + D.dropTopMap hD (QuotientGroup.mk x) = + QuotientGroup.mk (changeStep (D.dropTop hD).filtration.realification.lowerCentralSeries_eq_bot + D.filtration.realification.lowerCentralSeries_eq_bot x) := by + change QuotientGroup.mk (realificationMap + (hnil := (D.dropTop hD).filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L) x) = _ + rw [realificationMap_id_eq_changeStep] + +theorem dropTopMap_surjective : Function.Surjective (D.dropTopMap hD) := by + apply cosetMap_surjective + rw [realificationMap_id_eq_changeStep] + exact (changeStep _ _).surjective + +section Metric + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem dropTopMap_lipschitz : + letI := (D.dropTop hD).metricSpace + letI := D.metricSpace + LipschitzWith 1 (D.dropTopMap hD) := by + let : FiniteDimensional ℝ (ℝ ⊗[ℚ] L) := (D.basis.baseChange ℝ).finiteDimensional_of_finite + let := rightMetricSpace (hnil := (D.dropTop hD).filtration.realification.lowerCentralSeries_eq_bot) + (D.basis.baseChange ℝ) + let := rightMetricSpace (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + (D.basis.baseChange ℝ) + let := rightMetricSpace_isIsometricSMul + (hnil := (D.dropTop hD).filtration.realification.lowerCentralSeries_eq_bot) (D.basis.baseChange ℝ) + let := rightMetricSpace_isIsometricSMul (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + (D.basis.baseChange ℝ) + have hLip : LipschitzWith 1 + (realificationMap (hnil := (D.dropTop hD).filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L)) := by + rw [realificationMap_id_eq_changeStep] + exact lipschitz_changeStep (D.basis.baseChange ℝ) _ _ + exact lipschitz_cosetMap (D.dropTop hD).realLattice D.realLattice + (D.dropTop hD).realLattice_closed_discrete.1 D.realLattice_closed_discrete.1 _ _ hLip + +end Metric + +noncomputable def dropTopRealOrbit {σ : Type*} {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) : + (D.dropTop hD).filtration.realification.PolynomialOrbit w := + NilpotentLieFiltration.polynomialOrbitOfLog g.log g.adapted + +theorem dropTopMap_orbit {σ : Type*} {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (x : σ → ℤ) : + D.dropTopMap hD (QuotientGroup.mk + ((D.dropTop hD).filtration.realification.polynomialOrbitEval w x (D.dropTopRealOrbit hD g))) = + QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x g) := by + rw [D.dropTopMap_mk] + rfl + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L (s + 1) d} {w : σ → ℕ} + +noncomputable def dropTop (T : D.Niltest w) (hD : D.filtration.layer (s + 1) = ⊥) : + (D.dropTop hD).Niltest w where + orbit := D.dropTopRealOrbit hD T.orbit + observable := T.observable ∘ D.dropTopMap hD + normBound := T.normBound + lipBound := T.lipBound + norm_le _ := T.norm_le _ + lipschitz := by + let := D.metricSpace + let := (D.dropTop hD).metricSpace + simpa only [mul_one] using T.lipschitz.comp (D.dropTopMap_lipschitz hD) + +theorem dropTop_eval (T : D.Niltest w) (hD : D.filtration.layer (s + 1) = ⊥) (x : σ → ℤ) : + (T.dropTop hD).eval x = T.eval x := + congrArg T.observable (D.dropTopMap_orbit hD T.orbit x) + +theorem dropTop_evalCyclic (T : D.Niltest w) (hD : D.filtration.layer (s + 1) = ⊥) + (N : ℕ) [NeZero N] (x : σ → ZMod N) : (T.dropTop hD).evalCyclic N x = T.evalCyclic N x := + T.dropTop_eval hD _ + +theorem dropTop_complexity (T : D.Niltest w) (hD : D.filtration.layer (s + 1) = ⊥) + {p : ℝ} (hT : T.ComplexityLE p) : (T.dropTop hD).ComplexityLE p := + ⟨D.dropTop_geometry hD hT.1, hT.2⟩ + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.NativeDegreeRankFamily + +open scoped NNReal + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +variable {s r : ℕ} {A : Type*} {p : ℝ} (W : NativeDegreeRankFamily s r A p) + +noncomputable def component (i : Fin W.outputDim) (a : A) : + W.model.Niltest (fun _ : Unit => 1) where + orbit := W.orbit a + observable := W.vertical.observable i + normBound := 1 + lipBound := W.vertical.lipBound + norm_le := W.vertical.norm i + lipschitz := W.vertical.lipschitz i + +theorem component_eval (i : Fin W.outputDim) (a : A) (n : ℤ) : + (W.component i a).eval (fun _ => n) = W.eval i a n := rfl + +theorem component_evalCyclic (N : ℕ) [NeZero N] (i : Fin W.outputDim) (a : A) (n : ZMod N) : + (W.component i a).evalCyclic N (fun _ => n) = W.evalCyclic N i a n := rfl + +theorem component_complexity (hp : 0 ≤ p) (i : Fin W.outputDim) (a : A) : + (W.component i a).ComplexityLE (p + 4) := by + refine ⟨W.complexity.1.mono W.model (by linarith), ?_⟩ + have h := niltest_log_bound_of_exp (1 : ℝ≥0) W.vertical.lipBound + (a := 0) (b := p) (by norm_num) hp (by simp) W.vertical.lip_bound + simpa only [component, zero_add] using h + +end Erdos3.NativeDegreeRankFamily + +end + +section + +namespace Erdos3.NativeDegreeRankFamily + +attribute [local instance] NativeDegreeRankFamily.lie NativeDegreeRankFamily.algebra + NativeDegreeRankFamily.topology NativeDegreeRankFamily.topologicalAdd + NativeDegreeRankFamily.continuousSMul NativeDegreeRankFamily.hausdorff + +variable {s : ℕ} {A : Type*} {p : ℝ} (W : NativeDegreeRankFamily (s + 1) 0 A p) + +theorem rankZero_top_eq_bot : W.model.filtration.layer (s + 1) = ⊥ := by + rw [← W.rank.associated] + exact W.rank.filtration.rank_zero_top_eq_bot + +noncomputable def lowerComponent (i : Fin W.outputDim) (a : A) : + (W.model.dropTop W.rankZero_top_eq_bot).Niltest (fun _ : Unit => 1) := + (W.component i a).dropTop W.rankZero_top_eq_bot + +theorem lowerComponent_eval (i : Fin W.outputDim) (a : A) (n : ℤ) : + (W.lowerComponent i a).eval (fun _ => n) = W.eval i a n := by + rw [lowerComponent, RationalFilteredNilmanifold.Niltest.dropTop_eval, W.component_eval] + +theorem lowerComponent_evalCyclic (N : ℕ) [NeZero N] (i : Fin W.outputDim) (a : A) (n : ZMod N) : + (W.lowerComponent i a).evalCyclic N (fun _ => n) = W.evalCyclic N i a n := + W.lowerComponent_eval i a _ + +theorem lowerComponent_complexity (hp : 0 ≤ p) (i : Fin W.outputDim) (a : A) : + (W.lowerComponent i a).ComplexityLE (p + 4) := + (W.component i a).dropTop_complexity W.rankZero_top_eq_bot (W.component_complexity hp i a) + +end Erdos3.NativeDegreeRankFamily + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeResetBracketGeometry.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeResetBracketGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1017d9eec81f811bde4057c1fa39e8c2defbd20 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeResetBracketGeometry.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.Progressions.Linear.ChosenBasisGeometryBounds + +namespace OAI + +section + +namespace Erdos3 + +open Module + +noncomputable def nativeResetBracketHeight (p : ℝ) : ℕ := + ⌈Real.exp ((p + 4) ^ 11)⌉₊ + +theorem nativeResetBracketHeight_bounds {p : ℝ} (hp : 0 ≤ p) : + 1 ≤ nativeResetBracketHeight p ∧ + (nativeResetBracketHeight p : ℝ) ≤ Real.exp ((p + 4) ^ 11 + 1) := + ⟨one_le_ceil_exp _, ceil_exp_le_exp_add_one (by positivity)⟩ + +theorem nativeResetBracketLog_ge_input {p : ℝ} (hp : 0 ≤ p) : + p ≤ (p + 4) ^ 11 := by + have hpow : p + 4 ≤ (p + 4) ^ 11 := by + simpa only [pow_one] using pow_le_pow_right₀ (by linarith : 1 ≤ p + 4) + (by norm_num : (1 : ℕ) ≤ 11) + linarith only [hpow] + +namespace RationalFilteredNilmanifold + +variable {κ L M : Type*} [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + [LieRing M] [LieAlgebra ℚ M] {s t d f : ℕ} + (D : RationalFilteredNilmanifold L s d) + (Fmark : RationalFilteredNilmanifold M t f) (c : Basis κ ℚ M) + +theorem nativeResetBracketGeometry {p : ℝ} (hp : 0 ≤ p) + (hD : D.GeometryComplexityLE p) (hF : Fmark.GeometryComplexityLE p) + (hc : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p) : + (d : ℝ) ≤ p ∧ (Fintype.card κ : ℝ) ≤ p ∧ + (∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) + (nativeResetBracketHeight p)) ∧ + (∀ i j k, RationalHeightLE (c.repr ⁅c i, c j⁆ k) + (nativeResetBracketHeight p)) := by + obtain ⟨hdim, _, hbracket⟩ := Fmark.basis_geometry_of_forward_height c hp hF + (fun i j => (hc i j).trans (by linarith)) + exact ⟨hD.1, hdim, + fun i j k => rationalHeightLE_ceil_exp + ((hD.2.2.1 i j k).trans (nativeResetBracketLog_ge_input hp)), + fun i j k => rationalHeightLE_ceil_exp (hbracket i j k)⟩ + +theorem nativeResetBracketGeometry_of_height {p : ℝ} {H : ℕ} (hp : 0 ≤ p) + (hD : D.GeometryComplexityLE p) (hF : Fmark.GeometryComplexityLE p) + (hc : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p) + (hH : nativeResetBracketHeight p ≤ H) : + (d : ℝ) ≤ p ∧ (Fintype.card κ : ℝ) ≤ p ∧ + (∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) H) ∧ + (∀ i j k, RationalHeightLE (c.repr ⁅c i, c j⁆ k) H) := by + obtain ⟨hd, hf, hbracketD, hbracketF⟩ := D.nativeResetBracketGeometry Fmark c hp hD hF hc + exact ⟨hd, hf, fun i j k => (hbracketD i j k).mono hH, + fun i j k => (hbracketF i j k).mono hH⟩ + +theorem nativeResetBracketGeometry_of_logBudget {p q : ℝ} (hp : 0 ≤ p) + (hD : D.GeometryComplexityLE p) (hF : Fmark.GeometryComplexityLE p) + (hc : ∀ i j, rationalLogHeight (Fmark.basis.repr (c i) j) ≤ p) + (hbudget : (p + 4) ^ 11 ≤ q) : + 1 ≤ ⌈Real.exp q⌉₊ ∧ (⌈Real.exp q⌉₊ : ℝ) ≤ Real.exp (q + 1) ∧ + (d : ℝ) ≤ p ∧ (Fintype.card κ : ℝ) ≤ p ∧ + (∀ i j k, RationalHeightLE (D.basis.repr ⁅D.basis i, D.basis j⁆ k) ⌈Real.exp q⌉₊) ∧ + (∀ i j k, RationalHeightLE (c.repr ⁅c i, c j⁆ k) ⌈Real.exp q⌉₊) := by + refine ⟨one_le_ceil_exp _, ceil_exp_le_exp_add_one ?_, + D.nativeResetBracketGeometry_of_height Fmark c hp hD hF hc ?_⟩ + · exact (show 0 ≤ (p + 4) ^ 11 by positivity).trans hbudget + · exact Nat.ceil_mono (Real.exp_le_exp.mpr hbudget) + +end RationalFilteredNilmanifold +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeResidueNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeResidueNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..00610e1184e507c797c8547dd92dd76cf168112d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeResidueNiltests.lean @@ -0,0 +1,76 @@ +import OAI.Combinatorics.Progressions.Fourier.BohrNiltestBudget +import OAI.Combinatorics.Progressions.Lattices.CircleResiduePartition + +namespace OAI + +section + +namespace Erdos3.RationalTorus + +open CircleFourier +open scoped TensorProduct NNReal + +theorem residueObservable_lipschitz {q : ℕ} [NeZero q] (j : ZMod q) : + LipschitzWith (q : ℝ≥0) (fun v : Fin 1 → CircleFourier.Circle => residueCutoff j (v 0)) := by + apply LipschitzWith.of_dist_le_mul + intro v w + exact ((residueCutoff_lipschitz j).dist_le_mul _ _).trans + (mul_le_mul_of_nonneg_left (dist_le_pi_dist v w 0) (Nat.cast_nonneg q)) + +variable [TopologicalSpace (ℝ ⊗[ℚ] Algebra 1)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] Algebra 1)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] Algebra 1)] [T2Space (ℝ ⊗[ℚ] Algebra 1)] + +noncomputable def residueNiltest {q : ℕ} [NeZero q] (j : ZMod q) : + (nilmanifold 1).Niltest (fun _ : Unit => 1) := + realAffineNiltest (Equiv.refl (Fin 1)) (fun v => residueCutoff j (v 0)) + (fun _ => 0) (fun _ => 1 / (q : ℝ)) (q : ℝ≥0) + (fun v => residueCutoff_unit_interval j (v 0)) (residueObservable_lipschitz j) + +theorem residueNiltest_unit_interval {q : ℕ} [NeZero q] (j : ZMod q) : + (residueNiltest j).UnitIntervalValued := by + unfold residueNiltest + apply realAffineNiltest_unitInterval + +theorem residueNiltest_complexity {q : ℕ} [NeZero q] (j : ZMod q) {p : ℝ} + (hp : 0 ≤ p) (hq : (q : ℝ) ≤ Real.exp p) : + (residueNiltest j).ComplexityLE (p + 2) := by + unfold residueNiltest + apply realAffineNiltest_complexity _ _ _ _ _ _ _ (by linarith) (by norm_num; linarith) + apply (Real.log_le_iff_le_exp (by positivity)).mpr + have h1 := Real.one_le_exp hp + have h2 : (4 : ℝ) ≤ Real.exp 2 := by + rw [show (2 : ℝ) = 1 + 1 by norm_num, Real.exp_add] + nlinarith [Real.add_one_le_exp (1 : ℝ)] + rw [Real.exp_add] + change 3 + (q : ℝ) ≤ Real.exp p * Real.exp 2 + nlinarith [mul_le_mul_of_nonneg_left h2 (Real.exp_nonneg p)] + +theorem residueNiltest_evalCyclic {q : ℕ} [NeZero q] (j : ZMod q) + (N : ℕ) [NeZero N] (x : ZMod N) : + (residueNiltest j).evalCyclic N (fun _ : Unit => x) = + if (x.val : ZMod q) = j then 1 else 0 := by + classical + unfold residueNiltest + rw [realAffineNiltest_evalCyclic] + simp only [zero_add, mul_one_div] + rw [← ZMod.toAddCircle_natCast, residueCutoff_at_grid] + split_ifs <;> rfl + +theorem sum_residueNiltest_evalCyclic {q : ℕ} [NeZero q] + (N : ℕ) [NeZero N] (x : ZMod N) : + ∑ j : ZMod q, ((residueNiltest j).evalCyclic N (fun _ : Unit => x)).re = 1 := by + classical + simp [residueNiltest_evalCyclic, apply_ite] + +theorem residueNiltest_positive_iff {q : ℕ} [NeZero q] (j : ZMod q) + (N : ℕ) [NeZero N] (x : ZMod N) : + 0 < ((residueNiltest j).evalCyclic N (fun _ : Unit => x)).re ↔ (x.val : ZMod q) = j := by + classical + rw [residueNiltest_evalCyclic] + split_ifs <;> simp_all + +end Erdos3.RationalTorus + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeSquareNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeSquareNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..401a37a147d8308aac1aae99572607f132cb4dbe --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NativeSquareNiltest.lean @@ -0,0 +1,646 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeSquareOrbit +import OAI.Combinatorics.Progressions.Estimates.NormalizedCommonFamily +import OAI.Combinatorics.Progressions.Estimates.SpecifiedSquareObservable + +namespace OAI + +section + +namespace Erdos3.NilpotentLieFiltration + +open Module NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct NNReal + +variable {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] {s m : ℕ} + (F : NilpotentLieFiltration L (s + 1)) (Γ : Subgroup F.Group) + [TopologicalSpace (ℝ ⊗[ℚ] F.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] F.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] F.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] F.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (F.squareLieSubalgebra ⧸ F.squareFiltration.layerIdeal (s + 1)))] + +theorem exists_square_quotient_niltest_with_orbit + (b : Basis (Fin m) ℚ F.squareLieSubalgebra) (v : Fin m → ℕ) + (hlayers : ∀ j, F.squareFiltration.layer j = Submodule.span ℚ (b '' {i | j ≤ v i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates b (F.squareLattice Γ)) + (hout : bchSubgroupCoordinates b (F.squareLattice Γ) ⊆ denominatorGrid N) + (w : σ → ℕ) (q : F.squareFiltration.realification.PolynomialOrbit w) + (ε : F.realification.Group) (u : F.realification.Group ⧸ Γ.map realificationHom → ℂ) + (χ : F.realification.Group → CircleFourier.Circle) + (hu : ∀ z ∈ F.realification.subgroup (s + 1), ∀ x, u (z • x) = character (χ z) * u x) + (A B : ℝ≥0) + (hLip : letI := realificationQuotientMetricSpace b (F.squareLattice Γ) N hN hout + LipschitzWith A (F.realSquareObservable Γ ε u)) + (hb : ∀ x, ‖u x‖ ≤ B) : + let D := F.squareFiltration.topQuotientModel b v hlayers (F.squareLattice Γ) N hN hin hout + ∀ H : ℕ, 1 ≤ H → + (∀ i j, RationalHeightLE (D.basis.repr + (lieQuotientMap (F.squareFiltration.layerIdeal (s + 1)) (b j)) i) H) → + (∀ i j k, RationalHeightLE (lieStructureConstants D.basis i j k) H) → + ∃ T : D.Niltest w, + T.orbit = F.squareFiltration.realQuotientPolynomialOrbit + (F.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl q ∧ + (∀ z : F.squareFiltration.realification.Group, + T.observable (QuotientGroup.mk (F.squareFiltration.realQuotientStepHom + (F.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl z)) = + F.realSquareObservable Γ ε u (QuotientGroup.mk z)) ∧ + T.normBound = B ^ 2 ∧ + T.lipBound = rationalReconstructionLipschitzBound s m + (Fintype.card {i : Fin m // ¬ s + 1 ≤ v i}) H A (B ^ 2) ∧ + ∀ x : σ → ℤ, T.eval x = F.realSquareObservable Γ ε u + (QuotientGroup.mk (F.squareFiltration.realification.polynomialOrbitEval w x q)) := by + dsimp only + intro H hH he hc + let D := F.squareFiltration.topQuotientModel b v hlayers (F.squareLattice Γ) N hN hin hout + obtain ⟨f, hf, hfLip, hfBound⟩ := F.exists_lipschitz_realSquare_descent Γ + b D.basis N N H hN hN hH hout D.outer_grid he hc ε u χ hu A B hLip hb + let K := rationalReconstructionLipschitzBound s m + (Fintype.card {i : Fin m // ¬ s + 1 ≤ v i}) H A (B ^ 2) + let T : D.Niltest w := { + orbit := F.squareFiltration.realQuotientPolynomialOrbit + (F.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl q + observable := f + normBound := B ^ 2 + lipBound := K + norm_le := fun x => by simpa only [NNReal.coe_pow] using hfBound x + lipschitz := by + let : MetricSpace (F.squareFiltration.quotientTop.realification.Group ⧸ + ((F.squareLattice Γ).map (F.squareFiltration.quotientStepHom + (F.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl)).map realificationHom) := + realificationQuotientMetricSpace D.basis _ N hN D.outer_grid + exact hfLip.weaken (by simp only [Fintype.card_fin, K]; exact le_rfl) } + refine ⟨T, rfl, hf, rfl, rfl, ?_⟩ + intro x + change f (QuotientGroup.mk ((F.squareFiltration.quotientTop.realification.polynomialOrbitEval w x) + (F.squareFiltration.realQuotientPolynomialOrbit + (F.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl q))) = _ + exact (congrArg (fun g : F.squareFiltration.quotientTop.realification.Group => + f (QuotientGroup.mk g)) + (F.squareFiltration.realQuotientPolynomialOrbit_eval + (F.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl q x)).trans (hf _) + +theorem exists_square_quotient_niltest + (b : Basis (Fin m) ℚ F.squareLieSubalgebra) (v : Fin m → ℕ) + (hlayers : ∀ j, F.squareFiltration.layer j = Submodule.span ℚ (b '' {i | j ≤ v i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates b (F.squareLattice Γ)) + (hout : bchSubgroupCoordinates b (F.squareLattice Γ) ⊆ denominatorGrid N) + (w : σ → ℕ) (q : F.squareFiltration.realification.PolynomialOrbit w) + (ε : F.realification.Group) (u : F.realification.Group ⧸ Γ.map realificationHom → ℂ) + (χ : F.realification.Group → CircleFourier.Circle) + (hu : ∀ z ∈ F.realification.subgroup (s + 1), ∀ x, u (z • x) = character (χ z) * u x) + (A B : ℝ≥0) + (hLip : letI := realificationQuotientMetricSpace b (F.squareLattice Γ) N hN hout + LipschitzWith A (F.realSquareObservable Γ ε u)) + (hb : ∀ x, ‖u x‖ ≤ B) : + let D := F.squareFiltration.topQuotientModel b v hlayers (F.squareLattice Γ) N hN hin hout + ∀ H : ℕ, 1 ≤ H → + (∀ i j, RationalHeightLE (D.basis.repr + (lieQuotientMap (F.squareFiltration.layerIdeal (s + 1)) (b j)) i) H) → + (∀ i j k, RationalHeightLE (lieStructureConstants D.basis i j k) H) → + ∃ T : D.Niltest w, + T.normBound = B ^ 2 ∧ + T.lipBound = rationalReconstructionLipschitzBound s m + (Fintype.card {i : Fin m // ¬ s + 1 ≤ v i}) H A (B ^ 2) ∧ + ∀ x : σ → ℤ, T.eval x = F.realSquareObservable Γ ε u + (QuotientGroup.mk (F.squareFiltration.realification.polynomialOrbitEval w x q)) := by + dsimp only + intro H hH he hc + obtain ⟨T, _, _, hT⟩ := F.exists_square_quotient_niltest_with_orbit Γ b v hlayers N hN hin hout + w q ε u χ hu A B hLip hb H hH he hc + exact ⟨T, hT⟩ + +end Erdos3.NilpotentLieFiltration + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieFiltration NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct NNReal + +variable {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L (s + 1) d) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + +theorem exists_uniform_square_niltest_with_budget {w : σ → ℕ} (T : D.Niltest w) + {p : ℝ} (hp : 0 ≤ p) (hT : T.ComplexityLE p) (a b c : ℕ) + (hrec : ∀ (m n H : ℕ) (ℓ B : ℝ≥0) (r : ℝ), + 0 ≤ r → (m : ℝ) ≤ r → (n : ℝ) ≤ r → (H : ℝ) ≤ Real.exp r → + (ℓ : ℝ) ≤ Real.exp r → (B : ℝ) ≤ Real.exp r → + (rationalReconstructionLipschitzBound s m n H ℓ B : ℝ) ≤ Real.exp ((r + c) ^ c)) : + ∃ (e : Basis (Fin (finrank ℚ L)) ℚ L) (ω : Fin (finrank ℚ L) → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (e '' {i | j ≤ ω i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates + (D.filtration.squareFinBasis e ω (hF 2)) (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates (D.filtration.squareFinBasis e ω (hF 2)) + (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid N), + (∀ i j, rationalLogHeight (D.basis.repr (e i) j) ≤ p + 1) ∧ + let Q := D.filtration.squareFiltration.topQuotientModel + (D.filtration.squareFinBasis e ω (hF 2)) (squareFinWeight ω) + (D.filtration.squareFinBasis_layers e ω hF) + (D.filtration.squareLattice D.lattice) N hN hin hout + Q.GeometryComplexityLE (squareGeometryBudget p) ∧ + ∀ (ε : D.RealGroup) (q : D.filtration.squareFiltration.realification.PolynomialOrbit w) + (χ : D.RealGroup → CircleFourier.Circle), + (∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = character (χ z) * T.observable x) → + ∀ (A : ℝ≥0), (A : ℝ) ≤ Real.exp (normalizedSquareLeftBudget a b p) → + (letI := D.metricSpace; LipschitzWith A (fun x : D.Space => ε • x)) → + ∃ S : Q.Niltest w, + S.orbit = D.filtration.squareFiltration.realQuotientPolynomialOrbit + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl q ∧ + (∀ z : D.filtration.squareFiltration.realification.Group, + S.observable (QuotientGroup.mk (D.filtration.squareFiltration.realQuotientStepHom + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl z)) = + D.filtration.realSquareObservable D.lattice ε T.observable (QuotientGroup.mk z)) ∧ + S.normBound = T.normBound ^ 2 ∧ + S.ComplexityLE (normalizedSquareComplexityBudget a b c p) ∧ + ∀ x : σ → ℤ, S.eval x = D.filtration.realSquareObservable D.lattice ε T.observable + (QuotientGroup.mk (D.filtration.squareFiltration.realification.polynomialOrbitEval w x q)) := by + obtain ⟨b₀, v₀, hlayers, N, hN, hin, hout, hb₀, hgeom, hgeomQ⟩ := + D.exists_controlled_reduced_square_geometry hp hT.1 + let m := Fintype.card (Fin (finrank ℚ L) ⊕ {i // 2 ≤ v₀ i}) + let bs : Basis (Fin m) ℚ D.filtration.squareLieSubalgebra := D.filtration.squareFinBasis b₀ v₀ (hlayers 2) + let v : Fin m → ℕ := squareFinWeight v₀ + have hls := D.filtration.squareFinBasis_layers b₀ v₀ hlayers + let Q := D.filtration.squareFiltration.topQuotientModel bs v hls + (D.filtration.squareLattice D.lattice) N hN hin hout + refine ⟨b₀, v₀, hlayers, N, hN, hin, hout, hb₀, hgeomQ, ?_⟩ + intro ε q χ hvert A hA hALip + have hQ : Q.GeometryComplexityLE (squareGeometryBudget p) := hgeomQ + have hm : (m : ℝ) ≤ squareGeometryBudget p := hgeom.1 + have hQ0 := squareGeometryBudget_nonneg hp + have hObs0 := normalizedSquareObservableBudget_nonneg a b hp + have hB : (T.normBound : ℝ) ≤ Real.exp p := by + have hh := T.observable_budget hT + linarith [T.lipBound.coe_nonneg] + have hK : (T.lipBound : ℝ) ≤ Real.exp p := by + have hh := T.observable_budget hT + linarith [T.normBound.coe_nonneg] + let Hproj := ⌈Real.exp (p + 1)⌉₊ + have hproj := D.filtration.squareFinBasis_projection_height D.basis b₀ v₀ (hlayers 2) + (one_le_ceil_exp (p + 1)) (fun i j => rationalHeightLE_ceil_exp (hb₀ j i)) + let P := coordinateLipschitzBound (Fintype.card (Fin d)) (Fintype.card (Fin m)) Hproj + have hP : (P : ℝ) ≤ Real.exp (normalizedSquareProjectionBudget p) := by + have heq : normalizedSquareProjectionBudget p = (squareGeometryBudget p + p + 2 + 2) ^ 2 := by + unfold normalizedSquareProjectionBudget + ring + rw [heq] + apply coordinateLipschitzBound_le_exp _ _ Hproj + (show 0 ≤ squareGeometryBudget p + p + 2 by linarith) + · simpa only [Fintype.card_fin] using hT.1.1.trans (by linarith : p ≤ squareGeometryBudget p + p + 2) + · simpa only [Fintype.card_fin] using hm.trans (by linarith : squareGeometryBudget p ≤ squareGeometryBudget p + p + 2) + · exact (ceil_exp_le_exp_add_one (by linarith : 0 ≤ p + 1)).trans + (Real.exp_le_exp.mpr (by linarith)) + let ℓ := T.normBound * (T.lipBound * P) + T.normBound * (T.lipBound * (A * P)) + have hℓLip : letI := realificationQuotientMetricSpace bs (D.filtration.squareLattice D.lattice) N hN hout + LipschitzWith ℓ (D.filtration.realSquareObservable D.lattice ε T.observable) := + D.filtration.realSquareObservable_lipschitz D.basis bs D.lattice D.grid N Hproj D.grid_pos hN + D.outer_grid hout (fun k i => (hproj i k).1) (fun k i => (hproj i k).2) + ε T.observable A T.lipBound T.normBound hALip T.lipschitz T.norm_le + have hℓ : (ℓ : ℝ) ≤ Real.exp (normalizedSquareObservableBudget a b p) := + squareObservableLipschitz_le_exp A T.normBound T.lipBound P + (normalizedSquareLeftBudget_nonneg a b hp) hA hB hK hP + let H := ⌈Real.exp (squareGeometryBudget p)⌉₊ + have he (i j) : RationalHeightLE (Q.basis.repr + (lieQuotientMap (D.filtration.squareFiltration.layerIdeal (s + 1)) (bs j)) i) H := by + exact (quotientFinBasis_projection_height bs + (D.filtration.squareFiltration.layerIdeal (s + 1)) {i | s + 1 ≤ v i} + (hls (s + 1)) j i).mono (one_le_ceil_exp _) + obtain ⟨S, hOrbit, hObs, hSB, hSK, hSval⟩ := D.filtration.exists_square_quotient_niltest_with_orbit D.lattice + bs v hls N hN hin hout w q ε T.observable χ hvert ℓ T.normBound hℓLip T.norm_le + H (one_le_ceil_exp _) he (fun i j k => rationalHeightLE_ceil_exp (hQ.2.2.1 i j k)) + let r := normalizedSquareReconstructionBudget a b p + have hr : 0 ≤ r := normalizedSquareReconstructionBudget_nonneg a b hp + have hQr : squareGeometryBudget p + 1 ≤ r := by dsimp [r, normalizedSquareReconstructionBudget]; linarith + have hUr : normalizedSquareObservableBudget a b p ≤ r := by dsimp [r, normalizedSquareReconstructionBudget]; linarith + have hpr : 2 * p ≤ r := by dsimp [r, normalizedSquareReconstructionBudget]; linarith + have hB2 : (((T.normBound ^ 2 : ℝ≥0) : ℝ)) ≤ Real.exp (2 * p) := by + rw [NNReal.coe_pow] + calc + _ ≤ (Real.exp p) ^ 2 := pow_le_pow_left₀ T.normBound.coe_nonneg hB 2 + _ = _ := by rw [← Real.exp_nat_mul]; norm_num + have hSKBound : (S.lipBound : ℝ) ≤ Real.exp ((r + c) ^ c) := by + rw [hSK] + apply hrec _ _ H ℓ (T.normBound ^ 2) r hr + · exact hm.trans (by linarith) + · exact hQ.1.trans (by linarith) + · exact (ceil_exp_le_exp_add_one hQ0).trans (Real.exp_le_exp.mpr hQr) + · exact hℓ.trans (Real.exp_le_exp.mpr hUr) + · exact hB2.trans (Real.exp_le_exp.mpr hpr) + have hSBBound : (S.normBound : ℝ) ≤ Real.exp (2 * p) := by rw [hSB]; exact hB2 + have hlog := niltest_log_bound_of_exp S.normBound S.lipBound + (by linarith : 0 ≤ 2 * p) (by positivity : 0 ≤ (r + c) ^ c) hSBBound hSKBound + refine ⟨S, hOrbit, hObs, hSB, ?_, hSval⟩ + constructor + · apply hQ.mono + change squareGeometryBudget p ≤ squareGeometryBudget p + 2 * p + (r + c) ^ c + 4 + have hpow : 0 ≤ (r + c) ^ c := by positivity + linarith + · apply hlog.trans + change 2 * p + (r + c) ^ c + 4 ≤ squareGeometryBudget p + 2 * p + (r + c) ^ c + 4 + linarith + +theorem exists_square_niltest_with_budget_and_orbit {w : σ → ℕ} (T : D.Niltest w) + {p : ℝ} (hp : 0 ≤ p) (hT : T.ComplexityLE p) (a b c : ℕ) + (hrec : ∀ (m n H : ℕ) (ℓ B : ℝ≥0) (r : ℝ), + 0 ≤ r → (m : ℝ) ≤ r → (n : ℝ) ≤ r → (H : ℝ) ≤ Real.exp r → + (ℓ : ℝ) ≤ Real.exp r → (B : ℝ) ≤ Real.exp r → + (rationalReconstructionLipschitzBound s m n H ℓ B : ℝ) ≤ Real.exp ((r + c) ^ c)) + (ε : D.RealGroup) (q : D.filtration.squareFiltration.realification.PolynomialOrbit w) + (χ : D.RealGroup → CircleFourier.Circle) + (hvert : ∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = character (χ z) * T.observable x) + (A : ℝ≥0) (hA : (A : ℝ) ≤ Real.exp (normalizedSquareLeftBudget a b p)) + (hALip : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => ε • x)) : + ∃ (m : ℕ) (bs : Basis (Fin m) ℚ D.filtration.squareLieSubalgebra) (v : Fin m → ℕ) + (hls : ∀ j, D.filtration.squareFiltration.layer j = Submodule.span ℚ (bs '' {i | j ≤ v i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates bs (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates bs (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid N), + let Q := D.filtration.squareFiltration.topQuotientModel bs v hls + (D.filtration.squareLattice D.lattice) N hN hin hout + ∃ S : Q.Niltest w, + S.orbit = D.filtration.squareFiltration.realQuotientPolynomialOrbit + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl q ∧ + (∀ z : D.filtration.squareFiltration.realification.Group, + S.observable (QuotientGroup.mk (D.filtration.squareFiltration.realQuotientStepHom + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl z)) = + D.filtration.realSquareObservable D.lattice ε T.observable (QuotientGroup.mk z)) ∧ + S.normBound = T.normBound ^ 2 ∧ + S.ComplexityLE (normalizedSquareComplexityBudget a b c p) ∧ + ∀ x : σ → ℤ, S.eval x = D.filtration.realSquareObservable D.lattice ε T.observable + (QuotientGroup.mk (D.filtration.squareFiltration.realification.polynomialOrbitEval w x q)) := by + obtain ⟨e, ω, hF, N, hN, hin, hout, _, _, hconstruct⟩ := + D.exists_uniform_square_niltest_with_budget T hp hT a b c hrec + obtain ⟨S, hS⟩ := hconstruct ε q χ hvert A hA hALip + exact ⟨_, D.filtration.squareFinBasis e ω (hF 2), squareFinWeight ω, + D.filtration.squareFinBasis_layers e ω hF, N, hN, hin, hout, S, hS⟩ + +theorem exists_square_niltest_with_budget {w : σ → ℕ} (T : D.Niltest w) + {p : ℝ} (hp : 0 ≤ p) (hT : T.ComplexityLE p) (a b c : ℕ) + (hrec : ∀ (m n H : ℕ) (ℓ B : ℝ≥0) (r : ℝ), + 0 ≤ r → (m : ℝ) ≤ r → (n : ℝ) ≤ r → (H : ℝ) ≤ Real.exp r → + (ℓ : ℝ) ≤ Real.exp r → (B : ℝ) ≤ Real.exp r → + (rationalReconstructionLipschitzBound s m n H ℓ B : ℝ) ≤ Real.exp ((r + c) ^ c)) + (ε : D.RealGroup) (q : D.filtration.squareFiltration.realification.PolynomialOrbit w) + (χ : D.RealGroup → CircleFourier.Circle) + (hvert : ∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = character (χ z) * T.observable x) + (A : ℝ≥0) (hA : (A : ℝ) ≤ Real.exp (normalizedSquareLeftBudget a b p)) + (hALip : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => ε • x)) : + ∃ (m : ℕ) (bs : Basis (Fin m) ℚ D.filtration.squareLieSubalgebra) (v : Fin m → ℕ) + (hls : ∀ j, D.filtration.squareFiltration.layer j = Submodule.span ℚ (bs '' {i | j ≤ v i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates bs (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates bs (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid N), + let Q := D.filtration.squareFiltration.topQuotientModel bs v hls + (D.filtration.squareLattice D.lattice) N hN hin hout + ∃ S : Q.Niltest w, S.normBound = T.normBound ^ 2 ∧ + S.ComplexityLE (normalizedSquareComplexityBudget a b c p) ∧ + ∀ x : σ → ℤ, S.eval x = D.filtration.realSquareObservable D.lattice ε T.observable + (QuotientGroup.mk (D.filtration.squareFiltration.realification.polynomialOrbitEval w x q)) := by + obtain ⟨m, bs, v, hls, N, hN, hin, hout, S, _, _, hS⟩ := + D.exists_square_niltest_with_budget_and_orbit T hp hT a b c hrec ε q χ hvert A hA hALip + exact ⟨m, bs, v, hls, N, hN, hin, hout, S, hS⟩ + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieFiltration NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct NNReal + +theorem exists_specified_square_niltest (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {d m : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) + [TopologicalSpace (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + (b : Basis (Fin m) ℚ L) (v : Fin m → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ v i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates + (D.filtration.squareFinBasis b v (hF 2)) (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates (D.filtration.squareFinBasis b v (hF 2)) + (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid N) + {ω : σ → ℕ} (T : D.Niltest ω) {p : ℝ}, + 0 ≤ p → T.ComplexityLE p → + (D.filtration.squareFiltration.ofAdaptedBasis + (D.filtration.squareFinBasis b v (hF 2)) (squareFinWeight v) + (D.filtration.squareFinBasis_layers b v hF) + (D.filtration.squareLattice D.lattice) N hN hin hout).GeometryComplexityLE p → + (∀ i j, rationalLogHeight (D.basis.repr (b i) j) ≤ p) → + ∀ η : D.RealGroup, (∀ i, |(D.basis.baseChange ℝ).repr η.coord i| ≤ Real.exp p) → + ∀ (q : D.filtration.squareFiltration.realification.PolynomialOrbit ω) + (χ : D.RealGroup → CircleFourier.Circle), + (∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = character (χ z) * T.observable x) → + let Q := D.filtration.squareFiltration.topQuotientModel + (D.filtration.squareFinBasis b v (hF 2)) (squareFinWeight v) + (D.filtration.squareFinBasis_layers b v hF) + (D.filtration.squareLattice D.lattice) N hN hin hout + ∃ S : Q.Niltest ω, + S.orbit = D.filtration.squareFiltration.realQuotientPolynomialOrbit + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl q ∧ + (∀ z : D.filtration.squareFiltration.realification.Group, + S.observable (QuotientGroup.mk (D.filtration.squareFiltration.realQuotientStepHom + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl z)) = + D.filtration.realSquareObservable D.lattice η T.observable (QuotientGroup.mk z)) ∧ + S.normBound = T.normBound ^ 2 ∧ S.ComplexityLE ((p + C) ^ C) ∧ + ∀ x : σ → ℤ, S.eval x = D.filtration.realSquareObservable D.lattice η T.observable + (QuotientGroup.mk (D.filtration.squareFiltration.realification.polynomialOrbitEval ω x q)) := by + obtain ⟨A, _, hobs⟩ := exists_specified_square_observable_lipschitz s + obtain ⟨B, _, hrec⟩ := exists_rationalReconstructionLipschitzBound_exp s + let X : Polynomial ℕ := Polynomial.X + let U := X + 1 + (X + Polynomial.C A) ^ A + 2 * X + let P := X + 2 * X + (U + Polynomial.C B) ^ B + 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ L _ _ d m _ _ _ _ D _ _ _ _ _ _ _ _ b v hF N hN hin hout ω T p hp hT hV hb η hη q χ hvert + let bs := D.filtration.squareFinBasis b v (hF 2) + let vs := squareFinWeight v + let hls := D.filtration.squareFinBasis_layers b v hF + let Q := D.filtration.squareFiltration.topQuotientModel bs vs hls + (D.filtration.squareLattice D.lattice) N hN hin hout + have hQ : Q.GeometryComplexityLE p := + D.filtration.squareFiltration.topQuotientModel_geometry bs vs hls + (D.filtration.squareLattice D.lattice) N hN hin hout hp hV + obtain ⟨ℓ, hℓ, hℓLip⟩ := hobs D b v (hF 2) N hN hout T hp hT hV.1 hb η hη + let H := ⌈Real.exp p⌉₊ + have he (i j) : RationalHeightLE (Q.basis.repr + (lieQuotientMap (D.filtration.squareFiltration.layerIdeal (s + 1)) (bs j)) i) H := by + exact (quotientFinBasis_projection_height bs + (D.filtration.squareFiltration.layerIdeal (s + 1)) {i | s + 1 ≤ vs i} + (hls (s + 1)) j i).mono (one_le_ceil_exp p) + obtain ⟨S, horbit, hobservable, hnorm, hlip, hval⟩ := + D.filtration.exists_square_quotient_niltest_with_orbit D.lattice bs vs hls N hN hin hout + ω q η T.observable χ hvert ℓ T.normBound hℓLip T.norm_le H (one_le_ceil_exp p) he + (fun i j k => rationalHeightLE_ceil_exp (hQ.2.2.1 i j k)) + have hB : (T.normBound : ℝ) ≤ Real.exp p := by + have h := T.observable_budget hT + linarith [T.lipBound.coe_nonneg] + have hB2 : ((T.normBound ^ 2 : ℝ≥0) : ℝ) ≤ Real.exp (2 * p) := by + rw [NNReal.coe_pow] + calc + _ ≤ (Real.exp p) ^ 2 := pow_le_pow_left₀ T.normBound.coe_nonneg hB 2 + _ = _ := by rw [← Real.exp_nat_mul]; norm_num + let r := p + 1 + (p + A) ^ A + 2 * p + have hr : 0 ≤ r := by dsimp [r]; positivity + have hp1r : p + 1 ≤ r := by dsimp [r]; linarith [pow_nonneg (by positivity : 0 ≤ p + A) A] + have hAr : (p + A) ^ A ≤ r := by dsimp [r]; linarith + have h2pr : 2 * p ≤ r := by dsimp [r]; linarith [pow_nonneg (by positivity : 0 ≤ p + A) A] + have hlipBound : (S.lipBound : ℝ) ≤ Real.exp ((r + B) ^ B) := by + rw [hlip] + apply hrec _ _ H ℓ (T.normBound ^ 2) r hr + · simpa only [Fintype.card_fin] using hV.1.trans (by linarith : p ≤ r) + · exact hQ.1.trans (by linarith) + · exact (ceil_exp_le_exp_add_one hp).trans (Real.exp_le_exp.mpr hp1r) + · exact hℓ.trans (Real.exp_le_exp.mpr hAr) + · exact hB2.trans (Real.exp_le_exp.mpr h2pr) + have hnormBound : (S.normBound : ℝ) ≤ Real.exp (2 * p) := by rw [hnorm]; exact hB2 + have hlog := niltest_log_bound_of_exp S.normBound S.lipBound + (by linarith : 0 ≤ 2 * p) (by positivity : 0 ≤ (r + B) ^ B) hnormBound hlipBound + have hcost : p + 2 * p + (r + B) ^ B + 4 ≤ (p + C) ^ C := by + simpa [X, U, P, r, Polynomial.eval₂_pow] using hbudget p hp + refine ⟨S, horbit, hobservable, hnorm, ?_, hval⟩ + refine ⟨hQ.mono Q (by linarith [pow_nonneg (by positivity : 0 ≤ r + B) B]), ?_⟩ + exact hlog.trans (by linarith) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieFiltration NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct NNReal + +theorem exists_prescribed_two_shift_square_niltest (s k : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {d m : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) + [TopologicalSpace (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + (b : Basis (Fin m) ℚ L) (v : Fin m → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ v i})) + (M : ℕ) (hM : 0 < M) + (hin : scaledIntegerGrid M ⊆ bchSubgroupCoordinates + (D.filtration.squareFinBasis b v (hF 2)) (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates (D.filtration.squareFinBasis b v (hF 2)) + (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid M) + {ω : σ → ℕ} (T : D.Niltest ω) {p : ℝ}, + 0 ≤ p → T.ComplexityLE p → + (D.filtration.squareFiltration.ofAdaptedBasis + (D.filtration.squareFinBasis b v (hF 2)) (squareFinWeight v) + (D.filtration.squareFinBasis_layers b v hF) + (D.filtration.squareLattice D.lattice) M hM hin hout).GeometryComplexityLE p → + (∀ i j, rationalLogHeight (D.basis.repr (b i) j) ≤ p) → + ∀ (a b₀ : σ → ℤ) (η γ : D.RealGroup), γ ∈ D.realLattice → + (∀ i, |(D.basis.baseChange ℝ).repr η.coord i| ≤ Real.exp ((p + 2) ^ k)) → + ∀ (rSq : D.filtration.squareFiltration.realification.PolynomialOrbit ω) + (χ : D.RealGroup → CircleFourier.Circle), + (∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = character (χ z) * T.observable x) → + (∀ x : σ → ℤ, + D.filtration.realSquareFstHom + (D.filtration.squareFiltration.realification.polynomialOrbitEval ω x rSq) = + η⁻¹ * D.filtration.realification.polynomialOrbitEval ω (x + a) T.orbit * γ⁻¹ ∧ + D.filtration.realSquareSndHom + (D.filtration.squareFiltration.realification.polynomialOrbitEval ω x rSq) = + D.filtration.realification.polynomialOrbitEval ω (x + b₀) T.orbit) → + let Q := D.filtration.squareFiltration.topQuotientModel + (D.filtration.squareFinBasis b v (hF 2)) (squareFinWeight v) + (D.filtration.squareFinBasis_layers b v hF) + (D.filtration.squareLattice D.lattice) M hM hin hout + ∃ S : Q.Niltest ω, + S.orbit = D.filtration.squareFiltration.realQuotientPolynomialOrbit + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl rSq ∧ + S.normBound = T.normBound ^ 2 ∧ S.ComplexityLE ((p + C) ^ C) ∧ + ∀ x : σ → ℤ, S.eval x = T.eval (x + a) * star (T.eval (x + b₀)) := by + let A : ℕ := Classical.choose (exists_specified_square_niltest s) + have hconstruct := @(Classical.choose_spec (exists_specified_square_niltest s)).2 + let X : Polynomial ℕ := Polynomial.X + let V := X + (X + 2) ^ k + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget (V + (V + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro σ L _ _ d m _ _ _ _ D _ _ _ _ _ _ _ _ b v hF M hM hin hout ω T p hp hT hV hb + a b₀ η γ hγ hη rSq χ hvert hnorm + let V₀ := D.filtration.squareFiltration.ofAdaptedBasis + (D.filtration.squareFinBasis b v (hF 2)) (squareFinWeight v) + (D.filtration.squareFinBasis_layers b v hF) (D.filtration.squareLattice D.lattice) M hM hin hout + let t := p + (p + 2) ^ k + have hpt : p ≤ t := le_add_of_nonneg_right (pow_nonneg (by positivity) _) + have hkt : (p + 2) ^ k ≤ t := le_add_of_nonneg_left hp + have ht : 0 ≤ t := hp.trans hpt + have hbound : (t + A) ^ A ≤ (p + C) ^ C := by + have hh : t + (t + A) ^ A ≤ (p + C) ^ C := by + simpa [X, V, t, Polynomial.eval₂_pow] using hbudget p hp + linarith + obtain ⟨S, hSo, _, hSn, hSc, hSeval⟩ := hconstruct D b v hF M hM hin hout T ht + (hT.mono hpt) (hV.mono V₀ hpt) (fun i j => (hb i j).trans hpt) η + (fun i => (hη i).trans (Real.exp_le_exp.mpr hkt)) rSq χ hvert + refine ⟨S, hSo, hSn, hSc.mono hbound, ?_⟩ + intro x + exact (hSeval x).trans (D.filtration.realSquareObservable_recovers_product D.lattice η γ + (D.filtration.realification.polynomialOrbitEval ω (x + a) T.orbit) + (D.filtration.realification.polynomialOrbitEval ω (x + b₀) T.orbit) hγ T.observable + (D.filtration.squareFiltration.realification.polynomialOrbitEval ω x rSq) + (hnorm x).1 (hnorm x).2) + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration NilpotentLieBCHGroup VectorPolynomial CircleFourier +open scoped TensorProduct NNReal + +universe uσ uι uL + +def NativeSquareNiltestSpec (s C : ℕ) : Prop := + ∀ {σ : Type uσ} {ι : Type uι} {L : Type uL} + [Fintype σ] [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L (s + 1) d) + [TopologicalSpace (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [T2Space (ℝ ⊗[ℚ] D.filtration.squareLieSubalgebra)] + [TopologicalSpace (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (D.filtration.squareLieSubalgebra ⧸ + D.filtration.squareFiltration.layerIdeal (s + 1)))] + (b : Basis ι ℚ L) (ω : ι → ℕ) + (_hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (p : ℝ) (_hp : 0 ≤ p) (T : D.Niltest (fun _ : σ => 1)) (_hT : T.ComplexityLE p) + (g : D.filtration.RealAdaptedPolynomialGroup (fun _ : σ => 1)) + (_hg : D.filtration.nativePolynomialOrbit (fun _ => 1) g = T.orbit) + (χ : D.RealGroup → CircleFourier.Circle) + (_hvert : ∀ z ∈ D.filtration.realification.subgroup (s + 1), ∀ x, + T.observable (z • x) = character (χ z) * T.observable x) (h : σ → ℤ), + ∃ ε γ : D.RealGroup, γ ∈ D.realLattice ∧ + (∀ i, |(D.basis.baseChange ℝ).repr ε.coord i| ≤ Real.exp ((p + C) ^ C)) ∧ + ∃ r : D.filtration.squareFiltration.RealAdaptedPolynomialGroup (fun _ : σ => 1), + D.filtration.realAdaptedPolynomialMap (fun _ => 1) + (D.filtration.realSquareFstPolynomialHom (fun _ => 1) r).coord = + normalizedShiftLog (s + 1) (fun i => (h i : ℚ)) (-ε.coord) (-γ.coord) + (D.filtration.realAdaptedPolynomialMap (fun _ => 1) g.coord) ∧ + D.filtration.realSquareSndPolynomialHom (fun _ => 1) r = g ∧ + D.filtration.realFirstCoefficientDirectionMap g.coord (fun i => (h i : ℝ)) - + D.filtration.realFirstCoefficientConstant (fun _ => 1) ε.coord - + D.filtration.realFirstCoefficientAdjoint (fun _ => 1) g + (D.filtration.realFirstCoefficientConstant (fun _ => 1) γ.coord) = + D.filtration.realReducedRelativeCoefficient (fun _ => 1) (fun _ => Nat.zero_lt_one) + (D.filtration.squareFiltration.adaptedReducedRealSymbolHom (fun _ => 1) r) ∧ + ∃ (m : ℕ) (bs : Basis (Fin m) ℚ D.filtration.squareLieSubalgebra) (v : Fin m → ℕ) + (hls : ∀ j, D.filtration.squareFiltration.layer j = Submodule.span ℚ (bs '' {i | j ≤ v i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates bs (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates bs (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid N), + let Q := D.filtration.squareFiltration.topQuotientModel bs v hls + (D.filtration.squareLattice D.lattice) N hN hin hout + ∃ S : Q.Niltest (fun _ : σ => 1), + S.orbit = D.filtration.squareFiltration.nativeReducedPolynomialOrbit (fun _ => 1) r ∧ + (∀ z : D.filtration.squareFiltration.realification.Group, + S.observable (QuotientGroup.mk (D.filtration.squareFiltration.realQuotientStepHom + (D.filtration.squareFiltration.layerIdeal (s + 1)) (t := s) le_rfl z)) = + D.filtration.realSquareObservable D.lattice ε T.observable (QuotientGroup.mk z)) ∧ + S.normBound = T.normBound ^ 2 ∧ S.ComplexityLE ((p + C) ^ C) ∧ + ∀ x : σ → ℤ, S.eval x = T.eval (fun i => x i + h i) * star (T.eval x) + +theorem exists_native_square_niltest (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ NativeSquareNiltestSpec.{uσ, uι, uL} s C := by + obtain ⟨a, _, hnorm⟩ := exists_native_normalized_square.{uσ, uι, uL} s + obtain ⟨b, _, hleft⟩ := exists_bounded_normalization_left_lipschitz (s + 1) a + obtain ⟨c, _, hrec⟩ := exists_rationalReconstructionLipschitzBound_exp s + obtain ⟨c₀, _, hbudget⟩ := exists_normalizedSquareComplexityBudget_bound a b c + let P : Polynomial ℕ := (Polynomial.X + 1 + Polynomial.C a) ^ a + + (Polynomial.X + Polynomial.C c₀) ^ c₀ + obtain ⟨C, hC, hfinal⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro σ ι L _ _ _ d _ _ _ _ D _ _ _ _ _ _ _ _ e ω hF p hp T hT g hg χ hvert h + have hsum : (p + 1 + a) ^ a + (p + c₀) ^ c₀ ≤ (p + C) ^ C := by + simpa [P, Polynomial.eval₂_pow] using hfinal p hp + have hεC : (p + 1 + a) ^ a ≤ (p + C) ^ C := + (le_add_of_nonneg_right (by positivity : 0 ≤ (p + c₀) ^ c₀)).trans hsum + have hSC : (p + c₀) ^ c₀ ≤ (p + C) ^ C := + (le_add_of_nonneg_left (by positivity : 0 ≤ (p + 1 + a) ^ a)).trans hsum + obtain ⟨ε, γ, hγ, hε, r, hf, hs, hderivative⟩ := + hnorm D e ω hF p hp hT.1 (fun i => (h i : ℚ)) g + let q := D.filtration.squareFiltration.nativePolynomialOrbit (fun _ : σ => 1) r + obtain ⟨A, _, hA, hALip⟩ := hleft D p hp hT.1 + obtain ⟨m, bs, v, hls, N, hN, hin, hout, S, hOrbit, hObs, hSB, hS, hSval⟩ := + D.exists_square_niltest_with_budget_and_orbit T hp hT a b c hrec ε q χ hvert A hA (hALip ε hε) + refine ⟨ε, γ, hγ, (fun i => (hε i).trans (Real.exp_le_exp.mpr hεC)), r, hf, hs, ?_, + m, bs, v, hls, N, hN, hin, hout, S, hOrbit, hObs, hSB, hS.mono ((hbudget p hp).trans hSC), ?_⟩ + · simpa only [Rat.cast_intCast] using hderivative + · intro x + rw [hSval x] + have hproduct := D.filtration.nativeNormalizedSquareObservable_product (fun _ => 1) + D.lattice h ε γ hγ T.observable g r hf hs x + rw [hg] at hproduct + exact hproduct + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NilpotentBilinearExponential.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NilpotentBilinearExponential.lean new file mode 100644 index 0000000000000000000000000000000000000000..1135a9b49dd3c40ff3408ad4b26844bf6b5d6611 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NilpotentBilinearExponential.lean @@ -0,0 +1,41 @@ +import Mathlib.RingTheory.Nilpotent.Exp + +namespace OAI + +section + +namespace Erdos3 + +open IsNilpotent TensorProduct Module.End + +variable {R M N P : Type*} [CommRing R] + [AddCommGroup M] [Module R M] [Module ℚ M] + [AddCommGroup N] [Module R N] [Module ℚ N] + [AddCommGroup P] [Module R P] [Module ℚ P] + +theorem nilpotentExp_bilinear + (b : M →ₗ[R] N →ₗ[R] P) + (DM : Module.End R M) (DN : Module.End R N) (DP : Module.End R P) + (hM : IsNilpotent DM) (hN : IsNilpotent DN) (hP : IsNilpotent DP) + (hb : ∀ x y, DP (b x y) = b (DM x) y + b x (DN y)) (x : M) (y : N) : + exp DP (b x y) = b (exp DM x) (exp DN y) := by + let DL : Module.End R (M ⊗[R] N) := DM.rTensor N + let DR : Module.End R (M ⊗[R] N) := DN.lTensor M + have hL : IsNilpotent DL := hM.map (rTensorAlgHom R M N) + have hR : IsNilpotent DR := hN.map (lTensorAlgHom R N M) + have hc : Commute DL DR := by ext; simp [DL, DR] + let m : M ⊗[R] N →ₗ[R] P := TensorProduct.lift b + have he : exp DP ∘ₗ m = m ∘ₗ exp (DL + DR) := by + apply Module.End.commute_exp_left_of_commute (hc.isNilpotent_add hL hR) hP + ext x y + simp [m, DL, DR, hb] + have heL : exp DL = (exp DM).rTensor N := (hM.map_exp (rTensorAlgHom R M N)).symm + have heR : exp DR = (exp DN).lTensor M := (hN.map_exp (lTensorAlgHom R N M)).symm + have h := LinearMap.congr_fun he (x ⊗ₜ[R] y) + simpa [m, exp_add_of_commute hc hL hR, heL, heR] using h + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestAffineProjection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestAffineProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..34d4b6cb50267e8353ac60b4d077cd77e43232d1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestAffineProjection.lean @@ -0,0 +1,498 @@ +import OAI.Combinatorics.Progressions.Estimates.PositiveCyclicCorrelation +import OAI.Combinatorics.Progressions.Geometry.NestedBoxReindex +import OAI.Combinatorics.Progressions.Geometry.SymbolFactorizationTransport +import OAI.Combinatorics.Progressions.Nilpotent.NiltestProbabilityProjection +import OAI.Combinatorics.Progressions.Polynomial.PolynomialSymbolBounds + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ τ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} {v : τ → ℕ} + +noncomputable def substitute (T : D.Niltest w) (f : σ → MvPolynomial τ ℚ) + (hf : ∀ i, f i ∈ weightedSupportLE v (w i)) : D.Niltest v := + { T with orbit := D.filtration.realification.polynomialOrbitSubstitute f hf T.orbit } + +theorem eval_substitute (T : D.Niltest w) (f : σ → MvPolynomial τ ℚ) + (hf : ∀ i, f i ∈ weightedSupportLE v (w i)) (x : τ → ℤ) (y : σ → ℤ) + (hxy : ∀ i, MvPolynomial.aeval (R := ℚ) (fun j => (x j : ℚ)) (f i) = (y i : ℚ)) : + (T.substitute f hf).eval x = T.eval y := by + exact congrArg (fun z : D.RealGroup => T.observable (QuotientGroup.mk z)) + (D.filtration.realification.polynomialOrbitSubstitute_eval f hf T.orbit x y hxy) + +@[simp] theorem substitute_complexityLE (T : D.Niltest w) (f : σ → MvPolynomial τ ℚ) + (hf : ∀ i, f i ∈ weightedSupportLE v (w i)) (p : ℝ) : + (T.substitute f hf).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +noncomputable def affinePullback [Fintype τ] (T : D.Niltest (fun _ : σ => 1)) + (A : σ → τ → ℤ) (b : σ → ℤ) : D.Niltest (fun _ : τ => 1) := + T.substitute (integerAffinePolynomial A b) (integerAffinePolynomial_support A b) + +theorem eval_affinePullback [Fintype τ] (T : D.Niltest (fun _ : σ => 1)) + (A : σ → τ → ℤ) (b : σ → ℤ) (x : τ → ℤ) : + (T.affinePullback A b).eval x = T.eval (integerAffineMap A b x) := + T.eval_substitute (integerAffinePolynomial A b) (integerAffinePolynomial_support A b) + x (integerAffineMap A b x) (integerAffinePolynomial_eval A b x) + +@[simp] theorem affinePullback_complexityLE [Fintype τ] (T : D.Niltest (fun _ : σ => 1)) + (A : σ → τ → ℤ) (b : σ → ℤ) (p : ℝ) : + (T.affinePullback A b).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +noncomputable def linearPullbackHom [Fintype τ] (T : D.Niltest (fun _ : σ => 1)) + (f : σ → ((τ → ℤ) →+ ℤ)) : D.Niltest (fun _ : τ => 1) := by + classical + exact T.affinePullback (fun i j => f i (Pi.single j 1)) 0 + +theorem eval_linearPullbackHom [Fintype τ] (T : D.Niltest (fun _ : σ => 1)) + (f : σ → ((τ → ℤ) →+ ℤ)) (x : τ → ℤ) : + (T.linearPullbackHom f).eval x = T.eval (fun i => f i x) := by + classical + change (T.affinePullback (fun i j => f i (Pi.single j 1)) 0).eval x = _ + rw [eval_affinePullback] + congr 1 + funext i + simpa only [integerAffineMap, Pi.zero_apply, zero_add] using (integerLinearForm_eq_sum (f i) x).symm + +@[simp] theorem linearPullbackHom_complexityLE [Fintype τ] (T : D.Niltest (fun _ : σ => 1)) + (f : σ → ((τ → ℤ) →+ ℤ)) (p : ℝ) : + (T.linearPullbackHom f).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def translate (T : D.Niltest w) (hw : ∀ i, 0 < w i) (h : σ → ℤ) : D.Niltest w := + { T with + orbit := NilpotentLieFiltration.polynomialOrbitOfLog + (VectorPolynomial.translate (fun i => (h i : ℚ)) T.orbit.log) + (D.filtration.realification.adapted_translate w hw (fun i => (h i : ℚ)) T.orbit.adapted) } + +@[simp] theorem eval_translate (T : D.Niltest w) (hw : ∀ i, 0 < w i) (h x : σ → ℤ) : + (T.translate hw h).eval x = T.eval (x + h) := by + apply congrArg T.observable + apply congrArg QuotientGroup.mk + apply NilpotentLieBCHGroup.ext + change VectorPolynomial.eval (fun i => (x i : ℚ)) + (VectorPolynomial.translate (fun i => (h i : ℚ)) T.orbit.log) = + VectorPolynomial.eval (fun i => ((x + h) i : ℚ)) T.orbit.log + rw [VectorPolynomial.eval_translate] + simp only [Pi.add_apply, Int.cast_add] + +@[simp] theorem translate_complexityLE (T : D.Niltest w) (hw : ∀ i, 0 < w i) + (h : σ → ℤ) (p : ℝ) : (T.translate hw h).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {I L : Type*} [Fintype I] [DecidableEq I] [LieRing L] [LieAlgebra ℚ L] {s dim : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s dim} + +theorem exists_nested_box_restriction (T : D.Niltest (fun _ : I => 1)) + (c b : I → ℤ) {m d : ℕ} (hm : 0 < m) (hd : 0 < d) + (H K : I → ℕ) (hK : ∀ i, 0 < K i) + (hsub : commonStrideBox b d K ⊆ commonStrideBox c m H) : + ∃ U : D.Niltest (fun _ : I => 1), + (∀ p, U.ComplexityLE p ↔ T.ComplexityLE p) ∧ + ∀ x ∈ integerBox K, U.eval x = T.eval (commonStrideIndex c m (commonStridePoint b d x)) := by + obtain ⟨A, a, hA⟩ := exists_nested_box_affine c b hm hd H K hK hsub + refine ⟨T.affinePullback A a, fun p => affinePullback_complexityLE T A a p, ?_⟩ + intro x hx + rw [eval_affinePullback, (hA x hx).2, commonStrideIndex_point c hm] + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {K K' L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +noncomputable def coordinateEquiv (T : D.Niltest (fun _ : K => 1)) (e : K ≃ K') : + D.Niltest (fun _ : K' => 1) := + T.substitute (fun i => MvPolynomial.X (e i)) + (fun i => weightedSupportLE_X (fun _ : K' => 1) (e i)) + +@[simp] theorem eval_coordinateEquiv (T : D.Niltest (fun _ : K => 1)) (e : K ≃ K') + (x : K' → ℤ) : + (T.coordinateEquiv e).eval x = T.eval (fun i => x (e i)) := by + exact T.eval_substitute (fun i => MvPolynomial.X (e i)) + (fun i => weightedSupportLE_X (fun _ : K' => 1) (e i)) + x (fun i => x (e i)) (fun _ => by simp) + +@[simp] theorem eval_coordinateEquiv_symm (T : D.Niltest (fun _ : K => 1)) (e : K ≃ K') + (x : K → ℤ) : + (T.coordinateEquiv e).eval (fun j => x (e.symm j)) = T.eval x := by + simp only [eval_coordinateEquiv, Equiv.symm_apply_apply] + +@[simp] theorem coordinateEquiv_observable (T : D.Niltest (fun _ : K => 1)) (e : K ≃ K') : + (T.coordinateEquiv e).observable = T.observable := rfl + +@[simp] theorem coordinateEquiv_normBound (T : D.Niltest (fun _ : K => 1)) (e : K ≃ K') : + (T.coordinateEquiv e).normBound = T.normBound := rfl + +@[simp] theorem coordinateEquiv_lipBound (T : D.Niltest (fun _ : K => 1)) (e : K ≃ K') : + (T.coordinateEquiv e).lipBound = T.lipBound := rfl + +@[simp] theorem coordinateEquiv_complexityLE (T : D.Niltest (fun _ : K => 1)) + (e : K ≃ K') (p : ℝ) : + (T.coordinateEquiv e).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +open scoped TensorProduct BigOperators + +namespace Erdos3 + +theorem exists_correlating_niltest_product_piece {ι : Type*} [Fintype ι] + {L : ι → Type*} [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] + {s : ℕ} {d : ι → ℕ} + [∀ i, TopologicalSpace (ℝ ⊗[ℚ] L i)] [∀ i, IsTopologicalAddGroup (ℝ ⊗[ℚ] L i)] + [∀ i, ContinuousSMul ℝ (ℝ ⊗[ℚ] L i)] [∀ i, T2Space (ℝ ⊗[ℚ] L i)] + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + (w : Fin 1 → ℕ) (hw : ∀ j, 0 < w j) (T : ∀ i, (D i).Niltest w) + {p : ℝ} (hT : ∀ i, (T i).ComplexityLE p) {N : ℕ} [NeZero N] + (h : ι → ZMod N) (f : ZMod N → ℂ) (hf : ∀ x, ‖f x‖ ≤ 1) + (hc : Real.exp (-p) ≤ ‖finiteCorrelation Finset.univ f + (translatedCyclicProduct h (fun i n => (T i).eval (fun _ => n)))‖) : + ∃ a : commonCyclicCuts h, + let len := intervalCutUpper (commonCyclicCuts h) N a - a + let S := fun i => (T i).translate hw (fun _ => cyclicTranslationOffset (h i) a) + 0 < len ∧ a.val + len ≤ N ∧ 2 * ((len : ℤ) - 1) < N ∧ + (∀ i, (S i).ComplexityLE p) ∧ + Real.exp (-p) / (2 * ((Fintype.card ι : ℝ) + 8)) ≤ + ‖finiteCorrelation (Finset.Ico (a.val : ℤ) (a.val + len)) (fun x => f (x : ZMod N)) + (fun x => ∏ i, (S i).eval (fun _ => x))‖ ∧ + Real.exp (-p) / (2 * ((Fintype.card ι : ℝ) + 8) * Real.exp ((Fintype.card ι : ℝ) * p)) ≤ + (len : ℝ) / N := by + have hu (x : ZMod N) : + ‖translatedCyclicProduct h (fun i n => (T i).eval (fun _ => n)) x‖ ≤ + Real.exp ((Fintype.card ι : ℝ) * p) := + translatedCyclicProduct_norm_bound h _ (fun i n => (T i).eval_budget (hT i) _) x + obtain ⟨a, hpos, hbound, hshort, hcorr, hvol⟩ := exists_correlating_integer_product_interval + h (fun i n => (T i).eval (fun _ => n)) f (Real.exp_pos (-p)) + (Real.exp_pos ((Fintype.card ι : ℝ) * p)) hf hu hc + refine ⟨a, hpos, hbound, hshort, ?_, ?_, hvol⟩ + · intro i + exact hT i + · have he (x : ℤ) : + (∏ i, ((T i).translate hw (fun _ => cyclicTranslationOffset (h i) a)).eval (fun _ => x)) = + ∏ i, (T i).eval (fun _ => x + cyclicTranslationOffset (h i) a) := by + apply Finset.prod_congr rfl + intro i _ + rw [RationalFilteredNilmanifold.Niltest.eval_translate] + rfl + simpa only [he] using hcorr + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module VectorPolynomial +open scoped TensorProduct BigOperators + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def symbol (T : D.Niltest w) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) : + D.filtration.RealPolynomialSymbolGroup w := + D.filtration.realPolynomialSymbolHom b ω hF w ⟨⟨T.orbit.log, T.orbit.property⟩⟩ + +theorem symbol_translate (T : D.Niltest w) (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (hw : ∀ i, 0 < w i) (h : σ → ℤ) : + (T.translate hw h).symbol b ω hF = T.symbol b ω hF := by + apply D.filtration.realPolynomialSymbolHom_eq_of_quotient_eq b ω hF w + apply NilpotentLieBCHGroup.ext + exact D.filtration.realification.polynomialSymbolMap_translate w hw + (fun i => (h i : ℚ)) ⟨T.orbit.log, T.orbit.property⟩ + +theorem mean_translate_box [Fintype σ] [DecidableEq σ] + (T : D.Niltest w) (hw : ∀ i, 0 < w i) (a : σ → ℤ) (N : σ → ℕ) : + (𝔼 x ∈ integerBox N, (T.translate hw a).eval x) = + 𝔼 x ∈ translatedIntegerBox a N, T.eval x := by + rw [translatedIntegerBox, translateSupport, + Finset.expect_image (add_right_injective a).injOn] + apply Finset.expect_congr rfl + intro x _ + rw [T.eval_translate, add_comm] + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3 + +noncomputable def scalarAffinePolynomial {σ : Type*} (r : ℚ) (shift : σ → ℚ) (i : σ) : + MvPolynomial σ ℚ := MvPolynomial.C (shift i) + MvPolynomial.C r * MvPolynomial.X i + +theorem scalarAffinePolynomial_support {σ : Type*} (r : ℚ) (shift : σ → ℚ) (i : σ) : + scalarAffinePolynomial r shift i ∈ weightedSupportLE (fun _ : σ => 1) 1 := by + apply Submodule.add_mem + · exact weightedSupportLE_C _ 1 (shift i) + · simpa only [zero_add] using + weightedSupportLE_mul (weightedSupportLE_C (fun _ : σ => 1) 0 r) + (weightedSupportLE_X (fun _ : σ => 1) i) + +namespace VectorPolynomial + +theorem substitute_scalarAffinePolynomial {σ V : Type*} [AddCommGroup V] [Module ℚ V] + (r : ℚ) (shift : σ → ℚ) (p : VectorPolynomial σ ℚ V) : + substitute (scalarAffinePolynomial r shift) p = + weightedDilation (fun _ => 1) r (translate shift p) := by + apply sub_eq_zero.mp + apply eq_zero_of_eval_zero + intro x + rw [map_sub, eval_substitute, eval_weightedDilation, eval_translate] + simp [scalarAffinePolynomial, add_comm] + +end VectorPolynomial + +namespace RationalFilteredNilmanifold.Niltest + +open Module VectorPolynomial +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +noncomputable def scalarAffinePullback (T : D.Niltest (fun _ : σ => 1)) + (r : ℚ) (shift : σ → ℚ) : D.Niltest (fun _ : σ => 1) := + T.substitute (scalarAffinePolynomial r shift) (scalarAffinePolynomial_support r shift) + +@[simp] theorem scalarAffinePullback_complexityLE (T : D.Niltest (fun _ : σ => 1)) + (r : ℚ) (shift : σ → ℚ) (p : ℝ) : + (T.scalarAffinePullback r shift).ComplexityLE p ↔ T.ComplexityLE p := Iff.rfl + +theorem scalarAffinePullback_log (T : D.Niltest (fun _ : σ => 1)) (r : ℚ) (shift : σ → ℚ) : + (T.scalarAffinePullback r shift).orbit.log = + weightedDilation (fun _ => 1) r (VectorPolynomial.translate shift T.orbit.log) := + substitute_scalarAffinePolynomial r shift T.orbit.log + +theorem scalarAffinePullback_eval_integer (T : D.Niltest (fun _ : σ => 1)) + (a : ℤ) (shift x : σ → ℤ) : + (T.scalarAffinePullback a (fun i => (shift i : ℚ))).eval x = + T.eval (fun i => a * x i + shift i) := by + apply T.eval_substitute (scalarAffinePolynomial (a : ℚ) (fun i => (shift i : ℚ))) + (scalarAffinePolynomial_support _ _) x (fun i => a * x i + shift i) + intro i + simp [scalarAffinePolynomial, add_comm] + +theorem scalarAffinePullback_symbol (T : D.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (r : ℚ) (shift : σ → ℚ) : + (T.scalarAffinePullback r shift).symbol b ω hF = + D.filtration.realPolynomialSymbolDilationHom (fun _ => 1) r (T.symbol b ω hF) := by + apply NilpotentLieBCHGroup.ext + change D.filtration.realSymbolOfPolynomial b ω hF (fun _ => 1) + (T.scalarAffinePullback r shift).orbit.log = + D.filtration.realPolynomialSymbolDilation (fun _ => 1) r + (D.filtration.realSymbolOfPolynomial b ω hF (fun _ => 1) T.orbit.log) + rw [T.scalarAffinePullback_log] + apply NilpotentLieFiltration.realSymbolOfPolynomial_affine + · exact fun _ => Nat.zero_lt_one + · exact T.orbit.adapted + +theorem scalarAffinePullback_factorization (T : D.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + {S H : σ → ℝ} {p q : ℝ} {M : ℕ} {U : LieSubalgebra ℚ D.filtration.AssociatedGraded} + (h : D.filtration.SymbolFactorizationIn b ω hF S (T.symbol b ω hF) p M U) + (a : ℤ) (m : ℕ) (ha : a ≠ 0) (hm : 0 < m) (shift : σ → ℚ) + (hS : ∀ i, 0 < S i) (hH : ∀ i, 0 < H i) (hq : 0 ≤ q) + (hphysical : ∀ i, Real.exp (-q) * (|(((a : ℚ) / m : ℚ) : ℝ)| * H i) ≤ S i) : + D.filtration.SymbolFactorizationIn b ω hF H + ((T.scalarAffinePullback ((a : ℚ) / m) shift).symbol b ω hF) + (p + (s : ℝ) * q) (M * m ^ s) U := by + rw [T.scalarAffinePullback_symbol] + exact NilpotentLieFiltration.SymbolFactorizationIn.dilate_ratio D.filtration b ω hF + h a m ha hm hS hH hq hphysical + +end RationalFilteredNilmanifold.Niltest +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module +open scoped TensorProduct + +variable {σ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} + +theorem scalarAffinePullback_symbol_inverse_stride + (T : D.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (Q : ℕ) (hQ : 0 < Q) (shift : σ → ℚ) : + D.filtration.realPolynomialSymbolDilationHom (fun _ : σ => 1) ((Q : ℚ)⁻¹) + ((T.scalarAffinePullback Q shift).symbol b ω hF) = T.symbol b ω hF := by + rw [T.scalarAffinePullback_symbol] + apply NilpotentLieBCHGroup.ext + simp only [NilpotentLieFiltration.realPolynomialSymbolDilationHom_coord, + ← NilpotentLieFiltration.realPolynomialSymbolDilation_mul, + inv_mul_cancel₀ (show (Q : ℚ) ≠ 0 by exact_mod_cast hQ.ne'), + NilpotentLieFiltration.realPolynomialSymbolDilation_one] + +theorem scalarAffineCell_factorization_to_original + (T : D.Niltest (fun _ : σ => 1)) + (b : Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (Q : ℕ) (hQ : 0 < Q) (shift : σ → ℚ) + {S H : σ → ℝ} {p q : ℝ} {denom : ℕ} + {U : LieSubalgebra ℚ D.filtration.AssociatedGraded} + (h : D.filtration.SymbolFactorizationIn b ω hF S + ((T.scalarAffinePullback Q shift).symbol b ω hF) p denom U) + (hS : ∀ i, 0 < S i) (hH : ∀ i, 0 < H i) (hq : 0 ≤ q) + (hphysical : ∀ i, Real.exp (-q) * (H i / (Q : ℝ)) ≤ S i) : + D.filtration.SymbolFactorizationIn b ω hF H (T.symbol b ω hF) + (p + (s : ℝ) * q) (denom * Q ^ s) U := by + have hQreal : (0 : ℝ) < Q := by exact_mod_cast hQ + have hratio (i : σ) : + Real.exp (-q) * (|(((1 : ℚ) / Q : ℚ) : ℝ)| * H i) ≤ S i := by + convert hphysical i using 1 + push_cast + rw [abs_div, abs_one, abs_of_pos hQreal] + ring + have htransport := NilpotentLieFiltration.SymbolFactorizationIn.dilate_ratio + D.filtration b ω hF h 1 Q (by norm_num) hQ hS hH hq hratio + rw [Int.cast_one, one_div, + T.scalarAffinePullback_symbol_inverse_stride b ω hF Q hQ shift] at htransport + exact htransport + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open CircleFourier +open scoped TensorProduct BigOperators + +variable {σ τ ι L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem symbol_eq_of_orbit_eq (T U : D.Niltest w) (h : T.orbit = U.orbit) + (b : Module.Basis ι ℚ L) (ω : ι → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) : + T.symbol b ω hF = U.symbol b ω hF := by + unfold symbol + apply congrArg (D.filtration.realPolynomialSymbolHom b ω hF w) + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + exact congrArg (fun o : D.filtration.realification.PolynomialOrbit w => o.log) h + +theorem affinePullback_orbit_eq_of_orbit_eq [Fintype τ] + (T U : D.Niltest (fun _ : σ => 1)) (h : T.orbit = U.orbit) + (A : σ → τ → ℤ) (b : σ → ℤ) : + (T.affinePullback A b).orbit = (U.affinePullback A b).orbit := by + change D.filtration.realification.polynomialOrbitSubstitute _ _ T.orbit = + D.filtration.realification.polynomialOrbitSubstitute _ _ U.orbit + rw [h] + +theorem exists_affine_finset_kernel_projection_family [Fintype τ] + (T : D.Niltest (fun _ : σ => 1)) (hT : T.UnitIntervalValued) + {p : ℝ} (hTc : T.ComplexityLE p) (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + {J β : Type*} [Fintype J] + (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest (fun _ : σ => 1)) + (horbit : ∀ j, (U j).orbit = T.orbit) + (hvertical : ∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) + (A : β → σ → τ → ℤ) (b : β → σ → ℤ) + (boxes : β → Finset (τ → ℤ)) (hboxes : ∀ a, (boxes a).Nonempty) + (threshold : β → ℝ) {rho : ℝ} (hrho : 0 ≤ rho) (hthreshold : ∀ a, 0 ≤ threshold a) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (hkill : ∀ j, (∃ a, threshold a < + ‖𝔼 x ∈ boxes a, ((U j).affinePullback (A a) (b a)).eval x‖) → + ∀ v ∈ K, eta j v = 0) : + ∃ S : D.Niltest (fun _ : σ => 1), + S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ K.baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + ∀ a, ‖(𝔼 x ∈ boxes a, (T.affinePullback (A a) (b a)).eval x) - + (𝔼 x ∈ boxes a, (S.affinePullback (A a) (b a)).eval x)‖ ≤ + 2 * rho + Fintype.card J * threshold a := by + let law (a : β) := FiniteProbabilityWeights.uniformFinset (boxes a) (hboxes a) + let path (a : β) (x : ↥(boxes a)) := integerAffineMap (A a) (b a) x.val + have hmean (a : β) (F : D.Niltest (fun _ : σ => 1)) : + (law a).complexMean (fun x => F.eval (path a x)) = + 𝔼 x ∈ boxes a, (F.affinePullback (A a) (b a)).eval x := by + simpa only [law, path, eval_affinePullback] using + FiniteProbabilityWeights.uniformFinset_complexMean (boxes a) (hboxes a) + (fun x => F.eval (integerAffineMap (A a) (b a) x)) + have hkill' : ∀ j, (∃ a, threshold a < + ‖(law a).complexMean (fun x => (U j).eval (path a x))‖) → + ∀ v ∈ K, eta j v = 0 := by + intro j ⟨a, ha⟩ v hv + apply hkill j ⟨a, ?_⟩ v hv + simpa only [hmean] using ha + obtain ⟨S, hS, hSc, hSo, hinv, herr⟩ := + T.exists_probability_kernel_projection_family hT hTc K hK eta U horbit hvertical + law path threshold hrho hthreshold happrox hkill' + exact ⟨S, hS, hSc, hSo, hinv, fun a => by simpa only [hmean] using herr a⟩ + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestBasepointNormalization.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestBasepointNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..a757b0a14f945cf02a1e2d834d8c7265fe2e2035 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestBasepointNormalization.lean @@ -0,0 +1,749 @@ +import Mathlib.Analysis.Complex.Basic +import Mathlib.Data.ZMod.Basic +import OAI.Combinatorics.Progressions.Estimates.OrbitBasepointNormalization +import OAI.Combinatorics.Progressions.Lattices.RealifiedFiltrationLattices +import OAI.Combinatorics.Progressions.Nilpotent.FactorwiseBCHCovers +import OAI.Combinatorics.Progressions.Nilpotent.RealifiedBCHFiniteAtlas + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {ι κ L : Type*} [Fintype ι] [Fintype κ] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem basis_reindex_equivFun_symm (b : Basis ι ℚ L) (e : ι ≃ κ) (x : κ → ℚ) : + (b.reindex e).equivFun.symm x = b.equivFun.symm (fun i => x (e i)) := by + apply b.equivFun.injective + funext i + rw [LinearEquiv.apply_symm_apply] + have h := congrFun ((b.reindex e).equivFun.apply_symm_apply x) (e i) + simpa only [Basis.equivFun_apply, Basis.repr_reindex_apply, + Equiv.symm_apply_apply] using h + +theorem bchSubgroupCoordinates_reindex (b : Basis ι ℚ L) (e : ι ≃ κ) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (x : κ → ℚ) : + x ∈ bchSubgroupCoordinates (b.reindex e) Γ ↔ + (fun i => x (e i)) ∈ bchSubgroupCoordinates b Γ := by + unfold bchSubgroupCoordinates + simp only [Set.mem_ofPred_eq, basis_reindex_equivFun_symm] + +theorem bchSubgroup_inner_grid_reindex (b : Basis ι ℚ L) (e : ι ≃ κ) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) {N : ℕ} + (h : scaledIntegerGrid N ⊆ bchSubgroupCoordinates b Γ) : + scaledIntegerGrid N ⊆ bchSubgroupCoordinates (b.reindex e) Γ := by + rintro x ⟨z, rfl⟩ + apply (bchSubgroupCoordinates_reindex b e Γ _).mpr + exact h ⟨fun i => z (e i), rfl⟩ + +theorem bchSubgroup_outer_grid_reindex (b : Basis ι ℚ L) (e : ι ≃ κ) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) {N : ℕ} + (h : bchSubgroupCoordinates b Γ ⊆ denominatorGrid N) : + bchSubgroupCoordinates (b.reindex e) Γ ⊆ denominatorGrid N := by + intro x hx + obtain ⟨z, hz⟩ := h ((bchSubgroupCoordinates_reindex b e Γ x).mp hx) + refine ⟨fun i => z (e.symm i), fun i => ?_⟩ + simpa only [Pi.smul_apply, Equiv.apply_symm_apply] using hz (e.symm i) + +omit [Fintype ι] [Fintype κ] in +theorem basis_reindex_span_weights (b : Basis ι ℚ L) (e : ι ≃ κ) + (w : ι → ℕ) (j : ℕ) : + Submodule.span ℚ ((b.reindex e) '' {i | j ≤ w (e.symm i)}) = + Submodule.span ℚ (b '' {i | j ≤ w i}) := by + congr 1 + ext x + constructor + · rintro ⟨i, hi, rfl⟩ + exact ⟨e.symm i, hi, (Basis.reindex_apply b e i).symm⟩ + · rintro ⟨i, hi, rfl⟩ + refine ⟨e i, ?_, ?_⟩ + · simpa only [Set.mem_ofPred_eq, Equiv.symm_apply_apply] using hi + · simp only [Basis.reindex_apply, Equiv.symm_apply_apply] + +omit [Fintype ι] [Fintype κ] in +theorem lieStructureConstants_reindex (b : Basis ι ℚ L) (e : ι ≃ κ) (i j k : κ) : + lieStructureConstants (b.reindex e) i j k = + lieStructureConstants b (e.symm i) (e.symm j) (e.symm k) := by + simp only [lieStructureConstants, Basis.reindex_apply, Basis.repr_reindex_apply] + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Set Manifold +open scoped Manifold ContDiff Topology + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + +theorem contMDiff_of_quotient_pullback + {E' N : Type*} [NormedAddCommGroup E'] [NormedSpace ℝ E'] + [TopologicalSpace N] [ChartedSpace E' N] (n : ℕ∞ω) + (F : (NilpotentLieBCHGroup L s hnil ⧸ Γ) → N) : + letI := basisChartedSpace (hnil := hnil) e + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, E') n + (fun g : NilpotentLieBCHGroup L s hnil => F (QuotientGroup.mk g)) → + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, E') n F := by + let := basisChartedSpace (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e n + let := quotientChartedSpace e c hstructure hc Γ l hl hgrid + let := isManifold_quotient e c hstructure hc Γ l hl hgrid n + intro hF x + let z := x.out + let φ := quotientCoordinateChart e c hstructure hc Γ l hl hgrid z + have hx : x ∈ φ.target := by + simpa only [z, QuotientGroup.out_eq'] using quotientCoordinateChart_center_mem e c hstructure hc Γ l hl hgrid z + have hφ : φ.symm ∈ IsManifold.maximalAtlas 𝓘(ℝ, ι → ℝ) n (_ ⧸ Γ) := + IsManifold.subset_maximalAtlas (quotientCoordinateChart_mem_atlas e c hstructure hc Γ l hl hgrid z) + have hchart : ContMDiffAt 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n φ.symm x := + contMDiffAt_of_mem_maximalAtlas hφ hx + let σ := fun y : NilpotentLieBCHGroup L s hnil ⧸ Γ => z * (basisHomeomorph e).symm (φ.symm y) + have hσ : ContMDiffAt 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n σ x := + contMDiffAt_const.mul ((contMDiff_basisHomeomorph_symm e n).contMDiffAt.comp x hchart) + apply (hF.contMDiffAt.comp x hσ).congr_of_eventuallyEq + filter_upwards [φ.open_target.mem_nhds hx] with y hy + have hq : (QuotientGroup.mk (σ y) : _ ⧸ Γ) = y := + (quotientCoordinateChart_apply e c hstructure hc Γ l hl hgrid z (φ.symm y)).symm.trans (φ.right_inv hy) + change F y = F (QuotientGroup.mk (σ y)) + rw [hq] + +theorem contMDiff_quotient_iff + {E' N : Type*} [NormedAddCommGroup E'] [NormedSpace ℝ E'] + [TopologicalSpace N] [ChartedSpace E' N] (n : ℕ∞ω) + (F : (NilpotentLieBCHGroup L s hnil ⧸ Γ) → N) : + letI := basisChartedSpace (hnil := hnil) e + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, E') n F ↔ + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, E') n + (fun g : NilpotentLieBCHGroup L s hnil => F (QuotientGroup.mk g)) := by + let := basisChartedSpace (hnil := hnil) e + let := quotientChartedSpace e c hstructure hc Γ l hl hgrid + constructor + · intro hF + exact hF.comp (contMDiff_quotient_mk e c hstructure hc Γ l hl hgrid n) + · exact contMDiff_of_quotient_pullback e c hstructure hc Γ l hl hgrid n F + +theorem contMDiff_quotient_left_smul (a : NilpotentLieBCHGroup L s hnil) (n : ℕ∞ω) : + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n + (fun x : NilpotentLieBCHGroup L s hnil ⧸ Γ => a • x) := by + let := basisChartedSpace (hnil := hnil) e + let := lieGroup_basis (hnil := hnil) e n + let := quotientChartedSpace e c hstructure hc Γ l hl hgrid + apply contMDiff_of_quotient_pullback e c hstructure hc Γ l hl hgrid n + exact (contMDiff_quotient_mk e c hstructure hc Γ l hl hgrid n).comp + (contMDiff_const.mul contMDiff_id) + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +local notation "G" => NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil) + +variable (e : Basis ι ℚ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (l : ℕ) (hl : 0 < l) (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) + +@[instance_reducible] +noncomputable def realificationQuotientChartedSpace : + ChartedSpace (ι → ℝ) (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := + NilpotentLieBCHGroup.quotientChartedSpace (e.baseChange ℝ) (lieStructureConstants e) + (fun i j k => (realLieBasis_structure e i j k).symm) hc + (Γ.map NilpotentLieBCHGroup.realificationHom) l hl + (NilpotentLieBCHGroup.realification_subgroup_grid e Γ l houter) + +theorem isManifold_realification_quotient (n : ℕ∞ω) : + letI := realificationQuotientChartedSpace e Γ l hl houter hc + IsManifold 𝓘(ℝ, ι → ℝ) n (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := + NilpotentLieBCHGroup.isManifold_quotient (e.baseChange ℝ) (lieStructureConstants e) + (fun i j k => (realLieBasis_structure e i j k).symm) hc + (Γ.map NilpotentLieBCHGroup.realificationHom) l hl + (NilpotentLieBCHGroup.realification_subgroup_grid e Γ l houter) n + +theorem contMDiff_realification_quotient_mk (n : ℕ∞ω) : + letI := NilpotentLieBCHGroup.basisChartedSpace + (hnil := realification_lowerCentralSeries_eq_bot hnil) (e.baseChange ℝ) + letI := realificationQuotientChartedSpace e Γ l hl houter hc + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n + (QuotientGroup.mk : G → G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := + NilpotentLieBCHGroup.contMDiff_quotient_mk (e.baseChange ℝ) (lieStructureConstants e) + (fun i j k => (realLieBasis_structure e i j k).symm) hc + (Γ.map NilpotentLieBCHGroup.realificationHom) l hl + (NilpotentLieBCHGroup.realification_subgroup_grid e Γ l houter) n + +theorem contMDiff_realification_quotient_iff + {E' N : Type*} [NormedAddCommGroup E'] [NormedSpace ℝ E'] + [TopologicalSpace N] [ChartedSpace E' N] (n : ℕ∞ω) + (F : (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) → N) : + letI := NilpotentLieBCHGroup.basisChartedSpace + (hnil := realification_lowerCentralSeries_eq_bot hnil) (e.baseChange ℝ) + letI := realificationQuotientChartedSpace e Γ l hl houter hc + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, E') n F ↔ + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, E') n (fun g : G => F (QuotientGroup.mk g)) := + NilpotentLieBCHGroup.contMDiff_quotient_iff (e.baseChange ℝ) (lieStructureConstants e) + (fun i j k => (realLieBasis_structure e i j k).symm) hc + (Γ.map NilpotentLieBCHGroup.realificationHom) l hl + (NilpotentLieBCHGroup.realification_subgroup_grid e Γ l houter) n F + +theorem realification_quotient_chart_mem_maximalAtlas + (z : G) (φ : OpenPartialHomeomorph (ι → ℝ) (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom)) + (hφ : ∀ v, φ v = QuotientGroup.mk (z * (NilpotentLieBCHGroup.basisHomeomorph (e.baseChange ℝ)).symm v)) + (n : ℕ∞ω) : + letI := realificationQuotientChartedSpace e Γ l hl houter hc + φ.symm ∈ IsManifold.maximalAtlas 𝓘(ℝ, ι → ℝ) n (G ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) := + NilpotentLieBCHGroup.quotient_chart_mem_maximalAtlas (e.baseChange ℝ) (lieStructureConstants e) + (fun i j k => (realLieBasis_structure e i j k).symm) hc + (Γ.map NilpotentLieBCHGroup.realificationHom) l hl + (NilpotentLieBCHGroup.realification_subgroup_grid e Γ l houter) z φ hφ n + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped TensorProduct Manifold ContDiff + +variable {ι κ L M : Type*} [Fintype ι] [Fintype κ] + [LieRing L] [LieAlgebra ℚ L] [LieRing M] [LieAlgebra ℚ M] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + [TopologicalSpace (ℝ ⊗[ℚ] M)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] M)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M)] [T2Space (ℝ ⊗[ℚ] M)] + {s H₁ H₂ : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + {hM : LieModule.lowerCentralSeries ℚ M M s = ⊥} + +theorem contMDiff_realificationMap_quotient + (e : Basis ι ℚ L) (f : Basis κ ℚ M) (φ : L →ₗ⁅ℚ⁆ M) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (Λ : Subgroup (NilpotentLieBCHGroup M s hM)) + (hφ : Γ ≤ Λ.comap (map φ)) (l m : ℕ) (hl : 0 < l) (hm : 0 < m) + (hΓ : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (hΛ : bchSubgroupCoordinates f Λ ⊆ denominatorGrid m) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H₁) + (hc' : ∀ i j k, RationalHeightLE (lieStructureConstants f i j k) H₂) (n : ℕ∞ω) : + letI := realificationQuotientChartedSpace e Γ l hl hΓ hc + letI := realificationQuotientChartedSpace f Λ m hm hΛ hc' + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, κ → ℝ) n + (cosetMap (Γ.map realificationHom) (Λ.map realificationHom) + (realificationMap (hnil := hnil) (hM := hM) φ) (realificationMap_subgroup φ Γ Λ hφ)) := by + let := basisChartedSpace (hnil := realification_lowerCentralSeries_eq_bot hnil) (e.baseChange ℝ) + let := basisChartedSpace (hnil := realification_lowerCentralSeries_eq_bot hM) (f.baseChange ℝ) + let := realificationQuotientChartedSpace e Γ l hl hΓ hc + let := realificationQuotientChartedSpace f Λ m hm hΛ hc' + apply (contMDiff_realification_quotient_iff e Γ l hl hΓ hc n _).mpr + exact (contMDiff_realification_quotient_mk f Λ m hm hΛ hc' n).comp + (contMDiff_mapReal (e.baseChange ℝ) (f.baseChange ℝ) (realificationLieHom φ) n) + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct Manifold ContDiff + +theorem realification_filtered_nilmanifold + {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] {s H : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (F : NilpotentLieFiltration L s) (e : Basis ι ℚ L) (Γ : Subgroup F.Group) + (l : ℕ) (hl : 0 < l) (hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) : + letI := NilpotentLieBCHGroup.basisChartedSpace + (hnil := F.realification.lowerCentralSeries_eq_bot) (e.baseChange ℝ) + letI := realificationQuotientChartedSpace e Γ l hl houter hc + let G := F.realification.Group + let ΓR : Subgroup G := Γ.map NilpotentLieBCHGroup.realificationHom + LieGroup 𝓘(ℝ, ι → ℝ) ω G ∧ ConnectedSpace G ∧ SimplyConnectedSpace G ∧ + Group.IsNilpotent G ∧ Group.nilpotencyClass G ≤ s ∧ + IsClosed (ΓR : Set G) ∧ IsDiscrete (ΓR : Set G) ∧ CompactSpace (G ⧸ ΓR) ∧ + IsManifold 𝓘(ℝ, ι → ℝ) ω (G ⧸ ΓR) ∧ + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) ω (QuotientGroup.mk : G → G ⧸ ΓR) ∧ + F.realification.subgroup 1 = ⊤ ∧ F.realification.subgroup (s + 1) = ⊥ ∧ + Antitone F.realification.subgroup ∧ + (∀ i j (a b : G), a ∈ F.realification.subgroup i → b ∈ F.realification.subgroup j → + a * b * a⁻¹ * b⁻¹ ∈ F.realification.subgroup (i + j)) ∧ + ∀ i, IsClosed (F.realification.subgroup i : Set G) ∧ (F.realification.subgroup i).Normal ∧ + ConnectedSpace (F.realification.subgroup i) ∧ SimplyConnectedSpace (F.realification.subgroup i) ∧ + let Λ := ΓR.comap (F.realification.subgroup i).subtype + IsClosed (Λ : Set (F.realification.subgroup i)) ∧ IsDiscrete (Λ : Set (F.realification.subgroup i)) ∧ + CompactSpace (F.realification.subgroup i ⧸ Λ) := by + let : FiniteDimensional ℚ L := e.finiteDimensional_of_finite + let := NilpotentLieBCHGroup.basisChartedSpace + (hnil := F.realification.lowerCentralSeries_eq_bot) (e.baseChange ℝ) + let := realificationQuotientChartedSpace e Γ l hl houter hc + have hlattice := NilpotentLieBCHGroup.realification_subgroup_closed_discrete e Γ l hl houter + refine ⟨NilpotentLieBCHGroup.lieGroup_basis (e.baseChange ℝ) ω, inferInstance, inferInstance, + F.realification.isNilpotentGroup, F.realification.nilpotencyClass_le, hlattice.1, hlattice.2, + compactSpace_realification_quotient e Γ l hl hinner, + isManifold_realification_quotient e Γ l hl houter hc ω, + contMDiff_realification_quotient_mk e Γ l hl houter hc ω, + F.realification.subgroup_one, F.realification.subgroup_terminal, ?_, ?_, ?_⟩ + · intro i j hij g hg + exact F.realification.antitone hij hg + · intro i j a b ha hb + exact F.realification.commutator_mem ha hb + · intro i + have hconn := F.realification_subgroup_connected_simplyConnected i + have hdisc := F.realification_layer_lattice_closed_discrete e Γ l hl houter i + exact ⟨F.realification_subgroup_closed i, F.realification.subgroup_normal i, + hconn.1, hconn.2, hdisc.1, hdisc.2, F.realification_layer_lattice_cocompact e Γ l hl hinner houter i⟩ + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +variable (L : Type*) [LieRing L] [LieAlgebra ℚ L] + +structure RationalFilteredNilmanifold (s d : ℕ) where + filtration : NilpotentLieFiltration L s + basis : Basis (Fin d) ℚ L + layerBasis : ∀ i : Fin (s + 1), + Basis (Fin (Module.finrank ℚ (filtration.layer (i.val + 1)))) ℚ (filtration.layer (i.val + 1)) + lattice : Subgroup filtration.Group + grid : ℕ + grid_pos : 0 < grid + inner_grid : scaledIntegerGrid grid ⊆ bchSubgroupCoordinates basis lattice + outer_grid : bchSubgroupCoordinates basis lattice ⊆ denominatorGrid grid + +noncomputable def rationalLogHeight (q : ℚ) : ℝ := + Real.log (max (q.num.natAbs : ℝ) (q.den : ℝ)) + +namespace RationalFilteredNilmanifold + +variable {L} {s d : ℕ} (D : RationalFilteredNilmanifold L s d) + +abbrev RealGroup := D.filtration.realification.Group + +noncomputable def realLattice : Subgroup D.RealGroup := + D.lattice.map NilpotentLieBCHGroup.realificationHom + +abbrev Space : Type _ := D.RealGroup ⧸ D.realLattice + +def GeometryComplexityLE (p : ℝ) : Prop := + (d : ℝ) ≤ p ∧ (D.grid : ℝ) ≤ Real.exp p ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants D.basis i j k) ≤ p) ∧ + (∀ i j k, rationalLogHeight (D.basis.repr (D.layerBasis i j) k) ≤ p) + +theorem GeometryComplexityLE.mono {p q : ℝ} (hp : D.GeometryComplexityLE p) (hpq : p ≤ q) : + D.GeometryComplexityLE q := + ⟨hp.1.trans hpq, hp.2.1.trans (Real.exp_le_exp.mpr hpq), + fun i j k => (hp.2.2.1 i j k).trans hpq, + fun i j k => (hp.2.2.2 i j k).trans hpq⟩ + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +@[instance_reducible] +noncomputable def metricSpace : MetricSpace D.Space := + realificationQuotientMetricSpace D.basis D.lattice D.grid D.grid_pos D.outer_grid + +theorem space_compact : CompactSpace D.Space := + compactSpace_realification_quotient D.basis D.lattice D.grid D.grid_pos D.inner_grid + +theorem realLattice_closed_discrete : + IsClosed (D.realLattice : Set D.RealGroup) ∧ IsDiscrete (D.realLattice : Set D.RealGroup) := + NilpotentLieBCHGroup.realification_subgroup_closed_discrete + D.basis D.lattice D.grid D.grid_pos D.outer_grid + +omit [T2Space (ℝ ⊗[ℚ] L)] in +theorem layer_lattice_cocompact (i : ℕ) : + CompactSpace (D.filtration.realification.subgroup i ⧸ + D.realLattice.comap (D.filtration.realification.subgroup i).subtype) := + D.filtration.realification_layer_lattice_cocompact + D.basis D.lattice D.grid D.grid_pos D.inner_grid D.outer_grid i + +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L (s + 1) d) (hD : D.filtration.layer (s + 1) = ⊥) + +noncomputable def dropTop : RationalFilteredNilmanifold L s d where + filtration := D.filtration.dropTop hD + basis := D.basis + layerBasis i := D.layerBasis ⟨i.val, by omega⟩ + lattice := D.lattice.map (NilpotentLieBCHGroup.changeStep D.filtration.lowerCentralSeries_eq_bot + (D.filtration.dropTop hD).lowerCentralSeries_eq_bot).toMonoidHom + grid := D.grid + grid_pos := D.grid_pos + inner_grid := by + rw [bchSubgroupCoordinates_changeStep] + exact D.inner_grid + outer_grid := by + rw [bchSubgroupCoordinates_changeStep] + exact D.outer_grid + +theorem dropTop_geometry {p : ℝ} (hp : D.GeometryComplexityLE p) : + (D.dropTop hD).GeometryComplexityLE p := + ⟨hp.1, hp.2.1, hp.2.2.1, fun i j k => hp.2.2.2 ⟨i.val, by omega⟩ j k⟩ + +theorem dropTop_lattice_back : + (D.dropTop hD).lattice ≤ D.lattice.comap + (NilpotentLieBCHGroup.mapOfSteps + (hL := (D.filtration.dropTop hD).lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L)) := by + intro g hg + obtain ⟨x, hx, rfl⟩ := Subgroup.mem_map.mp hg + exact hx + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s d) + +structure Niltest (w : σ → ℕ) where + orbit : D.filtration.realification.PolynomialOrbit w + observable : D.Space → ℂ + normBound : ℝ≥0 + lipBound : ℝ≥0 + norm_le : ∀ x, ‖observable x‖ ≤ normBound + lipschitz : letI := D.metricSpace; LipschitzWith lipBound observable + +namespace Niltest + +variable {D} {w : σ → ℕ} + +noncomputable def const (D : RationalFilteredNilmanifold L s d) (w : σ → ℕ) (c : ℂ) : + D.Niltest w where + orbit := 1 + observable := fun _ => c + normBound := ‖c‖₊ + lipBound := 0 + norm_le _ := le_rfl + lipschitz := by + let := D.metricSpace + exact LipschitzWith.const c + +noncomputable def eval (T : D.Niltest w) (x : σ → ℤ) : ℂ := + T.observable (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x T.orbit)) + +@[simp] theorem eval_const (D : RationalFilteredNilmanifold L s d) + (w : σ → ℕ) (c : ℂ) (x : σ → ℤ) : (const D w c).eval x = c := rfl + +theorem norm_eval_le (T : D.Niltest w) (x : σ → ℤ) : ‖T.eval x‖ ≤ T.normBound := + T.norm_le _ + +noncomputable def evalCyclic (T : D.Niltest w) (N : ℕ) [NeZero N] (x : σ → ZMod N) : ℂ := + T.eval (fun i => ((x i).val : ℤ)) + +theorem evalCyclic_natCast (T : D.Niltest w) (N : ℕ) [NeZero N] + (x : σ → ℕ) (hx : ∀ i, x i < N) : + T.evalCyclic N (fun i => (x i : ZMod N)) = T.eval (fun i => (x i : ℤ)) := by + simp only [evalCyclic, ZMod.val_natCast_of_lt (hx _)] + +theorem norm_evalCyclic_le (T : D.Niltest w) (N : ℕ) [NeZero N] (x : σ → ZMod N) : + ‖T.evalCyclic N x‖ ≤ T.normBound := T.norm_eval_le _ + +def ComplexityLE (T : D.Niltest w) (p : ℝ) : Prop := + D.GeometryComplexityLE p ∧ Real.log (2 + (T.normBound : ℝ) + (T.lipBound : ℝ)) ≤ p + +theorem ComplexityLE.mono {T : D.Niltest w} {p q : ℝ} + (hp : T.ComplexityLE p) (hpq : p ≤ q) : T.ComplexityLE q := + ⟨GeometryComplexityLE.mono D hp.1 hpq, hp.2.trans hpq⟩ + +theorem observable_budget {T : D.Niltest w} {p : ℝ} (hp : T.ComplexityLE p) : + 2 + (T.normBound : ℝ) + (T.lipBound : ℝ) ≤ Real.exp p := by + have hpos : 0 < 2 + (T.normBound : ℝ) + (T.lipBound : ℝ) := by positivity + simpa only [Real.exp_log hpos] using Real.exp_le_exp.mpr hp.2 + +theorem eval_budget {T : D.Niltest w} {p : ℝ} (hp : T.ComplexityLE p) (x : σ → ℤ) : + ‖T.eval x‖ ≤ Real.exp p := by + have h := observable_budget hp + have hn := T.norm_eval_le x + have hl := T.lipBound.coe_nonneg + linarith + +theorem eval_step_zero (D : RationalFilteredNilmanifold L 0 d) + (T : D.Niltest w) (x : σ → ℤ) : + T.eval x = T.observable (QuotientGroup.mk (1 : D.RealGroup)) := by + unfold eval + rw [NilpotentLieFiltration.polynomialOrbitEval_step_zero] + +theorem eval_dimension_zero (D : RationalFilteredNilmanifold L s 0) + (T : D.Niltest w) (x : σ → ℤ) : + T.eval x = T.observable (QuotientGroup.mk (1 : D.RealGroup)) := by + have hz (g : D.RealGroup) : g = 1 := by + apply NilpotentLieBCHGroup.ext + apply (D.basis.baseChange ℝ).repr.injective + ext i + exact Fin.elim0 i + exact congrArg (fun g : D.RealGroup => T.observable (QuotientGroup.mk g)) (hz _) + +end Niltest +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s t d : ℕ} + (D : RationalFilteredNilmanifold L s d) (hst : s ≤ t) + +noncomputable def raisedLayerBasis (i : Fin (t + 1)) : + Basis (Fin (Module.finrank ℚ ((D.filtration.raiseStep hst).layer (i.val + 1)))) ℚ + ((D.filtration.raiseStep hst).layer (i.val + 1)) := by + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + exact if hi : i.val < s + 1 then D.layerBasis ⟨i.val, hi⟩ else + Module.finBasis ℚ ((D.filtration.raiseStep hst).layer (i.val + 1)) + +theorem raisedLayerBasis_of_lt (i : Fin (t + 1)) (hi : i.val < s + 1) : + D.raisedLayerBasis hst i = D.layerBasis ⟨i.val, hi⟩ := by + simp [raisedLayerBasis, hi] + rfl + +noncomputable def raiseStep : RationalFilteredNilmanifold L t d where + filtration := D.filtration.raiseStep hst + basis := D.basis + layerBasis := D.raisedLayerBasis hst + lattice := D.lattice.map (NilpotentLieBCHGroup.changeStep D.filtration.lowerCentralSeries_eq_bot + (D.filtration.raiseStep hst).lowerCentralSeries_eq_bot).toMonoidHom + grid := D.grid + grid_pos := D.grid_pos + inner_grid := by + rw [bchSubgroupCoordinates_changeStep] + exact D.inner_grid + outer_grid := by + rw [bchSubgroupCoordinates_changeStep] + exact D.outer_grid + +theorem raiseStep_geometry {p : ℝ} (hD : D.GeometryComplexityLE p) : + (D.raiseStep hst).GeometryComplexityLE p := by + refine ⟨hD.1, hD.2.1, hD.2.2.1, ?_⟩ + intro i j k + by_cases hi : i.val < s + 1 + · change rationalLogHeight (D.basis.repr (D.raisedLayerBasis hst i j) k) ≤ p + rw [D.raisedLayerBasis_of_lt hst i hi] + exact hD.2.2.2 ⟨i.val, hi⟩ j k + · have hbot : D.filtration.layer (i.val + 1) = ⊥ := + D.filtration.layer_eq_bot_above_step (by omega) + have hrank : Module.finrank ℚ ((D.filtration.raiseStep hst).layer (i.val + 1)) = 0 := by + rw [NilpotentLieFiltration.raiseStep_layer, hbot] + simp + have hj := j.isLt + change j.val < Module.finrank ℚ ((D.filtration.raiseStep hst).layer (i.val + 1)) at hj + rw [hrank] at hj + omega + +theorem raiseStep_lattice_back : + (D.raiseStep hst).lattice ≤ D.lattice.comap + (NilpotentLieBCHGroup.mapOfSteps + (hL := (D.filtration.raiseStep hst).lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L)) := by + intro g hg + obtain ⟨x, hx, rfl⟩ := Subgroup.mem_map.mp hg + exact hx + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +open Module +open scoped BigOperators + +namespace Erdos3 + +namespace NilpotentLieFiltration + +variable {ι : Type*} {L : ι → Type*} [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} + +def piLayerEquiv (F : ∀ i, NilpotentLieFiltration (L i) s) (n : ℕ) : + (∀ i, (F i).layer n) ≃ₗ[ℚ] (pi F).layer n where + toFun x := ⟨fun i => x i, (mem_pi_layer F n _).mpr (fun i => (x i).property)⟩ + invFun x i := ⟨x.val i, (mem_pi_layer F n _).mp x.property i⟩ + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl + +end NilpotentLieFiltration + +namespace RationalFilteredNilmanifold + +variable {ι : Type*} [Fintype ι] {L : ι → Type*} + [∀ i, LieRing (L i)] [∀ i, LieAlgebra ℚ (L i)] {s : ℕ} {d : ι → ℕ} + (D : ∀ i, RationalFilteredNilmanifold (L i) s (d i)) + +noncomputable def productFinBasis : Basis (Fin (Fintype.card (Σ i, Fin (d i)))) ℚ (∀ i, L i) := + (Pi.basis (fun i => (D i).basis)).reindex (Fintype.equivFin _) + +noncomputable def productLayerBasis (j : Fin (s + 1)) : + Basis (Σ i, Fin (finrank ℚ ((D i).filtration.layer (j.val + 1)))) ℚ + ((NilpotentLieFiltration.pi (fun i => (D i).filtration)).layer (j.val + 1)) := + (Pi.basis (fun i => (D i).layerBasis j)).map + (NilpotentLieFiltration.piLayerEquiv (fun i => (D i).filtration) (j.val + 1)) + +noncomputable def productLayerFinBasis (j : Fin (s + 1)) : + Basis (Fin (finrank ℚ ((NilpotentLieFiltration.pi (fun i => (D i).filtration)).layer (j.val + 1)))) ℚ + ((NilpotentLieFiltration.pi (fun i => (D i).filtration)).layer (j.val + 1)) := + (productLayerBasis D j).reindex (Fintype.equivFinOfCardEq (finrank_eq_card_basis (productLayerBasis D j)).symm) + +theorem product_inner_grid : scaledIntegerGrid (∏ i, (D i).grid) ⊆ + bchSubgroupCoordinates (productFinBasis D) + (piBCHSubgroup (fun i => (D i).filtration) (fun i => (D i).lattice)) := by + classical + apply bchSubgroup_inner_grid_reindex + apply piBCHSubgroup_inner_grid + intro i + exact (scaledIntegerGrid_subset_of_dvd (Finset.dvd_prod_of_mem _ (Finset.mem_univ i))).trans (D i).inner_grid + +theorem product_outer_grid : + bchSubgroupCoordinates (productFinBasis D) + (piBCHSubgroup (fun i => (D i).filtration) (fun i => (D i).lattice)) ⊆ + denominatorGrid (∏ i, (D i).grid) := by + classical + apply bchSubgroup_outer_grid_reindex + apply piBCHSubgroup_outer_grid + intro i + exact (D i).outer_grid.trans (denominatorGrid_subset_of_dvd (Finset.dvd_prod_of_mem _ (Finset.mem_univ i))) + +noncomputable def pi : RationalFilteredNilmanifold (∀ i, L i) s (Fintype.card (Σ i, Fin (d i))) where + filtration := NilpotentLieFiltration.pi (fun i => (D i).filtration) + basis := productFinBasis D + layerBasis := productLayerFinBasis D + lattice := piBCHSubgroup (fun i => (D i).filtration) (fun i => (D i).lattice) + grid := ∏ i, (D i).grid + grid_pos := Finset.prod_pos (fun i _ => (D i).grid_pos) + inner_grid := product_inner_grid D + outer_grid := product_outer_grid D + +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def normalizeBasepoint (T : D.Niltest w) (a γ : D.RealGroup) (A : ℝ≥0) + (hA : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => a • x)) : D.Niltest w where + orbit := D.filtration.realification.normalizePolynomialOrbit w T.orbit a γ + observable := fun x => T.observable (a • x) + normBound := T.normBound + lipBound := T.lipBound * A + norm_le x := T.norm_le (a • x) + lipschitz := by + let := D.metricSpace + exact T.lipschitz.comp hA + +theorem normalizeBasepoint_normBound (T : D.Niltest w) (a γ : D.RealGroup) (A : ℝ≥0) + (hA : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => a • x)) : + (T.normalizeBasepoint a γ A hA).normBound = T.normBound := rfl + +theorem normalizeBasepoint_zero (T : D.Niltest w) (a γ : D.RealGroup) (A : ℝ≥0) + (hA : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => a • x)) + (hg : D.filtration.realification.polynomialOrbitEval w 0 T.orbit = a * γ) : + D.filtration.realification.polynomialOrbitEval w 0 (T.normalizeBasepoint a γ A hA).orbit = 1 := + D.filtration.realification.normalizePolynomialOrbit_zero w T.orbit a γ hg + +theorem normalizeBasepoint_eval (T : D.Niltest w) (a γ : D.RealGroup) (A : ℝ≥0) + (hA : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => a • x)) + (hγ : γ ∈ D.realLattice) (x : σ → ℤ) : + (T.normalizeBasepoint a γ A hA).eval x = T.eval x := by + change T.observable (a • QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval w x + (D.filtration.realification.normalizePolynomialOrbit w T.orbit a γ))) = _ + rw [NilpotentLieFiltration.normalizePolynomialOrbit_eval] + simp only [MulAction.Quotient.smul_mk, smul_eq_mul, ← mul_assoc, mul_inv_cancel, one_mul] + exact congrArg T.observable (QuotientGroup.mk_mul_of_mem _ (D.realLattice.inv_mem hγ)) + +theorem normalizeBasepoint_evalCyclic (T : D.Niltest w) (a γ : D.RealGroup) (A : ℝ≥0) + (hA : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => a • x)) + (hγ : γ ∈ D.realLattice) (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (T.normalizeBasepoint a γ A hA).evalCyclic N x = T.evalCyclic N x := + T.normalizeBasepoint_eval a γ A hA hγ _ + +theorem normalizeBasepoint_complexity (T : D.Niltest w) (a γ : D.RealGroup) (A : ℝ≥0) + (hA : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => a • x)) + {p q : ℝ} (hT : T.ComplexityLE p) (hq : 0 ≤ q) (hbound : (A : ℝ) ≤ Real.exp q) : + (T.normalizeBasepoint a γ A hA).ComplexityLE (p + q) := by + refine ⟨hT.1.mono D (le_add_of_nonneg_right hq), ?_⟩ + change Real.log (2 + (T.normBound : ℝ) + (T.lipBound : ℝ) * A) ≤ p + q + apply (Real.log_le_iff_le_exp (by positivity)).mpr + have h1 : 1 ≤ Real.exp q := Real.one_le_exp hq + calc + _ ≤ (2 + (T.normBound : ℝ)) * Real.exp q + (T.lipBound : ℝ) * Real.exp q := + add_le_add (le_mul_of_one_le_right (by positivity) h1) + (mul_le_mul_of_nonneg_left hbound T.lipBound.coe_nonneg) + _ = (2 + (T.normBound : ℝ) + (T.lipBound : ℝ)) * Real.exp q := by ring + _ ≤ Real.exp p * Real.exp q := mul_le_mul_of_nonneg_right (observable_budget hT) (Real.exp_nonneg _) + _ = _ := (Real.exp_add _ _).symm + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestComplement.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f1fb0f3fd79c240ca8825d6c6238e9f05105830 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestComplement.lean @@ -0,0 +1,458 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeEquivalenceTransitivity + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem realificationLieHom_id_apply {L : Type*} [LieRing L] [LieAlgebra ℚ L] + (x : ℝ ⊗[ℚ] L) : realificationLieHom (LieHom.id : L →ₗ⁅ℚ⁆ L) x = x := by + induction x using TensorProduct.inductionOn with + | tmul r x => rfl + | add x y hx hy => simp only [map_add, hx, hy] + +namespace RationalFilteredNilmanifold + +open Module +open scoped NNReal + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s t d : ℕ} + (D : RationalFilteredNilmanifold L s d) (hst : s ≤ t) + +noncomputable def raiseStepProjection : (D.raiseStep hst).Space → D.Space := + cosetMap (D.raiseStep hst).realLattice D.realLattice + (NilpotentLieBCHGroup.realificationMap + (hnil := (D.raiseStep hst).filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L)) + (NilpotentLieBCHGroup.realificationMap_subgroup (LieHom.id : L →ₗ⁅ℚ⁆ L) + (D.raiseStep hst).lattice D.lattice (D.raiseStep_lattice_back hst)) + +theorem raiseStepProjection_mk (x : (D.raiseStep hst).RealGroup) : + D.raiseStepProjection hst (QuotientGroup.mk x) = + QuotientGroup.mk (NilpotentLieBCHGroup.realificationMap + (hnil := (D.raiseStep hst).filtration.lowerCentralSeries_eq_bot) + (hM := D.filtration.lowerCentralSeries_eq_bot) (LieHom.id : L →ₗ⁅ℚ⁆ L) x) := rfl + +section Metric + +variable [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem raiseStepProjection_lipschitz : + let := (D.raiseStep hst).metricSpace + let := D.metricSpace + LipschitzWith (coordinateLipschitzBound d d 1) (D.raiseStepProjection hst) := by + let := realificationQuotientMetricSpace (D.raiseStep hst).basis (D.raiseStep hst).lattice + (D.raiseStep hst).grid (D.raiseStep hst).grid_pos (D.raiseStep hst).outer_grid + let := realificationQuotientMetricSpace D.basis D.lattice D.grid D.grid_pos D.outer_grid + have hentry (k i : Fin d) : + RationalHeightLE (D.basis.repr ((LieHom.id : L →ₗ⁅ℚ⁆ L) ((D.raiseStep hst).basis i)) k) 1 := by + change RationalHeightLE (D.basis.repr (D.basis i) k) 1 + rw [Basis.repr_self] + by_cases h : i = k <;> simp [h, RationalHeightLE] + have h := NilpotentLieBCHGroup.lipschitz_realificationMap_quotient + (D.raiseStep hst).basis D.basis (LieHom.id : L →ₗ⁅ℚ⁆ L) + (D.raiseStep hst).lattice D.lattice (D.raiseStep_lattice_back hst) + (D.raiseStep hst).grid D.grid (D.raiseStep hst).grid_pos D.grid_pos + (D.raiseStep hst).outer_grid D.outer_grid 1 hentry + exact h.weaken (by simp only [Fintype.card_fin, Nat.cast_one, le_refl]) + +end Metric + +noncomputable def raiseStepRealOrbit {σ : Type*} {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) : + (D.raiseStep hst).filtration.realification.PolynomialOrbit w := + NilpotentLieFiltration.polynomialOrbitOfLog g.log g.adapted + +theorem raiseStepRealOrbit_log {σ : Type*} {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) : + (D.raiseStepRealOrbit hst g).log = g.log := rfl + +theorem raiseStepProjection_orbit {σ : Type*} {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (x : σ → ℤ) : + D.raiseStepProjection hst (QuotientGroup.mk + ((D.raiseStep hst).filtration.realification.polynomialOrbitEval w x + (D.raiseStepRealOrbit hst g))) = + QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x g) := by + rw [D.raiseStepProjection_mk] + apply congrArg (QuotientGroup.mk : D.RealGroup → D.Space) + apply NilpotentLieBCHGroup.ext + change realificationLieHom (LieHom.id : L →ₗ⁅ℚ⁆ L) + (VectorPolynomial.eval (fun i => (x i : ℚ)) g.log) = + VectorPolynomial.eval (fun i => (x i : ℚ)) g.log + exact realificationLieHom_id_apply _ + +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +namespace Erdos3 + +def raisedNiltestBudget (p : ℝ) : ℝ := p + (p + 2) ^ 2 + 3 + +theorem le_raisedNiltestBudget (p : ℝ) : p ≤ raisedNiltestBudget p := by + unfold raisedNiltestBudget + nlinarith [sq_nonneg (p + 2)] + +namespace RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s t d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def raiseStep (T : D.Niltest w) (hst : s ≤ t) : (D.raiseStep hst).Niltest w where + orbit := D.raiseStepRealOrbit hst T.orbit + observable := fun z => T.observable (D.raiseStepProjection hst z) + normBound := T.normBound + lipBound := T.lipBound * coordinateLipschitzBound d d 1 + norm_le z := T.norm_le _ + lipschitz := by + let := (D.raiseStep hst).metricSpace + let := D.metricSpace + exact T.lipschitz.comp (D.raiseStepProjection_lipschitz hst) + +theorem raiseStep_eval (T : D.Niltest w) (hst : s ≤ t) (x : σ → ℤ) : + (T.raiseStep hst).eval x = T.eval x := by + change T.observable (D.raiseStepProjection hst (QuotientGroup.mk + ((D.raiseStep hst).filtration.realification.polynomialOrbitEval w x + (D.raiseStepRealOrbit hst T.orbit)))) = T.eval x + rw [D.raiseStepProjection_orbit] + rfl + +theorem raiseStep_evalCyclic (T : D.Niltest w) (hst : s ≤ t) + (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (T.raiseStep hst).evalCyclic N x = T.evalCyclic N x := + T.raiseStep_eval hst _ + +theorem raiseStep_unit_interval (T : D.Niltest w) (hst : s ≤ t) (hT : T.UnitIntervalValued) : + (T.raiseStep hst).UnitIntervalValued := fun z => hT (D.raiseStepProjection hst z) + +theorem raiseStep_complexity (T : D.Niltest w) (hst : s ≤ t) {p : ℝ} + (hp : 0 ≤ p) (hT : T.ComplexityLE p) : + (T.raiseStep hst).ComplexityLE (raisedNiltestBudget p) := by + refine ⟨GeometryComplexityLE.mono (D.raiseStep hst) + (D.raiseStep_geometry hst hT.1) (le_raisedNiltestBudget p), ?_⟩ + have hraw := T.observable_budget hT + have hn : (T.normBound : ℝ) ≤ Real.exp p := by linarith [T.lipBound.coe_nonneg] + have hl : (T.lipBound : ℝ) ≤ Real.exp p := by linarith [T.normBound.coe_nonneg] + have hK := coordinateLipschitzBound_le_exp d d 1 hp hT.1.1 hT.1.1 + (by simpa using Real.one_le_exp_iff.mpr hp) + have hn' : (T.normBound : ℝ) ≤ Real.exp (p + (p + 2) ^ 2) := + hn.trans (Real.exp_le_exp.mpr (by nlinarith [sq_nonneg (p + 2)])) + have hl' : (T.lipBound : ℝ) * (coordinateLipschitzBound d d 1 : ℝ) ≤ + Real.exp (p + (p + 2) ^ 2) := by + rw [Real.exp_add] + exact mul_le_mul hl hK (by positivity) (Real.exp_nonneg _) + have hone : 1 ≤ Real.exp (p + (p + 2) ^ 2) := Real.one_le_exp_iff.mpr (by positivity) + have hfour : (4 : ℝ) ≤ Real.exp 3 := by linarith [Real.add_one_le_exp (3 : ℝ)] + have hsum : 2 + (T.normBound : ℝ) + + (T.lipBound : ℝ) * (coordinateLipschitzBound d d 1 : ℝ) ≤ + Real.exp (raisedNiltestBudget p) := by + calc + _ ≤ 4 * Real.exp (p + (p + 2) ^ 2) := by linarith + _ ≤ Real.exp 3 * Real.exp (p + (p + 2) ^ 2) := + mul_le_mul_of_nonneg_right hfour (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; unfold raisedNiltestBudget; ring + change Real.log (2 + (T.normBound : ℝ) + + (T.lipBound : ℝ) * (coordinateLipschitzBound d d 1 : ℝ)) ≤ raisedNiltestBudget p + exact (Real.log_le_iff_le_exp (by positivity)).mpr hsum + +end RationalFilteredNilmanifold.Niltest +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s t d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem raiseStep_top_vertical (T : D.Niltest w) (hst : s < t) + (z : (D.raiseStep hst.le).RealGroup) + (hz : z ∈ (D.raiseStep hst.le).filtration.realification.subgroup t) + (x : (D.raiseStep hst.le).Space) : + (T.raiseStep hst.le).observable (z • x) = + CircleFourier.character + ((realifyFunctional (0 : L →ₗ[ℚ] ℚ) z.coord : ℝ) : CircleFourier.Circle) * + (T.raiseStep hst.le).observable x := by + have hz' : z = 1 := by + apply NilpotentLieBCHGroup.ext + change z.coord = 0 + change z.coord ∈ D.filtration.realification.layer t at hz + simpa only [D.filtration.realification.layer_eq_bot_above_step hst, + Submodule.mem_bot] using hz + subst z + simp + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s t n : ℕ} + +theorem raiseStep_top_subgroup_eq_bot (D : RationalFilteredNilmanifold L s n) + (hst : s < t) : + (D.raiseStep hst.le).filtration.realification.subgroup t = ⊥ := by + apply le_antisymm ?_ bot_le + intro z hz + change z = 1 + apply NilpotentLieBCHGroup.ext + change z.coord = 0 + change z.coord ∈ D.filtration.realification.layer t at hz + simpa only [D.filtration.realification.layer_eq_bot_above_step hst, + Submodule.mem_bot] using hz + +theorem raiseStep_observable_top_vertical (D : RationalFilteredNilmanifold L s n) + (hst : s < t) (f : (D.raiseStep hst.le).Space → ℂ) + (z : (D.raiseStep hst.le).RealGroup) + (hz : z ∈ (D.raiseStep hst.le).filtration.realification.subgroup t) + (x : (D.raiseStep hst.le).Space) : + f (z • x) = + CircleFourier.character + ((realifyFunctional (0 : L →ₗ[ℚ] ℚ) z.coord : ℝ) : CircleFourier.Circle) * f x := by + have hz' : z = 1 := by + simpa only [raiseStep_top_subgroup_eq_bot D hst, Subgroup.mem_bot] using hz + subst z + simp + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct + +universe u + +theorem cyclic_upperComparison_mul_niltest + {degree low N : ℕ} [NeZero N] {P R error : ℝ} + (f g : ZMod N → ℝ) (hcompare : CyclicNiltestUpperComparison.{u} degree N P error f g) + (hlow : low ≤ degree) (hR : 0 ≤ R) + (hBudget : productNiltestBudget (raisedNiltestBudget R) ≤ P) + {L₁ : Type u} [lie₁ : LieRing L₁] [alg₁ : LieAlgebra ℚ L₁] {s₁ dim₁ : ℕ} + [top₁ : TopologicalSpace (ℝ ⊗[ℚ] L₁)] [add₁ : IsTopologicalAddGroup (ℝ ⊗[ℚ] L₁)] + [smul₁ : ContinuousSMul ℝ (ℝ ⊗[ℚ] L₁)] [t2₁ : T2Space (ℝ ⊗[ℚ] L₁)] + (D₁ : RationalFilteredNilmanifold L₁ s₁ dim₁) (hs₁ : s₁ ≤ degree) + (A : D₁.Niltest (fun _ : Unit => 1)) (hA : A.UnitIntervalValued) (hAc : A.ComplexityLE R) : + CyclicNiltestUpperComparison.{u} low N R error + (fun x => f x * (A.evalCyclic N (fun _ => x)).re) + (fun x => g x * (A.evalCyclic N (fun _ => x)).re) := by + intro L₂ lie₂ alg₂ s₂ dim₂ top₂ add₂ smul₂ t2₂ D₂ hs₂ T hT hTc + let K : Bool → Type u := BoolLieFamily L₁ L₂ + let dims : Bool → ℕ := fun b => Bool.rec dim₂ dim₁ b + let D : ∀ b, RationalFilteredNilmanifold (K b) degree (dims b) := fun b => by + cases b + · exact D₂.raiseStep (hs₂.trans hlow) + · exact D₁.raiseStep hs₁ + let U : ∀ b, (D b).Niltest (fun _ : Unit => 1) := fun b => by + cases b + · exact T.raiseStep (hs₂.trans hlow) + · exact A.raiseStep hs₁ + have hUc : ∀ b, (U b).ComplexityLE (raisedNiltestBudget R) := by + intro b + cases b + · exact T.raiseStep_complexity (hs₂.trans hlow) hR hTc + · exact A.raiseStep_complexity hs₁ hR hAc + have hU : ∀ b, (U b).UnitIntervalValued := by + intro b + cases b + · exact T.raiseStep_unit_interval (hs₂.trans hlow) hT + · exact A.raiseStep_unit_interval hs₁ hA + have hR' : 0 ≤ raisedNiltestBudget R := hR.trans (le_raisedNiltestBudget R) + have hcard : (Fintype.card Bool : ℝ) ≤ raisedNiltestBudget R := by + norm_num only [Fintype.card_bool, Nat.cast_ofNat] + unfold raisedNiltestBudget + nlinarith [sq_nonneg (R + 2)] + let : FiniteDimensional ℚ (∀ b, K b) := + (RationalFilteredNilmanifold.productFinBasis D).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ b, K b)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ b, K b)) := IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (∀ b, K b)) := + realification_moduleTopology_t2 (RationalFilteredNilmanifold.productFinBasis D) + let S := RationalFilteredNilmanifold.piNiltest D U hR' hcard hUc + have hSc : S.ComplexityLE P := + (RationalFilteredNilmanifold.piNiltest_complexity D U hR' hcard hUc).mono hBudget + have hSu : S.UnitIntervalValued := + RationalFilteredNilmanifold.piNiltest_unit_interval D U hR' hcard hUc hU + have h := hcompare (RationalFilteredNilmanifold.pi D) le_rfl S hSu hSc + have heval (x : ZMod N) : S.evalCyclic N (fun _ : Unit => x) = + A.evalCyclic N (fun _ : Unit => x) * T.evalCyclic N (fun _ : Unit => x) := by + change (RationalFilteredNilmanifold.piNiltest D U hR' hcard hUc).eval + (fun _ : Unit => (x.val : ℤ)) = _ + rw [RationalFilteredNilmanifold.piNiltest_eval, Fintype.prod_bool] + change (A.raiseStep hs₁).eval (fun _ : Unit => (x.val : ℤ)) * + (T.raiseStep (hs₂.trans hlow)).eval (fun _ : Unit => (x.val : ℤ)) = _ + rw [RationalFilteredNilmanifold.Niltest.raiseStep_eval, + RationalFilteredNilmanifold.Niltest.raiseStep_eval] + rfl + convert h using 1 + apply Finset.expect_congr rfl + intro x _ + rw [heval, Complex.mul_re, (A.unit_interval_evalCyclic hA N (fun _ => x)).1, + (T.unit_interval_evalCyclic hT N (fun _ => x)).1] + ring + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators + +inductive PositiveCyclicNiltest.{u} (degree N : ℕ) [NeZero N] (p : ℝ) + (f : ZMod N → ℝ) : Prop where + | of_test {L : Type u} [LieRing L] [LieAlgebra ℚ L] {s dim : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (D : RationalFilteredNilmanifold L s dim) (hdegree : s ≤ degree) + (T : D.Niltest (fun _ : Unit => 1)) (hpositive : T.UnitIntervalValued) + (hcomplexity : T.ComplexityLE p) + (heval : ∀ x, f x = (T.evalCyclic N (fun _ => x)).re) : + PositiveCyclicNiltest degree N p f + +namespace PositiveCyclicNiltest + +universe u + +theorem unit_interval {degree N : ℕ} [NeZero N] {p : ℝ} {f : ZMod N → ℝ} + (hf : PositiveCyclicNiltest.{u} degree N p f) (x : ZMod N) : + 0 ≤ f x ∧ f x ≤ 1 := by + rcases hf with ⟨D, hs, T, hT, hTc, heval⟩ + rw [heval] + exact (T.unit_interval_evalCyclic hT N (fun _ => x)).2 + +theorem mono {degree degree' N : ℕ} [NeZero N] {p p' : ℝ} {f : ZMod N → ℝ} + (hf : PositiveCyclicNiltest.{u} degree N p f) (hdegree : degree ≤ degree') + (hp : p ≤ p') : PositiveCyclicNiltest.{u} degree' N p' f := by + rcases hf with ⟨D, hs, T, hT, hTc, heval⟩ + exact .of_test D (hs.trans hdegree) T hT (hTc.mono hp) heval + +theorem mul_upperComparison {degree low N : ℕ} [NeZero N] {P R error : ℝ} + {a f g : ZMod N → ℝ} (ha : PositiveCyclicNiltest.{u} degree N R a) + (hcompare : CyclicNiltestUpperComparison.{u} degree N P error f g) + (hlow : low ≤ degree) (hR : 0 ≤ R) + (hBudget : productNiltestBudget (raisedNiltestBudget R) ≤ P) : + CyclicNiltestUpperComparison.{u} low N R error + (fun x => f x * a x) (fun x => g x * a x) := by + rcases ha with @⟨L, lie, alg, s, dim, top, add, smul, t2, D, hs, T, hT, hTc, heval⟩ + have heq : a = fun x => (T.evalCyclic N (fun _ => x)).re := funext heval + rw [heq] + exact @cyclic_upperComparison_mul_niltest degree low N _ P R error + f g @hcompare hlow hR hBudget L lie alg s dim top add smul t2 D hs T hT hTc + +theorem apply_shiftBound {degree N : ℕ} [NeZero N] {p error : ℝ} + {a J c : ZMod N → ℝ} {E : Finset (ZMod N)} + (hc : PositiveCyclicNiltest.{u} degree N p c) + (hbound : CyclicNiltestShiftBound.{u} degree N p error a J E) + {h : ZMod N} (hh : h ∉ E) : + (𝔼 n, a n * J (n + h) * c n) ≤ error := by + rcases hc with ⟨D, hs, T, hT, hTc, heval⟩ + simp_rw [heval] + exact hbound h hh D hs T hT hTc + +end PositiveCyclicNiltest +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators NNReal + +universe u + +namespace RationalFilteredNilmanifold.Niltest + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def complement (T : D.Niltest w) : D.Niltest w where + orbit := T.orbit + observable := fun z => 1 - T.observable z + normBound := 1 + T.normBound + lipBound := T.lipBound + norm_le z := by + exact (norm_sub_le _ _).trans (by simpa using add_le_add_left (T.norm_le z) 1) + lipschitz := by + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + have he : (1 - T.observable x) - (1 - T.observable y) = + -(T.observable x - T.observable y) := by ring + rw [dist_eq_norm, he, norm_neg] + simpa only [dist_eq_norm] using T.lipschitz.dist_le_mul x y + +theorem complement_evalCyclic (T : D.Niltest w) (N : ℕ) [NeZero N] (x : σ → ZMod N) : + T.complement.evalCyclic N x = 1 - T.evalCyclic N x := rfl + +theorem complement_unitInterval (T : D.Niltest w) (hT : T.UnitIntervalValued) : + T.complement.UnitIntervalValued := by + intro z + have hz := hT z + change (1 - T.observable z).im = 0 ∧ 0 ≤ (1 - T.observable z).re ∧ + (1 - T.observable z).re ≤ 1 + simp only [Complex.sub_im, Complex.one_im, Complex.sub_re, Complex.one_re, hz.1] + exact ⟨by norm_num, by linarith [hz.2.2], by linarith [hz.2.1]⟩ + +theorem complement_complexity (T : D.Niltest w) {p : ℝ} + (hT : T.ComplexityLE p) : T.complement.ComplexityLE (p + 1) := by + refine ⟨hT.1.mono D (by linarith), ?_⟩ + change Real.log (2 + (1 + (T.normBound : ℝ)) + (T.lipBound : ℝ)) ≤ p + 1 + apply (Real.log_le_iff_le_exp (by positivity)).2 + rw [Real.exp_add] + have hcap := T.observable_budget hT + nlinarith [Real.add_one_le_exp (1 : ℝ), T.normBound.coe_nonneg, T.lipBound.coe_nonneg] + +end RationalFilteredNilmanifold.Niltest + +theorem PositiveCyclicNiltest.complement {degree N : ℕ} [NeZero N] {p : ℝ} + {f : ZMod N → ℝ} (hf : PositiveCyclicNiltest.{u} degree N p f) : + PositiveCyclicNiltest.{u} degree N (p + 1) (fun x => 1 - f x) := by + rcases hf with ⟨D, hs, T, hT, hTc, heval⟩ + refine .of_test D hs T.complement (T.complement_unitInterval hT) + (T.complement_complexity hTc) ?_ + intro x + rw [T.complement_evalCyclic, Complex.sub_re, Complex.one_re, heval] + +theorem CyclicNiltestUpperComparison.test_positive {degree N : ℕ} [NeZero N] + {P R error : ℝ} {f g a : ZMod N → ℝ} + (hcompare : CyclicNiltestUpperComparison.{u} degree N P error f g) + (ha : PositiveCyclicNiltest.{u} degree N R a) (hRP : R ≤ P) : + (𝔼 x, (f x - g x) * a x) ≤ error := by + rcases ha with ⟨D, hs, T, hT, hTc, heval⟩ + simpa only [heval] using hcompare D hs T hT (hTc.mono hRP) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestOrbitOne.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestOrbitOne.lean new file mode 100644 index 0000000000000000000000000000000000000000..90fa52d7d5e9d63408eef8e096108ecd9dc4030d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestOrbitOne.lean @@ -0,0 +1,49 @@ +import OAI.Combinatorics.Progressions.Fourier.BoundedFrequencyKernel + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def oneOnOrbit (T : D.Niltest w) : D.Niltest w where + orbit := T.orbit + observable := fun _ => 1 + normBound := 1 + lipBound := 0 + norm_le _ := by simp + lipschitz := by + let := D.metricSpace + exact LipschitzWith.const 1 + +theorem oneOnOrbit_orbit (T : D.Niltest w) : T.oneOnOrbit.orbit = T.orbit := rfl + +theorem oneOnOrbit_eval (T : D.Niltest w) (x : σ → ℤ) : T.oneOnOrbit.eval x = 1 := rfl + +theorem oneOnOrbit_complexity (T : D.Niltest w) {p : ℝ} (hp : 2 ≤ p) + (hD : D.GeometryComplexityLE p) : T.oneOnOrbit.ComplexityLE p := by + refine ⟨hD, ?_⟩ + change Real.log (2 + 1 + 0) ≤ p + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3) + norm_num at h ⊢ + linarith + +theorem oneOnOrbit_vertical (T : D.Niltest w) (z : D.RealGroup) (x : D.Space) : + T.oneOnOrbit.observable (z • x) = + CircleFourier.character ((realifyFunctional (0 : L →ₗ[ℚ] ℚ) z.coord : ℝ) : CircleFourier.Circle) * + T.oneOnOrbit.observable x := by + simp only [oneOnOrbit, realifyFunctional_zero, AddCircle.coe_zero, + CircleFourier.character_zero, mul_one] + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestProbabilityProjection.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestProbabilityProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..e44a89399a1695d785233fda554fc1fa4ffc3f57 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestProbabilityProjection.lean @@ -0,0 +1,332 @@ +import OAI.Combinatorics.Progressions.Linear.ExternalFamilyCircleProjection +import OAI.Combinatorics.Progressions.Linear.RationalKernelInvariance + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open CircleFourier +open scoped TensorProduct BigOperators NNReal + +variable {σ α L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +noncomputable def averageCircles (T : D.Niltest w) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) : D.Niltest w := by + let := D.metricSpace + exact { + orbit := T.orbit + observable := iteratedCircleAverage A is T.observable + normBound := T.normBound + lipBound := T.lipBound + norm_le := iteratedCircleAverage_norm_le A is T.norm_le + lipschitz := iteratedCircleAverage_lipschitz A is T.lipschitz } + +theorem averageCircles_orbit (T : D.Niltest w) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) : + (T.averageCircles A is).orbit = T.orbit := rfl + +theorem averageCircles_complexity (T : D.Niltest w) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + {p : ℝ} (hT : T.ComplexityLE p) : (T.averageCircles A is).ComplexityLE p := hT + +theorem averageCircles_unit_interval (T : D.Niltest w) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + (hT : T.UnitIntervalValued) : (T.averageCircles A is).UnitIntervalValued := by + let := D.metricSpace + exact iteratedCircleAverage_unit_interval A is T.lipschitz hT + +theorem averageCircles_invariant (T : D.Niltest w) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + (hcomm : let := D.metricSpace; ∀ i ∈ is, ∀ j ∈ is, (A i).Commutes (A j)) + (j : α) (hj : j ∈ is) (t : CircleFourier.Circle) (x : D.Space) : + let := D.metricSpace + (T.averageCircles A is).observable ((A j).act t x) = (T.averageCircles A is).observable x := by + let := D.metricSpace + exact iteratedCircleAverage_invariant A is hcomm T.observable j hj t x + +theorem averageCircles_evalCyclic (T : D.Niltest w) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (T.averageCircles A is).evalCyclic N x = + (let := D.metricSpace; iteratedCircleAverage A is T.observable (D.cyclicOrbitPoint T.orbit N x)) := rfl + +theorem averageCircles_tested_error (T : D.Niltest (fun _ : Unit => 1)) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + {J : Type*} [Fintype J] (U : J → D.Niltest (fun _ : Unit => 1)) (n : J → α → ℤ) + (horbit : ∀ j, (U j).orbit = T.orbit) {N : ℕ} [NeZero N] (weight : ZMod N → ℂ) + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) (hweight : ∀ x, ‖weight x‖ ≤ B) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (heigen : let := D.metricSpace; ∀ j i, i ∈ is → ∀ t x, + (U j).observable ((A i).act t x) = character (n j i • t) * (U j).observable x) + (hdiscard : ∀ j, ¬ (∀ i ∈ is, n j i = 0) → + ‖𝔼 x, weight x * (U j).evalCyclic N (fun _ => x)‖ ≤ tau) : + ‖(𝔼 x, weight x * T.evalCyclic N (fun _ => x)) - + (𝔼 x, weight x * (T.averageCircles A is).evalCyclic N (fun _ => x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + let := D.metricSpace + let path : ZMod N → D.Space := fun x => D.cyclicOrbitPoint T.orbit N (fun _ => x) + have heval (j : J) (x : ZMod N) : + (U j).observable (path x) = (U j).evalCyclic N (fun _ => x) := by + change (U j).observable (D.cyclicOrbitPoint T.orbit N (fun _ => x)) = + (U j).observable (D.cyclicOrbitPoint (U j).orbit N (fun _ => x)) + rw [horbit j] + have hdiscard' (j : J) (hj : ¬ (∀ i ∈ is, n j i = 0)) : + ‖𝔼 x, weight x * (U j).observable (path x)‖ ≤ tau := by + simpa only [heval] using hdiscard j hj + exact iteratedCircleAverage_tested_error A is T.observable (fun j => (U j).observable) + n path weight T.lipBound (fun j => (U j).lipBound) T.lipschitz (fun j => (U j).lipschitz) + hB htau hweight happrox heigen hdiscard' + +theorem exists_positive_circle_projection (T : D.Niltest (fun _ : Unit => 1)) + (hT : T.UnitIntervalValued) {p : ℝ} (hTc : T.ComplexityLE p) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + (hcomm : let := D.metricSpace; ∀ i ∈ is, ∀ j ∈ is, (A i).Commutes (A j)) + {J : Type*} [Fintype J] (U : J → D.Niltest (fun _ : Unit => 1)) (n : J → α → ℤ) + (horbit : ∀ j, (U j).orbit = T.orbit) {N : ℕ} [NeZero N] (weight : ZMod N → ℂ) + {B rho tau : ℝ} (hB : 0 ≤ B) (htau : 0 ≤ tau) (hweight : ∀ x, ‖weight x‖ ≤ B) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (heigen : let := D.metricSpace; ∀ j i, i ∈ is → ∀ t x, + (U j).observable ((A i).act t x) = character (n j i • t) * (U j).observable x) + (hsignificant : ∀ j, tau < ‖𝔼 x, weight x * (U j).evalCyclic N (fun _ => x)‖ → + ∀ i ∈ is, n j i = 0) : + let := D.metricSpace + ∃ S : D.Niltest (fun _ : Unit => 1), S.UnitIntervalValued ∧ S.ComplexityLE p ∧ + S.orbit = T.orbit ∧ + (∀ i ∈ is, ∀ t x, S.observable ((A i).act t x) = S.observable x) ∧ + ‖(𝔼 x, weight x * T.evalCyclic N (fun _ => x)) - + (𝔼 x, weight x * S.evalCyclic N (fun _ => x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + let := D.metricSpace + refine ⟨T.averageCircles A is, T.averageCircles_unit_interval A is hT, + T.averageCircles_complexity A is hTc, T.averageCircles_orbit A is, ?_, ?_⟩ + · intro i hi t x + exact T.averageCircles_invariant A is hcomm i hi t x + · apply T.averageCircles_tested_error A is U n horbit weight hB htau hweight happrox heigen + intro j hj + exact le_of_not_gt (fun h => hj (hsignificant j h)) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open CircleFourier +open scoped TensorProduct BigOperators NNReal + +variable {σ α L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem averageCircles_weighted_error (T : D.Niltest w) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + {J G : Type*} [Fintype J] [Fintype G] (U : J → D.Niltest w) (n : J → α → ℤ) + (horbit : ∀ j, (U j).orbit = T.orbit) (path : G → σ → ℤ) (weight : G → ℂ) + {B rho tau : ℝ} (hmass : (∑ x, ‖weight x‖) ≤ B) (hrho : 0 ≤ rho) (htau : 0 ≤ tau) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (heigen : let := D.metricSpace; ∀ j i, i ∈ is → ∀ t x, + (U j).observable ((A i).act t x) = character (n j i • t) * (U j).observable x) + (hdiscard : ∀ j, ¬ (∀ i ∈ is, n j i = 0) → + ‖∑ x, weight x * (U j).eval (path x)‖ ≤ tau) : + ‖(∑ x, weight x * T.eval (path x)) - + (∑ x, weight x * (T.averageCircles A is).eval (path x))‖ ≤ + 2 * B * rho + Fintype.card J * tau := by + let := D.metricSpace + let orbitPath : G → D.Space := fun x => + QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w (path x) T.orbit) + have heval (j : J) (x : G) : + (U j).observable (orbitPath x) = (U j).eval (path x) := by + change (U j).observable (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval w (path x) T.orbit)) = + (U j).observable (QuotientGroup.mk + (D.filtration.realification.polynomialOrbitEval w (path x) (U j).orbit)) + rw [horbit j] + have hdiscard' (j : J) (hj : ¬ (∀ i ∈ is, n j i = 0)) : + ‖∑ x, weight x * (U j).observable (orbitPath x)‖ ≤ tau := by + simpa only [heval] using hdiscard j hj + exact iteratedCircleAverage_weighted_error A is T.observable (fun j => (U j).observable) + n orbitPath weight T.lipBound (fun j => (U j).lipBound) T.lipschitz + (fun j => (U j).lipschitz) hmass hrho htau happrox heigen hdiscard' + +theorem exists_positive_circle_projection_family (T : D.Niltest w) + (hT : T.UnitIntervalValued) {p : ℝ} (hTc : T.ComplexityLE p) + (A : let := D.metricSpace; α → IsometricCircleAction D.Space) (is : List α) + (hcomm : let := D.metricSpace; ∀ i ∈ is, ∀ j ∈ is, (A i).Commutes (A j)) + {J β : Type*} {G : β → Type*} [Fintype J] [∀ a, Fintype (G a)] + (U : J → D.Niltest w) (n : J → α → ℤ) (horbit : ∀ j, (U j).orbit = T.orbit) + (path : ∀ a, G a → σ → ℤ) (weight : ∀ a, G a → ℂ) (B tau : β → ℝ) + {rho : ℝ} (hmass : ∀ a, (∑ x, ‖weight a x‖) ≤ B a) + (hrho : 0 ≤ rho) (htau : ∀ a, 0 ≤ tau a) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (heigen : let := D.metricSpace; ∀ j i, i ∈ is → ∀ t x, + (U j).observable ((A i).act t x) = character (n j i • t) * (U j).observable x) + (hsignificant : ∀ j, (∃ a, tau a < ‖∑ x, weight a x * (U j).eval (path a x)‖) → + ∀ i ∈ is, n j i = 0) : + let := D.metricSpace + ∃ S : D.Niltest w, S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ i ∈ is, ∀ t x, S.observable ((A i).act t x) = S.observable x) ∧ + ∀ a, ‖(∑ x, weight a x * T.eval (path a x)) - + (∑ x, weight a x * S.eval (path a x))‖ ≤ + 2 * B a * rho + Fintype.card J * tau a := by + let := D.metricSpace + refine ⟨T.averageCircles A is, T.averageCircles_unit_interval A is hT, + T.averageCircles_complexity A is hTc, T.averageCircles_orbit A is, ?_, ?_⟩ + · intro i hi t x + exact T.averageCircles_invariant A is hcomm i hi t x + · intro a + apply T.averageCircles_weighted_error A is U n horbit (path a) (weight a) + (hmass a) hrho (htau a) happrox heigen + intro j hj + exact le_of_not_gt (fun h => hj (hsignificant j ⟨a, h⟩)) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open Module CircleFourier +open scoped TensorProduct BigOperators + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem exists_positive_kernel_projection_family (T : D.Niltest w) + (hT : T.UnitIntervalValued) {p : ℝ} (hTc : T.ComplexityLE p) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + {J β : Type*} {G : β → Type*} [Fintype J] [∀ a, Fintype (G a)] + (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (horbit : ∀ j, (U j).orbit = T.orbit) + (hvertical : ∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) + (path : ∀ a, G a → σ → ℤ) (weight : ∀ a, G a → ℂ) (B tau : β → ℝ) + {rho : ℝ} (hmass : ∀ a, (∑ x, ‖weight a x‖) ≤ B a) + (hrho : 0 ≤ rho) (htau : ∀ a, 0 ≤ tau a) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (hkill : ∀ j, (∃ a, tau a < ‖∑ x, weight a x * (U j).eval (path a x)‖) → + ∀ v ∈ K, eta j v = 0) : + ∃ S : D.Niltest w, S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ K.baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + ∀ a, ‖(∑ x, weight a x * T.eval (path a x)) - + (∑ x, weight a x * S.eval (path a x))‖ ≤ + 2 * B a * rho + Fintype.card J * tau a := by + classical + let := D.metricSpace + let : FiniteDimensional ℚ L := D.basis.finiteDimensional_of_finite + let b := Module.finBasis ℚ K + let v : Fin (finrank ℚ K) → L := fun i => b i + have hv (i : Fin (finrank ℚ K)) : v i ∈ D.filtration.layer s := hK (b i).property + let A : Fin (finrank ℚ K) → IsometricCircleAction D.Space := + fun i => D.centralRationalCircle (v i) (hv i) + have hfreq (j : J) (i : Fin (finrank ℚ K)) : ∃ n : ℤ, + (∀ t x, (U j).observable ((A i).act t x) = character (n • t) * (U j).observable x) ∧ + (eta j (v i) = 0 → n = 0) := + D.exists_centralRationalCircle_frequency (v i) (hv i) (eta j) (U j).observable (hvertical j) + choose n heigen hzero using hfreq + let is := List.finRange (finrank ℚ K) + have hcomm : ∀ i ∈ is, ∀ j ∈ is, (A i).Commutes (A j) := + fun i _ j _ => D.centralRationalCircle_commutes (v i) (v j) (hv i) (hv j) + have hsignificant (j : J) + (hj : ∃ a, tau a < ‖∑ x, weight a x * (U j).eval (path a x)‖) : + ∀ i ∈ is, n j i = 0 := by + intro i _ + exact hzero j i (hkill j hj (v i) (b i).property) + obtain ⟨S, hS, hSc, hSo, hSinv, herror⟩ := T.exists_positive_circle_projection_family hT hTc + A is hcomm U n horbit path weight B tau hmass hrho htau happrox + (fun j i _ => heigen j i) hsignificant + refine ⟨S, hS, hSc, hSo, ?_, herror⟩ + intro z hz x + exact D.invariant_of_kernel_circles K hK b S.observable + (fun i t y => hSinv i (by simp [is]) t y) z hz x + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open CircleFourier +open scoped TensorProduct BigOperators + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + +theorem exists_probability_kernel_projection_family (T : D.Niltest w) + (hT : T.UnitIntervalValued) {p : ℝ} (hTc : T.ComplexityLE p) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + {J β : Type*} {G : β → Type*} [Fintype J] [∀ a, Fintype (G a)] + (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (horbit : ∀ j, (U j).orbit = T.orbit) + (hvertical : ∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) + (law : ∀ a, FiniteProbabilityWeights (G a)) (path : ∀ a, G a → σ → ℤ) + (tau : β → ℝ) {rho : ℝ} (hrho : 0 ≤ rho) (htau : ∀ a, 0 ≤ tau a) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (hkill : ∀ j, (∃ a, tau a < ‖(law a).complexMean (fun x => (U j).eval (path a x))‖) → + ∀ v ∈ K, eta j v = 0) : + ∃ S : D.Niltest w, S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ K.baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + ∀ a, ‖(law a).complexMean (fun x => T.eval (path a x)) - + (law a).complexMean (fun x => S.eval (path a x))‖ ≤ + 2 * rho + Fintype.card J * tau a := by + have hmass (a : β) : (∑ x, ‖((law a).weight x : ℂ)‖) ≤ 1 := by + have hnorm (x : G a) : ‖((law a).weight x : ℂ)‖ = (law a).weight x := by + rw [Complex.norm_real, Real.norm_of_nonneg ((law a).nonneg x)] + simp_rw [hnorm] + exact (law a).total.le + simpa only [FiniteProbabilityWeights.complexMean, mul_one] using + T.exists_positive_kernel_projection_family hT hTc K hK eta U horbit hvertical path + (fun a x => ((law a).weight x : ℂ)) (fun _ => 1) tau hmass hrho htau happrox hkill + +theorem exists_finset_kernel_projection_family (T : D.Niltest w) + (hT : T.UnitIntervalValued) {p : ℝ} (hTc : T.ComplexityLE p) + (K : Submodule ℚ L) (hK : K ≤ D.filtration.layer s) + {J β : Type*} [Fintype J] + (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w) + (horbit : ∀ j, (U j).orbit = T.orbit) + (hvertical : ∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) + (boxes : β → Finset (σ → ℤ)) (hboxes : ∀ a, (boxes a).Nonempty) + (tau : β → ℝ) {rho : ℝ} (hrho : 0 ≤ rho) (htau : ∀ a, 0 ≤ tau a) + (happrox : ∀ x, ‖T.observable x - ∑ j, (U j).observable x‖ ≤ rho) + (hkill : ∀ j, (∃ a, tau a < ‖𝔼 x ∈ boxes a, (U j).eval x‖) → + ∀ v ∈ K, eta j v = 0) : + ∃ S : D.Niltest w, S.UnitIntervalValued ∧ S.ComplexityLE p ∧ S.orbit = T.orbit ∧ + (∀ z : D.RealGroup, z.coord ∈ K.baseChange ℝ → + ∀ x, S.observable (z • x) = S.observable x) ∧ + ∀ a, ‖(𝔼 x ∈ boxes a, T.eval x) - (𝔼 x ∈ boxes a, S.eval x)‖ ≤ + 2 * rho + Fintype.card J * tau a := by + let law (a : β) := FiniteProbabilityWeights.uniformFinset (boxes a) (hboxes a) + have hkill' : ∀ j, (∃ a, tau a < ‖(law a).complexMean (fun x => (U j).eval x.val)‖) → + ∀ v ∈ K, eta j v = 0 := by + simpa only [law, FiniteProbabilityWeights.uniformFinset_complexMean] using hkill + simpa only [law, FiniteProbabilityWeights.uniformFinset_complexMean] using + T.exists_probability_kernel_projection_family hT hTc K hK eta U horbit hvertical + law (fun _ x => x.val) tau hrho htau happrox hkill' + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestScalarTransfer.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestScalarTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f76a7b1de41abf82aa804ea580ff9dd80dca09d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestScalarTransfer.lean @@ -0,0 +1,1298 @@ +import OAI.Combinatorics.Progressions.Dynamics.ScalarDoublingBudget +import OAI.Combinatorics.Progressions.Estimates.BaselineNoIncrementTree +import OAI.Combinatorics.Progressions.Estimates.InitialReplacementMeshWidths +import OAI.Combinatorics.Progressions.Estimates.OrdinaryMeshMarginals +import OAI.Combinatorics.Progressions.Estimates.ScalarInputLogFactor +import OAI.Combinatorics.Progressions.Estimates.ScalarWindowPartitions +import OAI.Combinatorics.Progressions.Geometry.ScalarBoxGeometry +import OAI.Combinatorics.Progressions.Lattices.AffineMeshScalarTail +import OAI.Combinatorics.Progressions.Lattices.AffineNormalizedScales +import OAI.Combinatorics.Progressions.Lattices.AffinePrecisionBudget +import OAI.Combinatorics.Progressions.Lattices.AllocatedAffineSecondaryMesh +import OAI.Combinatorics.Progressions.Sampling.PhysicalGridCostFromLogs + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v w + +theorem exists_niltest_affine_reference_comparison (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {σ : Type u} {V : Type v} {J : Type*} + [Fintype ι] [LinearOrder ι] [Fintype σ] [Fintype J] + [LieRing V] [LieAlgebra ℚ V] [TopologicalSpace (ℝ ⊗[ℚ] V)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d) + (p ε L T C totalShell modLog dimLog sourceDimLog level : ℝ), + 2 ≤ p → 0 < ε → 0 ≤ L → 0 ≤ T → 0 ≤ C → 0 < totalShell → + 0 ≤ modLog → modLog ≤ p → 0 ≤ dimLog → 0 ≤ sourceDimLog → T + 4 ≤ p → + Real.exp (-L) ≤ level → level ≤ 2 → + (Fintype.card σ : ℝ) ≤ p → (Fintype.card ι : ℝ) ≤ Real.exp C → + (Fintype.card σ : ℝ) ≤ Real.exp dimLog → + (Fintype.card (Option J × σ) : ℝ) ≤ Real.exp sourceDimLog → 2 ≤ Fintype.card J → + ∀ g : nilmanifold.Niltest (fun _ : σ => 1), g.ComplexityLE p → + ∀ (prime power : ι → ℕ) [∀ i, NeZero (prime i ^ power i)], + (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp modLog) → + ∀ (D : ℕ) (parameterA : J → ℤ), + ((affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D).card : ℝ) ≤ p → + ((affineRemovalDepth T + affineComparisonTail ε L T : ℕ) : ℝ) ≤ p → + ∀ (parent lo a : σ → ℤ) (H N : σ → ℕ), PhysicalSubbox parent H lo N → + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ResidueSliceLogCostLE H lo N 1 a p → + ∀ (h : (σ → ℤ) → ℂ), + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval parent H ((p + 2) ^ E) level (affineIncrementTolerance L T) → + ∀ (hne : Nonempty (IntegerResidueBox lo (fun k => lo k + N k) (fun _ => (1 : ℤ)) a)) + (sourceLo sourceA : Option J × σ → ℤ) (sourceN : Option J × σ → ℕ) + (hneSource : Nonempty (IntegerResidueBox sourceLo (fun k => sourceLo k + sourceN k) + (fun _ => (1 : ℤ)) sourceA)) (sourceWeight : (Option J × σ → ℤ) → ℝ), + (∀ z ∈ translatedIntegerBox sourceLo sourceN, 0 ≤ sourceWeight z ∧ sourceWeight z ≤ 1) → + let A := ⌈(p + 2) ^ E⌉₊ + let B := adaptiveAffineCutoff A (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C totalShell modLog + (∀ k, Real.exp (max ((p + 2) ^ E) + (adaptiveAffineSideLog A (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C totalShell modLog dimLog)) ≤ (N k : ℝ)) → + (∀ k, Real.exp (adaptiveAffineSideLog A (Fintype.card (Option J × σ)) (Fintype.card σ) + ε L T C totalShell modLog sourceDimLog) ≤ (sourceN k : ℝ)) → + productTruncatedPairing (affinePeriodProductCoupling (σ := σ) (fun i => prime i ^ power i) D parameterA) + (lowDegreeCoordinateSets ι B) + (residuePrimeCoordinateDensity sourceLo sourceN 1 sourceA hneSource (fun i => prime i ^ power i) sourceWeight) + (fun z => residuePrimeCoordinateDensity lo N 1 a hne (fun i => prime i ^ power i) (fun x => (h x).re) z - + (1 + ε) * level * residuePrimeCoordinateDensity lo N 1 a hne (fun i => prime i ^ power i) (fun x => (g.eval x).re) z) ≤ + 100 * (1 + ε) * Real.exp (-T / 2) + (1 + ε) * totalShell := by + obtain ⟨E, hE, htreeExists⟩ := exists_baseline_comparison_tree.{u, v, w} s + refine ⟨E, hE, ?_⟩ + intro ι σ V J _ _ _ _ _ _ _ _ _ _ d nilmanifold p ε L T C totalShell modLog dimLog sourceDimLog level + hp hε hL hT hC htotal hmodLog hmodLogP hdimLog hsourceDimLog hTP hlower hlevel2 + hσ hcount hdim hsourceDim hJ g hcomplexity prime power _ hprime hinj hmoduli + D parameterA hmaskCard hr parent lo a H N hbox hunit hcost h hh hupper + hne sourceLo sourceA sourceN hneSource sourceWeight hw A B hside hsourceSide + let shell := adaptiveAffineShell A (Fintype.card (Option J × σ)) (Fintype.card σ) ε L T C totalShell modLog + have hδ : 0 < affineStabilityTolerance T := Real.exp_pos _ + have hδinv : (affineStabilityTolerance T)⁻¹ ≤ Real.exp p := by + simpa only [affineStabilityTolerance, Real.exp_neg, inv_inv] using Real.exp_le_exp.mpr hTP + have hprimeP (i) : ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp p := + (hmoduli i).trans (Real.exp_le_exp.mpr hmodLogP) + have hlarge (k : σ) : Real.exp ((p + 2) ^ E) ≤ (H k : ℝ) := + ((Real.exp_le_exp.mpr (le_max_left _ _)).trans (hside k)).trans + (by exact_mod_cast hbox.length_le k) + have hlevel : 0 ≤ level := (Real.exp_pos (-L)).le.trans hlower + obtain ⟨tree, depth, hdepth, htree⟩ := htreeExists nilmanifold p (affineStabilityTolerance T) + hp hσ hδ hδinv g hcomplexity prime power hprime hinj hprimeP + (affineSamplerPrimeMask prime (ε / (2 + ε)) (affineComparisonScale ε L T C) 1 1 D) + (affineRemovalDepth T + affineComparisonTail ε L T) hmaskCard hr + parent H N lo a 1 (by decide) hbox hunit hcost hlarge h level + (affineIncrementTolerance L T) hlevel hupper + have hA : depth ≤ A := by + exact_mod_cast hdepth.trans (Nat.le_ceil ((p + 2) ^ E)) + have hB := adaptiveAffineCutoff_bounds A (Fintype.card (Option J × σ)) (Fintype.card σ) + ε L T C totalShell modLog + have hshell : 0 < shell := adaptiveAffineShell_pos A (Fintype.card (Option J × σ)) + (Fintype.card σ) ε L T C modLog htotal + have hsideRaw (k : σ) : + Real.exp (modLog * A + affineComparisonLengthLog B ε L T C modLog dimLog + 2) ≤ (N k : ℝ) := + (Real.exp_le_exp.mpr (le_max_right _ _)).trans (hside k) + have hallocation := (adaptiveAffineShell_allocation A (Fintype.card (Option J × σ)) + (Fintype.card σ) ε L T C totalShell modLog).le + have hcomparison := normalized_adaptive_affine_comparison lo a N hne sourceLo sourceA sourceN hneSource + h g.eval sourceWeight (fun z hz => (hunit z hz).2) hh hw hε hL hT hC hshell hlower hlevel2 + hmodLog hdimLog hsourceDimLog hmoduli hcount hdim hsourceDim prime power hprime (fun _ => rfl) + hinj hJ D parameterA tree (fun _ _ => 0) (fun _ _ => 0) htree hA hB.1 hB.2 hsideRaw hsourceSide hallocation + have hP := (affineComparisonScale_bounds (ε := ε) hL hT hC).1 + have heta := affineComparisonAccuracy_bounds (level := Real.exp (-L)) B hP hL hT le_rfl + exact hcomparison.trans (normalized_affine_error_le hε.le hT hlevel hlevel2 heta.1.le heta.2.1.le + hshell.le (adaptiveAffineShell_le A (Fintype.card (Option J × σ)) (Fintype.card σ) hL hT hC hmodLog htotal.le)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v w + +theorem exists_niltest_mesh_reference_bounds (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {I : Type u} {V : Type v} {J : Type*} + [Fintype ι] [LinearOrder ι] [Fintype I] [Fintype J] + [LieRing V] [LieAlgebra ℚ V] [TopologicalSpace (ℝ ⊗[ℚ] V)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d) + (p epsilon L T C totalShell modLog dimLog sourceDimLog level : ℝ), + 2 ≤ p → 0 < epsilon → 0 ≤ L → 0 ≤ T → 0 ≤ C → 0 < totalShell → + 0 ≤ modLog → modLog ≤ p → 0 ≤ dimLog → 0 ≤ sourceDimLog → T + 4 ≤ p → + Real.exp (-L) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → (Fintype.card ι : ℝ) ≤ Real.exp C → + (Fintype.card I : ℝ) ≤ Real.exp dimLog → + (Fintype.card (Option J × I) : ℝ) ≤ Real.exp sourceDimLog → 2 ≤ Fintype.card J → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (prime power : ι → ℕ) [∀ i, NeZero (prime i ^ power i)], + (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp modLog) → + ∀ (D : ℕ) (anchor : J → ℤ), + ((affineSamplerPrimeMask prime (epsilon / (2 + epsilon)) (affineComparisonScale epsilon L T C) 1 1 D).card : ℝ) ≤ p → + ((affineRemovalDepth T + affineComparisonTail epsilon L T : ℕ) : ℝ) ≤ p → + ∀ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)), + (∀ i c, (P i).step c = 1) → ∀ (hPpos : ∀ i c, 0 < (P i).length c), + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + (∀ i c, Real.exp (-p) * (N i : ℝ) ≤ ((P i).length c : ℝ)) → + ∀ (h : (I → ℤ) → ℂ), + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N ((p + 2) ^ E) level (affineIncrementTolerance L T) → + ∀ (sourceLo sourceHi : Option J × I → ℤ) + (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat), + (∀ i cs, (S i).step cs = 1) → ∀ (hSpos : ∀ i cs, 0 < (S i).length cs), + ∀ sourceWeight : (Option J × I → ℤ) → ℝ, + (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ sourceWeight (fun i => (z i).val) ∧ sourceWeight (fun i => (z i).val) ≤ 1) → + let A := ⌈(p + 2) ^ E⌉₊ + let B := adaptiveAffineCutoff A (Fintype.card (Option J × I)) (Fintype.card I) + epsilon L T C totalShell modLog + (∀ i c, Real.exp (max ((p + 2) ^ E) + (adaptiveAffineSideLog A (Fintype.card (Option J × I)) (Fintype.card I) + epsilon L T C totalShell modLog dimLog)) ≤ ((P i).length c : ℝ)) → + (∀ i cs, Real.exp (adaptiveAffineSideLog A (Fintype.card (Option J × I)) (Fintype.card I) + epsilon L T C totalShell modLog sourceDimLog) ≤ ((S i).length cs : ℝ)) → + ∀ (cs : ∀ i, (S i).Label) (c : ∀ i, (P i).Label), + productTruncatedPairing (affinePeriodProductCoupling (σ := I) (fun i => prime i ^ power i) D anchor) + (lowDegreeCoordinateSets ι B) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) + (fun i => (S i).length (cs i)) 1 (fun _ => 0) + (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) + (fun i => prime i ^ power i) sourceWeight) + (fun x => residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) + (fun i => prime i ^ power i) (fun z => (h z).re) x - + (1 + epsilon) * level * residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) + (fun i => prime i ^ power i) (fun z => (g.eval z).re) x) ≤ + 100 * (1 + epsilon) * Real.exp (-T / 2) + (1 + epsilon) * totalShell := by + obtain ⟨E, hE, href⟩ := exists_niltest_affine_reference_comparison.{u,v,w} s + refine ⟨E, hE, ?_⟩ + intro ι I V J _ _ _ _ _ _ _ _ _ _ d nilmanifold p epsilon L T C totalShell modLog dimLog sourceDimLog level + hp hepsilon hL hT hC htotal hmodLog hmodLogP hdimLog hsourceDimLog hTP hlower hlevel2 + hI hcount hdim hsourceDim hJ g hcomplexity prime power _ hprime hinj hmoduli + D anchor hmask hdepth lo N P hPstep hPpos hunit hwidth h hh hupper + sourceLo sourceHi S hSstep hSpos sourceWeight hw A B hside hsourceSide cs c + have hsubset := physicalBoxCell_subset lo N P hPstep hPpos c + have hwcell (z) (hz : z ∈ translatedIntegerBox + (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) (fun i => (S i).length (cs i))) : + 0 ≤ sourceWeight z ∧ sourceWeight z ≤ 1 := by + obtain ⟨x, _, hx⟩ := integerBoxMesh_cell_realize sourceLo sourceHi S hSstep hSpos cs z hz + simpa only [hx] using hw x + exact href nilmanifold p epsilon L T C totalShell modLog dimLog sourceDimLog level + hp hepsilon hL hT hC htotal hmodLog hmodLogP hdimLog hsourceDimLog hTP hlower hlevel2 + hI hcount hdim hsourceDim hJ g hcomplexity prime power hprime hinj hmoduli + D anchor hmask hdepth lo (fun i => intervalCellLower (lo i) (P i) (c i)) (fun _ => 0) + N (fun i => (P i).length (c i)) (physicalBoxCell_subbox lo N P hPstep hPpos c) + (fun z hz => hunit z (hsubset hz)) (physicalBoxCell_log_cost lo N P c p (fun i => hwidth i (c i))) + h (fun z hz => hh z (hsubset hz)) hupper (physicalBoxCell_nonempty lo N P hPpos c) + (fun i => intervalCellLower (sourceLo i) (S i) (cs i)) (fun _ => 0) (fun i => (S i).length (cs i)) + (physicalBoxCell_nonempty sourceLo (fun i => (sourceHi i - sourceLo i).toNat) S hSpos cs) + sourceWeight hwcell (fun i => hside i (c i)) (fun i => hsourceSide i (cs i)) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v w + +theorem exists_niltest_mesh_scalar_transfer (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {I : Type u} {V : Type v} {J : Type*} + [Fintype ι] [LinearOrder ι] [Fintype I] [Fintype J] + [LieRing V] [LieAlgebra ℚ V] [TopologicalSpace (ℝ ⊗[ℚ] V)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d) + (p epsilon L T C totalShell modLog dimLog sourceDimLog level : ℝ), + 2 ≤ p → 0 < epsilon → 0 ≤ L → 0 ≤ T → 0 ≤ C → 0 < totalShell → + 0 ≤ modLog → modLog ≤ p → 0 ≤ dimLog → 0 ≤ sourceDimLog → T + 4 ≤ p → + Real.exp (-L) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → (Fintype.card ι : ℝ) ≤ Real.exp C → + (Fintype.card I : ℝ) ≤ Real.exp dimLog → + (Fintype.card (Option J × I) : ℝ) ≤ Real.exp sourceDimLog → 2 ≤ Fintype.card J → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (prime power : ι → ℕ) [∀ i, NeZero (prime i ^ power i)], + (∀ i, (prime i).Prime) → Function.Injective prime → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp modLog) → + ∀ (D : ℕ) (anchor : J → ℤ), + ((affineSamplerPrimeMask prime (epsilon / (2 + epsilon)) (affineComparisonScale epsilon L T C) 1 1 D).card : ℝ) ≤ p → + ((affineRemovalDepth T + affineComparisonTail epsilon L T : ℕ) : ℝ) ≤ p → + ∀ (lo : I → ℤ) (N : I → ℕ) (P : ∀ i, FiniteProgressionPartition (N i)), + (∀ i c, (P i).step c = 1) → ∀ (hPpos : ∀ i c, 0 < (P i).length c), + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + (∀ i c, Real.exp (-p) * (N i : ℝ) ≤ ((P i).length c : ℝ)) → + ∀ (h : (I → ℤ) → ℂ), + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N ((p + 2) ^ E) level (affineIncrementTolerance L T) → + ∀ (sourceLo sourceHi : Option J × I → ℤ) + (S : ∀ i, FiniteProgressionPartition (sourceHi i - sourceLo i).toNat), + (∀ i cs, (S i).step cs = 1) → ∀ (_hSpos : ∀ i cs, 0 < (S i).length cs), + ∀ (hsource : ∀ i, sourceLo i < sourceHi i), + let A := ⌈(p + 2) ^ E⌉₊ + let B := adaptiveAffineCutoff A (Fintype.card (Option J × I)) (Fintype.card I) + epsilon L T C totalShell modLog + (∀ i c, Real.exp (max ((p + 2) ^ E) + (adaptiveAffineSideLog A (Fintype.card (Option J × I)) (Fintype.card I) + epsilon L T C totalShell modLog dimLog)) ≤ ((P i).length c : ℝ)) → + (∀ i cs, Real.exp (adaptiveAffineSideLog A (Fintype.card (Option J × I)) (Fintype.card I) + epsilon L T C totalShell modLog sourceDimLog) ≤ ((S i).length cs : ℝ)) → + ∀ (paramLo paramHi : J → ℤ) (hparam : ∀ j, paramLo j < paramHi j) + (paramPartition : ∀ j, FiniteProgressionPartition (paramHi j - paramLo j).toNat), + (∀ j c, (paramPartition j).step c = 1) → + ∀ (hTpos : ∀ j c, 0 < (paramPartition j).length c), + ∀ (etaParam etaSite beta accuracy : ℝ), 0 ≤ etaParam → 0 ≤ etaSite → + ∀ (_hcloseParam : ∀ ct : (∀ j, (paramPartition j).Label), + ProductMarginalsClose (primeCoordinateReference (σ := J) (fun i => prime i ^ power i)) + (residuePrimeCoordinateDensity (fun j => intervalCellLower (paramLo j) (paramPartition j) (ct j)) + (fun j => (paramPartition j).length (ct j)) 1 (fun _ => 0) + (physicalBoxCell_nonempty paramLo (fun j => (paramHi j - paramLo j).toNat) paramPartition hTpos ct) + (fun i => prime i ^ power i) (fun _ => 1)) etaParam B) + (_hcloseSite : ∀ c : (∀ i, (P i).Label), + ProductMarginalsClose (primeCoordinateReference (σ := I) (fun i => prime i ^ power i)) + (residuePrimeCoordinateDensity (fun i => intervalCellLower (lo i) (P i) (c i)) + (fun i => (P i).length (c i)) 1 (fun _ => 0) (physicalBoxCell_nonempty lo N P hPpos c) + (fun i => prime i ^ power i) (fun _ => 1)) etaSite B) + (_hbad : ((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).eventProbability + (physicalMeshCrossing lo N P + (fun tz => (integerBoxMesh sourceLo sourceHi S tz.2, integerBoxMesh paramLo paramHi paramPartition tz.1)) + (fun tz => smoothAffineSample (fun j => anchor j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val))) ≤ beta) + (_heh : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) → + |((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos (fun i => prime i ^ power i) B (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy) + (_heg : ∀ w : (Option J × I → ℤ) → ℝ, (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) → + |((integerBoxUniformWeights paramLo paramHi hparam).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hPpos (fun i => prime i ^ power i) B (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ accuracy) + (pTarget dominationLog : ℝ) + (outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i))) + (_hdom : ∀ z, outer.weight z ≤ Real.exp dominationLog * + (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) + (_herror : (100 * (1 + epsilon) * Real.exp (-T / 2) + (1 + epsilon) * totalShell) + (1 + ((1 + epsilon) * level)) * ((etaParam + beta) * residueTruncationCap ι B etaSite + accuracy) ≤ + Real.exp (-(2 * pTarget + dominationLog)) / 2), + outer.eventProbability (fun z => Real.exp (-pTarget) < + (integerBoxUniformWeights paramLo paramHi hparam).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + ((1 + epsilon) * level) * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ + Real.exp (-pTarget) := by + obtain ⟨E, hE, href⟩ := exists_niltest_mesh_reference_bounds.{u,v,w} s + refine ⟨E, hE, ?_⟩ + intro ι I V J _ _ _ _ _ _ _ _ _ _ d nilmanifold p epsilon L T C totalShell modLog dimLog sourceDimLog level + hp hepsilon hL hT hC htotal hmodLog hmodLogP hdimLog hsourceDimLog hTP hlower hlevel2 + hI hcount hdim hsourceDim hJ g hcomplexity prime power _ hprime hinj hmoduli + D anchor hmask hdepth lo N P hPstep hPpos hunit hwidth h hh hupper + sourceLo sourceHi S hSstep hSpos hsource A B hside hsourceSide + paramLo paramHi hparam paramPartition hTstep hTpos etaParam etaSite beta accuracy + hetaParam hetaSite hcloseParam hcloseSite hbad heh heg pTarget dominationLog outer hdom herror + apply affine_mesh_scalar_tail lo N P hPstep hPpos sourceLo sourceHi hsource + S hSstep hSpos paramLo paramHi hparam paramPartition hTstep hTpos D anchor + (fun i => prime i ^ power i) B (fun z => (h z).re) (fun z => (g.eval z).re) + hh (fun z hz => (hunit z hz).2) hetaParam hetaSite + (mul_nonneg (by linarith) ((Real.exp_pos (-L)).le.trans hlower)) + (by positivity) hcloseParam hcloseSite ?_ hbad heh heg pTarget dominationLog outer hdom herror + intro sourceWeight hw cs c + exact href nilmanifold p epsilon L T C totalShell modLog dimLog sourceDimLog level + hp hepsilon hL hT hC htotal hmodLog hmodLogP hdimLog hsourceDimLog hTP hlower hlevel2 + hI hcount hdim hsourceDim hJ g hcomplexity prime power hprime hinj hmoduli + D anchor hmask hdepth lo N P hPstep hPpos hunit hwidth h hh hupper + sourceLo sourceHi S hSstep hSpos sourceWeight hw hside hsourceSide cs c + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v w + +theorem exists_niltest_geometric_scalar_transfer (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {ι : Type w} {I : Type u} {V : Type v} {J : Type*} + [Fintype ι] [LinearOrder ι] [Fintype I] [Fintype J] + [LieRing V] [LieAlgebra ℚ V] [TopologicalSpace (ℝ ⊗[ℚ] V)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d) + (p epsilon Z U gridLog ratioLog meshLog level budget : ℝ), + 2 ≤ p → 0 < epsilon → epsilon ≤ 1 → 0 ≤ Z → 0 ≤ U → 0 ≤ meshLog → + p ≤ U → scalarTransferTail (3 * p) ≤ U → Z ≤ U → + gridLog + ratioLog + 2 ≤ U → epsilon⁻¹ ≤ Real.exp U → + Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ U → (Fintype.card (Option J × I) : ℝ) ≤ U → + (Fintype.card J : ℝ) ≤ U → 2 ≤ Fintype.card J → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (prime power : ι → ℕ) [∀ i, NeZero (prime i ^ power i)], + (∀ i, (prime i).Prime) → Function.Injective prime → + (Fintype.card ι : ℝ) ≤ Real.exp Z → + (∀ i, ((prime i ^ power i : ℕ) : ℝ) ≤ Real.exp Z) → + ∀ (D : ℕ) (anchor : J → ℤ), 0 < D → (D : ℝ) ≤ Real.exp Z → + let pref := affineReferenceInput epsilon U + let common := affineCommonReferenceBudget E epsilon U + let Aref := ⌈(pref + 2) ^ E⌉₊ + let b := adaptiveAffineCutoff Aref (Fintype.card (Option J × I)) (Fintype.card I) + epsilon p (scalarTransferTail (3 * p)) Z (scalarTransferBaseAccuracy (3 * p)) Z + let _beta := scalarTransferMarginalAccuracy (3 * p) (scalarTransferCapLog b Z) + let cellLog := scalarTransferCellLog common b p Z U + (pref + 2) ^ E ≤ budget → p + scalarTransferTail (3 * p) + 4 ≤ budget → + scalarTransferAccuracyLog b p Z ≤ meshLog → + ∀ (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ) + (rho L C B A c sourceRatio parameterRatio : ℝ), + 0 < rho → 1 ≤ L → (∀ i, 0 < H i) → 0 ≤ C → 0 ≤ B → 0 ≤ A → 0 < c → + 0 ≤ sourceRatio → 0 ≤ parameterRatio → rho⁻¹ ≤ Real.exp gridLog → A ≤ Real.exp ratioLog → + ∀ (hsiteLarge : ∀ i, 4 ≤ rho * H i) (hsiteWhole : ∀ i, rho * H i ≤ 2 * (N i : ℝ)), + (∀ i, (N i : ℝ) ≤ A * H i) → + (∀ i, 4 * Real.exp (gridLog + max ((pref + 2) ^ E) cellLog) ≤ H i) → + let P := normalizedBoxPartitions N H rho hsiteLarge hsiteWhole + let hpos := normalizedBoxPartitions_positive N H rho hsiteLarge hsiteWhole + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ h : (I → ℤ) → ℂ, + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N budget level (Real.exp (-budget)) → + ∀ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z) + (parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + (∀ i, c * H i ≤ ((sourceHi (none,i) - sourceLo (none,i) : ℤ) : ℝ)) → + (∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) → + (∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) → + (∀ j i, |(sourceLo (some j,i) : ℝ)| ≤ B * H i / L) → + (∀ j i, |(sourceHi (some j,i) : ℝ)| ≤ B * H i / L) → + 40 * (Fintype.card I : ℝ) * A / (rho * c) ≤ Real.exp meshLog → + 1 + (Fintype.card J : ℝ) * (C + B) ≤ Real.exp meshLog → + sourceRatio ≤ Real.exp meshLog → parameterRatio ≤ Real.exp meshLog → + (∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + sourceRatio * ((sourceHi z - sourceLo z).toNat : ℝ)) → + (∀ j, L / (D : ℝ) ≤ parameterRatio * ((parHi j - parLo j).toNat : ℝ)) → + 4 * Real.exp (4 * meshLog + 18 + cellLog + Z) ≤ L → + (∀ i, 4 * Real.exp (4 * meshLog + 18 + cellLog) * L ^ (Fintype.card J + 1) ≤ H i) → + (∀ w : (Option J × I → ℤ) → ℝ, + (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) → + |((integerBoxUniformWeights parLo parHi hpar).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hpos + (fun i => prime i ^ power i) b (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ + scalarTransferBaseAccuracy (3 * p)) → + (∀ w : (Option J × I → ℤ) → ℝ, + (∀ z : (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + 0 ≤ w (fun i => (z i).val) ∧ w (fun i => (z i).val) ≤ 1) → + |((integerBoxUniformWeights parLo parHi hpar).prod + (integerBoxUniformWeights sourceLo sourceHi hsource)).mean + (fun tz => w (fun i => (tz.2 i).val) * physicalBoxResidual lo N P hpos + (fun i => prime i ^ power i) b (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (tz.1 j).val) (fun i => (tz.2 i).val)))| ≤ + scalarTransferBaseAccuracy (3 * p)) → + ∀ outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + (∀ z, outer.weight z ≤ Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) → + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + obtain ⟨E, hE, href⟩ := exists_niltest_mesh_scalar_transfer.{u,v,w} s + refine ⟨E, hE, ?_⟩ + intro ι I V J _ _ _ _ _ _ _ _ _ _ d nilmanifold p epsilon Z U gridLog ratioLog meshLog level budget + hp hepsilon hepsilon1 hZ hU hmesh hpU htailU hZU hgridBudget hepsInv hlower hlevel + hI hsourceDim hJdim hJ g hcomplexity prime power _ hprime hinj hcount hmoduli D anchor hD hDlog + pref common Aref b beta cellLog hbudget hprecision haccMesh lo N H rho L C B A c sourceRatio parameterRatio + hrho hL hH hC hB hA hc hsRatio hpRatio hrhoInv hAlog hsiteLarge hsiteWhole hsize hfirstScale + P hpos hunit h hh hupper sourceLo sourceHi hsource parLo parHi hpar + hbaseWidth hparamLo hparamHi hsourceLo hsourceHi hboundary hmovement hsLog hpLog hsourceWidth hparameterWidth + hLscale hHscale heh heg outer hdom + have hp0 : 0 ≤ p := by linarith + have hT : 0 ≤ scalarTransferTail (3 * p) := by unfold scalarTransferTail; positivity + have hbase : 0 < scalarTransferBaseAccuracy (3 * p) := Real.exp_pos _ + have hbaseInv : (scalarTransferBaseAccuracy (3 * p))⁻¹ ≤ Real.exp U := by + simp only [scalarTransferBaseAccuracy, Real.exp_neg, inv_inv] + apply Real.exp_le_exp.mpr + unfold scalarTransferTail at htailU + linarith + have hrefInput := affineReferenceInput_bounds epsilon hU + have hmask := affineReferenceInput_mask_and_depth prime hprime hinj D hD hepsilon hepsilon1 hU + hp0 hT hZ hpU htailU hZU hepsInv (hDlog.trans (Real.exp_le_exp.mpr hZU)) + have hcommon : 0 ≤ common := (affineCommonReferenceBudget_bounds hE epsilon hU).1 + have hlogs := scalarTransferAllocatedLogs_bounds b hcommon hp0 hZ hU + have hcell : 0 ≤ cellLog := hlogs.2.2.1 + have hacc : 0 ≤ scalarTransferAccuracyLog b p Z := hlogs.2.1 + have hbeta : 0 < beta := Real.exp_pos _ + have hbeta1 : beta ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr hacc) + have hbetaInv : beta⁻¹ ≤ Real.exp meshLog := by + change (Real.exp (-scalarTransferAccuracyLog b p Z))⁻¹ ≤ _ + rw [Real.exp_neg, inv_inv] + exact Real.exp_le_exp.mpr haccMesh + have hside := adaptiveAffineSideLog_reference_bound hE hepsilon hepsilon1 hU hp0 hT hZ hZ + hpU htailU hZU hZU le_rfl hsourceDim hI hepsInv hbase hbaseInv + have hsideCell : adaptiveAffineSideLog Aref (Fintype.card (Option J × I)) (Fintype.card I) + epsilon p (scalarTransferTail (3 * p)) Z (scalarTransferBaseAccuracy (3 * p)) Z U ≤ cellLog := + hside.trans hlogs.2.2.2.1 + have hpair : Pairwise (fun i j => (prime i ^ power i).Coprime (prime j ^ power j)) := by + intro i j hij + exact Nat.Coprime.pow _ _ ((Nat.coprime_primes (hprime i) (hprime j)).mpr (fun h => hij (hinj h))) + have hUexp : U ≤ Real.exp U := by linarith [Real.add_one_le_exp U] + have hdimi : (Fintype.card I : ℝ) ≤ Real.exp U := hI.trans hUexp + have hdimj : (Fintype.card J : ℝ) ≤ Real.exp U := hJdim.trans hUexp + have hdimsource : (Fintype.card (Option J × I) : ℝ) ≤ Real.exp U := hsourceDim.trans hUexp + have hfirst (i) (ci) : Real.exp (max ((pref + 2) ^ E) cellLog) ≤ ((P i).length ci : ℝ) := + normalizedBoxPartitions_exp_lengths N H rho gridLog _ hrho hrhoInv hfirstScale hsiteLarge hsiteWhole i ci + have hcellSite (i) (ci) : Real.exp cellLog ≤ ((P i).length ci : ℝ) := + (Real.exp_le_exp.mpr (le_max_right _ _)).trans (hfirst i ci) + have hscales := affineNormalizedScales_lower (J := J) H hL hD (by omega : 1 ≤ Fintype.card J + 1) + hDlog hLscale hHscale + obtain ⟨S, T, hSstep, hSpos, hTstep, hTpos, hSlength, hTlength, hbad⟩ := + exists_allocated_affine_secondary_mesh sourceLo sourceHi hsource parLo parHi anchor hpar D hD + lo N H (by linarith : 0 < L) hH hC hB hA hc hrho hsRatio hpRatio hmesh hcell hbeta + hsiteLarge hsiteWhole hsize hbaseWidth hparamLo hparamHi hsourceLo hsourceHi + hboundary hmovement hsLog hpLog hbetaInv hsourceWidth hparameterWidth hscales.2.1 hscales.2.2 + have hsiteClose := ordinaryMesh_marginals_of_lengths lo N P hpos (fun i => prime i ^ power i) + hpair b Z U 0 cellLog 1 hZ le_rfl (by norm_num) hmoduli hdimi + (by simpa only [add_zero] using hlogs.2.2.2.2.2) hcellSite + have hparamClose := ordinaryMesh_marginals_of_lengths parLo (fun j => (parHi j - parLo j).toNat) + T hTpos (fun i => prime i ^ power i) hpair b Z U (scalarTransferAccuracyLog b p Z) cellLog beta + hZ hbeta1 le_rfl hmoduli hdimj hlogs.2.2.2.2.1 hTlength + have hcap := residueTruncationCap_le_exp b hZ (by norm_num : (0 : ℝ) ≤ 1) le_rfl hcount + have hcap0 := residueTruncationCap_nonneg ι b (by norm_num : (0 : ℝ) ≤ 1) + have herror := scalarTransfer_combined_error_le (targetLog := 3 * p) hepsilon.le hepsilon1 + ((Real.exp_pos (-p)).le.trans hlower) hlevel hcap0 hcap + apply href nilmanifold pref epsilon p (scalarTransferTail (3 * p)) Z (scalarTransferBaseAccuracy (3 * p)) Z U U level + hrefInput.1 hepsilon hp0 hT hZ hbase hZ (hZU.trans hrefInput.2.1) hU hU hmask.2.2 hlower hlevel + (hI.trans hrefInput.2.1) hcount hdimi hdimsource hJ g + (hcomplexity.mono (hpU.trans hrefInput.2.1)) prime power hprime hinj hmoduli D anchor hmask.1 hmask.2.1 + lo N P (normalizedBoxPartitions_step _ _ _ _ _) hpos hunit + (normalized_physical_cell_width_log_budget N H rho A gridLog ratioLog pref + (fun i => (hH i).le) hrho hA hsiteLarge hsiteWhole hsize hrhoInv hAlog + (hgridBudget.trans hrefInput.2.1)) h hh (hupper.from_exponential_budget hbudget hprecision) + sourceLo sourceHi S hSstep hSpos hsource ?_ ?_ + parLo parHi hpar T hTstep hTpos beta 1 beta (scalarTransferBaseAccuracy (3 * p)) + hbeta.le (by norm_num) hparamClose hsiteClose hbad heh heg p p outer hdom ?_ + · intro i ci + exact (Real.exp_le_exp.mpr (max_le_max le_rfl hsideCell)).trans (hfirst i ci) + · intro i ci + exact (Real.exp_le_exp.mpr hsideCell).trans (hSlength i ci) + · simpa only [beta, scalarTransferCapLog, b, Aref, show 2 * p + p = 3 * p by ring] using herror + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v + +theorem exists_niltest_initial_scalar_transfer (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {I : Type u} {V : Type v} {J : Type*} + [Fintype I] [Fintype J] [LieRing V] [LieAlgebra ℚ V] + [TopologicalSpace (ℝ ⊗[ℚ] V)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d0 : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d0) + (p epsilon P0 level budget : ℝ), + 2 ≤ p → 0 < epsilon → epsilon ≤ 1 → 0 ≤ P0 → 3 * p + 10 ≤ P0 → + epsilon⁻¹ ≤ Real.exp P0 → Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → 2 ≤ Fintype.card J → + (Fintype.card J : ℝ) ≤ Real.exp P0 → + (probabilityProfileLipschitz : ℝ) ≤ Real.exp P0 → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (k0 : J) (D : ℕ) (anchor parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + 0 < D → (D : ℝ) ≤ Real.exp P0 → + ∀ (L C B A K c Cwidth : ℝ), 1 ≤ L → 1 ≤ C → 0 ≤ B → 0 ≤ A → 0 ≤ K → 0 < c → 0 ≤ Cwidth → + C ≤ Real.exp P0 → B ≤ Real.exp P0 → A ≤ Real.exp P0 → K ≤ Real.exp P0 → + c⁻¹ ≤ Real.exp P0 → Cwidth ≤ Real.exp P0 → + ∀ (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ), + (∀ i, H i ≤ 2 * (N i : ℝ)) → (∀ i, (N i : ℝ) ≤ A * H i) → + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ h : (I → ℤ) → ℂ, + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N budget level (Real.exp (-budget)) → + ∀ (R : ℕ) (parMin : ℝ), 0 < parMin → + (∀ j, parMin ≤ ((parHi j - parLo j : ℤ) : ℝ)) → + (∀ j, parHi j - parLo j ≤ (R : ℤ)) → (R : ℝ) ≤ Cwidth * parMin → c * L ≤ parMin → + (∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) → + (∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) → + ∀ (origin sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z), + (∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + K * ((sourceHi z - sourceLo z : ℤ) : ℝ)) → + (∀ z ∈ Fintype.piFinset (fun i => Finset.Ico (sourceLo i) (sourceHi i)), ∀ i, + |(z i : ℝ) - (origin i : ℝ)| ≤ smoothPairCoefficientScale (H i.2) L i.1 / 2) → + (∀ j i, |(sourceLo (some j,i) : ℝ)| ≤ B * H i / L) → + (∀ j i, |(sourceHi (some j,i) : ℝ)| ≤ B * H i / L) → + let m := Fintype.card (Option J × I) + let n := Fintype.card I + let d := Fintype.card J + let Z := replacementCommonInputLog m n d P0 + let G := 2 * physicalPairCoefficientLog n d Z + 2 + let U := scalarInitialReferenceInput m n d p P0 + let pref := affineReferenceInput epsilon U + let common := affineCommonReferenceBudget E epsilon U + let b := adaptiveAffineCutoff ⌈(pref + 2) ^ E⌉₊ m n epsilon p + (scalarTransferTail (3 * p)) Z (scalarTransferBaseAccuracy (3 * p)) Z + let cellLog := scalarTransferCellLog common b p Z U + let meshLog := scalarMeshLog G (P0 + 1) (scalarTransferAccuracyLog b p Z) + (pref + 2) ^ E ≤ budget → p + scalarTransferTail (3 * p) + 4 ≤ budget → + Real.exp (Z + P0) ≤ L → + (∀ i, Real.exp (2 * physicalReplacementThresholdLog n (Fintype.card {j : J // j ≠ k0}) b Z + 16) * + L ^ (d + 1) ≤ H i) → + (∀ i, 4 * Real.exp (G + max ((pref + 2) ^ E) cellLog) ≤ H i) → + 4 * Real.exp (4 * meshLog + 18 + cellLog + Z) ≤ L → + (∀ i, 4 * Real.exp (4 * meshLog + 18 + cellLog) * L ^ (d + 1) ≤ H i) → + ∀ outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + (∀ z, outer.weight z ≤ Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) → + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + obtain ⟨E, hE, hgeom⟩ := exists_niltest_geometric_scalar_transfer.{u,v,0} s + refine ⟨E, hE, ?_⟩ + intro I V J _ _ _ _ _ _ _ _ d0 nilmanifold p epsilon P0 level budget + hp hepsilon hepsilon1 hP0 htarget hepsInv hlower hlevel hnP hJ hJlog hprofile g hcomplexity + k0 D anchor parLo parHi hpar hD hDlog L C B A K c Cwidth hL hC hB hA hK hc hCwidth + hClog hBlog hAlog hKlog hcinv hWidthlog lo N H hupper hratio hunit h hh hnoincrement + R parMin hparMin hparSide hparWidth hwidthRatio hrelative hleft hright + origin sourceLo sourceHi hsource hwinScale hW hsourceLo hsourceHi + m n d Z G U pref common b cellLog meshLog hbudget hprecision hLlog hsizeExp hfirstScale hLmesh hHmesh outer hdom + have hp0 : 0 ≤ p := by linarith + have hpP0 : p ≤ P0 := by linarith + have hP0exp : P0 ≤ Real.exp P0 := by linarith [Real.add_one_le_exp P0] + have hnlog : (n : ℝ) ≤ Real.exp P0 := hnP.trans (hpP0.trans hP0exp) + have hZdata := replacementCommonInputLog_bounds m n d hP0 + have hZ : 0 ≤ Z := hZdata.1 + have hP0Z : P0 ≤ Z := hZdata.2.1 + obtain ⟨hU, hZU, hGU, hP0U, hmU, hnU, hdU, hTU, hpU⟩ := scalarInitialReferenceInput_bounds m n d hp0 hP0 + have hG : 0 ≤ G := by + have hcoef := (physicalPairCoefficientLog_bounds n d hZ).1 + dsimp only [G] + linarith + have hbase : 0 < scalarTransferBaseAccuracy (3 * p) := Real.exp_pos _ + have hbaseInv : (scalarTransferBaseAccuracy (3 * p))⁻¹ ≤ Real.exp P0 := by + simp only [scalarTransferBaseAccuracy, Real.exp_neg, inv_inv] + exact Real.exp_le_exp.mpr htarget + have hepsU := hepsInv.trans (Real.exp_le_exp.mpr hP0U) + have hbaseU := hbaseInv.trans (Real.exp_le_exp.mpr hP0U) + have hT : 0 ≤ scalarTransferTail (3 * p) := by unfold scalarTransferTail; positivity + have hb := adaptiveAffineCutoff_reference_bounds hE hepsilon hepsilon1 hU hp0 hT hZ hZ + hpU hTU hZU hZU hmU hnU hepsU hbase hbaseU + have hdegree : 2 * Z ≤ (b : ℝ) := (mul_le_mul_of_nonneg_left hZU (by norm_num)).trans hb.1 + let tol := weightedReplacementTolerance ((3 * K) ^ m) ((2 : ℝ) ^ (n + 1) * A ^ n) + (scalarTransferBaseAccuracy (3 * p)) + let Q := D * integerBoxGcdCutoff d Cwidth tol + let κ := integerBoxRetainedGap d D c tol + let rho := physicalPairGridAccuracy n k0 C κ A tol + obtain ⟨htol, _, _, _, hQlog, _⟩ := replacement_selected_parameter_bounds m n d D hP0 hK hA hCwidth hc hbase hD + hDlog hKlog hAlog hWidthlog hcinv hbaseInv + have hrho := physicalPairGridAccuracy_spec n k0 C κ hA htol + have hrhoInvSmall := selectedPhysicalGrid_inverse_le_exp m n k0 D hP0 hK hA + (zero_le_one.trans hC) hCwidth hc hbase hD hnlog hJlog hDlog hKlog hAlog hClog hWidthlog hcinv hbaseInv hprofile + have hsmall : physicalPairCoefficientLog n (Fintype.card {j : J // j ≠ k0}) Z ≤ + physicalPairCoefficientLog n d Z := + physicalPairCoefficientLog_mono_dimension n (Fintype.card_subtype_le _) hZ + have hrhoInv : rho⁻¹ ≤ Real.exp G := hrhoInvSmall.trans (Real.exp_le_exp.mpr (by dsimp only [G]; linarith)) + have hcommon : 0 ≤ common := (affineCommonReferenceBudget_bounds hE epsilon hU).1 + have hlogs := scalarTransferAllocatedLogs_bounds b hcommon hp0 hZ hU + have hcell : 0 ≤ cellLog := hlogs.2.2.1 + have hacc : 0 ≤ scalarTransferAccuracyLog b p Z := hlogs.2.1 + have hmeshBounds := scalarMeshLog_bounds hG (by linarith : 0 ≤ P0 + 1) hacc + have hH (i) : 0 < H i := + (mul_pos (Real.exp_pos _) (pow_pos (by linarith : 0 < L) (d + 1))).trans_le (hsizeExp i) + have hlarge (i) : 4 ≤ rho * H i := + normalizedMesh_scale_large hrho.1 hrhoInv (hcell.trans (le_max_right _ _)) (hfirstScale i) + have hwhole (i) : rho * H i ≤ 2 * (N i : ℝ) := + ((mul_le_mul_of_nonneg_right hrho.2.1 (hH i).le).trans_eq (one_mul _)).trans (hupper i) + have hwidths := initialReplacement_mesh_widths sourceLo sourceHi parLo parHi hsource hpar H + (zero_le_one.trans hL) hK hc hD hwinScale (fun j => hrelative.trans (hparSide j)) + have hcSource : 0 < (K + 1)⁻¹ := inv_pos.mpr (by positivity) + have hPup : Real.exp P0 ≤ Real.exp (P0 + 1) := Real.exp_le_exp.mpr (by linarith) + have hcSourceLog : ((K + 1)⁻¹)⁻¹ ≤ Real.exp (P0 + 1) := by + simpa only [inv_inv, add_comm] using one_add_le_exp_succ hP0 hKlog + have hboundary := scalarMesh_boundary_bound (Nat.cast_nonneg n) hA hrho.1 hcSource hG + (by linarith : 0 ≤ P0 + 1) hacc (hnlog.trans hPup) (hAlog.trans hPup) hrhoInv hcSourceLog + have hmovement := scalarMesh_movement_bound (zero_le_one.trans hC) hB hG + (by linarith : 0 ≤ P0 + 1) hacc (hJlog.trans hPup) (hClog.trans hPup) (hBlog.trans hPup) + have hPMesh : P0 ≤ meshLog := (by linarith : P0 ≤ P0 + 1).trans hmeshBounds.2.1 + have hDlogZ := hDlog.trans (Real.exp_le_exp.mpr hP0Z) + have hprimeBounds := boundedPrimeFamily_log_bounds Q hQlog + let : ∀ i : BoundedPrime Q, NeZero (boundedPrime Q i ^ boundedPrimeExponent Q i) := + fun i => ⟨(boundedPrimePower_pos Q i).ne'⟩ + apply hgeom nilmanifold p epsilon Z U G P0 meshLog level budget + hp hepsilon hepsilon1 hZ hU hmeshBounds.1 hpU hTU hZU hGU hepsU hlower hlevel hnU hmU hdU hJ + g hcomplexity (boundedPrime Q) (boundedPrimeExponent Q) (boundedPrime_prime Q) (boundedPrime_injective Q) + hprimeBounds.1 hprimeBounds.2 D anchor hD hDlogZ hbudget hprecision hmeshBounds.2.2.1 + lo N H rho L C B A ((K + 1)⁻¹) K c⁻¹ hrho.1 hL hH (zero_le_one.trans hC) hB hA hcSource hK + (inv_nonneg.mpr hc.le) hrhoInv hAlog hlarge hwhole hratio hfirstScale hunit h hh hnoincrement + sourceLo sourceHi hsource parLo parHi hpar hwidths.1 hleft hright hsourceLo hsourceHi hboundary hmovement + (hKlog.trans (Real.exp_le_exp.mpr hPMesh)) (hcinv.trans (Real.exp_le_exp.mpr hPMesh)) + hwidths.2.1 hwidths.2.2 hLmesh hHmesh ?_ ?_ outer hdom + · intro w hw + exact initial_budget_joint_physical_replacement k0 D anchor parLo parHi hpar H hL hC hA hbase hK hc hCwidth hD + hleft hright origin lo N b (d + 1) (by omega) (fun z => (h z).re) hh P0 hP0 hnlog hJlog + hDlog hKlog hAlog hClog hWidthlog hcinv hbaseInv hprofile hupper hratio R parMin hparMin hJ + hparSide hparWidth hwidthRatio hrelative sourceLo sourceHi hsource hwinScale w hw + hLlog hdegree hsizeExp hW + · intro w hw + exact initial_budget_joint_physical_replacement k0 D anchor parLo parHi hpar H hL hC hA hbase hK hc hCwidth hD + hleft hright origin lo N b (d + 1) (by omega) (fun z => (g.eval z).re) (fun z hz => (hunit z hz).2) + P0 hP0 hnlog hJlog hDlog hKlog hAlog hClog hWidthlog hcinv hbaseInv hprofile hupper hratio + R parMin hparMin hJ hparSide hparWidth hwidthRatio hrelative sourceLo sourceHi hsource hwinScale w hw + hLlog hdegree hsizeExp hW + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v + +theorem exists_niltest_threshold_scalar_transfer (s : ℕ) : + ∃ E : ℕ, 2 ≤ E ∧ ∀ {I : Type u} {V : Type v} {J : Type*} + [Fintype I] [Fintype J] [LieRing V] [LieAlgebra ℚ V] + [TopologicalSpace (ℝ ⊗[ℚ] V)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d0 : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d0) + (p epsilon P0 level budget : ℝ), + 2 ≤ p → 0 < epsilon → epsilon ≤ 1 → 0 ≤ P0 → 3 * p + 10 ≤ P0 → + epsilon⁻¹ ≤ Real.exp P0 → Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → 2 ≤ Fintype.card J → + (Fintype.card J : ℝ) ≤ Real.exp P0 → + (probabilityProfileLipschitz : ℝ) ≤ Real.exp P0 → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (_k0 : J) (D : ℕ) (anchor parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + 0 < D → (D : ℝ) ≤ Real.exp P0 → + ∀ (L C B A K c Cwidth : ℝ), 1 ≤ C → 0 ≤ B → 0 ≤ A → 0 ≤ K → 0 < c → 0 ≤ Cwidth → + C ≤ Real.exp P0 → B ≤ Real.exp P0 → A ≤ Real.exp P0 → K ≤ Real.exp P0 → + c⁻¹ ≤ Real.exp P0 → Cwidth ≤ Real.exp P0 → + ∀ (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ), + (∀ i, H i ≤ 2 * (N i : ℝ)) → (∀ i, (N i : ℝ) ≤ A * H i) → + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ h : (I → ℤ) → ℂ, + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N budget level (Real.exp (-budget)) → + ∀ (R : ℕ) (parMin : ℝ), 0 < parMin → + (∀ j, parMin ≤ ((parHi j - parLo j : ℤ) : ℝ)) → + (∀ j, parHi j - parLo j ≤ (R : ℤ)) → (R : ℝ) ≤ Cwidth * parMin → c * L ≤ parMin → + (∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) → + (∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) → + ∀ (origin sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z), + (∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + K * ((sourceHi z - sourceLo z : ℤ) : ℝ)) → + (∀ z ∈ Fintype.piFinset (fun i => Finset.Ico (sourceLo i) (sourceHi i)), ∀ i, + |(z i : ℝ) - (origin i : ℝ)| ≤ smoothPairCoefficientScale (H i.2) L i.1 / 2) → + (∀ j i, |(sourceLo (some j,i) : ℝ)| ≤ B * H i / L) → + (∀ j i, |(sourceHi (some j,i) : ℝ)| ≤ B * H i / L) → + let m := Fintype.card (Option J × I) + let n := Fintype.card I + let d := Fintype.card J + let Z := replacementCommonInputLog m n d P0 + let G := 2 * physicalPairCoefficientLog n d Z + 2 + let U := scalarInitialReferenceInput m n d p P0 + let pref := affineReferenceInput epsilon U + let common := affineCommonReferenceBudget E epsilon U + let b := adaptiveAffineCutoff ⌈(pref + 2) ^ E⌉₊ m n epsilon p + (scalarTransferTail (3 * p)) Z (scalarTransferBaseAccuracy (3 * p)) Z + let cellLog := scalarTransferCellLog common b p Z U + let meshLog := scalarMeshLog G (P0 + 1) (scalarTransferAccuracyLog b p Z) + scalarCombinedLogThreshold n d b p P0 Z G ((pref + 2) ^ E) cellLog meshLog ≤ budget → + Real.exp budget ≤ L → (∀ i, Real.exp budget * L ^ (d + 1) ≤ H i) → + ∀ outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + (∀ z, outer.weight z ≤ Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) → + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + obtain ⟨E, hE, hinitial⟩ := exists_niltest_initial_scalar_transfer.{u,v} s + refine ⟨E, hE, ?_⟩ + intro I V J _ _ _ _ _ _ _ _ d0 nilmanifold p epsilon P0 level budget + hp hepsilon hepsilon1 hP0 htarget hepsInv hlower hlevel hnP hJ hJlog hprofile g hcomplexity + k0 D anchor parLo parHi hpar hD hDlog L C B A K c Cwidth hC hB hA hK hc hCwidth + hClog hBlog hAlog hKlog hcinv hWidthlog lo N H hupper hratio hunit h hh hnoincrement + R parMin hparMin hparSide hparWidth hwidthRatio hrelative hleft hright + origin sourceLo sourceHi hsource hwinScale hW hsourceLo hsourceHi + m n d Z G U pref common b cellLog meshLog hbudget hLexp hHexp outer hdom + have hp0 : 0 ≤ p := by linarith + have hZ : 0 ≤ Z := (replacementCommonInputLog_bounds m n d hP0).1 + have hG : 0 ≤ G := by + have h := (physicalPairCoefficientLog_bounds n d hZ).1 + dsimp only [G]; linarith + have hU : 0 ≤ U := (scalarInitialReferenceInput_bounds m n d hp0 hP0).1 + have hpref : 0 ≤ pref + 2 := by + have h := (affineReferenceInput_bounds epsilon hU).1 + dsimp only [pref]; linarith + have hcost : 0 ≤ (pref + 2) ^ E := pow_nonneg hpref E + have hcommon : 0 ≤ common := (affineCommonReferenceBudget_bounds hE epsilon hU).1 + have hlogs := scalarTransferAllocatedLogs_bounds b hcommon hp0 hZ hU + have hcell : 0 ≤ cellLog := hlogs.2.2.1 + have hmesh : 0 ≤ meshLog := (scalarMeshLog_bounds hG (by linarith : 0 ≤ P0 + 1) hlogs.2.1).1 + obtain ⟨_, hcostBudget, hprecision, _, _, _, _⟩ := + scalarCombinedLogThreshold_bounds n d b hp0 hP0 hZ hG hcost hcell hmesh + obtain ⟨hL, hLlog, hRsize, hFsize, hLmesh, hHmesh⟩ := + scalarCombinedLogThreshold_size_conditions n d b (d + 1) H hp0 hP0 hZ hG hcost hcell hmesh hbudget hLexp hHexp + have hRother (i) : Real.exp (2 * physicalReplacementThresholdLog n (Fintype.card {j : J // j ≠ k0}) b Z + 16) * + L ^ (d + 1) ≤ H i := by + have hmono := physicalReplacementThresholdLog_mono_dimension n b (Fintype.card_subtype_le (fun j : J => j ≠ k0)) hZ + exact (mul_le_mul_of_nonneg_right (Real.exp_le_exp.mpr (by linarith)) + (pow_nonneg (zero_le_one.trans hL) (d + 1))).trans (hRsize i) + exact hinitial nilmanifold p epsilon P0 level budget hp hepsilon hepsilon1 hP0 htarget hepsInv hlower hlevel + hnP hJ hJlog hprofile g hcomplexity k0 D anchor parLo parHi hpar hD hDlog + L C B A K c Cwidth hL hC hB hA hK hc hCwidth hClog hBlog hAlog hKlog hcinv hWidthlog + lo N H hupper hratio hunit h hh hnoincrement R parMin hparMin hparSide hparWidth hwidthRatio hrelative + hleft hright origin sourceLo sourceHi hsource hwinScale hW hsourceLo hsourceHi + (hcostBudget.trans hbudget) (hprecision.trans hbudget) hLlog hRother hFsize hLmesh hHmesh outer hdom + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v + +theorem exists_niltest_polynomial_window_transfer (s ell A0 : ℕ) + (hell : 2 ≤ ell) (hA0 : 10 ≤ A0) {epsilon : ℝ} + (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) + (heps0 : epsilon⁻¹ ≤ Real.exp (A0 : ℝ)) + (hell0 : (ell : ℝ) ≤ Real.exp (A0 : ℝ)) + (hprofile0 : (probabilityProfileLipschitz : ℝ) ≤ Real.exp (A0 : ℝ)) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {I : Type u} {V : Type v} {J : Type*} + [Fintype I] [Fintype J] [LieRing V] [LieAlgebra ℚ V] + [TopologicalSpace (ℝ ⊗[ℚ] V)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d0 : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d0) + (p level : ℝ), + 2 ≤ p → + let P0 := (A0 : ℝ) * (p + 1) + let budget := (p + 2) ^ C + Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → Fintype.card J = ell → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (D : ℕ) (anchor parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + 0 < D → (D : ℝ) ≤ Real.exp P0 → + ∀ (L C B A K c Cwidth : ℝ), 1 ≤ C → 0 ≤ B → 0 ≤ A → 0 ≤ K → 0 < c → 0 ≤ Cwidth → + C ≤ Real.exp P0 → B ≤ Real.exp P0 → A ≤ Real.exp P0 → K ≤ Real.exp P0 → + c⁻¹ ≤ Real.exp P0 → Cwidth ≤ Real.exp P0 → + ∀ (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ), + (∀ i, H i ≤ 2 * (N i : ℝ)) → (∀ i, (N i : ℝ) ≤ A * H i) → + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ h : (I → ℤ) → ℂ, + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N budget level (Real.exp (-budget)) → + ∀ (R : ℕ) (parMin : ℝ), 0 < parMin → + (∀ j, parMin ≤ ((parHi j - parLo j : ℤ) : ℝ)) → + (∀ j, parHi j - parLo j ≤ (R : ℤ)) → (R : ℝ) ≤ Cwidth * parMin → c * L ≤ parMin → + (∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) → + (∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) → + ∀ (origin sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z), + (∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + K * ((sourceHi z - sourceLo z : ℤ) : ℝ)) → + (∀ z ∈ Fintype.piFinset (fun i => Finset.Ico (sourceLo i) (sourceHi i)), ∀ i, + |(z i : ℝ) - (origin i : ℝ)| ≤ smoothPairCoefficientScale (H i.2) L i.1 / 2) → + (∀ j i, |(sourceLo (some j,i) : ℝ)| ≤ B * H i / L) → + (∀ j i, |(sourceHi (some j,i) : ℝ)| ≤ B * H i / L) → + Real.exp budget ≤ L → (∀ i, Real.exp budget * L ^ (ell + 1) ≤ H i) → + ∀ outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + (∀ z, outer.weight z ≤ Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) → + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + obtain ⟨E, hE, htransfer⟩ := exists_niltest_threshold_scalar_transfer.{u,v} s + obtain ⟨Cexp, hCexp, hpower⟩ := exists_scalarInitialThreshold_power E ell A0 hE hepsilon hepsilon1 + refine ⟨Cexp, hCexp, ?_⟩ + intro I V J _ _ _ _ _ _ _ _ d0 nilmanifold p level hp P0 budget + hlower hlevel hnP hJ g hcomplexity D anchor parLo parHi hpar hD hDlog + L C B A K c Cwidth hC hB hA hK hc hCwidth hClog hBlog hAlog hKlog hcinv hWidthlog + lo N H hupper hratio hunit h hh hnoincrement R parMin hparMin hparSide hparWidth hwidthRatio hrelative + hleft hright origin sourceLo sourceHi hsource hwinScale hW hsourceLo hsourceHi hLexp hHexp outer hdom + have hp0 : 0 ≤ p := by linarith + have hA0real : (10 : ℝ) ≤ A0 := by exact_mod_cast hA0 + have hA0P0 : (A0 : ℝ) ≤ P0 := by + dsimp only [P0] + nlinarith [mul_nonneg (Nat.cast_nonneg A0) hp0] + have hP0 : 0 ≤ P0 := (Nat.cast_nonneg A0).trans hA0P0 + have htarget : 3 * p + 10 ≤ P0 := by + have hmul := mul_le_mul_of_nonneg_right hA0real (by linarith : 0 ≤ p + 1) + dsimp only [P0] + nlinarith + have hexp := Real.exp_le_exp.mpr hA0P0 + have hepsP0 : epsilon⁻¹ ≤ Real.exp P0 := heps0.trans hexp + have hJlog : (Fintype.card J : ℝ) ≤ Real.exp P0 := by + simpa only [hJ] using hell0.trans hexp + have hprofile : (probabilityProfileLipschitz : ℝ) ≤ Real.exp P0 := hprofile0.trans hexp + have hJtwo : 2 ≤ Fintype.card J := by omega + let : Nonempty J := Fintype.card_pos_iff.mp (by omega) + let k0 : J := Classical.choice (inferInstance : Nonempty J) + have hm : (Fintype.card (Option J × I) : ℝ) ≤ (ell + 1 : ℝ) * p := by + rw [Fintype.card_prod, Fintype.card_option, hJ] + push_cast + exact mul_le_mul_of_nonneg_left hnP (by positivity) + have hbound : scalarInitialThreshold E (Fintype.card (Option J × I)) (Fintype.card I) + (Fintype.card J) epsilon p P0 ≤ budget := by + simpa only [hJ] using hpower (Fintype.card (Option J × I)) (Fintype.card I) p hp hm hnP hepsP0 + exact htransfer nilmanifold p epsilon P0 level budget hp hepsilon hepsilon1 hP0 htarget hepsP0 hlower hlevel + hnP hJtwo hJlog hprofile g hcomplexity k0 D anchor parLo parHi hpar hD hDlog + L C B A K c Cwidth hC hB hA hK hc hCwidth hClog hBlog hAlog hKlog hcinv hWidthlog + lo N H hupper hratio hunit h hh hnoincrement R parMin hparMin hparSide hparWidth hwidthRatio hrelative + hleft hright origin sourceLo sourceHi hsource hwinScale hW hsourceLo hsourceHi hbound hLexp + (by simpa only [hJ] using hHexp) outer hdom + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v + +theorem exists_niltest_polynomial_box_transfer (s ell A0 : ℕ) + (hell : 2 ≤ ell) (hA0 : 10 ≤ A0) {epsilon : ℝ} + (hepsilon : 0 < epsilon) (hepsilon1 : epsilon ≤ 1) + (heps0 : epsilon⁻¹ ≤ Real.exp (A0 : ℝ)) + (hell0 : (ell : ℝ) ≤ Real.exp (A0 : ℝ)) + (hprofile0 : (probabilityProfileLipschitz : ℝ) ≤ Real.exp (A0 : ℝ)) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {I : Type u} {V : Type v} {J : Type*} + [Fintype I] [Fintype J] [LieRing V] [LieAlgebra ℚ V] + [TopologicalSpace (ℝ ⊗[ℚ] V)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d0 : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d0) + (p level : ℝ), + 2 ≤ p → + let P0 := (A0 : ℝ) * (p + 1) + let budget := (p + 2) ^ C + Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → Fintype.card J = ell → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (D : ℕ) (anchor parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + 0 < D → (D : ℝ) ≤ Real.exp P0 → + ∀ (L C B A K c Cwidth : ℝ), 1 ≤ C → 0 ≤ B → 0 ≤ A → 0 ≤ K → 0 < c → 0 ≤ Cwidth → + C ≤ Real.exp P0 → B ≤ Real.exp P0 → A ≤ Real.exp P0 → K + 8 ≤ Real.exp P0 → + c⁻¹ ≤ Real.exp P0 → Cwidth ≤ Real.exp P0 → + ∀ (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ), + (∀ i, H i ≤ 2 * (N i : ℝ)) → (∀ i, (N i : ℝ) ≤ A * H i) → + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ h : (I → ℤ) → ℂ, + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N budget level (Real.exp (-budget)) → + ∀ (R : ℕ) (parMin : ℝ), 0 < parMin → + (∀ j, parMin ≤ ((parHi j - parLo j : ℤ) : ℝ)) → + (∀ j, parHi j - parLo j ≤ (R : ℤ)) → (R : ℝ) ≤ Cwidth * parMin → c * L ≤ parMin → + (∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) → + (∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) → + ∀ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z), + (∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + K * ((sourceHi z - sourceLo z : ℤ) : ℝ)) → + (∀ j i, |(sourceLo (some j,i) : ℝ)| ≤ B * H i / L) → + (∀ j i, |(sourceHi (some j,i) : ℝ)| ≤ B * H i / L) → + Real.exp budget ≤ L → (∀ i, Real.exp budget * L ^ (ell + 1) ≤ H i) → + (integerBoxUniformWeights sourceLo sourceHi hsource).eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + obtain ⟨Cexp, hCexp, htransfer⟩ := exists_niltest_polynomial_window_transfer.{u,v} s ell A0 + hell hA0 hepsilon hepsilon1 heps0 hell0 hprofile0 + refine ⟨Cexp, hCexp, ?_⟩ + intro I V J _ _ _ _ _ _ _ _ d0 nilmanifold p level hp P0 budget + hlower hlevel hnP hJ g hcomplexity D anchor parLo parHi hpar hD hDlog + L C B A K c Cwidth hC hB hA hK hc hCwidth hClog hBlog hAlog hKlog hcinv hWidthlog + lo N H hupper hratio hunit h hh hnoincrement R parMin hparMin hparSide hparWidth hwidthRatio hrelative + hleft hright sourceLo sourceHi hsource hwinScale hsourceLo hsourceHi hLexp hHexp + have hp0 : 0 ≤ p := by linarith + have hbudget : 4 ≤ budget := calc + 4 ≤ p + 2 := by linarith + _ = (p + 2) ^ 1 := (pow_one _).symm + _ ≤ (p + 2) ^ Cexp := pow_le_pow_right₀ (by linarith) (by omega) + have hexp : 4 ≤ Real.exp budget := by linarith [Real.add_one_le_exp budget] + have hL : 1 ≤ L := by linarith + let scale := fun z : Option J × I => smoothPairCoefficientScale (H z.2) L z.1 + have hscale : ∀ z, 4 ≤ scale z := by + rintro ⟨j,i⟩ + have h := affinePhysicalScales_lower hL (Real.exp_pos budget).le (by omega : 1 ≤ ell + 1) (hHexp i) + cases j with + | none => exact hexp.trans h.1 + | some j => exact hexp.trans h.2 + have hcount (z) : (((sourceHi z - sourceLo z).toNat : ℕ) : ℝ) = + ((sourceHi z - sourceLo z : ℤ) : ℝ) := by + exact_mod_cast Int.toNat_of_nonneg (sub_nonneg.mpr (hsource z).le) + obtain ⟨S, hSstep, hSpos, hSlength, hSratio⟩ := exists_scalarWindowPartitions + (fun z => (sourceHi z - sourceLo z).toNat) scale K + (fun z => by have hz := hsource z; omega) hscale hK + (fun z => by rw [hcount]; exact hwinScale z) + let event := fun z : Option J × I → ℤ => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (h y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) z) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (g.eval y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) z)) + change (integerBoxUniformWeights sourceLo sourceHi hsource).eventProbability + (fun z => event (fun i => (z i).val)) ≤ Real.exp (-p) + apply integerBox_partition_eventProbability_le sourceLo sourceHi hsource S hSstep hSpos event + intro label + let slo := fun i => intervalCellLower (sourceLo i) (S i) (label i) + let shi := fun i => slo i + (S i).length (label i) + have hpositive : ∀ i, slo i < shi i := + fun i => lt_add_of_pos_right _ (by exact_mod_cast hSpos i (label i)) + have hratio' : ∀ z : Option J × I, scale z ≤ (K + 8) * ((shi z - slo z : ℤ) : ℝ) := by + intro z + simpa only [shi, add_sub_cancel_left, Int.cast_natCast] using hSratio z (label z) + have hwindow := htransfer nilmanifold p level hp hlower hlevel hnP hJ g hcomplexity + D anchor parLo parHi hpar hD hDlog L C B A (K + 8) c Cwidth hC hB hA (by linarith) hc hCwidth + hClog hBlog hAlog hKlog hcinv hWidthlog lo N H hupper hratio hunit h hh hnoincrement + R parMin hparMin hparSide hparWidth hwidthRatio hrelative hleft hright + slo slo shi hpositive hratio' + (integerWindow_cell_half_scale sourceLo sourceHi S scale label (fun i => hSlength i (label i))) + (fun j i => (integerWindow_cell_endpoint_abs (hsource (some j,i)) (hsourceLo j i) (hsourceHi j i) + (S (some j,i)) (hSstep (some j,i)) (label (some j,i)) (hSpos (some j,i) _)).1) + (fun j i => (integerWindow_cell_endpoint_abs (hsource (some j,i)) (hsourceLo j i) (hsourceHi j i) + (S (some j,i)) (hSstep (some j,i)) (label (some j,i)) (hSpos (some j,i) _)).2) + hLexp hHexp (integerBoxUniformWeights slo shi hpositive) + apply hwindow + intro z + have hone : 1 ≤ Real.exp p := by simpa only [Real.exp_zero] using Real.exp_le_exp.mpr hp0 + exact le_mul_of_one_le_left ((integerBoxUniformWeights slo shi hpositive).nonneg z) hone + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v + +theorem exists_niltest_window_scalar_transfer (s ell : ℕ) (hell : 2 ≤ ell) + {epsilon : ℝ} (hepsilon : 0 < epsilon) : + ∃ A0 C : ℕ, 10 ≤ A0 ∧ 2 ≤ C ∧ ∀ {I : Type u} {V : Type v} {J : Type*} + [Fintype I] [Fintype J] [LieRing V] [LieAlgebra ℚ V] + [TopologicalSpace (ℝ ⊗[ℚ] V)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d0 : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d0) + (p level : ℝ), + 2 ≤ p → + let P0 := (A0 : ℝ) * (p + 1) + let budget := (p + 2) ^ C + Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → Fintype.card J = ell → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (D : ℕ) (anchor parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + 0 < D → (D : ℝ) ≤ Real.exp P0 → + ∀ (L C B A K c Cwidth : ℝ), 1 ≤ C → 0 ≤ B → 0 ≤ A → 0 ≤ K → 0 < c → 0 ≤ Cwidth → + C ≤ Real.exp P0 → B ≤ Real.exp P0 → A ≤ Real.exp P0 → K ≤ Real.exp P0 → + c⁻¹ ≤ Real.exp P0 → Cwidth ≤ Real.exp P0 → + ∀ (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ), + (∀ i, H i ≤ 2 * (N i : ℝ)) → (∀ i, (N i : ℝ) ≤ A * H i) → + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ h : (I → ℤ) → ℂ, + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N budget level (Real.exp (-budget)) → + ∀ (R : ℕ) (parMin : ℝ), 0 < parMin → + (∀ j, parMin ≤ ((parHi j - parLo j : ℤ) : ℝ)) → + (∀ j, parHi j - parLo j ≤ (R : ℤ)) → (R : ℝ) ≤ Cwidth * parMin → c * L ≤ parMin → + (∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) → + (∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) → + ∀ (origin sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z), + (∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + K * ((sourceHi z - sourceLo z : ℤ) : ℝ)) → + (∀ z ∈ Fintype.piFinset (fun i => Finset.Ico (sourceLo i) (sourceHi i)), ∀ i, + |(z i : ℝ) - (origin i : ℝ)| ≤ smoothPairCoefficientScale (H i.2) L i.1 / 2) → + (∀ j i, |(sourceLo (some j,i) : ℝ)| ≤ B * H i / L) → + (∀ j i, |(sourceHi (some j,i) : ℝ)| ≤ B * H i / L) → + Real.exp budget ≤ L → (∀ i, Real.exp budget * L ^ (ell + 1) ≤ H i) → + ∀ outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + (∀ z, outer.weight z ≤ Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) → + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + let small := min epsilon 1 + have hsmall : 0 < small := lt_min hepsilon zero_lt_one + have hsmall1 : small ≤ 1 := min_le_right _ _ + obtain ⟨A0, hA0, heps0, hell0, hprofile0⟩ := exists_scalarInputLogFactor ell small + obtain ⟨Cexp, hCexp, htransfer⟩ := exists_niltest_polynomial_window_transfer s ell A0 hell hA0 hsmall hsmall1 + heps0 hell0 hprofile0 + refine ⟨A0, Cexp, hA0, hCexp, ?_⟩ + intro I V J _ _ _ _ _ _ _ _ d0 nilmanifold p level hp P0 budget + hlower hlevel hnP hJ g hcomplexity D anchor parLo parHi hpar hD hDlog + L C B A K c Cwidth hC hB hA hK hc hCwidth hClog hBlog hAlog hKlog hcinv hWidthlog + lo N H hupper hratio hunit h hh hnoincrement R parMin hparMin hparSide hparWidth hwidthRatio hrelative + hleft hright origin sourceLo sourceHi hsource hwinScale hW hsourceLo hsourceHi hLexp hHexp outer hdom + have hsmallBound := htransfer nilmanifold p level hp hlower hlevel hnP hJ g hcomplexity + D anchor parLo parHi hpar hD hDlog L C B A K c Cwidth hC hB hA hK hc hCwidth + hClog hBlog hAlog hKlog hcinv hWidthlog lo N H hupper hratio hunit h hh hnoincrement + R parMin hparMin hparSide hparWidth hwidthRatio hrelative hleft hright + origin sourceLo sourceHi hsource hwinScale hW hsourceLo hsourceHi hLexp hHexp outer hdom + have hg0 (x : I → ℤ) : 0 ≤ realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (g.eval y).re) x := + (realZeroExtendFinset_unit _ _ (fun y hy => (hunit y hy).2) x).1 + exact fixedParameter_scalar_tail_mono_slack outer (integerBoxUniformWeights parLo parHi hpar) + (fun z t => realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (h y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val))) + (fun z t => realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (g.eval y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val))) + (fun _ _ => hg0 _) ((Real.exp_pos (-p)).le.trans hlower) (show small ≤ epsilon from min_le_left _ _) + hsmallBound + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v + +theorem exists_niltest_box_scalar_transfer (s ell minimumLogFactor : ℕ) (hell : 2 ≤ ell) + {epsilon : ℝ} (hepsilon : 0 < epsilon) : + ∃ A0 C : ℕ, minimumLogFactor ≤ A0 ∧ 10 ≤ A0 ∧ 2 ≤ C ∧ ∀ {I : Type u} {V : Type v} {J : Type*} + [Fintype I] [Fintype J] [LieRing V] [LieAlgebra ℚ V] + [TopologicalSpace (ℝ ⊗[ℚ] V)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d0 : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d0) + (p level : ℝ), + 2 ≤ p → + let P0 := (A0 : ℝ) * (p + 1) + let budget := (p + 2) ^ C + Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → Fintype.card J = ell → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (D : ℕ) (anchor parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + 0 < D → (D : ℝ) ≤ Real.exp P0 → + ∀ (L C B A K c Cwidth : ℝ), 1 ≤ C → 0 ≤ B → 0 ≤ A → 0 ≤ K → 0 < c → 0 ≤ Cwidth → + C ≤ Real.exp P0 → B ≤ Real.exp P0 → A ≤ Real.exp P0 → K ≤ Real.exp P0 → + c⁻¹ ≤ Real.exp P0 → Cwidth ≤ Real.exp P0 → + ∀ (lo : I → ℤ) (N : I → ℕ) (H : I → ℝ), + (∀ i, H i ≤ 2 * (N i : ℝ)) → (∀ i, (N i : ℝ) ≤ A * H i) → + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ h : (I → ℤ) → ℂ, + (∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1) → + ResidueSliceUpperComparison h g.eval lo N budget level (Real.exp (-budget)) → + ∀ (R : ℕ) (parMin : ℝ), 0 < parMin → + (∀ j, parMin ≤ ((parHi j - parLo j : ℤ) : ℝ)) → + (∀ j, parHi j - parLo j ≤ (R : ℤ)) → (R : ℝ) ≤ Cwidth * parMin → c * L ≤ parMin → + (∀ j, |((anchor j + (D : ℤ) * parLo j : ℤ) : ℝ) / L| ≤ C) → + (∀ j, |((anchor j + (D : ℤ) * parHi j : ℤ) : ℝ) / L| ≤ C) → + ∀ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z), + (∀ z : Option J × I, smoothPairCoefficientScale (H z.2) L z.1 ≤ + K * ((sourceHi z - sourceLo z : ℤ) : ℝ)) → + (∀ j i, |(sourceLo (some j,i) : ℝ)| ≤ B * H i / L) → + (∀ j i, |(sourceHi (some j,i) : ℝ)| ≤ B * H i / L) → + Real.exp budget ≤ L → (∀ i, Real.exp budget * L ^ (ell + 1) ≤ H i) → + ∀ outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + (∀ z, outer.weight z ≤ Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) → + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (h z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun z => (g.eval z).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + let small := min epsilon 1 + have hsmall : 0 < small := lt_min hepsilon zero_lt_one + have hsmall1 : small ≤ 1 := min_le_right _ _ + obtain ⟨A, hA, heps0, hell0, hprofile0⟩ := exists_scalarInputLogFactor ell small + let A0 := max minimumLogFactor A + have hAA0 : A ≤ A0 := le_max_right _ _ + have hA0 : 10 ≤ A0 := hA.trans hAA0 + have hexpA : Real.exp (A : ℝ) ≤ Real.exp (A0 : ℝ) := Real.exp_le_exp.mpr (by exact_mod_cast hAA0) + obtain ⟨Cexp, hCexp, htransfer⟩ := exists_niltest_polynomial_box_transfer.{u,v} s ell A0 hell hA0 + hsmall hsmall1 (heps0.trans hexpA) (hell0.trans hexpA) (hprofile0.trans hexpA) + refine ⟨A0, 2 * Cexp, le_max_left _ _, hA0, by omega, ?_⟩ + intro I V J _ _ _ _ _ _ _ _ d0 nilmanifold p level hp P0 budget + hlower hlevel hnP hJ g hcomplexity D anchor parLo parHi hpar hD hDlog + L C B A K c Cwidth hC hB hA hK hc hCwidth hClog hBlog hAlog hKlog hcinv hWidthlog + lo N H hupper hratio hunit h hh hnoincrement R parMin hparMin hparSide hparWidth hwidthRatio hrelative + hleft hright sourceLo sourceHi hsource hwinScale hsourceLo hsourceHi hLexp hHexp outer hdom + have hp0 : 0 ≤ p := by linarith + have hbudget : (2 * p + 2) ^ Cexp ≤ budget := scalarTransfer_doubled_budget Cexp hp + have hlog8 : Real.exp P0 + 8 ≤ Real.exp ((A0 : ℝ) * (2 * p + 1)) := + scalarTransfer_doubled_log A0 hA0 hp + have hlog : Real.exp P0 ≤ Real.exp ((A0 : ℝ) * (2 * p + 1)) := by linarith + have hKlog' : K + 8 ≤ Real.exp ((A0 : ℝ) * (2 * p + 1)) := by linarith + have hLpos : 0 < L := (Real.exp_pos budget).trans_le hLexp + have hexpbudget := Real.exp_le_exp.mpr hbudget + have hraw := htransfer nilmanifold (2 * p) level (by linarith) + ((Real.exp_le_exp.mpr (by linarith : -(2 * p) ≤ -p)).trans hlower) hlevel + (hnP.trans (by linarith)) hJ g (hcomplexity.mono (by linarith)) + D anchor parLo parHi hpar hD (hDlog.trans hlog) L C B A K c Cwidth hC hB hA hK hc hCwidth + (hClog.trans hlog) (hBlog.trans hlog) (hAlog.trans hlog) hKlog' (hcinv.trans hlog) (hWidthlog.trans hlog) + lo N H hupper hratio hunit h hh + (hnoincrement.restrict_budget_and_error hbudget (Real.exp_le_exp.mpr (neg_le_neg hbudget))) + R parMin hparMin hparSide hparWidth hwidthRatio hrelative hleft hright + sourceLo sourceHi hsource hwinScale hsourceLo hsourceHi (hexpbudget.trans hLexp) + (fun i => (mul_le_mul_of_nonneg_right hexpbudget (pow_nonneg hLpos.le _)).trans (hHexp i)) + have hg0 (x : I → ℤ) : 0 ≤ realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (g.eval y).re) x := + (realZeroExtendFinset_unit _ _ (fun y hy => (hunit y hy).2) x).1 + exact fixedParameter_scalar_tail_dominated_slack (integerBoxUniformWeights sourceLo sourceHi hsource) + outer (integerBoxUniformWeights parLo parHi hpar) + (fun z t => realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (h y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val))) + (fun z t => realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (g.eval y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val))) + hp0 hdom (fun _ _ => hg0 _) ((Real.exp_pos (-p)).le.trans hlower) + (show small ≤ epsilon from min_le_left _ _) hraw + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct BigOperators Classical + +universe u v + +theorem exists_niltest_scalar_transfer (s ell sourceExponent parameterExponent : ℕ) (hell : 2 ≤ ell) + {epsilon : ℝ} (hepsilon : 0 < epsilon) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {I : Type u} {V : Type v} {J : Type*} + [Fintype I] [Fintype J] [LieRing V] [LieAlgebra ℚ V] + [TopologicalSpace (ℝ ⊗[ℚ] V)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] V)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V)] [T2Space (ℝ ⊗[ℚ] V)] + {d0 : ℕ} (nilmanifold : RationalFilteredNilmanifold V s d0) + (p level : ℝ), + 2 ≤ p → Real.exp (-p) ≤ level → level ≤ 2 → + (Fintype.card I : ℝ) ≤ p → Fintype.card J = ell → + ∀ g : nilmanifold.Niltest (fun _ : I => 1), g.ComplexityLE p → + ∀ (lo : I → ℤ) (N : I → ℕ), + (∀ z ∈ translatedIntegerBox lo N, (g.eval z).im = 0 ∧ 0 ≤ (g.eval z).re ∧ (g.eval z).re ≤ 1) → + ∀ f : (I → ℤ) → ℝ, (∀ z ∈ translatedIntegerBox lo N, 0 ≤ f z ∧ f z ≤ 1) → + let budget := (p + 2) ^ C + let parameterLog := ((parameterExponent : ℝ) + 1) * p + ResidueSliceUpperComparison (fun z => (f z : ℂ) * g.eval z) g.eval lo N budget level (Real.exp (-budget)) → + ∀ (D : ℕ) (anchor parLo parHi : J → ℤ) (hpar : ∀ j, parLo j < parHi j), + 0 < D → (D : ℝ) ≤ Real.exp parameterLog → + ∀ L : ℝ, Real.exp budget ≤ L → (∀ i, Real.exp budget * L ^ (ell + 1) ≤ (N i : ℝ)) → + (∀ j, L * Real.exp (-(2 * parameterLog)) ≤ ((parHi j - parLo j : ℤ) : ℝ)) → + (∀ j t, t ∈ Finset.Ico (parLo j) (parHi j) → + |((anchor j + (D : ℤ) * t : ℤ) : ℝ)| ≤ Real.exp parameterLog * L) → + ∀ (sourceLo sourceHi : Option J × I → ℤ) (hsource : ∀ z, sourceLo z < sourceHi z), + (∀ z : Option J × I, smoothPairCoefficientScale (N z.2 : ℝ) L z.1 ≤ + Real.exp ((sourceExponent : ℝ) * p) * ((sourceHi z - sourceLo z : ℤ) : ℝ)) → + (∀ j i x, x ∈ Finset.Ico (sourceLo (some j,i)) (sourceHi (some j,i)) → + |(x : ℝ)| ≤ Real.exp ((sourceExponent : ℝ) * p) * ((N i : ℝ) / L)) → + ∀ outer : FiniteProbabilityWeights (∀ i, Finset.Ico (sourceLo i) (sourceHi i)), + (∀ z, outer.weight z ≤ Real.exp p * (integerBoxUniformWeights sourceLo sourceHi hsource).weight z) → + outer.eventProbability (fun z => Real.exp (-p) < + (integerBoxUniformWeights parLo parHi hpar).mean (fun t => + realZeroExtendFinset (translatedIntegerBox lo N) (fun y => f y * (g.eval y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)) - + (1 + epsilon) * level * realZeroExtendFinset (translatedIntegerBox lo N) (fun y => (g.eval y).re) + (smoothAffineSample (fun j => anchor j + (D : ℤ) * (t j).val) (fun i => (z i).val)))) ≤ Real.exp (-p) := by + obtain ⟨A0, Cexp, hminimum, hA0, hCexp, htransfer⟩ := + exists_niltest_box_scalar_transfer.{u,v} s ell (sourceExponent + 5 * (parameterExponent + 1) + 6) hell hepsilon + refine ⟨Cexp, hCexp, ?_⟩ + intro I V J _ _ _ _ _ _ _ _ d0 nilmanifold p level hp hlower hlevel hnP hJ + g hcomplexity lo N hunit f hf budget parameterLog hnoincrement D anchor parLo parHi hpar hD hDlog + L hLexp hNexp hparWidth hparPoint sourceLo sourceHi hsource hsourceWidth hsourcePoint outer hdom + let P0 := (A0 : ℝ) * (p + 1) + let q := (sourceExponent : ℝ) * p + have hp0 : 0 ≤ p := by linarith + have hq0 : 0 ≤ q := mul_nonneg (Nat.cast_nonneg sourceExponent) hp0 + have hAr : (sourceExponent : ℝ) + 6 ≤ A0 := by + exact_mod_cast (show sourceExponent + 6 ≤ A0 by omega) + have hArp : 5 * ((parameterExponent : ℝ) + 1) + 6 ≤ A0 := by + exact_mod_cast (show 5 * (parameterExponent + 1) + 6 ≤ A0 by omega) + have hparameter : 2 ≤ parameterLog := by + dsimp only [parameterLog] + nlinarith [Nat.cast_nonneg (α := ℝ) parameterExponent] + have hAten : (10 : ℝ) ≤ A0 := by exact_mod_cast hA0 + have hfive : 5 * parameterLog ≤ P0 := by + have hm := mul_le_mul_of_nonneg_right hArp hp0 + dsimp only [parameterLog, P0] + nlinarith + have hqp : q + p ≤ P0 := by + have hm := mul_le_mul_of_nonneg_right hAr hp0 + dsimp only [q, P0] + nlinarith + have hP0 : 0 ≤ P0 := by linarith + have hbudget : 4 ≤ budget := calc + 4 ≤ p + 2 := by linarith + _ = (p + 2) ^ 1 := (pow_one _).symm + _ ≤ (p + 2) ^ Cexp := pow_le_pow_right₀ (by linarith) (by omega) + have hexp : 4 ≤ Real.exp budget := by linarith [Real.add_one_le_exp budget] + have hL : 1 ≤ L := by linarith + have hLpos : 0 < L := by linarith + have hscale (i : I) : 1 ≤ (N i : ℝ) / L := + (by linarith : 1 ≤ Real.exp budget).trans + (affinePhysicalScales_lower hL (Real.exp_pos budget).le (by omega : 1 ≤ ell + 1) (hNexp i)).2 + obtain ⟨R, hR, hRbound, hleft, hright⟩ := scalarTransfer_parameter_geometry D hD anchor parLo parHi hpar hparameter hL hDlog hparPoint + have hsourceEnds (j : J) (i : I) := scalarTransfer_source_endpoints + (sourceLo (some j,i)) (sourceHi (some j,i)) (hsource (some j,i)) hp hq0 (hscale i) (hsourcePoint j i) + let h : (I → ℤ) → ℂ := fun z => (f z : ℂ) * g.eval z + have hreal (z : I → ℤ) : (h z).re = f z * (g.eval z).re := by + simp only [h, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero] + have hh : ∀ z ∈ translatedIntegerBox lo N, 0 ≤ (h z).re ∧ (h z).re ≤ 1 := by + intro z hz + rw [hreal] + exact ⟨mul_nonneg (hf z hz).1 (hunit z hz).2.1, + (mul_le_of_le_one_left (hunit z hz).2.1 (hf z hz).2).trans (hunit z hz).2.2⟩ + have hone : 1 ≤ Real.exp P0 := by simpa only [Real.exp_zero] using Real.exp_le_exp.mpr hP0 + have htwo : Real.exp (2 * parameterLog) ≤ Real.exp P0 := Real.exp_le_exp.mpr (by linarith) + have hraw := htransfer nilmanifold p level hp hlower hlevel hnP hJ g hcomplexity + D anchor parLo parHi hpar hD (hDlog.trans (Real.exp_le_exp.mpr (by linarith))) + L (Real.exp (2 * parameterLog)) (Real.exp (q + p)) 1 (Real.exp q) (Real.exp (-(2 * parameterLog))) (Real.exp (5 * parameterLog)) + (by simpa only [Real.exp_zero] using Real.exp_le_exp.mpr (show 0 ≤ 2 * parameterLog by linarith)) + (Real.exp_pos _).le (by norm_num) (Real.exp_pos _).le (Real.exp_pos _) (Real.exp_pos _).le + htwo (Real.exp_le_exp.mpr hqp) hone (Real.exp_le_exp.mpr (by linarith)) + (by simpa only [Real.exp_neg, inv_inv] using htwo) (Real.exp_le_exp.mpr hfive) + lo N (fun i => (N i : ℝ)) (fun i => by nlinarith [Nat.cast_nonneg (α := ℝ) (N i)]) + (fun i => le_of_eq (one_mul (N i : ℝ)).symm) hunit h hh hnoincrement + R (L * Real.exp (-(2 * parameterLog))) (mul_pos hLpos (Real.exp_pos _)) hparWidth hR hRbound (le_of_eq (mul_comm _ _)) + hleft hright sourceLo sourceHi hsource hsourceWidth + (fun j i => by simpa only [mul_div_assoc] using (hsourceEnds j i).1) + (fun j i => by simpa only [mul_div_assoc] using (hsourceEnds j i).2) + hLexp hNexp outer hdom + simpa only [hreal] using hraw + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestVerticalBounds.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestVerticalBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc517e33144372ad6200805a5e513d06cfdef602 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/NiltestVerticalBounds.lean @@ -0,0 +1,468 @@ +import OAI.Combinatorics.Progressions.Dynamics.VerticalDecompositionBudget +import OAI.Combinatorics.Progressions.Estimates.SquareRationalModel +import OAI.Combinatorics.Progressions.Estimates.UniformCommutingCircleDecomposition +import OAI.Combinatorics.Progressions.Fourier.RationalFrequencyHeight +import OAI.Combinatorics.Progressions.Fourier.VerticalFrequencyIdentification +import OAI.Combinatorics.Progressions.Linear.RealifiedCentralBasisAction + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +theorem exists_controlled_adapted_basis {p : ℝ} (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) : + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ) (N : ℕ), + Monotone w ∧ IsCentralLieBasis b ∧ + (∀ i, D.filtration.layer i = Submodule.span ℚ (b '' {j | i ≤ w j})) ∧ + (∀ j i, rationalLogHeight (D.basis.repr (b j) i) ≤ p + 1) ∧ + (∀ i j, rationalLogHeight (b.repr (D.basis i) j) ≤ (p + 3) ^ 5) ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ (p + 3) ^ 11) ∧ + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 3) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b D.lattice ∧ + bchSubgroupCoordinates b D.lattice ⊆ denominatorGrid N := by + let H := ⌈Real.exp p⌉₊ + have hH : 1 ≤ H := one_le_ceil_exp p + have hHp : (H : ℝ) ≤ Real.exp (p + 1) := ceil_exp_le_exp_add_one hp + have hp1 : 0 ≤ p + 1 := by linarith + have hdp : (Fintype.card (Fin d) : ℝ) ≤ p + 1 := by + simpa only [Fintype.card_fin] using hD.1.trans (show p ≤ p + 1 by linarith) + have hlp : (D.grid : ℝ) ≤ Real.exp (p + 1) := + hD.2.1.trans (Real.exp_le_exp.mpr (by linarith)) + obtain ⟨b, w, N, hw, hc, hlayers, hb, hbinv, hbracket, hN, hNp, hin, hout⟩ := + D.filtration.exists_adapted_basis_and_grid D.basis (fun i => D.layerBasis i) + (fun i => (D.layerBasis i).span_eq) D.lattice hH D.grid_pos + (fun i j k => rationalHeightLE_ceil_exp (hD.2.2.2 i j k)) + (fun i j k => rationalHeightLE_ceil_exp (hD.2.2.1 i j k)) + D.inner_grid D.outer_grid hp1 hdp hHp hlp + have hdr : (finrank ℚ L : ℝ) ≤ p + 1 := by + simpa only [finrank_eq_card_basis D.basis] using hdp + have hshift : p + 1 + 2 = p + 3 := by ring + have hinvBudget : (rationalSolveHeight (finrank ℚ L) H : ℝ) ≤ Real.exp ((p + 3) ^ 5) := by + simpa only [hshift] using rationalSolveHeight_le_budget (finrank ℚ L) H hp1 hdr hHp + refine ⟨b, w, N, hw, hc, hlayers, ?_, ?_, ?_, hN, ?_, hin, hout⟩ + · exact fun j i => rationalLogHeight_le_of_height (hb j i) hHp + · exact fun i j => rationalLogHeight_le_of_height (hbinv i j) hinvBudget + · intro i j k + apply (rationalLogHeight_le_iff _ _).mpr + simpa only [hshift] using hbracket i j k + · simpa only [hshift] using hNp + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem exists_controlled_central_actions {p : ℝ} (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) : + letI := D.metricSpace + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ) (N : ℕ), + (∀ i, D.filtration.layer i = Submodule.span ℚ (b '' {j | i ≤ w j})) ∧ + (∀ j i, rationalLogHeight (D.basis.repr (b j) i) ≤ p + 1) ∧ + (∀ i j, rationalLogHeight (b.repr (D.basis i) j) ≤ (p + 3) ^ 5) ∧ + 0 < N ∧ (N : ℝ) ≤ Real.exp ((p + 3) ^ 9) ∧ + scaledIntegerGrid N ⊆ bchSubgroupCoordinates b D.lattice ∧ + bchSubgroupCoordinates b D.lattice ⊆ denominatorGrid N ∧ + ∃ A : {j // s ≤ w j} → CircleFourier.IsometricCircleAction D.Space, + (∀ i j, (A i).Commutes (A j)) ∧ + (∀ j (t : CircleFourier.Circle) x, + dist ((A j).act t x) x ≤ Real.exp ((p + 3) ^ 9 + 2 * p + 2) * ‖t‖) ∧ + ∀ j (r : ℝ) x, (A j).act (r : CircleFourier.Circle) x = + realBCHLine (hnil := D.filtration.realification.lowerCentralSeries_eq_bot) + ((N : ℝ) • (b.baseChange ℝ) j) r • x := by + let := D.metricSpace + obtain ⟨b, w, N, _, _, hlayers, hb, hbinv, _, hN, hNb, hin, hout⟩ := + D.exists_controlled_adapted_basis hp hD + have hcentral (j : {j // s ≤ w j}) (z : L) : ⁅b j, z⁆ = 0 := by + apply D.filtration.top_layer_central + rw [hlayers s] + exact Submodule.subset_span ⟨j, j.property, rfl⟩ + let A : {j // s ≤ w j} → CircleFourier.IsometricCircleAction D.Space := fun j => + realifiedCentralBasisAction D.basis b D.lattice D.grid D.grid_pos D.outer_grid N hin j (hcentral j) + have hbabs (j : Fin (finrank ℚ L)) (i : Fin d) : + |(D.basis.repr (b j) i : ℝ)| ≤ Real.exp (p + 2) := by + have hh := (rationalHeightLE_ceil_exp (hb j i)).abs_real_le + have hceil := ceil_exp_le_exp_add_one (show 0 ≤ p + 1 by linarith) + exact hh.trans (by simpa only [show p + 1 + 1 = p + 2 by ring] using hceil) + have hcost : ((d : ℝ) + 1) * ((N : ℝ) * Real.exp (p + 2)) ≤ + Real.exp ((p + 3) ^ 9 + 2 * p + 2) := by + have hd : (d : ℝ) + 1 ≤ Real.exp p := + (by linarith [hD.1] : (d : ℝ) + 1 ≤ p + 1).trans (Real.add_one_le_exp p) + calc + _ ≤ Real.exp p * (Real.exp ((p + 3) ^ 9) * Real.exp (p + 2)) := by gcongr + _ = _ := by simp only [← Real.exp_add]; congr 1; ring + refine ⟨b, w, N, hlayers, hb, hbinv, hN, hNb, hin, hout, A, ?_, ?_, ?_⟩ + · intro i j + exact realifiedCentralBasisAction_commutes D.basis b D.lattice D.grid D.grid_pos D.outer_grid + N hin i j (hcentral i) (hcentral j) + · intro j t x + have hh := realifiedCentralBasisAction_displacement D.basis b D.lattice D.grid D.grid_pos D.outer_grid + N hin j (hcentral j) (Real.exp_nonneg (p + 2)) (hbabs j) t x + simp only [Fintype.card_fin] at hh + exact hh.trans (mul_le_mul_of_nonneg_right hcost (norm_nonneg t)) + · intro j r x + exact realifiedCentralBasisAction_act_coe D.basis b D.lattice D.grid D.grid_pos D.outer_grid + N hin j (hcentral j) r x + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open Module + +theorem exists_nilmanifold_integral_cover (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L : Type*} [LieRing L] [LieAlgebra ℚ L] {d : ℕ} + (D : RationalFilteredNilmanifold L s d) (p : ℝ), 0 ≤ p → D.GeometryComplexityLE p → + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ) + (B : ℕ) (Λ : Subgroup D.filtration.Group), + Monotone w ∧ IsCentralLieBasis b ∧ + (∀ i, D.filtration.layer i = Submodule.span ℚ (b '' {j | i ≤ w j})) ∧ + (∀ j i, rationalLogHeight (D.basis.repr (b j) i) ≤ p + 1) ∧ + (∀ i j, rationalLogHeight (b.repr (D.basis i) j) ≤ (p + 3) ^ 5) ∧ + (∀ i j k, rationalLogHeight (lieStructureConstants b i j k) ≤ (p + 3) ^ 11) ∧ + 0 < B ∧ (B : ℝ) ≤ Real.exp (((p + 3) ^ 11 + 1 + C) ^ C) ∧ + Λ ≤ D.lattice ∧ (Λ.subgroupOf D.lattice).FiniteIndex ∧ + bchSubgroupCoordinates b Λ = scaledIntegerGrid B ∧ + ∀ g ∈ Λ, ∃! z : Fin (finrank ℚ L) → ℤ, + integralOrderedBasisProduct b D.filtration.lowerCentralSeries_eq_bot B z = g := by + obtain ⟨C, hC, hcover⟩ := exists_controlled_integral_coordinates s + refine ⟨C, hC, ?_⟩ + intro L _ _ d D p hp hD + obtain ⟨b, w, N, hw, hc, hlayer, hb, hbinv, hbracket, hN, hNp, hin, hout⟩ := + D.exists_controlled_adapted_basis hp hD + let q : ℝ := (p + 3) ^ 11 + let H := ⌈Real.exp q⌉₊ + have hq : 0 ≤ q := by dsimp [q]; positivity + have hbase : 1 ≤ p + 3 := by linarith + have hpq : p ≤ q := by + calc + p ≤ p + 3 := by linarith + _ ≤ (p + 3) ^ 11 := by + simpa only [pow_one] using pow_le_pow_right₀ hbase (by decide : 1 ≤ 11) + have hdq : (finrank ℚ L : ℝ) ≤ q + 1 := by + have hd : (finrank ℚ L : ℝ) ≤ p := by + simpa only [finrank_eq_card_basis D.basis, Fintype.card_fin] using hD.1 + exact (hd.trans hpq).trans (le_add_of_nonneg_right zero_le_one) + have hH : (H : ℝ) ≤ Real.exp (q + 1) := ceil_exp_le_exp_add_one hq + have hNq : (N : ℝ) ≤ Real.exp (q + 1) := by + apply hNp.trans (Real.exp_le_exp.mpr ?_) + exact (pow_le_pow_right₀ hbase (by decide : 9 ≤ 11)).trans + (le_add_of_nonneg_right zero_le_one) + obtain ⟨B, Λ, hB, _, hBp, hΛ, hfinite, hcoords, hnormal⟩ := + hcover b hc D.filtration.lowerCentralSeries_eq_bot D.lattice N H (q + 1) hN + (fun i j k => rationalHeightLE_ceil_exp (hbracket i j k)) + hin hout (by linarith) hdq hH hNq + exact ⟨b, w, B, Λ, hw, hc, hlayer, hb, hbinv, hbracket, hB, hBp, hΛ, hfinite, hcoords, hnormal⟩ + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open Module NilpotentLieBCHGroup CircleFourier +open scoped TensorProduct BigOperators NNReal + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem exists_controlled_vertical_decomposition {p : ℝ} (hp : 0 ≤ p) + (hD : D.GeometryComplexityLE p) : + letI := D.metricSpace + ∀ (f : D.Space → ℂ) (K B : ℝ≥0), LipschitzWith K f → (∀ x, ‖f x‖ ≤ B) → + (K : ℝ) ≤ Real.exp p → ∀ δ : ℝ, 0 < δ → δ⁻¹ ≤ Real.exp p → + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (η : J → L →ₗ[ℚ] ℚ) (v : J → D.Space → ℂ), + (Fintype.card J : ℝ) ≤ Real.exp (verticalDecompositionBudget p) ∧ + (∀ j i, rationalLogHeight (η j (D.basis i)) ≤ verticalDecompositionBudget p) ∧ + (∀ j, LipschitzWith K (v j) ∧ (∀ x, ‖v j x‖ ≤ B)) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + v j (z • x) = character ((realifyFunctional (η j) z.coord : ℝ) : CircleFourier.Circle) * v j x) ∧ + (∀ (z : D.RealGroup) (c : ℂ), (∀ x, f (z • x) = c * f x) → + ∀ j x, v j (z • x) = c * v j x) ∧ + ∀ x, ‖(∑ j, v j x) - f x‖ ≤ δ := by + classical + let := D.metricSpace + intro f K B hf hb hK δ hδ hδp + obtain ⟨b, w, N, hlayers, _, hbinv, hN, hNp, _, _, A, hcomm, horbit, hact⟩ := + D.exists_controlled_central_actions hp hD + let S : Set (Fin (finrank ℚ L)) := {j | s ≤ w j} + let q := centralActionBudget p + have hq : 0 ≤ q := centralActionBudget_nonneg hp + have hpq : p ≤ q := le_centralActionBudget hp + have hd : (Fintype.card S : ℝ) ≤ p := by + apply (Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans + simpa only [Fintype.card_fin, finrank_eq_card_basis D.basis] using hD.1 + let O : ℝ≥0 := ⟨Real.exp q, (Real.exp_pos q).le⟩ + obtain ⟨J, inst, ν, v, hcard, hν, hv, hchar, hpres, herr⟩ := + exists_controlled_commuting_circle_decomposition A hcomm f K B O hf hb horbit δ q hδ hq + (hd.trans hpq) (hK.trans (Real.exp_le_exp.mpr hpq)) le_rfl + (hδp.trans (Real.exp_le_exp.mpr hpq)) + let η : J → L →ₗ[ℚ] ℚ := fun j => basisFrequency b S N (ν j) + let R : ℝ := (2 * q + 2) ^ 4 + q + (p + 3) ^ 5 + have hpow : 0 ≤ (p + 3) ^ 5 := by positivity + have hR : 0 ≤ R := by dsimp [R]; positivity + have hqR : q ≤ R := by dsimp [R]; nlinarith [sq_nonneg ((2 * q + 2) ^ 2)] + have hfreq : (2 * q + 2) ^ 4 ≤ R := by dsimp [R]; linarith + have hbas : (p + 3) ^ 5 ≤ R := by dsimp [R]; nlinarith [sq_nonneg ((2 * q + 2) ^ 2)] + have hNq : (p + 3) ^ 9 ≤ q := by dsimp [q, centralActionBudget]; linarith + have hterm : 2 * q * (2 * q + 2) ^ 4 ≤ verticalDecompositionBudget p := by + change _ ≤ _ + (R + 2) ^ 4 + exact le_add_of_nonneg_right (by positivity) + have hheight : (R + 2) ^ 4 ≤ verticalDecompositionBudget p := by + change _ ≤ 2 * q * (2 * q + 2) ^ 4 + _ + have h : 0 ≤ 2 * q * (2 * q + 2) ^ 4 := by positivity + linarith + have hcentral (i : S) (z : L) : ⁅b i, z⁆ = 0 := by + apply D.filtration.top_layer_central + rw [hlayers s] + exact Submodule.subset_span ⟨i, i.property, rfl⟩ + have hucentral (i : S) (z : ℝ ⊗[ℚ] L) : ⁅(N : ℝ) • b.baseChange ℝ i, z⁆ = 0 := + scaled_real_basis_central b i (hcentral i) N z + refine ⟨J, inst, η, v, hcard.trans (Real.exp_le_exp.mpr hterm), ?_, hv, ?_, ?_, herr⟩ + · intro j i + exact (basisFrequency_logHeight_le D.basis b S N hN (ν j) hR (hd.trans (hpq.trans hqR)) + (hNp.trans (Real.exp_le_exp.mpr (hNq.trans hqR))) + (fun a => (hν j a).trans (Real.exp_le_exp.mpr hfreq)) + (fun a c => (hbinv a c).trans hbas) i).trans hheight + · intro j z hz x + apply central_span_character (fun i : S => (N : ℝ) • b.baseChange ℝ i) hucentral + (realifyFunctional (η j)) (v j) ?_ ?_ x + · intro i r y + have h := hchar j i (r : CircleFourier.Circle) y + rw [hact] at h + change _ = character ((r * realifyFunctional (basisFrequency b S N (ν j)) + ((N : ℝ) • b.baseChange ℝ i) : ℝ) : CircleFourier.Circle) * _ + rw [realify_basisFrequency_direction b S N hN (ν j) i] + simpa only [← AddCircle.coe_zsmul, zsmul_eq_mul, mul_comm] using h + · exact D.filtration.realLayer_le_span_scaled_basis b s S (hlayers s) N hN hz + · intro z c hc + apply hpres (fun x => z • x) c ?_ hc + intro i t x + obtain ⟨r, rfl⟩ := QuotientAddGroup.mk_surjective t + rw [hact, hact, ← mul_smul, ← mul_smul] + rw [(realBCHLine_commute _ (hucentral i) r z).eq] + +end Erdos3.RationalFilteredNilmanifold + +end + +section + +namespace Erdos3 + +open Module NilpotentLieFiltration + +noncomputable def squareGeometryBudget (p : ℝ) : ℝ := + ((p + 3) ^ 11 + 2 * p + 5) ^ 11 + +theorem squareGeometryBudget_nonneg {p : ℝ} (hp : 0 ≤ p) : 0 ≤ squareGeometryBudget p := by + unfold squareGeometryBudget + positivity + +theorem squareGeometryBudget_polynomial : + ∃ C : ℕ, 2 ≤ C ∧ ∀ p : ℝ, 0 ≤ p → squareGeometryBudget p ≤ (p + C) ^ C := by + refine ⟨132, by decide, ?_⟩ + intro p hp + have ht : 1 ≤ p + 5 := by linarith + have hsmall : 2 * p + 5 ≤ (p + 5) ^ 2 := by nlinarith [sq_nonneg p] + have htwo : (p + 5) ^ 2 ≤ (p + 5) ^ 11 := pow_le_pow_right₀ ht (by decide) + have hbig : (p + 3) ^ 11 ≤ (p + 5) ^ 11 := + pow_le_pow_left₀ (by linarith) (by linarith) _ + have hinner : (p + 3) ^ 11 + 2 * p + 5 ≤ (p + 5) ^ 12 := by + calc + _ ≤ 2 * (p + 5) ^ 11 := by linarith + _ ≤ (p + 5) * (p + 5) ^ 11 := + mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = _ := by ring + calc + squareGeometryBudget p ≤ ((p + 5) ^ 12) ^ 11 := + pow_le_pow_left₀ (by positivity) hinner _ + _ = (p + 5) ^ 132 := by rw [← pow_mul] + _ ≤ (p + (132 : ℕ)) ^ (132 : ℕ) := + pow_le_pow_left₀ (by linarith) (by norm_num) _ + +namespace RationalFilteredNilmanifold + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + (D : RationalFilteredNilmanifold L s d) + +theorem exists_controlled_square_geometry {p : ℝ} (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) : + ∃ (b : Basis (Fin (finrank ℚ L)) ℚ L) (w : Fin (finrank ℚ L) → ℕ) + (hlayers : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) + (N : ℕ) (hN : 0 < N) + (hin : scaledIntegerGrid N ⊆ bchSubgroupCoordinates + (D.filtration.squareFinBasis b w (hlayers 2)) (D.filtration.squareLattice D.lattice)) + (hout : bchSubgroupCoordinates (D.filtration.squareFinBasis b w (hlayers 2)) + (D.filtration.squareLattice D.lattice) ⊆ denominatorGrid N), + (∀ i j, rationalLogHeight (D.basis.repr (b i) j) ≤ p + 1) ∧ + (D.filtration.squareFiltration.ofAdaptedBasis + (D.filtration.squareFinBasis b w (hlayers 2)) (squareFinWeight w) + (D.filtration.squareFinBasis_layers b w hlayers) + (D.filtration.squareLattice D.lattice) N hN hin hout).GeometryComplexityLE + (squareGeometryBudget p) := by + obtain ⟨b, w, l, _, _, hlayers, hb, _, hc, hl, hlp, hin, hout⟩ := + D.exists_controlled_adapted_basis hp hD + let q : ℝ := (p + 3) ^ 11 + 2 * p + 3 + have hq : 0 ≤ q := by dsimp [q]; positivity + have hqbr : (p + 3) ^ 11 + 1 ≤ q := by dsimp [q]; linarith + have hdim : (Fintype.card (Fin (finrank ℚ L)) : ℝ) ≤ p := by + simpa only [Fintype.card_fin, finrank_eq_card_basis D.basis] using hD.1 + have h2dim : 2 * (Fintype.card (Fin (finrank ℚ L)) : ℝ) ≤ q := by + have hpow : 0 ≤ (p + 3) ^ 11 := by positivity + dsimp [q] + linarith + have hH : (⌈Real.exp ((p + 3) ^ 11)⌉₊ : ℝ) ≤ Real.exp q := + (ceil_exp_le_exp_add_one (by positivity)).trans (Real.exp_le_exp.mpr hqbr) + have hgrid : (l : ℝ) ≤ Real.exp q := by + apply hlp.trans (Real.exp_le_exp.mpr _) + have hpow := pow_le_pow_right₀ (by linarith : 1 ≤ p + 3) (by decide : 9 ≤ 11) + dsimp [q] + linarith + obtain ⟨N, hN, hinner, houter, hgeom⟩ := D.filtration.exists_square_rational_model + b w hlayers D.lattice hl (one_le_ceil_exp _) + (fun i j k => rationalHeightLE_ceil_exp (hc i j k)) hin hout hq h2dim hH hgrid + refine ⟨b, w, hlayers, N, hN, hinner, houter, hb, ?_⟩ + have he : q + 2 = (p + 3) ^ 11 + 2 * p + 5 := by dsimp [q]; ring + simpa only [he, squareGeometryBudget] using hgeom + +end RationalFilteredNilmanifold +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open CircleFourier +open scoped TensorProduct BigOperators + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem exists_controlled_vertical_decomposition (T : D.Niltest w) + {p : ℝ} (hp : 0 ≤ p) (hT : T.ComplexityLE p) + (δ : ℝ) (hδ : 0 < δ) (hδp : δ⁻¹ ≤ Real.exp p) : + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (η : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w), + (Fintype.card J : ℝ) ≤ Real.exp (verticalDecompositionBudget p) ∧ + (∀ j i, rationalLogHeight (η j (D.basis i)) ≤ verticalDecompositionBudget p) ∧ + (∀ j, (U j).ComplexityLE p ∧ (U j).orbit = T.orbit) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (η j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) ∧ + (∀ j, (∃ x, (U j).observable x ≠ 0) → ∀ z : D.RealGroup, + z ∈ D.filtration.realification.subgroup s → z ∈ D.realLattice → + ∃ n : ℤ, realifyFunctional (η j) z.coord = n) ∧ + (∀ (z : D.RealGroup) (c : ℂ), (∀ x, T.observable (z • x) = c * T.observable x) → + ∀ j x, (U j).observable (z • x) = c * (U j).observable x) ∧ + (∀ x, ‖(∑ j, (U j).observable x) - T.observable x‖ ≤ δ) ∧ + ∀ x : σ → ℤ, ‖(∑ j, (U j).eval x) - T.eval x‖ ≤ δ := by + let := D.metricSpace + have hK : (T.lipBound : ℝ) ≤ Real.exp p := by + have h := observable_budget hT + have hB := T.normBound.coe_nonneg + linarith + obtain ⟨J, inst, η, v, hcard, hheight, hv, hchar, hpres, herr⟩ := + D.exists_controlled_vertical_decomposition hp hT.1 T.observable T.lipBound T.normBound + T.lipschitz T.norm_le hK δ hδ hδp + let U : J → D.Niltest w := fun j => + { orbit := T.orbit + observable := v j + normBound := T.normBound + lipBound := T.lipBound + norm_le := (hv j).2 + lipschitz := (hv j).1 } + refine ⟨J, inst, η, U, hcard, hheight, fun j => ⟨hT, rfl⟩, hchar, ?_, hpres, herr, ?_⟩ + · intro j hne z hz hΓ + exact vertical_frequency_integral_on_lattice D.filtration D.realLattice (η j) (v j) + (hchar j) hne z hz hΓ + · intro x + exact herr (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x T.orbit)) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.Niltest + +open CircleFourier +open scoped TensorProduct BigOperators + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + {D : RationalFilteredNilmanifold L s d} {w : σ → ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + +theorem exists_vertical_decomposition_preserving_bounds (T : D.Niltest w) + {p rho : ℝ} (hp : 0 ≤ p) (hT : T.ComplexityLE p) (hrho : 0 < rho) + (hrhop : rho⁻¹ ≤ Real.exp p) : + ∃ (J : Type) (inst : Fintype J), letI := inst + ∃ (eta : J → L →ₗ[ℚ] ℚ) (U : J → D.Niltest w), + (Fintype.card J : ℝ) ≤ Real.exp (verticalDecompositionBudget p) ∧ + (∀ j i, rationalLogHeight (eta j (D.basis i)) ≤ verticalDecompositionBudget p) ∧ + (∀ j, (U j).ComplexityLE p ∧ (U j).orbit = T.orbit ∧ + (U j).normBound = T.normBound ∧ (U j).lipBound = T.lipBound) ∧ + (∀ j (z : D.RealGroup), z ∈ D.filtration.realification.subgroup s → ∀ x, + (U j).observable (z • x) = + character ((realifyFunctional (eta j) z.coord : ℝ) : CircleFourier.Circle) * (U j).observable x) ∧ + (∀ j, (∃ x, (U j).observable x ≠ 0) → ∀ z : D.RealGroup, + z ∈ D.filtration.realification.subgroup s → z ∈ D.realLattice → + ∃ n : ℤ, realifyFunctional (eta j) z.coord = n) ∧ + (∀ x, ‖(∑ j, (U j).observable x) - T.observable x‖ ≤ rho) ∧ + ∀ x : σ → ℤ, ‖(∑ j, (U j).eval x) - T.eval x‖ ≤ rho := by + let := D.metricSpace + have hK : (T.lipBound : ℝ) ≤ Real.exp p := by + have h := observable_budget hT + have hB := T.normBound.coe_nonneg + linarith + obtain ⟨J, inst, eta, v, hcard, hheight, hv, hchar, _, herr⟩ := + D.exists_controlled_vertical_decomposition hp hT.1 T.observable T.lipBound T.normBound + T.lipschitz T.norm_le hK rho hrho hrhop + let U : J → D.Niltest w := fun j => + { orbit := T.orbit + observable := v j + normBound := T.normBound + lipBound := T.lipBound + norm_le := (hv j).2 + lipschitz := (hv j).1 } + refine ⟨J, inst, eta, U, hcard, hheight, fun _ => ⟨hT, rfl, rfl, rfl⟩, hchar, ?_, herr, ?_⟩ + · intro j hne z hz hGamma + exact vertical_frequency_integral_on_lattice D.filtration D.realLattice (eta j) (v j) + (hchar j) hne z hz hGamma + · intro x + exact herr (QuotientGroup.mk (D.filtration.realification.polynomialOrbitEval w x T.orbit)) + +end Erdos3.RationalFilteredNilmanifold.Niltest + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PolarizedVerticalNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolarizedVerticalNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6fdc6905d3cd302840a50805a265098b05a0c3d --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolarizedVerticalNiltest.lean @@ -0,0 +1,84 @@ +import OAI.Combinatorics.Progressions.Estimates.ComplexPolarization +import OAI.Combinatorics.Progressions.Estimates.SourceUnitCover + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +open scoped TensorProduct NNReal + +variable {L I σ : Type*} [LieRing L] [LieAlgebra ℚ L] [Fintype I] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} {T : Subgroup D.RealGroup} {p : ℝ} + (V : D.UnitVerticalObservable T I p) + +noncomputable def coordinateCombination (i j : I) (c : ℂ) (x : D.Space) : ℂ := + V.observable i x + c * V.observable j x + +theorem coordinateCombination_norm (i j : I) (c : ℂ) (hc : ‖c‖ ≤ 1) (x : D.Space) : + ‖V.coordinateCombination i j c x‖ ≤ 2 := by + apply (norm_add_le _ _).trans + rw [norm_mul] + have hmul := mul_le_mul hc (V.norm j x) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + linarith [V.norm i x] + +theorem coordinateCombination_lipschitz (i j : I) (c : ℂ) (hc : ‖c‖ ≤ 1) : + letI := D.metricSpace + LipschitzWith (2 * V.lipBound) (V.coordinateCombination i j c) := by + let := D.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + have hi := (V.lipschitz i).dist_le_mul x y + have hj := (V.lipschitz j).dist_le_mul x y + rw [dist_eq_norm] at hi hj ⊢ + have he : V.coordinateCombination i j c x - V.coordinateCombination i j c y = + (V.observable i x - V.observable i y) + c * (V.observable j x - V.observable j y) := by + unfold coordinateCombination + ring + rw [he] + apply (norm_add_le _ _).trans + rw [norm_mul] + have hm := mul_le_mul_of_nonneg_right hc (norm_nonneg (V.observable j x - V.observable j y)) + simp only [NNReal.coe_mul, NNReal.coe_ofNat] + nlinarith + +theorem coordinateCombination_vertical (i j : I) (c : ℂ) (z : D.RealGroup) (hz : z ∈ T) + (x : D.Space) : V.coordinateCombination i j c (z • x) = + CircleFourier.character ((realifyFunctional V.frequency z.coord : ℝ) : CircleFourier.Circle) * + V.coordinateCombination i j c x := by + unfold coordinateCombination + rw [V.vertical i z hz, V.vertical j z hz] + ring + +noncomputable def combinationNiltest {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (i j : I) (c : ℂ) (hc : ‖c‖ ≤ 1) : + D.Niltest w where + orbit := g + observable := V.coordinateCombination i j c + normBound := 2 + lipBound := 2 * V.lipBound + norm_le := V.coordinateCombination_norm i j c hc + lipschitz := V.coordinateCombination_lipschitz i j c hc + +theorem combinationNiltest_complexity {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (i j : I) (c : ℂ) (hc : ‖c‖ ≤ 1) + (hp : 0 ≤ p) (hD : D.GeometryComplexityLE p) : + (V.combinationNiltest g i j c hc).ComplexityLE (p + 5) := by + refine ⟨hD.mono D (by linarith), ?_⟩ + change Real.log (2 + (2 : ℝ) + ((2 * V.lipBound : ℝ≥0) : ℝ)) ≤ p + 5 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + simp only [NNReal.coe_mul, NNReal.coe_ofNat] + calc + _ ≤ 6 * Real.exp p := by nlinarith [V.lip_bound, Real.one_le_exp hp] + _ ≤ Real.exp 5 * Real.exp p := mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (5 : ℝ)]) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, add_comm] + +end Erdos3.RationalFilteredNilmanifold.UnitVerticalObservable + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialBCHRemoval.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialBCHRemoval.lean new file mode 100644 index 0000000000000000000000000000000000000000..874f5dd918433e3fccc970df4fb2a7471f252534 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialBCHRemoval.lean @@ -0,0 +1,121 @@ +import OAI.Combinatorics.Progressions.Estimates.CurrentLayerPreservation + +namespace OAI + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +namespace VectorPolynomial + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] + +noncomputable def bchRemove (s : ℕ) (A P B : VectorPolynomial σ ℚ L) : + VectorPolynomial σ ℚ L := lieBCH s (lieBCH s (-A) P) (-B) + +theorem bchRemove_factorization {s : ℕ} (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (A P B : VectorPolynomial σ ℚ L) : + lieBCH s (lieBCH s A (bchRemove s A P B)) B = P := by + let a : NilpotentLieBCHGroup.PolynomialGroup σ hnil := ⟨A⟩ + let g : NilpotentLieBCHGroup.PolynomialGroup σ hnil := ⟨P⟩ + let c : NilpotentLieBCHGroup.PolynomialGroup σ hnil := ⟨B⟩ + have h : a * (a⁻¹ * g * c⁻¹) * c = g := by group + exact congrArg NilpotentLieBCHGroup.coord h + +theorem eval₂_bchRemove [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] + (s : ℕ) (A P B : VectorPolynomial σ ℚ L) (t : σ → ℝ) : + eval₂ t (bchRemove s A P B) = lieBCH s (lieBCH s (-eval₂ t A) (eval₂ t P)) (-eval₂ t B) := by + have h₁ := map_lieBCH (eval₂Lie (R := ℚ) (S := ℝ) (L := L) t) s (lieBCH s (-A) P) (-B) + have h₂ := map_lieBCH (eval₂Lie (R := ℚ) (S := ℝ) (L := L) t) s (-A) P + rw [h₂] at h₁ + simp only [map_neg, eval₂Lie_apply] at h₁ + exact h₁ + +theorem bchRemove_constant {s : ℕ} (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (A P B : VectorPolynomial σ ℚ L) (hA : coefficients A 0 = 0) (hB : coefficients B 0 = 0) : + coefficients (bchRemove s A P B) 0 = coefficients P 0 := by + have h₁ := eval_lieBCH (fun _ : σ => (0 : ℚ)) s (lieBCH s (-A) P) (-B) + have h₂ := eval_lieBCH (fun _ : σ => (0 : ℚ)) s (-A) P + rw [h₂] at h₁ + simp only [map_neg, eval_zero_eq_coefficient, hA, hB, neg_zero] at h₁ + apply h₁.trans + change ((1 : NilpotentLieBCHGroup L s hnil) * ⟨coefficients P 0⟩ * 1).coord = _ + simp only [one_mul, mul_one] + +theorem bchRemove_coefficients_mem (U : LieSubalgebra ℚ L) (s : ℕ) + (A P B : VectorPolynomial σ ℚ L) + (hA : ∀ α, coefficients A α ∈ U) (hP : ∀ α, coefficients P α ∈ U) + (hB : ∀ α, coefficients B α ∈ U) : + ∀ α, coefficients (bchRemove s A P B) α ∈ U := by + let W := coefficientLieSubalgebra (σ := σ) U + have ha : A ∈ W := hA + have hp : P ∈ W := hP + have hb : B ∈ W := hB + exact lieBCH_mem W s (lieBCH_mem W s (W.neg_mem ha) hp) (W.neg_mem hb) + +end VectorPolynomial + +namespace NilpotentLieFiltration + +open VectorPolynomial + +variable {σ L ι : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) (b : Basis ι ℚ L) (w : ι → ℕ) + (hlayers : ∀ j, F.layer j = Submodule.span ℚ (b '' {i | j ≤ w i})) + +include hlayers in +theorem polynomial_bchRemove_grades (E : Submodule ℝ (ℝ ⊗[ℚ] L)) (j : ℕ) + (hE : ∀ x ∈ E, basisGradeProjection (b.baseChange ℝ) w j x = x) + (A P B : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (hA : ∀ α, coefficients A α ∈ E) (hB : ∀ α, coefficients B α ∈ E) : + map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) (bchRemove s A P B) = + map ((basisGradeProjection (b.baseChange ℝ) w j).restrictScalars ℚ) P - A - B ∧ + ∀ d < j, map ((basisGradeProjection (b.baseChange ℝ) w d).restrictScalars ℚ) (bchRemove s A P B) = + map ((basisGradeProjection (b.baseChange ℝ) w d).restrictScalars ℚ) P := by + have heq (X Y : VectorPolynomial σ ℚ (ℝ ⊗[ℚ] L)) + (h : ∀ t : σ → ℝ, eval₂ t X = eval₂ t Y) : X = Y := by + apply sub_eq_zero.mp + apply eq_zero_of_eval₂_zero (K := ℝ) + intro t + rw [map_sub, h t, sub_self] + have hvalues (t : σ → ℝ) : + basisGradeProjection (b.baseChange ℝ) w j + (lieBCH s (lieBCH s (-eval₂ t A) (eval₂ t P)) (-eval₂ t B)) = + basisGradeProjection (b.baseChange ℝ) w j (eval₂ t P) - eval₂ t A - eval₂ t B ∧ + ∀ d < j, basisGradeProjection (b.baseChange ℝ) w d + (lieBCH s (lieBCH s (-eval₂ t A) (eval₂ t P)) (-eval₂ t B)) = + basisGradeProjection (b.baseChange ℝ) w d (eval₂ t P) := by + have ha := hE _ ((eval₂_mem_iff_coefficients E A).mpr hA t) + have hc := hE _ ((eval₂_mem_iff_coefficients E B).mpr hB t) + have hal : eval₂ t A ∈ F.realification.layer j := by + simpa only [ha] using F.realGradeProjection_mem_layer b w hlayers j (eval₂ t A) + have hcl : eval₂ t B ∈ F.realification.layer j := by + simpa only [hc] using F.realGradeProjection_mem_layer b w hlayers j (eval₂ t B) + have hcurrent := F.real_correction_current_grade b w hlayers j + ⟨eval₂ t A⟩ ⟨eval₂ t P⟩ ⟨eval₂ t B⟩ hal hcl + have hbelow := F.real_correction_preserves_grades_below b w hlayers j + ⟨eval₂ t A⟩ ⟨eval₂ t P⟩ ⟨eval₂ t B⟩ hal hcl + change basisGradeProjection (b.baseChange ℝ) w j + (lieBCH s (lieBCH s (-eval₂ t A) (eval₂ t P)) (-eval₂ t B)) = _ at hcurrent + rw [ha, hc] at hcurrent + exact ⟨hcurrent, hbelow⟩ + constructor + · apply heq + intro t + simp only [eval₂_map, eval₂_bchRemove, map_sub] + exact (hvalues t).1 + · intro d hd + apply heq + intro t + simp only [eval₂_map, eval₂_bchRemove] + exact (hvalues t).2 d hd + +end NilpotentLieFiltration +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialPatchWeightedChartNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialPatchWeightedChartNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9dedb8c175ae51ce49fdec370f1666319b83caa --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialPatchWeightedChartNiltest.lean @@ -0,0 +1,401 @@ +import OAI.Combinatorics.Progressions.Estimates.FixedPatchFunction +import OAI.Combinatorics.Progressions.Polynomial.PolynomialPatchMarkedChartRestoration +import OAI.Combinatorics.Progressions.Probability.MassBoundedShearBudget + +namespace OAI + +section + +namespace Erdos3.PolynomialPatch + +open scoped NNReal TensorProduct + +variable {σ : Type*} {s d : ℕ} (A : PolynomialPatch σ s d) + [Fintype (PolynomialShearIndex A.weight)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + +noncomputable def shearNiltest (M : ℝ≥0) + (hA : ∀ i, realPolynomialMass (A.form.center i) ≤ M) : + (polynomialShearNilmanifold A.weight s A.weight_le).Niltest (fun _ : σ => 1) where + orbit := A.shearOrbit + observable z := (A.shearObservable z : ℂ) + normBound := 1 + lipBound := A.shearObservableLipBound M + norm_le z := by + simpa only [Complex.norm_real, Real.norm_eq_abs, NNReal.coe_one] using A.abs_shearObservable_le_one z + lipschitz := by + let : MetricSpace ((polynomialShearFiltration A.weight s A.weight_le).realification.Group ⧸ + polynomialShearRealLattice s A.weight_le) := + (polynomialShearNilmanifold A.weight s A.weight_le).metricSpace + change LipschitzWith (A.shearObservableLipBound M) + (fun z : (polynomialShearFiltration A.weight s A.weight_le).realification.Group ⧸ + polynomialShearRealLattice s A.weight_le => (A.shearObservable z : ℂ)) + simpa only [one_mul, Function.comp_def] using + Complex.isometry_ofReal.lipschitzWith.comp (A.shearObservable_lipschitz M hA) + +theorem shearNiltest_unitInterval (M : ℝ≥0) + (hA : ∀ i, realPolynomialMass (A.form.center i) ≤ M) : + (A.shearNiltest M hA).UnitIntervalValued := by + intro z + exact ⟨rfl, A.shearObservable_mem_Icc z⟩ + +theorem shearNiltest_eval (M : ℝ≥0) + (hA : ∀ i, realPolynomialMass (A.form.center i) ≤ M) (t : σ → ℤ) : + (A.shearNiltest M hA).eval t = (A.value (fun i => (t i : ℝ)) : ℂ) := by + exact congrArg (fun r : ℝ => (r : ℂ)) (A.value_integer_eq_shearOrbit_observable t).symm + +theorem shearNiltest_complexity (M : ℝ≥0) + (hA : ∀ i, realPolynomialMass (A.form.center i) ≤ M) {p : ℝ} + (hgeometry : (polynomialShearNilmanifold A.weight s A.weight_le).GeometryComplexityLE p) + (hbound : Real.log (3 + (A.shearObservableLipBound M : ℝ)) ≤ p) : + (A.shearNiltest M hA).ComplexityLE p := by + exact ⟨hgeometry, by simpa only [shearNiltest, NNReal.coe_one, show (2 : ℝ) + 1 = 3 by norm_num] using hbound⟩ + +end Erdos3.PolynomialPatch + +end + +section + +namespace Erdos3.PolynomialSlots + +variable {X Y : Type*} {d s : ℕ} {w : Fin d → ℕ} + +theorem shearObservable_eval_lift (B : PolynomialSlots X d w) (A : PolynomialSlots Y d w) + (hw : Monotone w) (hpos : ∀ i, 1 ≤ w i) (hs : ∀ i, w i ≤ s) + (Φ : PatchKernel d) (t : Y → ℝ) : + let P : PolynomialPatch X s d := ⟨w, hpos, hs, hw, B, Φ⟩ + P.shearObservable (QuotientGroup.mk (A.shearGroupLift s hs t)) = + (B.shearTransformedSlots hw (A.loweringAt t)).patchValue Φ := by + intro P + change polynomialShearOrbitSum w s hs P.shearKernel (A.shearGroupLift s hs t) = _ + rw [P.shearOrbitSum_eq_patchValue] + simp only [P, shearGroupLift, MulEquiv.apply_symm_apply, inv_inv] + +theorem shearObservable_eval_orbit [Fintype (PolynomialShearIndex w)] + (B : PolynomialSlots X d w) (A : PolynomialSlots Y d w) + (hw : Monotone w) (hpos : ∀ i, 1 ≤ w i) (hs : ∀ i, w i ≤ s) + (Φ : PatchKernel d) (t : Y → ℝ) : + let P : PolynomialPatch X s d := ⟨w, hpos, hs, hw, B, Φ⟩ + P.shearObservable (QuotientGroup.mk + ((polynomialShearFiltration w s hs).realification.polynomialOrbitRealEval + (fun _ : Y => 1) t (A.shearPolynomialOrbit s hs))) = + (B.shearTransformedSlots hw (A.loweringAt t)).patchValue Φ := by + rw [A.shearPolynomialOrbit_realEval] + exact shearObservable_eval_lift B A hw hpos hs Φ t + +end Erdos3.PolynomialSlots + +end + +section + +namespace Erdos3 + +open scoped NNReal TensorProduct + +theorem exists_normalized_patch_niltest_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {σ : Type*} [Fintype σ] {d : ℕ} (A : PolynomialPatch σ s d) + [Fintype (PolynomialShearIndex A.weight)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] (p : ℝ), + 0 ≤ p → (Fintype.card σ : ℝ) ≤ p → (d : ℝ) ≤ p → + (∀ i α, |(A.form.center i).coeff α| ≤ 1 / 2) → + (A.kernel.lip : ℝ) ≤ Real.exp p → + ∃ T : (polynomialShearNilmanifold A.weight s A.weight_le).Niltest (fun _ : σ => 1), + T.UnitIntervalValued ∧ T.ComplexityLE ((p + 2) ^ C) ∧ + ∀ x : σ → ℤ, T.eval x = (A.value (fun i => (x i : ℝ)) : ℂ) := by + obtain ⟨a, ha, hlog⟩ := exists_bchLogMetricConstant_exp_bound s + obtain ⟨C, hC, hbudget⟩ := exists_shear_parameter_budget s a + refine ⟨C, hC, ?_⟩ + intro σ _ d A _ _ _ _ _ p hp hn hd hA hLip + let D := Fintype.card (PolynomialShearIndex A.weight) + let M : ℝ≥0 := ((s + 1) * (Fintype.card σ + d + 1) ^ s : ℕ) + have hD : D ≤ d * (d + 1) ^ s := by + simpa only [Fintype.card_fin] using + polynomialShearIndex_card_le A.weight s + (fun i => lt_of_lt_of_le Nat.zero_lt_one (A.weight_pos i)) A.weight_le + obtain ⟨t, ht, hpt, hgeom, hMt, htotal⟩ := hbudget (Fintype.card σ) d D p hp hn hd hD + have hmass (i) : realPolynomialMass (A.form.center i) ≤ M := + A.form.center_mass_le_of_normalized A.weight_pos s A.weight_le hA i + have hDt : (D : ℝ) ≤ t := by + have hle : D ≤ D + s.factorial + 2 * s + 1 := by omega + exact (Nat.cast_le.mpr hle).trans hgeom + have hHt : ((2 * s + 1 : ℕ) : ℝ) ≤ t := by + have hle : 2 * s + 1 ≤ D + s.factorial + 2 * s + 1 := by omega + exact (Nat.cast_le.mpr hle).trans hgeom + have hHexp : ((2 * s + 1 : ℕ) : ℝ) ≤ Real.exp t := + hHt.trans (by linarith [Real.add_one_le_exp t]) + have hClog := hlog D (2 * s + 1) t ht hDt hHexp + have hv : 0 ≤ (t + a) ^ a + 1 := by positivity + have hObs := shearObservable_log_bound A M hp hv hLip hClog + have hK := shearKernelLogBudget_nonneg s d M.coe_nonneg hp + have hT := shearActionLogBudget_nonneg s d M.coe_nonneg + change t + shearKernelLogBudget s d M p + shearActionLogBudget s d M + + (t + a) ^ a + 4 ≤ (p + 2) ^ C at htotal + have htP : t ≤ (p + 2) ^ C := by linarith [pow_nonneg (by positivity : 0 ≤ t + a) a] + have hgeometry : (polynomialShearNilmanifold A.weight s A.weight_le).GeometryComplexityLE + ((p + 2) ^ C) := + RationalFilteredNilmanifold.GeometryComplexityLE.mono + (polynomialShearNilmanifold A.weight s A.weight_le) + (polynomialShearNilmanifold_complexity_budget A.weight s + (fun i => lt_of_lt_of_le Nat.zero_lt_one (A.weight_pos i)) A.weight_le) + (hgeom.trans htP) + refine ⟨A.shearNiltest M hmass, A.shearNiltest_unitInterval M hmass, + A.shearNiltest_complexity M hmass hgeometry ?_, A.shearNiltest_eval M hmass⟩ + linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal TensorProduct + +namespace PolynomialPatch + +variable {X Y : Type*} {s d : ℕ} (P : PolynomialPatch X s d) + [Fintype (PolynomialShearIndex P.weight)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + +noncomputable def fixedObservableNiltest (M : ℝ≥0) + (hP : ∀ i, realPolynomialMass (P.form.center i) ≤ M) + (A : PolynomialSlots Y d P.weight) : + (polynomialShearNilmanifold P.weight s P.weight_le).Niltest (fun _ : Y => 1) where + orbit := A.shearPolynomialOrbit s P.weight_le + observable := (P.shearNiltest M hP).observable + normBound := 1 + lipBound := P.shearObservableLipBound M + norm_le := (P.shearNiltest M hP).norm_le + lipschitz := (P.shearNiltest M hP).lipschitz + +theorem fixedObservableNiltest_unitInterval (M : ℝ≥0) + (hP : ∀ i, realPolynomialMass (P.form.center i) ≤ M) + (A : PolynomialSlots Y d P.weight) : + (P.fixedObservableNiltest M hP A).UnitIntervalValued := + P.shearNiltest_unitInterval M hP + +theorem fixedObservableNiltest_eval (M : ℝ≥0) + (hP : ∀ i, realPolynomialMass (P.form.center i) ≤ M) + (A : PolynomialSlots Y d P.weight) (t : Y → ℤ) : + (P.fixedObservableNiltest M hP A).eval t = + ((P.form.shearTransformedSlots P.weight_mono + (A.loweringAt (fun i => (t i : ℝ)))).patchValue P.kernel : ℂ) := by + change (P.shearObservable (QuotientGroup.mk + ((polynomialShearFiltration P.weight s P.weight_le).realification.polynomialOrbitEval + (fun _ : Y => 1) t (A.shearPolynomialOrbit s P.weight_le))) : ℂ) = _ + rw [← NilpotentLieFiltration.polynomialOrbitRealEval_integer] + exact congrArg (fun r : ℝ => (r : ℂ)) + (PolynomialSlots.shearObservable_eval_orbit P.form A P.weight_mono P.weight_pos P.weight_le P.kernel _) + +theorem fixedObservableNiltest_complexity (M : ℝ≥0) + (hP : ∀ i, realPolynomialMass (P.form.center i) ≤ M) + (A : PolynomialSlots Y d P.weight) {p : ℝ} + (h : (P.shearNiltest M hP).ComplexityLE p) : + (P.fixedObservableNiltest M hP A).ComplexityLE p := h + +theorem exists_fixed_observable_family {Ω : Type*} (M : ℝ≥0) + (hP : ∀ i, realPolynomialMass (P.form.center i) ≤ M) + (A : Ω → PolynomialSlots Y d P.weight) {p : ℝ} + (hp : (P.shearNiltest M hP).ComplexityLE p) : + ∃ (F : (polynomialShearNilmanifold P.weight s P.weight_le).Space → ℂ) + (tests : Ω → (polynomialShearNilmanifold P.weight s P.weight_le).Niltest (fun _ : Y => 1)), + (∀ a, (tests a).observable = F ∧ (tests a).UnitIntervalValued ∧ (tests a).ComplexityLE p) ∧ + ∀ a t, ((tests a).eval t).re = + (P.form.shearTransformedSlots P.weight_mono + ((A a).loweringAt (fun i => (t i : ℝ)))).patchValue P.kernel := by + refine ⟨(P.shearNiltest M hP).observable, fun a => P.fixedObservableNiltest M hP (A a), ?_, ?_⟩ + · intro a + exact ⟨rfl, P.fixedObservableNiltest_unitInterval M hP (A a), + P.fixedObservableNiltest_complexity M hP (A a) hp⟩ + · intro a t + exact congrArg Complex.re (P.fixedObservableNiltest_eval M hP (A a) t) + +end PolynomialPatch + +theorem exists_mass_bounded_patch_niltest_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X : Type*} {d : ℕ} (P : PolynomialPatch X s d) + [Fintype (PolynomialShearIndex P.weight)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra P.weight ℚ)] + (M : ℝ≥0) (hP : ∀ i, realPolynomialMass (P.form.center i) ≤ M) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (M : ℝ) ≤ p → (P.kernel.lip : ℝ) ≤ Real.exp p → + (P.shearNiltest M hP).ComplexityLE ((p + 2) ^ C) := by + obtain ⟨a, ha, hlog⟩ := exists_bchLogMetricConstant_exp_bound s + obtain ⟨C, hC, hbudget⟩ := exists_mass_bounded_shear_parameter_budget s a + refine ⟨C, hC, ?_⟩ + intro X d P _ _ _ _ _ M hP p hp hd hMp hLip + let D := Fintype.card (PolynomialShearIndex P.weight) + have hD : D ≤ d * (d + 1) ^ s := by + simpa only [Fintype.card_fin] using polynomialShearIndex_card_le P.weight s + (fun i => lt_of_lt_of_le Nat.zero_lt_one (P.weight_pos i)) P.weight_le + obtain ⟨t, ht, hgeom, htotal⟩ := hbudget d D M p hp M.coe_nonneg hMp hd hD + have hDt : (D : ℝ) ≤ t := by + have hle : D ≤ D + s.factorial + 2 * s + 1 := by omega + exact (Nat.cast_le.mpr hle).trans hgeom + have hHt : ((2 * s + 1 : ℕ) : ℝ) ≤ t := by + have hle : 2 * s + 1 ≤ D + s.factorial + 2 * s + 1 := by omega + exact (Nat.cast_le.mpr hle).trans hgeom + have hHexp : ((2 * s + 1 : ℕ) : ℝ) ≤ Real.exp t := + hHt.trans (by linarith [Real.add_one_le_exp t]) + have hClog := hlog D (2 * s + 1) t ht hDt hHexp + have hv : 0 ≤ (t + a) ^ a + 1 := by positivity + have hObs := shearObservable_log_bound P M hp hv hLip hClog + have hK := shearKernelLogBudget_nonneg s d M.coe_nonneg hp + have hT := shearActionLogBudget_nonneg s d M.coe_nonneg + have htP : t ≤ (p + 2) ^ C := by + linarith [pow_nonneg (by positivity : 0 ≤ t + a) a] + apply P.shearNiltest_complexity M hP + · exact RationalFilteredNilmanifold.GeometryComplexityLE.mono + (polynomialShearNilmanifold P.weight s P.weight_le) + (polynomialShearNilmanifold_complexity_budget P.weight s + (fun i => lt_of_lt_of_le Nat.zero_lt_one (P.weight_pos i)) P.weight_le) + (hgeom.trans htP) + · linarith + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal TensorProduct + +theorem exists_fixed_local_patch_ordinary_niltest_family (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X Y Ω : Type*} {d : ℕ} {w : Fin d → ℕ} + [Fintype (PolynomialShearIndex w)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + (Ψ : PatchKernel d) (B : PolynomialSlots X d w) + (localForm : Ω → PolynomialSlots Y d w) + (hw : Monotone w) (_hpos : ∀ i, 1 ≤ w i) (hs : ∀ i, w i ≤ s) + (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → + (∀ i, realPolynomialMass (B.center i) ≤ p) → + (Ψ.lip : ℝ) ≤ Real.exp p → + ∃ (F : (polynomialShearNilmanifold w s hs).Space → ℂ) + (tests : Ω → (polynomialShearNilmanifold w s hs).Niltest (fun _ : Y => 1)), + (∀ a, (tests a).observable = F ∧ (tests a).UnitIntervalValued ∧ + (tests a).ComplexityLE ((p + 2) ^ C)) ∧ + ∀ a t, (tests a).eval t = + ((B.shearTransformedSlots hw + ((localForm a).loweringAt (fun i => (t i : ℝ)))).patchValue Ψ : ℂ) := by + obtain ⟨C, hC, hbudget⟩ := exists_mass_bounded_patch_niltest_budget s + refine ⟨C, hC, ?_⟩ + intro X Y Ω d w _ _ _ _ _ Ψ B localForm hw hpos hs p hp hd hB hΨ + let P : PolynomialPatch X s d := ⟨w, hpos, hs, hw, B, Ψ⟩ + let M : ℝ≥0 := ⟨p, hp⟩ + have hPm (i) : realPolynomialMass (P.form.center i) ≤ M := hB i + have hcomplex := hbudget P M hPm p hp hd le_rfl hΨ + refine ⟨(P.shearNiltest M hPm).observable, + fun a => P.fixedObservableNiltest M hPm (localForm a), ?_, ?_⟩ + · intro a + exact ⟨rfl, P.fixedObservableNiltest_unitInterval M hPm (localForm a), + P.fixedObservableNiltest_complexity M hPm (localForm a) hcomplex⟩ + · intro a t + exact P.fixedObservableNiltest_eval M hPm (localForm a) t + +theorem exists_fixed_local_patch_ordinary_niltest_family_preserving_scores (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {X Y Ω T : Type*} [Fintype Ω] [Fintype T] + {d : ℕ} {w : Fin d → ℕ} + [Fintype (PolynomialShearIndex w)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra w ℚ)] + (Ψ : PatchKernel d) (B : PolynomialSlots X d w) + (localForm : Ω → PolynomialSlots Y d w) + (hw : Monotone w) (_hpos : ∀ i, 1 ≤ w i) (hs : ∀ i, w i ≤ s) + (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → + (∀ i, realPolynomialMass (B.center i) ≤ p) → + (Ψ.lip : ℝ) ≤ Real.exp p → + ∀ (outer : FiniteProbabilityWeights Ω) (productive retained : Finset Ω) + (localLaw : Ω → FiniteProbabilityWeights T) (point : Ω → T → Y → ℤ) + (score : Ω → T → ℝ) (massThreshold correlationThreshold : ℝ), + retained ⊆ productive → massThreshold ≤ outer.mass retained → + (∀ a ∈ retained, correlationThreshold ≤ (localLaw a).mean (fun t => + score a t * (B.shearTransformedSlots hw + ((localForm a).loweringAt (fun i => (point a t i : ℝ)))).patchValue Ψ)) → + ∃ (F : (polynomialShearNilmanifold w s hs).Space → ℂ) + (tests : Ω → (polynomialShearNilmanifold w s hs).Niltest (fun _ : Y => 1)), + (∀ a, (tests a).observable = F ∧ (tests a).UnitIntervalValued ∧ + (tests a).ComplexityLE ((p + 2) ^ C)) ∧ + retained ⊆ productive ∧ massThreshold ≤ outer.mass retained ∧ + (∀ a t, (tests a).eval t = + ((B.shearTransformedSlots hw + ((localForm a).loweringAt (fun i => (t i : ℝ)))).patchValue Ψ : ℂ)) ∧ + ∀ a ∈ retained, correlationThreshold ≤ (localLaw a).mean (fun t => + score a t * ((tests a).eval (point a t)).re) := by + obtain ⟨C, hC, hfamily⟩ := exists_fixed_local_patch_ordinary_niltest_family s + refine ⟨C, hC, ?_⟩ + intro X Y Ω T _ _ d w _ _ _ _ _ Ψ B localForm hw hpos hs p hp hd hB hΨ + outer productive retained localLaw point score massThreshold correlationThreshold + hretained hmass hscore + obtain ⟨F, tests, htests, heval⟩ := + hfamily Ψ B localForm hw hpos hs p hp hd hB hΨ + refine ⟨F, tests, htests, hretained, hmass, heval, ?_⟩ + intro a ha + simpa only [heval, Complex.ofReal_re] using hscore a ha + +end Erdos3 + +end + +section + +namespace Erdos3.PolynomialPatch + +open scoped NNReal TensorProduct + +variable {σ τ ξ : Type*} {s d : ℕ} (A : PolynomialPatch σ s d) + [Fintype (PolynomialShearIndex A.weight)] + [TopologicalSpace (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + [T2Space (ℝ ⊗[ℚ] PolynomialShearLieAlgebra A.weight ℚ)] + +theorem exists_ordinary_niltest_of_weighted_chart + (M : ℝ≥0) (hA : ∀ i, realPolynomialMass (A.form.center i) ≤ M) + {p : ℝ} (hcomplex : (A.shearNiltest M hA).ComplexityLE p) + (w : ξ → ℕ) (β : ξ → MvPolynomial τ ℝ) + (hβ : ∀ i, β i ∈ weightedSupportLE (fun _ : τ => 1) (w i)) + (g : (polynomialShearFiltration A.weight s A.weight_le).realification.PolynomialOrbit w) : + ∃ T : (polynomialShearNilmanifold A.weight s A.weight_le).Niltest (fun _ : τ => 1), + T.observable = (A.shearNiltest M hA).observable ∧ + T.normBound = (A.shearNiltest M hA).normBound ∧ + T.lipBound = (A.shearNiltest M hA).lipBound ∧ + T.UnitIntervalValued ∧ T.ComplexityLE p ∧ + ∀ x : τ → ℤ, T.eval x = + ((A.ofWeightedChartShearOrbit w β hβ g).value (fun i => (x i : ℝ)) : ℂ) := by + let orbit := (polynomialShearFiltration A.weight s A.weight_le).polynomialOrbitRealChart + w (fun _ : τ => 1) β hβ g + let T := (A.shearNiltest M hA).withOrbit orbit + refine ⟨T, rfl, rfl, rfl, A.shearNiltest_unitInterval M hA, hcomplex, ?_⟩ + intro x + have heval := A.ofShearOrbit_value_integer orbit x + exact ((A.shearNiltest M hA).withOrbit_eval orbit x).trans + (congrArg (fun r : ℝ => (r : ℂ)) heval.symm) + +end Erdos3.PolynomialPatch + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialPotentialBCHHom.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialPotentialBCHHom.lean new file mode 100644 index 0000000000000000000000000000000000000000..066db748e2adc247aeb0bfae5a65849da023cf6b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialPotentialBCHHom.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.Progressions.Linear.WeightedTranslationBasisHeight + +namespace OAI + +section + +namespace Erdos3.PolynomialTranslationLie + +open MvPolynomial +variable {σ : Type*} [Fintype σ] + +theorem lie_eq_zero_of_potential (V : MvPolynomial σ ℚ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hV : ∀ x ∈ U, scalarDirectionalDerivative x.base V = x.polynomial) + (x y : U) : ⁅x,y⁆ = 0 := by + apply Subtype.ext + apply PolynomialTranslationLie.ext + · rfl + · change scalarDirectionalDerivative x.val.base y.val.polynomial - + scalarDirectionalDerivative y.val.base x.val.polynomial = 0 + rw [← hV x.val x.property, ← hV y.val y.property, + scalarDirectionalDerivative_commute, sub_self] + +theorem potential_lowerCentralSeries_eq_bot (V : MvPolynomial σ ℚ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hV : ∀ x ∈ U, scalarDirectionalDerivative x.base V = x.polynomial) : + LieModule.lowerCentralSeries ℚ U U 1 = ⊥ := by + rw [LieModule.lowerCentralSeries_succ] + apply bot_unique + rw [LieSubmodule.lie_le_iff] + intro x _ y _ + change ⁅x,y⁆ = 0 + exact lie_eq_zero_of_potential V U hV x y + +noncomputable def potentialExponentialHom (V : MvPolynomial σ ℚ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hV : ∀ x ∈ U, scalarDirectionalDerivative x.base V = x.polynomial) : + NilpotentLieBCHGroup U 1 (potential_lowerCentralSeries_eq_bot V U hV) →* + PolynomialTranslationGroup σ where + toFun g := PolynomialTranslationGroup.exponentialElement g.coord.val.base g.coord.val.polynomial + map_one' := by + change PolynomialTranslationGroup.exponentialElement 0 0 = 1 + rw [show (0 : MvPolynomial σ ℚ) = scalarDirectionalDerivative (0 : σ → ℚ) V by simp] + rw [PolynomialTranslationGroup.exponentialElement_potential, + PolynomialTranslationGroup.potentialElement_zero] + map_mul' g h := by + have hb := lieBCH_eq_add_of_lie_eq_zero + (potential_lowerCentralSeries_eq_bot V U hV) (lie_eq_zero_of_potential V U hV g.coord h.coord) + change PolynomialTranslationGroup.exponentialElement (lieBCH 1 g.coord h.coord).val.base + (lieBCH 1 g.coord h.coord).val.polynomial = _ + rw [hb] + have he (x : U) : PolynomialTranslationGroup.exponentialElement x.val.base x.val.polynomial = + PolynomialTranslationGroup.potentialElement V x.val.base := by + rw [← hV x.val x.property, PolynomialTranslationGroup.exponentialElement_potential] + rw [he, he, he] + exact PolynomialTranslationGroup.potentialElement_add V _ _ + +@[simp] theorem potentialExponentialHom_mem (V : MvPolynomial σ ℚ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hV : ∀ x ∈ U, scalarDirectionalDerivative x.base V = x.polynomial) + (g : NilpotentLieBCHGroup U 1 (potential_lowerCentralSeries_eq_bot V U hV)) : + potentialExponentialHom V U hV g ∈ PolynomialTranslationGroup.potentialSubgroup V := by + change PolynomialTranslationGroup.exponentialElement g.coord.val.base g.coord.val.polynomial ∈ _ + rw [← hV g.coord.val g.coord.property, PolynomialTranslationGroup.exponentialElement_potential] + exact (PolynomialTranslationGroup.mem_potentialSubgroup V _).mpr rfl + +theorem potentialExponentialHom_injective (V : MvPolynomial σ ℚ) + (U : LieSubalgebra ℚ (PolynomialTranslationLie σ)) + (hV : ∀ x ∈ U, scalarDirectionalDerivative x.base V = x.polynomial) : + Function.Injective (potentialExponentialHom V U hV) := by + intro x y h + have hb : x.coord.val.base = y.coord.val.base := + congrArg PolynomialTranslationGroup.base h + apply NilpotentLieBCHGroup.ext + apply Subtype.ext + apply PolynomialTranslationLie.ext hb + rw [← hV x.coord.val x.coord.property, ← hV y.coord.val y.coord.property, hb] + +end Erdos3.PolynomialTranslationLie + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearBCH.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearBCH.lean new file mode 100644 index 0000000000000000000000000000000000000000..01bd7793e97149c86adc4f19750559e7f2f86ed0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearBCH.lean @@ -0,0 +1,93 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialShearFactorialIntegrality +import OAI.Combinatorics.Progressions.Polynomial.WeightedPolynomialEndomorphisms + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial + +attribute [local instance 100] LieRing.ofAssociativeRing + +variable {σ : Type*} + +noncomputable def polynomialShearAssociativeAction (w : σ → ℕ) (s : ℕ) : + PolynomialShearLieAlgebra w ℚ →ₗ⁅ℚ⁆ weightedPolynomialEndAlgebra (R := ℚ) w s where + toLinearMap := + { toFun := fun D => ⟨polynomialShearEnd D s, + weightedPolynomialEndDrop_antitone w s (Nat.zero_le 1) + (polynomialShearEnd_mem_drop w s 1 D.property)⟩ + map_add' := by + intro D E + apply Subtype.ext + exact (polynomialShearAction w s).map_add D E + map_smul' := by + intro c D + apply Subtype.ext + exact (polynomialShearAction w s).map_smul c D } + map_lie' := by + intro D E + apply Subtype.ext + exact (polynomialShearAction w s).map_lie D E + +theorem polynomialShearAssociativeAction_positive (w : σ → ℕ) (s : ℕ) + (D : PolynomialShearLieAlgebra w ℚ) : + polynomialShearAssociativeAction w s D ∈ (weightedPolynomialEndFiltration w s).layer 1 := + polynomialShearEnd_mem_drop w s 1 D.property + +theorem polynomialShearExpOn_lieBCH (w : σ → ℕ) (s : ℕ) + (D E : PolynomialShearLieAlgebra w ℚ) : + polynomialShearExpOn (lieBCH s D E) s = polynomialShearExpOn D s * polynomialShearExpOn E s := by + let F := weightedPolynomialEndFiltration w s + let φ := polynomialShearAssociativeAction w s + have hp (A : PolynomialShearLieAlgebra w ℚ) : φ A ∈ F.layer 1 := + polynomialShearAssociativeAction_positive w s A + have hnil (A : PolynomialShearLieAlgebra w ℚ) : IsNilpotent (φ A) := + F.isNilpotent_of_mem le_rfl (hp A) + have he : IsNilpotent.exp (φ (lieBCH s D E)) = IsNilpotent.exp (φ D) * IsNilpotent.exp (φ E) := by + rw [map_lieBCH, F.lieBCH_eq (hp D) (hp E)] + exact exp_nilpotentBCH (F.layerAlgebra 1) F.positive_nilpotent (hp D) (hp E) + have hv := congrArg (weightedPolynomialEndAlgebra (R := ℚ) w s).val he + rw [map_mul, IsNilpotent.map_exp (hnil (lieBCH s D E)), + IsNilpotent.map_exp (hnil D), IsNilpotent.map_exp (hnil E)] at hv + exact hv + +theorem polynomialShearExpAut_lieBCH (w : σ → ℕ) (s : ℕ) (hw : ∀ i, w i ≤ s) + (D E : PolynomialShearLieAlgebra w ℚ) : + polynomialShearExpAut (lieBCH s D E) = polynomialShearExpAut D * polynomialShearExpAut E := by + apply WeightedLoweringAut.degreeActionHom_injective s hw + apply LinearEquiv.toLinearMap_injective + change ((polynomialShearExpAut (lieBCH s D E)).degreeAction s).toLinearMap = + ((polynomialShearExpAut D).degreeAction s).toLinearMap * + ((polynomialShearExpAut E).degreeAction s).toLinearMap + rw [polynomialShearExp_degreeAction, polynomialShearExp_degreeAction, + polynomialShearExp_degreeAction] + exact polynomialShearExpOn_lieBCH w s D E + +noncomputable def polynomialShearBCHEquiv (w : σ → ℕ) (s : ℕ) (hw : ∀ i, w i ≤ s) : + (polynomialShearFiltration w s hw).Group ≃* WeightedLoweringAut w ℚ where + toFun A := polynomialShearExpAut A.coord + invFun e := ⟨polynomialShearLog e⟩ + left_inv A := NilpotentLieBCHGroup.ext (polynomialShearLog_exp A.coord) + right_inv := polynomialShearExp_log + map_mul' A B := polynomialShearExpAut_lieBCH w s hw A.coord B.coord + +theorem weightedLoweringAut_isNilpotent (w : σ → ℕ) (s : ℕ) (hw : ∀ i, w i ≤ s) : + Group.IsNilpotent (WeightedLoweringAut w ℚ) := by + let := (polynomialShearFiltration w s hw).isNilpotentGroup + exact Group.nilpotent_of_mulEquiv (polynomialShearBCHEquiv w s hw) + +theorem weightedLoweringAut_nilpotencyClass_le (w : σ → ℕ) (s : ℕ) (hw : ∀ i, w i ≤ s) : + Group.nilpotencyClass (WeightedLoweringAut w ℚ) ≤ s := by + let := (polynomialShearFiltration w s hw).isNilpotentGroup + exact (Group.nilpotencyClass_le_of_surjective (polynomialShearBCHEquiv w s hw).toMonoidHom + (polynomialShearBCHEquiv w s hw).surjective).trans + (polynomialShear_group_nilpotencyClass_le w s hw) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearBCHOver.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearBCHOver.lean new file mode 100644 index 0000000000000000000000000000000000000000..178eed83ab9299b3460794f330038f03fbd7c275 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearBCHOver.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.Progressions.Polynomial.PolynomialShearRationalFiltration + +namespace OAI + +section + +namespace Erdos3 + +open MvPolynomial +attribute [local instance 100] LieRing.ofAssociativeRing + +variable {σ R : Type*} [CommRing R] [Algebra ℚ R] + +noncomputable def polynomialShearAssociativeActionOver (w : σ → ℕ) (s : ℕ) : + PolynomialShearLieAlgebra w R →ₗ⁅R⁆ weightedPolynomialEndAlgebra (R := R) w s where + toLinearMap := + { toFun := fun D => ⟨polynomialShearEnd D s, + weightedPolynomialEndDrop_antitone w s (Nat.zero_le 1) + (polynomialShearEnd_mem_drop w s 1 D.property)⟩ + map_add' := by + intro D E + apply Subtype.ext + exact (polynomialShearAction w s).map_add D E + map_smul' := by + intro c D + apply Subtype.ext + exact (polynomialShearAction w s).map_smul c D } + map_lie' := by + intro D E + apply Subtype.ext + exact (polynomialShearAction w s).map_lie D E + +noncomputable def polynomialShearAssociativeRatAction (w : σ → ℕ) (s : ℕ) : + PolynomialShearLieAlgebra w R →ₗ⁅ℚ⁆ weightedPolynomialEndAlgebra (R := R) w s where + toLinearMap := (polynomialShearAssociativeActionOver (R := R) w s).toLinearMap.restrictScalars ℚ + map_lie' := by + intro D E + exact (polynomialShearAssociativeActionOver (R := R) w s).map_lie D E + +theorem polynomialShearAssociativeActionOver_positive (w : σ → ℕ) (s : ℕ) + (D : PolynomialShearLieAlgebra w R) : + polynomialShearAssociativeRatAction (R := R) w s D ∈ (weightedPolynomialEndRatFiltration (R := R) w s).layer 1 := + polynomialShearEnd_mem_drop w s 1 D.property + +theorem polynomialShearExpOn_lieBCH_over (w : σ → ℕ) (s : ℕ) + (D E : PolynomialShearLieAlgebra w R) : + polynomialShearExpOn (lieBCH s D E) s = polynomialShearExpOn D s * polynomialShearExpOn E s := by + let F := weightedPolynomialEndRatFiltration (R := R) w s + let φ := polynomialShearAssociativeRatAction (R := R) w s + have hp (A : PolynomialShearLieAlgebra w R) : φ A ∈ F.layer 1 := + polynomialShearAssociativeActionOver_positive w s A + have hnil (A : PolynomialShearLieAlgebra w R) : IsNilpotent (φ A) := + F.isNilpotent_of_mem le_rfl (hp A) + have he : IsNilpotent.exp (φ (lieBCH s D E)) = IsNilpotent.exp (φ D) * IsNilpotent.exp (φ E) := by + rw [map_lieBCH, F.lieBCH_eq (hp D) (hp E)] + exact exp_nilpotentBCH (F.layerAlgebra 1) F.positive_nilpotent (hp D) (hp E) + have hv := congrArg (weightedPolynomialEndAlgebra (R := R) w s).val he + rw [map_mul, IsNilpotent.map_exp (hnil (lieBCH s D E)), + IsNilpotent.map_exp (hnil D), IsNilpotent.map_exp (hnil E)] at hv + exact hv + +theorem polynomialShearExpAut_lieBCH_over (w : σ → ℕ) (s : ℕ) (hw : ∀ i, w i ≤ s) + (D E : PolynomialShearLieAlgebra w R) : + polynomialShearExpAut (lieBCH s D E) = polynomialShearExpAut D * polynomialShearExpAut E := by + apply WeightedLoweringAut.degreeActionHom_injective s hw + apply LinearEquiv.toLinearMap_injective + change ((polynomialShearExpAut (lieBCH s D E)).degreeAction s).toLinearMap = + ((polynomialShearExpAut D).degreeAction s).toLinearMap * + ((polynomialShearExpAut E).degreeAction s).toLinearMap + rw [polynomialShearExp_degreeAction, polynomialShearExp_degreeAction, + polynomialShearExp_degreeAction] + exact polynomialShearExpOn_lieBCH_over w s D E + +noncomputable def polynomialShearBCHEquivOver (w : σ → ℕ) (s : ℕ) (hw : ∀ i, w i ≤ s) : + (polynomialShearRatFiltration (R := R) w s hw).Group ≃* WeightedLoweringAut w R where + toFun A := polynomialShearExpAut A.coord + invFun e := ⟨polynomialShearLog e⟩ + left_inv A := NilpotentLieBCHGroup.ext (polynomialShearLog_exp A.coord) + right_inv := polynomialShearExp_log + map_mul' A B := polynomialShearExpAut_lieBCH_over w s hw A.coord B.coord + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearNilmanifold.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearNilmanifold.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a2df23b437a2c0904caa483a68808c9652f76f3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PolynomialShearNilmanifold.lean @@ -0,0 +1,88 @@ +import OAI.Combinatorics.Progressions.Estimates.RationalPowerHeight +import OAI.Combinatorics.Progressions.Polynomial.PolynomialPatchShearOrbit + +namespace OAI + +section + +namespace Erdos3 + +open Module + +variable {σ : Type*} [Fintype σ] (w : σ → ℕ) [Fintype (PolynomialShearIndex w)] + +noncomputable def polynomialShearLayerBasis (r : ℕ) : + Basis {j : Fin (Fintype.card (PolynomialShearIndex w)) // r ≤ polynomialShearOrderedWeight w j} + ℚ (polynomialShearLayer (R := ℚ) w r) := + supportedSubmoduleBasis (polynomialShearOrderedBasis w) (polynomialShearLayer w r) + {j | r ≤ polynomialShearOrderedWeight w j} (polynomialShearOrderedBasis_layers w r) + +theorem polynomialShearLayerBasis_height (r : ℕ) + (i : {j : Fin (Fintype.card (PolynomialShearIndex w)) // r ≤ polynomialShearOrderedWeight w j}) (j) : + RationalHeightLE ((polynomialShearOrderedBasis w).repr + (polynomialShearLayerBasis w r i).val j) 1 := by + rw [polynomialShearLayerBasis, supportedSubmoduleBasis_coe] + exact basis_repr_height_one (polynomialShearOrderedBasis w) _ _ + +noncomputable def polynomialShearLayerIndexEquiv (r : ℕ) : + {j : Fin (Fintype.card (PolynomialShearIndex w)) // r ≤ polynomialShearOrderedWeight w j} ≃ + Fin (finrank ℚ (polynomialShearLayer (R := ℚ) w r)) := by + classical + exact Fintype.equivFinOfCardEq (finrank_eq_card_basis (polynomialShearLayerBasis w r)).symm + +noncomputable def polynomialShearLayerFinBasis (r : ℕ) : + Basis (Fin (finrank ℚ (polynomialShearLayer (R := ℚ) w r))) + ℚ (polynomialShearLayer (R := ℚ) w r) := + (polynomialShearLayerBasis w r).reindex (polynomialShearLayerIndexEquiv w r) + +theorem polynomialShearLayerFinBasis_height (r : ℕ) (i j) : + RationalHeightLE ((polynomialShearOrderedBasis w).repr + (polynomialShearLayerFinBasis w r i).val j) 1 := by + rw [polynomialShearLayerFinBasis, Basis.reindex_apply] + exact polynomialShearLayerBasis_height w r _ _ + +noncomputable def polynomialShearNilmanifold (s : ℕ) (hw : ∀ i, w i ≤ s) : + RationalFilteredNilmanifold (PolynomialShearLieAlgebra w ℚ) s + (Fintype.card (PolynomialShearIndex w)) where + filtration := polynomialShearFiltration w s hw + basis := polynomialShearOrderedBasis w + layerBasis i := polynomialShearLayerFinBasis w (i.val + 1) + lattice := polynomialShearLattice w s hw + grid := s.factorial + grid_pos := Nat.factorial_pos s + inner_grid := polynomialShearOrderedBasis_inner_grid w s hw + outer_grid := polynomialShearOrderedBasis_outer_grid w s hw + +theorem polynomialShearNilmanifold_complexity (s : ℕ) (hpos : ∀ i, 0 < w i) + (hw : ∀ i, w i ≤ s) {p : ℝ} (hp : 0 ≤ p) + (hd : (Fintype.card (PolynomialShearIndex w) : ℝ) ≤ p) + (hf : (s.factorial : ℝ) ≤ Real.exp p) + (hH : ((2 * s + 1 : ℕ) : ℝ) ≤ Real.exp p) : + (polynomialShearNilmanifold w s hw).GeometryComplexityLE p := by + refine ⟨hd, hf, ?_, ?_⟩ + · intro i j k + exact rationalLogHeight_le_of_height (polynomialShearOrderedBasis_structure_height w s hpos hw i j k) hH + · intro i j k + exact rationalLogHeight_le_of_height (polynomialShearLayerFinBasis_height w (i.val + 1) j k) + (by simpa using Real.one_le_exp_iff.mpr hp) + +theorem polynomialShearNilmanifold_complexity_budget (s : ℕ) (hpos : ∀ i, 0 < w i) + (hw : ∀ i, w i ≤ s) : + (polynomialShearNilmanifold w s hw).GeometryComplexityLE + ((Fintype.card (PolynomialShearIndex w) + s.factorial + 2 * s + 1 : ℕ) : ℝ) := by + let n := Fintype.card (PolynomialShearIndex w) + s.factorial + 2 * s + 1 + have hn : (Fintype.card (PolynomialShearIndex w) : ℝ) ≤ (n : ℝ) := by + exact_mod_cast (show Fintype.card (PolynomialShearIndex w) ≤ n by dsimp [n]; omega) + have hf : (s.factorial : ℝ) ≤ (n : ℝ) := by + exact_mod_cast (show s.factorial ≤ n by dsimp [n]; omega) + have hH : ((2 * s + 1 : ℕ) : ℝ) ≤ (n : ℝ) := by + exact_mod_cast (show 2 * s + 1 ≤ n by dsimp [n]; omega) + have he : (n : ℝ) ≤ Real.exp n := by linarith [Real.add_one_le_exp (n : ℝ)] + exact polynomialShearNilmanifold_complexity w s hpos hw (Nat.cast_nonneg n) hn + (hf.trans he) (hH.trans he) + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PositiveNiltestDiscretization.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PositiveNiltestDiscretization.lean new file mode 100644 index 0000000000000000000000000000000000000000..835f20eced131876a95fab191d8748b35ac8d7ef --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PositiveNiltestDiscretization.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.Progressions.Nilpotent.IdealInvariantNiltestBudget + +namespace OAI + +section + +namespace Erdos3 + +open scoped BigOperators TensorProduct NNReal + +theorem exists_positive_niltest_discretization + {I J Ξ : Type*} [Fintype I] [Fintype J] [PseudoMetricSpace Ξ] + (N : ℕ) [NeZero N] {K : ZMod N → Type*} + [∀ h, LieRing (K h)] [∀ h, LieAlgebra ℚ (K h)] {s : ℕ} {d : ZMod N → ℕ} + [∀ h, TopologicalSpace (ℝ ⊗[ℚ] K h)] [∀ h, IsTopologicalAddGroup (ℝ ⊗[ℚ] K h)] + [∀ h, ContinuousSMul ℝ (ℝ ⊗[ℚ] K h)] [∀ h, T2Space (ℝ ⊗[ℚ] K h)] + (D : ∀ h, RationalFilteredNilmanifold (K h) s (d h)) + (g : ∀ h, (D h).filtration.realification.PolynomialOrbit (fun _ : Unit => 1)) + (F : ∀ h, (D h).Space → Ξ → ℝ) + (A : I → ZMod N → ℝ) (B : J → ZMod N → ℝ) (E : ZMod N → Set (ZMod N)) + (xi : ZMod N → ZMod N → Ξ) (T : ZMod N → ZMod N → ℝ) + {L M : ℝ≥0} {rho p : ℝ} + (hA : ∀ i n, 0 ≤ A i n) (hB : ∀ j n, 0 ≤ B j n) + (hAsum : ∀ n, ∑ i, A i n = 1) (hBsum : ∀ n, ∑ j, B j n = 1) + (hF : ∀ h z a, 0 ≤ F h z a ∧ F h z a ≤ 1) + (hFirstLip : ∀ h, let := (D h).metricSpace; ∀ a, LipschitzWith M (fun z => F h z a)) + (hSecondLip : ∀ h z, LipschitzWith L (F h z)) + (hGeometry : ∀ h, (D h).GeometryComplexityLE p) + (hBudget : Real.log (3 + (M : ℝ)) ≤ p) + (hT : ∀ h n, n ∉ E h → + T h n = F h ((D h).cyclicOrbitPoint (g h) N (fun _ : Unit => n)) (xi h n)) + (hdiam : ∀ i j h n n', n ∉ E h → n' ∉ E h → + 0 < A i n * B j (n + h) → 0 < A i n' * B j (n' + h) → + dist (xi h n) (xi h n') ≤ rho) : + ∃ U : I → J → (h : ZMod N) → (D h).Niltest (fun _ : Unit => 1), + (∀ i j h, (U i j h).UnitIntervalValued) ∧ + (∀ i j h, (U i j h).ComplexityLE p) ∧ + (∀ i j h, (¬∃ n, n ∉ E h ∧ 0 < A i n * B j (n + h)) → + ∀ x, (U i j h).eval x = 0) ∧ + ∀ h n, n ∉ E h → + |T h n - ∑ i, ∑ j, A i n * B j (n + h) * + ((U i j h).evalCyclic N (fun _ : Unit => n)).re| ≤ L * rho := by + let z : (h : ZMod N) → ZMod N → (D h).Space := + fun h n => (D h).cyclicOrbitPoint (g h) N (fun _ : Unit => n) + obtain ⟨a, hempty, herr⟩ := exists_positive_shift_discretization A B E z xi F T + hA hB hAsum hBsum hT hSecondLip hdiam + let U : I → J → (h : ZMod N) → (D h).Niltest (fun _ : Unit => 1) := + fun i j h => (D h).sectionNiltest (g h) (F h) (hF h) M (hFirstLip h) (a i j h) + refine ⟨U, ?_, ?_, ?_, ?_⟩ + · intro i j h + exact (D h).sectionNiltest_unit_interval (g h) (F h) (hF h) M (hFirstLip h) (a i j h) + · intro i j h + exact (D h).sectionNiltest_complexityLE (g h) (F h) (hF h) M (hFirstLip h) + (a i j h) (hGeometry h) hBudget + · intro i j h hcell x + dsimp only [U] + rw [hempty i j h hcell] + exact (D h).sectionNiltest_none_eval (g h) (F h) (hF h) M (hFirstLip h) x + · intro h n hn + have heval (i : I) (j : J) : ((U i j h).evalCyclic N (fun _ : Unit => n)).re = + frozenRealSection (F h) (a i j h) (z h n) := rfl + simpa only [heval] using herr h n hn + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PositivePolynomialFactorNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PositivePolynomialFactorNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c45e5c466a5704fec60d8a09ec94e640be0646f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PositivePolynomialFactorNiltests.lean @@ -0,0 +1,73 @@ +import OAI.Combinatorics.Progressions.Polynomial.PositivePolynomialVectorOrbit + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open scoped TensorProduct NNReal + +variable {σ L : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + {s d : ℕ} {D : RationalFilteredNilmanifold L s d} {bound : σ → ℕ} + (M : D.MultidegreeStructure bound) (J : Set (σ →₀ ℕ)) [DecidablePred (· ∈ J)] + (hJ : IsLowerSet J) + [TopologicalSpace (ℝ ⊗[ℚ] (M.filtration.positivePolynomialAlgebra ⧸ + VectorPolynomial.restrictedOutsideDownsetIdeal M.filtration.positivePolynomialAlgebra J hJ))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (M.filtration.positivePolynomialAlgebra ⧸ + VectorPolynomial.restrictedOutsideDownsetIdeal M.filtration.positivePolynomialAlgebra J hJ))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (M.filtration.positivePolynomialAlgebra ⧸ + VectorPolynomial.restrictedOutsideDownsetIdeal M.filtration.positivePolynomialAlgebra J hJ))] + [T2Space (ℝ ⊗[ℚ] (M.filtration.positivePolynomialAlgebra ⧸ + VectorPolynomial.restrictedOutsideDownsetIdeal M.filtration.positivePolynomialAlgebra J hJ))] + (p : ℝ) (B : ℕ) (hB : 0 < B) (hstable : M.PositivePolynomialGridStable p B) + (g : M.filtration.positivePolynomialMultidegree.realification.PolynomialOrbit) + (ψ : (M.positivePolynomialDownsetModel J hJ p B hB hstable).Space → ℝ) + (hψ : ∀ x, 0 ≤ ψ x ∧ ψ x ≤ 1) (K : ℝ≥0) + (hLip : letI := (M.positivePolynomialDownsetModel J hJ p B hB hstable).metricSpace; + LipschitzWith K ψ) + +noncomputable def positivePolynomialFactorNiltest : + (M.positivePolynomialDownsetModel J hJ p B hB hstable).Niltest (fun _ : σ => 1) := + (M.positivePolynomialDownsetModel J hJ p B hB hstable).sectionNiltest + ((M.positivePolynomialDownsetModelMultidegree J hJ p B hB hstable).orbitToOrdinary + (M.filtration.positivePolynomialDownsetOrbit J hJ g)) + (fun z (_ : Unit) => ψ z) (fun z _ => hψ z) K (fun _ => hLip) (some ()) + +theorem positivePolynomialFactorNiltest_normBound : + (M.positivePolynomialFactorNiltest J hJ p B hB hstable g ψ hψ K hLip).normBound = 1 := rfl + +theorem positivePolynomialFactorNiltest_unit_interval : + (M.positivePolynomialFactorNiltest J hJ p B hB hstable g ψ hψ K hLip).UnitIntervalValued := + (M.positivePolynomialDownsetModel J hJ p B hB hstable).sectionNiltest_unit_interval _ _ _ _ _ _ + +theorem positivePolynomialFactorNiltest_eval (x : σ → ℤ) : + (M.positivePolynomialFactorNiltest J hJ p B hB hstable g ψ hψ K hLip).eval x = + (ψ (QuotientGroup.mk ((M.filtration.positivePolynomialDownsetQuotient J hJ).realification.polynomialOrbitEval x + (M.filtration.positivePolynomialDownsetOrbit J hJ g))) : ℂ) := by + exact congrArg (fun z : (M.positivePolynomialDownsetModel J hJ p B hB hstable).RealGroup => + (ψ (QuotientGroup.mk z) : ℂ)) + ((M.positivePolynomialDownsetModelMultidegree J hJ p B hB hstable).orbitToOrdinary_eval + (M.filtration.positivePolynomialDownsetOrbit J hJ g) x) + +theorem positivePolynomialFactorNiltest_complexity {q : ℝ} + (hE : (M.positivePolynomialDownsetModel J hJ p B hB hstable).GeometryComplexityLE q) + (hK : (K : ℝ) ≤ Real.exp q) : + (M.positivePolynomialFactorNiltest J hJ p B hB hstable g ψ hψ K hLip).ComplexityLE (q + 2) := by + have hq : 0 ≤ q := (Nat.cast_nonneg _).trans hE.1 + have h2 : (4 : ℝ) ≤ Real.exp 2 := by + rw [show (2 : ℝ) = 1 + 1 by norm_num, Real.exp_add] + nlinarith [Real.add_one_le_exp (1 : ℝ)] + have hlog : Real.log (3 + (K : ℝ)) ≤ q + 2 := by + apply (Real.log_le_iff_le_exp (by positivity)).mpr + rw [Real.exp_add] + nlinarith [Real.one_le_exp hq, + mul_le_mul_of_nonneg_left h2 (Real.exp_nonneg q)] + exact (M.positivePolynomialDownsetModel J hJ p B hB hstable).sectionNiltest_complexityLE + _ _ _ _ _ _ (hE.mono _ (by linarith)) hlog + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PositiveShiftTestingNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PositiveShiftTestingNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a794a44aeb972bb0f2451063a4f36b418910531 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PositiveShiftTestingNiltests.lean @@ -0,0 +1,66 @@ +import OAI.Combinatorics.Progressions.Linear.ShiftFailurePositiveBasis + +namespace OAI + +section + +namespace Erdos3.PositiveShiftBasis + +open scoped TensorProduct NNReal + +attribute [local instance] PositiveShiftBasis.lie PositiveShiftBasis.algebra + PositiveShiftBasis.topology PositiveShiftBasis.topologicalAdd + PositiveShiftBasis.continuousSMul PositiveShiftBasis.hausdorff + +variable {s N : ℕ} [NeZero N] {q : ℝ} {a J : ZMod N → ℝ} + +noncomputable def testingNiltest (B : PositiveShiftBasis s N q a J) + (hk : ZMod N × Fin B.count) : B.model.Niltest (fun _ : Fin 1 => 1) := by + classical + exact if hk.1 ∈ B.shifts then + (B.mode hk.1 hk.2).linearPullbackHom (fun _ : Unit => + { toFun := fun x => x 0, map_zero' := rfl, map_add' := fun _ _ => rfl }) + else RationalFilteredNilmanifold.Niltest.const B.model (fun _ : Fin 1 => 1) 0 + +theorem testingNiltest_eval (B : PositiveShiftBasis s N q a J) + (hk : ZMod N × Fin B.count) (x : ZMod N) : + (B.testingNiltest hk).eval (fun _ => (x.val : ℤ)) = B.testingFamily hk x := by + classical + by_cases hh : hk.1 ∈ B.shifts + · simp only [testingNiltest, testingFamily, ite_eq_left hh, + RationalFilteredNilmanifold.Niltest.eval_linearPullbackHom, + RationalFilteredNilmanifold.Niltest.evalCyclic, + AddMonoidHom.coe_mk, ZeroHom.coe_mk] + · simp only [testingNiltest, testingFamily, ite_eq_right hh, + RationalFilteredNilmanifold.Niltest.eval_const] + +theorem testingNiltest_norm (B : PositiveShiftBasis s N q a J) + (hk : ZMod N × Fin B.count) : (B.testingNiltest hk).normBound ≤ 1 := by + classical + by_cases hh : hk.1 ∈ B.shifts + · simp only [testingNiltest, ite_eq_left hh] + change (B.mode hk.1 hk.2).normBound ≤ 1 + exact B.mode_norm hk.1 hh hk.2 + · simp [testingNiltest, hh, RationalFilteredNilmanifold.Niltest.const] + +theorem testingNiltest_complexity (B : PositiveShiftBasis s N q a J) + (hk : ZMod N × Fin B.count) : (B.testingNiltest hk).ComplexityLE (q + 2) := by + classical + by_cases hh : hk.1 ∈ B.shifts + · simp only [testingNiltest, ite_eq_left hh, + RationalFilteredNilmanifold.Niltest.linearPullbackHom_complexityLE] + exact (B.mode_complexity hk.1 hh hk.2).mono (by linarith) + · simp only [testingNiltest, ite_eq_right hh] + refine ⟨RationalFilteredNilmanifold.GeometryComplexityLE.mono B.model B.geometry + (by linarith), ?_⟩ + change Real.log (2 + (‖(0 : ℂ)‖₊ : ℝ) + (0 : ℝ)) ≤ q + 2 + simp only [nnnorm_zero, NNReal.coe_zero, add_zero] + have hq : 0 ≤ q := (Nat.cast_nonneg B.dim).trans B.geometry.1 + have hlog := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + +end Erdos3.PositiveShiftBasis + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedAdditionNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedAdditionNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..b134aeef4c71472d845f9deda59adafef9d6ded3 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedAdditionNiltest.lean @@ -0,0 +1,173 @@ +import OAI.Combinatorics.Progressions.Estimates.DilationCost +import OAI.Combinatorics.Progressions.Geometry.NativeTripleObservableMetric + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct BigOperators NNReal + +variable {σ L I : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [Fintype I] {s d r n : ℕ} {D : RationalFilteredNilmanifold L (s + 1) d} {bound : σ → ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (M : D.MultidegreeStructure bound) (i : σ) (hi : bound i = 1) (hs : ∑ j, bound j = s + 1) + (E : RationalFilteredNilmanifold (M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) (s + 1) r) + (hEF : E.filtration = M.filtration.additiveTripleFiltration i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) + (hEL : E.lattice = M.additiveTripleLattice i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + [T2Space (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + (Q : RationalFilteredNilmanifold ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)) s n) + (hQF : Q.filtration = E.filtration.quotientTop) + (hQL : Q.lattice = E.lattice.map (E.filtration.quotientStepHom + (E.filtration.layerIdeal (s + 1)) (t := s) le_rfl)) + [TopologicalSpace (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + +include hs hEF hQF hQL + +theorem exists_addition_niltest_of_data {H : ℕ} (hH : 1 ≤ H) + (hentries : ∀ j k, RationalHeightLE + (Q.basis.repr (lieQuotientMap (E.filtration.layerIdeal (s + 1)) (E.basis k)) j) H) + (hstructure : ∀ a b c, RationalHeightLE (lieStructureConstants Q.basis a b c) H) + {p : ℝ} (V : D.UnitVerticalObservable (M.realSubgroup bound) I p) + (g : M.filtration.realification.PolynomialOrbit) (ε γ : D.RealGroup) + (hγ : γ ∈ D.realLattice) (hfactor : M.filtration.realification.polynomialOrbitEval 0 g = ε * γ) + (a : Fin 3 → I) (A : ℝ≥0) + (hLip : letI := E.metricSpace + LipschitzWith A (M.tripleObservable i hi.le _ (omittedCoordinateWeight_le_one i) + E hEL ε (fun j => V.observable (a j)))) : + ∃ T : Q.Niltest (fun _ : Option σ => 1), T.normBound = 1 ∧ + T.lipBound = rationalReconstructionLipschitzBound s r n H A 1 ∧ + Q.filtration.realification.polynomialOrbitEval _ 0 T.orbit = 1 ∧ + ∀ x, T.eval x = coordinateAdditionProduct + (fun j y => V.observable j (QuotientGroup.mk (M.filtration.realification.polynomialOrbitEval y g))) + a i x := by + obtain ⟨q, hq0, hq⟩ := M.exists_native_addition_orbit i hi.le E hEF g ε γ hγ hfactor + obtain ⟨T, hTnorm, hTlip, hTorbit, hTval⟩ := M.exists_unitVertical_triple_quotient_niltest + i hi hs E hEF hEL Q hQL hQF hH hentries hstructure V ε a A hLip q + refine ⟨T, hTnorm, hTlip, ?_, ?_⟩ + · rw [hTorbit, E.topQuotientOrbit_eval Q hQF, hq0, map_one] + · intro x + rw [hTval] + exact M.tripleObservable_of_addition_values i hi.le E hEL g ε q hq + (fun j => V.observable (a j)) x + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct BigOperators NNReal + +variable {σ L I : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [Fintype I] {s d r n : ℕ} {D : RationalFilteredNilmanifold L (s + 1) d} {bound : σ → ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (M : D.MultidegreeStructure bound) (i : σ) (hi : bound i = 1) (hs : ∑ j, bound j = s + 1) + (E : RationalFilteredNilmanifold (M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) (s + 1) r) + (hEF : E.filtration = M.filtration.additiveTripleFiltration i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) + (hEL : E.lattice = M.additiveTripleLattice i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + [T2Space (ℝ ⊗[ℚ] M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i))] + (Q : RationalFilteredNilmanifold ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)) s n) + (hQF : Q.filtration = E.filtration.quotientTop) + (hQL : Q.lattice = E.lattice.map (E.filtration.quotientStepHom + (E.filtration.layerIdeal (s + 1)) (t := s) le_rfl)) + [TopologicalSpace (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] ((M.filtration.additiveTripleSubalgebra i hi.le + (omittedCoordinateWeight i) (omittedCoordinateWeight_le_one i)) ⧸ E.filtration.layerIdeal (s + 1)))] + +include hs hEF hEL hQF hQL + +theorem exists_prepared_addition_niltest + {p : ℝ} (hp : 0 ≤ p) + (hD : D.GeometryComplexityLE (MultilinearityBudget.ambient p)) + (hE : E.GeometryComplexityLE (MultilinearityBudget.ambient p)) + (he : ∀ j a k, rationalLogHeight (D.basis.repr + (M.filtration.additiveTripleProjection i hi.le _ (omittedCoordinateWeight_le_one i) j (E.basis a)) k) ≤ + MultilinearityBudget.ambient p) + (hQ : Q.GeometryComplexityLE (MultilinearityBudget.quotient p)) + (hq : ∀ j k, rationalLogHeight + (Q.basis.repr (lieQuotientMap (E.filtration.layerIdeal (s + 1)) (E.basis k)) j) ≤ + MultilinearityBudget.quotient p) + (V : D.UnitVerticalObservable (M.realSubgroup bound) I p) + (g : M.filtration.realification.PolynomialOrbit) (C : ℕ) (ε γ : D.RealGroup) + (hγ : γ ∈ D.realLattice) (hfactor : M.filtration.realification.polynomialOrbitEval 0 g = ε * γ) + (A : ℝ≥0) (hA : (A : ℝ) ≤ Real.exp ((p + C) ^ C)) + (hε : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => ε • x)) + (a : Fin 3 → I) : + ∃ T : Q.Niltest (fun _ : Option σ => 1), T.normBound = 1 ∧ + T.ComplexityLE (MultilinearityBudget.total C (MultilinearityBudget.reconstructionExponent s) p) ∧ + Q.filtration.realification.polynomialOrbitEval _ 0 T.orbit = 1 ∧ + ∀ x, T.eval x = coordinateAdditionProduct + (fun j y => V.observable j (QuotientGroup.mk (M.filtration.realification.polynomialOrbitEval y g))) + a i x := by + let H := ⌈Real.exp (MultilinearityBudget.quotient p)⌉₊ + let A₃ : ℝ≥0 := 3 * (V.lipBound * (A * + ⟨Real.exp ((MultilinearityBudget.ambient p + 3) ^ 2), (Real.exp_pos _).le⟩)) + have hLip : letI := E.metricSpace + LipschitzWith A₃ (M.tripleObservable i hi.le _ (omittedCoordinateWeight_le_one i) + E hEL ε (fun j => V.observable (a j))) := + M.tripleObservable_lipschitz i hi.le _ (omittedCoordinateWeight_le_one i) E hEL + (MultilinearityBudget.ambient_bounds hp).1 hD hE he ε (fun j => V.observable (a j)) + V.lipBound A (fun j x => V.norm (a j) x) (fun j => V.lipschitz (a j)) hε + obtain ⟨T, hTnorm, hTlip, hTzero, hTeval⟩ := M.exists_addition_niltest_of_data + i hi hs E hEF hEL Q hQF hQL (one_le_ceil_exp _) + (fun j k => rationalHeightLE_ceil_exp (hq j k)) + (fun j k l => rationalHeightLE_ceil_exp (hQ.2.2.1 j k l)) + V g ε γ hγ hfactor a A₃ hLip + have hR := MultilinearityBudget.reconstruction_bounds C hp + have hHb : (H : ℝ) ≤ Real.exp (MultilinearityBudget.reconstruction C p) := + (ceil_exp_le_exp_add_one (MultilinearityBudget.quotient_bounds hp).1).trans + (Real.exp_le_exp.mpr hR.2.2.1) + have hA₃ : (A₃ : ℝ) ≤ Real.exp (MultilinearityBudget.reconstruction C p) := by + change (3 : ℝ) * (V.lipBound * (A * Real.exp ((MultilinearityBudget.ambient p + 3) ^ 2))) ≤ _ + exact (MultilinearityBudget.observable_bound C p V.lipBound A V.lip_bound hA).trans + (Real.exp_le_exp.mpr hR.2.2.2) + exact ⟨T, hTnorm, MultilinearityBudget.niltest_complexity Q T C r H A₃ hp hQ + (hE.1.trans hR.2.1) hHb hA₃ hTnorm hTlip, hTzero, hTeval⟩ + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedDilationNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedDilationNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..5277e06fe561601dc6e473b5e32c11d406cbeaee --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedDilationNiltest.lean @@ -0,0 +1,86 @@ +import OAI.Combinatorics.Progressions.Estimates.DilationCost +import OAI.Combinatorics.Progressions.Estimates.NativeDilationDescent +import OAI.Combinatorics.Progressions.Geometry.NativeDilationObservableMetric + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct BigOperators NNReal + +variable {σ L I : Type*} [Fintype σ] [DecidableEq σ] [LieRing L] [LieAlgebra ℚ L] + [Fintype I] {s d r n : ℕ} {D : RationalFilteredNilmanifold L (s + 1) d} {bound : σ → ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (M : D.MultidegreeStructure bound) (q : ℤ) (hs : ∑ j, bound j = s + 1) + (E : RationalFilteredNilmanifold (M.filtration.ordinary.dilationPairSubalgebra (q : ℚ)) (s + 1) r) + (hEF : E.filtration = M.filtration.ordinary.dilationPairFiltration (q : ℚ)) + (hEL : E.lattice = M.dilationPairLattice (q : ℚ)) + [TopologicalSpace (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra (q : ℚ))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra (q : ℚ))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra (q : ℚ))] + [T2Space (ℝ ⊗[ℚ] M.filtration.ordinary.dilationPairSubalgebra (q : ℚ))] + (Q : RationalFilteredNilmanifold + ((M.filtration.ordinary.dilationPairSubalgebra (q : ℚ)) ⧸ E.filtration.layerIdeal (s + 1)) s n) + (hQF : Q.filtration = E.filtration.quotientTop) + (hQL : Q.lattice = E.lattice.map + (E.filtration.quotientStepHom (E.filtration.layerIdeal (s + 1)) (t := s) le_rfl)) + [TopologicalSpace (ℝ ⊗[ℚ] + ((M.filtration.ordinary.dilationPairSubalgebra (q : ℚ)) ⧸ E.filtration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] + ((M.filtration.ordinary.dilationPairSubalgebra (q : ℚ)) ⧸ E.filtration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] + ((M.filtration.ordinary.dilationPairSubalgebra (q : ℚ)) ⧸ E.filtration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] + ((M.filtration.ordinary.dilationPairSubalgebra (q : ℚ)) ⧸ E.filtration.layerIdeal (s + 1)))] + +include hs hEF hEL hQF hQL + +theorem exists_prepared_dilation_niltest {p : ℝ} (hp : 0 ≤ p) + (hD : D.GeometryComplexityLE p) (hE : E.GeometryComplexityLE p) + (hheight : ∀ j a k, rationalLogHeight + (D.basis.repr (M.filtration.ordinary.dilationPairProjection (q : ℚ) j (E.basis a)) k) ≤ p) + (hQ : Q.GeometryComplexityLE p) + (hq : ∀ j k, rationalLogHeight + (Q.basis.repr (lieQuotientMap (E.filtration.layerIdeal (s + 1)) (E.basis k)) j) ≤ p) + (V : D.UnitVerticalObservable (M.realSubgroup bound) I p) + (g : M.filtration.realification.PolynomialOrbit) (ε γ : D.RealGroup) + (hγ : γ ∈ D.realLattice) (hfactor : M.filtration.realification.polynomialOrbitEval 0 g = ε * γ) + (A : ℝ≥0) (hA : (A : ℝ) ≤ Real.exp p) + (hε : letI := D.metricSpace; LipschitzWith A (fun x : D.Space => ε • x)) + (a₀ : I) (a : Fin (q ^ (s + 1)).natAbs → I) : + ∃ T : Q.Niltest (fun _ : σ => 1), T.normBound = 1 ∧ + T.ComplexityLE (DilationBudget.total (s + 1) q (MultilinearityBudget.reconstructionExponent s) p) ∧ + Q.filtration.realification.polynomialOrbitEval _ 0 T.orbit = 1 ∧ + ∀ x, T.eval x = + V.observable a₀ (QuotientGroup.mk (M.filtration.realification.polynomialOrbitEval + (fun i => q * x i) g)) * + star (signedTensorProduct (q ^ (s + 1)) (fun j => V.observable (a j) + (QuotientGroup.mk (M.filtration.realification.polynomialOrbitEval x g)))) := by + let H := ⌈Real.exp p⌉₊ + let B : ℝ≥0 := ((q ^ (s + 1)).natAbs + 1 : ℝ≥0) * + (V.lipBound * (A * ⟨Real.exp ((p + 3) ^ 2), (Real.exp_pos _).le⟩)) + have hLip : letI := E.metricSpace + LipschitzWith B (M.dilationObservable (q : ℚ) E hEL (q ^ (s + 1)) ε + (V.observable a₀) (fun j => V.observable (a j))) := + M.dilationObservable_lipschitz (q : ℚ) E hEL hp hD hE hheight + (q ^ (s + 1)) ε (V.observable a₀) (fun j => V.observable (a j)) V.lipBound A + (V.norm a₀) (fun j => V.norm (a j)) (V.lipschitz a₀) (fun j => V.lipschitz (a j)) hε + obtain ⟨T, hTn, hTl, hTzero, hTe⟩ := M.exists_dilation_niltest_of_data q hs E hEF hEL Q hQF hQL + (one_le_ceil_exp p) (fun j k => rationalHeightLE_ceil_exp (hq j k)) + (fun j k l => rationalHeightLE_ceil_exp (hQ.2.2.1 j k l)) V g ε γ hγ hfactor a₀ a B hLip + have hB : (B : ℝ) ≤ Real.exp (DilationBudget.reconstruction (s + 1) q p) := by + change (((q ^ (s + 1)).natAbs : ℝ) + 1) * + (V.lipBound * (A * Real.exp ((p + 3) ^ 2))) ≤ _ + exact DilationBudget.observable_bound (s + 1) q hp V.lipBound A V.lip_bound hA + exact ⟨T, hTn, DilationBudget.niltest_complexity Q T (s + 1) q r H B hp hQ hE.1 + (ceil_exp_le_exp_add_one hp) hB hTn hTl, hTzero, hTe⟩ + +end Erdos3.RationalFilteredNilmanifold.MultidegreeStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedFiniteScheduleAllNilmanifoldMaskProductiveGood.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedFiniteScheduleAllNilmanifoldMaskProductiveGood.lean new file mode 100644 index 0000000000000000000000000000000000000000..755030191075914a30b75f864f9e981a3fdb4cb8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedFiniteScheduleAllNilmanifoldMaskProductiveGood.lean @@ -0,0 +1,199 @@ +import OAI.Combinatorics.Progressions.Estimates.PreparedFiniteScheduleUniversalMaskProductiveGood + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped Classical BigOperators NNReal TensorProduct + +noncomputable section + +attribute [local irreducible] preparedSamplerTransverse preparedCommonBlockCount RankPreparationLayer.rank +attribute [local irreducible] PreparedFiniteScheduleDegreeModelsAtLaw integerBox allocatedPrincipalSides +attribute [local instance] NativeSampleModel.lie NativeSampleModel.algebra + NativeSampleModel.topology NativeSampleModel.topologicalAdd + NativeSampleModel.continuousSMul NativeSampleModel.hausdorff + +variable + {m nX M : ℕ} {X₀ J₀ : Type} + (prep : RankPreparationFamily X₀ J₀ m) + (U : ∀ j : Fin m, Submodule ℝ (RankPreparationLayer.Coord (prep j) → ℝ)) + (b : ∀ j, Basis (Fin (preparedSamplerTransverse prep j)) ℝ (euclideanSubspace (U j))ᗮ) + {R σ : Fin m → ℝ} + (S : LayerSamplerScale (G := EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) (I := PreparedSamplerContinuous prep) (n := preparedSamplerTransverse prep) + (J := fun j : Fin m => RankPreparationLayer.Coord (prep j)) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M))) U b R σ) + {Eout : Fin m → Type} [∀ j, Fintype (Eout j)] + (bW : ∀ j, Basis (Eout j) ℤ + (latticeSection (standardEuclideanLattice (RankPreparationLayer.Coord (prep j))) (euclideanSubspace (U j)))) + (hb : ∀ j, span ℤ (Set.range (b j)) = projectedIntegerLattice (euclideanSubspace (U j))) + (o : ∀ j, OrthonormalBasis (PreparedSamplerContinuous prep j) ℝ (euclideanSubspace (U j))) + (hR : ∀ j, 0 < R j) (hσ : ∀ j, 0 < σ j) + [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)))) U)] + (μ : Measure (CoefficientTorus (K := LayerSamplerVariables (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)))) U)) + (poly : ∀ j, VectorPolynomial (Fin nX) ℝ (RankPreparationLayer.Coord (prep j) → ℝ)) + (hm : ∀ j ex, coefficients (poly j) ex ∈ U j) + (stride : Fin nX → ℕ) + (width : Option (LayerSamplerVariables (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)))) × Fin nX → ℝ) + (bases : Finset (Fin nX → ℤ)) + (gainLog gain : ℝ) (Q : ℕ) + (e : Fin 2 × Fin nX ↪ EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) + (law : (CoefficientTorus (K := LayerSamplerVariables (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)))) U) → FiniteProbabilityWeights (bases × rectangularWeightIndices 0 width 1)) + (N : Fin nX → ℕ) (test : (Fin nX → ℝ) → ℝ) + [IsProbabilityMeasure μ] + (hweight : ∀ z, Measurable (fun center => (law center).weight z)) + (hgood : PreparedCenteredShortForecastGoodConclusion (m := m) (nX := nX) (M := M) + prep U b S bW hb o hR hσ μ poly hm stride width bases gainLog gain Q e law) + (hproductive : PreparedCenteredForecastProductiveConclusion (nX := nX) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M))) U b S + hb o hR hσ μ poly hm N width bases gainLog law) + (htest : ∀ x, |test x| ≤ 1) (hgain : Real.exp (-gainLog) ≤ gain) + (hmean : gain ≤ 𝔼 x ∈ integerBox N, test (fun i => (x i : ℝ))) + +local instance allNilmanifoldContinuousDecidableEq (j : Fin m) : DecidableEq (PreparedSamplerContinuous prep j) := Classical.decEq _ +local instance allNilmanifoldBlockDecidableEq (a : LayerSamplerAxis (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep)) : + DecidableEq (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)) a) := + Classical.decEq _ + +variable + (Pdetect : Polynomial ℕ) (hbox : (integerBox N).Nonempty) + (physical : (bases × rectangularWeightIndices 0 width 1) → integerBox (Sum.elim (fun _ : (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) => S.value) + (allocatedPrincipalSides (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M))) U b S)) → integerBox N) +variable + {Stage : Type} [Fintype Stage] + (degree : Stage → ℕ) (u p cap sliceLog testLog budget E : Stage → ℝ) +variable + (hModel : ∀ k : Stage, PreparedFiniteScheduleDegreeModelsAtLaw + (m := m) (nX := nX) (R := R) (σ := σ) + (Path := bases × rectangularWeightIndices 0 width 1) (G := EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) + (I := PreparedSamplerContinuous prep) (n := preparedSamplerTransverse prep) + (J := fun j : Fin m => RankPreparationLayer.Coord (prep j)) + (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M))) U b S N Pdetect μ poly hbox law hweight + physical (degree k) (u k) (p k) (cap k) (sliceLog k) (testLog k) (budget k) (E k)) +variable + (hSliceLog : ∀ k, 0 ≤ sliceLog k) + (hDetectorBudget : ∀ k, 2 ≤ Pdetect.eval₂ (Nat.castRingHom ℝ) (testLog k)) + (hnum : ∀ k, (Fintype.card (LayerSamplerVariables (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)))) : ℝ) ≤ + Pdetect.eval₂ (Nat.castRingHom ℝ) (testLog k)) +variable + {Forecast : Stage → Type} [∀ k, Nonempty (Forecast k)] + (Pnative massLog capLog Edata : Stage → ℝ) + (data : ∀ k, Forecast k → ActualForecastData N poly (Pnative k) (massLog k) (capLog k) (Edata k)) +variable + (hNative : ∀ k, 0 ≤ Pnative k) + (hAccuracy : ∀ k, 2 * u k + 4 * p k + 12 ≤ Edata k) + (hCap : ∀ k, Real.exp (capLog k) ≤ cap k) + (hPrecision : ∀ k, actualForecastDataModelRequired (budget k) (Pnative k) (massLog k) + (u k) (p k) ≤ E k) +variable + {History : Stage → Type} [∀ k, Fintype (History k)] + {Freq Bin Y : ∀ k, History k → Type} + [∀ k h, Fintype (Freq k h)] [∀ k h, Fintype (Bin k h)] + (F : ∀ k h, Freq k h → integerBox N → Y k h → ℂ) + (netCenters : ∀ k h, Freq k h → Bin k h → Y k h → ℂ) + {ε : ∀ k, History k → ℝ} + (hnet : ∀ k h f x, ∃ i, ∀ y, ‖F k h f x y - netCenters k h f i y‖ ≤ ε k h) +variable + (a : integerBox N → ℝ) (inputCap : ℝ) + (ha : ∀ x, |a x| ≤ Real.exp inputCap) + (hInputCap : ∀ k, inputCap ≤ p k) +variable + (historyLog frequencyLog binLog Eres : Stage → ℝ) (stageLog : ℝ) + (hHistory : ∀ k, (Fintype.card (History k) : ℝ) ≤ Real.exp (historyLog k)) + (hFrequency : ∀ k h, (Fintype.card (Freq k h) : ℝ) ≤ Real.exp (frequencyLog k)) + (hBin : ∀ k h, (Fintype.card (Bin k h) : ℝ) ≤ Real.exp (binLog k)) + (hStageCount : (Fintype.card Stage : ℝ) + 1 ≤ Real.exp stageLog) + (hErrorBudget : ∀ k, historyLog k + frequencyLog k + binLog k + gainLog + + Eres k + stageLog + 6 ≤ u k) + +include hgood hproductive htest hgain hmean hModel hSliceLog hDetectorBudget hnum + hNative hAccuracy hCap hPrecision ha hInputCap hHistory hFrequency hBin + hStageCount hErrorBudget in + +theorem exists_preparedFiniteScheduleAllNilmanifoldMaskProductiveGood : + let input : ∀ k, ExternalHistoryMaskIndex (Freq k) (Bin k) → integerBox N → ℂ := + fun k => externalHistoryMaskFamily (F k) (netCenters k) (hnet k) + (fun x => (a x : ℂ)) + let Packet := fun k => UniversalLocalMajorSliceTest + (Sum.elim (fun _ : EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M)) => S.value) + (allocatedPrincipalSides (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M))) U b S)) + (degree k) (sliceLog k) (Pdetect.eval₂ (Nat.castRingHom ℝ) (testLog k)) + let commonBudget := fun k => max (budget k) (3 * Pnative k + 3) + let Qmodel := fun k => max (commonBudget k) (2 * u k + 4 * p k + max 0 (massLog k) + 20) + let native := fun k => twistedNativeSampleFunctions (1 : Fin nX → ℕ) (degree k) (commonBudget k) + (fun v : integerBox N => v.val) + (fun (W : NormalizedPolynomialTwist (Fin nX) (Σ j, (fun j : Fin m => RankPreparationLayer.Coord (prep j)) j) + (Real.exp (commonBudget k)) (Real.exp (commonBudget k)) + ⟨Real.exp (commonBudget k), Real.exp_nonneg _⟩) + (v : integerBox N) => W.eval N poly v.val) + let localSeminorm : Stage → (integerBox N → ℂ) → ℝ := fun k => + sampledSliceSeminorm (centeredFiniteMarginal μ law hweight) physical + (fun _ (j : Packet k) => j.slice.subtypeSites) + (fun _ (j : Packet k) t => j.weight t.val) + let selectedLocal : Stage → (integerBox N → ℂ) → + (CoefficientTorus (K := LayerSamplerVariables (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)))) U × (bases × rectangularWeightIndices 0 width 1) → ℂ) → Prop := + fun k err errLocal => ∀ center z, ∃ j : Packet k, errLocal (center, z) = + 𝔼 t ∈ j.slice.subtypeSites, err (physical z t) * j.weight t.val + ∃ models : ∀ k, ExternalHistoryMaskIndex (Freq k) (Bin k) → CenteredForecastModel (integerBox N), + (∀ k branch, CenteredForecastModelBounds (centeredFiniteProbabilityMeasure μ law) + (native k) (FiniteProbabilityWeights.uniformFinset (integerBox N) hbox) + (fun f => (data k f).target) (localSeminorm k) (selectedLocal k) (input k branch) + (Real.exp (Qmodel k + 2)) (Real.exp (-u k)) + (Real.exp (2 * Qmodel k + 2 * u k + 4 * p k + 34)) (models k branch)) ∧ + PreparedCenteredStagedModelProductiveGoodConclusion (m := m) (nX := nX) (M := M) + prep U b S bW hb o hR hσ μ poly hm stride width bases gainLog gain Q e law N test + physical (fun k _ (j : Packet k) => j.slice.subtypeSites) + (fun k _ (j : Packet k) t => j.weight t.val) models Eres := by + intro input Packet commonBudget Qmodel native localSeminorm selectedLocal + let sides := Sum.elim + (fun _ : EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M)) => S.value) + (allocatedPrincipalSides (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M))) U b S) + have hSides (i : LayerSamplerVariables + (EnlargedPreparedCommonKernel m (modularInitialBlockCount m (nX + m * M))) + (PreparedSamplerContinuous prep) (preparedSamplerTransverse prep) + (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M)))) : + 0 < sides i := by + cases i with + | inl g => exact S.positive + | inr j => + exact allocatedPrincipalSides_pos + (EnlargedPreparedCommonSamplerBlock prep (modularInitialBlockCount m (nX + m * M))) U b S j + let : ∀ k, Nonempty (Packet k) := fun k => UniversalLocalMajorSliceTest.nonempty sides hSides + (degree k) (sliceLog k) (Pdetect.eval₂ (Nat.castRingHom ℝ) (testLog k)) + (hSliceLog k) (hDetectorBudget k) + have hmodels := exists_preparedFiniteScheduleExternalMaskProductiveGood + (prep := prep) (U := U) (b := b) (S := S) (bW := bW) (hb := hb) (o := o) + (hR := hR) (hσ := hσ) (μ := μ) (poly := poly) (hm := hm) (stride := stride) + (width := width) (bases := bases) (gainLog := gainLog) (gain := gain) (Q := Q) + (e := e) (law := law) (N := N) (test := test) (hweight := hweight) + (hgood := hgood) (hproductive := hproductive) (htest := htest) (hgain := hgain) (hmean := hmean) + (Pdetect := Pdetect) (hbox := hbox) (physical := physical) + (degree := degree) (u := u) (p := p) (cap := cap) (sliceLog := sliceLog) + (testLog := testLog) (budget := budget) (E := E) (hModel := hModel) + (Tests := fun k _ => Packet k) + (Ldetect := fun k _ j => j.nativeModel.L) (dims := fun k _ j => j.nativeModel.dim) + (Ddetect := fun k _ j => j.nativeModel.model) (Vdetect := fun k _ j => j.nativeModel.test) + (slices := fun k _ j => j.slice.subtypeSites) + (cdetect := fun k _ j i => (j.slice.start i : ℤ)) + (stepdetect := fun k _ j => j.stride) (Hdetect := fun k _ j => j.slice.length) + (hstep := fun k _ j => j.stride_pos) + (hSlices := fun k _ j => j.slice.subtypeSites_image_val.trans j.slice.integerPoints_eq_commonStrideBox) + (hDense := fun k _ j => j.slice.subtypeSites_dense j.dense) (hnum := hnum) + (hcomplex := fun k _ j => j.nativeModel.complexity) + (hcap := fun k _ j => by exact_mod_cast j.nativeModel.norm) + (Pnative := Pnative) (massLog := massLog) (capLog := capLog) (Edata := Edata) + (data := data) (hNative := hNative) (hAccuracy := hAccuracy) (hCap := hCap) + (hPrecision := hPrecision) (F := F) (netCenters := netCenters) (hnet := hnet) + (a := a) (inputCap := inputCap) (ha := ha) (hInputCap := hInputCap) + (historyLog := historyLog) (frequencyLog := frequencyLog) (binLog := binLog) + (hHistory := hHistory) (hFrequency := hFrequency) (hBin := hBin) (Eres := Eres) + (stageLog := stageLog) (hStageCount := hStageCount) (hErrorBudget := hErrorBudget) + simpa only [localSeminorm, selectedLocal, UniversalLocalMajorSliceTest.weight_eq_native_eval] using hmodels + +end + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedFiniteScheduleAllNilmanifoldModel.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedFiniteScheduleAllNilmanifoldModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ef72e02241685e9cf613c051bc7e11e647b66c8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/PreparedFiniteScheduleAllNilmanifoldModel.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Progressions.Polynomial.PreparedFiniteScheduleUniversalDegreeModel + +namespace OAI + +section + +namespace Erdos3.VectorPolynomial + +open MeasureTheory Module Submodule BooleanCubeKernel +open scoped Classical BigOperators NNReal TensorProduct + +attribute [local instance] NativeSampleModel.lie NativeSampleModel.algebra + NativeSampleModel.topology NativeSampleModel.topologicalAdd + NativeSampleModel.continuousSMul NativeSampleModel.hausdorff + +variable {m nX : ℕ} {G : Type} [Fintype G] [DecidableEq G] +variable {I : Fin m → Type} [∀ j, Fintype (I j)] {n : Fin m → ℕ} +variable {B : LayerSamplerAxis I n → Type} [∀ a, Fintype (B a)] +variable {J : Fin m → Type} [∀ j, Fintype (J j)] +variable {U : ∀ j, Submodule ℝ (J j → ℝ)} +variable {b : ∀ j, Basis (Fin (n j)) ℝ (euclideanSubspace (U j))ᗮ} +variable {R σ : Fin m → ℝ} {S : LayerSamplerScale (G := G) B U b R σ} +variable (N : Fin nX → ℕ) (Pdetect : Polynomial ℕ) +variable [MeasurableSpace (CoefficientTorus (K := LayerSamplerVariables G I n B) U)] +variable (μ : Measure (CoefficientTorus (K := LayerSamplerVariables G I n B) U)) +variable [IsProbabilityMeasure μ] +variable {Path : Type} [Fintype Path] [MeasurableSpace Path] [MeasurableSingletonClass Path] +variable (poly : ∀ j, VectorPolynomial (Fin nX) ℝ (J j → ℝ)) +variable (hbox : (integerBox N).Nonempty) +variable (law : CoefficientTorus (K := LayerSamplerVariables G I n B) U → FiniteProbabilityWeights Path) +variable (hweight : ∀ z, Measurable (fun center => (law center).weight z)) + +local notation "sides" => Sum.elim (fun _ : G => S.value) (allocatedPrincipalSides B U b S) +local notation "Sites" => integerBox sides + +theorem preparedFiniteScheduleDegreeModelsAtLaw_allNilmanifold_actualData + (physical : Path → integerBox (Sum.elim (fun _ : G => S.value) + (allocatedPrincipalSides B U b S)) → integerBox N) + (degree : ℕ) (u p cap sliceLog testLog budget E : ℝ) + (hModel : PreparedFiniteScheduleDegreeModelsAtLaw B U b S N Pdetect μ poly hbox law hweight + physical degree u p cap sliceLog testLog budget E) + (hSliceLog : 0 ≤ sliceLog) + (hDetectorBudget : 2 ≤ Pdetect.eval₂ (Nat.castRingHom ℝ) testLog) + (hnum : (Fintype.card (LayerSamplerVariables G I n B) : ℝ) ≤ + Pdetect.eval₂ (Nat.castRingHom ℝ) testLog) + {Forecast : Type} [Nonempty Forecast] {Pnative massLog capLog Edata : ℝ} + (data : Forecast → ActualForecastData N poly Pnative massLog capLog Edata) + (hNative : 0 ≤ Pnative) + (hAccuracy : 2 * u + 4 * p + 12 ≤ Edata) + (hCap : Real.exp capLog ≤ cap) + (hPrecision : actualForecastDataModelRequired budget Pnative massLog u p ≤ E) + {Branch : Type} [Fintype Branch] + (input : Branch → integerBox N → ℂ) + (hinput : ∀ branch v, ‖input branch v‖ ≤ Real.exp p) : + let Packet := UniversalLocalMajorSliceTest sides degree sliceLog (Pdetect.eval₂ (Nat.castRingHom ℝ) testLog) + let commonBudget := max budget (3 * Pnative + 3) + let Qmodel := max commonBudget (2 * u + 4 * p + max 0 massLog + 20) + let native := twistedNativeSampleFunctions (1 : Fin nX → ℕ) degree commonBudget + (fun v : integerBox N => v.val) + (fun (W : NormalizedPolynomialTwist (Fin nX) (Σ j, J j) + (Real.exp commonBudget) (Real.exp commonBudget) + ⟨Real.exp commonBudget, Real.exp_nonneg _⟩) + (v : integerBox N) => W.eval N poly v.val) + let localSeminorm : (integerBox N → ℂ) → ℝ := + sampledSliceSeminorm (centeredFiniteMarginal μ law hweight) physical + (fun _ (j : Packet) => j.slice.subtypeSites) + (fun _ (j : Packet) t => j.weight t.val) + let selectedLocal : (integerBox N → ℂ) → + (CoefficientTorus (K := LayerSamplerVariables G I n B) U × Path → ℂ) → Prop := + fun err errLocal => ∀ center z, ∃ j : Packet, errLocal (center, z) = + 𝔼 t ∈ j.slice.subtypeSites, err (physical z t) * j.weight t.val + ∃ models : Branch → CenteredForecastModel (integerBox N), + ∀ branch, CenteredForecastModelBounds (centeredFiniteProbabilityMeasure μ law) + native (FiniteProbabilityWeights.uniformFinset (integerBox N) hbox) (fun f => (data f).target) + localSeminorm selectedLocal (input branch) (Real.exp (Qmodel + 2)) + (Real.exp (-u)) (Real.exp (2 * Qmodel + 2 * u + 4 * p + 34)) (models branch) := by + classical + intro Packet commonBudget Qmodel native localSeminorm selectedLocal + have hSides (i : LayerSamplerVariables G I n B) : 0 < sides i := by + cases i with + | inl g => exact S.positive + | inr j => exact allocatedPrincipalSides_pos B U b S j + let : Nonempty Packet := UniversalLocalMajorSliceTest.nonempty sides hSides degree sliceLog + (Pdetect.eval₂ (Nat.castRingHom ℝ) testLog) hSliceLog hDetectorBudget + have hmodels := preparedFiniteScheduleDegreeModelsAtLaw_actualData + (B := B) (U := U) (b := b) (S := S) + N Pdetect μ poly hbox law hweight physical degree u p cap sliceLog testLog budget E hModel + (Tests := fun _ => Packet) (Ldetect := fun _ j => j.nativeModel.L) + (dims := fun _ j => j.nativeModel.dim) + (fun _ j => j.nativeModel.model) (fun _ j => j.nativeModel.test) (fun _ j => j.slice.subtypeSites) + (fun _ j i => (j.slice.start i : ℤ)) (fun _ j => j.stride) (fun _ j => j.slice.length) + (fun _ j => j.stride_pos) + (fun _ j => j.slice.subtypeSites_image_val.trans j.slice.integerPoints_eq_commonStrideBox) + (fun _ j => j.slice.subtypeSites_dense j.dense) hnum + (fun _ j => j.nativeModel.complexity) (fun _ j => by exact_mod_cast j.nativeModel.norm) + data hNative hAccuracy hCap hPrecision input hinput + simpa only [localSeminorm, selectedLocal, UniversalLocalMajorSliceTest.weight_eq_native_eval] using hmodels + +end Erdos3.VectorPolynomial + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/QuadraticPrimitiveNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuadraticPrimitiveNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2f3e7dd6161b43c27a6fa7222b17a7a9e78e471 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuadraticPrimitiveNiltest.lean @@ -0,0 +1,90 @@ +import OAI.Combinatorics.Progressions.Estimates.QuadraticCyclicIntegration + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + +theorem exists_quadratic_primitive_niltest_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + ∀ W : NativeMultidegreeNilcharacter (mixedCorrelationDegree 1) p, + ∀ i : Fin W.outputDim, ∀ χ : AddChar (ZMod N) ℂ, + (fun n : ZMod N => star (W.eval i (fun _ => (n.val : ℤ))) * χ n) ∈ + nativeCyclicFunctions 2 N ((p + C) ^ C) := by + obtain ⟨A, _, hproduct⟩ := exists_productNiltestBudget_bound + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget + ((Polynomial.X + 216 + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro N _ p hp W i χ + obtain ⟨T, hTnorm, hT, hTeval⟩ := W.exists_quadratic_diagonal_niltest i + obtain ⟨U, hUnorm, hU, hUeval⟩ := exists_cyclic_character_niltest χ + let hdegree : 1 ≤ 2 := by omega + let r := p + 216 + have hr : 0 ≤ r := by dsimp [r]; linarith + let K : Bool → Type := BoolLieFamily W.L (RationalTorus.Algebra 1) + let dims : Bool → ℕ := fun b => Bool.rec 1 W.dim b + let models : ∀ b, RationalFilteredNilmanifold (K b) 2 (dims b) := fun b => by + cases b + · exact (RationalTorus.nilmanifold 1).raiseStep hdegree + · exact W.model + let tests : ∀ b, (models b).Niltest (fun _ : Unit => 1) := fun b => by + cases b + · exact U.raiseStep hdegree + · exact T.conjugate + have htests : ∀ b, (tests b).ComplexityLE r := by + intro b + cases b + · apply (U.raiseStep_complexity hdegree (by norm_num) hU).mono + dsimp [raisedNiltestBudget, r] + linarith + · exact hT.mono (by dsimp [r]; linarith) + have hcap : ∀ b, (tests b).normBound ≤ 1 := by + intro b + cases b + · exact hUnorm + · exact hTnorm.le + have hcard : (Fintype.card Bool : ℝ) ≤ r := by + simp only [Fintype.card_bool, Nat.cast_ofNat] + dsimp [r] + linarith + let : FiniteDimensional ℚ (∀ b, K b) := + (RationalFilteredNilmanifold.productFinBasis models).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ b, K b)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ b, K b)) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (∀ b, K b)) := + realification_moduleTopology_t2 (RationalFilteredNilmanifold.productFinBasis models) + let S := RationalFilteredNilmanifold.unitBoundedPiNiltest models tests hr hcard htests hcap + have hcost : productNiltestBudget r ≤ (p + C) ^ C := by + apply (hproduct r hr).trans + simpa [r, Polynomial.eval₂_pow] using hbudget p hp + refine ⟨{ + L := ∀ b, K b + dim := _ + model := RationalFilteredNilmanifold.pi models + test := S + norm := le_rfl + complexity := (RationalFilteredNilmanifold.unitBoundedPiNiltest_complexity + models tests hr hcard htests hcap).mono hcost + eval := ?_ }⟩ + intro n + change _ = S.eval (fun _ => (n.val : ℤ)) + rw [RationalFilteredNilmanifold.unitBoundedPiNiltest_eval, Fintype.prod_bool] + change _ = star (T.eval (fun _ => (n.val : ℤ))) * + (U.raiseStep hdegree).eval (fun _ => (n.val : ℤ)) + rw [hTeval, RationalFilteredNilmanifold.Niltest.raiseStep_eval] + change _ = star (W.eval i (fun _ => (n.val : ℤ))) * U.evalCyclic N (fun _ => n) + rw [hUeval] + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/QuarticPairNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuarticPairNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..39812bc0c5d977cb4d48036485496858fad7eed0 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuarticPairNiltest.lean @@ -0,0 +1,67 @@ +import OAI.Combinatorics.Progressions.Estimates.QuarticPairFactors + +namespace OAI + +section + +namespace Erdos3.NativeSampleCorrelation + +open RationalFilteredNilmanifold +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeSampleCorrelation.lie NativeSampleCorrelation.algebra + NativeSampleCorrelation.topology NativeSampleCorrelation.topologicalAdd + NativeSampleCorrelation.continuousSMul NativeSampleCorrelation.hausdorff + +variable {p q : ℝ} {N : ℕ} [NeZero N] + {W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) p} + {i j : Fin W.outputDim} + (V : NativeSampleCorrelation (fun _ : Fin 4 => 1) 3 q + Finset.univ (fun z : Fin 4 → ZMod N => fun k => ((z k).val : ℤ)) + (fun z => W.quarticAntisymmetric i j (fun k => ((z k).val : ℤ)))) + [TopologicalSpace (ℝ ⊗[ℚ] V.QuarticPairAlgebra)] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] V.QuarticPairAlgebra)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] V.QuarticPairAlgebra)] + [T2Space (ℝ ⊗[ℚ] V.QuarticPairAlgebra)] + +noncomputable def quarticPairNiltest : (pi V.quarticPairModels).Niltest (fun _ : Fin 4 => 1) := + piNiltest V.quarticPairModels V.quarticPairTests + ((by norm_num : (0 : ℝ) ≤ 6).trans V.quarticPairBudget_six_le) + (by simpa using (show (3 : ℝ) ≤ quarticPairBudget p q from + (by norm_num : (3 : ℝ) ≤ 6).trans V.quarticPairBudget_six_le)) + V.quarticPairTests_complexity + +theorem quarticPairNiltest_complexity : + V.quarticPairNiltest.ComplexityLE (productNiltestBudget (quarticPairBudget p q)) := + piNiltest_complexity V.quarticPairModels V.quarticPairTests _ _ _ + +theorem quarticPairNiltest_eval (n : Fin 4 → ℤ) : + V.quarticPairNiltest.eval n = + W.quarticAntisymmetric i j n * star (V.test.eval n) := by + rw [quarticPairNiltest, piNiltest_eval] + exact V.quarticPairTests_eval n + +theorem quarticPairNiltest_vertical (z : (pi V.quarticPairModels).RealGroup) + (hz : z ∈ (pi V.quarticPairModels).filtration.realification.subgroup (∑ _ : QuarticReplicatedIndex, 1)) + (x : (pi V.quarticPairModels).Space) : + V.quarticPairNiltest.observable (z • x) = + CircleFourier.character + ((realifyFunctional (piFrequency V.quarticPairFrequencies) z.coord : ℝ) : CircleFourier.Circle) * + V.quarticPairNiltest.observable x := + piNiltest_vertical V.quarticPairModels V.quarticPairTests V.quarticPairFrequencies _ _ _ + V.quarticPairTests_vertical z hz x + +theorem quarticPairNiltest_bias : + Real.exp (-q) ≤ ‖𝔼 n ∈ integerBox (fun _ : Fin 4 => N), V.quarticPairNiltest.eval n‖ := by + rw [integerBox_expect_eq_zmod] + simp_rw [V.quarticPairNiltest_eval] + exact V.correlation + +end Erdos3.NativeSampleCorrelation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/QuarticPrimitiveNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuarticPrimitiveNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..01b8eb6ae3e4e7cb4d40564acbdc31e65a60c3c8 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuarticPrimitiveNiltest.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Progressions.Estimates.QuarticPrimitiveGowers + +namespace OAI + +section + +namespace Erdos3.NativeMultidegreeNilcharacter + +open scoped TensorProduct BigOperators + +attribute [local instance] NativeMultidegreeNilcharacter.lie NativeMultidegreeNilcharacter.algebra + NativeMultidegreeNilcharacter.topology NativeMultidegreeNilcharacter.topologicalAdd + NativeMultidegreeNilcharacter.continuousSMul NativeMultidegreeNilcharacter.hausdorff + NativeCyclicModel.lie NativeCyclicModel.algebra NativeCyclicModel.topology + NativeCyclicModel.topologicalAdd NativeCyclicModel.continuousSMul NativeCyclicModel.hausdorff + +theorem exists_quartic_diagonal_niltest {p : ℝ} + (W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) p) (i : Fin W.outputDim) : + ∃ T : W.model.Niltest (fun _ : Unit => 1), T.normBound = 1 ∧ T.ComplexityLE (p + 4) ∧ + ∀ n : ℤ, T.eval (fun _ => n) = W.eval i (fun _ => n) := by + obtain ⟨T, hT, hcomplexity, heval⟩ := W.exists_linear_niltest i + (fun _ => { toFun := fun x : Unit → ℤ => x (), map_zero' := rfl, map_add' := fun _ _ => rfl }) + exact ⟨T, hT, hcomplexity, fun n => heval (fun _ => n)⟩ + +theorem exists_quartic_primitive_niltest_budget : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {N : ℕ} [NeZero N] {p : ℝ}, 0 ≤ p → + ∀ W : NativeMultidegreeNilcharacter (fun _ : QuarticReplicatedIndex => 1) p, + ∀ i : Fin W.outputDim, ∀ g ∈ nativeCyclicFunctions 3 N p, + (fun n : ZMod N => star (W.eval i (fun _ => (n.val : ℤ))) * g n) ∈ + nativeCyclicFunctions 4 N ((p + C) ^ C) := by + obtain ⟨A, _, hproduct⟩ := exists_productNiltestBudget_bound + let X : Polynomial ℕ := Polynomial.X + let R := 2 * X + (X + 2) ^ 2 + 7 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget ((R + Polynomial.C A) ^ A) + refine ⟨C, hC, ?_⟩ + intro N _ p hp W i g ⟨G⟩ + have hdegree : (∑ _ : QuarticReplicatedIndex, (1 : ℕ)) = 4 := by decide + have hraise : 3 ≤ ∑ _ : QuarticReplicatedIndex, (1 : ℕ) := by omega + obtain ⟨T, hTnorm, hT, hTeval⟩ := W.exists_quartic_diagonal_niltest i + let r := 2 * p + (p + 2) ^ 2 + 7 + have hr : 0 ≤ r := by dsimp [r]; positivity + have hpr : p + 4 ≤ r := by dsimp [r]; nlinarith [sq_nonneg (p + 2)] + have hGr : raisedNiltestBudget p ≤ r := by dsimp [raisedNiltestBudget, r]; linarith + let K : Bool → Type := BoolLieFamily W.L G.L + let dims : Bool → ℕ := fun b => Bool.rec G.dim W.dim b + let models : ∀ b, RationalFilteredNilmanifold (K b) (∑ _ : QuarticReplicatedIndex, 1) (dims b) := fun b => by + cases b + · exact G.model.raiseStep hraise + · exact W.model + let tests : ∀ b, (models b).Niltest (fun _ : Unit => 1) := fun b => by + cases b + · exact G.test.raiseStep hraise + · exact T.conjugate + have htests : ∀ b, (tests b).ComplexityLE r := by + intro b + cases b + · exact (G.test.raiseStep_complexity hraise hp G.complexity).mono hGr + · exact hT.mono hpr + have hcap : ∀ b, (tests b).normBound ≤ 1 := by + intro b + cases b + · exact G.norm + · exact hTnorm.le + have hcard : (Fintype.card Bool : ℝ) ≤ r := by + simp only [Fintype.card_bool, Nat.cast_ofNat] + linarith + let : FiniteDimensional ℚ (∀ b, K b) := + (RationalFilteredNilmanifold.productFinBasis models).finiteDimensional_of_finite + let := moduleTopology ℝ (ℝ ⊗[ℚ] (∀ b, K b)) + let : IsTopologicalAddGroup (ℝ ⊗[ℚ] (∀ b, K b)) := + IsModuleTopology.isTopologicalAddGroup ℝ _ + let : T2Space (ℝ ⊗[ℚ] (∀ b, K b)) := + realification_moduleTopology_t2 (RationalFilteredNilmanifold.productFinBasis models) + let S := RationalFilteredNilmanifold.unitBoundedPiNiltest models tests hr hcard htests hcap + have hcost : productNiltestBudget r ≤ (p + C) ^ C := by + apply (hproduct r hr).trans + simpa [X, R, r, Polynomial.eval₂_pow] using hbudget p hp + have H : Nonempty (NativeCyclicModel (∑ _ : QuarticReplicatedIndex, 1) N ((p + C) ^ C) + (fun n : ZMod N => star (W.eval i (fun _ => (n.val : ℤ))) * g n)) := by + refine ⟨{ + L := ∀ b, K b + dim := _ + model := RationalFilteredNilmanifold.pi models + test := S + norm := le_rfl + complexity := (RationalFilteredNilmanifold.unitBoundedPiNiltest_complexity + models tests hr hcard htests hcap).mono hcost + eval := ?_ }⟩ + intro n + change _ = S.eval (fun _ => (n.val : ℤ)) + rw [RationalFilteredNilmanifold.unitBoundedPiNiltest_eval, Fintype.prod_bool] + change _ = star (T.eval (fun _ => (n.val : ℤ))) * + (G.test.raiseStep hraise).eval (fun _ => (n.val : ℤ)) + rw [hTeval, RationalFilteredNilmanifold.Niltest.raiseStep_eval, G.eval n] + rfl + change Nonempty (NativeCyclicModel 4 N ((p + C) ^ C) _) + simpa only [hdegree] using H + +end Erdos3.NativeMultidegreeNilcharacter + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/QuotientSectionNiltests.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuotientSectionNiltests.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f24e04c750ff7361334a9aa3e1c0416d9495f6f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/QuotientSectionNiltests.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.Progressions.Estimates.PositiveReconstruction +import OAI.Combinatorics.Progressions.Nilpotent.IdealInvariantNiltestBudget + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +theorem exists_quotient_section_niltests {L Z σ : Type*} [LieRing L] [LieAlgebra ℚ L] + {s d n : ℕ} (D : RationalFilteredNilmanifold L (s + 1) d) + (Q : RationalFilteredNilmanifold (L ⧸ D.filtration.layerIdeal (s + 1)) s n) + [TopologicalSpace (ℝ ⊗[ℚ] (L ⧸ D.filtration.layerIdeal (s + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ D.filtration.layerIdeal (s + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (L ⧸ D.filtration.layerIdeal (s + 1)))] + [T2Space (ℝ ⊗[ℚ] (L ⧸ D.filtration.layerIdeal (s + 1)))] [PseudoMetricSpace Z] + (hQ : Q.filtration = D.filtration.quotientTop) {w : σ → ℕ} + (g : D.filtration.realification.PolynomialOrbit w) (v : Q.Space × Z → ℂ) {K : ℝ≥0} + (hv : letI := Q.metricSpace; LipschitzWith K v) + (hpositive : ∀ y, (v y).im = 0 ∧ 0 ≤ (v y).re ∧ (v y).re ≤ 1) + {b : ℝ} (hb : 0 ≤ b) (hgeom : Q.GeometryComplexityLE b) (hK : (K : ℝ) ≤ Real.exp b) : + ∃ tests : Z → Q.Niltest w, + (∀ z, (tests z).UnitIntervalValued) ∧ + (∀ z, (tests z).ComplexityLE (b + 2)) ∧ + ∀ z x, (tests z).eval x = + v (QuotientGroup.mk (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) + (lieQuotientMap (D.filtration.layerIdeal (s + 1))) + (D.filtration.realification.polynomialOrbitEval w x g)), z) := by + let q₀ := D.filtration.realQuotientPolynomialOrbit (D.filtration.layerIdeal (s + 1)) + (t := s) le_rfl g + have hadapted : Q.filtration.realification.Adapted w q₀.log := by + rw [hQ] + exact q₀.adapted + let q : Q.filtration.realification.PolynomialOrbit w := + NilpotentLieFiltration.polynomialOrbitOfLog q₀.log hadapted + let := Q.metricSpace + let tests : Z → Q.Niltest w := fun z => { + orbit := q + observable := fun y => v (y, z) + normBound := 1 + lipBound := K + norm_le := fun y => by + simpa only [positiveClip_eq_self _ (hpositive (y, z)), NNReal.coe_one] using + norm_positiveClip_le_one (v (y, z)) + lipschitz := by + simpa only [mul_one, Function.comp_def] using hv.comp (LipschitzWith.prodMk_right z) } + have hlog : Real.log (3 + (K : ℝ)) ≤ b + 2 := by + apply (Real.log_le_iff_le_exp (by positivity)).mpr + have h1 : 1 ≤ Real.exp b := Real.one_le_exp hb + have h2 : (4 : ℝ) ≤ Real.exp 2 := by + rw [show (2 : ℝ) = 1 + 1 by norm_num, Real.exp_add] + nlinarith [Real.add_one_le_exp (1 : ℝ)] + rw [Real.exp_add] + nlinarith [mul_le_mul_of_nonneg_left h2 (Real.exp_nonneg b)] + refine ⟨tests, fun z y => hpositive (y, z), ?_, ?_⟩ + · intro z + refine ⟨hgeom.mono Q (by linarith), ?_⟩ + change Real.log (2 + 1 + (K : ℝ)) ≤ b + 2 + norm_num only [show (2 : ℝ) + 1 = 3 by norm_num] + exact hlog + · intro z x + have heval := D.filtration.realQuotientPolynomialOrbit_eval + (D.filtration.layerIdeal (s + 1)) (t := s) le_rfl g x + exact congrArg (fun y : Q.RealGroup => v (QuotientGroup.mk y, z)) heval + +end Erdos3.RationalFilteredNilmanifold + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/RankAdaptedNiltest.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/RankAdaptedNiltest.lean new file mode 100644 index 0000000000000000000000000000000000000000..219ac9d20bfd89a66b12d55a678f81ef28c55a1b --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/RankAdaptedNiltest.lean @@ -0,0 +1,151 @@ +import OAI.Combinatorics.Progressions.Linear.NativeRankQuotientOrbit + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.AdaptedModelData + +open Module CircleFourier +open scoped TensorProduct NNReal + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} (F : D.AdaptedModelData) (H : ℕ) + (hH : ∀ i j, RationalHeightLE (D.basis.repr (F.basis i) j) H) {w : σ → ℕ} + +noncomputable def rebaseNiltest (T : D.Niltest w) : F.model.Niltest w where + orbit := T.orbit + observable := T.observable + normBound := T.normBound + lipBound := T.lipBound * coordinateLipschitzBound d (finrank ℚ L) H + norm_le := T.norm_le + lipschitz := by + let := F.model.metricSpace + apply LipschitzWith.of_dist_le_mul + intro x y + have hT : dist (T.observable x) (T.observable y) ≤ + (T.lipBound : ℝ) * @dist D.Space D.metricSpace.toDist x y := by + let := D.metricSpace + exact T.lipschitz.dist_le_mul x y + calc + dist (T.observable x) (T.observable y) ≤ + (T.lipBound : ℝ) * @dist D.Space D.metricSpace.toDist x y := hT + _ ≤ (T.lipBound : ℝ) * + (coordinateLipschitzBound d (finrank ℚ L) H * dist x y) := + mul_le_mul_of_nonneg_left (F.original_dist_le H hH x y) T.lipBound.coe_nonneg + _ = ↑(T.lipBound * coordinateLipschitzBound d (finrank ℚ L) H) * dist x y := by + rw [NNReal.coe_mul] + ring + +theorem rebaseNiltest_orbit (T : D.Niltest w) : (F.rebaseNiltest H hH T).orbit = T.orbit := rfl + +theorem rebaseNiltest_normBound (T : D.Niltest w) : (F.rebaseNiltest H hH T).normBound = T.normBound := rfl + +theorem rebaseNiltest_eval (T : D.Niltest w) (x : σ → ℤ) : (F.rebaseNiltest H hH T).eval x = T.eval x := rfl + +theorem rebaseNiltest_evalCyclic (T : D.Niltest w) (N : ℕ) [NeZero N] (x : σ → ZMod N) : + (F.rebaseNiltest H hH T).evalCyclic N x = T.evalCyclic N x := rfl + +theorem rebaseNiltest_unit_interval (T : D.Niltest w) (hT : T.UnitIntervalValued) : + (F.rebaseNiltest H hH T).UnitIntervalValued := hT + +theorem rebaseNiltest_vertical (T : D.Niltest w) (eta : L →ₗ[ℚ] ℚ) + (hT : ∀ z, z ∈ D.filtration.realification.subgroup s → ∀ x, + T.observable (z • x) = character ((realifyFunctional eta z.coord : ℝ) : CircleFourier.Circle) * T.observable x) : + ∀ z, z ∈ F.model.filtration.realification.subgroup s → ∀ x, + (F.rebaseNiltest H hH T).observable (z • x) = + character ((realifyFunctional eta z.coord : ℝ) : CircleFourier.Circle) * + (F.rebaseNiltest H hH T).observable x := hT + +theorem rebaseNiltest_kernel_invariant (T : D.Niltest w) {J : Type*} (eta : J → L →ₗ[ℚ] ℚ) + (hT : ∀ z, z ∈ D.filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j) z.coord = 0) → ∀ x, T.observable (z • x) = T.observable x) : + ∀ z, z ∈ F.model.filtration.realification.subgroup s → + (∀ j, realifyFunctional (eta j) z.coord = 0) → ∀ x, + (F.rebaseNiltest H hH T).observable (z • x) = (F.rebaseNiltest H hH T).observable x := hT + +theorem rebaseNiltest_complexity (T : D.Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hT : T.ComplexityLE p) (hF : F.model.GeometryComplexityLE p) (hHp : (H : ℝ) ≤ Real.exp p) : + (F.rebaseNiltest H hH T).ComplexityLE (p + (p + 2) ^ 2) := by + have hK : (coordinateLipschitzBound d (finrank ℚ L) H : ℝ) ≤ Real.exp ((p + 2) ^ 2) := + coordinateLipschitzBound_le_exp d (finrank ℚ L) H hp hT.1.1 hF.1 hHp + have h1 : 1 ≤ Real.exp ((p + 2) ^ 2) := Real.one_le_exp_iff.mpr (sq_nonneg _) + refine ⟨hF.mono F.model (le_add_of_nonneg_right (sq_nonneg _)), ?_⟩ + change Real.log (2 + (T.normBound : ℝ) + + (T.lipBound : ℝ) * coordinateLipschitzBound d (finrank ℚ L) H) ≤ p + (p + 2) ^ 2 + apply (Real.log_le_iff_le_exp (by positivity)).mpr + calc + 2 + (T.normBound : ℝ) + (T.lipBound : ℝ) * coordinateLipschitzBound d (finrank ℚ L) H ≤ + (2 + (T.normBound : ℝ)) * Real.exp ((p + 2) ^ 2) + + (T.lipBound : ℝ) * Real.exp ((p + 2) ^ 2) := + add_le_add (le_mul_of_one_le_right (by positivity) h1) + (mul_le_mul_of_nonneg_left hK T.lipBound.coe_nonneg) + _ = (2 + (T.normBound : ℝ) + (T.lipBound : ℝ)) * Real.exp ((p + 2) ^ 2) := by ring + _ ≤ Real.exp p * Real.exp ((p + 2) ^ 2) := + mul_le_mul_of_nonneg_right (Niltest.observable_budget hT) (Real.exp_pos _).le + _ = Real.exp (p + (p + 2) ^ 2) := (Real.exp_add _ _).symm + +end Erdos3.RationalFilteredNilmanifold.AdaptedModelData + +end + +section + +namespace Erdos3 + +def rankAdaptedNiltestBase (p : ℝ) : ℝ := (p + 3) ^ 11 + p + 2 + +def rankAdaptedNiltestBudget (p : ℝ) : ℝ := + rankAdaptedNiltestBase p + (rankAdaptedNiltestBase p + 2) ^ 2 + +theorem le_rankAdaptedNiltestBudget {p : ℝ} (hp : 0 ≤ p) : + p ≤ rankAdaptedNiltestBudget p := by + have hpow : 0 ≤ (p + 3) ^ 11 := by positivity + unfold rankAdaptedNiltestBudget rankAdaptedNiltestBase + nlinarith [sq_nonneg ((p + 3) ^ 11 + p + 2 + 2)] + +namespace RationalFilteredNilmanifold.DegreeRankStructure + +open Module +open scoped TensorProduct + +theorem exists_adapted_niltest {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s d r : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure r) + {w : σ → ℕ} (T : D.Niltest w) {p : ℝ} (hp : 0 ≤ p) + (hR : R.ComplexityLE p) (hT : T.ComplexityLE p) : + ∃ F : R.AdaptedData, + F.rank.ComplexityLE (rankAdaptedNiltestBudget p) ∧ + (∀ i j, rationalLogHeight (D.basis.repr (F.basis i) j) ≤ p + 1) ∧ + (∀ j i, rationalLogHeight (F.basis.repr (D.basis j) i) ≤ (p + 3) ^ 5) ∧ + ∃ S : F.model.Niltest w, S.orbit = T.orbit ∧ S.observable = T.observable ∧ + S.ComplexityLE (rankAdaptedNiltestBudget p) := by + obtain ⟨F, hF, hb, hinv⟩ := R.exists_rank_adapted_data hp hR + let H := ⌈Real.exp (p + 1)⌉₊ + have hH (i j) : RationalHeightLE (D.basis.repr (F.basis i) j) H := + rationalHeightLE_ceil_exp (hb i j) + let q := rankAdaptedNiltestBase p + have hpow : 0 ≤ (p + 3) ^ 11 := by positivity + have hpq : p ≤ q := by dsimp [q, rankAdaptedNiltestBase]; linarith + have hfq : (p + 3) ^ 11 ≤ q := by dsimp [q, rankAdaptedNiltestBase]; linarith + have hq : 0 ≤ q := hp.trans hpq + have hHq : (H : ℝ) ≤ Real.exp q := + (ceil_exp_le_exp_add_one (by linarith : 0 ≤ p + 1)).trans + (Real.exp_le_exp.mpr (by dsimp [q, rankAdaptedNiltestBase]; linarith)) + have hqb : q ≤ rankAdaptedNiltestBudget p := by + exact le_add_of_nonneg_right (sq_nonneg _) + refine ⟨F, hF.mono F.rank (hfq.trans hqb), hb, hinv, + F.toAdaptedModelData.rebaseNiltest H hH T, rfl, rfl, ?_⟩ + exact F.toAdaptedModelData.rebaseNiltest_complexity H hH T hq + (hT.mono hpq) (hF.1.mono F.model hfq) hHq + +end RationalFilteredNilmanifold.DegreeRankStructure + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/RankBracketFactorizationMonotone.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/RankBracketFactorizationMonotone.lean new file mode 100644 index 0000000000000000000000000000000000000000..56fd5a4feb9f3322b2ce8febda9ccc9077d8ca87 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/RankBracketFactorizationMonotone.lean @@ -0,0 +1,238 @@ +import OAI.Combinatorics.Progressions.Fourier.JoinedFrequencyQuotientInjectivity +import OAI.Combinatorics.Progressions.Polynomial.RaisedDegreeRank + +namespace OAI + +section + +namespace Erdos3 + +namespace NilpotentLieFiltration + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem refiltered_lieTreeEval_mem (U : LieSubalgebra ℚ F.AssociatedGraded) + (d : I → ℕ) (v : I → L) (hv : ∀ i, v i ∈ F.gradedRefiltrationLayer U (d i)) + (a : FreeMagma I) : lieTreeEval v a ∈ F.gradedRefiltrationLayer U (lieTreeWeight d a) := by + induction a using FreeMagma.rec with + | of i => exact hv i + | mul a b ha hb => exact F.gradedRefiltrationLayer_lie_mem U ha hb + +end NilpotentLieFiltration + +namespace RationalFilteredNilmanifold.DegreeRankStructure + +open Module + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n : ℕ} + {D : RationalFilteredNilmanifold L s n} (R : D.DegreeRankStructure r) + +theorem refiltered_rank_bracket_frequency (b : Basis (Fin n) ℚ L) (ω : Fin n → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) (ξ η : L →ₗ[ℚ] ℚ) + (hξ : ∀ x ∈ U, + basisGradeProjection (D.filtration.associatedGradedBasis b ω hF) ω s x = x → + D.filtration.gradedFrequency b ω hF ξ x = 0) + (hrestrict : ∀ x ∈ R.filtration.layer s r, ξ x = η x) + (d : I → ℕ) (a : FreeMagma I) (hd : lieTreeWeight d a = s) (hr : a.length = r) + (v : I → L) (hv : ∀ i, v i ∈ D.filtration.gradedRefiltrationLayer U (d i)) : + η (lieTreeEval v a) = 0 := by + have htop : lieTreeEval v a ∈ D.filtration.gradedRefiltrationLayer U s := by + simpa only [hd] using D.filtration.refiltered_lieTreeEval_mem U d v hv a + have hleaves (i : I) : v i ∈ R.filtration.layer (d i) 1 := by + have h := D.filtration.gradedRefiltrationLayer_le U (d i) (hv i) + rw [← R.associated] at h + change v i ∈ R.filtration.layer (d i) 0 at h + rwa [R.filtration.rank_zero_eq_one] at h + have hrank : lieTreeEval v a ∈ R.filtration.layer s r := by + simpa only [hd, hr] using R.filtration.lieTreeEval_mem_length v d hleaves a + rw [← hrestrict _ hrank] + exact D.filtration.frequency_zero_on_refiltered_top b ω hF U ξ hξ _ htop + +end RationalFilteredNilmanifold.DegreeRankStructure + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped TensorProduct + +theorem realifyFunctional_sub_apply {V : Type*} [AddCommGroup V] [Module ℚ V] + (ξ η : V →ₗ[ℚ] ℚ) (x : ℝ ⊗[ℚ] V) : + realifyFunctional (ξ - η) x = realifyFunctional ξ x - realifyFunctional η x := by + induction x using TensorProduct.inductionOn with + | tmul t v => simp only [realifyFunctional_tmul, LinearMap.sub_apply, Rat.cast_sub, mul_sub] + | add x y hx hy => + simp only [map_add, hx, hy] + ring + +theorem realifyFunctional_eq_on_submodule {V : Type*} [AddCommGroup V] [Module ℚ V] + (P : Submodule ℚ V) (ξ η : V →ₗ[ℚ] ℚ) (h : ∀ x ∈ P, ξ x = η x) + (x : ℝ ⊗[ℚ] V) (hx : x ∈ P.baseChange ℝ) : + realifyFunctional ξ x = realifyFunctional η x := by + have hker : P ≤ LinearMap.ker (ξ - η) := by + intro y hy + change ξ y - η y = 0 + exact sub_eq_zero.mpr (h y hy) + have hz := (mem_realified_frequency_kernel_iff (ξ - η) x).mp (Submodule.baseChange_mono ℝ hker hx) + rw [realifyFunctional_sub_apply] at hz + exact sub_eq_zero.mp hz + +namespace NilpotentLieFiltration + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s : ℕ} + (F : NilpotentLieFiltration L s) + +theorem real_refiltered_lieTreeEval_mem (U : LieSubalgebra ℚ F.AssociatedGraded) + (d : I → ℕ) (v : I → ℝ ⊗[ℚ] L) (hv : ∀ i, v i ∈ F.realGradedRefiltrationLayer U (d i)) + (a : FreeMagma I) : lieTreeEval v a ∈ F.realGradedRefiltrationLayer U (lieTreeWeight d a) := by + induction a using FreeMagma.rec with + | of i => exact hv i + | mul a b ha hb => exact F.realGradedRefiltrationLayer_lie_mem U ha hb + +end NilpotentLieFiltration + +namespace RationalFilteredNilmanifold.DegreeRankStructure + +open Module + +variable {I L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n : ℕ} + {D : RationalFilteredNilmanifold L s n} (R : D.DegreeRankStructure r) + +theorem real_refiltered_rank_bracket_frequency (b : Basis (Fin n) ℚ L) (ω : Fin n → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (b '' {i | j ≤ ω i})) + (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) (ξ η : L →ₗ[ℚ] ℚ) + (hξ : ∀ x ∈ U, + basisGradeProjection (D.filtration.associatedGradedBasis b ω hF) ω s x = x → + D.filtration.gradedFrequency b ω hF ξ x = 0) + (hrestrict : ∀ x ∈ R.filtration.layer s r, ξ x = η x) + (d : I → ℕ) (a : FreeMagma I) (hd : lieTreeWeight d a = s) (hr : a.length = r) + (v : I → ℝ ⊗[ℚ] L) (hv : ∀ i, v i ∈ D.filtration.realGradedRefiltrationLayer U (d i)) : + realifyFunctional η (lieTreeEval v a) = 0 := by + have htop : lieTreeEval v a ∈ D.filtration.realGradedRefiltrationLayer U s := by + simpa only [hd] using D.filtration.real_refiltered_lieTreeEval_mem U d v hv a + have hleaves (i : I) : v i ∈ R.filtration.realification.layer (d i) 1 := by + have h : v i ∈ D.filtration.realification.layer (d i) := + D.filtration.realGradedRefiltrationLayer_le U (d i) (hv i) + rw [← R.real_associated] at h + change v i ∈ R.filtration.realification.layer (d i) 0 at h + rwa [R.filtration.realification.rank_zero_eq_one] at h + have hrank : lieTreeEval v a ∈ (R.filtration.layer s r).baseChange ℝ := by + have h : lieTreeEval v a ∈ R.filtration.realification.layer s r := by + simpa only [hd, hr] using R.filtration.realification.lieTreeEval_mem_length v d hleaves a + exact h + rw [← realifyFunctional_eq_on_submodule (R.filtration.layer s r) ξ η hrestrict _ hrank] + exact D.filtration.real_frequency_zero_on_refiltered_top b ω hF U ξ hξ _ htop + +end RationalFilteredNilmanifold.DegreeRankStructure + +end Erdos3 + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n : ℕ} + {D : RationalFilteredNilmanifold L s n} (R : D.DegreeRankStructure r) + +def ControlledRankBracketFactorization (_R : D.DegreeRankStructure r) (ω : Fin n → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (η : L →ₗ[ℚ] ℚ) (T : σ → ℝ) + (X : D.filtration.RealPolynomialSymbolGroup (fun _ : σ => 1)) (p : ℝ) : Prop := + ∃ (m : ℕ) (A P B : D.filtration.RealPolynomialSymbolGroup (fun _ : σ => 1)) + (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) (v : Fin n → D.filtration.AssociatedGraded), + 0 < m ∧ (m : ℝ) ≤ Real.exp p ∧ A * P * B = X ∧ + D.filtration.SymbolSlowBound D.basis ω hF (fun _ => 1) T (Real.exp p) A ∧ + D.filtration.SymbolRationalGrid D.basis ω hF (fun _ => 1) m B ∧ + Submodule.span ℚ (Set.range v) = U.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω U.toSubmodule ∧ + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (v i) j) ≤ p) ∧ + (∀ (k : ℕ) (d : Fin k → ℕ) (a : FreeMagma (Fin k)), + lieTreeWeight d a = s → a.length = r → + ∀ u : Fin k → ℝ ⊗[ℚ] L, + (∀ i, u i ∈ D.filtration.realGradedRefiltrationLayer U (d i)) → + realifyFunctional η (lieTreeEval u a) = 0) ∧ + P.coord ∈ realificationLieSubalgebra (D.filtration.symbolPointwiseSubalgebra D.basis ω hF (fun _ => 1) U) + +theorem controlledRankBracketFactorization_of_frequency_restriction (ω : Fin n → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + (ξ η : L →ₗ[ℚ] ℚ) (T : σ → ℝ) + (X : D.filtration.RealPolynomialSymbolGroup (fun _ : σ => 1)) (p : ℝ) + (h : D.filtration.ControlledSymbolFactorization D.basis ω hF ξ T X p) + (hrestrict : ∀ x ∈ R.filtration.layer s r, ξ x = η x) : + R.ControlledRankBracketFactorization ω hF η T X p := by + obtain ⟨m, A, P, B, U, v, hm, hmp, hprod, hA, hB, hv, hU, hheight, hξ, hP⟩ := h + refine ⟨m, A, P, B, U, v, hm, hmp, hprod, hA, hB, hv, hU, hheight, ?_, hP⟩ + intro k d a hd hr u hu + exact R.real_refiltered_rank_bracket_frequency D.basis ω hF U ξ η hξ hrestrict d a hd hr u hu + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open Module +open scoped TensorProduct + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n : ℕ} + {D : RationalFilteredNilmanifold L s n} (R : D.DegreeRankStructure r) + (ω : Fin n → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + +theorem ControlledRankBracketFactorization.exists_in {η : L →ₗ[ℚ] ℚ} {T : σ → ℝ} + {X : D.filtration.RealPolynomialSymbolGroup (fun _ : σ => 1)} {p : ℝ} + (h : R.ControlledRankBracketFactorization ω hF η T X p) : + ∃ (l : ℕ) (U : LieSubalgebra ℚ D.filtration.AssociatedGraded) + (v : Fin n → D.filtration.AssociatedGraded), + 0 < l ∧ (l : ℝ) ≤ Real.exp p ∧ Submodule.span ℚ (Set.range v) = U.toSubmodule ∧ + BasisGradedSubmodule (D.filtration.associatedGradedBasis D.basis ω hF) ω U.toSubmodule ∧ + (∀ i j, rationalLogHeight ((D.filtration.associatedGradedBasis D.basis ω hF).repr (v i) j) ≤ p) ∧ + (∀ (k : ℕ) (d : Fin k → ℕ) (a : FreeMagma (Fin k)), + lieTreeWeight d a = s → a.length = r → ∀ u : Fin k → ℝ ⊗[ℚ] L, + (∀ i, u i ∈ D.filtration.realGradedRefiltrationLayer U (d i)) → + realifyFunctional η (lieTreeEval u a) = 0) ∧ + D.filtration.SymbolFactorizationIn D.basis ω hF T X p l U := by + obtain ⟨l, A, P, B, U, v, hl, hlp, hprod, hA, hB, hv, hU, hh, hker, hP⟩ := h + exact ⟨l, U, v, hl, hlp, hv, hU, hh, hker, A, P, B, hprod, hA, hB, hP⟩ + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +variable {σ L : Type*} [LieRing L] [LieAlgebra ℚ L] {s r n : ℕ} + {D : RationalFilteredNilmanifold L s n} (R : D.DegreeRankStructure r) + (ω : Fin n → ℕ) + (hF : ∀ j, D.filtration.layer j = Submodule.span ℚ (D.basis '' {i | j ≤ ω i})) + +theorem ControlledRankBracketFactorization.mono {η : L →ₗ[ℚ] ℚ} {T : σ → ℝ} + {X : D.filtration.RealPolynomialSymbolGroup (fun _ : σ => 1)} {p q : ℝ} + (h : R.ControlledRankBracketFactorization ω hF η T X p) (hpq : p ≤ q) + (hT : ∀ i, 0 < T i) : R.ControlledRankBracketFactorization ω hF η T X q := by + obtain ⟨m, A, P, B, U, v, hm, hmp, hprod, hA, hB, hv, hU, hh, hη, hP⟩ := h + exact ⟨m, A, P, B, U, v, hm, hmp.trans (Real.exp_le_exp.mpr hpq), hprod, + D.filtration.symbolSlowBound_mono D.basis ω hF (fun _ => 1) T hT + (Real.exp_le_exp.mpr hpq) A hA, + hB, hv, hU, (fun i j => (hh i j).trans hpq), hη, hP⟩ + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/RankInvariantNiltestBudget.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/RankInvariantNiltestBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..24d4c3c6d900c1a8971dc7d7cc9c33810e2e8c34 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/RankInvariantNiltestBudget.lean @@ -0,0 +1,152 @@ +import OAI.Combinatorics.Progressions.Linear.NativeRankQuotientOrbit + +namespace OAI + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open NilpotentLieBCHGroup +open scoped TensorProduct NNReal + +variable {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] {s r d n : ℕ} + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure (r + 1)) + [TopologicalSpace (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + [T2Space (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + +theorem exists_rankInvariant_niltest + (Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n) + (hQF : Q.filtration = D.filtration.quotientLie + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal) + (hQL : Q.lattice = D.lattice.map (D.filtration.quotientStepHom + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal)) + {w : σ → ℕ} (T : D.Niltest w) + (hinv : ∀ z ∈ R.realSubgroup s (r + 1), ∀ x, T.observable (z • x) = T.observable x) + (H : ℕ) (hH : 1 ≤ H) + (he : ∀ i j, RationalHeightLE (Q.basis.repr + (lieQuotientMap (R.filtration.layerIdeal s (r + 1)) (D.basis j)) i) H) + (hc : ∀ i j k, RationalHeightLE (lieStructureConstants Q.basis i j k) H) : + ∃ S : Q.Niltest w, + S.orbit = R.rankQuotientOrbit Q hQF T.orbit ∧ + S.normBound = T.normBound ∧ + S.lipBound = rationalReconstructionLipschitzBound s d n H T.lipBound T.normBound ∧ + (∀ x : D.RealGroup, S.observable (QuotientGroup.mk + (realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) + (lieQuotientMap (R.filtration.layerIdeal s (r + 1))) x)) = + T.observable (QuotientGroup.mk x)) ∧ + ∀ x, S.eval x = T.eval x := by + have hcover : Q.lattice ≤ D.lattice.map + (mapOfSteps (lieQuotientMap (R.filtration.layerIdeal s (r + 1)))) := by + rw [hQL] + exact le_rfl + obtain ⟨f, hf, hfLip, hfBound⟩ := exists_lipschitz_realification_reconstruction + D.basis Q.basis (lieQuotientMap (R.filtration.layerIdeal s (r + 1))) + (lieQuotientMap_surjective _) D.lattice Q.lattice hcover + D.grid Q.grid H D.grid_pos Q.grid_pos hH D.outer_grid Q.outer_grid he hc + T.observable (fun k hk x => hinv k (by + apply (realification_mkQ_eq_zero_iff + (R.filtration.layerIdeal s (r + 1)).toSubmodule k.coord).mp + exact congrArg (fun z : Q.RealGroup => z.coord) (MonoidHom.mem_ker.mp hk)) + (QuotientGroup.mk x)) T.lipBound T.normBound T.lipschitz T.norm_le + let S : Q.Niltest w := { + orbit := R.rankQuotientOrbit Q hQF T.orbit + observable := f + normBound := T.normBound + lipBound := rationalReconstructionLipschitzBound s d n H T.lipBound T.normBound + norm_le := hfBound + lipschitz := by + let : MetricSpace (Q.RealGroup ⧸ Q.lattice.map realificationHom) := + realificationQuotientMetricSpace Q.basis Q.lattice Q.grid Q.grid_pos Q.outer_grid + exact hfLip.weaken (by simp only [Fintype.card_fin]; exact le_rfl) + } + refine ⟨S, rfl, rfl, rfl, hf, ?_⟩ + intro x + exact (congrArg (fun z : Q.RealGroup => f (QuotientGroup.mk z)) + (R.rankQuotientOrbit_eval Q hQF T.orbit x)).trans (hf _) + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +section + +namespace Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +open scoped TensorProduct NNReal + +theorem exists_rankInvariant_niltest_budget (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {L σ : Type*} [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + {r d n : ℕ} {D : RationalFilteredNilmanifold L s d} (R : D.DegreeRankStructure (r + 1)) + [TopologicalSpace (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + [IsTopologicalAddGroup (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + [T2Space (ℝ ⊗[ℚ] (L ⧸ R.filtration.layerIdeal s (r + 1)))] + (Q : RationalFilteredNilmanifold (L ⧸ R.filtration.layerIdeal s (r + 1)) s n) + (hQF : Q.filtration = D.filtration.quotientLie + (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal) + (_hQL : Q.lattice = D.lattice.map + (D.filtration.quotientStepHom (R.filtration.layerIdeal s (r + 1)) R.terminal_le_topRankIdeal)) + {w : σ → ℕ} (T : D.Niltest w) (p : ℝ), + 0 ≤ p → T.ComplexityLE p → Q.GeometryComplexityLE p → + (∀ i j, rationalLogHeight (Q.basis.repr + (lieQuotientMap (R.filtration.layerIdeal s (r + 1)) (D.basis j)) i) ≤ p) → + (∀ z ∈ R.realSubgroup s (r + 1), ∀ x, + T.observable (z • x) = T.observable x) → + ∃ S : Q.Niltest w, S.orbit = R.rankQuotientOrbit Q hQF T.orbit ∧ + S.normBound = T.normBound ∧ S.ComplexityLE ((p + C) ^ C) ∧ + (∀ x : D.RealGroup, S.observable (QuotientGroup.mk + (NilpotentLieBCHGroup.realificationMap (hnil := D.filtration.lowerCentralSeries_eq_bot) + (hM := Q.filtration.lowerCentralSeries_eq_bot) + (lieQuotientMap (R.filtration.layerIdeal s (r + 1))) x)) = + T.observable (QuotientGroup.mk x)) ∧ + ∀ x, S.eval x = T.eval x := by + obtain ⟨a, _, hcost⟩ := exists_rationalReconstructionLipschitzBound_exp s + let X : Polynomial ℕ := Polynomial.X + let P := (X + 1 + Polynomial.C a) ^ a + X + 4 + obtain ⟨C, hC, hbudget⟩ := exists_natPolynomial_eval_budget P + refine ⟨C, hC, ?_⟩ + intro L σ _ _ _ _ _ _ r d n D R _ _ _ _ Q hQF hQL w T p hp hT hQ he hinv + let H := ⌈Real.exp p⌉₊ + obtain ⟨S, hSo, hSn, hSl, hSp, hSe⟩ := R.exists_rankInvariant_niltest Q hQF hQL T hinv H + (one_le_ceil_exp p) (fun i j => rationalHeightLE_ceil_exp (he i j)) + (fun i j k => rationalHeightLE_ceil_exp (hQ.2.2.1 i j k)) + have hB : (T.normBound : ℝ) ≤ Real.exp p := by + linarith [T.observable_budget hT, T.lipBound.coe_nonneg] + have hL : (T.lipBound : ℝ) ≤ Real.exp p := by + linarith [T.observable_budget hT, T.normBound.coe_nonneg] + have hpp : Real.exp p ≤ Real.exp (p + 1) := Real.exp_le_exp.mpr (by linarith) + let r := (p + 1 + a) ^ a + have hr : 0 ≤ r := by dsimp [r]; positivity + have hK : (S.lipBound : ℝ) ≤ Real.exp r := by + rw [hSl] + exact hcost d n H T.lipBound T.normBound (p + 1) (by linarith) + (hT.1.1.trans (by linarith)) (hQ.1.trans (by linarith)) + (ceil_exp_le_exp_add_one hp) (hL.trans hpp) (hB.trans hpp) + have hnum : 2 + (S.normBound : ℝ) + (S.lipBound : ℝ) ≤ Real.exp (r + p + 4) := by + have hSn' : (S.normBound : ℝ) ≤ Real.exp (r + p) := by + rw [hSn] + exact hB.trans (Real.exp_le_exp.mpr (by linarith)) + have hSl' : (S.lipBound : ℝ) ≤ Real.exp (r + p) := + hK.trans (Real.exp_le_exp.mpr (by linarith)) + calc + _ ≤ 4 * Real.exp (r + p) := by linarith [Real.one_le_exp (show 0 ≤ r + p by linarith)] + _ ≤ Real.exp 4 * Real.exp (r + p) := mul_le_mul_of_nonneg_right + (by linarith [Real.add_one_le_exp (4 : ℝ)]) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hbound : r + p + 4 ≤ (p + C) ^ C := by + simpa [r, P, X, Polynomial.eval₂_pow] using hbudget p hp + refine ⟨S, hSo, hSn, ⟨hQ.mono Q ((by linarith : p ≤ r + p + 4).trans hbound), ?_⟩, hSp, hSe⟩ + exact ((Real.log_le_iff_le_exp (by positivity)).mpr hnum).trans hbound + +end Erdos3.RationalFilteredNilmanifold.DegreeRankStructure + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/RationalBCHProducts.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/RationalBCHProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..64316871b9312d123e1b88e8527ac808143772b1 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/RationalBCHProducts.lean @@ -0,0 +1,193 @@ +import OAI.Combinatorics.Progressions.Lattices.ConjugatedLatticeGrids +import OAI.Combinatorics.Progressions.Sampling.RealGridRationalLift + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped TensorProduct + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem realification_grid_mul (e : Basis ι ℚ L) (l m : ℕ) (hl : 0 < l) + (hmul : ∀ a b : NilpotentLieBCHGroup L s hnil, + e.equivFun a.coord ∈ denominatorGrid l → e.equivFun b.coord ∈ denominatorGrid l → + e.equivFun (a * b).coord ∈ denominatorGrid m) + (a b : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) + (ha : (e.baseChange ℝ).equivFun a.coord ∈ realDenominatorGrid l) + (hb : (e.baseChange ℝ).equivFun b.coord ∈ realDenominatorGrid l) : + (e.baseChange ℝ).equivFun (a * b).coord ∈ realDenominatorGrid m := by + obtain ⟨aq, haq, heqa⟩ := (realification_grid_iff (hnil := hnil) e l hl a).mp ha + obtain ⟨bq, hbq, heqb⟩ := (realification_grid_iff (hnil := hnil) e l hl b).mp hb + rw [← heqa, ← heqb, ← map_mul, realificationHom_coordinates, real_cast_mem_denominatorGrid_iff] + exact hmul aq bq haq hbq + +theorem realification_grid_inv (e : Basis ι ℚ L) (l m : ℕ) (hl : 0 < l) + (hinv : ∀ a : NilpotentLieBCHGroup L s hnil, + e.equivFun a.coord ∈ denominatorGrid l → e.equivFun (a⁻¹).coord ∈ denominatorGrid m) + (a : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)) + (ha : (e.baseChange ℝ).equivFun a.coord ∈ realDenominatorGrid l) : + (e.baseChange ℝ).equivFun (a⁻¹).coord ∈ realDenominatorGrid m := by + obtain ⟨aq, haq, heqa⟩ := (realification_grid_iff (hnil := hnil) e l hl a).mp ha + rw [← heqa, ← map_inv, realificationHom_coordinates, real_cast_mem_denominatorGrid_iff] + exact hinv aq haq + +end Erdos3.NilpotentLieBCHGroup + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem exists_real_bch_rational_closure (s : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + (∀ a b : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil), + (e.baseChange ℝ).equivFun a.coord ∈ realDenominatorGrid l → + (e.baseChange ℝ).equivFun b.coord ∈ realDenominatorGrid l → + (e.baseChange ℝ).equivFun (a * b).coord ∈ realDenominatorGrid m) ∧ + (∀ a : NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil), + (e.baseChange ℝ).equivFun a.coord ∈ realDenominatorGrid l → + (e.baseChange ℝ).equivFun (a⁻¹).coord ∈ realDenominatorGrid m) := by + obtain ⟨C, hC, hbound⟩ := exists_bch_rational_closure s + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ e H p hnil hp hd hH hc l hl hlp + obtain ⟨m, hm, hmp, hlm, hmul⟩ := hbound e H p hp hd hH hc l hl hlp + refine ⟨m, hm, hmp, hlm, ?_, ?_⟩ + · exact NilpotentLieBCHGroup.realification_grid_mul (hnil := hnil) e l m hl + (fun a b ha hb => hmul a.coord b.coord ha hb) + · apply NilpotentLieBCHGroup.realification_grid_inv (hnil := hnil) e l m hl + intro a ha + change e.equivFun (-a.coord) ∈ denominatorGrid m + rw [map_neg] + exact denominatorGrid_subset_of_dvd hlm (denominatorGrid_neg l ha) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem realDenominatorGrid_zero {ι : Type*} (l : ℕ) : + (0 : ι → ℝ) ∈ realDenominatorGrid l := by + exact ⟨0, by ext i; simp⟩ + +theorem realDenominatorGrid_subset_of_dvd {ι : Type*} {l m : ℕ} (hl : 0 < l) (hlm : l ∣ m) : + (realDenominatorGrid l : Set (ι → ℝ)) ⊆ realDenominatorGrid m := by + intro x hx + obtain ⟨y, hy, rfl⟩ := realDenominatorGrid_exists_rational l hl x hx + exact (real_cast_mem_denominatorGrid_iff m y).mpr (denominatorGrid_subset_of_dvd hlm hy) + +theorem exists_real_bch_rational_product_bound (s k : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j z, RationalHeightLE (lieStructureConstants e i j z) H) → + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + ∀ rs : List (NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil)), + rs.length ≤ k → + (∀ r ∈ rs, (e.baseChange ℝ).equivFun r.coord ∈ realDenominatorGrid l) → + (e.baseChange ℝ).equivFun rs.prod.coord ∈ realDenominatorGrid m := by + induction k with + | zero => + refine ⟨2, by omega, ?_⟩ + intro ι L _ _ _ e H p hnil hp hd hH hc l hl hlp + refine ⟨l, hl, hlp.trans (Real.exp_le_exp.mpr (le_power_budget hp (by omega))), dvd_refl l, ?_⟩ + intro rs hlen hrs + have hrs0 : rs = [] := List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero hlen) + subst rs + simpa only [List.prod_nil, NilpotentLieBCHGroup.coord_one, map_zero] using + (realDenominatorGrid_zero (ι := ι) l) + | succ k ih => + obtain ⟨K, hK, hprod⟩ := ih + obtain ⟨J, _, hmul⟩ := exists_real_bch_rational_closure s + let R : Polynomial ℕ := ((Polynomial.X + Polynomial.C K) ^ K + Polynomial.C J) ^ J + obtain ⟨C, hC, hbound⟩ := exists_natPolynomial_eval_budget R + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ e H p hnil hp hd hH hc l hl hlp + obtain ⟨m₁, hm₁, hm₁p, hlm₁, hprod₁⟩ := hprod e H p hnil hp hd hH hc l hl hlp + let q : ℝ := (p + K) ^ K + have hq : 0 ≤ q := by dsimp [q]; positivity + have hpq : p ≤ q := by + apply (show p ≤ p + K from le_add_of_nonneg_right (Nat.cast_nonneg K)).trans + have hK' : (2 : ℝ) ≤ K := by exact_mod_cast hK + simpa only [pow_one] using pow_le_pow_right₀ + (show (1 : ℝ) ≤ p + K by linarith) (show 1 ≤ K by omega) + obtain ⟨m₂, hm₂, hm₂p, hm₁m₂, hmul₂, _⟩ := hmul e H q hnil hq (hd.trans hpq) + (hH.trans (Real.exp_le_exp.mpr hpq)) hc m₁ hm₁ hm₁p + have hpoly : (q + J) ^ J ≤ (p + C) ^ C := by + simpa [R, q, Polynomial.eval₂_pow] using hbound p hp + refine ⟨m₂, hm₂, hm₂p.trans (Real.exp_le_exp.mpr hpoly), hlm₁.trans hm₁m₂, ?_⟩ + intro rs hlen hrs + cases rs with + | nil => + simpa only [List.prod_nil, NilpotentLieBCHGroup.coord_one, map_zero] using + (realDenominatorGrid_zero (ι := ι) m₂) + | cons r rs => + rw [List.prod_cons] + apply hmul₂ + · exact realDenominatorGrid_subset_of_dvd hl hlm₁ (hrs r (List.mem_cons_self)) + · apply hprod₁ rs (Nat.le_of_succ_le_succ hlen) + exact fun x hx => hrs x (List.mem_cons_of_mem r hx) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module NilpotentLieBCHGroup + +theorem exists_bch_rational_product_bound (s k : ℕ) : + ∃ C : ℕ, 2 ≤ C ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + (e : Basis ι ℚ L) (H : ℕ) (p : ℝ) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥), + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + (∀ i j z, RationalHeightLE (lieStructureConstants e i j z) H) → + ∀ l : ℕ, 0 < l → (l : ℝ) ≤ Real.exp p → + ∃ m : ℕ, 0 < m ∧ (m : ℝ) ≤ Real.exp ((p + C) ^ C) ∧ l ∣ m ∧ + ∀ rs : List (NilpotentLieBCHGroup L s hnil), rs.length ≤ k → + (∀ r ∈ rs, e.equivFun r.coord ∈ denominatorGrid l) → + e.equivFun rs.prod.coord ∈ denominatorGrid m := by + have hrealExists := exists_real_bch_rational_product_bound s k + obtain ⟨C, hC, hreal⟩ := hrealExists + refine ⟨C, hC, ?_⟩ + intro ι L _ _ _ e H p hnil hp hd hH hc l hl hlp + have hproductsExists := hreal e H p hnil hp hd hH hc l hl hlp + obtain ⟨m, hm, hmp, hlm, hproducts⟩ := hproductsExists + refine ⟨m, hm, hmp, hlm, ?_⟩ + intro rs hlen hrs + have hinputs : ∀ r ∈ rs.map (realificationHom (hnil := hnil)), + (e.baseChange ℝ).equivFun r.coord ∈ realDenominatorGrid l := by + intro r hr + obtain ⟨q, hq, rfl⟩ := List.mem_map.mp hr + rw [realificationHom_coordinates, real_cast_mem_denominatorGrid_iff] + exact hrs q hq + have hout := hproducts (rs.map (realificationHom (hnil := hnil))) + (by simpa only [List.length_map] using hlen) hinputs + rw [← map_list_prod, realificationHom_coordinates, real_cast_mem_denominatorGrid_iff] at hout + exact hout + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/RealBCHOrderedReduction.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/RealBCHOrderedReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6a8d23944d24cc867db52d3be9b30ad1a6c516f --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/RealBCHOrderedReduction.lean @@ -0,0 +1,51 @@ +import OAI.Combinatorics.Progressions.Linear.BoundedAdaptedBasis + +namespace OAI + +section + +namespace Erdos3.IsRealCentralLieBasis + +open Module + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] [IsScalarTower ℚ ℝ L] {d s : ℕ} + {e : Basis (Fin d) ℝ L} (he : IsRealCentralLieBasis e) + (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + +include he hnil + +theorem bch_remainder_mem_tail (i : ℕ) (a : L) {b : L} (hb : b ∈ realBasisTail e i) : + lieBCH s a b - (a + b) ∈ realBasisTail e (i + 1) := + lieBCH_sub_add_mem hnil (he.tailIdeal (i + 1)) a b (he.lie_mem_tail_succ i a hb) + +theorem bch_low_coordinate (i : ℕ) (a : L) {b : L} (hb : b ∈ realBasisTail e i) + (k : Fin d) (hk : k.val ≤ i) : + e.repr (lieBCH s a b) k = e.repr a k + e.repr b k := by + have h := he.bch_remainder_mem_tail hnil i a hb k (Nat.lt_succ_of_le hk) + rw [map_sub, Finsupp.sub_apply, map_add, Finsupp.add_apply] at h + exact sub_eq_zero.mp h + +theorem peel_mem_tail (j : Fin d) (g : NilpotentLieBCHGroup L s hnil) + (hg : g.coord ∈ realBasisTail e j.val) : + (((⟨e.repr g.coord j • e j⟩ : NilpotentLieBCHGroup L s hnil)⁻¹ * g).coord) ∈ + realBasisTail e (j.val + 1) := by + change lieBCH s (-(e.repr g.coord j • e j)) g.coord ∈ _ + have herr := he.bch_remainder_mem_tail hnil j.val (-(e.repr g.coord j • e j)) hg + have hlin : -(e.repr g.coord j • e j) + g.coord ∈ realBasisTail e (j.val + 1) := by + simpa only [sub_eq_add_neg, add_comm] using real_sub_coordinate_mem_tail e j hg + simpa only [sub_add_cancel] using (realBasisTail e (j.val + 1)).add_mem herr hlin + +theorem leading_coordinate (j : Fin d) (t : ℝ) (r : NilpotentLieBCHGroup L s hnil) + (hr : r.coord ∈ realBasisTail e (j.val + 1)) : + e.repr (((⟨t • e j⟩ : NilpotentLieBCHGroup L s hnil) * r).coord) j = t := by + change e.repr (lieBCH s (t • e j) r.coord) j = t + rw [he.bch_low_coordinate hnil j.val (t • e j) + (realBasisTail_antitone e (Nat.le_succ j.val) hr) j le_rfl] + simp only [map_smul, Finsupp.smul_apply, Basis.repr_self, Finsupp.single_eq_same, + smul_eq_mul, mul_one, hr j (Nat.lt_succ_self j.val), add_zero] + +end Erdos3.IsRealCentralLieBasis + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/RealFunctionalBCH.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/RealFunctionalBCH.lean new file mode 100644 index 0000000000000000000000000000000000000000..d229d0d8356d2ea35d460f6461da3dd339c99db2 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/RealFunctionalBCH.lean @@ -0,0 +1,48 @@ +import OAI.Combinatorics.Progressions.Estimates.NativeCentralSeed + +namespace OAI + +section + +namespace Erdos3 + +open scoped TensorProduct + +variable {L : Type*} [LieRing L] [LieAlgebra ℚ L] + +theorem realifyFunctional_lie_eq_zero (η : L →ₗ[ℚ] ℚ) + (hη : ∀ x y : L, η ⁅x, y⁆ = 0) (x y : ℝ ⊗[ℚ] L) : + realifyFunctional η ⁅x, y⁆ = 0 := by + induction x using TensorProduct.inductionOn with + | tmul a x => + induction y using TensorProduct.inductionOn with + | tmul b y => + simp only [LieAlgebra.ExtendScalars.bracket_tmul, realifyFunctional_tmul, + hη, Rat.cast_zero, mul_zero] + | add y z hy hz => simp only [LieRing.lie_add, map_add, hy, hz, add_zero] + | add x z hx hz => simp only [LieRing.add_lie, map_add, hx, hz, add_zero] + +attribute [local instance] LieRing.ofAssociativeRing + +noncomputable def realifyFunctionalLie (η : L →ₗ[ℚ] ℚ) + (hη : ∀ x y : L, η ⁅x, y⁆ = 0) : (ℝ ⊗[ℚ] L) →ₗ⁅ℚ⁆ ℝ where + toLinearMap := (realifyFunctional η).restrictScalars ℚ + map_lie' {x y} := by + change realifyFunctional η ⁅x, y⁆ = ⁅realifyFunctional η x, realifyFunctional η y⁆ + rw [realifyFunctional_lie_eq_zero η hη] + simp only [Ring.lie_def, mul_comm, sub_self] + +theorem realifyFunctional_lieBCH (η : L →ₗ[ℚ] ℚ) + (hη : ∀ x y : L, η ⁅x, y⁆ = 0) {s : ℕ} (hs : 1 ≤ s) + (x y : ℝ ⊗[ℚ] L) : + realifyFunctional η (lieBCH s x y) = realifyFunctional η x + realifyFunctional η y := by + change realifyFunctionalLie η hη (lieBCH s x y) = _ + rw [map_lieBCH, lieBCH_eq_add_of_lie_eq_zero_pos hs + (by simp only [Ring.lie_def, mul_comm, sub_self])] + rfl + +end Erdos3 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Progressions/Nilpotent/RealifiedBCHFiniteAtlas.lean b/lean/OAI/Combinatorics/Progressions/Nilpotent/RealifiedBCHFiniteAtlas.lean new file mode 100644 index 0000000000000000000000000000000000000000..93e3fcc01103568d6dc76695d423d0a3e6032231 --- /dev/null +++ b/lean/OAI/Combinatorics/Progressions/Nilpotent/RealifiedBCHFiniteAtlas.lean @@ -0,0 +1,608 @@ +import Mathlib.Topology.Algebra.Group.Quotient +import Mathlib.Topology.OpenPartialHomeomorph.Basic +import OAI.Combinatorics.Progressions.Estimates.ImageRepresentatives + +namespace OAI + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + +noncomputable def quotientCoordinateChart (z : NilpotentLieBCHGroup L s hnil) : + OpenPartialHomeomorph (ι → ℝ) (NilpotentLieBCHGroup L s hnil ⧸ Γ) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let f := fun v : ι → ℝ => (QuotientGroup.mk (z * (basisHomeomorph e).symm v) : _ ⧸ Γ) + let U := {v : ι → ℝ | ∀ i, |v i| < bchInjectivityRadius s (Fintype.card ι) H l} + have hi : Set.InjOn f U := (quotient_coordinate_injOn e c hstructure hc Γ l hl hgrid z).mono + (fun _ hx i => (hx i).le) + have hf : Continuous f := QuotientGroup.continuous_mk.comp + (continuous_const.mul (basisHomeomorph e).symm.continuous) + have ho : IsOpenMap f := QuotientGroup.isOpenMap_coe.comp + ((Homeomorph.mulLeft z).isOpenMap.comp (basisHomeomorph e).symm.isOpenMap) + have hU : IsOpen U := by + simp only [U, Set.ofPred_forall] + exact isOpen_iInter_of_finite (fun i => isOpen_lt (continuous_apply i).abs continuous_const) + exact OpenPartialHomeomorph.ofContinuousOpen (hi.toPartialEquiv f U) hf.continuousOn ho hU + +theorem quotientCoordinateChart_apply (z : NilpotentLieBCHGroup L s hnil) (v : ι → ℝ) : + quotientCoordinateChart e c hstructure hc Γ l hl hgrid z v = + (QuotientGroup.mk (z * (basisHomeomorph e).symm v) : _ ⧸ Γ) := rfl + +theorem quotientCoordinateChart_source (z : NilpotentLieBCHGroup L s hnil) : + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid z).source = + {v : ι → ℝ | ∀ i, |v i| < bchInjectivityRadius s (Fintype.card ι) H l} := rfl + +theorem quotientCoordinateChart_target (z : NilpotentLieBCHGroup L s hnil) : + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid z).target = + (fun v : ι → ℝ => (QuotientGroup.mk (z * (basisHomeomorph e).symm v) : _ ⧸ Γ)) '' + {v : ι → ℝ | ∀ i, |v i| < bchInjectivityRadius s (Fintype.card ι) H l} := rfl + +theorem quotientCoordinateChart_center_mem (z : NilpotentLieBCHGroup L s hnil) : + (QuotientGroup.mk z : _ ⧸ Γ) ∈ (quotientCoordinateChart e c hstructure hc Γ l hl hgrid z).target := by + have hzero : (basisHomeomorph (hnil := hnil) e).symm 0 = 1 := by + apply (basisHomeomorph e).injective + simp only [Homeomorph.apply_symm_apply, basisHomeomorph_apply, coord_one, map_zero] + rw [quotientCoordinateChart_target] + refine ⟨0, ?_, ?_⟩ + · intro i + simpa only [Pi.zero_apply, abs_zero] using bchInjectivityRadius_pos s (Fintype.card ι) H l + · simp only [hzero, mul_one] + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct NNReal + +namespace NilpotentLieBCHGroup + +theorem quotient_covered_by_coordinate_box {ι L : Type*} [Fintype ι] + [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + {s : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (B : ℝ) + (hrep : ∀ g : NilpotentLieBCHGroup L s hnil, ∃ z, + (∀ i, |e.repr z.coord i| ≤ B) ∧ ∃ γ ∈ Γ, g = z * γ) : + ∀ x : NilpotentLieBCHGroup L s hnil ⧸ Γ, ∃ v : ι → ℝ, + (∀ i, |v i| ≤ B) ∧ (QuotientGroup.mk ((basisHomeomorph e).symm v) : _ ⧸ Γ) = x := by + intro x + induction x using Quotient.inductionOn with + | h g => + obtain ⟨z, hz, γ, hγ, hg⟩ := hrep g + refine ⟨basisHomeomorph e z, hz, ?_⟩ + rw [Homeomorph.symm_apply_apply, hg] + exact (quotient_mk_mul_mem Γ z ⟨γ, hγ⟩).symm + +end NilpotentLieBCHGroup + +theorem exists_realification_metric_partition_exp_bound (s a : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (e : Basis ι ℚ L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l H : ℕ) (p : ℝ) + (hl : 0 < l) (_hinner : scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ) + (houter : bchSubgroupCoordinates e Γ ⊆ denominatorGrid l), + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + ∀ r : ℝ≥0, 0 < r → 1 / (r : ℝ) ≤ Real.exp ((p + 2) ^ a) → + letI := realificationQuotientMetricSpace e Γ l hl houter + let Q := NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil) ⧸ + Γ.map NilpotentLieBCHGroup.realificationHom + ∃ n : ℕ, 0 < n ∧ (n : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + ∃ K : ℝ≥0, (K : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + ∃ c : Fin n → Q, ∃ ψ : Fin n → Q → ℝ, + (∀ i x, 0 ≤ ψ i x ∧ ψ i x ≤ 1) ∧ + (∀ x, ∑ i, ψ i x = 1) ∧ + (∀ i x, 2 * (r : ℝ) ≤ dist x (c i) → ψ i x = 0) ∧ + (∀ i, LipschitzWith K (ψ i)) := by + obtain ⟨C₀, hC₀, hrep⟩ := exists_realification_representatives_exp_bound s + obtain ⟨C, hC, hbudget⟩ := exists_bch_partition_input_exp_bound s a C₀ hC₀ + refine ⟨C + 8, by omega, ?_⟩ + intro ι L _ _ _ _ _ _ _ e hnil Γ l H p hl hinner houter hc hp hd hH hlp r hr hrp + let := realificationQuotientMetricSpace e Γ l hl houter + let B : ℝ≥0 := ⟨Real.exp ((p + C₀) ^ C₀), Real.exp_nonneg _⟩ + let K := bchBoxMetricConstant s (Fintype.card ι) H B + have hB1 : 1 ≤ B := Real.one_le_exp (by positivity) + obtain ⟨hBp, hKp, hrbound⟩ := hbudget (Fintype.card ι) H p hp hd hH + let f := fun v : ι → ℝ => + (QuotientGroup.mk ((NilpotentLieBCHGroup.basisHomeomorph + (hnil := realification_lowerCentralSeries_eq_bot hnil) (e.baseChange ℝ)).symm v) : + _ ⧸ Γ.map NilpotentLieBCHGroup.realificationHom) + have hf : LipschitzOnWith K f {v | ∀ i, |v i| ≤ B} := + NilpotentLieBCHGroup.lipschitzOn_quotient_basisHomeomorph_symm_box (e.baseChange ℝ) + (lieStructureConstants e) (fun i j k => (realLieBasis_structure e i j k).symm) hc + (Γ.map NilpotentLieBCHGroup.realificationHom) + (NilpotentLieBCHGroup.realification_subgroup_closed_discrete e Γ l hl houter).1 B hB1 + have hcover : ∀ x, ∃ v : ι → ℝ, (∀ i, |v i| ≤ B) ∧ f v = x := + NilpotentLieBCHGroup.quotient_covered_by_coordinate_box (e.baseChange ℝ) + (Γ.map NilpotentLieBCHGroup.realificationHom) B + (hrep e hnil Γ l H p hl hinner hc hp hd hH hlp) + simpa only [Nat.cast_add, Nat.cast_ofNat] using + exists_metric_partition_exp_bound f (Real.exp_pos _) hf hcover r hr C hC hp hd hBp hKp + (hrp.trans hrbound) + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Set Manifold +open scoped Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +variable (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + +@[instance_reducible] +noncomputable def quotientChartedSpace : ChartedSpace (ι → ℝ) (NilpotentLieBCHGroup L s hnil ⧸ Γ) where + atlas := Set.range (fun z => (quotientCoordinateChart e c hstructure hc Γ l hl hgrid z).symm) + chartAt := fun x => (quotientCoordinateChart e c hstructure hc Γ l hl hgrid x.out).symm + mem_chart_source := fun x => by + simpa only [OpenPartialHomeomorph.symm_source, QuotientGroup.out_eq'] using + quotientCoordinateChart_center_mem e c hstructure hc Γ l hl hgrid x.out + chart_mem_atlas := fun x => ⟨x.out, rfl⟩ + +theorem quotientChartedSpace_chartAt (x : NilpotentLieBCHGroup L s hnil ⧸ Γ) : + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + chartAt (ι → ℝ) x = (quotientCoordinateChart e c hstructure hc Γ l hl hgrid x.out).symm := rfl + +theorem quotientCoordinateChart_mem_atlas (z : NilpotentLieBCHGroup L s hnil) : + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid z).symm ∈ + atlas (ι → ℝ) (NilpotentLieBCHGroup L s hnil ⧸ Γ) := ⟨z, rfl⟩ + +theorem isManifold_quotient (n : ℕ∞ω) : + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + IsManifold 𝓘(ℝ, ι → ℝ) n (NilpotentLieBCHGroup L s hnil ⧸ Γ) := by + let := quotientChartedSpace e c hstructure hc Γ l hl hgrid + apply isManifold_of_contDiffOn + intro φ ψ hφ hψ + obtain ⟨z, rfl⟩ := hφ + obtain ⟨w, rfl⟩ := hψ + simpa only [OpenPartialHomeomorph.symm_symm, modelWithCornersSelf_coe, + modelWithCornersSelf_coe_symm, Function.id_comp, Function.comp_id, + preimage_id, range_id, inter_univ] using + contDiffOn_quotient_chart_transition e Γ z w + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid z) + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid w) + (quotientCoordinateChart_apply e c hstructure hc Γ l hl hgrid z) + (quotientCoordinateChart_apply e c hstructure hc Γ l hl hgrid w) n + +theorem contMDiff_quotient_mk (n : ℕ∞ω) : + letI := basisChartedSpace (hnil := hnil) e + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + ContMDiff 𝓘(ℝ, ι → ℝ) 𝓘(ℝ, ι → ℝ) n + (QuotientGroup.mk : NilpotentLieBCHGroup L s hnil → _ ⧸ Γ) := by + let : FiniteDimensional ℝ L := e.finiteDimensional_of_finite + let := basisChartedSpace (hnil := hnil) e + let := quotientChartedSpace e c hstructure hc Γ l hl hgrid + intro g + apply contMDiffAt_iff_target.mpr + refine ⟨QuotientGroup.continuous_mk.continuousAt, ?_⟩ + have h := contMDiffAt_quotient_chartInverse e Γ (QuotientGroup.mk g : _ ⧸ Γ).out + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid (QuotientGroup.mk g : _ ⧸ Γ).out) + (quotientCoordinateChart_apply e c hstructure hc Γ l hl hgrid _) n g + (by simpa only [QuotientGroup.out_eq'] using + quotientCoordinateChart_center_mem e c hstructure hc Γ l hl hgrid (QuotientGroup.mk g : _ ⧸ Γ).out) + simpa only [extChartAt, OpenPartialHomeomorph.extend, PartialEquiv.coe_trans, + ModelWithCorners.toPartialEquiv_coe, OpenPartialHomeomorph.coe_toPartialEquiv, + modelWithCornersSelf_coe, Function.id_comp, quotientChartedSpace_chartAt, + Function.comp_def, Function.id_def] using h + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem exists_realification_open_charts_exp_bound (s : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (e : Basis ι ℚ L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l H : ℕ) (p : ℝ), + 0 < l → bchSubgroupCoordinates e Γ ⊆ denominatorGrid l → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + let G := NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil) + let ΓR : Subgroup G := Γ.map NilpotentLieBCHGroup.realificationHom + ∃ r : ℝ, 0 < r ∧ r ≤ 1 ∧ 1 / r ≤ Real.exp ((p + D) ^ D) ∧ + ∃ φ : G → OpenPartialHomeomorph (ι → ℝ) (G ⧸ ΓR), + (∀ z v, φ z v = (QuotientGroup.mk + (z * (NilpotentLieBCHGroup.basisHomeomorph (e.baseChange ℝ)).symm v) : G ⧸ ΓR)) ∧ + (∀ z, (φ z).source = {v | ∀ i, |v i| < r}) ∧ + (∀ z, (QuotientGroup.mk z : G ⧸ ΓR) ∈ (φ z).target) := by + obtain ⟨D, hD, hbudget⟩ := exists_bchInjectivityRadius_inv_exp_bound s + refine ⟨D, hD, ?_⟩ + intro ι L _ _ _ _ _ _ _ e hnil Γ l H p hl houter hc hp hd hH hlp + let ΓR := Γ.map NilpotentLieBCHGroup.realificationHom + have hgrid := NilpotentLieBCHGroup.realification_subgroup_grid e Γ l houter + have hstructure := fun i j k => (realLieBasis_structure e i j k).symm + refine ⟨bchInjectivityRadius s (Fintype.card ι) H l, + bchInjectivityRadius_pos _ _ _ _, bchInjectivityRadius_le_one _ _ _ _, + hbudget _ _ _ _ hp hd hH hlp, + NilpotentLieBCHGroup.quotientCoordinateChart (e.baseChange ℝ) (lieStructureConstants e) + hstructure hc ΓR l hl hgrid, ?_, ?_, ?_⟩ + · exact NilpotentLieBCHGroup.quotientCoordinateChart_apply _ _ _ _ _ _ _ _ + · exact NilpotentLieBCHGroup.quotientCoordinateChart_source _ _ _ _ _ _ _ _ + · exact NilpotentLieBCHGroup.quotientCoordinateChart_center_mem _ _ _ _ _ _ _ _ + +end Erdos3 + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module +open scoped NNReal + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem inv_mul_coordinates_bound + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (u v : NilpotentLieBCHGroup L s hnil) {B δ : ℝ} (hB : 1 ≤ B) (hδ : 0 ≤ δ) + (hu : ∀ i, |e.repr u.coord i| ≤ B) (hv : ∀ i, |e.repr v.coord i| ≤ B) + (huv : ∀ i, |e.repr u.coord i - e.repr v.coord i| ≤ δ) (k : ι) : + |e.repr (u⁻¹ * v).coord k| ≤ bchBoxCoordinateBound s (Fintype.card ι) H B * δ := by + simpa only [coord_mul, coord_inv, neg_neg] using + lieBCH_sub_coordinates_bound e c hstructure hc hnil (-u.coord) (-v.coord) hB hδ + (fun i => by simpa only [map_neg, Finsupp.neg_apply, abs_neg] using hu i) + (fun i => by simpa only [map_neg, Finsupp.neg_apply, abs_neg] using hv i) + (fun i => by simpa only [map_neg, Finsupp.neg_apply, neg_sub_neg, abs_sub_comm] using huv i) k + +variable [TopologicalSpace L] [IsTopologicalAddGroup L] [ContinuousSMul ℝ L] [T2Space L] + +theorem finite_quotient_coordinate_cover + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (B : ℝ) (hB : 1 ≤ B) + (hrep : ∀ g : NilpotentLieBCHGroup L s hnil, ∃ z, + (∀ i, |e.repr z.coord i| ≤ B) ∧ ∃ γ ∈ Γ, g = z * γ) + (r : ℝ) (hr : 0 < r) : + let K : ℝ≥0 := ⟨bchBoxCoordinateBound s (Fintype.card ι) H B, + bchBoxCoordinateBound_nonneg _ _ _ (by linarith)⟩ + let n := (boxCoverMeshCount B K (r / 2) + 1) ^ Fintype.card ι + ∃ centers : Fin n → NilpotentLieBCHGroup L s hnil, + (∀ j i, |e.repr (centers j).coord i| ≤ B) ∧ + ∀ x : NilpotentLieBCHGroup L s hnil ⧸ Γ, ∃ j, ∃ u : ι → ℝ, + (∀ i, |u i| ≤ r / 2) ∧ + (QuotientGroup.mk (centers j * (basisHomeomorph e).symm u) : _ ⧸ Γ) = x := by + classical + let K : ℝ≥0 := ⟨bchBoxCoordinateBound s (Fintype.card ι) H B, + bchBoxCoordinateBound_nonneg _ _ _ (by linarith)⟩ + let N := boxCoverMeshCount B K (r / 2) + let n := (N + 1) ^ Fintype.card ι + let I := ι → Fin (N + 1) + have hN : 0 < N := boxCoverMeshCount_pos _ _ _ + have hcard : Fintype.card I = n := by simp [I, n] + let reindex : I ≃ Fin n := Fintype.equivFinOfCardEq hcard + let centers : Fin n → NilpotentLieBCHGroup L s hnil := fun j => + (basisHomeomorph e).symm (uniformBoxGrid B N (reindex.symm j)) + have hcenters (j : Fin n) : e.equivFun (centers j).coord = uniformBoxGrid B N (reindex.symm j) := + (basisHomeomorph (hnil := hnil) e).apply_symm_apply _ + have hcentersB (j i) : |e.repr (centers j).coord i| ≤ B := by + have := uniformBoxGrid_mem (ι := ι) (by linarith : 0 ≤ B) hN (reindex.symm j) i + simpa only [← hcenters j, Basis.equivFun_apply] using this + refine ⟨centers, hcentersB, ?_⟩ + intro x + obtain ⟨v, hv, hvx⟩ := quotient_covered_by_coordinate_box e Γ B hrep x + obtain ⟨k, hk⟩ := exists_uniformBoxGrid_approx (by linarith : 0 < B) hN v hv + let j := reindex k + let g := (basisHomeomorph (hnil := hnil) e).symm v + have hgv : e.equivFun g.coord = v := (basisHomeomorph (hnil := hnil) e).apply_symm_apply v + have hgB (i) : |e.repr g.coord i| ≤ B := by + simpa only [← hgv, Basis.equivFun_apply] using hv i + have hdiff (i) : |e.repr (centers j).coord i - e.repr g.coord i| ≤ 2 * B / N := by + have hi := (dist_pi_le_iff (by positivity : 0 ≤ 2 * B / (N : ℝ))).mp hk i + have hj : reindex.symm j = k := reindex.symm_apply_apply k + have hci : e.repr (centers j).coord i = uniformBoxGrid B N k i := by + simpa only [Basis.equivFun_apply, hj] using congrFun (hcenters j) i + have hgi : e.repr g.coord i = v i := by + simpa only [Basis.equivFun_apply] using congrFun hgv i + simpa only [Real.dist_eq, ← hci, ← hgi, abs_sub_comm] using hi + have herror : (K : ℝ) * (2 * B / N) ≤ r / 2 := boxCoverMeshCount_error K (by linarith) + have hsmall (i) : |e.repr ((centers j)⁻¹ * g).coord i| ≤ r / 2 := + (inv_mul_coordinates_bound e c hstructure hc (centers j) g hB + (by positivity) (hcentersB j) hgB hdiff i).trans herror + refine ⟨j, basisHomeomorph e ((centers j)⁻¹ * g), hsmall, ?_⟩ + simp only [Homeomorph.symm_apply_apply, mul_inv_cancel_left] + exact hvx + +theorem finite_quotient_coordinate_chart_cover + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + (B : ℝ) (hB : 1 ≤ B) + (hrep : ∀ g : NilpotentLieBCHGroup L s hnil, ∃ z, + (∀ i, |e.repr z.coord i| ≤ B) ∧ ∃ γ ∈ Γ, g = z * γ) : + let r := bchInjectivityRadius s (Fintype.card ι) H l + let K : ℝ≥0 := ⟨bchBoxCoordinateBound s (Fintype.card ι) H B, + bchBoxCoordinateBound_nonneg _ _ _ (by linarith)⟩ + let n := (boxCoverMeshCount B K (r / 2) + 1) ^ Fintype.card ι + ∃ centers : Fin n → NilpotentLieBCHGroup L s hnil, + (∀ j i, |e.repr (centers j).coord i| ≤ B) ∧ + ∀ x : NilpotentLieBCHGroup L s hnil ⧸ Γ, ∃ j, + x ∈ (quotientCoordinateChart e c hstructure hc Γ l hl hgrid (centers j)).target := by + let r := bchInjectivityRadius s (Fintype.card ι) H l + have hr : 0 < r := bchInjectivityRadius_pos _ _ _ _ + obtain ⟨centers, hcenters, hcover⟩ := + finite_quotient_coordinate_cover e c hstructure hc Γ B hB hrep r hr + refine ⟨centers, hcenters, ?_⟩ + intro x + obtain ⟨j, u, hu, heq⟩ := hcover x + refine ⟨j, ?_⟩ + rw [quotientCoordinateChart_target] + exact ⟨u, fun i => (hu i).trans_lt (by linarith), heq⟩ + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3.NilpotentLieBCHGroup + +open Module Set Manifold +open scoped Manifold ContDiff + +variable {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] [LieAlgebra ℝ L] + [IsScalarTower ℚ ℝ L] [TopologicalSpace L] [IsTopologicalAddGroup L] + [ContinuousSMul ℝ L] [T2Space L] + {s H : ℕ} {hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥} + +theorem quotient_chart_transition_mem_contDiffGroupoid + (e : Basis ι ℝ L) (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) + (z w : NilpotentLieBCHGroup L s hnil) (φ ψ : OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ)) + (hφ : ∀ v, φ v = QuotientGroup.mk (z * (basisHomeomorph e).symm v)) + (hψ : ∀ v, ψ v = QuotientGroup.mk (w * (basisHomeomorph e).symm v)) (n : ℕ∞ω) : + φ.trans ψ.symm ∈ contDiffGroupoid n 𝓘(ℝ, ι → ℝ) := by + simp only [contDiffGroupoid, mem_groupoid_of_pregroupoid, contDiffPregroupoid, + modelWithCornersSelf_coe, modelWithCornersSelf_coe_symm, Function.id_comp, Function.comp_id, + preimage_id, range_id, inter_univ] + constructor + · exact contDiffOn_quotient_chart_transition e Γ z w φ ψ hφ hψ n + · exact contDiffOn_quotient_chart_transition e Γ w z ψ φ hψ hφ n + +theorem quotient_chart_mem_maximalAtlas + (e : Basis ι ℝ L) (c : ι → ι → ι → ℚ) + (hstructure : ∀ i j k, algebraMap ℚ ℝ (c i j k) = e.repr ⁅e i, e j⁆ k) + (hc : ∀ i j k, RationalHeightLE (c i j k) H) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l : ℕ) (hl : 0 < l) + (hgrid : ∀ g ∈ Γ, e.equivFun g.coord ∈ realDenominatorGrid l) + (z : NilpotentLieBCHGroup L s hnil) (φ : OpenPartialHomeomorph (ι → ℝ) (_ ⧸ Γ)) + (hφ : ∀ v, φ v = QuotientGroup.mk (z * (basisHomeomorph e).symm v)) (n : ℕ∞ω) : + letI := quotientChartedSpace e c hstructure hc Γ l hl hgrid + φ.symm ∈ IsManifold.maximalAtlas 𝓘(ℝ, ι → ℝ) n (NilpotentLieBCHGroup L s hnil ⧸ Γ) := by + let := quotientChartedSpace e c hstructure hc Γ l hl hgrid + intro ψ hψ + obtain ⟨w, rfl⟩ := hψ + constructor + · simpa only [OpenPartialHomeomorph.symm_symm] using + quotient_chart_transition_mem_contDiffGroupoid e Γ z w φ + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid w) hφ + (quotientCoordinateChart_apply e c hstructure hc Γ l hl hgrid w) n + · simpa only [OpenPartialHomeomorph.symm_symm] using + quotient_chart_transition_mem_contDiffGroupoid e Γ w z + (quotientCoordinateChart e c hstructure hc Γ l hl hgrid w) φ + (quotientCoordinateChart_apply e c hstructure hc Γ l hl hgrid w) hφ n + +end Erdos3.NilpotentLieBCHGroup + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem exists_bch_chart_cover_exp_bound (s C₀ : ℕ) (hC₀ : 2 ≤ C₀) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ (d H l : ℕ) (p : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + let B := Real.exp ((p + C₀) ^ C₀) + let r := bchInjectivityRadius s d H l + let K : ℝ≥0 := ⟨bchBoxCoordinateBound s d H B, + bchBoxCoordinateBound_nonneg _ _ _ (Real.exp_nonneg _)⟩ + (((boxCoverMeshCount B K (r / 2) + 1) ^ d : ℕ) : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + B ≤ Real.exp ((p + D) ^ D) ∧ 1 / r ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C₁, hC₁, hinput⟩ := exists_bch_partition_input_exp_bound s 0 C₀ hC₀ + obtain ⟨C₂, hC₂, hradius⟩ := exists_bchInjectivityRadius_inv_exp_bound s + let C := C₁ + C₂ + 5 + have hC : 2 ≤ C := by dsimp [C]; omega + refine ⟨C + 5, by omega, ?_⟩ + intro d H l p hp hd hH hl + let B := Real.exp ((p + C₀) ^ C₀) + let r := bchInjectivityRadius s d H l + let K : ℝ≥0 := ⟨bchBoxCoordinateBound s d H B, + bchBoxCoordinateBound_nonneg _ _ _ (Real.exp_nonneg _)⟩ + have hr : 0 < r := bchInjectivityRadius_pos _ _ _ _ + obtain ⟨hB, hmetric, _⟩ := hinput d H p hp hd hH + have hshift₁ := Real.exp_le_exp.mpr + (shifted_power_self_mono (C := C₁) (D := C) hp (by omega) (by dsimp [C]; omega)) + have hBC : B ≤ Real.exp ((p + C) ^ C) := hB.trans hshift₁ + have hKC : (K : ℝ) ≤ Real.exp ((p + C) ^ C) := by + apply le_trans ?_ (hmetric.trans hshift₁) + change bchBoxCoordinateBound s d H B ≤ ((d : ℝ) + 1) * bchBoxCoordinateBound s d H B + have := bchBoxCoordinateBound_nonneg s d H (Real.exp_nonneg ((p + C₀) ^ C₀)) + nlinarith [Nat.cast_nonneg (α := ℝ) d] + have hthree := metricPartition_constant_power_budget C₂ 1 hC₂ ⟨r, hr.le⟩ hp + (by simpa only [Nat.cast_one] using Real.one_le_exp (by positivity : 0 ≤ (p + C₂) ^ C₂)) + (hradius d H l p hp hd hH hl) + have hhalf : 1 / (r / 2) ≤ Real.exp ((p + (C₂ + 3 : ℕ)) ^ (C₂ + 3)) := by + have ht : 3 / r ≤ Real.exp ((p + (C₂ + 3 : ℕ)) ^ (C₂ + 3)) := by + norm_num at hthree ⊢ + exact hthree + apply le_trans ?_ ht + rw [show 1 / (r / 2) = 2 / r by ring] + exact div_le_div_of_nonneg_right (by norm_num) hr.le + have hhalfC := hhalf.trans (Real.exp_le_exp.mpr + (shifted_power_self_mono (C := C₂ + 3) (D := C) hp (by omega) (by dsimp [C]; omega))) + have hfinal := Real.exp_le_exp.mpr + (shifted_power_self_mono (C := C) (D := C + 5) hp (by omega) (by omega)) + refine ⟨?_, hBC.trans hfinal, ?_⟩ + · simpa only [Nat.cast_add, Nat.cast_ofNat] using + boxCoverCount_le_exp C d hC K (Real.exp_nonneg _) (by linarith) hp hd hBC hKC hhalfC + · apply le_trans ?_ (hhalfC.trans hfinal) + exact div_le_div_of_nonneg_left (by norm_num) (by linarith : 0 < r / 2) (by linarith) + +end Erdos3 + +end + +section + +namespace Erdos3 + +open scoped NNReal + +theorem half_radius_inverse_power_bound (C : ℕ) (hC : 2 ≤ C) {r p : ℝ} + (hr : 0 < r) (hp : 0 ≤ p) (hri : 1 / r ≤ Real.exp ((p + C) ^ C)) : + 1 / (r / 2) ≤ Real.exp ((p + (C + 3 : ℕ)) ^ (C + 3)) := by + have h := metricPartition_constant_power_budget C 1 hC ⟨r, hr.le⟩ hp + (by simpa only [Nat.cast_one] using Real.one_le_exp (by positivity : 0 ≤ (p + C) ^ C)) hri + have hthree : 3 / r ≤ Real.exp ((p + (C + 3 : ℕ)) ^ (C + 3)) := by + norm_num at h ⊢ + exact h + apply le_trans ?_ hthree + rw [show 1 / (r / 2) = 2 / r by ring] + exact div_le_div_of_nonneg_right (by norm_num) hr.le + +theorem shifted_center_power_bound (A B : ℕ) {p : ℝ} (hp : 0 ≤ p) : + ((p + A) + B) ^ B ≤ (p + (A + B + 2 : ℕ)) ^ (A + B + 2) := by + have hbase : (p + A) + B ≤ p + (A + B + 2 : ℕ) := by push_cast; linarith + apply (pow_le_pow_left₀ (by positivity) hbase B).trans + exact pow_le_pow_right₀ + (by push_cast; linarith [Nat.cast_nonneg (α := ℝ) A, Nat.cast_nonneg (α := ℝ) B]) (by omega) + +theorem exists_bch_flexible_cover_exp_bound (s C₀ Cᵣ : ℕ) (hC₀ : 2 ≤ C₀) (hCᵣ : 2 ≤ Cᵣ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ (d H : ℕ) (p r : ℝ), + 0 ≤ p → (d : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → + 0 < r → 1 / r ≤ Real.exp ((p + Cᵣ) ^ Cᵣ) → + let B := Real.exp ((p + C₀) ^ C₀) + let K : ℝ≥0 := ⟨bchBoxCoordinateBound s d H B, + bchBoxCoordinateBound_nonneg _ _ _ (Real.exp_nonneg _)⟩ + (((boxCoverMeshCount B K (r / 2) + 1) ^ d : ℕ) : ℝ) ≤ Real.exp ((p + D) ^ D) := by + obtain ⟨C₁, hC₁, hinput⟩ := exists_bch_partition_input_exp_bound s 0 C₀ hC₀ + let C := C₁ + Cᵣ + 5 + have hC : 2 ≤ C := by dsimp [C]; omega + refine ⟨C + 5, by omega, ?_⟩ + intro d H p r hp hd hH hr hri + let B := Real.exp ((p + C₀) ^ C₀) + let K : ℝ≥0 := ⟨bchBoxCoordinateBound s d H B, + bchBoxCoordinateBound_nonneg _ _ _ (Real.exp_nonneg _)⟩ + obtain ⟨hB, hmetric, _⟩ := hinput d H p hp hd hH + have hshift := Real.exp_le_exp.mpr + (shifted_power_self_mono (C := C₁) (D := C) hp (by omega) (by dsimp [C]; omega)) + have hBC := hB.trans hshift + have hKC : (K : ℝ) ≤ Real.exp ((p + C) ^ C) := + (bchBoxCoordinateBound_le_bchBoxMetricConstant s d H ⟨B, Real.exp_nonneg _⟩).trans + (hmetric.trans hshift) + have hhalf := (half_radius_inverse_power_bound Cᵣ hCᵣ hr hp hri).trans + (Real.exp_le_exp.mpr (shifted_power_self_mono (C := Cᵣ + 3) (D := C) + hp (by omega) (by dsimp [C]; omega))) + simpa only [Nat.cast_add, Nat.cast_ofNat] using + boxCoverCount_le_exp C d hC K (Real.exp_nonneg _) (by linarith) hp hd hBC hKC hhalf + +end Erdos3 + +end + +section + +namespace Erdos3 + +open Module +open scoped TensorProduct + +theorem exists_realification_finite_atlas_exp_bound (s : ℕ) : + ∃ D : ℕ, 2 ≤ D ∧ ∀ {ι L : Type*} [Fintype ι] [LieRing L] [LieAlgebra ℚ L] + [TopologicalSpace (ℝ ⊗[ℚ] L)] [IsTopologicalAddGroup (ℝ ⊗[ℚ] L)] + [ContinuousSMul ℝ (ℝ ⊗[ℚ] L)] [T2Space (ℝ ⊗[ℚ] L)] + (e : Basis ι ℚ L) (hnil : LieModule.lowerCentralSeries ℚ L L s = ⊥) + (Γ : Subgroup (NilpotentLieBCHGroup L s hnil)) (l H : ℕ) (p : ℝ), + 0 < l → scaledIntegerGrid l ⊆ bchSubgroupCoordinates e Γ → + bchSubgroupCoordinates e Γ ⊆ denominatorGrid l → + (∀ i j k, RationalHeightLE (lieStructureConstants e i j k) H) → + 0 ≤ p → (Fintype.card ι : ℝ) ≤ p → (H : ℝ) ≤ Real.exp p → (l : ℝ) ≤ Real.exp p → + let G := NilpotentLieBCHGroup (ℝ ⊗[ℚ] L) s (realification_lowerCentralSeries_eq_bot hnil) + let ΓR : Subgroup G := Γ.map NilpotentLieBCHGroup.realificationHom + ∃ r : ℝ, 0 < r ∧ r ≤ 1 ∧ 1 / r ≤ Real.exp ((p + D) ^ D) ∧ + ∃ n : ℕ, 0 < n ∧ (n : ℝ) ≤ Real.exp ((p + D) ^ D) ∧ + ∃ centers : Fin n → G, ∃ φ : Fin n → OpenPartialHomeomorph (ι → ℝ) (G ⧸ ΓR), + (∀ j i, |(e.baseChange ℝ).repr (centers j).coord i| ≤ Real.exp ((p + D) ^ D)) ∧ + (∀ j v, φ j v = (QuotientGroup.mk + (centers j * (NilpotentLieBCHGroup.basisHomeomorph (e.baseChange ℝ)).symm v) : G ⧸ ΓR)) ∧ + (∀ j, (φ j).source = {v | ∀ i, |v i| < r}) ∧ + (∀ x : G ⧸ ΓR, ∃ j, x ∈ (φ j).target) := by + obtain ⟨C₀, hC₀, hrep⟩ := exists_realification_representatives_exp_bound s + obtain ⟨D, hD, hbudget⟩ := exists_bch_chart_cover_exp_bound s C₀ hC₀ + refine ⟨D, hD, ?_⟩ + intro ι L _ _ _ _ _ _ _ e hnil Γ l H p hl hinner houter hc hp hd hH hlp + let ΓR := Γ.map NilpotentLieBCHGroup.realificationHom + have hgrid := NilpotentLieBCHGroup.realification_subgroup_grid e Γ l houter + have hstructure := fun i j k => (realLieBasis_structure e i j k).symm + let B := Real.exp ((p + C₀) ^ C₀) + have hB : 1 ≤ B := Real.one_le_exp (by positivity) + obtain ⟨hn, hBbound, hrbound⟩ := hbudget (Fintype.card ι) H l p hp hd hH hlp + obtain ⟨centers, hcenters, hcover⟩ := + NilpotentLieBCHGroup.finite_quotient_coordinate_chart_cover + (e.baseChange ℝ) (lieStructureConstants e) hstructure hc ΓR l hl hgrid B hB + (hrep e hnil Γ l H p hl hinner hc hp hd hH hlp) + refine ⟨bchInjectivityRadius s (Fintype.card ι) H l, + bchInjectivityRadius_pos _ _ _ _, bchInjectivityRadius_le_one _ _ _ _, hrbound, + _, by positivity, hn, centers, + (fun j => NilpotentLieBCHGroup.quotientCoordinateChart (e.baseChange ℝ) (lieStructureConstants e) + hstructure hc ΓR l hl hgrid (centers j)), ?_, ?_, ?_, hcover⟩ + · exact fun j i => (hcenters j i).trans hBbound + · exact fun j => NilpotentLieBCHGroup.quotientCoordinateChart_apply _ _ _ _ _ _ _ _ (centers j) + · exact fun j => NilpotentLieBCHGroup.quotientCoordinateChart_source _ _ _ _ _ _ _ _ (centers j) + +end Erdos3 + +end + +end OAI